hip_filename
stringlengths
5
84
hip_content
stringlengths
79
9.69M
cuda_filename
stringlengths
4
83
cuda_content
stringlengths
19
9.69M
6491088b0edf8e2e285fadec755193a750068c19.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include "kernel.h" #define TX 32 #define TY 32 #define DIM 2100 struct hipComplex { float r; float i; __device__ hipComplex( float a, float b ) : r(a), i(b) {} __device__ float magnitude2( void ) { return r * r + i * i; } __device__ hipComplex operator*(const hipComplex& a) { return hipComplex(r*a.r - i*a.i, i*a.r + r*a.i); } __device__ hipComplex operator-(const hipComplex& a) { return hipComplex(r-a.r, i-a.i); } __device__ hipComplex operator+(const hipComplex& a) { return hipComplex(r+a.r, i+a.i); } __device__ hipComplex operator/(const hipComplex& a) { return hipComplex((r*a.r + i*a.i)/(a.r*a.r + a.i*a.i), (i*a.r - r*a.i)/(a.r*a.r + a.i*a.i)); } }; __device__ hipComplex conj(hipComplex m) { hipComplex out(m.r,-m.i); return out; } __device__ hipComplex nor(hipComplex m) { hipComplex out(m.r*m.r+m.i*m.i,0.0); return out; } __device__ float norg(hipComplex m) { return sqrtf(m.r*m.r+m.i*m.i); } __device__ hipComplex qpoch(hipComplex a, hipComplex q) { hipComplex out(1.0,0.0); hipComplex unity(1.0,0.0); int i = 0; hipComplex Q = q; if(q.magnitude2()>1.0) { return hipComplex(0.0,0.0); } // We want to formally match the definition of a q-pochhammer symbol. for(i=1;i<80;i++) { out = out * (unity - a*Q); Q = q * Q; } return out; } __device__ hipComplex qp(hipComplex a, hipComplex q, int n) { hipComplex out(1.0,0.0); hipComplex unity(1.0,0.0); int i = 0; hipComplex Q = q; if(q.magnitude2()>1.0) { return hipComplex(0.0,0.0); } // We want to formally match the definition of a q-pochhammer symbol. for(i=1;i<n;i++) { out = out * (unity - a*Q); Q = q * Q; } return out; } __device__ hipComplex ramphi(hipComplex q) { hipComplex out(1.0,0.0); hipComplex mone(-1.0,0.0); hipComplex mq = mone*q; return qpoch(mq,mq)/qpoch(q,mq); } __device__ hipComplex rampsi(hipComplex q) { hipComplex out(1.0,0.0); hipComplex mone(-1.0,0.0); hipComplex mq = mone*q; return qpoch(mq,q)*qpoch(q*q,q*q); } __device__ hipComplex ramchi(hipComplex q) { hipComplex out(1.0,0.0); hipComplex mone(-1.0,0.0); hipComplex mq = mone*q; return qpoch(mq,q*q); } __device__ hipComplex ramf(hipComplex a, hipComplex b) { hipComplex out(1.0,0.0); hipComplex mone(-1.0,0.0); hipComplex ma = mone*a; hipComplex mb = mone*b; return qpoch(ma,a*b)*qpoch(mb,a*b)*qpoch(a*b,a*b); } // complex exponential __device__ hipComplex expc(hipComplex m) { hipComplex out(expf(m.r) * cosf(m.i),expf(m.r) * sinf(m.i)); return out; } __device__ hipComplex powc(hipComplex ag, hipComplex bg) { hipComplex out(0.0,0.0); hipComplex mesp(0.0,0.0); hipComplex frim(0.0,0.0); double radiu, thet; /* get the proper polar form of the complex number */ radiu = sqrtf(ag.r*ag.r + ag.i*ag.i); thet = atan2f(ag.i,ag.r); /* mesp gives R^(c+di) */ mesp.r = powf(radiu,bg.r)*cosf(bg.i*logf(radiu)); mesp.i = powf(radiu,bg.r)*sinf(bg.i*logf(radiu)); /* frim gives e^(i theta (c+di)) */ /* now since we already have the machinery for performing complex exponentiation (just exp), we can just call that here */ frim.r = -1.0 * bg.i * thet; frim.i = bg.r * thet; frim = expc(frim); out = mesp*frim; return out; } // cosine (nothing algorithmically clean) __device__ hipComplex cosc(hipComplex m) { hipComplex ai(0.0,1.0); hipComplex ot(0.5,0.0); hipComplex mone(-1.0,0.0); hipComplex out = ot*(expc(m*ai) + expc(mone*m*ai)); return out; } __device__ hipComplex sins(hipComplex m) { hipComplex ai(0.0,1.0); hipComplex ot(0.0,0.5); hipComplex mone(-1.0,0.0); hipComplex out = ot*(expc(m*ai) - expc(mone*m*ai)); return out; } __device__ hipComplex tans(hipComplex m) { return sins(m)/cosc(m); } __device__ hipComplex moeb(hipComplex t, hipComplex a, hipComplex z) { hipComplex out(0.0,0.0); hipComplex ai(0.0,1.0); hipComplex unity(1.0,0.0); out = expc(ai*t) * (z-a)/(unity-conj(a)*z); return out; } __device__ hipComplex bnewt(hipComplex z) { hipComplex three(3.0,0.0); hipComplex unity(1.0,0.0); hipComplex out(0.0,0.0); hipComplex Z =z; hipComplex L(0.0,0.0); hipComplex R(0.62348980185873359,0.7818314824680298); hipComplex v(0.62348980185873359,0.7818314824680298); int i; for(i=0;i<100;i++) { L = sins(expc(Z)-cosc(Z))-Z; out = out + v*L; v = R * v; Z = Z - L/((expc(Z)+sins(Z))*cosc(expc(Z)-cosc(Z))-unity); } return out; } __device__ hipComplex they3(hipComplex z, hipComplex q) { int u; hipComplex out(0.0,0.0); hipComplex enn(-20.0,0.0); hipComplex onn(1.0,0.0); hipComplex dui(0.0,1.0); for(u=-20;u<20;u++) { out = out + powc(q,enn*enn)*expc(dui*enn*z); enn = enn + onn; } return out; } __device__ hipComplex wahi(hipComplex z) { int u; hipComplex un(1.0,0.0); hipComplex ne(1.0,0.0); hipComplex out(0.0,0.0); for(u=1;u<40;u++) { out = out + powc(z/ne,ne); ne = ne + un; } out = out + un; return out; } __device__ hipComplex dwahi(hipComplex z) { int u; hipComplex un(1.0,0.0); hipComplex ne(1.0,0.0); hipComplex out(0.0,0.0); for(u=1;u<40;u++) { out = out + powc(z/ne,ne-un); ne = ne + un; } return out; } __device__ hipComplex they3p(hipComplex z, hipComplex q) { int u; hipComplex out(0.0,0.0); hipComplex enn(-20.0,0.0); hipComplex onn(1.0,0.0); hipComplex dui(0.0,1.0); for(u=-20;u<20;u++) { out = out + (enn*enn)*powc(q,enn*enn-onn)*expc(dui*enn*z); enn = enn + onn; } return out; } __device__ hipComplex h3ey3p(hipComplex z, hipComplex q) { int u; hipComplex out(0.0,0.0); hipComplex aut(0.0,0.0); hipComplex enn(-20.0,0.0); hipComplex onn(1.0,0.0); hipComplex dui(0.0,1.0); hipComplex vel(0.0,0.0); hipComplex rav(0.0,0.0); for(u=-40;u<40;u++) { vel = expc(dui*enn*z); rav = powc(q,enn*enn); aut = aut + (enn*enn)*rav/q*vel; out = out + rav*vel; enn = enn + onn; } return out/aut; } __device__ hipComplex thess(hipComplex z, hipComplex q) { int v; hipComplex unity(1.0,0.0); hipComplex out(1.0,0.0); hipComplex tw(2.0,0.0); hipComplex qoo(1.0,0.0); for(v=0;v<10;v++) { qoo = qoo * q * q; out = out * (unity - qoo) * (unity + tw * qoo/q * cosc(tw*z) + qoo*qoo/(q*q)); } return out; } __device__ hipComplex the1(hipComplex z, hipComplex q) { int v; hipComplex unity(1.0,0.0); hipComplex out(1.0,0.0); hipComplex tw(2.0,0.0); hipComplex qoo(1.0,0.0); hipComplex rt(0.25,0.0); for(v=0;v<10;v++) { qoo = qoo * q * q; out = out * (unity - qoo) * (unity + tw * qoo/q * cosc(tw*z) + qoo*qoo/(q*q)); } return tw*out*powc(q,rt)*sins(z); } __device__ hipComplex the2(hipComplex z, hipComplex q) { int v; hipComplex unity(1.0,0.0); hipComplex out(1.0,0.0); hipComplex tw(2.0,0.0); hipComplex qoo(1.0,0.0); hipComplex rt(0.25,0.0); for(v=0;v<10;v++) { qoo = qoo * q * q; out = out * (unity - qoo) * (unity - tw * qoo/q * cosc(tw*z) + qoo*qoo/(q*q)); } return tw*out*powc(q,rt)*cosc(z); } __device__ hipComplex the3(hipComplex z, hipComplex q) { int v; hipComplex unity(1.0,0.0); hipComplex out(1.0,0.0); hipComplex tw(2.0,0.0); hipComplex qoo(1.0,0.0); for(v=0;v<10;v++) { qoo = qoo * q * q; out = out * (unity - qoo) * (unity + tw * qoo/q * cosc(tw*z) + qoo*qoo/(q*q)); } return out; } __device__ hipComplex the4(hipComplex z, hipComplex q) { int v; hipComplex unity(1.0,0.0); hipComplex out(1.0,0.0); hipComplex tw(2.0,0.0); hipComplex qoo(1.0,0.0); for(v=0;v<10;v++) { qoo = qoo * q * q; out = out * (unity - qoo) * (unity - tw * qoo/q * cosc(tw*z) + qoo*qoo/(q*q)); } return out; } /* routine to generate q-integers */ __device__ hipComplex qin(hipComplex a, hipComplex q) { hipComplex unity(1.0,0.0); hipComplex out(1.0,0.0); out = (unity - powc(q, a))/(unity-q); return out; } /* generating function for n^2 */ __device__ hipComplex geffa(hipComplex z, hipComplex q) { hipComplex out(0.0,0.0); hipComplex unity(1.0,0.0); hipComplex wu(0.0,0.0); hipComplex Z=unity; int v; for(v=0;v<20;v++) { out = out + qin(wu*wu,q)* Z; wu = wu + unity; Z = z * Z; } return out; } __device__ hipComplex thratd(hipComplex z, hipComplex q) { int n; hipComplex fau(4.0,0.0); hipComplex too(2.0,0.0); hipComplex unity(1.0,0.0); hipComplex ennn(1.0,0.0); hipComplex ni(-1.0,0.0); hipComplex noo(-1.0,0.0); hipComplex out(0.0,0.0); hipComplex loo = q; hipComplex qoo =q*q; for(n=0;n<80;n++) { out = out + noo*(loo/(unity-qoo))*sins(too*ennn*z); qoo = qoo * q*q; loo = loo * q; ennn = ennn +unity; noo = ni * noo; } return out*fau; } __device__ hipComplex thess4(hipComplex z, hipComplex q) { int v; hipComplex unity(1.0,0.0); hipComplex out(1.0,0.0); hipComplex tw(2.0,0.0); hipComplex qoo(1.0,0.0); for(v=0;v<20;v++) { qoo = qoo * q * q; out = out * (unity - qoo) * (unity - tw * qoo/q * cosc(tw*z) + qoo*qoo/(q*q)); } return out; } __device__ hipComplex thesk(hipComplex z, hipComplex q, hipComplex r) { int v; hipComplex unity(1.0,0.0); hipComplex out(1.0,0.0); hipComplex tw(2.0,0.0); hipComplex qoo(1.0,0.0); hipComplex roo(1.0,0.0); for(v=0;v<20;v++) { qoo = qoo * q * q; roo = roo * r * r ; out = out * (unity - qoo) * (unity + tw * qoo/q * cosc(tw*z) + roo*roo/(r*r)); } return out; } __device__ hipComplex thass(hipComplex z, hipComplex q) { int v; hipComplex unity(1.0,0.0); hipComplex out(1.0,0.0); hipComplex tw(2.0,0.0); hipComplex qoo(1.0,0.0); for(v=0;v<20;v++) { qoo = qoo * q * q; out = out * (unity - qoo) * (unity + tw * qoo/q * sins(tw*z) + qoo*qoo/(q*q)); } return out; } __device__ hipComplex rogers( hipComplex q) { hipComplex onf(0.2,0.0); hipComplex Q5 = q*q*q*q*q; hipComplex out = powc(q,onf)* qpoch(q,Q5) * qpoch(q*q*q*q,Q5)/ (qpoch(q*q,Q5)*qpoch(q*q*q,Q5)); return out; } __device__ hipComplex flat(hipComplex m) { float ua = sqrtf(m.r*m.r + m.i*m.i); hipComplex out(m.r/ua,m.i/ua); return out; } __device__ hipComplex eff(hipComplex z, hipComplex lambda) { return z*z*z*z+ lambda/(z*z*z*z); } __device__ hipComplex thete(float R, hipComplex tau, hipComplex z) { /* note that as I'm not immediately doing this on the unit circle, as the real action is considered to happen on the z-plane, we don't yet need to fret about whether I'm looking at things in terms of tau or in terms of q, next revision */ /* set accumulant to zero */ hipComplex A(0.0,0.0); /* miscellaneous setup */ hipComplex pai(3.14159265353898,0.0); hipComplex ai(0.0,1.0); hipComplex oo(1.0,0.0); hipComplex oot(2.0,0.0); hipComplex nini(9.0,0.0); hipComplex eigh(-18.0,0.0); /* hipComplex arr(cos(2*3.1415926535897f*R/2048.0),0.0) */ hipComplex frann(1.0,0.0); frann = pai * ai * tau ; hipComplex shenn(1.0,0.0); shenn = oot * ai * z; hipComplex plenn(1.0,0.0); hipComplex enn(1.0,0.0); hipComplex ann(1.0,0.0); hipComplex bnn(1.0,0.0); hipComplex scrunn(1.0,0.0); float ca, cb,cc; int a, b; for(a=-10;a<10;a++) { ann.r = a; for(b=-10;b<10;b++) { bnn.r = b; if(((a+b)%2)==0) { scrunn.r = a*a + b*b; A = A + expc(frann* scrunn) * expc(shenn* (ann+bnn)); } else { ca = 5.0 + a*a + b*b; cb = 2*(a * cos(R)- b * sin(R)); cc = 4*(b * cos(R)+a*sin(R)); scrunn.r = ca + cb + cc; A = A + expc(frann*scrunn)*expc(shenn*(ann+bnn)); } } } return A; } __device__ hipComplex thetta(hipComplex tau, hipComplex z) { /* note that as I'm not immediately doing this on the unit circle, as the real action is considered to happen on the z-plane, we don't yet need to fret about whether I'm looking at things in terms of tau or in terms of q, next revision */ /* set accumulant to zero */ hipComplex A(0.0,0.0); /* miscellaneous setup */ hipComplex pai(3.14159265353898,0.0); hipComplex ai(0.0,1.0); hipComplex oo(1.0,0.0); hipComplex oot(2.0,0.0); hipComplex nini(9.0,0.0); hipComplex eigh(-18.0,0.0); /* hipComplex arr(cos(2*3.1415926535897f*R/2048.0),0.0) */ hipComplex frann(1.0,0.0); frann = pai * ai * tau ; hipComplex shenn(1.0,0.0); shenn = oot * ai * z; hipComplex plenn(1.0,0.0); hipComplex enn(1.0,0.0); int n; for(n=-10;n<10;n++) { enn.r = n; plenn = enn * enn; /* this get the hipComplex out of the event loop */ A = A + expc(frann* plenn) * expc(shenn* enn); } return A; } __device__ hipComplex mitlef(hipComplex z,hipComplex c) { hipComplex out(0.0,0.0); hipComplex Z(1.0,0.0); hipComplex frove(0.0,0.0); int v; for(v=0;v<20;v++) { frove.r = tgammaf(c.r*v+c.i); out = out + Z/frove; Z = Z * z; } return out; } __device__ hipComplex helva(hipComplex z) { hipComplex out(j0f(z.r),j1f(z.i)); return out; } __device__ hipComplex hilva(hipComplex z) { hipComplex out(j1f(z.r),j0f(z.i)); return out; } __device__ hipComplex halva(hipComplex z) { hipComplex out(j0f(z.r),j0f(z.i)); return out; } __device__ hipComplex hinva(hipComplex z) { hipComplex out(j1f(z.r),j1f(z.i)); return out; } __device__ hipComplex henga(hipComplex z) { hipComplex out(acoshf(z.r),asinhf(z.i)); return out; } __device__ hipComplex holva(hipComplex z) { hipComplex out(y0f(z.r),y1f(z.i)); return out; } __device__ hipComplex aliva(hipComplex z) { hipComplex out(j1f(z.r),cyl_bessel_i1f(z.i)); return out; } __device__ hipComplex ariva(hipComplex z) { hipComplex out(sinf(z.i),cbrtf(z.r)); return out; } __device__ hipComplex arago(hipComplex z, hipComplex q) { int v; hipComplex unity(1.0,0.0); hipComplex out(1.0,0.0); hipComplex tw(2.0,0.0); hipComplex qoo(1.0,0.0); for(v=0;v<10;v++) { qoo = qoo * q * q; out = out * (unity - qoo) * (unity + tw * qoo/q * hinva(tw*z) + qoo*qoo/(q*q)); } return out; } __device__ hipComplex irigo(hipComplex z, hipComplex q) { int v; hipComplex unity(1.0,0.0); hipComplex out(1.0,0.0); hipComplex tw(2.0,0.0); hipComplex qoo(1.0,0.0); for(v=0;v<10;v++) { qoo = qoo * q * q; out = out * (unity - qoo) * (unity + tw * qoo/q * holva(tw*z) + qoo*qoo/(q*q)); } return out; } __device__ hipComplex urigo(hipComplex z, hipComplex q) { int v; hipComplex unity(1.0,0.0); hipComplex out(1.0,0.0); hipComplex tw(2.0,0.0); hipComplex qoo(1.0,0.0); for(v=0;v<10;v++) { qoo = qoo * q * q; out = out * (unity - qoo) * (unity + tw * qoo/q * powc(hilva(q*z),helva(q*z)) + qoo*qoo/(q*q)); } return out; } __device__ hipComplex arreg(hipComplex q, hipComplex r, hipComplex z) { /* arreg implements the representation of theta3'(z)/theta(z) I don't know if these are derivatives with respect to z or q, we'll see */ hipComplex out(0.0,0.0); hipComplex qoo(1.0,0.0); hipComplex roo(1.0,0.0); hipComplex morra(-1.0,0.0); hipComplex tla(1.0,0.0); hipComplex vnn(0.0,0.0); hipComplex fou(4.0,0.0); hipComplex tw(2.0,0.0); hipComplex run(1.0,0.0); int v; for(v=0;v<20;v++) { qoo = qoo * q; roo = roo * r * r; tla = tla * morra; vnn = vnn + run; out = out + morra*qoo*sins(tw*z*run)/(run-roo); } return fou*out; } __device__ hipComplex urreg(hipComplex q, hipComplex r, hipComplex z) { /* arreg implements the representation of theta3'(z)/theta(z) I don't know if these are derivatives with respect to z or q, we'll see */ hipComplex out(0.0,0.0); hipComplex qoo(1.0,0.0); hipComplex roo(1.0,0.0); hipComplex morra(-1.0,0.0); hipComplex tla(1.0,0.0); hipComplex vnn(0.0,0.0); hipComplex fou(4.0,0.0); hipComplex tw(2.0,0.0); hipComplex run(1.0,0.0); int v; for(v=0;v<10;v++) { qoo = qoo * q; roo = roo * r * r; tla = tla * morra; vnn = vnn + run; out = out + morra*qoo*the3(tw*z*run,r)/(run-roo); } return fou*out; } // * small q-exponential __device__ hipComplex qexp(hipComplex z, hipComplex q) { hipComplex mone(-1.0,0.0); hipComplex une(1.0,0.0); return une/qpoch(z,q); } //* large q exponential is just qpoch(-z,q) __device__ hipComplex qExp(hipComplex z, hipComplex q) { hipComplex mone(-1.0,0.0); hipComplex une(1.0,0.0); return qpoch(mone*z,q); } __device__ hipComplex sinq(hipComplex z, hipComplex q) { hipComplex aie(0.0,1.0); hipComplex out(0.0,0.0); hipComplex doo(2.0,0.0); out = (qexp(z*aie,q) -qexp(z*aie,q))/doo; return out; } __device__ hipComplex cosq(hipComplex z, hipComplex q) { hipComplex aie(0.0,1.0); hipComplex out(0.0,0.0); hipComplex doo(2.0,0.0); out = (qexp(z*aie,q) +qexp(z*aie,q))/doo; return out; } __device__ hipComplex Sinq(hipComplex z, hipComplex q) { hipComplex aie(0.0,1.0); hipComplex out(0.0,0.0); hipComplex doo(2.0,0.0); out = (qExp(z*aie,q) -qExp(z*aie,q))/doo; return out; } __device__ hipComplex Cosq(hipComplex z, hipComplex q) { hipComplex aie(0.0,1.0); hipComplex out(0.0,0.0); hipComplex doo(2.0,0.0); out = (qExp(z*aie,q) +qExp(z*aie,q))/doo; return out; } __device__ hipComplex asins(hipComplex z) { float alp = 0.5 * (sqrtf((z.r+1)*(z.r+1) + z.i*z.i) + sqrtf((z.r-1)*(z.r-1) + z.i*z.i)); float bet = 0.5 * (sqrtf((z.r+1)*(z.r+1) + z.i*z.i) - sqrtf((z.r-1)*(z.r-1) + z.i*z.i)); float fla = z.i/abs(z.i); // *signum, but without a comparison, probably a saner way to do this? // hipComplex out(0.0,0.0); out.r = asinf(bet); out.i = fla * logf(alp + sqrtf(alp*alp-1)); return out; } __device__ int gcd(int a, int b) { int remainder = a % b; if (remainder == 0) { return b; } return gcd(b, remainder); } /* Real Analytic Eisenstein Series */ __device__ hipComplex reis(hipComplex s, hipComplex z) { // see en.wikipedia.org/wiki/Real_analytic_Eisenstein_series hipComplex out(0.0,0.0); hipComplex hav(0.5,0.0); hipComplex xu=out; hipComplex yu=out; yu.r = z.i; int m,n; hipComplex ema=out; hipComplex ena=out; hipComplex den=out; for(m=-40;m<40;m++) { for(n=-40;n<40;n++) { if((m!=0)&&(n!=0)) { if((gcd(m,n)==1)) { ena.r = n; ema.r = m; den.r = norg(ema*z+ena); out = out + powc(yu,s)/powc(den,s/hav); } } } } return out; } __device__ unsigned char clip(int n) { return n > 255 ? 255 : (n < 0 ? 0 : n); } __global__ void distanceKernel(uchar4 *d_out, int w, int h, int2 pos) { const int c = blockIdx.x*blockDim.x + threadIdx.x; const int r= blockIdx.y*blockDim.y + threadIdx.y; const int i = c + r*w; // 1D indexing float pi = 3.1415926535898; hipComplex ip(pi,0.0); const float scale = 8.0; float fx = scale * (float)(DIM/2 - c)/(DIM/2); float fy = scale * (float)(DIM/2 - r)/(DIM/2); hipComplex effx(fx,0.0); hipComplex effy(fy,0.0); float LA = scale * (float)(DIM/2 - pos.x)/(DIM/2); float LB = scale * (float)(DIM/2 - pos.y)/(DIM/2); hipComplex mouse(LA,LB); hipComplex moux(LA,0.0); hipComplex mouy(0.0,LB); hipComplex q(fx,fy); /* hipComplex tik(sin(ticks/40.0f),0.0);*/ /* hipComplex uon(cosf(-2*pi*ticks/16384.0),sinf(-2*pi*ticks/16384.0)); hipComplex aon(cosf(2.6457513110645912*2*pi*ticks/1024),sinf(2.645751311064591*2*pi*ticks/1024)); hipComplex eon(cosf(-2.6457513110645912*2*pi*ticks/1024.0),sinf(2.645751311064591*2*pi*ticks/1024.0));*/ hipComplex fixon(.029348,.828934); hipComplex faxon(.029348,-.828934); hipComplex unity(1.0,0.0); hipComplex ai(0.0,1.0); hipComplex aon = expc(ai*moux); hipComplex uon= expc(mouy); hipComplex flurn(0.0,0.0); hipComplex accume(1.0,0.0); hipComplex eccume(0.0,0.0); hipComplex rhun(1.02871376821872462237195122725097462534904479,0.0); hipComplex cue = q; hipComplex lam(0.73736887807831963, -0.67549029426152396); hipComplex due(3.0,0.0); hipComplex tir(2.0,0.0); hipComplex selga(3.5,0.0); hipComplex vro(-1.0,0.0); hipComplex tle(1.0,0.0); hipComplex sle(4.0,0.0); hipComplex cherra(0.62348980185873359, 0.7818314824680298); hipComplex lerra = cherra*cherra; hipComplex ferra = lerra * cherra; hipComplex terra = ferra * cherra; hipComplex zerra = terra * cherra; hipComplex nerra = zerra * cherra; hipComplex vlarv(1/3.0,0.0); hipComplex sugna(0.70710678118654757, 0.70710678118654746); hipComplex regna(0.99966573338968745, 0.025853848581176047); hipComplex spa(sqrtf(2.0),0.0); hipComplex spb(sqrtf(3.0),0.0); hipComplex spc(sqrtf(4.0),0.0); hipComplex spd(sqrtf(5.0),0.0); hipComplex mrun(1/2.0,0.0); hipComplex gloon (4.0,0.0); hipComplex plenod(-.01,0.0); hipComplex nue = cue; hipComplex bor(-10.0,0.0); hipComplex nat(0.0,-10.0); hipComplex rhus(1.0,0.0); hipComplex D(0.739085133215160641655312087674,0.0); hipComplex gren(2.0,0.0); hipComplex next=flurn; hipComplex current = cue; hipComplex xnext = flurn; hipComplex xcurrent = cue; hipComplex tinny(.0001,0.0001); hipComplex raga(0.5,27.0); float xa,xb,ya,yb,tta,ttb; /* if ((c >= w) || (r >= h)) return; // Check if within image bounds const int i = c + r*w; // 1D indexing const int dist = sqrtf((c - pos.x)*(c - pos.x) + (r - pos.y)*(r - pos.y)); const unsigned char intensity = clip(255 - dist);*/ // theta function varying on constant // cue =thess(cue,fixon*mouse); int v=1; int axa=-10; int uu; /*while((v<100)&&norg(cue)<2.0) { cue = cue*(cue-mouy)*(cue-moux) -cue * q; v++; }*/ // One way of describing this would be we want to perform Newton's method //on the Mandelbrot set /* preiterate */ //tex.stackexchange.com/questions/278843/making-a-phase-portrait-of-two-autonomous-system-of-differential-equations-with?fbclid=IwAR2Tz66CbUAq7LFVYck4uUGF5uQWnmzf5iZw3Bi8IOycvCC7czO6ZVgkz3s // this is not terribly hard to do with cuda // what we need: // x' = x - y -> dx / dt = x - y // y' = 1 - x^2 -> dy / dt = 1-x^2 // dy / dx = (dy / dt) / (dx/ dt) // so the trick is to convert dy/dx into a unit complex number to make this work, okay that's not that difficult cue = reis(raga,cue); double tha; tha = ((atan2(cue.i,cue.r) - pi)/(2.0*pi)); d_out[i].x = (unsigned char) (255.0*pow(sin(pi*tha),2)); d_out[i].y = (unsigned char) (255.0*pow(sin(pi*tha+pi/3),2)); d_out[i].z = (unsigned char) (255.0*pow(sin(pi*tha+2*pi/3),2)); d_out[i].w = 255; } void kernelLauncher(uchar4 *d_out, int w, int h, int2 pos) { const dim3 blockSize(TX, TY); const dim3 gridSize = dim3((w + TX - 1)/TX, (h + TY - 1)/TY); hipLaunchKernelGGL(( distanceKernel), dim3(gridSize), dim3(blockSize), 0, 0, d_out, w, h, pos); } /*for(v=1;v<5;v++) { cue = cue - cue * (expc(unity-cue/moux)+expc(cue-unity/mouy))/((vlarv-unity/moux )*(expc(unity-cue/moux))-expc(cue-unity/mouy)); accume = accume + ((vlarv-unity/moux )*(expc(unity-cue/moux))-expc(cue-unity/mouy)); } cue = accume;*/ /*cue = ramchi(moeb(unity,uon*fixon,q))*rampsi(moeb(unity,uon*fixon,q)); rhus = ramchi(uon/moeb(unity,uon*faxon,unity/q))*ramphi(uon/moeb(unity,uon*faxon,unity/q)); cue = rhus+cue; cue = cosc(unity/(unity-uon*cue))*rampsi(moeb(unity,uon*fixon,q));*/ /*for(v=0;v<60;v++){ cue = moeb(aon,fixon,cue) - aon/((expc(uon*cue-sins(cue))-cue)/((aon+cosc(cue)) * expc(uon*cue-sins(cue))-aon)); accume = accume *(unity - (expc(aon*moeb(uon,faxon,cue))-sins(moeb(aon,fixon,cue))-cue)); } cue = accume;*/ /* One for (x+d)/cos(d) -cos(x)/d Tungilipa D = cos(D) cos(sqrt(x*D))/D -1 = 0.0 The other for cos(x)-x Eripgrunna */
6491088b0edf8e2e285fadec755193a750068c19.cu
#include "kernel.h" #define TX 32 #define TY 32 #define DIM 2100 struct cuComplex { float r; float i; __device__ cuComplex( float a, float b ) : r(a), i(b) {} __device__ float magnitude2( void ) { return r * r + i * i; } __device__ cuComplex operator*(const cuComplex& a) { return cuComplex(r*a.r - i*a.i, i*a.r + r*a.i); } __device__ cuComplex operator-(const cuComplex& a) { return cuComplex(r-a.r, i-a.i); } __device__ cuComplex operator+(const cuComplex& a) { return cuComplex(r+a.r, i+a.i); } __device__ cuComplex operator/(const cuComplex& a) { return cuComplex((r*a.r + i*a.i)/(a.r*a.r + a.i*a.i), (i*a.r - r*a.i)/(a.r*a.r + a.i*a.i)); } }; __device__ cuComplex conj(cuComplex m) { cuComplex out(m.r,-m.i); return out; } __device__ cuComplex nor(cuComplex m) { cuComplex out(m.r*m.r+m.i*m.i,0.0); return out; } __device__ float norg(cuComplex m) { return sqrtf(m.r*m.r+m.i*m.i); } __device__ cuComplex qpoch(cuComplex a, cuComplex q) { cuComplex out(1.0,0.0); cuComplex unity(1.0,0.0); int i = 0; cuComplex Q = q; if(q.magnitude2()>1.0) { return cuComplex(0.0,0.0); } // We want to formally match the definition of a q-pochhammer symbol. for(i=1;i<80;i++) { out = out * (unity - a*Q); Q = q * Q; } return out; } __device__ cuComplex qp(cuComplex a, cuComplex q, int n) { cuComplex out(1.0,0.0); cuComplex unity(1.0,0.0); int i = 0; cuComplex Q = q; if(q.magnitude2()>1.0) { return cuComplex(0.0,0.0); } // We want to formally match the definition of a q-pochhammer symbol. for(i=1;i<n;i++) { out = out * (unity - a*Q); Q = q * Q; } return out; } __device__ cuComplex ramphi(cuComplex q) { cuComplex out(1.0,0.0); cuComplex mone(-1.0,0.0); cuComplex mq = mone*q; return qpoch(mq,mq)/qpoch(q,mq); } __device__ cuComplex rampsi(cuComplex q) { cuComplex out(1.0,0.0); cuComplex mone(-1.0,0.0); cuComplex mq = mone*q; return qpoch(mq,q)*qpoch(q*q,q*q); } __device__ cuComplex ramchi(cuComplex q) { cuComplex out(1.0,0.0); cuComplex mone(-1.0,0.0); cuComplex mq = mone*q; return qpoch(mq,q*q); } __device__ cuComplex ramf(cuComplex a, cuComplex b) { cuComplex out(1.0,0.0); cuComplex mone(-1.0,0.0); cuComplex ma = mone*a; cuComplex mb = mone*b; return qpoch(ma,a*b)*qpoch(mb,a*b)*qpoch(a*b,a*b); } // complex exponential __device__ cuComplex expc(cuComplex m) { cuComplex out(expf(m.r) * cosf(m.i),expf(m.r) * sinf(m.i)); return out; } __device__ cuComplex powc(cuComplex ag, cuComplex bg) { cuComplex out(0.0,0.0); cuComplex mesp(0.0,0.0); cuComplex frim(0.0,0.0); double radiu, thet; /* get the proper polar form of the complex number */ radiu = sqrtf(ag.r*ag.r + ag.i*ag.i); thet = atan2f(ag.i,ag.r); /* mesp gives R^(c+di) */ mesp.r = powf(radiu,bg.r)*cosf(bg.i*logf(radiu)); mesp.i = powf(radiu,bg.r)*sinf(bg.i*logf(radiu)); /* frim gives e^(i theta (c+di)) */ /* now since we already have the machinery for performing complex exponentiation (just exp), we can just call that here */ frim.r = -1.0 * bg.i * thet; frim.i = bg.r * thet; frim = expc(frim); out = mesp*frim; return out; } // cosine (nothing algorithmically clean) __device__ cuComplex cosc(cuComplex m) { cuComplex ai(0.0,1.0); cuComplex ot(0.5,0.0); cuComplex mone(-1.0,0.0); cuComplex out = ot*(expc(m*ai) + expc(mone*m*ai)); return out; } __device__ cuComplex sins(cuComplex m) { cuComplex ai(0.0,1.0); cuComplex ot(0.0,0.5); cuComplex mone(-1.0,0.0); cuComplex out = ot*(expc(m*ai) - expc(mone*m*ai)); return out; } __device__ cuComplex tans(cuComplex m) { return sins(m)/cosc(m); } __device__ cuComplex moeb(cuComplex t, cuComplex a, cuComplex z) { cuComplex out(0.0,0.0); cuComplex ai(0.0,1.0); cuComplex unity(1.0,0.0); out = expc(ai*t) * (z-a)/(unity-conj(a)*z); return out; } __device__ cuComplex bnewt(cuComplex z) { cuComplex three(3.0,0.0); cuComplex unity(1.0,0.0); cuComplex out(0.0,0.0); cuComplex Z =z; cuComplex L(0.0,0.0); cuComplex R(0.62348980185873359,0.7818314824680298); cuComplex v(0.62348980185873359,0.7818314824680298); int i; for(i=0;i<100;i++) { L = sins(expc(Z)-cosc(Z))-Z; out = out + v*L; v = R * v; Z = Z - L/((expc(Z)+sins(Z))*cosc(expc(Z)-cosc(Z))-unity); } return out; } __device__ cuComplex they3(cuComplex z, cuComplex q) { int u; cuComplex out(0.0,0.0); cuComplex enn(-20.0,0.0); cuComplex onn(1.0,0.0); cuComplex dui(0.0,1.0); for(u=-20;u<20;u++) { out = out + powc(q,enn*enn)*expc(dui*enn*z); enn = enn + onn; } return out; } __device__ cuComplex wahi(cuComplex z) { int u; cuComplex un(1.0,0.0); cuComplex ne(1.0,0.0); cuComplex out(0.0,0.0); for(u=1;u<40;u++) { out = out + powc(z/ne,ne); ne = ne + un; } out = out + un; return out; } __device__ cuComplex dwahi(cuComplex z) { int u; cuComplex un(1.0,0.0); cuComplex ne(1.0,0.0); cuComplex out(0.0,0.0); for(u=1;u<40;u++) { out = out + powc(z/ne,ne-un); ne = ne + un; } return out; } __device__ cuComplex they3p(cuComplex z, cuComplex q) { int u; cuComplex out(0.0,0.0); cuComplex enn(-20.0,0.0); cuComplex onn(1.0,0.0); cuComplex dui(0.0,1.0); for(u=-20;u<20;u++) { out = out + (enn*enn)*powc(q,enn*enn-onn)*expc(dui*enn*z); enn = enn + onn; } return out; } __device__ cuComplex h3ey3p(cuComplex z, cuComplex q) { int u; cuComplex out(0.0,0.0); cuComplex aut(0.0,0.0); cuComplex enn(-20.0,0.0); cuComplex onn(1.0,0.0); cuComplex dui(0.0,1.0); cuComplex vel(0.0,0.0); cuComplex rav(0.0,0.0); for(u=-40;u<40;u++) { vel = expc(dui*enn*z); rav = powc(q,enn*enn); aut = aut + (enn*enn)*rav/q*vel; out = out + rav*vel; enn = enn + onn; } return out/aut; } __device__ cuComplex thess(cuComplex z, cuComplex q) { int v; cuComplex unity(1.0,0.0); cuComplex out(1.0,0.0); cuComplex tw(2.0,0.0); cuComplex qoo(1.0,0.0); for(v=0;v<10;v++) { qoo = qoo * q * q; out = out * (unity - qoo) * (unity + tw * qoo/q * cosc(tw*z) + qoo*qoo/(q*q)); } return out; } __device__ cuComplex the1(cuComplex z, cuComplex q) { int v; cuComplex unity(1.0,0.0); cuComplex out(1.0,0.0); cuComplex tw(2.0,0.0); cuComplex qoo(1.0,0.0); cuComplex rt(0.25,0.0); for(v=0;v<10;v++) { qoo = qoo * q * q; out = out * (unity - qoo) * (unity + tw * qoo/q * cosc(tw*z) + qoo*qoo/(q*q)); } return tw*out*powc(q,rt)*sins(z); } __device__ cuComplex the2(cuComplex z, cuComplex q) { int v; cuComplex unity(1.0,0.0); cuComplex out(1.0,0.0); cuComplex tw(2.0,0.0); cuComplex qoo(1.0,0.0); cuComplex rt(0.25,0.0); for(v=0;v<10;v++) { qoo = qoo * q * q; out = out * (unity - qoo) * (unity - tw * qoo/q * cosc(tw*z) + qoo*qoo/(q*q)); } return tw*out*powc(q,rt)*cosc(z); } __device__ cuComplex the3(cuComplex z, cuComplex q) { int v; cuComplex unity(1.0,0.0); cuComplex out(1.0,0.0); cuComplex tw(2.0,0.0); cuComplex qoo(1.0,0.0); for(v=0;v<10;v++) { qoo = qoo * q * q; out = out * (unity - qoo) * (unity + tw * qoo/q * cosc(tw*z) + qoo*qoo/(q*q)); } return out; } __device__ cuComplex the4(cuComplex z, cuComplex q) { int v; cuComplex unity(1.0,0.0); cuComplex out(1.0,0.0); cuComplex tw(2.0,0.0); cuComplex qoo(1.0,0.0); for(v=0;v<10;v++) { qoo = qoo * q * q; out = out * (unity - qoo) * (unity - tw * qoo/q * cosc(tw*z) + qoo*qoo/(q*q)); } return out; } /* routine to generate q-integers */ __device__ cuComplex qin(cuComplex a, cuComplex q) { cuComplex unity(1.0,0.0); cuComplex out(1.0,0.0); out = (unity - powc(q, a))/(unity-q); return out; } /* generating function for n^2 */ __device__ cuComplex geffa(cuComplex z, cuComplex q) { cuComplex out(0.0,0.0); cuComplex unity(1.0,0.0); cuComplex wu(0.0,0.0); cuComplex Z=unity; int v; for(v=0;v<20;v++) { out = out + qin(wu*wu,q)* Z; wu = wu + unity; Z = z * Z; } return out; } __device__ cuComplex thratd(cuComplex z, cuComplex q) { int n; cuComplex fau(4.0,0.0); cuComplex too(2.0,0.0); cuComplex unity(1.0,0.0); cuComplex ennn(1.0,0.0); cuComplex ni(-1.0,0.0); cuComplex noo(-1.0,0.0); cuComplex out(0.0,0.0); cuComplex loo = q; cuComplex qoo =q*q; for(n=0;n<80;n++) { out = out + noo*(loo/(unity-qoo))*sins(too*ennn*z); qoo = qoo * q*q; loo = loo * q; ennn = ennn +unity; noo = ni * noo; } return out*fau; } __device__ cuComplex thess4(cuComplex z, cuComplex q) { int v; cuComplex unity(1.0,0.0); cuComplex out(1.0,0.0); cuComplex tw(2.0,0.0); cuComplex qoo(1.0,0.0); for(v=0;v<20;v++) { qoo = qoo * q * q; out = out * (unity - qoo) * (unity - tw * qoo/q * cosc(tw*z) + qoo*qoo/(q*q)); } return out; } __device__ cuComplex thesk(cuComplex z, cuComplex q, cuComplex r) { int v; cuComplex unity(1.0,0.0); cuComplex out(1.0,0.0); cuComplex tw(2.0,0.0); cuComplex qoo(1.0,0.0); cuComplex roo(1.0,0.0); for(v=0;v<20;v++) { qoo = qoo * q * q; roo = roo * r * r ; out = out * (unity - qoo) * (unity + tw * qoo/q * cosc(tw*z) + roo*roo/(r*r)); } return out; } __device__ cuComplex thass(cuComplex z, cuComplex q) { int v; cuComplex unity(1.0,0.0); cuComplex out(1.0,0.0); cuComplex tw(2.0,0.0); cuComplex qoo(1.0,0.0); for(v=0;v<20;v++) { qoo = qoo * q * q; out = out * (unity - qoo) * (unity + tw * qoo/q * sins(tw*z) + qoo*qoo/(q*q)); } return out; } __device__ cuComplex rogers( cuComplex q) { cuComplex onf(0.2,0.0); cuComplex Q5 = q*q*q*q*q; cuComplex out = powc(q,onf)* qpoch(q,Q5) * qpoch(q*q*q*q,Q5)/ (qpoch(q*q,Q5)*qpoch(q*q*q,Q5)); return out; } __device__ cuComplex flat(cuComplex m) { float ua = sqrtf(m.r*m.r + m.i*m.i); cuComplex out(m.r/ua,m.i/ua); return out; } __device__ cuComplex eff(cuComplex z, cuComplex lambda) { return z*z*z*z+ lambda/(z*z*z*z); } __device__ cuComplex thete(float R, cuComplex tau, cuComplex z) { /* note that as I'm not immediately doing this on the unit circle, as the real action is considered to happen on the z-plane, we don't yet need to fret about whether I'm looking at things in terms of tau or in terms of q, next revision */ /* set accumulant to zero */ cuComplex A(0.0,0.0); /* miscellaneous setup */ cuComplex pai(3.14159265353898,0.0); cuComplex ai(0.0,1.0); cuComplex oo(1.0,0.0); cuComplex oot(2.0,0.0); cuComplex nini(9.0,0.0); cuComplex eigh(-18.0,0.0); /* cuComplex arr(cos(2*3.1415926535897f*R/2048.0),0.0) */ cuComplex frann(1.0,0.0); frann = pai * ai * tau ; cuComplex shenn(1.0,0.0); shenn = oot * ai * z; cuComplex plenn(1.0,0.0); cuComplex enn(1.0,0.0); cuComplex ann(1.0,0.0); cuComplex bnn(1.0,0.0); cuComplex scrunn(1.0,0.0); float ca, cb,cc; int a, b; for(a=-10;a<10;a++) { ann.r = a; for(b=-10;b<10;b++) { bnn.r = b; if(((a+b)%2)==0) { scrunn.r = a*a + b*b; A = A + expc(frann* scrunn) * expc(shenn* (ann+bnn)); } else { ca = 5.0 + a*a + b*b; cb = 2*(a * cos(R)- b * sin(R)); cc = 4*(b * cos(R)+a*sin(R)); scrunn.r = ca + cb + cc; A = A + expc(frann*scrunn)*expc(shenn*(ann+bnn)); } } } return A; } __device__ cuComplex thetta(cuComplex tau, cuComplex z) { /* note that as I'm not immediately doing this on the unit circle, as the real action is considered to happen on the z-plane, we don't yet need to fret about whether I'm looking at things in terms of tau or in terms of q, next revision */ /* set accumulant to zero */ cuComplex A(0.0,0.0); /* miscellaneous setup */ cuComplex pai(3.14159265353898,0.0); cuComplex ai(0.0,1.0); cuComplex oo(1.0,0.0); cuComplex oot(2.0,0.0); cuComplex nini(9.0,0.0); cuComplex eigh(-18.0,0.0); /* cuComplex arr(cos(2*3.1415926535897f*R/2048.0),0.0) */ cuComplex frann(1.0,0.0); frann = pai * ai * tau ; cuComplex shenn(1.0,0.0); shenn = oot * ai * z; cuComplex plenn(1.0,0.0); cuComplex enn(1.0,0.0); int n; for(n=-10;n<10;n++) { enn.r = n; plenn = enn * enn; /* this get the cuComplex out of the event loop */ A = A + expc(frann* plenn) * expc(shenn* enn); } return A; } __device__ cuComplex mitlef(cuComplex z,cuComplex c) { cuComplex out(0.0,0.0); cuComplex Z(1.0,0.0); cuComplex frove(0.0,0.0); int v; for(v=0;v<20;v++) { frove.r = tgammaf(c.r*v+c.i); out = out + Z/frove; Z = Z * z; } return out; } __device__ cuComplex helva(cuComplex z) { cuComplex out(j0f(z.r),j1f(z.i)); return out; } __device__ cuComplex hilva(cuComplex z) { cuComplex out(j1f(z.r),j0f(z.i)); return out; } __device__ cuComplex halva(cuComplex z) { cuComplex out(j0f(z.r),j0f(z.i)); return out; } __device__ cuComplex hinva(cuComplex z) { cuComplex out(j1f(z.r),j1f(z.i)); return out; } __device__ cuComplex henga(cuComplex z) { cuComplex out(acoshf(z.r),asinhf(z.i)); return out; } __device__ cuComplex holva(cuComplex z) { cuComplex out(y0f(z.r),y1f(z.i)); return out; } __device__ cuComplex aliva(cuComplex z) { cuComplex out(j1f(z.r),cyl_bessel_i1f(z.i)); return out; } __device__ cuComplex ariva(cuComplex z) { cuComplex out(sinf(z.i),cbrtf(z.r)); return out; } __device__ cuComplex arago(cuComplex z, cuComplex q) { int v; cuComplex unity(1.0,0.0); cuComplex out(1.0,0.0); cuComplex tw(2.0,0.0); cuComplex qoo(1.0,0.0); for(v=0;v<10;v++) { qoo = qoo * q * q; out = out * (unity - qoo) * (unity + tw * qoo/q * hinva(tw*z) + qoo*qoo/(q*q)); } return out; } __device__ cuComplex irigo(cuComplex z, cuComplex q) { int v; cuComplex unity(1.0,0.0); cuComplex out(1.0,0.0); cuComplex tw(2.0,0.0); cuComplex qoo(1.0,0.0); for(v=0;v<10;v++) { qoo = qoo * q * q; out = out * (unity - qoo) * (unity + tw * qoo/q * holva(tw*z) + qoo*qoo/(q*q)); } return out; } __device__ cuComplex urigo(cuComplex z, cuComplex q) { int v; cuComplex unity(1.0,0.0); cuComplex out(1.0,0.0); cuComplex tw(2.0,0.0); cuComplex qoo(1.0,0.0); for(v=0;v<10;v++) { qoo = qoo * q * q; out = out * (unity - qoo) * (unity + tw * qoo/q * powc(hilva(q*z),helva(q*z)) + qoo*qoo/(q*q)); } return out; } __device__ cuComplex arreg(cuComplex q, cuComplex r, cuComplex z) { /* arreg implements the representation of theta3'(z)/theta(z) I don't know if these are derivatives with respect to z or q, we'll see */ cuComplex out(0.0,0.0); cuComplex qoo(1.0,0.0); cuComplex roo(1.0,0.0); cuComplex morra(-1.0,0.0); cuComplex tla(1.0,0.0); cuComplex vnn(0.0,0.0); cuComplex fou(4.0,0.0); cuComplex tw(2.0,0.0); cuComplex run(1.0,0.0); int v; for(v=0;v<20;v++) { qoo = qoo * q; roo = roo * r * r; tla = tla * morra; vnn = vnn + run; out = out + morra*qoo*sins(tw*z*run)/(run-roo); } return fou*out; } __device__ cuComplex urreg(cuComplex q, cuComplex r, cuComplex z) { /* arreg implements the representation of theta3'(z)/theta(z) I don't know if these are derivatives with respect to z or q, we'll see */ cuComplex out(0.0,0.0); cuComplex qoo(1.0,0.0); cuComplex roo(1.0,0.0); cuComplex morra(-1.0,0.0); cuComplex tla(1.0,0.0); cuComplex vnn(0.0,0.0); cuComplex fou(4.0,0.0); cuComplex tw(2.0,0.0); cuComplex run(1.0,0.0); int v; for(v=0;v<10;v++) { qoo = qoo * q; roo = roo * r * r; tla = tla * morra; vnn = vnn + run; out = out + morra*qoo*the3(tw*z*run,r)/(run-roo); } return fou*out; } // * small q-exponential __device__ cuComplex qexp(cuComplex z, cuComplex q) { cuComplex mone(-1.0,0.0); cuComplex une(1.0,0.0); return une/qpoch(z,q); } //* large q exponential is just qpoch(-z,q) __device__ cuComplex qExp(cuComplex z, cuComplex q) { cuComplex mone(-1.0,0.0); cuComplex une(1.0,0.0); return qpoch(mone*z,q); } __device__ cuComplex sinq(cuComplex z, cuComplex q) { cuComplex aie(0.0,1.0); cuComplex out(0.0,0.0); cuComplex doo(2.0,0.0); out = (qexp(z*aie,q) -qexp(z*aie,q))/doo; return out; } __device__ cuComplex cosq(cuComplex z, cuComplex q) { cuComplex aie(0.0,1.0); cuComplex out(0.0,0.0); cuComplex doo(2.0,0.0); out = (qexp(z*aie,q) +qexp(z*aie,q))/doo; return out; } __device__ cuComplex Sinq(cuComplex z, cuComplex q) { cuComplex aie(0.0,1.0); cuComplex out(0.0,0.0); cuComplex doo(2.0,0.0); out = (qExp(z*aie,q) -qExp(z*aie,q))/doo; return out; } __device__ cuComplex Cosq(cuComplex z, cuComplex q) { cuComplex aie(0.0,1.0); cuComplex out(0.0,0.0); cuComplex doo(2.0,0.0); out = (qExp(z*aie,q) +qExp(z*aie,q))/doo; return out; } __device__ cuComplex asins(cuComplex z) { float alp = 0.5 * (sqrtf((z.r+1)*(z.r+1) + z.i*z.i) + sqrtf((z.r-1)*(z.r-1) + z.i*z.i)); float bet = 0.5 * (sqrtf((z.r+1)*(z.r+1) + z.i*z.i) - sqrtf((z.r-1)*(z.r-1) + z.i*z.i)); float fla = z.i/abs(z.i); // *signum, but without a comparison, probably a saner way to do this? // cuComplex out(0.0,0.0); out.r = asinf(bet); out.i = fla * logf(alp + sqrtf(alp*alp-1)); return out; } __device__ int gcd(int a, int b) { int remainder = a % b; if (remainder == 0) { return b; } return gcd(b, remainder); } /* Real Analytic Eisenstein Series */ __device__ cuComplex reis(cuComplex s, cuComplex z) { // see en.wikipedia.org/wiki/Real_analytic_Eisenstein_series cuComplex out(0.0,0.0); cuComplex hav(0.5,0.0); cuComplex xu=out; cuComplex yu=out; yu.r = z.i; int m,n; cuComplex ema=out; cuComplex ena=out; cuComplex den=out; for(m=-40;m<40;m++) { for(n=-40;n<40;n++) { if((m!=0)&&(n!=0)) { if((gcd(m,n)==1)) { ena.r = n; ema.r = m; den.r = norg(ema*z+ena); out = out + powc(yu,s)/powc(den,s/hav); } } } } return out; } __device__ unsigned char clip(int n) { return n > 255 ? 255 : (n < 0 ? 0 : n); } __global__ void distanceKernel(uchar4 *d_out, int w, int h, int2 pos) { const int c = blockIdx.x*blockDim.x + threadIdx.x; const int r= blockIdx.y*blockDim.y + threadIdx.y; const int i = c + r*w; // 1D indexing float pi = 3.1415926535898; cuComplex ip(pi,0.0); const float scale = 8.0; float fx = scale * (float)(DIM/2 - c)/(DIM/2); float fy = scale * (float)(DIM/2 - r)/(DIM/2); cuComplex effx(fx,0.0); cuComplex effy(fy,0.0); float LA = scale * (float)(DIM/2 - pos.x)/(DIM/2); float LB = scale * (float)(DIM/2 - pos.y)/(DIM/2); cuComplex mouse(LA,LB); cuComplex moux(LA,0.0); cuComplex mouy(0.0,LB); cuComplex q(fx,fy); /* cuComplex tik(sin(ticks/40.0f),0.0);*/ /* cuComplex uon(cosf(-2*pi*ticks/16384.0),sinf(-2*pi*ticks/16384.0)); cuComplex aon(cosf(2.6457513110645912*2*pi*ticks/1024),sinf(2.645751311064591*2*pi*ticks/1024)); cuComplex eon(cosf(-2.6457513110645912*2*pi*ticks/1024.0),sinf(2.645751311064591*2*pi*ticks/1024.0));*/ cuComplex fixon(.029348,.828934); cuComplex faxon(.029348,-.828934); cuComplex unity(1.0,0.0); cuComplex ai(0.0,1.0); cuComplex aon = expc(ai*moux); cuComplex uon= expc(mouy); cuComplex flurn(0.0,0.0); cuComplex accume(1.0,0.0); cuComplex eccume(0.0,0.0); cuComplex rhun(1.02871376821872462237195122725097462534904479,0.0); cuComplex cue = q; cuComplex lam(0.73736887807831963, -0.67549029426152396); cuComplex due(3.0,0.0); cuComplex tir(2.0,0.0); cuComplex selga(3.5,0.0); cuComplex vro(-1.0,0.0); cuComplex tle(1.0,0.0); cuComplex sle(4.0,0.0); cuComplex cherra(0.62348980185873359, 0.7818314824680298); cuComplex lerra = cherra*cherra; cuComplex ferra = lerra * cherra; cuComplex terra = ferra * cherra; cuComplex zerra = terra * cherra; cuComplex nerra = zerra * cherra; cuComplex vlarv(1/3.0,0.0); cuComplex sugna(0.70710678118654757, 0.70710678118654746); cuComplex regna(0.99966573338968745, 0.025853848581176047); cuComplex spa(sqrtf(2.0),0.0); cuComplex spb(sqrtf(3.0),0.0); cuComplex spc(sqrtf(4.0),0.0); cuComplex spd(sqrtf(5.0),0.0); cuComplex mrun(1/2.0,0.0); cuComplex gloon (4.0,0.0); cuComplex plenod(-.01,0.0); cuComplex nue = cue; cuComplex bor(-10.0,0.0); cuComplex nat(0.0,-10.0); cuComplex rhus(1.0,0.0); cuComplex D(0.739085133215160641655312087674,0.0); cuComplex gren(2.0,0.0); cuComplex next=flurn; cuComplex current = cue; cuComplex xnext = flurn; cuComplex xcurrent = cue; cuComplex tinny(.0001,0.0001); cuComplex raga(0.5,27.0); float xa,xb,ya,yb,tta,ttb; /* if ((c >= w) || (r >= h)) return; // Check if within image bounds const int i = c + r*w; // 1D indexing const int dist = sqrtf((c - pos.x)*(c - pos.x) + (r - pos.y)*(r - pos.y)); const unsigned char intensity = clip(255 - dist);*/ // theta function varying on constant // cue =thess(cue,fixon*mouse); int v=1; int axa=-10; int uu; /*while((v<100)&&norg(cue)<2.0) { cue = cue*(cue-mouy)*(cue-moux) -cue * q; v++; }*/ // One way of describing this would be we want to perform Newton's method //on the Mandelbrot set /* preiterate */ //tex.stackexchange.com/questions/278843/making-a-phase-portrait-of-two-autonomous-system-of-differential-equations-with?fbclid=IwAR2Tz66CbUAq7LFVYck4uUGF5uQWnmzf5iZw3Bi8IOycvCC7czO6ZVgkz3s // this is not terribly hard to do with cuda // what we need: // x' = x - y -> dx / dt = x - y // y' = 1 - x^2 -> dy / dt = 1-x^2 // dy / dx = (dy / dt) / (dx/ dt) // so the trick is to convert dy/dx into a unit complex number to make this work, okay that's not that difficult cue = reis(raga,cue); double tha; tha = ((atan2(cue.i,cue.r) - pi)/(2.0*pi)); d_out[i].x = (unsigned char) (255.0*pow(sin(pi*tha),2)); d_out[i].y = (unsigned char) (255.0*pow(sin(pi*tha+pi/3),2)); d_out[i].z = (unsigned char) (255.0*pow(sin(pi*tha+2*pi/3),2)); d_out[i].w = 255; } void kernelLauncher(uchar4 *d_out, int w, int h, int2 pos) { const dim3 blockSize(TX, TY); const dim3 gridSize = dim3((w + TX - 1)/TX, (h + TY - 1)/TY); distanceKernel<<<gridSize, blockSize>>>(d_out, w, h, pos); } /*for(v=1;v<5;v++) { cue = cue - cue * (expc(unity-cue/moux)+expc(cue-unity/mouy))/((vlarv-unity/moux )*(expc(unity-cue/moux))-expc(cue-unity/mouy)); accume = accume + ((vlarv-unity/moux )*(expc(unity-cue/moux))-expc(cue-unity/mouy)); } cue = accume;*/ /*cue = ramchi(moeb(unity,uon*fixon,q))*rampsi(moeb(unity,uon*fixon,q)); rhus = ramchi(uon/moeb(unity,uon*faxon,unity/q))*ramphi(uon/moeb(unity,uon*faxon,unity/q)); cue = rhus+cue; cue = cosc(unity/(unity-uon*cue))*rampsi(moeb(unity,uon*fixon,q));*/ /*for(v=0;v<60;v++){ cue = moeb(aon,fixon,cue) - aon/((expc(uon*cue-sins(cue))-cue)/((aon+cosc(cue)) * expc(uon*cue-sins(cue))-aon)); accume = accume *(unity - (expc(aon*moeb(uon,faxon,cue))-sins(moeb(aon,fixon,cue))-cue)); } cue = accume;*/ /* One for (x+d)/cos(d) -cos(x)/d Tungilipa D = cos(D) cos(sqrt(x*D))/D -1 = 0.0 The other for cos(x)-x Eripgrunna */
d6f872fc2a226a445b88aa9c9f7e05d9a76d6a60.hip
// !!! This is a file automatically generated by hipify!!! /* Implements the sequential cuda vectors. */ #define PETSC_SKIP_SPINLOCK #include <petscconf.h> #include <petsc/private/vecimpl.h> #include <../src/vec/vec/impls/dvecimpl.h> #include <../src/vec/vec/impls/seq/seqcuda/cudavecimpl.h> #include <hip/hip_runtime.h> #include <thrust/device_ptr.h> #include <thrust/transform.h> #include <thrust/functional.h> /* Allocates space for the vector array on the GPU if it does not exist. Does NOT change the PetscCUDAFlag for the vector Does NOT zero the CUDA array */ PetscErrorCode VecCUDAAllocateCheck(Vec v) { PetscErrorCode ierr; hipError_t err; hipStream_t stream; Vec_CUDA *veccuda; PetscFunctionBegin; if (!v->spptr) { ierr = PetscMalloc(sizeof(Vec_CUDA),&v->spptr);CHKERRQ(ierr); veccuda = (Vec_CUDA*)v->spptr; err = hipMalloc((void**)&veccuda->GPUarray_allocated,sizeof(PetscScalar)*((PetscBLASInt)v->map->n));CHKERRCUDA(err); veccuda->GPUarray = veccuda->GPUarray_allocated; err = hipStreamCreate(&stream);CHKERRCUDA(err); veccuda->stream = stream; veccuda->hostDataRegisteredAsPageLocked = PETSC_FALSE; if (v->valid_GPU_array == PETSC_OFFLOAD_UNALLOCATED) { if (v->data && ((Vec_Seq*)v->data)->array) { v->valid_GPU_array = PETSC_OFFLOAD_CPU; } else { v->valid_GPU_array = PETSC_OFFLOAD_GPU; } } } PetscFunctionReturn(0); } /* Copies a vector from the CPU to the GPU unless we already have an up-to-date copy on the GPU */ PetscErrorCode VecCUDACopyToGPU(Vec v) { PetscErrorCode ierr; hipError_t err; Vec_CUDA *veccuda; PetscScalar *varray; PetscFunctionBegin; PetscCheckTypeNames(v,VECSEQCUDA,VECMPICUDA); ierr = VecCUDAAllocateCheck(v);CHKERRQ(ierr); if (v->valid_GPU_array == PETSC_OFFLOAD_CPU) { ierr = PetscLogEventBegin(VEC_CUDACopyToGPU,v,0,0,0);CHKERRQ(ierr); veccuda=(Vec_CUDA*)v->spptr; varray=veccuda->GPUarray; err = hipMemcpy(varray,((Vec_Seq*)v->data)->array,v->map->n*sizeof(PetscScalar),hipMemcpyHostToDevice);CHKERRCUDA(err); ierr = PetscLogEventEnd(VEC_CUDACopyToGPU,v,0,0,0);CHKERRQ(ierr); v->valid_GPU_array = PETSC_OFFLOAD_BOTH; } PetscFunctionReturn(0); } PetscErrorCode VecCUDACopyToGPUSome(Vec v, PetscCUDAIndices ci) { PetscScalar *varray; PetscErrorCode ierr; hipError_t err; PetscScalar *cpuPtr, *gpuPtr; Vec_Seq *s; VecScatterCUDAIndices_PtoP ptop_scatter = (VecScatterCUDAIndices_PtoP)ci->scatter; PetscFunctionBegin; PetscCheckTypeNames(v,VECSEQCUDA,VECMPICUDA); ierr = VecCUDAAllocateCheck(v);CHKERRQ(ierr); if (v->valid_GPU_array == PETSC_OFFLOAD_CPU) { s = (Vec_Seq*)v->data; ierr = PetscLogEventBegin(VEC_CUDACopyToGPUSome,v,0,0,0);CHKERRQ(ierr); varray = ((Vec_CUDA*)v->spptr)->GPUarray; gpuPtr = varray + ptop_scatter->recvLowestIndex; cpuPtr = s->array + ptop_scatter->recvLowestIndex; /* Note : this code copies the smallest contiguous chunk of data containing ALL of the indices */ err = hipMemcpy(gpuPtr,cpuPtr,ptop_scatter->nr*sizeof(PetscScalar),hipMemcpyHostToDevice);CHKERRCUDA(err); // Set the buffer states v->valid_GPU_array = PETSC_OFFLOAD_BOTH; ierr = PetscLogEventEnd(VEC_CUDACopyToGPUSome,v,0,0,0);CHKERRQ(ierr); } PetscFunctionReturn(0); } /* VecCUDACopyFromGPU - Copies a vector from the GPU to the CPU unless we already have an up-to-date copy on the CPU */ PetscErrorCode VecCUDACopyFromGPU(Vec v) { PetscErrorCode ierr; hipError_t err; Vec_CUDA *veccuda; PetscScalar *varray; PetscFunctionBegin; PetscCheckTypeNames(v,VECSEQCUDA,VECMPICUDA); ierr = VecCUDAAllocateCheckHost(v);CHKERRQ(ierr); if (v->valid_GPU_array == PETSC_OFFLOAD_GPU) { ierr = PetscLogEventBegin(VEC_CUDACopyFromGPU,v,0,0,0);CHKERRQ(ierr); veccuda=(Vec_CUDA*)v->spptr; varray=veccuda->GPUarray; err = hipMemcpy(((Vec_Seq*)v->data)->array,varray,v->map->n*sizeof(PetscScalar),hipMemcpyDeviceToHost);CHKERRCUDA(err); ierr = PetscLogEventEnd(VEC_CUDACopyFromGPU,v,0,0,0);CHKERRQ(ierr); v->valid_GPU_array = PETSC_OFFLOAD_BOTH; } PetscFunctionReturn(0); } /* Note that this function only copies *some* of the values up from the GPU to CPU, which means that we need recombine the data at some point before using any of the standard functions. We could add another few flag-types to keep track of this, or treat things like VecGetArray VecRestoreArray where you have to always call in pairs */ PetscErrorCode VecCUDACopyFromGPUSome(Vec v, PetscCUDAIndices ci) { const PetscScalar *varray, *gpuPtr; PetscErrorCode ierr; hipError_t err; PetscScalar *cpuPtr; Vec_Seq *s; VecScatterCUDAIndices_PtoP ptop_scatter = (VecScatterCUDAIndices_PtoP)ci->scatter; PetscFunctionBegin; PetscCheckTypeNames(v,VECSEQCUDA,VECMPICUDA); ierr = VecCUDAAllocateCheckHost(v);CHKERRQ(ierr); if (v->valid_GPU_array == PETSC_OFFLOAD_GPU) { ierr = PetscLogEventBegin(VEC_CUDACopyFromGPUSome,v,0,0,0);CHKERRQ(ierr); varray=((Vec_CUDA*)v->spptr)->GPUarray; s = (Vec_Seq*)v->data; gpuPtr = varray + ptop_scatter->sendLowestIndex; cpuPtr = s->array + ptop_scatter->sendLowestIndex; /* Note : this code copies the smallest contiguous chunk of data containing ALL of the indices */ err = hipMemcpy(cpuPtr,gpuPtr,ptop_scatter->ns*sizeof(PetscScalar),hipMemcpyDeviceToHost);CHKERRCUDA(err); ierr = VecCUDARestoreArrayRead(v,&varray);CHKERRQ(ierr); ierr = PetscLogEventEnd(VEC_CUDACopyFromGPUSome,v,0,0,0);CHKERRQ(ierr); } PetscFunctionReturn(0); } /*MC VECSEQCUDA - VECSEQCUDA = "seqcuda" - The basic sequential vector, modified to use CUDA Options Database Keys: . -vec_type seqcuda - sets the vector type to VECSEQCUDA during a call to VecSetFromOptions() Level: beginner .seealso: VecCreate(), VecSetType(), VecSetFromOptions(), VecCreateSeqWithArray(), VECMPI, VecType, VecCreateMPI(), VecCreateSeq() M*/ PetscErrorCode VecAYPX_SeqCUDA(Vec yin,PetscScalar alpha,Vec xin) { const PetscScalar *xarray; PetscScalar *yarray; PetscErrorCode ierr; PetscBLASInt one=1,bn; PetscScalar sone=1.0; hipblasHandle_t cublasv2handle; hipblasStatus_t cberr; hipError_t err; PetscFunctionBegin; ierr = PetscCUBLASGetHandle(&cublasv2handle);CHKERRQ(ierr); ierr = PetscBLASIntCast(yin->map->n,&bn);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayReadWrite(yin,&yarray);CHKERRQ(ierr); if (alpha == (PetscScalar)0.0) { err = hipMemcpy(yarray,xarray,bn*sizeof(PetscScalar),hipMemcpyDeviceToDevice);CHKERRCUDA(err); } else if (alpha == (PetscScalar)1.0) { cberr = cublasXaxpy(cublasv2handle,bn,&alpha,xarray,one,yarray,one);CHKERRCUBLAS(cberr); ierr = PetscLogFlops(2.0*yin->map->n);CHKERRQ(ierr); } else { cberr = cublasXscal(cublasv2handle,bn,&alpha,yarray,one);CHKERRCUBLAS(cberr); cberr = cublasXaxpy(cublasv2handle,bn,&sone,xarray,one,yarray,one);CHKERRCUBLAS(cberr); ierr = PetscLogFlops(2.0*yin->map->n);CHKERRQ(ierr); } ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayReadWrite(yin,&yarray);CHKERRQ(ierr); PetscFunctionReturn(0); } PetscErrorCode VecAXPY_SeqCUDA(Vec yin,PetscScalar alpha,Vec xin) { const PetscScalar *xarray; PetscScalar *yarray; PetscErrorCode ierr; PetscBLASInt one=1,bn; hipblasHandle_t cublasv2handle; hipblasStatus_t cberr; PetscFunctionBegin; ierr = PetscCUBLASGetHandle(&cublasv2handle);CHKERRQ(ierr); if (alpha != (PetscScalar)0.0) { ierr = PetscBLASIntCast(yin->map->n,&bn);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayReadWrite(yin,&yarray);CHKERRQ(ierr); cberr = cublasXaxpy(cublasv2handle,bn,&alpha,xarray,one,yarray,one);CHKERRCUBLAS(cberr); ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayReadWrite(yin,&yarray);CHKERRQ(ierr); ierr = PetscLogFlops(2.0*yin->map->n);CHKERRQ(ierr); } PetscFunctionReturn(0); } PetscErrorCode VecPointwiseDivide_SeqCUDA(Vec win, Vec xin, Vec yin) { PetscInt n = xin->map->n; const PetscScalar *xarray=NULL,*yarray=NULL; PetscScalar *warray=NULL; thrust::device_ptr<const PetscScalar> xptr,yptr; thrust::device_ptr<PetscScalar> wptr; PetscErrorCode ierr; PetscFunctionBegin; ierr = VecCUDAGetArrayWrite(win,&warray);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin,&yarray);CHKERRQ(ierr); try { wptr = thrust::device_pointer_cast(warray); xptr = thrust::device_pointer_cast(xarray); yptr = thrust::device_pointer_cast(yarray); thrust::transform(xptr,xptr+n,yptr,wptr,thrust::divides<PetscScalar>()); ierr = WaitForGPU();CHKERRCUDA(ierr); } catch (char *ex) { SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Thrust error: %s", ex); } ierr = PetscLogFlops(n);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin,&yarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayWrite(win,&warray);CHKERRQ(ierr); PetscFunctionReturn(0); } PetscErrorCode VecWAXPY_SeqCUDA(Vec win,PetscScalar alpha,Vec xin, Vec yin) { const PetscScalar *xarray=NULL,*yarray=NULL; PetscScalar *warray=NULL; PetscErrorCode ierr; PetscBLASInt one=1,bn; hipblasHandle_t cublasv2handle; hipblasStatus_t cberr; hipError_t err; PetscFunctionBegin; ierr = PetscCUBLASGetHandle(&cublasv2handle);CHKERRQ(ierr); ierr = PetscBLASIntCast(win->map->n,&bn);CHKERRQ(ierr); if (alpha == (PetscScalar)0.0) { ierr = VecCopy_SeqCUDA(yin,win);CHKERRQ(ierr); } else { ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin,&yarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayWrite(win,&warray);CHKERRQ(ierr); err = hipMemcpy(warray,yarray,win->map->n*sizeof(PetscScalar),hipMemcpyDeviceToDevice);CHKERRCUDA(err); cberr = cublasXaxpy(cublasv2handle,bn,&alpha,xarray,one,warray,one);CHKERRCUBLAS(cberr); ierr = PetscLogFlops(2*win->map->n);CHKERRQ(ierr); ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin,&yarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayWrite(win,&warray);CHKERRQ(ierr); } PetscFunctionReturn(0); } PetscErrorCode VecMAXPY_SeqCUDA(Vec xin, PetscInt nv,const PetscScalar *alpha,Vec *y) { PetscErrorCode ierr; PetscInt n = xin->map->n,j,j_rem; PetscScalar alpha0,alpha1,alpha2,alpha3; PetscFunctionBegin; ierr = PetscLogFlops(nv*2.0*n);CHKERRQ(ierr); switch (j_rem=nv&0x3) { case 3: alpha0 = alpha[0]; alpha1 = alpha[1]; alpha2 = alpha[2]; alpha += 3; ierr = VecAXPY_SeqCUDA(xin,alpha0,y[0]);CHKERRQ(ierr); ierr = VecAXPY_SeqCUDA(xin,alpha1,y[1]);CHKERRQ(ierr); ierr = VecAXPY_SeqCUDA(xin,alpha2,y[2]);CHKERRQ(ierr); y += 3; break; case 2: alpha0 = alpha[0]; alpha1 = alpha[1]; alpha +=2; ierr = VecAXPY_SeqCUDA(xin,alpha0,y[0]);CHKERRQ(ierr); ierr = VecAXPY_SeqCUDA(xin,alpha1,y[1]);CHKERRQ(ierr); y +=2; break; case 1: alpha0 = *alpha++; ierr = VecAXPY_SeqCUDA(xin,alpha0,y[0]);CHKERRQ(ierr); y +=1; break; } for (j=j_rem; j<nv; j+=4) { alpha0 = alpha[0]; alpha1 = alpha[1]; alpha2 = alpha[2]; alpha3 = alpha[3]; alpha += 4; ierr = VecAXPY_SeqCUDA(xin,alpha0,y[0]);CHKERRQ(ierr); ierr = VecAXPY_SeqCUDA(xin,alpha1,y[1]);CHKERRQ(ierr); ierr = VecAXPY_SeqCUDA(xin,alpha2,y[2]);CHKERRQ(ierr); ierr = VecAXPY_SeqCUDA(xin,alpha3,y[3]);CHKERRQ(ierr); y += 4; } ierr = WaitForGPU();CHKERRCUDA(ierr); PetscFunctionReturn(0); } PetscErrorCode VecDot_SeqCUDA(Vec xin,Vec yin,PetscScalar *z) { const PetscScalar *xarray,*yarray; PetscErrorCode ierr; PetscBLASInt one=1,bn; hipblasHandle_t cublasv2handle; hipblasStatus_t cberr; PetscFunctionBegin; ierr = PetscCUBLASGetHandle(&cublasv2handle);CHKERRQ(ierr); ierr = PetscBLASIntCast(yin->map->n,&bn);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin,&yarray);CHKERRQ(ierr); /* arguments y, x are reversed because BLAS complex conjugates the first argument, PETSc the second */ cberr = cublasXdot(cublasv2handle,bn,yarray,one,xarray,one,z);CHKERRCUBLAS(cberr); ierr = WaitForGPU();CHKERRCUDA(ierr); if (xin->map->n >0) { ierr = PetscLogFlops(2.0*xin->map->n-1);CHKERRQ(ierr); } ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin,&yarray);CHKERRQ(ierr); PetscFunctionReturn(0); } // // CUDA kernels for MDot to follow // // set work group size to be a power of 2 (128 is usually a good compromise between portability and speed) #define MDOT_WORKGROUP_SIZE 128 #define MDOT_WORKGROUP_NUM 128 #if !defined(PETSC_USE_COMPLEX) // M = 2: __global__ void VecMDot_SeqCUDA_kernel2(const PetscScalar *x,const PetscScalar *y0,const PetscScalar *y1, PetscInt size, PetscScalar *group_results) { __shared__ PetscScalar tmp_buffer[2*MDOT_WORKGROUP_SIZE]; PetscInt entries_per_group = (size - 1) / gridDim.x + 1; entries_per_group = (entries_per_group == 0) ? 1 : entries_per_group; // for very small vectors, a group should still do some work PetscInt vec_start_index = blockIdx.x * entries_per_group; PetscInt vec_stop_index = PetscMin((blockIdx.x + 1) * entries_per_group, size); // don't go beyond vec size PetscScalar entry_x = 0; PetscScalar group_sum0 = 0; PetscScalar group_sum1 = 0; for (PetscInt i = vec_start_index + threadIdx.x; i < vec_stop_index; i += blockDim.x) { entry_x = x[i]; // load only once from global memory! group_sum0 += entry_x * y0[i]; group_sum1 += entry_x * y1[i]; } tmp_buffer[threadIdx.x] = group_sum0; tmp_buffer[threadIdx.x + MDOT_WORKGROUP_SIZE] = group_sum1; // parallel reduction for (PetscInt stride = blockDim.x/2; stride > 0; stride /= 2) { __syncthreads(); if (threadIdx.x < stride) { tmp_buffer[threadIdx.x ] += tmp_buffer[threadIdx.x+stride ]; tmp_buffer[threadIdx.x + MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + MDOT_WORKGROUP_SIZE]; } } // write result of group to group_results if (threadIdx.x == 0) { group_results[blockIdx.x] = tmp_buffer[0]; group_results[blockIdx.x + gridDim.x] = tmp_buffer[MDOT_WORKGROUP_SIZE]; } } // M = 3: __global__ void VecMDot_SeqCUDA_kernel3(const PetscScalar *x,const PetscScalar *y0,const PetscScalar *y1,const PetscScalar *y2, PetscInt size, PetscScalar *group_results) { __shared__ PetscScalar tmp_buffer[3*MDOT_WORKGROUP_SIZE]; PetscInt entries_per_group = (size - 1) / gridDim.x + 1; entries_per_group = (entries_per_group == 0) ? 1 : entries_per_group; // for very small vectors, a group should still do some work PetscInt vec_start_index = blockIdx.x * entries_per_group; PetscInt vec_stop_index = PetscMin((blockIdx.x + 1) * entries_per_group, size); // don't go beyond vec size PetscScalar entry_x = 0; PetscScalar group_sum0 = 0; PetscScalar group_sum1 = 0; PetscScalar group_sum2 = 0; for (PetscInt i = vec_start_index + threadIdx.x; i < vec_stop_index; i += blockDim.x) { entry_x = x[i]; // load only once from global memory! group_sum0 += entry_x * y0[i]; group_sum1 += entry_x * y1[i]; group_sum2 += entry_x * y2[i]; } tmp_buffer[threadIdx.x] = group_sum0; tmp_buffer[threadIdx.x + MDOT_WORKGROUP_SIZE] = group_sum1; tmp_buffer[threadIdx.x + 2 * MDOT_WORKGROUP_SIZE] = group_sum2; // parallel reduction for (PetscInt stride = blockDim.x/2; stride > 0; stride /= 2) { __syncthreads(); if (threadIdx.x < stride) { tmp_buffer[threadIdx.x ] += tmp_buffer[threadIdx.x+stride ]; tmp_buffer[threadIdx.x + MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + MDOT_WORKGROUP_SIZE]; tmp_buffer[threadIdx.x + 2 * MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + 2 * MDOT_WORKGROUP_SIZE]; } } // write result of group to group_results if (threadIdx.x == 0) { group_results[blockIdx.x ] = tmp_buffer[0]; group_results[blockIdx.x + gridDim.x] = tmp_buffer[ MDOT_WORKGROUP_SIZE]; group_results[blockIdx.x + 2 * gridDim.x] = tmp_buffer[2 * MDOT_WORKGROUP_SIZE]; } } // M = 4: __global__ void VecMDot_SeqCUDA_kernel4(const PetscScalar *x,const PetscScalar *y0,const PetscScalar *y1,const PetscScalar *y2,const PetscScalar *y3, PetscInt size, PetscScalar *group_results) { __shared__ PetscScalar tmp_buffer[4*MDOT_WORKGROUP_SIZE]; PetscInt entries_per_group = (size - 1) / gridDim.x + 1; entries_per_group = (entries_per_group == 0) ? 1 : entries_per_group; // for very small vectors, a group should still do some work PetscInt vec_start_index = blockIdx.x * entries_per_group; PetscInt vec_stop_index = PetscMin((blockIdx.x + 1) * entries_per_group, size); // don't go beyond vec size PetscScalar entry_x = 0; PetscScalar group_sum0 = 0; PetscScalar group_sum1 = 0; PetscScalar group_sum2 = 0; PetscScalar group_sum3 = 0; for (PetscInt i = vec_start_index + threadIdx.x; i < vec_stop_index; i += blockDim.x) { entry_x = x[i]; // load only once from global memory! group_sum0 += entry_x * y0[i]; group_sum1 += entry_x * y1[i]; group_sum2 += entry_x * y2[i]; group_sum3 += entry_x * y3[i]; } tmp_buffer[threadIdx.x] = group_sum0; tmp_buffer[threadIdx.x + MDOT_WORKGROUP_SIZE] = group_sum1; tmp_buffer[threadIdx.x + 2 * MDOT_WORKGROUP_SIZE] = group_sum2; tmp_buffer[threadIdx.x + 3 * MDOT_WORKGROUP_SIZE] = group_sum3; // parallel reduction for (PetscInt stride = blockDim.x/2; stride > 0; stride /= 2) { __syncthreads(); if (threadIdx.x < stride) { tmp_buffer[threadIdx.x ] += tmp_buffer[threadIdx.x+stride ]; tmp_buffer[threadIdx.x + MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + MDOT_WORKGROUP_SIZE]; tmp_buffer[threadIdx.x + 2 * MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + 2 * MDOT_WORKGROUP_SIZE]; tmp_buffer[threadIdx.x + 3 * MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + 3 * MDOT_WORKGROUP_SIZE]; } } // write result of group to group_results if (threadIdx.x == 0) { group_results[blockIdx.x ] = tmp_buffer[0]; group_results[blockIdx.x + gridDim.x] = tmp_buffer[ MDOT_WORKGROUP_SIZE]; group_results[blockIdx.x + 2 * gridDim.x] = tmp_buffer[2 * MDOT_WORKGROUP_SIZE]; group_results[blockIdx.x + 3 * gridDim.x] = tmp_buffer[3 * MDOT_WORKGROUP_SIZE]; } } // M = 8: __global__ void VecMDot_SeqCUDA_kernel8(const PetscScalar *x,const PetscScalar *y0,const PetscScalar *y1,const PetscScalar *y2,const PetscScalar *y3, const PetscScalar *y4,const PetscScalar *y5,const PetscScalar *y6,const PetscScalar *y7, PetscInt size, PetscScalar *group_results) { __shared__ PetscScalar tmp_buffer[8*MDOT_WORKGROUP_SIZE]; PetscInt entries_per_group = (size - 1) / gridDim.x + 1; entries_per_group = (entries_per_group == 0) ? 1 : entries_per_group; // for very small vectors, a group should still do some work PetscInt vec_start_index = blockIdx.x * entries_per_group; PetscInt vec_stop_index = PetscMin((blockIdx.x + 1) * entries_per_group, size); // don't go beyond vec size PetscScalar entry_x = 0; PetscScalar group_sum0 = 0; PetscScalar group_sum1 = 0; PetscScalar group_sum2 = 0; PetscScalar group_sum3 = 0; PetscScalar group_sum4 = 0; PetscScalar group_sum5 = 0; PetscScalar group_sum6 = 0; PetscScalar group_sum7 = 0; for (PetscInt i = vec_start_index + threadIdx.x; i < vec_stop_index; i += blockDim.x) { entry_x = x[i]; // load only once from global memory! group_sum0 += entry_x * y0[i]; group_sum1 += entry_x * y1[i]; group_sum2 += entry_x * y2[i]; group_sum3 += entry_x * y3[i]; group_sum4 += entry_x * y4[i]; group_sum5 += entry_x * y5[i]; group_sum6 += entry_x * y6[i]; group_sum7 += entry_x * y7[i]; } tmp_buffer[threadIdx.x] = group_sum0; tmp_buffer[threadIdx.x + MDOT_WORKGROUP_SIZE] = group_sum1; tmp_buffer[threadIdx.x + 2 * MDOT_WORKGROUP_SIZE] = group_sum2; tmp_buffer[threadIdx.x + 3 * MDOT_WORKGROUP_SIZE] = group_sum3; tmp_buffer[threadIdx.x + 4 * MDOT_WORKGROUP_SIZE] = group_sum4; tmp_buffer[threadIdx.x + 5 * MDOT_WORKGROUP_SIZE] = group_sum5; tmp_buffer[threadIdx.x + 6 * MDOT_WORKGROUP_SIZE] = group_sum6; tmp_buffer[threadIdx.x + 7 * MDOT_WORKGROUP_SIZE] = group_sum7; // parallel reduction for (PetscInt stride = blockDim.x/2; stride > 0; stride /= 2) { __syncthreads(); if (threadIdx.x < stride) { tmp_buffer[threadIdx.x ] += tmp_buffer[threadIdx.x+stride ]; tmp_buffer[threadIdx.x + MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + MDOT_WORKGROUP_SIZE]; tmp_buffer[threadIdx.x + 2 * MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + 2 * MDOT_WORKGROUP_SIZE]; tmp_buffer[threadIdx.x + 3 * MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + 3 * MDOT_WORKGROUP_SIZE]; tmp_buffer[threadIdx.x + 4 * MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + 4 * MDOT_WORKGROUP_SIZE]; tmp_buffer[threadIdx.x + 5 * MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + 5 * MDOT_WORKGROUP_SIZE]; tmp_buffer[threadIdx.x + 6 * MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + 6 * MDOT_WORKGROUP_SIZE]; tmp_buffer[threadIdx.x + 7 * MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + 7 * MDOT_WORKGROUP_SIZE]; } } // write result of group to group_results if (threadIdx.x == 0) { group_results[blockIdx.x ] = tmp_buffer[0]; group_results[blockIdx.x + gridDim.x] = tmp_buffer[ MDOT_WORKGROUP_SIZE]; group_results[blockIdx.x + 2 * gridDim.x] = tmp_buffer[2 * MDOT_WORKGROUP_SIZE]; group_results[blockIdx.x + 3 * gridDim.x] = tmp_buffer[3 * MDOT_WORKGROUP_SIZE]; group_results[blockIdx.x + 4 * gridDim.x] = tmp_buffer[4 * MDOT_WORKGROUP_SIZE]; group_results[blockIdx.x + 5 * gridDim.x] = tmp_buffer[5 * MDOT_WORKGROUP_SIZE]; group_results[blockIdx.x + 6 * gridDim.x] = tmp_buffer[6 * MDOT_WORKGROUP_SIZE]; group_results[blockIdx.x + 7 * gridDim.x] = tmp_buffer[7 * MDOT_WORKGROUP_SIZE]; } } #endif /* !defined(PETSC_USE_COMPLEX) */ PetscErrorCode VecMDot_SeqCUDA(Vec xin,PetscInt nv,const Vec yin[],PetscScalar *z) { PetscErrorCode ierr; PetscInt i,n = xin->map->n,current_y_index = 0; const PetscScalar *xptr,*y0ptr,*y1ptr,*y2ptr,*y3ptr,*y4ptr,*y5ptr,*y6ptr,*y7ptr; PetscScalar *group_results_gpu; #if !defined(PETSC_USE_COMPLEX) PetscInt j; PetscScalar group_results_cpu[MDOT_WORKGROUP_NUM * 8]; // we process at most eight vectors in one kernel #endif hipError_t cuda_ierr; PetscBLASInt one=1,bn; hipblasHandle_t cublasv2handle; hipblasStatus_t cberr; PetscFunctionBegin; ierr = PetscCUBLASGetHandle(&cublasv2handle);CHKERRQ(ierr); ierr = PetscBLASIntCast(xin->map->n,&bn);CHKERRQ(ierr); if (nv <= 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"Number of vectors provided to VecMDot_SeqCUDA not positive."); /* Handle the case of local size zero first */ if (!xin->map->n) { for (i=0; i<nv; ++i) z[i] = 0; PetscFunctionReturn(0); } // allocate scratchpad memory for the results of individual work groups: cuda_ierr = hipMalloc((void**)&group_results_gpu, sizeof(PetscScalar) * MDOT_WORKGROUP_NUM * 8);CHKERRCUDA(cuda_ierr); ierr = VecCUDAGetArrayRead(xin,&xptr);CHKERRQ(ierr); while (current_y_index < nv) { switch (nv - current_y_index) { case 7: case 6: case 5: case 4: ierr = VecCUDAGetArrayRead(yin[current_y_index ],&y0ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+1],&y1ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+2],&y2ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+3],&y3ptr);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) cberr = cublasXdot(cublasv2handle,bn,y0ptr,one,xptr,one,&z[current_y_index]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y1ptr,one,xptr,one,&z[current_y_index+1]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y2ptr,one,xptr,one,&z[current_y_index+2]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y3ptr,one,xptr,one,&z[current_y_index+3]);CHKERRCUBLAS(cberr); #else // run kernel: hipLaunchKernelGGL(( VecMDot_SeqCUDA_kernel4), dim3(MDOT_WORKGROUP_NUM),dim3(MDOT_WORKGROUP_SIZE), 0, 0, xptr,y0ptr,y1ptr,y2ptr,y3ptr,n,group_results_gpu); // copy results back to cuda_ierr = hipMemcpy(group_results_cpu,group_results_gpu,sizeof(PetscScalar) * MDOT_WORKGROUP_NUM * 4,hipMemcpyDeviceToHost);CHKERRCUDA(cuda_ierr); // sum group results into z: for (j=0; j<4; ++j) { z[current_y_index + j] = 0; for (i=j*MDOT_WORKGROUP_NUM; i<(j+1)*MDOT_WORKGROUP_NUM; ++i) z[current_y_index + j] += group_results_cpu[i]; } #endif ierr = VecCUDARestoreArrayRead(yin[current_y_index ],&y0ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+1],&y1ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+2],&y2ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+3],&y3ptr);CHKERRQ(ierr); current_y_index += 4; break; case 3: ierr = VecCUDAGetArrayRead(yin[current_y_index ],&y0ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+1],&y1ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+2],&y2ptr);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) cberr = cublasXdot(cublasv2handle,bn,y0ptr,one,xptr,one,&z[current_y_index]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y1ptr,one,xptr,one,&z[current_y_index+1]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y2ptr,one,xptr,one,&z[current_y_index+2]);CHKERRCUBLAS(cberr); #else // run kernel: hipLaunchKernelGGL(( VecMDot_SeqCUDA_kernel3), dim3(MDOT_WORKGROUP_NUM),dim3(MDOT_WORKGROUP_SIZE), 0, 0, xptr,y0ptr,y1ptr,y2ptr,n,group_results_gpu); // copy results back to cuda_ierr = hipMemcpy(group_results_cpu,group_results_gpu,sizeof(PetscScalar) * MDOT_WORKGROUP_NUM * 3,hipMemcpyDeviceToHost);CHKERRCUDA(cuda_ierr); // sum group results into z: for (j=0; j<3; ++j) { z[current_y_index + j] = 0; for (i=j*MDOT_WORKGROUP_NUM; i<(j+1)*MDOT_WORKGROUP_NUM; ++i) z[current_y_index + j] += group_results_cpu[i]; } #endif ierr = VecCUDARestoreArrayRead(yin[current_y_index ],&y0ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+1],&y1ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+2],&y2ptr);CHKERRQ(ierr); current_y_index += 3; break; case 2: ierr = VecCUDAGetArrayRead(yin[current_y_index],&y0ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+1],&y1ptr);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) cberr = cublasXdot(cublasv2handle,bn,y0ptr,one,xptr,one,&z[current_y_index]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y1ptr,one,xptr,one,&z[current_y_index+1]);CHKERRCUBLAS(cberr); #else // run kernel: hipLaunchKernelGGL(( VecMDot_SeqCUDA_kernel2), dim3(MDOT_WORKGROUP_NUM),dim3(MDOT_WORKGROUP_SIZE), 0, 0, xptr,y0ptr,y1ptr,n,group_results_gpu); // copy results back to cuda_ierr = hipMemcpy(group_results_cpu,group_results_gpu,sizeof(PetscScalar) * MDOT_WORKGROUP_NUM * 2,hipMemcpyDeviceToHost);CHKERRCUDA(cuda_ierr); // sum group results into z: for (j=0; j<2; ++j) { z[current_y_index + j] = 0; for (i=j*MDOT_WORKGROUP_NUM; i<(j+1)*MDOT_WORKGROUP_NUM; ++i) z[current_y_index + j] += group_results_cpu[i]; } #endif ierr = VecCUDARestoreArrayRead(yin[current_y_index],&y0ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+1],&y1ptr);CHKERRQ(ierr); current_y_index += 2; break; case 1: ierr = VecCUDAGetArrayRead(yin[current_y_index],&y0ptr);CHKERRQ(ierr); cberr = cublasXdot(cublasv2handle,bn,y0ptr,one,xptr,one,&z[current_y_index]);CHKERRCUBLAS(cberr); ierr = VecCUDARestoreArrayRead(yin[current_y_index],&y0ptr);CHKERRQ(ierr); current_y_index += 1; break; default: // 8 or more vectors left ierr = VecCUDAGetArrayRead(yin[current_y_index ],&y0ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+1],&y1ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+2],&y2ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+3],&y3ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+4],&y4ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+5],&y5ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+6],&y6ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+7],&y7ptr);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) cberr = cublasXdot(cublasv2handle,bn,y0ptr,one,xptr,one,&z[current_y_index]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y1ptr,one,xptr,one,&z[current_y_index+1]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y2ptr,one,xptr,one,&z[current_y_index+2]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y3ptr,one,xptr,one,&z[current_y_index+3]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y4ptr,one,xptr,one,&z[current_y_index+4]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y5ptr,one,xptr,one,&z[current_y_index+5]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y6ptr,one,xptr,one,&z[current_y_index+6]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y7ptr,one,xptr,one,&z[current_y_index+7]);CHKERRCUBLAS(cberr); #else // run kernel: hipLaunchKernelGGL(( VecMDot_SeqCUDA_kernel8), dim3(MDOT_WORKGROUP_NUM),dim3(MDOT_WORKGROUP_SIZE), 0, 0, xptr,y0ptr,y1ptr,y2ptr,y3ptr,y4ptr,y5ptr,y6ptr,y7ptr,n,group_results_gpu); // copy results back to cuda_ierr = hipMemcpy(group_results_cpu,group_results_gpu,sizeof(PetscScalar) * MDOT_WORKGROUP_NUM * 8,hipMemcpyDeviceToHost);CHKERRCUDA(cuda_ierr); // sum group results into z: for (j=0; j<8; ++j) { z[current_y_index + j] = 0; for (i=j*MDOT_WORKGROUP_NUM; i<(j+1)*MDOT_WORKGROUP_NUM; ++i) z[current_y_index + j] += group_results_cpu[i]; } #endif ierr = VecCUDARestoreArrayRead(yin[current_y_index ],&y0ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+1],&y1ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+2],&y2ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+3],&y3ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+4],&y4ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+5],&y5ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+6],&y6ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+7],&y7ptr);CHKERRQ(ierr); current_y_index += 8; break; } } ierr = VecCUDARestoreArrayRead(xin,&xptr);CHKERRQ(ierr); cuda_ierr = hipFree(group_results_gpu);CHKERRCUDA(cuda_ierr); ierr = PetscLogFlops(PetscMax(nv*(2.0*n-1),0.0));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef MDOT_WORKGROUP_SIZE #undef MDOT_WORKGROUP_NUM PetscErrorCode VecSet_SeqCUDA(Vec xin,PetscScalar alpha) { PetscInt n = xin->map->n; PetscScalar *xarray=NULL; thrust::device_ptr<PetscScalar> xptr; PetscErrorCode ierr; hipError_t err; PetscFunctionBegin; ierr = VecCUDAGetArrayWrite(xin,&xarray);CHKERRQ(ierr); if (alpha == (PetscScalar)0.0) { err = hipMemset(xarray,0,n*sizeof(PetscScalar));CHKERRCUDA(err); } else { try { xptr = thrust::device_pointer_cast(xarray); thrust::fill(xptr,xptr+n,alpha); } catch (char *ex) { SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Thrust error: %s", ex); } } ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = VecCUDARestoreArrayWrite(xin,&xarray); PetscFunctionReturn(0); } PetscErrorCode VecScale_SeqCUDA(Vec xin,PetscScalar alpha) { PetscScalar *xarray; PetscErrorCode ierr; PetscBLASInt one=1,bn; hipblasHandle_t cublasv2handle; hipblasStatus_t cberr; PetscFunctionBegin; if (alpha == (PetscScalar)0.0) { ierr = VecSet_SeqCUDA(xin,alpha);CHKERRQ(ierr); } else if (alpha != (PetscScalar)1.0) { ierr = PetscCUBLASGetHandle(&cublasv2handle);CHKERRQ(ierr); ierr = PetscBLASIntCast(xin->map->n,&bn);CHKERRQ(ierr); ierr = VecCUDAGetArrayReadWrite(xin,&xarray);CHKERRQ(ierr); cberr = cublasXscal(cublasv2handle,bn,&alpha,xarray,one);CHKERRCUBLAS(cberr); ierr = VecCUDARestoreArrayReadWrite(xin,&xarray);CHKERRQ(ierr); } ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = PetscLogFlops(xin->map->n);CHKERRQ(ierr); PetscFunctionReturn(0); } PetscErrorCode VecTDot_SeqCUDA(Vec xin,Vec yin,PetscScalar *z) { const PetscScalar *xarray,*yarray; PetscErrorCode ierr; PetscBLASInt one=1,bn; hipblasHandle_t cublasv2handle; hipblasStatus_t cberr; PetscFunctionBegin; ierr = PetscCUBLASGetHandle(&cublasv2handle);CHKERRQ(ierr); ierr = PetscBLASIntCast(xin->map->n,&bn);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin,&yarray);CHKERRQ(ierr); cberr = cublasXdotu(cublasv2handle,bn,xarray,one,yarray,one,z);CHKERRCUBLAS(cberr); ierr = WaitForGPU();CHKERRCUDA(ierr); if (xin->map->n > 0) { ierr = PetscLogFlops(2.0*xin->map->n-1);CHKERRQ(ierr); } ierr = VecCUDARestoreArrayRead(yin,&yarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); PetscFunctionReturn(0); } PetscErrorCode VecCopy_SeqCUDA(Vec xin,Vec yin) { const PetscScalar *xarray; PetscScalar *yarray; PetscErrorCode ierr; hipError_t err; PetscFunctionBegin; if (xin != yin) { if (xin->valid_GPU_array == PETSC_OFFLOAD_GPU) { ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayWrite(yin,&yarray);CHKERRQ(ierr); err = hipMemcpy(yarray,xarray,yin->map->n*sizeof(PetscScalar),hipMemcpyDeviceToDevice);CHKERRCUDA(err); ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayWrite(yin,&yarray);CHKERRQ(ierr); } else if (xin->valid_GPU_array == PETSC_OFFLOAD_CPU) { /* copy in CPU if we are on the CPU*/ ierr = VecCopy_SeqCUDA_Private(xin,yin);CHKERRQ(ierr); } else if (xin->valid_GPU_array == PETSC_OFFLOAD_BOTH) { /* if xin is valid in both places, see where yin is and copy there (because it's probably where we'll want to next use it) */ if (yin->valid_GPU_array == PETSC_OFFLOAD_CPU) { /* copy in CPU */ ierr = VecCopy_SeqCUDA_Private(xin,yin);CHKERRQ(ierr); } else if (yin->valid_GPU_array == PETSC_OFFLOAD_GPU) { /* copy in GPU */ ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayWrite(yin,&yarray);CHKERRQ(ierr); err = hipMemcpy(yarray,xarray,yin->map->n*sizeof(PetscScalar),hipMemcpyDeviceToDevice);CHKERRCUDA(err); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayWrite(yin,&yarray);CHKERRQ(ierr); } else if (yin->valid_GPU_array == PETSC_OFFLOAD_BOTH) { /* xin and yin are both valid in both places (or yin was unallocated before the earlier call to allocatecheck default to copy in GPU (this is an arbitrary choice) */ ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayWrite(yin,&yarray);CHKERRQ(ierr); err = hipMemcpy(yarray,xarray,yin->map->n*sizeof(PetscScalar),hipMemcpyDeviceToDevice);CHKERRCUDA(err); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayWrite(yin,&yarray);CHKERRQ(ierr); } else { ierr = VecCopy_SeqCUDA_Private(xin,yin);CHKERRQ(ierr); } } } PetscFunctionReturn(0); } PetscErrorCode VecSwap_SeqCUDA(Vec xin,Vec yin) { PetscErrorCode ierr; PetscBLASInt one = 1,bn; PetscScalar *xarray,*yarray; hipblasHandle_t cublasv2handle; hipblasStatus_t cberr; PetscFunctionBegin; ierr = PetscCUBLASGetHandle(&cublasv2handle);CHKERRQ(ierr); ierr = PetscBLASIntCast(xin->map->n,&bn);CHKERRQ(ierr); if (xin != yin) { ierr = VecCUDAGetArrayReadWrite(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayReadWrite(yin,&yarray);CHKERRQ(ierr); cberr = cublasXswap(cublasv2handle,bn,xarray,one,yarray,one);CHKERRCUBLAS(cberr); ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = VecCUDARestoreArrayReadWrite(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayReadWrite(yin,&yarray);CHKERRQ(ierr); } PetscFunctionReturn(0); } PetscErrorCode VecAXPBY_SeqCUDA(Vec yin,PetscScalar alpha,PetscScalar beta,Vec xin) { PetscErrorCode ierr; PetscScalar a = alpha,b = beta; const PetscScalar *xarray; PetscScalar *yarray; PetscBLASInt one = 1, bn; hipblasHandle_t cublasv2handle; hipblasStatus_t cberr; hipError_t err; PetscFunctionBegin; ierr = PetscCUBLASGetHandle(&cublasv2handle);CHKERRQ(ierr); ierr = PetscBLASIntCast(yin->map->n,&bn);CHKERRQ(ierr); if (a == (PetscScalar)0.0) { ierr = VecScale_SeqCUDA(yin,beta);CHKERRQ(ierr); } else if (b == (PetscScalar)1.0) { ierr = VecAXPY_SeqCUDA(yin,alpha,xin);CHKERRQ(ierr); } else if (a == (PetscScalar)1.0) { ierr = VecAYPX_SeqCUDA(yin,beta,xin);CHKERRQ(ierr); } else if (b == (PetscScalar)0.0) { ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayReadWrite(yin,&yarray);CHKERRQ(ierr); err = hipMemcpy(yarray,xarray,yin->map->n*sizeof(PetscScalar),hipMemcpyDeviceToDevice);CHKERRCUDA(err); cberr = cublasXscal(cublasv2handle,bn,&alpha,yarray,one);CHKERRCUBLAS(cberr); ierr = PetscLogFlops(xin->map->n);CHKERRQ(ierr); ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayReadWrite(yin,&yarray);CHKERRQ(ierr); } else { ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayReadWrite(yin,&yarray);CHKERRQ(ierr); cberr = cublasXscal(cublasv2handle,bn,&beta,yarray,one);CHKERRCUBLAS(cberr); cberr = cublasXaxpy(cublasv2handle,bn,&alpha,xarray,one,yarray,one);CHKERRCUBLAS(cberr); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayReadWrite(yin,&yarray);CHKERRQ(ierr); ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = PetscLogFlops(3.0*xin->map->n);CHKERRQ(ierr); } PetscFunctionReturn(0); } PetscErrorCode VecAXPBYPCZ_SeqCUDA(Vec zin,PetscScalar alpha,PetscScalar beta,PetscScalar gamma,Vec xin,Vec yin) { PetscErrorCode ierr; PetscInt n = zin->map->n; PetscFunctionBegin; if (gamma == (PetscScalar)1.0) { /* z = ax + b*y + z */ ierr = VecAXPY_SeqCUDA(zin,alpha,xin);CHKERRQ(ierr); ierr = VecAXPY_SeqCUDA(zin,beta,yin);CHKERRQ(ierr); ierr = PetscLogFlops(4.0*n);CHKERRQ(ierr); } else { /* z = a*x + b*y + c*z */ ierr = VecScale_SeqCUDA(zin,gamma);CHKERRQ(ierr); ierr = VecAXPY_SeqCUDA(zin,alpha,xin);CHKERRQ(ierr); ierr = VecAXPY_SeqCUDA(zin,beta,yin);CHKERRQ(ierr); ierr = PetscLogFlops(5.0*n);CHKERRQ(ierr); } ierr = WaitForGPU();CHKERRCUDA(ierr); PetscFunctionReturn(0); } PetscErrorCode VecPointwiseMult_SeqCUDA(Vec win,Vec xin,Vec yin) { PetscInt n = win->map->n; const PetscScalar *xarray,*yarray; PetscScalar *warray; thrust::device_ptr<const PetscScalar> xptr,yptr; thrust::device_ptr<PetscScalar> wptr; PetscErrorCode ierr; PetscFunctionBegin; ierr = VecCUDAGetArrayReadWrite(win,&warray);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin,&yarray);CHKERRQ(ierr); try { wptr = thrust::device_pointer_cast(warray); xptr = thrust::device_pointer_cast(xarray); yptr = thrust::device_pointer_cast(yarray); thrust::transform(xptr,xptr+n,yptr,wptr,thrust::multiplies<PetscScalar>()); ierr = WaitForGPU();CHKERRCUDA(ierr); } catch (char *ex) { SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Thrust error: %s", ex); } ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin,&yarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayReadWrite(win,&warray);CHKERRQ(ierr); ierr = PetscLogFlops(n);CHKERRQ(ierr); PetscFunctionReturn(0); } /* should do infinity norm in cuda */ PetscErrorCode VecNorm_SeqCUDA(Vec xin,NormType type,PetscReal *z) { PetscErrorCode ierr; PetscInt n = xin->map->n; PetscBLASInt one = 1, bn; const PetscScalar *xarray; hipblasHandle_t cublasv2handle; hipblasStatus_t cberr; hipError_t err; PetscFunctionBegin; ierr = PetscCUBLASGetHandle(&cublasv2handle);CHKERRQ(ierr); ierr = PetscBLASIntCast(n,&bn);CHKERRQ(ierr); if (type == NORM_2 || type == NORM_FROBENIUS) { ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); cberr = cublasXnrm2(cublasv2handle,bn,xarray,one,z);CHKERRCUBLAS(cberr); ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = PetscLogFlops(PetscMax(2.0*n-1,0.0));CHKERRQ(ierr); } else if (type == NORM_INFINITY) { int i; ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); cberr = cublasIXamax(cublasv2handle,bn,xarray,one,&i);CHKERRCUBLAS(cberr); err = hipMemcpy(z,xarray+i,sizeof(PetscScalar),hipMemcpyDeviceToHost);CHKERRCUDA(err); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); } else if (type == NORM_1) { ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); cberr = cublasXasum(cublasv2handle,bn,xarray,one,z);CHKERRCUBLAS(cberr); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = PetscLogFlops(PetscMax(n-1.0,0.0));CHKERRQ(ierr); } else if (type == NORM_1_AND_2) { ierr = VecNorm_SeqCUDA(xin,NORM_1,z);CHKERRQ(ierr); ierr = VecNorm_SeqCUDA(xin,NORM_2,z+1);CHKERRQ(ierr); } PetscFunctionReturn(0); } PetscErrorCode VecDotNorm2_SeqCUDA(Vec s, Vec t, PetscScalar *dp, PetscScalar *nm) { PetscErrorCode ierr; PetscReal n=s->map->n; const PetscScalar *sarray,*tarray; PetscFunctionBegin; ierr = VecCUDAGetArrayRead(s,&sarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(t,&tarray);CHKERRQ(ierr); ierr = VecDot_SeqCUDA(s,t,dp);CHKERRQ(ierr); ierr = VecDot_SeqCUDA(t,t,nm);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(s,&sarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(t,&tarray);CHKERRQ(ierr); ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = PetscLogFlops(4.0*n);CHKERRQ(ierr); PetscFunctionReturn(0); } PetscErrorCode VecDestroy_SeqCUDA(Vec v) { PetscErrorCode ierr; hipError_t err; PetscFunctionBegin; if (v->spptr) { if (((Vec_CUDA*)v->spptr)->GPUarray_allocated) { err = hipFree(((Vec_CUDA*)v->spptr)->GPUarray_allocated);CHKERRCUDA(err); ((Vec_CUDA*)v->spptr)->GPUarray_allocated = NULL; } if (((Vec_CUDA*)v->spptr)->stream) { err = hipStreamDestroy(((Vec_CUDA*)v->spptr)->stream);CHKERRCUDA(err); } ierr = PetscFree(v->spptr);CHKERRQ(ierr); } ierr = VecDestroy_SeqCUDA_Private(v);CHKERRQ(ierr); PetscFunctionReturn(0); } #if defined(PETSC_USE_COMPLEX) struct conjugate { __host__ __device__ PetscScalar operator()(PetscScalar x) { return PetscConj(x); } }; #endif PetscErrorCode VecConjugate_SeqCUDA(Vec xin) { PetscScalar *xarray; PetscErrorCode ierr; #if defined(PETSC_USE_COMPLEX) PetscInt n = xin->map->n; thrust::device_ptr<PetscScalar> xptr; #endif PetscFunctionBegin; ierr = VecCUDAGetArrayReadWrite(xin,&xarray);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) try { xptr = thrust::device_pointer_cast(xarray); thrust::transform(xptr,xptr+n,xptr,conjugate()); ierr = WaitForGPU();CHKERRCUDA(ierr); } catch (char *ex) { SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Thrust error: %s", ex); } #endif ierr = VecCUDARestoreArrayReadWrite(xin,&xarray);CHKERRQ(ierr); PetscFunctionReturn(0); } PetscErrorCode VecGetLocalVector_SeqCUDA(Vec v,Vec w) { PetscErrorCode ierr; hipError_t err; PetscFunctionBegin; PetscValidHeaderSpecific(v,VEC_CLASSID,1); PetscValidHeaderSpecific(w,VEC_CLASSID,2); PetscCheckTypeName(w,VECSEQCUDA); if (w->data) { if (((Vec_Seq*)w->data)->array_allocated) { ierr = PetscFree(((Vec_Seq*)w->data)->array_allocated);CHKERRQ(ierr); } ((Vec_Seq*)w->data)->array = NULL; ((Vec_Seq*)w->data)->unplacedarray = NULL; } if (w->spptr) { if (((Vec_CUDA*)w->spptr)->GPUarray) { err = hipFree(((Vec_CUDA*)w->spptr)->GPUarray);CHKERRCUDA(err); ((Vec_CUDA*)w->spptr)->GPUarray = NULL; } err = hipStreamDestroy(((Vec_CUDA*)w->spptr)->stream);CHKERRCUDA(err); ierr = PetscFree(w->spptr);CHKERRQ(ierr); } if (v->petscnative) { ierr = PetscFree(w->data);CHKERRQ(ierr); w->data = v->data; w->valid_GPU_array = v->valid_GPU_array; w->spptr = v->spptr; ierr = PetscObjectStateIncrease((PetscObject)w);CHKERRQ(ierr); } else { ierr = VecGetArray(v,&((Vec_Seq*)w->data)->array);CHKERRQ(ierr); w->valid_GPU_array = PETSC_OFFLOAD_CPU; ierr = VecCUDAAllocateCheck(w);CHKERRQ(ierr); } PetscFunctionReturn(0); } PetscErrorCode VecRestoreLocalVector_SeqCUDA(Vec v,Vec w) { PetscErrorCode ierr; hipError_t err; PetscFunctionBegin; PetscValidHeaderSpecific(v,VEC_CLASSID,1); PetscValidHeaderSpecific(w,VEC_CLASSID,2); PetscCheckTypeName(w,VECSEQCUDA); if (v->petscnative) { v->data = w->data; v->valid_GPU_array = w->valid_GPU_array; v->spptr = w->spptr; ierr = VecCUDACopyFromGPU(v);CHKERRQ(ierr); ierr = PetscObjectStateIncrease((PetscObject)v);CHKERRQ(ierr); w->data = 0; w->valid_GPU_array = PETSC_OFFLOAD_UNALLOCATED; w->spptr = 0; } else { ierr = VecRestoreArray(v,&((Vec_Seq*)w->data)->array);CHKERRQ(ierr); if ((Vec_CUDA*)w->spptr) { err = hipFree(((Vec_CUDA*)w->spptr)->GPUarray);CHKERRCUDA(err); ((Vec_CUDA*)w->spptr)->GPUarray = NULL; err = hipStreamDestroy(((Vec_CUDA*)w->spptr)->stream);CHKERRCUDA(err); ierr = PetscFree(w->spptr);CHKERRQ(ierr); } } PetscFunctionReturn(0); } /*@C VecCUDAGetArrayReadWrite - Provides access to the CUDA buffer inside a vector. This function has semantics similar to VecGetArray(): the pointer returned by this function points to a consistent view of the vector data. This may involve a copy operation of data from the host to the device if the data on the device is out of date. If the device memory hasn't been allocated previously it will be allocated as part of this function call. VecCUDAGetArrayReadWrite() assumes that the user will modify the vector data. This is similar to intent(inout) in fortran. The CUDA device pointer has to be released by calling VecCUDARestoreArrayReadWrite(). Upon restoring the vector data the data on the host will be marked as out of date. A subsequent access of the host data will thus incur a data transfer from the device to the host. Input Parameter: . v - the vector Output Parameter: . a - the CUDA device pointer Fortran note: This function is not currently available from Fortran. Level: intermediate .seealso: VecCUDARestoreArrayReadWrite(), VecCUDAGetArrayRead(), VecCUDAGetArrayWrite(), VecGetArray(), VecGetArrayRead() @*/ PETSC_EXTERN PetscErrorCode VecCUDAGetArrayReadWrite(Vec v, PetscScalar **a) { PetscErrorCode ierr; PetscFunctionBegin; PetscCheckTypeNames(v,VECSEQCUDA,VECMPICUDA); *a = 0; ierr = VecCUDACopyToGPU(v);CHKERRQ(ierr); *a = ((Vec_CUDA*)v->spptr)->GPUarray; PetscFunctionReturn(0); } /*@C VecCUDARestoreArrayReadWrite - Restore a CUDA device pointer previously acquired with VecCUDAGetArrayReadWrite(). This marks the host data as out of date. Subsequent access to the vector data on the host side with for instance VecGetArray() incurs a data transfer. Input Parameter: + v - the vector - a - the CUDA device pointer. This pointer is invalid after VecCUDARestoreArrayReadWrite() returns. Fortran note: This function is not currently available from Fortran. Level: intermediate .seealso: VecCUDAGetArrayReadWrite(), VecCUDAGetArrayRead(), VecCUDAGetArrayWrite(), VecGetArray(), VecRestoreArray(), VecGetArrayRead() @*/ PETSC_EXTERN PetscErrorCode VecCUDARestoreArrayReadWrite(Vec v, PetscScalar **a) { PetscErrorCode ierr; PetscFunctionBegin; PetscCheckTypeNames(v,VECSEQCUDA,VECMPICUDA); v->valid_GPU_array = PETSC_OFFLOAD_GPU; ierr = PetscObjectStateIncrease((PetscObject)v);CHKERRQ(ierr); PetscFunctionReturn(0); } /*@C VecCUDAGetArrayRead - Provides read access to the CUDA buffer inside a vector. This function is analogous to VecGetArrayRead(): The pointer returned by this function points to a consistent view of the vector data. This may involve a copy operation of data from the host to the device if the data on the device is out of date. If the device memory hasn't been allocated previously it will be allocated as part of this function call. VecCUDAGetArrayRead() assumes that the user will not modify the vector data. This is analgogous to intent(in) in Fortran. The CUDA device pointer has to be released by calling VecCUDARestoreArrayRead(). If the data on the host side was previously up to date it will remain so, i.e. data on both the device and the host is up to date. Accessing data on the host side does not incur a device to host data transfer. Input Parameter: . v - the vector Output Parameter: . a - the CUDA pointer. Fortran note: This function is not currently available from Fortran. Level: intermediate .seealso: VecCUDARestoreArrayRead(), VecCUDAGetArrayReadWrite(), VecCUDAGetArrayWrite(), VecGetArray(), VecGetArrayRead() @*/ PETSC_EXTERN PetscErrorCode VecCUDAGetArrayRead(Vec v, const PetscScalar **a) { PetscErrorCode ierr; PetscFunctionBegin; PetscCheckTypeNames(v,VECSEQCUDA,VECMPICUDA); *a = 0; ierr = VecCUDACopyToGPU(v);CHKERRQ(ierr); *a = ((Vec_CUDA*)v->spptr)->GPUarray; PetscFunctionReturn(0); } /*@C VecCUDARestoreArrayRead - Restore a CUDA device pointer previously acquired with VecCUDAGetArrayRead(). If the data on the host side was previously up to date it will remain so, i.e. data on both the device and the host is up to date. Accessing data on the host side e.g. with VecGetArray() does not incur a device to host data transfer. Input Parameter: + v - the vector - a - the CUDA device pointer. This pointer is invalid after VecCUDARestoreArrayRead() returns. Fortran note: This function is not currently available from Fortran. Level: intermediate .seealso: VecCUDAGetArrayRead(), VecCUDAGetArrayWrite(), VecCUDAGetArrayReadWrite(), VecGetArray(), VecRestoreArray(), VecGetArrayRead() @*/ PETSC_EXTERN PetscErrorCode VecCUDARestoreArrayRead(Vec v, const PetscScalar **a) { PetscFunctionBegin; PetscCheckTypeNames(v,VECSEQCUDA,VECMPICUDA); PetscFunctionReturn(0); } /*@C VecCUDAGetArrayWrite - Provides write access to the CUDA buffer inside a vector. The data pointed to by the device pointer is uninitialized. The user may not read from this data. Furthermore, the entire array needs to be filled by the user to obtain well-defined behaviour. The device memory will be allocated by this function if it hasn't been allocated previously. This is analogous to intent(out) in Fortran. The device pointer needs to be released with VecCUDARestoreArrayWrite(). When the pointer is released the host data of the vector is marked as out of data. Subsequent access of the host data with e.g. VecGetArray() incurs a device to host data transfer. Input Parameter: . v - the vector Output Parameter: . a - the CUDA pointer Fortran note: This function is not currently available from Fortran. Level: advanced .seealso: VecCUDARestoreArrayWrite(), VecCUDAGetArrayReadWrite(), VecCUDAGetArrayRead(), VecCUDAGetArrayWrite(), VecGetArray(), VecGetArrayRead() @*/ PETSC_EXTERN PetscErrorCode VecCUDAGetArrayWrite(Vec v, PetscScalar **a) { PetscErrorCode ierr; PetscFunctionBegin; PetscCheckTypeNames(v,VECSEQCUDA,VECMPICUDA); *a = 0; ierr = VecCUDAAllocateCheck(v);CHKERRQ(ierr); *a = ((Vec_CUDA*)v->spptr)->GPUarray; PetscFunctionReturn(0); } /*@C VecCUDARestoreArrayWrite - Restore a CUDA device pointer previously acquired with VecCUDAGetArrayWrite(). Data on the host will be marked as out of date. Subsequent access of the data on the host side e.g. with VecGetArray() will incur a device to host data transfer. Input Parameter: + v - the vector - a - the CUDA device pointer. This pointer is invalid after VecCUDARestoreArrayWrite() returns. Fortran note: This function is not currently available from Fortran. Level: intermediate .seealso: VecCUDAGetArrayWrite(), VecCUDAGetArrayReadWrite(), VecCUDAGetArrayRead(), VecCUDAGetArrayWrite(), VecGetArray(), VecRestoreArray(), VecGetArrayRead() @*/ PETSC_EXTERN PetscErrorCode VecCUDARestoreArrayWrite(Vec v, PetscScalar **a) { PetscErrorCode ierr; PetscFunctionBegin; PetscCheckTypeNames(v,VECSEQCUDA,VECMPICUDA); v->valid_GPU_array = PETSC_OFFLOAD_GPU; ierr = PetscObjectStateIncrease((PetscObject)v);CHKERRQ(ierr); PetscFunctionReturn(0); } /*@C VecCUDAPlaceArray - Allows one to replace the GPU array in a vector with a GPU array provided by the user. This is useful to avoid copying an array into a vector. Not Collective Input Parameters: + vec - the vector - array - the GPU array Notes: You can return to the original GPU array with a call to VecCUDAResetArray() It is not possible to use VecCUDAPlaceArray() and VecPlaceArray() at the same time on the same vector. Level: developer .seealso: VecPlaceArray(), VecGetArray(), VecRestoreArray(), VecReplaceArray(), VecResetArray(), VecCUDAResetArray(), VecCUDAReplaceArray() @*/ PetscErrorCode VecCUDAPlaceArray(Vec vin,PetscScalar *a) { PetscErrorCode ierr; PetscFunctionBegin; PetscCheckTypeNames(vin,VECSEQCUDA,VECMPICUDA); ierr = VecCUDACopyToGPU(vin);CHKERRQ(ierr); if (((Vec_Seq*)vin->data)->unplacedarray) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"VecCUDAPlaceArray()/VecPlaceArray() was already called on this vector, without a call to VecCUDAResetArray()/VecResetArray()"); ((Vec_Seq*)vin->data)->unplacedarray = (PetscScalar *) ((Vec_CUDA*)vin->spptr)->GPUarray; /* save previous GPU array so reset can bring it back */ ((Vec_CUDA*)vin->spptr)->GPUarray = a; vin->valid_GPU_array = PETSC_OFFLOAD_GPU; ierr = PetscObjectStateIncrease((PetscObject)vin);CHKERRQ(ierr); PetscFunctionReturn(0); } /*@C VecCUDAReplaceArray - Allows one to replace the GPU array in a vector with a GPU array provided by the user. This is useful to avoid copying a GPU array into a vector. Not Collective Input Parameters: + vec - the vector - array - the GPU array Notes: This permanently replaces the GPU array and frees the memory associated with the old GPU array. The memory passed in CANNOT be freed by the user. It will be freed when the vector is destroyed. Not supported from Fortran Level: developer .seealso: VecGetArray(), VecRestoreArray(), VecPlaceArray(), VecResetArray(), VecCUDAResetArray(), VecCUDAPlaceArray(), VecReplaceArray() @*/ PetscErrorCode VecCUDAReplaceArray(Vec vin,PetscScalar *a) { hipError_t err; PetscErrorCode ierr; PetscFunctionBegin; PetscCheckTypeNames(vin,VECSEQCUDA,VECMPICUDA); err = hipFree(((Vec_CUDA*)vin->spptr)->GPUarray);CHKERRCUDA(err); ((Vec_CUDA*)vin->spptr)->GPUarray = a; vin->valid_GPU_array = PETSC_OFFLOAD_GPU; ierr = PetscObjectStateIncrease((PetscObject)vin);CHKERRQ(ierr); PetscFunctionReturn(0); } /*@C VecCUDAResetArray - Resets a vector to use its default memory. Call this after the use of VecCUDAPlaceArray(). Not Collective Input Parameters: . vec - the vector Level: developer .seealso: VecGetArray(), VecRestoreArray(), VecReplaceArray(), VecPlaceArray(), VecResetArray(), VecCUDAPlaceArray(), VecCUDAReplaceArray() @*/ PetscErrorCode VecCUDAResetArray(Vec vin) { PetscErrorCode ierr; PetscFunctionBegin; PetscCheckTypeNames(vin,VECSEQCUDA,VECMPICUDA); ierr = VecCUDACopyToGPU(vin);CHKERRQ(ierr); ((Vec_CUDA*)vin->spptr)->GPUarray = (PetscScalar *) ((Vec_Seq*)vin->data)->unplacedarray; ((Vec_Seq*)vin->data)->unplacedarray = 0; vin->valid_GPU_array = PETSC_OFFLOAD_GPU; ierr = PetscObjectStateIncrease((PetscObject)vin);CHKERRQ(ierr); PetscFunctionReturn(0); }
d6f872fc2a226a445b88aa9c9f7e05d9a76d6a60.cu
/* Implements the sequential cuda vectors. */ #define PETSC_SKIP_SPINLOCK #include <petscconf.h> #include <petsc/private/vecimpl.h> #include <../src/vec/vec/impls/dvecimpl.h> #include <../src/vec/vec/impls/seq/seqcuda/cudavecimpl.h> #include <cuda_runtime.h> #include <thrust/device_ptr.h> #include <thrust/transform.h> #include <thrust/functional.h> /* Allocates space for the vector array on the GPU if it does not exist. Does NOT change the PetscCUDAFlag for the vector Does NOT zero the CUDA array */ PetscErrorCode VecCUDAAllocateCheck(Vec v) { PetscErrorCode ierr; cudaError_t err; cudaStream_t stream; Vec_CUDA *veccuda; PetscFunctionBegin; if (!v->spptr) { ierr = PetscMalloc(sizeof(Vec_CUDA),&v->spptr);CHKERRQ(ierr); veccuda = (Vec_CUDA*)v->spptr; err = cudaMalloc((void**)&veccuda->GPUarray_allocated,sizeof(PetscScalar)*((PetscBLASInt)v->map->n));CHKERRCUDA(err); veccuda->GPUarray = veccuda->GPUarray_allocated; err = cudaStreamCreate(&stream);CHKERRCUDA(err); veccuda->stream = stream; veccuda->hostDataRegisteredAsPageLocked = PETSC_FALSE; if (v->valid_GPU_array == PETSC_OFFLOAD_UNALLOCATED) { if (v->data && ((Vec_Seq*)v->data)->array) { v->valid_GPU_array = PETSC_OFFLOAD_CPU; } else { v->valid_GPU_array = PETSC_OFFLOAD_GPU; } } } PetscFunctionReturn(0); } /* Copies a vector from the CPU to the GPU unless we already have an up-to-date copy on the GPU */ PetscErrorCode VecCUDACopyToGPU(Vec v) { PetscErrorCode ierr; cudaError_t err; Vec_CUDA *veccuda; PetscScalar *varray; PetscFunctionBegin; PetscCheckTypeNames(v,VECSEQCUDA,VECMPICUDA); ierr = VecCUDAAllocateCheck(v);CHKERRQ(ierr); if (v->valid_GPU_array == PETSC_OFFLOAD_CPU) { ierr = PetscLogEventBegin(VEC_CUDACopyToGPU,v,0,0,0);CHKERRQ(ierr); veccuda=(Vec_CUDA*)v->spptr; varray=veccuda->GPUarray; err = cudaMemcpy(varray,((Vec_Seq*)v->data)->array,v->map->n*sizeof(PetscScalar),cudaMemcpyHostToDevice);CHKERRCUDA(err); ierr = PetscLogEventEnd(VEC_CUDACopyToGPU,v,0,0,0);CHKERRQ(ierr); v->valid_GPU_array = PETSC_OFFLOAD_BOTH; } PetscFunctionReturn(0); } PetscErrorCode VecCUDACopyToGPUSome(Vec v, PetscCUDAIndices ci) { PetscScalar *varray; PetscErrorCode ierr; cudaError_t err; PetscScalar *cpuPtr, *gpuPtr; Vec_Seq *s; VecScatterCUDAIndices_PtoP ptop_scatter = (VecScatterCUDAIndices_PtoP)ci->scatter; PetscFunctionBegin; PetscCheckTypeNames(v,VECSEQCUDA,VECMPICUDA); ierr = VecCUDAAllocateCheck(v);CHKERRQ(ierr); if (v->valid_GPU_array == PETSC_OFFLOAD_CPU) { s = (Vec_Seq*)v->data; ierr = PetscLogEventBegin(VEC_CUDACopyToGPUSome,v,0,0,0);CHKERRQ(ierr); varray = ((Vec_CUDA*)v->spptr)->GPUarray; gpuPtr = varray + ptop_scatter->recvLowestIndex; cpuPtr = s->array + ptop_scatter->recvLowestIndex; /* Note : this code copies the smallest contiguous chunk of data containing ALL of the indices */ err = cudaMemcpy(gpuPtr,cpuPtr,ptop_scatter->nr*sizeof(PetscScalar),cudaMemcpyHostToDevice);CHKERRCUDA(err); // Set the buffer states v->valid_GPU_array = PETSC_OFFLOAD_BOTH; ierr = PetscLogEventEnd(VEC_CUDACopyToGPUSome,v,0,0,0);CHKERRQ(ierr); } PetscFunctionReturn(0); } /* VecCUDACopyFromGPU - Copies a vector from the GPU to the CPU unless we already have an up-to-date copy on the CPU */ PetscErrorCode VecCUDACopyFromGPU(Vec v) { PetscErrorCode ierr; cudaError_t err; Vec_CUDA *veccuda; PetscScalar *varray; PetscFunctionBegin; PetscCheckTypeNames(v,VECSEQCUDA,VECMPICUDA); ierr = VecCUDAAllocateCheckHost(v);CHKERRQ(ierr); if (v->valid_GPU_array == PETSC_OFFLOAD_GPU) { ierr = PetscLogEventBegin(VEC_CUDACopyFromGPU,v,0,0,0);CHKERRQ(ierr); veccuda=(Vec_CUDA*)v->spptr; varray=veccuda->GPUarray; err = cudaMemcpy(((Vec_Seq*)v->data)->array,varray,v->map->n*sizeof(PetscScalar),cudaMemcpyDeviceToHost);CHKERRCUDA(err); ierr = PetscLogEventEnd(VEC_CUDACopyFromGPU,v,0,0,0);CHKERRQ(ierr); v->valid_GPU_array = PETSC_OFFLOAD_BOTH; } PetscFunctionReturn(0); } /* Note that this function only copies *some* of the values up from the GPU to CPU, which means that we need recombine the data at some point before using any of the standard functions. We could add another few flag-types to keep track of this, or treat things like VecGetArray VecRestoreArray where you have to always call in pairs */ PetscErrorCode VecCUDACopyFromGPUSome(Vec v, PetscCUDAIndices ci) { const PetscScalar *varray, *gpuPtr; PetscErrorCode ierr; cudaError_t err; PetscScalar *cpuPtr; Vec_Seq *s; VecScatterCUDAIndices_PtoP ptop_scatter = (VecScatterCUDAIndices_PtoP)ci->scatter; PetscFunctionBegin; PetscCheckTypeNames(v,VECSEQCUDA,VECMPICUDA); ierr = VecCUDAAllocateCheckHost(v);CHKERRQ(ierr); if (v->valid_GPU_array == PETSC_OFFLOAD_GPU) { ierr = PetscLogEventBegin(VEC_CUDACopyFromGPUSome,v,0,0,0);CHKERRQ(ierr); varray=((Vec_CUDA*)v->spptr)->GPUarray; s = (Vec_Seq*)v->data; gpuPtr = varray + ptop_scatter->sendLowestIndex; cpuPtr = s->array + ptop_scatter->sendLowestIndex; /* Note : this code copies the smallest contiguous chunk of data containing ALL of the indices */ err = cudaMemcpy(cpuPtr,gpuPtr,ptop_scatter->ns*sizeof(PetscScalar),cudaMemcpyDeviceToHost);CHKERRCUDA(err); ierr = VecCUDARestoreArrayRead(v,&varray);CHKERRQ(ierr); ierr = PetscLogEventEnd(VEC_CUDACopyFromGPUSome,v,0,0,0);CHKERRQ(ierr); } PetscFunctionReturn(0); } /*MC VECSEQCUDA - VECSEQCUDA = "seqcuda" - The basic sequential vector, modified to use CUDA Options Database Keys: . -vec_type seqcuda - sets the vector type to VECSEQCUDA during a call to VecSetFromOptions() Level: beginner .seealso: VecCreate(), VecSetType(), VecSetFromOptions(), VecCreateSeqWithArray(), VECMPI, VecType, VecCreateMPI(), VecCreateSeq() M*/ PetscErrorCode VecAYPX_SeqCUDA(Vec yin,PetscScalar alpha,Vec xin) { const PetscScalar *xarray; PetscScalar *yarray; PetscErrorCode ierr; PetscBLASInt one=1,bn; PetscScalar sone=1.0; cublasHandle_t cublasv2handle; cublasStatus_t cberr; cudaError_t err; PetscFunctionBegin; ierr = PetscCUBLASGetHandle(&cublasv2handle);CHKERRQ(ierr); ierr = PetscBLASIntCast(yin->map->n,&bn);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayReadWrite(yin,&yarray);CHKERRQ(ierr); if (alpha == (PetscScalar)0.0) { err = cudaMemcpy(yarray,xarray,bn*sizeof(PetscScalar),cudaMemcpyDeviceToDevice);CHKERRCUDA(err); } else if (alpha == (PetscScalar)1.0) { cberr = cublasXaxpy(cublasv2handle,bn,&alpha,xarray,one,yarray,one);CHKERRCUBLAS(cberr); ierr = PetscLogFlops(2.0*yin->map->n);CHKERRQ(ierr); } else { cberr = cublasXscal(cublasv2handle,bn,&alpha,yarray,one);CHKERRCUBLAS(cberr); cberr = cublasXaxpy(cublasv2handle,bn,&sone,xarray,one,yarray,one);CHKERRCUBLAS(cberr); ierr = PetscLogFlops(2.0*yin->map->n);CHKERRQ(ierr); } ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayReadWrite(yin,&yarray);CHKERRQ(ierr); PetscFunctionReturn(0); } PetscErrorCode VecAXPY_SeqCUDA(Vec yin,PetscScalar alpha,Vec xin) { const PetscScalar *xarray; PetscScalar *yarray; PetscErrorCode ierr; PetscBLASInt one=1,bn; cublasHandle_t cublasv2handle; cublasStatus_t cberr; PetscFunctionBegin; ierr = PetscCUBLASGetHandle(&cublasv2handle);CHKERRQ(ierr); if (alpha != (PetscScalar)0.0) { ierr = PetscBLASIntCast(yin->map->n,&bn);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayReadWrite(yin,&yarray);CHKERRQ(ierr); cberr = cublasXaxpy(cublasv2handle,bn,&alpha,xarray,one,yarray,one);CHKERRCUBLAS(cberr); ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayReadWrite(yin,&yarray);CHKERRQ(ierr); ierr = PetscLogFlops(2.0*yin->map->n);CHKERRQ(ierr); } PetscFunctionReturn(0); } PetscErrorCode VecPointwiseDivide_SeqCUDA(Vec win, Vec xin, Vec yin) { PetscInt n = xin->map->n; const PetscScalar *xarray=NULL,*yarray=NULL; PetscScalar *warray=NULL; thrust::device_ptr<const PetscScalar> xptr,yptr; thrust::device_ptr<PetscScalar> wptr; PetscErrorCode ierr; PetscFunctionBegin; ierr = VecCUDAGetArrayWrite(win,&warray);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin,&yarray);CHKERRQ(ierr); try { wptr = thrust::device_pointer_cast(warray); xptr = thrust::device_pointer_cast(xarray); yptr = thrust::device_pointer_cast(yarray); thrust::transform(xptr,xptr+n,yptr,wptr,thrust::divides<PetscScalar>()); ierr = WaitForGPU();CHKERRCUDA(ierr); } catch (char *ex) { SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Thrust error: %s", ex); } ierr = PetscLogFlops(n);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin,&yarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayWrite(win,&warray);CHKERRQ(ierr); PetscFunctionReturn(0); } PetscErrorCode VecWAXPY_SeqCUDA(Vec win,PetscScalar alpha,Vec xin, Vec yin) { const PetscScalar *xarray=NULL,*yarray=NULL; PetscScalar *warray=NULL; PetscErrorCode ierr; PetscBLASInt one=1,bn; cublasHandle_t cublasv2handle; cublasStatus_t cberr; cudaError_t err; PetscFunctionBegin; ierr = PetscCUBLASGetHandle(&cublasv2handle);CHKERRQ(ierr); ierr = PetscBLASIntCast(win->map->n,&bn);CHKERRQ(ierr); if (alpha == (PetscScalar)0.0) { ierr = VecCopy_SeqCUDA(yin,win);CHKERRQ(ierr); } else { ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin,&yarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayWrite(win,&warray);CHKERRQ(ierr); err = cudaMemcpy(warray,yarray,win->map->n*sizeof(PetscScalar),cudaMemcpyDeviceToDevice);CHKERRCUDA(err); cberr = cublasXaxpy(cublasv2handle,bn,&alpha,xarray,one,warray,one);CHKERRCUBLAS(cberr); ierr = PetscLogFlops(2*win->map->n);CHKERRQ(ierr); ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin,&yarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayWrite(win,&warray);CHKERRQ(ierr); } PetscFunctionReturn(0); } PetscErrorCode VecMAXPY_SeqCUDA(Vec xin, PetscInt nv,const PetscScalar *alpha,Vec *y) { PetscErrorCode ierr; PetscInt n = xin->map->n,j,j_rem; PetscScalar alpha0,alpha1,alpha2,alpha3; PetscFunctionBegin; ierr = PetscLogFlops(nv*2.0*n);CHKERRQ(ierr); switch (j_rem=nv&0x3) { case 3: alpha0 = alpha[0]; alpha1 = alpha[1]; alpha2 = alpha[2]; alpha += 3; ierr = VecAXPY_SeqCUDA(xin,alpha0,y[0]);CHKERRQ(ierr); ierr = VecAXPY_SeqCUDA(xin,alpha1,y[1]);CHKERRQ(ierr); ierr = VecAXPY_SeqCUDA(xin,alpha2,y[2]);CHKERRQ(ierr); y += 3; break; case 2: alpha0 = alpha[0]; alpha1 = alpha[1]; alpha +=2; ierr = VecAXPY_SeqCUDA(xin,alpha0,y[0]);CHKERRQ(ierr); ierr = VecAXPY_SeqCUDA(xin,alpha1,y[1]);CHKERRQ(ierr); y +=2; break; case 1: alpha0 = *alpha++; ierr = VecAXPY_SeqCUDA(xin,alpha0,y[0]);CHKERRQ(ierr); y +=1; break; } for (j=j_rem; j<nv; j+=4) { alpha0 = alpha[0]; alpha1 = alpha[1]; alpha2 = alpha[2]; alpha3 = alpha[3]; alpha += 4; ierr = VecAXPY_SeqCUDA(xin,alpha0,y[0]);CHKERRQ(ierr); ierr = VecAXPY_SeqCUDA(xin,alpha1,y[1]);CHKERRQ(ierr); ierr = VecAXPY_SeqCUDA(xin,alpha2,y[2]);CHKERRQ(ierr); ierr = VecAXPY_SeqCUDA(xin,alpha3,y[3]);CHKERRQ(ierr); y += 4; } ierr = WaitForGPU();CHKERRCUDA(ierr); PetscFunctionReturn(0); } PetscErrorCode VecDot_SeqCUDA(Vec xin,Vec yin,PetscScalar *z) { const PetscScalar *xarray,*yarray; PetscErrorCode ierr; PetscBLASInt one=1,bn; cublasHandle_t cublasv2handle; cublasStatus_t cberr; PetscFunctionBegin; ierr = PetscCUBLASGetHandle(&cublasv2handle);CHKERRQ(ierr); ierr = PetscBLASIntCast(yin->map->n,&bn);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin,&yarray);CHKERRQ(ierr); /* arguments y, x are reversed because BLAS complex conjugates the first argument, PETSc the second */ cberr = cublasXdot(cublasv2handle,bn,yarray,one,xarray,one,z);CHKERRCUBLAS(cberr); ierr = WaitForGPU();CHKERRCUDA(ierr); if (xin->map->n >0) { ierr = PetscLogFlops(2.0*xin->map->n-1);CHKERRQ(ierr); } ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin,&yarray);CHKERRQ(ierr); PetscFunctionReturn(0); } // // CUDA kernels for MDot to follow // // set work group size to be a power of 2 (128 is usually a good compromise between portability and speed) #define MDOT_WORKGROUP_SIZE 128 #define MDOT_WORKGROUP_NUM 128 #if !defined(PETSC_USE_COMPLEX) // M = 2: __global__ void VecMDot_SeqCUDA_kernel2(const PetscScalar *x,const PetscScalar *y0,const PetscScalar *y1, PetscInt size, PetscScalar *group_results) { __shared__ PetscScalar tmp_buffer[2*MDOT_WORKGROUP_SIZE]; PetscInt entries_per_group = (size - 1) / gridDim.x + 1; entries_per_group = (entries_per_group == 0) ? 1 : entries_per_group; // for very small vectors, a group should still do some work PetscInt vec_start_index = blockIdx.x * entries_per_group; PetscInt vec_stop_index = PetscMin((blockIdx.x + 1) * entries_per_group, size); // don't go beyond vec size PetscScalar entry_x = 0; PetscScalar group_sum0 = 0; PetscScalar group_sum1 = 0; for (PetscInt i = vec_start_index + threadIdx.x; i < vec_stop_index; i += blockDim.x) { entry_x = x[i]; // load only once from global memory! group_sum0 += entry_x * y0[i]; group_sum1 += entry_x * y1[i]; } tmp_buffer[threadIdx.x] = group_sum0; tmp_buffer[threadIdx.x + MDOT_WORKGROUP_SIZE] = group_sum1; // parallel reduction for (PetscInt stride = blockDim.x/2; stride > 0; stride /= 2) { __syncthreads(); if (threadIdx.x < stride) { tmp_buffer[threadIdx.x ] += tmp_buffer[threadIdx.x+stride ]; tmp_buffer[threadIdx.x + MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + MDOT_WORKGROUP_SIZE]; } } // write result of group to group_results if (threadIdx.x == 0) { group_results[blockIdx.x] = tmp_buffer[0]; group_results[blockIdx.x + gridDim.x] = tmp_buffer[MDOT_WORKGROUP_SIZE]; } } // M = 3: __global__ void VecMDot_SeqCUDA_kernel3(const PetscScalar *x,const PetscScalar *y0,const PetscScalar *y1,const PetscScalar *y2, PetscInt size, PetscScalar *group_results) { __shared__ PetscScalar tmp_buffer[3*MDOT_WORKGROUP_SIZE]; PetscInt entries_per_group = (size - 1) / gridDim.x + 1; entries_per_group = (entries_per_group == 0) ? 1 : entries_per_group; // for very small vectors, a group should still do some work PetscInt vec_start_index = blockIdx.x * entries_per_group; PetscInt vec_stop_index = PetscMin((blockIdx.x + 1) * entries_per_group, size); // don't go beyond vec size PetscScalar entry_x = 0; PetscScalar group_sum0 = 0; PetscScalar group_sum1 = 0; PetscScalar group_sum2 = 0; for (PetscInt i = vec_start_index + threadIdx.x; i < vec_stop_index; i += blockDim.x) { entry_x = x[i]; // load only once from global memory! group_sum0 += entry_x * y0[i]; group_sum1 += entry_x * y1[i]; group_sum2 += entry_x * y2[i]; } tmp_buffer[threadIdx.x] = group_sum0; tmp_buffer[threadIdx.x + MDOT_WORKGROUP_SIZE] = group_sum1; tmp_buffer[threadIdx.x + 2 * MDOT_WORKGROUP_SIZE] = group_sum2; // parallel reduction for (PetscInt stride = blockDim.x/2; stride > 0; stride /= 2) { __syncthreads(); if (threadIdx.x < stride) { tmp_buffer[threadIdx.x ] += tmp_buffer[threadIdx.x+stride ]; tmp_buffer[threadIdx.x + MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + MDOT_WORKGROUP_SIZE]; tmp_buffer[threadIdx.x + 2 * MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + 2 * MDOT_WORKGROUP_SIZE]; } } // write result of group to group_results if (threadIdx.x == 0) { group_results[blockIdx.x ] = tmp_buffer[0]; group_results[blockIdx.x + gridDim.x] = tmp_buffer[ MDOT_WORKGROUP_SIZE]; group_results[blockIdx.x + 2 * gridDim.x] = tmp_buffer[2 * MDOT_WORKGROUP_SIZE]; } } // M = 4: __global__ void VecMDot_SeqCUDA_kernel4(const PetscScalar *x,const PetscScalar *y0,const PetscScalar *y1,const PetscScalar *y2,const PetscScalar *y3, PetscInt size, PetscScalar *group_results) { __shared__ PetscScalar tmp_buffer[4*MDOT_WORKGROUP_SIZE]; PetscInt entries_per_group = (size - 1) / gridDim.x + 1; entries_per_group = (entries_per_group == 0) ? 1 : entries_per_group; // for very small vectors, a group should still do some work PetscInt vec_start_index = blockIdx.x * entries_per_group; PetscInt vec_stop_index = PetscMin((blockIdx.x + 1) * entries_per_group, size); // don't go beyond vec size PetscScalar entry_x = 0; PetscScalar group_sum0 = 0; PetscScalar group_sum1 = 0; PetscScalar group_sum2 = 0; PetscScalar group_sum3 = 0; for (PetscInt i = vec_start_index + threadIdx.x; i < vec_stop_index; i += blockDim.x) { entry_x = x[i]; // load only once from global memory! group_sum0 += entry_x * y0[i]; group_sum1 += entry_x * y1[i]; group_sum2 += entry_x * y2[i]; group_sum3 += entry_x * y3[i]; } tmp_buffer[threadIdx.x] = group_sum0; tmp_buffer[threadIdx.x + MDOT_WORKGROUP_SIZE] = group_sum1; tmp_buffer[threadIdx.x + 2 * MDOT_WORKGROUP_SIZE] = group_sum2; tmp_buffer[threadIdx.x + 3 * MDOT_WORKGROUP_SIZE] = group_sum3; // parallel reduction for (PetscInt stride = blockDim.x/2; stride > 0; stride /= 2) { __syncthreads(); if (threadIdx.x < stride) { tmp_buffer[threadIdx.x ] += tmp_buffer[threadIdx.x+stride ]; tmp_buffer[threadIdx.x + MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + MDOT_WORKGROUP_SIZE]; tmp_buffer[threadIdx.x + 2 * MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + 2 * MDOT_WORKGROUP_SIZE]; tmp_buffer[threadIdx.x + 3 * MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + 3 * MDOT_WORKGROUP_SIZE]; } } // write result of group to group_results if (threadIdx.x == 0) { group_results[blockIdx.x ] = tmp_buffer[0]; group_results[blockIdx.x + gridDim.x] = tmp_buffer[ MDOT_WORKGROUP_SIZE]; group_results[blockIdx.x + 2 * gridDim.x] = tmp_buffer[2 * MDOT_WORKGROUP_SIZE]; group_results[blockIdx.x + 3 * gridDim.x] = tmp_buffer[3 * MDOT_WORKGROUP_SIZE]; } } // M = 8: __global__ void VecMDot_SeqCUDA_kernel8(const PetscScalar *x,const PetscScalar *y0,const PetscScalar *y1,const PetscScalar *y2,const PetscScalar *y3, const PetscScalar *y4,const PetscScalar *y5,const PetscScalar *y6,const PetscScalar *y7, PetscInt size, PetscScalar *group_results) { __shared__ PetscScalar tmp_buffer[8*MDOT_WORKGROUP_SIZE]; PetscInt entries_per_group = (size - 1) / gridDim.x + 1; entries_per_group = (entries_per_group == 0) ? 1 : entries_per_group; // for very small vectors, a group should still do some work PetscInt vec_start_index = blockIdx.x * entries_per_group; PetscInt vec_stop_index = PetscMin((blockIdx.x + 1) * entries_per_group, size); // don't go beyond vec size PetscScalar entry_x = 0; PetscScalar group_sum0 = 0; PetscScalar group_sum1 = 0; PetscScalar group_sum2 = 0; PetscScalar group_sum3 = 0; PetscScalar group_sum4 = 0; PetscScalar group_sum5 = 0; PetscScalar group_sum6 = 0; PetscScalar group_sum7 = 0; for (PetscInt i = vec_start_index + threadIdx.x; i < vec_stop_index; i += blockDim.x) { entry_x = x[i]; // load only once from global memory! group_sum0 += entry_x * y0[i]; group_sum1 += entry_x * y1[i]; group_sum2 += entry_x * y2[i]; group_sum3 += entry_x * y3[i]; group_sum4 += entry_x * y4[i]; group_sum5 += entry_x * y5[i]; group_sum6 += entry_x * y6[i]; group_sum7 += entry_x * y7[i]; } tmp_buffer[threadIdx.x] = group_sum0; tmp_buffer[threadIdx.x + MDOT_WORKGROUP_SIZE] = group_sum1; tmp_buffer[threadIdx.x + 2 * MDOT_WORKGROUP_SIZE] = group_sum2; tmp_buffer[threadIdx.x + 3 * MDOT_WORKGROUP_SIZE] = group_sum3; tmp_buffer[threadIdx.x + 4 * MDOT_WORKGROUP_SIZE] = group_sum4; tmp_buffer[threadIdx.x + 5 * MDOT_WORKGROUP_SIZE] = group_sum5; tmp_buffer[threadIdx.x + 6 * MDOT_WORKGROUP_SIZE] = group_sum6; tmp_buffer[threadIdx.x + 7 * MDOT_WORKGROUP_SIZE] = group_sum7; // parallel reduction for (PetscInt stride = blockDim.x/2; stride > 0; stride /= 2) { __syncthreads(); if (threadIdx.x < stride) { tmp_buffer[threadIdx.x ] += tmp_buffer[threadIdx.x+stride ]; tmp_buffer[threadIdx.x + MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + MDOT_WORKGROUP_SIZE]; tmp_buffer[threadIdx.x + 2 * MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + 2 * MDOT_WORKGROUP_SIZE]; tmp_buffer[threadIdx.x + 3 * MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + 3 * MDOT_WORKGROUP_SIZE]; tmp_buffer[threadIdx.x + 4 * MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + 4 * MDOT_WORKGROUP_SIZE]; tmp_buffer[threadIdx.x + 5 * MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + 5 * MDOT_WORKGROUP_SIZE]; tmp_buffer[threadIdx.x + 6 * MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + 6 * MDOT_WORKGROUP_SIZE]; tmp_buffer[threadIdx.x + 7 * MDOT_WORKGROUP_SIZE] += tmp_buffer[threadIdx.x+stride + 7 * MDOT_WORKGROUP_SIZE]; } } // write result of group to group_results if (threadIdx.x == 0) { group_results[blockIdx.x ] = tmp_buffer[0]; group_results[blockIdx.x + gridDim.x] = tmp_buffer[ MDOT_WORKGROUP_SIZE]; group_results[blockIdx.x + 2 * gridDim.x] = tmp_buffer[2 * MDOT_WORKGROUP_SIZE]; group_results[blockIdx.x + 3 * gridDim.x] = tmp_buffer[3 * MDOT_WORKGROUP_SIZE]; group_results[blockIdx.x + 4 * gridDim.x] = tmp_buffer[4 * MDOT_WORKGROUP_SIZE]; group_results[blockIdx.x + 5 * gridDim.x] = tmp_buffer[5 * MDOT_WORKGROUP_SIZE]; group_results[blockIdx.x + 6 * gridDim.x] = tmp_buffer[6 * MDOT_WORKGROUP_SIZE]; group_results[blockIdx.x + 7 * gridDim.x] = tmp_buffer[7 * MDOT_WORKGROUP_SIZE]; } } #endif /* !defined(PETSC_USE_COMPLEX) */ PetscErrorCode VecMDot_SeqCUDA(Vec xin,PetscInt nv,const Vec yin[],PetscScalar *z) { PetscErrorCode ierr; PetscInt i,n = xin->map->n,current_y_index = 0; const PetscScalar *xptr,*y0ptr,*y1ptr,*y2ptr,*y3ptr,*y4ptr,*y5ptr,*y6ptr,*y7ptr; PetscScalar *group_results_gpu; #if !defined(PETSC_USE_COMPLEX) PetscInt j; PetscScalar group_results_cpu[MDOT_WORKGROUP_NUM * 8]; // we process at most eight vectors in one kernel #endif cudaError_t cuda_ierr; PetscBLASInt one=1,bn; cublasHandle_t cublasv2handle; cublasStatus_t cberr; PetscFunctionBegin; ierr = PetscCUBLASGetHandle(&cublasv2handle);CHKERRQ(ierr); ierr = PetscBLASIntCast(xin->map->n,&bn);CHKERRQ(ierr); if (nv <= 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"Number of vectors provided to VecMDot_SeqCUDA not positive."); /* Handle the case of local size zero first */ if (!xin->map->n) { for (i=0; i<nv; ++i) z[i] = 0; PetscFunctionReturn(0); } // allocate scratchpad memory for the results of individual work groups: cuda_ierr = cudaMalloc((void**)&group_results_gpu, sizeof(PetscScalar) * MDOT_WORKGROUP_NUM * 8);CHKERRCUDA(cuda_ierr); ierr = VecCUDAGetArrayRead(xin,&xptr);CHKERRQ(ierr); while (current_y_index < nv) { switch (nv - current_y_index) { case 7: case 6: case 5: case 4: ierr = VecCUDAGetArrayRead(yin[current_y_index ],&y0ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+1],&y1ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+2],&y2ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+3],&y3ptr);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) cberr = cublasXdot(cublasv2handle,bn,y0ptr,one,xptr,one,&z[current_y_index]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y1ptr,one,xptr,one,&z[current_y_index+1]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y2ptr,one,xptr,one,&z[current_y_index+2]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y3ptr,one,xptr,one,&z[current_y_index+3]);CHKERRCUBLAS(cberr); #else // run kernel: VecMDot_SeqCUDA_kernel4<<<MDOT_WORKGROUP_NUM,MDOT_WORKGROUP_SIZE>>>(xptr,y0ptr,y1ptr,y2ptr,y3ptr,n,group_results_gpu); // copy results back to cuda_ierr = cudaMemcpy(group_results_cpu,group_results_gpu,sizeof(PetscScalar) * MDOT_WORKGROUP_NUM * 4,cudaMemcpyDeviceToHost);CHKERRCUDA(cuda_ierr); // sum group results into z: for (j=0; j<4; ++j) { z[current_y_index + j] = 0; for (i=j*MDOT_WORKGROUP_NUM; i<(j+1)*MDOT_WORKGROUP_NUM; ++i) z[current_y_index + j] += group_results_cpu[i]; } #endif ierr = VecCUDARestoreArrayRead(yin[current_y_index ],&y0ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+1],&y1ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+2],&y2ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+3],&y3ptr);CHKERRQ(ierr); current_y_index += 4; break; case 3: ierr = VecCUDAGetArrayRead(yin[current_y_index ],&y0ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+1],&y1ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+2],&y2ptr);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) cberr = cublasXdot(cublasv2handle,bn,y0ptr,one,xptr,one,&z[current_y_index]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y1ptr,one,xptr,one,&z[current_y_index+1]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y2ptr,one,xptr,one,&z[current_y_index+2]);CHKERRCUBLAS(cberr); #else // run kernel: VecMDot_SeqCUDA_kernel3<<<MDOT_WORKGROUP_NUM,MDOT_WORKGROUP_SIZE>>>(xptr,y0ptr,y1ptr,y2ptr,n,group_results_gpu); // copy results back to cuda_ierr = cudaMemcpy(group_results_cpu,group_results_gpu,sizeof(PetscScalar) * MDOT_WORKGROUP_NUM * 3,cudaMemcpyDeviceToHost);CHKERRCUDA(cuda_ierr); // sum group results into z: for (j=0; j<3; ++j) { z[current_y_index + j] = 0; for (i=j*MDOT_WORKGROUP_NUM; i<(j+1)*MDOT_WORKGROUP_NUM; ++i) z[current_y_index + j] += group_results_cpu[i]; } #endif ierr = VecCUDARestoreArrayRead(yin[current_y_index ],&y0ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+1],&y1ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+2],&y2ptr);CHKERRQ(ierr); current_y_index += 3; break; case 2: ierr = VecCUDAGetArrayRead(yin[current_y_index],&y0ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+1],&y1ptr);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) cberr = cublasXdot(cublasv2handle,bn,y0ptr,one,xptr,one,&z[current_y_index]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y1ptr,one,xptr,one,&z[current_y_index+1]);CHKERRCUBLAS(cberr); #else // run kernel: VecMDot_SeqCUDA_kernel2<<<MDOT_WORKGROUP_NUM,MDOT_WORKGROUP_SIZE>>>(xptr,y0ptr,y1ptr,n,group_results_gpu); // copy results back to cuda_ierr = cudaMemcpy(group_results_cpu,group_results_gpu,sizeof(PetscScalar) * MDOT_WORKGROUP_NUM * 2,cudaMemcpyDeviceToHost);CHKERRCUDA(cuda_ierr); // sum group results into z: for (j=0; j<2; ++j) { z[current_y_index + j] = 0; for (i=j*MDOT_WORKGROUP_NUM; i<(j+1)*MDOT_WORKGROUP_NUM; ++i) z[current_y_index + j] += group_results_cpu[i]; } #endif ierr = VecCUDARestoreArrayRead(yin[current_y_index],&y0ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+1],&y1ptr);CHKERRQ(ierr); current_y_index += 2; break; case 1: ierr = VecCUDAGetArrayRead(yin[current_y_index],&y0ptr);CHKERRQ(ierr); cberr = cublasXdot(cublasv2handle,bn,y0ptr,one,xptr,one,&z[current_y_index]);CHKERRCUBLAS(cberr); ierr = VecCUDARestoreArrayRead(yin[current_y_index],&y0ptr);CHKERRQ(ierr); current_y_index += 1; break; default: // 8 or more vectors left ierr = VecCUDAGetArrayRead(yin[current_y_index ],&y0ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+1],&y1ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+2],&y2ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+3],&y3ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+4],&y4ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+5],&y5ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+6],&y6ptr);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin[current_y_index+7],&y7ptr);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) cberr = cublasXdot(cublasv2handle,bn,y0ptr,one,xptr,one,&z[current_y_index]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y1ptr,one,xptr,one,&z[current_y_index+1]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y2ptr,one,xptr,one,&z[current_y_index+2]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y3ptr,one,xptr,one,&z[current_y_index+3]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y4ptr,one,xptr,one,&z[current_y_index+4]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y5ptr,one,xptr,one,&z[current_y_index+5]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y6ptr,one,xptr,one,&z[current_y_index+6]);CHKERRCUBLAS(cberr); cberr = cublasXdot(cublasv2handle,bn,y7ptr,one,xptr,one,&z[current_y_index+7]);CHKERRCUBLAS(cberr); #else // run kernel: VecMDot_SeqCUDA_kernel8<<<MDOT_WORKGROUP_NUM,MDOT_WORKGROUP_SIZE>>>(xptr,y0ptr,y1ptr,y2ptr,y3ptr,y4ptr,y5ptr,y6ptr,y7ptr,n,group_results_gpu); // copy results back to cuda_ierr = cudaMemcpy(group_results_cpu,group_results_gpu,sizeof(PetscScalar) * MDOT_WORKGROUP_NUM * 8,cudaMemcpyDeviceToHost);CHKERRCUDA(cuda_ierr); // sum group results into z: for (j=0; j<8; ++j) { z[current_y_index + j] = 0; for (i=j*MDOT_WORKGROUP_NUM; i<(j+1)*MDOT_WORKGROUP_NUM; ++i) z[current_y_index + j] += group_results_cpu[i]; } #endif ierr = VecCUDARestoreArrayRead(yin[current_y_index ],&y0ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+1],&y1ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+2],&y2ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+3],&y3ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+4],&y4ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+5],&y5ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+6],&y6ptr);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin[current_y_index+7],&y7ptr);CHKERRQ(ierr); current_y_index += 8; break; } } ierr = VecCUDARestoreArrayRead(xin,&xptr);CHKERRQ(ierr); cuda_ierr = cudaFree(group_results_gpu);CHKERRCUDA(cuda_ierr); ierr = PetscLogFlops(PetscMax(nv*(2.0*n-1),0.0));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef MDOT_WORKGROUP_SIZE #undef MDOT_WORKGROUP_NUM PetscErrorCode VecSet_SeqCUDA(Vec xin,PetscScalar alpha) { PetscInt n = xin->map->n; PetscScalar *xarray=NULL; thrust::device_ptr<PetscScalar> xptr; PetscErrorCode ierr; cudaError_t err; PetscFunctionBegin; ierr = VecCUDAGetArrayWrite(xin,&xarray);CHKERRQ(ierr); if (alpha == (PetscScalar)0.0) { err = cudaMemset(xarray,0,n*sizeof(PetscScalar));CHKERRCUDA(err); } else { try { xptr = thrust::device_pointer_cast(xarray); thrust::fill(xptr,xptr+n,alpha); } catch (char *ex) { SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Thrust error: %s", ex); } } ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = VecCUDARestoreArrayWrite(xin,&xarray); PetscFunctionReturn(0); } PetscErrorCode VecScale_SeqCUDA(Vec xin,PetscScalar alpha) { PetscScalar *xarray; PetscErrorCode ierr; PetscBLASInt one=1,bn; cublasHandle_t cublasv2handle; cublasStatus_t cberr; PetscFunctionBegin; if (alpha == (PetscScalar)0.0) { ierr = VecSet_SeqCUDA(xin,alpha);CHKERRQ(ierr); } else if (alpha != (PetscScalar)1.0) { ierr = PetscCUBLASGetHandle(&cublasv2handle);CHKERRQ(ierr); ierr = PetscBLASIntCast(xin->map->n,&bn);CHKERRQ(ierr); ierr = VecCUDAGetArrayReadWrite(xin,&xarray);CHKERRQ(ierr); cberr = cublasXscal(cublasv2handle,bn,&alpha,xarray,one);CHKERRCUBLAS(cberr); ierr = VecCUDARestoreArrayReadWrite(xin,&xarray);CHKERRQ(ierr); } ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = PetscLogFlops(xin->map->n);CHKERRQ(ierr); PetscFunctionReturn(0); } PetscErrorCode VecTDot_SeqCUDA(Vec xin,Vec yin,PetscScalar *z) { const PetscScalar *xarray,*yarray; PetscErrorCode ierr; PetscBLASInt one=1,bn; cublasHandle_t cublasv2handle; cublasStatus_t cberr; PetscFunctionBegin; ierr = PetscCUBLASGetHandle(&cublasv2handle);CHKERRQ(ierr); ierr = PetscBLASIntCast(xin->map->n,&bn);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin,&yarray);CHKERRQ(ierr); cberr = cublasXdotu(cublasv2handle,bn,xarray,one,yarray,one,z);CHKERRCUBLAS(cberr); ierr = WaitForGPU();CHKERRCUDA(ierr); if (xin->map->n > 0) { ierr = PetscLogFlops(2.0*xin->map->n-1);CHKERRQ(ierr); } ierr = VecCUDARestoreArrayRead(yin,&yarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); PetscFunctionReturn(0); } PetscErrorCode VecCopy_SeqCUDA(Vec xin,Vec yin) { const PetscScalar *xarray; PetscScalar *yarray; PetscErrorCode ierr; cudaError_t err; PetscFunctionBegin; if (xin != yin) { if (xin->valid_GPU_array == PETSC_OFFLOAD_GPU) { ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayWrite(yin,&yarray);CHKERRQ(ierr); err = cudaMemcpy(yarray,xarray,yin->map->n*sizeof(PetscScalar),cudaMemcpyDeviceToDevice);CHKERRCUDA(err); ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayWrite(yin,&yarray);CHKERRQ(ierr); } else if (xin->valid_GPU_array == PETSC_OFFLOAD_CPU) { /* copy in CPU if we are on the CPU*/ ierr = VecCopy_SeqCUDA_Private(xin,yin);CHKERRQ(ierr); } else if (xin->valid_GPU_array == PETSC_OFFLOAD_BOTH) { /* if xin is valid in both places, see where yin is and copy there (because it's probably where we'll want to next use it) */ if (yin->valid_GPU_array == PETSC_OFFLOAD_CPU) { /* copy in CPU */ ierr = VecCopy_SeqCUDA_Private(xin,yin);CHKERRQ(ierr); } else if (yin->valid_GPU_array == PETSC_OFFLOAD_GPU) { /* copy in GPU */ ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayWrite(yin,&yarray);CHKERRQ(ierr); err = cudaMemcpy(yarray,xarray,yin->map->n*sizeof(PetscScalar),cudaMemcpyDeviceToDevice);CHKERRCUDA(err); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayWrite(yin,&yarray);CHKERRQ(ierr); } else if (yin->valid_GPU_array == PETSC_OFFLOAD_BOTH) { /* xin and yin are both valid in both places (or yin was unallocated before the earlier call to allocatecheck default to copy in GPU (this is an arbitrary choice) */ ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayWrite(yin,&yarray);CHKERRQ(ierr); err = cudaMemcpy(yarray,xarray,yin->map->n*sizeof(PetscScalar),cudaMemcpyDeviceToDevice);CHKERRCUDA(err); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayWrite(yin,&yarray);CHKERRQ(ierr); } else { ierr = VecCopy_SeqCUDA_Private(xin,yin);CHKERRQ(ierr); } } } PetscFunctionReturn(0); } PetscErrorCode VecSwap_SeqCUDA(Vec xin,Vec yin) { PetscErrorCode ierr; PetscBLASInt one = 1,bn; PetscScalar *xarray,*yarray; cublasHandle_t cublasv2handle; cublasStatus_t cberr; PetscFunctionBegin; ierr = PetscCUBLASGetHandle(&cublasv2handle);CHKERRQ(ierr); ierr = PetscBLASIntCast(xin->map->n,&bn);CHKERRQ(ierr); if (xin != yin) { ierr = VecCUDAGetArrayReadWrite(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayReadWrite(yin,&yarray);CHKERRQ(ierr); cberr = cublasXswap(cublasv2handle,bn,xarray,one,yarray,one);CHKERRCUBLAS(cberr); ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = VecCUDARestoreArrayReadWrite(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayReadWrite(yin,&yarray);CHKERRQ(ierr); } PetscFunctionReturn(0); } PetscErrorCode VecAXPBY_SeqCUDA(Vec yin,PetscScalar alpha,PetscScalar beta,Vec xin) { PetscErrorCode ierr; PetscScalar a = alpha,b = beta; const PetscScalar *xarray; PetscScalar *yarray; PetscBLASInt one = 1, bn; cublasHandle_t cublasv2handle; cublasStatus_t cberr; cudaError_t err; PetscFunctionBegin; ierr = PetscCUBLASGetHandle(&cublasv2handle);CHKERRQ(ierr); ierr = PetscBLASIntCast(yin->map->n,&bn);CHKERRQ(ierr); if (a == (PetscScalar)0.0) { ierr = VecScale_SeqCUDA(yin,beta);CHKERRQ(ierr); } else if (b == (PetscScalar)1.0) { ierr = VecAXPY_SeqCUDA(yin,alpha,xin);CHKERRQ(ierr); } else if (a == (PetscScalar)1.0) { ierr = VecAYPX_SeqCUDA(yin,beta,xin);CHKERRQ(ierr); } else if (b == (PetscScalar)0.0) { ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayReadWrite(yin,&yarray);CHKERRQ(ierr); err = cudaMemcpy(yarray,xarray,yin->map->n*sizeof(PetscScalar),cudaMemcpyDeviceToDevice);CHKERRCUDA(err); cberr = cublasXscal(cublasv2handle,bn,&alpha,yarray,one);CHKERRCUBLAS(cberr); ierr = PetscLogFlops(xin->map->n);CHKERRQ(ierr); ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayReadWrite(yin,&yarray);CHKERRQ(ierr); } else { ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayReadWrite(yin,&yarray);CHKERRQ(ierr); cberr = cublasXscal(cublasv2handle,bn,&beta,yarray,one);CHKERRCUBLAS(cberr); cberr = cublasXaxpy(cublasv2handle,bn,&alpha,xarray,one,yarray,one);CHKERRCUBLAS(cberr); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayReadWrite(yin,&yarray);CHKERRQ(ierr); ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = PetscLogFlops(3.0*xin->map->n);CHKERRQ(ierr); } PetscFunctionReturn(0); } PetscErrorCode VecAXPBYPCZ_SeqCUDA(Vec zin,PetscScalar alpha,PetscScalar beta,PetscScalar gamma,Vec xin,Vec yin) { PetscErrorCode ierr; PetscInt n = zin->map->n; PetscFunctionBegin; if (gamma == (PetscScalar)1.0) { /* z = ax + b*y + z */ ierr = VecAXPY_SeqCUDA(zin,alpha,xin);CHKERRQ(ierr); ierr = VecAXPY_SeqCUDA(zin,beta,yin);CHKERRQ(ierr); ierr = PetscLogFlops(4.0*n);CHKERRQ(ierr); } else { /* z = a*x + b*y + c*z */ ierr = VecScale_SeqCUDA(zin,gamma);CHKERRQ(ierr); ierr = VecAXPY_SeqCUDA(zin,alpha,xin);CHKERRQ(ierr); ierr = VecAXPY_SeqCUDA(zin,beta,yin);CHKERRQ(ierr); ierr = PetscLogFlops(5.0*n);CHKERRQ(ierr); } ierr = WaitForGPU();CHKERRCUDA(ierr); PetscFunctionReturn(0); } PetscErrorCode VecPointwiseMult_SeqCUDA(Vec win,Vec xin,Vec yin) { PetscInt n = win->map->n; const PetscScalar *xarray,*yarray; PetscScalar *warray; thrust::device_ptr<const PetscScalar> xptr,yptr; thrust::device_ptr<PetscScalar> wptr; PetscErrorCode ierr; PetscFunctionBegin; ierr = VecCUDAGetArrayReadWrite(win,&warray);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(yin,&yarray);CHKERRQ(ierr); try { wptr = thrust::device_pointer_cast(warray); xptr = thrust::device_pointer_cast(xarray); yptr = thrust::device_pointer_cast(yarray); thrust::transform(xptr,xptr+n,yptr,wptr,thrust::multiplies<PetscScalar>()); ierr = WaitForGPU();CHKERRCUDA(ierr); } catch (char *ex) { SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Thrust error: %s", ex); } ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(yin,&yarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayReadWrite(win,&warray);CHKERRQ(ierr); ierr = PetscLogFlops(n);CHKERRQ(ierr); PetscFunctionReturn(0); } /* should do infinity norm in cuda */ PetscErrorCode VecNorm_SeqCUDA(Vec xin,NormType type,PetscReal *z) { PetscErrorCode ierr; PetscInt n = xin->map->n; PetscBLASInt one = 1, bn; const PetscScalar *xarray; cublasHandle_t cublasv2handle; cublasStatus_t cberr; cudaError_t err; PetscFunctionBegin; ierr = PetscCUBLASGetHandle(&cublasv2handle);CHKERRQ(ierr); ierr = PetscBLASIntCast(n,&bn);CHKERRQ(ierr); if (type == NORM_2 || type == NORM_FROBENIUS) { ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); cberr = cublasXnrm2(cublasv2handle,bn,xarray,one,z);CHKERRCUBLAS(cberr); ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = PetscLogFlops(PetscMax(2.0*n-1,0.0));CHKERRQ(ierr); } else if (type == NORM_INFINITY) { int i; ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); cberr = cublasIXamax(cublasv2handle,bn,xarray,one,&i);CHKERRCUBLAS(cberr); err = cudaMemcpy(z,xarray+i,sizeof(PetscScalar),cudaMemcpyDeviceToHost);CHKERRCUDA(err); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); } else if (type == NORM_1) { ierr = VecCUDAGetArrayRead(xin,&xarray);CHKERRQ(ierr); cberr = cublasXasum(cublasv2handle,bn,xarray,one,z);CHKERRCUBLAS(cberr); ierr = VecCUDARestoreArrayRead(xin,&xarray);CHKERRQ(ierr); ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = PetscLogFlops(PetscMax(n-1.0,0.0));CHKERRQ(ierr); } else if (type == NORM_1_AND_2) { ierr = VecNorm_SeqCUDA(xin,NORM_1,z);CHKERRQ(ierr); ierr = VecNorm_SeqCUDA(xin,NORM_2,z+1);CHKERRQ(ierr); } PetscFunctionReturn(0); } PetscErrorCode VecDotNorm2_SeqCUDA(Vec s, Vec t, PetscScalar *dp, PetscScalar *nm) { PetscErrorCode ierr; PetscReal n=s->map->n; const PetscScalar *sarray,*tarray; PetscFunctionBegin; ierr = VecCUDAGetArrayRead(s,&sarray);CHKERRQ(ierr); ierr = VecCUDAGetArrayRead(t,&tarray);CHKERRQ(ierr); ierr = VecDot_SeqCUDA(s,t,dp);CHKERRQ(ierr); ierr = VecDot_SeqCUDA(t,t,nm);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(s,&sarray);CHKERRQ(ierr); ierr = VecCUDARestoreArrayRead(t,&tarray);CHKERRQ(ierr); ierr = WaitForGPU();CHKERRCUDA(ierr); ierr = PetscLogFlops(4.0*n);CHKERRQ(ierr); PetscFunctionReturn(0); } PetscErrorCode VecDestroy_SeqCUDA(Vec v) { PetscErrorCode ierr; cudaError_t err; PetscFunctionBegin; if (v->spptr) { if (((Vec_CUDA*)v->spptr)->GPUarray_allocated) { err = cudaFree(((Vec_CUDA*)v->spptr)->GPUarray_allocated);CHKERRCUDA(err); ((Vec_CUDA*)v->spptr)->GPUarray_allocated = NULL; } if (((Vec_CUDA*)v->spptr)->stream) { err = cudaStreamDestroy(((Vec_CUDA*)v->spptr)->stream);CHKERRCUDA(err); } ierr = PetscFree(v->spptr);CHKERRQ(ierr); } ierr = VecDestroy_SeqCUDA_Private(v);CHKERRQ(ierr); PetscFunctionReturn(0); } #if defined(PETSC_USE_COMPLEX) struct conjugate { __host__ __device__ PetscScalar operator()(PetscScalar x) { return PetscConj(x); } }; #endif PetscErrorCode VecConjugate_SeqCUDA(Vec xin) { PetscScalar *xarray; PetscErrorCode ierr; #if defined(PETSC_USE_COMPLEX) PetscInt n = xin->map->n; thrust::device_ptr<PetscScalar> xptr; #endif PetscFunctionBegin; ierr = VecCUDAGetArrayReadWrite(xin,&xarray);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) try { xptr = thrust::device_pointer_cast(xarray); thrust::transform(xptr,xptr+n,xptr,conjugate()); ierr = WaitForGPU();CHKERRCUDA(ierr); } catch (char *ex) { SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Thrust error: %s", ex); } #endif ierr = VecCUDARestoreArrayReadWrite(xin,&xarray);CHKERRQ(ierr); PetscFunctionReturn(0); } PetscErrorCode VecGetLocalVector_SeqCUDA(Vec v,Vec w) { PetscErrorCode ierr; cudaError_t err; PetscFunctionBegin; PetscValidHeaderSpecific(v,VEC_CLASSID,1); PetscValidHeaderSpecific(w,VEC_CLASSID,2); PetscCheckTypeName(w,VECSEQCUDA); if (w->data) { if (((Vec_Seq*)w->data)->array_allocated) { ierr = PetscFree(((Vec_Seq*)w->data)->array_allocated);CHKERRQ(ierr); } ((Vec_Seq*)w->data)->array = NULL; ((Vec_Seq*)w->data)->unplacedarray = NULL; } if (w->spptr) { if (((Vec_CUDA*)w->spptr)->GPUarray) { err = cudaFree(((Vec_CUDA*)w->spptr)->GPUarray);CHKERRCUDA(err); ((Vec_CUDA*)w->spptr)->GPUarray = NULL; } err = cudaStreamDestroy(((Vec_CUDA*)w->spptr)->stream);CHKERRCUDA(err); ierr = PetscFree(w->spptr);CHKERRQ(ierr); } if (v->petscnative) { ierr = PetscFree(w->data);CHKERRQ(ierr); w->data = v->data; w->valid_GPU_array = v->valid_GPU_array; w->spptr = v->spptr; ierr = PetscObjectStateIncrease((PetscObject)w);CHKERRQ(ierr); } else { ierr = VecGetArray(v,&((Vec_Seq*)w->data)->array);CHKERRQ(ierr); w->valid_GPU_array = PETSC_OFFLOAD_CPU; ierr = VecCUDAAllocateCheck(w);CHKERRQ(ierr); } PetscFunctionReturn(0); } PetscErrorCode VecRestoreLocalVector_SeqCUDA(Vec v,Vec w) { PetscErrorCode ierr; cudaError_t err; PetscFunctionBegin; PetscValidHeaderSpecific(v,VEC_CLASSID,1); PetscValidHeaderSpecific(w,VEC_CLASSID,2); PetscCheckTypeName(w,VECSEQCUDA); if (v->petscnative) { v->data = w->data; v->valid_GPU_array = w->valid_GPU_array; v->spptr = w->spptr; ierr = VecCUDACopyFromGPU(v);CHKERRQ(ierr); ierr = PetscObjectStateIncrease((PetscObject)v);CHKERRQ(ierr); w->data = 0; w->valid_GPU_array = PETSC_OFFLOAD_UNALLOCATED; w->spptr = 0; } else { ierr = VecRestoreArray(v,&((Vec_Seq*)w->data)->array);CHKERRQ(ierr); if ((Vec_CUDA*)w->spptr) { err = cudaFree(((Vec_CUDA*)w->spptr)->GPUarray);CHKERRCUDA(err); ((Vec_CUDA*)w->spptr)->GPUarray = NULL; err = cudaStreamDestroy(((Vec_CUDA*)w->spptr)->stream);CHKERRCUDA(err); ierr = PetscFree(w->spptr);CHKERRQ(ierr); } } PetscFunctionReturn(0); } /*@C VecCUDAGetArrayReadWrite - Provides access to the CUDA buffer inside a vector. This function has semantics similar to VecGetArray(): the pointer returned by this function points to a consistent view of the vector data. This may involve a copy operation of data from the host to the device if the data on the device is out of date. If the device memory hasn't been allocated previously it will be allocated as part of this function call. VecCUDAGetArrayReadWrite() assumes that the user will modify the vector data. This is similar to intent(inout) in fortran. The CUDA device pointer has to be released by calling VecCUDARestoreArrayReadWrite(). Upon restoring the vector data the data on the host will be marked as out of date. A subsequent access of the host data will thus incur a data transfer from the device to the host. Input Parameter: . v - the vector Output Parameter: . a - the CUDA device pointer Fortran note: This function is not currently available from Fortran. Level: intermediate .seealso: VecCUDARestoreArrayReadWrite(), VecCUDAGetArrayRead(), VecCUDAGetArrayWrite(), VecGetArray(), VecGetArrayRead() @*/ PETSC_EXTERN PetscErrorCode VecCUDAGetArrayReadWrite(Vec v, PetscScalar **a) { PetscErrorCode ierr; PetscFunctionBegin; PetscCheckTypeNames(v,VECSEQCUDA,VECMPICUDA); *a = 0; ierr = VecCUDACopyToGPU(v);CHKERRQ(ierr); *a = ((Vec_CUDA*)v->spptr)->GPUarray; PetscFunctionReturn(0); } /*@C VecCUDARestoreArrayReadWrite - Restore a CUDA device pointer previously acquired with VecCUDAGetArrayReadWrite(). This marks the host data as out of date. Subsequent access to the vector data on the host side with for instance VecGetArray() incurs a data transfer. Input Parameter: + v - the vector - a - the CUDA device pointer. This pointer is invalid after VecCUDARestoreArrayReadWrite() returns. Fortran note: This function is not currently available from Fortran. Level: intermediate .seealso: VecCUDAGetArrayReadWrite(), VecCUDAGetArrayRead(), VecCUDAGetArrayWrite(), VecGetArray(), VecRestoreArray(), VecGetArrayRead() @*/ PETSC_EXTERN PetscErrorCode VecCUDARestoreArrayReadWrite(Vec v, PetscScalar **a) { PetscErrorCode ierr; PetscFunctionBegin; PetscCheckTypeNames(v,VECSEQCUDA,VECMPICUDA); v->valid_GPU_array = PETSC_OFFLOAD_GPU; ierr = PetscObjectStateIncrease((PetscObject)v);CHKERRQ(ierr); PetscFunctionReturn(0); } /*@C VecCUDAGetArrayRead - Provides read access to the CUDA buffer inside a vector. This function is analogous to VecGetArrayRead(): The pointer returned by this function points to a consistent view of the vector data. This may involve a copy operation of data from the host to the device if the data on the device is out of date. If the device memory hasn't been allocated previously it will be allocated as part of this function call. VecCUDAGetArrayRead() assumes that the user will not modify the vector data. This is analgogous to intent(in) in Fortran. The CUDA device pointer has to be released by calling VecCUDARestoreArrayRead(). If the data on the host side was previously up to date it will remain so, i.e. data on both the device and the host is up to date. Accessing data on the host side does not incur a device to host data transfer. Input Parameter: . v - the vector Output Parameter: . a - the CUDA pointer. Fortran note: This function is not currently available from Fortran. Level: intermediate .seealso: VecCUDARestoreArrayRead(), VecCUDAGetArrayReadWrite(), VecCUDAGetArrayWrite(), VecGetArray(), VecGetArrayRead() @*/ PETSC_EXTERN PetscErrorCode VecCUDAGetArrayRead(Vec v, const PetscScalar **a) { PetscErrorCode ierr; PetscFunctionBegin; PetscCheckTypeNames(v,VECSEQCUDA,VECMPICUDA); *a = 0; ierr = VecCUDACopyToGPU(v);CHKERRQ(ierr); *a = ((Vec_CUDA*)v->spptr)->GPUarray; PetscFunctionReturn(0); } /*@C VecCUDARestoreArrayRead - Restore a CUDA device pointer previously acquired with VecCUDAGetArrayRead(). If the data on the host side was previously up to date it will remain so, i.e. data on both the device and the host is up to date. Accessing data on the host side e.g. with VecGetArray() does not incur a device to host data transfer. Input Parameter: + v - the vector - a - the CUDA device pointer. This pointer is invalid after VecCUDARestoreArrayRead() returns. Fortran note: This function is not currently available from Fortran. Level: intermediate .seealso: VecCUDAGetArrayRead(), VecCUDAGetArrayWrite(), VecCUDAGetArrayReadWrite(), VecGetArray(), VecRestoreArray(), VecGetArrayRead() @*/ PETSC_EXTERN PetscErrorCode VecCUDARestoreArrayRead(Vec v, const PetscScalar **a) { PetscFunctionBegin; PetscCheckTypeNames(v,VECSEQCUDA,VECMPICUDA); PetscFunctionReturn(0); } /*@C VecCUDAGetArrayWrite - Provides write access to the CUDA buffer inside a vector. The data pointed to by the device pointer is uninitialized. The user may not read from this data. Furthermore, the entire array needs to be filled by the user to obtain well-defined behaviour. The device memory will be allocated by this function if it hasn't been allocated previously. This is analogous to intent(out) in Fortran. The device pointer needs to be released with VecCUDARestoreArrayWrite(). When the pointer is released the host data of the vector is marked as out of data. Subsequent access of the host data with e.g. VecGetArray() incurs a device to host data transfer. Input Parameter: . v - the vector Output Parameter: . a - the CUDA pointer Fortran note: This function is not currently available from Fortran. Level: advanced .seealso: VecCUDARestoreArrayWrite(), VecCUDAGetArrayReadWrite(), VecCUDAGetArrayRead(), VecCUDAGetArrayWrite(), VecGetArray(), VecGetArrayRead() @*/ PETSC_EXTERN PetscErrorCode VecCUDAGetArrayWrite(Vec v, PetscScalar **a) { PetscErrorCode ierr; PetscFunctionBegin; PetscCheckTypeNames(v,VECSEQCUDA,VECMPICUDA); *a = 0; ierr = VecCUDAAllocateCheck(v);CHKERRQ(ierr); *a = ((Vec_CUDA*)v->spptr)->GPUarray; PetscFunctionReturn(0); } /*@C VecCUDARestoreArrayWrite - Restore a CUDA device pointer previously acquired with VecCUDAGetArrayWrite(). Data on the host will be marked as out of date. Subsequent access of the data on the host side e.g. with VecGetArray() will incur a device to host data transfer. Input Parameter: + v - the vector - a - the CUDA device pointer. This pointer is invalid after VecCUDARestoreArrayWrite() returns. Fortran note: This function is not currently available from Fortran. Level: intermediate .seealso: VecCUDAGetArrayWrite(), VecCUDAGetArrayReadWrite(), VecCUDAGetArrayRead(), VecCUDAGetArrayWrite(), VecGetArray(), VecRestoreArray(), VecGetArrayRead() @*/ PETSC_EXTERN PetscErrorCode VecCUDARestoreArrayWrite(Vec v, PetscScalar **a) { PetscErrorCode ierr; PetscFunctionBegin; PetscCheckTypeNames(v,VECSEQCUDA,VECMPICUDA); v->valid_GPU_array = PETSC_OFFLOAD_GPU; ierr = PetscObjectStateIncrease((PetscObject)v);CHKERRQ(ierr); PetscFunctionReturn(0); } /*@C VecCUDAPlaceArray - Allows one to replace the GPU array in a vector with a GPU array provided by the user. This is useful to avoid copying an array into a vector. Not Collective Input Parameters: + vec - the vector - array - the GPU array Notes: You can return to the original GPU array with a call to VecCUDAResetArray() It is not possible to use VecCUDAPlaceArray() and VecPlaceArray() at the same time on the same vector. Level: developer .seealso: VecPlaceArray(), VecGetArray(), VecRestoreArray(), VecReplaceArray(), VecResetArray(), VecCUDAResetArray(), VecCUDAReplaceArray() @*/ PetscErrorCode VecCUDAPlaceArray(Vec vin,PetscScalar *a) { PetscErrorCode ierr; PetscFunctionBegin; PetscCheckTypeNames(vin,VECSEQCUDA,VECMPICUDA); ierr = VecCUDACopyToGPU(vin);CHKERRQ(ierr); if (((Vec_Seq*)vin->data)->unplacedarray) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"VecCUDAPlaceArray()/VecPlaceArray() was already called on this vector, without a call to VecCUDAResetArray()/VecResetArray()"); ((Vec_Seq*)vin->data)->unplacedarray = (PetscScalar *) ((Vec_CUDA*)vin->spptr)->GPUarray; /* save previous GPU array so reset can bring it back */ ((Vec_CUDA*)vin->spptr)->GPUarray = a; vin->valid_GPU_array = PETSC_OFFLOAD_GPU; ierr = PetscObjectStateIncrease((PetscObject)vin);CHKERRQ(ierr); PetscFunctionReturn(0); } /*@C VecCUDAReplaceArray - Allows one to replace the GPU array in a vector with a GPU array provided by the user. This is useful to avoid copying a GPU array into a vector. Not Collective Input Parameters: + vec - the vector - array - the GPU array Notes: This permanently replaces the GPU array and frees the memory associated with the old GPU array. The memory passed in CANNOT be freed by the user. It will be freed when the vector is destroyed. Not supported from Fortran Level: developer .seealso: VecGetArray(), VecRestoreArray(), VecPlaceArray(), VecResetArray(), VecCUDAResetArray(), VecCUDAPlaceArray(), VecReplaceArray() @*/ PetscErrorCode VecCUDAReplaceArray(Vec vin,PetscScalar *a) { cudaError_t err; PetscErrorCode ierr; PetscFunctionBegin; PetscCheckTypeNames(vin,VECSEQCUDA,VECMPICUDA); err = cudaFree(((Vec_CUDA*)vin->spptr)->GPUarray);CHKERRCUDA(err); ((Vec_CUDA*)vin->spptr)->GPUarray = a; vin->valid_GPU_array = PETSC_OFFLOAD_GPU; ierr = PetscObjectStateIncrease((PetscObject)vin);CHKERRQ(ierr); PetscFunctionReturn(0); } /*@C VecCUDAResetArray - Resets a vector to use its default memory. Call this after the use of VecCUDAPlaceArray(). Not Collective Input Parameters: . vec - the vector Level: developer .seealso: VecGetArray(), VecRestoreArray(), VecReplaceArray(), VecPlaceArray(), VecResetArray(), VecCUDAPlaceArray(), VecCUDAReplaceArray() @*/ PetscErrorCode VecCUDAResetArray(Vec vin) { PetscErrorCode ierr; PetscFunctionBegin; PetscCheckTypeNames(vin,VECSEQCUDA,VECMPICUDA); ierr = VecCUDACopyToGPU(vin);CHKERRQ(ierr); ((Vec_CUDA*)vin->spptr)->GPUarray = (PetscScalar *) ((Vec_Seq*)vin->data)->unplacedarray; ((Vec_Seq*)vin->data)->unplacedarray = 0; vin->valid_GPU_array = PETSC_OFFLOAD_GPU; ierr = PetscObjectStateIncrease((PetscObject)vin);CHKERRQ(ierr); PetscFunctionReturn(0); }
3a7983e99a6134bf7953e9b213f69ed637de8d70.hip
// !!! This is a file automatically generated by hipify!!! /* * Copyright 1993-2015 NVIDIA Corporation. All rights reserved. * * Please refer to the NVIDIA end user license agreement (EULA) associated * with this source code for terms and conditions that govern your use of * this software. Any use, reproduction, disclosure, or distribution of * this software and related documentation outside the terms of the EULA * is strictly prohibited. * */ /* * This sample demonstrates how to use texture fetches from layered 2D textures in CUDA C * * This sample first generates a 3D input data array for the layered texture * and the expected output. Then it starts CUDA C kernels, one for each layer, * which fetch their layer's texture data (using normalized texture coordinates) * transform it to the expected output, and write it to a 3D output data array. */ // includes, system #include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> // includes CUDA #include <hip/hip_runtime.h> // helper functions and utilities to work with CUDA #include <helper_functions.h> #include <helper_cuda.h> //static const char *sSDKname = "simpleCubemapTexture"; // includes, kernels // declare texture reference for layered 2D float texture // Note: The "dim" field in the texture reference template is now deprecated. // Instead, please use a texture type macro such as hipTextureType1D, etc. texture<float, hipTextureTypeCubemap> tex; //////////////////////////////////////////////////////////////////////////////// //! Transform a cubemap face of a linear buffe using cubemap texture lookups //! @param g_odata output data in global memory //////////////////////////////////////////////////////////////////////////////// __global__ void transformKernel(float *g_odata, int width) { // calculate this thread's data point unsigned int x = blockIdx.x*blockDim.x + threadIdx.x; unsigned int y = blockIdx.y*blockDim.y + threadIdx.y; // 0.5f offset and division are necessary to access the original data points // in the texture (such that bilinear interpolation will not be activated). // For details, see also CUDA Programming Guide, Appendix D float u = ((x+0.5f) / (float) width) * 2.f - 1.f; float v = ((y+0.5f) / (float) width) * 2.f - 1.f; float cx, cy, cz; for (unsigned int face = 0; face < 6; face ++) { //Layer 0 is positive X face if (face == 0) { cx = 1; cy = -v; cz = -u; } //Layer 1 is negative X face else if (face == 1) { cx = -1; cy = -v; cz = u; } //Layer 2 is positive Y face else if (face == 2) { cx = u; cy = 1; cz = v; } //Layer 3 is negative Y face else if (face == 3) { cx = u; cy = -1; cz = -v; } //Layer 4 is positive Z face else if (face == 4) { cx = u; cy = -v; cz = 1; } //Layer 4 is negative Z face else if (face == 5) { cx = -u; cy = -v; cz = -1; } // read from texture, do expected transformation and write to global memory g_odata[face*width*width + y*width + x] = -texCubemap(tex, cx, cy, cz); } } //////////////////////////////////////////////////////////////////////////////// // Program main //////////////////////////////////////////////////////////////////////////////// int main(int argc, char **argv) { // use command-line specified CUDA device, otherwise use device with highest Gflops/s //int devID = findCudaDevice(argc, (const char **)argv); bool bResult = true; // get number of SMs on this GPU //hipDeviceProp_t deviceProps; //checkCudaErrors(hipGetDeviceProperties(&deviceProps, devID)); //printf("CUDA device [%s] has %d Multi-Processors ", deviceProps.name, deviceProps.multiProcessorCount); //printf("SM %d.%d\n", deviceProps.major, deviceProps.minor); //if (deviceProps.major < 2) //{ //printf("%s requires SM 2.0 or higher for support of Texture Arrays. Test will exit... \n", sSDKname); //exit(EXIT_WAIVED); //} // generate input data for layered texture unsigned int width=64, num_faces = 6, num_layers = 1; unsigned int cubemap_size = width * width * num_faces; unsigned int size = cubemap_size * num_layers * sizeof(float); float *h_data = (float *) malloc(size); for (int i = 0; i < (int)(cubemap_size * num_layers); i++) { h_data[i] = (float)i; } // this is the expected transformation of the input data (the expected output) float *h_data_ref = (float *) malloc(size); for (unsigned int layer = 0; layer < num_layers; layer++) { for (int i = 0; i < (int)(cubemap_size); i++) { h_data_ref[layer*cubemap_size + i] = -h_data[layer*cubemap_size + i] + layer; } } // allocate device memory for result float *d_data = NULL; checkCudaErrors(hipMalloc((void **) &d_data, size)); // allocate array and copy image data hipChannelFormatDesc channelDesc = hipCreateChannelDesc(32, 0, 0, 0, hipChannelFormatKindFloat); hipArray *cu_3darray; // checkCudaErrors(hipMalloc3DArray( &cu_3darray, &channelDesc, make_hipExtent(width, height, num_layers), hipArrayLayered )); checkCudaErrors(hipMalloc3DArray(&cu_3darray, &channelDesc, make_hipExtent(width, width, num_faces), hipArrayCubemap)); hipMemcpy3DParms myparms = {0}; myparms.srcPos = make_hipPos(0,0,0); myparms.dstPos = make_hipPos(0,0,0); myparms.srcPtr = make_hipPitchedPtr(h_data, width * sizeof(float), width, width); myparms.dstArray = cu_3darray; myparms.extent = make_hipExtent(width, width, num_faces); myparms.kind = hipMemcpyHostToDevice; checkCudaErrors(hipMemcpy3D(&myparms)); // set texture parameters tex.addressMode[0] = hipAddressModeWrap; tex.addressMode[1] = hipAddressModeWrap; tex.filterMode = hipFilterModeLinear; tex.normalized = true; // access with normalized texture coordinates // Bind the array to the texture checkCudaErrors(hipBindTextureToArray(tex, cu_3darray, channelDesc)); dim3 dimBlock(8, 8, 1); dim3 dimGrid(width / dimBlock.x, width / dimBlock.y, 1); //printf("Covering Cubemap data array of %d~3 x %d: Grid size is %d x %d, each block has 8 x 8 threads\n", // width, num_layers, dimGrid.x, dimGrid.y); hipLaunchKernelGGL(( transformKernel), dim3(dimGrid), dim3(dimBlock) , 0, 0, d_data, width); // warmup (for better timing) // check if kernel execution generated an error getLastCudaError("warmup Kernel execution failed"); checkCudaErrors(hipDeviceSynchronize()); StopWatchInterface *timer = NULL; sdkCreateTimer(&timer); sdkStartTimer(&timer); // execute the kernel hipLaunchKernelGGL(( transformKernel), dim3(dimGrid), dim3(dimBlock), 0 , 0, d_data, width); // check if kernel execution generated an error getLastCudaError("Kernel execution failed"); checkCudaErrors(hipDeviceSynchronize()); sdkStopTimer(&timer); //printf("Processing time: %.3f msec\n", sdkGetTimerValue(&timer)); //printf("%.2f Mtexlookups/sec\n", (cubemap_size / (sdkGetTimerValue(&timer) / 1000.0f) / 1e6)); sdkDeleteTimer(&timer); // allocate mem for the result on host side float *h_odata = (float *) malloc(size); // copy result from device to host checkCudaErrors(hipMemcpy(h_odata, d_data, size, hipMemcpyDeviceToHost)); // write regression file if necessary if (checkCmdLineFlag(argc, (const char **)argv, "regression")) { // write file for regression test sdkWriteFile<float>("./data/regression.dat", h_odata, width*width, 0.0f, false); } else { //printf("Comparing kernel output to expected data\n"); #define MIN_EPSILON_ERROR 5e-3f bResult = compareData(h_odata, h_data_ref, cubemap_size, MIN_EPSILON_ERROR, 0.0f); } // cleanup memory free(h_data); free(h_data_ref); free(h_odata); checkCudaErrors(hipFree(d_data)); checkCudaErrors(hipFreeArray(cu_3darray)); exit(bResult ? EXIT_SUCCESS : EXIT_FAILURE); }
3a7983e99a6134bf7953e9b213f69ed637de8d70.cu
/* * Copyright 1993-2015 NVIDIA Corporation. All rights reserved. * * Please refer to the NVIDIA end user license agreement (EULA) associated * with this source code for terms and conditions that govern your use of * this software. Any use, reproduction, disclosure, or distribution of * this software and related documentation outside the terms of the EULA * is strictly prohibited. * */ /* * This sample demonstrates how to use texture fetches from layered 2D textures in CUDA C * * This sample first generates a 3D input data array for the layered texture * and the expected output. Then it starts CUDA C kernels, one for each layer, * which fetch their layer's texture data (using normalized texture coordinates) * transform it to the expected output, and write it to a 3D output data array. */ // includes, system #include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> // includes CUDA #include <cuda_runtime.h> // helper functions and utilities to work with CUDA #include <helper_functions.h> #include <helper_cuda.h> //static const char *sSDKname = "simpleCubemapTexture"; // includes, kernels // declare texture reference for layered 2D float texture // Note: The "dim" field in the texture reference template is now deprecated. // Instead, please use a texture type macro such as cudaTextureType1D, etc. texture<float, cudaTextureTypeCubemap> tex; //////////////////////////////////////////////////////////////////////////////// //! Transform a cubemap face of a linear buffe using cubemap texture lookups //! @param g_odata output data in global memory //////////////////////////////////////////////////////////////////////////////// __global__ void transformKernel(float *g_odata, int width) { // calculate this thread's data point unsigned int x = blockIdx.x*blockDim.x + threadIdx.x; unsigned int y = blockIdx.y*blockDim.y + threadIdx.y; // 0.5f offset and division are necessary to access the original data points // in the texture (such that bilinear interpolation will not be activated). // For details, see also CUDA Programming Guide, Appendix D float u = ((x+0.5f) / (float) width) * 2.f - 1.f; float v = ((y+0.5f) / (float) width) * 2.f - 1.f; float cx, cy, cz; for (unsigned int face = 0; face < 6; face ++) { //Layer 0 is positive X face if (face == 0) { cx = 1; cy = -v; cz = -u; } //Layer 1 is negative X face else if (face == 1) { cx = -1; cy = -v; cz = u; } //Layer 2 is positive Y face else if (face == 2) { cx = u; cy = 1; cz = v; } //Layer 3 is negative Y face else if (face == 3) { cx = u; cy = -1; cz = -v; } //Layer 4 is positive Z face else if (face == 4) { cx = u; cy = -v; cz = 1; } //Layer 4 is negative Z face else if (face == 5) { cx = -u; cy = -v; cz = -1; } // read from texture, do expected transformation and write to global memory g_odata[face*width*width + y*width + x] = -texCubemap(tex, cx, cy, cz); } } //////////////////////////////////////////////////////////////////////////////// // Program main //////////////////////////////////////////////////////////////////////////////// int main(int argc, char **argv) { // use command-line specified CUDA device, otherwise use device with highest Gflops/s //int devID = findCudaDevice(argc, (const char **)argv); bool bResult = true; // get number of SMs on this GPU //cudaDeviceProp deviceProps; //checkCudaErrors(cudaGetDeviceProperties(&deviceProps, devID)); //printf("CUDA device [%s] has %d Multi-Processors ", deviceProps.name, deviceProps.multiProcessorCount); //printf("SM %d.%d\n", deviceProps.major, deviceProps.minor); //if (deviceProps.major < 2) //{ //printf("%s requires SM 2.0 or higher for support of Texture Arrays. Test will exit... \n", sSDKname); //exit(EXIT_WAIVED); //} // generate input data for layered texture unsigned int width=64, num_faces = 6, num_layers = 1; unsigned int cubemap_size = width * width * num_faces; unsigned int size = cubemap_size * num_layers * sizeof(float); float *h_data = (float *) malloc(size); for (int i = 0; i < (int)(cubemap_size * num_layers); i++) { h_data[i] = (float)i; } // this is the expected transformation of the input data (the expected output) float *h_data_ref = (float *) malloc(size); for (unsigned int layer = 0; layer < num_layers; layer++) { for (int i = 0; i < (int)(cubemap_size); i++) { h_data_ref[layer*cubemap_size + i] = -h_data[layer*cubemap_size + i] + layer; } } // allocate device memory for result float *d_data = NULL; checkCudaErrors(cudaMalloc((void **) &d_data, size)); // allocate array and copy image data cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc(32, 0, 0, 0, cudaChannelFormatKindFloat); cudaArray *cu_3darray; // checkCudaErrors(cudaMalloc3DArray( &cu_3darray, &channelDesc, make_cudaExtent(width, height, num_layers), cudaArrayLayered )); checkCudaErrors(cudaMalloc3DArray(&cu_3darray, &channelDesc, make_cudaExtent(width, width, num_faces), cudaArrayCubemap)); cudaMemcpy3DParms myparms = {0}; myparms.srcPos = make_cudaPos(0,0,0); myparms.dstPos = make_cudaPos(0,0,0); myparms.srcPtr = make_cudaPitchedPtr(h_data, width * sizeof(float), width, width); myparms.dstArray = cu_3darray; myparms.extent = make_cudaExtent(width, width, num_faces); myparms.kind = cudaMemcpyHostToDevice; checkCudaErrors(cudaMemcpy3D(&myparms)); // set texture parameters tex.addressMode[0] = cudaAddressModeWrap; tex.addressMode[1] = cudaAddressModeWrap; tex.filterMode = cudaFilterModeLinear; tex.normalized = true; // access with normalized texture coordinates // Bind the array to the texture checkCudaErrors(cudaBindTextureToArray(tex, cu_3darray, channelDesc)); dim3 dimBlock(8, 8, 1); dim3 dimGrid(width / dimBlock.x, width / dimBlock.y, 1); //printf("Covering Cubemap data array of %d~3 x %d: Grid size is %d x %d, each block has 8 x 8 threads\n", // width, num_layers, dimGrid.x, dimGrid.y); transformKernel<<< dimGrid, dimBlock >>>(d_data, width); // warmup (for better timing) // check if kernel execution generated an error getLastCudaError("warmup Kernel execution failed"); checkCudaErrors(cudaDeviceSynchronize()); StopWatchInterface *timer = NULL; sdkCreateTimer(&timer); sdkStartTimer(&timer); // execute the kernel transformKernel<<< dimGrid, dimBlock, 0 >>>(d_data, width); // check if kernel execution generated an error getLastCudaError("Kernel execution failed"); checkCudaErrors(cudaDeviceSynchronize()); sdkStopTimer(&timer); //printf("Processing time: %.3f msec\n", sdkGetTimerValue(&timer)); //printf("%.2f Mtexlookups/sec\n", (cubemap_size / (sdkGetTimerValue(&timer) / 1000.0f) / 1e6)); sdkDeleteTimer(&timer); // allocate mem for the result on host side float *h_odata = (float *) malloc(size); // copy result from device to host checkCudaErrors(cudaMemcpy(h_odata, d_data, size, cudaMemcpyDeviceToHost)); // write regression file if necessary if (checkCmdLineFlag(argc, (const char **)argv, "regression")) { // write file for regression test sdkWriteFile<float>("./data/regression.dat", h_odata, width*width, 0.0f, false); } else { //printf("Comparing kernel output to expected data\n"); #define MIN_EPSILON_ERROR 5e-3f bResult = compareData(h_odata, h_data_ref, cubemap_size, MIN_EPSILON_ERROR, 0.0f); } // cleanup memory free(h_data); free(h_data_ref); free(h_odata); checkCudaErrors(cudaFree(d_data)); checkCudaErrors(cudaFreeArray(cu_3darray)); exit(bResult ? EXIT_SUCCESS : EXIT_FAILURE); }
8a36bb9baba7e2e6e858162b18e9a1af74305097.hip
// !!! This is a file automatically generated by hipify!!! #include <stdbool.h> #include <stdio.h> #include <string.h> #include <getopt.h> #include <hiprand/hiprand_kernel.h> #include <stdlib.h> #include <hip/hip_runtime.h> #include <sys/time.h> #include "_bcnn_forward_depthwise_sep_conv_weight_kernel.cu" #include<chrono> #include<iostream> using namespace std; using namespace std::chrono; int blocks_[20][2] = {{8,8},{16,16},{24,24},{32,32},{1,64},{1,128},{1,192},{1,256},{1,320},{1,384},{1,448},{1,512},{1,576},{1,640},{1,704},{1,768},{1,832},{1,896},{1,960},{1,1024}}; int matrices_[7][2] = {{240,240},{496,496},{784,784},{1016,1016},{1232,1232},{1680,1680},{2024,2024}}; int main(int argc, char **argv) { hipSetDevice(0); char* p;int matrix_len=strtol(argv[1], &p, 10); for(int matrix_looper=0;matrix_looper<matrix_len;matrix_looper++){ for(int block_looper=0;block_looper<20;block_looper++){ int XSIZE=matrices_[matrix_looper][0],YSIZE=matrices_[matrix_looper][1],BLOCKX=blocks_[block_looper][0],BLOCKY=blocks_[block_looper][1]; int nthreads = 1; float *src_data = NULL; hipMalloc(&src_data, XSIZE*YSIZE); float *weight_data = NULL; hipMalloc(&weight_data, XSIZE*YSIZE); int channels = 1; int dst_h = 1; int dst_w = 1; int src_h = 1; int src_w = 1; int kernel_sz = 1; int stride = 2; int pad = 2; float *dst_data = NULL; hipMalloc(&dst_data, XSIZE*YSIZE); int iXSIZE= XSIZE; int iYSIZE= YSIZE; while(iXSIZE%BLOCKX!=0) { iXSIZE++; } while(iYSIZE%BLOCKY!=0) { iYSIZE++; } dim3 gridBlock(iXSIZE/BLOCKX, iYSIZE/BLOCKY); dim3 threadBlock(BLOCKX, BLOCKY); hipFree(0);hipLaunchKernelGGL(( _bcnn_forward_depthwise_sep_conv_weight_kernel), dim3(gridBlock),dim3(threadBlock), 0, 0, nthreads,src_data,weight_data,channels,dst_h,dst_w,src_h,src_w,kernel_sz,stride,pad,dst_data); hipDeviceSynchronize(); for (int loop_counter = 0; loop_counter < 10; ++loop_counter) {hipLaunchKernelGGL(( _bcnn_forward_depthwise_sep_conv_weight_kernel), dim3(gridBlock),dim3(threadBlock), 0, 0, nthreads,src_data,weight_data,channels,dst_h,dst_w,src_h,src_w,kernel_sz,stride,pad,dst_data); } auto start = steady_clock::now(); for (int loop_counter = 0; loop_counter < 1000; loop_counter++) {hipLaunchKernelGGL(( _bcnn_forward_depthwise_sep_conv_weight_kernel), dim3(gridBlock),dim3(threadBlock), 0, 0, nthreads,src_data,weight_data,channels,dst_h,dst_w,src_h,src_w,kernel_sz,stride,pad,dst_data); } auto end = steady_clock::now(); auto usecs = duration_cast<duration<float, microseconds::period> >(end - start); cout <<'['<<usecs.count()<<','<<'('<<BLOCKX<<','<<BLOCKY<<')' << ','<<'('<<XSIZE<<','<<YSIZE<<')'<<']' << endl; } }}
8a36bb9baba7e2e6e858162b18e9a1af74305097.cu
#include <stdbool.h> #include <stdio.h> #include <string.h> #include <getopt.h> #include <curand_kernel.h> #include <stdlib.h> #include <cuda.h> #include <sys/time.h> #include "_bcnn_forward_depthwise_sep_conv_weight_kernel.cu" #include<chrono> #include<iostream> using namespace std; using namespace std::chrono; int blocks_[20][2] = {{8,8},{16,16},{24,24},{32,32},{1,64},{1,128},{1,192},{1,256},{1,320},{1,384},{1,448},{1,512},{1,576},{1,640},{1,704},{1,768},{1,832},{1,896},{1,960},{1,1024}}; int matrices_[7][2] = {{240,240},{496,496},{784,784},{1016,1016},{1232,1232},{1680,1680},{2024,2024}}; int main(int argc, char **argv) { cudaSetDevice(0); char* p;int matrix_len=strtol(argv[1], &p, 10); for(int matrix_looper=0;matrix_looper<matrix_len;matrix_looper++){ for(int block_looper=0;block_looper<20;block_looper++){ int XSIZE=matrices_[matrix_looper][0],YSIZE=matrices_[matrix_looper][1],BLOCKX=blocks_[block_looper][0],BLOCKY=blocks_[block_looper][1]; int nthreads = 1; float *src_data = NULL; cudaMalloc(&src_data, XSIZE*YSIZE); float *weight_data = NULL; cudaMalloc(&weight_data, XSIZE*YSIZE); int channels = 1; int dst_h = 1; int dst_w = 1; int src_h = 1; int src_w = 1; int kernel_sz = 1; int stride = 2; int pad = 2; float *dst_data = NULL; cudaMalloc(&dst_data, XSIZE*YSIZE); int iXSIZE= XSIZE; int iYSIZE= YSIZE; while(iXSIZE%BLOCKX!=0) { iXSIZE++; } while(iYSIZE%BLOCKY!=0) { iYSIZE++; } dim3 gridBlock(iXSIZE/BLOCKX, iYSIZE/BLOCKY); dim3 threadBlock(BLOCKX, BLOCKY); cudaFree(0); _bcnn_forward_depthwise_sep_conv_weight_kernel<<<gridBlock,threadBlock>>>(nthreads,src_data,weight_data,channels,dst_h,dst_w,src_h,src_w,kernel_sz,stride,pad,dst_data); cudaDeviceSynchronize(); for (int loop_counter = 0; loop_counter < 10; ++loop_counter) { _bcnn_forward_depthwise_sep_conv_weight_kernel<<<gridBlock,threadBlock>>>(nthreads,src_data,weight_data,channels,dst_h,dst_w,src_h,src_w,kernel_sz,stride,pad,dst_data); } auto start = steady_clock::now(); for (int loop_counter = 0; loop_counter < 1000; loop_counter++) { _bcnn_forward_depthwise_sep_conv_weight_kernel<<<gridBlock,threadBlock>>>(nthreads,src_data,weight_data,channels,dst_h,dst_w,src_h,src_w,kernel_sz,stride,pad,dst_data); } auto end = steady_clock::now(); auto usecs = duration_cast<duration<float, microseconds::period> >(end - start); cout <<'['<<usecs.count()<<','<<'('<<BLOCKX<<','<<BLOCKY<<')' << ','<<'('<<XSIZE<<','<<YSIZE<<')'<<']' << endl; } }}
7d60038b58636c3f56f178a47e409959fb6cd080.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" /* * * nullKernelAsync.cu * * Microbenchmark for throughput of asynchronous kernel launch. * * Build with: nvcc -I ../chLib <options> nullKernelAsync.cu * Requires: No minimum SM requirement. * * Copyright (c) 2011-2012, Archaea Software, LLC. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * */ #include <stdio.h> #include "chTimer.h" __global__ void NullKernel() { } int main( int argc, char *argv[] ) { const int cIterations = 1000000; printf( "Measuring asynchronous launch time... " ); fflush( stdout ); chTimerTimestamp start, stop; chTimerGetTime( &start ); for ( int i = 0; i < cIterations; i++ ) { hipLaunchKernelGGL(( NullKernel), dim3(1),dim3(1), 0, 0, ); } hipDeviceSynchronize(); chTimerGetTime( &stop ); { double microseconds = 1e6*chTimerElapsedTime( &start, &stop ); double usPerLaunch = microseconds / (float) cIterations; printf( "%.2f us\n", usPerLaunch ); } return 0; }
7d60038b58636c3f56f178a47e409959fb6cd080.cu
/* * * nullKernelAsync.cu * * Microbenchmark for throughput of asynchronous kernel launch. * * Build with: nvcc -I ../chLib <options> nullKernelAsync.cu * Requires: No minimum SM requirement. * * Copyright (c) 2011-2012, Archaea Software, LLC. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * */ #include <stdio.h> #include "chTimer.h" __global__ void NullKernel() { } int main( int argc, char *argv[] ) { const int cIterations = 1000000; printf( "Measuring asynchronous launch time... " ); fflush( stdout ); chTimerTimestamp start, stop; chTimerGetTime( &start ); for ( int i = 0; i < cIterations; i++ ) { NullKernel<<<1,1>>>(); } cudaThreadSynchronize(); chTimerGetTime( &stop ); { double microseconds = 1e6*chTimerElapsedTime( &start, &stop ); double usPerLaunch = microseconds / (float) cIterations; printf( "%.2f us\n", usPerLaunch ); } return 0; }
eb86339f490f43098b7cad8040942097e5aa2c34.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include<stdio.h> #include<stdlib.h> #include<math.h> void printMatrix(int*,int); __global__ void MatrixAddKernel(int*,int*,int*,int,int); int main() { int nrow=1000; int ncol=1000; /* Dynamically allocate memory to 3 matrices. Each matrix is represented as a 1D array*/ int* mat1=new int[nrow*ncol]; int* mat2=new int[nrow*ncol]; int* sum=new int[nrow*ncol]; srand(time(NULL)); for(int i=0;i<nrow;i++) for(int j=0;j<ncol;j++) { mat1[i*ncol+j]=rand()%4; mat2[i*ncol+j]=rand()%6; } int size=nrow*ncol*sizeof(int); int* mat1_d, *mat2_d, *sum_d; hipMalloc((void**)&mat1_d,size); hipMalloc((void**)&mat2_d,size); hipMalloc((void**)&sum_d,size); hipMemcpy(mat1_d,mat1,size,hipMemcpyHostToDevice); hipMemcpy(mat2_d,mat2,size,hipMemcpyHostToDevice); /*Each block consists of 1024 threads. Each block of threads functions conceptually like a tile*/ dim3 dimBlock(32,32); /*The x-dimension is horizontal and the y-dimension is vertical*/ /*The x-dimension and the y-dimension depend on the no. of columns and the no. of rows respectively*/ dim3 dimGrid(ceil(ncol/32.0),ceil(nrow/32.0)); hipLaunchKernelGGL(( MatrixAddKernel), dim3(dimGrid),dim3(dimBlock), 0, 0, mat1_d,mat2_d,sum_d,nrow,ncol); hipMemcpy(sum,sum_d,size,hipMemcpyDeviceToHost); printMatrix(mat1,ncol); printMatrix(mat2,ncol); printMatrix(sum,ncol); hipFree(mat1_d); hipFree(mat2_d); hipFree(sum_d); } __global__ void MatrixAddKernel(int* mat1_d, int* mat2_d, int* sum_d, int nrow, int ncol) { int row=blockIdx.y*blockDim.y+threadIdx.y; int col=blockIdx.x*blockDim.x+threadIdx.x; /*Error checking is required because matrices need not fit in exact tiles*/ if(row<nrow && col<ncol) sum_d[row*ncol+col]=mat1_d[row*ncol+col]+mat2_d[row*ncol+col]; } void printMatrix(int* mat,int ncol) { for(int i=0;i<3;i++) { for(int j=0;j<3;j++) printf("%d ",mat[i*ncol+j]); printf("\n"); } printf("\n\n"); }
eb86339f490f43098b7cad8040942097e5aa2c34.cu
#include<stdio.h> #include<stdlib.h> #include<math.h> void printMatrix(int*,int); __global__ void MatrixAddKernel(int*,int*,int*,int,int); int main() { int nrow=1000; int ncol=1000; /* Dynamically allocate memory to 3 matrices. Each matrix is represented as a 1D array*/ int* mat1=new int[nrow*ncol]; int* mat2=new int[nrow*ncol]; int* sum=new int[nrow*ncol]; srand(time(NULL)); for(int i=0;i<nrow;i++) for(int j=0;j<ncol;j++) { mat1[i*ncol+j]=rand()%4; mat2[i*ncol+j]=rand()%6; } int size=nrow*ncol*sizeof(int); int* mat1_d, *mat2_d, *sum_d; cudaMalloc((void**)&mat1_d,size); cudaMalloc((void**)&mat2_d,size); cudaMalloc((void**)&sum_d,size); cudaMemcpy(mat1_d,mat1,size,cudaMemcpyHostToDevice); cudaMemcpy(mat2_d,mat2,size,cudaMemcpyHostToDevice); /*Each block consists of 1024 threads. Each block of threads functions conceptually like a tile*/ dim3 dimBlock(32,32); /*The x-dimension is horizontal and the y-dimension is vertical*/ /*The x-dimension and the y-dimension depend on the no. of columns and the no. of rows respectively*/ dim3 dimGrid(ceil(ncol/32.0),ceil(nrow/32.0)); MatrixAddKernel<<<dimGrid,dimBlock>>>(mat1_d,mat2_d,sum_d,nrow,ncol); cudaMemcpy(sum,sum_d,size,cudaMemcpyDeviceToHost); printMatrix(mat1,ncol); printMatrix(mat2,ncol); printMatrix(sum,ncol); cudaFree(mat1_d); cudaFree(mat2_d); cudaFree(sum_d); } __global__ void MatrixAddKernel(int* mat1_d, int* mat2_d, int* sum_d, int nrow, int ncol) { int row=blockIdx.y*blockDim.y+threadIdx.y; int col=blockIdx.x*blockDim.x+threadIdx.x; /*Error checking is required because matrices need not fit in exact tiles*/ if(row<nrow && col<ncol) sum_d[row*ncol+col]=mat1_d[row*ncol+col]+mat2_d[row*ncol+col]; } void printMatrix(int* mat,int ncol) { for(int i=0;i<3;i++) { for(int j=0;j<3;j++) printf("%d ",mat[i*ncol+j]); printf("\n"); } printf("\n\n"); }
0c663f2f9784bbb72b2d133043b995dc77546812.hip
// !!! This is a file automatically generated by hipify!!! /************************************* * Fichier enhanced_algo_opt_cuda.cu * *************************************/ #include <stdlib.h> #include <stdio.h> #include <sys/time.h> #include "../inc/utils.h" #include <hip/hip_runtime.h> // Less than 1000 : no changes; more than 10000 : a bit slower #define NUM_LOCALS 1000 /** * CUDA error control and debugging. */ #ifdef CUDA_DEBUG #define CUDA_SYNC_ERROR() { \ hipError_t sync_error; \ hipDeviceSynchronize(); \ sync_error = hipGetLastError(); \ if(sync_error != hipSuccess) { \ fprintf(stderr, "[CUDA SYNC ERROR at %s:%d -> %s]\n", \ __FILE__ , __LINE__, hipGetErrorString(sync_error)); \ exit(EXIT_FAILURE); \ } \ } #else /* #ifdef CUDA_DEBUG */ #define CUDA_SYNC_ERROR() #endif /* #ifdef CUDA_DEBUG */ #define CUDA_ERROR(cuda_call) { \ hipError_t error = cuda_call; \ if(error != hipSuccess){ \ fprintf(stderr, "[CUDA ERROR at %s:%d -> %s]\n", \ __FILE__ , __LINE__, hipGetErrorString(error)); \ exit(EXIT_FAILURE); \ } \ CUDA_SYNC_ERROR(); \ } /** * Function iDivUp() * Return integer quotient superior or equal to "a/b" * Source : CUDA SDK 4.1 */ static int iDivUp(int a, int b){ return ((a % b != 0) ? (a / b + 1) : (a / b)); } /** * * Function enhanced_algo_opt_cuda() * **/ __global__ void enhanced_algo_opt_cuda(unsigned long *abs, unsigned long *ord, int n, int l, int h, unsigned long long *S_gpu, unsigned long long *local_max, int num_locals){ int a = blockDim.x * blockIdx.x + threadIdx.x; int li = a%num_locals; int b = 0; unsigned long long old_max; int ymin = 0, aux = n/10; unsigned long long S_it = 0, S = 0; if ((a < n)){ // Compute only when a < b for(b = a+1; b < n; b++){ if(b == a+1) ymin = h; else if (ymin > ord[b-1]) ymin = ord[b-1]; //else -- nothing // WARNING : no default case S_it = (abs[b] - abs[a]) * ymin; if(S_it > S) S = S_it; } // for loop // Optimized with local maximums old_max = atomicMax(&local_max[li], S); if (old_max < S) atomicMax(S_gpu, S); } // test bound loop return; } /** * * Function main() * **/ int main(int argc, char **argv){ double debut=0.0, fin=0.0; unsigned long **data, *abs_gpu, *ord_gpu; unsigned long long S = 0, *S_gpu, *local_max_gpu; int num_locals = NUM_LOCALS; // modulo = nombre de maximaux locaux int res = 0, i= 0; int n = 0, l = 0, h = 0; int *n_gpu, *l_gpu, *h_gpu; if(argc != 2){ printf("Usage: %s <path_of_data_file>\n", argv[0]); return -1; } char *name = argv[1]; /* Read parameters */ res = read_param(name, data, &n, &l, &h); if(res != 0){ printf("read_param :\t ERROR\n"); return -1; } /* Allocate data table */ data = (unsigned long **) malloc(2 * sizeof(unsigned long *)); data[0] = (unsigned long *) malloc(n * sizeof(unsigned long)); data[1] = (unsigned long *) malloc(n * sizeof(unsigned long)); /* Read coordinates from file */ res = read_data(name, data, n); if(res != 0){ printf("read_data :\t ERROR\n"); return -1; } /* GPU allocation */ printf("GPU allocation.\n"); hipMalloc((void **)&n_gpu, sizeof(int)); hipMalloc((void **)&l_gpu, sizeof(int)); hipMalloc((void **)&h_gpu, sizeof(int)); hipMalloc((void **)&S_gpu, sizeof(unsigned long long)); if(n_gpu == NULL || l_gpu == NULL || h_gpu == NULL || S_gpu == NULL) printf("Parameters allocation failed\n"); hipMalloc((void **)&abs_gpu, n * sizeof(unsigned long)); hipMalloc((void **)&ord_gpu, n * sizeof(unsigned long)); hipMalloc((void **)&local_max_gpu, num_locals * sizeof(unsigned long long)); /* CPU -> GPU transfer (synchrones) */ printf("CPU -> GPU transfer.\n"); hipMemcpy(n_gpu, &n, sizeof(int), hipMemcpyHostToDevice); hipMemcpy(l_gpu, &l, sizeof(int), hipMemcpyHostToDevice); hipMemcpy(h_gpu, &h, sizeof(int), hipMemcpyHostToDevice); hipMemcpy(abs_gpu, data[0], n * sizeof(unsigned long), hipMemcpyHostToDevice); hipMemcpy(ord_gpu, data[1], n * sizeof(unsigned long), hipMemcpyHostToDevice); hipMemset(local_max_gpu, 0, num_locals * sizeof(unsigned long long)); hipMemset(S_gpu, 0, sizeof(unsigned long long)); /* Kernel launching */ printf("Launching kernel.\n"); // Using n*n threads but not every one is useful, because of the "i < j" constraint dim3 threadsParBloc(32, 1); dim3 tailleGrille(iDivUp(n,32), 1); /* Start timing */ debut = my_gettimeofday(); /* Do computation: */ printf("Lauching.\n"); hipLaunchKernelGGL(( enhanced_algo_opt_cuda), dim3(tailleGrille), dim3(threadsParBloc), 0, 0, abs_gpu, ord_gpu, n, l, h, S_gpu, local_max_gpu, num_locals); printf("Leaving kernel.\n"); hipDeviceSynchronize(); /* Recopie de l aire maximale sur le CPU */ hipMemcpy((void *)&S, S_gpu, sizeof(unsigned long long), hipMemcpyDeviceToHost); /* End timing */ fin = my_gettimeofday(); fprintf(stdout, "***** Algorithme amlior optimal, en CUDA *****\n"); fprintf(stdout, "Pour les paramtres N = %d\t S = %llu\n", n, S); fprintf( stdout, "Total computation time in s (with gettimeofday()) :\t"); fprintf( stdout, "%g\n\n", fin - debut); /* Free */ printf("\nFreeing and quitting.\n"); free(data[0]); free(data[1]); free(data); hipFree(l_gpu); hipFree(h_gpu); hipFree(n_gpu); hipFree(S_gpu); hipFree(abs_gpu); hipFree(ord_gpu); hipFree(local_max_gpu); return 0; }
0c663f2f9784bbb72b2d133043b995dc77546812.cu
/************************************* * Fichier enhanced_algo_opt_cuda.cu * *************************************/ #include <stdlib.h> #include <stdio.h> #include <sys/time.h> #include "../inc/utils.h" #include <cuda.h> // Less than 1000 : no changes; more than 10000 : a bit slower #define NUM_LOCALS 1000 /** * CUDA error control and debugging. */ #ifdef CUDA_DEBUG #define CUDA_SYNC_ERROR() { \ cudaError_t sync_error; \ cudaDeviceSynchronize(); \ sync_error = cudaGetLastError(); \ if(sync_error != cudaSuccess) { \ fprintf(stderr, "[CUDA SYNC ERROR at %s:%d -> %s]\n", \ __FILE__ , __LINE__, cudaGetErrorString(sync_error)); \ exit(EXIT_FAILURE); \ } \ } #else /* #ifdef CUDA_DEBUG */ #define CUDA_SYNC_ERROR() #endif /* #ifdef CUDA_DEBUG */ #define CUDA_ERROR(cuda_call) { \ cudaError_t error = cuda_call; \ if(error != cudaSuccess){ \ fprintf(stderr, "[CUDA ERROR at %s:%d -> %s]\n", \ __FILE__ , __LINE__, cudaGetErrorString(error)); \ exit(EXIT_FAILURE); \ } \ CUDA_SYNC_ERROR(); \ } /** * Function iDivUp() * Return integer quotient superior or equal to "a/b" * Source : CUDA SDK 4.1 */ static int iDivUp(int a, int b){ return ((a % b != 0) ? (a / b + 1) : (a / b)); } /** * * Function enhanced_algo_opt_cuda() * **/ __global__ void enhanced_algo_opt_cuda(unsigned long *abs, unsigned long *ord, int n, int l, int h, unsigned long long *S_gpu, unsigned long long *local_max, int num_locals){ int a = blockDim.x * blockIdx.x + threadIdx.x; int li = a%num_locals; int b = 0; unsigned long long old_max; int ymin = 0, aux = n/10; unsigned long long S_it = 0, S = 0; if ((a < n)){ // Compute only when a < b for(b = a+1; b < n; b++){ if(b == a+1) ymin = h; else if (ymin > ord[b-1]) ymin = ord[b-1]; //else -- nothing // WARNING : no default case S_it = (abs[b] - abs[a]) * ymin; if(S_it > S) S = S_it; } // for loop // Optimized with local maximums old_max = atomicMax(&local_max[li], S); if (old_max < S) atomicMax(S_gpu, S); } // test bound loop return; } /** * * Function main() * **/ int main(int argc, char **argv){ double debut=0.0, fin=0.0; unsigned long **data, *abs_gpu, *ord_gpu; unsigned long long S = 0, *S_gpu, *local_max_gpu; int num_locals = NUM_LOCALS; // modulo = nombre de maximaux locaux int res = 0, i= 0; int n = 0, l = 0, h = 0; int *n_gpu, *l_gpu, *h_gpu; if(argc != 2){ printf("Usage: %s <path_of_data_file>\n", argv[0]); return -1; } char *name = argv[1]; /* Read parameters */ res = read_param(name, data, &n, &l, &h); if(res != 0){ printf("read_param :\t ERROR\n"); return -1; } /* Allocate data table */ data = (unsigned long **) malloc(2 * sizeof(unsigned long *)); data[0] = (unsigned long *) malloc(n * sizeof(unsigned long)); data[1] = (unsigned long *) malloc(n * sizeof(unsigned long)); /* Read coordinates from file */ res = read_data(name, data, n); if(res != 0){ printf("read_data :\t ERROR\n"); return -1; } /* GPU allocation */ printf("GPU allocation.\n"); cudaMalloc((void **)&n_gpu, sizeof(int)); cudaMalloc((void **)&l_gpu, sizeof(int)); cudaMalloc((void **)&h_gpu, sizeof(int)); cudaMalloc((void **)&S_gpu, sizeof(unsigned long long)); if(n_gpu == NULL || l_gpu == NULL || h_gpu == NULL || S_gpu == NULL) printf("Parameters allocation failed\n"); cudaMalloc((void **)&abs_gpu, n * sizeof(unsigned long)); cudaMalloc((void **)&ord_gpu, n * sizeof(unsigned long)); cudaMalloc((void **)&local_max_gpu, num_locals * sizeof(unsigned long long)); /* CPU -> GPU transfer (synchrones) */ printf("CPU -> GPU transfer.\n"); cudaMemcpy(n_gpu, &n, sizeof(int), cudaMemcpyHostToDevice); cudaMemcpy(l_gpu, &l, sizeof(int), cudaMemcpyHostToDevice); cudaMemcpy(h_gpu, &h, sizeof(int), cudaMemcpyHostToDevice); cudaMemcpy(abs_gpu, data[0], n * sizeof(unsigned long), cudaMemcpyHostToDevice); cudaMemcpy(ord_gpu, data[1], n * sizeof(unsigned long), cudaMemcpyHostToDevice); cudaMemset(local_max_gpu, 0, num_locals * sizeof(unsigned long long)); cudaMemset(S_gpu, 0, sizeof(unsigned long long)); /* Kernel launching */ printf("Launching kernel.\n"); // Using n*n threads but not every one is useful, because of the "i < j" constraint dim3 threadsParBloc(32, 1); dim3 tailleGrille(iDivUp(n,32), 1); /* Start timing */ debut = my_gettimeofday(); /* Do computation: */ printf("Lauching.\n"); enhanced_algo_opt_cuda<<<tailleGrille, threadsParBloc>>>(abs_gpu, ord_gpu, n, l, h, S_gpu, local_max_gpu, num_locals); printf("Leaving kernel.\n"); cudaDeviceSynchronize(); /* Recopie de l aire maximale sur le CPU */ cudaMemcpy((void *)&S, S_gpu, sizeof(unsigned long long), cudaMemcpyDeviceToHost); /* End timing */ fin = my_gettimeofday(); fprintf(stdout, "***** Algorithme amélioré optimal, en CUDA *****\n"); fprintf(stdout, "Pour les paramètres N = %d\t S = %llu\n", n, S); fprintf( stdout, "Total computation time in s (with gettimeofday()) :\t"); fprintf( stdout, "%g\n\n", fin - debut); /* Free */ printf("\nFreeing and quitting.\n"); free(data[0]); free(data[1]); free(data); cudaFree(l_gpu); cudaFree(h_gpu); cudaFree(n_gpu); cudaFree(S_gpu); cudaFree(abs_gpu); cudaFree(ord_gpu); cudaFree(local_max_gpu); return 0; }
e67dd6c893014bbdc0be7cf3d44f47762c2d385a.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include "caffe2/operators/softsign_op.h" #include <algorithm> #include <functional> #include "caffe2/core/context_gpu.h" namespace caffe2 { namespace { template <typename T> inline __host__ __device__ T SquareCUDA(const T x) { return x * x; } template <typename T> inline __device__ T typed_abs(T x); template <> inline __device__ float typed_abs(float x) { return fabsf(x); } template <> inline __device__ double typed_abs(double x) { return fabs(x); } template <typename T> __global__ void SoftsignCUDAKernel(const int N, const T* X, T* Y) { CUDA_1D_KERNEL_LOOP(i, N) { #if __CUDA_ARCH__ >= 350 Y[i] = __ldg(X + i) / (T(1) + typed_abs(__ldg(X + i))); #else Y[i] = X[i] / (T(1) + typed_abs(X[i])); #endif } } template <typename T> __global__ void SoftsignGradientCUDAKernel(const int N, const T* dY, const T* X, T* dX) { CUDA_1D_KERNEL_LOOP(i, N) { #if __CUDA_ARCH__ >= 350 dX[i] = __ldg(dY + i) / SquareCUDA(T(1) + typed_abs(__ldg(X + i))); #else dX[i] = dY[i] / SquareCUDA(T(1) + typed_abs(X[i])); #endif } } } // namespace template <> template <typename T> bool SoftsignFunctor<CUDAContext>:: operator()(const int N, const T* X, T* Y, CUDAContext* context) const { hipLaunchKernelGGL(( SoftsignCUDAKernel<T>) , dim3(CAFFE_GET_BLOCKS(N)), dim3(CAFFE_CUDA_NUM_THREADS), 0, context->cuda_stream(), N, X, Y); return true; } template <> template <typename T> bool SoftsignGradientFunctor<CUDAContext>::Forward( const std::vector<int>& X_dims, const std::vector<int>& /* dY_dims */, const T* X, const T* dY, T* dX, CUDAContext* context) const { const int size = std::accumulate( X_dims.cbegin(), X_dims.cend(), 1, std::multiplies<int>()); hipLaunchKernelGGL(( SoftsignGradientCUDAKernel<T>) , dim3(CAFFE_GET_BLOCKS(size)), dim3(CAFFE_CUDA_NUM_THREADS), 0, context->cuda_stream(), size, dY, X, dX); return true; } REGISTER_CUDA_OPERATOR( Softsign, UnaryElementwiseOp< TensorTypes<float>, CUDAContext, SoftsignFunctor<CUDAContext>>); REGISTER_CUDA_OPERATOR( SoftsignGradient, BinaryElementwiseOp< TensorTypes<float>, CUDAContext, SoftsignGradientFunctor<CUDAContext>>); } // namespace caffe2
e67dd6c893014bbdc0be7cf3d44f47762c2d385a.cu
#include "caffe2/operators/softsign_op.h" #include <algorithm> #include <functional> #include "caffe2/core/context_gpu.h" namespace caffe2 { namespace { template <typename T> inline __host__ __device__ T SquareCUDA(const T x) { return x * x; } template <typename T> inline __device__ T typed_abs(T x); template <> inline __device__ float typed_abs(float x) { return fabsf(x); } template <> inline __device__ double typed_abs(double x) { return fabs(x); } template <typename T> __global__ void SoftsignCUDAKernel(const int N, const T* X, T* Y) { CUDA_1D_KERNEL_LOOP(i, N) { #if __CUDA_ARCH__ >= 350 Y[i] = __ldg(X + i) / (T(1) + typed_abs(__ldg(X + i))); #else Y[i] = X[i] / (T(1) + typed_abs(X[i])); #endif } } template <typename T> __global__ void SoftsignGradientCUDAKernel(const int N, const T* dY, const T* X, T* dX) { CUDA_1D_KERNEL_LOOP(i, N) { #if __CUDA_ARCH__ >= 350 dX[i] = __ldg(dY + i) / SquareCUDA(T(1) + typed_abs(__ldg(X + i))); #else dX[i] = dY[i] / SquareCUDA(T(1) + typed_abs(X[i])); #endif } } } // namespace template <> template <typename T> bool SoftsignFunctor<CUDAContext>:: operator()(const int N, const T* X, T* Y, CUDAContext* context) const { SoftsignCUDAKernel<T> <<<CAFFE_GET_BLOCKS(N), CAFFE_CUDA_NUM_THREADS, 0, context->cuda_stream()>>>(N, X, Y); return true; } template <> template <typename T> bool SoftsignGradientFunctor<CUDAContext>::Forward( const std::vector<int>& X_dims, const std::vector<int>& /* dY_dims */, const T* X, const T* dY, T* dX, CUDAContext* context) const { const int size = std::accumulate( X_dims.cbegin(), X_dims.cend(), 1, std::multiplies<int>()); SoftsignGradientCUDAKernel<T> <<<CAFFE_GET_BLOCKS(size), CAFFE_CUDA_NUM_THREADS, 0, context->cuda_stream()>>>(size, dY, X, dX); return true; } REGISTER_CUDA_OPERATOR( Softsign, UnaryElementwiseOp< TensorTypes<float>, CUDAContext, SoftsignFunctor<CUDAContext>>); REGISTER_CUDA_OPERATOR( SoftsignGradient, BinaryElementwiseOp< TensorTypes<float>, CUDAContext, SoftsignGradientFunctor<CUDAContext>>); } // namespace caffe2
507675afa8544421478763ce29fc232dd24a67a1.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" /// /// Copyright (c) 2013, Intel Corporation /// Copyright (c) 2015, NVIDIA CORPORATION. /// /// Redistribution and use in source and binary forms, with or without /// modification, are permitted provided that the following conditions /// are met: /// /// * Redistributions of source code must retain the above copyright /// notice, this list of conditions and the following disclaimer. /// * Redistributions in binary form must reproduce the above /// copyright notice, this list of conditions and the following /// disclaimer in the documentation and/or other materials provided /// with the distribution. /// * Neither the name of Intel Corporation nor the names of its /// contributors may be used to endorse or promote products /// derived from this software without specific prior written /// permission. /// /// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS /// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT /// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS /// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE /// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, /// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, /// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; /// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER /// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT /// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN /// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE /// POSSIBILITY OF SUCH DAMAGE. ////////////////////////////////////////////////////////////////////// /// /// NAME: transpose /// /// PURPOSE: This program measures the time for the transpose of a /// column-major stored matrix into a row-major stored matrix. /// /// USAGE: Program input is the matrix order and the number of times to /// repeat the operation: /// /// transpose <matrix_size> <# iterations> [tile size] /// /// An optional parameter specifies the tile size used to divide the /// individual matrix blocks for improved cache and TLB performance. /// /// The output consists of diagnostics to make sure the /// transpose worked and timing statistics. /// /// HISTORY: Written by Rob Van der Wijngaart, February 2009. /// Converted to C++11 by Jeff Hammond, February 2016 and May 2017. /// ////////////////////////////////////////////////////////////////////// #include "prk_util.h" #include "prk_cuda.h" #define TILED 0 #if TILED // The kernel was derived from https://github.com/parallel-forall/code-samples/blob/master/series/cuda-cpp/transpose/transpose.cu, // which is the reason for the additional copyright noted above. const int tile_dim = 32; const int block_rows = 8; __global__ void transpose(int order, prk_float * A, prk_float * B) { auto x = blockIdx.x * tile_dim + threadIdx.x; auto y = blockIdx.y * tile_dim + threadIdx.y; auto width = gridDim.x * tile_dim; for (int j = 0; j < tile_dim; j+= block_rows) { B[x*width + (y+j)] += A[(y+j)*width + x]; A[(y+j)*width + x] += (prk_float)1; } } #else __global__ void transpose(unsigned order, prk_float * A, prk_float * B) { auto i = blockIdx.x * blockDim.x + threadIdx.x; auto j = blockIdx.y * blockDim.y + threadIdx.y; if ((i<order) && (j<order)) { B[i*order+j] += A[j*order+i]; A[j*order+i] += (prk_float)1; } } #endif int main(int argc, char * argv[]) { std::cout << "Parallel Research Kernels version " << PRKVERSION << std::endl; std::cout << "C++11/CUDA Matrix transpose: B = A^T" << std::endl; prk::CUDA::info info; info.print(); ////////////////////////////////////////////////////////////////////// // Read and test input parameters ////////////////////////////////////////////////////////////////////// int iterations; int order, tile_size; try { if (argc < 3) { throw "Usage: <# iterations> <matrix order>"; } iterations = std::atoi(argv[1]); if (iterations < 1) { throw "ERROR: iterations must be >= 1"; } order = std::atoi(argv[2]); if (order <= 0) { throw "ERROR: Matrix Order must be greater than 0"; } else if (order > prk::get_max_matrix_size()) { throw "ERROR: matrix dimension too large - overflow risk"; } #if TILED if (order % tile_dim != 0) { std::cout << "Sorry, but order (" << order << ") must be evenly divible by " << tile_dim << " or the results are going to be wrong.\n"; } #else // default tile size for tiling of local transpose tile_size = 32; if (argc > 3) { tile_size = std::atoi(argv[3]); if (tile_size <= 0) tile_size = order; if (tile_size > order) tile_size = order; if (tile_size > 32) { std::cout << "The results are probably going to be wrong; use tile_size<=32.\n"; } } #endif #ifdef __CORIANDERCC__ // This has not been analyzed, but it is an empirical fact. if (order > 1234) { std::cout << "The results are probably going to be wrong, because order>1234.\n"; } #endif } catch (const char * e) { std::cout << e << std::endl; return 1; } std::cout << "Number of iterations = " << iterations << std::endl; std::cout << "Matrix order = " << order << std::endl; #if TILED std::cout << "Tile size = " << tile_dim << std::endl; #else std::cout << "Tile size = " << tile_size << std::endl; #endif #if TILED dim3 dimGrid(order/tile_dim, order/tile_dim, 1); dim3 dimBlock(tile_dim, block_rows, 1); #else dim3 dimGrid(prk::divceil(order,tile_size),prk::divceil(order,tile_size),1); dim3 dimBlock(tile_size, tile_size, 1); #endif info.checkDims(dimBlock, dimGrid); ////////////////////////////////////////////////////////////////////// // Allocate space for the input and transpose matrix ////////////////////////////////////////////////////////////////////// const size_t nelems = (size_t)order * (size_t)order; const size_t bytes = nelems * sizeof(prk_float); prk_float * h_a; prk_float * h_b; #ifndef __CORIANDERCC__ prk::CUDA::check( hipHostMalloc((void**)&h_a, bytes) ); prk::CUDA::check( hipHostMalloc((void**)&h_b, bytes) ); #else h_a = new prk_float[nelems]; h_b = new prk_float[nelems]; #endif // fill A with the sequence 0 to order^2-1 for (int j=0; j<order; j++) { for (int i=0; i<order; i++) { h_a[j*order+i] = static_cast<prk_float>(order*j+i); h_b[j*order+i] = static_cast<prk_float>(0); } } // copy input from host to device prk_float * d_a; prk_float * d_b; prk::CUDA::check( hipMalloc((void**)&d_a, bytes) ); prk::CUDA::check( hipMalloc((void**)&d_b, bytes) ); prk::CUDA::check( hipMemcpy(d_a, &(h_a[0]), bytes, hipMemcpyHostToDevice) ); prk::CUDA::check( hipMemcpy(d_b, &(h_b[0]), bytes, hipMemcpyHostToDevice) ); double trans_time{0}; for (int iter = 0; iter<=iterations; iter++) { if (iter==1) trans_time = prk::wtime(); hipLaunchKernelGGL(( transpose), dim3(dimGrid), dim3(dimBlock), 0, 0, order, d_a, d_b); #ifndef __CORIANDERCC__ // silence "ignoring hipDeviceSynchronize for now" warning prk::CUDA::check( hipDeviceSynchronize() ); #endif } trans_time = prk::wtime() - trans_time; // copy output back to host prk::CUDA::check( hipMemcpy(&(h_b[0]), d_b, bytes, hipMemcpyDeviceToHost) ); #ifdef VERBOSE // copy input back to host - debug only prk::CUDA::check( hipMemcpy(&(h_a[0]), d_a, bytes, hipMemcpyDeviceToHost) ); #endif prk::CUDA::check( hipFree(d_b) ); prk::CUDA::check( hipFree(d_a) ); ////////////////////////////////////////////////////////////////////// /// Analyze and output results ////////////////////////////////////////////////////////////////////// const double addit = (iterations+1.) * (iterations/2.); double abserr(0); for (int j=0; j<order; j++) { for (int i=0; i<order; i++) { const size_t ij = (size_t)i*(size_t)order+(size_t)j; const size_t ji = (size_t)j*(size_t)order+(size_t)i; const double reference = static_cast<double>(ij)*(1.+iterations)+addit; abserr += prk::abs(h_b[ji] - reference); } } #ifdef VERBOSE std::cout << "Sum of absolute differences: " << abserr << std::endl; #endif #ifndef __CORIANDERCC__ prk::CUDA::check( hipHostFree(h_b) ); prk::CUDA::check( hipHostFree(h_a) ); #endif const auto epsilon = 1.0e-8; if (abserr < epsilon) { std::cout << "Solution validates" << std::endl; auto avgtime = trans_time/iterations; auto bytes = (size_t)order * (size_t)order * sizeof(prk_float); std::cout << "Rate (MB/s): " << 1.0e-6 * (2L*bytes)/avgtime << " Avg time (s): " << avgtime << std::endl; } else { #ifdef VERBOSE for (int i=0; i<order; i++) { for (int j=0; j<order; j++) { std::cout << "(" << i << "," << j << ") = " << h_a[i*order+j] << ", " << h_b[i*order+j] << "\n"; } } #endif std::cout << "ERROR: Aggregate squared error " << abserr << " exceeds threshold " << epsilon << std::endl; return 1; } return 0; }
507675afa8544421478763ce29fc232dd24a67a1.cu
/// /// Copyright (c) 2013, Intel Corporation /// Copyright (c) 2015, NVIDIA CORPORATION. /// /// Redistribution and use in source and binary forms, with or without /// modification, are permitted provided that the following conditions /// are met: /// /// * Redistributions of source code must retain the above copyright /// notice, this list of conditions and the following disclaimer. /// * Redistributions in binary form must reproduce the above /// copyright notice, this list of conditions and the following /// disclaimer in the documentation and/or other materials provided /// with the distribution. /// * Neither the name of Intel Corporation nor the names of its /// contributors may be used to endorse or promote products /// derived from this software without specific prior written /// permission. /// /// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS /// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT /// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS /// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE /// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, /// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, /// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; /// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER /// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT /// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN /// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE /// POSSIBILITY OF SUCH DAMAGE. ////////////////////////////////////////////////////////////////////// /// /// NAME: transpose /// /// PURPOSE: This program measures the time for the transpose of a /// column-major stored matrix into a row-major stored matrix. /// /// USAGE: Program input is the matrix order and the number of times to /// repeat the operation: /// /// transpose <matrix_size> <# iterations> [tile size] /// /// An optional parameter specifies the tile size used to divide the /// individual matrix blocks for improved cache and TLB performance. /// /// The output consists of diagnostics to make sure the /// transpose worked and timing statistics. /// /// HISTORY: Written by Rob Van der Wijngaart, February 2009. /// Converted to C++11 by Jeff Hammond, February 2016 and May 2017. /// ////////////////////////////////////////////////////////////////////// #include "prk_util.h" #include "prk_cuda.h" #define TILED 0 #if TILED // The kernel was derived from https://github.com/parallel-forall/code-samples/blob/master/series/cuda-cpp/transpose/transpose.cu, // which is the reason for the additional copyright noted above. const int tile_dim = 32; const int block_rows = 8; __global__ void transpose(int order, prk_float * A, prk_float * B) { auto x = blockIdx.x * tile_dim + threadIdx.x; auto y = blockIdx.y * tile_dim + threadIdx.y; auto width = gridDim.x * tile_dim; for (int j = 0; j < tile_dim; j+= block_rows) { B[x*width + (y+j)] += A[(y+j)*width + x]; A[(y+j)*width + x] += (prk_float)1; } } #else __global__ void transpose(unsigned order, prk_float * A, prk_float * B) { auto i = blockIdx.x * blockDim.x + threadIdx.x; auto j = blockIdx.y * blockDim.y + threadIdx.y; if ((i<order) && (j<order)) { B[i*order+j] += A[j*order+i]; A[j*order+i] += (prk_float)1; } } #endif int main(int argc, char * argv[]) { std::cout << "Parallel Research Kernels version " << PRKVERSION << std::endl; std::cout << "C++11/CUDA Matrix transpose: B = A^T" << std::endl; prk::CUDA::info info; info.print(); ////////////////////////////////////////////////////////////////////// // Read and test input parameters ////////////////////////////////////////////////////////////////////// int iterations; int order, tile_size; try { if (argc < 3) { throw "Usage: <# iterations> <matrix order>"; } iterations = std::atoi(argv[1]); if (iterations < 1) { throw "ERROR: iterations must be >= 1"; } order = std::atoi(argv[2]); if (order <= 0) { throw "ERROR: Matrix Order must be greater than 0"; } else if (order > prk::get_max_matrix_size()) { throw "ERROR: matrix dimension too large - overflow risk"; } #if TILED if (order % tile_dim != 0) { std::cout << "Sorry, but order (" << order << ") must be evenly divible by " << tile_dim << " or the results are going to be wrong.\n"; } #else // default tile size for tiling of local transpose tile_size = 32; if (argc > 3) { tile_size = std::atoi(argv[3]); if (tile_size <= 0) tile_size = order; if (tile_size > order) tile_size = order; if (tile_size > 32) { std::cout << "The results are probably going to be wrong; use tile_size<=32.\n"; } } #endif #ifdef __CORIANDERCC__ // This has not been analyzed, but it is an empirical fact. if (order > 1234) { std::cout << "The results are probably going to be wrong, because order>1234.\n"; } #endif } catch (const char * e) { std::cout << e << std::endl; return 1; } std::cout << "Number of iterations = " << iterations << std::endl; std::cout << "Matrix order = " << order << std::endl; #if TILED std::cout << "Tile size = " << tile_dim << std::endl; #else std::cout << "Tile size = " << tile_size << std::endl; #endif #if TILED dim3 dimGrid(order/tile_dim, order/tile_dim, 1); dim3 dimBlock(tile_dim, block_rows, 1); #else dim3 dimGrid(prk::divceil(order,tile_size),prk::divceil(order,tile_size),1); dim3 dimBlock(tile_size, tile_size, 1); #endif info.checkDims(dimBlock, dimGrid); ////////////////////////////////////////////////////////////////////// // Allocate space for the input and transpose matrix ////////////////////////////////////////////////////////////////////// const size_t nelems = (size_t)order * (size_t)order; const size_t bytes = nelems * sizeof(prk_float); prk_float * h_a; prk_float * h_b; #ifndef __CORIANDERCC__ prk::CUDA::check( cudaMallocHost((void**)&h_a, bytes) ); prk::CUDA::check( cudaMallocHost((void**)&h_b, bytes) ); #else h_a = new prk_float[nelems]; h_b = new prk_float[nelems]; #endif // fill A with the sequence 0 to order^2-1 for (int j=0; j<order; j++) { for (int i=0; i<order; i++) { h_a[j*order+i] = static_cast<prk_float>(order*j+i); h_b[j*order+i] = static_cast<prk_float>(0); } } // copy input from host to device prk_float * d_a; prk_float * d_b; prk::CUDA::check( cudaMalloc((void**)&d_a, bytes) ); prk::CUDA::check( cudaMalloc((void**)&d_b, bytes) ); prk::CUDA::check( cudaMemcpy(d_a, &(h_a[0]), bytes, cudaMemcpyHostToDevice) ); prk::CUDA::check( cudaMemcpy(d_b, &(h_b[0]), bytes, cudaMemcpyHostToDevice) ); double trans_time{0}; for (int iter = 0; iter<=iterations; iter++) { if (iter==1) trans_time = prk::wtime(); transpose<<<dimGrid, dimBlock>>>(order, d_a, d_b); #ifndef __CORIANDERCC__ // silence "ignoring cudaDeviceSynchronize for now" warning prk::CUDA::check( cudaDeviceSynchronize() ); #endif } trans_time = prk::wtime() - trans_time; // copy output back to host prk::CUDA::check( cudaMemcpy(&(h_b[0]), d_b, bytes, cudaMemcpyDeviceToHost) ); #ifdef VERBOSE // copy input back to host - debug only prk::CUDA::check( cudaMemcpy(&(h_a[0]), d_a, bytes, cudaMemcpyDeviceToHost) ); #endif prk::CUDA::check( cudaFree(d_b) ); prk::CUDA::check( cudaFree(d_a) ); ////////////////////////////////////////////////////////////////////// /// Analyze and output results ////////////////////////////////////////////////////////////////////// const double addit = (iterations+1.) * (iterations/2.); double abserr(0); for (int j=0; j<order; j++) { for (int i=0; i<order; i++) { const size_t ij = (size_t)i*(size_t)order+(size_t)j; const size_t ji = (size_t)j*(size_t)order+(size_t)i; const double reference = static_cast<double>(ij)*(1.+iterations)+addit; abserr += prk::abs(h_b[ji] - reference); } } #ifdef VERBOSE std::cout << "Sum of absolute differences: " << abserr << std::endl; #endif #ifndef __CORIANDERCC__ prk::CUDA::check( cudaFreeHost(h_b) ); prk::CUDA::check( cudaFreeHost(h_a) ); #endif const auto epsilon = 1.0e-8; if (abserr < epsilon) { std::cout << "Solution validates" << std::endl; auto avgtime = trans_time/iterations; auto bytes = (size_t)order * (size_t)order * sizeof(prk_float); std::cout << "Rate (MB/s): " << 1.0e-6 * (2L*bytes)/avgtime << " Avg time (s): " << avgtime << std::endl; } else { #ifdef VERBOSE for (int i=0; i<order; i++) { for (int j=0; j<order; j++) { std::cout << "(" << i << "," << j << ") = " << h_a[i*order+j] << ", " << h_b[i*order+j] << "\n"; } } #endif std::cout << "ERROR: Aggregate squared error " << abserr << " exceeds threshold " << epsilon << std::endl; return 1; } return 0; }
960efde66d46ab1c20e7467109083980e47702c1.hip
// !!! This is a file automatically generated by hipify!!! #include <ATen/ATen.h> #include <ATen/hip/HIPContext.h> #include <THH/THHGeneral.h> #include <THH/THHThrustAllocator.cuh> #include <thrust/execution_policy.h> #include <tuple> #include <iterator> #include <thrust/unique.h> #include <thrust/sort.h> #include <thrust/scan.h> #include <thrust/scatter.h> namespace at { namespace native{ namespace { template < typename policy_t, typename scalar_t, typename equal_t, typename not_equal_t > std::tuple<Tensor, Tensor, int64_t> compute_unique( const policy_t &policy, scalar_t *data, int64_t num_inp, const Tensor &sorted_indices, const bool return_inverse, const bool return_counts, TensorOptions options, equal_t equal, not_equal_t not_equal ) { // inverse indices Tensor inverse_indices; if (!return_inverse) { inverse_indices = at::empty({0}, options); } else { TORCH_CHECK(sorted_indices.defined(), "return_inverse is set to true, but sorted_indices is undefined. Send a bug report!"); const int64_t *sorted_indices_ptr = sorted_indices.data<int64_t>(); Tensor inv_loc = at::empty({num_inp}, options); inverse_indices = at::empty({num_inp}, options); int64_t* inv_loc_ptr = inv_loc.data<int64_t>(); int64_t* inverse_indices_ptr = inverse_indices.data<int64_t>(); thrust::adjacent_difference(policy, data, data + num_inp, inv_loc_ptr, not_equal); inv_loc[0] = 0; thrust::inclusive_scan(policy, inv_loc_ptr, inv_loc_ptr + num_inp, inv_loc_ptr); thrust::scatter(policy, inv_loc_ptr, inv_loc_ptr + num_inp, sorted_indices_ptr, inverse_indices_ptr); } // unique and count Tensor counts = at::empty({0}, options); int64_t num_out; if (!return_counts) { num_out = thrust::unique(policy, data, data + num_inp, equal) - data; } else { Tensor range = at::arange(0, num_inp + 1, options); int64_t *range_ptr = range.data<int64_t>(); num_out = thrust::unique_by_key(policy, data, data + num_inp, range_ptr, equal).first - data; range[num_out] = num_inp; counts.resize_(num_out); int64_t* counts_ptr = counts.data<int64_t>(); thrust::adjacent_difference(policy, range_ptr + 1, range_ptr + num_out + 1, counts_ptr); } THCudaCheck(hipGetLastError()); return std::tuple<Tensor, Tensor, int64_t>(inverse_indices, counts, num_out); } template <typename scalar_t> std::tuple<Tensor, Tensor, Tensor> unique_cuda_template( const Tensor& self, const bool consecutive, const bool return_inverse, const bool return_counts ) { hipStream_t stream = at::hip::getCurrentHIPStreamMasqueradingAsCUDA(); auto allocator = THCThrustAllocator(globalContext().lazyInitCUDA()); auto policy = thrust::hip::par(allocator).on(stream); auto options = self.options().dtype(kLong); Tensor output = self.clone().reshape(-1); int64_t num_inp = output.numel(); scalar_t* output_data = output.data<scalar_t>(); Tensor sorted_indices; if (!return_inverse) { if (!consecutive) { thrust::sort(policy, output_data, output_data + num_inp); } } else { sorted_indices = at::arange(0, num_inp, options); if (!consecutive) { int64_t *sorted_indices_ptr = sorted_indices.data<int64_t>(); thrust::sort_by_key(policy, output_data, output_data + num_inp, sorted_indices_ptr); } } Tensor inverse_indices, counts; int64_t num_out; std::tie(inverse_indices, counts, num_out) = compute_unique( policy, output_data, num_inp, sorted_indices, return_inverse, return_counts, options, thrust::equal_to<scalar_t>(), thrust::not_equal_to<scalar_t>() ); output.resize_(num_out); if (return_inverse) { inverse_indices.resize_(self.sizes()); } return std::tuple<Tensor, Tensor, Tensor>(output, inverse_indices, counts); } template <typename scalar_t> std::tuple<Tensor, Tensor, Tensor> unique_dim_cuda_template( const Tensor& self, const int64_t dim, const bool consecutive, const bool return_inverse, const bool return_counts ) { /** * The idea for implementing this is basically the same as unique. * For unique_dim, we are taking the unique with respect to a index * tensor, but during the processes, we override the compare and equal * operator by checking the data underlying it instead. After the * algorithm, we would use index_select to map the resulting indicies * to the result on the actual data. */ hipStream_t stream = at::hip::getCurrentHIPStreamMasqueradingAsCUDA(); auto allocator = THCThrustAllocator(globalContext().lazyInitCUDA()); auto policy = thrust::hip::par(allocator).on(stream); auto sizes = self.sizes().vec(); // check how many zero dimensions exist auto num_zero_dims = std::count(sizes.begin(), sizes.end(), 0); // tensor is not well formed as it has 0 sized dimensions if (self.size(dim) == 0){ AT_CHECK( num_zero_dims == 1, "Number of zero sized dimensions is more than one, so unique cannot be applied ") Tensor output = at::empty({0}, self.options()); Tensor inverse_indices = at::empty({0}, self.options().dtype(kLong)); Tensor counts = at::empty({0}, self.options().dtype(kLong)); return std::make_tuple(output, inverse_indices, counts); } AT_CHECK(num_zero_dims == 0, "There are 0 sized dimensions, and they aren't selected, so unique cannot be applied"); int64_t num_inp = self.size(dim); auto options = self.options().dtype(kLong); Tensor input_flat = self.transpose(dim, 0).contiguous().view({num_inp, -1}); int64_t n = input_flat.size(1); scalar_t *input_flat_ptr = input_flat.data<scalar_t>(); Tensor indices = at::arange(0, num_inp, options); int64_t *indices_data = indices.data<int64_t>(); if (!consecutive) { thrust::sort(policy, indices_data, indices_data + num_inp, [=] __device__ (int64_t a, int64_t b) -> bool { for (int64_t i = 0; i < n; ++i) { scalar_t lhs = input_flat_ptr[i + a * n]; scalar_t rhs = input_flat_ptr[i + b * n]; if (lhs < rhs) { return true; } else if (lhs > rhs) { return false; } } return false; } ); } Tensor inverse_indices, counts; int64_t num_out; std::tie(inverse_indices, counts, num_out) = compute_unique( policy, indices_data, num_inp, indices, return_inverse, return_counts, options, [=] __device__ (int64_t a, int64_t b) -> bool { for (int64_t i = 0; i < n; ++i) { scalar_t lhs = input_flat_ptr[i + a * n]; scalar_t rhs = input_flat_ptr[i + b * n]; if (lhs != rhs) { return false; } } return true; }, [=] __device__ (int64_t a, int64_t b) -> int64_t { for (int64_t i = 0; i < n; ++i) { scalar_t lhs = input_flat_ptr[i + a * n]; scalar_t rhs = input_flat_ptr[i + b * n]; if (lhs != rhs) { return 1; } } return 0; } ); indices.resize_(num_out); return std::tuple<Tensor, Tensor, Tensor>(self.index_select(dim, indices), inverse_indices, counts); } } // namespace std::tuple<Tensor, Tensor> _unique_cuda(const Tensor& self, const bool sorted, const bool return_inverse) { return AT_DISPATCH_ALL_TYPES(self.scalar_type(), "unique", [&] { // The current CUDA implementation of unique always sort due to the // lack of hashtable implementation in thrust Tensor output, inverse; std::tie(output, inverse, std::ignore) = unique_cuda_template<scalar_t>(self, false, return_inverse, false); return std::make_tuple(output, inverse); }); } std::tuple<Tensor, Tensor, Tensor> _unique2_cuda(const Tensor& self, const bool sorted, const bool return_inverse, const bool return_counts) { return AT_DISPATCH_ALL_TYPES(self.scalar_type(), "unique", [&] { // The current CUDA implementation of unique always sort due to the // lack of hashtable implementation in thrust return unique_cuda_template<scalar_t>(self, false, return_inverse, return_counts); }); } std::tuple<Tensor, Tensor, Tensor> unique_dim_cuda(const Tensor& self, const int64_t dim, const bool sorted, const bool return_inverse, const bool return_counts) { return AT_DISPATCH_ALL_TYPES(self.scalar_type(), "unique_dim", [&] { return unique_dim_cuda_template<scalar_t>(self, dim, false, return_inverse, return_counts); }); } std::tuple<Tensor, Tensor, Tensor> unique_dim_consecutive_cuda(const Tensor& self, const int64_t dim, const bool return_inverse, const bool return_counts) { return AT_DISPATCH_ALL_TYPES(self.scalar_type(), "unique_dim", [&] { return unique_dim_cuda_template<scalar_t>(self, dim, true, return_inverse, return_counts); }); } std::tuple<Tensor, Tensor, Tensor> unique_consecutive_cuda(const Tensor& self, const bool return_inverse, const bool return_counts, c10::optional<int64_t> dim) { if (!dim.has_value()) { return AT_DISPATCH_ALL_TYPES(self.scalar_type(), "unique", [&] { // The current CUDA implementation of unique always sort due to the // lack of hashtable implementation in thrust return unique_cuda_template<scalar_t>(self, true, return_inverse, return_counts); }); } return unique_dim_consecutive_cuda(self, dim.value(), return_inverse, return_counts); } } // namespace native } // namespace at
960efde66d46ab1c20e7467109083980e47702c1.cu
#include <ATen/ATen.h> #include <ATen/cuda/CUDAContext.h> #include <THC/THCGeneral.h> #include <THC/THCThrustAllocator.cuh> #include <thrust/execution_policy.h> #include <tuple> #include <iterator> #include <thrust/unique.h> #include <thrust/sort.h> #include <thrust/scan.h> #include <thrust/scatter.h> namespace at { namespace native{ namespace { template < typename policy_t, typename scalar_t, typename equal_t, typename not_equal_t > std::tuple<Tensor, Tensor, int64_t> compute_unique( const policy_t &policy, scalar_t *data, int64_t num_inp, const Tensor &sorted_indices, const bool return_inverse, const bool return_counts, TensorOptions options, equal_t equal, not_equal_t not_equal ) { // inverse indices Tensor inverse_indices; if (!return_inverse) { inverse_indices = at::empty({0}, options); } else { TORCH_CHECK(sorted_indices.defined(), "return_inverse is set to true, but sorted_indices is undefined. Send a bug report!"); const int64_t *sorted_indices_ptr = sorted_indices.data<int64_t>(); Tensor inv_loc = at::empty({num_inp}, options); inverse_indices = at::empty({num_inp}, options); int64_t* inv_loc_ptr = inv_loc.data<int64_t>(); int64_t* inverse_indices_ptr = inverse_indices.data<int64_t>(); thrust::adjacent_difference(policy, data, data + num_inp, inv_loc_ptr, not_equal); inv_loc[0] = 0; thrust::inclusive_scan(policy, inv_loc_ptr, inv_loc_ptr + num_inp, inv_loc_ptr); thrust::scatter(policy, inv_loc_ptr, inv_loc_ptr + num_inp, sorted_indices_ptr, inverse_indices_ptr); } // unique and count Tensor counts = at::empty({0}, options); int64_t num_out; if (!return_counts) { num_out = thrust::unique(policy, data, data + num_inp, equal) - data; } else { Tensor range = at::arange(0, num_inp + 1, options); int64_t *range_ptr = range.data<int64_t>(); num_out = thrust::unique_by_key(policy, data, data + num_inp, range_ptr, equal).first - data; range[num_out] = num_inp; counts.resize_(num_out); int64_t* counts_ptr = counts.data<int64_t>(); thrust::adjacent_difference(policy, range_ptr + 1, range_ptr + num_out + 1, counts_ptr); } THCudaCheck(cudaGetLastError()); return std::tuple<Tensor, Tensor, int64_t>(inverse_indices, counts, num_out); } template <typename scalar_t> std::tuple<Tensor, Tensor, Tensor> unique_cuda_template( const Tensor& self, const bool consecutive, const bool return_inverse, const bool return_counts ) { cudaStream_t stream = at::cuda::getCurrentCUDAStream(); auto allocator = THCThrustAllocator(globalContext().lazyInitCUDA()); auto policy = thrust::cuda::par(allocator).on(stream); auto options = self.options().dtype(kLong); Tensor output = self.clone().reshape(-1); int64_t num_inp = output.numel(); scalar_t* output_data = output.data<scalar_t>(); Tensor sorted_indices; if (!return_inverse) { if (!consecutive) { thrust::sort(policy, output_data, output_data + num_inp); } } else { sorted_indices = at::arange(0, num_inp, options); if (!consecutive) { int64_t *sorted_indices_ptr = sorted_indices.data<int64_t>(); thrust::sort_by_key(policy, output_data, output_data + num_inp, sorted_indices_ptr); } } Tensor inverse_indices, counts; int64_t num_out; std::tie(inverse_indices, counts, num_out) = compute_unique( policy, output_data, num_inp, sorted_indices, return_inverse, return_counts, options, thrust::equal_to<scalar_t>(), thrust::not_equal_to<scalar_t>() ); output.resize_(num_out); if (return_inverse) { inverse_indices.resize_(self.sizes()); } return std::tuple<Tensor, Tensor, Tensor>(output, inverse_indices, counts); } template <typename scalar_t> std::tuple<Tensor, Tensor, Tensor> unique_dim_cuda_template( const Tensor& self, const int64_t dim, const bool consecutive, const bool return_inverse, const bool return_counts ) { /** * The idea for implementing this is basically the same as unique. * For unique_dim, we are taking the unique with respect to a index * tensor, but during the processes, we override the compare and equal * operator by checking the data underlying it instead. After the * algorithm, we would use index_select to map the resulting indicies * to the result on the actual data. */ cudaStream_t stream = at::cuda::getCurrentCUDAStream(); auto allocator = THCThrustAllocator(globalContext().lazyInitCUDA()); auto policy = thrust::cuda::par(allocator).on(stream); auto sizes = self.sizes().vec(); // check how many zero dimensions exist auto num_zero_dims = std::count(sizes.begin(), sizes.end(), 0); // tensor is not well formed as it has 0 sized dimensions if (self.size(dim) == 0){ AT_CHECK( num_zero_dims == 1, "Number of zero sized dimensions is more than one, so unique cannot be applied ") Tensor output = at::empty({0}, self.options()); Tensor inverse_indices = at::empty({0}, self.options().dtype(kLong)); Tensor counts = at::empty({0}, self.options().dtype(kLong)); return std::make_tuple(output, inverse_indices, counts); } AT_CHECK(num_zero_dims == 0, "There are 0 sized dimensions, and they aren't selected, so unique cannot be applied"); int64_t num_inp = self.size(dim); auto options = self.options().dtype(kLong); Tensor input_flat = self.transpose(dim, 0).contiguous().view({num_inp, -1}); int64_t n = input_flat.size(1); scalar_t *input_flat_ptr = input_flat.data<scalar_t>(); Tensor indices = at::arange(0, num_inp, options); int64_t *indices_data = indices.data<int64_t>(); if (!consecutive) { thrust::sort(policy, indices_data, indices_data + num_inp, [=] __device__ (int64_t a, int64_t b) -> bool { for (int64_t i = 0; i < n; ++i) { scalar_t lhs = input_flat_ptr[i + a * n]; scalar_t rhs = input_flat_ptr[i + b * n]; if (lhs < rhs) { return true; } else if (lhs > rhs) { return false; } } return false; } ); } Tensor inverse_indices, counts; int64_t num_out; std::tie(inverse_indices, counts, num_out) = compute_unique( policy, indices_data, num_inp, indices, return_inverse, return_counts, options, [=] __device__ (int64_t a, int64_t b) -> bool { for (int64_t i = 0; i < n; ++i) { scalar_t lhs = input_flat_ptr[i + a * n]; scalar_t rhs = input_flat_ptr[i + b * n]; if (lhs != rhs) { return false; } } return true; }, [=] __device__ (int64_t a, int64_t b) -> int64_t { for (int64_t i = 0; i < n; ++i) { scalar_t lhs = input_flat_ptr[i + a * n]; scalar_t rhs = input_flat_ptr[i + b * n]; if (lhs != rhs) { return 1; } } return 0; } ); indices.resize_(num_out); return std::tuple<Tensor, Tensor, Tensor>(self.index_select(dim, indices), inverse_indices, counts); } } // namespace std::tuple<Tensor, Tensor> _unique_cuda(const Tensor& self, const bool sorted, const bool return_inverse) { return AT_DISPATCH_ALL_TYPES(self.scalar_type(), "unique", [&] { // The current CUDA implementation of unique always sort due to the // lack of hashtable implementation in thrust Tensor output, inverse; std::tie(output, inverse, std::ignore) = unique_cuda_template<scalar_t>(self, false, return_inverse, false); return std::make_tuple(output, inverse); }); } std::tuple<Tensor, Tensor, Tensor> _unique2_cuda(const Tensor& self, const bool sorted, const bool return_inverse, const bool return_counts) { return AT_DISPATCH_ALL_TYPES(self.scalar_type(), "unique", [&] { // The current CUDA implementation of unique always sort due to the // lack of hashtable implementation in thrust return unique_cuda_template<scalar_t>(self, false, return_inverse, return_counts); }); } std::tuple<Tensor, Tensor, Tensor> unique_dim_cuda(const Tensor& self, const int64_t dim, const bool sorted, const bool return_inverse, const bool return_counts) { return AT_DISPATCH_ALL_TYPES(self.scalar_type(), "unique_dim", [&] { return unique_dim_cuda_template<scalar_t>(self, dim, false, return_inverse, return_counts); }); } std::tuple<Tensor, Tensor, Tensor> unique_dim_consecutive_cuda(const Tensor& self, const int64_t dim, const bool return_inverse, const bool return_counts) { return AT_DISPATCH_ALL_TYPES(self.scalar_type(), "unique_dim", [&] { return unique_dim_cuda_template<scalar_t>(self, dim, true, return_inverse, return_counts); }); } std::tuple<Tensor, Tensor, Tensor> unique_consecutive_cuda(const Tensor& self, const bool return_inverse, const bool return_counts, c10::optional<int64_t> dim) { if (!dim.has_value()) { return AT_DISPATCH_ALL_TYPES(self.scalar_type(), "unique", [&] { // The current CUDA implementation of unique always sort due to the // lack of hashtable implementation in thrust return unique_cuda_template<scalar_t>(self, true, return_inverse, return_counts); }); } return unique_dim_consecutive_cuda(self, dim.value(), return_inverse, return_counts); } } // namespace native } // namespace at
9f3437703e20c74f509d7ee3205fb73b3ae3b3ef.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include "includes.h" __global__ void cudaDSoftplus_backPropagate_kernel(double* x, double* dx, unsigned int size) { const unsigned int index = blockIdx.x * blockDim.x + threadIdx.x; const unsigned int stride = blockDim.x * gridDim.x; for (unsigned int i = index; i < size; i += stride) { dx[i] *= (1.0 - exp(-x[i])); } }
9f3437703e20c74f509d7ee3205fb73b3ae3b3ef.cu
#include "includes.h" __global__ void cudaDSoftplus_backPropagate_kernel(double* x, double* dx, unsigned int size) { const unsigned int index = blockIdx.x * blockDim.x + threadIdx.x; const unsigned int stride = blockDim.x * gridDim.x; for (unsigned int i = index; i < size; i += stride) { dx[i] *= (1.0 - exp(-x[i])); } }
e39ddb193011f7cad7dddbb9cdd23775e3023be1.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include <stdio.h> #include <stdlib.h> #include <assert.h> #include <sys/time.h> #include <time.h> #include "diff_ms.h" // #define TIME_MEM_TRANS 1 /* 2048 20*/ /* 4096 21*/ /* 8192 22*/ /* 16384 23*/ /* 32768 24*/ #define BLOCKS 32768 #define LARGE_SIZE BLOCKS*SMALL_SIZE #define SMALL_SIZE 512 #define THREADS 256 #define LOG_SMALL_SIZE 9 #define LOG_LARGE_SIZE 24 //* kernel for sorting small fixed size arrays all on the GPU #define NUM 512 __device__ inline void swap(int & a, int & b) { // Alternative swap doesn't use a temporary register: // a ^= b; // b ^= a; // a ^= b; int tmp = a; a = b; b = tmp; } __global__ static void bitonicSort(int * values, int *results) { extern __shared__ int shared[]; const unsigned int tid = threadIdx.x; const unsigned int bid = blockIdx.x; // Copy input to shared mem. shared[tid] = values[(bid*NUM) + tid]; __syncthreads(); // Parallel bitonic sort. for (unsigned int k = 2; k <= NUM; k *= 2) { // Bitonic merge: for (unsigned int j = k / 2; j>0; j /= 2) { unsigned int ixj = tid ^ j; if (ixj > tid) { if ((tid & k) == 0) { if (shared[tid] > shared[ixj]) { swap(shared[tid], shared[ixj]); } } else { if (shared[tid] < shared[ixj]) { swap(shared[tid], shared[ixj]); } } } __syncthreads(); } } // Write result. results[(bid*NUM) + tid] = shared[tid]; } /* -------------------------------------------------------------------------- tsortSmall -------------------------------------------------------------------------- */ __global__ void tsortSmall(int *input0,int *result0){ unsigned int tid = threadIdx.x; unsigned int bid = blockIdx.x; extern __shared__ unsigned char sbase[]; (( int *)sbase)[(tid<<1)] = min(input0[((bid*512)+(tid<<1))],input0[((bid*512)+((tid<<1)^1))]); (( int *)sbase)[((tid<<1)^1)] = max(input0[((bid*512)+(tid<<1))],input0[((bid*512)+((tid<<1)^1))]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967294))] = min((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^3)]); (( int *)(sbase + 2048))[((tid+(tid&4294967294))^3)] = max((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^3)]); __syncthreads(); (( int *)sbase)[(tid<<1)] = min((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); (( int *)sbase)[((tid<<1)^1)] = max((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967292))] = min((( int *)sbase)[(tid+(tid&4294967292))],(( int *)sbase)[((tid+(tid&4294967292))^7)]); (( int *)(sbase + 2048))[((tid+(tid&4294967292))^7)] = max((( int *)sbase)[(tid+(tid&4294967292))],(( int *)sbase)[((tid+(tid&4294967292))^7)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967294))] = min((( int *)(sbase+2048))[(tid+(tid&4294967294))],(( int *)(sbase+2048))[((tid+(tid&4294967294))^2)]); (( int *)sbase)[((tid+(tid&4294967294))^2)] = max((( int *)(sbase+2048))[(tid+(tid&4294967294))],(( int *)(sbase+2048))[((tid+(tid&4294967294))^2)]); __syncthreads(); (( int *)(sbase + 2048))[(tid<<1)] = min((( int *)sbase)[(tid<<1)],(( int *)sbase)[((tid<<1)^1)]); (( int *)(sbase + 2048))[((tid<<1)^1)] = max((( int *)sbase)[(tid<<1)],(( int *)sbase)[((tid<<1)^1)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967288))] = min((( int *)(sbase+2048))[(tid+(tid&4294967288))],(( int *)(sbase+2048))[((tid+(tid&4294967288))^15)]); (( int *)sbase)[((tid+(tid&4294967288))^15)] = max((( int *)(sbase+2048))[(tid+(tid&4294967288))],(( int *)(sbase+2048))[((tid+(tid&4294967288))^15)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967292))] = min((( int *)sbase)[(tid+(tid&4294967292))],(( int *)sbase)[((tid+(tid&4294967292))^4)]); (( int *)(sbase + 2048))[((tid+(tid&4294967292))^4)] = max((( int *)sbase)[(tid+(tid&4294967292))],(( int *)sbase)[((tid+(tid&4294967292))^4)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967294))] = min((( int *)(sbase+2048))[(tid+(tid&4294967294))],(( int *)(sbase+2048))[((tid+(tid&4294967294))^2)]); (( int *)sbase)[((tid+(tid&4294967294))^2)] = max((( int *)(sbase+2048))[(tid+(tid&4294967294))],(( int *)(sbase+2048))[((tid+(tid&4294967294))^2)]); __syncthreads(); (( int *)(sbase + 2048))[(tid<<1)] = min((( int *)sbase)[(tid<<1)],(( int *)sbase)[((tid<<1)^1)]); (( int *)(sbase + 2048))[((tid<<1)^1)] = max((( int *)sbase)[(tid<<1)],(( int *)sbase)[((tid<<1)^1)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967280))] = min((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^31)]); (( int *)sbase)[((tid+(tid&4294967280))^31)] = max((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^31)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967288))] = min((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^8)]); (( int *)(sbase + 2048))[((tid+(tid&4294967288))^8)] = max((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^8)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967292))] = min((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^4)]); (( int *)sbase)[((tid+(tid&4294967292))^4)] = max((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^4)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967294))] = min((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^2)]); (( int *)(sbase + 2048))[((tid+(tid&4294967294))^2)] = max((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^2)]); __syncthreads(); (( int *)sbase)[(tid<<1)] = min((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); (( int *)sbase)[((tid<<1)^1)] = max((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967264))] = min((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^63)]); (( int *)(sbase + 2048))[((tid+(tid&4294967264))^63)] = max((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^63)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967280))] = min((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^16)]); (( int *)sbase)[((tid+(tid&4294967280))^16)] = max((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^16)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967288))] = min((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^8)]); (( int *)(sbase + 2048))[((tid+(tid&4294967288))^8)] = max((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^8)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967292))] = min((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^4)]); (( int *)sbase)[((tid+(tid&4294967292))^4)] = max((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^4)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967294))] = min((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^2)]); (( int *)(sbase + 2048))[((tid+(tid&4294967294))^2)] = max((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^2)]); __syncthreads(); (( int *)sbase)[(tid<<1)] = min((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); (( int *)sbase)[((tid<<1)^1)] = max((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967232))] = min((( int *)sbase)[(tid+(tid&4294967232))],(( int *)sbase)[((tid+(tid&4294967232))^127)]); (( int *)(sbase + 2048))[((tid+(tid&4294967232))^127)] = max((( int *)sbase)[(tid+(tid&4294967232))],(( int *)sbase)[((tid+(tid&4294967232))^127)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967264))] = min((( int *)(sbase+2048))[(tid+(tid&4294967264))],(( int *)(sbase+2048))[((tid+(tid&4294967264))^32)]); (( int *)sbase)[((tid+(tid&4294967264))^32)] = max((( int *)(sbase+2048))[(tid+(tid&4294967264))],(( int *)(sbase+2048))[((tid+(tid&4294967264))^32)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967280))] = min((( int *)sbase)[(tid+(tid&4294967280))],(( int *)sbase)[((tid+(tid&4294967280))^16)]); (( int *)(sbase + 2048))[((tid+(tid&4294967280))^16)] = max((( int *)sbase)[(tid+(tid&4294967280))],(( int *)sbase)[((tid+(tid&4294967280))^16)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967288))] = min((( int *)(sbase+2048))[(tid+(tid&4294967288))],(( int *)(sbase+2048))[((tid+(tid&4294967288))^8)]); (( int *)sbase)[((tid+(tid&4294967288))^8)] = max((( int *)(sbase+2048))[(tid+(tid&4294967288))],(( int *)(sbase+2048))[((tid+(tid&4294967288))^8)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967292))] = min((( int *)sbase)[(tid+(tid&4294967292))],(( int *)sbase)[((tid+(tid&4294967292))^4)]); (( int *)(sbase + 2048))[((tid+(tid&4294967292))^4)] = max((( int *)sbase)[(tid+(tid&4294967292))],(( int *)sbase)[((tid+(tid&4294967292))^4)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967294))] = min((( int *)(sbase+2048))[(tid+(tid&4294967294))],(( int *)(sbase+2048))[((tid+(tid&4294967294))^2)]); (( int *)sbase)[((tid+(tid&4294967294))^2)] = max((( int *)(sbase+2048))[(tid+(tid&4294967294))],(( int *)(sbase+2048))[((tid+(tid&4294967294))^2)]); __syncthreads(); (( int *)(sbase + 2048))[(tid<<1)] = min((( int *)sbase)[(tid<<1)],(( int *)sbase)[((tid<<1)^1)]); (( int *)(sbase + 2048))[((tid<<1)^1)] = max((( int *)sbase)[(tid<<1)],(( int *)sbase)[((tid<<1)^1)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967168))] = min((( int *)(sbase+2048))[(tid+(tid&4294967168))],(( int *)(sbase+2048))[((tid+(tid&4294967168))^255)]); (( int *)sbase)[((tid+(tid&4294967168))^255)] = max((( int *)(sbase+2048))[(tid+(tid&4294967168))],(( int *)(sbase+2048))[((tid+(tid&4294967168))^255)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967232))] = min((( int *)sbase)[(tid+(tid&4294967232))],(( int *)sbase)[((tid+(tid&4294967232))^64)]); (( int *)(sbase + 2048))[((tid+(tid&4294967232))^64)] = max((( int *)sbase)[(tid+(tid&4294967232))],(( int *)sbase)[((tid+(tid&4294967232))^64)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967264))] = min((( int *)(sbase+2048))[(tid+(tid&4294967264))],(( int *)(sbase+2048))[((tid+(tid&4294967264))^32)]); (( int *)sbase)[((tid+(tid&4294967264))^32)] = max((( int *)(sbase+2048))[(tid+(tid&4294967264))],(( int *)(sbase+2048))[((tid+(tid&4294967264))^32)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967280))] = min((( int *)sbase)[(tid+(tid&4294967280))],(( int *)sbase)[((tid+(tid&4294967280))^16)]); (( int *)(sbase + 2048))[((tid+(tid&4294967280))^16)] = max((( int *)sbase)[(tid+(tid&4294967280))],(( int *)sbase)[((tid+(tid&4294967280))^16)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967288))] = min((( int *)(sbase+2048))[(tid+(tid&4294967288))],(( int *)(sbase+2048))[((tid+(tid&4294967288))^8)]); (( int *)sbase)[((tid+(tid&4294967288))^8)] = max((( int *)(sbase+2048))[(tid+(tid&4294967288))],(( int *)(sbase+2048))[((tid+(tid&4294967288))^8)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967292))] = min((( int *)sbase)[(tid+(tid&4294967292))],(( int *)sbase)[((tid+(tid&4294967292))^4)]); (( int *)(sbase + 2048))[((tid+(tid&4294967292))^4)] = max((( int *)sbase)[(tid+(tid&4294967292))],(( int *)sbase)[((tid+(tid&4294967292))^4)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967294))] = min((( int *)(sbase+2048))[(tid+(tid&4294967294))],(( int *)(sbase+2048))[((tid+(tid&4294967294))^2)]); (( int *)sbase)[((tid+(tid&4294967294))^2)] = max((( int *)(sbase+2048))[(tid+(tid&4294967294))],(( int *)(sbase+2048))[((tid+(tid&4294967294))^2)]); __syncthreads(); (( int *)(sbase + 2048))[(tid<<1)] = min((( int *)sbase)[(tid<<1)],(( int *)sbase)[((tid<<1)^1)]); (( int *)(sbase + 2048))[((tid<<1)^1)] = max((( int *)sbase)[(tid<<1)],(( int *)sbase)[((tid<<1)^1)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967040))] = min((( int *)(sbase+2048))[(tid+(tid&4294967040))],(( int *)(sbase+2048))[((tid+(tid&4294967040))^511)]); (( int *)sbase)[((tid+(tid&4294967040))^511)] = max((( int *)(sbase+2048))[(tid+(tid&4294967040))],(( int *)(sbase+2048))[((tid+(tid&4294967040))^511)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967168))] = min((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^128)]); (( int *)(sbase + 2048))[((tid+(tid&4294967168))^128)] = max((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^128)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967232))] = min((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^64)]); (( int *)sbase)[((tid+(tid&4294967232))^64)] = max((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^64)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967264))] = min((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^32)]); (( int *)(sbase + 2048))[((tid+(tid&4294967264))^32)] = max((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^32)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967280))] = min((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^16)]); (( int *)sbase)[((tid+(tid&4294967280))^16)] = max((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^16)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967288))] = min((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^8)]); (( int *)(sbase + 2048))[((tid+(tid&4294967288))^8)] = max((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^8)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967292))] = min((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^4)]); (( int *)sbase)[((tid+(tid&4294967292))^4)] = max((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^4)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967294))] = min((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^2)]); (( int *)(sbase + 2048))[((tid+(tid&4294967294))^2)] = max((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^2)]); __syncthreads(); (( int *)sbase)[(tid<<1)] = min((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); (( int *)sbase)[((tid<<1)^1)] = max((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); __syncthreads(); result0[((bid*512)+tid)] = (( int *)sbase)[tid]; result0[((bid*512)+(tid+256))] = (( int *)sbase)[(tid+256)]; } /* -------------------------------------------------------------------------- tsortSmall -------------------------------------------------------------------------- */ __global__ void vsortSmall(int *input0,int *result0){ unsigned int tid = threadIdx.x; unsigned int bid = blockIdx.x; extern __shared__ unsigned char sbase[]; (( int *)sbase)[(tid+(tid&4294967040))] = min(input0[((bid*512)+(tid+(tid&4294967040)))],input0[((bid*512)+((tid+(tid&4294967040))^256))]); (( int *)sbase)[((tid+(tid&4294967040))^256)] = max(input0[((bid*512)+(tid+(tid&4294967040)))],input0[((bid*512)+((tid+(tid&4294967040))^256))]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967040))] = min((( int *)sbase)[(tid+(tid&4294967040))],(( int *)sbase)[((tid+(tid&4294967040))^384)]); (( int *)(sbase + 2048))[((tid+(tid&4294967040))^384)] = max((( int *)sbase)[(tid+(tid&4294967040))],(( int *)sbase)[((tid+(tid&4294967040))^384)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967168))] = min((( int *)(sbase+2048))[(tid+(tid&4294967168))],(( int *)(sbase+2048))[((tid+(tid&4294967168))^128)]); (( int *)sbase)[((tid+(tid&4294967168))^128)] = max((( int *)(sbase+2048))[(tid+(tid&4294967168))],(( int *)(sbase+2048))[((tid+(tid&4294967168))^128)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967040))] = min((( int *)sbase)[(tid+(tid&4294967040))],(( int *)sbase)[((tid+(tid&4294967040))^448)]); (( int *)(sbase + 2048))[((tid+(tid&4294967040))^448)] = max((( int *)sbase)[(tid+(tid&4294967040))],(( int *)sbase)[((tid+(tid&4294967040))^448)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967168))] = min((( int *)(sbase+2048))[(tid+(tid&4294967168))],(( int *)(sbase+2048))[((tid+(tid&4294967168))^192)]); (( int *)sbase)[((tid+(tid&4294967168))^192)] = max((( int *)(sbase+2048))[(tid+(tid&4294967168))],(( int *)(sbase+2048))[((tid+(tid&4294967168))^192)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967232))] = min((( int *)sbase)[(tid+(tid&4294967232))],(( int *)sbase)[((tid+(tid&4294967232))^64)]); (( int *)(sbase + 2048))[((tid+(tid&4294967232))^64)] = max((( int *)sbase)[(tid+(tid&4294967232))],(( int *)sbase)[((tid+(tid&4294967232))^64)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967040))] = min((( int *)(sbase+2048))[(tid+(tid&4294967040))],(( int *)(sbase+2048))[((tid+(tid&4294967040))^480)]); (( int *)sbase)[((tid+(tid&4294967040))^480)] = max((( int *)(sbase+2048))[(tid+(tid&4294967040))],(( int *)(sbase+2048))[((tid+(tid&4294967040))^480)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967168))] = min((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^224)]); (( int *)(sbase + 2048))[((tid+(tid&4294967168))^224)] = max((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^224)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967232))] = min((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^96)]); (( int *)sbase)[((tid+(tid&4294967232))^96)] = max((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^96)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967264))] = min((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^32)]); (( int *)(sbase + 2048))[((tid+(tid&4294967264))^32)] = max((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^32)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967040))] = min((( int *)(sbase+2048))[(tid+(tid&4294967040))],(( int *)(sbase+2048))[((tid+(tid&4294967040))^496)]); (( int *)sbase)[((tid+(tid&4294967040))^496)] = max((( int *)(sbase+2048))[(tid+(tid&4294967040))],(( int *)(sbase+2048))[((tid+(tid&4294967040))^496)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967168))] = min((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^240)]); (( int *)(sbase + 2048))[((tid+(tid&4294967168))^240)] = max((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^240)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967232))] = min((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^112)]); (( int *)sbase)[((tid+(tid&4294967232))^112)] = max((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^112)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967264))] = min((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^48)]); (( int *)(sbase + 2048))[((tid+(tid&4294967264))^48)] = max((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^48)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967280))] = min((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^16)]); (( int *)sbase)[((tid+(tid&4294967280))^16)] = max((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^16)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967040))] = min((( int *)sbase)[(tid+(tid&4294967040))],(( int *)sbase)[((tid+(tid&4294967040))^504)]); (( int *)(sbase + 2048))[((tid+(tid&4294967040))^504)] = max((( int *)sbase)[(tid+(tid&4294967040))],(( int *)sbase)[((tid+(tid&4294967040))^504)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967168))] = min((( int *)(sbase+2048))[(tid+(tid&4294967168))],(( int *)(sbase+2048))[((tid+(tid&4294967168))^248)]); (( int *)sbase)[((tid+(tid&4294967168))^248)] = max((( int *)(sbase+2048))[(tid+(tid&4294967168))],(( int *)(sbase+2048))[((tid+(tid&4294967168))^248)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967232))] = min((( int *)sbase)[(tid+(tid&4294967232))],(( int *)sbase)[((tid+(tid&4294967232))^120)]); (( int *)(sbase + 2048))[((tid+(tid&4294967232))^120)] = max((( int *)sbase)[(tid+(tid&4294967232))],(( int *)sbase)[((tid+(tid&4294967232))^120)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967264))] = min((( int *)(sbase+2048))[(tid+(tid&4294967264))],(( int *)(sbase+2048))[((tid+(tid&4294967264))^56)]); (( int *)sbase)[((tid+(tid&4294967264))^56)] = max((( int *)(sbase+2048))[(tid+(tid&4294967264))],(( int *)(sbase+2048))[((tid+(tid&4294967264))^56)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967280))] = min((( int *)sbase)[(tid+(tid&4294967280))],(( int *)sbase)[((tid+(tid&4294967280))^24)]); (( int *)(sbase + 2048))[((tid+(tid&4294967280))^24)] = max((( int *)sbase)[(tid+(tid&4294967280))],(( int *)sbase)[((tid+(tid&4294967280))^24)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967288))] = min((( int *)(sbase+2048))[(tid+(tid&4294967288))],(( int *)(sbase+2048))[((tid+(tid&4294967288))^8)]); (( int *)sbase)[((tid+(tid&4294967288))^8)] = max((( int *)(sbase+2048))[(tid+(tid&4294967288))],(( int *)(sbase+2048))[((tid+(tid&4294967288))^8)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967040))] = min((( int *)sbase)[(tid+(tid&4294967040))],(( int *)sbase)[((tid+(tid&4294967040))^508)]); (( int *)(sbase + 2048))[((tid+(tid&4294967040))^508)] = max((( int *)sbase)[(tid+(tid&4294967040))],(( int *)sbase)[((tid+(tid&4294967040))^508)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967168))] = min((( int *)(sbase+2048))[(tid+(tid&4294967168))],(( int *)(sbase+2048))[((tid+(tid&4294967168))^252)]); (( int *)sbase)[((tid+(tid&4294967168))^252)] = max((( int *)(sbase+2048))[(tid+(tid&4294967168))],(( int *)(sbase+2048))[((tid+(tid&4294967168))^252)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967232))] = min((( int *)sbase)[(tid+(tid&4294967232))],(( int *)sbase)[((tid+(tid&4294967232))^124)]); (( int *)(sbase + 2048))[((tid+(tid&4294967232))^124)] = max((( int *)sbase)[(tid+(tid&4294967232))],(( int *)sbase)[((tid+(tid&4294967232))^124)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967264))] = min((( int *)(sbase+2048))[(tid+(tid&4294967264))],(( int *)(sbase+2048))[((tid+(tid&4294967264))^60)]); (( int *)sbase)[((tid+(tid&4294967264))^60)] = max((( int *)(sbase+2048))[(tid+(tid&4294967264))],(( int *)(sbase+2048))[((tid+(tid&4294967264))^60)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967280))] = min((( int *)sbase)[(tid+(tid&4294967280))],(( int *)sbase)[((tid+(tid&4294967280))^28)]); (( int *)(sbase + 2048))[((tid+(tid&4294967280))^28)] = max((( int *)sbase)[(tid+(tid&4294967280))],(( int *)sbase)[((tid+(tid&4294967280))^28)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967288))] = min((( int *)(sbase+2048))[(tid+(tid&4294967288))],(( int *)(sbase+2048))[((tid+(tid&4294967288))^12)]); (( int *)sbase)[((tid+(tid&4294967288))^12)] = max((( int *)(sbase+2048))[(tid+(tid&4294967288))],(( int *)(sbase+2048))[((tid+(tid&4294967288))^12)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967292))] = min((( int *)sbase)[(tid+(tid&4294967292))],(( int *)sbase)[((tid+(tid&4294967292))^4)]); (( int *)(sbase + 2048))[((tid+(tid&4294967292))^4)] = max((( int *)sbase)[(tid+(tid&4294967292))],(( int *)sbase)[((tid+(tid&4294967292))^4)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967040))] = min((( int *)(sbase+2048))[(tid+(tid&4294967040))],(( int *)(sbase+2048))[((tid+(tid&4294967040))^510)]); (( int *)sbase)[((tid+(tid&4294967040))^510)] = max((( int *)(sbase+2048))[(tid+(tid&4294967040))],(( int *)(sbase+2048))[((tid+(tid&4294967040))^510)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967168))] = min((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^254)]); (( int *)(sbase + 2048))[((tid+(tid&4294967168))^254)] = max((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^254)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967232))] = min((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^126)]); (( int *)sbase)[((tid+(tid&4294967232))^126)] = max((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^126)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967264))] = min((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^62)]); (( int *)(sbase + 2048))[((tid+(tid&4294967264))^62)] = max((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^62)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967280))] = min((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^30)]); (( int *)sbase)[((tid+(tid&4294967280))^30)] = max((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^30)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967288))] = min((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^14)]); (( int *)(sbase + 2048))[((tid+(tid&4294967288))^14)] = max((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^14)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967292))] = min((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^6)]); (( int *)sbase)[((tid+(tid&4294967292))^6)] = max((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^6)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967294))] = min((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^2)]); (( int *)(sbase + 2048))[((tid+(tid&4294967294))^2)] = max((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^2)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967040))] = min((( int *)(sbase+2048))[(tid+(tid&4294967040))],(( int *)(sbase+2048))[((tid+(tid&4294967040))^511)]); (( int *)sbase)[((tid+(tid&4294967040))^511)] = max((( int *)(sbase+2048))[(tid+(tid&4294967040))],(( int *)(sbase+2048))[((tid+(tid&4294967040))^511)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967168))] = min((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^255)]); (( int *)(sbase + 2048))[((tid+(tid&4294967168))^255)] = max((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^255)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967232))] = min((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^127)]); (( int *)sbase)[((tid+(tid&4294967232))^127)] = max((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^127)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967264))] = min((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^63)]); (( int *)(sbase + 2048))[((tid+(tid&4294967264))^63)] = max((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^63)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967280))] = min((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^31)]); (( int *)sbase)[((tid+(tid&4294967280))^31)] = max((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^31)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967288))] = min((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^15)]); (( int *)(sbase + 2048))[((tid+(tid&4294967288))^15)] = max((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^15)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967292))] = min((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^7)]); (( int *)sbase)[((tid+(tid&4294967292))^7)] = max((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^7)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967294))] = min((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^3)]); (( int *)(sbase + 2048))[((tid+(tid&4294967294))^3)] = max((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^3)]); __syncthreads(); (( int *)sbase)[(tid<<1)] = min((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); (( int *)sbase)[((tid<<1)^1)] = max((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); __syncthreads(); result0[((bid*512)+tid)] = (( int *)sbase)[tid]; result0[((bid*512)+(tid+256))] = (( int *)sbase)[(tid+256)]; } //* kernel for merging small fixed size arrays all on the GPU //* bitonic merge (on 512 elements), generated by Obsidian __global__ void bmergeSmall(int *input0,int *result0){ unsigned int tid = threadIdx.x; unsigned int bid = blockIdx.x; extern __shared__ unsigned char sbase[]; (( int *)sbase)[(tid+(tid&4294967040))] = min(input0[((bid*512)+(tid+(tid&4294967040)))],input0[((bid*512)+((tid+(tid&4294967040))^256))]); (( int *)sbase)[((tid+(tid&4294967040))^256)] = max(input0[((bid*512)+(tid+(tid&4294967040)))],input0[((bid*512)+((tid+(tid&4294967040))^256))]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967168))] = min((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^128)]); (( int *)(sbase + 2048))[((tid+(tid&4294967168))^128)] = max((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^128)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967232))] = min((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^64)]); (( int *)sbase)[((tid+(tid&4294967232))^64)] = max((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^64)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967264))] = min((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^32)]); (( int *)(sbase + 2048))[((tid+(tid&4294967264))^32)] = max((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^32)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967280))] = min((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^16)]); (( int *)sbase)[((tid+(tid&4294967280))^16)] = max((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^16)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967288))] = min((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^8)]); (( int *)(sbase + 2048))[((tid+(tid&4294967288))^8)] = max((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^8)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967292))] = min((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^4)]); (( int *)sbase)[((tid+(tid&4294967292))^4)] = max((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^4)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967294))] = min((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^2)]); (( int *)(sbase + 2048))[((tid+(tid&4294967294))^2)] = max((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^2)]); __syncthreads(); (( int *)sbase)[(tid<<1)] = min((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); (( int *)sbase)[((tid<<1)^1)] = max((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); __syncthreads(); result0[((bid*512)+tid)] = (( int *)sbase)[tid]; result0[((bid*512)+(tid+256))] = (( int *)sbase)[(tid+256)]; } //* Compare and swap elements in a large array with a stride of 2^k //* stride > SMALL_SIZE and < array length (all a power of two) __global__ void iSwap( int *d_input, int *d_output, unsigned int stride){ unsigned int tid = blockIdx.x * blockDim.x + threadIdx.x; unsigned int ix = tid + (tid & ~(stride - 1)); int v1 = d_input[ix]; int v2 = d_input[ix + stride]; d_output[ix] = min(v1,v2); d_output[ix + stride] = max(v1,v2); } __global__ void iSwap2( int *d_input, int *d_output, unsigned int stride){ unsigned int tid = blockIdx.x * blockDim.x + threadIdx.x; unsigned int ix00 = tid + 3*(tid & ~((stride>>1) - 1)); unsigned int ix01 = ix00 + (stride >> 1); int v1 = d_input[ix00]; int v2 = d_input[ix01]; int v3 = d_input[ix00 + stride]; int v4 = d_input[ix01 + stride]; int t1 = min(v1,v3); int t2 = max(v1,v3); int t3 = min(v2,v4); int t4 = max(v2,v4); d_output[ix00] = min(t1,t3); d_output[ix01] = max(t1,t3); d_output[ix00 + stride] = min(t2,t4); d_output[ix01 + stride] = max(t2,t4); } __global__ void iSwap3( int *d_input, int *d_output, unsigned int stride){ unsigned int tid = blockIdx.x * blockDim.x + threadIdx.x; unsigned int s4 = stride >> 2; unsigned int ix00 = tid + 7*(tid & ~(s4 - 1)); unsigned int ix01 = ix00 + (stride >> 1); int v1 = d_input[ix00]; int v2 = d_input[ix00 + s4]; int v3 = d_input[ix00 + 2*s4]; int v4 = d_input[ix00 + 3*s4]; int v5 = d_input[ix00 + stride]; int v6 = d_input[ix00 + 5*s4]; int v7 = d_input[ix00 + 6*s4]; int v8 = d_input[ix00 + 7*s4]; int t1 = min(v1,v5); int t2 = max(v1,v5); int t3 = min(v2,v6); int t4 = max(v2,v6); int t5 = min(v3,v7); int t6 = max(v3,v7); int t7 = min(v4,v8); int t8 = max(v4,v8); v1 = min(t1,t5); v2 = max(t1,t5); v3 = min(t3,t7); v4 = max(t3,t7); v5 = min(t2,t6); v6 = max(t2,t6); v7 = min(t4,t8); v8 = max(t4,t8); d_output[ix00] = min(v1,v3); d_output[ix00 + s4] = max(v1,v3); d_output[ix00 + 2*s4] = min(v2,v4); d_output[ix00 + 3*s4] = max(v2,v4); d_output[ix00 + stride] = min(v5,v7); d_output[ix00 + 5*s4] = max(v5,v7); d_output[ix00 + 6*s4] = min(v6,v8); d_output[ix00 + 7*s4] = max(v6,v8); } //* Compare and swap elements in a large array, as a series of //* adjacent "vee" shaped patterns __global__ void vSwap( int *d_input, int *d_output, unsigned int stride){ unsigned int tid = blockIdx.x * blockDim.x + threadIdx.x; unsigned int ix = tid + (tid & ~(stride - 1)); unsigned int ix2 = ix^((stride<<1)-1); int v1 = d_input[ix]; int v2 = d_input[ix2]; d_output[ix] = min(v1,v2); d_output[ix2] = max(v1,v2); } //* kernel for sorting large arrays, demanding repeated use of kernels //* that sort or merge small fixed size arrays //* Assume input and output arrays have length 2^lenLog //* Small kernels work on SMALL_SIZE inputs. Assume lenLog >= LOG_SMALL_SIZE > 0 void sort(int *d_data) { unsigned int arrayLength = 1 << LOG_LARGE_SIZE; unsigned int diff = LOG_LARGE_SIZE - LOG_SMALL_SIZE; unsigned int blocks = arrayLength / SMALL_SIZE; unsigned int threads = SMALL_SIZE / 2; //bitonicSort<<<blocks,threads*2,2048>>>(d_data, d_data); //tsortSmall<<<blocks, threads,4096>>>(d_data, d_data); hipLaunchKernelGGL(( vsortSmall), dim3(blocks), dim3(threads),4096, 0, d_data, d_data); for(int i = 0 ; i < diff ; i += 1){ hipLaunchKernelGGL(( vSwap), dim3(blocks/2),dim3(threads*2),0, 0, d_data, d_data,(1<<i)*SMALL_SIZE); for(int j = i-1; j >= 0; j -= 3){ if (j==0) { hipLaunchKernelGGL(( iSwap), dim3(blocks/2),dim3(threads*2),0, 0, d_data, d_data,(1<<j)*SMALL_SIZE); } else {if (j==1) { hipLaunchKernelGGL(( iSwap2), dim3(blocks/4),dim3(threads*2),0, 0, d_data, d_data,(1<<j)*SMALL_SIZE);} else hipLaunchKernelGGL(({iSwap3), dim3(blocks/8),dim3(threads*2),0, 0, d_data, d_data,(1<<j)*SMALL_SIZE);}}} hipLaunchKernelGGL(( bmergeSmall), dim3(blocks),dim3(threads),4096, 0, d_data, d_data); } } /* comparator for cpusort ------------------------------------------------------ */ int cmp(const void *a,const void * b) { return(*(int *)a - *(int *)b ); } int main(int argc, char *argv[]){ int *values; int *result; int *dvalues; /*timing*/ timeval gpustart,gpustop; timeval cpustart,cpustop; values = (int*)malloc(LARGE_SIZE*sizeof(int)); result = (int*)malloc(LARGE_SIZE*sizeof(int)); for (int i = 0; i < LARGE_SIZE; ++i) { values[i] = rand (); } /* Allocate GPU arrays */ hipMalloc((void**)&dvalues, sizeof(int) * LARGE_SIZE ); #ifdef TIME_MEM_TRANS gettimeofday(&gpustart,NULL); #endif hipMemcpy(dvalues, values, sizeof(int) * LARGE_SIZE, hipMemcpyHostToDevice); #ifndef TIME_MEM_TRANS gettimeofday(&gpustart,NULL); #endif /* Launch sorting algorithm on gpu */ sort(dvalues); #ifndef TIME_MEM_TRANS hipDeviceSynchronize(); gettimeofday(&gpustop,NULL); #endif hipMemcpy(result, dvalues, sizeof(int) * LARGE_SIZE , hipMemcpyDeviceToHost); #ifdef TIME_MEM_TRANS gettimeofday(&gpustop,NULL); #endif hipFree(dvalues); /* Results ?*/ int passed = 1; for (int i = 1; i < LARGE_SIZE; ++i) { if (result[i] < result[i-1]) { // printf("[%d](%d, %d) ",i, result[i], result[i-1]); passed = 0; } } printf("%s first test.\n",passed ? "Passed" : "Failed"); gettimeofday(&cpustart,NULL); qsort(values,LARGE_SIZE,sizeof(int),cmp); gettimeofday(&cpustop,NULL); for (int i = 0; i < LARGE_SIZE; ++i) { if (result[i] != values[i]) { //printf("[%d](%d, %d) ",i, result[i], values[i]); passed = 0; } } printf("%s second test.\n",passed ? "Passed" : "Failed"); #ifdef TIME_MEM_TRANS printf("GPUTIME includes memory transfer time \n"); #endif printf("GPUTIME %dms\n", diff_ms(&gpustart,&gpustop)); printf("CPUTIME %dms\n", diff_ms(&cpustart,&cpustop)); return 0; }
e39ddb193011f7cad7dddbb9cdd23775e3023be1.cu
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <sys/time.h> #include <time.h> #include "diff_ms.h" // #define TIME_MEM_TRANS 1 /* 2048 20*/ /* 4096 21*/ /* 8192 22*/ /* 16384 23*/ /* 32768 24*/ #define BLOCKS 32768 #define LARGE_SIZE BLOCKS*SMALL_SIZE #define SMALL_SIZE 512 #define THREADS 256 #define LOG_SMALL_SIZE 9 #define LOG_LARGE_SIZE 24 //* kernel for sorting small fixed size arrays all on the GPU #define NUM 512 __device__ inline void swap(int & a, int & b) { // Alternative swap doesn't use a temporary register: // a ^= b; // b ^= a; // a ^= b; int tmp = a; a = b; b = tmp; } __global__ static void bitonicSort(int * values, int *results) { extern __shared__ int shared[]; const unsigned int tid = threadIdx.x; const unsigned int bid = blockIdx.x; // Copy input to shared mem. shared[tid] = values[(bid*NUM) + tid]; __syncthreads(); // Parallel bitonic sort. for (unsigned int k = 2; k <= NUM; k *= 2) { // Bitonic merge: for (unsigned int j = k / 2; j>0; j /= 2) { unsigned int ixj = tid ^ j; if (ixj > tid) { if ((tid & k) == 0) { if (shared[tid] > shared[ixj]) { swap(shared[tid], shared[ixj]); } } else { if (shared[tid] < shared[ixj]) { swap(shared[tid], shared[ixj]); } } } __syncthreads(); } } // Write result. results[(bid*NUM) + tid] = shared[tid]; } /* -------------------------------------------------------------------------- tsortSmall -------------------------------------------------------------------------- */ __global__ void tsortSmall(int *input0,int *result0){ unsigned int tid = threadIdx.x; unsigned int bid = blockIdx.x; extern __shared__ unsigned char sbase[]; (( int *)sbase)[(tid<<1)] = min(input0[((bid*512)+(tid<<1))],input0[((bid*512)+((tid<<1)^1))]); (( int *)sbase)[((tid<<1)^1)] = max(input0[((bid*512)+(tid<<1))],input0[((bid*512)+((tid<<1)^1))]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967294))] = min((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^3)]); (( int *)(sbase + 2048))[((tid+(tid&4294967294))^3)] = max((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^3)]); __syncthreads(); (( int *)sbase)[(tid<<1)] = min((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); (( int *)sbase)[((tid<<1)^1)] = max((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967292))] = min((( int *)sbase)[(tid+(tid&4294967292))],(( int *)sbase)[((tid+(tid&4294967292))^7)]); (( int *)(sbase + 2048))[((tid+(tid&4294967292))^7)] = max((( int *)sbase)[(tid+(tid&4294967292))],(( int *)sbase)[((tid+(tid&4294967292))^7)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967294))] = min((( int *)(sbase+2048))[(tid+(tid&4294967294))],(( int *)(sbase+2048))[((tid+(tid&4294967294))^2)]); (( int *)sbase)[((tid+(tid&4294967294))^2)] = max((( int *)(sbase+2048))[(tid+(tid&4294967294))],(( int *)(sbase+2048))[((tid+(tid&4294967294))^2)]); __syncthreads(); (( int *)(sbase + 2048))[(tid<<1)] = min((( int *)sbase)[(tid<<1)],(( int *)sbase)[((tid<<1)^1)]); (( int *)(sbase + 2048))[((tid<<1)^1)] = max((( int *)sbase)[(tid<<1)],(( int *)sbase)[((tid<<1)^1)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967288))] = min((( int *)(sbase+2048))[(tid+(tid&4294967288))],(( int *)(sbase+2048))[((tid+(tid&4294967288))^15)]); (( int *)sbase)[((tid+(tid&4294967288))^15)] = max((( int *)(sbase+2048))[(tid+(tid&4294967288))],(( int *)(sbase+2048))[((tid+(tid&4294967288))^15)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967292))] = min((( int *)sbase)[(tid+(tid&4294967292))],(( int *)sbase)[((tid+(tid&4294967292))^4)]); (( int *)(sbase + 2048))[((tid+(tid&4294967292))^4)] = max((( int *)sbase)[(tid+(tid&4294967292))],(( int *)sbase)[((tid+(tid&4294967292))^4)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967294))] = min((( int *)(sbase+2048))[(tid+(tid&4294967294))],(( int *)(sbase+2048))[((tid+(tid&4294967294))^2)]); (( int *)sbase)[((tid+(tid&4294967294))^2)] = max((( int *)(sbase+2048))[(tid+(tid&4294967294))],(( int *)(sbase+2048))[((tid+(tid&4294967294))^2)]); __syncthreads(); (( int *)(sbase + 2048))[(tid<<1)] = min((( int *)sbase)[(tid<<1)],(( int *)sbase)[((tid<<1)^1)]); (( int *)(sbase + 2048))[((tid<<1)^1)] = max((( int *)sbase)[(tid<<1)],(( int *)sbase)[((tid<<1)^1)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967280))] = min((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^31)]); (( int *)sbase)[((tid+(tid&4294967280))^31)] = max((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^31)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967288))] = min((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^8)]); (( int *)(sbase + 2048))[((tid+(tid&4294967288))^8)] = max((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^8)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967292))] = min((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^4)]); (( int *)sbase)[((tid+(tid&4294967292))^4)] = max((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^4)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967294))] = min((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^2)]); (( int *)(sbase + 2048))[((tid+(tid&4294967294))^2)] = max((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^2)]); __syncthreads(); (( int *)sbase)[(tid<<1)] = min((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); (( int *)sbase)[((tid<<1)^1)] = max((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967264))] = min((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^63)]); (( int *)(sbase + 2048))[((tid+(tid&4294967264))^63)] = max((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^63)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967280))] = min((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^16)]); (( int *)sbase)[((tid+(tid&4294967280))^16)] = max((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^16)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967288))] = min((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^8)]); (( int *)(sbase + 2048))[((tid+(tid&4294967288))^8)] = max((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^8)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967292))] = min((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^4)]); (( int *)sbase)[((tid+(tid&4294967292))^4)] = max((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^4)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967294))] = min((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^2)]); (( int *)(sbase + 2048))[((tid+(tid&4294967294))^2)] = max((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^2)]); __syncthreads(); (( int *)sbase)[(tid<<1)] = min((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); (( int *)sbase)[((tid<<1)^1)] = max((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967232))] = min((( int *)sbase)[(tid+(tid&4294967232))],(( int *)sbase)[((tid+(tid&4294967232))^127)]); (( int *)(sbase + 2048))[((tid+(tid&4294967232))^127)] = max((( int *)sbase)[(tid+(tid&4294967232))],(( int *)sbase)[((tid+(tid&4294967232))^127)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967264))] = min((( int *)(sbase+2048))[(tid+(tid&4294967264))],(( int *)(sbase+2048))[((tid+(tid&4294967264))^32)]); (( int *)sbase)[((tid+(tid&4294967264))^32)] = max((( int *)(sbase+2048))[(tid+(tid&4294967264))],(( int *)(sbase+2048))[((tid+(tid&4294967264))^32)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967280))] = min((( int *)sbase)[(tid+(tid&4294967280))],(( int *)sbase)[((tid+(tid&4294967280))^16)]); (( int *)(sbase + 2048))[((tid+(tid&4294967280))^16)] = max((( int *)sbase)[(tid+(tid&4294967280))],(( int *)sbase)[((tid+(tid&4294967280))^16)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967288))] = min((( int *)(sbase+2048))[(tid+(tid&4294967288))],(( int *)(sbase+2048))[((tid+(tid&4294967288))^8)]); (( int *)sbase)[((tid+(tid&4294967288))^8)] = max((( int *)(sbase+2048))[(tid+(tid&4294967288))],(( int *)(sbase+2048))[((tid+(tid&4294967288))^8)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967292))] = min((( int *)sbase)[(tid+(tid&4294967292))],(( int *)sbase)[((tid+(tid&4294967292))^4)]); (( int *)(sbase + 2048))[((tid+(tid&4294967292))^4)] = max((( int *)sbase)[(tid+(tid&4294967292))],(( int *)sbase)[((tid+(tid&4294967292))^4)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967294))] = min((( int *)(sbase+2048))[(tid+(tid&4294967294))],(( int *)(sbase+2048))[((tid+(tid&4294967294))^2)]); (( int *)sbase)[((tid+(tid&4294967294))^2)] = max((( int *)(sbase+2048))[(tid+(tid&4294967294))],(( int *)(sbase+2048))[((tid+(tid&4294967294))^2)]); __syncthreads(); (( int *)(sbase + 2048))[(tid<<1)] = min((( int *)sbase)[(tid<<1)],(( int *)sbase)[((tid<<1)^1)]); (( int *)(sbase + 2048))[((tid<<1)^1)] = max((( int *)sbase)[(tid<<1)],(( int *)sbase)[((tid<<1)^1)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967168))] = min((( int *)(sbase+2048))[(tid+(tid&4294967168))],(( int *)(sbase+2048))[((tid+(tid&4294967168))^255)]); (( int *)sbase)[((tid+(tid&4294967168))^255)] = max((( int *)(sbase+2048))[(tid+(tid&4294967168))],(( int *)(sbase+2048))[((tid+(tid&4294967168))^255)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967232))] = min((( int *)sbase)[(tid+(tid&4294967232))],(( int *)sbase)[((tid+(tid&4294967232))^64)]); (( int *)(sbase + 2048))[((tid+(tid&4294967232))^64)] = max((( int *)sbase)[(tid+(tid&4294967232))],(( int *)sbase)[((tid+(tid&4294967232))^64)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967264))] = min((( int *)(sbase+2048))[(tid+(tid&4294967264))],(( int *)(sbase+2048))[((tid+(tid&4294967264))^32)]); (( int *)sbase)[((tid+(tid&4294967264))^32)] = max((( int *)(sbase+2048))[(tid+(tid&4294967264))],(( int *)(sbase+2048))[((tid+(tid&4294967264))^32)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967280))] = min((( int *)sbase)[(tid+(tid&4294967280))],(( int *)sbase)[((tid+(tid&4294967280))^16)]); (( int *)(sbase + 2048))[((tid+(tid&4294967280))^16)] = max((( int *)sbase)[(tid+(tid&4294967280))],(( int *)sbase)[((tid+(tid&4294967280))^16)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967288))] = min((( int *)(sbase+2048))[(tid+(tid&4294967288))],(( int *)(sbase+2048))[((tid+(tid&4294967288))^8)]); (( int *)sbase)[((tid+(tid&4294967288))^8)] = max((( int *)(sbase+2048))[(tid+(tid&4294967288))],(( int *)(sbase+2048))[((tid+(tid&4294967288))^8)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967292))] = min((( int *)sbase)[(tid+(tid&4294967292))],(( int *)sbase)[((tid+(tid&4294967292))^4)]); (( int *)(sbase + 2048))[((tid+(tid&4294967292))^4)] = max((( int *)sbase)[(tid+(tid&4294967292))],(( int *)sbase)[((tid+(tid&4294967292))^4)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967294))] = min((( int *)(sbase+2048))[(tid+(tid&4294967294))],(( int *)(sbase+2048))[((tid+(tid&4294967294))^2)]); (( int *)sbase)[((tid+(tid&4294967294))^2)] = max((( int *)(sbase+2048))[(tid+(tid&4294967294))],(( int *)(sbase+2048))[((tid+(tid&4294967294))^2)]); __syncthreads(); (( int *)(sbase + 2048))[(tid<<1)] = min((( int *)sbase)[(tid<<1)],(( int *)sbase)[((tid<<1)^1)]); (( int *)(sbase + 2048))[((tid<<1)^1)] = max((( int *)sbase)[(tid<<1)],(( int *)sbase)[((tid<<1)^1)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967040))] = min((( int *)(sbase+2048))[(tid+(tid&4294967040))],(( int *)(sbase+2048))[((tid+(tid&4294967040))^511)]); (( int *)sbase)[((tid+(tid&4294967040))^511)] = max((( int *)(sbase+2048))[(tid+(tid&4294967040))],(( int *)(sbase+2048))[((tid+(tid&4294967040))^511)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967168))] = min((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^128)]); (( int *)(sbase + 2048))[((tid+(tid&4294967168))^128)] = max((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^128)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967232))] = min((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^64)]); (( int *)sbase)[((tid+(tid&4294967232))^64)] = max((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^64)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967264))] = min((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^32)]); (( int *)(sbase + 2048))[((tid+(tid&4294967264))^32)] = max((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^32)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967280))] = min((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^16)]); (( int *)sbase)[((tid+(tid&4294967280))^16)] = max((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^16)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967288))] = min((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^8)]); (( int *)(sbase + 2048))[((tid+(tid&4294967288))^8)] = max((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^8)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967292))] = min((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^4)]); (( int *)sbase)[((tid+(tid&4294967292))^4)] = max((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^4)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967294))] = min((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^2)]); (( int *)(sbase + 2048))[((tid+(tid&4294967294))^2)] = max((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^2)]); __syncthreads(); (( int *)sbase)[(tid<<1)] = min((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); (( int *)sbase)[((tid<<1)^1)] = max((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); __syncthreads(); result0[((bid*512)+tid)] = (( int *)sbase)[tid]; result0[((bid*512)+(tid+256))] = (( int *)sbase)[(tid+256)]; } /* -------------------------------------------------------------------------- tsortSmall -------------------------------------------------------------------------- */ __global__ void vsortSmall(int *input0,int *result0){ unsigned int tid = threadIdx.x; unsigned int bid = blockIdx.x; extern __shared__ unsigned char sbase[]; (( int *)sbase)[(tid+(tid&4294967040))] = min(input0[((bid*512)+(tid+(tid&4294967040)))],input0[((bid*512)+((tid+(tid&4294967040))^256))]); (( int *)sbase)[((tid+(tid&4294967040))^256)] = max(input0[((bid*512)+(tid+(tid&4294967040)))],input0[((bid*512)+((tid+(tid&4294967040))^256))]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967040))] = min((( int *)sbase)[(tid+(tid&4294967040))],(( int *)sbase)[((tid+(tid&4294967040))^384)]); (( int *)(sbase + 2048))[((tid+(tid&4294967040))^384)] = max((( int *)sbase)[(tid+(tid&4294967040))],(( int *)sbase)[((tid+(tid&4294967040))^384)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967168))] = min((( int *)(sbase+2048))[(tid+(tid&4294967168))],(( int *)(sbase+2048))[((tid+(tid&4294967168))^128)]); (( int *)sbase)[((tid+(tid&4294967168))^128)] = max((( int *)(sbase+2048))[(tid+(tid&4294967168))],(( int *)(sbase+2048))[((tid+(tid&4294967168))^128)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967040))] = min((( int *)sbase)[(tid+(tid&4294967040))],(( int *)sbase)[((tid+(tid&4294967040))^448)]); (( int *)(sbase + 2048))[((tid+(tid&4294967040))^448)] = max((( int *)sbase)[(tid+(tid&4294967040))],(( int *)sbase)[((tid+(tid&4294967040))^448)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967168))] = min((( int *)(sbase+2048))[(tid+(tid&4294967168))],(( int *)(sbase+2048))[((tid+(tid&4294967168))^192)]); (( int *)sbase)[((tid+(tid&4294967168))^192)] = max((( int *)(sbase+2048))[(tid+(tid&4294967168))],(( int *)(sbase+2048))[((tid+(tid&4294967168))^192)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967232))] = min((( int *)sbase)[(tid+(tid&4294967232))],(( int *)sbase)[((tid+(tid&4294967232))^64)]); (( int *)(sbase + 2048))[((tid+(tid&4294967232))^64)] = max((( int *)sbase)[(tid+(tid&4294967232))],(( int *)sbase)[((tid+(tid&4294967232))^64)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967040))] = min((( int *)(sbase+2048))[(tid+(tid&4294967040))],(( int *)(sbase+2048))[((tid+(tid&4294967040))^480)]); (( int *)sbase)[((tid+(tid&4294967040))^480)] = max((( int *)(sbase+2048))[(tid+(tid&4294967040))],(( int *)(sbase+2048))[((tid+(tid&4294967040))^480)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967168))] = min((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^224)]); (( int *)(sbase + 2048))[((tid+(tid&4294967168))^224)] = max((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^224)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967232))] = min((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^96)]); (( int *)sbase)[((tid+(tid&4294967232))^96)] = max((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^96)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967264))] = min((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^32)]); (( int *)(sbase + 2048))[((tid+(tid&4294967264))^32)] = max((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^32)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967040))] = min((( int *)(sbase+2048))[(tid+(tid&4294967040))],(( int *)(sbase+2048))[((tid+(tid&4294967040))^496)]); (( int *)sbase)[((tid+(tid&4294967040))^496)] = max((( int *)(sbase+2048))[(tid+(tid&4294967040))],(( int *)(sbase+2048))[((tid+(tid&4294967040))^496)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967168))] = min((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^240)]); (( int *)(sbase + 2048))[((tid+(tid&4294967168))^240)] = max((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^240)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967232))] = min((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^112)]); (( int *)sbase)[((tid+(tid&4294967232))^112)] = max((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^112)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967264))] = min((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^48)]); (( int *)(sbase + 2048))[((tid+(tid&4294967264))^48)] = max((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^48)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967280))] = min((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^16)]); (( int *)sbase)[((tid+(tid&4294967280))^16)] = max((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^16)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967040))] = min((( int *)sbase)[(tid+(tid&4294967040))],(( int *)sbase)[((tid+(tid&4294967040))^504)]); (( int *)(sbase + 2048))[((tid+(tid&4294967040))^504)] = max((( int *)sbase)[(tid+(tid&4294967040))],(( int *)sbase)[((tid+(tid&4294967040))^504)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967168))] = min((( int *)(sbase+2048))[(tid+(tid&4294967168))],(( int *)(sbase+2048))[((tid+(tid&4294967168))^248)]); (( int *)sbase)[((tid+(tid&4294967168))^248)] = max((( int *)(sbase+2048))[(tid+(tid&4294967168))],(( int *)(sbase+2048))[((tid+(tid&4294967168))^248)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967232))] = min((( int *)sbase)[(tid+(tid&4294967232))],(( int *)sbase)[((tid+(tid&4294967232))^120)]); (( int *)(sbase + 2048))[((tid+(tid&4294967232))^120)] = max((( int *)sbase)[(tid+(tid&4294967232))],(( int *)sbase)[((tid+(tid&4294967232))^120)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967264))] = min((( int *)(sbase+2048))[(tid+(tid&4294967264))],(( int *)(sbase+2048))[((tid+(tid&4294967264))^56)]); (( int *)sbase)[((tid+(tid&4294967264))^56)] = max((( int *)(sbase+2048))[(tid+(tid&4294967264))],(( int *)(sbase+2048))[((tid+(tid&4294967264))^56)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967280))] = min((( int *)sbase)[(tid+(tid&4294967280))],(( int *)sbase)[((tid+(tid&4294967280))^24)]); (( int *)(sbase + 2048))[((tid+(tid&4294967280))^24)] = max((( int *)sbase)[(tid+(tid&4294967280))],(( int *)sbase)[((tid+(tid&4294967280))^24)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967288))] = min((( int *)(sbase+2048))[(tid+(tid&4294967288))],(( int *)(sbase+2048))[((tid+(tid&4294967288))^8)]); (( int *)sbase)[((tid+(tid&4294967288))^8)] = max((( int *)(sbase+2048))[(tid+(tid&4294967288))],(( int *)(sbase+2048))[((tid+(tid&4294967288))^8)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967040))] = min((( int *)sbase)[(tid+(tid&4294967040))],(( int *)sbase)[((tid+(tid&4294967040))^508)]); (( int *)(sbase + 2048))[((tid+(tid&4294967040))^508)] = max((( int *)sbase)[(tid+(tid&4294967040))],(( int *)sbase)[((tid+(tid&4294967040))^508)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967168))] = min((( int *)(sbase+2048))[(tid+(tid&4294967168))],(( int *)(sbase+2048))[((tid+(tid&4294967168))^252)]); (( int *)sbase)[((tid+(tid&4294967168))^252)] = max((( int *)(sbase+2048))[(tid+(tid&4294967168))],(( int *)(sbase+2048))[((tid+(tid&4294967168))^252)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967232))] = min((( int *)sbase)[(tid+(tid&4294967232))],(( int *)sbase)[((tid+(tid&4294967232))^124)]); (( int *)(sbase + 2048))[((tid+(tid&4294967232))^124)] = max((( int *)sbase)[(tid+(tid&4294967232))],(( int *)sbase)[((tid+(tid&4294967232))^124)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967264))] = min((( int *)(sbase+2048))[(tid+(tid&4294967264))],(( int *)(sbase+2048))[((tid+(tid&4294967264))^60)]); (( int *)sbase)[((tid+(tid&4294967264))^60)] = max((( int *)(sbase+2048))[(tid+(tid&4294967264))],(( int *)(sbase+2048))[((tid+(tid&4294967264))^60)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967280))] = min((( int *)sbase)[(tid+(tid&4294967280))],(( int *)sbase)[((tid+(tid&4294967280))^28)]); (( int *)(sbase + 2048))[((tid+(tid&4294967280))^28)] = max((( int *)sbase)[(tid+(tid&4294967280))],(( int *)sbase)[((tid+(tid&4294967280))^28)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967288))] = min((( int *)(sbase+2048))[(tid+(tid&4294967288))],(( int *)(sbase+2048))[((tid+(tid&4294967288))^12)]); (( int *)sbase)[((tid+(tid&4294967288))^12)] = max((( int *)(sbase+2048))[(tid+(tid&4294967288))],(( int *)(sbase+2048))[((tid+(tid&4294967288))^12)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967292))] = min((( int *)sbase)[(tid+(tid&4294967292))],(( int *)sbase)[((tid+(tid&4294967292))^4)]); (( int *)(sbase + 2048))[((tid+(tid&4294967292))^4)] = max((( int *)sbase)[(tid+(tid&4294967292))],(( int *)sbase)[((tid+(tid&4294967292))^4)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967040))] = min((( int *)(sbase+2048))[(tid+(tid&4294967040))],(( int *)(sbase+2048))[((tid+(tid&4294967040))^510)]); (( int *)sbase)[((tid+(tid&4294967040))^510)] = max((( int *)(sbase+2048))[(tid+(tid&4294967040))],(( int *)(sbase+2048))[((tid+(tid&4294967040))^510)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967168))] = min((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^254)]); (( int *)(sbase + 2048))[((tid+(tid&4294967168))^254)] = max((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^254)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967232))] = min((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^126)]); (( int *)sbase)[((tid+(tid&4294967232))^126)] = max((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^126)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967264))] = min((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^62)]); (( int *)(sbase + 2048))[((tid+(tid&4294967264))^62)] = max((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^62)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967280))] = min((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^30)]); (( int *)sbase)[((tid+(tid&4294967280))^30)] = max((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^30)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967288))] = min((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^14)]); (( int *)(sbase + 2048))[((tid+(tid&4294967288))^14)] = max((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^14)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967292))] = min((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^6)]); (( int *)sbase)[((tid+(tid&4294967292))^6)] = max((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^6)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967294))] = min((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^2)]); (( int *)(sbase + 2048))[((tid+(tid&4294967294))^2)] = max((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^2)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967040))] = min((( int *)(sbase+2048))[(tid+(tid&4294967040))],(( int *)(sbase+2048))[((tid+(tid&4294967040))^511)]); (( int *)sbase)[((tid+(tid&4294967040))^511)] = max((( int *)(sbase+2048))[(tid+(tid&4294967040))],(( int *)(sbase+2048))[((tid+(tid&4294967040))^511)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967168))] = min((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^255)]); (( int *)(sbase + 2048))[((tid+(tid&4294967168))^255)] = max((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^255)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967232))] = min((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^127)]); (( int *)sbase)[((tid+(tid&4294967232))^127)] = max((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^127)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967264))] = min((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^63)]); (( int *)(sbase + 2048))[((tid+(tid&4294967264))^63)] = max((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^63)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967280))] = min((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^31)]); (( int *)sbase)[((tid+(tid&4294967280))^31)] = max((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^31)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967288))] = min((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^15)]); (( int *)(sbase + 2048))[((tid+(tid&4294967288))^15)] = max((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^15)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967292))] = min((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^7)]); (( int *)sbase)[((tid+(tid&4294967292))^7)] = max((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^7)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967294))] = min((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^3)]); (( int *)(sbase + 2048))[((tid+(tid&4294967294))^3)] = max((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^3)]); __syncthreads(); (( int *)sbase)[(tid<<1)] = min((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); (( int *)sbase)[((tid<<1)^1)] = max((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); __syncthreads(); result0[((bid*512)+tid)] = (( int *)sbase)[tid]; result0[((bid*512)+(tid+256))] = (( int *)sbase)[(tid+256)]; } //* kernel for merging small fixed size arrays all on the GPU //* bitonic merge (on 512 elements), generated by Obsidian __global__ void bmergeSmall(int *input0,int *result0){ unsigned int tid = threadIdx.x; unsigned int bid = blockIdx.x; extern __shared__ unsigned char sbase[]; (( int *)sbase)[(tid+(tid&4294967040))] = min(input0[((bid*512)+(tid+(tid&4294967040)))],input0[((bid*512)+((tid+(tid&4294967040))^256))]); (( int *)sbase)[((tid+(tid&4294967040))^256)] = max(input0[((bid*512)+(tid+(tid&4294967040)))],input0[((bid*512)+((tid+(tid&4294967040))^256))]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967168))] = min((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^128)]); (( int *)(sbase + 2048))[((tid+(tid&4294967168))^128)] = max((( int *)sbase)[(tid+(tid&4294967168))],(( int *)sbase)[((tid+(tid&4294967168))^128)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967232))] = min((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^64)]); (( int *)sbase)[((tid+(tid&4294967232))^64)] = max((( int *)(sbase+2048))[(tid+(tid&4294967232))],(( int *)(sbase+2048))[((tid+(tid&4294967232))^64)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967264))] = min((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^32)]); (( int *)(sbase + 2048))[((tid+(tid&4294967264))^32)] = max((( int *)sbase)[(tid+(tid&4294967264))],(( int *)sbase)[((tid+(tid&4294967264))^32)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967280))] = min((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^16)]); (( int *)sbase)[((tid+(tid&4294967280))^16)] = max((( int *)(sbase+2048))[(tid+(tid&4294967280))],(( int *)(sbase+2048))[((tid+(tid&4294967280))^16)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967288))] = min((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^8)]); (( int *)(sbase + 2048))[((tid+(tid&4294967288))^8)] = max((( int *)sbase)[(tid+(tid&4294967288))],(( int *)sbase)[((tid+(tid&4294967288))^8)]); __syncthreads(); (( int *)sbase)[(tid+(tid&4294967292))] = min((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^4)]); (( int *)sbase)[((tid+(tid&4294967292))^4)] = max((( int *)(sbase+2048))[(tid+(tid&4294967292))],(( int *)(sbase+2048))[((tid+(tid&4294967292))^4)]); __syncthreads(); (( int *)(sbase + 2048))[(tid+(tid&4294967294))] = min((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^2)]); (( int *)(sbase + 2048))[((tid+(tid&4294967294))^2)] = max((( int *)sbase)[(tid+(tid&4294967294))],(( int *)sbase)[((tid+(tid&4294967294))^2)]); __syncthreads(); (( int *)sbase)[(tid<<1)] = min((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); (( int *)sbase)[((tid<<1)^1)] = max((( int *)(sbase+2048))[(tid<<1)],(( int *)(sbase+2048))[((tid<<1)^1)]); __syncthreads(); result0[((bid*512)+tid)] = (( int *)sbase)[tid]; result0[((bid*512)+(tid+256))] = (( int *)sbase)[(tid+256)]; } //* Compare and swap elements in a large array with a stride of 2^k //* stride > SMALL_SIZE and < array length (all a power of two) __global__ void iSwap( int *d_input, int *d_output, unsigned int stride){ unsigned int tid = blockIdx.x * blockDim.x + threadIdx.x; unsigned int ix = tid + (tid & ~(stride - 1)); int v1 = d_input[ix]; int v2 = d_input[ix + stride]; d_output[ix] = min(v1,v2); d_output[ix + stride] = max(v1,v2); } __global__ void iSwap2( int *d_input, int *d_output, unsigned int stride){ unsigned int tid = blockIdx.x * blockDim.x + threadIdx.x; unsigned int ix00 = tid + 3*(tid & ~((stride>>1) - 1)); unsigned int ix01 = ix00 + (stride >> 1); int v1 = d_input[ix00]; int v2 = d_input[ix01]; int v3 = d_input[ix00 + stride]; int v4 = d_input[ix01 + stride]; int t1 = min(v1,v3); int t2 = max(v1,v3); int t3 = min(v2,v4); int t4 = max(v2,v4); d_output[ix00] = min(t1,t3); d_output[ix01] = max(t1,t3); d_output[ix00 + stride] = min(t2,t4); d_output[ix01 + stride] = max(t2,t4); } __global__ void iSwap3( int *d_input, int *d_output, unsigned int stride){ unsigned int tid = blockIdx.x * blockDim.x + threadIdx.x; unsigned int s4 = stride >> 2; unsigned int ix00 = tid + 7*(tid & ~(s4 - 1)); unsigned int ix01 = ix00 + (stride >> 1); int v1 = d_input[ix00]; int v2 = d_input[ix00 + s4]; int v3 = d_input[ix00 + 2*s4]; int v4 = d_input[ix00 + 3*s4]; int v5 = d_input[ix00 + stride]; int v6 = d_input[ix00 + 5*s4]; int v7 = d_input[ix00 + 6*s4]; int v8 = d_input[ix00 + 7*s4]; int t1 = min(v1,v5); int t2 = max(v1,v5); int t3 = min(v2,v6); int t4 = max(v2,v6); int t5 = min(v3,v7); int t6 = max(v3,v7); int t7 = min(v4,v8); int t8 = max(v4,v8); v1 = min(t1,t5); v2 = max(t1,t5); v3 = min(t3,t7); v4 = max(t3,t7); v5 = min(t2,t6); v6 = max(t2,t6); v7 = min(t4,t8); v8 = max(t4,t8); d_output[ix00] = min(v1,v3); d_output[ix00 + s4] = max(v1,v3); d_output[ix00 + 2*s4] = min(v2,v4); d_output[ix00 + 3*s4] = max(v2,v4); d_output[ix00 + stride] = min(v5,v7); d_output[ix00 + 5*s4] = max(v5,v7); d_output[ix00 + 6*s4] = min(v6,v8); d_output[ix00 + 7*s4] = max(v6,v8); } //* Compare and swap elements in a large array, as a series of //* adjacent "vee" shaped patterns __global__ void vSwap( int *d_input, int *d_output, unsigned int stride){ unsigned int tid = blockIdx.x * blockDim.x + threadIdx.x; unsigned int ix = tid + (tid & ~(stride - 1)); unsigned int ix2 = ix^((stride<<1)-1); int v1 = d_input[ix]; int v2 = d_input[ix2]; d_output[ix] = min(v1,v2); d_output[ix2] = max(v1,v2); } //* kernel for sorting large arrays, demanding repeated use of kernels //* that sort or merge small fixed size arrays //* Assume input and output arrays have length 2^lenLog //* Small kernels work on SMALL_SIZE inputs. Assume lenLog >= LOG_SMALL_SIZE > 0 void sort(int *d_data) { unsigned int arrayLength = 1 << LOG_LARGE_SIZE; unsigned int diff = LOG_LARGE_SIZE - LOG_SMALL_SIZE; unsigned int blocks = arrayLength / SMALL_SIZE; unsigned int threads = SMALL_SIZE / 2; //bitonicSort<<<blocks,threads*2,2048>>>(d_data, d_data); //tsortSmall<<<blocks, threads,4096>>>(d_data, d_data); vsortSmall<<<blocks, threads,4096>>>(d_data, d_data); for(int i = 0 ; i < diff ; i += 1){ vSwap<<<blocks/2,threads*2,0>>>(d_data, d_data,(1<<i)*SMALL_SIZE); for(int j = i-1; j >= 0; j -= 3){ if (j==0) { iSwap<<<blocks/2,threads*2,0>>>(d_data, d_data,(1<<j)*SMALL_SIZE); } else {if (j==1) { iSwap2<<<blocks/4,threads*2,0>>>(d_data, d_data,(1<<j)*SMALL_SIZE);} else {iSwap3<<<blocks/8,threads*2,0>>>(d_data, d_data,(1<<j)*SMALL_SIZE);}}} bmergeSmall<<<blocks,threads,4096>>>(d_data, d_data); } } /* comparator for cpusort ------------------------------------------------------ */ int cmp(const void *a,const void * b) { return(*(int *)a - *(int *)b ); } int main(int argc, char *argv[]){ int *values; int *result; int *dvalues; /*timing*/ timeval gpustart,gpustop; timeval cpustart,cpustop; values = (int*)malloc(LARGE_SIZE*sizeof(int)); result = (int*)malloc(LARGE_SIZE*sizeof(int)); for (int i = 0; i < LARGE_SIZE; ++i) { values[i] = rand (); } /* Allocate GPU arrays */ cudaMalloc((void**)&dvalues, sizeof(int) * LARGE_SIZE ); #ifdef TIME_MEM_TRANS gettimeofday(&gpustart,NULL); #endif cudaMemcpy(dvalues, values, sizeof(int) * LARGE_SIZE, cudaMemcpyHostToDevice); #ifndef TIME_MEM_TRANS gettimeofday(&gpustart,NULL); #endif /* Launch sorting algorithm on gpu */ sort(dvalues); #ifndef TIME_MEM_TRANS cudaThreadSynchronize(); gettimeofday(&gpustop,NULL); #endif cudaMemcpy(result, dvalues, sizeof(int) * LARGE_SIZE , cudaMemcpyDeviceToHost); #ifdef TIME_MEM_TRANS gettimeofday(&gpustop,NULL); #endif cudaFree(dvalues); /* Results ?*/ int passed = 1; for (int i = 1; i < LARGE_SIZE; ++i) { if (result[i] < result[i-1]) { // printf("[%d](%d, %d) ",i, result[i], result[i-1]); passed = 0; } } printf("%s first test.\n",passed ? "Passed" : "Failed"); gettimeofday(&cpustart,NULL); qsort(values,LARGE_SIZE,sizeof(int),cmp); gettimeofday(&cpustop,NULL); for (int i = 0; i < LARGE_SIZE; ++i) { if (result[i] != values[i]) { //printf("[%d](%d, %d) ",i, result[i], values[i]); passed = 0; } } printf("%s second test.\n",passed ? "Passed" : "Failed"); #ifdef TIME_MEM_TRANS printf("GPUTIME includes memory transfer time \n"); #endif printf("GPUTIME %dms\n", diff_ms(&gpustart,&gpustop)); printf("CPUTIME %dms\n", diff_ms(&cpustart,&cpustop)); return 0; }
6ae43c6ded2ffb6858770e2a1d08076d33bd6dcb.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include <algorithm> #include <cfloat> #include <vector> #include "caffe/layer.hpp" #include "caffe/util/math_functions.hpp" #include "caffe/vision_layers.hpp" namespace caffe { template <typename Dtype> __global__ void SoftmaxLossForwardGPU(const int nthreads, const Dtype* prob_data, const Dtype* label, Dtype* loss, const int num, const int dim, const int spatial_dim, const bool has_ignore_label_, const int ignore_label_, Dtype* counts) { CUDA_KERNEL_LOOP(index, nthreads) { const int n = index / spatial_dim; const int s = index % spatial_dim; const int label_value = static_cast<int>(label[n * spatial_dim + s]); if (has_ignore_label_ && label_value == ignore_label_) { loss[index] = 0; counts[index] = 0; } else { loss[index] = -log(max(prob_data[n * dim + label_value * spatial_dim + s], Dtype(FLT_MIN))); counts[index] = 1; } } } template <typename Dtype> void SoftmaxWithLossLayer<Dtype>::Forward_gpu( const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) { softmax_layer_->Forward(softmax_bottom_vec_, softmax_top_vec_); const Dtype* prob_data = prob_.gpu_data(); const Dtype* label = bottom[1]->gpu_data(); const int dim = prob_.count() / outer_num_; const int nthreads = outer_num_ * inner_num_; // Since this memory is not used for anything until it is overwritten // on the backward pass, we use it here to avoid having to allocate new GPU // memory to accumulate intermediate results in the kernel. // Dtype* loss_data = bottom[0]->mutable_gpu_diff(); // Similarly, this memory is never used elsewhere, and thus we can use it // to avoid having to allocate additional GPU memory. /* Cui: No, we don't want to do that. We use losses_ instead */ Dtype* loss_data = losses_.mutable_gpu_diff(); Dtype* counts = prob_.mutable_gpu_diff(); // NOLINT_NEXT_LINE(whitespace/operators) hipLaunchKernelGGL(( SoftmaxLossForwardGPU<Dtype>), dim3(CAFFE_GET_BLOCKS(nthreads)), dim3(CAFFE_CUDA_NUM_THREADS), 0, Caffe::cuda_stream(), nthreads, prob_data, label, loss_data, outer_num_, dim, inner_num_, has_ignore_label_, ignore_label_, counts); Dtype loss; caffe_gpu_asum(nthreads, loss_data, &loss); if (normalize_) { Dtype count; caffe_gpu_asum(nthreads, counts, &count); loss /= count; } else { loss /= outer_num_; } top[0]->mutable_cpu_data()[0] = loss; if (top.size() == 2) { CHECK(0); top[1]->ShareData(prob_); } } template <typename Dtype> __global__ void SoftmaxLossBackwardGPU(const int nthreads, const Dtype* top, const Dtype* label, Dtype* bottom_diff, const int num, const int dim, const int spatial_dim, const bool has_ignore_label_, const int ignore_label_, Dtype* counts) { const int channels = dim / spatial_dim; CUDA_KERNEL_LOOP(index, nthreads) { const int n = index / spatial_dim; const int s = index % spatial_dim; const int label_value = static_cast<int>(label[n * spatial_dim + s]); if (has_ignore_label_ && label_value == ignore_label_) { for (int c = 0; c < channels; ++c) { bottom_diff[n * dim + c * spatial_dim + s] = 0; } counts[index] = 0; } else { bottom_diff[n * dim + label_value * spatial_dim + s] -= 1; counts[index] = 1; } } } template <typename Dtype> void SoftmaxWithLossLayer<Dtype>::Backward_gpu(const vector<Blob<Dtype>*>& top, const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom) { if (propagate_down[1]) { LOG(FATAL) << this->type() << " Layer cannot backpropagate to label inputs."; } if (propagate_down[0]) { Dtype* bottom_diff = bottom[0]->mutable_gpu_diff(); const Dtype* prob_data = prob_.gpu_data(); const Dtype* top_data = top[0]->gpu_data(); caffe_gpu_memcpy(prob_.count() * sizeof(Dtype), prob_data, bottom_diff); const Dtype* label = bottom[1]->gpu_data(); const int dim = prob_.count() / outer_num_; const int nthreads = outer_num_ * inner_num_; // Since this memory is never used for anything else, // we use to to avoid allocating new GPU memory. Dtype* counts = prob_.mutable_gpu_diff(); // NOLINT_NEXT_LINE(whitespace/operators) hipLaunchKernelGGL(( SoftmaxLossBackwardGPU<Dtype>), dim3(CAFFE_GET_BLOCKS(nthreads)), dim3(CAFFE_CUDA_NUM_THREADS), 0, Caffe::cuda_stream(), nthreads, top_data, label, bottom_diff, outer_num_, dim, inner_num_, has_ignore_label_, ignore_label_, counts); const Dtype loss_weight = top[0]->cpu_diff()[0]; if (normalize_) { Dtype count; caffe_gpu_asum(nthreads, counts, &count); caffe_gpu_scal(prob_.count(), loss_weight / count, bottom_diff); } else { caffe_gpu_scal(prob_.count(), loss_weight / outer_num_, bottom_diff); } } } INSTANTIATE_LAYER_GPU_FUNCS(SoftmaxWithLossLayer); } // namespace caffe
6ae43c6ded2ffb6858770e2a1d08076d33bd6dcb.cu
#include <algorithm> #include <cfloat> #include <vector> #include "caffe/layer.hpp" #include "caffe/util/math_functions.hpp" #include "caffe/vision_layers.hpp" namespace caffe { template <typename Dtype> __global__ void SoftmaxLossForwardGPU(const int nthreads, const Dtype* prob_data, const Dtype* label, Dtype* loss, const int num, const int dim, const int spatial_dim, const bool has_ignore_label_, const int ignore_label_, Dtype* counts) { CUDA_KERNEL_LOOP(index, nthreads) { const int n = index / spatial_dim; const int s = index % spatial_dim; const int label_value = static_cast<int>(label[n * spatial_dim + s]); if (has_ignore_label_ && label_value == ignore_label_) { loss[index] = 0; counts[index] = 0; } else { loss[index] = -log(max(prob_data[n * dim + label_value * spatial_dim + s], Dtype(FLT_MIN))); counts[index] = 1; } } } template <typename Dtype> void SoftmaxWithLossLayer<Dtype>::Forward_gpu( const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) { softmax_layer_->Forward(softmax_bottom_vec_, softmax_top_vec_); const Dtype* prob_data = prob_.gpu_data(); const Dtype* label = bottom[1]->gpu_data(); const int dim = prob_.count() / outer_num_; const int nthreads = outer_num_ * inner_num_; // Since this memory is not used for anything until it is overwritten // on the backward pass, we use it here to avoid having to allocate new GPU // memory to accumulate intermediate results in the kernel. // Dtype* loss_data = bottom[0]->mutable_gpu_diff(); // Similarly, this memory is never used elsewhere, and thus we can use it // to avoid having to allocate additional GPU memory. /* Cui: No, we don't want to do that. We use losses_ instead */ Dtype* loss_data = losses_.mutable_gpu_diff(); Dtype* counts = prob_.mutable_gpu_diff(); // NOLINT_NEXT_LINE(whitespace/operators) SoftmaxLossForwardGPU<Dtype><<<CAFFE_GET_BLOCKS(nthreads), CAFFE_CUDA_NUM_THREADS, 0, Caffe::cuda_stream()>>>( nthreads, prob_data, label, loss_data, outer_num_, dim, inner_num_, has_ignore_label_, ignore_label_, counts); Dtype loss; caffe_gpu_asum(nthreads, loss_data, &loss); if (normalize_) { Dtype count; caffe_gpu_asum(nthreads, counts, &count); loss /= count; } else { loss /= outer_num_; } top[0]->mutable_cpu_data()[0] = loss; if (top.size() == 2) { CHECK(0); top[1]->ShareData(prob_); } } template <typename Dtype> __global__ void SoftmaxLossBackwardGPU(const int nthreads, const Dtype* top, const Dtype* label, Dtype* bottom_diff, const int num, const int dim, const int spatial_dim, const bool has_ignore_label_, const int ignore_label_, Dtype* counts) { const int channels = dim / spatial_dim; CUDA_KERNEL_LOOP(index, nthreads) { const int n = index / spatial_dim; const int s = index % spatial_dim; const int label_value = static_cast<int>(label[n * spatial_dim + s]); if (has_ignore_label_ && label_value == ignore_label_) { for (int c = 0; c < channels; ++c) { bottom_diff[n * dim + c * spatial_dim + s] = 0; } counts[index] = 0; } else { bottom_diff[n * dim + label_value * spatial_dim + s] -= 1; counts[index] = 1; } } } template <typename Dtype> void SoftmaxWithLossLayer<Dtype>::Backward_gpu(const vector<Blob<Dtype>*>& top, const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom) { if (propagate_down[1]) { LOG(FATAL) << this->type() << " Layer cannot backpropagate to label inputs."; } if (propagate_down[0]) { Dtype* bottom_diff = bottom[0]->mutable_gpu_diff(); const Dtype* prob_data = prob_.gpu_data(); const Dtype* top_data = top[0]->gpu_data(); caffe_gpu_memcpy(prob_.count() * sizeof(Dtype), prob_data, bottom_diff); const Dtype* label = bottom[1]->gpu_data(); const int dim = prob_.count() / outer_num_; const int nthreads = outer_num_ * inner_num_; // Since this memory is never used for anything else, // we use to to avoid allocating new GPU memory. Dtype* counts = prob_.mutable_gpu_diff(); // NOLINT_NEXT_LINE(whitespace/operators) SoftmaxLossBackwardGPU<Dtype><<<CAFFE_GET_BLOCKS(nthreads), CAFFE_CUDA_NUM_THREADS, 0, Caffe::cuda_stream()>>>( nthreads, top_data, label, bottom_diff, outer_num_, dim, inner_num_, has_ignore_label_, ignore_label_, counts); const Dtype loss_weight = top[0]->cpu_diff()[0]; if (normalize_) { Dtype count; caffe_gpu_asum(nthreads, counts, &count); caffe_gpu_scal(prob_.count(), loss_weight / count, bottom_diff); } else { caffe_gpu_scal(prob_.count(), loss_weight / outer_num_, bottom_diff); } } } INSTANTIATE_LAYER_GPU_FUNCS(SoftmaxWithLossLayer); } // namespace caffe
fe7c6249c40b7ba32d85377d87f697883c27f4ca.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include <stdio.h> #define N 2048 * 2048 // Number of elements in each vector __global__ void saxpy(int * a, int * b, int * c) { // Determine our unique global thread ID, so we know which element to process int tid = blockIdx.x * blockDim.x + threadIdx.x; int stride = blockDim.x * gridDim.x; for (int i = tid; i < N; i += stride) c[i] = 2 * a[i] + b[i]; } int main() { int *a, *b, *c; int size = N * sizeof (int); // The total number of bytes per vector int deviceId; int numberOfSMs; hipGetDevice(&deviceId); hipDeviceGetAttribute(&numberOfSMs, hipDeviceAttributeMultiprocessorCount, deviceId); // Allocate memory hipMallocManaged(&a, size); hipMallocManaged(&b, size); hipMallocManaged(&c, size); // Initialize memory for( int i = 0; i < N; ++i ) { a[i] = 2; b[i] = 1; c[i] = 0; } hipMemPrefetchAsync(a, size, deviceId); hipMemPrefetchAsync(b, size, deviceId); hipMemPrefetchAsync(c, size, deviceId); int threads_per_block = 256; int number_of_blocks = numberOfSMs * 32; hipLaunchKernelGGL(( saxpy) , dim3(number_of_blocks), dim3(threads_per_block), 0, 0, a, b, c ); hipDeviceSynchronize(); // Wait for the GPU to finish // Print out the first and last 5 values of c for a quality check for( int i = 0; i < 5; ++i ) printf("c[%d] = %d, ", i, c[i]); printf ("\n"); for( int i = N-5; i < N; ++i ) printf("c[%d] = %d, ", i, c[i]); printf ("\n"); // Free all our allocated memory hipFree( a ); hipFree( b ); hipFree( c ); }
fe7c6249c40b7ba32d85377d87f697883c27f4ca.cu
#include <stdio.h> #define N 2048 * 2048 // Number of elements in each vector __global__ void saxpy(int * a, int * b, int * c) { // Determine our unique global thread ID, so we know which element to process int tid = blockIdx.x * blockDim.x + threadIdx.x; int stride = blockDim.x * gridDim.x; for (int i = tid; i < N; i += stride) c[i] = 2 * a[i] + b[i]; } int main() { int *a, *b, *c; int size = N * sizeof (int); // The total number of bytes per vector int deviceId; int numberOfSMs; cudaGetDevice(&deviceId); cudaDeviceGetAttribute(&numberOfSMs, cudaDevAttrMultiProcessorCount, deviceId); // Allocate memory cudaMallocManaged(&a, size); cudaMallocManaged(&b, size); cudaMallocManaged(&c, size); // Initialize memory for( int i = 0; i < N; ++i ) { a[i] = 2; b[i] = 1; c[i] = 0; } cudaMemPrefetchAsync(a, size, deviceId); cudaMemPrefetchAsync(b, size, deviceId); cudaMemPrefetchAsync(c, size, deviceId); int threads_per_block = 256; int number_of_blocks = numberOfSMs * 32; saxpy <<<number_of_blocks, threads_per_block>>>( a, b, c ); cudaDeviceSynchronize(); // Wait for the GPU to finish // Print out the first and last 5 values of c for a quality check for( int i = 0; i < 5; ++i ) printf("c[%d] = %d, ", i, c[i]); printf ("\n"); for( int i = N-5; i < N; ++i ) printf("c[%d] = %d, ", i, c[i]); printf ("\n"); // Free all our allocated memory cudaFree( a ); cudaFree( b ); cudaFree( c ); }
32be31b2be319684e770cd33e55a4c5456a17023.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include "neural_net.h" #include <time.h> template <typename T> __global__ void softmaxLossBackProp(int *y, T *SO, T *dSO, int batch_size, int output_size, float eps) { int i = blockIdx.x * blockDim.x + threadIdx.x; if (i >= batch_size) return; int cur_class = static_cast<int>(y[i]); dSO[i * output_size + cur_class] = -1 / (SO[i * output_size + cur_class] * batch_size + eps); } template <typename T> __global__ void computeSoftmaxLoss(T *O, int *y, float *loss, int batch_size, int num_classes, float eps) { int i = blockIdx.x * blockDim.x + threadIdx.x; if (i >= batch_size) return; loss[i] = -logf(O[i * num_classes + y[i]] + eps); } template <typename T> __global__ void inferClass(T *O, int *pred_y, int batch_size, int num_classes) { int i = blockIdx.x * blockDim.x + threadIdx.x; if (i >= batch_size) return; T max = O[i * num_classes]; int index = 0; for (int j = 1; j < num_classes; j++) { if (O[i * num_classes + j] > max) { max = O[i * num_classes + j]; index = j; } } pred_y[i] = index; } float NeuralNet::computeLoss() { if (layer_type[num_layers - 1] == SOFTMAX) { if (data_type == CUDNN_DATA_FLOAT) hipLaunchKernelGGL(( computeSoftmaxLoss<float>), dim3(ceil(1.0 * batch_size / BW)), dim3(BW), 0, 0, (float *)layer_input[num_layers], this->y, loss, batch_size, num_classes, softmax_eps); else if (data_type == CUDNN_DATA_DOUBLE) hipLaunchKernelGGL(( computeSoftmaxLoss<double>), dim3(ceil(1.0 * batch_size / BW)), dim3(BW), 0, 0, (double *)layer_input[num_layers], this->y, loss, batch_size, num_classes, softmax_eps); } checkCudaErrors(hipMemcpy(h_loss, loss, batch_size * sizeof(float), hipMemcpyDeviceToHost)); float total_loss = 0.0; for (int i = 0; i < batch_size; i++) total_loss += h_loss[i]; return total_loss / batch_size; } void NeuralNet::compareOutputCorrect(int *correct_count, int *y) { *correct_count = 0; if (data_type == CUDNN_DATA_FLOAT) { float *typecast_O = (float *)layer_input[num_layers - 1]; hipLaunchKernelGGL(( inferClass<float>), dim3(ceil(1.0 * batch_size / BW)), dim3(BW), 0, 0, typecast_O, pred_y, batch_size, num_classes); checkCudaErrors(hipMemcpy(h_pred_y, pred_y, batch_size * sizeof(int), hipMemcpyDeviceToHost)); for (int i = 0; i < batch_size; i++) { if (h_pred_y[i] == y[i]) *correct_count = *correct_count + 1; } } else if (data_type == CUDNN_DATA_DOUBLE) { double *typecast_O = (double *)layer_input[num_layers - 1]; hipLaunchKernelGGL(( inferClass<double>), dim3(ceil(1.0 * batch_size / BW)), dim3(BW), 0, 0, typecast_O, pred_y, batch_size, num_classes); checkCudaErrors(hipMemcpy(h_pred_y, pred_y, batch_size * sizeof(int), hipMemcpyDeviceToHost)); for (int i = 0; i < batch_size; i++) { if (h_pred_y[i] == y[i]) *correct_count = *correct_count + 1; } } } void NeuralNet::getLoss(void *X, int *y, double learning_rate, bool train, int *correct_count, float *loss) { std::vector<float> t1, t2; this->getLoss(X, y, learning_rate, t1, t2, train, correct_count, loss); } void NeuralNet::getLoss(void *X, int *y, double learning_rate, std::vector<float> &fwd_vdnn_lag, std::vector<float> &bwd_vdnn_lag, bool train, int *correct_count, float *scalar_loss) { CnmemSpace space_tracker(free_bytes); // std::cout << "here\n"; // std::cout << "Free bytes: " << free_bytes << std::endl; for (int i = 0; i < num_layers; i++) prefetched[i] = false; checkCNMEM(cnmemMalloc(&layer_input[0], layer_input_size[0] * data_type_size, NULL)); space_tracker.updateSpace(CnmemSpace::SUB, layer_input_size[0] * data_type_size); checkCudaErrors(hipMemcpy(layer_input[0], X, batch_size * input_channels * input_h * input_w * data_type_size, hipMemcpyHostToDevice)); if (train == true) { checkCudaErrors(hipMemcpy(this->y, y, batch_size * data_type_size, hipMemcpyHostToDevice)); } float alpha = 1.0, beta = 0.0; float Salpha = 1.0, Sbeta = 0.0; double Dalpha = 1.0, Dbeta = 0.0; // forward propagate for (int i = 0; i < num_layers; i++) { if (train == false && i == num_layers - 1) break; // ---------------------- vDNN start ---------------------- size_t cur_workspace_size; void *cur_workspace; // // offload if required // if (i > 0 && to_offload[i] && train == true) { // checkCudaErrors(hipMemcpyAsync(h_layer_input[i], layer_input[i], // layer_input_size[i] * data_type_size, hipMemcpyDeviceToHost, stream_memory)); // checkCudaErrors(hipEventRecord(event_offload_done[i], stream_memory)); // } lockedcnmemMalloc(&layer_input[i + 1], layer_input_size[i + 1] * data_type_size, NULL); space_tracker.updateSpace(CnmemSpace::SUB, layer_input_size[i + 1] * data_type_size); // std::cout << "Free bytes: " << free_bytes << std::endl; // ---------------------- vDNN end ------------------------ // std::cout << "here" << i << std::endl; if (layer_type[i] == CONV) { // std::cout << "conv\n"; ConvLayerParams *cur_params = (ConvLayerParams *)params[i]; cur_workspace_size = cur_params->fwd_workspace_size; lockedcnmemMalloc(&cur_workspace, cur_workspace_size, NULL); // computation checkCUDNN(cudnnConvolutionForward(cudnn_handle, &alpha, cur_params->input_tensor, layer_input[i], cur_params->filter_desc, cur_params->W, cur_params->conv_desc, cur_params->fwd_algo, cur_workspace, cur_workspace_size, &beta, cur_params->output_tensor, layer_input[i + 1])); checkCUDNN(cudnnAddTensor(cudnn_handle, &alpha, cur_params->bias_desc, cur_params->b, &alpha, cur_params->output_tensor, layer_input[i + 1])); // if activation required if (cur_params->activation_mode != ACTIVATION_NONE) { checkCUDNN(cudnnActivationForward(cudnn_handle, cur_params->actv_desc, &alpha, cur_params->output_tensor, layer_input[i + 1], &beta, cur_params->output_tensor, layer_input[i + 1])); } space_tracker.updateSpace(CnmemSpace::SUB, cur_workspace_size); // std::cout << "Free bytes: " << free_bytes << std::endl; } else if (layer_type[i] == FULLY_CONNECTED) { // std::cout << "FC\n"; FCLayerParams *cur_params = (FCLayerParams *)params[i]; // std::cout << "FChere" << i << std::endl; if (data_type == CUDNN_DATA_FLOAT) { checkCUBLAS(hipblasSgemm(cublas_handle, HIPBLAS_OP_N, HIPBLAS_OP_N, cur_params->C_out, batch_size, cur_params->C_in, &Salpha, (float *)cur_params->W, cur_params->C_out, (float *)layer_input[i], cur_params->C_in, &Sbeta, (float *)layer_input[i + 1], cur_params->C_out)); checkCUBLAS(hipblasSgemm(cublas_handle, HIPBLAS_OP_N, HIPBLAS_OP_N, cur_params->C_out, batch_size, 1, &Salpha, (float *)cur_params->b, cur_params->C_out, (float *)one_vec, 1, &Salpha, (float *)layer_input[i + 1], cur_params->C_out)); } else if (data_type == CUDNN_DATA_DOUBLE) { checkCUBLAS(hipblasDgemm(cublas_handle, HIPBLAS_OP_N, HIPBLAS_OP_N, cur_params->C_out, batch_size, cur_params->C_in, &Dalpha, (double *)cur_params->W, cur_params->C_out, (double *)layer_input[i], cur_params->C_in, &Dbeta, (double *)layer_input[i + 1], cur_params->C_out)); checkCUBLAS(hipblasDgemm(cublas_handle, HIPBLAS_OP_N, HIPBLAS_OP_N, cur_params->C_out, batch_size, 1, &Dalpha, (double *)cur_params->b, cur_params->C_out, (double *)one_vec, 1, &Dalpha, (double *)layer_input[i + 1], cur_params->C_out)); } if (cur_params->activation_mode != ACTIVATION_NONE) { checkCUDNN(cudnnActivationForward(cudnn_handle, cur_params->actv_desc, &alpha, cur_params->output_tensor, layer_input[i + 1], &beta, cur_params->output_tensor, layer_input[i + 1])); } // std::cout << "FChere" << i << std::endl; } else if (layer_type[i] == DROPOUT) { // std::cout << "Dropout\n"; DropoutLayerParams *cur_params = (DropoutLayerParams *)params[i]; checkCUDNN(cudnnDropoutForward(cudnn_handle, cur_params->dropout_desc, cur_params->input_tensor, layer_input[i], cur_params->input_tensor, layer_input[i + 1], cur_params->reserved_space, cur_params->reserved_space_size)); } else if (layer_type[i] == BATCHNORM) { // std::cout << "Batchnorm\n"; BatchNormLayerParams *cur_params = (BatchNormLayerParams *)params[i]; if (train == true) { checkCUDNN(cudnnBatchNormalizationForwardTraining(cudnn_handle, cur_params->mode, &alpha, &beta, cur_params->input_tensor, layer_input[i], cur_params->input_tensor, layer_input[i + 1], cur_params->sbmv_desc, cur_params->scale, cur_params->bias, cur_params->factor, cur_params->running_mean, cur_params->running_variance, cur_params->epsilon, cur_params->result_save_mean, cur_params->result_save_inv_var)); } else { checkCUDNN(cudnnBatchNormalizationForwardInference(cudnn_handle, cur_params->mode, &alpha, &beta, cur_params->input_tensor, layer_input[i], cur_params->input_tensor, layer_input[i + 1], cur_params->sbmv_desc, cur_params->scale, cur_params->bias, cur_params->running_mean, cur_params->running_variance, cur_params->epsilon)); } } else if (layer_type[i] == POOLING) { // std::cout << "Pooling\n"; PoolingLayerParams *cur_params = (PoolingLayerParams *)params[i]; checkCUDNN(cudnnPoolingForward(cudnn_handle, cur_params->pool_desc, &alpha, cur_params->input_tensor, layer_input[i], &beta, cur_params->output_tensor, layer_input[i + 1])); } else if (layer_type[i] == ACTV) { // std::cout << "Actv\n"; std::cout << "Panic!! ACTV wrong place\n"; exit(0); ActivationLayerParams *cur_params = (ActivationLayerParams *)params[i]; checkCUDNN(cudnnActivationForward(cudnn_handle, cur_params->actv_desc, &alpha, cur_params->input_tensor, layer_input[i], &beta, cur_params->input_tensor, layer_input[i + 1])); } else if (layer_type[i] == SOFTMAX) { // std::cout << "Softmax\n"; std::cout << "Panic!! SOFTMAX wrong place\n"; exit(0); if (train == true) { SoftmaxLayerParams *cur_params = (SoftmaxLayerParams *)params[i]; checkCUDNN(cudnnSoftmaxForward(cudnn_handle, cur_params->algo, cur_params->mode, &alpha, cur_params->input_tensor, layer_input[i], &beta, cur_params->input_tensor, layer_input[i + 1])); } } // ---------------------- vDNN start ---------------------- // synchronization // checkCudaErrors(hipDeviceSynchronize()); // if next layer is ACTV or SOFTMAX, complete that and come to synchronization // the case in above if for ACTV and SOFTMAX never occurs if (layer_type[i + 1] == SOFTMAX) { i++; if (train == true) { layer_input[i + 1] = layer_input[i]; SoftmaxLayerParams *cur_params = (SoftmaxLayerParams *)params[i]; checkCUDNN(cudnnSoftmaxForward(cudnn_handle, cur_params->algo, cur_params->mode, &alpha, cur_params->input_tensor, layer_input[i], &beta, cur_params->input_tensor, layer_input[i + 1])); } i--; } // record the point at which computation ends checkCudaErrors(hipEventRecord(event_fwd_compute_done[i], stream_compute)); if (to_offload[i] && train == true) { checkPThreadErrors(pthread_create(&thread_offload_handler[i], NULL, NeuralNet::threadOffloadHandlerHelper, (void *)(&(layer_num[i])))); checkPThreadErrors(pthread_detach(thread_offload_handler[i])); } // struct timespec start_time, end_time; checkCudaErrors(hipStreamSynchronize(stream_compute)); // if (train && to_offload[i]){ // checkPThreadErrors(pthread_create(&thread_free_layer_input[i], NULL, NeuralNet::threadOffloadHandlerHelper, (void *)(&(layer_num[i])))); // checkPThreadErrors(pthread_detach(thread_free_layer_input[i])); // } // if (train) // clock_gettime(CLOCK_MONOTONIC, &start_time); // checkCudaErrors(hipStreamSynchronize(stream_memory)); // if (train) { // clock_gettime(CLOCK_MONOTONIC, &end_time); // float lag = (end_time.tv_sec - start_time.tv_sec) * 1e3 + (end_time.tv_nsec - start_time.tv_nsec) * 1e-6; // fwd_vdnn_lag.push_back(lag); // } if (layer_type[i] == CONV) { lockedcnmemFree(cur_workspace, NULL); space_tracker.updateSpace(CnmemSpace::ADD, cur_workspace_size); } if (to_offload[i] && train == true) { // lockedcnmemFree(layer_input[i], NULL); // space_tracker.updateSpace(CnmemSpace::ADD, layer_input_size[i] * data_type_size); } if (train == false) { lockedcnmemFree(layer_input[i], NULL); space_tracker.updateSpace(CnmemSpace::ADD, layer_input_size[i] * data_type_size); } if (layer_type[i + 1] == ACTV or layer_type[i + 1] == SOFTMAX) { i = i + 1; } // ---------------------- vDNN end ------------------------ } // std::cout << "here" << std::endl; if (train == false) { compareOutputCorrect(correct_count, y); checkCNMEM(cnmemFree(layer_input[num_layers - 1], NULL)); space_tracker.updateSpace(CnmemSpace::ADD, layer_input_size[num_layers - 1] * data_type_size); return; } struct timespec start_time, end_time; clock_gettime(CLOCK_MONOTONIC, &start_time); for (int i = 0; i < num_layers; i++) { if (to_offload[i]) checkSemaphoreErrors(sem_wait(&sem_offload_done[i])); } clock_gettime(CLOCK_MONOTONIC, &end_time); float lag = (end_time.tv_sec - start_time.tv_sec) * 1e3 + (end_time.tv_nsec - start_time.tv_nsec) * 1e-6; fwd_vdnn_lag.push_back(lag); *scalar_loss = computeLoss(); // ---------------------- vDNN start ---------------------- checkCNMEM(cnmemMalloc(&dlayer_input[num_layers], batch_size * num_classes * data_type_size, NULL)); space_tracker.updateSpace(CnmemSpace::SUB, layer_input_size[num_layers] * data_type_size); // std::cout << "Free bytes: " << free_bytes << std::endl; // ---------------------- vDNN end ------------------------ if (layer_type[num_layers - 1] == SOFTMAX) { // SoftmaxLayerParams *cur_params = (SoftmaxLayerParams *)params[num_layers - 1]; if (data_type == CUDNN_DATA_FLOAT) { checkCudaErrors(hipMemset(dlayer_input[num_layers], 0, batch_size * num_classes * sizeof(float))); hipLaunchKernelGGL(( softmaxLossBackProp<float>), dim3(ceil(1.0 * batch_size / BW)), dim3(BW), 0, 0, this->y, (float *)layer_input[num_layers], (float *)dlayer_input[num_layers], batch_size, num_classes, softmax_eps); } else if (data_type == CUDNN_DATA_DOUBLE) { checkCudaErrors(hipMemset(dlayer_input[num_layers], 0, batch_size * num_classes * sizeof(double))); hipLaunchKernelGGL(( softmaxLossBackProp<double>), dim3(ceil(1.0 * batch_size / BW)), dim3(BW), 0, 0, this->y, (double *)layer_input[num_layers], (double *)dlayer_input[num_layers], batch_size, num_classes, softmax_eps); } } for (int i = num_layers - 1; i >= 0; i--) { // ---------------------- vDNN start ---------------------- int cur_filter_workspace_size, cur_data_workspace_size, cur_workspace_size; void *cur_workspace; struct timespec start_time, end_time; clock_gettime(CLOCK_MONOTONIC, &start_time); if (to_offload[i]) checkSemaphoreErrors(sem_wait(&sem_prefetch_done[i])); clock_gettime(CLOCK_MONOTONIC, &end_time); float lag = (end_time.tv_sec - start_time.tv_sec) * 1e3 + (end_time.tv_nsec - start_time.tv_nsec) * 1e-6; bwd_vdnn_lag.insert(bwd_vdnn_lag.begin(), lag); // { // int n; // std::cout << "waiting..\n"; // std::cin >> n; // } if (i > 0) { if (layer_type[i] == ACTV or layer_type[i] == SOFTMAX) { dlayer_input[i] = dlayer_input[i + 1]; } else { int layer_to_prefetch = findPrefetchLayer(i); if (layer_to_prefetch != -1) { checkCNMEM(cnmemMalloc(&layer_input[layer_to_prefetch], layer_input_size[layer_to_prefetch] * data_type_size, NULL)); space_tracker.updateSpace(CnmemSpace::SUB, layer_input_size[layer_to_prefetch] * data_type_size); // std::cout << "Free bytes: " << free_bytes << std::endl; if (layer_to_prefetch != 0) { checkCudaErrors(hipMemcpyAsync(layer_input[layer_to_prefetch], h_layer_input[layer_to_prefetch], layer_input_size[layer_to_prefetch] * data_type_size, hipMemcpyHostToDevice, stream_memory)); } else { // std::cout << "transfer here\n"; checkCudaErrors(hipMemcpyAsync(layer_input[layer_to_prefetch], X, layer_input_size[layer_to_prefetch] * data_type_size, hipMemcpyHostToDevice, stream_memory)); // std::cout << "transfer here\n"; } checkCudaErrors(hipEventRecord(event_prefetch_done[layer_to_prefetch], stream_memory)); checkPThreadErrors(pthread_create(&thread_flag_prefetch_done[layer_to_prefetch], NULL, NeuralNet::threadFlagPrefetchDoneHelper, (void *)(&(layer_num[layer_to_prefetch])))); checkPThreadErrors(pthread_detach(thread_flag_prefetch_done[layer_to_prefetch])); } checkCNMEM(cnmemMalloc(&dlayer_input[i], layer_input_size[i] * data_type_size, NULL)); space_tracker.updateSpace(CnmemSpace::SUB, layer_input_size[i] * data_type_size); } // std::cout << "Free bytes: " << free_bytes << std::endl; } // ---------------------- vDNN end ------------------------ if (layer_type[i] == CONV) { // std::cout << "here\n"; ConvLayerParams *cur_params = (ConvLayerParams *)params[i]; if (cur_params->activation_mode != ACTIVATION_NONE) { checkCUDNN(cudnnActivationBackward(cudnn_handle, cur_params->actv_desc, &alpha, cur_params->output_tensor, layer_input[i + 1], cur_params->output_tensor, dlayer_input[i + 1], cur_params->output_tensor, layer_input[i + 1], &beta, cur_params->output_tensor, dlayer_input[i + 1])); } // allocate space for derivative if (!pre_alloc_conv_derivative) { cur_params->cnmemAllocDerivatives(data_type_size, NULL); space_tracker.updateSpace(CnmemSpace::SUB, cur_params->kernel_size * data_type_size); space_tracker.updateSpace(CnmemSpace::SUB, cur_params->C_out * data_type_size); } cur_filter_workspace_size = cur_params->bwd_filter_workspace_size; if (i > 0) cur_data_workspace_size = cur_params->bwd_data_workspace_size; else cur_data_workspace_size = 0; // std::cout << "bwd cur_workspace_size: " << cur_workspace_size << std::endl; cur_workspace_size = (cur_filter_workspace_size > cur_data_workspace_size) ? cur_filter_workspace_size : cur_data_workspace_size; checkCNMEM(cnmemMalloc(&cur_workspace, cur_workspace_size, NULL)); checkCUDNN(cudnnConvolutionBackwardBias(cudnn_handle, &alpha, cur_params->output_tensor, dlayer_input[i + 1], &beta, cur_params->bias_desc, cur_params->db)); // std::cout << "neural_net: backward conv i:" << i << std::endl; checkCUDNN(cudnnConvolutionBackwardFilter(cudnn_handle, &alpha, cur_params->input_tensor, layer_input[i], cur_params->output_tensor, dlayer_input[i + 1], cur_params->conv_desc, cur_params->bwd_filter_algo, cur_workspace, cur_workspace_size, &beta, cur_params->filter_desc, cur_params->dW)); if (i > 0) checkCUDNN(cudnnConvolutionBackwardData(cudnn_handle, &alpha, cur_params->filter_desc, cur_params->W, cur_params->output_tensor, dlayer_input[i + 1], cur_params->conv_desc, cur_params->bwd_data_algo, cur_workspace, cur_workspace_size, &beta, cur_params->input_tensor, dlayer_input[i])); space_tracker.updateSpace(CnmemSpace::SUB, cur_workspace_size); // std::cout << "Free bytes: " << free_bytes << std::endl; // std::cout << "here\n"; cur_params->stepParams(cublas_handle, learning_rate); } else if (layer_type[i] == FULLY_CONNECTED) { FCLayerParams *cur_params = (FCLayerParams *)params[i]; if (cur_params->activation_mode != ACTIVATION_NONE) { checkCUDNN(cudnnActivationBackward(cudnn_handle, cur_params->actv_desc, &alpha, cur_params->output_tensor, layer_input[i + 1], cur_params->output_tensor, dlayer_input[i + 1], cur_params->output_tensor, layer_input[i + 1], &beta, cur_params->output_tensor, dlayer_input[i + 1])); } if (!pre_alloc_fc_derivative) { cur_params->cnmemAllocDerivatives(data_type_size, NULL); space_tracker.updateSpace(CnmemSpace::SUB, cur_params->weight_matrix_size * data_type_size); space_tracker.updateSpace(CnmemSpace::SUB, cur_params->C_out * data_type_size); } if (data_type == CUDNN_DATA_FLOAT) { // bias backward checkCUBLAS(hipblasSgemm(cublas_handle, HIPBLAS_OP_N, HIPBLAS_OP_N, cur_params->C_out, 1, batch_size, &Salpha, (float *)dlayer_input[i + 1], cur_params->C_out, (float *)one_vec, batch_size, &Sbeta, (float *)cur_params->db, cur_params->C_out)); // weight backward checkCUBLAS(hipblasSgemm(cublas_handle, HIPBLAS_OP_N, HIPBLAS_OP_T, cur_params->C_out, cur_params->C_in, batch_size, &Salpha, (float *)dlayer_input[i + 1], cur_params->C_out, (float *)layer_input[i], cur_params->C_in, &Sbeta, (float *)cur_params->dW, cur_params->C_out)); // data backward if (i > 0) checkCUBLAS(hipblasSgemm(cublas_handle, HIPBLAS_OP_T, HIPBLAS_OP_N, cur_params->C_in, batch_size, cur_params->C_out, &Salpha, (float *)cur_params->W, cur_params->C_out, (float *)dlayer_input[i + 1], cur_params->C_out, &Sbeta, (float *)dlayer_input[i], cur_params->C_in)); } else if (data_type == CUDNN_DATA_DOUBLE) { // bias backward checkCUBLAS(hipblasDgemm(cublas_handle, HIPBLAS_OP_N, HIPBLAS_OP_N, cur_params->C_out, 1, batch_size, &Dalpha, (double *)dlayer_input[i + 1], cur_params->C_out, (double *)one_vec, batch_size, &Dbeta, (double *)cur_params->db, cur_params->C_out)); // weight backward checkCUBLAS(hipblasDgemm(cublas_handle, HIPBLAS_OP_N, HIPBLAS_OP_T, cur_params->C_out, cur_params->C_in, batch_size, &Dalpha, (double *)dlayer_input[i + 1], cur_params->C_out, (double *)layer_input[i], cur_params->C_in, &Dbeta, (double *)cur_params->dW, cur_params->C_out)); // data backward if (i > 0) checkCUBLAS(hipblasDgemm(cublas_handle, HIPBLAS_OP_T, HIPBLAS_OP_N, cur_params->C_in, batch_size, cur_params->C_out, &Dalpha, (double *)cur_params->W, cur_params->C_out, (double *)dlayer_input[i + 1], cur_params->C_out, &Dbeta, (double *)dlayer_input[i], cur_params->C_in)); } cur_params->stepParams(cublas_handle, learning_rate); } else if (layer_type[i] == DROPOUT) { DropoutLayerParams *cur_params = (DropoutLayerParams *)params[i]; checkCUDNN(cudnnDropoutBackward(cudnn_handle, cur_params->dropout_desc, cur_params->input_tensor, dlayer_input[i + 1], cur_params->input_tensor, dlayer_input[i], cur_params->reserved_space, cur_params->reserved_space_size)); } else if (layer_type[i] == BATCHNORM) { BatchNormLayerParams *cur_params = (BatchNormLayerParams *)params[i]; if (!pre_alloc_batch_norm_derivative) { cur_params->cnmemAllocDerivatives(data_type_size, NULL); space_tracker.updateSpace(CnmemSpace::SUB, cur_params->allocation_size * data_type_size); space_tracker.updateSpace(CnmemSpace::SUB, cur_params->allocation_size * data_type_size); } checkCUDNN(cudnnBatchNormalizationBackward(cudnn_handle, cur_params->mode, &alpha, &beta, &alpha, &beta, cur_params->input_tensor, layer_input[i], cur_params->input_tensor, dlayer_input[i + 1], cur_params->input_tensor, dlayer_input[i], cur_params->sbmv_desc, cur_params->scale, cur_params->dscale, cur_params->dbias, cur_params->epsilon, cur_params->result_save_mean, cur_params->result_save_inv_var)); cur_params->stepParams(cublas_handle, learning_rate); } else if (layer_type[i] == POOLING) { PoolingLayerParams *cur_params = (PoolingLayerParams *)params[i]; checkCUDNN(cudnnPoolingBackward(cudnn_handle, cur_params->pool_desc, &alpha, cur_params->output_tensor, layer_input[i + 1], cur_params->output_tensor, dlayer_input[i + 1], cur_params->input_tensor, layer_input[i], &beta, cur_params->input_tensor, dlayer_input[i])); } else if (layer_type[i] == ACTV) { ActivationLayerParams *cur_params = (ActivationLayerParams *)params[i]; checkCUDNN(cudnnActivationBackward(cudnn_handle, cur_params->actv_desc, &alpha, cur_params->input_tensor, layer_input[i + 1], cur_params->input_tensor, dlayer_input[i + 1], cur_params->input_tensor, layer_input[i], &beta, cur_params->input_tensor, dlayer_input[i])); continue; } else if (layer_type[i] == SOFTMAX) { // std::cout << "compute here\n"; SoftmaxLayerParams *cur_params = (SoftmaxLayerParams *)params[i]; checkCUDNN(cudnnSoftmaxBackward(cudnn_handle, cur_params->algo, cur_params->mode, &alpha, cur_params->input_tensor, layer_input[i + 1], cur_params->input_tensor, dlayer_input[i + 1], &beta, cur_params->input_tensor, dlayer_input[i])); // std::cout << "compute here\n"; continue; } // ---------------------- vDNN start ---------------------- // checkCudaErrors(hipDeviceSynchronize()); // struct timespec start_time, end_time; checkCudaErrors(hipStreamSynchronize(stream_compute)); // if (train) // clock_gettime(CLOCK_MONOTONIC, &start_time); // checkCudaErrors(hipStreamSynchronize(stream_memory)); // if (train) { // clock_gettime(CLOCK_MONOTONIC, &end_time); // float lag = (end_time.tv_sec - start_time.tv_sec) * 1e3 + (end_time.tv_nsec - start_time.tv_nsec) * 1e-6; // bwd_vdnn_lag.insert(bwd_vdnn_lag.begin(), lag); // } if (layer_type[i] == CONV) { checkCNMEM(cnmemFree(cur_workspace, NULL)); space_tracker.updateSpace(CnmemSpace::ADD, cur_workspace_size); if (!pre_alloc_conv_derivative) { ConvLayerParams *cur_params = (ConvLayerParams *)params[i]; cur_params->cnmemFreeDerivatives(NULL); space_tracker.updateSpace(CnmemSpace::ADD, cur_params->kernel_size * data_type_size); space_tracker.updateSpace(CnmemSpace::ADD, cur_params->C_out * data_type_size); } } else if (layer_type[i] == FULLY_CONNECTED) { if (!pre_alloc_fc_derivative) { FCLayerParams *cur_params = (FCLayerParams *)params[i]; cur_params->cnmemFreeDerivatives(NULL); space_tracker.updateSpace(CnmemSpace::ADD, cur_params->weight_matrix_size * data_type_size); space_tracker.updateSpace(CnmemSpace::ADD, cur_params->C_out * data_type_size); } } else if (layer_type[i] == BATCHNORM) { if (train == true and !pre_alloc_batch_norm_derivative) { BatchNormLayerParams *cur_params = (BatchNormLayerParams *)params[i]; cur_params->cnmemFreeDerivatives(NULL); space_tracker.updateSpace(CnmemSpace::ADD, cur_params->allocation_size * data_type_size); space_tracker.updateSpace(CnmemSpace::ADD, cur_params->allocation_size * data_type_size); } } checkCNMEM(cnmemFree(layer_input[i + 1], NULL)); space_tracker.updateSpace(CnmemSpace::ADD, layer_input_size[i + 1] * data_type_size); checkCNMEM(cnmemFree(dlayer_input[i + 1], NULL)); space_tracker.updateSpace(CnmemSpace::ADD, layer_input_size[i + 1] * data_type_size); if (i == 0) { checkCNMEM(cnmemFree(layer_input[i], NULL)); space_tracker.updateSpace(CnmemSpace::ADD, layer_input_size[i] * data_type_size); } // ---------------------- vDNN end ------------------------ } if (space_tracker.getConsumed() != 0) { // std::cout << "Panic!! Space not updated properly\n"; } // exit(0); }
32be31b2be319684e770cd33e55a4c5456a17023.cu
#include "neural_net.h" #include <time.h> template <typename T> __global__ void softmaxLossBackProp(int *y, T *SO, T *dSO, int batch_size, int output_size, float eps) { int i = blockIdx.x * blockDim.x + threadIdx.x; if (i >= batch_size) return; int cur_class = static_cast<int>(y[i]); dSO[i * output_size + cur_class] = -1 / (SO[i * output_size + cur_class] * batch_size + eps); } template <typename T> __global__ void computeSoftmaxLoss(T *O, int *y, float *loss, int batch_size, int num_classes, float eps) { int i = blockIdx.x * blockDim.x + threadIdx.x; if (i >= batch_size) return; loss[i] = -logf(O[i * num_classes + y[i]] + eps); } template <typename T> __global__ void inferClass(T *O, int *pred_y, int batch_size, int num_classes) { int i = blockIdx.x * blockDim.x + threadIdx.x; if (i >= batch_size) return; T max = O[i * num_classes]; int index = 0; for (int j = 1; j < num_classes; j++) { if (O[i * num_classes + j] > max) { max = O[i * num_classes + j]; index = j; } } pred_y[i] = index; } float NeuralNet::computeLoss() { if (layer_type[num_layers - 1] == SOFTMAX) { if (data_type == CUDNN_DATA_FLOAT) computeSoftmaxLoss<float><<<ceil(1.0 * batch_size / BW), BW>>>((float *)layer_input[num_layers], this->y, loss, batch_size, num_classes, softmax_eps); else if (data_type == CUDNN_DATA_DOUBLE) computeSoftmaxLoss<double><<<ceil(1.0 * batch_size / BW), BW>>>((double *)layer_input[num_layers], this->y, loss, batch_size, num_classes, softmax_eps); } checkCudaErrors(cudaMemcpy(h_loss, loss, batch_size * sizeof(float), cudaMemcpyDeviceToHost)); float total_loss = 0.0; for (int i = 0; i < batch_size; i++) total_loss += h_loss[i]; return total_loss / batch_size; } void NeuralNet::compareOutputCorrect(int *correct_count, int *y) { *correct_count = 0; if (data_type == CUDNN_DATA_FLOAT) { float *typecast_O = (float *)layer_input[num_layers - 1]; inferClass<float><<<ceil(1.0 * batch_size / BW), BW>>>(typecast_O, pred_y, batch_size, num_classes); checkCudaErrors(cudaMemcpy(h_pred_y, pred_y, batch_size * sizeof(int), cudaMemcpyDeviceToHost)); for (int i = 0; i < batch_size; i++) { if (h_pred_y[i] == y[i]) *correct_count = *correct_count + 1; } } else if (data_type == CUDNN_DATA_DOUBLE) { double *typecast_O = (double *)layer_input[num_layers - 1]; inferClass<double><<<ceil(1.0 * batch_size / BW), BW>>>(typecast_O, pred_y, batch_size, num_classes); checkCudaErrors(cudaMemcpy(h_pred_y, pred_y, batch_size * sizeof(int), cudaMemcpyDeviceToHost)); for (int i = 0; i < batch_size; i++) { if (h_pred_y[i] == y[i]) *correct_count = *correct_count + 1; } } } void NeuralNet::getLoss(void *X, int *y, double learning_rate, bool train, int *correct_count, float *loss) { std::vector<float> t1, t2; this->getLoss(X, y, learning_rate, t1, t2, train, correct_count, loss); } void NeuralNet::getLoss(void *X, int *y, double learning_rate, std::vector<float> &fwd_vdnn_lag, std::vector<float> &bwd_vdnn_lag, bool train, int *correct_count, float *scalar_loss) { CnmemSpace space_tracker(free_bytes); // std::cout << "here\n"; // std::cout << "Free bytes: " << free_bytes << std::endl; for (int i = 0; i < num_layers; i++) prefetched[i] = false; checkCNMEM(cnmemMalloc(&layer_input[0], layer_input_size[0] * data_type_size, NULL)); space_tracker.updateSpace(CnmemSpace::SUB, layer_input_size[0] * data_type_size); checkCudaErrors(cudaMemcpy(layer_input[0], X, batch_size * input_channels * input_h * input_w * data_type_size, cudaMemcpyHostToDevice)); if (train == true) { checkCudaErrors(cudaMemcpy(this->y, y, batch_size * data_type_size, cudaMemcpyHostToDevice)); } float alpha = 1.0, beta = 0.0; float Salpha = 1.0, Sbeta = 0.0; double Dalpha = 1.0, Dbeta = 0.0; // forward propagate for (int i = 0; i < num_layers; i++) { if (train == false && i == num_layers - 1) break; // ---------------------- vDNN start ---------------------- size_t cur_workspace_size; void *cur_workspace; // // offload if required // if (i > 0 && to_offload[i] && train == true) { // checkCudaErrors(cudaMemcpyAsync(h_layer_input[i], layer_input[i], // layer_input_size[i] * data_type_size, cudaMemcpyDeviceToHost, stream_memory)); // checkCudaErrors(cudaEventRecord(event_offload_done[i], stream_memory)); // } lockedcnmemMalloc(&layer_input[i + 1], layer_input_size[i + 1] * data_type_size, NULL); space_tracker.updateSpace(CnmemSpace::SUB, layer_input_size[i + 1] * data_type_size); // std::cout << "Free bytes: " << free_bytes << std::endl; // ---------------------- vDNN end ------------------------ // std::cout << "here" << i << std::endl; if (layer_type[i] == CONV) { // std::cout << "conv\n"; ConvLayerParams *cur_params = (ConvLayerParams *)params[i]; cur_workspace_size = cur_params->fwd_workspace_size; lockedcnmemMalloc(&cur_workspace, cur_workspace_size, NULL); // computation checkCUDNN(cudnnConvolutionForward(cudnn_handle, &alpha, cur_params->input_tensor, layer_input[i], cur_params->filter_desc, cur_params->W, cur_params->conv_desc, cur_params->fwd_algo, cur_workspace, cur_workspace_size, &beta, cur_params->output_tensor, layer_input[i + 1])); checkCUDNN(cudnnAddTensor(cudnn_handle, &alpha, cur_params->bias_desc, cur_params->b, &alpha, cur_params->output_tensor, layer_input[i + 1])); // if activation required if (cur_params->activation_mode != ACTIVATION_NONE) { checkCUDNN(cudnnActivationForward(cudnn_handle, cur_params->actv_desc, &alpha, cur_params->output_tensor, layer_input[i + 1], &beta, cur_params->output_tensor, layer_input[i + 1])); } space_tracker.updateSpace(CnmemSpace::SUB, cur_workspace_size); // std::cout << "Free bytes: " << free_bytes << std::endl; } else if (layer_type[i] == FULLY_CONNECTED) { // std::cout << "FC\n"; FCLayerParams *cur_params = (FCLayerParams *)params[i]; // std::cout << "FChere" << i << std::endl; if (data_type == CUDNN_DATA_FLOAT) { checkCUBLAS(cublasSgemm(cublas_handle, CUBLAS_OP_N, CUBLAS_OP_N, cur_params->C_out, batch_size, cur_params->C_in, &Salpha, (float *)cur_params->W, cur_params->C_out, (float *)layer_input[i], cur_params->C_in, &Sbeta, (float *)layer_input[i + 1], cur_params->C_out)); checkCUBLAS(cublasSgemm(cublas_handle, CUBLAS_OP_N, CUBLAS_OP_N, cur_params->C_out, batch_size, 1, &Salpha, (float *)cur_params->b, cur_params->C_out, (float *)one_vec, 1, &Salpha, (float *)layer_input[i + 1], cur_params->C_out)); } else if (data_type == CUDNN_DATA_DOUBLE) { checkCUBLAS(cublasDgemm(cublas_handle, CUBLAS_OP_N, CUBLAS_OP_N, cur_params->C_out, batch_size, cur_params->C_in, &Dalpha, (double *)cur_params->W, cur_params->C_out, (double *)layer_input[i], cur_params->C_in, &Dbeta, (double *)layer_input[i + 1], cur_params->C_out)); checkCUBLAS(cublasDgemm(cublas_handle, CUBLAS_OP_N, CUBLAS_OP_N, cur_params->C_out, batch_size, 1, &Dalpha, (double *)cur_params->b, cur_params->C_out, (double *)one_vec, 1, &Dalpha, (double *)layer_input[i + 1], cur_params->C_out)); } if (cur_params->activation_mode != ACTIVATION_NONE) { checkCUDNN(cudnnActivationForward(cudnn_handle, cur_params->actv_desc, &alpha, cur_params->output_tensor, layer_input[i + 1], &beta, cur_params->output_tensor, layer_input[i + 1])); } // std::cout << "FChere" << i << std::endl; } else if (layer_type[i] == DROPOUT) { // std::cout << "Dropout\n"; DropoutLayerParams *cur_params = (DropoutLayerParams *)params[i]; checkCUDNN(cudnnDropoutForward(cudnn_handle, cur_params->dropout_desc, cur_params->input_tensor, layer_input[i], cur_params->input_tensor, layer_input[i + 1], cur_params->reserved_space, cur_params->reserved_space_size)); } else if (layer_type[i] == BATCHNORM) { // std::cout << "Batchnorm\n"; BatchNormLayerParams *cur_params = (BatchNormLayerParams *)params[i]; if (train == true) { checkCUDNN(cudnnBatchNormalizationForwardTraining(cudnn_handle, cur_params->mode, &alpha, &beta, cur_params->input_tensor, layer_input[i], cur_params->input_tensor, layer_input[i + 1], cur_params->sbmv_desc, cur_params->scale, cur_params->bias, cur_params->factor, cur_params->running_mean, cur_params->running_variance, cur_params->epsilon, cur_params->result_save_mean, cur_params->result_save_inv_var)); } else { checkCUDNN(cudnnBatchNormalizationForwardInference(cudnn_handle, cur_params->mode, &alpha, &beta, cur_params->input_tensor, layer_input[i], cur_params->input_tensor, layer_input[i + 1], cur_params->sbmv_desc, cur_params->scale, cur_params->bias, cur_params->running_mean, cur_params->running_variance, cur_params->epsilon)); } } else if (layer_type[i] == POOLING) { // std::cout << "Pooling\n"; PoolingLayerParams *cur_params = (PoolingLayerParams *)params[i]; checkCUDNN(cudnnPoolingForward(cudnn_handle, cur_params->pool_desc, &alpha, cur_params->input_tensor, layer_input[i], &beta, cur_params->output_tensor, layer_input[i + 1])); } else if (layer_type[i] == ACTV) { // std::cout << "Actv\n"; std::cout << "Panic!! ACTV wrong place\n"; exit(0); ActivationLayerParams *cur_params = (ActivationLayerParams *)params[i]; checkCUDNN(cudnnActivationForward(cudnn_handle, cur_params->actv_desc, &alpha, cur_params->input_tensor, layer_input[i], &beta, cur_params->input_tensor, layer_input[i + 1])); } else if (layer_type[i] == SOFTMAX) { // std::cout << "Softmax\n"; std::cout << "Panic!! SOFTMAX wrong place\n"; exit(0); if (train == true) { SoftmaxLayerParams *cur_params = (SoftmaxLayerParams *)params[i]; checkCUDNN(cudnnSoftmaxForward(cudnn_handle, cur_params->algo, cur_params->mode, &alpha, cur_params->input_tensor, layer_input[i], &beta, cur_params->input_tensor, layer_input[i + 1])); } } // ---------------------- vDNN start ---------------------- // synchronization // checkCudaErrors(cudaDeviceSynchronize()); // if next layer is ACTV or SOFTMAX, complete that and come to synchronization // the case in above if for ACTV and SOFTMAX never occurs if (layer_type[i + 1] == SOFTMAX) { i++; if (train == true) { layer_input[i + 1] = layer_input[i]; SoftmaxLayerParams *cur_params = (SoftmaxLayerParams *)params[i]; checkCUDNN(cudnnSoftmaxForward(cudnn_handle, cur_params->algo, cur_params->mode, &alpha, cur_params->input_tensor, layer_input[i], &beta, cur_params->input_tensor, layer_input[i + 1])); } i--; } // record the point at which computation ends checkCudaErrors(cudaEventRecord(event_fwd_compute_done[i], stream_compute)); if (to_offload[i] && train == true) { checkPThreadErrors(pthread_create(&thread_offload_handler[i], NULL, NeuralNet::threadOffloadHandlerHelper, (void *)(&(layer_num[i])))); checkPThreadErrors(pthread_detach(thread_offload_handler[i])); } // struct timespec start_time, end_time; checkCudaErrors(cudaStreamSynchronize(stream_compute)); // if (train && to_offload[i]){ // checkPThreadErrors(pthread_create(&thread_free_layer_input[i], NULL, NeuralNet::threadOffloadHandlerHelper, (void *)(&(layer_num[i])))); // checkPThreadErrors(pthread_detach(thread_free_layer_input[i])); // } // if (train) // clock_gettime(CLOCK_MONOTONIC, &start_time); // checkCudaErrors(cudaStreamSynchronize(stream_memory)); // if (train) { // clock_gettime(CLOCK_MONOTONIC, &end_time); // float lag = (end_time.tv_sec - start_time.tv_sec) * 1e3 + (end_time.tv_nsec - start_time.tv_nsec) * 1e-6; // fwd_vdnn_lag.push_back(lag); // } if (layer_type[i] == CONV) { lockedcnmemFree(cur_workspace, NULL); space_tracker.updateSpace(CnmemSpace::ADD, cur_workspace_size); } if (to_offload[i] && train == true) { // lockedcnmemFree(layer_input[i], NULL); // space_tracker.updateSpace(CnmemSpace::ADD, layer_input_size[i] * data_type_size); } if (train == false) { lockedcnmemFree(layer_input[i], NULL); space_tracker.updateSpace(CnmemSpace::ADD, layer_input_size[i] * data_type_size); } if (layer_type[i + 1] == ACTV or layer_type[i + 1] == SOFTMAX) { i = i + 1; } // ---------------------- vDNN end ------------------------ } // std::cout << "here" << std::endl; if (train == false) { compareOutputCorrect(correct_count, y); checkCNMEM(cnmemFree(layer_input[num_layers - 1], NULL)); space_tracker.updateSpace(CnmemSpace::ADD, layer_input_size[num_layers - 1] * data_type_size); return; } struct timespec start_time, end_time; clock_gettime(CLOCK_MONOTONIC, &start_time); for (int i = 0; i < num_layers; i++) { if (to_offload[i]) checkSemaphoreErrors(sem_wait(&sem_offload_done[i])); } clock_gettime(CLOCK_MONOTONIC, &end_time); float lag = (end_time.tv_sec - start_time.tv_sec) * 1e3 + (end_time.tv_nsec - start_time.tv_nsec) * 1e-6; fwd_vdnn_lag.push_back(lag); *scalar_loss = computeLoss(); // ---------------------- vDNN start ---------------------- checkCNMEM(cnmemMalloc(&dlayer_input[num_layers], batch_size * num_classes * data_type_size, NULL)); space_tracker.updateSpace(CnmemSpace::SUB, layer_input_size[num_layers] * data_type_size); // std::cout << "Free bytes: " << free_bytes << std::endl; // ---------------------- vDNN end ------------------------ if (layer_type[num_layers - 1] == SOFTMAX) { // SoftmaxLayerParams *cur_params = (SoftmaxLayerParams *)params[num_layers - 1]; if (data_type == CUDNN_DATA_FLOAT) { checkCudaErrors(cudaMemset(dlayer_input[num_layers], 0, batch_size * num_classes * sizeof(float))); softmaxLossBackProp<float><<<ceil(1.0 * batch_size / BW), BW>>>(this->y, (float *)layer_input[num_layers], (float *)dlayer_input[num_layers], batch_size, num_classes, softmax_eps); } else if (data_type == CUDNN_DATA_DOUBLE) { checkCudaErrors(cudaMemset(dlayer_input[num_layers], 0, batch_size * num_classes * sizeof(double))); softmaxLossBackProp<double><<<ceil(1.0 * batch_size / BW), BW>>>(this->y, (double *)layer_input[num_layers], (double *)dlayer_input[num_layers], batch_size, num_classes, softmax_eps); } } for (int i = num_layers - 1; i >= 0; i--) { // ---------------------- vDNN start ---------------------- int cur_filter_workspace_size, cur_data_workspace_size, cur_workspace_size; void *cur_workspace; struct timespec start_time, end_time; clock_gettime(CLOCK_MONOTONIC, &start_time); if (to_offload[i]) checkSemaphoreErrors(sem_wait(&sem_prefetch_done[i])); clock_gettime(CLOCK_MONOTONIC, &end_time); float lag = (end_time.tv_sec - start_time.tv_sec) * 1e3 + (end_time.tv_nsec - start_time.tv_nsec) * 1e-6; bwd_vdnn_lag.insert(bwd_vdnn_lag.begin(), lag); // { // int n; // std::cout << "waiting..\n"; // std::cin >> n; // } if (i > 0) { if (layer_type[i] == ACTV or layer_type[i] == SOFTMAX) { dlayer_input[i] = dlayer_input[i + 1]; } else { int layer_to_prefetch = findPrefetchLayer(i); if (layer_to_prefetch != -1) { checkCNMEM(cnmemMalloc(&layer_input[layer_to_prefetch], layer_input_size[layer_to_prefetch] * data_type_size, NULL)); space_tracker.updateSpace(CnmemSpace::SUB, layer_input_size[layer_to_prefetch] * data_type_size); // std::cout << "Free bytes: " << free_bytes << std::endl; if (layer_to_prefetch != 0) { checkCudaErrors(cudaMemcpyAsync(layer_input[layer_to_prefetch], h_layer_input[layer_to_prefetch], layer_input_size[layer_to_prefetch] * data_type_size, cudaMemcpyHostToDevice, stream_memory)); } else { // std::cout << "transfer here\n"; checkCudaErrors(cudaMemcpyAsync(layer_input[layer_to_prefetch], X, layer_input_size[layer_to_prefetch] * data_type_size, cudaMemcpyHostToDevice, stream_memory)); // std::cout << "transfer here\n"; } checkCudaErrors(cudaEventRecord(event_prefetch_done[layer_to_prefetch], stream_memory)); checkPThreadErrors(pthread_create(&thread_flag_prefetch_done[layer_to_prefetch], NULL, NeuralNet::threadFlagPrefetchDoneHelper, (void *)(&(layer_num[layer_to_prefetch])))); checkPThreadErrors(pthread_detach(thread_flag_prefetch_done[layer_to_prefetch])); } checkCNMEM(cnmemMalloc(&dlayer_input[i], layer_input_size[i] * data_type_size, NULL)); space_tracker.updateSpace(CnmemSpace::SUB, layer_input_size[i] * data_type_size); } // std::cout << "Free bytes: " << free_bytes << std::endl; } // ---------------------- vDNN end ------------------------ if (layer_type[i] == CONV) { // std::cout << "here\n"; ConvLayerParams *cur_params = (ConvLayerParams *)params[i]; if (cur_params->activation_mode != ACTIVATION_NONE) { checkCUDNN(cudnnActivationBackward(cudnn_handle, cur_params->actv_desc, &alpha, cur_params->output_tensor, layer_input[i + 1], cur_params->output_tensor, dlayer_input[i + 1], cur_params->output_tensor, layer_input[i + 1], &beta, cur_params->output_tensor, dlayer_input[i + 1])); } // allocate space for derivative if (!pre_alloc_conv_derivative) { cur_params->cnmemAllocDerivatives(data_type_size, NULL); space_tracker.updateSpace(CnmemSpace::SUB, cur_params->kernel_size * data_type_size); space_tracker.updateSpace(CnmemSpace::SUB, cur_params->C_out * data_type_size); } cur_filter_workspace_size = cur_params->bwd_filter_workspace_size; if (i > 0) cur_data_workspace_size = cur_params->bwd_data_workspace_size; else cur_data_workspace_size = 0; // std::cout << "bwd cur_workspace_size: " << cur_workspace_size << std::endl; cur_workspace_size = (cur_filter_workspace_size > cur_data_workspace_size) ? cur_filter_workspace_size : cur_data_workspace_size; checkCNMEM(cnmemMalloc(&cur_workspace, cur_workspace_size, NULL)); checkCUDNN(cudnnConvolutionBackwardBias(cudnn_handle, &alpha, cur_params->output_tensor, dlayer_input[i + 1], &beta, cur_params->bias_desc, cur_params->db)); // std::cout << "neural_net: backward conv i:" << i << std::endl; checkCUDNN(cudnnConvolutionBackwardFilter(cudnn_handle, &alpha, cur_params->input_tensor, layer_input[i], cur_params->output_tensor, dlayer_input[i + 1], cur_params->conv_desc, cur_params->bwd_filter_algo, cur_workspace, cur_workspace_size, &beta, cur_params->filter_desc, cur_params->dW)); if (i > 0) checkCUDNN(cudnnConvolutionBackwardData(cudnn_handle, &alpha, cur_params->filter_desc, cur_params->W, cur_params->output_tensor, dlayer_input[i + 1], cur_params->conv_desc, cur_params->bwd_data_algo, cur_workspace, cur_workspace_size, &beta, cur_params->input_tensor, dlayer_input[i])); space_tracker.updateSpace(CnmemSpace::SUB, cur_workspace_size); // std::cout << "Free bytes: " << free_bytes << std::endl; // std::cout << "here\n"; cur_params->stepParams(cublas_handle, learning_rate); } else if (layer_type[i] == FULLY_CONNECTED) { FCLayerParams *cur_params = (FCLayerParams *)params[i]; if (cur_params->activation_mode != ACTIVATION_NONE) { checkCUDNN(cudnnActivationBackward(cudnn_handle, cur_params->actv_desc, &alpha, cur_params->output_tensor, layer_input[i + 1], cur_params->output_tensor, dlayer_input[i + 1], cur_params->output_tensor, layer_input[i + 1], &beta, cur_params->output_tensor, dlayer_input[i + 1])); } if (!pre_alloc_fc_derivative) { cur_params->cnmemAllocDerivatives(data_type_size, NULL); space_tracker.updateSpace(CnmemSpace::SUB, cur_params->weight_matrix_size * data_type_size); space_tracker.updateSpace(CnmemSpace::SUB, cur_params->C_out * data_type_size); } if (data_type == CUDNN_DATA_FLOAT) { // bias backward checkCUBLAS(cublasSgemm(cublas_handle, CUBLAS_OP_N, CUBLAS_OP_N, cur_params->C_out, 1, batch_size, &Salpha, (float *)dlayer_input[i + 1], cur_params->C_out, (float *)one_vec, batch_size, &Sbeta, (float *)cur_params->db, cur_params->C_out)); // weight backward checkCUBLAS(cublasSgemm(cublas_handle, CUBLAS_OP_N, CUBLAS_OP_T, cur_params->C_out, cur_params->C_in, batch_size, &Salpha, (float *)dlayer_input[i + 1], cur_params->C_out, (float *)layer_input[i], cur_params->C_in, &Sbeta, (float *)cur_params->dW, cur_params->C_out)); // data backward if (i > 0) checkCUBLAS(cublasSgemm(cublas_handle, CUBLAS_OP_T, CUBLAS_OP_N, cur_params->C_in, batch_size, cur_params->C_out, &Salpha, (float *)cur_params->W, cur_params->C_out, (float *)dlayer_input[i + 1], cur_params->C_out, &Sbeta, (float *)dlayer_input[i], cur_params->C_in)); } else if (data_type == CUDNN_DATA_DOUBLE) { // bias backward checkCUBLAS(cublasDgemm(cublas_handle, CUBLAS_OP_N, CUBLAS_OP_N, cur_params->C_out, 1, batch_size, &Dalpha, (double *)dlayer_input[i + 1], cur_params->C_out, (double *)one_vec, batch_size, &Dbeta, (double *)cur_params->db, cur_params->C_out)); // weight backward checkCUBLAS(cublasDgemm(cublas_handle, CUBLAS_OP_N, CUBLAS_OP_T, cur_params->C_out, cur_params->C_in, batch_size, &Dalpha, (double *)dlayer_input[i + 1], cur_params->C_out, (double *)layer_input[i], cur_params->C_in, &Dbeta, (double *)cur_params->dW, cur_params->C_out)); // data backward if (i > 0) checkCUBLAS(cublasDgemm(cublas_handle, CUBLAS_OP_T, CUBLAS_OP_N, cur_params->C_in, batch_size, cur_params->C_out, &Dalpha, (double *)cur_params->W, cur_params->C_out, (double *)dlayer_input[i + 1], cur_params->C_out, &Dbeta, (double *)dlayer_input[i], cur_params->C_in)); } cur_params->stepParams(cublas_handle, learning_rate); } else if (layer_type[i] == DROPOUT) { DropoutLayerParams *cur_params = (DropoutLayerParams *)params[i]; checkCUDNN(cudnnDropoutBackward(cudnn_handle, cur_params->dropout_desc, cur_params->input_tensor, dlayer_input[i + 1], cur_params->input_tensor, dlayer_input[i], cur_params->reserved_space, cur_params->reserved_space_size)); } else if (layer_type[i] == BATCHNORM) { BatchNormLayerParams *cur_params = (BatchNormLayerParams *)params[i]; if (!pre_alloc_batch_norm_derivative) { cur_params->cnmemAllocDerivatives(data_type_size, NULL); space_tracker.updateSpace(CnmemSpace::SUB, cur_params->allocation_size * data_type_size); space_tracker.updateSpace(CnmemSpace::SUB, cur_params->allocation_size * data_type_size); } checkCUDNN(cudnnBatchNormalizationBackward(cudnn_handle, cur_params->mode, &alpha, &beta, &alpha, &beta, cur_params->input_tensor, layer_input[i], cur_params->input_tensor, dlayer_input[i + 1], cur_params->input_tensor, dlayer_input[i], cur_params->sbmv_desc, cur_params->scale, cur_params->dscale, cur_params->dbias, cur_params->epsilon, cur_params->result_save_mean, cur_params->result_save_inv_var)); cur_params->stepParams(cublas_handle, learning_rate); } else if (layer_type[i] == POOLING) { PoolingLayerParams *cur_params = (PoolingLayerParams *)params[i]; checkCUDNN(cudnnPoolingBackward(cudnn_handle, cur_params->pool_desc, &alpha, cur_params->output_tensor, layer_input[i + 1], cur_params->output_tensor, dlayer_input[i + 1], cur_params->input_tensor, layer_input[i], &beta, cur_params->input_tensor, dlayer_input[i])); } else if (layer_type[i] == ACTV) { ActivationLayerParams *cur_params = (ActivationLayerParams *)params[i]; checkCUDNN(cudnnActivationBackward(cudnn_handle, cur_params->actv_desc, &alpha, cur_params->input_tensor, layer_input[i + 1], cur_params->input_tensor, dlayer_input[i + 1], cur_params->input_tensor, layer_input[i], &beta, cur_params->input_tensor, dlayer_input[i])); continue; } else if (layer_type[i] == SOFTMAX) { // std::cout << "compute here\n"; SoftmaxLayerParams *cur_params = (SoftmaxLayerParams *)params[i]; checkCUDNN(cudnnSoftmaxBackward(cudnn_handle, cur_params->algo, cur_params->mode, &alpha, cur_params->input_tensor, layer_input[i + 1], cur_params->input_tensor, dlayer_input[i + 1], &beta, cur_params->input_tensor, dlayer_input[i])); // std::cout << "compute here\n"; continue; } // ---------------------- vDNN start ---------------------- // checkCudaErrors(cudaDeviceSynchronize()); // struct timespec start_time, end_time; checkCudaErrors(cudaStreamSynchronize(stream_compute)); // if (train) // clock_gettime(CLOCK_MONOTONIC, &start_time); // checkCudaErrors(cudaStreamSynchronize(stream_memory)); // if (train) { // clock_gettime(CLOCK_MONOTONIC, &end_time); // float lag = (end_time.tv_sec - start_time.tv_sec) * 1e3 + (end_time.tv_nsec - start_time.tv_nsec) * 1e-6; // bwd_vdnn_lag.insert(bwd_vdnn_lag.begin(), lag); // } if (layer_type[i] == CONV) { checkCNMEM(cnmemFree(cur_workspace, NULL)); space_tracker.updateSpace(CnmemSpace::ADD, cur_workspace_size); if (!pre_alloc_conv_derivative) { ConvLayerParams *cur_params = (ConvLayerParams *)params[i]; cur_params->cnmemFreeDerivatives(NULL); space_tracker.updateSpace(CnmemSpace::ADD, cur_params->kernel_size * data_type_size); space_tracker.updateSpace(CnmemSpace::ADD, cur_params->C_out * data_type_size); } } else if (layer_type[i] == FULLY_CONNECTED) { if (!pre_alloc_fc_derivative) { FCLayerParams *cur_params = (FCLayerParams *)params[i]; cur_params->cnmemFreeDerivatives(NULL); space_tracker.updateSpace(CnmemSpace::ADD, cur_params->weight_matrix_size * data_type_size); space_tracker.updateSpace(CnmemSpace::ADD, cur_params->C_out * data_type_size); } } else if (layer_type[i] == BATCHNORM) { if (train == true and !pre_alloc_batch_norm_derivative) { BatchNormLayerParams *cur_params = (BatchNormLayerParams *)params[i]; cur_params->cnmemFreeDerivatives(NULL); space_tracker.updateSpace(CnmemSpace::ADD, cur_params->allocation_size * data_type_size); space_tracker.updateSpace(CnmemSpace::ADD, cur_params->allocation_size * data_type_size); } } checkCNMEM(cnmemFree(layer_input[i + 1], NULL)); space_tracker.updateSpace(CnmemSpace::ADD, layer_input_size[i + 1] * data_type_size); checkCNMEM(cnmemFree(dlayer_input[i + 1], NULL)); space_tracker.updateSpace(CnmemSpace::ADD, layer_input_size[i + 1] * data_type_size); if (i == 0) { checkCNMEM(cnmemFree(layer_input[i], NULL)); space_tracker.updateSpace(CnmemSpace::ADD, layer_input_size[i] * data_type_size); } // ---------------------- vDNN end ------------------------ } if (space_tracker.getConsumed() != 0) { // std::cout << "Panic!! Space not updated properly\n"; } // exit(0); }
456a59dc1713b61a0f4ddacd952aeec5a5dfe542.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" __global__ void getSum_kernel(float *g_idata, float *result, long long n) { //load shared_mem unsigned int THREAD_NUM = blockDim.x; extern __shared__ float sdata[]; unsigned int tid = threadIdx.x; sdata[tid] = 0.0f; for (long long i=tid; i<n; i+=THREAD_NUM) sdata[tid] += g_idata[i]; __syncthreads(); unsigned int k = THREAD_NUM/2; while (k>0) { if (tid<k) sdata[tid]+=sdata[tid+k]; k = k/2; __syncthreads(); } if (tid == 0) result[0] = sdata[0]; // __syncthreads(); } __global__ void L2_norm_kernel(float *d_1, float *d_2) { long long i = blockIdx.z*blockDim.x*gridDim.x*gridDim.y + blockIdx.y* blockDim.x*gridDim.x + blockIdx.x*blockDim.x + threadIdx.x; d_1[i] = (d_1[i]-d_2[i])*(d_1[i]-d_2[i]); } __global__ void TV_norm_kernel(float *d_TV, float *d_volume) { int x = threadIdx.x + blockIdx.x * blockDim.x; int y = blockIdx.y; int z = blockIdx.z; unsigned int i = z* M*N + y*M + x; unsigned int j = z* M*N + y*M + (x+1); unsigned int k = z* M*N + (y+1)*M + x; unsigned int l = (z+1)* M*N + y*M + x; if ((threadIdx.x<M-1)&&(blockIdx.x<N-1)&&(blockIdx.y<ZETA-1)) d_TV[i]=sqrt( (d_volume[i]-d_volume[j])*(d_volume[i]-d_volume[j])+(d_volume[i]-d_volume[k])*(d_volume[i]-d_volume[k])+(d_volume[i]-d_volume[l])*(d_volume[i]-d_volume[l]) ); else if ((threadIdx.x==M-1)&&(blockIdx.x<N-1)&&(blockIdx.y<ZETA-1)) d_TV[i]=sqrt( (d_volume[i]-d_volume[k])*(d_volume[i]-d_volume[k])+(d_volume[i]-d_volume[l])*(d_volume[i]-d_volume[l]) ); else if ((threadIdx.x<M-1)&&(blockIdx.x==N-1)&&(blockIdx.y<ZETA-1)) d_TV[i]=sqrt( (d_volume[i]-d_volume[j])*(d_volume[i]-d_volume[j])+(d_volume[i]-d_volume[l])*(d_volume[i]-d_volume[l]) ); else if ((threadIdx.x<M-1)&&(blockIdx.x<N-1)&&(blockIdx.y==ZETA-1)) d_TV[i]=sqrt( (d_volume[i]-d_volume[j])*(d_volume[i]-d_volume[j])+(d_volume[i]-d_volume[k])*(d_volume[i]-d_volume[k]) ); else if ((threadIdx.x==M-1)&&(blockIdx.x==N-1)&&(blockIdx.y<ZETA-1)) d_TV[i]=abs( d_volume[i]-d_volume[l]); else if ((threadIdx.x==M-1)&&(blockIdx.x<N-1)&&(blockIdx.y==ZETA-1)) d_TV[i]=abs( d_volume[i]-d_volume[k]); else if ((threadIdx.x<M-1)&&(blockIdx.x==N-1)&&(blockIdx.y==ZETA-1)) d_TV[i]=abs( d_volume[i]-d_volume[j]); } __global__ void substract_3d_kernel(float *d_1, float *d_2, float *d_result) { long i = blockIdx.y* blockDim.x*gridDim.x + blockIdx.x*blockDim.x + threadIdx.x; d_result[i] = d_1[i] -d_2[i]; }
456a59dc1713b61a0f4ddacd952aeec5a5dfe542.cu
__global__ void getSum_kernel(float *g_idata, float *result, long long n) { //load shared_mem unsigned int THREAD_NUM = blockDim.x; extern __shared__ float sdata[]; unsigned int tid = threadIdx.x; sdata[tid] = 0.0f; for (long long i=tid; i<n; i+=THREAD_NUM) sdata[tid] += g_idata[i]; __syncthreads(); unsigned int k = THREAD_NUM/2; while (k>0) { if (tid<k) sdata[tid]+=sdata[tid+k]; k = k/2; __syncthreads(); } if (tid == 0) result[0] = sdata[0]; // __syncthreads(); } __global__ void L2_norm_kernel(float *d_1, float *d_2) { long long i = blockIdx.z*blockDim.x*gridDim.x*gridDim.y + blockIdx.y* blockDim.x*gridDim.x + blockIdx.x*blockDim.x + threadIdx.x; d_1[i] = (d_1[i]-d_2[i])*(d_1[i]-d_2[i]); } __global__ void TV_norm_kernel(float *d_TV, float *d_volume) { int x = threadIdx.x + blockIdx.x * blockDim.x; int y = blockIdx.y; int z = blockIdx.z; unsigned int i = z* M*N + y*M + x; unsigned int j = z* M*N + y*M + (x+1); unsigned int k = z* M*N + (y+1)*M + x; unsigned int l = (z+1)* M*N + y*M + x; if ((threadIdx.x<M-1)&&(blockIdx.x<N-1)&&(blockIdx.y<ZETA-1)) d_TV[i]=sqrt( (d_volume[i]-d_volume[j])*(d_volume[i]-d_volume[j])+(d_volume[i]-d_volume[k])*(d_volume[i]-d_volume[k])+(d_volume[i]-d_volume[l])*(d_volume[i]-d_volume[l]) ); else if ((threadIdx.x==M-1)&&(blockIdx.x<N-1)&&(blockIdx.y<ZETA-1)) d_TV[i]=sqrt( (d_volume[i]-d_volume[k])*(d_volume[i]-d_volume[k])+(d_volume[i]-d_volume[l])*(d_volume[i]-d_volume[l]) ); else if ((threadIdx.x<M-1)&&(blockIdx.x==N-1)&&(blockIdx.y<ZETA-1)) d_TV[i]=sqrt( (d_volume[i]-d_volume[j])*(d_volume[i]-d_volume[j])+(d_volume[i]-d_volume[l])*(d_volume[i]-d_volume[l]) ); else if ((threadIdx.x<M-1)&&(blockIdx.x<N-1)&&(blockIdx.y==ZETA-1)) d_TV[i]=sqrt( (d_volume[i]-d_volume[j])*(d_volume[i]-d_volume[j])+(d_volume[i]-d_volume[k])*(d_volume[i]-d_volume[k]) ); else if ((threadIdx.x==M-1)&&(blockIdx.x==N-1)&&(blockIdx.y<ZETA-1)) d_TV[i]=abs( d_volume[i]-d_volume[l]); else if ((threadIdx.x==M-1)&&(blockIdx.x<N-1)&&(blockIdx.y==ZETA-1)) d_TV[i]=abs( d_volume[i]-d_volume[k]); else if ((threadIdx.x<M-1)&&(blockIdx.x==N-1)&&(blockIdx.y==ZETA-1)) d_TV[i]=abs( d_volume[i]-d_volume[j]); } __global__ void substract_3d_kernel(float *d_1, float *d_2, float *d_result) { long i = blockIdx.y* blockDim.x*gridDim.x + blockIdx.x*blockDim.x + threadIdx.x; d_result[i] = d_1[i] -d_2[i]; }
99001e90d35656bae69d2e071fd3b71abab50010.hip
// !!! This is a file automatically generated by hipify!!! #include <stdbool.h> #include <stdio.h> #include <string.h> #include <getopt.h> #include <hiprand/hiprand_kernel.h> #include <stdlib.h> #include <hip/hip_runtime.h> #include <sys/time.h> #include "rowNorm_a.cu" #include<chrono> #include<iostream> using namespace std; using namespace std::chrono; int blocks_[20][2] = {{8,8},{16,16},{24,24},{32,32},{1,64},{1,128},{1,192},{1,256},{1,320},{1,384},{1,448},{1,512},{1,576},{1,640},{1,704},{1,768},{1,832},{1,896},{1,960},{1,1024}}; int matrices_[7][2] = {{240,240},{496,496},{784,784},{1016,1016},{1232,1232},{1680,1680},{2024,2024}}; int main(int argc, char **argv) { hipSetDevice(0); char* p;int matrix_len=strtol(argv[1], &p, 10); for(int matrix_looper=0;matrix_looper<matrix_len;matrix_looper++){ for(int block_looper=0;block_looper<20;block_looper++){ int XSIZE=matrices_[matrix_looper][0],YSIZE=matrices_[matrix_looper][1],BLOCKX=blocks_[block_looper][0],BLOCKY=blocks_[block_looper][1]; float *X = NULL; hipMalloc(&X, XSIZE*YSIZE); float *v = NULL; hipMalloc(&v, XSIZE*YSIZE); float *a = NULL; hipMalloc(&a, XSIZE*YSIZE); unsigned int size = 1; unsigned int n = 1; int iXSIZE= XSIZE; int iYSIZE= YSIZE; while(iXSIZE%BLOCKX!=0) { iXSIZE++; } while(iYSIZE%BLOCKY!=0) { iYSIZE++; } dim3 gridBlock(iXSIZE/BLOCKX, iYSIZE/BLOCKY); dim3 threadBlock(BLOCKX, BLOCKY); hipFree(0);hipLaunchKernelGGL(( rowNorm_a), dim3(gridBlock),dim3(threadBlock), 0, 0, X,v,a,size,n); hipDeviceSynchronize(); for (int loop_counter = 0; loop_counter < 10; ++loop_counter) {hipLaunchKernelGGL(( rowNorm_a), dim3(gridBlock),dim3(threadBlock), 0, 0, X,v,a,size,n); } auto start = steady_clock::now(); for (int loop_counter = 0; loop_counter < 1000; loop_counter++) {hipLaunchKernelGGL(( rowNorm_a), dim3(gridBlock),dim3(threadBlock), 0, 0, X,v,a,size,n); } auto end = steady_clock::now(); auto usecs = duration_cast<duration<float, microseconds::period> >(end - start); cout <<'['<<usecs.count()<<','<<'('<<BLOCKX<<','<<BLOCKY<<')' << ','<<'('<<XSIZE<<','<<YSIZE<<')'<<']' << endl; } }}
99001e90d35656bae69d2e071fd3b71abab50010.cu
#include <stdbool.h> #include <stdio.h> #include <string.h> #include <getopt.h> #include <curand_kernel.h> #include <stdlib.h> #include <cuda.h> #include <sys/time.h> #include "rowNorm_a.cu" #include<chrono> #include<iostream> using namespace std; using namespace std::chrono; int blocks_[20][2] = {{8,8},{16,16},{24,24},{32,32},{1,64},{1,128},{1,192},{1,256},{1,320},{1,384},{1,448},{1,512},{1,576},{1,640},{1,704},{1,768},{1,832},{1,896},{1,960},{1,1024}}; int matrices_[7][2] = {{240,240},{496,496},{784,784},{1016,1016},{1232,1232},{1680,1680},{2024,2024}}; int main(int argc, char **argv) { cudaSetDevice(0); char* p;int matrix_len=strtol(argv[1], &p, 10); for(int matrix_looper=0;matrix_looper<matrix_len;matrix_looper++){ for(int block_looper=0;block_looper<20;block_looper++){ int XSIZE=matrices_[matrix_looper][0],YSIZE=matrices_[matrix_looper][1],BLOCKX=blocks_[block_looper][0],BLOCKY=blocks_[block_looper][1]; float *X = NULL; cudaMalloc(&X, XSIZE*YSIZE); float *v = NULL; cudaMalloc(&v, XSIZE*YSIZE); float *a = NULL; cudaMalloc(&a, XSIZE*YSIZE); unsigned int size = 1; unsigned int n = 1; int iXSIZE= XSIZE; int iYSIZE= YSIZE; while(iXSIZE%BLOCKX!=0) { iXSIZE++; } while(iYSIZE%BLOCKY!=0) { iYSIZE++; } dim3 gridBlock(iXSIZE/BLOCKX, iYSIZE/BLOCKY); dim3 threadBlock(BLOCKX, BLOCKY); cudaFree(0); rowNorm_a<<<gridBlock,threadBlock>>>(X,v,a,size,n); cudaDeviceSynchronize(); for (int loop_counter = 0; loop_counter < 10; ++loop_counter) { rowNorm_a<<<gridBlock,threadBlock>>>(X,v,a,size,n); } auto start = steady_clock::now(); for (int loop_counter = 0; loop_counter < 1000; loop_counter++) { rowNorm_a<<<gridBlock,threadBlock>>>(X,v,a,size,n); } auto end = steady_clock::now(); auto usecs = duration_cast<duration<float, microseconds::period> >(end - start); cout <<'['<<usecs.count()<<','<<'('<<BLOCKX<<','<<BLOCKY<<')' << ','<<'('<<XSIZE<<','<<YSIZE<<')'<<']' << endl; } }}
389a7a3652f516d90485dc820fcb27c5c6a08b3c.hip
// !!! This is a file automatically generated by hipify!!! /* * Copyright (c) 2018, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <gtest/gtest.h> #include <vector> #include "random/rng.h" #include "test_utils.h" #include <cuda_utils.h> #include "ml_utils.h" #include "pca/pca.h" #include <linalg/cublas_wrappers.h> namespace ML { using namespace MLCommon; template<typename T> struct PcaInputs { T tolerance; int len; int n_row; int n_col; int len2; int n_row2; int n_col2; unsigned long long int seed; int algo; bool whiten; }; template<typename T> ::std::ostream& operator<<(::std::ostream& os, const PcaInputs<T>& dims) { return os; } template<typename T> class PcaTest: public ::testing::TestWithParam<PcaInputs<T> > { protected: void basicTest() { hipblasHandle_t cublas_handle; CUBLAS_CHECK(hipblasCreate(&cublas_handle)); hipsolverDnHandle_t cusolver_handle = NULL; CUSOLVER_CHECK(hipsolverDnCreate(&cusolver_handle)); params = ::testing::TestWithParam<PcaInputs<T>>::GetParam(); Random::Rng<T> r(params.seed, MLCommon::Random::GenTaps); int len = params.len; allocate(data, len); allocate(data_back, len); allocate(trans_data, len); allocate(trans_data_ref, len); std::vector<T> data_h = { 1.0, 2.0, 5.0, 4.0, 2.0, 1.0 }; data_h.resize(len); updateDevice(data, data_h.data(), len); std::vector<T> trans_data_ref_h = { -2.3231, -0.3517, 2.6748, -0.3979, 0.6571, -0.2592 }; trans_data_ref_h.resize(len); updateDevice(trans_data_ref, trans_data_ref_h.data(), len); int len_comp = params.n_col * params.n_col; allocate(components, len_comp); allocate(explained_vars, params.n_col); allocate(explained_var_ratio, params.n_col); allocate(singular_vals, params.n_col); allocate(mean, params.n_col); allocate(noise_vars, 1); std::vector<T> components_ref_h = { 0.8163, 0.5776, -0.5776, 0.8163 }; components_ref_h.resize(len_comp); std::vector<T> explained_vars_ref_h = { 6.338, 0.3287 }; explained_vars_ref_h.resize(params.n_col); allocate(components_ref, len_comp); allocate(explained_vars_ref, params.n_col); updateDevice(components_ref, components_ref_h.data(), len_comp); updateDevice(explained_vars_ref, explained_vars_ref_h.data(), params.n_col); paramsPCA prms; prms.n_cols = params.n_col; prms.n_rows = params.n_row; prms.n_components = params.n_col; prms.whiten = false; if (params.algo == 0) prms.algorithm = solver::COV_EIG_DQ; else prms.algorithm = solver::COV_EIG_JACOBI; pcaFit(data, components, explained_vars, explained_var_ratio, singular_vals, mean, noise_vars, prms, cublas_handle, cusolver_handle); pcaTransform(data, components, trans_data, singular_vals, mean, prms, cublas_handle); pcaInverseTransform(trans_data, components, singular_vals, mean, data_back, prms, cublas_handle); CUBLAS_CHECK(hipblasDestroy(cublas_handle)); CUSOLVER_CHECK(hipsolverDnDestroy(cusolver_handle)); } void advancedTest() { hipblasHandle_t cublas_handle; CUBLAS_CHECK(hipblasCreate(&cublas_handle)); hipsolverDnHandle_t cusolver_handle = NULL; CUSOLVER_CHECK(hipsolverDnCreate(&cusolver_handle)); params = ::testing::TestWithParam<PcaInputs<T>>::GetParam(); Random::Rng<T> r(params.seed, MLCommon::Random::GenTaps); int len = params.len2; paramsPCA prms; prms.n_cols = params.n_col2; prms.n_rows = params.n_row2; prms.n_components = params.n_col2; prms.whiten = params.whiten; if (params.algo == 0) prms.algorithm = solver::COV_EIG_DQ; else if (params.algo == 1) prms.algorithm = solver::COV_EIG_JACOBI; else if (params.algo == 2) { prms.algorithm = solver::RANDOMIZED; prms.n_components = params.n_col2 - 15; } allocate(data2, len); r.uniform(data2, len, T(-1.0), T(1.0)); allocate(data2_trans, prms.n_rows * prms.n_components); int len_comp = params.n_col2 * prms.n_components; allocate(components2, len_comp); allocate(explained_vars2, prms.n_components); allocate(explained_var_ratio2, prms.n_components); allocate(singular_vals2, prms.n_components); allocate(mean2, prms.n_cols); allocate(noise_vars2, 1); pcaFitTransform(data2, data2_trans, components2, explained_vars2, explained_var_ratio2, singular_vals2, mean2, noise_vars2, prms, cublas_handle, cusolver_handle); allocate(data2_back, len); pcaInverseTransform(data2_trans, components2, singular_vals2, mean2, data2_back, prms, cublas_handle); CUBLAS_CHECK(hipblasDestroy(cublas_handle)); CUSOLVER_CHECK(hipsolverDnDestroy(cusolver_handle)); } void SetUp() override { basicTest(); advancedTest(); } void TearDown() override { CUDA_CHECK(hipFree(data)); CUDA_CHECK(hipFree(components)); CUDA_CHECK(hipFree(trans_data)); CUDA_CHECK(hipFree(data_back)); CUDA_CHECK(hipFree(trans_data_ref)); CUDA_CHECK(hipFree(explained_vars)); CUDA_CHECK(hipFree(explained_var_ratio)); CUDA_CHECK(hipFree(singular_vals)); CUDA_CHECK(hipFree(mean)); CUDA_CHECK(hipFree(noise_vars)); CUDA_CHECK(hipFree(components_ref)); CUDA_CHECK(hipFree(explained_vars_ref)); CUDA_CHECK(hipFree(data2)); CUDA_CHECK(hipFree(data2_trans)); CUDA_CHECK(hipFree(data2_back)); CUDA_CHECK(hipFree(components2)); CUDA_CHECK(hipFree(explained_vars2)); CUDA_CHECK(hipFree(explained_var_ratio2)); CUDA_CHECK(hipFree(singular_vals2)); CUDA_CHECK(hipFree(mean2)); CUDA_CHECK(hipFree(noise_vars2)); } protected: PcaInputs<T> params; T *data, *trans_data, *data_back, *components, *explained_vars, *explained_var_ratio, *singular_vals, *mean, *noise_vars, *trans_data_ref, *components_ref, *explained_vars_ref; T *data2, *data2_trans, *data2_back, *components2, *explained_vars2, *explained_var_ratio2, *singular_vals2, *mean2, *noise_vars2; }; const std::vector<PcaInputs<float> > inputsf2 = { { 0.01f, 3 * 2, 3, 2, 1024 * 128, 1024, 128, 1234ULL, 0, false }, { 0.01f, 3 * 2, 3, 2, 256 * 32, 256, 32, 1234ULL, 1, true }, { 0.05f, 3 * 2, 3, 2, 256 * 64, 256, 64, 1234ULL, 2, true }}; const std::vector<PcaInputs<double> > inputsd2 = { { 0.01, 3 * 2, 3, 2, 1024 * 128, 1024, 128, 1234ULL, 0, false }, { 0.01, 3 * 2, 3, 2, 256 * 32, 256, 32, 1234ULL, 1, true }, { 0.05, 3 * 2, 3, 2, 256 * 64, 256, 64, 1234ULL, 2, true }}; typedef PcaTest<float> PcaTestValF; TEST_P(PcaTestValF, Result) { ASSERT_TRUE( devArrMatch(explained_vars, explained_vars_ref, params.n_col, CompareApproxAbs<float>(params.tolerance))); } typedef PcaTest<double> PcaTestValD; TEST_P(PcaTestValD, Result) { ASSERT_TRUE( devArrMatch(explained_vars, explained_vars_ref, params.n_col, CompareApproxAbs<double>(params.tolerance))); } typedef PcaTest<float> PcaTestLeftVecF; TEST_P(PcaTestLeftVecF, Result) { ASSERT_TRUE( devArrMatch(components, components_ref, (params.n_col * params.n_col), CompareApproxAbs<float>(params.tolerance))); } typedef PcaTest<double> PcaTestLeftVecD; TEST_P(PcaTestLeftVecD, Result) { ASSERT_TRUE( devArrMatch(components, components_ref, (params.n_col * params.n_col), CompareApproxAbs<double>(params.tolerance))); } typedef PcaTest<float> PcaTestTransDataF; TEST_P(PcaTestTransDataF, Result) { ASSERT_TRUE( devArrMatch(trans_data, trans_data_ref, (params.n_row * params.n_col), CompareApproxAbs<float>(params.tolerance))); } typedef PcaTest<double> PcaTestTransDataD; TEST_P(PcaTestTransDataD, Result) { ASSERT_TRUE( devArrMatch(trans_data, trans_data_ref, (params.n_row * params.n_col), CompareApproxAbs<double>(params.tolerance))); } typedef PcaTest<float> PcaTestDataVecSmallF; TEST_P(PcaTestDataVecSmallF, Result) { ASSERT_TRUE( devArrMatch(data, data_back, (params.n_col * params.n_col), CompareApproxAbs<float>(params.tolerance))); } typedef PcaTest<double> PcaTestDataVecSmallD; TEST_P(PcaTestDataVecSmallD, Result) { ASSERT_TRUE( devArrMatch(data, data_back, (params.n_col * params.n_col), CompareApproxAbs<double>(params.tolerance))); } typedef PcaTest<float> PcaTestDataVecF; TEST_P(PcaTestDataVecF, Result) { ASSERT_TRUE( devArrMatch(data2, data2_back, (params.n_col2 * params.n_col2), CompareApproxAbs<float>(params.tolerance))); } typedef PcaTest<double> PcaTestDataVecD; TEST_P(PcaTestDataVecD, Result) { ASSERT_TRUE( devArrMatch(data2, data2_back, (params.n_col2 * params.n_col2), CompareApproxAbs<double>(params.tolerance))); } INSTANTIATE_TEST_CASE_P(PcaTests, PcaTestValF, ::testing::ValuesIn(inputsf2)); INSTANTIATE_TEST_CASE_P(PcaTests, PcaTestValD, ::testing::ValuesIn(inputsd2)); INSTANTIATE_TEST_CASE_P(PcaTests, PcaTestLeftVecF, ::testing::ValuesIn(inputsf2)); INSTANTIATE_TEST_CASE_P(PcaTests, PcaTestLeftVecD, ::testing::ValuesIn(inputsd2)); INSTANTIATE_TEST_CASE_P(PcaTests, PcaTestDataVecSmallF, ::testing::ValuesIn(inputsf2)); INSTANTIATE_TEST_CASE_P(PcaTests, PcaTestDataVecSmallD, ::testing::ValuesIn(inputsd2)); INSTANTIATE_TEST_CASE_P(PcaTests, PcaTestTransDataF, ::testing::ValuesIn(inputsf2)); INSTANTIATE_TEST_CASE_P(PcaTests, PcaTestTransDataD, ::testing::ValuesIn(inputsd2)); INSTANTIATE_TEST_CASE_P(PcaTests, PcaTestDataVecF, ::testing::ValuesIn(inputsf2)); INSTANTIATE_TEST_CASE_P(PcaTests, PcaTestDataVecD, ::testing::ValuesIn(inputsd2)); } // end namespace ML
389a7a3652f516d90485dc820fcb27c5c6a08b3c.cu
/* * Copyright (c) 2018, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <gtest/gtest.h> #include <vector> #include "random/rng.h" #include "test_utils.h" #include <cuda_utils.h> #include "ml_utils.h" #include "pca/pca.h" #include <linalg/cublas_wrappers.h> namespace ML { using namespace MLCommon; template<typename T> struct PcaInputs { T tolerance; int len; int n_row; int n_col; int len2; int n_row2; int n_col2; unsigned long long int seed; int algo; bool whiten; }; template<typename T> ::std::ostream& operator<<(::std::ostream& os, const PcaInputs<T>& dims) { return os; } template<typename T> class PcaTest: public ::testing::TestWithParam<PcaInputs<T> > { protected: void basicTest() { cublasHandle_t cublas_handle; CUBLAS_CHECK(cublasCreate(&cublas_handle)); cusolverDnHandle_t cusolver_handle = NULL; CUSOLVER_CHECK(cusolverDnCreate(&cusolver_handle)); params = ::testing::TestWithParam<PcaInputs<T>>::GetParam(); Random::Rng<T> r(params.seed, MLCommon::Random::GenTaps); int len = params.len; allocate(data, len); allocate(data_back, len); allocate(trans_data, len); allocate(trans_data_ref, len); std::vector<T> data_h = { 1.0, 2.0, 5.0, 4.0, 2.0, 1.0 }; data_h.resize(len); updateDevice(data, data_h.data(), len); std::vector<T> trans_data_ref_h = { -2.3231, -0.3517, 2.6748, -0.3979, 0.6571, -0.2592 }; trans_data_ref_h.resize(len); updateDevice(trans_data_ref, trans_data_ref_h.data(), len); int len_comp = params.n_col * params.n_col; allocate(components, len_comp); allocate(explained_vars, params.n_col); allocate(explained_var_ratio, params.n_col); allocate(singular_vals, params.n_col); allocate(mean, params.n_col); allocate(noise_vars, 1); std::vector<T> components_ref_h = { 0.8163, 0.5776, -0.5776, 0.8163 }; components_ref_h.resize(len_comp); std::vector<T> explained_vars_ref_h = { 6.338, 0.3287 }; explained_vars_ref_h.resize(params.n_col); allocate(components_ref, len_comp); allocate(explained_vars_ref, params.n_col); updateDevice(components_ref, components_ref_h.data(), len_comp); updateDevice(explained_vars_ref, explained_vars_ref_h.data(), params.n_col); paramsPCA prms; prms.n_cols = params.n_col; prms.n_rows = params.n_row; prms.n_components = params.n_col; prms.whiten = false; if (params.algo == 0) prms.algorithm = solver::COV_EIG_DQ; else prms.algorithm = solver::COV_EIG_JACOBI; pcaFit(data, components, explained_vars, explained_var_ratio, singular_vals, mean, noise_vars, prms, cublas_handle, cusolver_handle); pcaTransform(data, components, trans_data, singular_vals, mean, prms, cublas_handle); pcaInverseTransform(trans_data, components, singular_vals, mean, data_back, prms, cublas_handle); CUBLAS_CHECK(cublasDestroy(cublas_handle)); CUSOLVER_CHECK(cusolverDnDestroy(cusolver_handle)); } void advancedTest() { cublasHandle_t cublas_handle; CUBLAS_CHECK(cublasCreate(&cublas_handle)); cusolverDnHandle_t cusolver_handle = NULL; CUSOLVER_CHECK(cusolverDnCreate(&cusolver_handle)); params = ::testing::TestWithParam<PcaInputs<T>>::GetParam(); Random::Rng<T> r(params.seed, MLCommon::Random::GenTaps); int len = params.len2; paramsPCA prms; prms.n_cols = params.n_col2; prms.n_rows = params.n_row2; prms.n_components = params.n_col2; prms.whiten = params.whiten; if (params.algo == 0) prms.algorithm = solver::COV_EIG_DQ; else if (params.algo == 1) prms.algorithm = solver::COV_EIG_JACOBI; else if (params.algo == 2) { prms.algorithm = solver::RANDOMIZED; prms.n_components = params.n_col2 - 15; } allocate(data2, len); r.uniform(data2, len, T(-1.0), T(1.0)); allocate(data2_trans, prms.n_rows * prms.n_components); int len_comp = params.n_col2 * prms.n_components; allocate(components2, len_comp); allocate(explained_vars2, prms.n_components); allocate(explained_var_ratio2, prms.n_components); allocate(singular_vals2, prms.n_components); allocate(mean2, prms.n_cols); allocate(noise_vars2, 1); pcaFitTransform(data2, data2_trans, components2, explained_vars2, explained_var_ratio2, singular_vals2, mean2, noise_vars2, prms, cublas_handle, cusolver_handle); allocate(data2_back, len); pcaInverseTransform(data2_trans, components2, singular_vals2, mean2, data2_back, prms, cublas_handle); CUBLAS_CHECK(cublasDestroy(cublas_handle)); CUSOLVER_CHECK(cusolverDnDestroy(cusolver_handle)); } void SetUp() override { basicTest(); advancedTest(); } void TearDown() override { CUDA_CHECK(cudaFree(data)); CUDA_CHECK(cudaFree(components)); CUDA_CHECK(cudaFree(trans_data)); CUDA_CHECK(cudaFree(data_back)); CUDA_CHECK(cudaFree(trans_data_ref)); CUDA_CHECK(cudaFree(explained_vars)); CUDA_CHECK(cudaFree(explained_var_ratio)); CUDA_CHECK(cudaFree(singular_vals)); CUDA_CHECK(cudaFree(mean)); CUDA_CHECK(cudaFree(noise_vars)); CUDA_CHECK(cudaFree(components_ref)); CUDA_CHECK(cudaFree(explained_vars_ref)); CUDA_CHECK(cudaFree(data2)); CUDA_CHECK(cudaFree(data2_trans)); CUDA_CHECK(cudaFree(data2_back)); CUDA_CHECK(cudaFree(components2)); CUDA_CHECK(cudaFree(explained_vars2)); CUDA_CHECK(cudaFree(explained_var_ratio2)); CUDA_CHECK(cudaFree(singular_vals2)); CUDA_CHECK(cudaFree(mean2)); CUDA_CHECK(cudaFree(noise_vars2)); } protected: PcaInputs<T> params; T *data, *trans_data, *data_back, *components, *explained_vars, *explained_var_ratio, *singular_vals, *mean, *noise_vars, *trans_data_ref, *components_ref, *explained_vars_ref; T *data2, *data2_trans, *data2_back, *components2, *explained_vars2, *explained_var_ratio2, *singular_vals2, *mean2, *noise_vars2; }; const std::vector<PcaInputs<float> > inputsf2 = { { 0.01f, 3 * 2, 3, 2, 1024 * 128, 1024, 128, 1234ULL, 0, false }, { 0.01f, 3 * 2, 3, 2, 256 * 32, 256, 32, 1234ULL, 1, true }, { 0.05f, 3 * 2, 3, 2, 256 * 64, 256, 64, 1234ULL, 2, true }}; const std::vector<PcaInputs<double> > inputsd2 = { { 0.01, 3 * 2, 3, 2, 1024 * 128, 1024, 128, 1234ULL, 0, false }, { 0.01, 3 * 2, 3, 2, 256 * 32, 256, 32, 1234ULL, 1, true }, { 0.05, 3 * 2, 3, 2, 256 * 64, 256, 64, 1234ULL, 2, true }}; typedef PcaTest<float> PcaTestValF; TEST_P(PcaTestValF, Result) { ASSERT_TRUE( devArrMatch(explained_vars, explained_vars_ref, params.n_col, CompareApproxAbs<float>(params.tolerance))); } typedef PcaTest<double> PcaTestValD; TEST_P(PcaTestValD, Result) { ASSERT_TRUE( devArrMatch(explained_vars, explained_vars_ref, params.n_col, CompareApproxAbs<double>(params.tolerance))); } typedef PcaTest<float> PcaTestLeftVecF; TEST_P(PcaTestLeftVecF, Result) { ASSERT_TRUE( devArrMatch(components, components_ref, (params.n_col * params.n_col), CompareApproxAbs<float>(params.tolerance))); } typedef PcaTest<double> PcaTestLeftVecD; TEST_P(PcaTestLeftVecD, Result) { ASSERT_TRUE( devArrMatch(components, components_ref, (params.n_col * params.n_col), CompareApproxAbs<double>(params.tolerance))); } typedef PcaTest<float> PcaTestTransDataF; TEST_P(PcaTestTransDataF, Result) { ASSERT_TRUE( devArrMatch(trans_data, trans_data_ref, (params.n_row * params.n_col), CompareApproxAbs<float>(params.tolerance))); } typedef PcaTest<double> PcaTestTransDataD; TEST_P(PcaTestTransDataD, Result) { ASSERT_TRUE( devArrMatch(trans_data, trans_data_ref, (params.n_row * params.n_col), CompareApproxAbs<double>(params.tolerance))); } typedef PcaTest<float> PcaTestDataVecSmallF; TEST_P(PcaTestDataVecSmallF, Result) { ASSERT_TRUE( devArrMatch(data, data_back, (params.n_col * params.n_col), CompareApproxAbs<float>(params.tolerance))); } typedef PcaTest<double> PcaTestDataVecSmallD; TEST_P(PcaTestDataVecSmallD, Result) { ASSERT_TRUE( devArrMatch(data, data_back, (params.n_col * params.n_col), CompareApproxAbs<double>(params.tolerance))); } typedef PcaTest<float> PcaTestDataVecF; TEST_P(PcaTestDataVecF, Result) { ASSERT_TRUE( devArrMatch(data2, data2_back, (params.n_col2 * params.n_col2), CompareApproxAbs<float>(params.tolerance))); } typedef PcaTest<double> PcaTestDataVecD; TEST_P(PcaTestDataVecD, Result) { ASSERT_TRUE( devArrMatch(data2, data2_back, (params.n_col2 * params.n_col2), CompareApproxAbs<double>(params.tolerance))); } INSTANTIATE_TEST_CASE_P(PcaTests, PcaTestValF, ::testing::ValuesIn(inputsf2)); INSTANTIATE_TEST_CASE_P(PcaTests, PcaTestValD, ::testing::ValuesIn(inputsd2)); INSTANTIATE_TEST_CASE_P(PcaTests, PcaTestLeftVecF, ::testing::ValuesIn(inputsf2)); INSTANTIATE_TEST_CASE_P(PcaTests, PcaTestLeftVecD, ::testing::ValuesIn(inputsd2)); INSTANTIATE_TEST_CASE_P(PcaTests, PcaTestDataVecSmallF, ::testing::ValuesIn(inputsf2)); INSTANTIATE_TEST_CASE_P(PcaTests, PcaTestDataVecSmallD, ::testing::ValuesIn(inputsd2)); INSTANTIATE_TEST_CASE_P(PcaTests, PcaTestTransDataF, ::testing::ValuesIn(inputsf2)); INSTANTIATE_TEST_CASE_P(PcaTests, PcaTestTransDataD, ::testing::ValuesIn(inputsd2)); INSTANTIATE_TEST_CASE_P(PcaTests, PcaTestDataVecF, ::testing::ValuesIn(inputsf2)); INSTANTIATE_TEST_CASE_P(PcaTests, PcaTestDataVecD, ::testing::ValuesIn(inputsd2)); } // end namespace ML
6326ad0b9d117d3efa743edfb4ee8fae54ea28e1.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include <cstdlib> #include <cstdio> #include <cstring> //////////////////////////////////////////////////////////////////////////////// // Tracker state variables and pointers //////////////////////////////////////////////////////////////////////////////// //Have the pointers been initialized? bool trackerPointers = false; //////////////////////////////////////////////////////////////////////////////// // Common host and device functions //////////////////////////////////////////////////////////////////////////////// //Round a / b to nearest higher integer value int iDivUp(int a, int b){ return (a % b != 0) ? (a / b + 1) : (a / b); } //Round a / b to nearest lower integer value int iDivDown(int a, int b){ return a / b; } //Align a to nearest higher multiple of b int iAlignUp(int a, int b){ return (a % b != 0) ? (a - a % b + b) : a; } //Align a to nearest lower multiple of b int iAlignDown(int a, int b){ return a - a % b; } //////////////////////////////////////////////////////////////////////////////// // GPU convolution //////////////////////////////////////////////////////////////////////////////// //kernels #include "gradkern.cu" #include "convkern.cu" //////////////////////////////////////////////////////////////////////////////// // Data configuration //////////////////////////////////////////////////////////////////////////////// //Image width should be aligned to maximum coalesced read/write size //for best global memory performance in both row and column filter. //const int DATA_W = iAlignUp(256, 16); //const int DATA_H = 256; //const int DATA_SIZE = DATA_W * DATA_H * sizeof(float); //const int GRADIENT_SIZE = GRADIENT_W * sizeof(float); //////////////////////////////////////////////////////////////////////////////// // Main program //////////////////////////////////////////////////////////////////////////////// void calculateGradient(float* h_ResultGPU, float* img, int imgWidth, int imgHeight){ const int DATA_W = imgWidth; const int DATA_H = imgHeight; const int DATA_SIZE = DATA_W * DATA_H * sizeof(float); const int GRADIENT_SIZE = GRADIENT_W * sizeof(float); const int KERNEL_SIZE = KERNEL_W * sizeof(float); float *h_Gradient, *h_Kernel; float *d_DataA, *d_DataIx, *d_DataIy, *d_DataTemp; double sum_delta, sum_ref, L1norm, gpuTime; int i; printf("%i x %i\n", DATA_W, DATA_H); printf("Initializing data...\n"); h_Gradient = (float *)malloc(GRADIENT_SIZE); h_Kernel = (float *)malloc(KERNEL_SIZE); hipMalloc( (void **)&d_DataA, DATA_SIZE); hipMalloc( (void **)&d_DataIx, DATA_SIZE); hipMalloc( (void **)&d_DataIy, DATA_SIZE); hipMalloc( (void **)&d_DataTemp, DATA_SIZE); //Initializing gradient computation filter for(i = -GRADIENT_RADIUS; i < GRADIENT_RADIUS+1; i++){ h_Gradient[i+GRADIENT_RADIUS] = 1.0*i; } //Initializing smoothing convolution kernel float kernelSum = 0; for(i = 0; i < KERNEL_W; i++){ //float dist = (float)(i - KERNEL_RADIUS) / (float)KERNEL_RADIUS; h_Kernel[i] = 1.0;//expf(- dist * dist / 2); kernelSum += h_Kernel[i]; } for(i = 0; i < KERNEL_W; i++) h_Kernel[i] /= kernelSum; //Copying to device hipMemcpyToSymbol(d_Gradient, h_Gradient, GRADIENT_SIZE); hipMemcpyToSymbol(d_Kernel, h_Kernel, KERNEL_SIZE); hipMemcpy(d_DataA, img, DATA_SIZE, hipMemcpyHostToDevice); //Gradient filter dimensions dim3 gradBlockGridRows(iDivUp(DATA_W, GRAD_ROW_TILE_W), DATA_H); dim3 gradBlockGridColumns(iDivUp(DATA_W, GRAD_COLUMN_TILE_W), iDivUp(DATA_H, GRAD_COLUMN_TILE_H)); dim3 gradThreadBlockRows(GRADIENT_RADIUS_ALIGNED + GRAD_ROW_TILE_W + GRADIENT_RADIUS); dim3 gradThreadBlockColumns(GRAD_COLUMN_TILE_W, 8); //Smoothing convolution filter dimensions dim3 convBlockGridRows(iDivUp(DATA_W, ROW_TILE_W), DATA_H); dim3 convBlockGridColumns(iDivUp(DATA_W, COLUMN_TILE_W), iDivUp(DATA_H, COLUMN_TILE_H)); dim3 convThreadBlockRows(KERNEL_RADIUS_ALIGNED + ROW_TILE_W + KERNEL_RADIUS); dim3 convThreadBlockColumns(COLUMN_TILE_W, 8); /**/ printf("GPU gradient calculation...\n"); hipDeviceSynchronize(); //Compute Ix and Iy (gradient) hipLaunchKernelGGL(( gradientRowGPU), dim3(gradBlockGridRows), dim3(gradThreadBlockRows), 0, 0, d_DataIx, d_DataA, DATA_W, DATA_H ); hipLaunchKernelGGL(( gradientColumnGPU), dim3(gradBlockGridColumns), dim3(gradThreadBlockColumns), 0, 0, d_DataIy, d_DataA, DATA_W, DATA_H, GRAD_COLUMN_TILE_W * gradThreadBlockColumns.y, DATA_W * gradThreadBlockColumns.y ); //Compute Ix*Iy smoothed hipLaunchKernelGGL(( iXiYRowGPU), dim3(convBlockGridRows), dim3(convThreadBlockRows), 0, 0, d_DataTemp, d_DataIx, d_DataIy, DATA_W, DATA_H ); hipLaunchKernelGGL(( convolutionColumnGPU), dim3(convBlockGridColumns), dim3(convThreadBlockColumns), 0, 0, d_DataA, d_DataTemp, DATA_W, DATA_H, COLUMN_TILE_W * convThreadBlockColumns.y, DATA_W * convThreadBlockColumns.y ); //Compute Ix^2 smoothed hipLaunchKernelGGL(( convolutionSquaredRowGPU), dim3(convBlockGridRows), dim3(convThreadBlockRows), 0, 0, d_DataTemp, d_DataIx, DATA_W, DATA_H ); hipLaunchKernelGGL(( convolutionColumnGPU), dim3(convBlockGridColumns), dim3(convThreadBlockColumns), 0, 0, d_DataIx, d_DataTemp, DATA_W, DATA_H, COLUMN_TILE_W * convThreadBlockColumns.y, DATA_W * convThreadBlockColumns.y ); //Compute Iy^2 smoothed hipLaunchKernelGGL(( convolutionSquaredRowGPU), dim3(convBlockGridRows), dim3(convThreadBlockRows), 0, 0, d_DataTemp, d_DataIy, DATA_W, DATA_H ); hipLaunchKernelGGL(( convolutionColumnGPU), dim3(convBlockGridColumns), dim3(convThreadBlockColumns), 0, 0, d_DataIy, d_DataTemp, DATA_W, DATA_H, COLUMN_TILE_W * convThreadBlockColumns.y, DATA_W * convThreadBlockColumns.y ); hipDeviceSynchronize(); /**/ printf("Reading back GPU results...\n"); hipMemcpy(h_ResultGPU, d_DataA, DATA_SIZE, hipMemcpyDeviceToHost); printf("Shutting down...\n"); hipFree(d_DataIx); hipFree(d_DataIy); hipFree(d_DataA); free(h_Gradient); free(h_Kernel); return; }
6326ad0b9d117d3efa743edfb4ee8fae54ea28e1.cu
#include <cstdlib> #include <cstdio> #include <cstring> //////////////////////////////////////////////////////////////////////////////// // Tracker state variables and pointers //////////////////////////////////////////////////////////////////////////////// //Have the pointers been initialized? bool trackerPointers = false; //////////////////////////////////////////////////////////////////////////////// // Common host and device functions //////////////////////////////////////////////////////////////////////////////// //Round a / b to nearest higher integer value int iDivUp(int a, int b){ return (a % b != 0) ? (a / b + 1) : (a / b); } //Round a / b to nearest lower integer value int iDivDown(int a, int b){ return a / b; } //Align a to nearest higher multiple of b int iAlignUp(int a, int b){ return (a % b != 0) ? (a - a % b + b) : a; } //Align a to nearest lower multiple of b int iAlignDown(int a, int b){ return a - a % b; } //////////////////////////////////////////////////////////////////////////////// // GPU convolution //////////////////////////////////////////////////////////////////////////////// //kernels #include "gradkern.cu" #include "convkern.cu" //////////////////////////////////////////////////////////////////////////////// // Data configuration //////////////////////////////////////////////////////////////////////////////// //Image width should be aligned to maximum coalesced read/write size //for best global memory performance in both row and column filter. //const int DATA_W = iAlignUp(256, 16); //const int DATA_H = 256; //const int DATA_SIZE = DATA_W * DATA_H * sizeof(float); //const int GRADIENT_SIZE = GRADIENT_W * sizeof(float); //////////////////////////////////////////////////////////////////////////////// // Main program //////////////////////////////////////////////////////////////////////////////// void calculateGradient(float* h_ResultGPU, float* img, int imgWidth, int imgHeight){ const int DATA_W = imgWidth; const int DATA_H = imgHeight; const int DATA_SIZE = DATA_W * DATA_H * sizeof(float); const int GRADIENT_SIZE = GRADIENT_W * sizeof(float); const int KERNEL_SIZE = KERNEL_W * sizeof(float); float *h_Gradient, *h_Kernel; float *d_DataA, *d_DataIx, *d_DataIy, *d_DataTemp; double sum_delta, sum_ref, L1norm, gpuTime; int i; printf("%i x %i\n", DATA_W, DATA_H); printf("Initializing data...\n"); h_Gradient = (float *)malloc(GRADIENT_SIZE); h_Kernel = (float *)malloc(KERNEL_SIZE); cudaMalloc( (void **)&d_DataA, DATA_SIZE); cudaMalloc( (void **)&d_DataIx, DATA_SIZE); cudaMalloc( (void **)&d_DataIy, DATA_SIZE); cudaMalloc( (void **)&d_DataTemp, DATA_SIZE); //Initializing gradient computation filter for(i = -GRADIENT_RADIUS; i < GRADIENT_RADIUS+1; i++){ h_Gradient[i+GRADIENT_RADIUS] = 1.0*i; } //Initializing smoothing convolution kernel float kernelSum = 0; for(i = 0; i < KERNEL_W; i++){ //float dist = (float)(i - KERNEL_RADIUS) / (float)KERNEL_RADIUS; h_Kernel[i] = 1.0;//expf(- dist * dist / 2); kernelSum += h_Kernel[i]; } for(i = 0; i < KERNEL_W; i++) h_Kernel[i] /= kernelSum; //Copying to device cudaMemcpyToSymbol(d_Gradient, h_Gradient, GRADIENT_SIZE); cudaMemcpyToSymbol(d_Kernel, h_Kernel, KERNEL_SIZE); cudaMemcpy(d_DataA, img, DATA_SIZE, cudaMemcpyHostToDevice); //Gradient filter dimensions dim3 gradBlockGridRows(iDivUp(DATA_W, GRAD_ROW_TILE_W), DATA_H); dim3 gradBlockGridColumns(iDivUp(DATA_W, GRAD_COLUMN_TILE_W), iDivUp(DATA_H, GRAD_COLUMN_TILE_H)); dim3 gradThreadBlockRows(GRADIENT_RADIUS_ALIGNED + GRAD_ROW_TILE_W + GRADIENT_RADIUS); dim3 gradThreadBlockColumns(GRAD_COLUMN_TILE_W, 8); //Smoothing convolution filter dimensions dim3 convBlockGridRows(iDivUp(DATA_W, ROW_TILE_W), DATA_H); dim3 convBlockGridColumns(iDivUp(DATA_W, COLUMN_TILE_W), iDivUp(DATA_H, COLUMN_TILE_H)); dim3 convThreadBlockRows(KERNEL_RADIUS_ALIGNED + ROW_TILE_W + KERNEL_RADIUS); dim3 convThreadBlockColumns(COLUMN_TILE_W, 8); /**/ printf("GPU gradient calculation...\n"); cudaThreadSynchronize(); //Compute Ix and Iy (gradient) gradientRowGPU<<<gradBlockGridRows, gradThreadBlockRows>>>( d_DataIx, d_DataA, DATA_W, DATA_H ); gradientColumnGPU<<<gradBlockGridColumns, gradThreadBlockColumns>>>( d_DataIy, d_DataA, DATA_W, DATA_H, GRAD_COLUMN_TILE_W * gradThreadBlockColumns.y, DATA_W * gradThreadBlockColumns.y ); //Compute Ix*Iy smoothed iXiYRowGPU<<<convBlockGridRows, convThreadBlockRows>>>( d_DataTemp, d_DataIx, d_DataIy, DATA_W, DATA_H ); convolutionColumnGPU<<<convBlockGridColumns, convThreadBlockColumns>>>( d_DataA, d_DataTemp, DATA_W, DATA_H, COLUMN_TILE_W * convThreadBlockColumns.y, DATA_W * convThreadBlockColumns.y ); //Compute Ix^2 smoothed convolutionSquaredRowGPU<<<convBlockGridRows, convThreadBlockRows>>>( d_DataTemp, d_DataIx, DATA_W, DATA_H ); convolutionColumnGPU<<<convBlockGridColumns, convThreadBlockColumns>>>( d_DataIx, d_DataTemp, DATA_W, DATA_H, COLUMN_TILE_W * convThreadBlockColumns.y, DATA_W * convThreadBlockColumns.y ); //Compute Iy^2 smoothed convolutionSquaredRowGPU<<<convBlockGridRows, convThreadBlockRows>>>( d_DataTemp, d_DataIy, DATA_W, DATA_H ); convolutionColumnGPU<<<convBlockGridColumns, convThreadBlockColumns>>>( d_DataIy, d_DataTemp, DATA_W, DATA_H, COLUMN_TILE_W * convThreadBlockColumns.y, DATA_W * convThreadBlockColumns.y ); cudaThreadSynchronize(); /**/ printf("Reading back GPU results...\n"); cudaMemcpy(h_ResultGPU, d_DataA, DATA_SIZE, cudaMemcpyDeviceToHost); printf("Shutting down...\n"); cudaFree(d_DataIx); cudaFree(d_DataIy); cudaFree(d_DataA); free(h_Gradient); free(h_Kernel); return; }
0358df326f5001564c8b961192b9d085de72e15a.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <vector> #include "Node.h" #include "SOM.h" #include <time.h> #include "constants.h" #include "resource.h" #include "hip/hip_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <omp.h> #include <sstream> #include <fstream> #include <iostream> float cpuStart; float cpuEnd; char* g_szApplicationName = "Kohonen Self Organizing Map Demo"; char* g_szWindowClassName = "MyWindowClass"; bool Train(); void CreateDataSet(); //pointer to a Self Organising Map SOM* pSOM = new SOM(); //the data for the training //used to create the back buffer static HDC hdcBackBuffer; static HBITMAP hBitmap; static HBITMAP hOldBitmap; LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { //these hold the dimensions of the client window area static int CxClient, CyClient; //used to create the back buffer //static HDC hdcBackBuffer; //static HBITMAP hBitmap; //static HBITMAP hOldBitmap; switch (msg) { case WM_CREATE: { //to get get the size of the client window first we need to create //a RECT and then ask Windows to fill in our RECT structure with //the client window size. Then we assign to CxClient and CyClient //accordingly RECT rect; GetClientRect(hwnd, &rect); CxClient = rect.right; CyClient = rect.bottom; //seed random number generator srand((unsigned)time(NULL)); //create a memory device context hdcBackBuffer = CreateCompatibleDC(NULL); //get the DC for the front buffer HDC hdc = GetDC(hwnd); hBitmap = CreateCompatibleBitmap(hdc, CxClient, CyClient); //select the bitmap into the memory device context hOldBitmap = (HBITMAP)SelectObject(hdcBackBuffer, hBitmap); //don't forget to release the DC ReleaseDC(hwnd, hdc); pSOM->Create(CxClient, CyClient, constNumCellsAcross, constNumCellsDown, constNumIterations); } break; case WM_KEYUP: { switch (wParam) { case VK_ESCAPE: { SendMessage(hwnd, WM_DESTROY, NULL, NULL); PostQuitMessage(0); } break; case 'R': { delete pSOM; pSOM = new SOM(); pSOM->Create(CxClient, CyClient, constNumCellsAcross, constNumCellsDown, constNumIterations); } break; } } case WM_PAINT: { PAINTSTRUCT ps; BeginPaint(hwnd, &ps); //fill the backbuffer with white BitBlt(hdcBackBuffer, 0, 0, CxClient, CyClient, NULL, NULL, NULL, WHITENESS); pSOM->Render(hdcBackBuffer); //now blit the backbuffer to the front BitBlt(ps.hdc, 0, 0, CxClient, CyClient, hdcBackBuffer, 0, 0, SRCCOPY); EndPaint(hwnd, &ps); } break; //has the user resized the client area? case WM_SIZE: { //if so we need to update our variables so that any drawing //we do using cxClient and cyClient is scaled accordingly CxClient = LOWORD(lParam); CyClient = HIWORD(lParam); //now to resize the backbuffer accordingly. First select //the old bitmap back into the DC SelectObject(hdcBackBuffer, hOldBitmap); //don't forget to do this or you will get resource leaks DeleteObject(hBitmap); //get the DC for the application HDC hdc = GetDC(hwnd); //create another bitmap of the same size and mode //as the application hBitmap = CreateCompatibleBitmap(hdc, CxClient, CyClient); ReleaseDC(hwnd, hdc); //select the new bitmap into the DC SelectObject(hdcBackBuffer, hBitmap); } break; case WM_DESTROY: { //clean up our backbuffer objects SelectObject(hdcBackBuffer, hOldBitmap); DeleteDC(hdcBackBuffer); DeleteObject(hBitmap); // kill the application, this sends a WM_QUIT message PostQuitMessage(0); } break; }//end switch //this is where all the messages not specifically handled by our //winproc are sent to be processed return DefWindowProc(hwnd, msg, wParam, lParam); } wchar_t *convertCharArrayToLPCWSTR(const char* charArray) { wchar_t* wString = new wchar_t[4096]; MultiByteToWideChar(CP_ACP, 0, charArray, -1, wString, 4096); return wString; } string Convert(float number){ std::ostringstream buff; buff<<number; return buff.str(); } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow) { CreateDataSet(); //handle to our window HWND hWnd; //our window class structure WNDCLASSEX winclass; // first fill in the window class stucture winclass.cbSize = sizeof(WNDCLASSEX); winclass.style = CS_HREDRAW | CS_VREDRAW; winclass.lpfnWndProc = WindowProc; winclass.cbClsExtra = 0; winclass.cbWndExtra = 0; winclass.hInstance = hInstance; winclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1)); winclass.hCursor = LoadCursor(NULL, IDC_ARROW); winclass.hbrBackground = NULL; winclass.lpszMenuName = NULL; winclass.lpszClassName = g_szWindowClassName; winclass.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1)); //register the window class if (!RegisterClassEx(&winclass)) { MessageBox(NULL, TEXT("Registration Failed!"), TEXT("Error"), 0); //exit the application return 0; } //create a window with the *client* area specified. RECT rect; rect.left = 0; rect.top = 0; rect.bottom = constWindowHeight; rect.right = constWindowWidth; if (!AdjustWindowRectEx(&rect, CS_HREDRAW | CS_VREDRAW, true, NULL)) { MessageBox(NULL, TEXT("Problem creating window"), TEXT("error!"), MB_OK); return 0; } //create the window and assign its ID to hwnd hWnd = CreateWindowEx(NULL, // extended style g_szWindowClassName, // window class name g_szApplicationName, // window caption WS_OVERLAPPED | WS_VISIBLE | WS_CAPTION | WS_SYSMENU, GetSystemMetrics(SM_CXSCREEN) / 2 - constWindowWidth / 2, GetSystemMetrics(SM_CYSCREEN) / 2 - constWindowHeight / 2, rect.right, // initial x size rect.bottom, // initial y size NULL, // parent window handle NULL, // window menu handle hInstance, // program instance handle NULL); // creation parameters //make sure the window creation has gone OK if (!hWnd) { MessageBox(NULL, TEXT("CreateWindowEx Failed!"), TEXT("Error!"), 0); } //make the window visible ShowWindow(hWnd, iCmdShow); UpdateWindow(hWnd); // enter the message loop bool bDone = false; MSG msg; cpuStart= omp_get_wtime(); while (!bDone) { while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) { // Stop loop if it's a quit message bDone = true; } else { TranslateMessage(&msg); DispatchMessage(&msg); } } if (!pSOM->FinishedTraining()) { pSOM->Epoch(pSOM->m_TrainingSet); //this will call WM_PAINT which will render the map InvalidateRect(hWnd, NULL, TRUE); UpdateWindow(hWnd); } if(pSOM->getIteration() == constNumIterations){ cpuEnd = omp_get_wtime(); bDone = true; } } float cpuTime = (cpuEnd-cpuStart);//*1000; char str[256]; char num[256]; char it[256]; sprintf_s(str, " CPU Time: %6f \n", cpuTime); sprintf_s(num, " Number of Nodes: %d \n",pSOM->getSize()); sprintf_s(it, " Number of Iterations: %d \n",pSOM->getIteration()); OutputDebugString("----------CPU TIME-----------\n"); OutputDebugString(str); OutputDebugString("----------Number of Nodes-----------\n"); OutputDebugString(num); OutputDebugString("----------Number of Iterations-----------\n"); OutputDebugString(it); OutputDebugString("-----------------------------\n"); delete pSOM; UnregisterClass (g_szWindowClassName, winclass.hInstance); return msg.wParam; } void Render(HDC surface) { pSOM->Render(surface); } inline int RandInt(int x, int y) { return rand() % (y - x + 1) + x; } inline double RandFloat() { return (rand()) / (RAND_MAX + 1.0); } void CreateDataSet() { #ifndef RANDOM_TRAINING_SETS //create a data set vector<double> red, green, blue, yellow, orange, purple, dk_green, dk_blue; //push to back of vector red.push_back(1); red.push_back(0); red.push_back(0); green.push_back(0); green.push_back(1); green.push_back(0); dk_green.push_back(0); dk_green.push_back(0.5); dk_green.push_back(0.25); blue.push_back(0); blue.push_back(0); blue.push_back(1); dk_blue.push_back(0); dk_blue.push_back(0); dk_blue.push_back(0.5); yellow.push_back(1); yellow.push_back(1); yellow.push_back(0.2); orange.push_back(1); orange.push_back(0.4); orange.push_back(0.25); purple.push_back(1); purple.push_back(0); purple.push_back(1); m_TrainingSet.push_back(red); m_TrainingSet.push_back(green); m_TrainingSet.push_back(blue); m_TrainingSet.push_back(yellow); m_TrainingSet.push_back(orange); m_TrainingSet.push_back(purple); m_TrainingSet.push_back(dk_green); m_TrainingSet.push_back(dk_blue); #else //choose a random number of training sets int NumSets = RandInt(constMinNumTrainingSets, constMaxNumTrainingSets); for (int s = 0; s<NumSets; ++s) { vector<double> set; set.push_back(RandFloat()); set.push_back(RandFloat()); set.push_back(RandFloat()); pSOM->m_TrainingSet.push_back(set); } #endif }
0358df326f5001564c8b961192b9d085de72e15a.cu
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <vector> #include "Node.h" #include "SOM.h" #include <time.h> #include "constants.h" #include "resource.h" #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <omp.h> #include <sstream> #include <fstream> #include <iostream> float cpuStart; float cpuEnd; char* g_szApplicationName = "Kohonen Self Organizing Map Demo"; char* g_szWindowClassName = "MyWindowClass"; bool Train(); void CreateDataSet(); //pointer to a Self Organising Map SOM* pSOM = new SOM(); //the data for the training //used to create the back buffer static HDC hdcBackBuffer; static HBITMAP hBitmap; static HBITMAP hOldBitmap; LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { //these hold the dimensions of the client window area static int CxClient, CyClient; //used to create the back buffer //static HDC hdcBackBuffer; //static HBITMAP hBitmap; //static HBITMAP hOldBitmap; switch (msg) { case WM_CREATE: { //to get get the size of the client window first we need to create //a RECT and then ask Windows to fill in our RECT structure with //the client window size. Then we assign to CxClient and CyClient //accordingly RECT rect; GetClientRect(hwnd, &rect); CxClient = rect.right; CyClient = rect.bottom; //seed random number generator srand((unsigned)time(NULL)); //create a memory device context hdcBackBuffer = CreateCompatibleDC(NULL); //get the DC for the front buffer HDC hdc = GetDC(hwnd); hBitmap = CreateCompatibleBitmap(hdc, CxClient, CyClient); //select the bitmap into the memory device context hOldBitmap = (HBITMAP)SelectObject(hdcBackBuffer, hBitmap); //don't forget to release the DC ReleaseDC(hwnd, hdc); pSOM->Create(CxClient, CyClient, constNumCellsAcross, constNumCellsDown, constNumIterations); } break; case WM_KEYUP: { switch (wParam) { case VK_ESCAPE: { SendMessage(hwnd, WM_DESTROY, NULL, NULL); PostQuitMessage(0); } break; case 'R': { delete pSOM; pSOM = new SOM(); pSOM->Create(CxClient, CyClient, constNumCellsAcross, constNumCellsDown, constNumIterations); } break; } } case WM_PAINT: { PAINTSTRUCT ps; BeginPaint(hwnd, &ps); //fill the backbuffer with white BitBlt(hdcBackBuffer, 0, 0, CxClient, CyClient, NULL, NULL, NULL, WHITENESS); pSOM->Render(hdcBackBuffer); //now blit the backbuffer to the front BitBlt(ps.hdc, 0, 0, CxClient, CyClient, hdcBackBuffer, 0, 0, SRCCOPY); EndPaint(hwnd, &ps); } break; //has the user resized the client area? case WM_SIZE: { //if so we need to update our variables so that any drawing //we do using cxClient and cyClient is scaled accordingly CxClient = LOWORD(lParam); CyClient = HIWORD(lParam); //now to resize the backbuffer accordingly. First select //the old bitmap back into the DC SelectObject(hdcBackBuffer, hOldBitmap); //don't forget to do this or you will get resource leaks DeleteObject(hBitmap); //get the DC for the application HDC hdc = GetDC(hwnd); //create another bitmap of the same size and mode //as the application hBitmap = CreateCompatibleBitmap(hdc, CxClient, CyClient); ReleaseDC(hwnd, hdc); //select the new bitmap into the DC SelectObject(hdcBackBuffer, hBitmap); } break; case WM_DESTROY: { //clean up our backbuffer objects SelectObject(hdcBackBuffer, hOldBitmap); DeleteDC(hdcBackBuffer); DeleteObject(hBitmap); // kill the application, this sends a WM_QUIT message PostQuitMessage(0); } break; }//end switch //this is where all the messages not specifically handled by our //winproc are sent to be processed return DefWindowProc(hwnd, msg, wParam, lParam); } wchar_t *convertCharArrayToLPCWSTR(const char* charArray) { wchar_t* wString = new wchar_t[4096]; MultiByteToWideChar(CP_ACP, 0, charArray, -1, wString, 4096); return wString; } string Convert(float number){ std::ostringstream buff; buff<<number; return buff.str(); } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow) { CreateDataSet(); //handle to our window HWND hWnd; //our window class structure WNDCLASSEX winclass; // first fill in the window class stucture winclass.cbSize = sizeof(WNDCLASSEX); winclass.style = CS_HREDRAW | CS_VREDRAW; winclass.lpfnWndProc = WindowProc; winclass.cbClsExtra = 0; winclass.cbWndExtra = 0; winclass.hInstance = hInstance; winclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1)); winclass.hCursor = LoadCursor(NULL, IDC_ARROW); winclass.hbrBackground = NULL; winclass.lpszMenuName = NULL; winclass.lpszClassName = g_szWindowClassName; winclass.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1)); //register the window class if (!RegisterClassEx(&winclass)) { MessageBox(NULL, TEXT("Registration Failed!"), TEXT("Error"), 0); //exit the application return 0; } //create a window with the *client* area specified. RECT rect; rect.left = 0; rect.top = 0; rect.bottom = constWindowHeight; rect.right = constWindowWidth; if (!AdjustWindowRectEx(&rect, CS_HREDRAW | CS_VREDRAW, true, NULL)) { MessageBox(NULL, TEXT("Problem creating window"), TEXT("error!"), MB_OK); return 0; } //create the window and assign its ID to hwnd hWnd = CreateWindowEx(NULL, // extended style g_szWindowClassName, // window class name g_szApplicationName, // window caption WS_OVERLAPPED | WS_VISIBLE | WS_CAPTION | WS_SYSMENU, GetSystemMetrics(SM_CXSCREEN) / 2 - constWindowWidth / 2, GetSystemMetrics(SM_CYSCREEN) / 2 - constWindowHeight / 2, rect.right, // initial x size rect.bottom, // initial y size NULL, // parent window handle NULL, // window menu handle hInstance, // program instance handle NULL); // creation parameters //make sure the window creation has gone OK if (!hWnd) { MessageBox(NULL, TEXT("CreateWindowEx Failed!"), TEXT("Error!"), 0); } //make the window visible ShowWindow(hWnd, iCmdShow); UpdateWindow(hWnd); // enter the message loop bool bDone = false; MSG msg; cpuStart= omp_get_wtime(); while (!bDone) { while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) { // Stop loop if it's a quit message bDone = true; } else { TranslateMessage(&msg); DispatchMessage(&msg); } } if (!pSOM->FinishedTraining()) { pSOM->Epoch(pSOM->m_TrainingSet); //this will call WM_PAINT which will render the map InvalidateRect(hWnd, NULL, TRUE); UpdateWindow(hWnd); } if(pSOM->getIteration() == constNumIterations){ cpuEnd = omp_get_wtime(); bDone = true; } } float cpuTime = (cpuEnd-cpuStart);//*1000; char str[256]; char num[256]; char it[256]; sprintf_s(str, " CPU Time: %6f \n", cpuTime); sprintf_s(num, " Number of Nodes: %d \n",pSOM->getSize()); sprintf_s(it, " Number of Iterations: %d \n",pSOM->getIteration()); OutputDebugString("----------CPU TIME-----------\n"); OutputDebugString(str); OutputDebugString("----------Number of Nodes-----------\n"); OutputDebugString(num); OutputDebugString("----------Number of Iterations-----------\n"); OutputDebugString(it); OutputDebugString("-----------------------------\n"); delete pSOM; UnregisterClass (g_szWindowClassName, winclass.hInstance); return msg.wParam; } void Render(HDC surface) { pSOM->Render(surface); } inline int RandInt(int x, int y) { return rand() % (y - x + 1) + x; } inline double RandFloat() { return (rand()) / (RAND_MAX + 1.0); } void CreateDataSet() { #ifndef RANDOM_TRAINING_SETS //create a data set vector<double> red, green, blue, yellow, orange, purple, dk_green, dk_blue; //push to back of vector red.push_back(1); red.push_back(0); red.push_back(0); green.push_back(0); green.push_back(1); green.push_back(0); dk_green.push_back(0); dk_green.push_back(0.5); dk_green.push_back(0.25); blue.push_back(0); blue.push_back(0); blue.push_back(1); dk_blue.push_back(0); dk_blue.push_back(0); dk_blue.push_back(0.5); yellow.push_back(1); yellow.push_back(1); yellow.push_back(0.2); orange.push_back(1); orange.push_back(0.4); orange.push_back(0.25); purple.push_back(1); purple.push_back(0); purple.push_back(1); m_TrainingSet.push_back(red); m_TrainingSet.push_back(green); m_TrainingSet.push_back(blue); m_TrainingSet.push_back(yellow); m_TrainingSet.push_back(orange); m_TrainingSet.push_back(purple); m_TrainingSet.push_back(dk_green); m_TrainingSet.push_back(dk_blue); #else //choose a random number of training sets int NumSets = RandInt(constMinNumTrainingSets, constMaxNumTrainingSets); for (int s = 0; s<NumSets; ++s) { vector<double> set; set.push_back(RandFloat()); set.push_back(RandFloat()); set.push_back(RandFloat()); pSOM->m_TrainingSet.push_back(set); } #endif }
d69c3e6dd51ae762bb7eabf9e570d32541321540.hip
// !!! This is a file automatically generated by hipify!!! // This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2014 Benoit Steiner <[email protected]> // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. #define EIGEN_TEST_NO_LONGDOUBLE #define EIGEN_TEST_NO_COMPLEX #define EIGEN_TEST_FUNC cxx11_tensor_cuda #define EIGEN_USE_GPU #if defined __CUDACC_VER__ && __CUDACC_VER__ >= 70500 #include <hip/hip_fp16.h> #endif #include "4dface-ulsTracker.h" #include <unsupported/Eigen/CXX11/Tensor> using Eigen::Tensor; void test_cuda_nullary() { Tensor<float, 1, 0, int> in1(2); Tensor<float, 1, 0, int> in2(2); in1.setRandom(); in2.setRandom(); std::size_t tensor_bytes = in1.size() * sizeof(float); float* d_in1; float* d_in2; hipMalloc((void**)(&d_in1), tensor_bytes); hipMalloc((void**)(&d_in2), tensor_bytes); hipMemcpy(d_in1, in1.data(), tensor_bytes, hipMemcpyHostToDevice); hipMemcpy(d_in2, in2.data(), tensor_bytes, hipMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<float, 1, 0, int>, Eigen::Aligned> gpu_in1( d_in1, 2); Eigen::TensorMap<Eigen::Tensor<float, 1, 0, int>, Eigen::Aligned> gpu_in2( d_in2, 2); gpu_in1.device(gpu_device) = gpu_in1.constant(3.14f); gpu_in2.device(gpu_device) = gpu_in2.random(); Tensor<float, 1, 0, int> new1(2); Tensor<float, 1, 0, int> new2(2); assert(hipMemcpyAsync(new1.data(), d_in1, tensor_bytes, hipMemcpyDeviceToHost, gpu_device.stream()) == hipSuccess); assert(hipMemcpyAsync(new2.data(), d_in2, tensor_bytes, hipMemcpyDeviceToHost, gpu_device.stream()) == hipSuccess); assert(hipStreamSynchronize(gpu_device.stream()) == hipSuccess); for (int i = 0; i < 2; ++i) { VERIFY_IS_APPROX(new1(i), 3.14f); VERIFY_IS_NOT_EQUAL(new2(i), in2(i)); } hipFree(d_in1); hipFree(d_in2); } void test_cuda_elementwise_small() { Tensor<float, 1> in1(Eigen::array<Eigen::DenseIndex, 1>(2)); Tensor<float, 1> in2(Eigen::array<Eigen::DenseIndex, 1>(2)); Tensor<float, 1> out(Eigen::array<Eigen::DenseIndex, 1>(2)); in1.setRandom(); in2.setRandom(); std::size_t in1_bytes = in1.size() * sizeof(float); std::size_t in2_bytes = in2.size() * sizeof(float); std::size_t out_bytes = out.size() * sizeof(float); float* d_in1; float* d_in2; float* d_out; hipMalloc((void**)(&d_in1), in1_bytes); hipMalloc((void**)(&d_in2), in2_bytes); hipMalloc((void**)(&d_out), out_bytes); hipMemcpy(d_in1, in1.data(), in1_bytes, hipMemcpyHostToDevice); hipMemcpy(d_in2, in2.data(), in2_bytes, hipMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<float, 1>, Eigen::Aligned> gpu_in1( d_in1, Eigen::array<Eigen::DenseIndex, 1>(2)); Eigen::TensorMap<Eigen::Tensor<float, 1>, Eigen::Aligned> gpu_in2( d_in2, Eigen::array<Eigen::DenseIndex, 1>(2)); Eigen::TensorMap<Eigen::Tensor<float, 1>, Eigen::Aligned> gpu_out( d_out, Eigen::array<Eigen::DenseIndex, 1>(2)); gpu_out.device(gpu_device) = gpu_in1 + gpu_in2; assert(hipMemcpyAsync(out.data(), d_out, out_bytes, hipMemcpyDeviceToHost, gpu_device.stream()) == hipSuccess); assert(hipStreamSynchronize(gpu_device.stream()) == hipSuccess); for (int i = 0; i < 2; ++i) { VERIFY_IS_APPROX( out(Eigen::array<Eigen::DenseIndex, 1>(i)), in1(Eigen::array<Eigen::DenseIndex, 1>(i)) + in2(Eigen::array<Eigen::DenseIndex, 1>(i))); } hipFree(d_in1); hipFree(d_in2); hipFree(d_out); } void test_cuda_elementwise() { Tensor<float, 3> in1(Eigen::array<Eigen::DenseIndex, 3>(72,53,97)); Tensor<float, 3> in2(Eigen::array<Eigen::DenseIndex, 3>(72,53,97)); Tensor<float, 3> in3(Eigen::array<Eigen::DenseIndex, 3>(72,53,97)); Tensor<float, 3> out(Eigen::array<Eigen::DenseIndex, 3>(72,53,97)); in1.setRandom(); in2.setRandom(); in3.setRandom(); std::size_t in1_bytes = in1.size() * sizeof(float); std::size_t in2_bytes = in2.size() * sizeof(float); std::size_t in3_bytes = in3.size() * sizeof(float); std::size_t out_bytes = out.size() * sizeof(float); float* d_in1; float* d_in2; float* d_in3; float* d_out; hipMalloc((void**)(&d_in1), in1_bytes); hipMalloc((void**)(&d_in2), in2_bytes); hipMalloc((void**)(&d_in3), in3_bytes); hipMalloc((void**)(&d_out), out_bytes); hipMemcpy(d_in1, in1.data(), in1_bytes, hipMemcpyHostToDevice); hipMemcpy(d_in2, in2.data(), in2_bytes, hipMemcpyHostToDevice); hipMemcpy(d_in3, in3.data(), in3_bytes, hipMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<float, 3> > gpu_in1(d_in1, Eigen::array<Eigen::DenseIndex, 3>(72,53,97)); Eigen::TensorMap<Eigen::Tensor<float, 3> > gpu_in2(d_in2, Eigen::array<Eigen::DenseIndex, 3>(72,53,97)); Eigen::TensorMap<Eigen::Tensor<float, 3> > gpu_in3(d_in3, Eigen::array<Eigen::DenseIndex, 3>(72,53,97)); Eigen::TensorMap<Eigen::Tensor<float, 3> > gpu_out(d_out, Eigen::array<Eigen::DenseIndex, 3>(72,53,97)); gpu_out.device(gpu_device) = gpu_in1 + gpu_in2 * gpu_in3; assert(hipMemcpyAsync(out.data(), d_out, out_bytes, hipMemcpyDeviceToHost, gpu_device.stream()) == hipSuccess); assert(hipStreamSynchronize(gpu_device.stream()) == hipSuccess); for (int i = 0; i < 72; ++i) { for (int j = 0; j < 53; ++j) { for (int k = 0; k < 97; ++k) { VERIFY_IS_APPROX(out(Eigen::array<Eigen::DenseIndex, 3>(i,j,k)), in1(Eigen::array<Eigen::DenseIndex, 3>(i,j,k)) + in2(Eigen::array<Eigen::DenseIndex, 3>(i,j, k)) * in3(Eigen::array<Eigen::DenseIndex, 3>(i,j,k))); } } } hipFree(d_in1); hipFree(d_in2); hipFree(d_in3); hipFree(d_out); } void test_cuda_props() { Tensor<float, 1> in1(200); Tensor<bool, 1> out(200); in1.setRandom(); std::size_t in1_bytes = in1.size() * sizeof(float); std::size_t out_bytes = out.size() * sizeof(bool); float* d_in1; bool* d_out; hipMalloc((void**)(&d_in1), in1_bytes); hipMalloc((void**)(&d_out), out_bytes); hipMemcpy(d_in1, in1.data(), in1_bytes, hipMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<float, 1>, Eigen::Aligned> gpu_in1( d_in1, 200); Eigen::TensorMap<Eigen::Tensor<bool, 1>, Eigen::Aligned> gpu_out( d_out, 200); gpu_out.device(gpu_device) = (gpu_in1.isnan)(); assert(hipMemcpyAsync(out.data(), d_out, out_bytes, hipMemcpyDeviceToHost, gpu_device.stream()) == hipSuccess); assert(hipStreamSynchronize(gpu_device.stream()) == hipSuccess); for (int i = 0; i < 200; ++i) { VERIFY_IS_EQUAL(out(i), (std::isnan)(in1(i))); } hipFree(d_in1); hipFree(d_out); } void test_cuda_reduction() { Tensor<float, 4> in1(72,53,97,113); Tensor<float, 2> out(72,97); in1.setRandom(); std::size_t in1_bytes = in1.size() * sizeof(float); std::size_t out_bytes = out.size() * sizeof(float); float* d_in1; float* d_out; hipMalloc((void**)(&d_in1), in1_bytes); hipMalloc((void**)(&d_out), out_bytes); hipMemcpy(d_in1, in1.data(), in1_bytes, hipMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<float, 4> > gpu_in1(d_in1, 72,53,97,113); Eigen::TensorMap<Eigen::Tensor<float, 2> > gpu_out(d_out, 72,97); array<Eigen::DenseIndex, 2> reduction_axis; reduction_axis[0] = 1; reduction_axis[1] = 3; gpu_out.device(gpu_device) = gpu_in1.maximum(reduction_axis); assert(hipMemcpyAsync(out.data(), d_out, out_bytes, hipMemcpyDeviceToHost, gpu_device.stream()) == hipSuccess); assert(hipStreamSynchronize(gpu_device.stream()) == hipSuccess); for (int i = 0; i < 72; ++i) { for (int j = 0; j < 97; ++j) { float expected = 0; for (int k = 0; k < 53; ++k) { for (int l = 0; l < 113; ++l) { expected = std::max<float>(expected, in1(i, k, j, l)); } } VERIFY_IS_APPROX(out(i,j), expected); } } hipFree(d_in1); hipFree(d_out); } template<int DataLayout> void test_cuda_contraction() { // with these dimensions, the output has 300 * 140 elements, which is // more than 30 * 1024, which is the number of threads in blocks on // a 15 SM GK110 GPU Tensor<float, 4, DataLayout> t_left(6, 50, 3, 31); Tensor<float, 5, DataLayout> t_right(Eigen::array<Eigen::DenseIndex, 5>(3, 31, 7, 20, 1)); Tensor<float, 5, DataLayout> t_result(Eigen::array<Eigen::DenseIndex, 5>(6, 50, 7, 20, 1)); t_left.setRandom(); t_right.setRandom(); std::size_t t_left_bytes = t_left.size() * sizeof(float); std::size_t t_right_bytes = t_right.size() * sizeof(float); std::size_t t_result_bytes = t_result.size() * sizeof(float); float* d_t_left; float* d_t_right; float* d_t_result; hipMalloc((void**)(&d_t_left), t_left_bytes); hipMalloc((void**)(&d_t_right), t_right_bytes); hipMalloc((void**)(&d_t_result), t_result_bytes); hipMemcpy(d_t_left, t_left.data(), t_left_bytes, hipMemcpyHostToDevice); hipMemcpy(d_t_right, t_right.data(), t_right_bytes, hipMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<float, 4, DataLayout> > gpu_t_left(d_t_left, 6, 50, 3, 31); Eigen::TensorMap<Eigen::Tensor<float, 5, DataLayout> > gpu_t_right(d_t_right, 3, 31, 7, 20, 1); Eigen::TensorMap<Eigen::Tensor<float, 5, DataLayout> > gpu_t_result(d_t_result, 6, 50, 7, 20, 1); typedef Eigen::Map<Eigen::Matrix<float, Dynamic, Dynamic, DataLayout> > MapXf; MapXf m_left(t_left.data(), 300, 93); MapXf m_right(t_right.data(), 93, 140); Eigen::Matrix<float, Dynamic, Dynamic, DataLayout> m_result(300, 140); typedef Tensor<float, 1>::DimensionPair DimPair; Eigen::array<DimPair, 2> dims; dims[0] = DimPair(2, 0); dims[1] = DimPair(3, 1); m_result = m_left * m_right; gpu_t_result.device(gpu_device) = gpu_t_left.contract(gpu_t_right, dims); hipMemcpy(t_result.data(), d_t_result, t_result_bytes, hipMemcpyDeviceToHost); for (DenseIndex i = 0; i < t_result.size(); i++) { if (fabs(t_result.data()[i] - m_result.data()[i]) >= 1e-4f) { std::cout << "mismatch detected at index " << i << ": " << t_result.data()[i] << " vs " << m_result.data()[i] << std::endl; assert(false); } } hipFree(d_t_left); hipFree(d_t_right); hipFree(d_t_result); } template<int DataLayout> void test_cuda_convolution_1d() { Tensor<float, 4, DataLayout> input(74,37,11,137); Tensor<float, 1, DataLayout> kernel(4); Tensor<float, 4, DataLayout> out(74,34,11,137); input = input.constant(10.0f) + input.random(); kernel = kernel.constant(7.0f) + kernel.random(); std::size_t input_bytes = input.size() * sizeof(float); std::size_t kernel_bytes = kernel.size() * sizeof(float); std::size_t out_bytes = out.size() * sizeof(float); float* d_input; float* d_kernel; float* d_out; hipMalloc((void**)(&d_input), input_bytes); hipMalloc((void**)(&d_kernel), kernel_bytes); hipMalloc((void**)(&d_out), out_bytes); hipMemcpy(d_input, input.data(), input_bytes, hipMemcpyHostToDevice); hipMemcpy(d_kernel, kernel.data(), kernel_bytes, hipMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<float, 4, DataLayout> > gpu_input(d_input, 74,37,11,137); Eigen::TensorMap<Eigen::Tensor<float, 1, DataLayout> > gpu_kernel(d_kernel, 4); Eigen::TensorMap<Eigen::Tensor<float, 4, DataLayout> > gpu_out(d_out, 74,34,11,137); Eigen::array<Eigen::DenseIndex, 1> dims(1); gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims); assert(hipMemcpyAsync(out.data(), d_out, out_bytes, hipMemcpyDeviceToHost, gpu_device.stream()) == hipSuccess); assert(hipStreamSynchronize(gpu_device.stream()) == hipSuccess); for (int i = 0; i < 74; ++i) { for (int j = 0; j < 34; ++j) { for (int k = 0; k < 11; ++k) { for (int l = 0; l < 137; ++l) { const float result = out(i,j,k,l); const float expected = input(i,j+0,k,l) * kernel(0) + input(i,j+1,k,l) * kernel(1) + input(i,j+2,k,l) * kernel(2) + input(i,j+3,k,l) * kernel(3); VERIFY_IS_APPROX(result, expected); } } } } hipFree(d_input); hipFree(d_kernel); hipFree(d_out); } void test_cuda_convolution_inner_dim_col_major_1d() { Tensor<float, 4, ColMajor> input(74,9,11,7); Tensor<float, 1, ColMajor> kernel(4); Tensor<float, 4, ColMajor> out(71,9,11,7); input = input.constant(10.0f) + input.random(); kernel = kernel.constant(7.0f) + kernel.random(); std::size_t input_bytes = input.size() * sizeof(float); std::size_t kernel_bytes = kernel.size() * sizeof(float); std::size_t out_bytes = out.size() * sizeof(float); float* d_input; float* d_kernel; float* d_out; hipMalloc((void**)(&d_input), input_bytes); hipMalloc((void**)(&d_kernel), kernel_bytes); hipMalloc((void**)(&d_out), out_bytes); hipMemcpy(d_input, input.data(), input_bytes, hipMemcpyHostToDevice); hipMemcpy(d_kernel, kernel.data(), kernel_bytes, hipMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<float, 4, ColMajor> > gpu_input(d_input,74,9,11,7); Eigen::TensorMap<Eigen::Tensor<float, 1, ColMajor> > gpu_kernel(d_kernel,4); Eigen::TensorMap<Eigen::Tensor<float, 4, ColMajor> > gpu_out(d_out,71,9,11,7); Eigen::array<Eigen::DenseIndex, 1> dims(0); gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims); assert(hipMemcpyAsync(out.data(), d_out, out_bytes, hipMemcpyDeviceToHost, gpu_device.stream()) == hipSuccess); assert(hipStreamSynchronize(gpu_device.stream()) == hipSuccess); for (int i = 0; i < 71; ++i) { for (int j = 0; j < 9; ++j) { for (int k = 0; k < 11; ++k) { for (int l = 0; l < 7; ++l) { const float result = out(i,j,k,l); const float expected = input(i+0,j,k,l) * kernel(0) + input(i+1,j,k,l) * kernel(1) + input(i+2,j,k,l) * kernel(2) + input(i+3,j,k,l) * kernel(3); VERIFY_IS_APPROX(result, expected); } } } } hipFree(d_input); hipFree(d_kernel); hipFree(d_out); } void test_cuda_convolution_inner_dim_row_major_1d() { Tensor<float, 4, RowMajor> input(7,9,11,74); Tensor<float, 1, RowMajor> kernel(4); Tensor<float, 4, RowMajor> out(7,9,11,71); input = input.constant(10.0f) + input.random(); kernel = kernel.constant(7.0f) + kernel.random(); std::size_t input_bytes = input.size() * sizeof(float); std::size_t kernel_bytes = kernel.size() * sizeof(float); std::size_t out_bytes = out.size() * sizeof(float); float* d_input; float* d_kernel; float* d_out; hipMalloc((void**)(&d_input), input_bytes); hipMalloc((void**)(&d_kernel), kernel_bytes); hipMalloc((void**)(&d_out), out_bytes); hipMemcpy(d_input, input.data(), input_bytes, hipMemcpyHostToDevice); hipMemcpy(d_kernel, kernel.data(), kernel_bytes, hipMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<float, 4, RowMajor> > gpu_input(d_input, 7,9,11,74); Eigen::TensorMap<Eigen::Tensor<float, 1, RowMajor> > gpu_kernel(d_kernel, 4); Eigen::TensorMap<Eigen::Tensor<float, 4, RowMajor> > gpu_out(d_out, 7,9,11,71); Eigen::array<Eigen::DenseIndex, 1> dims(3); gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims); assert(hipMemcpyAsync(out.data(), d_out, out_bytes, hipMemcpyDeviceToHost, gpu_device.stream()) == hipSuccess); assert(hipStreamSynchronize(gpu_device.stream()) == hipSuccess); for (int i = 0; i < 7; ++i) { for (int j = 0; j < 9; ++j) { for (int k = 0; k < 11; ++k) { for (int l = 0; l < 71; ++l) { const float result = out(i,j,k,l); const float expected = input(i,j,k,l+0) * kernel(0) + input(i,j,k,l+1) * kernel(1) + input(i,j,k,l+2) * kernel(2) + input(i,j,k,l+3) * kernel(3); VERIFY_IS_APPROX(result, expected); } } } } hipFree(d_input); hipFree(d_kernel); hipFree(d_out); } template<int DataLayout> void test_cuda_convolution_2d() { Tensor<float, 4, DataLayout> input(74,37,11,137); Tensor<float, 2, DataLayout> kernel(3,4); Tensor<float, 4, DataLayout> out(74,35,8,137); input = input.constant(10.0f) + input.random(); kernel = kernel.constant(7.0f) + kernel.random(); std::size_t input_bytes = input.size() * sizeof(float); std::size_t kernel_bytes = kernel.size() * sizeof(float); std::size_t out_bytes = out.size() * sizeof(float); float* d_input; float* d_kernel; float* d_out; hipMalloc((void**)(&d_input), input_bytes); hipMalloc((void**)(&d_kernel), kernel_bytes); hipMalloc((void**)(&d_out), out_bytes); hipMemcpy(d_input, input.data(), input_bytes, hipMemcpyHostToDevice); hipMemcpy(d_kernel, kernel.data(), kernel_bytes, hipMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<float, 4, DataLayout> > gpu_input(d_input,74,37,11,137); Eigen::TensorMap<Eigen::Tensor<float, 2, DataLayout> > gpu_kernel(d_kernel,3,4); Eigen::TensorMap<Eigen::Tensor<float, 4, DataLayout> > gpu_out(d_out,74,35,8,137); Eigen::array<Eigen::DenseIndex, 2> dims(1,2); gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims); assert(hipMemcpyAsync(out.data(), d_out, out_bytes, hipMemcpyDeviceToHost, gpu_device.stream()) == hipSuccess); assert(hipStreamSynchronize(gpu_device.stream()) == hipSuccess); for (int i = 0; i < 74; ++i) { for (int j = 0; j < 35; ++j) { for (int k = 0; k < 8; ++k) { for (int l = 0; l < 137; ++l) { const float result = out(i,j,k,l); const float expected = input(i,j+0,k+0,l) * kernel(0,0) + input(i,j+1,k+0,l) * kernel(1,0) + input(i,j+2,k+0,l) * kernel(2,0) + input(i,j+0,k+1,l) * kernel(0,1) + input(i,j+1,k+1,l) * kernel(1,1) + input(i,j+2,k+1,l) * kernel(2,1) + input(i,j+0,k+2,l) * kernel(0,2) + input(i,j+1,k+2,l) * kernel(1,2) + input(i,j+2,k+2,l) * kernel(2,2) + input(i,j+0,k+3,l) * kernel(0,3) + input(i,j+1,k+3,l) * kernel(1,3) + input(i,j+2,k+3,l) * kernel(2,3); VERIFY_IS_APPROX(result, expected); } } } } hipFree(d_input); hipFree(d_kernel); hipFree(d_out); } template<int DataLayout> void test_cuda_convolution_3d() { Tensor<float, 5, DataLayout> input(Eigen::array<Eigen::DenseIndex, 5>(74,37,11,137,17)); Tensor<float, 3, DataLayout> kernel(3,4,2); Tensor<float, 5, DataLayout> out(Eigen::array<Eigen::DenseIndex, 5>(74,35,8,136,17)); input = input.constant(10.0f) + input.random(); kernel = kernel.constant(7.0f) + kernel.random(); std::size_t input_bytes = input.size() * sizeof(float); std::size_t kernel_bytes = kernel.size() * sizeof(float); std::size_t out_bytes = out.size() * sizeof(float); float* d_input; float* d_kernel; float* d_out; hipMalloc((void**)(&d_input), input_bytes); hipMalloc((void**)(&d_kernel), kernel_bytes); hipMalloc((void**)(&d_out), out_bytes); hipMemcpy(d_input, input.data(), input_bytes, hipMemcpyHostToDevice); hipMemcpy(d_kernel, kernel.data(), kernel_bytes, hipMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<float, 5, DataLayout> > gpu_input(d_input,74,37,11,137,17); Eigen::TensorMap<Eigen::Tensor<float, 3, DataLayout> > gpu_kernel(d_kernel,3,4,2); Eigen::TensorMap<Eigen::Tensor<float, 5, DataLayout> > gpu_out(d_out,74,35,8,136,17); Eigen::array<Eigen::DenseIndex, 3> dims(1,2,3); gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims); assert(hipMemcpyAsync(out.data(), d_out, out_bytes, hipMemcpyDeviceToHost, gpu_device.stream()) == hipSuccess); assert(hipStreamSynchronize(gpu_device.stream()) == hipSuccess); for (int i = 0; i < 74; ++i) { for (int j = 0; j < 35; ++j) { for (int k = 0; k < 8; ++k) { for (int l = 0; l < 136; ++l) { for (int m = 0; m < 17; ++m) { const float result = out(i,j,k,l,m); const float expected = input(i,j+0,k+0,l+0,m) * kernel(0,0,0) + input(i,j+1,k+0,l+0,m) * kernel(1,0,0) + input(i,j+2,k+0,l+0,m) * kernel(2,0,0) + input(i,j+0,k+1,l+0,m) * kernel(0,1,0) + input(i,j+1,k+1,l+0,m) * kernel(1,1,0) + input(i,j+2,k+1,l+0,m) * kernel(2,1,0) + input(i,j+0,k+2,l+0,m) * kernel(0,2,0) + input(i,j+1,k+2,l+0,m) * kernel(1,2,0) + input(i,j+2,k+2,l+0,m) * kernel(2,2,0) + input(i,j+0,k+3,l+0,m) * kernel(0,3,0) + input(i,j+1,k+3,l+0,m) * kernel(1,3,0) + input(i,j+2,k+3,l+0,m) * kernel(2,3,0) + input(i,j+0,k+0,l+1,m) * kernel(0,0,1) + input(i,j+1,k+0,l+1,m) * kernel(1,0,1) + input(i,j+2,k+0,l+1,m) * kernel(2,0,1) + input(i,j+0,k+1,l+1,m) * kernel(0,1,1) + input(i,j+1,k+1,l+1,m) * kernel(1,1,1) + input(i,j+2,k+1,l+1,m) * kernel(2,1,1) + input(i,j+0,k+2,l+1,m) * kernel(0,2,1) + input(i,j+1,k+2,l+1,m) * kernel(1,2,1) + input(i,j+2,k+2,l+1,m) * kernel(2,2,1) + input(i,j+0,k+3,l+1,m) * kernel(0,3,1) + input(i,j+1,k+3,l+1,m) * kernel(1,3,1) + input(i,j+2,k+3,l+1,m) * kernel(2,3,1); VERIFY_IS_APPROX(result, expected); } } } } } hipFree(d_input); hipFree(d_kernel); hipFree(d_out); } template <typename Scalar> void test_cuda_lgamma(const Scalar stddev) { Tensor<Scalar, 2> in(72,97); in.setRandom(); in *= in.constant(stddev); Tensor<Scalar, 2> out(72,97); out.setZero(); std::size_t bytes = in.size() * sizeof(Scalar); Scalar* d_in; Scalar* d_out; hipMalloc((void**)(&d_in), bytes); hipMalloc((void**)(&d_out), bytes); hipMemcpy(d_in, in.data(), bytes, hipMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_in(d_in, 72, 97); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_out(d_out, 72, 97); gpu_out.device(gpu_device) = gpu_in.lgamma(); assert(hipMemcpyAsync(out.data(), d_out, bytes, hipMemcpyDeviceToHost, gpu_device.stream()) == hipSuccess); assert(hipStreamSynchronize(gpu_device.stream()) == hipSuccess); for (int i = 0; i < 72; ++i) { for (int j = 0; j < 97; ++j) { VERIFY_IS_APPROX(out(i,j), (std::lgamma)(in(i,j))); } } hipFree(d_in); hipFree(d_out); } template <typename Scalar> void test_cuda_digamma() { Tensor<Scalar, 1> in(7); Tensor<Scalar, 1> out(7); Tensor<Scalar, 1> expected_out(7); out.setZero(); in(0) = Scalar(1); in(1) = Scalar(1.5); in(2) = Scalar(4); in(3) = Scalar(-10.5); in(4) = Scalar(10000.5); in(5) = Scalar(0); in(6) = Scalar(-1); expected_out(0) = Scalar(-0.5772156649015329); expected_out(1) = Scalar(0.03648997397857645); expected_out(2) = Scalar(1.2561176684318); expected_out(3) = Scalar(2.398239129535781); expected_out(4) = Scalar(9.210340372392849); expected_out(5) = std::numeric_limits<Scalar>::infinity(); expected_out(6) = std::numeric_limits<Scalar>::infinity(); std::size_t bytes = in.size() * sizeof(Scalar); Scalar* d_in; Scalar* d_out; hipMalloc((void**)(&d_in), bytes); hipMalloc((void**)(&d_out), bytes); hipMemcpy(d_in, in.data(), bytes, hipMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_in(d_in, 7); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_out(d_out, 7); gpu_out.device(gpu_device) = gpu_in.digamma(); assert(hipMemcpyAsync(out.data(), d_out, bytes, hipMemcpyDeviceToHost, gpu_device.stream()) == hipSuccess); assert(hipStreamSynchronize(gpu_device.stream()) == hipSuccess); for (int i = 0; i < 5; ++i) { VERIFY_IS_APPROX(out(i), expected_out(i)); } for (int i = 5; i < 7; ++i) { VERIFY_IS_EQUAL(out(i), expected_out(i)); } hipFree(d_in); hipFree(d_out); } template <typename Scalar> void test_cuda_zeta() { Tensor<Scalar, 1> in_x(6); Tensor<Scalar, 1> in_q(6); Tensor<Scalar, 1> out(6); Tensor<Scalar, 1> expected_out(6); out.setZero(); in_x(0) = Scalar(1); in_x(1) = Scalar(1.5); in_x(2) = Scalar(4); in_x(3) = Scalar(-10.5); in_x(4) = Scalar(10000.5); in_x(5) = Scalar(3); in_q(0) = Scalar(1.2345); in_q(1) = Scalar(2); in_q(2) = Scalar(1.5); in_q(3) = Scalar(3); in_q(4) = Scalar(1.0001); in_q(5) = Scalar(-2.5); expected_out(0) = std::numeric_limits<Scalar>::infinity(); expected_out(1) = Scalar(1.61237534869); expected_out(2) = Scalar(0.234848505667); expected_out(3) = Scalar(1.03086757337e-5); expected_out(4) = Scalar(0.367879440865); expected_out(5) = Scalar(0.054102025820864097); std::size_t bytes = in_x.size() * sizeof(Scalar); Scalar* d_in_x; Scalar* d_in_q; Scalar* d_out; hipMalloc((void**)(&d_in_x), bytes); hipMalloc((void**)(&d_in_q), bytes); hipMalloc((void**)(&d_out), bytes); hipMemcpy(d_in_x, in_x.data(), bytes, hipMemcpyHostToDevice); hipMemcpy(d_in_q, in_q.data(), bytes, hipMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_in_x(d_in_x, 6); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_in_q(d_in_q, 6); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_out(d_out, 6); gpu_out.device(gpu_device) = gpu_in_x.zeta(gpu_in_q); assert(hipMemcpyAsync(out.data(), d_out, bytes, hipMemcpyDeviceToHost, gpu_device.stream()) == hipSuccess); assert(hipStreamSynchronize(gpu_device.stream()) == hipSuccess); VERIFY_IS_EQUAL(out(0), expected_out(0)); VERIFY((std::isnan)(out(3))); for (int i = 1; i < 6; ++i) { if (i != 3) { VERIFY_IS_APPROX(out(i), expected_out(i)); } } hipFree(d_in_x); hipFree(d_in_q); hipFree(d_out); } template <typename Scalar> void test_cuda_polygamma() { Tensor<Scalar, 1> in_x(7); Tensor<Scalar, 1> in_n(7); Tensor<Scalar, 1> out(7); Tensor<Scalar, 1> expected_out(7); out.setZero(); in_n(0) = Scalar(1); in_n(1) = Scalar(1); in_n(2) = Scalar(1); in_n(3) = Scalar(17); in_n(4) = Scalar(31); in_n(5) = Scalar(28); in_n(6) = Scalar(8); in_x(0) = Scalar(2); in_x(1) = Scalar(3); in_x(2) = Scalar(25.5); in_x(3) = Scalar(4.7); in_x(4) = Scalar(11.8); in_x(5) = Scalar(17.7); in_x(6) = Scalar(30.2); expected_out(0) = Scalar(0.644934066848); expected_out(1) = Scalar(0.394934066848); expected_out(2) = Scalar(0.0399946696496); expected_out(3) = Scalar(293.334565435); expected_out(4) = Scalar(0.445487887616); expected_out(5) = Scalar(-2.47810300902e-07); expected_out(6) = Scalar(-8.29668781082e-09); std::size_t bytes = in_x.size() * sizeof(Scalar); Scalar* d_in_x; Scalar* d_in_n; Scalar* d_out; hipMalloc((void**)(&d_in_x), bytes); hipMalloc((void**)(&d_in_n), bytes); hipMalloc((void**)(&d_out), bytes); hipMemcpy(d_in_x, in_x.data(), bytes, hipMemcpyHostToDevice); hipMemcpy(d_in_n, in_n.data(), bytes, hipMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_in_x(d_in_x, 7); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_in_n(d_in_n, 7); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_out(d_out, 7); gpu_out.device(gpu_device) = gpu_in_n.polygamma(gpu_in_x); assert(hipMemcpyAsync(out.data(), d_out, bytes, hipMemcpyDeviceToHost, gpu_device.stream()) == hipSuccess); assert(hipStreamSynchronize(gpu_device.stream()) == hipSuccess); for (int i = 0; i < 7; ++i) { VERIFY_IS_APPROX(out(i), expected_out(i)); } hipFree(d_in_x); hipFree(d_in_n); hipFree(d_out); } template <typename Scalar> void test_cuda_igamma() { Tensor<Scalar, 2> a(6, 6); Tensor<Scalar, 2> x(6, 6); Tensor<Scalar, 2> out(6, 6); out.setZero(); Scalar a_s[] = {Scalar(0), Scalar(1), Scalar(1.5), Scalar(4), Scalar(0.0001), Scalar(1000.5)}; Scalar x_s[] = {Scalar(0), Scalar(1), Scalar(1.5), Scalar(4), Scalar(0.0001), Scalar(1000.5)}; for (int i = 0; i < 6; ++i) { for (int j = 0; j < 6; ++j) { a(i, j) = a_s[i]; x(i, j) = x_s[j]; } } Scalar nan = std::numeric_limits<Scalar>::quiet_NaN(); Scalar igamma_s[][6] = {{0.0, nan, nan, nan, nan, nan}, { 0.0, 0.6321205588285578, 0.7768698398515702, 0.9816843611112658, 9.999500016666262e-05, 1.0 }, { 0.0, 0.4275932955291202, 0.608374823728911, 0.9539882943107686, 7.522076445089201e-07, 1.0 }, { 0.0, 0.01898815687615381, 0.06564245437845008, 0.5665298796332909, 4.166333347221828e-18, 1.0 }, { 0.0, 0.9999780593618628, 0.9999899967080838, 0.9999996219837988, 0.9991370418689945, 1.0 }, {0.0, 0.0, 0.0, 0.0, 0.0, 0.5042041932513908} }; std::size_t bytes = a.size() * sizeof(Scalar); Scalar* d_a; Scalar* d_x; Scalar* d_out; assert(hipMalloc((void**)(&d_a), bytes) == hipSuccess); assert(hipMalloc((void**)(&d_x), bytes) == hipSuccess); assert(hipMalloc((void**)(&d_out), bytes) == hipSuccess); hipMemcpy(d_a, a.data(), bytes, hipMemcpyHostToDevice); hipMemcpy(d_x, x.data(), bytes, hipMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_a(d_a, 6, 6); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_x(d_x, 6, 6); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_out(d_out, 6, 6); gpu_out.device(gpu_device) = gpu_a.igamma(gpu_x); assert(hipMemcpyAsync(out.data(), d_out, bytes, hipMemcpyDeviceToHost, gpu_device.stream()) == hipSuccess); assert(hipStreamSynchronize(gpu_device.stream()) == hipSuccess); for (int i = 0; i < 6; ++i) { for (int j = 0; j < 6; ++j) { if ((std::isnan)(igamma_s[i][j])) { VERIFY((std::isnan)(out(i, j))); } else { VERIFY_IS_APPROX(out(i, j), igamma_s[i][j]); } } } hipFree(d_a); hipFree(d_x); hipFree(d_out); } template <typename Scalar> void test_cuda_igammac() { Tensor<Scalar, 2> a(6, 6); Tensor<Scalar, 2> x(6, 6); Tensor<Scalar, 2> out(6, 6); out.setZero(); Scalar a_s[] = {Scalar(0), Scalar(1), Scalar(1.5), Scalar(4), Scalar(0.0001), Scalar(1000.5)}; Scalar x_s[] = {Scalar(0), Scalar(1), Scalar(1.5), Scalar(4), Scalar(0.0001), Scalar(1000.5)}; for (int i = 0; i < 6; ++i) { for (int j = 0; j < 6; ++j) { a(i, j) = a_s[i]; x(i, j) = x_s[j]; } } Scalar nan = std::numeric_limits<Scalar>::quiet_NaN(); Scalar igammac_s[][6] = {{nan, nan, nan, nan, nan, nan}, { 1.0, 0.36787944117144233, 0.22313016014842982, 0.018315638888734182, 0.9999000049998333, 0.0 }, { 1.0, 0.5724067044708798, 0.3916251762710878, 0.04601170568923136, 0.9999992477923555, 0.0 }, { 1.0, 0.9810118431238462, 0.9343575456215499, 0.4334701203667089, 1.0, 0.0 }, { 1.0, 2.1940638138146658e-05, 1.0003291916285e-05, 3.7801620118431334e-07, 0.0008629581310054535, 0.0 }, {1.0, 1.0, 1.0, 1.0, 1.0, 0.49579580674813944} }; std::size_t bytes = a.size() * sizeof(Scalar); Scalar* d_a; Scalar* d_x; Scalar* d_out; hipMalloc((void**)(&d_a), bytes); hipMalloc((void**)(&d_x), bytes); hipMalloc((void**)(&d_out), bytes); hipMemcpy(d_a, a.data(), bytes, hipMemcpyHostToDevice); hipMemcpy(d_x, x.data(), bytes, hipMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_a(d_a, 6, 6); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_x(d_x, 6, 6); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_out(d_out, 6, 6); gpu_out.device(gpu_device) = gpu_a.igammac(gpu_x); assert(hipMemcpyAsync(out.data(), d_out, bytes, hipMemcpyDeviceToHost, gpu_device.stream()) == hipSuccess); assert(hipStreamSynchronize(gpu_device.stream()) == hipSuccess); for (int i = 0; i < 6; ++i) { for (int j = 0; j < 6; ++j) { if ((std::isnan)(igammac_s[i][j])) { VERIFY((std::isnan)(out(i, j))); } else { VERIFY_IS_APPROX(out(i, j), igammac_s[i][j]); } } } hipFree(d_a); hipFree(d_x); hipFree(d_out); } template <typename Scalar> void test_cuda_erf(const Scalar stddev) { Tensor<Scalar, 2> in(72,97); in.setRandom(); in *= in.constant(stddev); Tensor<Scalar, 2> out(72,97); out.setZero(); std::size_t bytes = in.size() * sizeof(Scalar); Scalar* d_in; Scalar* d_out; assert(hipMalloc((void**)(&d_in), bytes) == hipSuccess); assert(hipMalloc((void**)(&d_out), bytes) == hipSuccess); hipMemcpy(d_in, in.data(), bytes, hipMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_in(d_in, 72, 97); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_out(d_out, 72, 97); gpu_out.device(gpu_device) = gpu_in.erf(); assert(hipMemcpyAsync(out.data(), d_out, bytes, hipMemcpyDeviceToHost, gpu_device.stream()) == hipSuccess); assert(hipStreamSynchronize(gpu_device.stream()) == hipSuccess); for (int i = 0; i < 72; ++i) { for (int j = 0; j < 97; ++j) { VERIFY_IS_APPROX(out(i,j), (std::erf)(in(i,j))); } } hipFree(d_in); hipFree(d_out); } template <typename Scalar> void test_cuda_erfc(const Scalar stddev) { Tensor<Scalar, 2> in(72,97); in.setRandom(); in *= in.constant(stddev); Tensor<Scalar, 2> out(72,97); out.setZero(); std::size_t bytes = in.size() * sizeof(Scalar); Scalar* d_in; Scalar* d_out; hipMalloc((void**)(&d_in), bytes); hipMalloc((void**)(&d_out), bytes); hipMemcpy(d_in, in.data(), bytes, hipMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_in(d_in, 72, 97); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_out(d_out, 72, 97); gpu_out.device(gpu_device) = gpu_in.erfc(); assert(hipMemcpyAsync(out.data(), d_out, bytes, hipMemcpyDeviceToHost, gpu_device.stream()) == hipSuccess); assert(hipStreamSynchronize(gpu_device.stream()) == hipSuccess); for (int i = 0; i < 72; ++i) { for (int j = 0; j < 97; ++j) { VERIFY_IS_APPROX(out(i,j), (std::erfc)(in(i,j))); } } hipFree(d_in); hipFree(d_out); } template <typename Scalar> void test_cuda_betainc() { Tensor<Scalar, 1> in_x(125); Tensor<Scalar, 1> in_a(125); Tensor<Scalar, 1> in_b(125); Tensor<Scalar, 1> out(125); Tensor<Scalar, 1> expected_out(125); out.setZero(); Scalar nan = std::numeric_limits<Scalar>::quiet_NaN(); Array<Scalar, 1, Dynamic> x(125); Array<Scalar, 1, Dynamic> a(125); Array<Scalar, 1, Dynamic> b(125); Array<Scalar, 1, Dynamic> v(125); a << 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999; b << 0.0, 0.0, 0.0, 0.0, 0.0, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.999, 0.999, 0.999, 0.999, 0.999, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 999.999, 999.999, 999.999, 999.999, 999.999, 0.0, 0.0, 0.0, 0.0, 0.0, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.999, 0.999, 0.999, 0.999, 0.999, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 999.999, 999.999, 999.999, 999.999, 999.999, 0.0, 0.0, 0.0, 0.0, 0.0, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.999, 0.999, 0.999, 0.999, 0.999, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 999.999, 999.999, 999.999, 999.999, 999.999, 0.0, 0.0, 0.0, 0.0, 0.0, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.999, 0.999, 0.999, 0.999, 0.999, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 999.999, 999.999, 999.999, 999.999, 999.999, 0.0, 0.0, 0.0, 0.0, 0.0, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.999, 0.999, 0.999, 0.999, 0.999, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 999.999, 999.999, 999.999, 999.999, 999.999; x << -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1; v << nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, 0.47972119876364683, 0.5, 0.5202788012363533, nan, nan, 0.9518683957740043, 0.9789663010413743, 0.9931729188073435, nan, nan, 0.999995949033062, 0.9999999999993698, 0.9999999999999999, nan, nan, 0.9999999999999999, 0.9999999999999999, 0.9999999999999999, nan, nan, nan, nan, nan, nan, nan, 0.006827081192655869, 0.0210336989586256, 0.04813160422599567, nan, nan, 0.20014344256217678, 0.5000000000000001, 0.7998565574378232, nan, nan, 0.9991401428435834, 0.999999999698403, 0.9999999999999999, nan, nan, 0.9999999999999999, 0.9999999999999999, 0.9999999999999999, nan, nan, nan, nan, nan, nan, nan, 1.0646600232370887e-25, 6.301722877826246e-13, 4.050966937974938e-06, nan, nan, 7.864342668429763e-23, 3.015969667594166e-10, 0.0008598571564165444, nan, nan, 6.031987710123844e-08, 0.5000000000000007, 0.9999999396801229, nan, nan, 0.9999999999999999, 0.9999999999999999, 0.9999999999999999, nan, nan, nan, nan, nan, nan, nan, 0.0, 7.029920380986636e-306, 2.2450728208591345e-101, nan, nan, 0.0, 9.275871147869727e-302, 1.2232913026152827e-97, nan, nan, 0.0, 3.0891393081932924e-252, 2.9303043666183996e-60, nan, nan, 2.248913486879199e-196, 0.5000000000004947, 0.9999999999999999, nan; for (int i = 0; i < 125; ++i) { in_x(i) = x(i); in_a(i) = a(i); in_b(i) = b(i); expected_out(i) = v(i); } std::size_t bytes = in_x.size() * sizeof(Scalar); Scalar* d_in_x; Scalar* d_in_a; Scalar* d_in_b; Scalar* d_out; hipMalloc((void**)(&d_in_x), bytes); hipMalloc((void**)(&d_in_a), bytes); hipMalloc((void**)(&d_in_b), bytes); hipMalloc((void**)(&d_out), bytes); hipMemcpy(d_in_x, in_x.data(), bytes, hipMemcpyHostToDevice); hipMemcpy(d_in_a, in_a.data(), bytes, hipMemcpyHostToDevice); hipMemcpy(d_in_b, in_b.data(), bytes, hipMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_in_x(d_in_x, 125); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_in_a(d_in_a, 125); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_in_b(d_in_b, 125); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_out(d_out, 125); gpu_out.device(gpu_device) = betainc(gpu_in_a, gpu_in_b, gpu_in_x); assert(hipMemcpyAsync(out.data(), d_out, bytes, hipMemcpyDeviceToHost, gpu_device.stream()) == hipSuccess); assert(hipStreamSynchronize(gpu_device.stream()) == hipSuccess); for (int i = 1; i < 125; ++i) { if ((std::isnan)(expected_out(i))) { VERIFY((std::isnan)(out(i))); } else { VERIFY_IS_APPROX(out(i), expected_out(i)); } } hipFree(d_in_x); hipFree(d_in_a); hipFree(d_in_b); hipFree(d_out); } void test_cxx11_tensor_cuda() { CALL_SUBTEST_1(test_cuda_nullary()); CALL_SUBTEST_1(test_cuda_elementwise_small()); CALL_SUBTEST_1(test_cuda_elementwise()); CALL_SUBTEST_1(test_cuda_props()); CALL_SUBTEST_1(test_cuda_reduction()); CALL_SUBTEST_2(test_cuda_contraction<ColMajor>()); CALL_SUBTEST_2(test_cuda_contraction<RowMajor>()); CALL_SUBTEST_3(test_cuda_convolution_1d<ColMajor>()); CALL_SUBTEST_3(test_cuda_convolution_1d<RowMajor>()); CALL_SUBTEST_3(test_cuda_convolution_inner_dim_col_major_1d()); CALL_SUBTEST_3(test_cuda_convolution_inner_dim_row_major_1d()); CALL_SUBTEST_3(test_cuda_convolution_2d<ColMajor>()); CALL_SUBTEST_3(test_cuda_convolution_2d<RowMajor>()); CALL_SUBTEST_3(test_cuda_convolution_3d<ColMajor>()); CALL_SUBTEST_3(test_cuda_convolution_3d<RowMajor>()); #if __cplusplus > 199711L // std::erf, std::erfc, and so on where only added in c++11. We use them // as a golden reference to validate the results produced by Eigen. Therefore // we can only run these tests if we use a c++11 compiler. CALL_SUBTEST_4(test_cuda_lgamma<float>(1.0f)); CALL_SUBTEST_4(test_cuda_lgamma<float>(100.0f)); CALL_SUBTEST_4(test_cuda_lgamma<float>(0.01f)); CALL_SUBTEST_4(test_cuda_lgamma<float>(0.001f)); CALL_SUBTEST_4(test_cuda_lgamma<double>(1.0)); CALL_SUBTEST_4(test_cuda_lgamma<double>(100.0)); CALL_SUBTEST_4(test_cuda_lgamma<double>(0.01)); CALL_SUBTEST_4(test_cuda_lgamma<double>(0.001)); CALL_SUBTEST_4(test_cuda_erf<float>(1.0f)); CALL_SUBTEST_4(test_cuda_erf<float>(100.0f)); CALL_SUBTEST_4(test_cuda_erf<float>(0.01f)); CALL_SUBTEST_4(test_cuda_erf<float>(0.001f)); CALL_SUBTEST_4(test_cuda_erfc<float>(1.0f)); // CALL_SUBTEST(test_cuda_erfc<float>(100.0f)); CALL_SUBTEST_4(test_cuda_erfc<float>(5.0f)); // CUDA erfc lacks precision for large inputs CALL_SUBTEST_4(test_cuda_erfc<float>(0.01f)); CALL_SUBTEST_4(test_cuda_erfc<float>(0.001f)); CALL_SUBTEST_4(test_cuda_erf<double>(1.0)); CALL_SUBTEST_4(test_cuda_erf<double>(100.0)); CALL_SUBTEST_4(test_cuda_erf<double>(0.01)); CALL_SUBTEST_4(test_cuda_erf<double>(0.001)); CALL_SUBTEST_4(test_cuda_erfc<double>(1.0)); // CALL_SUBTEST(test_cuda_erfc<double>(100.0)); CALL_SUBTEST_4(test_cuda_erfc<double>(5.0)); // CUDA erfc lacks precision for large inputs CALL_SUBTEST_4(test_cuda_erfc<double>(0.01)); CALL_SUBTEST_4(test_cuda_erfc<double>(0.001)); CALL_SUBTEST_5(test_cuda_digamma<float>()); CALL_SUBTEST_5(test_cuda_digamma<double>()); CALL_SUBTEST_5(test_cuda_polygamma<float>()); CALL_SUBTEST_5(test_cuda_polygamma<double>()); CALL_SUBTEST_5(test_cuda_zeta<float>()); CALL_SUBTEST_5(test_cuda_zeta<double>()); CALL_SUBTEST_5(test_cuda_igamma<float>()); CALL_SUBTEST_5(test_cuda_igammac<float>()); CALL_SUBTEST_5(test_cuda_igamma<double>()); CALL_SUBTEST_5(test_cuda_igammac<double>()); CALL_SUBTEST_6(test_cuda_betainc<float>()); CALL_SUBTEST_6(test_cuda_betainc<double>()); #endif }
d69c3e6dd51ae762bb7eabf9e570d32541321540.cu
// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2014 Benoit Steiner <[email protected]> // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. #define EIGEN_TEST_NO_LONGDOUBLE #define EIGEN_TEST_NO_COMPLEX #define EIGEN_TEST_FUNC cxx11_tensor_cuda #define EIGEN_USE_GPU #if defined __CUDACC_VER__ && __CUDACC_VER__ >= 70500 #include <cuda_fp16.h> #endif #include "4dface-ulsTracker.h" #include <unsupported/Eigen/CXX11/Tensor> using Eigen::Tensor; void test_cuda_nullary() { Tensor<float, 1, 0, int> in1(2); Tensor<float, 1, 0, int> in2(2); in1.setRandom(); in2.setRandom(); std::size_t tensor_bytes = in1.size() * sizeof(float); float* d_in1; float* d_in2; cudaMalloc((void**)(&d_in1), tensor_bytes); cudaMalloc((void**)(&d_in2), tensor_bytes); cudaMemcpy(d_in1, in1.data(), tensor_bytes, cudaMemcpyHostToDevice); cudaMemcpy(d_in2, in2.data(), tensor_bytes, cudaMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<float, 1, 0, int>, Eigen::Aligned> gpu_in1( d_in1, 2); Eigen::TensorMap<Eigen::Tensor<float, 1, 0, int>, Eigen::Aligned> gpu_in2( d_in2, 2); gpu_in1.device(gpu_device) = gpu_in1.constant(3.14f); gpu_in2.device(gpu_device) = gpu_in2.random(); Tensor<float, 1, 0, int> new1(2); Tensor<float, 1, 0, int> new2(2); assert(cudaMemcpyAsync(new1.data(), d_in1, tensor_bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess); assert(cudaMemcpyAsync(new2.data(), d_in2, tensor_bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess); assert(cudaStreamSynchronize(gpu_device.stream()) == cudaSuccess); for (int i = 0; i < 2; ++i) { VERIFY_IS_APPROX(new1(i), 3.14f); VERIFY_IS_NOT_EQUAL(new2(i), in2(i)); } cudaFree(d_in1); cudaFree(d_in2); } void test_cuda_elementwise_small() { Tensor<float, 1> in1(Eigen::array<Eigen::DenseIndex, 1>(2)); Tensor<float, 1> in2(Eigen::array<Eigen::DenseIndex, 1>(2)); Tensor<float, 1> out(Eigen::array<Eigen::DenseIndex, 1>(2)); in1.setRandom(); in2.setRandom(); std::size_t in1_bytes = in1.size() * sizeof(float); std::size_t in2_bytes = in2.size() * sizeof(float); std::size_t out_bytes = out.size() * sizeof(float); float* d_in1; float* d_in2; float* d_out; cudaMalloc((void**)(&d_in1), in1_bytes); cudaMalloc((void**)(&d_in2), in2_bytes); cudaMalloc((void**)(&d_out), out_bytes); cudaMemcpy(d_in1, in1.data(), in1_bytes, cudaMemcpyHostToDevice); cudaMemcpy(d_in2, in2.data(), in2_bytes, cudaMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<float, 1>, Eigen::Aligned> gpu_in1( d_in1, Eigen::array<Eigen::DenseIndex, 1>(2)); Eigen::TensorMap<Eigen::Tensor<float, 1>, Eigen::Aligned> gpu_in2( d_in2, Eigen::array<Eigen::DenseIndex, 1>(2)); Eigen::TensorMap<Eigen::Tensor<float, 1>, Eigen::Aligned> gpu_out( d_out, Eigen::array<Eigen::DenseIndex, 1>(2)); gpu_out.device(gpu_device) = gpu_in1 + gpu_in2; assert(cudaMemcpyAsync(out.data(), d_out, out_bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess); assert(cudaStreamSynchronize(gpu_device.stream()) == cudaSuccess); for (int i = 0; i < 2; ++i) { VERIFY_IS_APPROX( out(Eigen::array<Eigen::DenseIndex, 1>(i)), in1(Eigen::array<Eigen::DenseIndex, 1>(i)) + in2(Eigen::array<Eigen::DenseIndex, 1>(i))); } cudaFree(d_in1); cudaFree(d_in2); cudaFree(d_out); } void test_cuda_elementwise() { Tensor<float, 3> in1(Eigen::array<Eigen::DenseIndex, 3>(72,53,97)); Tensor<float, 3> in2(Eigen::array<Eigen::DenseIndex, 3>(72,53,97)); Tensor<float, 3> in3(Eigen::array<Eigen::DenseIndex, 3>(72,53,97)); Tensor<float, 3> out(Eigen::array<Eigen::DenseIndex, 3>(72,53,97)); in1.setRandom(); in2.setRandom(); in3.setRandom(); std::size_t in1_bytes = in1.size() * sizeof(float); std::size_t in2_bytes = in2.size() * sizeof(float); std::size_t in3_bytes = in3.size() * sizeof(float); std::size_t out_bytes = out.size() * sizeof(float); float* d_in1; float* d_in2; float* d_in3; float* d_out; cudaMalloc((void**)(&d_in1), in1_bytes); cudaMalloc((void**)(&d_in2), in2_bytes); cudaMalloc((void**)(&d_in3), in3_bytes); cudaMalloc((void**)(&d_out), out_bytes); cudaMemcpy(d_in1, in1.data(), in1_bytes, cudaMemcpyHostToDevice); cudaMemcpy(d_in2, in2.data(), in2_bytes, cudaMemcpyHostToDevice); cudaMemcpy(d_in3, in3.data(), in3_bytes, cudaMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<float, 3> > gpu_in1(d_in1, Eigen::array<Eigen::DenseIndex, 3>(72,53,97)); Eigen::TensorMap<Eigen::Tensor<float, 3> > gpu_in2(d_in2, Eigen::array<Eigen::DenseIndex, 3>(72,53,97)); Eigen::TensorMap<Eigen::Tensor<float, 3> > gpu_in3(d_in3, Eigen::array<Eigen::DenseIndex, 3>(72,53,97)); Eigen::TensorMap<Eigen::Tensor<float, 3> > gpu_out(d_out, Eigen::array<Eigen::DenseIndex, 3>(72,53,97)); gpu_out.device(gpu_device) = gpu_in1 + gpu_in2 * gpu_in3; assert(cudaMemcpyAsync(out.data(), d_out, out_bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess); assert(cudaStreamSynchronize(gpu_device.stream()) == cudaSuccess); for (int i = 0; i < 72; ++i) { for (int j = 0; j < 53; ++j) { for (int k = 0; k < 97; ++k) { VERIFY_IS_APPROX(out(Eigen::array<Eigen::DenseIndex, 3>(i,j,k)), in1(Eigen::array<Eigen::DenseIndex, 3>(i,j,k)) + in2(Eigen::array<Eigen::DenseIndex, 3>(i,j, k)) * in3(Eigen::array<Eigen::DenseIndex, 3>(i,j,k))); } } } cudaFree(d_in1); cudaFree(d_in2); cudaFree(d_in3); cudaFree(d_out); } void test_cuda_props() { Tensor<float, 1> in1(200); Tensor<bool, 1> out(200); in1.setRandom(); std::size_t in1_bytes = in1.size() * sizeof(float); std::size_t out_bytes = out.size() * sizeof(bool); float* d_in1; bool* d_out; cudaMalloc((void**)(&d_in1), in1_bytes); cudaMalloc((void**)(&d_out), out_bytes); cudaMemcpy(d_in1, in1.data(), in1_bytes, cudaMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<float, 1>, Eigen::Aligned> gpu_in1( d_in1, 200); Eigen::TensorMap<Eigen::Tensor<bool, 1>, Eigen::Aligned> gpu_out( d_out, 200); gpu_out.device(gpu_device) = (gpu_in1.isnan)(); assert(cudaMemcpyAsync(out.data(), d_out, out_bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess); assert(cudaStreamSynchronize(gpu_device.stream()) == cudaSuccess); for (int i = 0; i < 200; ++i) { VERIFY_IS_EQUAL(out(i), (std::isnan)(in1(i))); } cudaFree(d_in1); cudaFree(d_out); } void test_cuda_reduction() { Tensor<float, 4> in1(72,53,97,113); Tensor<float, 2> out(72,97); in1.setRandom(); std::size_t in1_bytes = in1.size() * sizeof(float); std::size_t out_bytes = out.size() * sizeof(float); float* d_in1; float* d_out; cudaMalloc((void**)(&d_in1), in1_bytes); cudaMalloc((void**)(&d_out), out_bytes); cudaMemcpy(d_in1, in1.data(), in1_bytes, cudaMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<float, 4> > gpu_in1(d_in1, 72,53,97,113); Eigen::TensorMap<Eigen::Tensor<float, 2> > gpu_out(d_out, 72,97); array<Eigen::DenseIndex, 2> reduction_axis; reduction_axis[0] = 1; reduction_axis[1] = 3; gpu_out.device(gpu_device) = gpu_in1.maximum(reduction_axis); assert(cudaMemcpyAsync(out.data(), d_out, out_bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess); assert(cudaStreamSynchronize(gpu_device.stream()) == cudaSuccess); for (int i = 0; i < 72; ++i) { for (int j = 0; j < 97; ++j) { float expected = 0; for (int k = 0; k < 53; ++k) { for (int l = 0; l < 113; ++l) { expected = std::max<float>(expected, in1(i, k, j, l)); } } VERIFY_IS_APPROX(out(i,j), expected); } } cudaFree(d_in1); cudaFree(d_out); } template<int DataLayout> void test_cuda_contraction() { // with these dimensions, the output has 300 * 140 elements, which is // more than 30 * 1024, which is the number of threads in blocks on // a 15 SM GK110 GPU Tensor<float, 4, DataLayout> t_left(6, 50, 3, 31); Tensor<float, 5, DataLayout> t_right(Eigen::array<Eigen::DenseIndex, 5>(3, 31, 7, 20, 1)); Tensor<float, 5, DataLayout> t_result(Eigen::array<Eigen::DenseIndex, 5>(6, 50, 7, 20, 1)); t_left.setRandom(); t_right.setRandom(); std::size_t t_left_bytes = t_left.size() * sizeof(float); std::size_t t_right_bytes = t_right.size() * sizeof(float); std::size_t t_result_bytes = t_result.size() * sizeof(float); float* d_t_left; float* d_t_right; float* d_t_result; cudaMalloc((void**)(&d_t_left), t_left_bytes); cudaMalloc((void**)(&d_t_right), t_right_bytes); cudaMalloc((void**)(&d_t_result), t_result_bytes); cudaMemcpy(d_t_left, t_left.data(), t_left_bytes, cudaMemcpyHostToDevice); cudaMemcpy(d_t_right, t_right.data(), t_right_bytes, cudaMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<float, 4, DataLayout> > gpu_t_left(d_t_left, 6, 50, 3, 31); Eigen::TensorMap<Eigen::Tensor<float, 5, DataLayout> > gpu_t_right(d_t_right, 3, 31, 7, 20, 1); Eigen::TensorMap<Eigen::Tensor<float, 5, DataLayout> > gpu_t_result(d_t_result, 6, 50, 7, 20, 1); typedef Eigen::Map<Eigen::Matrix<float, Dynamic, Dynamic, DataLayout> > MapXf; MapXf m_left(t_left.data(), 300, 93); MapXf m_right(t_right.data(), 93, 140); Eigen::Matrix<float, Dynamic, Dynamic, DataLayout> m_result(300, 140); typedef Tensor<float, 1>::DimensionPair DimPair; Eigen::array<DimPair, 2> dims; dims[0] = DimPair(2, 0); dims[1] = DimPair(3, 1); m_result = m_left * m_right; gpu_t_result.device(gpu_device) = gpu_t_left.contract(gpu_t_right, dims); cudaMemcpy(t_result.data(), d_t_result, t_result_bytes, cudaMemcpyDeviceToHost); for (DenseIndex i = 0; i < t_result.size(); i++) { if (fabs(t_result.data()[i] - m_result.data()[i]) >= 1e-4f) { std::cout << "mismatch detected at index " << i << ": " << t_result.data()[i] << " vs " << m_result.data()[i] << std::endl; assert(false); } } cudaFree(d_t_left); cudaFree(d_t_right); cudaFree(d_t_result); } template<int DataLayout> void test_cuda_convolution_1d() { Tensor<float, 4, DataLayout> input(74,37,11,137); Tensor<float, 1, DataLayout> kernel(4); Tensor<float, 4, DataLayout> out(74,34,11,137); input = input.constant(10.0f) + input.random(); kernel = kernel.constant(7.0f) + kernel.random(); std::size_t input_bytes = input.size() * sizeof(float); std::size_t kernel_bytes = kernel.size() * sizeof(float); std::size_t out_bytes = out.size() * sizeof(float); float* d_input; float* d_kernel; float* d_out; cudaMalloc((void**)(&d_input), input_bytes); cudaMalloc((void**)(&d_kernel), kernel_bytes); cudaMalloc((void**)(&d_out), out_bytes); cudaMemcpy(d_input, input.data(), input_bytes, cudaMemcpyHostToDevice); cudaMemcpy(d_kernel, kernel.data(), kernel_bytes, cudaMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<float, 4, DataLayout> > gpu_input(d_input, 74,37,11,137); Eigen::TensorMap<Eigen::Tensor<float, 1, DataLayout> > gpu_kernel(d_kernel, 4); Eigen::TensorMap<Eigen::Tensor<float, 4, DataLayout> > gpu_out(d_out, 74,34,11,137); Eigen::array<Eigen::DenseIndex, 1> dims(1); gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims); assert(cudaMemcpyAsync(out.data(), d_out, out_bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess); assert(cudaStreamSynchronize(gpu_device.stream()) == cudaSuccess); for (int i = 0; i < 74; ++i) { for (int j = 0; j < 34; ++j) { for (int k = 0; k < 11; ++k) { for (int l = 0; l < 137; ++l) { const float result = out(i,j,k,l); const float expected = input(i,j+0,k,l) * kernel(0) + input(i,j+1,k,l) * kernel(1) + input(i,j+2,k,l) * kernel(2) + input(i,j+3,k,l) * kernel(3); VERIFY_IS_APPROX(result, expected); } } } } cudaFree(d_input); cudaFree(d_kernel); cudaFree(d_out); } void test_cuda_convolution_inner_dim_col_major_1d() { Tensor<float, 4, ColMajor> input(74,9,11,7); Tensor<float, 1, ColMajor> kernel(4); Tensor<float, 4, ColMajor> out(71,9,11,7); input = input.constant(10.0f) + input.random(); kernel = kernel.constant(7.0f) + kernel.random(); std::size_t input_bytes = input.size() * sizeof(float); std::size_t kernel_bytes = kernel.size() * sizeof(float); std::size_t out_bytes = out.size() * sizeof(float); float* d_input; float* d_kernel; float* d_out; cudaMalloc((void**)(&d_input), input_bytes); cudaMalloc((void**)(&d_kernel), kernel_bytes); cudaMalloc((void**)(&d_out), out_bytes); cudaMemcpy(d_input, input.data(), input_bytes, cudaMemcpyHostToDevice); cudaMemcpy(d_kernel, kernel.data(), kernel_bytes, cudaMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<float, 4, ColMajor> > gpu_input(d_input,74,9,11,7); Eigen::TensorMap<Eigen::Tensor<float, 1, ColMajor> > gpu_kernel(d_kernel,4); Eigen::TensorMap<Eigen::Tensor<float, 4, ColMajor> > gpu_out(d_out,71,9,11,7); Eigen::array<Eigen::DenseIndex, 1> dims(0); gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims); assert(cudaMemcpyAsync(out.data(), d_out, out_bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess); assert(cudaStreamSynchronize(gpu_device.stream()) == cudaSuccess); for (int i = 0; i < 71; ++i) { for (int j = 0; j < 9; ++j) { for (int k = 0; k < 11; ++k) { for (int l = 0; l < 7; ++l) { const float result = out(i,j,k,l); const float expected = input(i+0,j,k,l) * kernel(0) + input(i+1,j,k,l) * kernel(1) + input(i+2,j,k,l) * kernel(2) + input(i+3,j,k,l) * kernel(3); VERIFY_IS_APPROX(result, expected); } } } } cudaFree(d_input); cudaFree(d_kernel); cudaFree(d_out); } void test_cuda_convolution_inner_dim_row_major_1d() { Tensor<float, 4, RowMajor> input(7,9,11,74); Tensor<float, 1, RowMajor> kernel(4); Tensor<float, 4, RowMajor> out(7,9,11,71); input = input.constant(10.0f) + input.random(); kernel = kernel.constant(7.0f) + kernel.random(); std::size_t input_bytes = input.size() * sizeof(float); std::size_t kernel_bytes = kernel.size() * sizeof(float); std::size_t out_bytes = out.size() * sizeof(float); float* d_input; float* d_kernel; float* d_out; cudaMalloc((void**)(&d_input), input_bytes); cudaMalloc((void**)(&d_kernel), kernel_bytes); cudaMalloc((void**)(&d_out), out_bytes); cudaMemcpy(d_input, input.data(), input_bytes, cudaMemcpyHostToDevice); cudaMemcpy(d_kernel, kernel.data(), kernel_bytes, cudaMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<float, 4, RowMajor> > gpu_input(d_input, 7,9,11,74); Eigen::TensorMap<Eigen::Tensor<float, 1, RowMajor> > gpu_kernel(d_kernel, 4); Eigen::TensorMap<Eigen::Tensor<float, 4, RowMajor> > gpu_out(d_out, 7,9,11,71); Eigen::array<Eigen::DenseIndex, 1> dims(3); gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims); assert(cudaMemcpyAsync(out.data(), d_out, out_bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess); assert(cudaStreamSynchronize(gpu_device.stream()) == cudaSuccess); for (int i = 0; i < 7; ++i) { for (int j = 0; j < 9; ++j) { for (int k = 0; k < 11; ++k) { for (int l = 0; l < 71; ++l) { const float result = out(i,j,k,l); const float expected = input(i,j,k,l+0) * kernel(0) + input(i,j,k,l+1) * kernel(1) + input(i,j,k,l+2) * kernel(2) + input(i,j,k,l+3) * kernel(3); VERIFY_IS_APPROX(result, expected); } } } } cudaFree(d_input); cudaFree(d_kernel); cudaFree(d_out); } template<int DataLayout> void test_cuda_convolution_2d() { Tensor<float, 4, DataLayout> input(74,37,11,137); Tensor<float, 2, DataLayout> kernel(3,4); Tensor<float, 4, DataLayout> out(74,35,8,137); input = input.constant(10.0f) + input.random(); kernel = kernel.constant(7.0f) + kernel.random(); std::size_t input_bytes = input.size() * sizeof(float); std::size_t kernel_bytes = kernel.size() * sizeof(float); std::size_t out_bytes = out.size() * sizeof(float); float* d_input; float* d_kernel; float* d_out; cudaMalloc((void**)(&d_input), input_bytes); cudaMalloc((void**)(&d_kernel), kernel_bytes); cudaMalloc((void**)(&d_out), out_bytes); cudaMemcpy(d_input, input.data(), input_bytes, cudaMemcpyHostToDevice); cudaMemcpy(d_kernel, kernel.data(), kernel_bytes, cudaMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<float, 4, DataLayout> > gpu_input(d_input,74,37,11,137); Eigen::TensorMap<Eigen::Tensor<float, 2, DataLayout> > gpu_kernel(d_kernel,3,4); Eigen::TensorMap<Eigen::Tensor<float, 4, DataLayout> > gpu_out(d_out,74,35,8,137); Eigen::array<Eigen::DenseIndex, 2> dims(1,2); gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims); assert(cudaMemcpyAsync(out.data(), d_out, out_bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess); assert(cudaStreamSynchronize(gpu_device.stream()) == cudaSuccess); for (int i = 0; i < 74; ++i) { for (int j = 0; j < 35; ++j) { for (int k = 0; k < 8; ++k) { for (int l = 0; l < 137; ++l) { const float result = out(i,j,k,l); const float expected = input(i,j+0,k+0,l) * kernel(0,0) + input(i,j+1,k+0,l) * kernel(1,0) + input(i,j+2,k+0,l) * kernel(2,0) + input(i,j+0,k+1,l) * kernel(0,1) + input(i,j+1,k+1,l) * kernel(1,1) + input(i,j+2,k+1,l) * kernel(2,1) + input(i,j+0,k+2,l) * kernel(0,2) + input(i,j+1,k+2,l) * kernel(1,2) + input(i,j+2,k+2,l) * kernel(2,2) + input(i,j+0,k+3,l) * kernel(0,3) + input(i,j+1,k+3,l) * kernel(1,3) + input(i,j+2,k+3,l) * kernel(2,3); VERIFY_IS_APPROX(result, expected); } } } } cudaFree(d_input); cudaFree(d_kernel); cudaFree(d_out); } template<int DataLayout> void test_cuda_convolution_3d() { Tensor<float, 5, DataLayout> input(Eigen::array<Eigen::DenseIndex, 5>(74,37,11,137,17)); Tensor<float, 3, DataLayout> kernel(3,4,2); Tensor<float, 5, DataLayout> out(Eigen::array<Eigen::DenseIndex, 5>(74,35,8,136,17)); input = input.constant(10.0f) + input.random(); kernel = kernel.constant(7.0f) + kernel.random(); std::size_t input_bytes = input.size() * sizeof(float); std::size_t kernel_bytes = kernel.size() * sizeof(float); std::size_t out_bytes = out.size() * sizeof(float); float* d_input; float* d_kernel; float* d_out; cudaMalloc((void**)(&d_input), input_bytes); cudaMalloc((void**)(&d_kernel), kernel_bytes); cudaMalloc((void**)(&d_out), out_bytes); cudaMemcpy(d_input, input.data(), input_bytes, cudaMemcpyHostToDevice); cudaMemcpy(d_kernel, kernel.data(), kernel_bytes, cudaMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<float, 5, DataLayout> > gpu_input(d_input,74,37,11,137,17); Eigen::TensorMap<Eigen::Tensor<float, 3, DataLayout> > gpu_kernel(d_kernel,3,4,2); Eigen::TensorMap<Eigen::Tensor<float, 5, DataLayout> > gpu_out(d_out,74,35,8,136,17); Eigen::array<Eigen::DenseIndex, 3> dims(1,2,3); gpu_out.device(gpu_device) = gpu_input.convolve(gpu_kernel, dims); assert(cudaMemcpyAsync(out.data(), d_out, out_bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess); assert(cudaStreamSynchronize(gpu_device.stream()) == cudaSuccess); for (int i = 0; i < 74; ++i) { for (int j = 0; j < 35; ++j) { for (int k = 0; k < 8; ++k) { for (int l = 0; l < 136; ++l) { for (int m = 0; m < 17; ++m) { const float result = out(i,j,k,l,m); const float expected = input(i,j+0,k+0,l+0,m) * kernel(0,0,0) + input(i,j+1,k+0,l+0,m) * kernel(1,0,0) + input(i,j+2,k+0,l+0,m) * kernel(2,0,0) + input(i,j+0,k+1,l+0,m) * kernel(0,1,0) + input(i,j+1,k+1,l+0,m) * kernel(1,1,0) + input(i,j+2,k+1,l+0,m) * kernel(2,1,0) + input(i,j+0,k+2,l+0,m) * kernel(0,2,0) + input(i,j+1,k+2,l+0,m) * kernel(1,2,0) + input(i,j+2,k+2,l+0,m) * kernel(2,2,0) + input(i,j+0,k+3,l+0,m) * kernel(0,3,0) + input(i,j+1,k+3,l+0,m) * kernel(1,3,0) + input(i,j+2,k+3,l+0,m) * kernel(2,3,0) + input(i,j+0,k+0,l+1,m) * kernel(0,0,1) + input(i,j+1,k+0,l+1,m) * kernel(1,0,1) + input(i,j+2,k+0,l+1,m) * kernel(2,0,1) + input(i,j+0,k+1,l+1,m) * kernel(0,1,1) + input(i,j+1,k+1,l+1,m) * kernel(1,1,1) + input(i,j+2,k+1,l+1,m) * kernel(2,1,1) + input(i,j+0,k+2,l+1,m) * kernel(0,2,1) + input(i,j+1,k+2,l+1,m) * kernel(1,2,1) + input(i,j+2,k+2,l+1,m) * kernel(2,2,1) + input(i,j+0,k+3,l+1,m) * kernel(0,3,1) + input(i,j+1,k+3,l+1,m) * kernel(1,3,1) + input(i,j+2,k+3,l+1,m) * kernel(2,3,1); VERIFY_IS_APPROX(result, expected); } } } } } cudaFree(d_input); cudaFree(d_kernel); cudaFree(d_out); } template <typename Scalar> void test_cuda_lgamma(const Scalar stddev) { Tensor<Scalar, 2> in(72,97); in.setRandom(); in *= in.constant(stddev); Tensor<Scalar, 2> out(72,97); out.setZero(); std::size_t bytes = in.size() * sizeof(Scalar); Scalar* d_in; Scalar* d_out; cudaMalloc((void**)(&d_in), bytes); cudaMalloc((void**)(&d_out), bytes); cudaMemcpy(d_in, in.data(), bytes, cudaMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_in(d_in, 72, 97); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_out(d_out, 72, 97); gpu_out.device(gpu_device) = gpu_in.lgamma(); assert(cudaMemcpyAsync(out.data(), d_out, bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess); assert(cudaStreamSynchronize(gpu_device.stream()) == cudaSuccess); for (int i = 0; i < 72; ++i) { for (int j = 0; j < 97; ++j) { VERIFY_IS_APPROX(out(i,j), (std::lgamma)(in(i,j))); } } cudaFree(d_in); cudaFree(d_out); } template <typename Scalar> void test_cuda_digamma() { Tensor<Scalar, 1> in(7); Tensor<Scalar, 1> out(7); Tensor<Scalar, 1> expected_out(7); out.setZero(); in(0) = Scalar(1); in(1) = Scalar(1.5); in(2) = Scalar(4); in(3) = Scalar(-10.5); in(4) = Scalar(10000.5); in(5) = Scalar(0); in(6) = Scalar(-1); expected_out(0) = Scalar(-0.5772156649015329); expected_out(1) = Scalar(0.03648997397857645); expected_out(2) = Scalar(1.2561176684318); expected_out(3) = Scalar(2.398239129535781); expected_out(4) = Scalar(9.210340372392849); expected_out(5) = std::numeric_limits<Scalar>::infinity(); expected_out(6) = std::numeric_limits<Scalar>::infinity(); std::size_t bytes = in.size() * sizeof(Scalar); Scalar* d_in; Scalar* d_out; cudaMalloc((void**)(&d_in), bytes); cudaMalloc((void**)(&d_out), bytes); cudaMemcpy(d_in, in.data(), bytes, cudaMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_in(d_in, 7); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_out(d_out, 7); gpu_out.device(gpu_device) = gpu_in.digamma(); assert(cudaMemcpyAsync(out.data(), d_out, bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess); assert(cudaStreamSynchronize(gpu_device.stream()) == cudaSuccess); for (int i = 0; i < 5; ++i) { VERIFY_IS_APPROX(out(i), expected_out(i)); } for (int i = 5; i < 7; ++i) { VERIFY_IS_EQUAL(out(i), expected_out(i)); } cudaFree(d_in); cudaFree(d_out); } template <typename Scalar> void test_cuda_zeta() { Tensor<Scalar, 1> in_x(6); Tensor<Scalar, 1> in_q(6); Tensor<Scalar, 1> out(6); Tensor<Scalar, 1> expected_out(6); out.setZero(); in_x(0) = Scalar(1); in_x(1) = Scalar(1.5); in_x(2) = Scalar(4); in_x(3) = Scalar(-10.5); in_x(4) = Scalar(10000.5); in_x(5) = Scalar(3); in_q(0) = Scalar(1.2345); in_q(1) = Scalar(2); in_q(2) = Scalar(1.5); in_q(3) = Scalar(3); in_q(4) = Scalar(1.0001); in_q(5) = Scalar(-2.5); expected_out(0) = std::numeric_limits<Scalar>::infinity(); expected_out(1) = Scalar(1.61237534869); expected_out(2) = Scalar(0.234848505667); expected_out(3) = Scalar(1.03086757337e-5); expected_out(4) = Scalar(0.367879440865); expected_out(5) = Scalar(0.054102025820864097); std::size_t bytes = in_x.size() * sizeof(Scalar); Scalar* d_in_x; Scalar* d_in_q; Scalar* d_out; cudaMalloc((void**)(&d_in_x), bytes); cudaMalloc((void**)(&d_in_q), bytes); cudaMalloc((void**)(&d_out), bytes); cudaMemcpy(d_in_x, in_x.data(), bytes, cudaMemcpyHostToDevice); cudaMemcpy(d_in_q, in_q.data(), bytes, cudaMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_in_x(d_in_x, 6); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_in_q(d_in_q, 6); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_out(d_out, 6); gpu_out.device(gpu_device) = gpu_in_x.zeta(gpu_in_q); assert(cudaMemcpyAsync(out.data(), d_out, bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess); assert(cudaStreamSynchronize(gpu_device.stream()) == cudaSuccess); VERIFY_IS_EQUAL(out(0), expected_out(0)); VERIFY((std::isnan)(out(3))); for (int i = 1; i < 6; ++i) { if (i != 3) { VERIFY_IS_APPROX(out(i), expected_out(i)); } } cudaFree(d_in_x); cudaFree(d_in_q); cudaFree(d_out); } template <typename Scalar> void test_cuda_polygamma() { Tensor<Scalar, 1> in_x(7); Tensor<Scalar, 1> in_n(7); Tensor<Scalar, 1> out(7); Tensor<Scalar, 1> expected_out(7); out.setZero(); in_n(0) = Scalar(1); in_n(1) = Scalar(1); in_n(2) = Scalar(1); in_n(3) = Scalar(17); in_n(4) = Scalar(31); in_n(5) = Scalar(28); in_n(6) = Scalar(8); in_x(0) = Scalar(2); in_x(1) = Scalar(3); in_x(2) = Scalar(25.5); in_x(3) = Scalar(4.7); in_x(4) = Scalar(11.8); in_x(5) = Scalar(17.7); in_x(6) = Scalar(30.2); expected_out(0) = Scalar(0.644934066848); expected_out(1) = Scalar(0.394934066848); expected_out(2) = Scalar(0.0399946696496); expected_out(3) = Scalar(293.334565435); expected_out(4) = Scalar(0.445487887616); expected_out(5) = Scalar(-2.47810300902e-07); expected_out(6) = Scalar(-8.29668781082e-09); std::size_t bytes = in_x.size() * sizeof(Scalar); Scalar* d_in_x; Scalar* d_in_n; Scalar* d_out; cudaMalloc((void**)(&d_in_x), bytes); cudaMalloc((void**)(&d_in_n), bytes); cudaMalloc((void**)(&d_out), bytes); cudaMemcpy(d_in_x, in_x.data(), bytes, cudaMemcpyHostToDevice); cudaMemcpy(d_in_n, in_n.data(), bytes, cudaMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_in_x(d_in_x, 7); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_in_n(d_in_n, 7); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_out(d_out, 7); gpu_out.device(gpu_device) = gpu_in_n.polygamma(gpu_in_x); assert(cudaMemcpyAsync(out.data(), d_out, bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess); assert(cudaStreamSynchronize(gpu_device.stream()) == cudaSuccess); for (int i = 0; i < 7; ++i) { VERIFY_IS_APPROX(out(i), expected_out(i)); } cudaFree(d_in_x); cudaFree(d_in_n); cudaFree(d_out); } template <typename Scalar> void test_cuda_igamma() { Tensor<Scalar, 2> a(6, 6); Tensor<Scalar, 2> x(6, 6); Tensor<Scalar, 2> out(6, 6); out.setZero(); Scalar a_s[] = {Scalar(0), Scalar(1), Scalar(1.5), Scalar(4), Scalar(0.0001), Scalar(1000.5)}; Scalar x_s[] = {Scalar(0), Scalar(1), Scalar(1.5), Scalar(4), Scalar(0.0001), Scalar(1000.5)}; for (int i = 0; i < 6; ++i) { for (int j = 0; j < 6; ++j) { a(i, j) = a_s[i]; x(i, j) = x_s[j]; } } Scalar nan = std::numeric_limits<Scalar>::quiet_NaN(); Scalar igamma_s[][6] = {{0.0, nan, nan, nan, nan, nan}, { 0.0, 0.6321205588285578, 0.7768698398515702, 0.9816843611112658, 9.999500016666262e-05, 1.0 }, { 0.0, 0.4275932955291202, 0.608374823728911, 0.9539882943107686, 7.522076445089201e-07, 1.0 }, { 0.0, 0.01898815687615381, 0.06564245437845008, 0.5665298796332909, 4.166333347221828e-18, 1.0 }, { 0.0, 0.9999780593618628, 0.9999899967080838, 0.9999996219837988, 0.9991370418689945, 1.0 }, {0.0, 0.0, 0.0, 0.0, 0.0, 0.5042041932513908} }; std::size_t bytes = a.size() * sizeof(Scalar); Scalar* d_a; Scalar* d_x; Scalar* d_out; assert(cudaMalloc((void**)(&d_a), bytes) == cudaSuccess); assert(cudaMalloc((void**)(&d_x), bytes) == cudaSuccess); assert(cudaMalloc((void**)(&d_out), bytes) == cudaSuccess); cudaMemcpy(d_a, a.data(), bytes, cudaMemcpyHostToDevice); cudaMemcpy(d_x, x.data(), bytes, cudaMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_a(d_a, 6, 6); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_x(d_x, 6, 6); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_out(d_out, 6, 6); gpu_out.device(gpu_device) = gpu_a.igamma(gpu_x); assert(cudaMemcpyAsync(out.data(), d_out, bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess); assert(cudaStreamSynchronize(gpu_device.stream()) == cudaSuccess); for (int i = 0; i < 6; ++i) { for (int j = 0; j < 6; ++j) { if ((std::isnan)(igamma_s[i][j])) { VERIFY((std::isnan)(out(i, j))); } else { VERIFY_IS_APPROX(out(i, j), igamma_s[i][j]); } } } cudaFree(d_a); cudaFree(d_x); cudaFree(d_out); } template <typename Scalar> void test_cuda_igammac() { Tensor<Scalar, 2> a(6, 6); Tensor<Scalar, 2> x(6, 6); Tensor<Scalar, 2> out(6, 6); out.setZero(); Scalar a_s[] = {Scalar(0), Scalar(1), Scalar(1.5), Scalar(4), Scalar(0.0001), Scalar(1000.5)}; Scalar x_s[] = {Scalar(0), Scalar(1), Scalar(1.5), Scalar(4), Scalar(0.0001), Scalar(1000.5)}; for (int i = 0; i < 6; ++i) { for (int j = 0; j < 6; ++j) { a(i, j) = a_s[i]; x(i, j) = x_s[j]; } } Scalar nan = std::numeric_limits<Scalar>::quiet_NaN(); Scalar igammac_s[][6] = {{nan, nan, nan, nan, nan, nan}, { 1.0, 0.36787944117144233, 0.22313016014842982, 0.018315638888734182, 0.9999000049998333, 0.0 }, { 1.0, 0.5724067044708798, 0.3916251762710878, 0.04601170568923136, 0.9999992477923555, 0.0 }, { 1.0, 0.9810118431238462, 0.9343575456215499, 0.4334701203667089, 1.0, 0.0 }, { 1.0, 2.1940638138146658e-05, 1.0003291916285e-05, 3.7801620118431334e-07, 0.0008629581310054535, 0.0 }, {1.0, 1.0, 1.0, 1.0, 1.0, 0.49579580674813944} }; std::size_t bytes = a.size() * sizeof(Scalar); Scalar* d_a; Scalar* d_x; Scalar* d_out; cudaMalloc((void**)(&d_a), bytes); cudaMalloc((void**)(&d_x), bytes); cudaMalloc((void**)(&d_out), bytes); cudaMemcpy(d_a, a.data(), bytes, cudaMemcpyHostToDevice); cudaMemcpy(d_x, x.data(), bytes, cudaMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_a(d_a, 6, 6); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_x(d_x, 6, 6); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_out(d_out, 6, 6); gpu_out.device(gpu_device) = gpu_a.igammac(gpu_x); assert(cudaMemcpyAsync(out.data(), d_out, bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess); assert(cudaStreamSynchronize(gpu_device.stream()) == cudaSuccess); for (int i = 0; i < 6; ++i) { for (int j = 0; j < 6; ++j) { if ((std::isnan)(igammac_s[i][j])) { VERIFY((std::isnan)(out(i, j))); } else { VERIFY_IS_APPROX(out(i, j), igammac_s[i][j]); } } } cudaFree(d_a); cudaFree(d_x); cudaFree(d_out); } template <typename Scalar> void test_cuda_erf(const Scalar stddev) { Tensor<Scalar, 2> in(72,97); in.setRandom(); in *= in.constant(stddev); Tensor<Scalar, 2> out(72,97); out.setZero(); std::size_t bytes = in.size() * sizeof(Scalar); Scalar* d_in; Scalar* d_out; assert(cudaMalloc((void**)(&d_in), bytes) == cudaSuccess); assert(cudaMalloc((void**)(&d_out), bytes) == cudaSuccess); cudaMemcpy(d_in, in.data(), bytes, cudaMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_in(d_in, 72, 97); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_out(d_out, 72, 97); gpu_out.device(gpu_device) = gpu_in.erf(); assert(cudaMemcpyAsync(out.data(), d_out, bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess); assert(cudaStreamSynchronize(gpu_device.stream()) == cudaSuccess); for (int i = 0; i < 72; ++i) { for (int j = 0; j < 97; ++j) { VERIFY_IS_APPROX(out(i,j), (std::erf)(in(i,j))); } } cudaFree(d_in); cudaFree(d_out); } template <typename Scalar> void test_cuda_erfc(const Scalar stddev) { Tensor<Scalar, 2> in(72,97); in.setRandom(); in *= in.constant(stddev); Tensor<Scalar, 2> out(72,97); out.setZero(); std::size_t bytes = in.size() * sizeof(Scalar); Scalar* d_in; Scalar* d_out; cudaMalloc((void**)(&d_in), bytes); cudaMalloc((void**)(&d_out), bytes); cudaMemcpy(d_in, in.data(), bytes, cudaMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_in(d_in, 72, 97); Eigen::TensorMap<Eigen::Tensor<Scalar, 2> > gpu_out(d_out, 72, 97); gpu_out.device(gpu_device) = gpu_in.erfc(); assert(cudaMemcpyAsync(out.data(), d_out, bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess); assert(cudaStreamSynchronize(gpu_device.stream()) == cudaSuccess); for (int i = 0; i < 72; ++i) { for (int j = 0; j < 97; ++j) { VERIFY_IS_APPROX(out(i,j), (std::erfc)(in(i,j))); } } cudaFree(d_in); cudaFree(d_out); } template <typename Scalar> void test_cuda_betainc() { Tensor<Scalar, 1> in_x(125); Tensor<Scalar, 1> in_a(125); Tensor<Scalar, 1> in_b(125); Tensor<Scalar, 1> out(125); Tensor<Scalar, 1> expected_out(125); out.setZero(); Scalar nan = std::numeric_limits<Scalar>::quiet_NaN(); Array<Scalar, 1, Dynamic> x(125); Array<Scalar, 1, Dynamic> a(125); Array<Scalar, 1, Dynamic> b(125); Array<Scalar, 1, Dynamic> v(125); a << 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999, 999.999; b << 0.0, 0.0, 0.0, 0.0, 0.0, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.999, 0.999, 0.999, 0.999, 0.999, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 999.999, 999.999, 999.999, 999.999, 999.999, 0.0, 0.0, 0.0, 0.0, 0.0, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.999, 0.999, 0.999, 0.999, 0.999, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 999.999, 999.999, 999.999, 999.999, 999.999, 0.0, 0.0, 0.0, 0.0, 0.0, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.999, 0.999, 0.999, 0.999, 0.999, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 999.999, 999.999, 999.999, 999.999, 999.999, 0.0, 0.0, 0.0, 0.0, 0.0, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.999, 0.999, 0.999, 0.999, 0.999, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 999.999, 999.999, 999.999, 999.999, 999.999, 0.0, 0.0, 0.0, 0.0, 0.0, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.03062277660168379, 0.999, 0.999, 0.999, 0.999, 0.999, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 31.62177660168379, 999.999, 999.999, 999.999, 999.999, 999.999; x << -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1, -0.1, 0.2, 0.5, 0.8, 1.1; v << nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, 0.47972119876364683, 0.5, 0.5202788012363533, nan, nan, 0.9518683957740043, 0.9789663010413743, 0.9931729188073435, nan, nan, 0.999995949033062, 0.9999999999993698, 0.9999999999999999, nan, nan, 0.9999999999999999, 0.9999999999999999, 0.9999999999999999, nan, nan, nan, nan, nan, nan, nan, 0.006827081192655869, 0.0210336989586256, 0.04813160422599567, nan, nan, 0.20014344256217678, 0.5000000000000001, 0.7998565574378232, nan, nan, 0.9991401428435834, 0.999999999698403, 0.9999999999999999, nan, nan, 0.9999999999999999, 0.9999999999999999, 0.9999999999999999, nan, nan, nan, nan, nan, nan, nan, 1.0646600232370887e-25, 6.301722877826246e-13, 4.050966937974938e-06, nan, nan, 7.864342668429763e-23, 3.015969667594166e-10, 0.0008598571564165444, nan, nan, 6.031987710123844e-08, 0.5000000000000007, 0.9999999396801229, nan, nan, 0.9999999999999999, 0.9999999999999999, 0.9999999999999999, nan, nan, nan, nan, nan, nan, nan, 0.0, 7.029920380986636e-306, 2.2450728208591345e-101, nan, nan, 0.0, 9.275871147869727e-302, 1.2232913026152827e-97, nan, nan, 0.0, 3.0891393081932924e-252, 2.9303043666183996e-60, nan, nan, 2.248913486879199e-196, 0.5000000000004947, 0.9999999999999999, nan; for (int i = 0; i < 125; ++i) { in_x(i) = x(i); in_a(i) = a(i); in_b(i) = b(i); expected_out(i) = v(i); } std::size_t bytes = in_x.size() * sizeof(Scalar); Scalar* d_in_x; Scalar* d_in_a; Scalar* d_in_b; Scalar* d_out; cudaMalloc((void**)(&d_in_x), bytes); cudaMalloc((void**)(&d_in_a), bytes); cudaMalloc((void**)(&d_in_b), bytes); cudaMalloc((void**)(&d_out), bytes); cudaMemcpy(d_in_x, in_x.data(), bytes, cudaMemcpyHostToDevice); cudaMemcpy(d_in_a, in_a.data(), bytes, cudaMemcpyHostToDevice); cudaMemcpy(d_in_b, in_b.data(), bytes, cudaMemcpyHostToDevice); Eigen::CudaStreamDevice stream; Eigen::GpuDevice gpu_device(&stream); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_in_x(d_in_x, 125); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_in_a(d_in_a, 125); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_in_b(d_in_b, 125); Eigen::TensorMap<Eigen::Tensor<Scalar, 1> > gpu_out(d_out, 125); gpu_out.device(gpu_device) = betainc(gpu_in_a, gpu_in_b, gpu_in_x); assert(cudaMemcpyAsync(out.data(), d_out, bytes, cudaMemcpyDeviceToHost, gpu_device.stream()) == cudaSuccess); assert(cudaStreamSynchronize(gpu_device.stream()) == cudaSuccess); for (int i = 1; i < 125; ++i) { if ((std::isnan)(expected_out(i))) { VERIFY((std::isnan)(out(i))); } else { VERIFY_IS_APPROX(out(i), expected_out(i)); } } cudaFree(d_in_x); cudaFree(d_in_a); cudaFree(d_in_b); cudaFree(d_out); } void test_cxx11_tensor_cuda() { CALL_SUBTEST_1(test_cuda_nullary()); CALL_SUBTEST_1(test_cuda_elementwise_small()); CALL_SUBTEST_1(test_cuda_elementwise()); CALL_SUBTEST_1(test_cuda_props()); CALL_SUBTEST_1(test_cuda_reduction()); CALL_SUBTEST_2(test_cuda_contraction<ColMajor>()); CALL_SUBTEST_2(test_cuda_contraction<RowMajor>()); CALL_SUBTEST_3(test_cuda_convolution_1d<ColMajor>()); CALL_SUBTEST_3(test_cuda_convolution_1d<RowMajor>()); CALL_SUBTEST_3(test_cuda_convolution_inner_dim_col_major_1d()); CALL_SUBTEST_3(test_cuda_convolution_inner_dim_row_major_1d()); CALL_SUBTEST_3(test_cuda_convolution_2d<ColMajor>()); CALL_SUBTEST_3(test_cuda_convolution_2d<RowMajor>()); CALL_SUBTEST_3(test_cuda_convolution_3d<ColMajor>()); CALL_SUBTEST_3(test_cuda_convolution_3d<RowMajor>()); #if __cplusplus > 199711L // std::erf, std::erfc, and so on where only added in c++11. We use them // as a golden reference to validate the results produced by Eigen. Therefore // we can only run these tests if we use a c++11 compiler. CALL_SUBTEST_4(test_cuda_lgamma<float>(1.0f)); CALL_SUBTEST_4(test_cuda_lgamma<float>(100.0f)); CALL_SUBTEST_4(test_cuda_lgamma<float>(0.01f)); CALL_SUBTEST_4(test_cuda_lgamma<float>(0.001f)); CALL_SUBTEST_4(test_cuda_lgamma<double>(1.0)); CALL_SUBTEST_4(test_cuda_lgamma<double>(100.0)); CALL_SUBTEST_4(test_cuda_lgamma<double>(0.01)); CALL_SUBTEST_4(test_cuda_lgamma<double>(0.001)); CALL_SUBTEST_4(test_cuda_erf<float>(1.0f)); CALL_SUBTEST_4(test_cuda_erf<float>(100.0f)); CALL_SUBTEST_4(test_cuda_erf<float>(0.01f)); CALL_SUBTEST_4(test_cuda_erf<float>(0.001f)); CALL_SUBTEST_4(test_cuda_erfc<float>(1.0f)); // CALL_SUBTEST(test_cuda_erfc<float>(100.0f)); CALL_SUBTEST_4(test_cuda_erfc<float>(5.0f)); // CUDA erfc lacks precision for large inputs CALL_SUBTEST_4(test_cuda_erfc<float>(0.01f)); CALL_SUBTEST_4(test_cuda_erfc<float>(0.001f)); CALL_SUBTEST_4(test_cuda_erf<double>(1.0)); CALL_SUBTEST_4(test_cuda_erf<double>(100.0)); CALL_SUBTEST_4(test_cuda_erf<double>(0.01)); CALL_SUBTEST_4(test_cuda_erf<double>(0.001)); CALL_SUBTEST_4(test_cuda_erfc<double>(1.0)); // CALL_SUBTEST(test_cuda_erfc<double>(100.0)); CALL_SUBTEST_4(test_cuda_erfc<double>(5.0)); // CUDA erfc lacks precision for large inputs CALL_SUBTEST_4(test_cuda_erfc<double>(0.01)); CALL_SUBTEST_4(test_cuda_erfc<double>(0.001)); CALL_SUBTEST_5(test_cuda_digamma<float>()); CALL_SUBTEST_5(test_cuda_digamma<double>()); CALL_SUBTEST_5(test_cuda_polygamma<float>()); CALL_SUBTEST_5(test_cuda_polygamma<double>()); CALL_SUBTEST_5(test_cuda_zeta<float>()); CALL_SUBTEST_5(test_cuda_zeta<double>()); CALL_SUBTEST_5(test_cuda_igamma<float>()); CALL_SUBTEST_5(test_cuda_igammac<float>()); CALL_SUBTEST_5(test_cuda_igamma<double>()); CALL_SUBTEST_5(test_cuda_igammac<double>()); CALL_SUBTEST_6(test_cuda_betainc<float>()); CALL_SUBTEST_6(test_cuda_betainc<double>()); #endif }
413a595828259a3baf7af9d805ec99dbafd01531.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <hiprand/hiprand.h> #include <hiprand/hiprand_kernel.h> #include <ctime> #include <time.h> #include "../common/book.h" //Elabora un nmero aleatorio __global__ void make_rand(int seed, char* m, int size) { float myrandf; int num; int idx = blockIdx.x * blockDim.x + threadIdx.x; hiprandState_t state; hiprand_init(seed, idx, 0, &state); //Se prepara la ejecucin del random de CUDA myrandf = hiprand_uniform(&state); myrandf *= (size - 0 + 0.999999); num = myrandf; if (m[num] == 'O') { m[num] = 'X'; } } //Se da el valor inicial de las distintas casillas de la matriz __global__ void prepare_matrix(char* p) { int idx = blockIdx.x * blockDim.x + threadIdx.x; p[idx] = 'O'; } //Se genera una matriz de manera que los elementos bajan una fila __global__ void matrix_operation(char* m, char* p, int width, int size) { int idx = blockIdx.x * blockDim.x + threadIdx.x; // Id del hilo segn su bloque y su posicin en el mismo e ndice de la posicin trabaja de las distintas matrices int counter = 0; // Contador del nmero de posiciones con clulas vivas if ((idx % width != 0) && (idx - width >= 0) && (m[idx - width - 1] == 'X')) // Estudia si existe esquina superior izquierda y si tiene una clula viva { counter++; } if ((idx % width != 0) && (m[idx - 1] == 'X')) //Estudia si existe el casilla en el lateral izquierdo y si tiene una clula viva { counter++; } if ((idx - width >= 0) && (m[idx - width] == 'X')) //Estudia si existe el casilla en el lateral superior y si tiene una clula viva { counter++; } if ((idx % width != width-1) && (idx - width >= 0) && (m[idx - width + 1] == 'X')) // Estudia si existe esquina superior derecha y si tiene una clula viva { counter++; } if ((idx % width != width - 1) && (m[idx + 1] == 'X')) //Estudia si existe el casilla en el lateral derecho y si tiene una clula viva { counter++; } if ((idx % width != 0) && (idx + width < size) && (m[idx + width - 1] == 'X')) // Estudia si existe esquina inferior izquierda y si tiene una clula viva { counter++; } if ((idx + width < size) && (m[idx + width] == 'X')) //Estudia si existe el casilla en el lateral inferior y si tiene una clula viva { counter++; } if ((idx % width != width - 1) && (idx + width < size) && (m[idx + width + 1] == 'X')) // Estudia si existe esquina inferior derecha y si tiene una clula viva { counter++; } if ((counter == 3) && (m[idx] == 'O')) // Una clula muerte se convierte en viva si tiene 3 clulas vivas alrededor de ella { p[idx] = 'X'; } else if (((counter < 2) || (counter > 3)) && (m[idx] == 'X')) // Una clula viva se convierte en muerte si alrededor de ella hay un nmero de clulas distinto de 2 o 3 { p[idx] = 'O'; } else //La clula mantiene su estado { p[idx] = m[idx]; } } void generate_matrix(char* m, int size, int nBlocks, int nThreads); int generate_random(int min, int max); void step_life(char* m, char* p, int width, int size, int nBlocks, int nThreads); void show_info_gpu_card(); int get_max_number_threads_block(); int main(int argc, char* argv[]) { show_info_gpu_card(); // Muestra la informacin de la tarjeta grfica int maxThreads = get_max_number_threads_block(); // Devuelve el nmero mximo de hilos que se pueden ejecutar por bloque printf("Comienza el juego de la vida:\n"); int number_blocks = 1; //Nmero de bloques int number_rows = 32; // Nmero de elementos por fila int number_columns = 32; // Nmero de elementos por columna char execution_mode = 'a'; // Modo de ejecucin del programa // Condiciones para los casos en los que se est pasando por terminal una serie de parmetros if (argc == 2)//Consideracin si solo se pasan dos parmetros por consola { execution_mode = argv[1][0]; } else if (argc == 3)//Consideracin si solo se pasan tres parmetros por consola { execution_mode = argv[1][0]; number_rows = atoi(argv[2]); } else if (argc >= 4)//Consideracin si solo se pasan cuatro o ms parmetros por consola { execution_mode = argv[1][0]; number_rows = atoi(argv[2]); number_columns = atoi(argv[3]); } int size = number_rows * number_columns; //Tamao de la matriz int width = number_columns; //Ancho del bloque if (size <= maxThreads) // Si el tamao de la matriz es inferior o igual al mximo nmero de hilos por bloque que admite la GPU { int counter = 1;//Contador de nmero de paso de matriz del juego char* a = (char*)malloc(size * sizeof(char)); char* b = (char*)malloc(size * sizeof(char)); generate_matrix(a, size, number_blocks, size); printf("Situacion Inicial:\n"); for (int i = 0; i < size; i++)//Representacin matriz inicial { if (i % width == width - 1) { printf("%c\n", a[i]); } else { printf("%c ", a[i]); } } while (execution_mode == 'm' || execution_mode == 'a') { if (counter % 2 == 1) { step_life(a, b, width, size, number_blocks, size); printf("Matriz paso %d:\n", counter); for (int i = 0; i < size; i++)//Representacin matriz inicial { if (i % width == width - 1) { printf("%c\n", b[i]); } else { printf("%c ", b[i]); } } } else { step_life(b, a, width, size, number_blocks, size); printf("Matriz paso %d:\n", counter); for (int i = 0; i < size; i++)//Representacin matriz inicial { if (i % width == width - 1) { printf("%c\n", a[i]); } else { printf("%c ", a[i]); } } } counter++; if (execution_mode == 'm') //Si el modo seleccionado no es automtico para hasta que el usuario pulse una tecla { getchar(); } } if (execution_mode != 'm' && execution_mode != 'a')//Si el modo ejecucin es distinto a los propuestos parar el programa { printf("El modo de ejecucion del programa es incorrecto.\n"); } free(a); free(b); } else // Si el tamao de la matriz es mayor al mximo nmero de hilos por bloque que admite la GPU { printf("Las dimensiones de la matriz introducidas no son validas.\n"); } getchar(); getchar(); return 0; } void generate_matrix(char* m, int size, int nBlocks, int nThreads) // Genera la matriz con su estado inicial { srand(time(NULL)); int seed = rand() % 50000; char* m_d; int numElem = generate_random(1, size*0.15);// Genera un nmero aleatorio de mxima nmero de clulas vivas en la etapa inicial siendo el mximo un 15% del mximo nmero de casillas hipMalloc((void**)&m_d, size * sizeof(char)); hipMemcpy(m_d, m, size * sizeof(char), hipMemcpyHostToDevice); hipLaunchKernelGGL(( prepare_matrix) , dim3(nBlocks), dim3(nThreads) , 0, 0, m_d);//Prepara la matriz con todas las casillas con clulas muertas hipLaunchKernelGGL(( make_rand) , dim3(nBlocks), dim3(numElem) , 0, 0, seed, m_d, size);// Va colocando de forma aleatoria clulas vivas en las casillas de la matriz hipDeviceSynchronize(); hipMemcpy(m, m_d, size * sizeof(char), hipMemcpyDeviceToHost); hipFree(m_d); } void step_life(char* m, char* p, int width, int size, int nBlocks, int nThreads) // Genera la matriz resultado a partir de una matriz inicial con las restricciones marcadas para cada casilla { char* m_d; char* p_d; hipMalloc((void**)&m_d, size * sizeof(char)); hipMalloc((void**)&p_d, size * sizeof(char)); hipMemcpy(m_d, m, size * sizeof(char), hipMemcpyHostToDevice); hipMemcpy(p_d, p, size * sizeof(char), hipMemcpyHostToDevice); hipLaunchKernelGGL(( matrix_operation) , dim3(nBlocks), dim3(nThreads) , 0, 0, m_d, p_d, width, size);// Estudia el cambio o no de valor de las distintas casillas de la matriz hipDeviceSynchronize(); hipMemcpy(m, m_d, size * sizeof(char), hipMemcpyDeviceToHost); hipMemcpy(p, p_d, size * sizeof(char), hipMemcpyDeviceToHost); hipFree(m_d); hipFree(p_d); } int generate_random(int min, int max)// Genera un nmero aleatorio entre un mnimo y un mximo { srand(time(NULL)); int randNumber = rand() % (max - min) + min; return randNumber; } int get_max_number_threads_block()// Devuelve el nmero mximo de hilos que se pueden ejecutar por bloque { hipDeviceProp_t prop; int count; //Obtencin nmero de dispositivos compatibles con CUDA HANDLE_ERROR(hipGetDeviceCount(&count)); HANDLE_ERROR(hipGetDeviceProperties(&prop, 0)); return prop.maxThreadsPerBlock; } void show_info_gpu_card()// Muestra las caractersticas de la tarjeta grfica usada { hipDeviceProp_t prop; int count; //Obtencin nmero de dispositivos compatibles con CUDA HANDLE_ERROR(hipGetDeviceCount(&count)); printf("Numero de dispositivos compatibles con CUDA: %d.\n", count); //Obtencin de caractersticas relativas a cada dispositivo for (int i = 0; i < count; i++) { HANDLE_ERROR(hipGetDeviceProperties(&prop, i)); printf("Informacion general del dispositivo %d compatible con CUDA:\n", i + 1); printf("Nombre GPU: %s.\n", prop.name); printf("Capacidad de computo: %d,%d.\n", prop.major, prop.minor); printf("Velocidad de reloj: %d kHz.\n", prop.clockRate); printf("Copia solapada dispositivo: "); if (prop.deviceOverlap) { printf("Activo.\n"); } else { printf("Inactivo.\n"); } printf("Timeout de ejecucion del Kernel: "); if (prop.kernelExecTimeoutEnabled) { printf("Activo.\n"); } else { printf("Inactivo.\n"); } printf("\nInformacion de memoria para el dispositivo %d:\n", i + 1); printf("Memoria global total: %zu GB.\n", prop.totalGlobalMem / (1024 * 1024 * 1024)); printf("Memoria constante total: %zu Bytes.\n", prop.totalConstMem); printf("Memoria compartida por bloque: %zu Bytes.\n", prop.sharedMemPerBlock); printf("Numero registros compartidos por bloque: %d.\n", prop.regsPerBlock); printf("Numero hilos maximos por bloque: %d.\n", prop.maxThreadsPerBlock); printf("Memoria compartida por multiprocesador: %zu Bytes.\n", prop.sharedMemPerMultiprocessor); printf("Numero registros compartidos por multiprocesador: %d.\n", prop.regsPerMultiprocessor); printf("Numero hilos maximos por multiprocesador: %d.\n", prop.maxThreadsPerMultiProcessor); printf("Numero de hilos en warp: %d.\n", prop.warpSize); printf("Alineamiento maximo de memoria: %zu.\n", prop.memPitch); printf("Textura de alineamiento: %zd.\n", prop.textureAlignment); printf("Total de multiprocesadores: %d.\n", prop.multiProcessorCount); printf("Maximas dimensiones de un hilo: (%d, %d, %d).\n", prop.maxThreadsDim[0], prop.maxThreadsDim[1], prop.maxThreadsDim[2]); printf("Maximas dimensiones de grid: (%d, %d, %d).\n\n", prop.maxGridSize[0], prop.maxGridSize[1], prop.maxGridSize[2]); } getchar(); }
413a595828259a3baf7af9d805ec99dbafd01531.cu
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <curand.h> #include <curand_kernel.h> #include <ctime> #include <time.h> #include "../common/book.h" //Elabora un número aleatorio __global__ void make_rand(int seed, char* m, int size) { float myrandf; int num; int idx = blockIdx.x * blockDim.x + threadIdx.x; curandState state; curand_init(seed, idx, 0, &state); //Se prepara la ejecución del random de CUDA myrandf = curand_uniform(&state); myrandf *= (size - 0 + 0.999999); num = myrandf; if (m[num] == 'O') { m[num] = 'X'; } } //Se da el valor inicial de las distintas casillas de la matriz __global__ void prepare_matrix(char* p) { int idx = blockIdx.x * blockDim.x + threadIdx.x; p[idx] = 'O'; } //Se genera una matriz de manera que los elementos bajan una fila __global__ void matrix_operation(char* m, char* p, int width, int size) { int idx = blockIdx.x * blockDim.x + threadIdx.x; // Id del hilo según su bloque y su posición en el mismo e índice de la posición trabaja de las distintas matrices int counter = 0; // Contador del número de posiciones con células vivas if ((idx % width != 0) && (idx - width >= 0) && (m[idx - width - 1] == 'X')) // Estudia si existe esquina superior izquierda y si tiene una célula viva { counter++; } if ((idx % width != 0) && (m[idx - 1] == 'X')) //Estudia si existe el casilla en el lateral izquierdo y si tiene una célula viva { counter++; } if ((idx - width >= 0) && (m[idx - width] == 'X')) //Estudia si existe el casilla en el lateral superior y si tiene una célula viva { counter++; } if ((idx % width != width-1) && (idx - width >= 0) && (m[idx - width + 1] == 'X')) // Estudia si existe esquina superior derecha y si tiene una célula viva { counter++; } if ((idx % width != width - 1) && (m[idx + 1] == 'X')) //Estudia si existe el casilla en el lateral derecho y si tiene una célula viva { counter++; } if ((idx % width != 0) && (idx + width < size) && (m[idx + width - 1] == 'X')) // Estudia si existe esquina inferior izquierda y si tiene una célula viva { counter++; } if ((idx + width < size) && (m[idx + width] == 'X')) //Estudia si existe el casilla en el lateral inferior y si tiene una célula viva { counter++; } if ((idx % width != width - 1) && (idx + width < size) && (m[idx + width + 1] == 'X')) // Estudia si existe esquina inferior derecha y si tiene una célula viva { counter++; } if ((counter == 3) && (m[idx] == 'O')) // Una célula muerte se convierte en viva si tiene 3 células vivas alrededor de ella { p[idx] = 'X'; } else if (((counter < 2) || (counter > 3)) && (m[idx] == 'X')) // Una célula viva se convierte en muerte si alrededor de ella hay un número de células distinto de 2 o 3 { p[idx] = 'O'; } else //La célula mantiene su estado { p[idx] = m[idx]; } } void generate_matrix(char* m, int size, int nBlocks, int nThreads); int generate_random(int min, int max); void step_life(char* m, char* p, int width, int size, int nBlocks, int nThreads); void show_info_gpu_card(); int get_max_number_threads_block(); int main(int argc, char* argv[]) { show_info_gpu_card(); // Muestra la información de la tarjeta gráfica int maxThreads = get_max_number_threads_block(); // Devuelve el número máximo de hilos que se pueden ejecutar por bloque printf("Comienza el juego de la vida:\n"); int number_blocks = 1; //Número de bloques int number_rows = 32; // Número de elementos por fila int number_columns = 32; // Número de elementos por columna char execution_mode = 'a'; // Modo de ejecución del programa // Condiciones para los casos en los que se está pasando por terminal una serie de parámetros if (argc == 2)//Consideración si solo se pasan dos parámetros por consola { execution_mode = argv[1][0]; } else if (argc == 3)//Consideración si solo se pasan tres parámetros por consola { execution_mode = argv[1][0]; number_rows = atoi(argv[2]); } else if (argc >= 4)//Consideración si solo se pasan cuatro o más parámetros por consola { execution_mode = argv[1][0]; number_rows = atoi(argv[2]); number_columns = atoi(argv[3]); } int size = number_rows * number_columns; //Tamaño de la matriz int width = number_columns; //Ancho del bloque if (size <= maxThreads) // Si el tamaño de la matriz es inferior o igual al máximo número de hilos por bloque que admite la GPU { int counter = 1;//Contador de número de paso de matriz del juego char* a = (char*)malloc(size * sizeof(char)); char* b = (char*)malloc(size * sizeof(char)); generate_matrix(a, size, number_blocks, size); printf("Situacion Inicial:\n"); for (int i = 0; i < size; i++)//Representación matriz inicial { if (i % width == width - 1) { printf("%c\n", a[i]); } else { printf("%c ", a[i]); } } while (execution_mode == 'm' || execution_mode == 'a') { if (counter % 2 == 1) { step_life(a, b, width, size, number_blocks, size); printf("Matriz paso %d:\n", counter); for (int i = 0; i < size; i++)//Representación matriz inicial { if (i % width == width - 1) { printf("%c\n", b[i]); } else { printf("%c ", b[i]); } } } else { step_life(b, a, width, size, number_blocks, size); printf("Matriz paso %d:\n", counter); for (int i = 0; i < size; i++)//Representación matriz inicial { if (i % width == width - 1) { printf("%c\n", a[i]); } else { printf("%c ", a[i]); } } } counter++; if (execution_mode == 'm') //Si el modo seleccionado no es automático para hasta que el usuario pulse una tecla { getchar(); } } if (execution_mode != 'm' && execution_mode != 'a')//Si el modo ejecución es distinto a los propuestos parar el programa { printf("El modo de ejecucion del programa es incorrecto.\n"); } free(a); free(b); } else // Si el tamaño de la matriz es mayor al máximo número de hilos por bloque que admite la GPU { printf("Las dimensiones de la matriz introducidas no son validas.\n"); } getchar(); getchar(); return 0; } void generate_matrix(char* m, int size, int nBlocks, int nThreads) // Genera la matriz con su estado inicial { srand(time(NULL)); int seed = rand() % 50000; char* m_d; int numElem = generate_random(1, size*0.15);// Genera un número aleatorio de máxima número de células vivas en la etapa inicial siendo el máximo un 15% del máximo número de casillas cudaMalloc((void**)&m_d, size * sizeof(char)); cudaMemcpy(m_d, m, size * sizeof(char), cudaMemcpyHostToDevice); prepare_matrix <<<nBlocks, nThreads >>> (m_d);//Prepara la matriz con todas las casillas con células muertas make_rand <<<nBlocks, numElem >>> (seed, m_d, size);// Va colocando de forma aleatoria células vivas en las casillas de la matriz cudaDeviceSynchronize(); cudaMemcpy(m, m_d, size * sizeof(char), cudaMemcpyDeviceToHost); cudaFree(m_d); } void step_life(char* m, char* p, int width, int size, int nBlocks, int nThreads) // Genera la matriz resultado a partir de una matriz inicial con las restricciones marcadas para cada casilla { char* m_d; char* p_d; cudaMalloc((void**)&m_d, size * sizeof(char)); cudaMalloc((void**)&p_d, size * sizeof(char)); cudaMemcpy(m_d, m, size * sizeof(char), cudaMemcpyHostToDevice); cudaMemcpy(p_d, p, size * sizeof(char), cudaMemcpyHostToDevice); matrix_operation <<<nBlocks, nThreads >>> (m_d, p_d, width, size);// Estudia el cambio o no de valor de las distintas casillas de la matriz cudaDeviceSynchronize(); cudaMemcpy(m, m_d, size * sizeof(char), cudaMemcpyDeviceToHost); cudaMemcpy(p, p_d, size * sizeof(char), cudaMemcpyDeviceToHost); cudaFree(m_d); cudaFree(p_d); } int generate_random(int min, int max)// Genera un número aleatorio entre un mínimo y un máximo { srand(time(NULL)); int randNumber = rand() % (max - min) + min; return randNumber; } int get_max_number_threads_block()// Devuelve el número máximo de hilos que se pueden ejecutar por bloque { cudaDeviceProp prop; int count; //Obtención número de dispositivos compatibles con CUDA HANDLE_ERROR(cudaGetDeviceCount(&count)); HANDLE_ERROR(cudaGetDeviceProperties(&prop, 0)); return prop.maxThreadsPerBlock; } void show_info_gpu_card()// Muestra las características de la tarjeta gráfica usada { cudaDeviceProp prop; int count; //Obtención número de dispositivos compatibles con CUDA HANDLE_ERROR(cudaGetDeviceCount(&count)); printf("Numero de dispositivos compatibles con CUDA: %d.\n", count); //Obtención de características relativas a cada dispositivo for (int i = 0; i < count; i++) { HANDLE_ERROR(cudaGetDeviceProperties(&prop, i)); printf("Informacion general del dispositivo %d compatible con CUDA:\n", i + 1); printf("Nombre GPU: %s.\n", prop.name); printf("Capacidad de computo: %d,%d.\n", prop.major, prop.minor); printf("Velocidad de reloj: %d kHz.\n", prop.clockRate); printf("Copia solapada dispositivo: "); if (prop.deviceOverlap) { printf("Activo.\n"); } else { printf("Inactivo.\n"); } printf("Timeout de ejecucion del Kernel: "); if (prop.kernelExecTimeoutEnabled) { printf("Activo.\n"); } else { printf("Inactivo.\n"); } printf("\nInformacion de memoria para el dispositivo %d:\n", i + 1); printf("Memoria global total: %zu GB.\n", prop.totalGlobalMem / (1024 * 1024 * 1024)); printf("Memoria constante total: %zu Bytes.\n", prop.totalConstMem); printf("Memoria compartida por bloque: %zu Bytes.\n", prop.sharedMemPerBlock); printf("Numero registros compartidos por bloque: %d.\n", prop.regsPerBlock); printf("Numero hilos maximos por bloque: %d.\n", prop.maxThreadsPerBlock); printf("Memoria compartida por multiprocesador: %zu Bytes.\n", prop.sharedMemPerMultiprocessor); printf("Numero registros compartidos por multiprocesador: %d.\n", prop.regsPerMultiprocessor); printf("Numero hilos maximos por multiprocesador: %d.\n", prop.maxThreadsPerMultiProcessor); printf("Numero de hilos en warp: %d.\n", prop.warpSize); printf("Alineamiento maximo de memoria: %zu.\n", prop.memPitch); printf("Textura de alineamiento: %zd.\n", prop.textureAlignment); printf("Total de multiprocesadores: %d.\n", prop.multiProcessorCount); printf("Maximas dimensiones de un hilo: (%d, %d, %d).\n", prop.maxThreadsDim[0], prop.maxThreadsDim[1], prop.maxThreadsDim[2]); printf("Maximas dimensiones de grid: (%d, %d, %d).\n\n", prop.maxGridSize[0], prop.maxGridSize[1], prop.maxGridSize[2]); } getchar(); }
c24b873a039c7fe39e050692011f4790ac2c67f1.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" __global__ void addVectors(const int entries, const float *a, const float *b, float *ab){ const int N = threadIdx.x + (16 * blockIdx.x); if(N < entries) ab[N] = a[N] + b[N]; }
c24b873a039c7fe39e050692011f4790ac2c67f1.cu
__global__ void addVectors(const int entries, const float *a, const float *b, float *ab){ const int N = threadIdx.x + (16 * blockIdx.x); if(N < entries) ab[N] = a[N] + b[N]; }
d4b2f1fcda2b2e1d454ce3ceeca151d6c2231543.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include <ATen/ATen.h> #include <ATen/TensorUtils.h> #include <ATen/hip/HIPContext.h> #include <ATen/hip/impl/HIPGuardImplMasqueradingAsCUDA.h> #include <THH/THHAtomics.cuh> #include "cuda_helpers.h" template <typename T> __device__ T bilinear_interpolate( const T* input, int height, int width, T y, T x, int index /* index for debug only*/) { // deal with cases that inverse elements are out of feature map boundary if (y < -1.0 || y > height || x < -1.0 || x > width) { // empty return 0; } if (y <= 0) y = 0; if (x <= 0) x = 0; int y_low = (int)y; int x_low = (int)x; int y_high; int x_high; if (y_low >= height - 1) { y_high = y_low = height - 1; y = (T)y_low; } else { y_high = y_low + 1; } if (x_low >= width - 1) { x_high = x_low = width - 1; x = (T)x_low; } else { x_high = x_low + 1; } T ly = y - y_low; T lx = x - x_low; T hy = 1. - ly, hx = 1. - lx; // do bilinear interpolation T v1 = input[y_low * width + x_low]; T v2 = input[y_low * width + x_high]; T v3 = input[y_high * width + x_low]; T v4 = input[y_high * width + x_high]; T w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx; T val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); return val; } template <typename T> __global__ void RoIAlignForward( int nthreads, const T* input, const T spatial_scale, int channels, int height, int width, int pooled_height, int pooled_width, int sampling_ratio, bool aligned, const T* rois, T* output) { CUDA_1D_KERNEL_LOOP(index, nthreads) { // (n, c, ph, pw) is an element in the pooled output int pw = index % pooled_width; int ph = (index / pooled_width) % pooled_height; int c = (index / pooled_width / pooled_height) % channels; int n = index / pooled_width / pooled_height / channels; const T* offset_rois = rois + n * 5; int roi_batch_ind = offset_rois[0]; // Do not using rounding; this implementation detail is critical T offset = aligned ? (T)0.5 : (T)0.0; T roi_start_w = offset_rois[1] * spatial_scale - offset; T roi_start_h = offset_rois[2] * spatial_scale - offset; T roi_end_w = offset_rois[3] * spatial_scale - offset; T roi_end_h = offset_rois[4] * spatial_scale - offset; T roi_width = roi_end_w - roi_start_w; T roi_height = roi_end_h - roi_start_h; if (!aligned) { // Force malformed ROIs to be 1x1 roi_width = max(roi_width, (T)1.); roi_height = max(roi_height, (T)1.); } T bin_size_h = static_cast<T>(roi_height) / static_cast<T>(pooled_height); T bin_size_w = static_cast<T>(roi_width) / static_cast<T>(pooled_width); const T* offset_input = input + (roi_batch_ind * channels + c) * height * width; // We use roi_bin_grid to sample the grid and mimic integral int roi_bin_grid_h = (sampling_ratio > 0) ? sampling_ratio : ceil(roi_height / pooled_height); // e.g., = 2 int roi_bin_grid_w = (sampling_ratio > 0) ? sampling_ratio : ceil(roi_width / pooled_width); // We do average (integral) pooling inside a bin // When the grid is empty, output zeros. const T count = max(roi_bin_grid_h * roi_bin_grid_w, 1); // e.g. = 4 T output_val = 0.; for (int iy = 0; iy < roi_bin_grid_h; iy++) // e.g., iy = 0, 1 { const T y = roi_start_h + ph * bin_size_h + static_cast<T>(iy + .5f) * bin_size_h / static_cast<T>(roi_bin_grid_h); // e.g., 0.5, 1.5 for (int ix = 0; ix < roi_bin_grid_w; ix++) { const T x = roi_start_w + pw * bin_size_w + static_cast<T>(ix + .5f) * bin_size_w / static_cast<T>(roi_bin_grid_w); T val = bilinear_interpolate(offset_input, height, width, y, x, index); output_val += val; } } output_val /= count; output[index] = output_val; } } template <typename T> __device__ void bilinear_interpolate_gradient( int height, int width, T y, T x, T& w1, T& w2, T& w3, T& w4, int& x_low, int& x_high, int& y_low, int& y_high, int index /* index for debug only*/) { // deal with cases that inverse elements are out of feature map boundary if (y < -1.0 || y > height || x < -1.0 || x > width) { // empty w1 = w2 = w3 = w4 = 0.; x_low = x_high = y_low = y_high = -1; return; } if (y <= 0) y = 0; if (x <= 0) x = 0; y_low = (int)y; x_low = (int)x; if (y_low >= height - 1) { y_high = y_low = height - 1; y = (T)y_low; } else { y_high = y_low + 1; } if (x_low >= width - 1) { x_high = x_low = width - 1; x = (T)x_low; } else { x_high = x_low + 1; } T ly = y - y_low; T lx = x - x_low; T hy = 1. - ly, hx = 1. - lx; // reference in forward // T v1 = input[y_low * width + x_low]; // T v2 = input[y_low * width + x_high]; // T v3 = input[y_high * width + x_low]; // T v4 = input[y_high * width + x_high]; // T val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx; } template <typename T> __global__ void RoIAlignBackward( int nthreads, const T* grad_output, const T spatial_scale, int channels, int height, int width, int pooled_height, int pooled_width, int sampling_ratio, bool aligned, T* grad_input, const T* rois, int n_stride, int c_stride, int h_stride, int w_stride) { CUDA_1D_KERNEL_LOOP(index, nthreads) { // (n, c, ph, pw) is an element in the pooled output int pw = index % pooled_width; int ph = (index / pooled_width) % pooled_height; int c = (index / pooled_width / pooled_height) % channels; int n = index / pooled_width / pooled_height / channels; const T* offset_rois = rois + n * 5; int roi_batch_ind = offset_rois[0]; // Do not using rounding; this implementation detail is critical T offset = aligned ? (T)0.5 : (T)0.0; T roi_start_w = offset_rois[1] * spatial_scale - offset; T roi_start_h = offset_rois[2] * spatial_scale - offset; T roi_end_w = offset_rois[3] * spatial_scale - offset; T roi_end_h = offset_rois[4] * spatial_scale - offset; T roi_width = roi_end_w - roi_start_w; T roi_height = roi_end_h - roi_start_h; if (!aligned) { // Force malformed ROIs to be 1x1 roi_width = max(roi_width, (T)1.); roi_height = max(roi_height, (T)1.); } T bin_size_h = static_cast<T>(roi_height) / static_cast<T>(pooled_height); T bin_size_w = static_cast<T>(roi_width) / static_cast<T>(pooled_width); T* offset_grad_input = grad_input + ((roi_batch_ind * channels + c) * height * width); // We need to index the gradient using the tensor strides to access the // correct values. int output_offset = n * n_stride + c * c_stride; const T* offset_grad_output = grad_output + output_offset; const T grad_output_this_bin = offset_grad_output[ph * h_stride + pw * w_stride]; // We use roi_bin_grid to sample the grid and mimic integral int roi_bin_grid_h = (sampling_ratio > 0) ? sampling_ratio : ceil(roi_height / pooled_height); // e.g., = 2 int roi_bin_grid_w = (sampling_ratio > 0) ? sampling_ratio : ceil(roi_width / pooled_width); // We do average (integral) pooling inside a bin const T count = roi_bin_grid_h * roi_bin_grid_w; // e.g. = 4 for (int iy = 0; iy < roi_bin_grid_h; iy++) // e.g., iy = 0, 1 { const T y = roi_start_h + ph * bin_size_h + static_cast<T>(iy + .5f) * bin_size_h / static_cast<T>(roi_bin_grid_h); // e.g., 0.5, 1.5 for (int ix = 0; ix < roi_bin_grid_w; ix++) { const T x = roi_start_w + pw * bin_size_w + static_cast<T>(ix + .5f) * bin_size_w / static_cast<T>(roi_bin_grid_w); T w1, w2, w3, w4; int x_low, x_high, y_low, y_high; bilinear_interpolate_gradient( height, width, y, x, w1, w2, w3, w4, x_low, x_high, y_low, y_high, index); T g1 = grad_output_this_bin * w1 / count; T g2 = grad_output_this_bin * w2 / count; T g3 = grad_output_this_bin * w3 / count; T g4 = grad_output_this_bin * w4 / count; if (x_low >= 0 && x_high >= 0 && y_low >= 0 && y_high >= 0) { atomicAdd( offset_grad_input + y_low * width + x_low, static_cast<T>(g1)); atomicAdd( offset_grad_input + y_low * width + x_high, static_cast<T>(g2)); atomicAdd( offset_grad_input + y_high * width + x_low, static_cast<T>(g3)); atomicAdd( offset_grad_input + y_high * width + x_high, static_cast<T>(g4)); } // if } // ix } // iy } // CUDA_1D_KERNEL_LOOP } // RoIAlignBackward at::Tensor ROIAlign_forward_cuda( const at::Tensor& input, const at::Tensor& rois, double spatial_scale, int64_t pooled_height, int64_t pooled_width, int64_t sampling_ratio, bool aligned) { TORCH_CHECK(input.is_cuda(), "input must be a CUDA tensor"); TORCH_CHECK(rois.is_cuda(), "rois must be a CUDA tensor"); TORCH_CHECK( rois.size(1) == 5, "rois must have shape as Tensor[K, 5]"); at::TensorArg input_t{input, "input", 1}, rois_t{rois, "rois", 2}; at::CheckedFrom c = "ROIAlign_forward_cuda"; at::checkAllSameGPU(c, {input_t, rois_t}); at::checkAllSameType(c, {input_t, rois_t}); at::hip::HIPGuardMasqueradingAsCUDA device_guard(input.device()); auto num_rois = rois.size(0); auto channels = input.size(1); auto height = input.size(2); auto width = input.size(3); at::Tensor output = at::zeros( {num_rois, channels, pooled_height, pooled_width}, input.options()); auto output_size = num_rois * pooled_height * pooled_width * channels; hipStream_t stream = at::hip::getCurrentHIPStreamMasqueradingAsCUDA(); dim3 grid(::min( ceil_div(static_cast<int64_t>(output_size), static_cast<int64_t>(512)), static_cast<int64_t>(4096))); dim3 block(512); if (output.numel() == 0) { AT_CUDA_CHECK(hipGetLastError()); return output; } auto input_ = input.contiguous(), rois_ = rois.contiguous(); AT_DISPATCH_FLOATING_TYPES_AND_HALF(input.scalar_type(), "ROIAlign_forward", [&] { hipLaunchKernelGGL(( RoIAlignForward<scalar_t>), dim3(grid), dim3(block), 0, stream, output_size, input_.data_ptr<scalar_t>(), spatial_scale, channels, height, width, pooled_height, pooled_width, sampling_ratio, aligned, rois_.data_ptr<scalar_t>(), output.data_ptr<scalar_t>()); }); AT_CUDA_CHECK(hipGetLastError()); return output; } at::Tensor ROIAlign_backward_cuda( const at::Tensor& grad, const at::Tensor& rois, double spatial_scale, int64_t pooled_height, int64_t pooled_width, int64_t batch_size, int64_t channels, int64_t height, int64_t width, int64_t sampling_ratio, bool aligned) { TORCH_CHECK(grad.is_cuda(), "grad must be a CUDA tensor"); TORCH_CHECK(rois.is_cuda(), "rois must be a CUDA tensor"); at::TensorArg grad_t{grad, "grad", 1}, rois_t{rois, "rois", 2}; at::CheckedFrom c = "ROIAlign_backward_cuda"; at::checkAllSameGPU(c, {grad_t, rois_t}); at::checkAllSameType(c, {grad_t, rois_t}); at::hip::HIPGuardMasqueradingAsCUDA device_guard(grad.device()); at::Tensor grad_input = at::zeros({batch_size, channels, height, width}, grad.options()); hipStream_t stream = at::hip::getCurrentHIPStreamMasqueradingAsCUDA(); dim3 grid(::min( ceil_div(static_cast<int64_t>(grad.numel()), static_cast<int64_t>(512)), static_cast<int64_t>(4096))); dim3 block(512); // handle possibly empty gradients if (grad.numel() == 0) { AT_CUDA_CHECK(hipGetLastError()); return grad_input; } int n_stride = grad.stride(0); int c_stride = grad.stride(1); int h_stride = grad.stride(2); int w_stride = grad.stride(3); auto rois_ = rois.contiguous(); AT_DISPATCH_FLOATING_TYPES_AND_HALF(grad.scalar_type(), "ROIAlign_backward", [&] { hipLaunchKernelGGL(( RoIAlignBackward<scalar_t>), dim3(grid), dim3(block), 0, stream, grad.numel(), grad.data_ptr<scalar_t>(), spatial_scale, channels, height, width, pooled_height, pooled_width, sampling_ratio, aligned, grad_input.data_ptr<scalar_t>(), rois_.data_ptr<scalar_t>(), n_stride, c_stride, h_stride, w_stride); }); AT_CUDA_CHECK(hipGetLastError()); return grad_input; }
d4b2f1fcda2b2e1d454ce3ceeca151d6c2231543.cu
#include <ATen/ATen.h> #include <ATen/TensorUtils.h> #include <ATen/cuda/CUDAContext.h> #include <c10/cuda/CUDAGuard.h> #include <THC/THCAtomics.cuh> #include "cuda_helpers.h" template <typename T> __device__ T bilinear_interpolate( const T* input, int height, int width, T y, T x, int index /* index for debug only*/) { // deal with cases that inverse elements are out of feature map boundary if (y < -1.0 || y > height || x < -1.0 || x > width) { // empty return 0; } if (y <= 0) y = 0; if (x <= 0) x = 0; int y_low = (int)y; int x_low = (int)x; int y_high; int x_high; if (y_low >= height - 1) { y_high = y_low = height - 1; y = (T)y_low; } else { y_high = y_low + 1; } if (x_low >= width - 1) { x_high = x_low = width - 1; x = (T)x_low; } else { x_high = x_low + 1; } T ly = y - y_low; T lx = x - x_low; T hy = 1. - ly, hx = 1. - lx; // do bilinear interpolation T v1 = input[y_low * width + x_low]; T v2 = input[y_low * width + x_high]; T v3 = input[y_high * width + x_low]; T v4 = input[y_high * width + x_high]; T w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx; T val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); return val; } template <typename T> __global__ void RoIAlignForward( int nthreads, const T* input, const T spatial_scale, int channels, int height, int width, int pooled_height, int pooled_width, int sampling_ratio, bool aligned, const T* rois, T* output) { CUDA_1D_KERNEL_LOOP(index, nthreads) { // (n, c, ph, pw) is an element in the pooled output int pw = index % pooled_width; int ph = (index / pooled_width) % pooled_height; int c = (index / pooled_width / pooled_height) % channels; int n = index / pooled_width / pooled_height / channels; const T* offset_rois = rois + n * 5; int roi_batch_ind = offset_rois[0]; // Do not using rounding; this implementation detail is critical T offset = aligned ? (T)0.5 : (T)0.0; T roi_start_w = offset_rois[1] * spatial_scale - offset; T roi_start_h = offset_rois[2] * spatial_scale - offset; T roi_end_w = offset_rois[3] * spatial_scale - offset; T roi_end_h = offset_rois[4] * spatial_scale - offset; T roi_width = roi_end_w - roi_start_w; T roi_height = roi_end_h - roi_start_h; if (!aligned) { // Force malformed ROIs to be 1x1 roi_width = max(roi_width, (T)1.); roi_height = max(roi_height, (T)1.); } T bin_size_h = static_cast<T>(roi_height) / static_cast<T>(pooled_height); T bin_size_w = static_cast<T>(roi_width) / static_cast<T>(pooled_width); const T* offset_input = input + (roi_batch_ind * channels + c) * height * width; // We use roi_bin_grid to sample the grid and mimic integral int roi_bin_grid_h = (sampling_ratio > 0) ? sampling_ratio : ceil(roi_height / pooled_height); // e.g., = 2 int roi_bin_grid_w = (sampling_ratio > 0) ? sampling_ratio : ceil(roi_width / pooled_width); // We do average (integral) pooling inside a bin // When the grid is empty, output zeros. const T count = max(roi_bin_grid_h * roi_bin_grid_w, 1); // e.g. = 4 T output_val = 0.; for (int iy = 0; iy < roi_bin_grid_h; iy++) // e.g., iy = 0, 1 { const T y = roi_start_h + ph * bin_size_h + static_cast<T>(iy + .5f) * bin_size_h / static_cast<T>(roi_bin_grid_h); // e.g., 0.5, 1.5 for (int ix = 0; ix < roi_bin_grid_w; ix++) { const T x = roi_start_w + pw * bin_size_w + static_cast<T>(ix + .5f) * bin_size_w / static_cast<T>(roi_bin_grid_w); T val = bilinear_interpolate(offset_input, height, width, y, x, index); output_val += val; } } output_val /= count; output[index] = output_val; } } template <typename T> __device__ void bilinear_interpolate_gradient( int height, int width, T y, T x, T& w1, T& w2, T& w3, T& w4, int& x_low, int& x_high, int& y_low, int& y_high, int index /* index for debug only*/) { // deal with cases that inverse elements are out of feature map boundary if (y < -1.0 || y > height || x < -1.0 || x > width) { // empty w1 = w2 = w3 = w4 = 0.; x_low = x_high = y_low = y_high = -1; return; } if (y <= 0) y = 0; if (x <= 0) x = 0; y_low = (int)y; x_low = (int)x; if (y_low >= height - 1) { y_high = y_low = height - 1; y = (T)y_low; } else { y_high = y_low + 1; } if (x_low >= width - 1) { x_high = x_low = width - 1; x = (T)x_low; } else { x_high = x_low + 1; } T ly = y - y_low; T lx = x - x_low; T hy = 1. - ly, hx = 1. - lx; // reference in forward // T v1 = input[y_low * width + x_low]; // T v2 = input[y_low * width + x_high]; // T v3 = input[y_high * width + x_low]; // T v4 = input[y_high * width + x_high]; // T val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx; } template <typename T> __global__ void RoIAlignBackward( int nthreads, const T* grad_output, const T spatial_scale, int channels, int height, int width, int pooled_height, int pooled_width, int sampling_ratio, bool aligned, T* grad_input, const T* rois, int n_stride, int c_stride, int h_stride, int w_stride) { CUDA_1D_KERNEL_LOOP(index, nthreads) { // (n, c, ph, pw) is an element in the pooled output int pw = index % pooled_width; int ph = (index / pooled_width) % pooled_height; int c = (index / pooled_width / pooled_height) % channels; int n = index / pooled_width / pooled_height / channels; const T* offset_rois = rois + n * 5; int roi_batch_ind = offset_rois[0]; // Do not using rounding; this implementation detail is critical T offset = aligned ? (T)0.5 : (T)0.0; T roi_start_w = offset_rois[1] * spatial_scale - offset; T roi_start_h = offset_rois[2] * spatial_scale - offset; T roi_end_w = offset_rois[3] * spatial_scale - offset; T roi_end_h = offset_rois[4] * spatial_scale - offset; T roi_width = roi_end_w - roi_start_w; T roi_height = roi_end_h - roi_start_h; if (!aligned) { // Force malformed ROIs to be 1x1 roi_width = max(roi_width, (T)1.); roi_height = max(roi_height, (T)1.); } T bin_size_h = static_cast<T>(roi_height) / static_cast<T>(pooled_height); T bin_size_w = static_cast<T>(roi_width) / static_cast<T>(pooled_width); T* offset_grad_input = grad_input + ((roi_batch_ind * channels + c) * height * width); // We need to index the gradient using the tensor strides to access the // correct values. int output_offset = n * n_stride + c * c_stride; const T* offset_grad_output = grad_output + output_offset; const T grad_output_this_bin = offset_grad_output[ph * h_stride + pw * w_stride]; // We use roi_bin_grid to sample the grid and mimic integral int roi_bin_grid_h = (sampling_ratio > 0) ? sampling_ratio : ceil(roi_height / pooled_height); // e.g., = 2 int roi_bin_grid_w = (sampling_ratio > 0) ? sampling_ratio : ceil(roi_width / pooled_width); // We do average (integral) pooling inside a bin const T count = roi_bin_grid_h * roi_bin_grid_w; // e.g. = 4 for (int iy = 0; iy < roi_bin_grid_h; iy++) // e.g., iy = 0, 1 { const T y = roi_start_h + ph * bin_size_h + static_cast<T>(iy + .5f) * bin_size_h / static_cast<T>(roi_bin_grid_h); // e.g., 0.5, 1.5 for (int ix = 0; ix < roi_bin_grid_w; ix++) { const T x = roi_start_w + pw * bin_size_w + static_cast<T>(ix + .5f) * bin_size_w / static_cast<T>(roi_bin_grid_w); T w1, w2, w3, w4; int x_low, x_high, y_low, y_high; bilinear_interpolate_gradient( height, width, y, x, w1, w2, w3, w4, x_low, x_high, y_low, y_high, index); T g1 = grad_output_this_bin * w1 / count; T g2 = grad_output_this_bin * w2 / count; T g3 = grad_output_this_bin * w3 / count; T g4 = grad_output_this_bin * w4 / count; if (x_low >= 0 && x_high >= 0 && y_low >= 0 && y_high >= 0) { atomicAdd( offset_grad_input + y_low * width + x_low, static_cast<T>(g1)); atomicAdd( offset_grad_input + y_low * width + x_high, static_cast<T>(g2)); atomicAdd( offset_grad_input + y_high * width + x_low, static_cast<T>(g3)); atomicAdd( offset_grad_input + y_high * width + x_high, static_cast<T>(g4)); } // if } // ix } // iy } // CUDA_1D_KERNEL_LOOP } // RoIAlignBackward at::Tensor ROIAlign_forward_cuda( const at::Tensor& input, const at::Tensor& rois, double spatial_scale, int64_t pooled_height, int64_t pooled_width, int64_t sampling_ratio, bool aligned) { TORCH_CHECK(input.is_cuda(), "input must be a CUDA tensor"); TORCH_CHECK(rois.is_cuda(), "rois must be a CUDA tensor"); TORCH_CHECK( rois.size(1) == 5, "rois must have shape as Tensor[K, 5]"); at::TensorArg input_t{input, "input", 1}, rois_t{rois, "rois", 2}; at::CheckedFrom c = "ROIAlign_forward_cuda"; at::checkAllSameGPU(c, {input_t, rois_t}); at::checkAllSameType(c, {input_t, rois_t}); at::cuda::CUDAGuard device_guard(input.device()); auto num_rois = rois.size(0); auto channels = input.size(1); auto height = input.size(2); auto width = input.size(3); at::Tensor output = at::zeros( {num_rois, channels, pooled_height, pooled_width}, input.options()); auto output_size = num_rois * pooled_height * pooled_width * channels; cudaStream_t stream = at::cuda::getCurrentCUDAStream(); dim3 grid(std::min( ceil_div(static_cast<int64_t>(output_size), static_cast<int64_t>(512)), static_cast<int64_t>(4096))); dim3 block(512); if (output.numel() == 0) { AT_CUDA_CHECK(cudaGetLastError()); return output; } auto input_ = input.contiguous(), rois_ = rois.contiguous(); AT_DISPATCH_FLOATING_TYPES_AND_HALF(input.scalar_type(), "ROIAlign_forward", [&] { RoIAlignForward<scalar_t><<<grid, block, 0, stream>>>( output_size, input_.data_ptr<scalar_t>(), spatial_scale, channels, height, width, pooled_height, pooled_width, sampling_ratio, aligned, rois_.data_ptr<scalar_t>(), output.data_ptr<scalar_t>()); }); AT_CUDA_CHECK(cudaGetLastError()); return output; } at::Tensor ROIAlign_backward_cuda( const at::Tensor& grad, const at::Tensor& rois, double spatial_scale, int64_t pooled_height, int64_t pooled_width, int64_t batch_size, int64_t channels, int64_t height, int64_t width, int64_t sampling_ratio, bool aligned) { TORCH_CHECK(grad.is_cuda(), "grad must be a CUDA tensor"); TORCH_CHECK(rois.is_cuda(), "rois must be a CUDA tensor"); at::TensorArg grad_t{grad, "grad", 1}, rois_t{rois, "rois", 2}; at::CheckedFrom c = "ROIAlign_backward_cuda"; at::checkAllSameGPU(c, {grad_t, rois_t}); at::checkAllSameType(c, {grad_t, rois_t}); at::cuda::CUDAGuard device_guard(grad.device()); at::Tensor grad_input = at::zeros({batch_size, channels, height, width}, grad.options()); cudaStream_t stream = at::cuda::getCurrentCUDAStream(); dim3 grid(std::min( ceil_div(static_cast<int64_t>(grad.numel()), static_cast<int64_t>(512)), static_cast<int64_t>(4096))); dim3 block(512); // handle possibly empty gradients if (grad.numel() == 0) { AT_CUDA_CHECK(cudaGetLastError()); return grad_input; } int n_stride = grad.stride(0); int c_stride = grad.stride(1); int h_stride = grad.stride(2); int w_stride = grad.stride(3); auto rois_ = rois.contiguous(); AT_DISPATCH_FLOATING_TYPES_AND_HALF(grad.scalar_type(), "ROIAlign_backward", [&] { RoIAlignBackward<scalar_t><<<grid, block, 0, stream>>>( grad.numel(), grad.data_ptr<scalar_t>(), spatial_scale, channels, height, width, pooled_height, pooled_width, sampling_ratio, aligned, grad_input.data_ptr<scalar_t>(), rois_.data_ptr<scalar_t>(), n_stride, c_stride, h_stride, w_stride); }); AT_CUDA_CHECK(cudaGetLastError()); return grad_input; }
34911fc7a0ffd10b886a234513068fcb02c1927a.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #ifdef USE_CUDNN #include <vector> #include "caffe/layers/cudnn_conv_layer.hpp" namespace caffe { __global__ void sync_conv_groups() { } template <typename Dtype> void CuDNNConvolutionLayer<Dtype>::Forward_gpu( const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) { const Dtype* weight = this->blobs_[0]->gpu_data(); for (int i = 0; i < bottom.size(); ++i) { const Dtype* bottom_data = bottom[i]->gpu_data(); Dtype* top_data = top[i]->mutable_gpu_data(); // Forward through cuDNN in parallel over groups. for (int g = 0; g < this->group_; g++) { // Filters. CUDNN_CHECK(cudnnConvolutionForward(handle_[g], cudnn::dataType<Dtype>::one, bottom_descs_[i], bottom_data + bottom_offset_ * g, filter_desc_, weight + this->weight_offset_ * g, conv_descs_[i], fwd_algo_[i], workspace[g], workspace_fwd_sizes_[i], cudnn::dataType<Dtype>::zero, top_descs_[i], top_data + top_offset_ * g)); // Bias. if (this->bias_term_) { const Dtype* bias_data = this->blobs_[1]->gpu_data(); CUDNN_CHECK(cudnnAddTensor(handle_[g], cudnn::dataType<Dtype>::one, bias_desc_, bias_data + bias_offset_ * g, cudnn::dataType<Dtype>::one, top_descs_[i], top_data + top_offset_ * g)); } } // Synchronize the work across groups, each of which went into its own // stream, by launching an empty kernel into the default (null) stream. // NOLINT_NEXT_LINE(whitespace/operators) hipLaunchKernelGGL(( sync_conv_groups), dim3(1), dim3(1), 0, 0, ); } } //for iccv17 bier loss template <typename Dtype> __global__ void compute_norm(const int d, const int h, Dtype* w, Dtype* temp) { CUDA_KERNEL_LOOP(index, d) { for(int i = 0; i < h; i++) { temp[index]=temp[index] + w[index*h+i] * w[index*h+i]; } temp[index] = temp[index] - Dtype(1.0); } } template <typename Dtype> __global__ void compute_gradients(const int d, const int h, Dtype* w, Dtype* w_g, Dtype* temp, Dtype lamda) { CUDA_KERNEL_LOOP(index, d*h) { int i = index/h; int j = index%h; w_g[i*h+j] = w_g[i*h+j] + Dtype(4.0) * lamda * temp[i] * w[i*h+j]; } } template <typename Dtype> void CuDNNConvolutionLayer<Dtype>::Backward_gpu(const vector<Blob<Dtype>*>& top, const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom) { const Dtype* weight = NULL; Dtype* weight_diff = NULL; if (this->param_propagate_down_[0]) { weight = this->blobs_[0]->gpu_data(); weight_diff = this->blobs_[0]->mutable_gpu_diff(); } Dtype* bias_diff = NULL; if (this->bias_term_ && this->param_propagate_down_[1]) { bias_diff = this->blobs_[1]->mutable_gpu_diff(); } for (int i = 0; i < top.size(); ++i) { const Dtype* top_diff = top[i]->gpu_diff(); // Backward through cuDNN in parallel over groups and gradients. for (int g = 0; g < this->group_; g++) { // Gradient w.r.t. bias. if (this->bias_term_ && this->param_propagate_down_[1]) { CUDNN_CHECK(cudnnConvolutionBackwardBias(handle_[0*this->group_ + g], cudnn::dataType<Dtype>::one, top_descs_[i], top_diff + top_offset_ * g, cudnn::dataType<Dtype>::one, bias_desc_, bias_diff + bias_offset_ * g)); } // Gradient w.r.t. weights. if (this->param_propagate_down_[0]) { const Dtype* bottom_data = bottom[i]->gpu_data(); CUDNN_CHECK(cudnnConvolutionBackwardFilter( handle_[1*this->group_ + g], cudnn::dataType<Dtype>::one, bottom_descs_[i], bottom_data + bottom_offset_ * g, top_descs_[i], top_diff + top_offset_ * g, conv_descs_[i], bwd_filter_algo_[i], workspace[1*this->group_ + g], workspace_bwd_filter_sizes_[i], cudnn::dataType<Dtype>::one, filter_desc_, weight_diff + this->weight_offset_ * g)); //ICCV17 BIER if(this->layer_param_.convolution_param().bier_init()) { const int N_ = bier_temp_.count();//num_output; const int K_ = this->blobs_[0]->count()/N_;// Dtype lamda_ = this->layer_param_.convolution_param().lamda(); caffe_gpu_set(bier_temp_.count(), Dtype(0.0), bier_temp_.mutable_gpu_data()); hipLaunchKernelGGL(( compute_norm<Dtype>), dim3(CAFFE_GET_BLOCKS(N_)), dim3(CAFFE_CUDA_NUM_THREADS), 0, 0, N_, K_, this->blobs_[0]->mutable_gpu_data(), bier_temp_.mutable_gpu_data()); //add new codes hipLaunchKernelGGL(( compute_gradients<Dtype>), dim3(CAFFE_GET_BLOCKS(N_*K_)), dim3(CAFFE_CUDA_NUM_THREADS), 0, 0, N_, K_, this->blobs_[0]->mutable_gpu_data(), this->blobs_[0]->mutable_gpu_diff(), bier_temp_.mutable_gpu_data(), lamda_/Dtype(N_)); } } // Gradient w.r.t. bottom data. if (propagate_down[i]) { if (weight == NULL) { weight = this->blobs_[0]->gpu_data(); } Dtype* bottom_diff = bottom[i]->mutable_gpu_diff(); CUDNN_CHECK(cudnnConvolutionBackwardData( handle_[2*this->group_ + g], cudnn::dataType<Dtype>::one, filter_desc_, weight + this->weight_offset_ * g, top_descs_[i], top_diff + top_offset_ * g, conv_descs_[i], bwd_data_algo_[i], workspace[2*this->group_ + g], workspace_bwd_data_sizes_[i], cudnn::dataType<Dtype>::zero, bottom_descs_[i], bottom_diff + bottom_offset_ * g)); } } // Synchronize the work across groups, each of which went into its own // stream, by launching an empty kernel into the default (null) stream. // NOLINT_NEXT_LINE(whitespace/operators) hipLaunchKernelGGL(( sync_conv_groups), dim3(1), dim3(1), 0, 0, ); } } INSTANTIATE_LAYER_GPU_FUNCS(CuDNNConvolutionLayer); } // namespace caffe #endif
34911fc7a0ffd10b886a234513068fcb02c1927a.cu
#ifdef USE_CUDNN #include <vector> #include "caffe/layers/cudnn_conv_layer.hpp" namespace caffe { __global__ void sync_conv_groups() { } template <typename Dtype> void CuDNNConvolutionLayer<Dtype>::Forward_gpu( const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) { const Dtype* weight = this->blobs_[0]->gpu_data(); for (int i = 0; i < bottom.size(); ++i) { const Dtype* bottom_data = bottom[i]->gpu_data(); Dtype* top_data = top[i]->mutable_gpu_data(); // Forward through cuDNN in parallel over groups. for (int g = 0; g < this->group_; g++) { // Filters. CUDNN_CHECK(cudnnConvolutionForward(handle_[g], cudnn::dataType<Dtype>::one, bottom_descs_[i], bottom_data + bottom_offset_ * g, filter_desc_, weight + this->weight_offset_ * g, conv_descs_[i], fwd_algo_[i], workspace[g], workspace_fwd_sizes_[i], cudnn::dataType<Dtype>::zero, top_descs_[i], top_data + top_offset_ * g)); // Bias. if (this->bias_term_) { const Dtype* bias_data = this->blobs_[1]->gpu_data(); CUDNN_CHECK(cudnnAddTensor(handle_[g], cudnn::dataType<Dtype>::one, bias_desc_, bias_data + bias_offset_ * g, cudnn::dataType<Dtype>::one, top_descs_[i], top_data + top_offset_ * g)); } } // Synchronize the work across groups, each of which went into its own // stream, by launching an empty kernel into the default (null) stream. // NOLINT_NEXT_LINE(whitespace/operators) sync_conv_groups<<<1, 1>>>(); } } //for iccv17 bier loss template <typename Dtype> __global__ void compute_norm(const int d, const int h, Dtype* w, Dtype* temp) { CUDA_KERNEL_LOOP(index, d) { for(int i = 0; i < h; i++) { temp[index]=temp[index] + w[index*h+i] * w[index*h+i]; } temp[index] = temp[index] - Dtype(1.0); } } template <typename Dtype> __global__ void compute_gradients(const int d, const int h, Dtype* w, Dtype* w_g, Dtype* temp, Dtype lamda) { CUDA_KERNEL_LOOP(index, d*h) { int i = index/h; int j = index%h; w_g[i*h+j] = w_g[i*h+j] + Dtype(4.0) * lamda * temp[i] * w[i*h+j]; } } template <typename Dtype> void CuDNNConvolutionLayer<Dtype>::Backward_gpu(const vector<Blob<Dtype>*>& top, const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom) { const Dtype* weight = NULL; Dtype* weight_diff = NULL; if (this->param_propagate_down_[0]) { weight = this->blobs_[0]->gpu_data(); weight_diff = this->blobs_[0]->mutable_gpu_diff(); } Dtype* bias_diff = NULL; if (this->bias_term_ && this->param_propagate_down_[1]) { bias_diff = this->blobs_[1]->mutable_gpu_diff(); } for (int i = 0; i < top.size(); ++i) { const Dtype* top_diff = top[i]->gpu_diff(); // Backward through cuDNN in parallel over groups and gradients. for (int g = 0; g < this->group_; g++) { // Gradient w.r.t. bias. if (this->bias_term_ && this->param_propagate_down_[1]) { CUDNN_CHECK(cudnnConvolutionBackwardBias(handle_[0*this->group_ + g], cudnn::dataType<Dtype>::one, top_descs_[i], top_diff + top_offset_ * g, cudnn::dataType<Dtype>::one, bias_desc_, bias_diff + bias_offset_ * g)); } // Gradient w.r.t. weights. if (this->param_propagate_down_[0]) { const Dtype* bottom_data = bottom[i]->gpu_data(); CUDNN_CHECK(cudnnConvolutionBackwardFilter( handle_[1*this->group_ + g], cudnn::dataType<Dtype>::one, bottom_descs_[i], bottom_data + bottom_offset_ * g, top_descs_[i], top_diff + top_offset_ * g, conv_descs_[i], bwd_filter_algo_[i], workspace[1*this->group_ + g], workspace_bwd_filter_sizes_[i], cudnn::dataType<Dtype>::one, filter_desc_, weight_diff + this->weight_offset_ * g)); //ICCV17 BIER if(this->layer_param_.convolution_param().bier_init()) { const int N_ = bier_temp_.count();//num_output; const int K_ = this->blobs_[0]->count()/N_;// Dtype lamda_ = this->layer_param_.convolution_param().lamda(); caffe_gpu_set(bier_temp_.count(), Dtype(0.0), bier_temp_.mutable_gpu_data()); compute_norm<Dtype><<<CAFFE_GET_BLOCKS(N_), CAFFE_CUDA_NUM_THREADS>>>(N_, K_, this->blobs_[0]->mutable_gpu_data(), bier_temp_.mutable_gpu_data()); //add new codes compute_gradients<Dtype><<<CAFFE_GET_BLOCKS(N_*K_), CAFFE_CUDA_NUM_THREADS>>>(N_, K_, this->blobs_[0]->mutable_gpu_data(), this->blobs_[0]->mutable_gpu_diff(), bier_temp_.mutable_gpu_data(), lamda_/Dtype(N_)); } } // Gradient w.r.t. bottom data. if (propagate_down[i]) { if (weight == NULL) { weight = this->blobs_[0]->gpu_data(); } Dtype* bottom_diff = bottom[i]->mutable_gpu_diff(); CUDNN_CHECK(cudnnConvolutionBackwardData( handle_[2*this->group_ + g], cudnn::dataType<Dtype>::one, filter_desc_, weight + this->weight_offset_ * g, top_descs_[i], top_diff + top_offset_ * g, conv_descs_[i], bwd_data_algo_[i], workspace[2*this->group_ + g], workspace_bwd_data_sizes_[i], cudnn::dataType<Dtype>::zero, bottom_descs_[i], bottom_diff + bottom_offset_ * g)); } } // Synchronize the work across groups, each of which went into its own // stream, by launching an empty kernel into the default (null) stream. // NOLINT_NEXT_LINE(whitespace/operators) sync_conv_groups<<<1, 1>>>(); } } INSTANTIATE_LAYER_GPU_FUNCS(CuDNNConvolutionLayer); } // namespace caffe #endif
78a6ebe3e0e2891325bfc7eada7fc185042f5198.hip
// !!! This is a file automatically generated by hipify!!! #include <cstdlib> #include <stdio.h> #include <iostream> #include <cmath> #include <hip/hip_runtime.h> #include <hiprand/hiprand.h> #include <hiprand/hiprand_kernel.h> #include <iomanip> #include <vector> #include "asset.h" #include "second.h" #define BLOCKSIZE 128 using namespace std; #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(hipError_t code, const char *file, int line, bool abort=true) { if (code != hipSuccess) { fprintf(stderr,"GPUassert: %s %s %d\n", hipGetErrorString(code), file, line); if (abort) exit(code); } } static __global__ void adjoint_method_correlation_GPU( double* d_ST_max, double* d_ST_del, double* d_ST_veg, int* d_ST_aid, double* d_assets, double* d_chlsky, int num_sims, int num_steps, int num_assets, double dt, double r, double K ) { int tid = blockDim.x * blockIdx.x + threadIdx.x; if (tid < num_sims) { double assets[18]; // 3 * 6 double chlsky[9]; // 3 * 3 double2 Z_indp[3]; double Z_corr[3]; int winning_asset; double ST_max, ST_del, ST_veg; double x_8, x_7, x_6, x_5, x_4, x_3, x_2, x_1; double x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23[3], x24[3]; double _x24, _x22, _x21, _x19, _x15, _x9, _x0; double _x23, _x17, _x16, _x13, _x11, _x8, _x5v, _x0v; double _x_1[3], _x_2[3], _x_2v[3]; double Zs, Zv; double payoff; // fetch asset and chlsky data for (int i=0; i<18; i++) { assets[i] = d_assets[i]; } for (int i=0; i<9; i++) { chlsky[i] = d_chlsky[i]; } // done fetching // random number generator and state curandStatePhilox4_32_10 rng_state; hiprand_init(1234, tid, 0, &rng_state); winning_asset = 0; ST_max = ST_del = ST_veg = 0.0; for (int a=0; a<num_assets; a++) { x23[a] = assets[1*num_assets+a]; // vega x24[a] = assets[0*num_assets+a]; // asset // init sensitivity vector _x_1[a] = 1.0; _x_2[a] = 0.0; _x_2v[a] = 1.0; } for (int t=0; t<num_steps; t++) { // generate correlated rngs for (int a=0; a<num_assets; a++) { Z_indp[a] = hiprand_normal2_double(&rng_state); Z_corr[a] = 0.0; } for (int row=0; row<num_assets; row++) for (int c=0; c<num_assets; c++) { Z_corr[row] += chlsky[num_assets*row+c] * Z_indp[c].x; } for (int a=0; a<num_assets; a++) { // init input parameters x_8 = assets[2*num_assets+a]; // rho x_7 = assets[3*num_assets+a]; // kappa x_6 = assets[4*num_assets+a]; // theta x_5 = assets[5*num_assets+a]; // sigma x_4 = dt; x_3 = r; x_2 = x23[a]; x_1 = x24[a]; Zs = Z_corr[a]; Zv = x_8 * Zs + sqrt(1-x_8*x_8) * Z_indp[a].y; // forward pass x0 = x_2 * x_4; x1 = x_3 * x_4; x2 = x_6 * x_4; x3 = x_5 * x_5; x4 = Zv * Zv; x5 = sqrt(x0); x6 = x3 * x_4; x7 = x_7 * x2; x8 = x_7 * x0; x9 = -0.5 * x0; x10 = x4 - 1; x11 = x_5 * x5; x12 = Zs * x5; x13 = x_2 + x7; x14 = 0.25 * x10; x15 = x9 + x12; x16 = Zv * x11; x17 = x13 - x8; x18 = x14 * x6; x19 = x1 + x15; x20 = x17 + x16; x21 = x20 + x18; x22 = exp(x19); x23[a] = max(x21, 0.0); x24[a] = x_1 * x22; // adjoint pass // asset adjoints _x24 = 1; _x22 = x_1 * _x24; _x19 = x22 * _x22; _x15 = _x19; _x9 = _x15; _x0 = -0.5 * _x9; // volatility adjoints _x23 = 1.0; _x21 = (x23[a] > 0.0) ? _x23 : 0.0; _x13 = _x16 = _x17 = _x21; _x11 = Zv * _x16; _x8 = -1 * _x17; _x5v = x_5 * _x11; _x0v = (0.5 * _x5v / x5) + _x8*x_7; // xbar inputs _x_1[a] = (_x24*x22) * _x_1[a]; _x_2[a] = _x_2[a]*x22 - (_x0*x_4) * _x_2v[a] * (-1 + Zs / x5); _x_2v[a] = _x_2v[a] * (_x13 + _x0v*x_4); } } for (int a=0; a<num_assets; a++) { payoff = max(x24[a]-K, 0.0); if (payoff > ST_max) { winning_asset = a; ST_max = payoff; ST_del = _x_1[a]; ST_veg = _x_2[a]; } } d_ST_max[tid] = ST_max; d_ST_del[tid] = ST_del; d_ST_veg[tid] = ST_veg; d_ST_aid[tid] = winning_asset; } // end if (tid < num_sims) } int main(int argc, char **argv) { int num_sims, num_steps, num_assets; double overhead, start, duration, dt, r, K, T, price, delta[3], vega[3]; num_sims = strtod(argv[1], NULL); num_steps = strtod(argv[2], NULL); cin >> num_assets; dim3 dimBlock(BLOCKSIZE, 1, 1); dim3 dimGrid(ceil( ((double)num_sims)/BLOCKSIZE ), 1, 1); int ST_bytes = num_sims * sizeof(double); int aid_bytes = num_sims * sizeof(int); int assets_bytes = num_assets * 6 * sizeof(double); int chlsky_bytes = num_assets * num_assets * sizeof(double); // allocate memory for gpu and host double* h_ST_max = (double*) malloc(ST_bytes); double* h_ST_del = (double*) malloc(ST_bytes); double* h_ST_veg = (double*) malloc(ST_bytes); int* h_ST_aid = (int*) malloc(aid_bytes); double* d_ST_max = (double*) malloc(ST_bytes); double* d_ST_del = (double*) malloc(ST_bytes); double* d_ST_veg = (double*) malloc(ST_bytes); int* d_ST_aid = (int*) malloc(aid_bytes); // double* h_assets = (double*) malloc(assets_bytes); double* h_chlsky = (double*) malloc(chlsky_bytes); double* d_assets = (double*) malloc(assets_bytes); double* d_chlsky = (double*) malloc(chlsky_bytes); // gpuErrchk( hipMalloc((void**) &d_ST_max, ST_bytes) ); gpuErrchk( hipMalloc((void**) &d_ST_del, ST_bytes) ); gpuErrchk( hipMalloc((void**) &d_ST_veg, ST_bytes) ); gpuErrchk( hipMalloc((void**) &d_ST_aid, aid_bytes) ); gpuErrchk( hipMalloc((void**) &d_assets, assets_bytes) ); gpuErrchk( hipMalloc((void**) &d_chlsky, chlsky_bytes) ); // read asset parameters for (int i=0; i<num_assets; i++) { asset a; cin >> a.S >> a.V >> a.r >> a.T >> a.kappa >> a.theta >> a.sigma >> a.rho >> a.K; // these two are constant between assets (i'm being lazy here by re-assigning) T = a.T; dt = T / num_steps; r = a.r; K = a.K; // h_assets[0*num_assets+i] = a.S; h_assets[1*num_assets+i] = a.V; h_assets[2*num_assets+i] = a.rho; h_assets[3*num_assets+i] = a.kappa; h_assets[4*num_assets+i] = a.theta; h_assets[5*num_assets+i] = a.sigma; } // read lower cholesky decomposed matrix for (int i=0; i<num_assets; i++) { for (int j=0; j<num_assets; j++) { cin >> h_chlsky[num_assets*i+j]; } } overhead = second()-second(); // overhead of timing method start = second(); // copy data across gpuErrchk( hipDeviceSetSharedMemConfig(hipSharedMemBankSizeEightByte) ); gpuErrchk( hipMemcpy(d_assets, h_assets, assets_bytes, hipMemcpyHostToDevice) ); gpuErrchk( hipMemcpy(d_chlsky, h_chlsky, chlsky_bytes, hipMemcpyHostToDevice) ); hipLaunchKernelGGL(( adjoint_method_correlation_GPU), dim3(dimGrid), dim3(dimBlock), 0, 0, d_ST_max, d_ST_del, d_ST_veg, d_ST_aid, d_assets, d_chlsky, num_sims, num_steps, num_assets, dt, r, K ); gpuErrchk( hipDeviceSynchronize() ); gpuErrchk( hipPeekAtLastError() ); gpuErrchk( hipMemcpy(h_ST_max, d_ST_max, ST_bytes, hipMemcpyDeviceToHost) ); gpuErrchk( hipMemcpy(h_ST_del, d_ST_del, ST_bytes, hipMemcpyDeviceToHost) ); gpuErrchk( hipMemcpy(h_ST_veg, d_ST_veg, ST_bytes, hipMemcpyDeviceToHost) ); gpuErrchk( hipMemcpy(h_ST_aid, d_ST_aid, aid_bytes, hipMemcpyDeviceToHost) ); for (int i=0; i<num_sims; i++) { price += h_ST_max[i]; delta[(int)h_ST_aid[i]] += h_ST_del[i]; vega[(int)h_ST_aid[i]] += h_ST_veg[i]; } double disc_fac = exp(-r*T); price = disc_fac * price / num_sims; printf("--------------------------------------\n"); printf("Heston 3 assets rainbow call on max\n"); printf("price 0: %0.15g\n", price); for (int i=0; i<num_assets; i++) { printf("delta %d: %0.15g\n", i, disc_fac * delta[i] / num_sims); printf("vega %d: %0.15g\n", i, disc_fac * vega[i] / num_sims); } duration = second()-start-overhead; printf("======================================\n"); printf("duration: %0.15g\n", duration); printf("======================================\n"); return 0; }
78a6ebe3e0e2891325bfc7eada7fc185042f5198.cu
#include <cstdlib> #include <stdio.h> #include <iostream> #include <cmath> #include <cuda_runtime.h> #include <curand.h> #include <curand_kernel.h> #include <iomanip> #include <vector> #include "asset.h" #include "second.h" #define BLOCKSIZE 128 using namespace std; #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true) { if (code != cudaSuccess) { fprintf(stderr,"GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line); if (abort) exit(code); } } static __global__ void adjoint_method_correlation_GPU( double* d_ST_max, double* d_ST_del, double* d_ST_veg, int* d_ST_aid, double* d_assets, double* d_chlsky, int num_sims, int num_steps, int num_assets, double dt, double r, double K ) { int tid = blockDim.x * blockIdx.x + threadIdx.x; if (tid < num_sims) { double assets[18]; // 3 * 6 double chlsky[9]; // 3 * 3 double2 Z_indp[3]; double Z_corr[3]; int winning_asset; double ST_max, ST_del, ST_veg; double x_8, x_7, x_6, x_5, x_4, x_3, x_2, x_1; double x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23[3], x24[3]; double _x24, _x22, _x21, _x19, _x15, _x9, _x0; double _x23, _x17, _x16, _x13, _x11, _x8, _x5v, _x0v; double _x_1[3], _x_2[3], _x_2v[3]; double Zs, Zv; double payoff; // fetch asset and chlsky data for (int i=0; i<18; i++) { assets[i] = d_assets[i]; } for (int i=0; i<9; i++) { chlsky[i] = d_chlsky[i]; } // done fetching // random number generator and state curandStatePhilox4_32_10 rng_state; curand_init(1234, tid, 0, &rng_state); winning_asset = 0; ST_max = ST_del = ST_veg = 0.0; for (int a=0; a<num_assets; a++) { x23[a] = assets[1*num_assets+a]; // vega x24[a] = assets[0*num_assets+a]; // asset // init sensitivity vector _x_1[a] = 1.0; _x_2[a] = 0.0; _x_2v[a] = 1.0; } for (int t=0; t<num_steps; t++) { // generate correlated rngs for (int a=0; a<num_assets; a++) { Z_indp[a] = curand_normal2_double(&rng_state); Z_corr[a] = 0.0; } for (int row=0; row<num_assets; row++) for (int c=0; c<num_assets; c++) { Z_corr[row] += chlsky[num_assets*row+c] * Z_indp[c].x; } for (int a=0; a<num_assets; a++) { // init input parameters x_8 = assets[2*num_assets+a]; // rho x_7 = assets[3*num_assets+a]; // kappa x_6 = assets[4*num_assets+a]; // theta x_5 = assets[5*num_assets+a]; // sigma x_4 = dt; x_3 = r; x_2 = x23[a]; x_1 = x24[a]; Zs = Z_corr[a]; Zv = x_8 * Zs + sqrt(1-x_8*x_8) * Z_indp[a].y; // forward pass x0 = x_2 * x_4; x1 = x_3 * x_4; x2 = x_6 * x_4; x3 = x_5 * x_5; x4 = Zv * Zv; x5 = sqrt(x0); x6 = x3 * x_4; x7 = x_7 * x2; x8 = x_7 * x0; x9 = -0.5 * x0; x10 = x4 - 1; x11 = x_5 * x5; x12 = Zs * x5; x13 = x_2 + x7; x14 = 0.25 * x10; x15 = x9 + x12; x16 = Zv * x11; x17 = x13 - x8; x18 = x14 * x6; x19 = x1 + x15; x20 = x17 + x16; x21 = x20 + x18; x22 = exp(x19); x23[a] = max(x21, 0.0); x24[a] = x_1 * x22; // adjoint pass // asset adjoints _x24 = 1; _x22 = x_1 * _x24; _x19 = x22 * _x22; _x15 = _x19; _x9 = _x15; _x0 = -0.5 * _x9; // volatility adjoints _x23 = 1.0; _x21 = (x23[a] > 0.0) ? _x23 : 0.0; _x13 = _x16 = _x17 = _x21; _x11 = Zv * _x16; _x8 = -1 * _x17; _x5v = x_5 * _x11; _x0v = (0.5 * _x5v / x5) + _x8*x_7; // xbar inputs _x_1[a] = (_x24*x22) * _x_1[a]; _x_2[a] = _x_2[a]*x22 - (_x0*x_4) * _x_2v[a] * (-1 + Zs / x5); _x_2v[a] = _x_2v[a] * (_x13 + _x0v*x_4); } } for (int a=0; a<num_assets; a++) { payoff = max(x24[a]-K, 0.0); if (payoff > ST_max) { winning_asset = a; ST_max = payoff; ST_del = _x_1[a]; ST_veg = _x_2[a]; } } d_ST_max[tid] = ST_max; d_ST_del[tid] = ST_del; d_ST_veg[tid] = ST_veg; d_ST_aid[tid] = winning_asset; } // end if (tid < num_sims) } int main(int argc, char **argv) { int num_sims, num_steps, num_assets; double overhead, start, duration, dt, r, K, T, price, delta[3], vega[3]; num_sims = strtod(argv[1], NULL); num_steps = strtod(argv[2], NULL); cin >> num_assets; dim3 dimBlock(BLOCKSIZE, 1, 1); dim3 dimGrid(ceil( ((double)num_sims)/BLOCKSIZE ), 1, 1); int ST_bytes = num_sims * sizeof(double); int aid_bytes = num_sims * sizeof(int); int assets_bytes = num_assets * 6 * sizeof(double); int chlsky_bytes = num_assets * num_assets * sizeof(double); // allocate memory for gpu and host double* h_ST_max = (double*) malloc(ST_bytes); double* h_ST_del = (double*) malloc(ST_bytes); double* h_ST_veg = (double*) malloc(ST_bytes); int* h_ST_aid = (int*) malloc(aid_bytes); double* d_ST_max = (double*) malloc(ST_bytes); double* d_ST_del = (double*) malloc(ST_bytes); double* d_ST_veg = (double*) malloc(ST_bytes); int* d_ST_aid = (int*) malloc(aid_bytes); // double* h_assets = (double*) malloc(assets_bytes); double* h_chlsky = (double*) malloc(chlsky_bytes); double* d_assets = (double*) malloc(assets_bytes); double* d_chlsky = (double*) malloc(chlsky_bytes); // gpuErrchk( cudaMalloc((void**) &d_ST_max, ST_bytes) ); gpuErrchk( cudaMalloc((void**) &d_ST_del, ST_bytes) ); gpuErrchk( cudaMalloc((void**) &d_ST_veg, ST_bytes) ); gpuErrchk( cudaMalloc((void**) &d_ST_aid, aid_bytes) ); gpuErrchk( cudaMalloc((void**) &d_assets, assets_bytes) ); gpuErrchk( cudaMalloc((void**) &d_chlsky, chlsky_bytes) ); // read asset parameters for (int i=0; i<num_assets; i++) { asset a; cin >> a.S >> a.V >> a.r >> a.T >> a.kappa >> a.theta >> a.sigma >> a.rho >> a.K; // these two are constant between assets (i'm being lazy here by re-assigning) T = a.T; dt = T / num_steps; r = a.r; K = a.K; // h_assets[0*num_assets+i] = a.S; h_assets[1*num_assets+i] = a.V; h_assets[2*num_assets+i] = a.rho; h_assets[3*num_assets+i] = a.kappa; h_assets[4*num_assets+i] = a.theta; h_assets[5*num_assets+i] = a.sigma; } // read lower cholesky decomposed matrix for (int i=0; i<num_assets; i++) { for (int j=0; j<num_assets; j++) { cin >> h_chlsky[num_assets*i+j]; } } overhead = second()-second(); // overhead of timing method start = second(); // copy data across gpuErrchk( cudaDeviceSetSharedMemConfig(cudaSharedMemBankSizeEightByte) ); gpuErrchk( cudaMemcpy(d_assets, h_assets, assets_bytes, cudaMemcpyHostToDevice) ); gpuErrchk( cudaMemcpy(d_chlsky, h_chlsky, chlsky_bytes, cudaMemcpyHostToDevice) ); adjoint_method_correlation_GPU<<<dimGrid, dimBlock>>>( d_ST_max, d_ST_del, d_ST_veg, d_ST_aid, d_assets, d_chlsky, num_sims, num_steps, num_assets, dt, r, K ); gpuErrchk( cudaDeviceSynchronize() ); gpuErrchk( cudaPeekAtLastError() ); gpuErrchk( cudaMemcpy(h_ST_max, d_ST_max, ST_bytes, cudaMemcpyDeviceToHost) ); gpuErrchk( cudaMemcpy(h_ST_del, d_ST_del, ST_bytes, cudaMemcpyDeviceToHost) ); gpuErrchk( cudaMemcpy(h_ST_veg, d_ST_veg, ST_bytes, cudaMemcpyDeviceToHost) ); gpuErrchk( cudaMemcpy(h_ST_aid, d_ST_aid, aid_bytes, cudaMemcpyDeviceToHost) ); for (int i=0; i<num_sims; i++) { price += h_ST_max[i]; delta[(int)h_ST_aid[i]] += h_ST_del[i]; vega[(int)h_ST_aid[i]] += h_ST_veg[i]; } double disc_fac = exp(-r*T); price = disc_fac * price / num_sims; printf("--------------------------------------\n"); printf("Heston 3 assets rainbow call on max\n"); printf("price 0: %0.15g\n", price); for (int i=0; i<num_assets; i++) { printf("delta %d: %0.15g\n", i, disc_fac * delta[i] / num_sims); printf("vega %d: %0.15g\n", i, disc_fac * vega[i] / num_sims); } duration = second()-start-overhead; printf("======================================\n"); printf("duration: %0.15g\n", duration); printf("======================================\n"); return 0; }
492455558ef92abd04de7cb213bba097d8a3e8fd.hip
// !!! This is a file automatically generated by hipify!!! #include "THHTensorMath.h" #include "THHGeneral.h" #include "THHBlas.h" #include "THHTensorCopy.h" #include "THHTensorRandom.h" #include "THHApply.cuh" #include "THHReduce.cuh" #include <thrust/device_ptr.h> #include <thrust/fill.h> #include <thrust/functional.h> #include <thrust/reduce.h> #include <thrust/inner_product.h> #ifndef DIVUP #define DIVUP(x, y) (((x) + (y) - 1) / (y)) #endif struct TensorMaskedFillOp { TensorMaskedFillOp(float v) : value(v) {} __device__ __forceinline__ void operator()(float* t, float* mask) { // Really mask should be `0` or `1` but we can't propagate errors here. const float maskVal = *mask; if (maskVal != 0.0f) { *t = value; } } float value; }; void THCudaTensor_maskedFill(THCState* state, THCudaTensor *tensor, THCudaTensor *mask, float value) { THAssert(THCudaTensor_checkGPU(state, 2, tensor, mask)); THArgCheck(THCudaTensor_nElement(state, tensor) == THCudaTensor_nElement(state, mask), 2, "sizes do not match"); if (!THCudaTensor_pointwiseApply2(state, tensor, mask, TensorMaskedFillOp(value))) { THArgCheck(false, 2, CUTORCH_DIM_WARNING); } THCudaCheck(hipGetLastError()); } void THCudaTensor_maskedCopy(THCState* state, THCudaTensor *tensor, THCudaTensor *mask, THCudaTensor *src) { THError("maskedCopy is not yet implemented for CUDA"); THAssert(THCudaTensor_checkGPU(state, 3, tensor, mask, src)); } struct TensorMaskedSelectOp { TensorMaskedSelectOp(float* t) : out(t) {} __device__ __forceinline__ void operator()(float* mask, float* maskPrefixSum, float* in) { // Really mask should be `0` or `1` but we can't propagate errors here. if (*mask != 0.0f) { out[(int) *maskPrefixSum] = *in; } } float* out; }; void THCudaTensor_maskedSelect(THCState* state, THCudaTensor *tensor, THCudaTensor *src, THCudaTensor *mask) { THAssert(THCudaTensor_checkGPU(state, 3, tensor, src, mask)); THArgCheck(THCudaTensor_nElement(state, mask) == THCudaTensor_nElement(state, src), 2, "sizes do not match"); // Determine our output size THCudaTensor* contigMask = THCudaTensor_newContiguous(state, mask); int totalElements = (int) THCudaTensor_sumall(state, contigMask); THCudaTensor_resize1d(state, tensor, totalElements); // Use a prefix sum to determine the output locations of the masked elements THCudaTensor* maskPrefixSum = THCudaTensor_new(state); THCudaTensor_resizeAs(state, maskPrefixSum, mask); thrust::device_ptr<float> maskData(THCudaTensor_data(state, contigMask)); thrust::device_ptr<float> maskPrefixSumData(THCudaTensor_data(state, maskPrefixSum)); thrust::exclusive_scan(maskData, maskData + THCudaTensor_nElement(state, contigMask), maskPrefixSumData); // Then copy over the masked elements at their desired output index bool status = THCudaTensor_pointwiseApply3( state, contigMask, maskPrefixSum, src, TensorMaskedSelectOp(THCudaTensor_data(state, tensor))); THCudaTensor_free(state, contigMask); THCudaTensor_free(state, maskPrefixSum); if (!status) { THArgCheck(false, 2, CUTORCH_DIM_WARNING); } THCudaCheck(hipGetLastError()); } void THCudaTensor_maskedFillByte(THCState* state, THCudaTensor *tensor, THByteTensor *mask, float value) { THAssert(THCudaTensor_checkGPU(state, 1, tensor)); THLongStorage* maskSize = THByteTensor_newSizeOf(mask); THCudaTensor* maskCuda = THCudaTensor_newWithSize(state, maskSize, NULL); THLongStorage_free(maskSize); THCudaTensor_copyByte(state, maskCuda, mask); THCudaTensor_maskedFill(state, tensor, maskCuda, value); THCudaTensor_free(state, maskCuda); } void THCudaTensor_maskedCopyByte(THCState* state, THCudaTensor *tensor, THByteTensor *mask, THCudaTensor *src) { THError("maskedCopyByte is not yet implemented for CUDA"); THAssert(THCudaTensor_checkGPU(state, 1, tensor)); } void THCudaTensor_maskedSelectByte(THCState* state, THCudaTensor *tensor, THCudaTensor *src, THByteTensor *mask) { THAssert(THCudaTensor_checkGPU(state, 2, tensor, src)); THLongStorage* maskSize = THByteTensor_newSizeOf(mask); THCudaTensor* maskCuda = THCudaTensor_newWithSize(state, maskSize, NULL); THLongStorage_free(maskSize); THCudaTensor_copyByte(state, maskCuda, mask); THCudaTensor_maskedSelect(state, tensor, src, maskCuda); THCudaTensor_free(state, maskCuda); }
492455558ef92abd04de7cb213bba097d8a3e8fd.cu
#include "THCTensorMath.h" #include "THCGeneral.h" #include "THCBlas.h" #include "THCTensorCopy.h" #include "THCTensorRandom.h" #include "THCApply.cuh" #include "THCReduce.cuh" #include <thrust/device_ptr.h> #include <thrust/fill.h> #include <thrust/functional.h> #include <thrust/reduce.h> #include <thrust/inner_product.h> #ifndef DIVUP #define DIVUP(x, y) (((x) + (y) - 1) / (y)) #endif struct TensorMaskedFillOp { TensorMaskedFillOp(float v) : value(v) {} __device__ __forceinline__ void operator()(float* t, float* mask) { // Really mask should be `0` or `1` but we can't propagate errors here. const float maskVal = *mask; if (maskVal != 0.0f) { *t = value; } } float value; }; void THCudaTensor_maskedFill(THCState* state, THCudaTensor *tensor, THCudaTensor *mask, float value) { THAssert(THCudaTensor_checkGPU(state, 2, tensor, mask)); THArgCheck(THCudaTensor_nElement(state, tensor) == THCudaTensor_nElement(state, mask), 2, "sizes do not match"); if (!THCudaTensor_pointwiseApply2(state, tensor, mask, TensorMaskedFillOp(value))) { THArgCheck(false, 2, CUTORCH_DIM_WARNING); } THCudaCheck(cudaGetLastError()); } void THCudaTensor_maskedCopy(THCState* state, THCudaTensor *tensor, THCudaTensor *mask, THCudaTensor *src) { THError("maskedCopy is not yet implemented for CUDA"); THAssert(THCudaTensor_checkGPU(state, 3, tensor, mask, src)); } struct TensorMaskedSelectOp { TensorMaskedSelectOp(float* t) : out(t) {} __device__ __forceinline__ void operator()(float* mask, float* maskPrefixSum, float* in) { // Really mask should be `0` or `1` but we can't propagate errors here. if (*mask != 0.0f) { out[(int) *maskPrefixSum] = *in; } } float* out; }; void THCudaTensor_maskedSelect(THCState* state, THCudaTensor *tensor, THCudaTensor *src, THCudaTensor *mask) { THAssert(THCudaTensor_checkGPU(state, 3, tensor, src, mask)); THArgCheck(THCudaTensor_nElement(state, mask) == THCudaTensor_nElement(state, src), 2, "sizes do not match"); // Determine our output size THCudaTensor* contigMask = THCudaTensor_newContiguous(state, mask); int totalElements = (int) THCudaTensor_sumall(state, contigMask); THCudaTensor_resize1d(state, tensor, totalElements); // Use a prefix sum to determine the output locations of the masked elements THCudaTensor* maskPrefixSum = THCudaTensor_new(state); THCudaTensor_resizeAs(state, maskPrefixSum, mask); thrust::device_ptr<float> maskData(THCudaTensor_data(state, contigMask)); thrust::device_ptr<float> maskPrefixSumData(THCudaTensor_data(state, maskPrefixSum)); thrust::exclusive_scan(maskData, maskData + THCudaTensor_nElement(state, contigMask), maskPrefixSumData); // Then copy over the masked elements at their desired output index bool status = THCudaTensor_pointwiseApply3( state, contigMask, maskPrefixSum, src, TensorMaskedSelectOp(THCudaTensor_data(state, tensor))); THCudaTensor_free(state, contigMask); THCudaTensor_free(state, maskPrefixSum); if (!status) { THArgCheck(false, 2, CUTORCH_DIM_WARNING); } THCudaCheck(cudaGetLastError()); } void THCudaTensor_maskedFillByte(THCState* state, THCudaTensor *tensor, THByteTensor *mask, float value) { THAssert(THCudaTensor_checkGPU(state, 1, tensor)); THLongStorage* maskSize = THByteTensor_newSizeOf(mask); THCudaTensor* maskCuda = THCudaTensor_newWithSize(state, maskSize, NULL); THLongStorage_free(maskSize); THCudaTensor_copyByte(state, maskCuda, mask); THCudaTensor_maskedFill(state, tensor, maskCuda, value); THCudaTensor_free(state, maskCuda); } void THCudaTensor_maskedCopyByte(THCState* state, THCudaTensor *tensor, THByteTensor *mask, THCudaTensor *src) { THError("maskedCopyByte is not yet implemented for CUDA"); THAssert(THCudaTensor_checkGPU(state, 1, tensor)); } void THCudaTensor_maskedSelectByte(THCState* state, THCudaTensor *tensor, THCudaTensor *src, THByteTensor *mask) { THAssert(THCudaTensor_checkGPU(state, 2, tensor, src)); THLongStorage* maskSize = THByteTensor_newSizeOf(mask); THCudaTensor* maskCuda = THCudaTensor_newWithSize(state, maskSize, NULL); THLongStorage_free(maskSize); THCudaTensor_copyByte(state, maskCuda, mask); THCudaTensor_maskedSelect(state, tensor, src, maskCuda); THCudaTensor_free(state, maskCuda); }
04ee8ada71bad9f39a873ebd3337b5a7eb7c934e.hip
// !!! This is a file automatically generated by hipify!!! #include <iomanip> #include <iostream> #include <vector> #include <Host/Basic.hpp>//xlib::byte_t #include <Host/PrintExt.hpp>//xlib::char_sequence and xlib::human_readable #include <Device/Util/Timer.cuh>//timer::Timer #include <StandardAPI.hpp> using namespace hornets_nest; using timer_duration_t = float;//return type of timer::Timer::duration() int exec() { #if defined(RMM_WRAPPER) constexpr size_t repeat_cnt = 10; size_t min_size = 1024;//1KB size_t round = 0; std::vector<timer_duration_t> v_alloc_time_host_cpp;//new and delete std::vector<timer_duration_t> v_alloc_time_host_cuda;//hipHostMalloc and hipHostFree std::vector<timer_duration_t> v_alloc_time_device_cuda;//hipMalloc and hipFree std::vector<timer_duration_t> v_alloc_time_device_rmm;//RMM_ALLOC and RMM_FREE timer::Timer<timer::DEVICE,timer::milli> my_timer; std::cout << "Computing (repeat count=" << repeat_cnt << ", RMM alloc mode=pool)" << std::endl; while (true) { size_t size = min_size << round; bool success = true; std::cout << "." << std::flush; { my_timer.start(); for (std::size_t i = 0; i < repeat_cnt; i++) { std::unique_ptr<xlib::byte_t[]> h_p_cpp(new (std::nothrow) xlib::byte_t[size]);//no initialization, should not use std::make_unique here as this enforces initialization and is slower. if (h_p_cpp == nullptr) { std::cout << std::endl; std::cout << "new failed (size=" << xlib::human_readable(size) << "), this is normal if the size exceeds available host memory." << std::endl; success = false; break; } } my_timer.stop(); v_alloc_time_host_cpp.push_back(my_timer.duration()); } if (success == true ) { my_timer.start(); for (std::size_t i = 0; i < repeat_cnt; i++) { auto my_new = [](const size_t size) { xlib::byte_t* h_p_cuda; auto result = hipHostMalloc(&h_p_cuda, size); if (result == hipSuccess) { return static_cast<xlib::byte_t*>(h_p_cuda); } else { return static_cast<xlib::byte_t*>(nullptr); } }; auto my_del = [](xlib::byte_t* h_p_cuda) { SAFE_CALL(hipHostFree(h_p_cuda)); }; std::unique_ptr<xlib::byte_t[], decltype(my_del)> h_p_cuda(my_new(size), my_del); if (h_p_cuda == nullptr) { std::cout << std::endl; std::cout << "hipHostMalloc failed (size=" << xlib::human_readable(size) << "), this is normal if the size exceeds available host memory (that can be page-locked)." << std::endl; success = false; break; } } my_timer.stop(); v_alloc_time_host_cuda.push_back(my_timer.duration()); } if (success == true ) { my_timer.start(); for (std::size_t i = 0; i < repeat_cnt; i++) { auto my_new = [](const size_t size) { xlib::byte_t* d_p_cuda; auto result = hipMalloc(&d_p_cuda, size); if (result == hipSuccess) { return static_cast<xlib::byte_t*>(d_p_cuda); } else { return static_cast<xlib::byte_t*>(nullptr); } }; auto my_del = [](xlib::byte_t* d_p_cuda) { SAFE_CALL(hipFree(d_p_cuda)); }; std::unique_ptr<xlib::byte_t[], decltype(my_del)> d_p_cuda(my_new(size), my_del); if (d_p_cuda == nullptr) { std::cout << std::endl; std::cout << "hipMalloc failed (size=" << xlib::human_readable(size) << "), this is normal if the size exceeds available device memory." << std::endl; success = false; break; } } my_timer.stop(); v_alloc_time_device_cuda.push_back(my_timer.duration()); } if (success == true ) { my_timer.start(); for (std::size_t i = 0; i < repeat_cnt; i++) { auto my_new = [](const size_t size) { xlib::byte_t* d_p_rmm; auto result = RMM_ALLOC(&d_p_rmm, size, 0);/* by default, use the default stream, RMM_ALLOC instead of gpu::allocate to test return value, gpu::allocate calls std::exit on error */ if (result == RMM_SUCCESS) { return static_cast<xlib::byte_t*>(d_p_rmm); } else { return static_cast<xlib::byte_t*>(nullptr); } }; auto my_del = [](xlib::byte_t* d_p_rmm) { gpu::free(d_p_rmm); }; std::unique_ptr<xlib::byte_t[], decltype(my_del)> d_p_rmm(my_new(size), my_del); if (d_p_rmm == nullptr) { std::cout << std::endl; std::cout << "RMM_ALLOC failed (size=" << xlib::human_readable(size) << "), this is normal if the size exceeds available device memory (accessible to RMM)." << std::endl; success = false; break; } } my_timer.stop(); v_alloc_time_device_rmm.push_back(my_timer.duration()); } if (success == true ) { round++; } else { v_alloc_time_host_cpp.resize(round); v_alloc_time_host_cuda.resize(round); v_alloc_time_device_cuda.resize(round); v_alloc_time_device_rmm.resize(round); break; } } std::cout << "RESULT:" << std::endl; std::cout << std::setprecision(2) << std::right << std::fixed << std::setw(8) << "SIZE" << std::setw(16) << "malloc" << std::setw(16) << "hipHostMalloc" << std::setw(16) << "hipMalloc" << std::setw(16) << "rmmAlloc" << std::endl; xlib::char_sequence('-', 80); for (size_t i = 0; i < round; i++) { std::cout << std::setw(8) << xlib::human_readable(min_size << i) << std::setw(16) << v_alloc_time_host_cpp[i] << std::setw(16) << v_alloc_time_host_cuda[i] << std::setw(16) << v_alloc_time_device_cuda[i] << std::setw(16) << v_alloc_time_device_rmm[i] << std::endl; } std::cout << "* unit: ms, measured time includes both memory allocation and deallocation." << std::endl; #else std::cout << "RMM_WRAPPER should be defined to benchmark RMM." << std::endl; #endif return 0; } int main() { int ret = 0; #if defined(RMM_WRAPPER) gpu::initializeRMMPoolAllocation();//update initPoolSize if you know your memory requirement and memory availability in your system, if initial pool size is set to 0 (default value), RMM currently assigns half the device memory. {//scoping technique to make sure that gpu::finalizeRMMPoolAllocation is called after freeing all RMM allocations. #endif ret = exec(); #if defined(RMM_WRAPPER) }//scoping technique to make sure that gpu::finalizeRMMPoolAllocation is called after freeing all RMM allocations. gpu::finalizeRMMPoolAllocation(); #endif return ret; }
04ee8ada71bad9f39a873ebd3337b5a7eb7c934e.cu
#include <iomanip> #include <iostream> #include <vector> #include <Host/Basic.hpp>//xlib::byte_t #include <Host/PrintExt.hpp>//xlib::char_sequence and xlib::human_readable #include <Device/Util/Timer.cuh>//timer::Timer #include <StandardAPI.hpp> using namespace hornets_nest; using timer_duration_t = float;//return type of timer::Timer::duration() int exec() { #if defined(RMM_WRAPPER) constexpr size_t repeat_cnt = 10; size_t min_size = 1024;//1KB size_t round = 0; std::vector<timer_duration_t> v_alloc_time_host_cpp;//new and delete std::vector<timer_duration_t> v_alloc_time_host_cuda;//cudaMallocHost and cudaFreeHost std::vector<timer_duration_t> v_alloc_time_device_cuda;//cudaMalloc and cudaFree std::vector<timer_duration_t> v_alloc_time_device_rmm;//RMM_ALLOC and RMM_FREE timer::Timer<timer::DEVICE,timer::milli> my_timer; std::cout << "Computing (repeat count=" << repeat_cnt << ", RMM alloc mode=pool)" << std::endl; while (true) { size_t size = min_size << round; bool success = true; std::cout << "." << std::flush; { my_timer.start(); for (std::size_t i = 0; i < repeat_cnt; i++) { std::unique_ptr<xlib::byte_t[]> h_p_cpp(new (std::nothrow) xlib::byte_t[size]);//no initialization, should not use std::make_unique here as this enforces initialization and is slower. if (h_p_cpp == nullptr) { std::cout << std::endl; std::cout << "new failed (size=" << xlib::human_readable(size) << "), this is normal if the size exceeds available host memory." << std::endl; success = false; break; } } my_timer.stop(); v_alloc_time_host_cpp.push_back(my_timer.duration()); } if (success == true ) { my_timer.start(); for (std::size_t i = 0; i < repeat_cnt; i++) { auto my_new = [](const size_t size) { xlib::byte_t* h_p_cuda; auto result = cudaMallocHost(&h_p_cuda, size); if (result == cudaSuccess) { return static_cast<xlib::byte_t*>(h_p_cuda); } else { return static_cast<xlib::byte_t*>(nullptr); } }; auto my_del = [](xlib::byte_t* h_p_cuda) { SAFE_CALL(cudaFreeHost(h_p_cuda)); }; std::unique_ptr<xlib::byte_t[], decltype(my_del)> h_p_cuda(my_new(size), my_del); if (h_p_cuda == nullptr) { std::cout << std::endl; std::cout << "cudaMallocHost failed (size=" << xlib::human_readable(size) << "), this is normal if the size exceeds available host memory (that can be page-locked)." << std::endl; success = false; break; } } my_timer.stop(); v_alloc_time_host_cuda.push_back(my_timer.duration()); } if (success == true ) { my_timer.start(); for (std::size_t i = 0; i < repeat_cnt; i++) { auto my_new = [](const size_t size) { xlib::byte_t* d_p_cuda; auto result = cudaMalloc(&d_p_cuda, size); if (result == cudaSuccess) { return static_cast<xlib::byte_t*>(d_p_cuda); } else { return static_cast<xlib::byte_t*>(nullptr); } }; auto my_del = [](xlib::byte_t* d_p_cuda) { SAFE_CALL(cudaFree(d_p_cuda)); }; std::unique_ptr<xlib::byte_t[], decltype(my_del)> d_p_cuda(my_new(size), my_del); if (d_p_cuda == nullptr) { std::cout << std::endl; std::cout << "cudaMalloc failed (size=" << xlib::human_readable(size) << "), this is normal if the size exceeds available device memory." << std::endl; success = false; break; } } my_timer.stop(); v_alloc_time_device_cuda.push_back(my_timer.duration()); } if (success == true ) { my_timer.start(); for (std::size_t i = 0; i < repeat_cnt; i++) { auto my_new = [](const size_t size) { xlib::byte_t* d_p_rmm; auto result = RMM_ALLOC(&d_p_rmm, size, 0);/* by default, use the default stream, RMM_ALLOC instead of gpu::allocate to test return value, gpu::allocate calls std::exit on error */ if (result == RMM_SUCCESS) { return static_cast<xlib::byte_t*>(d_p_rmm); } else { return static_cast<xlib::byte_t*>(nullptr); } }; auto my_del = [](xlib::byte_t* d_p_rmm) { gpu::free(d_p_rmm); }; std::unique_ptr<xlib::byte_t[], decltype(my_del)> d_p_rmm(my_new(size), my_del); if (d_p_rmm == nullptr) { std::cout << std::endl; std::cout << "RMM_ALLOC failed (size=" << xlib::human_readable(size) << "), this is normal if the size exceeds available device memory (accessible to RMM)." << std::endl; success = false; break; } } my_timer.stop(); v_alloc_time_device_rmm.push_back(my_timer.duration()); } if (success == true ) { round++; } else { v_alloc_time_host_cpp.resize(round); v_alloc_time_host_cuda.resize(round); v_alloc_time_device_cuda.resize(round); v_alloc_time_device_rmm.resize(round); break; } } std::cout << "RESULT:" << std::endl; std::cout << std::setprecision(2) << std::right << std::fixed << std::setw(8) << "SIZE" << std::setw(16) << "malloc" << std::setw(16) << "cudaMallocHost" << std::setw(16) << "cudaMalloc" << std::setw(16) << "rmmAlloc" << std::endl; xlib::char_sequence('-', 80); for (size_t i = 0; i < round; i++) { std::cout << std::setw(8) << xlib::human_readable(min_size << i) << std::setw(16) << v_alloc_time_host_cpp[i] << std::setw(16) << v_alloc_time_host_cuda[i] << std::setw(16) << v_alloc_time_device_cuda[i] << std::setw(16) << v_alloc_time_device_rmm[i] << std::endl; } std::cout << "* unit: ms, measured time includes both memory allocation and deallocation." << std::endl; #else std::cout << "RMM_WRAPPER should be defined to benchmark RMM." << std::endl; #endif return 0; } int main() { int ret = 0; #if defined(RMM_WRAPPER) gpu::initializeRMMPoolAllocation();//update initPoolSize if you know your memory requirement and memory availability in your system, if initial pool size is set to 0 (default value), RMM currently assigns half the device memory. {//scoping technique to make sure that gpu::finalizeRMMPoolAllocation is called after freeing all RMM allocations. #endif ret = exec(); #if defined(RMM_WRAPPER) }//scoping technique to make sure that gpu::finalizeRMMPoolAllocation is called after freeing all RMM allocations. gpu::finalizeRMMPoolAllocation(); #endif return ret; }
6c7644fa5e3e475843108e09d0a50bca87a2686e.hip
// !!! This is a file automatically generated by hipify!!! /* Copyright (c) 2013 The University of Texas at Austin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA, or see <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>. Author: Mario Mendez-Lojo */ #include <algorithm> #include <fstream> #include <iostream> #include <iterator> #include <sstream> #include <vector> #include "andersen.h" //#include "mySVN/gzstream.h" // commented by, #define igzstream ifstream // added by, #include "andersen.cu" // added by Rupesh Nasre on Dec 27, 2012. using namespace std; // check that the obtained solution is a subset of the desired solution. Useful when trying to // detect bugs (for instance, detected the 1st iteration such that the inclusion does not hold) #define USE_INCLUSION (2) static uint transferH2dTime = 0; static uint transferD2hTime = 0; //static void printDeviceMemory() { //size_t uCurAvailMemoryInBytes, uTotalMemoryInBytes; //hipMemGetInfo( &uCurAvailMemoryInBytes, &uTotalMemoryInBytes ); //cout << "[host] GPU's total memory: "<< B2MB(uTotalMemoryInBytes) << " MB, free Memory: " // << B2MB(uCurAvailMemoryInBytes) << " MB" << endl; //if (B2MB(uCurAvailMemoryInBytes) < 3930) { // cout << "Warning: there is not enough memory in your GPU to analyze all inputs." << endl; //} //} static void printVector(const vector<uint>& m) { vector<uint>::size_type size = m.size(); cout << "["; if (size) { ostream_iterator<uint> out_it (cout,", "); std::copy(m.begin(), m.begin() + size - 1, out_it); cout << m[size - 1]; } cout << "]"; } static void printVector(uint* m, const uint size) { cout << "["; if (size) { ostream_iterator<uint> out_it (cout,", "); std::copy(m, m + size - 1, out_it); cout << m[size - 1]; } cout << "]"; } void printMatrix(uint* m, const uint rows, const uint cols) { printf("["); for (uint i = 0; i < rows; i++) { if (i > 0) { printf(" "); } printVector(&m[i * cols], cols); if (i < rows - 1) { printf("\n"); } } printf("]\n"); } void checkGPUConfiguration() { int deviceCount; hipGetDeviceCount(&deviceCount); if (deviceCount == 0) { cerr << "There is no device supporting CUDA\n" << endl; exit(-1); } hipDeviceProp_t deviceProp; hipGetDeviceProperties(&deviceProp, 0); if ((deviceProp.major == 9999) && (deviceProp.minor == 9999)) { cerr << "There is no CUDA capable device" << endl; exit(-1); } if ((WARP_SIZE != 32)) { cerr << "Warp size must be 32" << endl ; exit(-1); } // Make printf buffer bigger, otherwise some printf messages are not displayed size_t limit; hipDeviceGetLimit(&limit, hipLimitPrintfFifoSize); hipDeviceSetLimit(hipLimitPrintfFifoSize, limit * 16); // Make stack bigger, otherwise recursive functions will fail silently (?) //hipThreadGetLimit(&limit, hipLimitStackSize); //hipThreadSetLimit(hipLimitStackSize, limit * 8); } uint nextUint(istringstream& lineStream) { string item; getline(lineStream, item, ','); return atoi(item.c_str()); } string skipBlanksAndComments(igzstream& inFile){ string line; for (;;) { getline(inFile, line); if (!line.empty() && line[0] != '#') { return string(line); } } } uint readNumVars(igzstream &inFile) { string line = skipBlanksAndComments(inFile); istringstream linestream(line); return nextUint(linestream); } uint readNodes(char *fileName, uint& numVars, uint& numObjectVars) { cout << "[host] Reading nodes..." << flush; igzstream inFile(fileName, igzstream::in); if (!inFile) { fprintf(stderr, "Error: file %s not found.\n", fileName); exit(-1); } string line = skipBlanksAndComments(inFile); istringstream linestream(line); // read total number of variables numVars = roundToNextMultipleOf(nextUint(linestream), 32); // cout << "number of variables: " << numVars << endl; line = skipBlanksAndComments(inFile); istringstream linestream2(line); // for some reason, the number stored is lastObjectVar numObjectVars = nextUint(linestream2) + 1; // cout << " object variables: " << numObjectVars << endl; skipBlanksAndComments(inFile); // skip lastFunctionNode uint length = roundToNextMultipleOf(numObjectVars, 32); uint* size = new uint[length]; assert (size != NULL); for (uint i = 0; i < numObjectVars; i++) { line = skipBlanksAndComments(inFile); istringstream linestream(line); nextUint(linestream); // ignore var ID size[i] = nextUint(linestream); nextUint(linestream);// ignore functionNode crap } inFile.close(); for (uint i = numObjectVars; i < length; i++) { size[i] = 0; } const uint startTime = clock(); uint* sizeLocal; cudaSafeCall(hipMalloc((void **) &sizeLocal, length * uintSize)); cudaSafeCall(hipMemcpy(sizeLocal, size, length * uintSize, H2D)); cudaSafeCall(hipMemcpyToSymbol(__size__, &sizeLocal, sizeof(uint*))); cudaSafeCall(hipMemcpyToSymbol(__numVars__, &numVars, uintSize)); transferH2dTime += getEllapsedTime(startTime); cout << "OK." << endl << flush; return numObjectVars; } uint inline padNumber(uint num) { uint ret = roundToNextMultipleOf(num, 32); if (ret == num) { ret = roundToNextMultipleOf(num + 1, 32); } return ret; } uint* readConstraints(igzstream &inFile, uint rows) { uint length = padNumber(rows); uint* constraints = new uint[length * 2]; assert (constraints != NULL); for (uint i = 0; i < rows; i++) { string line = skipBlanksAndComments(inFile); istringstream linestream(line); nextUint(linestream); // ignore constraint ID uint src = nextUint(linestream); uint dst = nextUint(linestream); nextUint(linestream); // ignore type uint offset = nextUint(linestream); if (offset) { cerr << "Detected constraint with offset" << endl << flush; exit(-1); } constraints[i] = dst; constraints[i + length] = src; } // pad with NILs for (uint i = rows; i < length; i++) { constraints[i] = NIL; constraints[i + length] = NIL; } return constraints; } void readAndTransferConstraints(igzstream &inFile, uint numConstraints, uint* &constraintsName, uint &numConstraintsName) { uint* constraints = readConstraints(inFile, numConstraints); const uint startTime = clock(); uint* constraintLocal; uint paddedSize = padNumber(numConstraints); size_t size = paddedSize * uintSize * 2; cudaSafeCall(hipMalloc((void **) &constraintLocal, size)); cudaSafeCall(hipMemcpyToSymbol(constraintsName, &constraintLocal, sizeof(uint*))); cudaSafeCall(hipMemcpyToSymbol(numConstraintsName, &paddedSize, uintSize)); cudaSafeCall(hipMemcpy(constraintLocal, constraints, size, H2D)); transferH2dTime += getEllapsedTime(startTime); delete [] constraints; } void readAndTransferGepConstraints(igzstream &inFile, uint numConstraints, uint& maxOffset) { uint length = roundToNextMultipleOf(numConstraints * 2, 32); uint* constraints = new uint[length]; assert (constraints != NULL); for (uint i = 0; i < numConstraints; i++) { string line = skipBlanksAndComments(inFile); istringstream linestream(line); nextUint(linestream); // ignore constraint ID uint src = nextUint(linestream); uint dst = nextUint(linestream); nextUint(linestream); // ignore type uint offset = nextUint(linestream); if (offset > maxOffset) { maxOffset = offset; } if (offset > MAX_GEP_OFFSET) { cerr << "Offset too large: " << offset << " (max. allowed: " << MAX_GEP_OFFSET << ")"; exit(-1); } constraints[i * 2] = dst; constraints[i * 2 + 1] = idOffset(src, offset); } // pad with NILs for (uint i = numConstraints * 2; i < length; i++) { constraints[i] = NIL; } const uint startTime = clock(); uint* formattedConstraintsLocal; cudaSafeCall(hipMalloc((void **) &formattedConstraintsLocal, length * uintSize)); cudaSafeCall(hipMemcpy(formattedConstraintsLocal, constraints, length * uintSize, H2D)); cudaSafeCall(hipMemcpyToSymbol(__gepInv__, &formattedConstraintsLocal, sizeof(uint*))); cudaSafeCall(hipMemcpyToSymbol(__numGepInv__, &numConstraints, uintSize, 0, H2D)); transferH2dTime += getEllapsedTime(startTime); delete [] constraints; } // returns a pointer to __pts__ void readConstraints(char *fileName, uint numVars, uint& maxOffset) { cout << "[host] Reading constraints..." << flush; igzstream inFile(fileName, igzstream::in); if (!inFile) { fprintf(stderr, "Error: file %s not found.\n", fileName); exit(-1); } string line = skipBlanksAndComments(inFile); istringstream linestream(line); uint numAddressOf = nextUint(linestream); uint numCopy = nextUint(linestream); uint numLoad = nextUint(linestream); uint numStore = nextUint(linestream); uint numGep = nextUint(linestream); readAndTransferConstraints(inFile, numAddressOf, __ptsConstraints__, __numPtsConstraints__); readAndTransferConstraints(inFile, numCopy, __copyConstraints__, __numCopyConstraints__); readAndTransferConstraints(inFile, numLoad, __loadConstraints__, __numLoadConstraints__); readAndTransferConstraints(inFile, numStore, __storeConstraints__, __numStoreConstraints__); uint headerSize = numVars * ELEMENT_WIDTH; uint start = COPY_INV_START + headerSize; cudaSafeCall(hipMemcpyToSymbol(__loadInvStart__, &start, sizeof(uint))); start += headerSize; cudaSafeCall(hipMemcpyToSymbol(__storeStart__, &start, sizeof(uint))); readAndTransferGepConstraints(inFile, numGep, maxOffset); inFile.close(); cout << "OK." << endl << flush; } // TODO: this code is too complex, simplify void readHcdInfo(char *fileName) { cout << "[host] Reading HCD table..." << flush; igzstream inFile(fileName, igzstream::in); if (!inFile) { fprintf(stderr, "Error: file %s not found.\n", fileName); exit(-1); } // a) read initial table of representatives string line = skipBlanksAndComments(inFile); istringstream linestream(line); uint numMerged = nextUint(linestream); uint* initialNonRep = new uint[numMerged]; uint* initialRep = new uint[numMerged]; for (uint i = 0; i < numMerged; i++) { string line = skipBlanksAndComments(inFile); istringstream linestream(line); uint var = nextUint(linestream); uint rep = nextUint(linestream); initialNonRep[i] = var; initialRep[i] = rep; } int* initRepLocal; // transfer index table cudaSafeCall(hipMalloc((void **) &initRepLocal, uintSize * numMerged)); cudaSafeCall(hipMemcpy(initRepLocal, initialRep, uintSize * numMerged, H2D)); cudaSafeCall(hipMemcpyToSymbol(__initialRep__, &initRepLocal, sizeof(uint*))); cudaSafeCall(hipMalloc((void **) &initRepLocal, uintSize * numMerged)); cudaSafeCall(hipMemcpy(initRepLocal, initialNonRep, uintSize * numMerged, H2D)); cudaSafeCall(hipMemcpyToSymbol(__initialNonRep__, &initRepLocal, sizeof(uint*))); cudaSafeCall(hipMemcpyToSymbol(__numInitialRep__, &numMerged, uintSize)); // b) read HCD table itself { string line = skipBlanksAndComments(inFile); istringstream linestream(line); uint numKeys = nextUint(linestream); uint numValues = nextUint(linestream); uint hcdTableSize = numKeys + numValues; uint* table = new uint[hcdTableSize]; uint* index = new uint[numKeys]; if (numKeys) { uint keys = 0; uint lastY = 0; index[keys] = getFirst(0); for (uint i = 0; i < numValues; i++) { string line = skipBlanksAndComments(inFile); istringstream linestream(line); uint y = nextUint(linestream); uint x = nextUint(linestream); if (y != lastY) { table[i + keys] = y; if (keys) { assert(((i + keys) - (index[keys - 1])) <= HCD_TABLE_SIZE); index[keys - 1] = createPair(index[keys - 1], i + keys); index[keys] = i + keys; } keys++; lastY = y; } table[i + keys] = x; } assert(((numKeys + numValues) - (index[keys - 1])) <= HCD_TABLE_SIZE); index[keys - 1] = createPair(index[keys - 1], numKeys + numValues); } int* hcdIndexLocal; int* hcdTableLocal; // transfer index table cudaSafeCall(hipMalloc((void **) &hcdIndexLocal, uintSize * numKeys)); cudaSafeCall(hipMemcpy(hcdIndexLocal, index, uintSize * numKeys, H2D)); cudaSafeCall(hipMemcpyToSymbol(__hcdIndex__, &hcdIndexLocal, sizeof(uint*))); cudaSafeCall(hipMemcpyToSymbol(__numHcdIndex__, &numKeys, uintSize)); // transfer HCD table cudaSafeCall(hipMalloc((void **) &hcdTableLocal, uintSize * (numKeys + numValues))); cudaSafeCall(hipMemcpy(hcdTableLocal, table, uintSize * (numKeys + numValues), H2D)); cudaSafeCall(hipMemcpyToSymbol(__hcdTable__, &hcdTableLocal, sizeof(uint*))); cudaSafeCall(hipMemcpyToSymbol(__numHcdTable__, &hcdTableSize, uintSize)); } cout << "OK." << endl << flush; } // allocate memory for the graph edges uint* allocateElementPool() { const uint startTime = clock(); uint* elementPoolLocal; size_t size = HEAP_SIZE * sizeof(uint); cudaSafeCall(hipMalloc((void **) &elementPoolLocal, size)); // elements are initialized on the GPU, so we only transfer the pointers cudaSafeCall(hipMemcpyToSymbol(__graph__, &elementPoolLocal, sizeof(uint*))); cudaSafeCall(hipMemcpyToSymbol(__edges__, &elementPoolLocal, sizeof(uint*))); transferH2dTime += getEllapsedTime(startTime); return elementPoolLocal; } uint* allocateOther(uint numVars) { uint* lockLocal; size_t size = roundToNextMultipleOf(numVars, 32) * sizeof(uint); cudaSafeCall(hipMalloc((void **) &lockLocal, size)); cudaSafeCall(hipMemcpyToSymbol(__lock__, &lockLocal, sizeof(uint*))); cudaSafeCall(hipMalloc((void **) &lockLocal, size)); cudaSafeCall(hipMemcpyToSymbol(__currPtsHead__, &lockLocal, sizeof(uint*))); cudaSafeCall(hipMalloc((void **) &lockLocal, getBlocks() * HCD_DECODE_VECTOR_SIZE)); cudaSafeCall(hipMemcpyToSymbol(__nextVar__, &lockLocal, sizeof(uint*))); cudaSafeCall(hipMalloc((void **) &lockLocal, size)); cudaSafeCall(hipMemcpyToSymbol(__rep__, &lockLocal, sizeof(uint*))); return lockLocal; } void allocateDiffPtsMask(uint numVars) { int* maskLocal; int rows = ceil((float) numVars / (float) ELEMENT_CARDINALITY); size_t size = rows * ELEMENT_WIDTH * sizeof(uint); cudaSafeCall(hipMalloc((void **) &maskLocal, size)); cudaSafeCall(hipMemcpyToSymbol(__diffPtsMask__, &maskLocal, sizeof(uint*))); } void allocateOffsetMask(uint numObjectVars, uint maxOffset) { int* maskLocal; int rows = ceil((float) numObjectVars / (float) ELEMENT_CARDINALITY); size_t size = rows * ELEMENT_WIDTH * maxOffset * sizeof(uint); cudaSafeCall(hipMalloc((void **) &maskLocal, size)); cudaSafeCall(hipMemcpyToSymbol(__offsetMask__, &maskLocal, sizeof(uint*))); cudaSafeCall(hipMemcpyToSymbol(__offsetMaskRowsPerOffset__, &rows, sizeof(uint))); } uint* allocateOthers(const uint numVars, const uint numObjectVars, const uint maxOffset) { const uint startTime = clock(); uint* repD = allocateOther(numVars); allocateDiffPtsMask(numVars); allocateOffsetMask(numObjectVars, maxOffset); transferH2dTime += getEllapsedTime(startTime); return repD; } void convertCsvIntoVector(string csv, vector<uint>& ret) { if (csv.empty()) { return; } istringstream linestream(csv); while (!linestream.eof()) { uint next = nextUint(linestream); ret.push_back(next); } } void getPts(uint var, uint* ptsEdges, uint ptsSize, vector<uint>& ret) { uint index = mul32(var); do { if (index > ptsSize) { cerr << "Error at variable " << var << ". The NEXT field exceeds the size of PTS. Next: " << index << ", size: " << ptsSize << endl << flush; return; //exit(-1); } uint base = ptsEdges[index + BASE]; // if base == NIL => empty adjancency list if (base == NIL) { return; } for (uint j = 0; j < BASE; j++) { uint word = ptsEdges[index + j]; if (!word) { continue; } for (uint z = 0; z < WARP_SIZE; z++) { if (isBitActive(word, z)) { uint num = base * ELEMENT_CARDINALITY + j * WARP_SIZE + z; ret.push_back(num); } } } index = ptsEdges[index + NEXT]; } while (index != NIL); } void verifySolution(bool useInclusion, uint* ptsEdges, uint ptsSize, uint* rep, const vector<uint>& vars, const vector<uint>& sol) { for (uint i = 0; i < vars.size(); i++) { uint var = vars[i]; vector<uint> ptsVar; uint representative = rep[var]; if (representative != var) { // non-representative: simply make sure that the representative is included in 'vars' if (std::find(vars.begin(), vars.end(), representative) == vars.end()) { getPts(representative, ptsEdges, ptsSize, ptsVar); cerr << "Error at variable " << var << " (rep=" << representative << "): the obtained pts (1st line) differs from the correct solution (2nd line)" << endl; printVector(ptsVar); cerr << endl; printVector(sol); cerr << endl; exit(-1); } } else { getPts(representative, ptsEdges, ptsSize, ptsVar); bool OK = useInclusion ? includes(sol.begin(), sol.end(), ptsVar.begin(), ptsVar.end()) : (ptsVar == sol); if (!OK) { cerr << "Error at representative " << var << ": the obtained pts (1st line) " << "differs from the correct solution (2nd line)" << endl; printVector(ptsVar); cerr << endl; printVector(sol); cerr << endl; exit(-1); } } } } void verifySolution(uint verify, uint* ptsEdges, uint ptsSize, uint* rep, char* solFile) { if (!verify) { return; } igzstream inFile(solFile, igzstream::in); if (!inFile) { fprintf(stderr, "Error: file %s not found.\n", solFile); exit(-1); } if (verify == USE_INCLUSION) { cerr << "[host] WARNING: verification uses inclusion." << endl << flush; } cerr << "[host] Verifying against " << solFile << "..." << flush; string line; getline(inFile, line); // skip first line while (getline(inFile, line)) { size_t pos = line.find("] => ["); string lhs = line.substr(1, pos - 1); vector<uint> vars; convertCsvIntoVector(lhs, vars); string rhs = line.substr(pos + 6); rhs = rhs.substr(0, rhs.size() - 1); vector<uint> sol; convertCsvIntoVector(rhs, sol); verifySolution(verify == USE_INCLUSION, ptsEdges, ptsSize, rep, vars, sol); } inFile.close(); cerr << "OK." << endl << flush; } void printSolution(uint numVars, uint* ptsEdges, uint ptsSize) { for (uint i = 0; i < numVars; i++) { vector<uint> ptsVar; getPts(i, ptsEdges, ptsSize, ptsVar); if (!ptsVar.empty()) { cout << i << " => " << flush; printVector(ptsVar); cout << endl << flush; } } } // transfer back PTS and representative tables void transferBackInfo(uint verify, uint numVars, uint* edgesD, uint ptsSize, uint* repD, char* solFile) { cerr << "[host] Tranferring back " << B2MB(ptsSize * 4) << " MB..." << flush; const uint startTime = clock(); uint* ptsEdges = NULL; cudaSafeCall(hipHostMalloc((void**) &ptsEdges, ptsSize * uintSize, 0)); cudaSafeCall(hipMemcpy(ptsEdges, edgesD, ptsSize * uintSize, D2H)); uint* rep = NULL; cudaSafeCall(hipHostMalloc((void**) &rep, numVars * uintSize, 0)); cudaSafeCall(hipMemcpy(rep, repD, numVars * uintSize, D2H)); //printSolution(numVars, ptsEdges, ptsSize); transferD2hTime += getEllapsedTime(startTime); cerr << "OK." << endl << flush; cout << "TRANSFER runtime: " << (transferH2dTime + transferD2hTime) << " ms." << endl; cout << " h2d: " << transferH2dTime << " ms." << endl; cout << " d2h: " << transferD2hTime << " ms." << endl; verifySolution(verify, ptsEdges, ptsSize, rep, solFile); cudaSafeCall(hipHostFree(ptsEdges)); cudaSafeCall(hipHostFree(rep)); } int main(int argc, char** argv) { if ((argc < 5) || (argc > 7)) { cerr << "Usage : " << argv[0] << " NODES_FILE CONSTRAINTS_FILE HCD_TABLE SOLUTION_FILE [TRANSFER, VERIFY]" << endl; exit(-1); } // printDeviceMemory(); // TODO: a lot of checks on the arguments are missing... bool transfer = false; int verify = 0; if (argc > 5) { transfer = atoi(argv[5]); verify = atoi(argv[6]); } checkGPUConfiguration(); uint maxOffset = 0; uint numVars, numObjectVars; string input(argv[1]); size_t start = input.find_last_of('/') + 1; size_t end = input.find('_'); cerr << "\n[host] Input: " << input.substr(start, end - start) << endl; #ifdef __LP64__ cout << "[host] 64-bit detected." << endl << flush; #endif readNodes(argv[1], numVars, numObjectVars); readConstraints(argv[2], numVars, maxOffset); printf("%d\t%d\n", numObjectVars, numVars); readHcdInfo(argv[3]); uint* edgesD = allocateElementPool(); uint* repD = allocateOthers(numVars, numObjectVars, maxOffset); createGraph(numObjectVars, maxOffset); uint endIndex = andersen(numVars); if (transfer) { transferBackInfo(verify, numVars, edgesD, endIndex, repD, argv[4]); } return 0; }
6c7644fa5e3e475843108e09d0a50bca87a2686e.cu
/* Copyright (c) 2013 The University of Texas at Austin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA, or see <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>. Author: Mario Mendez-Lojo */ #include <algorithm> #include <fstream> #include <iostream> #include <iterator> #include <sstream> #include <vector> #include "andersen.h" //#include "mySVN/gzstream.h" // commented by, #define igzstream ifstream // added by, #include "andersen.cu" // added by Rupesh Nasre on Dec 27, 2012. using namespace std; // check that the obtained solution is a subset of the desired solution. Useful when trying to // detect bugs (for instance, detected the 1st iteration such that the inclusion does not hold) #define USE_INCLUSION (2) static uint transferH2dTime = 0; static uint transferD2hTime = 0; //static void printDeviceMemory() { //size_t uCurAvailMemoryInBytes, uTotalMemoryInBytes; //cudaMemGetInfo( &uCurAvailMemoryInBytes, &uTotalMemoryInBytes ); //cout << "[host] GPU's total memory: "<< B2MB(uTotalMemoryInBytes) << " MB, free Memory: " // << B2MB(uCurAvailMemoryInBytes) << " MB" << endl; //if (B2MB(uCurAvailMemoryInBytes) < 3930) { // cout << "Warning: there is not enough memory in your GPU to analyze all inputs." << endl; //} //} static void printVector(const vector<uint>& m) { vector<uint>::size_type size = m.size(); cout << "["; if (size) { ostream_iterator<uint> out_it (cout,", "); std::copy(m.begin(), m.begin() + size - 1, out_it); cout << m[size - 1]; } cout << "]"; } static void printVector(uint* m, const uint size) { cout << "["; if (size) { ostream_iterator<uint> out_it (cout,", "); std::copy(m, m + size - 1, out_it); cout << m[size - 1]; } cout << "]"; } void printMatrix(uint* m, const uint rows, const uint cols) { printf("["); for (uint i = 0; i < rows; i++) { if (i > 0) { printf(" "); } printVector(&m[i * cols], cols); if (i < rows - 1) { printf("\n"); } } printf("]\n"); } void checkGPUConfiguration() { int deviceCount; cudaGetDeviceCount(&deviceCount); if (deviceCount == 0) { cerr << "There is no device supporting CUDA\n" << endl; exit(-1); } cudaDeviceProp deviceProp; cudaGetDeviceProperties(&deviceProp, 0); if ((deviceProp.major == 9999) && (deviceProp.minor == 9999)) { cerr << "There is no CUDA capable device" << endl; exit(-1); } if ((WARP_SIZE != 32)) { cerr << "Warp size must be 32" << endl ; exit(-1); } // Make printf buffer bigger, otherwise some printf messages are not displayed size_t limit; cudaDeviceGetLimit(&limit, cudaLimitPrintfFifoSize); cudaDeviceSetLimit(cudaLimitPrintfFifoSize, limit * 16); // Make stack bigger, otherwise recursive functions will fail silently (?) //cudaThreadGetLimit(&limit, cudaLimitStackSize); //cudaThreadSetLimit(cudaLimitStackSize, limit * 8); } uint nextUint(istringstream& lineStream) { string item; getline(lineStream, item, ','); return atoi(item.c_str()); } string skipBlanksAndComments(igzstream& inFile){ string line; for (;;) { getline(inFile, line); if (!line.empty() && line[0] != '#') { return string(line); } } } uint readNumVars(igzstream &inFile) { string line = skipBlanksAndComments(inFile); istringstream linestream(line); return nextUint(linestream); } uint readNodes(char *fileName, uint& numVars, uint& numObjectVars) { cout << "[host] Reading nodes..." << flush; igzstream inFile(fileName, igzstream::in); if (!inFile) { fprintf(stderr, "Error: file %s not found.\n", fileName); exit(-1); } string line = skipBlanksAndComments(inFile); istringstream linestream(line); // read total number of variables numVars = roundToNextMultipleOf(nextUint(linestream), 32); // cout << "number of variables: " << numVars << endl; line = skipBlanksAndComments(inFile); istringstream linestream2(line); // for some reason, the number stored is lastObjectVar numObjectVars = nextUint(linestream2) + 1; // cout << " object variables: " << numObjectVars << endl; skipBlanksAndComments(inFile); // skip lastFunctionNode uint length = roundToNextMultipleOf(numObjectVars, 32); uint* size = new uint[length]; assert (size != NULL); for (uint i = 0; i < numObjectVars; i++) { line = skipBlanksAndComments(inFile); istringstream linestream(line); nextUint(linestream); // ignore var ID size[i] = nextUint(linestream); nextUint(linestream);// ignore functionNode crap } inFile.close(); for (uint i = numObjectVars; i < length; i++) { size[i] = 0; } const uint startTime = clock(); uint* sizeLocal; cudaSafeCall(cudaMalloc((void **) &sizeLocal, length * uintSize)); cudaSafeCall(cudaMemcpy(sizeLocal, size, length * uintSize, H2D)); cudaSafeCall(cudaMemcpyToSymbol(__size__, &sizeLocal, sizeof(uint*))); cudaSafeCall(cudaMemcpyToSymbol(__numVars__, &numVars, uintSize)); transferH2dTime += getEllapsedTime(startTime); cout << "OK." << endl << flush; return numObjectVars; } uint inline padNumber(uint num) { uint ret = roundToNextMultipleOf(num, 32); if (ret == num) { ret = roundToNextMultipleOf(num + 1, 32); } return ret; } uint* readConstraints(igzstream &inFile, uint rows) { uint length = padNumber(rows); uint* constraints = new uint[length * 2]; assert (constraints != NULL); for (uint i = 0; i < rows; i++) { string line = skipBlanksAndComments(inFile); istringstream linestream(line); nextUint(linestream); // ignore constraint ID uint src = nextUint(linestream); uint dst = nextUint(linestream); nextUint(linestream); // ignore type uint offset = nextUint(linestream); if (offset) { cerr << "Detected constraint with offset" << endl << flush; exit(-1); } constraints[i] = dst; constraints[i + length] = src; } // pad with NILs for (uint i = rows; i < length; i++) { constraints[i] = NIL; constraints[i + length] = NIL; } return constraints; } void readAndTransferConstraints(igzstream &inFile, uint numConstraints, uint* &constraintsName, uint &numConstraintsName) { uint* constraints = readConstraints(inFile, numConstraints); const uint startTime = clock(); uint* constraintLocal; uint paddedSize = padNumber(numConstraints); size_t size = paddedSize * uintSize * 2; cudaSafeCall(cudaMalloc((void **) &constraintLocal, size)); cudaSafeCall(cudaMemcpyToSymbol(constraintsName, &constraintLocal, sizeof(uint*))); cudaSafeCall(cudaMemcpyToSymbol(numConstraintsName, &paddedSize, uintSize)); cudaSafeCall(cudaMemcpy(constraintLocal, constraints, size, H2D)); transferH2dTime += getEllapsedTime(startTime); delete [] constraints; } void readAndTransferGepConstraints(igzstream &inFile, uint numConstraints, uint& maxOffset) { uint length = roundToNextMultipleOf(numConstraints * 2, 32); uint* constraints = new uint[length]; assert (constraints != NULL); for (uint i = 0; i < numConstraints; i++) { string line = skipBlanksAndComments(inFile); istringstream linestream(line); nextUint(linestream); // ignore constraint ID uint src = nextUint(linestream); uint dst = nextUint(linestream); nextUint(linestream); // ignore type uint offset = nextUint(linestream); if (offset > maxOffset) { maxOffset = offset; } if (offset > MAX_GEP_OFFSET) { cerr << "Offset too large: " << offset << " (max. allowed: " << MAX_GEP_OFFSET << ")"; exit(-1); } constraints[i * 2] = dst; constraints[i * 2 + 1] = idOffset(src, offset); } // pad with NILs for (uint i = numConstraints * 2; i < length; i++) { constraints[i] = NIL; } const uint startTime = clock(); uint* formattedConstraintsLocal; cudaSafeCall(cudaMalloc((void **) &formattedConstraintsLocal, length * uintSize)); cudaSafeCall(cudaMemcpy(formattedConstraintsLocal, constraints, length * uintSize, H2D)); cudaSafeCall(cudaMemcpyToSymbol(__gepInv__, &formattedConstraintsLocal, sizeof(uint*))); cudaSafeCall(cudaMemcpyToSymbol(__numGepInv__, &numConstraints, uintSize, 0, H2D)); transferH2dTime += getEllapsedTime(startTime); delete [] constraints; } // returns a pointer to __pts__ void readConstraints(char *fileName, uint numVars, uint& maxOffset) { cout << "[host] Reading constraints..." << flush; igzstream inFile(fileName, igzstream::in); if (!inFile) { fprintf(stderr, "Error: file %s not found.\n", fileName); exit(-1); } string line = skipBlanksAndComments(inFile); istringstream linestream(line); uint numAddressOf = nextUint(linestream); uint numCopy = nextUint(linestream); uint numLoad = nextUint(linestream); uint numStore = nextUint(linestream); uint numGep = nextUint(linestream); readAndTransferConstraints(inFile, numAddressOf, __ptsConstraints__, __numPtsConstraints__); readAndTransferConstraints(inFile, numCopy, __copyConstraints__, __numCopyConstraints__); readAndTransferConstraints(inFile, numLoad, __loadConstraints__, __numLoadConstraints__); readAndTransferConstraints(inFile, numStore, __storeConstraints__, __numStoreConstraints__); uint headerSize = numVars * ELEMENT_WIDTH; uint start = COPY_INV_START + headerSize; cudaSafeCall(cudaMemcpyToSymbol(__loadInvStart__, &start, sizeof(uint))); start += headerSize; cudaSafeCall(cudaMemcpyToSymbol(__storeStart__, &start, sizeof(uint))); readAndTransferGepConstraints(inFile, numGep, maxOffset); inFile.close(); cout << "OK." << endl << flush; } // TODO: this code is too complex, simplify void readHcdInfo(char *fileName) { cout << "[host] Reading HCD table..." << flush; igzstream inFile(fileName, igzstream::in); if (!inFile) { fprintf(stderr, "Error: file %s not found.\n", fileName); exit(-1); } // a) read initial table of representatives string line = skipBlanksAndComments(inFile); istringstream linestream(line); uint numMerged = nextUint(linestream); uint* initialNonRep = new uint[numMerged]; uint* initialRep = new uint[numMerged]; for (uint i = 0; i < numMerged; i++) { string line = skipBlanksAndComments(inFile); istringstream linestream(line); uint var = nextUint(linestream); uint rep = nextUint(linestream); initialNonRep[i] = var; initialRep[i] = rep; } int* initRepLocal; // transfer index table cudaSafeCall(cudaMalloc((void **) &initRepLocal, uintSize * numMerged)); cudaSafeCall(cudaMemcpy(initRepLocal, initialRep, uintSize * numMerged, H2D)); cudaSafeCall(cudaMemcpyToSymbol(__initialRep__, &initRepLocal, sizeof(uint*))); cudaSafeCall(cudaMalloc((void **) &initRepLocal, uintSize * numMerged)); cudaSafeCall(cudaMemcpy(initRepLocal, initialNonRep, uintSize * numMerged, H2D)); cudaSafeCall(cudaMemcpyToSymbol(__initialNonRep__, &initRepLocal, sizeof(uint*))); cudaSafeCall(cudaMemcpyToSymbol(__numInitialRep__, &numMerged, uintSize)); // b) read HCD table itself { string line = skipBlanksAndComments(inFile); istringstream linestream(line); uint numKeys = nextUint(linestream); uint numValues = nextUint(linestream); uint hcdTableSize = numKeys + numValues; uint* table = new uint[hcdTableSize]; uint* index = new uint[numKeys]; if (numKeys) { uint keys = 0; uint lastY = 0; index[keys] = getFirst(0); for (uint i = 0; i < numValues; i++) { string line = skipBlanksAndComments(inFile); istringstream linestream(line); uint y = nextUint(linestream); uint x = nextUint(linestream); if (y != lastY) { table[i + keys] = y; if (keys) { assert(((i + keys) - (index[keys - 1])) <= HCD_TABLE_SIZE); index[keys - 1] = createPair(index[keys - 1], i + keys); index[keys] = i + keys; } keys++; lastY = y; } table[i + keys] = x; } assert(((numKeys + numValues) - (index[keys - 1])) <= HCD_TABLE_SIZE); index[keys - 1] = createPair(index[keys - 1], numKeys + numValues); } int* hcdIndexLocal; int* hcdTableLocal; // transfer index table cudaSafeCall(cudaMalloc((void **) &hcdIndexLocal, uintSize * numKeys)); cudaSafeCall(cudaMemcpy(hcdIndexLocal, index, uintSize * numKeys, H2D)); cudaSafeCall(cudaMemcpyToSymbol(__hcdIndex__, &hcdIndexLocal, sizeof(uint*))); cudaSafeCall(cudaMemcpyToSymbol(__numHcdIndex__, &numKeys, uintSize)); // transfer HCD table cudaSafeCall(cudaMalloc((void **) &hcdTableLocal, uintSize * (numKeys + numValues))); cudaSafeCall(cudaMemcpy(hcdTableLocal, table, uintSize * (numKeys + numValues), H2D)); cudaSafeCall(cudaMemcpyToSymbol(__hcdTable__, &hcdTableLocal, sizeof(uint*))); cudaSafeCall(cudaMemcpyToSymbol(__numHcdTable__, &hcdTableSize, uintSize)); } cout << "OK." << endl << flush; } // allocate memory for the graph edges uint* allocateElementPool() { const uint startTime = clock(); uint* elementPoolLocal; size_t size = HEAP_SIZE * sizeof(uint); cudaSafeCall(cudaMalloc((void **) &elementPoolLocal, size)); // elements are initialized on the GPU, so we only transfer the pointers cudaSafeCall(cudaMemcpyToSymbol(__graph__, &elementPoolLocal, sizeof(uint*))); cudaSafeCall(cudaMemcpyToSymbol(__edges__, &elementPoolLocal, sizeof(uint*))); transferH2dTime += getEllapsedTime(startTime); return elementPoolLocal; } uint* allocateOther(uint numVars) { uint* lockLocal; size_t size = roundToNextMultipleOf(numVars, 32) * sizeof(uint); cudaSafeCall(cudaMalloc((void **) &lockLocal, size)); cudaSafeCall(cudaMemcpyToSymbol(__lock__, &lockLocal, sizeof(uint*))); cudaSafeCall(cudaMalloc((void **) &lockLocal, size)); cudaSafeCall(cudaMemcpyToSymbol(__currPtsHead__, &lockLocal, sizeof(uint*))); cudaSafeCall(cudaMalloc((void **) &lockLocal, getBlocks() * HCD_DECODE_VECTOR_SIZE)); cudaSafeCall(cudaMemcpyToSymbol(__nextVar__, &lockLocal, sizeof(uint*))); cudaSafeCall(cudaMalloc((void **) &lockLocal, size)); cudaSafeCall(cudaMemcpyToSymbol(__rep__, &lockLocal, sizeof(uint*))); return lockLocal; } void allocateDiffPtsMask(uint numVars) { int* maskLocal; int rows = ceil((float) numVars / (float) ELEMENT_CARDINALITY); size_t size = rows * ELEMENT_WIDTH * sizeof(uint); cudaSafeCall(cudaMalloc((void **) &maskLocal, size)); cudaSafeCall(cudaMemcpyToSymbol(__diffPtsMask__, &maskLocal, sizeof(uint*))); } void allocateOffsetMask(uint numObjectVars, uint maxOffset) { int* maskLocal; int rows = ceil((float) numObjectVars / (float) ELEMENT_CARDINALITY); size_t size = rows * ELEMENT_WIDTH * maxOffset * sizeof(uint); cudaSafeCall(cudaMalloc((void **) &maskLocal, size)); cudaSafeCall(cudaMemcpyToSymbol(__offsetMask__, &maskLocal, sizeof(uint*))); cudaSafeCall(cudaMemcpyToSymbol(__offsetMaskRowsPerOffset__, &rows, sizeof(uint))); } uint* allocateOthers(const uint numVars, const uint numObjectVars, const uint maxOffset) { const uint startTime = clock(); uint* repD = allocateOther(numVars); allocateDiffPtsMask(numVars); allocateOffsetMask(numObjectVars, maxOffset); transferH2dTime += getEllapsedTime(startTime); return repD; } void convertCsvIntoVector(string csv, vector<uint>& ret) { if (csv.empty()) { return; } istringstream linestream(csv); while (!linestream.eof()) { uint next = nextUint(linestream); ret.push_back(next); } } void getPts(uint var, uint* ptsEdges, uint ptsSize, vector<uint>& ret) { uint index = mul32(var); do { if (index > ptsSize) { cerr << "Error at variable " << var << ". The NEXT field exceeds the size of PTS. Next: " << index << ", size: " << ptsSize << endl << flush; return; //exit(-1); } uint base = ptsEdges[index + BASE]; // if base == NIL => empty adjancency list if (base == NIL) { return; } for (uint j = 0; j < BASE; j++) { uint word = ptsEdges[index + j]; if (!word) { continue; } for (uint z = 0; z < WARP_SIZE; z++) { if (isBitActive(word, z)) { uint num = base * ELEMENT_CARDINALITY + j * WARP_SIZE + z; ret.push_back(num); } } } index = ptsEdges[index + NEXT]; } while (index != NIL); } void verifySolution(bool useInclusion, uint* ptsEdges, uint ptsSize, uint* rep, const vector<uint>& vars, const vector<uint>& sol) { for (uint i = 0; i < vars.size(); i++) { uint var = vars[i]; vector<uint> ptsVar; uint representative = rep[var]; if (representative != var) { // non-representative: simply make sure that the representative is included in 'vars' if (std::find(vars.begin(), vars.end(), representative) == vars.end()) { getPts(representative, ptsEdges, ptsSize, ptsVar); cerr << "Error at variable " << var << " (rep=" << representative << "): the obtained pts (1st line) differs from the correct solution (2nd line)" << endl; printVector(ptsVar); cerr << endl; printVector(sol); cerr << endl; exit(-1); } } else { getPts(representative, ptsEdges, ptsSize, ptsVar); bool OK = useInclusion ? includes(sol.begin(), sol.end(), ptsVar.begin(), ptsVar.end()) : (ptsVar == sol); if (!OK) { cerr << "Error at representative " << var << ": the obtained pts (1st line) " << "differs from the correct solution (2nd line)" << endl; printVector(ptsVar); cerr << endl; printVector(sol); cerr << endl; exit(-1); } } } } void verifySolution(uint verify, uint* ptsEdges, uint ptsSize, uint* rep, char* solFile) { if (!verify) { return; } igzstream inFile(solFile, igzstream::in); if (!inFile) { fprintf(stderr, "Error: file %s not found.\n", solFile); exit(-1); } if (verify == USE_INCLUSION) { cerr << "[host] WARNING: verification uses inclusion." << endl << flush; } cerr << "[host] Verifying against " << solFile << "..." << flush; string line; getline(inFile, line); // skip first line while (getline(inFile, line)) { size_t pos = line.find("] => ["); string lhs = line.substr(1, pos - 1); vector<uint> vars; convertCsvIntoVector(lhs, vars); string rhs = line.substr(pos + 6); rhs = rhs.substr(0, rhs.size() - 1); vector<uint> sol; convertCsvIntoVector(rhs, sol); verifySolution(verify == USE_INCLUSION, ptsEdges, ptsSize, rep, vars, sol); } inFile.close(); cerr << "OK." << endl << flush; } void printSolution(uint numVars, uint* ptsEdges, uint ptsSize) { for (uint i = 0; i < numVars; i++) { vector<uint> ptsVar; getPts(i, ptsEdges, ptsSize, ptsVar); if (!ptsVar.empty()) { cout << i << " => " << flush; printVector(ptsVar); cout << endl << flush; } } } // transfer back PTS and representative tables void transferBackInfo(uint verify, uint numVars, uint* edgesD, uint ptsSize, uint* repD, char* solFile) { cerr << "[host] Tranferring back " << B2MB(ptsSize * 4) << " MB..." << flush; const uint startTime = clock(); uint* ptsEdges = NULL; cudaSafeCall(cudaHostAlloc((void**) &ptsEdges, ptsSize * uintSize, 0)); cudaSafeCall(cudaMemcpy(ptsEdges, edgesD, ptsSize * uintSize, D2H)); uint* rep = NULL; cudaSafeCall(cudaHostAlloc((void**) &rep, numVars * uintSize, 0)); cudaSafeCall(cudaMemcpy(rep, repD, numVars * uintSize, D2H)); //printSolution(numVars, ptsEdges, ptsSize); transferD2hTime += getEllapsedTime(startTime); cerr << "OK." << endl << flush; cout << "TRANSFER runtime: " << (transferH2dTime + transferD2hTime) << " ms." << endl; cout << " h2d: " << transferH2dTime << " ms." << endl; cout << " d2h: " << transferD2hTime << " ms." << endl; verifySolution(verify, ptsEdges, ptsSize, rep, solFile); cudaSafeCall(cudaFreeHost(ptsEdges)); cudaSafeCall(cudaFreeHost(rep)); } int main(int argc, char** argv) { if ((argc < 5) || (argc > 7)) { cerr << "Usage : " << argv[0] << " NODES_FILE CONSTRAINTS_FILE HCD_TABLE SOLUTION_FILE [TRANSFER, VERIFY]" << endl; exit(-1); } // printDeviceMemory(); // TODO: a lot of checks on the arguments are missing... bool transfer = false; int verify = 0; if (argc > 5) { transfer = atoi(argv[5]); verify = atoi(argv[6]); } checkGPUConfiguration(); uint maxOffset = 0; uint numVars, numObjectVars; string input(argv[1]); size_t start = input.find_last_of('/') + 1; size_t end = input.find('_'); cerr << "\n[host] Input: " << input.substr(start, end - start) << endl; #ifdef __LP64__ cout << "[host] 64-bit detected." << endl << flush; #endif readNodes(argv[1], numVars, numObjectVars); readConstraints(argv[2], numVars, maxOffset); printf("%d\t%d\n", numObjectVars, numVars); readHcdInfo(argv[3]); uint* edgesD = allocateElementPool(); uint* repD = allocateOthers(numVars, numObjectVars, maxOffset); createGraph(numObjectVars, maxOffset); uint endIndex = andersen(numVars); if (transfer) { transferBackInfo(verify, numVars, edgesD, endIndex, repD, argv[4]); } return 0; }
aecd6fb108a42fd0e8418607d922121b0bf3cf48.hip
// !!! This is a file automatically generated by hipify!!! #include <ATen/ATen.h> #include <ATen/hip/HIPApplyUtils.cuh> #include <ATen/hip/HIPContext.h> #include <ATen/native/TensorFactories.h> #include <ATen/hip/cub.cuh> #include <ATen/native/hip/Randperm.cuh> #include <limits> namespace at { namespace native { // [Algorithm of randperm] // // randperm is implemented by sorting an arange tensor of size n with randomly // generated keys. When random keys are different from each other, all different // permutations have the same probability. // // However, there is a pitfall here: // For better performance, these N random keys are generated independently, // and there is no effort to make sure they are different at the time of generation. // When two keys are identical, stable sorting algorithms will not permute these two keys. // As a result, (0, 1) will appear more often than (1, 0). // // To overcome this pitfall we first carefully choose the number of bits in these keys, // so that the probability of having duplicate keys is under a threshold. Let q be the // threshold probability for having non-duplicate keys, then it can be proved that[1] // the number of bits required is: ceil(log2(n - (6 n^2 + 1) / (12 log(q)))) // // Then after sort, we lauch a separate kernel that additionally shuffles any islands // of values whose keys matched. The algorithm of this kernel is as follows: // Each thread reads its key and the keys of its neighbors to tell if it's part of an island. // For each island, the first thread in the island sees a key match at index i+1 but not index i-1. // This thread considers itself the "island leader". The island leader then reads more indices to // the right to figure out how big the island is. Most likely, the island will be very small, // just a few values. The island leader then rolls that many RNG, uses them to additionally // shuffle values within the island using serial Fisher-Yates, and writes them out. // // Reference // [1] https://osf.io/af2hy/ // The kernels are templated on an opaque, self-aligned type of the correct // size to avoid redundant kernels for different types of the same size. namespace { template <int N> struct alignas(N) OpaqueType { char data[N]; }; } Tensor& randperm_out_cuda(int64_t n, c10::optional<Generator> generator, Tensor& result) { TORCH_CHECK(n >= 0, "n must be non-negative, got", n); check_supported_max_int_with_precision(n, result); result.resize_({n}); auto range = at::arange(n, result.options()); // shuffled_data points to the underlying data of the output tensor if the tensor is contiguous; otherwise it // points to a new tensor. Tensor shuffled; void *shuffled_data; if (result.is_contiguous()) { shuffled_data = result.data_ptr(); } else { shuffled = at::empty(n, result.options()); shuffled_data = shuffled.data_ptr(); } auto opt = TensorOptions().device(result.device()); // See note [Algorithm of randperm] const double log_threshold_12 = ::log(0.9) * 12; double nd = static_cast<double>(n); int bits = ::min(64, static_cast<int>(::ceil(std::log2(nd - (6 * nd * nd + 1) / log_threshold_12)))); if (n == 0) { return result; } else if (bits <= 32) { // For asserting device type match of the generator and result, // we deligate that to the 'random_' function below. auto keys = at::empty(result.sizes(), opt.dtype(kInt)).random_( std::numeric_limits<int>::min(), std::numeric_limits<int>::max(), generator); auto keys_tmp = at::empty_like(keys); auto keys_out = keys_tmp.data_ptr<int>(); AT_DISPATCH_ALL_TYPES_AND(kHalf, result.scalar_type(), "randperm_out_cuda", [&] { using dtype = OpaqueType<sizeof(scalar_t)>; auto shuffled_data_ = reinterpret_cast<dtype*>(shuffled_data); dtype* range_data = reinterpret_cast<dtype*>(range.data_ptr()); at::cuda::cub::sort_pairs<int, dtype>( keys.data_ptr<int>(), keys_out, range_data, shuffled_data_, n, false, 0, bits); randperm_handle_duplicate_keys(keys_out, shuffled_data_, bits, n, generator); }); } else { auto keys = at::empty(result.sizes(), opt.dtype(kLong)).random_( std::numeric_limits<int64_t>::min(), std::numeric_limits<int64_t>::max(), generator); auto keys_tmp = at::empty_like(keys); auto keys_out = keys_tmp.data_ptr<int64_t>(); AT_DISPATCH_ALL_TYPES_AND(kHalf, result.scalar_type(), "randperm_out_cuda", [&] { using dtype = OpaqueType<sizeof(scalar_t)>; auto shuffled_data_ = reinterpret_cast<dtype*>(shuffled_data); dtype* range_data = reinterpret_cast<dtype*>(range.data_ptr()); at::cuda::cub::sort_pairs<int64_t, dtype>( keys.data_ptr<int64_t>(), keys_out, range_data, shuffled_data_, n, false, 0, bits); randperm_handle_duplicate_keys(keys_out, shuffled_data_, bits, n, generator); }); } if (!result.is_contiguous()) { result.copy_(shuffled); } return result; } }} // namespace at::native
aecd6fb108a42fd0e8418607d922121b0bf3cf48.cu
#include <ATen/ATen.h> #include <ATen/cuda/CUDAApplyUtils.cuh> #include <ATen/cuda/CUDAContext.h> #include <ATen/native/TensorFactories.h> #include <ATen/cuda/cub.cuh> #include <ATen/native/cuda/Randperm.cuh> #include <limits> namespace at { namespace native { // [Algorithm of randperm] // // randperm is implemented by sorting an arange tensor of size n with randomly // generated keys. When random keys are different from each other, all different // permutations have the same probability. // // However, there is a pitfall here: // For better performance, these N random keys are generated independently, // and there is no effort to make sure they are different at the time of generation. // When two keys are identical, stable sorting algorithms will not permute these two keys. // As a result, (0, 1) will appear more often than (1, 0). // // To overcome this pitfall we first carefully choose the number of bits in these keys, // so that the probability of having duplicate keys is under a threshold. Let q be the // threshold probability for having non-duplicate keys, then it can be proved that[1] // the number of bits required is: ceil(log2(n - (6 n^2 + 1) / (12 log(q)))) // // Then after sort, we lauch a separate kernel that additionally shuffles any islands // of values whose keys matched. The algorithm of this kernel is as follows: // Each thread reads its key and the keys of its neighbors to tell if it's part of an island. // For each island, the first thread in the island sees a key match at index i+1 but not index i-1. // This thread considers itself the "island leader". The island leader then reads more indices to // the right to figure out how big the island is. Most likely, the island will be very small, // just a few values. The island leader then rolls that many RNG, uses them to additionally // shuffle values within the island using serial Fisher-Yates, and writes them out. // // Reference // [1] https://osf.io/af2hy/ // The kernels are templated on an opaque, self-aligned type of the correct // size to avoid redundant kernels for different types of the same size. namespace { template <int N> struct alignas(N) OpaqueType { char data[N]; }; } Tensor& randperm_out_cuda(int64_t n, c10::optional<Generator> generator, Tensor& result) { TORCH_CHECK(n >= 0, "n must be non-negative, got", n); check_supported_max_int_with_precision(n, result); result.resize_({n}); auto range = at::arange(n, result.options()); // shuffled_data points to the underlying data of the output tensor if the tensor is contiguous; otherwise it // points to a new tensor. Tensor shuffled; void *shuffled_data; if (result.is_contiguous()) { shuffled_data = result.data_ptr(); } else { shuffled = at::empty(n, result.options()); shuffled_data = shuffled.data_ptr(); } auto opt = TensorOptions().device(result.device()); // See note [Algorithm of randperm] const double log_threshold_12 = std::log(0.9) * 12; double nd = static_cast<double>(n); int bits = std::min(64, static_cast<int>(std::ceil(std::log2(nd - (6 * nd * nd + 1) / log_threshold_12)))); if (n == 0) { return result; } else if (bits <= 32) { // For asserting device type match of the generator and result, // we deligate that to the 'random_' function below. auto keys = at::empty(result.sizes(), opt.dtype(kInt)).random_( std::numeric_limits<int>::min(), std::numeric_limits<int>::max(), generator); auto keys_tmp = at::empty_like(keys); auto keys_out = keys_tmp.data_ptr<int>(); AT_DISPATCH_ALL_TYPES_AND(kHalf, result.scalar_type(), "randperm_out_cuda", [&] { using dtype = OpaqueType<sizeof(scalar_t)>; auto shuffled_data_ = reinterpret_cast<dtype*>(shuffled_data); dtype* range_data = reinterpret_cast<dtype*>(range.data_ptr()); at::cuda::cub::sort_pairs<int, dtype>( keys.data_ptr<int>(), keys_out, range_data, shuffled_data_, n, false, 0, bits); randperm_handle_duplicate_keys(keys_out, shuffled_data_, bits, n, generator); }); } else { auto keys = at::empty(result.sizes(), opt.dtype(kLong)).random_( std::numeric_limits<int64_t>::min(), std::numeric_limits<int64_t>::max(), generator); auto keys_tmp = at::empty_like(keys); auto keys_out = keys_tmp.data_ptr<int64_t>(); AT_DISPATCH_ALL_TYPES_AND(kHalf, result.scalar_type(), "randperm_out_cuda", [&] { using dtype = OpaqueType<sizeof(scalar_t)>; auto shuffled_data_ = reinterpret_cast<dtype*>(shuffled_data); dtype* range_data = reinterpret_cast<dtype*>(range.data_ptr()); at::cuda::cub::sort_pairs<int64_t, dtype>( keys.data_ptr<int64_t>(), keys_out, range_data, shuffled_data_, n, false, 0, bits); randperm_handle_duplicate_keys(keys_out, shuffled_data_, bits, n, generator); }); } if (!result.is_contiguous()) { result.copy_(shuffled); } return result; } }} // namespace at::native
3ddeb5dff6772739956112d8ab931341caa59a76.hip
// !!! This is a file automatically generated by hipify!!! // ---------------------------------------------------------------------------- // - Open3D: www.open3d.org - // ---------------------------------------------------------------------------- // The MIT License (MIT) // // Copyright (c) 2018-2021 www.open3d.org // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. // ---------------------------------------------------------------------------- #define EIGEN_USE_GPU #include "ContinuousConvBackpropFilterOpKernel.h" #include "open3d/ml/Helper.h" #include "open3d/ml/impl/continuous_conv/ContinuousConvBackpropFilter.cuh" using namespace open3d; using namespace open3d::ml; using namespace open3d::ml::impl; using namespace tensorflow; template <class TFeat, class TOut, class TReal, class TIndex> class ContinuousConvBackpropFilterOpKernelCUDA : public ContinuousConvBackpropFilterOpKernel<TIndex> { public: explicit ContinuousConvBackpropFilterOpKernelCUDA( OpKernelConstruction* construction) : ContinuousConvBackpropFilterOpKernel<TIndex>(construction) { texture_alignment = GetCUDACurrentDeviceTextureAlignment(); } void Kernel(tensorflow::OpKernelContext* context, const tensorflow::Tensor& filter, const tensorflow::Tensor& out_positions, const tensorflow::Tensor& extents, const tensorflow::Tensor& offset, const tensorflow::Tensor& inp_positions, const tensorflow::Tensor& inp_features, const tensorflow::Tensor& inp_importance, const tensorflow::Tensor& neighbors_index, const tensorflow::Tensor& neighbors_importance, const tensorflow::Tensor& neighbors_row_splits, const tensorflow::Tensor& out_features_gradient, const std::vector<int>& filter_dims, const bool individual_extents, const bool isotropic_extents, const bool point_importances, const bool has_neighbors_importances, tensorflow::Tensor& filter_backprop) { auto device = context->eigen_gpu_device(); void* temp_ptr = nullptr; size_t temp_size = 0; size_t max_temp_size = 0; // determine temp_size CConvBackpropFilterCUDA<TFeat, TOut, TReal, TIndex>( device.stream(), temp_ptr, temp_size, max_temp_size, texture_alignment, filter_backprop.flat<TOut>().data(), filter_dims, out_positions.shape().dim_size(0), out_positions.flat<TReal>().data(), inp_positions.shape().dim_size(0), inp_positions.flat<TReal>().data(), inp_features.flat<TFeat>().data(), point_importances ? inp_importance.flat<TFeat>().data() : nullptr, neighbors_index.shape().dim_size(0), (TIndex*)neighbors_index.flat<TIndex>().data(), has_neighbors_importances ? neighbors_importance.flat<TFeat>().data() : nullptr, (int64_t*)neighbors_row_splits.flat<int64>().data(), extents.flat<TReal>().data(), offset.flat<TReal>().data(), out_features_gradient.flat<TFeat>().data(), this->interpolation, this->coordinate_mapping, this->align_corners, individual_extents, isotropic_extents, this->normalize); temp_size = ::max(::min(size_t(this->max_temp_mem_MB) * 1024 * 1024, max_temp_size), temp_size); Tensor temp_tensor; TensorShape temp_shape({ssize_t(temp_size)}); OP_REQUIRES_OK(context, context->allocate_temp(DataTypeToEnum<uint8_t>::v(), temp_shape, &temp_tensor)); temp_ptr = temp_tensor.flat<uint8_t>().data(); // actually run the operation CConvBackpropFilterCUDA<TFeat, TOut, TReal, TIndex>( device.stream(), temp_ptr, temp_size, max_temp_size, texture_alignment, filter_backprop.flat<TOut>().data(), filter_dims, out_positions.shape().dim_size(0), out_positions.flat<TReal>().data(), inp_positions.shape().dim_size(0), inp_positions.flat<TReal>().data(), inp_features.flat<TFeat>().data(), point_importances ? inp_importance.flat<TFeat>().data() : nullptr, neighbors_index.shape().dim_size(0), (TIndex*)neighbors_index.flat<TIndex>().data(), has_neighbors_importances ? neighbors_importance.flat<TFeat>().data() : nullptr, (int64_t*)neighbors_row_splits.flat<int64>().data(), extents.flat<TReal>().data(), offset.flat<TReal>().data(), out_features_gradient.flat<TFeat>().data(), this->interpolation, this->coordinate_mapping, this->align_corners, individual_extents, isotropic_extents, this->normalize); } private: int texture_alignment; }; #define REG_KB(feattype, outtype, realtype, indextype) \ REGISTER_KERNEL_BUILDER( \ Name("Open3DContinuousConvBackpropFilter") \ .Device(DEVICE_GPU) \ .TypeConstraint<feattype>("TFeat") \ .TypeConstraint<outtype>("output_type") \ .TypeConstraint<realtype>("TReal") \ .TypeConstraint<indextype>("TIndex"), \ ContinuousConvBackpropFilterOpKernelCUDA<feattype, outtype, \ realtype, indextype>); REG_KB(float, float, float, int32) #undef REG_KB
3ddeb5dff6772739956112d8ab931341caa59a76.cu
// ---------------------------------------------------------------------------- // - Open3D: www.open3d.org - // ---------------------------------------------------------------------------- // The MIT License (MIT) // // Copyright (c) 2018-2021 www.open3d.org // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. // ---------------------------------------------------------------------------- #define EIGEN_USE_GPU #include "ContinuousConvBackpropFilterOpKernel.h" #include "open3d/ml/Helper.h" #include "open3d/ml/impl/continuous_conv/ContinuousConvBackpropFilter.cuh" using namespace open3d; using namespace open3d::ml; using namespace open3d::ml::impl; using namespace tensorflow; template <class TFeat, class TOut, class TReal, class TIndex> class ContinuousConvBackpropFilterOpKernelCUDA : public ContinuousConvBackpropFilterOpKernel<TIndex> { public: explicit ContinuousConvBackpropFilterOpKernelCUDA( OpKernelConstruction* construction) : ContinuousConvBackpropFilterOpKernel<TIndex>(construction) { texture_alignment = GetCUDACurrentDeviceTextureAlignment(); } void Kernel(tensorflow::OpKernelContext* context, const tensorflow::Tensor& filter, const tensorflow::Tensor& out_positions, const tensorflow::Tensor& extents, const tensorflow::Tensor& offset, const tensorflow::Tensor& inp_positions, const tensorflow::Tensor& inp_features, const tensorflow::Tensor& inp_importance, const tensorflow::Tensor& neighbors_index, const tensorflow::Tensor& neighbors_importance, const tensorflow::Tensor& neighbors_row_splits, const tensorflow::Tensor& out_features_gradient, const std::vector<int>& filter_dims, const bool individual_extents, const bool isotropic_extents, const bool point_importances, const bool has_neighbors_importances, tensorflow::Tensor& filter_backprop) { auto device = context->eigen_gpu_device(); void* temp_ptr = nullptr; size_t temp_size = 0; size_t max_temp_size = 0; // determine temp_size CConvBackpropFilterCUDA<TFeat, TOut, TReal, TIndex>( device.stream(), temp_ptr, temp_size, max_temp_size, texture_alignment, filter_backprop.flat<TOut>().data(), filter_dims, out_positions.shape().dim_size(0), out_positions.flat<TReal>().data(), inp_positions.shape().dim_size(0), inp_positions.flat<TReal>().data(), inp_features.flat<TFeat>().data(), point_importances ? inp_importance.flat<TFeat>().data() : nullptr, neighbors_index.shape().dim_size(0), (TIndex*)neighbors_index.flat<TIndex>().data(), has_neighbors_importances ? neighbors_importance.flat<TFeat>().data() : nullptr, (int64_t*)neighbors_row_splits.flat<int64>().data(), extents.flat<TReal>().data(), offset.flat<TReal>().data(), out_features_gradient.flat<TFeat>().data(), this->interpolation, this->coordinate_mapping, this->align_corners, individual_extents, isotropic_extents, this->normalize); temp_size = std::max(std::min(size_t(this->max_temp_mem_MB) * 1024 * 1024, max_temp_size), temp_size); Tensor temp_tensor; TensorShape temp_shape({ssize_t(temp_size)}); OP_REQUIRES_OK(context, context->allocate_temp(DataTypeToEnum<uint8_t>::v(), temp_shape, &temp_tensor)); temp_ptr = temp_tensor.flat<uint8_t>().data(); // actually run the operation CConvBackpropFilterCUDA<TFeat, TOut, TReal, TIndex>( device.stream(), temp_ptr, temp_size, max_temp_size, texture_alignment, filter_backprop.flat<TOut>().data(), filter_dims, out_positions.shape().dim_size(0), out_positions.flat<TReal>().data(), inp_positions.shape().dim_size(0), inp_positions.flat<TReal>().data(), inp_features.flat<TFeat>().data(), point_importances ? inp_importance.flat<TFeat>().data() : nullptr, neighbors_index.shape().dim_size(0), (TIndex*)neighbors_index.flat<TIndex>().data(), has_neighbors_importances ? neighbors_importance.flat<TFeat>().data() : nullptr, (int64_t*)neighbors_row_splits.flat<int64>().data(), extents.flat<TReal>().data(), offset.flat<TReal>().data(), out_features_gradient.flat<TFeat>().data(), this->interpolation, this->coordinate_mapping, this->align_corners, individual_extents, isotropic_extents, this->normalize); } private: int texture_alignment; }; #define REG_KB(feattype, outtype, realtype, indextype) \ REGISTER_KERNEL_BUILDER( \ Name("Open3DContinuousConvBackpropFilter") \ .Device(DEVICE_GPU) \ .TypeConstraint<feattype>("TFeat") \ .TypeConstraint<outtype>("output_type") \ .TypeConstraint<realtype>("TReal") \ .TypeConstraint<indextype>("TIndex"), \ ContinuousConvBackpropFilterOpKernelCUDA<feattype, outtype, \ realtype, indextype>); REG_KB(float, float, float, int32) #undef REG_KB
24fccf0a20e7ee8d6481cf64594c2c2cc3a6d7a8.hip
// !!! This is a file automatically generated by hipify!!! #include "cudaDebug.h" #include "stdio.h" #include "string.h" #include "hip/hip_runtime.h" #include <hip/hip_runtime_api.h> void gpuAssert(hipError_t code, const char *file, int line, bool abort) { if (code != hipSuccess) { fprintf(stdout,"GPUassert: %s %s %d\n", hipGetErrorString(code), file, line); if (abort) exit(code); } } void cudaMemoryTest(const char *file, int line) { const unsigned int N = 1048576; const unsigned int bytes = N * sizeof(int); int *h_a = (int*)malloc(bytes); int *d_a; gpuAssert(hipMalloc(&d_a, bytes), file, line); memset(h_a, 0, bytes); gpuAssert(hipMemcpy(d_a, h_a, bytes, hipMemcpyHostToDevice), file, line); gpuAssert(hipMemcpy(h_a, d_a, bytes, hipMemcpyDeviceToHost), file, line); }
24fccf0a20e7ee8d6481cf64594c2c2cc3a6d7a8.cu
#include "cudaDebug.h" #include "stdio.h" #include "string.h" #include "cuda.h" #include <cuda_runtime_api.h> void gpuAssert(cudaError_t code, const char *file, int line, bool abort) { if (code != cudaSuccess) { fprintf(stdout,"GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line); if (abort) exit(code); } } void cudaMemoryTest(const char *file, int line) { const unsigned int N = 1048576; const unsigned int bytes = N * sizeof(int); int *h_a = (int*)malloc(bytes); int *d_a; gpuAssert(cudaMalloc(&d_a, bytes), file, line); memset(h_a, 0, bytes); gpuAssert(cudaMemcpy(d_a, h_a, bytes, cudaMemcpyHostToDevice), file, line); gpuAssert(cudaMemcpy(h_a, d_a, bytes, cudaMemcpyDeviceToHost), file, line); }
4ab4f6b06b62c6e36e033a5b43886d8b8dfac5c2.hip
// !!! This is a file automatically generated by hipify!!! // Copyright (c) 2017-2018 Uber Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include <hip/hip_runtime.h> #include <hip/hip_runtime_api.h> #include <rmm/rmm.h> #include <rmm/rmm_api.h> #include <cstdio> #include <cstring> #include "../memory.h" // checkCUDAError checks the cuda error of last runtime calls and returns the // pointer to the buffer of error message. This buffer needs to be released // by caller or upper callers. char *checkCUDAError(const char *message) { hipError_t error = hipGetLastError(); if (error != hipSuccess) { char *buffer = reinterpret_cast<char *>(malloc(MAX_ERROR_LEN)); snprintf(buffer, MAX_ERROR_LEN, "ERROR when calling CUDA functions from host: %s: %s\n", message, hipGetErrorString(error)); return buffer; } return NULL; } char *checkRMMError(rmmError_t rmmError, const char* message) { if (rmmError != RMM_SUCCESS) { char *buffer = reinterpret_cast<char *>(malloc(MAX_ERROR_LEN)); snprintf(buffer, MAX_ERROR_LEN, "ERROR when calling RMM functions: %s: %s\n", message, rmmGetErrorString(rmmError)); return buffer; } return NULL; } // init_helper is purely for running some initializing code before main // is running. If this logic is required in multiple place, we may consider // wrap it with a macro. struct init_helper { static int init_flag; // init rmm manager with rmmOptions. static int init() { CGoCallResHandle resHandle = GetDeviceCount(); if (resHandle.pStrErr != nullptr) { throw std::runtime_error(const_cast<char *>(resHandle.pStrErr)); } size_t deviceCount = reinterpret_cast<size_t>(resHandle.res); for (size_t device = 0; device < deviceCount; device++) { hipSetDevice(device); rmmOptions_t options = { CudaDefaultAllocation, // Use PoolAllocation when RMM has improved // their sub allocator. 0, // Default to half ot total memory false // Disable logging. }; resHandle.pStrErr = checkRMMError(rmmInitialize(&options), "rmmInitialize"); if (resHandle.pStrErr != nullptr) { throw std::runtime_error(const_cast<char *>(resHandle.pStrErr)); } } return 0; } }; int init_helper::init_flag = init(); DeviceMemoryFlags GetFlags() { DeviceMemoryFlags flags = DEVICE_MEMORY_IMPLEMENTATION_FLAG | POOLED_MEMORY_FLAG; #ifdef SUPPORT_HASH_REDUCTION flags |= HASH_REDUCTION_SUPPORT; #endif return flags; } CGoCallResHandle DeviceAllocate(size_t bytes, int device) { CGoCallResHandle resHandle = {NULL, NULL}; hipSetDevice(device); // For now use default stream to avoid changing the memory allocation // interface. // TODO(lucafuji): use the stream of current execution pipeline for // allocation and free. resHandle.pStrErr = checkRMMError(RMM_ALLOC(&resHandle.res, bytes, 0), "DeviceAllocate"); if (resHandle.pStrErr == nullptr) { hipMemset(resHandle.res, 0, bytes); resHandle.pStrErr = checkCUDAError("DeviceAllocate"); } return resHandle; } CGoCallResHandle DeviceFree(void *p, int device) { CGoCallResHandle resHandle = {NULL, NULL}; hipSetDevice(device); // For now use default stream to avoid changing the memory allocation // interface. // TODO(lucafuji): use the stream of current execution pipeline for // allocation and free. resHandle.pStrErr = checkRMMError(RMM_FREE(p, 0), "DeviceFree"); return resHandle; } // All following function implementation is the same as cuda_malloc.cu. // We might remove cuda_malloc.cu file after RMM is proven to be working // in production environment CGoCallResHandle HostAlloc(size_t bytes) { CGoCallResHandle resHandle = {NULL, NULL}; // hipHostMallocPortable makes sure that the allocation is associated with all // devices, not just the current device. hipHostMalloc(&resHandle.res, bytes, hipHostMallocPortable); memset(resHandle.res, 0, bytes); resHandle.pStrErr = checkCUDAError("Allocate"); return resHandle; } CGoCallResHandle HostFree(void *p) { CGoCallResHandle resHandle = {NULL, NULL}; hipHostFree(p); resHandle.pStrErr = checkCUDAError("Free"); return resHandle; } CGoCallResHandle HostMemCpy(void *dst, const void* src, size_t bytes) { CGoCallResHandle resHandle = {NULL, NULL}; void* ptr = memcpy(dst, src, bytes); if (ptr != dst) { resHandle.pStrErr = fmtError("HostMemCpy", "Returned pointer does not match destination"); } return resHandle; } CGoCallResHandle CreateCudaStream(int device) { CGoCallResHandle resHandle = {NULL, NULL}; hipSetDevice(device); hipStream_t s = NULL; hipStreamCreate(&s); resHandle.res = reinterpret_cast<void *>(s); resHandle.pStrErr = checkCUDAError("CreateCudaStream"); return resHandle; } CGoCallResHandle WaitForCudaStream(void *s, int device) { CGoCallResHandle resHandle = {NULL, NULL}; hipSetDevice(device); hipStreamSynchronize((hipStream_t) s); resHandle.pStrErr = checkCUDAError("WaitForCudaStream"); return resHandle; } CGoCallResHandle DestroyCudaStream(void *s, int device) { CGoCallResHandle resHandle = {NULL, NULL}; hipSetDevice(device); hipStreamDestroy((hipStream_t) s); resHandle.pStrErr = checkCUDAError("DestroyCudaStream"); return resHandle; } CGoCallResHandle AsyncCopyHostToDevice( void *dst, void *src, size_t bytes, void *stream, int device) { CGoCallResHandle resHandle = {NULL, NULL}; hipSetDevice(device); hipMemcpyAsync(dst, src, bytes, hipMemcpyHostToDevice, (hipStream_t) stream); resHandle.pStrErr = checkCUDAError("AsyncCopyHostToDevice"); return resHandle; } CGoCallResHandle AsyncCopyDeviceToDevice( void *dst, void *src, size_t bytes, void *stream, int device) { CGoCallResHandle resHandle = {NULL, NULL}; hipSetDevice(device); hipMemcpyAsync(dst, src, bytes, hipMemcpyDeviceToDevice, (hipStream_t) stream); resHandle.pStrErr = checkCUDAError("AsyncCopyDeviceToDevice"); return resHandle; } CGoCallResHandle AsyncCopyDeviceToHost( void *dst, void *src, size_t bytes, void *stream, int device) { CGoCallResHandle resHandle = {NULL, NULL}; hipSetDevice(device); hipMemcpyAsync(dst, src, bytes, hipMemcpyDeviceToHost, (hipStream_t) stream); resHandle.pStrErr = checkCUDAError("AsyncCopyDeviceToHost"); return resHandle; } CGoCallResHandle GetDeviceCount() { CGoCallResHandle resHandle = {NULL, NULL}; hipGetDeviceCount(reinterpret_cast<int *>(&resHandle.res)); resHandle.pStrErr = checkCUDAError("GetDeviceCount"); return resHandle; } CGoCallResHandle GetDeviceGlobalMemoryInMB(int device) { CGoCallResHandle resHandle = {NULL, NULL}; hipDeviceProp_t prop; hipGetDeviceProperties(&prop, device); resHandle.res = reinterpret_cast<void *>(prop.totalGlobalMem / (1024 * 1024)); resHandle.pStrErr = checkCUDAError("GetDeviceGlobalMemoryInMB"); return resHandle; } CGoCallResHandle CudaProfilerStart() { CGoCallResHandle resHandle = {NULL, NULL}; hipProfilerStart(); resHandle.pStrErr = checkCUDAError("hipProfilerStart"); return resHandle; } CGoCallResHandle CudaProfilerStop() { CGoCallResHandle resHandle = {NULL, NULL}; hipDeviceSynchronize(); hipProfilerStop(); resHandle.pStrErr = checkCUDAError("hipProfilerStop"); return resHandle; } CGoCallResHandle GetDeviceMemoryInfo(size_t *freeSize, size_t *totalSize, int device) { CGoCallResHandle resHandle = {NULL, NULL}; hipSetDevice(device); resHandle.pStrErr = checkRMMError(rmmGetInfo(freeSize, totalSize, 0), "GetDeviceMemoryInfo"); return resHandle; } CGoCallResHandle deviceMalloc(void **devPtr, size_t size) { CGoCallResHandle resHandle = {NULL, NULL}; // For now use default stream to avoid changing the memory allocation // interface. // TODO(lucafuji): use the stream of current execution pipeline for // allocation and free. resHandle.pStrErr = checkRMMError(RMM_ALLOC(devPtr, size, 0), "deviceMalloc"); return resHandle; } CGoCallResHandle deviceFree(void *devPtr) { CGoCallResHandle resHandle = {NULL, NULL}; // For now use default stream to avoid changing the memory allocation // interface. // TODO(lucafuji): use the stream of current execution pipeline for // allocation and free. resHandle.pStrErr = checkRMMError(RMM_FREE(devPtr, 0), "deviceFree"); return resHandle; } CGoCallResHandle deviceMemset(void *devPtr, int value, size_t count) { CGoCallResHandle resHandle = {NULL, NULL}; hipMemset(devPtr, value, count); resHandle.pStrErr = checkCUDAError("deviceMemset"); return resHandle; } CGoCallResHandle asyncCopyHostToDevice(void* dst, const void* src, size_t count, void* stream) { CGoCallResHandle resHandle = {NULL, NULL}; hipMemcpyAsync(dst, src, count, hipMemcpyHostToDevice, (hipStream_t) stream); resHandle.pStrErr = checkCUDAError("asyncCopyHostToDevice"); return resHandle; } CGoCallResHandle asyncCopyDeviceToHost(void* dst, const void* src, size_t count, void* stream) { CGoCallResHandle resHandle = {NULL, NULL}; hipMemcpyAsync(dst, src, count, hipMemcpyDeviceToHost, (hipStream_t) stream); resHandle.pStrErr = checkCUDAError("asyncCopyDeviceToHost"); return resHandle; } CGoCallResHandle waitForCudaStream(void *stream) { CGoCallResHandle resHandle = {NULL, NULL}; hipStreamSynchronize((hipStream_t) stream); resHandle.pStrErr = checkCUDAError("waitForCudaStream"); return resHandle; }
4ab4f6b06b62c6e36e033a5b43886d8b8dfac5c2.cu
// Copyright (c) 2017-2018 Uber Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include <cuda_runtime.h> #include <cuda_profiler_api.h> #include <rmm/rmm.h> #include <rmm/rmm_api.h> #include <cstdio> #include <cstring> #include "../memory.h" // checkCUDAError checks the cuda error of last runtime calls and returns the // pointer to the buffer of error message. This buffer needs to be released // by caller or upper callers. char *checkCUDAError(const char *message) { cudaError_t error = cudaGetLastError(); if (error != cudaSuccess) { char *buffer = reinterpret_cast<char *>(malloc(MAX_ERROR_LEN)); snprintf(buffer, MAX_ERROR_LEN, "ERROR when calling CUDA functions from host: %s: %s\n", message, cudaGetErrorString(error)); return buffer; } return NULL; } char *checkRMMError(rmmError_t rmmError, const char* message) { if (rmmError != RMM_SUCCESS) { char *buffer = reinterpret_cast<char *>(malloc(MAX_ERROR_LEN)); snprintf(buffer, MAX_ERROR_LEN, "ERROR when calling RMM functions: %s: %s\n", message, rmmGetErrorString(rmmError)); return buffer; } return NULL; } // init_helper is purely for running some initializing code before main // is running. If this logic is required in multiple place, we may consider // wrap it with a macro. struct init_helper { static int init_flag; // init rmm manager with rmmOptions. static int init() { CGoCallResHandle resHandle = GetDeviceCount(); if (resHandle.pStrErr != nullptr) { throw std::runtime_error(const_cast<char *>(resHandle.pStrErr)); } size_t deviceCount = reinterpret_cast<size_t>(resHandle.res); for (size_t device = 0; device < deviceCount; device++) { cudaSetDevice(device); rmmOptions_t options = { CudaDefaultAllocation, // Use PoolAllocation when RMM has improved // their sub allocator. 0, // Default to half ot total memory false // Disable logging. }; resHandle.pStrErr = checkRMMError(rmmInitialize(&options), "rmmInitialize"); if (resHandle.pStrErr != nullptr) { throw std::runtime_error(const_cast<char *>(resHandle.pStrErr)); } } return 0; } }; int init_helper::init_flag = init(); DeviceMemoryFlags GetFlags() { DeviceMemoryFlags flags = DEVICE_MEMORY_IMPLEMENTATION_FLAG | POOLED_MEMORY_FLAG; #ifdef SUPPORT_HASH_REDUCTION flags |= HASH_REDUCTION_SUPPORT; #endif return flags; } CGoCallResHandle DeviceAllocate(size_t bytes, int device) { CGoCallResHandle resHandle = {NULL, NULL}; cudaSetDevice(device); // For now use default stream to avoid changing the memory allocation // interface. // TODO(lucafuji): use the stream of current execution pipeline for // allocation and free. resHandle.pStrErr = checkRMMError(RMM_ALLOC(&resHandle.res, bytes, 0), "DeviceAllocate"); if (resHandle.pStrErr == nullptr) { cudaMemset(resHandle.res, 0, bytes); resHandle.pStrErr = checkCUDAError("DeviceAllocate"); } return resHandle; } CGoCallResHandle DeviceFree(void *p, int device) { CGoCallResHandle resHandle = {NULL, NULL}; cudaSetDevice(device); // For now use default stream to avoid changing the memory allocation // interface. // TODO(lucafuji): use the stream of current execution pipeline for // allocation and free. resHandle.pStrErr = checkRMMError(RMM_FREE(p, 0), "DeviceFree"); return resHandle; } // All following function implementation is the same as cuda_malloc.cu. // We might remove cuda_malloc.cu file after RMM is proven to be working // in production environment CGoCallResHandle HostAlloc(size_t bytes) { CGoCallResHandle resHandle = {NULL, NULL}; // cudaHostAllocPortable makes sure that the allocation is associated with all // devices, not just the current device. cudaHostAlloc(&resHandle.res, bytes, cudaHostAllocPortable); memset(resHandle.res, 0, bytes); resHandle.pStrErr = checkCUDAError("Allocate"); return resHandle; } CGoCallResHandle HostFree(void *p) { CGoCallResHandle resHandle = {NULL, NULL}; cudaFreeHost(p); resHandle.pStrErr = checkCUDAError("Free"); return resHandle; } CGoCallResHandle HostMemCpy(void *dst, const void* src, size_t bytes) { CGoCallResHandle resHandle = {NULL, NULL}; void* ptr = memcpy(dst, src, bytes); if (ptr != dst) { resHandle.pStrErr = fmtError("HostMemCpy", "Returned pointer does not match destination"); } return resHandle; } CGoCallResHandle CreateCudaStream(int device) { CGoCallResHandle resHandle = {NULL, NULL}; cudaSetDevice(device); cudaStream_t s = NULL; cudaStreamCreate(&s); resHandle.res = reinterpret_cast<void *>(s); resHandle.pStrErr = checkCUDAError("CreateCudaStream"); return resHandle; } CGoCallResHandle WaitForCudaStream(void *s, int device) { CGoCallResHandle resHandle = {NULL, NULL}; cudaSetDevice(device); cudaStreamSynchronize((cudaStream_t) s); resHandle.pStrErr = checkCUDAError("WaitForCudaStream"); return resHandle; } CGoCallResHandle DestroyCudaStream(void *s, int device) { CGoCallResHandle resHandle = {NULL, NULL}; cudaSetDevice(device); cudaStreamDestroy((cudaStream_t) s); resHandle.pStrErr = checkCUDAError("DestroyCudaStream"); return resHandle; } CGoCallResHandle AsyncCopyHostToDevice( void *dst, void *src, size_t bytes, void *stream, int device) { CGoCallResHandle resHandle = {NULL, NULL}; cudaSetDevice(device); cudaMemcpyAsync(dst, src, bytes, cudaMemcpyHostToDevice, (cudaStream_t) stream); resHandle.pStrErr = checkCUDAError("AsyncCopyHostToDevice"); return resHandle; } CGoCallResHandle AsyncCopyDeviceToDevice( void *dst, void *src, size_t bytes, void *stream, int device) { CGoCallResHandle resHandle = {NULL, NULL}; cudaSetDevice(device); cudaMemcpyAsync(dst, src, bytes, cudaMemcpyDeviceToDevice, (cudaStream_t) stream); resHandle.pStrErr = checkCUDAError("AsyncCopyDeviceToDevice"); return resHandle; } CGoCallResHandle AsyncCopyDeviceToHost( void *dst, void *src, size_t bytes, void *stream, int device) { CGoCallResHandle resHandle = {NULL, NULL}; cudaSetDevice(device); cudaMemcpyAsync(dst, src, bytes, cudaMemcpyDeviceToHost, (cudaStream_t) stream); resHandle.pStrErr = checkCUDAError("AsyncCopyDeviceToHost"); return resHandle; } CGoCallResHandle GetDeviceCount() { CGoCallResHandle resHandle = {NULL, NULL}; cudaGetDeviceCount(reinterpret_cast<int *>(&resHandle.res)); resHandle.pStrErr = checkCUDAError("GetDeviceCount"); return resHandle; } CGoCallResHandle GetDeviceGlobalMemoryInMB(int device) { CGoCallResHandle resHandle = {NULL, NULL}; cudaDeviceProp prop; cudaGetDeviceProperties(&prop, device); resHandle.res = reinterpret_cast<void *>(prop.totalGlobalMem / (1024 * 1024)); resHandle.pStrErr = checkCUDAError("GetDeviceGlobalMemoryInMB"); return resHandle; } CGoCallResHandle CudaProfilerStart() { CGoCallResHandle resHandle = {NULL, NULL}; cudaProfilerStart(); resHandle.pStrErr = checkCUDAError("cudaProfilerStart"); return resHandle; } CGoCallResHandle CudaProfilerStop() { CGoCallResHandle resHandle = {NULL, NULL}; cudaDeviceSynchronize(); cudaProfilerStop(); resHandle.pStrErr = checkCUDAError("cudaProfilerStop"); return resHandle; } CGoCallResHandle GetDeviceMemoryInfo(size_t *freeSize, size_t *totalSize, int device) { CGoCallResHandle resHandle = {NULL, NULL}; cudaSetDevice(device); resHandle.pStrErr = checkRMMError(rmmGetInfo(freeSize, totalSize, 0), "GetDeviceMemoryInfo"); return resHandle; } CGoCallResHandle deviceMalloc(void **devPtr, size_t size) { CGoCallResHandle resHandle = {NULL, NULL}; // For now use default stream to avoid changing the memory allocation // interface. // TODO(lucafuji): use the stream of current execution pipeline for // allocation and free. resHandle.pStrErr = checkRMMError(RMM_ALLOC(devPtr, size, 0), "deviceMalloc"); return resHandle; } CGoCallResHandle deviceFree(void *devPtr) { CGoCallResHandle resHandle = {NULL, NULL}; // For now use default stream to avoid changing the memory allocation // interface. // TODO(lucafuji): use the stream of current execution pipeline for // allocation and free. resHandle.pStrErr = checkRMMError(RMM_FREE(devPtr, 0), "deviceFree"); return resHandle; } CGoCallResHandle deviceMemset(void *devPtr, int value, size_t count) { CGoCallResHandle resHandle = {NULL, NULL}; cudaMemset(devPtr, value, count); resHandle.pStrErr = checkCUDAError("deviceMemset"); return resHandle; } CGoCallResHandle asyncCopyHostToDevice(void* dst, const void* src, size_t count, void* stream) { CGoCallResHandle resHandle = {NULL, NULL}; cudaMemcpyAsync(dst, src, count, cudaMemcpyHostToDevice, (cudaStream_t) stream); resHandle.pStrErr = checkCUDAError("asyncCopyHostToDevice"); return resHandle; } CGoCallResHandle asyncCopyDeviceToHost(void* dst, const void* src, size_t count, void* stream) { CGoCallResHandle resHandle = {NULL, NULL}; cudaMemcpyAsync(dst, src, count, cudaMemcpyDeviceToHost, (cudaStream_t) stream); resHandle.pStrErr = checkCUDAError("asyncCopyDeviceToHost"); return resHandle; } CGoCallResHandle waitForCudaStream(void *stream) { CGoCallResHandle resHandle = {NULL, NULL}; cudaStreamSynchronize((cudaStream_t) stream); resHandle.pStrErr = checkCUDAError("waitForCudaStream"); return resHandle; }
397cf3f07acf6674906e7550d7f070104574b979.hip
// !!! This is a file automatically generated by hipify!!! #ifdef ENABLE_CURD #include<curd_lib_host.h> #else #endif #ifdef ENABLE_CURD #define CURD_ALLOC(a, b) allocateReadWriteSets(a, b) #define CURD_FREE(a, b) freeReadWriteSets(a, b) #else #define CURD_ALLOC(a, b) #define CURD_FREE(a, b) #endif /****************************************************************************** * Copyright (c) 2011, Duane Merrill. All rights reserved. * Copyright (c) 2011-2016, NVIDIA CORPORATION. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the NVIDIA CORPORATION nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ******************************************************************************/ /****************************************************************************** * Simple example of DeviceHistogram::MultiChannelSharedAtomic(). * * Computes three 256-bin RGB histograms from quad-channel pixels (interleaved * 8b RGBA samples) using an algorithm based upon shared-memory atomic instructions. * * To compile using the command line: * nvcc -arch=sm_XX example_device_histogram.cu -I../.. -lcudart -O3 * ******************************************************************************/ // Ensure printing of CUDA runtime errors to console #define CUB_STDERR #include <stdio.h> #include <limits> #include <hipcub/hipcub.hpp> #include <cub/iterator/tex_ref_input_iterator.cuh> #include <cub/device/device_histogram.cuh> #include "test_util.h" using namespace cub; //--------------------------------------------------------------------- // Globals, constants and typedefs //--------------------------------------------------------------------- bool g_verbose = false; // Whether to display input/output to console CachingDeviceAllocator g_allocator(true); // Caching allocator for device memory //--------------------------------------------------------------------- // Test generation //--------------------------------------------------------------------- /** * Initialize problem (and solution) */ template < int BINS, int CHANNELS, int ACTIVE_CHANNELS> void Initialize( unsigned char *h_samples, int h_histograms[ACTIVE_CHANNELS][BINS], int num_pixels) { // Init bins for (int channel = 0; channel < ACTIVE_CHANNELS; ++channel) for (int bin = 0; bin < BINS; ++bin) h_histograms[channel][bin] = 0; if (g_verbose) printf("Samples: \n"); // Initialize interleaved channel samples and histogram them correspondingly for (int i = 0; i < num_pixels * CHANNELS; i += CHANNELS) { if (g_verbose) std::cout << "<"; for (int channel = 0; channel < ACTIVE_CHANNELS; ++channel) { RandomBits(h_samples[i + channel]); h_histograms[channel][h_samples[i + channel]]++; if (g_verbose) { std::cout << int(h_samples[i + channel]); if (channel < CHANNELS - 1) std::cout << ","; } } for (int channel = ACTIVE_CHANNELS; channel < CHANNELS; ++channel) { RandomBits(h_samples[i + channel]); if (g_verbose) { std::cout << int(h_samples[i + channel]); if (channel < CHANNELS - 1) std::cout << ","; } } if (g_verbose) std::cout << "> "; } if (g_verbose) printf("\n\n"); } //--------------------------------------------------------------------- // Main //--------------------------------------------------------------------- /** * Main */ int main(int argc, char** argv) { const int CHANNELS = 4; /// Four interleaved RGBA 8b samples per pixel const int ACTIVE_CHANNELS = 3; /// We want histograms for only RGB channels const int BINS = 256; /// 256 bins per sample int num_pixels = 150; // Initialize command line CommandLineArgs args(argc, argv); g_verbose = args.CheckCmdLineFlag("v"); bool quick = args.CheckCmdLineFlag("quick"); args.GetCmdLineArgument("n", num_pixels); // Print usage if (args.CheckCmdLineFlag("help")) { printf("%s " "[--n=<number of RGBA pixels> " "[--device=<device-id>] " "[--v] " "\n", argv[0]); exit(0); } // Initialize device CubDebugExit(args.DeviceInit()); int num_samples = num_pixels * CHANNELS; printf("cub::DeviceHistogram::MultiChannelSharedAtomic() RGB histograms from %d RGBA pixels (%d %d-byte channel samples)\n", num_pixels, num_samples, (int) sizeof(unsigned char)); fflush(stdout); int total_bins = ACTIVE_CHANNELS * BINS; // Allocate host arrays unsigned char *h_samples = new unsigned char[num_samples]; int h_histograms[ACTIVE_CHANNELS][BINS]; // Initialize problem Initialize<BINS, CHANNELS, ACTIVE_CHANNELS>(h_samples, h_histograms, num_pixels); // Allocate problem device arrays unsigned char *d_samples = NULL; int *d_histograms_linear = NULL; CubDebugExit(g_allocator.DeviceAllocate((void**)&d_samples, sizeof(unsigned char) * num_samples)); CubDebugExit(g_allocator.DeviceAllocate((void**)&d_histograms_linear, sizeof(int) * total_bins)); // Initialize device arrays CubDebugExit(hipMemcpy(d_samples, h_samples, sizeof(unsigned char) * num_samples, hipMemcpyHostToDevice)); // Structure of channel histograms int *d_histograms[ACTIVE_CHANNELS]; for (int CHANNEL = 0; CHANNEL < ACTIVE_CHANNELS; ++CHANNEL) d_histograms[CHANNEL] = d_histograms_linear + (CHANNEL * BINS); // Texture iterator type for loading samples through tex TexRefInputIterator<unsigned char, __LINE__, int> d_sample_itr; CubDebugExit(d_sample_itr.BindTexture(d_samples, sizeof(unsigned char) * num_samples)); // Allocate temporary storage void *d_temp_storage = NULL; size_t temp_storage_bytes = 0; CubDebugExit((DeviceHistogram::MultiChannelSharedAtomic<BINS, CHANNELS, ACTIVE_CHANNELS>(d_temp_storage, temp_storage_bytes, d_sample_itr, d_histograms, num_samples))); CubDebugExit(g_allocator.DeviceAllocate(&d_temp_storage, temp_storage_bytes)); // Run CubDebugExit((DeviceHistogram::MultiChannelSharedAtomic<BINS, CHANNELS, ACTIVE_CHANNELS>(d_temp_storage, temp_storage_bytes, d_sample_itr, d_histograms, num_samples))); // Check for correctness (and display results, if specified) printf("R channel: "); int compare = CompareDeviceResults(h_histograms[0], d_histograms[0], BINS, g_verbose, g_verbose); printf("%s\n", compare ? "FAIL" : "PASS"); AssertEquals(0, compare); printf("G channel: "); compare = CompareDeviceResults(h_histograms[1], d_histograms[1], BINS, g_verbose, g_verbose); printf("%s\n", compare ? "FAIL" : "PASS"); AssertEquals(0, compare); printf("B channel: "); compare = CompareDeviceResults(h_histograms[2], d_histograms[2], BINS, g_verbose, g_verbose); printf("%s\n", compare ? "FAIL" : "PASS"); AssertEquals(0, compare); // Cleanup CubDebugExit(d_sample_itr.UnbindTexture()); if (h_samples) delete[] h_samples; if (d_samples) CubDebugExit(g_allocator.DeviceFree(d_samples)); if (d_histograms_linear) CubDebugExit(g_allocator.DeviceFree(d_histograms_linear)); if (d_temp_storage) CubDebugExit(g_allocator.DeviceFree(d_temp_storage)); printf("\n\n"); return 0; }
397cf3f07acf6674906e7550d7f070104574b979.cu
#ifdef ENABLE_CURD #include<curd_lib_host.h> #else #endif #ifdef ENABLE_CURD #define CURD_ALLOC(a, b) allocateReadWriteSets(a, b) #define CURD_FREE(a, b) freeReadWriteSets(a, b) #else #define CURD_ALLOC(a, b) #define CURD_FREE(a, b) #endif /****************************************************************************** * Copyright (c) 2011, Duane Merrill. All rights reserved. * Copyright (c) 2011-2016, NVIDIA CORPORATION. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the NVIDIA CORPORATION nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ******************************************************************************/ /****************************************************************************** * Simple example of DeviceHistogram::MultiChannelSharedAtomic(). * * Computes three 256-bin RGB histograms from quad-channel pixels (interleaved * 8b RGBA samples) using an algorithm based upon shared-memory atomic instructions. * * To compile using the command line: * nvcc -arch=sm_XX example_device_histogram.cu -I../.. -lcudart -O3 * ******************************************************************************/ // Ensure printing of CUDA runtime errors to console #define CUB_STDERR #include <stdio.h> #include <limits> #include <cub/util_allocator.cuh> #include <cub/iterator/tex_ref_input_iterator.cuh> #include <cub/device/device_histogram.cuh> #include "test_util.h" using namespace cub; //--------------------------------------------------------------------- // Globals, constants and typedefs //--------------------------------------------------------------------- bool g_verbose = false; // Whether to display input/output to console CachingDeviceAllocator g_allocator(true); // Caching allocator for device memory //--------------------------------------------------------------------- // Test generation //--------------------------------------------------------------------- /** * Initialize problem (and solution) */ template < int BINS, int CHANNELS, int ACTIVE_CHANNELS> void Initialize( unsigned char *h_samples, int h_histograms[ACTIVE_CHANNELS][BINS], int num_pixels) { // Init bins for (int channel = 0; channel < ACTIVE_CHANNELS; ++channel) for (int bin = 0; bin < BINS; ++bin) h_histograms[channel][bin] = 0; if (g_verbose) printf("Samples: \n"); // Initialize interleaved channel samples and histogram them correspondingly for (int i = 0; i < num_pixels * CHANNELS; i += CHANNELS) { if (g_verbose) std::cout << "<"; for (int channel = 0; channel < ACTIVE_CHANNELS; ++channel) { RandomBits(h_samples[i + channel]); h_histograms[channel][h_samples[i + channel]]++; if (g_verbose) { std::cout << int(h_samples[i + channel]); if (channel < CHANNELS - 1) std::cout << ","; } } for (int channel = ACTIVE_CHANNELS; channel < CHANNELS; ++channel) { RandomBits(h_samples[i + channel]); if (g_verbose) { std::cout << int(h_samples[i + channel]); if (channel < CHANNELS - 1) std::cout << ","; } } if (g_verbose) std::cout << "> "; } if (g_verbose) printf("\n\n"); } //--------------------------------------------------------------------- // Main //--------------------------------------------------------------------- /** * Main */ int main(int argc, char** argv) { const int CHANNELS = 4; /// Four interleaved RGBA 8b samples per pixel const int ACTIVE_CHANNELS = 3; /// We want histograms for only RGB channels const int BINS = 256; /// 256 bins per sample int num_pixels = 150; // Initialize command line CommandLineArgs args(argc, argv); g_verbose = args.CheckCmdLineFlag("v"); bool quick = args.CheckCmdLineFlag("quick"); args.GetCmdLineArgument("n", num_pixels); // Print usage if (args.CheckCmdLineFlag("help")) { printf("%s " "[--n=<number of RGBA pixels> " "[--device=<device-id>] " "[--v] " "\n", argv[0]); exit(0); } // Initialize device CubDebugExit(args.DeviceInit()); int num_samples = num_pixels * CHANNELS; printf("cub::DeviceHistogram::MultiChannelSharedAtomic() RGB histograms from %d RGBA pixels (%d %d-byte channel samples)\n", num_pixels, num_samples, (int) sizeof(unsigned char)); fflush(stdout); int total_bins = ACTIVE_CHANNELS * BINS; // Allocate host arrays unsigned char *h_samples = new unsigned char[num_samples]; int h_histograms[ACTIVE_CHANNELS][BINS]; // Initialize problem Initialize<BINS, CHANNELS, ACTIVE_CHANNELS>(h_samples, h_histograms, num_pixels); // Allocate problem device arrays unsigned char *d_samples = NULL; int *d_histograms_linear = NULL; CubDebugExit(g_allocator.DeviceAllocate((void**)&d_samples, sizeof(unsigned char) * num_samples)); CubDebugExit(g_allocator.DeviceAllocate((void**)&d_histograms_linear, sizeof(int) * total_bins)); // Initialize device arrays CubDebugExit(cudaMemcpy(d_samples, h_samples, sizeof(unsigned char) * num_samples, cudaMemcpyHostToDevice)); // Structure of channel histograms int *d_histograms[ACTIVE_CHANNELS]; for (int CHANNEL = 0; CHANNEL < ACTIVE_CHANNELS; ++CHANNEL) d_histograms[CHANNEL] = d_histograms_linear + (CHANNEL * BINS); // Texture iterator type for loading samples through tex TexRefInputIterator<unsigned char, __LINE__, int> d_sample_itr; CubDebugExit(d_sample_itr.BindTexture(d_samples, sizeof(unsigned char) * num_samples)); // Allocate temporary storage void *d_temp_storage = NULL; size_t temp_storage_bytes = 0; CubDebugExit((DeviceHistogram::MultiChannelSharedAtomic<BINS, CHANNELS, ACTIVE_CHANNELS>(d_temp_storage, temp_storage_bytes, d_sample_itr, d_histograms, num_samples))); CubDebugExit(g_allocator.DeviceAllocate(&d_temp_storage, temp_storage_bytes)); // Run CubDebugExit((DeviceHistogram::MultiChannelSharedAtomic<BINS, CHANNELS, ACTIVE_CHANNELS>(d_temp_storage, temp_storage_bytes, d_sample_itr, d_histograms, num_samples))); // Check for correctness (and display results, if specified) printf("R channel: "); int compare = CompareDeviceResults(h_histograms[0], d_histograms[0], BINS, g_verbose, g_verbose); printf("%s\n", compare ? "FAIL" : "PASS"); AssertEquals(0, compare); printf("G channel: "); compare = CompareDeviceResults(h_histograms[1], d_histograms[1], BINS, g_verbose, g_verbose); printf("%s\n", compare ? "FAIL" : "PASS"); AssertEquals(0, compare); printf("B channel: "); compare = CompareDeviceResults(h_histograms[2], d_histograms[2], BINS, g_verbose, g_verbose); printf("%s\n", compare ? "FAIL" : "PASS"); AssertEquals(0, compare); // Cleanup CubDebugExit(d_sample_itr.UnbindTexture()); if (h_samples) delete[] h_samples; if (d_samples) CubDebugExit(g_allocator.DeviceFree(d_samples)); if (d_histograms_linear) CubDebugExit(g_allocator.DeviceFree(d_histograms_linear)); if (d_temp_storage) CubDebugExit(g_allocator.DeviceFree(d_temp_storage)); printf("\n\n"); return 0; }
14f5d265fc2df02f6671428fb9e3b9d988e60ea8.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" // 10,000 threads incrementing 10 array elements // We need to avoid the conflicts #include <stdio.h> //#include "gputimer.h" #define NUM_THREADS 1000 #define ARRAY_SIZE 10 #define BLOCK_WIDTH 100 void print_array(int* array, int size) { for(int i(0); i < size ; ++i) { printf("%d \t", array[i]); } } __global__ void increment_naive(int* g) { // thread index int i = blockIdx.x * blockDim.x + threadIdx.x; // map it to the array_size i = i % ARRAY_SIZE; //g[i] = g[i] + 1; -> do not do this atomicAdd(&g[i], 1); } int main() { //Gputimer timer; printf("%d total threads in %d blocks writing into %d array element \t", NUM_THREADS, NUM_THREADS / BLOCK_WIDTH, ARRAY_SIZE); // declare and allocate host memory int h_array[ARRAY_SIZE]; const int ARRAY_BYTES = ARRAY_SIZE * sizeof(int); // declare, allocate, and zero-oout GPU memory int* d_array; hipMalloc((void**) &d_array, ARRAY_BYTES); hipMemset((void*) d_array, 0, ARRAY_BYTES); // launch kernel //dim3 gridSize = (NUM_THREADS/BLOCK_WIDTH, 1, 1); //dim3 blockSize = (BLOCK_WIDTH, 1, 1); //timer.Start(); hipLaunchKernelGGL(( increment_naive), dim3(NUM_THREADS/BLOCK_WIDTH), dim3(BLOCK_WIDTH), 0, 0, d_array); //timer.Stop(); // copy back from the GPU memory to CPU memory hipMemcpy(h_array, d_array, ARRAY_BYTES, hipMemcpyDeviceToHost); print_array(h_array, ARRAY_SIZE); // check time //printf("Time elapsed = %g ms \n", timer.Elapsed()); // free cuda memory hipFree(d_array); return 0; }
14f5d265fc2df02f6671428fb9e3b9d988e60ea8.cu
// 10,000 threads incrementing 10 array elements // We need to avoid the conflicts #include <stdio.h> //#include "gputimer.h" #define NUM_THREADS 1000 #define ARRAY_SIZE 10 #define BLOCK_WIDTH 100 void print_array(int* array, int size) { for(int i(0); i < size ; ++i) { printf("%d \t", array[i]); } } __global__ void increment_naive(int* g) { // thread index int i = blockIdx.x * blockDim.x + threadIdx.x; // map it to the array_size i = i % ARRAY_SIZE; //g[i] = g[i] + 1; -> do not do this atomicAdd(&g[i], 1); } int main() { //Gputimer timer; printf("%d total threads in %d blocks writing into %d array element \t", NUM_THREADS, NUM_THREADS / BLOCK_WIDTH, ARRAY_SIZE); // declare and allocate host memory int h_array[ARRAY_SIZE]; const int ARRAY_BYTES = ARRAY_SIZE * sizeof(int); // declare, allocate, and zero-oout GPU memory int* d_array; cudaMalloc((void**) &d_array, ARRAY_BYTES); cudaMemset((void*) d_array, 0, ARRAY_BYTES); // launch kernel //dim3 gridSize = (NUM_THREADS/BLOCK_WIDTH, 1, 1); //dim3 blockSize = (BLOCK_WIDTH, 1, 1); //timer.Start(); increment_naive<<<NUM_THREADS/BLOCK_WIDTH, BLOCK_WIDTH>>>(d_array); //timer.Stop(); // copy back from the GPU memory to CPU memory cudaMemcpy(h_array, d_array, ARRAY_BYTES, cudaMemcpyDeviceToHost); print_array(h_array, ARRAY_SIZE); // check time //printf("Time elapsed = %g ms \n", timer.Elapsed()); // free cuda memory cudaFree(d_array); return 0; }
40d16dbd81d87083e112acf396ce3d70226b7dd8.hip
// !!! This is a file automatically generated by hipify!!! //atomicAdd(XX, 1) -> atomicInc !!!!!!! #define OUTPUT_TXT // CUDA Runtime #include <hip/hip_runtime.h> #include <hip/hip_runtime_api.h> #include <assert.h> #include <string> using namespace std; typedef unsigned int uint; #define REAL_infinity 1.0e30 // Utilities and system includes #include <helper_functions.h> // helper for shared functions common to CUDA SDK samples #include <helper_cuda.h> // helper for CUDA error checking #include "vec3.cuh" #include "tools.cuh" #include "box.cuh" #include "tri3f.cuh" #include "bvh.cuh" #include "pair.cuh" #include "tri-contact.cuh" #include "mesh.cuh" #include <math.h> #include <stdarg.h> #include <thrust/device_vector.h> #include <thrust/scan.h> #include <thrust/sort.h> //======================================================= hipDeviceProp_t deviceProp; extern void initPairsGPU(); void initGPU() { static int devID = 0; if (devID == 0) { hipGetDevice(&devID); checkCudaErrors(hipGetDeviceProperties(&deviceProp, devID)); initPairsGPU(); } } //======================================================= g_mesh theCloth; g_bvh theBVH[2]; g_front theFront[2]; g_pair thePairs[2]; // potentially colliding pairs g_pair retPairs; //results g_pairCCD retPairsCCD; //======================================================= void initPairsGPU() { //pairs[0].init(MAX_PAIR_NUM); // MAX_PAIR_NUM); thePairs[1].init(MAX_PAIR_NUM); retPairs.init(MAX_PAIR_NUM); retPairsCCD.init(MAX_PAIR_NUM / 10); } void pushMesh2GPU(int numFace, int numVert, void *faces, void *nodes) { theCloth.init(); theCloth.numFace = numFace; theCloth.numVert = numVert; hipMalloc((void **)&theCloth._df, numFace*sizeof(tri3f)); hipMalloc((void **)&theCloth._dfBx, numFace*sizeof(g_box)); hipMalloc((void **)&theCloth._dx, numVert*sizeof(REAL3)); hipMalloc((void **)&theCloth._dx0, numVert*sizeof(REAL3)); hipMemcpy(theCloth._df, faces, sizeof(tri3f)*numFace, hipMemcpyHostToDevice); hipMemcpy(theCloth._dx, nodes, sizeof(REAL3)*numVert, hipMemcpyHostToDevice); hipMemcpy(theCloth._dx0, theCloth._dx, sizeof(REAL3)*numVert, hipMemcpyDeviceToDevice); theCloth.computeWSdata(0, false); } void updateMesh2GPU(void *nodes,void *prenodes,REAL thickness) { //hipMemcpy(theCloth._dx0, theCloth._dx, sizeof(REAL3)*theCloth.numVert, hipMemcpyDeviceToDevice); hipMemcpy(theCloth._dx, nodes, sizeof(REAL3)*theCloth.numVert, hipMemcpyHostToDevice); hipMemcpy(theCloth._dx0, prenodes, sizeof(REAL3)*theCloth.numVert, hipMemcpyHostToDevice); theCloth.computeWSdata(thickness, true); REAL3* dx = new REAL3[theCloth.numVert]; REAL3* dx0 = new REAL3[theCloth.numVert]; hipMemcpy(dx, theCloth._dx, sizeof(REAL3)*theCloth.numVert, hipMemcpyDeviceToHost); hipMemcpy(dx0, theCloth._dx0, sizeof(REAL3)*theCloth.numVert, hipMemcpyDeviceToHost); vector<REAL3> tem; for (int i = 0; i < theCloth.numVert; i++) { tem.push_back(dx[i]); tem.push_back(dx0[i]); } int ss = 0; ss++; } //======================================================= void pushBVHIdx(int max_level, unsigned int *level_idx, bool isCloth) { theBVH[isCloth]._max_level = max_level; theBVH[isCloth]._level_idx = new uint[max_level]; memcpy(theBVH[isCloth]._level_idx, level_idx, sizeof(uint)*max_level); } void pushBVH(unsigned int length, int *ids, bool isCloth) { theBVH[isCloth]._num = length; checkCudaErrors(hipMalloc((void**)&theBVH[isCloth]._bvh, length*sizeof(int) * 2)); checkCudaErrors(hipMemcpy(theBVH[isCloth]._bvh, ids, length*sizeof(int) * 2, hipMemcpyHostToDevice)); checkCudaErrors(hipMalloc((void**)&theBVH[isCloth]._bxs, length*sizeof(g_box))); checkCudaErrors(hipMemset(theBVH[isCloth]._bxs, 0, length*sizeof(g_box))); theBVH[isCloth].hBxs = NULL; theBVH[isCloth]._triBxs = isCloth ? theCloth._dfBx : NULL; theBVH[isCloth]._triCones = NULL; } void pushBVHLeaf(unsigned int length, int *idf, bool isCloth) { checkCudaErrors(hipMalloc((void**)&theBVH[isCloth]._bvh_leaf, length*sizeof(int))); checkCudaErrors(hipMemcpy(theBVH[isCloth]._bvh_leaf, idf, length*sizeof(int), hipMemcpyHostToDevice)); } //====================================================== void refitBVH_Serial(bool isCloth, int length) { refit_serial_kernel << <1, 1, 0 >> > (theBVH[isCloth]._bvh, theBVH[isCloth]._bxs, theBVH[isCloth]._triBxs, theBVH[isCloth]._cones, theBVH[isCloth]._triCones, length == 0 ? theBVH[isCloth]._num : length); getLastCudaError("refit_serial_kernel"); hipDeviceSynchronize(); } void refitBVH_Parallel(bool isCloth, int st, int length) { BLK_PAR(length); refit_kernel << < B, T >> > (theBVH[isCloth]._bvh, theBVH[isCloth]._bxs, theBVH[isCloth]._triBxs, theBVH[isCloth]._cones, theBVH[isCloth]._triCones, st, length); getLastCudaError("refit_kernel"); hipDeviceSynchronize(); } void refitBVH(bool isCloth) { // before refit, need to get _tri_boxes !!!! // copying !!! for (int i = theBVH[isCloth]._max_level - 1; i >= 0; i--) { int st = theBVH[isCloth]._level_idx[i]; int ed = (i != theBVH[isCloth]._max_level - 1) ? theBVH[isCloth]._level_idx[i + 1] - 1 : theBVH[isCloth]._num - 1; int length = ed - st + 1; if (i < 5) { refitBVH_Serial(isCloth, length + st); break; } else { refitBVH_Parallel(isCloth, st, length); } } } //=============================================== void pushFront(bool self, int num, unsigned int *data) { g_front *f = &theFront[self]; f->init(); f->push(num, (uint4 *)data); } //=============================================== // show memory usage of GPU void reportMemory(char *tag) { //return; #ifdef OUTPUT_TXT size_t free_byte; size_t total_byte; hipError_t cuda_status = hipMemGetInfo(&free_byte, &total_byte); if (hipSuccess != cuda_status) { printf("Error: hipMemGetInfo fails, %s \n", hipGetErrorString(cuda_status)); exit(1); } REAL free_db = (REAL)free_byte; REAL total_db = (REAL)total_byte; REAL used_db = total_db - free_db; printf("%s: GPU memory usage: used = %f, free = %f MB, total = %f MB\n", tag, used_db / 1024.0 / 1024.0, free_db / 1024.0 / 1024.0, total_db / 1024.0 / 1024.0); #endif } //=============================================== #define STACK_SIZE 50 #define EMPTY (nIdx == 0) #define PUSH_PAIR(nd1, nd2) {\ nStack[nIdx].x = nd1;\ nStack[nIdx].y = nd2;\ nIdx++;\ } #define POP_PAIR(nd1, nd2) {\ nIdx--;\ nd1 = nStack[nIdx].x;\ nd2 = nStack[nIdx].y;\ } #define NEXT(n1, n2) POP_PAIR(n1, n2) inline __device__ void pushToFront(int a, int b, uint4 *front, uint *idx, uint ptr) { // (*idx)++; if (*idx < MAX_FRONT_NUM) { uint offset = atomicAdd(idx, 1); front[offset] = make_uint4(a, b, 0, ptr); } } inline __device__ void sproutingAdaptive(int left, int right, int *bvhA, g_box *bxsA, int *bvhB, g_box *bxsB, uint4 *front, uint *frontIdx, uint2 *pairs, uint *pairIdx, bool update, uint ptr) { uint2 nStack[STACK_SIZE]; uint nIdx = 0; for (int i = 0; i<4; i++) { if (isLeaf(left, bvhA) && isLeaf(right, bvhB)) { pushToFront(left, right, front, frontIdx, ptr); } else { if (!overlaps(left, right, bxsA, bxsB)) { pushToFront(left, right, front, frontIdx, ptr); } else { if (isLeaf(left, bvhA)) { PUSH_PAIR(left, getLeftChild(right, bvhB)); PUSH_PAIR(left, getRightChild(right, bvhB)); } else { PUSH_PAIR(getLeftChild(left, bvhA), right); PUSH_PAIR(getRightChild(left, bvhA), right); } } } if (EMPTY) return; NEXT(left, right); } while (!EMPTY) { NEXT(left, right); pushToFront(left, right, front, frontIdx, ptr); } } inline __device__ void sprouting(int left, int right, int *bvhA, g_box *bxsA, int *bvhB, g_box *bxsB, uint4 *front, uint *frontIdx, int2 *pairs, uint *pairIdx, bool update, uint ptr, tri3f *Atris) { uint2 nStack[STACK_SIZE]; uint nIdx = 0; while (1) { if (isLeaf(left, bvhA) && isLeaf(right, bvhB)) { if (update) pushToFront(left, right, front, frontIdx, ptr); if (overlaps(left, right, bxsA, bxsB)) { if(!covertex(getTriID(left, bvhA), getTriID(right, bvhB), Atris)) addPair(getTriID(left, bvhA), getTriID(right, bvhB), pairs, pairIdx); } } else { if (!overlaps(left, right, bxsA, bxsB)) { if (update) pushToFront(left, right, front, frontIdx, ptr); } else { if (isLeaf(left, bvhA)) { PUSH_PAIR(left, getLeftChild(right, bvhB)); PUSH_PAIR(left, getRightChild(right, bvhB)); } else { PUSH_PAIR(getLeftChild(left, bvhA), right); PUSH_PAIR(getRightChild(left, bvhA), right); } } } if (EMPTY) return; NEXT(left, right); } } __device__ void doPropogate( uint4 *front, uint *frontIdx, int num, int *bvhA, g_box *bxsA, int bvhAnum, int *bvhB, g_box *bxsB, int bvhBnum, int2 *pairs, uint *pairIdx, bool update, tri3f *Atris, int idx, bool *flags) { uint4 node = front[idx]; if (node.z != 0) { #if defined(_DEBUG) || defined(OUTPUT_TXT) atomicAdd(frontIdx + 1, 1); #endif return; } #ifdef USE_NC if (flags != NULL && flags[node.w] == 0) { #if defined(_DEBUG) || defined(OUTPUT_TXT) atomicAdd(frontIdx + 2, 1); #endif return; } #endif uint left = node.x; uint right = node.y; if (isLeaf(left, bvhA) && isLeaf(right, bvhB)) { bool tem = overlaps(left, right, bxsA, bxsB); if (bxsA[left]._min.z > bxsB[right]._max.z) tem = false; if (bxsA[left]._min.z == bxsB[right]._max.z) tem = false; if (overlaps(left, right, bxsA, bxsB)) if (bvhA != bvhB) addPair(getTriID(left, bvhA), getTriID(right, bvhB), pairs, pairIdx); else { // for self ccd, we need to remove adjacent triangles, they will be processed seperatedly with orphan set if (!covertex(getTriID(left, bvhA), getTriID(right, bvhB), Atris)) addPair(getTriID(left, bvhA), getTriID(right, bvhB), pairs, pairIdx); } return; } if (!overlaps(left, right, bxsA, bxsB)) return; if (update) front[idx].z = 1; int ptr = node.w; if (isLeaf(left, bvhA)) { sprouting(left, getLeftChild(right, bvhB), bvhA, bxsA, bvhB, bxsB, front, frontIdx, pairs, pairIdx, update, ptr, Atris); sprouting(left, getRightChild(right, bvhB), bvhA, bxsA, bvhB, bxsB, front, frontIdx, pairs, pairIdx, update, ptr, Atris); } else { sprouting(getLeftChild(left, bvhA), right, bvhA, bxsA, bvhB, bxsB, front, frontIdx, pairs, pairIdx, update, ptr, Atris); sprouting(getRightChild(left, bvhA), right, bvhA, bxsA, bvhB, bxsB, front, frontIdx, pairs, pairIdx, update, ptr, Atris); } } __global__ void kernelPropogate(uint4 *front, uint *frontIdx, int num, int *bvhA, g_box *bxsA, int bvhAnum, int *bvhB, g_box *bxsB, int bvhBnum,uint* tt, int2 *pairs, uint *pairIdx, bool update, tri3f *Atris, int stride, bool *flags) { int idx = blockDim.x * blockIdx.x + threadIdx.x; for (int i = 0; i<stride; i++) { int j = idx*stride + i; if (j >= num) return; atomicAdd(tt, 1); doPropogate(front, frontIdx, num, bvhA, bxsA, bvhAnum, bvhB, bxsB, bvhBnum, pairs, pairIdx, update, Atris, j, flags); } } int g_front::propogate(bool &update, bool self, bool ccd) { uint dummy[1]; cutilSafeCall(hipMemcpy(dummy, _dIdx, 1 * sizeof(uint), hipMemcpyDeviceToHost)); #ifdef OUTPUT_TXT printf("Before propogate, length = %d\n", dummy[0]); #endif #if defined(_DEBUG) || defined(OUTPUT_TXT) uint dummy2[5] = { 0, 0, 0, 0, 0 }; cutilSafeCall(hipMemcpy(_dIdx + 1, dummy2, 5 * sizeof(int), hipMemcpyHostToDevice)); #endif if (dummy[0] != 0) { g_bvh *pb1 = &theBVH[1]; g_bvh *pb2 = (self) ? &theBVH[1] : &theBVH[0]; tri3f *faces = (self ? theCloth._df: NULL); int stride = 4; #ifdef FIX_BT_NUM BLK_PAR2(dummy[0], stride); #else BLK_PAR3(dummy[0], stride, getBlkSize((void *)kernelPropogate)); #endif uint* tt; cutilSafeCall(hipMalloc((void**)&tt, 1 * sizeof(uint))); uint ttt = 0; cutilSafeCall(hipMemcpy(tt, &ttt, 1 * sizeof(uint), hipMemcpyHostToDevice)); kernelPropogate << < B, T >> > (_dFront, _dIdx, dummy[0], pb1->_bvh, pb1->_bxs, pb1->_num, pb2->_bvh, pb2->_bxs, pb2->_num,tt, thePairs[self]._dPairs, thePairs[self]._dIdx, update, faces, stride, self ? theBVH[1]._ctFlags : NULL); //thePairs[self]._dPairs, thePairs[self]._dIdx, update, faces, stride, (self && !ccd) ? theBVH[1]._ctFlags : NULL); //reportMemory("propogate"); //cutilSafeCall(hipMemcpy(&ttt, tt, 1 * sizeof(uint), hipMemcpyDeviceToHost)); hipDeviceSynchronize(); getLastCudaError("kernelPropogate"); } cutilSafeCall(hipMemcpy(dummy, _dIdx, 1 * sizeof(uint), hipMemcpyDeviceToHost)); #ifdef OUTPUT_TXT printf("After propogate, length = %d\n", dummy[0]); #endif #if defined(_DEBUG) || defined(OUTPUT_TXT) cutilSafeCall(hipMemcpy(dummy2, _dIdx + 1, 5 * sizeof(int), hipMemcpyDeviceToHost)); //printf("Invalid = %d, NC culled = %d\n", dummy2[0], dummy2[1]); #endif if (update && dummy[0] > SAFE_FRONT_NUM) { printf("Too long front, stop updating ...\n"); update = false; } if (dummy[0] > MAX_FRONT_NUM) { printf("Too long front, exiting ...\n"); exit(0); } return dummy[0]; } //=============================================== __global__ void kernel_face_ws(tri3f *face, REAL3 *x, REAL3 *ox, g_box *bxs, bool ccd, REAL thickness, int num) { LEN_CHK(num); int id0 = face[idx].id0(); int id1 = face[idx].id1(); int id2 = face[idx].id2(); REAL3 ox0 = ox[id0]; REAL3 ox1 = ox[id1]; REAL3 ox2 = ox[id2]; REAL3 x0 = x[id0]; REAL3 x1 = x[id1]; REAL3 x2 = x[id2]; bxs[idx].set(ox0, ox1); bxs[idx].add(ox2); if (ccd) { bxs[idx].add(x0); bxs[idx].add(x1); bxs[idx].add(x2); } //else bxs[idx].enlarge(thickness); } void g_mesh::computeWSdata(REAL thickness, bool ccd) { if (numFace == 0) return; { int num = numFace; BLK_PAR(num); kernel_face_ws << <B, T >> > ( _df, _dx, _dx0, _dfBx, ccd, thickness, num); getLastCudaError("kernel_face_ws"); } } //=============================================== __device__ REAL triProduct(REAL3 &a, REAL3 &b, REAL3 &c) { return dot(cross(a, b), c); } __device__ REAL3 xvpos(REAL3 x, REAL3 v, REAL t) { return x + v*t; } __device__ int sgn(REAL x) { return x<0 ? -1 : 1; } __device__ int solve_quadratic(REAL a, REAL b, REAL c, REAL x[2]) { // http://en.wikipedia.org/wiki/Quadratic_formula#Floating_point_implementation REAL d = b*b - 4 * a*c; if (d < 0) { x[0] = -b / (2 * a); return 0; } REAL q = -(b + sgn(b)*sqrt(d)) / 2; int i = 0; if (abs(a) > 1e-12*abs(q)) x[i++] = q / a; if (abs(q) > 1e-12*abs(c)) x[i++] = c / q; if (i == 2 && x[0] > x[1]) fswap(x[0], x[1]); return i; } __device__ REAL newtons_method(REAL a, REAL b, REAL c, REAL d, REAL x0, int init_dir) { if (init_dir != 0) { // quadratic approximation around x0, assuming y' = 0 REAL y0 = d + x0*(c + x0*(b + x0*a)), ddy0 = 2 * b + x0*(6 * a); x0 += init_dir*sqrt(abs(2 * y0 / ddy0)); } for (int iter = 0; iter < 100; iter++) { REAL y = d + x0*(c + x0*(b + x0*a)); REAL dy = c + x0*(2 * b + x0 * 3 * a); if (dy == 0) return x0; REAL x1 = x0 - y / dy; if (abs(x0 - x1) < 1e-6) return x0; x0 = x1; } return x0; } // solves a x^3 + b x^2 + c x + d == 0 __device__ int solve_cubic(REAL a, REAL b, REAL c, REAL d, REAL x[3]) { REAL xc[2]; int ncrit = solve_quadratic(3 * a, 2 * b, c, xc); if (ncrit == 0) { x[0] = newtons_method(a, b, c, d, xc[0], 0); return 1; } else if (ncrit == 1) {// cubic is actually quadratic return solve_quadratic(b, c, d, x); } else { REAL yc[2] = { d + xc[0] * (c + xc[0] * (b + xc[0] * a)), d + xc[1] * (c + xc[1] * (b + xc[1] * a)) }; int i = 0; if (yc[0] * a >= 0) x[i++] = newtons_method(a, b, c, d, xc[0], -1); if (yc[0] * yc[1] <= 0) { int closer = abs(yc[0])<abs(yc[1]) ? 0 : 1; x[i++] = newtons_method(a, b, c, d, xc[closer], closer == 0 ? 1 : -1); } if (yc[1] * a <= 0) x[i++] = newtons_method(a, b, c, d, xc[1], 1); return i; } } REAL signed_ee_distance(const REAL3 &x0, const REAL3 &x1, const REAL3 &y0, const REAL3 &y1, REAL3 *n, REAL *w); __device__ REAL signed_vf_distance (const REAL3 &x, const REAL3 &y0, const REAL3 &y1, const REAL3 &y2, REAL3 *n, REAL *w); __device__ bool collision_test( const REAL3 &x0, const REAL3 &x1, const REAL3 &x2, const REAL3 &x3, const REAL3 &v0, const REAL3 &v1, const REAL3 &v2, const REAL3 &v3,REAL &time,const int isVF)//0:vf 1:ee { REAL a0 = stp(x1, x2, x3), a1 = stp(v1, x2, x3) + stp(x1, v2, x3) + stp(x1, x2, v3), a2 = stp(x1, v2, v3) + stp(v1, x2, v3) + stp(v1, v2, x3), a3 = stp(v1, v2, v3); if (a1 == 0 && a2 == 0 && a3 == 0) return false; REAL t[4]; int nsol = solve_cubic(a3, a2, a1, a0, t); //t[nsol] = 1; // also check at end of timestep bool t_flag = false; for (int i = 0; i < nsol; i++) { if (t[i] < 0 || t[i] > 1) continue; REAL3 tx0 = xvpos(x0, v0, t[i]), tx1 = xvpos(x1 + x0, v1 + v0, t[i]), tx2 = xvpos(x2 + x0, v2 + v0, t[i]), tx3 = xvpos(x3 + x0, v3 + v0, t[i]); REAL3 n; REAL w[4]; REAL d; bool inside; if (isVF == 0) { d = signed_vf_distance(tx0, tx1, tx2, tx3, &n, w); inside = (fmin(-w[1], fmin(-w[2], -w[3])) >= -1e-6); } else {// Impact::EE d = signed_ee_distance(tx0, tx1, tx2, tx3, &n, w); inside = (fmin(fmin(w[0], w[1]), fmin(-w[2], -w[3])) >= -1e-6); } if (fabs(d) < 1e-6 && inside) { time = t[i]; return true; } //t_flag = true; //if (t[i] < time) //time = t[i]; } return t_flag; } __device__ void doImpactVF( REAL3 x0, REAL3 x1, REAL3 x2, REAL3 x3, REAL3 x00,REAL3 x10,REAL3 x20,REAL3 x30,REAL &time ) { REAL3 p0 = x00; REAL3 p1 = x10 - x00; REAL3 p2 = x20 - x00; REAL3 p3 = x30 - x00; REAL3 v0 = x0 - x00; REAL3 v1 = x1 - x10 - v0; REAL3 v2 = x2 - x20 - v0; REAL3 v3 = x3 - x30 - v0; /* if (iii == 69 && vid == 162 && t.id0() == 4 && t.id1() == 44 && t.id2() == 32) vid = 162; */ #ifdef USE_DNF_FILTER //bool ret1 = dnf_filter(x00, x10, x20, x30, x0, x1, x2, x3); #endif bool ret = collision_test(p0, p1, p2, p3, v0, v1, v2, v3,time,0); if (ret) { } } inline __device__ REAL3 norm(REAL3 p1, REAL3 p2, REAL3 p3) { return cross(p2 - p1, p3 - p1); } inline __device__ bool dnf_filter(REAL3 &a0, REAL3 &b0, REAL3 &c0, REAL3 &d0, REAL3 &a1, REAL3 &b1, REAL3 &c1, REAL3 &d1) { REAL3 n0 = norm(a0, b0, c0); REAL3 n1 = norm(a1, b1, c1); REAL3 delta = norm(a1 - a0, b1 - b0, c1 - c0); REAL3 nX = (n0 + n1 - delta)*REAL(0.5); REAL3 pa0 = d0 - a0; REAL3 pa1 = d1 - a1; REAL A = dot(n0, pa0); REAL B = dot(n1, pa1); REAL C = dot(nX, pa0); REAL D = dot(nX, pa1); REAL E = dot(n1, pa0); REAL F = dot(n0, pa1); if (A > 0 && B > 0 && (REAL(2.0) * C + F) > 0 && (REAL(2.0) * D + E) > 0) return false; if (A < 0 && B < 0 && (REAL(2.0) * C + F) < 0 && (REAL(2.0) * D + E) < 0) return false; return true; } __device__ void doImpactEE( REAL3 x0, REAL3 x1, REAL3 x2, REAL3 x3, REAL3 x00, REAL3 x10, REAL3 x20, REAL3 x30, REAL &time) { REAL3 p0 = x00; REAL3 p1 = x10 - x00; REAL3 p2 = x20 - x00; REAL3 p3 = x30 - x00; REAL3 v0 = x0 - x00; REAL3 v1 = x1 - x10 - v0; REAL3 v2 = x2 - x20 - v0; REAL3 v3 = x3 - x30 - v0; #ifdef USE_DNF_FILTER //bool ret1 = dnf_filter(x10, x20, x30, x40, x1, x2, x3, x4); #endif /* if (e0.x == 41 && e0.y == 624 && e1.x == 599 && e1.y == 383) e0.x = 41; */ //bool ret1 = dnf_filter(p0, p1, p2, p3, v0, v1, v2, v3); //if (!ret1) //{ // return; //} bool ret = collision_test(p0, p1, p2, p3, v0, v1, v2, v3,time,1); if (ret) { } } __device__ REAL signed_vf_distance (const REAL3 &x, const REAL3 &y0, const REAL3 &y1, const REAL3 &y2, REAL3 *n, REAL *w) { REAL3 _n; if (!n) n = &_n; REAL _w[4]; if (!w) w = _w; *n = cross(normalize(y1 - y0), normalize(y2 - y0)); if (norm2(*n) < 1e-6) return REAL_infinity; *n = normalize(*n); REAL h = dot(x - y0, *n); REAL b0 = stp(y1 - x, y2 - x, *n), b1 = stp(y2 - x, y0 - x, *n), b2 = stp(y0 - x, y1 - x, *n); w[0] = 1; w[1] = -b0 / (b0 + b1 + b2); w[2] = -b1 / (b0 + b1 + b2); w[3] = -b2 / (b0 + b1 + b2); return h; } __device__ REAL signed_ee_distance(const REAL3 &x0, const REAL3 &x1, const REAL3 &y0, const REAL3 &y1, REAL3 *n, REAL *w) { REAL3 _n; if (!n) n = &_n; REAL _w[4]; if (!w) w = _w; *n = cross(normalize(x1 - x0), normalize(y1 - y0)); if (norm2(*n) < 1e-6) return REAL_infinity; *n = normalize(*n); REAL h = dot(x0 - y0, *n); REAL a0 = stp(y1 - x1, y0 - x1, *n), a1 = stp(y0 - x0, y1 - x0, *n), b0 = stp(x0 - y1, x1 - y1, *n), b1 = stp(x1 - y0, x0 - y0, *n); w[0] = a0 / (a0 + a1); w[1] = a1 / (a0 + a1); w[2] = -b0 / (b0 + b1); w[3] = -b1 / (b0 + b1); return h; } __device__ REAL doProximityVF( REAL3 _x4, REAL3 _x1, REAL3 _x2, REAL3 _x3, REAL *_mrt ) { REAL mrt = _mrt[0]; REAL3 x1 = _x1; REAL3 x2 = _x2; REAL3 x3 = _x3; REAL3 x4 = _x4; REAL3 n; REAL w[4]; REAL d = signed_vf_distance(x4, x1, x2, x3, &n, w); d = abs(d); const REAL dmin = mrt; if (d >= dmin) return d; bool inside = (min(min(-w[1], -w[2]), -w[3]) >= -1e-6); if (!inside) return -d; return d; } __device__ REAL doProximityEE( REAL3 _e00, REAL3 _e01, REAL3 _e10, REAL3 _e11, REAL *_mrt ) { REAL mrt = _mrt[0]; REAL3 e00 = _e00; REAL3 e01 = _e01; REAL3 e10 = _e10; REAL3 e11 = _e11; /* if (e0.x == 891 && e0.y == 446 && e1.x == 18 && e1.y == 188) e1.x = 18; */ REAL3 n; REAL w[4]; REAL d = signed_ee_distance(e00, e01, e10, e11, &n, w); d = abs(d); if (d == 0) int sd = d; const REAL dmin = mrt; if (d >= dmin) return d; bool inside = min(min(w[0], w[1]), min(-w[2], -w[3])) >= -1e-6; if (!inside) return -d; return d; } __device__ void tri_CCD( uint t1, uint t2, uint t3, uint tt1, uint tt2, uint tt3, REAL3 *cx, REAL3 *cx0, int2 *pairRets, uint *pairIdx, int fid1, int fid2, int *t ) { REAL3 p[3]; p[0] = cx[t1]; p[1] = cx[t2]; p[2] = cx[t3]; REAL3 pp[3]; pp[0] = cx0[t1]; pp[1] = cx0[t2]; pp[2] = cx0[t3]; REAL3 q[3]; q[0] = cx[tt1]; q[1] = cx[tt2]; q[2] = cx[tt3]; REAL3 qq[3]; qq[0] = cx0[tt1]; qq[1] = cx0[tt2]; qq[2] = cx0[tt3]; REAL time = 2; ///* //VF for (int st = 0; st < 3; st++) { doImpactVF( p[st], q[0], q[1], q[2], pp[st], qq[0], qq[1], qq[2], time ); } //VF for (int st = 0; st < 3; st++) { doImpactVF(q[st], p[0], p[1], p[2], qq[st], pp[0], pp[1], pp[2], time ); } //EE uint idx0[3]; uint idx1[3]; idx0[0] = t1; idx0[1] = t2; idx0[2] = t3; idx1[0] = tt1; idx1[1] = tt2; idx1[2] = tt3; for (int st = 0; st < 3; st++) { int ind0 = st; int ind1 = (st + 1) % 3; for (int ss = 0; ss < 3; ss++) { int ind2 = st; int ind3 = (st + 1) % 3; doImpactEE( cx[idx0[ind0]], cx[idx0[ind1]], cx[idx1[ind2]], cx[idx1[ind3]], cx0[idx0[ind0]], cx0[idx0[ind1]], cx0[idx1[ind2]], cx0[idx1[ind3]], time ); } } if (time >= 0 && time <= 1) { //int index = addPair(fid1, fid2, pairRets, pairIdx); //if (index != -1) //{ t[0]=1; //} } } __device__ void tri_DCD( uint t1, uint t2, uint t3, uint tt1, uint tt2, uint tt3, REAL3 *cx, REAL3 *cx0, int2 *pairRets, int4 *dv, int *VF_EE, REAL* dist,int *CCDres,int *t, uint *pairIdx, int fid1, int fid2, REAL *thickness ) { REAL3 p[3]; p[0] = cx[t1]; p[1] = cx[t2]; p[2] = cx[t3]; REAL3 pp[3]; pp[0] = cx0[t1]; pp[1] = cx0[t2]; pp[2] = cx0[t3]; REAL3 q[3]; q[0] = cx[tt1]; q[1] = cx[tt2]; q[2] = cx[tt3]; REAL3 qq[3]; qq[0] = cx0[tt1]; qq[1] = cx0[tt2]; qq[2] = cx0[tt3]; //REAL time = 2; uint idx0[3]; uint idx1[3]; idx0[0] = t1; idx0[1] = t2; idx0[2] = t3; idx1[0] = tt1; idx1[1] = tt2; idx1[2] = tt3; REAL time = 2; t[0] = 0; ///* //VF for (int st = 0; st < 3; st++) { t[0] = 0; time = 2; doImpactVF( p[st], q[0], q[1], q[2], pp[st], qq[0], qq[1], qq[2], time ); REAL d = doProximityVF( p[st], q[0], q[1], q[2], thickness ); if ((time >= 0 && time <= 1)) { t[0] = 1; } if ((time >= 0 && time <= 1)||(d<thickness[0] && d>=0)) { addPairDCD(fid1, fid2, 0, idx0[st], idx1[0], idx1[1], idx1[2], d, t, pairRets, dv, VF_EE, dist, CCDres, pairIdx); } if (d != -1) { //addPairDCD(fid1, fid2, 0, idx0[st], idx1[0], idx1[1], idx1[2], d,t, // pairRets, dv, VF_EE, dist, CCDres,pairIdx); } } //VF for (int st = 0; st < 3; st++) { t[0] = 0; time = 2; if (st == 0) { REAL d = doProximityVF( q[st], p[0], p[1], p[2], thickness ); } doImpactVF(q[st], p[0], p[1], p[2], qq[st], pp[0], pp[1], pp[2], time ); REAL d = doProximityVF( q[st], p[0], p[1], p[2], thickness ); if ((time >= 0 && time <= 1)) { t[0] = 1; } if ((time >= 0 && time <= 1) || (d < thickness[0] && d >= 0)) { addPairDCD(fid1, fid2, 0, idx1[st], idx0[0], idx0[1], idx0[2], d, t, pairRets, dv, VF_EE, dist, CCDres, pairIdx); } if (d != -1) { //addPairDCD(fid1, fid2, 0, idx1[st], idx0[0], idx0[1], idx0[2], d,t, // pairRets, dv, VF_EE, dist, CCDres, pairIdx); } } //EE for (int st = 0; st < 3; st++) { int ind0 = st; int ind1 = (st + 1) % 3; for (int ss = 0; ss < 3; ss++) { int ind2 = ss; int ind3 = (ss + 1) % 3; t[0] = 0; time = 2; doImpactEE( cx[idx0[ind0]], cx[idx0[ind1]], cx[idx1[ind2]], cx[idx1[ind3]], cx0[idx0[ind0]], cx0[idx0[ind1]], cx0[idx1[ind2]], cx0[idx1[ind3]], time ); REAL d = doProximityEE( cx[idx0[ind0]], cx[idx0[ind1]], cx[idx1[ind2]], cx[idx1[ind3]], thickness ); if ((time >= 0 && time <= 1)) { t[0] = 1; } if ((time >= 0 && time <= 1) || (d < thickness[0] && d >= 0)) { addPairDCD(fid1, fid2, 1, idx0[ind0], idx0[ind1], idx1[ind2], idx1[ind3], d, t, pairRets, dv, VF_EE, dist, CCDres, pairIdx); } if (d != -1) { //addPairDCD(fid1, fid2, 1, idx0[ind0], idx0[ind1], idx1[ind2], idx1[ind3], d,t, // pairRets, dv, VF_EE, dist, CCDres, pairIdx); } } } } __global__ void kernelGetCollisions( int2 *pairs, int num, REAL3 *cx, REAL3 *cx0,tri3f *ctris, int2 *pairRets, int4 *dv, int *VF_EE, REAL* dist,int *CCDres, uint *pairIdx, int *t, REAL *thickness, int stride) { int idxx = blockDim.x * blockIdx.x + threadIdx.x; for (int i = 0; i < stride; i++) { int j = idxx*stride + i; if (j >= num) return; int idx = j; int2 pair = pairs[idx]; int fid1 = pair.x; int fid2 = pair.y; int ss = 0; tri3f t1 = ctris[fid1]; tri3f t2 = ctris[fid2]; uint tt1[3]; uint tt2[3]; tt1[0] = t1.id0(); tt1[1] = t1.id1(); tt1[2] = t1.id2(); tt2[0] = t2.id0(); tt2[1] = t2.id1(); tt2[2] = t2.id2(); #ifdef FOR_DEBUG bool find = false; if (fid1 == 369 && fid2 == 3564) find = true; if (fid2 == 369 && fid1 == 3564) find = true; #endif REAL3 p[3]; p[0] = cx[t1.id0()]; p[1] = cx[t1.id1()]; p[2] = cx[t1.id2()]; REAL3 pp[3]; pp[0] = cx0[t1.id0()]; pp[1] = cx0[t1.id1()]; pp[2] = cx0[t1.id2()]; REAL3 q[3]; q[0] = cx[t2.id0()]; q[1] = cx[t2.id1()]; q[2] = cx[t2.id2()]; REAL3 qq[3]; qq[0] = cx0[t2.id0()]; qq[1] = cx0[t2.id1()]; qq[2] = cx0[t2.id2()]; bool iscovetex = false; for (int st = 0; st < 3; st++) { for (int ss = 0; ss < 3; ss++) { if (tt1[st] == tt2[ss]) { iscovetex = true; } } } if (iscovetex) continue; //tri_CCD(t1.id0(), t1.id1(), t1.id2(), t2.id0(), t2.id1(), t2.id2(), cx, cx0, pairRets, pairIdx, fid1, fid2, t); tri_DCD(t1.id0(), t1.id1(), t1.id2(), t2.id0(), t2.id1(), t2.id2(), cx, cx0, pairRets, dv, VF_EE, dist,CCDres,t, pairIdx, fid1, fid2, thickness); } /* ///* //VF for (int st = 0; st < 3; st++) { doImpactVF( p[st], q[0], q[1], q[2], pp[st], qq[0], qq[1], qq[2], time ); } //VF for (int st = 0; st < 3; st++) { doImpactVF(q[st], p[0], p[1], p[2], qq[st], pp[0], pp[1], pp[2], time ); } //EE int idx0[2]; int idx1[2]; for (int st = 0; st < 3; st++) { idx0[0] = st; idx0[1] = (st + 1) % 3; for (int ss = 0; ss < 3; ss++) { idx1[0] = ss; idx1[1] = (ss + 1) % 3; doImpactEE( cx[idx0[0]], cx[idx0[1]], cx[idx1[0]], cx[idx1[1]], cx0[idx0[0]], cx0[idx0[1]], cx0[idx1[0]], cx0[idx1[1]], time ); } } #ifdef FOR_DEBUG if (find) { printf("%d: %lf, %lf, %lf\n", t1.id0(), p0.x, p0.y, p0.z); printf("%d: %lf, %lf, %lf\n", t1.id1(), p1.x, p1.y, p1.z); printf("%d: %lf, %lf, %lf\n", t1.id2(), p2.x, p2.y, p2.z); printf("%d: %lf, %lf, %lf\n", t2.id0(), q0.x, q0.y, q0.z); printf("%d: %lf, %lf, %lf\n", t2.id1(), q1.x, q1.y, q1.z); printf("%d: %lf, %lf, %lf\n", t2.id2(), q2.x, q2.y, q2.z); } #endif REAL3 p0 = cx[t1.id0()]; REAL3 p1 = cx[t1.id1()]; REAL3 p2 = cx[t1.id2()]; REAL3 q0 = cx[t2.id0()]; REAL3 q1 = cx[t2.id1()]; REAL3 q2 = cx[t2.id2()]; if (tri_contact(p0, p1, p2, q0, q1, q2)) addPair(fid1, fid2, pairRets, pairIdx); if (time >= 0 && time <= 1) { int index = addPair(fid1, fid2, pairRets, pairIdx); if (index != -1) { t[index] = time; } } } */ } //=============================================== int g_pair::getCollisions(bool self, g_pairCCD &ret, int *time, REAL* thickness) { int num = length(); printf("pair = %d\n", num); #ifdef OUTPUT_TXT //if (self) //printf("self pair = %d\n", num); //else //printf("inter-obj pair = %d\n", num); #endif if (num == 0) return 0; ret.clear(); int stride = 4; #ifdef FIX_BT_NUM BLK_PAR3(num, stride, 32); #else BLK_PAR3(num, stride, getBlkSize((void *)kernelGetCollisions)); #endif int *tem_time; int tem = 0; cutilSafeCall(hipMalloc((void**)&tem_time, 1 * sizeof(int))); cutilSafeCall(hipMemcpy(tem_time, &tem, 1 * sizeof(int), hipMemcpyHostToDevice)); REAL *gthickness; cutilSafeCall(hipMalloc((void**)&gthickness, 1 * sizeof(REAL))); cutilSafeCall(hipMemcpy(gthickness, thickness, 1 * sizeof(REAL), hipMemcpyHostToDevice)); kernelGetCollisions << < B, T >> > (_dPairs, num, theCloth._dx, theCloth._dx0, theCloth._df, ret._dPairs, ret._dv, ret._dVF_EE, ret.dist,ret.CCD_res, ret._dIdx, tem_time, gthickness, stride); getLastCudaError("kernelGetCollisions"); int len = ret.length(); #ifdef OUTPUT_TXT //printf("collision num = %d\n", len); #endif printf("collision num = %d\n", len); //if (len > 0) //{ cutilSafeCall(hipMemcpy(time, tem_time, sizeof(int)* 1, hipMemcpyDeviceToHost)); //} hipFree(tem_time); return len; } //=============================================== int getCollisionsGPU(int *rets, int *vf_ee, int *vertex_id, REAL *dist, int *time,int* CCDres, REAL* thickness) { bool update = true; int len = 0; TIMING_BEGIN thePairs[1].clear(); refitBVH(true); theFront[1].propogate(update, 1, false); hipDeviceSynchronize(); len = thePairs[1].getCollisions(true, retPairsCCD, time, thickness); hipDeviceSynchronize(); TIMING_END("$$$get_collisions_gpu") if (len > 0) { cutilSafeCall(hipMemcpy(rets, retPairsCCD._dPairs, sizeof(uint) * 2 * len, hipMemcpyDeviceToHost)); cutilSafeCall(hipMemcpy(vf_ee, retPairsCCD._dVF_EE, sizeof(int) * len, hipMemcpyDeviceToHost)); cutilSafeCall(hipMemcpy(vertex_id, retPairsCCD._dv, sizeof(int) * 4 * len, hipMemcpyDeviceToHost)); cutilSafeCall(hipMemcpy(dist, retPairsCCD.dist, sizeof(double) * len, hipMemcpyDeviceToHost)); cutilSafeCall(hipMemcpy(CCDres, retPairsCCD.CCD_res, sizeof(int) * len, hipMemcpyDeviceToHost)); } return len; }
40d16dbd81d87083e112acf396ce3d70226b7dd8.cu
//atomicAdd(XX, 1) -> atomicInc !!!!!!! #define OUTPUT_TXT // CUDA Runtime #include <cuda_runtime.h> #include <cuda_profiler_api.h> #include <assert.h> #include <string> using namespace std; typedef unsigned int uint; #define REAL_infinity 1.0e30 // Utilities and system includes #include <helper_functions.h> // helper for shared functions common to CUDA SDK samples #include <helper_cuda.h> // helper for CUDA error checking #include "vec3.cuh" #include "tools.cuh" #include "box.cuh" #include "tri3f.cuh" #include "bvh.cuh" #include "pair.cuh" #include "tri-contact.cuh" #include "mesh.cuh" #include <math.h> #include <stdarg.h> #include <thrust/device_vector.h> #include <thrust/scan.h> #include <thrust/sort.h> //======================================================= cudaDeviceProp deviceProp; extern void initPairsGPU(); void initGPU() { static int devID = 0; if (devID == 0) { cudaGetDevice(&devID); checkCudaErrors(cudaGetDeviceProperties(&deviceProp, devID)); initPairsGPU(); } } //======================================================= g_mesh theCloth; g_bvh theBVH[2]; g_front theFront[2]; g_pair thePairs[2]; // potentially colliding pairs g_pair retPairs; //results g_pairCCD retPairsCCD; //======================================================= void initPairsGPU() { //pairs[0].init(MAX_PAIR_NUM); // MAX_PAIR_NUM); thePairs[1].init(MAX_PAIR_NUM); retPairs.init(MAX_PAIR_NUM); retPairsCCD.init(MAX_PAIR_NUM / 10); } void pushMesh2GPU(int numFace, int numVert, void *faces, void *nodes) { theCloth.init(); theCloth.numFace = numFace; theCloth.numVert = numVert; cudaMalloc((void **)&theCloth._df, numFace*sizeof(tri3f)); cudaMalloc((void **)&theCloth._dfBx, numFace*sizeof(g_box)); cudaMalloc((void **)&theCloth._dx, numVert*sizeof(REAL3)); cudaMalloc((void **)&theCloth._dx0, numVert*sizeof(REAL3)); cudaMemcpy(theCloth._df, faces, sizeof(tri3f)*numFace, cudaMemcpyHostToDevice); cudaMemcpy(theCloth._dx, nodes, sizeof(REAL3)*numVert, cudaMemcpyHostToDevice); cudaMemcpy(theCloth._dx0, theCloth._dx, sizeof(REAL3)*numVert, cudaMemcpyDeviceToDevice); theCloth.computeWSdata(0, false); } void updateMesh2GPU(void *nodes,void *prenodes,REAL thickness) { //cudaMemcpy(theCloth._dx0, theCloth._dx, sizeof(REAL3)*theCloth.numVert, cudaMemcpyDeviceToDevice); cudaMemcpy(theCloth._dx, nodes, sizeof(REAL3)*theCloth.numVert, cudaMemcpyHostToDevice); cudaMemcpy(theCloth._dx0, prenodes, sizeof(REAL3)*theCloth.numVert, cudaMemcpyHostToDevice); theCloth.computeWSdata(thickness, true); REAL3* dx = new REAL3[theCloth.numVert]; REAL3* dx0 = new REAL3[theCloth.numVert]; cudaMemcpy(dx, theCloth._dx, sizeof(REAL3)*theCloth.numVert, cudaMemcpyDeviceToHost); cudaMemcpy(dx0, theCloth._dx0, sizeof(REAL3)*theCloth.numVert, cudaMemcpyDeviceToHost); vector<REAL3> tem; for (int i = 0; i < theCloth.numVert; i++) { tem.push_back(dx[i]); tem.push_back(dx0[i]); } int ss = 0; ss++; } //======================================================= void pushBVHIdx(int max_level, unsigned int *level_idx, bool isCloth) { theBVH[isCloth]._max_level = max_level; theBVH[isCloth]._level_idx = new uint[max_level]; memcpy(theBVH[isCloth]._level_idx, level_idx, sizeof(uint)*max_level); } void pushBVH(unsigned int length, int *ids, bool isCloth) { theBVH[isCloth]._num = length; checkCudaErrors(cudaMalloc((void**)&theBVH[isCloth]._bvh, length*sizeof(int) * 2)); checkCudaErrors(cudaMemcpy(theBVH[isCloth]._bvh, ids, length*sizeof(int) * 2, cudaMemcpyHostToDevice)); checkCudaErrors(cudaMalloc((void**)&theBVH[isCloth]._bxs, length*sizeof(g_box))); checkCudaErrors(cudaMemset(theBVH[isCloth]._bxs, 0, length*sizeof(g_box))); theBVH[isCloth].hBxs = NULL; theBVH[isCloth]._triBxs = isCloth ? theCloth._dfBx : NULL; theBVH[isCloth]._triCones = NULL; } void pushBVHLeaf(unsigned int length, int *idf, bool isCloth) { checkCudaErrors(cudaMalloc((void**)&theBVH[isCloth]._bvh_leaf, length*sizeof(int))); checkCudaErrors(cudaMemcpy(theBVH[isCloth]._bvh_leaf, idf, length*sizeof(int), cudaMemcpyHostToDevice)); } //====================================================== void refitBVH_Serial(bool isCloth, int length) { refit_serial_kernel << <1, 1, 0 >> > (theBVH[isCloth]._bvh, theBVH[isCloth]._bxs, theBVH[isCloth]._triBxs, theBVH[isCloth]._cones, theBVH[isCloth]._triCones, length == 0 ? theBVH[isCloth]._num : length); getLastCudaError("refit_serial_kernel"); cudaThreadSynchronize(); } void refitBVH_Parallel(bool isCloth, int st, int length) { BLK_PAR(length); refit_kernel << < B, T >> > (theBVH[isCloth]._bvh, theBVH[isCloth]._bxs, theBVH[isCloth]._triBxs, theBVH[isCloth]._cones, theBVH[isCloth]._triCones, st, length); getLastCudaError("refit_kernel"); cudaThreadSynchronize(); } void refitBVH(bool isCloth) { // before refit, need to get _tri_boxes !!!! // copying !!! for (int i = theBVH[isCloth]._max_level - 1; i >= 0; i--) { int st = theBVH[isCloth]._level_idx[i]; int ed = (i != theBVH[isCloth]._max_level - 1) ? theBVH[isCloth]._level_idx[i + 1] - 1 : theBVH[isCloth]._num - 1; int length = ed - st + 1; if (i < 5) { refitBVH_Serial(isCloth, length + st); break; } else { refitBVH_Parallel(isCloth, st, length); } } } //=============================================== void pushFront(bool self, int num, unsigned int *data) { g_front *f = &theFront[self]; f->init(); f->push(num, (uint4 *)data); } //=============================================== // show memory usage of GPU void reportMemory(char *tag) { //return; #ifdef OUTPUT_TXT size_t free_byte; size_t total_byte; cudaError_t cuda_status = cudaMemGetInfo(&free_byte, &total_byte); if (cudaSuccess != cuda_status) { printf("Error: cudaMemGetInfo fails, %s \n", cudaGetErrorString(cuda_status)); exit(1); } REAL free_db = (REAL)free_byte; REAL total_db = (REAL)total_byte; REAL used_db = total_db - free_db; printf("%s: GPU memory usage: used = %f, free = %f MB, total = %f MB\n", tag, used_db / 1024.0 / 1024.0, free_db / 1024.0 / 1024.0, total_db / 1024.0 / 1024.0); #endif } //=============================================== #define STACK_SIZE 50 #define EMPTY (nIdx == 0) #define PUSH_PAIR(nd1, nd2) {\ nStack[nIdx].x = nd1;\ nStack[nIdx].y = nd2;\ nIdx++;\ } #define POP_PAIR(nd1, nd2) {\ nIdx--;\ nd1 = nStack[nIdx].x;\ nd2 = nStack[nIdx].y;\ } #define NEXT(n1, n2) POP_PAIR(n1, n2) inline __device__ void pushToFront(int a, int b, uint4 *front, uint *idx, uint ptr) { // (*idx)++; if (*idx < MAX_FRONT_NUM) { uint offset = atomicAdd(idx, 1); front[offset] = make_uint4(a, b, 0, ptr); } } inline __device__ void sproutingAdaptive(int left, int right, int *bvhA, g_box *bxsA, int *bvhB, g_box *bxsB, uint4 *front, uint *frontIdx, uint2 *pairs, uint *pairIdx, bool update, uint ptr) { uint2 nStack[STACK_SIZE]; uint nIdx = 0; for (int i = 0; i<4; i++) { if (isLeaf(left, bvhA) && isLeaf(right, bvhB)) { pushToFront(left, right, front, frontIdx, ptr); } else { if (!overlaps(left, right, bxsA, bxsB)) { pushToFront(left, right, front, frontIdx, ptr); } else { if (isLeaf(left, bvhA)) { PUSH_PAIR(left, getLeftChild(right, bvhB)); PUSH_PAIR(left, getRightChild(right, bvhB)); } else { PUSH_PAIR(getLeftChild(left, bvhA), right); PUSH_PAIR(getRightChild(left, bvhA), right); } } } if (EMPTY) return; NEXT(left, right); } while (!EMPTY) { NEXT(left, right); pushToFront(left, right, front, frontIdx, ptr); } } inline __device__ void sprouting(int left, int right, int *bvhA, g_box *bxsA, int *bvhB, g_box *bxsB, uint4 *front, uint *frontIdx, int2 *pairs, uint *pairIdx, bool update, uint ptr, tri3f *Atris) { uint2 nStack[STACK_SIZE]; uint nIdx = 0; while (1) { if (isLeaf(left, bvhA) && isLeaf(right, bvhB)) { if (update) pushToFront(left, right, front, frontIdx, ptr); if (overlaps(left, right, bxsA, bxsB)) { if(!covertex(getTriID(left, bvhA), getTriID(right, bvhB), Atris)) addPair(getTriID(left, bvhA), getTriID(right, bvhB), pairs, pairIdx); } } else { if (!overlaps(left, right, bxsA, bxsB)) { if (update) pushToFront(left, right, front, frontIdx, ptr); } else { if (isLeaf(left, bvhA)) { PUSH_PAIR(left, getLeftChild(right, bvhB)); PUSH_PAIR(left, getRightChild(right, bvhB)); } else { PUSH_PAIR(getLeftChild(left, bvhA), right); PUSH_PAIR(getRightChild(left, bvhA), right); } } } if (EMPTY) return; NEXT(left, right); } } __device__ void doPropogate( uint4 *front, uint *frontIdx, int num, int *bvhA, g_box *bxsA, int bvhAnum, int *bvhB, g_box *bxsB, int bvhBnum, int2 *pairs, uint *pairIdx, bool update, tri3f *Atris, int idx, bool *flags) { uint4 node = front[idx]; if (node.z != 0) { #if defined(_DEBUG) || defined(OUTPUT_TXT) atomicAdd(frontIdx + 1, 1); #endif return; } #ifdef USE_NC if (flags != NULL && flags[node.w] == 0) { #if defined(_DEBUG) || defined(OUTPUT_TXT) atomicAdd(frontIdx + 2, 1); #endif return; } #endif uint left = node.x; uint right = node.y; if (isLeaf(left, bvhA) && isLeaf(right, bvhB)) { bool tem = overlaps(left, right, bxsA, bxsB); if (bxsA[left]._min.z > bxsB[right]._max.z) tem = false; if (bxsA[left]._min.z == bxsB[right]._max.z) tem = false; if (overlaps(left, right, bxsA, bxsB)) if (bvhA != bvhB) addPair(getTriID(left, bvhA), getTriID(right, bvhB), pairs, pairIdx); else { // for self ccd, we need to remove adjacent triangles, they will be processed seperatedly with orphan set if (!covertex(getTriID(left, bvhA), getTriID(right, bvhB), Atris)) addPair(getTriID(left, bvhA), getTriID(right, bvhB), pairs, pairIdx); } return; } if (!overlaps(left, right, bxsA, bxsB)) return; if (update) front[idx].z = 1; int ptr = node.w; if (isLeaf(left, bvhA)) { sprouting(left, getLeftChild(right, bvhB), bvhA, bxsA, bvhB, bxsB, front, frontIdx, pairs, pairIdx, update, ptr, Atris); sprouting(left, getRightChild(right, bvhB), bvhA, bxsA, bvhB, bxsB, front, frontIdx, pairs, pairIdx, update, ptr, Atris); } else { sprouting(getLeftChild(left, bvhA), right, bvhA, bxsA, bvhB, bxsB, front, frontIdx, pairs, pairIdx, update, ptr, Atris); sprouting(getRightChild(left, bvhA), right, bvhA, bxsA, bvhB, bxsB, front, frontIdx, pairs, pairIdx, update, ptr, Atris); } } __global__ void kernelPropogate(uint4 *front, uint *frontIdx, int num, int *bvhA, g_box *bxsA, int bvhAnum, int *bvhB, g_box *bxsB, int bvhBnum,uint* tt, int2 *pairs, uint *pairIdx, bool update, tri3f *Atris, int stride, bool *flags) { int idx = blockDim.x * blockIdx.x + threadIdx.x; for (int i = 0; i<stride; i++) { int j = idx*stride + i; if (j >= num) return; atomicAdd(tt, 1); doPropogate(front, frontIdx, num, bvhA, bxsA, bvhAnum, bvhB, bxsB, bvhBnum, pairs, pairIdx, update, Atris, j, flags); } } int g_front::propogate(bool &update, bool self, bool ccd) { uint dummy[1]; cutilSafeCall(cudaMemcpy(dummy, _dIdx, 1 * sizeof(uint), cudaMemcpyDeviceToHost)); #ifdef OUTPUT_TXT printf("Before propogate, length = %d\n", dummy[0]); #endif #if defined(_DEBUG) || defined(OUTPUT_TXT) uint dummy2[5] = { 0, 0, 0, 0, 0 }; cutilSafeCall(cudaMemcpy(_dIdx + 1, dummy2, 5 * sizeof(int), cudaMemcpyHostToDevice)); #endif if (dummy[0] != 0) { g_bvh *pb1 = &theBVH[1]; g_bvh *pb2 = (self) ? &theBVH[1] : &theBVH[0]; tri3f *faces = (self ? theCloth._df: NULL); int stride = 4; #ifdef FIX_BT_NUM BLK_PAR2(dummy[0], stride); #else BLK_PAR3(dummy[0], stride, getBlkSize((void *)kernelPropogate)); #endif uint* tt; cutilSafeCall(cudaMalloc((void**)&tt, 1 * sizeof(uint))); uint ttt = 0; cutilSafeCall(cudaMemcpy(tt, &ttt, 1 * sizeof(uint), cudaMemcpyHostToDevice)); kernelPropogate << < B, T >> > (_dFront, _dIdx, dummy[0], pb1->_bvh, pb1->_bxs, pb1->_num, pb2->_bvh, pb2->_bxs, pb2->_num,tt, thePairs[self]._dPairs, thePairs[self]._dIdx, update, faces, stride, self ? theBVH[1]._ctFlags : NULL); //thePairs[self]._dPairs, thePairs[self]._dIdx, update, faces, stride, (self && !ccd) ? theBVH[1]._ctFlags : NULL); //reportMemory("propogate"); //cutilSafeCall(cudaMemcpy(&ttt, tt, 1 * sizeof(uint), cudaMemcpyDeviceToHost)); cudaThreadSynchronize(); getLastCudaError("kernelPropogate"); } cutilSafeCall(cudaMemcpy(dummy, _dIdx, 1 * sizeof(uint), cudaMemcpyDeviceToHost)); #ifdef OUTPUT_TXT printf("After propogate, length = %d\n", dummy[0]); #endif #if defined(_DEBUG) || defined(OUTPUT_TXT) cutilSafeCall(cudaMemcpy(dummy2, _dIdx + 1, 5 * sizeof(int), cudaMemcpyDeviceToHost)); //printf("Invalid = %d, NC culled = %d\n", dummy2[0], dummy2[1]); #endif if (update && dummy[0] > SAFE_FRONT_NUM) { printf("Too long front, stop updating ...\n"); update = false; } if (dummy[0] > MAX_FRONT_NUM) { printf("Too long front, exiting ...\n"); exit(0); } return dummy[0]; } //=============================================== __global__ void kernel_face_ws(tri3f *face, REAL3 *x, REAL3 *ox, g_box *bxs, bool ccd, REAL thickness, int num) { LEN_CHK(num); int id0 = face[idx].id0(); int id1 = face[idx].id1(); int id2 = face[idx].id2(); REAL3 ox0 = ox[id0]; REAL3 ox1 = ox[id1]; REAL3 ox2 = ox[id2]; REAL3 x0 = x[id0]; REAL3 x1 = x[id1]; REAL3 x2 = x[id2]; bxs[idx].set(ox0, ox1); bxs[idx].add(ox2); if (ccd) { bxs[idx].add(x0); bxs[idx].add(x1); bxs[idx].add(x2); } //else bxs[idx].enlarge(thickness); } void g_mesh::computeWSdata(REAL thickness, bool ccd) { if (numFace == 0) return; { int num = numFace; BLK_PAR(num); kernel_face_ws << <B, T >> > ( _df, _dx, _dx0, _dfBx, ccd, thickness, num); getLastCudaError("kernel_face_ws"); } } //=============================================== __device__ REAL triProduct(REAL3 &a, REAL3 &b, REAL3 &c) { return dot(cross(a, b), c); } __device__ REAL3 xvpos(REAL3 x, REAL3 v, REAL t) { return x + v*t; } __device__ int sgn(REAL x) { return x<0 ? -1 : 1; } __device__ int solve_quadratic(REAL a, REAL b, REAL c, REAL x[2]) { // http://en.wikipedia.org/wiki/Quadratic_formula#Floating_point_implementation REAL d = b*b - 4 * a*c; if (d < 0) { x[0] = -b / (2 * a); return 0; } REAL q = -(b + sgn(b)*sqrt(d)) / 2; int i = 0; if (abs(a) > 1e-12*abs(q)) x[i++] = q / a; if (abs(q) > 1e-12*abs(c)) x[i++] = c / q; if (i == 2 && x[0] > x[1]) fswap(x[0], x[1]); return i; } __device__ REAL newtons_method(REAL a, REAL b, REAL c, REAL d, REAL x0, int init_dir) { if (init_dir != 0) { // quadratic approximation around x0, assuming y' = 0 REAL y0 = d + x0*(c + x0*(b + x0*a)), ddy0 = 2 * b + x0*(6 * a); x0 += init_dir*sqrt(abs(2 * y0 / ddy0)); } for (int iter = 0; iter < 100; iter++) { REAL y = d + x0*(c + x0*(b + x0*a)); REAL dy = c + x0*(2 * b + x0 * 3 * a); if (dy == 0) return x0; REAL x1 = x0 - y / dy; if (abs(x0 - x1) < 1e-6) return x0; x0 = x1; } return x0; } // solves a x^3 + b x^2 + c x + d == 0 __device__ int solve_cubic(REAL a, REAL b, REAL c, REAL d, REAL x[3]) { REAL xc[2]; int ncrit = solve_quadratic(3 * a, 2 * b, c, xc); if (ncrit == 0) { x[0] = newtons_method(a, b, c, d, xc[0], 0); return 1; } else if (ncrit == 1) {// cubic is actually quadratic return solve_quadratic(b, c, d, x); } else { REAL yc[2] = { d + xc[0] * (c + xc[0] * (b + xc[0] * a)), d + xc[1] * (c + xc[1] * (b + xc[1] * a)) }; int i = 0; if (yc[0] * a >= 0) x[i++] = newtons_method(a, b, c, d, xc[0], -1); if (yc[0] * yc[1] <= 0) { int closer = abs(yc[0])<abs(yc[1]) ? 0 : 1; x[i++] = newtons_method(a, b, c, d, xc[closer], closer == 0 ? 1 : -1); } if (yc[1] * a <= 0) x[i++] = newtons_method(a, b, c, d, xc[1], 1); return i; } } REAL signed_ee_distance(const REAL3 &x0, const REAL3 &x1, const REAL3 &y0, const REAL3 &y1, REAL3 *n, REAL *w); __device__ REAL signed_vf_distance (const REAL3 &x, const REAL3 &y0, const REAL3 &y1, const REAL3 &y2, REAL3 *n, REAL *w); __device__ bool collision_test( const REAL3 &x0, const REAL3 &x1, const REAL3 &x2, const REAL3 &x3, const REAL3 &v0, const REAL3 &v1, const REAL3 &v2, const REAL3 &v3,REAL &time,const int isVF)//0:vf 1:ee { REAL a0 = stp(x1, x2, x3), a1 = stp(v1, x2, x3) + stp(x1, v2, x3) + stp(x1, x2, v3), a2 = stp(x1, v2, v3) + stp(v1, x2, v3) + stp(v1, v2, x3), a3 = stp(v1, v2, v3); if (a1 == 0 && a2 == 0 && a3 == 0) return false; REAL t[4]; int nsol = solve_cubic(a3, a2, a1, a0, t); //t[nsol] = 1; // also check at end of timestep bool t_flag = false; for (int i = 0; i < nsol; i++) { if (t[i] < 0 || t[i] > 1) continue; REAL3 tx0 = xvpos(x0, v0, t[i]), tx1 = xvpos(x1 + x0, v1 + v0, t[i]), tx2 = xvpos(x2 + x0, v2 + v0, t[i]), tx3 = xvpos(x3 + x0, v3 + v0, t[i]); REAL3 n; REAL w[4]; REAL d; bool inside; if (isVF == 0) { d = signed_vf_distance(tx0, tx1, tx2, tx3, &n, w); inside = (fmin(-w[1], fmin(-w[2], -w[3])) >= -1e-6); } else {// Impact::EE d = signed_ee_distance(tx0, tx1, tx2, tx3, &n, w); inside = (fmin(fmin(w[0], w[1]), fmin(-w[2], -w[3])) >= -1e-6); } if (fabs(d) < 1e-6 && inside) { time = t[i]; return true; } //t_flag = true; //if (t[i] < time) //time = t[i]; } return t_flag; } __device__ void doImpactVF( REAL3 x0, REAL3 x1, REAL3 x2, REAL3 x3, REAL3 x00,REAL3 x10,REAL3 x20,REAL3 x30,REAL &time ) { REAL3 p0 = x00; REAL3 p1 = x10 - x00; REAL3 p2 = x20 - x00; REAL3 p3 = x30 - x00; REAL3 v0 = x0 - x00; REAL3 v1 = x1 - x10 - v0; REAL3 v2 = x2 - x20 - v0; REAL3 v3 = x3 - x30 - v0; /* if (iii == 69 && vid == 162 && t.id0() == 4 && t.id1() == 44 && t.id2() == 32) vid = 162; */ #ifdef USE_DNF_FILTER //bool ret1 = dnf_filter(x00, x10, x20, x30, x0, x1, x2, x3); #endif bool ret = collision_test(p0, p1, p2, p3, v0, v1, v2, v3,time,0); if (ret) { } } inline __device__ REAL3 norm(REAL3 p1, REAL3 p2, REAL3 p3) { return cross(p2 - p1, p3 - p1); } inline __device__ bool dnf_filter(REAL3 &a0, REAL3 &b0, REAL3 &c0, REAL3 &d0, REAL3 &a1, REAL3 &b1, REAL3 &c1, REAL3 &d1) { REAL3 n0 = norm(a0, b0, c0); REAL3 n1 = norm(a1, b1, c1); REAL3 delta = norm(a1 - a0, b1 - b0, c1 - c0); REAL3 nX = (n0 + n1 - delta)*REAL(0.5); REAL3 pa0 = d0 - a0; REAL3 pa1 = d1 - a1; REAL A = dot(n0, pa0); REAL B = dot(n1, pa1); REAL C = dot(nX, pa0); REAL D = dot(nX, pa1); REAL E = dot(n1, pa0); REAL F = dot(n0, pa1); if (A > 0 && B > 0 && (REAL(2.0) * C + F) > 0 && (REAL(2.0) * D + E) > 0) return false; if (A < 0 && B < 0 && (REAL(2.0) * C + F) < 0 && (REAL(2.0) * D + E) < 0) return false; return true; } __device__ void doImpactEE( REAL3 x0, REAL3 x1, REAL3 x2, REAL3 x3, REAL3 x00, REAL3 x10, REAL3 x20, REAL3 x30, REAL &time) { REAL3 p0 = x00; REAL3 p1 = x10 - x00; REAL3 p2 = x20 - x00; REAL3 p3 = x30 - x00; REAL3 v0 = x0 - x00; REAL3 v1 = x1 - x10 - v0; REAL3 v2 = x2 - x20 - v0; REAL3 v3 = x3 - x30 - v0; #ifdef USE_DNF_FILTER //bool ret1 = dnf_filter(x10, x20, x30, x40, x1, x2, x3, x4); #endif /* if (e0.x == 41 && e0.y == 624 && e1.x == 599 && e1.y == 383) e0.x = 41; */ //bool ret1 = dnf_filter(p0, p1, p2, p3, v0, v1, v2, v3); //if (!ret1) //{ // return; //} bool ret = collision_test(p0, p1, p2, p3, v0, v1, v2, v3,time,1); if (ret) { } } __device__ REAL signed_vf_distance (const REAL3 &x, const REAL3 &y0, const REAL3 &y1, const REAL3 &y2, REAL3 *n, REAL *w) { REAL3 _n; if (!n) n = &_n; REAL _w[4]; if (!w) w = _w; *n = cross(normalize(y1 - y0), normalize(y2 - y0)); if (norm2(*n) < 1e-6) return REAL_infinity; *n = normalize(*n); REAL h = dot(x - y0, *n); REAL b0 = stp(y1 - x, y2 - x, *n), b1 = stp(y2 - x, y0 - x, *n), b2 = stp(y0 - x, y1 - x, *n); w[0] = 1; w[1] = -b0 / (b0 + b1 + b2); w[2] = -b1 / (b0 + b1 + b2); w[3] = -b2 / (b0 + b1 + b2); return h; } __device__ REAL signed_ee_distance(const REAL3 &x0, const REAL3 &x1, const REAL3 &y0, const REAL3 &y1, REAL3 *n, REAL *w) { REAL3 _n; if (!n) n = &_n; REAL _w[4]; if (!w) w = _w; *n = cross(normalize(x1 - x0), normalize(y1 - y0)); if (norm2(*n) < 1e-6) return REAL_infinity; *n = normalize(*n); REAL h = dot(x0 - y0, *n); REAL a0 = stp(y1 - x1, y0 - x1, *n), a1 = stp(y0 - x0, y1 - x0, *n), b0 = stp(x0 - y1, x1 - y1, *n), b1 = stp(x1 - y0, x0 - y0, *n); w[0] = a0 / (a0 + a1); w[1] = a1 / (a0 + a1); w[2] = -b0 / (b0 + b1); w[3] = -b1 / (b0 + b1); return h; } __device__ REAL doProximityVF( REAL3 _x4, REAL3 _x1, REAL3 _x2, REAL3 _x3, REAL *_mrt ) { REAL mrt = _mrt[0]; REAL3 x1 = _x1; REAL3 x2 = _x2; REAL3 x3 = _x3; REAL3 x4 = _x4; REAL3 n; REAL w[4]; REAL d = signed_vf_distance(x4, x1, x2, x3, &n, w); d = abs(d); const REAL dmin = mrt; if (d >= dmin) return d; bool inside = (min(min(-w[1], -w[2]), -w[3]) >= -1e-6); if (!inside) return -d; return d; } __device__ REAL doProximityEE( REAL3 _e00, REAL3 _e01, REAL3 _e10, REAL3 _e11, REAL *_mrt ) { REAL mrt = _mrt[0]; REAL3 e00 = _e00; REAL3 e01 = _e01; REAL3 e10 = _e10; REAL3 e11 = _e11; /* if (e0.x == 891 && e0.y == 446 && e1.x == 18 && e1.y == 188) e1.x = 18; */ REAL3 n; REAL w[4]; REAL d = signed_ee_distance(e00, e01, e10, e11, &n, w); d = abs(d); if (d == 0) int sd = d; const REAL dmin = mrt; if (d >= dmin) return d; bool inside = min(min(w[0], w[1]), min(-w[2], -w[3])) >= -1e-6; if (!inside) return -d; return d; } __device__ void tri_CCD( uint t1, uint t2, uint t3, uint tt1, uint tt2, uint tt3, REAL3 *cx, REAL3 *cx0, int2 *pairRets, uint *pairIdx, int fid1, int fid2, int *t ) { REAL3 p[3]; p[0] = cx[t1]; p[1] = cx[t2]; p[2] = cx[t3]; REAL3 pp[3]; pp[0] = cx0[t1]; pp[1] = cx0[t2]; pp[2] = cx0[t3]; REAL3 q[3]; q[0] = cx[tt1]; q[1] = cx[tt2]; q[2] = cx[tt3]; REAL3 qq[3]; qq[0] = cx0[tt1]; qq[1] = cx0[tt2]; qq[2] = cx0[tt3]; REAL time = 2; ///* //VF for (int st = 0; st < 3; st++) { doImpactVF( p[st], q[0], q[1], q[2], pp[st], qq[0], qq[1], qq[2], time ); } //VF for (int st = 0; st < 3; st++) { doImpactVF(q[st], p[0], p[1], p[2], qq[st], pp[0], pp[1], pp[2], time ); } //EE uint idx0[3]; uint idx1[3]; idx0[0] = t1; idx0[1] = t2; idx0[2] = t3; idx1[0] = tt1; idx1[1] = tt2; idx1[2] = tt3; for (int st = 0; st < 3; st++) { int ind0 = st; int ind1 = (st + 1) % 3; for (int ss = 0; ss < 3; ss++) { int ind2 = st; int ind3 = (st + 1) % 3; doImpactEE( cx[idx0[ind0]], cx[idx0[ind1]], cx[idx1[ind2]], cx[idx1[ind3]], cx0[idx0[ind0]], cx0[idx0[ind1]], cx0[idx1[ind2]], cx0[idx1[ind3]], time ); } } if (time >= 0 && time <= 1) { //int index = addPair(fid1, fid2, pairRets, pairIdx); //if (index != -1) //{ t[0]=1; //} } } __device__ void tri_DCD( uint t1, uint t2, uint t3, uint tt1, uint tt2, uint tt3, REAL3 *cx, REAL3 *cx0, int2 *pairRets, int4 *dv, int *VF_EE, REAL* dist,int *CCDres,int *t, uint *pairIdx, int fid1, int fid2, REAL *thickness ) { REAL3 p[3]; p[0] = cx[t1]; p[1] = cx[t2]; p[2] = cx[t3]; REAL3 pp[3]; pp[0] = cx0[t1]; pp[1] = cx0[t2]; pp[2] = cx0[t3]; REAL3 q[3]; q[0] = cx[tt1]; q[1] = cx[tt2]; q[2] = cx[tt3]; REAL3 qq[3]; qq[0] = cx0[tt1]; qq[1] = cx0[tt2]; qq[2] = cx0[tt3]; //REAL time = 2; uint idx0[3]; uint idx1[3]; idx0[0] = t1; idx0[1] = t2; idx0[2] = t3; idx1[0] = tt1; idx1[1] = tt2; idx1[2] = tt3; REAL time = 2; t[0] = 0; ///* //VF for (int st = 0; st < 3; st++) { t[0] = 0; time = 2; doImpactVF( p[st], q[0], q[1], q[2], pp[st], qq[0], qq[1], qq[2], time ); REAL d = doProximityVF( p[st], q[0], q[1], q[2], thickness ); if ((time >= 0 && time <= 1)) { t[0] = 1; } if ((time >= 0 && time <= 1)||(d<thickness[0] && d>=0)) { addPairDCD(fid1, fid2, 0, idx0[st], idx1[0], idx1[1], idx1[2], d, t, pairRets, dv, VF_EE, dist, CCDres, pairIdx); } if (d != -1) { //addPairDCD(fid1, fid2, 0, idx0[st], idx1[0], idx1[1], idx1[2], d,t, // pairRets, dv, VF_EE, dist, CCDres,pairIdx); } } //VF for (int st = 0; st < 3; st++) { t[0] = 0; time = 2; if (st == 0) { REAL d = doProximityVF( q[st], p[0], p[1], p[2], thickness ); } doImpactVF(q[st], p[0], p[1], p[2], qq[st], pp[0], pp[1], pp[2], time ); REAL d = doProximityVF( q[st], p[0], p[1], p[2], thickness ); if ((time >= 0 && time <= 1)) { t[0] = 1; } if ((time >= 0 && time <= 1) || (d < thickness[0] && d >= 0)) { addPairDCD(fid1, fid2, 0, idx1[st], idx0[0], idx0[1], idx0[2], d, t, pairRets, dv, VF_EE, dist, CCDres, pairIdx); } if (d != -1) { //addPairDCD(fid1, fid2, 0, idx1[st], idx0[0], idx0[1], idx0[2], d,t, // pairRets, dv, VF_EE, dist, CCDres, pairIdx); } } //EE for (int st = 0; st < 3; st++) { int ind0 = st; int ind1 = (st + 1) % 3; for (int ss = 0; ss < 3; ss++) { int ind2 = ss; int ind3 = (ss + 1) % 3; t[0] = 0; time = 2; doImpactEE( cx[idx0[ind0]], cx[idx0[ind1]], cx[idx1[ind2]], cx[idx1[ind3]], cx0[idx0[ind0]], cx0[idx0[ind1]], cx0[idx1[ind2]], cx0[idx1[ind3]], time ); REAL d = doProximityEE( cx[idx0[ind0]], cx[idx0[ind1]], cx[idx1[ind2]], cx[idx1[ind3]], thickness ); if ((time >= 0 && time <= 1)) { t[0] = 1; } if ((time >= 0 && time <= 1) || (d < thickness[0] && d >= 0)) { addPairDCD(fid1, fid2, 1, idx0[ind0], idx0[ind1], idx1[ind2], idx1[ind3], d, t, pairRets, dv, VF_EE, dist, CCDres, pairIdx); } if (d != -1) { //addPairDCD(fid1, fid2, 1, idx0[ind0], idx0[ind1], idx1[ind2], idx1[ind3], d,t, // pairRets, dv, VF_EE, dist, CCDres, pairIdx); } } } } __global__ void kernelGetCollisions( int2 *pairs, int num, REAL3 *cx, REAL3 *cx0,tri3f *ctris, int2 *pairRets, int4 *dv, int *VF_EE, REAL* dist,int *CCDres, uint *pairIdx, int *t, REAL *thickness, int stride) { int idxx = blockDim.x * blockIdx.x + threadIdx.x; for (int i = 0; i < stride; i++) { int j = idxx*stride + i; if (j >= num) return; int idx = j; int2 pair = pairs[idx]; int fid1 = pair.x; int fid2 = pair.y; int ss = 0; tri3f t1 = ctris[fid1]; tri3f t2 = ctris[fid2]; uint tt1[3]; uint tt2[3]; tt1[0] = t1.id0(); tt1[1] = t1.id1(); tt1[2] = t1.id2(); tt2[0] = t2.id0(); tt2[1] = t2.id1(); tt2[2] = t2.id2(); #ifdef FOR_DEBUG bool find = false; if (fid1 == 369 && fid2 == 3564) find = true; if (fid2 == 369 && fid1 == 3564) find = true; #endif REAL3 p[3]; p[0] = cx[t1.id0()]; p[1] = cx[t1.id1()]; p[2] = cx[t1.id2()]; REAL3 pp[3]; pp[0] = cx0[t1.id0()]; pp[1] = cx0[t1.id1()]; pp[2] = cx0[t1.id2()]; REAL3 q[3]; q[0] = cx[t2.id0()]; q[1] = cx[t2.id1()]; q[2] = cx[t2.id2()]; REAL3 qq[3]; qq[0] = cx0[t2.id0()]; qq[1] = cx0[t2.id1()]; qq[2] = cx0[t2.id2()]; bool iscovetex = false; for (int st = 0; st < 3; st++) { for (int ss = 0; ss < 3; ss++) { if (tt1[st] == tt2[ss]) { iscovetex = true; } } } if (iscovetex) continue; //tri_CCD(t1.id0(), t1.id1(), t1.id2(), t2.id0(), t2.id1(), t2.id2(), cx, cx0, pairRets, pairIdx, fid1, fid2, t); tri_DCD(t1.id0(), t1.id1(), t1.id2(), t2.id0(), t2.id1(), t2.id2(), cx, cx0, pairRets, dv, VF_EE, dist,CCDres,t, pairIdx, fid1, fid2, thickness); } /* ///* //VF for (int st = 0; st < 3; st++) { doImpactVF( p[st], q[0], q[1], q[2], pp[st], qq[0], qq[1], qq[2], time ); } //VF for (int st = 0; st < 3; st++) { doImpactVF(q[st], p[0], p[1], p[2], qq[st], pp[0], pp[1], pp[2], time ); } //EE int idx0[2]; int idx1[2]; for (int st = 0; st < 3; st++) { idx0[0] = st; idx0[1] = (st + 1) % 3; for (int ss = 0; ss < 3; ss++) { idx1[0] = ss; idx1[1] = (ss + 1) % 3; doImpactEE( cx[idx0[0]], cx[idx0[1]], cx[idx1[0]], cx[idx1[1]], cx0[idx0[0]], cx0[idx0[1]], cx0[idx1[0]], cx0[idx1[1]], time ); } } #ifdef FOR_DEBUG if (find) { printf("%d: %lf, %lf, %lf\n", t1.id0(), p0.x, p0.y, p0.z); printf("%d: %lf, %lf, %lf\n", t1.id1(), p1.x, p1.y, p1.z); printf("%d: %lf, %lf, %lf\n", t1.id2(), p2.x, p2.y, p2.z); printf("%d: %lf, %lf, %lf\n", t2.id0(), q0.x, q0.y, q0.z); printf("%d: %lf, %lf, %lf\n", t2.id1(), q1.x, q1.y, q1.z); printf("%d: %lf, %lf, %lf\n", t2.id2(), q2.x, q2.y, q2.z); } #endif REAL3 p0 = cx[t1.id0()]; REAL3 p1 = cx[t1.id1()]; REAL3 p2 = cx[t1.id2()]; REAL3 q0 = cx[t2.id0()]; REAL3 q1 = cx[t2.id1()]; REAL3 q2 = cx[t2.id2()]; if (tri_contact(p0, p1, p2, q0, q1, q2)) addPair(fid1, fid2, pairRets, pairIdx); if (time >= 0 && time <= 1) { int index = addPair(fid1, fid2, pairRets, pairIdx); if (index != -1) { t[index] = time; } } } */ } //=============================================== int g_pair::getCollisions(bool self, g_pairCCD &ret, int *time, REAL* thickness) { int num = length(); printf("pair = %d\n", num); #ifdef OUTPUT_TXT //if (self) //printf("self pair = %d\n", num); //else //printf("inter-obj pair = %d\n", num); #endif if (num == 0) return 0; ret.clear(); int stride = 4; #ifdef FIX_BT_NUM BLK_PAR3(num, stride, 32); #else BLK_PAR3(num, stride, getBlkSize((void *)kernelGetCollisions)); #endif int *tem_time; int tem = 0; cutilSafeCall(cudaMalloc((void**)&tem_time, 1 * sizeof(int))); cutilSafeCall(cudaMemcpy(tem_time, &tem, 1 * sizeof(int), cudaMemcpyHostToDevice)); REAL *gthickness; cutilSafeCall(cudaMalloc((void**)&gthickness, 1 * sizeof(REAL))); cutilSafeCall(cudaMemcpy(gthickness, thickness, 1 * sizeof(REAL), cudaMemcpyHostToDevice)); kernelGetCollisions << < B, T >> > (_dPairs, num, theCloth._dx, theCloth._dx0, theCloth._df, ret._dPairs, ret._dv, ret._dVF_EE, ret.dist,ret.CCD_res, ret._dIdx, tem_time, gthickness, stride); getLastCudaError("kernelGetCollisions"); int len = ret.length(); #ifdef OUTPUT_TXT //printf("collision num = %d\n", len); #endif printf("collision num = %d\n", len); //if (len > 0) //{ cutilSafeCall(cudaMemcpy(time, tem_time, sizeof(int)* 1, cudaMemcpyDeviceToHost)); //} cudaFree(tem_time); return len; } //=============================================== int getCollisionsGPU(int *rets, int *vf_ee, int *vertex_id, REAL *dist, int *time,int* CCDres, REAL* thickness) { bool update = true; int len = 0; TIMING_BEGIN thePairs[1].clear(); refitBVH(true); theFront[1].propogate(update, 1, false); cudaThreadSynchronize(); len = thePairs[1].getCollisions(true, retPairsCCD, time, thickness); cudaThreadSynchronize(); TIMING_END("$$$get_collisions_gpu") if (len > 0) { cutilSafeCall(cudaMemcpy(rets, retPairsCCD._dPairs, sizeof(uint) * 2 * len, cudaMemcpyDeviceToHost)); cutilSafeCall(cudaMemcpy(vf_ee, retPairsCCD._dVF_EE, sizeof(int) * len, cudaMemcpyDeviceToHost)); cutilSafeCall(cudaMemcpy(vertex_id, retPairsCCD._dv, sizeof(int) * 4 * len, cudaMemcpyDeviceToHost)); cutilSafeCall(cudaMemcpy(dist, retPairsCCD.dist, sizeof(double) * len, cudaMemcpyDeviceToHost)); cutilSafeCall(cudaMemcpy(CCDres, retPairsCCD.CCD_res, sizeof(int) * len, cudaMemcpyDeviceToHost)); } return len; }
346670d21237cd013e283bfb2b581e1f941277a5.hip
// !!! This is a file automatically generated by hipify!!! //////////////////////////////////////////////////////////////////////////////// /** * @file main.cpp * @date 2017-03-04 * @author Tiago Lobato Gimenes ([email protected]) * * @copyright * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ //////////////////////////////////////////////////////////////////////////////// #include <cstdlib> #include <vector> #include <iostream> #include <fstream> #include <sstream> #include <string> #include <chrono> #include <hip/hip_runtime.h> #include "log.hpp" #include "utils.hpp" #include "parser.hpp" #include "su_gather.hpp" //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// __global__ void init_c(real *c, real inc, real c0) { int i = blockIdx.x; c[i] = c0 + inc*i; } //////////////////////////////////////////////////////////////////////////////// __global__ void init_half(const real* __restrict scalco, const real* __restrict gx, const real* __restrict gy, const real* __restrict sx, const real* __restrict sy, real* __restrict h) { int i = blockIdx.x; real _s = scalco[i]; if(-EPSILON < _s && _s < EPSILON) _s = 1.0f; else if(_s < 0) _s = 1.0f / _s; real hx = (gx[i] - sx[i]) * _s; real hy = (gy[i] - sy[i]) * _s; h[i] = 0.25f * (hx * hx + hy * hy) / FACTOR; } //////////////////////////////////////////////////////////////////////////////// __global__ void compute_semblances(const real* __restrict h, const real* __restrict c, const real* __restrict samples, real* __restrict num, real* __restrict stt, int t_id0, int t_idf, real _idt, real _dt, int _tau, int _w, int nc, int ns) { real _den = 0.0f, _ac_linear = 0.0f, _ac_squared = 0.0f; real _num[MAX_W], m = 0.0f; int err = 0; int i = blockIdx.x * NTHREADS + threadIdx.x; int t0 = i / nc; int c_id = i % nc; if(i < ns * nc) { real _c = c[c_id]; real _t0 = _dt * t0; _t0 *= _t0; for(int j=0; j < _w; j++) _num[j] = 0.0f; for(int t_id=t_id0; t_id < t_idf; t_id++) { real t = sqrtf(_t0 + _c * h[t_id]) * _idt; int it = (int)( t ); int ittau = it - _tau; real x = t - (real)it; if(ittau >= 0 && it + _tau + 1 < ns) { int k1 = ittau + (t_id-t_id0)*ns; real sk1p1 = samples[k1], sk1; for(int j=0; j < _w; j++) { k1++; sk1 = sk1p1; sk1p1 = samples[k1]; // linear interpolation optmized for this problema real v = (sk1p1 - sk1) * x + sk1; _num[j] += v; _den += v * v; _ac_linear += v; } m += 1; } else { err++; } } // Reduction for num for(int j=0; j < _w; j++) _ac_squared += _num[j] * _num[j]; // Evaluate semblances if(_den > EPSILON && m > EPSILON && _w > EPSILON && err < 2) { num[i] = _ac_squared / (_den * m); stt[i] = _ac_linear / (_w * m); } else { num[i] = -1.0f; stt[i] = -1.0f; } } } //////////////////////////////////////////////////////////////////////////////// __global__ void redux_semblances(const real* __restrict num, const real* __restrict stt, int* __restrict ctr, real* __restrict str, real* __restrict stk, const int nc, const int cdp_id, const int ns) { int t0 = blockIdx.x * NTHREADS + threadIdx.x; if(t0 < ns) { real max_sem = 0.0f; int max_c = -1; for(int it=t0*nc; it < (t0+1)*nc ; it++) { real _num = num[it]; if(_num > max_sem) { max_sem = _num; max_c = it; } } ctr[cdp_id*ns + t0] = max_c % nc; str[cdp_id*ns + t0] = max_sem; stk[cdp_id*ns + t0] = max_c > -1 ? stt[max_c] : 0; } } //////////////////////////////////////////////////////////////////////////////// int main(int argc, const char** argv) { #ifdef SAVE std::ofstream c_out("cmp.c.su", std::ofstream::out | std::ios::binary); std::ofstream s_out("cmp.coher.su", std::ofstream::out | std::ios::binary); std::ofstream stack("cmp.stack.su", std::ofstream::out | std::ios::binary); #endif // Parse command line and read arguments parser::add_argument("-c0", "C0 constant"); parser::add_argument("-c1", "C1 constant"); parser::add_argument("-nc", "NC constant"); parser::add_argument("-aph", "APH constant"); parser::add_argument("-tau", "Tau constant"); parser::add_argument("-i", "Data path"); parser::add_argument("-v", "Verbosity Level 0-3"); parser::parse(argc, argv); // Read parameters and input const real c0 = std::stof(parser::get("-c0", true)) * FACTOR; const real c1 = std::stof(parser::get("-c1", true)) * FACTOR; const real itau = std::stof(parser::get("-tau", true)); const int nc = std::stoi(parser::get("-nc", true)); const int aph = std::stoi(parser::get("-aph", true)); std::string path = parser::get("-i", true); logger::verbosity_level(std::stoi(parser::get("-v", false))); // Reads *.su data and starts gather su_gather gather(path, aph, nc); real *h_gx, *h_gy, *h_sx, *h_sy, *h_scalco, *h_samples, *h_str, *h_stk, dt; int *ntraces_by_cdp_id, *h_ctr; // Linearize gather data in order to improve data coalescence in GPU gather.linearize(ntraces_by_cdp_id, h_samples, dt, h_gx, h_gy, h_sx, h_sy, h_scalco, nc); const int ttraces = gather.ttraces(); // Total traces -> Total amount of traces read const int ncdps = gather().size(); // Number of cdps -> Total number of cdps read const int ns = gather.ns(); // Number of samples const int ntrs = gather.ntrs(); // Max number of traces by cdp const real inc = (c1-c0) * (1.0f / (real)nc); dt = dt / 1000000.0f; real idt = 1.0f / dt; int tau = ((int)( itau * idt) > 0) ? ((int)( itau * idt)) : 0; int w = (2 * tau) + 1; int number_of_semblances = 0; LOG(DEBUG, "Starting CMP execution"); // Alloc memory real *d_h, *d_gx, *d_gy, *d_sx, *d_sy, *d_scalco, *d_cdpsmpl; real *d_c, *d_num, *d_stt, *d_str, *d_stk; // nc stts per sample int *d_ctr; // ns Cs per cdp hipMalloc((void**)&d_gx, sizeof(real)*ttraces); hipMalloc((void**)&d_gy, sizeof(real)*ttraces); hipMalloc((void**)&d_sx, sizeof(real)*ttraces); hipMalloc((void**)&d_sy, sizeof(real)*ttraces); hipMalloc((void**)&d_scalco, sizeof(real)*ttraces); hipMalloc((void**)&d_cdpsmpl, sizeof(real)*ntrs*ns); hipMemcpy(d_gx , h_gx , sizeof(real)*ttraces, hipMemcpyHostToDevice); hipMemcpy(d_gy , h_gy , sizeof(real)*ttraces, hipMemcpyHostToDevice); hipMemcpy(d_sx , h_sx , sizeof(real)*ttraces, hipMemcpyHostToDevice); hipMemcpy(d_sy , h_sy , sizeof(real)*ttraces, hipMemcpyHostToDevice); hipMemcpy(d_scalco, h_scalco, sizeof(real)*ttraces, hipMemcpyHostToDevice); hipMalloc((void** ) &d_c , sizeof(real)*nc ); hipMemset(d_c , 0, sizeof(real)*nc ); hipMalloc((void** ) &d_h , sizeof(real)*ttraces ); hipMemset(d_h , 0, sizeof(real)*ttraces ); hipMalloc((void** ) &d_num, sizeof(real)*ns*nc ); hipMemset(d_num, 0, sizeof(real)*ns*nc ); hipMalloc((void** ) &d_stt, sizeof(real)*ns*nc ); hipMemset(d_stt, 0, sizeof(real)*ns*nc ); hipMalloc((void** ) &d_ctr, sizeof(int )*ncdps*ns); hipMemset(d_ctr, 0, sizeof(int )*ncdps*ns); hipMalloc((void** ) &d_str, sizeof(real)*ncdps*ns); hipMemset(d_str, 0, sizeof(real)*ncdps*ns); hipMalloc((void** ) &d_stk, sizeof(real)*ncdps*ns); hipMemset(d_stk, 0,sizeof(real)*ncdps*ns); h_ctr = (int*) malloc (sizeof(int )*ncdps*ns); h_str = (real*) malloc (sizeof(real)*ncdps*ns); h_stk = (real*) malloc (sizeof(real)*ncdps*ns); // Chronometer auto beg = std::chrono::high_resolution_clock::now(); // // DEVICE REGION // // Evaluate Cs - linspace hipLaunchKernelGGL(( init_c), dim3(nc), dim3(1), 0, 0, d_c, inc, c0); // Evaluate halfoffset points in x and y coordinates hipLaunchKernelGGL(( init_half), dim3(ttraces), dim3(1), 0, 0, d_scalco, d_gx, d_gy, d_sx, d_sy, d_h); for(int cdp_id = 0; cdp_id < ncdps; cdp_id++) { int t_id0 = cdp_id > 0 ? ntraces_by_cdp_id[cdp_id-1] : 0; int t_idf = ntraces_by_cdp_id[cdp_id]; int stride = t_idf - t_id0; hipMemcpyAsync(d_cdpsmpl, h_samples + t_id0*ns , sizeof(real)*stride*ns , hipMemcpyHostToDevice); // Compute semblances for each c for each sample hipLaunchKernelGGL(( compute_semblances), dim3((ns*nc+NTHREADS-1)/NTHREADS), dim3(NTHREADS), 0, 0, d_h, d_c, d_cdpsmpl, d_num, d_stt, t_id0, t_idf, idt, dt, tau, w, nc, ns); // Get max C for max semblance for each sample on this cdp hipLaunchKernelGGL(( redux_semblances), dim3((ns+NTHREADS-1)/NTHREADS), dim3(NTHREADS), 0, 0, d_num, d_stt, d_ctr, d_str, d_stk, nc, cdp_id, ns); number_of_semblances += stride; LOG(DEBUG, "Progress: " + std::to_string(cdp_id) + "/" + std::to_string(ncdps)); } // Gets time at end of computation hipDeviceSynchronize(); auto end = std::chrono::high_resolution_clock::now(); // Copy results back to host hipMemcpy(h_ctr, d_ctr, sizeof(int ) * ncdps * ns, hipMemcpyDeviceToHost); hipMemcpy(h_str, d_str, sizeof(real) * ncdps * ns, hipMemcpyDeviceToHost); hipMemcpy(h_stk, d_stk, sizeof(real) * ncdps * ns, hipMemcpyDeviceToHost); // // END DEVICE REGION // // Verify real* h_c = (real*) malloc (sizeof(real)*nc ); real* h_h = (real*) malloc (sizeof(real)*ttraces ); real* h_num = (real*) malloc (sizeof(real)*ns*nc ); real* h_stt = (real*) malloc (sizeof(real)*ns*nc ); // reference results int* r_ctr = (int*) malloc (sizeof(int )*ncdps*ns); real* r_str = (real*) malloc (sizeof(real)*ncdps*ns); real* r_stk = (real*) malloc (sizeof(real)*ncdps*ns); h_init_c(nc, h_c, inc, c0); h_init_half(ttraces, h_scalco, h_gx, h_gy, h_sx, h_sy, h_h); for(int cdp_id = 0; cdp_id < ncdps; cdp_id++) { int t_id0 = cdp_id > 0 ? ntraces_by_cdp_id[cdp_id-1] : 0; int t_idf = ntraces_by_cdp_id[cdp_id]; // Compute semblances for each c for each sample h_compute_semblances( h_h, h_c, h_samples+t_id0*ns, h_num, h_stt, t_id0, t_idf, idt, dt, tau, w, nc, ns); // Get max C for max semblance for each sample on this cdp h_redux_semblances(h_num, h_stt, r_ctr, r_str, r_stk, nc, cdp_id, ns); LOG(DEBUG, "Progress: " + std::to_string(cdp_id) + "/" + std::to_string(ncdps)); } int error = 0; for (int i = 0; i < ncdps*ns; i++) { if (r_ctr[i] != h_ctr[i] || (r_str[i] - h_str[i] > 1e-3) || (r_stk[i] - h_stk[i] > 1e-3)) { error = 1; break; } } if (error) LOG(INFO, "Test: FAILED"); else LOG(INFO, "Test: PASS"); // Logs stats (exec time and semblance-traces per second) double total_exec_time = std::chrono::duration_cast<std::chrono::duration<double>>(end - beg).count(); double stps = (number_of_semblances / 1e9 ) * (ns * nc / total_exec_time); std::string stats = "Total Execution Time: " + std::to_string(total_exec_time); stats += ": Giga-Semblances-Trace/s: " + std::to_string(stps); LOG(INFO, stats); #ifdef SAVE // Delinearizes data and save it into a *.su file for(int i=0; i < ncdps; i++) { su_trace ctr_t = gather[i].traces()[0]; su_trace str_t = gather[i].traces()[0]; su_trace stk_t = gather[i].traces()[0]; ctr_t.offset() = 0; ctr_t.sx() = ctr_t.gx() = (gather[i].traces()[0].sx() + gather[i].traces()[0].gx()) >> 1; ctr_t.sy() = ctr_t.gy() = (gather[i].traces()[0].sy() + gather[i].traces()[0].gy()) >> 1; for(int k=0; k < ns; k++) ctr_t.data()[k] = h_ctr[i*ns+k] < 0 ? 0.0f: (c0 + inc * h_ctr[i*ns+k]) / FACTOR; str_t.data().assign(h_str + i*ns, h_str + (i+1)*ns); stk_t.data().assign(h_stk + i*ns, h_stk + (i+1)*ns); ctr_t.fputtr(c_out); str_t.fputtr(s_out); stk_t.fputtr(stack); } #endif hipFree(d_gx ); hipFree(d_gy ); hipFree(d_sx ); hipFree(d_sy ); hipFree(d_scalco ); hipFree(d_cdpsmpl); hipFree(d_h ); hipFree(d_c ); hipFree(d_num ); hipFree(d_stt ); hipFree(d_ctr ); hipFree(d_str ); hipFree(d_stk ); free(h_ctr ); free(h_str ); free(h_stk ); free(h_h ); free(h_c ); free(h_num ); free(h_stt ); free(r_ctr ); free(r_str ); free(r_stk ); delete [] h_gx ; delete [] h_gy ; delete [] h_sx ; delete [] h_sy ; delete [] h_scalco ; delete [] h_samples ; delete [] ntraces_by_cdp_id ; return EXIT_SUCCESS; }
346670d21237cd013e283bfb2b581e1f941277a5.cu
//////////////////////////////////////////////////////////////////////////////// /** * @file main.cpp * @date 2017-03-04 * @author Tiago Lobato Gimenes ([email protected]) * * @copyright * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ //////////////////////////////////////////////////////////////////////////////// #include <cstdlib> #include <vector> #include <iostream> #include <fstream> #include <sstream> #include <string> #include <chrono> #include <cuda.h> #include "log.hpp" #include "utils.hpp" #include "parser.hpp" #include "su_gather.hpp" //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// __global__ void init_c(real *c, real inc, real c0) { int i = blockIdx.x; c[i] = c0 + inc*i; } //////////////////////////////////////////////////////////////////////////////// __global__ void init_half(const real* __restrict scalco, const real* __restrict gx, const real* __restrict gy, const real* __restrict sx, const real* __restrict sy, real* __restrict h) { int i = blockIdx.x; real _s = scalco[i]; if(-EPSILON < _s && _s < EPSILON) _s = 1.0f; else if(_s < 0) _s = 1.0f / _s; real hx = (gx[i] - sx[i]) * _s; real hy = (gy[i] - sy[i]) * _s; h[i] = 0.25f * (hx * hx + hy * hy) / FACTOR; } //////////////////////////////////////////////////////////////////////////////// __global__ void compute_semblances(const real* __restrict h, const real* __restrict c, const real* __restrict samples, real* __restrict num, real* __restrict stt, int t_id0, int t_idf, real _idt, real _dt, int _tau, int _w, int nc, int ns) { real _den = 0.0f, _ac_linear = 0.0f, _ac_squared = 0.0f; real _num[MAX_W], m = 0.0f; int err = 0; int i = blockIdx.x * NTHREADS + threadIdx.x; int t0 = i / nc; int c_id = i % nc; if(i < ns * nc) { real _c = c[c_id]; real _t0 = _dt * t0; _t0 *= _t0; for(int j=0; j < _w; j++) _num[j] = 0.0f; for(int t_id=t_id0; t_id < t_idf; t_id++) { real t = sqrtf(_t0 + _c * h[t_id]) * _idt; int it = (int)( t ); int ittau = it - _tau; real x = t - (real)it; if(ittau >= 0 && it + _tau + 1 < ns) { int k1 = ittau + (t_id-t_id0)*ns; real sk1p1 = samples[k1], sk1; for(int j=0; j < _w; j++) { k1++; sk1 = sk1p1; sk1p1 = samples[k1]; // linear interpolation optmized for this problema real v = (sk1p1 - sk1) * x + sk1; _num[j] += v; _den += v * v; _ac_linear += v; } m += 1; } else { err++; } } // Reduction for num for(int j=0; j < _w; j++) _ac_squared += _num[j] * _num[j]; // Evaluate semblances if(_den > EPSILON && m > EPSILON && _w > EPSILON && err < 2) { num[i] = _ac_squared / (_den * m); stt[i] = _ac_linear / (_w * m); } else { num[i] = -1.0f; stt[i] = -1.0f; } } } //////////////////////////////////////////////////////////////////////////////// __global__ void redux_semblances(const real* __restrict num, const real* __restrict stt, int* __restrict ctr, real* __restrict str, real* __restrict stk, const int nc, const int cdp_id, const int ns) { int t0 = blockIdx.x * NTHREADS + threadIdx.x; if(t0 < ns) { real max_sem = 0.0f; int max_c = -1; for(int it=t0*nc; it < (t0+1)*nc ; it++) { real _num = num[it]; if(_num > max_sem) { max_sem = _num; max_c = it; } } ctr[cdp_id*ns + t0] = max_c % nc; str[cdp_id*ns + t0] = max_sem; stk[cdp_id*ns + t0] = max_c > -1 ? stt[max_c] : 0; } } //////////////////////////////////////////////////////////////////////////////// int main(int argc, const char** argv) { #ifdef SAVE std::ofstream c_out("cmp.c.su", std::ofstream::out | std::ios::binary); std::ofstream s_out("cmp.coher.su", std::ofstream::out | std::ios::binary); std::ofstream stack("cmp.stack.su", std::ofstream::out | std::ios::binary); #endif // Parse command line and read arguments parser::add_argument("-c0", "C0 constant"); parser::add_argument("-c1", "C1 constant"); parser::add_argument("-nc", "NC constant"); parser::add_argument("-aph", "APH constant"); parser::add_argument("-tau", "Tau constant"); parser::add_argument("-i", "Data path"); parser::add_argument("-v", "Verbosity Level 0-3"); parser::parse(argc, argv); // Read parameters and input const real c0 = std::stof(parser::get("-c0", true)) * FACTOR; const real c1 = std::stof(parser::get("-c1", true)) * FACTOR; const real itau = std::stof(parser::get("-tau", true)); const int nc = std::stoi(parser::get("-nc", true)); const int aph = std::stoi(parser::get("-aph", true)); std::string path = parser::get("-i", true); logger::verbosity_level(std::stoi(parser::get("-v", false))); // Reads *.su data and starts gather su_gather gather(path, aph, nc); real *h_gx, *h_gy, *h_sx, *h_sy, *h_scalco, *h_samples, *h_str, *h_stk, dt; int *ntraces_by_cdp_id, *h_ctr; // Linearize gather data in order to improve data coalescence in GPU gather.linearize(ntraces_by_cdp_id, h_samples, dt, h_gx, h_gy, h_sx, h_sy, h_scalco, nc); const int ttraces = gather.ttraces(); // Total traces -> Total amount of traces read const int ncdps = gather().size(); // Number of cdps -> Total number of cdps read const int ns = gather.ns(); // Number of samples const int ntrs = gather.ntrs(); // Max number of traces by cdp const real inc = (c1-c0) * (1.0f / (real)nc); dt = dt / 1000000.0f; real idt = 1.0f / dt; int tau = ((int)( itau * idt) > 0) ? ((int)( itau * idt)) : 0; int w = (2 * tau) + 1; int number_of_semblances = 0; LOG(DEBUG, "Starting CMP execution"); // Alloc memory real *d_h, *d_gx, *d_gy, *d_sx, *d_sy, *d_scalco, *d_cdpsmpl; real *d_c, *d_num, *d_stt, *d_str, *d_stk; // nc stts per sample int *d_ctr; // ns Cs per cdp cudaMalloc((void**)&d_gx, sizeof(real)*ttraces); cudaMalloc((void**)&d_gy, sizeof(real)*ttraces); cudaMalloc((void**)&d_sx, sizeof(real)*ttraces); cudaMalloc((void**)&d_sy, sizeof(real)*ttraces); cudaMalloc((void**)&d_scalco, sizeof(real)*ttraces); cudaMalloc((void**)&d_cdpsmpl, sizeof(real)*ntrs*ns); cudaMemcpy(d_gx , h_gx , sizeof(real)*ttraces, cudaMemcpyHostToDevice); cudaMemcpy(d_gy , h_gy , sizeof(real)*ttraces, cudaMemcpyHostToDevice); cudaMemcpy(d_sx , h_sx , sizeof(real)*ttraces, cudaMemcpyHostToDevice); cudaMemcpy(d_sy , h_sy , sizeof(real)*ttraces, cudaMemcpyHostToDevice); cudaMemcpy(d_scalco, h_scalco, sizeof(real)*ttraces, cudaMemcpyHostToDevice); cudaMalloc((void** ) &d_c , sizeof(real)*nc ); cudaMemset(d_c , 0, sizeof(real)*nc ); cudaMalloc((void** ) &d_h , sizeof(real)*ttraces ); cudaMemset(d_h , 0, sizeof(real)*ttraces ); cudaMalloc((void** ) &d_num, sizeof(real)*ns*nc ); cudaMemset(d_num, 0, sizeof(real)*ns*nc ); cudaMalloc((void** ) &d_stt, sizeof(real)*ns*nc ); cudaMemset(d_stt, 0, sizeof(real)*ns*nc ); cudaMalloc((void** ) &d_ctr, sizeof(int )*ncdps*ns); cudaMemset(d_ctr, 0, sizeof(int )*ncdps*ns); cudaMalloc((void** ) &d_str, sizeof(real)*ncdps*ns); cudaMemset(d_str, 0, sizeof(real)*ncdps*ns); cudaMalloc((void** ) &d_stk, sizeof(real)*ncdps*ns); cudaMemset(d_stk, 0,sizeof(real)*ncdps*ns); h_ctr = (int*) malloc (sizeof(int )*ncdps*ns); h_str = (real*) malloc (sizeof(real)*ncdps*ns); h_stk = (real*) malloc (sizeof(real)*ncdps*ns); // Chronometer auto beg = std::chrono::high_resolution_clock::now(); // // DEVICE REGION // // Evaluate Cs - linspace init_c<<<nc, 1>>>(d_c, inc, c0); // Evaluate halfoffset points in x and y coordinates init_half<<<ttraces, 1>>>(d_scalco, d_gx, d_gy, d_sx, d_sy, d_h); for(int cdp_id = 0; cdp_id < ncdps; cdp_id++) { int t_id0 = cdp_id > 0 ? ntraces_by_cdp_id[cdp_id-1] : 0; int t_idf = ntraces_by_cdp_id[cdp_id]; int stride = t_idf - t_id0; cudaMemcpyAsync(d_cdpsmpl, h_samples + t_id0*ns , sizeof(real)*stride*ns , cudaMemcpyHostToDevice); // Compute semblances for each c for each sample compute_semblances<<<(ns*nc+NTHREADS-1)/NTHREADS, NTHREADS>>>( d_h, d_c, d_cdpsmpl, d_num, d_stt, t_id0, t_idf, idt, dt, tau, w, nc, ns); // Get max C for max semblance for each sample on this cdp redux_semblances<<<(ns+NTHREADS-1)/NTHREADS, NTHREADS>>>( d_num, d_stt, d_ctr, d_str, d_stk, nc, cdp_id, ns); number_of_semblances += stride; LOG(DEBUG, "Progress: " + std::to_string(cdp_id) + "/" + std::to_string(ncdps)); } // Gets time at end of computation cudaDeviceSynchronize(); auto end = std::chrono::high_resolution_clock::now(); // Copy results back to host cudaMemcpy(h_ctr, d_ctr, sizeof(int ) * ncdps * ns, cudaMemcpyDeviceToHost); cudaMemcpy(h_str, d_str, sizeof(real) * ncdps * ns, cudaMemcpyDeviceToHost); cudaMemcpy(h_stk, d_stk, sizeof(real) * ncdps * ns, cudaMemcpyDeviceToHost); // // END DEVICE REGION // // Verify real* h_c = (real*) malloc (sizeof(real)*nc ); real* h_h = (real*) malloc (sizeof(real)*ttraces ); real* h_num = (real*) malloc (sizeof(real)*ns*nc ); real* h_stt = (real*) malloc (sizeof(real)*ns*nc ); // reference results int* r_ctr = (int*) malloc (sizeof(int )*ncdps*ns); real* r_str = (real*) malloc (sizeof(real)*ncdps*ns); real* r_stk = (real*) malloc (sizeof(real)*ncdps*ns); h_init_c(nc, h_c, inc, c0); h_init_half(ttraces, h_scalco, h_gx, h_gy, h_sx, h_sy, h_h); for(int cdp_id = 0; cdp_id < ncdps; cdp_id++) { int t_id0 = cdp_id > 0 ? ntraces_by_cdp_id[cdp_id-1] : 0; int t_idf = ntraces_by_cdp_id[cdp_id]; // Compute semblances for each c for each sample h_compute_semblances( h_h, h_c, h_samples+t_id0*ns, h_num, h_stt, t_id0, t_idf, idt, dt, tau, w, nc, ns); // Get max C for max semblance for each sample on this cdp h_redux_semblances(h_num, h_stt, r_ctr, r_str, r_stk, nc, cdp_id, ns); LOG(DEBUG, "Progress: " + std::to_string(cdp_id) + "/" + std::to_string(ncdps)); } int error = 0; for (int i = 0; i < ncdps*ns; i++) { if (r_ctr[i] != h_ctr[i] || (r_str[i] - h_str[i] > 1e-3) || (r_stk[i] - h_stk[i] > 1e-3)) { error = 1; break; } } if (error) LOG(INFO, "Test: FAILED"); else LOG(INFO, "Test: PASS"); // Logs stats (exec time and semblance-traces per second) double total_exec_time = std::chrono::duration_cast<std::chrono::duration<double>>(end - beg).count(); double stps = (number_of_semblances / 1e9 ) * (ns * nc / total_exec_time); std::string stats = "Total Execution Time: " + std::to_string(total_exec_time); stats += ": Giga-Semblances-Trace/s: " + std::to_string(stps); LOG(INFO, stats); #ifdef SAVE // Delinearizes data and save it into a *.su file for(int i=0; i < ncdps; i++) { su_trace ctr_t = gather[i].traces()[0]; su_trace str_t = gather[i].traces()[0]; su_trace stk_t = gather[i].traces()[0]; ctr_t.offset() = 0; ctr_t.sx() = ctr_t.gx() = (gather[i].traces()[0].sx() + gather[i].traces()[0].gx()) >> 1; ctr_t.sy() = ctr_t.gy() = (gather[i].traces()[0].sy() + gather[i].traces()[0].gy()) >> 1; for(int k=0; k < ns; k++) ctr_t.data()[k] = h_ctr[i*ns+k] < 0 ? 0.0f: (c0 + inc * h_ctr[i*ns+k]) / FACTOR; str_t.data().assign(h_str + i*ns, h_str + (i+1)*ns); stk_t.data().assign(h_stk + i*ns, h_stk + (i+1)*ns); ctr_t.fputtr(c_out); str_t.fputtr(s_out); stk_t.fputtr(stack); } #endif cudaFree(d_gx ); cudaFree(d_gy ); cudaFree(d_sx ); cudaFree(d_sy ); cudaFree(d_scalco ); cudaFree(d_cdpsmpl); cudaFree(d_h ); cudaFree(d_c ); cudaFree(d_num ); cudaFree(d_stt ); cudaFree(d_ctr ); cudaFree(d_str ); cudaFree(d_stk ); free(h_ctr ); free(h_str ); free(h_stk ); free(h_h ); free(h_c ); free(h_num ); free(h_stt ); free(r_ctr ); free(r_str ); free(r_stk ); delete [] h_gx ; delete [] h_gy ; delete [] h_sx ; delete [] h_sy ; delete [] h_scalco ; delete [] h_samples ; delete [] ntraces_by_cdp_id ; return EXIT_SUCCESS; }
c17fb37da85e3aec6181aaac568e41ae097e5d4b.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. #include <ATen/ATen.h> #include <ATen/hip/HIPContext.h> #include <THH/THH.h> #include <THH/THHDeviceUtils.cuh> #include <vector> //#include <iostream> #include <algorithm> #include <math.h> #include <stdio.h> //using namespace std; #define maxn 100 #define nmax 512 const double eps=1E-8; int const threadsPerBlock = 64; //sizeof(unsigned long long) * 8; __device__ inline int sig(double d){ return(d>eps)-(d<-eps); } struct Point{ double x,y; __device__ Point(){} __device__ Point(double x,double y):x(x),y(y){} }; __device__ inline bool point_same(Point& a, Point& b){ return sig(a.x - b.x) == 0 && sig(a.y - b.y) == 0; } __device__ inline void swap1(Point* a, Point* b){ Point temp; temp.x = a->x; temp.y = a->y; a->x = b->x; a->y = b->y; b->x = temp.x; b->y = temp.y; } __device__ inline void reverse1(Point* a, const int n){ Point temp[maxn]; for(int i = 0; i < n; i++){ temp[i].x = a[i].x; temp[i].y = a[i].y; } for(int i = 0; i < n; i++){ a[i].x = temp[n - 1 - i].x; a[i].y = temp[n - 1 - i].y; } } __device__ inline double cross(Point o,Point a,Point b){ return(a.x-o.x)*(b.y-o.y)-(b.x-o.x)*(a.y-o.y); } __device__ inline double dis(Point a,Point b){ return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y); } __device__ inline double area(Point* ps,int n){ ps[n]=ps[0]; double res=0; for(int i=0;i<n;i++){ res+=ps[i].x*ps[i+1].y-ps[i].y*ps[i+1].x; } return res/2.0; } __device__ inline double polygen_area_grad(Point* ps,int n, int* polygen_to_pred_index, int n_pred, double* grad_C){ ps[n] = ps[0]; double partion_grad[4 * 30 + 2]; double res = 0; for(int i = 0; i < n; i++){ res += ps[i].x * ps[i+1].y - ps[i].y * ps[i+1].x; partion_grad[i * 4 + 2] = ps[i + 1].y; partion_grad[i * 4 + 3] = -ps[i + 1].x; if(i != n - 1) { partion_grad[i * 4 + 4] = -ps[i].y; partion_grad[i * 4 + 5] = ps[i].x; } else { partion_grad[0] = -ps[i].y; partion_grad[1] = ps[i].x; } } for(int i = 0; i < 2 * n; i++) { if(!(i % 2)) { for(int j = 0; j < n_pred; j++) { if(i / 2 == polygen_to_pred_index[j]) { grad_C[2 * polygen_to_pred_index[j + n_pred]] = (partion_grad[i / 2 * 4] + partion_grad[i / 2 * 4 + 2]) / 2; break; } } } else { for(int j = 0; j < n_pred; j++) { if(i / 2 == polygen_to_pred_index[j]) { grad_C[2 * polygen_to_pred_index[j + n_pred] + 1] = (partion_grad[i / 2 * 4 + 1] + partion_grad[i / 2 * 4 + 1 + 2]) / 2; break; } } } } return res/2.0; } __device__ inline int lineCross(Point a,Point b,Point c,Point d,Point&p, double* cut_grad, int m, int n, int i){ double s1,s2; double s2_s1_2; double ds1_dxc, ds1_dyc, ds2_dxd, ds2_dyd; double dxp_dxc, dxp_dyc, dxp_dxd, dxp_dyd, dyp_dxc, dyp_dyc, dyp_dxd, dyp_dyd; s1=cross(a,b,c); s2=cross(a,b,d); ds1_dxc = - (b.y - a.y); ds1_dyc = b.x - a.x; ds2_dxd = ds1_dxc; ds2_dyd = ds1_dyc; s2_s1_2 = (s2 - s1) * (s2 - s1); if(sig(s1)==0&&sig(s2)==0) return 2; if(sig(s2-s1)==0) return 0; dxp_dxc = ( (s2 - d.x * ds1_dxc) * (s2 - s1) - (c.x * s2 - d.x * s1) * (- ds1_dxc) ) / (s2_s1_2); dxp_dyc = ( (0 - d.x * ds1_dyc) * (s2 - s1) - (c.x * s2 - d.x * s1) * (- ds1_dyc) ) / (s2_s1_2); dxp_dxd = ( (c.x * ds2_dxd - s1) * (s2 - s1) - (c.x * s2 - d.x * s1) * (ds2_dxd) ) / (s2_s1_2); dxp_dyd = ( (c.x * ds2_dyd - 0) * (s2 - s1) - (c.x * s2 - d.x * s1) * (ds2_dyd) ) / (s2_s1_2); dyp_dxc = ( (0 - d.y * ds1_dxc) * (s2 - s1) - (c.y * s2 - d.y * s1) * (- ds1_dxc) ) / (s2_s1_2); dyp_dyc = ( (s2 - d.y * ds1_dyc) * (s2 - s1) - (c.y * s2 - d.y * s1) * (- ds1_dyc) ) / (s2_s1_2); dyp_dxd = ( (c.y * ds2_dxd - 0) * (s2 - s1) - (c.y * s2 - d.y * s1) * (ds2_dxd) ) / (s2_s1_2); dyp_dyd = ( (c.y * ds2_dyd - s1) * (s2 - s1) - (c.y * s2 - d.y * s1) * (ds2_dyd) ) / (s2_s1_2); p.x=(c.x*s2-d.x*s1)/(s2-s1); p.y=(c.y*s2-d.y*s1)/(s2-s1); if(i == n - 1) { cut_grad[4 * n * m + 4 * i] = dxp_dxc;// + dyp_dxc; cut_grad[4 * n * m + 4 * i + 1] = dyp_dxc; cut_grad[4 * n * m + 4 * i + 2] = dxp_dyc;// + dyp_dyc; cut_grad[4 * n * m + 4 * i + 3] = dyp_dyc; cut_grad[4 * n * m + 0] = dxp_dxd;// + dyp_dxd; cut_grad[4 * n * m + 1] = dyp_dxd; cut_grad[4 * n * m + 2] = dxp_dyd;// + dyp_dyd; cut_grad[4 * n * m + 3] = dyp_dyd; } else { cut_grad[4 * n * m + 4 * i] = dxp_dxc;// + dyp_dxc; cut_grad[4 * n * m + 4 * i + 1] = dyp_dxc; cut_grad[4 * n * m + 4 * i + 2] = dxp_dyc;// + dyp_dyc; cut_grad[4 * n * m + 4 * i + 3] = dyp_dyc; cut_grad[4 * n * m + 4 * (i + 1)] = dxp_dxd;// + dyp_dxd; cut_grad[4 * n * m + 4 * (i + 1) + 1] = dyp_dxd; cut_grad[4 * n * m + 4 * (i + 1) + 2] = dxp_dyd;// + dyp_dyd; cut_grad[4 * n * m + 4 * (i + 1) + 3] = dyp_dyd; } return 1; } __device__ inline void polygon_cut(Point*p,int&n,Point a,Point b, double* cut_grad){ Point pp[maxn]; double ccur_grad[maxn] = {}; int m=0;p[n]=p[0]; int k = n; for(int i=0;i<n;i++){ if(sig(cross(a,b,p[i]))>0) { pp[m]=p[i]; ccur_grad[4 * n * m + 4 * i] = 1.0; ccur_grad[4 * n * m + 4 * i + 3] = 1.0; m++; } if(sig(cross(a,b,p[i]))!=sig(cross(a,b,p[i+1]))) { lineCross(a,b,p[i],p[i+1],pp[m], ccur_grad, m, n, i); m++; } } n=0; for(int i=0;i<m;i++) { if(!i || !(point_same(pp[i], pp[i-1]))) { p[n]=pp[i]; for(int j = 0; j < 4 * k; j++) { cut_grad[4 * k * n + j] = ccur_grad[4 * k * i + j]; } n++; } } while(n > 1 && point_same(p[n-1], p[0]))n--; } __device__ inline double intersectArea(Point a,Point b,Point c,Point d, double* grad_AB, int order, int convex_n){ Point o(0,0); int res_flag = 0; int s1=sig(cross(o,a,b)); int s2=sig(cross(o,c,d)); if(s1==0||s2==0)return 0.0; if(s1==-1){ Point* i = &a; Point* j = &b; swap1(i, j); res_flag = 1; } if(s2==-1){ Point* i = &c; Point* j = &d; swap1(i, j); } Point p[10]={o,a,b}; int n=3, n0 = 3, n1, n2, n3; double cut_grad1[maxn] = {}; double cut_grad2[maxn] = {}; double cut_grad3[maxn] = {}; double p1_p_grad[10][10] = {}; double p2_p1_grad[10][10] = {}; double p3_p2_grad[10][10] = {}; double p3_p1_grad[10][10] = {}; double p3_p_grad[10][10] = {}; //***********************11111111111111111************************************ polygon_cut(p,n,o,c,cut_grad1); n1 = n; for(int i = 0; i < n; i++) { for(int j = 0; j < 4 * n0; j++) { if(!(j % 2)) { p1_p_grad[2 * i][j / 2] = cut_grad1[4 * n0 * i + j]; } else { p1_p_grad[2 * i + 1][j / 2] = cut_grad1[4 * n0 * i + j]; } } } //*************************222222222222222********************************** polygon_cut(p,n,c,d,cut_grad2); n2 = n; for(int i = 0; i < n; i++) { for(int j = 0; j < 4 * n1; j++) { if(!(j % 2)) { p2_p1_grad[2 * i][j / 2] = cut_grad2[4 * n1 * i + j]; } else { p2_p1_grad[2 * i + 1][j / 2] = cut_grad2[4 * n1 * i + j]; } } } //**********************3333333333333333333************************************* polygon_cut(p,n,d,o,cut_grad3); n3 = n; for(int i = 0; i < n; i++) { for(int j = 0; j < 4 * n2; j++) { if(!(j % 2)) { p3_p2_grad[2 * i][j / 2] = cut_grad3[4 * n2 * i + j]; } else { p3_p2_grad[2 * i + 1][j / 2] = cut_grad3[4 * n2 * i + j]; } } } //**************************mul************************************* //p3_p2(n3 * n2) * p2_p1(n2 * n1) = p3_p1 (n3 * n1) for (int i = 0; i < 2 * n3; i++) { for (int j = 0; j < 2 * n1; j++) { double sum = 0.0; for (int m = 0; m < 2 * n2; m++) { sum = sum + p3_p2_grad[i][m] * p2_p1_grad[m][j]; } p3_p1_grad[i][j] = sum; } } //p3_p1 (n3 * n1) * p1_p (n1 * n0) = p3_p (n3 * n0) for (int i = 0; i < 2 * n3; i++) { for (int j = 0; j < 2 * n0; j++) { double sum = 0.0; for (int m = 0; m < 2 * n1; m++) { sum = sum + p3_p1_grad[i][m] * p1_p_grad[m][j]; } p3_p_grad[i][j] = sum; } } //calculate S_grad int polygen_index_box_index[20]; double grad_polygen[20]; double S_grad[6]; for(int i = 0; i < n3; i++) { polygen_index_box_index[i] = i; polygen_index_box_index[i + n3] = i; } double res=polygen_area_grad(p, n3, polygen_index_box_index, n3, grad_polygen); if(s1*s2==-1) { for(int j = 0; j < 2 * 3; j++) { double sum = 0.0; for (int m = 0; m < 2 * n3; m++) { sum = sum - grad_polygen[m] * p3_p_grad[m][j]; } S_grad[j] = sum; } if(order != convex_n - 1) { if(res_flag) { grad_AB[2 * order] += S_grad[4]; grad_AB[2 * order + 1] += S_grad[5]; grad_AB[2 * order + 2] += S_grad[2]; grad_AB[2 * order + 3] += S_grad[3]; } else { grad_AB[2 * order] += S_grad[2]; grad_AB[2 * order + 1] += S_grad[3]; grad_AB[2 * order + 2] += S_grad[4]; grad_AB[2 * order + 3] += S_grad[5]; } } else { if(res_flag) { grad_AB[2 * order] += S_grad[4]; grad_AB[2 * order + 1] += S_grad[5]; grad_AB[0] += S_grad[2]; grad_AB[1] += S_grad[3]; } else { grad_AB[2 * order] += S_grad[2]; grad_AB[2 * order + 1] += S_grad[3]; grad_AB[0] += S_grad[4]; grad_AB[1] += S_grad[5]; } } res=-res; } else { for(int j = 0; j < 2 * 3; j++) { double sum = 0.0; for (int m = 0; m < 2 * n3; m++) { sum = sum + grad_polygen[m] * p3_p_grad[m][j]; } S_grad[j] = sum; } if(order != convex_n - 1) { if(res_flag) { grad_AB[2 * order] += S_grad[4]; grad_AB[2 * order + 1] += S_grad[5]; grad_AB[2 * order + 2] += S_grad[2]; grad_AB[2 * order + 3] += S_grad[3]; } else { grad_AB[2 * order] += S_grad[2]; grad_AB[2 * order + 1] += S_grad[3]; grad_AB[2 * order + 2] += S_grad[4]; grad_AB[2 * order + 3] += S_grad[5]; } } else { if(res_flag) { grad_AB[2 * order] += S_grad[4]; grad_AB[2 * order + 1] += S_grad[5]; grad_AB[0] += S_grad[2]; grad_AB[1] += S_grad[3]; } else { grad_AB[2 * order] += S_grad[2]; grad_AB[2 * order + 1] += S_grad[3]; grad_AB[0] += S_grad[4]; grad_AB[1] += S_grad[5]; } } } return res; } __device__ inline double intersectAreaO(Point*ps1,int n1,Point*ps2,int n2, double* grad_AB){ if(area(ps1,n1)<0) reverse1(ps1,n1); if(area(ps2,n2)<0) reverse1(ps2,n2); ps1[n1]=ps1[0]; ps2[n2]=ps2[0]; double res=0; for(int i=0;i<n1;i++){ for(int j=0;j<n2;j++){ res+=intersectArea(ps1[i],ps1[i+1],ps2[j],ps2[j+1], grad_AB, i, n1); } } return res; } __device__ inline void Jarvis(Point *in_poly, int &n_poly) { Point p_max, p_k; int max_index, k_index; int Stack[nmax] = {}, top1, top2; double sign; Point right_point[10], left_point[10]; for(int i = 0; i < n_poly; i++) { if(in_poly[i].y < in_poly[0].y || in_poly[i].y == in_poly[0].y && in_poly[i].x < in_poly[0].x) { Point *j = &(in_poly[0]); Point *k = &(in_poly[i]); swap1(j, k); } if(i == 0) { p_max = in_poly[0]; max_index = 0; } if(in_poly[i].y > p_max.y || in_poly[i].y == p_max.y && in_poly[i].x > p_max.x) { p_max = in_poly[i]; max_index = i; } } if(max_index == 0){ max_index = 1; p_max = in_poly[max_index]; } k_index = 0, Stack[0] = 0, top1 = 0; while(k_index != max_index) { p_k = p_max; k_index = max_index; for(int i = 1; i < n_poly; i++) { sign = cross(in_poly[Stack[top1]], in_poly[i], p_k); if( (sign > 0) || ((sign == 0) && (dis(in_poly[Stack[top1]], in_poly[i]) > dis(in_poly[Stack[top1]], p_k)))) { p_k = in_poly[i]; k_index = i; } } top1++; Stack[top1] = k_index; } for(int i = 0; i <= top1; i++) right_point[i] = in_poly[Stack[i]]; k_index = 0, Stack[0] = 0, top2 = 0; while(k_index != max_index) { p_k = p_max; k_index = max_index; for(int i = 1; i < n_poly; i++) { sign = cross(in_poly[Stack[top2]], in_poly[i], p_k); if( (sign < 0) || (sign == 0) && (dis(in_poly[Stack[top2]], in_poly[i]) > dis(in_poly[Stack[top2]], p_k))) { p_k = in_poly[i]; k_index = i; } } top2++; Stack[top2] = k_index; } for(int i = top2 - 1; i >= 0; i--) left_point[i] = in_poly[Stack[i]]; for(int i = 0; i < top1 + top2; i++){ if(i <= top1) { in_poly[i] = right_point[i]; } else { in_poly[i] = left_point[top2 -(i - top1)]; } } n_poly = top1 + top2; } __device__ inline double intersectAreaPoly(Point*ps1,int n1,Point*ps2,int n2, double* grad_C){ Point polygen[maxn]; int n = n1 + n2, n_poly = 0; for(int i = 0; i < n1; i++) { for(int j = 0; j < n - n1; j++) { if(point_same(ps1[i], ps2[j])) { for(int k = j; k < n - n1 - 1; k++) { ps2[k] = ps2[k + 1]; } n2--; break; } } } n_poly = n1 + n2; for(int i = 0; i < n_poly; i++) { if(i < n1) { polygen[i] = ps1[i]; } else { polygen[i] = ps2[i - n1]; } } Jarvis(polygen, n_poly); int polygen_to_pred_index[18] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; int n_pred = 0; for(int i = 0; i < n_poly; i++) { for(int j = 0; j < n1; j++) { if(polygen[i].x == ps1[j].x && polygen[i].y == ps1[j].y) { polygen_to_pred_index[n_pred] = i; polygen_to_pred_index[n_pred + n1] = j; n_pred += 1; break; } } } if(n_pred == 0) { double polygen_area = fabs(area(polygen, n_poly)); for(int i = 0; i< 18; i++) { grad_C[i] = 0.0; } return polygen_area; } else { double polygen_area = polygen_area_grad(polygen, n_poly, polygen_to_pred_index, n1, grad_C); if(polygen_area < 0) { for(int i = 0; i < 18; i++) { grad_C[i] = -grad_C[i]; } } return fabs(polygen_area); } } // convex_find and get the polygen_index_box_index __device__ inline void Jarvis_and_index(Point *in_poly, int &n_poly, int *points_to_convex_ind) { int n_input = n_poly; Point input_poly[20]; for(int i = 0; i < n_input; i++) { input_poly[i].x = in_poly[i].x; input_poly[i].y = in_poly[i].y; } Point p_max, p_k; int max_index, k_index; int Stack[20], top1, top2; double sign; Point right_point[10], left_point[10]; for(int i = 0; i < n_poly; i++) { if(in_poly[i].y < in_poly[0].y || in_poly[i].y == in_poly[0].y && in_poly[i].x < in_poly[0].x) { Point *j = &(in_poly[0]); Point *k = &(in_poly[i]); swap1(j, k); } if(i == 0) { p_max = in_poly[0]; max_index = 0; } if(in_poly[i].y > p_max.y || in_poly[i].y == p_max.y && in_poly[i].x > p_max.x) { p_max = in_poly[i]; max_index = i; } } if(max_index == 0){ max_index = 1; p_max = in_poly[max_index]; } k_index = 0, Stack[0] = 0, top1 = 0; while(k_index != max_index) { p_k = p_max; k_index = max_index; for(int i = 1; i < n_poly; i++) { sign = cross(in_poly[Stack[top1]], in_poly[i], p_k); if( (sign > 0) || ((sign == 0) && (dis(in_poly[Stack[top1]], in_poly[i]) > dis(in_poly[Stack[top1]], p_k)))) { p_k = in_poly[i]; k_index = i; } } top1++; Stack[top1] = k_index; } for(int i = 0; i <= top1; i++) { right_point[i] = in_poly[Stack[i]]; } k_index = 0, Stack[0] = 0, top2 = 0; while(k_index != max_index) { p_k = p_max; k_index = max_index; for(int i = 1; i < n_poly; i++) { sign = cross(in_poly[Stack[top2]], in_poly[i], p_k); if( (sign < 0) || (sign == 0) && (dis(in_poly[Stack[top2]], in_poly[i]) > dis(in_poly[Stack[top2]], p_k))) { p_k = in_poly[i]; k_index = i; } } top2++; Stack[top2] = k_index; } for(int i = top2 - 1; i >= 0; i--) { left_point[i] = in_poly[Stack[i]]; } for(int i = 0; i < top1 + top2; i++){ if(i <= top1) { in_poly[i] = right_point[i]; } else { in_poly[i] = left_point[top2 -(i - top1)]; } } n_poly = top1 + top2; for(int i = 0; i < n_poly; i++) { for(int j = 0; j < n_input; j++) { if(point_same(in_poly[i], input_poly[j])) { points_to_convex_ind[i] = j; break; } } } } __device__ inline float devrIoU(float const * const p, float const * const q, float* point_grad, const int idx) { Point ps1[maxn],ps2[maxn]; Point convex[maxn]; for(int i = 0; i < 9; i++) { convex[i].x = (double)p[i * 2]; convex[i].y = (double)p[i * 2 + 1]; } int n_convex = 9; int points_to_convex_ind[9] = {-1, -1, -1, -1, -1, -1, -1, -1, -1}; Jarvis_and_index(convex, n_convex, points_to_convex_ind); int n1 = n_convex; int n2 = 4; for(int i = 0; i < n1; i++) { ps1[i].x = (double)convex[i].x; ps1[i].y = (double)convex[i].y; } for (int i = 0; i < n2; i++) { ps2[i].x = (double)q[i * 2]; ps2[i].y = (double)q[i * 2 + 1]; } int polygen_index_box_index[18]; for(int i = 0; i < n1; i++) { polygen_index_box_index[i] = i; polygen_index_box_index[i + n1] = i; } double grad_A[18] = {}; double grad_AB[18] = {}; double grad_C[18] = {}; double inter_area = intersectAreaO(ps1, n1, ps2, n2, grad_AB); double S_pred = polygen_area_grad(ps1, n1, polygen_index_box_index, n1, grad_A); if(S_pred < 0) { for(int i = 0; i < n_convex * 2; i++) { grad_A[i] = -grad_A[i]; } } double union_area = fabs(S_pred) + fabs(area(ps2, n2)) - inter_area; double iou = inter_area / union_area; double polygen_area = intersectAreaPoly(ps1, n1, ps2, n2, grad_C); // printf("%d:live\n", idx); double rot_giou = iou - (polygen_area - union_area) / polygen_area; float grad_point_temp[18] = {}; for(int i = 0; i < n_convex; i++) { int grad_point = points_to_convex_ind[i]; grad_point_temp[2 * grad_point] = (float)((union_area + inter_area) / (union_area * union_area) * grad_AB[2 * i] - iou / union_area * grad_A[2 * i] \ - 1 / polygen_area * (grad_AB[2 * i] - grad_A[2 * i]) - (union_area) / polygen_area / polygen_area * grad_C[2 * i]); grad_point_temp[2 * grad_point + 1] = (float)((union_area + inter_area) / (union_area * union_area) * grad_AB[2 * i + 1] - iou / union_area * grad_A[2 * i + 1] \ - 1 / polygen_area * (grad_AB[2 * i + 1] - grad_A[2 * i + 1]) - (union_area) / polygen_area / polygen_area * grad_C[2 * i + 1]); } for(int i = 0; i < 9; i++) { point_grad[2 * i] = grad_point_temp[2 * i]; point_grad[2 * i + 1] = grad_point_temp[2 * i + 1]; } return (float)rot_giou; } __global__ void convex_giou_kernel(const int ex_n_boxes, const int gt_n_boxes, const float *ex_boxes, const float *gt_boxes, //double* iou, double* point_grad, double* iou_grad) { float* point_grad){ const int ex_start = blockIdx.x; const int ex_size = min(ex_n_boxes - ex_start * threadsPerBlock, threadsPerBlock); if (threadIdx.x < ex_size) { const int cur_box_idx = threadsPerBlock * ex_start + threadIdx.x; //printf("%d, alive!\n", cur_box_idx); const float *cur_box = ex_boxes + cur_box_idx * 18; const float *cur_gt_box = gt_boxes + cur_box_idx * 8; float* cur_grad = point_grad + cur_box_idx * 19; float giou = devrIoU(cur_box, cur_gt_box, cur_grad, threadIdx.x); cur_grad[18] = giou; } } // should be N x 8 tensor at::Tensor convex_giou_cuda(const at::Tensor ex_boxes, const at::Tensor gt_boxes) { using scalar_t = float; AT_ASSERTM(ex_boxes.type().is_cuda(), "ex_boxes must be a CUDA tensor"); AT_ASSERTM(gt_boxes.type().is_cuda(), "gt_boxes must be a CUDA tensor"); AT_ASSERTM(gt_boxes.size(0) == ex_boxes.size(0), "ex_boxes must equre to gt_boxesr"); int ex_boxes_num = ex_boxes.size(0); int gt_boxes_num = gt_boxes.size(0); const int ex_blocks = THCCeilDiv(ex_boxes_num, threadsPerBlock); scalar_t* ex_boxes_dev = ex_boxes.data<scalar_t>(); scalar_t* gt_boxes_dev = gt_boxes.data<scalar_t>();// const int size = 19 * (ex_boxes_num) * sizeof(float); float *point_grad_host, *point_grad_dev; point_grad_host = (float*)malloc(size); hipMalloc((void**)&point_grad_dev, size); dim3 blocks(ex_blocks); dim3 threads(threadsPerBlock); hipLaunchKernelGGL(( convex_giou_kernel), dim3(blocks), dim3(threads), 0, 0, ex_boxes_num, gt_boxes_num, ex_boxes_dev, gt_boxes_dev, point_grad_dev); THCudaCheck(hipMemcpy(point_grad_host, point_grad_dev, size, hipMemcpyDeviceToHost)); at::Tensor overlaps = at::empty({ex_boxes_num * 19}, ex_boxes.options().dtype(at::kFloat).device(at::kCPU)); float* overlaps_out = overlaps.data<float>(); for(int i = 0; i < (ex_boxes_num * 19); i++) { overlaps_out[i] = point_grad_host[i]; } hipFree(point_grad_dev); // TODO improve this part return overlaps.to(ex_boxes.device());//, point_grad.to(ex_boxes.device()); }
c17fb37da85e3aec6181aaac568e41ae097e5d4b.cu
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. #include <ATen/ATen.h> #include <ATen/cuda/CUDAContext.h> #include <THC/THC.h> #include <THC/THCDeviceUtils.cuh> #include <vector> //#include <iostream> #include <algorithm> #include <math.h> #include <stdio.h> //using namespace std; #define maxn 100 #define nmax 512 const double eps=1E-8; int const threadsPerBlock = 64; //sizeof(unsigned long long) * 8; __device__ inline int sig(double d){ return(d>eps)-(d<-eps); } struct Point{ double x,y; __device__ Point(){} __device__ Point(double x,double y):x(x),y(y){} }; __device__ inline bool point_same(Point& a, Point& b){ return sig(a.x - b.x) == 0 && sig(a.y - b.y) == 0; } __device__ inline void swap1(Point* a, Point* b){ Point temp; temp.x = a->x; temp.y = a->y; a->x = b->x; a->y = b->y; b->x = temp.x; b->y = temp.y; } __device__ inline void reverse1(Point* a, const int n){ Point temp[maxn]; for(int i = 0; i < n; i++){ temp[i].x = a[i].x; temp[i].y = a[i].y; } for(int i = 0; i < n; i++){ a[i].x = temp[n - 1 - i].x; a[i].y = temp[n - 1 - i].y; } } __device__ inline double cross(Point o,Point a,Point b){ return(a.x-o.x)*(b.y-o.y)-(b.x-o.x)*(a.y-o.y); } __device__ inline double dis(Point a,Point b){ return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y); } __device__ inline double area(Point* ps,int n){ ps[n]=ps[0]; double res=0; for(int i=0;i<n;i++){ res+=ps[i].x*ps[i+1].y-ps[i].y*ps[i+1].x; } return res/2.0; } __device__ inline double polygen_area_grad(Point* ps,int n, int* polygen_to_pred_index, int n_pred, double* grad_C){ ps[n] = ps[0]; double partion_grad[4 * 30 + 2]; double res = 0; for(int i = 0; i < n; i++){ res += ps[i].x * ps[i+1].y - ps[i].y * ps[i+1].x; partion_grad[i * 4 + 2] = ps[i + 1].y; partion_grad[i * 4 + 3] = -ps[i + 1].x; if(i != n - 1) { partion_grad[i * 4 + 4] = -ps[i].y; partion_grad[i * 4 + 5] = ps[i].x; } else { partion_grad[0] = -ps[i].y; partion_grad[1] = ps[i].x; } } for(int i = 0; i < 2 * n; i++) { if(!(i % 2)) { for(int j = 0; j < n_pred; j++) { if(i / 2 == polygen_to_pred_index[j]) { grad_C[2 * polygen_to_pred_index[j + n_pred]] = (partion_grad[i / 2 * 4] + partion_grad[i / 2 * 4 + 2]) / 2; break; } } } else { for(int j = 0; j < n_pred; j++) { if(i / 2 == polygen_to_pred_index[j]) { grad_C[2 * polygen_to_pred_index[j + n_pred] + 1] = (partion_grad[i / 2 * 4 + 1] + partion_grad[i / 2 * 4 + 1 + 2]) / 2; break; } } } } return res/2.0; } __device__ inline int lineCross(Point a,Point b,Point c,Point d,Point&p, double* cut_grad, int m, int n, int i){ double s1,s2; double s2_s1_2; double ds1_dxc, ds1_dyc, ds2_dxd, ds2_dyd; double dxp_dxc, dxp_dyc, dxp_dxd, dxp_dyd, dyp_dxc, dyp_dyc, dyp_dxd, dyp_dyd; s1=cross(a,b,c); s2=cross(a,b,d); ds1_dxc = - (b.y - a.y); ds1_dyc = b.x - a.x; ds2_dxd = ds1_dxc; ds2_dyd = ds1_dyc; s2_s1_2 = (s2 - s1) * (s2 - s1); if(sig(s1)==0&&sig(s2)==0) return 2; if(sig(s2-s1)==0) return 0; dxp_dxc = ( (s2 - d.x * ds1_dxc) * (s2 - s1) - (c.x * s2 - d.x * s1) * (- ds1_dxc) ) / (s2_s1_2); dxp_dyc = ( (0 - d.x * ds1_dyc) * (s2 - s1) - (c.x * s2 - d.x * s1) * (- ds1_dyc) ) / (s2_s1_2); dxp_dxd = ( (c.x * ds2_dxd - s1) * (s2 - s1) - (c.x * s2 - d.x * s1) * (ds2_dxd) ) / (s2_s1_2); dxp_dyd = ( (c.x * ds2_dyd - 0) * (s2 - s1) - (c.x * s2 - d.x * s1) * (ds2_dyd) ) / (s2_s1_2); dyp_dxc = ( (0 - d.y * ds1_dxc) * (s2 - s1) - (c.y * s2 - d.y * s1) * (- ds1_dxc) ) / (s2_s1_2); dyp_dyc = ( (s2 - d.y * ds1_dyc) * (s2 - s1) - (c.y * s2 - d.y * s1) * (- ds1_dyc) ) / (s2_s1_2); dyp_dxd = ( (c.y * ds2_dxd - 0) * (s2 - s1) - (c.y * s2 - d.y * s1) * (ds2_dxd) ) / (s2_s1_2); dyp_dyd = ( (c.y * ds2_dyd - s1) * (s2 - s1) - (c.y * s2 - d.y * s1) * (ds2_dyd) ) / (s2_s1_2); p.x=(c.x*s2-d.x*s1)/(s2-s1); p.y=(c.y*s2-d.y*s1)/(s2-s1); if(i == n - 1) { cut_grad[4 * n * m + 4 * i] = dxp_dxc;// + dyp_dxc; cut_grad[4 * n * m + 4 * i + 1] = dyp_dxc; cut_grad[4 * n * m + 4 * i + 2] = dxp_dyc;// + dyp_dyc; cut_grad[4 * n * m + 4 * i + 3] = dyp_dyc; cut_grad[4 * n * m + 0] = dxp_dxd;// + dyp_dxd; cut_grad[4 * n * m + 1] = dyp_dxd; cut_grad[4 * n * m + 2] = dxp_dyd;// + dyp_dyd; cut_grad[4 * n * m + 3] = dyp_dyd; } else { cut_grad[4 * n * m + 4 * i] = dxp_dxc;// + dyp_dxc; cut_grad[4 * n * m + 4 * i + 1] = dyp_dxc; cut_grad[4 * n * m + 4 * i + 2] = dxp_dyc;// + dyp_dyc; cut_grad[4 * n * m + 4 * i + 3] = dyp_dyc; cut_grad[4 * n * m + 4 * (i + 1)] = dxp_dxd;// + dyp_dxd; cut_grad[4 * n * m + 4 * (i + 1) + 1] = dyp_dxd; cut_grad[4 * n * m + 4 * (i + 1) + 2] = dxp_dyd;// + dyp_dyd; cut_grad[4 * n * m + 4 * (i + 1) + 3] = dyp_dyd; } return 1; } __device__ inline void polygon_cut(Point*p,int&n,Point a,Point b, double* cut_grad){ Point pp[maxn]; double ccur_grad[maxn] = {}; int m=0;p[n]=p[0]; int k = n; for(int i=0;i<n;i++){ if(sig(cross(a,b,p[i]))>0) { pp[m]=p[i]; ccur_grad[4 * n * m + 4 * i] = 1.0; ccur_grad[4 * n * m + 4 * i + 3] = 1.0; m++; } if(sig(cross(a,b,p[i]))!=sig(cross(a,b,p[i+1]))) { lineCross(a,b,p[i],p[i+1],pp[m], ccur_grad, m, n, i); m++; } } n=0; for(int i=0;i<m;i++) { if(!i || !(point_same(pp[i], pp[i-1]))) { p[n]=pp[i]; for(int j = 0; j < 4 * k; j++) { cut_grad[4 * k * n + j] = ccur_grad[4 * k * i + j]; } n++; } } while(n > 1 && point_same(p[n-1], p[0]))n--; } __device__ inline double intersectArea(Point a,Point b,Point c,Point d, double* grad_AB, int order, int convex_n){ Point o(0,0); int res_flag = 0; int s1=sig(cross(o,a,b)); int s2=sig(cross(o,c,d)); if(s1==0||s2==0)return 0.0; if(s1==-1){ Point* i = &a; Point* j = &b; swap1(i, j); res_flag = 1; } if(s2==-1){ Point* i = &c; Point* j = &d; swap1(i, j); } Point p[10]={o,a,b}; int n=3, n0 = 3, n1, n2, n3; double cut_grad1[maxn] = {}; double cut_grad2[maxn] = {}; double cut_grad3[maxn] = {}; double p1_p_grad[10][10] = {}; double p2_p1_grad[10][10] = {}; double p3_p2_grad[10][10] = {}; double p3_p1_grad[10][10] = {}; double p3_p_grad[10][10] = {}; //***********************11111111111111111************************************ polygon_cut(p,n,o,c,cut_grad1); n1 = n; for(int i = 0; i < n; i++) { for(int j = 0; j < 4 * n0; j++) { if(!(j % 2)) { p1_p_grad[2 * i][j / 2] = cut_grad1[4 * n0 * i + j]; } else { p1_p_grad[2 * i + 1][j / 2] = cut_grad1[4 * n0 * i + j]; } } } //*************************222222222222222********************************** polygon_cut(p,n,c,d,cut_grad2); n2 = n; for(int i = 0; i < n; i++) { for(int j = 0; j < 4 * n1; j++) { if(!(j % 2)) { p2_p1_grad[2 * i][j / 2] = cut_grad2[4 * n1 * i + j]; } else { p2_p1_grad[2 * i + 1][j / 2] = cut_grad2[4 * n1 * i + j]; } } } //**********************3333333333333333333************************************* polygon_cut(p,n,d,o,cut_grad3); n3 = n; for(int i = 0; i < n; i++) { for(int j = 0; j < 4 * n2; j++) { if(!(j % 2)) { p3_p2_grad[2 * i][j / 2] = cut_grad3[4 * n2 * i + j]; } else { p3_p2_grad[2 * i + 1][j / 2] = cut_grad3[4 * n2 * i + j]; } } } //**************************mul************************************* //p3_p2(n3 * n2) * p2_p1(n2 * n1) = p3_p1 (n3 * n1) for (int i = 0; i < 2 * n3; i++) { for (int j = 0; j < 2 * n1; j++) { double sum = 0.0; for (int m = 0; m < 2 * n2; m++) { sum = sum + p3_p2_grad[i][m] * p2_p1_grad[m][j]; } p3_p1_grad[i][j] = sum; } } //p3_p1 (n3 * n1) * p1_p (n1 * n0) = p3_p (n3 * n0) for (int i = 0; i < 2 * n3; i++) { for (int j = 0; j < 2 * n0; j++) { double sum = 0.0; for (int m = 0; m < 2 * n1; m++) { sum = sum + p3_p1_grad[i][m] * p1_p_grad[m][j]; } p3_p_grad[i][j] = sum; } } //calculate S_grad int polygen_index_box_index[20]; double grad_polygen[20]; double S_grad[6]; for(int i = 0; i < n3; i++) { polygen_index_box_index[i] = i; polygen_index_box_index[i + n3] = i; } double res=polygen_area_grad(p, n3, polygen_index_box_index, n3, grad_polygen); if(s1*s2==-1) { for(int j = 0; j < 2 * 3; j++) { double sum = 0.0; for (int m = 0; m < 2 * n3; m++) { sum = sum - grad_polygen[m] * p3_p_grad[m][j]; } S_grad[j] = sum; } if(order != convex_n - 1) { if(res_flag) { grad_AB[2 * order] += S_grad[4]; grad_AB[2 * order + 1] += S_grad[5]; grad_AB[2 * order + 2] += S_grad[2]; grad_AB[2 * order + 3] += S_grad[3]; } else { grad_AB[2 * order] += S_grad[2]; grad_AB[2 * order + 1] += S_grad[3]; grad_AB[2 * order + 2] += S_grad[4]; grad_AB[2 * order + 3] += S_grad[5]; } } else { if(res_flag) { grad_AB[2 * order] += S_grad[4]; grad_AB[2 * order + 1] += S_grad[5]; grad_AB[0] += S_grad[2]; grad_AB[1] += S_grad[3]; } else { grad_AB[2 * order] += S_grad[2]; grad_AB[2 * order + 1] += S_grad[3]; grad_AB[0] += S_grad[4]; grad_AB[1] += S_grad[5]; } } res=-res; } else { for(int j = 0; j < 2 * 3; j++) { double sum = 0.0; for (int m = 0; m < 2 * n3; m++) { sum = sum + grad_polygen[m] * p3_p_grad[m][j]; } S_grad[j] = sum; } if(order != convex_n - 1) { if(res_flag) { grad_AB[2 * order] += S_grad[4]; grad_AB[2 * order + 1] += S_grad[5]; grad_AB[2 * order + 2] += S_grad[2]; grad_AB[2 * order + 3] += S_grad[3]; } else { grad_AB[2 * order] += S_grad[2]; grad_AB[2 * order + 1] += S_grad[3]; grad_AB[2 * order + 2] += S_grad[4]; grad_AB[2 * order + 3] += S_grad[5]; } } else { if(res_flag) { grad_AB[2 * order] += S_grad[4]; grad_AB[2 * order + 1] += S_grad[5]; grad_AB[0] += S_grad[2]; grad_AB[1] += S_grad[3]; } else { grad_AB[2 * order] += S_grad[2]; grad_AB[2 * order + 1] += S_grad[3]; grad_AB[0] += S_grad[4]; grad_AB[1] += S_grad[5]; } } } return res; } __device__ inline double intersectAreaO(Point*ps1,int n1,Point*ps2,int n2, double* grad_AB){ if(area(ps1,n1)<0) reverse1(ps1,n1); if(area(ps2,n2)<0) reverse1(ps2,n2); ps1[n1]=ps1[0]; ps2[n2]=ps2[0]; double res=0; for(int i=0;i<n1;i++){ for(int j=0;j<n2;j++){ res+=intersectArea(ps1[i],ps1[i+1],ps2[j],ps2[j+1], grad_AB, i, n1); } } return res; } __device__ inline void Jarvis(Point *in_poly, int &n_poly) { Point p_max, p_k; int max_index, k_index; int Stack[nmax] = {}, top1, top2; double sign; Point right_point[10], left_point[10]; for(int i = 0; i < n_poly; i++) { if(in_poly[i].y < in_poly[0].y || in_poly[i].y == in_poly[0].y && in_poly[i].x < in_poly[0].x) { Point *j = &(in_poly[0]); Point *k = &(in_poly[i]); swap1(j, k); } if(i == 0) { p_max = in_poly[0]; max_index = 0; } if(in_poly[i].y > p_max.y || in_poly[i].y == p_max.y && in_poly[i].x > p_max.x) { p_max = in_poly[i]; max_index = i; } } if(max_index == 0){ max_index = 1; p_max = in_poly[max_index]; } k_index = 0, Stack[0] = 0, top1 = 0; while(k_index != max_index) { p_k = p_max; k_index = max_index; for(int i = 1; i < n_poly; i++) { sign = cross(in_poly[Stack[top1]], in_poly[i], p_k); if( (sign > 0) || ((sign == 0) && (dis(in_poly[Stack[top1]], in_poly[i]) > dis(in_poly[Stack[top1]], p_k)))) { p_k = in_poly[i]; k_index = i; } } top1++; Stack[top1] = k_index; } for(int i = 0; i <= top1; i++) right_point[i] = in_poly[Stack[i]]; k_index = 0, Stack[0] = 0, top2 = 0; while(k_index != max_index) { p_k = p_max; k_index = max_index; for(int i = 1; i < n_poly; i++) { sign = cross(in_poly[Stack[top2]], in_poly[i], p_k); if( (sign < 0) || (sign == 0) && (dis(in_poly[Stack[top2]], in_poly[i]) > dis(in_poly[Stack[top2]], p_k))) { p_k = in_poly[i]; k_index = i; } } top2++; Stack[top2] = k_index; } for(int i = top2 - 1; i >= 0; i--) left_point[i] = in_poly[Stack[i]]; for(int i = 0; i < top1 + top2; i++){ if(i <= top1) { in_poly[i] = right_point[i]; } else { in_poly[i] = left_point[top2 -(i - top1)]; } } n_poly = top1 + top2; } __device__ inline double intersectAreaPoly(Point*ps1,int n1,Point*ps2,int n2, double* grad_C){ Point polygen[maxn]; int n = n1 + n2, n_poly = 0; for(int i = 0; i < n1; i++) { for(int j = 0; j < n - n1; j++) { if(point_same(ps1[i], ps2[j])) { for(int k = j; k < n - n1 - 1; k++) { ps2[k] = ps2[k + 1]; } n2--; break; } } } n_poly = n1 + n2; for(int i = 0; i < n_poly; i++) { if(i < n1) { polygen[i] = ps1[i]; } else { polygen[i] = ps2[i - n1]; } } Jarvis(polygen, n_poly); int polygen_to_pred_index[18] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; int n_pred = 0; for(int i = 0; i < n_poly; i++) { for(int j = 0; j < n1; j++) { if(polygen[i].x == ps1[j].x && polygen[i].y == ps1[j].y) { polygen_to_pred_index[n_pred] = i; polygen_to_pred_index[n_pred + n1] = j; n_pred += 1; break; } } } if(n_pred == 0) { double polygen_area = fabs(area(polygen, n_poly)); for(int i = 0; i< 18; i++) { grad_C[i] = 0.0; } return polygen_area; } else { double polygen_area = polygen_area_grad(polygen, n_poly, polygen_to_pred_index, n1, grad_C); if(polygen_area < 0) { for(int i = 0; i < 18; i++) { grad_C[i] = -grad_C[i]; } } return fabs(polygen_area); } } // convex_find and get the polygen_index_box_index __device__ inline void Jarvis_and_index(Point *in_poly, int &n_poly, int *points_to_convex_ind) { int n_input = n_poly; Point input_poly[20]; for(int i = 0; i < n_input; i++) { input_poly[i].x = in_poly[i].x; input_poly[i].y = in_poly[i].y; } Point p_max, p_k; int max_index, k_index; int Stack[20], top1, top2; double sign; Point right_point[10], left_point[10]; for(int i = 0; i < n_poly; i++) { if(in_poly[i].y < in_poly[0].y || in_poly[i].y == in_poly[0].y && in_poly[i].x < in_poly[0].x) { Point *j = &(in_poly[0]); Point *k = &(in_poly[i]); swap1(j, k); } if(i == 0) { p_max = in_poly[0]; max_index = 0; } if(in_poly[i].y > p_max.y || in_poly[i].y == p_max.y && in_poly[i].x > p_max.x) { p_max = in_poly[i]; max_index = i; } } if(max_index == 0){ max_index = 1; p_max = in_poly[max_index]; } k_index = 0, Stack[0] = 0, top1 = 0; while(k_index != max_index) { p_k = p_max; k_index = max_index; for(int i = 1; i < n_poly; i++) { sign = cross(in_poly[Stack[top1]], in_poly[i], p_k); if( (sign > 0) || ((sign == 0) && (dis(in_poly[Stack[top1]], in_poly[i]) > dis(in_poly[Stack[top1]], p_k)))) { p_k = in_poly[i]; k_index = i; } } top1++; Stack[top1] = k_index; } for(int i = 0; i <= top1; i++) { right_point[i] = in_poly[Stack[i]]; } k_index = 0, Stack[0] = 0, top2 = 0; while(k_index != max_index) { p_k = p_max; k_index = max_index; for(int i = 1; i < n_poly; i++) { sign = cross(in_poly[Stack[top2]], in_poly[i], p_k); if( (sign < 0) || (sign == 0) && (dis(in_poly[Stack[top2]], in_poly[i]) > dis(in_poly[Stack[top2]], p_k))) { p_k = in_poly[i]; k_index = i; } } top2++; Stack[top2] = k_index; } for(int i = top2 - 1; i >= 0; i--) { left_point[i] = in_poly[Stack[i]]; } for(int i = 0; i < top1 + top2; i++){ if(i <= top1) { in_poly[i] = right_point[i]; } else { in_poly[i] = left_point[top2 -(i - top1)]; } } n_poly = top1 + top2; for(int i = 0; i < n_poly; i++) { for(int j = 0; j < n_input; j++) { if(point_same(in_poly[i], input_poly[j])) { points_to_convex_ind[i] = j; break; } } } } __device__ inline float devrIoU(float const * const p, float const * const q, float* point_grad, const int idx) { Point ps1[maxn],ps2[maxn]; Point convex[maxn]; for(int i = 0; i < 9; i++) { convex[i].x = (double)p[i * 2]; convex[i].y = (double)p[i * 2 + 1]; } int n_convex = 9; int points_to_convex_ind[9] = {-1, -1, -1, -1, -1, -1, -1, -1, -1}; Jarvis_and_index(convex, n_convex, points_to_convex_ind); int n1 = n_convex; int n2 = 4; for(int i = 0; i < n1; i++) { ps1[i].x = (double)convex[i].x; ps1[i].y = (double)convex[i].y; } for (int i = 0; i < n2; i++) { ps2[i].x = (double)q[i * 2]; ps2[i].y = (double)q[i * 2 + 1]; } int polygen_index_box_index[18]; for(int i = 0; i < n1; i++) { polygen_index_box_index[i] = i; polygen_index_box_index[i + n1] = i; } double grad_A[18] = {}; double grad_AB[18] = {}; double grad_C[18] = {}; double inter_area = intersectAreaO(ps1, n1, ps2, n2, grad_AB); double S_pred = polygen_area_grad(ps1, n1, polygen_index_box_index, n1, grad_A); if(S_pred < 0) { for(int i = 0; i < n_convex * 2; i++) { grad_A[i] = -grad_A[i]; } } double union_area = fabs(S_pred) + fabs(area(ps2, n2)) - inter_area; double iou = inter_area / union_area; double polygen_area = intersectAreaPoly(ps1, n1, ps2, n2, grad_C); // printf("%d:live\n", idx); double rot_giou = iou - (polygen_area - union_area) / polygen_area; float grad_point_temp[18] = {}; for(int i = 0; i < n_convex; i++) { int grad_point = points_to_convex_ind[i]; grad_point_temp[2 * grad_point] = (float)((union_area + inter_area) / (union_area * union_area) * grad_AB[2 * i] - iou / union_area * grad_A[2 * i] \ - 1 / polygen_area * (grad_AB[2 * i] - grad_A[2 * i]) - (union_area) / polygen_area / polygen_area * grad_C[2 * i]); grad_point_temp[2 * grad_point + 1] = (float)((union_area + inter_area) / (union_area * union_area) * grad_AB[2 * i + 1] - iou / union_area * grad_A[2 * i + 1] \ - 1 / polygen_area * (grad_AB[2 * i + 1] - grad_A[2 * i + 1]) - (union_area) / polygen_area / polygen_area * grad_C[2 * i + 1]); } for(int i = 0; i < 9; i++) { point_grad[2 * i] = grad_point_temp[2 * i]; point_grad[2 * i + 1] = grad_point_temp[2 * i + 1]; } return (float)rot_giou; } __global__ void convex_giou_kernel(const int ex_n_boxes, const int gt_n_boxes, const float *ex_boxes, const float *gt_boxes, //double* iou, double* point_grad, double* iou_grad) { float* point_grad){ const int ex_start = blockIdx.x; const int ex_size = min(ex_n_boxes - ex_start * threadsPerBlock, threadsPerBlock); if (threadIdx.x < ex_size) { const int cur_box_idx = threadsPerBlock * ex_start + threadIdx.x; //printf("%d, alive!\n", cur_box_idx); const float *cur_box = ex_boxes + cur_box_idx * 18; const float *cur_gt_box = gt_boxes + cur_box_idx * 8; float* cur_grad = point_grad + cur_box_idx * 19; float giou = devrIoU(cur_box, cur_gt_box, cur_grad, threadIdx.x); cur_grad[18] = giou; } } // should be N x 8 tensor at::Tensor convex_giou_cuda(const at::Tensor ex_boxes, const at::Tensor gt_boxes) { using scalar_t = float; AT_ASSERTM(ex_boxes.type().is_cuda(), "ex_boxes must be a CUDA tensor"); AT_ASSERTM(gt_boxes.type().is_cuda(), "gt_boxes must be a CUDA tensor"); AT_ASSERTM(gt_boxes.size(0) == ex_boxes.size(0), "ex_boxes must equre to gt_boxesr"); int ex_boxes_num = ex_boxes.size(0); int gt_boxes_num = gt_boxes.size(0); const int ex_blocks = THCCeilDiv(ex_boxes_num, threadsPerBlock); scalar_t* ex_boxes_dev = ex_boxes.data<scalar_t>(); scalar_t* gt_boxes_dev = gt_boxes.data<scalar_t>();// const int size = 19 * (ex_boxes_num) * sizeof(float); float *point_grad_host, *point_grad_dev; point_grad_host = (float*)malloc(size); cudaMalloc((void**)&point_grad_dev, size); dim3 blocks(ex_blocks); dim3 threads(threadsPerBlock); convex_giou_kernel<<<blocks, threads>>>(ex_boxes_num, gt_boxes_num, ex_boxes_dev, gt_boxes_dev, point_grad_dev); THCudaCheck(cudaMemcpy(point_grad_host, point_grad_dev, size, cudaMemcpyDeviceToHost)); at::Tensor overlaps = at::empty({ex_boxes_num * 19}, ex_boxes.options().dtype(at::kFloat).device(at::kCPU)); float* overlaps_out = overlaps.data<float>(); for(int i = 0; i < (ex_boxes_num * 19); i++) { overlaps_out[i] = point_grad_host[i]; } cudaFree(point_grad_dev); // TODO improve this part return overlaps.to(ex_boxes.device());//, point_grad.to(ex_boxes.device()); }
e3b50e72f6e8780af2843bf23d6c1a798b6bfc8d.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" // Copyright (c) 2018 John Biddiscombe // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include <pika/cuda.hpp> #include <pika/execution.hpp> #include <pika/functional/bind_front.hpp> #include <pika/init.hpp> #include <pika/testing.hpp> #include <whip.hpp> #include <algorithm> #include <cmath> #include <cstddef> #include <iostream> #include <sstream> #include <utility> #include <vector> namespace cu = pika::cuda::experimental; namespace ex = pika::execution::experimental; namespace tt = pika::this_thread::experimental; __global__ void saxpy(int n, float a, float* x, float* y) { int i = blockIdx.x * blockDim.x + threadIdx.x; if (i < n) y[i] = a * x[i] + y[i]; } template <typename Sender> auto launch_saxpy_kernel(pika::cuda::experimental::cuda_scheduler& cuda_sched, Sender&& predecessor, unsigned int& blocks, unsigned int& threads, void** args) { return ex::when_all(std::forward<Sender>(predecessor), ex::just(reinterpret_cast<const void*>(&saxpy), dim3(blocks), dim3(threads), args, std::size_t(0))) | ex::transfer(cuda_sched) | cu::then_with_stream(whip::launch_kernel); } template <typename T> __global__ void trivial_kernel(T val) { printf("hello from gpu with value %f\n", static_cast<double>(val)); } template <typename T> void cuda_trivial_kernel(T t, whip::stream_t stream) { hipLaunchKernelGGL(( trivial_kernel), dim3(1), dim3(1), 0, stream, t); } void test_saxpy(pika::cuda::experimental::cuda_scheduler& cuda_sched) { int N = 1 << 20; // host arrays (CUDA pinned host memory for asynchronous data transfers) float *h_A, *h_B; whip::malloc_host(&h_A, N * sizeof(float)); whip::malloc_host(&h_B, N * sizeof(float)); // device arrays float *d_A, *d_B; whip::malloc(&d_A, N * sizeof(float)); whip::malloc(&d_B, N * sizeof(float)); // init host data for (int idx = 0; idx < N; idx++) { h_A[idx] = 1.0f; h_B[idx] = 2.0f; } // copy both arrays from cpu to gpu, putting both copies onto the stream // no need to get a future back yet auto copy_A = ex::transfer_just(cuda_sched, d_A, h_A, N * sizeof(float), whip::memcpy_host_to_device) | cu::then_with_stream(whip::memcpy_async); auto copy_B = ex::transfer_just(cuda_sched, d_B, h_B, N * sizeof(float), whip::memcpy_host_to_device) | cu::then_with_stream(whip::memcpy_async); unsigned int threads = 256; unsigned int blocks = (N + 255) / threads; float ratio = 2.0f; // now launch a kernel on the stream void* args[] = {&N, &ratio, &d_A, &d_B}; auto s = launch_saxpy_kernel(cuda_sched, ex::when_all(std::move(copy_A), std::move(copy_B)), blocks, threads, args) | // finally, perform a copy from the gpu back to the cpu all on the same stream // grab a future to when this completes cu::then_with_stream(pika::util::detail::bind_front( whip::memcpy_async, h_B, d_B, N * sizeof(float), whip::memcpy_device_to_host)) | // we can add a continuation to the memcpy sender, so that when the // memory copy completes, we can do new things ... ex::transfer(ex::thread_pool_scheduler{}) | ex::then([&]() { std::cout << "saxpy completed on GPU, checking results in continuation" << std::endl; float max_error = 0.0f; for (int jdx = 0; jdx < N; jdx++) { max_error = (std::max)(max_error, abs(h_B[jdx] - 4.0f)); } std::cout << "Max Error: " << max_error << std::endl; // We must reach this point. Otherwise something has gone wrong. PIKA_TEST(true); }); // the sync_wait() is important because without it, this function returns // and the tasks are never spawned. tt::sync_wait(std::move(s)); } // ------------------------------------------------------------------------- int pika_main(pika::program_options::variables_map& vm) { std::size_t device = vm["device"].as<std::size_t>(); // unsigned int seed = (unsigned int) std::time(nullptr); #if !defined(PIKA_HAVE_HIP) // ROCm Clang-15 (HIP 5.3.3) fails to compile this with an internal compiler // error. See https://github.com/pika-org/pika/issues/585 for more details. if (vm.count("seed")) seed = vm["seed"].as<unsigned int>(); #else std::cout << "The --seed command line argument is ignored because HIP is "; std::cout << "enabled. See https://github.com/pika-org/pika/issues/585 "; std::cout << "for more details." << std::endl; #endif std::cout << "using seed: " << seed << std::endl; std::srand(seed); pika::cuda::experimental::cuda_pool cuda_pool(device); // install cuda future polling handler pika::cuda::experimental::enable_user_polling poll("default"); // pika::cuda::experimental::cuda_scheduler cuda_sched(std::move(cuda_pool)); // -------------------- // test kernel launch<float> using then_with_stream float testf = 1.2345; std::cout << "schedule : cuda kernel <float> : " << testf << std::endl; tt::sync_wait( ex::transfer_just(cuda_sched, testf) | cu::then_with_stream(&cuda_trivial_kernel<float>)); // -------------------- // test kernel launch<double> using apply and async double testd = 1.2345; std::cout << "schedule : cuda kernel <double> : " << testd << std::endl; tt::sync_wait( ex::transfer_just(cuda_sched, testd) | cu::then_with_stream(&cuda_trivial_kernel<double>)); // -------------------- // test adding a continuation to a cuda call double testd2 = 3.1415; std::cout << "then_with_stream/continuation : " << testd2 << std::endl; tt::sync_wait(ex::transfer_just(cuda_sched, testd2) | cu::then_with_stream(&cuda_trivial_kernel<double>) | cu::then_on_host([] { std::cout << "continuation triggered\n"; })); // -------------------- // test using a copy of a cuda executor // and adding a continuation with a copy of a copy std::cout << "Copying executor : " << testd2 + 1 << std::endl; auto cuda_sched_copy = cuda_sched; tt::sync_wait(ex::transfer_just(cuda_sched_copy, testd2 + 1) | cu::then_with_stream(&cuda_trivial_kernel<double>) | cu::then_on_host([] { std::cout << "copy continuation triggered\n"; })); // -------------------- // test a full kernel example test_saxpy(cuda_sched); return pika::finalize(); } // ------------------------------------------------------------------------- int main(int argc, char** argv) { printf("[pika Cuda future] - Starting...\n"); using namespace pika::program_options; options_description cmdline("usage: " PIKA_APPLICATION_STRING " [options]"); cmdline.add_options()("device", pika::program_options::value<std::size_t>()->default_value(0), "Device to use")("iterations", pika::program_options::value<std::size_t>()->default_value(30), "iterations")("seed,s", pika::program_options::value<unsigned int>(), "the random number generator seed to use for this run"); pika::init_params init_args; init_args.desc_cmdline = cmdline; return pika::init(pika_main, argc, argv, init_args); }
e3b50e72f6e8780af2843bf23d6c1a798b6bfc8d.cu
// Copyright (c) 2018 John Biddiscombe // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include <pika/cuda.hpp> #include <pika/execution.hpp> #include <pika/functional/bind_front.hpp> #include <pika/init.hpp> #include <pika/testing.hpp> #include <whip.hpp> #include <algorithm> #include <cmath> #include <cstddef> #include <iostream> #include <sstream> #include <utility> #include <vector> namespace cu = pika::cuda::experimental; namespace ex = pika::execution::experimental; namespace tt = pika::this_thread::experimental; __global__ void saxpy(int n, float a, float* x, float* y) { int i = blockIdx.x * blockDim.x + threadIdx.x; if (i < n) y[i] = a * x[i] + y[i]; } template <typename Sender> auto launch_saxpy_kernel(pika::cuda::experimental::cuda_scheduler& cuda_sched, Sender&& predecessor, unsigned int& blocks, unsigned int& threads, void** args) { return ex::when_all(std::forward<Sender>(predecessor), ex::just(reinterpret_cast<const void*>(&saxpy), dim3(blocks), dim3(threads), args, std::size_t(0))) | ex::transfer(cuda_sched) | cu::then_with_stream(whip::launch_kernel); } template <typename T> __global__ void trivial_kernel(T val) { printf("hello from gpu with value %f\n", static_cast<double>(val)); } template <typename T> void cuda_trivial_kernel(T t, whip::stream_t stream) { trivial_kernel<<<1, 1, 0, stream>>>(t); } void test_saxpy(pika::cuda::experimental::cuda_scheduler& cuda_sched) { int N = 1 << 20; // host arrays (CUDA pinned host memory for asynchronous data transfers) float *h_A, *h_B; whip::malloc_host(&h_A, N * sizeof(float)); whip::malloc_host(&h_B, N * sizeof(float)); // device arrays float *d_A, *d_B; whip::malloc(&d_A, N * sizeof(float)); whip::malloc(&d_B, N * sizeof(float)); // init host data for (int idx = 0; idx < N; idx++) { h_A[idx] = 1.0f; h_B[idx] = 2.0f; } // copy both arrays from cpu to gpu, putting both copies onto the stream // no need to get a future back yet auto copy_A = ex::transfer_just(cuda_sched, d_A, h_A, N * sizeof(float), whip::memcpy_host_to_device) | cu::then_with_stream(whip::memcpy_async); auto copy_B = ex::transfer_just(cuda_sched, d_B, h_B, N * sizeof(float), whip::memcpy_host_to_device) | cu::then_with_stream(whip::memcpy_async); unsigned int threads = 256; unsigned int blocks = (N + 255) / threads; float ratio = 2.0f; // now launch a kernel on the stream void* args[] = {&N, &ratio, &d_A, &d_B}; auto s = launch_saxpy_kernel(cuda_sched, ex::when_all(std::move(copy_A), std::move(copy_B)), blocks, threads, args) | // finally, perform a copy from the gpu back to the cpu all on the same stream // grab a future to when this completes cu::then_with_stream(pika::util::detail::bind_front( whip::memcpy_async, h_B, d_B, N * sizeof(float), whip::memcpy_device_to_host)) | // we can add a continuation to the memcpy sender, so that when the // memory copy completes, we can do new things ... ex::transfer(ex::thread_pool_scheduler{}) | ex::then([&]() { std::cout << "saxpy completed on GPU, checking results in continuation" << std::endl; float max_error = 0.0f; for (int jdx = 0; jdx < N; jdx++) { max_error = (std::max)(max_error, abs(h_B[jdx] - 4.0f)); } std::cout << "Max Error: " << max_error << std::endl; // We must reach this point. Otherwise something has gone wrong. PIKA_TEST(true); }); // the sync_wait() is important because without it, this function returns // and the tasks are never spawned. tt::sync_wait(std::move(s)); } // ------------------------------------------------------------------------- int pika_main(pika::program_options::variables_map& vm) { std::size_t device = vm["device"].as<std::size_t>(); // unsigned int seed = (unsigned int) std::time(nullptr); #if !defined(PIKA_HAVE_HIP) // ROCm Clang-15 (HIP 5.3.3) fails to compile this with an internal compiler // error. See https://github.com/pika-org/pika/issues/585 for more details. if (vm.count("seed")) seed = vm["seed"].as<unsigned int>(); #else std::cout << "The --seed command line argument is ignored because HIP is "; std::cout << "enabled. See https://github.com/pika-org/pika/issues/585 "; std::cout << "for more details." << std::endl; #endif std::cout << "using seed: " << seed << std::endl; std::srand(seed); pika::cuda::experimental::cuda_pool cuda_pool(device); // install cuda future polling handler pika::cuda::experimental::enable_user_polling poll("default"); // pika::cuda::experimental::cuda_scheduler cuda_sched(std::move(cuda_pool)); // -------------------- // test kernel launch<float> using then_with_stream float testf = 1.2345; std::cout << "schedule : cuda kernel <float> : " << testf << std::endl; tt::sync_wait( ex::transfer_just(cuda_sched, testf) | cu::then_with_stream(&cuda_trivial_kernel<float>)); // -------------------- // test kernel launch<double> using apply and async double testd = 1.2345; std::cout << "schedule : cuda kernel <double> : " << testd << std::endl; tt::sync_wait( ex::transfer_just(cuda_sched, testd) | cu::then_with_stream(&cuda_trivial_kernel<double>)); // -------------------- // test adding a continuation to a cuda call double testd2 = 3.1415; std::cout << "then_with_stream/continuation : " << testd2 << std::endl; tt::sync_wait(ex::transfer_just(cuda_sched, testd2) | cu::then_with_stream(&cuda_trivial_kernel<double>) | cu::then_on_host([] { std::cout << "continuation triggered\n"; })); // -------------------- // test using a copy of a cuda executor // and adding a continuation with a copy of a copy std::cout << "Copying executor : " << testd2 + 1 << std::endl; auto cuda_sched_copy = cuda_sched; tt::sync_wait(ex::transfer_just(cuda_sched_copy, testd2 + 1) | cu::then_with_stream(&cuda_trivial_kernel<double>) | cu::then_on_host([] { std::cout << "copy continuation triggered\n"; })); // -------------------- // test a full kernel example test_saxpy(cuda_sched); return pika::finalize(); } // ------------------------------------------------------------------------- int main(int argc, char** argv) { printf("[pika Cuda future] - Starting...\n"); using namespace pika::program_options; options_description cmdline("usage: " PIKA_APPLICATION_STRING " [options]"); cmdline.add_options()("device", pika::program_options::value<std::size_t>()->default_value(0), "Device to use")("iterations", pika::program_options::value<std::size_t>()->default_value(30), "iterations")("seed,s", pika::program_options::value<unsigned int>(), "the random number generator seed to use for this run"); pika::init_params init_args; init_args.desc_cmdline = cmdline; return pika::init(pika_main, argc, argv, init_args); }
ce46d261913ec3686366d64d0d1f7247dc17de73.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include <algorithm> #include <cfloat> #include <vector> #include "caffe/layers/softmax_loss_layer.hpp" #include "caffe/util/math_functions.hpp" // Added modification noted below: // // Taken from mohamed-ezz's implementation of class-weighting (spatial weight map feature excluded) // Ref: https://github.com/mohamed-ezz/caffe/commit/876e387a6d7f8974f68f42beacd3728b4fc92ff7 // namespace caffe { template <typename Dtype> __global__ void SoftmaxLossForwardGPU(const int nthreads, const Dtype* prob_data, const Dtype* label, Dtype* loss, const int num, const int dim, const int spatial_dim, const bool has_ignore_label_, const int ignore_label_, Dtype* counts) { CUDA_KERNEL_LOOP(index, nthreads) { const int n = index / spatial_dim; const int s = index % spatial_dim; const int label_value = static_cast<int>(label[n * spatial_dim + s]); if (has_ignore_label_ && label_value == ignore_label_) { loss[index] = 0; counts[index] = 0; } else { loss[index] = -log(max(prob_data[n * dim + label_value * spatial_dim + s], Dtype(FLT_MIN))); counts[index] = 1; } } } template <typename Dtype> __global__ void SoftmaxLossForwardGPUClassWeight(const int nthreads, const Dtype* prob_data, const Dtype* label, Dtype* loss, const int num, const int dim, const int spatial_dim, const bool has_ignore_label_, const int ignore_label_, const float* class_loss_weights_arr, const int class_loss_weights_arr_size, Dtype* counts) { CUDA_KERNEL_LOOP(index, nthreads) { const int n = index / spatial_dim; const int s = index % spatial_dim; const int label_value = static_cast<int>(label[n * spatial_dim + s]); if (has_ignore_label_ && label_value == ignore_label_) { loss[index] = 0; counts[index] = 0; } else { // code added by McM Dtype weight = 1; if( label_value < class_loss_weights_arr_size) { weight = class_loss_weights_arr[label_value]; } loss[index] = -weight * log(max(prob_data[n * dim + label_value * spatial_dim + s], Dtype(FLT_MIN))); counts[index] = weight; } } } template <typename Dtype> void SoftmaxWithLossLayer<Dtype>::Forward_gpu( const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) { softmax_layer_->Forward(softmax_bottom_vec_, softmax_top_vec_); const Dtype* prob_data = prob_.gpu_data(); const Dtype* label = bottom[1]->gpu_data(); const int dim = prob_.count() / outer_num_; const int nthreads = outer_num_ * inner_num_; // Since this memory is not used for anything until it is overwritten // on the backward pass, we use it here to avoid having to allocate new GPU // memory to accumulate intermediate results in the kernel. Dtype* loss_data = bottom[0]->mutable_gpu_diff(); // Similarly, this memory is never used elsewhere, and thus we can use it // to avoid having to allocate additional GPU memory. Dtype* counts = prob_.mutable_gpu_diff(); // NOLINT_NEXT_LINE(whitespace/operators) if(class_loss_weights_.size() > 0) { // label weights // first transform vector to array, as cuda does not support vectors float class_loss_weights_arr[class_loss_weights_.size()]; std::copy(class_loss_weights_.begin(), class_loss_weights_.end(), class_loss_weights_arr); // alloc cuda space float* device_class_loss_weights_arr; hipMalloc((void**)&device_class_loss_weights_arr, class_loss_weights_.size() * sizeof(float)); hipMemcpy( device_class_loss_weights_arr, class_loss_weights_arr, class_loss_weights_.size() * sizeof(float), hipMemcpyHostToDevice); // now upload to device hipLaunchKernelGGL(( SoftmaxLossForwardGPUClassWeight<Dtype>), dim3(CAFFE_GET_BLOCKS(nthreads)), dim3(CAFFE_CUDA_NUM_THREADS), 0, 0, nthreads, prob_data, label, loss_data, outer_num_, dim, inner_num_, has_ignore_label_, ignore_label_, device_class_loss_weights_arr, class_loss_weights_.size(), counts); // free hipFree(device_class_loss_weights_arr); } else { hipLaunchKernelGGL(( SoftmaxLossForwardGPU<Dtype>), dim3(CAFFE_GET_BLOCKS(nthreads)), dim3(CAFFE_CUDA_NUM_THREADS), 0, 0, nthreads, prob_data, label, loss_data, outer_num_, dim, inner_num_, has_ignore_label_, ignore_label_, counts); } Dtype loss; caffe_gpu_asum(nthreads, loss_data, &loss); Dtype valid_count = -1; // Only launch another CUDA kernel if we actually need the count of valid // outputs. if (normalization_ == LossParameter_NormalizationMode_VALID && has_ignore_label_) { caffe_gpu_asum(nthreads, counts, &valid_count); } top[0]->mutable_cpu_data()[0] = loss / get_normalizer(normalization_, valid_count); if (top.size() == 2) { top[1]->ShareData(prob_); } } template <typename Dtype> __global__ void SoftmaxLossBackwardGPU(const int nthreads, const Dtype* top, const Dtype* label, Dtype* bottom_diff, const int num, const int dim, const int spatial_dim, const bool has_ignore_label_, const int ignore_label_, Dtype* counts) { const int channels = dim / spatial_dim; CUDA_KERNEL_LOOP(index, nthreads) { const int n = index / spatial_dim; const int s = index % spatial_dim; const int label_value = static_cast<int>(label[n * spatial_dim + s]); if (has_ignore_label_ && label_value == ignore_label_) { for (int c = 0; c < channels; ++c) { bottom_diff[n * dim + c * spatial_dim + s] = 0; } counts[index] = 0; } else { bottom_diff[n * dim + label_value * spatial_dim + s] -= 1; counts[index] = 1; } } } template <typename Dtype> __global__ void SoftmaxLossBackwardGPUClassWeight(const int nthreads, const Dtype* top, const Dtype* label, Dtype* bottom_diff, const int num, const int dim, const int spatial_dim, const bool has_ignore_label_, const int ignore_label_, const float* class_loss_weights_arr, int class_loss_weights_arr_size, Dtype* counts) { const int channels = dim / spatial_dim; CUDA_KERNEL_LOOP(index, nthreads) { const int n = index / spatial_dim; const int s = index % spatial_dim; const int label_value = static_cast<int>(label[n * spatial_dim + s]); if (has_ignore_label_ && label_value == ignore_label_) { for (int c = 0; c < channels; ++c) { bottom_diff[n * dim + c * spatial_dim + s] = 0; } counts[index] = 0; } else { // code added by McM Dtype weight = 1; if( label_value < class_loss_weights_arr_size) { weight = class_loss_weights_arr[label_value]; } bottom_diff[n * dim + label_value * spatial_dim + s] -= 1; for (int c = 0; c < channels; ++c) { bottom_diff[n * dim + c * spatial_dim + s] *= weight; } counts[index] = weight; } } } template <typename Dtype> void SoftmaxWithLossLayer<Dtype>::Backward_gpu(const vector<Blob<Dtype>*>& top, const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom) { if (propagate_down[1]) { LOG(FATAL) << this->type() << " Layer cannot backpropagate to label inputs."; } if (propagate_down[0]) { Dtype* bottom_diff = bottom[0]->mutable_gpu_diff(); const Dtype* prob_data = prob_.gpu_data(); const Dtype* top_data = top[0]->gpu_data(); caffe_gpu_memcpy(prob_.count() * sizeof(Dtype), prob_data, bottom_diff); const Dtype* label = bottom[1]->gpu_data(); const int dim = prob_.count() / outer_num_; const int nthreads = outer_num_ * inner_num_; // Since this memory is never used for anything else, // we use to to avoid allocating new GPU memory. Dtype* counts = prob_.mutable_gpu_diff(); // NOLINT_NEXT_LINE(whitespace/operators) if(class_loss_weights_.size() > 0) { // label weights // first transform vector to array, as cuda does not support vectors float class_loss_weights_arr[class_loss_weights_.size()]; std::copy(class_loss_weights_.begin(), class_loss_weights_.end(), class_loss_weights_arr); // alloc cuda space float* device_class_loss_weights_arr; hipMalloc((void**)&device_class_loss_weights_arr, class_loss_weights_.size() * sizeof(float)); hipMemcpy( device_class_loss_weights_arr, class_loss_weights_arr, class_loss_weights_.size() * sizeof(float), hipMemcpyHostToDevice); // now upload to device hipLaunchKernelGGL(( SoftmaxLossBackwardGPUClassWeight<Dtype>), dim3(CAFFE_GET_BLOCKS(nthreads)), dim3(CAFFE_CUDA_NUM_THREADS), 0, 0, nthreads, top_data, label, bottom_diff, outer_num_, dim, inner_num_, has_ignore_label_, ignore_label_, device_class_loss_weights_arr, class_loss_weights_.size(), counts); // free hipFree(device_class_loss_weights_arr); } else { hipLaunchKernelGGL(( SoftmaxLossBackwardGPU<Dtype>), dim3(CAFFE_GET_BLOCKS(nthreads)), dim3(CAFFE_CUDA_NUM_THREADS), 0, 0, nthreads, top_data, label, bottom_diff, outer_num_, dim, inner_num_, has_ignore_label_, ignore_label_, counts); } Dtype valid_count = -1; // Only launch another CUDA kernel if we actually need the count of valid // outputs. if (normalization_ == LossParameter_NormalizationMode_VALID && has_ignore_label_) { caffe_gpu_asum(nthreads, counts, &valid_count); } const Dtype loss_weight = top[0]->cpu_diff()[0] / get_normalizer(normalization_, valid_count); caffe_gpu_scal(prob_.count(), loss_weight , bottom_diff); } } INSTANTIATE_LAYER_GPU_FUNCS(SoftmaxWithLossLayer); } // namespace caffe
ce46d261913ec3686366d64d0d1f7247dc17de73.cu
#include <algorithm> #include <cfloat> #include <vector> #include "caffe/layers/softmax_loss_layer.hpp" #include "caffe/util/math_functions.hpp" // Added modification noted below: // // Taken from mohamed-ezz's implementation of class-weighting (spatial weight map feature excluded) // Ref: https://github.com/mohamed-ezz/caffe/commit/876e387a6d7f8974f68f42beacd3728b4fc92ff7 // namespace caffe { template <typename Dtype> __global__ void SoftmaxLossForwardGPU(const int nthreads, const Dtype* prob_data, const Dtype* label, Dtype* loss, const int num, const int dim, const int spatial_dim, const bool has_ignore_label_, const int ignore_label_, Dtype* counts) { CUDA_KERNEL_LOOP(index, nthreads) { const int n = index / spatial_dim; const int s = index % spatial_dim; const int label_value = static_cast<int>(label[n * spatial_dim + s]); if (has_ignore_label_ && label_value == ignore_label_) { loss[index] = 0; counts[index] = 0; } else { loss[index] = -log(max(prob_data[n * dim + label_value * spatial_dim + s], Dtype(FLT_MIN))); counts[index] = 1; } } } template <typename Dtype> __global__ void SoftmaxLossForwardGPUClassWeight(const int nthreads, const Dtype* prob_data, const Dtype* label, Dtype* loss, const int num, const int dim, const int spatial_dim, const bool has_ignore_label_, const int ignore_label_, const float* class_loss_weights_arr, const int class_loss_weights_arr_size, Dtype* counts) { CUDA_KERNEL_LOOP(index, nthreads) { const int n = index / spatial_dim; const int s = index % spatial_dim; const int label_value = static_cast<int>(label[n * spatial_dim + s]); if (has_ignore_label_ && label_value == ignore_label_) { loss[index] = 0; counts[index] = 0; } else { // code added by McM Dtype weight = 1; if( label_value < class_loss_weights_arr_size) { weight = class_loss_weights_arr[label_value]; } loss[index] = -weight * log(max(prob_data[n * dim + label_value * spatial_dim + s], Dtype(FLT_MIN))); counts[index] = weight; } } } template <typename Dtype> void SoftmaxWithLossLayer<Dtype>::Forward_gpu( const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) { softmax_layer_->Forward(softmax_bottom_vec_, softmax_top_vec_); const Dtype* prob_data = prob_.gpu_data(); const Dtype* label = bottom[1]->gpu_data(); const int dim = prob_.count() / outer_num_; const int nthreads = outer_num_ * inner_num_; // Since this memory is not used for anything until it is overwritten // on the backward pass, we use it here to avoid having to allocate new GPU // memory to accumulate intermediate results in the kernel. Dtype* loss_data = bottom[0]->mutable_gpu_diff(); // Similarly, this memory is never used elsewhere, and thus we can use it // to avoid having to allocate additional GPU memory. Dtype* counts = prob_.mutable_gpu_diff(); // NOLINT_NEXT_LINE(whitespace/operators) if(class_loss_weights_.size() > 0) { // label weights // first transform vector to array, as cuda does not support vectors float class_loss_weights_arr[class_loss_weights_.size()]; std::copy(class_loss_weights_.begin(), class_loss_weights_.end(), class_loss_weights_arr); // alloc cuda space float* device_class_loss_weights_arr; cudaMalloc((void**)&device_class_loss_weights_arr, class_loss_weights_.size() * sizeof(float)); cudaMemcpy( device_class_loss_weights_arr, class_loss_weights_arr, class_loss_weights_.size() * sizeof(float), cudaMemcpyHostToDevice); // now upload to device SoftmaxLossForwardGPUClassWeight<Dtype><<<CAFFE_GET_BLOCKS(nthreads), CAFFE_CUDA_NUM_THREADS>>>(nthreads, prob_data, label, loss_data, outer_num_, dim, inner_num_, has_ignore_label_, ignore_label_, device_class_loss_weights_arr, class_loss_weights_.size(), counts); // free cudaFree(device_class_loss_weights_arr); } else { SoftmaxLossForwardGPU<Dtype><<<CAFFE_GET_BLOCKS(nthreads), CAFFE_CUDA_NUM_THREADS>>>(nthreads, prob_data, label, loss_data, outer_num_, dim, inner_num_, has_ignore_label_, ignore_label_, counts); } Dtype loss; caffe_gpu_asum(nthreads, loss_data, &loss); Dtype valid_count = -1; // Only launch another CUDA kernel if we actually need the count of valid // outputs. if (normalization_ == LossParameter_NormalizationMode_VALID && has_ignore_label_) { caffe_gpu_asum(nthreads, counts, &valid_count); } top[0]->mutable_cpu_data()[0] = loss / get_normalizer(normalization_, valid_count); if (top.size() == 2) { top[1]->ShareData(prob_); } } template <typename Dtype> __global__ void SoftmaxLossBackwardGPU(const int nthreads, const Dtype* top, const Dtype* label, Dtype* bottom_diff, const int num, const int dim, const int spatial_dim, const bool has_ignore_label_, const int ignore_label_, Dtype* counts) { const int channels = dim / spatial_dim; CUDA_KERNEL_LOOP(index, nthreads) { const int n = index / spatial_dim; const int s = index % spatial_dim; const int label_value = static_cast<int>(label[n * spatial_dim + s]); if (has_ignore_label_ && label_value == ignore_label_) { for (int c = 0; c < channels; ++c) { bottom_diff[n * dim + c * spatial_dim + s] = 0; } counts[index] = 0; } else { bottom_diff[n * dim + label_value * spatial_dim + s] -= 1; counts[index] = 1; } } } template <typename Dtype> __global__ void SoftmaxLossBackwardGPUClassWeight(const int nthreads, const Dtype* top, const Dtype* label, Dtype* bottom_diff, const int num, const int dim, const int spatial_dim, const bool has_ignore_label_, const int ignore_label_, const float* class_loss_weights_arr, int class_loss_weights_arr_size, Dtype* counts) { const int channels = dim / spatial_dim; CUDA_KERNEL_LOOP(index, nthreads) { const int n = index / spatial_dim; const int s = index % spatial_dim; const int label_value = static_cast<int>(label[n * spatial_dim + s]); if (has_ignore_label_ && label_value == ignore_label_) { for (int c = 0; c < channels; ++c) { bottom_diff[n * dim + c * spatial_dim + s] = 0; } counts[index] = 0; } else { // code added by McM Dtype weight = 1; if( label_value < class_loss_weights_arr_size) { weight = class_loss_weights_arr[label_value]; } bottom_diff[n * dim + label_value * spatial_dim + s] -= 1; for (int c = 0; c < channels; ++c) { bottom_diff[n * dim + c * spatial_dim + s] *= weight; } counts[index] = weight; } } } template <typename Dtype> void SoftmaxWithLossLayer<Dtype>::Backward_gpu(const vector<Blob<Dtype>*>& top, const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom) { if (propagate_down[1]) { LOG(FATAL) << this->type() << " Layer cannot backpropagate to label inputs."; } if (propagate_down[0]) { Dtype* bottom_diff = bottom[0]->mutable_gpu_diff(); const Dtype* prob_data = prob_.gpu_data(); const Dtype* top_data = top[0]->gpu_data(); caffe_gpu_memcpy(prob_.count() * sizeof(Dtype), prob_data, bottom_diff); const Dtype* label = bottom[1]->gpu_data(); const int dim = prob_.count() / outer_num_; const int nthreads = outer_num_ * inner_num_; // Since this memory is never used for anything else, // we use to to avoid allocating new GPU memory. Dtype* counts = prob_.mutable_gpu_diff(); // NOLINT_NEXT_LINE(whitespace/operators) if(class_loss_weights_.size() > 0) { // label weights // first transform vector to array, as cuda does not support vectors float class_loss_weights_arr[class_loss_weights_.size()]; std::copy(class_loss_weights_.begin(), class_loss_weights_.end(), class_loss_weights_arr); // alloc cuda space float* device_class_loss_weights_arr; cudaMalloc((void**)&device_class_loss_weights_arr, class_loss_weights_.size() * sizeof(float)); cudaMemcpy( device_class_loss_weights_arr, class_loss_weights_arr, class_loss_weights_.size() * sizeof(float), cudaMemcpyHostToDevice); // now upload to device SoftmaxLossBackwardGPUClassWeight<Dtype><<<CAFFE_GET_BLOCKS(nthreads), CAFFE_CUDA_NUM_THREADS>>>(nthreads, top_data, label, bottom_diff, outer_num_, dim, inner_num_, has_ignore_label_, ignore_label_, device_class_loss_weights_arr, class_loss_weights_.size(), counts); // free cudaFree(device_class_loss_weights_arr); } else { SoftmaxLossBackwardGPU<Dtype><<<CAFFE_GET_BLOCKS(nthreads), CAFFE_CUDA_NUM_THREADS>>>(nthreads, top_data, label, bottom_diff, outer_num_, dim, inner_num_, has_ignore_label_, ignore_label_, counts); } Dtype valid_count = -1; // Only launch another CUDA kernel if we actually need the count of valid // outputs. if (normalization_ == LossParameter_NormalizationMode_VALID && has_ignore_label_) { caffe_gpu_asum(nthreads, counts, &valid_count); } const Dtype loss_weight = top[0]->cpu_diff()[0] / get_normalizer(normalization_, valid_count); caffe_gpu_scal(prob_.count(), loss_weight , bottom_diff); } } INSTANTIATE_LAYER_GPU_FUNCS(SoftmaxWithLossLayer); } // namespace caffe
cd476331b4a8a1cc7cb44aebba0cca0540558f64.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" /* -- MAGMA (version 1.5.0-beta3) -- Univ. of Tennessee, Knoxville Univ. of California, Berkeley Univ. of Colorado, Denver @date July 2014 @generated from zswap.cu normal z -> c, Fri Jul 18 17:34:12 2014 */ #include "common_magma.h" #define BLOCK_SIZE 64 /********************************************************* * * SWAP BLAS: permute to set of N elements * ********************************************************/ /* * First version: line per line */ typedef struct { magmaFloatComplex *A1; magmaFloatComplex *A2; int n, lda1, lda2; } magmagpu_cswap_params_t; __global__ void magmagpu_cswap( magmagpu_cswap_params_t params ) { unsigned int x = threadIdx.x + blockDim.x*blockIdx.x; unsigned int offset1 = x*params.lda1; unsigned int offset2 = x*params.lda2; if( x < params.n ) { magmaFloatComplex *A1 = params.A1 + offset1; magmaFloatComplex *A2 = params.A2 + offset2; magmaFloatComplex temp = *A1; *A1 = *A2; *A2 = temp; } } extern "C" void magmablas_cswap( magma_int_t n, magmaFloatComplex *dA1T, magma_int_t lda1, magmaFloatComplex *dA2T, magma_int_t lda2) { int blocksize = 64; dim3 blocks( (n+blocksize-1) / blocksize, 1, 1); magmagpu_cswap_params_t params = { dA1T, dA2T, n, lda1, lda2 }; hipLaunchKernelGGL(( magmagpu_cswap), dim3(blocks), dim3(blocksize), 0, magma_stream , params ); }
cd476331b4a8a1cc7cb44aebba0cca0540558f64.cu
/* -- MAGMA (version 1.5.0-beta3) -- Univ. of Tennessee, Knoxville Univ. of California, Berkeley Univ. of Colorado, Denver @date July 2014 @generated from zswap.cu normal z -> c, Fri Jul 18 17:34:12 2014 */ #include "common_magma.h" #define BLOCK_SIZE 64 /********************************************************* * * SWAP BLAS: permute to set of N elements * ********************************************************/ /* * First version: line per line */ typedef struct { magmaFloatComplex *A1; magmaFloatComplex *A2; int n, lda1, lda2; } magmagpu_cswap_params_t; __global__ void magmagpu_cswap( magmagpu_cswap_params_t params ) { unsigned int x = threadIdx.x + blockDim.x*blockIdx.x; unsigned int offset1 = x*params.lda1; unsigned int offset2 = x*params.lda2; if( x < params.n ) { magmaFloatComplex *A1 = params.A1 + offset1; magmaFloatComplex *A2 = params.A2 + offset2; magmaFloatComplex temp = *A1; *A1 = *A2; *A2 = temp; } } extern "C" void magmablas_cswap( magma_int_t n, magmaFloatComplex *dA1T, magma_int_t lda1, magmaFloatComplex *dA2T, magma_int_t lda2) { int blocksize = 64; dim3 blocks( (n+blocksize-1) / blocksize, 1, 1); magmagpu_cswap_params_t params = { dA1T, dA2T, n, lda1, lda2 }; magmagpu_cswap<<< blocks, blocksize, 0, magma_stream >>>( params ); }
576827912c940c65dfae63c93efcb8e6814ad42f.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include<math.h> #include"Boys_gpu.h" #define PI 3.1415926535897932 #define P25 17.4934183276248620 #define NTHREAD 64 texture<int2,1,hipReadModeElementType> tex_P; texture<int2,1,hipReadModeElementType> tex_Zta; texture<int2,1,hipReadModeElementType> tex_pp; texture<float,1,hipReadModeElementType> tex_K2_p; texture<int2,1,hipReadModeElementType> tex_PA; texture<int2,1,hipReadModeElementType> tex_PB; texture<unsigned int,1,hipReadModeElementType> tex_id_bra; texture<int2,1,hipReadModeElementType> tex_Q; texture<int2,1,hipReadModeElementType> tex_Eta; texture<int2,1,hipReadModeElementType> tex_pq; texture<float,1,hipReadModeElementType> tex_K2_q; texture<int2,1,hipReadModeElementType> tex_QC; texture<int2,1,hipReadModeElementType> tex_QD; texture<unsigned int,1,hipReadModeElementType> tex_id_ket; void MD_texture_binding_bra_dd(double * P_d,double * PA_d,double * PB_d,\ double * alphaP_d,double * pp_d,float * K2_p_d,unsigned int * id_bra_d,\ unsigned int primit_len){ hipBindTexture(0, tex_P, P_d, sizeof(double)*primit_len*3); hipBindTexture(0, tex_Zta, alphaP_d, sizeof(double)*primit_len); hipBindTexture(0, tex_pp, pp_d, sizeof(double)*primit_len); hipBindTexture(0, tex_K2_p, K2_p_d, sizeof(float)*primit_len); hipBindTexture(0, tex_PA, PA_d, sizeof(double)*primit_len*3); hipBindTexture(0, tex_PB, PB_d, sizeof(double)*primit_len*3); hipBindTexture(0, tex_id_bra, id_bra_d, sizeof(unsigned int)*primit_len); } void MD_texture_unbind_bra_dd(){ hipUnbindTexture(tex_P); hipUnbindTexture(tex_Zta); hipUnbindTexture(tex_pp); hipUnbindTexture(tex_K2_p); hipUnbindTexture(tex_PA); hipUnbindTexture(tex_PB); hipUnbindTexture(tex_id_bra); } void MD_texture_binding_ket_dd(double * Q_d,double * QC_d,double * QD_d,\ double * alphaQ_d,double * pq_d,float * K2_q_d,unsigned int * id_ket_d,\ unsigned int primit_len){ hipBindTexture(0, tex_Q, Q_d, sizeof(double)*primit_len*3); hipBindTexture(0, tex_Eta, alphaQ_d, sizeof(double)*primit_len); hipBindTexture(0, tex_pq, pq_d, sizeof(double)*primit_len); hipBindTexture(0, tex_K2_q, K2_q_d, sizeof(float)*primit_len); hipBindTexture(0, tex_QC, QC_d, sizeof(double)*primit_len*3); hipBindTexture(0, tex_QD, QD_d, sizeof(double)*primit_len*3); hipBindTexture(0, tex_id_ket, id_ket_d, sizeof(unsigned int)*primit_len); } void MD_texture_unbind_ket_dd(){ hipUnbindTexture(tex_Q); hipUnbindTexture(tex_Eta); hipUnbindTexture(tex_pq); hipUnbindTexture(tex_K2_q); hipUnbindTexture(tex_QC); hipUnbindTexture(tex_QD); hipUnbindTexture(tex_id_ket); } __global__ void MD_Kp_dddd_fs(unsigned int contrc_bra_num,unsigned int contrc_ket_num,\ unsigned int * contrc_bra_id,\ unsigned int * contrc_ket_id,\ unsigned int mtrx_len,\ double * Pmtrx_in,\ double * P,\ double * PA,\ double * PB,\ double * Zta_in,\ double * pp_in,\ float * K2_p_in,\ unsigned int * id_bra_in,\ double * Q,\ double * QC,\ double * QD,\ double * Eta_in,\ double * pq_in,\ float * K2_q_in,\ unsigned int * id_ket_in,\ double * ans){ unsigned int tId_x = threadIdx.x; unsigned int bId_x = blockIdx.x; unsigned int bId_y = blockIdx.y; unsigned int tdis = blockDim.x; unsigned int bdis_x = gridDim.x; unsigned int bdis_y = gridDim.y; unsigned int ans_id=tId_x; double Pmtrx[36]={0.0}; __shared__ double ans_temp[NTHREAD*36]; for(int i=0;i<36;i++){ ans_temp[i*tdis+tId_x]=0.0; } for(unsigned int i_contrc_bra=bId_x;i_contrc_bra<contrc_bra_num;i_contrc_bra+=bdis_x){ for(unsigned int j_contrc_ket=bId_y;j_contrc_ket<contrc_ket_num;j_contrc_ket+=bdis_y){ unsigned int primit_bra_start = contrc_bra_id[i_contrc_bra ]; unsigned int primit_bra_end = contrc_bra_id[i_contrc_bra+1]; unsigned int primit_ket_start = contrc_ket_id[j_contrc_ket ]; unsigned int primit_ket_end = contrc_ket_id[j_contrc_ket+1]; if(i_contrc_bra>j_contrc_ket){ if(tId_x==0){ for(int ians=0;ians<36;ians++){ ans[(i_contrc_bra*contrc_ket_num+j_contrc_ket)*36+ians]=0.0; } } continue; } for(unsigned int ii=primit_ket_start;ii<primit_ket_end;ii++){ unsigned int id_ket=id_ket_in[ii]; double QX=Q[ii*3+0]; double QY=Q[ii*3+1]; double QZ=Q[ii*3+2]; double Qd_010[3]; Qd_010[0]=QC[ii*3+0]; Qd_010[1]=QC[ii*3+1]; Qd_010[2]=QC[ii*3+2]; double Qd_001[3]; Qd_001[0]=QD[ii*3+0]; Qd_001[1]=QD[ii*3+1]; Qd_001[2]=QD[ii*3+2]; double Eta=Eta_in[ii]; double pq=pq_in[ii]; float K2_q=K2_q_in[ii]; double aQin1=1/(2*Eta); for(unsigned int j=tId_x;j<primit_bra_end-primit_bra_start;j+=tdis){ unsigned int jj=primit_bra_start+j; unsigned int id_bra=tex1Dfetch(tex_id_bra,jj); double P_max=0.0; for(int p_j=0;p_j<6;p_j++){ for(int p_i=0;p_i<6;p_i++){ Pmtrx[p_i*6+p_j]=Pmtrx_in[(id_ket+p_j)*mtrx_len+(id_bra+p_i)]; double temp_P=fabsf(Pmtrx[p_i*6+p_j]); if(temp_P>P_max) P_max=temp_P; } } float K2_p=tex1Dfetch(tex_K2_p,jj); if(fabsf(K2_p*K2_q)<1.0E-14){ break; } if(fabsf(P_max*K2_p*K2_q)<1.0E-14) continue; int2 temp_int2; temp_int2=tex1Dfetch(tex_Zta,jj); double Zta=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_pp,jj); double pp=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_P,jj*3+0); double PX=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_P,jj*3+1); double PY=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_P,jj*3+2); double PZ=__hiloint2double(temp_int2.y,temp_int2.x); double Pd_010[3]; temp_int2=tex1Dfetch(tex_PA,jj*3+0); Pd_010[0]=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_PA,jj*3+1); Pd_010[1]=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_PA,jj*3+2); Pd_010[2]=__hiloint2double(temp_int2.y,temp_int2.x); double Pd_001[3]; temp_int2=tex1Dfetch(tex_PB,jj*3+0); Pd_001[0]=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_PB,jj*3+1); Pd_001[1]=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_PB,jj*3+2); Pd_001[2]=__hiloint2double(temp_int2.y,temp_int2.x); double alphaT=rsqrt(Eta+Zta); double lmd=2*P25*pp*pq*alphaT; alphaT=Eta*Zta*alphaT*alphaT; double TX=PX-QX; double TY=PY-QY; double TZ=PZ-QZ; double T=alphaT*(TX*TX+TY*TY+TZ*TZ); double R_000[9]; Ft_fs_8(8,T,R_000); R_000[0]*=lmd; R_000[1]*=-2*alphaT*lmd; R_000[2]*=4*alphaT*alphaT*lmd; R_000[3]*=-8*alphaT*alphaT*alphaT*lmd; R_000[4]*=16*alphaT*alphaT*alphaT*alphaT*lmd; R_000[5]*=-32*alphaT*alphaT*alphaT*alphaT*alphaT*lmd; R_000[6]*=64*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*lmd; R_000[7]*=-128*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*lmd; R_000[8]*=256*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*lmd; double aPin1=1/(2*Zta); double R_100[8]; double R_200[7]; double R_300[6]; double R_400[5]; double R_500[4]; double R_600[3]; double R_700[2]; double R_800[1]; double R_010[8]; double R_110[7]; double R_210[6]; double R_310[5]; double R_410[4]; double R_510[3]; double R_610[2]; double R_710[1]; double R_020[7]; double R_120[6]; double R_220[5]; double R_320[4]; double R_420[3]; double R_520[2]; double R_620[1]; double R_030[6]; double R_130[5]; double R_230[4]; double R_330[3]; double R_430[2]; double R_530[1]; double R_040[5]; double R_140[4]; double R_240[3]; double R_340[2]; double R_440[1]; double R_050[4]; double R_150[3]; double R_250[2]; double R_350[1]; double R_060[3]; double R_160[2]; double R_260[1]; double R_070[2]; double R_170[1]; double R_080[1]; double R_001[8]; double R_101[7]; double R_201[6]; double R_301[5]; double R_401[4]; double R_501[3]; double R_601[2]; double R_701[1]; double R_011[7]; double R_111[6]; double R_211[5]; double R_311[4]; double R_411[3]; double R_511[2]; double R_611[1]; double R_021[6]; double R_121[5]; double R_221[4]; double R_321[3]; double R_421[2]; double R_521[1]; double R_031[5]; double R_131[4]; double R_231[3]; double R_331[2]; double R_431[1]; double R_041[4]; double R_141[3]; double R_241[2]; double R_341[1]; double R_051[3]; double R_151[2]; double R_251[1]; double R_061[2]; double R_161[1]; double R_071[1]; double R_002[7]; double R_102[6]; double R_202[5]; double R_302[4]; double R_402[3]; double R_502[2]; double R_602[1]; double R_012[6]; double R_112[5]; double R_212[4]; double R_312[3]; double R_412[2]; double R_512[1]; double R_022[5]; double R_122[4]; double R_222[3]; double R_322[2]; double R_422[1]; double R_032[4]; double R_132[3]; double R_232[2]; double R_332[1]; double R_042[3]; double R_142[2]; double R_242[1]; double R_052[2]; double R_152[1]; double R_062[1]; double R_003[6]; double R_103[5]; double R_203[4]; double R_303[3]; double R_403[2]; double R_503[1]; double R_013[5]; double R_113[4]; double R_213[3]; double R_313[2]; double R_413[1]; double R_023[4]; double R_123[3]; double R_223[2]; double R_323[1]; double R_033[3]; double R_133[2]; double R_233[1]; double R_043[2]; double R_143[1]; double R_053[1]; double R_004[5]; double R_104[4]; double R_204[3]; double R_304[2]; double R_404[1]; double R_014[4]; double R_114[3]; double R_214[2]; double R_314[1]; double R_024[3]; double R_124[2]; double R_224[1]; double R_034[2]; double R_134[1]; double R_044[1]; double R_005[4]; double R_105[3]; double R_205[2]; double R_305[1]; double R_015[3]; double R_115[2]; double R_215[1]; double R_025[2]; double R_125[1]; double R_035[1]; double R_006[3]; double R_106[2]; double R_206[1]; double R_016[2]; double R_116[1]; double R_026[1]; double R_007[2]; double R_107[1]; double R_017[1]; double R_008[1]; for(int i=0;i<8;i++){ R_100[i]=TX*R_000[i+1]; } for(int i=0;i<8;i++){ R_010[i]=TY*R_000[i+1]; } for(int i=0;i<8;i++){ R_001[i]=TZ*R_000[i+1]; } for(int i=0;i<7;i++){ R_200[i]=TX*R_100[i+1]+R_000[i+1]; } for(int i=0;i<7;i++){ R_110[i]=TX*R_010[i+1]; } for(int i=0;i<7;i++){ R_020[i]=TY*R_010[i+1]+R_000[i+1]; } for(int i=0;i<7;i++){ R_101[i]=TX*R_001[i+1]; } for(int i=0;i<7;i++){ R_011[i]=TY*R_001[i+1]; } for(int i=0;i<7;i++){ R_002[i]=TZ*R_001[i+1]+R_000[i+1]; } for(int i=0;i<6;i++){ R_300[i]=TX*R_200[i+1]+2*R_100[i+1]; } for(int i=0;i<6;i++){ R_210[i]=TY*R_200[i+1]; } for(int i=0;i<6;i++){ R_120[i]=TX*R_020[i+1]; } for(int i=0;i<6;i++){ R_030[i]=TY*R_020[i+1]+2*R_010[i+1]; } for(int i=0;i<6;i++){ R_201[i]=TZ*R_200[i+1]; } for(int i=0;i<6;i++){ R_111[i]=TX*R_011[i+1]; } for(int i=0;i<6;i++){ R_021[i]=TZ*R_020[i+1]; } for(int i=0;i<6;i++){ R_102[i]=TX*R_002[i+1]; } for(int i=0;i<6;i++){ R_012[i]=TY*R_002[i+1]; } for(int i=0;i<6;i++){ R_003[i]=TZ*R_002[i+1]+2*R_001[i+1]; } for(int i=0;i<5;i++){ R_400[i]=TX*R_300[i+1]+3*R_200[i+1]; } for(int i=0;i<5;i++){ R_310[i]=TY*R_300[i+1]; } for(int i=0;i<5;i++){ R_220[i]=TX*R_120[i+1]+R_020[i+1]; } for(int i=0;i<5;i++){ R_130[i]=TX*R_030[i+1]; } for(int i=0;i<5;i++){ R_040[i]=TY*R_030[i+1]+3*R_020[i+1]; } for(int i=0;i<5;i++){ R_301[i]=TZ*R_300[i+1]; } for(int i=0;i<5;i++){ R_211[i]=TY*R_201[i+1]; } for(int i=0;i<5;i++){ R_121[i]=TX*R_021[i+1]; } for(int i=0;i<5;i++){ R_031[i]=TZ*R_030[i+1]; } for(int i=0;i<5;i++){ R_202[i]=TX*R_102[i+1]+R_002[i+1]; } for(int i=0;i<5;i++){ R_112[i]=TX*R_012[i+1]; } for(int i=0;i<5;i++){ R_022[i]=TY*R_012[i+1]+R_002[i+1]; } for(int i=0;i<5;i++){ R_103[i]=TX*R_003[i+1]; } for(int i=0;i<5;i++){ R_013[i]=TY*R_003[i+1]; } for(int i=0;i<5;i++){ R_004[i]=TZ*R_003[i+1]+3*R_002[i+1]; } for(int i=0;i<4;i++){ R_500[i]=TX*R_400[i+1]+4*R_300[i+1]; } for(int i=0;i<4;i++){ R_410[i]=TY*R_400[i+1]; } for(int i=0;i<4;i++){ R_320[i]=TX*R_220[i+1]+2*R_120[i+1]; } for(int i=0;i<4;i++){ R_230[i]=TY*R_220[i+1]+2*R_210[i+1]; } for(int i=0;i<4;i++){ R_140[i]=TX*R_040[i+1]; } for(int i=0;i<4;i++){ R_050[i]=TY*R_040[i+1]+4*R_030[i+1]; } for(int i=0;i<4;i++){ R_401[i]=TZ*R_400[i+1]; } for(int i=0;i<4;i++){ R_311[i]=TY*R_301[i+1]; } for(int i=0;i<4;i++){ R_221[i]=TZ*R_220[i+1]; } for(int i=0;i<4;i++){ R_131[i]=TX*R_031[i+1]; } for(int i=0;i<4;i++){ R_041[i]=TZ*R_040[i+1]; } for(int i=0;i<4;i++){ R_302[i]=TX*R_202[i+1]+2*R_102[i+1]; } for(int i=0;i<4;i++){ R_212[i]=TY*R_202[i+1]; } for(int i=0;i<4;i++){ R_122[i]=TX*R_022[i+1]; } for(int i=0;i<4;i++){ R_032[i]=TY*R_022[i+1]+2*R_012[i+1]; } for(int i=0;i<4;i++){ R_203[i]=TZ*R_202[i+1]+2*R_201[i+1]; } for(int i=0;i<4;i++){ R_113[i]=TX*R_013[i+1]; } for(int i=0;i<4;i++){ R_023[i]=TZ*R_022[i+1]+2*R_021[i+1]; } for(int i=0;i<4;i++){ R_104[i]=TX*R_004[i+1]; } for(int i=0;i<4;i++){ R_014[i]=TY*R_004[i+1]; } for(int i=0;i<4;i++){ R_005[i]=TZ*R_004[i+1]+4*R_003[i+1]; } for(int i=0;i<3;i++){ R_600[i]=TX*R_500[i+1]+5*R_400[i+1]; } for(int i=0;i<3;i++){ R_510[i]=TY*R_500[i+1]; } for(int i=0;i<3;i++){ R_420[i]=TX*R_320[i+1]+3*R_220[i+1]; } for(int i=0;i<3;i++){ R_330[i]=TX*R_230[i+1]+2*R_130[i+1]; } for(int i=0;i<3;i++){ R_240[i]=TY*R_230[i+1]+3*R_220[i+1]; } for(int i=0;i<3;i++){ R_150[i]=TX*R_050[i+1]; } for(int i=0;i<3;i++){ R_060[i]=TY*R_050[i+1]+5*R_040[i+1]; } for(int i=0;i<3;i++){ R_501[i]=TZ*R_500[i+1]; } for(int i=0;i<3;i++){ R_411[i]=TY*R_401[i+1]; } for(int i=0;i<3;i++){ R_321[i]=TZ*R_320[i+1]; } for(int i=0;i<3;i++){ R_231[i]=TZ*R_230[i+1]; } for(int i=0;i<3;i++){ R_141[i]=TX*R_041[i+1]; } for(int i=0;i<3;i++){ R_051[i]=TZ*R_050[i+1]; } for(int i=0;i<3;i++){ R_402[i]=TX*R_302[i+1]+3*R_202[i+1]; } for(int i=0;i<3;i++){ R_312[i]=TY*R_302[i+1]; } for(int i=0;i<3;i++){ R_222[i]=TX*R_122[i+1]+R_022[i+1]; } for(int i=0;i<3;i++){ R_132[i]=TX*R_032[i+1]; } for(int i=0;i<3;i++){ R_042[i]=TY*R_032[i+1]+3*R_022[i+1]; } for(int i=0;i<3;i++){ R_303[i]=TX*R_203[i+1]+2*R_103[i+1]; } for(int i=0;i<3;i++){ R_213[i]=TY*R_203[i+1]; } for(int i=0;i<3;i++){ R_123[i]=TX*R_023[i+1]; } for(int i=0;i<3;i++){ R_033[i]=TY*R_023[i+1]+2*R_013[i+1]; } for(int i=0;i<3;i++){ R_204[i]=TZ*R_203[i+1]+3*R_202[i+1]; } for(int i=0;i<3;i++){ R_114[i]=TX*R_014[i+1]; } for(int i=0;i<3;i++){ R_024[i]=TZ*R_023[i+1]+3*R_022[i+1]; } for(int i=0;i<3;i++){ R_105[i]=TX*R_005[i+1]; } for(int i=0;i<3;i++){ R_015[i]=TY*R_005[i+1]; } for(int i=0;i<3;i++){ R_006[i]=TZ*R_005[i+1]+5*R_004[i+1]; } for(int i=0;i<2;i++){ R_700[i]=TX*R_600[i+1]+6*R_500[i+1]; } for(int i=0;i<2;i++){ R_610[i]=TY*R_600[i+1]; } for(int i=0;i<2;i++){ R_520[i]=TX*R_420[i+1]+4*R_320[i+1]; } for(int i=0;i<2;i++){ R_430[i]=TX*R_330[i+1]+3*R_230[i+1]; } for(int i=0;i<2;i++){ R_340[i]=TY*R_330[i+1]+3*R_320[i+1]; } for(int i=0;i<2;i++){ R_250[i]=TY*R_240[i+1]+4*R_230[i+1]; } for(int i=0;i<2;i++){ R_160[i]=TX*R_060[i+1]; } for(int i=0;i<2;i++){ R_070[i]=TY*R_060[i+1]+6*R_050[i+1]; } for(int i=0;i<2;i++){ R_601[i]=TZ*R_600[i+1]; } for(int i=0;i<2;i++){ R_511[i]=TY*R_501[i+1]; } for(int i=0;i<2;i++){ R_421[i]=TZ*R_420[i+1]; } for(int i=0;i<2;i++){ R_331[i]=TZ*R_330[i+1]; } for(int i=0;i<2;i++){ R_241[i]=TZ*R_240[i+1]; } for(int i=0;i<2;i++){ R_151[i]=TX*R_051[i+1]; } for(int i=0;i<2;i++){ R_061[i]=TZ*R_060[i+1]; } for(int i=0;i<2;i++){ R_502[i]=TX*R_402[i+1]+4*R_302[i+1]; } for(int i=0;i<2;i++){ R_412[i]=TY*R_402[i+1]; } for(int i=0;i<2;i++){ R_322[i]=TX*R_222[i+1]+2*R_122[i+1]; } for(int i=0;i<2;i++){ R_232[i]=TY*R_222[i+1]+2*R_212[i+1]; } for(int i=0;i<2;i++){ R_142[i]=TX*R_042[i+1]; } for(int i=0;i<2;i++){ R_052[i]=TY*R_042[i+1]+4*R_032[i+1]; } for(int i=0;i<2;i++){ R_403[i]=TX*R_303[i+1]+3*R_203[i+1]; } for(int i=0;i<2;i++){ R_313[i]=TY*R_303[i+1]; } for(int i=0;i<2;i++){ R_223[i]=TZ*R_222[i+1]+2*R_221[i+1]; } for(int i=0;i<2;i++){ R_133[i]=TX*R_033[i+1]; } for(int i=0;i<2;i++){ R_043[i]=TY*R_033[i+1]+3*R_023[i+1]; } for(int i=0;i<2;i++){ R_304[i]=TZ*R_303[i+1]+3*R_302[i+1]; } for(int i=0;i<2;i++){ R_214[i]=TY*R_204[i+1]; } for(int i=0;i<2;i++){ R_124[i]=TX*R_024[i+1]; } for(int i=0;i<2;i++){ R_034[i]=TZ*R_033[i+1]+3*R_032[i+1]; } for(int i=0;i<2;i++){ R_205[i]=TZ*R_204[i+1]+4*R_203[i+1]; } for(int i=0;i<2;i++){ R_115[i]=TX*R_015[i+1]; } for(int i=0;i<2;i++){ R_025[i]=TZ*R_024[i+1]+4*R_023[i+1]; } for(int i=0;i<2;i++){ R_106[i]=TX*R_006[i+1]; } for(int i=0;i<2;i++){ R_016[i]=TY*R_006[i+1]; } for(int i=0;i<2;i++){ R_007[i]=TZ*R_006[i+1]+6*R_005[i+1]; } for(int i=0;i<1;i++){ R_800[i]=TX*R_700[i+1]+7*R_600[i+1]; } for(int i=0;i<1;i++){ R_710[i]=TY*R_700[i+1]; } for(int i=0;i<1;i++){ R_620[i]=TX*R_520[i+1]+5*R_420[i+1]; } for(int i=0;i<1;i++){ R_530[i]=TX*R_430[i+1]+4*R_330[i+1]; } for(int i=0;i<1;i++){ R_440[i]=TX*R_340[i+1]+3*R_240[i+1]; } for(int i=0;i<1;i++){ R_350[i]=TY*R_340[i+1]+4*R_330[i+1]; } for(int i=0;i<1;i++){ R_260[i]=TY*R_250[i+1]+5*R_240[i+1]; } for(int i=0;i<1;i++){ R_170[i]=TX*R_070[i+1]; } for(int i=0;i<1;i++){ R_080[i]=TY*R_070[i+1]+7*R_060[i+1]; } for(int i=0;i<1;i++){ R_701[i]=TZ*R_700[i+1]; } for(int i=0;i<1;i++){ R_611[i]=TY*R_601[i+1]; } for(int i=0;i<1;i++){ R_521[i]=TZ*R_520[i+1]; } for(int i=0;i<1;i++){ R_431[i]=TZ*R_430[i+1]; } for(int i=0;i<1;i++){ R_341[i]=TZ*R_340[i+1]; } for(int i=0;i<1;i++){ R_251[i]=TZ*R_250[i+1]; } for(int i=0;i<1;i++){ R_161[i]=TX*R_061[i+1]; } for(int i=0;i<1;i++){ R_071[i]=TZ*R_070[i+1]; } for(int i=0;i<1;i++){ R_602[i]=TX*R_502[i+1]+5*R_402[i+1]; } for(int i=0;i<1;i++){ R_512[i]=TY*R_502[i+1]; } for(int i=0;i<1;i++){ R_422[i]=TX*R_322[i+1]+3*R_222[i+1]; } for(int i=0;i<1;i++){ R_332[i]=TX*R_232[i+1]+2*R_132[i+1]; } for(int i=0;i<1;i++){ R_242[i]=TY*R_232[i+1]+3*R_222[i+1]; } for(int i=0;i<1;i++){ R_152[i]=TX*R_052[i+1]; } for(int i=0;i<1;i++){ R_062[i]=TY*R_052[i+1]+5*R_042[i+1]; } for(int i=0;i<1;i++){ R_503[i]=TX*R_403[i+1]+4*R_303[i+1]; } for(int i=0;i<1;i++){ R_413[i]=TY*R_403[i+1]; } for(int i=0;i<1;i++){ R_323[i]=TX*R_223[i+1]+2*R_123[i+1]; } for(int i=0;i<1;i++){ R_233[i]=TY*R_223[i+1]+2*R_213[i+1]; } for(int i=0;i<1;i++){ R_143[i]=TX*R_043[i+1]; } for(int i=0;i<1;i++){ R_053[i]=TY*R_043[i+1]+4*R_033[i+1]; } for(int i=0;i<1;i++){ R_404[i]=TX*R_304[i+1]+3*R_204[i+1]; } for(int i=0;i<1;i++){ R_314[i]=TY*R_304[i+1]; } for(int i=0;i<1;i++){ R_224[i]=TZ*R_223[i+1]+3*R_222[i+1]; } for(int i=0;i<1;i++){ R_134[i]=TX*R_034[i+1]; } for(int i=0;i<1;i++){ R_044[i]=TY*R_034[i+1]+3*R_024[i+1]; } for(int i=0;i<1;i++){ R_305[i]=TZ*R_304[i+1]+4*R_303[i+1]; } for(int i=0;i<1;i++){ R_215[i]=TY*R_205[i+1]; } for(int i=0;i<1;i++){ R_125[i]=TX*R_025[i+1]; } for(int i=0;i<1;i++){ R_035[i]=TZ*R_034[i+1]+4*R_033[i+1]; } for(int i=0;i<1;i++){ R_206[i]=TZ*R_205[i+1]+5*R_204[i+1]; } for(int i=0;i<1;i++){ R_116[i]=TX*R_016[i+1]; } for(int i=0;i<1;i++){ R_026[i]=TZ*R_025[i+1]+5*R_024[i+1]; } for(int i=0;i<1;i++){ R_107[i]=TX*R_007[i+1]; } for(int i=0;i<1;i++){ R_017[i]=TY*R_007[i+1]; } for(int i=0;i<1;i++){ R_008[i]=TZ*R_007[i+1]+7*R_006[i+1]; } double Pd_101[3]; double Pd_002[3]; double Pd_102[3]; double Pd_202[3]; double Pd_110[3]; double Pd_011[3]; double Pd_111[3]; double Pd_211[3]; double Pd_012[3]; double Pd_112[3]; double Pd_212[3]; double Pd_312[3]; double Pd_020[3]; double Pd_120[3]; double Pd_220[3]; double Pd_021[3]; double Pd_121[3]; double Pd_221[3]; double Pd_321[3]; double Pd_022[3]; double Pd_122[3]; double Pd_222[3]; double Pd_322[3]; double Pd_422[3]; for(int i=0;i<3;i++){ Pd_101[i]=aPin1; } for(int i=0;i<3;i++){ Pd_002[i]=Pd_101[i]+Pd_001[i]*Pd_001[i]; } for(int i=0;i<3;i++){ Pd_102[i]=Pd_001[i]*Pd_101[i]+aPin1*Pd_001[i]; } for(int i=0;i<3;i++){ Pd_202[i]=aPin1*Pd_101[i]; } for(int i=0;i<3;i++){ Pd_110[i]=aPin1; } for(int i=0;i<3;i++){ Pd_011[i]=Pd_101[i]+Pd_010[i]*Pd_001[i]; } for(int i=0;i<3;i++){ Pd_111[i]=Pd_010[i]*Pd_101[i]+aPin1*Pd_001[i]; } for(int i=0;i<3;i++){ Pd_211[i]=aPin1*Pd_101[i]; } for(int i=0;i<3;i++){ Pd_012[i]=Pd_111[i]+Pd_001[i]*Pd_011[i]; } for(int i=0;i<3;i++){ Pd_112[i]=2*Pd_211[i]+Pd_001[i]*Pd_111[i]+aPin1*Pd_011[i]; } for(int i=0;i<3;i++){ Pd_212[i]=Pd_001[i]*Pd_211[i]+aPin1*Pd_111[i]; } for(int i=0;i<3;i++){ Pd_312[i]=aPin1*Pd_211[i]; } for(int i=0;i<3;i++){ Pd_020[i]=Pd_110[i]+Pd_010[i]*Pd_010[i]; } for(int i=0;i<3;i++){ Pd_120[i]=Pd_010[i]*Pd_110[i]+aPin1*Pd_010[i]; } for(int i=0;i<3;i++){ Pd_220[i]=aPin1*Pd_110[i]; } for(int i=0;i<3;i++){ Pd_021[i]=Pd_111[i]+Pd_010[i]*Pd_011[i]; } for(int i=0;i<3;i++){ Pd_121[i]=2*Pd_211[i]+Pd_010[i]*Pd_111[i]+aPin1*Pd_011[i]; } for(int i=0;i<3;i++){ Pd_221[i]=Pd_010[i]*Pd_211[i]+aPin1*Pd_111[i]; } for(int i=0;i<3;i++){ Pd_321[i]=aPin1*Pd_211[i]; } for(int i=0;i<3;i++){ Pd_022[i]=Pd_112[i]+Pd_010[i]*Pd_012[i]; } for(int i=0;i<3;i++){ Pd_122[i]=2*Pd_212[i]+Pd_010[i]*Pd_112[i]+aPin1*Pd_012[i]; } for(int i=0;i<3;i++){ Pd_222[i]=3*Pd_312[i]+Pd_010[i]*Pd_212[i]+aPin1*Pd_112[i]; } for(int i=0;i<3;i++){ Pd_322[i]=Pd_010[i]*Pd_312[i]+aPin1*Pd_212[i]; } for(int i=0;i<3;i++){ Pd_422[i]=aPin1*Pd_312[i]; } double P_022000000=Pd_022[0]; double P_122000000=Pd_122[0]; double P_222000000=Pd_222[0]; double P_322000000=Pd_322[0]; double P_422000000=Pd_422[0]; double P_021001000=Pd_021[0]*Pd_001[1]; double P_021101000=Pd_021[0]*Pd_101[1]; double P_121001000=Pd_121[0]*Pd_001[1]; double P_121101000=Pd_121[0]*Pd_101[1]; double P_221001000=Pd_221[0]*Pd_001[1]; double P_221101000=Pd_221[0]*Pd_101[1]; double P_321001000=Pd_321[0]*Pd_001[1]; double P_321101000=Pd_321[0]*Pd_101[1]; double P_020002000=Pd_020[0]*Pd_002[1]; double P_020102000=Pd_020[0]*Pd_102[1]; double P_020202000=Pd_020[0]*Pd_202[1]; double P_120002000=Pd_120[0]*Pd_002[1]; double P_120102000=Pd_120[0]*Pd_102[1]; double P_120202000=Pd_120[0]*Pd_202[1]; double P_220002000=Pd_220[0]*Pd_002[1]; double P_220102000=Pd_220[0]*Pd_102[1]; double P_220202000=Pd_220[0]*Pd_202[1]; double P_021000001=Pd_021[0]*Pd_001[2]; double P_021000101=Pd_021[0]*Pd_101[2]; double P_121000001=Pd_121[0]*Pd_001[2]; double P_121000101=Pd_121[0]*Pd_101[2]; double P_221000001=Pd_221[0]*Pd_001[2]; double P_221000101=Pd_221[0]*Pd_101[2]; double P_321000001=Pd_321[0]*Pd_001[2]; double P_321000101=Pd_321[0]*Pd_101[2]; double P_020001001=Pd_020[0]*Pd_001[1]*Pd_001[2]; double P_020001101=Pd_020[0]*Pd_001[1]*Pd_101[2]; double P_020101001=Pd_020[0]*Pd_101[1]*Pd_001[2]; double P_020101101=Pd_020[0]*Pd_101[1]*Pd_101[2]; double P_120001001=Pd_120[0]*Pd_001[1]*Pd_001[2]; double P_120001101=Pd_120[0]*Pd_001[1]*Pd_101[2]; double P_120101001=Pd_120[0]*Pd_101[1]*Pd_001[2]; double P_120101101=Pd_120[0]*Pd_101[1]*Pd_101[2]; double P_220001001=Pd_220[0]*Pd_001[1]*Pd_001[2]; double P_220001101=Pd_220[0]*Pd_001[1]*Pd_101[2]; double P_220101001=Pd_220[0]*Pd_101[1]*Pd_001[2]; double P_220101101=Pd_220[0]*Pd_101[1]*Pd_101[2]; double P_020000002=Pd_020[0]*Pd_002[2]; double P_020000102=Pd_020[0]*Pd_102[2]; double P_020000202=Pd_020[0]*Pd_202[2]; double P_120000002=Pd_120[0]*Pd_002[2]; double P_120000102=Pd_120[0]*Pd_102[2]; double P_120000202=Pd_120[0]*Pd_202[2]; double P_220000002=Pd_220[0]*Pd_002[2]; double P_220000102=Pd_220[0]*Pd_102[2]; double P_220000202=Pd_220[0]*Pd_202[2]; double P_012010000=Pd_012[0]*Pd_010[1]; double P_012110000=Pd_012[0]*Pd_110[1]; double P_112010000=Pd_112[0]*Pd_010[1]; double P_112110000=Pd_112[0]*Pd_110[1]; double P_212010000=Pd_212[0]*Pd_010[1]; double P_212110000=Pd_212[0]*Pd_110[1]; double P_312010000=Pd_312[0]*Pd_010[1]; double P_312110000=Pd_312[0]*Pd_110[1]; double P_011011000=Pd_011[0]*Pd_011[1]; double P_011111000=Pd_011[0]*Pd_111[1]; double P_011211000=Pd_011[0]*Pd_211[1]; double P_111011000=Pd_111[0]*Pd_011[1]; double P_111111000=Pd_111[0]*Pd_111[1]; double P_111211000=Pd_111[0]*Pd_211[1]; double P_211011000=Pd_211[0]*Pd_011[1]; double P_211111000=Pd_211[0]*Pd_111[1]; double P_211211000=Pd_211[0]*Pd_211[1]; double P_010012000=Pd_010[0]*Pd_012[1]; double P_010112000=Pd_010[0]*Pd_112[1]; double P_010212000=Pd_010[0]*Pd_212[1]; double P_010312000=Pd_010[0]*Pd_312[1]; double P_110012000=Pd_110[0]*Pd_012[1]; double P_110112000=Pd_110[0]*Pd_112[1]; double P_110212000=Pd_110[0]*Pd_212[1]; double P_110312000=Pd_110[0]*Pd_312[1]; double P_011010001=Pd_011[0]*Pd_010[1]*Pd_001[2]; double P_011010101=Pd_011[0]*Pd_010[1]*Pd_101[2]; double P_011110001=Pd_011[0]*Pd_110[1]*Pd_001[2]; double P_011110101=Pd_011[0]*Pd_110[1]*Pd_101[2]; double P_111010001=Pd_111[0]*Pd_010[1]*Pd_001[2]; double P_111010101=Pd_111[0]*Pd_010[1]*Pd_101[2]; double P_111110001=Pd_111[0]*Pd_110[1]*Pd_001[2]; double P_111110101=Pd_111[0]*Pd_110[1]*Pd_101[2]; double P_211010001=Pd_211[0]*Pd_010[1]*Pd_001[2]; double P_211010101=Pd_211[0]*Pd_010[1]*Pd_101[2]; double P_211110001=Pd_211[0]*Pd_110[1]*Pd_001[2]; double P_211110101=Pd_211[0]*Pd_110[1]*Pd_101[2]; double P_010011001=Pd_010[0]*Pd_011[1]*Pd_001[2]; double P_010011101=Pd_010[0]*Pd_011[1]*Pd_101[2]; double P_010111001=Pd_010[0]*Pd_111[1]*Pd_001[2]; double P_010111101=Pd_010[0]*Pd_111[1]*Pd_101[2]; double P_010211001=Pd_010[0]*Pd_211[1]*Pd_001[2]; double P_010211101=Pd_010[0]*Pd_211[1]*Pd_101[2]; double P_110011001=Pd_110[0]*Pd_011[1]*Pd_001[2]; double P_110011101=Pd_110[0]*Pd_011[1]*Pd_101[2]; double P_110111001=Pd_110[0]*Pd_111[1]*Pd_001[2]; double P_110111101=Pd_110[0]*Pd_111[1]*Pd_101[2]; double P_110211001=Pd_110[0]*Pd_211[1]*Pd_001[2]; double P_110211101=Pd_110[0]*Pd_211[1]*Pd_101[2]; double P_010010002=Pd_010[0]*Pd_010[1]*Pd_002[2]; double P_010010102=Pd_010[0]*Pd_010[1]*Pd_102[2]; double P_010010202=Pd_010[0]*Pd_010[1]*Pd_202[2]; double P_010110002=Pd_010[0]*Pd_110[1]*Pd_002[2]; double P_010110102=Pd_010[0]*Pd_110[1]*Pd_102[2]; double P_010110202=Pd_010[0]*Pd_110[1]*Pd_202[2]; double P_110010002=Pd_110[0]*Pd_010[1]*Pd_002[2]; double P_110010102=Pd_110[0]*Pd_010[1]*Pd_102[2]; double P_110010202=Pd_110[0]*Pd_010[1]*Pd_202[2]; double P_110110002=Pd_110[0]*Pd_110[1]*Pd_002[2]; double P_110110102=Pd_110[0]*Pd_110[1]*Pd_102[2]; double P_110110202=Pd_110[0]*Pd_110[1]*Pd_202[2]; double P_002020000=Pd_002[0]*Pd_020[1]; double P_002120000=Pd_002[0]*Pd_120[1]; double P_002220000=Pd_002[0]*Pd_220[1]; double P_102020000=Pd_102[0]*Pd_020[1]; double P_102120000=Pd_102[0]*Pd_120[1]; double P_102220000=Pd_102[0]*Pd_220[1]; double P_202020000=Pd_202[0]*Pd_020[1]; double P_202120000=Pd_202[0]*Pd_120[1]; double P_202220000=Pd_202[0]*Pd_220[1]; double P_001021000=Pd_001[0]*Pd_021[1]; double P_001121000=Pd_001[0]*Pd_121[1]; double P_001221000=Pd_001[0]*Pd_221[1]; double P_001321000=Pd_001[0]*Pd_321[1]; double P_101021000=Pd_101[0]*Pd_021[1]; double P_101121000=Pd_101[0]*Pd_121[1]; double P_101221000=Pd_101[0]*Pd_221[1]; double P_101321000=Pd_101[0]*Pd_321[1]; double P_000022000=Pd_022[1]; double P_000122000=Pd_122[1]; double P_000222000=Pd_222[1]; double P_000322000=Pd_322[1]; double P_000422000=Pd_422[1]; double P_001020001=Pd_001[0]*Pd_020[1]*Pd_001[2]; double P_001020101=Pd_001[0]*Pd_020[1]*Pd_101[2]; double P_001120001=Pd_001[0]*Pd_120[1]*Pd_001[2]; double P_001120101=Pd_001[0]*Pd_120[1]*Pd_101[2]; double P_001220001=Pd_001[0]*Pd_220[1]*Pd_001[2]; double P_001220101=Pd_001[0]*Pd_220[1]*Pd_101[2]; double P_101020001=Pd_101[0]*Pd_020[1]*Pd_001[2]; double P_101020101=Pd_101[0]*Pd_020[1]*Pd_101[2]; double P_101120001=Pd_101[0]*Pd_120[1]*Pd_001[2]; double P_101120101=Pd_101[0]*Pd_120[1]*Pd_101[2]; double P_101220001=Pd_101[0]*Pd_220[1]*Pd_001[2]; double P_101220101=Pd_101[0]*Pd_220[1]*Pd_101[2]; double P_000021001=Pd_021[1]*Pd_001[2]; double P_000021101=Pd_021[1]*Pd_101[2]; double P_000121001=Pd_121[1]*Pd_001[2]; double P_000121101=Pd_121[1]*Pd_101[2]; double P_000221001=Pd_221[1]*Pd_001[2]; double P_000221101=Pd_221[1]*Pd_101[2]; double P_000321001=Pd_321[1]*Pd_001[2]; double P_000321101=Pd_321[1]*Pd_101[2]; double P_000020002=Pd_020[1]*Pd_002[2]; double P_000020102=Pd_020[1]*Pd_102[2]; double P_000020202=Pd_020[1]*Pd_202[2]; double P_000120002=Pd_120[1]*Pd_002[2]; double P_000120102=Pd_120[1]*Pd_102[2]; double P_000120202=Pd_120[1]*Pd_202[2]; double P_000220002=Pd_220[1]*Pd_002[2]; double P_000220102=Pd_220[1]*Pd_102[2]; double P_000220202=Pd_220[1]*Pd_202[2]; double P_012000010=Pd_012[0]*Pd_010[2]; double P_012000110=Pd_012[0]*Pd_110[2]; double P_112000010=Pd_112[0]*Pd_010[2]; double P_112000110=Pd_112[0]*Pd_110[2]; double P_212000010=Pd_212[0]*Pd_010[2]; double P_212000110=Pd_212[0]*Pd_110[2]; double P_312000010=Pd_312[0]*Pd_010[2]; double P_312000110=Pd_312[0]*Pd_110[2]; double P_011001010=Pd_011[0]*Pd_001[1]*Pd_010[2]; double P_011001110=Pd_011[0]*Pd_001[1]*Pd_110[2]; double P_011101010=Pd_011[0]*Pd_101[1]*Pd_010[2]; double P_011101110=Pd_011[0]*Pd_101[1]*Pd_110[2]; double P_111001010=Pd_111[0]*Pd_001[1]*Pd_010[2]; double P_111001110=Pd_111[0]*Pd_001[1]*Pd_110[2]; double P_111101010=Pd_111[0]*Pd_101[1]*Pd_010[2]; double P_111101110=Pd_111[0]*Pd_101[1]*Pd_110[2]; double P_211001010=Pd_211[0]*Pd_001[1]*Pd_010[2]; double P_211001110=Pd_211[0]*Pd_001[1]*Pd_110[2]; double P_211101010=Pd_211[0]*Pd_101[1]*Pd_010[2]; double P_211101110=Pd_211[0]*Pd_101[1]*Pd_110[2]; double P_010002010=Pd_010[0]*Pd_002[1]*Pd_010[2]; double P_010002110=Pd_010[0]*Pd_002[1]*Pd_110[2]; double P_010102010=Pd_010[0]*Pd_102[1]*Pd_010[2]; double P_010102110=Pd_010[0]*Pd_102[1]*Pd_110[2]; double P_010202010=Pd_010[0]*Pd_202[1]*Pd_010[2]; double P_010202110=Pd_010[0]*Pd_202[1]*Pd_110[2]; double P_110002010=Pd_110[0]*Pd_002[1]*Pd_010[2]; double P_110002110=Pd_110[0]*Pd_002[1]*Pd_110[2]; double P_110102010=Pd_110[0]*Pd_102[1]*Pd_010[2]; double P_110102110=Pd_110[0]*Pd_102[1]*Pd_110[2]; double P_110202010=Pd_110[0]*Pd_202[1]*Pd_010[2]; double P_110202110=Pd_110[0]*Pd_202[1]*Pd_110[2]; double P_011000011=Pd_011[0]*Pd_011[2]; double P_011000111=Pd_011[0]*Pd_111[2]; double P_011000211=Pd_011[0]*Pd_211[2]; double P_111000011=Pd_111[0]*Pd_011[2]; double P_111000111=Pd_111[0]*Pd_111[2]; double P_111000211=Pd_111[0]*Pd_211[2]; double P_211000011=Pd_211[0]*Pd_011[2]; double P_211000111=Pd_211[0]*Pd_111[2]; double P_211000211=Pd_211[0]*Pd_211[2]; double P_010001011=Pd_010[0]*Pd_001[1]*Pd_011[2]; double P_010001111=Pd_010[0]*Pd_001[1]*Pd_111[2]; double P_010001211=Pd_010[0]*Pd_001[1]*Pd_211[2]; double P_010101011=Pd_010[0]*Pd_101[1]*Pd_011[2]; double P_010101111=Pd_010[0]*Pd_101[1]*Pd_111[2]; double P_010101211=Pd_010[0]*Pd_101[1]*Pd_211[2]; double P_110001011=Pd_110[0]*Pd_001[1]*Pd_011[2]; double P_110001111=Pd_110[0]*Pd_001[1]*Pd_111[2]; double P_110001211=Pd_110[0]*Pd_001[1]*Pd_211[2]; double P_110101011=Pd_110[0]*Pd_101[1]*Pd_011[2]; double P_110101111=Pd_110[0]*Pd_101[1]*Pd_111[2]; double P_110101211=Pd_110[0]*Pd_101[1]*Pd_211[2]; double P_010000012=Pd_010[0]*Pd_012[2]; double P_010000112=Pd_010[0]*Pd_112[2]; double P_010000212=Pd_010[0]*Pd_212[2]; double P_010000312=Pd_010[0]*Pd_312[2]; double P_110000012=Pd_110[0]*Pd_012[2]; double P_110000112=Pd_110[0]*Pd_112[2]; double P_110000212=Pd_110[0]*Pd_212[2]; double P_110000312=Pd_110[0]*Pd_312[2]; double P_002010010=Pd_002[0]*Pd_010[1]*Pd_010[2]; double P_002010110=Pd_002[0]*Pd_010[1]*Pd_110[2]; double P_002110010=Pd_002[0]*Pd_110[1]*Pd_010[2]; double P_002110110=Pd_002[0]*Pd_110[1]*Pd_110[2]; double P_102010010=Pd_102[0]*Pd_010[1]*Pd_010[2]; double P_102010110=Pd_102[0]*Pd_010[1]*Pd_110[2]; double P_102110010=Pd_102[0]*Pd_110[1]*Pd_010[2]; double P_102110110=Pd_102[0]*Pd_110[1]*Pd_110[2]; double P_202010010=Pd_202[0]*Pd_010[1]*Pd_010[2]; double P_202010110=Pd_202[0]*Pd_010[1]*Pd_110[2]; double P_202110010=Pd_202[0]*Pd_110[1]*Pd_010[2]; double P_202110110=Pd_202[0]*Pd_110[1]*Pd_110[2]; double P_001011010=Pd_001[0]*Pd_011[1]*Pd_010[2]; double P_001011110=Pd_001[0]*Pd_011[1]*Pd_110[2]; double P_001111010=Pd_001[0]*Pd_111[1]*Pd_010[2]; double P_001111110=Pd_001[0]*Pd_111[1]*Pd_110[2]; double P_001211010=Pd_001[0]*Pd_211[1]*Pd_010[2]; double P_001211110=Pd_001[0]*Pd_211[1]*Pd_110[2]; double P_101011010=Pd_101[0]*Pd_011[1]*Pd_010[2]; double P_101011110=Pd_101[0]*Pd_011[1]*Pd_110[2]; double P_101111010=Pd_101[0]*Pd_111[1]*Pd_010[2]; double P_101111110=Pd_101[0]*Pd_111[1]*Pd_110[2]; double P_101211010=Pd_101[0]*Pd_211[1]*Pd_010[2]; double P_101211110=Pd_101[0]*Pd_211[1]*Pd_110[2]; double P_000012010=Pd_012[1]*Pd_010[2]; double P_000012110=Pd_012[1]*Pd_110[2]; double P_000112010=Pd_112[1]*Pd_010[2]; double P_000112110=Pd_112[1]*Pd_110[2]; double P_000212010=Pd_212[1]*Pd_010[2]; double P_000212110=Pd_212[1]*Pd_110[2]; double P_000312010=Pd_312[1]*Pd_010[2]; double P_000312110=Pd_312[1]*Pd_110[2]; double P_001010011=Pd_001[0]*Pd_010[1]*Pd_011[2]; double P_001010111=Pd_001[0]*Pd_010[1]*Pd_111[2]; double P_001010211=Pd_001[0]*Pd_010[1]*Pd_211[2]; double P_001110011=Pd_001[0]*Pd_110[1]*Pd_011[2]; double P_001110111=Pd_001[0]*Pd_110[1]*Pd_111[2]; double P_001110211=Pd_001[0]*Pd_110[1]*Pd_211[2]; double P_101010011=Pd_101[0]*Pd_010[1]*Pd_011[2]; double P_101010111=Pd_101[0]*Pd_010[1]*Pd_111[2]; double P_101010211=Pd_101[0]*Pd_010[1]*Pd_211[2]; double P_101110011=Pd_101[0]*Pd_110[1]*Pd_011[2]; double P_101110111=Pd_101[0]*Pd_110[1]*Pd_111[2]; double P_101110211=Pd_101[0]*Pd_110[1]*Pd_211[2]; double P_000011011=Pd_011[1]*Pd_011[2]; double P_000011111=Pd_011[1]*Pd_111[2]; double P_000011211=Pd_011[1]*Pd_211[2]; double P_000111011=Pd_111[1]*Pd_011[2]; double P_000111111=Pd_111[1]*Pd_111[2]; double P_000111211=Pd_111[1]*Pd_211[2]; double P_000211011=Pd_211[1]*Pd_011[2]; double P_000211111=Pd_211[1]*Pd_111[2]; double P_000211211=Pd_211[1]*Pd_211[2]; double P_000010012=Pd_010[1]*Pd_012[2]; double P_000010112=Pd_010[1]*Pd_112[2]; double P_000010212=Pd_010[1]*Pd_212[2]; double P_000010312=Pd_010[1]*Pd_312[2]; double P_000110012=Pd_110[1]*Pd_012[2]; double P_000110112=Pd_110[1]*Pd_112[2]; double P_000110212=Pd_110[1]*Pd_212[2]; double P_000110312=Pd_110[1]*Pd_312[2]; double P_002000020=Pd_002[0]*Pd_020[2]; double P_002000120=Pd_002[0]*Pd_120[2]; double P_002000220=Pd_002[0]*Pd_220[2]; double P_102000020=Pd_102[0]*Pd_020[2]; double P_102000120=Pd_102[0]*Pd_120[2]; double P_102000220=Pd_102[0]*Pd_220[2]; double P_202000020=Pd_202[0]*Pd_020[2]; double P_202000120=Pd_202[0]*Pd_120[2]; double P_202000220=Pd_202[0]*Pd_220[2]; double P_001001020=Pd_001[0]*Pd_001[1]*Pd_020[2]; double P_001001120=Pd_001[0]*Pd_001[1]*Pd_120[2]; double P_001001220=Pd_001[0]*Pd_001[1]*Pd_220[2]; double P_001101020=Pd_001[0]*Pd_101[1]*Pd_020[2]; double P_001101120=Pd_001[0]*Pd_101[1]*Pd_120[2]; double P_001101220=Pd_001[0]*Pd_101[1]*Pd_220[2]; double P_101001020=Pd_101[0]*Pd_001[1]*Pd_020[2]; double P_101001120=Pd_101[0]*Pd_001[1]*Pd_120[2]; double P_101001220=Pd_101[0]*Pd_001[1]*Pd_220[2]; double P_101101020=Pd_101[0]*Pd_101[1]*Pd_020[2]; double P_101101120=Pd_101[0]*Pd_101[1]*Pd_120[2]; double P_101101220=Pd_101[0]*Pd_101[1]*Pd_220[2]; double P_000002020=Pd_002[1]*Pd_020[2]; double P_000002120=Pd_002[1]*Pd_120[2]; double P_000002220=Pd_002[1]*Pd_220[2]; double P_000102020=Pd_102[1]*Pd_020[2]; double P_000102120=Pd_102[1]*Pd_120[2]; double P_000102220=Pd_102[1]*Pd_220[2]; double P_000202020=Pd_202[1]*Pd_020[2]; double P_000202120=Pd_202[1]*Pd_120[2]; double P_000202220=Pd_202[1]*Pd_220[2]; double P_001000021=Pd_001[0]*Pd_021[2]; double P_001000121=Pd_001[0]*Pd_121[2]; double P_001000221=Pd_001[0]*Pd_221[2]; double P_001000321=Pd_001[0]*Pd_321[2]; double P_101000021=Pd_101[0]*Pd_021[2]; double P_101000121=Pd_101[0]*Pd_121[2]; double P_101000221=Pd_101[0]*Pd_221[2]; double P_101000321=Pd_101[0]*Pd_321[2]; double P_000001021=Pd_001[1]*Pd_021[2]; double P_000001121=Pd_001[1]*Pd_121[2]; double P_000001221=Pd_001[1]*Pd_221[2]; double P_000001321=Pd_001[1]*Pd_321[2]; double P_000101021=Pd_101[1]*Pd_021[2]; double P_000101121=Pd_101[1]*Pd_121[2]; double P_000101221=Pd_101[1]*Pd_221[2]; double P_000101321=Pd_101[1]*Pd_321[2]; double P_000000022=Pd_022[2]; double P_000000122=Pd_122[2]; double P_000000222=Pd_222[2]; double P_000000322=Pd_322[2]; double P_000000422=Pd_422[2]; double PR_022000000000=P_022000000*R_000[0]+-1*P_122000000*R_100[0]+P_222000000*R_200[0]+-1*P_322000000*R_300[0]+P_422000000*R_400[0]; double PR_021001000000=P_021001000*R_000[0]+-1*P_021101000*R_010[0]+-1*P_121001000*R_100[0]+P_121101000*R_110[0]+P_221001000*R_200[0]+-1*P_221101000*R_210[0]+-1*P_321001000*R_300[0]+P_321101000*R_310[0]; double PR_020002000000=P_020002000*R_000[0]+-1*P_020102000*R_010[0]+P_020202000*R_020[0]+-1*P_120002000*R_100[0]+P_120102000*R_110[0]+-1*P_120202000*R_120[0]+P_220002000*R_200[0]+-1*P_220102000*R_210[0]+P_220202000*R_220[0]; double PR_021000001000=P_021000001*R_000[0]+-1*P_021000101*R_001[0]+-1*P_121000001*R_100[0]+P_121000101*R_101[0]+P_221000001*R_200[0]+-1*P_221000101*R_201[0]+-1*P_321000001*R_300[0]+P_321000101*R_301[0]; double PR_020001001000=P_020001001*R_000[0]+-1*P_020001101*R_001[0]+-1*P_020101001*R_010[0]+P_020101101*R_011[0]+-1*P_120001001*R_100[0]+P_120001101*R_101[0]+P_120101001*R_110[0]+-1*P_120101101*R_111[0]+P_220001001*R_200[0]+-1*P_220001101*R_201[0]+-1*P_220101001*R_210[0]+P_220101101*R_211[0]; double PR_020000002000=P_020000002*R_000[0]+-1*P_020000102*R_001[0]+P_020000202*R_002[0]+-1*P_120000002*R_100[0]+P_120000102*R_101[0]+-1*P_120000202*R_102[0]+P_220000002*R_200[0]+-1*P_220000102*R_201[0]+P_220000202*R_202[0]; double PR_012010000000=P_012010000*R_000[0]+-1*P_012110000*R_010[0]+-1*P_112010000*R_100[0]+P_112110000*R_110[0]+P_212010000*R_200[0]+-1*P_212110000*R_210[0]+-1*P_312010000*R_300[0]+P_312110000*R_310[0]; double PR_011011000000=P_011011000*R_000[0]+-1*P_011111000*R_010[0]+P_011211000*R_020[0]+-1*P_111011000*R_100[0]+P_111111000*R_110[0]+-1*P_111211000*R_120[0]+P_211011000*R_200[0]+-1*P_211111000*R_210[0]+P_211211000*R_220[0]; double PR_010012000000=P_010012000*R_000[0]+-1*P_010112000*R_010[0]+P_010212000*R_020[0]+-1*P_010312000*R_030[0]+-1*P_110012000*R_100[0]+P_110112000*R_110[0]+-1*P_110212000*R_120[0]+P_110312000*R_130[0]; double PR_011010001000=P_011010001*R_000[0]+-1*P_011010101*R_001[0]+-1*P_011110001*R_010[0]+P_011110101*R_011[0]+-1*P_111010001*R_100[0]+P_111010101*R_101[0]+P_111110001*R_110[0]+-1*P_111110101*R_111[0]+P_211010001*R_200[0]+-1*P_211010101*R_201[0]+-1*P_211110001*R_210[0]+P_211110101*R_211[0]; double PR_010011001000=P_010011001*R_000[0]+-1*P_010011101*R_001[0]+-1*P_010111001*R_010[0]+P_010111101*R_011[0]+P_010211001*R_020[0]+-1*P_010211101*R_021[0]+-1*P_110011001*R_100[0]+P_110011101*R_101[0]+P_110111001*R_110[0]+-1*P_110111101*R_111[0]+-1*P_110211001*R_120[0]+P_110211101*R_121[0]; double PR_010010002000=P_010010002*R_000[0]+-1*P_010010102*R_001[0]+P_010010202*R_002[0]+-1*P_010110002*R_010[0]+P_010110102*R_011[0]+-1*P_010110202*R_012[0]+-1*P_110010002*R_100[0]+P_110010102*R_101[0]+-1*P_110010202*R_102[0]+P_110110002*R_110[0]+-1*P_110110102*R_111[0]+P_110110202*R_112[0]; double PR_002020000000=P_002020000*R_000[0]+-1*P_002120000*R_010[0]+P_002220000*R_020[0]+-1*P_102020000*R_100[0]+P_102120000*R_110[0]+-1*P_102220000*R_120[0]+P_202020000*R_200[0]+-1*P_202120000*R_210[0]+P_202220000*R_220[0]; double PR_001021000000=P_001021000*R_000[0]+-1*P_001121000*R_010[0]+P_001221000*R_020[0]+-1*P_001321000*R_030[0]+-1*P_101021000*R_100[0]+P_101121000*R_110[0]+-1*P_101221000*R_120[0]+P_101321000*R_130[0]; double PR_000022000000=P_000022000*R_000[0]+-1*P_000122000*R_010[0]+P_000222000*R_020[0]+-1*P_000322000*R_030[0]+P_000422000*R_040[0]; double PR_001020001000=P_001020001*R_000[0]+-1*P_001020101*R_001[0]+-1*P_001120001*R_010[0]+P_001120101*R_011[0]+P_001220001*R_020[0]+-1*P_001220101*R_021[0]+-1*P_101020001*R_100[0]+P_101020101*R_101[0]+P_101120001*R_110[0]+-1*P_101120101*R_111[0]+-1*P_101220001*R_120[0]+P_101220101*R_121[0]; double PR_000021001000=P_000021001*R_000[0]+-1*P_000021101*R_001[0]+-1*P_000121001*R_010[0]+P_000121101*R_011[0]+P_000221001*R_020[0]+-1*P_000221101*R_021[0]+-1*P_000321001*R_030[0]+P_000321101*R_031[0]; double PR_000020002000=P_000020002*R_000[0]+-1*P_000020102*R_001[0]+P_000020202*R_002[0]+-1*P_000120002*R_010[0]+P_000120102*R_011[0]+-1*P_000120202*R_012[0]+P_000220002*R_020[0]+-1*P_000220102*R_021[0]+P_000220202*R_022[0]; double PR_012000010000=P_012000010*R_000[0]+-1*P_012000110*R_001[0]+-1*P_112000010*R_100[0]+P_112000110*R_101[0]+P_212000010*R_200[0]+-1*P_212000110*R_201[0]+-1*P_312000010*R_300[0]+P_312000110*R_301[0]; double PR_011001010000=P_011001010*R_000[0]+-1*P_011001110*R_001[0]+-1*P_011101010*R_010[0]+P_011101110*R_011[0]+-1*P_111001010*R_100[0]+P_111001110*R_101[0]+P_111101010*R_110[0]+-1*P_111101110*R_111[0]+P_211001010*R_200[0]+-1*P_211001110*R_201[0]+-1*P_211101010*R_210[0]+P_211101110*R_211[0]; double PR_010002010000=P_010002010*R_000[0]+-1*P_010002110*R_001[0]+-1*P_010102010*R_010[0]+P_010102110*R_011[0]+P_010202010*R_020[0]+-1*P_010202110*R_021[0]+-1*P_110002010*R_100[0]+P_110002110*R_101[0]+P_110102010*R_110[0]+-1*P_110102110*R_111[0]+-1*P_110202010*R_120[0]+P_110202110*R_121[0]; double PR_011000011000=P_011000011*R_000[0]+-1*P_011000111*R_001[0]+P_011000211*R_002[0]+-1*P_111000011*R_100[0]+P_111000111*R_101[0]+-1*P_111000211*R_102[0]+P_211000011*R_200[0]+-1*P_211000111*R_201[0]+P_211000211*R_202[0]; double PR_010001011000=P_010001011*R_000[0]+-1*P_010001111*R_001[0]+P_010001211*R_002[0]+-1*P_010101011*R_010[0]+P_010101111*R_011[0]+-1*P_010101211*R_012[0]+-1*P_110001011*R_100[0]+P_110001111*R_101[0]+-1*P_110001211*R_102[0]+P_110101011*R_110[0]+-1*P_110101111*R_111[0]+P_110101211*R_112[0]; double PR_010000012000=P_010000012*R_000[0]+-1*P_010000112*R_001[0]+P_010000212*R_002[0]+-1*P_010000312*R_003[0]+-1*P_110000012*R_100[0]+P_110000112*R_101[0]+-1*P_110000212*R_102[0]+P_110000312*R_103[0]; double PR_002010010000=P_002010010*R_000[0]+-1*P_002010110*R_001[0]+-1*P_002110010*R_010[0]+P_002110110*R_011[0]+-1*P_102010010*R_100[0]+P_102010110*R_101[0]+P_102110010*R_110[0]+-1*P_102110110*R_111[0]+P_202010010*R_200[0]+-1*P_202010110*R_201[0]+-1*P_202110010*R_210[0]+P_202110110*R_211[0]; double PR_001011010000=P_001011010*R_000[0]+-1*P_001011110*R_001[0]+-1*P_001111010*R_010[0]+P_001111110*R_011[0]+P_001211010*R_020[0]+-1*P_001211110*R_021[0]+-1*P_101011010*R_100[0]+P_101011110*R_101[0]+P_101111010*R_110[0]+-1*P_101111110*R_111[0]+-1*P_101211010*R_120[0]+P_101211110*R_121[0]; double PR_000012010000=P_000012010*R_000[0]+-1*P_000012110*R_001[0]+-1*P_000112010*R_010[0]+P_000112110*R_011[0]+P_000212010*R_020[0]+-1*P_000212110*R_021[0]+-1*P_000312010*R_030[0]+P_000312110*R_031[0]; double PR_001010011000=P_001010011*R_000[0]+-1*P_001010111*R_001[0]+P_001010211*R_002[0]+-1*P_001110011*R_010[0]+P_001110111*R_011[0]+-1*P_001110211*R_012[0]+-1*P_101010011*R_100[0]+P_101010111*R_101[0]+-1*P_101010211*R_102[0]+P_101110011*R_110[0]+-1*P_101110111*R_111[0]+P_101110211*R_112[0]; double PR_000011011000=P_000011011*R_000[0]+-1*P_000011111*R_001[0]+P_000011211*R_002[0]+-1*P_000111011*R_010[0]+P_000111111*R_011[0]+-1*P_000111211*R_012[0]+P_000211011*R_020[0]+-1*P_000211111*R_021[0]+P_000211211*R_022[0]; double PR_000010012000=P_000010012*R_000[0]+-1*P_000010112*R_001[0]+P_000010212*R_002[0]+-1*P_000010312*R_003[0]+-1*P_000110012*R_010[0]+P_000110112*R_011[0]+-1*P_000110212*R_012[0]+P_000110312*R_013[0]; double PR_002000020000=P_002000020*R_000[0]+-1*P_002000120*R_001[0]+P_002000220*R_002[0]+-1*P_102000020*R_100[0]+P_102000120*R_101[0]+-1*P_102000220*R_102[0]+P_202000020*R_200[0]+-1*P_202000120*R_201[0]+P_202000220*R_202[0]; double PR_001001020000=P_001001020*R_000[0]+-1*P_001001120*R_001[0]+P_001001220*R_002[0]+-1*P_001101020*R_010[0]+P_001101120*R_011[0]+-1*P_001101220*R_012[0]+-1*P_101001020*R_100[0]+P_101001120*R_101[0]+-1*P_101001220*R_102[0]+P_101101020*R_110[0]+-1*P_101101120*R_111[0]+P_101101220*R_112[0]; double PR_000002020000=P_000002020*R_000[0]+-1*P_000002120*R_001[0]+P_000002220*R_002[0]+-1*P_000102020*R_010[0]+P_000102120*R_011[0]+-1*P_000102220*R_012[0]+P_000202020*R_020[0]+-1*P_000202120*R_021[0]+P_000202220*R_022[0]; double PR_001000021000=P_001000021*R_000[0]+-1*P_001000121*R_001[0]+P_001000221*R_002[0]+-1*P_001000321*R_003[0]+-1*P_101000021*R_100[0]+P_101000121*R_101[0]+-1*P_101000221*R_102[0]+P_101000321*R_103[0]; double PR_000001021000=P_000001021*R_000[0]+-1*P_000001121*R_001[0]+P_000001221*R_002[0]+-1*P_000001321*R_003[0]+-1*P_000101021*R_010[0]+P_000101121*R_011[0]+-1*P_000101221*R_012[0]+P_000101321*R_013[0]; double PR_000000022000=P_000000022*R_000[0]+-1*P_000000122*R_001[0]+P_000000222*R_002[0]+-1*P_000000322*R_003[0]+P_000000422*R_004[0]; double PR_022000000001=P_022000000*R_001[0]+-1*P_122000000*R_101[0]+P_222000000*R_201[0]+-1*P_322000000*R_301[0]+P_422000000*R_401[0]; double PR_021001000001=P_021001000*R_001[0]+-1*P_021101000*R_011[0]+-1*P_121001000*R_101[0]+P_121101000*R_111[0]+P_221001000*R_201[0]+-1*P_221101000*R_211[0]+-1*P_321001000*R_301[0]+P_321101000*R_311[0]; double PR_020002000001=P_020002000*R_001[0]+-1*P_020102000*R_011[0]+P_020202000*R_021[0]+-1*P_120002000*R_101[0]+P_120102000*R_111[0]+-1*P_120202000*R_121[0]+P_220002000*R_201[0]+-1*P_220102000*R_211[0]+P_220202000*R_221[0]; double PR_021000001001=P_021000001*R_001[0]+-1*P_021000101*R_002[0]+-1*P_121000001*R_101[0]+P_121000101*R_102[0]+P_221000001*R_201[0]+-1*P_221000101*R_202[0]+-1*P_321000001*R_301[0]+P_321000101*R_302[0]; double PR_020001001001=P_020001001*R_001[0]+-1*P_020001101*R_002[0]+-1*P_020101001*R_011[0]+P_020101101*R_012[0]+-1*P_120001001*R_101[0]+P_120001101*R_102[0]+P_120101001*R_111[0]+-1*P_120101101*R_112[0]+P_220001001*R_201[0]+-1*P_220001101*R_202[0]+-1*P_220101001*R_211[0]+P_220101101*R_212[0]; double PR_020000002001=P_020000002*R_001[0]+-1*P_020000102*R_002[0]+P_020000202*R_003[0]+-1*P_120000002*R_101[0]+P_120000102*R_102[0]+-1*P_120000202*R_103[0]+P_220000002*R_201[0]+-1*P_220000102*R_202[0]+P_220000202*R_203[0]; double PR_012010000001=P_012010000*R_001[0]+-1*P_012110000*R_011[0]+-1*P_112010000*R_101[0]+P_112110000*R_111[0]+P_212010000*R_201[0]+-1*P_212110000*R_211[0]+-1*P_312010000*R_301[0]+P_312110000*R_311[0]; double PR_011011000001=P_011011000*R_001[0]+-1*P_011111000*R_011[0]+P_011211000*R_021[0]+-1*P_111011000*R_101[0]+P_111111000*R_111[0]+-1*P_111211000*R_121[0]+P_211011000*R_201[0]+-1*P_211111000*R_211[0]+P_211211000*R_221[0]; double PR_010012000001=P_010012000*R_001[0]+-1*P_010112000*R_011[0]+P_010212000*R_021[0]+-1*P_010312000*R_031[0]+-1*P_110012000*R_101[0]+P_110112000*R_111[0]+-1*P_110212000*R_121[0]+P_110312000*R_131[0]; double PR_011010001001=P_011010001*R_001[0]+-1*P_011010101*R_002[0]+-1*P_011110001*R_011[0]+P_011110101*R_012[0]+-1*P_111010001*R_101[0]+P_111010101*R_102[0]+P_111110001*R_111[0]+-1*P_111110101*R_112[0]+P_211010001*R_201[0]+-1*P_211010101*R_202[0]+-1*P_211110001*R_211[0]+P_211110101*R_212[0]; double PR_010011001001=P_010011001*R_001[0]+-1*P_010011101*R_002[0]+-1*P_010111001*R_011[0]+P_010111101*R_012[0]+P_010211001*R_021[0]+-1*P_010211101*R_022[0]+-1*P_110011001*R_101[0]+P_110011101*R_102[0]+P_110111001*R_111[0]+-1*P_110111101*R_112[0]+-1*P_110211001*R_121[0]+P_110211101*R_122[0]; double PR_010010002001=P_010010002*R_001[0]+-1*P_010010102*R_002[0]+P_010010202*R_003[0]+-1*P_010110002*R_011[0]+P_010110102*R_012[0]+-1*P_010110202*R_013[0]+-1*P_110010002*R_101[0]+P_110010102*R_102[0]+-1*P_110010202*R_103[0]+P_110110002*R_111[0]+-1*P_110110102*R_112[0]+P_110110202*R_113[0]; double PR_002020000001=P_002020000*R_001[0]+-1*P_002120000*R_011[0]+P_002220000*R_021[0]+-1*P_102020000*R_101[0]+P_102120000*R_111[0]+-1*P_102220000*R_121[0]+P_202020000*R_201[0]+-1*P_202120000*R_211[0]+P_202220000*R_221[0]; double PR_001021000001=P_001021000*R_001[0]+-1*P_001121000*R_011[0]+P_001221000*R_021[0]+-1*P_001321000*R_031[0]+-1*P_101021000*R_101[0]+P_101121000*R_111[0]+-1*P_101221000*R_121[0]+P_101321000*R_131[0]; double PR_000022000001=P_000022000*R_001[0]+-1*P_000122000*R_011[0]+P_000222000*R_021[0]+-1*P_000322000*R_031[0]+P_000422000*R_041[0]; double PR_001020001001=P_001020001*R_001[0]+-1*P_001020101*R_002[0]+-1*P_001120001*R_011[0]+P_001120101*R_012[0]+P_001220001*R_021[0]+-1*P_001220101*R_022[0]+-1*P_101020001*R_101[0]+P_101020101*R_102[0]+P_101120001*R_111[0]+-1*P_101120101*R_112[0]+-1*P_101220001*R_121[0]+P_101220101*R_122[0]; double PR_000021001001=P_000021001*R_001[0]+-1*P_000021101*R_002[0]+-1*P_000121001*R_011[0]+P_000121101*R_012[0]+P_000221001*R_021[0]+-1*P_000221101*R_022[0]+-1*P_000321001*R_031[0]+P_000321101*R_032[0]; double PR_000020002001=P_000020002*R_001[0]+-1*P_000020102*R_002[0]+P_000020202*R_003[0]+-1*P_000120002*R_011[0]+P_000120102*R_012[0]+-1*P_000120202*R_013[0]+P_000220002*R_021[0]+-1*P_000220102*R_022[0]+P_000220202*R_023[0]; double PR_012000010001=P_012000010*R_001[0]+-1*P_012000110*R_002[0]+-1*P_112000010*R_101[0]+P_112000110*R_102[0]+P_212000010*R_201[0]+-1*P_212000110*R_202[0]+-1*P_312000010*R_301[0]+P_312000110*R_302[0]; double PR_011001010001=P_011001010*R_001[0]+-1*P_011001110*R_002[0]+-1*P_011101010*R_011[0]+P_011101110*R_012[0]+-1*P_111001010*R_101[0]+P_111001110*R_102[0]+P_111101010*R_111[0]+-1*P_111101110*R_112[0]+P_211001010*R_201[0]+-1*P_211001110*R_202[0]+-1*P_211101010*R_211[0]+P_211101110*R_212[0]; double PR_010002010001=P_010002010*R_001[0]+-1*P_010002110*R_002[0]+-1*P_010102010*R_011[0]+P_010102110*R_012[0]+P_010202010*R_021[0]+-1*P_010202110*R_022[0]+-1*P_110002010*R_101[0]+P_110002110*R_102[0]+P_110102010*R_111[0]+-1*P_110102110*R_112[0]+-1*P_110202010*R_121[0]+P_110202110*R_122[0]; double PR_011000011001=P_011000011*R_001[0]+-1*P_011000111*R_002[0]+P_011000211*R_003[0]+-1*P_111000011*R_101[0]+P_111000111*R_102[0]+-1*P_111000211*R_103[0]+P_211000011*R_201[0]+-1*P_211000111*R_202[0]+P_211000211*R_203[0]; double PR_010001011001=P_010001011*R_001[0]+-1*P_010001111*R_002[0]+P_010001211*R_003[0]+-1*P_010101011*R_011[0]+P_010101111*R_012[0]+-1*P_010101211*R_013[0]+-1*P_110001011*R_101[0]+P_110001111*R_102[0]+-1*P_110001211*R_103[0]+P_110101011*R_111[0]+-1*P_110101111*R_112[0]+P_110101211*R_113[0]; double PR_010000012001=P_010000012*R_001[0]+-1*P_010000112*R_002[0]+P_010000212*R_003[0]+-1*P_010000312*R_004[0]+-1*P_110000012*R_101[0]+P_110000112*R_102[0]+-1*P_110000212*R_103[0]+P_110000312*R_104[0]; double PR_002010010001=P_002010010*R_001[0]+-1*P_002010110*R_002[0]+-1*P_002110010*R_011[0]+P_002110110*R_012[0]+-1*P_102010010*R_101[0]+P_102010110*R_102[0]+P_102110010*R_111[0]+-1*P_102110110*R_112[0]+P_202010010*R_201[0]+-1*P_202010110*R_202[0]+-1*P_202110010*R_211[0]+P_202110110*R_212[0]; double PR_001011010001=P_001011010*R_001[0]+-1*P_001011110*R_002[0]+-1*P_001111010*R_011[0]+P_001111110*R_012[0]+P_001211010*R_021[0]+-1*P_001211110*R_022[0]+-1*P_101011010*R_101[0]+P_101011110*R_102[0]+P_101111010*R_111[0]+-1*P_101111110*R_112[0]+-1*P_101211010*R_121[0]+P_101211110*R_122[0]; double PR_000012010001=P_000012010*R_001[0]+-1*P_000012110*R_002[0]+-1*P_000112010*R_011[0]+P_000112110*R_012[0]+P_000212010*R_021[0]+-1*P_000212110*R_022[0]+-1*P_000312010*R_031[0]+P_000312110*R_032[0]; double PR_001010011001=P_001010011*R_001[0]+-1*P_001010111*R_002[0]+P_001010211*R_003[0]+-1*P_001110011*R_011[0]+P_001110111*R_012[0]+-1*P_001110211*R_013[0]+-1*P_101010011*R_101[0]+P_101010111*R_102[0]+-1*P_101010211*R_103[0]+P_101110011*R_111[0]+-1*P_101110111*R_112[0]+P_101110211*R_113[0]; double PR_000011011001=P_000011011*R_001[0]+-1*P_000011111*R_002[0]+P_000011211*R_003[0]+-1*P_000111011*R_011[0]+P_000111111*R_012[0]+-1*P_000111211*R_013[0]+P_000211011*R_021[0]+-1*P_000211111*R_022[0]+P_000211211*R_023[0]; double PR_000010012001=P_000010012*R_001[0]+-1*P_000010112*R_002[0]+P_000010212*R_003[0]+-1*P_000010312*R_004[0]+-1*P_000110012*R_011[0]+P_000110112*R_012[0]+-1*P_000110212*R_013[0]+P_000110312*R_014[0]; double PR_002000020001=P_002000020*R_001[0]+-1*P_002000120*R_002[0]+P_002000220*R_003[0]+-1*P_102000020*R_101[0]+P_102000120*R_102[0]+-1*P_102000220*R_103[0]+P_202000020*R_201[0]+-1*P_202000120*R_202[0]+P_202000220*R_203[0]; double PR_001001020001=P_001001020*R_001[0]+-1*P_001001120*R_002[0]+P_001001220*R_003[0]+-1*P_001101020*R_011[0]+P_001101120*R_012[0]+-1*P_001101220*R_013[0]+-1*P_101001020*R_101[0]+P_101001120*R_102[0]+-1*P_101001220*R_103[0]+P_101101020*R_111[0]+-1*P_101101120*R_112[0]+P_101101220*R_113[0]; double PR_000002020001=P_000002020*R_001[0]+-1*P_000002120*R_002[0]+P_000002220*R_003[0]+-1*P_000102020*R_011[0]+P_000102120*R_012[0]+-1*P_000102220*R_013[0]+P_000202020*R_021[0]+-1*P_000202120*R_022[0]+P_000202220*R_023[0]; double PR_001000021001=P_001000021*R_001[0]+-1*P_001000121*R_002[0]+P_001000221*R_003[0]+-1*P_001000321*R_004[0]+-1*P_101000021*R_101[0]+P_101000121*R_102[0]+-1*P_101000221*R_103[0]+P_101000321*R_104[0]; double PR_000001021001=P_000001021*R_001[0]+-1*P_000001121*R_002[0]+P_000001221*R_003[0]+-1*P_000001321*R_004[0]+-1*P_000101021*R_011[0]+P_000101121*R_012[0]+-1*P_000101221*R_013[0]+P_000101321*R_014[0]; double PR_000000022001=P_000000022*R_001[0]+-1*P_000000122*R_002[0]+P_000000222*R_003[0]+-1*P_000000322*R_004[0]+P_000000422*R_005[0]; double PR_022000000010=P_022000000*R_010[0]+-1*P_122000000*R_110[0]+P_222000000*R_210[0]+-1*P_322000000*R_310[0]+P_422000000*R_410[0]; double PR_021001000010=P_021001000*R_010[0]+-1*P_021101000*R_020[0]+-1*P_121001000*R_110[0]+P_121101000*R_120[0]+P_221001000*R_210[0]+-1*P_221101000*R_220[0]+-1*P_321001000*R_310[0]+P_321101000*R_320[0]; double PR_020002000010=P_020002000*R_010[0]+-1*P_020102000*R_020[0]+P_020202000*R_030[0]+-1*P_120002000*R_110[0]+P_120102000*R_120[0]+-1*P_120202000*R_130[0]+P_220002000*R_210[0]+-1*P_220102000*R_220[0]+P_220202000*R_230[0]; double PR_021000001010=P_021000001*R_010[0]+-1*P_021000101*R_011[0]+-1*P_121000001*R_110[0]+P_121000101*R_111[0]+P_221000001*R_210[0]+-1*P_221000101*R_211[0]+-1*P_321000001*R_310[0]+P_321000101*R_311[0]; double PR_020001001010=P_020001001*R_010[0]+-1*P_020001101*R_011[0]+-1*P_020101001*R_020[0]+P_020101101*R_021[0]+-1*P_120001001*R_110[0]+P_120001101*R_111[0]+P_120101001*R_120[0]+-1*P_120101101*R_121[0]+P_220001001*R_210[0]+-1*P_220001101*R_211[0]+-1*P_220101001*R_220[0]+P_220101101*R_221[0]; double PR_020000002010=P_020000002*R_010[0]+-1*P_020000102*R_011[0]+P_020000202*R_012[0]+-1*P_120000002*R_110[0]+P_120000102*R_111[0]+-1*P_120000202*R_112[0]+P_220000002*R_210[0]+-1*P_220000102*R_211[0]+P_220000202*R_212[0]; double PR_012010000010=P_012010000*R_010[0]+-1*P_012110000*R_020[0]+-1*P_112010000*R_110[0]+P_112110000*R_120[0]+P_212010000*R_210[0]+-1*P_212110000*R_220[0]+-1*P_312010000*R_310[0]+P_312110000*R_320[0]; double PR_011011000010=P_011011000*R_010[0]+-1*P_011111000*R_020[0]+P_011211000*R_030[0]+-1*P_111011000*R_110[0]+P_111111000*R_120[0]+-1*P_111211000*R_130[0]+P_211011000*R_210[0]+-1*P_211111000*R_220[0]+P_211211000*R_230[0]; double PR_010012000010=P_010012000*R_010[0]+-1*P_010112000*R_020[0]+P_010212000*R_030[0]+-1*P_010312000*R_040[0]+-1*P_110012000*R_110[0]+P_110112000*R_120[0]+-1*P_110212000*R_130[0]+P_110312000*R_140[0]; double PR_011010001010=P_011010001*R_010[0]+-1*P_011010101*R_011[0]+-1*P_011110001*R_020[0]+P_011110101*R_021[0]+-1*P_111010001*R_110[0]+P_111010101*R_111[0]+P_111110001*R_120[0]+-1*P_111110101*R_121[0]+P_211010001*R_210[0]+-1*P_211010101*R_211[0]+-1*P_211110001*R_220[0]+P_211110101*R_221[0]; double PR_010011001010=P_010011001*R_010[0]+-1*P_010011101*R_011[0]+-1*P_010111001*R_020[0]+P_010111101*R_021[0]+P_010211001*R_030[0]+-1*P_010211101*R_031[0]+-1*P_110011001*R_110[0]+P_110011101*R_111[0]+P_110111001*R_120[0]+-1*P_110111101*R_121[0]+-1*P_110211001*R_130[0]+P_110211101*R_131[0]; double PR_010010002010=P_010010002*R_010[0]+-1*P_010010102*R_011[0]+P_010010202*R_012[0]+-1*P_010110002*R_020[0]+P_010110102*R_021[0]+-1*P_010110202*R_022[0]+-1*P_110010002*R_110[0]+P_110010102*R_111[0]+-1*P_110010202*R_112[0]+P_110110002*R_120[0]+-1*P_110110102*R_121[0]+P_110110202*R_122[0]; double PR_002020000010=P_002020000*R_010[0]+-1*P_002120000*R_020[0]+P_002220000*R_030[0]+-1*P_102020000*R_110[0]+P_102120000*R_120[0]+-1*P_102220000*R_130[0]+P_202020000*R_210[0]+-1*P_202120000*R_220[0]+P_202220000*R_230[0]; double PR_001021000010=P_001021000*R_010[0]+-1*P_001121000*R_020[0]+P_001221000*R_030[0]+-1*P_001321000*R_040[0]+-1*P_101021000*R_110[0]+P_101121000*R_120[0]+-1*P_101221000*R_130[0]+P_101321000*R_140[0]; double PR_000022000010=P_000022000*R_010[0]+-1*P_000122000*R_020[0]+P_000222000*R_030[0]+-1*P_000322000*R_040[0]+P_000422000*R_050[0]; double PR_001020001010=P_001020001*R_010[0]+-1*P_001020101*R_011[0]+-1*P_001120001*R_020[0]+P_001120101*R_021[0]+P_001220001*R_030[0]+-1*P_001220101*R_031[0]+-1*P_101020001*R_110[0]+P_101020101*R_111[0]+P_101120001*R_120[0]+-1*P_101120101*R_121[0]+-1*P_101220001*R_130[0]+P_101220101*R_131[0]; double PR_000021001010=P_000021001*R_010[0]+-1*P_000021101*R_011[0]+-1*P_000121001*R_020[0]+P_000121101*R_021[0]+P_000221001*R_030[0]+-1*P_000221101*R_031[0]+-1*P_000321001*R_040[0]+P_000321101*R_041[0]; double PR_000020002010=P_000020002*R_010[0]+-1*P_000020102*R_011[0]+P_000020202*R_012[0]+-1*P_000120002*R_020[0]+P_000120102*R_021[0]+-1*P_000120202*R_022[0]+P_000220002*R_030[0]+-1*P_000220102*R_031[0]+P_000220202*R_032[0]; double PR_012000010010=P_012000010*R_010[0]+-1*P_012000110*R_011[0]+-1*P_112000010*R_110[0]+P_112000110*R_111[0]+P_212000010*R_210[0]+-1*P_212000110*R_211[0]+-1*P_312000010*R_310[0]+P_312000110*R_311[0]; double PR_011001010010=P_011001010*R_010[0]+-1*P_011001110*R_011[0]+-1*P_011101010*R_020[0]+P_011101110*R_021[0]+-1*P_111001010*R_110[0]+P_111001110*R_111[0]+P_111101010*R_120[0]+-1*P_111101110*R_121[0]+P_211001010*R_210[0]+-1*P_211001110*R_211[0]+-1*P_211101010*R_220[0]+P_211101110*R_221[0]; double PR_010002010010=P_010002010*R_010[0]+-1*P_010002110*R_011[0]+-1*P_010102010*R_020[0]+P_010102110*R_021[0]+P_010202010*R_030[0]+-1*P_010202110*R_031[0]+-1*P_110002010*R_110[0]+P_110002110*R_111[0]+P_110102010*R_120[0]+-1*P_110102110*R_121[0]+-1*P_110202010*R_130[0]+P_110202110*R_131[0]; double PR_011000011010=P_011000011*R_010[0]+-1*P_011000111*R_011[0]+P_011000211*R_012[0]+-1*P_111000011*R_110[0]+P_111000111*R_111[0]+-1*P_111000211*R_112[0]+P_211000011*R_210[0]+-1*P_211000111*R_211[0]+P_211000211*R_212[0]; double PR_010001011010=P_010001011*R_010[0]+-1*P_010001111*R_011[0]+P_010001211*R_012[0]+-1*P_010101011*R_020[0]+P_010101111*R_021[0]+-1*P_010101211*R_022[0]+-1*P_110001011*R_110[0]+P_110001111*R_111[0]+-1*P_110001211*R_112[0]+P_110101011*R_120[0]+-1*P_110101111*R_121[0]+P_110101211*R_122[0]; double PR_010000012010=P_010000012*R_010[0]+-1*P_010000112*R_011[0]+P_010000212*R_012[0]+-1*P_010000312*R_013[0]+-1*P_110000012*R_110[0]+P_110000112*R_111[0]+-1*P_110000212*R_112[0]+P_110000312*R_113[0]; double PR_002010010010=P_002010010*R_010[0]+-1*P_002010110*R_011[0]+-1*P_002110010*R_020[0]+P_002110110*R_021[0]+-1*P_102010010*R_110[0]+P_102010110*R_111[0]+P_102110010*R_120[0]+-1*P_102110110*R_121[0]+P_202010010*R_210[0]+-1*P_202010110*R_211[0]+-1*P_202110010*R_220[0]+P_202110110*R_221[0]; double PR_001011010010=P_001011010*R_010[0]+-1*P_001011110*R_011[0]+-1*P_001111010*R_020[0]+P_001111110*R_021[0]+P_001211010*R_030[0]+-1*P_001211110*R_031[0]+-1*P_101011010*R_110[0]+P_101011110*R_111[0]+P_101111010*R_120[0]+-1*P_101111110*R_121[0]+-1*P_101211010*R_130[0]+P_101211110*R_131[0]; double PR_000012010010=P_000012010*R_010[0]+-1*P_000012110*R_011[0]+-1*P_000112010*R_020[0]+P_000112110*R_021[0]+P_000212010*R_030[0]+-1*P_000212110*R_031[0]+-1*P_000312010*R_040[0]+P_000312110*R_041[0]; double PR_001010011010=P_001010011*R_010[0]+-1*P_001010111*R_011[0]+P_001010211*R_012[0]+-1*P_001110011*R_020[0]+P_001110111*R_021[0]+-1*P_001110211*R_022[0]+-1*P_101010011*R_110[0]+P_101010111*R_111[0]+-1*P_101010211*R_112[0]+P_101110011*R_120[0]+-1*P_101110111*R_121[0]+P_101110211*R_122[0]; double PR_000011011010=P_000011011*R_010[0]+-1*P_000011111*R_011[0]+P_000011211*R_012[0]+-1*P_000111011*R_020[0]+P_000111111*R_021[0]+-1*P_000111211*R_022[0]+P_000211011*R_030[0]+-1*P_000211111*R_031[0]+P_000211211*R_032[0]; double PR_000010012010=P_000010012*R_010[0]+-1*P_000010112*R_011[0]+P_000010212*R_012[0]+-1*P_000010312*R_013[0]+-1*P_000110012*R_020[0]+P_000110112*R_021[0]+-1*P_000110212*R_022[0]+P_000110312*R_023[0]; double PR_002000020010=P_002000020*R_010[0]+-1*P_002000120*R_011[0]+P_002000220*R_012[0]+-1*P_102000020*R_110[0]+P_102000120*R_111[0]+-1*P_102000220*R_112[0]+P_202000020*R_210[0]+-1*P_202000120*R_211[0]+P_202000220*R_212[0]; double PR_001001020010=P_001001020*R_010[0]+-1*P_001001120*R_011[0]+P_001001220*R_012[0]+-1*P_001101020*R_020[0]+P_001101120*R_021[0]+-1*P_001101220*R_022[0]+-1*P_101001020*R_110[0]+P_101001120*R_111[0]+-1*P_101001220*R_112[0]+P_101101020*R_120[0]+-1*P_101101120*R_121[0]+P_101101220*R_122[0]; double PR_000002020010=P_000002020*R_010[0]+-1*P_000002120*R_011[0]+P_000002220*R_012[0]+-1*P_000102020*R_020[0]+P_000102120*R_021[0]+-1*P_000102220*R_022[0]+P_000202020*R_030[0]+-1*P_000202120*R_031[0]+P_000202220*R_032[0]; double PR_001000021010=P_001000021*R_010[0]+-1*P_001000121*R_011[0]+P_001000221*R_012[0]+-1*P_001000321*R_013[0]+-1*P_101000021*R_110[0]+P_101000121*R_111[0]+-1*P_101000221*R_112[0]+P_101000321*R_113[0]; double PR_000001021010=P_000001021*R_010[0]+-1*P_000001121*R_011[0]+P_000001221*R_012[0]+-1*P_000001321*R_013[0]+-1*P_000101021*R_020[0]+P_000101121*R_021[0]+-1*P_000101221*R_022[0]+P_000101321*R_023[0]; double PR_000000022010=P_000000022*R_010[0]+-1*P_000000122*R_011[0]+P_000000222*R_012[0]+-1*P_000000322*R_013[0]+P_000000422*R_014[0]; double PR_022000000100=P_022000000*R_100[0]+-1*P_122000000*R_200[0]+P_222000000*R_300[0]+-1*P_322000000*R_400[0]+P_422000000*R_500[0]; double PR_021001000100=P_021001000*R_100[0]+-1*P_021101000*R_110[0]+-1*P_121001000*R_200[0]+P_121101000*R_210[0]+P_221001000*R_300[0]+-1*P_221101000*R_310[0]+-1*P_321001000*R_400[0]+P_321101000*R_410[0]; double PR_020002000100=P_020002000*R_100[0]+-1*P_020102000*R_110[0]+P_020202000*R_120[0]+-1*P_120002000*R_200[0]+P_120102000*R_210[0]+-1*P_120202000*R_220[0]+P_220002000*R_300[0]+-1*P_220102000*R_310[0]+P_220202000*R_320[0]; double PR_021000001100=P_021000001*R_100[0]+-1*P_021000101*R_101[0]+-1*P_121000001*R_200[0]+P_121000101*R_201[0]+P_221000001*R_300[0]+-1*P_221000101*R_301[0]+-1*P_321000001*R_400[0]+P_321000101*R_401[0]; double PR_020001001100=P_020001001*R_100[0]+-1*P_020001101*R_101[0]+-1*P_020101001*R_110[0]+P_020101101*R_111[0]+-1*P_120001001*R_200[0]+P_120001101*R_201[0]+P_120101001*R_210[0]+-1*P_120101101*R_211[0]+P_220001001*R_300[0]+-1*P_220001101*R_301[0]+-1*P_220101001*R_310[0]+P_220101101*R_311[0]; double PR_020000002100=P_020000002*R_100[0]+-1*P_020000102*R_101[0]+P_020000202*R_102[0]+-1*P_120000002*R_200[0]+P_120000102*R_201[0]+-1*P_120000202*R_202[0]+P_220000002*R_300[0]+-1*P_220000102*R_301[0]+P_220000202*R_302[0]; double PR_012010000100=P_012010000*R_100[0]+-1*P_012110000*R_110[0]+-1*P_112010000*R_200[0]+P_112110000*R_210[0]+P_212010000*R_300[0]+-1*P_212110000*R_310[0]+-1*P_312010000*R_400[0]+P_312110000*R_410[0]; double PR_011011000100=P_011011000*R_100[0]+-1*P_011111000*R_110[0]+P_011211000*R_120[0]+-1*P_111011000*R_200[0]+P_111111000*R_210[0]+-1*P_111211000*R_220[0]+P_211011000*R_300[0]+-1*P_211111000*R_310[0]+P_211211000*R_320[0]; double PR_010012000100=P_010012000*R_100[0]+-1*P_010112000*R_110[0]+P_010212000*R_120[0]+-1*P_010312000*R_130[0]+-1*P_110012000*R_200[0]+P_110112000*R_210[0]+-1*P_110212000*R_220[0]+P_110312000*R_230[0]; double PR_011010001100=P_011010001*R_100[0]+-1*P_011010101*R_101[0]+-1*P_011110001*R_110[0]+P_011110101*R_111[0]+-1*P_111010001*R_200[0]+P_111010101*R_201[0]+P_111110001*R_210[0]+-1*P_111110101*R_211[0]+P_211010001*R_300[0]+-1*P_211010101*R_301[0]+-1*P_211110001*R_310[0]+P_211110101*R_311[0]; double PR_010011001100=P_010011001*R_100[0]+-1*P_010011101*R_101[0]+-1*P_010111001*R_110[0]+P_010111101*R_111[0]+P_010211001*R_120[0]+-1*P_010211101*R_121[0]+-1*P_110011001*R_200[0]+P_110011101*R_201[0]+P_110111001*R_210[0]+-1*P_110111101*R_211[0]+-1*P_110211001*R_220[0]+P_110211101*R_221[0]; double PR_010010002100=P_010010002*R_100[0]+-1*P_010010102*R_101[0]+P_010010202*R_102[0]+-1*P_010110002*R_110[0]+P_010110102*R_111[0]+-1*P_010110202*R_112[0]+-1*P_110010002*R_200[0]+P_110010102*R_201[0]+-1*P_110010202*R_202[0]+P_110110002*R_210[0]+-1*P_110110102*R_211[0]+P_110110202*R_212[0]; double PR_002020000100=P_002020000*R_100[0]+-1*P_002120000*R_110[0]+P_002220000*R_120[0]+-1*P_102020000*R_200[0]+P_102120000*R_210[0]+-1*P_102220000*R_220[0]+P_202020000*R_300[0]+-1*P_202120000*R_310[0]+P_202220000*R_320[0]; double PR_001021000100=P_001021000*R_100[0]+-1*P_001121000*R_110[0]+P_001221000*R_120[0]+-1*P_001321000*R_130[0]+-1*P_101021000*R_200[0]+P_101121000*R_210[0]+-1*P_101221000*R_220[0]+P_101321000*R_230[0]; double PR_000022000100=P_000022000*R_100[0]+-1*P_000122000*R_110[0]+P_000222000*R_120[0]+-1*P_000322000*R_130[0]+P_000422000*R_140[0]; double PR_001020001100=P_001020001*R_100[0]+-1*P_001020101*R_101[0]+-1*P_001120001*R_110[0]+P_001120101*R_111[0]+P_001220001*R_120[0]+-1*P_001220101*R_121[0]+-1*P_101020001*R_200[0]+P_101020101*R_201[0]+P_101120001*R_210[0]+-1*P_101120101*R_211[0]+-1*P_101220001*R_220[0]+P_101220101*R_221[0]; double PR_000021001100=P_000021001*R_100[0]+-1*P_000021101*R_101[0]+-1*P_000121001*R_110[0]+P_000121101*R_111[0]+P_000221001*R_120[0]+-1*P_000221101*R_121[0]+-1*P_000321001*R_130[0]+P_000321101*R_131[0]; double PR_000020002100=P_000020002*R_100[0]+-1*P_000020102*R_101[0]+P_000020202*R_102[0]+-1*P_000120002*R_110[0]+P_000120102*R_111[0]+-1*P_000120202*R_112[0]+P_000220002*R_120[0]+-1*P_000220102*R_121[0]+P_000220202*R_122[0]; double PR_012000010100=P_012000010*R_100[0]+-1*P_012000110*R_101[0]+-1*P_112000010*R_200[0]+P_112000110*R_201[0]+P_212000010*R_300[0]+-1*P_212000110*R_301[0]+-1*P_312000010*R_400[0]+P_312000110*R_401[0]; double PR_011001010100=P_011001010*R_100[0]+-1*P_011001110*R_101[0]+-1*P_011101010*R_110[0]+P_011101110*R_111[0]+-1*P_111001010*R_200[0]+P_111001110*R_201[0]+P_111101010*R_210[0]+-1*P_111101110*R_211[0]+P_211001010*R_300[0]+-1*P_211001110*R_301[0]+-1*P_211101010*R_310[0]+P_211101110*R_311[0]; double PR_010002010100=P_010002010*R_100[0]+-1*P_010002110*R_101[0]+-1*P_010102010*R_110[0]+P_010102110*R_111[0]+P_010202010*R_120[0]+-1*P_010202110*R_121[0]+-1*P_110002010*R_200[0]+P_110002110*R_201[0]+P_110102010*R_210[0]+-1*P_110102110*R_211[0]+-1*P_110202010*R_220[0]+P_110202110*R_221[0]; double PR_011000011100=P_011000011*R_100[0]+-1*P_011000111*R_101[0]+P_011000211*R_102[0]+-1*P_111000011*R_200[0]+P_111000111*R_201[0]+-1*P_111000211*R_202[0]+P_211000011*R_300[0]+-1*P_211000111*R_301[0]+P_211000211*R_302[0]; double PR_010001011100=P_010001011*R_100[0]+-1*P_010001111*R_101[0]+P_010001211*R_102[0]+-1*P_010101011*R_110[0]+P_010101111*R_111[0]+-1*P_010101211*R_112[0]+-1*P_110001011*R_200[0]+P_110001111*R_201[0]+-1*P_110001211*R_202[0]+P_110101011*R_210[0]+-1*P_110101111*R_211[0]+P_110101211*R_212[0]; double PR_010000012100=P_010000012*R_100[0]+-1*P_010000112*R_101[0]+P_010000212*R_102[0]+-1*P_010000312*R_103[0]+-1*P_110000012*R_200[0]+P_110000112*R_201[0]+-1*P_110000212*R_202[0]+P_110000312*R_203[0]; double PR_002010010100=P_002010010*R_100[0]+-1*P_002010110*R_101[0]+-1*P_002110010*R_110[0]+P_002110110*R_111[0]+-1*P_102010010*R_200[0]+P_102010110*R_201[0]+P_102110010*R_210[0]+-1*P_102110110*R_211[0]+P_202010010*R_300[0]+-1*P_202010110*R_301[0]+-1*P_202110010*R_310[0]+P_202110110*R_311[0]; double PR_001011010100=P_001011010*R_100[0]+-1*P_001011110*R_101[0]+-1*P_001111010*R_110[0]+P_001111110*R_111[0]+P_001211010*R_120[0]+-1*P_001211110*R_121[0]+-1*P_101011010*R_200[0]+P_101011110*R_201[0]+P_101111010*R_210[0]+-1*P_101111110*R_211[0]+-1*P_101211010*R_220[0]+P_101211110*R_221[0]; double PR_000012010100=P_000012010*R_100[0]+-1*P_000012110*R_101[0]+-1*P_000112010*R_110[0]+P_000112110*R_111[0]+P_000212010*R_120[0]+-1*P_000212110*R_121[0]+-1*P_000312010*R_130[0]+P_000312110*R_131[0]; double PR_001010011100=P_001010011*R_100[0]+-1*P_001010111*R_101[0]+P_001010211*R_102[0]+-1*P_001110011*R_110[0]+P_001110111*R_111[0]+-1*P_001110211*R_112[0]+-1*P_101010011*R_200[0]+P_101010111*R_201[0]+-1*P_101010211*R_202[0]+P_101110011*R_210[0]+-1*P_101110111*R_211[0]+P_101110211*R_212[0]; double PR_000011011100=P_000011011*R_100[0]+-1*P_000011111*R_101[0]+P_000011211*R_102[0]+-1*P_000111011*R_110[0]+P_000111111*R_111[0]+-1*P_000111211*R_112[0]+P_000211011*R_120[0]+-1*P_000211111*R_121[0]+P_000211211*R_122[0]; double PR_000010012100=P_000010012*R_100[0]+-1*P_000010112*R_101[0]+P_000010212*R_102[0]+-1*P_000010312*R_103[0]+-1*P_000110012*R_110[0]+P_000110112*R_111[0]+-1*P_000110212*R_112[0]+P_000110312*R_113[0]; double PR_002000020100=P_002000020*R_100[0]+-1*P_002000120*R_101[0]+P_002000220*R_102[0]+-1*P_102000020*R_200[0]+P_102000120*R_201[0]+-1*P_102000220*R_202[0]+P_202000020*R_300[0]+-1*P_202000120*R_301[0]+P_202000220*R_302[0]; double PR_001001020100=P_001001020*R_100[0]+-1*P_001001120*R_101[0]+P_001001220*R_102[0]+-1*P_001101020*R_110[0]+P_001101120*R_111[0]+-1*P_001101220*R_112[0]+-1*P_101001020*R_200[0]+P_101001120*R_201[0]+-1*P_101001220*R_202[0]+P_101101020*R_210[0]+-1*P_101101120*R_211[0]+P_101101220*R_212[0]; double PR_000002020100=P_000002020*R_100[0]+-1*P_000002120*R_101[0]+P_000002220*R_102[0]+-1*P_000102020*R_110[0]+P_000102120*R_111[0]+-1*P_000102220*R_112[0]+P_000202020*R_120[0]+-1*P_000202120*R_121[0]+P_000202220*R_122[0]; double PR_001000021100=P_001000021*R_100[0]+-1*P_001000121*R_101[0]+P_001000221*R_102[0]+-1*P_001000321*R_103[0]+-1*P_101000021*R_200[0]+P_101000121*R_201[0]+-1*P_101000221*R_202[0]+P_101000321*R_203[0]; double PR_000001021100=P_000001021*R_100[0]+-1*P_000001121*R_101[0]+P_000001221*R_102[0]+-1*P_000001321*R_103[0]+-1*P_000101021*R_110[0]+P_000101121*R_111[0]+-1*P_000101221*R_112[0]+P_000101321*R_113[0]; double PR_000000022100=P_000000022*R_100[0]+-1*P_000000122*R_101[0]+P_000000222*R_102[0]+-1*P_000000322*R_103[0]+P_000000422*R_104[0]; double PR_022000000002=P_022000000*R_002[0]+-1*P_122000000*R_102[0]+P_222000000*R_202[0]+-1*P_322000000*R_302[0]+P_422000000*R_402[0]; double PR_021001000002=P_021001000*R_002[0]+-1*P_021101000*R_012[0]+-1*P_121001000*R_102[0]+P_121101000*R_112[0]+P_221001000*R_202[0]+-1*P_221101000*R_212[0]+-1*P_321001000*R_302[0]+P_321101000*R_312[0]; double PR_020002000002=P_020002000*R_002[0]+-1*P_020102000*R_012[0]+P_020202000*R_022[0]+-1*P_120002000*R_102[0]+P_120102000*R_112[0]+-1*P_120202000*R_122[0]+P_220002000*R_202[0]+-1*P_220102000*R_212[0]+P_220202000*R_222[0]; double PR_021000001002=P_021000001*R_002[0]+-1*P_021000101*R_003[0]+-1*P_121000001*R_102[0]+P_121000101*R_103[0]+P_221000001*R_202[0]+-1*P_221000101*R_203[0]+-1*P_321000001*R_302[0]+P_321000101*R_303[0]; double PR_020001001002=P_020001001*R_002[0]+-1*P_020001101*R_003[0]+-1*P_020101001*R_012[0]+P_020101101*R_013[0]+-1*P_120001001*R_102[0]+P_120001101*R_103[0]+P_120101001*R_112[0]+-1*P_120101101*R_113[0]+P_220001001*R_202[0]+-1*P_220001101*R_203[0]+-1*P_220101001*R_212[0]+P_220101101*R_213[0]; double PR_020000002002=P_020000002*R_002[0]+-1*P_020000102*R_003[0]+P_020000202*R_004[0]+-1*P_120000002*R_102[0]+P_120000102*R_103[0]+-1*P_120000202*R_104[0]+P_220000002*R_202[0]+-1*P_220000102*R_203[0]+P_220000202*R_204[0]; double PR_012010000002=P_012010000*R_002[0]+-1*P_012110000*R_012[0]+-1*P_112010000*R_102[0]+P_112110000*R_112[0]+P_212010000*R_202[0]+-1*P_212110000*R_212[0]+-1*P_312010000*R_302[0]+P_312110000*R_312[0]; double PR_011011000002=P_011011000*R_002[0]+-1*P_011111000*R_012[0]+P_011211000*R_022[0]+-1*P_111011000*R_102[0]+P_111111000*R_112[0]+-1*P_111211000*R_122[0]+P_211011000*R_202[0]+-1*P_211111000*R_212[0]+P_211211000*R_222[0]; double PR_010012000002=P_010012000*R_002[0]+-1*P_010112000*R_012[0]+P_010212000*R_022[0]+-1*P_010312000*R_032[0]+-1*P_110012000*R_102[0]+P_110112000*R_112[0]+-1*P_110212000*R_122[0]+P_110312000*R_132[0]; double PR_011010001002=P_011010001*R_002[0]+-1*P_011010101*R_003[0]+-1*P_011110001*R_012[0]+P_011110101*R_013[0]+-1*P_111010001*R_102[0]+P_111010101*R_103[0]+P_111110001*R_112[0]+-1*P_111110101*R_113[0]+P_211010001*R_202[0]+-1*P_211010101*R_203[0]+-1*P_211110001*R_212[0]+P_211110101*R_213[0]; double PR_010011001002=P_010011001*R_002[0]+-1*P_010011101*R_003[0]+-1*P_010111001*R_012[0]+P_010111101*R_013[0]+P_010211001*R_022[0]+-1*P_010211101*R_023[0]+-1*P_110011001*R_102[0]+P_110011101*R_103[0]+P_110111001*R_112[0]+-1*P_110111101*R_113[0]+-1*P_110211001*R_122[0]+P_110211101*R_123[0]; double PR_010010002002=P_010010002*R_002[0]+-1*P_010010102*R_003[0]+P_010010202*R_004[0]+-1*P_010110002*R_012[0]+P_010110102*R_013[0]+-1*P_010110202*R_014[0]+-1*P_110010002*R_102[0]+P_110010102*R_103[0]+-1*P_110010202*R_104[0]+P_110110002*R_112[0]+-1*P_110110102*R_113[0]+P_110110202*R_114[0]; double PR_002020000002=P_002020000*R_002[0]+-1*P_002120000*R_012[0]+P_002220000*R_022[0]+-1*P_102020000*R_102[0]+P_102120000*R_112[0]+-1*P_102220000*R_122[0]+P_202020000*R_202[0]+-1*P_202120000*R_212[0]+P_202220000*R_222[0]; double PR_001021000002=P_001021000*R_002[0]+-1*P_001121000*R_012[0]+P_001221000*R_022[0]+-1*P_001321000*R_032[0]+-1*P_101021000*R_102[0]+P_101121000*R_112[0]+-1*P_101221000*R_122[0]+P_101321000*R_132[0]; double PR_000022000002=P_000022000*R_002[0]+-1*P_000122000*R_012[0]+P_000222000*R_022[0]+-1*P_000322000*R_032[0]+P_000422000*R_042[0]; double PR_001020001002=P_001020001*R_002[0]+-1*P_001020101*R_003[0]+-1*P_001120001*R_012[0]+P_001120101*R_013[0]+P_001220001*R_022[0]+-1*P_001220101*R_023[0]+-1*P_101020001*R_102[0]+P_101020101*R_103[0]+P_101120001*R_112[0]+-1*P_101120101*R_113[0]+-1*P_101220001*R_122[0]+P_101220101*R_123[0]; double PR_000021001002=P_000021001*R_002[0]+-1*P_000021101*R_003[0]+-1*P_000121001*R_012[0]+P_000121101*R_013[0]+P_000221001*R_022[0]+-1*P_000221101*R_023[0]+-1*P_000321001*R_032[0]+P_000321101*R_033[0]; double PR_000020002002=P_000020002*R_002[0]+-1*P_000020102*R_003[0]+P_000020202*R_004[0]+-1*P_000120002*R_012[0]+P_000120102*R_013[0]+-1*P_000120202*R_014[0]+P_000220002*R_022[0]+-1*P_000220102*R_023[0]+P_000220202*R_024[0]; double PR_012000010002=P_012000010*R_002[0]+-1*P_012000110*R_003[0]+-1*P_112000010*R_102[0]+P_112000110*R_103[0]+P_212000010*R_202[0]+-1*P_212000110*R_203[0]+-1*P_312000010*R_302[0]+P_312000110*R_303[0]; double PR_011001010002=P_011001010*R_002[0]+-1*P_011001110*R_003[0]+-1*P_011101010*R_012[0]+P_011101110*R_013[0]+-1*P_111001010*R_102[0]+P_111001110*R_103[0]+P_111101010*R_112[0]+-1*P_111101110*R_113[0]+P_211001010*R_202[0]+-1*P_211001110*R_203[0]+-1*P_211101010*R_212[0]+P_211101110*R_213[0]; double PR_010002010002=P_010002010*R_002[0]+-1*P_010002110*R_003[0]+-1*P_010102010*R_012[0]+P_010102110*R_013[0]+P_010202010*R_022[0]+-1*P_010202110*R_023[0]+-1*P_110002010*R_102[0]+P_110002110*R_103[0]+P_110102010*R_112[0]+-1*P_110102110*R_113[0]+-1*P_110202010*R_122[0]+P_110202110*R_123[0]; double PR_011000011002=P_011000011*R_002[0]+-1*P_011000111*R_003[0]+P_011000211*R_004[0]+-1*P_111000011*R_102[0]+P_111000111*R_103[0]+-1*P_111000211*R_104[0]+P_211000011*R_202[0]+-1*P_211000111*R_203[0]+P_211000211*R_204[0]; double PR_010001011002=P_010001011*R_002[0]+-1*P_010001111*R_003[0]+P_010001211*R_004[0]+-1*P_010101011*R_012[0]+P_010101111*R_013[0]+-1*P_010101211*R_014[0]+-1*P_110001011*R_102[0]+P_110001111*R_103[0]+-1*P_110001211*R_104[0]+P_110101011*R_112[0]+-1*P_110101111*R_113[0]+P_110101211*R_114[0]; double PR_010000012002=P_010000012*R_002[0]+-1*P_010000112*R_003[0]+P_010000212*R_004[0]+-1*P_010000312*R_005[0]+-1*P_110000012*R_102[0]+P_110000112*R_103[0]+-1*P_110000212*R_104[0]+P_110000312*R_105[0]; double PR_002010010002=P_002010010*R_002[0]+-1*P_002010110*R_003[0]+-1*P_002110010*R_012[0]+P_002110110*R_013[0]+-1*P_102010010*R_102[0]+P_102010110*R_103[0]+P_102110010*R_112[0]+-1*P_102110110*R_113[0]+P_202010010*R_202[0]+-1*P_202010110*R_203[0]+-1*P_202110010*R_212[0]+P_202110110*R_213[0]; double PR_001011010002=P_001011010*R_002[0]+-1*P_001011110*R_003[0]+-1*P_001111010*R_012[0]+P_001111110*R_013[0]+P_001211010*R_022[0]+-1*P_001211110*R_023[0]+-1*P_101011010*R_102[0]+P_101011110*R_103[0]+P_101111010*R_112[0]+-1*P_101111110*R_113[0]+-1*P_101211010*R_122[0]+P_101211110*R_123[0]; double PR_000012010002=P_000012010*R_002[0]+-1*P_000012110*R_003[0]+-1*P_000112010*R_012[0]+P_000112110*R_013[0]+P_000212010*R_022[0]+-1*P_000212110*R_023[0]+-1*P_000312010*R_032[0]+P_000312110*R_033[0]; double PR_001010011002=P_001010011*R_002[0]+-1*P_001010111*R_003[0]+P_001010211*R_004[0]+-1*P_001110011*R_012[0]+P_001110111*R_013[0]+-1*P_001110211*R_014[0]+-1*P_101010011*R_102[0]+P_101010111*R_103[0]+-1*P_101010211*R_104[0]+P_101110011*R_112[0]+-1*P_101110111*R_113[0]+P_101110211*R_114[0]; double PR_000011011002=P_000011011*R_002[0]+-1*P_000011111*R_003[0]+P_000011211*R_004[0]+-1*P_000111011*R_012[0]+P_000111111*R_013[0]+-1*P_000111211*R_014[0]+P_000211011*R_022[0]+-1*P_000211111*R_023[0]+P_000211211*R_024[0]; double PR_000010012002=P_000010012*R_002[0]+-1*P_000010112*R_003[0]+P_000010212*R_004[0]+-1*P_000010312*R_005[0]+-1*P_000110012*R_012[0]+P_000110112*R_013[0]+-1*P_000110212*R_014[0]+P_000110312*R_015[0]; double PR_002000020002=P_002000020*R_002[0]+-1*P_002000120*R_003[0]+P_002000220*R_004[0]+-1*P_102000020*R_102[0]+P_102000120*R_103[0]+-1*P_102000220*R_104[0]+P_202000020*R_202[0]+-1*P_202000120*R_203[0]+P_202000220*R_204[0]; double PR_001001020002=P_001001020*R_002[0]+-1*P_001001120*R_003[0]+P_001001220*R_004[0]+-1*P_001101020*R_012[0]+P_001101120*R_013[0]+-1*P_001101220*R_014[0]+-1*P_101001020*R_102[0]+P_101001120*R_103[0]+-1*P_101001220*R_104[0]+P_101101020*R_112[0]+-1*P_101101120*R_113[0]+P_101101220*R_114[0]; double PR_000002020002=P_000002020*R_002[0]+-1*P_000002120*R_003[0]+P_000002220*R_004[0]+-1*P_000102020*R_012[0]+P_000102120*R_013[0]+-1*P_000102220*R_014[0]+P_000202020*R_022[0]+-1*P_000202120*R_023[0]+P_000202220*R_024[0]; double PR_001000021002=P_001000021*R_002[0]+-1*P_001000121*R_003[0]+P_001000221*R_004[0]+-1*P_001000321*R_005[0]+-1*P_101000021*R_102[0]+P_101000121*R_103[0]+-1*P_101000221*R_104[0]+P_101000321*R_105[0]; double PR_000001021002=P_000001021*R_002[0]+-1*P_000001121*R_003[0]+P_000001221*R_004[0]+-1*P_000001321*R_005[0]+-1*P_000101021*R_012[0]+P_000101121*R_013[0]+-1*P_000101221*R_014[0]+P_000101321*R_015[0]; double PR_000000022002=P_000000022*R_002[0]+-1*P_000000122*R_003[0]+P_000000222*R_004[0]+-1*P_000000322*R_005[0]+P_000000422*R_006[0]; double PR_022000000011=P_022000000*R_011[0]+-1*P_122000000*R_111[0]+P_222000000*R_211[0]+-1*P_322000000*R_311[0]+P_422000000*R_411[0]; double PR_021001000011=P_021001000*R_011[0]+-1*P_021101000*R_021[0]+-1*P_121001000*R_111[0]+P_121101000*R_121[0]+P_221001000*R_211[0]+-1*P_221101000*R_221[0]+-1*P_321001000*R_311[0]+P_321101000*R_321[0]; double PR_020002000011=P_020002000*R_011[0]+-1*P_020102000*R_021[0]+P_020202000*R_031[0]+-1*P_120002000*R_111[0]+P_120102000*R_121[0]+-1*P_120202000*R_131[0]+P_220002000*R_211[0]+-1*P_220102000*R_221[0]+P_220202000*R_231[0]; double PR_021000001011=P_021000001*R_011[0]+-1*P_021000101*R_012[0]+-1*P_121000001*R_111[0]+P_121000101*R_112[0]+P_221000001*R_211[0]+-1*P_221000101*R_212[0]+-1*P_321000001*R_311[0]+P_321000101*R_312[0]; double PR_020001001011=P_020001001*R_011[0]+-1*P_020001101*R_012[0]+-1*P_020101001*R_021[0]+P_020101101*R_022[0]+-1*P_120001001*R_111[0]+P_120001101*R_112[0]+P_120101001*R_121[0]+-1*P_120101101*R_122[0]+P_220001001*R_211[0]+-1*P_220001101*R_212[0]+-1*P_220101001*R_221[0]+P_220101101*R_222[0]; double PR_020000002011=P_020000002*R_011[0]+-1*P_020000102*R_012[0]+P_020000202*R_013[0]+-1*P_120000002*R_111[0]+P_120000102*R_112[0]+-1*P_120000202*R_113[0]+P_220000002*R_211[0]+-1*P_220000102*R_212[0]+P_220000202*R_213[0]; double PR_012010000011=P_012010000*R_011[0]+-1*P_012110000*R_021[0]+-1*P_112010000*R_111[0]+P_112110000*R_121[0]+P_212010000*R_211[0]+-1*P_212110000*R_221[0]+-1*P_312010000*R_311[0]+P_312110000*R_321[0]; double PR_011011000011=P_011011000*R_011[0]+-1*P_011111000*R_021[0]+P_011211000*R_031[0]+-1*P_111011000*R_111[0]+P_111111000*R_121[0]+-1*P_111211000*R_131[0]+P_211011000*R_211[0]+-1*P_211111000*R_221[0]+P_211211000*R_231[0]; double PR_010012000011=P_010012000*R_011[0]+-1*P_010112000*R_021[0]+P_010212000*R_031[0]+-1*P_010312000*R_041[0]+-1*P_110012000*R_111[0]+P_110112000*R_121[0]+-1*P_110212000*R_131[0]+P_110312000*R_141[0]; double PR_011010001011=P_011010001*R_011[0]+-1*P_011010101*R_012[0]+-1*P_011110001*R_021[0]+P_011110101*R_022[0]+-1*P_111010001*R_111[0]+P_111010101*R_112[0]+P_111110001*R_121[0]+-1*P_111110101*R_122[0]+P_211010001*R_211[0]+-1*P_211010101*R_212[0]+-1*P_211110001*R_221[0]+P_211110101*R_222[0]; double PR_010011001011=P_010011001*R_011[0]+-1*P_010011101*R_012[0]+-1*P_010111001*R_021[0]+P_010111101*R_022[0]+P_010211001*R_031[0]+-1*P_010211101*R_032[0]+-1*P_110011001*R_111[0]+P_110011101*R_112[0]+P_110111001*R_121[0]+-1*P_110111101*R_122[0]+-1*P_110211001*R_131[0]+P_110211101*R_132[0]; double PR_010010002011=P_010010002*R_011[0]+-1*P_010010102*R_012[0]+P_010010202*R_013[0]+-1*P_010110002*R_021[0]+P_010110102*R_022[0]+-1*P_010110202*R_023[0]+-1*P_110010002*R_111[0]+P_110010102*R_112[0]+-1*P_110010202*R_113[0]+P_110110002*R_121[0]+-1*P_110110102*R_122[0]+P_110110202*R_123[0]; double PR_002020000011=P_002020000*R_011[0]+-1*P_002120000*R_021[0]+P_002220000*R_031[0]+-1*P_102020000*R_111[0]+P_102120000*R_121[0]+-1*P_102220000*R_131[0]+P_202020000*R_211[0]+-1*P_202120000*R_221[0]+P_202220000*R_231[0]; double PR_001021000011=P_001021000*R_011[0]+-1*P_001121000*R_021[0]+P_001221000*R_031[0]+-1*P_001321000*R_041[0]+-1*P_101021000*R_111[0]+P_101121000*R_121[0]+-1*P_101221000*R_131[0]+P_101321000*R_141[0]; double PR_000022000011=P_000022000*R_011[0]+-1*P_000122000*R_021[0]+P_000222000*R_031[0]+-1*P_000322000*R_041[0]+P_000422000*R_051[0]; double PR_001020001011=P_001020001*R_011[0]+-1*P_001020101*R_012[0]+-1*P_001120001*R_021[0]+P_001120101*R_022[0]+P_001220001*R_031[0]+-1*P_001220101*R_032[0]+-1*P_101020001*R_111[0]+P_101020101*R_112[0]+P_101120001*R_121[0]+-1*P_101120101*R_122[0]+-1*P_101220001*R_131[0]+P_101220101*R_132[0]; double PR_000021001011=P_000021001*R_011[0]+-1*P_000021101*R_012[0]+-1*P_000121001*R_021[0]+P_000121101*R_022[0]+P_000221001*R_031[0]+-1*P_000221101*R_032[0]+-1*P_000321001*R_041[0]+P_000321101*R_042[0]; double PR_000020002011=P_000020002*R_011[0]+-1*P_000020102*R_012[0]+P_000020202*R_013[0]+-1*P_000120002*R_021[0]+P_000120102*R_022[0]+-1*P_000120202*R_023[0]+P_000220002*R_031[0]+-1*P_000220102*R_032[0]+P_000220202*R_033[0]; double PR_012000010011=P_012000010*R_011[0]+-1*P_012000110*R_012[0]+-1*P_112000010*R_111[0]+P_112000110*R_112[0]+P_212000010*R_211[0]+-1*P_212000110*R_212[0]+-1*P_312000010*R_311[0]+P_312000110*R_312[0]; double PR_011001010011=P_011001010*R_011[0]+-1*P_011001110*R_012[0]+-1*P_011101010*R_021[0]+P_011101110*R_022[0]+-1*P_111001010*R_111[0]+P_111001110*R_112[0]+P_111101010*R_121[0]+-1*P_111101110*R_122[0]+P_211001010*R_211[0]+-1*P_211001110*R_212[0]+-1*P_211101010*R_221[0]+P_211101110*R_222[0]; double PR_010002010011=P_010002010*R_011[0]+-1*P_010002110*R_012[0]+-1*P_010102010*R_021[0]+P_010102110*R_022[0]+P_010202010*R_031[0]+-1*P_010202110*R_032[0]+-1*P_110002010*R_111[0]+P_110002110*R_112[0]+P_110102010*R_121[0]+-1*P_110102110*R_122[0]+-1*P_110202010*R_131[0]+P_110202110*R_132[0]; double PR_011000011011=P_011000011*R_011[0]+-1*P_011000111*R_012[0]+P_011000211*R_013[0]+-1*P_111000011*R_111[0]+P_111000111*R_112[0]+-1*P_111000211*R_113[0]+P_211000011*R_211[0]+-1*P_211000111*R_212[0]+P_211000211*R_213[0]; double PR_010001011011=P_010001011*R_011[0]+-1*P_010001111*R_012[0]+P_010001211*R_013[0]+-1*P_010101011*R_021[0]+P_010101111*R_022[0]+-1*P_010101211*R_023[0]+-1*P_110001011*R_111[0]+P_110001111*R_112[0]+-1*P_110001211*R_113[0]+P_110101011*R_121[0]+-1*P_110101111*R_122[0]+P_110101211*R_123[0]; double PR_010000012011=P_010000012*R_011[0]+-1*P_010000112*R_012[0]+P_010000212*R_013[0]+-1*P_010000312*R_014[0]+-1*P_110000012*R_111[0]+P_110000112*R_112[0]+-1*P_110000212*R_113[0]+P_110000312*R_114[0]; double PR_002010010011=P_002010010*R_011[0]+-1*P_002010110*R_012[0]+-1*P_002110010*R_021[0]+P_002110110*R_022[0]+-1*P_102010010*R_111[0]+P_102010110*R_112[0]+P_102110010*R_121[0]+-1*P_102110110*R_122[0]+P_202010010*R_211[0]+-1*P_202010110*R_212[0]+-1*P_202110010*R_221[0]+P_202110110*R_222[0]; double PR_001011010011=P_001011010*R_011[0]+-1*P_001011110*R_012[0]+-1*P_001111010*R_021[0]+P_001111110*R_022[0]+P_001211010*R_031[0]+-1*P_001211110*R_032[0]+-1*P_101011010*R_111[0]+P_101011110*R_112[0]+P_101111010*R_121[0]+-1*P_101111110*R_122[0]+-1*P_101211010*R_131[0]+P_101211110*R_132[0]; double PR_000012010011=P_000012010*R_011[0]+-1*P_000012110*R_012[0]+-1*P_000112010*R_021[0]+P_000112110*R_022[0]+P_000212010*R_031[0]+-1*P_000212110*R_032[0]+-1*P_000312010*R_041[0]+P_000312110*R_042[0]; double PR_001010011011=P_001010011*R_011[0]+-1*P_001010111*R_012[0]+P_001010211*R_013[0]+-1*P_001110011*R_021[0]+P_001110111*R_022[0]+-1*P_001110211*R_023[0]+-1*P_101010011*R_111[0]+P_101010111*R_112[0]+-1*P_101010211*R_113[0]+P_101110011*R_121[0]+-1*P_101110111*R_122[0]+P_101110211*R_123[0]; double PR_000011011011=P_000011011*R_011[0]+-1*P_000011111*R_012[0]+P_000011211*R_013[0]+-1*P_000111011*R_021[0]+P_000111111*R_022[0]+-1*P_000111211*R_023[0]+P_000211011*R_031[0]+-1*P_000211111*R_032[0]+P_000211211*R_033[0]; double PR_000010012011=P_000010012*R_011[0]+-1*P_000010112*R_012[0]+P_000010212*R_013[0]+-1*P_000010312*R_014[0]+-1*P_000110012*R_021[0]+P_000110112*R_022[0]+-1*P_000110212*R_023[0]+P_000110312*R_024[0]; double PR_002000020011=P_002000020*R_011[0]+-1*P_002000120*R_012[0]+P_002000220*R_013[0]+-1*P_102000020*R_111[0]+P_102000120*R_112[0]+-1*P_102000220*R_113[0]+P_202000020*R_211[0]+-1*P_202000120*R_212[0]+P_202000220*R_213[0]; double PR_001001020011=P_001001020*R_011[0]+-1*P_001001120*R_012[0]+P_001001220*R_013[0]+-1*P_001101020*R_021[0]+P_001101120*R_022[0]+-1*P_001101220*R_023[0]+-1*P_101001020*R_111[0]+P_101001120*R_112[0]+-1*P_101001220*R_113[0]+P_101101020*R_121[0]+-1*P_101101120*R_122[0]+P_101101220*R_123[0]; double PR_000002020011=P_000002020*R_011[0]+-1*P_000002120*R_012[0]+P_000002220*R_013[0]+-1*P_000102020*R_021[0]+P_000102120*R_022[0]+-1*P_000102220*R_023[0]+P_000202020*R_031[0]+-1*P_000202120*R_032[0]+P_000202220*R_033[0]; double PR_001000021011=P_001000021*R_011[0]+-1*P_001000121*R_012[0]+P_001000221*R_013[0]+-1*P_001000321*R_014[0]+-1*P_101000021*R_111[0]+P_101000121*R_112[0]+-1*P_101000221*R_113[0]+P_101000321*R_114[0]; double PR_000001021011=P_000001021*R_011[0]+-1*P_000001121*R_012[0]+P_000001221*R_013[0]+-1*P_000001321*R_014[0]+-1*P_000101021*R_021[0]+P_000101121*R_022[0]+-1*P_000101221*R_023[0]+P_000101321*R_024[0]; double PR_000000022011=P_000000022*R_011[0]+-1*P_000000122*R_012[0]+P_000000222*R_013[0]+-1*P_000000322*R_014[0]+P_000000422*R_015[0]; double PR_022000000020=P_022000000*R_020[0]+-1*P_122000000*R_120[0]+P_222000000*R_220[0]+-1*P_322000000*R_320[0]+P_422000000*R_420[0]; double PR_021001000020=P_021001000*R_020[0]+-1*P_021101000*R_030[0]+-1*P_121001000*R_120[0]+P_121101000*R_130[0]+P_221001000*R_220[0]+-1*P_221101000*R_230[0]+-1*P_321001000*R_320[0]+P_321101000*R_330[0]; double PR_020002000020=P_020002000*R_020[0]+-1*P_020102000*R_030[0]+P_020202000*R_040[0]+-1*P_120002000*R_120[0]+P_120102000*R_130[0]+-1*P_120202000*R_140[0]+P_220002000*R_220[0]+-1*P_220102000*R_230[0]+P_220202000*R_240[0]; double PR_021000001020=P_021000001*R_020[0]+-1*P_021000101*R_021[0]+-1*P_121000001*R_120[0]+P_121000101*R_121[0]+P_221000001*R_220[0]+-1*P_221000101*R_221[0]+-1*P_321000001*R_320[0]+P_321000101*R_321[0]; double PR_020001001020=P_020001001*R_020[0]+-1*P_020001101*R_021[0]+-1*P_020101001*R_030[0]+P_020101101*R_031[0]+-1*P_120001001*R_120[0]+P_120001101*R_121[0]+P_120101001*R_130[0]+-1*P_120101101*R_131[0]+P_220001001*R_220[0]+-1*P_220001101*R_221[0]+-1*P_220101001*R_230[0]+P_220101101*R_231[0]; double PR_020000002020=P_020000002*R_020[0]+-1*P_020000102*R_021[0]+P_020000202*R_022[0]+-1*P_120000002*R_120[0]+P_120000102*R_121[0]+-1*P_120000202*R_122[0]+P_220000002*R_220[0]+-1*P_220000102*R_221[0]+P_220000202*R_222[0]; double PR_012010000020=P_012010000*R_020[0]+-1*P_012110000*R_030[0]+-1*P_112010000*R_120[0]+P_112110000*R_130[0]+P_212010000*R_220[0]+-1*P_212110000*R_230[0]+-1*P_312010000*R_320[0]+P_312110000*R_330[0]; double PR_011011000020=P_011011000*R_020[0]+-1*P_011111000*R_030[0]+P_011211000*R_040[0]+-1*P_111011000*R_120[0]+P_111111000*R_130[0]+-1*P_111211000*R_140[0]+P_211011000*R_220[0]+-1*P_211111000*R_230[0]+P_211211000*R_240[0]; double PR_010012000020=P_010012000*R_020[0]+-1*P_010112000*R_030[0]+P_010212000*R_040[0]+-1*P_010312000*R_050[0]+-1*P_110012000*R_120[0]+P_110112000*R_130[0]+-1*P_110212000*R_140[0]+P_110312000*R_150[0]; double PR_011010001020=P_011010001*R_020[0]+-1*P_011010101*R_021[0]+-1*P_011110001*R_030[0]+P_011110101*R_031[0]+-1*P_111010001*R_120[0]+P_111010101*R_121[0]+P_111110001*R_130[0]+-1*P_111110101*R_131[0]+P_211010001*R_220[0]+-1*P_211010101*R_221[0]+-1*P_211110001*R_230[0]+P_211110101*R_231[0]; double PR_010011001020=P_010011001*R_020[0]+-1*P_010011101*R_021[0]+-1*P_010111001*R_030[0]+P_010111101*R_031[0]+P_010211001*R_040[0]+-1*P_010211101*R_041[0]+-1*P_110011001*R_120[0]+P_110011101*R_121[0]+P_110111001*R_130[0]+-1*P_110111101*R_131[0]+-1*P_110211001*R_140[0]+P_110211101*R_141[0]; double PR_010010002020=P_010010002*R_020[0]+-1*P_010010102*R_021[0]+P_010010202*R_022[0]+-1*P_010110002*R_030[0]+P_010110102*R_031[0]+-1*P_010110202*R_032[0]+-1*P_110010002*R_120[0]+P_110010102*R_121[0]+-1*P_110010202*R_122[0]+P_110110002*R_130[0]+-1*P_110110102*R_131[0]+P_110110202*R_132[0]; double PR_002020000020=P_002020000*R_020[0]+-1*P_002120000*R_030[0]+P_002220000*R_040[0]+-1*P_102020000*R_120[0]+P_102120000*R_130[0]+-1*P_102220000*R_140[0]+P_202020000*R_220[0]+-1*P_202120000*R_230[0]+P_202220000*R_240[0]; double PR_001021000020=P_001021000*R_020[0]+-1*P_001121000*R_030[0]+P_001221000*R_040[0]+-1*P_001321000*R_050[0]+-1*P_101021000*R_120[0]+P_101121000*R_130[0]+-1*P_101221000*R_140[0]+P_101321000*R_150[0]; double PR_000022000020=P_000022000*R_020[0]+-1*P_000122000*R_030[0]+P_000222000*R_040[0]+-1*P_000322000*R_050[0]+P_000422000*R_060[0]; double PR_001020001020=P_001020001*R_020[0]+-1*P_001020101*R_021[0]+-1*P_001120001*R_030[0]+P_001120101*R_031[0]+P_001220001*R_040[0]+-1*P_001220101*R_041[0]+-1*P_101020001*R_120[0]+P_101020101*R_121[0]+P_101120001*R_130[0]+-1*P_101120101*R_131[0]+-1*P_101220001*R_140[0]+P_101220101*R_141[0]; double PR_000021001020=P_000021001*R_020[0]+-1*P_000021101*R_021[0]+-1*P_000121001*R_030[0]+P_000121101*R_031[0]+P_000221001*R_040[0]+-1*P_000221101*R_041[0]+-1*P_000321001*R_050[0]+P_000321101*R_051[0]; double PR_000020002020=P_000020002*R_020[0]+-1*P_000020102*R_021[0]+P_000020202*R_022[0]+-1*P_000120002*R_030[0]+P_000120102*R_031[0]+-1*P_000120202*R_032[0]+P_000220002*R_040[0]+-1*P_000220102*R_041[0]+P_000220202*R_042[0]; double PR_012000010020=P_012000010*R_020[0]+-1*P_012000110*R_021[0]+-1*P_112000010*R_120[0]+P_112000110*R_121[0]+P_212000010*R_220[0]+-1*P_212000110*R_221[0]+-1*P_312000010*R_320[0]+P_312000110*R_321[0]; double PR_011001010020=P_011001010*R_020[0]+-1*P_011001110*R_021[0]+-1*P_011101010*R_030[0]+P_011101110*R_031[0]+-1*P_111001010*R_120[0]+P_111001110*R_121[0]+P_111101010*R_130[0]+-1*P_111101110*R_131[0]+P_211001010*R_220[0]+-1*P_211001110*R_221[0]+-1*P_211101010*R_230[0]+P_211101110*R_231[0]; double PR_010002010020=P_010002010*R_020[0]+-1*P_010002110*R_021[0]+-1*P_010102010*R_030[0]+P_010102110*R_031[0]+P_010202010*R_040[0]+-1*P_010202110*R_041[0]+-1*P_110002010*R_120[0]+P_110002110*R_121[0]+P_110102010*R_130[0]+-1*P_110102110*R_131[0]+-1*P_110202010*R_140[0]+P_110202110*R_141[0]; double PR_011000011020=P_011000011*R_020[0]+-1*P_011000111*R_021[0]+P_011000211*R_022[0]+-1*P_111000011*R_120[0]+P_111000111*R_121[0]+-1*P_111000211*R_122[0]+P_211000011*R_220[0]+-1*P_211000111*R_221[0]+P_211000211*R_222[0]; double PR_010001011020=P_010001011*R_020[0]+-1*P_010001111*R_021[0]+P_010001211*R_022[0]+-1*P_010101011*R_030[0]+P_010101111*R_031[0]+-1*P_010101211*R_032[0]+-1*P_110001011*R_120[0]+P_110001111*R_121[0]+-1*P_110001211*R_122[0]+P_110101011*R_130[0]+-1*P_110101111*R_131[0]+P_110101211*R_132[0]; double PR_010000012020=P_010000012*R_020[0]+-1*P_010000112*R_021[0]+P_010000212*R_022[0]+-1*P_010000312*R_023[0]+-1*P_110000012*R_120[0]+P_110000112*R_121[0]+-1*P_110000212*R_122[0]+P_110000312*R_123[0]; double PR_002010010020=P_002010010*R_020[0]+-1*P_002010110*R_021[0]+-1*P_002110010*R_030[0]+P_002110110*R_031[0]+-1*P_102010010*R_120[0]+P_102010110*R_121[0]+P_102110010*R_130[0]+-1*P_102110110*R_131[0]+P_202010010*R_220[0]+-1*P_202010110*R_221[0]+-1*P_202110010*R_230[0]+P_202110110*R_231[0]; double PR_001011010020=P_001011010*R_020[0]+-1*P_001011110*R_021[0]+-1*P_001111010*R_030[0]+P_001111110*R_031[0]+P_001211010*R_040[0]+-1*P_001211110*R_041[0]+-1*P_101011010*R_120[0]+P_101011110*R_121[0]+P_101111010*R_130[0]+-1*P_101111110*R_131[0]+-1*P_101211010*R_140[0]+P_101211110*R_141[0]; double PR_000012010020=P_000012010*R_020[0]+-1*P_000012110*R_021[0]+-1*P_000112010*R_030[0]+P_000112110*R_031[0]+P_000212010*R_040[0]+-1*P_000212110*R_041[0]+-1*P_000312010*R_050[0]+P_000312110*R_051[0]; double PR_001010011020=P_001010011*R_020[0]+-1*P_001010111*R_021[0]+P_001010211*R_022[0]+-1*P_001110011*R_030[0]+P_001110111*R_031[0]+-1*P_001110211*R_032[0]+-1*P_101010011*R_120[0]+P_101010111*R_121[0]+-1*P_101010211*R_122[0]+P_101110011*R_130[0]+-1*P_101110111*R_131[0]+P_101110211*R_132[0]; double PR_000011011020=P_000011011*R_020[0]+-1*P_000011111*R_021[0]+P_000011211*R_022[0]+-1*P_000111011*R_030[0]+P_000111111*R_031[0]+-1*P_000111211*R_032[0]+P_000211011*R_040[0]+-1*P_000211111*R_041[0]+P_000211211*R_042[0]; double PR_000010012020=P_000010012*R_020[0]+-1*P_000010112*R_021[0]+P_000010212*R_022[0]+-1*P_000010312*R_023[0]+-1*P_000110012*R_030[0]+P_000110112*R_031[0]+-1*P_000110212*R_032[0]+P_000110312*R_033[0]; double PR_002000020020=P_002000020*R_020[0]+-1*P_002000120*R_021[0]+P_002000220*R_022[0]+-1*P_102000020*R_120[0]+P_102000120*R_121[0]+-1*P_102000220*R_122[0]+P_202000020*R_220[0]+-1*P_202000120*R_221[0]+P_202000220*R_222[0]; double PR_001001020020=P_001001020*R_020[0]+-1*P_001001120*R_021[0]+P_001001220*R_022[0]+-1*P_001101020*R_030[0]+P_001101120*R_031[0]+-1*P_001101220*R_032[0]+-1*P_101001020*R_120[0]+P_101001120*R_121[0]+-1*P_101001220*R_122[0]+P_101101020*R_130[0]+-1*P_101101120*R_131[0]+P_101101220*R_132[0]; double PR_000002020020=P_000002020*R_020[0]+-1*P_000002120*R_021[0]+P_000002220*R_022[0]+-1*P_000102020*R_030[0]+P_000102120*R_031[0]+-1*P_000102220*R_032[0]+P_000202020*R_040[0]+-1*P_000202120*R_041[0]+P_000202220*R_042[0]; double PR_001000021020=P_001000021*R_020[0]+-1*P_001000121*R_021[0]+P_001000221*R_022[0]+-1*P_001000321*R_023[0]+-1*P_101000021*R_120[0]+P_101000121*R_121[0]+-1*P_101000221*R_122[0]+P_101000321*R_123[0]; double PR_000001021020=P_000001021*R_020[0]+-1*P_000001121*R_021[0]+P_000001221*R_022[0]+-1*P_000001321*R_023[0]+-1*P_000101021*R_030[0]+P_000101121*R_031[0]+-1*P_000101221*R_032[0]+P_000101321*R_033[0]; double PR_000000022020=P_000000022*R_020[0]+-1*P_000000122*R_021[0]+P_000000222*R_022[0]+-1*P_000000322*R_023[0]+P_000000422*R_024[0]; double PR_022000000101=P_022000000*R_101[0]+-1*P_122000000*R_201[0]+P_222000000*R_301[0]+-1*P_322000000*R_401[0]+P_422000000*R_501[0]; double PR_021001000101=P_021001000*R_101[0]+-1*P_021101000*R_111[0]+-1*P_121001000*R_201[0]+P_121101000*R_211[0]+P_221001000*R_301[0]+-1*P_221101000*R_311[0]+-1*P_321001000*R_401[0]+P_321101000*R_411[0]; double PR_020002000101=P_020002000*R_101[0]+-1*P_020102000*R_111[0]+P_020202000*R_121[0]+-1*P_120002000*R_201[0]+P_120102000*R_211[0]+-1*P_120202000*R_221[0]+P_220002000*R_301[0]+-1*P_220102000*R_311[0]+P_220202000*R_321[0]; double PR_021000001101=P_021000001*R_101[0]+-1*P_021000101*R_102[0]+-1*P_121000001*R_201[0]+P_121000101*R_202[0]+P_221000001*R_301[0]+-1*P_221000101*R_302[0]+-1*P_321000001*R_401[0]+P_321000101*R_402[0]; double PR_020001001101=P_020001001*R_101[0]+-1*P_020001101*R_102[0]+-1*P_020101001*R_111[0]+P_020101101*R_112[0]+-1*P_120001001*R_201[0]+P_120001101*R_202[0]+P_120101001*R_211[0]+-1*P_120101101*R_212[0]+P_220001001*R_301[0]+-1*P_220001101*R_302[0]+-1*P_220101001*R_311[0]+P_220101101*R_312[0]; double PR_020000002101=P_020000002*R_101[0]+-1*P_020000102*R_102[0]+P_020000202*R_103[0]+-1*P_120000002*R_201[0]+P_120000102*R_202[0]+-1*P_120000202*R_203[0]+P_220000002*R_301[0]+-1*P_220000102*R_302[0]+P_220000202*R_303[0]; double PR_012010000101=P_012010000*R_101[0]+-1*P_012110000*R_111[0]+-1*P_112010000*R_201[0]+P_112110000*R_211[0]+P_212010000*R_301[0]+-1*P_212110000*R_311[0]+-1*P_312010000*R_401[0]+P_312110000*R_411[0]; double PR_011011000101=P_011011000*R_101[0]+-1*P_011111000*R_111[0]+P_011211000*R_121[0]+-1*P_111011000*R_201[0]+P_111111000*R_211[0]+-1*P_111211000*R_221[0]+P_211011000*R_301[0]+-1*P_211111000*R_311[0]+P_211211000*R_321[0]; double PR_010012000101=P_010012000*R_101[0]+-1*P_010112000*R_111[0]+P_010212000*R_121[0]+-1*P_010312000*R_131[0]+-1*P_110012000*R_201[0]+P_110112000*R_211[0]+-1*P_110212000*R_221[0]+P_110312000*R_231[0]; double PR_011010001101=P_011010001*R_101[0]+-1*P_011010101*R_102[0]+-1*P_011110001*R_111[0]+P_011110101*R_112[0]+-1*P_111010001*R_201[0]+P_111010101*R_202[0]+P_111110001*R_211[0]+-1*P_111110101*R_212[0]+P_211010001*R_301[0]+-1*P_211010101*R_302[0]+-1*P_211110001*R_311[0]+P_211110101*R_312[0]; double PR_010011001101=P_010011001*R_101[0]+-1*P_010011101*R_102[0]+-1*P_010111001*R_111[0]+P_010111101*R_112[0]+P_010211001*R_121[0]+-1*P_010211101*R_122[0]+-1*P_110011001*R_201[0]+P_110011101*R_202[0]+P_110111001*R_211[0]+-1*P_110111101*R_212[0]+-1*P_110211001*R_221[0]+P_110211101*R_222[0]; double PR_010010002101=P_010010002*R_101[0]+-1*P_010010102*R_102[0]+P_010010202*R_103[0]+-1*P_010110002*R_111[0]+P_010110102*R_112[0]+-1*P_010110202*R_113[0]+-1*P_110010002*R_201[0]+P_110010102*R_202[0]+-1*P_110010202*R_203[0]+P_110110002*R_211[0]+-1*P_110110102*R_212[0]+P_110110202*R_213[0]; double PR_002020000101=P_002020000*R_101[0]+-1*P_002120000*R_111[0]+P_002220000*R_121[0]+-1*P_102020000*R_201[0]+P_102120000*R_211[0]+-1*P_102220000*R_221[0]+P_202020000*R_301[0]+-1*P_202120000*R_311[0]+P_202220000*R_321[0]; double PR_001021000101=P_001021000*R_101[0]+-1*P_001121000*R_111[0]+P_001221000*R_121[0]+-1*P_001321000*R_131[0]+-1*P_101021000*R_201[0]+P_101121000*R_211[0]+-1*P_101221000*R_221[0]+P_101321000*R_231[0]; double PR_000022000101=P_000022000*R_101[0]+-1*P_000122000*R_111[0]+P_000222000*R_121[0]+-1*P_000322000*R_131[0]+P_000422000*R_141[0]; double PR_001020001101=P_001020001*R_101[0]+-1*P_001020101*R_102[0]+-1*P_001120001*R_111[0]+P_001120101*R_112[0]+P_001220001*R_121[0]+-1*P_001220101*R_122[0]+-1*P_101020001*R_201[0]+P_101020101*R_202[0]+P_101120001*R_211[0]+-1*P_101120101*R_212[0]+-1*P_101220001*R_221[0]+P_101220101*R_222[0]; double PR_000021001101=P_000021001*R_101[0]+-1*P_000021101*R_102[0]+-1*P_000121001*R_111[0]+P_000121101*R_112[0]+P_000221001*R_121[0]+-1*P_000221101*R_122[0]+-1*P_000321001*R_131[0]+P_000321101*R_132[0]; double PR_000020002101=P_000020002*R_101[0]+-1*P_000020102*R_102[0]+P_000020202*R_103[0]+-1*P_000120002*R_111[0]+P_000120102*R_112[0]+-1*P_000120202*R_113[0]+P_000220002*R_121[0]+-1*P_000220102*R_122[0]+P_000220202*R_123[0]; double PR_012000010101=P_012000010*R_101[0]+-1*P_012000110*R_102[0]+-1*P_112000010*R_201[0]+P_112000110*R_202[0]+P_212000010*R_301[0]+-1*P_212000110*R_302[0]+-1*P_312000010*R_401[0]+P_312000110*R_402[0]; double PR_011001010101=P_011001010*R_101[0]+-1*P_011001110*R_102[0]+-1*P_011101010*R_111[0]+P_011101110*R_112[0]+-1*P_111001010*R_201[0]+P_111001110*R_202[0]+P_111101010*R_211[0]+-1*P_111101110*R_212[0]+P_211001010*R_301[0]+-1*P_211001110*R_302[0]+-1*P_211101010*R_311[0]+P_211101110*R_312[0]; double PR_010002010101=P_010002010*R_101[0]+-1*P_010002110*R_102[0]+-1*P_010102010*R_111[0]+P_010102110*R_112[0]+P_010202010*R_121[0]+-1*P_010202110*R_122[0]+-1*P_110002010*R_201[0]+P_110002110*R_202[0]+P_110102010*R_211[0]+-1*P_110102110*R_212[0]+-1*P_110202010*R_221[0]+P_110202110*R_222[0]; double PR_011000011101=P_011000011*R_101[0]+-1*P_011000111*R_102[0]+P_011000211*R_103[0]+-1*P_111000011*R_201[0]+P_111000111*R_202[0]+-1*P_111000211*R_203[0]+P_211000011*R_301[0]+-1*P_211000111*R_302[0]+P_211000211*R_303[0]; double PR_010001011101=P_010001011*R_101[0]+-1*P_010001111*R_102[0]+P_010001211*R_103[0]+-1*P_010101011*R_111[0]+P_010101111*R_112[0]+-1*P_010101211*R_113[0]+-1*P_110001011*R_201[0]+P_110001111*R_202[0]+-1*P_110001211*R_203[0]+P_110101011*R_211[0]+-1*P_110101111*R_212[0]+P_110101211*R_213[0]; double PR_010000012101=P_010000012*R_101[0]+-1*P_010000112*R_102[0]+P_010000212*R_103[0]+-1*P_010000312*R_104[0]+-1*P_110000012*R_201[0]+P_110000112*R_202[0]+-1*P_110000212*R_203[0]+P_110000312*R_204[0]; double PR_002010010101=P_002010010*R_101[0]+-1*P_002010110*R_102[0]+-1*P_002110010*R_111[0]+P_002110110*R_112[0]+-1*P_102010010*R_201[0]+P_102010110*R_202[0]+P_102110010*R_211[0]+-1*P_102110110*R_212[0]+P_202010010*R_301[0]+-1*P_202010110*R_302[0]+-1*P_202110010*R_311[0]+P_202110110*R_312[0]; double PR_001011010101=P_001011010*R_101[0]+-1*P_001011110*R_102[0]+-1*P_001111010*R_111[0]+P_001111110*R_112[0]+P_001211010*R_121[0]+-1*P_001211110*R_122[0]+-1*P_101011010*R_201[0]+P_101011110*R_202[0]+P_101111010*R_211[0]+-1*P_101111110*R_212[0]+-1*P_101211010*R_221[0]+P_101211110*R_222[0]; double PR_000012010101=P_000012010*R_101[0]+-1*P_000012110*R_102[0]+-1*P_000112010*R_111[0]+P_000112110*R_112[0]+P_000212010*R_121[0]+-1*P_000212110*R_122[0]+-1*P_000312010*R_131[0]+P_000312110*R_132[0]; double PR_001010011101=P_001010011*R_101[0]+-1*P_001010111*R_102[0]+P_001010211*R_103[0]+-1*P_001110011*R_111[0]+P_001110111*R_112[0]+-1*P_001110211*R_113[0]+-1*P_101010011*R_201[0]+P_101010111*R_202[0]+-1*P_101010211*R_203[0]+P_101110011*R_211[0]+-1*P_101110111*R_212[0]+P_101110211*R_213[0]; double PR_000011011101=P_000011011*R_101[0]+-1*P_000011111*R_102[0]+P_000011211*R_103[0]+-1*P_000111011*R_111[0]+P_000111111*R_112[0]+-1*P_000111211*R_113[0]+P_000211011*R_121[0]+-1*P_000211111*R_122[0]+P_000211211*R_123[0]; double PR_000010012101=P_000010012*R_101[0]+-1*P_000010112*R_102[0]+P_000010212*R_103[0]+-1*P_000010312*R_104[0]+-1*P_000110012*R_111[0]+P_000110112*R_112[0]+-1*P_000110212*R_113[0]+P_000110312*R_114[0]; double PR_002000020101=P_002000020*R_101[0]+-1*P_002000120*R_102[0]+P_002000220*R_103[0]+-1*P_102000020*R_201[0]+P_102000120*R_202[0]+-1*P_102000220*R_203[0]+P_202000020*R_301[0]+-1*P_202000120*R_302[0]+P_202000220*R_303[0]; double PR_001001020101=P_001001020*R_101[0]+-1*P_001001120*R_102[0]+P_001001220*R_103[0]+-1*P_001101020*R_111[0]+P_001101120*R_112[0]+-1*P_001101220*R_113[0]+-1*P_101001020*R_201[0]+P_101001120*R_202[0]+-1*P_101001220*R_203[0]+P_101101020*R_211[0]+-1*P_101101120*R_212[0]+P_101101220*R_213[0]; double PR_000002020101=P_000002020*R_101[0]+-1*P_000002120*R_102[0]+P_000002220*R_103[0]+-1*P_000102020*R_111[0]+P_000102120*R_112[0]+-1*P_000102220*R_113[0]+P_000202020*R_121[0]+-1*P_000202120*R_122[0]+P_000202220*R_123[0]; double PR_001000021101=P_001000021*R_101[0]+-1*P_001000121*R_102[0]+P_001000221*R_103[0]+-1*P_001000321*R_104[0]+-1*P_101000021*R_201[0]+P_101000121*R_202[0]+-1*P_101000221*R_203[0]+P_101000321*R_204[0]; double PR_000001021101=P_000001021*R_101[0]+-1*P_000001121*R_102[0]+P_000001221*R_103[0]+-1*P_000001321*R_104[0]+-1*P_000101021*R_111[0]+P_000101121*R_112[0]+-1*P_000101221*R_113[0]+P_000101321*R_114[0]; double PR_000000022101=P_000000022*R_101[0]+-1*P_000000122*R_102[0]+P_000000222*R_103[0]+-1*P_000000322*R_104[0]+P_000000422*R_105[0]; double PR_022000000110=P_022000000*R_110[0]+-1*P_122000000*R_210[0]+P_222000000*R_310[0]+-1*P_322000000*R_410[0]+P_422000000*R_510[0]; double PR_021001000110=P_021001000*R_110[0]+-1*P_021101000*R_120[0]+-1*P_121001000*R_210[0]+P_121101000*R_220[0]+P_221001000*R_310[0]+-1*P_221101000*R_320[0]+-1*P_321001000*R_410[0]+P_321101000*R_420[0]; double PR_020002000110=P_020002000*R_110[0]+-1*P_020102000*R_120[0]+P_020202000*R_130[0]+-1*P_120002000*R_210[0]+P_120102000*R_220[0]+-1*P_120202000*R_230[0]+P_220002000*R_310[0]+-1*P_220102000*R_320[0]+P_220202000*R_330[0]; double PR_021000001110=P_021000001*R_110[0]+-1*P_021000101*R_111[0]+-1*P_121000001*R_210[0]+P_121000101*R_211[0]+P_221000001*R_310[0]+-1*P_221000101*R_311[0]+-1*P_321000001*R_410[0]+P_321000101*R_411[0]; double PR_020001001110=P_020001001*R_110[0]+-1*P_020001101*R_111[0]+-1*P_020101001*R_120[0]+P_020101101*R_121[0]+-1*P_120001001*R_210[0]+P_120001101*R_211[0]+P_120101001*R_220[0]+-1*P_120101101*R_221[0]+P_220001001*R_310[0]+-1*P_220001101*R_311[0]+-1*P_220101001*R_320[0]+P_220101101*R_321[0]; double PR_020000002110=P_020000002*R_110[0]+-1*P_020000102*R_111[0]+P_020000202*R_112[0]+-1*P_120000002*R_210[0]+P_120000102*R_211[0]+-1*P_120000202*R_212[0]+P_220000002*R_310[0]+-1*P_220000102*R_311[0]+P_220000202*R_312[0]; double PR_012010000110=P_012010000*R_110[0]+-1*P_012110000*R_120[0]+-1*P_112010000*R_210[0]+P_112110000*R_220[0]+P_212010000*R_310[0]+-1*P_212110000*R_320[0]+-1*P_312010000*R_410[0]+P_312110000*R_420[0]; double PR_011011000110=P_011011000*R_110[0]+-1*P_011111000*R_120[0]+P_011211000*R_130[0]+-1*P_111011000*R_210[0]+P_111111000*R_220[0]+-1*P_111211000*R_230[0]+P_211011000*R_310[0]+-1*P_211111000*R_320[0]+P_211211000*R_330[0]; double PR_010012000110=P_010012000*R_110[0]+-1*P_010112000*R_120[0]+P_010212000*R_130[0]+-1*P_010312000*R_140[0]+-1*P_110012000*R_210[0]+P_110112000*R_220[0]+-1*P_110212000*R_230[0]+P_110312000*R_240[0]; double PR_011010001110=P_011010001*R_110[0]+-1*P_011010101*R_111[0]+-1*P_011110001*R_120[0]+P_011110101*R_121[0]+-1*P_111010001*R_210[0]+P_111010101*R_211[0]+P_111110001*R_220[0]+-1*P_111110101*R_221[0]+P_211010001*R_310[0]+-1*P_211010101*R_311[0]+-1*P_211110001*R_320[0]+P_211110101*R_321[0]; double PR_010011001110=P_010011001*R_110[0]+-1*P_010011101*R_111[0]+-1*P_010111001*R_120[0]+P_010111101*R_121[0]+P_010211001*R_130[0]+-1*P_010211101*R_131[0]+-1*P_110011001*R_210[0]+P_110011101*R_211[0]+P_110111001*R_220[0]+-1*P_110111101*R_221[0]+-1*P_110211001*R_230[0]+P_110211101*R_231[0]; double PR_010010002110=P_010010002*R_110[0]+-1*P_010010102*R_111[0]+P_010010202*R_112[0]+-1*P_010110002*R_120[0]+P_010110102*R_121[0]+-1*P_010110202*R_122[0]+-1*P_110010002*R_210[0]+P_110010102*R_211[0]+-1*P_110010202*R_212[0]+P_110110002*R_220[0]+-1*P_110110102*R_221[0]+P_110110202*R_222[0]; double PR_002020000110=P_002020000*R_110[0]+-1*P_002120000*R_120[0]+P_002220000*R_130[0]+-1*P_102020000*R_210[0]+P_102120000*R_220[0]+-1*P_102220000*R_230[0]+P_202020000*R_310[0]+-1*P_202120000*R_320[0]+P_202220000*R_330[0]; double PR_001021000110=P_001021000*R_110[0]+-1*P_001121000*R_120[0]+P_001221000*R_130[0]+-1*P_001321000*R_140[0]+-1*P_101021000*R_210[0]+P_101121000*R_220[0]+-1*P_101221000*R_230[0]+P_101321000*R_240[0]; double PR_000022000110=P_000022000*R_110[0]+-1*P_000122000*R_120[0]+P_000222000*R_130[0]+-1*P_000322000*R_140[0]+P_000422000*R_150[0]; double PR_001020001110=P_001020001*R_110[0]+-1*P_001020101*R_111[0]+-1*P_001120001*R_120[0]+P_001120101*R_121[0]+P_001220001*R_130[0]+-1*P_001220101*R_131[0]+-1*P_101020001*R_210[0]+P_101020101*R_211[0]+P_101120001*R_220[0]+-1*P_101120101*R_221[0]+-1*P_101220001*R_230[0]+P_101220101*R_231[0]; double PR_000021001110=P_000021001*R_110[0]+-1*P_000021101*R_111[0]+-1*P_000121001*R_120[0]+P_000121101*R_121[0]+P_000221001*R_130[0]+-1*P_000221101*R_131[0]+-1*P_000321001*R_140[0]+P_000321101*R_141[0]; double PR_000020002110=P_000020002*R_110[0]+-1*P_000020102*R_111[0]+P_000020202*R_112[0]+-1*P_000120002*R_120[0]+P_000120102*R_121[0]+-1*P_000120202*R_122[0]+P_000220002*R_130[0]+-1*P_000220102*R_131[0]+P_000220202*R_132[0]; double PR_012000010110=P_012000010*R_110[0]+-1*P_012000110*R_111[0]+-1*P_112000010*R_210[0]+P_112000110*R_211[0]+P_212000010*R_310[0]+-1*P_212000110*R_311[0]+-1*P_312000010*R_410[0]+P_312000110*R_411[0]; double PR_011001010110=P_011001010*R_110[0]+-1*P_011001110*R_111[0]+-1*P_011101010*R_120[0]+P_011101110*R_121[0]+-1*P_111001010*R_210[0]+P_111001110*R_211[0]+P_111101010*R_220[0]+-1*P_111101110*R_221[0]+P_211001010*R_310[0]+-1*P_211001110*R_311[0]+-1*P_211101010*R_320[0]+P_211101110*R_321[0]; double PR_010002010110=P_010002010*R_110[0]+-1*P_010002110*R_111[0]+-1*P_010102010*R_120[0]+P_010102110*R_121[0]+P_010202010*R_130[0]+-1*P_010202110*R_131[0]+-1*P_110002010*R_210[0]+P_110002110*R_211[0]+P_110102010*R_220[0]+-1*P_110102110*R_221[0]+-1*P_110202010*R_230[0]+P_110202110*R_231[0]; double PR_011000011110=P_011000011*R_110[0]+-1*P_011000111*R_111[0]+P_011000211*R_112[0]+-1*P_111000011*R_210[0]+P_111000111*R_211[0]+-1*P_111000211*R_212[0]+P_211000011*R_310[0]+-1*P_211000111*R_311[0]+P_211000211*R_312[0]; double PR_010001011110=P_010001011*R_110[0]+-1*P_010001111*R_111[0]+P_010001211*R_112[0]+-1*P_010101011*R_120[0]+P_010101111*R_121[0]+-1*P_010101211*R_122[0]+-1*P_110001011*R_210[0]+P_110001111*R_211[0]+-1*P_110001211*R_212[0]+P_110101011*R_220[0]+-1*P_110101111*R_221[0]+P_110101211*R_222[0]; double PR_010000012110=P_010000012*R_110[0]+-1*P_010000112*R_111[0]+P_010000212*R_112[0]+-1*P_010000312*R_113[0]+-1*P_110000012*R_210[0]+P_110000112*R_211[0]+-1*P_110000212*R_212[0]+P_110000312*R_213[0]; double PR_002010010110=P_002010010*R_110[0]+-1*P_002010110*R_111[0]+-1*P_002110010*R_120[0]+P_002110110*R_121[0]+-1*P_102010010*R_210[0]+P_102010110*R_211[0]+P_102110010*R_220[0]+-1*P_102110110*R_221[0]+P_202010010*R_310[0]+-1*P_202010110*R_311[0]+-1*P_202110010*R_320[0]+P_202110110*R_321[0]; double PR_001011010110=P_001011010*R_110[0]+-1*P_001011110*R_111[0]+-1*P_001111010*R_120[0]+P_001111110*R_121[0]+P_001211010*R_130[0]+-1*P_001211110*R_131[0]+-1*P_101011010*R_210[0]+P_101011110*R_211[0]+P_101111010*R_220[0]+-1*P_101111110*R_221[0]+-1*P_101211010*R_230[0]+P_101211110*R_231[0]; double PR_000012010110=P_000012010*R_110[0]+-1*P_000012110*R_111[0]+-1*P_000112010*R_120[0]+P_000112110*R_121[0]+P_000212010*R_130[0]+-1*P_000212110*R_131[0]+-1*P_000312010*R_140[0]+P_000312110*R_141[0]; double PR_001010011110=P_001010011*R_110[0]+-1*P_001010111*R_111[0]+P_001010211*R_112[0]+-1*P_001110011*R_120[0]+P_001110111*R_121[0]+-1*P_001110211*R_122[0]+-1*P_101010011*R_210[0]+P_101010111*R_211[0]+-1*P_101010211*R_212[0]+P_101110011*R_220[0]+-1*P_101110111*R_221[0]+P_101110211*R_222[0]; double PR_000011011110=P_000011011*R_110[0]+-1*P_000011111*R_111[0]+P_000011211*R_112[0]+-1*P_000111011*R_120[0]+P_000111111*R_121[0]+-1*P_000111211*R_122[0]+P_000211011*R_130[0]+-1*P_000211111*R_131[0]+P_000211211*R_132[0]; double PR_000010012110=P_000010012*R_110[0]+-1*P_000010112*R_111[0]+P_000010212*R_112[0]+-1*P_000010312*R_113[0]+-1*P_000110012*R_120[0]+P_000110112*R_121[0]+-1*P_000110212*R_122[0]+P_000110312*R_123[0]; double PR_002000020110=P_002000020*R_110[0]+-1*P_002000120*R_111[0]+P_002000220*R_112[0]+-1*P_102000020*R_210[0]+P_102000120*R_211[0]+-1*P_102000220*R_212[0]+P_202000020*R_310[0]+-1*P_202000120*R_311[0]+P_202000220*R_312[0]; double PR_001001020110=P_001001020*R_110[0]+-1*P_001001120*R_111[0]+P_001001220*R_112[0]+-1*P_001101020*R_120[0]+P_001101120*R_121[0]+-1*P_001101220*R_122[0]+-1*P_101001020*R_210[0]+P_101001120*R_211[0]+-1*P_101001220*R_212[0]+P_101101020*R_220[0]+-1*P_101101120*R_221[0]+P_101101220*R_222[0]; double PR_000002020110=P_000002020*R_110[0]+-1*P_000002120*R_111[0]+P_000002220*R_112[0]+-1*P_000102020*R_120[0]+P_000102120*R_121[0]+-1*P_000102220*R_122[0]+P_000202020*R_130[0]+-1*P_000202120*R_131[0]+P_000202220*R_132[0]; double PR_001000021110=P_001000021*R_110[0]+-1*P_001000121*R_111[0]+P_001000221*R_112[0]+-1*P_001000321*R_113[0]+-1*P_101000021*R_210[0]+P_101000121*R_211[0]+-1*P_101000221*R_212[0]+P_101000321*R_213[0]; double PR_000001021110=P_000001021*R_110[0]+-1*P_000001121*R_111[0]+P_000001221*R_112[0]+-1*P_000001321*R_113[0]+-1*P_000101021*R_120[0]+P_000101121*R_121[0]+-1*P_000101221*R_122[0]+P_000101321*R_123[0]; double PR_000000022110=P_000000022*R_110[0]+-1*P_000000122*R_111[0]+P_000000222*R_112[0]+-1*P_000000322*R_113[0]+P_000000422*R_114[0]; double PR_022000000200=P_022000000*R_200[0]+-1*P_122000000*R_300[0]+P_222000000*R_400[0]+-1*P_322000000*R_500[0]+P_422000000*R_600[0]; double PR_021001000200=P_021001000*R_200[0]+-1*P_021101000*R_210[0]+-1*P_121001000*R_300[0]+P_121101000*R_310[0]+P_221001000*R_400[0]+-1*P_221101000*R_410[0]+-1*P_321001000*R_500[0]+P_321101000*R_510[0]; double PR_020002000200=P_020002000*R_200[0]+-1*P_020102000*R_210[0]+P_020202000*R_220[0]+-1*P_120002000*R_300[0]+P_120102000*R_310[0]+-1*P_120202000*R_320[0]+P_220002000*R_400[0]+-1*P_220102000*R_410[0]+P_220202000*R_420[0]; double PR_021000001200=P_021000001*R_200[0]+-1*P_021000101*R_201[0]+-1*P_121000001*R_300[0]+P_121000101*R_301[0]+P_221000001*R_400[0]+-1*P_221000101*R_401[0]+-1*P_321000001*R_500[0]+P_321000101*R_501[0]; double PR_020001001200=P_020001001*R_200[0]+-1*P_020001101*R_201[0]+-1*P_020101001*R_210[0]+P_020101101*R_211[0]+-1*P_120001001*R_300[0]+P_120001101*R_301[0]+P_120101001*R_310[0]+-1*P_120101101*R_311[0]+P_220001001*R_400[0]+-1*P_220001101*R_401[0]+-1*P_220101001*R_410[0]+P_220101101*R_411[0]; double PR_020000002200=P_020000002*R_200[0]+-1*P_020000102*R_201[0]+P_020000202*R_202[0]+-1*P_120000002*R_300[0]+P_120000102*R_301[0]+-1*P_120000202*R_302[0]+P_220000002*R_400[0]+-1*P_220000102*R_401[0]+P_220000202*R_402[0]; double PR_012010000200=P_012010000*R_200[0]+-1*P_012110000*R_210[0]+-1*P_112010000*R_300[0]+P_112110000*R_310[0]+P_212010000*R_400[0]+-1*P_212110000*R_410[0]+-1*P_312010000*R_500[0]+P_312110000*R_510[0]; double PR_011011000200=P_011011000*R_200[0]+-1*P_011111000*R_210[0]+P_011211000*R_220[0]+-1*P_111011000*R_300[0]+P_111111000*R_310[0]+-1*P_111211000*R_320[0]+P_211011000*R_400[0]+-1*P_211111000*R_410[0]+P_211211000*R_420[0]; double PR_010012000200=P_010012000*R_200[0]+-1*P_010112000*R_210[0]+P_010212000*R_220[0]+-1*P_010312000*R_230[0]+-1*P_110012000*R_300[0]+P_110112000*R_310[0]+-1*P_110212000*R_320[0]+P_110312000*R_330[0]; double PR_011010001200=P_011010001*R_200[0]+-1*P_011010101*R_201[0]+-1*P_011110001*R_210[0]+P_011110101*R_211[0]+-1*P_111010001*R_300[0]+P_111010101*R_301[0]+P_111110001*R_310[0]+-1*P_111110101*R_311[0]+P_211010001*R_400[0]+-1*P_211010101*R_401[0]+-1*P_211110001*R_410[0]+P_211110101*R_411[0]; double PR_010011001200=P_010011001*R_200[0]+-1*P_010011101*R_201[0]+-1*P_010111001*R_210[0]+P_010111101*R_211[0]+P_010211001*R_220[0]+-1*P_010211101*R_221[0]+-1*P_110011001*R_300[0]+P_110011101*R_301[0]+P_110111001*R_310[0]+-1*P_110111101*R_311[0]+-1*P_110211001*R_320[0]+P_110211101*R_321[0]; double PR_010010002200=P_010010002*R_200[0]+-1*P_010010102*R_201[0]+P_010010202*R_202[0]+-1*P_010110002*R_210[0]+P_010110102*R_211[0]+-1*P_010110202*R_212[0]+-1*P_110010002*R_300[0]+P_110010102*R_301[0]+-1*P_110010202*R_302[0]+P_110110002*R_310[0]+-1*P_110110102*R_311[0]+P_110110202*R_312[0]; double PR_002020000200=P_002020000*R_200[0]+-1*P_002120000*R_210[0]+P_002220000*R_220[0]+-1*P_102020000*R_300[0]+P_102120000*R_310[0]+-1*P_102220000*R_320[0]+P_202020000*R_400[0]+-1*P_202120000*R_410[0]+P_202220000*R_420[0]; double PR_001021000200=P_001021000*R_200[0]+-1*P_001121000*R_210[0]+P_001221000*R_220[0]+-1*P_001321000*R_230[0]+-1*P_101021000*R_300[0]+P_101121000*R_310[0]+-1*P_101221000*R_320[0]+P_101321000*R_330[0]; double PR_000022000200=P_000022000*R_200[0]+-1*P_000122000*R_210[0]+P_000222000*R_220[0]+-1*P_000322000*R_230[0]+P_000422000*R_240[0]; double PR_001020001200=P_001020001*R_200[0]+-1*P_001020101*R_201[0]+-1*P_001120001*R_210[0]+P_001120101*R_211[0]+P_001220001*R_220[0]+-1*P_001220101*R_221[0]+-1*P_101020001*R_300[0]+P_101020101*R_301[0]+P_101120001*R_310[0]+-1*P_101120101*R_311[0]+-1*P_101220001*R_320[0]+P_101220101*R_321[0]; double PR_000021001200=P_000021001*R_200[0]+-1*P_000021101*R_201[0]+-1*P_000121001*R_210[0]+P_000121101*R_211[0]+P_000221001*R_220[0]+-1*P_000221101*R_221[0]+-1*P_000321001*R_230[0]+P_000321101*R_231[0]; double PR_000020002200=P_000020002*R_200[0]+-1*P_000020102*R_201[0]+P_000020202*R_202[0]+-1*P_000120002*R_210[0]+P_000120102*R_211[0]+-1*P_000120202*R_212[0]+P_000220002*R_220[0]+-1*P_000220102*R_221[0]+P_000220202*R_222[0]; double PR_012000010200=P_012000010*R_200[0]+-1*P_012000110*R_201[0]+-1*P_112000010*R_300[0]+P_112000110*R_301[0]+P_212000010*R_400[0]+-1*P_212000110*R_401[0]+-1*P_312000010*R_500[0]+P_312000110*R_501[0]; double PR_011001010200=P_011001010*R_200[0]+-1*P_011001110*R_201[0]+-1*P_011101010*R_210[0]+P_011101110*R_211[0]+-1*P_111001010*R_300[0]+P_111001110*R_301[0]+P_111101010*R_310[0]+-1*P_111101110*R_311[0]+P_211001010*R_400[0]+-1*P_211001110*R_401[0]+-1*P_211101010*R_410[0]+P_211101110*R_411[0]; double PR_010002010200=P_010002010*R_200[0]+-1*P_010002110*R_201[0]+-1*P_010102010*R_210[0]+P_010102110*R_211[0]+P_010202010*R_220[0]+-1*P_010202110*R_221[0]+-1*P_110002010*R_300[0]+P_110002110*R_301[0]+P_110102010*R_310[0]+-1*P_110102110*R_311[0]+-1*P_110202010*R_320[0]+P_110202110*R_321[0]; double PR_011000011200=P_011000011*R_200[0]+-1*P_011000111*R_201[0]+P_011000211*R_202[0]+-1*P_111000011*R_300[0]+P_111000111*R_301[0]+-1*P_111000211*R_302[0]+P_211000011*R_400[0]+-1*P_211000111*R_401[0]+P_211000211*R_402[0]; double PR_010001011200=P_010001011*R_200[0]+-1*P_010001111*R_201[0]+P_010001211*R_202[0]+-1*P_010101011*R_210[0]+P_010101111*R_211[0]+-1*P_010101211*R_212[0]+-1*P_110001011*R_300[0]+P_110001111*R_301[0]+-1*P_110001211*R_302[0]+P_110101011*R_310[0]+-1*P_110101111*R_311[0]+P_110101211*R_312[0]; double PR_010000012200=P_010000012*R_200[0]+-1*P_010000112*R_201[0]+P_010000212*R_202[0]+-1*P_010000312*R_203[0]+-1*P_110000012*R_300[0]+P_110000112*R_301[0]+-1*P_110000212*R_302[0]+P_110000312*R_303[0]; double PR_002010010200=P_002010010*R_200[0]+-1*P_002010110*R_201[0]+-1*P_002110010*R_210[0]+P_002110110*R_211[0]+-1*P_102010010*R_300[0]+P_102010110*R_301[0]+P_102110010*R_310[0]+-1*P_102110110*R_311[0]+P_202010010*R_400[0]+-1*P_202010110*R_401[0]+-1*P_202110010*R_410[0]+P_202110110*R_411[0]; double PR_001011010200=P_001011010*R_200[0]+-1*P_001011110*R_201[0]+-1*P_001111010*R_210[0]+P_001111110*R_211[0]+P_001211010*R_220[0]+-1*P_001211110*R_221[0]+-1*P_101011010*R_300[0]+P_101011110*R_301[0]+P_101111010*R_310[0]+-1*P_101111110*R_311[0]+-1*P_101211010*R_320[0]+P_101211110*R_321[0]; double PR_000012010200=P_000012010*R_200[0]+-1*P_000012110*R_201[0]+-1*P_000112010*R_210[0]+P_000112110*R_211[0]+P_000212010*R_220[0]+-1*P_000212110*R_221[0]+-1*P_000312010*R_230[0]+P_000312110*R_231[0]; double PR_001010011200=P_001010011*R_200[0]+-1*P_001010111*R_201[0]+P_001010211*R_202[0]+-1*P_001110011*R_210[0]+P_001110111*R_211[0]+-1*P_001110211*R_212[0]+-1*P_101010011*R_300[0]+P_101010111*R_301[0]+-1*P_101010211*R_302[0]+P_101110011*R_310[0]+-1*P_101110111*R_311[0]+P_101110211*R_312[0]; double PR_000011011200=P_000011011*R_200[0]+-1*P_000011111*R_201[0]+P_000011211*R_202[0]+-1*P_000111011*R_210[0]+P_000111111*R_211[0]+-1*P_000111211*R_212[0]+P_000211011*R_220[0]+-1*P_000211111*R_221[0]+P_000211211*R_222[0]; double PR_000010012200=P_000010012*R_200[0]+-1*P_000010112*R_201[0]+P_000010212*R_202[0]+-1*P_000010312*R_203[0]+-1*P_000110012*R_210[0]+P_000110112*R_211[0]+-1*P_000110212*R_212[0]+P_000110312*R_213[0]; double PR_002000020200=P_002000020*R_200[0]+-1*P_002000120*R_201[0]+P_002000220*R_202[0]+-1*P_102000020*R_300[0]+P_102000120*R_301[0]+-1*P_102000220*R_302[0]+P_202000020*R_400[0]+-1*P_202000120*R_401[0]+P_202000220*R_402[0]; double PR_001001020200=P_001001020*R_200[0]+-1*P_001001120*R_201[0]+P_001001220*R_202[0]+-1*P_001101020*R_210[0]+P_001101120*R_211[0]+-1*P_001101220*R_212[0]+-1*P_101001020*R_300[0]+P_101001120*R_301[0]+-1*P_101001220*R_302[0]+P_101101020*R_310[0]+-1*P_101101120*R_311[0]+P_101101220*R_312[0]; double PR_000002020200=P_000002020*R_200[0]+-1*P_000002120*R_201[0]+P_000002220*R_202[0]+-1*P_000102020*R_210[0]+P_000102120*R_211[0]+-1*P_000102220*R_212[0]+P_000202020*R_220[0]+-1*P_000202120*R_221[0]+P_000202220*R_222[0]; double PR_001000021200=P_001000021*R_200[0]+-1*P_001000121*R_201[0]+P_001000221*R_202[0]+-1*P_001000321*R_203[0]+-1*P_101000021*R_300[0]+P_101000121*R_301[0]+-1*P_101000221*R_302[0]+P_101000321*R_303[0]; double PR_000001021200=P_000001021*R_200[0]+-1*P_000001121*R_201[0]+P_000001221*R_202[0]+-1*P_000001321*R_203[0]+-1*P_000101021*R_210[0]+P_000101121*R_211[0]+-1*P_000101221*R_212[0]+P_000101321*R_213[0]; double PR_000000022200=P_000000022*R_200[0]+-1*P_000000122*R_201[0]+P_000000222*R_202[0]+-1*P_000000322*R_203[0]+P_000000422*R_204[0]; double PR_022000000003=P_022000000*R_003[0]+-1*P_122000000*R_103[0]+P_222000000*R_203[0]+-1*P_322000000*R_303[0]+P_422000000*R_403[0]; double PR_021001000003=P_021001000*R_003[0]+-1*P_021101000*R_013[0]+-1*P_121001000*R_103[0]+P_121101000*R_113[0]+P_221001000*R_203[0]+-1*P_221101000*R_213[0]+-1*P_321001000*R_303[0]+P_321101000*R_313[0]; double PR_020002000003=P_020002000*R_003[0]+-1*P_020102000*R_013[0]+P_020202000*R_023[0]+-1*P_120002000*R_103[0]+P_120102000*R_113[0]+-1*P_120202000*R_123[0]+P_220002000*R_203[0]+-1*P_220102000*R_213[0]+P_220202000*R_223[0]; double PR_021000001003=P_021000001*R_003[0]+-1*P_021000101*R_004[0]+-1*P_121000001*R_103[0]+P_121000101*R_104[0]+P_221000001*R_203[0]+-1*P_221000101*R_204[0]+-1*P_321000001*R_303[0]+P_321000101*R_304[0]; double PR_020001001003=P_020001001*R_003[0]+-1*P_020001101*R_004[0]+-1*P_020101001*R_013[0]+P_020101101*R_014[0]+-1*P_120001001*R_103[0]+P_120001101*R_104[0]+P_120101001*R_113[0]+-1*P_120101101*R_114[0]+P_220001001*R_203[0]+-1*P_220001101*R_204[0]+-1*P_220101001*R_213[0]+P_220101101*R_214[0]; double PR_020000002003=P_020000002*R_003[0]+-1*P_020000102*R_004[0]+P_020000202*R_005[0]+-1*P_120000002*R_103[0]+P_120000102*R_104[0]+-1*P_120000202*R_105[0]+P_220000002*R_203[0]+-1*P_220000102*R_204[0]+P_220000202*R_205[0]; double PR_012010000003=P_012010000*R_003[0]+-1*P_012110000*R_013[0]+-1*P_112010000*R_103[0]+P_112110000*R_113[0]+P_212010000*R_203[0]+-1*P_212110000*R_213[0]+-1*P_312010000*R_303[0]+P_312110000*R_313[0]; double PR_011011000003=P_011011000*R_003[0]+-1*P_011111000*R_013[0]+P_011211000*R_023[0]+-1*P_111011000*R_103[0]+P_111111000*R_113[0]+-1*P_111211000*R_123[0]+P_211011000*R_203[0]+-1*P_211111000*R_213[0]+P_211211000*R_223[0]; double PR_010012000003=P_010012000*R_003[0]+-1*P_010112000*R_013[0]+P_010212000*R_023[0]+-1*P_010312000*R_033[0]+-1*P_110012000*R_103[0]+P_110112000*R_113[0]+-1*P_110212000*R_123[0]+P_110312000*R_133[0]; double PR_011010001003=P_011010001*R_003[0]+-1*P_011010101*R_004[0]+-1*P_011110001*R_013[0]+P_011110101*R_014[0]+-1*P_111010001*R_103[0]+P_111010101*R_104[0]+P_111110001*R_113[0]+-1*P_111110101*R_114[0]+P_211010001*R_203[0]+-1*P_211010101*R_204[0]+-1*P_211110001*R_213[0]+P_211110101*R_214[0]; double PR_010011001003=P_010011001*R_003[0]+-1*P_010011101*R_004[0]+-1*P_010111001*R_013[0]+P_010111101*R_014[0]+P_010211001*R_023[0]+-1*P_010211101*R_024[0]+-1*P_110011001*R_103[0]+P_110011101*R_104[0]+P_110111001*R_113[0]+-1*P_110111101*R_114[0]+-1*P_110211001*R_123[0]+P_110211101*R_124[0]; double PR_010010002003=P_010010002*R_003[0]+-1*P_010010102*R_004[0]+P_010010202*R_005[0]+-1*P_010110002*R_013[0]+P_010110102*R_014[0]+-1*P_010110202*R_015[0]+-1*P_110010002*R_103[0]+P_110010102*R_104[0]+-1*P_110010202*R_105[0]+P_110110002*R_113[0]+-1*P_110110102*R_114[0]+P_110110202*R_115[0]; double PR_002020000003=P_002020000*R_003[0]+-1*P_002120000*R_013[0]+P_002220000*R_023[0]+-1*P_102020000*R_103[0]+P_102120000*R_113[0]+-1*P_102220000*R_123[0]+P_202020000*R_203[0]+-1*P_202120000*R_213[0]+P_202220000*R_223[0]; double PR_001021000003=P_001021000*R_003[0]+-1*P_001121000*R_013[0]+P_001221000*R_023[0]+-1*P_001321000*R_033[0]+-1*P_101021000*R_103[0]+P_101121000*R_113[0]+-1*P_101221000*R_123[0]+P_101321000*R_133[0]; double PR_000022000003=P_000022000*R_003[0]+-1*P_000122000*R_013[0]+P_000222000*R_023[0]+-1*P_000322000*R_033[0]+P_000422000*R_043[0]; double PR_001020001003=P_001020001*R_003[0]+-1*P_001020101*R_004[0]+-1*P_001120001*R_013[0]+P_001120101*R_014[0]+P_001220001*R_023[0]+-1*P_001220101*R_024[0]+-1*P_101020001*R_103[0]+P_101020101*R_104[0]+P_101120001*R_113[0]+-1*P_101120101*R_114[0]+-1*P_101220001*R_123[0]+P_101220101*R_124[0]; double PR_000021001003=P_000021001*R_003[0]+-1*P_000021101*R_004[0]+-1*P_000121001*R_013[0]+P_000121101*R_014[0]+P_000221001*R_023[0]+-1*P_000221101*R_024[0]+-1*P_000321001*R_033[0]+P_000321101*R_034[0]; double PR_000020002003=P_000020002*R_003[0]+-1*P_000020102*R_004[0]+P_000020202*R_005[0]+-1*P_000120002*R_013[0]+P_000120102*R_014[0]+-1*P_000120202*R_015[0]+P_000220002*R_023[0]+-1*P_000220102*R_024[0]+P_000220202*R_025[0]; double PR_012000010003=P_012000010*R_003[0]+-1*P_012000110*R_004[0]+-1*P_112000010*R_103[0]+P_112000110*R_104[0]+P_212000010*R_203[0]+-1*P_212000110*R_204[0]+-1*P_312000010*R_303[0]+P_312000110*R_304[0]; double PR_011001010003=P_011001010*R_003[0]+-1*P_011001110*R_004[0]+-1*P_011101010*R_013[0]+P_011101110*R_014[0]+-1*P_111001010*R_103[0]+P_111001110*R_104[0]+P_111101010*R_113[0]+-1*P_111101110*R_114[0]+P_211001010*R_203[0]+-1*P_211001110*R_204[0]+-1*P_211101010*R_213[0]+P_211101110*R_214[0]; double PR_010002010003=P_010002010*R_003[0]+-1*P_010002110*R_004[0]+-1*P_010102010*R_013[0]+P_010102110*R_014[0]+P_010202010*R_023[0]+-1*P_010202110*R_024[0]+-1*P_110002010*R_103[0]+P_110002110*R_104[0]+P_110102010*R_113[0]+-1*P_110102110*R_114[0]+-1*P_110202010*R_123[0]+P_110202110*R_124[0]; double PR_011000011003=P_011000011*R_003[0]+-1*P_011000111*R_004[0]+P_011000211*R_005[0]+-1*P_111000011*R_103[0]+P_111000111*R_104[0]+-1*P_111000211*R_105[0]+P_211000011*R_203[0]+-1*P_211000111*R_204[0]+P_211000211*R_205[0]; double PR_010001011003=P_010001011*R_003[0]+-1*P_010001111*R_004[0]+P_010001211*R_005[0]+-1*P_010101011*R_013[0]+P_010101111*R_014[0]+-1*P_010101211*R_015[0]+-1*P_110001011*R_103[0]+P_110001111*R_104[0]+-1*P_110001211*R_105[0]+P_110101011*R_113[0]+-1*P_110101111*R_114[0]+P_110101211*R_115[0]; double PR_010000012003=P_010000012*R_003[0]+-1*P_010000112*R_004[0]+P_010000212*R_005[0]+-1*P_010000312*R_006[0]+-1*P_110000012*R_103[0]+P_110000112*R_104[0]+-1*P_110000212*R_105[0]+P_110000312*R_106[0]; double PR_002010010003=P_002010010*R_003[0]+-1*P_002010110*R_004[0]+-1*P_002110010*R_013[0]+P_002110110*R_014[0]+-1*P_102010010*R_103[0]+P_102010110*R_104[0]+P_102110010*R_113[0]+-1*P_102110110*R_114[0]+P_202010010*R_203[0]+-1*P_202010110*R_204[0]+-1*P_202110010*R_213[0]+P_202110110*R_214[0]; double PR_001011010003=P_001011010*R_003[0]+-1*P_001011110*R_004[0]+-1*P_001111010*R_013[0]+P_001111110*R_014[0]+P_001211010*R_023[0]+-1*P_001211110*R_024[0]+-1*P_101011010*R_103[0]+P_101011110*R_104[0]+P_101111010*R_113[0]+-1*P_101111110*R_114[0]+-1*P_101211010*R_123[0]+P_101211110*R_124[0]; double PR_000012010003=P_000012010*R_003[0]+-1*P_000012110*R_004[0]+-1*P_000112010*R_013[0]+P_000112110*R_014[0]+P_000212010*R_023[0]+-1*P_000212110*R_024[0]+-1*P_000312010*R_033[0]+P_000312110*R_034[0]; double PR_001010011003=P_001010011*R_003[0]+-1*P_001010111*R_004[0]+P_001010211*R_005[0]+-1*P_001110011*R_013[0]+P_001110111*R_014[0]+-1*P_001110211*R_015[0]+-1*P_101010011*R_103[0]+P_101010111*R_104[0]+-1*P_101010211*R_105[0]+P_101110011*R_113[0]+-1*P_101110111*R_114[0]+P_101110211*R_115[0]; double PR_000011011003=P_000011011*R_003[0]+-1*P_000011111*R_004[0]+P_000011211*R_005[0]+-1*P_000111011*R_013[0]+P_000111111*R_014[0]+-1*P_000111211*R_015[0]+P_000211011*R_023[0]+-1*P_000211111*R_024[0]+P_000211211*R_025[0]; double PR_000010012003=P_000010012*R_003[0]+-1*P_000010112*R_004[0]+P_000010212*R_005[0]+-1*P_000010312*R_006[0]+-1*P_000110012*R_013[0]+P_000110112*R_014[0]+-1*P_000110212*R_015[0]+P_000110312*R_016[0]; double PR_002000020003=P_002000020*R_003[0]+-1*P_002000120*R_004[0]+P_002000220*R_005[0]+-1*P_102000020*R_103[0]+P_102000120*R_104[0]+-1*P_102000220*R_105[0]+P_202000020*R_203[0]+-1*P_202000120*R_204[0]+P_202000220*R_205[0]; double PR_001001020003=P_001001020*R_003[0]+-1*P_001001120*R_004[0]+P_001001220*R_005[0]+-1*P_001101020*R_013[0]+P_001101120*R_014[0]+-1*P_001101220*R_015[0]+-1*P_101001020*R_103[0]+P_101001120*R_104[0]+-1*P_101001220*R_105[0]+P_101101020*R_113[0]+-1*P_101101120*R_114[0]+P_101101220*R_115[0]; double PR_000002020003=P_000002020*R_003[0]+-1*P_000002120*R_004[0]+P_000002220*R_005[0]+-1*P_000102020*R_013[0]+P_000102120*R_014[0]+-1*P_000102220*R_015[0]+P_000202020*R_023[0]+-1*P_000202120*R_024[0]+P_000202220*R_025[0]; double PR_001000021003=P_001000021*R_003[0]+-1*P_001000121*R_004[0]+P_001000221*R_005[0]+-1*P_001000321*R_006[0]+-1*P_101000021*R_103[0]+P_101000121*R_104[0]+-1*P_101000221*R_105[0]+P_101000321*R_106[0]; double PR_000001021003=P_000001021*R_003[0]+-1*P_000001121*R_004[0]+P_000001221*R_005[0]+-1*P_000001321*R_006[0]+-1*P_000101021*R_013[0]+P_000101121*R_014[0]+-1*P_000101221*R_015[0]+P_000101321*R_016[0]; double PR_000000022003=P_000000022*R_003[0]+-1*P_000000122*R_004[0]+P_000000222*R_005[0]+-1*P_000000322*R_006[0]+P_000000422*R_007[0]; double PR_022000000012=P_022000000*R_012[0]+-1*P_122000000*R_112[0]+P_222000000*R_212[0]+-1*P_322000000*R_312[0]+P_422000000*R_412[0]; double PR_021001000012=P_021001000*R_012[0]+-1*P_021101000*R_022[0]+-1*P_121001000*R_112[0]+P_121101000*R_122[0]+P_221001000*R_212[0]+-1*P_221101000*R_222[0]+-1*P_321001000*R_312[0]+P_321101000*R_322[0]; double PR_020002000012=P_020002000*R_012[0]+-1*P_020102000*R_022[0]+P_020202000*R_032[0]+-1*P_120002000*R_112[0]+P_120102000*R_122[0]+-1*P_120202000*R_132[0]+P_220002000*R_212[0]+-1*P_220102000*R_222[0]+P_220202000*R_232[0]; double PR_021000001012=P_021000001*R_012[0]+-1*P_021000101*R_013[0]+-1*P_121000001*R_112[0]+P_121000101*R_113[0]+P_221000001*R_212[0]+-1*P_221000101*R_213[0]+-1*P_321000001*R_312[0]+P_321000101*R_313[0]; double PR_020001001012=P_020001001*R_012[0]+-1*P_020001101*R_013[0]+-1*P_020101001*R_022[0]+P_020101101*R_023[0]+-1*P_120001001*R_112[0]+P_120001101*R_113[0]+P_120101001*R_122[0]+-1*P_120101101*R_123[0]+P_220001001*R_212[0]+-1*P_220001101*R_213[0]+-1*P_220101001*R_222[0]+P_220101101*R_223[0]; double PR_020000002012=P_020000002*R_012[0]+-1*P_020000102*R_013[0]+P_020000202*R_014[0]+-1*P_120000002*R_112[0]+P_120000102*R_113[0]+-1*P_120000202*R_114[0]+P_220000002*R_212[0]+-1*P_220000102*R_213[0]+P_220000202*R_214[0]; double PR_012010000012=P_012010000*R_012[0]+-1*P_012110000*R_022[0]+-1*P_112010000*R_112[0]+P_112110000*R_122[0]+P_212010000*R_212[0]+-1*P_212110000*R_222[0]+-1*P_312010000*R_312[0]+P_312110000*R_322[0]; double PR_011011000012=P_011011000*R_012[0]+-1*P_011111000*R_022[0]+P_011211000*R_032[0]+-1*P_111011000*R_112[0]+P_111111000*R_122[0]+-1*P_111211000*R_132[0]+P_211011000*R_212[0]+-1*P_211111000*R_222[0]+P_211211000*R_232[0]; double PR_010012000012=P_010012000*R_012[0]+-1*P_010112000*R_022[0]+P_010212000*R_032[0]+-1*P_010312000*R_042[0]+-1*P_110012000*R_112[0]+P_110112000*R_122[0]+-1*P_110212000*R_132[0]+P_110312000*R_142[0]; double PR_011010001012=P_011010001*R_012[0]+-1*P_011010101*R_013[0]+-1*P_011110001*R_022[0]+P_011110101*R_023[0]+-1*P_111010001*R_112[0]+P_111010101*R_113[0]+P_111110001*R_122[0]+-1*P_111110101*R_123[0]+P_211010001*R_212[0]+-1*P_211010101*R_213[0]+-1*P_211110001*R_222[0]+P_211110101*R_223[0]; double PR_010011001012=P_010011001*R_012[0]+-1*P_010011101*R_013[0]+-1*P_010111001*R_022[0]+P_010111101*R_023[0]+P_010211001*R_032[0]+-1*P_010211101*R_033[0]+-1*P_110011001*R_112[0]+P_110011101*R_113[0]+P_110111001*R_122[0]+-1*P_110111101*R_123[0]+-1*P_110211001*R_132[0]+P_110211101*R_133[0]; double PR_010010002012=P_010010002*R_012[0]+-1*P_010010102*R_013[0]+P_010010202*R_014[0]+-1*P_010110002*R_022[0]+P_010110102*R_023[0]+-1*P_010110202*R_024[0]+-1*P_110010002*R_112[0]+P_110010102*R_113[0]+-1*P_110010202*R_114[0]+P_110110002*R_122[0]+-1*P_110110102*R_123[0]+P_110110202*R_124[0]; double PR_002020000012=P_002020000*R_012[0]+-1*P_002120000*R_022[0]+P_002220000*R_032[0]+-1*P_102020000*R_112[0]+P_102120000*R_122[0]+-1*P_102220000*R_132[0]+P_202020000*R_212[0]+-1*P_202120000*R_222[0]+P_202220000*R_232[0]; double PR_001021000012=P_001021000*R_012[0]+-1*P_001121000*R_022[0]+P_001221000*R_032[0]+-1*P_001321000*R_042[0]+-1*P_101021000*R_112[0]+P_101121000*R_122[0]+-1*P_101221000*R_132[0]+P_101321000*R_142[0]; double PR_000022000012=P_000022000*R_012[0]+-1*P_000122000*R_022[0]+P_000222000*R_032[0]+-1*P_000322000*R_042[0]+P_000422000*R_052[0]; double PR_001020001012=P_001020001*R_012[0]+-1*P_001020101*R_013[0]+-1*P_001120001*R_022[0]+P_001120101*R_023[0]+P_001220001*R_032[0]+-1*P_001220101*R_033[0]+-1*P_101020001*R_112[0]+P_101020101*R_113[0]+P_101120001*R_122[0]+-1*P_101120101*R_123[0]+-1*P_101220001*R_132[0]+P_101220101*R_133[0]; double PR_000021001012=P_000021001*R_012[0]+-1*P_000021101*R_013[0]+-1*P_000121001*R_022[0]+P_000121101*R_023[0]+P_000221001*R_032[0]+-1*P_000221101*R_033[0]+-1*P_000321001*R_042[0]+P_000321101*R_043[0]; double PR_000020002012=P_000020002*R_012[0]+-1*P_000020102*R_013[0]+P_000020202*R_014[0]+-1*P_000120002*R_022[0]+P_000120102*R_023[0]+-1*P_000120202*R_024[0]+P_000220002*R_032[0]+-1*P_000220102*R_033[0]+P_000220202*R_034[0]; double PR_012000010012=P_012000010*R_012[0]+-1*P_012000110*R_013[0]+-1*P_112000010*R_112[0]+P_112000110*R_113[0]+P_212000010*R_212[0]+-1*P_212000110*R_213[0]+-1*P_312000010*R_312[0]+P_312000110*R_313[0]; double PR_011001010012=P_011001010*R_012[0]+-1*P_011001110*R_013[0]+-1*P_011101010*R_022[0]+P_011101110*R_023[0]+-1*P_111001010*R_112[0]+P_111001110*R_113[0]+P_111101010*R_122[0]+-1*P_111101110*R_123[0]+P_211001010*R_212[0]+-1*P_211001110*R_213[0]+-1*P_211101010*R_222[0]+P_211101110*R_223[0]; double PR_010002010012=P_010002010*R_012[0]+-1*P_010002110*R_013[0]+-1*P_010102010*R_022[0]+P_010102110*R_023[0]+P_010202010*R_032[0]+-1*P_010202110*R_033[0]+-1*P_110002010*R_112[0]+P_110002110*R_113[0]+P_110102010*R_122[0]+-1*P_110102110*R_123[0]+-1*P_110202010*R_132[0]+P_110202110*R_133[0]; double PR_011000011012=P_011000011*R_012[0]+-1*P_011000111*R_013[0]+P_011000211*R_014[0]+-1*P_111000011*R_112[0]+P_111000111*R_113[0]+-1*P_111000211*R_114[0]+P_211000011*R_212[0]+-1*P_211000111*R_213[0]+P_211000211*R_214[0]; double PR_010001011012=P_010001011*R_012[0]+-1*P_010001111*R_013[0]+P_010001211*R_014[0]+-1*P_010101011*R_022[0]+P_010101111*R_023[0]+-1*P_010101211*R_024[0]+-1*P_110001011*R_112[0]+P_110001111*R_113[0]+-1*P_110001211*R_114[0]+P_110101011*R_122[0]+-1*P_110101111*R_123[0]+P_110101211*R_124[0]; double PR_010000012012=P_010000012*R_012[0]+-1*P_010000112*R_013[0]+P_010000212*R_014[0]+-1*P_010000312*R_015[0]+-1*P_110000012*R_112[0]+P_110000112*R_113[0]+-1*P_110000212*R_114[0]+P_110000312*R_115[0]; double PR_002010010012=P_002010010*R_012[0]+-1*P_002010110*R_013[0]+-1*P_002110010*R_022[0]+P_002110110*R_023[0]+-1*P_102010010*R_112[0]+P_102010110*R_113[0]+P_102110010*R_122[0]+-1*P_102110110*R_123[0]+P_202010010*R_212[0]+-1*P_202010110*R_213[0]+-1*P_202110010*R_222[0]+P_202110110*R_223[0]; double PR_001011010012=P_001011010*R_012[0]+-1*P_001011110*R_013[0]+-1*P_001111010*R_022[0]+P_001111110*R_023[0]+P_001211010*R_032[0]+-1*P_001211110*R_033[0]+-1*P_101011010*R_112[0]+P_101011110*R_113[0]+P_101111010*R_122[0]+-1*P_101111110*R_123[0]+-1*P_101211010*R_132[0]+P_101211110*R_133[0]; double PR_000012010012=P_000012010*R_012[0]+-1*P_000012110*R_013[0]+-1*P_000112010*R_022[0]+P_000112110*R_023[0]+P_000212010*R_032[0]+-1*P_000212110*R_033[0]+-1*P_000312010*R_042[0]+P_000312110*R_043[0]; double PR_001010011012=P_001010011*R_012[0]+-1*P_001010111*R_013[0]+P_001010211*R_014[0]+-1*P_001110011*R_022[0]+P_001110111*R_023[0]+-1*P_001110211*R_024[0]+-1*P_101010011*R_112[0]+P_101010111*R_113[0]+-1*P_101010211*R_114[0]+P_101110011*R_122[0]+-1*P_101110111*R_123[0]+P_101110211*R_124[0]; double PR_000011011012=P_000011011*R_012[0]+-1*P_000011111*R_013[0]+P_000011211*R_014[0]+-1*P_000111011*R_022[0]+P_000111111*R_023[0]+-1*P_000111211*R_024[0]+P_000211011*R_032[0]+-1*P_000211111*R_033[0]+P_000211211*R_034[0]; double PR_000010012012=P_000010012*R_012[0]+-1*P_000010112*R_013[0]+P_000010212*R_014[0]+-1*P_000010312*R_015[0]+-1*P_000110012*R_022[0]+P_000110112*R_023[0]+-1*P_000110212*R_024[0]+P_000110312*R_025[0]; double PR_002000020012=P_002000020*R_012[0]+-1*P_002000120*R_013[0]+P_002000220*R_014[0]+-1*P_102000020*R_112[0]+P_102000120*R_113[0]+-1*P_102000220*R_114[0]+P_202000020*R_212[0]+-1*P_202000120*R_213[0]+P_202000220*R_214[0]; double PR_001001020012=P_001001020*R_012[0]+-1*P_001001120*R_013[0]+P_001001220*R_014[0]+-1*P_001101020*R_022[0]+P_001101120*R_023[0]+-1*P_001101220*R_024[0]+-1*P_101001020*R_112[0]+P_101001120*R_113[0]+-1*P_101001220*R_114[0]+P_101101020*R_122[0]+-1*P_101101120*R_123[0]+P_101101220*R_124[0]; double PR_000002020012=P_000002020*R_012[0]+-1*P_000002120*R_013[0]+P_000002220*R_014[0]+-1*P_000102020*R_022[0]+P_000102120*R_023[0]+-1*P_000102220*R_024[0]+P_000202020*R_032[0]+-1*P_000202120*R_033[0]+P_000202220*R_034[0]; double PR_001000021012=P_001000021*R_012[0]+-1*P_001000121*R_013[0]+P_001000221*R_014[0]+-1*P_001000321*R_015[0]+-1*P_101000021*R_112[0]+P_101000121*R_113[0]+-1*P_101000221*R_114[0]+P_101000321*R_115[0]; double PR_000001021012=P_000001021*R_012[0]+-1*P_000001121*R_013[0]+P_000001221*R_014[0]+-1*P_000001321*R_015[0]+-1*P_000101021*R_022[0]+P_000101121*R_023[0]+-1*P_000101221*R_024[0]+P_000101321*R_025[0]; double PR_000000022012=P_000000022*R_012[0]+-1*P_000000122*R_013[0]+P_000000222*R_014[0]+-1*P_000000322*R_015[0]+P_000000422*R_016[0]; double PR_022000000021=P_022000000*R_021[0]+-1*P_122000000*R_121[0]+P_222000000*R_221[0]+-1*P_322000000*R_321[0]+P_422000000*R_421[0]; double PR_021001000021=P_021001000*R_021[0]+-1*P_021101000*R_031[0]+-1*P_121001000*R_121[0]+P_121101000*R_131[0]+P_221001000*R_221[0]+-1*P_221101000*R_231[0]+-1*P_321001000*R_321[0]+P_321101000*R_331[0]; double PR_020002000021=P_020002000*R_021[0]+-1*P_020102000*R_031[0]+P_020202000*R_041[0]+-1*P_120002000*R_121[0]+P_120102000*R_131[0]+-1*P_120202000*R_141[0]+P_220002000*R_221[0]+-1*P_220102000*R_231[0]+P_220202000*R_241[0]; double PR_021000001021=P_021000001*R_021[0]+-1*P_021000101*R_022[0]+-1*P_121000001*R_121[0]+P_121000101*R_122[0]+P_221000001*R_221[0]+-1*P_221000101*R_222[0]+-1*P_321000001*R_321[0]+P_321000101*R_322[0]; double PR_020001001021=P_020001001*R_021[0]+-1*P_020001101*R_022[0]+-1*P_020101001*R_031[0]+P_020101101*R_032[0]+-1*P_120001001*R_121[0]+P_120001101*R_122[0]+P_120101001*R_131[0]+-1*P_120101101*R_132[0]+P_220001001*R_221[0]+-1*P_220001101*R_222[0]+-1*P_220101001*R_231[0]+P_220101101*R_232[0]; double PR_020000002021=P_020000002*R_021[0]+-1*P_020000102*R_022[0]+P_020000202*R_023[0]+-1*P_120000002*R_121[0]+P_120000102*R_122[0]+-1*P_120000202*R_123[0]+P_220000002*R_221[0]+-1*P_220000102*R_222[0]+P_220000202*R_223[0]; double PR_012010000021=P_012010000*R_021[0]+-1*P_012110000*R_031[0]+-1*P_112010000*R_121[0]+P_112110000*R_131[0]+P_212010000*R_221[0]+-1*P_212110000*R_231[0]+-1*P_312010000*R_321[0]+P_312110000*R_331[0]; double PR_011011000021=P_011011000*R_021[0]+-1*P_011111000*R_031[0]+P_011211000*R_041[0]+-1*P_111011000*R_121[0]+P_111111000*R_131[0]+-1*P_111211000*R_141[0]+P_211011000*R_221[0]+-1*P_211111000*R_231[0]+P_211211000*R_241[0]; double PR_010012000021=P_010012000*R_021[0]+-1*P_010112000*R_031[0]+P_010212000*R_041[0]+-1*P_010312000*R_051[0]+-1*P_110012000*R_121[0]+P_110112000*R_131[0]+-1*P_110212000*R_141[0]+P_110312000*R_151[0]; double PR_011010001021=P_011010001*R_021[0]+-1*P_011010101*R_022[0]+-1*P_011110001*R_031[0]+P_011110101*R_032[0]+-1*P_111010001*R_121[0]+P_111010101*R_122[0]+P_111110001*R_131[0]+-1*P_111110101*R_132[0]+P_211010001*R_221[0]+-1*P_211010101*R_222[0]+-1*P_211110001*R_231[0]+P_211110101*R_232[0]; double PR_010011001021=P_010011001*R_021[0]+-1*P_010011101*R_022[0]+-1*P_010111001*R_031[0]+P_010111101*R_032[0]+P_010211001*R_041[0]+-1*P_010211101*R_042[0]+-1*P_110011001*R_121[0]+P_110011101*R_122[0]+P_110111001*R_131[0]+-1*P_110111101*R_132[0]+-1*P_110211001*R_141[0]+P_110211101*R_142[0]; double PR_010010002021=P_010010002*R_021[0]+-1*P_010010102*R_022[0]+P_010010202*R_023[0]+-1*P_010110002*R_031[0]+P_010110102*R_032[0]+-1*P_010110202*R_033[0]+-1*P_110010002*R_121[0]+P_110010102*R_122[0]+-1*P_110010202*R_123[0]+P_110110002*R_131[0]+-1*P_110110102*R_132[0]+P_110110202*R_133[0]; double PR_002020000021=P_002020000*R_021[0]+-1*P_002120000*R_031[0]+P_002220000*R_041[0]+-1*P_102020000*R_121[0]+P_102120000*R_131[0]+-1*P_102220000*R_141[0]+P_202020000*R_221[0]+-1*P_202120000*R_231[0]+P_202220000*R_241[0]; double PR_001021000021=P_001021000*R_021[0]+-1*P_001121000*R_031[0]+P_001221000*R_041[0]+-1*P_001321000*R_051[0]+-1*P_101021000*R_121[0]+P_101121000*R_131[0]+-1*P_101221000*R_141[0]+P_101321000*R_151[0]; double PR_000022000021=P_000022000*R_021[0]+-1*P_000122000*R_031[0]+P_000222000*R_041[0]+-1*P_000322000*R_051[0]+P_000422000*R_061[0]; double PR_001020001021=P_001020001*R_021[0]+-1*P_001020101*R_022[0]+-1*P_001120001*R_031[0]+P_001120101*R_032[0]+P_001220001*R_041[0]+-1*P_001220101*R_042[0]+-1*P_101020001*R_121[0]+P_101020101*R_122[0]+P_101120001*R_131[0]+-1*P_101120101*R_132[0]+-1*P_101220001*R_141[0]+P_101220101*R_142[0]; double PR_000021001021=P_000021001*R_021[0]+-1*P_000021101*R_022[0]+-1*P_000121001*R_031[0]+P_000121101*R_032[0]+P_000221001*R_041[0]+-1*P_000221101*R_042[0]+-1*P_000321001*R_051[0]+P_000321101*R_052[0]; double PR_000020002021=P_000020002*R_021[0]+-1*P_000020102*R_022[0]+P_000020202*R_023[0]+-1*P_000120002*R_031[0]+P_000120102*R_032[0]+-1*P_000120202*R_033[0]+P_000220002*R_041[0]+-1*P_000220102*R_042[0]+P_000220202*R_043[0]; double PR_012000010021=P_012000010*R_021[0]+-1*P_012000110*R_022[0]+-1*P_112000010*R_121[0]+P_112000110*R_122[0]+P_212000010*R_221[0]+-1*P_212000110*R_222[0]+-1*P_312000010*R_321[0]+P_312000110*R_322[0]; double PR_011001010021=P_011001010*R_021[0]+-1*P_011001110*R_022[0]+-1*P_011101010*R_031[0]+P_011101110*R_032[0]+-1*P_111001010*R_121[0]+P_111001110*R_122[0]+P_111101010*R_131[0]+-1*P_111101110*R_132[0]+P_211001010*R_221[0]+-1*P_211001110*R_222[0]+-1*P_211101010*R_231[0]+P_211101110*R_232[0]; double PR_010002010021=P_010002010*R_021[0]+-1*P_010002110*R_022[0]+-1*P_010102010*R_031[0]+P_010102110*R_032[0]+P_010202010*R_041[0]+-1*P_010202110*R_042[0]+-1*P_110002010*R_121[0]+P_110002110*R_122[0]+P_110102010*R_131[0]+-1*P_110102110*R_132[0]+-1*P_110202010*R_141[0]+P_110202110*R_142[0]; double PR_011000011021=P_011000011*R_021[0]+-1*P_011000111*R_022[0]+P_011000211*R_023[0]+-1*P_111000011*R_121[0]+P_111000111*R_122[0]+-1*P_111000211*R_123[0]+P_211000011*R_221[0]+-1*P_211000111*R_222[0]+P_211000211*R_223[0]; double PR_010001011021=P_010001011*R_021[0]+-1*P_010001111*R_022[0]+P_010001211*R_023[0]+-1*P_010101011*R_031[0]+P_010101111*R_032[0]+-1*P_010101211*R_033[0]+-1*P_110001011*R_121[0]+P_110001111*R_122[0]+-1*P_110001211*R_123[0]+P_110101011*R_131[0]+-1*P_110101111*R_132[0]+P_110101211*R_133[0]; double PR_010000012021=P_010000012*R_021[0]+-1*P_010000112*R_022[0]+P_010000212*R_023[0]+-1*P_010000312*R_024[0]+-1*P_110000012*R_121[0]+P_110000112*R_122[0]+-1*P_110000212*R_123[0]+P_110000312*R_124[0]; double PR_002010010021=P_002010010*R_021[0]+-1*P_002010110*R_022[0]+-1*P_002110010*R_031[0]+P_002110110*R_032[0]+-1*P_102010010*R_121[0]+P_102010110*R_122[0]+P_102110010*R_131[0]+-1*P_102110110*R_132[0]+P_202010010*R_221[0]+-1*P_202010110*R_222[0]+-1*P_202110010*R_231[0]+P_202110110*R_232[0]; double PR_001011010021=P_001011010*R_021[0]+-1*P_001011110*R_022[0]+-1*P_001111010*R_031[0]+P_001111110*R_032[0]+P_001211010*R_041[0]+-1*P_001211110*R_042[0]+-1*P_101011010*R_121[0]+P_101011110*R_122[0]+P_101111010*R_131[0]+-1*P_101111110*R_132[0]+-1*P_101211010*R_141[0]+P_101211110*R_142[0]; double PR_000012010021=P_000012010*R_021[0]+-1*P_000012110*R_022[0]+-1*P_000112010*R_031[0]+P_000112110*R_032[0]+P_000212010*R_041[0]+-1*P_000212110*R_042[0]+-1*P_000312010*R_051[0]+P_000312110*R_052[0]; double PR_001010011021=P_001010011*R_021[0]+-1*P_001010111*R_022[0]+P_001010211*R_023[0]+-1*P_001110011*R_031[0]+P_001110111*R_032[0]+-1*P_001110211*R_033[0]+-1*P_101010011*R_121[0]+P_101010111*R_122[0]+-1*P_101010211*R_123[0]+P_101110011*R_131[0]+-1*P_101110111*R_132[0]+P_101110211*R_133[0]; double PR_000011011021=P_000011011*R_021[0]+-1*P_000011111*R_022[0]+P_000011211*R_023[0]+-1*P_000111011*R_031[0]+P_000111111*R_032[0]+-1*P_000111211*R_033[0]+P_000211011*R_041[0]+-1*P_000211111*R_042[0]+P_000211211*R_043[0]; double PR_000010012021=P_000010012*R_021[0]+-1*P_000010112*R_022[0]+P_000010212*R_023[0]+-1*P_000010312*R_024[0]+-1*P_000110012*R_031[0]+P_000110112*R_032[0]+-1*P_000110212*R_033[0]+P_000110312*R_034[0]; double PR_002000020021=P_002000020*R_021[0]+-1*P_002000120*R_022[0]+P_002000220*R_023[0]+-1*P_102000020*R_121[0]+P_102000120*R_122[0]+-1*P_102000220*R_123[0]+P_202000020*R_221[0]+-1*P_202000120*R_222[0]+P_202000220*R_223[0]; double PR_001001020021=P_001001020*R_021[0]+-1*P_001001120*R_022[0]+P_001001220*R_023[0]+-1*P_001101020*R_031[0]+P_001101120*R_032[0]+-1*P_001101220*R_033[0]+-1*P_101001020*R_121[0]+P_101001120*R_122[0]+-1*P_101001220*R_123[0]+P_101101020*R_131[0]+-1*P_101101120*R_132[0]+P_101101220*R_133[0]; double PR_000002020021=P_000002020*R_021[0]+-1*P_000002120*R_022[0]+P_000002220*R_023[0]+-1*P_000102020*R_031[0]+P_000102120*R_032[0]+-1*P_000102220*R_033[0]+P_000202020*R_041[0]+-1*P_000202120*R_042[0]+P_000202220*R_043[0]; double PR_001000021021=P_001000021*R_021[0]+-1*P_001000121*R_022[0]+P_001000221*R_023[0]+-1*P_001000321*R_024[0]+-1*P_101000021*R_121[0]+P_101000121*R_122[0]+-1*P_101000221*R_123[0]+P_101000321*R_124[0]; double PR_000001021021=P_000001021*R_021[0]+-1*P_000001121*R_022[0]+P_000001221*R_023[0]+-1*P_000001321*R_024[0]+-1*P_000101021*R_031[0]+P_000101121*R_032[0]+-1*P_000101221*R_033[0]+P_000101321*R_034[0]; double PR_000000022021=P_000000022*R_021[0]+-1*P_000000122*R_022[0]+P_000000222*R_023[0]+-1*P_000000322*R_024[0]+P_000000422*R_025[0]; double PR_022000000030=P_022000000*R_030[0]+-1*P_122000000*R_130[0]+P_222000000*R_230[0]+-1*P_322000000*R_330[0]+P_422000000*R_430[0]; double PR_021001000030=P_021001000*R_030[0]+-1*P_021101000*R_040[0]+-1*P_121001000*R_130[0]+P_121101000*R_140[0]+P_221001000*R_230[0]+-1*P_221101000*R_240[0]+-1*P_321001000*R_330[0]+P_321101000*R_340[0]; double PR_020002000030=P_020002000*R_030[0]+-1*P_020102000*R_040[0]+P_020202000*R_050[0]+-1*P_120002000*R_130[0]+P_120102000*R_140[0]+-1*P_120202000*R_150[0]+P_220002000*R_230[0]+-1*P_220102000*R_240[0]+P_220202000*R_250[0]; double PR_021000001030=P_021000001*R_030[0]+-1*P_021000101*R_031[0]+-1*P_121000001*R_130[0]+P_121000101*R_131[0]+P_221000001*R_230[0]+-1*P_221000101*R_231[0]+-1*P_321000001*R_330[0]+P_321000101*R_331[0]; double PR_020001001030=P_020001001*R_030[0]+-1*P_020001101*R_031[0]+-1*P_020101001*R_040[0]+P_020101101*R_041[0]+-1*P_120001001*R_130[0]+P_120001101*R_131[0]+P_120101001*R_140[0]+-1*P_120101101*R_141[0]+P_220001001*R_230[0]+-1*P_220001101*R_231[0]+-1*P_220101001*R_240[0]+P_220101101*R_241[0]; double PR_020000002030=P_020000002*R_030[0]+-1*P_020000102*R_031[0]+P_020000202*R_032[0]+-1*P_120000002*R_130[0]+P_120000102*R_131[0]+-1*P_120000202*R_132[0]+P_220000002*R_230[0]+-1*P_220000102*R_231[0]+P_220000202*R_232[0]; double PR_012010000030=P_012010000*R_030[0]+-1*P_012110000*R_040[0]+-1*P_112010000*R_130[0]+P_112110000*R_140[0]+P_212010000*R_230[0]+-1*P_212110000*R_240[0]+-1*P_312010000*R_330[0]+P_312110000*R_340[0]; double PR_011011000030=P_011011000*R_030[0]+-1*P_011111000*R_040[0]+P_011211000*R_050[0]+-1*P_111011000*R_130[0]+P_111111000*R_140[0]+-1*P_111211000*R_150[0]+P_211011000*R_230[0]+-1*P_211111000*R_240[0]+P_211211000*R_250[0]; double PR_010012000030=P_010012000*R_030[0]+-1*P_010112000*R_040[0]+P_010212000*R_050[0]+-1*P_010312000*R_060[0]+-1*P_110012000*R_130[0]+P_110112000*R_140[0]+-1*P_110212000*R_150[0]+P_110312000*R_160[0]; double PR_011010001030=P_011010001*R_030[0]+-1*P_011010101*R_031[0]+-1*P_011110001*R_040[0]+P_011110101*R_041[0]+-1*P_111010001*R_130[0]+P_111010101*R_131[0]+P_111110001*R_140[0]+-1*P_111110101*R_141[0]+P_211010001*R_230[0]+-1*P_211010101*R_231[0]+-1*P_211110001*R_240[0]+P_211110101*R_241[0]; double PR_010011001030=P_010011001*R_030[0]+-1*P_010011101*R_031[0]+-1*P_010111001*R_040[0]+P_010111101*R_041[0]+P_010211001*R_050[0]+-1*P_010211101*R_051[0]+-1*P_110011001*R_130[0]+P_110011101*R_131[0]+P_110111001*R_140[0]+-1*P_110111101*R_141[0]+-1*P_110211001*R_150[0]+P_110211101*R_151[0]; double PR_010010002030=P_010010002*R_030[0]+-1*P_010010102*R_031[0]+P_010010202*R_032[0]+-1*P_010110002*R_040[0]+P_010110102*R_041[0]+-1*P_010110202*R_042[0]+-1*P_110010002*R_130[0]+P_110010102*R_131[0]+-1*P_110010202*R_132[0]+P_110110002*R_140[0]+-1*P_110110102*R_141[0]+P_110110202*R_142[0]; double PR_002020000030=P_002020000*R_030[0]+-1*P_002120000*R_040[0]+P_002220000*R_050[0]+-1*P_102020000*R_130[0]+P_102120000*R_140[0]+-1*P_102220000*R_150[0]+P_202020000*R_230[0]+-1*P_202120000*R_240[0]+P_202220000*R_250[0]; double PR_001021000030=P_001021000*R_030[0]+-1*P_001121000*R_040[0]+P_001221000*R_050[0]+-1*P_001321000*R_060[0]+-1*P_101021000*R_130[0]+P_101121000*R_140[0]+-1*P_101221000*R_150[0]+P_101321000*R_160[0]; double PR_000022000030=P_000022000*R_030[0]+-1*P_000122000*R_040[0]+P_000222000*R_050[0]+-1*P_000322000*R_060[0]+P_000422000*R_070[0]; double PR_001020001030=P_001020001*R_030[0]+-1*P_001020101*R_031[0]+-1*P_001120001*R_040[0]+P_001120101*R_041[0]+P_001220001*R_050[0]+-1*P_001220101*R_051[0]+-1*P_101020001*R_130[0]+P_101020101*R_131[0]+P_101120001*R_140[0]+-1*P_101120101*R_141[0]+-1*P_101220001*R_150[0]+P_101220101*R_151[0]; double PR_000021001030=P_000021001*R_030[0]+-1*P_000021101*R_031[0]+-1*P_000121001*R_040[0]+P_000121101*R_041[0]+P_000221001*R_050[0]+-1*P_000221101*R_051[0]+-1*P_000321001*R_060[0]+P_000321101*R_061[0]; double PR_000020002030=P_000020002*R_030[0]+-1*P_000020102*R_031[0]+P_000020202*R_032[0]+-1*P_000120002*R_040[0]+P_000120102*R_041[0]+-1*P_000120202*R_042[0]+P_000220002*R_050[0]+-1*P_000220102*R_051[0]+P_000220202*R_052[0]; double PR_012000010030=P_012000010*R_030[0]+-1*P_012000110*R_031[0]+-1*P_112000010*R_130[0]+P_112000110*R_131[0]+P_212000010*R_230[0]+-1*P_212000110*R_231[0]+-1*P_312000010*R_330[0]+P_312000110*R_331[0]; double PR_011001010030=P_011001010*R_030[0]+-1*P_011001110*R_031[0]+-1*P_011101010*R_040[0]+P_011101110*R_041[0]+-1*P_111001010*R_130[0]+P_111001110*R_131[0]+P_111101010*R_140[0]+-1*P_111101110*R_141[0]+P_211001010*R_230[0]+-1*P_211001110*R_231[0]+-1*P_211101010*R_240[0]+P_211101110*R_241[0]; double PR_010002010030=P_010002010*R_030[0]+-1*P_010002110*R_031[0]+-1*P_010102010*R_040[0]+P_010102110*R_041[0]+P_010202010*R_050[0]+-1*P_010202110*R_051[0]+-1*P_110002010*R_130[0]+P_110002110*R_131[0]+P_110102010*R_140[0]+-1*P_110102110*R_141[0]+-1*P_110202010*R_150[0]+P_110202110*R_151[0]; double PR_011000011030=P_011000011*R_030[0]+-1*P_011000111*R_031[0]+P_011000211*R_032[0]+-1*P_111000011*R_130[0]+P_111000111*R_131[0]+-1*P_111000211*R_132[0]+P_211000011*R_230[0]+-1*P_211000111*R_231[0]+P_211000211*R_232[0]; double PR_010001011030=P_010001011*R_030[0]+-1*P_010001111*R_031[0]+P_010001211*R_032[0]+-1*P_010101011*R_040[0]+P_010101111*R_041[0]+-1*P_010101211*R_042[0]+-1*P_110001011*R_130[0]+P_110001111*R_131[0]+-1*P_110001211*R_132[0]+P_110101011*R_140[0]+-1*P_110101111*R_141[0]+P_110101211*R_142[0]; double PR_010000012030=P_010000012*R_030[0]+-1*P_010000112*R_031[0]+P_010000212*R_032[0]+-1*P_010000312*R_033[0]+-1*P_110000012*R_130[0]+P_110000112*R_131[0]+-1*P_110000212*R_132[0]+P_110000312*R_133[0]; double PR_002010010030=P_002010010*R_030[0]+-1*P_002010110*R_031[0]+-1*P_002110010*R_040[0]+P_002110110*R_041[0]+-1*P_102010010*R_130[0]+P_102010110*R_131[0]+P_102110010*R_140[0]+-1*P_102110110*R_141[0]+P_202010010*R_230[0]+-1*P_202010110*R_231[0]+-1*P_202110010*R_240[0]+P_202110110*R_241[0]; double PR_001011010030=P_001011010*R_030[0]+-1*P_001011110*R_031[0]+-1*P_001111010*R_040[0]+P_001111110*R_041[0]+P_001211010*R_050[0]+-1*P_001211110*R_051[0]+-1*P_101011010*R_130[0]+P_101011110*R_131[0]+P_101111010*R_140[0]+-1*P_101111110*R_141[0]+-1*P_101211010*R_150[0]+P_101211110*R_151[0]; double PR_000012010030=P_000012010*R_030[0]+-1*P_000012110*R_031[0]+-1*P_000112010*R_040[0]+P_000112110*R_041[0]+P_000212010*R_050[0]+-1*P_000212110*R_051[0]+-1*P_000312010*R_060[0]+P_000312110*R_061[0]; double PR_001010011030=P_001010011*R_030[0]+-1*P_001010111*R_031[0]+P_001010211*R_032[0]+-1*P_001110011*R_040[0]+P_001110111*R_041[0]+-1*P_001110211*R_042[0]+-1*P_101010011*R_130[0]+P_101010111*R_131[0]+-1*P_101010211*R_132[0]+P_101110011*R_140[0]+-1*P_101110111*R_141[0]+P_101110211*R_142[0]; double PR_000011011030=P_000011011*R_030[0]+-1*P_000011111*R_031[0]+P_000011211*R_032[0]+-1*P_000111011*R_040[0]+P_000111111*R_041[0]+-1*P_000111211*R_042[0]+P_000211011*R_050[0]+-1*P_000211111*R_051[0]+P_000211211*R_052[0]; double PR_000010012030=P_000010012*R_030[0]+-1*P_000010112*R_031[0]+P_000010212*R_032[0]+-1*P_000010312*R_033[0]+-1*P_000110012*R_040[0]+P_000110112*R_041[0]+-1*P_000110212*R_042[0]+P_000110312*R_043[0]; double PR_002000020030=P_002000020*R_030[0]+-1*P_002000120*R_031[0]+P_002000220*R_032[0]+-1*P_102000020*R_130[0]+P_102000120*R_131[0]+-1*P_102000220*R_132[0]+P_202000020*R_230[0]+-1*P_202000120*R_231[0]+P_202000220*R_232[0]; double PR_001001020030=P_001001020*R_030[0]+-1*P_001001120*R_031[0]+P_001001220*R_032[0]+-1*P_001101020*R_040[0]+P_001101120*R_041[0]+-1*P_001101220*R_042[0]+-1*P_101001020*R_130[0]+P_101001120*R_131[0]+-1*P_101001220*R_132[0]+P_101101020*R_140[0]+-1*P_101101120*R_141[0]+P_101101220*R_142[0]; double PR_000002020030=P_000002020*R_030[0]+-1*P_000002120*R_031[0]+P_000002220*R_032[0]+-1*P_000102020*R_040[0]+P_000102120*R_041[0]+-1*P_000102220*R_042[0]+P_000202020*R_050[0]+-1*P_000202120*R_051[0]+P_000202220*R_052[0]; double PR_001000021030=P_001000021*R_030[0]+-1*P_001000121*R_031[0]+P_001000221*R_032[0]+-1*P_001000321*R_033[0]+-1*P_101000021*R_130[0]+P_101000121*R_131[0]+-1*P_101000221*R_132[0]+P_101000321*R_133[0]; double PR_000001021030=P_000001021*R_030[0]+-1*P_000001121*R_031[0]+P_000001221*R_032[0]+-1*P_000001321*R_033[0]+-1*P_000101021*R_040[0]+P_000101121*R_041[0]+-1*P_000101221*R_042[0]+P_000101321*R_043[0]; double PR_000000022030=P_000000022*R_030[0]+-1*P_000000122*R_031[0]+P_000000222*R_032[0]+-1*P_000000322*R_033[0]+P_000000422*R_034[0]; double PR_022000000102=P_022000000*R_102[0]+-1*P_122000000*R_202[0]+P_222000000*R_302[0]+-1*P_322000000*R_402[0]+P_422000000*R_502[0]; double PR_021001000102=P_021001000*R_102[0]+-1*P_021101000*R_112[0]+-1*P_121001000*R_202[0]+P_121101000*R_212[0]+P_221001000*R_302[0]+-1*P_221101000*R_312[0]+-1*P_321001000*R_402[0]+P_321101000*R_412[0]; double PR_020002000102=P_020002000*R_102[0]+-1*P_020102000*R_112[0]+P_020202000*R_122[0]+-1*P_120002000*R_202[0]+P_120102000*R_212[0]+-1*P_120202000*R_222[0]+P_220002000*R_302[0]+-1*P_220102000*R_312[0]+P_220202000*R_322[0]; double PR_021000001102=P_021000001*R_102[0]+-1*P_021000101*R_103[0]+-1*P_121000001*R_202[0]+P_121000101*R_203[0]+P_221000001*R_302[0]+-1*P_221000101*R_303[0]+-1*P_321000001*R_402[0]+P_321000101*R_403[0]; double PR_020001001102=P_020001001*R_102[0]+-1*P_020001101*R_103[0]+-1*P_020101001*R_112[0]+P_020101101*R_113[0]+-1*P_120001001*R_202[0]+P_120001101*R_203[0]+P_120101001*R_212[0]+-1*P_120101101*R_213[0]+P_220001001*R_302[0]+-1*P_220001101*R_303[0]+-1*P_220101001*R_312[0]+P_220101101*R_313[0]; double PR_020000002102=P_020000002*R_102[0]+-1*P_020000102*R_103[0]+P_020000202*R_104[0]+-1*P_120000002*R_202[0]+P_120000102*R_203[0]+-1*P_120000202*R_204[0]+P_220000002*R_302[0]+-1*P_220000102*R_303[0]+P_220000202*R_304[0]; double PR_012010000102=P_012010000*R_102[0]+-1*P_012110000*R_112[0]+-1*P_112010000*R_202[0]+P_112110000*R_212[0]+P_212010000*R_302[0]+-1*P_212110000*R_312[0]+-1*P_312010000*R_402[0]+P_312110000*R_412[0]; double PR_011011000102=P_011011000*R_102[0]+-1*P_011111000*R_112[0]+P_011211000*R_122[0]+-1*P_111011000*R_202[0]+P_111111000*R_212[0]+-1*P_111211000*R_222[0]+P_211011000*R_302[0]+-1*P_211111000*R_312[0]+P_211211000*R_322[0]; double PR_010012000102=P_010012000*R_102[0]+-1*P_010112000*R_112[0]+P_010212000*R_122[0]+-1*P_010312000*R_132[0]+-1*P_110012000*R_202[0]+P_110112000*R_212[0]+-1*P_110212000*R_222[0]+P_110312000*R_232[0]; double PR_011010001102=P_011010001*R_102[0]+-1*P_011010101*R_103[0]+-1*P_011110001*R_112[0]+P_011110101*R_113[0]+-1*P_111010001*R_202[0]+P_111010101*R_203[0]+P_111110001*R_212[0]+-1*P_111110101*R_213[0]+P_211010001*R_302[0]+-1*P_211010101*R_303[0]+-1*P_211110001*R_312[0]+P_211110101*R_313[0]; double PR_010011001102=P_010011001*R_102[0]+-1*P_010011101*R_103[0]+-1*P_010111001*R_112[0]+P_010111101*R_113[0]+P_010211001*R_122[0]+-1*P_010211101*R_123[0]+-1*P_110011001*R_202[0]+P_110011101*R_203[0]+P_110111001*R_212[0]+-1*P_110111101*R_213[0]+-1*P_110211001*R_222[0]+P_110211101*R_223[0]; double PR_010010002102=P_010010002*R_102[0]+-1*P_010010102*R_103[0]+P_010010202*R_104[0]+-1*P_010110002*R_112[0]+P_010110102*R_113[0]+-1*P_010110202*R_114[0]+-1*P_110010002*R_202[0]+P_110010102*R_203[0]+-1*P_110010202*R_204[0]+P_110110002*R_212[0]+-1*P_110110102*R_213[0]+P_110110202*R_214[0]; double PR_002020000102=P_002020000*R_102[0]+-1*P_002120000*R_112[0]+P_002220000*R_122[0]+-1*P_102020000*R_202[0]+P_102120000*R_212[0]+-1*P_102220000*R_222[0]+P_202020000*R_302[0]+-1*P_202120000*R_312[0]+P_202220000*R_322[0]; double PR_001021000102=P_001021000*R_102[0]+-1*P_001121000*R_112[0]+P_001221000*R_122[0]+-1*P_001321000*R_132[0]+-1*P_101021000*R_202[0]+P_101121000*R_212[0]+-1*P_101221000*R_222[0]+P_101321000*R_232[0]; double PR_000022000102=P_000022000*R_102[0]+-1*P_000122000*R_112[0]+P_000222000*R_122[0]+-1*P_000322000*R_132[0]+P_000422000*R_142[0]; double PR_001020001102=P_001020001*R_102[0]+-1*P_001020101*R_103[0]+-1*P_001120001*R_112[0]+P_001120101*R_113[0]+P_001220001*R_122[0]+-1*P_001220101*R_123[0]+-1*P_101020001*R_202[0]+P_101020101*R_203[0]+P_101120001*R_212[0]+-1*P_101120101*R_213[0]+-1*P_101220001*R_222[0]+P_101220101*R_223[0]; double PR_000021001102=P_000021001*R_102[0]+-1*P_000021101*R_103[0]+-1*P_000121001*R_112[0]+P_000121101*R_113[0]+P_000221001*R_122[0]+-1*P_000221101*R_123[0]+-1*P_000321001*R_132[0]+P_000321101*R_133[0]; double PR_000020002102=P_000020002*R_102[0]+-1*P_000020102*R_103[0]+P_000020202*R_104[0]+-1*P_000120002*R_112[0]+P_000120102*R_113[0]+-1*P_000120202*R_114[0]+P_000220002*R_122[0]+-1*P_000220102*R_123[0]+P_000220202*R_124[0]; double PR_012000010102=P_012000010*R_102[0]+-1*P_012000110*R_103[0]+-1*P_112000010*R_202[0]+P_112000110*R_203[0]+P_212000010*R_302[0]+-1*P_212000110*R_303[0]+-1*P_312000010*R_402[0]+P_312000110*R_403[0]; double PR_011001010102=P_011001010*R_102[0]+-1*P_011001110*R_103[0]+-1*P_011101010*R_112[0]+P_011101110*R_113[0]+-1*P_111001010*R_202[0]+P_111001110*R_203[0]+P_111101010*R_212[0]+-1*P_111101110*R_213[0]+P_211001010*R_302[0]+-1*P_211001110*R_303[0]+-1*P_211101010*R_312[0]+P_211101110*R_313[0]; double PR_010002010102=P_010002010*R_102[0]+-1*P_010002110*R_103[0]+-1*P_010102010*R_112[0]+P_010102110*R_113[0]+P_010202010*R_122[0]+-1*P_010202110*R_123[0]+-1*P_110002010*R_202[0]+P_110002110*R_203[0]+P_110102010*R_212[0]+-1*P_110102110*R_213[0]+-1*P_110202010*R_222[0]+P_110202110*R_223[0]; double PR_011000011102=P_011000011*R_102[0]+-1*P_011000111*R_103[0]+P_011000211*R_104[0]+-1*P_111000011*R_202[0]+P_111000111*R_203[0]+-1*P_111000211*R_204[0]+P_211000011*R_302[0]+-1*P_211000111*R_303[0]+P_211000211*R_304[0]; double PR_010001011102=P_010001011*R_102[0]+-1*P_010001111*R_103[0]+P_010001211*R_104[0]+-1*P_010101011*R_112[0]+P_010101111*R_113[0]+-1*P_010101211*R_114[0]+-1*P_110001011*R_202[0]+P_110001111*R_203[0]+-1*P_110001211*R_204[0]+P_110101011*R_212[0]+-1*P_110101111*R_213[0]+P_110101211*R_214[0]; double PR_010000012102=P_010000012*R_102[0]+-1*P_010000112*R_103[0]+P_010000212*R_104[0]+-1*P_010000312*R_105[0]+-1*P_110000012*R_202[0]+P_110000112*R_203[0]+-1*P_110000212*R_204[0]+P_110000312*R_205[0]; double PR_002010010102=P_002010010*R_102[0]+-1*P_002010110*R_103[0]+-1*P_002110010*R_112[0]+P_002110110*R_113[0]+-1*P_102010010*R_202[0]+P_102010110*R_203[0]+P_102110010*R_212[0]+-1*P_102110110*R_213[0]+P_202010010*R_302[0]+-1*P_202010110*R_303[0]+-1*P_202110010*R_312[0]+P_202110110*R_313[0]; double PR_001011010102=P_001011010*R_102[0]+-1*P_001011110*R_103[0]+-1*P_001111010*R_112[0]+P_001111110*R_113[0]+P_001211010*R_122[0]+-1*P_001211110*R_123[0]+-1*P_101011010*R_202[0]+P_101011110*R_203[0]+P_101111010*R_212[0]+-1*P_101111110*R_213[0]+-1*P_101211010*R_222[0]+P_101211110*R_223[0]; double PR_000012010102=P_000012010*R_102[0]+-1*P_000012110*R_103[0]+-1*P_000112010*R_112[0]+P_000112110*R_113[0]+P_000212010*R_122[0]+-1*P_000212110*R_123[0]+-1*P_000312010*R_132[0]+P_000312110*R_133[0]; double PR_001010011102=P_001010011*R_102[0]+-1*P_001010111*R_103[0]+P_001010211*R_104[0]+-1*P_001110011*R_112[0]+P_001110111*R_113[0]+-1*P_001110211*R_114[0]+-1*P_101010011*R_202[0]+P_101010111*R_203[0]+-1*P_101010211*R_204[0]+P_101110011*R_212[0]+-1*P_101110111*R_213[0]+P_101110211*R_214[0]; double PR_000011011102=P_000011011*R_102[0]+-1*P_000011111*R_103[0]+P_000011211*R_104[0]+-1*P_000111011*R_112[0]+P_000111111*R_113[0]+-1*P_000111211*R_114[0]+P_000211011*R_122[0]+-1*P_000211111*R_123[0]+P_000211211*R_124[0]; double PR_000010012102=P_000010012*R_102[0]+-1*P_000010112*R_103[0]+P_000010212*R_104[0]+-1*P_000010312*R_105[0]+-1*P_000110012*R_112[0]+P_000110112*R_113[0]+-1*P_000110212*R_114[0]+P_000110312*R_115[0]; double PR_002000020102=P_002000020*R_102[0]+-1*P_002000120*R_103[0]+P_002000220*R_104[0]+-1*P_102000020*R_202[0]+P_102000120*R_203[0]+-1*P_102000220*R_204[0]+P_202000020*R_302[0]+-1*P_202000120*R_303[0]+P_202000220*R_304[0]; double PR_001001020102=P_001001020*R_102[0]+-1*P_001001120*R_103[0]+P_001001220*R_104[0]+-1*P_001101020*R_112[0]+P_001101120*R_113[0]+-1*P_001101220*R_114[0]+-1*P_101001020*R_202[0]+P_101001120*R_203[0]+-1*P_101001220*R_204[0]+P_101101020*R_212[0]+-1*P_101101120*R_213[0]+P_101101220*R_214[0]; double PR_000002020102=P_000002020*R_102[0]+-1*P_000002120*R_103[0]+P_000002220*R_104[0]+-1*P_000102020*R_112[0]+P_000102120*R_113[0]+-1*P_000102220*R_114[0]+P_000202020*R_122[0]+-1*P_000202120*R_123[0]+P_000202220*R_124[0]; double PR_001000021102=P_001000021*R_102[0]+-1*P_001000121*R_103[0]+P_001000221*R_104[0]+-1*P_001000321*R_105[0]+-1*P_101000021*R_202[0]+P_101000121*R_203[0]+-1*P_101000221*R_204[0]+P_101000321*R_205[0]; double PR_000001021102=P_000001021*R_102[0]+-1*P_000001121*R_103[0]+P_000001221*R_104[0]+-1*P_000001321*R_105[0]+-1*P_000101021*R_112[0]+P_000101121*R_113[0]+-1*P_000101221*R_114[0]+P_000101321*R_115[0]; double PR_000000022102=P_000000022*R_102[0]+-1*P_000000122*R_103[0]+P_000000222*R_104[0]+-1*P_000000322*R_105[0]+P_000000422*R_106[0]; double PR_022000000111=P_022000000*R_111[0]+-1*P_122000000*R_211[0]+P_222000000*R_311[0]+-1*P_322000000*R_411[0]+P_422000000*R_511[0]; double PR_021001000111=P_021001000*R_111[0]+-1*P_021101000*R_121[0]+-1*P_121001000*R_211[0]+P_121101000*R_221[0]+P_221001000*R_311[0]+-1*P_221101000*R_321[0]+-1*P_321001000*R_411[0]+P_321101000*R_421[0]; double PR_020002000111=P_020002000*R_111[0]+-1*P_020102000*R_121[0]+P_020202000*R_131[0]+-1*P_120002000*R_211[0]+P_120102000*R_221[0]+-1*P_120202000*R_231[0]+P_220002000*R_311[0]+-1*P_220102000*R_321[0]+P_220202000*R_331[0]; double PR_021000001111=P_021000001*R_111[0]+-1*P_021000101*R_112[0]+-1*P_121000001*R_211[0]+P_121000101*R_212[0]+P_221000001*R_311[0]+-1*P_221000101*R_312[0]+-1*P_321000001*R_411[0]+P_321000101*R_412[0]; double PR_020001001111=P_020001001*R_111[0]+-1*P_020001101*R_112[0]+-1*P_020101001*R_121[0]+P_020101101*R_122[0]+-1*P_120001001*R_211[0]+P_120001101*R_212[0]+P_120101001*R_221[0]+-1*P_120101101*R_222[0]+P_220001001*R_311[0]+-1*P_220001101*R_312[0]+-1*P_220101001*R_321[0]+P_220101101*R_322[0]; double PR_020000002111=P_020000002*R_111[0]+-1*P_020000102*R_112[0]+P_020000202*R_113[0]+-1*P_120000002*R_211[0]+P_120000102*R_212[0]+-1*P_120000202*R_213[0]+P_220000002*R_311[0]+-1*P_220000102*R_312[0]+P_220000202*R_313[0]; double PR_012010000111=P_012010000*R_111[0]+-1*P_012110000*R_121[0]+-1*P_112010000*R_211[0]+P_112110000*R_221[0]+P_212010000*R_311[0]+-1*P_212110000*R_321[0]+-1*P_312010000*R_411[0]+P_312110000*R_421[0]; double PR_011011000111=P_011011000*R_111[0]+-1*P_011111000*R_121[0]+P_011211000*R_131[0]+-1*P_111011000*R_211[0]+P_111111000*R_221[0]+-1*P_111211000*R_231[0]+P_211011000*R_311[0]+-1*P_211111000*R_321[0]+P_211211000*R_331[0]; double PR_010012000111=P_010012000*R_111[0]+-1*P_010112000*R_121[0]+P_010212000*R_131[0]+-1*P_010312000*R_141[0]+-1*P_110012000*R_211[0]+P_110112000*R_221[0]+-1*P_110212000*R_231[0]+P_110312000*R_241[0]; double PR_011010001111=P_011010001*R_111[0]+-1*P_011010101*R_112[0]+-1*P_011110001*R_121[0]+P_011110101*R_122[0]+-1*P_111010001*R_211[0]+P_111010101*R_212[0]+P_111110001*R_221[0]+-1*P_111110101*R_222[0]+P_211010001*R_311[0]+-1*P_211010101*R_312[0]+-1*P_211110001*R_321[0]+P_211110101*R_322[0]; double PR_010011001111=P_010011001*R_111[0]+-1*P_010011101*R_112[0]+-1*P_010111001*R_121[0]+P_010111101*R_122[0]+P_010211001*R_131[0]+-1*P_010211101*R_132[0]+-1*P_110011001*R_211[0]+P_110011101*R_212[0]+P_110111001*R_221[0]+-1*P_110111101*R_222[0]+-1*P_110211001*R_231[0]+P_110211101*R_232[0]; double PR_010010002111=P_010010002*R_111[0]+-1*P_010010102*R_112[0]+P_010010202*R_113[0]+-1*P_010110002*R_121[0]+P_010110102*R_122[0]+-1*P_010110202*R_123[0]+-1*P_110010002*R_211[0]+P_110010102*R_212[0]+-1*P_110010202*R_213[0]+P_110110002*R_221[0]+-1*P_110110102*R_222[0]+P_110110202*R_223[0]; double PR_002020000111=P_002020000*R_111[0]+-1*P_002120000*R_121[0]+P_002220000*R_131[0]+-1*P_102020000*R_211[0]+P_102120000*R_221[0]+-1*P_102220000*R_231[0]+P_202020000*R_311[0]+-1*P_202120000*R_321[0]+P_202220000*R_331[0]; double PR_001021000111=P_001021000*R_111[0]+-1*P_001121000*R_121[0]+P_001221000*R_131[0]+-1*P_001321000*R_141[0]+-1*P_101021000*R_211[0]+P_101121000*R_221[0]+-1*P_101221000*R_231[0]+P_101321000*R_241[0]; double PR_000022000111=P_000022000*R_111[0]+-1*P_000122000*R_121[0]+P_000222000*R_131[0]+-1*P_000322000*R_141[0]+P_000422000*R_151[0]; double PR_001020001111=P_001020001*R_111[0]+-1*P_001020101*R_112[0]+-1*P_001120001*R_121[0]+P_001120101*R_122[0]+P_001220001*R_131[0]+-1*P_001220101*R_132[0]+-1*P_101020001*R_211[0]+P_101020101*R_212[0]+P_101120001*R_221[0]+-1*P_101120101*R_222[0]+-1*P_101220001*R_231[0]+P_101220101*R_232[0]; double PR_000021001111=P_000021001*R_111[0]+-1*P_000021101*R_112[0]+-1*P_000121001*R_121[0]+P_000121101*R_122[0]+P_000221001*R_131[0]+-1*P_000221101*R_132[0]+-1*P_000321001*R_141[0]+P_000321101*R_142[0]; double PR_000020002111=P_000020002*R_111[0]+-1*P_000020102*R_112[0]+P_000020202*R_113[0]+-1*P_000120002*R_121[0]+P_000120102*R_122[0]+-1*P_000120202*R_123[0]+P_000220002*R_131[0]+-1*P_000220102*R_132[0]+P_000220202*R_133[0]; double PR_012000010111=P_012000010*R_111[0]+-1*P_012000110*R_112[0]+-1*P_112000010*R_211[0]+P_112000110*R_212[0]+P_212000010*R_311[0]+-1*P_212000110*R_312[0]+-1*P_312000010*R_411[0]+P_312000110*R_412[0]; double PR_011001010111=P_011001010*R_111[0]+-1*P_011001110*R_112[0]+-1*P_011101010*R_121[0]+P_011101110*R_122[0]+-1*P_111001010*R_211[0]+P_111001110*R_212[0]+P_111101010*R_221[0]+-1*P_111101110*R_222[0]+P_211001010*R_311[0]+-1*P_211001110*R_312[0]+-1*P_211101010*R_321[0]+P_211101110*R_322[0]; double PR_010002010111=P_010002010*R_111[0]+-1*P_010002110*R_112[0]+-1*P_010102010*R_121[0]+P_010102110*R_122[0]+P_010202010*R_131[0]+-1*P_010202110*R_132[0]+-1*P_110002010*R_211[0]+P_110002110*R_212[0]+P_110102010*R_221[0]+-1*P_110102110*R_222[0]+-1*P_110202010*R_231[0]+P_110202110*R_232[0]; double PR_011000011111=P_011000011*R_111[0]+-1*P_011000111*R_112[0]+P_011000211*R_113[0]+-1*P_111000011*R_211[0]+P_111000111*R_212[0]+-1*P_111000211*R_213[0]+P_211000011*R_311[0]+-1*P_211000111*R_312[0]+P_211000211*R_313[0]; double PR_010001011111=P_010001011*R_111[0]+-1*P_010001111*R_112[0]+P_010001211*R_113[0]+-1*P_010101011*R_121[0]+P_010101111*R_122[0]+-1*P_010101211*R_123[0]+-1*P_110001011*R_211[0]+P_110001111*R_212[0]+-1*P_110001211*R_213[0]+P_110101011*R_221[0]+-1*P_110101111*R_222[0]+P_110101211*R_223[0]; double PR_010000012111=P_010000012*R_111[0]+-1*P_010000112*R_112[0]+P_010000212*R_113[0]+-1*P_010000312*R_114[0]+-1*P_110000012*R_211[0]+P_110000112*R_212[0]+-1*P_110000212*R_213[0]+P_110000312*R_214[0]; double PR_002010010111=P_002010010*R_111[0]+-1*P_002010110*R_112[0]+-1*P_002110010*R_121[0]+P_002110110*R_122[0]+-1*P_102010010*R_211[0]+P_102010110*R_212[0]+P_102110010*R_221[0]+-1*P_102110110*R_222[0]+P_202010010*R_311[0]+-1*P_202010110*R_312[0]+-1*P_202110010*R_321[0]+P_202110110*R_322[0]; double PR_001011010111=P_001011010*R_111[0]+-1*P_001011110*R_112[0]+-1*P_001111010*R_121[0]+P_001111110*R_122[0]+P_001211010*R_131[0]+-1*P_001211110*R_132[0]+-1*P_101011010*R_211[0]+P_101011110*R_212[0]+P_101111010*R_221[0]+-1*P_101111110*R_222[0]+-1*P_101211010*R_231[0]+P_101211110*R_232[0]; double PR_000012010111=P_000012010*R_111[0]+-1*P_000012110*R_112[0]+-1*P_000112010*R_121[0]+P_000112110*R_122[0]+P_000212010*R_131[0]+-1*P_000212110*R_132[0]+-1*P_000312010*R_141[0]+P_000312110*R_142[0]; double PR_001010011111=P_001010011*R_111[0]+-1*P_001010111*R_112[0]+P_001010211*R_113[0]+-1*P_001110011*R_121[0]+P_001110111*R_122[0]+-1*P_001110211*R_123[0]+-1*P_101010011*R_211[0]+P_101010111*R_212[0]+-1*P_101010211*R_213[0]+P_101110011*R_221[0]+-1*P_101110111*R_222[0]+P_101110211*R_223[0]; double PR_000011011111=P_000011011*R_111[0]+-1*P_000011111*R_112[0]+P_000011211*R_113[0]+-1*P_000111011*R_121[0]+P_000111111*R_122[0]+-1*P_000111211*R_123[0]+P_000211011*R_131[0]+-1*P_000211111*R_132[0]+P_000211211*R_133[0]; double PR_000010012111=P_000010012*R_111[0]+-1*P_000010112*R_112[0]+P_000010212*R_113[0]+-1*P_000010312*R_114[0]+-1*P_000110012*R_121[0]+P_000110112*R_122[0]+-1*P_000110212*R_123[0]+P_000110312*R_124[0]; double PR_002000020111=P_002000020*R_111[0]+-1*P_002000120*R_112[0]+P_002000220*R_113[0]+-1*P_102000020*R_211[0]+P_102000120*R_212[0]+-1*P_102000220*R_213[0]+P_202000020*R_311[0]+-1*P_202000120*R_312[0]+P_202000220*R_313[0]; double PR_001001020111=P_001001020*R_111[0]+-1*P_001001120*R_112[0]+P_001001220*R_113[0]+-1*P_001101020*R_121[0]+P_001101120*R_122[0]+-1*P_001101220*R_123[0]+-1*P_101001020*R_211[0]+P_101001120*R_212[0]+-1*P_101001220*R_213[0]+P_101101020*R_221[0]+-1*P_101101120*R_222[0]+P_101101220*R_223[0]; double PR_000002020111=P_000002020*R_111[0]+-1*P_000002120*R_112[0]+P_000002220*R_113[0]+-1*P_000102020*R_121[0]+P_000102120*R_122[0]+-1*P_000102220*R_123[0]+P_000202020*R_131[0]+-1*P_000202120*R_132[0]+P_000202220*R_133[0]; double PR_001000021111=P_001000021*R_111[0]+-1*P_001000121*R_112[0]+P_001000221*R_113[0]+-1*P_001000321*R_114[0]+-1*P_101000021*R_211[0]+P_101000121*R_212[0]+-1*P_101000221*R_213[0]+P_101000321*R_214[0]; double PR_000001021111=P_000001021*R_111[0]+-1*P_000001121*R_112[0]+P_000001221*R_113[0]+-1*P_000001321*R_114[0]+-1*P_000101021*R_121[0]+P_000101121*R_122[0]+-1*P_000101221*R_123[0]+P_000101321*R_124[0]; double PR_000000022111=P_000000022*R_111[0]+-1*P_000000122*R_112[0]+P_000000222*R_113[0]+-1*P_000000322*R_114[0]+P_000000422*R_115[0]; double PR_022000000120=P_022000000*R_120[0]+-1*P_122000000*R_220[0]+P_222000000*R_320[0]+-1*P_322000000*R_420[0]+P_422000000*R_520[0]; double PR_021001000120=P_021001000*R_120[0]+-1*P_021101000*R_130[0]+-1*P_121001000*R_220[0]+P_121101000*R_230[0]+P_221001000*R_320[0]+-1*P_221101000*R_330[0]+-1*P_321001000*R_420[0]+P_321101000*R_430[0]; double PR_020002000120=P_020002000*R_120[0]+-1*P_020102000*R_130[0]+P_020202000*R_140[0]+-1*P_120002000*R_220[0]+P_120102000*R_230[0]+-1*P_120202000*R_240[0]+P_220002000*R_320[0]+-1*P_220102000*R_330[0]+P_220202000*R_340[0]; double PR_021000001120=P_021000001*R_120[0]+-1*P_021000101*R_121[0]+-1*P_121000001*R_220[0]+P_121000101*R_221[0]+P_221000001*R_320[0]+-1*P_221000101*R_321[0]+-1*P_321000001*R_420[0]+P_321000101*R_421[0]; double PR_020001001120=P_020001001*R_120[0]+-1*P_020001101*R_121[0]+-1*P_020101001*R_130[0]+P_020101101*R_131[0]+-1*P_120001001*R_220[0]+P_120001101*R_221[0]+P_120101001*R_230[0]+-1*P_120101101*R_231[0]+P_220001001*R_320[0]+-1*P_220001101*R_321[0]+-1*P_220101001*R_330[0]+P_220101101*R_331[0]; double PR_020000002120=P_020000002*R_120[0]+-1*P_020000102*R_121[0]+P_020000202*R_122[0]+-1*P_120000002*R_220[0]+P_120000102*R_221[0]+-1*P_120000202*R_222[0]+P_220000002*R_320[0]+-1*P_220000102*R_321[0]+P_220000202*R_322[0]; double PR_012010000120=P_012010000*R_120[0]+-1*P_012110000*R_130[0]+-1*P_112010000*R_220[0]+P_112110000*R_230[0]+P_212010000*R_320[0]+-1*P_212110000*R_330[0]+-1*P_312010000*R_420[0]+P_312110000*R_430[0]; double PR_011011000120=P_011011000*R_120[0]+-1*P_011111000*R_130[0]+P_011211000*R_140[0]+-1*P_111011000*R_220[0]+P_111111000*R_230[0]+-1*P_111211000*R_240[0]+P_211011000*R_320[0]+-1*P_211111000*R_330[0]+P_211211000*R_340[0]; double PR_010012000120=P_010012000*R_120[0]+-1*P_010112000*R_130[0]+P_010212000*R_140[0]+-1*P_010312000*R_150[0]+-1*P_110012000*R_220[0]+P_110112000*R_230[0]+-1*P_110212000*R_240[0]+P_110312000*R_250[0]; double PR_011010001120=P_011010001*R_120[0]+-1*P_011010101*R_121[0]+-1*P_011110001*R_130[0]+P_011110101*R_131[0]+-1*P_111010001*R_220[0]+P_111010101*R_221[0]+P_111110001*R_230[0]+-1*P_111110101*R_231[0]+P_211010001*R_320[0]+-1*P_211010101*R_321[0]+-1*P_211110001*R_330[0]+P_211110101*R_331[0]; double PR_010011001120=P_010011001*R_120[0]+-1*P_010011101*R_121[0]+-1*P_010111001*R_130[0]+P_010111101*R_131[0]+P_010211001*R_140[0]+-1*P_010211101*R_141[0]+-1*P_110011001*R_220[0]+P_110011101*R_221[0]+P_110111001*R_230[0]+-1*P_110111101*R_231[0]+-1*P_110211001*R_240[0]+P_110211101*R_241[0]; double PR_010010002120=P_010010002*R_120[0]+-1*P_010010102*R_121[0]+P_010010202*R_122[0]+-1*P_010110002*R_130[0]+P_010110102*R_131[0]+-1*P_010110202*R_132[0]+-1*P_110010002*R_220[0]+P_110010102*R_221[0]+-1*P_110010202*R_222[0]+P_110110002*R_230[0]+-1*P_110110102*R_231[0]+P_110110202*R_232[0]; double PR_002020000120=P_002020000*R_120[0]+-1*P_002120000*R_130[0]+P_002220000*R_140[0]+-1*P_102020000*R_220[0]+P_102120000*R_230[0]+-1*P_102220000*R_240[0]+P_202020000*R_320[0]+-1*P_202120000*R_330[0]+P_202220000*R_340[0]; double PR_001021000120=P_001021000*R_120[0]+-1*P_001121000*R_130[0]+P_001221000*R_140[0]+-1*P_001321000*R_150[0]+-1*P_101021000*R_220[0]+P_101121000*R_230[0]+-1*P_101221000*R_240[0]+P_101321000*R_250[0]; double PR_000022000120=P_000022000*R_120[0]+-1*P_000122000*R_130[0]+P_000222000*R_140[0]+-1*P_000322000*R_150[0]+P_000422000*R_160[0]; double PR_001020001120=P_001020001*R_120[0]+-1*P_001020101*R_121[0]+-1*P_001120001*R_130[0]+P_001120101*R_131[0]+P_001220001*R_140[0]+-1*P_001220101*R_141[0]+-1*P_101020001*R_220[0]+P_101020101*R_221[0]+P_101120001*R_230[0]+-1*P_101120101*R_231[0]+-1*P_101220001*R_240[0]+P_101220101*R_241[0]; double PR_000021001120=P_000021001*R_120[0]+-1*P_000021101*R_121[0]+-1*P_000121001*R_130[0]+P_000121101*R_131[0]+P_000221001*R_140[0]+-1*P_000221101*R_141[0]+-1*P_000321001*R_150[0]+P_000321101*R_151[0]; double PR_000020002120=P_000020002*R_120[0]+-1*P_000020102*R_121[0]+P_000020202*R_122[0]+-1*P_000120002*R_130[0]+P_000120102*R_131[0]+-1*P_000120202*R_132[0]+P_000220002*R_140[0]+-1*P_000220102*R_141[0]+P_000220202*R_142[0]; double PR_012000010120=P_012000010*R_120[0]+-1*P_012000110*R_121[0]+-1*P_112000010*R_220[0]+P_112000110*R_221[0]+P_212000010*R_320[0]+-1*P_212000110*R_321[0]+-1*P_312000010*R_420[0]+P_312000110*R_421[0]; double PR_011001010120=P_011001010*R_120[0]+-1*P_011001110*R_121[0]+-1*P_011101010*R_130[0]+P_011101110*R_131[0]+-1*P_111001010*R_220[0]+P_111001110*R_221[0]+P_111101010*R_230[0]+-1*P_111101110*R_231[0]+P_211001010*R_320[0]+-1*P_211001110*R_321[0]+-1*P_211101010*R_330[0]+P_211101110*R_331[0]; double PR_010002010120=P_010002010*R_120[0]+-1*P_010002110*R_121[0]+-1*P_010102010*R_130[0]+P_010102110*R_131[0]+P_010202010*R_140[0]+-1*P_010202110*R_141[0]+-1*P_110002010*R_220[0]+P_110002110*R_221[0]+P_110102010*R_230[0]+-1*P_110102110*R_231[0]+-1*P_110202010*R_240[0]+P_110202110*R_241[0]; double PR_011000011120=P_011000011*R_120[0]+-1*P_011000111*R_121[0]+P_011000211*R_122[0]+-1*P_111000011*R_220[0]+P_111000111*R_221[0]+-1*P_111000211*R_222[0]+P_211000011*R_320[0]+-1*P_211000111*R_321[0]+P_211000211*R_322[0]; double PR_010001011120=P_010001011*R_120[0]+-1*P_010001111*R_121[0]+P_010001211*R_122[0]+-1*P_010101011*R_130[0]+P_010101111*R_131[0]+-1*P_010101211*R_132[0]+-1*P_110001011*R_220[0]+P_110001111*R_221[0]+-1*P_110001211*R_222[0]+P_110101011*R_230[0]+-1*P_110101111*R_231[0]+P_110101211*R_232[0]; double PR_010000012120=P_010000012*R_120[0]+-1*P_010000112*R_121[0]+P_010000212*R_122[0]+-1*P_010000312*R_123[0]+-1*P_110000012*R_220[0]+P_110000112*R_221[0]+-1*P_110000212*R_222[0]+P_110000312*R_223[0]; double PR_002010010120=P_002010010*R_120[0]+-1*P_002010110*R_121[0]+-1*P_002110010*R_130[0]+P_002110110*R_131[0]+-1*P_102010010*R_220[0]+P_102010110*R_221[0]+P_102110010*R_230[0]+-1*P_102110110*R_231[0]+P_202010010*R_320[0]+-1*P_202010110*R_321[0]+-1*P_202110010*R_330[0]+P_202110110*R_331[0]; double PR_001011010120=P_001011010*R_120[0]+-1*P_001011110*R_121[0]+-1*P_001111010*R_130[0]+P_001111110*R_131[0]+P_001211010*R_140[0]+-1*P_001211110*R_141[0]+-1*P_101011010*R_220[0]+P_101011110*R_221[0]+P_101111010*R_230[0]+-1*P_101111110*R_231[0]+-1*P_101211010*R_240[0]+P_101211110*R_241[0]; double PR_000012010120=P_000012010*R_120[0]+-1*P_000012110*R_121[0]+-1*P_000112010*R_130[0]+P_000112110*R_131[0]+P_000212010*R_140[0]+-1*P_000212110*R_141[0]+-1*P_000312010*R_150[0]+P_000312110*R_151[0]; double PR_001010011120=P_001010011*R_120[0]+-1*P_001010111*R_121[0]+P_001010211*R_122[0]+-1*P_001110011*R_130[0]+P_001110111*R_131[0]+-1*P_001110211*R_132[0]+-1*P_101010011*R_220[0]+P_101010111*R_221[0]+-1*P_101010211*R_222[0]+P_101110011*R_230[0]+-1*P_101110111*R_231[0]+P_101110211*R_232[0]; double PR_000011011120=P_000011011*R_120[0]+-1*P_000011111*R_121[0]+P_000011211*R_122[0]+-1*P_000111011*R_130[0]+P_000111111*R_131[0]+-1*P_000111211*R_132[0]+P_000211011*R_140[0]+-1*P_000211111*R_141[0]+P_000211211*R_142[0]; double PR_000010012120=P_000010012*R_120[0]+-1*P_000010112*R_121[0]+P_000010212*R_122[0]+-1*P_000010312*R_123[0]+-1*P_000110012*R_130[0]+P_000110112*R_131[0]+-1*P_000110212*R_132[0]+P_000110312*R_133[0]; double PR_002000020120=P_002000020*R_120[0]+-1*P_002000120*R_121[0]+P_002000220*R_122[0]+-1*P_102000020*R_220[0]+P_102000120*R_221[0]+-1*P_102000220*R_222[0]+P_202000020*R_320[0]+-1*P_202000120*R_321[0]+P_202000220*R_322[0]; double PR_001001020120=P_001001020*R_120[0]+-1*P_001001120*R_121[0]+P_001001220*R_122[0]+-1*P_001101020*R_130[0]+P_001101120*R_131[0]+-1*P_001101220*R_132[0]+-1*P_101001020*R_220[0]+P_101001120*R_221[0]+-1*P_101001220*R_222[0]+P_101101020*R_230[0]+-1*P_101101120*R_231[0]+P_101101220*R_232[0]; double PR_000002020120=P_000002020*R_120[0]+-1*P_000002120*R_121[0]+P_000002220*R_122[0]+-1*P_000102020*R_130[0]+P_000102120*R_131[0]+-1*P_000102220*R_132[0]+P_000202020*R_140[0]+-1*P_000202120*R_141[0]+P_000202220*R_142[0]; double PR_001000021120=P_001000021*R_120[0]+-1*P_001000121*R_121[0]+P_001000221*R_122[0]+-1*P_001000321*R_123[0]+-1*P_101000021*R_220[0]+P_101000121*R_221[0]+-1*P_101000221*R_222[0]+P_101000321*R_223[0]; double PR_000001021120=P_000001021*R_120[0]+-1*P_000001121*R_121[0]+P_000001221*R_122[0]+-1*P_000001321*R_123[0]+-1*P_000101021*R_130[0]+P_000101121*R_131[0]+-1*P_000101221*R_132[0]+P_000101321*R_133[0]; double PR_000000022120=P_000000022*R_120[0]+-1*P_000000122*R_121[0]+P_000000222*R_122[0]+-1*P_000000322*R_123[0]+P_000000422*R_124[0]; double PR_022000000201=P_022000000*R_201[0]+-1*P_122000000*R_301[0]+P_222000000*R_401[0]+-1*P_322000000*R_501[0]+P_422000000*R_601[0]; double PR_021001000201=P_021001000*R_201[0]+-1*P_021101000*R_211[0]+-1*P_121001000*R_301[0]+P_121101000*R_311[0]+P_221001000*R_401[0]+-1*P_221101000*R_411[0]+-1*P_321001000*R_501[0]+P_321101000*R_511[0]; double PR_020002000201=P_020002000*R_201[0]+-1*P_020102000*R_211[0]+P_020202000*R_221[0]+-1*P_120002000*R_301[0]+P_120102000*R_311[0]+-1*P_120202000*R_321[0]+P_220002000*R_401[0]+-1*P_220102000*R_411[0]+P_220202000*R_421[0]; double PR_021000001201=P_021000001*R_201[0]+-1*P_021000101*R_202[0]+-1*P_121000001*R_301[0]+P_121000101*R_302[0]+P_221000001*R_401[0]+-1*P_221000101*R_402[0]+-1*P_321000001*R_501[0]+P_321000101*R_502[0]; double PR_020001001201=P_020001001*R_201[0]+-1*P_020001101*R_202[0]+-1*P_020101001*R_211[0]+P_020101101*R_212[0]+-1*P_120001001*R_301[0]+P_120001101*R_302[0]+P_120101001*R_311[0]+-1*P_120101101*R_312[0]+P_220001001*R_401[0]+-1*P_220001101*R_402[0]+-1*P_220101001*R_411[0]+P_220101101*R_412[0]; double PR_020000002201=P_020000002*R_201[0]+-1*P_020000102*R_202[0]+P_020000202*R_203[0]+-1*P_120000002*R_301[0]+P_120000102*R_302[0]+-1*P_120000202*R_303[0]+P_220000002*R_401[0]+-1*P_220000102*R_402[0]+P_220000202*R_403[0]; double PR_012010000201=P_012010000*R_201[0]+-1*P_012110000*R_211[0]+-1*P_112010000*R_301[0]+P_112110000*R_311[0]+P_212010000*R_401[0]+-1*P_212110000*R_411[0]+-1*P_312010000*R_501[0]+P_312110000*R_511[0]; double PR_011011000201=P_011011000*R_201[0]+-1*P_011111000*R_211[0]+P_011211000*R_221[0]+-1*P_111011000*R_301[0]+P_111111000*R_311[0]+-1*P_111211000*R_321[0]+P_211011000*R_401[0]+-1*P_211111000*R_411[0]+P_211211000*R_421[0]; double PR_010012000201=P_010012000*R_201[0]+-1*P_010112000*R_211[0]+P_010212000*R_221[0]+-1*P_010312000*R_231[0]+-1*P_110012000*R_301[0]+P_110112000*R_311[0]+-1*P_110212000*R_321[0]+P_110312000*R_331[0]; double PR_011010001201=P_011010001*R_201[0]+-1*P_011010101*R_202[0]+-1*P_011110001*R_211[0]+P_011110101*R_212[0]+-1*P_111010001*R_301[0]+P_111010101*R_302[0]+P_111110001*R_311[0]+-1*P_111110101*R_312[0]+P_211010001*R_401[0]+-1*P_211010101*R_402[0]+-1*P_211110001*R_411[0]+P_211110101*R_412[0]; double PR_010011001201=P_010011001*R_201[0]+-1*P_010011101*R_202[0]+-1*P_010111001*R_211[0]+P_010111101*R_212[0]+P_010211001*R_221[0]+-1*P_010211101*R_222[0]+-1*P_110011001*R_301[0]+P_110011101*R_302[0]+P_110111001*R_311[0]+-1*P_110111101*R_312[0]+-1*P_110211001*R_321[0]+P_110211101*R_322[0]; double PR_010010002201=P_010010002*R_201[0]+-1*P_010010102*R_202[0]+P_010010202*R_203[0]+-1*P_010110002*R_211[0]+P_010110102*R_212[0]+-1*P_010110202*R_213[0]+-1*P_110010002*R_301[0]+P_110010102*R_302[0]+-1*P_110010202*R_303[0]+P_110110002*R_311[0]+-1*P_110110102*R_312[0]+P_110110202*R_313[0]; double PR_002020000201=P_002020000*R_201[0]+-1*P_002120000*R_211[0]+P_002220000*R_221[0]+-1*P_102020000*R_301[0]+P_102120000*R_311[0]+-1*P_102220000*R_321[0]+P_202020000*R_401[0]+-1*P_202120000*R_411[0]+P_202220000*R_421[0]; double PR_001021000201=P_001021000*R_201[0]+-1*P_001121000*R_211[0]+P_001221000*R_221[0]+-1*P_001321000*R_231[0]+-1*P_101021000*R_301[0]+P_101121000*R_311[0]+-1*P_101221000*R_321[0]+P_101321000*R_331[0]; double PR_000022000201=P_000022000*R_201[0]+-1*P_000122000*R_211[0]+P_000222000*R_221[0]+-1*P_000322000*R_231[0]+P_000422000*R_241[0]; double PR_001020001201=P_001020001*R_201[0]+-1*P_001020101*R_202[0]+-1*P_001120001*R_211[0]+P_001120101*R_212[0]+P_001220001*R_221[0]+-1*P_001220101*R_222[0]+-1*P_101020001*R_301[0]+P_101020101*R_302[0]+P_101120001*R_311[0]+-1*P_101120101*R_312[0]+-1*P_101220001*R_321[0]+P_101220101*R_322[0]; double PR_000021001201=P_000021001*R_201[0]+-1*P_000021101*R_202[0]+-1*P_000121001*R_211[0]+P_000121101*R_212[0]+P_000221001*R_221[0]+-1*P_000221101*R_222[0]+-1*P_000321001*R_231[0]+P_000321101*R_232[0]; double PR_000020002201=P_000020002*R_201[0]+-1*P_000020102*R_202[0]+P_000020202*R_203[0]+-1*P_000120002*R_211[0]+P_000120102*R_212[0]+-1*P_000120202*R_213[0]+P_000220002*R_221[0]+-1*P_000220102*R_222[0]+P_000220202*R_223[0]; double PR_012000010201=P_012000010*R_201[0]+-1*P_012000110*R_202[0]+-1*P_112000010*R_301[0]+P_112000110*R_302[0]+P_212000010*R_401[0]+-1*P_212000110*R_402[0]+-1*P_312000010*R_501[0]+P_312000110*R_502[0]; double PR_011001010201=P_011001010*R_201[0]+-1*P_011001110*R_202[0]+-1*P_011101010*R_211[0]+P_011101110*R_212[0]+-1*P_111001010*R_301[0]+P_111001110*R_302[0]+P_111101010*R_311[0]+-1*P_111101110*R_312[0]+P_211001010*R_401[0]+-1*P_211001110*R_402[0]+-1*P_211101010*R_411[0]+P_211101110*R_412[0]; double PR_010002010201=P_010002010*R_201[0]+-1*P_010002110*R_202[0]+-1*P_010102010*R_211[0]+P_010102110*R_212[0]+P_010202010*R_221[0]+-1*P_010202110*R_222[0]+-1*P_110002010*R_301[0]+P_110002110*R_302[0]+P_110102010*R_311[0]+-1*P_110102110*R_312[0]+-1*P_110202010*R_321[0]+P_110202110*R_322[0]; double PR_011000011201=P_011000011*R_201[0]+-1*P_011000111*R_202[0]+P_011000211*R_203[0]+-1*P_111000011*R_301[0]+P_111000111*R_302[0]+-1*P_111000211*R_303[0]+P_211000011*R_401[0]+-1*P_211000111*R_402[0]+P_211000211*R_403[0]; double PR_010001011201=P_010001011*R_201[0]+-1*P_010001111*R_202[0]+P_010001211*R_203[0]+-1*P_010101011*R_211[0]+P_010101111*R_212[0]+-1*P_010101211*R_213[0]+-1*P_110001011*R_301[0]+P_110001111*R_302[0]+-1*P_110001211*R_303[0]+P_110101011*R_311[0]+-1*P_110101111*R_312[0]+P_110101211*R_313[0]; double PR_010000012201=P_010000012*R_201[0]+-1*P_010000112*R_202[0]+P_010000212*R_203[0]+-1*P_010000312*R_204[0]+-1*P_110000012*R_301[0]+P_110000112*R_302[0]+-1*P_110000212*R_303[0]+P_110000312*R_304[0]; double PR_002010010201=P_002010010*R_201[0]+-1*P_002010110*R_202[0]+-1*P_002110010*R_211[0]+P_002110110*R_212[0]+-1*P_102010010*R_301[0]+P_102010110*R_302[0]+P_102110010*R_311[0]+-1*P_102110110*R_312[0]+P_202010010*R_401[0]+-1*P_202010110*R_402[0]+-1*P_202110010*R_411[0]+P_202110110*R_412[0]; double PR_001011010201=P_001011010*R_201[0]+-1*P_001011110*R_202[0]+-1*P_001111010*R_211[0]+P_001111110*R_212[0]+P_001211010*R_221[0]+-1*P_001211110*R_222[0]+-1*P_101011010*R_301[0]+P_101011110*R_302[0]+P_101111010*R_311[0]+-1*P_101111110*R_312[0]+-1*P_101211010*R_321[0]+P_101211110*R_322[0]; double PR_000012010201=P_000012010*R_201[0]+-1*P_000012110*R_202[0]+-1*P_000112010*R_211[0]+P_000112110*R_212[0]+P_000212010*R_221[0]+-1*P_000212110*R_222[0]+-1*P_000312010*R_231[0]+P_000312110*R_232[0]; double PR_001010011201=P_001010011*R_201[0]+-1*P_001010111*R_202[0]+P_001010211*R_203[0]+-1*P_001110011*R_211[0]+P_001110111*R_212[0]+-1*P_001110211*R_213[0]+-1*P_101010011*R_301[0]+P_101010111*R_302[0]+-1*P_101010211*R_303[0]+P_101110011*R_311[0]+-1*P_101110111*R_312[0]+P_101110211*R_313[0]; double PR_000011011201=P_000011011*R_201[0]+-1*P_000011111*R_202[0]+P_000011211*R_203[0]+-1*P_000111011*R_211[0]+P_000111111*R_212[0]+-1*P_000111211*R_213[0]+P_000211011*R_221[0]+-1*P_000211111*R_222[0]+P_000211211*R_223[0]; double PR_000010012201=P_000010012*R_201[0]+-1*P_000010112*R_202[0]+P_000010212*R_203[0]+-1*P_000010312*R_204[0]+-1*P_000110012*R_211[0]+P_000110112*R_212[0]+-1*P_000110212*R_213[0]+P_000110312*R_214[0]; double PR_002000020201=P_002000020*R_201[0]+-1*P_002000120*R_202[0]+P_002000220*R_203[0]+-1*P_102000020*R_301[0]+P_102000120*R_302[0]+-1*P_102000220*R_303[0]+P_202000020*R_401[0]+-1*P_202000120*R_402[0]+P_202000220*R_403[0]; double PR_001001020201=P_001001020*R_201[0]+-1*P_001001120*R_202[0]+P_001001220*R_203[0]+-1*P_001101020*R_211[0]+P_001101120*R_212[0]+-1*P_001101220*R_213[0]+-1*P_101001020*R_301[0]+P_101001120*R_302[0]+-1*P_101001220*R_303[0]+P_101101020*R_311[0]+-1*P_101101120*R_312[0]+P_101101220*R_313[0]; double PR_000002020201=P_000002020*R_201[0]+-1*P_000002120*R_202[0]+P_000002220*R_203[0]+-1*P_000102020*R_211[0]+P_000102120*R_212[0]+-1*P_000102220*R_213[0]+P_000202020*R_221[0]+-1*P_000202120*R_222[0]+P_000202220*R_223[0]; double PR_001000021201=P_001000021*R_201[0]+-1*P_001000121*R_202[0]+P_001000221*R_203[0]+-1*P_001000321*R_204[0]+-1*P_101000021*R_301[0]+P_101000121*R_302[0]+-1*P_101000221*R_303[0]+P_101000321*R_304[0]; double PR_000001021201=P_000001021*R_201[0]+-1*P_000001121*R_202[0]+P_000001221*R_203[0]+-1*P_000001321*R_204[0]+-1*P_000101021*R_211[0]+P_000101121*R_212[0]+-1*P_000101221*R_213[0]+P_000101321*R_214[0]; double PR_000000022201=P_000000022*R_201[0]+-1*P_000000122*R_202[0]+P_000000222*R_203[0]+-1*P_000000322*R_204[0]+P_000000422*R_205[0]; double PR_022000000210=P_022000000*R_210[0]+-1*P_122000000*R_310[0]+P_222000000*R_410[0]+-1*P_322000000*R_510[0]+P_422000000*R_610[0]; double PR_021001000210=P_021001000*R_210[0]+-1*P_021101000*R_220[0]+-1*P_121001000*R_310[0]+P_121101000*R_320[0]+P_221001000*R_410[0]+-1*P_221101000*R_420[0]+-1*P_321001000*R_510[0]+P_321101000*R_520[0]; double PR_020002000210=P_020002000*R_210[0]+-1*P_020102000*R_220[0]+P_020202000*R_230[0]+-1*P_120002000*R_310[0]+P_120102000*R_320[0]+-1*P_120202000*R_330[0]+P_220002000*R_410[0]+-1*P_220102000*R_420[0]+P_220202000*R_430[0]; double PR_021000001210=P_021000001*R_210[0]+-1*P_021000101*R_211[0]+-1*P_121000001*R_310[0]+P_121000101*R_311[0]+P_221000001*R_410[0]+-1*P_221000101*R_411[0]+-1*P_321000001*R_510[0]+P_321000101*R_511[0]; double PR_020001001210=P_020001001*R_210[0]+-1*P_020001101*R_211[0]+-1*P_020101001*R_220[0]+P_020101101*R_221[0]+-1*P_120001001*R_310[0]+P_120001101*R_311[0]+P_120101001*R_320[0]+-1*P_120101101*R_321[0]+P_220001001*R_410[0]+-1*P_220001101*R_411[0]+-1*P_220101001*R_420[0]+P_220101101*R_421[0]; double PR_020000002210=P_020000002*R_210[0]+-1*P_020000102*R_211[0]+P_020000202*R_212[0]+-1*P_120000002*R_310[0]+P_120000102*R_311[0]+-1*P_120000202*R_312[0]+P_220000002*R_410[0]+-1*P_220000102*R_411[0]+P_220000202*R_412[0]; double PR_012010000210=P_012010000*R_210[0]+-1*P_012110000*R_220[0]+-1*P_112010000*R_310[0]+P_112110000*R_320[0]+P_212010000*R_410[0]+-1*P_212110000*R_420[0]+-1*P_312010000*R_510[0]+P_312110000*R_520[0]; double PR_011011000210=P_011011000*R_210[0]+-1*P_011111000*R_220[0]+P_011211000*R_230[0]+-1*P_111011000*R_310[0]+P_111111000*R_320[0]+-1*P_111211000*R_330[0]+P_211011000*R_410[0]+-1*P_211111000*R_420[0]+P_211211000*R_430[0]; double PR_010012000210=P_010012000*R_210[0]+-1*P_010112000*R_220[0]+P_010212000*R_230[0]+-1*P_010312000*R_240[0]+-1*P_110012000*R_310[0]+P_110112000*R_320[0]+-1*P_110212000*R_330[0]+P_110312000*R_340[0]; double PR_011010001210=P_011010001*R_210[0]+-1*P_011010101*R_211[0]+-1*P_011110001*R_220[0]+P_011110101*R_221[0]+-1*P_111010001*R_310[0]+P_111010101*R_311[0]+P_111110001*R_320[0]+-1*P_111110101*R_321[0]+P_211010001*R_410[0]+-1*P_211010101*R_411[0]+-1*P_211110001*R_420[0]+P_211110101*R_421[0]; double PR_010011001210=P_010011001*R_210[0]+-1*P_010011101*R_211[0]+-1*P_010111001*R_220[0]+P_010111101*R_221[0]+P_010211001*R_230[0]+-1*P_010211101*R_231[0]+-1*P_110011001*R_310[0]+P_110011101*R_311[0]+P_110111001*R_320[0]+-1*P_110111101*R_321[0]+-1*P_110211001*R_330[0]+P_110211101*R_331[0]; double PR_010010002210=P_010010002*R_210[0]+-1*P_010010102*R_211[0]+P_010010202*R_212[0]+-1*P_010110002*R_220[0]+P_010110102*R_221[0]+-1*P_010110202*R_222[0]+-1*P_110010002*R_310[0]+P_110010102*R_311[0]+-1*P_110010202*R_312[0]+P_110110002*R_320[0]+-1*P_110110102*R_321[0]+P_110110202*R_322[0]; double PR_002020000210=P_002020000*R_210[0]+-1*P_002120000*R_220[0]+P_002220000*R_230[0]+-1*P_102020000*R_310[0]+P_102120000*R_320[0]+-1*P_102220000*R_330[0]+P_202020000*R_410[0]+-1*P_202120000*R_420[0]+P_202220000*R_430[0]; double PR_001021000210=P_001021000*R_210[0]+-1*P_001121000*R_220[0]+P_001221000*R_230[0]+-1*P_001321000*R_240[0]+-1*P_101021000*R_310[0]+P_101121000*R_320[0]+-1*P_101221000*R_330[0]+P_101321000*R_340[0]; double PR_000022000210=P_000022000*R_210[0]+-1*P_000122000*R_220[0]+P_000222000*R_230[0]+-1*P_000322000*R_240[0]+P_000422000*R_250[0]; double PR_001020001210=P_001020001*R_210[0]+-1*P_001020101*R_211[0]+-1*P_001120001*R_220[0]+P_001120101*R_221[0]+P_001220001*R_230[0]+-1*P_001220101*R_231[0]+-1*P_101020001*R_310[0]+P_101020101*R_311[0]+P_101120001*R_320[0]+-1*P_101120101*R_321[0]+-1*P_101220001*R_330[0]+P_101220101*R_331[0]; double PR_000021001210=P_000021001*R_210[0]+-1*P_000021101*R_211[0]+-1*P_000121001*R_220[0]+P_000121101*R_221[0]+P_000221001*R_230[0]+-1*P_000221101*R_231[0]+-1*P_000321001*R_240[0]+P_000321101*R_241[0]; double PR_000020002210=P_000020002*R_210[0]+-1*P_000020102*R_211[0]+P_000020202*R_212[0]+-1*P_000120002*R_220[0]+P_000120102*R_221[0]+-1*P_000120202*R_222[0]+P_000220002*R_230[0]+-1*P_000220102*R_231[0]+P_000220202*R_232[0]; double PR_012000010210=P_012000010*R_210[0]+-1*P_012000110*R_211[0]+-1*P_112000010*R_310[0]+P_112000110*R_311[0]+P_212000010*R_410[0]+-1*P_212000110*R_411[0]+-1*P_312000010*R_510[0]+P_312000110*R_511[0]; double PR_011001010210=P_011001010*R_210[0]+-1*P_011001110*R_211[0]+-1*P_011101010*R_220[0]+P_011101110*R_221[0]+-1*P_111001010*R_310[0]+P_111001110*R_311[0]+P_111101010*R_320[0]+-1*P_111101110*R_321[0]+P_211001010*R_410[0]+-1*P_211001110*R_411[0]+-1*P_211101010*R_420[0]+P_211101110*R_421[0]; double PR_010002010210=P_010002010*R_210[0]+-1*P_010002110*R_211[0]+-1*P_010102010*R_220[0]+P_010102110*R_221[0]+P_010202010*R_230[0]+-1*P_010202110*R_231[0]+-1*P_110002010*R_310[0]+P_110002110*R_311[0]+P_110102010*R_320[0]+-1*P_110102110*R_321[0]+-1*P_110202010*R_330[0]+P_110202110*R_331[0]; double PR_011000011210=P_011000011*R_210[0]+-1*P_011000111*R_211[0]+P_011000211*R_212[0]+-1*P_111000011*R_310[0]+P_111000111*R_311[0]+-1*P_111000211*R_312[0]+P_211000011*R_410[0]+-1*P_211000111*R_411[0]+P_211000211*R_412[0]; double PR_010001011210=P_010001011*R_210[0]+-1*P_010001111*R_211[0]+P_010001211*R_212[0]+-1*P_010101011*R_220[0]+P_010101111*R_221[0]+-1*P_010101211*R_222[0]+-1*P_110001011*R_310[0]+P_110001111*R_311[0]+-1*P_110001211*R_312[0]+P_110101011*R_320[0]+-1*P_110101111*R_321[0]+P_110101211*R_322[0]; double PR_010000012210=P_010000012*R_210[0]+-1*P_010000112*R_211[0]+P_010000212*R_212[0]+-1*P_010000312*R_213[0]+-1*P_110000012*R_310[0]+P_110000112*R_311[0]+-1*P_110000212*R_312[0]+P_110000312*R_313[0]; double PR_002010010210=P_002010010*R_210[0]+-1*P_002010110*R_211[0]+-1*P_002110010*R_220[0]+P_002110110*R_221[0]+-1*P_102010010*R_310[0]+P_102010110*R_311[0]+P_102110010*R_320[0]+-1*P_102110110*R_321[0]+P_202010010*R_410[0]+-1*P_202010110*R_411[0]+-1*P_202110010*R_420[0]+P_202110110*R_421[0]; double PR_001011010210=P_001011010*R_210[0]+-1*P_001011110*R_211[0]+-1*P_001111010*R_220[0]+P_001111110*R_221[0]+P_001211010*R_230[0]+-1*P_001211110*R_231[0]+-1*P_101011010*R_310[0]+P_101011110*R_311[0]+P_101111010*R_320[0]+-1*P_101111110*R_321[0]+-1*P_101211010*R_330[0]+P_101211110*R_331[0]; double PR_000012010210=P_000012010*R_210[0]+-1*P_000012110*R_211[0]+-1*P_000112010*R_220[0]+P_000112110*R_221[0]+P_000212010*R_230[0]+-1*P_000212110*R_231[0]+-1*P_000312010*R_240[0]+P_000312110*R_241[0]; double PR_001010011210=P_001010011*R_210[0]+-1*P_001010111*R_211[0]+P_001010211*R_212[0]+-1*P_001110011*R_220[0]+P_001110111*R_221[0]+-1*P_001110211*R_222[0]+-1*P_101010011*R_310[0]+P_101010111*R_311[0]+-1*P_101010211*R_312[0]+P_101110011*R_320[0]+-1*P_101110111*R_321[0]+P_101110211*R_322[0]; double PR_000011011210=P_000011011*R_210[0]+-1*P_000011111*R_211[0]+P_000011211*R_212[0]+-1*P_000111011*R_220[0]+P_000111111*R_221[0]+-1*P_000111211*R_222[0]+P_000211011*R_230[0]+-1*P_000211111*R_231[0]+P_000211211*R_232[0]; double PR_000010012210=P_000010012*R_210[0]+-1*P_000010112*R_211[0]+P_000010212*R_212[0]+-1*P_000010312*R_213[0]+-1*P_000110012*R_220[0]+P_000110112*R_221[0]+-1*P_000110212*R_222[0]+P_000110312*R_223[0]; double PR_002000020210=P_002000020*R_210[0]+-1*P_002000120*R_211[0]+P_002000220*R_212[0]+-1*P_102000020*R_310[0]+P_102000120*R_311[0]+-1*P_102000220*R_312[0]+P_202000020*R_410[0]+-1*P_202000120*R_411[0]+P_202000220*R_412[0]; double PR_001001020210=P_001001020*R_210[0]+-1*P_001001120*R_211[0]+P_001001220*R_212[0]+-1*P_001101020*R_220[0]+P_001101120*R_221[0]+-1*P_001101220*R_222[0]+-1*P_101001020*R_310[0]+P_101001120*R_311[0]+-1*P_101001220*R_312[0]+P_101101020*R_320[0]+-1*P_101101120*R_321[0]+P_101101220*R_322[0]; double PR_000002020210=P_000002020*R_210[0]+-1*P_000002120*R_211[0]+P_000002220*R_212[0]+-1*P_000102020*R_220[0]+P_000102120*R_221[0]+-1*P_000102220*R_222[0]+P_000202020*R_230[0]+-1*P_000202120*R_231[0]+P_000202220*R_232[0]; double PR_001000021210=P_001000021*R_210[0]+-1*P_001000121*R_211[0]+P_001000221*R_212[0]+-1*P_001000321*R_213[0]+-1*P_101000021*R_310[0]+P_101000121*R_311[0]+-1*P_101000221*R_312[0]+P_101000321*R_313[0]; double PR_000001021210=P_000001021*R_210[0]+-1*P_000001121*R_211[0]+P_000001221*R_212[0]+-1*P_000001321*R_213[0]+-1*P_000101021*R_220[0]+P_000101121*R_221[0]+-1*P_000101221*R_222[0]+P_000101321*R_223[0]; double PR_000000022210=P_000000022*R_210[0]+-1*P_000000122*R_211[0]+P_000000222*R_212[0]+-1*P_000000322*R_213[0]+P_000000422*R_214[0]; double PR_022000000300=P_022000000*R_300[0]+-1*P_122000000*R_400[0]+P_222000000*R_500[0]+-1*P_322000000*R_600[0]+P_422000000*R_700[0]; double PR_021001000300=P_021001000*R_300[0]+-1*P_021101000*R_310[0]+-1*P_121001000*R_400[0]+P_121101000*R_410[0]+P_221001000*R_500[0]+-1*P_221101000*R_510[0]+-1*P_321001000*R_600[0]+P_321101000*R_610[0]; double PR_020002000300=P_020002000*R_300[0]+-1*P_020102000*R_310[0]+P_020202000*R_320[0]+-1*P_120002000*R_400[0]+P_120102000*R_410[0]+-1*P_120202000*R_420[0]+P_220002000*R_500[0]+-1*P_220102000*R_510[0]+P_220202000*R_520[0]; double PR_021000001300=P_021000001*R_300[0]+-1*P_021000101*R_301[0]+-1*P_121000001*R_400[0]+P_121000101*R_401[0]+P_221000001*R_500[0]+-1*P_221000101*R_501[0]+-1*P_321000001*R_600[0]+P_321000101*R_601[0]; double PR_020001001300=P_020001001*R_300[0]+-1*P_020001101*R_301[0]+-1*P_020101001*R_310[0]+P_020101101*R_311[0]+-1*P_120001001*R_400[0]+P_120001101*R_401[0]+P_120101001*R_410[0]+-1*P_120101101*R_411[0]+P_220001001*R_500[0]+-1*P_220001101*R_501[0]+-1*P_220101001*R_510[0]+P_220101101*R_511[0]; double PR_020000002300=P_020000002*R_300[0]+-1*P_020000102*R_301[0]+P_020000202*R_302[0]+-1*P_120000002*R_400[0]+P_120000102*R_401[0]+-1*P_120000202*R_402[0]+P_220000002*R_500[0]+-1*P_220000102*R_501[0]+P_220000202*R_502[0]; double PR_012010000300=P_012010000*R_300[0]+-1*P_012110000*R_310[0]+-1*P_112010000*R_400[0]+P_112110000*R_410[0]+P_212010000*R_500[0]+-1*P_212110000*R_510[0]+-1*P_312010000*R_600[0]+P_312110000*R_610[0]; double PR_011011000300=P_011011000*R_300[0]+-1*P_011111000*R_310[0]+P_011211000*R_320[0]+-1*P_111011000*R_400[0]+P_111111000*R_410[0]+-1*P_111211000*R_420[0]+P_211011000*R_500[0]+-1*P_211111000*R_510[0]+P_211211000*R_520[0]; double PR_010012000300=P_010012000*R_300[0]+-1*P_010112000*R_310[0]+P_010212000*R_320[0]+-1*P_010312000*R_330[0]+-1*P_110012000*R_400[0]+P_110112000*R_410[0]+-1*P_110212000*R_420[0]+P_110312000*R_430[0]; double PR_011010001300=P_011010001*R_300[0]+-1*P_011010101*R_301[0]+-1*P_011110001*R_310[0]+P_011110101*R_311[0]+-1*P_111010001*R_400[0]+P_111010101*R_401[0]+P_111110001*R_410[0]+-1*P_111110101*R_411[0]+P_211010001*R_500[0]+-1*P_211010101*R_501[0]+-1*P_211110001*R_510[0]+P_211110101*R_511[0]; double PR_010011001300=P_010011001*R_300[0]+-1*P_010011101*R_301[0]+-1*P_010111001*R_310[0]+P_010111101*R_311[0]+P_010211001*R_320[0]+-1*P_010211101*R_321[0]+-1*P_110011001*R_400[0]+P_110011101*R_401[0]+P_110111001*R_410[0]+-1*P_110111101*R_411[0]+-1*P_110211001*R_420[0]+P_110211101*R_421[0]; double PR_010010002300=P_010010002*R_300[0]+-1*P_010010102*R_301[0]+P_010010202*R_302[0]+-1*P_010110002*R_310[0]+P_010110102*R_311[0]+-1*P_010110202*R_312[0]+-1*P_110010002*R_400[0]+P_110010102*R_401[0]+-1*P_110010202*R_402[0]+P_110110002*R_410[0]+-1*P_110110102*R_411[0]+P_110110202*R_412[0]; double PR_002020000300=P_002020000*R_300[0]+-1*P_002120000*R_310[0]+P_002220000*R_320[0]+-1*P_102020000*R_400[0]+P_102120000*R_410[0]+-1*P_102220000*R_420[0]+P_202020000*R_500[0]+-1*P_202120000*R_510[0]+P_202220000*R_520[0]; double PR_001021000300=P_001021000*R_300[0]+-1*P_001121000*R_310[0]+P_001221000*R_320[0]+-1*P_001321000*R_330[0]+-1*P_101021000*R_400[0]+P_101121000*R_410[0]+-1*P_101221000*R_420[0]+P_101321000*R_430[0]; double PR_000022000300=P_000022000*R_300[0]+-1*P_000122000*R_310[0]+P_000222000*R_320[0]+-1*P_000322000*R_330[0]+P_000422000*R_340[0]; double PR_001020001300=P_001020001*R_300[0]+-1*P_001020101*R_301[0]+-1*P_001120001*R_310[0]+P_001120101*R_311[0]+P_001220001*R_320[0]+-1*P_001220101*R_321[0]+-1*P_101020001*R_400[0]+P_101020101*R_401[0]+P_101120001*R_410[0]+-1*P_101120101*R_411[0]+-1*P_101220001*R_420[0]+P_101220101*R_421[0]; double PR_000021001300=P_000021001*R_300[0]+-1*P_000021101*R_301[0]+-1*P_000121001*R_310[0]+P_000121101*R_311[0]+P_000221001*R_320[0]+-1*P_000221101*R_321[0]+-1*P_000321001*R_330[0]+P_000321101*R_331[0]; double PR_000020002300=P_000020002*R_300[0]+-1*P_000020102*R_301[0]+P_000020202*R_302[0]+-1*P_000120002*R_310[0]+P_000120102*R_311[0]+-1*P_000120202*R_312[0]+P_000220002*R_320[0]+-1*P_000220102*R_321[0]+P_000220202*R_322[0]; double PR_012000010300=P_012000010*R_300[0]+-1*P_012000110*R_301[0]+-1*P_112000010*R_400[0]+P_112000110*R_401[0]+P_212000010*R_500[0]+-1*P_212000110*R_501[0]+-1*P_312000010*R_600[0]+P_312000110*R_601[0]; double PR_011001010300=P_011001010*R_300[0]+-1*P_011001110*R_301[0]+-1*P_011101010*R_310[0]+P_011101110*R_311[0]+-1*P_111001010*R_400[0]+P_111001110*R_401[0]+P_111101010*R_410[0]+-1*P_111101110*R_411[0]+P_211001010*R_500[0]+-1*P_211001110*R_501[0]+-1*P_211101010*R_510[0]+P_211101110*R_511[0]; double PR_010002010300=P_010002010*R_300[0]+-1*P_010002110*R_301[0]+-1*P_010102010*R_310[0]+P_010102110*R_311[0]+P_010202010*R_320[0]+-1*P_010202110*R_321[0]+-1*P_110002010*R_400[0]+P_110002110*R_401[0]+P_110102010*R_410[0]+-1*P_110102110*R_411[0]+-1*P_110202010*R_420[0]+P_110202110*R_421[0]; double PR_011000011300=P_011000011*R_300[0]+-1*P_011000111*R_301[0]+P_011000211*R_302[0]+-1*P_111000011*R_400[0]+P_111000111*R_401[0]+-1*P_111000211*R_402[0]+P_211000011*R_500[0]+-1*P_211000111*R_501[0]+P_211000211*R_502[0]; double PR_010001011300=P_010001011*R_300[0]+-1*P_010001111*R_301[0]+P_010001211*R_302[0]+-1*P_010101011*R_310[0]+P_010101111*R_311[0]+-1*P_010101211*R_312[0]+-1*P_110001011*R_400[0]+P_110001111*R_401[0]+-1*P_110001211*R_402[0]+P_110101011*R_410[0]+-1*P_110101111*R_411[0]+P_110101211*R_412[0]; double PR_010000012300=P_010000012*R_300[0]+-1*P_010000112*R_301[0]+P_010000212*R_302[0]+-1*P_010000312*R_303[0]+-1*P_110000012*R_400[0]+P_110000112*R_401[0]+-1*P_110000212*R_402[0]+P_110000312*R_403[0]; double PR_002010010300=P_002010010*R_300[0]+-1*P_002010110*R_301[0]+-1*P_002110010*R_310[0]+P_002110110*R_311[0]+-1*P_102010010*R_400[0]+P_102010110*R_401[0]+P_102110010*R_410[0]+-1*P_102110110*R_411[0]+P_202010010*R_500[0]+-1*P_202010110*R_501[0]+-1*P_202110010*R_510[0]+P_202110110*R_511[0]; double PR_001011010300=P_001011010*R_300[0]+-1*P_001011110*R_301[0]+-1*P_001111010*R_310[0]+P_001111110*R_311[0]+P_001211010*R_320[0]+-1*P_001211110*R_321[0]+-1*P_101011010*R_400[0]+P_101011110*R_401[0]+P_101111010*R_410[0]+-1*P_101111110*R_411[0]+-1*P_101211010*R_420[0]+P_101211110*R_421[0]; double PR_000012010300=P_000012010*R_300[0]+-1*P_000012110*R_301[0]+-1*P_000112010*R_310[0]+P_000112110*R_311[0]+P_000212010*R_320[0]+-1*P_000212110*R_321[0]+-1*P_000312010*R_330[0]+P_000312110*R_331[0]; double PR_001010011300=P_001010011*R_300[0]+-1*P_001010111*R_301[0]+P_001010211*R_302[0]+-1*P_001110011*R_310[0]+P_001110111*R_311[0]+-1*P_001110211*R_312[0]+-1*P_101010011*R_400[0]+P_101010111*R_401[0]+-1*P_101010211*R_402[0]+P_101110011*R_410[0]+-1*P_101110111*R_411[0]+P_101110211*R_412[0]; double PR_000011011300=P_000011011*R_300[0]+-1*P_000011111*R_301[0]+P_000011211*R_302[0]+-1*P_000111011*R_310[0]+P_000111111*R_311[0]+-1*P_000111211*R_312[0]+P_000211011*R_320[0]+-1*P_000211111*R_321[0]+P_000211211*R_322[0]; double PR_000010012300=P_000010012*R_300[0]+-1*P_000010112*R_301[0]+P_000010212*R_302[0]+-1*P_000010312*R_303[0]+-1*P_000110012*R_310[0]+P_000110112*R_311[0]+-1*P_000110212*R_312[0]+P_000110312*R_313[0]; double PR_002000020300=P_002000020*R_300[0]+-1*P_002000120*R_301[0]+P_002000220*R_302[0]+-1*P_102000020*R_400[0]+P_102000120*R_401[0]+-1*P_102000220*R_402[0]+P_202000020*R_500[0]+-1*P_202000120*R_501[0]+P_202000220*R_502[0]; double PR_001001020300=P_001001020*R_300[0]+-1*P_001001120*R_301[0]+P_001001220*R_302[0]+-1*P_001101020*R_310[0]+P_001101120*R_311[0]+-1*P_001101220*R_312[0]+-1*P_101001020*R_400[0]+P_101001120*R_401[0]+-1*P_101001220*R_402[0]+P_101101020*R_410[0]+-1*P_101101120*R_411[0]+P_101101220*R_412[0]; double PR_000002020300=P_000002020*R_300[0]+-1*P_000002120*R_301[0]+P_000002220*R_302[0]+-1*P_000102020*R_310[0]+P_000102120*R_311[0]+-1*P_000102220*R_312[0]+P_000202020*R_320[0]+-1*P_000202120*R_321[0]+P_000202220*R_322[0]; double PR_001000021300=P_001000021*R_300[0]+-1*P_001000121*R_301[0]+P_001000221*R_302[0]+-1*P_001000321*R_303[0]+-1*P_101000021*R_400[0]+P_101000121*R_401[0]+-1*P_101000221*R_402[0]+P_101000321*R_403[0]; double PR_000001021300=P_000001021*R_300[0]+-1*P_000001121*R_301[0]+P_000001221*R_302[0]+-1*P_000001321*R_303[0]+-1*P_000101021*R_310[0]+P_000101121*R_311[0]+-1*P_000101221*R_312[0]+P_000101321*R_313[0]; double PR_000000022300=P_000000022*R_300[0]+-1*P_000000122*R_301[0]+P_000000222*R_302[0]+-1*P_000000322*R_303[0]+P_000000422*R_304[0]; double PR_022000000004=P_022000000*R_004[0]+-1*P_122000000*R_104[0]+P_222000000*R_204[0]+-1*P_322000000*R_304[0]+P_422000000*R_404[0]; double PR_021001000004=P_021001000*R_004[0]+-1*P_021101000*R_014[0]+-1*P_121001000*R_104[0]+P_121101000*R_114[0]+P_221001000*R_204[0]+-1*P_221101000*R_214[0]+-1*P_321001000*R_304[0]+P_321101000*R_314[0]; double PR_020002000004=P_020002000*R_004[0]+-1*P_020102000*R_014[0]+P_020202000*R_024[0]+-1*P_120002000*R_104[0]+P_120102000*R_114[0]+-1*P_120202000*R_124[0]+P_220002000*R_204[0]+-1*P_220102000*R_214[0]+P_220202000*R_224[0]; double PR_021000001004=P_021000001*R_004[0]+-1*P_021000101*R_005[0]+-1*P_121000001*R_104[0]+P_121000101*R_105[0]+P_221000001*R_204[0]+-1*P_221000101*R_205[0]+-1*P_321000001*R_304[0]+P_321000101*R_305[0]; double PR_020001001004=P_020001001*R_004[0]+-1*P_020001101*R_005[0]+-1*P_020101001*R_014[0]+P_020101101*R_015[0]+-1*P_120001001*R_104[0]+P_120001101*R_105[0]+P_120101001*R_114[0]+-1*P_120101101*R_115[0]+P_220001001*R_204[0]+-1*P_220001101*R_205[0]+-1*P_220101001*R_214[0]+P_220101101*R_215[0]; double PR_020000002004=P_020000002*R_004[0]+-1*P_020000102*R_005[0]+P_020000202*R_006[0]+-1*P_120000002*R_104[0]+P_120000102*R_105[0]+-1*P_120000202*R_106[0]+P_220000002*R_204[0]+-1*P_220000102*R_205[0]+P_220000202*R_206[0]; double PR_012010000004=P_012010000*R_004[0]+-1*P_012110000*R_014[0]+-1*P_112010000*R_104[0]+P_112110000*R_114[0]+P_212010000*R_204[0]+-1*P_212110000*R_214[0]+-1*P_312010000*R_304[0]+P_312110000*R_314[0]; double PR_011011000004=P_011011000*R_004[0]+-1*P_011111000*R_014[0]+P_011211000*R_024[0]+-1*P_111011000*R_104[0]+P_111111000*R_114[0]+-1*P_111211000*R_124[0]+P_211011000*R_204[0]+-1*P_211111000*R_214[0]+P_211211000*R_224[0]; double PR_010012000004=P_010012000*R_004[0]+-1*P_010112000*R_014[0]+P_010212000*R_024[0]+-1*P_010312000*R_034[0]+-1*P_110012000*R_104[0]+P_110112000*R_114[0]+-1*P_110212000*R_124[0]+P_110312000*R_134[0]; double PR_011010001004=P_011010001*R_004[0]+-1*P_011010101*R_005[0]+-1*P_011110001*R_014[0]+P_011110101*R_015[0]+-1*P_111010001*R_104[0]+P_111010101*R_105[0]+P_111110001*R_114[0]+-1*P_111110101*R_115[0]+P_211010001*R_204[0]+-1*P_211010101*R_205[0]+-1*P_211110001*R_214[0]+P_211110101*R_215[0]; double PR_010011001004=P_010011001*R_004[0]+-1*P_010011101*R_005[0]+-1*P_010111001*R_014[0]+P_010111101*R_015[0]+P_010211001*R_024[0]+-1*P_010211101*R_025[0]+-1*P_110011001*R_104[0]+P_110011101*R_105[0]+P_110111001*R_114[0]+-1*P_110111101*R_115[0]+-1*P_110211001*R_124[0]+P_110211101*R_125[0]; double PR_010010002004=P_010010002*R_004[0]+-1*P_010010102*R_005[0]+P_010010202*R_006[0]+-1*P_010110002*R_014[0]+P_010110102*R_015[0]+-1*P_010110202*R_016[0]+-1*P_110010002*R_104[0]+P_110010102*R_105[0]+-1*P_110010202*R_106[0]+P_110110002*R_114[0]+-1*P_110110102*R_115[0]+P_110110202*R_116[0]; double PR_002020000004=P_002020000*R_004[0]+-1*P_002120000*R_014[0]+P_002220000*R_024[0]+-1*P_102020000*R_104[0]+P_102120000*R_114[0]+-1*P_102220000*R_124[0]+P_202020000*R_204[0]+-1*P_202120000*R_214[0]+P_202220000*R_224[0]; double PR_001021000004=P_001021000*R_004[0]+-1*P_001121000*R_014[0]+P_001221000*R_024[0]+-1*P_001321000*R_034[0]+-1*P_101021000*R_104[0]+P_101121000*R_114[0]+-1*P_101221000*R_124[0]+P_101321000*R_134[0]; double PR_000022000004=P_000022000*R_004[0]+-1*P_000122000*R_014[0]+P_000222000*R_024[0]+-1*P_000322000*R_034[0]+P_000422000*R_044[0]; double PR_001020001004=P_001020001*R_004[0]+-1*P_001020101*R_005[0]+-1*P_001120001*R_014[0]+P_001120101*R_015[0]+P_001220001*R_024[0]+-1*P_001220101*R_025[0]+-1*P_101020001*R_104[0]+P_101020101*R_105[0]+P_101120001*R_114[0]+-1*P_101120101*R_115[0]+-1*P_101220001*R_124[0]+P_101220101*R_125[0]; double PR_000021001004=P_000021001*R_004[0]+-1*P_000021101*R_005[0]+-1*P_000121001*R_014[0]+P_000121101*R_015[0]+P_000221001*R_024[0]+-1*P_000221101*R_025[0]+-1*P_000321001*R_034[0]+P_000321101*R_035[0]; double PR_000020002004=P_000020002*R_004[0]+-1*P_000020102*R_005[0]+P_000020202*R_006[0]+-1*P_000120002*R_014[0]+P_000120102*R_015[0]+-1*P_000120202*R_016[0]+P_000220002*R_024[0]+-1*P_000220102*R_025[0]+P_000220202*R_026[0]; double PR_012000010004=P_012000010*R_004[0]+-1*P_012000110*R_005[0]+-1*P_112000010*R_104[0]+P_112000110*R_105[0]+P_212000010*R_204[0]+-1*P_212000110*R_205[0]+-1*P_312000010*R_304[0]+P_312000110*R_305[0]; double PR_011001010004=P_011001010*R_004[0]+-1*P_011001110*R_005[0]+-1*P_011101010*R_014[0]+P_011101110*R_015[0]+-1*P_111001010*R_104[0]+P_111001110*R_105[0]+P_111101010*R_114[0]+-1*P_111101110*R_115[0]+P_211001010*R_204[0]+-1*P_211001110*R_205[0]+-1*P_211101010*R_214[0]+P_211101110*R_215[0]; double PR_010002010004=P_010002010*R_004[0]+-1*P_010002110*R_005[0]+-1*P_010102010*R_014[0]+P_010102110*R_015[0]+P_010202010*R_024[0]+-1*P_010202110*R_025[0]+-1*P_110002010*R_104[0]+P_110002110*R_105[0]+P_110102010*R_114[0]+-1*P_110102110*R_115[0]+-1*P_110202010*R_124[0]+P_110202110*R_125[0]; double PR_011000011004=P_011000011*R_004[0]+-1*P_011000111*R_005[0]+P_011000211*R_006[0]+-1*P_111000011*R_104[0]+P_111000111*R_105[0]+-1*P_111000211*R_106[0]+P_211000011*R_204[0]+-1*P_211000111*R_205[0]+P_211000211*R_206[0]; double PR_010001011004=P_010001011*R_004[0]+-1*P_010001111*R_005[0]+P_010001211*R_006[0]+-1*P_010101011*R_014[0]+P_010101111*R_015[0]+-1*P_010101211*R_016[0]+-1*P_110001011*R_104[0]+P_110001111*R_105[0]+-1*P_110001211*R_106[0]+P_110101011*R_114[0]+-1*P_110101111*R_115[0]+P_110101211*R_116[0]; double PR_010000012004=P_010000012*R_004[0]+-1*P_010000112*R_005[0]+P_010000212*R_006[0]+-1*P_010000312*R_007[0]+-1*P_110000012*R_104[0]+P_110000112*R_105[0]+-1*P_110000212*R_106[0]+P_110000312*R_107[0]; double PR_002010010004=P_002010010*R_004[0]+-1*P_002010110*R_005[0]+-1*P_002110010*R_014[0]+P_002110110*R_015[0]+-1*P_102010010*R_104[0]+P_102010110*R_105[0]+P_102110010*R_114[0]+-1*P_102110110*R_115[0]+P_202010010*R_204[0]+-1*P_202010110*R_205[0]+-1*P_202110010*R_214[0]+P_202110110*R_215[0]; double PR_001011010004=P_001011010*R_004[0]+-1*P_001011110*R_005[0]+-1*P_001111010*R_014[0]+P_001111110*R_015[0]+P_001211010*R_024[0]+-1*P_001211110*R_025[0]+-1*P_101011010*R_104[0]+P_101011110*R_105[0]+P_101111010*R_114[0]+-1*P_101111110*R_115[0]+-1*P_101211010*R_124[0]+P_101211110*R_125[0]; double PR_000012010004=P_000012010*R_004[0]+-1*P_000012110*R_005[0]+-1*P_000112010*R_014[0]+P_000112110*R_015[0]+P_000212010*R_024[0]+-1*P_000212110*R_025[0]+-1*P_000312010*R_034[0]+P_000312110*R_035[0]; double PR_001010011004=P_001010011*R_004[0]+-1*P_001010111*R_005[0]+P_001010211*R_006[0]+-1*P_001110011*R_014[0]+P_001110111*R_015[0]+-1*P_001110211*R_016[0]+-1*P_101010011*R_104[0]+P_101010111*R_105[0]+-1*P_101010211*R_106[0]+P_101110011*R_114[0]+-1*P_101110111*R_115[0]+P_101110211*R_116[0]; double PR_000011011004=P_000011011*R_004[0]+-1*P_000011111*R_005[0]+P_000011211*R_006[0]+-1*P_000111011*R_014[0]+P_000111111*R_015[0]+-1*P_000111211*R_016[0]+P_000211011*R_024[0]+-1*P_000211111*R_025[0]+P_000211211*R_026[0]; double PR_000010012004=P_000010012*R_004[0]+-1*P_000010112*R_005[0]+P_000010212*R_006[0]+-1*P_000010312*R_007[0]+-1*P_000110012*R_014[0]+P_000110112*R_015[0]+-1*P_000110212*R_016[0]+P_000110312*R_017[0]; double PR_002000020004=P_002000020*R_004[0]+-1*P_002000120*R_005[0]+P_002000220*R_006[0]+-1*P_102000020*R_104[0]+P_102000120*R_105[0]+-1*P_102000220*R_106[0]+P_202000020*R_204[0]+-1*P_202000120*R_205[0]+P_202000220*R_206[0]; double PR_001001020004=P_001001020*R_004[0]+-1*P_001001120*R_005[0]+P_001001220*R_006[0]+-1*P_001101020*R_014[0]+P_001101120*R_015[0]+-1*P_001101220*R_016[0]+-1*P_101001020*R_104[0]+P_101001120*R_105[0]+-1*P_101001220*R_106[0]+P_101101020*R_114[0]+-1*P_101101120*R_115[0]+P_101101220*R_116[0]; double PR_000002020004=P_000002020*R_004[0]+-1*P_000002120*R_005[0]+P_000002220*R_006[0]+-1*P_000102020*R_014[0]+P_000102120*R_015[0]+-1*P_000102220*R_016[0]+P_000202020*R_024[0]+-1*P_000202120*R_025[0]+P_000202220*R_026[0]; double PR_001000021004=P_001000021*R_004[0]+-1*P_001000121*R_005[0]+P_001000221*R_006[0]+-1*P_001000321*R_007[0]+-1*P_101000021*R_104[0]+P_101000121*R_105[0]+-1*P_101000221*R_106[0]+P_101000321*R_107[0]; double PR_000001021004=P_000001021*R_004[0]+-1*P_000001121*R_005[0]+P_000001221*R_006[0]+-1*P_000001321*R_007[0]+-1*P_000101021*R_014[0]+P_000101121*R_015[0]+-1*P_000101221*R_016[0]+P_000101321*R_017[0]; double PR_000000022004=P_000000022*R_004[0]+-1*P_000000122*R_005[0]+P_000000222*R_006[0]+-1*P_000000322*R_007[0]+P_000000422*R_008[0]; double PR_022000000013=P_022000000*R_013[0]+-1*P_122000000*R_113[0]+P_222000000*R_213[0]+-1*P_322000000*R_313[0]+P_422000000*R_413[0]; double PR_021001000013=P_021001000*R_013[0]+-1*P_021101000*R_023[0]+-1*P_121001000*R_113[0]+P_121101000*R_123[0]+P_221001000*R_213[0]+-1*P_221101000*R_223[0]+-1*P_321001000*R_313[0]+P_321101000*R_323[0]; double PR_020002000013=P_020002000*R_013[0]+-1*P_020102000*R_023[0]+P_020202000*R_033[0]+-1*P_120002000*R_113[0]+P_120102000*R_123[0]+-1*P_120202000*R_133[0]+P_220002000*R_213[0]+-1*P_220102000*R_223[0]+P_220202000*R_233[0]; double PR_021000001013=P_021000001*R_013[0]+-1*P_021000101*R_014[0]+-1*P_121000001*R_113[0]+P_121000101*R_114[0]+P_221000001*R_213[0]+-1*P_221000101*R_214[0]+-1*P_321000001*R_313[0]+P_321000101*R_314[0]; double PR_020001001013=P_020001001*R_013[0]+-1*P_020001101*R_014[0]+-1*P_020101001*R_023[0]+P_020101101*R_024[0]+-1*P_120001001*R_113[0]+P_120001101*R_114[0]+P_120101001*R_123[0]+-1*P_120101101*R_124[0]+P_220001001*R_213[0]+-1*P_220001101*R_214[0]+-1*P_220101001*R_223[0]+P_220101101*R_224[0]; double PR_020000002013=P_020000002*R_013[0]+-1*P_020000102*R_014[0]+P_020000202*R_015[0]+-1*P_120000002*R_113[0]+P_120000102*R_114[0]+-1*P_120000202*R_115[0]+P_220000002*R_213[0]+-1*P_220000102*R_214[0]+P_220000202*R_215[0]; double PR_012010000013=P_012010000*R_013[0]+-1*P_012110000*R_023[0]+-1*P_112010000*R_113[0]+P_112110000*R_123[0]+P_212010000*R_213[0]+-1*P_212110000*R_223[0]+-1*P_312010000*R_313[0]+P_312110000*R_323[0]; double PR_011011000013=P_011011000*R_013[0]+-1*P_011111000*R_023[0]+P_011211000*R_033[0]+-1*P_111011000*R_113[0]+P_111111000*R_123[0]+-1*P_111211000*R_133[0]+P_211011000*R_213[0]+-1*P_211111000*R_223[0]+P_211211000*R_233[0]; double PR_010012000013=P_010012000*R_013[0]+-1*P_010112000*R_023[0]+P_010212000*R_033[0]+-1*P_010312000*R_043[0]+-1*P_110012000*R_113[0]+P_110112000*R_123[0]+-1*P_110212000*R_133[0]+P_110312000*R_143[0]; double PR_011010001013=P_011010001*R_013[0]+-1*P_011010101*R_014[0]+-1*P_011110001*R_023[0]+P_011110101*R_024[0]+-1*P_111010001*R_113[0]+P_111010101*R_114[0]+P_111110001*R_123[0]+-1*P_111110101*R_124[0]+P_211010001*R_213[0]+-1*P_211010101*R_214[0]+-1*P_211110001*R_223[0]+P_211110101*R_224[0]; double PR_010011001013=P_010011001*R_013[0]+-1*P_010011101*R_014[0]+-1*P_010111001*R_023[0]+P_010111101*R_024[0]+P_010211001*R_033[0]+-1*P_010211101*R_034[0]+-1*P_110011001*R_113[0]+P_110011101*R_114[0]+P_110111001*R_123[0]+-1*P_110111101*R_124[0]+-1*P_110211001*R_133[0]+P_110211101*R_134[0]; double PR_010010002013=P_010010002*R_013[0]+-1*P_010010102*R_014[0]+P_010010202*R_015[0]+-1*P_010110002*R_023[0]+P_010110102*R_024[0]+-1*P_010110202*R_025[0]+-1*P_110010002*R_113[0]+P_110010102*R_114[0]+-1*P_110010202*R_115[0]+P_110110002*R_123[0]+-1*P_110110102*R_124[0]+P_110110202*R_125[0]; double PR_002020000013=P_002020000*R_013[0]+-1*P_002120000*R_023[0]+P_002220000*R_033[0]+-1*P_102020000*R_113[0]+P_102120000*R_123[0]+-1*P_102220000*R_133[0]+P_202020000*R_213[0]+-1*P_202120000*R_223[0]+P_202220000*R_233[0]; double PR_001021000013=P_001021000*R_013[0]+-1*P_001121000*R_023[0]+P_001221000*R_033[0]+-1*P_001321000*R_043[0]+-1*P_101021000*R_113[0]+P_101121000*R_123[0]+-1*P_101221000*R_133[0]+P_101321000*R_143[0]; double PR_000022000013=P_000022000*R_013[0]+-1*P_000122000*R_023[0]+P_000222000*R_033[0]+-1*P_000322000*R_043[0]+P_000422000*R_053[0]; double PR_001020001013=P_001020001*R_013[0]+-1*P_001020101*R_014[0]+-1*P_001120001*R_023[0]+P_001120101*R_024[0]+P_001220001*R_033[0]+-1*P_001220101*R_034[0]+-1*P_101020001*R_113[0]+P_101020101*R_114[0]+P_101120001*R_123[0]+-1*P_101120101*R_124[0]+-1*P_101220001*R_133[0]+P_101220101*R_134[0]; double PR_000021001013=P_000021001*R_013[0]+-1*P_000021101*R_014[0]+-1*P_000121001*R_023[0]+P_000121101*R_024[0]+P_000221001*R_033[0]+-1*P_000221101*R_034[0]+-1*P_000321001*R_043[0]+P_000321101*R_044[0]; double PR_000020002013=P_000020002*R_013[0]+-1*P_000020102*R_014[0]+P_000020202*R_015[0]+-1*P_000120002*R_023[0]+P_000120102*R_024[0]+-1*P_000120202*R_025[0]+P_000220002*R_033[0]+-1*P_000220102*R_034[0]+P_000220202*R_035[0]; double PR_012000010013=P_012000010*R_013[0]+-1*P_012000110*R_014[0]+-1*P_112000010*R_113[0]+P_112000110*R_114[0]+P_212000010*R_213[0]+-1*P_212000110*R_214[0]+-1*P_312000010*R_313[0]+P_312000110*R_314[0]; double PR_011001010013=P_011001010*R_013[0]+-1*P_011001110*R_014[0]+-1*P_011101010*R_023[0]+P_011101110*R_024[0]+-1*P_111001010*R_113[0]+P_111001110*R_114[0]+P_111101010*R_123[0]+-1*P_111101110*R_124[0]+P_211001010*R_213[0]+-1*P_211001110*R_214[0]+-1*P_211101010*R_223[0]+P_211101110*R_224[0]; double PR_010002010013=P_010002010*R_013[0]+-1*P_010002110*R_014[0]+-1*P_010102010*R_023[0]+P_010102110*R_024[0]+P_010202010*R_033[0]+-1*P_010202110*R_034[0]+-1*P_110002010*R_113[0]+P_110002110*R_114[0]+P_110102010*R_123[0]+-1*P_110102110*R_124[0]+-1*P_110202010*R_133[0]+P_110202110*R_134[0]; double PR_011000011013=P_011000011*R_013[0]+-1*P_011000111*R_014[0]+P_011000211*R_015[0]+-1*P_111000011*R_113[0]+P_111000111*R_114[0]+-1*P_111000211*R_115[0]+P_211000011*R_213[0]+-1*P_211000111*R_214[0]+P_211000211*R_215[0]; double PR_010001011013=P_010001011*R_013[0]+-1*P_010001111*R_014[0]+P_010001211*R_015[0]+-1*P_010101011*R_023[0]+P_010101111*R_024[0]+-1*P_010101211*R_025[0]+-1*P_110001011*R_113[0]+P_110001111*R_114[0]+-1*P_110001211*R_115[0]+P_110101011*R_123[0]+-1*P_110101111*R_124[0]+P_110101211*R_125[0]; double PR_010000012013=P_010000012*R_013[0]+-1*P_010000112*R_014[0]+P_010000212*R_015[0]+-1*P_010000312*R_016[0]+-1*P_110000012*R_113[0]+P_110000112*R_114[0]+-1*P_110000212*R_115[0]+P_110000312*R_116[0]; double PR_002010010013=P_002010010*R_013[0]+-1*P_002010110*R_014[0]+-1*P_002110010*R_023[0]+P_002110110*R_024[0]+-1*P_102010010*R_113[0]+P_102010110*R_114[0]+P_102110010*R_123[0]+-1*P_102110110*R_124[0]+P_202010010*R_213[0]+-1*P_202010110*R_214[0]+-1*P_202110010*R_223[0]+P_202110110*R_224[0]; double PR_001011010013=P_001011010*R_013[0]+-1*P_001011110*R_014[0]+-1*P_001111010*R_023[0]+P_001111110*R_024[0]+P_001211010*R_033[0]+-1*P_001211110*R_034[0]+-1*P_101011010*R_113[0]+P_101011110*R_114[0]+P_101111010*R_123[0]+-1*P_101111110*R_124[0]+-1*P_101211010*R_133[0]+P_101211110*R_134[0]; double PR_000012010013=P_000012010*R_013[0]+-1*P_000012110*R_014[0]+-1*P_000112010*R_023[0]+P_000112110*R_024[0]+P_000212010*R_033[0]+-1*P_000212110*R_034[0]+-1*P_000312010*R_043[0]+P_000312110*R_044[0]; double PR_001010011013=P_001010011*R_013[0]+-1*P_001010111*R_014[0]+P_001010211*R_015[0]+-1*P_001110011*R_023[0]+P_001110111*R_024[0]+-1*P_001110211*R_025[0]+-1*P_101010011*R_113[0]+P_101010111*R_114[0]+-1*P_101010211*R_115[0]+P_101110011*R_123[0]+-1*P_101110111*R_124[0]+P_101110211*R_125[0]; double PR_000011011013=P_000011011*R_013[0]+-1*P_000011111*R_014[0]+P_000011211*R_015[0]+-1*P_000111011*R_023[0]+P_000111111*R_024[0]+-1*P_000111211*R_025[0]+P_000211011*R_033[0]+-1*P_000211111*R_034[0]+P_000211211*R_035[0]; double PR_000010012013=P_000010012*R_013[0]+-1*P_000010112*R_014[0]+P_000010212*R_015[0]+-1*P_000010312*R_016[0]+-1*P_000110012*R_023[0]+P_000110112*R_024[0]+-1*P_000110212*R_025[0]+P_000110312*R_026[0]; double PR_002000020013=P_002000020*R_013[0]+-1*P_002000120*R_014[0]+P_002000220*R_015[0]+-1*P_102000020*R_113[0]+P_102000120*R_114[0]+-1*P_102000220*R_115[0]+P_202000020*R_213[0]+-1*P_202000120*R_214[0]+P_202000220*R_215[0]; double PR_001001020013=P_001001020*R_013[0]+-1*P_001001120*R_014[0]+P_001001220*R_015[0]+-1*P_001101020*R_023[0]+P_001101120*R_024[0]+-1*P_001101220*R_025[0]+-1*P_101001020*R_113[0]+P_101001120*R_114[0]+-1*P_101001220*R_115[0]+P_101101020*R_123[0]+-1*P_101101120*R_124[0]+P_101101220*R_125[0]; double PR_000002020013=P_000002020*R_013[0]+-1*P_000002120*R_014[0]+P_000002220*R_015[0]+-1*P_000102020*R_023[0]+P_000102120*R_024[0]+-1*P_000102220*R_025[0]+P_000202020*R_033[0]+-1*P_000202120*R_034[0]+P_000202220*R_035[0]; double PR_001000021013=P_001000021*R_013[0]+-1*P_001000121*R_014[0]+P_001000221*R_015[0]+-1*P_001000321*R_016[0]+-1*P_101000021*R_113[0]+P_101000121*R_114[0]+-1*P_101000221*R_115[0]+P_101000321*R_116[0]; double PR_000001021013=P_000001021*R_013[0]+-1*P_000001121*R_014[0]+P_000001221*R_015[0]+-1*P_000001321*R_016[0]+-1*P_000101021*R_023[0]+P_000101121*R_024[0]+-1*P_000101221*R_025[0]+P_000101321*R_026[0]; double PR_000000022013=P_000000022*R_013[0]+-1*P_000000122*R_014[0]+P_000000222*R_015[0]+-1*P_000000322*R_016[0]+P_000000422*R_017[0]; double PR_022000000022=P_022000000*R_022[0]+-1*P_122000000*R_122[0]+P_222000000*R_222[0]+-1*P_322000000*R_322[0]+P_422000000*R_422[0]; double PR_021001000022=P_021001000*R_022[0]+-1*P_021101000*R_032[0]+-1*P_121001000*R_122[0]+P_121101000*R_132[0]+P_221001000*R_222[0]+-1*P_221101000*R_232[0]+-1*P_321001000*R_322[0]+P_321101000*R_332[0]; double PR_020002000022=P_020002000*R_022[0]+-1*P_020102000*R_032[0]+P_020202000*R_042[0]+-1*P_120002000*R_122[0]+P_120102000*R_132[0]+-1*P_120202000*R_142[0]+P_220002000*R_222[0]+-1*P_220102000*R_232[0]+P_220202000*R_242[0]; double PR_021000001022=P_021000001*R_022[0]+-1*P_021000101*R_023[0]+-1*P_121000001*R_122[0]+P_121000101*R_123[0]+P_221000001*R_222[0]+-1*P_221000101*R_223[0]+-1*P_321000001*R_322[0]+P_321000101*R_323[0]; double PR_020001001022=P_020001001*R_022[0]+-1*P_020001101*R_023[0]+-1*P_020101001*R_032[0]+P_020101101*R_033[0]+-1*P_120001001*R_122[0]+P_120001101*R_123[0]+P_120101001*R_132[0]+-1*P_120101101*R_133[0]+P_220001001*R_222[0]+-1*P_220001101*R_223[0]+-1*P_220101001*R_232[0]+P_220101101*R_233[0]; double PR_020000002022=P_020000002*R_022[0]+-1*P_020000102*R_023[0]+P_020000202*R_024[0]+-1*P_120000002*R_122[0]+P_120000102*R_123[0]+-1*P_120000202*R_124[0]+P_220000002*R_222[0]+-1*P_220000102*R_223[0]+P_220000202*R_224[0]; double PR_012010000022=P_012010000*R_022[0]+-1*P_012110000*R_032[0]+-1*P_112010000*R_122[0]+P_112110000*R_132[0]+P_212010000*R_222[0]+-1*P_212110000*R_232[0]+-1*P_312010000*R_322[0]+P_312110000*R_332[0]; double PR_011011000022=P_011011000*R_022[0]+-1*P_011111000*R_032[0]+P_011211000*R_042[0]+-1*P_111011000*R_122[0]+P_111111000*R_132[0]+-1*P_111211000*R_142[0]+P_211011000*R_222[0]+-1*P_211111000*R_232[0]+P_211211000*R_242[0]; double PR_010012000022=P_010012000*R_022[0]+-1*P_010112000*R_032[0]+P_010212000*R_042[0]+-1*P_010312000*R_052[0]+-1*P_110012000*R_122[0]+P_110112000*R_132[0]+-1*P_110212000*R_142[0]+P_110312000*R_152[0]; double PR_011010001022=P_011010001*R_022[0]+-1*P_011010101*R_023[0]+-1*P_011110001*R_032[0]+P_011110101*R_033[0]+-1*P_111010001*R_122[0]+P_111010101*R_123[0]+P_111110001*R_132[0]+-1*P_111110101*R_133[0]+P_211010001*R_222[0]+-1*P_211010101*R_223[0]+-1*P_211110001*R_232[0]+P_211110101*R_233[0]; double PR_010011001022=P_010011001*R_022[0]+-1*P_010011101*R_023[0]+-1*P_010111001*R_032[0]+P_010111101*R_033[0]+P_010211001*R_042[0]+-1*P_010211101*R_043[0]+-1*P_110011001*R_122[0]+P_110011101*R_123[0]+P_110111001*R_132[0]+-1*P_110111101*R_133[0]+-1*P_110211001*R_142[0]+P_110211101*R_143[0]; double PR_010010002022=P_010010002*R_022[0]+-1*P_010010102*R_023[0]+P_010010202*R_024[0]+-1*P_010110002*R_032[0]+P_010110102*R_033[0]+-1*P_010110202*R_034[0]+-1*P_110010002*R_122[0]+P_110010102*R_123[0]+-1*P_110010202*R_124[0]+P_110110002*R_132[0]+-1*P_110110102*R_133[0]+P_110110202*R_134[0]; double PR_002020000022=P_002020000*R_022[0]+-1*P_002120000*R_032[0]+P_002220000*R_042[0]+-1*P_102020000*R_122[0]+P_102120000*R_132[0]+-1*P_102220000*R_142[0]+P_202020000*R_222[0]+-1*P_202120000*R_232[0]+P_202220000*R_242[0]; double PR_001021000022=P_001021000*R_022[0]+-1*P_001121000*R_032[0]+P_001221000*R_042[0]+-1*P_001321000*R_052[0]+-1*P_101021000*R_122[0]+P_101121000*R_132[0]+-1*P_101221000*R_142[0]+P_101321000*R_152[0]; double PR_000022000022=P_000022000*R_022[0]+-1*P_000122000*R_032[0]+P_000222000*R_042[0]+-1*P_000322000*R_052[0]+P_000422000*R_062[0]; double PR_001020001022=P_001020001*R_022[0]+-1*P_001020101*R_023[0]+-1*P_001120001*R_032[0]+P_001120101*R_033[0]+P_001220001*R_042[0]+-1*P_001220101*R_043[0]+-1*P_101020001*R_122[0]+P_101020101*R_123[0]+P_101120001*R_132[0]+-1*P_101120101*R_133[0]+-1*P_101220001*R_142[0]+P_101220101*R_143[0]; double PR_000021001022=P_000021001*R_022[0]+-1*P_000021101*R_023[0]+-1*P_000121001*R_032[0]+P_000121101*R_033[0]+P_000221001*R_042[0]+-1*P_000221101*R_043[0]+-1*P_000321001*R_052[0]+P_000321101*R_053[0]; double PR_000020002022=P_000020002*R_022[0]+-1*P_000020102*R_023[0]+P_000020202*R_024[0]+-1*P_000120002*R_032[0]+P_000120102*R_033[0]+-1*P_000120202*R_034[0]+P_000220002*R_042[0]+-1*P_000220102*R_043[0]+P_000220202*R_044[0]; double PR_012000010022=P_012000010*R_022[0]+-1*P_012000110*R_023[0]+-1*P_112000010*R_122[0]+P_112000110*R_123[0]+P_212000010*R_222[0]+-1*P_212000110*R_223[0]+-1*P_312000010*R_322[0]+P_312000110*R_323[0]; double PR_011001010022=P_011001010*R_022[0]+-1*P_011001110*R_023[0]+-1*P_011101010*R_032[0]+P_011101110*R_033[0]+-1*P_111001010*R_122[0]+P_111001110*R_123[0]+P_111101010*R_132[0]+-1*P_111101110*R_133[0]+P_211001010*R_222[0]+-1*P_211001110*R_223[0]+-1*P_211101010*R_232[0]+P_211101110*R_233[0]; double PR_010002010022=P_010002010*R_022[0]+-1*P_010002110*R_023[0]+-1*P_010102010*R_032[0]+P_010102110*R_033[0]+P_010202010*R_042[0]+-1*P_010202110*R_043[0]+-1*P_110002010*R_122[0]+P_110002110*R_123[0]+P_110102010*R_132[0]+-1*P_110102110*R_133[0]+-1*P_110202010*R_142[0]+P_110202110*R_143[0]; double PR_011000011022=P_011000011*R_022[0]+-1*P_011000111*R_023[0]+P_011000211*R_024[0]+-1*P_111000011*R_122[0]+P_111000111*R_123[0]+-1*P_111000211*R_124[0]+P_211000011*R_222[0]+-1*P_211000111*R_223[0]+P_211000211*R_224[0]; double PR_010001011022=P_010001011*R_022[0]+-1*P_010001111*R_023[0]+P_010001211*R_024[0]+-1*P_010101011*R_032[0]+P_010101111*R_033[0]+-1*P_010101211*R_034[0]+-1*P_110001011*R_122[0]+P_110001111*R_123[0]+-1*P_110001211*R_124[0]+P_110101011*R_132[0]+-1*P_110101111*R_133[0]+P_110101211*R_134[0]; double PR_010000012022=P_010000012*R_022[0]+-1*P_010000112*R_023[0]+P_010000212*R_024[0]+-1*P_010000312*R_025[0]+-1*P_110000012*R_122[0]+P_110000112*R_123[0]+-1*P_110000212*R_124[0]+P_110000312*R_125[0]; double PR_002010010022=P_002010010*R_022[0]+-1*P_002010110*R_023[0]+-1*P_002110010*R_032[0]+P_002110110*R_033[0]+-1*P_102010010*R_122[0]+P_102010110*R_123[0]+P_102110010*R_132[0]+-1*P_102110110*R_133[0]+P_202010010*R_222[0]+-1*P_202010110*R_223[0]+-1*P_202110010*R_232[0]+P_202110110*R_233[0]; double PR_001011010022=P_001011010*R_022[0]+-1*P_001011110*R_023[0]+-1*P_001111010*R_032[0]+P_001111110*R_033[0]+P_001211010*R_042[0]+-1*P_001211110*R_043[0]+-1*P_101011010*R_122[0]+P_101011110*R_123[0]+P_101111010*R_132[0]+-1*P_101111110*R_133[0]+-1*P_101211010*R_142[0]+P_101211110*R_143[0]; double PR_000012010022=P_000012010*R_022[0]+-1*P_000012110*R_023[0]+-1*P_000112010*R_032[0]+P_000112110*R_033[0]+P_000212010*R_042[0]+-1*P_000212110*R_043[0]+-1*P_000312010*R_052[0]+P_000312110*R_053[0]; double PR_001010011022=P_001010011*R_022[0]+-1*P_001010111*R_023[0]+P_001010211*R_024[0]+-1*P_001110011*R_032[0]+P_001110111*R_033[0]+-1*P_001110211*R_034[0]+-1*P_101010011*R_122[0]+P_101010111*R_123[0]+-1*P_101010211*R_124[0]+P_101110011*R_132[0]+-1*P_101110111*R_133[0]+P_101110211*R_134[0]; double PR_000011011022=P_000011011*R_022[0]+-1*P_000011111*R_023[0]+P_000011211*R_024[0]+-1*P_000111011*R_032[0]+P_000111111*R_033[0]+-1*P_000111211*R_034[0]+P_000211011*R_042[0]+-1*P_000211111*R_043[0]+P_000211211*R_044[0]; double PR_000010012022=P_000010012*R_022[0]+-1*P_000010112*R_023[0]+P_000010212*R_024[0]+-1*P_000010312*R_025[0]+-1*P_000110012*R_032[0]+P_000110112*R_033[0]+-1*P_000110212*R_034[0]+P_000110312*R_035[0]; double PR_002000020022=P_002000020*R_022[0]+-1*P_002000120*R_023[0]+P_002000220*R_024[0]+-1*P_102000020*R_122[0]+P_102000120*R_123[0]+-1*P_102000220*R_124[0]+P_202000020*R_222[0]+-1*P_202000120*R_223[0]+P_202000220*R_224[0]; double PR_001001020022=P_001001020*R_022[0]+-1*P_001001120*R_023[0]+P_001001220*R_024[0]+-1*P_001101020*R_032[0]+P_001101120*R_033[0]+-1*P_001101220*R_034[0]+-1*P_101001020*R_122[0]+P_101001120*R_123[0]+-1*P_101001220*R_124[0]+P_101101020*R_132[0]+-1*P_101101120*R_133[0]+P_101101220*R_134[0]; double PR_000002020022=P_000002020*R_022[0]+-1*P_000002120*R_023[0]+P_000002220*R_024[0]+-1*P_000102020*R_032[0]+P_000102120*R_033[0]+-1*P_000102220*R_034[0]+P_000202020*R_042[0]+-1*P_000202120*R_043[0]+P_000202220*R_044[0]; double PR_001000021022=P_001000021*R_022[0]+-1*P_001000121*R_023[0]+P_001000221*R_024[0]+-1*P_001000321*R_025[0]+-1*P_101000021*R_122[0]+P_101000121*R_123[0]+-1*P_101000221*R_124[0]+P_101000321*R_125[0]; double PR_000001021022=P_000001021*R_022[0]+-1*P_000001121*R_023[0]+P_000001221*R_024[0]+-1*P_000001321*R_025[0]+-1*P_000101021*R_032[0]+P_000101121*R_033[0]+-1*P_000101221*R_034[0]+P_000101321*R_035[0]; double PR_000000022022=P_000000022*R_022[0]+-1*P_000000122*R_023[0]+P_000000222*R_024[0]+-1*P_000000322*R_025[0]+P_000000422*R_026[0]; double PR_022000000031=P_022000000*R_031[0]+-1*P_122000000*R_131[0]+P_222000000*R_231[0]+-1*P_322000000*R_331[0]+P_422000000*R_431[0]; double PR_021001000031=P_021001000*R_031[0]+-1*P_021101000*R_041[0]+-1*P_121001000*R_131[0]+P_121101000*R_141[0]+P_221001000*R_231[0]+-1*P_221101000*R_241[0]+-1*P_321001000*R_331[0]+P_321101000*R_341[0]; double PR_020002000031=P_020002000*R_031[0]+-1*P_020102000*R_041[0]+P_020202000*R_051[0]+-1*P_120002000*R_131[0]+P_120102000*R_141[0]+-1*P_120202000*R_151[0]+P_220002000*R_231[0]+-1*P_220102000*R_241[0]+P_220202000*R_251[0]; double PR_021000001031=P_021000001*R_031[0]+-1*P_021000101*R_032[0]+-1*P_121000001*R_131[0]+P_121000101*R_132[0]+P_221000001*R_231[0]+-1*P_221000101*R_232[0]+-1*P_321000001*R_331[0]+P_321000101*R_332[0]; double PR_020001001031=P_020001001*R_031[0]+-1*P_020001101*R_032[0]+-1*P_020101001*R_041[0]+P_020101101*R_042[0]+-1*P_120001001*R_131[0]+P_120001101*R_132[0]+P_120101001*R_141[0]+-1*P_120101101*R_142[0]+P_220001001*R_231[0]+-1*P_220001101*R_232[0]+-1*P_220101001*R_241[0]+P_220101101*R_242[0]; double PR_020000002031=P_020000002*R_031[0]+-1*P_020000102*R_032[0]+P_020000202*R_033[0]+-1*P_120000002*R_131[0]+P_120000102*R_132[0]+-1*P_120000202*R_133[0]+P_220000002*R_231[0]+-1*P_220000102*R_232[0]+P_220000202*R_233[0]; double PR_012010000031=P_012010000*R_031[0]+-1*P_012110000*R_041[0]+-1*P_112010000*R_131[0]+P_112110000*R_141[0]+P_212010000*R_231[0]+-1*P_212110000*R_241[0]+-1*P_312010000*R_331[0]+P_312110000*R_341[0]; double PR_011011000031=P_011011000*R_031[0]+-1*P_011111000*R_041[0]+P_011211000*R_051[0]+-1*P_111011000*R_131[0]+P_111111000*R_141[0]+-1*P_111211000*R_151[0]+P_211011000*R_231[0]+-1*P_211111000*R_241[0]+P_211211000*R_251[0]; double PR_010012000031=P_010012000*R_031[0]+-1*P_010112000*R_041[0]+P_010212000*R_051[0]+-1*P_010312000*R_061[0]+-1*P_110012000*R_131[0]+P_110112000*R_141[0]+-1*P_110212000*R_151[0]+P_110312000*R_161[0]; double PR_011010001031=P_011010001*R_031[0]+-1*P_011010101*R_032[0]+-1*P_011110001*R_041[0]+P_011110101*R_042[0]+-1*P_111010001*R_131[0]+P_111010101*R_132[0]+P_111110001*R_141[0]+-1*P_111110101*R_142[0]+P_211010001*R_231[0]+-1*P_211010101*R_232[0]+-1*P_211110001*R_241[0]+P_211110101*R_242[0]; double PR_010011001031=P_010011001*R_031[0]+-1*P_010011101*R_032[0]+-1*P_010111001*R_041[0]+P_010111101*R_042[0]+P_010211001*R_051[0]+-1*P_010211101*R_052[0]+-1*P_110011001*R_131[0]+P_110011101*R_132[0]+P_110111001*R_141[0]+-1*P_110111101*R_142[0]+-1*P_110211001*R_151[0]+P_110211101*R_152[0]; double PR_010010002031=P_010010002*R_031[0]+-1*P_010010102*R_032[0]+P_010010202*R_033[0]+-1*P_010110002*R_041[0]+P_010110102*R_042[0]+-1*P_010110202*R_043[0]+-1*P_110010002*R_131[0]+P_110010102*R_132[0]+-1*P_110010202*R_133[0]+P_110110002*R_141[0]+-1*P_110110102*R_142[0]+P_110110202*R_143[0]; double PR_002020000031=P_002020000*R_031[0]+-1*P_002120000*R_041[0]+P_002220000*R_051[0]+-1*P_102020000*R_131[0]+P_102120000*R_141[0]+-1*P_102220000*R_151[0]+P_202020000*R_231[0]+-1*P_202120000*R_241[0]+P_202220000*R_251[0]; double PR_001021000031=P_001021000*R_031[0]+-1*P_001121000*R_041[0]+P_001221000*R_051[0]+-1*P_001321000*R_061[0]+-1*P_101021000*R_131[0]+P_101121000*R_141[0]+-1*P_101221000*R_151[0]+P_101321000*R_161[0]; double PR_000022000031=P_000022000*R_031[0]+-1*P_000122000*R_041[0]+P_000222000*R_051[0]+-1*P_000322000*R_061[0]+P_000422000*R_071[0]; double PR_001020001031=P_001020001*R_031[0]+-1*P_001020101*R_032[0]+-1*P_001120001*R_041[0]+P_001120101*R_042[0]+P_001220001*R_051[0]+-1*P_001220101*R_052[0]+-1*P_101020001*R_131[0]+P_101020101*R_132[0]+P_101120001*R_141[0]+-1*P_101120101*R_142[0]+-1*P_101220001*R_151[0]+P_101220101*R_152[0]; double PR_000021001031=P_000021001*R_031[0]+-1*P_000021101*R_032[0]+-1*P_000121001*R_041[0]+P_000121101*R_042[0]+P_000221001*R_051[0]+-1*P_000221101*R_052[0]+-1*P_000321001*R_061[0]+P_000321101*R_062[0]; double PR_000020002031=P_000020002*R_031[0]+-1*P_000020102*R_032[0]+P_000020202*R_033[0]+-1*P_000120002*R_041[0]+P_000120102*R_042[0]+-1*P_000120202*R_043[0]+P_000220002*R_051[0]+-1*P_000220102*R_052[0]+P_000220202*R_053[0]; double PR_012000010031=P_012000010*R_031[0]+-1*P_012000110*R_032[0]+-1*P_112000010*R_131[0]+P_112000110*R_132[0]+P_212000010*R_231[0]+-1*P_212000110*R_232[0]+-1*P_312000010*R_331[0]+P_312000110*R_332[0]; double PR_011001010031=P_011001010*R_031[0]+-1*P_011001110*R_032[0]+-1*P_011101010*R_041[0]+P_011101110*R_042[0]+-1*P_111001010*R_131[0]+P_111001110*R_132[0]+P_111101010*R_141[0]+-1*P_111101110*R_142[0]+P_211001010*R_231[0]+-1*P_211001110*R_232[0]+-1*P_211101010*R_241[0]+P_211101110*R_242[0]; double PR_010002010031=P_010002010*R_031[0]+-1*P_010002110*R_032[0]+-1*P_010102010*R_041[0]+P_010102110*R_042[0]+P_010202010*R_051[0]+-1*P_010202110*R_052[0]+-1*P_110002010*R_131[0]+P_110002110*R_132[0]+P_110102010*R_141[0]+-1*P_110102110*R_142[0]+-1*P_110202010*R_151[0]+P_110202110*R_152[0]; double PR_011000011031=P_011000011*R_031[0]+-1*P_011000111*R_032[0]+P_011000211*R_033[0]+-1*P_111000011*R_131[0]+P_111000111*R_132[0]+-1*P_111000211*R_133[0]+P_211000011*R_231[0]+-1*P_211000111*R_232[0]+P_211000211*R_233[0]; double PR_010001011031=P_010001011*R_031[0]+-1*P_010001111*R_032[0]+P_010001211*R_033[0]+-1*P_010101011*R_041[0]+P_010101111*R_042[0]+-1*P_010101211*R_043[0]+-1*P_110001011*R_131[0]+P_110001111*R_132[0]+-1*P_110001211*R_133[0]+P_110101011*R_141[0]+-1*P_110101111*R_142[0]+P_110101211*R_143[0]; double PR_010000012031=P_010000012*R_031[0]+-1*P_010000112*R_032[0]+P_010000212*R_033[0]+-1*P_010000312*R_034[0]+-1*P_110000012*R_131[0]+P_110000112*R_132[0]+-1*P_110000212*R_133[0]+P_110000312*R_134[0]; double PR_002010010031=P_002010010*R_031[0]+-1*P_002010110*R_032[0]+-1*P_002110010*R_041[0]+P_002110110*R_042[0]+-1*P_102010010*R_131[0]+P_102010110*R_132[0]+P_102110010*R_141[0]+-1*P_102110110*R_142[0]+P_202010010*R_231[0]+-1*P_202010110*R_232[0]+-1*P_202110010*R_241[0]+P_202110110*R_242[0]; double PR_001011010031=P_001011010*R_031[0]+-1*P_001011110*R_032[0]+-1*P_001111010*R_041[0]+P_001111110*R_042[0]+P_001211010*R_051[0]+-1*P_001211110*R_052[0]+-1*P_101011010*R_131[0]+P_101011110*R_132[0]+P_101111010*R_141[0]+-1*P_101111110*R_142[0]+-1*P_101211010*R_151[0]+P_101211110*R_152[0]; double PR_000012010031=P_000012010*R_031[0]+-1*P_000012110*R_032[0]+-1*P_000112010*R_041[0]+P_000112110*R_042[0]+P_000212010*R_051[0]+-1*P_000212110*R_052[0]+-1*P_000312010*R_061[0]+P_000312110*R_062[0]; double PR_001010011031=P_001010011*R_031[0]+-1*P_001010111*R_032[0]+P_001010211*R_033[0]+-1*P_001110011*R_041[0]+P_001110111*R_042[0]+-1*P_001110211*R_043[0]+-1*P_101010011*R_131[0]+P_101010111*R_132[0]+-1*P_101010211*R_133[0]+P_101110011*R_141[0]+-1*P_101110111*R_142[0]+P_101110211*R_143[0]; double PR_000011011031=P_000011011*R_031[0]+-1*P_000011111*R_032[0]+P_000011211*R_033[0]+-1*P_000111011*R_041[0]+P_000111111*R_042[0]+-1*P_000111211*R_043[0]+P_000211011*R_051[0]+-1*P_000211111*R_052[0]+P_000211211*R_053[0]; double PR_000010012031=P_000010012*R_031[0]+-1*P_000010112*R_032[0]+P_000010212*R_033[0]+-1*P_000010312*R_034[0]+-1*P_000110012*R_041[0]+P_000110112*R_042[0]+-1*P_000110212*R_043[0]+P_000110312*R_044[0]; double PR_002000020031=P_002000020*R_031[0]+-1*P_002000120*R_032[0]+P_002000220*R_033[0]+-1*P_102000020*R_131[0]+P_102000120*R_132[0]+-1*P_102000220*R_133[0]+P_202000020*R_231[0]+-1*P_202000120*R_232[0]+P_202000220*R_233[0]; double PR_001001020031=P_001001020*R_031[0]+-1*P_001001120*R_032[0]+P_001001220*R_033[0]+-1*P_001101020*R_041[0]+P_001101120*R_042[0]+-1*P_001101220*R_043[0]+-1*P_101001020*R_131[0]+P_101001120*R_132[0]+-1*P_101001220*R_133[0]+P_101101020*R_141[0]+-1*P_101101120*R_142[0]+P_101101220*R_143[0]; double PR_000002020031=P_000002020*R_031[0]+-1*P_000002120*R_032[0]+P_000002220*R_033[0]+-1*P_000102020*R_041[0]+P_000102120*R_042[0]+-1*P_000102220*R_043[0]+P_000202020*R_051[0]+-1*P_000202120*R_052[0]+P_000202220*R_053[0]; double PR_001000021031=P_001000021*R_031[0]+-1*P_001000121*R_032[0]+P_001000221*R_033[0]+-1*P_001000321*R_034[0]+-1*P_101000021*R_131[0]+P_101000121*R_132[0]+-1*P_101000221*R_133[0]+P_101000321*R_134[0]; double PR_000001021031=P_000001021*R_031[0]+-1*P_000001121*R_032[0]+P_000001221*R_033[0]+-1*P_000001321*R_034[0]+-1*P_000101021*R_041[0]+P_000101121*R_042[0]+-1*P_000101221*R_043[0]+P_000101321*R_044[0]; double PR_000000022031=P_000000022*R_031[0]+-1*P_000000122*R_032[0]+P_000000222*R_033[0]+-1*P_000000322*R_034[0]+P_000000422*R_035[0]; double PR_022000000040=P_022000000*R_040[0]+-1*P_122000000*R_140[0]+P_222000000*R_240[0]+-1*P_322000000*R_340[0]+P_422000000*R_440[0]; double PR_021001000040=P_021001000*R_040[0]+-1*P_021101000*R_050[0]+-1*P_121001000*R_140[0]+P_121101000*R_150[0]+P_221001000*R_240[0]+-1*P_221101000*R_250[0]+-1*P_321001000*R_340[0]+P_321101000*R_350[0]; double PR_020002000040=P_020002000*R_040[0]+-1*P_020102000*R_050[0]+P_020202000*R_060[0]+-1*P_120002000*R_140[0]+P_120102000*R_150[0]+-1*P_120202000*R_160[0]+P_220002000*R_240[0]+-1*P_220102000*R_250[0]+P_220202000*R_260[0]; double PR_021000001040=P_021000001*R_040[0]+-1*P_021000101*R_041[0]+-1*P_121000001*R_140[0]+P_121000101*R_141[0]+P_221000001*R_240[0]+-1*P_221000101*R_241[0]+-1*P_321000001*R_340[0]+P_321000101*R_341[0]; double PR_020001001040=P_020001001*R_040[0]+-1*P_020001101*R_041[0]+-1*P_020101001*R_050[0]+P_020101101*R_051[0]+-1*P_120001001*R_140[0]+P_120001101*R_141[0]+P_120101001*R_150[0]+-1*P_120101101*R_151[0]+P_220001001*R_240[0]+-1*P_220001101*R_241[0]+-1*P_220101001*R_250[0]+P_220101101*R_251[0]; double PR_020000002040=P_020000002*R_040[0]+-1*P_020000102*R_041[0]+P_020000202*R_042[0]+-1*P_120000002*R_140[0]+P_120000102*R_141[0]+-1*P_120000202*R_142[0]+P_220000002*R_240[0]+-1*P_220000102*R_241[0]+P_220000202*R_242[0]; double PR_012010000040=P_012010000*R_040[0]+-1*P_012110000*R_050[0]+-1*P_112010000*R_140[0]+P_112110000*R_150[0]+P_212010000*R_240[0]+-1*P_212110000*R_250[0]+-1*P_312010000*R_340[0]+P_312110000*R_350[0]; double PR_011011000040=P_011011000*R_040[0]+-1*P_011111000*R_050[0]+P_011211000*R_060[0]+-1*P_111011000*R_140[0]+P_111111000*R_150[0]+-1*P_111211000*R_160[0]+P_211011000*R_240[0]+-1*P_211111000*R_250[0]+P_211211000*R_260[0]; double PR_010012000040=P_010012000*R_040[0]+-1*P_010112000*R_050[0]+P_010212000*R_060[0]+-1*P_010312000*R_070[0]+-1*P_110012000*R_140[0]+P_110112000*R_150[0]+-1*P_110212000*R_160[0]+P_110312000*R_170[0]; double PR_011010001040=P_011010001*R_040[0]+-1*P_011010101*R_041[0]+-1*P_011110001*R_050[0]+P_011110101*R_051[0]+-1*P_111010001*R_140[0]+P_111010101*R_141[0]+P_111110001*R_150[0]+-1*P_111110101*R_151[0]+P_211010001*R_240[0]+-1*P_211010101*R_241[0]+-1*P_211110001*R_250[0]+P_211110101*R_251[0]; double PR_010011001040=P_010011001*R_040[0]+-1*P_010011101*R_041[0]+-1*P_010111001*R_050[0]+P_010111101*R_051[0]+P_010211001*R_060[0]+-1*P_010211101*R_061[0]+-1*P_110011001*R_140[0]+P_110011101*R_141[0]+P_110111001*R_150[0]+-1*P_110111101*R_151[0]+-1*P_110211001*R_160[0]+P_110211101*R_161[0]; double PR_010010002040=P_010010002*R_040[0]+-1*P_010010102*R_041[0]+P_010010202*R_042[0]+-1*P_010110002*R_050[0]+P_010110102*R_051[0]+-1*P_010110202*R_052[0]+-1*P_110010002*R_140[0]+P_110010102*R_141[0]+-1*P_110010202*R_142[0]+P_110110002*R_150[0]+-1*P_110110102*R_151[0]+P_110110202*R_152[0]; double PR_002020000040=P_002020000*R_040[0]+-1*P_002120000*R_050[0]+P_002220000*R_060[0]+-1*P_102020000*R_140[0]+P_102120000*R_150[0]+-1*P_102220000*R_160[0]+P_202020000*R_240[0]+-1*P_202120000*R_250[0]+P_202220000*R_260[0]; double PR_001021000040=P_001021000*R_040[0]+-1*P_001121000*R_050[0]+P_001221000*R_060[0]+-1*P_001321000*R_070[0]+-1*P_101021000*R_140[0]+P_101121000*R_150[0]+-1*P_101221000*R_160[0]+P_101321000*R_170[0]; double PR_000022000040=P_000022000*R_040[0]+-1*P_000122000*R_050[0]+P_000222000*R_060[0]+-1*P_000322000*R_070[0]+P_000422000*R_080[0]; double PR_001020001040=P_001020001*R_040[0]+-1*P_001020101*R_041[0]+-1*P_001120001*R_050[0]+P_001120101*R_051[0]+P_001220001*R_060[0]+-1*P_001220101*R_061[0]+-1*P_101020001*R_140[0]+P_101020101*R_141[0]+P_101120001*R_150[0]+-1*P_101120101*R_151[0]+-1*P_101220001*R_160[0]+P_101220101*R_161[0]; double PR_000021001040=P_000021001*R_040[0]+-1*P_000021101*R_041[0]+-1*P_000121001*R_050[0]+P_000121101*R_051[0]+P_000221001*R_060[0]+-1*P_000221101*R_061[0]+-1*P_000321001*R_070[0]+P_000321101*R_071[0]; double PR_000020002040=P_000020002*R_040[0]+-1*P_000020102*R_041[0]+P_000020202*R_042[0]+-1*P_000120002*R_050[0]+P_000120102*R_051[0]+-1*P_000120202*R_052[0]+P_000220002*R_060[0]+-1*P_000220102*R_061[0]+P_000220202*R_062[0]; double PR_012000010040=P_012000010*R_040[0]+-1*P_012000110*R_041[0]+-1*P_112000010*R_140[0]+P_112000110*R_141[0]+P_212000010*R_240[0]+-1*P_212000110*R_241[0]+-1*P_312000010*R_340[0]+P_312000110*R_341[0]; double PR_011001010040=P_011001010*R_040[0]+-1*P_011001110*R_041[0]+-1*P_011101010*R_050[0]+P_011101110*R_051[0]+-1*P_111001010*R_140[0]+P_111001110*R_141[0]+P_111101010*R_150[0]+-1*P_111101110*R_151[0]+P_211001010*R_240[0]+-1*P_211001110*R_241[0]+-1*P_211101010*R_250[0]+P_211101110*R_251[0]; double PR_010002010040=P_010002010*R_040[0]+-1*P_010002110*R_041[0]+-1*P_010102010*R_050[0]+P_010102110*R_051[0]+P_010202010*R_060[0]+-1*P_010202110*R_061[0]+-1*P_110002010*R_140[0]+P_110002110*R_141[0]+P_110102010*R_150[0]+-1*P_110102110*R_151[0]+-1*P_110202010*R_160[0]+P_110202110*R_161[0]; double PR_011000011040=P_011000011*R_040[0]+-1*P_011000111*R_041[0]+P_011000211*R_042[0]+-1*P_111000011*R_140[0]+P_111000111*R_141[0]+-1*P_111000211*R_142[0]+P_211000011*R_240[0]+-1*P_211000111*R_241[0]+P_211000211*R_242[0]; double PR_010001011040=P_010001011*R_040[0]+-1*P_010001111*R_041[0]+P_010001211*R_042[0]+-1*P_010101011*R_050[0]+P_010101111*R_051[0]+-1*P_010101211*R_052[0]+-1*P_110001011*R_140[0]+P_110001111*R_141[0]+-1*P_110001211*R_142[0]+P_110101011*R_150[0]+-1*P_110101111*R_151[0]+P_110101211*R_152[0]; double PR_010000012040=P_010000012*R_040[0]+-1*P_010000112*R_041[0]+P_010000212*R_042[0]+-1*P_010000312*R_043[0]+-1*P_110000012*R_140[0]+P_110000112*R_141[0]+-1*P_110000212*R_142[0]+P_110000312*R_143[0]; double PR_002010010040=P_002010010*R_040[0]+-1*P_002010110*R_041[0]+-1*P_002110010*R_050[0]+P_002110110*R_051[0]+-1*P_102010010*R_140[0]+P_102010110*R_141[0]+P_102110010*R_150[0]+-1*P_102110110*R_151[0]+P_202010010*R_240[0]+-1*P_202010110*R_241[0]+-1*P_202110010*R_250[0]+P_202110110*R_251[0]; double PR_001011010040=P_001011010*R_040[0]+-1*P_001011110*R_041[0]+-1*P_001111010*R_050[0]+P_001111110*R_051[0]+P_001211010*R_060[0]+-1*P_001211110*R_061[0]+-1*P_101011010*R_140[0]+P_101011110*R_141[0]+P_101111010*R_150[0]+-1*P_101111110*R_151[0]+-1*P_101211010*R_160[0]+P_101211110*R_161[0]; double PR_000012010040=P_000012010*R_040[0]+-1*P_000012110*R_041[0]+-1*P_000112010*R_050[0]+P_000112110*R_051[0]+P_000212010*R_060[0]+-1*P_000212110*R_061[0]+-1*P_000312010*R_070[0]+P_000312110*R_071[0]; double PR_001010011040=P_001010011*R_040[0]+-1*P_001010111*R_041[0]+P_001010211*R_042[0]+-1*P_001110011*R_050[0]+P_001110111*R_051[0]+-1*P_001110211*R_052[0]+-1*P_101010011*R_140[0]+P_101010111*R_141[0]+-1*P_101010211*R_142[0]+P_101110011*R_150[0]+-1*P_101110111*R_151[0]+P_101110211*R_152[0]; double PR_000011011040=P_000011011*R_040[0]+-1*P_000011111*R_041[0]+P_000011211*R_042[0]+-1*P_000111011*R_050[0]+P_000111111*R_051[0]+-1*P_000111211*R_052[0]+P_000211011*R_060[0]+-1*P_000211111*R_061[0]+P_000211211*R_062[0]; double PR_000010012040=P_000010012*R_040[0]+-1*P_000010112*R_041[0]+P_000010212*R_042[0]+-1*P_000010312*R_043[0]+-1*P_000110012*R_050[0]+P_000110112*R_051[0]+-1*P_000110212*R_052[0]+P_000110312*R_053[0]; double PR_002000020040=P_002000020*R_040[0]+-1*P_002000120*R_041[0]+P_002000220*R_042[0]+-1*P_102000020*R_140[0]+P_102000120*R_141[0]+-1*P_102000220*R_142[0]+P_202000020*R_240[0]+-1*P_202000120*R_241[0]+P_202000220*R_242[0]; double PR_001001020040=P_001001020*R_040[0]+-1*P_001001120*R_041[0]+P_001001220*R_042[0]+-1*P_001101020*R_050[0]+P_001101120*R_051[0]+-1*P_001101220*R_052[0]+-1*P_101001020*R_140[0]+P_101001120*R_141[0]+-1*P_101001220*R_142[0]+P_101101020*R_150[0]+-1*P_101101120*R_151[0]+P_101101220*R_152[0]; double PR_000002020040=P_000002020*R_040[0]+-1*P_000002120*R_041[0]+P_000002220*R_042[0]+-1*P_000102020*R_050[0]+P_000102120*R_051[0]+-1*P_000102220*R_052[0]+P_000202020*R_060[0]+-1*P_000202120*R_061[0]+P_000202220*R_062[0]; double PR_001000021040=P_001000021*R_040[0]+-1*P_001000121*R_041[0]+P_001000221*R_042[0]+-1*P_001000321*R_043[0]+-1*P_101000021*R_140[0]+P_101000121*R_141[0]+-1*P_101000221*R_142[0]+P_101000321*R_143[0]; double PR_000001021040=P_000001021*R_040[0]+-1*P_000001121*R_041[0]+P_000001221*R_042[0]+-1*P_000001321*R_043[0]+-1*P_000101021*R_050[0]+P_000101121*R_051[0]+-1*P_000101221*R_052[0]+P_000101321*R_053[0]; double PR_000000022040=P_000000022*R_040[0]+-1*P_000000122*R_041[0]+P_000000222*R_042[0]+-1*P_000000322*R_043[0]+P_000000422*R_044[0]; double PR_022000000103=P_022000000*R_103[0]+-1*P_122000000*R_203[0]+P_222000000*R_303[0]+-1*P_322000000*R_403[0]+P_422000000*R_503[0]; double PR_021001000103=P_021001000*R_103[0]+-1*P_021101000*R_113[0]+-1*P_121001000*R_203[0]+P_121101000*R_213[0]+P_221001000*R_303[0]+-1*P_221101000*R_313[0]+-1*P_321001000*R_403[0]+P_321101000*R_413[0]; double PR_020002000103=P_020002000*R_103[0]+-1*P_020102000*R_113[0]+P_020202000*R_123[0]+-1*P_120002000*R_203[0]+P_120102000*R_213[0]+-1*P_120202000*R_223[0]+P_220002000*R_303[0]+-1*P_220102000*R_313[0]+P_220202000*R_323[0]; double PR_021000001103=P_021000001*R_103[0]+-1*P_021000101*R_104[0]+-1*P_121000001*R_203[0]+P_121000101*R_204[0]+P_221000001*R_303[0]+-1*P_221000101*R_304[0]+-1*P_321000001*R_403[0]+P_321000101*R_404[0]; double PR_020001001103=P_020001001*R_103[0]+-1*P_020001101*R_104[0]+-1*P_020101001*R_113[0]+P_020101101*R_114[0]+-1*P_120001001*R_203[0]+P_120001101*R_204[0]+P_120101001*R_213[0]+-1*P_120101101*R_214[0]+P_220001001*R_303[0]+-1*P_220001101*R_304[0]+-1*P_220101001*R_313[0]+P_220101101*R_314[0]; double PR_020000002103=P_020000002*R_103[0]+-1*P_020000102*R_104[0]+P_020000202*R_105[0]+-1*P_120000002*R_203[0]+P_120000102*R_204[0]+-1*P_120000202*R_205[0]+P_220000002*R_303[0]+-1*P_220000102*R_304[0]+P_220000202*R_305[0]; double PR_012010000103=P_012010000*R_103[0]+-1*P_012110000*R_113[0]+-1*P_112010000*R_203[0]+P_112110000*R_213[0]+P_212010000*R_303[0]+-1*P_212110000*R_313[0]+-1*P_312010000*R_403[0]+P_312110000*R_413[0]; double PR_011011000103=P_011011000*R_103[0]+-1*P_011111000*R_113[0]+P_011211000*R_123[0]+-1*P_111011000*R_203[0]+P_111111000*R_213[0]+-1*P_111211000*R_223[0]+P_211011000*R_303[0]+-1*P_211111000*R_313[0]+P_211211000*R_323[0]; double PR_010012000103=P_010012000*R_103[0]+-1*P_010112000*R_113[0]+P_010212000*R_123[0]+-1*P_010312000*R_133[0]+-1*P_110012000*R_203[0]+P_110112000*R_213[0]+-1*P_110212000*R_223[0]+P_110312000*R_233[0]; double PR_011010001103=P_011010001*R_103[0]+-1*P_011010101*R_104[0]+-1*P_011110001*R_113[0]+P_011110101*R_114[0]+-1*P_111010001*R_203[0]+P_111010101*R_204[0]+P_111110001*R_213[0]+-1*P_111110101*R_214[0]+P_211010001*R_303[0]+-1*P_211010101*R_304[0]+-1*P_211110001*R_313[0]+P_211110101*R_314[0]; double PR_010011001103=P_010011001*R_103[0]+-1*P_010011101*R_104[0]+-1*P_010111001*R_113[0]+P_010111101*R_114[0]+P_010211001*R_123[0]+-1*P_010211101*R_124[0]+-1*P_110011001*R_203[0]+P_110011101*R_204[0]+P_110111001*R_213[0]+-1*P_110111101*R_214[0]+-1*P_110211001*R_223[0]+P_110211101*R_224[0]; double PR_010010002103=P_010010002*R_103[0]+-1*P_010010102*R_104[0]+P_010010202*R_105[0]+-1*P_010110002*R_113[0]+P_010110102*R_114[0]+-1*P_010110202*R_115[0]+-1*P_110010002*R_203[0]+P_110010102*R_204[0]+-1*P_110010202*R_205[0]+P_110110002*R_213[0]+-1*P_110110102*R_214[0]+P_110110202*R_215[0]; double PR_002020000103=P_002020000*R_103[0]+-1*P_002120000*R_113[0]+P_002220000*R_123[0]+-1*P_102020000*R_203[0]+P_102120000*R_213[0]+-1*P_102220000*R_223[0]+P_202020000*R_303[0]+-1*P_202120000*R_313[0]+P_202220000*R_323[0]; double PR_001021000103=P_001021000*R_103[0]+-1*P_001121000*R_113[0]+P_001221000*R_123[0]+-1*P_001321000*R_133[0]+-1*P_101021000*R_203[0]+P_101121000*R_213[0]+-1*P_101221000*R_223[0]+P_101321000*R_233[0]; double PR_000022000103=P_000022000*R_103[0]+-1*P_000122000*R_113[0]+P_000222000*R_123[0]+-1*P_000322000*R_133[0]+P_000422000*R_143[0]; double PR_001020001103=P_001020001*R_103[0]+-1*P_001020101*R_104[0]+-1*P_001120001*R_113[0]+P_001120101*R_114[0]+P_001220001*R_123[0]+-1*P_001220101*R_124[0]+-1*P_101020001*R_203[0]+P_101020101*R_204[0]+P_101120001*R_213[0]+-1*P_101120101*R_214[0]+-1*P_101220001*R_223[0]+P_101220101*R_224[0]; double PR_000021001103=P_000021001*R_103[0]+-1*P_000021101*R_104[0]+-1*P_000121001*R_113[0]+P_000121101*R_114[0]+P_000221001*R_123[0]+-1*P_000221101*R_124[0]+-1*P_000321001*R_133[0]+P_000321101*R_134[0]; double PR_000020002103=P_000020002*R_103[0]+-1*P_000020102*R_104[0]+P_000020202*R_105[0]+-1*P_000120002*R_113[0]+P_000120102*R_114[0]+-1*P_000120202*R_115[0]+P_000220002*R_123[0]+-1*P_000220102*R_124[0]+P_000220202*R_125[0]; double PR_012000010103=P_012000010*R_103[0]+-1*P_012000110*R_104[0]+-1*P_112000010*R_203[0]+P_112000110*R_204[0]+P_212000010*R_303[0]+-1*P_212000110*R_304[0]+-1*P_312000010*R_403[0]+P_312000110*R_404[0]; double PR_011001010103=P_011001010*R_103[0]+-1*P_011001110*R_104[0]+-1*P_011101010*R_113[0]+P_011101110*R_114[0]+-1*P_111001010*R_203[0]+P_111001110*R_204[0]+P_111101010*R_213[0]+-1*P_111101110*R_214[0]+P_211001010*R_303[0]+-1*P_211001110*R_304[0]+-1*P_211101010*R_313[0]+P_211101110*R_314[0]; double PR_010002010103=P_010002010*R_103[0]+-1*P_010002110*R_104[0]+-1*P_010102010*R_113[0]+P_010102110*R_114[0]+P_010202010*R_123[0]+-1*P_010202110*R_124[0]+-1*P_110002010*R_203[0]+P_110002110*R_204[0]+P_110102010*R_213[0]+-1*P_110102110*R_214[0]+-1*P_110202010*R_223[0]+P_110202110*R_224[0]; double PR_011000011103=P_011000011*R_103[0]+-1*P_011000111*R_104[0]+P_011000211*R_105[0]+-1*P_111000011*R_203[0]+P_111000111*R_204[0]+-1*P_111000211*R_205[0]+P_211000011*R_303[0]+-1*P_211000111*R_304[0]+P_211000211*R_305[0]; double PR_010001011103=P_010001011*R_103[0]+-1*P_010001111*R_104[0]+P_010001211*R_105[0]+-1*P_010101011*R_113[0]+P_010101111*R_114[0]+-1*P_010101211*R_115[0]+-1*P_110001011*R_203[0]+P_110001111*R_204[0]+-1*P_110001211*R_205[0]+P_110101011*R_213[0]+-1*P_110101111*R_214[0]+P_110101211*R_215[0]; double PR_010000012103=P_010000012*R_103[0]+-1*P_010000112*R_104[0]+P_010000212*R_105[0]+-1*P_010000312*R_106[0]+-1*P_110000012*R_203[0]+P_110000112*R_204[0]+-1*P_110000212*R_205[0]+P_110000312*R_206[0]; double PR_002010010103=P_002010010*R_103[0]+-1*P_002010110*R_104[0]+-1*P_002110010*R_113[0]+P_002110110*R_114[0]+-1*P_102010010*R_203[0]+P_102010110*R_204[0]+P_102110010*R_213[0]+-1*P_102110110*R_214[0]+P_202010010*R_303[0]+-1*P_202010110*R_304[0]+-1*P_202110010*R_313[0]+P_202110110*R_314[0]; double PR_001011010103=P_001011010*R_103[0]+-1*P_001011110*R_104[0]+-1*P_001111010*R_113[0]+P_001111110*R_114[0]+P_001211010*R_123[0]+-1*P_001211110*R_124[0]+-1*P_101011010*R_203[0]+P_101011110*R_204[0]+P_101111010*R_213[0]+-1*P_101111110*R_214[0]+-1*P_101211010*R_223[0]+P_101211110*R_224[0]; double PR_000012010103=P_000012010*R_103[0]+-1*P_000012110*R_104[0]+-1*P_000112010*R_113[0]+P_000112110*R_114[0]+P_000212010*R_123[0]+-1*P_000212110*R_124[0]+-1*P_000312010*R_133[0]+P_000312110*R_134[0]; double PR_001010011103=P_001010011*R_103[0]+-1*P_001010111*R_104[0]+P_001010211*R_105[0]+-1*P_001110011*R_113[0]+P_001110111*R_114[0]+-1*P_001110211*R_115[0]+-1*P_101010011*R_203[0]+P_101010111*R_204[0]+-1*P_101010211*R_205[0]+P_101110011*R_213[0]+-1*P_101110111*R_214[0]+P_101110211*R_215[0]; double PR_000011011103=P_000011011*R_103[0]+-1*P_000011111*R_104[0]+P_000011211*R_105[0]+-1*P_000111011*R_113[0]+P_000111111*R_114[0]+-1*P_000111211*R_115[0]+P_000211011*R_123[0]+-1*P_000211111*R_124[0]+P_000211211*R_125[0]; double PR_000010012103=P_000010012*R_103[0]+-1*P_000010112*R_104[0]+P_000010212*R_105[0]+-1*P_000010312*R_106[0]+-1*P_000110012*R_113[0]+P_000110112*R_114[0]+-1*P_000110212*R_115[0]+P_000110312*R_116[0]; double PR_002000020103=P_002000020*R_103[0]+-1*P_002000120*R_104[0]+P_002000220*R_105[0]+-1*P_102000020*R_203[0]+P_102000120*R_204[0]+-1*P_102000220*R_205[0]+P_202000020*R_303[0]+-1*P_202000120*R_304[0]+P_202000220*R_305[0]; double PR_001001020103=P_001001020*R_103[0]+-1*P_001001120*R_104[0]+P_001001220*R_105[0]+-1*P_001101020*R_113[0]+P_001101120*R_114[0]+-1*P_001101220*R_115[0]+-1*P_101001020*R_203[0]+P_101001120*R_204[0]+-1*P_101001220*R_205[0]+P_101101020*R_213[0]+-1*P_101101120*R_214[0]+P_101101220*R_215[0]; double PR_000002020103=P_000002020*R_103[0]+-1*P_000002120*R_104[0]+P_000002220*R_105[0]+-1*P_000102020*R_113[0]+P_000102120*R_114[0]+-1*P_000102220*R_115[0]+P_000202020*R_123[0]+-1*P_000202120*R_124[0]+P_000202220*R_125[0]; double PR_001000021103=P_001000021*R_103[0]+-1*P_001000121*R_104[0]+P_001000221*R_105[0]+-1*P_001000321*R_106[0]+-1*P_101000021*R_203[0]+P_101000121*R_204[0]+-1*P_101000221*R_205[0]+P_101000321*R_206[0]; double PR_000001021103=P_000001021*R_103[0]+-1*P_000001121*R_104[0]+P_000001221*R_105[0]+-1*P_000001321*R_106[0]+-1*P_000101021*R_113[0]+P_000101121*R_114[0]+-1*P_000101221*R_115[0]+P_000101321*R_116[0]; double PR_000000022103=P_000000022*R_103[0]+-1*P_000000122*R_104[0]+P_000000222*R_105[0]+-1*P_000000322*R_106[0]+P_000000422*R_107[0]; double PR_022000000112=P_022000000*R_112[0]+-1*P_122000000*R_212[0]+P_222000000*R_312[0]+-1*P_322000000*R_412[0]+P_422000000*R_512[0]; double PR_021001000112=P_021001000*R_112[0]+-1*P_021101000*R_122[0]+-1*P_121001000*R_212[0]+P_121101000*R_222[0]+P_221001000*R_312[0]+-1*P_221101000*R_322[0]+-1*P_321001000*R_412[0]+P_321101000*R_422[0]; double PR_020002000112=P_020002000*R_112[0]+-1*P_020102000*R_122[0]+P_020202000*R_132[0]+-1*P_120002000*R_212[0]+P_120102000*R_222[0]+-1*P_120202000*R_232[0]+P_220002000*R_312[0]+-1*P_220102000*R_322[0]+P_220202000*R_332[0]; double PR_021000001112=P_021000001*R_112[0]+-1*P_021000101*R_113[0]+-1*P_121000001*R_212[0]+P_121000101*R_213[0]+P_221000001*R_312[0]+-1*P_221000101*R_313[0]+-1*P_321000001*R_412[0]+P_321000101*R_413[0]; double PR_020001001112=P_020001001*R_112[0]+-1*P_020001101*R_113[0]+-1*P_020101001*R_122[0]+P_020101101*R_123[0]+-1*P_120001001*R_212[0]+P_120001101*R_213[0]+P_120101001*R_222[0]+-1*P_120101101*R_223[0]+P_220001001*R_312[0]+-1*P_220001101*R_313[0]+-1*P_220101001*R_322[0]+P_220101101*R_323[0]; double PR_020000002112=P_020000002*R_112[0]+-1*P_020000102*R_113[0]+P_020000202*R_114[0]+-1*P_120000002*R_212[0]+P_120000102*R_213[0]+-1*P_120000202*R_214[0]+P_220000002*R_312[0]+-1*P_220000102*R_313[0]+P_220000202*R_314[0]; double PR_012010000112=P_012010000*R_112[0]+-1*P_012110000*R_122[0]+-1*P_112010000*R_212[0]+P_112110000*R_222[0]+P_212010000*R_312[0]+-1*P_212110000*R_322[0]+-1*P_312010000*R_412[0]+P_312110000*R_422[0]; double PR_011011000112=P_011011000*R_112[0]+-1*P_011111000*R_122[0]+P_011211000*R_132[0]+-1*P_111011000*R_212[0]+P_111111000*R_222[0]+-1*P_111211000*R_232[0]+P_211011000*R_312[0]+-1*P_211111000*R_322[0]+P_211211000*R_332[0]; double PR_010012000112=P_010012000*R_112[0]+-1*P_010112000*R_122[0]+P_010212000*R_132[0]+-1*P_010312000*R_142[0]+-1*P_110012000*R_212[0]+P_110112000*R_222[0]+-1*P_110212000*R_232[0]+P_110312000*R_242[0]; double PR_011010001112=P_011010001*R_112[0]+-1*P_011010101*R_113[0]+-1*P_011110001*R_122[0]+P_011110101*R_123[0]+-1*P_111010001*R_212[0]+P_111010101*R_213[0]+P_111110001*R_222[0]+-1*P_111110101*R_223[0]+P_211010001*R_312[0]+-1*P_211010101*R_313[0]+-1*P_211110001*R_322[0]+P_211110101*R_323[0]; double PR_010011001112=P_010011001*R_112[0]+-1*P_010011101*R_113[0]+-1*P_010111001*R_122[0]+P_010111101*R_123[0]+P_010211001*R_132[0]+-1*P_010211101*R_133[0]+-1*P_110011001*R_212[0]+P_110011101*R_213[0]+P_110111001*R_222[0]+-1*P_110111101*R_223[0]+-1*P_110211001*R_232[0]+P_110211101*R_233[0]; double PR_010010002112=P_010010002*R_112[0]+-1*P_010010102*R_113[0]+P_010010202*R_114[0]+-1*P_010110002*R_122[0]+P_010110102*R_123[0]+-1*P_010110202*R_124[0]+-1*P_110010002*R_212[0]+P_110010102*R_213[0]+-1*P_110010202*R_214[0]+P_110110002*R_222[0]+-1*P_110110102*R_223[0]+P_110110202*R_224[0]; double PR_002020000112=P_002020000*R_112[0]+-1*P_002120000*R_122[0]+P_002220000*R_132[0]+-1*P_102020000*R_212[0]+P_102120000*R_222[0]+-1*P_102220000*R_232[0]+P_202020000*R_312[0]+-1*P_202120000*R_322[0]+P_202220000*R_332[0]; double PR_001021000112=P_001021000*R_112[0]+-1*P_001121000*R_122[0]+P_001221000*R_132[0]+-1*P_001321000*R_142[0]+-1*P_101021000*R_212[0]+P_101121000*R_222[0]+-1*P_101221000*R_232[0]+P_101321000*R_242[0]; double PR_000022000112=P_000022000*R_112[0]+-1*P_000122000*R_122[0]+P_000222000*R_132[0]+-1*P_000322000*R_142[0]+P_000422000*R_152[0]; double PR_001020001112=P_001020001*R_112[0]+-1*P_001020101*R_113[0]+-1*P_001120001*R_122[0]+P_001120101*R_123[0]+P_001220001*R_132[0]+-1*P_001220101*R_133[0]+-1*P_101020001*R_212[0]+P_101020101*R_213[0]+P_101120001*R_222[0]+-1*P_101120101*R_223[0]+-1*P_101220001*R_232[0]+P_101220101*R_233[0]; double PR_000021001112=P_000021001*R_112[0]+-1*P_000021101*R_113[0]+-1*P_000121001*R_122[0]+P_000121101*R_123[0]+P_000221001*R_132[0]+-1*P_000221101*R_133[0]+-1*P_000321001*R_142[0]+P_000321101*R_143[0]; double PR_000020002112=P_000020002*R_112[0]+-1*P_000020102*R_113[0]+P_000020202*R_114[0]+-1*P_000120002*R_122[0]+P_000120102*R_123[0]+-1*P_000120202*R_124[0]+P_000220002*R_132[0]+-1*P_000220102*R_133[0]+P_000220202*R_134[0]; double PR_012000010112=P_012000010*R_112[0]+-1*P_012000110*R_113[0]+-1*P_112000010*R_212[0]+P_112000110*R_213[0]+P_212000010*R_312[0]+-1*P_212000110*R_313[0]+-1*P_312000010*R_412[0]+P_312000110*R_413[0]; double PR_011001010112=P_011001010*R_112[0]+-1*P_011001110*R_113[0]+-1*P_011101010*R_122[0]+P_011101110*R_123[0]+-1*P_111001010*R_212[0]+P_111001110*R_213[0]+P_111101010*R_222[0]+-1*P_111101110*R_223[0]+P_211001010*R_312[0]+-1*P_211001110*R_313[0]+-1*P_211101010*R_322[0]+P_211101110*R_323[0]; double PR_010002010112=P_010002010*R_112[0]+-1*P_010002110*R_113[0]+-1*P_010102010*R_122[0]+P_010102110*R_123[0]+P_010202010*R_132[0]+-1*P_010202110*R_133[0]+-1*P_110002010*R_212[0]+P_110002110*R_213[0]+P_110102010*R_222[0]+-1*P_110102110*R_223[0]+-1*P_110202010*R_232[0]+P_110202110*R_233[0]; double PR_011000011112=P_011000011*R_112[0]+-1*P_011000111*R_113[0]+P_011000211*R_114[0]+-1*P_111000011*R_212[0]+P_111000111*R_213[0]+-1*P_111000211*R_214[0]+P_211000011*R_312[0]+-1*P_211000111*R_313[0]+P_211000211*R_314[0]; double PR_010001011112=P_010001011*R_112[0]+-1*P_010001111*R_113[0]+P_010001211*R_114[0]+-1*P_010101011*R_122[0]+P_010101111*R_123[0]+-1*P_010101211*R_124[0]+-1*P_110001011*R_212[0]+P_110001111*R_213[0]+-1*P_110001211*R_214[0]+P_110101011*R_222[0]+-1*P_110101111*R_223[0]+P_110101211*R_224[0]; double PR_010000012112=P_010000012*R_112[0]+-1*P_010000112*R_113[0]+P_010000212*R_114[0]+-1*P_010000312*R_115[0]+-1*P_110000012*R_212[0]+P_110000112*R_213[0]+-1*P_110000212*R_214[0]+P_110000312*R_215[0]; double PR_002010010112=P_002010010*R_112[0]+-1*P_002010110*R_113[0]+-1*P_002110010*R_122[0]+P_002110110*R_123[0]+-1*P_102010010*R_212[0]+P_102010110*R_213[0]+P_102110010*R_222[0]+-1*P_102110110*R_223[0]+P_202010010*R_312[0]+-1*P_202010110*R_313[0]+-1*P_202110010*R_322[0]+P_202110110*R_323[0]; double PR_001011010112=P_001011010*R_112[0]+-1*P_001011110*R_113[0]+-1*P_001111010*R_122[0]+P_001111110*R_123[0]+P_001211010*R_132[0]+-1*P_001211110*R_133[0]+-1*P_101011010*R_212[0]+P_101011110*R_213[0]+P_101111010*R_222[0]+-1*P_101111110*R_223[0]+-1*P_101211010*R_232[0]+P_101211110*R_233[0]; double PR_000012010112=P_000012010*R_112[0]+-1*P_000012110*R_113[0]+-1*P_000112010*R_122[0]+P_000112110*R_123[0]+P_000212010*R_132[0]+-1*P_000212110*R_133[0]+-1*P_000312010*R_142[0]+P_000312110*R_143[0]; double PR_001010011112=P_001010011*R_112[0]+-1*P_001010111*R_113[0]+P_001010211*R_114[0]+-1*P_001110011*R_122[0]+P_001110111*R_123[0]+-1*P_001110211*R_124[0]+-1*P_101010011*R_212[0]+P_101010111*R_213[0]+-1*P_101010211*R_214[0]+P_101110011*R_222[0]+-1*P_101110111*R_223[0]+P_101110211*R_224[0]; double PR_000011011112=P_000011011*R_112[0]+-1*P_000011111*R_113[0]+P_000011211*R_114[0]+-1*P_000111011*R_122[0]+P_000111111*R_123[0]+-1*P_000111211*R_124[0]+P_000211011*R_132[0]+-1*P_000211111*R_133[0]+P_000211211*R_134[0]; double PR_000010012112=P_000010012*R_112[0]+-1*P_000010112*R_113[0]+P_000010212*R_114[0]+-1*P_000010312*R_115[0]+-1*P_000110012*R_122[0]+P_000110112*R_123[0]+-1*P_000110212*R_124[0]+P_000110312*R_125[0]; double PR_002000020112=P_002000020*R_112[0]+-1*P_002000120*R_113[0]+P_002000220*R_114[0]+-1*P_102000020*R_212[0]+P_102000120*R_213[0]+-1*P_102000220*R_214[0]+P_202000020*R_312[0]+-1*P_202000120*R_313[0]+P_202000220*R_314[0]; double PR_001001020112=P_001001020*R_112[0]+-1*P_001001120*R_113[0]+P_001001220*R_114[0]+-1*P_001101020*R_122[0]+P_001101120*R_123[0]+-1*P_001101220*R_124[0]+-1*P_101001020*R_212[0]+P_101001120*R_213[0]+-1*P_101001220*R_214[0]+P_101101020*R_222[0]+-1*P_101101120*R_223[0]+P_101101220*R_224[0]; double PR_000002020112=P_000002020*R_112[0]+-1*P_000002120*R_113[0]+P_000002220*R_114[0]+-1*P_000102020*R_122[0]+P_000102120*R_123[0]+-1*P_000102220*R_124[0]+P_000202020*R_132[0]+-1*P_000202120*R_133[0]+P_000202220*R_134[0]; double PR_001000021112=P_001000021*R_112[0]+-1*P_001000121*R_113[0]+P_001000221*R_114[0]+-1*P_001000321*R_115[0]+-1*P_101000021*R_212[0]+P_101000121*R_213[0]+-1*P_101000221*R_214[0]+P_101000321*R_215[0]; double PR_000001021112=P_000001021*R_112[0]+-1*P_000001121*R_113[0]+P_000001221*R_114[0]+-1*P_000001321*R_115[0]+-1*P_000101021*R_122[0]+P_000101121*R_123[0]+-1*P_000101221*R_124[0]+P_000101321*R_125[0]; double PR_000000022112=P_000000022*R_112[0]+-1*P_000000122*R_113[0]+P_000000222*R_114[0]+-1*P_000000322*R_115[0]+P_000000422*R_116[0]; double PR_022000000121=P_022000000*R_121[0]+-1*P_122000000*R_221[0]+P_222000000*R_321[0]+-1*P_322000000*R_421[0]+P_422000000*R_521[0]; double PR_021001000121=P_021001000*R_121[0]+-1*P_021101000*R_131[0]+-1*P_121001000*R_221[0]+P_121101000*R_231[0]+P_221001000*R_321[0]+-1*P_221101000*R_331[0]+-1*P_321001000*R_421[0]+P_321101000*R_431[0]; double PR_020002000121=P_020002000*R_121[0]+-1*P_020102000*R_131[0]+P_020202000*R_141[0]+-1*P_120002000*R_221[0]+P_120102000*R_231[0]+-1*P_120202000*R_241[0]+P_220002000*R_321[0]+-1*P_220102000*R_331[0]+P_220202000*R_341[0]; double PR_021000001121=P_021000001*R_121[0]+-1*P_021000101*R_122[0]+-1*P_121000001*R_221[0]+P_121000101*R_222[0]+P_221000001*R_321[0]+-1*P_221000101*R_322[0]+-1*P_321000001*R_421[0]+P_321000101*R_422[0]; double PR_020001001121=P_020001001*R_121[0]+-1*P_020001101*R_122[0]+-1*P_020101001*R_131[0]+P_020101101*R_132[0]+-1*P_120001001*R_221[0]+P_120001101*R_222[0]+P_120101001*R_231[0]+-1*P_120101101*R_232[0]+P_220001001*R_321[0]+-1*P_220001101*R_322[0]+-1*P_220101001*R_331[0]+P_220101101*R_332[0]; double PR_020000002121=P_020000002*R_121[0]+-1*P_020000102*R_122[0]+P_020000202*R_123[0]+-1*P_120000002*R_221[0]+P_120000102*R_222[0]+-1*P_120000202*R_223[0]+P_220000002*R_321[0]+-1*P_220000102*R_322[0]+P_220000202*R_323[0]; double PR_012010000121=P_012010000*R_121[0]+-1*P_012110000*R_131[0]+-1*P_112010000*R_221[0]+P_112110000*R_231[0]+P_212010000*R_321[0]+-1*P_212110000*R_331[0]+-1*P_312010000*R_421[0]+P_312110000*R_431[0]; double PR_011011000121=P_011011000*R_121[0]+-1*P_011111000*R_131[0]+P_011211000*R_141[0]+-1*P_111011000*R_221[0]+P_111111000*R_231[0]+-1*P_111211000*R_241[0]+P_211011000*R_321[0]+-1*P_211111000*R_331[0]+P_211211000*R_341[0]; double PR_010012000121=P_010012000*R_121[0]+-1*P_010112000*R_131[0]+P_010212000*R_141[0]+-1*P_010312000*R_151[0]+-1*P_110012000*R_221[0]+P_110112000*R_231[0]+-1*P_110212000*R_241[0]+P_110312000*R_251[0]; double PR_011010001121=P_011010001*R_121[0]+-1*P_011010101*R_122[0]+-1*P_011110001*R_131[0]+P_011110101*R_132[0]+-1*P_111010001*R_221[0]+P_111010101*R_222[0]+P_111110001*R_231[0]+-1*P_111110101*R_232[0]+P_211010001*R_321[0]+-1*P_211010101*R_322[0]+-1*P_211110001*R_331[0]+P_211110101*R_332[0]; double PR_010011001121=P_010011001*R_121[0]+-1*P_010011101*R_122[0]+-1*P_010111001*R_131[0]+P_010111101*R_132[0]+P_010211001*R_141[0]+-1*P_010211101*R_142[0]+-1*P_110011001*R_221[0]+P_110011101*R_222[0]+P_110111001*R_231[0]+-1*P_110111101*R_232[0]+-1*P_110211001*R_241[0]+P_110211101*R_242[0]; double PR_010010002121=P_010010002*R_121[0]+-1*P_010010102*R_122[0]+P_010010202*R_123[0]+-1*P_010110002*R_131[0]+P_010110102*R_132[0]+-1*P_010110202*R_133[0]+-1*P_110010002*R_221[0]+P_110010102*R_222[0]+-1*P_110010202*R_223[0]+P_110110002*R_231[0]+-1*P_110110102*R_232[0]+P_110110202*R_233[0]; double PR_002020000121=P_002020000*R_121[0]+-1*P_002120000*R_131[0]+P_002220000*R_141[0]+-1*P_102020000*R_221[0]+P_102120000*R_231[0]+-1*P_102220000*R_241[0]+P_202020000*R_321[0]+-1*P_202120000*R_331[0]+P_202220000*R_341[0]; double PR_001021000121=P_001021000*R_121[0]+-1*P_001121000*R_131[0]+P_001221000*R_141[0]+-1*P_001321000*R_151[0]+-1*P_101021000*R_221[0]+P_101121000*R_231[0]+-1*P_101221000*R_241[0]+P_101321000*R_251[0]; double PR_000022000121=P_000022000*R_121[0]+-1*P_000122000*R_131[0]+P_000222000*R_141[0]+-1*P_000322000*R_151[0]+P_000422000*R_161[0]; double PR_001020001121=P_001020001*R_121[0]+-1*P_001020101*R_122[0]+-1*P_001120001*R_131[0]+P_001120101*R_132[0]+P_001220001*R_141[0]+-1*P_001220101*R_142[0]+-1*P_101020001*R_221[0]+P_101020101*R_222[0]+P_101120001*R_231[0]+-1*P_101120101*R_232[0]+-1*P_101220001*R_241[0]+P_101220101*R_242[0]; double PR_000021001121=P_000021001*R_121[0]+-1*P_000021101*R_122[0]+-1*P_000121001*R_131[0]+P_000121101*R_132[0]+P_000221001*R_141[0]+-1*P_000221101*R_142[0]+-1*P_000321001*R_151[0]+P_000321101*R_152[0]; double PR_000020002121=P_000020002*R_121[0]+-1*P_000020102*R_122[0]+P_000020202*R_123[0]+-1*P_000120002*R_131[0]+P_000120102*R_132[0]+-1*P_000120202*R_133[0]+P_000220002*R_141[0]+-1*P_000220102*R_142[0]+P_000220202*R_143[0]; double PR_012000010121=P_012000010*R_121[0]+-1*P_012000110*R_122[0]+-1*P_112000010*R_221[0]+P_112000110*R_222[0]+P_212000010*R_321[0]+-1*P_212000110*R_322[0]+-1*P_312000010*R_421[0]+P_312000110*R_422[0]; double PR_011001010121=P_011001010*R_121[0]+-1*P_011001110*R_122[0]+-1*P_011101010*R_131[0]+P_011101110*R_132[0]+-1*P_111001010*R_221[0]+P_111001110*R_222[0]+P_111101010*R_231[0]+-1*P_111101110*R_232[0]+P_211001010*R_321[0]+-1*P_211001110*R_322[0]+-1*P_211101010*R_331[0]+P_211101110*R_332[0]; double PR_010002010121=P_010002010*R_121[0]+-1*P_010002110*R_122[0]+-1*P_010102010*R_131[0]+P_010102110*R_132[0]+P_010202010*R_141[0]+-1*P_010202110*R_142[0]+-1*P_110002010*R_221[0]+P_110002110*R_222[0]+P_110102010*R_231[0]+-1*P_110102110*R_232[0]+-1*P_110202010*R_241[0]+P_110202110*R_242[0]; double PR_011000011121=P_011000011*R_121[0]+-1*P_011000111*R_122[0]+P_011000211*R_123[0]+-1*P_111000011*R_221[0]+P_111000111*R_222[0]+-1*P_111000211*R_223[0]+P_211000011*R_321[0]+-1*P_211000111*R_322[0]+P_211000211*R_323[0]; double PR_010001011121=P_010001011*R_121[0]+-1*P_010001111*R_122[0]+P_010001211*R_123[0]+-1*P_010101011*R_131[0]+P_010101111*R_132[0]+-1*P_010101211*R_133[0]+-1*P_110001011*R_221[0]+P_110001111*R_222[0]+-1*P_110001211*R_223[0]+P_110101011*R_231[0]+-1*P_110101111*R_232[0]+P_110101211*R_233[0]; double PR_010000012121=P_010000012*R_121[0]+-1*P_010000112*R_122[0]+P_010000212*R_123[0]+-1*P_010000312*R_124[0]+-1*P_110000012*R_221[0]+P_110000112*R_222[0]+-1*P_110000212*R_223[0]+P_110000312*R_224[0]; double PR_002010010121=P_002010010*R_121[0]+-1*P_002010110*R_122[0]+-1*P_002110010*R_131[0]+P_002110110*R_132[0]+-1*P_102010010*R_221[0]+P_102010110*R_222[0]+P_102110010*R_231[0]+-1*P_102110110*R_232[0]+P_202010010*R_321[0]+-1*P_202010110*R_322[0]+-1*P_202110010*R_331[0]+P_202110110*R_332[0]; double PR_001011010121=P_001011010*R_121[0]+-1*P_001011110*R_122[0]+-1*P_001111010*R_131[0]+P_001111110*R_132[0]+P_001211010*R_141[0]+-1*P_001211110*R_142[0]+-1*P_101011010*R_221[0]+P_101011110*R_222[0]+P_101111010*R_231[0]+-1*P_101111110*R_232[0]+-1*P_101211010*R_241[0]+P_101211110*R_242[0]; double PR_000012010121=P_000012010*R_121[0]+-1*P_000012110*R_122[0]+-1*P_000112010*R_131[0]+P_000112110*R_132[0]+P_000212010*R_141[0]+-1*P_000212110*R_142[0]+-1*P_000312010*R_151[0]+P_000312110*R_152[0]; double PR_001010011121=P_001010011*R_121[0]+-1*P_001010111*R_122[0]+P_001010211*R_123[0]+-1*P_001110011*R_131[0]+P_001110111*R_132[0]+-1*P_001110211*R_133[0]+-1*P_101010011*R_221[0]+P_101010111*R_222[0]+-1*P_101010211*R_223[0]+P_101110011*R_231[0]+-1*P_101110111*R_232[0]+P_101110211*R_233[0]; double PR_000011011121=P_000011011*R_121[0]+-1*P_000011111*R_122[0]+P_000011211*R_123[0]+-1*P_000111011*R_131[0]+P_000111111*R_132[0]+-1*P_000111211*R_133[0]+P_000211011*R_141[0]+-1*P_000211111*R_142[0]+P_000211211*R_143[0]; double PR_000010012121=P_000010012*R_121[0]+-1*P_000010112*R_122[0]+P_000010212*R_123[0]+-1*P_000010312*R_124[0]+-1*P_000110012*R_131[0]+P_000110112*R_132[0]+-1*P_000110212*R_133[0]+P_000110312*R_134[0]; double PR_002000020121=P_002000020*R_121[0]+-1*P_002000120*R_122[0]+P_002000220*R_123[0]+-1*P_102000020*R_221[0]+P_102000120*R_222[0]+-1*P_102000220*R_223[0]+P_202000020*R_321[0]+-1*P_202000120*R_322[0]+P_202000220*R_323[0]; double PR_001001020121=P_001001020*R_121[0]+-1*P_001001120*R_122[0]+P_001001220*R_123[0]+-1*P_001101020*R_131[0]+P_001101120*R_132[0]+-1*P_001101220*R_133[0]+-1*P_101001020*R_221[0]+P_101001120*R_222[0]+-1*P_101001220*R_223[0]+P_101101020*R_231[0]+-1*P_101101120*R_232[0]+P_101101220*R_233[0]; double PR_000002020121=P_000002020*R_121[0]+-1*P_000002120*R_122[0]+P_000002220*R_123[0]+-1*P_000102020*R_131[0]+P_000102120*R_132[0]+-1*P_000102220*R_133[0]+P_000202020*R_141[0]+-1*P_000202120*R_142[0]+P_000202220*R_143[0]; double PR_001000021121=P_001000021*R_121[0]+-1*P_001000121*R_122[0]+P_001000221*R_123[0]+-1*P_001000321*R_124[0]+-1*P_101000021*R_221[0]+P_101000121*R_222[0]+-1*P_101000221*R_223[0]+P_101000321*R_224[0]; double PR_000001021121=P_000001021*R_121[0]+-1*P_000001121*R_122[0]+P_000001221*R_123[0]+-1*P_000001321*R_124[0]+-1*P_000101021*R_131[0]+P_000101121*R_132[0]+-1*P_000101221*R_133[0]+P_000101321*R_134[0]; double PR_000000022121=P_000000022*R_121[0]+-1*P_000000122*R_122[0]+P_000000222*R_123[0]+-1*P_000000322*R_124[0]+P_000000422*R_125[0]; double PR_022000000130=P_022000000*R_130[0]+-1*P_122000000*R_230[0]+P_222000000*R_330[0]+-1*P_322000000*R_430[0]+P_422000000*R_530[0]; double PR_021001000130=P_021001000*R_130[0]+-1*P_021101000*R_140[0]+-1*P_121001000*R_230[0]+P_121101000*R_240[0]+P_221001000*R_330[0]+-1*P_221101000*R_340[0]+-1*P_321001000*R_430[0]+P_321101000*R_440[0]; double PR_020002000130=P_020002000*R_130[0]+-1*P_020102000*R_140[0]+P_020202000*R_150[0]+-1*P_120002000*R_230[0]+P_120102000*R_240[0]+-1*P_120202000*R_250[0]+P_220002000*R_330[0]+-1*P_220102000*R_340[0]+P_220202000*R_350[0]; double PR_021000001130=P_021000001*R_130[0]+-1*P_021000101*R_131[0]+-1*P_121000001*R_230[0]+P_121000101*R_231[0]+P_221000001*R_330[0]+-1*P_221000101*R_331[0]+-1*P_321000001*R_430[0]+P_321000101*R_431[0]; double PR_020001001130=P_020001001*R_130[0]+-1*P_020001101*R_131[0]+-1*P_020101001*R_140[0]+P_020101101*R_141[0]+-1*P_120001001*R_230[0]+P_120001101*R_231[0]+P_120101001*R_240[0]+-1*P_120101101*R_241[0]+P_220001001*R_330[0]+-1*P_220001101*R_331[0]+-1*P_220101001*R_340[0]+P_220101101*R_341[0]; double PR_020000002130=P_020000002*R_130[0]+-1*P_020000102*R_131[0]+P_020000202*R_132[0]+-1*P_120000002*R_230[0]+P_120000102*R_231[0]+-1*P_120000202*R_232[0]+P_220000002*R_330[0]+-1*P_220000102*R_331[0]+P_220000202*R_332[0]; double PR_012010000130=P_012010000*R_130[0]+-1*P_012110000*R_140[0]+-1*P_112010000*R_230[0]+P_112110000*R_240[0]+P_212010000*R_330[0]+-1*P_212110000*R_340[0]+-1*P_312010000*R_430[0]+P_312110000*R_440[0]; double PR_011011000130=P_011011000*R_130[0]+-1*P_011111000*R_140[0]+P_011211000*R_150[0]+-1*P_111011000*R_230[0]+P_111111000*R_240[0]+-1*P_111211000*R_250[0]+P_211011000*R_330[0]+-1*P_211111000*R_340[0]+P_211211000*R_350[0]; double PR_010012000130=P_010012000*R_130[0]+-1*P_010112000*R_140[0]+P_010212000*R_150[0]+-1*P_010312000*R_160[0]+-1*P_110012000*R_230[0]+P_110112000*R_240[0]+-1*P_110212000*R_250[0]+P_110312000*R_260[0]; double PR_011010001130=P_011010001*R_130[0]+-1*P_011010101*R_131[0]+-1*P_011110001*R_140[0]+P_011110101*R_141[0]+-1*P_111010001*R_230[0]+P_111010101*R_231[0]+P_111110001*R_240[0]+-1*P_111110101*R_241[0]+P_211010001*R_330[0]+-1*P_211010101*R_331[0]+-1*P_211110001*R_340[0]+P_211110101*R_341[0]; double PR_010011001130=P_010011001*R_130[0]+-1*P_010011101*R_131[0]+-1*P_010111001*R_140[0]+P_010111101*R_141[0]+P_010211001*R_150[0]+-1*P_010211101*R_151[0]+-1*P_110011001*R_230[0]+P_110011101*R_231[0]+P_110111001*R_240[0]+-1*P_110111101*R_241[0]+-1*P_110211001*R_250[0]+P_110211101*R_251[0]; double PR_010010002130=P_010010002*R_130[0]+-1*P_010010102*R_131[0]+P_010010202*R_132[0]+-1*P_010110002*R_140[0]+P_010110102*R_141[0]+-1*P_010110202*R_142[0]+-1*P_110010002*R_230[0]+P_110010102*R_231[0]+-1*P_110010202*R_232[0]+P_110110002*R_240[0]+-1*P_110110102*R_241[0]+P_110110202*R_242[0]; double PR_002020000130=P_002020000*R_130[0]+-1*P_002120000*R_140[0]+P_002220000*R_150[0]+-1*P_102020000*R_230[0]+P_102120000*R_240[0]+-1*P_102220000*R_250[0]+P_202020000*R_330[0]+-1*P_202120000*R_340[0]+P_202220000*R_350[0]; double PR_001021000130=P_001021000*R_130[0]+-1*P_001121000*R_140[0]+P_001221000*R_150[0]+-1*P_001321000*R_160[0]+-1*P_101021000*R_230[0]+P_101121000*R_240[0]+-1*P_101221000*R_250[0]+P_101321000*R_260[0]; double PR_000022000130=P_000022000*R_130[0]+-1*P_000122000*R_140[0]+P_000222000*R_150[0]+-1*P_000322000*R_160[0]+P_000422000*R_170[0]; double PR_001020001130=P_001020001*R_130[0]+-1*P_001020101*R_131[0]+-1*P_001120001*R_140[0]+P_001120101*R_141[0]+P_001220001*R_150[0]+-1*P_001220101*R_151[0]+-1*P_101020001*R_230[0]+P_101020101*R_231[0]+P_101120001*R_240[0]+-1*P_101120101*R_241[0]+-1*P_101220001*R_250[0]+P_101220101*R_251[0]; double PR_000021001130=P_000021001*R_130[0]+-1*P_000021101*R_131[0]+-1*P_000121001*R_140[0]+P_000121101*R_141[0]+P_000221001*R_150[0]+-1*P_000221101*R_151[0]+-1*P_000321001*R_160[0]+P_000321101*R_161[0]; double PR_000020002130=P_000020002*R_130[0]+-1*P_000020102*R_131[0]+P_000020202*R_132[0]+-1*P_000120002*R_140[0]+P_000120102*R_141[0]+-1*P_000120202*R_142[0]+P_000220002*R_150[0]+-1*P_000220102*R_151[0]+P_000220202*R_152[0]; double PR_012000010130=P_012000010*R_130[0]+-1*P_012000110*R_131[0]+-1*P_112000010*R_230[0]+P_112000110*R_231[0]+P_212000010*R_330[0]+-1*P_212000110*R_331[0]+-1*P_312000010*R_430[0]+P_312000110*R_431[0]; double PR_011001010130=P_011001010*R_130[0]+-1*P_011001110*R_131[0]+-1*P_011101010*R_140[0]+P_011101110*R_141[0]+-1*P_111001010*R_230[0]+P_111001110*R_231[0]+P_111101010*R_240[0]+-1*P_111101110*R_241[0]+P_211001010*R_330[0]+-1*P_211001110*R_331[0]+-1*P_211101010*R_340[0]+P_211101110*R_341[0]; double PR_010002010130=P_010002010*R_130[0]+-1*P_010002110*R_131[0]+-1*P_010102010*R_140[0]+P_010102110*R_141[0]+P_010202010*R_150[0]+-1*P_010202110*R_151[0]+-1*P_110002010*R_230[0]+P_110002110*R_231[0]+P_110102010*R_240[0]+-1*P_110102110*R_241[0]+-1*P_110202010*R_250[0]+P_110202110*R_251[0]; double PR_011000011130=P_011000011*R_130[0]+-1*P_011000111*R_131[0]+P_011000211*R_132[0]+-1*P_111000011*R_230[0]+P_111000111*R_231[0]+-1*P_111000211*R_232[0]+P_211000011*R_330[0]+-1*P_211000111*R_331[0]+P_211000211*R_332[0]; double PR_010001011130=P_010001011*R_130[0]+-1*P_010001111*R_131[0]+P_010001211*R_132[0]+-1*P_010101011*R_140[0]+P_010101111*R_141[0]+-1*P_010101211*R_142[0]+-1*P_110001011*R_230[0]+P_110001111*R_231[0]+-1*P_110001211*R_232[0]+P_110101011*R_240[0]+-1*P_110101111*R_241[0]+P_110101211*R_242[0]; double PR_010000012130=P_010000012*R_130[0]+-1*P_010000112*R_131[0]+P_010000212*R_132[0]+-1*P_010000312*R_133[0]+-1*P_110000012*R_230[0]+P_110000112*R_231[0]+-1*P_110000212*R_232[0]+P_110000312*R_233[0]; double PR_002010010130=P_002010010*R_130[0]+-1*P_002010110*R_131[0]+-1*P_002110010*R_140[0]+P_002110110*R_141[0]+-1*P_102010010*R_230[0]+P_102010110*R_231[0]+P_102110010*R_240[0]+-1*P_102110110*R_241[0]+P_202010010*R_330[0]+-1*P_202010110*R_331[0]+-1*P_202110010*R_340[0]+P_202110110*R_341[0]; double PR_001011010130=P_001011010*R_130[0]+-1*P_001011110*R_131[0]+-1*P_001111010*R_140[0]+P_001111110*R_141[0]+P_001211010*R_150[0]+-1*P_001211110*R_151[0]+-1*P_101011010*R_230[0]+P_101011110*R_231[0]+P_101111010*R_240[0]+-1*P_101111110*R_241[0]+-1*P_101211010*R_250[0]+P_101211110*R_251[0]; double PR_000012010130=P_000012010*R_130[0]+-1*P_000012110*R_131[0]+-1*P_000112010*R_140[0]+P_000112110*R_141[0]+P_000212010*R_150[0]+-1*P_000212110*R_151[0]+-1*P_000312010*R_160[0]+P_000312110*R_161[0]; double PR_001010011130=P_001010011*R_130[0]+-1*P_001010111*R_131[0]+P_001010211*R_132[0]+-1*P_001110011*R_140[0]+P_001110111*R_141[0]+-1*P_001110211*R_142[0]+-1*P_101010011*R_230[0]+P_101010111*R_231[0]+-1*P_101010211*R_232[0]+P_101110011*R_240[0]+-1*P_101110111*R_241[0]+P_101110211*R_242[0]; double PR_000011011130=P_000011011*R_130[0]+-1*P_000011111*R_131[0]+P_000011211*R_132[0]+-1*P_000111011*R_140[0]+P_000111111*R_141[0]+-1*P_000111211*R_142[0]+P_000211011*R_150[0]+-1*P_000211111*R_151[0]+P_000211211*R_152[0]; double PR_000010012130=P_000010012*R_130[0]+-1*P_000010112*R_131[0]+P_000010212*R_132[0]+-1*P_000010312*R_133[0]+-1*P_000110012*R_140[0]+P_000110112*R_141[0]+-1*P_000110212*R_142[0]+P_000110312*R_143[0]; double PR_002000020130=P_002000020*R_130[0]+-1*P_002000120*R_131[0]+P_002000220*R_132[0]+-1*P_102000020*R_230[0]+P_102000120*R_231[0]+-1*P_102000220*R_232[0]+P_202000020*R_330[0]+-1*P_202000120*R_331[0]+P_202000220*R_332[0]; double PR_001001020130=P_001001020*R_130[0]+-1*P_001001120*R_131[0]+P_001001220*R_132[0]+-1*P_001101020*R_140[0]+P_001101120*R_141[0]+-1*P_001101220*R_142[0]+-1*P_101001020*R_230[0]+P_101001120*R_231[0]+-1*P_101001220*R_232[0]+P_101101020*R_240[0]+-1*P_101101120*R_241[0]+P_101101220*R_242[0]; double PR_000002020130=P_000002020*R_130[0]+-1*P_000002120*R_131[0]+P_000002220*R_132[0]+-1*P_000102020*R_140[0]+P_000102120*R_141[0]+-1*P_000102220*R_142[0]+P_000202020*R_150[0]+-1*P_000202120*R_151[0]+P_000202220*R_152[0]; double PR_001000021130=P_001000021*R_130[0]+-1*P_001000121*R_131[0]+P_001000221*R_132[0]+-1*P_001000321*R_133[0]+-1*P_101000021*R_230[0]+P_101000121*R_231[0]+-1*P_101000221*R_232[0]+P_101000321*R_233[0]; double PR_000001021130=P_000001021*R_130[0]+-1*P_000001121*R_131[0]+P_000001221*R_132[0]+-1*P_000001321*R_133[0]+-1*P_000101021*R_140[0]+P_000101121*R_141[0]+-1*P_000101221*R_142[0]+P_000101321*R_143[0]; double PR_000000022130=P_000000022*R_130[0]+-1*P_000000122*R_131[0]+P_000000222*R_132[0]+-1*P_000000322*R_133[0]+P_000000422*R_134[0]; double PR_022000000202=P_022000000*R_202[0]+-1*P_122000000*R_302[0]+P_222000000*R_402[0]+-1*P_322000000*R_502[0]+P_422000000*R_602[0]; double PR_021001000202=P_021001000*R_202[0]+-1*P_021101000*R_212[0]+-1*P_121001000*R_302[0]+P_121101000*R_312[0]+P_221001000*R_402[0]+-1*P_221101000*R_412[0]+-1*P_321001000*R_502[0]+P_321101000*R_512[0]; double PR_020002000202=P_020002000*R_202[0]+-1*P_020102000*R_212[0]+P_020202000*R_222[0]+-1*P_120002000*R_302[0]+P_120102000*R_312[0]+-1*P_120202000*R_322[0]+P_220002000*R_402[0]+-1*P_220102000*R_412[0]+P_220202000*R_422[0]; double PR_021000001202=P_021000001*R_202[0]+-1*P_021000101*R_203[0]+-1*P_121000001*R_302[0]+P_121000101*R_303[0]+P_221000001*R_402[0]+-1*P_221000101*R_403[0]+-1*P_321000001*R_502[0]+P_321000101*R_503[0]; double PR_020001001202=P_020001001*R_202[0]+-1*P_020001101*R_203[0]+-1*P_020101001*R_212[0]+P_020101101*R_213[0]+-1*P_120001001*R_302[0]+P_120001101*R_303[0]+P_120101001*R_312[0]+-1*P_120101101*R_313[0]+P_220001001*R_402[0]+-1*P_220001101*R_403[0]+-1*P_220101001*R_412[0]+P_220101101*R_413[0]; double PR_020000002202=P_020000002*R_202[0]+-1*P_020000102*R_203[0]+P_020000202*R_204[0]+-1*P_120000002*R_302[0]+P_120000102*R_303[0]+-1*P_120000202*R_304[0]+P_220000002*R_402[0]+-1*P_220000102*R_403[0]+P_220000202*R_404[0]; double PR_012010000202=P_012010000*R_202[0]+-1*P_012110000*R_212[0]+-1*P_112010000*R_302[0]+P_112110000*R_312[0]+P_212010000*R_402[0]+-1*P_212110000*R_412[0]+-1*P_312010000*R_502[0]+P_312110000*R_512[0]; double PR_011011000202=P_011011000*R_202[0]+-1*P_011111000*R_212[0]+P_011211000*R_222[0]+-1*P_111011000*R_302[0]+P_111111000*R_312[0]+-1*P_111211000*R_322[0]+P_211011000*R_402[0]+-1*P_211111000*R_412[0]+P_211211000*R_422[0]; double PR_010012000202=P_010012000*R_202[0]+-1*P_010112000*R_212[0]+P_010212000*R_222[0]+-1*P_010312000*R_232[0]+-1*P_110012000*R_302[0]+P_110112000*R_312[0]+-1*P_110212000*R_322[0]+P_110312000*R_332[0]; double PR_011010001202=P_011010001*R_202[0]+-1*P_011010101*R_203[0]+-1*P_011110001*R_212[0]+P_011110101*R_213[0]+-1*P_111010001*R_302[0]+P_111010101*R_303[0]+P_111110001*R_312[0]+-1*P_111110101*R_313[0]+P_211010001*R_402[0]+-1*P_211010101*R_403[0]+-1*P_211110001*R_412[0]+P_211110101*R_413[0]; double PR_010011001202=P_010011001*R_202[0]+-1*P_010011101*R_203[0]+-1*P_010111001*R_212[0]+P_010111101*R_213[0]+P_010211001*R_222[0]+-1*P_010211101*R_223[0]+-1*P_110011001*R_302[0]+P_110011101*R_303[0]+P_110111001*R_312[0]+-1*P_110111101*R_313[0]+-1*P_110211001*R_322[0]+P_110211101*R_323[0]; double PR_010010002202=P_010010002*R_202[0]+-1*P_010010102*R_203[0]+P_010010202*R_204[0]+-1*P_010110002*R_212[0]+P_010110102*R_213[0]+-1*P_010110202*R_214[0]+-1*P_110010002*R_302[0]+P_110010102*R_303[0]+-1*P_110010202*R_304[0]+P_110110002*R_312[0]+-1*P_110110102*R_313[0]+P_110110202*R_314[0]; double PR_002020000202=P_002020000*R_202[0]+-1*P_002120000*R_212[0]+P_002220000*R_222[0]+-1*P_102020000*R_302[0]+P_102120000*R_312[0]+-1*P_102220000*R_322[0]+P_202020000*R_402[0]+-1*P_202120000*R_412[0]+P_202220000*R_422[0]; double PR_001021000202=P_001021000*R_202[0]+-1*P_001121000*R_212[0]+P_001221000*R_222[0]+-1*P_001321000*R_232[0]+-1*P_101021000*R_302[0]+P_101121000*R_312[0]+-1*P_101221000*R_322[0]+P_101321000*R_332[0]; double PR_000022000202=P_000022000*R_202[0]+-1*P_000122000*R_212[0]+P_000222000*R_222[0]+-1*P_000322000*R_232[0]+P_000422000*R_242[0]; double PR_001020001202=P_001020001*R_202[0]+-1*P_001020101*R_203[0]+-1*P_001120001*R_212[0]+P_001120101*R_213[0]+P_001220001*R_222[0]+-1*P_001220101*R_223[0]+-1*P_101020001*R_302[0]+P_101020101*R_303[0]+P_101120001*R_312[0]+-1*P_101120101*R_313[0]+-1*P_101220001*R_322[0]+P_101220101*R_323[0]; double PR_000021001202=P_000021001*R_202[0]+-1*P_000021101*R_203[0]+-1*P_000121001*R_212[0]+P_000121101*R_213[0]+P_000221001*R_222[0]+-1*P_000221101*R_223[0]+-1*P_000321001*R_232[0]+P_000321101*R_233[0]; double PR_000020002202=P_000020002*R_202[0]+-1*P_000020102*R_203[0]+P_000020202*R_204[0]+-1*P_000120002*R_212[0]+P_000120102*R_213[0]+-1*P_000120202*R_214[0]+P_000220002*R_222[0]+-1*P_000220102*R_223[0]+P_000220202*R_224[0]; double PR_012000010202=P_012000010*R_202[0]+-1*P_012000110*R_203[0]+-1*P_112000010*R_302[0]+P_112000110*R_303[0]+P_212000010*R_402[0]+-1*P_212000110*R_403[0]+-1*P_312000010*R_502[0]+P_312000110*R_503[0]; double PR_011001010202=P_011001010*R_202[0]+-1*P_011001110*R_203[0]+-1*P_011101010*R_212[0]+P_011101110*R_213[0]+-1*P_111001010*R_302[0]+P_111001110*R_303[0]+P_111101010*R_312[0]+-1*P_111101110*R_313[0]+P_211001010*R_402[0]+-1*P_211001110*R_403[0]+-1*P_211101010*R_412[0]+P_211101110*R_413[0]; double PR_010002010202=P_010002010*R_202[0]+-1*P_010002110*R_203[0]+-1*P_010102010*R_212[0]+P_010102110*R_213[0]+P_010202010*R_222[0]+-1*P_010202110*R_223[0]+-1*P_110002010*R_302[0]+P_110002110*R_303[0]+P_110102010*R_312[0]+-1*P_110102110*R_313[0]+-1*P_110202010*R_322[0]+P_110202110*R_323[0]; double PR_011000011202=P_011000011*R_202[0]+-1*P_011000111*R_203[0]+P_011000211*R_204[0]+-1*P_111000011*R_302[0]+P_111000111*R_303[0]+-1*P_111000211*R_304[0]+P_211000011*R_402[0]+-1*P_211000111*R_403[0]+P_211000211*R_404[0]; double PR_010001011202=P_010001011*R_202[0]+-1*P_010001111*R_203[0]+P_010001211*R_204[0]+-1*P_010101011*R_212[0]+P_010101111*R_213[0]+-1*P_010101211*R_214[0]+-1*P_110001011*R_302[0]+P_110001111*R_303[0]+-1*P_110001211*R_304[0]+P_110101011*R_312[0]+-1*P_110101111*R_313[0]+P_110101211*R_314[0]; double PR_010000012202=P_010000012*R_202[0]+-1*P_010000112*R_203[0]+P_010000212*R_204[0]+-1*P_010000312*R_205[0]+-1*P_110000012*R_302[0]+P_110000112*R_303[0]+-1*P_110000212*R_304[0]+P_110000312*R_305[0]; double PR_002010010202=P_002010010*R_202[0]+-1*P_002010110*R_203[0]+-1*P_002110010*R_212[0]+P_002110110*R_213[0]+-1*P_102010010*R_302[0]+P_102010110*R_303[0]+P_102110010*R_312[0]+-1*P_102110110*R_313[0]+P_202010010*R_402[0]+-1*P_202010110*R_403[0]+-1*P_202110010*R_412[0]+P_202110110*R_413[0]; double PR_001011010202=P_001011010*R_202[0]+-1*P_001011110*R_203[0]+-1*P_001111010*R_212[0]+P_001111110*R_213[0]+P_001211010*R_222[0]+-1*P_001211110*R_223[0]+-1*P_101011010*R_302[0]+P_101011110*R_303[0]+P_101111010*R_312[0]+-1*P_101111110*R_313[0]+-1*P_101211010*R_322[0]+P_101211110*R_323[0]; double PR_000012010202=P_000012010*R_202[0]+-1*P_000012110*R_203[0]+-1*P_000112010*R_212[0]+P_000112110*R_213[0]+P_000212010*R_222[0]+-1*P_000212110*R_223[0]+-1*P_000312010*R_232[0]+P_000312110*R_233[0]; double PR_001010011202=P_001010011*R_202[0]+-1*P_001010111*R_203[0]+P_001010211*R_204[0]+-1*P_001110011*R_212[0]+P_001110111*R_213[0]+-1*P_001110211*R_214[0]+-1*P_101010011*R_302[0]+P_101010111*R_303[0]+-1*P_101010211*R_304[0]+P_101110011*R_312[0]+-1*P_101110111*R_313[0]+P_101110211*R_314[0]; double PR_000011011202=P_000011011*R_202[0]+-1*P_000011111*R_203[0]+P_000011211*R_204[0]+-1*P_000111011*R_212[0]+P_000111111*R_213[0]+-1*P_000111211*R_214[0]+P_000211011*R_222[0]+-1*P_000211111*R_223[0]+P_000211211*R_224[0]; double PR_000010012202=P_000010012*R_202[0]+-1*P_000010112*R_203[0]+P_000010212*R_204[0]+-1*P_000010312*R_205[0]+-1*P_000110012*R_212[0]+P_000110112*R_213[0]+-1*P_000110212*R_214[0]+P_000110312*R_215[0]; double PR_002000020202=P_002000020*R_202[0]+-1*P_002000120*R_203[0]+P_002000220*R_204[0]+-1*P_102000020*R_302[0]+P_102000120*R_303[0]+-1*P_102000220*R_304[0]+P_202000020*R_402[0]+-1*P_202000120*R_403[0]+P_202000220*R_404[0]; double PR_001001020202=P_001001020*R_202[0]+-1*P_001001120*R_203[0]+P_001001220*R_204[0]+-1*P_001101020*R_212[0]+P_001101120*R_213[0]+-1*P_001101220*R_214[0]+-1*P_101001020*R_302[0]+P_101001120*R_303[0]+-1*P_101001220*R_304[0]+P_101101020*R_312[0]+-1*P_101101120*R_313[0]+P_101101220*R_314[0]; double PR_000002020202=P_000002020*R_202[0]+-1*P_000002120*R_203[0]+P_000002220*R_204[0]+-1*P_000102020*R_212[0]+P_000102120*R_213[0]+-1*P_000102220*R_214[0]+P_000202020*R_222[0]+-1*P_000202120*R_223[0]+P_000202220*R_224[0]; double PR_001000021202=P_001000021*R_202[0]+-1*P_001000121*R_203[0]+P_001000221*R_204[0]+-1*P_001000321*R_205[0]+-1*P_101000021*R_302[0]+P_101000121*R_303[0]+-1*P_101000221*R_304[0]+P_101000321*R_305[0]; double PR_000001021202=P_000001021*R_202[0]+-1*P_000001121*R_203[0]+P_000001221*R_204[0]+-1*P_000001321*R_205[0]+-1*P_000101021*R_212[0]+P_000101121*R_213[0]+-1*P_000101221*R_214[0]+P_000101321*R_215[0]; double PR_000000022202=P_000000022*R_202[0]+-1*P_000000122*R_203[0]+P_000000222*R_204[0]+-1*P_000000322*R_205[0]+P_000000422*R_206[0]; double PR_022000000211=P_022000000*R_211[0]+-1*P_122000000*R_311[0]+P_222000000*R_411[0]+-1*P_322000000*R_511[0]+P_422000000*R_611[0]; double PR_021001000211=P_021001000*R_211[0]+-1*P_021101000*R_221[0]+-1*P_121001000*R_311[0]+P_121101000*R_321[0]+P_221001000*R_411[0]+-1*P_221101000*R_421[0]+-1*P_321001000*R_511[0]+P_321101000*R_521[0]; double PR_020002000211=P_020002000*R_211[0]+-1*P_020102000*R_221[0]+P_020202000*R_231[0]+-1*P_120002000*R_311[0]+P_120102000*R_321[0]+-1*P_120202000*R_331[0]+P_220002000*R_411[0]+-1*P_220102000*R_421[0]+P_220202000*R_431[0]; double PR_021000001211=P_021000001*R_211[0]+-1*P_021000101*R_212[0]+-1*P_121000001*R_311[0]+P_121000101*R_312[0]+P_221000001*R_411[0]+-1*P_221000101*R_412[0]+-1*P_321000001*R_511[0]+P_321000101*R_512[0]; double PR_020001001211=P_020001001*R_211[0]+-1*P_020001101*R_212[0]+-1*P_020101001*R_221[0]+P_020101101*R_222[0]+-1*P_120001001*R_311[0]+P_120001101*R_312[0]+P_120101001*R_321[0]+-1*P_120101101*R_322[0]+P_220001001*R_411[0]+-1*P_220001101*R_412[0]+-1*P_220101001*R_421[0]+P_220101101*R_422[0]; double PR_020000002211=P_020000002*R_211[0]+-1*P_020000102*R_212[0]+P_020000202*R_213[0]+-1*P_120000002*R_311[0]+P_120000102*R_312[0]+-1*P_120000202*R_313[0]+P_220000002*R_411[0]+-1*P_220000102*R_412[0]+P_220000202*R_413[0]; double PR_012010000211=P_012010000*R_211[0]+-1*P_012110000*R_221[0]+-1*P_112010000*R_311[0]+P_112110000*R_321[0]+P_212010000*R_411[0]+-1*P_212110000*R_421[0]+-1*P_312010000*R_511[0]+P_312110000*R_521[0]; double PR_011011000211=P_011011000*R_211[0]+-1*P_011111000*R_221[0]+P_011211000*R_231[0]+-1*P_111011000*R_311[0]+P_111111000*R_321[0]+-1*P_111211000*R_331[0]+P_211011000*R_411[0]+-1*P_211111000*R_421[0]+P_211211000*R_431[0]; double PR_010012000211=P_010012000*R_211[0]+-1*P_010112000*R_221[0]+P_010212000*R_231[0]+-1*P_010312000*R_241[0]+-1*P_110012000*R_311[0]+P_110112000*R_321[0]+-1*P_110212000*R_331[0]+P_110312000*R_341[0]; double PR_011010001211=P_011010001*R_211[0]+-1*P_011010101*R_212[0]+-1*P_011110001*R_221[0]+P_011110101*R_222[0]+-1*P_111010001*R_311[0]+P_111010101*R_312[0]+P_111110001*R_321[0]+-1*P_111110101*R_322[0]+P_211010001*R_411[0]+-1*P_211010101*R_412[0]+-1*P_211110001*R_421[0]+P_211110101*R_422[0]; double PR_010011001211=P_010011001*R_211[0]+-1*P_010011101*R_212[0]+-1*P_010111001*R_221[0]+P_010111101*R_222[0]+P_010211001*R_231[0]+-1*P_010211101*R_232[0]+-1*P_110011001*R_311[0]+P_110011101*R_312[0]+P_110111001*R_321[0]+-1*P_110111101*R_322[0]+-1*P_110211001*R_331[0]+P_110211101*R_332[0]; double PR_010010002211=P_010010002*R_211[0]+-1*P_010010102*R_212[0]+P_010010202*R_213[0]+-1*P_010110002*R_221[0]+P_010110102*R_222[0]+-1*P_010110202*R_223[0]+-1*P_110010002*R_311[0]+P_110010102*R_312[0]+-1*P_110010202*R_313[0]+P_110110002*R_321[0]+-1*P_110110102*R_322[0]+P_110110202*R_323[0]; double PR_002020000211=P_002020000*R_211[0]+-1*P_002120000*R_221[0]+P_002220000*R_231[0]+-1*P_102020000*R_311[0]+P_102120000*R_321[0]+-1*P_102220000*R_331[0]+P_202020000*R_411[0]+-1*P_202120000*R_421[0]+P_202220000*R_431[0]; double PR_001021000211=P_001021000*R_211[0]+-1*P_001121000*R_221[0]+P_001221000*R_231[0]+-1*P_001321000*R_241[0]+-1*P_101021000*R_311[0]+P_101121000*R_321[0]+-1*P_101221000*R_331[0]+P_101321000*R_341[0]; double PR_000022000211=P_000022000*R_211[0]+-1*P_000122000*R_221[0]+P_000222000*R_231[0]+-1*P_000322000*R_241[0]+P_000422000*R_251[0]; double PR_001020001211=P_001020001*R_211[0]+-1*P_001020101*R_212[0]+-1*P_001120001*R_221[0]+P_001120101*R_222[0]+P_001220001*R_231[0]+-1*P_001220101*R_232[0]+-1*P_101020001*R_311[0]+P_101020101*R_312[0]+P_101120001*R_321[0]+-1*P_101120101*R_322[0]+-1*P_101220001*R_331[0]+P_101220101*R_332[0]; double PR_000021001211=P_000021001*R_211[0]+-1*P_000021101*R_212[0]+-1*P_000121001*R_221[0]+P_000121101*R_222[0]+P_000221001*R_231[0]+-1*P_000221101*R_232[0]+-1*P_000321001*R_241[0]+P_000321101*R_242[0]; double PR_000020002211=P_000020002*R_211[0]+-1*P_000020102*R_212[0]+P_000020202*R_213[0]+-1*P_000120002*R_221[0]+P_000120102*R_222[0]+-1*P_000120202*R_223[0]+P_000220002*R_231[0]+-1*P_000220102*R_232[0]+P_000220202*R_233[0]; double PR_012000010211=P_012000010*R_211[0]+-1*P_012000110*R_212[0]+-1*P_112000010*R_311[0]+P_112000110*R_312[0]+P_212000010*R_411[0]+-1*P_212000110*R_412[0]+-1*P_312000010*R_511[0]+P_312000110*R_512[0]; double PR_011001010211=P_011001010*R_211[0]+-1*P_011001110*R_212[0]+-1*P_011101010*R_221[0]+P_011101110*R_222[0]+-1*P_111001010*R_311[0]+P_111001110*R_312[0]+P_111101010*R_321[0]+-1*P_111101110*R_322[0]+P_211001010*R_411[0]+-1*P_211001110*R_412[0]+-1*P_211101010*R_421[0]+P_211101110*R_422[0]; double PR_010002010211=P_010002010*R_211[0]+-1*P_010002110*R_212[0]+-1*P_010102010*R_221[0]+P_010102110*R_222[0]+P_010202010*R_231[0]+-1*P_010202110*R_232[0]+-1*P_110002010*R_311[0]+P_110002110*R_312[0]+P_110102010*R_321[0]+-1*P_110102110*R_322[0]+-1*P_110202010*R_331[0]+P_110202110*R_332[0]; double PR_011000011211=P_011000011*R_211[0]+-1*P_011000111*R_212[0]+P_011000211*R_213[0]+-1*P_111000011*R_311[0]+P_111000111*R_312[0]+-1*P_111000211*R_313[0]+P_211000011*R_411[0]+-1*P_211000111*R_412[0]+P_211000211*R_413[0]; double PR_010001011211=P_010001011*R_211[0]+-1*P_010001111*R_212[0]+P_010001211*R_213[0]+-1*P_010101011*R_221[0]+P_010101111*R_222[0]+-1*P_010101211*R_223[0]+-1*P_110001011*R_311[0]+P_110001111*R_312[0]+-1*P_110001211*R_313[0]+P_110101011*R_321[0]+-1*P_110101111*R_322[0]+P_110101211*R_323[0]; double PR_010000012211=P_010000012*R_211[0]+-1*P_010000112*R_212[0]+P_010000212*R_213[0]+-1*P_010000312*R_214[0]+-1*P_110000012*R_311[0]+P_110000112*R_312[0]+-1*P_110000212*R_313[0]+P_110000312*R_314[0]; double PR_002010010211=P_002010010*R_211[0]+-1*P_002010110*R_212[0]+-1*P_002110010*R_221[0]+P_002110110*R_222[0]+-1*P_102010010*R_311[0]+P_102010110*R_312[0]+P_102110010*R_321[0]+-1*P_102110110*R_322[0]+P_202010010*R_411[0]+-1*P_202010110*R_412[0]+-1*P_202110010*R_421[0]+P_202110110*R_422[0]; double PR_001011010211=P_001011010*R_211[0]+-1*P_001011110*R_212[0]+-1*P_001111010*R_221[0]+P_001111110*R_222[0]+P_001211010*R_231[0]+-1*P_001211110*R_232[0]+-1*P_101011010*R_311[0]+P_101011110*R_312[0]+P_101111010*R_321[0]+-1*P_101111110*R_322[0]+-1*P_101211010*R_331[0]+P_101211110*R_332[0]; double PR_000012010211=P_000012010*R_211[0]+-1*P_000012110*R_212[0]+-1*P_000112010*R_221[0]+P_000112110*R_222[0]+P_000212010*R_231[0]+-1*P_000212110*R_232[0]+-1*P_000312010*R_241[0]+P_000312110*R_242[0]; double PR_001010011211=P_001010011*R_211[0]+-1*P_001010111*R_212[0]+P_001010211*R_213[0]+-1*P_001110011*R_221[0]+P_001110111*R_222[0]+-1*P_001110211*R_223[0]+-1*P_101010011*R_311[0]+P_101010111*R_312[0]+-1*P_101010211*R_313[0]+P_101110011*R_321[0]+-1*P_101110111*R_322[0]+P_101110211*R_323[0]; double PR_000011011211=P_000011011*R_211[0]+-1*P_000011111*R_212[0]+P_000011211*R_213[0]+-1*P_000111011*R_221[0]+P_000111111*R_222[0]+-1*P_000111211*R_223[0]+P_000211011*R_231[0]+-1*P_000211111*R_232[0]+P_000211211*R_233[0]; double PR_000010012211=P_000010012*R_211[0]+-1*P_000010112*R_212[0]+P_000010212*R_213[0]+-1*P_000010312*R_214[0]+-1*P_000110012*R_221[0]+P_000110112*R_222[0]+-1*P_000110212*R_223[0]+P_000110312*R_224[0]; double PR_002000020211=P_002000020*R_211[0]+-1*P_002000120*R_212[0]+P_002000220*R_213[0]+-1*P_102000020*R_311[0]+P_102000120*R_312[0]+-1*P_102000220*R_313[0]+P_202000020*R_411[0]+-1*P_202000120*R_412[0]+P_202000220*R_413[0]; double PR_001001020211=P_001001020*R_211[0]+-1*P_001001120*R_212[0]+P_001001220*R_213[0]+-1*P_001101020*R_221[0]+P_001101120*R_222[0]+-1*P_001101220*R_223[0]+-1*P_101001020*R_311[0]+P_101001120*R_312[0]+-1*P_101001220*R_313[0]+P_101101020*R_321[0]+-1*P_101101120*R_322[0]+P_101101220*R_323[0]; double PR_000002020211=P_000002020*R_211[0]+-1*P_000002120*R_212[0]+P_000002220*R_213[0]+-1*P_000102020*R_221[0]+P_000102120*R_222[0]+-1*P_000102220*R_223[0]+P_000202020*R_231[0]+-1*P_000202120*R_232[0]+P_000202220*R_233[0]; double PR_001000021211=P_001000021*R_211[0]+-1*P_001000121*R_212[0]+P_001000221*R_213[0]+-1*P_001000321*R_214[0]+-1*P_101000021*R_311[0]+P_101000121*R_312[0]+-1*P_101000221*R_313[0]+P_101000321*R_314[0]; double PR_000001021211=P_000001021*R_211[0]+-1*P_000001121*R_212[0]+P_000001221*R_213[0]+-1*P_000001321*R_214[0]+-1*P_000101021*R_221[0]+P_000101121*R_222[0]+-1*P_000101221*R_223[0]+P_000101321*R_224[0]; double PR_000000022211=P_000000022*R_211[0]+-1*P_000000122*R_212[0]+P_000000222*R_213[0]+-1*P_000000322*R_214[0]+P_000000422*R_215[0]; double PR_022000000220=P_022000000*R_220[0]+-1*P_122000000*R_320[0]+P_222000000*R_420[0]+-1*P_322000000*R_520[0]+P_422000000*R_620[0]; double PR_021001000220=P_021001000*R_220[0]+-1*P_021101000*R_230[0]+-1*P_121001000*R_320[0]+P_121101000*R_330[0]+P_221001000*R_420[0]+-1*P_221101000*R_430[0]+-1*P_321001000*R_520[0]+P_321101000*R_530[0]; double PR_020002000220=P_020002000*R_220[0]+-1*P_020102000*R_230[0]+P_020202000*R_240[0]+-1*P_120002000*R_320[0]+P_120102000*R_330[0]+-1*P_120202000*R_340[0]+P_220002000*R_420[0]+-1*P_220102000*R_430[0]+P_220202000*R_440[0]; double PR_021000001220=P_021000001*R_220[0]+-1*P_021000101*R_221[0]+-1*P_121000001*R_320[0]+P_121000101*R_321[0]+P_221000001*R_420[0]+-1*P_221000101*R_421[0]+-1*P_321000001*R_520[0]+P_321000101*R_521[0]; double PR_020001001220=P_020001001*R_220[0]+-1*P_020001101*R_221[0]+-1*P_020101001*R_230[0]+P_020101101*R_231[0]+-1*P_120001001*R_320[0]+P_120001101*R_321[0]+P_120101001*R_330[0]+-1*P_120101101*R_331[0]+P_220001001*R_420[0]+-1*P_220001101*R_421[0]+-1*P_220101001*R_430[0]+P_220101101*R_431[0]; double PR_020000002220=P_020000002*R_220[0]+-1*P_020000102*R_221[0]+P_020000202*R_222[0]+-1*P_120000002*R_320[0]+P_120000102*R_321[0]+-1*P_120000202*R_322[0]+P_220000002*R_420[0]+-1*P_220000102*R_421[0]+P_220000202*R_422[0]; double PR_012010000220=P_012010000*R_220[0]+-1*P_012110000*R_230[0]+-1*P_112010000*R_320[0]+P_112110000*R_330[0]+P_212010000*R_420[0]+-1*P_212110000*R_430[0]+-1*P_312010000*R_520[0]+P_312110000*R_530[0]; double PR_011011000220=P_011011000*R_220[0]+-1*P_011111000*R_230[0]+P_011211000*R_240[0]+-1*P_111011000*R_320[0]+P_111111000*R_330[0]+-1*P_111211000*R_340[0]+P_211011000*R_420[0]+-1*P_211111000*R_430[0]+P_211211000*R_440[0]; double PR_010012000220=P_010012000*R_220[0]+-1*P_010112000*R_230[0]+P_010212000*R_240[0]+-1*P_010312000*R_250[0]+-1*P_110012000*R_320[0]+P_110112000*R_330[0]+-1*P_110212000*R_340[0]+P_110312000*R_350[0]; double PR_011010001220=P_011010001*R_220[0]+-1*P_011010101*R_221[0]+-1*P_011110001*R_230[0]+P_011110101*R_231[0]+-1*P_111010001*R_320[0]+P_111010101*R_321[0]+P_111110001*R_330[0]+-1*P_111110101*R_331[0]+P_211010001*R_420[0]+-1*P_211010101*R_421[0]+-1*P_211110001*R_430[0]+P_211110101*R_431[0]; double PR_010011001220=P_010011001*R_220[0]+-1*P_010011101*R_221[0]+-1*P_010111001*R_230[0]+P_010111101*R_231[0]+P_010211001*R_240[0]+-1*P_010211101*R_241[0]+-1*P_110011001*R_320[0]+P_110011101*R_321[0]+P_110111001*R_330[0]+-1*P_110111101*R_331[0]+-1*P_110211001*R_340[0]+P_110211101*R_341[0]; double PR_010010002220=P_010010002*R_220[0]+-1*P_010010102*R_221[0]+P_010010202*R_222[0]+-1*P_010110002*R_230[0]+P_010110102*R_231[0]+-1*P_010110202*R_232[0]+-1*P_110010002*R_320[0]+P_110010102*R_321[0]+-1*P_110010202*R_322[0]+P_110110002*R_330[0]+-1*P_110110102*R_331[0]+P_110110202*R_332[0]; double PR_002020000220=P_002020000*R_220[0]+-1*P_002120000*R_230[0]+P_002220000*R_240[0]+-1*P_102020000*R_320[0]+P_102120000*R_330[0]+-1*P_102220000*R_340[0]+P_202020000*R_420[0]+-1*P_202120000*R_430[0]+P_202220000*R_440[0]; double PR_001021000220=P_001021000*R_220[0]+-1*P_001121000*R_230[0]+P_001221000*R_240[0]+-1*P_001321000*R_250[0]+-1*P_101021000*R_320[0]+P_101121000*R_330[0]+-1*P_101221000*R_340[0]+P_101321000*R_350[0]; double PR_000022000220=P_000022000*R_220[0]+-1*P_000122000*R_230[0]+P_000222000*R_240[0]+-1*P_000322000*R_250[0]+P_000422000*R_260[0]; double PR_001020001220=P_001020001*R_220[0]+-1*P_001020101*R_221[0]+-1*P_001120001*R_230[0]+P_001120101*R_231[0]+P_001220001*R_240[0]+-1*P_001220101*R_241[0]+-1*P_101020001*R_320[0]+P_101020101*R_321[0]+P_101120001*R_330[0]+-1*P_101120101*R_331[0]+-1*P_101220001*R_340[0]+P_101220101*R_341[0]; double PR_000021001220=P_000021001*R_220[0]+-1*P_000021101*R_221[0]+-1*P_000121001*R_230[0]+P_000121101*R_231[0]+P_000221001*R_240[0]+-1*P_000221101*R_241[0]+-1*P_000321001*R_250[0]+P_000321101*R_251[0]; double PR_000020002220=P_000020002*R_220[0]+-1*P_000020102*R_221[0]+P_000020202*R_222[0]+-1*P_000120002*R_230[0]+P_000120102*R_231[0]+-1*P_000120202*R_232[0]+P_000220002*R_240[0]+-1*P_000220102*R_241[0]+P_000220202*R_242[0]; double PR_012000010220=P_012000010*R_220[0]+-1*P_012000110*R_221[0]+-1*P_112000010*R_320[0]+P_112000110*R_321[0]+P_212000010*R_420[0]+-1*P_212000110*R_421[0]+-1*P_312000010*R_520[0]+P_312000110*R_521[0]; double PR_011001010220=P_011001010*R_220[0]+-1*P_011001110*R_221[0]+-1*P_011101010*R_230[0]+P_011101110*R_231[0]+-1*P_111001010*R_320[0]+P_111001110*R_321[0]+P_111101010*R_330[0]+-1*P_111101110*R_331[0]+P_211001010*R_420[0]+-1*P_211001110*R_421[0]+-1*P_211101010*R_430[0]+P_211101110*R_431[0]; double PR_010002010220=P_010002010*R_220[0]+-1*P_010002110*R_221[0]+-1*P_010102010*R_230[0]+P_010102110*R_231[0]+P_010202010*R_240[0]+-1*P_010202110*R_241[0]+-1*P_110002010*R_320[0]+P_110002110*R_321[0]+P_110102010*R_330[0]+-1*P_110102110*R_331[0]+-1*P_110202010*R_340[0]+P_110202110*R_341[0]; double PR_011000011220=P_011000011*R_220[0]+-1*P_011000111*R_221[0]+P_011000211*R_222[0]+-1*P_111000011*R_320[0]+P_111000111*R_321[0]+-1*P_111000211*R_322[0]+P_211000011*R_420[0]+-1*P_211000111*R_421[0]+P_211000211*R_422[0]; double PR_010001011220=P_010001011*R_220[0]+-1*P_010001111*R_221[0]+P_010001211*R_222[0]+-1*P_010101011*R_230[0]+P_010101111*R_231[0]+-1*P_010101211*R_232[0]+-1*P_110001011*R_320[0]+P_110001111*R_321[0]+-1*P_110001211*R_322[0]+P_110101011*R_330[0]+-1*P_110101111*R_331[0]+P_110101211*R_332[0]; double PR_010000012220=P_010000012*R_220[0]+-1*P_010000112*R_221[0]+P_010000212*R_222[0]+-1*P_010000312*R_223[0]+-1*P_110000012*R_320[0]+P_110000112*R_321[0]+-1*P_110000212*R_322[0]+P_110000312*R_323[0]; double PR_002010010220=P_002010010*R_220[0]+-1*P_002010110*R_221[0]+-1*P_002110010*R_230[0]+P_002110110*R_231[0]+-1*P_102010010*R_320[0]+P_102010110*R_321[0]+P_102110010*R_330[0]+-1*P_102110110*R_331[0]+P_202010010*R_420[0]+-1*P_202010110*R_421[0]+-1*P_202110010*R_430[0]+P_202110110*R_431[0]; double PR_001011010220=P_001011010*R_220[0]+-1*P_001011110*R_221[0]+-1*P_001111010*R_230[0]+P_001111110*R_231[0]+P_001211010*R_240[0]+-1*P_001211110*R_241[0]+-1*P_101011010*R_320[0]+P_101011110*R_321[0]+P_101111010*R_330[0]+-1*P_101111110*R_331[0]+-1*P_101211010*R_340[0]+P_101211110*R_341[0]; double PR_000012010220=P_000012010*R_220[0]+-1*P_000012110*R_221[0]+-1*P_000112010*R_230[0]+P_000112110*R_231[0]+P_000212010*R_240[0]+-1*P_000212110*R_241[0]+-1*P_000312010*R_250[0]+P_000312110*R_251[0]; double PR_001010011220=P_001010011*R_220[0]+-1*P_001010111*R_221[0]+P_001010211*R_222[0]+-1*P_001110011*R_230[0]+P_001110111*R_231[0]+-1*P_001110211*R_232[0]+-1*P_101010011*R_320[0]+P_101010111*R_321[0]+-1*P_101010211*R_322[0]+P_101110011*R_330[0]+-1*P_101110111*R_331[0]+P_101110211*R_332[0]; double PR_000011011220=P_000011011*R_220[0]+-1*P_000011111*R_221[0]+P_000011211*R_222[0]+-1*P_000111011*R_230[0]+P_000111111*R_231[0]+-1*P_000111211*R_232[0]+P_000211011*R_240[0]+-1*P_000211111*R_241[0]+P_000211211*R_242[0]; double PR_000010012220=P_000010012*R_220[0]+-1*P_000010112*R_221[0]+P_000010212*R_222[0]+-1*P_000010312*R_223[0]+-1*P_000110012*R_230[0]+P_000110112*R_231[0]+-1*P_000110212*R_232[0]+P_000110312*R_233[0]; double PR_002000020220=P_002000020*R_220[0]+-1*P_002000120*R_221[0]+P_002000220*R_222[0]+-1*P_102000020*R_320[0]+P_102000120*R_321[0]+-1*P_102000220*R_322[0]+P_202000020*R_420[0]+-1*P_202000120*R_421[0]+P_202000220*R_422[0]; double PR_001001020220=P_001001020*R_220[0]+-1*P_001001120*R_221[0]+P_001001220*R_222[0]+-1*P_001101020*R_230[0]+P_001101120*R_231[0]+-1*P_001101220*R_232[0]+-1*P_101001020*R_320[0]+P_101001120*R_321[0]+-1*P_101001220*R_322[0]+P_101101020*R_330[0]+-1*P_101101120*R_331[0]+P_101101220*R_332[0]; double PR_000002020220=P_000002020*R_220[0]+-1*P_000002120*R_221[0]+P_000002220*R_222[0]+-1*P_000102020*R_230[0]+P_000102120*R_231[0]+-1*P_000102220*R_232[0]+P_000202020*R_240[0]+-1*P_000202120*R_241[0]+P_000202220*R_242[0]; double PR_001000021220=P_001000021*R_220[0]+-1*P_001000121*R_221[0]+P_001000221*R_222[0]+-1*P_001000321*R_223[0]+-1*P_101000021*R_320[0]+P_101000121*R_321[0]+-1*P_101000221*R_322[0]+P_101000321*R_323[0]; double PR_000001021220=P_000001021*R_220[0]+-1*P_000001121*R_221[0]+P_000001221*R_222[0]+-1*P_000001321*R_223[0]+-1*P_000101021*R_230[0]+P_000101121*R_231[0]+-1*P_000101221*R_232[0]+P_000101321*R_233[0]; double PR_000000022220=P_000000022*R_220[0]+-1*P_000000122*R_221[0]+P_000000222*R_222[0]+-1*P_000000322*R_223[0]+P_000000422*R_224[0]; double PR_022000000301=P_022000000*R_301[0]+-1*P_122000000*R_401[0]+P_222000000*R_501[0]+-1*P_322000000*R_601[0]+P_422000000*R_701[0]; double PR_021001000301=P_021001000*R_301[0]+-1*P_021101000*R_311[0]+-1*P_121001000*R_401[0]+P_121101000*R_411[0]+P_221001000*R_501[0]+-1*P_221101000*R_511[0]+-1*P_321001000*R_601[0]+P_321101000*R_611[0]; double PR_020002000301=P_020002000*R_301[0]+-1*P_020102000*R_311[0]+P_020202000*R_321[0]+-1*P_120002000*R_401[0]+P_120102000*R_411[0]+-1*P_120202000*R_421[0]+P_220002000*R_501[0]+-1*P_220102000*R_511[0]+P_220202000*R_521[0]; double PR_021000001301=P_021000001*R_301[0]+-1*P_021000101*R_302[0]+-1*P_121000001*R_401[0]+P_121000101*R_402[0]+P_221000001*R_501[0]+-1*P_221000101*R_502[0]+-1*P_321000001*R_601[0]+P_321000101*R_602[0]; double PR_020001001301=P_020001001*R_301[0]+-1*P_020001101*R_302[0]+-1*P_020101001*R_311[0]+P_020101101*R_312[0]+-1*P_120001001*R_401[0]+P_120001101*R_402[0]+P_120101001*R_411[0]+-1*P_120101101*R_412[0]+P_220001001*R_501[0]+-1*P_220001101*R_502[0]+-1*P_220101001*R_511[0]+P_220101101*R_512[0]; double PR_020000002301=P_020000002*R_301[0]+-1*P_020000102*R_302[0]+P_020000202*R_303[0]+-1*P_120000002*R_401[0]+P_120000102*R_402[0]+-1*P_120000202*R_403[0]+P_220000002*R_501[0]+-1*P_220000102*R_502[0]+P_220000202*R_503[0]; double PR_012010000301=P_012010000*R_301[0]+-1*P_012110000*R_311[0]+-1*P_112010000*R_401[0]+P_112110000*R_411[0]+P_212010000*R_501[0]+-1*P_212110000*R_511[0]+-1*P_312010000*R_601[0]+P_312110000*R_611[0]; double PR_011011000301=P_011011000*R_301[0]+-1*P_011111000*R_311[0]+P_011211000*R_321[0]+-1*P_111011000*R_401[0]+P_111111000*R_411[0]+-1*P_111211000*R_421[0]+P_211011000*R_501[0]+-1*P_211111000*R_511[0]+P_211211000*R_521[0]; double PR_010012000301=P_010012000*R_301[0]+-1*P_010112000*R_311[0]+P_010212000*R_321[0]+-1*P_010312000*R_331[0]+-1*P_110012000*R_401[0]+P_110112000*R_411[0]+-1*P_110212000*R_421[0]+P_110312000*R_431[0]; double PR_011010001301=P_011010001*R_301[0]+-1*P_011010101*R_302[0]+-1*P_011110001*R_311[0]+P_011110101*R_312[0]+-1*P_111010001*R_401[0]+P_111010101*R_402[0]+P_111110001*R_411[0]+-1*P_111110101*R_412[0]+P_211010001*R_501[0]+-1*P_211010101*R_502[0]+-1*P_211110001*R_511[0]+P_211110101*R_512[0]; double PR_010011001301=P_010011001*R_301[0]+-1*P_010011101*R_302[0]+-1*P_010111001*R_311[0]+P_010111101*R_312[0]+P_010211001*R_321[0]+-1*P_010211101*R_322[0]+-1*P_110011001*R_401[0]+P_110011101*R_402[0]+P_110111001*R_411[0]+-1*P_110111101*R_412[0]+-1*P_110211001*R_421[0]+P_110211101*R_422[0]; double PR_010010002301=P_010010002*R_301[0]+-1*P_010010102*R_302[0]+P_010010202*R_303[0]+-1*P_010110002*R_311[0]+P_010110102*R_312[0]+-1*P_010110202*R_313[0]+-1*P_110010002*R_401[0]+P_110010102*R_402[0]+-1*P_110010202*R_403[0]+P_110110002*R_411[0]+-1*P_110110102*R_412[0]+P_110110202*R_413[0]; double PR_002020000301=P_002020000*R_301[0]+-1*P_002120000*R_311[0]+P_002220000*R_321[0]+-1*P_102020000*R_401[0]+P_102120000*R_411[0]+-1*P_102220000*R_421[0]+P_202020000*R_501[0]+-1*P_202120000*R_511[0]+P_202220000*R_521[0]; double PR_001021000301=P_001021000*R_301[0]+-1*P_001121000*R_311[0]+P_001221000*R_321[0]+-1*P_001321000*R_331[0]+-1*P_101021000*R_401[0]+P_101121000*R_411[0]+-1*P_101221000*R_421[0]+P_101321000*R_431[0]; double PR_000022000301=P_000022000*R_301[0]+-1*P_000122000*R_311[0]+P_000222000*R_321[0]+-1*P_000322000*R_331[0]+P_000422000*R_341[0]; double PR_001020001301=P_001020001*R_301[0]+-1*P_001020101*R_302[0]+-1*P_001120001*R_311[0]+P_001120101*R_312[0]+P_001220001*R_321[0]+-1*P_001220101*R_322[0]+-1*P_101020001*R_401[0]+P_101020101*R_402[0]+P_101120001*R_411[0]+-1*P_101120101*R_412[0]+-1*P_101220001*R_421[0]+P_101220101*R_422[0]; double PR_000021001301=P_000021001*R_301[0]+-1*P_000021101*R_302[0]+-1*P_000121001*R_311[0]+P_000121101*R_312[0]+P_000221001*R_321[0]+-1*P_000221101*R_322[0]+-1*P_000321001*R_331[0]+P_000321101*R_332[0]; double PR_000020002301=P_000020002*R_301[0]+-1*P_000020102*R_302[0]+P_000020202*R_303[0]+-1*P_000120002*R_311[0]+P_000120102*R_312[0]+-1*P_000120202*R_313[0]+P_000220002*R_321[0]+-1*P_000220102*R_322[0]+P_000220202*R_323[0]; double PR_012000010301=P_012000010*R_301[0]+-1*P_012000110*R_302[0]+-1*P_112000010*R_401[0]+P_112000110*R_402[0]+P_212000010*R_501[0]+-1*P_212000110*R_502[0]+-1*P_312000010*R_601[0]+P_312000110*R_602[0]; double PR_011001010301=P_011001010*R_301[0]+-1*P_011001110*R_302[0]+-1*P_011101010*R_311[0]+P_011101110*R_312[0]+-1*P_111001010*R_401[0]+P_111001110*R_402[0]+P_111101010*R_411[0]+-1*P_111101110*R_412[0]+P_211001010*R_501[0]+-1*P_211001110*R_502[0]+-1*P_211101010*R_511[0]+P_211101110*R_512[0]; double PR_010002010301=P_010002010*R_301[0]+-1*P_010002110*R_302[0]+-1*P_010102010*R_311[0]+P_010102110*R_312[0]+P_010202010*R_321[0]+-1*P_010202110*R_322[0]+-1*P_110002010*R_401[0]+P_110002110*R_402[0]+P_110102010*R_411[0]+-1*P_110102110*R_412[0]+-1*P_110202010*R_421[0]+P_110202110*R_422[0]; double PR_011000011301=P_011000011*R_301[0]+-1*P_011000111*R_302[0]+P_011000211*R_303[0]+-1*P_111000011*R_401[0]+P_111000111*R_402[0]+-1*P_111000211*R_403[0]+P_211000011*R_501[0]+-1*P_211000111*R_502[0]+P_211000211*R_503[0]; double PR_010001011301=P_010001011*R_301[0]+-1*P_010001111*R_302[0]+P_010001211*R_303[0]+-1*P_010101011*R_311[0]+P_010101111*R_312[0]+-1*P_010101211*R_313[0]+-1*P_110001011*R_401[0]+P_110001111*R_402[0]+-1*P_110001211*R_403[0]+P_110101011*R_411[0]+-1*P_110101111*R_412[0]+P_110101211*R_413[0]; double PR_010000012301=P_010000012*R_301[0]+-1*P_010000112*R_302[0]+P_010000212*R_303[0]+-1*P_010000312*R_304[0]+-1*P_110000012*R_401[0]+P_110000112*R_402[0]+-1*P_110000212*R_403[0]+P_110000312*R_404[0]; double PR_002010010301=P_002010010*R_301[0]+-1*P_002010110*R_302[0]+-1*P_002110010*R_311[0]+P_002110110*R_312[0]+-1*P_102010010*R_401[0]+P_102010110*R_402[0]+P_102110010*R_411[0]+-1*P_102110110*R_412[0]+P_202010010*R_501[0]+-1*P_202010110*R_502[0]+-1*P_202110010*R_511[0]+P_202110110*R_512[0]; double PR_001011010301=P_001011010*R_301[0]+-1*P_001011110*R_302[0]+-1*P_001111010*R_311[0]+P_001111110*R_312[0]+P_001211010*R_321[0]+-1*P_001211110*R_322[0]+-1*P_101011010*R_401[0]+P_101011110*R_402[0]+P_101111010*R_411[0]+-1*P_101111110*R_412[0]+-1*P_101211010*R_421[0]+P_101211110*R_422[0]; double PR_000012010301=P_000012010*R_301[0]+-1*P_000012110*R_302[0]+-1*P_000112010*R_311[0]+P_000112110*R_312[0]+P_000212010*R_321[0]+-1*P_000212110*R_322[0]+-1*P_000312010*R_331[0]+P_000312110*R_332[0]; double PR_001010011301=P_001010011*R_301[0]+-1*P_001010111*R_302[0]+P_001010211*R_303[0]+-1*P_001110011*R_311[0]+P_001110111*R_312[0]+-1*P_001110211*R_313[0]+-1*P_101010011*R_401[0]+P_101010111*R_402[0]+-1*P_101010211*R_403[0]+P_101110011*R_411[0]+-1*P_101110111*R_412[0]+P_101110211*R_413[0]; double PR_000011011301=P_000011011*R_301[0]+-1*P_000011111*R_302[0]+P_000011211*R_303[0]+-1*P_000111011*R_311[0]+P_000111111*R_312[0]+-1*P_000111211*R_313[0]+P_000211011*R_321[0]+-1*P_000211111*R_322[0]+P_000211211*R_323[0]; double PR_000010012301=P_000010012*R_301[0]+-1*P_000010112*R_302[0]+P_000010212*R_303[0]+-1*P_000010312*R_304[0]+-1*P_000110012*R_311[0]+P_000110112*R_312[0]+-1*P_000110212*R_313[0]+P_000110312*R_314[0]; double PR_002000020301=P_002000020*R_301[0]+-1*P_002000120*R_302[0]+P_002000220*R_303[0]+-1*P_102000020*R_401[0]+P_102000120*R_402[0]+-1*P_102000220*R_403[0]+P_202000020*R_501[0]+-1*P_202000120*R_502[0]+P_202000220*R_503[0]; double PR_001001020301=P_001001020*R_301[0]+-1*P_001001120*R_302[0]+P_001001220*R_303[0]+-1*P_001101020*R_311[0]+P_001101120*R_312[0]+-1*P_001101220*R_313[0]+-1*P_101001020*R_401[0]+P_101001120*R_402[0]+-1*P_101001220*R_403[0]+P_101101020*R_411[0]+-1*P_101101120*R_412[0]+P_101101220*R_413[0]; double PR_000002020301=P_000002020*R_301[0]+-1*P_000002120*R_302[0]+P_000002220*R_303[0]+-1*P_000102020*R_311[0]+P_000102120*R_312[0]+-1*P_000102220*R_313[0]+P_000202020*R_321[0]+-1*P_000202120*R_322[0]+P_000202220*R_323[0]; double PR_001000021301=P_001000021*R_301[0]+-1*P_001000121*R_302[0]+P_001000221*R_303[0]+-1*P_001000321*R_304[0]+-1*P_101000021*R_401[0]+P_101000121*R_402[0]+-1*P_101000221*R_403[0]+P_101000321*R_404[0]; double PR_000001021301=P_000001021*R_301[0]+-1*P_000001121*R_302[0]+P_000001221*R_303[0]+-1*P_000001321*R_304[0]+-1*P_000101021*R_311[0]+P_000101121*R_312[0]+-1*P_000101221*R_313[0]+P_000101321*R_314[0]; double PR_000000022301=P_000000022*R_301[0]+-1*P_000000122*R_302[0]+P_000000222*R_303[0]+-1*P_000000322*R_304[0]+P_000000422*R_305[0]; double PR_022000000310=P_022000000*R_310[0]+-1*P_122000000*R_410[0]+P_222000000*R_510[0]+-1*P_322000000*R_610[0]+P_422000000*R_710[0]; double PR_021001000310=P_021001000*R_310[0]+-1*P_021101000*R_320[0]+-1*P_121001000*R_410[0]+P_121101000*R_420[0]+P_221001000*R_510[0]+-1*P_221101000*R_520[0]+-1*P_321001000*R_610[0]+P_321101000*R_620[0]; double PR_020002000310=P_020002000*R_310[0]+-1*P_020102000*R_320[0]+P_020202000*R_330[0]+-1*P_120002000*R_410[0]+P_120102000*R_420[0]+-1*P_120202000*R_430[0]+P_220002000*R_510[0]+-1*P_220102000*R_520[0]+P_220202000*R_530[0]; double PR_021000001310=P_021000001*R_310[0]+-1*P_021000101*R_311[0]+-1*P_121000001*R_410[0]+P_121000101*R_411[0]+P_221000001*R_510[0]+-1*P_221000101*R_511[0]+-1*P_321000001*R_610[0]+P_321000101*R_611[0]; double PR_020001001310=P_020001001*R_310[0]+-1*P_020001101*R_311[0]+-1*P_020101001*R_320[0]+P_020101101*R_321[0]+-1*P_120001001*R_410[0]+P_120001101*R_411[0]+P_120101001*R_420[0]+-1*P_120101101*R_421[0]+P_220001001*R_510[0]+-1*P_220001101*R_511[0]+-1*P_220101001*R_520[0]+P_220101101*R_521[0]; double PR_020000002310=P_020000002*R_310[0]+-1*P_020000102*R_311[0]+P_020000202*R_312[0]+-1*P_120000002*R_410[0]+P_120000102*R_411[0]+-1*P_120000202*R_412[0]+P_220000002*R_510[0]+-1*P_220000102*R_511[0]+P_220000202*R_512[0]; double PR_012010000310=P_012010000*R_310[0]+-1*P_012110000*R_320[0]+-1*P_112010000*R_410[0]+P_112110000*R_420[0]+P_212010000*R_510[0]+-1*P_212110000*R_520[0]+-1*P_312010000*R_610[0]+P_312110000*R_620[0]; double PR_011011000310=P_011011000*R_310[0]+-1*P_011111000*R_320[0]+P_011211000*R_330[0]+-1*P_111011000*R_410[0]+P_111111000*R_420[0]+-1*P_111211000*R_430[0]+P_211011000*R_510[0]+-1*P_211111000*R_520[0]+P_211211000*R_530[0]; double PR_010012000310=P_010012000*R_310[0]+-1*P_010112000*R_320[0]+P_010212000*R_330[0]+-1*P_010312000*R_340[0]+-1*P_110012000*R_410[0]+P_110112000*R_420[0]+-1*P_110212000*R_430[0]+P_110312000*R_440[0]; double PR_011010001310=P_011010001*R_310[0]+-1*P_011010101*R_311[0]+-1*P_011110001*R_320[0]+P_011110101*R_321[0]+-1*P_111010001*R_410[0]+P_111010101*R_411[0]+P_111110001*R_420[0]+-1*P_111110101*R_421[0]+P_211010001*R_510[0]+-1*P_211010101*R_511[0]+-1*P_211110001*R_520[0]+P_211110101*R_521[0]; double PR_010011001310=P_010011001*R_310[0]+-1*P_010011101*R_311[0]+-1*P_010111001*R_320[0]+P_010111101*R_321[0]+P_010211001*R_330[0]+-1*P_010211101*R_331[0]+-1*P_110011001*R_410[0]+P_110011101*R_411[0]+P_110111001*R_420[0]+-1*P_110111101*R_421[0]+-1*P_110211001*R_430[0]+P_110211101*R_431[0]; double PR_010010002310=P_010010002*R_310[0]+-1*P_010010102*R_311[0]+P_010010202*R_312[0]+-1*P_010110002*R_320[0]+P_010110102*R_321[0]+-1*P_010110202*R_322[0]+-1*P_110010002*R_410[0]+P_110010102*R_411[0]+-1*P_110010202*R_412[0]+P_110110002*R_420[0]+-1*P_110110102*R_421[0]+P_110110202*R_422[0]; double PR_002020000310=P_002020000*R_310[0]+-1*P_002120000*R_320[0]+P_002220000*R_330[0]+-1*P_102020000*R_410[0]+P_102120000*R_420[0]+-1*P_102220000*R_430[0]+P_202020000*R_510[0]+-1*P_202120000*R_520[0]+P_202220000*R_530[0]; double PR_001021000310=P_001021000*R_310[0]+-1*P_001121000*R_320[0]+P_001221000*R_330[0]+-1*P_001321000*R_340[0]+-1*P_101021000*R_410[0]+P_101121000*R_420[0]+-1*P_101221000*R_430[0]+P_101321000*R_440[0]; double PR_000022000310=P_000022000*R_310[0]+-1*P_000122000*R_320[0]+P_000222000*R_330[0]+-1*P_000322000*R_340[0]+P_000422000*R_350[0]; double PR_001020001310=P_001020001*R_310[0]+-1*P_001020101*R_311[0]+-1*P_001120001*R_320[0]+P_001120101*R_321[0]+P_001220001*R_330[0]+-1*P_001220101*R_331[0]+-1*P_101020001*R_410[0]+P_101020101*R_411[0]+P_101120001*R_420[0]+-1*P_101120101*R_421[0]+-1*P_101220001*R_430[0]+P_101220101*R_431[0]; double PR_000021001310=P_000021001*R_310[0]+-1*P_000021101*R_311[0]+-1*P_000121001*R_320[0]+P_000121101*R_321[0]+P_000221001*R_330[0]+-1*P_000221101*R_331[0]+-1*P_000321001*R_340[0]+P_000321101*R_341[0]; double PR_000020002310=P_000020002*R_310[0]+-1*P_000020102*R_311[0]+P_000020202*R_312[0]+-1*P_000120002*R_320[0]+P_000120102*R_321[0]+-1*P_000120202*R_322[0]+P_000220002*R_330[0]+-1*P_000220102*R_331[0]+P_000220202*R_332[0]; double PR_012000010310=P_012000010*R_310[0]+-1*P_012000110*R_311[0]+-1*P_112000010*R_410[0]+P_112000110*R_411[0]+P_212000010*R_510[0]+-1*P_212000110*R_511[0]+-1*P_312000010*R_610[0]+P_312000110*R_611[0]; double PR_011001010310=P_011001010*R_310[0]+-1*P_011001110*R_311[0]+-1*P_011101010*R_320[0]+P_011101110*R_321[0]+-1*P_111001010*R_410[0]+P_111001110*R_411[0]+P_111101010*R_420[0]+-1*P_111101110*R_421[0]+P_211001010*R_510[0]+-1*P_211001110*R_511[0]+-1*P_211101010*R_520[0]+P_211101110*R_521[0]; double PR_010002010310=P_010002010*R_310[0]+-1*P_010002110*R_311[0]+-1*P_010102010*R_320[0]+P_010102110*R_321[0]+P_010202010*R_330[0]+-1*P_010202110*R_331[0]+-1*P_110002010*R_410[0]+P_110002110*R_411[0]+P_110102010*R_420[0]+-1*P_110102110*R_421[0]+-1*P_110202010*R_430[0]+P_110202110*R_431[0]; double PR_011000011310=P_011000011*R_310[0]+-1*P_011000111*R_311[0]+P_011000211*R_312[0]+-1*P_111000011*R_410[0]+P_111000111*R_411[0]+-1*P_111000211*R_412[0]+P_211000011*R_510[0]+-1*P_211000111*R_511[0]+P_211000211*R_512[0]; double PR_010001011310=P_010001011*R_310[0]+-1*P_010001111*R_311[0]+P_010001211*R_312[0]+-1*P_010101011*R_320[0]+P_010101111*R_321[0]+-1*P_010101211*R_322[0]+-1*P_110001011*R_410[0]+P_110001111*R_411[0]+-1*P_110001211*R_412[0]+P_110101011*R_420[0]+-1*P_110101111*R_421[0]+P_110101211*R_422[0]; double PR_010000012310=P_010000012*R_310[0]+-1*P_010000112*R_311[0]+P_010000212*R_312[0]+-1*P_010000312*R_313[0]+-1*P_110000012*R_410[0]+P_110000112*R_411[0]+-1*P_110000212*R_412[0]+P_110000312*R_413[0]; double PR_002010010310=P_002010010*R_310[0]+-1*P_002010110*R_311[0]+-1*P_002110010*R_320[0]+P_002110110*R_321[0]+-1*P_102010010*R_410[0]+P_102010110*R_411[0]+P_102110010*R_420[0]+-1*P_102110110*R_421[0]+P_202010010*R_510[0]+-1*P_202010110*R_511[0]+-1*P_202110010*R_520[0]+P_202110110*R_521[0]; double PR_001011010310=P_001011010*R_310[0]+-1*P_001011110*R_311[0]+-1*P_001111010*R_320[0]+P_001111110*R_321[0]+P_001211010*R_330[0]+-1*P_001211110*R_331[0]+-1*P_101011010*R_410[0]+P_101011110*R_411[0]+P_101111010*R_420[0]+-1*P_101111110*R_421[0]+-1*P_101211010*R_430[0]+P_101211110*R_431[0]; double PR_000012010310=P_000012010*R_310[0]+-1*P_000012110*R_311[0]+-1*P_000112010*R_320[0]+P_000112110*R_321[0]+P_000212010*R_330[0]+-1*P_000212110*R_331[0]+-1*P_000312010*R_340[0]+P_000312110*R_341[0]; double PR_001010011310=P_001010011*R_310[0]+-1*P_001010111*R_311[0]+P_001010211*R_312[0]+-1*P_001110011*R_320[0]+P_001110111*R_321[0]+-1*P_001110211*R_322[0]+-1*P_101010011*R_410[0]+P_101010111*R_411[0]+-1*P_101010211*R_412[0]+P_101110011*R_420[0]+-1*P_101110111*R_421[0]+P_101110211*R_422[0]; double PR_000011011310=P_000011011*R_310[0]+-1*P_000011111*R_311[0]+P_000011211*R_312[0]+-1*P_000111011*R_320[0]+P_000111111*R_321[0]+-1*P_000111211*R_322[0]+P_000211011*R_330[0]+-1*P_000211111*R_331[0]+P_000211211*R_332[0]; double PR_000010012310=P_000010012*R_310[0]+-1*P_000010112*R_311[0]+P_000010212*R_312[0]+-1*P_000010312*R_313[0]+-1*P_000110012*R_320[0]+P_000110112*R_321[0]+-1*P_000110212*R_322[0]+P_000110312*R_323[0]; double PR_002000020310=P_002000020*R_310[0]+-1*P_002000120*R_311[0]+P_002000220*R_312[0]+-1*P_102000020*R_410[0]+P_102000120*R_411[0]+-1*P_102000220*R_412[0]+P_202000020*R_510[0]+-1*P_202000120*R_511[0]+P_202000220*R_512[0]; double PR_001001020310=P_001001020*R_310[0]+-1*P_001001120*R_311[0]+P_001001220*R_312[0]+-1*P_001101020*R_320[0]+P_001101120*R_321[0]+-1*P_001101220*R_322[0]+-1*P_101001020*R_410[0]+P_101001120*R_411[0]+-1*P_101001220*R_412[0]+P_101101020*R_420[0]+-1*P_101101120*R_421[0]+P_101101220*R_422[0]; double PR_000002020310=P_000002020*R_310[0]+-1*P_000002120*R_311[0]+P_000002220*R_312[0]+-1*P_000102020*R_320[0]+P_000102120*R_321[0]+-1*P_000102220*R_322[0]+P_000202020*R_330[0]+-1*P_000202120*R_331[0]+P_000202220*R_332[0]; double PR_001000021310=P_001000021*R_310[0]+-1*P_001000121*R_311[0]+P_001000221*R_312[0]+-1*P_001000321*R_313[0]+-1*P_101000021*R_410[0]+P_101000121*R_411[0]+-1*P_101000221*R_412[0]+P_101000321*R_413[0]; double PR_000001021310=P_000001021*R_310[0]+-1*P_000001121*R_311[0]+P_000001221*R_312[0]+-1*P_000001321*R_313[0]+-1*P_000101021*R_320[0]+P_000101121*R_321[0]+-1*P_000101221*R_322[0]+P_000101321*R_323[0]; double PR_000000022310=P_000000022*R_310[0]+-1*P_000000122*R_311[0]+P_000000222*R_312[0]+-1*P_000000322*R_313[0]+P_000000422*R_314[0]; double PR_022000000400=P_022000000*R_400[0]+-1*P_122000000*R_500[0]+P_222000000*R_600[0]+-1*P_322000000*R_700[0]+P_422000000*R_800[0]; double PR_021001000400=P_021001000*R_400[0]+-1*P_021101000*R_410[0]+-1*P_121001000*R_500[0]+P_121101000*R_510[0]+P_221001000*R_600[0]+-1*P_221101000*R_610[0]+-1*P_321001000*R_700[0]+P_321101000*R_710[0]; double PR_020002000400=P_020002000*R_400[0]+-1*P_020102000*R_410[0]+P_020202000*R_420[0]+-1*P_120002000*R_500[0]+P_120102000*R_510[0]+-1*P_120202000*R_520[0]+P_220002000*R_600[0]+-1*P_220102000*R_610[0]+P_220202000*R_620[0]; double PR_021000001400=P_021000001*R_400[0]+-1*P_021000101*R_401[0]+-1*P_121000001*R_500[0]+P_121000101*R_501[0]+P_221000001*R_600[0]+-1*P_221000101*R_601[0]+-1*P_321000001*R_700[0]+P_321000101*R_701[0]; double PR_020001001400=P_020001001*R_400[0]+-1*P_020001101*R_401[0]+-1*P_020101001*R_410[0]+P_020101101*R_411[0]+-1*P_120001001*R_500[0]+P_120001101*R_501[0]+P_120101001*R_510[0]+-1*P_120101101*R_511[0]+P_220001001*R_600[0]+-1*P_220001101*R_601[0]+-1*P_220101001*R_610[0]+P_220101101*R_611[0]; double PR_020000002400=P_020000002*R_400[0]+-1*P_020000102*R_401[0]+P_020000202*R_402[0]+-1*P_120000002*R_500[0]+P_120000102*R_501[0]+-1*P_120000202*R_502[0]+P_220000002*R_600[0]+-1*P_220000102*R_601[0]+P_220000202*R_602[0]; double PR_012010000400=P_012010000*R_400[0]+-1*P_012110000*R_410[0]+-1*P_112010000*R_500[0]+P_112110000*R_510[0]+P_212010000*R_600[0]+-1*P_212110000*R_610[0]+-1*P_312010000*R_700[0]+P_312110000*R_710[0]; double PR_011011000400=P_011011000*R_400[0]+-1*P_011111000*R_410[0]+P_011211000*R_420[0]+-1*P_111011000*R_500[0]+P_111111000*R_510[0]+-1*P_111211000*R_520[0]+P_211011000*R_600[0]+-1*P_211111000*R_610[0]+P_211211000*R_620[0]; double PR_010012000400=P_010012000*R_400[0]+-1*P_010112000*R_410[0]+P_010212000*R_420[0]+-1*P_010312000*R_430[0]+-1*P_110012000*R_500[0]+P_110112000*R_510[0]+-1*P_110212000*R_520[0]+P_110312000*R_530[0]; double PR_011010001400=P_011010001*R_400[0]+-1*P_011010101*R_401[0]+-1*P_011110001*R_410[0]+P_011110101*R_411[0]+-1*P_111010001*R_500[0]+P_111010101*R_501[0]+P_111110001*R_510[0]+-1*P_111110101*R_511[0]+P_211010001*R_600[0]+-1*P_211010101*R_601[0]+-1*P_211110001*R_610[0]+P_211110101*R_611[0]; double PR_010011001400=P_010011001*R_400[0]+-1*P_010011101*R_401[0]+-1*P_010111001*R_410[0]+P_010111101*R_411[0]+P_010211001*R_420[0]+-1*P_010211101*R_421[0]+-1*P_110011001*R_500[0]+P_110011101*R_501[0]+P_110111001*R_510[0]+-1*P_110111101*R_511[0]+-1*P_110211001*R_520[0]+P_110211101*R_521[0]; double PR_010010002400=P_010010002*R_400[0]+-1*P_010010102*R_401[0]+P_010010202*R_402[0]+-1*P_010110002*R_410[0]+P_010110102*R_411[0]+-1*P_010110202*R_412[0]+-1*P_110010002*R_500[0]+P_110010102*R_501[0]+-1*P_110010202*R_502[0]+P_110110002*R_510[0]+-1*P_110110102*R_511[0]+P_110110202*R_512[0]; double PR_002020000400=P_002020000*R_400[0]+-1*P_002120000*R_410[0]+P_002220000*R_420[0]+-1*P_102020000*R_500[0]+P_102120000*R_510[0]+-1*P_102220000*R_520[0]+P_202020000*R_600[0]+-1*P_202120000*R_610[0]+P_202220000*R_620[0]; double PR_001021000400=P_001021000*R_400[0]+-1*P_001121000*R_410[0]+P_001221000*R_420[0]+-1*P_001321000*R_430[0]+-1*P_101021000*R_500[0]+P_101121000*R_510[0]+-1*P_101221000*R_520[0]+P_101321000*R_530[0]; double PR_000022000400=P_000022000*R_400[0]+-1*P_000122000*R_410[0]+P_000222000*R_420[0]+-1*P_000322000*R_430[0]+P_000422000*R_440[0]; double PR_001020001400=P_001020001*R_400[0]+-1*P_001020101*R_401[0]+-1*P_001120001*R_410[0]+P_001120101*R_411[0]+P_001220001*R_420[0]+-1*P_001220101*R_421[0]+-1*P_101020001*R_500[0]+P_101020101*R_501[0]+P_101120001*R_510[0]+-1*P_101120101*R_511[0]+-1*P_101220001*R_520[0]+P_101220101*R_521[0]; double PR_000021001400=P_000021001*R_400[0]+-1*P_000021101*R_401[0]+-1*P_000121001*R_410[0]+P_000121101*R_411[0]+P_000221001*R_420[0]+-1*P_000221101*R_421[0]+-1*P_000321001*R_430[0]+P_000321101*R_431[0]; double PR_000020002400=P_000020002*R_400[0]+-1*P_000020102*R_401[0]+P_000020202*R_402[0]+-1*P_000120002*R_410[0]+P_000120102*R_411[0]+-1*P_000120202*R_412[0]+P_000220002*R_420[0]+-1*P_000220102*R_421[0]+P_000220202*R_422[0]; double PR_012000010400=P_012000010*R_400[0]+-1*P_012000110*R_401[0]+-1*P_112000010*R_500[0]+P_112000110*R_501[0]+P_212000010*R_600[0]+-1*P_212000110*R_601[0]+-1*P_312000010*R_700[0]+P_312000110*R_701[0]; double PR_011001010400=P_011001010*R_400[0]+-1*P_011001110*R_401[0]+-1*P_011101010*R_410[0]+P_011101110*R_411[0]+-1*P_111001010*R_500[0]+P_111001110*R_501[0]+P_111101010*R_510[0]+-1*P_111101110*R_511[0]+P_211001010*R_600[0]+-1*P_211001110*R_601[0]+-1*P_211101010*R_610[0]+P_211101110*R_611[0]; double PR_010002010400=P_010002010*R_400[0]+-1*P_010002110*R_401[0]+-1*P_010102010*R_410[0]+P_010102110*R_411[0]+P_010202010*R_420[0]+-1*P_010202110*R_421[0]+-1*P_110002010*R_500[0]+P_110002110*R_501[0]+P_110102010*R_510[0]+-1*P_110102110*R_511[0]+-1*P_110202010*R_520[0]+P_110202110*R_521[0]; double PR_011000011400=P_011000011*R_400[0]+-1*P_011000111*R_401[0]+P_011000211*R_402[0]+-1*P_111000011*R_500[0]+P_111000111*R_501[0]+-1*P_111000211*R_502[0]+P_211000011*R_600[0]+-1*P_211000111*R_601[0]+P_211000211*R_602[0]; double PR_010001011400=P_010001011*R_400[0]+-1*P_010001111*R_401[0]+P_010001211*R_402[0]+-1*P_010101011*R_410[0]+P_010101111*R_411[0]+-1*P_010101211*R_412[0]+-1*P_110001011*R_500[0]+P_110001111*R_501[0]+-1*P_110001211*R_502[0]+P_110101011*R_510[0]+-1*P_110101111*R_511[0]+P_110101211*R_512[0]; double PR_010000012400=P_010000012*R_400[0]+-1*P_010000112*R_401[0]+P_010000212*R_402[0]+-1*P_010000312*R_403[0]+-1*P_110000012*R_500[0]+P_110000112*R_501[0]+-1*P_110000212*R_502[0]+P_110000312*R_503[0]; double PR_002010010400=P_002010010*R_400[0]+-1*P_002010110*R_401[0]+-1*P_002110010*R_410[0]+P_002110110*R_411[0]+-1*P_102010010*R_500[0]+P_102010110*R_501[0]+P_102110010*R_510[0]+-1*P_102110110*R_511[0]+P_202010010*R_600[0]+-1*P_202010110*R_601[0]+-1*P_202110010*R_610[0]+P_202110110*R_611[0]; double PR_001011010400=P_001011010*R_400[0]+-1*P_001011110*R_401[0]+-1*P_001111010*R_410[0]+P_001111110*R_411[0]+P_001211010*R_420[0]+-1*P_001211110*R_421[0]+-1*P_101011010*R_500[0]+P_101011110*R_501[0]+P_101111010*R_510[0]+-1*P_101111110*R_511[0]+-1*P_101211010*R_520[0]+P_101211110*R_521[0]; double PR_000012010400=P_000012010*R_400[0]+-1*P_000012110*R_401[0]+-1*P_000112010*R_410[0]+P_000112110*R_411[0]+P_000212010*R_420[0]+-1*P_000212110*R_421[0]+-1*P_000312010*R_430[0]+P_000312110*R_431[0]; double PR_001010011400=P_001010011*R_400[0]+-1*P_001010111*R_401[0]+P_001010211*R_402[0]+-1*P_001110011*R_410[0]+P_001110111*R_411[0]+-1*P_001110211*R_412[0]+-1*P_101010011*R_500[0]+P_101010111*R_501[0]+-1*P_101010211*R_502[0]+P_101110011*R_510[0]+-1*P_101110111*R_511[0]+P_101110211*R_512[0]; double PR_000011011400=P_000011011*R_400[0]+-1*P_000011111*R_401[0]+P_000011211*R_402[0]+-1*P_000111011*R_410[0]+P_000111111*R_411[0]+-1*P_000111211*R_412[0]+P_000211011*R_420[0]+-1*P_000211111*R_421[0]+P_000211211*R_422[0]; double PR_000010012400=P_000010012*R_400[0]+-1*P_000010112*R_401[0]+P_000010212*R_402[0]+-1*P_000010312*R_403[0]+-1*P_000110012*R_410[0]+P_000110112*R_411[0]+-1*P_000110212*R_412[0]+P_000110312*R_413[0]; double PR_002000020400=P_002000020*R_400[0]+-1*P_002000120*R_401[0]+P_002000220*R_402[0]+-1*P_102000020*R_500[0]+P_102000120*R_501[0]+-1*P_102000220*R_502[0]+P_202000020*R_600[0]+-1*P_202000120*R_601[0]+P_202000220*R_602[0]; double PR_001001020400=P_001001020*R_400[0]+-1*P_001001120*R_401[0]+P_001001220*R_402[0]+-1*P_001101020*R_410[0]+P_001101120*R_411[0]+-1*P_001101220*R_412[0]+-1*P_101001020*R_500[0]+P_101001120*R_501[0]+-1*P_101001220*R_502[0]+P_101101020*R_510[0]+-1*P_101101120*R_511[0]+P_101101220*R_512[0]; double PR_000002020400=P_000002020*R_400[0]+-1*P_000002120*R_401[0]+P_000002220*R_402[0]+-1*P_000102020*R_410[0]+P_000102120*R_411[0]+-1*P_000102220*R_412[0]+P_000202020*R_420[0]+-1*P_000202120*R_421[0]+P_000202220*R_422[0]; double PR_001000021400=P_001000021*R_400[0]+-1*P_001000121*R_401[0]+P_001000221*R_402[0]+-1*P_001000321*R_403[0]+-1*P_101000021*R_500[0]+P_101000121*R_501[0]+-1*P_101000221*R_502[0]+P_101000321*R_503[0]; double PR_000001021400=P_000001021*R_400[0]+-1*P_000001121*R_401[0]+P_000001221*R_402[0]+-1*P_000001321*R_403[0]+-1*P_000101021*R_410[0]+P_000101121*R_411[0]+-1*P_000101221*R_412[0]+P_000101321*R_413[0]; double PR_000000022400=P_000000022*R_400[0]+-1*P_000000122*R_401[0]+P_000000222*R_402[0]+-1*P_000000322*R_403[0]+P_000000422*R_404[0]; double Qd_101[3]; double Qd_002[3]; double Qd_102[3]; double Qd_202[3]; double Qd_110[3]; double Qd_011[3]; double Qd_111[3]; double Qd_211[3]; double Qd_012[3]; double Qd_112[3]; double Qd_212[3]; double Qd_312[3]; double Qd_020[3]; double Qd_120[3]; double Qd_220[3]; double Qd_021[3]; double Qd_121[3]; double Qd_221[3]; double Qd_321[3]; double Qd_022[3]; double Qd_122[3]; double Qd_222[3]; double Qd_322[3]; double Qd_422[3]; for(int i=0;i<3;i++){ Qd_101[i]=aQin1; } for(int i=0;i<3;i++){ Qd_002[i]=Qd_101[i]+Qd_001[i]*Qd_001[i]; } for(int i=0;i<3;i++){ Qd_102[i]=Qd_001[i]*Qd_101[i]+aQin1*Qd_001[i]; } for(int i=0;i<3;i++){ Qd_202[i]=aQin1*Qd_101[i]; } for(int i=0;i<3;i++){ Qd_110[i]=aQin1; } for(int i=0;i<3;i++){ Qd_011[i]=Qd_101[i]+Qd_010[i]*Qd_001[i]; } for(int i=0;i<3;i++){ Qd_111[i]=Qd_010[i]*Qd_101[i]+aQin1*Qd_001[i]; } for(int i=0;i<3;i++){ Qd_211[i]=aQin1*Qd_101[i]; } for(int i=0;i<3;i++){ Qd_012[i]=Qd_111[i]+Qd_001[i]*Qd_011[i]; } for(int i=0;i<3;i++){ Qd_112[i]=2*Qd_211[i]+Qd_001[i]*Qd_111[i]+aQin1*Qd_011[i]; } for(int i=0;i<3;i++){ Qd_212[i]=Qd_001[i]*Qd_211[i]+aQin1*Qd_111[i]; } for(int i=0;i<3;i++){ Qd_312[i]=aQin1*Qd_211[i]; } for(int i=0;i<3;i++){ Qd_020[i]=Qd_110[i]+Qd_010[i]*Qd_010[i]; } for(int i=0;i<3;i++){ Qd_120[i]=Qd_010[i]*Qd_110[i]+aQin1*Qd_010[i]; } for(int i=0;i<3;i++){ Qd_220[i]=aQin1*Qd_110[i]; } for(int i=0;i<3;i++){ Qd_021[i]=Qd_111[i]+Qd_010[i]*Qd_011[i]; } for(int i=0;i<3;i++){ Qd_121[i]=2*Qd_211[i]+Qd_010[i]*Qd_111[i]+aQin1*Qd_011[i]; } for(int i=0;i<3;i++){ Qd_221[i]=Qd_010[i]*Qd_211[i]+aQin1*Qd_111[i]; } for(int i=0;i<3;i++){ Qd_321[i]=aQin1*Qd_211[i]; } for(int i=0;i<3;i++){ Qd_022[i]=Qd_112[i]+Qd_010[i]*Qd_012[i]; } for(int i=0;i<3;i++){ Qd_122[i]=2*Qd_212[i]+Qd_010[i]*Qd_112[i]+aQin1*Qd_012[i]; } for(int i=0;i<3;i++){ Qd_222[i]=3*Qd_312[i]+Qd_010[i]*Qd_212[i]+aQin1*Qd_112[i]; } for(int i=0;i<3;i++){ Qd_322[i]=Qd_010[i]*Qd_312[i]+aQin1*Qd_212[i]; } for(int i=0;i<3;i++){ Qd_422[i]=aQin1*Qd_312[i]; } double Q_022000000=Qd_022[0]; double Q_122000000=Qd_122[0]; double Q_222000000=Qd_222[0]; double Q_322000000=Qd_322[0]; double Q_422000000=Qd_422[0]; double Q_021001000=Qd_021[0]*Qd_001[1]; double Q_021101000=Qd_021[0]*Qd_101[1]; double Q_121001000=Qd_121[0]*Qd_001[1]; double Q_121101000=Qd_121[0]*Qd_101[1]; double Q_221001000=Qd_221[0]*Qd_001[1]; double Q_221101000=Qd_221[0]*Qd_101[1]; double Q_321001000=Qd_321[0]*Qd_001[1]; double Q_321101000=Qd_321[0]*Qd_101[1]; double Q_020002000=Qd_020[0]*Qd_002[1]; double Q_020102000=Qd_020[0]*Qd_102[1]; double Q_020202000=Qd_020[0]*Qd_202[1]; double Q_120002000=Qd_120[0]*Qd_002[1]; double Q_120102000=Qd_120[0]*Qd_102[1]; double Q_120202000=Qd_120[0]*Qd_202[1]; double Q_220002000=Qd_220[0]*Qd_002[1]; double Q_220102000=Qd_220[0]*Qd_102[1]; double Q_220202000=Qd_220[0]*Qd_202[1]; double Q_021000001=Qd_021[0]*Qd_001[2]; double Q_021000101=Qd_021[0]*Qd_101[2]; double Q_121000001=Qd_121[0]*Qd_001[2]; double Q_121000101=Qd_121[0]*Qd_101[2]; double Q_221000001=Qd_221[0]*Qd_001[2]; double Q_221000101=Qd_221[0]*Qd_101[2]; double Q_321000001=Qd_321[0]*Qd_001[2]; double Q_321000101=Qd_321[0]*Qd_101[2]; double Q_020001001=Qd_020[0]*Qd_001[1]*Qd_001[2]; double Q_020001101=Qd_020[0]*Qd_001[1]*Qd_101[2]; double Q_020101001=Qd_020[0]*Qd_101[1]*Qd_001[2]; double Q_020101101=Qd_020[0]*Qd_101[1]*Qd_101[2]; double Q_120001001=Qd_120[0]*Qd_001[1]*Qd_001[2]; double Q_120001101=Qd_120[0]*Qd_001[1]*Qd_101[2]; double Q_120101001=Qd_120[0]*Qd_101[1]*Qd_001[2]; double Q_120101101=Qd_120[0]*Qd_101[1]*Qd_101[2]; double Q_220001001=Qd_220[0]*Qd_001[1]*Qd_001[2]; double Q_220001101=Qd_220[0]*Qd_001[1]*Qd_101[2]; double Q_220101001=Qd_220[0]*Qd_101[1]*Qd_001[2]; double Q_220101101=Qd_220[0]*Qd_101[1]*Qd_101[2]; double Q_020000002=Qd_020[0]*Qd_002[2]; double Q_020000102=Qd_020[0]*Qd_102[2]; double Q_020000202=Qd_020[0]*Qd_202[2]; double Q_120000002=Qd_120[0]*Qd_002[2]; double Q_120000102=Qd_120[0]*Qd_102[2]; double Q_120000202=Qd_120[0]*Qd_202[2]; double Q_220000002=Qd_220[0]*Qd_002[2]; double Q_220000102=Qd_220[0]*Qd_102[2]; double Q_220000202=Qd_220[0]*Qd_202[2]; double Q_012010000=Qd_012[0]*Qd_010[1]; double Q_012110000=Qd_012[0]*Qd_110[1]; double Q_112010000=Qd_112[0]*Qd_010[1]; double Q_112110000=Qd_112[0]*Qd_110[1]; double Q_212010000=Qd_212[0]*Qd_010[1]; double Q_212110000=Qd_212[0]*Qd_110[1]; double Q_312010000=Qd_312[0]*Qd_010[1]; double Q_312110000=Qd_312[0]*Qd_110[1]; double Q_011011000=Qd_011[0]*Qd_011[1]; double Q_011111000=Qd_011[0]*Qd_111[1]; double Q_011211000=Qd_011[0]*Qd_211[1]; double Q_111011000=Qd_111[0]*Qd_011[1]; double Q_111111000=Qd_111[0]*Qd_111[1]; double Q_111211000=Qd_111[0]*Qd_211[1]; double Q_211011000=Qd_211[0]*Qd_011[1]; double Q_211111000=Qd_211[0]*Qd_111[1]; double Q_211211000=Qd_211[0]*Qd_211[1]; double Q_010012000=Qd_010[0]*Qd_012[1]; double Q_010112000=Qd_010[0]*Qd_112[1]; double Q_010212000=Qd_010[0]*Qd_212[1]; double Q_010312000=Qd_010[0]*Qd_312[1]; double Q_110012000=Qd_110[0]*Qd_012[1]; double Q_110112000=Qd_110[0]*Qd_112[1]; double Q_110212000=Qd_110[0]*Qd_212[1]; double Q_110312000=Qd_110[0]*Qd_312[1]; double Q_011010001=Qd_011[0]*Qd_010[1]*Qd_001[2]; double Q_011010101=Qd_011[0]*Qd_010[1]*Qd_101[2]; double Q_011110001=Qd_011[0]*Qd_110[1]*Qd_001[2]; double Q_011110101=Qd_011[0]*Qd_110[1]*Qd_101[2]; double Q_111010001=Qd_111[0]*Qd_010[1]*Qd_001[2]; double Q_111010101=Qd_111[0]*Qd_010[1]*Qd_101[2]; double Q_111110001=Qd_111[0]*Qd_110[1]*Qd_001[2]; double Q_111110101=Qd_111[0]*Qd_110[1]*Qd_101[2]; double Q_211010001=Qd_211[0]*Qd_010[1]*Qd_001[2]; double Q_211010101=Qd_211[0]*Qd_010[1]*Qd_101[2]; double Q_211110001=Qd_211[0]*Qd_110[1]*Qd_001[2]; double Q_211110101=Qd_211[0]*Qd_110[1]*Qd_101[2]; double Q_010011001=Qd_010[0]*Qd_011[1]*Qd_001[2]; double Q_010011101=Qd_010[0]*Qd_011[1]*Qd_101[2]; double Q_010111001=Qd_010[0]*Qd_111[1]*Qd_001[2]; double Q_010111101=Qd_010[0]*Qd_111[1]*Qd_101[2]; double Q_010211001=Qd_010[0]*Qd_211[1]*Qd_001[2]; double Q_010211101=Qd_010[0]*Qd_211[1]*Qd_101[2]; double Q_110011001=Qd_110[0]*Qd_011[1]*Qd_001[2]; double Q_110011101=Qd_110[0]*Qd_011[1]*Qd_101[2]; double Q_110111001=Qd_110[0]*Qd_111[1]*Qd_001[2]; double Q_110111101=Qd_110[0]*Qd_111[1]*Qd_101[2]; double Q_110211001=Qd_110[0]*Qd_211[1]*Qd_001[2]; double Q_110211101=Qd_110[0]*Qd_211[1]*Qd_101[2]; double Q_010010002=Qd_010[0]*Qd_010[1]*Qd_002[2]; double Q_010010102=Qd_010[0]*Qd_010[1]*Qd_102[2]; double Q_010010202=Qd_010[0]*Qd_010[1]*Qd_202[2]; double Q_010110002=Qd_010[0]*Qd_110[1]*Qd_002[2]; double Q_010110102=Qd_010[0]*Qd_110[1]*Qd_102[2]; double Q_010110202=Qd_010[0]*Qd_110[1]*Qd_202[2]; double Q_110010002=Qd_110[0]*Qd_010[1]*Qd_002[2]; double Q_110010102=Qd_110[0]*Qd_010[1]*Qd_102[2]; double Q_110010202=Qd_110[0]*Qd_010[1]*Qd_202[2]; double Q_110110002=Qd_110[0]*Qd_110[1]*Qd_002[2]; double Q_110110102=Qd_110[0]*Qd_110[1]*Qd_102[2]; double Q_110110202=Qd_110[0]*Qd_110[1]*Qd_202[2]; double Q_002020000=Qd_002[0]*Qd_020[1]; double Q_002120000=Qd_002[0]*Qd_120[1]; double Q_002220000=Qd_002[0]*Qd_220[1]; double Q_102020000=Qd_102[0]*Qd_020[1]; double Q_102120000=Qd_102[0]*Qd_120[1]; double Q_102220000=Qd_102[0]*Qd_220[1]; double Q_202020000=Qd_202[0]*Qd_020[1]; double Q_202120000=Qd_202[0]*Qd_120[1]; double Q_202220000=Qd_202[0]*Qd_220[1]; double Q_001021000=Qd_001[0]*Qd_021[1]; double Q_001121000=Qd_001[0]*Qd_121[1]; double Q_001221000=Qd_001[0]*Qd_221[1]; double Q_001321000=Qd_001[0]*Qd_321[1]; double Q_101021000=Qd_101[0]*Qd_021[1]; double Q_101121000=Qd_101[0]*Qd_121[1]; double Q_101221000=Qd_101[0]*Qd_221[1]; double Q_101321000=Qd_101[0]*Qd_321[1]; double Q_000022000=Qd_022[1]; double Q_000122000=Qd_122[1]; double Q_000222000=Qd_222[1]; double Q_000322000=Qd_322[1]; double Q_000422000=Qd_422[1]; double Q_001020001=Qd_001[0]*Qd_020[1]*Qd_001[2]; double Q_001020101=Qd_001[0]*Qd_020[1]*Qd_101[2]; double Q_001120001=Qd_001[0]*Qd_120[1]*Qd_001[2]; double Q_001120101=Qd_001[0]*Qd_120[1]*Qd_101[2]; double Q_001220001=Qd_001[0]*Qd_220[1]*Qd_001[2]; double Q_001220101=Qd_001[0]*Qd_220[1]*Qd_101[2]; double Q_101020001=Qd_101[0]*Qd_020[1]*Qd_001[2]; double Q_101020101=Qd_101[0]*Qd_020[1]*Qd_101[2]; double Q_101120001=Qd_101[0]*Qd_120[1]*Qd_001[2]; double Q_101120101=Qd_101[0]*Qd_120[1]*Qd_101[2]; double Q_101220001=Qd_101[0]*Qd_220[1]*Qd_001[2]; double Q_101220101=Qd_101[0]*Qd_220[1]*Qd_101[2]; double Q_000021001=Qd_021[1]*Qd_001[2]; double Q_000021101=Qd_021[1]*Qd_101[2]; double Q_000121001=Qd_121[1]*Qd_001[2]; double Q_000121101=Qd_121[1]*Qd_101[2]; double Q_000221001=Qd_221[1]*Qd_001[2]; double Q_000221101=Qd_221[1]*Qd_101[2]; double Q_000321001=Qd_321[1]*Qd_001[2]; double Q_000321101=Qd_321[1]*Qd_101[2]; double Q_000020002=Qd_020[1]*Qd_002[2]; double Q_000020102=Qd_020[1]*Qd_102[2]; double Q_000020202=Qd_020[1]*Qd_202[2]; double Q_000120002=Qd_120[1]*Qd_002[2]; double Q_000120102=Qd_120[1]*Qd_102[2]; double Q_000120202=Qd_120[1]*Qd_202[2]; double Q_000220002=Qd_220[1]*Qd_002[2]; double Q_000220102=Qd_220[1]*Qd_102[2]; double Q_000220202=Qd_220[1]*Qd_202[2]; double Q_012000010=Qd_012[0]*Qd_010[2]; double Q_012000110=Qd_012[0]*Qd_110[2]; double Q_112000010=Qd_112[0]*Qd_010[2]; double Q_112000110=Qd_112[0]*Qd_110[2]; double Q_212000010=Qd_212[0]*Qd_010[2]; double Q_212000110=Qd_212[0]*Qd_110[2]; double Q_312000010=Qd_312[0]*Qd_010[2]; double Q_312000110=Qd_312[0]*Qd_110[2]; double Q_011001010=Qd_011[0]*Qd_001[1]*Qd_010[2]; double Q_011001110=Qd_011[0]*Qd_001[1]*Qd_110[2]; double Q_011101010=Qd_011[0]*Qd_101[1]*Qd_010[2]; double Q_011101110=Qd_011[0]*Qd_101[1]*Qd_110[2]; double Q_111001010=Qd_111[0]*Qd_001[1]*Qd_010[2]; double Q_111001110=Qd_111[0]*Qd_001[1]*Qd_110[2]; double Q_111101010=Qd_111[0]*Qd_101[1]*Qd_010[2]; double Q_111101110=Qd_111[0]*Qd_101[1]*Qd_110[2]; double Q_211001010=Qd_211[0]*Qd_001[1]*Qd_010[2]; double Q_211001110=Qd_211[0]*Qd_001[1]*Qd_110[2]; double Q_211101010=Qd_211[0]*Qd_101[1]*Qd_010[2]; double Q_211101110=Qd_211[0]*Qd_101[1]*Qd_110[2]; double Q_010002010=Qd_010[0]*Qd_002[1]*Qd_010[2]; double Q_010002110=Qd_010[0]*Qd_002[1]*Qd_110[2]; double Q_010102010=Qd_010[0]*Qd_102[1]*Qd_010[2]; double Q_010102110=Qd_010[0]*Qd_102[1]*Qd_110[2]; double Q_010202010=Qd_010[0]*Qd_202[1]*Qd_010[2]; double Q_010202110=Qd_010[0]*Qd_202[1]*Qd_110[2]; double Q_110002010=Qd_110[0]*Qd_002[1]*Qd_010[2]; double Q_110002110=Qd_110[0]*Qd_002[1]*Qd_110[2]; double Q_110102010=Qd_110[0]*Qd_102[1]*Qd_010[2]; double Q_110102110=Qd_110[0]*Qd_102[1]*Qd_110[2]; double Q_110202010=Qd_110[0]*Qd_202[1]*Qd_010[2]; double Q_110202110=Qd_110[0]*Qd_202[1]*Qd_110[2]; double Q_011000011=Qd_011[0]*Qd_011[2]; double Q_011000111=Qd_011[0]*Qd_111[2]; double Q_011000211=Qd_011[0]*Qd_211[2]; double Q_111000011=Qd_111[0]*Qd_011[2]; double Q_111000111=Qd_111[0]*Qd_111[2]; double Q_111000211=Qd_111[0]*Qd_211[2]; double Q_211000011=Qd_211[0]*Qd_011[2]; double Q_211000111=Qd_211[0]*Qd_111[2]; double Q_211000211=Qd_211[0]*Qd_211[2]; double Q_010001011=Qd_010[0]*Qd_001[1]*Qd_011[2]; double Q_010001111=Qd_010[0]*Qd_001[1]*Qd_111[2]; double Q_010001211=Qd_010[0]*Qd_001[1]*Qd_211[2]; double Q_010101011=Qd_010[0]*Qd_101[1]*Qd_011[2]; double Q_010101111=Qd_010[0]*Qd_101[1]*Qd_111[2]; double Q_010101211=Qd_010[0]*Qd_101[1]*Qd_211[2]; double Q_110001011=Qd_110[0]*Qd_001[1]*Qd_011[2]; double Q_110001111=Qd_110[0]*Qd_001[1]*Qd_111[2]; double Q_110001211=Qd_110[0]*Qd_001[1]*Qd_211[2]; double Q_110101011=Qd_110[0]*Qd_101[1]*Qd_011[2]; double Q_110101111=Qd_110[0]*Qd_101[1]*Qd_111[2]; double Q_110101211=Qd_110[0]*Qd_101[1]*Qd_211[2]; double Q_010000012=Qd_010[0]*Qd_012[2]; double Q_010000112=Qd_010[0]*Qd_112[2]; double Q_010000212=Qd_010[0]*Qd_212[2]; double Q_010000312=Qd_010[0]*Qd_312[2]; double Q_110000012=Qd_110[0]*Qd_012[2]; double Q_110000112=Qd_110[0]*Qd_112[2]; double Q_110000212=Qd_110[0]*Qd_212[2]; double Q_110000312=Qd_110[0]*Qd_312[2]; double Q_002010010=Qd_002[0]*Qd_010[1]*Qd_010[2]; double Q_002010110=Qd_002[0]*Qd_010[1]*Qd_110[2]; double Q_002110010=Qd_002[0]*Qd_110[1]*Qd_010[2]; double Q_002110110=Qd_002[0]*Qd_110[1]*Qd_110[2]; double Q_102010010=Qd_102[0]*Qd_010[1]*Qd_010[2]; double Q_102010110=Qd_102[0]*Qd_010[1]*Qd_110[2]; double Q_102110010=Qd_102[0]*Qd_110[1]*Qd_010[2]; double Q_102110110=Qd_102[0]*Qd_110[1]*Qd_110[2]; double Q_202010010=Qd_202[0]*Qd_010[1]*Qd_010[2]; double Q_202010110=Qd_202[0]*Qd_010[1]*Qd_110[2]; double Q_202110010=Qd_202[0]*Qd_110[1]*Qd_010[2]; double Q_202110110=Qd_202[0]*Qd_110[1]*Qd_110[2]; double Q_001011010=Qd_001[0]*Qd_011[1]*Qd_010[2]; double Q_001011110=Qd_001[0]*Qd_011[1]*Qd_110[2]; double Q_001111010=Qd_001[0]*Qd_111[1]*Qd_010[2]; double Q_001111110=Qd_001[0]*Qd_111[1]*Qd_110[2]; double Q_001211010=Qd_001[0]*Qd_211[1]*Qd_010[2]; double Q_001211110=Qd_001[0]*Qd_211[1]*Qd_110[2]; double Q_101011010=Qd_101[0]*Qd_011[1]*Qd_010[2]; double Q_101011110=Qd_101[0]*Qd_011[1]*Qd_110[2]; double Q_101111010=Qd_101[0]*Qd_111[1]*Qd_010[2]; double Q_101111110=Qd_101[0]*Qd_111[1]*Qd_110[2]; double Q_101211010=Qd_101[0]*Qd_211[1]*Qd_010[2]; double Q_101211110=Qd_101[0]*Qd_211[1]*Qd_110[2]; double Q_000012010=Qd_012[1]*Qd_010[2]; double Q_000012110=Qd_012[1]*Qd_110[2]; double Q_000112010=Qd_112[1]*Qd_010[2]; double Q_000112110=Qd_112[1]*Qd_110[2]; double Q_000212010=Qd_212[1]*Qd_010[2]; double Q_000212110=Qd_212[1]*Qd_110[2]; double Q_000312010=Qd_312[1]*Qd_010[2]; double Q_000312110=Qd_312[1]*Qd_110[2]; double Q_001010011=Qd_001[0]*Qd_010[1]*Qd_011[2]; double Q_001010111=Qd_001[0]*Qd_010[1]*Qd_111[2]; double Q_001010211=Qd_001[0]*Qd_010[1]*Qd_211[2]; double Q_001110011=Qd_001[0]*Qd_110[1]*Qd_011[2]; double Q_001110111=Qd_001[0]*Qd_110[1]*Qd_111[2]; double Q_001110211=Qd_001[0]*Qd_110[1]*Qd_211[2]; double Q_101010011=Qd_101[0]*Qd_010[1]*Qd_011[2]; double Q_101010111=Qd_101[0]*Qd_010[1]*Qd_111[2]; double Q_101010211=Qd_101[0]*Qd_010[1]*Qd_211[2]; double Q_101110011=Qd_101[0]*Qd_110[1]*Qd_011[2]; double Q_101110111=Qd_101[0]*Qd_110[1]*Qd_111[2]; double Q_101110211=Qd_101[0]*Qd_110[1]*Qd_211[2]; double Q_000011011=Qd_011[1]*Qd_011[2]; double Q_000011111=Qd_011[1]*Qd_111[2]; double Q_000011211=Qd_011[1]*Qd_211[2]; double Q_000111011=Qd_111[1]*Qd_011[2]; double Q_000111111=Qd_111[1]*Qd_111[2]; double Q_000111211=Qd_111[1]*Qd_211[2]; double Q_000211011=Qd_211[1]*Qd_011[2]; double Q_000211111=Qd_211[1]*Qd_111[2]; double Q_000211211=Qd_211[1]*Qd_211[2]; double Q_000010012=Qd_010[1]*Qd_012[2]; double Q_000010112=Qd_010[1]*Qd_112[2]; double Q_000010212=Qd_010[1]*Qd_212[2]; double Q_000010312=Qd_010[1]*Qd_312[2]; double Q_000110012=Qd_110[1]*Qd_012[2]; double Q_000110112=Qd_110[1]*Qd_112[2]; double Q_000110212=Qd_110[1]*Qd_212[2]; double Q_000110312=Qd_110[1]*Qd_312[2]; double Q_002000020=Qd_002[0]*Qd_020[2]; double Q_002000120=Qd_002[0]*Qd_120[2]; double Q_002000220=Qd_002[0]*Qd_220[2]; double Q_102000020=Qd_102[0]*Qd_020[2]; double Q_102000120=Qd_102[0]*Qd_120[2]; double Q_102000220=Qd_102[0]*Qd_220[2]; double Q_202000020=Qd_202[0]*Qd_020[2]; double Q_202000120=Qd_202[0]*Qd_120[2]; double Q_202000220=Qd_202[0]*Qd_220[2]; double Q_001001020=Qd_001[0]*Qd_001[1]*Qd_020[2]; double Q_001001120=Qd_001[0]*Qd_001[1]*Qd_120[2]; double Q_001001220=Qd_001[0]*Qd_001[1]*Qd_220[2]; double Q_001101020=Qd_001[0]*Qd_101[1]*Qd_020[2]; double Q_001101120=Qd_001[0]*Qd_101[1]*Qd_120[2]; double Q_001101220=Qd_001[0]*Qd_101[1]*Qd_220[2]; double Q_101001020=Qd_101[0]*Qd_001[1]*Qd_020[2]; double Q_101001120=Qd_101[0]*Qd_001[1]*Qd_120[2]; double Q_101001220=Qd_101[0]*Qd_001[1]*Qd_220[2]; double Q_101101020=Qd_101[0]*Qd_101[1]*Qd_020[2]; double Q_101101120=Qd_101[0]*Qd_101[1]*Qd_120[2]; double Q_101101220=Qd_101[0]*Qd_101[1]*Qd_220[2]; double Q_000002020=Qd_002[1]*Qd_020[2]; double Q_000002120=Qd_002[1]*Qd_120[2]; double Q_000002220=Qd_002[1]*Qd_220[2]; double Q_000102020=Qd_102[1]*Qd_020[2]; double Q_000102120=Qd_102[1]*Qd_120[2]; double Q_000102220=Qd_102[1]*Qd_220[2]; double Q_000202020=Qd_202[1]*Qd_020[2]; double Q_000202120=Qd_202[1]*Qd_120[2]; double Q_000202220=Qd_202[1]*Qd_220[2]; double Q_001000021=Qd_001[0]*Qd_021[2]; double Q_001000121=Qd_001[0]*Qd_121[2]; double Q_001000221=Qd_001[0]*Qd_221[2]; double Q_001000321=Qd_001[0]*Qd_321[2]; double Q_101000021=Qd_101[0]*Qd_021[2]; double Q_101000121=Qd_101[0]*Qd_121[2]; double Q_101000221=Qd_101[0]*Qd_221[2]; double Q_101000321=Qd_101[0]*Qd_321[2]; double Q_000001021=Qd_001[1]*Qd_021[2]; double Q_000001121=Qd_001[1]*Qd_121[2]; double Q_000001221=Qd_001[1]*Qd_221[2]; double Q_000001321=Qd_001[1]*Qd_321[2]; double Q_000101021=Qd_101[1]*Qd_021[2]; double Q_000101121=Qd_101[1]*Qd_121[2]; double Q_000101221=Qd_101[1]*Qd_221[2]; double Q_000101321=Qd_101[1]*Qd_321[2]; double Q_000000022=Qd_022[2]; double Q_000000122=Qd_122[2]; double Q_000000222=Qd_222[2]; double Q_000000322=Qd_322[2]; double Q_000000422=Qd_422[2]; ans_temp[ans_id*36+0]+=Pmtrx[0]*(Q_022000000*PR_022000000000+Q_122000000*PR_022000000100+Q_222000000*PR_022000000200+Q_322000000*PR_022000000300+Q_422000000*PR_022000000400); ans_temp[ans_id*36+0]+=Pmtrx[1]*(Q_021001000*PR_022000000000+Q_021101000*PR_022000000010+Q_121001000*PR_022000000100+Q_121101000*PR_022000000110+Q_221001000*PR_022000000200+Q_221101000*PR_022000000210+Q_321001000*PR_022000000300+Q_321101000*PR_022000000310); ans_temp[ans_id*36+0]+=Pmtrx[2]*(Q_020002000*PR_022000000000+Q_020102000*PR_022000000010+Q_020202000*PR_022000000020+Q_120002000*PR_022000000100+Q_120102000*PR_022000000110+Q_120202000*PR_022000000120+Q_220002000*PR_022000000200+Q_220102000*PR_022000000210+Q_220202000*PR_022000000220); ans_temp[ans_id*36+0]+=Pmtrx[3]*(Q_021000001*PR_022000000000+Q_021000101*PR_022000000001+Q_121000001*PR_022000000100+Q_121000101*PR_022000000101+Q_221000001*PR_022000000200+Q_221000101*PR_022000000201+Q_321000001*PR_022000000300+Q_321000101*PR_022000000301); ans_temp[ans_id*36+0]+=Pmtrx[4]*(Q_020001001*PR_022000000000+Q_020001101*PR_022000000001+Q_020101001*PR_022000000010+Q_020101101*PR_022000000011+Q_120001001*PR_022000000100+Q_120001101*PR_022000000101+Q_120101001*PR_022000000110+Q_120101101*PR_022000000111+Q_220001001*PR_022000000200+Q_220001101*PR_022000000201+Q_220101001*PR_022000000210+Q_220101101*PR_022000000211); ans_temp[ans_id*36+0]+=Pmtrx[5]*(Q_020000002*PR_022000000000+Q_020000102*PR_022000000001+Q_020000202*PR_022000000002+Q_120000002*PR_022000000100+Q_120000102*PR_022000000101+Q_120000202*PR_022000000102+Q_220000002*PR_022000000200+Q_220000102*PR_022000000201+Q_220000202*PR_022000000202); ans_temp[ans_id*36+1]+=Pmtrx[0]*(Q_012010000*PR_022000000000+Q_012110000*PR_022000000010+Q_112010000*PR_022000000100+Q_112110000*PR_022000000110+Q_212010000*PR_022000000200+Q_212110000*PR_022000000210+Q_312010000*PR_022000000300+Q_312110000*PR_022000000310); ans_temp[ans_id*36+1]+=Pmtrx[1]*(Q_011011000*PR_022000000000+Q_011111000*PR_022000000010+Q_011211000*PR_022000000020+Q_111011000*PR_022000000100+Q_111111000*PR_022000000110+Q_111211000*PR_022000000120+Q_211011000*PR_022000000200+Q_211111000*PR_022000000210+Q_211211000*PR_022000000220); ans_temp[ans_id*36+1]+=Pmtrx[2]*(Q_010012000*PR_022000000000+Q_010112000*PR_022000000010+Q_010212000*PR_022000000020+Q_010312000*PR_022000000030+Q_110012000*PR_022000000100+Q_110112000*PR_022000000110+Q_110212000*PR_022000000120+Q_110312000*PR_022000000130); ans_temp[ans_id*36+1]+=Pmtrx[3]*(Q_011010001*PR_022000000000+Q_011010101*PR_022000000001+Q_011110001*PR_022000000010+Q_011110101*PR_022000000011+Q_111010001*PR_022000000100+Q_111010101*PR_022000000101+Q_111110001*PR_022000000110+Q_111110101*PR_022000000111+Q_211010001*PR_022000000200+Q_211010101*PR_022000000201+Q_211110001*PR_022000000210+Q_211110101*PR_022000000211); ans_temp[ans_id*36+1]+=Pmtrx[4]*(Q_010011001*PR_022000000000+Q_010011101*PR_022000000001+Q_010111001*PR_022000000010+Q_010111101*PR_022000000011+Q_010211001*PR_022000000020+Q_010211101*PR_022000000021+Q_110011001*PR_022000000100+Q_110011101*PR_022000000101+Q_110111001*PR_022000000110+Q_110111101*PR_022000000111+Q_110211001*PR_022000000120+Q_110211101*PR_022000000121); ans_temp[ans_id*36+1]+=Pmtrx[5]*(Q_010010002*PR_022000000000+Q_010010102*PR_022000000001+Q_010010202*PR_022000000002+Q_010110002*PR_022000000010+Q_010110102*PR_022000000011+Q_010110202*PR_022000000012+Q_110010002*PR_022000000100+Q_110010102*PR_022000000101+Q_110010202*PR_022000000102+Q_110110002*PR_022000000110+Q_110110102*PR_022000000111+Q_110110202*PR_022000000112); ans_temp[ans_id*36+2]+=Pmtrx[0]*(Q_002020000*PR_022000000000+Q_002120000*PR_022000000010+Q_002220000*PR_022000000020+Q_102020000*PR_022000000100+Q_102120000*PR_022000000110+Q_102220000*PR_022000000120+Q_202020000*PR_022000000200+Q_202120000*PR_022000000210+Q_202220000*PR_022000000220); ans_temp[ans_id*36+2]+=Pmtrx[1]*(Q_001021000*PR_022000000000+Q_001121000*PR_022000000010+Q_001221000*PR_022000000020+Q_001321000*PR_022000000030+Q_101021000*PR_022000000100+Q_101121000*PR_022000000110+Q_101221000*PR_022000000120+Q_101321000*PR_022000000130); ans_temp[ans_id*36+2]+=Pmtrx[2]*(Q_000022000*PR_022000000000+Q_000122000*PR_022000000010+Q_000222000*PR_022000000020+Q_000322000*PR_022000000030+Q_000422000*PR_022000000040); ans_temp[ans_id*36+2]+=Pmtrx[3]*(Q_001020001*PR_022000000000+Q_001020101*PR_022000000001+Q_001120001*PR_022000000010+Q_001120101*PR_022000000011+Q_001220001*PR_022000000020+Q_001220101*PR_022000000021+Q_101020001*PR_022000000100+Q_101020101*PR_022000000101+Q_101120001*PR_022000000110+Q_101120101*PR_022000000111+Q_101220001*PR_022000000120+Q_101220101*PR_022000000121); ans_temp[ans_id*36+2]+=Pmtrx[4]*(Q_000021001*PR_022000000000+Q_000021101*PR_022000000001+Q_000121001*PR_022000000010+Q_000121101*PR_022000000011+Q_000221001*PR_022000000020+Q_000221101*PR_022000000021+Q_000321001*PR_022000000030+Q_000321101*PR_022000000031); ans_temp[ans_id*36+2]+=Pmtrx[5]*(Q_000020002*PR_022000000000+Q_000020102*PR_022000000001+Q_000020202*PR_022000000002+Q_000120002*PR_022000000010+Q_000120102*PR_022000000011+Q_000120202*PR_022000000012+Q_000220002*PR_022000000020+Q_000220102*PR_022000000021+Q_000220202*PR_022000000022); ans_temp[ans_id*36+3]+=Pmtrx[0]*(Q_012000010*PR_022000000000+Q_012000110*PR_022000000001+Q_112000010*PR_022000000100+Q_112000110*PR_022000000101+Q_212000010*PR_022000000200+Q_212000110*PR_022000000201+Q_312000010*PR_022000000300+Q_312000110*PR_022000000301); ans_temp[ans_id*36+3]+=Pmtrx[1]*(Q_011001010*PR_022000000000+Q_011001110*PR_022000000001+Q_011101010*PR_022000000010+Q_011101110*PR_022000000011+Q_111001010*PR_022000000100+Q_111001110*PR_022000000101+Q_111101010*PR_022000000110+Q_111101110*PR_022000000111+Q_211001010*PR_022000000200+Q_211001110*PR_022000000201+Q_211101010*PR_022000000210+Q_211101110*PR_022000000211); ans_temp[ans_id*36+3]+=Pmtrx[2]*(Q_010002010*PR_022000000000+Q_010002110*PR_022000000001+Q_010102010*PR_022000000010+Q_010102110*PR_022000000011+Q_010202010*PR_022000000020+Q_010202110*PR_022000000021+Q_110002010*PR_022000000100+Q_110002110*PR_022000000101+Q_110102010*PR_022000000110+Q_110102110*PR_022000000111+Q_110202010*PR_022000000120+Q_110202110*PR_022000000121); ans_temp[ans_id*36+3]+=Pmtrx[3]*(Q_011000011*PR_022000000000+Q_011000111*PR_022000000001+Q_011000211*PR_022000000002+Q_111000011*PR_022000000100+Q_111000111*PR_022000000101+Q_111000211*PR_022000000102+Q_211000011*PR_022000000200+Q_211000111*PR_022000000201+Q_211000211*PR_022000000202); ans_temp[ans_id*36+3]+=Pmtrx[4]*(Q_010001011*PR_022000000000+Q_010001111*PR_022000000001+Q_010001211*PR_022000000002+Q_010101011*PR_022000000010+Q_010101111*PR_022000000011+Q_010101211*PR_022000000012+Q_110001011*PR_022000000100+Q_110001111*PR_022000000101+Q_110001211*PR_022000000102+Q_110101011*PR_022000000110+Q_110101111*PR_022000000111+Q_110101211*PR_022000000112); ans_temp[ans_id*36+3]+=Pmtrx[5]*(Q_010000012*PR_022000000000+Q_010000112*PR_022000000001+Q_010000212*PR_022000000002+Q_010000312*PR_022000000003+Q_110000012*PR_022000000100+Q_110000112*PR_022000000101+Q_110000212*PR_022000000102+Q_110000312*PR_022000000103); ans_temp[ans_id*36+4]+=Pmtrx[0]*(Q_002010010*PR_022000000000+Q_002010110*PR_022000000001+Q_002110010*PR_022000000010+Q_002110110*PR_022000000011+Q_102010010*PR_022000000100+Q_102010110*PR_022000000101+Q_102110010*PR_022000000110+Q_102110110*PR_022000000111+Q_202010010*PR_022000000200+Q_202010110*PR_022000000201+Q_202110010*PR_022000000210+Q_202110110*PR_022000000211); ans_temp[ans_id*36+4]+=Pmtrx[1]*(Q_001011010*PR_022000000000+Q_001011110*PR_022000000001+Q_001111010*PR_022000000010+Q_001111110*PR_022000000011+Q_001211010*PR_022000000020+Q_001211110*PR_022000000021+Q_101011010*PR_022000000100+Q_101011110*PR_022000000101+Q_101111010*PR_022000000110+Q_101111110*PR_022000000111+Q_101211010*PR_022000000120+Q_101211110*PR_022000000121); ans_temp[ans_id*36+4]+=Pmtrx[2]*(Q_000012010*PR_022000000000+Q_000012110*PR_022000000001+Q_000112010*PR_022000000010+Q_000112110*PR_022000000011+Q_000212010*PR_022000000020+Q_000212110*PR_022000000021+Q_000312010*PR_022000000030+Q_000312110*PR_022000000031); ans_temp[ans_id*36+4]+=Pmtrx[3]*(Q_001010011*PR_022000000000+Q_001010111*PR_022000000001+Q_001010211*PR_022000000002+Q_001110011*PR_022000000010+Q_001110111*PR_022000000011+Q_001110211*PR_022000000012+Q_101010011*PR_022000000100+Q_101010111*PR_022000000101+Q_101010211*PR_022000000102+Q_101110011*PR_022000000110+Q_101110111*PR_022000000111+Q_101110211*PR_022000000112); ans_temp[ans_id*36+4]+=Pmtrx[4]*(Q_000011011*PR_022000000000+Q_000011111*PR_022000000001+Q_000011211*PR_022000000002+Q_000111011*PR_022000000010+Q_000111111*PR_022000000011+Q_000111211*PR_022000000012+Q_000211011*PR_022000000020+Q_000211111*PR_022000000021+Q_000211211*PR_022000000022); ans_temp[ans_id*36+4]+=Pmtrx[5]*(Q_000010012*PR_022000000000+Q_000010112*PR_022000000001+Q_000010212*PR_022000000002+Q_000010312*PR_022000000003+Q_000110012*PR_022000000010+Q_000110112*PR_022000000011+Q_000110212*PR_022000000012+Q_000110312*PR_022000000013); ans_temp[ans_id*36+5]+=Pmtrx[0]*(Q_002000020*PR_022000000000+Q_002000120*PR_022000000001+Q_002000220*PR_022000000002+Q_102000020*PR_022000000100+Q_102000120*PR_022000000101+Q_102000220*PR_022000000102+Q_202000020*PR_022000000200+Q_202000120*PR_022000000201+Q_202000220*PR_022000000202); ans_temp[ans_id*36+5]+=Pmtrx[1]*(Q_001001020*PR_022000000000+Q_001001120*PR_022000000001+Q_001001220*PR_022000000002+Q_001101020*PR_022000000010+Q_001101120*PR_022000000011+Q_001101220*PR_022000000012+Q_101001020*PR_022000000100+Q_101001120*PR_022000000101+Q_101001220*PR_022000000102+Q_101101020*PR_022000000110+Q_101101120*PR_022000000111+Q_101101220*PR_022000000112); ans_temp[ans_id*36+5]+=Pmtrx[2]*(Q_000002020*PR_022000000000+Q_000002120*PR_022000000001+Q_000002220*PR_022000000002+Q_000102020*PR_022000000010+Q_000102120*PR_022000000011+Q_000102220*PR_022000000012+Q_000202020*PR_022000000020+Q_000202120*PR_022000000021+Q_000202220*PR_022000000022); ans_temp[ans_id*36+5]+=Pmtrx[3]*(Q_001000021*PR_022000000000+Q_001000121*PR_022000000001+Q_001000221*PR_022000000002+Q_001000321*PR_022000000003+Q_101000021*PR_022000000100+Q_101000121*PR_022000000101+Q_101000221*PR_022000000102+Q_101000321*PR_022000000103); ans_temp[ans_id*36+5]+=Pmtrx[4]*(Q_000001021*PR_022000000000+Q_000001121*PR_022000000001+Q_000001221*PR_022000000002+Q_000001321*PR_022000000003+Q_000101021*PR_022000000010+Q_000101121*PR_022000000011+Q_000101221*PR_022000000012+Q_000101321*PR_022000000013); ans_temp[ans_id*36+5]+=Pmtrx[5]*(Q_000000022*PR_022000000000+Q_000000122*PR_022000000001+Q_000000222*PR_022000000002+Q_000000322*PR_022000000003+Q_000000422*PR_022000000004); ans_temp[ans_id*36+0]+=Pmtrx[6]*(Q_022000000*PR_021001000000+Q_122000000*PR_021001000100+Q_222000000*PR_021001000200+Q_322000000*PR_021001000300+Q_422000000*PR_021001000400); ans_temp[ans_id*36+0]+=Pmtrx[7]*(Q_021001000*PR_021001000000+Q_021101000*PR_021001000010+Q_121001000*PR_021001000100+Q_121101000*PR_021001000110+Q_221001000*PR_021001000200+Q_221101000*PR_021001000210+Q_321001000*PR_021001000300+Q_321101000*PR_021001000310); ans_temp[ans_id*36+0]+=Pmtrx[8]*(Q_020002000*PR_021001000000+Q_020102000*PR_021001000010+Q_020202000*PR_021001000020+Q_120002000*PR_021001000100+Q_120102000*PR_021001000110+Q_120202000*PR_021001000120+Q_220002000*PR_021001000200+Q_220102000*PR_021001000210+Q_220202000*PR_021001000220); ans_temp[ans_id*36+0]+=Pmtrx[9]*(Q_021000001*PR_021001000000+Q_021000101*PR_021001000001+Q_121000001*PR_021001000100+Q_121000101*PR_021001000101+Q_221000001*PR_021001000200+Q_221000101*PR_021001000201+Q_321000001*PR_021001000300+Q_321000101*PR_021001000301); ans_temp[ans_id*36+0]+=Pmtrx[10]*(Q_020001001*PR_021001000000+Q_020001101*PR_021001000001+Q_020101001*PR_021001000010+Q_020101101*PR_021001000011+Q_120001001*PR_021001000100+Q_120001101*PR_021001000101+Q_120101001*PR_021001000110+Q_120101101*PR_021001000111+Q_220001001*PR_021001000200+Q_220001101*PR_021001000201+Q_220101001*PR_021001000210+Q_220101101*PR_021001000211); ans_temp[ans_id*36+0]+=Pmtrx[11]*(Q_020000002*PR_021001000000+Q_020000102*PR_021001000001+Q_020000202*PR_021001000002+Q_120000002*PR_021001000100+Q_120000102*PR_021001000101+Q_120000202*PR_021001000102+Q_220000002*PR_021001000200+Q_220000102*PR_021001000201+Q_220000202*PR_021001000202); ans_temp[ans_id*36+1]+=Pmtrx[6]*(Q_012010000*PR_021001000000+Q_012110000*PR_021001000010+Q_112010000*PR_021001000100+Q_112110000*PR_021001000110+Q_212010000*PR_021001000200+Q_212110000*PR_021001000210+Q_312010000*PR_021001000300+Q_312110000*PR_021001000310); ans_temp[ans_id*36+1]+=Pmtrx[7]*(Q_011011000*PR_021001000000+Q_011111000*PR_021001000010+Q_011211000*PR_021001000020+Q_111011000*PR_021001000100+Q_111111000*PR_021001000110+Q_111211000*PR_021001000120+Q_211011000*PR_021001000200+Q_211111000*PR_021001000210+Q_211211000*PR_021001000220); ans_temp[ans_id*36+1]+=Pmtrx[8]*(Q_010012000*PR_021001000000+Q_010112000*PR_021001000010+Q_010212000*PR_021001000020+Q_010312000*PR_021001000030+Q_110012000*PR_021001000100+Q_110112000*PR_021001000110+Q_110212000*PR_021001000120+Q_110312000*PR_021001000130); ans_temp[ans_id*36+1]+=Pmtrx[9]*(Q_011010001*PR_021001000000+Q_011010101*PR_021001000001+Q_011110001*PR_021001000010+Q_011110101*PR_021001000011+Q_111010001*PR_021001000100+Q_111010101*PR_021001000101+Q_111110001*PR_021001000110+Q_111110101*PR_021001000111+Q_211010001*PR_021001000200+Q_211010101*PR_021001000201+Q_211110001*PR_021001000210+Q_211110101*PR_021001000211); ans_temp[ans_id*36+1]+=Pmtrx[10]*(Q_010011001*PR_021001000000+Q_010011101*PR_021001000001+Q_010111001*PR_021001000010+Q_010111101*PR_021001000011+Q_010211001*PR_021001000020+Q_010211101*PR_021001000021+Q_110011001*PR_021001000100+Q_110011101*PR_021001000101+Q_110111001*PR_021001000110+Q_110111101*PR_021001000111+Q_110211001*PR_021001000120+Q_110211101*PR_021001000121); ans_temp[ans_id*36+1]+=Pmtrx[11]*(Q_010010002*PR_021001000000+Q_010010102*PR_021001000001+Q_010010202*PR_021001000002+Q_010110002*PR_021001000010+Q_010110102*PR_021001000011+Q_010110202*PR_021001000012+Q_110010002*PR_021001000100+Q_110010102*PR_021001000101+Q_110010202*PR_021001000102+Q_110110002*PR_021001000110+Q_110110102*PR_021001000111+Q_110110202*PR_021001000112); ans_temp[ans_id*36+2]+=Pmtrx[6]*(Q_002020000*PR_021001000000+Q_002120000*PR_021001000010+Q_002220000*PR_021001000020+Q_102020000*PR_021001000100+Q_102120000*PR_021001000110+Q_102220000*PR_021001000120+Q_202020000*PR_021001000200+Q_202120000*PR_021001000210+Q_202220000*PR_021001000220); ans_temp[ans_id*36+2]+=Pmtrx[7]*(Q_001021000*PR_021001000000+Q_001121000*PR_021001000010+Q_001221000*PR_021001000020+Q_001321000*PR_021001000030+Q_101021000*PR_021001000100+Q_101121000*PR_021001000110+Q_101221000*PR_021001000120+Q_101321000*PR_021001000130); ans_temp[ans_id*36+2]+=Pmtrx[8]*(Q_000022000*PR_021001000000+Q_000122000*PR_021001000010+Q_000222000*PR_021001000020+Q_000322000*PR_021001000030+Q_000422000*PR_021001000040); ans_temp[ans_id*36+2]+=Pmtrx[9]*(Q_001020001*PR_021001000000+Q_001020101*PR_021001000001+Q_001120001*PR_021001000010+Q_001120101*PR_021001000011+Q_001220001*PR_021001000020+Q_001220101*PR_021001000021+Q_101020001*PR_021001000100+Q_101020101*PR_021001000101+Q_101120001*PR_021001000110+Q_101120101*PR_021001000111+Q_101220001*PR_021001000120+Q_101220101*PR_021001000121); ans_temp[ans_id*36+2]+=Pmtrx[10]*(Q_000021001*PR_021001000000+Q_000021101*PR_021001000001+Q_000121001*PR_021001000010+Q_000121101*PR_021001000011+Q_000221001*PR_021001000020+Q_000221101*PR_021001000021+Q_000321001*PR_021001000030+Q_000321101*PR_021001000031); ans_temp[ans_id*36+2]+=Pmtrx[11]*(Q_000020002*PR_021001000000+Q_000020102*PR_021001000001+Q_000020202*PR_021001000002+Q_000120002*PR_021001000010+Q_000120102*PR_021001000011+Q_000120202*PR_021001000012+Q_000220002*PR_021001000020+Q_000220102*PR_021001000021+Q_000220202*PR_021001000022); ans_temp[ans_id*36+3]+=Pmtrx[6]*(Q_012000010*PR_021001000000+Q_012000110*PR_021001000001+Q_112000010*PR_021001000100+Q_112000110*PR_021001000101+Q_212000010*PR_021001000200+Q_212000110*PR_021001000201+Q_312000010*PR_021001000300+Q_312000110*PR_021001000301); ans_temp[ans_id*36+3]+=Pmtrx[7]*(Q_011001010*PR_021001000000+Q_011001110*PR_021001000001+Q_011101010*PR_021001000010+Q_011101110*PR_021001000011+Q_111001010*PR_021001000100+Q_111001110*PR_021001000101+Q_111101010*PR_021001000110+Q_111101110*PR_021001000111+Q_211001010*PR_021001000200+Q_211001110*PR_021001000201+Q_211101010*PR_021001000210+Q_211101110*PR_021001000211); ans_temp[ans_id*36+3]+=Pmtrx[8]*(Q_010002010*PR_021001000000+Q_010002110*PR_021001000001+Q_010102010*PR_021001000010+Q_010102110*PR_021001000011+Q_010202010*PR_021001000020+Q_010202110*PR_021001000021+Q_110002010*PR_021001000100+Q_110002110*PR_021001000101+Q_110102010*PR_021001000110+Q_110102110*PR_021001000111+Q_110202010*PR_021001000120+Q_110202110*PR_021001000121); ans_temp[ans_id*36+3]+=Pmtrx[9]*(Q_011000011*PR_021001000000+Q_011000111*PR_021001000001+Q_011000211*PR_021001000002+Q_111000011*PR_021001000100+Q_111000111*PR_021001000101+Q_111000211*PR_021001000102+Q_211000011*PR_021001000200+Q_211000111*PR_021001000201+Q_211000211*PR_021001000202); ans_temp[ans_id*36+3]+=Pmtrx[10]*(Q_010001011*PR_021001000000+Q_010001111*PR_021001000001+Q_010001211*PR_021001000002+Q_010101011*PR_021001000010+Q_010101111*PR_021001000011+Q_010101211*PR_021001000012+Q_110001011*PR_021001000100+Q_110001111*PR_021001000101+Q_110001211*PR_021001000102+Q_110101011*PR_021001000110+Q_110101111*PR_021001000111+Q_110101211*PR_021001000112); ans_temp[ans_id*36+3]+=Pmtrx[11]*(Q_010000012*PR_021001000000+Q_010000112*PR_021001000001+Q_010000212*PR_021001000002+Q_010000312*PR_021001000003+Q_110000012*PR_021001000100+Q_110000112*PR_021001000101+Q_110000212*PR_021001000102+Q_110000312*PR_021001000103); ans_temp[ans_id*36+4]+=Pmtrx[6]*(Q_002010010*PR_021001000000+Q_002010110*PR_021001000001+Q_002110010*PR_021001000010+Q_002110110*PR_021001000011+Q_102010010*PR_021001000100+Q_102010110*PR_021001000101+Q_102110010*PR_021001000110+Q_102110110*PR_021001000111+Q_202010010*PR_021001000200+Q_202010110*PR_021001000201+Q_202110010*PR_021001000210+Q_202110110*PR_021001000211); ans_temp[ans_id*36+4]+=Pmtrx[7]*(Q_001011010*PR_021001000000+Q_001011110*PR_021001000001+Q_001111010*PR_021001000010+Q_001111110*PR_021001000011+Q_001211010*PR_021001000020+Q_001211110*PR_021001000021+Q_101011010*PR_021001000100+Q_101011110*PR_021001000101+Q_101111010*PR_021001000110+Q_101111110*PR_021001000111+Q_101211010*PR_021001000120+Q_101211110*PR_021001000121); ans_temp[ans_id*36+4]+=Pmtrx[8]*(Q_000012010*PR_021001000000+Q_000012110*PR_021001000001+Q_000112010*PR_021001000010+Q_000112110*PR_021001000011+Q_000212010*PR_021001000020+Q_000212110*PR_021001000021+Q_000312010*PR_021001000030+Q_000312110*PR_021001000031); ans_temp[ans_id*36+4]+=Pmtrx[9]*(Q_001010011*PR_021001000000+Q_001010111*PR_021001000001+Q_001010211*PR_021001000002+Q_001110011*PR_021001000010+Q_001110111*PR_021001000011+Q_001110211*PR_021001000012+Q_101010011*PR_021001000100+Q_101010111*PR_021001000101+Q_101010211*PR_021001000102+Q_101110011*PR_021001000110+Q_101110111*PR_021001000111+Q_101110211*PR_021001000112); ans_temp[ans_id*36+4]+=Pmtrx[10]*(Q_000011011*PR_021001000000+Q_000011111*PR_021001000001+Q_000011211*PR_021001000002+Q_000111011*PR_021001000010+Q_000111111*PR_021001000011+Q_000111211*PR_021001000012+Q_000211011*PR_021001000020+Q_000211111*PR_021001000021+Q_000211211*PR_021001000022); ans_temp[ans_id*36+4]+=Pmtrx[11]*(Q_000010012*PR_021001000000+Q_000010112*PR_021001000001+Q_000010212*PR_021001000002+Q_000010312*PR_021001000003+Q_000110012*PR_021001000010+Q_000110112*PR_021001000011+Q_000110212*PR_021001000012+Q_000110312*PR_021001000013); ans_temp[ans_id*36+5]+=Pmtrx[6]*(Q_002000020*PR_021001000000+Q_002000120*PR_021001000001+Q_002000220*PR_021001000002+Q_102000020*PR_021001000100+Q_102000120*PR_021001000101+Q_102000220*PR_021001000102+Q_202000020*PR_021001000200+Q_202000120*PR_021001000201+Q_202000220*PR_021001000202); ans_temp[ans_id*36+5]+=Pmtrx[7]*(Q_001001020*PR_021001000000+Q_001001120*PR_021001000001+Q_001001220*PR_021001000002+Q_001101020*PR_021001000010+Q_001101120*PR_021001000011+Q_001101220*PR_021001000012+Q_101001020*PR_021001000100+Q_101001120*PR_021001000101+Q_101001220*PR_021001000102+Q_101101020*PR_021001000110+Q_101101120*PR_021001000111+Q_101101220*PR_021001000112); ans_temp[ans_id*36+5]+=Pmtrx[8]*(Q_000002020*PR_021001000000+Q_000002120*PR_021001000001+Q_000002220*PR_021001000002+Q_000102020*PR_021001000010+Q_000102120*PR_021001000011+Q_000102220*PR_021001000012+Q_000202020*PR_021001000020+Q_000202120*PR_021001000021+Q_000202220*PR_021001000022); ans_temp[ans_id*36+5]+=Pmtrx[9]*(Q_001000021*PR_021001000000+Q_001000121*PR_021001000001+Q_001000221*PR_021001000002+Q_001000321*PR_021001000003+Q_101000021*PR_021001000100+Q_101000121*PR_021001000101+Q_101000221*PR_021001000102+Q_101000321*PR_021001000103); ans_temp[ans_id*36+5]+=Pmtrx[10]*(Q_000001021*PR_021001000000+Q_000001121*PR_021001000001+Q_000001221*PR_021001000002+Q_000001321*PR_021001000003+Q_000101021*PR_021001000010+Q_000101121*PR_021001000011+Q_000101221*PR_021001000012+Q_000101321*PR_021001000013); ans_temp[ans_id*36+5]+=Pmtrx[11]*(Q_000000022*PR_021001000000+Q_000000122*PR_021001000001+Q_000000222*PR_021001000002+Q_000000322*PR_021001000003+Q_000000422*PR_021001000004); ans_temp[ans_id*36+0]+=Pmtrx[12]*(Q_022000000*PR_020002000000+Q_122000000*PR_020002000100+Q_222000000*PR_020002000200+Q_322000000*PR_020002000300+Q_422000000*PR_020002000400); ans_temp[ans_id*36+0]+=Pmtrx[13]*(Q_021001000*PR_020002000000+Q_021101000*PR_020002000010+Q_121001000*PR_020002000100+Q_121101000*PR_020002000110+Q_221001000*PR_020002000200+Q_221101000*PR_020002000210+Q_321001000*PR_020002000300+Q_321101000*PR_020002000310); ans_temp[ans_id*36+0]+=Pmtrx[14]*(Q_020002000*PR_020002000000+Q_020102000*PR_020002000010+Q_020202000*PR_020002000020+Q_120002000*PR_020002000100+Q_120102000*PR_020002000110+Q_120202000*PR_020002000120+Q_220002000*PR_020002000200+Q_220102000*PR_020002000210+Q_220202000*PR_020002000220); ans_temp[ans_id*36+0]+=Pmtrx[15]*(Q_021000001*PR_020002000000+Q_021000101*PR_020002000001+Q_121000001*PR_020002000100+Q_121000101*PR_020002000101+Q_221000001*PR_020002000200+Q_221000101*PR_020002000201+Q_321000001*PR_020002000300+Q_321000101*PR_020002000301); ans_temp[ans_id*36+0]+=Pmtrx[16]*(Q_020001001*PR_020002000000+Q_020001101*PR_020002000001+Q_020101001*PR_020002000010+Q_020101101*PR_020002000011+Q_120001001*PR_020002000100+Q_120001101*PR_020002000101+Q_120101001*PR_020002000110+Q_120101101*PR_020002000111+Q_220001001*PR_020002000200+Q_220001101*PR_020002000201+Q_220101001*PR_020002000210+Q_220101101*PR_020002000211); ans_temp[ans_id*36+0]+=Pmtrx[17]*(Q_020000002*PR_020002000000+Q_020000102*PR_020002000001+Q_020000202*PR_020002000002+Q_120000002*PR_020002000100+Q_120000102*PR_020002000101+Q_120000202*PR_020002000102+Q_220000002*PR_020002000200+Q_220000102*PR_020002000201+Q_220000202*PR_020002000202); ans_temp[ans_id*36+1]+=Pmtrx[12]*(Q_012010000*PR_020002000000+Q_012110000*PR_020002000010+Q_112010000*PR_020002000100+Q_112110000*PR_020002000110+Q_212010000*PR_020002000200+Q_212110000*PR_020002000210+Q_312010000*PR_020002000300+Q_312110000*PR_020002000310); ans_temp[ans_id*36+1]+=Pmtrx[13]*(Q_011011000*PR_020002000000+Q_011111000*PR_020002000010+Q_011211000*PR_020002000020+Q_111011000*PR_020002000100+Q_111111000*PR_020002000110+Q_111211000*PR_020002000120+Q_211011000*PR_020002000200+Q_211111000*PR_020002000210+Q_211211000*PR_020002000220); ans_temp[ans_id*36+1]+=Pmtrx[14]*(Q_010012000*PR_020002000000+Q_010112000*PR_020002000010+Q_010212000*PR_020002000020+Q_010312000*PR_020002000030+Q_110012000*PR_020002000100+Q_110112000*PR_020002000110+Q_110212000*PR_020002000120+Q_110312000*PR_020002000130); ans_temp[ans_id*36+1]+=Pmtrx[15]*(Q_011010001*PR_020002000000+Q_011010101*PR_020002000001+Q_011110001*PR_020002000010+Q_011110101*PR_020002000011+Q_111010001*PR_020002000100+Q_111010101*PR_020002000101+Q_111110001*PR_020002000110+Q_111110101*PR_020002000111+Q_211010001*PR_020002000200+Q_211010101*PR_020002000201+Q_211110001*PR_020002000210+Q_211110101*PR_020002000211); ans_temp[ans_id*36+1]+=Pmtrx[16]*(Q_010011001*PR_020002000000+Q_010011101*PR_020002000001+Q_010111001*PR_020002000010+Q_010111101*PR_020002000011+Q_010211001*PR_020002000020+Q_010211101*PR_020002000021+Q_110011001*PR_020002000100+Q_110011101*PR_020002000101+Q_110111001*PR_020002000110+Q_110111101*PR_020002000111+Q_110211001*PR_020002000120+Q_110211101*PR_020002000121); ans_temp[ans_id*36+1]+=Pmtrx[17]*(Q_010010002*PR_020002000000+Q_010010102*PR_020002000001+Q_010010202*PR_020002000002+Q_010110002*PR_020002000010+Q_010110102*PR_020002000011+Q_010110202*PR_020002000012+Q_110010002*PR_020002000100+Q_110010102*PR_020002000101+Q_110010202*PR_020002000102+Q_110110002*PR_020002000110+Q_110110102*PR_020002000111+Q_110110202*PR_020002000112); ans_temp[ans_id*36+2]+=Pmtrx[12]*(Q_002020000*PR_020002000000+Q_002120000*PR_020002000010+Q_002220000*PR_020002000020+Q_102020000*PR_020002000100+Q_102120000*PR_020002000110+Q_102220000*PR_020002000120+Q_202020000*PR_020002000200+Q_202120000*PR_020002000210+Q_202220000*PR_020002000220); ans_temp[ans_id*36+2]+=Pmtrx[13]*(Q_001021000*PR_020002000000+Q_001121000*PR_020002000010+Q_001221000*PR_020002000020+Q_001321000*PR_020002000030+Q_101021000*PR_020002000100+Q_101121000*PR_020002000110+Q_101221000*PR_020002000120+Q_101321000*PR_020002000130); ans_temp[ans_id*36+2]+=Pmtrx[14]*(Q_000022000*PR_020002000000+Q_000122000*PR_020002000010+Q_000222000*PR_020002000020+Q_000322000*PR_020002000030+Q_000422000*PR_020002000040); ans_temp[ans_id*36+2]+=Pmtrx[15]*(Q_001020001*PR_020002000000+Q_001020101*PR_020002000001+Q_001120001*PR_020002000010+Q_001120101*PR_020002000011+Q_001220001*PR_020002000020+Q_001220101*PR_020002000021+Q_101020001*PR_020002000100+Q_101020101*PR_020002000101+Q_101120001*PR_020002000110+Q_101120101*PR_020002000111+Q_101220001*PR_020002000120+Q_101220101*PR_020002000121); ans_temp[ans_id*36+2]+=Pmtrx[16]*(Q_000021001*PR_020002000000+Q_000021101*PR_020002000001+Q_000121001*PR_020002000010+Q_000121101*PR_020002000011+Q_000221001*PR_020002000020+Q_000221101*PR_020002000021+Q_000321001*PR_020002000030+Q_000321101*PR_020002000031); ans_temp[ans_id*36+2]+=Pmtrx[17]*(Q_000020002*PR_020002000000+Q_000020102*PR_020002000001+Q_000020202*PR_020002000002+Q_000120002*PR_020002000010+Q_000120102*PR_020002000011+Q_000120202*PR_020002000012+Q_000220002*PR_020002000020+Q_000220102*PR_020002000021+Q_000220202*PR_020002000022); ans_temp[ans_id*36+3]+=Pmtrx[12]*(Q_012000010*PR_020002000000+Q_012000110*PR_020002000001+Q_112000010*PR_020002000100+Q_112000110*PR_020002000101+Q_212000010*PR_020002000200+Q_212000110*PR_020002000201+Q_312000010*PR_020002000300+Q_312000110*PR_020002000301); ans_temp[ans_id*36+3]+=Pmtrx[13]*(Q_011001010*PR_020002000000+Q_011001110*PR_020002000001+Q_011101010*PR_020002000010+Q_011101110*PR_020002000011+Q_111001010*PR_020002000100+Q_111001110*PR_020002000101+Q_111101010*PR_020002000110+Q_111101110*PR_020002000111+Q_211001010*PR_020002000200+Q_211001110*PR_020002000201+Q_211101010*PR_020002000210+Q_211101110*PR_020002000211); ans_temp[ans_id*36+3]+=Pmtrx[14]*(Q_010002010*PR_020002000000+Q_010002110*PR_020002000001+Q_010102010*PR_020002000010+Q_010102110*PR_020002000011+Q_010202010*PR_020002000020+Q_010202110*PR_020002000021+Q_110002010*PR_020002000100+Q_110002110*PR_020002000101+Q_110102010*PR_020002000110+Q_110102110*PR_020002000111+Q_110202010*PR_020002000120+Q_110202110*PR_020002000121); ans_temp[ans_id*36+3]+=Pmtrx[15]*(Q_011000011*PR_020002000000+Q_011000111*PR_020002000001+Q_011000211*PR_020002000002+Q_111000011*PR_020002000100+Q_111000111*PR_020002000101+Q_111000211*PR_020002000102+Q_211000011*PR_020002000200+Q_211000111*PR_020002000201+Q_211000211*PR_020002000202); ans_temp[ans_id*36+3]+=Pmtrx[16]*(Q_010001011*PR_020002000000+Q_010001111*PR_020002000001+Q_010001211*PR_020002000002+Q_010101011*PR_020002000010+Q_010101111*PR_020002000011+Q_010101211*PR_020002000012+Q_110001011*PR_020002000100+Q_110001111*PR_020002000101+Q_110001211*PR_020002000102+Q_110101011*PR_020002000110+Q_110101111*PR_020002000111+Q_110101211*PR_020002000112); ans_temp[ans_id*36+3]+=Pmtrx[17]*(Q_010000012*PR_020002000000+Q_010000112*PR_020002000001+Q_010000212*PR_020002000002+Q_010000312*PR_020002000003+Q_110000012*PR_020002000100+Q_110000112*PR_020002000101+Q_110000212*PR_020002000102+Q_110000312*PR_020002000103); ans_temp[ans_id*36+4]+=Pmtrx[12]*(Q_002010010*PR_020002000000+Q_002010110*PR_020002000001+Q_002110010*PR_020002000010+Q_002110110*PR_020002000011+Q_102010010*PR_020002000100+Q_102010110*PR_020002000101+Q_102110010*PR_020002000110+Q_102110110*PR_020002000111+Q_202010010*PR_020002000200+Q_202010110*PR_020002000201+Q_202110010*PR_020002000210+Q_202110110*PR_020002000211); ans_temp[ans_id*36+4]+=Pmtrx[13]*(Q_001011010*PR_020002000000+Q_001011110*PR_020002000001+Q_001111010*PR_020002000010+Q_001111110*PR_020002000011+Q_001211010*PR_020002000020+Q_001211110*PR_020002000021+Q_101011010*PR_020002000100+Q_101011110*PR_020002000101+Q_101111010*PR_020002000110+Q_101111110*PR_020002000111+Q_101211010*PR_020002000120+Q_101211110*PR_020002000121); ans_temp[ans_id*36+4]+=Pmtrx[14]*(Q_000012010*PR_020002000000+Q_000012110*PR_020002000001+Q_000112010*PR_020002000010+Q_000112110*PR_020002000011+Q_000212010*PR_020002000020+Q_000212110*PR_020002000021+Q_000312010*PR_020002000030+Q_000312110*PR_020002000031); ans_temp[ans_id*36+4]+=Pmtrx[15]*(Q_001010011*PR_020002000000+Q_001010111*PR_020002000001+Q_001010211*PR_020002000002+Q_001110011*PR_020002000010+Q_001110111*PR_020002000011+Q_001110211*PR_020002000012+Q_101010011*PR_020002000100+Q_101010111*PR_020002000101+Q_101010211*PR_020002000102+Q_101110011*PR_020002000110+Q_101110111*PR_020002000111+Q_101110211*PR_020002000112); ans_temp[ans_id*36+4]+=Pmtrx[16]*(Q_000011011*PR_020002000000+Q_000011111*PR_020002000001+Q_000011211*PR_020002000002+Q_000111011*PR_020002000010+Q_000111111*PR_020002000011+Q_000111211*PR_020002000012+Q_000211011*PR_020002000020+Q_000211111*PR_020002000021+Q_000211211*PR_020002000022); ans_temp[ans_id*36+4]+=Pmtrx[17]*(Q_000010012*PR_020002000000+Q_000010112*PR_020002000001+Q_000010212*PR_020002000002+Q_000010312*PR_020002000003+Q_000110012*PR_020002000010+Q_000110112*PR_020002000011+Q_000110212*PR_020002000012+Q_000110312*PR_020002000013); ans_temp[ans_id*36+5]+=Pmtrx[12]*(Q_002000020*PR_020002000000+Q_002000120*PR_020002000001+Q_002000220*PR_020002000002+Q_102000020*PR_020002000100+Q_102000120*PR_020002000101+Q_102000220*PR_020002000102+Q_202000020*PR_020002000200+Q_202000120*PR_020002000201+Q_202000220*PR_020002000202); ans_temp[ans_id*36+5]+=Pmtrx[13]*(Q_001001020*PR_020002000000+Q_001001120*PR_020002000001+Q_001001220*PR_020002000002+Q_001101020*PR_020002000010+Q_001101120*PR_020002000011+Q_001101220*PR_020002000012+Q_101001020*PR_020002000100+Q_101001120*PR_020002000101+Q_101001220*PR_020002000102+Q_101101020*PR_020002000110+Q_101101120*PR_020002000111+Q_101101220*PR_020002000112); ans_temp[ans_id*36+5]+=Pmtrx[14]*(Q_000002020*PR_020002000000+Q_000002120*PR_020002000001+Q_000002220*PR_020002000002+Q_000102020*PR_020002000010+Q_000102120*PR_020002000011+Q_000102220*PR_020002000012+Q_000202020*PR_020002000020+Q_000202120*PR_020002000021+Q_000202220*PR_020002000022); ans_temp[ans_id*36+5]+=Pmtrx[15]*(Q_001000021*PR_020002000000+Q_001000121*PR_020002000001+Q_001000221*PR_020002000002+Q_001000321*PR_020002000003+Q_101000021*PR_020002000100+Q_101000121*PR_020002000101+Q_101000221*PR_020002000102+Q_101000321*PR_020002000103); ans_temp[ans_id*36+5]+=Pmtrx[16]*(Q_000001021*PR_020002000000+Q_000001121*PR_020002000001+Q_000001221*PR_020002000002+Q_000001321*PR_020002000003+Q_000101021*PR_020002000010+Q_000101121*PR_020002000011+Q_000101221*PR_020002000012+Q_000101321*PR_020002000013); ans_temp[ans_id*36+5]+=Pmtrx[17]*(Q_000000022*PR_020002000000+Q_000000122*PR_020002000001+Q_000000222*PR_020002000002+Q_000000322*PR_020002000003+Q_000000422*PR_020002000004); ans_temp[ans_id*36+0]+=Pmtrx[18]*(Q_022000000*PR_021000001000+Q_122000000*PR_021000001100+Q_222000000*PR_021000001200+Q_322000000*PR_021000001300+Q_422000000*PR_021000001400); ans_temp[ans_id*36+0]+=Pmtrx[19]*(Q_021001000*PR_021000001000+Q_021101000*PR_021000001010+Q_121001000*PR_021000001100+Q_121101000*PR_021000001110+Q_221001000*PR_021000001200+Q_221101000*PR_021000001210+Q_321001000*PR_021000001300+Q_321101000*PR_021000001310); ans_temp[ans_id*36+0]+=Pmtrx[20]*(Q_020002000*PR_021000001000+Q_020102000*PR_021000001010+Q_020202000*PR_021000001020+Q_120002000*PR_021000001100+Q_120102000*PR_021000001110+Q_120202000*PR_021000001120+Q_220002000*PR_021000001200+Q_220102000*PR_021000001210+Q_220202000*PR_021000001220); ans_temp[ans_id*36+0]+=Pmtrx[21]*(Q_021000001*PR_021000001000+Q_021000101*PR_021000001001+Q_121000001*PR_021000001100+Q_121000101*PR_021000001101+Q_221000001*PR_021000001200+Q_221000101*PR_021000001201+Q_321000001*PR_021000001300+Q_321000101*PR_021000001301); ans_temp[ans_id*36+0]+=Pmtrx[22]*(Q_020001001*PR_021000001000+Q_020001101*PR_021000001001+Q_020101001*PR_021000001010+Q_020101101*PR_021000001011+Q_120001001*PR_021000001100+Q_120001101*PR_021000001101+Q_120101001*PR_021000001110+Q_120101101*PR_021000001111+Q_220001001*PR_021000001200+Q_220001101*PR_021000001201+Q_220101001*PR_021000001210+Q_220101101*PR_021000001211); ans_temp[ans_id*36+0]+=Pmtrx[23]*(Q_020000002*PR_021000001000+Q_020000102*PR_021000001001+Q_020000202*PR_021000001002+Q_120000002*PR_021000001100+Q_120000102*PR_021000001101+Q_120000202*PR_021000001102+Q_220000002*PR_021000001200+Q_220000102*PR_021000001201+Q_220000202*PR_021000001202); ans_temp[ans_id*36+1]+=Pmtrx[18]*(Q_012010000*PR_021000001000+Q_012110000*PR_021000001010+Q_112010000*PR_021000001100+Q_112110000*PR_021000001110+Q_212010000*PR_021000001200+Q_212110000*PR_021000001210+Q_312010000*PR_021000001300+Q_312110000*PR_021000001310); ans_temp[ans_id*36+1]+=Pmtrx[19]*(Q_011011000*PR_021000001000+Q_011111000*PR_021000001010+Q_011211000*PR_021000001020+Q_111011000*PR_021000001100+Q_111111000*PR_021000001110+Q_111211000*PR_021000001120+Q_211011000*PR_021000001200+Q_211111000*PR_021000001210+Q_211211000*PR_021000001220); ans_temp[ans_id*36+1]+=Pmtrx[20]*(Q_010012000*PR_021000001000+Q_010112000*PR_021000001010+Q_010212000*PR_021000001020+Q_010312000*PR_021000001030+Q_110012000*PR_021000001100+Q_110112000*PR_021000001110+Q_110212000*PR_021000001120+Q_110312000*PR_021000001130); ans_temp[ans_id*36+1]+=Pmtrx[21]*(Q_011010001*PR_021000001000+Q_011010101*PR_021000001001+Q_011110001*PR_021000001010+Q_011110101*PR_021000001011+Q_111010001*PR_021000001100+Q_111010101*PR_021000001101+Q_111110001*PR_021000001110+Q_111110101*PR_021000001111+Q_211010001*PR_021000001200+Q_211010101*PR_021000001201+Q_211110001*PR_021000001210+Q_211110101*PR_021000001211); ans_temp[ans_id*36+1]+=Pmtrx[22]*(Q_010011001*PR_021000001000+Q_010011101*PR_021000001001+Q_010111001*PR_021000001010+Q_010111101*PR_021000001011+Q_010211001*PR_021000001020+Q_010211101*PR_021000001021+Q_110011001*PR_021000001100+Q_110011101*PR_021000001101+Q_110111001*PR_021000001110+Q_110111101*PR_021000001111+Q_110211001*PR_021000001120+Q_110211101*PR_021000001121); ans_temp[ans_id*36+1]+=Pmtrx[23]*(Q_010010002*PR_021000001000+Q_010010102*PR_021000001001+Q_010010202*PR_021000001002+Q_010110002*PR_021000001010+Q_010110102*PR_021000001011+Q_010110202*PR_021000001012+Q_110010002*PR_021000001100+Q_110010102*PR_021000001101+Q_110010202*PR_021000001102+Q_110110002*PR_021000001110+Q_110110102*PR_021000001111+Q_110110202*PR_021000001112); ans_temp[ans_id*36+2]+=Pmtrx[18]*(Q_002020000*PR_021000001000+Q_002120000*PR_021000001010+Q_002220000*PR_021000001020+Q_102020000*PR_021000001100+Q_102120000*PR_021000001110+Q_102220000*PR_021000001120+Q_202020000*PR_021000001200+Q_202120000*PR_021000001210+Q_202220000*PR_021000001220); ans_temp[ans_id*36+2]+=Pmtrx[19]*(Q_001021000*PR_021000001000+Q_001121000*PR_021000001010+Q_001221000*PR_021000001020+Q_001321000*PR_021000001030+Q_101021000*PR_021000001100+Q_101121000*PR_021000001110+Q_101221000*PR_021000001120+Q_101321000*PR_021000001130); ans_temp[ans_id*36+2]+=Pmtrx[20]*(Q_000022000*PR_021000001000+Q_000122000*PR_021000001010+Q_000222000*PR_021000001020+Q_000322000*PR_021000001030+Q_000422000*PR_021000001040); ans_temp[ans_id*36+2]+=Pmtrx[21]*(Q_001020001*PR_021000001000+Q_001020101*PR_021000001001+Q_001120001*PR_021000001010+Q_001120101*PR_021000001011+Q_001220001*PR_021000001020+Q_001220101*PR_021000001021+Q_101020001*PR_021000001100+Q_101020101*PR_021000001101+Q_101120001*PR_021000001110+Q_101120101*PR_021000001111+Q_101220001*PR_021000001120+Q_101220101*PR_021000001121); ans_temp[ans_id*36+2]+=Pmtrx[22]*(Q_000021001*PR_021000001000+Q_000021101*PR_021000001001+Q_000121001*PR_021000001010+Q_000121101*PR_021000001011+Q_000221001*PR_021000001020+Q_000221101*PR_021000001021+Q_000321001*PR_021000001030+Q_000321101*PR_021000001031); ans_temp[ans_id*36+2]+=Pmtrx[23]*(Q_000020002*PR_021000001000+Q_000020102*PR_021000001001+Q_000020202*PR_021000001002+Q_000120002*PR_021000001010+Q_000120102*PR_021000001011+Q_000120202*PR_021000001012+Q_000220002*PR_021000001020+Q_000220102*PR_021000001021+Q_000220202*PR_021000001022); ans_temp[ans_id*36+3]+=Pmtrx[18]*(Q_012000010*PR_021000001000+Q_012000110*PR_021000001001+Q_112000010*PR_021000001100+Q_112000110*PR_021000001101+Q_212000010*PR_021000001200+Q_212000110*PR_021000001201+Q_312000010*PR_021000001300+Q_312000110*PR_021000001301); ans_temp[ans_id*36+3]+=Pmtrx[19]*(Q_011001010*PR_021000001000+Q_011001110*PR_021000001001+Q_011101010*PR_021000001010+Q_011101110*PR_021000001011+Q_111001010*PR_021000001100+Q_111001110*PR_021000001101+Q_111101010*PR_021000001110+Q_111101110*PR_021000001111+Q_211001010*PR_021000001200+Q_211001110*PR_021000001201+Q_211101010*PR_021000001210+Q_211101110*PR_021000001211); ans_temp[ans_id*36+3]+=Pmtrx[20]*(Q_010002010*PR_021000001000+Q_010002110*PR_021000001001+Q_010102010*PR_021000001010+Q_010102110*PR_021000001011+Q_010202010*PR_021000001020+Q_010202110*PR_021000001021+Q_110002010*PR_021000001100+Q_110002110*PR_021000001101+Q_110102010*PR_021000001110+Q_110102110*PR_021000001111+Q_110202010*PR_021000001120+Q_110202110*PR_021000001121); ans_temp[ans_id*36+3]+=Pmtrx[21]*(Q_011000011*PR_021000001000+Q_011000111*PR_021000001001+Q_011000211*PR_021000001002+Q_111000011*PR_021000001100+Q_111000111*PR_021000001101+Q_111000211*PR_021000001102+Q_211000011*PR_021000001200+Q_211000111*PR_021000001201+Q_211000211*PR_021000001202); ans_temp[ans_id*36+3]+=Pmtrx[22]*(Q_010001011*PR_021000001000+Q_010001111*PR_021000001001+Q_010001211*PR_021000001002+Q_010101011*PR_021000001010+Q_010101111*PR_021000001011+Q_010101211*PR_021000001012+Q_110001011*PR_021000001100+Q_110001111*PR_021000001101+Q_110001211*PR_021000001102+Q_110101011*PR_021000001110+Q_110101111*PR_021000001111+Q_110101211*PR_021000001112); ans_temp[ans_id*36+3]+=Pmtrx[23]*(Q_010000012*PR_021000001000+Q_010000112*PR_021000001001+Q_010000212*PR_021000001002+Q_010000312*PR_021000001003+Q_110000012*PR_021000001100+Q_110000112*PR_021000001101+Q_110000212*PR_021000001102+Q_110000312*PR_021000001103); ans_temp[ans_id*36+4]+=Pmtrx[18]*(Q_002010010*PR_021000001000+Q_002010110*PR_021000001001+Q_002110010*PR_021000001010+Q_002110110*PR_021000001011+Q_102010010*PR_021000001100+Q_102010110*PR_021000001101+Q_102110010*PR_021000001110+Q_102110110*PR_021000001111+Q_202010010*PR_021000001200+Q_202010110*PR_021000001201+Q_202110010*PR_021000001210+Q_202110110*PR_021000001211); ans_temp[ans_id*36+4]+=Pmtrx[19]*(Q_001011010*PR_021000001000+Q_001011110*PR_021000001001+Q_001111010*PR_021000001010+Q_001111110*PR_021000001011+Q_001211010*PR_021000001020+Q_001211110*PR_021000001021+Q_101011010*PR_021000001100+Q_101011110*PR_021000001101+Q_101111010*PR_021000001110+Q_101111110*PR_021000001111+Q_101211010*PR_021000001120+Q_101211110*PR_021000001121); ans_temp[ans_id*36+4]+=Pmtrx[20]*(Q_000012010*PR_021000001000+Q_000012110*PR_021000001001+Q_000112010*PR_021000001010+Q_000112110*PR_021000001011+Q_000212010*PR_021000001020+Q_000212110*PR_021000001021+Q_000312010*PR_021000001030+Q_000312110*PR_021000001031); ans_temp[ans_id*36+4]+=Pmtrx[21]*(Q_001010011*PR_021000001000+Q_001010111*PR_021000001001+Q_001010211*PR_021000001002+Q_001110011*PR_021000001010+Q_001110111*PR_021000001011+Q_001110211*PR_021000001012+Q_101010011*PR_021000001100+Q_101010111*PR_021000001101+Q_101010211*PR_021000001102+Q_101110011*PR_021000001110+Q_101110111*PR_021000001111+Q_101110211*PR_021000001112); ans_temp[ans_id*36+4]+=Pmtrx[22]*(Q_000011011*PR_021000001000+Q_000011111*PR_021000001001+Q_000011211*PR_021000001002+Q_000111011*PR_021000001010+Q_000111111*PR_021000001011+Q_000111211*PR_021000001012+Q_000211011*PR_021000001020+Q_000211111*PR_021000001021+Q_000211211*PR_021000001022); ans_temp[ans_id*36+4]+=Pmtrx[23]*(Q_000010012*PR_021000001000+Q_000010112*PR_021000001001+Q_000010212*PR_021000001002+Q_000010312*PR_021000001003+Q_000110012*PR_021000001010+Q_000110112*PR_021000001011+Q_000110212*PR_021000001012+Q_000110312*PR_021000001013); ans_temp[ans_id*36+5]+=Pmtrx[18]*(Q_002000020*PR_021000001000+Q_002000120*PR_021000001001+Q_002000220*PR_021000001002+Q_102000020*PR_021000001100+Q_102000120*PR_021000001101+Q_102000220*PR_021000001102+Q_202000020*PR_021000001200+Q_202000120*PR_021000001201+Q_202000220*PR_021000001202); ans_temp[ans_id*36+5]+=Pmtrx[19]*(Q_001001020*PR_021000001000+Q_001001120*PR_021000001001+Q_001001220*PR_021000001002+Q_001101020*PR_021000001010+Q_001101120*PR_021000001011+Q_001101220*PR_021000001012+Q_101001020*PR_021000001100+Q_101001120*PR_021000001101+Q_101001220*PR_021000001102+Q_101101020*PR_021000001110+Q_101101120*PR_021000001111+Q_101101220*PR_021000001112); ans_temp[ans_id*36+5]+=Pmtrx[20]*(Q_000002020*PR_021000001000+Q_000002120*PR_021000001001+Q_000002220*PR_021000001002+Q_000102020*PR_021000001010+Q_000102120*PR_021000001011+Q_000102220*PR_021000001012+Q_000202020*PR_021000001020+Q_000202120*PR_021000001021+Q_000202220*PR_021000001022); ans_temp[ans_id*36+5]+=Pmtrx[21]*(Q_001000021*PR_021000001000+Q_001000121*PR_021000001001+Q_001000221*PR_021000001002+Q_001000321*PR_021000001003+Q_101000021*PR_021000001100+Q_101000121*PR_021000001101+Q_101000221*PR_021000001102+Q_101000321*PR_021000001103); ans_temp[ans_id*36+5]+=Pmtrx[22]*(Q_000001021*PR_021000001000+Q_000001121*PR_021000001001+Q_000001221*PR_021000001002+Q_000001321*PR_021000001003+Q_000101021*PR_021000001010+Q_000101121*PR_021000001011+Q_000101221*PR_021000001012+Q_000101321*PR_021000001013); ans_temp[ans_id*36+5]+=Pmtrx[23]*(Q_000000022*PR_021000001000+Q_000000122*PR_021000001001+Q_000000222*PR_021000001002+Q_000000322*PR_021000001003+Q_000000422*PR_021000001004); ans_temp[ans_id*36+0]+=Pmtrx[24]*(Q_022000000*PR_020001001000+Q_122000000*PR_020001001100+Q_222000000*PR_020001001200+Q_322000000*PR_020001001300+Q_422000000*PR_020001001400); ans_temp[ans_id*36+0]+=Pmtrx[25]*(Q_021001000*PR_020001001000+Q_021101000*PR_020001001010+Q_121001000*PR_020001001100+Q_121101000*PR_020001001110+Q_221001000*PR_020001001200+Q_221101000*PR_020001001210+Q_321001000*PR_020001001300+Q_321101000*PR_020001001310); ans_temp[ans_id*36+0]+=Pmtrx[26]*(Q_020002000*PR_020001001000+Q_020102000*PR_020001001010+Q_020202000*PR_020001001020+Q_120002000*PR_020001001100+Q_120102000*PR_020001001110+Q_120202000*PR_020001001120+Q_220002000*PR_020001001200+Q_220102000*PR_020001001210+Q_220202000*PR_020001001220); ans_temp[ans_id*36+0]+=Pmtrx[27]*(Q_021000001*PR_020001001000+Q_021000101*PR_020001001001+Q_121000001*PR_020001001100+Q_121000101*PR_020001001101+Q_221000001*PR_020001001200+Q_221000101*PR_020001001201+Q_321000001*PR_020001001300+Q_321000101*PR_020001001301); ans_temp[ans_id*36+0]+=Pmtrx[28]*(Q_020001001*PR_020001001000+Q_020001101*PR_020001001001+Q_020101001*PR_020001001010+Q_020101101*PR_020001001011+Q_120001001*PR_020001001100+Q_120001101*PR_020001001101+Q_120101001*PR_020001001110+Q_120101101*PR_020001001111+Q_220001001*PR_020001001200+Q_220001101*PR_020001001201+Q_220101001*PR_020001001210+Q_220101101*PR_020001001211); ans_temp[ans_id*36+0]+=Pmtrx[29]*(Q_020000002*PR_020001001000+Q_020000102*PR_020001001001+Q_020000202*PR_020001001002+Q_120000002*PR_020001001100+Q_120000102*PR_020001001101+Q_120000202*PR_020001001102+Q_220000002*PR_020001001200+Q_220000102*PR_020001001201+Q_220000202*PR_020001001202); ans_temp[ans_id*36+1]+=Pmtrx[24]*(Q_012010000*PR_020001001000+Q_012110000*PR_020001001010+Q_112010000*PR_020001001100+Q_112110000*PR_020001001110+Q_212010000*PR_020001001200+Q_212110000*PR_020001001210+Q_312010000*PR_020001001300+Q_312110000*PR_020001001310); ans_temp[ans_id*36+1]+=Pmtrx[25]*(Q_011011000*PR_020001001000+Q_011111000*PR_020001001010+Q_011211000*PR_020001001020+Q_111011000*PR_020001001100+Q_111111000*PR_020001001110+Q_111211000*PR_020001001120+Q_211011000*PR_020001001200+Q_211111000*PR_020001001210+Q_211211000*PR_020001001220); ans_temp[ans_id*36+1]+=Pmtrx[26]*(Q_010012000*PR_020001001000+Q_010112000*PR_020001001010+Q_010212000*PR_020001001020+Q_010312000*PR_020001001030+Q_110012000*PR_020001001100+Q_110112000*PR_020001001110+Q_110212000*PR_020001001120+Q_110312000*PR_020001001130); ans_temp[ans_id*36+1]+=Pmtrx[27]*(Q_011010001*PR_020001001000+Q_011010101*PR_020001001001+Q_011110001*PR_020001001010+Q_011110101*PR_020001001011+Q_111010001*PR_020001001100+Q_111010101*PR_020001001101+Q_111110001*PR_020001001110+Q_111110101*PR_020001001111+Q_211010001*PR_020001001200+Q_211010101*PR_020001001201+Q_211110001*PR_020001001210+Q_211110101*PR_020001001211); ans_temp[ans_id*36+1]+=Pmtrx[28]*(Q_010011001*PR_020001001000+Q_010011101*PR_020001001001+Q_010111001*PR_020001001010+Q_010111101*PR_020001001011+Q_010211001*PR_020001001020+Q_010211101*PR_020001001021+Q_110011001*PR_020001001100+Q_110011101*PR_020001001101+Q_110111001*PR_020001001110+Q_110111101*PR_020001001111+Q_110211001*PR_020001001120+Q_110211101*PR_020001001121); ans_temp[ans_id*36+1]+=Pmtrx[29]*(Q_010010002*PR_020001001000+Q_010010102*PR_020001001001+Q_010010202*PR_020001001002+Q_010110002*PR_020001001010+Q_010110102*PR_020001001011+Q_010110202*PR_020001001012+Q_110010002*PR_020001001100+Q_110010102*PR_020001001101+Q_110010202*PR_020001001102+Q_110110002*PR_020001001110+Q_110110102*PR_020001001111+Q_110110202*PR_020001001112); ans_temp[ans_id*36+2]+=Pmtrx[24]*(Q_002020000*PR_020001001000+Q_002120000*PR_020001001010+Q_002220000*PR_020001001020+Q_102020000*PR_020001001100+Q_102120000*PR_020001001110+Q_102220000*PR_020001001120+Q_202020000*PR_020001001200+Q_202120000*PR_020001001210+Q_202220000*PR_020001001220); ans_temp[ans_id*36+2]+=Pmtrx[25]*(Q_001021000*PR_020001001000+Q_001121000*PR_020001001010+Q_001221000*PR_020001001020+Q_001321000*PR_020001001030+Q_101021000*PR_020001001100+Q_101121000*PR_020001001110+Q_101221000*PR_020001001120+Q_101321000*PR_020001001130); ans_temp[ans_id*36+2]+=Pmtrx[26]*(Q_000022000*PR_020001001000+Q_000122000*PR_020001001010+Q_000222000*PR_020001001020+Q_000322000*PR_020001001030+Q_000422000*PR_020001001040); ans_temp[ans_id*36+2]+=Pmtrx[27]*(Q_001020001*PR_020001001000+Q_001020101*PR_020001001001+Q_001120001*PR_020001001010+Q_001120101*PR_020001001011+Q_001220001*PR_020001001020+Q_001220101*PR_020001001021+Q_101020001*PR_020001001100+Q_101020101*PR_020001001101+Q_101120001*PR_020001001110+Q_101120101*PR_020001001111+Q_101220001*PR_020001001120+Q_101220101*PR_020001001121); ans_temp[ans_id*36+2]+=Pmtrx[28]*(Q_000021001*PR_020001001000+Q_000021101*PR_020001001001+Q_000121001*PR_020001001010+Q_000121101*PR_020001001011+Q_000221001*PR_020001001020+Q_000221101*PR_020001001021+Q_000321001*PR_020001001030+Q_000321101*PR_020001001031); ans_temp[ans_id*36+2]+=Pmtrx[29]*(Q_000020002*PR_020001001000+Q_000020102*PR_020001001001+Q_000020202*PR_020001001002+Q_000120002*PR_020001001010+Q_000120102*PR_020001001011+Q_000120202*PR_020001001012+Q_000220002*PR_020001001020+Q_000220102*PR_020001001021+Q_000220202*PR_020001001022); ans_temp[ans_id*36+3]+=Pmtrx[24]*(Q_012000010*PR_020001001000+Q_012000110*PR_020001001001+Q_112000010*PR_020001001100+Q_112000110*PR_020001001101+Q_212000010*PR_020001001200+Q_212000110*PR_020001001201+Q_312000010*PR_020001001300+Q_312000110*PR_020001001301); ans_temp[ans_id*36+3]+=Pmtrx[25]*(Q_011001010*PR_020001001000+Q_011001110*PR_020001001001+Q_011101010*PR_020001001010+Q_011101110*PR_020001001011+Q_111001010*PR_020001001100+Q_111001110*PR_020001001101+Q_111101010*PR_020001001110+Q_111101110*PR_020001001111+Q_211001010*PR_020001001200+Q_211001110*PR_020001001201+Q_211101010*PR_020001001210+Q_211101110*PR_020001001211); ans_temp[ans_id*36+3]+=Pmtrx[26]*(Q_010002010*PR_020001001000+Q_010002110*PR_020001001001+Q_010102010*PR_020001001010+Q_010102110*PR_020001001011+Q_010202010*PR_020001001020+Q_010202110*PR_020001001021+Q_110002010*PR_020001001100+Q_110002110*PR_020001001101+Q_110102010*PR_020001001110+Q_110102110*PR_020001001111+Q_110202010*PR_020001001120+Q_110202110*PR_020001001121); ans_temp[ans_id*36+3]+=Pmtrx[27]*(Q_011000011*PR_020001001000+Q_011000111*PR_020001001001+Q_011000211*PR_020001001002+Q_111000011*PR_020001001100+Q_111000111*PR_020001001101+Q_111000211*PR_020001001102+Q_211000011*PR_020001001200+Q_211000111*PR_020001001201+Q_211000211*PR_020001001202); ans_temp[ans_id*36+3]+=Pmtrx[28]*(Q_010001011*PR_020001001000+Q_010001111*PR_020001001001+Q_010001211*PR_020001001002+Q_010101011*PR_020001001010+Q_010101111*PR_020001001011+Q_010101211*PR_020001001012+Q_110001011*PR_020001001100+Q_110001111*PR_020001001101+Q_110001211*PR_020001001102+Q_110101011*PR_020001001110+Q_110101111*PR_020001001111+Q_110101211*PR_020001001112); ans_temp[ans_id*36+3]+=Pmtrx[29]*(Q_010000012*PR_020001001000+Q_010000112*PR_020001001001+Q_010000212*PR_020001001002+Q_010000312*PR_020001001003+Q_110000012*PR_020001001100+Q_110000112*PR_020001001101+Q_110000212*PR_020001001102+Q_110000312*PR_020001001103); ans_temp[ans_id*36+4]+=Pmtrx[24]*(Q_002010010*PR_020001001000+Q_002010110*PR_020001001001+Q_002110010*PR_020001001010+Q_002110110*PR_020001001011+Q_102010010*PR_020001001100+Q_102010110*PR_020001001101+Q_102110010*PR_020001001110+Q_102110110*PR_020001001111+Q_202010010*PR_020001001200+Q_202010110*PR_020001001201+Q_202110010*PR_020001001210+Q_202110110*PR_020001001211); ans_temp[ans_id*36+4]+=Pmtrx[25]*(Q_001011010*PR_020001001000+Q_001011110*PR_020001001001+Q_001111010*PR_020001001010+Q_001111110*PR_020001001011+Q_001211010*PR_020001001020+Q_001211110*PR_020001001021+Q_101011010*PR_020001001100+Q_101011110*PR_020001001101+Q_101111010*PR_020001001110+Q_101111110*PR_020001001111+Q_101211010*PR_020001001120+Q_101211110*PR_020001001121); ans_temp[ans_id*36+4]+=Pmtrx[26]*(Q_000012010*PR_020001001000+Q_000012110*PR_020001001001+Q_000112010*PR_020001001010+Q_000112110*PR_020001001011+Q_000212010*PR_020001001020+Q_000212110*PR_020001001021+Q_000312010*PR_020001001030+Q_000312110*PR_020001001031); ans_temp[ans_id*36+4]+=Pmtrx[27]*(Q_001010011*PR_020001001000+Q_001010111*PR_020001001001+Q_001010211*PR_020001001002+Q_001110011*PR_020001001010+Q_001110111*PR_020001001011+Q_001110211*PR_020001001012+Q_101010011*PR_020001001100+Q_101010111*PR_020001001101+Q_101010211*PR_020001001102+Q_101110011*PR_020001001110+Q_101110111*PR_020001001111+Q_101110211*PR_020001001112); ans_temp[ans_id*36+4]+=Pmtrx[28]*(Q_000011011*PR_020001001000+Q_000011111*PR_020001001001+Q_000011211*PR_020001001002+Q_000111011*PR_020001001010+Q_000111111*PR_020001001011+Q_000111211*PR_020001001012+Q_000211011*PR_020001001020+Q_000211111*PR_020001001021+Q_000211211*PR_020001001022); ans_temp[ans_id*36+4]+=Pmtrx[29]*(Q_000010012*PR_020001001000+Q_000010112*PR_020001001001+Q_000010212*PR_020001001002+Q_000010312*PR_020001001003+Q_000110012*PR_020001001010+Q_000110112*PR_020001001011+Q_000110212*PR_020001001012+Q_000110312*PR_020001001013); ans_temp[ans_id*36+5]+=Pmtrx[24]*(Q_002000020*PR_020001001000+Q_002000120*PR_020001001001+Q_002000220*PR_020001001002+Q_102000020*PR_020001001100+Q_102000120*PR_020001001101+Q_102000220*PR_020001001102+Q_202000020*PR_020001001200+Q_202000120*PR_020001001201+Q_202000220*PR_020001001202); ans_temp[ans_id*36+5]+=Pmtrx[25]*(Q_001001020*PR_020001001000+Q_001001120*PR_020001001001+Q_001001220*PR_020001001002+Q_001101020*PR_020001001010+Q_001101120*PR_020001001011+Q_001101220*PR_020001001012+Q_101001020*PR_020001001100+Q_101001120*PR_020001001101+Q_101001220*PR_020001001102+Q_101101020*PR_020001001110+Q_101101120*PR_020001001111+Q_101101220*PR_020001001112); ans_temp[ans_id*36+5]+=Pmtrx[26]*(Q_000002020*PR_020001001000+Q_000002120*PR_020001001001+Q_000002220*PR_020001001002+Q_000102020*PR_020001001010+Q_000102120*PR_020001001011+Q_000102220*PR_020001001012+Q_000202020*PR_020001001020+Q_000202120*PR_020001001021+Q_000202220*PR_020001001022); ans_temp[ans_id*36+5]+=Pmtrx[27]*(Q_001000021*PR_020001001000+Q_001000121*PR_020001001001+Q_001000221*PR_020001001002+Q_001000321*PR_020001001003+Q_101000021*PR_020001001100+Q_101000121*PR_020001001101+Q_101000221*PR_020001001102+Q_101000321*PR_020001001103); ans_temp[ans_id*36+5]+=Pmtrx[28]*(Q_000001021*PR_020001001000+Q_000001121*PR_020001001001+Q_000001221*PR_020001001002+Q_000001321*PR_020001001003+Q_000101021*PR_020001001010+Q_000101121*PR_020001001011+Q_000101221*PR_020001001012+Q_000101321*PR_020001001013); ans_temp[ans_id*36+5]+=Pmtrx[29]*(Q_000000022*PR_020001001000+Q_000000122*PR_020001001001+Q_000000222*PR_020001001002+Q_000000322*PR_020001001003+Q_000000422*PR_020001001004); ans_temp[ans_id*36+0]+=Pmtrx[30]*(Q_022000000*PR_020000002000+Q_122000000*PR_020000002100+Q_222000000*PR_020000002200+Q_322000000*PR_020000002300+Q_422000000*PR_020000002400); ans_temp[ans_id*36+0]+=Pmtrx[31]*(Q_021001000*PR_020000002000+Q_021101000*PR_020000002010+Q_121001000*PR_020000002100+Q_121101000*PR_020000002110+Q_221001000*PR_020000002200+Q_221101000*PR_020000002210+Q_321001000*PR_020000002300+Q_321101000*PR_020000002310); ans_temp[ans_id*36+0]+=Pmtrx[32]*(Q_020002000*PR_020000002000+Q_020102000*PR_020000002010+Q_020202000*PR_020000002020+Q_120002000*PR_020000002100+Q_120102000*PR_020000002110+Q_120202000*PR_020000002120+Q_220002000*PR_020000002200+Q_220102000*PR_020000002210+Q_220202000*PR_020000002220); ans_temp[ans_id*36+0]+=Pmtrx[33]*(Q_021000001*PR_020000002000+Q_021000101*PR_020000002001+Q_121000001*PR_020000002100+Q_121000101*PR_020000002101+Q_221000001*PR_020000002200+Q_221000101*PR_020000002201+Q_321000001*PR_020000002300+Q_321000101*PR_020000002301); ans_temp[ans_id*36+0]+=Pmtrx[34]*(Q_020001001*PR_020000002000+Q_020001101*PR_020000002001+Q_020101001*PR_020000002010+Q_020101101*PR_020000002011+Q_120001001*PR_020000002100+Q_120001101*PR_020000002101+Q_120101001*PR_020000002110+Q_120101101*PR_020000002111+Q_220001001*PR_020000002200+Q_220001101*PR_020000002201+Q_220101001*PR_020000002210+Q_220101101*PR_020000002211); ans_temp[ans_id*36+0]+=Pmtrx[35]*(Q_020000002*PR_020000002000+Q_020000102*PR_020000002001+Q_020000202*PR_020000002002+Q_120000002*PR_020000002100+Q_120000102*PR_020000002101+Q_120000202*PR_020000002102+Q_220000002*PR_020000002200+Q_220000102*PR_020000002201+Q_220000202*PR_020000002202); ans_temp[ans_id*36+1]+=Pmtrx[30]*(Q_012010000*PR_020000002000+Q_012110000*PR_020000002010+Q_112010000*PR_020000002100+Q_112110000*PR_020000002110+Q_212010000*PR_020000002200+Q_212110000*PR_020000002210+Q_312010000*PR_020000002300+Q_312110000*PR_020000002310); ans_temp[ans_id*36+1]+=Pmtrx[31]*(Q_011011000*PR_020000002000+Q_011111000*PR_020000002010+Q_011211000*PR_020000002020+Q_111011000*PR_020000002100+Q_111111000*PR_020000002110+Q_111211000*PR_020000002120+Q_211011000*PR_020000002200+Q_211111000*PR_020000002210+Q_211211000*PR_020000002220); ans_temp[ans_id*36+1]+=Pmtrx[32]*(Q_010012000*PR_020000002000+Q_010112000*PR_020000002010+Q_010212000*PR_020000002020+Q_010312000*PR_020000002030+Q_110012000*PR_020000002100+Q_110112000*PR_020000002110+Q_110212000*PR_020000002120+Q_110312000*PR_020000002130); ans_temp[ans_id*36+1]+=Pmtrx[33]*(Q_011010001*PR_020000002000+Q_011010101*PR_020000002001+Q_011110001*PR_020000002010+Q_011110101*PR_020000002011+Q_111010001*PR_020000002100+Q_111010101*PR_020000002101+Q_111110001*PR_020000002110+Q_111110101*PR_020000002111+Q_211010001*PR_020000002200+Q_211010101*PR_020000002201+Q_211110001*PR_020000002210+Q_211110101*PR_020000002211); ans_temp[ans_id*36+1]+=Pmtrx[34]*(Q_010011001*PR_020000002000+Q_010011101*PR_020000002001+Q_010111001*PR_020000002010+Q_010111101*PR_020000002011+Q_010211001*PR_020000002020+Q_010211101*PR_020000002021+Q_110011001*PR_020000002100+Q_110011101*PR_020000002101+Q_110111001*PR_020000002110+Q_110111101*PR_020000002111+Q_110211001*PR_020000002120+Q_110211101*PR_020000002121); ans_temp[ans_id*36+1]+=Pmtrx[35]*(Q_010010002*PR_020000002000+Q_010010102*PR_020000002001+Q_010010202*PR_020000002002+Q_010110002*PR_020000002010+Q_010110102*PR_020000002011+Q_010110202*PR_020000002012+Q_110010002*PR_020000002100+Q_110010102*PR_020000002101+Q_110010202*PR_020000002102+Q_110110002*PR_020000002110+Q_110110102*PR_020000002111+Q_110110202*PR_020000002112); ans_temp[ans_id*36+2]+=Pmtrx[30]*(Q_002020000*PR_020000002000+Q_002120000*PR_020000002010+Q_002220000*PR_020000002020+Q_102020000*PR_020000002100+Q_102120000*PR_020000002110+Q_102220000*PR_020000002120+Q_202020000*PR_020000002200+Q_202120000*PR_020000002210+Q_202220000*PR_020000002220); ans_temp[ans_id*36+2]+=Pmtrx[31]*(Q_001021000*PR_020000002000+Q_001121000*PR_020000002010+Q_001221000*PR_020000002020+Q_001321000*PR_020000002030+Q_101021000*PR_020000002100+Q_101121000*PR_020000002110+Q_101221000*PR_020000002120+Q_101321000*PR_020000002130); ans_temp[ans_id*36+2]+=Pmtrx[32]*(Q_000022000*PR_020000002000+Q_000122000*PR_020000002010+Q_000222000*PR_020000002020+Q_000322000*PR_020000002030+Q_000422000*PR_020000002040); ans_temp[ans_id*36+2]+=Pmtrx[33]*(Q_001020001*PR_020000002000+Q_001020101*PR_020000002001+Q_001120001*PR_020000002010+Q_001120101*PR_020000002011+Q_001220001*PR_020000002020+Q_001220101*PR_020000002021+Q_101020001*PR_020000002100+Q_101020101*PR_020000002101+Q_101120001*PR_020000002110+Q_101120101*PR_020000002111+Q_101220001*PR_020000002120+Q_101220101*PR_020000002121); ans_temp[ans_id*36+2]+=Pmtrx[34]*(Q_000021001*PR_020000002000+Q_000021101*PR_020000002001+Q_000121001*PR_020000002010+Q_000121101*PR_020000002011+Q_000221001*PR_020000002020+Q_000221101*PR_020000002021+Q_000321001*PR_020000002030+Q_000321101*PR_020000002031); ans_temp[ans_id*36+2]+=Pmtrx[35]*(Q_000020002*PR_020000002000+Q_000020102*PR_020000002001+Q_000020202*PR_020000002002+Q_000120002*PR_020000002010+Q_000120102*PR_020000002011+Q_000120202*PR_020000002012+Q_000220002*PR_020000002020+Q_000220102*PR_020000002021+Q_000220202*PR_020000002022); ans_temp[ans_id*36+3]+=Pmtrx[30]*(Q_012000010*PR_020000002000+Q_012000110*PR_020000002001+Q_112000010*PR_020000002100+Q_112000110*PR_020000002101+Q_212000010*PR_020000002200+Q_212000110*PR_020000002201+Q_312000010*PR_020000002300+Q_312000110*PR_020000002301); ans_temp[ans_id*36+3]+=Pmtrx[31]*(Q_011001010*PR_020000002000+Q_011001110*PR_020000002001+Q_011101010*PR_020000002010+Q_011101110*PR_020000002011+Q_111001010*PR_020000002100+Q_111001110*PR_020000002101+Q_111101010*PR_020000002110+Q_111101110*PR_020000002111+Q_211001010*PR_020000002200+Q_211001110*PR_020000002201+Q_211101010*PR_020000002210+Q_211101110*PR_020000002211); ans_temp[ans_id*36+3]+=Pmtrx[32]*(Q_010002010*PR_020000002000+Q_010002110*PR_020000002001+Q_010102010*PR_020000002010+Q_010102110*PR_020000002011+Q_010202010*PR_020000002020+Q_010202110*PR_020000002021+Q_110002010*PR_020000002100+Q_110002110*PR_020000002101+Q_110102010*PR_020000002110+Q_110102110*PR_020000002111+Q_110202010*PR_020000002120+Q_110202110*PR_020000002121); ans_temp[ans_id*36+3]+=Pmtrx[33]*(Q_011000011*PR_020000002000+Q_011000111*PR_020000002001+Q_011000211*PR_020000002002+Q_111000011*PR_020000002100+Q_111000111*PR_020000002101+Q_111000211*PR_020000002102+Q_211000011*PR_020000002200+Q_211000111*PR_020000002201+Q_211000211*PR_020000002202); ans_temp[ans_id*36+3]+=Pmtrx[34]*(Q_010001011*PR_020000002000+Q_010001111*PR_020000002001+Q_010001211*PR_020000002002+Q_010101011*PR_020000002010+Q_010101111*PR_020000002011+Q_010101211*PR_020000002012+Q_110001011*PR_020000002100+Q_110001111*PR_020000002101+Q_110001211*PR_020000002102+Q_110101011*PR_020000002110+Q_110101111*PR_020000002111+Q_110101211*PR_020000002112); ans_temp[ans_id*36+3]+=Pmtrx[35]*(Q_010000012*PR_020000002000+Q_010000112*PR_020000002001+Q_010000212*PR_020000002002+Q_010000312*PR_020000002003+Q_110000012*PR_020000002100+Q_110000112*PR_020000002101+Q_110000212*PR_020000002102+Q_110000312*PR_020000002103); ans_temp[ans_id*36+4]+=Pmtrx[30]*(Q_002010010*PR_020000002000+Q_002010110*PR_020000002001+Q_002110010*PR_020000002010+Q_002110110*PR_020000002011+Q_102010010*PR_020000002100+Q_102010110*PR_020000002101+Q_102110010*PR_020000002110+Q_102110110*PR_020000002111+Q_202010010*PR_020000002200+Q_202010110*PR_020000002201+Q_202110010*PR_020000002210+Q_202110110*PR_020000002211); ans_temp[ans_id*36+4]+=Pmtrx[31]*(Q_001011010*PR_020000002000+Q_001011110*PR_020000002001+Q_001111010*PR_020000002010+Q_001111110*PR_020000002011+Q_001211010*PR_020000002020+Q_001211110*PR_020000002021+Q_101011010*PR_020000002100+Q_101011110*PR_020000002101+Q_101111010*PR_020000002110+Q_101111110*PR_020000002111+Q_101211010*PR_020000002120+Q_101211110*PR_020000002121); ans_temp[ans_id*36+4]+=Pmtrx[32]*(Q_000012010*PR_020000002000+Q_000012110*PR_020000002001+Q_000112010*PR_020000002010+Q_000112110*PR_020000002011+Q_000212010*PR_020000002020+Q_000212110*PR_020000002021+Q_000312010*PR_020000002030+Q_000312110*PR_020000002031); ans_temp[ans_id*36+4]+=Pmtrx[33]*(Q_001010011*PR_020000002000+Q_001010111*PR_020000002001+Q_001010211*PR_020000002002+Q_001110011*PR_020000002010+Q_001110111*PR_020000002011+Q_001110211*PR_020000002012+Q_101010011*PR_020000002100+Q_101010111*PR_020000002101+Q_101010211*PR_020000002102+Q_101110011*PR_020000002110+Q_101110111*PR_020000002111+Q_101110211*PR_020000002112); ans_temp[ans_id*36+4]+=Pmtrx[34]*(Q_000011011*PR_020000002000+Q_000011111*PR_020000002001+Q_000011211*PR_020000002002+Q_000111011*PR_020000002010+Q_000111111*PR_020000002011+Q_000111211*PR_020000002012+Q_000211011*PR_020000002020+Q_000211111*PR_020000002021+Q_000211211*PR_020000002022); ans_temp[ans_id*36+4]+=Pmtrx[35]*(Q_000010012*PR_020000002000+Q_000010112*PR_020000002001+Q_000010212*PR_020000002002+Q_000010312*PR_020000002003+Q_000110012*PR_020000002010+Q_000110112*PR_020000002011+Q_000110212*PR_020000002012+Q_000110312*PR_020000002013); ans_temp[ans_id*36+5]+=Pmtrx[30]*(Q_002000020*PR_020000002000+Q_002000120*PR_020000002001+Q_002000220*PR_020000002002+Q_102000020*PR_020000002100+Q_102000120*PR_020000002101+Q_102000220*PR_020000002102+Q_202000020*PR_020000002200+Q_202000120*PR_020000002201+Q_202000220*PR_020000002202); ans_temp[ans_id*36+5]+=Pmtrx[31]*(Q_001001020*PR_020000002000+Q_001001120*PR_020000002001+Q_001001220*PR_020000002002+Q_001101020*PR_020000002010+Q_001101120*PR_020000002011+Q_001101220*PR_020000002012+Q_101001020*PR_020000002100+Q_101001120*PR_020000002101+Q_101001220*PR_020000002102+Q_101101020*PR_020000002110+Q_101101120*PR_020000002111+Q_101101220*PR_020000002112); ans_temp[ans_id*36+5]+=Pmtrx[32]*(Q_000002020*PR_020000002000+Q_000002120*PR_020000002001+Q_000002220*PR_020000002002+Q_000102020*PR_020000002010+Q_000102120*PR_020000002011+Q_000102220*PR_020000002012+Q_000202020*PR_020000002020+Q_000202120*PR_020000002021+Q_000202220*PR_020000002022); ans_temp[ans_id*36+5]+=Pmtrx[33]*(Q_001000021*PR_020000002000+Q_001000121*PR_020000002001+Q_001000221*PR_020000002002+Q_001000321*PR_020000002003+Q_101000021*PR_020000002100+Q_101000121*PR_020000002101+Q_101000221*PR_020000002102+Q_101000321*PR_020000002103); ans_temp[ans_id*36+5]+=Pmtrx[34]*(Q_000001021*PR_020000002000+Q_000001121*PR_020000002001+Q_000001221*PR_020000002002+Q_000001321*PR_020000002003+Q_000101021*PR_020000002010+Q_000101121*PR_020000002011+Q_000101221*PR_020000002012+Q_000101321*PR_020000002013); ans_temp[ans_id*36+5]+=Pmtrx[35]*(Q_000000022*PR_020000002000+Q_000000122*PR_020000002001+Q_000000222*PR_020000002002+Q_000000322*PR_020000002003+Q_000000422*PR_020000002004); ans_temp[ans_id*36+6]+=Pmtrx[0]*(Q_022000000*PR_012010000000+Q_122000000*PR_012010000100+Q_222000000*PR_012010000200+Q_322000000*PR_012010000300+Q_422000000*PR_012010000400); ans_temp[ans_id*36+6]+=Pmtrx[1]*(Q_021001000*PR_012010000000+Q_021101000*PR_012010000010+Q_121001000*PR_012010000100+Q_121101000*PR_012010000110+Q_221001000*PR_012010000200+Q_221101000*PR_012010000210+Q_321001000*PR_012010000300+Q_321101000*PR_012010000310); ans_temp[ans_id*36+6]+=Pmtrx[2]*(Q_020002000*PR_012010000000+Q_020102000*PR_012010000010+Q_020202000*PR_012010000020+Q_120002000*PR_012010000100+Q_120102000*PR_012010000110+Q_120202000*PR_012010000120+Q_220002000*PR_012010000200+Q_220102000*PR_012010000210+Q_220202000*PR_012010000220); ans_temp[ans_id*36+6]+=Pmtrx[3]*(Q_021000001*PR_012010000000+Q_021000101*PR_012010000001+Q_121000001*PR_012010000100+Q_121000101*PR_012010000101+Q_221000001*PR_012010000200+Q_221000101*PR_012010000201+Q_321000001*PR_012010000300+Q_321000101*PR_012010000301); ans_temp[ans_id*36+6]+=Pmtrx[4]*(Q_020001001*PR_012010000000+Q_020001101*PR_012010000001+Q_020101001*PR_012010000010+Q_020101101*PR_012010000011+Q_120001001*PR_012010000100+Q_120001101*PR_012010000101+Q_120101001*PR_012010000110+Q_120101101*PR_012010000111+Q_220001001*PR_012010000200+Q_220001101*PR_012010000201+Q_220101001*PR_012010000210+Q_220101101*PR_012010000211); ans_temp[ans_id*36+6]+=Pmtrx[5]*(Q_020000002*PR_012010000000+Q_020000102*PR_012010000001+Q_020000202*PR_012010000002+Q_120000002*PR_012010000100+Q_120000102*PR_012010000101+Q_120000202*PR_012010000102+Q_220000002*PR_012010000200+Q_220000102*PR_012010000201+Q_220000202*PR_012010000202); ans_temp[ans_id*36+7]+=Pmtrx[0]*(Q_012010000*PR_012010000000+Q_012110000*PR_012010000010+Q_112010000*PR_012010000100+Q_112110000*PR_012010000110+Q_212010000*PR_012010000200+Q_212110000*PR_012010000210+Q_312010000*PR_012010000300+Q_312110000*PR_012010000310); ans_temp[ans_id*36+7]+=Pmtrx[1]*(Q_011011000*PR_012010000000+Q_011111000*PR_012010000010+Q_011211000*PR_012010000020+Q_111011000*PR_012010000100+Q_111111000*PR_012010000110+Q_111211000*PR_012010000120+Q_211011000*PR_012010000200+Q_211111000*PR_012010000210+Q_211211000*PR_012010000220); ans_temp[ans_id*36+7]+=Pmtrx[2]*(Q_010012000*PR_012010000000+Q_010112000*PR_012010000010+Q_010212000*PR_012010000020+Q_010312000*PR_012010000030+Q_110012000*PR_012010000100+Q_110112000*PR_012010000110+Q_110212000*PR_012010000120+Q_110312000*PR_012010000130); ans_temp[ans_id*36+7]+=Pmtrx[3]*(Q_011010001*PR_012010000000+Q_011010101*PR_012010000001+Q_011110001*PR_012010000010+Q_011110101*PR_012010000011+Q_111010001*PR_012010000100+Q_111010101*PR_012010000101+Q_111110001*PR_012010000110+Q_111110101*PR_012010000111+Q_211010001*PR_012010000200+Q_211010101*PR_012010000201+Q_211110001*PR_012010000210+Q_211110101*PR_012010000211); ans_temp[ans_id*36+7]+=Pmtrx[4]*(Q_010011001*PR_012010000000+Q_010011101*PR_012010000001+Q_010111001*PR_012010000010+Q_010111101*PR_012010000011+Q_010211001*PR_012010000020+Q_010211101*PR_012010000021+Q_110011001*PR_012010000100+Q_110011101*PR_012010000101+Q_110111001*PR_012010000110+Q_110111101*PR_012010000111+Q_110211001*PR_012010000120+Q_110211101*PR_012010000121); ans_temp[ans_id*36+7]+=Pmtrx[5]*(Q_010010002*PR_012010000000+Q_010010102*PR_012010000001+Q_010010202*PR_012010000002+Q_010110002*PR_012010000010+Q_010110102*PR_012010000011+Q_010110202*PR_012010000012+Q_110010002*PR_012010000100+Q_110010102*PR_012010000101+Q_110010202*PR_012010000102+Q_110110002*PR_012010000110+Q_110110102*PR_012010000111+Q_110110202*PR_012010000112); ans_temp[ans_id*36+8]+=Pmtrx[0]*(Q_002020000*PR_012010000000+Q_002120000*PR_012010000010+Q_002220000*PR_012010000020+Q_102020000*PR_012010000100+Q_102120000*PR_012010000110+Q_102220000*PR_012010000120+Q_202020000*PR_012010000200+Q_202120000*PR_012010000210+Q_202220000*PR_012010000220); ans_temp[ans_id*36+8]+=Pmtrx[1]*(Q_001021000*PR_012010000000+Q_001121000*PR_012010000010+Q_001221000*PR_012010000020+Q_001321000*PR_012010000030+Q_101021000*PR_012010000100+Q_101121000*PR_012010000110+Q_101221000*PR_012010000120+Q_101321000*PR_012010000130); ans_temp[ans_id*36+8]+=Pmtrx[2]*(Q_000022000*PR_012010000000+Q_000122000*PR_012010000010+Q_000222000*PR_012010000020+Q_000322000*PR_012010000030+Q_000422000*PR_012010000040); ans_temp[ans_id*36+8]+=Pmtrx[3]*(Q_001020001*PR_012010000000+Q_001020101*PR_012010000001+Q_001120001*PR_012010000010+Q_001120101*PR_012010000011+Q_001220001*PR_012010000020+Q_001220101*PR_012010000021+Q_101020001*PR_012010000100+Q_101020101*PR_012010000101+Q_101120001*PR_012010000110+Q_101120101*PR_012010000111+Q_101220001*PR_012010000120+Q_101220101*PR_012010000121); ans_temp[ans_id*36+8]+=Pmtrx[4]*(Q_000021001*PR_012010000000+Q_000021101*PR_012010000001+Q_000121001*PR_012010000010+Q_000121101*PR_012010000011+Q_000221001*PR_012010000020+Q_000221101*PR_012010000021+Q_000321001*PR_012010000030+Q_000321101*PR_012010000031); ans_temp[ans_id*36+8]+=Pmtrx[5]*(Q_000020002*PR_012010000000+Q_000020102*PR_012010000001+Q_000020202*PR_012010000002+Q_000120002*PR_012010000010+Q_000120102*PR_012010000011+Q_000120202*PR_012010000012+Q_000220002*PR_012010000020+Q_000220102*PR_012010000021+Q_000220202*PR_012010000022); ans_temp[ans_id*36+9]+=Pmtrx[0]*(Q_012000010*PR_012010000000+Q_012000110*PR_012010000001+Q_112000010*PR_012010000100+Q_112000110*PR_012010000101+Q_212000010*PR_012010000200+Q_212000110*PR_012010000201+Q_312000010*PR_012010000300+Q_312000110*PR_012010000301); ans_temp[ans_id*36+9]+=Pmtrx[1]*(Q_011001010*PR_012010000000+Q_011001110*PR_012010000001+Q_011101010*PR_012010000010+Q_011101110*PR_012010000011+Q_111001010*PR_012010000100+Q_111001110*PR_012010000101+Q_111101010*PR_012010000110+Q_111101110*PR_012010000111+Q_211001010*PR_012010000200+Q_211001110*PR_012010000201+Q_211101010*PR_012010000210+Q_211101110*PR_012010000211); ans_temp[ans_id*36+9]+=Pmtrx[2]*(Q_010002010*PR_012010000000+Q_010002110*PR_012010000001+Q_010102010*PR_012010000010+Q_010102110*PR_012010000011+Q_010202010*PR_012010000020+Q_010202110*PR_012010000021+Q_110002010*PR_012010000100+Q_110002110*PR_012010000101+Q_110102010*PR_012010000110+Q_110102110*PR_012010000111+Q_110202010*PR_012010000120+Q_110202110*PR_012010000121); ans_temp[ans_id*36+9]+=Pmtrx[3]*(Q_011000011*PR_012010000000+Q_011000111*PR_012010000001+Q_011000211*PR_012010000002+Q_111000011*PR_012010000100+Q_111000111*PR_012010000101+Q_111000211*PR_012010000102+Q_211000011*PR_012010000200+Q_211000111*PR_012010000201+Q_211000211*PR_012010000202); ans_temp[ans_id*36+9]+=Pmtrx[4]*(Q_010001011*PR_012010000000+Q_010001111*PR_012010000001+Q_010001211*PR_012010000002+Q_010101011*PR_012010000010+Q_010101111*PR_012010000011+Q_010101211*PR_012010000012+Q_110001011*PR_012010000100+Q_110001111*PR_012010000101+Q_110001211*PR_012010000102+Q_110101011*PR_012010000110+Q_110101111*PR_012010000111+Q_110101211*PR_012010000112); ans_temp[ans_id*36+9]+=Pmtrx[5]*(Q_010000012*PR_012010000000+Q_010000112*PR_012010000001+Q_010000212*PR_012010000002+Q_010000312*PR_012010000003+Q_110000012*PR_012010000100+Q_110000112*PR_012010000101+Q_110000212*PR_012010000102+Q_110000312*PR_012010000103); ans_temp[ans_id*36+10]+=Pmtrx[0]*(Q_002010010*PR_012010000000+Q_002010110*PR_012010000001+Q_002110010*PR_012010000010+Q_002110110*PR_012010000011+Q_102010010*PR_012010000100+Q_102010110*PR_012010000101+Q_102110010*PR_012010000110+Q_102110110*PR_012010000111+Q_202010010*PR_012010000200+Q_202010110*PR_012010000201+Q_202110010*PR_012010000210+Q_202110110*PR_012010000211); ans_temp[ans_id*36+10]+=Pmtrx[1]*(Q_001011010*PR_012010000000+Q_001011110*PR_012010000001+Q_001111010*PR_012010000010+Q_001111110*PR_012010000011+Q_001211010*PR_012010000020+Q_001211110*PR_012010000021+Q_101011010*PR_012010000100+Q_101011110*PR_012010000101+Q_101111010*PR_012010000110+Q_101111110*PR_012010000111+Q_101211010*PR_012010000120+Q_101211110*PR_012010000121); ans_temp[ans_id*36+10]+=Pmtrx[2]*(Q_000012010*PR_012010000000+Q_000012110*PR_012010000001+Q_000112010*PR_012010000010+Q_000112110*PR_012010000011+Q_000212010*PR_012010000020+Q_000212110*PR_012010000021+Q_000312010*PR_012010000030+Q_000312110*PR_012010000031); ans_temp[ans_id*36+10]+=Pmtrx[3]*(Q_001010011*PR_012010000000+Q_001010111*PR_012010000001+Q_001010211*PR_012010000002+Q_001110011*PR_012010000010+Q_001110111*PR_012010000011+Q_001110211*PR_012010000012+Q_101010011*PR_012010000100+Q_101010111*PR_012010000101+Q_101010211*PR_012010000102+Q_101110011*PR_012010000110+Q_101110111*PR_012010000111+Q_101110211*PR_012010000112); ans_temp[ans_id*36+10]+=Pmtrx[4]*(Q_000011011*PR_012010000000+Q_000011111*PR_012010000001+Q_000011211*PR_012010000002+Q_000111011*PR_012010000010+Q_000111111*PR_012010000011+Q_000111211*PR_012010000012+Q_000211011*PR_012010000020+Q_000211111*PR_012010000021+Q_000211211*PR_012010000022); ans_temp[ans_id*36+10]+=Pmtrx[5]*(Q_000010012*PR_012010000000+Q_000010112*PR_012010000001+Q_000010212*PR_012010000002+Q_000010312*PR_012010000003+Q_000110012*PR_012010000010+Q_000110112*PR_012010000011+Q_000110212*PR_012010000012+Q_000110312*PR_012010000013); ans_temp[ans_id*36+11]+=Pmtrx[0]*(Q_002000020*PR_012010000000+Q_002000120*PR_012010000001+Q_002000220*PR_012010000002+Q_102000020*PR_012010000100+Q_102000120*PR_012010000101+Q_102000220*PR_012010000102+Q_202000020*PR_012010000200+Q_202000120*PR_012010000201+Q_202000220*PR_012010000202); ans_temp[ans_id*36+11]+=Pmtrx[1]*(Q_001001020*PR_012010000000+Q_001001120*PR_012010000001+Q_001001220*PR_012010000002+Q_001101020*PR_012010000010+Q_001101120*PR_012010000011+Q_001101220*PR_012010000012+Q_101001020*PR_012010000100+Q_101001120*PR_012010000101+Q_101001220*PR_012010000102+Q_101101020*PR_012010000110+Q_101101120*PR_012010000111+Q_101101220*PR_012010000112); ans_temp[ans_id*36+11]+=Pmtrx[2]*(Q_000002020*PR_012010000000+Q_000002120*PR_012010000001+Q_000002220*PR_012010000002+Q_000102020*PR_012010000010+Q_000102120*PR_012010000011+Q_000102220*PR_012010000012+Q_000202020*PR_012010000020+Q_000202120*PR_012010000021+Q_000202220*PR_012010000022); ans_temp[ans_id*36+11]+=Pmtrx[3]*(Q_001000021*PR_012010000000+Q_001000121*PR_012010000001+Q_001000221*PR_012010000002+Q_001000321*PR_012010000003+Q_101000021*PR_012010000100+Q_101000121*PR_012010000101+Q_101000221*PR_012010000102+Q_101000321*PR_012010000103); ans_temp[ans_id*36+11]+=Pmtrx[4]*(Q_000001021*PR_012010000000+Q_000001121*PR_012010000001+Q_000001221*PR_012010000002+Q_000001321*PR_012010000003+Q_000101021*PR_012010000010+Q_000101121*PR_012010000011+Q_000101221*PR_012010000012+Q_000101321*PR_012010000013); ans_temp[ans_id*36+11]+=Pmtrx[5]*(Q_000000022*PR_012010000000+Q_000000122*PR_012010000001+Q_000000222*PR_012010000002+Q_000000322*PR_012010000003+Q_000000422*PR_012010000004); ans_temp[ans_id*36+6]+=Pmtrx[6]*(Q_022000000*PR_011011000000+Q_122000000*PR_011011000100+Q_222000000*PR_011011000200+Q_322000000*PR_011011000300+Q_422000000*PR_011011000400); ans_temp[ans_id*36+6]+=Pmtrx[7]*(Q_021001000*PR_011011000000+Q_021101000*PR_011011000010+Q_121001000*PR_011011000100+Q_121101000*PR_011011000110+Q_221001000*PR_011011000200+Q_221101000*PR_011011000210+Q_321001000*PR_011011000300+Q_321101000*PR_011011000310); ans_temp[ans_id*36+6]+=Pmtrx[8]*(Q_020002000*PR_011011000000+Q_020102000*PR_011011000010+Q_020202000*PR_011011000020+Q_120002000*PR_011011000100+Q_120102000*PR_011011000110+Q_120202000*PR_011011000120+Q_220002000*PR_011011000200+Q_220102000*PR_011011000210+Q_220202000*PR_011011000220); ans_temp[ans_id*36+6]+=Pmtrx[9]*(Q_021000001*PR_011011000000+Q_021000101*PR_011011000001+Q_121000001*PR_011011000100+Q_121000101*PR_011011000101+Q_221000001*PR_011011000200+Q_221000101*PR_011011000201+Q_321000001*PR_011011000300+Q_321000101*PR_011011000301); ans_temp[ans_id*36+6]+=Pmtrx[10]*(Q_020001001*PR_011011000000+Q_020001101*PR_011011000001+Q_020101001*PR_011011000010+Q_020101101*PR_011011000011+Q_120001001*PR_011011000100+Q_120001101*PR_011011000101+Q_120101001*PR_011011000110+Q_120101101*PR_011011000111+Q_220001001*PR_011011000200+Q_220001101*PR_011011000201+Q_220101001*PR_011011000210+Q_220101101*PR_011011000211); ans_temp[ans_id*36+6]+=Pmtrx[11]*(Q_020000002*PR_011011000000+Q_020000102*PR_011011000001+Q_020000202*PR_011011000002+Q_120000002*PR_011011000100+Q_120000102*PR_011011000101+Q_120000202*PR_011011000102+Q_220000002*PR_011011000200+Q_220000102*PR_011011000201+Q_220000202*PR_011011000202); ans_temp[ans_id*36+7]+=Pmtrx[6]*(Q_012010000*PR_011011000000+Q_012110000*PR_011011000010+Q_112010000*PR_011011000100+Q_112110000*PR_011011000110+Q_212010000*PR_011011000200+Q_212110000*PR_011011000210+Q_312010000*PR_011011000300+Q_312110000*PR_011011000310); ans_temp[ans_id*36+7]+=Pmtrx[7]*(Q_011011000*PR_011011000000+Q_011111000*PR_011011000010+Q_011211000*PR_011011000020+Q_111011000*PR_011011000100+Q_111111000*PR_011011000110+Q_111211000*PR_011011000120+Q_211011000*PR_011011000200+Q_211111000*PR_011011000210+Q_211211000*PR_011011000220); ans_temp[ans_id*36+7]+=Pmtrx[8]*(Q_010012000*PR_011011000000+Q_010112000*PR_011011000010+Q_010212000*PR_011011000020+Q_010312000*PR_011011000030+Q_110012000*PR_011011000100+Q_110112000*PR_011011000110+Q_110212000*PR_011011000120+Q_110312000*PR_011011000130); ans_temp[ans_id*36+7]+=Pmtrx[9]*(Q_011010001*PR_011011000000+Q_011010101*PR_011011000001+Q_011110001*PR_011011000010+Q_011110101*PR_011011000011+Q_111010001*PR_011011000100+Q_111010101*PR_011011000101+Q_111110001*PR_011011000110+Q_111110101*PR_011011000111+Q_211010001*PR_011011000200+Q_211010101*PR_011011000201+Q_211110001*PR_011011000210+Q_211110101*PR_011011000211); ans_temp[ans_id*36+7]+=Pmtrx[10]*(Q_010011001*PR_011011000000+Q_010011101*PR_011011000001+Q_010111001*PR_011011000010+Q_010111101*PR_011011000011+Q_010211001*PR_011011000020+Q_010211101*PR_011011000021+Q_110011001*PR_011011000100+Q_110011101*PR_011011000101+Q_110111001*PR_011011000110+Q_110111101*PR_011011000111+Q_110211001*PR_011011000120+Q_110211101*PR_011011000121); ans_temp[ans_id*36+7]+=Pmtrx[11]*(Q_010010002*PR_011011000000+Q_010010102*PR_011011000001+Q_010010202*PR_011011000002+Q_010110002*PR_011011000010+Q_010110102*PR_011011000011+Q_010110202*PR_011011000012+Q_110010002*PR_011011000100+Q_110010102*PR_011011000101+Q_110010202*PR_011011000102+Q_110110002*PR_011011000110+Q_110110102*PR_011011000111+Q_110110202*PR_011011000112); ans_temp[ans_id*36+8]+=Pmtrx[6]*(Q_002020000*PR_011011000000+Q_002120000*PR_011011000010+Q_002220000*PR_011011000020+Q_102020000*PR_011011000100+Q_102120000*PR_011011000110+Q_102220000*PR_011011000120+Q_202020000*PR_011011000200+Q_202120000*PR_011011000210+Q_202220000*PR_011011000220); ans_temp[ans_id*36+8]+=Pmtrx[7]*(Q_001021000*PR_011011000000+Q_001121000*PR_011011000010+Q_001221000*PR_011011000020+Q_001321000*PR_011011000030+Q_101021000*PR_011011000100+Q_101121000*PR_011011000110+Q_101221000*PR_011011000120+Q_101321000*PR_011011000130); ans_temp[ans_id*36+8]+=Pmtrx[8]*(Q_000022000*PR_011011000000+Q_000122000*PR_011011000010+Q_000222000*PR_011011000020+Q_000322000*PR_011011000030+Q_000422000*PR_011011000040); ans_temp[ans_id*36+8]+=Pmtrx[9]*(Q_001020001*PR_011011000000+Q_001020101*PR_011011000001+Q_001120001*PR_011011000010+Q_001120101*PR_011011000011+Q_001220001*PR_011011000020+Q_001220101*PR_011011000021+Q_101020001*PR_011011000100+Q_101020101*PR_011011000101+Q_101120001*PR_011011000110+Q_101120101*PR_011011000111+Q_101220001*PR_011011000120+Q_101220101*PR_011011000121); ans_temp[ans_id*36+8]+=Pmtrx[10]*(Q_000021001*PR_011011000000+Q_000021101*PR_011011000001+Q_000121001*PR_011011000010+Q_000121101*PR_011011000011+Q_000221001*PR_011011000020+Q_000221101*PR_011011000021+Q_000321001*PR_011011000030+Q_000321101*PR_011011000031); ans_temp[ans_id*36+8]+=Pmtrx[11]*(Q_000020002*PR_011011000000+Q_000020102*PR_011011000001+Q_000020202*PR_011011000002+Q_000120002*PR_011011000010+Q_000120102*PR_011011000011+Q_000120202*PR_011011000012+Q_000220002*PR_011011000020+Q_000220102*PR_011011000021+Q_000220202*PR_011011000022); ans_temp[ans_id*36+9]+=Pmtrx[6]*(Q_012000010*PR_011011000000+Q_012000110*PR_011011000001+Q_112000010*PR_011011000100+Q_112000110*PR_011011000101+Q_212000010*PR_011011000200+Q_212000110*PR_011011000201+Q_312000010*PR_011011000300+Q_312000110*PR_011011000301); ans_temp[ans_id*36+9]+=Pmtrx[7]*(Q_011001010*PR_011011000000+Q_011001110*PR_011011000001+Q_011101010*PR_011011000010+Q_011101110*PR_011011000011+Q_111001010*PR_011011000100+Q_111001110*PR_011011000101+Q_111101010*PR_011011000110+Q_111101110*PR_011011000111+Q_211001010*PR_011011000200+Q_211001110*PR_011011000201+Q_211101010*PR_011011000210+Q_211101110*PR_011011000211); ans_temp[ans_id*36+9]+=Pmtrx[8]*(Q_010002010*PR_011011000000+Q_010002110*PR_011011000001+Q_010102010*PR_011011000010+Q_010102110*PR_011011000011+Q_010202010*PR_011011000020+Q_010202110*PR_011011000021+Q_110002010*PR_011011000100+Q_110002110*PR_011011000101+Q_110102010*PR_011011000110+Q_110102110*PR_011011000111+Q_110202010*PR_011011000120+Q_110202110*PR_011011000121); ans_temp[ans_id*36+9]+=Pmtrx[9]*(Q_011000011*PR_011011000000+Q_011000111*PR_011011000001+Q_011000211*PR_011011000002+Q_111000011*PR_011011000100+Q_111000111*PR_011011000101+Q_111000211*PR_011011000102+Q_211000011*PR_011011000200+Q_211000111*PR_011011000201+Q_211000211*PR_011011000202); ans_temp[ans_id*36+9]+=Pmtrx[10]*(Q_010001011*PR_011011000000+Q_010001111*PR_011011000001+Q_010001211*PR_011011000002+Q_010101011*PR_011011000010+Q_010101111*PR_011011000011+Q_010101211*PR_011011000012+Q_110001011*PR_011011000100+Q_110001111*PR_011011000101+Q_110001211*PR_011011000102+Q_110101011*PR_011011000110+Q_110101111*PR_011011000111+Q_110101211*PR_011011000112); ans_temp[ans_id*36+9]+=Pmtrx[11]*(Q_010000012*PR_011011000000+Q_010000112*PR_011011000001+Q_010000212*PR_011011000002+Q_010000312*PR_011011000003+Q_110000012*PR_011011000100+Q_110000112*PR_011011000101+Q_110000212*PR_011011000102+Q_110000312*PR_011011000103); ans_temp[ans_id*36+10]+=Pmtrx[6]*(Q_002010010*PR_011011000000+Q_002010110*PR_011011000001+Q_002110010*PR_011011000010+Q_002110110*PR_011011000011+Q_102010010*PR_011011000100+Q_102010110*PR_011011000101+Q_102110010*PR_011011000110+Q_102110110*PR_011011000111+Q_202010010*PR_011011000200+Q_202010110*PR_011011000201+Q_202110010*PR_011011000210+Q_202110110*PR_011011000211); ans_temp[ans_id*36+10]+=Pmtrx[7]*(Q_001011010*PR_011011000000+Q_001011110*PR_011011000001+Q_001111010*PR_011011000010+Q_001111110*PR_011011000011+Q_001211010*PR_011011000020+Q_001211110*PR_011011000021+Q_101011010*PR_011011000100+Q_101011110*PR_011011000101+Q_101111010*PR_011011000110+Q_101111110*PR_011011000111+Q_101211010*PR_011011000120+Q_101211110*PR_011011000121); ans_temp[ans_id*36+10]+=Pmtrx[8]*(Q_000012010*PR_011011000000+Q_000012110*PR_011011000001+Q_000112010*PR_011011000010+Q_000112110*PR_011011000011+Q_000212010*PR_011011000020+Q_000212110*PR_011011000021+Q_000312010*PR_011011000030+Q_000312110*PR_011011000031); ans_temp[ans_id*36+10]+=Pmtrx[9]*(Q_001010011*PR_011011000000+Q_001010111*PR_011011000001+Q_001010211*PR_011011000002+Q_001110011*PR_011011000010+Q_001110111*PR_011011000011+Q_001110211*PR_011011000012+Q_101010011*PR_011011000100+Q_101010111*PR_011011000101+Q_101010211*PR_011011000102+Q_101110011*PR_011011000110+Q_101110111*PR_011011000111+Q_101110211*PR_011011000112); ans_temp[ans_id*36+10]+=Pmtrx[10]*(Q_000011011*PR_011011000000+Q_000011111*PR_011011000001+Q_000011211*PR_011011000002+Q_000111011*PR_011011000010+Q_000111111*PR_011011000011+Q_000111211*PR_011011000012+Q_000211011*PR_011011000020+Q_000211111*PR_011011000021+Q_000211211*PR_011011000022); ans_temp[ans_id*36+10]+=Pmtrx[11]*(Q_000010012*PR_011011000000+Q_000010112*PR_011011000001+Q_000010212*PR_011011000002+Q_000010312*PR_011011000003+Q_000110012*PR_011011000010+Q_000110112*PR_011011000011+Q_000110212*PR_011011000012+Q_000110312*PR_011011000013); ans_temp[ans_id*36+11]+=Pmtrx[6]*(Q_002000020*PR_011011000000+Q_002000120*PR_011011000001+Q_002000220*PR_011011000002+Q_102000020*PR_011011000100+Q_102000120*PR_011011000101+Q_102000220*PR_011011000102+Q_202000020*PR_011011000200+Q_202000120*PR_011011000201+Q_202000220*PR_011011000202); ans_temp[ans_id*36+11]+=Pmtrx[7]*(Q_001001020*PR_011011000000+Q_001001120*PR_011011000001+Q_001001220*PR_011011000002+Q_001101020*PR_011011000010+Q_001101120*PR_011011000011+Q_001101220*PR_011011000012+Q_101001020*PR_011011000100+Q_101001120*PR_011011000101+Q_101001220*PR_011011000102+Q_101101020*PR_011011000110+Q_101101120*PR_011011000111+Q_101101220*PR_011011000112); ans_temp[ans_id*36+11]+=Pmtrx[8]*(Q_000002020*PR_011011000000+Q_000002120*PR_011011000001+Q_000002220*PR_011011000002+Q_000102020*PR_011011000010+Q_000102120*PR_011011000011+Q_000102220*PR_011011000012+Q_000202020*PR_011011000020+Q_000202120*PR_011011000021+Q_000202220*PR_011011000022); ans_temp[ans_id*36+11]+=Pmtrx[9]*(Q_001000021*PR_011011000000+Q_001000121*PR_011011000001+Q_001000221*PR_011011000002+Q_001000321*PR_011011000003+Q_101000021*PR_011011000100+Q_101000121*PR_011011000101+Q_101000221*PR_011011000102+Q_101000321*PR_011011000103); ans_temp[ans_id*36+11]+=Pmtrx[10]*(Q_000001021*PR_011011000000+Q_000001121*PR_011011000001+Q_000001221*PR_011011000002+Q_000001321*PR_011011000003+Q_000101021*PR_011011000010+Q_000101121*PR_011011000011+Q_000101221*PR_011011000012+Q_000101321*PR_011011000013); ans_temp[ans_id*36+11]+=Pmtrx[11]*(Q_000000022*PR_011011000000+Q_000000122*PR_011011000001+Q_000000222*PR_011011000002+Q_000000322*PR_011011000003+Q_000000422*PR_011011000004); ans_temp[ans_id*36+6]+=Pmtrx[12]*(Q_022000000*PR_010012000000+Q_122000000*PR_010012000100+Q_222000000*PR_010012000200+Q_322000000*PR_010012000300+Q_422000000*PR_010012000400); ans_temp[ans_id*36+6]+=Pmtrx[13]*(Q_021001000*PR_010012000000+Q_021101000*PR_010012000010+Q_121001000*PR_010012000100+Q_121101000*PR_010012000110+Q_221001000*PR_010012000200+Q_221101000*PR_010012000210+Q_321001000*PR_010012000300+Q_321101000*PR_010012000310); ans_temp[ans_id*36+6]+=Pmtrx[14]*(Q_020002000*PR_010012000000+Q_020102000*PR_010012000010+Q_020202000*PR_010012000020+Q_120002000*PR_010012000100+Q_120102000*PR_010012000110+Q_120202000*PR_010012000120+Q_220002000*PR_010012000200+Q_220102000*PR_010012000210+Q_220202000*PR_010012000220); ans_temp[ans_id*36+6]+=Pmtrx[15]*(Q_021000001*PR_010012000000+Q_021000101*PR_010012000001+Q_121000001*PR_010012000100+Q_121000101*PR_010012000101+Q_221000001*PR_010012000200+Q_221000101*PR_010012000201+Q_321000001*PR_010012000300+Q_321000101*PR_010012000301); ans_temp[ans_id*36+6]+=Pmtrx[16]*(Q_020001001*PR_010012000000+Q_020001101*PR_010012000001+Q_020101001*PR_010012000010+Q_020101101*PR_010012000011+Q_120001001*PR_010012000100+Q_120001101*PR_010012000101+Q_120101001*PR_010012000110+Q_120101101*PR_010012000111+Q_220001001*PR_010012000200+Q_220001101*PR_010012000201+Q_220101001*PR_010012000210+Q_220101101*PR_010012000211); ans_temp[ans_id*36+6]+=Pmtrx[17]*(Q_020000002*PR_010012000000+Q_020000102*PR_010012000001+Q_020000202*PR_010012000002+Q_120000002*PR_010012000100+Q_120000102*PR_010012000101+Q_120000202*PR_010012000102+Q_220000002*PR_010012000200+Q_220000102*PR_010012000201+Q_220000202*PR_010012000202); ans_temp[ans_id*36+7]+=Pmtrx[12]*(Q_012010000*PR_010012000000+Q_012110000*PR_010012000010+Q_112010000*PR_010012000100+Q_112110000*PR_010012000110+Q_212010000*PR_010012000200+Q_212110000*PR_010012000210+Q_312010000*PR_010012000300+Q_312110000*PR_010012000310); ans_temp[ans_id*36+7]+=Pmtrx[13]*(Q_011011000*PR_010012000000+Q_011111000*PR_010012000010+Q_011211000*PR_010012000020+Q_111011000*PR_010012000100+Q_111111000*PR_010012000110+Q_111211000*PR_010012000120+Q_211011000*PR_010012000200+Q_211111000*PR_010012000210+Q_211211000*PR_010012000220); ans_temp[ans_id*36+7]+=Pmtrx[14]*(Q_010012000*PR_010012000000+Q_010112000*PR_010012000010+Q_010212000*PR_010012000020+Q_010312000*PR_010012000030+Q_110012000*PR_010012000100+Q_110112000*PR_010012000110+Q_110212000*PR_010012000120+Q_110312000*PR_010012000130); ans_temp[ans_id*36+7]+=Pmtrx[15]*(Q_011010001*PR_010012000000+Q_011010101*PR_010012000001+Q_011110001*PR_010012000010+Q_011110101*PR_010012000011+Q_111010001*PR_010012000100+Q_111010101*PR_010012000101+Q_111110001*PR_010012000110+Q_111110101*PR_010012000111+Q_211010001*PR_010012000200+Q_211010101*PR_010012000201+Q_211110001*PR_010012000210+Q_211110101*PR_010012000211); ans_temp[ans_id*36+7]+=Pmtrx[16]*(Q_010011001*PR_010012000000+Q_010011101*PR_010012000001+Q_010111001*PR_010012000010+Q_010111101*PR_010012000011+Q_010211001*PR_010012000020+Q_010211101*PR_010012000021+Q_110011001*PR_010012000100+Q_110011101*PR_010012000101+Q_110111001*PR_010012000110+Q_110111101*PR_010012000111+Q_110211001*PR_010012000120+Q_110211101*PR_010012000121); ans_temp[ans_id*36+7]+=Pmtrx[17]*(Q_010010002*PR_010012000000+Q_010010102*PR_010012000001+Q_010010202*PR_010012000002+Q_010110002*PR_010012000010+Q_010110102*PR_010012000011+Q_010110202*PR_010012000012+Q_110010002*PR_010012000100+Q_110010102*PR_010012000101+Q_110010202*PR_010012000102+Q_110110002*PR_010012000110+Q_110110102*PR_010012000111+Q_110110202*PR_010012000112); ans_temp[ans_id*36+8]+=Pmtrx[12]*(Q_002020000*PR_010012000000+Q_002120000*PR_010012000010+Q_002220000*PR_010012000020+Q_102020000*PR_010012000100+Q_102120000*PR_010012000110+Q_102220000*PR_010012000120+Q_202020000*PR_010012000200+Q_202120000*PR_010012000210+Q_202220000*PR_010012000220); ans_temp[ans_id*36+8]+=Pmtrx[13]*(Q_001021000*PR_010012000000+Q_001121000*PR_010012000010+Q_001221000*PR_010012000020+Q_001321000*PR_010012000030+Q_101021000*PR_010012000100+Q_101121000*PR_010012000110+Q_101221000*PR_010012000120+Q_101321000*PR_010012000130); ans_temp[ans_id*36+8]+=Pmtrx[14]*(Q_000022000*PR_010012000000+Q_000122000*PR_010012000010+Q_000222000*PR_010012000020+Q_000322000*PR_010012000030+Q_000422000*PR_010012000040); ans_temp[ans_id*36+8]+=Pmtrx[15]*(Q_001020001*PR_010012000000+Q_001020101*PR_010012000001+Q_001120001*PR_010012000010+Q_001120101*PR_010012000011+Q_001220001*PR_010012000020+Q_001220101*PR_010012000021+Q_101020001*PR_010012000100+Q_101020101*PR_010012000101+Q_101120001*PR_010012000110+Q_101120101*PR_010012000111+Q_101220001*PR_010012000120+Q_101220101*PR_010012000121); ans_temp[ans_id*36+8]+=Pmtrx[16]*(Q_000021001*PR_010012000000+Q_000021101*PR_010012000001+Q_000121001*PR_010012000010+Q_000121101*PR_010012000011+Q_000221001*PR_010012000020+Q_000221101*PR_010012000021+Q_000321001*PR_010012000030+Q_000321101*PR_010012000031); ans_temp[ans_id*36+8]+=Pmtrx[17]*(Q_000020002*PR_010012000000+Q_000020102*PR_010012000001+Q_000020202*PR_010012000002+Q_000120002*PR_010012000010+Q_000120102*PR_010012000011+Q_000120202*PR_010012000012+Q_000220002*PR_010012000020+Q_000220102*PR_010012000021+Q_000220202*PR_010012000022); ans_temp[ans_id*36+9]+=Pmtrx[12]*(Q_012000010*PR_010012000000+Q_012000110*PR_010012000001+Q_112000010*PR_010012000100+Q_112000110*PR_010012000101+Q_212000010*PR_010012000200+Q_212000110*PR_010012000201+Q_312000010*PR_010012000300+Q_312000110*PR_010012000301); ans_temp[ans_id*36+9]+=Pmtrx[13]*(Q_011001010*PR_010012000000+Q_011001110*PR_010012000001+Q_011101010*PR_010012000010+Q_011101110*PR_010012000011+Q_111001010*PR_010012000100+Q_111001110*PR_010012000101+Q_111101010*PR_010012000110+Q_111101110*PR_010012000111+Q_211001010*PR_010012000200+Q_211001110*PR_010012000201+Q_211101010*PR_010012000210+Q_211101110*PR_010012000211); ans_temp[ans_id*36+9]+=Pmtrx[14]*(Q_010002010*PR_010012000000+Q_010002110*PR_010012000001+Q_010102010*PR_010012000010+Q_010102110*PR_010012000011+Q_010202010*PR_010012000020+Q_010202110*PR_010012000021+Q_110002010*PR_010012000100+Q_110002110*PR_010012000101+Q_110102010*PR_010012000110+Q_110102110*PR_010012000111+Q_110202010*PR_010012000120+Q_110202110*PR_010012000121); ans_temp[ans_id*36+9]+=Pmtrx[15]*(Q_011000011*PR_010012000000+Q_011000111*PR_010012000001+Q_011000211*PR_010012000002+Q_111000011*PR_010012000100+Q_111000111*PR_010012000101+Q_111000211*PR_010012000102+Q_211000011*PR_010012000200+Q_211000111*PR_010012000201+Q_211000211*PR_010012000202); ans_temp[ans_id*36+9]+=Pmtrx[16]*(Q_010001011*PR_010012000000+Q_010001111*PR_010012000001+Q_010001211*PR_010012000002+Q_010101011*PR_010012000010+Q_010101111*PR_010012000011+Q_010101211*PR_010012000012+Q_110001011*PR_010012000100+Q_110001111*PR_010012000101+Q_110001211*PR_010012000102+Q_110101011*PR_010012000110+Q_110101111*PR_010012000111+Q_110101211*PR_010012000112); ans_temp[ans_id*36+9]+=Pmtrx[17]*(Q_010000012*PR_010012000000+Q_010000112*PR_010012000001+Q_010000212*PR_010012000002+Q_010000312*PR_010012000003+Q_110000012*PR_010012000100+Q_110000112*PR_010012000101+Q_110000212*PR_010012000102+Q_110000312*PR_010012000103); ans_temp[ans_id*36+10]+=Pmtrx[12]*(Q_002010010*PR_010012000000+Q_002010110*PR_010012000001+Q_002110010*PR_010012000010+Q_002110110*PR_010012000011+Q_102010010*PR_010012000100+Q_102010110*PR_010012000101+Q_102110010*PR_010012000110+Q_102110110*PR_010012000111+Q_202010010*PR_010012000200+Q_202010110*PR_010012000201+Q_202110010*PR_010012000210+Q_202110110*PR_010012000211); ans_temp[ans_id*36+10]+=Pmtrx[13]*(Q_001011010*PR_010012000000+Q_001011110*PR_010012000001+Q_001111010*PR_010012000010+Q_001111110*PR_010012000011+Q_001211010*PR_010012000020+Q_001211110*PR_010012000021+Q_101011010*PR_010012000100+Q_101011110*PR_010012000101+Q_101111010*PR_010012000110+Q_101111110*PR_010012000111+Q_101211010*PR_010012000120+Q_101211110*PR_010012000121); ans_temp[ans_id*36+10]+=Pmtrx[14]*(Q_000012010*PR_010012000000+Q_000012110*PR_010012000001+Q_000112010*PR_010012000010+Q_000112110*PR_010012000011+Q_000212010*PR_010012000020+Q_000212110*PR_010012000021+Q_000312010*PR_010012000030+Q_000312110*PR_010012000031); ans_temp[ans_id*36+10]+=Pmtrx[15]*(Q_001010011*PR_010012000000+Q_001010111*PR_010012000001+Q_001010211*PR_010012000002+Q_001110011*PR_010012000010+Q_001110111*PR_010012000011+Q_001110211*PR_010012000012+Q_101010011*PR_010012000100+Q_101010111*PR_010012000101+Q_101010211*PR_010012000102+Q_101110011*PR_010012000110+Q_101110111*PR_010012000111+Q_101110211*PR_010012000112); ans_temp[ans_id*36+10]+=Pmtrx[16]*(Q_000011011*PR_010012000000+Q_000011111*PR_010012000001+Q_000011211*PR_010012000002+Q_000111011*PR_010012000010+Q_000111111*PR_010012000011+Q_000111211*PR_010012000012+Q_000211011*PR_010012000020+Q_000211111*PR_010012000021+Q_000211211*PR_010012000022); ans_temp[ans_id*36+10]+=Pmtrx[17]*(Q_000010012*PR_010012000000+Q_000010112*PR_010012000001+Q_000010212*PR_010012000002+Q_000010312*PR_010012000003+Q_000110012*PR_010012000010+Q_000110112*PR_010012000011+Q_000110212*PR_010012000012+Q_000110312*PR_010012000013); ans_temp[ans_id*36+11]+=Pmtrx[12]*(Q_002000020*PR_010012000000+Q_002000120*PR_010012000001+Q_002000220*PR_010012000002+Q_102000020*PR_010012000100+Q_102000120*PR_010012000101+Q_102000220*PR_010012000102+Q_202000020*PR_010012000200+Q_202000120*PR_010012000201+Q_202000220*PR_010012000202); ans_temp[ans_id*36+11]+=Pmtrx[13]*(Q_001001020*PR_010012000000+Q_001001120*PR_010012000001+Q_001001220*PR_010012000002+Q_001101020*PR_010012000010+Q_001101120*PR_010012000011+Q_001101220*PR_010012000012+Q_101001020*PR_010012000100+Q_101001120*PR_010012000101+Q_101001220*PR_010012000102+Q_101101020*PR_010012000110+Q_101101120*PR_010012000111+Q_101101220*PR_010012000112); ans_temp[ans_id*36+11]+=Pmtrx[14]*(Q_000002020*PR_010012000000+Q_000002120*PR_010012000001+Q_000002220*PR_010012000002+Q_000102020*PR_010012000010+Q_000102120*PR_010012000011+Q_000102220*PR_010012000012+Q_000202020*PR_010012000020+Q_000202120*PR_010012000021+Q_000202220*PR_010012000022); ans_temp[ans_id*36+11]+=Pmtrx[15]*(Q_001000021*PR_010012000000+Q_001000121*PR_010012000001+Q_001000221*PR_010012000002+Q_001000321*PR_010012000003+Q_101000021*PR_010012000100+Q_101000121*PR_010012000101+Q_101000221*PR_010012000102+Q_101000321*PR_010012000103); ans_temp[ans_id*36+11]+=Pmtrx[16]*(Q_000001021*PR_010012000000+Q_000001121*PR_010012000001+Q_000001221*PR_010012000002+Q_000001321*PR_010012000003+Q_000101021*PR_010012000010+Q_000101121*PR_010012000011+Q_000101221*PR_010012000012+Q_000101321*PR_010012000013); ans_temp[ans_id*36+11]+=Pmtrx[17]*(Q_000000022*PR_010012000000+Q_000000122*PR_010012000001+Q_000000222*PR_010012000002+Q_000000322*PR_010012000003+Q_000000422*PR_010012000004); ans_temp[ans_id*36+6]+=Pmtrx[18]*(Q_022000000*PR_011010001000+Q_122000000*PR_011010001100+Q_222000000*PR_011010001200+Q_322000000*PR_011010001300+Q_422000000*PR_011010001400); ans_temp[ans_id*36+6]+=Pmtrx[19]*(Q_021001000*PR_011010001000+Q_021101000*PR_011010001010+Q_121001000*PR_011010001100+Q_121101000*PR_011010001110+Q_221001000*PR_011010001200+Q_221101000*PR_011010001210+Q_321001000*PR_011010001300+Q_321101000*PR_011010001310); ans_temp[ans_id*36+6]+=Pmtrx[20]*(Q_020002000*PR_011010001000+Q_020102000*PR_011010001010+Q_020202000*PR_011010001020+Q_120002000*PR_011010001100+Q_120102000*PR_011010001110+Q_120202000*PR_011010001120+Q_220002000*PR_011010001200+Q_220102000*PR_011010001210+Q_220202000*PR_011010001220); ans_temp[ans_id*36+6]+=Pmtrx[21]*(Q_021000001*PR_011010001000+Q_021000101*PR_011010001001+Q_121000001*PR_011010001100+Q_121000101*PR_011010001101+Q_221000001*PR_011010001200+Q_221000101*PR_011010001201+Q_321000001*PR_011010001300+Q_321000101*PR_011010001301); ans_temp[ans_id*36+6]+=Pmtrx[22]*(Q_020001001*PR_011010001000+Q_020001101*PR_011010001001+Q_020101001*PR_011010001010+Q_020101101*PR_011010001011+Q_120001001*PR_011010001100+Q_120001101*PR_011010001101+Q_120101001*PR_011010001110+Q_120101101*PR_011010001111+Q_220001001*PR_011010001200+Q_220001101*PR_011010001201+Q_220101001*PR_011010001210+Q_220101101*PR_011010001211); ans_temp[ans_id*36+6]+=Pmtrx[23]*(Q_020000002*PR_011010001000+Q_020000102*PR_011010001001+Q_020000202*PR_011010001002+Q_120000002*PR_011010001100+Q_120000102*PR_011010001101+Q_120000202*PR_011010001102+Q_220000002*PR_011010001200+Q_220000102*PR_011010001201+Q_220000202*PR_011010001202); ans_temp[ans_id*36+7]+=Pmtrx[18]*(Q_012010000*PR_011010001000+Q_012110000*PR_011010001010+Q_112010000*PR_011010001100+Q_112110000*PR_011010001110+Q_212010000*PR_011010001200+Q_212110000*PR_011010001210+Q_312010000*PR_011010001300+Q_312110000*PR_011010001310); ans_temp[ans_id*36+7]+=Pmtrx[19]*(Q_011011000*PR_011010001000+Q_011111000*PR_011010001010+Q_011211000*PR_011010001020+Q_111011000*PR_011010001100+Q_111111000*PR_011010001110+Q_111211000*PR_011010001120+Q_211011000*PR_011010001200+Q_211111000*PR_011010001210+Q_211211000*PR_011010001220); ans_temp[ans_id*36+7]+=Pmtrx[20]*(Q_010012000*PR_011010001000+Q_010112000*PR_011010001010+Q_010212000*PR_011010001020+Q_010312000*PR_011010001030+Q_110012000*PR_011010001100+Q_110112000*PR_011010001110+Q_110212000*PR_011010001120+Q_110312000*PR_011010001130); ans_temp[ans_id*36+7]+=Pmtrx[21]*(Q_011010001*PR_011010001000+Q_011010101*PR_011010001001+Q_011110001*PR_011010001010+Q_011110101*PR_011010001011+Q_111010001*PR_011010001100+Q_111010101*PR_011010001101+Q_111110001*PR_011010001110+Q_111110101*PR_011010001111+Q_211010001*PR_011010001200+Q_211010101*PR_011010001201+Q_211110001*PR_011010001210+Q_211110101*PR_011010001211); ans_temp[ans_id*36+7]+=Pmtrx[22]*(Q_010011001*PR_011010001000+Q_010011101*PR_011010001001+Q_010111001*PR_011010001010+Q_010111101*PR_011010001011+Q_010211001*PR_011010001020+Q_010211101*PR_011010001021+Q_110011001*PR_011010001100+Q_110011101*PR_011010001101+Q_110111001*PR_011010001110+Q_110111101*PR_011010001111+Q_110211001*PR_011010001120+Q_110211101*PR_011010001121); ans_temp[ans_id*36+7]+=Pmtrx[23]*(Q_010010002*PR_011010001000+Q_010010102*PR_011010001001+Q_010010202*PR_011010001002+Q_010110002*PR_011010001010+Q_010110102*PR_011010001011+Q_010110202*PR_011010001012+Q_110010002*PR_011010001100+Q_110010102*PR_011010001101+Q_110010202*PR_011010001102+Q_110110002*PR_011010001110+Q_110110102*PR_011010001111+Q_110110202*PR_011010001112); ans_temp[ans_id*36+8]+=Pmtrx[18]*(Q_002020000*PR_011010001000+Q_002120000*PR_011010001010+Q_002220000*PR_011010001020+Q_102020000*PR_011010001100+Q_102120000*PR_011010001110+Q_102220000*PR_011010001120+Q_202020000*PR_011010001200+Q_202120000*PR_011010001210+Q_202220000*PR_011010001220); ans_temp[ans_id*36+8]+=Pmtrx[19]*(Q_001021000*PR_011010001000+Q_001121000*PR_011010001010+Q_001221000*PR_011010001020+Q_001321000*PR_011010001030+Q_101021000*PR_011010001100+Q_101121000*PR_011010001110+Q_101221000*PR_011010001120+Q_101321000*PR_011010001130); ans_temp[ans_id*36+8]+=Pmtrx[20]*(Q_000022000*PR_011010001000+Q_000122000*PR_011010001010+Q_000222000*PR_011010001020+Q_000322000*PR_011010001030+Q_000422000*PR_011010001040); ans_temp[ans_id*36+8]+=Pmtrx[21]*(Q_001020001*PR_011010001000+Q_001020101*PR_011010001001+Q_001120001*PR_011010001010+Q_001120101*PR_011010001011+Q_001220001*PR_011010001020+Q_001220101*PR_011010001021+Q_101020001*PR_011010001100+Q_101020101*PR_011010001101+Q_101120001*PR_011010001110+Q_101120101*PR_011010001111+Q_101220001*PR_011010001120+Q_101220101*PR_011010001121); ans_temp[ans_id*36+8]+=Pmtrx[22]*(Q_000021001*PR_011010001000+Q_000021101*PR_011010001001+Q_000121001*PR_011010001010+Q_000121101*PR_011010001011+Q_000221001*PR_011010001020+Q_000221101*PR_011010001021+Q_000321001*PR_011010001030+Q_000321101*PR_011010001031); ans_temp[ans_id*36+8]+=Pmtrx[23]*(Q_000020002*PR_011010001000+Q_000020102*PR_011010001001+Q_000020202*PR_011010001002+Q_000120002*PR_011010001010+Q_000120102*PR_011010001011+Q_000120202*PR_011010001012+Q_000220002*PR_011010001020+Q_000220102*PR_011010001021+Q_000220202*PR_011010001022); ans_temp[ans_id*36+9]+=Pmtrx[18]*(Q_012000010*PR_011010001000+Q_012000110*PR_011010001001+Q_112000010*PR_011010001100+Q_112000110*PR_011010001101+Q_212000010*PR_011010001200+Q_212000110*PR_011010001201+Q_312000010*PR_011010001300+Q_312000110*PR_011010001301); ans_temp[ans_id*36+9]+=Pmtrx[19]*(Q_011001010*PR_011010001000+Q_011001110*PR_011010001001+Q_011101010*PR_011010001010+Q_011101110*PR_011010001011+Q_111001010*PR_011010001100+Q_111001110*PR_011010001101+Q_111101010*PR_011010001110+Q_111101110*PR_011010001111+Q_211001010*PR_011010001200+Q_211001110*PR_011010001201+Q_211101010*PR_011010001210+Q_211101110*PR_011010001211); ans_temp[ans_id*36+9]+=Pmtrx[20]*(Q_010002010*PR_011010001000+Q_010002110*PR_011010001001+Q_010102010*PR_011010001010+Q_010102110*PR_011010001011+Q_010202010*PR_011010001020+Q_010202110*PR_011010001021+Q_110002010*PR_011010001100+Q_110002110*PR_011010001101+Q_110102010*PR_011010001110+Q_110102110*PR_011010001111+Q_110202010*PR_011010001120+Q_110202110*PR_011010001121); ans_temp[ans_id*36+9]+=Pmtrx[21]*(Q_011000011*PR_011010001000+Q_011000111*PR_011010001001+Q_011000211*PR_011010001002+Q_111000011*PR_011010001100+Q_111000111*PR_011010001101+Q_111000211*PR_011010001102+Q_211000011*PR_011010001200+Q_211000111*PR_011010001201+Q_211000211*PR_011010001202); ans_temp[ans_id*36+9]+=Pmtrx[22]*(Q_010001011*PR_011010001000+Q_010001111*PR_011010001001+Q_010001211*PR_011010001002+Q_010101011*PR_011010001010+Q_010101111*PR_011010001011+Q_010101211*PR_011010001012+Q_110001011*PR_011010001100+Q_110001111*PR_011010001101+Q_110001211*PR_011010001102+Q_110101011*PR_011010001110+Q_110101111*PR_011010001111+Q_110101211*PR_011010001112); ans_temp[ans_id*36+9]+=Pmtrx[23]*(Q_010000012*PR_011010001000+Q_010000112*PR_011010001001+Q_010000212*PR_011010001002+Q_010000312*PR_011010001003+Q_110000012*PR_011010001100+Q_110000112*PR_011010001101+Q_110000212*PR_011010001102+Q_110000312*PR_011010001103); ans_temp[ans_id*36+10]+=Pmtrx[18]*(Q_002010010*PR_011010001000+Q_002010110*PR_011010001001+Q_002110010*PR_011010001010+Q_002110110*PR_011010001011+Q_102010010*PR_011010001100+Q_102010110*PR_011010001101+Q_102110010*PR_011010001110+Q_102110110*PR_011010001111+Q_202010010*PR_011010001200+Q_202010110*PR_011010001201+Q_202110010*PR_011010001210+Q_202110110*PR_011010001211); ans_temp[ans_id*36+10]+=Pmtrx[19]*(Q_001011010*PR_011010001000+Q_001011110*PR_011010001001+Q_001111010*PR_011010001010+Q_001111110*PR_011010001011+Q_001211010*PR_011010001020+Q_001211110*PR_011010001021+Q_101011010*PR_011010001100+Q_101011110*PR_011010001101+Q_101111010*PR_011010001110+Q_101111110*PR_011010001111+Q_101211010*PR_011010001120+Q_101211110*PR_011010001121); ans_temp[ans_id*36+10]+=Pmtrx[20]*(Q_000012010*PR_011010001000+Q_000012110*PR_011010001001+Q_000112010*PR_011010001010+Q_000112110*PR_011010001011+Q_000212010*PR_011010001020+Q_000212110*PR_011010001021+Q_000312010*PR_011010001030+Q_000312110*PR_011010001031); ans_temp[ans_id*36+10]+=Pmtrx[21]*(Q_001010011*PR_011010001000+Q_001010111*PR_011010001001+Q_001010211*PR_011010001002+Q_001110011*PR_011010001010+Q_001110111*PR_011010001011+Q_001110211*PR_011010001012+Q_101010011*PR_011010001100+Q_101010111*PR_011010001101+Q_101010211*PR_011010001102+Q_101110011*PR_011010001110+Q_101110111*PR_011010001111+Q_101110211*PR_011010001112); ans_temp[ans_id*36+10]+=Pmtrx[22]*(Q_000011011*PR_011010001000+Q_000011111*PR_011010001001+Q_000011211*PR_011010001002+Q_000111011*PR_011010001010+Q_000111111*PR_011010001011+Q_000111211*PR_011010001012+Q_000211011*PR_011010001020+Q_000211111*PR_011010001021+Q_000211211*PR_011010001022); ans_temp[ans_id*36+10]+=Pmtrx[23]*(Q_000010012*PR_011010001000+Q_000010112*PR_011010001001+Q_000010212*PR_011010001002+Q_000010312*PR_011010001003+Q_000110012*PR_011010001010+Q_000110112*PR_011010001011+Q_000110212*PR_011010001012+Q_000110312*PR_011010001013); ans_temp[ans_id*36+11]+=Pmtrx[18]*(Q_002000020*PR_011010001000+Q_002000120*PR_011010001001+Q_002000220*PR_011010001002+Q_102000020*PR_011010001100+Q_102000120*PR_011010001101+Q_102000220*PR_011010001102+Q_202000020*PR_011010001200+Q_202000120*PR_011010001201+Q_202000220*PR_011010001202); ans_temp[ans_id*36+11]+=Pmtrx[19]*(Q_001001020*PR_011010001000+Q_001001120*PR_011010001001+Q_001001220*PR_011010001002+Q_001101020*PR_011010001010+Q_001101120*PR_011010001011+Q_001101220*PR_011010001012+Q_101001020*PR_011010001100+Q_101001120*PR_011010001101+Q_101001220*PR_011010001102+Q_101101020*PR_011010001110+Q_101101120*PR_011010001111+Q_101101220*PR_011010001112); ans_temp[ans_id*36+11]+=Pmtrx[20]*(Q_000002020*PR_011010001000+Q_000002120*PR_011010001001+Q_000002220*PR_011010001002+Q_000102020*PR_011010001010+Q_000102120*PR_011010001011+Q_000102220*PR_011010001012+Q_000202020*PR_011010001020+Q_000202120*PR_011010001021+Q_000202220*PR_011010001022); ans_temp[ans_id*36+11]+=Pmtrx[21]*(Q_001000021*PR_011010001000+Q_001000121*PR_011010001001+Q_001000221*PR_011010001002+Q_001000321*PR_011010001003+Q_101000021*PR_011010001100+Q_101000121*PR_011010001101+Q_101000221*PR_011010001102+Q_101000321*PR_011010001103); ans_temp[ans_id*36+11]+=Pmtrx[22]*(Q_000001021*PR_011010001000+Q_000001121*PR_011010001001+Q_000001221*PR_011010001002+Q_000001321*PR_011010001003+Q_000101021*PR_011010001010+Q_000101121*PR_011010001011+Q_000101221*PR_011010001012+Q_000101321*PR_011010001013); ans_temp[ans_id*36+11]+=Pmtrx[23]*(Q_000000022*PR_011010001000+Q_000000122*PR_011010001001+Q_000000222*PR_011010001002+Q_000000322*PR_011010001003+Q_000000422*PR_011010001004); ans_temp[ans_id*36+6]+=Pmtrx[24]*(Q_022000000*PR_010011001000+Q_122000000*PR_010011001100+Q_222000000*PR_010011001200+Q_322000000*PR_010011001300+Q_422000000*PR_010011001400); ans_temp[ans_id*36+6]+=Pmtrx[25]*(Q_021001000*PR_010011001000+Q_021101000*PR_010011001010+Q_121001000*PR_010011001100+Q_121101000*PR_010011001110+Q_221001000*PR_010011001200+Q_221101000*PR_010011001210+Q_321001000*PR_010011001300+Q_321101000*PR_010011001310); ans_temp[ans_id*36+6]+=Pmtrx[26]*(Q_020002000*PR_010011001000+Q_020102000*PR_010011001010+Q_020202000*PR_010011001020+Q_120002000*PR_010011001100+Q_120102000*PR_010011001110+Q_120202000*PR_010011001120+Q_220002000*PR_010011001200+Q_220102000*PR_010011001210+Q_220202000*PR_010011001220); ans_temp[ans_id*36+6]+=Pmtrx[27]*(Q_021000001*PR_010011001000+Q_021000101*PR_010011001001+Q_121000001*PR_010011001100+Q_121000101*PR_010011001101+Q_221000001*PR_010011001200+Q_221000101*PR_010011001201+Q_321000001*PR_010011001300+Q_321000101*PR_010011001301); ans_temp[ans_id*36+6]+=Pmtrx[28]*(Q_020001001*PR_010011001000+Q_020001101*PR_010011001001+Q_020101001*PR_010011001010+Q_020101101*PR_010011001011+Q_120001001*PR_010011001100+Q_120001101*PR_010011001101+Q_120101001*PR_010011001110+Q_120101101*PR_010011001111+Q_220001001*PR_010011001200+Q_220001101*PR_010011001201+Q_220101001*PR_010011001210+Q_220101101*PR_010011001211); ans_temp[ans_id*36+6]+=Pmtrx[29]*(Q_020000002*PR_010011001000+Q_020000102*PR_010011001001+Q_020000202*PR_010011001002+Q_120000002*PR_010011001100+Q_120000102*PR_010011001101+Q_120000202*PR_010011001102+Q_220000002*PR_010011001200+Q_220000102*PR_010011001201+Q_220000202*PR_010011001202); ans_temp[ans_id*36+7]+=Pmtrx[24]*(Q_012010000*PR_010011001000+Q_012110000*PR_010011001010+Q_112010000*PR_010011001100+Q_112110000*PR_010011001110+Q_212010000*PR_010011001200+Q_212110000*PR_010011001210+Q_312010000*PR_010011001300+Q_312110000*PR_010011001310); ans_temp[ans_id*36+7]+=Pmtrx[25]*(Q_011011000*PR_010011001000+Q_011111000*PR_010011001010+Q_011211000*PR_010011001020+Q_111011000*PR_010011001100+Q_111111000*PR_010011001110+Q_111211000*PR_010011001120+Q_211011000*PR_010011001200+Q_211111000*PR_010011001210+Q_211211000*PR_010011001220); ans_temp[ans_id*36+7]+=Pmtrx[26]*(Q_010012000*PR_010011001000+Q_010112000*PR_010011001010+Q_010212000*PR_010011001020+Q_010312000*PR_010011001030+Q_110012000*PR_010011001100+Q_110112000*PR_010011001110+Q_110212000*PR_010011001120+Q_110312000*PR_010011001130); ans_temp[ans_id*36+7]+=Pmtrx[27]*(Q_011010001*PR_010011001000+Q_011010101*PR_010011001001+Q_011110001*PR_010011001010+Q_011110101*PR_010011001011+Q_111010001*PR_010011001100+Q_111010101*PR_010011001101+Q_111110001*PR_010011001110+Q_111110101*PR_010011001111+Q_211010001*PR_010011001200+Q_211010101*PR_010011001201+Q_211110001*PR_010011001210+Q_211110101*PR_010011001211); ans_temp[ans_id*36+7]+=Pmtrx[28]*(Q_010011001*PR_010011001000+Q_010011101*PR_010011001001+Q_010111001*PR_010011001010+Q_010111101*PR_010011001011+Q_010211001*PR_010011001020+Q_010211101*PR_010011001021+Q_110011001*PR_010011001100+Q_110011101*PR_010011001101+Q_110111001*PR_010011001110+Q_110111101*PR_010011001111+Q_110211001*PR_010011001120+Q_110211101*PR_010011001121); ans_temp[ans_id*36+7]+=Pmtrx[29]*(Q_010010002*PR_010011001000+Q_010010102*PR_010011001001+Q_010010202*PR_010011001002+Q_010110002*PR_010011001010+Q_010110102*PR_010011001011+Q_010110202*PR_010011001012+Q_110010002*PR_010011001100+Q_110010102*PR_010011001101+Q_110010202*PR_010011001102+Q_110110002*PR_010011001110+Q_110110102*PR_010011001111+Q_110110202*PR_010011001112); ans_temp[ans_id*36+8]+=Pmtrx[24]*(Q_002020000*PR_010011001000+Q_002120000*PR_010011001010+Q_002220000*PR_010011001020+Q_102020000*PR_010011001100+Q_102120000*PR_010011001110+Q_102220000*PR_010011001120+Q_202020000*PR_010011001200+Q_202120000*PR_010011001210+Q_202220000*PR_010011001220); ans_temp[ans_id*36+8]+=Pmtrx[25]*(Q_001021000*PR_010011001000+Q_001121000*PR_010011001010+Q_001221000*PR_010011001020+Q_001321000*PR_010011001030+Q_101021000*PR_010011001100+Q_101121000*PR_010011001110+Q_101221000*PR_010011001120+Q_101321000*PR_010011001130); ans_temp[ans_id*36+8]+=Pmtrx[26]*(Q_000022000*PR_010011001000+Q_000122000*PR_010011001010+Q_000222000*PR_010011001020+Q_000322000*PR_010011001030+Q_000422000*PR_010011001040); ans_temp[ans_id*36+8]+=Pmtrx[27]*(Q_001020001*PR_010011001000+Q_001020101*PR_010011001001+Q_001120001*PR_010011001010+Q_001120101*PR_010011001011+Q_001220001*PR_010011001020+Q_001220101*PR_010011001021+Q_101020001*PR_010011001100+Q_101020101*PR_010011001101+Q_101120001*PR_010011001110+Q_101120101*PR_010011001111+Q_101220001*PR_010011001120+Q_101220101*PR_010011001121); ans_temp[ans_id*36+8]+=Pmtrx[28]*(Q_000021001*PR_010011001000+Q_000021101*PR_010011001001+Q_000121001*PR_010011001010+Q_000121101*PR_010011001011+Q_000221001*PR_010011001020+Q_000221101*PR_010011001021+Q_000321001*PR_010011001030+Q_000321101*PR_010011001031); ans_temp[ans_id*36+8]+=Pmtrx[29]*(Q_000020002*PR_010011001000+Q_000020102*PR_010011001001+Q_000020202*PR_010011001002+Q_000120002*PR_010011001010+Q_000120102*PR_010011001011+Q_000120202*PR_010011001012+Q_000220002*PR_010011001020+Q_000220102*PR_010011001021+Q_000220202*PR_010011001022); ans_temp[ans_id*36+9]+=Pmtrx[24]*(Q_012000010*PR_010011001000+Q_012000110*PR_010011001001+Q_112000010*PR_010011001100+Q_112000110*PR_010011001101+Q_212000010*PR_010011001200+Q_212000110*PR_010011001201+Q_312000010*PR_010011001300+Q_312000110*PR_010011001301); ans_temp[ans_id*36+9]+=Pmtrx[25]*(Q_011001010*PR_010011001000+Q_011001110*PR_010011001001+Q_011101010*PR_010011001010+Q_011101110*PR_010011001011+Q_111001010*PR_010011001100+Q_111001110*PR_010011001101+Q_111101010*PR_010011001110+Q_111101110*PR_010011001111+Q_211001010*PR_010011001200+Q_211001110*PR_010011001201+Q_211101010*PR_010011001210+Q_211101110*PR_010011001211); ans_temp[ans_id*36+9]+=Pmtrx[26]*(Q_010002010*PR_010011001000+Q_010002110*PR_010011001001+Q_010102010*PR_010011001010+Q_010102110*PR_010011001011+Q_010202010*PR_010011001020+Q_010202110*PR_010011001021+Q_110002010*PR_010011001100+Q_110002110*PR_010011001101+Q_110102010*PR_010011001110+Q_110102110*PR_010011001111+Q_110202010*PR_010011001120+Q_110202110*PR_010011001121); ans_temp[ans_id*36+9]+=Pmtrx[27]*(Q_011000011*PR_010011001000+Q_011000111*PR_010011001001+Q_011000211*PR_010011001002+Q_111000011*PR_010011001100+Q_111000111*PR_010011001101+Q_111000211*PR_010011001102+Q_211000011*PR_010011001200+Q_211000111*PR_010011001201+Q_211000211*PR_010011001202); ans_temp[ans_id*36+9]+=Pmtrx[28]*(Q_010001011*PR_010011001000+Q_010001111*PR_010011001001+Q_010001211*PR_010011001002+Q_010101011*PR_010011001010+Q_010101111*PR_010011001011+Q_010101211*PR_010011001012+Q_110001011*PR_010011001100+Q_110001111*PR_010011001101+Q_110001211*PR_010011001102+Q_110101011*PR_010011001110+Q_110101111*PR_010011001111+Q_110101211*PR_010011001112); ans_temp[ans_id*36+9]+=Pmtrx[29]*(Q_010000012*PR_010011001000+Q_010000112*PR_010011001001+Q_010000212*PR_010011001002+Q_010000312*PR_010011001003+Q_110000012*PR_010011001100+Q_110000112*PR_010011001101+Q_110000212*PR_010011001102+Q_110000312*PR_010011001103); ans_temp[ans_id*36+10]+=Pmtrx[24]*(Q_002010010*PR_010011001000+Q_002010110*PR_010011001001+Q_002110010*PR_010011001010+Q_002110110*PR_010011001011+Q_102010010*PR_010011001100+Q_102010110*PR_010011001101+Q_102110010*PR_010011001110+Q_102110110*PR_010011001111+Q_202010010*PR_010011001200+Q_202010110*PR_010011001201+Q_202110010*PR_010011001210+Q_202110110*PR_010011001211); ans_temp[ans_id*36+10]+=Pmtrx[25]*(Q_001011010*PR_010011001000+Q_001011110*PR_010011001001+Q_001111010*PR_010011001010+Q_001111110*PR_010011001011+Q_001211010*PR_010011001020+Q_001211110*PR_010011001021+Q_101011010*PR_010011001100+Q_101011110*PR_010011001101+Q_101111010*PR_010011001110+Q_101111110*PR_010011001111+Q_101211010*PR_010011001120+Q_101211110*PR_010011001121); ans_temp[ans_id*36+10]+=Pmtrx[26]*(Q_000012010*PR_010011001000+Q_000012110*PR_010011001001+Q_000112010*PR_010011001010+Q_000112110*PR_010011001011+Q_000212010*PR_010011001020+Q_000212110*PR_010011001021+Q_000312010*PR_010011001030+Q_000312110*PR_010011001031); ans_temp[ans_id*36+10]+=Pmtrx[27]*(Q_001010011*PR_010011001000+Q_001010111*PR_010011001001+Q_001010211*PR_010011001002+Q_001110011*PR_010011001010+Q_001110111*PR_010011001011+Q_001110211*PR_010011001012+Q_101010011*PR_010011001100+Q_101010111*PR_010011001101+Q_101010211*PR_010011001102+Q_101110011*PR_010011001110+Q_101110111*PR_010011001111+Q_101110211*PR_010011001112); ans_temp[ans_id*36+10]+=Pmtrx[28]*(Q_000011011*PR_010011001000+Q_000011111*PR_010011001001+Q_000011211*PR_010011001002+Q_000111011*PR_010011001010+Q_000111111*PR_010011001011+Q_000111211*PR_010011001012+Q_000211011*PR_010011001020+Q_000211111*PR_010011001021+Q_000211211*PR_010011001022); ans_temp[ans_id*36+10]+=Pmtrx[29]*(Q_000010012*PR_010011001000+Q_000010112*PR_010011001001+Q_000010212*PR_010011001002+Q_000010312*PR_010011001003+Q_000110012*PR_010011001010+Q_000110112*PR_010011001011+Q_000110212*PR_010011001012+Q_000110312*PR_010011001013); ans_temp[ans_id*36+11]+=Pmtrx[24]*(Q_002000020*PR_010011001000+Q_002000120*PR_010011001001+Q_002000220*PR_010011001002+Q_102000020*PR_010011001100+Q_102000120*PR_010011001101+Q_102000220*PR_010011001102+Q_202000020*PR_010011001200+Q_202000120*PR_010011001201+Q_202000220*PR_010011001202); ans_temp[ans_id*36+11]+=Pmtrx[25]*(Q_001001020*PR_010011001000+Q_001001120*PR_010011001001+Q_001001220*PR_010011001002+Q_001101020*PR_010011001010+Q_001101120*PR_010011001011+Q_001101220*PR_010011001012+Q_101001020*PR_010011001100+Q_101001120*PR_010011001101+Q_101001220*PR_010011001102+Q_101101020*PR_010011001110+Q_101101120*PR_010011001111+Q_101101220*PR_010011001112); ans_temp[ans_id*36+11]+=Pmtrx[26]*(Q_000002020*PR_010011001000+Q_000002120*PR_010011001001+Q_000002220*PR_010011001002+Q_000102020*PR_010011001010+Q_000102120*PR_010011001011+Q_000102220*PR_010011001012+Q_000202020*PR_010011001020+Q_000202120*PR_010011001021+Q_000202220*PR_010011001022); ans_temp[ans_id*36+11]+=Pmtrx[27]*(Q_001000021*PR_010011001000+Q_001000121*PR_010011001001+Q_001000221*PR_010011001002+Q_001000321*PR_010011001003+Q_101000021*PR_010011001100+Q_101000121*PR_010011001101+Q_101000221*PR_010011001102+Q_101000321*PR_010011001103); ans_temp[ans_id*36+11]+=Pmtrx[28]*(Q_000001021*PR_010011001000+Q_000001121*PR_010011001001+Q_000001221*PR_010011001002+Q_000001321*PR_010011001003+Q_000101021*PR_010011001010+Q_000101121*PR_010011001011+Q_000101221*PR_010011001012+Q_000101321*PR_010011001013); ans_temp[ans_id*36+11]+=Pmtrx[29]*(Q_000000022*PR_010011001000+Q_000000122*PR_010011001001+Q_000000222*PR_010011001002+Q_000000322*PR_010011001003+Q_000000422*PR_010011001004); ans_temp[ans_id*36+6]+=Pmtrx[30]*(Q_022000000*PR_010010002000+Q_122000000*PR_010010002100+Q_222000000*PR_010010002200+Q_322000000*PR_010010002300+Q_422000000*PR_010010002400); ans_temp[ans_id*36+6]+=Pmtrx[31]*(Q_021001000*PR_010010002000+Q_021101000*PR_010010002010+Q_121001000*PR_010010002100+Q_121101000*PR_010010002110+Q_221001000*PR_010010002200+Q_221101000*PR_010010002210+Q_321001000*PR_010010002300+Q_321101000*PR_010010002310); ans_temp[ans_id*36+6]+=Pmtrx[32]*(Q_020002000*PR_010010002000+Q_020102000*PR_010010002010+Q_020202000*PR_010010002020+Q_120002000*PR_010010002100+Q_120102000*PR_010010002110+Q_120202000*PR_010010002120+Q_220002000*PR_010010002200+Q_220102000*PR_010010002210+Q_220202000*PR_010010002220); ans_temp[ans_id*36+6]+=Pmtrx[33]*(Q_021000001*PR_010010002000+Q_021000101*PR_010010002001+Q_121000001*PR_010010002100+Q_121000101*PR_010010002101+Q_221000001*PR_010010002200+Q_221000101*PR_010010002201+Q_321000001*PR_010010002300+Q_321000101*PR_010010002301); ans_temp[ans_id*36+6]+=Pmtrx[34]*(Q_020001001*PR_010010002000+Q_020001101*PR_010010002001+Q_020101001*PR_010010002010+Q_020101101*PR_010010002011+Q_120001001*PR_010010002100+Q_120001101*PR_010010002101+Q_120101001*PR_010010002110+Q_120101101*PR_010010002111+Q_220001001*PR_010010002200+Q_220001101*PR_010010002201+Q_220101001*PR_010010002210+Q_220101101*PR_010010002211); ans_temp[ans_id*36+6]+=Pmtrx[35]*(Q_020000002*PR_010010002000+Q_020000102*PR_010010002001+Q_020000202*PR_010010002002+Q_120000002*PR_010010002100+Q_120000102*PR_010010002101+Q_120000202*PR_010010002102+Q_220000002*PR_010010002200+Q_220000102*PR_010010002201+Q_220000202*PR_010010002202); ans_temp[ans_id*36+7]+=Pmtrx[30]*(Q_012010000*PR_010010002000+Q_012110000*PR_010010002010+Q_112010000*PR_010010002100+Q_112110000*PR_010010002110+Q_212010000*PR_010010002200+Q_212110000*PR_010010002210+Q_312010000*PR_010010002300+Q_312110000*PR_010010002310); ans_temp[ans_id*36+7]+=Pmtrx[31]*(Q_011011000*PR_010010002000+Q_011111000*PR_010010002010+Q_011211000*PR_010010002020+Q_111011000*PR_010010002100+Q_111111000*PR_010010002110+Q_111211000*PR_010010002120+Q_211011000*PR_010010002200+Q_211111000*PR_010010002210+Q_211211000*PR_010010002220); ans_temp[ans_id*36+7]+=Pmtrx[32]*(Q_010012000*PR_010010002000+Q_010112000*PR_010010002010+Q_010212000*PR_010010002020+Q_010312000*PR_010010002030+Q_110012000*PR_010010002100+Q_110112000*PR_010010002110+Q_110212000*PR_010010002120+Q_110312000*PR_010010002130); ans_temp[ans_id*36+7]+=Pmtrx[33]*(Q_011010001*PR_010010002000+Q_011010101*PR_010010002001+Q_011110001*PR_010010002010+Q_011110101*PR_010010002011+Q_111010001*PR_010010002100+Q_111010101*PR_010010002101+Q_111110001*PR_010010002110+Q_111110101*PR_010010002111+Q_211010001*PR_010010002200+Q_211010101*PR_010010002201+Q_211110001*PR_010010002210+Q_211110101*PR_010010002211); ans_temp[ans_id*36+7]+=Pmtrx[34]*(Q_010011001*PR_010010002000+Q_010011101*PR_010010002001+Q_010111001*PR_010010002010+Q_010111101*PR_010010002011+Q_010211001*PR_010010002020+Q_010211101*PR_010010002021+Q_110011001*PR_010010002100+Q_110011101*PR_010010002101+Q_110111001*PR_010010002110+Q_110111101*PR_010010002111+Q_110211001*PR_010010002120+Q_110211101*PR_010010002121); ans_temp[ans_id*36+7]+=Pmtrx[35]*(Q_010010002*PR_010010002000+Q_010010102*PR_010010002001+Q_010010202*PR_010010002002+Q_010110002*PR_010010002010+Q_010110102*PR_010010002011+Q_010110202*PR_010010002012+Q_110010002*PR_010010002100+Q_110010102*PR_010010002101+Q_110010202*PR_010010002102+Q_110110002*PR_010010002110+Q_110110102*PR_010010002111+Q_110110202*PR_010010002112); ans_temp[ans_id*36+8]+=Pmtrx[30]*(Q_002020000*PR_010010002000+Q_002120000*PR_010010002010+Q_002220000*PR_010010002020+Q_102020000*PR_010010002100+Q_102120000*PR_010010002110+Q_102220000*PR_010010002120+Q_202020000*PR_010010002200+Q_202120000*PR_010010002210+Q_202220000*PR_010010002220); ans_temp[ans_id*36+8]+=Pmtrx[31]*(Q_001021000*PR_010010002000+Q_001121000*PR_010010002010+Q_001221000*PR_010010002020+Q_001321000*PR_010010002030+Q_101021000*PR_010010002100+Q_101121000*PR_010010002110+Q_101221000*PR_010010002120+Q_101321000*PR_010010002130); ans_temp[ans_id*36+8]+=Pmtrx[32]*(Q_000022000*PR_010010002000+Q_000122000*PR_010010002010+Q_000222000*PR_010010002020+Q_000322000*PR_010010002030+Q_000422000*PR_010010002040); ans_temp[ans_id*36+8]+=Pmtrx[33]*(Q_001020001*PR_010010002000+Q_001020101*PR_010010002001+Q_001120001*PR_010010002010+Q_001120101*PR_010010002011+Q_001220001*PR_010010002020+Q_001220101*PR_010010002021+Q_101020001*PR_010010002100+Q_101020101*PR_010010002101+Q_101120001*PR_010010002110+Q_101120101*PR_010010002111+Q_101220001*PR_010010002120+Q_101220101*PR_010010002121); ans_temp[ans_id*36+8]+=Pmtrx[34]*(Q_000021001*PR_010010002000+Q_000021101*PR_010010002001+Q_000121001*PR_010010002010+Q_000121101*PR_010010002011+Q_000221001*PR_010010002020+Q_000221101*PR_010010002021+Q_000321001*PR_010010002030+Q_000321101*PR_010010002031); ans_temp[ans_id*36+8]+=Pmtrx[35]*(Q_000020002*PR_010010002000+Q_000020102*PR_010010002001+Q_000020202*PR_010010002002+Q_000120002*PR_010010002010+Q_000120102*PR_010010002011+Q_000120202*PR_010010002012+Q_000220002*PR_010010002020+Q_000220102*PR_010010002021+Q_000220202*PR_010010002022); ans_temp[ans_id*36+9]+=Pmtrx[30]*(Q_012000010*PR_010010002000+Q_012000110*PR_010010002001+Q_112000010*PR_010010002100+Q_112000110*PR_010010002101+Q_212000010*PR_010010002200+Q_212000110*PR_010010002201+Q_312000010*PR_010010002300+Q_312000110*PR_010010002301); ans_temp[ans_id*36+9]+=Pmtrx[31]*(Q_011001010*PR_010010002000+Q_011001110*PR_010010002001+Q_011101010*PR_010010002010+Q_011101110*PR_010010002011+Q_111001010*PR_010010002100+Q_111001110*PR_010010002101+Q_111101010*PR_010010002110+Q_111101110*PR_010010002111+Q_211001010*PR_010010002200+Q_211001110*PR_010010002201+Q_211101010*PR_010010002210+Q_211101110*PR_010010002211); ans_temp[ans_id*36+9]+=Pmtrx[32]*(Q_010002010*PR_010010002000+Q_010002110*PR_010010002001+Q_010102010*PR_010010002010+Q_010102110*PR_010010002011+Q_010202010*PR_010010002020+Q_010202110*PR_010010002021+Q_110002010*PR_010010002100+Q_110002110*PR_010010002101+Q_110102010*PR_010010002110+Q_110102110*PR_010010002111+Q_110202010*PR_010010002120+Q_110202110*PR_010010002121); ans_temp[ans_id*36+9]+=Pmtrx[33]*(Q_011000011*PR_010010002000+Q_011000111*PR_010010002001+Q_011000211*PR_010010002002+Q_111000011*PR_010010002100+Q_111000111*PR_010010002101+Q_111000211*PR_010010002102+Q_211000011*PR_010010002200+Q_211000111*PR_010010002201+Q_211000211*PR_010010002202); ans_temp[ans_id*36+9]+=Pmtrx[34]*(Q_010001011*PR_010010002000+Q_010001111*PR_010010002001+Q_010001211*PR_010010002002+Q_010101011*PR_010010002010+Q_010101111*PR_010010002011+Q_010101211*PR_010010002012+Q_110001011*PR_010010002100+Q_110001111*PR_010010002101+Q_110001211*PR_010010002102+Q_110101011*PR_010010002110+Q_110101111*PR_010010002111+Q_110101211*PR_010010002112); ans_temp[ans_id*36+9]+=Pmtrx[35]*(Q_010000012*PR_010010002000+Q_010000112*PR_010010002001+Q_010000212*PR_010010002002+Q_010000312*PR_010010002003+Q_110000012*PR_010010002100+Q_110000112*PR_010010002101+Q_110000212*PR_010010002102+Q_110000312*PR_010010002103); ans_temp[ans_id*36+10]+=Pmtrx[30]*(Q_002010010*PR_010010002000+Q_002010110*PR_010010002001+Q_002110010*PR_010010002010+Q_002110110*PR_010010002011+Q_102010010*PR_010010002100+Q_102010110*PR_010010002101+Q_102110010*PR_010010002110+Q_102110110*PR_010010002111+Q_202010010*PR_010010002200+Q_202010110*PR_010010002201+Q_202110010*PR_010010002210+Q_202110110*PR_010010002211); ans_temp[ans_id*36+10]+=Pmtrx[31]*(Q_001011010*PR_010010002000+Q_001011110*PR_010010002001+Q_001111010*PR_010010002010+Q_001111110*PR_010010002011+Q_001211010*PR_010010002020+Q_001211110*PR_010010002021+Q_101011010*PR_010010002100+Q_101011110*PR_010010002101+Q_101111010*PR_010010002110+Q_101111110*PR_010010002111+Q_101211010*PR_010010002120+Q_101211110*PR_010010002121); ans_temp[ans_id*36+10]+=Pmtrx[32]*(Q_000012010*PR_010010002000+Q_000012110*PR_010010002001+Q_000112010*PR_010010002010+Q_000112110*PR_010010002011+Q_000212010*PR_010010002020+Q_000212110*PR_010010002021+Q_000312010*PR_010010002030+Q_000312110*PR_010010002031); ans_temp[ans_id*36+10]+=Pmtrx[33]*(Q_001010011*PR_010010002000+Q_001010111*PR_010010002001+Q_001010211*PR_010010002002+Q_001110011*PR_010010002010+Q_001110111*PR_010010002011+Q_001110211*PR_010010002012+Q_101010011*PR_010010002100+Q_101010111*PR_010010002101+Q_101010211*PR_010010002102+Q_101110011*PR_010010002110+Q_101110111*PR_010010002111+Q_101110211*PR_010010002112); ans_temp[ans_id*36+10]+=Pmtrx[34]*(Q_000011011*PR_010010002000+Q_000011111*PR_010010002001+Q_000011211*PR_010010002002+Q_000111011*PR_010010002010+Q_000111111*PR_010010002011+Q_000111211*PR_010010002012+Q_000211011*PR_010010002020+Q_000211111*PR_010010002021+Q_000211211*PR_010010002022); ans_temp[ans_id*36+10]+=Pmtrx[35]*(Q_000010012*PR_010010002000+Q_000010112*PR_010010002001+Q_000010212*PR_010010002002+Q_000010312*PR_010010002003+Q_000110012*PR_010010002010+Q_000110112*PR_010010002011+Q_000110212*PR_010010002012+Q_000110312*PR_010010002013); ans_temp[ans_id*36+11]+=Pmtrx[30]*(Q_002000020*PR_010010002000+Q_002000120*PR_010010002001+Q_002000220*PR_010010002002+Q_102000020*PR_010010002100+Q_102000120*PR_010010002101+Q_102000220*PR_010010002102+Q_202000020*PR_010010002200+Q_202000120*PR_010010002201+Q_202000220*PR_010010002202); ans_temp[ans_id*36+11]+=Pmtrx[31]*(Q_001001020*PR_010010002000+Q_001001120*PR_010010002001+Q_001001220*PR_010010002002+Q_001101020*PR_010010002010+Q_001101120*PR_010010002011+Q_001101220*PR_010010002012+Q_101001020*PR_010010002100+Q_101001120*PR_010010002101+Q_101001220*PR_010010002102+Q_101101020*PR_010010002110+Q_101101120*PR_010010002111+Q_101101220*PR_010010002112); ans_temp[ans_id*36+11]+=Pmtrx[32]*(Q_000002020*PR_010010002000+Q_000002120*PR_010010002001+Q_000002220*PR_010010002002+Q_000102020*PR_010010002010+Q_000102120*PR_010010002011+Q_000102220*PR_010010002012+Q_000202020*PR_010010002020+Q_000202120*PR_010010002021+Q_000202220*PR_010010002022); ans_temp[ans_id*36+11]+=Pmtrx[33]*(Q_001000021*PR_010010002000+Q_001000121*PR_010010002001+Q_001000221*PR_010010002002+Q_001000321*PR_010010002003+Q_101000021*PR_010010002100+Q_101000121*PR_010010002101+Q_101000221*PR_010010002102+Q_101000321*PR_010010002103); ans_temp[ans_id*36+11]+=Pmtrx[34]*(Q_000001021*PR_010010002000+Q_000001121*PR_010010002001+Q_000001221*PR_010010002002+Q_000001321*PR_010010002003+Q_000101021*PR_010010002010+Q_000101121*PR_010010002011+Q_000101221*PR_010010002012+Q_000101321*PR_010010002013); ans_temp[ans_id*36+11]+=Pmtrx[35]*(Q_000000022*PR_010010002000+Q_000000122*PR_010010002001+Q_000000222*PR_010010002002+Q_000000322*PR_010010002003+Q_000000422*PR_010010002004); ans_temp[ans_id*36+12]+=Pmtrx[0]*(Q_022000000*PR_002020000000+Q_122000000*PR_002020000100+Q_222000000*PR_002020000200+Q_322000000*PR_002020000300+Q_422000000*PR_002020000400); ans_temp[ans_id*36+12]+=Pmtrx[1]*(Q_021001000*PR_002020000000+Q_021101000*PR_002020000010+Q_121001000*PR_002020000100+Q_121101000*PR_002020000110+Q_221001000*PR_002020000200+Q_221101000*PR_002020000210+Q_321001000*PR_002020000300+Q_321101000*PR_002020000310); ans_temp[ans_id*36+12]+=Pmtrx[2]*(Q_020002000*PR_002020000000+Q_020102000*PR_002020000010+Q_020202000*PR_002020000020+Q_120002000*PR_002020000100+Q_120102000*PR_002020000110+Q_120202000*PR_002020000120+Q_220002000*PR_002020000200+Q_220102000*PR_002020000210+Q_220202000*PR_002020000220); ans_temp[ans_id*36+12]+=Pmtrx[3]*(Q_021000001*PR_002020000000+Q_021000101*PR_002020000001+Q_121000001*PR_002020000100+Q_121000101*PR_002020000101+Q_221000001*PR_002020000200+Q_221000101*PR_002020000201+Q_321000001*PR_002020000300+Q_321000101*PR_002020000301); ans_temp[ans_id*36+12]+=Pmtrx[4]*(Q_020001001*PR_002020000000+Q_020001101*PR_002020000001+Q_020101001*PR_002020000010+Q_020101101*PR_002020000011+Q_120001001*PR_002020000100+Q_120001101*PR_002020000101+Q_120101001*PR_002020000110+Q_120101101*PR_002020000111+Q_220001001*PR_002020000200+Q_220001101*PR_002020000201+Q_220101001*PR_002020000210+Q_220101101*PR_002020000211); ans_temp[ans_id*36+12]+=Pmtrx[5]*(Q_020000002*PR_002020000000+Q_020000102*PR_002020000001+Q_020000202*PR_002020000002+Q_120000002*PR_002020000100+Q_120000102*PR_002020000101+Q_120000202*PR_002020000102+Q_220000002*PR_002020000200+Q_220000102*PR_002020000201+Q_220000202*PR_002020000202); ans_temp[ans_id*36+13]+=Pmtrx[0]*(Q_012010000*PR_002020000000+Q_012110000*PR_002020000010+Q_112010000*PR_002020000100+Q_112110000*PR_002020000110+Q_212010000*PR_002020000200+Q_212110000*PR_002020000210+Q_312010000*PR_002020000300+Q_312110000*PR_002020000310); ans_temp[ans_id*36+13]+=Pmtrx[1]*(Q_011011000*PR_002020000000+Q_011111000*PR_002020000010+Q_011211000*PR_002020000020+Q_111011000*PR_002020000100+Q_111111000*PR_002020000110+Q_111211000*PR_002020000120+Q_211011000*PR_002020000200+Q_211111000*PR_002020000210+Q_211211000*PR_002020000220); ans_temp[ans_id*36+13]+=Pmtrx[2]*(Q_010012000*PR_002020000000+Q_010112000*PR_002020000010+Q_010212000*PR_002020000020+Q_010312000*PR_002020000030+Q_110012000*PR_002020000100+Q_110112000*PR_002020000110+Q_110212000*PR_002020000120+Q_110312000*PR_002020000130); ans_temp[ans_id*36+13]+=Pmtrx[3]*(Q_011010001*PR_002020000000+Q_011010101*PR_002020000001+Q_011110001*PR_002020000010+Q_011110101*PR_002020000011+Q_111010001*PR_002020000100+Q_111010101*PR_002020000101+Q_111110001*PR_002020000110+Q_111110101*PR_002020000111+Q_211010001*PR_002020000200+Q_211010101*PR_002020000201+Q_211110001*PR_002020000210+Q_211110101*PR_002020000211); ans_temp[ans_id*36+13]+=Pmtrx[4]*(Q_010011001*PR_002020000000+Q_010011101*PR_002020000001+Q_010111001*PR_002020000010+Q_010111101*PR_002020000011+Q_010211001*PR_002020000020+Q_010211101*PR_002020000021+Q_110011001*PR_002020000100+Q_110011101*PR_002020000101+Q_110111001*PR_002020000110+Q_110111101*PR_002020000111+Q_110211001*PR_002020000120+Q_110211101*PR_002020000121); ans_temp[ans_id*36+13]+=Pmtrx[5]*(Q_010010002*PR_002020000000+Q_010010102*PR_002020000001+Q_010010202*PR_002020000002+Q_010110002*PR_002020000010+Q_010110102*PR_002020000011+Q_010110202*PR_002020000012+Q_110010002*PR_002020000100+Q_110010102*PR_002020000101+Q_110010202*PR_002020000102+Q_110110002*PR_002020000110+Q_110110102*PR_002020000111+Q_110110202*PR_002020000112); ans_temp[ans_id*36+14]+=Pmtrx[0]*(Q_002020000*PR_002020000000+Q_002120000*PR_002020000010+Q_002220000*PR_002020000020+Q_102020000*PR_002020000100+Q_102120000*PR_002020000110+Q_102220000*PR_002020000120+Q_202020000*PR_002020000200+Q_202120000*PR_002020000210+Q_202220000*PR_002020000220); ans_temp[ans_id*36+14]+=Pmtrx[1]*(Q_001021000*PR_002020000000+Q_001121000*PR_002020000010+Q_001221000*PR_002020000020+Q_001321000*PR_002020000030+Q_101021000*PR_002020000100+Q_101121000*PR_002020000110+Q_101221000*PR_002020000120+Q_101321000*PR_002020000130); ans_temp[ans_id*36+14]+=Pmtrx[2]*(Q_000022000*PR_002020000000+Q_000122000*PR_002020000010+Q_000222000*PR_002020000020+Q_000322000*PR_002020000030+Q_000422000*PR_002020000040); ans_temp[ans_id*36+14]+=Pmtrx[3]*(Q_001020001*PR_002020000000+Q_001020101*PR_002020000001+Q_001120001*PR_002020000010+Q_001120101*PR_002020000011+Q_001220001*PR_002020000020+Q_001220101*PR_002020000021+Q_101020001*PR_002020000100+Q_101020101*PR_002020000101+Q_101120001*PR_002020000110+Q_101120101*PR_002020000111+Q_101220001*PR_002020000120+Q_101220101*PR_002020000121); ans_temp[ans_id*36+14]+=Pmtrx[4]*(Q_000021001*PR_002020000000+Q_000021101*PR_002020000001+Q_000121001*PR_002020000010+Q_000121101*PR_002020000011+Q_000221001*PR_002020000020+Q_000221101*PR_002020000021+Q_000321001*PR_002020000030+Q_000321101*PR_002020000031); ans_temp[ans_id*36+14]+=Pmtrx[5]*(Q_000020002*PR_002020000000+Q_000020102*PR_002020000001+Q_000020202*PR_002020000002+Q_000120002*PR_002020000010+Q_000120102*PR_002020000011+Q_000120202*PR_002020000012+Q_000220002*PR_002020000020+Q_000220102*PR_002020000021+Q_000220202*PR_002020000022); ans_temp[ans_id*36+15]+=Pmtrx[0]*(Q_012000010*PR_002020000000+Q_012000110*PR_002020000001+Q_112000010*PR_002020000100+Q_112000110*PR_002020000101+Q_212000010*PR_002020000200+Q_212000110*PR_002020000201+Q_312000010*PR_002020000300+Q_312000110*PR_002020000301); ans_temp[ans_id*36+15]+=Pmtrx[1]*(Q_011001010*PR_002020000000+Q_011001110*PR_002020000001+Q_011101010*PR_002020000010+Q_011101110*PR_002020000011+Q_111001010*PR_002020000100+Q_111001110*PR_002020000101+Q_111101010*PR_002020000110+Q_111101110*PR_002020000111+Q_211001010*PR_002020000200+Q_211001110*PR_002020000201+Q_211101010*PR_002020000210+Q_211101110*PR_002020000211); ans_temp[ans_id*36+15]+=Pmtrx[2]*(Q_010002010*PR_002020000000+Q_010002110*PR_002020000001+Q_010102010*PR_002020000010+Q_010102110*PR_002020000011+Q_010202010*PR_002020000020+Q_010202110*PR_002020000021+Q_110002010*PR_002020000100+Q_110002110*PR_002020000101+Q_110102010*PR_002020000110+Q_110102110*PR_002020000111+Q_110202010*PR_002020000120+Q_110202110*PR_002020000121); ans_temp[ans_id*36+15]+=Pmtrx[3]*(Q_011000011*PR_002020000000+Q_011000111*PR_002020000001+Q_011000211*PR_002020000002+Q_111000011*PR_002020000100+Q_111000111*PR_002020000101+Q_111000211*PR_002020000102+Q_211000011*PR_002020000200+Q_211000111*PR_002020000201+Q_211000211*PR_002020000202); ans_temp[ans_id*36+15]+=Pmtrx[4]*(Q_010001011*PR_002020000000+Q_010001111*PR_002020000001+Q_010001211*PR_002020000002+Q_010101011*PR_002020000010+Q_010101111*PR_002020000011+Q_010101211*PR_002020000012+Q_110001011*PR_002020000100+Q_110001111*PR_002020000101+Q_110001211*PR_002020000102+Q_110101011*PR_002020000110+Q_110101111*PR_002020000111+Q_110101211*PR_002020000112); ans_temp[ans_id*36+15]+=Pmtrx[5]*(Q_010000012*PR_002020000000+Q_010000112*PR_002020000001+Q_010000212*PR_002020000002+Q_010000312*PR_002020000003+Q_110000012*PR_002020000100+Q_110000112*PR_002020000101+Q_110000212*PR_002020000102+Q_110000312*PR_002020000103); ans_temp[ans_id*36+16]+=Pmtrx[0]*(Q_002010010*PR_002020000000+Q_002010110*PR_002020000001+Q_002110010*PR_002020000010+Q_002110110*PR_002020000011+Q_102010010*PR_002020000100+Q_102010110*PR_002020000101+Q_102110010*PR_002020000110+Q_102110110*PR_002020000111+Q_202010010*PR_002020000200+Q_202010110*PR_002020000201+Q_202110010*PR_002020000210+Q_202110110*PR_002020000211); ans_temp[ans_id*36+16]+=Pmtrx[1]*(Q_001011010*PR_002020000000+Q_001011110*PR_002020000001+Q_001111010*PR_002020000010+Q_001111110*PR_002020000011+Q_001211010*PR_002020000020+Q_001211110*PR_002020000021+Q_101011010*PR_002020000100+Q_101011110*PR_002020000101+Q_101111010*PR_002020000110+Q_101111110*PR_002020000111+Q_101211010*PR_002020000120+Q_101211110*PR_002020000121); ans_temp[ans_id*36+16]+=Pmtrx[2]*(Q_000012010*PR_002020000000+Q_000012110*PR_002020000001+Q_000112010*PR_002020000010+Q_000112110*PR_002020000011+Q_000212010*PR_002020000020+Q_000212110*PR_002020000021+Q_000312010*PR_002020000030+Q_000312110*PR_002020000031); ans_temp[ans_id*36+16]+=Pmtrx[3]*(Q_001010011*PR_002020000000+Q_001010111*PR_002020000001+Q_001010211*PR_002020000002+Q_001110011*PR_002020000010+Q_001110111*PR_002020000011+Q_001110211*PR_002020000012+Q_101010011*PR_002020000100+Q_101010111*PR_002020000101+Q_101010211*PR_002020000102+Q_101110011*PR_002020000110+Q_101110111*PR_002020000111+Q_101110211*PR_002020000112); ans_temp[ans_id*36+16]+=Pmtrx[4]*(Q_000011011*PR_002020000000+Q_000011111*PR_002020000001+Q_000011211*PR_002020000002+Q_000111011*PR_002020000010+Q_000111111*PR_002020000011+Q_000111211*PR_002020000012+Q_000211011*PR_002020000020+Q_000211111*PR_002020000021+Q_000211211*PR_002020000022); ans_temp[ans_id*36+16]+=Pmtrx[5]*(Q_000010012*PR_002020000000+Q_000010112*PR_002020000001+Q_000010212*PR_002020000002+Q_000010312*PR_002020000003+Q_000110012*PR_002020000010+Q_000110112*PR_002020000011+Q_000110212*PR_002020000012+Q_000110312*PR_002020000013); ans_temp[ans_id*36+17]+=Pmtrx[0]*(Q_002000020*PR_002020000000+Q_002000120*PR_002020000001+Q_002000220*PR_002020000002+Q_102000020*PR_002020000100+Q_102000120*PR_002020000101+Q_102000220*PR_002020000102+Q_202000020*PR_002020000200+Q_202000120*PR_002020000201+Q_202000220*PR_002020000202); ans_temp[ans_id*36+17]+=Pmtrx[1]*(Q_001001020*PR_002020000000+Q_001001120*PR_002020000001+Q_001001220*PR_002020000002+Q_001101020*PR_002020000010+Q_001101120*PR_002020000011+Q_001101220*PR_002020000012+Q_101001020*PR_002020000100+Q_101001120*PR_002020000101+Q_101001220*PR_002020000102+Q_101101020*PR_002020000110+Q_101101120*PR_002020000111+Q_101101220*PR_002020000112); ans_temp[ans_id*36+17]+=Pmtrx[2]*(Q_000002020*PR_002020000000+Q_000002120*PR_002020000001+Q_000002220*PR_002020000002+Q_000102020*PR_002020000010+Q_000102120*PR_002020000011+Q_000102220*PR_002020000012+Q_000202020*PR_002020000020+Q_000202120*PR_002020000021+Q_000202220*PR_002020000022); ans_temp[ans_id*36+17]+=Pmtrx[3]*(Q_001000021*PR_002020000000+Q_001000121*PR_002020000001+Q_001000221*PR_002020000002+Q_001000321*PR_002020000003+Q_101000021*PR_002020000100+Q_101000121*PR_002020000101+Q_101000221*PR_002020000102+Q_101000321*PR_002020000103); ans_temp[ans_id*36+17]+=Pmtrx[4]*(Q_000001021*PR_002020000000+Q_000001121*PR_002020000001+Q_000001221*PR_002020000002+Q_000001321*PR_002020000003+Q_000101021*PR_002020000010+Q_000101121*PR_002020000011+Q_000101221*PR_002020000012+Q_000101321*PR_002020000013); ans_temp[ans_id*36+17]+=Pmtrx[5]*(Q_000000022*PR_002020000000+Q_000000122*PR_002020000001+Q_000000222*PR_002020000002+Q_000000322*PR_002020000003+Q_000000422*PR_002020000004); ans_temp[ans_id*36+12]+=Pmtrx[6]*(Q_022000000*PR_001021000000+Q_122000000*PR_001021000100+Q_222000000*PR_001021000200+Q_322000000*PR_001021000300+Q_422000000*PR_001021000400); ans_temp[ans_id*36+12]+=Pmtrx[7]*(Q_021001000*PR_001021000000+Q_021101000*PR_001021000010+Q_121001000*PR_001021000100+Q_121101000*PR_001021000110+Q_221001000*PR_001021000200+Q_221101000*PR_001021000210+Q_321001000*PR_001021000300+Q_321101000*PR_001021000310); ans_temp[ans_id*36+12]+=Pmtrx[8]*(Q_020002000*PR_001021000000+Q_020102000*PR_001021000010+Q_020202000*PR_001021000020+Q_120002000*PR_001021000100+Q_120102000*PR_001021000110+Q_120202000*PR_001021000120+Q_220002000*PR_001021000200+Q_220102000*PR_001021000210+Q_220202000*PR_001021000220); ans_temp[ans_id*36+12]+=Pmtrx[9]*(Q_021000001*PR_001021000000+Q_021000101*PR_001021000001+Q_121000001*PR_001021000100+Q_121000101*PR_001021000101+Q_221000001*PR_001021000200+Q_221000101*PR_001021000201+Q_321000001*PR_001021000300+Q_321000101*PR_001021000301); ans_temp[ans_id*36+12]+=Pmtrx[10]*(Q_020001001*PR_001021000000+Q_020001101*PR_001021000001+Q_020101001*PR_001021000010+Q_020101101*PR_001021000011+Q_120001001*PR_001021000100+Q_120001101*PR_001021000101+Q_120101001*PR_001021000110+Q_120101101*PR_001021000111+Q_220001001*PR_001021000200+Q_220001101*PR_001021000201+Q_220101001*PR_001021000210+Q_220101101*PR_001021000211); ans_temp[ans_id*36+12]+=Pmtrx[11]*(Q_020000002*PR_001021000000+Q_020000102*PR_001021000001+Q_020000202*PR_001021000002+Q_120000002*PR_001021000100+Q_120000102*PR_001021000101+Q_120000202*PR_001021000102+Q_220000002*PR_001021000200+Q_220000102*PR_001021000201+Q_220000202*PR_001021000202); ans_temp[ans_id*36+13]+=Pmtrx[6]*(Q_012010000*PR_001021000000+Q_012110000*PR_001021000010+Q_112010000*PR_001021000100+Q_112110000*PR_001021000110+Q_212010000*PR_001021000200+Q_212110000*PR_001021000210+Q_312010000*PR_001021000300+Q_312110000*PR_001021000310); ans_temp[ans_id*36+13]+=Pmtrx[7]*(Q_011011000*PR_001021000000+Q_011111000*PR_001021000010+Q_011211000*PR_001021000020+Q_111011000*PR_001021000100+Q_111111000*PR_001021000110+Q_111211000*PR_001021000120+Q_211011000*PR_001021000200+Q_211111000*PR_001021000210+Q_211211000*PR_001021000220); ans_temp[ans_id*36+13]+=Pmtrx[8]*(Q_010012000*PR_001021000000+Q_010112000*PR_001021000010+Q_010212000*PR_001021000020+Q_010312000*PR_001021000030+Q_110012000*PR_001021000100+Q_110112000*PR_001021000110+Q_110212000*PR_001021000120+Q_110312000*PR_001021000130); ans_temp[ans_id*36+13]+=Pmtrx[9]*(Q_011010001*PR_001021000000+Q_011010101*PR_001021000001+Q_011110001*PR_001021000010+Q_011110101*PR_001021000011+Q_111010001*PR_001021000100+Q_111010101*PR_001021000101+Q_111110001*PR_001021000110+Q_111110101*PR_001021000111+Q_211010001*PR_001021000200+Q_211010101*PR_001021000201+Q_211110001*PR_001021000210+Q_211110101*PR_001021000211); ans_temp[ans_id*36+13]+=Pmtrx[10]*(Q_010011001*PR_001021000000+Q_010011101*PR_001021000001+Q_010111001*PR_001021000010+Q_010111101*PR_001021000011+Q_010211001*PR_001021000020+Q_010211101*PR_001021000021+Q_110011001*PR_001021000100+Q_110011101*PR_001021000101+Q_110111001*PR_001021000110+Q_110111101*PR_001021000111+Q_110211001*PR_001021000120+Q_110211101*PR_001021000121); ans_temp[ans_id*36+13]+=Pmtrx[11]*(Q_010010002*PR_001021000000+Q_010010102*PR_001021000001+Q_010010202*PR_001021000002+Q_010110002*PR_001021000010+Q_010110102*PR_001021000011+Q_010110202*PR_001021000012+Q_110010002*PR_001021000100+Q_110010102*PR_001021000101+Q_110010202*PR_001021000102+Q_110110002*PR_001021000110+Q_110110102*PR_001021000111+Q_110110202*PR_001021000112); ans_temp[ans_id*36+14]+=Pmtrx[6]*(Q_002020000*PR_001021000000+Q_002120000*PR_001021000010+Q_002220000*PR_001021000020+Q_102020000*PR_001021000100+Q_102120000*PR_001021000110+Q_102220000*PR_001021000120+Q_202020000*PR_001021000200+Q_202120000*PR_001021000210+Q_202220000*PR_001021000220); ans_temp[ans_id*36+14]+=Pmtrx[7]*(Q_001021000*PR_001021000000+Q_001121000*PR_001021000010+Q_001221000*PR_001021000020+Q_001321000*PR_001021000030+Q_101021000*PR_001021000100+Q_101121000*PR_001021000110+Q_101221000*PR_001021000120+Q_101321000*PR_001021000130); ans_temp[ans_id*36+14]+=Pmtrx[8]*(Q_000022000*PR_001021000000+Q_000122000*PR_001021000010+Q_000222000*PR_001021000020+Q_000322000*PR_001021000030+Q_000422000*PR_001021000040); ans_temp[ans_id*36+14]+=Pmtrx[9]*(Q_001020001*PR_001021000000+Q_001020101*PR_001021000001+Q_001120001*PR_001021000010+Q_001120101*PR_001021000011+Q_001220001*PR_001021000020+Q_001220101*PR_001021000021+Q_101020001*PR_001021000100+Q_101020101*PR_001021000101+Q_101120001*PR_001021000110+Q_101120101*PR_001021000111+Q_101220001*PR_001021000120+Q_101220101*PR_001021000121); ans_temp[ans_id*36+14]+=Pmtrx[10]*(Q_000021001*PR_001021000000+Q_000021101*PR_001021000001+Q_000121001*PR_001021000010+Q_000121101*PR_001021000011+Q_000221001*PR_001021000020+Q_000221101*PR_001021000021+Q_000321001*PR_001021000030+Q_000321101*PR_001021000031); ans_temp[ans_id*36+14]+=Pmtrx[11]*(Q_000020002*PR_001021000000+Q_000020102*PR_001021000001+Q_000020202*PR_001021000002+Q_000120002*PR_001021000010+Q_000120102*PR_001021000011+Q_000120202*PR_001021000012+Q_000220002*PR_001021000020+Q_000220102*PR_001021000021+Q_000220202*PR_001021000022); ans_temp[ans_id*36+15]+=Pmtrx[6]*(Q_012000010*PR_001021000000+Q_012000110*PR_001021000001+Q_112000010*PR_001021000100+Q_112000110*PR_001021000101+Q_212000010*PR_001021000200+Q_212000110*PR_001021000201+Q_312000010*PR_001021000300+Q_312000110*PR_001021000301); ans_temp[ans_id*36+15]+=Pmtrx[7]*(Q_011001010*PR_001021000000+Q_011001110*PR_001021000001+Q_011101010*PR_001021000010+Q_011101110*PR_001021000011+Q_111001010*PR_001021000100+Q_111001110*PR_001021000101+Q_111101010*PR_001021000110+Q_111101110*PR_001021000111+Q_211001010*PR_001021000200+Q_211001110*PR_001021000201+Q_211101010*PR_001021000210+Q_211101110*PR_001021000211); ans_temp[ans_id*36+15]+=Pmtrx[8]*(Q_010002010*PR_001021000000+Q_010002110*PR_001021000001+Q_010102010*PR_001021000010+Q_010102110*PR_001021000011+Q_010202010*PR_001021000020+Q_010202110*PR_001021000021+Q_110002010*PR_001021000100+Q_110002110*PR_001021000101+Q_110102010*PR_001021000110+Q_110102110*PR_001021000111+Q_110202010*PR_001021000120+Q_110202110*PR_001021000121); ans_temp[ans_id*36+15]+=Pmtrx[9]*(Q_011000011*PR_001021000000+Q_011000111*PR_001021000001+Q_011000211*PR_001021000002+Q_111000011*PR_001021000100+Q_111000111*PR_001021000101+Q_111000211*PR_001021000102+Q_211000011*PR_001021000200+Q_211000111*PR_001021000201+Q_211000211*PR_001021000202); ans_temp[ans_id*36+15]+=Pmtrx[10]*(Q_010001011*PR_001021000000+Q_010001111*PR_001021000001+Q_010001211*PR_001021000002+Q_010101011*PR_001021000010+Q_010101111*PR_001021000011+Q_010101211*PR_001021000012+Q_110001011*PR_001021000100+Q_110001111*PR_001021000101+Q_110001211*PR_001021000102+Q_110101011*PR_001021000110+Q_110101111*PR_001021000111+Q_110101211*PR_001021000112); ans_temp[ans_id*36+15]+=Pmtrx[11]*(Q_010000012*PR_001021000000+Q_010000112*PR_001021000001+Q_010000212*PR_001021000002+Q_010000312*PR_001021000003+Q_110000012*PR_001021000100+Q_110000112*PR_001021000101+Q_110000212*PR_001021000102+Q_110000312*PR_001021000103); ans_temp[ans_id*36+16]+=Pmtrx[6]*(Q_002010010*PR_001021000000+Q_002010110*PR_001021000001+Q_002110010*PR_001021000010+Q_002110110*PR_001021000011+Q_102010010*PR_001021000100+Q_102010110*PR_001021000101+Q_102110010*PR_001021000110+Q_102110110*PR_001021000111+Q_202010010*PR_001021000200+Q_202010110*PR_001021000201+Q_202110010*PR_001021000210+Q_202110110*PR_001021000211); ans_temp[ans_id*36+16]+=Pmtrx[7]*(Q_001011010*PR_001021000000+Q_001011110*PR_001021000001+Q_001111010*PR_001021000010+Q_001111110*PR_001021000011+Q_001211010*PR_001021000020+Q_001211110*PR_001021000021+Q_101011010*PR_001021000100+Q_101011110*PR_001021000101+Q_101111010*PR_001021000110+Q_101111110*PR_001021000111+Q_101211010*PR_001021000120+Q_101211110*PR_001021000121); ans_temp[ans_id*36+16]+=Pmtrx[8]*(Q_000012010*PR_001021000000+Q_000012110*PR_001021000001+Q_000112010*PR_001021000010+Q_000112110*PR_001021000011+Q_000212010*PR_001021000020+Q_000212110*PR_001021000021+Q_000312010*PR_001021000030+Q_000312110*PR_001021000031); ans_temp[ans_id*36+16]+=Pmtrx[9]*(Q_001010011*PR_001021000000+Q_001010111*PR_001021000001+Q_001010211*PR_001021000002+Q_001110011*PR_001021000010+Q_001110111*PR_001021000011+Q_001110211*PR_001021000012+Q_101010011*PR_001021000100+Q_101010111*PR_001021000101+Q_101010211*PR_001021000102+Q_101110011*PR_001021000110+Q_101110111*PR_001021000111+Q_101110211*PR_001021000112); ans_temp[ans_id*36+16]+=Pmtrx[10]*(Q_000011011*PR_001021000000+Q_000011111*PR_001021000001+Q_000011211*PR_001021000002+Q_000111011*PR_001021000010+Q_000111111*PR_001021000011+Q_000111211*PR_001021000012+Q_000211011*PR_001021000020+Q_000211111*PR_001021000021+Q_000211211*PR_001021000022); ans_temp[ans_id*36+16]+=Pmtrx[11]*(Q_000010012*PR_001021000000+Q_000010112*PR_001021000001+Q_000010212*PR_001021000002+Q_000010312*PR_001021000003+Q_000110012*PR_001021000010+Q_000110112*PR_001021000011+Q_000110212*PR_001021000012+Q_000110312*PR_001021000013); ans_temp[ans_id*36+17]+=Pmtrx[6]*(Q_002000020*PR_001021000000+Q_002000120*PR_001021000001+Q_002000220*PR_001021000002+Q_102000020*PR_001021000100+Q_102000120*PR_001021000101+Q_102000220*PR_001021000102+Q_202000020*PR_001021000200+Q_202000120*PR_001021000201+Q_202000220*PR_001021000202); ans_temp[ans_id*36+17]+=Pmtrx[7]*(Q_001001020*PR_001021000000+Q_001001120*PR_001021000001+Q_001001220*PR_001021000002+Q_001101020*PR_001021000010+Q_001101120*PR_001021000011+Q_001101220*PR_001021000012+Q_101001020*PR_001021000100+Q_101001120*PR_001021000101+Q_101001220*PR_001021000102+Q_101101020*PR_001021000110+Q_101101120*PR_001021000111+Q_101101220*PR_001021000112); ans_temp[ans_id*36+17]+=Pmtrx[8]*(Q_000002020*PR_001021000000+Q_000002120*PR_001021000001+Q_000002220*PR_001021000002+Q_000102020*PR_001021000010+Q_000102120*PR_001021000011+Q_000102220*PR_001021000012+Q_000202020*PR_001021000020+Q_000202120*PR_001021000021+Q_000202220*PR_001021000022); ans_temp[ans_id*36+17]+=Pmtrx[9]*(Q_001000021*PR_001021000000+Q_001000121*PR_001021000001+Q_001000221*PR_001021000002+Q_001000321*PR_001021000003+Q_101000021*PR_001021000100+Q_101000121*PR_001021000101+Q_101000221*PR_001021000102+Q_101000321*PR_001021000103); ans_temp[ans_id*36+17]+=Pmtrx[10]*(Q_000001021*PR_001021000000+Q_000001121*PR_001021000001+Q_000001221*PR_001021000002+Q_000001321*PR_001021000003+Q_000101021*PR_001021000010+Q_000101121*PR_001021000011+Q_000101221*PR_001021000012+Q_000101321*PR_001021000013); ans_temp[ans_id*36+17]+=Pmtrx[11]*(Q_000000022*PR_001021000000+Q_000000122*PR_001021000001+Q_000000222*PR_001021000002+Q_000000322*PR_001021000003+Q_000000422*PR_001021000004); ans_temp[ans_id*36+12]+=Pmtrx[12]*(Q_022000000*PR_000022000000+Q_122000000*PR_000022000100+Q_222000000*PR_000022000200+Q_322000000*PR_000022000300+Q_422000000*PR_000022000400); ans_temp[ans_id*36+12]+=Pmtrx[13]*(Q_021001000*PR_000022000000+Q_021101000*PR_000022000010+Q_121001000*PR_000022000100+Q_121101000*PR_000022000110+Q_221001000*PR_000022000200+Q_221101000*PR_000022000210+Q_321001000*PR_000022000300+Q_321101000*PR_000022000310); ans_temp[ans_id*36+12]+=Pmtrx[14]*(Q_020002000*PR_000022000000+Q_020102000*PR_000022000010+Q_020202000*PR_000022000020+Q_120002000*PR_000022000100+Q_120102000*PR_000022000110+Q_120202000*PR_000022000120+Q_220002000*PR_000022000200+Q_220102000*PR_000022000210+Q_220202000*PR_000022000220); ans_temp[ans_id*36+12]+=Pmtrx[15]*(Q_021000001*PR_000022000000+Q_021000101*PR_000022000001+Q_121000001*PR_000022000100+Q_121000101*PR_000022000101+Q_221000001*PR_000022000200+Q_221000101*PR_000022000201+Q_321000001*PR_000022000300+Q_321000101*PR_000022000301); ans_temp[ans_id*36+12]+=Pmtrx[16]*(Q_020001001*PR_000022000000+Q_020001101*PR_000022000001+Q_020101001*PR_000022000010+Q_020101101*PR_000022000011+Q_120001001*PR_000022000100+Q_120001101*PR_000022000101+Q_120101001*PR_000022000110+Q_120101101*PR_000022000111+Q_220001001*PR_000022000200+Q_220001101*PR_000022000201+Q_220101001*PR_000022000210+Q_220101101*PR_000022000211); ans_temp[ans_id*36+12]+=Pmtrx[17]*(Q_020000002*PR_000022000000+Q_020000102*PR_000022000001+Q_020000202*PR_000022000002+Q_120000002*PR_000022000100+Q_120000102*PR_000022000101+Q_120000202*PR_000022000102+Q_220000002*PR_000022000200+Q_220000102*PR_000022000201+Q_220000202*PR_000022000202); ans_temp[ans_id*36+13]+=Pmtrx[12]*(Q_012010000*PR_000022000000+Q_012110000*PR_000022000010+Q_112010000*PR_000022000100+Q_112110000*PR_000022000110+Q_212010000*PR_000022000200+Q_212110000*PR_000022000210+Q_312010000*PR_000022000300+Q_312110000*PR_000022000310); ans_temp[ans_id*36+13]+=Pmtrx[13]*(Q_011011000*PR_000022000000+Q_011111000*PR_000022000010+Q_011211000*PR_000022000020+Q_111011000*PR_000022000100+Q_111111000*PR_000022000110+Q_111211000*PR_000022000120+Q_211011000*PR_000022000200+Q_211111000*PR_000022000210+Q_211211000*PR_000022000220); ans_temp[ans_id*36+13]+=Pmtrx[14]*(Q_010012000*PR_000022000000+Q_010112000*PR_000022000010+Q_010212000*PR_000022000020+Q_010312000*PR_000022000030+Q_110012000*PR_000022000100+Q_110112000*PR_000022000110+Q_110212000*PR_000022000120+Q_110312000*PR_000022000130); ans_temp[ans_id*36+13]+=Pmtrx[15]*(Q_011010001*PR_000022000000+Q_011010101*PR_000022000001+Q_011110001*PR_000022000010+Q_011110101*PR_000022000011+Q_111010001*PR_000022000100+Q_111010101*PR_000022000101+Q_111110001*PR_000022000110+Q_111110101*PR_000022000111+Q_211010001*PR_000022000200+Q_211010101*PR_000022000201+Q_211110001*PR_000022000210+Q_211110101*PR_000022000211); ans_temp[ans_id*36+13]+=Pmtrx[16]*(Q_010011001*PR_000022000000+Q_010011101*PR_000022000001+Q_010111001*PR_000022000010+Q_010111101*PR_000022000011+Q_010211001*PR_000022000020+Q_010211101*PR_000022000021+Q_110011001*PR_000022000100+Q_110011101*PR_000022000101+Q_110111001*PR_000022000110+Q_110111101*PR_000022000111+Q_110211001*PR_000022000120+Q_110211101*PR_000022000121); ans_temp[ans_id*36+13]+=Pmtrx[17]*(Q_010010002*PR_000022000000+Q_010010102*PR_000022000001+Q_010010202*PR_000022000002+Q_010110002*PR_000022000010+Q_010110102*PR_000022000011+Q_010110202*PR_000022000012+Q_110010002*PR_000022000100+Q_110010102*PR_000022000101+Q_110010202*PR_000022000102+Q_110110002*PR_000022000110+Q_110110102*PR_000022000111+Q_110110202*PR_000022000112); ans_temp[ans_id*36+14]+=Pmtrx[12]*(Q_002020000*PR_000022000000+Q_002120000*PR_000022000010+Q_002220000*PR_000022000020+Q_102020000*PR_000022000100+Q_102120000*PR_000022000110+Q_102220000*PR_000022000120+Q_202020000*PR_000022000200+Q_202120000*PR_000022000210+Q_202220000*PR_000022000220); ans_temp[ans_id*36+14]+=Pmtrx[13]*(Q_001021000*PR_000022000000+Q_001121000*PR_000022000010+Q_001221000*PR_000022000020+Q_001321000*PR_000022000030+Q_101021000*PR_000022000100+Q_101121000*PR_000022000110+Q_101221000*PR_000022000120+Q_101321000*PR_000022000130); ans_temp[ans_id*36+14]+=Pmtrx[14]*(Q_000022000*PR_000022000000+Q_000122000*PR_000022000010+Q_000222000*PR_000022000020+Q_000322000*PR_000022000030+Q_000422000*PR_000022000040); ans_temp[ans_id*36+14]+=Pmtrx[15]*(Q_001020001*PR_000022000000+Q_001020101*PR_000022000001+Q_001120001*PR_000022000010+Q_001120101*PR_000022000011+Q_001220001*PR_000022000020+Q_001220101*PR_000022000021+Q_101020001*PR_000022000100+Q_101020101*PR_000022000101+Q_101120001*PR_000022000110+Q_101120101*PR_000022000111+Q_101220001*PR_000022000120+Q_101220101*PR_000022000121); ans_temp[ans_id*36+14]+=Pmtrx[16]*(Q_000021001*PR_000022000000+Q_000021101*PR_000022000001+Q_000121001*PR_000022000010+Q_000121101*PR_000022000011+Q_000221001*PR_000022000020+Q_000221101*PR_000022000021+Q_000321001*PR_000022000030+Q_000321101*PR_000022000031); ans_temp[ans_id*36+14]+=Pmtrx[17]*(Q_000020002*PR_000022000000+Q_000020102*PR_000022000001+Q_000020202*PR_000022000002+Q_000120002*PR_000022000010+Q_000120102*PR_000022000011+Q_000120202*PR_000022000012+Q_000220002*PR_000022000020+Q_000220102*PR_000022000021+Q_000220202*PR_000022000022); ans_temp[ans_id*36+15]+=Pmtrx[12]*(Q_012000010*PR_000022000000+Q_012000110*PR_000022000001+Q_112000010*PR_000022000100+Q_112000110*PR_000022000101+Q_212000010*PR_000022000200+Q_212000110*PR_000022000201+Q_312000010*PR_000022000300+Q_312000110*PR_000022000301); ans_temp[ans_id*36+15]+=Pmtrx[13]*(Q_011001010*PR_000022000000+Q_011001110*PR_000022000001+Q_011101010*PR_000022000010+Q_011101110*PR_000022000011+Q_111001010*PR_000022000100+Q_111001110*PR_000022000101+Q_111101010*PR_000022000110+Q_111101110*PR_000022000111+Q_211001010*PR_000022000200+Q_211001110*PR_000022000201+Q_211101010*PR_000022000210+Q_211101110*PR_000022000211); ans_temp[ans_id*36+15]+=Pmtrx[14]*(Q_010002010*PR_000022000000+Q_010002110*PR_000022000001+Q_010102010*PR_000022000010+Q_010102110*PR_000022000011+Q_010202010*PR_000022000020+Q_010202110*PR_000022000021+Q_110002010*PR_000022000100+Q_110002110*PR_000022000101+Q_110102010*PR_000022000110+Q_110102110*PR_000022000111+Q_110202010*PR_000022000120+Q_110202110*PR_000022000121); ans_temp[ans_id*36+15]+=Pmtrx[15]*(Q_011000011*PR_000022000000+Q_011000111*PR_000022000001+Q_011000211*PR_000022000002+Q_111000011*PR_000022000100+Q_111000111*PR_000022000101+Q_111000211*PR_000022000102+Q_211000011*PR_000022000200+Q_211000111*PR_000022000201+Q_211000211*PR_000022000202); ans_temp[ans_id*36+15]+=Pmtrx[16]*(Q_010001011*PR_000022000000+Q_010001111*PR_000022000001+Q_010001211*PR_000022000002+Q_010101011*PR_000022000010+Q_010101111*PR_000022000011+Q_010101211*PR_000022000012+Q_110001011*PR_000022000100+Q_110001111*PR_000022000101+Q_110001211*PR_000022000102+Q_110101011*PR_000022000110+Q_110101111*PR_000022000111+Q_110101211*PR_000022000112); ans_temp[ans_id*36+15]+=Pmtrx[17]*(Q_010000012*PR_000022000000+Q_010000112*PR_000022000001+Q_010000212*PR_000022000002+Q_010000312*PR_000022000003+Q_110000012*PR_000022000100+Q_110000112*PR_000022000101+Q_110000212*PR_000022000102+Q_110000312*PR_000022000103); ans_temp[ans_id*36+16]+=Pmtrx[12]*(Q_002010010*PR_000022000000+Q_002010110*PR_000022000001+Q_002110010*PR_000022000010+Q_002110110*PR_000022000011+Q_102010010*PR_000022000100+Q_102010110*PR_000022000101+Q_102110010*PR_000022000110+Q_102110110*PR_000022000111+Q_202010010*PR_000022000200+Q_202010110*PR_000022000201+Q_202110010*PR_000022000210+Q_202110110*PR_000022000211); ans_temp[ans_id*36+16]+=Pmtrx[13]*(Q_001011010*PR_000022000000+Q_001011110*PR_000022000001+Q_001111010*PR_000022000010+Q_001111110*PR_000022000011+Q_001211010*PR_000022000020+Q_001211110*PR_000022000021+Q_101011010*PR_000022000100+Q_101011110*PR_000022000101+Q_101111010*PR_000022000110+Q_101111110*PR_000022000111+Q_101211010*PR_000022000120+Q_101211110*PR_000022000121); ans_temp[ans_id*36+16]+=Pmtrx[14]*(Q_000012010*PR_000022000000+Q_000012110*PR_000022000001+Q_000112010*PR_000022000010+Q_000112110*PR_000022000011+Q_000212010*PR_000022000020+Q_000212110*PR_000022000021+Q_000312010*PR_000022000030+Q_000312110*PR_000022000031); ans_temp[ans_id*36+16]+=Pmtrx[15]*(Q_001010011*PR_000022000000+Q_001010111*PR_000022000001+Q_001010211*PR_000022000002+Q_001110011*PR_000022000010+Q_001110111*PR_000022000011+Q_001110211*PR_000022000012+Q_101010011*PR_000022000100+Q_101010111*PR_000022000101+Q_101010211*PR_000022000102+Q_101110011*PR_000022000110+Q_101110111*PR_000022000111+Q_101110211*PR_000022000112); ans_temp[ans_id*36+16]+=Pmtrx[16]*(Q_000011011*PR_000022000000+Q_000011111*PR_000022000001+Q_000011211*PR_000022000002+Q_000111011*PR_000022000010+Q_000111111*PR_000022000011+Q_000111211*PR_000022000012+Q_000211011*PR_000022000020+Q_000211111*PR_000022000021+Q_000211211*PR_000022000022); ans_temp[ans_id*36+16]+=Pmtrx[17]*(Q_000010012*PR_000022000000+Q_000010112*PR_000022000001+Q_000010212*PR_000022000002+Q_000010312*PR_000022000003+Q_000110012*PR_000022000010+Q_000110112*PR_000022000011+Q_000110212*PR_000022000012+Q_000110312*PR_000022000013); ans_temp[ans_id*36+17]+=Pmtrx[12]*(Q_002000020*PR_000022000000+Q_002000120*PR_000022000001+Q_002000220*PR_000022000002+Q_102000020*PR_000022000100+Q_102000120*PR_000022000101+Q_102000220*PR_000022000102+Q_202000020*PR_000022000200+Q_202000120*PR_000022000201+Q_202000220*PR_000022000202); ans_temp[ans_id*36+17]+=Pmtrx[13]*(Q_001001020*PR_000022000000+Q_001001120*PR_000022000001+Q_001001220*PR_000022000002+Q_001101020*PR_000022000010+Q_001101120*PR_000022000011+Q_001101220*PR_000022000012+Q_101001020*PR_000022000100+Q_101001120*PR_000022000101+Q_101001220*PR_000022000102+Q_101101020*PR_000022000110+Q_101101120*PR_000022000111+Q_101101220*PR_000022000112); ans_temp[ans_id*36+17]+=Pmtrx[14]*(Q_000002020*PR_000022000000+Q_000002120*PR_000022000001+Q_000002220*PR_000022000002+Q_000102020*PR_000022000010+Q_000102120*PR_000022000011+Q_000102220*PR_000022000012+Q_000202020*PR_000022000020+Q_000202120*PR_000022000021+Q_000202220*PR_000022000022); ans_temp[ans_id*36+17]+=Pmtrx[15]*(Q_001000021*PR_000022000000+Q_001000121*PR_000022000001+Q_001000221*PR_000022000002+Q_001000321*PR_000022000003+Q_101000021*PR_000022000100+Q_101000121*PR_000022000101+Q_101000221*PR_000022000102+Q_101000321*PR_000022000103); ans_temp[ans_id*36+17]+=Pmtrx[16]*(Q_000001021*PR_000022000000+Q_000001121*PR_000022000001+Q_000001221*PR_000022000002+Q_000001321*PR_000022000003+Q_000101021*PR_000022000010+Q_000101121*PR_000022000011+Q_000101221*PR_000022000012+Q_000101321*PR_000022000013); ans_temp[ans_id*36+17]+=Pmtrx[17]*(Q_000000022*PR_000022000000+Q_000000122*PR_000022000001+Q_000000222*PR_000022000002+Q_000000322*PR_000022000003+Q_000000422*PR_000022000004); ans_temp[ans_id*36+12]+=Pmtrx[18]*(Q_022000000*PR_001020001000+Q_122000000*PR_001020001100+Q_222000000*PR_001020001200+Q_322000000*PR_001020001300+Q_422000000*PR_001020001400); ans_temp[ans_id*36+12]+=Pmtrx[19]*(Q_021001000*PR_001020001000+Q_021101000*PR_001020001010+Q_121001000*PR_001020001100+Q_121101000*PR_001020001110+Q_221001000*PR_001020001200+Q_221101000*PR_001020001210+Q_321001000*PR_001020001300+Q_321101000*PR_001020001310); ans_temp[ans_id*36+12]+=Pmtrx[20]*(Q_020002000*PR_001020001000+Q_020102000*PR_001020001010+Q_020202000*PR_001020001020+Q_120002000*PR_001020001100+Q_120102000*PR_001020001110+Q_120202000*PR_001020001120+Q_220002000*PR_001020001200+Q_220102000*PR_001020001210+Q_220202000*PR_001020001220); ans_temp[ans_id*36+12]+=Pmtrx[21]*(Q_021000001*PR_001020001000+Q_021000101*PR_001020001001+Q_121000001*PR_001020001100+Q_121000101*PR_001020001101+Q_221000001*PR_001020001200+Q_221000101*PR_001020001201+Q_321000001*PR_001020001300+Q_321000101*PR_001020001301); ans_temp[ans_id*36+12]+=Pmtrx[22]*(Q_020001001*PR_001020001000+Q_020001101*PR_001020001001+Q_020101001*PR_001020001010+Q_020101101*PR_001020001011+Q_120001001*PR_001020001100+Q_120001101*PR_001020001101+Q_120101001*PR_001020001110+Q_120101101*PR_001020001111+Q_220001001*PR_001020001200+Q_220001101*PR_001020001201+Q_220101001*PR_001020001210+Q_220101101*PR_001020001211); ans_temp[ans_id*36+12]+=Pmtrx[23]*(Q_020000002*PR_001020001000+Q_020000102*PR_001020001001+Q_020000202*PR_001020001002+Q_120000002*PR_001020001100+Q_120000102*PR_001020001101+Q_120000202*PR_001020001102+Q_220000002*PR_001020001200+Q_220000102*PR_001020001201+Q_220000202*PR_001020001202); ans_temp[ans_id*36+13]+=Pmtrx[18]*(Q_012010000*PR_001020001000+Q_012110000*PR_001020001010+Q_112010000*PR_001020001100+Q_112110000*PR_001020001110+Q_212010000*PR_001020001200+Q_212110000*PR_001020001210+Q_312010000*PR_001020001300+Q_312110000*PR_001020001310); ans_temp[ans_id*36+13]+=Pmtrx[19]*(Q_011011000*PR_001020001000+Q_011111000*PR_001020001010+Q_011211000*PR_001020001020+Q_111011000*PR_001020001100+Q_111111000*PR_001020001110+Q_111211000*PR_001020001120+Q_211011000*PR_001020001200+Q_211111000*PR_001020001210+Q_211211000*PR_001020001220); ans_temp[ans_id*36+13]+=Pmtrx[20]*(Q_010012000*PR_001020001000+Q_010112000*PR_001020001010+Q_010212000*PR_001020001020+Q_010312000*PR_001020001030+Q_110012000*PR_001020001100+Q_110112000*PR_001020001110+Q_110212000*PR_001020001120+Q_110312000*PR_001020001130); ans_temp[ans_id*36+13]+=Pmtrx[21]*(Q_011010001*PR_001020001000+Q_011010101*PR_001020001001+Q_011110001*PR_001020001010+Q_011110101*PR_001020001011+Q_111010001*PR_001020001100+Q_111010101*PR_001020001101+Q_111110001*PR_001020001110+Q_111110101*PR_001020001111+Q_211010001*PR_001020001200+Q_211010101*PR_001020001201+Q_211110001*PR_001020001210+Q_211110101*PR_001020001211); ans_temp[ans_id*36+13]+=Pmtrx[22]*(Q_010011001*PR_001020001000+Q_010011101*PR_001020001001+Q_010111001*PR_001020001010+Q_010111101*PR_001020001011+Q_010211001*PR_001020001020+Q_010211101*PR_001020001021+Q_110011001*PR_001020001100+Q_110011101*PR_001020001101+Q_110111001*PR_001020001110+Q_110111101*PR_001020001111+Q_110211001*PR_001020001120+Q_110211101*PR_001020001121); ans_temp[ans_id*36+13]+=Pmtrx[23]*(Q_010010002*PR_001020001000+Q_010010102*PR_001020001001+Q_010010202*PR_001020001002+Q_010110002*PR_001020001010+Q_010110102*PR_001020001011+Q_010110202*PR_001020001012+Q_110010002*PR_001020001100+Q_110010102*PR_001020001101+Q_110010202*PR_001020001102+Q_110110002*PR_001020001110+Q_110110102*PR_001020001111+Q_110110202*PR_001020001112); ans_temp[ans_id*36+14]+=Pmtrx[18]*(Q_002020000*PR_001020001000+Q_002120000*PR_001020001010+Q_002220000*PR_001020001020+Q_102020000*PR_001020001100+Q_102120000*PR_001020001110+Q_102220000*PR_001020001120+Q_202020000*PR_001020001200+Q_202120000*PR_001020001210+Q_202220000*PR_001020001220); ans_temp[ans_id*36+14]+=Pmtrx[19]*(Q_001021000*PR_001020001000+Q_001121000*PR_001020001010+Q_001221000*PR_001020001020+Q_001321000*PR_001020001030+Q_101021000*PR_001020001100+Q_101121000*PR_001020001110+Q_101221000*PR_001020001120+Q_101321000*PR_001020001130); ans_temp[ans_id*36+14]+=Pmtrx[20]*(Q_000022000*PR_001020001000+Q_000122000*PR_001020001010+Q_000222000*PR_001020001020+Q_000322000*PR_001020001030+Q_000422000*PR_001020001040); ans_temp[ans_id*36+14]+=Pmtrx[21]*(Q_001020001*PR_001020001000+Q_001020101*PR_001020001001+Q_001120001*PR_001020001010+Q_001120101*PR_001020001011+Q_001220001*PR_001020001020+Q_001220101*PR_001020001021+Q_101020001*PR_001020001100+Q_101020101*PR_001020001101+Q_101120001*PR_001020001110+Q_101120101*PR_001020001111+Q_101220001*PR_001020001120+Q_101220101*PR_001020001121); ans_temp[ans_id*36+14]+=Pmtrx[22]*(Q_000021001*PR_001020001000+Q_000021101*PR_001020001001+Q_000121001*PR_001020001010+Q_000121101*PR_001020001011+Q_000221001*PR_001020001020+Q_000221101*PR_001020001021+Q_000321001*PR_001020001030+Q_000321101*PR_001020001031); ans_temp[ans_id*36+14]+=Pmtrx[23]*(Q_000020002*PR_001020001000+Q_000020102*PR_001020001001+Q_000020202*PR_001020001002+Q_000120002*PR_001020001010+Q_000120102*PR_001020001011+Q_000120202*PR_001020001012+Q_000220002*PR_001020001020+Q_000220102*PR_001020001021+Q_000220202*PR_001020001022); ans_temp[ans_id*36+15]+=Pmtrx[18]*(Q_012000010*PR_001020001000+Q_012000110*PR_001020001001+Q_112000010*PR_001020001100+Q_112000110*PR_001020001101+Q_212000010*PR_001020001200+Q_212000110*PR_001020001201+Q_312000010*PR_001020001300+Q_312000110*PR_001020001301); ans_temp[ans_id*36+15]+=Pmtrx[19]*(Q_011001010*PR_001020001000+Q_011001110*PR_001020001001+Q_011101010*PR_001020001010+Q_011101110*PR_001020001011+Q_111001010*PR_001020001100+Q_111001110*PR_001020001101+Q_111101010*PR_001020001110+Q_111101110*PR_001020001111+Q_211001010*PR_001020001200+Q_211001110*PR_001020001201+Q_211101010*PR_001020001210+Q_211101110*PR_001020001211); ans_temp[ans_id*36+15]+=Pmtrx[20]*(Q_010002010*PR_001020001000+Q_010002110*PR_001020001001+Q_010102010*PR_001020001010+Q_010102110*PR_001020001011+Q_010202010*PR_001020001020+Q_010202110*PR_001020001021+Q_110002010*PR_001020001100+Q_110002110*PR_001020001101+Q_110102010*PR_001020001110+Q_110102110*PR_001020001111+Q_110202010*PR_001020001120+Q_110202110*PR_001020001121); ans_temp[ans_id*36+15]+=Pmtrx[21]*(Q_011000011*PR_001020001000+Q_011000111*PR_001020001001+Q_011000211*PR_001020001002+Q_111000011*PR_001020001100+Q_111000111*PR_001020001101+Q_111000211*PR_001020001102+Q_211000011*PR_001020001200+Q_211000111*PR_001020001201+Q_211000211*PR_001020001202); ans_temp[ans_id*36+15]+=Pmtrx[22]*(Q_010001011*PR_001020001000+Q_010001111*PR_001020001001+Q_010001211*PR_001020001002+Q_010101011*PR_001020001010+Q_010101111*PR_001020001011+Q_010101211*PR_001020001012+Q_110001011*PR_001020001100+Q_110001111*PR_001020001101+Q_110001211*PR_001020001102+Q_110101011*PR_001020001110+Q_110101111*PR_001020001111+Q_110101211*PR_001020001112); ans_temp[ans_id*36+15]+=Pmtrx[23]*(Q_010000012*PR_001020001000+Q_010000112*PR_001020001001+Q_010000212*PR_001020001002+Q_010000312*PR_001020001003+Q_110000012*PR_001020001100+Q_110000112*PR_001020001101+Q_110000212*PR_001020001102+Q_110000312*PR_001020001103); ans_temp[ans_id*36+16]+=Pmtrx[18]*(Q_002010010*PR_001020001000+Q_002010110*PR_001020001001+Q_002110010*PR_001020001010+Q_002110110*PR_001020001011+Q_102010010*PR_001020001100+Q_102010110*PR_001020001101+Q_102110010*PR_001020001110+Q_102110110*PR_001020001111+Q_202010010*PR_001020001200+Q_202010110*PR_001020001201+Q_202110010*PR_001020001210+Q_202110110*PR_001020001211); ans_temp[ans_id*36+16]+=Pmtrx[19]*(Q_001011010*PR_001020001000+Q_001011110*PR_001020001001+Q_001111010*PR_001020001010+Q_001111110*PR_001020001011+Q_001211010*PR_001020001020+Q_001211110*PR_001020001021+Q_101011010*PR_001020001100+Q_101011110*PR_001020001101+Q_101111010*PR_001020001110+Q_101111110*PR_001020001111+Q_101211010*PR_001020001120+Q_101211110*PR_001020001121); ans_temp[ans_id*36+16]+=Pmtrx[20]*(Q_000012010*PR_001020001000+Q_000012110*PR_001020001001+Q_000112010*PR_001020001010+Q_000112110*PR_001020001011+Q_000212010*PR_001020001020+Q_000212110*PR_001020001021+Q_000312010*PR_001020001030+Q_000312110*PR_001020001031); ans_temp[ans_id*36+16]+=Pmtrx[21]*(Q_001010011*PR_001020001000+Q_001010111*PR_001020001001+Q_001010211*PR_001020001002+Q_001110011*PR_001020001010+Q_001110111*PR_001020001011+Q_001110211*PR_001020001012+Q_101010011*PR_001020001100+Q_101010111*PR_001020001101+Q_101010211*PR_001020001102+Q_101110011*PR_001020001110+Q_101110111*PR_001020001111+Q_101110211*PR_001020001112); ans_temp[ans_id*36+16]+=Pmtrx[22]*(Q_000011011*PR_001020001000+Q_000011111*PR_001020001001+Q_000011211*PR_001020001002+Q_000111011*PR_001020001010+Q_000111111*PR_001020001011+Q_000111211*PR_001020001012+Q_000211011*PR_001020001020+Q_000211111*PR_001020001021+Q_000211211*PR_001020001022); ans_temp[ans_id*36+16]+=Pmtrx[23]*(Q_000010012*PR_001020001000+Q_000010112*PR_001020001001+Q_000010212*PR_001020001002+Q_000010312*PR_001020001003+Q_000110012*PR_001020001010+Q_000110112*PR_001020001011+Q_000110212*PR_001020001012+Q_000110312*PR_001020001013); ans_temp[ans_id*36+17]+=Pmtrx[18]*(Q_002000020*PR_001020001000+Q_002000120*PR_001020001001+Q_002000220*PR_001020001002+Q_102000020*PR_001020001100+Q_102000120*PR_001020001101+Q_102000220*PR_001020001102+Q_202000020*PR_001020001200+Q_202000120*PR_001020001201+Q_202000220*PR_001020001202); ans_temp[ans_id*36+17]+=Pmtrx[19]*(Q_001001020*PR_001020001000+Q_001001120*PR_001020001001+Q_001001220*PR_001020001002+Q_001101020*PR_001020001010+Q_001101120*PR_001020001011+Q_001101220*PR_001020001012+Q_101001020*PR_001020001100+Q_101001120*PR_001020001101+Q_101001220*PR_001020001102+Q_101101020*PR_001020001110+Q_101101120*PR_001020001111+Q_101101220*PR_001020001112); ans_temp[ans_id*36+17]+=Pmtrx[20]*(Q_000002020*PR_001020001000+Q_000002120*PR_001020001001+Q_000002220*PR_001020001002+Q_000102020*PR_001020001010+Q_000102120*PR_001020001011+Q_000102220*PR_001020001012+Q_000202020*PR_001020001020+Q_000202120*PR_001020001021+Q_000202220*PR_001020001022); ans_temp[ans_id*36+17]+=Pmtrx[21]*(Q_001000021*PR_001020001000+Q_001000121*PR_001020001001+Q_001000221*PR_001020001002+Q_001000321*PR_001020001003+Q_101000021*PR_001020001100+Q_101000121*PR_001020001101+Q_101000221*PR_001020001102+Q_101000321*PR_001020001103); ans_temp[ans_id*36+17]+=Pmtrx[22]*(Q_000001021*PR_001020001000+Q_000001121*PR_001020001001+Q_000001221*PR_001020001002+Q_000001321*PR_001020001003+Q_000101021*PR_001020001010+Q_000101121*PR_001020001011+Q_000101221*PR_001020001012+Q_000101321*PR_001020001013); ans_temp[ans_id*36+17]+=Pmtrx[23]*(Q_000000022*PR_001020001000+Q_000000122*PR_001020001001+Q_000000222*PR_001020001002+Q_000000322*PR_001020001003+Q_000000422*PR_001020001004); ans_temp[ans_id*36+12]+=Pmtrx[24]*(Q_022000000*PR_000021001000+Q_122000000*PR_000021001100+Q_222000000*PR_000021001200+Q_322000000*PR_000021001300+Q_422000000*PR_000021001400); ans_temp[ans_id*36+12]+=Pmtrx[25]*(Q_021001000*PR_000021001000+Q_021101000*PR_000021001010+Q_121001000*PR_000021001100+Q_121101000*PR_000021001110+Q_221001000*PR_000021001200+Q_221101000*PR_000021001210+Q_321001000*PR_000021001300+Q_321101000*PR_000021001310); ans_temp[ans_id*36+12]+=Pmtrx[26]*(Q_020002000*PR_000021001000+Q_020102000*PR_000021001010+Q_020202000*PR_000021001020+Q_120002000*PR_000021001100+Q_120102000*PR_000021001110+Q_120202000*PR_000021001120+Q_220002000*PR_000021001200+Q_220102000*PR_000021001210+Q_220202000*PR_000021001220); ans_temp[ans_id*36+12]+=Pmtrx[27]*(Q_021000001*PR_000021001000+Q_021000101*PR_000021001001+Q_121000001*PR_000021001100+Q_121000101*PR_000021001101+Q_221000001*PR_000021001200+Q_221000101*PR_000021001201+Q_321000001*PR_000021001300+Q_321000101*PR_000021001301); ans_temp[ans_id*36+12]+=Pmtrx[28]*(Q_020001001*PR_000021001000+Q_020001101*PR_000021001001+Q_020101001*PR_000021001010+Q_020101101*PR_000021001011+Q_120001001*PR_000021001100+Q_120001101*PR_000021001101+Q_120101001*PR_000021001110+Q_120101101*PR_000021001111+Q_220001001*PR_000021001200+Q_220001101*PR_000021001201+Q_220101001*PR_000021001210+Q_220101101*PR_000021001211); ans_temp[ans_id*36+12]+=Pmtrx[29]*(Q_020000002*PR_000021001000+Q_020000102*PR_000021001001+Q_020000202*PR_000021001002+Q_120000002*PR_000021001100+Q_120000102*PR_000021001101+Q_120000202*PR_000021001102+Q_220000002*PR_000021001200+Q_220000102*PR_000021001201+Q_220000202*PR_000021001202); ans_temp[ans_id*36+13]+=Pmtrx[24]*(Q_012010000*PR_000021001000+Q_012110000*PR_000021001010+Q_112010000*PR_000021001100+Q_112110000*PR_000021001110+Q_212010000*PR_000021001200+Q_212110000*PR_000021001210+Q_312010000*PR_000021001300+Q_312110000*PR_000021001310); ans_temp[ans_id*36+13]+=Pmtrx[25]*(Q_011011000*PR_000021001000+Q_011111000*PR_000021001010+Q_011211000*PR_000021001020+Q_111011000*PR_000021001100+Q_111111000*PR_000021001110+Q_111211000*PR_000021001120+Q_211011000*PR_000021001200+Q_211111000*PR_000021001210+Q_211211000*PR_000021001220); ans_temp[ans_id*36+13]+=Pmtrx[26]*(Q_010012000*PR_000021001000+Q_010112000*PR_000021001010+Q_010212000*PR_000021001020+Q_010312000*PR_000021001030+Q_110012000*PR_000021001100+Q_110112000*PR_000021001110+Q_110212000*PR_000021001120+Q_110312000*PR_000021001130); ans_temp[ans_id*36+13]+=Pmtrx[27]*(Q_011010001*PR_000021001000+Q_011010101*PR_000021001001+Q_011110001*PR_000021001010+Q_011110101*PR_000021001011+Q_111010001*PR_000021001100+Q_111010101*PR_000021001101+Q_111110001*PR_000021001110+Q_111110101*PR_000021001111+Q_211010001*PR_000021001200+Q_211010101*PR_000021001201+Q_211110001*PR_000021001210+Q_211110101*PR_000021001211); ans_temp[ans_id*36+13]+=Pmtrx[28]*(Q_010011001*PR_000021001000+Q_010011101*PR_000021001001+Q_010111001*PR_000021001010+Q_010111101*PR_000021001011+Q_010211001*PR_000021001020+Q_010211101*PR_000021001021+Q_110011001*PR_000021001100+Q_110011101*PR_000021001101+Q_110111001*PR_000021001110+Q_110111101*PR_000021001111+Q_110211001*PR_000021001120+Q_110211101*PR_000021001121); ans_temp[ans_id*36+13]+=Pmtrx[29]*(Q_010010002*PR_000021001000+Q_010010102*PR_000021001001+Q_010010202*PR_000021001002+Q_010110002*PR_000021001010+Q_010110102*PR_000021001011+Q_010110202*PR_000021001012+Q_110010002*PR_000021001100+Q_110010102*PR_000021001101+Q_110010202*PR_000021001102+Q_110110002*PR_000021001110+Q_110110102*PR_000021001111+Q_110110202*PR_000021001112); ans_temp[ans_id*36+14]+=Pmtrx[24]*(Q_002020000*PR_000021001000+Q_002120000*PR_000021001010+Q_002220000*PR_000021001020+Q_102020000*PR_000021001100+Q_102120000*PR_000021001110+Q_102220000*PR_000021001120+Q_202020000*PR_000021001200+Q_202120000*PR_000021001210+Q_202220000*PR_000021001220); ans_temp[ans_id*36+14]+=Pmtrx[25]*(Q_001021000*PR_000021001000+Q_001121000*PR_000021001010+Q_001221000*PR_000021001020+Q_001321000*PR_000021001030+Q_101021000*PR_000021001100+Q_101121000*PR_000021001110+Q_101221000*PR_000021001120+Q_101321000*PR_000021001130); ans_temp[ans_id*36+14]+=Pmtrx[26]*(Q_000022000*PR_000021001000+Q_000122000*PR_000021001010+Q_000222000*PR_000021001020+Q_000322000*PR_000021001030+Q_000422000*PR_000021001040); ans_temp[ans_id*36+14]+=Pmtrx[27]*(Q_001020001*PR_000021001000+Q_001020101*PR_000021001001+Q_001120001*PR_000021001010+Q_001120101*PR_000021001011+Q_001220001*PR_000021001020+Q_001220101*PR_000021001021+Q_101020001*PR_000021001100+Q_101020101*PR_000021001101+Q_101120001*PR_000021001110+Q_101120101*PR_000021001111+Q_101220001*PR_000021001120+Q_101220101*PR_000021001121); ans_temp[ans_id*36+14]+=Pmtrx[28]*(Q_000021001*PR_000021001000+Q_000021101*PR_000021001001+Q_000121001*PR_000021001010+Q_000121101*PR_000021001011+Q_000221001*PR_000021001020+Q_000221101*PR_000021001021+Q_000321001*PR_000021001030+Q_000321101*PR_000021001031); ans_temp[ans_id*36+14]+=Pmtrx[29]*(Q_000020002*PR_000021001000+Q_000020102*PR_000021001001+Q_000020202*PR_000021001002+Q_000120002*PR_000021001010+Q_000120102*PR_000021001011+Q_000120202*PR_000021001012+Q_000220002*PR_000021001020+Q_000220102*PR_000021001021+Q_000220202*PR_000021001022); ans_temp[ans_id*36+15]+=Pmtrx[24]*(Q_012000010*PR_000021001000+Q_012000110*PR_000021001001+Q_112000010*PR_000021001100+Q_112000110*PR_000021001101+Q_212000010*PR_000021001200+Q_212000110*PR_000021001201+Q_312000010*PR_000021001300+Q_312000110*PR_000021001301); ans_temp[ans_id*36+15]+=Pmtrx[25]*(Q_011001010*PR_000021001000+Q_011001110*PR_000021001001+Q_011101010*PR_000021001010+Q_011101110*PR_000021001011+Q_111001010*PR_000021001100+Q_111001110*PR_000021001101+Q_111101010*PR_000021001110+Q_111101110*PR_000021001111+Q_211001010*PR_000021001200+Q_211001110*PR_000021001201+Q_211101010*PR_000021001210+Q_211101110*PR_000021001211); ans_temp[ans_id*36+15]+=Pmtrx[26]*(Q_010002010*PR_000021001000+Q_010002110*PR_000021001001+Q_010102010*PR_000021001010+Q_010102110*PR_000021001011+Q_010202010*PR_000021001020+Q_010202110*PR_000021001021+Q_110002010*PR_000021001100+Q_110002110*PR_000021001101+Q_110102010*PR_000021001110+Q_110102110*PR_000021001111+Q_110202010*PR_000021001120+Q_110202110*PR_000021001121); ans_temp[ans_id*36+15]+=Pmtrx[27]*(Q_011000011*PR_000021001000+Q_011000111*PR_000021001001+Q_011000211*PR_000021001002+Q_111000011*PR_000021001100+Q_111000111*PR_000021001101+Q_111000211*PR_000021001102+Q_211000011*PR_000021001200+Q_211000111*PR_000021001201+Q_211000211*PR_000021001202); ans_temp[ans_id*36+15]+=Pmtrx[28]*(Q_010001011*PR_000021001000+Q_010001111*PR_000021001001+Q_010001211*PR_000021001002+Q_010101011*PR_000021001010+Q_010101111*PR_000021001011+Q_010101211*PR_000021001012+Q_110001011*PR_000021001100+Q_110001111*PR_000021001101+Q_110001211*PR_000021001102+Q_110101011*PR_000021001110+Q_110101111*PR_000021001111+Q_110101211*PR_000021001112); ans_temp[ans_id*36+15]+=Pmtrx[29]*(Q_010000012*PR_000021001000+Q_010000112*PR_000021001001+Q_010000212*PR_000021001002+Q_010000312*PR_000021001003+Q_110000012*PR_000021001100+Q_110000112*PR_000021001101+Q_110000212*PR_000021001102+Q_110000312*PR_000021001103); ans_temp[ans_id*36+16]+=Pmtrx[24]*(Q_002010010*PR_000021001000+Q_002010110*PR_000021001001+Q_002110010*PR_000021001010+Q_002110110*PR_000021001011+Q_102010010*PR_000021001100+Q_102010110*PR_000021001101+Q_102110010*PR_000021001110+Q_102110110*PR_000021001111+Q_202010010*PR_000021001200+Q_202010110*PR_000021001201+Q_202110010*PR_000021001210+Q_202110110*PR_000021001211); ans_temp[ans_id*36+16]+=Pmtrx[25]*(Q_001011010*PR_000021001000+Q_001011110*PR_000021001001+Q_001111010*PR_000021001010+Q_001111110*PR_000021001011+Q_001211010*PR_000021001020+Q_001211110*PR_000021001021+Q_101011010*PR_000021001100+Q_101011110*PR_000021001101+Q_101111010*PR_000021001110+Q_101111110*PR_000021001111+Q_101211010*PR_000021001120+Q_101211110*PR_000021001121); ans_temp[ans_id*36+16]+=Pmtrx[26]*(Q_000012010*PR_000021001000+Q_000012110*PR_000021001001+Q_000112010*PR_000021001010+Q_000112110*PR_000021001011+Q_000212010*PR_000021001020+Q_000212110*PR_000021001021+Q_000312010*PR_000021001030+Q_000312110*PR_000021001031); ans_temp[ans_id*36+16]+=Pmtrx[27]*(Q_001010011*PR_000021001000+Q_001010111*PR_000021001001+Q_001010211*PR_000021001002+Q_001110011*PR_000021001010+Q_001110111*PR_000021001011+Q_001110211*PR_000021001012+Q_101010011*PR_000021001100+Q_101010111*PR_000021001101+Q_101010211*PR_000021001102+Q_101110011*PR_000021001110+Q_101110111*PR_000021001111+Q_101110211*PR_000021001112); ans_temp[ans_id*36+16]+=Pmtrx[28]*(Q_000011011*PR_000021001000+Q_000011111*PR_000021001001+Q_000011211*PR_000021001002+Q_000111011*PR_000021001010+Q_000111111*PR_000021001011+Q_000111211*PR_000021001012+Q_000211011*PR_000021001020+Q_000211111*PR_000021001021+Q_000211211*PR_000021001022); ans_temp[ans_id*36+16]+=Pmtrx[29]*(Q_000010012*PR_000021001000+Q_000010112*PR_000021001001+Q_000010212*PR_000021001002+Q_000010312*PR_000021001003+Q_000110012*PR_000021001010+Q_000110112*PR_000021001011+Q_000110212*PR_000021001012+Q_000110312*PR_000021001013); ans_temp[ans_id*36+17]+=Pmtrx[24]*(Q_002000020*PR_000021001000+Q_002000120*PR_000021001001+Q_002000220*PR_000021001002+Q_102000020*PR_000021001100+Q_102000120*PR_000021001101+Q_102000220*PR_000021001102+Q_202000020*PR_000021001200+Q_202000120*PR_000021001201+Q_202000220*PR_000021001202); ans_temp[ans_id*36+17]+=Pmtrx[25]*(Q_001001020*PR_000021001000+Q_001001120*PR_000021001001+Q_001001220*PR_000021001002+Q_001101020*PR_000021001010+Q_001101120*PR_000021001011+Q_001101220*PR_000021001012+Q_101001020*PR_000021001100+Q_101001120*PR_000021001101+Q_101001220*PR_000021001102+Q_101101020*PR_000021001110+Q_101101120*PR_000021001111+Q_101101220*PR_000021001112); ans_temp[ans_id*36+17]+=Pmtrx[26]*(Q_000002020*PR_000021001000+Q_000002120*PR_000021001001+Q_000002220*PR_000021001002+Q_000102020*PR_000021001010+Q_000102120*PR_000021001011+Q_000102220*PR_000021001012+Q_000202020*PR_000021001020+Q_000202120*PR_000021001021+Q_000202220*PR_000021001022); ans_temp[ans_id*36+17]+=Pmtrx[27]*(Q_001000021*PR_000021001000+Q_001000121*PR_000021001001+Q_001000221*PR_000021001002+Q_001000321*PR_000021001003+Q_101000021*PR_000021001100+Q_101000121*PR_000021001101+Q_101000221*PR_000021001102+Q_101000321*PR_000021001103); ans_temp[ans_id*36+17]+=Pmtrx[28]*(Q_000001021*PR_000021001000+Q_000001121*PR_000021001001+Q_000001221*PR_000021001002+Q_000001321*PR_000021001003+Q_000101021*PR_000021001010+Q_000101121*PR_000021001011+Q_000101221*PR_000021001012+Q_000101321*PR_000021001013); ans_temp[ans_id*36+17]+=Pmtrx[29]*(Q_000000022*PR_000021001000+Q_000000122*PR_000021001001+Q_000000222*PR_000021001002+Q_000000322*PR_000021001003+Q_000000422*PR_000021001004); ans_temp[ans_id*36+12]+=Pmtrx[30]*(Q_022000000*PR_000020002000+Q_122000000*PR_000020002100+Q_222000000*PR_000020002200+Q_322000000*PR_000020002300+Q_422000000*PR_000020002400); ans_temp[ans_id*36+12]+=Pmtrx[31]*(Q_021001000*PR_000020002000+Q_021101000*PR_000020002010+Q_121001000*PR_000020002100+Q_121101000*PR_000020002110+Q_221001000*PR_000020002200+Q_221101000*PR_000020002210+Q_321001000*PR_000020002300+Q_321101000*PR_000020002310); ans_temp[ans_id*36+12]+=Pmtrx[32]*(Q_020002000*PR_000020002000+Q_020102000*PR_000020002010+Q_020202000*PR_000020002020+Q_120002000*PR_000020002100+Q_120102000*PR_000020002110+Q_120202000*PR_000020002120+Q_220002000*PR_000020002200+Q_220102000*PR_000020002210+Q_220202000*PR_000020002220); ans_temp[ans_id*36+12]+=Pmtrx[33]*(Q_021000001*PR_000020002000+Q_021000101*PR_000020002001+Q_121000001*PR_000020002100+Q_121000101*PR_000020002101+Q_221000001*PR_000020002200+Q_221000101*PR_000020002201+Q_321000001*PR_000020002300+Q_321000101*PR_000020002301); ans_temp[ans_id*36+12]+=Pmtrx[34]*(Q_020001001*PR_000020002000+Q_020001101*PR_000020002001+Q_020101001*PR_000020002010+Q_020101101*PR_000020002011+Q_120001001*PR_000020002100+Q_120001101*PR_000020002101+Q_120101001*PR_000020002110+Q_120101101*PR_000020002111+Q_220001001*PR_000020002200+Q_220001101*PR_000020002201+Q_220101001*PR_000020002210+Q_220101101*PR_000020002211); ans_temp[ans_id*36+12]+=Pmtrx[35]*(Q_020000002*PR_000020002000+Q_020000102*PR_000020002001+Q_020000202*PR_000020002002+Q_120000002*PR_000020002100+Q_120000102*PR_000020002101+Q_120000202*PR_000020002102+Q_220000002*PR_000020002200+Q_220000102*PR_000020002201+Q_220000202*PR_000020002202); ans_temp[ans_id*36+13]+=Pmtrx[30]*(Q_012010000*PR_000020002000+Q_012110000*PR_000020002010+Q_112010000*PR_000020002100+Q_112110000*PR_000020002110+Q_212010000*PR_000020002200+Q_212110000*PR_000020002210+Q_312010000*PR_000020002300+Q_312110000*PR_000020002310); ans_temp[ans_id*36+13]+=Pmtrx[31]*(Q_011011000*PR_000020002000+Q_011111000*PR_000020002010+Q_011211000*PR_000020002020+Q_111011000*PR_000020002100+Q_111111000*PR_000020002110+Q_111211000*PR_000020002120+Q_211011000*PR_000020002200+Q_211111000*PR_000020002210+Q_211211000*PR_000020002220); ans_temp[ans_id*36+13]+=Pmtrx[32]*(Q_010012000*PR_000020002000+Q_010112000*PR_000020002010+Q_010212000*PR_000020002020+Q_010312000*PR_000020002030+Q_110012000*PR_000020002100+Q_110112000*PR_000020002110+Q_110212000*PR_000020002120+Q_110312000*PR_000020002130); ans_temp[ans_id*36+13]+=Pmtrx[33]*(Q_011010001*PR_000020002000+Q_011010101*PR_000020002001+Q_011110001*PR_000020002010+Q_011110101*PR_000020002011+Q_111010001*PR_000020002100+Q_111010101*PR_000020002101+Q_111110001*PR_000020002110+Q_111110101*PR_000020002111+Q_211010001*PR_000020002200+Q_211010101*PR_000020002201+Q_211110001*PR_000020002210+Q_211110101*PR_000020002211); ans_temp[ans_id*36+13]+=Pmtrx[34]*(Q_010011001*PR_000020002000+Q_010011101*PR_000020002001+Q_010111001*PR_000020002010+Q_010111101*PR_000020002011+Q_010211001*PR_000020002020+Q_010211101*PR_000020002021+Q_110011001*PR_000020002100+Q_110011101*PR_000020002101+Q_110111001*PR_000020002110+Q_110111101*PR_000020002111+Q_110211001*PR_000020002120+Q_110211101*PR_000020002121); ans_temp[ans_id*36+13]+=Pmtrx[35]*(Q_010010002*PR_000020002000+Q_010010102*PR_000020002001+Q_010010202*PR_000020002002+Q_010110002*PR_000020002010+Q_010110102*PR_000020002011+Q_010110202*PR_000020002012+Q_110010002*PR_000020002100+Q_110010102*PR_000020002101+Q_110010202*PR_000020002102+Q_110110002*PR_000020002110+Q_110110102*PR_000020002111+Q_110110202*PR_000020002112); ans_temp[ans_id*36+14]+=Pmtrx[30]*(Q_002020000*PR_000020002000+Q_002120000*PR_000020002010+Q_002220000*PR_000020002020+Q_102020000*PR_000020002100+Q_102120000*PR_000020002110+Q_102220000*PR_000020002120+Q_202020000*PR_000020002200+Q_202120000*PR_000020002210+Q_202220000*PR_000020002220); ans_temp[ans_id*36+14]+=Pmtrx[31]*(Q_001021000*PR_000020002000+Q_001121000*PR_000020002010+Q_001221000*PR_000020002020+Q_001321000*PR_000020002030+Q_101021000*PR_000020002100+Q_101121000*PR_000020002110+Q_101221000*PR_000020002120+Q_101321000*PR_000020002130); ans_temp[ans_id*36+14]+=Pmtrx[32]*(Q_000022000*PR_000020002000+Q_000122000*PR_000020002010+Q_000222000*PR_000020002020+Q_000322000*PR_000020002030+Q_000422000*PR_000020002040); ans_temp[ans_id*36+14]+=Pmtrx[33]*(Q_001020001*PR_000020002000+Q_001020101*PR_000020002001+Q_001120001*PR_000020002010+Q_001120101*PR_000020002011+Q_001220001*PR_000020002020+Q_001220101*PR_000020002021+Q_101020001*PR_000020002100+Q_101020101*PR_000020002101+Q_101120001*PR_000020002110+Q_101120101*PR_000020002111+Q_101220001*PR_000020002120+Q_101220101*PR_000020002121); ans_temp[ans_id*36+14]+=Pmtrx[34]*(Q_000021001*PR_000020002000+Q_000021101*PR_000020002001+Q_000121001*PR_000020002010+Q_000121101*PR_000020002011+Q_000221001*PR_000020002020+Q_000221101*PR_000020002021+Q_000321001*PR_000020002030+Q_000321101*PR_000020002031); ans_temp[ans_id*36+14]+=Pmtrx[35]*(Q_000020002*PR_000020002000+Q_000020102*PR_000020002001+Q_000020202*PR_000020002002+Q_000120002*PR_000020002010+Q_000120102*PR_000020002011+Q_000120202*PR_000020002012+Q_000220002*PR_000020002020+Q_000220102*PR_000020002021+Q_000220202*PR_000020002022); ans_temp[ans_id*36+15]+=Pmtrx[30]*(Q_012000010*PR_000020002000+Q_012000110*PR_000020002001+Q_112000010*PR_000020002100+Q_112000110*PR_000020002101+Q_212000010*PR_000020002200+Q_212000110*PR_000020002201+Q_312000010*PR_000020002300+Q_312000110*PR_000020002301); ans_temp[ans_id*36+15]+=Pmtrx[31]*(Q_011001010*PR_000020002000+Q_011001110*PR_000020002001+Q_011101010*PR_000020002010+Q_011101110*PR_000020002011+Q_111001010*PR_000020002100+Q_111001110*PR_000020002101+Q_111101010*PR_000020002110+Q_111101110*PR_000020002111+Q_211001010*PR_000020002200+Q_211001110*PR_000020002201+Q_211101010*PR_000020002210+Q_211101110*PR_000020002211); ans_temp[ans_id*36+15]+=Pmtrx[32]*(Q_010002010*PR_000020002000+Q_010002110*PR_000020002001+Q_010102010*PR_000020002010+Q_010102110*PR_000020002011+Q_010202010*PR_000020002020+Q_010202110*PR_000020002021+Q_110002010*PR_000020002100+Q_110002110*PR_000020002101+Q_110102010*PR_000020002110+Q_110102110*PR_000020002111+Q_110202010*PR_000020002120+Q_110202110*PR_000020002121); ans_temp[ans_id*36+15]+=Pmtrx[33]*(Q_011000011*PR_000020002000+Q_011000111*PR_000020002001+Q_011000211*PR_000020002002+Q_111000011*PR_000020002100+Q_111000111*PR_000020002101+Q_111000211*PR_000020002102+Q_211000011*PR_000020002200+Q_211000111*PR_000020002201+Q_211000211*PR_000020002202); ans_temp[ans_id*36+15]+=Pmtrx[34]*(Q_010001011*PR_000020002000+Q_010001111*PR_000020002001+Q_010001211*PR_000020002002+Q_010101011*PR_000020002010+Q_010101111*PR_000020002011+Q_010101211*PR_000020002012+Q_110001011*PR_000020002100+Q_110001111*PR_000020002101+Q_110001211*PR_000020002102+Q_110101011*PR_000020002110+Q_110101111*PR_000020002111+Q_110101211*PR_000020002112); ans_temp[ans_id*36+15]+=Pmtrx[35]*(Q_010000012*PR_000020002000+Q_010000112*PR_000020002001+Q_010000212*PR_000020002002+Q_010000312*PR_000020002003+Q_110000012*PR_000020002100+Q_110000112*PR_000020002101+Q_110000212*PR_000020002102+Q_110000312*PR_000020002103); ans_temp[ans_id*36+16]+=Pmtrx[30]*(Q_002010010*PR_000020002000+Q_002010110*PR_000020002001+Q_002110010*PR_000020002010+Q_002110110*PR_000020002011+Q_102010010*PR_000020002100+Q_102010110*PR_000020002101+Q_102110010*PR_000020002110+Q_102110110*PR_000020002111+Q_202010010*PR_000020002200+Q_202010110*PR_000020002201+Q_202110010*PR_000020002210+Q_202110110*PR_000020002211); ans_temp[ans_id*36+16]+=Pmtrx[31]*(Q_001011010*PR_000020002000+Q_001011110*PR_000020002001+Q_001111010*PR_000020002010+Q_001111110*PR_000020002011+Q_001211010*PR_000020002020+Q_001211110*PR_000020002021+Q_101011010*PR_000020002100+Q_101011110*PR_000020002101+Q_101111010*PR_000020002110+Q_101111110*PR_000020002111+Q_101211010*PR_000020002120+Q_101211110*PR_000020002121); ans_temp[ans_id*36+16]+=Pmtrx[32]*(Q_000012010*PR_000020002000+Q_000012110*PR_000020002001+Q_000112010*PR_000020002010+Q_000112110*PR_000020002011+Q_000212010*PR_000020002020+Q_000212110*PR_000020002021+Q_000312010*PR_000020002030+Q_000312110*PR_000020002031); ans_temp[ans_id*36+16]+=Pmtrx[33]*(Q_001010011*PR_000020002000+Q_001010111*PR_000020002001+Q_001010211*PR_000020002002+Q_001110011*PR_000020002010+Q_001110111*PR_000020002011+Q_001110211*PR_000020002012+Q_101010011*PR_000020002100+Q_101010111*PR_000020002101+Q_101010211*PR_000020002102+Q_101110011*PR_000020002110+Q_101110111*PR_000020002111+Q_101110211*PR_000020002112); ans_temp[ans_id*36+16]+=Pmtrx[34]*(Q_000011011*PR_000020002000+Q_000011111*PR_000020002001+Q_000011211*PR_000020002002+Q_000111011*PR_000020002010+Q_000111111*PR_000020002011+Q_000111211*PR_000020002012+Q_000211011*PR_000020002020+Q_000211111*PR_000020002021+Q_000211211*PR_000020002022); ans_temp[ans_id*36+16]+=Pmtrx[35]*(Q_000010012*PR_000020002000+Q_000010112*PR_000020002001+Q_000010212*PR_000020002002+Q_000010312*PR_000020002003+Q_000110012*PR_000020002010+Q_000110112*PR_000020002011+Q_000110212*PR_000020002012+Q_000110312*PR_000020002013); ans_temp[ans_id*36+17]+=Pmtrx[30]*(Q_002000020*PR_000020002000+Q_002000120*PR_000020002001+Q_002000220*PR_000020002002+Q_102000020*PR_000020002100+Q_102000120*PR_000020002101+Q_102000220*PR_000020002102+Q_202000020*PR_000020002200+Q_202000120*PR_000020002201+Q_202000220*PR_000020002202); ans_temp[ans_id*36+17]+=Pmtrx[31]*(Q_001001020*PR_000020002000+Q_001001120*PR_000020002001+Q_001001220*PR_000020002002+Q_001101020*PR_000020002010+Q_001101120*PR_000020002011+Q_001101220*PR_000020002012+Q_101001020*PR_000020002100+Q_101001120*PR_000020002101+Q_101001220*PR_000020002102+Q_101101020*PR_000020002110+Q_101101120*PR_000020002111+Q_101101220*PR_000020002112); ans_temp[ans_id*36+17]+=Pmtrx[32]*(Q_000002020*PR_000020002000+Q_000002120*PR_000020002001+Q_000002220*PR_000020002002+Q_000102020*PR_000020002010+Q_000102120*PR_000020002011+Q_000102220*PR_000020002012+Q_000202020*PR_000020002020+Q_000202120*PR_000020002021+Q_000202220*PR_000020002022); ans_temp[ans_id*36+17]+=Pmtrx[33]*(Q_001000021*PR_000020002000+Q_001000121*PR_000020002001+Q_001000221*PR_000020002002+Q_001000321*PR_000020002003+Q_101000021*PR_000020002100+Q_101000121*PR_000020002101+Q_101000221*PR_000020002102+Q_101000321*PR_000020002103); ans_temp[ans_id*36+17]+=Pmtrx[34]*(Q_000001021*PR_000020002000+Q_000001121*PR_000020002001+Q_000001221*PR_000020002002+Q_000001321*PR_000020002003+Q_000101021*PR_000020002010+Q_000101121*PR_000020002011+Q_000101221*PR_000020002012+Q_000101321*PR_000020002013); ans_temp[ans_id*36+17]+=Pmtrx[35]*(Q_000000022*PR_000020002000+Q_000000122*PR_000020002001+Q_000000222*PR_000020002002+Q_000000322*PR_000020002003+Q_000000422*PR_000020002004); ans_temp[ans_id*36+18]+=Pmtrx[0]*(Q_022000000*PR_012000010000+Q_122000000*PR_012000010100+Q_222000000*PR_012000010200+Q_322000000*PR_012000010300+Q_422000000*PR_012000010400); ans_temp[ans_id*36+18]+=Pmtrx[1]*(Q_021001000*PR_012000010000+Q_021101000*PR_012000010010+Q_121001000*PR_012000010100+Q_121101000*PR_012000010110+Q_221001000*PR_012000010200+Q_221101000*PR_012000010210+Q_321001000*PR_012000010300+Q_321101000*PR_012000010310); ans_temp[ans_id*36+18]+=Pmtrx[2]*(Q_020002000*PR_012000010000+Q_020102000*PR_012000010010+Q_020202000*PR_012000010020+Q_120002000*PR_012000010100+Q_120102000*PR_012000010110+Q_120202000*PR_012000010120+Q_220002000*PR_012000010200+Q_220102000*PR_012000010210+Q_220202000*PR_012000010220); ans_temp[ans_id*36+18]+=Pmtrx[3]*(Q_021000001*PR_012000010000+Q_021000101*PR_012000010001+Q_121000001*PR_012000010100+Q_121000101*PR_012000010101+Q_221000001*PR_012000010200+Q_221000101*PR_012000010201+Q_321000001*PR_012000010300+Q_321000101*PR_012000010301); ans_temp[ans_id*36+18]+=Pmtrx[4]*(Q_020001001*PR_012000010000+Q_020001101*PR_012000010001+Q_020101001*PR_012000010010+Q_020101101*PR_012000010011+Q_120001001*PR_012000010100+Q_120001101*PR_012000010101+Q_120101001*PR_012000010110+Q_120101101*PR_012000010111+Q_220001001*PR_012000010200+Q_220001101*PR_012000010201+Q_220101001*PR_012000010210+Q_220101101*PR_012000010211); ans_temp[ans_id*36+18]+=Pmtrx[5]*(Q_020000002*PR_012000010000+Q_020000102*PR_012000010001+Q_020000202*PR_012000010002+Q_120000002*PR_012000010100+Q_120000102*PR_012000010101+Q_120000202*PR_012000010102+Q_220000002*PR_012000010200+Q_220000102*PR_012000010201+Q_220000202*PR_012000010202); ans_temp[ans_id*36+19]+=Pmtrx[0]*(Q_012010000*PR_012000010000+Q_012110000*PR_012000010010+Q_112010000*PR_012000010100+Q_112110000*PR_012000010110+Q_212010000*PR_012000010200+Q_212110000*PR_012000010210+Q_312010000*PR_012000010300+Q_312110000*PR_012000010310); ans_temp[ans_id*36+19]+=Pmtrx[1]*(Q_011011000*PR_012000010000+Q_011111000*PR_012000010010+Q_011211000*PR_012000010020+Q_111011000*PR_012000010100+Q_111111000*PR_012000010110+Q_111211000*PR_012000010120+Q_211011000*PR_012000010200+Q_211111000*PR_012000010210+Q_211211000*PR_012000010220); ans_temp[ans_id*36+19]+=Pmtrx[2]*(Q_010012000*PR_012000010000+Q_010112000*PR_012000010010+Q_010212000*PR_012000010020+Q_010312000*PR_012000010030+Q_110012000*PR_012000010100+Q_110112000*PR_012000010110+Q_110212000*PR_012000010120+Q_110312000*PR_012000010130); ans_temp[ans_id*36+19]+=Pmtrx[3]*(Q_011010001*PR_012000010000+Q_011010101*PR_012000010001+Q_011110001*PR_012000010010+Q_011110101*PR_012000010011+Q_111010001*PR_012000010100+Q_111010101*PR_012000010101+Q_111110001*PR_012000010110+Q_111110101*PR_012000010111+Q_211010001*PR_012000010200+Q_211010101*PR_012000010201+Q_211110001*PR_012000010210+Q_211110101*PR_012000010211); ans_temp[ans_id*36+19]+=Pmtrx[4]*(Q_010011001*PR_012000010000+Q_010011101*PR_012000010001+Q_010111001*PR_012000010010+Q_010111101*PR_012000010011+Q_010211001*PR_012000010020+Q_010211101*PR_012000010021+Q_110011001*PR_012000010100+Q_110011101*PR_012000010101+Q_110111001*PR_012000010110+Q_110111101*PR_012000010111+Q_110211001*PR_012000010120+Q_110211101*PR_012000010121); ans_temp[ans_id*36+19]+=Pmtrx[5]*(Q_010010002*PR_012000010000+Q_010010102*PR_012000010001+Q_010010202*PR_012000010002+Q_010110002*PR_012000010010+Q_010110102*PR_012000010011+Q_010110202*PR_012000010012+Q_110010002*PR_012000010100+Q_110010102*PR_012000010101+Q_110010202*PR_012000010102+Q_110110002*PR_012000010110+Q_110110102*PR_012000010111+Q_110110202*PR_012000010112); ans_temp[ans_id*36+20]+=Pmtrx[0]*(Q_002020000*PR_012000010000+Q_002120000*PR_012000010010+Q_002220000*PR_012000010020+Q_102020000*PR_012000010100+Q_102120000*PR_012000010110+Q_102220000*PR_012000010120+Q_202020000*PR_012000010200+Q_202120000*PR_012000010210+Q_202220000*PR_012000010220); ans_temp[ans_id*36+20]+=Pmtrx[1]*(Q_001021000*PR_012000010000+Q_001121000*PR_012000010010+Q_001221000*PR_012000010020+Q_001321000*PR_012000010030+Q_101021000*PR_012000010100+Q_101121000*PR_012000010110+Q_101221000*PR_012000010120+Q_101321000*PR_012000010130); ans_temp[ans_id*36+20]+=Pmtrx[2]*(Q_000022000*PR_012000010000+Q_000122000*PR_012000010010+Q_000222000*PR_012000010020+Q_000322000*PR_012000010030+Q_000422000*PR_012000010040); ans_temp[ans_id*36+20]+=Pmtrx[3]*(Q_001020001*PR_012000010000+Q_001020101*PR_012000010001+Q_001120001*PR_012000010010+Q_001120101*PR_012000010011+Q_001220001*PR_012000010020+Q_001220101*PR_012000010021+Q_101020001*PR_012000010100+Q_101020101*PR_012000010101+Q_101120001*PR_012000010110+Q_101120101*PR_012000010111+Q_101220001*PR_012000010120+Q_101220101*PR_012000010121); ans_temp[ans_id*36+20]+=Pmtrx[4]*(Q_000021001*PR_012000010000+Q_000021101*PR_012000010001+Q_000121001*PR_012000010010+Q_000121101*PR_012000010011+Q_000221001*PR_012000010020+Q_000221101*PR_012000010021+Q_000321001*PR_012000010030+Q_000321101*PR_012000010031); ans_temp[ans_id*36+20]+=Pmtrx[5]*(Q_000020002*PR_012000010000+Q_000020102*PR_012000010001+Q_000020202*PR_012000010002+Q_000120002*PR_012000010010+Q_000120102*PR_012000010011+Q_000120202*PR_012000010012+Q_000220002*PR_012000010020+Q_000220102*PR_012000010021+Q_000220202*PR_012000010022); ans_temp[ans_id*36+21]+=Pmtrx[0]*(Q_012000010*PR_012000010000+Q_012000110*PR_012000010001+Q_112000010*PR_012000010100+Q_112000110*PR_012000010101+Q_212000010*PR_012000010200+Q_212000110*PR_012000010201+Q_312000010*PR_012000010300+Q_312000110*PR_012000010301); ans_temp[ans_id*36+21]+=Pmtrx[1]*(Q_011001010*PR_012000010000+Q_011001110*PR_012000010001+Q_011101010*PR_012000010010+Q_011101110*PR_012000010011+Q_111001010*PR_012000010100+Q_111001110*PR_012000010101+Q_111101010*PR_012000010110+Q_111101110*PR_012000010111+Q_211001010*PR_012000010200+Q_211001110*PR_012000010201+Q_211101010*PR_012000010210+Q_211101110*PR_012000010211); ans_temp[ans_id*36+21]+=Pmtrx[2]*(Q_010002010*PR_012000010000+Q_010002110*PR_012000010001+Q_010102010*PR_012000010010+Q_010102110*PR_012000010011+Q_010202010*PR_012000010020+Q_010202110*PR_012000010021+Q_110002010*PR_012000010100+Q_110002110*PR_012000010101+Q_110102010*PR_012000010110+Q_110102110*PR_012000010111+Q_110202010*PR_012000010120+Q_110202110*PR_012000010121); ans_temp[ans_id*36+21]+=Pmtrx[3]*(Q_011000011*PR_012000010000+Q_011000111*PR_012000010001+Q_011000211*PR_012000010002+Q_111000011*PR_012000010100+Q_111000111*PR_012000010101+Q_111000211*PR_012000010102+Q_211000011*PR_012000010200+Q_211000111*PR_012000010201+Q_211000211*PR_012000010202); ans_temp[ans_id*36+21]+=Pmtrx[4]*(Q_010001011*PR_012000010000+Q_010001111*PR_012000010001+Q_010001211*PR_012000010002+Q_010101011*PR_012000010010+Q_010101111*PR_012000010011+Q_010101211*PR_012000010012+Q_110001011*PR_012000010100+Q_110001111*PR_012000010101+Q_110001211*PR_012000010102+Q_110101011*PR_012000010110+Q_110101111*PR_012000010111+Q_110101211*PR_012000010112); ans_temp[ans_id*36+21]+=Pmtrx[5]*(Q_010000012*PR_012000010000+Q_010000112*PR_012000010001+Q_010000212*PR_012000010002+Q_010000312*PR_012000010003+Q_110000012*PR_012000010100+Q_110000112*PR_012000010101+Q_110000212*PR_012000010102+Q_110000312*PR_012000010103); ans_temp[ans_id*36+22]+=Pmtrx[0]*(Q_002010010*PR_012000010000+Q_002010110*PR_012000010001+Q_002110010*PR_012000010010+Q_002110110*PR_012000010011+Q_102010010*PR_012000010100+Q_102010110*PR_012000010101+Q_102110010*PR_012000010110+Q_102110110*PR_012000010111+Q_202010010*PR_012000010200+Q_202010110*PR_012000010201+Q_202110010*PR_012000010210+Q_202110110*PR_012000010211); ans_temp[ans_id*36+22]+=Pmtrx[1]*(Q_001011010*PR_012000010000+Q_001011110*PR_012000010001+Q_001111010*PR_012000010010+Q_001111110*PR_012000010011+Q_001211010*PR_012000010020+Q_001211110*PR_012000010021+Q_101011010*PR_012000010100+Q_101011110*PR_012000010101+Q_101111010*PR_012000010110+Q_101111110*PR_012000010111+Q_101211010*PR_012000010120+Q_101211110*PR_012000010121); ans_temp[ans_id*36+22]+=Pmtrx[2]*(Q_000012010*PR_012000010000+Q_000012110*PR_012000010001+Q_000112010*PR_012000010010+Q_000112110*PR_012000010011+Q_000212010*PR_012000010020+Q_000212110*PR_012000010021+Q_000312010*PR_012000010030+Q_000312110*PR_012000010031); ans_temp[ans_id*36+22]+=Pmtrx[3]*(Q_001010011*PR_012000010000+Q_001010111*PR_012000010001+Q_001010211*PR_012000010002+Q_001110011*PR_012000010010+Q_001110111*PR_012000010011+Q_001110211*PR_012000010012+Q_101010011*PR_012000010100+Q_101010111*PR_012000010101+Q_101010211*PR_012000010102+Q_101110011*PR_012000010110+Q_101110111*PR_012000010111+Q_101110211*PR_012000010112); ans_temp[ans_id*36+22]+=Pmtrx[4]*(Q_000011011*PR_012000010000+Q_000011111*PR_012000010001+Q_000011211*PR_012000010002+Q_000111011*PR_012000010010+Q_000111111*PR_012000010011+Q_000111211*PR_012000010012+Q_000211011*PR_012000010020+Q_000211111*PR_012000010021+Q_000211211*PR_012000010022); ans_temp[ans_id*36+22]+=Pmtrx[5]*(Q_000010012*PR_012000010000+Q_000010112*PR_012000010001+Q_000010212*PR_012000010002+Q_000010312*PR_012000010003+Q_000110012*PR_012000010010+Q_000110112*PR_012000010011+Q_000110212*PR_012000010012+Q_000110312*PR_012000010013); ans_temp[ans_id*36+23]+=Pmtrx[0]*(Q_002000020*PR_012000010000+Q_002000120*PR_012000010001+Q_002000220*PR_012000010002+Q_102000020*PR_012000010100+Q_102000120*PR_012000010101+Q_102000220*PR_012000010102+Q_202000020*PR_012000010200+Q_202000120*PR_012000010201+Q_202000220*PR_012000010202); ans_temp[ans_id*36+23]+=Pmtrx[1]*(Q_001001020*PR_012000010000+Q_001001120*PR_012000010001+Q_001001220*PR_012000010002+Q_001101020*PR_012000010010+Q_001101120*PR_012000010011+Q_001101220*PR_012000010012+Q_101001020*PR_012000010100+Q_101001120*PR_012000010101+Q_101001220*PR_012000010102+Q_101101020*PR_012000010110+Q_101101120*PR_012000010111+Q_101101220*PR_012000010112); ans_temp[ans_id*36+23]+=Pmtrx[2]*(Q_000002020*PR_012000010000+Q_000002120*PR_012000010001+Q_000002220*PR_012000010002+Q_000102020*PR_012000010010+Q_000102120*PR_012000010011+Q_000102220*PR_012000010012+Q_000202020*PR_012000010020+Q_000202120*PR_012000010021+Q_000202220*PR_012000010022); ans_temp[ans_id*36+23]+=Pmtrx[3]*(Q_001000021*PR_012000010000+Q_001000121*PR_012000010001+Q_001000221*PR_012000010002+Q_001000321*PR_012000010003+Q_101000021*PR_012000010100+Q_101000121*PR_012000010101+Q_101000221*PR_012000010102+Q_101000321*PR_012000010103); ans_temp[ans_id*36+23]+=Pmtrx[4]*(Q_000001021*PR_012000010000+Q_000001121*PR_012000010001+Q_000001221*PR_012000010002+Q_000001321*PR_012000010003+Q_000101021*PR_012000010010+Q_000101121*PR_012000010011+Q_000101221*PR_012000010012+Q_000101321*PR_012000010013); ans_temp[ans_id*36+23]+=Pmtrx[5]*(Q_000000022*PR_012000010000+Q_000000122*PR_012000010001+Q_000000222*PR_012000010002+Q_000000322*PR_012000010003+Q_000000422*PR_012000010004); ans_temp[ans_id*36+18]+=Pmtrx[6]*(Q_022000000*PR_011001010000+Q_122000000*PR_011001010100+Q_222000000*PR_011001010200+Q_322000000*PR_011001010300+Q_422000000*PR_011001010400); ans_temp[ans_id*36+18]+=Pmtrx[7]*(Q_021001000*PR_011001010000+Q_021101000*PR_011001010010+Q_121001000*PR_011001010100+Q_121101000*PR_011001010110+Q_221001000*PR_011001010200+Q_221101000*PR_011001010210+Q_321001000*PR_011001010300+Q_321101000*PR_011001010310); ans_temp[ans_id*36+18]+=Pmtrx[8]*(Q_020002000*PR_011001010000+Q_020102000*PR_011001010010+Q_020202000*PR_011001010020+Q_120002000*PR_011001010100+Q_120102000*PR_011001010110+Q_120202000*PR_011001010120+Q_220002000*PR_011001010200+Q_220102000*PR_011001010210+Q_220202000*PR_011001010220); ans_temp[ans_id*36+18]+=Pmtrx[9]*(Q_021000001*PR_011001010000+Q_021000101*PR_011001010001+Q_121000001*PR_011001010100+Q_121000101*PR_011001010101+Q_221000001*PR_011001010200+Q_221000101*PR_011001010201+Q_321000001*PR_011001010300+Q_321000101*PR_011001010301); ans_temp[ans_id*36+18]+=Pmtrx[10]*(Q_020001001*PR_011001010000+Q_020001101*PR_011001010001+Q_020101001*PR_011001010010+Q_020101101*PR_011001010011+Q_120001001*PR_011001010100+Q_120001101*PR_011001010101+Q_120101001*PR_011001010110+Q_120101101*PR_011001010111+Q_220001001*PR_011001010200+Q_220001101*PR_011001010201+Q_220101001*PR_011001010210+Q_220101101*PR_011001010211); ans_temp[ans_id*36+18]+=Pmtrx[11]*(Q_020000002*PR_011001010000+Q_020000102*PR_011001010001+Q_020000202*PR_011001010002+Q_120000002*PR_011001010100+Q_120000102*PR_011001010101+Q_120000202*PR_011001010102+Q_220000002*PR_011001010200+Q_220000102*PR_011001010201+Q_220000202*PR_011001010202); ans_temp[ans_id*36+19]+=Pmtrx[6]*(Q_012010000*PR_011001010000+Q_012110000*PR_011001010010+Q_112010000*PR_011001010100+Q_112110000*PR_011001010110+Q_212010000*PR_011001010200+Q_212110000*PR_011001010210+Q_312010000*PR_011001010300+Q_312110000*PR_011001010310); ans_temp[ans_id*36+19]+=Pmtrx[7]*(Q_011011000*PR_011001010000+Q_011111000*PR_011001010010+Q_011211000*PR_011001010020+Q_111011000*PR_011001010100+Q_111111000*PR_011001010110+Q_111211000*PR_011001010120+Q_211011000*PR_011001010200+Q_211111000*PR_011001010210+Q_211211000*PR_011001010220); ans_temp[ans_id*36+19]+=Pmtrx[8]*(Q_010012000*PR_011001010000+Q_010112000*PR_011001010010+Q_010212000*PR_011001010020+Q_010312000*PR_011001010030+Q_110012000*PR_011001010100+Q_110112000*PR_011001010110+Q_110212000*PR_011001010120+Q_110312000*PR_011001010130); ans_temp[ans_id*36+19]+=Pmtrx[9]*(Q_011010001*PR_011001010000+Q_011010101*PR_011001010001+Q_011110001*PR_011001010010+Q_011110101*PR_011001010011+Q_111010001*PR_011001010100+Q_111010101*PR_011001010101+Q_111110001*PR_011001010110+Q_111110101*PR_011001010111+Q_211010001*PR_011001010200+Q_211010101*PR_011001010201+Q_211110001*PR_011001010210+Q_211110101*PR_011001010211); ans_temp[ans_id*36+19]+=Pmtrx[10]*(Q_010011001*PR_011001010000+Q_010011101*PR_011001010001+Q_010111001*PR_011001010010+Q_010111101*PR_011001010011+Q_010211001*PR_011001010020+Q_010211101*PR_011001010021+Q_110011001*PR_011001010100+Q_110011101*PR_011001010101+Q_110111001*PR_011001010110+Q_110111101*PR_011001010111+Q_110211001*PR_011001010120+Q_110211101*PR_011001010121); ans_temp[ans_id*36+19]+=Pmtrx[11]*(Q_010010002*PR_011001010000+Q_010010102*PR_011001010001+Q_010010202*PR_011001010002+Q_010110002*PR_011001010010+Q_010110102*PR_011001010011+Q_010110202*PR_011001010012+Q_110010002*PR_011001010100+Q_110010102*PR_011001010101+Q_110010202*PR_011001010102+Q_110110002*PR_011001010110+Q_110110102*PR_011001010111+Q_110110202*PR_011001010112); ans_temp[ans_id*36+20]+=Pmtrx[6]*(Q_002020000*PR_011001010000+Q_002120000*PR_011001010010+Q_002220000*PR_011001010020+Q_102020000*PR_011001010100+Q_102120000*PR_011001010110+Q_102220000*PR_011001010120+Q_202020000*PR_011001010200+Q_202120000*PR_011001010210+Q_202220000*PR_011001010220); ans_temp[ans_id*36+20]+=Pmtrx[7]*(Q_001021000*PR_011001010000+Q_001121000*PR_011001010010+Q_001221000*PR_011001010020+Q_001321000*PR_011001010030+Q_101021000*PR_011001010100+Q_101121000*PR_011001010110+Q_101221000*PR_011001010120+Q_101321000*PR_011001010130); ans_temp[ans_id*36+20]+=Pmtrx[8]*(Q_000022000*PR_011001010000+Q_000122000*PR_011001010010+Q_000222000*PR_011001010020+Q_000322000*PR_011001010030+Q_000422000*PR_011001010040); ans_temp[ans_id*36+20]+=Pmtrx[9]*(Q_001020001*PR_011001010000+Q_001020101*PR_011001010001+Q_001120001*PR_011001010010+Q_001120101*PR_011001010011+Q_001220001*PR_011001010020+Q_001220101*PR_011001010021+Q_101020001*PR_011001010100+Q_101020101*PR_011001010101+Q_101120001*PR_011001010110+Q_101120101*PR_011001010111+Q_101220001*PR_011001010120+Q_101220101*PR_011001010121); ans_temp[ans_id*36+20]+=Pmtrx[10]*(Q_000021001*PR_011001010000+Q_000021101*PR_011001010001+Q_000121001*PR_011001010010+Q_000121101*PR_011001010011+Q_000221001*PR_011001010020+Q_000221101*PR_011001010021+Q_000321001*PR_011001010030+Q_000321101*PR_011001010031); ans_temp[ans_id*36+20]+=Pmtrx[11]*(Q_000020002*PR_011001010000+Q_000020102*PR_011001010001+Q_000020202*PR_011001010002+Q_000120002*PR_011001010010+Q_000120102*PR_011001010011+Q_000120202*PR_011001010012+Q_000220002*PR_011001010020+Q_000220102*PR_011001010021+Q_000220202*PR_011001010022); ans_temp[ans_id*36+21]+=Pmtrx[6]*(Q_012000010*PR_011001010000+Q_012000110*PR_011001010001+Q_112000010*PR_011001010100+Q_112000110*PR_011001010101+Q_212000010*PR_011001010200+Q_212000110*PR_011001010201+Q_312000010*PR_011001010300+Q_312000110*PR_011001010301); ans_temp[ans_id*36+21]+=Pmtrx[7]*(Q_011001010*PR_011001010000+Q_011001110*PR_011001010001+Q_011101010*PR_011001010010+Q_011101110*PR_011001010011+Q_111001010*PR_011001010100+Q_111001110*PR_011001010101+Q_111101010*PR_011001010110+Q_111101110*PR_011001010111+Q_211001010*PR_011001010200+Q_211001110*PR_011001010201+Q_211101010*PR_011001010210+Q_211101110*PR_011001010211); ans_temp[ans_id*36+21]+=Pmtrx[8]*(Q_010002010*PR_011001010000+Q_010002110*PR_011001010001+Q_010102010*PR_011001010010+Q_010102110*PR_011001010011+Q_010202010*PR_011001010020+Q_010202110*PR_011001010021+Q_110002010*PR_011001010100+Q_110002110*PR_011001010101+Q_110102010*PR_011001010110+Q_110102110*PR_011001010111+Q_110202010*PR_011001010120+Q_110202110*PR_011001010121); ans_temp[ans_id*36+21]+=Pmtrx[9]*(Q_011000011*PR_011001010000+Q_011000111*PR_011001010001+Q_011000211*PR_011001010002+Q_111000011*PR_011001010100+Q_111000111*PR_011001010101+Q_111000211*PR_011001010102+Q_211000011*PR_011001010200+Q_211000111*PR_011001010201+Q_211000211*PR_011001010202); ans_temp[ans_id*36+21]+=Pmtrx[10]*(Q_010001011*PR_011001010000+Q_010001111*PR_011001010001+Q_010001211*PR_011001010002+Q_010101011*PR_011001010010+Q_010101111*PR_011001010011+Q_010101211*PR_011001010012+Q_110001011*PR_011001010100+Q_110001111*PR_011001010101+Q_110001211*PR_011001010102+Q_110101011*PR_011001010110+Q_110101111*PR_011001010111+Q_110101211*PR_011001010112); ans_temp[ans_id*36+21]+=Pmtrx[11]*(Q_010000012*PR_011001010000+Q_010000112*PR_011001010001+Q_010000212*PR_011001010002+Q_010000312*PR_011001010003+Q_110000012*PR_011001010100+Q_110000112*PR_011001010101+Q_110000212*PR_011001010102+Q_110000312*PR_011001010103); ans_temp[ans_id*36+22]+=Pmtrx[6]*(Q_002010010*PR_011001010000+Q_002010110*PR_011001010001+Q_002110010*PR_011001010010+Q_002110110*PR_011001010011+Q_102010010*PR_011001010100+Q_102010110*PR_011001010101+Q_102110010*PR_011001010110+Q_102110110*PR_011001010111+Q_202010010*PR_011001010200+Q_202010110*PR_011001010201+Q_202110010*PR_011001010210+Q_202110110*PR_011001010211); ans_temp[ans_id*36+22]+=Pmtrx[7]*(Q_001011010*PR_011001010000+Q_001011110*PR_011001010001+Q_001111010*PR_011001010010+Q_001111110*PR_011001010011+Q_001211010*PR_011001010020+Q_001211110*PR_011001010021+Q_101011010*PR_011001010100+Q_101011110*PR_011001010101+Q_101111010*PR_011001010110+Q_101111110*PR_011001010111+Q_101211010*PR_011001010120+Q_101211110*PR_011001010121); ans_temp[ans_id*36+22]+=Pmtrx[8]*(Q_000012010*PR_011001010000+Q_000012110*PR_011001010001+Q_000112010*PR_011001010010+Q_000112110*PR_011001010011+Q_000212010*PR_011001010020+Q_000212110*PR_011001010021+Q_000312010*PR_011001010030+Q_000312110*PR_011001010031); ans_temp[ans_id*36+22]+=Pmtrx[9]*(Q_001010011*PR_011001010000+Q_001010111*PR_011001010001+Q_001010211*PR_011001010002+Q_001110011*PR_011001010010+Q_001110111*PR_011001010011+Q_001110211*PR_011001010012+Q_101010011*PR_011001010100+Q_101010111*PR_011001010101+Q_101010211*PR_011001010102+Q_101110011*PR_011001010110+Q_101110111*PR_011001010111+Q_101110211*PR_011001010112); ans_temp[ans_id*36+22]+=Pmtrx[10]*(Q_000011011*PR_011001010000+Q_000011111*PR_011001010001+Q_000011211*PR_011001010002+Q_000111011*PR_011001010010+Q_000111111*PR_011001010011+Q_000111211*PR_011001010012+Q_000211011*PR_011001010020+Q_000211111*PR_011001010021+Q_000211211*PR_011001010022); ans_temp[ans_id*36+22]+=Pmtrx[11]*(Q_000010012*PR_011001010000+Q_000010112*PR_011001010001+Q_000010212*PR_011001010002+Q_000010312*PR_011001010003+Q_000110012*PR_011001010010+Q_000110112*PR_011001010011+Q_000110212*PR_011001010012+Q_000110312*PR_011001010013); ans_temp[ans_id*36+23]+=Pmtrx[6]*(Q_002000020*PR_011001010000+Q_002000120*PR_011001010001+Q_002000220*PR_011001010002+Q_102000020*PR_011001010100+Q_102000120*PR_011001010101+Q_102000220*PR_011001010102+Q_202000020*PR_011001010200+Q_202000120*PR_011001010201+Q_202000220*PR_011001010202); ans_temp[ans_id*36+23]+=Pmtrx[7]*(Q_001001020*PR_011001010000+Q_001001120*PR_011001010001+Q_001001220*PR_011001010002+Q_001101020*PR_011001010010+Q_001101120*PR_011001010011+Q_001101220*PR_011001010012+Q_101001020*PR_011001010100+Q_101001120*PR_011001010101+Q_101001220*PR_011001010102+Q_101101020*PR_011001010110+Q_101101120*PR_011001010111+Q_101101220*PR_011001010112); ans_temp[ans_id*36+23]+=Pmtrx[8]*(Q_000002020*PR_011001010000+Q_000002120*PR_011001010001+Q_000002220*PR_011001010002+Q_000102020*PR_011001010010+Q_000102120*PR_011001010011+Q_000102220*PR_011001010012+Q_000202020*PR_011001010020+Q_000202120*PR_011001010021+Q_000202220*PR_011001010022); ans_temp[ans_id*36+23]+=Pmtrx[9]*(Q_001000021*PR_011001010000+Q_001000121*PR_011001010001+Q_001000221*PR_011001010002+Q_001000321*PR_011001010003+Q_101000021*PR_011001010100+Q_101000121*PR_011001010101+Q_101000221*PR_011001010102+Q_101000321*PR_011001010103); ans_temp[ans_id*36+23]+=Pmtrx[10]*(Q_000001021*PR_011001010000+Q_000001121*PR_011001010001+Q_000001221*PR_011001010002+Q_000001321*PR_011001010003+Q_000101021*PR_011001010010+Q_000101121*PR_011001010011+Q_000101221*PR_011001010012+Q_000101321*PR_011001010013); ans_temp[ans_id*36+23]+=Pmtrx[11]*(Q_000000022*PR_011001010000+Q_000000122*PR_011001010001+Q_000000222*PR_011001010002+Q_000000322*PR_011001010003+Q_000000422*PR_011001010004); ans_temp[ans_id*36+18]+=Pmtrx[12]*(Q_022000000*PR_010002010000+Q_122000000*PR_010002010100+Q_222000000*PR_010002010200+Q_322000000*PR_010002010300+Q_422000000*PR_010002010400); ans_temp[ans_id*36+18]+=Pmtrx[13]*(Q_021001000*PR_010002010000+Q_021101000*PR_010002010010+Q_121001000*PR_010002010100+Q_121101000*PR_010002010110+Q_221001000*PR_010002010200+Q_221101000*PR_010002010210+Q_321001000*PR_010002010300+Q_321101000*PR_010002010310); ans_temp[ans_id*36+18]+=Pmtrx[14]*(Q_020002000*PR_010002010000+Q_020102000*PR_010002010010+Q_020202000*PR_010002010020+Q_120002000*PR_010002010100+Q_120102000*PR_010002010110+Q_120202000*PR_010002010120+Q_220002000*PR_010002010200+Q_220102000*PR_010002010210+Q_220202000*PR_010002010220); ans_temp[ans_id*36+18]+=Pmtrx[15]*(Q_021000001*PR_010002010000+Q_021000101*PR_010002010001+Q_121000001*PR_010002010100+Q_121000101*PR_010002010101+Q_221000001*PR_010002010200+Q_221000101*PR_010002010201+Q_321000001*PR_010002010300+Q_321000101*PR_010002010301); ans_temp[ans_id*36+18]+=Pmtrx[16]*(Q_020001001*PR_010002010000+Q_020001101*PR_010002010001+Q_020101001*PR_010002010010+Q_020101101*PR_010002010011+Q_120001001*PR_010002010100+Q_120001101*PR_010002010101+Q_120101001*PR_010002010110+Q_120101101*PR_010002010111+Q_220001001*PR_010002010200+Q_220001101*PR_010002010201+Q_220101001*PR_010002010210+Q_220101101*PR_010002010211); ans_temp[ans_id*36+18]+=Pmtrx[17]*(Q_020000002*PR_010002010000+Q_020000102*PR_010002010001+Q_020000202*PR_010002010002+Q_120000002*PR_010002010100+Q_120000102*PR_010002010101+Q_120000202*PR_010002010102+Q_220000002*PR_010002010200+Q_220000102*PR_010002010201+Q_220000202*PR_010002010202); ans_temp[ans_id*36+19]+=Pmtrx[12]*(Q_012010000*PR_010002010000+Q_012110000*PR_010002010010+Q_112010000*PR_010002010100+Q_112110000*PR_010002010110+Q_212010000*PR_010002010200+Q_212110000*PR_010002010210+Q_312010000*PR_010002010300+Q_312110000*PR_010002010310); ans_temp[ans_id*36+19]+=Pmtrx[13]*(Q_011011000*PR_010002010000+Q_011111000*PR_010002010010+Q_011211000*PR_010002010020+Q_111011000*PR_010002010100+Q_111111000*PR_010002010110+Q_111211000*PR_010002010120+Q_211011000*PR_010002010200+Q_211111000*PR_010002010210+Q_211211000*PR_010002010220); ans_temp[ans_id*36+19]+=Pmtrx[14]*(Q_010012000*PR_010002010000+Q_010112000*PR_010002010010+Q_010212000*PR_010002010020+Q_010312000*PR_010002010030+Q_110012000*PR_010002010100+Q_110112000*PR_010002010110+Q_110212000*PR_010002010120+Q_110312000*PR_010002010130); ans_temp[ans_id*36+19]+=Pmtrx[15]*(Q_011010001*PR_010002010000+Q_011010101*PR_010002010001+Q_011110001*PR_010002010010+Q_011110101*PR_010002010011+Q_111010001*PR_010002010100+Q_111010101*PR_010002010101+Q_111110001*PR_010002010110+Q_111110101*PR_010002010111+Q_211010001*PR_010002010200+Q_211010101*PR_010002010201+Q_211110001*PR_010002010210+Q_211110101*PR_010002010211); ans_temp[ans_id*36+19]+=Pmtrx[16]*(Q_010011001*PR_010002010000+Q_010011101*PR_010002010001+Q_010111001*PR_010002010010+Q_010111101*PR_010002010011+Q_010211001*PR_010002010020+Q_010211101*PR_010002010021+Q_110011001*PR_010002010100+Q_110011101*PR_010002010101+Q_110111001*PR_010002010110+Q_110111101*PR_010002010111+Q_110211001*PR_010002010120+Q_110211101*PR_010002010121); ans_temp[ans_id*36+19]+=Pmtrx[17]*(Q_010010002*PR_010002010000+Q_010010102*PR_010002010001+Q_010010202*PR_010002010002+Q_010110002*PR_010002010010+Q_010110102*PR_010002010011+Q_010110202*PR_010002010012+Q_110010002*PR_010002010100+Q_110010102*PR_010002010101+Q_110010202*PR_010002010102+Q_110110002*PR_010002010110+Q_110110102*PR_010002010111+Q_110110202*PR_010002010112); ans_temp[ans_id*36+20]+=Pmtrx[12]*(Q_002020000*PR_010002010000+Q_002120000*PR_010002010010+Q_002220000*PR_010002010020+Q_102020000*PR_010002010100+Q_102120000*PR_010002010110+Q_102220000*PR_010002010120+Q_202020000*PR_010002010200+Q_202120000*PR_010002010210+Q_202220000*PR_010002010220); ans_temp[ans_id*36+20]+=Pmtrx[13]*(Q_001021000*PR_010002010000+Q_001121000*PR_010002010010+Q_001221000*PR_010002010020+Q_001321000*PR_010002010030+Q_101021000*PR_010002010100+Q_101121000*PR_010002010110+Q_101221000*PR_010002010120+Q_101321000*PR_010002010130); ans_temp[ans_id*36+20]+=Pmtrx[14]*(Q_000022000*PR_010002010000+Q_000122000*PR_010002010010+Q_000222000*PR_010002010020+Q_000322000*PR_010002010030+Q_000422000*PR_010002010040); ans_temp[ans_id*36+20]+=Pmtrx[15]*(Q_001020001*PR_010002010000+Q_001020101*PR_010002010001+Q_001120001*PR_010002010010+Q_001120101*PR_010002010011+Q_001220001*PR_010002010020+Q_001220101*PR_010002010021+Q_101020001*PR_010002010100+Q_101020101*PR_010002010101+Q_101120001*PR_010002010110+Q_101120101*PR_010002010111+Q_101220001*PR_010002010120+Q_101220101*PR_010002010121); ans_temp[ans_id*36+20]+=Pmtrx[16]*(Q_000021001*PR_010002010000+Q_000021101*PR_010002010001+Q_000121001*PR_010002010010+Q_000121101*PR_010002010011+Q_000221001*PR_010002010020+Q_000221101*PR_010002010021+Q_000321001*PR_010002010030+Q_000321101*PR_010002010031); ans_temp[ans_id*36+20]+=Pmtrx[17]*(Q_000020002*PR_010002010000+Q_000020102*PR_010002010001+Q_000020202*PR_010002010002+Q_000120002*PR_010002010010+Q_000120102*PR_010002010011+Q_000120202*PR_010002010012+Q_000220002*PR_010002010020+Q_000220102*PR_010002010021+Q_000220202*PR_010002010022); ans_temp[ans_id*36+21]+=Pmtrx[12]*(Q_012000010*PR_010002010000+Q_012000110*PR_010002010001+Q_112000010*PR_010002010100+Q_112000110*PR_010002010101+Q_212000010*PR_010002010200+Q_212000110*PR_010002010201+Q_312000010*PR_010002010300+Q_312000110*PR_010002010301); ans_temp[ans_id*36+21]+=Pmtrx[13]*(Q_011001010*PR_010002010000+Q_011001110*PR_010002010001+Q_011101010*PR_010002010010+Q_011101110*PR_010002010011+Q_111001010*PR_010002010100+Q_111001110*PR_010002010101+Q_111101010*PR_010002010110+Q_111101110*PR_010002010111+Q_211001010*PR_010002010200+Q_211001110*PR_010002010201+Q_211101010*PR_010002010210+Q_211101110*PR_010002010211); ans_temp[ans_id*36+21]+=Pmtrx[14]*(Q_010002010*PR_010002010000+Q_010002110*PR_010002010001+Q_010102010*PR_010002010010+Q_010102110*PR_010002010011+Q_010202010*PR_010002010020+Q_010202110*PR_010002010021+Q_110002010*PR_010002010100+Q_110002110*PR_010002010101+Q_110102010*PR_010002010110+Q_110102110*PR_010002010111+Q_110202010*PR_010002010120+Q_110202110*PR_010002010121); ans_temp[ans_id*36+21]+=Pmtrx[15]*(Q_011000011*PR_010002010000+Q_011000111*PR_010002010001+Q_011000211*PR_010002010002+Q_111000011*PR_010002010100+Q_111000111*PR_010002010101+Q_111000211*PR_010002010102+Q_211000011*PR_010002010200+Q_211000111*PR_010002010201+Q_211000211*PR_010002010202); ans_temp[ans_id*36+21]+=Pmtrx[16]*(Q_010001011*PR_010002010000+Q_010001111*PR_010002010001+Q_010001211*PR_010002010002+Q_010101011*PR_010002010010+Q_010101111*PR_010002010011+Q_010101211*PR_010002010012+Q_110001011*PR_010002010100+Q_110001111*PR_010002010101+Q_110001211*PR_010002010102+Q_110101011*PR_010002010110+Q_110101111*PR_010002010111+Q_110101211*PR_010002010112); ans_temp[ans_id*36+21]+=Pmtrx[17]*(Q_010000012*PR_010002010000+Q_010000112*PR_010002010001+Q_010000212*PR_010002010002+Q_010000312*PR_010002010003+Q_110000012*PR_010002010100+Q_110000112*PR_010002010101+Q_110000212*PR_010002010102+Q_110000312*PR_010002010103); ans_temp[ans_id*36+22]+=Pmtrx[12]*(Q_002010010*PR_010002010000+Q_002010110*PR_010002010001+Q_002110010*PR_010002010010+Q_002110110*PR_010002010011+Q_102010010*PR_010002010100+Q_102010110*PR_010002010101+Q_102110010*PR_010002010110+Q_102110110*PR_010002010111+Q_202010010*PR_010002010200+Q_202010110*PR_010002010201+Q_202110010*PR_010002010210+Q_202110110*PR_010002010211); ans_temp[ans_id*36+22]+=Pmtrx[13]*(Q_001011010*PR_010002010000+Q_001011110*PR_010002010001+Q_001111010*PR_010002010010+Q_001111110*PR_010002010011+Q_001211010*PR_010002010020+Q_001211110*PR_010002010021+Q_101011010*PR_010002010100+Q_101011110*PR_010002010101+Q_101111010*PR_010002010110+Q_101111110*PR_010002010111+Q_101211010*PR_010002010120+Q_101211110*PR_010002010121); ans_temp[ans_id*36+22]+=Pmtrx[14]*(Q_000012010*PR_010002010000+Q_000012110*PR_010002010001+Q_000112010*PR_010002010010+Q_000112110*PR_010002010011+Q_000212010*PR_010002010020+Q_000212110*PR_010002010021+Q_000312010*PR_010002010030+Q_000312110*PR_010002010031); ans_temp[ans_id*36+22]+=Pmtrx[15]*(Q_001010011*PR_010002010000+Q_001010111*PR_010002010001+Q_001010211*PR_010002010002+Q_001110011*PR_010002010010+Q_001110111*PR_010002010011+Q_001110211*PR_010002010012+Q_101010011*PR_010002010100+Q_101010111*PR_010002010101+Q_101010211*PR_010002010102+Q_101110011*PR_010002010110+Q_101110111*PR_010002010111+Q_101110211*PR_010002010112); ans_temp[ans_id*36+22]+=Pmtrx[16]*(Q_000011011*PR_010002010000+Q_000011111*PR_010002010001+Q_000011211*PR_010002010002+Q_000111011*PR_010002010010+Q_000111111*PR_010002010011+Q_000111211*PR_010002010012+Q_000211011*PR_010002010020+Q_000211111*PR_010002010021+Q_000211211*PR_010002010022); ans_temp[ans_id*36+22]+=Pmtrx[17]*(Q_000010012*PR_010002010000+Q_000010112*PR_010002010001+Q_000010212*PR_010002010002+Q_000010312*PR_010002010003+Q_000110012*PR_010002010010+Q_000110112*PR_010002010011+Q_000110212*PR_010002010012+Q_000110312*PR_010002010013); ans_temp[ans_id*36+23]+=Pmtrx[12]*(Q_002000020*PR_010002010000+Q_002000120*PR_010002010001+Q_002000220*PR_010002010002+Q_102000020*PR_010002010100+Q_102000120*PR_010002010101+Q_102000220*PR_010002010102+Q_202000020*PR_010002010200+Q_202000120*PR_010002010201+Q_202000220*PR_010002010202); ans_temp[ans_id*36+23]+=Pmtrx[13]*(Q_001001020*PR_010002010000+Q_001001120*PR_010002010001+Q_001001220*PR_010002010002+Q_001101020*PR_010002010010+Q_001101120*PR_010002010011+Q_001101220*PR_010002010012+Q_101001020*PR_010002010100+Q_101001120*PR_010002010101+Q_101001220*PR_010002010102+Q_101101020*PR_010002010110+Q_101101120*PR_010002010111+Q_101101220*PR_010002010112); ans_temp[ans_id*36+23]+=Pmtrx[14]*(Q_000002020*PR_010002010000+Q_000002120*PR_010002010001+Q_000002220*PR_010002010002+Q_000102020*PR_010002010010+Q_000102120*PR_010002010011+Q_000102220*PR_010002010012+Q_000202020*PR_010002010020+Q_000202120*PR_010002010021+Q_000202220*PR_010002010022); ans_temp[ans_id*36+23]+=Pmtrx[15]*(Q_001000021*PR_010002010000+Q_001000121*PR_010002010001+Q_001000221*PR_010002010002+Q_001000321*PR_010002010003+Q_101000021*PR_010002010100+Q_101000121*PR_010002010101+Q_101000221*PR_010002010102+Q_101000321*PR_010002010103); ans_temp[ans_id*36+23]+=Pmtrx[16]*(Q_000001021*PR_010002010000+Q_000001121*PR_010002010001+Q_000001221*PR_010002010002+Q_000001321*PR_010002010003+Q_000101021*PR_010002010010+Q_000101121*PR_010002010011+Q_000101221*PR_010002010012+Q_000101321*PR_010002010013); ans_temp[ans_id*36+23]+=Pmtrx[17]*(Q_000000022*PR_010002010000+Q_000000122*PR_010002010001+Q_000000222*PR_010002010002+Q_000000322*PR_010002010003+Q_000000422*PR_010002010004); ans_temp[ans_id*36+18]+=Pmtrx[18]*(Q_022000000*PR_011000011000+Q_122000000*PR_011000011100+Q_222000000*PR_011000011200+Q_322000000*PR_011000011300+Q_422000000*PR_011000011400); ans_temp[ans_id*36+18]+=Pmtrx[19]*(Q_021001000*PR_011000011000+Q_021101000*PR_011000011010+Q_121001000*PR_011000011100+Q_121101000*PR_011000011110+Q_221001000*PR_011000011200+Q_221101000*PR_011000011210+Q_321001000*PR_011000011300+Q_321101000*PR_011000011310); ans_temp[ans_id*36+18]+=Pmtrx[20]*(Q_020002000*PR_011000011000+Q_020102000*PR_011000011010+Q_020202000*PR_011000011020+Q_120002000*PR_011000011100+Q_120102000*PR_011000011110+Q_120202000*PR_011000011120+Q_220002000*PR_011000011200+Q_220102000*PR_011000011210+Q_220202000*PR_011000011220); ans_temp[ans_id*36+18]+=Pmtrx[21]*(Q_021000001*PR_011000011000+Q_021000101*PR_011000011001+Q_121000001*PR_011000011100+Q_121000101*PR_011000011101+Q_221000001*PR_011000011200+Q_221000101*PR_011000011201+Q_321000001*PR_011000011300+Q_321000101*PR_011000011301); ans_temp[ans_id*36+18]+=Pmtrx[22]*(Q_020001001*PR_011000011000+Q_020001101*PR_011000011001+Q_020101001*PR_011000011010+Q_020101101*PR_011000011011+Q_120001001*PR_011000011100+Q_120001101*PR_011000011101+Q_120101001*PR_011000011110+Q_120101101*PR_011000011111+Q_220001001*PR_011000011200+Q_220001101*PR_011000011201+Q_220101001*PR_011000011210+Q_220101101*PR_011000011211); ans_temp[ans_id*36+18]+=Pmtrx[23]*(Q_020000002*PR_011000011000+Q_020000102*PR_011000011001+Q_020000202*PR_011000011002+Q_120000002*PR_011000011100+Q_120000102*PR_011000011101+Q_120000202*PR_011000011102+Q_220000002*PR_011000011200+Q_220000102*PR_011000011201+Q_220000202*PR_011000011202); ans_temp[ans_id*36+19]+=Pmtrx[18]*(Q_012010000*PR_011000011000+Q_012110000*PR_011000011010+Q_112010000*PR_011000011100+Q_112110000*PR_011000011110+Q_212010000*PR_011000011200+Q_212110000*PR_011000011210+Q_312010000*PR_011000011300+Q_312110000*PR_011000011310); ans_temp[ans_id*36+19]+=Pmtrx[19]*(Q_011011000*PR_011000011000+Q_011111000*PR_011000011010+Q_011211000*PR_011000011020+Q_111011000*PR_011000011100+Q_111111000*PR_011000011110+Q_111211000*PR_011000011120+Q_211011000*PR_011000011200+Q_211111000*PR_011000011210+Q_211211000*PR_011000011220); ans_temp[ans_id*36+19]+=Pmtrx[20]*(Q_010012000*PR_011000011000+Q_010112000*PR_011000011010+Q_010212000*PR_011000011020+Q_010312000*PR_011000011030+Q_110012000*PR_011000011100+Q_110112000*PR_011000011110+Q_110212000*PR_011000011120+Q_110312000*PR_011000011130); ans_temp[ans_id*36+19]+=Pmtrx[21]*(Q_011010001*PR_011000011000+Q_011010101*PR_011000011001+Q_011110001*PR_011000011010+Q_011110101*PR_011000011011+Q_111010001*PR_011000011100+Q_111010101*PR_011000011101+Q_111110001*PR_011000011110+Q_111110101*PR_011000011111+Q_211010001*PR_011000011200+Q_211010101*PR_011000011201+Q_211110001*PR_011000011210+Q_211110101*PR_011000011211); ans_temp[ans_id*36+19]+=Pmtrx[22]*(Q_010011001*PR_011000011000+Q_010011101*PR_011000011001+Q_010111001*PR_011000011010+Q_010111101*PR_011000011011+Q_010211001*PR_011000011020+Q_010211101*PR_011000011021+Q_110011001*PR_011000011100+Q_110011101*PR_011000011101+Q_110111001*PR_011000011110+Q_110111101*PR_011000011111+Q_110211001*PR_011000011120+Q_110211101*PR_011000011121); ans_temp[ans_id*36+19]+=Pmtrx[23]*(Q_010010002*PR_011000011000+Q_010010102*PR_011000011001+Q_010010202*PR_011000011002+Q_010110002*PR_011000011010+Q_010110102*PR_011000011011+Q_010110202*PR_011000011012+Q_110010002*PR_011000011100+Q_110010102*PR_011000011101+Q_110010202*PR_011000011102+Q_110110002*PR_011000011110+Q_110110102*PR_011000011111+Q_110110202*PR_011000011112); ans_temp[ans_id*36+20]+=Pmtrx[18]*(Q_002020000*PR_011000011000+Q_002120000*PR_011000011010+Q_002220000*PR_011000011020+Q_102020000*PR_011000011100+Q_102120000*PR_011000011110+Q_102220000*PR_011000011120+Q_202020000*PR_011000011200+Q_202120000*PR_011000011210+Q_202220000*PR_011000011220); ans_temp[ans_id*36+20]+=Pmtrx[19]*(Q_001021000*PR_011000011000+Q_001121000*PR_011000011010+Q_001221000*PR_011000011020+Q_001321000*PR_011000011030+Q_101021000*PR_011000011100+Q_101121000*PR_011000011110+Q_101221000*PR_011000011120+Q_101321000*PR_011000011130); ans_temp[ans_id*36+20]+=Pmtrx[20]*(Q_000022000*PR_011000011000+Q_000122000*PR_011000011010+Q_000222000*PR_011000011020+Q_000322000*PR_011000011030+Q_000422000*PR_011000011040); ans_temp[ans_id*36+20]+=Pmtrx[21]*(Q_001020001*PR_011000011000+Q_001020101*PR_011000011001+Q_001120001*PR_011000011010+Q_001120101*PR_011000011011+Q_001220001*PR_011000011020+Q_001220101*PR_011000011021+Q_101020001*PR_011000011100+Q_101020101*PR_011000011101+Q_101120001*PR_011000011110+Q_101120101*PR_011000011111+Q_101220001*PR_011000011120+Q_101220101*PR_011000011121); ans_temp[ans_id*36+20]+=Pmtrx[22]*(Q_000021001*PR_011000011000+Q_000021101*PR_011000011001+Q_000121001*PR_011000011010+Q_000121101*PR_011000011011+Q_000221001*PR_011000011020+Q_000221101*PR_011000011021+Q_000321001*PR_011000011030+Q_000321101*PR_011000011031); ans_temp[ans_id*36+20]+=Pmtrx[23]*(Q_000020002*PR_011000011000+Q_000020102*PR_011000011001+Q_000020202*PR_011000011002+Q_000120002*PR_011000011010+Q_000120102*PR_011000011011+Q_000120202*PR_011000011012+Q_000220002*PR_011000011020+Q_000220102*PR_011000011021+Q_000220202*PR_011000011022); ans_temp[ans_id*36+21]+=Pmtrx[18]*(Q_012000010*PR_011000011000+Q_012000110*PR_011000011001+Q_112000010*PR_011000011100+Q_112000110*PR_011000011101+Q_212000010*PR_011000011200+Q_212000110*PR_011000011201+Q_312000010*PR_011000011300+Q_312000110*PR_011000011301); ans_temp[ans_id*36+21]+=Pmtrx[19]*(Q_011001010*PR_011000011000+Q_011001110*PR_011000011001+Q_011101010*PR_011000011010+Q_011101110*PR_011000011011+Q_111001010*PR_011000011100+Q_111001110*PR_011000011101+Q_111101010*PR_011000011110+Q_111101110*PR_011000011111+Q_211001010*PR_011000011200+Q_211001110*PR_011000011201+Q_211101010*PR_011000011210+Q_211101110*PR_011000011211); ans_temp[ans_id*36+21]+=Pmtrx[20]*(Q_010002010*PR_011000011000+Q_010002110*PR_011000011001+Q_010102010*PR_011000011010+Q_010102110*PR_011000011011+Q_010202010*PR_011000011020+Q_010202110*PR_011000011021+Q_110002010*PR_011000011100+Q_110002110*PR_011000011101+Q_110102010*PR_011000011110+Q_110102110*PR_011000011111+Q_110202010*PR_011000011120+Q_110202110*PR_011000011121); ans_temp[ans_id*36+21]+=Pmtrx[21]*(Q_011000011*PR_011000011000+Q_011000111*PR_011000011001+Q_011000211*PR_011000011002+Q_111000011*PR_011000011100+Q_111000111*PR_011000011101+Q_111000211*PR_011000011102+Q_211000011*PR_011000011200+Q_211000111*PR_011000011201+Q_211000211*PR_011000011202); ans_temp[ans_id*36+21]+=Pmtrx[22]*(Q_010001011*PR_011000011000+Q_010001111*PR_011000011001+Q_010001211*PR_011000011002+Q_010101011*PR_011000011010+Q_010101111*PR_011000011011+Q_010101211*PR_011000011012+Q_110001011*PR_011000011100+Q_110001111*PR_011000011101+Q_110001211*PR_011000011102+Q_110101011*PR_011000011110+Q_110101111*PR_011000011111+Q_110101211*PR_011000011112); ans_temp[ans_id*36+21]+=Pmtrx[23]*(Q_010000012*PR_011000011000+Q_010000112*PR_011000011001+Q_010000212*PR_011000011002+Q_010000312*PR_011000011003+Q_110000012*PR_011000011100+Q_110000112*PR_011000011101+Q_110000212*PR_011000011102+Q_110000312*PR_011000011103); ans_temp[ans_id*36+22]+=Pmtrx[18]*(Q_002010010*PR_011000011000+Q_002010110*PR_011000011001+Q_002110010*PR_011000011010+Q_002110110*PR_011000011011+Q_102010010*PR_011000011100+Q_102010110*PR_011000011101+Q_102110010*PR_011000011110+Q_102110110*PR_011000011111+Q_202010010*PR_011000011200+Q_202010110*PR_011000011201+Q_202110010*PR_011000011210+Q_202110110*PR_011000011211); ans_temp[ans_id*36+22]+=Pmtrx[19]*(Q_001011010*PR_011000011000+Q_001011110*PR_011000011001+Q_001111010*PR_011000011010+Q_001111110*PR_011000011011+Q_001211010*PR_011000011020+Q_001211110*PR_011000011021+Q_101011010*PR_011000011100+Q_101011110*PR_011000011101+Q_101111010*PR_011000011110+Q_101111110*PR_011000011111+Q_101211010*PR_011000011120+Q_101211110*PR_011000011121); ans_temp[ans_id*36+22]+=Pmtrx[20]*(Q_000012010*PR_011000011000+Q_000012110*PR_011000011001+Q_000112010*PR_011000011010+Q_000112110*PR_011000011011+Q_000212010*PR_011000011020+Q_000212110*PR_011000011021+Q_000312010*PR_011000011030+Q_000312110*PR_011000011031); ans_temp[ans_id*36+22]+=Pmtrx[21]*(Q_001010011*PR_011000011000+Q_001010111*PR_011000011001+Q_001010211*PR_011000011002+Q_001110011*PR_011000011010+Q_001110111*PR_011000011011+Q_001110211*PR_011000011012+Q_101010011*PR_011000011100+Q_101010111*PR_011000011101+Q_101010211*PR_011000011102+Q_101110011*PR_011000011110+Q_101110111*PR_011000011111+Q_101110211*PR_011000011112); ans_temp[ans_id*36+22]+=Pmtrx[22]*(Q_000011011*PR_011000011000+Q_000011111*PR_011000011001+Q_000011211*PR_011000011002+Q_000111011*PR_011000011010+Q_000111111*PR_011000011011+Q_000111211*PR_011000011012+Q_000211011*PR_011000011020+Q_000211111*PR_011000011021+Q_000211211*PR_011000011022); ans_temp[ans_id*36+22]+=Pmtrx[23]*(Q_000010012*PR_011000011000+Q_000010112*PR_011000011001+Q_000010212*PR_011000011002+Q_000010312*PR_011000011003+Q_000110012*PR_011000011010+Q_000110112*PR_011000011011+Q_000110212*PR_011000011012+Q_000110312*PR_011000011013); ans_temp[ans_id*36+23]+=Pmtrx[18]*(Q_002000020*PR_011000011000+Q_002000120*PR_011000011001+Q_002000220*PR_011000011002+Q_102000020*PR_011000011100+Q_102000120*PR_011000011101+Q_102000220*PR_011000011102+Q_202000020*PR_011000011200+Q_202000120*PR_011000011201+Q_202000220*PR_011000011202); ans_temp[ans_id*36+23]+=Pmtrx[19]*(Q_001001020*PR_011000011000+Q_001001120*PR_011000011001+Q_001001220*PR_011000011002+Q_001101020*PR_011000011010+Q_001101120*PR_011000011011+Q_001101220*PR_011000011012+Q_101001020*PR_011000011100+Q_101001120*PR_011000011101+Q_101001220*PR_011000011102+Q_101101020*PR_011000011110+Q_101101120*PR_011000011111+Q_101101220*PR_011000011112); ans_temp[ans_id*36+23]+=Pmtrx[20]*(Q_000002020*PR_011000011000+Q_000002120*PR_011000011001+Q_000002220*PR_011000011002+Q_000102020*PR_011000011010+Q_000102120*PR_011000011011+Q_000102220*PR_011000011012+Q_000202020*PR_011000011020+Q_000202120*PR_011000011021+Q_000202220*PR_011000011022); ans_temp[ans_id*36+23]+=Pmtrx[21]*(Q_001000021*PR_011000011000+Q_001000121*PR_011000011001+Q_001000221*PR_011000011002+Q_001000321*PR_011000011003+Q_101000021*PR_011000011100+Q_101000121*PR_011000011101+Q_101000221*PR_011000011102+Q_101000321*PR_011000011103); ans_temp[ans_id*36+23]+=Pmtrx[22]*(Q_000001021*PR_011000011000+Q_000001121*PR_011000011001+Q_000001221*PR_011000011002+Q_000001321*PR_011000011003+Q_000101021*PR_011000011010+Q_000101121*PR_011000011011+Q_000101221*PR_011000011012+Q_000101321*PR_011000011013); ans_temp[ans_id*36+23]+=Pmtrx[23]*(Q_000000022*PR_011000011000+Q_000000122*PR_011000011001+Q_000000222*PR_011000011002+Q_000000322*PR_011000011003+Q_000000422*PR_011000011004); ans_temp[ans_id*36+18]+=Pmtrx[24]*(Q_022000000*PR_010001011000+Q_122000000*PR_010001011100+Q_222000000*PR_010001011200+Q_322000000*PR_010001011300+Q_422000000*PR_010001011400); ans_temp[ans_id*36+18]+=Pmtrx[25]*(Q_021001000*PR_010001011000+Q_021101000*PR_010001011010+Q_121001000*PR_010001011100+Q_121101000*PR_010001011110+Q_221001000*PR_010001011200+Q_221101000*PR_010001011210+Q_321001000*PR_010001011300+Q_321101000*PR_010001011310); ans_temp[ans_id*36+18]+=Pmtrx[26]*(Q_020002000*PR_010001011000+Q_020102000*PR_010001011010+Q_020202000*PR_010001011020+Q_120002000*PR_010001011100+Q_120102000*PR_010001011110+Q_120202000*PR_010001011120+Q_220002000*PR_010001011200+Q_220102000*PR_010001011210+Q_220202000*PR_010001011220); ans_temp[ans_id*36+18]+=Pmtrx[27]*(Q_021000001*PR_010001011000+Q_021000101*PR_010001011001+Q_121000001*PR_010001011100+Q_121000101*PR_010001011101+Q_221000001*PR_010001011200+Q_221000101*PR_010001011201+Q_321000001*PR_010001011300+Q_321000101*PR_010001011301); ans_temp[ans_id*36+18]+=Pmtrx[28]*(Q_020001001*PR_010001011000+Q_020001101*PR_010001011001+Q_020101001*PR_010001011010+Q_020101101*PR_010001011011+Q_120001001*PR_010001011100+Q_120001101*PR_010001011101+Q_120101001*PR_010001011110+Q_120101101*PR_010001011111+Q_220001001*PR_010001011200+Q_220001101*PR_010001011201+Q_220101001*PR_010001011210+Q_220101101*PR_010001011211); ans_temp[ans_id*36+18]+=Pmtrx[29]*(Q_020000002*PR_010001011000+Q_020000102*PR_010001011001+Q_020000202*PR_010001011002+Q_120000002*PR_010001011100+Q_120000102*PR_010001011101+Q_120000202*PR_010001011102+Q_220000002*PR_010001011200+Q_220000102*PR_010001011201+Q_220000202*PR_010001011202); ans_temp[ans_id*36+19]+=Pmtrx[24]*(Q_012010000*PR_010001011000+Q_012110000*PR_010001011010+Q_112010000*PR_010001011100+Q_112110000*PR_010001011110+Q_212010000*PR_010001011200+Q_212110000*PR_010001011210+Q_312010000*PR_010001011300+Q_312110000*PR_010001011310); ans_temp[ans_id*36+19]+=Pmtrx[25]*(Q_011011000*PR_010001011000+Q_011111000*PR_010001011010+Q_011211000*PR_010001011020+Q_111011000*PR_010001011100+Q_111111000*PR_010001011110+Q_111211000*PR_010001011120+Q_211011000*PR_010001011200+Q_211111000*PR_010001011210+Q_211211000*PR_010001011220); ans_temp[ans_id*36+19]+=Pmtrx[26]*(Q_010012000*PR_010001011000+Q_010112000*PR_010001011010+Q_010212000*PR_010001011020+Q_010312000*PR_010001011030+Q_110012000*PR_010001011100+Q_110112000*PR_010001011110+Q_110212000*PR_010001011120+Q_110312000*PR_010001011130); ans_temp[ans_id*36+19]+=Pmtrx[27]*(Q_011010001*PR_010001011000+Q_011010101*PR_010001011001+Q_011110001*PR_010001011010+Q_011110101*PR_010001011011+Q_111010001*PR_010001011100+Q_111010101*PR_010001011101+Q_111110001*PR_010001011110+Q_111110101*PR_010001011111+Q_211010001*PR_010001011200+Q_211010101*PR_010001011201+Q_211110001*PR_010001011210+Q_211110101*PR_010001011211); ans_temp[ans_id*36+19]+=Pmtrx[28]*(Q_010011001*PR_010001011000+Q_010011101*PR_010001011001+Q_010111001*PR_010001011010+Q_010111101*PR_010001011011+Q_010211001*PR_010001011020+Q_010211101*PR_010001011021+Q_110011001*PR_010001011100+Q_110011101*PR_010001011101+Q_110111001*PR_010001011110+Q_110111101*PR_010001011111+Q_110211001*PR_010001011120+Q_110211101*PR_010001011121); ans_temp[ans_id*36+19]+=Pmtrx[29]*(Q_010010002*PR_010001011000+Q_010010102*PR_010001011001+Q_010010202*PR_010001011002+Q_010110002*PR_010001011010+Q_010110102*PR_010001011011+Q_010110202*PR_010001011012+Q_110010002*PR_010001011100+Q_110010102*PR_010001011101+Q_110010202*PR_010001011102+Q_110110002*PR_010001011110+Q_110110102*PR_010001011111+Q_110110202*PR_010001011112); ans_temp[ans_id*36+20]+=Pmtrx[24]*(Q_002020000*PR_010001011000+Q_002120000*PR_010001011010+Q_002220000*PR_010001011020+Q_102020000*PR_010001011100+Q_102120000*PR_010001011110+Q_102220000*PR_010001011120+Q_202020000*PR_010001011200+Q_202120000*PR_010001011210+Q_202220000*PR_010001011220); ans_temp[ans_id*36+20]+=Pmtrx[25]*(Q_001021000*PR_010001011000+Q_001121000*PR_010001011010+Q_001221000*PR_010001011020+Q_001321000*PR_010001011030+Q_101021000*PR_010001011100+Q_101121000*PR_010001011110+Q_101221000*PR_010001011120+Q_101321000*PR_010001011130); ans_temp[ans_id*36+20]+=Pmtrx[26]*(Q_000022000*PR_010001011000+Q_000122000*PR_010001011010+Q_000222000*PR_010001011020+Q_000322000*PR_010001011030+Q_000422000*PR_010001011040); ans_temp[ans_id*36+20]+=Pmtrx[27]*(Q_001020001*PR_010001011000+Q_001020101*PR_010001011001+Q_001120001*PR_010001011010+Q_001120101*PR_010001011011+Q_001220001*PR_010001011020+Q_001220101*PR_010001011021+Q_101020001*PR_010001011100+Q_101020101*PR_010001011101+Q_101120001*PR_010001011110+Q_101120101*PR_010001011111+Q_101220001*PR_010001011120+Q_101220101*PR_010001011121); ans_temp[ans_id*36+20]+=Pmtrx[28]*(Q_000021001*PR_010001011000+Q_000021101*PR_010001011001+Q_000121001*PR_010001011010+Q_000121101*PR_010001011011+Q_000221001*PR_010001011020+Q_000221101*PR_010001011021+Q_000321001*PR_010001011030+Q_000321101*PR_010001011031); ans_temp[ans_id*36+20]+=Pmtrx[29]*(Q_000020002*PR_010001011000+Q_000020102*PR_010001011001+Q_000020202*PR_010001011002+Q_000120002*PR_010001011010+Q_000120102*PR_010001011011+Q_000120202*PR_010001011012+Q_000220002*PR_010001011020+Q_000220102*PR_010001011021+Q_000220202*PR_010001011022); ans_temp[ans_id*36+21]+=Pmtrx[24]*(Q_012000010*PR_010001011000+Q_012000110*PR_010001011001+Q_112000010*PR_010001011100+Q_112000110*PR_010001011101+Q_212000010*PR_010001011200+Q_212000110*PR_010001011201+Q_312000010*PR_010001011300+Q_312000110*PR_010001011301); ans_temp[ans_id*36+21]+=Pmtrx[25]*(Q_011001010*PR_010001011000+Q_011001110*PR_010001011001+Q_011101010*PR_010001011010+Q_011101110*PR_010001011011+Q_111001010*PR_010001011100+Q_111001110*PR_010001011101+Q_111101010*PR_010001011110+Q_111101110*PR_010001011111+Q_211001010*PR_010001011200+Q_211001110*PR_010001011201+Q_211101010*PR_010001011210+Q_211101110*PR_010001011211); ans_temp[ans_id*36+21]+=Pmtrx[26]*(Q_010002010*PR_010001011000+Q_010002110*PR_010001011001+Q_010102010*PR_010001011010+Q_010102110*PR_010001011011+Q_010202010*PR_010001011020+Q_010202110*PR_010001011021+Q_110002010*PR_010001011100+Q_110002110*PR_010001011101+Q_110102010*PR_010001011110+Q_110102110*PR_010001011111+Q_110202010*PR_010001011120+Q_110202110*PR_010001011121); ans_temp[ans_id*36+21]+=Pmtrx[27]*(Q_011000011*PR_010001011000+Q_011000111*PR_010001011001+Q_011000211*PR_010001011002+Q_111000011*PR_010001011100+Q_111000111*PR_010001011101+Q_111000211*PR_010001011102+Q_211000011*PR_010001011200+Q_211000111*PR_010001011201+Q_211000211*PR_010001011202); ans_temp[ans_id*36+21]+=Pmtrx[28]*(Q_010001011*PR_010001011000+Q_010001111*PR_010001011001+Q_010001211*PR_010001011002+Q_010101011*PR_010001011010+Q_010101111*PR_010001011011+Q_010101211*PR_010001011012+Q_110001011*PR_010001011100+Q_110001111*PR_010001011101+Q_110001211*PR_010001011102+Q_110101011*PR_010001011110+Q_110101111*PR_010001011111+Q_110101211*PR_010001011112); ans_temp[ans_id*36+21]+=Pmtrx[29]*(Q_010000012*PR_010001011000+Q_010000112*PR_010001011001+Q_010000212*PR_010001011002+Q_010000312*PR_010001011003+Q_110000012*PR_010001011100+Q_110000112*PR_010001011101+Q_110000212*PR_010001011102+Q_110000312*PR_010001011103); ans_temp[ans_id*36+22]+=Pmtrx[24]*(Q_002010010*PR_010001011000+Q_002010110*PR_010001011001+Q_002110010*PR_010001011010+Q_002110110*PR_010001011011+Q_102010010*PR_010001011100+Q_102010110*PR_010001011101+Q_102110010*PR_010001011110+Q_102110110*PR_010001011111+Q_202010010*PR_010001011200+Q_202010110*PR_010001011201+Q_202110010*PR_010001011210+Q_202110110*PR_010001011211); ans_temp[ans_id*36+22]+=Pmtrx[25]*(Q_001011010*PR_010001011000+Q_001011110*PR_010001011001+Q_001111010*PR_010001011010+Q_001111110*PR_010001011011+Q_001211010*PR_010001011020+Q_001211110*PR_010001011021+Q_101011010*PR_010001011100+Q_101011110*PR_010001011101+Q_101111010*PR_010001011110+Q_101111110*PR_010001011111+Q_101211010*PR_010001011120+Q_101211110*PR_010001011121); ans_temp[ans_id*36+22]+=Pmtrx[26]*(Q_000012010*PR_010001011000+Q_000012110*PR_010001011001+Q_000112010*PR_010001011010+Q_000112110*PR_010001011011+Q_000212010*PR_010001011020+Q_000212110*PR_010001011021+Q_000312010*PR_010001011030+Q_000312110*PR_010001011031); ans_temp[ans_id*36+22]+=Pmtrx[27]*(Q_001010011*PR_010001011000+Q_001010111*PR_010001011001+Q_001010211*PR_010001011002+Q_001110011*PR_010001011010+Q_001110111*PR_010001011011+Q_001110211*PR_010001011012+Q_101010011*PR_010001011100+Q_101010111*PR_010001011101+Q_101010211*PR_010001011102+Q_101110011*PR_010001011110+Q_101110111*PR_010001011111+Q_101110211*PR_010001011112); ans_temp[ans_id*36+22]+=Pmtrx[28]*(Q_000011011*PR_010001011000+Q_000011111*PR_010001011001+Q_000011211*PR_010001011002+Q_000111011*PR_010001011010+Q_000111111*PR_010001011011+Q_000111211*PR_010001011012+Q_000211011*PR_010001011020+Q_000211111*PR_010001011021+Q_000211211*PR_010001011022); ans_temp[ans_id*36+22]+=Pmtrx[29]*(Q_000010012*PR_010001011000+Q_000010112*PR_010001011001+Q_000010212*PR_010001011002+Q_000010312*PR_010001011003+Q_000110012*PR_010001011010+Q_000110112*PR_010001011011+Q_000110212*PR_010001011012+Q_000110312*PR_010001011013); ans_temp[ans_id*36+23]+=Pmtrx[24]*(Q_002000020*PR_010001011000+Q_002000120*PR_010001011001+Q_002000220*PR_010001011002+Q_102000020*PR_010001011100+Q_102000120*PR_010001011101+Q_102000220*PR_010001011102+Q_202000020*PR_010001011200+Q_202000120*PR_010001011201+Q_202000220*PR_010001011202); ans_temp[ans_id*36+23]+=Pmtrx[25]*(Q_001001020*PR_010001011000+Q_001001120*PR_010001011001+Q_001001220*PR_010001011002+Q_001101020*PR_010001011010+Q_001101120*PR_010001011011+Q_001101220*PR_010001011012+Q_101001020*PR_010001011100+Q_101001120*PR_010001011101+Q_101001220*PR_010001011102+Q_101101020*PR_010001011110+Q_101101120*PR_010001011111+Q_101101220*PR_010001011112); ans_temp[ans_id*36+23]+=Pmtrx[26]*(Q_000002020*PR_010001011000+Q_000002120*PR_010001011001+Q_000002220*PR_010001011002+Q_000102020*PR_010001011010+Q_000102120*PR_010001011011+Q_000102220*PR_010001011012+Q_000202020*PR_010001011020+Q_000202120*PR_010001011021+Q_000202220*PR_010001011022); ans_temp[ans_id*36+23]+=Pmtrx[27]*(Q_001000021*PR_010001011000+Q_001000121*PR_010001011001+Q_001000221*PR_010001011002+Q_001000321*PR_010001011003+Q_101000021*PR_010001011100+Q_101000121*PR_010001011101+Q_101000221*PR_010001011102+Q_101000321*PR_010001011103); ans_temp[ans_id*36+23]+=Pmtrx[28]*(Q_000001021*PR_010001011000+Q_000001121*PR_010001011001+Q_000001221*PR_010001011002+Q_000001321*PR_010001011003+Q_000101021*PR_010001011010+Q_000101121*PR_010001011011+Q_000101221*PR_010001011012+Q_000101321*PR_010001011013); ans_temp[ans_id*36+23]+=Pmtrx[29]*(Q_000000022*PR_010001011000+Q_000000122*PR_010001011001+Q_000000222*PR_010001011002+Q_000000322*PR_010001011003+Q_000000422*PR_010001011004); ans_temp[ans_id*36+18]+=Pmtrx[30]*(Q_022000000*PR_010000012000+Q_122000000*PR_010000012100+Q_222000000*PR_010000012200+Q_322000000*PR_010000012300+Q_422000000*PR_010000012400); ans_temp[ans_id*36+18]+=Pmtrx[31]*(Q_021001000*PR_010000012000+Q_021101000*PR_010000012010+Q_121001000*PR_010000012100+Q_121101000*PR_010000012110+Q_221001000*PR_010000012200+Q_221101000*PR_010000012210+Q_321001000*PR_010000012300+Q_321101000*PR_010000012310); ans_temp[ans_id*36+18]+=Pmtrx[32]*(Q_020002000*PR_010000012000+Q_020102000*PR_010000012010+Q_020202000*PR_010000012020+Q_120002000*PR_010000012100+Q_120102000*PR_010000012110+Q_120202000*PR_010000012120+Q_220002000*PR_010000012200+Q_220102000*PR_010000012210+Q_220202000*PR_010000012220); ans_temp[ans_id*36+18]+=Pmtrx[33]*(Q_021000001*PR_010000012000+Q_021000101*PR_010000012001+Q_121000001*PR_010000012100+Q_121000101*PR_010000012101+Q_221000001*PR_010000012200+Q_221000101*PR_010000012201+Q_321000001*PR_010000012300+Q_321000101*PR_010000012301); ans_temp[ans_id*36+18]+=Pmtrx[34]*(Q_020001001*PR_010000012000+Q_020001101*PR_010000012001+Q_020101001*PR_010000012010+Q_020101101*PR_010000012011+Q_120001001*PR_010000012100+Q_120001101*PR_010000012101+Q_120101001*PR_010000012110+Q_120101101*PR_010000012111+Q_220001001*PR_010000012200+Q_220001101*PR_010000012201+Q_220101001*PR_010000012210+Q_220101101*PR_010000012211); ans_temp[ans_id*36+18]+=Pmtrx[35]*(Q_020000002*PR_010000012000+Q_020000102*PR_010000012001+Q_020000202*PR_010000012002+Q_120000002*PR_010000012100+Q_120000102*PR_010000012101+Q_120000202*PR_010000012102+Q_220000002*PR_010000012200+Q_220000102*PR_010000012201+Q_220000202*PR_010000012202); ans_temp[ans_id*36+19]+=Pmtrx[30]*(Q_012010000*PR_010000012000+Q_012110000*PR_010000012010+Q_112010000*PR_010000012100+Q_112110000*PR_010000012110+Q_212010000*PR_010000012200+Q_212110000*PR_010000012210+Q_312010000*PR_010000012300+Q_312110000*PR_010000012310); ans_temp[ans_id*36+19]+=Pmtrx[31]*(Q_011011000*PR_010000012000+Q_011111000*PR_010000012010+Q_011211000*PR_010000012020+Q_111011000*PR_010000012100+Q_111111000*PR_010000012110+Q_111211000*PR_010000012120+Q_211011000*PR_010000012200+Q_211111000*PR_010000012210+Q_211211000*PR_010000012220); ans_temp[ans_id*36+19]+=Pmtrx[32]*(Q_010012000*PR_010000012000+Q_010112000*PR_010000012010+Q_010212000*PR_010000012020+Q_010312000*PR_010000012030+Q_110012000*PR_010000012100+Q_110112000*PR_010000012110+Q_110212000*PR_010000012120+Q_110312000*PR_010000012130); ans_temp[ans_id*36+19]+=Pmtrx[33]*(Q_011010001*PR_010000012000+Q_011010101*PR_010000012001+Q_011110001*PR_010000012010+Q_011110101*PR_010000012011+Q_111010001*PR_010000012100+Q_111010101*PR_010000012101+Q_111110001*PR_010000012110+Q_111110101*PR_010000012111+Q_211010001*PR_010000012200+Q_211010101*PR_010000012201+Q_211110001*PR_010000012210+Q_211110101*PR_010000012211); ans_temp[ans_id*36+19]+=Pmtrx[34]*(Q_010011001*PR_010000012000+Q_010011101*PR_010000012001+Q_010111001*PR_010000012010+Q_010111101*PR_010000012011+Q_010211001*PR_010000012020+Q_010211101*PR_010000012021+Q_110011001*PR_010000012100+Q_110011101*PR_010000012101+Q_110111001*PR_010000012110+Q_110111101*PR_010000012111+Q_110211001*PR_010000012120+Q_110211101*PR_010000012121); ans_temp[ans_id*36+19]+=Pmtrx[35]*(Q_010010002*PR_010000012000+Q_010010102*PR_010000012001+Q_010010202*PR_010000012002+Q_010110002*PR_010000012010+Q_010110102*PR_010000012011+Q_010110202*PR_010000012012+Q_110010002*PR_010000012100+Q_110010102*PR_010000012101+Q_110010202*PR_010000012102+Q_110110002*PR_010000012110+Q_110110102*PR_010000012111+Q_110110202*PR_010000012112); ans_temp[ans_id*36+20]+=Pmtrx[30]*(Q_002020000*PR_010000012000+Q_002120000*PR_010000012010+Q_002220000*PR_010000012020+Q_102020000*PR_010000012100+Q_102120000*PR_010000012110+Q_102220000*PR_010000012120+Q_202020000*PR_010000012200+Q_202120000*PR_010000012210+Q_202220000*PR_010000012220); ans_temp[ans_id*36+20]+=Pmtrx[31]*(Q_001021000*PR_010000012000+Q_001121000*PR_010000012010+Q_001221000*PR_010000012020+Q_001321000*PR_010000012030+Q_101021000*PR_010000012100+Q_101121000*PR_010000012110+Q_101221000*PR_010000012120+Q_101321000*PR_010000012130); ans_temp[ans_id*36+20]+=Pmtrx[32]*(Q_000022000*PR_010000012000+Q_000122000*PR_010000012010+Q_000222000*PR_010000012020+Q_000322000*PR_010000012030+Q_000422000*PR_010000012040); ans_temp[ans_id*36+20]+=Pmtrx[33]*(Q_001020001*PR_010000012000+Q_001020101*PR_010000012001+Q_001120001*PR_010000012010+Q_001120101*PR_010000012011+Q_001220001*PR_010000012020+Q_001220101*PR_010000012021+Q_101020001*PR_010000012100+Q_101020101*PR_010000012101+Q_101120001*PR_010000012110+Q_101120101*PR_010000012111+Q_101220001*PR_010000012120+Q_101220101*PR_010000012121); ans_temp[ans_id*36+20]+=Pmtrx[34]*(Q_000021001*PR_010000012000+Q_000021101*PR_010000012001+Q_000121001*PR_010000012010+Q_000121101*PR_010000012011+Q_000221001*PR_010000012020+Q_000221101*PR_010000012021+Q_000321001*PR_010000012030+Q_000321101*PR_010000012031); ans_temp[ans_id*36+20]+=Pmtrx[35]*(Q_000020002*PR_010000012000+Q_000020102*PR_010000012001+Q_000020202*PR_010000012002+Q_000120002*PR_010000012010+Q_000120102*PR_010000012011+Q_000120202*PR_010000012012+Q_000220002*PR_010000012020+Q_000220102*PR_010000012021+Q_000220202*PR_010000012022); ans_temp[ans_id*36+21]+=Pmtrx[30]*(Q_012000010*PR_010000012000+Q_012000110*PR_010000012001+Q_112000010*PR_010000012100+Q_112000110*PR_010000012101+Q_212000010*PR_010000012200+Q_212000110*PR_010000012201+Q_312000010*PR_010000012300+Q_312000110*PR_010000012301); ans_temp[ans_id*36+21]+=Pmtrx[31]*(Q_011001010*PR_010000012000+Q_011001110*PR_010000012001+Q_011101010*PR_010000012010+Q_011101110*PR_010000012011+Q_111001010*PR_010000012100+Q_111001110*PR_010000012101+Q_111101010*PR_010000012110+Q_111101110*PR_010000012111+Q_211001010*PR_010000012200+Q_211001110*PR_010000012201+Q_211101010*PR_010000012210+Q_211101110*PR_010000012211); ans_temp[ans_id*36+21]+=Pmtrx[32]*(Q_010002010*PR_010000012000+Q_010002110*PR_010000012001+Q_010102010*PR_010000012010+Q_010102110*PR_010000012011+Q_010202010*PR_010000012020+Q_010202110*PR_010000012021+Q_110002010*PR_010000012100+Q_110002110*PR_010000012101+Q_110102010*PR_010000012110+Q_110102110*PR_010000012111+Q_110202010*PR_010000012120+Q_110202110*PR_010000012121); ans_temp[ans_id*36+21]+=Pmtrx[33]*(Q_011000011*PR_010000012000+Q_011000111*PR_010000012001+Q_011000211*PR_010000012002+Q_111000011*PR_010000012100+Q_111000111*PR_010000012101+Q_111000211*PR_010000012102+Q_211000011*PR_010000012200+Q_211000111*PR_010000012201+Q_211000211*PR_010000012202); ans_temp[ans_id*36+21]+=Pmtrx[34]*(Q_010001011*PR_010000012000+Q_010001111*PR_010000012001+Q_010001211*PR_010000012002+Q_010101011*PR_010000012010+Q_010101111*PR_010000012011+Q_010101211*PR_010000012012+Q_110001011*PR_010000012100+Q_110001111*PR_010000012101+Q_110001211*PR_010000012102+Q_110101011*PR_010000012110+Q_110101111*PR_010000012111+Q_110101211*PR_010000012112); ans_temp[ans_id*36+21]+=Pmtrx[35]*(Q_010000012*PR_010000012000+Q_010000112*PR_010000012001+Q_010000212*PR_010000012002+Q_010000312*PR_010000012003+Q_110000012*PR_010000012100+Q_110000112*PR_010000012101+Q_110000212*PR_010000012102+Q_110000312*PR_010000012103); ans_temp[ans_id*36+22]+=Pmtrx[30]*(Q_002010010*PR_010000012000+Q_002010110*PR_010000012001+Q_002110010*PR_010000012010+Q_002110110*PR_010000012011+Q_102010010*PR_010000012100+Q_102010110*PR_010000012101+Q_102110010*PR_010000012110+Q_102110110*PR_010000012111+Q_202010010*PR_010000012200+Q_202010110*PR_010000012201+Q_202110010*PR_010000012210+Q_202110110*PR_010000012211); ans_temp[ans_id*36+22]+=Pmtrx[31]*(Q_001011010*PR_010000012000+Q_001011110*PR_010000012001+Q_001111010*PR_010000012010+Q_001111110*PR_010000012011+Q_001211010*PR_010000012020+Q_001211110*PR_010000012021+Q_101011010*PR_010000012100+Q_101011110*PR_010000012101+Q_101111010*PR_010000012110+Q_101111110*PR_010000012111+Q_101211010*PR_010000012120+Q_101211110*PR_010000012121); ans_temp[ans_id*36+22]+=Pmtrx[32]*(Q_000012010*PR_010000012000+Q_000012110*PR_010000012001+Q_000112010*PR_010000012010+Q_000112110*PR_010000012011+Q_000212010*PR_010000012020+Q_000212110*PR_010000012021+Q_000312010*PR_010000012030+Q_000312110*PR_010000012031); ans_temp[ans_id*36+22]+=Pmtrx[33]*(Q_001010011*PR_010000012000+Q_001010111*PR_010000012001+Q_001010211*PR_010000012002+Q_001110011*PR_010000012010+Q_001110111*PR_010000012011+Q_001110211*PR_010000012012+Q_101010011*PR_010000012100+Q_101010111*PR_010000012101+Q_101010211*PR_010000012102+Q_101110011*PR_010000012110+Q_101110111*PR_010000012111+Q_101110211*PR_010000012112); ans_temp[ans_id*36+22]+=Pmtrx[34]*(Q_000011011*PR_010000012000+Q_000011111*PR_010000012001+Q_000011211*PR_010000012002+Q_000111011*PR_010000012010+Q_000111111*PR_010000012011+Q_000111211*PR_010000012012+Q_000211011*PR_010000012020+Q_000211111*PR_010000012021+Q_000211211*PR_010000012022); ans_temp[ans_id*36+22]+=Pmtrx[35]*(Q_000010012*PR_010000012000+Q_000010112*PR_010000012001+Q_000010212*PR_010000012002+Q_000010312*PR_010000012003+Q_000110012*PR_010000012010+Q_000110112*PR_010000012011+Q_000110212*PR_010000012012+Q_000110312*PR_010000012013); ans_temp[ans_id*36+23]+=Pmtrx[30]*(Q_002000020*PR_010000012000+Q_002000120*PR_010000012001+Q_002000220*PR_010000012002+Q_102000020*PR_010000012100+Q_102000120*PR_010000012101+Q_102000220*PR_010000012102+Q_202000020*PR_010000012200+Q_202000120*PR_010000012201+Q_202000220*PR_010000012202); ans_temp[ans_id*36+23]+=Pmtrx[31]*(Q_001001020*PR_010000012000+Q_001001120*PR_010000012001+Q_001001220*PR_010000012002+Q_001101020*PR_010000012010+Q_001101120*PR_010000012011+Q_001101220*PR_010000012012+Q_101001020*PR_010000012100+Q_101001120*PR_010000012101+Q_101001220*PR_010000012102+Q_101101020*PR_010000012110+Q_101101120*PR_010000012111+Q_101101220*PR_010000012112); ans_temp[ans_id*36+23]+=Pmtrx[32]*(Q_000002020*PR_010000012000+Q_000002120*PR_010000012001+Q_000002220*PR_010000012002+Q_000102020*PR_010000012010+Q_000102120*PR_010000012011+Q_000102220*PR_010000012012+Q_000202020*PR_010000012020+Q_000202120*PR_010000012021+Q_000202220*PR_010000012022); ans_temp[ans_id*36+23]+=Pmtrx[33]*(Q_001000021*PR_010000012000+Q_001000121*PR_010000012001+Q_001000221*PR_010000012002+Q_001000321*PR_010000012003+Q_101000021*PR_010000012100+Q_101000121*PR_010000012101+Q_101000221*PR_010000012102+Q_101000321*PR_010000012103); ans_temp[ans_id*36+23]+=Pmtrx[34]*(Q_000001021*PR_010000012000+Q_000001121*PR_010000012001+Q_000001221*PR_010000012002+Q_000001321*PR_010000012003+Q_000101021*PR_010000012010+Q_000101121*PR_010000012011+Q_000101221*PR_010000012012+Q_000101321*PR_010000012013); ans_temp[ans_id*36+23]+=Pmtrx[35]*(Q_000000022*PR_010000012000+Q_000000122*PR_010000012001+Q_000000222*PR_010000012002+Q_000000322*PR_010000012003+Q_000000422*PR_010000012004); ans_temp[ans_id*36+24]+=Pmtrx[0]*(Q_022000000*PR_002010010000+Q_122000000*PR_002010010100+Q_222000000*PR_002010010200+Q_322000000*PR_002010010300+Q_422000000*PR_002010010400); ans_temp[ans_id*36+24]+=Pmtrx[1]*(Q_021001000*PR_002010010000+Q_021101000*PR_002010010010+Q_121001000*PR_002010010100+Q_121101000*PR_002010010110+Q_221001000*PR_002010010200+Q_221101000*PR_002010010210+Q_321001000*PR_002010010300+Q_321101000*PR_002010010310); ans_temp[ans_id*36+24]+=Pmtrx[2]*(Q_020002000*PR_002010010000+Q_020102000*PR_002010010010+Q_020202000*PR_002010010020+Q_120002000*PR_002010010100+Q_120102000*PR_002010010110+Q_120202000*PR_002010010120+Q_220002000*PR_002010010200+Q_220102000*PR_002010010210+Q_220202000*PR_002010010220); ans_temp[ans_id*36+24]+=Pmtrx[3]*(Q_021000001*PR_002010010000+Q_021000101*PR_002010010001+Q_121000001*PR_002010010100+Q_121000101*PR_002010010101+Q_221000001*PR_002010010200+Q_221000101*PR_002010010201+Q_321000001*PR_002010010300+Q_321000101*PR_002010010301); ans_temp[ans_id*36+24]+=Pmtrx[4]*(Q_020001001*PR_002010010000+Q_020001101*PR_002010010001+Q_020101001*PR_002010010010+Q_020101101*PR_002010010011+Q_120001001*PR_002010010100+Q_120001101*PR_002010010101+Q_120101001*PR_002010010110+Q_120101101*PR_002010010111+Q_220001001*PR_002010010200+Q_220001101*PR_002010010201+Q_220101001*PR_002010010210+Q_220101101*PR_002010010211); ans_temp[ans_id*36+24]+=Pmtrx[5]*(Q_020000002*PR_002010010000+Q_020000102*PR_002010010001+Q_020000202*PR_002010010002+Q_120000002*PR_002010010100+Q_120000102*PR_002010010101+Q_120000202*PR_002010010102+Q_220000002*PR_002010010200+Q_220000102*PR_002010010201+Q_220000202*PR_002010010202); ans_temp[ans_id*36+25]+=Pmtrx[0]*(Q_012010000*PR_002010010000+Q_012110000*PR_002010010010+Q_112010000*PR_002010010100+Q_112110000*PR_002010010110+Q_212010000*PR_002010010200+Q_212110000*PR_002010010210+Q_312010000*PR_002010010300+Q_312110000*PR_002010010310); ans_temp[ans_id*36+25]+=Pmtrx[1]*(Q_011011000*PR_002010010000+Q_011111000*PR_002010010010+Q_011211000*PR_002010010020+Q_111011000*PR_002010010100+Q_111111000*PR_002010010110+Q_111211000*PR_002010010120+Q_211011000*PR_002010010200+Q_211111000*PR_002010010210+Q_211211000*PR_002010010220); ans_temp[ans_id*36+25]+=Pmtrx[2]*(Q_010012000*PR_002010010000+Q_010112000*PR_002010010010+Q_010212000*PR_002010010020+Q_010312000*PR_002010010030+Q_110012000*PR_002010010100+Q_110112000*PR_002010010110+Q_110212000*PR_002010010120+Q_110312000*PR_002010010130); ans_temp[ans_id*36+25]+=Pmtrx[3]*(Q_011010001*PR_002010010000+Q_011010101*PR_002010010001+Q_011110001*PR_002010010010+Q_011110101*PR_002010010011+Q_111010001*PR_002010010100+Q_111010101*PR_002010010101+Q_111110001*PR_002010010110+Q_111110101*PR_002010010111+Q_211010001*PR_002010010200+Q_211010101*PR_002010010201+Q_211110001*PR_002010010210+Q_211110101*PR_002010010211); ans_temp[ans_id*36+25]+=Pmtrx[4]*(Q_010011001*PR_002010010000+Q_010011101*PR_002010010001+Q_010111001*PR_002010010010+Q_010111101*PR_002010010011+Q_010211001*PR_002010010020+Q_010211101*PR_002010010021+Q_110011001*PR_002010010100+Q_110011101*PR_002010010101+Q_110111001*PR_002010010110+Q_110111101*PR_002010010111+Q_110211001*PR_002010010120+Q_110211101*PR_002010010121); ans_temp[ans_id*36+25]+=Pmtrx[5]*(Q_010010002*PR_002010010000+Q_010010102*PR_002010010001+Q_010010202*PR_002010010002+Q_010110002*PR_002010010010+Q_010110102*PR_002010010011+Q_010110202*PR_002010010012+Q_110010002*PR_002010010100+Q_110010102*PR_002010010101+Q_110010202*PR_002010010102+Q_110110002*PR_002010010110+Q_110110102*PR_002010010111+Q_110110202*PR_002010010112); ans_temp[ans_id*36+26]+=Pmtrx[0]*(Q_002020000*PR_002010010000+Q_002120000*PR_002010010010+Q_002220000*PR_002010010020+Q_102020000*PR_002010010100+Q_102120000*PR_002010010110+Q_102220000*PR_002010010120+Q_202020000*PR_002010010200+Q_202120000*PR_002010010210+Q_202220000*PR_002010010220); ans_temp[ans_id*36+26]+=Pmtrx[1]*(Q_001021000*PR_002010010000+Q_001121000*PR_002010010010+Q_001221000*PR_002010010020+Q_001321000*PR_002010010030+Q_101021000*PR_002010010100+Q_101121000*PR_002010010110+Q_101221000*PR_002010010120+Q_101321000*PR_002010010130); ans_temp[ans_id*36+26]+=Pmtrx[2]*(Q_000022000*PR_002010010000+Q_000122000*PR_002010010010+Q_000222000*PR_002010010020+Q_000322000*PR_002010010030+Q_000422000*PR_002010010040); ans_temp[ans_id*36+26]+=Pmtrx[3]*(Q_001020001*PR_002010010000+Q_001020101*PR_002010010001+Q_001120001*PR_002010010010+Q_001120101*PR_002010010011+Q_001220001*PR_002010010020+Q_001220101*PR_002010010021+Q_101020001*PR_002010010100+Q_101020101*PR_002010010101+Q_101120001*PR_002010010110+Q_101120101*PR_002010010111+Q_101220001*PR_002010010120+Q_101220101*PR_002010010121); ans_temp[ans_id*36+26]+=Pmtrx[4]*(Q_000021001*PR_002010010000+Q_000021101*PR_002010010001+Q_000121001*PR_002010010010+Q_000121101*PR_002010010011+Q_000221001*PR_002010010020+Q_000221101*PR_002010010021+Q_000321001*PR_002010010030+Q_000321101*PR_002010010031); ans_temp[ans_id*36+26]+=Pmtrx[5]*(Q_000020002*PR_002010010000+Q_000020102*PR_002010010001+Q_000020202*PR_002010010002+Q_000120002*PR_002010010010+Q_000120102*PR_002010010011+Q_000120202*PR_002010010012+Q_000220002*PR_002010010020+Q_000220102*PR_002010010021+Q_000220202*PR_002010010022); ans_temp[ans_id*36+27]+=Pmtrx[0]*(Q_012000010*PR_002010010000+Q_012000110*PR_002010010001+Q_112000010*PR_002010010100+Q_112000110*PR_002010010101+Q_212000010*PR_002010010200+Q_212000110*PR_002010010201+Q_312000010*PR_002010010300+Q_312000110*PR_002010010301); ans_temp[ans_id*36+27]+=Pmtrx[1]*(Q_011001010*PR_002010010000+Q_011001110*PR_002010010001+Q_011101010*PR_002010010010+Q_011101110*PR_002010010011+Q_111001010*PR_002010010100+Q_111001110*PR_002010010101+Q_111101010*PR_002010010110+Q_111101110*PR_002010010111+Q_211001010*PR_002010010200+Q_211001110*PR_002010010201+Q_211101010*PR_002010010210+Q_211101110*PR_002010010211); ans_temp[ans_id*36+27]+=Pmtrx[2]*(Q_010002010*PR_002010010000+Q_010002110*PR_002010010001+Q_010102010*PR_002010010010+Q_010102110*PR_002010010011+Q_010202010*PR_002010010020+Q_010202110*PR_002010010021+Q_110002010*PR_002010010100+Q_110002110*PR_002010010101+Q_110102010*PR_002010010110+Q_110102110*PR_002010010111+Q_110202010*PR_002010010120+Q_110202110*PR_002010010121); ans_temp[ans_id*36+27]+=Pmtrx[3]*(Q_011000011*PR_002010010000+Q_011000111*PR_002010010001+Q_011000211*PR_002010010002+Q_111000011*PR_002010010100+Q_111000111*PR_002010010101+Q_111000211*PR_002010010102+Q_211000011*PR_002010010200+Q_211000111*PR_002010010201+Q_211000211*PR_002010010202); ans_temp[ans_id*36+27]+=Pmtrx[4]*(Q_010001011*PR_002010010000+Q_010001111*PR_002010010001+Q_010001211*PR_002010010002+Q_010101011*PR_002010010010+Q_010101111*PR_002010010011+Q_010101211*PR_002010010012+Q_110001011*PR_002010010100+Q_110001111*PR_002010010101+Q_110001211*PR_002010010102+Q_110101011*PR_002010010110+Q_110101111*PR_002010010111+Q_110101211*PR_002010010112); ans_temp[ans_id*36+27]+=Pmtrx[5]*(Q_010000012*PR_002010010000+Q_010000112*PR_002010010001+Q_010000212*PR_002010010002+Q_010000312*PR_002010010003+Q_110000012*PR_002010010100+Q_110000112*PR_002010010101+Q_110000212*PR_002010010102+Q_110000312*PR_002010010103); ans_temp[ans_id*36+28]+=Pmtrx[0]*(Q_002010010*PR_002010010000+Q_002010110*PR_002010010001+Q_002110010*PR_002010010010+Q_002110110*PR_002010010011+Q_102010010*PR_002010010100+Q_102010110*PR_002010010101+Q_102110010*PR_002010010110+Q_102110110*PR_002010010111+Q_202010010*PR_002010010200+Q_202010110*PR_002010010201+Q_202110010*PR_002010010210+Q_202110110*PR_002010010211); ans_temp[ans_id*36+28]+=Pmtrx[1]*(Q_001011010*PR_002010010000+Q_001011110*PR_002010010001+Q_001111010*PR_002010010010+Q_001111110*PR_002010010011+Q_001211010*PR_002010010020+Q_001211110*PR_002010010021+Q_101011010*PR_002010010100+Q_101011110*PR_002010010101+Q_101111010*PR_002010010110+Q_101111110*PR_002010010111+Q_101211010*PR_002010010120+Q_101211110*PR_002010010121); ans_temp[ans_id*36+28]+=Pmtrx[2]*(Q_000012010*PR_002010010000+Q_000012110*PR_002010010001+Q_000112010*PR_002010010010+Q_000112110*PR_002010010011+Q_000212010*PR_002010010020+Q_000212110*PR_002010010021+Q_000312010*PR_002010010030+Q_000312110*PR_002010010031); ans_temp[ans_id*36+28]+=Pmtrx[3]*(Q_001010011*PR_002010010000+Q_001010111*PR_002010010001+Q_001010211*PR_002010010002+Q_001110011*PR_002010010010+Q_001110111*PR_002010010011+Q_001110211*PR_002010010012+Q_101010011*PR_002010010100+Q_101010111*PR_002010010101+Q_101010211*PR_002010010102+Q_101110011*PR_002010010110+Q_101110111*PR_002010010111+Q_101110211*PR_002010010112); ans_temp[ans_id*36+28]+=Pmtrx[4]*(Q_000011011*PR_002010010000+Q_000011111*PR_002010010001+Q_000011211*PR_002010010002+Q_000111011*PR_002010010010+Q_000111111*PR_002010010011+Q_000111211*PR_002010010012+Q_000211011*PR_002010010020+Q_000211111*PR_002010010021+Q_000211211*PR_002010010022); ans_temp[ans_id*36+28]+=Pmtrx[5]*(Q_000010012*PR_002010010000+Q_000010112*PR_002010010001+Q_000010212*PR_002010010002+Q_000010312*PR_002010010003+Q_000110012*PR_002010010010+Q_000110112*PR_002010010011+Q_000110212*PR_002010010012+Q_000110312*PR_002010010013); ans_temp[ans_id*36+29]+=Pmtrx[0]*(Q_002000020*PR_002010010000+Q_002000120*PR_002010010001+Q_002000220*PR_002010010002+Q_102000020*PR_002010010100+Q_102000120*PR_002010010101+Q_102000220*PR_002010010102+Q_202000020*PR_002010010200+Q_202000120*PR_002010010201+Q_202000220*PR_002010010202); ans_temp[ans_id*36+29]+=Pmtrx[1]*(Q_001001020*PR_002010010000+Q_001001120*PR_002010010001+Q_001001220*PR_002010010002+Q_001101020*PR_002010010010+Q_001101120*PR_002010010011+Q_001101220*PR_002010010012+Q_101001020*PR_002010010100+Q_101001120*PR_002010010101+Q_101001220*PR_002010010102+Q_101101020*PR_002010010110+Q_101101120*PR_002010010111+Q_101101220*PR_002010010112); ans_temp[ans_id*36+29]+=Pmtrx[2]*(Q_000002020*PR_002010010000+Q_000002120*PR_002010010001+Q_000002220*PR_002010010002+Q_000102020*PR_002010010010+Q_000102120*PR_002010010011+Q_000102220*PR_002010010012+Q_000202020*PR_002010010020+Q_000202120*PR_002010010021+Q_000202220*PR_002010010022); ans_temp[ans_id*36+29]+=Pmtrx[3]*(Q_001000021*PR_002010010000+Q_001000121*PR_002010010001+Q_001000221*PR_002010010002+Q_001000321*PR_002010010003+Q_101000021*PR_002010010100+Q_101000121*PR_002010010101+Q_101000221*PR_002010010102+Q_101000321*PR_002010010103); ans_temp[ans_id*36+29]+=Pmtrx[4]*(Q_000001021*PR_002010010000+Q_000001121*PR_002010010001+Q_000001221*PR_002010010002+Q_000001321*PR_002010010003+Q_000101021*PR_002010010010+Q_000101121*PR_002010010011+Q_000101221*PR_002010010012+Q_000101321*PR_002010010013); ans_temp[ans_id*36+29]+=Pmtrx[5]*(Q_000000022*PR_002010010000+Q_000000122*PR_002010010001+Q_000000222*PR_002010010002+Q_000000322*PR_002010010003+Q_000000422*PR_002010010004); ans_temp[ans_id*36+24]+=Pmtrx[6]*(Q_022000000*PR_001011010000+Q_122000000*PR_001011010100+Q_222000000*PR_001011010200+Q_322000000*PR_001011010300+Q_422000000*PR_001011010400); ans_temp[ans_id*36+24]+=Pmtrx[7]*(Q_021001000*PR_001011010000+Q_021101000*PR_001011010010+Q_121001000*PR_001011010100+Q_121101000*PR_001011010110+Q_221001000*PR_001011010200+Q_221101000*PR_001011010210+Q_321001000*PR_001011010300+Q_321101000*PR_001011010310); ans_temp[ans_id*36+24]+=Pmtrx[8]*(Q_020002000*PR_001011010000+Q_020102000*PR_001011010010+Q_020202000*PR_001011010020+Q_120002000*PR_001011010100+Q_120102000*PR_001011010110+Q_120202000*PR_001011010120+Q_220002000*PR_001011010200+Q_220102000*PR_001011010210+Q_220202000*PR_001011010220); ans_temp[ans_id*36+24]+=Pmtrx[9]*(Q_021000001*PR_001011010000+Q_021000101*PR_001011010001+Q_121000001*PR_001011010100+Q_121000101*PR_001011010101+Q_221000001*PR_001011010200+Q_221000101*PR_001011010201+Q_321000001*PR_001011010300+Q_321000101*PR_001011010301); ans_temp[ans_id*36+24]+=Pmtrx[10]*(Q_020001001*PR_001011010000+Q_020001101*PR_001011010001+Q_020101001*PR_001011010010+Q_020101101*PR_001011010011+Q_120001001*PR_001011010100+Q_120001101*PR_001011010101+Q_120101001*PR_001011010110+Q_120101101*PR_001011010111+Q_220001001*PR_001011010200+Q_220001101*PR_001011010201+Q_220101001*PR_001011010210+Q_220101101*PR_001011010211); ans_temp[ans_id*36+24]+=Pmtrx[11]*(Q_020000002*PR_001011010000+Q_020000102*PR_001011010001+Q_020000202*PR_001011010002+Q_120000002*PR_001011010100+Q_120000102*PR_001011010101+Q_120000202*PR_001011010102+Q_220000002*PR_001011010200+Q_220000102*PR_001011010201+Q_220000202*PR_001011010202); ans_temp[ans_id*36+25]+=Pmtrx[6]*(Q_012010000*PR_001011010000+Q_012110000*PR_001011010010+Q_112010000*PR_001011010100+Q_112110000*PR_001011010110+Q_212010000*PR_001011010200+Q_212110000*PR_001011010210+Q_312010000*PR_001011010300+Q_312110000*PR_001011010310); ans_temp[ans_id*36+25]+=Pmtrx[7]*(Q_011011000*PR_001011010000+Q_011111000*PR_001011010010+Q_011211000*PR_001011010020+Q_111011000*PR_001011010100+Q_111111000*PR_001011010110+Q_111211000*PR_001011010120+Q_211011000*PR_001011010200+Q_211111000*PR_001011010210+Q_211211000*PR_001011010220); ans_temp[ans_id*36+25]+=Pmtrx[8]*(Q_010012000*PR_001011010000+Q_010112000*PR_001011010010+Q_010212000*PR_001011010020+Q_010312000*PR_001011010030+Q_110012000*PR_001011010100+Q_110112000*PR_001011010110+Q_110212000*PR_001011010120+Q_110312000*PR_001011010130); ans_temp[ans_id*36+25]+=Pmtrx[9]*(Q_011010001*PR_001011010000+Q_011010101*PR_001011010001+Q_011110001*PR_001011010010+Q_011110101*PR_001011010011+Q_111010001*PR_001011010100+Q_111010101*PR_001011010101+Q_111110001*PR_001011010110+Q_111110101*PR_001011010111+Q_211010001*PR_001011010200+Q_211010101*PR_001011010201+Q_211110001*PR_001011010210+Q_211110101*PR_001011010211); ans_temp[ans_id*36+25]+=Pmtrx[10]*(Q_010011001*PR_001011010000+Q_010011101*PR_001011010001+Q_010111001*PR_001011010010+Q_010111101*PR_001011010011+Q_010211001*PR_001011010020+Q_010211101*PR_001011010021+Q_110011001*PR_001011010100+Q_110011101*PR_001011010101+Q_110111001*PR_001011010110+Q_110111101*PR_001011010111+Q_110211001*PR_001011010120+Q_110211101*PR_001011010121); ans_temp[ans_id*36+25]+=Pmtrx[11]*(Q_010010002*PR_001011010000+Q_010010102*PR_001011010001+Q_010010202*PR_001011010002+Q_010110002*PR_001011010010+Q_010110102*PR_001011010011+Q_010110202*PR_001011010012+Q_110010002*PR_001011010100+Q_110010102*PR_001011010101+Q_110010202*PR_001011010102+Q_110110002*PR_001011010110+Q_110110102*PR_001011010111+Q_110110202*PR_001011010112); ans_temp[ans_id*36+26]+=Pmtrx[6]*(Q_002020000*PR_001011010000+Q_002120000*PR_001011010010+Q_002220000*PR_001011010020+Q_102020000*PR_001011010100+Q_102120000*PR_001011010110+Q_102220000*PR_001011010120+Q_202020000*PR_001011010200+Q_202120000*PR_001011010210+Q_202220000*PR_001011010220); ans_temp[ans_id*36+26]+=Pmtrx[7]*(Q_001021000*PR_001011010000+Q_001121000*PR_001011010010+Q_001221000*PR_001011010020+Q_001321000*PR_001011010030+Q_101021000*PR_001011010100+Q_101121000*PR_001011010110+Q_101221000*PR_001011010120+Q_101321000*PR_001011010130); ans_temp[ans_id*36+26]+=Pmtrx[8]*(Q_000022000*PR_001011010000+Q_000122000*PR_001011010010+Q_000222000*PR_001011010020+Q_000322000*PR_001011010030+Q_000422000*PR_001011010040); ans_temp[ans_id*36+26]+=Pmtrx[9]*(Q_001020001*PR_001011010000+Q_001020101*PR_001011010001+Q_001120001*PR_001011010010+Q_001120101*PR_001011010011+Q_001220001*PR_001011010020+Q_001220101*PR_001011010021+Q_101020001*PR_001011010100+Q_101020101*PR_001011010101+Q_101120001*PR_001011010110+Q_101120101*PR_001011010111+Q_101220001*PR_001011010120+Q_101220101*PR_001011010121); ans_temp[ans_id*36+26]+=Pmtrx[10]*(Q_000021001*PR_001011010000+Q_000021101*PR_001011010001+Q_000121001*PR_001011010010+Q_000121101*PR_001011010011+Q_000221001*PR_001011010020+Q_000221101*PR_001011010021+Q_000321001*PR_001011010030+Q_000321101*PR_001011010031); ans_temp[ans_id*36+26]+=Pmtrx[11]*(Q_000020002*PR_001011010000+Q_000020102*PR_001011010001+Q_000020202*PR_001011010002+Q_000120002*PR_001011010010+Q_000120102*PR_001011010011+Q_000120202*PR_001011010012+Q_000220002*PR_001011010020+Q_000220102*PR_001011010021+Q_000220202*PR_001011010022); ans_temp[ans_id*36+27]+=Pmtrx[6]*(Q_012000010*PR_001011010000+Q_012000110*PR_001011010001+Q_112000010*PR_001011010100+Q_112000110*PR_001011010101+Q_212000010*PR_001011010200+Q_212000110*PR_001011010201+Q_312000010*PR_001011010300+Q_312000110*PR_001011010301); ans_temp[ans_id*36+27]+=Pmtrx[7]*(Q_011001010*PR_001011010000+Q_011001110*PR_001011010001+Q_011101010*PR_001011010010+Q_011101110*PR_001011010011+Q_111001010*PR_001011010100+Q_111001110*PR_001011010101+Q_111101010*PR_001011010110+Q_111101110*PR_001011010111+Q_211001010*PR_001011010200+Q_211001110*PR_001011010201+Q_211101010*PR_001011010210+Q_211101110*PR_001011010211); ans_temp[ans_id*36+27]+=Pmtrx[8]*(Q_010002010*PR_001011010000+Q_010002110*PR_001011010001+Q_010102010*PR_001011010010+Q_010102110*PR_001011010011+Q_010202010*PR_001011010020+Q_010202110*PR_001011010021+Q_110002010*PR_001011010100+Q_110002110*PR_001011010101+Q_110102010*PR_001011010110+Q_110102110*PR_001011010111+Q_110202010*PR_001011010120+Q_110202110*PR_001011010121); ans_temp[ans_id*36+27]+=Pmtrx[9]*(Q_011000011*PR_001011010000+Q_011000111*PR_001011010001+Q_011000211*PR_001011010002+Q_111000011*PR_001011010100+Q_111000111*PR_001011010101+Q_111000211*PR_001011010102+Q_211000011*PR_001011010200+Q_211000111*PR_001011010201+Q_211000211*PR_001011010202); ans_temp[ans_id*36+27]+=Pmtrx[10]*(Q_010001011*PR_001011010000+Q_010001111*PR_001011010001+Q_010001211*PR_001011010002+Q_010101011*PR_001011010010+Q_010101111*PR_001011010011+Q_010101211*PR_001011010012+Q_110001011*PR_001011010100+Q_110001111*PR_001011010101+Q_110001211*PR_001011010102+Q_110101011*PR_001011010110+Q_110101111*PR_001011010111+Q_110101211*PR_001011010112); ans_temp[ans_id*36+27]+=Pmtrx[11]*(Q_010000012*PR_001011010000+Q_010000112*PR_001011010001+Q_010000212*PR_001011010002+Q_010000312*PR_001011010003+Q_110000012*PR_001011010100+Q_110000112*PR_001011010101+Q_110000212*PR_001011010102+Q_110000312*PR_001011010103); ans_temp[ans_id*36+28]+=Pmtrx[6]*(Q_002010010*PR_001011010000+Q_002010110*PR_001011010001+Q_002110010*PR_001011010010+Q_002110110*PR_001011010011+Q_102010010*PR_001011010100+Q_102010110*PR_001011010101+Q_102110010*PR_001011010110+Q_102110110*PR_001011010111+Q_202010010*PR_001011010200+Q_202010110*PR_001011010201+Q_202110010*PR_001011010210+Q_202110110*PR_001011010211); ans_temp[ans_id*36+28]+=Pmtrx[7]*(Q_001011010*PR_001011010000+Q_001011110*PR_001011010001+Q_001111010*PR_001011010010+Q_001111110*PR_001011010011+Q_001211010*PR_001011010020+Q_001211110*PR_001011010021+Q_101011010*PR_001011010100+Q_101011110*PR_001011010101+Q_101111010*PR_001011010110+Q_101111110*PR_001011010111+Q_101211010*PR_001011010120+Q_101211110*PR_001011010121); ans_temp[ans_id*36+28]+=Pmtrx[8]*(Q_000012010*PR_001011010000+Q_000012110*PR_001011010001+Q_000112010*PR_001011010010+Q_000112110*PR_001011010011+Q_000212010*PR_001011010020+Q_000212110*PR_001011010021+Q_000312010*PR_001011010030+Q_000312110*PR_001011010031); ans_temp[ans_id*36+28]+=Pmtrx[9]*(Q_001010011*PR_001011010000+Q_001010111*PR_001011010001+Q_001010211*PR_001011010002+Q_001110011*PR_001011010010+Q_001110111*PR_001011010011+Q_001110211*PR_001011010012+Q_101010011*PR_001011010100+Q_101010111*PR_001011010101+Q_101010211*PR_001011010102+Q_101110011*PR_001011010110+Q_101110111*PR_001011010111+Q_101110211*PR_001011010112); ans_temp[ans_id*36+28]+=Pmtrx[10]*(Q_000011011*PR_001011010000+Q_000011111*PR_001011010001+Q_000011211*PR_001011010002+Q_000111011*PR_001011010010+Q_000111111*PR_001011010011+Q_000111211*PR_001011010012+Q_000211011*PR_001011010020+Q_000211111*PR_001011010021+Q_000211211*PR_001011010022); ans_temp[ans_id*36+28]+=Pmtrx[11]*(Q_000010012*PR_001011010000+Q_000010112*PR_001011010001+Q_000010212*PR_001011010002+Q_000010312*PR_001011010003+Q_000110012*PR_001011010010+Q_000110112*PR_001011010011+Q_000110212*PR_001011010012+Q_000110312*PR_001011010013); ans_temp[ans_id*36+29]+=Pmtrx[6]*(Q_002000020*PR_001011010000+Q_002000120*PR_001011010001+Q_002000220*PR_001011010002+Q_102000020*PR_001011010100+Q_102000120*PR_001011010101+Q_102000220*PR_001011010102+Q_202000020*PR_001011010200+Q_202000120*PR_001011010201+Q_202000220*PR_001011010202); ans_temp[ans_id*36+29]+=Pmtrx[7]*(Q_001001020*PR_001011010000+Q_001001120*PR_001011010001+Q_001001220*PR_001011010002+Q_001101020*PR_001011010010+Q_001101120*PR_001011010011+Q_001101220*PR_001011010012+Q_101001020*PR_001011010100+Q_101001120*PR_001011010101+Q_101001220*PR_001011010102+Q_101101020*PR_001011010110+Q_101101120*PR_001011010111+Q_101101220*PR_001011010112); ans_temp[ans_id*36+29]+=Pmtrx[8]*(Q_000002020*PR_001011010000+Q_000002120*PR_001011010001+Q_000002220*PR_001011010002+Q_000102020*PR_001011010010+Q_000102120*PR_001011010011+Q_000102220*PR_001011010012+Q_000202020*PR_001011010020+Q_000202120*PR_001011010021+Q_000202220*PR_001011010022); ans_temp[ans_id*36+29]+=Pmtrx[9]*(Q_001000021*PR_001011010000+Q_001000121*PR_001011010001+Q_001000221*PR_001011010002+Q_001000321*PR_001011010003+Q_101000021*PR_001011010100+Q_101000121*PR_001011010101+Q_101000221*PR_001011010102+Q_101000321*PR_001011010103); ans_temp[ans_id*36+29]+=Pmtrx[10]*(Q_000001021*PR_001011010000+Q_000001121*PR_001011010001+Q_000001221*PR_001011010002+Q_000001321*PR_001011010003+Q_000101021*PR_001011010010+Q_000101121*PR_001011010011+Q_000101221*PR_001011010012+Q_000101321*PR_001011010013); ans_temp[ans_id*36+29]+=Pmtrx[11]*(Q_000000022*PR_001011010000+Q_000000122*PR_001011010001+Q_000000222*PR_001011010002+Q_000000322*PR_001011010003+Q_000000422*PR_001011010004); ans_temp[ans_id*36+24]+=Pmtrx[12]*(Q_022000000*PR_000012010000+Q_122000000*PR_000012010100+Q_222000000*PR_000012010200+Q_322000000*PR_000012010300+Q_422000000*PR_000012010400); ans_temp[ans_id*36+24]+=Pmtrx[13]*(Q_021001000*PR_000012010000+Q_021101000*PR_000012010010+Q_121001000*PR_000012010100+Q_121101000*PR_000012010110+Q_221001000*PR_000012010200+Q_221101000*PR_000012010210+Q_321001000*PR_000012010300+Q_321101000*PR_000012010310); ans_temp[ans_id*36+24]+=Pmtrx[14]*(Q_020002000*PR_000012010000+Q_020102000*PR_000012010010+Q_020202000*PR_000012010020+Q_120002000*PR_000012010100+Q_120102000*PR_000012010110+Q_120202000*PR_000012010120+Q_220002000*PR_000012010200+Q_220102000*PR_000012010210+Q_220202000*PR_000012010220); ans_temp[ans_id*36+24]+=Pmtrx[15]*(Q_021000001*PR_000012010000+Q_021000101*PR_000012010001+Q_121000001*PR_000012010100+Q_121000101*PR_000012010101+Q_221000001*PR_000012010200+Q_221000101*PR_000012010201+Q_321000001*PR_000012010300+Q_321000101*PR_000012010301); ans_temp[ans_id*36+24]+=Pmtrx[16]*(Q_020001001*PR_000012010000+Q_020001101*PR_000012010001+Q_020101001*PR_000012010010+Q_020101101*PR_000012010011+Q_120001001*PR_000012010100+Q_120001101*PR_000012010101+Q_120101001*PR_000012010110+Q_120101101*PR_000012010111+Q_220001001*PR_000012010200+Q_220001101*PR_000012010201+Q_220101001*PR_000012010210+Q_220101101*PR_000012010211); ans_temp[ans_id*36+24]+=Pmtrx[17]*(Q_020000002*PR_000012010000+Q_020000102*PR_000012010001+Q_020000202*PR_000012010002+Q_120000002*PR_000012010100+Q_120000102*PR_000012010101+Q_120000202*PR_000012010102+Q_220000002*PR_000012010200+Q_220000102*PR_000012010201+Q_220000202*PR_000012010202); ans_temp[ans_id*36+25]+=Pmtrx[12]*(Q_012010000*PR_000012010000+Q_012110000*PR_000012010010+Q_112010000*PR_000012010100+Q_112110000*PR_000012010110+Q_212010000*PR_000012010200+Q_212110000*PR_000012010210+Q_312010000*PR_000012010300+Q_312110000*PR_000012010310); ans_temp[ans_id*36+25]+=Pmtrx[13]*(Q_011011000*PR_000012010000+Q_011111000*PR_000012010010+Q_011211000*PR_000012010020+Q_111011000*PR_000012010100+Q_111111000*PR_000012010110+Q_111211000*PR_000012010120+Q_211011000*PR_000012010200+Q_211111000*PR_000012010210+Q_211211000*PR_000012010220); ans_temp[ans_id*36+25]+=Pmtrx[14]*(Q_010012000*PR_000012010000+Q_010112000*PR_000012010010+Q_010212000*PR_000012010020+Q_010312000*PR_000012010030+Q_110012000*PR_000012010100+Q_110112000*PR_000012010110+Q_110212000*PR_000012010120+Q_110312000*PR_000012010130); ans_temp[ans_id*36+25]+=Pmtrx[15]*(Q_011010001*PR_000012010000+Q_011010101*PR_000012010001+Q_011110001*PR_000012010010+Q_011110101*PR_000012010011+Q_111010001*PR_000012010100+Q_111010101*PR_000012010101+Q_111110001*PR_000012010110+Q_111110101*PR_000012010111+Q_211010001*PR_000012010200+Q_211010101*PR_000012010201+Q_211110001*PR_000012010210+Q_211110101*PR_000012010211); ans_temp[ans_id*36+25]+=Pmtrx[16]*(Q_010011001*PR_000012010000+Q_010011101*PR_000012010001+Q_010111001*PR_000012010010+Q_010111101*PR_000012010011+Q_010211001*PR_000012010020+Q_010211101*PR_000012010021+Q_110011001*PR_000012010100+Q_110011101*PR_000012010101+Q_110111001*PR_000012010110+Q_110111101*PR_000012010111+Q_110211001*PR_000012010120+Q_110211101*PR_000012010121); ans_temp[ans_id*36+25]+=Pmtrx[17]*(Q_010010002*PR_000012010000+Q_010010102*PR_000012010001+Q_010010202*PR_000012010002+Q_010110002*PR_000012010010+Q_010110102*PR_000012010011+Q_010110202*PR_000012010012+Q_110010002*PR_000012010100+Q_110010102*PR_000012010101+Q_110010202*PR_000012010102+Q_110110002*PR_000012010110+Q_110110102*PR_000012010111+Q_110110202*PR_000012010112); ans_temp[ans_id*36+26]+=Pmtrx[12]*(Q_002020000*PR_000012010000+Q_002120000*PR_000012010010+Q_002220000*PR_000012010020+Q_102020000*PR_000012010100+Q_102120000*PR_000012010110+Q_102220000*PR_000012010120+Q_202020000*PR_000012010200+Q_202120000*PR_000012010210+Q_202220000*PR_000012010220); ans_temp[ans_id*36+26]+=Pmtrx[13]*(Q_001021000*PR_000012010000+Q_001121000*PR_000012010010+Q_001221000*PR_000012010020+Q_001321000*PR_000012010030+Q_101021000*PR_000012010100+Q_101121000*PR_000012010110+Q_101221000*PR_000012010120+Q_101321000*PR_000012010130); ans_temp[ans_id*36+26]+=Pmtrx[14]*(Q_000022000*PR_000012010000+Q_000122000*PR_000012010010+Q_000222000*PR_000012010020+Q_000322000*PR_000012010030+Q_000422000*PR_000012010040); ans_temp[ans_id*36+26]+=Pmtrx[15]*(Q_001020001*PR_000012010000+Q_001020101*PR_000012010001+Q_001120001*PR_000012010010+Q_001120101*PR_000012010011+Q_001220001*PR_000012010020+Q_001220101*PR_000012010021+Q_101020001*PR_000012010100+Q_101020101*PR_000012010101+Q_101120001*PR_000012010110+Q_101120101*PR_000012010111+Q_101220001*PR_000012010120+Q_101220101*PR_000012010121); ans_temp[ans_id*36+26]+=Pmtrx[16]*(Q_000021001*PR_000012010000+Q_000021101*PR_000012010001+Q_000121001*PR_000012010010+Q_000121101*PR_000012010011+Q_000221001*PR_000012010020+Q_000221101*PR_000012010021+Q_000321001*PR_000012010030+Q_000321101*PR_000012010031); ans_temp[ans_id*36+26]+=Pmtrx[17]*(Q_000020002*PR_000012010000+Q_000020102*PR_000012010001+Q_000020202*PR_000012010002+Q_000120002*PR_000012010010+Q_000120102*PR_000012010011+Q_000120202*PR_000012010012+Q_000220002*PR_000012010020+Q_000220102*PR_000012010021+Q_000220202*PR_000012010022); ans_temp[ans_id*36+27]+=Pmtrx[12]*(Q_012000010*PR_000012010000+Q_012000110*PR_000012010001+Q_112000010*PR_000012010100+Q_112000110*PR_000012010101+Q_212000010*PR_000012010200+Q_212000110*PR_000012010201+Q_312000010*PR_000012010300+Q_312000110*PR_000012010301); ans_temp[ans_id*36+27]+=Pmtrx[13]*(Q_011001010*PR_000012010000+Q_011001110*PR_000012010001+Q_011101010*PR_000012010010+Q_011101110*PR_000012010011+Q_111001010*PR_000012010100+Q_111001110*PR_000012010101+Q_111101010*PR_000012010110+Q_111101110*PR_000012010111+Q_211001010*PR_000012010200+Q_211001110*PR_000012010201+Q_211101010*PR_000012010210+Q_211101110*PR_000012010211); ans_temp[ans_id*36+27]+=Pmtrx[14]*(Q_010002010*PR_000012010000+Q_010002110*PR_000012010001+Q_010102010*PR_000012010010+Q_010102110*PR_000012010011+Q_010202010*PR_000012010020+Q_010202110*PR_000012010021+Q_110002010*PR_000012010100+Q_110002110*PR_000012010101+Q_110102010*PR_000012010110+Q_110102110*PR_000012010111+Q_110202010*PR_000012010120+Q_110202110*PR_000012010121); ans_temp[ans_id*36+27]+=Pmtrx[15]*(Q_011000011*PR_000012010000+Q_011000111*PR_000012010001+Q_011000211*PR_000012010002+Q_111000011*PR_000012010100+Q_111000111*PR_000012010101+Q_111000211*PR_000012010102+Q_211000011*PR_000012010200+Q_211000111*PR_000012010201+Q_211000211*PR_000012010202); ans_temp[ans_id*36+27]+=Pmtrx[16]*(Q_010001011*PR_000012010000+Q_010001111*PR_000012010001+Q_010001211*PR_000012010002+Q_010101011*PR_000012010010+Q_010101111*PR_000012010011+Q_010101211*PR_000012010012+Q_110001011*PR_000012010100+Q_110001111*PR_000012010101+Q_110001211*PR_000012010102+Q_110101011*PR_000012010110+Q_110101111*PR_000012010111+Q_110101211*PR_000012010112); ans_temp[ans_id*36+27]+=Pmtrx[17]*(Q_010000012*PR_000012010000+Q_010000112*PR_000012010001+Q_010000212*PR_000012010002+Q_010000312*PR_000012010003+Q_110000012*PR_000012010100+Q_110000112*PR_000012010101+Q_110000212*PR_000012010102+Q_110000312*PR_000012010103); ans_temp[ans_id*36+28]+=Pmtrx[12]*(Q_002010010*PR_000012010000+Q_002010110*PR_000012010001+Q_002110010*PR_000012010010+Q_002110110*PR_000012010011+Q_102010010*PR_000012010100+Q_102010110*PR_000012010101+Q_102110010*PR_000012010110+Q_102110110*PR_000012010111+Q_202010010*PR_000012010200+Q_202010110*PR_000012010201+Q_202110010*PR_000012010210+Q_202110110*PR_000012010211); ans_temp[ans_id*36+28]+=Pmtrx[13]*(Q_001011010*PR_000012010000+Q_001011110*PR_000012010001+Q_001111010*PR_000012010010+Q_001111110*PR_000012010011+Q_001211010*PR_000012010020+Q_001211110*PR_000012010021+Q_101011010*PR_000012010100+Q_101011110*PR_000012010101+Q_101111010*PR_000012010110+Q_101111110*PR_000012010111+Q_101211010*PR_000012010120+Q_101211110*PR_000012010121); ans_temp[ans_id*36+28]+=Pmtrx[14]*(Q_000012010*PR_000012010000+Q_000012110*PR_000012010001+Q_000112010*PR_000012010010+Q_000112110*PR_000012010011+Q_000212010*PR_000012010020+Q_000212110*PR_000012010021+Q_000312010*PR_000012010030+Q_000312110*PR_000012010031); ans_temp[ans_id*36+28]+=Pmtrx[15]*(Q_001010011*PR_000012010000+Q_001010111*PR_000012010001+Q_001010211*PR_000012010002+Q_001110011*PR_000012010010+Q_001110111*PR_000012010011+Q_001110211*PR_000012010012+Q_101010011*PR_000012010100+Q_101010111*PR_000012010101+Q_101010211*PR_000012010102+Q_101110011*PR_000012010110+Q_101110111*PR_000012010111+Q_101110211*PR_000012010112); ans_temp[ans_id*36+28]+=Pmtrx[16]*(Q_000011011*PR_000012010000+Q_000011111*PR_000012010001+Q_000011211*PR_000012010002+Q_000111011*PR_000012010010+Q_000111111*PR_000012010011+Q_000111211*PR_000012010012+Q_000211011*PR_000012010020+Q_000211111*PR_000012010021+Q_000211211*PR_000012010022); ans_temp[ans_id*36+28]+=Pmtrx[17]*(Q_000010012*PR_000012010000+Q_000010112*PR_000012010001+Q_000010212*PR_000012010002+Q_000010312*PR_000012010003+Q_000110012*PR_000012010010+Q_000110112*PR_000012010011+Q_000110212*PR_000012010012+Q_000110312*PR_000012010013); ans_temp[ans_id*36+29]+=Pmtrx[12]*(Q_002000020*PR_000012010000+Q_002000120*PR_000012010001+Q_002000220*PR_000012010002+Q_102000020*PR_000012010100+Q_102000120*PR_000012010101+Q_102000220*PR_000012010102+Q_202000020*PR_000012010200+Q_202000120*PR_000012010201+Q_202000220*PR_000012010202); ans_temp[ans_id*36+29]+=Pmtrx[13]*(Q_001001020*PR_000012010000+Q_001001120*PR_000012010001+Q_001001220*PR_000012010002+Q_001101020*PR_000012010010+Q_001101120*PR_000012010011+Q_001101220*PR_000012010012+Q_101001020*PR_000012010100+Q_101001120*PR_000012010101+Q_101001220*PR_000012010102+Q_101101020*PR_000012010110+Q_101101120*PR_000012010111+Q_101101220*PR_000012010112); ans_temp[ans_id*36+29]+=Pmtrx[14]*(Q_000002020*PR_000012010000+Q_000002120*PR_000012010001+Q_000002220*PR_000012010002+Q_000102020*PR_000012010010+Q_000102120*PR_000012010011+Q_000102220*PR_000012010012+Q_000202020*PR_000012010020+Q_000202120*PR_000012010021+Q_000202220*PR_000012010022); ans_temp[ans_id*36+29]+=Pmtrx[15]*(Q_001000021*PR_000012010000+Q_001000121*PR_000012010001+Q_001000221*PR_000012010002+Q_001000321*PR_000012010003+Q_101000021*PR_000012010100+Q_101000121*PR_000012010101+Q_101000221*PR_000012010102+Q_101000321*PR_000012010103); ans_temp[ans_id*36+29]+=Pmtrx[16]*(Q_000001021*PR_000012010000+Q_000001121*PR_000012010001+Q_000001221*PR_000012010002+Q_000001321*PR_000012010003+Q_000101021*PR_000012010010+Q_000101121*PR_000012010011+Q_000101221*PR_000012010012+Q_000101321*PR_000012010013); ans_temp[ans_id*36+29]+=Pmtrx[17]*(Q_000000022*PR_000012010000+Q_000000122*PR_000012010001+Q_000000222*PR_000012010002+Q_000000322*PR_000012010003+Q_000000422*PR_000012010004); ans_temp[ans_id*36+24]+=Pmtrx[18]*(Q_022000000*PR_001010011000+Q_122000000*PR_001010011100+Q_222000000*PR_001010011200+Q_322000000*PR_001010011300+Q_422000000*PR_001010011400); ans_temp[ans_id*36+24]+=Pmtrx[19]*(Q_021001000*PR_001010011000+Q_021101000*PR_001010011010+Q_121001000*PR_001010011100+Q_121101000*PR_001010011110+Q_221001000*PR_001010011200+Q_221101000*PR_001010011210+Q_321001000*PR_001010011300+Q_321101000*PR_001010011310); ans_temp[ans_id*36+24]+=Pmtrx[20]*(Q_020002000*PR_001010011000+Q_020102000*PR_001010011010+Q_020202000*PR_001010011020+Q_120002000*PR_001010011100+Q_120102000*PR_001010011110+Q_120202000*PR_001010011120+Q_220002000*PR_001010011200+Q_220102000*PR_001010011210+Q_220202000*PR_001010011220); ans_temp[ans_id*36+24]+=Pmtrx[21]*(Q_021000001*PR_001010011000+Q_021000101*PR_001010011001+Q_121000001*PR_001010011100+Q_121000101*PR_001010011101+Q_221000001*PR_001010011200+Q_221000101*PR_001010011201+Q_321000001*PR_001010011300+Q_321000101*PR_001010011301); ans_temp[ans_id*36+24]+=Pmtrx[22]*(Q_020001001*PR_001010011000+Q_020001101*PR_001010011001+Q_020101001*PR_001010011010+Q_020101101*PR_001010011011+Q_120001001*PR_001010011100+Q_120001101*PR_001010011101+Q_120101001*PR_001010011110+Q_120101101*PR_001010011111+Q_220001001*PR_001010011200+Q_220001101*PR_001010011201+Q_220101001*PR_001010011210+Q_220101101*PR_001010011211); ans_temp[ans_id*36+24]+=Pmtrx[23]*(Q_020000002*PR_001010011000+Q_020000102*PR_001010011001+Q_020000202*PR_001010011002+Q_120000002*PR_001010011100+Q_120000102*PR_001010011101+Q_120000202*PR_001010011102+Q_220000002*PR_001010011200+Q_220000102*PR_001010011201+Q_220000202*PR_001010011202); ans_temp[ans_id*36+25]+=Pmtrx[18]*(Q_012010000*PR_001010011000+Q_012110000*PR_001010011010+Q_112010000*PR_001010011100+Q_112110000*PR_001010011110+Q_212010000*PR_001010011200+Q_212110000*PR_001010011210+Q_312010000*PR_001010011300+Q_312110000*PR_001010011310); ans_temp[ans_id*36+25]+=Pmtrx[19]*(Q_011011000*PR_001010011000+Q_011111000*PR_001010011010+Q_011211000*PR_001010011020+Q_111011000*PR_001010011100+Q_111111000*PR_001010011110+Q_111211000*PR_001010011120+Q_211011000*PR_001010011200+Q_211111000*PR_001010011210+Q_211211000*PR_001010011220); ans_temp[ans_id*36+25]+=Pmtrx[20]*(Q_010012000*PR_001010011000+Q_010112000*PR_001010011010+Q_010212000*PR_001010011020+Q_010312000*PR_001010011030+Q_110012000*PR_001010011100+Q_110112000*PR_001010011110+Q_110212000*PR_001010011120+Q_110312000*PR_001010011130); ans_temp[ans_id*36+25]+=Pmtrx[21]*(Q_011010001*PR_001010011000+Q_011010101*PR_001010011001+Q_011110001*PR_001010011010+Q_011110101*PR_001010011011+Q_111010001*PR_001010011100+Q_111010101*PR_001010011101+Q_111110001*PR_001010011110+Q_111110101*PR_001010011111+Q_211010001*PR_001010011200+Q_211010101*PR_001010011201+Q_211110001*PR_001010011210+Q_211110101*PR_001010011211); ans_temp[ans_id*36+25]+=Pmtrx[22]*(Q_010011001*PR_001010011000+Q_010011101*PR_001010011001+Q_010111001*PR_001010011010+Q_010111101*PR_001010011011+Q_010211001*PR_001010011020+Q_010211101*PR_001010011021+Q_110011001*PR_001010011100+Q_110011101*PR_001010011101+Q_110111001*PR_001010011110+Q_110111101*PR_001010011111+Q_110211001*PR_001010011120+Q_110211101*PR_001010011121); ans_temp[ans_id*36+25]+=Pmtrx[23]*(Q_010010002*PR_001010011000+Q_010010102*PR_001010011001+Q_010010202*PR_001010011002+Q_010110002*PR_001010011010+Q_010110102*PR_001010011011+Q_010110202*PR_001010011012+Q_110010002*PR_001010011100+Q_110010102*PR_001010011101+Q_110010202*PR_001010011102+Q_110110002*PR_001010011110+Q_110110102*PR_001010011111+Q_110110202*PR_001010011112); ans_temp[ans_id*36+26]+=Pmtrx[18]*(Q_002020000*PR_001010011000+Q_002120000*PR_001010011010+Q_002220000*PR_001010011020+Q_102020000*PR_001010011100+Q_102120000*PR_001010011110+Q_102220000*PR_001010011120+Q_202020000*PR_001010011200+Q_202120000*PR_001010011210+Q_202220000*PR_001010011220); ans_temp[ans_id*36+26]+=Pmtrx[19]*(Q_001021000*PR_001010011000+Q_001121000*PR_001010011010+Q_001221000*PR_001010011020+Q_001321000*PR_001010011030+Q_101021000*PR_001010011100+Q_101121000*PR_001010011110+Q_101221000*PR_001010011120+Q_101321000*PR_001010011130); ans_temp[ans_id*36+26]+=Pmtrx[20]*(Q_000022000*PR_001010011000+Q_000122000*PR_001010011010+Q_000222000*PR_001010011020+Q_000322000*PR_001010011030+Q_000422000*PR_001010011040); ans_temp[ans_id*36+26]+=Pmtrx[21]*(Q_001020001*PR_001010011000+Q_001020101*PR_001010011001+Q_001120001*PR_001010011010+Q_001120101*PR_001010011011+Q_001220001*PR_001010011020+Q_001220101*PR_001010011021+Q_101020001*PR_001010011100+Q_101020101*PR_001010011101+Q_101120001*PR_001010011110+Q_101120101*PR_001010011111+Q_101220001*PR_001010011120+Q_101220101*PR_001010011121); ans_temp[ans_id*36+26]+=Pmtrx[22]*(Q_000021001*PR_001010011000+Q_000021101*PR_001010011001+Q_000121001*PR_001010011010+Q_000121101*PR_001010011011+Q_000221001*PR_001010011020+Q_000221101*PR_001010011021+Q_000321001*PR_001010011030+Q_000321101*PR_001010011031); ans_temp[ans_id*36+26]+=Pmtrx[23]*(Q_000020002*PR_001010011000+Q_000020102*PR_001010011001+Q_000020202*PR_001010011002+Q_000120002*PR_001010011010+Q_000120102*PR_001010011011+Q_000120202*PR_001010011012+Q_000220002*PR_001010011020+Q_000220102*PR_001010011021+Q_000220202*PR_001010011022); ans_temp[ans_id*36+27]+=Pmtrx[18]*(Q_012000010*PR_001010011000+Q_012000110*PR_001010011001+Q_112000010*PR_001010011100+Q_112000110*PR_001010011101+Q_212000010*PR_001010011200+Q_212000110*PR_001010011201+Q_312000010*PR_001010011300+Q_312000110*PR_001010011301); ans_temp[ans_id*36+27]+=Pmtrx[19]*(Q_011001010*PR_001010011000+Q_011001110*PR_001010011001+Q_011101010*PR_001010011010+Q_011101110*PR_001010011011+Q_111001010*PR_001010011100+Q_111001110*PR_001010011101+Q_111101010*PR_001010011110+Q_111101110*PR_001010011111+Q_211001010*PR_001010011200+Q_211001110*PR_001010011201+Q_211101010*PR_001010011210+Q_211101110*PR_001010011211); ans_temp[ans_id*36+27]+=Pmtrx[20]*(Q_010002010*PR_001010011000+Q_010002110*PR_001010011001+Q_010102010*PR_001010011010+Q_010102110*PR_001010011011+Q_010202010*PR_001010011020+Q_010202110*PR_001010011021+Q_110002010*PR_001010011100+Q_110002110*PR_001010011101+Q_110102010*PR_001010011110+Q_110102110*PR_001010011111+Q_110202010*PR_001010011120+Q_110202110*PR_001010011121); ans_temp[ans_id*36+27]+=Pmtrx[21]*(Q_011000011*PR_001010011000+Q_011000111*PR_001010011001+Q_011000211*PR_001010011002+Q_111000011*PR_001010011100+Q_111000111*PR_001010011101+Q_111000211*PR_001010011102+Q_211000011*PR_001010011200+Q_211000111*PR_001010011201+Q_211000211*PR_001010011202); ans_temp[ans_id*36+27]+=Pmtrx[22]*(Q_010001011*PR_001010011000+Q_010001111*PR_001010011001+Q_010001211*PR_001010011002+Q_010101011*PR_001010011010+Q_010101111*PR_001010011011+Q_010101211*PR_001010011012+Q_110001011*PR_001010011100+Q_110001111*PR_001010011101+Q_110001211*PR_001010011102+Q_110101011*PR_001010011110+Q_110101111*PR_001010011111+Q_110101211*PR_001010011112); ans_temp[ans_id*36+27]+=Pmtrx[23]*(Q_010000012*PR_001010011000+Q_010000112*PR_001010011001+Q_010000212*PR_001010011002+Q_010000312*PR_001010011003+Q_110000012*PR_001010011100+Q_110000112*PR_001010011101+Q_110000212*PR_001010011102+Q_110000312*PR_001010011103); ans_temp[ans_id*36+28]+=Pmtrx[18]*(Q_002010010*PR_001010011000+Q_002010110*PR_001010011001+Q_002110010*PR_001010011010+Q_002110110*PR_001010011011+Q_102010010*PR_001010011100+Q_102010110*PR_001010011101+Q_102110010*PR_001010011110+Q_102110110*PR_001010011111+Q_202010010*PR_001010011200+Q_202010110*PR_001010011201+Q_202110010*PR_001010011210+Q_202110110*PR_001010011211); ans_temp[ans_id*36+28]+=Pmtrx[19]*(Q_001011010*PR_001010011000+Q_001011110*PR_001010011001+Q_001111010*PR_001010011010+Q_001111110*PR_001010011011+Q_001211010*PR_001010011020+Q_001211110*PR_001010011021+Q_101011010*PR_001010011100+Q_101011110*PR_001010011101+Q_101111010*PR_001010011110+Q_101111110*PR_001010011111+Q_101211010*PR_001010011120+Q_101211110*PR_001010011121); ans_temp[ans_id*36+28]+=Pmtrx[20]*(Q_000012010*PR_001010011000+Q_000012110*PR_001010011001+Q_000112010*PR_001010011010+Q_000112110*PR_001010011011+Q_000212010*PR_001010011020+Q_000212110*PR_001010011021+Q_000312010*PR_001010011030+Q_000312110*PR_001010011031); ans_temp[ans_id*36+28]+=Pmtrx[21]*(Q_001010011*PR_001010011000+Q_001010111*PR_001010011001+Q_001010211*PR_001010011002+Q_001110011*PR_001010011010+Q_001110111*PR_001010011011+Q_001110211*PR_001010011012+Q_101010011*PR_001010011100+Q_101010111*PR_001010011101+Q_101010211*PR_001010011102+Q_101110011*PR_001010011110+Q_101110111*PR_001010011111+Q_101110211*PR_001010011112); ans_temp[ans_id*36+28]+=Pmtrx[22]*(Q_000011011*PR_001010011000+Q_000011111*PR_001010011001+Q_000011211*PR_001010011002+Q_000111011*PR_001010011010+Q_000111111*PR_001010011011+Q_000111211*PR_001010011012+Q_000211011*PR_001010011020+Q_000211111*PR_001010011021+Q_000211211*PR_001010011022); ans_temp[ans_id*36+28]+=Pmtrx[23]*(Q_000010012*PR_001010011000+Q_000010112*PR_001010011001+Q_000010212*PR_001010011002+Q_000010312*PR_001010011003+Q_000110012*PR_001010011010+Q_000110112*PR_001010011011+Q_000110212*PR_001010011012+Q_000110312*PR_001010011013); ans_temp[ans_id*36+29]+=Pmtrx[18]*(Q_002000020*PR_001010011000+Q_002000120*PR_001010011001+Q_002000220*PR_001010011002+Q_102000020*PR_001010011100+Q_102000120*PR_001010011101+Q_102000220*PR_001010011102+Q_202000020*PR_001010011200+Q_202000120*PR_001010011201+Q_202000220*PR_001010011202); ans_temp[ans_id*36+29]+=Pmtrx[19]*(Q_001001020*PR_001010011000+Q_001001120*PR_001010011001+Q_001001220*PR_001010011002+Q_001101020*PR_001010011010+Q_001101120*PR_001010011011+Q_001101220*PR_001010011012+Q_101001020*PR_001010011100+Q_101001120*PR_001010011101+Q_101001220*PR_001010011102+Q_101101020*PR_001010011110+Q_101101120*PR_001010011111+Q_101101220*PR_001010011112); ans_temp[ans_id*36+29]+=Pmtrx[20]*(Q_000002020*PR_001010011000+Q_000002120*PR_001010011001+Q_000002220*PR_001010011002+Q_000102020*PR_001010011010+Q_000102120*PR_001010011011+Q_000102220*PR_001010011012+Q_000202020*PR_001010011020+Q_000202120*PR_001010011021+Q_000202220*PR_001010011022); ans_temp[ans_id*36+29]+=Pmtrx[21]*(Q_001000021*PR_001010011000+Q_001000121*PR_001010011001+Q_001000221*PR_001010011002+Q_001000321*PR_001010011003+Q_101000021*PR_001010011100+Q_101000121*PR_001010011101+Q_101000221*PR_001010011102+Q_101000321*PR_001010011103); ans_temp[ans_id*36+29]+=Pmtrx[22]*(Q_000001021*PR_001010011000+Q_000001121*PR_001010011001+Q_000001221*PR_001010011002+Q_000001321*PR_001010011003+Q_000101021*PR_001010011010+Q_000101121*PR_001010011011+Q_000101221*PR_001010011012+Q_000101321*PR_001010011013); ans_temp[ans_id*36+29]+=Pmtrx[23]*(Q_000000022*PR_001010011000+Q_000000122*PR_001010011001+Q_000000222*PR_001010011002+Q_000000322*PR_001010011003+Q_000000422*PR_001010011004); ans_temp[ans_id*36+24]+=Pmtrx[24]*(Q_022000000*PR_000011011000+Q_122000000*PR_000011011100+Q_222000000*PR_000011011200+Q_322000000*PR_000011011300+Q_422000000*PR_000011011400); ans_temp[ans_id*36+24]+=Pmtrx[25]*(Q_021001000*PR_000011011000+Q_021101000*PR_000011011010+Q_121001000*PR_000011011100+Q_121101000*PR_000011011110+Q_221001000*PR_000011011200+Q_221101000*PR_000011011210+Q_321001000*PR_000011011300+Q_321101000*PR_000011011310); ans_temp[ans_id*36+24]+=Pmtrx[26]*(Q_020002000*PR_000011011000+Q_020102000*PR_000011011010+Q_020202000*PR_000011011020+Q_120002000*PR_000011011100+Q_120102000*PR_000011011110+Q_120202000*PR_000011011120+Q_220002000*PR_000011011200+Q_220102000*PR_000011011210+Q_220202000*PR_000011011220); ans_temp[ans_id*36+24]+=Pmtrx[27]*(Q_021000001*PR_000011011000+Q_021000101*PR_000011011001+Q_121000001*PR_000011011100+Q_121000101*PR_000011011101+Q_221000001*PR_000011011200+Q_221000101*PR_000011011201+Q_321000001*PR_000011011300+Q_321000101*PR_000011011301); ans_temp[ans_id*36+24]+=Pmtrx[28]*(Q_020001001*PR_000011011000+Q_020001101*PR_000011011001+Q_020101001*PR_000011011010+Q_020101101*PR_000011011011+Q_120001001*PR_000011011100+Q_120001101*PR_000011011101+Q_120101001*PR_000011011110+Q_120101101*PR_000011011111+Q_220001001*PR_000011011200+Q_220001101*PR_000011011201+Q_220101001*PR_000011011210+Q_220101101*PR_000011011211); ans_temp[ans_id*36+24]+=Pmtrx[29]*(Q_020000002*PR_000011011000+Q_020000102*PR_000011011001+Q_020000202*PR_000011011002+Q_120000002*PR_000011011100+Q_120000102*PR_000011011101+Q_120000202*PR_000011011102+Q_220000002*PR_000011011200+Q_220000102*PR_000011011201+Q_220000202*PR_000011011202); ans_temp[ans_id*36+25]+=Pmtrx[24]*(Q_012010000*PR_000011011000+Q_012110000*PR_000011011010+Q_112010000*PR_000011011100+Q_112110000*PR_000011011110+Q_212010000*PR_000011011200+Q_212110000*PR_000011011210+Q_312010000*PR_000011011300+Q_312110000*PR_000011011310); ans_temp[ans_id*36+25]+=Pmtrx[25]*(Q_011011000*PR_000011011000+Q_011111000*PR_000011011010+Q_011211000*PR_000011011020+Q_111011000*PR_000011011100+Q_111111000*PR_000011011110+Q_111211000*PR_000011011120+Q_211011000*PR_000011011200+Q_211111000*PR_000011011210+Q_211211000*PR_000011011220); ans_temp[ans_id*36+25]+=Pmtrx[26]*(Q_010012000*PR_000011011000+Q_010112000*PR_000011011010+Q_010212000*PR_000011011020+Q_010312000*PR_000011011030+Q_110012000*PR_000011011100+Q_110112000*PR_000011011110+Q_110212000*PR_000011011120+Q_110312000*PR_000011011130); ans_temp[ans_id*36+25]+=Pmtrx[27]*(Q_011010001*PR_000011011000+Q_011010101*PR_000011011001+Q_011110001*PR_000011011010+Q_011110101*PR_000011011011+Q_111010001*PR_000011011100+Q_111010101*PR_000011011101+Q_111110001*PR_000011011110+Q_111110101*PR_000011011111+Q_211010001*PR_000011011200+Q_211010101*PR_000011011201+Q_211110001*PR_000011011210+Q_211110101*PR_000011011211); ans_temp[ans_id*36+25]+=Pmtrx[28]*(Q_010011001*PR_000011011000+Q_010011101*PR_000011011001+Q_010111001*PR_000011011010+Q_010111101*PR_000011011011+Q_010211001*PR_000011011020+Q_010211101*PR_000011011021+Q_110011001*PR_000011011100+Q_110011101*PR_000011011101+Q_110111001*PR_000011011110+Q_110111101*PR_000011011111+Q_110211001*PR_000011011120+Q_110211101*PR_000011011121); ans_temp[ans_id*36+25]+=Pmtrx[29]*(Q_010010002*PR_000011011000+Q_010010102*PR_000011011001+Q_010010202*PR_000011011002+Q_010110002*PR_000011011010+Q_010110102*PR_000011011011+Q_010110202*PR_000011011012+Q_110010002*PR_000011011100+Q_110010102*PR_000011011101+Q_110010202*PR_000011011102+Q_110110002*PR_000011011110+Q_110110102*PR_000011011111+Q_110110202*PR_000011011112); ans_temp[ans_id*36+26]+=Pmtrx[24]*(Q_002020000*PR_000011011000+Q_002120000*PR_000011011010+Q_002220000*PR_000011011020+Q_102020000*PR_000011011100+Q_102120000*PR_000011011110+Q_102220000*PR_000011011120+Q_202020000*PR_000011011200+Q_202120000*PR_000011011210+Q_202220000*PR_000011011220); ans_temp[ans_id*36+26]+=Pmtrx[25]*(Q_001021000*PR_000011011000+Q_001121000*PR_000011011010+Q_001221000*PR_000011011020+Q_001321000*PR_000011011030+Q_101021000*PR_000011011100+Q_101121000*PR_000011011110+Q_101221000*PR_000011011120+Q_101321000*PR_000011011130); ans_temp[ans_id*36+26]+=Pmtrx[26]*(Q_000022000*PR_000011011000+Q_000122000*PR_000011011010+Q_000222000*PR_000011011020+Q_000322000*PR_000011011030+Q_000422000*PR_000011011040); ans_temp[ans_id*36+26]+=Pmtrx[27]*(Q_001020001*PR_000011011000+Q_001020101*PR_000011011001+Q_001120001*PR_000011011010+Q_001120101*PR_000011011011+Q_001220001*PR_000011011020+Q_001220101*PR_000011011021+Q_101020001*PR_000011011100+Q_101020101*PR_000011011101+Q_101120001*PR_000011011110+Q_101120101*PR_000011011111+Q_101220001*PR_000011011120+Q_101220101*PR_000011011121); ans_temp[ans_id*36+26]+=Pmtrx[28]*(Q_000021001*PR_000011011000+Q_000021101*PR_000011011001+Q_000121001*PR_000011011010+Q_000121101*PR_000011011011+Q_000221001*PR_000011011020+Q_000221101*PR_000011011021+Q_000321001*PR_000011011030+Q_000321101*PR_000011011031); ans_temp[ans_id*36+26]+=Pmtrx[29]*(Q_000020002*PR_000011011000+Q_000020102*PR_000011011001+Q_000020202*PR_000011011002+Q_000120002*PR_000011011010+Q_000120102*PR_000011011011+Q_000120202*PR_000011011012+Q_000220002*PR_000011011020+Q_000220102*PR_000011011021+Q_000220202*PR_000011011022); ans_temp[ans_id*36+27]+=Pmtrx[24]*(Q_012000010*PR_000011011000+Q_012000110*PR_000011011001+Q_112000010*PR_000011011100+Q_112000110*PR_000011011101+Q_212000010*PR_000011011200+Q_212000110*PR_000011011201+Q_312000010*PR_000011011300+Q_312000110*PR_000011011301); ans_temp[ans_id*36+27]+=Pmtrx[25]*(Q_011001010*PR_000011011000+Q_011001110*PR_000011011001+Q_011101010*PR_000011011010+Q_011101110*PR_000011011011+Q_111001010*PR_000011011100+Q_111001110*PR_000011011101+Q_111101010*PR_000011011110+Q_111101110*PR_000011011111+Q_211001010*PR_000011011200+Q_211001110*PR_000011011201+Q_211101010*PR_000011011210+Q_211101110*PR_000011011211); ans_temp[ans_id*36+27]+=Pmtrx[26]*(Q_010002010*PR_000011011000+Q_010002110*PR_000011011001+Q_010102010*PR_000011011010+Q_010102110*PR_000011011011+Q_010202010*PR_000011011020+Q_010202110*PR_000011011021+Q_110002010*PR_000011011100+Q_110002110*PR_000011011101+Q_110102010*PR_000011011110+Q_110102110*PR_000011011111+Q_110202010*PR_000011011120+Q_110202110*PR_000011011121); ans_temp[ans_id*36+27]+=Pmtrx[27]*(Q_011000011*PR_000011011000+Q_011000111*PR_000011011001+Q_011000211*PR_000011011002+Q_111000011*PR_000011011100+Q_111000111*PR_000011011101+Q_111000211*PR_000011011102+Q_211000011*PR_000011011200+Q_211000111*PR_000011011201+Q_211000211*PR_000011011202); ans_temp[ans_id*36+27]+=Pmtrx[28]*(Q_010001011*PR_000011011000+Q_010001111*PR_000011011001+Q_010001211*PR_000011011002+Q_010101011*PR_000011011010+Q_010101111*PR_000011011011+Q_010101211*PR_000011011012+Q_110001011*PR_000011011100+Q_110001111*PR_000011011101+Q_110001211*PR_000011011102+Q_110101011*PR_000011011110+Q_110101111*PR_000011011111+Q_110101211*PR_000011011112); ans_temp[ans_id*36+27]+=Pmtrx[29]*(Q_010000012*PR_000011011000+Q_010000112*PR_000011011001+Q_010000212*PR_000011011002+Q_010000312*PR_000011011003+Q_110000012*PR_000011011100+Q_110000112*PR_000011011101+Q_110000212*PR_000011011102+Q_110000312*PR_000011011103); ans_temp[ans_id*36+28]+=Pmtrx[24]*(Q_002010010*PR_000011011000+Q_002010110*PR_000011011001+Q_002110010*PR_000011011010+Q_002110110*PR_000011011011+Q_102010010*PR_000011011100+Q_102010110*PR_000011011101+Q_102110010*PR_000011011110+Q_102110110*PR_000011011111+Q_202010010*PR_000011011200+Q_202010110*PR_000011011201+Q_202110010*PR_000011011210+Q_202110110*PR_000011011211); ans_temp[ans_id*36+28]+=Pmtrx[25]*(Q_001011010*PR_000011011000+Q_001011110*PR_000011011001+Q_001111010*PR_000011011010+Q_001111110*PR_000011011011+Q_001211010*PR_000011011020+Q_001211110*PR_000011011021+Q_101011010*PR_000011011100+Q_101011110*PR_000011011101+Q_101111010*PR_000011011110+Q_101111110*PR_000011011111+Q_101211010*PR_000011011120+Q_101211110*PR_000011011121); ans_temp[ans_id*36+28]+=Pmtrx[26]*(Q_000012010*PR_000011011000+Q_000012110*PR_000011011001+Q_000112010*PR_000011011010+Q_000112110*PR_000011011011+Q_000212010*PR_000011011020+Q_000212110*PR_000011011021+Q_000312010*PR_000011011030+Q_000312110*PR_000011011031); ans_temp[ans_id*36+28]+=Pmtrx[27]*(Q_001010011*PR_000011011000+Q_001010111*PR_000011011001+Q_001010211*PR_000011011002+Q_001110011*PR_000011011010+Q_001110111*PR_000011011011+Q_001110211*PR_000011011012+Q_101010011*PR_000011011100+Q_101010111*PR_000011011101+Q_101010211*PR_000011011102+Q_101110011*PR_000011011110+Q_101110111*PR_000011011111+Q_101110211*PR_000011011112); ans_temp[ans_id*36+28]+=Pmtrx[28]*(Q_000011011*PR_000011011000+Q_000011111*PR_000011011001+Q_000011211*PR_000011011002+Q_000111011*PR_000011011010+Q_000111111*PR_000011011011+Q_000111211*PR_000011011012+Q_000211011*PR_000011011020+Q_000211111*PR_000011011021+Q_000211211*PR_000011011022); ans_temp[ans_id*36+28]+=Pmtrx[29]*(Q_000010012*PR_000011011000+Q_000010112*PR_000011011001+Q_000010212*PR_000011011002+Q_000010312*PR_000011011003+Q_000110012*PR_000011011010+Q_000110112*PR_000011011011+Q_000110212*PR_000011011012+Q_000110312*PR_000011011013); ans_temp[ans_id*36+29]+=Pmtrx[24]*(Q_002000020*PR_000011011000+Q_002000120*PR_000011011001+Q_002000220*PR_000011011002+Q_102000020*PR_000011011100+Q_102000120*PR_000011011101+Q_102000220*PR_000011011102+Q_202000020*PR_000011011200+Q_202000120*PR_000011011201+Q_202000220*PR_000011011202); ans_temp[ans_id*36+29]+=Pmtrx[25]*(Q_001001020*PR_000011011000+Q_001001120*PR_000011011001+Q_001001220*PR_000011011002+Q_001101020*PR_000011011010+Q_001101120*PR_000011011011+Q_001101220*PR_000011011012+Q_101001020*PR_000011011100+Q_101001120*PR_000011011101+Q_101001220*PR_000011011102+Q_101101020*PR_000011011110+Q_101101120*PR_000011011111+Q_101101220*PR_000011011112); ans_temp[ans_id*36+29]+=Pmtrx[26]*(Q_000002020*PR_000011011000+Q_000002120*PR_000011011001+Q_000002220*PR_000011011002+Q_000102020*PR_000011011010+Q_000102120*PR_000011011011+Q_000102220*PR_000011011012+Q_000202020*PR_000011011020+Q_000202120*PR_000011011021+Q_000202220*PR_000011011022); ans_temp[ans_id*36+29]+=Pmtrx[27]*(Q_001000021*PR_000011011000+Q_001000121*PR_000011011001+Q_001000221*PR_000011011002+Q_001000321*PR_000011011003+Q_101000021*PR_000011011100+Q_101000121*PR_000011011101+Q_101000221*PR_000011011102+Q_101000321*PR_000011011103); ans_temp[ans_id*36+29]+=Pmtrx[28]*(Q_000001021*PR_000011011000+Q_000001121*PR_000011011001+Q_000001221*PR_000011011002+Q_000001321*PR_000011011003+Q_000101021*PR_000011011010+Q_000101121*PR_000011011011+Q_000101221*PR_000011011012+Q_000101321*PR_000011011013); ans_temp[ans_id*36+29]+=Pmtrx[29]*(Q_000000022*PR_000011011000+Q_000000122*PR_000011011001+Q_000000222*PR_000011011002+Q_000000322*PR_000011011003+Q_000000422*PR_000011011004); ans_temp[ans_id*36+24]+=Pmtrx[30]*(Q_022000000*PR_000010012000+Q_122000000*PR_000010012100+Q_222000000*PR_000010012200+Q_322000000*PR_000010012300+Q_422000000*PR_000010012400); ans_temp[ans_id*36+24]+=Pmtrx[31]*(Q_021001000*PR_000010012000+Q_021101000*PR_000010012010+Q_121001000*PR_000010012100+Q_121101000*PR_000010012110+Q_221001000*PR_000010012200+Q_221101000*PR_000010012210+Q_321001000*PR_000010012300+Q_321101000*PR_000010012310); ans_temp[ans_id*36+24]+=Pmtrx[32]*(Q_020002000*PR_000010012000+Q_020102000*PR_000010012010+Q_020202000*PR_000010012020+Q_120002000*PR_000010012100+Q_120102000*PR_000010012110+Q_120202000*PR_000010012120+Q_220002000*PR_000010012200+Q_220102000*PR_000010012210+Q_220202000*PR_000010012220); ans_temp[ans_id*36+24]+=Pmtrx[33]*(Q_021000001*PR_000010012000+Q_021000101*PR_000010012001+Q_121000001*PR_000010012100+Q_121000101*PR_000010012101+Q_221000001*PR_000010012200+Q_221000101*PR_000010012201+Q_321000001*PR_000010012300+Q_321000101*PR_000010012301); ans_temp[ans_id*36+24]+=Pmtrx[34]*(Q_020001001*PR_000010012000+Q_020001101*PR_000010012001+Q_020101001*PR_000010012010+Q_020101101*PR_000010012011+Q_120001001*PR_000010012100+Q_120001101*PR_000010012101+Q_120101001*PR_000010012110+Q_120101101*PR_000010012111+Q_220001001*PR_000010012200+Q_220001101*PR_000010012201+Q_220101001*PR_000010012210+Q_220101101*PR_000010012211); ans_temp[ans_id*36+24]+=Pmtrx[35]*(Q_020000002*PR_000010012000+Q_020000102*PR_000010012001+Q_020000202*PR_000010012002+Q_120000002*PR_000010012100+Q_120000102*PR_000010012101+Q_120000202*PR_000010012102+Q_220000002*PR_000010012200+Q_220000102*PR_000010012201+Q_220000202*PR_000010012202); ans_temp[ans_id*36+25]+=Pmtrx[30]*(Q_012010000*PR_000010012000+Q_012110000*PR_000010012010+Q_112010000*PR_000010012100+Q_112110000*PR_000010012110+Q_212010000*PR_000010012200+Q_212110000*PR_000010012210+Q_312010000*PR_000010012300+Q_312110000*PR_000010012310); ans_temp[ans_id*36+25]+=Pmtrx[31]*(Q_011011000*PR_000010012000+Q_011111000*PR_000010012010+Q_011211000*PR_000010012020+Q_111011000*PR_000010012100+Q_111111000*PR_000010012110+Q_111211000*PR_000010012120+Q_211011000*PR_000010012200+Q_211111000*PR_000010012210+Q_211211000*PR_000010012220); ans_temp[ans_id*36+25]+=Pmtrx[32]*(Q_010012000*PR_000010012000+Q_010112000*PR_000010012010+Q_010212000*PR_000010012020+Q_010312000*PR_000010012030+Q_110012000*PR_000010012100+Q_110112000*PR_000010012110+Q_110212000*PR_000010012120+Q_110312000*PR_000010012130); ans_temp[ans_id*36+25]+=Pmtrx[33]*(Q_011010001*PR_000010012000+Q_011010101*PR_000010012001+Q_011110001*PR_000010012010+Q_011110101*PR_000010012011+Q_111010001*PR_000010012100+Q_111010101*PR_000010012101+Q_111110001*PR_000010012110+Q_111110101*PR_000010012111+Q_211010001*PR_000010012200+Q_211010101*PR_000010012201+Q_211110001*PR_000010012210+Q_211110101*PR_000010012211); ans_temp[ans_id*36+25]+=Pmtrx[34]*(Q_010011001*PR_000010012000+Q_010011101*PR_000010012001+Q_010111001*PR_000010012010+Q_010111101*PR_000010012011+Q_010211001*PR_000010012020+Q_010211101*PR_000010012021+Q_110011001*PR_000010012100+Q_110011101*PR_000010012101+Q_110111001*PR_000010012110+Q_110111101*PR_000010012111+Q_110211001*PR_000010012120+Q_110211101*PR_000010012121); ans_temp[ans_id*36+25]+=Pmtrx[35]*(Q_010010002*PR_000010012000+Q_010010102*PR_000010012001+Q_010010202*PR_000010012002+Q_010110002*PR_000010012010+Q_010110102*PR_000010012011+Q_010110202*PR_000010012012+Q_110010002*PR_000010012100+Q_110010102*PR_000010012101+Q_110010202*PR_000010012102+Q_110110002*PR_000010012110+Q_110110102*PR_000010012111+Q_110110202*PR_000010012112); ans_temp[ans_id*36+26]+=Pmtrx[30]*(Q_002020000*PR_000010012000+Q_002120000*PR_000010012010+Q_002220000*PR_000010012020+Q_102020000*PR_000010012100+Q_102120000*PR_000010012110+Q_102220000*PR_000010012120+Q_202020000*PR_000010012200+Q_202120000*PR_000010012210+Q_202220000*PR_000010012220); ans_temp[ans_id*36+26]+=Pmtrx[31]*(Q_001021000*PR_000010012000+Q_001121000*PR_000010012010+Q_001221000*PR_000010012020+Q_001321000*PR_000010012030+Q_101021000*PR_000010012100+Q_101121000*PR_000010012110+Q_101221000*PR_000010012120+Q_101321000*PR_000010012130); ans_temp[ans_id*36+26]+=Pmtrx[32]*(Q_000022000*PR_000010012000+Q_000122000*PR_000010012010+Q_000222000*PR_000010012020+Q_000322000*PR_000010012030+Q_000422000*PR_000010012040); ans_temp[ans_id*36+26]+=Pmtrx[33]*(Q_001020001*PR_000010012000+Q_001020101*PR_000010012001+Q_001120001*PR_000010012010+Q_001120101*PR_000010012011+Q_001220001*PR_000010012020+Q_001220101*PR_000010012021+Q_101020001*PR_000010012100+Q_101020101*PR_000010012101+Q_101120001*PR_000010012110+Q_101120101*PR_000010012111+Q_101220001*PR_000010012120+Q_101220101*PR_000010012121); ans_temp[ans_id*36+26]+=Pmtrx[34]*(Q_000021001*PR_000010012000+Q_000021101*PR_000010012001+Q_000121001*PR_000010012010+Q_000121101*PR_000010012011+Q_000221001*PR_000010012020+Q_000221101*PR_000010012021+Q_000321001*PR_000010012030+Q_000321101*PR_000010012031); ans_temp[ans_id*36+26]+=Pmtrx[35]*(Q_000020002*PR_000010012000+Q_000020102*PR_000010012001+Q_000020202*PR_000010012002+Q_000120002*PR_000010012010+Q_000120102*PR_000010012011+Q_000120202*PR_000010012012+Q_000220002*PR_000010012020+Q_000220102*PR_000010012021+Q_000220202*PR_000010012022); ans_temp[ans_id*36+27]+=Pmtrx[30]*(Q_012000010*PR_000010012000+Q_012000110*PR_000010012001+Q_112000010*PR_000010012100+Q_112000110*PR_000010012101+Q_212000010*PR_000010012200+Q_212000110*PR_000010012201+Q_312000010*PR_000010012300+Q_312000110*PR_000010012301); ans_temp[ans_id*36+27]+=Pmtrx[31]*(Q_011001010*PR_000010012000+Q_011001110*PR_000010012001+Q_011101010*PR_000010012010+Q_011101110*PR_000010012011+Q_111001010*PR_000010012100+Q_111001110*PR_000010012101+Q_111101010*PR_000010012110+Q_111101110*PR_000010012111+Q_211001010*PR_000010012200+Q_211001110*PR_000010012201+Q_211101010*PR_000010012210+Q_211101110*PR_000010012211); ans_temp[ans_id*36+27]+=Pmtrx[32]*(Q_010002010*PR_000010012000+Q_010002110*PR_000010012001+Q_010102010*PR_000010012010+Q_010102110*PR_000010012011+Q_010202010*PR_000010012020+Q_010202110*PR_000010012021+Q_110002010*PR_000010012100+Q_110002110*PR_000010012101+Q_110102010*PR_000010012110+Q_110102110*PR_000010012111+Q_110202010*PR_000010012120+Q_110202110*PR_000010012121); ans_temp[ans_id*36+27]+=Pmtrx[33]*(Q_011000011*PR_000010012000+Q_011000111*PR_000010012001+Q_011000211*PR_000010012002+Q_111000011*PR_000010012100+Q_111000111*PR_000010012101+Q_111000211*PR_000010012102+Q_211000011*PR_000010012200+Q_211000111*PR_000010012201+Q_211000211*PR_000010012202); ans_temp[ans_id*36+27]+=Pmtrx[34]*(Q_010001011*PR_000010012000+Q_010001111*PR_000010012001+Q_010001211*PR_000010012002+Q_010101011*PR_000010012010+Q_010101111*PR_000010012011+Q_010101211*PR_000010012012+Q_110001011*PR_000010012100+Q_110001111*PR_000010012101+Q_110001211*PR_000010012102+Q_110101011*PR_000010012110+Q_110101111*PR_000010012111+Q_110101211*PR_000010012112); ans_temp[ans_id*36+27]+=Pmtrx[35]*(Q_010000012*PR_000010012000+Q_010000112*PR_000010012001+Q_010000212*PR_000010012002+Q_010000312*PR_000010012003+Q_110000012*PR_000010012100+Q_110000112*PR_000010012101+Q_110000212*PR_000010012102+Q_110000312*PR_000010012103); ans_temp[ans_id*36+28]+=Pmtrx[30]*(Q_002010010*PR_000010012000+Q_002010110*PR_000010012001+Q_002110010*PR_000010012010+Q_002110110*PR_000010012011+Q_102010010*PR_000010012100+Q_102010110*PR_000010012101+Q_102110010*PR_000010012110+Q_102110110*PR_000010012111+Q_202010010*PR_000010012200+Q_202010110*PR_000010012201+Q_202110010*PR_000010012210+Q_202110110*PR_000010012211); ans_temp[ans_id*36+28]+=Pmtrx[31]*(Q_001011010*PR_000010012000+Q_001011110*PR_000010012001+Q_001111010*PR_000010012010+Q_001111110*PR_000010012011+Q_001211010*PR_000010012020+Q_001211110*PR_000010012021+Q_101011010*PR_000010012100+Q_101011110*PR_000010012101+Q_101111010*PR_000010012110+Q_101111110*PR_000010012111+Q_101211010*PR_000010012120+Q_101211110*PR_000010012121); ans_temp[ans_id*36+28]+=Pmtrx[32]*(Q_000012010*PR_000010012000+Q_000012110*PR_000010012001+Q_000112010*PR_000010012010+Q_000112110*PR_000010012011+Q_000212010*PR_000010012020+Q_000212110*PR_000010012021+Q_000312010*PR_000010012030+Q_000312110*PR_000010012031); ans_temp[ans_id*36+28]+=Pmtrx[33]*(Q_001010011*PR_000010012000+Q_001010111*PR_000010012001+Q_001010211*PR_000010012002+Q_001110011*PR_000010012010+Q_001110111*PR_000010012011+Q_001110211*PR_000010012012+Q_101010011*PR_000010012100+Q_101010111*PR_000010012101+Q_101010211*PR_000010012102+Q_101110011*PR_000010012110+Q_101110111*PR_000010012111+Q_101110211*PR_000010012112); ans_temp[ans_id*36+28]+=Pmtrx[34]*(Q_000011011*PR_000010012000+Q_000011111*PR_000010012001+Q_000011211*PR_000010012002+Q_000111011*PR_000010012010+Q_000111111*PR_000010012011+Q_000111211*PR_000010012012+Q_000211011*PR_000010012020+Q_000211111*PR_000010012021+Q_000211211*PR_000010012022); ans_temp[ans_id*36+28]+=Pmtrx[35]*(Q_000010012*PR_000010012000+Q_000010112*PR_000010012001+Q_000010212*PR_000010012002+Q_000010312*PR_000010012003+Q_000110012*PR_000010012010+Q_000110112*PR_000010012011+Q_000110212*PR_000010012012+Q_000110312*PR_000010012013); ans_temp[ans_id*36+29]+=Pmtrx[30]*(Q_002000020*PR_000010012000+Q_002000120*PR_000010012001+Q_002000220*PR_000010012002+Q_102000020*PR_000010012100+Q_102000120*PR_000010012101+Q_102000220*PR_000010012102+Q_202000020*PR_000010012200+Q_202000120*PR_000010012201+Q_202000220*PR_000010012202); ans_temp[ans_id*36+29]+=Pmtrx[31]*(Q_001001020*PR_000010012000+Q_001001120*PR_000010012001+Q_001001220*PR_000010012002+Q_001101020*PR_000010012010+Q_001101120*PR_000010012011+Q_001101220*PR_000010012012+Q_101001020*PR_000010012100+Q_101001120*PR_000010012101+Q_101001220*PR_000010012102+Q_101101020*PR_000010012110+Q_101101120*PR_000010012111+Q_101101220*PR_000010012112); ans_temp[ans_id*36+29]+=Pmtrx[32]*(Q_000002020*PR_000010012000+Q_000002120*PR_000010012001+Q_000002220*PR_000010012002+Q_000102020*PR_000010012010+Q_000102120*PR_000010012011+Q_000102220*PR_000010012012+Q_000202020*PR_000010012020+Q_000202120*PR_000010012021+Q_000202220*PR_000010012022); ans_temp[ans_id*36+29]+=Pmtrx[33]*(Q_001000021*PR_000010012000+Q_001000121*PR_000010012001+Q_001000221*PR_000010012002+Q_001000321*PR_000010012003+Q_101000021*PR_000010012100+Q_101000121*PR_000010012101+Q_101000221*PR_000010012102+Q_101000321*PR_000010012103); ans_temp[ans_id*36+29]+=Pmtrx[34]*(Q_000001021*PR_000010012000+Q_000001121*PR_000010012001+Q_000001221*PR_000010012002+Q_000001321*PR_000010012003+Q_000101021*PR_000010012010+Q_000101121*PR_000010012011+Q_000101221*PR_000010012012+Q_000101321*PR_000010012013); ans_temp[ans_id*36+29]+=Pmtrx[35]*(Q_000000022*PR_000010012000+Q_000000122*PR_000010012001+Q_000000222*PR_000010012002+Q_000000322*PR_000010012003+Q_000000422*PR_000010012004); ans_temp[ans_id*36+30]+=Pmtrx[0]*(Q_022000000*PR_002000020000+Q_122000000*PR_002000020100+Q_222000000*PR_002000020200+Q_322000000*PR_002000020300+Q_422000000*PR_002000020400); ans_temp[ans_id*36+30]+=Pmtrx[1]*(Q_021001000*PR_002000020000+Q_021101000*PR_002000020010+Q_121001000*PR_002000020100+Q_121101000*PR_002000020110+Q_221001000*PR_002000020200+Q_221101000*PR_002000020210+Q_321001000*PR_002000020300+Q_321101000*PR_002000020310); ans_temp[ans_id*36+30]+=Pmtrx[2]*(Q_020002000*PR_002000020000+Q_020102000*PR_002000020010+Q_020202000*PR_002000020020+Q_120002000*PR_002000020100+Q_120102000*PR_002000020110+Q_120202000*PR_002000020120+Q_220002000*PR_002000020200+Q_220102000*PR_002000020210+Q_220202000*PR_002000020220); ans_temp[ans_id*36+30]+=Pmtrx[3]*(Q_021000001*PR_002000020000+Q_021000101*PR_002000020001+Q_121000001*PR_002000020100+Q_121000101*PR_002000020101+Q_221000001*PR_002000020200+Q_221000101*PR_002000020201+Q_321000001*PR_002000020300+Q_321000101*PR_002000020301); ans_temp[ans_id*36+30]+=Pmtrx[4]*(Q_020001001*PR_002000020000+Q_020001101*PR_002000020001+Q_020101001*PR_002000020010+Q_020101101*PR_002000020011+Q_120001001*PR_002000020100+Q_120001101*PR_002000020101+Q_120101001*PR_002000020110+Q_120101101*PR_002000020111+Q_220001001*PR_002000020200+Q_220001101*PR_002000020201+Q_220101001*PR_002000020210+Q_220101101*PR_002000020211); ans_temp[ans_id*36+30]+=Pmtrx[5]*(Q_020000002*PR_002000020000+Q_020000102*PR_002000020001+Q_020000202*PR_002000020002+Q_120000002*PR_002000020100+Q_120000102*PR_002000020101+Q_120000202*PR_002000020102+Q_220000002*PR_002000020200+Q_220000102*PR_002000020201+Q_220000202*PR_002000020202); ans_temp[ans_id*36+31]+=Pmtrx[0]*(Q_012010000*PR_002000020000+Q_012110000*PR_002000020010+Q_112010000*PR_002000020100+Q_112110000*PR_002000020110+Q_212010000*PR_002000020200+Q_212110000*PR_002000020210+Q_312010000*PR_002000020300+Q_312110000*PR_002000020310); ans_temp[ans_id*36+31]+=Pmtrx[1]*(Q_011011000*PR_002000020000+Q_011111000*PR_002000020010+Q_011211000*PR_002000020020+Q_111011000*PR_002000020100+Q_111111000*PR_002000020110+Q_111211000*PR_002000020120+Q_211011000*PR_002000020200+Q_211111000*PR_002000020210+Q_211211000*PR_002000020220); ans_temp[ans_id*36+31]+=Pmtrx[2]*(Q_010012000*PR_002000020000+Q_010112000*PR_002000020010+Q_010212000*PR_002000020020+Q_010312000*PR_002000020030+Q_110012000*PR_002000020100+Q_110112000*PR_002000020110+Q_110212000*PR_002000020120+Q_110312000*PR_002000020130); ans_temp[ans_id*36+31]+=Pmtrx[3]*(Q_011010001*PR_002000020000+Q_011010101*PR_002000020001+Q_011110001*PR_002000020010+Q_011110101*PR_002000020011+Q_111010001*PR_002000020100+Q_111010101*PR_002000020101+Q_111110001*PR_002000020110+Q_111110101*PR_002000020111+Q_211010001*PR_002000020200+Q_211010101*PR_002000020201+Q_211110001*PR_002000020210+Q_211110101*PR_002000020211); ans_temp[ans_id*36+31]+=Pmtrx[4]*(Q_010011001*PR_002000020000+Q_010011101*PR_002000020001+Q_010111001*PR_002000020010+Q_010111101*PR_002000020011+Q_010211001*PR_002000020020+Q_010211101*PR_002000020021+Q_110011001*PR_002000020100+Q_110011101*PR_002000020101+Q_110111001*PR_002000020110+Q_110111101*PR_002000020111+Q_110211001*PR_002000020120+Q_110211101*PR_002000020121); ans_temp[ans_id*36+31]+=Pmtrx[5]*(Q_010010002*PR_002000020000+Q_010010102*PR_002000020001+Q_010010202*PR_002000020002+Q_010110002*PR_002000020010+Q_010110102*PR_002000020011+Q_010110202*PR_002000020012+Q_110010002*PR_002000020100+Q_110010102*PR_002000020101+Q_110010202*PR_002000020102+Q_110110002*PR_002000020110+Q_110110102*PR_002000020111+Q_110110202*PR_002000020112); ans_temp[ans_id*36+32]+=Pmtrx[0]*(Q_002020000*PR_002000020000+Q_002120000*PR_002000020010+Q_002220000*PR_002000020020+Q_102020000*PR_002000020100+Q_102120000*PR_002000020110+Q_102220000*PR_002000020120+Q_202020000*PR_002000020200+Q_202120000*PR_002000020210+Q_202220000*PR_002000020220); ans_temp[ans_id*36+32]+=Pmtrx[1]*(Q_001021000*PR_002000020000+Q_001121000*PR_002000020010+Q_001221000*PR_002000020020+Q_001321000*PR_002000020030+Q_101021000*PR_002000020100+Q_101121000*PR_002000020110+Q_101221000*PR_002000020120+Q_101321000*PR_002000020130); ans_temp[ans_id*36+32]+=Pmtrx[2]*(Q_000022000*PR_002000020000+Q_000122000*PR_002000020010+Q_000222000*PR_002000020020+Q_000322000*PR_002000020030+Q_000422000*PR_002000020040); ans_temp[ans_id*36+32]+=Pmtrx[3]*(Q_001020001*PR_002000020000+Q_001020101*PR_002000020001+Q_001120001*PR_002000020010+Q_001120101*PR_002000020011+Q_001220001*PR_002000020020+Q_001220101*PR_002000020021+Q_101020001*PR_002000020100+Q_101020101*PR_002000020101+Q_101120001*PR_002000020110+Q_101120101*PR_002000020111+Q_101220001*PR_002000020120+Q_101220101*PR_002000020121); ans_temp[ans_id*36+32]+=Pmtrx[4]*(Q_000021001*PR_002000020000+Q_000021101*PR_002000020001+Q_000121001*PR_002000020010+Q_000121101*PR_002000020011+Q_000221001*PR_002000020020+Q_000221101*PR_002000020021+Q_000321001*PR_002000020030+Q_000321101*PR_002000020031); ans_temp[ans_id*36+32]+=Pmtrx[5]*(Q_000020002*PR_002000020000+Q_000020102*PR_002000020001+Q_000020202*PR_002000020002+Q_000120002*PR_002000020010+Q_000120102*PR_002000020011+Q_000120202*PR_002000020012+Q_000220002*PR_002000020020+Q_000220102*PR_002000020021+Q_000220202*PR_002000020022); ans_temp[ans_id*36+33]+=Pmtrx[0]*(Q_012000010*PR_002000020000+Q_012000110*PR_002000020001+Q_112000010*PR_002000020100+Q_112000110*PR_002000020101+Q_212000010*PR_002000020200+Q_212000110*PR_002000020201+Q_312000010*PR_002000020300+Q_312000110*PR_002000020301); ans_temp[ans_id*36+33]+=Pmtrx[1]*(Q_011001010*PR_002000020000+Q_011001110*PR_002000020001+Q_011101010*PR_002000020010+Q_011101110*PR_002000020011+Q_111001010*PR_002000020100+Q_111001110*PR_002000020101+Q_111101010*PR_002000020110+Q_111101110*PR_002000020111+Q_211001010*PR_002000020200+Q_211001110*PR_002000020201+Q_211101010*PR_002000020210+Q_211101110*PR_002000020211); ans_temp[ans_id*36+33]+=Pmtrx[2]*(Q_010002010*PR_002000020000+Q_010002110*PR_002000020001+Q_010102010*PR_002000020010+Q_010102110*PR_002000020011+Q_010202010*PR_002000020020+Q_010202110*PR_002000020021+Q_110002010*PR_002000020100+Q_110002110*PR_002000020101+Q_110102010*PR_002000020110+Q_110102110*PR_002000020111+Q_110202010*PR_002000020120+Q_110202110*PR_002000020121); ans_temp[ans_id*36+33]+=Pmtrx[3]*(Q_011000011*PR_002000020000+Q_011000111*PR_002000020001+Q_011000211*PR_002000020002+Q_111000011*PR_002000020100+Q_111000111*PR_002000020101+Q_111000211*PR_002000020102+Q_211000011*PR_002000020200+Q_211000111*PR_002000020201+Q_211000211*PR_002000020202); ans_temp[ans_id*36+33]+=Pmtrx[4]*(Q_010001011*PR_002000020000+Q_010001111*PR_002000020001+Q_010001211*PR_002000020002+Q_010101011*PR_002000020010+Q_010101111*PR_002000020011+Q_010101211*PR_002000020012+Q_110001011*PR_002000020100+Q_110001111*PR_002000020101+Q_110001211*PR_002000020102+Q_110101011*PR_002000020110+Q_110101111*PR_002000020111+Q_110101211*PR_002000020112); ans_temp[ans_id*36+33]+=Pmtrx[5]*(Q_010000012*PR_002000020000+Q_010000112*PR_002000020001+Q_010000212*PR_002000020002+Q_010000312*PR_002000020003+Q_110000012*PR_002000020100+Q_110000112*PR_002000020101+Q_110000212*PR_002000020102+Q_110000312*PR_002000020103); ans_temp[ans_id*36+34]+=Pmtrx[0]*(Q_002010010*PR_002000020000+Q_002010110*PR_002000020001+Q_002110010*PR_002000020010+Q_002110110*PR_002000020011+Q_102010010*PR_002000020100+Q_102010110*PR_002000020101+Q_102110010*PR_002000020110+Q_102110110*PR_002000020111+Q_202010010*PR_002000020200+Q_202010110*PR_002000020201+Q_202110010*PR_002000020210+Q_202110110*PR_002000020211); ans_temp[ans_id*36+34]+=Pmtrx[1]*(Q_001011010*PR_002000020000+Q_001011110*PR_002000020001+Q_001111010*PR_002000020010+Q_001111110*PR_002000020011+Q_001211010*PR_002000020020+Q_001211110*PR_002000020021+Q_101011010*PR_002000020100+Q_101011110*PR_002000020101+Q_101111010*PR_002000020110+Q_101111110*PR_002000020111+Q_101211010*PR_002000020120+Q_101211110*PR_002000020121); ans_temp[ans_id*36+34]+=Pmtrx[2]*(Q_000012010*PR_002000020000+Q_000012110*PR_002000020001+Q_000112010*PR_002000020010+Q_000112110*PR_002000020011+Q_000212010*PR_002000020020+Q_000212110*PR_002000020021+Q_000312010*PR_002000020030+Q_000312110*PR_002000020031); ans_temp[ans_id*36+34]+=Pmtrx[3]*(Q_001010011*PR_002000020000+Q_001010111*PR_002000020001+Q_001010211*PR_002000020002+Q_001110011*PR_002000020010+Q_001110111*PR_002000020011+Q_001110211*PR_002000020012+Q_101010011*PR_002000020100+Q_101010111*PR_002000020101+Q_101010211*PR_002000020102+Q_101110011*PR_002000020110+Q_101110111*PR_002000020111+Q_101110211*PR_002000020112); ans_temp[ans_id*36+34]+=Pmtrx[4]*(Q_000011011*PR_002000020000+Q_000011111*PR_002000020001+Q_000011211*PR_002000020002+Q_000111011*PR_002000020010+Q_000111111*PR_002000020011+Q_000111211*PR_002000020012+Q_000211011*PR_002000020020+Q_000211111*PR_002000020021+Q_000211211*PR_002000020022); ans_temp[ans_id*36+34]+=Pmtrx[5]*(Q_000010012*PR_002000020000+Q_000010112*PR_002000020001+Q_000010212*PR_002000020002+Q_000010312*PR_002000020003+Q_000110012*PR_002000020010+Q_000110112*PR_002000020011+Q_000110212*PR_002000020012+Q_000110312*PR_002000020013); ans_temp[ans_id*36+35]+=Pmtrx[0]*(Q_002000020*PR_002000020000+Q_002000120*PR_002000020001+Q_002000220*PR_002000020002+Q_102000020*PR_002000020100+Q_102000120*PR_002000020101+Q_102000220*PR_002000020102+Q_202000020*PR_002000020200+Q_202000120*PR_002000020201+Q_202000220*PR_002000020202); ans_temp[ans_id*36+35]+=Pmtrx[1]*(Q_001001020*PR_002000020000+Q_001001120*PR_002000020001+Q_001001220*PR_002000020002+Q_001101020*PR_002000020010+Q_001101120*PR_002000020011+Q_001101220*PR_002000020012+Q_101001020*PR_002000020100+Q_101001120*PR_002000020101+Q_101001220*PR_002000020102+Q_101101020*PR_002000020110+Q_101101120*PR_002000020111+Q_101101220*PR_002000020112); ans_temp[ans_id*36+35]+=Pmtrx[2]*(Q_000002020*PR_002000020000+Q_000002120*PR_002000020001+Q_000002220*PR_002000020002+Q_000102020*PR_002000020010+Q_000102120*PR_002000020011+Q_000102220*PR_002000020012+Q_000202020*PR_002000020020+Q_000202120*PR_002000020021+Q_000202220*PR_002000020022); ans_temp[ans_id*36+35]+=Pmtrx[3]*(Q_001000021*PR_002000020000+Q_001000121*PR_002000020001+Q_001000221*PR_002000020002+Q_001000321*PR_002000020003+Q_101000021*PR_002000020100+Q_101000121*PR_002000020101+Q_101000221*PR_002000020102+Q_101000321*PR_002000020103); ans_temp[ans_id*36+35]+=Pmtrx[4]*(Q_000001021*PR_002000020000+Q_000001121*PR_002000020001+Q_000001221*PR_002000020002+Q_000001321*PR_002000020003+Q_000101021*PR_002000020010+Q_000101121*PR_002000020011+Q_000101221*PR_002000020012+Q_000101321*PR_002000020013); ans_temp[ans_id*36+35]+=Pmtrx[5]*(Q_000000022*PR_002000020000+Q_000000122*PR_002000020001+Q_000000222*PR_002000020002+Q_000000322*PR_002000020003+Q_000000422*PR_002000020004); ans_temp[ans_id*36+30]+=Pmtrx[6]*(Q_022000000*PR_001001020000+Q_122000000*PR_001001020100+Q_222000000*PR_001001020200+Q_322000000*PR_001001020300+Q_422000000*PR_001001020400); ans_temp[ans_id*36+30]+=Pmtrx[7]*(Q_021001000*PR_001001020000+Q_021101000*PR_001001020010+Q_121001000*PR_001001020100+Q_121101000*PR_001001020110+Q_221001000*PR_001001020200+Q_221101000*PR_001001020210+Q_321001000*PR_001001020300+Q_321101000*PR_001001020310); ans_temp[ans_id*36+30]+=Pmtrx[8]*(Q_020002000*PR_001001020000+Q_020102000*PR_001001020010+Q_020202000*PR_001001020020+Q_120002000*PR_001001020100+Q_120102000*PR_001001020110+Q_120202000*PR_001001020120+Q_220002000*PR_001001020200+Q_220102000*PR_001001020210+Q_220202000*PR_001001020220); ans_temp[ans_id*36+30]+=Pmtrx[9]*(Q_021000001*PR_001001020000+Q_021000101*PR_001001020001+Q_121000001*PR_001001020100+Q_121000101*PR_001001020101+Q_221000001*PR_001001020200+Q_221000101*PR_001001020201+Q_321000001*PR_001001020300+Q_321000101*PR_001001020301); ans_temp[ans_id*36+30]+=Pmtrx[10]*(Q_020001001*PR_001001020000+Q_020001101*PR_001001020001+Q_020101001*PR_001001020010+Q_020101101*PR_001001020011+Q_120001001*PR_001001020100+Q_120001101*PR_001001020101+Q_120101001*PR_001001020110+Q_120101101*PR_001001020111+Q_220001001*PR_001001020200+Q_220001101*PR_001001020201+Q_220101001*PR_001001020210+Q_220101101*PR_001001020211); ans_temp[ans_id*36+30]+=Pmtrx[11]*(Q_020000002*PR_001001020000+Q_020000102*PR_001001020001+Q_020000202*PR_001001020002+Q_120000002*PR_001001020100+Q_120000102*PR_001001020101+Q_120000202*PR_001001020102+Q_220000002*PR_001001020200+Q_220000102*PR_001001020201+Q_220000202*PR_001001020202); ans_temp[ans_id*36+31]+=Pmtrx[6]*(Q_012010000*PR_001001020000+Q_012110000*PR_001001020010+Q_112010000*PR_001001020100+Q_112110000*PR_001001020110+Q_212010000*PR_001001020200+Q_212110000*PR_001001020210+Q_312010000*PR_001001020300+Q_312110000*PR_001001020310); ans_temp[ans_id*36+31]+=Pmtrx[7]*(Q_011011000*PR_001001020000+Q_011111000*PR_001001020010+Q_011211000*PR_001001020020+Q_111011000*PR_001001020100+Q_111111000*PR_001001020110+Q_111211000*PR_001001020120+Q_211011000*PR_001001020200+Q_211111000*PR_001001020210+Q_211211000*PR_001001020220); ans_temp[ans_id*36+31]+=Pmtrx[8]*(Q_010012000*PR_001001020000+Q_010112000*PR_001001020010+Q_010212000*PR_001001020020+Q_010312000*PR_001001020030+Q_110012000*PR_001001020100+Q_110112000*PR_001001020110+Q_110212000*PR_001001020120+Q_110312000*PR_001001020130); ans_temp[ans_id*36+31]+=Pmtrx[9]*(Q_011010001*PR_001001020000+Q_011010101*PR_001001020001+Q_011110001*PR_001001020010+Q_011110101*PR_001001020011+Q_111010001*PR_001001020100+Q_111010101*PR_001001020101+Q_111110001*PR_001001020110+Q_111110101*PR_001001020111+Q_211010001*PR_001001020200+Q_211010101*PR_001001020201+Q_211110001*PR_001001020210+Q_211110101*PR_001001020211); ans_temp[ans_id*36+31]+=Pmtrx[10]*(Q_010011001*PR_001001020000+Q_010011101*PR_001001020001+Q_010111001*PR_001001020010+Q_010111101*PR_001001020011+Q_010211001*PR_001001020020+Q_010211101*PR_001001020021+Q_110011001*PR_001001020100+Q_110011101*PR_001001020101+Q_110111001*PR_001001020110+Q_110111101*PR_001001020111+Q_110211001*PR_001001020120+Q_110211101*PR_001001020121); ans_temp[ans_id*36+31]+=Pmtrx[11]*(Q_010010002*PR_001001020000+Q_010010102*PR_001001020001+Q_010010202*PR_001001020002+Q_010110002*PR_001001020010+Q_010110102*PR_001001020011+Q_010110202*PR_001001020012+Q_110010002*PR_001001020100+Q_110010102*PR_001001020101+Q_110010202*PR_001001020102+Q_110110002*PR_001001020110+Q_110110102*PR_001001020111+Q_110110202*PR_001001020112); ans_temp[ans_id*36+32]+=Pmtrx[6]*(Q_002020000*PR_001001020000+Q_002120000*PR_001001020010+Q_002220000*PR_001001020020+Q_102020000*PR_001001020100+Q_102120000*PR_001001020110+Q_102220000*PR_001001020120+Q_202020000*PR_001001020200+Q_202120000*PR_001001020210+Q_202220000*PR_001001020220); ans_temp[ans_id*36+32]+=Pmtrx[7]*(Q_001021000*PR_001001020000+Q_001121000*PR_001001020010+Q_001221000*PR_001001020020+Q_001321000*PR_001001020030+Q_101021000*PR_001001020100+Q_101121000*PR_001001020110+Q_101221000*PR_001001020120+Q_101321000*PR_001001020130); ans_temp[ans_id*36+32]+=Pmtrx[8]*(Q_000022000*PR_001001020000+Q_000122000*PR_001001020010+Q_000222000*PR_001001020020+Q_000322000*PR_001001020030+Q_000422000*PR_001001020040); ans_temp[ans_id*36+32]+=Pmtrx[9]*(Q_001020001*PR_001001020000+Q_001020101*PR_001001020001+Q_001120001*PR_001001020010+Q_001120101*PR_001001020011+Q_001220001*PR_001001020020+Q_001220101*PR_001001020021+Q_101020001*PR_001001020100+Q_101020101*PR_001001020101+Q_101120001*PR_001001020110+Q_101120101*PR_001001020111+Q_101220001*PR_001001020120+Q_101220101*PR_001001020121); ans_temp[ans_id*36+32]+=Pmtrx[10]*(Q_000021001*PR_001001020000+Q_000021101*PR_001001020001+Q_000121001*PR_001001020010+Q_000121101*PR_001001020011+Q_000221001*PR_001001020020+Q_000221101*PR_001001020021+Q_000321001*PR_001001020030+Q_000321101*PR_001001020031); ans_temp[ans_id*36+32]+=Pmtrx[11]*(Q_000020002*PR_001001020000+Q_000020102*PR_001001020001+Q_000020202*PR_001001020002+Q_000120002*PR_001001020010+Q_000120102*PR_001001020011+Q_000120202*PR_001001020012+Q_000220002*PR_001001020020+Q_000220102*PR_001001020021+Q_000220202*PR_001001020022); ans_temp[ans_id*36+33]+=Pmtrx[6]*(Q_012000010*PR_001001020000+Q_012000110*PR_001001020001+Q_112000010*PR_001001020100+Q_112000110*PR_001001020101+Q_212000010*PR_001001020200+Q_212000110*PR_001001020201+Q_312000010*PR_001001020300+Q_312000110*PR_001001020301); ans_temp[ans_id*36+33]+=Pmtrx[7]*(Q_011001010*PR_001001020000+Q_011001110*PR_001001020001+Q_011101010*PR_001001020010+Q_011101110*PR_001001020011+Q_111001010*PR_001001020100+Q_111001110*PR_001001020101+Q_111101010*PR_001001020110+Q_111101110*PR_001001020111+Q_211001010*PR_001001020200+Q_211001110*PR_001001020201+Q_211101010*PR_001001020210+Q_211101110*PR_001001020211); ans_temp[ans_id*36+33]+=Pmtrx[8]*(Q_010002010*PR_001001020000+Q_010002110*PR_001001020001+Q_010102010*PR_001001020010+Q_010102110*PR_001001020011+Q_010202010*PR_001001020020+Q_010202110*PR_001001020021+Q_110002010*PR_001001020100+Q_110002110*PR_001001020101+Q_110102010*PR_001001020110+Q_110102110*PR_001001020111+Q_110202010*PR_001001020120+Q_110202110*PR_001001020121); ans_temp[ans_id*36+33]+=Pmtrx[9]*(Q_011000011*PR_001001020000+Q_011000111*PR_001001020001+Q_011000211*PR_001001020002+Q_111000011*PR_001001020100+Q_111000111*PR_001001020101+Q_111000211*PR_001001020102+Q_211000011*PR_001001020200+Q_211000111*PR_001001020201+Q_211000211*PR_001001020202); ans_temp[ans_id*36+33]+=Pmtrx[10]*(Q_010001011*PR_001001020000+Q_010001111*PR_001001020001+Q_010001211*PR_001001020002+Q_010101011*PR_001001020010+Q_010101111*PR_001001020011+Q_010101211*PR_001001020012+Q_110001011*PR_001001020100+Q_110001111*PR_001001020101+Q_110001211*PR_001001020102+Q_110101011*PR_001001020110+Q_110101111*PR_001001020111+Q_110101211*PR_001001020112); ans_temp[ans_id*36+33]+=Pmtrx[11]*(Q_010000012*PR_001001020000+Q_010000112*PR_001001020001+Q_010000212*PR_001001020002+Q_010000312*PR_001001020003+Q_110000012*PR_001001020100+Q_110000112*PR_001001020101+Q_110000212*PR_001001020102+Q_110000312*PR_001001020103); ans_temp[ans_id*36+34]+=Pmtrx[6]*(Q_002010010*PR_001001020000+Q_002010110*PR_001001020001+Q_002110010*PR_001001020010+Q_002110110*PR_001001020011+Q_102010010*PR_001001020100+Q_102010110*PR_001001020101+Q_102110010*PR_001001020110+Q_102110110*PR_001001020111+Q_202010010*PR_001001020200+Q_202010110*PR_001001020201+Q_202110010*PR_001001020210+Q_202110110*PR_001001020211); ans_temp[ans_id*36+34]+=Pmtrx[7]*(Q_001011010*PR_001001020000+Q_001011110*PR_001001020001+Q_001111010*PR_001001020010+Q_001111110*PR_001001020011+Q_001211010*PR_001001020020+Q_001211110*PR_001001020021+Q_101011010*PR_001001020100+Q_101011110*PR_001001020101+Q_101111010*PR_001001020110+Q_101111110*PR_001001020111+Q_101211010*PR_001001020120+Q_101211110*PR_001001020121); ans_temp[ans_id*36+34]+=Pmtrx[8]*(Q_000012010*PR_001001020000+Q_000012110*PR_001001020001+Q_000112010*PR_001001020010+Q_000112110*PR_001001020011+Q_000212010*PR_001001020020+Q_000212110*PR_001001020021+Q_000312010*PR_001001020030+Q_000312110*PR_001001020031); ans_temp[ans_id*36+34]+=Pmtrx[9]*(Q_001010011*PR_001001020000+Q_001010111*PR_001001020001+Q_001010211*PR_001001020002+Q_001110011*PR_001001020010+Q_001110111*PR_001001020011+Q_001110211*PR_001001020012+Q_101010011*PR_001001020100+Q_101010111*PR_001001020101+Q_101010211*PR_001001020102+Q_101110011*PR_001001020110+Q_101110111*PR_001001020111+Q_101110211*PR_001001020112); ans_temp[ans_id*36+34]+=Pmtrx[10]*(Q_000011011*PR_001001020000+Q_000011111*PR_001001020001+Q_000011211*PR_001001020002+Q_000111011*PR_001001020010+Q_000111111*PR_001001020011+Q_000111211*PR_001001020012+Q_000211011*PR_001001020020+Q_000211111*PR_001001020021+Q_000211211*PR_001001020022); ans_temp[ans_id*36+34]+=Pmtrx[11]*(Q_000010012*PR_001001020000+Q_000010112*PR_001001020001+Q_000010212*PR_001001020002+Q_000010312*PR_001001020003+Q_000110012*PR_001001020010+Q_000110112*PR_001001020011+Q_000110212*PR_001001020012+Q_000110312*PR_001001020013); ans_temp[ans_id*36+35]+=Pmtrx[6]*(Q_002000020*PR_001001020000+Q_002000120*PR_001001020001+Q_002000220*PR_001001020002+Q_102000020*PR_001001020100+Q_102000120*PR_001001020101+Q_102000220*PR_001001020102+Q_202000020*PR_001001020200+Q_202000120*PR_001001020201+Q_202000220*PR_001001020202); ans_temp[ans_id*36+35]+=Pmtrx[7]*(Q_001001020*PR_001001020000+Q_001001120*PR_001001020001+Q_001001220*PR_001001020002+Q_001101020*PR_001001020010+Q_001101120*PR_001001020011+Q_001101220*PR_001001020012+Q_101001020*PR_001001020100+Q_101001120*PR_001001020101+Q_101001220*PR_001001020102+Q_101101020*PR_001001020110+Q_101101120*PR_001001020111+Q_101101220*PR_001001020112); ans_temp[ans_id*36+35]+=Pmtrx[8]*(Q_000002020*PR_001001020000+Q_000002120*PR_001001020001+Q_000002220*PR_001001020002+Q_000102020*PR_001001020010+Q_000102120*PR_001001020011+Q_000102220*PR_001001020012+Q_000202020*PR_001001020020+Q_000202120*PR_001001020021+Q_000202220*PR_001001020022); ans_temp[ans_id*36+35]+=Pmtrx[9]*(Q_001000021*PR_001001020000+Q_001000121*PR_001001020001+Q_001000221*PR_001001020002+Q_001000321*PR_001001020003+Q_101000021*PR_001001020100+Q_101000121*PR_001001020101+Q_101000221*PR_001001020102+Q_101000321*PR_001001020103); ans_temp[ans_id*36+35]+=Pmtrx[10]*(Q_000001021*PR_001001020000+Q_000001121*PR_001001020001+Q_000001221*PR_001001020002+Q_000001321*PR_001001020003+Q_000101021*PR_001001020010+Q_000101121*PR_001001020011+Q_000101221*PR_001001020012+Q_000101321*PR_001001020013); ans_temp[ans_id*36+35]+=Pmtrx[11]*(Q_000000022*PR_001001020000+Q_000000122*PR_001001020001+Q_000000222*PR_001001020002+Q_000000322*PR_001001020003+Q_000000422*PR_001001020004); ans_temp[ans_id*36+30]+=Pmtrx[12]*(Q_022000000*PR_000002020000+Q_122000000*PR_000002020100+Q_222000000*PR_000002020200+Q_322000000*PR_000002020300+Q_422000000*PR_000002020400); ans_temp[ans_id*36+30]+=Pmtrx[13]*(Q_021001000*PR_000002020000+Q_021101000*PR_000002020010+Q_121001000*PR_000002020100+Q_121101000*PR_000002020110+Q_221001000*PR_000002020200+Q_221101000*PR_000002020210+Q_321001000*PR_000002020300+Q_321101000*PR_000002020310); ans_temp[ans_id*36+30]+=Pmtrx[14]*(Q_020002000*PR_000002020000+Q_020102000*PR_000002020010+Q_020202000*PR_000002020020+Q_120002000*PR_000002020100+Q_120102000*PR_000002020110+Q_120202000*PR_000002020120+Q_220002000*PR_000002020200+Q_220102000*PR_000002020210+Q_220202000*PR_000002020220); ans_temp[ans_id*36+30]+=Pmtrx[15]*(Q_021000001*PR_000002020000+Q_021000101*PR_000002020001+Q_121000001*PR_000002020100+Q_121000101*PR_000002020101+Q_221000001*PR_000002020200+Q_221000101*PR_000002020201+Q_321000001*PR_000002020300+Q_321000101*PR_000002020301); ans_temp[ans_id*36+30]+=Pmtrx[16]*(Q_020001001*PR_000002020000+Q_020001101*PR_000002020001+Q_020101001*PR_000002020010+Q_020101101*PR_000002020011+Q_120001001*PR_000002020100+Q_120001101*PR_000002020101+Q_120101001*PR_000002020110+Q_120101101*PR_000002020111+Q_220001001*PR_000002020200+Q_220001101*PR_000002020201+Q_220101001*PR_000002020210+Q_220101101*PR_000002020211); ans_temp[ans_id*36+30]+=Pmtrx[17]*(Q_020000002*PR_000002020000+Q_020000102*PR_000002020001+Q_020000202*PR_000002020002+Q_120000002*PR_000002020100+Q_120000102*PR_000002020101+Q_120000202*PR_000002020102+Q_220000002*PR_000002020200+Q_220000102*PR_000002020201+Q_220000202*PR_000002020202); ans_temp[ans_id*36+31]+=Pmtrx[12]*(Q_012010000*PR_000002020000+Q_012110000*PR_000002020010+Q_112010000*PR_000002020100+Q_112110000*PR_000002020110+Q_212010000*PR_000002020200+Q_212110000*PR_000002020210+Q_312010000*PR_000002020300+Q_312110000*PR_000002020310); ans_temp[ans_id*36+31]+=Pmtrx[13]*(Q_011011000*PR_000002020000+Q_011111000*PR_000002020010+Q_011211000*PR_000002020020+Q_111011000*PR_000002020100+Q_111111000*PR_000002020110+Q_111211000*PR_000002020120+Q_211011000*PR_000002020200+Q_211111000*PR_000002020210+Q_211211000*PR_000002020220); ans_temp[ans_id*36+31]+=Pmtrx[14]*(Q_010012000*PR_000002020000+Q_010112000*PR_000002020010+Q_010212000*PR_000002020020+Q_010312000*PR_000002020030+Q_110012000*PR_000002020100+Q_110112000*PR_000002020110+Q_110212000*PR_000002020120+Q_110312000*PR_000002020130); ans_temp[ans_id*36+31]+=Pmtrx[15]*(Q_011010001*PR_000002020000+Q_011010101*PR_000002020001+Q_011110001*PR_000002020010+Q_011110101*PR_000002020011+Q_111010001*PR_000002020100+Q_111010101*PR_000002020101+Q_111110001*PR_000002020110+Q_111110101*PR_000002020111+Q_211010001*PR_000002020200+Q_211010101*PR_000002020201+Q_211110001*PR_000002020210+Q_211110101*PR_000002020211); ans_temp[ans_id*36+31]+=Pmtrx[16]*(Q_010011001*PR_000002020000+Q_010011101*PR_000002020001+Q_010111001*PR_000002020010+Q_010111101*PR_000002020011+Q_010211001*PR_000002020020+Q_010211101*PR_000002020021+Q_110011001*PR_000002020100+Q_110011101*PR_000002020101+Q_110111001*PR_000002020110+Q_110111101*PR_000002020111+Q_110211001*PR_000002020120+Q_110211101*PR_000002020121); ans_temp[ans_id*36+31]+=Pmtrx[17]*(Q_010010002*PR_000002020000+Q_010010102*PR_000002020001+Q_010010202*PR_000002020002+Q_010110002*PR_000002020010+Q_010110102*PR_000002020011+Q_010110202*PR_000002020012+Q_110010002*PR_000002020100+Q_110010102*PR_000002020101+Q_110010202*PR_000002020102+Q_110110002*PR_000002020110+Q_110110102*PR_000002020111+Q_110110202*PR_000002020112); ans_temp[ans_id*36+32]+=Pmtrx[12]*(Q_002020000*PR_000002020000+Q_002120000*PR_000002020010+Q_002220000*PR_000002020020+Q_102020000*PR_000002020100+Q_102120000*PR_000002020110+Q_102220000*PR_000002020120+Q_202020000*PR_000002020200+Q_202120000*PR_000002020210+Q_202220000*PR_000002020220); ans_temp[ans_id*36+32]+=Pmtrx[13]*(Q_001021000*PR_000002020000+Q_001121000*PR_000002020010+Q_001221000*PR_000002020020+Q_001321000*PR_000002020030+Q_101021000*PR_000002020100+Q_101121000*PR_000002020110+Q_101221000*PR_000002020120+Q_101321000*PR_000002020130); ans_temp[ans_id*36+32]+=Pmtrx[14]*(Q_000022000*PR_000002020000+Q_000122000*PR_000002020010+Q_000222000*PR_000002020020+Q_000322000*PR_000002020030+Q_000422000*PR_000002020040); ans_temp[ans_id*36+32]+=Pmtrx[15]*(Q_001020001*PR_000002020000+Q_001020101*PR_000002020001+Q_001120001*PR_000002020010+Q_001120101*PR_000002020011+Q_001220001*PR_000002020020+Q_001220101*PR_000002020021+Q_101020001*PR_000002020100+Q_101020101*PR_000002020101+Q_101120001*PR_000002020110+Q_101120101*PR_000002020111+Q_101220001*PR_000002020120+Q_101220101*PR_000002020121); ans_temp[ans_id*36+32]+=Pmtrx[16]*(Q_000021001*PR_000002020000+Q_000021101*PR_000002020001+Q_000121001*PR_000002020010+Q_000121101*PR_000002020011+Q_000221001*PR_000002020020+Q_000221101*PR_000002020021+Q_000321001*PR_000002020030+Q_000321101*PR_000002020031); ans_temp[ans_id*36+32]+=Pmtrx[17]*(Q_000020002*PR_000002020000+Q_000020102*PR_000002020001+Q_000020202*PR_000002020002+Q_000120002*PR_000002020010+Q_000120102*PR_000002020011+Q_000120202*PR_000002020012+Q_000220002*PR_000002020020+Q_000220102*PR_000002020021+Q_000220202*PR_000002020022); ans_temp[ans_id*36+33]+=Pmtrx[12]*(Q_012000010*PR_000002020000+Q_012000110*PR_000002020001+Q_112000010*PR_000002020100+Q_112000110*PR_000002020101+Q_212000010*PR_000002020200+Q_212000110*PR_000002020201+Q_312000010*PR_000002020300+Q_312000110*PR_000002020301); ans_temp[ans_id*36+33]+=Pmtrx[13]*(Q_011001010*PR_000002020000+Q_011001110*PR_000002020001+Q_011101010*PR_000002020010+Q_011101110*PR_000002020011+Q_111001010*PR_000002020100+Q_111001110*PR_000002020101+Q_111101010*PR_000002020110+Q_111101110*PR_000002020111+Q_211001010*PR_000002020200+Q_211001110*PR_000002020201+Q_211101010*PR_000002020210+Q_211101110*PR_000002020211); ans_temp[ans_id*36+33]+=Pmtrx[14]*(Q_010002010*PR_000002020000+Q_010002110*PR_000002020001+Q_010102010*PR_000002020010+Q_010102110*PR_000002020011+Q_010202010*PR_000002020020+Q_010202110*PR_000002020021+Q_110002010*PR_000002020100+Q_110002110*PR_000002020101+Q_110102010*PR_000002020110+Q_110102110*PR_000002020111+Q_110202010*PR_000002020120+Q_110202110*PR_000002020121); ans_temp[ans_id*36+33]+=Pmtrx[15]*(Q_011000011*PR_000002020000+Q_011000111*PR_000002020001+Q_011000211*PR_000002020002+Q_111000011*PR_000002020100+Q_111000111*PR_000002020101+Q_111000211*PR_000002020102+Q_211000011*PR_000002020200+Q_211000111*PR_000002020201+Q_211000211*PR_000002020202); ans_temp[ans_id*36+33]+=Pmtrx[16]*(Q_010001011*PR_000002020000+Q_010001111*PR_000002020001+Q_010001211*PR_000002020002+Q_010101011*PR_000002020010+Q_010101111*PR_000002020011+Q_010101211*PR_000002020012+Q_110001011*PR_000002020100+Q_110001111*PR_000002020101+Q_110001211*PR_000002020102+Q_110101011*PR_000002020110+Q_110101111*PR_000002020111+Q_110101211*PR_000002020112); ans_temp[ans_id*36+33]+=Pmtrx[17]*(Q_010000012*PR_000002020000+Q_010000112*PR_000002020001+Q_010000212*PR_000002020002+Q_010000312*PR_000002020003+Q_110000012*PR_000002020100+Q_110000112*PR_000002020101+Q_110000212*PR_000002020102+Q_110000312*PR_000002020103); ans_temp[ans_id*36+34]+=Pmtrx[12]*(Q_002010010*PR_000002020000+Q_002010110*PR_000002020001+Q_002110010*PR_000002020010+Q_002110110*PR_000002020011+Q_102010010*PR_000002020100+Q_102010110*PR_000002020101+Q_102110010*PR_000002020110+Q_102110110*PR_000002020111+Q_202010010*PR_000002020200+Q_202010110*PR_000002020201+Q_202110010*PR_000002020210+Q_202110110*PR_000002020211); ans_temp[ans_id*36+34]+=Pmtrx[13]*(Q_001011010*PR_000002020000+Q_001011110*PR_000002020001+Q_001111010*PR_000002020010+Q_001111110*PR_000002020011+Q_001211010*PR_000002020020+Q_001211110*PR_000002020021+Q_101011010*PR_000002020100+Q_101011110*PR_000002020101+Q_101111010*PR_000002020110+Q_101111110*PR_000002020111+Q_101211010*PR_000002020120+Q_101211110*PR_000002020121); ans_temp[ans_id*36+34]+=Pmtrx[14]*(Q_000012010*PR_000002020000+Q_000012110*PR_000002020001+Q_000112010*PR_000002020010+Q_000112110*PR_000002020011+Q_000212010*PR_000002020020+Q_000212110*PR_000002020021+Q_000312010*PR_000002020030+Q_000312110*PR_000002020031); ans_temp[ans_id*36+34]+=Pmtrx[15]*(Q_001010011*PR_000002020000+Q_001010111*PR_000002020001+Q_001010211*PR_000002020002+Q_001110011*PR_000002020010+Q_001110111*PR_000002020011+Q_001110211*PR_000002020012+Q_101010011*PR_000002020100+Q_101010111*PR_000002020101+Q_101010211*PR_000002020102+Q_101110011*PR_000002020110+Q_101110111*PR_000002020111+Q_101110211*PR_000002020112); ans_temp[ans_id*36+34]+=Pmtrx[16]*(Q_000011011*PR_000002020000+Q_000011111*PR_000002020001+Q_000011211*PR_000002020002+Q_000111011*PR_000002020010+Q_000111111*PR_000002020011+Q_000111211*PR_000002020012+Q_000211011*PR_000002020020+Q_000211111*PR_000002020021+Q_000211211*PR_000002020022); ans_temp[ans_id*36+34]+=Pmtrx[17]*(Q_000010012*PR_000002020000+Q_000010112*PR_000002020001+Q_000010212*PR_000002020002+Q_000010312*PR_000002020003+Q_000110012*PR_000002020010+Q_000110112*PR_000002020011+Q_000110212*PR_000002020012+Q_000110312*PR_000002020013); ans_temp[ans_id*36+35]+=Pmtrx[12]*(Q_002000020*PR_000002020000+Q_002000120*PR_000002020001+Q_002000220*PR_000002020002+Q_102000020*PR_000002020100+Q_102000120*PR_000002020101+Q_102000220*PR_000002020102+Q_202000020*PR_000002020200+Q_202000120*PR_000002020201+Q_202000220*PR_000002020202); ans_temp[ans_id*36+35]+=Pmtrx[13]*(Q_001001020*PR_000002020000+Q_001001120*PR_000002020001+Q_001001220*PR_000002020002+Q_001101020*PR_000002020010+Q_001101120*PR_000002020011+Q_001101220*PR_000002020012+Q_101001020*PR_000002020100+Q_101001120*PR_000002020101+Q_101001220*PR_000002020102+Q_101101020*PR_000002020110+Q_101101120*PR_000002020111+Q_101101220*PR_000002020112); ans_temp[ans_id*36+35]+=Pmtrx[14]*(Q_000002020*PR_000002020000+Q_000002120*PR_000002020001+Q_000002220*PR_000002020002+Q_000102020*PR_000002020010+Q_000102120*PR_000002020011+Q_000102220*PR_000002020012+Q_000202020*PR_000002020020+Q_000202120*PR_000002020021+Q_000202220*PR_000002020022); ans_temp[ans_id*36+35]+=Pmtrx[15]*(Q_001000021*PR_000002020000+Q_001000121*PR_000002020001+Q_001000221*PR_000002020002+Q_001000321*PR_000002020003+Q_101000021*PR_000002020100+Q_101000121*PR_000002020101+Q_101000221*PR_000002020102+Q_101000321*PR_000002020103); ans_temp[ans_id*36+35]+=Pmtrx[16]*(Q_000001021*PR_000002020000+Q_000001121*PR_000002020001+Q_000001221*PR_000002020002+Q_000001321*PR_000002020003+Q_000101021*PR_000002020010+Q_000101121*PR_000002020011+Q_000101221*PR_000002020012+Q_000101321*PR_000002020013); ans_temp[ans_id*36+35]+=Pmtrx[17]*(Q_000000022*PR_000002020000+Q_000000122*PR_000002020001+Q_000000222*PR_000002020002+Q_000000322*PR_000002020003+Q_000000422*PR_000002020004); ans_temp[ans_id*36+30]+=Pmtrx[18]*(Q_022000000*PR_001000021000+Q_122000000*PR_001000021100+Q_222000000*PR_001000021200+Q_322000000*PR_001000021300+Q_422000000*PR_001000021400); ans_temp[ans_id*36+30]+=Pmtrx[19]*(Q_021001000*PR_001000021000+Q_021101000*PR_001000021010+Q_121001000*PR_001000021100+Q_121101000*PR_001000021110+Q_221001000*PR_001000021200+Q_221101000*PR_001000021210+Q_321001000*PR_001000021300+Q_321101000*PR_001000021310); ans_temp[ans_id*36+30]+=Pmtrx[20]*(Q_020002000*PR_001000021000+Q_020102000*PR_001000021010+Q_020202000*PR_001000021020+Q_120002000*PR_001000021100+Q_120102000*PR_001000021110+Q_120202000*PR_001000021120+Q_220002000*PR_001000021200+Q_220102000*PR_001000021210+Q_220202000*PR_001000021220); ans_temp[ans_id*36+30]+=Pmtrx[21]*(Q_021000001*PR_001000021000+Q_021000101*PR_001000021001+Q_121000001*PR_001000021100+Q_121000101*PR_001000021101+Q_221000001*PR_001000021200+Q_221000101*PR_001000021201+Q_321000001*PR_001000021300+Q_321000101*PR_001000021301); ans_temp[ans_id*36+30]+=Pmtrx[22]*(Q_020001001*PR_001000021000+Q_020001101*PR_001000021001+Q_020101001*PR_001000021010+Q_020101101*PR_001000021011+Q_120001001*PR_001000021100+Q_120001101*PR_001000021101+Q_120101001*PR_001000021110+Q_120101101*PR_001000021111+Q_220001001*PR_001000021200+Q_220001101*PR_001000021201+Q_220101001*PR_001000021210+Q_220101101*PR_001000021211); ans_temp[ans_id*36+30]+=Pmtrx[23]*(Q_020000002*PR_001000021000+Q_020000102*PR_001000021001+Q_020000202*PR_001000021002+Q_120000002*PR_001000021100+Q_120000102*PR_001000021101+Q_120000202*PR_001000021102+Q_220000002*PR_001000021200+Q_220000102*PR_001000021201+Q_220000202*PR_001000021202); ans_temp[ans_id*36+31]+=Pmtrx[18]*(Q_012010000*PR_001000021000+Q_012110000*PR_001000021010+Q_112010000*PR_001000021100+Q_112110000*PR_001000021110+Q_212010000*PR_001000021200+Q_212110000*PR_001000021210+Q_312010000*PR_001000021300+Q_312110000*PR_001000021310); ans_temp[ans_id*36+31]+=Pmtrx[19]*(Q_011011000*PR_001000021000+Q_011111000*PR_001000021010+Q_011211000*PR_001000021020+Q_111011000*PR_001000021100+Q_111111000*PR_001000021110+Q_111211000*PR_001000021120+Q_211011000*PR_001000021200+Q_211111000*PR_001000021210+Q_211211000*PR_001000021220); ans_temp[ans_id*36+31]+=Pmtrx[20]*(Q_010012000*PR_001000021000+Q_010112000*PR_001000021010+Q_010212000*PR_001000021020+Q_010312000*PR_001000021030+Q_110012000*PR_001000021100+Q_110112000*PR_001000021110+Q_110212000*PR_001000021120+Q_110312000*PR_001000021130); ans_temp[ans_id*36+31]+=Pmtrx[21]*(Q_011010001*PR_001000021000+Q_011010101*PR_001000021001+Q_011110001*PR_001000021010+Q_011110101*PR_001000021011+Q_111010001*PR_001000021100+Q_111010101*PR_001000021101+Q_111110001*PR_001000021110+Q_111110101*PR_001000021111+Q_211010001*PR_001000021200+Q_211010101*PR_001000021201+Q_211110001*PR_001000021210+Q_211110101*PR_001000021211); ans_temp[ans_id*36+31]+=Pmtrx[22]*(Q_010011001*PR_001000021000+Q_010011101*PR_001000021001+Q_010111001*PR_001000021010+Q_010111101*PR_001000021011+Q_010211001*PR_001000021020+Q_010211101*PR_001000021021+Q_110011001*PR_001000021100+Q_110011101*PR_001000021101+Q_110111001*PR_001000021110+Q_110111101*PR_001000021111+Q_110211001*PR_001000021120+Q_110211101*PR_001000021121); ans_temp[ans_id*36+31]+=Pmtrx[23]*(Q_010010002*PR_001000021000+Q_010010102*PR_001000021001+Q_010010202*PR_001000021002+Q_010110002*PR_001000021010+Q_010110102*PR_001000021011+Q_010110202*PR_001000021012+Q_110010002*PR_001000021100+Q_110010102*PR_001000021101+Q_110010202*PR_001000021102+Q_110110002*PR_001000021110+Q_110110102*PR_001000021111+Q_110110202*PR_001000021112); ans_temp[ans_id*36+32]+=Pmtrx[18]*(Q_002020000*PR_001000021000+Q_002120000*PR_001000021010+Q_002220000*PR_001000021020+Q_102020000*PR_001000021100+Q_102120000*PR_001000021110+Q_102220000*PR_001000021120+Q_202020000*PR_001000021200+Q_202120000*PR_001000021210+Q_202220000*PR_001000021220); ans_temp[ans_id*36+32]+=Pmtrx[19]*(Q_001021000*PR_001000021000+Q_001121000*PR_001000021010+Q_001221000*PR_001000021020+Q_001321000*PR_001000021030+Q_101021000*PR_001000021100+Q_101121000*PR_001000021110+Q_101221000*PR_001000021120+Q_101321000*PR_001000021130); ans_temp[ans_id*36+32]+=Pmtrx[20]*(Q_000022000*PR_001000021000+Q_000122000*PR_001000021010+Q_000222000*PR_001000021020+Q_000322000*PR_001000021030+Q_000422000*PR_001000021040); ans_temp[ans_id*36+32]+=Pmtrx[21]*(Q_001020001*PR_001000021000+Q_001020101*PR_001000021001+Q_001120001*PR_001000021010+Q_001120101*PR_001000021011+Q_001220001*PR_001000021020+Q_001220101*PR_001000021021+Q_101020001*PR_001000021100+Q_101020101*PR_001000021101+Q_101120001*PR_001000021110+Q_101120101*PR_001000021111+Q_101220001*PR_001000021120+Q_101220101*PR_001000021121); ans_temp[ans_id*36+32]+=Pmtrx[22]*(Q_000021001*PR_001000021000+Q_000021101*PR_001000021001+Q_000121001*PR_001000021010+Q_000121101*PR_001000021011+Q_000221001*PR_001000021020+Q_000221101*PR_001000021021+Q_000321001*PR_001000021030+Q_000321101*PR_001000021031); ans_temp[ans_id*36+32]+=Pmtrx[23]*(Q_000020002*PR_001000021000+Q_000020102*PR_001000021001+Q_000020202*PR_001000021002+Q_000120002*PR_001000021010+Q_000120102*PR_001000021011+Q_000120202*PR_001000021012+Q_000220002*PR_001000021020+Q_000220102*PR_001000021021+Q_000220202*PR_001000021022); ans_temp[ans_id*36+33]+=Pmtrx[18]*(Q_012000010*PR_001000021000+Q_012000110*PR_001000021001+Q_112000010*PR_001000021100+Q_112000110*PR_001000021101+Q_212000010*PR_001000021200+Q_212000110*PR_001000021201+Q_312000010*PR_001000021300+Q_312000110*PR_001000021301); ans_temp[ans_id*36+33]+=Pmtrx[19]*(Q_011001010*PR_001000021000+Q_011001110*PR_001000021001+Q_011101010*PR_001000021010+Q_011101110*PR_001000021011+Q_111001010*PR_001000021100+Q_111001110*PR_001000021101+Q_111101010*PR_001000021110+Q_111101110*PR_001000021111+Q_211001010*PR_001000021200+Q_211001110*PR_001000021201+Q_211101010*PR_001000021210+Q_211101110*PR_001000021211); ans_temp[ans_id*36+33]+=Pmtrx[20]*(Q_010002010*PR_001000021000+Q_010002110*PR_001000021001+Q_010102010*PR_001000021010+Q_010102110*PR_001000021011+Q_010202010*PR_001000021020+Q_010202110*PR_001000021021+Q_110002010*PR_001000021100+Q_110002110*PR_001000021101+Q_110102010*PR_001000021110+Q_110102110*PR_001000021111+Q_110202010*PR_001000021120+Q_110202110*PR_001000021121); ans_temp[ans_id*36+33]+=Pmtrx[21]*(Q_011000011*PR_001000021000+Q_011000111*PR_001000021001+Q_011000211*PR_001000021002+Q_111000011*PR_001000021100+Q_111000111*PR_001000021101+Q_111000211*PR_001000021102+Q_211000011*PR_001000021200+Q_211000111*PR_001000021201+Q_211000211*PR_001000021202); ans_temp[ans_id*36+33]+=Pmtrx[22]*(Q_010001011*PR_001000021000+Q_010001111*PR_001000021001+Q_010001211*PR_001000021002+Q_010101011*PR_001000021010+Q_010101111*PR_001000021011+Q_010101211*PR_001000021012+Q_110001011*PR_001000021100+Q_110001111*PR_001000021101+Q_110001211*PR_001000021102+Q_110101011*PR_001000021110+Q_110101111*PR_001000021111+Q_110101211*PR_001000021112); ans_temp[ans_id*36+33]+=Pmtrx[23]*(Q_010000012*PR_001000021000+Q_010000112*PR_001000021001+Q_010000212*PR_001000021002+Q_010000312*PR_001000021003+Q_110000012*PR_001000021100+Q_110000112*PR_001000021101+Q_110000212*PR_001000021102+Q_110000312*PR_001000021103); ans_temp[ans_id*36+34]+=Pmtrx[18]*(Q_002010010*PR_001000021000+Q_002010110*PR_001000021001+Q_002110010*PR_001000021010+Q_002110110*PR_001000021011+Q_102010010*PR_001000021100+Q_102010110*PR_001000021101+Q_102110010*PR_001000021110+Q_102110110*PR_001000021111+Q_202010010*PR_001000021200+Q_202010110*PR_001000021201+Q_202110010*PR_001000021210+Q_202110110*PR_001000021211); ans_temp[ans_id*36+34]+=Pmtrx[19]*(Q_001011010*PR_001000021000+Q_001011110*PR_001000021001+Q_001111010*PR_001000021010+Q_001111110*PR_001000021011+Q_001211010*PR_001000021020+Q_001211110*PR_001000021021+Q_101011010*PR_001000021100+Q_101011110*PR_001000021101+Q_101111010*PR_001000021110+Q_101111110*PR_001000021111+Q_101211010*PR_001000021120+Q_101211110*PR_001000021121); ans_temp[ans_id*36+34]+=Pmtrx[20]*(Q_000012010*PR_001000021000+Q_000012110*PR_001000021001+Q_000112010*PR_001000021010+Q_000112110*PR_001000021011+Q_000212010*PR_001000021020+Q_000212110*PR_001000021021+Q_000312010*PR_001000021030+Q_000312110*PR_001000021031); ans_temp[ans_id*36+34]+=Pmtrx[21]*(Q_001010011*PR_001000021000+Q_001010111*PR_001000021001+Q_001010211*PR_001000021002+Q_001110011*PR_001000021010+Q_001110111*PR_001000021011+Q_001110211*PR_001000021012+Q_101010011*PR_001000021100+Q_101010111*PR_001000021101+Q_101010211*PR_001000021102+Q_101110011*PR_001000021110+Q_101110111*PR_001000021111+Q_101110211*PR_001000021112); ans_temp[ans_id*36+34]+=Pmtrx[22]*(Q_000011011*PR_001000021000+Q_000011111*PR_001000021001+Q_000011211*PR_001000021002+Q_000111011*PR_001000021010+Q_000111111*PR_001000021011+Q_000111211*PR_001000021012+Q_000211011*PR_001000021020+Q_000211111*PR_001000021021+Q_000211211*PR_001000021022); ans_temp[ans_id*36+34]+=Pmtrx[23]*(Q_000010012*PR_001000021000+Q_000010112*PR_001000021001+Q_000010212*PR_001000021002+Q_000010312*PR_001000021003+Q_000110012*PR_001000021010+Q_000110112*PR_001000021011+Q_000110212*PR_001000021012+Q_000110312*PR_001000021013); ans_temp[ans_id*36+35]+=Pmtrx[18]*(Q_002000020*PR_001000021000+Q_002000120*PR_001000021001+Q_002000220*PR_001000021002+Q_102000020*PR_001000021100+Q_102000120*PR_001000021101+Q_102000220*PR_001000021102+Q_202000020*PR_001000021200+Q_202000120*PR_001000021201+Q_202000220*PR_001000021202); ans_temp[ans_id*36+35]+=Pmtrx[19]*(Q_001001020*PR_001000021000+Q_001001120*PR_001000021001+Q_001001220*PR_001000021002+Q_001101020*PR_001000021010+Q_001101120*PR_001000021011+Q_001101220*PR_001000021012+Q_101001020*PR_001000021100+Q_101001120*PR_001000021101+Q_101001220*PR_001000021102+Q_101101020*PR_001000021110+Q_101101120*PR_001000021111+Q_101101220*PR_001000021112); ans_temp[ans_id*36+35]+=Pmtrx[20]*(Q_000002020*PR_001000021000+Q_000002120*PR_001000021001+Q_000002220*PR_001000021002+Q_000102020*PR_001000021010+Q_000102120*PR_001000021011+Q_000102220*PR_001000021012+Q_000202020*PR_001000021020+Q_000202120*PR_001000021021+Q_000202220*PR_001000021022); ans_temp[ans_id*36+35]+=Pmtrx[21]*(Q_001000021*PR_001000021000+Q_001000121*PR_001000021001+Q_001000221*PR_001000021002+Q_001000321*PR_001000021003+Q_101000021*PR_001000021100+Q_101000121*PR_001000021101+Q_101000221*PR_001000021102+Q_101000321*PR_001000021103); ans_temp[ans_id*36+35]+=Pmtrx[22]*(Q_000001021*PR_001000021000+Q_000001121*PR_001000021001+Q_000001221*PR_001000021002+Q_000001321*PR_001000021003+Q_000101021*PR_001000021010+Q_000101121*PR_001000021011+Q_000101221*PR_001000021012+Q_000101321*PR_001000021013); ans_temp[ans_id*36+35]+=Pmtrx[23]*(Q_000000022*PR_001000021000+Q_000000122*PR_001000021001+Q_000000222*PR_001000021002+Q_000000322*PR_001000021003+Q_000000422*PR_001000021004); ans_temp[ans_id*36+30]+=Pmtrx[24]*(Q_022000000*PR_000001021000+Q_122000000*PR_000001021100+Q_222000000*PR_000001021200+Q_322000000*PR_000001021300+Q_422000000*PR_000001021400); ans_temp[ans_id*36+30]+=Pmtrx[25]*(Q_021001000*PR_000001021000+Q_021101000*PR_000001021010+Q_121001000*PR_000001021100+Q_121101000*PR_000001021110+Q_221001000*PR_000001021200+Q_221101000*PR_000001021210+Q_321001000*PR_000001021300+Q_321101000*PR_000001021310); ans_temp[ans_id*36+30]+=Pmtrx[26]*(Q_020002000*PR_000001021000+Q_020102000*PR_000001021010+Q_020202000*PR_000001021020+Q_120002000*PR_000001021100+Q_120102000*PR_000001021110+Q_120202000*PR_000001021120+Q_220002000*PR_000001021200+Q_220102000*PR_000001021210+Q_220202000*PR_000001021220); ans_temp[ans_id*36+30]+=Pmtrx[27]*(Q_021000001*PR_000001021000+Q_021000101*PR_000001021001+Q_121000001*PR_000001021100+Q_121000101*PR_000001021101+Q_221000001*PR_000001021200+Q_221000101*PR_000001021201+Q_321000001*PR_000001021300+Q_321000101*PR_000001021301); ans_temp[ans_id*36+30]+=Pmtrx[28]*(Q_020001001*PR_000001021000+Q_020001101*PR_000001021001+Q_020101001*PR_000001021010+Q_020101101*PR_000001021011+Q_120001001*PR_000001021100+Q_120001101*PR_000001021101+Q_120101001*PR_000001021110+Q_120101101*PR_000001021111+Q_220001001*PR_000001021200+Q_220001101*PR_000001021201+Q_220101001*PR_000001021210+Q_220101101*PR_000001021211); ans_temp[ans_id*36+30]+=Pmtrx[29]*(Q_020000002*PR_000001021000+Q_020000102*PR_000001021001+Q_020000202*PR_000001021002+Q_120000002*PR_000001021100+Q_120000102*PR_000001021101+Q_120000202*PR_000001021102+Q_220000002*PR_000001021200+Q_220000102*PR_000001021201+Q_220000202*PR_000001021202); ans_temp[ans_id*36+31]+=Pmtrx[24]*(Q_012010000*PR_000001021000+Q_012110000*PR_000001021010+Q_112010000*PR_000001021100+Q_112110000*PR_000001021110+Q_212010000*PR_000001021200+Q_212110000*PR_000001021210+Q_312010000*PR_000001021300+Q_312110000*PR_000001021310); ans_temp[ans_id*36+31]+=Pmtrx[25]*(Q_011011000*PR_000001021000+Q_011111000*PR_000001021010+Q_011211000*PR_000001021020+Q_111011000*PR_000001021100+Q_111111000*PR_000001021110+Q_111211000*PR_000001021120+Q_211011000*PR_000001021200+Q_211111000*PR_000001021210+Q_211211000*PR_000001021220); ans_temp[ans_id*36+31]+=Pmtrx[26]*(Q_010012000*PR_000001021000+Q_010112000*PR_000001021010+Q_010212000*PR_000001021020+Q_010312000*PR_000001021030+Q_110012000*PR_000001021100+Q_110112000*PR_000001021110+Q_110212000*PR_000001021120+Q_110312000*PR_000001021130); ans_temp[ans_id*36+31]+=Pmtrx[27]*(Q_011010001*PR_000001021000+Q_011010101*PR_000001021001+Q_011110001*PR_000001021010+Q_011110101*PR_000001021011+Q_111010001*PR_000001021100+Q_111010101*PR_000001021101+Q_111110001*PR_000001021110+Q_111110101*PR_000001021111+Q_211010001*PR_000001021200+Q_211010101*PR_000001021201+Q_211110001*PR_000001021210+Q_211110101*PR_000001021211); ans_temp[ans_id*36+31]+=Pmtrx[28]*(Q_010011001*PR_000001021000+Q_010011101*PR_000001021001+Q_010111001*PR_000001021010+Q_010111101*PR_000001021011+Q_010211001*PR_000001021020+Q_010211101*PR_000001021021+Q_110011001*PR_000001021100+Q_110011101*PR_000001021101+Q_110111001*PR_000001021110+Q_110111101*PR_000001021111+Q_110211001*PR_000001021120+Q_110211101*PR_000001021121); ans_temp[ans_id*36+31]+=Pmtrx[29]*(Q_010010002*PR_000001021000+Q_010010102*PR_000001021001+Q_010010202*PR_000001021002+Q_010110002*PR_000001021010+Q_010110102*PR_000001021011+Q_010110202*PR_000001021012+Q_110010002*PR_000001021100+Q_110010102*PR_000001021101+Q_110010202*PR_000001021102+Q_110110002*PR_000001021110+Q_110110102*PR_000001021111+Q_110110202*PR_000001021112); ans_temp[ans_id*36+32]+=Pmtrx[24]*(Q_002020000*PR_000001021000+Q_002120000*PR_000001021010+Q_002220000*PR_000001021020+Q_102020000*PR_000001021100+Q_102120000*PR_000001021110+Q_102220000*PR_000001021120+Q_202020000*PR_000001021200+Q_202120000*PR_000001021210+Q_202220000*PR_000001021220); ans_temp[ans_id*36+32]+=Pmtrx[25]*(Q_001021000*PR_000001021000+Q_001121000*PR_000001021010+Q_001221000*PR_000001021020+Q_001321000*PR_000001021030+Q_101021000*PR_000001021100+Q_101121000*PR_000001021110+Q_101221000*PR_000001021120+Q_101321000*PR_000001021130); ans_temp[ans_id*36+32]+=Pmtrx[26]*(Q_000022000*PR_000001021000+Q_000122000*PR_000001021010+Q_000222000*PR_000001021020+Q_000322000*PR_000001021030+Q_000422000*PR_000001021040); ans_temp[ans_id*36+32]+=Pmtrx[27]*(Q_001020001*PR_000001021000+Q_001020101*PR_000001021001+Q_001120001*PR_000001021010+Q_001120101*PR_000001021011+Q_001220001*PR_000001021020+Q_001220101*PR_000001021021+Q_101020001*PR_000001021100+Q_101020101*PR_000001021101+Q_101120001*PR_000001021110+Q_101120101*PR_000001021111+Q_101220001*PR_000001021120+Q_101220101*PR_000001021121); ans_temp[ans_id*36+32]+=Pmtrx[28]*(Q_000021001*PR_000001021000+Q_000021101*PR_000001021001+Q_000121001*PR_000001021010+Q_000121101*PR_000001021011+Q_000221001*PR_000001021020+Q_000221101*PR_000001021021+Q_000321001*PR_000001021030+Q_000321101*PR_000001021031); ans_temp[ans_id*36+32]+=Pmtrx[29]*(Q_000020002*PR_000001021000+Q_000020102*PR_000001021001+Q_000020202*PR_000001021002+Q_000120002*PR_000001021010+Q_000120102*PR_000001021011+Q_000120202*PR_000001021012+Q_000220002*PR_000001021020+Q_000220102*PR_000001021021+Q_000220202*PR_000001021022); ans_temp[ans_id*36+33]+=Pmtrx[24]*(Q_012000010*PR_000001021000+Q_012000110*PR_000001021001+Q_112000010*PR_000001021100+Q_112000110*PR_000001021101+Q_212000010*PR_000001021200+Q_212000110*PR_000001021201+Q_312000010*PR_000001021300+Q_312000110*PR_000001021301); ans_temp[ans_id*36+33]+=Pmtrx[25]*(Q_011001010*PR_000001021000+Q_011001110*PR_000001021001+Q_011101010*PR_000001021010+Q_011101110*PR_000001021011+Q_111001010*PR_000001021100+Q_111001110*PR_000001021101+Q_111101010*PR_000001021110+Q_111101110*PR_000001021111+Q_211001010*PR_000001021200+Q_211001110*PR_000001021201+Q_211101010*PR_000001021210+Q_211101110*PR_000001021211); ans_temp[ans_id*36+33]+=Pmtrx[26]*(Q_010002010*PR_000001021000+Q_010002110*PR_000001021001+Q_010102010*PR_000001021010+Q_010102110*PR_000001021011+Q_010202010*PR_000001021020+Q_010202110*PR_000001021021+Q_110002010*PR_000001021100+Q_110002110*PR_000001021101+Q_110102010*PR_000001021110+Q_110102110*PR_000001021111+Q_110202010*PR_000001021120+Q_110202110*PR_000001021121); ans_temp[ans_id*36+33]+=Pmtrx[27]*(Q_011000011*PR_000001021000+Q_011000111*PR_000001021001+Q_011000211*PR_000001021002+Q_111000011*PR_000001021100+Q_111000111*PR_000001021101+Q_111000211*PR_000001021102+Q_211000011*PR_000001021200+Q_211000111*PR_000001021201+Q_211000211*PR_000001021202); ans_temp[ans_id*36+33]+=Pmtrx[28]*(Q_010001011*PR_000001021000+Q_010001111*PR_000001021001+Q_010001211*PR_000001021002+Q_010101011*PR_000001021010+Q_010101111*PR_000001021011+Q_010101211*PR_000001021012+Q_110001011*PR_000001021100+Q_110001111*PR_000001021101+Q_110001211*PR_000001021102+Q_110101011*PR_000001021110+Q_110101111*PR_000001021111+Q_110101211*PR_000001021112); ans_temp[ans_id*36+33]+=Pmtrx[29]*(Q_010000012*PR_000001021000+Q_010000112*PR_000001021001+Q_010000212*PR_000001021002+Q_010000312*PR_000001021003+Q_110000012*PR_000001021100+Q_110000112*PR_000001021101+Q_110000212*PR_000001021102+Q_110000312*PR_000001021103); ans_temp[ans_id*36+34]+=Pmtrx[24]*(Q_002010010*PR_000001021000+Q_002010110*PR_000001021001+Q_002110010*PR_000001021010+Q_002110110*PR_000001021011+Q_102010010*PR_000001021100+Q_102010110*PR_000001021101+Q_102110010*PR_000001021110+Q_102110110*PR_000001021111+Q_202010010*PR_000001021200+Q_202010110*PR_000001021201+Q_202110010*PR_000001021210+Q_202110110*PR_000001021211); ans_temp[ans_id*36+34]+=Pmtrx[25]*(Q_001011010*PR_000001021000+Q_001011110*PR_000001021001+Q_001111010*PR_000001021010+Q_001111110*PR_000001021011+Q_001211010*PR_000001021020+Q_001211110*PR_000001021021+Q_101011010*PR_000001021100+Q_101011110*PR_000001021101+Q_101111010*PR_000001021110+Q_101111110*PR_000001021111+Q_101211010*PR_000001021120+Q_101211110*PR_000001021121); ans_temp[ans_id*36+34]+=Pmtrx[26]*(Q_000012010*PR_000001021000+Q_000012110*PR_000001021001+Q_000112010*PR_000001021010+Q_000112110*PR_000001021011+Q_000212010*PR_000001021020+Q_000212110*PR_000001021021+Q_000312010*PR_000001021030+Q_000312110*PR_000001021031); ans_temp[ans_id*36+34]+=Pmtrx[27]*(Q_001010011*PR_000001021000+Q_001010111*PR_000001021001+Q_001010211*PR_000001021002+Q_001110011*PR_000001021010+Q_001110111*PR_000001021011+Q_001110211*PR_000001021012+Q_101010011*PR_000001021100+Q_101010111*PR_000001021101+Q_101010211*PR_000001021102+Q_101110011*PR_000001021110+Q_101110111*PR_000001021111+Q_101110211*PR_000001021112); ans_temp[ans_id*36+34]+=Pmtrx[28]*(Q_000011011*PR_000001021000+Q_000011111*PR_000001021001+Q_000011211*PR_000001021002+Q_000111011*PR_000001021010+Q_000111111*PR_000001021011+Q_000111211*PR_000001021012+Q_000211011*PR_000001021020+Q_000211111*PR_000001021021+Q_000211211*PR_000001021022); ans_temp[ans_id*36+34]+=Pmtrx[29]*(Q_000010012*PR_000001021000+Q_000010112*PR_000001021001+Q_000010212*PR_000001021002+Q_000010312*PR_000001021003+Q_000110012*PR_000001021010+Q_000110112*PR_000001021011+Q_000110212*PR_000001021012+Q_000110312*PR_000001021013); ans_temp[ans_id*36+35]+=Pmtrx[24]*(Q_002000020*PR_000001021000+Q_002000120*PR_000001021001+Q_002000220*PR_000001021002+Q_102000020*PR_000001021100+Q_102000120*PR_000001021101+Q_102000220*PR_000001021102+Q_202000020*PR_000001021200+Q_202000120*PR_000001021201+Q_202000220*PR_000001021202); ans_temp[ans_id*36+35]+=Pmtrx[25]*(Q_001001020*PR_000001021000+Q_001001120*PR_000001021001+Q_001001220*PR_000001021002+Q_001101020*PR_000001021010+Q_001101120*PR_000001021011+Q_001101220*PR_000001021012+Q_101001020*PR_000001021100+Q_101001120*PR_000001021101+Q_101001220*PR_000001021102+Q_101101020*PR_000001021110+Q_101101120*PR_000001021111+Q_101101220*PR_000001021112); ans_temp[ans_id*36+35]+=Pmtrx[26]*(Q_000002020*PR_000001021000+Q_000002120*PR_000001021001+Q_000002220*PR_000001021002+Q_000102020*PR_000001021010+Q_000102120*PR_000001021011+Q_000102220*PR_000001021012+Q_000202020*PR_000001021020+Q_000202120*PR_000001021021+Q_000202220*PR_000001021022); ans_temp[ans_id*36+35]+=Pmtrx[27]*(Q_001000021*PR_000001021000+Q_001000121*PR_000001021001+Q_001000221*PR_000001021002+Q_001000321*PR_000001021003+Q_101000021*PR_000001021100+Q_101000121*PR_000001021101+Q_101000221*PR_000001021102+Q_101000321*PR_000001021103); ans_temp[ans_id*36+35]+=Pmtrx[28]*(Q_000001021*PR_000001021000+Q_000001121*PR_000001021001+Q_000001221*PR_000001021002+Q_000001321*PR_000001021003+Q_000101021*PR_000001021010+Q_000101121*PR_000001021011+Q_000101221*PR_000001021012+Q_000101321*PR_000001021013); ans_temp[ans_id*36+35]+=Pmtrx[29]*(Q_000000022*PR_000001021000+Q_000000122*PR_000001021001+Q_000000222*PR_000001021002+Q_000000322*PR_000001021003+Q_000000422*PR_000001021004); ans_temp[ans_id*36+30]+=Pmtrx[30]*(Q_022000000*PR_000000022000+Q_122000000*PR_000000022100+Q_222000000*PR_000000022200+Q_322000000*PR_000000022300+Q_422000000*PR_000000022400); ans_temp[ans_id*36+30]+=Pmtrx[31]*(Q_021001000*PR_000000022000+Q_021101000*PR_000000022010+Q_121001000*PR_000000022100+Q_121101000*PR_000000022110+Q_221001000*PR_000000022200+Q_221101000*PR_000000022210+Q_321001000*PR_000000022300+Q_321101000*PR_000000022310); ans_temp[ans_id*36+30]+=Pmtrx[32]*(Q_020002000*PR_000000022000+Q_020102000*PR_000000022010+Q_020202000*PR_000000022020+Q_120002000*PR_000000022100+Q_120102000*PR_000000022110+Q_120202000*PR_000000022120+Q_220002000*PR_000000022200+Q_220102000*PR_000000022210+Q_220202000*PR_000000022220); ans_temp[ans_id*36+30]+=Pmtrx[33]*(Q_021000001*PR_000000022000+Q_021000101*PR_000000022001+Q_121000001*PR_000000022100+Q_121000101*PR_000000022101+Q_221000001*PR_000000022200+Q_221000101*PR_000000022201+Q_321000001*PR_000000022300+Q_321000101*PR_000000022301); ans_temp[ans_id*36+30]+=Pmtrx[34]*(Q_020001001*PR_000000022000+Q_020001101*PR_000000022001+Q_020101001*PR_000000022010+Q_020101101*PR_000000022011+Q_120001001*PR_000000022100+Q_120001101*PR_000000022101+Q_120101001*PR_000000022110+Q_120101101*PR_000000022111+Q_220001001*PR_000000022200+Q_220001101*PR_000000022201+Q_220101001*PR_000000022210+Q_220101101*PR_000000022211); ans_temp[ans_id*36+30]+=Pmtrx[35]*(Q_020000002*PR_000000022000+Q_020000102*PR_000000022001+Q_020000202*PR_000000022002+Q_120000002*PR_000000022100+Q_120000102*PR_000000022101+Q_120000202*PR_000000022102+Q_220000002*PR_000000022200+Q_220000102*PR_000000022201+Q_220000202*PR_000000022202); ans_temp[ans_id*36+31]+=Pmtrx[30]*(Q_012010000*PR_000000022000+Q_012110000*PR_000000022010+Q_112010000*PR_000000022100+Q_112110000*PR_000000022110+Q_212010000*PR_000000022200+Q_212110000*PR_000000022210+Q_312010000*PR_000000022300+Q_312110000*PR_000000022310); ans_temp[ans_id*36+31]+=Pmtrx[31]*(Q_011011000*PR_000000022000+Q_011111000*PR_000000022010+Q_011211000*PR_000000022020+Q_111011000*PR_000000022100+Q_111111000*PR_000000022110+Q_111211000*PR_000000022120+Q_211011000*PR_000000022200+Q_211111000*PR_000000022210+Q_211211000*PR_000000022220); ans_temp[ans_id*36+31]+=Pmtrx[32]*(Q_010012000*PR_000000022000+Q_010112000*PR_000000022010+Q_010212000*PR_000000022020+Q_010312000*PR_000000022030+Q_110012000*PR_000000022100+Q_110112000*PR_000000022110+Q_110212000*PR_000000022120+Q_110312000*PR_000000022130); ans_temp[ans_id*36+31]+=Pmtrx[33]*(Q_011010001*PR_000000022000+Q_011010101*PR_000000022001+Q_011110001*PR_000000022010+Q_011110101*PR_000000022011+Q_111010001*PR_000000022100+Q_111010101*PR_000000022101+Q_111110001*PR_000000022110+Q_111110101*PR_000000022111+Q_211010001*PR_000000022200+Q_211010101*PR_000000022201+Q_211110001*PR_000000022210+Q_211110101*PR_000000022211); ans_temp[ans_id*36+31]+=Pmtrx[34]*(Q_010011001*PR_000000022000+Q_010011101*PR_000000022001+Q_010111001*PR_000000022010+Q_010111101*PR_000000022011+Q_010211001*PR_000000022020+Q_010211101*PR_000000022021+Q_110011001*PR_000000022100+Q_110011101*PR_000000022101+Q_110111001*PR_000000022110+Q_110111101*PR_000000022111+Q_110211001*PR_000000022120+Q_110211101*PR_000000022121); ans_temp[ans_id*36+31]+=Pmtrx[35]*(Q_010010002*PR_000000022000+Q_010010102*PR_000000022001+Q_010010202*PR_000000022002+Q_010110002*PR_000000022010+Q_010110102*PR_000000022011+Q_010110202*PR_000000022012+Q_110010002*PR_000000022100+Q_110010102*PR_000000022101+Q_110010202*PR_000000022102+Q_110110002*PR_000000022110+Q_110110102*PR_000000022111+Q_110110202*PR_000000022112); ans_temp[ans_id*36+32]+=Pmtrx[30]*(Q_002020000*PR_000000022000+Q_002120000*PR_000000022010+Q_002220000*PR_000000022020+Q_102020000*PR_000000022100+Q_102120000*PR_000000022110+Q_102220000*PR_000000022120+Q_202020000*PR_000000022200+Q_202120000*PR_000000022210+Q_202220000*PR_000000022220); ans_temp[ans_id*36+32]+=Pmtrx[31]*(Q_001021000*PR_000000022000+Q_001121000*PR_000000022010+Q_001221000*PR_000000022020+Q_001321000*PR_000000022030+Q_101021000*PR_000000022100+Q_101121000*PR_000000022110+Q_101221000*PR_000000022120+Q_101321000*PR_000000022130); ans_temp[ans_id*36+32]+=Pmtrx[32]*(Q_000022000*PR_000000022000+Q_000122000*PR_000000022010+Q_000222000*PR_000000022020+Q_000322000*PR_000000022030+Q_000422000*PR_000000022040); ans_temp[ans_id*36+32]+=Pmtrx[33]*(Q_001020001*PR_000000022000+Q_001020101*PR_000000022001+Q_001120001*PR_000000022010+Q_001120101*PR_000000022011+Q_001220001*PR_000000022020+Q_001220101*PR_000000022021+Q_101020001*PR_000000022100+Q_101020101*PR_000000022101+Q_101120001*PR_000000022110+Q_101120101*PR_000000022111+Q_101220001*PR_000000022120+Q_101220101*PR_000000022121); ans_temp[ans_id*36+32]+=Pmtrx[34]*(Q_000021001*PR_000000022000+Q_000021101*PR_000000022001+Q_000121001*PR_000000022010+Q_000121101*PR_000000022011+Q_000221001*PR_000000022020+Q_000221101*PR_000000022021+Q_000321001*PR_000000022030+Q_000321101*PR_000000022031); ans_temp[ans_id*36+32]+=Pmtrx[35]*(Q_000020002*PR_000000022000+Q_000020102*PR_000000022001+Q_000020202*PR_000000022002+Q_000120002*PR_000000022010+Q_000120102*PR_000000022011+Q_000120202*PR_000000022012+Q_000220002*PR_000000022020+Q_000220102*PR_000000022021+Q_000220202*PR_000000022022); ans_temp[ans_id*36+33]+=Pmtrx[30]*(Q_012000010*PR_000000022000+Q_012000110*PR_000000022001+Q_112000010*PR_000000022100+Q_112000110*PR_000000022101+Q_212000010*PR_000000022200+Q_212000110*PR_000000022201+Q_312000010*PR_000000022300+Q_312000110*PR_000000022301); ans_temp[ans_id*36+33]+=Pmtrx[31]*(Q_011001010*PR_000000022000+Q_011001110*PR_000000022001+Q_011101010*PR_000000022010+Q_011101110*PR_000000022011+Q_111001010*PR_000000022100+Q_111001110*PR_000000022101+Q_111101010*PR_000000022110+Q_111101110*PR_000000022111+Q_211001010*PR_000000022200+Q_211001110*PR_000000022201+Q_211101010*PR_000000022210+Q_211101110*PR_000000022211); ans_temp[ans_id*36+33]+=Pmtrx[32]*(Q_010002010*PR_000000022000+Q_010002110*PR_000000022001+Q_010102010*PR_000000022010+Q_010102110*PR_000000022011+Q_010202010*PR_000000022020+Q_010202110*PR_000000022021+Q_110002010*PR_000000022100+Q_110002110*PR_000000022101+Q_110102010*PR_000000022110+Q_110102110*PR_000000022111+Q_110202010*PR_000000022120+Q_110202110*PR_000000022121); ans_temp[ans_id*36+33]+=Pmtrx[33]*(Q_011000011*PR_000000022000+Q_011000111*PR_000000022001+Q_011000211*PR_000000022002+Q_111000011*PR_000000022100+Q_111000111*PR_000000022101+Q_111000211*PR_000000022102+Q_211000011*PR_000000022200+Q_211000111*PR_000000022201+Q_211000211*PR_000000022202); ans_temp[ans_id*36+33]+=Pmtrx[34]*(Q_010001011*PR_000000022000+Q_010001111*PR_000000022001+Q_010001211*PR_000000022002+Q_010101011*PR_000000022010+Q_010101111*PR_000000022011+Q_010101211*PR_000000022012+Q_110001011*PR_000000022100+Q_110001111*PR_000000022101+Q_110001211*PR_000000022102+Q_110101011*PR_000000022110+Q_110101111*PR_000000022111+Q_110101211*PR_000000022112); ans_temp[ans_id*36+33]+=Pmtrx[35]*(Q_010000012*PR_000000022000+Q_010000112*PR_000000022001+Q_010000212*PR_000000022002+Q_010000312*PR_000000022003+Q_110000012*PR_000000022100+Q_110000112*PR_000000022101+Q_110000212*PR_000000022102+Q_110000312*PR_000000022103); ans_temp[ans_id*36+34]+=Pmtrx[30]*(Q_002010010*PR_000000022000+Q_002010110*PR_000000022001+Q_002110010*PR_000000022010+Q_002110110*PR_000000022011+Q_102010010*PR_000000022100+Q_102010110*PR_000000022101+Q_102110010*PR_000000022110+Q_102110110*PR_000000022111+Q_202010010*PR_000000022200+Q_202010110*PR_000000022201+Q_202110010*PR_000000022210+Q_202110110*PR_000000022211); ans_temp[ans_id*36+34]+=Pmtrx[31]*(Q_001011010*PR_000000022000+Q_001011110*PR_000000022001+Q_001111010*PR_000000022010+Q_001111110*PR_000000022011+Q_001211010*PR_000000022020+Q_001211110*PR_000000022021+Q_101011010*PR_000000022100+Q_101011110*PR_000000022101+Q_101111010*PR_000000022110+Q_101111110*PR_000000022111+Q_101211010*PR_000000022120+Q_101211110*PR_000000022121); ans_temp[ans_id*36+34]+=Pmtrx[32]*(Q_000012010*PR_000000022000+Q_000012110*PR_000000022001+Q_000112010*PR_000000022010+Q_000112110*PR_000000022011+Q_000212010*PR_000000022020+Q_000212110*PR_000000022021+Q_000312010*PR_000000022030+Q_000312110*PR_000000022031); ans_temp[ans_id*36+34]+=Pmtrx[33]*(Q_001010011*PR_000000022000+Q_001010111*PR_000000022001+Q_001010211*PR_000000022002+Q_001110011*PR_000000022010+Q_001110111*PR_000000022011+Q_001110211*PR_000000022012+Q_101010011*PR_000000022100+Q_101010111*PR_000000022101+Q_101010211*PR_000000022102+Q_101110011*PR_000000022110+Q_101110111*PR_000000022111+Q_101110211*PR_000000022112); ans_temp[ans_id*36+34]+=Pmtrx[34]*(Q_000011011*PR_000000022000+Q_000011111*PR_000000022001+Q_000011211*PR_000000022002+Q_000111011*PR_000000022010+Q_000111111*PR_000000022011+Q_000111211*PR_000000022012+Q_000211011*PR_000000022020+Q_000211111*PR_000000022021+Q_000211211*PR_000000022022); ans_temp[ans_id*36+34]+=Pmtrx[35]*(Q_000010012*PR_000000022000+Q_000010112*PR_000000022001+Q_000010212*PR_000000022002+Q_000010312*PR_000000022003+Q_000110012*PR_000000022010+Q_000110112*PR_000000022011+Q_000110212*PR_000000022012+Q_000110312*PR_000000022013); ans_temp[ans_id*36+35]+=Pmtrx[30]*(Q_002000020*PR_000000022000+Q_002000120*PR_000000022001+Q_002000220*PR_000000022002+Q_102000020*PR_000000022100+Q_102000120*PR_000000022101+Q_102000220*PR_000000022102+Q_202000020*PR_000000022200+Q_202000120*PR_000000022201+Q_202000220*PR_000000022202); ans_temp[ans_id*36+35]+=Pmtrx[31]*(Q_001001020*PR_000000022000+Q_001001120*PR_000000022001+Q_001001220*PR_000000022002+Q_001101020*PR_000000022010+Q_001101120*PR_000000022011+Q_001101220*PR_000000022012+Q_101001020*PR_000000022100+Q_101001120*PR_000000022101+Q_101001220*PR_000000022102+Q_101101020*PR_000000022110+Q_101101120*PR_000000022111+Q_101101220*PR_000000022112); ans_temp[ans_id*36+35]+=Pmtrx[32]*(Q_000002020*PR_000000022000+Q_000002120*PR_000000022001+Q_000002220*PR_000000022002+Q_000102020*PR_000000022010+Q_000102120*PR_000000022011+Q_000102220*PR_000000022012+Q_000202020*PR_000000022020+Q_000202120*PR_000000022021+Q_000202220*PR_000000022022); ans_temp[ans_id*36+35]+=Pmtrx[33]*(Q_001000021*PR_000000022000+Q_001000121*PR_000000022001+Q_001000221*PR_000000022002+Q_001000321*PR_000000022003+Q_101000021*PR_000000022100+Q_101000121*PR_000000022101+Q_101000221*PR_000000022102+Q_101000321*PR_000000022103); ans_temp[ans_id*36+35]+=Pmtrx[34]*(Q_000001021*PR_000000022000+Q_000001121*PR_000000022001+Q_000001221*PR_000000022002+Q_000001321*PR_000000022003+Q_000101021*PR_000000022010+Q_000101121*PR_000000022011+Q_000101221*PR_000000022012+Q_000101321*PR_000000022013); ans_temp[ans_id*36+35]+=Pmtrx[35]*(Q_000000022*PR_000000022000+Q_000000122*PR_000000022001+Q_000000222*PR_000000022002+Q_000000322*PR_000000022003+Q_000000422*PR_000000022004); } } __syncthreads(); int num_thread=NTHREAD/2; while (num_thread!=0){ __syncthreads(); if(tId_x<num_thread){ for(int ians=0;ians<36;ians++){ ans_temp[tId_x*36+ians]+=ans_temp[(tId_x+num_thread)*36+ians]; } } num_thread/=2; } if(tId_x==0){ for(int ians=0;ians<36;ians++){ ans[(i_contrc_bra*contrc_ket_num+j_contrc_ket)*36+ians]=ans_temp[(tId_x)*36+ians]; } } } } } __global__ void MD_Kq_dddd_fs(unsigned int contrc_bra_num,unsigned int contrc_ket_num,\ unsigned int * contrc_bra_id,\ unsigned int * contrc_ket_id,\ unsigned int mtrx_len,\ double * Pmtrx_in,\ double * P,\ double * PA,\ double * PB,\ double * Zta_in,\ double * pp_in,\ float * K2_p_in,\ unsigned int * id_bra_in,\ double * Q,\ double * QC,\ double * QD,\ double * Eta_in,\ double * pq_in,\ float * K2_q_in,\ unsigned int * id_ket_in,\ double * ans){ unsigned int tId_x = threadIdx.x; unsigned int bId_x = blockIdx.x; unsigned int bId_y = blockIdx.y; unsigned int tdis = blockDim.x; unsigned int bdis_x = gridDim.x; unsigned int bdis_y = gridDim.y; unsigned int ans_id=tId_x; double Pmtrx[36]={0.0}; __shared__ double ans_temp[NTHREAD*36]; for(int i=0;i<36;i++){ ans_temp[i*tdis+tId_x]=0.0; } for(unsigned int i_contrc_bra=bId_x;i_contrc_bra<contrc_bra_num;i_contrc_bra+=bdis_x){ for(unsigned int j_contrc_ket=bId_y;j_contrc_ket<contrc_ket_num;j_contrc_ket+=bdis_y){ unsigned int primit_bra_start = contrc_bra_id[i_contrc_bra ]; unsigned int primit_bra_end = contrc_bra_id[i_contrc_bra+1]; unsigned int primit_ket_start = contrc_ket_id[j_contrc_ket ]; unsigned int primit_ket_end = contrc_ket_id[j_contrc_ket+1]; if(i_contrc_bra>j_contrc_ket){ if(tId_x==0){ for(int ians=0;ians<36;ians++){ ans[(i_contrc_bra*contrc_ket_num+j_contrc_ket)*36+ians]=0.0; } } continue; } for(unsigned int ii=primit_bra_start;ii<primit_bra_end;ii++){ unsigned int id_bra=id_bra_in[ii]; double PX=P[ii*3+0]; double PY=P[ii*3+1]; double PZ=P[ii*3+2]; double Pd_010[3]; Pd_010[0]=PA[ii*3+0]; Pd_010[1]=PA[ii*3+1]; Pd_010[2]=PA[ii*3+2]; double Pd_001[3]; Pd_001[0]=PB[ii*3+0]; Pd_001[1]=PB[ii*3+1]; Pd_001[2]=PB[ii*3+2]; double Zta=Zta_in[ii]; double pp=pp_in[ii]; float K2_p=K2_p_in[ii]; double aPin1=1/(2*Zta); for(unsigned int j=tId_x;j<primit_ket_end-primit_ket_start;j+=tdis){ unsigned int jj=primit_ket_start+j; unsigned int id_ket=tex1Dfetch(tex_id_ket,jj); double P_max=0.0; for(int p_j=0;p_j<6;p_j++){ for(int p_i=0;p_i<6;p_i++){ Pmtrx[p_i*6+p_j]=Pmtrx_in[(id_ket+p_j)*mtrx_len+(id_bra+p_i)]; double temp_P=fabsf(Pmtrx[p_i*6+p_j]); if(temp_P>P_max) P_max=temp_P; } } float K2_q=tex1Dfetch(tex_K2_q,jj); if(fabsf(K2_p*K2_q)<1.0E-14){ break; } if(fabsf(P_max*K2_p*K2_q)<1.0E-14) continue; int2 temp_int2; temp_int2=tex1Dfetch(tex_Eta,jj); double Eta=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_pq,jj); double pq=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_Q,jj*3+0); double QX=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_Q,jj*3+1); double QY=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_Q,jj*3+2); double QZ=__hiloint2double(temp_int2.y,temp_int2.x); double Qd_010[3]; temp_int2=tex1Dfetch(tex_QC,jj*3+0); Qd_010[0]=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_QC,jj*3+1); Qd_010[1]=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_QC,jj*3+2); Qd_010[2]=__hiloint2double(temp_int2.y,temp_int2.x); double Qd_001[3]; temp_int2=tex1Dfetch(tex_QD,jj*3+0); Qd_001[0]=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_QD,jj*3+1); Qd_001[1]=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_QD,jj*3+2); Qd_001[2]=__hiloint2double(temp_int2.y,temp_int2.x); double alphaT=rsqrt(Eta+Zta); double lmd=2*P25*pp*pq*alphaT; alphaT=Eta*Zta*alphaT*alphaT; double TX=PX-QX; double TY=PY-QY; double TZ=PZ-QZ; double T=alphaT*(TX*TX+TY*TY+TZ*TZ); double R_000[9]; Ft_fs_8(8,T,R_000); R_000[0]*=lmd; R_000[1]*=-2*alphaT*lmd; R_000[2]*=4*alphaT*alphaT*lmd; R_000[3]*=-8*alphaT*alphaT*alphaT*lmd; R_000[4]*=16*alphaT*alphaT*alphaT*alphaT*lmd; R_000[5]*=-32*alphaT*alphaT*alphaT*alphaT*alphaT*lmd; R_000[6]*=64*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*lmd; R_000[7]*=-128*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*lmd; R_000[8]*=256*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*lmd; double aQin1=1/(2*Eta); double R_100[8]; double R_200[7]; double R_300[6]; double R_400[5]; double R_500[4]; double R_600[3]; double R_700[2]; double R_800[1]; double R_010[8]; double R_110[7]; double R_210[6]; double R_310[5]; double R_410[4]; double R_510[3]; double R_610[2]; double R_710[1]; double R_020[7]; double R_120[6]; double R_220[5]; double R_320[4]; double R_420[3]; double R_520[2]; double R_620[1]; double R_030[6]; double R_130[5]; double R_230[4]; double R_330[3]; double R_430[2]; double R_530[1]; double R_040[5]; double R_140[4]; double R_240[3]; double R_340[2]; double R_440[1]; double R_050[4]; double R_150[3]; double R_250[2]; double R_350[1]; double R_060[3]; double R_160[2]; double R_260[1]; double R_070[2]; double R_170[1]; double R_080[1]; double R_001[8]; double R_101[7]; double R_201[6]; double R_301[5]; double R_401[4]; double R_501[3]; double R_601[2]; double R_701[1]; double R_011[7]; double R_111[6]; double R_211[5]; double R_311[4]; double R_411[3]; double R_511[2]; double R_611[1]; double R_021[6]; double R_121[5]; double R_221[4]; double R_321[3]; double R_421[2]; double R_521[1]; double R_031[5]; double R_131[4]; double R_231[3]; double R_331[2]; double R_431[1]; double R_041[4]; double R_141[3]; double R_241[2]; double R_341[1]; double R_051[3]; double R_151[2]; double R_251[1]; double R_061[2]; double R_161[1]; double R_071[1]; double R_002[7]; double R_102[6]; double R_202[5]; double R_302[4]; double R_402[3]; double R_502[2]; double R_602[1]; double R_012[6]; double R_112[5]; double R_212[4]; double R_312[3]; double R_412[2]; double R_512[1]; double R_022[5]; double R_122[4]; double R_222[3]; double R_322[2]; double R_422[1]; double R_032[4]; double R_132[3]; double R_232[2]; double R_332[1]; double R_042[3]; double R_142[2]; double R_242[1]; double R_052[2]; double R_152[1]; double R_062[1]; double R_003[6]; double R_103[5]; double R_203[4]; double R_303[3]; double R_403[2]; double R_503[1]; double R_013[5]; double R_113[4]; double R_213[3]; double R_313[2]; double R_413[1]; double R_023[4]; double R_123[3]; double R_223[2]; double R_323[1]; double R_033[3]; double R_133[2]; double R_233[1]; double R_043[2]; double R_143[1]; double R_053[1]; double R_004[5]; double R_104[4]; double R_204[3]; double R_304[2]; double R_404[1]; double R_014[4]; double R_114[3]; double R_214[2]; double R_314[1]; double R_024[3]; double R_124[2]; double R_224[1]; double R_034[2]; double R_134[1]; double R_044[1]; double R_005[4]; double R_105[3]; double R_205[2]; double R_305[1]; double R_015[3]; double R_115[2]; double R_215[1]; double R_025[2]; double R_125[1]; double R_035[1]; double R_006[3]; double R_106[2]; double R_206[1]; double R_016[2]; double R_116[1]; double R_026[1]; double R_007[2]; double R_107[1]; double R_017[1]; double R_008[1]; for(int i=0;i<8;i++){ R_100[i]=TX*R_000[i+1]; } for(int i=0;i<8;i++){ R_010[i]=TY*R_000[i+1]; } for(int i=0;i<8;i++){ R_001[i]=TZ*R_000[i+1]; } for(int i=0;i<7;i++){ R_200[i]=TX*R_100[i+1]+R_000[i+1]; } for(int i=0;i<7;i++){ R_110[i]=TX*R_010[i+1]; } for(int i=0;i<7;i++){ R_020[i]=TY*R_010[i+1]+R_000[i+1]; } for(int i=0;i<7;i++){ R_101[i]=TX*R_001[i+1]; } for(int i=0;i<7;i++){ R_011[i]=TY*R_001[i+1]; } for(int i=0;i<7;i++){ R_002[i]=TZ*R_001[i+1]+R_000[i+1]; } for(int i=0;i<6;i++){ R_300[i]=TX*R_200[i+1]+2*R_100[i+1]; } for(int i=0;i<6;i++){ R_210[i]=TY*R_200[i+1]; } for(int i=0;i<6;i++){ R_120[i]=TX*R_020[i+1]; } for(int i=0;i<6;i++){ R_030[i]=TY*R_020[i+1]+2*R_010[i+1]; } for(int i=0;i<6;i++){ R_201[i]=TZ*R_200[i+1]; } for(int i=0;i<6;i++){ R_111[i]=TX*R_011[i+1]; } for(int i=0;i<6;i++){ R_021[i]=TZ*R_020[i+1]; } for(int i=0;i<6;i++){ R_102[i]=TX*R_002[i+1]; } for(int i=0;i<6;i++){ R_012[i]=TY*R_002[i+1]; } for(int i=0;i<6;i++){ R_003[i]=TZ*R_002[i+1]+2*R_001[i+1]; } for(int i=0;i<5;i++){ R_400[i]=TX*R_300[i+1]+3*R_200[i+1]; } for(int i=0;i<5;i++){ R_310[i]=TY*R_300[i+1]; } for(int i=0;i<5;i++){ R_220[i]=TX*R_120[i+1]+R_020[i+1]; } for(int i=0;i<5;i++){ R_130[i]=TX*R_030[i+1]; } for(int i=0;i<5;i++){ R_040[i]=TY*R_030[i+1]+3*R_020[i+1]; } for(int i=0;i<5;i++){ R_301[i]=TZ*R_300[i+1]; } for(int i=0;i<5;i++){ R_211[i]=TY*R_201[i+1]; } for(int i=0;i<5;i++){ R_121[i]=TX*R_021[i+1]; } for(int i=0;i<5;i++){ R_031[i]=TZ*R_030[i+1]; } for(int i=0;i<5;i++){ R_202[i]=TX*R_102[i+1]+R_002[i+1]; } for(int i=0;i<5;i++){ R_112[i]=TX*R_012[i+1]; } for(int i=0;i<5;i++){ R_022[i]=TY*R_012[i+1]+R_002[i+1]; } for(int i=0;i<5;i++){ R_103[i]=TX*R_003[i+1]; } for(int i=0;i<5;i++){ R_013[i]=TY*R_003[i+1]; } for(int i=0;i<5;i++){ R_004[i]=TZ*R_003[i+1]+3*R_002[i+1]; } for(int i=0;i<4;i++){ R_500[i]=TX*R_400[i+1]+4*R_300[i+1]; } for(int i=0;i<4;i++){ R_410[i]=TY*R_400[i+1]; } for(int i=0;i<4;i++){ R_320[i]=TX*R_220[i+1]+2*R_120[i+1]; } for(int i=0;i<4;i++){ R_230[i]=TY*R_220[i+1]+2*R_210[i+1]; } for(int i=0;i<4;i++){ R_140[i]=TX*R_040[i+1]; } for(int i=0;i<4;i++){ R_050[i]=TY*R_040[i+1]+4*R_030[i+1]; } for(int i=0;i<4;i++){ R_401[i]=TZ*R_400[i+1]; } for(int i=0;i<4;i++){ R_311[i]=TY*R_301[i+1]; } for(int i=0;i<4;i++){ R_221[i]=TZ*R_220[i+1]; } for(int i=0;i<4;i++){ R_131[i]=TX*R_031[i+1]; } for(int i=0;i<4;i++){ R_041[i]=TZ*R_040[i+1]; } for(int i=0;i<4;i++){ R_302[i]=TX*R_202[i+1]+2*R_102[i+1]; } for(int i=0;i<4;i++){ R_212[i]=TY*R_202[i+1]; } for(int i=0;i<4;i++){ R_122[i]=TX*R_022[i+1]; } for(int i=0;i<4;i++){ R_032[i]=TY*R_022[i+1]+2*R_012[i+1]; } for(int i=0;i<4;i++){ R_203[i]=TZ*R_202[i+1]+2*R_201[i+1]; } for(int i=0;i<4;i++){ R_113[i]=TX*R_013[i+1]; } for(int i=0;i<4;i++){ R_023[i]=TZ*R_022[i+1]+2*R_021[i+1]; } for(int i=0;i<4;i++){ R_104[i]=TX*R_004[i+1]; } for(int i=0;i<4;i++){ R_014[i]=TY*R_004[i+1]; } for(int i=0;i<4;i++){ R_005[i]=TZ*R_004[i+1]+4*R_003[i+1]; } for(int i=0;i<3;i++){ R_600[i]=TX*R_500[i+1]+5*R_400[i+1]; } for(int i=0;i<3;i++){ R_510[i]=TY*R_500[i+1]; } for(int i=0;i<3;i++){ R_420[i]=TX*R_320[i+1]+3*R_220[i+1]; } for(int i=0;i<3;i++){ R_330[i]=TX*R_230[i+1]+2*R_130[i+1]; } for(int i=0;i<3;i++){ R_240[i]=TY*R_230[i+1]+3*R_220[i+1]; } for(int i=0;i<3;i++){ R_150[i]=TX*R_050[i+1]; } for(int i=0;i<3;i++){ R_060[i]=TY*R_050[i+1]+5*R_040[i+1]; } for(int i=0;i<3;i++){ R_501[i]=TZ*R_500[i+1]; } for(int i=0;i<3;i++){ R_411[i]=TY*R_401[i+1]; } for(int i=0;i<3;i++){ R_321[i]=TZ*R_320[i+1]; } for(int i=0;i<3;i++){ R_231[i]=TZ*R_230[i+1]; } for(int i=0;i<3;i++){ R_141[i]=TX*R_041[i+1]; } for(int i=0;i<3;i++){ R_051[i]=TZ*R_050[i+1]; } for(int i=0;i<3;i++){ R_402[i]=TX*R_302[i+1]+3*R_202[i+1]; } for(int i=0;i<3;i++){ R_312[i]=TY*R_302[i+1]; } for(int i=0;i<3;i++){ R_222[i]=TX*R_122[i+1]+R_022[i+1]; } for(int i=0;i<3;i++){ R_132[i]=TX*R_032[i+1]; } for(int i=0;i<3;i++){ R_042[i]=TY*R_032[i+1]+3*R_022[i+1]; } for(int i=0;i<3;i++){ R_303[i]=TX*R_203[i+1]+2*R_103[i+1]; } for(int i=0;i<3;i++){ R_213[i]=TY*R_203[i+1]; } for(int i=0;i<3;i++){ R_123[i]=TX*R_023[i+1]; } for(int i=0;i<3;i++){ R_033[i]=TY*R_023[i+1]+2*R_013[i+1]; } for(int i=0;i<3;i++){ R_204[i]=TZ*R_203[i+1]+3*R_202[i+1]; } for(int i=0;i<3;i++){ R_114[i]=TX*R_014[i+1]; } for(int i=0;i<3;i++){ R_024[i]=TZ*R_023[i+1]+3*R_022[i+1]; } for(int i=0;i<3;i++){ R_105[i]=TX*R_005[i+1]; } for(int i=0;i<3;i++){ R_015[i]=TY*R_005[i+1]; } for(int i=0;i<3;i++){ R_006[i]=TZ*R_005[i+1]+5*R_004[i+1]; } for(int i=0;i<2;i++){ R_700[i]=TX*R_600[i+1]+6*R_500[i+1]; } for(int i=0;i<2;i++){ R_610[i]=TY*R_600[i+1]; } for(int i=0;i<2;i++){ R_520[i]=TX*R_420[i+1]+4*R_320[i+1]; } for(int i=0;i<2;i++){ R_430[i]=TX*R_330[i+1]+3*R_230[i+1]; } for(int i=0;i<2;i++){ R_340[i]=TY*R_330[i+1]+3*R_320[i+1]; } for(int i=0;i<2;i++){ R_250[i]=TY*R_240[i+1]+4*R_230[i+1]; } for(int i=0;i<2;i++){ R_160[i]=TX*R_060[i+1]; } for(int i=0;i<2;i++){ R_070[i]=TY*R_060[i+1]+6*R_050[i+1]; } for(int i=0;i<2;i++){ R_601[i]=TZ*R_600[i+1]; } for(int i=0;i<2;i++){ R_511[i]=TY*R_501[i+1]; } for(int i=0;i<2;i++){ R_421[i]=TZ*R_420[i+1]; } for(int i=0;i<2;i++){ R_331[i]=TZ*R_330[i+1]; } for(int i=0;i<2;i++){ R_241[i]=TZ*R_240[i+1]; } for(int i=0;i<2;i++){ R_151[i]=TX*R_051[i+1]; } for(int i=0;i<2;i++){ R_061[i]=TZ*R_060[i+1]; } for(int i=0;i<2;i++){ R_502[i]=TX*R_402[i+1]+4*R_302[i+1]; } for(int i=0;i<2;i++){ R_412[i]=TY*R_402[i+1]; } for(int i=0;i<2;i++){ R_322[i]=TX*R_222[i+1]+2*R_122[i+1]; } for(int i=0;i<2;i++){ R_232[i]=TY*R_222[i+1]+2*R_212[i+1]; } for(int i=0;i<2;i++){ R_142[i]=TX*R_042[i+1]; } for(int i=0;i<2;i++){ R_052[i]=TY*R_042[i+1]+4*R_032[i+1]; } for(int i=0;i<2;i++){ R_403[i]=TX*R_303[i+1]+3*R_203[i+1]; } for(int i=0;i<2;i++){ R_313[i]=TY*R_303[i+1]; } for(int i=0;i<2;i++){ R_223[i]=TZ*R_222[i+1]+2*R_221[i+1]; } for(int i=0;i<2;i++){ R_133[i]=TX*R_033[i+1]; } for(int i=0;i<2;i++){ R_043[i]=TY*R_033[i+1]+3*R_023[i+1]; } for(int i=0;i<2;i++){ R_304[i]=TZ*R_303[i+1]+3*R_302[i+1]; } for(int i=0;i<2;i++){ R_214[i]=TY*R_204[i+1]; } for(int i=0;i<2;i++){ R_124[i]=TX*R_024[i+1]; } for(int i=0;i<2;i++){ R_034[i]=TZ*R_033[i+1]+3*R_032[i+1]; } for(int i=0;i<2;i++){ R_205[i]=TZ*R_204[i+1]+4*R_203[i+1]; } for(int i=0;i<2;i++){ R_115[i]=TX*R_015[i+1]; } for(int i=0;i<2;i++){ R_025[i]=TZ*R_024[i+1]+4*R_023[i+1]; } for(int i=0;i<2;i++){ R_106[i]=TX*R_006[i+1]; } for(int i=0;i<2;i++){ R_016[i]=TY*R_006[i+1]; } for(int i=0;i<2;i++){ R_007[i]=TZ*R_006[i+1]+6*R_005[i+1]; } for(int i=0;i<1;i++){ R_800[i]=TX*R_700[i+1]+7*R_600[i+1]; } for(int i=0;i<1;i++){ R_710[i]=TY*R_700[i+1]; } for(int i=0;i<1;i++){ R_620[i]=TX*R_520[i+1]+5*R_420[i+1]; } for(int i=0;i<1;i++){ R_530[i]=TX*R_430[i+1]+4*R_330[i+1]; } for(int i=0;i<1;i++){ R_440[i]=TX*R_340[i+1]+3*R_240[i+1]; } for(int i=0;i<1;i++){ R_350[i]=TY*R_340[i+1]+4*R_330[i+1]; } for(int i=0;i<1;i++){ R_260[i]=TY*R_250[i+1]+5*R_240[i+1]; } for(int i=0;i<1;i++){ R_170[i]=TX*R_070[i+1]; } for(int i=0;i<1;i++){ R_080[i]=TY*R_070[i+1]+7*R_060[i+1]; } for(int i=0;i<1;i++){ R_701[i]=TZ*R_700[i+1]; } for(int i=0;i<1;i++){ R_611[i]=TY*R_601[i+1]; } for(int i=0;i<1;i++){ R_521[i]=TZ*R_520[i+1]; } for(int i=0;i<1;i++){ R_431[i]=TZ*R_430[i+1]; } for(int i=0;i<1;i++){ R_341[i]=TZ*R_340[i+1]; } for(int i=0;i<1;i++){ R_251[i]=TZ*R_250[i+1]; } for(int i=0;i<1;i++){ R_161[i]=TX*R_061[i+1]; } for(int i=0;i<1;i++){ R_071[i]=TZ*R_070[i+1]; } for(int i=0;i<1;i++){ R_602[i]=TX*R_502[i+1]+5*R_402[i+1]; } for(int i=0;i<1;i++){ R_512[i]=TY*R_502[i+1]; } for(int i=0;i<1;i++){ R_422[i]=TX*R_322[i+1]+3*R_222[i+1]; } for(int i=0;i<1;i++){ R_332[i]=TX*R_232[i+1]+2*R_132[i+1]; } for(int i=0;i<1;i++){ R_242[i]=TY*R_232[i+1]+3*R_222[i+1]; } for(int i=0;i<1;i++){ R_152[i]=TX*R_052[i+1]; } for(int i=0;i<1;i++){ R_062[i]=TY*R_052[i+1]+5*R_042[i+1]; } for(int i=0;i<1;i++){ R_503[i]=TX*R_403[i+1]+4*R_303[i+1]; } for(int i=0;i<1;i++){ R_413[i]=TY*R_403[i+1]; } for(int i=0;i<1;i++){ R_323[i]=TX*R_223[i+1]+2*R_123[i+1]; } for(int i=0;i<1;i++){ R_233[i]=TY*R_223[i+1]+2*R_213[i+1]; } for(int i=0;i<1;i++){ R_143[i]=TX*R_043[i+1]; } for(int i=0;i<1;i++){ R_053[i]=TY*R_043[i+1]+4*R_033[i+1]; } for(int i=0;i<1;i++){ R_404[i]=TX*R_304[i+1]+3*R_204[i+1]; } for(int i=0;i<1;i++){ R_314[i]=TY*R_304[i+1]; } for(int i=0;i<1;i++){ R_224[i]=TZ*R_223[i+1]+3*R_222[i+1]; } for(int i=0;i<1;i++){ R_134[i]=TX*R_034[i+1]; } for(int i=0;i<1;i++){ R_044[i]=TY*R_034[i+1]+3*R_024[i+1]; } for(int i=0;i<1;i++){ R_305[i]=TZ*R_304[i+1]+4*R_303[i+1]; } for(int i=0;i<1;i++){ R_215[i]=TY*R_205[i+1]; } for(int i=0;i<1;i++){ R_125[i]=TX*R_025[i+1]; } for(int i=0;i<1;i++){ R_035[i]=TZ*R_034[i+1]+4*R_033[i+1]; } for(int i=0;i<1;i++){ R_206[i]=TZ*R_205[i+1]+5*R_204[i+1]; } for(int i=0;i<1;i++){ R_116[i]=TX*R_016[i+1]; } for(int i=0;i<1;i++){ R_026[i]=TZ*R_025[i+1]+5*R_024[i+1]; } for(int i=0;i<1;i++){ R_107[i]=TX*R_007[i+1]; } for(int i=0;i<1;i++){ R_017[i]=TY*R_007[i+1]; } for(int i=0;i<1;i++){ R_008[i]=TZ*R_007[i+1]+7*R_006[i+1]; } double Qd_101[3]; double Qd_002[3]; double Qd_102[3]; double Qd_202[3]; double Qd_110[3]; double Qd_011[3]; double Qd_111[3]; double Qd_211[3]; double Qd_012[3]; double Qd_112[3]; double Qd_212[3]; double Qd_312[3]; double Qd_020[3]; double Qd_120[3]; double Qd_220[3]; double Qd_021[3]; double Qd_121[3]; double Qd_221[3]; double Qd_321[3]; double Qd_022[3]; double Qd_122[3]; double Qd_222[3]; double Qd_322[3]; double Qd_422[3]; for(int i=0;i<3;i++){ Qd_101[i]=aQin1; } for(int i=0;i<3;i++){ Qd_002[i]=Qd_101[i]+Qd_001[i]*Qd_001[i]; } for(int i=0;i<3;i++){ Qd_102[i]=Qd_001[i]*Qd_101[i]+aQin1*Qd_001[i]; } for(int i=0;i<3;i++){ Qd_202[i]=aQin1*Qd_101[i]; } for(int i=0;i<3;i++){ Qd_110[i]=aQin1; } for(int i=0;i<3;i++){ Qd_011[i]=Qd_101[i]+Qd_010[i]*Qd_001[i]; } for(int i=0;i<3;i++){ Qd_111[i]=Qd_010[i]*Qd_101[i]+aQin1*Qd_001[i]; } for(int i=0;i<3;i++){ Qd_211[i]=aQin1*Qd_101[i]; } for(int i=0;i<3;i++){ Qd_012[i]=Qd_111[i]+Qd_001[i]*Qd_011[i]; } for(int i=0;i<3;i++){ Qd_112[i]=2*Qd_211[i]+Qd_001[i]*Qd_111[i]+aQin1*Qd_011[i]; } for(int i=0;i<3;i++){ Qd_212[i]=Qd_001[i]*Qd_211[i]+aQin1*Qd_111[i]; } for(int i=0;i<3;i++){ Qd_312[i]=aQin1*Qd_211[i]; } for(int i=0;i<3;i++){ Qd_020[i]=Qd_110[i]+Qd_010[i]*Qd_010[i]; } for(int i=0;i<3;i++){ Qd_120[i]=Qd_010[i]*Qd_110[i]+aQin1*Qd_010[i]; } for(int i=0;i<3;i++){ Qd_220[i]=aQin1*Qd_110[i]; } for(int i=0;i<3;i++){ Qd_021[i]=Qd_111[i]+Qd_010[i]*Qd_011[i]; } for(int i=0;i<3;i++){ Qd_121[i]=2*Qd_211[i]+Qd_010[i]*Qd_111[i]+aQin1*Qd_011[i]; } for(int i=0;i<3;i++){ Qd_221[i]=Qd_010[i]*Qd_211[i]+aQin1*Qd_111[i]; } for(int i=0;i<3;i++){ Qd_321[i]=aQin1*Qd_211[i]; } for(int i=0;i<3;i++){ Qd_022[i]=Qd_112[i]+Qd_010[i]*Qd_012[i]; } for(int i=0;i<3;i++){ Qd_122[i]=2*Qd_212[i]+Qd_010[i]*Qd_112[i]+aQin1*Qd_012[i]; } for(int i=0;i<3;i++){ Qd_222[i]=3*Qd_312[i]+Qd_010[i]*Qd_212[i]+aQin1*Qd_112[i]; } for(int i=0;i<3;i++){ Qd_322[i]=Qd_010[i]*Qd_312[i]+aQin1*Qd_212[i]; } for(int i=0;i<3;i++){ Qd_422[i]=aQin1*Qd_312[i]; } double Q_022000000=Qd_022[0]; double Q_122000000=Qd_122[0]; double Q_222000000=Qd_222[0]; double Q_322000000=Qd_322[0]; double Q_422000000=Qd_422[0]; double Q_021001000=Qd_021[0]*Qd_001[1]; double Q_021101000=Qd_021[0]*Qd_101[1]; double Q_121001000=Qd_121[0]*Qd_001[1]; double Q_121101000=Qd_121[0]*Qd_101[1]; double Q_221001000=Qd_221[0]*Qd_001[1]; double Q_221101000=Qd_221[0]*Qd_101[1]; double Q_321001000=Qd_321[0]*Qd_001[1]; double Q_321101000=Qd_321[0]*Qd_101[1]; double Q_020002000=Qd_020[0]*Qd_002[1]; double Q_020102000=Qd_020[0]*Qd_102[1]; double Q_020202000=Qd_020[0]*Qd_202[1]; double Q_120002000=Qd_120[0]*Qd_002[1]; double Q_120102000=Qd_120[0]*Qd_102[1]; double Q_120202000=Qd_120[0]*Qd_202[1]; double Q_220002000=Qd_220[0]*Qd_002[1]; double Q_220102000=Qd_220[0]*Qd_102[1]; double Q_220202000=Qd_220[0]*Qd_202[1]; double Q_021000001=Qd_021[0]*Qd_001[2]; double Q_021000101=Qd_021[0]*Qd_101[2]; double Q_121000001=Qd_121[0]*Qd_001[2]; double Q_121000101=Qd_121[0]*Qd_101[2]; double Q_221000001=Qd_221[0]*Qd_001[2]; double Q_221000101=Qd_221[0]*Qd_101[2]; double Q_321000001=Qd_321[0]*Qd_001[2]; double Q_321000101=Qd_321[0]*Qd_101[2]; double Q_020001001=Qd_020[0]*Qd_001[1]*Qd_001[2]; double Q_020001101=Qd_020[0]*Qd_001[1]*Qd_101[2]; double Q_020101001=Qd_020[0]*Qd_101[1]*Qd_001[2]; double Q_020101101=Qd_020[0]*Qd_101[1]*Qd_101[2]; double Q_120001001=Qd_120[0]*Qd_001[1]*Qd_001[2]; double Q_120001101=Qd_120[0]*Qd_001[1]*Qd_101[2]; double Q_120101001=Qd_120[0]*Qd_101[1]*Qd_001[2]; double Q_120101101=Qd_120[0]*Qd_101[1]*Qd_101[2]; double Q_220001001=Qd_220[0]*Qd_001[1]*Qd_001[2]; double Q_220001101=Qd_220[0]*Qd_001[1]*Qd_101[2]; double Q_220101001=Qd_220[0]*Qd_101[1]*Qd_001[2]; double Q_220101101=Qd_220[0]*Qd_101[1]*Qd_101[2]; double Q_020000002=Qd_020[0]*Qd_002[2]; double Q_020000102=Qd_020[0]*Qd_102[2]; double Q_020000202=Qd_020[0]*Qd_202[2]; double Q_120000002=Qd_120[0]*Qd_002[2]; double Q_120000102=Qd_120[0]*Qd_102[2]; double Q_120000202=Qd_120[0]*Qd_202[2]; double Q_220000002=Qd_220[0]*Qd_002[2]; double Q_220000102=Qd_220[0]*Qd_102[2]; double Q_220000202=Qd_220[0]*Qd_202[2]; double Q_012010000=Qd_012[0]*Qd_010[1]; double Q_012110000=Qd_012[0]*Qd_110[1]; double Q_112010000=Qd_112[0]*Qd_010[1]; double Q_112110000=Qd_112[0]*Qd_110[1]; double Q_212010000=Qd_212[0]*Qd_010[1]; double Q_212110000=Qd_212[0]*Qd_110[1]; double Q_312010000=Qd_312[0]*Qd_010[1]; double Q_312110000=Qd_312[0]*Qd_110[1]; double Q_011011000=Qd_011[0]*Qd_011[1]; double Q_011111000=Qd_011[0]*Qd_111[1]; double Q_011211000=Qd_011[0]*Qd_211[1]; double Q_111011000=Qd_111[0]*Qd_011[1]; double Q_111111000=Qd_111[0]*Qd_111[1]; double Q_111211000=Qd_111[0]*Qd_211[1]; double Q_211011000=Qd_211[0]*Qd_011[1]; double Q_211111000=Qd_211[0]*Qd_111[1]; double Q_211211000=Qd_211[0]*Qd_211[1]; double Q_010012000=Qd_010[0]*Qd_012[1]; double Q_010112000=Qd_010[0]*Qd_112[1]; double Q_010212000=Qd_010[0]*Qd_212[1]; double Q_010312000=Qd_010[0]*Qd_312[1]; double Q_110012000=Qd_110[0]*Qd_012[1]; double Q_110112000=Qd_110[0]*Qd_112[1]; double Q_110212000=Qd_110[0]*Qd_212[1]; double Q_110312000=Qd_110[0]*Qd_312[1]; double Q_011010001=Qd_011[0]*Qd_010[1]*Qd_001[2]; double Q_011010101=Qd_011[0]*Qd_010[1]*Qd_101[2]; double Q_011110001=Qd_011[0]*Qd_110[1]*Qd_001[2]; double Q_011110101=Qd_011[0]*Qd_110[1]*Qd_101[2]; double Q_111010001=Qd_111[0]*Qd_010[1]*Qd_001[2]; double Q_111010101=Qd_111[0]*Qd_010[1]*Qd_101[2]; double Q_111110001=Qd_111[0]*Qd_110[1]*Qd_001[2]; double Q_111110101=Qd_111[0]*Qd_110[1]*Qd_101[2]; double Q_211010001=Qd_211[0]*Qd_010[1]*Qd_001[2]; double Q_211010101=Qd_211[0]*Qd_010[1]*Qd_101[2]; double Q_211110001=Qd_211[0]*Qd_110[1]*Qd_001[2]; double Q_211110101=Qd_211[0]*Qd_110[1]*Qd_101[2]; double Q_010011001=Qd_010[0]*Qd_011[1]*Qd_001[2]; double Q_010011101=Qd_010[0]*Qd_011[1]*Qd_101[2]; double Q_010111001=Qd_010[0]*Qd_111[1]*Qd_001[2]; double Q_010111101=Qd_010[0]*Qd_111[1]*Qd_101[2]; double Q_010211001=Qd_010[0]*Qd_211[1]*Qd_001[2]; double Q_010211101=Qd_010[0]*Qd_211[1]*Qd_101[2]; double Q_110011001=Qd_110[0]*Qd_011[1]*Qd_001[2]; double Q_110011101=Qd_110[0]*Qd_011[1]*Qd_101[2]; double Q_110111001=Qd_110[0]*Qd_111[1]*Qd_001[2]; double Q_110111101=Qd_110[0]*Qd_111[1]*Qd_101[2]; double Q_110211001=Qd_110[0]*Qd_211[1]*Qd_001[2]; double Q_110211101=Qd_110[0]*Qd_211[1]*Qd_101[2]; double Q_010010002=Qd_010[0]*Qd_010[1]*Qd_002[2]; double Q_010010102=Qd_010[0]*Qd_010[1]*Qd_102[2]; double Q_010010202=Qd_010[0]*Qd_010[1]*Qd_202[2]; double Q_010110002=Qd_010[0]*Qd_110[1]*Qd_002[2]; double Q_010110102=Qd_010[0]*Qd_110[1]*Qd_102[2]; double Q_010110202=Qd_010[0]*Qd_110[1]*Qd_202[2]; double Q_110010002=Qd_110[0]*Qd_010[1]*Qd_002[2]; double Q_110010102=Qd_110[0]*Qd_010[1]*Qd_102[2]; double Q_110010202=Qd_110[0]*Qd_010[1]*Qd_202[2]; double Q_110110002=Qd_110[0]*Qd_110[1]*Qd_002[2]; double Q_110110102=Qd_110[0]*Qd_110[1]*Qd_102[2]; double Q_110110202=Qd_110[0]*Qd_110[1]*Qd_202[2]; double Q_002020000=Qd_002[0]*Qd_020[1]; double Q_002120000=Qd_002[0]*Qd_120[1]; double Q_002220000=Qd_002[0]*Qd_220[1]; double Q_102020000=Qd_102[0]*Qd_020[1]; double Q_102120000=Qd_102[0]*Qd_120[1]; double Q_102220000=Qd_102[0]*Qd_220[1]; double Q_202020000=Qd_202[0]*Qd_020[1]; double Q_202120000=Qd_202[0]*Qd_120[1]; double Q_202220000=Qd_202[0]*Qd_220[1]; double Q_001021000=Qd_001[0]*Qd_021[1]; double Q_001121000=Qd_001[0]*Qd_121[1]; double Q_001221000=Qd_001[0]*Qd_221[1]; double Q_001321000=Qd_001[0]*Qd_321[1]; double Q_101021000=Qd_101[0]*Qd_021[1]; double Q_101121000=Qd_101[0]*Qd_121[1]; double Q_101221000=Qd_101[0]*Qd_221[1]; double Q_101321000=Qd_101[0]*Qd_321[1]; double Q_000022000=Qd_022[1]; double Q_000122000=Qd_122[1]; double Q_000222000=Qd_222[1]; double Q_000322000=Qd_322[1]; double Q_000422000=Qd_422[1]; double Q_001020001=Qd_001[0]*Qd_020[1]*Qd_001[2]; double Q_001020101=Qd_001[0]*Qd_020[1]*Qd_101[2]; double Q_001120001=Qd_001[0]*Qd_120[1]*Qd_001[2]; double Q_001120101=Qd_001[0]*Qd_120[1]*Qd_101[2]; double Q_001220001=Qd_001[0]*Qd_220[1]*Qd_001[2]; double Q_001220101=Qd_001[0]*Qd_220[1]*Qd_101[2]; double Q_101020001=Qd_101[0]*Qd_020[1]*Qd_001[2]; double Q_101020101=Qd_101[0]*Qd_020[1]*Qd_101[2]; double Q_101120001=Qd_101[0]*Qd_120[1]*Qd_001[2]; double Q_101120101=Qd_101[0]*Qd_120[1]*Qd_101[2]; double Q_101220001=Qd_101[0]*Qd_220[1]*Qd_001[2]; double Q_101220101=Qd_101[0]*Qd_220[1]*Qd_101[2]; double Q_000021001=Qd_021[1]*Qd_001[2]; double Q_000021101=Qd_021[1]*Qd_101[2]; double Q_000121001=Qd_121[1]*Qd_001[2]; double Q_000121101=Qd_121[1]*Qd_101[2]; double Q_000221001=Qd_221[1]*Qd_001[2]; double Q_000221101=Qd_221[1]*Qd_101[2]; double Q_000321001=Qd_321[1]*Qd_001[2]; double Q_000321101=Qd_321[1]*Qd_101[2]; double Q_000020002=Qd_020[1]*Qd_002[2]; double Q_000020102=Qd_020[1]*Qd_102[2]; double Q_000020202=Qd_020[1]*Qd_202[2]; double Q_000120002=Qd_120[1]*Qd_002[2]; double Q_000120102=Qd_120[1]*Qd_102[2]; double Q_000120202=Qd_120[1]*Qd_202[2]; double Q_000220002=Qd_220[1]*Qd_002[2]; double Q_000220102=Qd_220[1]*Qd_102[2]; double Q_000220202=Qd_220[1]*Qd_202[2]; double Q_012000010=Qd_012[0]*Qd_010[2]; double Q_012000110=Qd_012[0]*Qd_110[2]; double Q_112000010=Qd_112[0]*Qd_010[2]; double Q_112000110=Qd_112[0]*Qd_110[2]; double Q_212000010=Qd_212[0]*Qd_010[2]; double Q_212000110=Qd_212[0]*Qd_110[2]; double Q_312000010=Qd_312[0]*Qd_010[2]; double Q_312000110=Qd_312[0]*Qd_110[2]; double Q_011001010=Qd_011[0]*Qd_001[1]*Qd_010[2]; double Q_011001110=Qd_011[0]*Qd_001[1]*Qd_110[2]; double Q_011101010=Qd_011[0]*Qd_101[1]*Qd_010[2]; double Q_011101110=Qd_011[0]*Qd_101[1]*Qd_110[2]; double Q_111001010=Qd_111[0]*Qd_001[1]*Qd_010[2]; double Q_111001110=Qd_111[0]*Qd_001[1]*Qd_110[2]; double Q_111101010=Qd_111[0]*Qd_101[1]*Qd_010[2]; double Q_111101110=Qd_111[0]*Qd_101[1]*Qd_110[2]; double Q_211001010=Qd_211[0]*Qd_001[1]*Qd_010[2]; double Q_211001110=Qd_211[0]*Qd_001[1]*Qd_110[2]; double Q_211101010=Qd_211[0]*Qd_101[1]*Qd_010[2]; double Q_211101110=Qd_211[0]*Qd_101[1]*Qd_110[2]; double Q_010002010=Qd_010[0]*Qd_002[1]*Qd_010[2]; double Q_010002110=Qd_010[0]*Qd_002[1]*Qd_110[2]; double Q_010102010=Qd_010[0]*Qd_102[1]*Qd_010[2]; double Q_010102110=Qd_010[0]*Qd_102[1]*Qd_110[2]; double Q_010202010=Qd_010[0]*Qd_202[1]*Qd_010[2]; double Q_010202110=Qd_010[0]*Qd_202[1]*Qd_110[2]; double Q_110002010=Qd_110[0]*Qd_002[1]*Qd_010[2]; double Q_110002110=Qd_110[0]*Qd_002[1]*Qd_110[2]; double Q_110102010=Qd_110[0]*Qd_102[1]*Qd_010[2]; double Q_110102110=Qd_110[0]*Qd_102[1]*Qd_110[2]; double Q_110202010=Qd_110[0]*Qd_202[1]*Qd_010[2]; double Q_110202110=Qd_110[0]*Qd_202[1]*Qd_110[2]; double Q_011000011=Qd_011[0]*Qd_011[2]; double Q_011000111=Qd_011[0]*Qd_111[2]; double Q_011000211=Qd_011[0]*Qd_211[2]; double Q_111000011=Qd_111[0]*Qd_011[2]; double Q_111000111=Qd_111[0]*Qd_111[2]; double Q_111000211=Qd_111[0]*Qd_211[2]; double Q_211000011=Qd_211[0]*Qd_011[2]; double Q_211000111=Qd_211[0]*Qd_111[2]; double Q_211000211=Qd_211[0]*Qd_211[2]; double Q_010001011=Qd_010[0]*Qd_001[1]*Qd_011[2]; double Q_010001111=Qd_010[0]*Qd_001[1]*Qd_111[2]; double Q_010001211=Qd_010[0]*Qd_001[1]*Qd_211[2]; double Q_010101011=Qd_010[0]*Qd_101[1]*Qd_011[2]; double Q_010101111=Qd_010[0]*Qd_101[1]*Qd_111[2]; double Q_010101211=Qd_010[0]*Qd_101[1]*Qd_211[2]; double Q_110001011=Qd_110[0]*Qd_001[1]*Qd_011[2]; double Q_110001111=Qd_110[0]*Qd_001[1]*Qd_111[2]; double Q_110001211=Qd_110[0]*Qd_001[1]*Qd_211[2]; double Q_110101011=Qd_110[0]*Qd_101[1]*Qd_011[2]; double Q_110101111=Qd_110[0]*Qd_101[1]*Qd_111[2]; double Q_110101211=Qd_110[0]*Qd_101[1]*Qd_211[2]; double Q_010000012=Qd_010[0]*Qd_012[2]; double Q_010000112=Qd_010[0]*Qd_112[2]; double Q_010000212=Qd_010[0]*Qd_212[2]; double Q_010000312=Qd_010[0]*Qd_312[2]; double Q_110000012=Qd_110[0]*Qd_012[2]; double Q_110000112=Qd_110[0]*Qd_112[2]; double Q_110000212=Qd_110[0]*Qd_212[2]; double Q_110000312=Qd_110[0]*Qd_312[2]; double Q_002010010=Qd_002[0]*Qd_010[1]*Qd_010[2]; double Q_002010110=Qd_002[0]*Qd_010[1]*Qd_110[2]; double Q_002110010=Qd_002[0]*Qd_110[1]*Qd_010[2]; double Q_002110110=Qd_002[0]*Qd_110[1]*Qd_110[2]; double Q_102010010=Qd_102[0]*Qd_010[1]*Qd_010[2]; double Q_102010110=Qd_102[0]*Qd_010[1]*Qd_110[2]; double Q_102110010=Qd_102[0]*Qd_110[1]*Qd_010[2]; double Q_102110110=Qd_102[0]*Qd_110[1]*Qd_110[2]; double Q_202010010=Qd_202[0]*Qd_010[1]*Qd_010[2]; double Q_202010110=Qd_202[0]*Qd_010[1]*Qd_110[2]; double Q_202110010=Qd_202[0]*Qd_110[1]*Qd_010[2]; double Q_202110110=Qd_202[0]*Qd_110[1]*Qd_110[2]; double Q_001011010=Qd_001[0]*Qd_011[1]*Qd_010[2]; double Q_001011110=Qd_001[0]*Qd_011[1]*Qd_110[2]; double Q_001111010=Qd_001[0]*Qd_111[1]*Qd_010[2]; double Q_001111110=Qd_001[0]*Qd_111[1]*Qd_110[2]; double Q_001211010=Qd_001[0]*Qd_211[1]*Qd_010[2]; double Q_001211110=Qd_001[0]*Qd_211[1]*Qd_110[2]; double Q_101011010=Qd_101[0]*Qd_011[1]*Qd_010[2]; double Q_101011110=Qd_101[0]*Qd_011[1]*Qd_110[2]; double Q_101111010=Qd_101[0]*Qd_111[1]*Qd_010[2]; double Q_101111110=Qd_101[0]*Qd_111[1]*Qd_110[2]; double Q_101211010=Qd_101[0]*Qd_211[1]*Qd_010[2]; double Q_101211110=Qd_101[0]*Qd_211[1]*Qd_110[2]; double Q_000012010=Qd_012[1]*Qd_010[2]; double Q_000012110=Qd_012[1]*Qd_110[2]; double Q_000112010=Qd_112[1]*Qd_010[2]; double Q_000112110=Qd_112[1]*Qd_110[2]; double Q_000212010=Qd_212[1]*Qd_010[2]; double Q_000212110=Qd_212[1]*Qd_110[2]; double Q_000312010=Qd_312[1]*Qd_010[2]; double Q_000312110=Qd_312[1]*Qd_110[2]; double Q_001010011=Qd_001[0]*Qd_010[1]*Qd_011[2]; double Q_001010111=Qd_001[0]*Qd_010[1]*Qd_111[2]; double Q_001010211=Qd_001[0]*Qd_010[1]*Qd_211[2]; double Q_001110011=Qd_001[0]*Qd_110[1]*Qd_011[2]; double Q_001110111=Qd_001[0]*Qd_110[1]*Qd_111[2]; double Q_001110211=Qd_001[0]*Qd_110[1]*Qd_211[2]; double Q_101010011=Qd_101[0]*Qd_010[1]*Qd_011[2]; double Q_101010111=Qd_101[0]*Qd_010[1]*Qd_111[2]; double Q_101010211=Qd_101[0]*Qd_010[1]*Qd_211[2]; double Q_101110011=Qd_101[0]*Qd_110[1]*Qd_011[2]; double Q_101110111=Qd_101[0]*Qd_110[1]*Qd_111[2]; double Q_101110211=Qd_101[0]*Qd_110[1]*Qd_211[2]; double Q_000011011=Qd_011[1]*Qd_011[2]; double Q_000011111=Qd_011[1]*Qd_111[2]; double Q_000011211=Qd_011[1]*Qd_211[2]; double Q_000111011=Qd_111[1]*Qd_011[2]; double Q_000111111=Qd_111[1]*Qd_111[2]; double Q_000111211=Qd_111[1]*Qd_211[2]; double Q_000211011=Qd_211[1]*Qd_011[2]; double Q_000211111=Qd_211[1]*Qd_111[2]; double Q_000211211=Qd_211[1]*Qd_211[2]; double Q_000010012=Qd_010[1]*Qd_012[2]; double Q_000010112=Qd_010[1]*Qd_112[2]; double Q_000010212=Qd_010[1]*Qd_212[2]; double Q_000010312=Qd_010[1]*Qd_312[2]; double Q_000110012=Qd_110[1]*Qd_012[2]; double Q_000110112=Qd_110[1]*Qd_112[2]; double Q_000110212=Qd_110[1]*Qd_212[2]; double Q_000110312=Qd_110[1]*Qd_312[2]; double Q_002000020=Qd_002[0]*Qd_020[2]; double Q_002000120=Qd_002[0]*Qd_120[2]; double Q_002000220=Qd_002[0]*Qd_220[2]; double Q_102000020=Qd_102[0]*Qd_020[2]; double Q_102000120=Qd_102[0]*Qd_120[2]; double Q_102000220=Qd_102[0]*Qd_220[2]; double Q_202000020=Qd_202[0]*Qd_020[2]; double Q_202000120=Qd_202[0]*Qd_120[2]; double Q_202000220=Qd_202[0]*Qd_220[2]; double Q_001001020=Qd_001[0]*Qd_001[1]*Qd_020[2]; double Q_001001120=Qd_001[0]*Qd_001[1]*Qd_120[2]; double Q_001001220=Qd_001[0]*Qd_001[1]*Qd_220[2]; double Q_001101020=Qd_001[0]*Qd_101[1]*Qd_020[2]; double Q_001101120=Qd_001[0]*Qd_101[1]*Qd_120[2]; double Q_001101220=Qd_001[0]*Qd_101[1]*Qd_220[2]; double Q_101001020=Qd_101[0]*Qd_001[1]*Qd_020[2]; double Q_101001120=Qd_101[0]*Qd_001[1]*Qd_120[2]; double Q_101001220=Qd_101[0]*Qd_001[1]*Qd_220[2]; double Q_101101020=Qd_101[0]*Qd_101[1]*Qd_020[2]; double Q_101101120=Qd_101[0]*Qd_101[1]*Qd_120[2]; double Q_101101220=Qd_101[0]*Qd_101[1]*Qd_220[2]; double Q_000002020=Qd_002[1]*Qd_020[2]; double Q_000002120=Qd_002[1]*Qd_120[2]; double Q_000002220=Qd_002[1]*Qd_220[2]; double Q_000102020=Qd_102[1]*Qd_020[2]; double Q_000102120=Qd_102[1]*Qd_120[2]; double Q_000102220=Qd_102[1]*Qd_220[2]; double Q_000202020=Qd_202[1]*Qd_020[2]; double Q_000202120=Qd_202[1]*Qd_120[2]; double Q_000202220=Qd_202[1]*Qd_220[2]; double Q_001000021=Qd_001[0]*Qd_021[2]; double Q_001000121=Qd_001[0]*Qd_121[2]; double Q_001000221=Qd_001[0]*Qd_221[2]; double Q_001000321=Qd_001[0]*Qd_321[2]; double Q_101000021=Qd_101[0]*Qd_021[2]; double Q_101000121=Qd_101[0]*Qd_121[2]; double Q_101000221=Qd_101[0]*Qd_221[2]; double Q_101000321=Qd_101[0]*Qd_321[2]; double Q_000001021=Qd_001[1]*Qd_021[2]; double Q_000001121=Qd_001[1]*Qd_121[2]; double Q_000001221=Qd_001[1]*Qd_221[2]; double Q_000001321=Qd_001[1]*Qd_321[2]; double Q_000101021=Qd_101[1]*Qd_021[2]; double Q_000101121=Qd_101[1]*Qd_121[2]; double Q_000101221=Qd_101[1]*Qd_221[2]; double Q_000101321=Qd_101[1]*Qd_321[2]; double Q_000000022=Qd_022[2]; double Q_000000122=Qd_122[2]; double Q_000000222=Qd_222[2]; double Q_000000322=Qd_322[2]; double Q_000000422=Qd_422[2]; double QR_022000000000=Q_022000000*R_000[0]+-1*Q_122000000*R_100[0]+Q_222000000*R_200[0]+-1*Q_322000000*R_300[0]+Q_422000000*R_400[0]; double QR_021001000000=Q_021001000*R_000[0]+-1*Q_021101000*R_010[0]+-1*Q_121001000*R_100[0]+Q_121101000*R_110[0]+Q_221001000*R_200[0]+-1*Q_221101000*R_210[0]+-1*Q_321001000*R_300[0]+Q_321101000*R_310[0]; double QR_020002000000=Q_020002000*R_000[0]+-1*Q_020102000*R_010[0]+Q_020202000*R_020[0]+-1*Q_120002000*R_100[0]+Q_120102000*R_110[0]+-1*Q_120202000*R_120[0]+Q_220002000*R_200[0]+-1*Q_220102000*R_210[0]+Q_220202000*R_220[0]; double QR_021000001000=Q_021000001*R_000[0]+-1*Q_021000101*R_001[0]+-1*Q_121000001*R_100[0]+Q_121000101*R_101[0]+Q_221000001*R_200[0]+-1*Q_221000101*R_201[0]+-1*Q_321000001*R_300[0]+Q_321000101*R_301[0]; double QR_020001001000=Q_020001001*R_000[0]+-1*Q_020001101*R_001[0]+-1*Q_020101001*R_010[0]+Q_020101101*R_011[0]+-1*Q_120001001*R_100[0]+Q_120001101*R_101[0]+Q_120101001*R_110[0]+-1*Q_120101101*R_111[0]+Q_220001001*R_200[0]+-1*Q_220001101*R_201[0]+-1*Q_220101001*R_210[0]+Q_220101101*R_211[0]; double QR_020000002000=Q_020000002*R_000[0]+-1*Q_020000102*R_001[0]+Q_020000202*R_002[0]+-1*Q_120000002*R_100[0]+Q_120000102*R_101[0]+-1*Q_120000202*R_102[0]+Q_220000002*R_200[0]+-1*Q_220000102*R_201[0]+Q_220000202*R_202[0]; double QR_012010000000=Q_012010000*R_000[0]+-1*Q_012110000*R_010[0]+-1*Q_112010000*R_100[0]+Q_112110000*R_110[0]+Q_212010000*R_200[0]+-1*Q_212110000*R_210[0]+-1*Q_312010000*R_300[0]+Q_312110000*R_310[0]; double QR_011011000000=Q_011011000*R_000[0]+-1*Q_011111000*R_010[0]+Q_011211000*R_020[0]+-1*Q_111011000*R_100[0]+Q_111111000*R_110[0]+-1*Q_111211000*R_120[0]+Q_211011000*R_200[0]+-1*Q_211111000*R_210[0]+Q_211211000*R_220[0]; double QR_010012000000=Q_010012000*R_000[0]+-1*Q_010112000*R_010[0]+Q_010212000*R_020[0]+-1*Q_010312000*R_030[0]+-1*Q_110012000*R_100[0]+Q_110112000*R_110[0]+-1*Q_110212000*R_120[0]+Q_110312000*R_130[0]; double QR_011010001000=Q_011010001*R_000[0]+-1*Q_011010101*R_001[0]+-1*Q_011110001*R_010[0]+Q_011110101*R_011[0]+-1*Q_111010001*R_100[0]+Q_111010101*R_101[0]+Q_111110001*R_110[0]+-1*Q_111110101*R_111[0]+Q_211010001*R_200[0]+-1*Q_211010101*R_201[0]+-1*Q_211110001*R_210[0]+Q_211110101*R_211[0]; double QR_010011001000=Q_010011001*R_000[0]+-1*Q_010011101*R_001[0]+-1*Q_010111001*R_010[0]+Q_010111101*R_011[0]+Q_010211001*R_020[0]+-1*Q_010211101*R_021[0]+-1*Q_110011001*R_100[0]+Q_110011101*R_101[0]+Q_110111001*R_110[0]+-1*Q_110111101*R_111[0]+-1*Q_110211001*R_120[0]+Q_110211101*R_121[0]; double QR_010010002000=Q_010010002*R_000[0]+-1*Q_010010102*R_001[0]+Q_010010202*R_002[0]+-1*Q_010110002*R_010[0]+Q_010110102*R_011[0]+-1*Q_010110202*R_012[0]+-1*Q_110010002*R_100[0]+Q_110010102*R_101[0]+-1*Q_110010202*R_102[0]+Q_110110002*R_110[0]+-1*Q_110110102*R_111[0]+Q_110110202*R_112[0]; double QR_002020000000=Q_002020000*R_000[0]+-1*Q_002120000*R_010[0]+Q_002220000*R_020[0]+-1*Q_102020000*R_100[0]+Q_102120000*R_110[0]+-1*Q_102220000*R_120[0]+Q_202020000*R_200[0]+-1*Q_202120000*R_210[0]+Q_202220000*R_220[0]; double QR_001021000000=Q_001021000*R_000[0]+-1*Q_001121000*R_010[0]+Q_001221000*R_020[0]+-1*Q_001321000*R_030[0]+-1*Q_101021000*R_100[0]+Q_101121000*R_110[0]+-1*Q_101221000*R_120[0]+Q_101321000*R_130[0]; double QR_000022000000=Q_000022000*R_000[0]+-1*Q_000122000*R_010[0]+Q_000222000*R_020[0]+-1*Q_000322000*R_030[0]+Q_000422000*R_040[0]; double QR_001020001000=Q_001020001*R_000[0]+-1*Q_001020101*R_001[0]+-1*Q_001120001*R_010[0]+Q_001120101*R_011[0]+Q_001220001*R_020[0]+-1*Q_001220101*R_021[0]+-1*Q_101020001*R_100[0]+Q_101020101*R_101[0]+Q_101120001*R_110[0]+-1*Q_101120101*R_111[0]+-1*Q_101220001*R_120[0]+Q_101220101*R_121[0]; double QR_000021001000=Q_000021001*R_000[0]+-1*Q_000021101*R_001[0]+-1*Q_000121001*R_010[0]+Q_000121101*R_011[0]+Q_000221001*R_020[0]+-1*Q_000221101*R_021[0]+-1*Q_000321001*R_030[0]+Q_000321101*R_031[0]; double QR_000020002000=Q_000020002*R_000[0]+-1*Q_000020102*R_001[0]+Q_000020202*R_002[0]+-1*Q_000120002*R_010[0]+Q_000120102*R_011[0]+-1*Q_000120202*R_012[0]+Q_000220002*R_020[0]+-1*Q_000220102*R_021[0]+Q_000220202*R_022[0]; double QR_012000010000=Q_012000010*R_000[0]+-1*Q_012000110*R_001[0]+-1*Q_112000010*R_100[0]+Q_112000110*R_101[0]+Q_212000010*R_200[0]+-1*Q_212000110*R_201[0]+-1*Q_312000010*R_300[0]+Q_312000110*R_301[0]; double QR_011001010000=Q_011001010*R_000[0]+-1*Q_011001110*R_001[0]+-1*Q_011101010*R_010[0]+Q_011101110*R_011[0]+-1*Q_111001010*R_100[0]+Q_111001110*R_101[0]+Q_111101010*R_110[0]+-1*Q_111101110*R_111[0]+Q_211001010*R_200[0]+-1*Q_211001110*R_201[0]+-1*Q_211101010*R_210[0]+Q_211101110*R_211[0]; double QR_010002010000=Q_010002010*R_000[0]+-1*Q_010002110*R_001[0]+-1*Q_010102010*R_010[0]+Q_010102110*R_011[0]+Q_010202010*R_020[0]+-1*Q_010202110*R_021[0]+-1*Q_110002010*R_100[0]+Q_110002110*R_101[0]+Q_110102010*R_110[0]+-1*Q_110102110*R_111[0]+-1*Q_110202010*R_120[0]+Q_110202110*R_121[0]; double QR_011000011000=Q_011000011*R_000[0]+-1*Q_011000111*R_001[0]+Q_011000211*R_002[0]+-1*Q_111000011*R_100[0]+Q_111000111*R_101[0]+-1*Q_111000211*R_102[0]+Q_211000011*R_200[0]+-1*Q_211000111*R_201[0]+Q_211000211*R_202[0]; double QR_010001011000=Q_010001011*R_000[0]+-1*Q_010001111*R_001[0]+Q_010001211*R_002[0]+-1*Q_010101011*R_010[0]+Q_010101111*R_011[0]+-1*Q_010101211*R_012[0]+-1*Q_110001011*R_100[0]+Q_110001111*R_101[0]+-1*Q_110001211*R_102[0]+Q_110101011*R_110[0]+-1*Q_110101111*R_111[0]+Q_110101211*R_112[0]; double QR_010000012000=Q_010000012*R_000[0]+-1*Q_010000112*R_001[0]+Q_010000212*R_002[0]+-1*Q_010000312*R_003[0]+-1*Q_110000012*R_100[0]+Q_110000112*R_101[0]+-1*Q_110000212*R_102[0]+Q_110000312*R_103[0]; double QR_002010010000=Q_002010010*R_000[0]+-1*Q_002010110*R_001[0]+-1*Q_002110010*R_010[0]+Q_002110110*R_011[0]+-1*Q_102010010*R_100[0]+Q_102010110*R_101[0]+Q_102110010*R_110[0]+-1*Q_102110110*R_111[0]+Q_202010010*R_200[0]+-1*Q_202010110*R_201[0]+-1*Q_202110010*R_210[0]+Q_202110110*R_211[0]; double QR_001011010000=Q_001011010*R_000[0]+-1*Q_001011110*R_001[0]+-1*Q_001111010*R_010[0]+Q_001111110*R_011[0]+Q_001211010*R_020[0]+-1*Q_001211110*R_021[0]+-1*Q_101011010*R_100[0]+Q_101011110*R_101[0]+Q_101111010*R_110[0]+-1*Q_101111110*R_111[0]+-1*Q_101211010*R_120[0]+Q_101211110*R_121[0]; double QR_000012010000=Q_000012010*R_000[0]+-1*Q_000012110*R_001[0]+-1*Q_000112010*R_010[0]+Q_000112110*R_011[0]+Q_000212010*R_020[0]+-1*Q_000212110*R_021[0]+-1*Q_000312010*R_030[0]+Q_000312110*R_031[0]; double QR_001010011000=Q_001010011*R_000[0]+-1*Q_001010111*R_001[0]+Q_001010211*R_002[0]+-1*Q_001110011*R_010[0]+Q_001110111*R_011[0]+-1*Q_001110211*R_012[0]+-1*Q_101010011*R_100[0]+Q_101010111*R_101[0]+-1*Q_101010211*R_102[0]+Q_101110011*R_110[0]+-1*Q_101110111*R_111[0]+Q_101110211*R_112[0]; double QR_000011011000=Q_000011011*R_000[0]+-1*Q_000011111*R_001[0]+Q_000011211*R_002[0]+-1*Q_000111011*R_010[0]+Q_000111111*R_011[0]+-1*Q_000111211*R_012[0]+Q_000211011*R_020[0]+-1*Q_000211111*R_021[0]+Q_000211211*R_022[0]; double QR_000010012000=Q_000010012*R_000[0]+-1*Q_000010112*R_001[0]+Q_000010212*R_002[0]+-1*Q_000010312*R_003[0]+-1*Q_000110012*R_010[0]+Q_000110112*R_011[0]+-1*Q_000110212*R_012[0]+Q_000110312*R_013[0]; double QR_002000020000=Q_002000020*R_000[0]+-1*Q_002000120*R_001[0]+Q_002000220*R_002[0]+-1*Q_102000020*R_100[0]+Q_102000120*R_101[0]+-1*Q_102000220*R_102[0]+Q_202000020*R_200[0]+-1*Q_202000120*R_201[0]+Q_202000220*R_202[0]; double QR_001001020000=Q_001001020*R_000[0]+-1*Q_001001120*R_001[0]+Q_001001220*R_002[0]+-1*Q_001101020*R_010[0]+Q_001101120*R_011[0]+-1*Q_001101220*R_012[0]+-1*Q_101001020*R_100[0]+Q_101001120*R_101[0]+-1*Q_101001220*R_102[0]+Q_101101020*R_110[0]+-1*Q_101101120*R_111[0]+Q_101101220*R_112[0]; double QR_000002020000=Q_000002020*R_000[0]+-1*Q_000002120*R_001[0]+Q_000002220*R_002[0]+-1*Q_000102020*R_010[0]+Q_000102120*R_011[0]+-1*Q_000102220*R_012[0]+Q_000202020*R_020[0]+-1*Q_000202120*R_021[0]+Q_000202220*R_022[0]; double QR_001000021000=Q_001000021*R_000[0]+-1*Q_001000121*R_001[0]+Q_001000221*R_002[0]+-1*Q_001000321*R_003[0]+-1*Q_101000021*R_100[0]+Q_101000121*R_101[0]+-1*Q_101000221*R_102[0]+Q_101000321*R_103[0]; double QR_000001021000=Q_000001021*R_000[0]+-1*Q_000001121*R_001[0]+Q_000001221*R_002[0]+-1*Q_000001321*R_003[0]+-1*Q_000101021*R_010[0]+Q_000101121*R_011[0]+-1*Q_000101221*R_012[0]+Q_000101321*R_013[0]; double QR_000000022000=Q_000000022*R_000[0]+-1*Q_000000122*R_001[0]+Q_000000222*R_002[0]+-1*Q_000000322*R_003[0]+Q_000000422*R_004[0]; double QR_022000000001=Q_022000000*R_001[0]+-1*Q_122000000*R_101[0]+Q_222000000*R_201[0]+-1*Q_322000000*R_301[0]+Q_422000000*R_401[0]; double QR_021001000001=Q_021001000*R_001[0]+-1*Q_021101000*R_011[0]+-1*Q_121001000*R_101[0]+Q_121101000*R_111[0]+Q_221001000*R_201[0]+-1*Q_221101000*R_211[0]+-1*Q_321001000*R_301[0]+Q_321101000*R_311[0]; double QR_020002000001=Q_020002000*R_001[0]+-1*Q_020102000*R_011[0]+Q_020202000*R_021[0]+-1*Q_120002000*R_101[0]+Q_120102000*R_111[0]+-1*Q_120202000*R_121[0]+Q_220002000*R_201[0]+-1*Q_220102000*R_211[0]+Q_220202000*R_221[0]; double QR_021000001001=Q_021000001*R_001[0]+-1*Q_021000101*R_002[0]+-1*Q_121000001*R_101[0]+Q_121000101*R_102[0]+Q_221000001*R_201[0]+-1*Q_221000101*R_202[0]+-1*Q_321000001*R_301[0]+Q_321000101*R_302[0]; double QR_020001001001=Q_020001001*R_001[0]+-1*Q_020001101*R_002[0]+-1*Q_020101001*R_011[0]+Q_020101101*R_012[0]+-1*Q_120001001*R_101[0]+Q_120001101*R_102[0]+Q_120101001*R_111[0]+-1*Q_120101101*R_112[0]+Q_220001001*R_201[0]+-1*Q_220001101*R_202[0]+-1*Q_220101001*R_211[0]+Q_220101101*R_212[0]; double QR_020000002001=Q_020000002*R_001[0]+-1*Q_020000102*R_002[0]+Q_020000202*R_003[0]+-1*Q_120000002*R_101[0]+Q_120000102*R_102[0]+-1*Q_120000202*R_103[0]+Q_220000002*R_201[0]+-1*Q_220000102*R_202[0]+Q_220000202*R_203[0]; double QR_012010000001=Q_012010000*R_001[0]+-1*Q_012110000*R_011[0]+-1*Q_112010000*R_101[0]+Q_112110000*R_111[0]+Q_212010000*R_201[0]+-1*Q_212110000*R_211[0]+-1*Q_312010000*R_301[0]+Q_312110000*R_311[0]; double QR_011011000001=Q_011011000*R_001[0]+-1*Q_011111000*R_011[0]+Q_011211000*R_021[0]+-1*Q_111011000*R_101[0]+Q_111111000*R_111[0]+-1*Q_111211000*R_121[0]+Q_211011000*R_201[0]+-1*Q_211111000*R_211[0]+Q_211211000*R_221[0]; double QR_010012000001=Q_010012000*R_001[0]+-1*Q_010112000*R_011[0]+Q_010212000*R_021[0]+-1*Q_010312000*R_031[0]+-1*Q_110012000*R_101[0]+Q_110112000*R_111[0]+-1*Q_110212000*R_121[0]+Q_110312000*R_131[0]; double QR_011010001001=Q_011010001*R_001[0]+-1*Q_011010101*R_002[0]+-1*Q_011110001*R_011[0]+Q_011110101*R_012[0]+-1*Q_111010001*R_101[0]+Q_111010101*R_102[0]+Q_111110001*R_111[0]+-1*Q_111110101*R_112[0]+Q_211010001*R_201[0]+-1*Q_211010101*R_202[0]+-1*Q_211110001*R_211[0]+Q_211110101*R_212[0]; double QR_010011001001=Q_010011001*R_001[0]+-1*Q_010011101*R_002[0]+-1*Q_010111001*R_011[0]+Q_010111101*R_012[0]+Q_010211001*R_021[0]+-1*Q_010211101*R_022[0]+-1*Q_110011001*R_101[0]+Q_110011101*R_102[0]+Q_110111001*R_111[0]+-1*Q_110111101*R_112[0]+-1*Q_110211001*R_121[0]+Q_110211101*R_122[0]; double QR_010010002001=Q_010010002*R_001[0]+-1*Q_010010102*R_002[0]+Q_010010202*R_003[0]+-1*Q_010110002*R_011[0]+Q_010110102*R_012[0]+-1*Q_010110202*R_013[0]+-1*Q_110010002*R_101[0]+Q_110010102*R_102[0]+-1*Q_110010202*R_103[0]+Q_110110002*R_111[0]+-1*Q_110110102*R_112[0]+Q_110110202*R_113[0]; double QR_002020000001=Q_002020000*R_001[0]+-1*Q_002120000*R_011[0]+Q_002220000*R_021[0]+-1*Q_102020000*R_101[0]+Q_102120000*R_111[0]+-1*Q_102220000*R_121[0]+Q_202020000*R_201[0]+-1*Q_202120000*R_211[0]+Q_202220000*R_221[0]; double QR_001021000001=Q_001021000*R_001[0]+-1*Q_001121000*R_011[0]+Q_001221000*R_021[0]+-1*Q_001321000*R_031[0]+-1*Q_101021000*R_101[0]+Q_101121000*R_111[0]+-1*Q_101221000*R_121[0]+Q_101321000*R_131[0]; double QR_000022000001=Q_000022000*R_001[0]+-1*Q_000122000*R_011[0]+Q_000222000*R_021[0]+-1*Q_000322000*R_031[0]+Q_000422000*R_041[0]; double QR_001020001001=Q_001020001*R_001[0]+-1*Q_001020101*R_002[0]+-1*Q_001120001*R_011[0]+Q_001120101*R_012[0]+Q_001220001*R_021[0]+-1*Q_001220101*R_022[0]+-1*Q_101020001*R_101[0]+Q_101020101*R_102[0]+Q_101120001*R_111[0]+-1*Q_101120101*R_112[0]+-1*Q_101220001*R_121[0]+Q_101220101*R_122[0]; double QR_000021001001=Q_000021001*R_001[0]+-1*Q_000021101*R_002[0]+-1*Q_000121001*R_011[0]+Q_000121101*R_012[0]+Q_000221001*R_021[0]+-1*Q_000221101*R_022[0]+-1*Q_000321001*R_031[0]+Q_000321101*R_032[0]; double QR_000020002001=Q_000020002*R_001[0]+-1*Q_000020102*R_002[0]+Q_000020202*R_003[0]+-1*Q_000120002*R_011[0]+Q_000120102*R_012[0]+-1*Q_000120202*R_013[0]+Q_000220002*R_021[0]+-1*Q_000220102*R_022[0]+Q_000220202*R_023[0]; double QR_012000010001=Q_012000010*R_001[0]+-1*Q_012000110*R_002[0]+-1*Q_112000010*R_101[0]+Q_112000110*R_102[0]+Q_212000010*R_201[0]+-1*Q_212000110*R_202[0]+-1*Q_312000010*R_301[0]+Q_312000110*R_302[0]; double QR_011001010001=Q_011001010*R_001[0]+-1*Q_011001110*R_002[0]+-1*Q_011101010*R_011[0]+Q_011101110*R_012[0]+-1*Q_111001010*R_101[0]+Q_111001110*R_102[0]+Q_111101010*R_111[0]+-1*Q_111101110*R_112[0]+Q_211001010*R_201[0]+-1*Q_211001110*R_202[0]+-1*Q_211101010*R_211[0]+Q_211101110*R_212[0]; double QR_010002010001=Q_010002010*R_001[0]+-1*Q_010002110*R_002[0]+-1*Q_010102010*R_011[0]+Q_010102110*R_012[0]+Q_010202010*R_021[0]+-1*Q_010202110*R_022[0]+-1*Q_110002010*R_101[0]+Q_110002110*R_102[0]+Q_110102010*R_111[0]+-1*Q_110102110*R_112[0]+-1*Q_110202010*R_121[0]+Q_110202110*R_122[0]; double QR_011000011001=Q_011000011*R_001[0]+-1*Q_011000111*R_002[0]+Q_011000211*R_003[0]+-1*Q_111000011*R_101[0]+Q_111000111*R_102[0]+-1*Q_111000211*R_103[0]+Q_211000011*R_201[0]+-1*Q_211000111*R_202[0]+Q_211000211*R_203[0]; double QR_010001011001=Q_010001011*R_001[0]+-1*Q_010001111*R_002[0]+Q_010001211*R_003[0]+-1*Q_010101011*R_011[0]+Q_010101111*R_012[0]+-1*Q_010101211*R_013[0]+-1*Q_110001011*R_101[0]+Q_110001111*R_102[0]+-1*Q_110001211*R_103[0]+Q_110101011*R_111[0]+-1*Q_110101111*R_112[0]+Q_110101211*R_113[0]; double QR_010000012001=Q_010000012*R_001[0]+-1*Q_010000112*R_002[0]+Q_010000212*R_003[0]+-1*Q_010000312*R_004[0]+-1*Q_110000012*R_101[0]+Q_110000112*R_102[0]+-1*Q_110000212*R_103[0]+Q_110000312*R_104[0]; double QR_002010010001=Q_002010010*R_001[0]+-1*Q_002010110*R_002[0]+-1*Q_002110010*R_011[0]+Q_002110110*R_012[0]+-1*Q_102010010*R_101[0]+Q_102010110*R_102[0]+Q_102110010*R_111[0]+-1*Q_102110110*R_112[0]+Q_202010010*R_201[0]+-1*Q_202010110*R_202[0]+-1*Q_202110010*R_211[0]+Q_202110110*R_212[0]; double QR_001011010001=Q_001011010*R_001[0]+-1*Q_001011110*R_002[0]+-1*Q_001111010*R_011[0]+Q_001111110*R_012[0]+Q_001211010*R_021[0]+-1*Q_001211110*R_022[0]+-1*Q_101011010*R_101[0]+Q_101011110*R_102[0]+Q_101111010*R_111[0]+-1*Q_101111110*R_112[0]+-1*Q_101211010*R_121[0]+Q_101211110*R_122[0]; double QR_000012010001=Q_000012010*R_001[0]+-1*Q_000012110*R_002[0]+-1*Q_000112010*R_011[0]+Q_000112110*R_012[0]+Q_000212010*R_021[0]+-1*Q_000212110*R_022[0]+-1*Q_000312010*R_031[0]+Q_000312110*R_032[0]; double QR_001010011001=Q_001010011*R_001[0]+-1*Q_001010111*R_002[0]+Q_001010211*R_003[0]+-1*Q_001110011*R_011[0]+Q_001110111*R_012[0]+-1*Q_001110211*R_013[0]+-1*Q_101010011*R_101[0]+Q_101010111*R_102[0]+-1*Q_101010211*R_103[0]+Q_101110011*R_111[0]+-1*Q_101110111*R_112[0]+Q_101110211*R_113[0]; double QR_000011011001=Q_000011011*R_001[0]+-1*Q_000011111*R_002[0]+Q_000011211*R_003[0]+-1*Q_000111011*R_011[0]+Q_000111111*R_012[0]+-1*Q_000111211*R_013[0]+Q_000211011*R_021[0]+-1*Q_000211111*R_022[0]+Q_000211211*R_023[0]; double QR_000010012001=Q_000010012*R_001[0]+-1*Q_000010112*R_002[0]+Q_000010212*R_003[0]+-1*Q_000010312*R_004[0]+-1*Q_000110012*R_011[0]+Q_000110112*R_012[0]+-1*Q_000110212*R_013[0]+Q_000110312*R_014[0]; double QR_002000020001=Q_002000020*R_001[0]+-1*Q_002000120*R_002[0]+Q_002000220*R_003[0]+-1*Q_102000020*R_101[0]+Q_102000120*R_102[0]+-1*Q_102000220*R_103[0]+Q_202000020*R_201[0]+-1*Q_202000120*R_202[0]+Q_202000220*R_203[0]; double QR_001001020001=Q_001001020*R_001[0]+-1*Q_001001120*R_002[0]+Q_001001220*R_003[0]+-1*Q_001101020*R_011[0]+Q_001101120*R_012[0]+-1*Q_001101220*R_013[0]+-1*Q_101001020*R_101[0]+Q_101001120*R_102[0]+-1*Q_101001220*R_103[0]+Q_101101020*R_111[0]+-1*Q_101101120*R_112[0]+Q_101101220*R_113[0]; double QR_000002020001=Q_000002020*R_001[0]+-1*Q_000002120*R_002[0]+Q_000002220*R_003[0]+-1*Q_000102020*R_011[0]+Q_000102120*R_012[0]+-1*Q_000102220*R_013[0]+Q_000202020*R_021[0]+-1*Q_000202120*R_022[0]+Q_000202220*R_023[0]; double QR_001000021001=Q_001000021*R_001[0]+-1*Q_001000121*R_002[0]+Q_001000221*R_003[0]+-1*Q_001000321*R_004[0]+-1*Q_101000021*R_101[0]+Q_101000121*R_102[0]+-1*Q_101000221*R_103[0]+Q_101000321*R_104[0]; double QR_000001021001=Q_000001021*R_001[0]+-1*Q_000001121*R_002[0]+Q_000001221*R_003[0]+-1*Q_000001321*R_004[0]+-1*Q_000101021*R_011[0]+Q_000101121*R_012[0]+-1*Q_000101221*R_013[0]+Q_000101321*R_014[0]; double QR_000000022001=Q_000000022*R_001[0]+-1*Q_000000122*R_002[0]+Q_000000222*R_003[0]+-1*Q_000000322*R_004[0]+Q_000000422*R_005[0]; double QR_022000000010=Q_022000000*R_010[0]+-1*Q_122000000*R_110[0]+Q_222000000*R_210[0]+-1*Q_322000000*R_310[0]+Q_422000000*R_410[0]; double QR_021001000010=Q_021001000*R_010[0]+-1*Q_021101000*R_020[0]+-1*Q_121001000*R_110[0]+Q_121101000*R_120[0]+Q_221001000*R_210[0]+-1*Q_221101000*R_220[0]+-1*Q_321001000*R_310[0]+Q_321101000*R_320[0]; double QR_020002000010=Q_020002000*R_010[0]+-1*Q_020102000*R_020[0]+Q_020202000*R_030[0]+-1*Q_120002000*R_110[0]+Q_120102000*R_120[0]+-1*Q_120202000*R_130[0]+Q_220002000*R_210[0]+-1*Q_220102000*R_220[0]+Q_220202000*R_230[0]; double QR_021000001010=Q_021000001*R_010[0]+-1*Q_021000101*R_011[0]+-1*Q_121000001*R_110[0]+Q_121000101*R_111[0]+Q_221000001*R_210[0]+-1*Q_221000101*R_211[0]+-1*Q_321000001*R_310[0]+Q_321000101*R_311[0]; double QR_020001001010=Q_020001001*R_010[0]+-1*Q_020001101*R_011[0]+-1*Q_020101001*R_020[0]+Q_020101101*R_021[0]+-1*Q_120001001*R_110[0]+Q_120001101*R_111[0]+Q_120101001*R_120[0]+-1*Q_120101101*R_121[0]+Q_220001001*R_210[0]+-1*Q_220001101*R_211[0]+-1*Q_220101001*R_220[0]+Q_220101101*R_221[0]; double QR_020000002010=Q_020000002*R_010[0]+-1*Q_020000102*R_011[0]+Q_020000202*R_012[0]+-1*Q_120000002*R_110[0]+Q_120000102*R_111[0]+-1*Q_120000202*R_112[0]+Q_220000002*R_210[0]+-1*Q_220000102*R_211[0]+Q_220000202*R_212[0]; double QR_012010000010=Q_012010000*R_010[0]+-1*Q_012110000*R_020[0]+-1*Q_112010000*R_110[0]+Q_112110000*R_120[0]+Q_212010000*R_210[0]+-1*Q_212110000*R_220[0]+-1*Q_312010000*R_310[0]+Q_312110000*R_320[0]; double QR_011011000010=Q_011011000*R_010[0]+-1*Q_011111000*R_020[0]+Q_011211000*R_030[0]+-1*Q_111011000*R_110[0]+Q_111111000*R_120[0]+-1*Q_111211000*R_130[0]+Q_211011000*R_210[0]+-1*Q_211111000*R_220[0]+Q_211211000*R_230[0]; double QR_010012000010=Q_010012000*R_010[0]+-1*Q_010112000*R_020[0]+Q_010212000*R_030[0]+-1*Q_010312000*R_040[0]+-1*Q_110012000*R_110[0]+Q_110112000*R_120[0]+-1*Q_110212000*R_130[0]+Q_110312000*R_140[0]; double QR_011010001010=Q_011010001*R_010[0]+-1*Q_011010101*R_011[0]+-1*Q_011110001*R_020[0]+Q_011110101*R_021[0]+-1*Q_111010001*R_110[0]+Q_111010101*R_111[0]+Q_111110001*R_120[0]+-1*Q_111110101*R_121[0]+Q_211010001*R_210[0]+-1*Q_211010101*R_211[0]+-1*Q_211110001*R_220[0]+Q_211110101*R_221[0]; double QR_010011001010=Q_010011001*R_010[0]+-1*Q_010011101*R_011[0]+-1*Q_010111001*R_020[0]+Q_010111101*R_021[0]+Q_010211001*R_030[0]+-1*Q_010211101*R_031[0]+-1*Q_110011001*R_110[0]+Q_110011101*R_111[0]+Q_110111001*R_120[0]+-1*Q_110111101*R_121[0]+-1*Q_110211001*R_130[0]+Q_110211101*R_131[0]; double QR_010010002010=Q_010010002*R_010[0]+-1*Q_010010102*R_011[0]+Q_010010202*R_012[0]+-1*Q_010110002*R_020[0]+Q_010110102*R_021[0]+-1*Q_010110202*R_022[0]+-1*Q_110010002*R_110[0]+Q_110010102*R_111[0]+-1*Q_110010202*R_112[0]+Q_110110002*R_120[0]+-1*Q_110110102*R_121[0]+Q_110110202*R_122[0]; double QR_002020000010=Q_002020000*R_010[0]+-1*Q_002120000*R_020[0]+Q_002220000*R_030[0]+-1*Q_102020000*R_110[0]+Q_102120000*R_120[0]+-1*Q_102220000*R_130[0]+Q_202020000*R_210[0]+-1*Q_202120000*R_220[0]+Q_202220000*R_230[0]; double QR_001021000010=Q_001021000*R_010[0]+-1*Q_001121000*R_020[0]+Q_001221000*R_030[0]+-1*Q_001321000*R_040[0]+-1*Q_101021000*R_110[0]+Q_101121000*R_120[0]+-1*Q_101221000*R_130[0]+Q_101321000*R_140[0]; double QR_000022000010=Q_000022000*R_010[0]+-1*Q_000122000*R_020[0]+Q_000222000*R_030[0]+-1*Q_000322000*R_040[0]+Q_000422000*R_050[0]; double QR_001020001010=Q_001020001*R_010[0]+-1*Q_001020101*R_011[0]+-1*Q_001120001*R_020[0]+Q_001120101*R_021[0]+Q_001220001*R_030[0]+-1*Q_001220101*R_031[0]+-1*Q_101020001*R_110[0]+Q_101020101*R_111[0]+Q_101120001*R_120[0]+-1*Q_101120101*R_121[0]+-1*Q_101220001*R_130[0]+Q_101220101*R_131[0]; double QR_000021001010=Q_000021001*R_010[0]+-1*Q_000021101*R_011[0]+-1*Q_000121001*R_020[0]+Q_000121101*R_021[0]+Q_000221001*R_030[0]+-1*Q_000221101*R_031[0]+-1*Q_000321001*R_040[0]+Q_000321101*R_041[0]; double QR_000020002010=Q_000020002*R_010[0]+-1*Q_000020102*R_011[0]+Q_000020202*R_012[0]+-1*Q_000120002*R_020[0]+Q_000120102*R_021[0]+-1*Q_000120202*R_022[0]+Q_000220002*R_030[0]+-1*Q_000220102*R_031[0]+Q_000220202*R_032[0]; double QR_012000010010=Q_012000010*R_010[0]+-1*Q_012000110*R_011[0]+-1*Q_112000010*R_110[0]+Q_112000110*R_111[0]+Q_212000010*R_210[0]+-1*Q_212000110*R_211[0]+-1*Q_312000010*R_310[0]+Q_312000110*R_311[0]; double QR_011001010010=Q_011001010*R_010[0]+-1*Q_011001110*R_011[0]+-1*Q_011101010*R_020[0]+Q_011101110*R_021[0]+-1*Q_111001010*R_110[0]+Q_111001110*R_111[0]+Q_111101010*R_120[0]+-1*Q_111101110*R_121[0]+Q_211001010*R_210[0]+-1*Q_211001110*R_211[0]+-1*Q_211101010*R_220[0]+Q_211101110*R_221[0]; double QR_010002010010=Q_010002010*R_010[0]+-1*Q_010002110*R_011[0]+-1*Q_010102010*R_020[0]+Q_010102110*R_021[0]+Q_010202010*R_030[0]+-1*Q_010202110*R_031[0]+-1*Q_110002010*R_110[0]+Q_110002110*R_111[0]+Q_110102010*R_120[0]+-1*Q_110102110*R_121[0]+-1*Q_110202010*R_130[0]+Q_110202110*R_131[0]; double QR_011000011010=Q_011000011*R_010[0]+-1*Q_011000111*R_011[0]+Q_011000211*R_012[0]+-1*Q_111000011*R_110[0]+Q_111000111*R_111[0]+-1*Q_111000211*R_112[0]+Q_211000011*R_210[0]+-1*Q_211000111*R_211[0]+Q_211000211*R_212[0]; double QR_010001011010=Q_010001011*R_010[0]+-1*Q_010001111*R_011[0]+Q_010001211*R_012[0]+-1*Q_010101011*R_020[0]+Q_010101111*R_021[0]+-1*Q_010101211*R_022[0]+-1*Q_110001011*R_110[0]+Q_110001111*R_111[0]+-1*Q_110001211*R_112[0]+Q_110101011*R_120[0]+-1*Q_110101111*R_121[0]+Q_110101211*R_122[0]; double QR_010000012010=Q_010000012*R_010[0]+-1*Q_010000112*R_011[0]+Q_010000212*R_012[0]+-1*Q_010000312*R_013[0]+-1*Q_110000012*R_110[0]+Q_110000112*R_111[0]+-1*Q_110000212*R_112[0]+Q_110000312*R_113[0]; double QR_002010010010=Q_002010010*R_010[0]+-1*Q_002010110*R_011[0]+-1*Q_002110010*R_020[0]+Q_002110110*R_021[0]+-1*Q_102010010*R_110[0]+Q_102010110*R_111[0]+Q_102110010*R_120[0]+-1*Q_102110110*R_121[0]+Q_202010010*R_210[0]+-1*Q_202010110*R_211[0]+-1*Q_202110010*R_220[0]+Q_202110110*R_221[0]; double QR_001011010010=Q_001011010*R_010[0]+-1*Q_001011110*R_011[0]+-1*Q_001111010*R_020[0]+Q_001111110*R_021[0]+Q_001211010*R_030[0]+-1*Q_001211110*R_031[0]+-1*Q_101011010*R_110[0]+Q_101011110*R_111[0]+Q_101111010*R_120[0]+-1*Q_101111110*R_121[0]+-1*Q_101211010*R_130[0]+Q_101211110*R_131[0]; double QR_000012010010=Q_000012010*R_010[0]+-1*Q_000012110*R_011[0]+-1*Q_000112010*R_020[0]+Q_000112110*R_021[0]+Q_000212010*R_030[0]+-1*Q_000212110*R_031[0]+-1*Q_000312010*R_040[0]+Q_000312110*R_041[0]; double QR_001010011010=Q_001010011*R_010[0]+-1*Q_001010111*R_011[0]+Q_001010211*R_012[0]+-1*Q_001110011*R_020[0]+Q_001110111*R_021[0]+-1*Q_001110211*R_022[0]+-1*Q_101010011*R_110[0]+Q_101010111*R_111[0]+-1*Q_101010211*R_112[0]+Q_101110011*R_120[0]+-1*Q_101110111*R_121[0]+Q_101110211*R_122[0]; double QR_000011011010=Q_000011011*R_010[0]+-1*Q_000011111*R_011[0]+Q_000011211*R_012[0]+-1*Q_000111011*R_020[0]+Q_000111111*R_021[0]+-1*Q_000111211*R_022[0]+Q_000211011*R_030[0]+-1*Q_000211111*R_031[0]+Q_000211211*R_032[0]; double QR_000010012010=Q_000010012*R_010[0]+-1*Q_000010112*R_011[0]+Q_000010212*R_012[0]+-1*Q_000010312*R_013[0]+-1*Q_000110012*R_020[0]+Q_000110112*R_021[0]+-1*Q_000110212*R_022[0]+Q_000110312*R_023[0]; double QR_002000020010=Q_002000020*R_010[0]+-1*Q_002000120*R_011[0]+Q_002000220*R_012[0]+-1*Q_102000020*R_110[0]+Q_102000120*R_111[0]+-1*Q_102000220*R_112[0]+Q_202000020*R_210[0]+-1*Q_202000120*R_211[0]+Q_202000220*R_212[0]; double QR_001001020010=Q_001001020*R_010[0]+-1*Q_001001120*R_011[0]+Q_001001220*R_012[0]+-1*Q_001101020*R_020[0]+Q_001101120*R_021[0]+-1*Q_001101220*R_022[0]+-1*Q_101001020*R_110[0]+Q_101001120*R_111[0]+-1*Q_101001220*R_112[0]+Q_101101020*R_120[0]+-1*Q_101101120*R_121[0]+Q_101101220*R_122[0]; double QR_000002020010=Q_000002020*R_010[0]+-1*Q_000002120*R_011[0]+Q_000002220*R_012[0]+-1*Q_000102020*R_020[0]+Q_000102120*R_021[0]+-1*Q_000102220*R_022[0]+Q_000202020*R_030[0]+-1*Q_000202120*R_031[0]+Q_000202220*R_032[0]; double QR_001000021010=Q_001000021*R_010[0]+-1*Q_001000121*R_011[0]+Q_001000221*R_012[0]+-1*Q_001000321*R_013[0]+-1*Q_101000021*R_110[0]+Q_101000121*R_111[0]+-1*Q_101000221*R_112[0]+Q_101000321*R_113[0]; double QR_000001021010=Q_000001021*R_010[0]+-1*Q_000001121*R_011[0]+Q_000001221*R_012[0]+-1*Q_000001321*R_013[0]+-1*Q_000101021*R_020[0]+Q_000101121*R_021[0]+-1*Q_000101221*R_022[0]+Q_000101321*R_023[0]; double QR_000000022010=Q_000000022*R_010[0]+-1*Q_000000122*R_011[0]+Q_000000222*R_012[0]+-1*Q_000000322*R_013[0]+Q_000000422*R_014[0]; double QR_022000000100=Q_022000000*R_100[0]+-1*Q_122000000*R_200[0]+Q_222000000*R_300[0]+-1*Q_322000000*R_400[0]+Q_422000000*R_500[0]; double QR_021001000100=Q_021001000*R_100[0]+-1*Q_021101000*R_110[0]+-1*Q_121001000*R_200[0]+Q_121101000*R_210[0]+Q_221001000*R_300[0]+-1*Q_221101000*R_310[0]+-1*Q_321001000*R_400[0]+Q_321101000*R_410[0]; double QR_020002000100=Q_020002000*R_100[0]+-1*Q_020102000*R_110[0]+Q_020202000*R_120[0]+-1*Q_120002000*R_200[0]+Q_120102000*R_210[0]+-1*Q_120202000*R_220[0]+Q_220002000*R_300[0]+-1*Q_220102000*R_310[0]+Q_220202000*R_320[0]; double QR_021000001100=Q_021000001*R_100[0]+-1*Q_021000101*R_101[0]+-1*Q_121000001*R_200[0]+Q_121000101*R_201[0]+Q_221000001*R_300[0]+-1*Q_221000101*R_301[0]+-1*Q_321000001*R_400[0]+Q_321000101*R_401[0]; double QR_020001001100=Q_020001001*R_100[0]+-1*Q_020001101*R_101[0]+-1*Q_020101001*R_110[0]+Q_020101101*R_111[0]+-1*Q_120001001*R_200[0]+Q_120001101*R_201[0]+Q_120101001*R_210[0]+-1*Q_120101101*R_211[0]+Q_220001001*R_300[0]+-1*Q_220001101*R_301[0]+-1*Q_220101001*R_310[0]+Q_220101101*R_311[0]; double QR_020000002100=Q_020000002*R_100[0]+-1*Q_020000102*R_101[0]+Q_020000202*R_102[0]+-1*Q_120000002*R_200[0]+Q_120000102*R_201[0]+-1*Q_120000202*R_202[0]+Q_220000002*R_300[0]+-1*Q_220000102*R_301[0]+Q_220000202*R_302[0]; double QR_012010000100=Q_012010000*R_100[0]+-1*Q_012110000*R_110[0]+-1*Q_112010000*R_200[0]+Q_112110000*R_210[0]+Q_212010000*R_300[0]+-1*Q_212110000*R_310[0]+-1*Q_312010000*R_400[0]+Q_312110000*R_410[0]; double QR_011011000100=Q_011011000*R_100[0]+-1*Q_011111000*R_110[0]+Q_011211000*R_120[0]+-1*Q_111011000*R_200[0]+Q_111111000*R_210[0]+-1*Q_111211000*R_220[0]+Q_211011000*R_300[0]+-1*Q_211111000*R_310[0]+Q_211211000*R_320[0]; double QR_010012000100=Q_010012000*R_100[0]+-1*Q_010112000*R_110[0]+Q_010212000*R_120[0]+-1*Q_010312000*R_130[0]+-1*Q_110012000*R_200[0]+Q_110112000*R_210[0]+-1*Q_110212000*R_220[0]+Q_110312000*R_230[0]; double QR_011010001100=Q_011010001*R_100[0]+-1*Q_011010101*R_101[0]+-1*Q_011110001*R_110[0]+Q_011110101*R_111[0]+-1*Q_111010001*R_200[0]+Q_111010101*R_201[0]+Q_111110001*R_210[0]+-1*Q_111110101*R_211[0]+Q_211010001*R_300[0]+-1*Q_211010101*R_301[0]+-1*Q_211110001*R_310[0]+Q_211110101*R_311[0]; double QR_010011001100=Q_010011001*R_100[0]+-1*Q_010011101*R_101[0]+-1*Q_010111001*R_110[0]+Q_010111101*R_111[0]+Q_010211001*R_120[0]+-1*Q_010211101*R_121[0]+-1*Q_110011001*R_200[0]+Q_110011101*R_201[0]+Q_110111001*R_210[0]+-1*Q_110111101*R_211[0]+-1*Q_110211001*R_220[0]+Q_110211101*R_221[0]; double QR_010010002100=Q_010010002*R_100[0]+-1*Q_010010102*R_101[0]+Q_010010202*R_102[0]+-1*Q_010110002*R_110[0]+Q_010110102*R_111[0]+-1*Q_010110202*R_112[0]+-1*Q_110010002*R_200[0]+Q_110010102*R_201[0]+-1*Q_110010202*R_202[0]+Q_110110002*R_210[0]+-1*Q_110110102*R_211[0]+Q_110110202*R_212[0]; double QR_002020000100=Q_002020000*R_100[0]+-1*Q_002120000*R_110[0]+Q_002220000*R_120[0]+-1*Q_102020000*R_200[0]+Q_102120000*R_210[0]+-1*Q_102220000*R_220[0]+Q_202020000*R_300[0]+-1*Q_202120000*R_310[0]+Q_202220000*R_320[0]; double QR_001021000100=Q_001021000*R_100[0]+-1*Q_001121000*R_110[0]+Q_001221000*R_120[0]+-1*Q_001321000*R_130[0]+-1*Q_101021000*R_200[0]+Q_101121000*R_210[0]+-1*Q_101221000*R_220[0]+Q_101321000*R_230[0]; double QR_000022000100=Q_000022000*R_100[0]+-1*Q_000122000*R_110[0]+Q_000222000*R_120[0]+-1*Q_000322000*R_130[0]+Q_000422000*R_140[0]; double QR_001020001100=Q_001020001*R_100[0]+-1*Q_001020101*R_101[0]+-1*Q_001120001*R_110[0]+Q_001120101*R_111[0]+Q_001220001*R_120[0]+-1*Q_001220101*R_121[0]+-1*Q_101020001*R_200[0]+Q_101020101*R_201[0]+Q_101120001*R_210[0]+-1*Q_101120101*R_211[0]+-1*Q_101220001*R_220[0]+Q_101220101*R_221[0]; double QR_000021001100=Q_000021001*R_100[0]+-1*Q_000021101*R_101[0]+-1*Q_000121001*R_110[0]+Q_000121101*R_111[0]+Q_000221001*R_120[0]+-1*Q_000221101*R_121[0]+-1*Q_000321001*R_130[0]+Q_000321101*R_131[0]; double QR_000020002100=Q_000020002*R_100[0]+-1*Q_000020102*R_101[0]+Q_000020202*R_102[0]+-1*Q_000120002*R_110[0]+Q_000120102*R_111[0]+-1*Q_000120202*R_112[0]+Q_000220002*R_120[0]+-1*Q_000220102*R_121[0]+Q_000220202*R_122[0]; double QR_012000010100=Q_012000010*R_100[0]+-1*Q_012000110*R_101[0]+-1*Q_112000010*R_200[0]+Q_112000110*R_201[0]+Q_212000010*R_300[0]+-1*Q_212000110*R_301[0]+-1*Q_312000010*R_400[0]+Q_312000110*R_401[0]; double QR_011001010100=Q_011001010*R_100[0]+-1*Q_011001110*R_101[0]+-1*Q_011101010*R_110[0]+Q_011101110*R_111[0]+-1*Q_111001010*R_200[0]+Q_111001110*R_201[0]+Q_111101010*R_210[0]+-1*Q_111101110*R_211[0]+Q_211001010*R_300[0]+-1*Q_211001110*R_301[0]+-1*Q_211101010*R_310[0]+Q_211101110*R_311[0]; double QR_010002010100=Q_010002010*R_100[0]+-1*Q_010002110*R_101[0]+-1*Q_010102010*R_110[0]+Q_010102110*R_111[0]+Q_010202010*R_120[0]+-1*Q_010202110*R_121[0]+-1*Q_110002010*R_200[0]+Q_110002110*R_201[0]+Q_110102010*R_210[0]+-1*Q_110102110*R_211[0]+-1*Q_110202010*R_220[0]+Q_110202110*R_221[0]; double QR_011000011100=Q_011000011*R_100[0]+-1*Q_011000111*R_101[0]+Q_011000211*R_102[0]+-1*Q_111000011*R_200[0]+Q_111000111*R_201[0]+-1*Q_111000211*R_202[0]+Q_211000011*R_300[0]+-1*Q_211000111*R_301[0]+Q_211000211*R_302[0]; double QR_010001011100=Q_010001011*R_100[0]+-1*Q_010001111*R_101[0]+Q_010001211*R_102[0]+-1*Q_010101011*R_110[0]+Q_010101111*R_111[0]+-1*Q_010101211*R_112[0]+-1*Q_110001011*R_200[0]+Q_110001111*R_201[0]+-1*Q_110001211*R_202[0]+Q_110101011*R_210[0]+-1*Q_110101111*R_211[0]+Q_110101211*R_212[0]; double QR_010000012100=Q_010000012*R_100[0]+-1*Q_010000112*R_101[0]+Q_010000212*R_102[0]+-1*Q_010000312*R_103[0]+-1*Q_110000012*R_200[0]+Q_110000112*R_201[0]+-1*Q_110000212*R_202[0]+Q_110000312*R_203[0]; double QR_002010010100=Q_002010010*R_100[0]+-1*Q_002010110*R_101[0]+-1*Q_002110010*R_110[0]+Q_002110110*R_111[0]+-1*Q_102010010*R_200[0]+Q_102010110*R_201[0]+Q_102110010*R_210[0]+-1*Q_102110110*R_211[0]+Q_202010010*R_300[0]+-1*Q_202010110*R_301[0]+-1*Q_202110010*R_310[0]+Q_202110110*R_311[0]; double QR_001011010100=Q_001011010*R_100[0]+-1*Q_001011110*R_101[0]+-1*Q_001111010*R_110[0]+Q_001111110*R_111[0]+Q_001211010*R_120[0]+-1*Q_001211110*R_121[0]+-1*Q_101011010*R_200[0]+Q_101011110*R_201[0]+Q_101111010*R_210[0]+-1*Q_101111110*R_211[0]+-1*Q_101211010*R_220[0]+Q_101211110*R_221[0]; double QR_000012010100=Q_000012010*R_100[0]+-1*Q_000012110*R_101[0]+-1*Q_000112010*R_110[0]+Q_000112110*R_111[0]+Q_000212010*R_120[0]+-1*Q_000212110*R_121[0]+-1*Q_000312010*R_130[0]+Q_000312110*R_131[0]; double QR_001010011100=Q_001010011*R_100[0]+-1*Q_001010111*R_101[0]+Q_001010211*R_102[0]+-1*Q_001110011*R_110[0]+Q_001110111*R_111[0]+-1*Q_001110211*R_112[0]+-1*Q_101010011*R_200[0]+Q_101010111*R_201[0]+-1*Q_101010211*R_202[0]+Q_101110011*R_210[0]+-1*Q_101110111*R_211[0]+Q_101110211*R_212[0]; double QR_000011011100=Q_000011011*R_100[0]+-1*Q_000011111*R_101[0]+Q_000011211*R_102[0]+-1*Q_000111011*R_110[0]+Q_000111111*R_111[0]+-1*Q_000111211*R_112[0]+Q_000211011*R_120[0]+-1*Q_000211111*R_121[0]+Q_000211211*R_122[0]; double QR_000010012100=Q_000010012*R_100[0]+-1*Q_000010112*R_101[0]+Q_000010212*R_102[0]+-1*Q_000010312*R_103[0]+-1*Q_000110012*R_110[0]+Q_000110112*R_111[0]+-1*Q_000110212*R_112[0]+Q_000110312*R_113[0]; double QR_002000020100=Q_002000020*R_100[0]+-1*Q_002000120*R_101[0]+Q_002000220*R_102[0]+-1*Q_102000020*R_200[0]+Q_102000120*R_201[0]+-1*Q_102000220*R_202[0]+Q_202000020*R_300[0]+-1*Q_202000120*R_301[0]+Q_202000220*R_302[0]; double QR_001001020100=Q_001001020*R_100[0]+-1*Q_001001120*R_101[0]+Q_001001220*R_102[0]+-1*Q_001101020*R_110[0]+Q_001101120*R_111[0]+-1*Q_001101220*R_112[0]+-1*Q_101001020*R_200[0]+Q_101001120*R_201[0]+-1*Q_101001220*R_202[0]+Q_101101020*R_210[0]+-1*Q_101101120*R_211[0]+Q_101101220*R_212[0]; double QR_000002020100=Q_000002020*R_100[0]+-1*Q_000002120*R_101[0]+Q_000002220*R_102[0]+-1*Q_000102020*R_110[0]+Q_000102120*R_111[0]+-1*Q_000102220*R_112[0]+Q_000202020*R_120[0]+-1*Q_000202120*R_121[0]+Q_000202220*R_122[0]; double QR_001000021100=Q_001000021*R_100[0]+-1*Q_001000121*R_101[0]+Q_001000221*R_102[0]+-1*Q_001000321*R_103[0]+-1*Q_101000021*R_200[0]+Q_101000121*R_201[0]+-1*Q_101000221*R_202[0]+Q_101000321*R_203[0]; double QR_000001021100=Q_000001021*R_100[0]+-1*Q_000001121*R_101[0]+Q_000001221*R_102[0]+-1*Q_000001321*R_103[0]+-1*Q_000101021*R_110[0]+Q_000101121*R_111[0]+-1*Q_000101221*R_112[0]+Q_000101321*R_113[0]; double QR_000000022100=Q_000000022*R_100[0]+-1*Q_000000122*R_101[0]+Q_000000222*R_102[0]+-1*Q_000000322*R_103[0]+Q_000000422*R_104[0]; double QR_022000000002=Q_022000000*R_002[0]+-1*Q_122000000*R_102[0]+Q_222000000*R_202[0]+-1*Q_322000000*R_302[0]+Q_422000000*R_402[0]; double QR_021001000002=Q_021001000*R_002[0]+-1*Q_021101000*R_012[0]+-1*Q_121001000*R_102[0]+Q_121101000*R_112[0]+Q_221001000*R_202[0]+-1*Q_221101000*R_212[0]+-1*Q_321001000*R_302[0]+Q_321101000*R_312[0]; double QR_020002000002=Q_020002000*R_002[0]+-1*Q_020102000*R_012[0]+Q_020202000*R_022[0]+-1*Q_120002000*R_102[0]+Q_120102000*R_112[0]+-1*Q_120202000*R_122[0]+Q_220002000*R_202[0]+-1*Q_220102000*R_212[0]+Q_220202000*R_222[0]; double QR_021000001002=Q_021000001*R_002[0]+-1*Q_021000101*R_003[0]+-1*Q_121000001*R_102[0]+Q_121000101*R_103[0]+Q_221000001*R_202[0]+-1*Q_221000101*R_203[0]+-1*Q_321000001*R_302[0]+Q_321000101*R_303[0]; double QR_020001001002=Q_020001001*R_002[0]+-1*Q_020001101*R_003[0]+-1*Q_020101001*R_012[0]+Q_020101101*R_013[0]+-1*Q_120001001*R_102[0]+Q_120001101*R_103[0]+Q_120101001*R_112[0]+-1*Q_120101101*R_113[0]+Q_220001001*R_202[0]+-1*Q_220001101*R_203[0]+-1*Q_220101001*R_212[0]+Q_220101101*R_213[0]; double QR_020000002002=Q_020000002*R_002[0]+-1*Q_020000102*R_003[0]+Q_020000202*R_004[0]+-1*Q_120000002*R_102[0]+Q_120000102*R_103[0]+-1*Q_120000202*R_104[0]+Q_220000002*R_202[0]+-1*Q_220000102*R_203[0]+Q_220000202*R_204[0]; double QR_012010000002=Q_012010000*R_002[0]+-1*Q_012110000*R_012[0]+-1*Q_112010000*R_102[0]+Q_112110000*R_112[0]+Q_212010000*R_202[0]+-1*Q_212110000*R_212[0]+-1*Q_312010000*R_302[0]+Q_312110000*R_312[0]; double QR_011011000002=Q_011011000*R_002[0]+-1*Q_011111000*R_012[0]+Q_011211000*R_022[0]+-1*Q_111011000*R_102[0]+Q_111111000*R_112[0]+-1*Q_111211000*R_122[0]+Q_211011000*R_202[0]+-1*Q_211111000*R_212[0]+Q_211211000*R_222[0]; double QR_010012000002=Q_010012000*R_002[0]+-1*Q_010112000*R_012[0]+Q_010212000*R_022[0]+-1*Q_010312000*R_032[0]+-1*Q_110012000*R_102[0]+Q_110112000*R_112[0]+-1*Q_110212000*R_122[0]+Q_110312000*R_132[0]; double QR_011010001002=Q_011010001*R_002[0]+-1*Q_011010101*R_003[0]+-1*Q_011110001*R_012[0]+Q_011110101*R_013[0]+-1*Q_111010001*R_102[0]+Q_111010101*R_103[0]+Q_111110001*R_112[0]+-1*Q_111110101*R_113[0]+Q_211010001*R_202[0]+-1*Q_211010101*R_203[0]+-1*Q_211110001*R_212[0]+Q_211110101*R_213[0]; double QR_010011001002=Q_010011001*R_002[0]+-1*Q_010011101*R_003[0]+-1*Q_010111001*R_012[0]+Q_010111101*R_013[0]+Q_010211001*R_022[0]+-1*Q_010211101*R_023[0]+-1*Q_110011001*R_102[0]+Q_110011101*R_103[0]+Q_110111001*R_112[0]+-1*Q_110111101*R_113[0]+-1*Q_110211001*R_122[0]+Q_110211101*R_123[0]; double QR_010010002002=Q_010010002*R_002[0]+-1*Q_010010102*R_003[0]+Q_010010202*R_004[0]+-1*Q_010110002*R_012[0]+Q_010110102*R_013[0]+-1*Q_010110202*R_014[0]+-1*Q_110010002*R_102[0]+Q_110010102*R_103[0]+-1*Q_110010202*R_104[0]+Q_110110002*R_112[0]+-1*Q_110110102*R_113[0]+Q_110110202*R_114[0]; double QR_002020000002=Q_002020000*R_002[0]+-1*Q_002120000*R_012[0]+Q_002220000*R_022[0]+-1*Q_102020000*R_102[0]+Q_102120000*R_112[0]+-1*Q_102220000*R_122[0]+Q_202020000*R_202[0]+-1*Q_202120000*R_212[0]+Q_202220000*R_222[0]; double QR_001021000002=Q_001021000*R_002[0]+-1*Q_001121000*R_012[0]+Q_001221000*R_022[0]+-1*Q_001321000*R_032[0]+-1*Q_101021000*R_102[0]+Q_101121000*R_112[0]+-1*Q_101221000*R_122[0]+Q_101321000*R_132[0]; double QR_000022000002=Q_000022000*R_002[0]+-1*Q_000122000*R_012[0]+Q_000222000*R_022[0]+-1*Q_000322000*R_032[0]+Q_000422000*R_042[0]; double QR_001020001002=Q_001020001*R_002[0]+-1*Q_001020101*R_003[0]+-1*Q_001120001*R_012[0]+Q_001120101*R_013[0]+Q_001220001*R_022[0]+-1*Q_001220101*R_023[0]+-1*Q_101020001*R_102[0]+Q_101020101*R_103[0]+Q_101120001*R_112[0]+-1*Q_101120101*R_113[0]+-1*Q_101220001*R_122[0]+Q_101220101*R_123[0]; double QR_000021001002=Q_000021001*R_002[0]+-1*Q_000021101*R_003[0]+-1*Q_000121001*R_012[0]+Q_000121101*R_013[0]+Q_000221001*R_022[0]+-1*Q_000221101*R_023[0]+-1*Q_000321001*R_032[0]+Q_000321101*R_033[0]; double QR_000020002002=Q_000020002*R_002[0]+-1*Q_000020102*R_003[0]+Q_000020202*R_004[0]+-1*Q_000120002*R_012[0]+Q_000120102*R_013[0]+-1*Q_000120202*R_014[0]+Q_000220002*R_022[0]+-1*Q_000220102*R_023[0]+Q_000220202*R_024[0]; double QR_012000010002=Q_012000010*R_002[0]+-1*Q_012000110*R_003[0]+-1*Q_112000010*R_102[0]+Q_112000110*R_103[0]+Q_212000010*R_202[0]+-1*Q_212000110*R_203[0]+-1*Q_312000010*R_302[0]+Q_312000110*R_303[0]; double QR_011001010002=Q_011001010*R_002[0]+-1*Q_011001110*R_003[0]+-1*Q_011101010*R_012[0]+Q_011101110*R_013[0]+-1*Q_111001010*R_102[0]+Q_111001110*R_103[0]+Q_111101010*R_112[0]+-1*Q_111101110*R_113[0]+Q_211001010*R_202[0]+-1*Q_211001110*R_203[0]+-1*Q_211101010*R_212[0]+Q_211101110*R_213[0]; double QR_010002010002=Q_010002010*R_002[0]+-1*Q_010002110*R_003[0]+-1*Q_010102010*R_012[0]+Q_010102110*R_013[0]+Q_010202010*R_022[0]+-1*Q_010202110*R_023[0]+-1*Q_110002010*R_102[0]+Q_110002110*R_103[0]+Q_110102010*R_112[0]+-1*Q_110102110*R_113[0]+-1*Q_110202010*R_122[0]+Q_110202110*R_123[0]; double QR_011000011002=Q_011000011*R_002[0]+-1*Q_011000111*R_003[0]+Q_011000211*R_004[0]+-1*Q_111000011*R_102[0]+Q_111000111*R_103[0]+-1*Q_111000211*R_104[0]+Q_211000011*R_202[0]+-1*Q_211000111*R_203[0]+Q_211000211*R_204[0]; double QR_010001011002=Q_010001011*R_002[0]+-1*Q_010001111*R_003[0]+Q_010001211*R_004[0]+-1*Q_010101011*R_012[0]+Q_010101111*R_013[0]+-1*Q_010101211*R_014[0]+-1*Q_110001011*R_102[0]+Q_110001111*R_103[0]+-1*Q_110001211*R_104[0]+Q_110101011*R_112[0]+-1*Q_110101111*R_113[0]+Q_110101211*R_114[0]; double QR_010000012002=Q_010000012*R_002[0]+-1*Q_010000112*R_003[0]+Q_010000212*R_004[0]+-1*Q_010000312*R_005[0]+-1*Q_110000012*R_102[0]+Q_110000112*R_103[0]+-1*Q_110000212*R_104[0]+Q_110000312*R_105[0]; double QR_002010010002=Q_002010010*R_002[0]+-1*Q_002010110*R_003[0]+-1*Q_002110010*R_012[0]+Q_002110110*R_013[0]+-1*Q_102010010*R_102[0]+Q_102010110*R_103[0]+Q_102110010*R_112[0]+-1*Q_102110110*R_113[0]+Q_202010010*R_202[0]+-1*Q_202010110*R_203[0]+-1*Q_202110010*R_212[0]+Q_202110110*R_213[0]; double QR_001011010002=Q_001011010*R_002[0]+-1*Q_001011110*R_003[0]+-1*Q_001111010*R_012[0]+Q_001111110*R_013[0]+Q_001211010*R_022[0]+-1*Q_001211110*R_023[0]+-1*Q_101011010*R_102[0]+Q_101011110*R_103[0]+Q_101111010*R_112[0]+-1*Q_101111110*R_113[0]+-1*Q_101211010*R_122[0]+Q_101211110*R_123[0]; double QR_000012010002=Q_000012010*R_002[0]+-1*Q_000012110*R_003[0]+-1*Q_000112010*R_012[0]+Q_000112110*R_013[0]+Q_000212010*R_022[0]+-1*Q_000212110*R_023[0]+-1*Q_000312010*R_032[0]+Q_000312110*R_033[0]; double QR_001010011002=Q_001010011*R_002[0]+-1*Q_001010111*R_003[0]+Q_001010211*R_004[0]+-1*Q_001110011*R_012[0]+Q_001110111*R_013[0]+-1*Q_001110211*R_014[0]+-1*Q_101010011*R_102[0]+Q_101010111*R_103[0]+-1*Q_101010211*R_104[0]+Q_101110011*R_112[0]+-1*Q_101110111*R_113[0]+Q_101110211*R_114[0]; double QR_000011011002=Q_000011011*R_002[0]+-1*Q_000011111*R_003[0]+Q_000011211*R_004[0]+-1*Q_000111011*R_012[0]+Q_000111111*R_013[0]+-1*Q_000111211*R_014[0]+Q_000211011*R_022[0]+-1*Q_000211111*R_023[0]+Q_000211211*R_024[0]; double QR_000010012002=Q_000010012*R_002[0]+-1*Q_000010112*R_003[0]+Q_000010212*R_004[0]+-1*Q_000010312*R_005[0]+-1*Q_000110012*R_012[0]+Q_000110112*R_013[0]+-1*Q_000110212*R_014[0]+Q_000110312*R_015[0]; double QR_002000020002=Q_002000020*R_002[0]+-1*Q_002000120*R_003[0]+Q_002000220*R_004[0]+-1*Q_102000020*R_102[0]+Q_102000120*R_103[0]+-1*Q_102000220*R_104[0]+Q_202000020*R_202[0]+-1*Q_202000120*R_203[0]+Q_202000220*R_204[0]; double QR_001001020002=Q_001001020*R_002[0]+-1*Q_001001120*R_003[0]+Q_001001220*R_004[0]+-1*Q_001101020*R_012[0]+Q_001101120*R_013[0]+-1*Q_001101220*R_014[0]+-1*Q_101001020*R_102[0]+Q_101001120*R_103[0]+-1*Q_101001220*R_104[0]+Q_101101020*R_112[0]+-1*Q_101101120*R_113[0]+Q_101101220*R_114[0]; double QR_000002020002=Q_000002020*R_002[0]+-1*Q_000002120*R_003[0]+Q_000002220*R_004[0]+-1*Q_000102020*R_012[0]+Q_000102120*R_013[0]+-1*Q_000102220*R_014[0]+Q_000202020*R_022[0]+-1*Q_000202120*R_023[0]+Q_000202220*R_024[0]; double QR_001000021002=Q_001000021*R_002[0]+-1*Q_001000121*R_003[0]+Q_001000221*R_004[0]+-1*Q_001000321*R_005[0]+-1*Q_101000021*R_102[0]+Q_101000121*R_103[0]+-1*Q_101000221*R_104[0]+Q_101000321*R_105[0]; double QR_000001021002=Q_000001021*R_002[0]+-1*Q_000001121*R_003[0]+Q_000001221*R_004[0]+-1*Q_000001321*R_005[0]+-1*Q_000101021*R_012[0]+Q_000101121*R_013[0]+-1*Q_000101221*R_014[0]+Q_000101321*R_015[0]; double QR_000000022002=Q_000000022*R_002[0]+-1*Q_000000122*R_003[0]+Q_000000222*R_004[0]+-1*Q_000000322*R_005[0]+Q_000000422*R_006[0]; double QR_022000000011=Q_022000000*R_011[0]+-1*Q_122000000*R_111[0]+Q_222000000*R_211[0]+-1*Q_322000000*R_311[0]+Q_422000000*R_411[0]; double QR_021001000011=Q_021001000*R_011[0]+-1*Q_021101000*R_021[0]+-1*Q_121001000*R_111[0]+Q_121101000*R_121[0]+Q_221001000*R_211[0]+-1*Q_221101000*R_221[0]+-1*Q_321001000*R_311[0]+Q_321101000*R_321[0]; double QR_020002000011=Q_020002000*R_011[0]+-1*Q_020102000*R_021[0]+Q_020202000*R_031[0]+-1*Q_120002000*R_111[0]+Q_120102000*R_121[0]+-1*Q_120202000*R_131[0]+Q_220002000*R_211[0]+-1*Q_220102000*R_221[0]+Q_220202000*R_231[0]; double QR_021000001011=Q_021000001*R_011[0]+-1*Q_021000101*R_012[0]+-1*Q_121000001*R_111[0]+Q_121000101*R_112[0]+Q_221000001*R_211[0]+-1*Q_221000101*R_212[0]+-1*Q_321000001*R_311[0]+Q_321000101*R_312[0]; double QR_020001001011=Q_020001001*R_011[0]+-1*Q_020001101*R_012[0]+-1*Q_020101001*R_021[0]+Q_020101101*R_022[0]+-1*Q_120001001*R_111[0]+Q_120001101*R_112[0]+Q_120101001*R_121[0]+-1*Q_120101101*R_122[0]+Q_220001001*R_211[0]+-1*Q_220001101*R_212[0]+-1*Q_220101001*R_221[0]+Q_220101101*R_222[0]; double QR_020000002011=Q_020000002*R_011[0]+-1*Q_020000102*R_012[0]+Q_020000202*R_013[0]+-1*Q_120000002*R_111[0]+Q_120000102*R_112[0]+-1*Q_120000202*R_113[0]+Q_220000002*R_211[0]+-1*Q_220000102*R_212[0]+Q_220000202*R_213[0]; double QR_012010000011=Q_012010000*R_011[0]+-1*Q_012110000*R_021[0]+-1*Q_112010000*R_111[0]+Q_112110000*R_121[0]+Q_212010000*R_211[0]+-1*Q_212110000*R_221[0]+-1*Q_312010000*R_311[0]+Q_312110000*R_321[0]; double QR_011011000011=Q_011011000*R_011[0]+-1*Q_011111000*R_021[0]+Q_011211000*R_031[0]+-1*Q_111011000*R_111[0]+Q_111111000*R_121[0]+-1*Q_111211000*R_131[0]+Q_211011000*R_211[0]+-1*Q_211111000*R_221[0]+Q_211211000*R_231[0]; double QR_010012000011=Q_010012000*R_011[0]+-1*Q_010112000*R_021[0]+Q_010212000*R_031[0]+-1*Q_010312000*R_041[0]+-1*Q_110012000*R_111[0]+Q_110112000*R_121[0]+-1*Q_110212000*R_131[0]+Q_110312000*R_141[0]; double QR_011010001011=Q_011010001*R_011[0]+-1*Q_011010101*R_012[0]+-1*Q_011110001*R_021[0]+Q_011110101*R_022[0]+-1*Q_111010001*R_111[0]+Q_111010101*R_112[0]+Q_111110001*R_121[0]+-1*Q_111110101*R_122[0]+Q_211010001*R_211[0]+-1*Q_211010101*R_212[0]+-1*Q_211110001*R_221[0]+Q_211110101*R_222[0]; double QR_010011001011=Q_010011001*R_011[0]+-1*Q_010011101*R_012[0]+-1*Q_010111001*R_021[0]+Q_010111101*R_022[0]+Q_010211001*R_031[0]+-1*Q_010211101*R_032[0]+-1*Q_110011001*R_111[0]+Q_110011101*R_112[0]+Q_110111001*R_121[0]+-1*Q_110111101*R_122[0]+-1*Q_110211001*R_131[0]+Q_110211101*R_132[0]; double QR_010010002011=Q_010010002*R_011[0]+-1*Q_010010102*R_012[0]+Q_010010202*R_013[0]+-1*Q_010110002*R_021[0]+Q_010110102*R_022[0]+-1*Q_010110202*R_023[0]+-1*Q_110010002*R_111[0]+Q_110010102*R_112[0]+-1*Q_110010202*R_113[0]+Q_110110002*R_121[0]+-1*Q_110110102*R_122[0]+Q_110110202*R_123[0]; double QR_002020000011=Q_002020000*R_011[0]+-1*Q_002120000*R_021[0]+Q_002220000*R_031[0]+-1*Q_102020000*R_111[0]+Q_102120000*R_121[0]+-1*Q_102220000*R_131[0]+Q_202020000*R_211[0]+-1*Q_202120000*R_221[0]+Q_202220000*R_231[0]; double QR_001021000011=Q_001021000*R_011[0]+-1*Q_001121000*R_021[0]+Q_001221000*R_031[0]+-1*Q_001321000*R_041[0]+-1*Q_101021000*R_111[0]+Q_101121000*R_121[0]+-1*Q_101221000*R_131[0]+Q_101321000*R_141[0]; double QR_000022000011=Q_000022000*R_011[0]+-1*Q_000122000*R_021[0]+Q_000222000*R_031[0]+-1*Q_000322000*R_041[0]+Q_000422000*R_051[0]; double QR_001020001011=Q_001020001*R_011[0]+-1*Q_001020101*R_012[0]+-1*Q_001120001*R_021[0]+Q_001120101*R_022[0]+Q_001220001*R_031[0]+-1*Q_001220101*R_032[0]+-1*Q_101020001*R_111[0]+Q_101020101*R_112[0]+Q_101120001*R_121[0]+-1*Q_101120101*R_122[0]+-1*Q_101220001*R_131[0]+Q_101220101*R_132[0]; double QR_000021001011=Q_000021001*R_011[0]+-1*Q_000021101*R_012[0]+-1*Q_000121001*R_021[0]+Q_000121101*R_022[0]+Q_000221001*R_031[0]+-1*Q_000221101*R_032[0]+-1*Q_000321001*R_041[0]+Q_000321101*R_042[0]; double QR_000020002011=Q_000020002*R_011[0]+-1*Q_000020102*R_012[0]+Q_000020202*R_013[0]+-1*Q_000120002*R_021[0]+Q_000120102*R_022[0]+-1*Q_000120202*R_023[0]+Q_000220002*R_031[0]+-1*Q_000220102*R_032[0]+Q_000220202*R_033[0]; double QR_012000010011=Q_012000010*R_011[0]+-1*Q_012000110*R_012[0]+-1*Q_112000010*R_111[0]+Q_112000110*R_112[0]+Q_212000010*R_211[0]+-1*Q_212000110*R_212[0]+-1*Q_312000010*R_311[0]+Q_312000110*R_312[0]; double QR_011001010011=Q_011001010*R_011[0]+-1*Q_011001110*R_012[0]+-1*Q_011101010*R_021[0]+Q_011101110*R_022[0]+-1*Q_111001010*R_111[0]+Q_111001110*R_112[0]+Q_111101010*R_121[0]+-1*Q_111101110*R_122[0]+Q_211001010*R_211[0]+-1*Q_211001110*R_212[0]+-1*Q_211101010*R_221[0]+Q_211101110*R_222[0]; double QR_010002010011=Q_010002010*R_011[0]+-1*Q_010002110*R_012[0]+-1*Q_010102010*R_021[0]+Q_010102110*R_022[0]+Q_010202010*R_031[0]+-1*Q_010202110*R_032[0]+-1*Q_110002010*R_111[0]+Q_110002110*R_112[0]+Q_110102010*R_121[0]+-1*Q_110102110*R_122[0]+-1*Q_110202010*R_131[0]+Q_110202110*R_132[0]; double QR_011000011011=Q_011000011*R_011[0]+-1*Q_011000111*R_012[0]+Q_011000211*R_013[0]+-1*Q_111000011*R_111[0]+Q_111000111*R_112[0]+-1*Q_111000211*R_113[0]+Q_211000011*R_211[0]+-1*Q_211000111*R_212[0]+Q_211000211*R_213[0]; double QR_010001011011=Q_010001011*R_011[0]+-1*Q_010001111*R_012[0]+Q_010001211*R_013[0]+-1*Q_010101011*R_021[0]+Q_010101111*R_022[0]+-1*Q_010101211*R_023[0]+-1*Q_110001011*R_111[0]+Q_110001111*R_112[0]+-1*Q_110001211*R_113[0]+Q_110101011*R_121[0]+-1*Q_110101111*R_122[0]+Q_110101211*R_123[0]; double QR_010000012011=Q_010000012*R_011[0]+-1*Q_010000112*R_012[0]+Q_010000212*R_013[0]+-1*Q_010000312*R_014[0]+-1*Q_110000012*R_111[0]+Q_110000112*R_112[0]+-1*Q_110000212*R_113[0]+Q_110000312*R_114[0]; double QR_002010010011=Q_002010010*R_011[0]+-1*Q_002010110*R_012[0]+-1*Q_002110010*R_021[0]+Q_002110110*R_022[0]+-1*Q_102010010*R_111[0]+Q_102010110*R_112[0]+Q_102110010*R_121[0]+-1*Q_102110110*R_122[0]+Q_202010010*R_211[0]+-1*Q_202010110*R_212[0]+-1*Q_202110010*R_221[0]+Q_202110110*R_222[0]; double QR_001011010011=Q_001011010*R_011[0]+-1*Q_001011110*R_012[0]+-1*Q_001111010*R_021[0]+Q_001111110*R_022[0]+Q_001211010*R_031[0]+-1*Q_001211110*R_032[0]+-1*Q_101011010*R_111[0]+Q_101011110*R_112[0]+Q_101111010*R_121[0]+-1*Q_101111110*R_122[0]+-1*Q_101211010*R_131[0]+Q_101211110*R_132[0]; double QR_000012010011=Q_000012010*R_011[0]+-1*Q_000012110*R_012[0]+-1*Q_000112010*R_021[0]+Q_000112110*R_022[0]+Q_000212010*R_031[0]+-1*Q_000212110*R_032[0]+-1*Q_000312010*R_041[0]+Q_000312110*R_042[0]; double QR_001010011011=Q_001010011*R_011[0]+-1*Q_001010111*R_012[0]+Q_001010211*R_013[0]+-1*Q_001110011*R_021[0]+Q_001110111*R_022[0]+-1*Q_001110211*R_023[0]+-1*Q_101010011*R_111[0]+Q_101010111*R_112[0]+-1*Q_101010211*R_113[0]+Q_101110011*R_121[0]+-1*Q_101110111*R_122[0]+Q_101110211*R_123[0]; double QR_000011011011=Q_000011011*R_011[0]+-1*Q_000011111*R_012[0]+Q_000011211*R_013[0]+-1*Q_000111011*R_021[0]+Q_000111111*R_022[0]+-1*Q_000111211*R_023[0]+Q_000211011*R_031[0]+-1*Q_000211111*R_032[0]+Q_000211211*R_033[0]; double QR_000010012011=Q_000010012*R_011[0]+-1*Q_000010112*R_012[0]+Q_000010212*R_013[0]+-1*Q_000010312*R_014[0]+-1*Q_000110012*R_021[0]+Q_000110112*R_022[0]+-1*Q_000110212*R_023[0]+Q_000110312*R_024[0]; double QR_002000020011=Q_002000020*R_011[0]+-1*Q_002000120*R_012[0]+Q_002000220*R_013[0]+-1*Q_102000020*R_111[0]+Q_102000120*R_112[0]+-1*Q_102000220*R_113[0]+Q_202000020*R_211[0]+-1*Q_202000120*R_212[0]+Q_202000220*R_213[0]; double QR_001001020011=Q_001001020*R_011[0]+-1*Q_001001120*R_012[0]+Q_001001220*R_013[0]+-1*Q_001101020*R_021[0]+Q_001101120*R_022[0]+-1*Q_001101220*R_023[0]+-1*Q_101001020*R_111[0]+Q_101001120*R_112[0]+-1*Q_101001220*R_113[0]+Q_101101020*R_121[0]+-1*Q_101101120*R_122[0]+Q_101101220*R_123[0]; double QR_000002020011=Q_000002020*R_011[0]+-1*Q_000002120*R_012[0]+Q_000002220*R_013[0]+-1*Q_000102020*R_021[0]+Q_000102120*R_022[0]+-1*Q_000102220*R_023[0]+Q_000202020*R_031[0]+-1*Q_000202120*R_032[0]+Q_000202220*R_033[0]; double QR_001000021011=Q_001000021*R_011[0]+-1*Q_001000121*R_012[0]+Q_001000221*R_013[0]+-1*Q_001000321*R_014[0]+-1*Q_101000021*R_111[0]+Q_101000121*R_112[0]+-1*Q_101000221*R_113[0]+Q_101000321*R_114[0]; double QR_000001021011=Q_000001021*R_011[0]+-1*Q_000001121*R_012[0]+Q_000001221*R_013[0]+-1*Q_000001321*R_014[0]+-1*Q_000101021*R_021[0]+Q_000101121*R_022[0]+-1*Q_000101221*R_023[0]+Q_000101321*R_024[0]; double QR_000000022011=Q_000000022*R_011[0]+-1*Q_000000122*R_012[0]+Q_000000222*R_013[0]+-1*Q_000000322*R_014[0]+Q_000000422*R_015[0]; double QR_022000000020=Q_022000000*R_020[0]+-1*Q_122000000*R_120[0]+Q_222000000*R_220[0]+-1*Q_322000000*R_320[0]+Q_422000000*R_420[0]; double QR_021001000020=Q_021001000*R_020[0]+-1*Q_021101000*R_030[0]+-1*Q_121001000*R_120[0]+Q_121101000*R_130[0]+Q_221001000*R_220[0]+-1*Q_221101000*R_230[0]+-1*Q_321001000*R_320[0]+Q_321101000*R_330[0]; double QR_020002000020=Q_020002000*R_020[0]+-1*Q_020102000*R_030[0]+Q_020202000*R_040[0]+-1*Q_120002000*R_120[0]+Q_120102000*R_130[0]+-1*Q_120202000*R_140[0]+Q_220002000*R_220[0]+-1*Q_220102000*R_230[0]+Q_220202000*R_240[0]; double QR_021000001020=Q_021000001*R_020[0]+-1*Q_021000101*R_021[0]+-1*Q_121000001*R_120[0]+Q_121000101*R_121[0]+Q_221000001*R_220[0]+-1*Q_221000101*R_221[0]+-1*Q_321000001*R_320[0]+Q_321000101*R_321[0]; double QR_020001001020=Q_020001001*R_020[0]+-1*Q_020001101*R_021[0]+-1*Q_020101001*R_030[0]+Q_020101101*R_031[0]+-1*Q_120001001*R_120[0]+Q_120001101*R_121[0]+Q_120101001*R_130[0]+-1*Q_120101101*R_131[0]+Q_220001001*R_220[0]+-1*Q_220001101*R_221[0]+-1*Q_220101001*R_230[0]+Q_220101101*R_231[0]; double QR_020000002020=Q_020000002*R_020[0]+-1*Q_020000102*R_021[0]+Q_020000202*R_022[0]+-1*Q_120000002*R_120[0]+Q_120000102*R_121[0]+-1*Q_120000202*R_122[0]+Q_220000002*R_220[0]+-1*Q_220000102*R_221[0]+Q_220000202*R_222[0]; double QR_012010000020=Q_012010000*R_020[0]+-1*Q_012110000*R_030[0]+-1*Q_112010000*R_120[0]+Q_112110000*R_130[0]+Q_212010000*R_220[0]+-1*Q_212110000*R_230[0]+-1*Q_312010000*R_320[0]+Q_312110000*R_330[0]; double QR_011011000020=Q_011011000*R_020[0]+-1*Q_011111000*R_030[0]+Q_011211000*R_040[0]+-1*Q_111011000*R_120[0]+Q_111111000*R_130[0]+-1*Q_111211000*R_140[0]+Q_211011000*R_220[0]+-1*Q_211111000*R_230[0]+Q_211211000*R_240[0]; double QR_010012000020=Q_010012000*R_020[0]+-1*Q_010112000*R_030[0]+Q_010212000*R_040[0]+-1*Q_010312000*R_050[0]+-1*Q_110012000*R_120[0]+Q_110112000*R_130[0]+-1*Q_110212000*R_140[0]+Q_110312000*R_150[0]; double QR_011010001020=Q_011010001*R_020[0]+-1*Q_011010101*R_021[0]+-1*Q_011110001*R_030[0]+Q_011110101*R_031[0]+-1*Q_111010001*R_120[0]+Q_111010101*R_121[0]+Q_111110001*R_130[0]+-1*Q_111110101*R_131[0]+Q_211010001*R_220[0]+-1*Q_211010101*R_221[0]+-1*Q_211110001*R_230[0]+Q_211110101*R_231[0]; double QR_010011001020=Q_010011001*R_020[0]+-1*Q_010011101*R_021[0]+-1*Q_010111001*R_030[0]+Q_010111101*R_031[0]+Q_010211001*R_040[0]+-1*Q_010211101*R_041[0]+-1*Q_110011001*R_120[0]+Q_110011101*R_121[0]+Q_110111001*R_130[0]+-1*Q_110111101*R_131[0]+-1*Q_110211001*R_140[0]+Q_110211101*R_141[0]; double QR_010010002020=Q_010010002*R_020[0]+-1*Q_010010102*R_021[0]+Q_010010202*R_022[0]+-1*Q_010110002*R_030[0]+Q_010110102*R_031[0]+-1*Q_010110202*R_032[0]+-1*Q_110010002*R_120[0]+Q_110010102*R_121[0]+-1*Q_110010202*R_122[0]+Q_110110002*R_130[0]+-1*Q_110110102*R_131[0]+Q_110110202*R_132[0]; double QR_002020000020=Q_002020000*R_020[0]+-1*Q_002120000*R_030[0]+Q_002220000*R_040[0]+-1*Q_102020000*R_120[0]+Q_102120000*R_130[0]+-1*Q_102220000*R_140[0]+Q_202020000*R_220[0]+-1*Q_202120000*R_230[0]+Q_202220000*R_240[0]; double QR_001021000020=Q_001021000*R_020[0]+-1*Q_001121000*R_030[0]+Q_001221000*R_040[0]+-1*Q_001321000*R_050[0]+-1*Q_101021000*R_120[0]+Q_101121000*R_130[0]+-1*Q_101221000*R_140[0]+Q_101321000*R_150[0]; double QR_000022000020=Q_000022000*R_020[0]+-1*Q_000122000*R_030[0]+Q_000222000*R_040[0]+-1*Q_000322000*R_050[0]+Q_000422000*R_060[0]; double QR_001020001020=Q_001020001*R_020[0]+-1*Q_001020101*R_021[0]+-1*Q_001120001*R_030[0]+Q_001120101*R_031[0]+Q_001220001*R_040[0]+-1*Q_001220101*R_041[0]+-1*Q_101020001*R_120[0]+Q_101020101*R_121[0]+Q_101120001*R_130[0]+-1*Q_101120101*R_131[0]+-1*Q_101220001*R_140[0]+Q_101220101*R_141[0]; double QR_000021001020=Q_000021001*R_020[0]+-1*Q_000021101*R_021[0]+-1*Q_000121001*R_030[0]+Q_000121101*R_031[0]+Q_000221001*R_040[0]+-1*Q_000221101*R_041[0]+-1*Q_000321001*R_050[0]+Q_000321101*R_051[0]; double QR_000020002020=Q_000020002*R_020[0]+-1*Q_000020102*R_021[0]+Q_000020202*R_022[0]+-1*Q_000120002*R_030[0]+Q_000120102*R_031[0]+-1*Q_000120202*R_032[0]+Q_000220002*R_040[0]+-1*Q_000220102*R_041[0]+Q_000220202*R_042[0]; double QR_012000010020=Q_012000010*R_020[0]+-1*Q_012000110*R_021[0]+-1*Q_112000010*R_120[0]+Q_112000110*R_121[0]+Q_212000010*R_220[0]+-1*Q_212000110*R_221[0]+-1*Q_312000010*R_320[0]+Q_312000110*R_321[0]; double QR_011001010020=Q_011001010*R_020[0]+-1*Q_011001110*R_021[0]+-1*Q_011101010*R_030[0]+Q_011101110*R_031[0]+-1*Q_111001010*R_120[0]+Q_111001110*R_121[0]+Q_111101010*R_130[0]+-1*Q_111101110*R_131[0]+Q_211001010*R_220[0]+-1*Q_211001110*R_221[0]+-1*Q_211101010*R_230[0]+Q_211101110*R_231[0]; double QR_010002010020=Q_010002010*R_020[0]+-1*Q_010002110*R_021[0]+-1*Q_010102010*R_030[0]+Q_010102110*R_031[0]+Q_010202010*R_040[0]+-1*Q_010202110*R_041[0]+-1*Q_110002010*R_120[0]+Q_110002110*R_121[0]+Q_110102010*R_130[0]+-1*Q_110102110*R_131[0]+-1*Q_110202010*R_140[0]+Q_110202110*R_141[0]; double QR_011000011020=Q_011000011*R_020[0]+-1*Q_011000111*R_021[0]+Q_011000211*R_022[0]+-1*Q_111000011*R_120[0]+Q_111000111*R_121[0]+-1*Q_111000211*R_122[0]+Q_211000011*R_220[0]+-1*Q_211000111*R_221[0]+Q_211000211*R_222[0]; double QR_010001011020=Q_010001011*R_020[0]+-1*Q_010001111*R_021[0]+Q_010001211*R_022[0]+-1*Q_010101011*R_030[0]+Q_010101111*R_031[0]+-1*Q_010101211*R_032[0]+-1*Q_110001011*R_120[0]+Q_110001111*R_121[0]+-1*Q_110001211*R_122[0]+Q_110101011*R_130[0]+-1*Q_110101111*R_131[0]+Q_110101211*R_132[0]; double QR_010000012020=Q_010000012*R_020[0]+-1*Q_010000112*R_021[0]+Q_010000212*R_022[0]+-1*Q_010000312*R_023[0]+-1*Q_110000012*R_120[0]+Q_110000112*R_121[0]+-1*Q_110000212*R_122[0]+Q_110000312*R_123[0]; double QR_002010010020=Q_002010010*R_020[0]+-1*Q_002010110*R_021[0]+-1*Q_002110010*R_030[0]+Q_002110110*R_031[0]+-1*Q_102010010*R_120[0]+Q_102010110*R_121[0]+Q_102110010*R_130[0]+-1*Q_102110110*R_131[0]+Q_202010010*R_220[0]+-1*Q_202010110*R_221[0]+-1*Q_202110010*R_230[0]+Q_202110110*R_231[0]; double QR_001011010020=Q_001011010*R_020[0]+-1*Q_001011110*R_021[0]+-1*Q_001111010*R_030[0]+Q_001111110*R_031[0]+Q_001211010*R_040[0]+-1*Q_001211110*R_041[0]+-1*Q_101011010*R_120[0]+Q_101011110*R_121[0]+Q_101111010*R_130[0]+-1*Q_101111110*R_131[0]+-1*Q_101211010*R_140[0]+Q_101211110*R_141[0]; double QR_000012010020=Q_000012010*R_020[0]+-1*Q_000012110*R_021[0]+-1*Q_000112010*R_030[0]+Q_000112110*R_031[0]+Q_000212010*R_040[0]+-1*Q_000212110*R_041[0]+-1*Q_000312010*R_050[0]+Q_000312110*R_051[0]; double QR_001010011020=Q_001010011*R_020[0]+-1*Q_001010111*R_021[0]+Q_001010211*R_022[0]+-1*Q_001110011*R_030[0]+Q_001110111*R_031[0]+-1*Q_001110211*R_032[0]+-1*Q_101010011*R_120[0]+Q_101010111*R_121[0]+-1*Q_101010211*R_122[0]+Q_101110011*R_130[0]+-1*Q_101110111*R_131[0]+Q_101110211*R_132[0]; double QR_000011011020=Q_000011011*R_020[0]+-1*Q_000011111*R_021[0]+Q_000011211*R_022[0]+-1*Q_000111011*R_030[0]+Q_000111111*R_031[0]+-1*Q_000111211*R_032[0]+Q_000211011*R_040[0]+-1*Q_000211111*R_041[0]+Q_000211211*R_042[0]; double QR_000010012020=Q_000010012*R_020[0]+-1*Q_000010112*R_021[0]+Q_000010212*R_022[0]+-1*Q_000010312*R_023[0]+-1*Q_000110012*R_030[0]+Q_000110112*R_031[0]+-1*Q_000110212*R_032[0]+Q_000110312*R_033[0]; double QR_002000020020=Q_002000020*R_020[0]+-1*Q_002000120*R_021[0]+Q_002000220*R_022[0]+-1*Q_102000020*R_120[0]+Q_102000120*R_121[0]+-1*Q_102000220*R_122[0]+Q_202000020*R_220[0]+-1*Q_202000120*R_221[0]+Q_202000220*R_222[0]; double QR_001001020020=Q_001001020*R_020[0]+-1*Q_001001120*R_021[0]+Q_001001220*R_022[0]+-1*Q_001101020*R_030[0]+Q_001101120*R_031[0]+-1*Q_001101220*R_032[0]+-1*Q_101001020*R_120[0]+Q_101001120*R_121[0]+-1*Q_101001220*R_122[0]+Q_101101020*R_130[0]+-1*Q_101101120*R_131[0]+Q_101101220*R_132[0]; double QR_000002020020=Q_000002020*R_020[0]+-1*Q_000002120*R_021[0]+Q_000002220*R_022[0]+-1*Q_000102020*R_030[0]+Q_000102120*R_031[0]+-1*Q_000102220*R_032[0]+Q_000202020*R_040[0]+-1*Q_000202120*R_041[0]+Q_000202220*R_042[0]; double QR_001000021020=Q_001000021*R_020[0]+-1*Q_001000121*R_021[0]+Q_001000221*R_022[0]+-1*Q_001000321*R_023[0]+-1*Q_101000021*R_120[0]+Q_101000121*R_121[0]+-1*Q_101000221*R_122[0]+Q_101000321*R_123[0]; double QR_000001021020=Q_000001021*R_020[0]+-1*Q_000001121*R_021[0]+Q_000001221*R_022[0]+-1*Q_000001321*R_023[0]+-1*Q_000101021*R_030[0]+Q_000101121*R_031[0]+-1*Q_000101221*R_032[0]+Q_000101321*R_033[0]; double QR_000000022020=Q_000000022*R_020[0]+-1*Q_000000122*R_021[0]+Q_000000222*R_022[0]+-1*Q_000000322*R_023[0]+Q_000000422*R_024[0]; double QR_022000000101=Q_022000000*R_101[0]+-1*Q_122000000*R_201[0]+Q_222000000*R_301[0]+-1*Q_322000000*R_401[0]+Q_422000000*R_501[0]; double QR_021001000101=Q_021001000*R_101[0]+-1*Q_021101000*R_111[0]+-1*Q_121001000*R_201[0]+Q_121101000*R_211[0]+Q_221001000*R_301[0]+-1*Q_221101000*R_311[0]+-1*Q_321001000*R_401[0]+Q_321101000*R_411[0]; double QR_020002000101=Q_020002000*R_101[0]+-1*Q_020102000*R_111[0]+Q_020202000*R_121[0]+-1*Q_120002000*R_201[0]+Q_120102000*R_211[0]+-1*Q_120202000*R_221[0]+Q_220002000*R_301[0]+-1*Q_220102000*R_311[0]+Q_220202000*R_321[0]; double QR_021000001101=Q_021000001*R_101[0]+-1*Q_021000101*R_102[0]+-1*Q_121000001*R_201[0]+Q_121000101*R_202[0]+Q_221000001*R_301[0]+-1*Q_221000101*R_302[0]+-1*Q_321000001*R_401[0]+Q_321000101*R_402[0]; double QR_020001001101=Q_020001001*R_101[0]+-1*Q_020001101*R_102[0]+-1*Q_020101001*R_111[0]+Q_020101101*R_112[0]+-1*Q_120001001*R_201[0]+Q_120001101*R_202[0]+Q_120101001*R_211[0]+-1*Q_120101101*R_212[0]+Q_220001001*R_301[0]+-1*Q_220001101*R_302[0]+-1*Q_220101001*R_311[0]+Q_220101101*R_312[0]; double QR_020000002101=Q_020000002*R_101[0]+-1*Q_020000102*R_102[0]+Q_020000202*R_103[0]+-1*Q_120000002*R_201[0]+Q_120000102*R_202[0]+-1*Q_120000202*R_203[0]+Q_220000002*R_301[0]+-1*Q_220000102*R_302[0]+Q_220000202*R_303[0]; double QR_012010000101=Q_012010000*R_101[0]+-1*Q_012110000*R_111[0]+-1*Q_112010000*R_201[0]+Q_112110000*R_211[0]+Q_212010000*R_301[0]+-1*Q_212110000*R_311[0]+-1*Q_312010000*R_401[0]+Q_312110000*R_411[0]; double QR_011011000101=Q_011011000*R_101[0]+-1*Q_011111000*R_111[0]+Q_011211000*R_121[0]+-1*Q_111011000*R_201[0]+Q_111111000*R_211[0]+-1*Q_111211000*R_221[0]+Q_211011000*R_301[0]+-1*Q_211111000*R_311[0]+Q_211211000*R_321[0]; double QR_010012000101=Q_010012000*R_101[0]+-1*Q_010112000*R_111[0]+Q_010212000*R_121[0]+-1*Q_010312000*R_131[0]+-1*Q_110012000*R_201[0]+Q_110112000*R_211[0]+-1*Q_110212000*R_221[0]+Q_110312000*R_231[0]; double QR_011010001101=Q_011010001*R_101[0]+-1*Q_011010101*R_102[0]+-1*Q_011110001*R_111[0]+Q_011110101*R_112[0]+-1*Q_111010001*R_201[0]+Q_111010101*R_202[0]+Q_111110001*R_211[0]+-1*Q_111110101*R_212[0]+Q_211010001*R_301[0]+-1*Q_211010101*R_302[0]+-1*Q_211110001*R_311[0]+Q_211110101*R_312[0]; double QR_010011001101=Q_010011001*R_101[0]+-1*Q_010011101*R_102[0]+-1*Q_010111001*R_111[0]+Q_010111101*R_112[0]+Q_010211001*R_121[0]+-1*Q_010211101*R_122[0]+-1*Q_110011001*R_201[0]+Q_110011101*R_202[0]+Q_110111001*R_211[0]+-1*Q_110111101*R_212[0]+-1*Q_110211001*R_221[0]+Q_110211101*R_222[0]; double QR_010010002101=Q_010010002*R_101[0]+-1*Q_010010102*R_102[0]+Q_010010202*R_103[0]+-1*Q_010110002*R_111[0]+Q_010110102*R_112[0]+-1*Q_010110202*R_113[0]+-1*Q_110010002*R_201[0]+Q_110010102*R_202[0]+-1*Q_110010202*R_203[0]+Q_110110002*R_211[0]+-1*Q_110110102*R_212[0]+Q_110110202*R_213[0]; double QR_002020000101=Q_002020000*R_101[0]+-1*Q_002120000*R_111[0]+Q_002220000*R_121[0]+-1*Q_102020000*R_201[0]+Q_102120000*R_211[0]+-1*Q_102220000*R_221[0]+Q_202020000*R_301[0]+-1*Q_202120000*R_311[0]+Q_202220000*R_321[0]; double QR_001021000101=Q_001021000*R_101[0]+-1*Q_001121000*R_111[0]+Q_001221000*R_121[0]+-1*Q_001321000*R_131[0]+-1*Q_101021000*R_201[0]+Q_101121000*R_211[0]+-1*Q_101221000*R_221[0]+Q_101321000*R_231[0]; double QR_000022000101=Q_000022000*R_101[0]+-1*Q_000122000*R_111[0]+Q_000222000*R_121[0]+-1*Q_000322000*R_131[0]+Q_000422000*R_141[0]; double QR_001020001101=Q_001020001*R_101[0]+-1*Q_001020101*R_102[0]+-1*Q_001120001*R_111[0]+Q_001120101*R_112[0]+Q_001220001*R_121[0]+-1*Q_001220101*R_122[0]+-1*Q_101020001*R_201[0]+Q_101020101*R_202[0]+Q_101120001*R_211[0]+-1*Q_101120101*R_212[0]+-1*Q_101220001*R_221[0]+Q_101220101*R_222[0]; double QR_000021001101=Q_000021001*R_101[0]+-1*Q_000021101*R_102[0]+-1*Q_000121001*R_111[0]+Q_000121101*R_112[0]+Q_000221001*R_121[0]+-1*Q_000221101*R_122[0]+-1*Q_000321001*R_131[0]+Q_000321101*R_132[0]; double QR_000020002101=Q_000020002*R_101[0]+-1*Q_000020102*R_102[0]+Q_000020202*R_103[0]+-1*Q_000120002*R_111[0]+Q_000120102*R_112[0]+-1*Q_000120202*R_113[0]+Q_000220002*R_121[0]+-1*Q_000220102*R_122[0]+Q_000220202*R_123[0]; double QR_012000010101=Q_012000010*R_101[0]+-1*Q_012000110*R_102[0]+-1*Q_112000010*R_201[0]+Q_112000110*R_202[0]+Q_212000010*R_301[0]+-1*Q_212000110*R_302[0]+-1*Q_312000010*R_401[0]+Q_312000110*R_402[0]; double QR_011001010101=Q_011001010*R_101[0]+-1*Q_011001110*R_102[0]+-1*Q_011101010*R_111[0]+Q_011101110*R_112[0]+-1*Q_111001010*R_201[0]+Q_111001110*R_202[0]+Q_111101010*R_211[0]+-1*Q_111101110*R_212[0]+Q_211001010*R_301[0]+-1*Q_211001110*R_302[0]+-1*Q_211101010*R_311[0]+Q_211101110*R_312[0]; double QR_010002010101=Q_010002010*R_101[0]+-1*Q_010002110*R_102[0]+-1*Q_010102010*R_111[0]+Q_010102110*R_112[0]+Q_010202010*R_121[0]+-1*Q_010202110*R_122[0]+-1*Q_110002010*R_201[0]+Q_110002110*R_202[0]+Q_110102010*R_211[0]+-1*Q_110102110*R_212[0]+-1*Q_110202010*R_221[0]+Q_110202110*R_222[0]; double QR_011000011101=Q_011000011*R_101[0]+-1*Q_011000111*R_102[0]+Q_011000211*R_103[0]+-1*Q_111000011*R_201[0]+Q_111000111*R_202[0]+-1*Q_111000211*R_203[0]+Q_211000011*R_301[0]+-1*Q_211000111*R_302[0]+Q_211000211*R_303[0]; double QR_010001011101=Q_010001011*R_101[0]+-1*Q_010001111*R_102[0]+Q_010001211*R_103[0]+-1*Q_010101011*R_111[0]+Q_010101111*R_112[0]+-1*Q_010101211*R_113[0]+-1*Q_110001011*R_201[0]+Q_110001111*R_202[0]+-1*Q_110001211*R_203[0]+Q_110101011*R_211[0]+-1*Q_110101111*R_212[0]+Q_110101211*R_213[0]; double QR_010000012101=Q_010000012*R_101[0]+-1*Q_010000112*R_102[0]+Q_010000212*R_103[0]+-1*Q_010000312*R_104[0]+-1*Q_110000012*R_201[0]+Q_110000112*R_202[0]+-1*Q_110000212*R_203[0]+Q_110000312*R_204[0]; double QR_002010010101=Q_002010010*R_101[0]+-1*Q_002010110*R_102[0]+-1*Q_002110010*R_111[0]+Q_002110110*R_112[0]+-1*Q_102010010*R_201[0]+Q_102010110*R_202[0]+Q_102110010*R_211[0]+-1*Q_102110110*R_212[0]+Q_202010010*R_301[0]+-1*Q_202010110*R_302[0]+-1*Q_202110010*R_311[0]+Q_202110110*R_312[0]; double QR_001011010101=Q_001011010*R_101[0]+-1*Q_001011110*R_102[0]+-1*Q_001111010*R_111[0]+Q_001111110*R_112[0]+Q_001211010*R_121[0]+-1*Q_001211110*R_122[0]+-1*Q_101011010*R_201[0]+Q_101011110*R_202[0]+Q_101111010*R_211[0]+-1*Q_101111110*R_212[0]+-1*Q_101211010*R_221[0]+Q_101211110*R_222[0]; double QR_000012010101=Q_000012010*R_101[0]+-1*Q_000012110*R_102[0]+-1*Q_000112010*R_111[0]+Q_000112110*R_112[0]+Q_000212010*R_121[0]+-1*Q_000212110*R_122[0]+-1*Q_000312010*R_131[0]+Q_000312110*R_132[0]; double QR_001010011101=Q_001010011*R_101[0]+-1*Q_001010111*R_102[0]+Q_001010211*R_103[0]+-1*Q_001110011*R_111[0]+Q_001110111*R_112[0]+-1*Q_001110211*R_113[0]+-1*Q_101010011*R_201[0]+Q_101010111*R_202[0]+-1*Q_101010211*R_203[0]+Q_101110011*R_211[0]+-1*Q_101110111*R_212[0]+Q_101110211*R_213[0]; double QR_000011011101=Q_000011011*R_101[0]+-1*Q_000011111*R_102[0]+Q_000011211*R_103[0]+-1*Q_000111011*R_111[0]+Q_000111111*R_112[0]+-1*Q_000111211*R_113[0]+Q_000211011*R_121[0]+-1*Q_000211111*R_122[0]+Q_000211211*R_123[0]; double QR_000010012101=Q_000010012*R_101[0]+-1*Q_000010112*R_102[0]+Q_000010212*R_103[0]+-1*Q_000010312*R_104[0]+-1*Q_000110012*R_111[0]+Q_000110112*R_112[0]+-1*Q_000110212*R_113[0]+Q_000110312*R_114[0]; double QR_002000020101=Q_002000020*R_101[0]+-1*Q_002000120*R_102[0]+Q_002000220*R_103[0]+-1*Q_102000020*R_201[0]+Q_102000120*R_202[0]+-1*Q_102000220*R_203[0]+Q_202000020*R_301[0]+-1*Q_202000120*R_302[0]+Q_202000220*R_303[0]; double QR_001001020101=Q_001001020*R_101[0]+-1*Q_001001120*R_102[0]+Q_001001220*R_103[0]+-1*Q_001101020*R_111[0]+Q_001101120*R_112[0]+-1*Q_001101220*R_113[0]+-1*Q_101001020*R_201[0]+Q_101001120*R_202[0]+-1*Q_101001220*R_203[0]+Q_101101020*R_211[0]+-1*Q_101101120*R_212[0]+Q_101101220*R_213[0]; double QR_000002020101=Q_000002020*R_101[0]+-1*Q_000002120*R_102[0]+Q_000002220*R_103[0]+-1*Q_000102020*R_111[0]+Q_000102120*R_112[0]+-1*Q_000102220*R_113[0]+Q_000202020*R_121[0]+-1*Q_000202120*R_122[0]+Q_000202220*R_123[0]; double QR_001000021101=Q_001000021*R_101[0]+-1*Q_001000121*R_102[0]+Q_001000221*R_103[0]+-1*Q_001000321*R_104[0]+-1*Q_101000021*R_201[0]+Q_101000121*R_202[0]+-1*Q_101000221*R_203[0]+Q_101000321*R_204[0]; double QR_000001021101=Q_000001021*R_101[0]+-1*Q_000001121*R_102[0]+Q_000001221*R_103[0]+-1*Q_000001321*R_104[0]+-1*Q_000101021*R_111[0]+Q_000101121*R_112[0]+-1*Q_000101221*R_113[0]+Q_000101321*R_114[0]; double QR_000000022101=Q_000000022*R_101[0]+-1*Q_000000122*R_102[0]+Q_000000222*R_103[0]+-1*Q_000000322*R_104[0]+Q_000000422*R_105[0]; double QR_022000000110=Q_022000000*R_110[0]+-1*Q_122000000*R_210[0]+Q_222000000*R_310[0]+-1*Q_322000000*R_410[0]+Q_422000000*R_510[0]; double QR_021001000110=Q_021001000*R_110[0]+-1*Q_021101000*R_120[0]+-1*Q_121001000*R_210[0]+Q_121101000*R_220[0]+Q_221001000*R_310[0]+-1*Q_221101000*R_320[0]+-1*Q_321001000*R_410[0]+Q_321101000*R_420[0]; double QR_020002000110=Q_020002000*R_110[0]+-1*Q_020102000*R_120[0]+Q_020202000*R_130[0]+-1*Q_120002000*R_210[0]+Q_120102000*R_220[0]+-1*Q_120202000*R_230[0]+Q_220002000*R_310[0]+-1*Q_220102000*R_320[0]+Q_220202000*R_330[0]; double QR_021000001110=Q_021000001*R_110[0]+-1*Q_021000101*R_111[0]+-1*Q_121000001*R_210[0]+Q_121000101*R_211[0]+Q_221000001*R_310[0]+-1*Q_221000101*R_311[0]+-1*Q_321000001*R_410[0]+Q_321000101*R_411[0]; double QR_020001001110=Q_020001001*R_110[0]+-1*Q_020001101*R_111[0]+-1*Q_020101001*R_120[0]+Q_020101101*R_121[0]+-1*Q_120001001*R_210[0]+Q_120001101*R_211[0]+Q_120101001*R_220[0]+-1*Q_120101101*R_221[0]+Q_220001001*R_310[0]+-1*Q_220001101*R_311[0]+-1*Q_220101001*R_320[0]+Q_220101101*R_321[0]; double QR_020000002110=Q_020000002*R_110[0]+-1*Q_020000102*R_111[0]+Q_020000202*R_112[0]+-1*Q_120000002*R_210[0]+Q_120000102*R_211[0]+-1*Q_120000202*R_212[0]+Q_220000002*R_310[0]+-1*Q_220000102*R_311[0]+Q_220000202*R_312[0]; double QR_012010000110=Q_012010000*R_110[0]+-1*Q_012110000*R_120[0]+-1*Q_112010000*R_210[0]+Q_112110000*R_220[0]+Q_212010000*R_310[0]+-1*Q_212110000*R_320[0]+-1*Q_312010000*R_410[0]+Q_312110000*R_420[0]; double QR_011011000110=Q_011011000*R_110[0]+-1*Q_011111000*R_120[0]+Q_011211000*R_130[0]+-1*Q_111011000*R_210[0]+Q_111111000*R_220[0]+-1*Q_111211000*R_230[0]+Q_211011000*R_310[0]+-1*Q_211111000*R_320[0]+Q_211211000*R_330[0]; double QR_010012000110=Q_010012000*R_110[0]+-1*Q_010112000*R_120[0]+Q_010212000*R_130[0]+-1*Q_010312000*R_140[0]+-1*Q_110012000*R_210[0]+Q_110112000*R_220[0]+-1*Q_110212000*R_230[0]+Q_110312000*R_240[0]; double QR_011010001110=Q_011010001*R_110[0]+-1*Q_011010101*R_111[0]+-1*Q_011110001*R_120[0]+Q_011110101*R_121[0]+-1*Q_111010001*R_210[0]+Q_111010101*R_211[0]+Q_111110001*R_220[0]+-1*Q_111110101*R_221[0]+Q_211010001*R_310[0]+-1*Q_211010101*R_311[0]+-1*Q_211110001*R_320[0]+Q_211110101*R_321[0]; double QR_010011001110=Q_010011001*R_110[0]+-1*Q_010011101*R_111[0]+-1*Q_010111001*R_120[0]+Q_010111101*R_121[0]+Q_010211001*R_130[0]+-1*Q_010211101*R_131[0]+-1*Q_110011001*R_210[0]+Q_110011101*R_211[0]+Q_110111001*R_220[0]+-1*Q_110111101*R_221[0]+-1*Q_110211001*R_230[0]+Q_110211101*R_231[0]; double QR_010010002110=Q_010010002*R_110[0]+-1*Q_010010102*R_111[0]+Q_010010202*R_112[0]+-1*Q_010110002*R_120[0]+Q_010110102*R_121[0]+-1*Q_010110202*R_122[0]+-1*Q_110010002*R_210[0]+Q_110010102*R_211[0]+-1*Q_110010202*R_212[0]+Q_110110002*R_220[0]+-1*Q_110110102*R_221[0]+Q_110110202*R_222[0]; double QR_002020000110=Q_002020000*R_110[0]+-1*Q_002120000*R_120[0]+Q_002220000*R_130[0]+-1*Q_102020000*R_210[0]+Q_102120000*R_220[0]+-1*Q_102220000*R_230[0]+Q_202020000*R_310[0]+-1*Q_202120000*R_320[0]+Q_202220000*R_330[0]; double QR_001021000110=Q_001021000*R_110[0]+-1*Q_001121000*R_120[0]+Q_001221000*R_130[0]+-1*Q_001321000*R_140[0]+-1*Q_101021000*R_210[0]+Q_101121000*R_220[0]+-1*Q_101221000*R_230[0]+Q_101321000*R_240[0]; double QR_000022000110=Q_000022000*R_110[0]+-1*Q_000122000*R_120[0]+Q_000222000*R_130[0]+-1*Q_000322000*R_140[0]+Q_000422000*R_150[0]; double QR_001020001110=Q_001020001*R_110[0]+-1*Q_001020101*R_111[0]+-1*Q_001120001*R_120[0]+Q_001120101*R_121[0]+Q_001220001*R_130[0]+-1*Q_001220101*R_131[0]+-1*Q_101020001*R_210[0]+Q_101020101*R_211[0]+Q_101120001*R_220[0]+-1*Q_101120101*R_221[0]+-1*Q_101220001*R_230[0]+Q_101220101*R_231[0]; double QR_000021001110=Q_000021001*R_110[0]+-1*Q_000021101*R_111[0]+-1*Q_000121001*R_120[0]+Q_000121101*R_121[0]+Q_000221001*R_130[0]+-1*Q_000221101*R_131[0]+-1*Q_000321001*R_140[0]+Q_000321101*R_141[0]; double QR_000020002110=Q_000020002*R_110[0]+-1*Q_000020102*R_111[0]+Q_000020202*R_112[0]+-1*Q_000120002*R_120[0]+Q_000120102*R_121[0]+-1*Q_000120202*R_122[0]+Q_000220002*R_130[0]+-1*Q_000220102*R_131[0]+Q_000220202*R_132[0]; double QR_012000010110=Q_012000010*R_110[0]+-1*Q_012000110*R_111[0]+-1*Q_112000010*R_210[0]+Q_112000110*R_211[0]+Q_212000010*R_310[0]+-1*Q_212000110*R_311[0]+-1*Q_312000010*R_410[0]+Q_312000110*R_411[0]; double QR_011001010110=Q_011001010*R_110[0]+-1*Q_011001110*R_111[0]+-1*Q_011101010*R_120[0]+Q_011101110*R_121[0]+-1*Q_111001010*R_210[0]+Q_111001110*R_211[0]+Q_111101010*R_220[0]+-1*Q_111101110*R_221[0]+Q_211001010*R_310[0]+-1*Q_211001110*R_311[0]+-1*Q_211101010*R_320[0]+Q_211101110*R_321[0]; double QR_010002010110=Q_010002010*R_110[0]+-1*Q_010002110*R_111[0]+-1*Q_010102010*R_120[0]+Q_010102110*R_121[0]+Q_010202010*R_130[0]+-1*Q_010202110*R_131[0]+-1*Q_110002010*R_210[0]+Q_110002110*R_211[0]+Q_110102010*R_220[0]+-1*Q_110102110*R_221[0]+-1*Q_110202010*R_230[0]+Q_110202110*R_231[0]; double QR_011000011110=Q_011000011*R_110[0]+-1*Q_011000111*R_111[0]+Q_011000211*R_112[0]+-1*Q_111000011*R_210[0]+Q_111000111*R_211[0]+-1*Q_111000211*R_212[0]+Q_211000011*R_310[0]+-1*Q_211000111*R_311[0]+Q_211000211*R_312[0]; double QR_010001011110=Q_010001011*R_110[0]+-1*Q_010001111*R_111[0]+Q_010001211*R_112[0]+-1*Q_010101011*R_120[0]+Q_010101111*R_121[0]+-1*Q_010101211*R_122[0]+-1*Q_110001011*R_210[0]+Q_110001111*R_211[0]+-1*Q_110001211*R_212[0]+Q_110101011*R_220[0]+-1*Q_110101111*R_221[0]+Q_110101211*R_222[0]; double QR_010000012110=Q_010000012*R_110[0]+-1*Q_010000112*R_111[0]+Q_010000212*R_112[0]+-1*Q_010000312*R_113[0]+-1*Q_110000012*R_210[0]+Q_110000112*R_211[0]+-1*Q_110000212*R_212[0]+Q_110000312*R_213[0]; double QR_002010010110=Q_002010010*R_110[0]+-1*Q_002010110*R_111[0]+-1*Q_002110010*R_120[0]+Q_002110110*R_121[0]+-1*Q_102010010*R_210[0]+Q_102010110*R_211[0]+Q_102110010*R_220[0]+-1*Q_102110110*R_221[0]+Q_202010010*R_310[0]+-1*Q_202010110*R_311[0]+-1*Q_202110010*R_320[0]+Q_202110110*R_321[0]; double QR_001011010110=Q_001011010*R_110[0]+-1*Q_001011110*R_111[0]+-1*Q_001111010*R_120[0]+Q_001111110*R_121[0]+Q_001211010*R_130[0]+-1*Q_001211110*R_131[0]+-1*Q_101011010*R_210[0]+Q_101011110*R_211[0]+Q_101111010*R_220[0]+-1*Q_101111110*R_221[0]+-1*Q_101211010*R_230[0]+Q_101211110*R_231[0]; double QR_000012010110=Q_000012010*R_110[0]+-1*Q_000012110*R_111[0]+-1*Q_000112010*R_120[0]+Q_000112110*R_121[0]+Q_000212010*R_130[0]+-1*Q_000212110*R_131[0]+-1*Q_000312010*R_140[0]+Q_000312110*R_141[0]; double QR_001010011110=Q_001010011*R_110[0]+-1*Q_001010111*R_111[0]+Q_001010211*R_112[0]+-1*Q_001110011*R_120[0]+Q_001110111*R_121[0]+-1*Q_001110211*R_122[0]+-1*Q_101010011*R_210[0]+Q_101010111*R_211[0]+-1*Q_101010211*R_212[0]+Q_101110011*R_220[0]+-1*Q_101110111*R_221[0]+Q_101110211*R_222[0]; double QR_000011011110=Q_000011011*R_110[0]+-1*Q_000011111*R_111[0]+Q_000011211*R_112[0]+-1*Q_000111011*R_120[0]+Q_000111111*R_121[0]+-1*Q_000111211*R_122[0]+Q_000211011*R_130[0]+-1*Q_000211111*R_131[0]+Q_000211211*R_132[0]; double QR_000010012110=Q_000010012*R_110[0]+-1*Q_000010112*R_111[0]+Q_000010212*R_112[0]+-1*Q_000010312*R_113[0]+-1*Q_000110012*R_120[0]+Q_000110112*R_121[0]+-1*Q_000110212*R_122[0]+Q_000110312*R_123[0]; double QR_002000020110=Q_002000020*R_110[0]+-1*Q_002000120*R_111[0]+Q_002000220*R_112[0]+-1*Q_102000020*R_210[0]+Q_102000120*R_211[0]+-1*Q_102000220*R_212[0]+Q_202000020*R_310[0]+-1*Q_202000120*R_311[0]+Q_202000220*R_312[0]; double QR_001001020110=Q_001001020*R_110[0]+-1*Q_001001120*R_111[0]+Q_001001220*R_112[0]+-1*Q_001101020*R_120[0]+Q_001101120*R_121[0]+-1*Q_001101220*R_122[0]+-1*Q_101001020*R_210[0]+Q_101001120*R_211[0]+-1*Q_101001220*R_212[0]+Q_101101020*R_220[0]+-1*Q_101101120*R_221[0]+Q_101101220*R_222[0]; double QR_000002020110=Q_000002020*R_110[0]+-1*Q_000002120*R_111[0]+Q_000002220*R_112[0]+-1*Q_000102020*R_120[0]+Q_000102120*R_121[0]+-1*Q_000102220*R_122[0]+Q_000202020*R_130[0]+-1*Q_000202120*R_131[0]+Q_000202220*R_132[0]; double QR_001000021110=Q_001000021*R_110[0]+-1*Q_001000121*R_111[0]+Q_001000221*R_112[0]+-1*Q_001000321*R_113[0]+-1*Q_101000021*R_210[0]+Q_101000121*R_211[0]+-1*Q_101000221*R_212[0]+Q_101000321*R_213[0]; double QR_000001021110=Q_000001021*R_110[0]+-1*Q_000001121*R_111[0]+Q_000001221*R_112[0]+-1*Q_000001321*R_113[0]+-1*Q_000101021*R_120[0]+Q_000101121*R_121[0]+-1*Q_000101221*R_122[0]+Q_000101321*R_123[0]; double QR_000000022110=Q_000000022*R_110[0]+-1*Q_000000122*R_111[0]+Q_000000222*R_112[0]+-1*Q_000000322*R_113[0]+Q_000000422*R_114[0]; double QR_022000000200=Q_022000000*R_200[0]+-1*Q_122000000*R_300[0]+Q_222000000*R_400[0]+-1*Q_322000000*R_500[0]+Q_422000000*R_600[0]; double QR_021001000200=Q_021001000*R_200[0]+-1*Q_021101000*R_210[0]+-1*Q_121001000*R_300[0]+Q_121101000*R_310[0]+Q_221001000*R_400[0]+-1*Q_221101000*R_410[0]+-1*Q_321001000*R_500[0]+Q_321101000*R_510[0]; double QR_020002000200=Q_020002000*R_200[0]+-1*Q_020102000*R_210[0]+Q_020202000*R_220[0]+-1*Q_120002000*R_300[0]+Q_120102000*R_310[0]+-1*Q_120202000*R_320[0]+Q_220002000*R_400[0]+-1*Q_220102000*R_410[0]+Q_220202000*R_420[0]; double QR_021000001200=Q_021000001*R_200[0]+-1*Q_021000101*R_201[0]+-1*Q_121000001*R_300[0]+Q_121000101*R_301[0]+Q_221000001*R_400[0]+-1*Q_221000101*R_401[0]+-1*Q_321000001*R_500[0]+Q_321000101*R_501[0]; double QR_020001001200=Q_020001001*R_200[0]+-1*Q_020001101*R_201[0]+-1*Q_020101001*R_210[0]+Q_020101101*R_211[0]+-1*Q_120001001*R_300[0]+Q_120001101*R_301[0]+Q_120101001*R_310[0]+-1*Q_120101101*R_311[0]+Q_220001001*R_400[0]+-1*Q_220001101*R_401[0]+-1*Q_220101001*R_410[0]+Q_220101101*R_411[0]; double QR_020000002200=Q_020000002*R_200[0]+-1*Q_020000102*R_201[0]+Q_020000202*R_202[0]+-1*Q_120000002*R_300[0]+Q_120000102*R_301[0]+-1*Q_120000202*R_302[0]+Q_220000002*R_400[0]+-1*Q_220000102*R_401[0]+Q_220000202*R_402[0]; double QR_012010000200=Q_012010000*R_200[0]+-1*Q_012110000*R_210[0]+-1*Q_112010000*R_300[0]+Q_112110000*R_310[0]+Q_212010000*R_400[0]+-1*Q_212110000*R_410[0]+-1*Q_312010000*R_500[0]+Q_312110000*R_510[0]; double QR_011011000200=Q_011011000*R_200[0]+-1*Q_011111000*R_210[0]+Q_011211000*R_220[0]+-1*Q_111011000*R_300[0]+Q_111111000*R_310[0]+-1*Q_111211000*R_320[0]+Q_211011000*R_400[0]+-1*Q_211111000*R_410[0]+Q_211211000*R_420[0]; double QR_010012000200=Q_010012000*R_200[0]+-1*Q_010112000*R_210[0]+Q_010212000*R_220[0]+-1*Q_010312000*R_230[0]+-1*Q_110012000*R_300[0]+Q_110112000*R_310[0]+-1*Q_110212000*R_320[0]+Q_110312000*R_330[0]; double QR_011010001200=Q_011010001*R_200[0]+-1*Q_011010101*R_201[0]+-1*Q_011110001*R_210[0]+Q_011110101*R_211[0]+-1*Q_111010001*R_300[0]+Q_111010101*R_301[0]+Q_111110001*R_310[0]+-1*Q_111110101*R_311[0]+Q_211010001*R_400[0]+-1*Q_211010101*R_401[0]+-1*Q_211110001*R_410[0]+Q_211110101*R_411[0]; double QR_010011001200=Q_010011001*R_200[0]+-1*Q_010011101*R_201[0]+-1*Q_010111001*R_210[0]+Q_010111101*R_211[0]+Q_010211001*R_220[0]+-1*Q_010211101*R_221[0]+-1*Q_110011001*R_300[0]+Q_110011101*R_301[0]+Q_110111001*R_310[0]+-1*Q_110111101*R_311[0]+-1*Q_110211001*R_320[0]+Q_110211101*R_321[0]; double QR_010010002200=Q_010010002*R_200[0]+-1*Q_010010102*R_201[0]+Q_010010202*R_202[0]+-1*Q_010110002*R_210[0]+Q_010110102*R_211[0]+-1*Q_010110202*R_212[0]+-1*Q_110010002*R_300[0]+Q_110010102*R_301[0]+-1*Q_110010202*R_302[0]+Q_110110002*R_310[0]+-1*Q_110110102*R_311[0]+Q_110110202*R_312[0]; double QR_002020000200=Q_002020000*R_200[0]+-1*Q_002120000*R_210[0]+Q_002220000*R_220[0]+-1*Q_102020000*R_300[0]+Q_102120000*R_310[0]+-1*Q_102220000*R_320[0]+Q_202020000*R_400[0]+-1*Q_202120000*R_410[0]+Q_202220000*R_420[0]; double QR_001021000200=Q_001021000*R_200[0]+-1*Q_001121000*R_210[0]+Q_001221000*R_220[0]+-1*Q_001321000*R_230[0]+-1*Q_101021000*R_300[0]+Q_101121000*R_310[0]+-1*Q_101221000*R_320[0]+Q_101321000*R_330[0]; double QR_000022000200=Q_000022000*R_200[0]+-1*Q_000122000*R_210[0]+Q_000222000*R_220[0]+-1*Q_000322000*R_230[0]+Q_000422000*R_240[0]; double QR_001020001200=Q_001020001*R_200[0]+-1*Q_001020101*R_201[0]+-1*Q_001120001*R_210[0]+Q_001120101*R_211[0]+Q_001220001*R_220[0]+-1*Q_001220101*R_221[0]+-1*Q_101020001*R_300[0]+Q_101020101*R_301[0]+Q_101120001*R_310[0]+-1*Q_101120101*R_311[0]+-1*Q_101220001*R_320[0]+Q_101220101*R_321[0]; double QR_000021001200=Q_000021001*R_200[0]+-1*Q_000021101*R_201[0]+-1*Q_000121001*R_210[0]+Q_000121101*R_211[0]+Q_000221001*R_220[0]+-1*Q_000221101*R_221[0]+-1*Q_000321001*R_230[0]+Q_000321101*R_231[0]; double QR_000020002200=Q_000020002*R_200[0]+-1*Q_000020102*R_201[0]+Q_000020202*R_202[0]+-1*Q_000120002*R_210[0]+Q_000120102*R_211[0]+-1*Q_000120202*R_212[0]+Q_000220002*R_220[0]+-1*Q_000220102*R_221[0]+Q_000220202*R_222[0]; double QR_012000010200=Q_012000010*R_200[0]+-1*Q_012000110*R_201[0]+-1*Q_112000010*R_300[0]+Q_112000110*R_301[0]+Q_212000010*R_400[0]+-1*Q_212000110*R_401[0]+-1*Q_312000010*R_500[0]+Q_312000110*R_501[0]; double QR_011001010200=Q_011001010*R_200[0]+-1*Q_011001110*R_201[0]+-1*Q_011101010*R_210[0]+Q_011101110*R_211[0]+-1*Q_111001010*R_300[0]+Q_111001110*R_301[0]+Q_111101010*R_310[0]+-1*Q_111101110*R_311[0]+Q_211001010*R_400[0]+-1*Q_211001110*R_401[0]+-1*Q_211101010*R_410[0]+Q_211101110*R_411[0]; double QR_010002010200=Q_010002010*R_200[0]+-1*Q_010002110*R_201[0]+-1*Q_010102010*R_210[0]+Q_010102110*R_211[0]+Q_010202010*R_220[0]+-1*Q_010202110*R_221[0]+-1*Q_110002010*R_300[0]+Q_110002110*R_301[0]+Q_110102010*R_310[0]+-1*Q_110102110*R_311[0]+-1*Q_110202010*R_320[0]+Q_110202110*R_321[0]; double QR_011000011200=Q_011000011*R_200[0]+-1*Q_011000111*R_201[0]+Q_011000211*R_202[0]+-1*Q_111000011*R_300[0]+Q_111000111*R_301[0]+-1*Q_111000211*R_302[0]+Q_211000011*R_400[0]+-1*Q_211000111*R_401[0]+Q_211000211*R_402[0]; double QR_010001011200=Q_010001011*R_200[0]+-1*Q_010001111*R_201[0]+Q_010001211*R_202[0]+-1*Q_010101011*R_210[0]+Q_010101111*R_211[0]+-1*Q_010101211*R_212[0]+-1*Q_110001011*R_300[0]+Q_110001111*R_301[0]+-1*Q_110001211*R_302[0]+Q_110101011*R_310[0]+-1*Q_110101111*R_311[0]+Q_110101211*R_312[0]; double QR_010000012200=Q_010000012*R_200[0]+-1*Q_010000112*R_201[0]+Q_010000212*R_202[0]+-1*Q_010000312*R_203[0]+-1*Q_110000012*R_300[0]+Q_110000112*R_301[0]+-1*Q_110000212*R_302[0]+Q_110000312*R_303[0]; double QR_002010010200=Q_002010010*R_200[0]+-1*Q_002010110*R_201[0]+-1*Q_002110010*R_210[0]+Q_002110110*R_211[0]+-1*Q_102010010*R_300[0]+Q_102010110*R_301[0]+Q_102110010*R_310[0]+-1*Q_102110110*R_311[0]+Q_202010010*R_400[0]+-1*Q_202010110*R_401[0]+-1*Q_202110010*R_410[0]+Q_202110110*R_411[0]; double QR_001011010200=Q_001011010*R_200[0]+-1*Q_001011110*R_201[0]+-1*Q_001111010*R_210[0]+Q_001111110*R_211[0]+Q_001211010*R_220[0]+-1*Q_001211110*R_221[0]+-1*Q_101011010*R_300[0]+Q_101011110*R_301[0]+Q_101111010*R_310[0]+-1*Q_101111110*R_311[0]+-1*Q_101211010*R_320[0]+Q_101211110*R_321[0]; double QR_000012010200=Q_000012010*R_200[0]+-1*Q_000012110*R_201[0]+-1*Q_000112010*R_210[0]+Q_000112110*R_211[0]+Q_000212010*R_220[0]+-1*Q_000212110*R_221[0]+-1*Q_000312010*R_230[0]+Q_000312110*R_231[0]; double QR_001010011200=Q_001010011*R_200[0]+-1*Q_001010111*R_201[0]+Q_001010211*R_202[0]+-1*Q_001110011*R_210[0]+Q_001110111*R_211[0]+-1*Q_001110211*R_212[0]+-1*Q_101010011*R_300[0]+Q_101010111*R_301[0]+-1*Q_101010211*R_302[0]+Q_101110011*R_310[0]+-1*Q_101110111*R_311[0]+Q_101110211*R_312[0]; double QR_000011011200=Q_000011011*R_200[0]+-1*Q_000011111*R_201[0]+Q_000011211*R_202[0]+-1*Q_000111011*R_210[0]+Q_000111111*R_211[0]+-1*Q_000111211*R_212[0]+Q_000211011*R_220[0]+-1*Q_000211111*R_221[0]+Q_000211211*R_222[0]; double QR_000010012200=Q_000010012*R_200[0]+-1*Q_000010112*R_201[0]+Q_000010212*R_202[0]+-1*Q_000010312*R_203[0]+-1*Q_000110012*R_210[0]+Q_000110112*R_211[0]+-1*Q_000110212*R_212[0]+Q_000110312*R_213[0]; double QR_002000020200=Q_002000020*R_200[0]+-1*Q_002000120*R_201[0]+Q_002000220*R_202[0]+-1*Q_102000020*R_300[0]+Q_102000120*R_301[0]+-1*Q_102000220*R_302[0]+Q_202000020*R_400[0]+-1*Q_202000120*R_401[0]+Q_202000220*R_402[0]; double QR_001001020200=Q_001001020*R_200[0]+-1*Q_001001120*R_201[0]+Q_001001220*R_202[0]+-1*Q_001101020*R_210[0]+Q_001101120*R_211[0]+-1*Q_001101220*R_212[0]+-1*Q_101001020*R_300[0]+Q_101001120*R_301[0]+-1*Q_101001220*R_302[0]+Q_101101020*R_310[0]+-1*Q_101101120*R_311[0]+Q_101101220*R_312[0]; double QR_000002020200=Q_000002020*R_200[0]+-1*Q_000002120*R_201[0]+Q_000002220*R_202[0]+-1*Q_000102020*R_210[0]+Q_000102120*R_211[0]+-1*Q_000102220*R_212[0]+Q_000202020*R_220[0]+-1*Q_000202120*R_221[0]+Q_000202220*R_222[0]; double QR_001000021200=Q_001000021*R_200[0]+-1*Q_001000121*R_201[0]+Q_001000221*R_202[0]+-1*Q_001000321*R_203[0]+-1*Q_101000021*R_300[0]+Q_101000121*R_301[0]+-1*Q_101000221*R_302[0]+Q_101000321*R_303[0]; double QR_000001021200=Q_000001021*R_200[0]+-1*Q_000001121*R_201[0]+Q_000001221*R_202[0]+-1*Q_000001321*R_203[0]+-1*Q_000101021*R_210[0]+Q_000101121*R_211[0]+-1*Q_000101221*R_212[0]+Q_000101321*R_213[0]; double QR_000000022200=Q_000000022*R_200[0]+-1*Q_000000122*R_201[0]+Q_000000222*R_202[0]+-1*Q_000000322*R_203[0]+Q_000000422*R_204[0]; double QR_022000000003=Q_022000000*R_003[0]+-1*Q_122000000*R_103[0]+Q_222000000*R_203[0]+-1*Q_322000000*R_303[0]+Q_422000000*R_403[0]; double QR_021001000003=Q_021001000*R_003[0]+-1*Q_021101000*R_013[0]+-1*Q_121001000*R_103[0]+Q_121101000*R_113[0]+Q_221001000*R_203[0]+-1*Q_221101000*R_213[0]+-1*Q_321001000*R_303[0]+Q_321101000*R_313[0]; double QR_020002000003=Q_020002000*R_003[0]+-1*Q_020102000*R_013[0]+Q_020202000*R_023[0]+-1*Q_120002000*R_103[0]+Q_120102000*R_113[0]+-1*Q_120202000*R_123[0]+Q_220002000*R_203[0]+-1*Q_220102000*R_213[0]+Q_220202000*R_223[0]; double QR_021000001003=Q_021000001*R_003[0]+-1*Q_021000101*R_004[0]+-1*Q_121000001*R_103[0]+Q_121000101*R_104[0]+Q_221000001*R_203[0]+-1*Q_221000101*R_204[0]+-1*Q_321000001*R_303[0]+Q_321000101*R_304[0]; double QR_020001001003=Q_020001001*R_003[0]+-1*Q_020001101*R_004[0]+-1*Q_020101001*R_013[0]+Q_020101101*R_014[0]+-1*Q_120001001*R_103[0]+Q_120001101*R_104[0]+Q_120101001*R_113[0]+-1*Q_120101101*R_114[0]+Q_220001001*R_203[0]+-1*Q_220001101*R_204[0]+-1*Q_220101001*R_213[0]+Q_220101101*R_214[0]; double QR_020000002003=Q_020000002*R_003[0]+-1*Q_020000102*R_004[0]+Q_020000202*R_005[0]+-1*Q_120000002*R_103[0]+Q_120000102*R_104[0]+-1*Q_120000202*R_105[0]+Q_220000002*R_203[0]+-1*Q_220000102*R_204[0]+Q_220000202*R_205[0]; double QR_012010000003=Q_012010000*R_003[0]+-1*Q_012110000*R_013[0]+-1*Q_112010000*R_103[0]+Q_112110000*R_113[0]+Q_212010000*R_203[0]+-1*Q_212110000*R_213[0]+-1*Q_312010000*R_303[0]+Q_312110000*R_313[0]; double QR_011011000003=Q_011011000*R_003[0]+-1*Q_011111000*R_013[0]+Q_011211000*R_023[0]+-1*Q_111011000*R_103[0]+Q_111111000*R_113[0]+-1*Q_111211000*R_123[0]+Q_211011000*R_203[0]+-1*Q_211111000*R_213[0]+Q_211211000*R_223[0]; double QR_010012000003=Q_010012000*R_003[0]+-1*Q_010112000*R_013[0]+Q_010212000*R_023[0]+-1*Q_010312000*R_033[0]+-1*Q_110012000*R_103[0]+Q_110112000*R_113[0]+-1*Q_110212000*R_123[0]+Q_110312000*R_133[0]; double QR_011010001003=Q_011010001*R_003[0]+-1*Q_011010101*R_004[0]+-1*Q_011110001*R_013[0]+Q_011110101*R_014[0]+-1*Q_111010001*R_103[0]+Q_111010101*R_104[0]+Q_111110001*R_113[0]+-1*Q_111110101*R_114[0]+Q_211010001*R_203[0]+-1*Q_211010101*R_204[0]+-1*Q_211110001*R_213[0]+Q_211110101*R_214[0]; double QR_010011001003=Q_010011001*R_003[0]+-1*Q_010011101*R_004[0]+-1*Q_010111001*R_013[0]+Q_010111101*R_014[0]+Q_010211001*R_023[0]+-1*Q_010211101*R_024[0]+-1*Q_110011001*R_103[0]+Q_110011101*R_104[0]+Q_110111001*R_113[0]+-1*Q_110111101*R_114[0]+-1*Q_110211001*R_123[0]+Q_110211101*R_124[0]; double QR_010010002003=Q_010010002*R_003[0]+-1*Q_010010102*R_004[0]+Q_010010202*R_005[0]+-1*Q_010110002*R_013[0]+Q_010110102*R_014[0]+-1*Q_010110202*R_015[0]+-1*Q_110010002*R_103[0]+Q_110010102*R_104[0]+-1*Q_110010202*R_105[0]+Q_110110002*R_113[0]+-1*Q_110110102*R_114[0]+Q_110110202*R_115[0]; double QR_002020000003=Q_002020000*R_003[0]+-1*Q_002120000*R_013[0]+Q_002220000*R_023[0]+-1*Q_102020000*R_103[0]+Q_102120000*R_113[0]+-1*Q_102220000*R_123[0]+Q_202020000*R_203[0]+-1*Q_202120000*R_213[0]+Q_202220000*R_223[0]; double QR_001021000003=Q_001021000*R_003[0]+-1*Q_001121000*R_013[0]+Q_001221000*R_023[0]+-1*Q_001321000*R_033[0]+-1*Q_101021000*R_103[0]+Q_101121000*R_113[0]+-1*Q_101221000*R_123[0]+Q_101321000*R_133[0]; double QR_000022000003=Q_000022000*R_003[0]+-1*Q_000122000*R_013[0]+Q_000222000*R_023[0]+-1*Q_000322000*R_033[0]+Q_000422000*R_043[0]; double QR_001020001003=Q_001020001*R_003[0]+-1*Q_001020101*R_004[0]+-1*Q_001120001*R_013[0]+Q_001120101*R_014[0]+Q_001220001*R_023[0]+-1*Q_001220101*R_024[0]+-1*Q_101020001*R_103[0]+Q_101020101*R_104[0]+Q_101120001*R_113[0]+-1*Q_101120101*R_114[0]+-1*Q_101220001*R_123[0]+Q_101220101*R_124[0]; double QR_000021001003=Q_000021001*R_003[0]+-1*Q_000021101*R_004[0]+-1*Q_000121001*R_013[0]+Q_000121101*R_014[0]+Q_000221001*R_023[0]+-1*Q_000221101*R_024[0]+-1*Q_000321001*R_033[0]+Q_000321101*R_034[0]; double QR_000020002003=Q_000020002*R_003[0]+-1*Q_000020102*R_004[0]+Q_000020202*R_005[0]+-1*Q_000120002*R_013[0]+Q_000120102*R_014[0]+-1*Q_000120202*R_015[0]+Q_000220002*R_023[0]+-1*Q_000220102*R_024[0]+Q_000220202*R_025[0]; double QR_012000010003=Q_012000010*R_003[0]+-1*Q_012000110*R_004[0]+-1*Q_112000010*R_103[0]+Q_112000110*R_104[0]+Q_212000010*R_203[0]+-1*Q_212000110*R_204[0]+-1*Q_312000010*R_303[0]+Q_312000110*R_304[0]; double QR_011001010003=Q_011001010*R_003[0]+-1*Q_011001110*R_004[0]+-1*Q_011101010*R_013[0]+Q_011101110*R_014[0]+-1*Q_111001010*R_103[0]+Q_111001110*R_104[0]+Q_111101010*R_113[0]+-1*Q_111101110*R_114[0]+Q_211001010*R_203[0]+-1*Q_211001110*R_204[0]+-1*Q_211101010*R_213[0]+Q_211101110*R_214[0]; double QR_010002010003=Q_010002010*R_003[0]+-1*Q_010002110*R_004[0]+-1*Q_010102010*R_013[0]+Q_010102110*R_014[0]+Q_010202010*R_023[0]+-1*Q_010202110*R_024[0]+-1*Q_110002010*R_103[0]+Q_110002110*R_104[0]+Q_110102010*R_113[0]+-1*Q_110102110*R_114[0]+-1*Q_110202010*R_123[0]+Q_110202110*R_124[0]; double QR_011000011003=Q_011000011*R_003[0]+-1*Q_011000111*R_004[0]+Q_011000211*R_005[0]+-1*Q_111000011*R_103[0]+Q_111000111*R_104[0]+-1*Q_111000211*R_105[0]+Q_211000011*R_203[0]+-1*Q_211000111*R_204[0]+Q_211000211*R_205[0]; double QR_010001011003=Q_010001011*R_003[0]+-1*Q_010001111*R_004[0]+Q_010001211*R_005[0]+-1*Q_010101011*R_013[0]+Q_010101111*R_014[0]+-1*Q_010101211*R_015[0]+-1*Q_110001011*R_103[0]+Q_110001111*R_104[0]+-1*Q_110001211*R_105[0]+Q_110101011*R_113[0]+-1*Q_110101111*R_114[0]+Q_110101211*R_115[0]; double QR_010000012003=Q_010000012*R_003[0]+-1*Q_010000112*R_004[0]+Q_010000212*R_005[0]+-1*Q_010000312*R_006[0]+-1*Q_110000012*R_103[0]+Q_110000112*R_104[0]+-1*Q_110000212*R_105[0]+Q_110000312*R_106[0]; double QR_002010010003=Q_002010010*R_003[0]+-1*Q_002010110*R_004[0]+-1*Q_002110010*R_013[0]+Q_002110110*R_014[0]+-1*Q_102010010*R_103[0]+Q_102010110*R_104[0]+Q_102110010*R_113[0]+-1*Q_102110110*R_114[0]+Q_202010010*R_203[0]+-1*Q_202010110*R_204[0]+-1*Q_202110010*R_213[0]+Q_202110110*R_214[0]; double QR_001011010003=Q_001011010*R_003[0]+-1*Q_001011110*R_004[0]+-1*Q_001111010*R_013[0]+Q_001111110*R_014[0]+Q_001211010*R_023[0]+-1*Q_001211110*R_024[0]+-1*Q_101011010*R_103[0]+Q_101011110*R_104[0]+Q_101111010*R_113[0]+-1*Q_101111110*R_114[0]+-1*Q_101211010*R_123[0]+Q_101211110*R_124[0]; double QR_000012010003=Q_000012010*R_003[0]+-1*Q_000012110*R_004[0]+-1*Q_000112010*R_013[0]+Q_000112110*R_014[0]+Q_000212010*R_023[0]+-1*Q_000212110*R_024[0]+-1*Q_000312010*R_033[0]+Q_000312110*R_034[0]; double QR_001010011003=Q_001010011*R_003[0]+-1*Q_001010111*R_004[0]+Q_001010211*R_005[0]+-1*Q_001110011*R_013[0]+Q_001110111*R_014[0]+-1*Q_001110211*R_015[0]+-1*Q_101010011*R_103[0]+Q_101010111*R_104[0]+-1*Q_101010211*R_105[0]+Q_101110011*R_113[0]+-1*Q_101110111*R_114[0]+Q_101110211*R_115[0]; double QR_000011011003=Q_000011011*R_003[0]+-1*Q_000011111*R_004[0]+Q_000011211*R_005[0]+-1*Q_000111011*R_013[0]+Q_000111111*R_014[0]+-1*Q_000111211*R_015[0]+Q_000211011*R_023[0]+-1*Q_000211111*R_024[0]+Q_000211211*R_025[0]; double QR_000010012003=Q_000010012*R_003[0]+-1*Q_000010112*R_004[0]+Q_000010212*R_005[0]+-1*Q_000010312*R_006[0]+-1*Q_000110012*R_013[0]+Q_000110112*R_014[0]+-1*Q_000110212*R_015[0]+Q_000110312*R_016[0]; double QR_002000020003=Q_002000020*R_003[0]+-1*Q_002000120*R_004[0]+Q_002000220*R_005[0]+-1*Q_102000020*R_103[0]+Q_102000120*R_104[0]+-1*Q_102000220*R_105[0]+Q_202000020*R_203[0]+-1*Q_202000120*R_204[0]+Q_202000220*R_205[0]; double QR_001001020003=Q_001001020*R_003[0]+-1*Q_001001120*R_004[0]+Q_001001220*R_005[0]+-1*Q_001101020*R_013[0]+Q_001101120*R_014[0]+-1*Q_001101220*R_015[0]+-1*Q_101001020*R_103[0]+Q_101001120*R_104[0]+-1*Q_101001220*R_105[0]+Q_101101020*R_113[0]+-1*Q_101101120*R_114[0]+Q_101101220*R_115[0]; double QR_000002020003=Q_000002020*R_003[0]+-1*Q_000002120*R_004[0]+Q_000002220*R_005[0]+-1*Q_000102020*R_013[0]+Q_000102120*R_014[0]+-1*Q_000102220*R_015[0]+Q_000202020*R_023[0]+-1*Q_000202120*R_024[0]+Q_000202220*R_025[0]; double QR_001000021003=Q_001000021*R_003[0]+-1*Q_001000121*R_004[0]+Q_001000221*R_005[0]+-1*Q_001000321*R_006[0]+-1*Q_101000021*R_103[0]+Q_101000121*R_104[0]+-1*Q_101000221*R_105[0]+Q_101000321*R_106[0]; double QR_000001021003=Q_000001021*R_003[0]+-1*Q_000001121*R_004[0]+Q_000001221*R_005[0]+-1*Q_000001321*R_006[0]+-1*Q_000101021*R_013[0]+Q_000101121*R_014[0]+-1*Q_000101221*R_015[0]+Q_000101321*R_016[0]; double QR_000000022003=Q_000000022*R_003[0]+-1*Q_000000122*R_004[0]+Q_000000222*R_005[0]+-1*Q_000000322*R_006[0]+Q_000000422*R_007[0]; double QR_022000000012=Q_022000000*R_012[0]+-1*Q_122000000*R_112[0]+Q_222000000*R_212[0]+-1*Q_322000000*R_312[0]+Q_422000000*R_412[0]; double QR_021001000012=Q_021001000*R_012[0]+-1*Q_021101000*R_022[0]+-1*Q_121001000*R_112[0]+Q_121101000*R_122[0]+Q_221001000*R_212[0]+-1*Q_221101000*R_222[0]+-1*Q_321001000*R_312[0]+Q_321101000*R_322[0]; double QR_020002000012=Q_020002000*R_012[0]+-1*Q_020102000*R_022[0]+Q_020202000*R_032[0]+-1*Q_120002000*R_112[0]+Q_120102000*R_122[0]+-1*Q_120202000*R_132[0]+Q_220002000*R_212[0]+-1*Q_220102000*R_222[0]+Q_220202000*R_232[0]; double QR_021000001012=Q_021000001*R_012[0]+-1*Q_021000101*R_013[0]+-1*Q_121000001*R_112[0]+Q_121000101*R_113[0]+Q_221000001*R_212[0]+-1*Q_221000101*R_213[0]+-1*Q_321000001*R_312[0]+Q_321000101*R_313[0]; double QR_020001001012=Q_020001001*R_012[0]+-1*Q_020001101*R_013[0]+-1*Q_020101001*R_022[0]+Q_020101101*R_023[0]+-1*Q_120001001*R_112[0]+Q_120001101*R_113[0]+Q_120101001*R_122[0]+-1*Q_120101101*R_123[0]+Q_220001001*R_212[0]+-1*Q_220001101*R_213[0]+-1*Q_220101001*R_222[0]+Q_220101101*R_223[0]; double QR_020000002012=Q_020000002*R_012[0]+-1*Q_020000102*R_013[0]+Q_020000202*R_014[0]+-1*Q_120000002*R_112[0]+Q_120000102*R_113[0]+-1*Q_120000202*R_114[0]+Q_220000002*R_212[0]+-1*Q_220000102*R_213[0]+Q_220000202*R_214[0]; double QR_012010000012=Q_012010000*R_012[0]+-1*Q_012110000*R_022[0]+-1*Q_112010000*R_112[0]+Q_112110000*R_122[0]+Q_212010000*R_212[0]+-1*Q_212110000*R_222[0]+-1*Q_312010000*R_312[0]+Q_312110000*R_322[0]; double QR_011011000012=Q_011011000*R_012[0]+-1*Q_011111000*R_022[0]+Q_011211000*R_032[0]+-1*Q_111011000*R_112[0]+Q_111111000*R_122[0]+-1*Q_111211000*R_132[0]+Q_211011000*R_212[0]+-1*Q_211111000*R_222[0]+Q_211211000*R_232[0]; double QR_010012000012=Q_010012000*R_012[0]+-1*Q_010112000*R_022[0]+Q_010212000*R_032[0]+-1*Q_010312000*R_042[0]+-1*Q_110012000*R_112[0]+Q_110112000*R_122[0]+-1*Q_110212000*R_132[0]+Q_110312000*R_142[0]; double QR_011010001012=Q_011010001*R_012[0]+-1*Q_011010101*R_013[0]+-1*Q_011110001*R_022[0]+Q_011110101*R_023[0]+-1*Q_111010001*R_112[0]+Q_111010101*R_113[0]+Q_111110001*R_122[0]+-1*Q_111110101*R_123[0]+Q_211010001*R_212[0]+-1*Q_211010101*R_213[0]+-1*Q_211110001*R_222[0]+Q_211110101*R_223[0]; double QR_010011001012=Q_010011001*R_012[0]+-1*Q_010011101*R_013[0]+-1*Q_010111001*R_022[0]+Q_010111101*R_023[0]+Q_010211001*R_032[0]+-1*Q_010211101*R_033[0]+-1*Q_110011001*R_112[0]+Q_110011101*R_113[0]+Q_110111001*R_122[0]+-1*Q_110111101*R_123[0]+-1*Q_110211001*R_132[0]+Q_110211101*R_133[0]; double QR_010010002012=Q_010010002*R_012[0]+-1*Q_010010102*R_013[0]+Q_010010202*R_014[0]+-1*Q_010110002*R_022[0]+Q_010110102*R_023[0]+-1*Q_010110202*R_024[0]+-1*Q_110010002*R_112[0]+Q_110010102*R_113[0]+-1*Q_110010202*R_114[0]+Q_110110002*R_122[0]+-1*Q_110110102*R_123[0]+Q_110110202*R_124[0]; double QR_002020000012=Q_002020000*R_012[0]+-1*Q_002120000*R_022[0]+Q_002220000*R_032[0]+-1*Q_102020000*R_112[0]+Q_102120000*R_122[0]+-1*Q_102220000*R_132[0]+Q_202020000*R_212[0]+-1*Q_202120000*R_222[0]+Q_202220000*R_232[0]; double QR_001021000012=Q_001021000*R_012[0]+-1*Q_001121000*R_022[0]+Q_001221000*R_032[0]+-1*Q_001321000*R_042[0]+-1*Q_101021000*R_112[0]+Q_101121000*R_122[0]+-1*Q_101221000*R_132[0]+Q_101321000*R_142[0]; double QR_000022000012=Q_000022000*R_012[0]+-1*Q_000122000*R_022[0]+Q_000222000*R_032[0]+-1*Q_000322000*R_042[0]+Q_000422000*R_052[0]; double QR_001020001012=Q_001020001*R_012[0]+-1*Q_001020101*R_013[0]+-1*Q_001120001*R_022[0]+Q_001120101*R_023[0]+Q_001220001*R_032[0]+-1*Q_001220101*R_033[0]+-1*Q_101020001*R_112[0]+Q_101020101*R_113[0]+Q_101120001*R_122[0]+-1*Q_101120101*R_123[0]+-1*Q_101220001*R_132[0]+Q_101220101*R_133[0]; double QR_000021001012=Q_000021001*R_012[0]+-1*Q_000021101*R_013[0]+-1*Q_000121001*R_022[0]+Q_000121101*R_023[0]+Q_000221001*R_032[0]+-1*Q_000221101*R_033[0]+-1*Q_000321001*R_042[0]+Q_000321101*R_043[0]; double QR_000020002012=Q_000020002*R_012[0]+-1*Q_000020102*R_013[0]+Q_000020202*R_014[0]+-1*Q_000120002*R_022[0]+Q_000120102*R_023[0]+-1*Q_000120202*R_024[0]+Q_000220002*R_032[0]+-1*Q_000220102*R_033[0]+Q_000220202*R_034[0]; double QR_012000010012=Q_012000010*R_012[0]+-1*Q_012000110*R_013[0]+-1*Q_112000010*R_112[0]+Q_112000110*R_113[0]+Q_212000010*R_212[0]+-1*Q_212000110*R_213[0]+-1*Q_312000010*R_312[0]+Q_312000110*R_313[0]; double QR_011001010012=Q_011001010*R_012[0]+-1*Q_011001110*R_013[0]+-1*Q_011101010*R_022[0]+Q_011101110*R_023[0]+-1*Q_111001010*R_112[0]+Q_111001110*R_113[0]+Q_111101010*R_122[0]+-1*Q_111101110*R_123[0]+Q_211001010*R_212[0]+-1*Q_211001110*R_213[0]+-1*Q_211101010*R_222[0]+Q_211101110*R_223[0]; double QR_010002010012=Q_010002010*R_012[0]+-1*Q_010002110*R_013[0]+-1*Q_010102010*R_022[0]+Q_010102110*R_023[0]+Q_010202010*R_032[0]+-1*Q_010202110*R_033[0]+-1*Q_110002010*R_112[0]+Q_110002110*R_113[0]+Q_110102010*R_122[0]+-1*Q_110102110*R_123[0]+-1*Q_110202010*R_132[0]+Q_110202110*R_133[0]; double QR_011000011012=Q_011000011*R_012[0]+-1*Q_011000111*R_013[0]+Q_011000211*R_014[0]+-1*Q_111000011*R_112[0]+Q_111000111*R_113[0]+-1*Q_111000211*R_114[0]+Q_211000011*R_212[0]+-1*Q_211000111*R_213[0]+Q_211000211*R_214[0]; double QR_010001011012=Q_010001011*R_012[0]+-1*Q_010001111*R_013[0]+Q_010001211*R_014[0]+-1*Q_010101011*R_022[0]+Q_010101111*R_023[0]+-1*Q_010101211*R_024[0]+-1*Q_110001011*R_112[0]+Q_110001111*R_113[0]+-1*Q_110001211*R_114[0]+Q_110101011*R_122[0]+-1*Q_110101111*R_123[0]+Q_110101211*R_124[0]; double QR_010000012012=Q_010000012*R_012[0]+-1*Q_010000112*R_013[0]+Q_010000212*R_014[0]+-1*Q_010000312*R_015[0]+-1*Q_110000012*R_112[0]+Q_110000112*R_113[0]+-1*Q_110000212*R_114[0]+Q_110000312*R_115[0]; double QR_002010010012=Q_002010010*R_012[0]+-1*Q_002010110*R_013[0]+-1*Q_002110010*R_022[0]+Q_002110110*R_023[0]+-1*Q_102010010*R_112[0]+Q_102010110*R_113[0]+Q_102110010*R_122[0]+-1*Q_102110110*R_123[0]+Q_202010010*R_212[0]+-1*Q_202010110*R_213[0]+-1*Q_202110010*R_222[0]+Q_202110110*R_223[0]; double QR_001011010012=Q_001011010*R_012[0]+-1*Q_001011110*R_013[0]+-1*Q_001111010*R_022[0]+Q_001111110*R_023[0]+Q_001211010*R_032[0]+-1*Q_001211110*R_033[0]+-1*Q_101011010*R_112[0]+Q_101011110*R_113[0]+Q_101111010*R_122[0]+-1*Q_101111110*R_123[0]+-1*Q_101211010*R_132[0]+Q_101211110*R_133[0]; double QR_000012010012=Q_000012010*R_012[0]+-1*Q_000012110*R_013[0]+-1*Q_000112010*R_022[0]+Q_000112110*R_023[0]+Q_000212010*R_032[0]+-1*Q_000212110*R_033[0]+-1*Q_000312010*R_042[0]+Q_000312110*R_043[0]; double QR_001010011012=Q_001010011*R_012[0]+-1*Q_001010111*R_013[0]+Q_001010211*R_014[0]+-1*Q_001110011*R_022[0]+Q_001110111*R_023[0]+-1*Q_001110211*R_024[0]+-1*Q_101010011*R_112[0]+Q_101010111*R_113[0]+-1*Q_101010211*R_114[0]+Q_101110011*R_122[0]+-1*Q_101110111*R_123[0]+Q_101110211*R_124[0]; double QR_000011011012=Q_000011011*R_012[0]+-1*Q_000011111*R_013[0]+Q_000011211*R_014[0]+-1*Q_000111011*R_022[0]+Q_000111111*R_023[0]+-1*Q_000111211*R_024[0]+Q_000211011*R_032[0]+-1*Q_000211111*R_033[0]+Q_000211211*R_034[0]; double QR_000010012012=Q_000010012*R_012[0]+-1*Q_000010112*R_013[0]+Q_000010212*R_014[0]+-1*Q_000010312*R_015[0]+-1*Q_000110012*R_022[0]+Q_000110112*R_023[0]+-1*Q_000110212*R_024[0]+Q_000110312*R_025[0]; double QR_002000020012=Q_002000020*R_012[0]+-1*Q_002000120*R_013[0]+Q_002000220*R_014[0]+-1*Q_102000020*R_112[0]+Q_102000120*R_113[0]+-1*Q_102000220*R_114[0]+Q_202000020*R_212[0]+-1*Q_202000120*R_213[0]+Q_202000220*R_214[0]; double QR_001001020012=Q_001001020*R_012[0]+-1*Q_001001120*R_013[0]+Q_001001220*R_014[0]+-1*Q_001101020*R_022[0]+Q_001101120*R_023[0]+-1*Q_001101220*R_024[0]+-1*Q_101001020*R_112[0]+Q_101001120*R_113[0]+-1*Q_101001220*R_114[0]+Q_101101020*R_122[0]+-1*Q_101101120*R_123[0]+Q_101101220*R_124[0]; double QR_000002020012=Q_000002020*R_012[0]+-1*Q_000002120*R_013[0]+Q_000002220*R_014[0]+-1*Q_000102020*R_022[0]+Q_000102120*R_023[0]+-1*Q_000102220*R_024[0]+Q_000202020*R_032[0]+-1*Q_000202120*R_033[0]+Q_000202220*R_034[0]; double QR_001000021012=Q_001000021*R_012[0]+-1*Q_001000121*R_013[0]+Q_001000221*R_014[0]+-1*Q_001000321*R_015[0]+-1*Q_101000021*R_112[0]+Q_101000121*R_113[0]+-1*Q_101000221*R_114[0]+Q_101000321*R_115[0]; double QR_000001021012=Q_000001021*R_012[0]+-1*Q_000001121*R_013[0]+Q_000001221*R_014[0]+-1*Q_000001321*R_015[0]+-1*Q_000101021*R_022[0]+Q_000101121*R_023[0]+-1*Q_000101221*R_024[0]+Q_000101321*R_025[0]; double QR_000000022012=Q_000000022*R_012[0]+-1*Q_000000122*R_013[0]+Q_000000222*R_014[0]+-1*Q_000000322*R_015[0]+Q_000000422*R_016[0]; double QR_022000000021=Q_022000000*R_021[0]+-1*Q_122000000*R_121[0]+Q_222000000*R_221[0]+-1*Q_322000000*R_321[0]+Q_422000000*R_421[0]; double QR_021001000021=Q_021001000*R_021[0]+-1*Q_021101000*R_031[0]+-1*Q_121001000*R_121[0]+Q_121101000*R_131[0]+Q_221001000*R_221[0]+-1*Q_221101000*R_231[0]+-1*Q_321001000*R_321[0]+Q_321101000*R_331[0]; double QR_020002000021=Q_020002000*R_021[0]+-1*Q_020102000*R_031[0]+Q_020202000*R_041[0]+-1*Q_120002000*R_121[0]+Q_120102000*R_131[0]+-1*Q_120202000*R_141[0]+Q_220002000*R_221[0]+-1*Q_220102000*R_231[0]+Q_220202000*R_241[0]; double QR_021000001021=Q_021000001*R_021[0]+-1*Q_021000101*R_022[0]+-1*Q_121000001*R_121[0]+Q_121000101*R_122[0]+Q_221000001*R_221[0]+-1*Q_221000101*R_222[0]+-1*Q_321000001*R_321[0]+Q_321000101*R_322[0]; double QR_020001001021=Q_020001001*R_021[0]+-1*Q_020001101*R_022[0]+-1*Q_020101001*R_031[0]+Q_020101101*R_032[0]+-1*Q_120001001*R_121[0]+Q_120001101*R_122[0]+Q_120101001*R_131[0]+-1*Q_120101101*R_132[0]+Q_220001001*R_221[0]+-1*Q_220001101*R_222[0]+-1*Q_220101001*R_231[0]+Q_220101101*R_232[0]; double QR_020000002021=Q_020000002*R_021[0]+-1*Q_020000102*R_022[0]+Q_020000202*R_023[0]+-1*Q_120000002*R_121[0]+Q_120000102*R_122[0]+-1*Q_120000202*R_123[0]+Q_220000002*R_221[0]+-1*Q_220000102*R_222[0]+Q_220000202*R_223[0]; double QR_012010000021=Q_012010000*R_021[0]+-1*Q_012110000*R_031[0]+-1*Q_112010000*R_121[0]+Q_112110000*R_131[0]+Q_212010000*R_221[0]+-1*Q_212110000*R_231[0]+-1*Q_312010000*R_321[0]+Q_312110000*R_331[0]; double QR_011011000021=Q_011011000*R_021[0]+-1*Q_011111000*R_031[0]+Q_011211000*R_041[0]+-1*Q_111011000*R_121[0]+Q_111111000*R_131[0]+-1*Q_111211000*R_141[0]+Q_211011000*R_221[0]+-1*Q_211111000*R_231[0]+Q_211211000*R_241[0]; double QR_010012000021=Q_010012000*R_021[0]+-1*Q_010112000*R_031[0]+Q_010212000*R_041[0]+-1*Q_010312000*R_051[0]+-1*Q_110012000*R_121[0]+Q_110112000*R_131[0]+-1*Q_110212000*R_141[0]+Q_110312000*R_151[0]; double QR_011010001021=Q_011010001*R_021[0]+-1*Q_011010101*R_022[0]+-1*Q_011110001*R_031[0]+Q_011110101*R_032[0]+-1*Q_111010001*R_121[0]+Q_111010101*R_122[0]+Q_111110001*R_131[0]+-1*Q_111110101*R_132[0]+Q_211010001*R_221[0]+-1*Q_211010101*R_222[0]+-1*Q_211110001*R_231[0]+Q_211110101*R_232[0]; double QR_010011001021=Q_010011001*R_021[0]+-1*Q_010011101*R_022[0]+-1*Q_010111001*R_031[0]+Q_010111101*R_032[0]+Q_010211001*R_041[0]+-1*Q_010211101*R_042[0]+-1*Q_110011001*R_121[0]+Q_110011101*R_122[0]+Q_110111001*R_131[0]+-1*Q_110111101*R_132[0]+-1*Q_110211001*R_141[0]+Q_110211101*R_142[0]; double QR_010010002021=Q_010010002*R_021[0]+-1*Q_010010102*R_022[0]+Q_010010202*R_023[0]+-1*Q_010110002*R_031[0]+Q_010110102*R_032[0]+-1*Q_010110202*R_033[0]+-1*Q_110010002*R_121[0]+Q_110010102*R_122[0]+-1*Q_110010202*R_123[0]+Q_110110002*R_131[0]+-1*Q_110110102*R_132[0]+Q_110110202*R_133[0]; double QR_002020000021=Q_002020000*R_021[0]+-1*Q_002120000*R_031[0]+Q_002220000*R_041[0]+-1*Q_102020000*R_121[0]+Q_102120000*R_131[0]+-1*Q_102220000*R_141[0]+Q_202020000*R_221[0]+-1*Q_202120000*R_231[0]+Q_202220000*R_241[0]; double QR_001021000021=Q_001021000*R_021[0]+-1*Q_001121000*R_031[0]+Q_001221000*R_041[0]+-1*Q_001321000*R_051[0]+-1*Q_101021000*R_121[0]+Q_101121000*R_131[0]+-1*Q_101221000*R_141[0]+Q_101321000*R_151[0]; double QR_000022000021=Q_000022000*R_021[0]+-1*Q_000122000*R_031[0]+Q_000222000*R_041[0]+-1*Q_000322000*R_051[0]+Q_000422000*R_061[0]; double QR_001020001021=Q_001020001*R_021[0]+-1*Q_001020101*R_022[0]+-1*Q_001120001*R_031[0]+Q_001120101*R_032[0]+Q_001220001*R_041[0]+-1*Q_001220101*R_042[0]+-1*Q_101020001*R_121[0]+Q_101020101*R_122[0]+Q_101120001*R_131[0]+-1*Q_101120101*R_132[0]+-1*Q_101220001*R_141[0]+Q_101220101*R_142[0]; double QR_000021001021=Q_000021001*R_021[0]+-1*Q_000021101*R_022[0]+-1*Q_000121001*R_031[0]+Q_000121101*R_032[0]+Q_000221001*R_041[0]+-1*Q_000221101*R_042[0]+-1*Q_000321001*R_051[0]+Q_000321101*R_052[0]; double QR_000020002021=Q_000020002*R_021[0]+-1*Q_000020102*R_022[0]+Q_000020202*R_023[0]+-1*Q_000120002*R_031[0]+Q_000120102*R_032[0]+-1*Q_000120202*R_033[0]+Q_000220002*R_041[0]+-1*Q_000220102*R_042[0]+Q_000220202*R_043[0]; double QR_012000010021=Q_012000010*R_021[0]+-1*Q_012000110*R_022[0]+-1*Q_112000010*R_121[0]+Q_112000110*R_122[0]+Q_212000010*R_221[0]+-1*Q_212000110*R_222[0]+-1*Q_312000010*R_321[0]+Q_312000110*R_322[0]; double QR_011001010021=Q_011001010*R_021[0]+-1*Q_011001110*R_022[0]+-1*Q_011101010*R_031[0]+Q_011101110*R_032[0]+-1*Q_111001010*R_121[0]+Q_111001110*R_122[0]+Q_111101010*R_131[0]+-1*Q_111101110*R_132[0]+Q_211001010*R_221[0]+-1*Q_211001110*R_222[0]+-1*Q_211101010*R_231[0]+Q_211101110*R_232[0]; double QR_010002010021=Q_010002010*R_021[0]+-1*Q_010002110*R_022[0]+-1*Q_010102010*R_031[0]+Q_010102110*R_032[0]+Q_010202010*R_041[0]+-1*Q_010202110*R_042[0]+-1*Q_110002010*R_121[0]+Q_110002110*R_122[0]+Q_110102010*R_131[0]+-1*Q_110102110*R_132[0]+-1*Q_110202010*R_141[0]+Q_110202110*R_142[0]; double QR_011000011021=Q_011000011*R_021[0]+-1*Q_011000111*R_022[0]+Q_011000211*R_023[0]+-1*Q_111000011*R_121[0]+Q_111000111*R_122[0]+-1*Q_111000211*R_123[0]+Q_211000011*R_221[0]+-1*Q_211000111*R_222[0]+Q_211000211*R_223[0]; double QR_010001011021=Q_010001011*R_021[0]+-1*Q_010001111*R_022[0]+Q_010001211*R_023[0]+-1*Q_010101011*R_031[0]+Q_010101111*R_032[0]+-1*Q_010101211*R_033[0]+-1*Q_110001011*R_121[0]+Q_110001111*R_122[0]+-1*Q_110001211*R_123[0]+Q_110101011*R_131[0]+-1*Q_110101111*R_132[0]+Q_110101211*R_133[0]; double QR_010000012021=Q_010000012*R_021[0]+-1*Q_010000112*R_022[0]+Q_010000212*R_023[0]+-1*Q_010000312*R_024[0]+-1*Q_110000012*R_121[0]+Q_110000112*R_122[0]+-1*Q_110000212*R_123[0]+Q_110000312*R_124[0]; double QR_002010010021=Q_002010010*R_021[0]+-1*Q_002010110*R_022[0]+-1*Q_002110010*R_031[0]+Q_002110110*R_032[0]+-1*Q_102010010*R_121[0]+Q_102010110*R_122[0]+Q_102110010*R_131[0]+-1*Q_102110110*R_132[0]+Q_202010010*R_221[0]+-1*Q_202010110*R_222[0]+-1*Q_202110010*R_231[0]+Q_202110110*R_232[0]; double QR_001011010021=Q_001011010*R_021[0]+-1*Q_001011110*R_022[0]+-1*Q_001111010*R_031[0]+Q_001111110*R_032[0]+Q_001211010*R_041[0]+-1*Q_001211110*R_042[0]+-1*Q_101011010*R_121[0]+Q_101011110*R_122[0]+Q_101111010*R_131[0]+-1*Q_101111110*R_132[0]+-1*Q_101211010*R_141[0]+Q_101211110*R_142[0]; double QR_000012010021=Q_000012010*R_021[0]+-1*Q_000012110*R_022[0]+-1*Q_000112010*R_031[0]+Q_000112110*R_032[0]+Q_000212010*R_041[0]+-1*Q_000212110*R_042[0]+-1*Q_000312010*R_051[0]+Q_000312110*R_052[0]; double QR_001010011021=Q_001010011*R_021[0]+-1*Q_001010111*R_022[0]+Q_001010211*R_023[0]+-1*Q_001110011*R_031[0]+Q_001110111*R_032[0]+-1*Q_001110211*R_033[0]+-1*Q_101010011*R_121[0]+Q_101010111*R_122[0]+-1*Q_101010211*R_123[0]+Q_101110011*R_131[0]+-1*Q_101110111*R_132[0]+Q_101110211*R_133[0]; double QR_000011011021=Q_000011011*R_021[0]+-1*Q_000011111*R_022[0]+Q_000011211*R_023[0]+-1*Q_000111011*R_031[0]+Q_000111111*R_032[0]+-1*Q_000111211*R_033[0]+Q_000211011*R_041[0]+-1*Q_000211111*R_042[0]+Q_000211211*R_043[0]; double QR_000010012021=Q_000010012*R_021[0]+-1*Q_000010112*R_022[0]+Q_000010212*R_023[0]+-1*Q_000010312*R_024[0]+-1*Q_000110012*R_031[0]+Q_000110112*R_032[0]+-1*Q_000110212*R_033[0]+Q_000110312*R_034[0]; double QR_002000020021=Q_002000020*R_021[0]+-1*Q_002000120*R_022[0]+Q_002000220*R_023[0]+-1*Q_102000020*R_121[0]+Q_102000120*R_122[0]+-1*Q_102000220*R_123[0]+Q_202000020*R_221[0]+-1*Q_202000120*R_222[0]+Q_202000220*R_223[0]; double QR_001001020021=Q_001001020*R_021[0]+-1*Q_001001120*R_022[0]+Q_001001220*R_023[0]+-1*Q_001101020*R_031[0]+Q_001101120*R_032[0]+-1*Q_001101220*R_033[0]+-1*Q_101001020*R_121[0]+Q_101001120*R_122[0]+-1*Q_101001220*R_123[0]+Q_101101020*R_131[0]+-1*Q_101101120*R_132[0]+Q_101101220*R_133[0]; double QR_000002020021=Q_000002020*R_021[0]+-1*Q_000002120*R_022[0]+Q_000002220*R_023[0]+-1*Q_000102020*R_031[0]+Q_000102120*R_032[0]+-1*Q_000102220*R_033[0]+Q_000202020*R_041[0]+-1*Q_000202120*R_042[0]+Q_000202220*R_043[0]; double QR_001000021021=Q_001000021*R_021[0]+-1*Q_001000121*R_022[0]+Q_001000221*R_023[0]+-1*Q_001000321*R_024[0]+-1*Q_101000021*R_121[0]+Q_101000121*R_122[0]+-1*Q_101000221*R_123[0]+Q_101000321*R_124[0]; double QR_000001021021=Q_000001021*R_021[0]+-1*Q_000001121*R_022[0]+Q_000001221*R_023[0]+-1*Q_000001321*R_024[0]+-1*Q_000101021*R_031[0]+Q_000101121*R_032[0]+-1*Q_000101221*R_033[0]+Q_000101321*R_034[0]; double QR_000000022021=Q_000000022*R_021[0]+-1*Q_000000122*R_022[0]+Q_000000222*R_023[0]+-1*Q_000000322*R_024[0]+Q_000000422*R_025[0]; double QR_022000000030=Q_022000000*R_030[0]+-1*Q_122000000*R_130[0]+Q_222000000*R_230[0]+-1*Q_322000000*R_330[0]+Q_422000000*R_430[0]; double QR_021001000030=Q_021001000*R_030[0]+-1*Q_021101000*R_040[0]+-1*Q_121001000*R_130[0]+Q_121101000*R_140[0]+Q_221001000*R_230[0]+-1*Q_221101000*R_240[0]+-1*Q_321001000*R_330[0]+Q_321101000*R_340[0]; double QR_020002000030=Q_020002000*R_030[0]+-1*Q_020102000*R_040[0]+Q_020202000*R_050[0]+-1*Q_120002000*R_130[0]+Q_120102000*R_140[0]+-1*Q_120202000*R_150[0]+Q_220002000*R_230[0]+-1*Q_220102000*R_240[0]+Q_220202000*R_250[0]; double QR_021000001030=Q_021000001*R_030[0]+-1*Q_021000101*R_031[0]+-1*Q_121000001*R_130[0]+Q_121000101*R_131[0]+Q_221000001*R_230[0]+-1*Q_221000101*R_231[0]+-1*Q_321000001*R_330[0]+Q_321000101*R_331[0]; double QR_020001001030=Q_020001001*R_030[0]+-1*Q_020001101*R_031[0]+-1*Q_020101001*R_040[0]+Q_020101101*R_041[0]+-1*Q_120001001*R_130[0]+Q_120001101*R_131[0]+Q_120101001*R_140[0]+-1*Q_120101101*R_141[0]+Q_220001001*R_230[0]+-1*Q_220001101*R_231[0]+-1*Q_220101001*R_240[0]+Q_220101101*R_241[0]; double QR_020000002030=Q_020000002*R_030[0]+-1*Q_020000102*R_031[0]+Q_020000202*R_032[0]+-1*Q_120000002*R_130[0]+Q_120000102*R_131[0]+-1*Q_120000202*R_132[0]+Q_220000002*R_230[0]+-1*Q_220000102*R_231[0]+Q_220000202*R_232[0]; double QR_012010000030=Q_012010000*R_030[0]+-1*Q_012110000*R_040[0]+-1*Q_112010000*R_130[0]+Q_112110000*R_140[0]+Q_212010000*R_230[0]+-1*Q_212110000*R_240[0]+-1*Q_312010000*R_330[0]+Q_312110000*R_340[0]; double QR_011011000030=Q_011011000*R_030[0]+-1*Q_011111000*R_040[0]+Q_011211000*R_050[0]+-1*Q_111011000*R_130[0]+Q_111111000*R_140[0]+-1*Q_111211000*R_150[0]+Q_211011000*R_230[0]+-1*Q_211111000*R_240[0]+Q_211211000*R_250[0]; double QR_010012000030=Q_010012000*R_030[0]+-1*Q_010112000*R_040[0]+Q_010212000*R_050[0]+-1*Q_010312000*R_060[0]+-1*Q_110012000*R_130[0]+Q_110112000*R_140[0]+-1*Q_110212000*R_150[0]+Q_110312000*R_160[0]; double QR_011010001030=Q_011010001*R_030[0]+-1*Q_011010101*R_031[0]+-1*Q_011110001*R_040[0]+Q_011110101*R_041[0]+-1*Q_111010001*R_130[0]+Q_111010101*R_131[0]+Q_111110001*R_140[0]+-1*Q_111110101*R_141[0]+Q_211010001*R_230[0]+-1*Q_211010101*R_231[0]+-1*Q_211110001*R_240[0]+Q_211110101*R_241[0]; double QR_010011001030=Q_010011001*R_030[0]+-1*Q_010011101*R_031[0]+-1*Q_010111001*R_040[0]+Q_010111101*R_041[0]+Q_010211001*R_050[0]+-1*Q_010211101*R_051[0]+-1*Q_110011001*R_130[0]+Q_110011101*R_131[0]+Q_110111001*R_140[0]+-1*Q_110111101*R_141[0]+-1*Q_110211001*R_150[0]+Q_110211101*R_151[0]; double QR_010010002030=Q_010010002*R_030[0]+-1*Q_010010102*R_031[0]+Q_010010202*R_032[0]+-1*Q_010110002*R_040[0]+Q_010110102*R_041[0]+-1*Q_010110202*R_042[0]+-1*Q_110010002*R_130[0]+Q_110010102*R_131[0]+-1*Q_110010202*R_132[0]+Q_110110002*R_140[0]+-1*Q_110110102*R_141[0]+Q_110110202*R_142[0]; double QR_002020000030=Q_002020000*R_030[0]+-1*Q_002120000*R_040[0]+Q_002220000*R_050[0]+-1*Q_102020000*R_130[0]+Q_102120000*R_140[0]+-1*Q_102220000*R_150[0]+Q_202020000*R_230[0]+-1*Q_202120000*R_240[0]+Q_202220000*R_250[0]; double QR_001021000030=Q_001021000*R_030[0]+-1*Q_001121000*R_040[0]+Q_001221000*R_050[0]+-1*Q_001321000*R_060[0]+-1*Q_101021000*R_130[0]+Q_101121000*R_140[0]+-1*Q_101221000*R_150[0]+Q_101321000*R_160[0]; double QR_000022000030=Q_000022000*R_030[0]+-1*Q_000122000*R_040[0]+Q_000222000*R_050[0]+-1*Q_000322000*R_060[0]+Q_000422000*R_070[0]; double QR_001020001030=Q_001020001*R_030[0]+-1*Q_001020101*R_031[0]+-1*Q_001120001*R_040[0]+Q_001120101*R_041[0]+Q_001220001*R_050[0]+-1*Q_001220101*R_051[0]+-1*Q_101020001*R_130[0]+Q_101020101*R_131[0]+Q_101120001*R_140[0]+-1*Q_101120101*R_141[0]+-1*Q_101220001*R_150[0]+Q_101220101*R_151[0]; double QR_000021001030=Q_000021001*R_030[0]+-1*Q_000021101*R_031[0]+-1*Q_000121001*R_040[0]+Q_000121101*R_041[0]+Q_000221001*R_050[0]+-1*Q_000221101*R_051[0]+-1*Q_000321001*R_060[0]+Q_000321101*R_061[0]; double QR_000020002030=Q_000020002*R_030[0]+-1*Q_000020102*R_031[0]+Q_000020202*R_032[0]+-1*Q_000120002*R_040[0]+Q_000120102*R_041[0]+-1*Q_000120202*R_042[0]+Q_000220002*R_050[0]+-1*Q_000220102*R_051[0]+Q_000220202*R_052[0]; double QR_012000010030=Q_012000010*R_030[0]+-1*Q_012000110*R_031[0]+-1*Q_112000010*R_130[0]+Q_112000110*R_131[0]+Q_212000010*R_230[0]+-1*Q_212000110*R_231[0]+-1*Q_312000010*R_330[0]+Q_312000110*R_331[0]; double QR_011001010030=Q_011001010*R_030[0]+-1*Q_011001110*R_031[0]+-1*Q_011101010*R_040[0]+Q_011101110*R_041[0]+-1*Q_111001010*R_130[0]+Q_111001110*R_131[0]+Q_111101010*R_140[0]+-1*Q_111101110*R_141[0]+Q_211001010*R_230[0]+-1*Q_211001110*R_231[0]+-1*Q_211101010*R_240[0]+Q_211101110*R_241[0]; double QR_010002010030=Q_010002010*R_030[0]+-1*Q_010002110*R_031[0]+-1*Q_010102010*R_040[0]+Q_010102110*R_041[0]+Q_010202010*R_050[0]+-1*Q_010202110*R_051[0]+-1*Q_110002010*R_130[0]+Q_110002110*R_131[0]+Q_110102010*R_140[0]+-1*Q_110102110*R_141[0]+-1*Q_110202010*R_150[0]+Q_110202110*R_151[0]; double QR_011000011030=Q_011000011*R_030[0]+-1*Q_011000111*R_031[0]+Q_011000211*R_032[0]+-1*Q_111000011*R_130[0]+Q_111000111*R_131[0]+-1*Q_111000211*R_132[0]+Q_211000011*R_230[0]+-1*Q_211000111*R_231[0]+Q_211000211*R_232[0]; double QR_010001011030=Q_010001011*R_030[0]+-1*Q_010001111*R_031[0]+Q_010001211*R_032[0]+-1*Q_010101011*R_040[0]+Q_010101111*R_041[0]+-1*Q_010101211*R_042[0]+-1*Q_110001011*R_130[0]+Q_110001111*R_131[0]+-1*Q_110001211*R_132[0]+Q_110101011*R_140[0]+-1*Q_110101111*R_141[0]+Q_110101211*R_142[0]; double QR_010000012030=Q_010000012*R_030[0]+-1*Q_010000112*R_031[0]+Q_010000212*R_032[0]+-1*Q_010000312*R_033[0]+-1*Q_110000012*R_130[0]+Q_110000112*R_131[0]+-1*Q_110000212*R_132[0]+Q_110000312*R_133[0]; double QR_002010010030=Q_002010010*R_030[0]+-1*Q_002010110*R_031[0]+-1*Q_002110010*R_040[0]+Q_002110110*R_041[0]+-1*Q_102010010*R_130[0]+Q_102010110*R_131[0]+Q_102110010*R_140[0]+-1*Q_102110110*R_141[0]+Q_202010010*R_230[0]+-1*Q_202010110*R_231[0]+-1*Q_202110010*R_240[0]+Q_202110110*R_241[0]; double QR_001011010030=Q_001011010*R_030[0]+-1*Q_001011110*R_031[0]+-1*Q_001111010*R_040[0]+Q_001111110*R_041[0]+Q_001211010*R_050[0]+-1*Q_001211110*R_051[0]+-1*Q_101011010*R_130[0]+Q_101011110*R_131[0]+Q_101111010*R_140[0]+-1*Q_101111110*R_141[0]+-1*Q_101211010*R_150[0]+Q_101211110*R_151[0]; double QR_000012010030=Q_000012010*R_030[0]+-1*Q_000012110*R_031[0]+-1*Q_000112010*R_040[0]+Q_000112110*R_041[0]+Q_000212010*R_050[0]+-1*Q_000212110*R_051[0]+-1*Q_000312010*R_060[0]+Q_000312110*R_061[0]; double QR_001010011030=Q_001010011*R_030[0]+-1*Q_001010111*R_031[0]+Q_001010211*R_032[0]+-1*Q_001110011*R_040[0]+Q_001110111*R_041[0]+-1*Q_001110211*R_042[0]+-1*Q_101010011*R_130[0]+Q_101010111*R_131[0]+-1*Q_101010211*R_132[0]+Q_101110011*R_140[0]+-1*Q_101110111*R_141[0]+Q_101110211*R_142[0]; double QR_000011011030=Q_000011011*R_030[0]+-1*Q_000011111*R_031[0]+Q_000011211*R_032[0]+-1*Q_000111011*R_040[0]+Q_000111111*R_041[0]+-1*Q_000111211*R_042[0]+Q_000211011*R_050[0]+-1*Q_000211111*R_051[0]+Q_000211211*R_052[0]; double QR_000010012030=Q_000010012*R_030[0]+-1*Q_000010112*R_031[0]+Q_000010212*R_032[0]+-1*Q_000010312*R_033[0]+-1*Q_000110012*R_040[0]+Q_000110112*R_041[0]+-1*Q_000110212*R_042[0]+Q_000110312*R_043[0]; double QR_002000020030=Q_002000020*R_030[0]+-1*Q_002000120*R_031[0]+Q_002000220*R_032[0]+-1*Q_102000020*R_130[0]+Q_102000120*R_131[0]+-1*Q_102000220*R_132[0]+Q_202000020*R_230[0]+-1*Q_202000120*R_231[0]+Q_202000220*R_232[0]; double QR_001001020030=Q_001001020*R_030[0]+-1*Q_001001120*R_031[0]+Q_001001220*R_032[0]+-1*Q_001101020*R_040[0]+Q_001101120*R_041[0]+-1*Q_001101220*R_042[0]+-1*Q_101001020*R_130[0]+Q_101001120*R_131[0]+-1*Q_101001220*R_132[0]+Q_101101020*R_140[0]+-1*Q_101101120*R_141[0]+Q_101101220*R_142[0]; double QR_000002020030=Q_000002020*R_030[0]+-1*Q_000002120*R_031[0]+Q_000002220*R_032[0]+-1*Q_000102020*R_040[0]+Q_000102120*R_041[0]+-1*Q_000102220*R_042[0]+Q_000202020*R_050[0]+-1*Q_000202120*R_051[0]+Q_000202220*R_052[0]; double QR_001000021030=Q_001000021*R_030[0]+-1*Q_001000121*R_031[0]+Q_001000221*R_032[0]+-1*Q_001000321*R_033[0]+-1*Q_101000021*R_130[0]+Q_101000121*R_131[0]+-1*Q_101000221*R_132[0]+Q_101000321*R_133[0]; double QR_000001021030=Q_000001021*R_030[0]+-1*Q_000001121*R_031[0]+Q_000001221*R_032[0]+-1*Q_000001321*R_033[0]+-1*Q_000101021*R_040[0]+Q_000101121*R_041[0]+-1*Q_000101221*R_042[0]+Q_000101321*R_043[0]; double QR_000000022030=Q_000000022*R_030[0]+-1*Q_000000122*R_031[0]+Q_000000222*R_032[0]+-1*Q_000000322*R_033[0]+Q_000000422*R_034[0]; double QR_022000000102=Q_022000000*R_102[0]+-1*Q_122000000*R_202[0]+Q_222000000*R_302[0]+-1*Q_322000000*R_402[0]+Q_422000000*R_502[0]; double QR_021001000102=Q_021001000*R_102[0]+-1*Q_021101000*R_112[0]+-1*Q_121001000*R_202[0]+Q_121101000*R_212[0]+Q_221001000*R_302[0]+-1*Q_221101000*R_312[0]+-1*Q_321001000*R_402[0]+Q_321101000*R_412[0]; double QR_020002000102=Q_020002000*R_102[0]+-1*Q_020102000*R_112[0]+Q_020202000*R_122[0]+-1*Q_120002000*R_202[0]+Q_120102000*R_212[0]+-1*Q_120202000*R_222[0]+Q_220002000*R_302[0]+-1*Q_220102000*R_312[0]+Q_220202000*R_322[0]; double QR_021000001102=Q_021000001*R_102[0]+-1*Q_021000101*R_103[0]+-1*Q_121000001*R_202[0]+Q_121000101*R_203[0]+Q_221000001*R_302[0]+-1*Q_221000101*R_303[0]+-1*Q_321000001*R_402[0]+Q_321000101*R_403[0]; double QR_020001001102=Q_020001001*R_102[0]+-1*Q_020001101*R_103[0]+-1*Q_020101001*R_112[0]+Q_020101101*R_113[0]+-1*Q_120001001*R_202[0]+Q_120001101*R_203[0]+Q_120101001*R_212[0]+-1*Q_120101101*R_213[0]+Q_220001001*R_302[0]+-1*Q_220001101*R_303[0]+-1*Q_220101001*R_312[0]+Q_220101101*R_313[0]; double QR_020000002102=Q_020000002*R_102[0]+-1*Q_020000102*R_103[0]+Q_020000202*R_104[0]+-1*Q_120000002*R_202[0]+Q_120000102*R_203[0]+-1*Q_120000202*R_204[0]+Q_220000002*R_302[0]+-1*Q_220000102*R_303[0]+Q_220000202*R_304[0]; double QR_012010000102=Q_012010000*R_102[0]+-1*Q_012110000*R_112[0]+-1*Q_112010000*R_202[0]+Q_112110000*R_212[0]+Q_212010000*R_302[0]+-1*Q_212110000*R_312[0]+-1*Q_312010000*R_402[0]+Q_312110000*R_412[0]; double QR_011011000102=Q_011011000*R_102[0]+-1*Q_011111000*R_112[0]+Q_011211000*R_122[0]+-1*Q_111011000*R_202[0]+Q_111111000*R_212[0]+-1*Q_111211000*R_222[0]+Q_211011000*R_302[0]+-1*Q_211111000*R_312[0]+Q_211211000*R_322[0]; double QR_010012000102=Q_010012000*R_102[0]+-1*Q_010112000*R_112[0]+Q_010212000*R_122[0]+-1*Q_010312000*R_132[0]+-1*Q_110012000*R_202[0]+Q_110112000*R_212[0]+-1*Q_110212000*R_222[0]+Q_110312000*R_232[0]; double QR_011010001102=Q_011010001*R_102[0]+-1*Q_011010101*R_103[0]+-1*Q_011110001*R_112[0]+Q_011110101*R_113[0]+-1*Q_111010001*R_202[0]+Q_111010101*R_203[0]+Q_111110001*R_212[0]+-1*Q_111110101*R_213[0]+Q_211010001*R_302[0]+-1*Q_211010101*R_303[0]+-1*Q_211110001*R_312[0]+Q_211110101*R_313[0]; double QR_010011001102=Q_010011001*R_102[0]+-1*Q_010011101*R_103[0]+-1*Q_010111001*R_112[0]+Q_010111101*R_113[0]+Q_010211001*R_122[0]+-1*Q_010211101*R_123[0]+-1*Q_110011001*R_202[0]+Q_110011101*R_203[0]+Q_110111001*R_212[0]+-1*Q_110111101*R_213[0]+-1*Q_110211001*R_222[0]+Q_110211101*R_223[0]; double QR_010010002102=Q_010010002*R_102[0]+-1*Q_010010102*R_103[0]+Q_010010202*R_104[0]+-1*Q_010110002*R_112[0]+Q_010110102*R_113[0]+-1*Q_010110202*R_114[0]+-1*Q_110010002*R_202[0]+Q_110010102*R_203[0]+-1*Q_110010202*R_204[0]+Q_110110002*R_212[0]+-1*Q_110110102*R_213[0]+Q_110110202*R_214[0]; double QR_002020000102=Q_002020000*R_102[0]+-1*Q_002120000*R_112[0]+Q_002220000*R_122[0]+-1*Q_102020000*R_202[0]+Q_102120000*R_212[0]+-1*Q_102220000*R_222[0]+Q_202020000*R_302[0]+-1*Q_202120000*R_312[0]+Q_202220000*R_322[0]; double QR_001021000102=Q_001021000*R_102[0]+-1*Q_001121000*R_112[0]+Q_001221000*R_122[0]+-1*Q_001321000*R_132[0]+-1*Q_101021000*R_202[0]+Q_101121000*R_212[0]+-1*Q_101221000*R_222[0]+Q_101321000*R_232[0]; double QR_000022000102=Q_000022000*R_102[0]+-1*Q_000122000*R_112[0]+Q_000222000*R_122[0]+-1*Q_000322000*R_132[0]+Q_000422000*R_142[0]; double QR_001020001102=Q_001020001*R_102[0]+-1*Q_001020101*R_103[0]+-1*Q_001120001*R_112[0]+Q_001120101*R_113[0]+Q_001220001*R_122[0]+-1*Q_001220101*R_123[0]+-1*Q_101020001*R_202[0]+Q_101020101*R_203[0]+Q_101120001*R_212[0]+-1*Q_101120101*R_213[0]+-1*Q_101220001*R_222[0]+Q_101220101*R_223[0]; double QR_000021001102=Q_000021001*R_102[0]+-1*Q_000021101*R_103[0]+-1*Q_000121001*R_112[0]+Q_000121101*R_113[0]+Q_000221001*R_122[0]+-1*Q_000221101*R_123[0]+-1*Q_000321001*R_132[0]+Q_000321101*R_133[0]; double QR_000020002102=Q_000020002*R_102[0]+-1*Q_000020102*R_103[0]+Q_000020202*R_104[0]+-1*Q_000120002*R_112[0]+Q_000120102*R_113[0]+-1*Q_000120202*R_114[0]+Q_000220002*R_122[0]+-1*Q_000220102*R_123[0]+Q_000220202*R_124[0]; double QR_012000010102=Q_012000010*R_102[0]+-1*Q_012000110*R_103[0]+-1*Q_112000010*R_202[0]+Q_112000110*R_203[0]+Q_212000010*R_302[0]+-1*Q_212000110*R_303[0]+-1*Q_312000010*R_402[0]+Q_312000110*R_403[0]; double QR_011001010102=Q_011001010*R_102[0]+-1*Q_011001110*R_103[0]+-1*Q_011101010*R_112[0]+Q_011101110*R_113[0]+-1*Q_111001010*R_202[0]+Q_111001110*R_203[0]+Q_111101010*R_212[0]+-1*Q_111101110*R_213[0]+Q_211001010*R_302[0]+-1*Q_211001110*R_303[0]+-1*Q_211101010*R_312[0]+Q_211101110*R_313[0]; double QR_010002010102=Q_010002010*R_102[0]+-1*Q_010002110*R_103[0]+-1*Q_010102010*R_112[0]+Q_010102110*R_113[0]+Q_010202010*R_122[0]+-1*Q_010202110*R_123[0]+-1*Q_110002010*R_202[0]+Q_110002110*R_203[0]+Q_110102010*R_212[0]+-1*Q_110102110*R_213[0]+-1*Q_110202010*R_222[0]+Q_110202110*R_223[0]; double QR_011000011102=Q_011000011*R_102[0]+-1*Q_011000111*R_103[0]+Q_011000211*R_104[0]+-1*Q_111000011*R_202[0]+Q_111000111*R_203[0]+-1*Q_111000211*R_204[0]+Q_211000011*R_302[0]+-1*Q_211000111*R_303[0]+Q_211000211*R_304[0]; double QR_010001011102=Q_010001011*R_102[0]+-1*Q_010001111*R_103[0]+Q_010001211*R_104[0]+-1*Q_010101011*R_112[0]+Q_010101111*R_113[0]+-1*Q_010101211*R_114[0]+-1*Q_110001011*R_202[0]+Q_110001111*R_203[0]+-1*Q_110001211*R_204[0]+Q_110101011*R_212[0]+-1*Q_110101111*R_213[0]+Q_110101211*R_214[0]; double QR_010000012102=Q_010000012*R_102[0]+-1*Q_010000112*R_103[0]+Q_010000212*R_104[0]+-1*Q_010000312*R_105[0]+-1*Q_110000012*R_202[0]+Q_110000112*R_203[0]+-1*Q_110000212*R_204[0]+Q_110000312*R_205[0]; double QR_002010010102=Q_002010010*R_102[0]+-1*Q_002010110*R_103[0]+-1*Q_002110010*R_112[0]+Q_002110110*R_113[0]+-1*Q_102010010*R_202[0]+Q_102010110*R_203[0]+Q_102110010*R_212[0]+-1*Q_102110110*R_213[0]+Q_202010010*R_302[0]+-1*Q_202010110*R_303[0]+-1*Q_202110010*R_312[0]+Q_202110110*R_313[0]; double QR_001011010102=Q_001011010*R_102[0]+-1*Q_001011110*R_103[0]+-1*Q_001111010*R_112[0]+Q_001111110*R_113[0]+Q_001211010*R_122[0]+-1*Q_001211110*R_123[0]+-1*Q_101011010*R_202[0]+Q_101011110*R_203[0]+Q_101111010*R_212[0]+-1*Q_101111110*R_213[0]+-1*Q_101211010*R_222[0]+Q_101211110*R_223[0]; double QR_000012010102=Q_000012010*R_102[0]+-1*Q_000012110*R_103[0]+-1*Q_000112010*R_112[0]+Q_000112110*R_113[0]+Q_000212010*R_122[0]+-1*Q_000212110*R_123[0]+-1*Q_000312010*R_132[0]+Q_000312110*R_133[0]; double QR_001010011102=Q_001010011*R_102[0]+-1*Q_001010111*R_103[0]+Q_001010211*R_104[0]+-1*Q_001110011*R_112[0]+Q_001110111*R_113[0]+-1*Q_001110211*R_114[0]+-1*Q_101010011*R_202[0]+Q_101010111*R_203[0]+-1*Q_101010211*R_204[0]+Q_101110011*R_212[0]+-1*Q_101110111*R_213[0]+Q_101110211*R_214[0]; double QR_000011011102=Q_000011011*R_102[0]+-1*Q_000011111*R_103[0]+Q_000011211*R_104[0]+-1*Q_000111011*R_112[0]+Q_000111111*R_113[0]+-1*Q_000111211*R_114[0]+Q_000211011*R_122[0]+-1*Q_000211111*R_123[0]+Q_000211211*R_124[0]; double QR_000010012102=Q_000010012*R_102[0]+-1*Q_000010112*R_103[0]+Q_000010212*R_104[0]+-1*Q_000010312*R_105[0]+-1*Q_000110012*R_112[0]+Q_000110112*R_113[0]+-1*Q_000110212*R_114[0]+Q_000110312*R_115[0]; double QR_002000020102=Q_002000020*R_102[0]+-1*Q_002000120*R_103[0]+Q_002000220*R_104[0]+-1*Q_102000020*R_202[0]+Q_102000120*R_203[0]+-1*Q_102000220*R_204[0]+Q_202000020*R_302[0]+-1*Q_202000120*R_303[0]+Q_202000220*R_304[0]; double QR_001001020102=Q_001001020*R_102[0]+-1*Q_001001120*R_103[0]+Q_001001220*R_104[0]+-1*Q_001101020*R_112[0]+Q_001101120*R_113[0]+-1*Q_001101220*R_114[0]+-1*Q_101001020*R_202[0]+Q_101001120*R_203[0]+-1*Q_101001220*R_204[0]+Q_101101020*R_212[0]+-1*Q_101101120*R_213[0]+Q_101101220*R_214[0]; double QR_000002020102=Q_000002020*R_102[0]+-1*Q_000002120*R_103[0]+Q_000002220*R_104[0]+-1*Q_000102020*R_112[0]+Q_000102120*R_113[0]+-1*Q_000102220*R_114[0]+Q_000202020*R_122[0]+-1*Q_000202120*R_123[0]+Q_000202220*R_124[0]; double QR_001000021102=Q_001000021*R_102[0]+-1*Q_001000121*R_103[0]+Q_001000221*R_104[0]+-1*Q_001000321*R_105[0]+-1*Q_101000021*R_202[0]+Q_101000121*R_203[0]+-1*Q_101000221*R_204[0]+Q_101000321*R_205[0]; double QR_000001021102=Q_000001021*R_102[0]+-1*Q_000001121*R_103[0]+Q_000001221*R_104[0]+-1*Q_000001321*R_105[0]+-1*Q_000101021*R_112[0]+Q_000101121*R_113[0]+-1*Q_000101221*R_114[0]+Q_000101321*R_115[0]; double QR_000000022102=Q_000000022*R_102[0]+-1*Q_000000122*R_103[0]+Q_000000222*R_104[0]+-1*Q_000000322*R_105[0]+Q_000000422*R_106[0]; double QR_022000000111=Q_022000000*R_111[0]+-1*Q_122000000*R_211[0]+Q_222000000*R_311[0]+-1*Q_322000000*R_411[0]+Q_422000000*R_511[0]; double QR_021001000111=Q_021001000*R_111[0]+-1*Q_021101000*R_121[0]+-1*Q_121001000*R_211[0]+Q_121101000*R_221[0]+Q_221001000*R_311[0]+-1*Q_221101000*R_321[0]+-1*Q_321001000*R_411[0]+Q_321101000*R_421[0]; double QR_020002000111=Q_020002000*R_111[0]+-1*Q_020102000*R_121[0]+Q_020202000*R_131[0]+-1*Q_120002000*R_211[0]+Q_120102000*R_221[0]+-1*Q_120202000*R_231[0]+Q_220002000*R_311[0]+-1*Q_220102000*R_321[0]+Q_220202000*R_331[0]; double QR_021000001111=Q_021000001*R_111[0]+-1*Q_021000101*R_112[0]+-1*Q_121000001*R_211[0]+Q_121000101*R_212[0]+Q_221000001*R_311[0]+-1*Q_221000101*R_312[0]+-1*Q_321000001*R_411[0]+Q_321000101*R_412[0]; double QR_020001001111=Q_020001001*R_111[0]+-1*Q_020001101*R_112[0]+-1*Q_020101001*R_121[0]+Q_020101101*R_122[0]+-1*Q_120001001*R_211[0]+Q_120001101*R_212[0]+Q_120101001*R_221[0]+-1*Q_120101101*R_222[0]+Q_220001001*R_311[0]+-1*Q_220001101*R_312[0]+-1*Q_220101001*R_321[0]+Q_220101101*R_322[0]; double QR_020000002111=Q_020000002*R_111[0]+-1*Q_020000102*R_112[0]+Q_020000202*R_113[0]+-1*Q_120000002*R_211[0]+Q_120000102*R_212[0]+-1*Q_120000202*R_213[0]+Q_220000002*R_311[0]+-1*Q_220000102*R_312[0]+Q_220000202*R_313[0]; double QR_012010000111=Q_012010000*R_111[0]+-1*Q_012110000*R_121[0]+-1*Q_112010000*R_211[0]+Q_112110000*R_221[0]+Q_212010000*R_311[0]+-1*Q_212110000*R_321[0]+-1*Q_312010000*R_411[0]+Q_312110000*R_421[0]; double QR_011011000111=Q_011011000*R_111[0]+-1*Q_011111000*R_121[0]+Q_011211000*R_131[0]+-1*Q_111011000*R_211[0]+Q_111111000*R_221[0]+-1*Q_111211000*R_231[0]+Q_211011000*R_311[0]+-1*Q_211111000*R_321[0]+Q_211211000*R_331[0]; double QR_010012000111=Q_010012000*R_111[0]+-1*Q_010112000*R_121[0]+Q_010212000*R_131[0]+-1*Q_010312000*R_141[0]+-1*Q_110012000*R_211[0]+Q_110112000*R_221[0]+-1*Q_110212000*R_231[0]+Q_110312000*R_241[0]; double QR_011010001111=Q_011010001*R_111[0]+-1*Q_011010101*R_112[0]+-1*Q_011110001*R_121[0]+Q_011110101*R_122[0]+-1*Q_111010001*R_211[0]+Q_111010101*R_212[0]+Q_111110001*R_221[0]+-1*Q_111110101*R_222[0]+Q_211010001*R_311[0]+-1*Q_211010101*R_312[0]+-1*Q_211110001*R_321[0]+Q_211110101*R_322[0]; double QR_010011001111=Q_010011001*R_111[0]+-1*Q_010011101*R_112[0]+-1*Q_010111001*R_121[0]+Q_010111101*R_122[0]+Q_010211001*R_131[0]+-1*Q_010211101*R_132[0]+-1*Q_110011001*R_211[0]+Q_110011101*R_212[0]+Q_110111001*R_221[0]+-1*Q_110111101*R_222[0]+-1*Q_110211001*R_231[0]+Q_110211101*R_232[0]; double QR_010010002111=Q_010010002*R_111[0]+-1*Q_010010102*R_112[0]+Q_010010202*R_113[0]+-1*Q_010110002*R_121[0]+Q_010110102*R_122[0]+-1*Q_010110202*R_123[0]+-1*Q_110010002*R_211[0]+Q_110010102*R_212[0]+-1*Q_110010202*R_213[0]+Q_110110002*R_221[0]+-1*Q_110110102*R_222[0]+Q_110110202*R_223[0]; double QR_002020000111=Q_002020000*R_111[0]+-1*Q_002120000*R_121[0]+Q_002220000*R_131[0]+-1*Q_102020000*R_211[0]+Q_102120000*R_221[0]+-1*Q_102220000*R_231[0]+Q_202020000*R_311[0]+-1*Q_202120000*R_321[0]+Q_202220000*R_331[0]; double QR_001021000111=Q_001021000*R_111[0]+-1*Q_001121000*R_121[0]+Q_001221000*R_131[0]+-1*Q_001321000*R_141[0]+-1*Q_101021000*R_211[0]+Q_101121000*R_221[0]+-1*Q_101221000*R_231[0]+Q_101321000*R_241[0]; double QR_000022000111=Q_000022000*R_111[0]+-1*Q_000122000*R_121[0]+Q_000222000*R_131[0]+-1*Q_000322000*R_141[0]+Q_000422000*R_151[0]; double QR_001020001111=Q_001020001*R_111[0]+-1*Q_001020101*R_112[0]+-1*Q_001120001*R_121[0]+Q_001120101*R_122[0]+Q_001220001*R_131[0]+-1*Q_001220101*R_132[0]+-1*Q_101020001*R_211[0]+Q_101020101*R_212[0]+Q_101120001*R_221[0]+-1*Q_101120101*R_222[0]+-1*Q_101220001*R_231[0]+Q_101220101*R_232[0]; double QR_000021001111=Q_000021001*R_111[0]+-1*Q_000021101*R_112[0]+-1*Q_000121001*R_121[0]+Q_000121101*R_122[0]+Q_000221001*R_131[0]+-1*Q_000221101*R_132[0]+-1*Q_000321001*R_141[0]+Q_000321101*R_142[0]; double QR_000020002111=Q_000020002*R_111[0]+-1*Q_000020102*R_112[0]+Q_000020202*R_113[0]+-1*Q_000120002*R_121[0]+Q_000120102*R_122[0]+-1*Q_000120202*R_123[0]+Q_000220002*R_131[0]+-1*Q_000220102*R_132[0]+Q_000220202*R_133[0]; double QR_012000010111=Q_012000010*R_111[0]+-1*Q_012000110*R_112[0]+-1*Q_112000010*R_211[0]+Q_112000110*R_212[0]+Q_212000010*R_311[0]+-1*Q_212000110*R_312[0]+-1*Q_312000010*R_411[0]+Q_312000110*R_412[0]; double QR_011001010111=Q_011001010*R_111[0]+-1*Q_011001110*R_112[0]+-1*Q_011101010*R_121[0]+Q_011101110*R_122[0]+-1*Q_111001010*R_211[0]+Q_111001110*R_212[0]+Q_111101010*R_221[0]+-1*Q_111101110*R_222[0]+Q_211001010*R_311[0]+-1*Q_211001110*R_312[0]+-1*Q_211101010*R_321[0]+Q_211101110*R_322[0]; double QR_010002010111=Q_010002010*R_111[0]+-1*Q_010002110*R_112[0]+-1*Q_010102010*R_121[0]+Q_010102110*R_122[0]+Q_010202010*R_131[0]+-1*Q_010202110*R_132[0]+-1*Q_110002010*R_211[0]+Q_110002110*R_212[0]+Q_110102010*R_221[0]+-1*Q_110102110*R_222[0]+-1*Q_110202010*R_231[0]+Q_110202110*R_232[0]; double QR_011000011111=Q_011000011*R_111[0]+-1*Q_011000111*R_112[0]+Q_011000211*R_113[0]+-1*Q_111000011*R_211[0]+Q_111000111*R_212[0]+-1*Q_111000211*R_213[0]+Q_211000011*R_311[0]+-1*Q_211000111*R_312[0]+Q_211000211*R_313[0]; double QR_010001011111=Q_010001011*R_111[0]+-1*Q_010001111*R_112[0]+Q_010001211*R_113[0]+-1*Q_010101011*R_121[0]+Q_010101111*R_122[0]+-1*Q_010101211*R_123[0]+-1*Q_110001011*R_211[0]+Q_110001111*R_212[0]+-1*Q_110001211*R_213[0]+Q_110101011*R_221[0]+-1*Q_110101111*R_222[0]+Q_110101211*R_223[0]; double QR_010000012111=Q_010000012*R_111[0]+-1*Q_010000112*R_112[0]+Q_010000212*R_113[0]+-1*Q_010000312*R_114[0]+-1*Q_110000012*R_211[0]+Q_110000112*R_212[0]+-1*Q_110000212*R_213[0]+Q_110000312*R_214[0]; double QR_002010010111=Q_002010010*R_111[0]+-1*Q_002010110*R_112[0]+-1*Q_002110010*R_121[0]+Q_002110110*R_122[0]+-1*Q_102010010*R_211[0]+Q_102010110*R_212[0]+Q_102110010*R_221[0]+-1*Q_102110110*R_222[0]+Q_202010010*R_311[0]+-1*Q_202010110*R_312[0]+-1*Q_202110010*R_321[0]+Q_202110110*R_322[0]; double QR_001011010111=Q_001011010*R_111[0]+-1*Q_001011110*R_112[0]+-1*Q_001111010*R_121[0]+Q_001111110*R_122[0]+Q_001211010*R_131[0]+-1*Q_001211110*R_132[0]+-1*Q_101011010*R_211[0]+Q_101011110*R_212[0]+Q_101111010*R_221[0]+-1*Q_101111110*R_222[0]+-1*Q_101211010*R_231[0]+Q_101211110*R_232[0]; double QR_000012010111=Q_000012010*R_111[0]+-1*Q_000012110*R_112[0]+-1*Q_000112010*R_121[0]+Q_000112110*R_122[0]+Q_000212010*R_131[0]+-1*Q_000212110*R_132[0]+-1*Q_000312010*R_141[0]+Q_000312110*R_142[0]; double QR_001010011111=Q_001010011*R_111[0]+-1*Q_001010111*R_112[0]+Q_001010211*R_113[0]+-1*Q_001110011*R_121[0]+Q_001110111*R_122[0]+-1*Q_001110211*R_123[0]+-1*Q_101010011*R_211[0]+Q_101010111*R_212[0]+-1*Q_101010211*R_213[0]+Q_101110011*R_221[0]+-1*Q_101110111*R_222[0]+Q_101110211*R_223[0]; double QR_000011011111=Q_000011011*R_111[0]+-1*Q_000011111*R_112[0]+Q_000011211*R_113[0]+-1*Q_000111011*R_121[0]+Q_000111111*R_122[0]+-1*Q_000111211*R_123[0]+Q_000211011*R_131[0]+-1*Q_000211111*R_132[0]+Q_000211211*R_133[0]; double QR_000010012111=Q_000010012*R_111[0]+-1*Q_000010112*R_112[0]+Q_000010212*R_113[0]+-1*Q_000010312*R_114[0]+-1*Q_000110012*R_121[0]+Q_000110112*R_122[0]+-1*Q_000110212*R_123[0]+Q_000110312*R_124[0]; double QR_002000020111=Q_002000020*R_111[0]+-1*Q_002000120*R_112[0]+Q_002000220*R_113[0]+-1*Q_102000020*R_211[0]+Q_102000120*R_212[0]+-1*Q_102000220*R_213[0]+Q_202000020*R_311[0]+-1*Q_202000120*R_312[0]+Q_202000220*R_313[0]; double QR_001001020111=Q_001001020*R_111[0]+-1*Q_001001120*R_112[0]+Q_001001220*R_113[0]+-1*Q_001101020*R_121[0]+Q_001101120*R_122[0]+-1*Q_001101220*R_123[0]+-1*Q_101001020*R_211[0]+Q_101001120*R_212[0]+-1*Q_101001220*R_213[0]+Q_101101020*R_221[0]+-1*Q_101101120*R_222[0]+Q_101101220*R_223[0]; double QR_000002020111=Q_000002020*R_111[0]+-1*Q_000002120*R_112[0]+Q_000002220*R_113[0]+-1*Q_000102020*R_121[0]+Q_000102120*R_122[0]+-1*Q_000102220*R_123[0]+Q_000202020*R_131[0]+-1*Q_000202120*R_132[0]+Q_000202220*R_133[0]; double QR_001000021111=Q_001000021*R_111[0]+-1*Q_001000121*R_112[0]+Q_001000221*R_113[0]+-1*Q_001000321*R_114[0]+-1*Q_101000021*R_211[0]+Q_101000121*R_212[0]+-1*Q_101000221*R_213[0]+Q_101000321*R_214[0]; double QR_000001021111=Q_000001021*R_111[0]+-1*Q_000001121*R_112[0]+Q_000001221*R_113[0]+-1*Q_000001321*R_114[0]+-1*Q_000101021*R_121[0]+Q_000101121*R_122[0]+-1*Q_000101221*R_123[0]+Q_000101321*R_124[0]; double QR_000000022111=Q_000000022*R_111[0]+-1*Q_000000122*R_112[0]+Q_000000222*R_113[0]+-1*Q_000000322*R_114[0]+Q_000000422*R_115[0]; double QR_022000000120=Q_022000000*R_120[0]+-1*Q_122000000*R_220[0]+Q_222000000*R_320[0]+-1*Q_322000000*R_420[0]+Q_422000000*R_520[0]; double QR_021001000120=Q_021001000*R_120[0]+-1*Q_021101000*R_130[0]+-1*Q_121001000*R_220[0]+Q_121101000*R_230[0]+Q_221001000*R_320[0]+-1*Q_221101000*R_330[0]+-1*Q_321001000*R_420[0]+Q_321101000*R_430[0]; double QR_020002000120=Q_020002000*R_120[0]+-1*Q_020102000*R_130[0]+Q_020202000*R_140[0]+-1*Q_120002000*R_220[0]+Q_120102000*R_230[0]+-1*Q_120202000*R_240[0]+Q_220002000*R_320[0]+-1*Q_220102000*R_330[0]+Q_220202000*R_340[0]; double QR_021000001120=Q_021000001*R_120[0]+-1*Q_021000101*R_121[0]+-1*Q_121000001*R_220[0]+Q_121000101*R_221[0]+Q_221000001*R_320[0]+-1*Q_221000101*R_321[0]+-1*Q_321000001*R_420[0]+Q_321000101*R_421[0]; double QR_020001001120=Q_020001001*R_120[0]+-1*Q_020001101*R_121[0]+-1*Q_020101001*R_130[0]+Q_020101101*R_131[0]+-1*Q_120001001*R_220[0]+Q_120001101*R_221[0]+Q_120101001*R_230[0]+-1*Q_120101101*R_231[0]+Q_220001001*R_320[0]+-1*Q_220001101*R_321[0]+-1*Q_220101001*R_330[0]+Q_220101101*R_331[0]; double QR_020000002120=Q_020000002*R_120[0]+-1*Q_020000102*R_121[0]+Q_020000202*R_122[0]+-1*Q_120000002*R_220[0]+Q_120000102*R_221[0]+-1*Q_120000202*R_222[0]+Q_220000002*R_320[0]+-1*Q_220000102*R_321[0]+Q_220000202*R_322[0]; double QR_012010000120=Q_012010000*R_120[0]+-1*Q_012110000*R_130[0]+-1*Q_112010000*R_220[0]+Q_112110000*R_230[0]+Q_212010000*R_320[0]+-1*Q_212110000*R_330[0]+-1*Q_312010000*R_420[0]+Q_312110000*R_430[0]; double QR_011011000120=Q_011011000*R_120[0]+-1*Q_011111000*R_130[0]+Q_011211000*R_140[0]+-1*Q_111011000*R_220[0]+Q_111111000*R_230[0]+-1*Q_111211000*R_240[0]+Q_211011000*R_320[0]+-1*Q_211111000*R_330[0]+Q_211211000*R_340[0]; double QR_010012000120=Q_010012000*R_120[0]+-1*Q_010112000*R_130[0]+Q_010212000*R_140[0]+-1*Q_010312000*R_150[0]+-1*Q_110012000*R_220[0]+Q_110112000*R_230[0]+-1*Q_110212000*R_240[0]+Q_110312000*R_250[0]; double QR_011010001120=Q_011010001*R_120[0]+-1*Q_011010101*R_121[0]+-1*Q_011110001*R_130[0]+Q_011110101*R_131[0]+-1*Q_111010001*R_220[0]+Q_111010101*R_221[0]+Q_111110001*R_230[0]+-1*Q_111110101*R_231[0]+Q_211010001*R_320[0]+-1*Q_211010101*R_321[0]+-1*Q_211110001*R_330[0]+Q_211110101*R_331[0]; double QR_010011001120=Q_010011001*R_120[0]+-1*Q_010011101*R_121[0]+-1*Q_010111001*R_130[0]+Q_010111101*R_131[0]+Q_010211001*R_140[0]+-1*Q_010211101*R_141[0]+-1*Q_110011001*R_220[0]+Q_110011101*R_221[0]+Q_110111001*R_230[0]+-1*Q_110111101*R_231[0]+-1*Q_110211001*R_240[0]+Q_110211101*R_241[0]; double QR_010010002120=Q_010010002*R_120[0]+-1*Q_010010102*R_121[0]+Q_010010202*R_122[0]+-1*Q_010110002*R_130[0]+Q_010110102*R_131[0]+-1*Q_010110202*R_132[0]+-1*Q_110010002*R_220[0]+Q_110010102*R_221[0]+-1*Q_110010202*R_222[0]+Q_110110002*R_230[0]+-1*Q_110110102*R_231[0]+Q_110110202*R_232[0]; double QR_002020000120=Q_002020000*R_120[0]+-1*Q_002120000*R_130[0]+Q_002220000*R_140[0]+-1*Q_102020000*R_220[0]+Q_102120000*R_230[0]+-1*Q_102220000*R_240[0]+Q_202020000*R_320[0]+-1*Q_202120000*R_330[0]+Q_202220000*R_340[0]; double QR_001021000120=Q_001021000*R_120[0]+-1*Q_001121000*R_130[0]+Q_001221000*R_140[0]+-1*Q_001321000*R_150[0]+-1*Q_101021000*R_220[0]+Q_101121000*R_230[0]+-1*Q_101221000*R_240[0]+Q_101321000*R_250[0]; double QR_000022000120=Q_000022000*R_120[0]+-1*Q_000122000*R_130[0]+Q_000222000*R_140[0]+-1*Q_000322000*R_150[0]+Q_000422000*R_160[0]; double QR_001020001120=Q_001020001*R_120[0]+-1*Q_001020101*R_121[0]+-1*Q_001120001*R_130[0]+Q_001120101*R_131[0]+Q_001220001*R_140[0]+-1*Q_001220101*R_141[0]+-1*Q_101020001*R_220[0]+Q_101020101*R_221[0]+Q_101120001*R_230[0]+-1*Q_101120101*R_231[0]+-1*Q_101220001*R_240[0]+Q_101220101*R_241[0]; double QR_000021001120=Q_000021001*R_120[0]+-1*Q_000021101*R_121[0]+-1*Q_000121001*R_130[0]+Q_000121101*R_131[0]+Q_000221001*R_140[0]+-1*Q_000221101*R_141[0]+-1*Q_000321001*R_150[0]+Q_000321101*R_151[0]; double QR_000020002120=Q_000020002*R_120[0]+-1*Q_000020102*R_121[0]+Q_000020202*R_122[0]+-1*Q_000120002*R_130[0]+Q_000120102*R_131[0]+-1*Q_000120202*R_132[0]+Q_000220002*R_140[0]+-1*Q_000220102*R_141[0]+Q_000220202*R_142[0]; double QR_012000010120=Q_012000010*R_120[0]+-1*Q_012000110*R_121[0]+-1*Q_112000010*R_220[0]+Q_112000110*R_221[0]+Q_212000010*R_320[0]+-1*Q_212000110*R_321[0]+-1*Q_312000010*R_420[0]+Q_312000110*R_421[0]; double QR_011001010120=Q_011001010*R_120[0]+-1*Q_011001110*R_121[0]+-1*Q_011101010*R_130[0]+Q_011101110*R_131[0]+-1*Q_111001010*R_220[0]+Q_111001110*R_221[0]+Q_111101010*R_230[0]+-1*Q_111101110*R_231[0]+Q_211001010*R_320[0]+-1*Q_211001110*R_321[0]+-1*Q_211101010*R_330[0]+Q_211101110*R_331[0]; double QR_010002010120=Q_010002010*R_120[0]+-1*Q_010002110*R_121[0]+-1*Q_010102010*R_130[0]+Q_010102110*R_131[0]+Q_010202010*R_140[0]+-1*Q_010202110*R_141[0]+-1*Q_110002010*R_220[0]+Q_110002110*R_221[0]+Q_110102010*R_230[0]+-1*Q_110102110*R_231[0]+-1*Q_110202010*R_240[0]+Q_110202110*R_241[0]; double QR_011000011120=Q_011000011*R_120[0]+-1*Q_011000111*R_121[0]+Q_011000211*R_122[0]+-1*Q_111000011*R_220[0]+Q_111000111*R_221[0]+-1*Q_111000211*R_222[0]+Q_211000011*R_320[0]+-1*Q_211000111*R_321[0]+Q_211000211*R_322[0]; double QR_010001011120=Q_010001011*R_120[0]+-1*Q_010001111*R_121[0]+Q_010001211*R_122[0]+-1*Q_010101011*R_130[0]+Q_010101111*R_131[0]+-1*Q_010101211*R_132[0]+-1*Q_110001011*R_220[0]+Q_110001111*R_221[0]+-1*Q_110001211*R_222[0]+Q_110101011*R_230[0]+-1*Q_110101111*R_231[0]+Q_110101211*R_232[0]; double QR_010000012120=Q_010000012*R_120[0]+-1*Q_010000112*R_121[0]+Q_010000212*R_122[0]+-1*Q_010000312*R_123[0]+-1*Q_110000012*R_220[0]+Q_110000112*R_221[0]+-1*Q_110000212*R_222[0]+Q_110000312*R_223[0]; double QR_002010010120=Q_002010010*R_120[0]+-1*Q_002010110*R_121[0]+-1*Q_002110010*R_130[0]+Q_002110110*R_131[0]+-1*Q_102010010*R_220[0]+Q_102010110*R_221[0]+Q_102110010*R_230[0]+-1*Q_102110110*R_231[0]+Q_202010010*R_320[0]+-1*Q_202010110*R_321[0]+-1*Q_202110010*R_330[0]+Q_202110110*R_331[0]; double QR_001011010120=Q_001011010*R_120[0]+-1*Q_001011110*R_121[0]+-1*Q_001111010*R_130[0]+Q_001111110*R_131[0]+Q_001211010*R_140[0]+-1*Q_001211110*R_141[0]+-1*Q_101011010*R_220[0]+Q_101011110*R_221[0]+Q_101111010*R_230[0]+-1*Q_101111110*R_231[0]+-1*Q_101211010*R_240[0]+Q_101211110*R_241[0]; double QR_000012010120=Q_000012010*R_120[0]+-1*Q_000012110*R_121[0]+-1*Q_000112010*R_130[0]+Q_000112110*R_131[0]+Q_000212010*R_140[0]+-1*Q_000212110*R_141[0]+-1*Q_000312010*R_150[0]+Q_000312110*R_151[0]; double QR_001010011120=Q_001010011*R_120[0]+-1*Q_001010111*R_121[0]+Q_001010211*R_122[0]+-1*Q_001110011*R_130[0]+Q_001110111*R_131[0]+-1*Q_001110211*R_132[0]+-1*Q_101010011*R_220[0]+Q_101010111*R_221[0]+-1*Q_101010211*R_222[0]+Q_101110011*R_230[0]+-1*Q_101110111*R_231[0]+Q_101110211*R_232[0]; double QR_000011011120=Q_000011011*R_120[0]+-1*Q_000011111*R_121[0]+Q_000011211*R_122[0]+-1*Q_000111011*R_130[0]+Q_000111111*R_131[0]+-1*Q_000111211*R_132[0]+Q_000211011*R_140[0]+-1*Q_000211111*R_141[0]+Q_000211211*R_142[0]; double QR_000010012120=Q_000010012*R_120[0]+-1*Q_000010112*R_121[0]+Q_000010212*R_122[0]+-1*Q_000010312*R_123[0]+-1*Q_000110012*R_130[0]+Q_000110112*R_131[0]+-1*Q_000110212*R_132[0]+Q_000110312*R_133[0]; double QR_002000020120=Q_002000020*R_120[0]+-1*Q_002000120*R_121[0]+Q_002000220*R_122[0]+-1*Q_102000020*R_220[0]+Q_102000120*R_221[0]+-1*Q_102000220*R_222[0]+Q_202000020*R_320[0]+-1*Q_202000120*R_321[0]+Q_202000220*R_322[0]; double QR_001001020120=Q_001001020*R_120[0]+-1*Q_001001120*R_121[0]+Q_001001220*R_122[0]+-1*Q_001101020*R_130[0]+Q_001101120*R_131[0]+-1*Q_001101220*R_132[0]+-1*Q_101001020*R_220[0]+Q_101001120*R_221[0]+-1*Q_101001220*R_222[0]+Q_101101020*R_230[0]+-1*Q_101101120*R_231[0]+Q_101101220*R_232[0]; double QR_000002020120=Q_000002020*R_120[0]+-1*Q_000002120*R_121[0]+Q_000002220*R_122[0]+-1*Q_000102020*R_130[0]+Q_000102120*R_131[0]+-1*Q_000102220*R_132[0]+Q_000202020*R_140[0]+-1*Q_000202120*R_141[0]+Q_000202220*R_142[0]; double QR_001000021120=Q_001000021*R_120[0]+-1*Q_001000121*R_121[0]+Q_001000221*R_122[0]+-1*Q_001000321*R_123[0]+-1*Q_101000021*R_220[0]+Q_101000121*R_221[0]+-1*Q_101000221*R_222[0]+Q_101000321*R_223[0]; double QR_000001021120=Q_000001021*R_120[0]+-1*Q_000001121*R_121[0]+Q_000001221*R_122[0]+-1*Q_000001321*R_123[0]+-1*Q_000101021*R_130[0]+Q_000101121*R_131[0]+-1*Q_000101221*R_132[0]+Q_000101321*R_133[0]; double QR_000000022120=Q_000000022*R_120[0]+-1*Q_000000122*R_121[0]+Q_000000222*R_122[0]+-1*Q_000000322*R_123[0]+Q_000000422*R_124[0]; double QR_022000000201=Q_022000000*R_201[0]+-1*Q_122000000*R_301[0]+Q_222000000*R_401[0]+-1*Q_322000000*R_501[0]+Q_422000000*R_601[0]; double QR_021001000201=Q_021001000*R_201[0]+-1*Q_021101000*R_211[0]+-1*Q_121001000*R_301[0]+Q_121101000*R_311[0]+Q_221001000*R_401[0]+-1*Q_221101000*R_411[0]+-1*Q_321001000*R_501[0]+Q_321101000*R_511[0]; double QR_020002000201=Q_020002000*R_201[0]+-1*Q_020102000*R_211[0]+Q_020202000*R_221[0]+-1*Q_120002000*R_301[0]+Q_120102000*R_311[0]+-1*Q_120202000*R_321[0]+Q_220002000*R_401[0]+-1*Q_220102000*R_411[0]+Q_220202000*R_421[0]; double QR_021000001201=Q_021000001*R_201[0]+-1*Q_021000101*R_202[0]+-1*Q_121000001*R_301[0]+Q_121000101*R_302[0]+Q_221000001*R_401[0]+-1*Q_221000101*R_402[0]+-1*Q_321000001*R_501[0]+Q_321000101*R_502[0]; double QR_020001001201=Q_020001001*R_201[0]+-1*Q_020001101*R_202[0]+-1*Q_020101001*R_211[0]+Q_020101101*R_212[0]+-1*Q_120001001*R_301[0]+Q_120001101*R_302[0]+Q_120101001*R_311[0]+-1*Q_120101101*R_312[0]+Q_220001001*R_401[0]+-1*Q_220001101*R_402[0]+-1*Q_220101001*R_411[0]+Q_220101101*R_412[0]; double QR_020000002201=Q_020000002*R_201[0]+-1*Q_020000102*R_202[0]+Q_020000202*R_203[0]+-1*Q_120000002*R_301[0]+Q_120000102*R_302[0]+-1*Q_120000202*R_303[0]+Q_220000002*R_401[0]+-1*Q_220000102*R_402[0]+Q_220000202*R_403[0]; double QR_012010000201=Q_012010000*R_201[0]+-1*Q_012110000*R_211[0]+-1*Q_112010000*R_301[0]+Q_112110000*R_311[0]+Q_212010000*R_401[0]+-1*Q_212110000*R_411[0]+-1*Q_312010000*R_501[0]+Q_312110000*R_511[0]; double QR_011011000201=Q_011011000*R_201[0]+-1*Q_011111000*R_211[0]+Q_011211000*R_221[0]+-1*Q_111011000*R_301[0]+Q_111111000*R_311[0]+-1*Q_111211000*R_321[0]+Q_211011000*R_401[0]+-1*Q_211111000*R_411[0]+Q_211211000*R_421[0]; double QR_010012000201=Q_010012000*R_201[0]+-1*Q_010112000*R_211[0]+Q_010212000*R_221[0]+-1*Q_010312000*R_231[0]+-1*Q_110012000*R_301[0]+Q_110112000*R_311[0]+-1*Q_110212000*R_321[0]+Q_110312000*R_331[0]; double QR_011010001201=Q_011010001*R_201[0]+-1*Q_011010101*R_202[0]+-1*Q_011110001*R_211[0]+Q_011110101*R_212[0]+-1*Q_111010001*R_301[0]+Q_111010101*R_302[0]+Q_111110001*R_311[0]+-1*Q_111110101*R_312[0]+Q_211010001*R_401[0]+-1*Q_211010101*R_402[0]+-1*Q_211110001*R_411[0]+Q_211110101*R_412[0]; double QR_010011001201=Q_010011001*R_201[0]+-1*Q_010011101*R_202[0]+-1*Q_010111001*R_211[0]+Q_010111101*R_212[0]+Q_010211001*R_221[0]+-1*Q_010211101*R_222[0]+-1*Q_110011001*R_301[0]+Q_110011101*R_302[0]+Q_110111001*R_311[0]+-1*Q_110111101*R_312[0]+-1*Q_110211001*R_321[0]+Q_110211101*R_322[0]; double QR_010010002201=Q_010010002*R_201[0]+-1*Q_010010102*R_202[0]+Q_010010202*R_203[0]+-1*Q_010110002*R_211[0]+Q_010110102*R_212[0]+-1*Q_010110202*R_213[0]+-1*Q_110010002*R_301[0]+Q_110010102*R_302[0]+-1*Q_110010202*R_303[0]+Q_110110002*R_311[0]+-1*Q_110110102*R_312[0]+Q_110110202*R_313[0]; double QR_002020000201=Q_002020000*R_201[0]+-1*Q_002120000*R_211[0]+Q_002220000*R_221[0]+-1*Q_102020000*R_301[0]+Q_102120000*R_311[0]+-1*Q_102220000*R_321[0]+Q_202020000*R_401[0]+-1*Q_202120000*R_411[0]+Q_202220000*R_421[0]; double QR_001021000201=Q_001021000*R_201[0]+-1*Q_001121000*R_211[0]+Q_001221000*R_221[0]+-1*Q_001321000*R_231[0]+-1*Q_101021000*R_301[0]+Q_101121000*R_311[0]+-1*Q_101221000*R_321[0]+Q_101321000*R_331[0]; double QR_000022000201=Q_000022000*R_201[0]+-1*Q_000122000*R_211[0]+Q_000222000*R_221[0]+-1*Q_000322000*R_231[0]+Q_000422000*R_241[0]; double QR_001020001201=Q_001020001*R_201[0]+-1*Q_001020101*R_202[0]+-1*Q_001120001*R_211[0]+Q_001120101*R_212[0]+Q_001220001*R_221[0]+-1*Q_001220101*R_222[0]+-1*Q_101020001*R_301[0]+Q_101020101*R_302[0]+Q_101120001*R_311[0]+-1*Q_101120101*R_312[0]+-1*Q_101220001*R_321[0]+Q_101220101*R_322[0]; double QR_000021001201=Q_000021001*R_201[0]+-1*Q_000021101*R_202[0]+-1*Q_000121001*R_211[0]+Q_000121101*R_212[0]+Q_000221001*R_221[0]+-1*Q_000221101*R_222[0]+-1*Q_000321001*R_231[0]+Q_000321101*R_232[0]; double QR_000020002201=Q_000020002*R_201[0]+-1*Q_000020102*R_202[0]+Q_000020202*R_203[0]+-1*Q_000120002*R_211[0]+Q_000120102*R_212[0]+-1*Q_000120202*R_213[0]+Q_000220002*R_221[0]+-1*Q_000220102*R_222[0]+Q_000220202*R_223[0]; double QR_012000010201=Q_012000010*R_201[0]+-1*Q_012000110*R_202[0]+-1*Q_112000010*R_301[0]+Q_112000110*R_302[0]+Q_212000010*R_401[0]+-1*Q_212000110*R_402[0]+-1*Q_312000010*R_501[0]+Q_312000110*R_502[0]; double QR_011001010201=Q_011001010*R_201[0]+-1*Q_011001110*R_202[0]+-1*Q_011101010*R_211[0]+Q_011101110*R_212[0]+-1*Q_111001010*R_301[0]+Q_111001110*R_302[0]+Q_111101010*R_311[0]+-1*Q_111101110*R_312[0]+Q_211001010*R_401[0]+-1*Q_211001110*R_402[0]+-1*Q_211101010*R_411[0]+Q_211101110*R_412[0]; double QR_010002010201=Q_010002010*R_201[0]+-1*Q_010002110*R_202[0]+-1*Q_010102010*R_211[0]+Q_010102110*R_212[0]+Q_010202010*R_221[0]+-1*Q_010202110*R_222[0]+-1*Q_110002010*R_301[0]+Q_110002110*R_302[0]+Q_110102010*R_311[0]+-1*Q_110102110*R_312[0]+-1*Q_110202010*R_321[0]+Q_110202110*R_322[0]; double QR_011000011201=Q_011000011*R_201[0]+-1*Q_011000111*R_202[0]+Q_011000211*R_203[0]+-1*Q_111000011*R_301[0]+Q_111000111*R_302[0]+-1*Q_111000211*R_303[0]+Q_211000011*R_401[0]+-1*Q_211000111*R_402[0]+Q_211000211*R_403[0]; double QR_010001011201=Q_010001011*R_201[0]+-1*Q_010001111*R_202[0]+Q_010001211*R_203[0]+-1*Q_010101011*R_211[0]+Q_010101111*R_212[0]+-1*Q_010101211*R_213[0]+-1*Q_110001011*R_301[0]+Q_110001111*R_302[0]+-1*Q_110001211*R_303[0]+Q_110101011*R_311[0]+-1*Q_110101111*R_312[0]+Q_110101211*R_313[0]; double QR_010000012201=Q_010000012*R_201[0]+-1*Q_010000112*R_202[0]+Q_010000212*R_203[0]+-1*Q_010000312*R_204[0]+-1*Q_110000012*R_301[0]+Q_110000112*R_302[0]+-1*Q_110000212*R_303[0]+Q_110000312*R_304[0]; double QR_002010010201=Q_002010010*R_201[0]+-1*Q_002010110*R_202[0]+-1*Q_002110010*R_211[0]+Q_002110110*R_212[0]+-1*Q_102010010*R_301[0]+Q_102010110*R_302[0]+Q_102110010*R_311[0]+-1*Q_102110110*R_312[0]+Q_202010010*R_401[0]+-1*Q_202010110*R_402[0]+-1*Q_202110010*R_411[0]+Q_202110110*R_412[0]; double QR_001011010201=Q_001011010*R_201[0]+-1*Q_001011110*R_202[0]+-1*Q_001111010*R_211[0]+Q_001111110*R_212[0]+Q_001211010*R_221[0]+-1*Q_001211110*R_222[0]+-1*Q_101011010*R_301[0]+Q_101011110*R_302[0]+Q_101111010*R_311[0]+-1*Q_101111110*R_312[0]+-1*Q_101211010*R_321[0]+Q_101211110*R_322[0]; double QR_000012010201=Q_000012010*R_201[0]+-1*Q_000012110*R_202[0]+-1*Q_000112010*R_211[0]+Q_000112110*R_212[0]+Q_000212010*R_221[0]+-1*Q_000212110*R_222[0]+-1*Q_000312010*R_231[0]+Q_000312110*R_232[0]; double QR_001010011201=Q_001010011*R_201[0]+-1*Q_001010111*R_202[0]+Q_001010211*R_203[0]+-1*Q_001110011*R_211[0]+Q_001110111*R_212[0]+-1*Q_001110211*R_213[0]+-1*Q_101010011*R_301[0]+Q_101010111*R_302[0]+-1*Q_101010211*R_303[0]+Q_101110011*R_311[0]+-1*Q_101110111*R_312[0]+Q_101110211*R_313[0]; double QR_000011011201=Q_000011011*R_201[0]+-1*Q_000011111*R_202[0]+Q_000011211*R_203[0]+-1*Q_000111011*R_211[0]+Q_000111111*R_212[0]+-1*Q_000111211*R_213[0]+Q_000211011*R_221[0]+-1*Q_000211111*R_222[0]+Q_000211211*R_223[0]; double QR_000010012201=Q_000010012*R_201[0]+-1*Q_000010112*R_202[0]+Q_000010212*R_203[0]+-1*Q_000010312*R_204[0]+-1*Q_000110012*R_211[0]+Q_000110112*R_212[0]+-1*Q_000110212*R_213[0]+Q_000110312*R_214[0]; double QR_002000020201=Q_002000020*R_201[0]+-1*Q_002000120*R_202[0]+Q_002000220*R_203[0]+-1*Q_102000020*R_301[0]+Q_102000120*R_302[0]+-1*Q_102000220*R_303[0]+Q_202000020*R_401[0]+-1*Q_202000120*R_402[0]+Q_202000220*R_403[0]; double QR_001001020201=Q_001001020*R_201[0]+-1*Q_001001120*R_202[0]+Q_001001220*R_203[0]+-1*Q_001101020*R_211[0]+Q_001101120*R_212[0]+-1*Q_001101220*R_213[0]+-1*Q_101001020*R_301[0]+Q_101001120*R_302[0]+-1*Q_101001220*R_303[0]+Q_101101020*R_311[0]+-1*Q_101101120*R_312[0]+Q_101101220*R_313[0]; double QR_000002020201=Q_000002020*R_201[0]+-1*Q_000002120*R_202[0]+Q_000002220*R_203[0]+-1*Q_000102020*R_211[0]+Q_000102120*R_212[0]+-1*Q_000102220*R_213[0]+Q_000202020*R_221[0]+-1*Q_000202120*R_222[0]+Q_000202220*R_223[0]; double QR_001000021201=Q_001000021*R_201[0]+-1*Q_001000121*R_202[0]+Q_001000221*R_203[0]+-1*Q_001000321*R_204[0]+-1*Q_101000021*R_301[0]+Q_101000121*R_302[0]+-1*Q_101000221*R_303[0]+Q_101000321*R_304[0]; double QR_000001021201=Q_000001021*R_201[0]+-1*Q_000001121*R_202[0]+Q_000001221*R_203[0]+-1*Q_000001321*R_204[0]+-1*Q_000101021*R_211[0]+Q_000101121*R_212[0]+-1*Q_000101221*R_213[0]+Q_000101321*R_214[0]; double QR_000000022201=Q_000000022*R_201[0]+-1*Q_000000122*R_202[0]+Q_000000222*R_203[0]+-1*Q_000000322*R_204[0]+Q_000000422*R_205[0]; double QR_022000000210=Q_022000000*R_210[0]+-1*Q_122000000*R_310[0]+Q_222000000*R_410[0]+-1*Q_322000000*R_510[0]+Q_422000000*R_610[0]; double QR_021001000210=Q_021001000*R_210[0]+-1*Q_021101000*R_220[0]+-1*Q_121001000*R_310[0]+Q_121101000*R_320[0]+Q_221001000*R_410[0]+-1*Q_221101000*R_420[0]+-1*Q_321001000*R_510[0]+Q_321101000*R_520[0]; double QR_020002000210=Q_020002000*R_210[0]+-1*Q_020102000*R_220[0]+Q_020202000*R_230[0]+-1*Q_120002000*R_310[0]+Q_120102000*R_320[0]+-1*Q_120202000*R_330[0]+Q_220002000*R_410[0]+-1*Q_220102000*R_420[0]+Q_220202000*R_430[0]; double QR_021000001210=Q_021000001*R_210[0]+-1*Q_021000101*R_211[0]+-1*Q_121000001*R_310[0]+Q_121000101*R_311[0]+Q_221000001*R_410[0]+-1*Q_221000101*R_411[0]+-1*Q_321000001*R_510[0]+Q_321000101*R_511[0]; double QR_020001001210=Q_020001001*R_210[0]+-1*Q_020001101*R_211[0]+-1*Q_020101001*R_220[0]+Q_020101101*R_221[0]+-1*Q_120001001*R_310[0]+Q_120001101*R_311[0]+Q_120101001*R_320[0]+-1*Q_120101101*R_321[0]+Q_220001001*R_410[0]+-1*Q_220001101*R_411[0]+-1*Q_220101001*R_420[0]+Q_220101101*R_421[0]; double QR_020000002210=Q_020000002*R_210[0]+-1*Q_020000102*R_211[0]+Q_020000202*R_212[0]+-1*Q_120000002*R_310[0]+Q_120000102*R_311[0]+-1*Q_120000202*R_312[0]+Q_220000002*R_410[0]+-1*Q_220000102*R_411[0]+Q_220000202*R_412[0]; double QR_012010000210=Q_012010000*R_210[0]+-1*Q_012110000*R_220[0]+-1*Q_112010000*R_310[0]+Q_112110000*R_320[0]+Q_212010000*R_410[0]+-1*Q_212110000*R_420[0]+-1*Q_312010000*R_510[0]+Q_312110000*R_520[0]; double QR_011011000210=Q_011011000*R_210[0]+-1*Q_011111000*R_220[0]+Q_011211000*R_230[0]+-1*Q_111011000*R_310[0]+Q_111111000*R_320[0]+-1*Q_111211000*R_330[0]+Q_211011000*R_410[0]+-1*Q_211111000*R_420[0]+Q_211211000*R_430[0]; double QR_010012000210=Q_010012000*R_210[0]+-1*Q_010112000*R_220[0]+Q_010212000*R_230[0]+-1*Q_010312000*R_240[0]+-1*Q_110012000*R_310[0]+Q_110112000*R_320[0]+-1*Q_110212000*R_330[0]+Q_110312000*R_340[0]; double QR_011010001210=Q_011010001*R_210[0]+-1*Q_011010101*R_211[0]+-1*Q_011110001*R_220[0]+Q_011110101*R_221[0]+-1*Q_111010001*R_310[0]+Q_111010101*R_311[0]+Q_111110001*R_320[0]+-1*Q_111110101*R_321[0]+Q_211010001*R_410[0]+-1*Q_211010101*R_411[0]+-1*Q_211110001*R_420[0]+Q_211110101*R_421[0]; double QR_010011001210=Q_010011001*R_210[0]+-1*Q_010011101*R_211[0]+-1*Q_010111001*R_220[0]+Q_010111101*R_221[0]+Q_010211001*R_230[0]+-1*Q_010211101*R_231[0]+-1*Q_110011001*R_310[0]+Q_110011101*R_311[0]+Q_110111001*R_320[0]+-1*Q_110111101*R_321[0]+-1*Q_110211001*R_330[0]+Q_110211101*R_331[0]; double QR_010010002210=Q_010010002*R_210[0]+-1*Q_010010102*R_211[0]+Q_010010202*R_212[0]+-1*Q_010110002*R_220[0]+Q_010110102*R_221[0]+-1*Q_010110202*R_222[0]+-1*Q_110010002*R_310[0]+Q_110010102*R_311[0]+-1*Q_110010202*R_312[0]+Q_110110002*R_320[0]+-1*Q_110110102*R_321[0]+Q_110110202*R_322[0]; double QR_002020000210=Q_002020000*R_210[0]+-1*Q_002120000*R_220[0]+Q_002220000*R_230[0]+-1*Q_102020000*R_310[0]+Q_102120000*R_320[0]+-1*Q_102220000*R_330[0]+Q_202020000*R_410[0]+-1*Q_202120000*R_420[0]+Q_202220000*R_430[0]; double QR_001021000210=Q_001021000*R_210[0]+-1*Q_001121000*R_220[0]+Q_001221000*R_230[0]+-1*Q_001321000*R_240[0]+-1*Q_101021000*R_310[0]+Q_101121000*R_320[0]+-1*Q_101221000*R_330[0]+Q_101321000*R_340[0]; double QR_000022000210=Q_000022000*R_210[0]+-1*Q_000122000*R_220[0]+Q_000222000*R_230[0]+-1*Q_000322000*R_240[0]+Q_000422000*R_250[0]; double QR_001020001210=Q_001020001*R_210[0]+-1*Q_001020101*R_211[0]+-1*Q_001120001*R_220[0]+Q_001120101*R_221[0]+Q_001220001*R_230[0]+-1*Q_001220101*R_231[0]+-1*Q_101020001*R_310[0]+Q_101020101*R_311[0]+Q_101120001*R_320[0]+-1*Q_101120101*R_321[0]+-1*Q_101220001*R_330[0]+Q_101220101*R_331[0]; double QR_000021001210=Q_000021001*R_210[0]+-1*Q_000021101*R_211[0]+-1*Q_000121001*R_220[0]+Q_000121101*R_221[0]+Q_000221001*R_230[0]+-1*Q_000221101*R_231[0]+-1*Q_000321001*R_240[0]+Q_000321101*R_241[0]; double QR_000020002210=Q_000020002*R_210[0]+-1*Q_000020102*R_211[0]+Q_000020202*R_212[0]+-1*Q_000120002*R_220[0]+Q_000120102*R_221[0]+-1*Q_000120202*R_222[0]+Q_000220002*R_230[0]+-1*Q_000220102*R_231[0]+Q_000220202*R_232[0]; double QR_012000010210=Q_012000010*R_210[0]+-1*Q_012000110*R_211[0]+-1*Q_112000010*R_310[0]+Q_112000110*R_311[0]+Q_212000010*R_410[0]+-1*Q_212000110*R_411[0]+-1*Q_312000010*R_510[0]+Q_312000110*R_511[0]; double QR_011001010210=Q_011001010*R_210[0]+-1*Q_011001110*R_211[0]+-1*Q_011101010*R_220[0]+Q_011101110*R_221[0]+-1*Q_111001010*R_310[0]+Q_111001110*R_311[0]+Q_111101010*R_320[0]+-1*Q_111101110*R_321[0]+Q_211001010*R_410[0]+-1*Q_211001110*R_411[0]+-1*Q_211101010*R_420[0]+Q_211101110*R_421[0]; double QR_010002010210=Q_010002010*R_210[0]+-1*Q_010002110*R_211[0]+-1*Q_010102010*R_220[0]+Q_010102110*R_221[0]+Q_010202010*R_230[0]+-1*Q_010202110*R_231[0]+-1*Q_110002010*R_310[0]+Q_110002110*R_311[0]+Q_110102010*R_320[0]+-1*Q_110102110*R_321[0]+-1*Q_110202010*R_330[0]+Q_110202110*R_331[0]; double QR_011000011210=Q_011000011*R_210[0]+-1*Q_011000111*R_211[0]+Q_011000211*R_212[0]+-1*Q_111000011*R_310[0]+Q_111000111*R_311[0]+-1*Q_111000211*R_312[0]+Q_211000011*R_410[0]+-1*Q_211000111*R_411[0]+Q_211000211*R_412[0]; double QR_010001011210=Q_010001011*R_210[0]+-1*Q_010001111*R_211[0]+Q_010001211*R_212[0]+-1*Q_010101011*R_220[0]+Q_010101111*R_221[0]+-1*Q_010101211*R_222[0]+-1*Q_110001011*R_310[0]+Q_110001111*R_311[0]+-1*Q_110001211*R_312[0]+Q_110101011*R_320[0]+-1*Q_110101111*R_321[0]+Q_110101211*R_322[0]; double QR_010000012210=Q_010000012*R_210[0]+-1*Q_010000112*R_211[0]+Q_010000212*R_212[0]+-1*Q_010000312*R_213[0]+-1*Q_110000012*R_310[0]+Q_110000112*R_311[0]+-1*Q_110000212*R_312[0]+Q_110000312*R_313[0]; double QR_002010010210=Q_002010010*R_210[0]+-1*Q_002010110*R_211[0]+-1*Q_002110010*R_220[0]+Q_002110110*R_221[0]+-1*Q_102010010*R_310[0]+Q_102010110*R_311[0]+Q_102110010*R_320[0]+-1*Q_102110110*R_321[0]+Q_202010010*R_410[0]+-1*Q_202010110*R_411[0]+-1*Q_202110010*R_420[0]+Q_202110110*R_421[0]; double QR_001011010210=Q_001011010*R_210[0]+-1*Q_001011110*R_211[0]+-1*Q_001111010*R_220[0]+Q_001111110*R_221[0]+Q_001211010*R_230[0]+-1*Q_001211110*R_231[0]+-1*Q_101011010*R_310[0]+Q_101011110*R_311[0]+Q_101111010*R_320[0]+-1*Q_101111110*R_321[0]+-1*Q_101211010*R_330[0]+Q_101211110*R_331[0]; double QR_000012010210=Q_000012010*R_210[0]+-1*Q_000012110*R_211[0]+-1*Q_000112010*R_220[0]+Q_000112110*R_221[0]+Q_000212010*R_230[0]+-1*Q_000212110*R_231[0]+-1*Q_000312010*R_240[0]+Q_000312110*R_241[0]; double QR_001010011210=Q_001010011*R_210[0]+-1*Q_001010111*R_211[0]+Q_001010211*R_212[0]+-1*Q_001110011*R_220[0]+Q_001110111*R_221[0]+-1*Q_001110211*R_222[0]+-1*Q_101010011*R_310[0]+Q_101010111*R_311[0]+-1*Q_101010211*R_312[0]+Q_101110011*R_320[0]+-1*Q_101110111*R_321[0]+Q_101110211*R_322[0]; double QR_000011011210=Q_000011011*R_210[0]+-1*Q_000011111*R_211[0]+Q_000011211*R_212[0]+-1*Q_000111011*R_220[0]+Q_000111111*R_221[0]+-1*Q_000111211*R_222[0]+Q_000211011*R_230[0]+-1*Q_000211111*R_231[0]+Q_000211211*R_232[0]; double QR_000010012210=Q_000010012*R_210[0]+-1*Q_000010112*R_211[0]+Q_000010212*R_212[0]+-1*Q_000010312*R_213[0]+-1*Q_000110012*R_220[0]+Q_000110112*R_221[0]+-1*Q_000110212*R_222[0]+Q_000110312*R_223[0]; double QR_002000020210=Q_002000020*R_210[0]+-1*Q_002000120*R_211[0]+Q_002000220*R_212[0]+-1*Q_102000020*R_310[0]+Q_102000120*R_311[0]+-1*Q_102000220*R_312[0]+Q_202000020*R_410[0]+-1*Q_202000120*R_411[0]+Q_202000220*R_412[0]; double QR_001001020210=Q_001001020*R_210[0]+-1*Q_001001120*R_211[0]+Q_001001220*R_212[0]+-1*Q_001101020*R_220[0]+Q_001101120*R_221[0]+-1*Q_001101220*R_222[0]+-1*Q_101001020*R_310[0]+Q_101001120*R_311[0]+-1*Q_101001220*R_312[0]+Q_101101020*R_320[0]+-1*Q_101101120*R_321[0]+Q_101101220*R_322[0]; double QR_000002020210=Q_000002020*R_210[0]+-1*Q_000002120*R_211[0]+Q_000002220*R_212[0]+-1*Q_000102020*R_220[0]+Q_000102120*R_221[0]+-1*Q_000102220*R_222[0]+Q_000202020*R_230[0]+-1*Q_000202120*R_231[0]+Q_000202220*R_232[0]; double QR_001000021210=Q_001000021*R_210[0]+-1*Q_001000121*R_211[0]+Q_001000221*R_212[0]+-1*Q_001000321*R_213[0]+-1*Q_101000021*R_310[0]+Q_101000121*R_311[0]+-1*Q_101000221*R_312[0]+Q_101000321*R_313[0]; double QR_000001021210=Q_000001021*R_210[0]+-1*Q_000001121*R_211[0]+Q_000001221*R_212[0]+-1*Q_000001321*R_213[0]+-1*Q_000101021*R_220[0]+Q_000101121*R_221[0]+-1*Q_000101221*R_222[0]+Q_000101321*R_223[0]; double QR_000000022210=Q_000000022*R_210[0]+-1*Q_000000122*R_211[0]+Q_000000222*R_212[0]+-1*Q_000000322*R_213[0]+Q_000000422*R_214[0]; double QR_022000000300=Q_022000000*R_300[0]+-1*Q_122000000*R_400[0]+Q_222000000*R_500[0]+-1*Q_322000000*R_600[0]+Q_422000000*R_700[0]; double QR_021001000300=Q_021001000*R_300[0]+-1*Q_021101000*R_310[0]+-1*Q_121001000*R_400[0]+Q_121101000*R_410[0]+Q_221001000*R_500[0]+-1*Q_221101000*R_510[0]+-1*Q_321001000*R_600[0]+Q_321101000*R_610[0]; double QR_020002000300=Q_020002000*R_300[0]+-1*Q_020102000*R_310[0]+Q_020202000*R_320[0]+-1*Q_120002000*R_400[0]+Q_120102000*R_410[0]+-1*Q_120202000*R_420[0]+Q_220002000*R_500[0]+-1*Q_220102000*R_510[0]+Q_220202000*R_520[0]; double QR_021000001300=Q_021000001*R_300[0]+-1*Q_021000101*R_301[0]+-1*Q_121000001*R_400[0]+Q_121000101*R_401[0]+Q_221000001*R_500[0]+-1*Q_221000101*R_501[0]+-1*Q_321000001*R_600[0]+Q_321000101*R_601[0]; double QR_020001001300=Q_020001001*R_300[0]+-1*Q_020001101*R_301[0]+-1*Q_020101001*R_310[0]+Q_020101101*R_311[0]+-1*Q_120001001*R_400[0]+Q_120001101*R_401[0]+Q_120101001*R_410[0]+-1*Q_120101101*R_411[0]+Q_220001001*R_500[0]+-1*Q_220001101*R_501[0]+-1*Q_220101001*R_510[0]+Q_220101101*R_511[0]; double QR_020000002300=Q_020000002*R_300[0]+-1*Q_020000102*R_301[0]+Q_020000202*R_302[0]+-1*Q_120000002*R_400[0]+Q_120000102*R_401[0]+-1*Q_120000202*R_402[0]+Q_220000002*R_500[0]+-1*Q_220000102*R_501[0]+Q_220000202*R_502[0]; double QR_012010000300=Q_012010000*R_300[0]+-1*Q_012110000*R_310[0]+-1*Q_112010000*R_400[0]+Q_112110000*R_410[0]+Q_212010000*R_500[0]+-1*Q_212110000*R_510[0]+-1*Q_312010000*R_600[0]+Q_312110000*R_610[0]; double QR_011011000300=Q_011011000*R_300[0]+-1*Q_011111000*R_310[0]+Q_011211000*R_320[0]+-1*Q_111011000*R_400[0]+Q_111111000*R_410[0]+-1*Q_111211000*R_420[0]+Q_211011000*R_500[0]+-1*Q_211111000*R_510[0]+Q_211211000*R_520[0]; double QR_010012000300=Q_010012000*R_300[0]+-1*Q_010112000*R_310[0]+Q_010212000*R_320[0]+-1*Q_010312000*R_330[0]+-1*Q_110012000*R_400[0]+Q_110112000*R_410[0]+-1*Q_110212000*R_420[0]+Q_110312000*R_430[0]; double QR_011010001300=Q_011010001*R_300[0]+-1*Q_011010101*R_301[0]+-1*Q_011110001*R_310[0]+Q_011110101*R_311[0]+-1*Q_111010001*R_400[0]+Q_111010101*R_401[0]+Q_111110001*R_410[0]+-1*Q_111110101*R_411[0]+Q_211010001*R_500[0]+-1*Q_211010101*R_501[0]+-1*Q_211110001*R_510[0]+Q_211110101*R_511[0]; double QR_010011001300=Q_010011001*R_300[0]+-1*Q_010011101*R_301[0]+-1*Q_010111001*R_310[0]+Q_010111101*R_311[0]+Q_010211001*R_320[0]+-1*Q_010211101*R_321[0]+-1*Q_110011001*R_400[0]+Q_110011101*R_401[0]+Q_110111001*R_410[0]+-1*Q_110111101*R_411[0]+-1*Q_110211001*R_420[0]+Q_110211101*R_421[0]; double QR_010010002300=Q_010010002*R_300[0]+-1*Q_010010102*R_301[0]+Q_010010202*R_302[0]+-1*Q_010110002*R_310[0]+Q_010110102*R_311[0]+-1*Q_010110202*R_312[0]+-1*Q_110010002*R_400[0]+Q_110010102*R_401[0]+-1*Q_110010202*R_402[0]+Q_110110002*R_410[0]+-1*Q_110110102*R_411[0]+Q_110110202*R_412[0]; double QR_002020000300=Q_002020000*R_300[0]+-1*Q_002120000*R_310[0]+Q_002220000*R_320[0]+-1*Q_102020000*R_400[0]+Q_102120000*R_410[0]+-1*Q_102220000*R_420[0]+Q_202020000*R_500[0]+-1*Q_202120000*R_510[0]+Q_202220000*R_520[0]; double QR_001021000300=Q_001021000*R_300[0]+-1*Q_001121000*R_310[0]+Q_001221000*R_320[0]+-1*Q_001321000*R_330[0]+-1*Q_101021000*R_400[0]+Q_101121000*R_410[0]+-1*Q_101221000*R_420[0]+Q_101321000*R_430[0]; double QR_000022000300=Q_000022000*R_300[0]+-1*Q_000122000*R_310[0]+Q_000222000*R_320[0]+-1*Q_000322000*R_330[0]+Q_000422000*R_340[0]; double QR_001020001300=Q_001020001*R_300[0]+-1*Q_001020101*R_301[0]+-1*Q_001120001*R_310[0]+Q_001120101*R_311[0]+Q_001220001*R_320[0]+-1*Q_001220101*R_321[0]+-1*Q_101020001*R_400[0]+Q_101020101*R_401[0]+Q_101120001*R_410[0]+-1*Q_101120101*R_411[0]+-1*Q_101220001*R_420[0]+Q_101220101*R_421[0]; double QR_000021001300=Q_000021001*R_300[0]+-1*Q_000021101*R_301[0]+-1*Q_000121001*R_310[0]+Q_000121101*R_311[0]+Q_000221001*R_320[0]+-1*Q_000221101*R_321[0]+-1*Q_000321001*R_330[0]+Q_000321101*R_331[0]; double QR_000020002300=Q_000020002*R_300[0]+-1*Q_000020102*R_301[0]+Q_000020202*R_302[0]+-1*Q_000120002*R_310[0]+Q_000120102*R_311[0]+-1*Q_000120202*R_312[0]+Q_000220002*R_320[0]+-1*Q_000220102*R_321[0]+Q_000220202*R_322[0]; double QR_012000010300=Q_012000010*R_300[0]+-1*Q_012000110*R_301[0]+-1*Q_112000010*R_400[0]+Q_112000110*R_401[0]+Q_212000010*R_500[0]+-1*Q_212000110*R_501[0]+-1*Q_312000010*R_600[0]+Q_312000110*R_601[0]; double QR_011001010300=Q_011001010*R_300[0]+-1*Q_011001110*R_301[0]+-1*Q_011101010*R_310[0]+Q_011101110*R_311[0]+-1*Q_111001010*R_400[0]+Q_111001110*R_401[0]+Q_111101010*R_410[0]+-1*Q_111101110*R_411[0]+Q_211001010*R_500[0]+-1*Q_211001110*R_501[0]+-1*Q_211101010*R_510[0]+Q_211101110*R_511[0]; double QR_010002010300=Q_010002010*R_300[0]+-1*Q_010002110*R_301[0]+-1*Q_010102010*R_310[0]+Q_010102110*R_311[0]+Q_010202010*R_320[0]+-1*Q_010202110*R_321[0]+-1*Q_110002010*R_400[0]+Q_110002110*R_401[0]+Q_110102010*R_410[0]+-1*Q_110102110*R_411[0]+-1*Q_110202010*R_420[0]+Q_110202110*R_421[0]; double QR_011000011300=Q_011000011*R_300[0]+-1*Q_011000111*R_301[0]+Q_011000211*R_302[0]+-1*Q_111000011*R_400[0]+Q_111000111*R_401[0]+-1*Q_111000211*R_402[0]+Q_211000011*R_500[0]+-1*Q_211000111*R_501[0]+Q_211000211*R_502[0]; double QR_010001011300=Q_010001011*R_300[0]+-1*Q_010001111*R_301[0]+Q_010001211*R_302[0]+-1*Q_010101011*R_310[0]+Q_010101111*R_311[0]+-1*Q_010101211*R_312[0]+-1*Q_110001011*R_400[0]+Q_110001111*R_401[0]+-1*Q_110001211*R_402[0]+Q_110101011*R_410[0]+-1*Q_110101111*R_411[0]+Q_110101211*R_412[0]; double QR_010000012300=Q_010000012*R_300[0]+-1*Q_010000112*R_301[0]+Q_010000212*R_302[0]+-1*Q_010000312*R_303[0]+-1*Q_110000012*R_400[0]+Q_110000112*R_401[0]+-1*Q_110000212*R_402[0]+Q_110000312*R_403[0]; double QR_002010010300=Q_002010010*R_300[0]+-1*Q_002010110*R_301[0]+-1*Q_002110010*R_310[0]+Q_002110110*R_311[0]+-1*Q_102010010*R_400[0]+Q_102010110*R_401[0]+Q_102110010*R_410[0]+-1*Q_102110110*R_411[0]+Q_202010010*R_500[0]+-1*Q_202010110*R_501[0]+-1*Q_202110010*R_510[0]+Q_202110110*R_511[0]; double QR_001011010300=Q_001011010*R_300[0]+-1*Q_001011110*R_301[0]+-1*Q_001111010*R_310[0]+Q_001111110*R_311[0]+Q_001211010*R_320[0]+-1*Q_001211110*R_321[0]+-1*Q_101011010*R_400[0]+Q_101011110*R_401[0]+Q_101111010*R_410[0]+-1*Q_101111110*R_411[0]+-1*Q_101211010*R_420[0]+Q_101211110*R_421[0]; double QR_000012010300=Q_000012010*R_300[0]+-1*Q_000012110*R_301[0]+-1*Q_000112010*R_310[0]+Q_000112110*R_311[0]+Q_000212010*R_320[0]+-1*Q_000212110*R_321[0]+-1*Q_000312010*R_330[0]+Q_000312110*R_331[0]; double QR_001010011300=Q_001010011*R_300[0]+-1*Q_001010111*R_301[0]+Q_001010211*R_302[0]+-1*Q_001110011*R_310[0]+Q_001110111*R_311[0]+-1*Q_001110211*R_312[0]+-1*Q_101010011*R_400[0]+Q_101010111*R_401[0]+-1*Q_101010211*R_402[0]+Q_101110011*R_410[0]+-1*Q_101110111*R_411[0]+Q_101110211*R_412[0]; double QR_000011011300=Q_000011011*R_300[0]+-1*Q_000011111*R_301[0]+Q_000011211*R_302[0]+-1*Q_000111011*R_310[0]+Q_000111111*R_311[0]+-1*Q_000111211*R_312[0]+Q_000211011*R_320[0]+-1*Q_000211111*R_321[0]+Q_000211211*R_322[0]; double QR_000010012300=Q_000010012*R_300[0]+-1*Q_000010112*R_301[0]+Q_000010212*R_302[0]+-1*Q_000010312*R_303[0]+-1*Q_000110012*R_310[0]+Q_000110112*R_311[0]+-1*Q_000110212*R_312[0]+Q_000110312*R_313[0]; double QR_002000020300=Q_002000020*R_300[0]+-1*Q_002000120*R_301[0]+Q_002000220*R_302[0]+-1*Q_102000020*R_400[0]+Q_102000120*R_401[0]+-1*Q_102000220*R_402[0]+Q_202000020*R_500[0]+-1*Q_202000120*R_501[0]+Q_202000220*R_502[0]; double QR_001001020300=Q_001001020*R_300[0]+-1*Q_001001120*R_301[0]+Q_001001220*R_302[0]+-1*Q_001101020*R_310[0]+Q_001101120*R_311[0]+-1*Q_001101220*R_312[0]+-1*Q_101001020*R_400[0]+Q_101001120*R_401[0]+-1*Q_101001220*R_402[0]+Q_101101020*R_410[0]+-1*Q_101101120*R_411[0]+Q_101101220*R_412[0]; double QR_000002020300=Q_000002020*R_300[0]+-1*Q_000002120*R_301[0]+Q_000002220*R_302[0]+-1*Q_000102020*R_310[0]+Q_000102120*R_311[0]+-1*Q_000102220*R_312[0]+Q_000202020*R_320[0]+-1*Q_000202120*R_321[0]+Q_000202220*R_322[0]; double QR_001000021300=Q_001000021*R_300[0]+-1*Q_001000121*R_301[0]+Q_001000221*R_302[0]+-1*Q_001000321*R_303[0]+-1*Q_101000021*R_400[0]+Q_101000121*R_401[0]+-1*Q_101000221*R_402[0]+Q_101000321*R_403[0]; double QR_000001021300=Q_000001021*R_300[0]+-1*Q_000001121*R_301[0]+Q_000001221*R_302[0]+-1*Q_000001321*R_303[0]+-1*Q_000101021*R_310[0]+Q_000101121*R_311[0]+-1*Q_000101221*R_312[0]+Q_000101321*R_313[0]; double QR_000000022300=Q_000000022*R_300[0]+-1*Q_000000122*R_301[0]+Q_000000222*R_302[0]+-1*Q_000000322*R_303[0]+Q_000000422*R_304[0]; double QR_022000000004=Q_022000000*R_004[0]+-1*Q_122000000*R_104[0]+Q_222000000*R_204[0]+-1*Q_322000000*R_304[0]+Q_422000000*R_404[0]; double QR_021001000004=Q_021001000*R_004[0]+-1*Q_021101000*R_014[0]+-1*Q_121001000*R_104[0]+Q_121101000*R_114[0]+Q_221001000*R_204[0]+-1*Q_221101000*R_214[0]+-1*Q_321001000*R_304[0]+Q_321101000*R_314[0]; double QR_020002000004=Q_020002000*R_004[0]+-1*Q_020102000*R_014[0]+Q_020202000*R_024[0]+-1*Q_120002000*R_104[0]+Q_120102000*R_114[0]+-1*Q_120202000*R_124[0]+Q_220002000*R_204[0]+-1*Q_220102000*R_214[0]+Q_220202000*R_224[0]; double QR_021000001004=Q_021000001*R_004[0]+-1*Q_021000101*R_005[0]+-1*Q_121000001*R_104[0]+Q_121000101*R_105[0]+Q_221000001*R_204[0]+-1*Q_221000101*R_205[0]+-1*Q_321000001*R_304[0]+Q_321000101*R_305[0]; double QR_020001001004=Q_020001001*R_004[0]+-1*Q_020001101*R_005[0]+-1*Q_020101001*R_014[0]+Q_020101101*R_015[0]+-1*Q_120001001*R_104[0]+Q_120001101*R_105[0]+Q_120101001*R_114[0]+-1*Q_120101101*R_115[0]+Q_220001001*R_204[0]+-1*Q_220001101*R_205[0]+-1*Q_220101001*R_214[0]+Q_220101101*R_215[0]; double QR_020000002004=Q_020000002*R_004[0]+-1*Q_020000102*R_005[0]+Q_020000202*R_006[0]+-1*Q_120000002*R_104[0]+Q_120000102*R_105[0]+-1*Q_120000202*R_106[0]+Q_220000002*R_204[0]+-1*Q_220000102*R_205[0]+Q_220000202*R_206[0]; double QR_012010000004=Q_012010000*R_004[0]+-1*Q_012110000*R_014[0]+-1*Q_112010000*R_104[0]+Q_112110000*R_114[0]+Q_212010000*R_204[0]+-1*Q_212110000*R_214[0]+-1*Q_312010000*R_304[0]+Q_312110000*R_314[0]; double QR_011011000004=Q_011011000*R_004[0]+-1*Q_011111000*R_014[0]+Q_011211000*R_024[0]+-1*Q_111011000*R_104[0]+Q_111111000*R_114[0]+-1*Q_111211000*R_124[0]+Q_211011000*R_204[0]+-1*Q_211111000*R_214[0]+Q_211211000*R_224[0]; double QR_010012000004=Q_010012000*R_004[0]+-1*Q_010112000*R_014[0]+Q_010212000*R_024[0]+-1*Q_010312000*R_034[0]+-1*Q_110012000*R_104[0]+Q_110112000*R_114[0]+-1*Q_110212000*R_124[0]+Q_110312000*R_134[0]; double QR_011010001004=Q_011010001*R_004[0]+-1*Q_011010101*R_005[0]+-1*Q_011110001*R_014[0]+Q_011110101*R_015[0]+-1*Q_111010001*R_104[0]+Q_111010101*R_105[0]+Q_111110001*R_114[0]+-1*Q_111110101*R_115[0]+Q_211010001*R_204[0]+-1*Q_211010101*R_205[0]+-1*Q_211110001*R_214[0]+Q_211110101*R_215[0]; double QR_010011001004=Q_010011001*R_004[0]+-1*Q_010011101*R_005[0]+-1*Q_010111001*R_014[0]+Q_010111101*R_015[0]+Q_010211001*R_024[0]+-1*Q_010211101*R_025[0]+-1*Q_110011001*R_104[0]+Q_110011101*R_105[0]+Q_110111001*R_114[0]+-1*Q_110111101*R_115[0]+-1*Q_110211001*R_124[0]+Q_110211101*R_125[0]; double QR_010010002004=Q_010010002*R_004[0]+-1*Q_010010102*R_005[0]+Q_010010202*R_006[0]+-1*Q_010110002*R_014[0]+Q_010110102*R_015[0]+-1*Q_010110202*R_016[0]+-1*Q_110010002*R_104[0]+Q_110010102*R_105[0]+-1*Q_110010202*R_106[0]+Q_110110002*R_114[0]+-1*Q_110110102*R_115[0]+Q_110110202*R_116[0]; double QR_002020000004=Q_002020000*R_004[0]+-1*Q_002120000*R_014[0]+Q_002220000*R_024[0]+-1*Q_102020000*R_104[0]+Q_102120000*R_114[0]+-1*Q_102220000*R_124[0]+Q_202020000*R_204[0]+-1*Q_202120000*R_214[0]+Q_202220000*R_224[0]; double QR_001021000004=Q_001021000*R_004[0]+-1*Q_001121000*R_014[0]+Q_001221000*R_024[0]+-1*Q_001321000*R_034[0]+-1*Q_101021000*R_104[0]+Q_101121000*R_114[0]+-1*Q_101221000*R_124[0]+Q_101321000*R_134[0]; double QR_000022000004=Q_000022000*R_004[0]+-1*Q_000122000*R_014[0]+Q_000222000*R_024[0]+-1*Q_000322000*R_034[0]+Q_000422000*R_044[0]; double QR_001020001004=Q_001020001*R_004[0]+-1*Q_001020101*R_005[0]+-1*Q_001120001*R_014[0]+Q_001120101*R_015[0]+Q_001220001*R_024[0]+-1*Q_001220101*R_025[0]+-1*Q_101020001*R_104[0]+Q_101020101*R_105[0]+Q_101120001*R_114[0]+-1*Q_101120101*R_115[0]+-1*Q_101220001*R_124[0]+Q_101220101*R_125[0]; double QR_000021001004=Q_000021001*R_004[0]+-1*Q_000021101*R_005[0]+-1*Q_000121001*R_014[0]+Q_000121101*R_015[0]+Q_000221001*R_024[0]+-1*Q_000221101*R_025[0]+-1*Q_000321001*R_034[0]+Q_000321101*R_035[0]; double QR_000020002004=Q_000020002*R_004[0]+-1*Q_000020102*R_005[0]+Q_000020202*R_006[0]+-1*Q_000120002*R_014[0]+Q_000120102*R_015[0]+-1*Q_000120202*R_016[0]+Q_000220002*R_024[0]+-1*Q_000220102*R_025[0]+Q_000220202*R_026[0]; double QR_012000010004=Q_012000010*R_004[0]+-1*Q_012000110*R_005[0]+-1*Q_112000010*R_104[0]+Q_112000110*R_105[0]+Q_212000010*R_204[0]+-1*Q_212000110*R_205[0]+-1*Q_312000010*R_304[0]+Q_312000110*R_305[0]; double QR_011001010004=Q_011001010*R_004[0]+-1*Q_011001110*R_005[0]+-1*Q_011101010*R_014[0]+Q_011101110*R_015[0]+-1*Q_111001010*R_104[0]+Q_111001110*R_105[0]+Q_111101010*R_114[0]+-1*Q_111101110*R_115[0]+Q_211001010*R_204[0]+-1*Q_211001110*R_205[0]+-1*Q_211101010*R_214[0]+Q_211101110*R_215[0]; double QR_010002010004=Q_010002010*R_004[0]+-1*Q_010002110*R_005[0]+-1*Q_010102010*R_014[0]+Q_010102110*R_015[0]+Q_010202010*R_024[0]+-1*Q_010202110*R_025[0]+-1*Q_110002010*R_104[0]+Q_110002110*R_105[0]+Q_110102010*R_114[0]+-1*Q_110102110*R_115[0]+-1*Q_110202010*R_124[0]+Q_110202110*R_125[0]; double QR_011000011004=Q_011000011*R_004[0]+-1*Q_011000111*R_005[0]+Q_011000211*R_006[0]+-1*Q_111000011*R_104[0]+Q_111000111*R_105[0]+-1*Q_111000211*R_106[0]+Q_211000011*R_204[0]+-1*Q_211000111*R_205[0]+Q_211000211*R_206[0]; double QR_010001011004=Q_010001011*R_004[0]+-1*Q_010001111*R_005[0]+Q_010001211*R_006[0]+-1*Q_010101011*R_014[0]+Q_010101111*R_015[0]+-1*Q_010101211*R_016[0]+-1*Q_110001011*R_104[0]+Q_110001111*R_105[0]+-1*Q_110001211*R_106[0]+Q_110101011*R_114[0]+-1*Q_110101111*R_115[0]+Q_110101211*R_116[0]; double QR_010000012004=Q_010000012*R_004[0]+-1*Q_010000112*R_005[0]+Q_010000212*R_006[0]+-1*Q_010000312*R_007[0]+-1*Q_110000012*R_104[0]+Q_110000112*R_105[0]+-1*Q_110000212*R_106[0]+Q_110000312*R_107[0]; double QR_002010010004=Q_002010010*R_004[0]+-1*Q_002010110*R_005[0]+-1*Q_002110010*R_014[0]+Q_002110110*R_015[0]+-1*Q_102010010*R_104[0]+Q_102010110*R_105[0]+Q_102110010*R_114[0]+-1*Q_102110110*R_115[0]+Q_202010010*R_204[0]+-1*Q_202010110*R_205[0]+-1*Q_202110010*R_214[0]+Q_202110110*R_215[0]; double QR_001011010004=Q_001011010*R_004[0]+-1*Q_001011110*R_005[0]+-1*Q_001111010*R_014[0]+Q_001111110*R_015[0]+Q_001211010*R_024[0]+-1*Q_001211110*R_025[0]+-1*Q_101011010*R_104[0]+Q_101011110*R_105[0]+Q_101111010*R_114[0]+-1*Q_101111110*R_115[0]+-1*Q_101211010*R_124[0]+Q_101211110*R_125[0]; double QR_000012010004=Q_000012010*R_004[0]+-1*Q_000012110*R_005[0]+-1*Q_000112010*R_014[0]+Q_000112110*R_015[0]+Q_000212010*R_024[0]+-1*Q_000212110*R_025[0]+-1*Q_000312010*R_034[0]+Q_000312110*R_035[0]; double QR_001010011004=Q_001010011*R_004[0]+-1*Q_001010111*R_005[0]+Q_001010211*R_006[0]+-1*Q_001110011*R_014[0]+Q_001110111*R_015[0]+-1*Q_001110211*R_016[0]+-1*Q_101010011*R_104[0]+Q_101010111*R_105[0]+-1*Q_101010211*R_106[0]+Q_101110011*R_114[0]+-1*Q_101110111*R_115[0]+Q_101110211*R_116[0]; double QR_000011011004=Q_000011011*R_004[0]+-1*Q_000011111*R_005[0]+Q_000011211*R_006[0]+-1*Q_000111011*R_014[0]+Q_000111111*R_015[0]+-1*Q_000111211*R_016[0]+Q_000211011*R_024[0]+-1*Q_000211111*R_025[0]+Q_000211211*R_026[0]; double QR_000010012004=Q_000010012*R_004[0]+-1*Q_000010112*R_005[0]+Q_000010212*R_006[0]+-1*Q_000010312*R_007[0]+-1*Q_000110012*R_014[0]+Q_000110112*R_015[0]+-1*Q_000110212*R_016[0]+Q_000110312*R_017[0]; double QR_002000020004=Q_002000020*R_004[0]+-1*Q_002000120*R_005[0]+Q_002000220*R_006[0]+-1*Q_102000020*R_104[0]+Q_102000120*R_105[0]+-1*Q_102000220*R_106[0]+Q_202000020*R_204[0]+-1*Q_202000120*R_205[0]+Q_202000220*R_206[0]; double QR_001001020004=Q_001001020*R_004[0]+-1*Q_001001120*R_005[0]+Q_001001220*R_006[0]+-1*Q_001101020*R_014[0]+Q_001101120*R_015[0]+-1*Q_001101220*R_016[0]+-1*Q_101001020*R_104[0]+Q_101001120*R_105[0]+-1*Q_101001220*R_106[0]+Q_101101020*R_114[0]+-1*Q_101101120*R_115[0]+Q_101101220*R_116[0]; double QR_000002020004=Q_000002020*R_004[0]+-1*Q_000002120*R_005[0]+Q_000002220*R_006[0]+-1*Q_000102020*R_014[0]+Q_000102120*R_015[0]+-1*Q_000102220*R_016[0]+Q_000202020*R_024[0]+-1*Q_000202120*R_025[0]+Q_000202220*R_026[0]; double QR_001000021004=Q_001000021*R_004[0]+-1*Q_001000121*R_005[0]+Q_001000221*R_006[0]+-1*Q_001000321*R_007[0]+-1*Q_101000021*R_104[0]+Q_101000121*R_105[0]+-1*Q_101000221*R_106[0]+Q_101000321*R_107[0]; double QR_000001021004=Q_000001021*R_004[0]+-1*Q_000001121*R_005[0]+Q_000001221*R_006[0]+-1*Q_000001321*R_007[0]+-1*Q_000101021*R_014[0]+Q_000101121*R_015[0]+-1*Q_000101221*R_016[0]+Q_000101321*R_017[0]; double QR_000000022004=Q_000000022*R_004[0]+-1*Q_000000122*R_005[0]+Q_000000222*R_006[0]+-1*Q_000000322*R_007[0]+Q_000000422*R_008[0]; double QR_022000000013=Q_022000000*R_013[0]+-1*Q_122000000*R_113[0]+Q_222000000*R_213[0]+-1*Q_322000000*R_313[0]+Q_422000000*R_413[0]; double QR_021001000013=Q_021001000*R_013[0]+-1*Q_021101000*R_023[0]+-1*Q_121001000*R_113[0]+Q_121101000*R_123[0]+Q_221001000*R_213[0]+-1*Q_221101000*R_223[0]+-1*Q_321001000*R_313[0]+Q_321101000*R_323[0]; double QR_020002000013=Q_020002000*R_013[0]+-1*Q_020102000*R_023[0]+Q_020202000*R_033[0]+-1*Q_120002000*R_113[0]+Q_120102000*R_123[0]+-1*Q_120202000*R_133[0]+Q_220002000*R_213[0]+-1*Q_220102000*R_223[0]+Q_220202000*R_233[0]; double QR_021000001013=Q_021000001*R_013[0]+-1*Q_021000101*R_014[0]+-1*Q_121000001*R_113[0]+Q_121000101*R_114[0]+Q_221000001*R_213[0]+-1*Q_221000101*R_214[0]+-1*Q_321000001*R_313[0]+Q_321000101*R_314[0]; double QR_020001001013=Q_020001001*R_013[0]+-1*Q_020001101*R_014[0]+-1*Q_020101001*R_023[0]+Q_020101101*R_024[0]+-1*Q_120001001*R_113[0]+Q_120001101*R_114[0]+Q_120101001*R_123[0]+-1*Q_120101101*R_124[0]+Q_220001001*R_213[0]+-1*Q_220001101*R_214[0]+-1*Q_220101001*R_223[0]+Q_220101101*R_224[0]; double QR_020000002013=Q_020000002*R_013[0]+-1*Q_020000102*R_014[0]+Q_020000202*R_015[0]+-1*Q_120000002*R_113[0]+Q_120000102*R_114[0]+-1*Q_120000202*R_115[0]+Q_220000002*R_213[0]+-1*Q_220000102*R_214[0]+Q_220000202*R_215[0]; double QR_012010000013=Q_012010000*R_013[0]+-1*Q_012110000*R_023[0]+-1*Q_112010000*R_113[0]+Q_112110000*R_123[0]+Q_212010000*R_213[0]+-1*Q_212110000*R_223[0]+-1*Q_312010000*R_313[0]+Q_312110000*R_323[0]; double QR_011011000013=Q_011011000*R_013[0]+-1*Q_011111000*R_023[0]+Q_011211000*R_033[0]+-1*Q_111011000*R_113[0]+Q_111111000*R_123[0]+-1*Q_111211000*R_133[0]+Q_211011000*R_213[0]+-1*Q_211111000*R_223[0]+Q_211211000*R_233[0]; double QR_010012000013=Q_010012000*R_013[0]+-1*Q_010112000*R_023[0]+Q_010212000*R_033[0]+-1*Q_010312000*R_043[0]+-1*Q_110012000*R_113[0]+Q_110112000*R_123[0]+-1*Q_110212000*R_133[0]+Q_110312000*R_143[0]; double QR_011010001013=Q_011010001*R_013[0]+-1*Q_011010101*R_014[0]+-1*Q_011110001*R_023[0]+Q_011110101*R_024[0]+-1*Q_111010001*R_113[0]+Q_111010101*R_114[0]+Q_111110001*R_123[0]+-1*Q_111110101*R_124[0]+Q_211010001*R_213[0]+-1*Q_211010101*R_214[0]+-1*Q_211110001*R_223[0]+Q_211110101*R_224[0]; double QR_010011001013=Q_010011001*R_013[0]+-1*Q_010011101*R_014[0]+-1*Q_010111001*R_023[0]+Q_010111101*R_024[0]+Q_010211001*R_033[0]+-1*Q_010211101*R_034[0]+-1*Q_110011001*R_113[0]+Q_110011101*R_114[0]+Q_110111001*R_123[0]+-1*Q_110111101*R_124[0]+-1*Q_110211001*R_133[0]+Q_110211101*R_134[0]; double QR_010010002013=Q_010010002*R_013[0]+-1*Q_010010102*R_014[0]+Q_010010202*R_015[0]+-1*Q_010110002*R_023[0]+Q_010110102*R_024[0]+-1*Q_010110202*R_025[0]+-1*Q_110010002*R_113[0]+Q_110010102*R_114[0]+-1*Q_110010202*R_115[0]+Q_110110002*R_123[0]+-1*Q_110110102*R_124[0]+Q_110110202*R_125[0]; double QR_002020000013=Q_002020000*R_013[0]+-1*Q_002120000*R_023[0]+Q_002220000*R_033[0]+-1*Q_102020000*R_113[0]+Q_102120000*R_123[0]+-1*Q_102220000*R_133[0]+Q_202020000*R_213[0]+-1*Q_202120000*R_223[0]+Q_202220000*R_233[0]; double QR_001021000013=Q_001021000*R_013[0]+-1*Q_001121000*R_023[0]+Q_001221000*R_033[0]+-1*Q_001321000*R_043[0]+-1*Q_101021000*R_113[0]+Q_101121000*R_123[0]+-1*Q_101221000*R_133[0]+Q_101321000*R_143[0]; double QR_000022000013=Q_000022000*R_013[0]+-1*Q_000122000*R_023[0]+Q_000222000*R_033[0]+-1*Q_000322000*R_043[0]+Q_000422000*R_053[0]; double QR_001020001013=Q_001020001*R_013[0]+-1*Q_001020101*R_014[0]+-1*Q_001120001*R_023[0]+Q_001120101*R_024[0]+Q_001220001*R_033[0]+-1*Q_001220101*R_034[0]+-1*Q_101020001*R_113[0]+Q_101020101*R_114[0]+Q_101120001*R_123[0]+-1*Q_101120101*R_124[0]+-1*Q_101220001*R_133[0]+Q_101220101*R_134[0]; double QR_000021001013=Q_000021001*R_013[0]+-1*Q_000021101*R_014[0]+-1*Q_000121001*R_023[0]+Q_000121101*R_024[0]+Q_000221001*R_033[0]+-1*Q_000221101*R_034[0]+-1*Q_000321001*R_043[0]+Q_000321101*R_044[0]; double QR_000020002013=Q_000020002*R_013[0]+-1*Q_000020102*R_014[0]+Q_000020202*R_015[0]+-1*Q_000120002*R_023[0]+Q_000120102*R_024[0]+-1*Q_000120202*R_025[0]+Q_000220002*R_033[0]+-1*Q_000220102*R_034[0]+Q_000220202*R_035[0]; double QR_012000010013=Q_012000010*R_013[0]+-1*Q_012000110*R_014[0]+-1*Q_112000010*R_113[0]+Q_112000110*R_114[0]+Q_212000010*R_213[0]+-1*Q_212000110*R_214[0]+-1*Q_312000010*R_313[0]+Q_312000110*R_314[0]; double QR_011001010013=Q_011001010*R_013[0]+-1*Q_011001110*R_014[0]+-1*Q_011101010*R_023[0]+Q_011101110*R_024[0]+-1*Q_111001010*R_113[0]+Q_111001110*R_114[0]+Q_111101010*R_123[0]+-1*Q_111101110*R_124[0]+Q_211001010*R_213[0]+-1*Q_211001110*R_214[0]+-1*Q_211101010*R_223[0]+Q_211101110*R_224[0]; double QR_010002010013=Q_010002010*R_013[0]+-1*Q_010002110*R_014[0]+-1*Q_010102010*R_023[0]+Q_010102110*R_024[0]+Q_010202010*R_033[0]+-1*Q_010202110*R_034[0]+-1*Q_110002010*R_113[0]+Q_110002110*R_114[0]+Q_110102010*R_123[0]+-1*Q_110102110*R_124[0]+-1*Q_110202010*R_133[0]+Q_110202110*R_134[0]; double QR_011000011013=Q_011000011*R_013[0]+-1*Q_011000111*R_014[0]+Q_011000211*R_015[0]+-1*Q_111000011*R_113[0]+Q_111000111*R_114[0]+-1*Q_111000211*R_115[0]+Q_211000011*R_213[0]+-1*Q_211000111*R_214[0]+Q_211000211*R_215[0]; double QR_010001011013=Q_010001011*R_013[0]+-1*Q_010001111*R_014[0]+Q_010001211*R_015[0]+-1*Q_010101011*R_023[0]+Q_010101111*R_024[0]+-1*Q_010101211*R_025[0]+-1*Q_110001011*R_113[0]+Q_110001111*R_114[0]+-1*Q_110001211*R_115[0]+Q_110101011*R_123[0]+-1*Q_110101111*R_124[0]+Q_110101211*R_125[0]; double QR_010000012013=Q_010000012*R_013[0]+-1*Q_010000112*R_014[0]+Q_010000212*R_015[0]+-1*Q_010000312*R_016[0]+-1*Q_110000012*R_113[0]+Q_110000112*R_114[0]+-1*Q_110000212*R_115[0]+Q_110000312*R_116[0]; double QR_002010010013=Q_002010010*R_013[0]+-1*Q_002010110*R_014[0]+-1*Q_002110010*R_023[0]+Q_002110110*R_024[0]+-1*Q_102010010*R_113[0]+Q_102010110*R_114[0]+Q_102110010*R_123[0]+-1*Q_102110110*R_124[0]+Q_202010010*R_213[0]+-1*Q_202010110*R_214[0]+-1*Q_202110010*R_223[0]+Q_202110110*R_224[0]; double QR_001011010013=Q_001011010*R_013[0]+-1*Q_001011110*R_014[0]+-1*Q_001111010*R_023[0]+Q_001111110*R_024[0]+Q_001211010*R_033[0]+-1*Q_001211110*R_034[0]+-1*Q_101011010*R_113[0]+Q_101011110*R_114[0]+Q_101111010*R_123[0]+-1*Q_101111110*R_124[0]+-1*Q_101211010*R_133[0]+Q_101211110*R_134[0]; double QR_000012010013=Q_000012010*R_013[0]+-1*Q_000012110*R_014[0]+-1*Q_000112010*R_023[0]+Q_000112110*R_024[0]+Q_000212010*R_033[0]+-1*Q_000212110*R_034[0]+-1*Q_000312010*R_043[0]+Q_000312110*R_044[0]; double QR_001010011013=Q_001010011*R_013[0]+-1*Q_001010111*R_014[0]+Q_001010211*R_015[0]+-1*Q_001110011*R_023[0]+Q_001110111*R_024[0]+-1*Q_001110211*R_025[0]+-1*Q_101010011*R_113[0]+Q_101010111*R_114[0]+-1*Q_101010211*R_115[0]+Q_101110011*R_123[0]+-1*Q_101110111*R_124[0]+Q_101110211*R_125[0]; double QR_000011011013=Q_000011011*R_013[0]+-1*Q_000011111*R_014[0]+Q_000011211*R_015[0]+-1*Q_000111011*R_023[0]+Q_000111111*R_024[0]+-1*Q_000111211*R_025[0]+Q_000211011*R_033[0]+-1*Q_000211111*R_034[0]+Q_000211211*R_035[0]; double QR_000010012013=Q_000010012*R_013[0]+-1*Q_000010112*R_014[0]+Q_000010212*R_015[0]+-1*Q_000010312*R_016[0]+-1*Q_000110012*R_023[0]+Q_000110112*R_024[0]+-1*Q_000110212*R_025[0]+Q_000110312*R_026[0]; double QR_002000020013=Q_002000020*R_013[0]+-1*Q_002000120*R_014[0]+Q_002000220*R_015[0]+-1*Q_102000020*R_113[0]+Q_102000120*R_114[0]+-1*Q_102000220*R_115[0]+Q_202000020*R_213[0]+-1*Q_202000120*R_214[0]+Q_202000220*R_215[0]; double QR_001001020013=Q_001001020*R_013[0]+-1*Q_001001120*R_014[0]+Q_001001220*R_015[0]+-1*Q_001101020*R_023[0]+Q_001101120*R_024[0]+-1*Q_001101220*R_025[0]+-1*Q_101001020*R_113[0]+Q_101001120*R_114[0]+-1*Q_101001220*R_115[0]+Q_101101020*R_123[0]+-1*Q_101101120*R_124[0]+Q_101101220*R_125[0]; double QR_000002020013=Q_000002020*R_013[0]+-1*Q_000002120*R_014[0]+Q_000002220*R_015[0]+-1*Q_000102020*R_023[0]+Q_000102120*R_024[0]+-1*Q_000102220*R_025[0]+Q_000202020*R_033[0]+-1*Q_000202120*R_034[0]+Q_000202220*R_035[0]; double QR_001000021013=Q_001000021*R_013[0]+-1*Q_001000121*R_014[0]+Q_001000221*R_015[0]+-1*Q_001000321*R_016[0]+-1*Q_101000021*R_113[0]+Q_101000121*R_114[0]+-1*Q_101000221*R_115[0]+Q_101000321*R_116[0]; double QR_000001021013=Q_000001021*R_013[0]+-1*Q_000001121*R_014[0]+Q_000001221*R_015[0]+-1*Q_000001321*R_016[0]+-1*Q_000101021*R_023[0]+Q_000101121*R_024[0]+-1*Q_000101221*R_025[0]+Q_000101321*R_026[0]; double QR_000000022013=Q_000000022*R_013[0]+-1*Q_000000122*R_014[0]+Q_000000222*R_015[0]+-1*Q_000000322*R_016[0]+Q_000000422*R_017[0]; double QR_022000000022=Q_022000000*R_022[0]+-1*Q_122000000*R_122[0]+Q_222000000*R_222[0]+-1*Q_322000000*R_322[0]+Q_422000000*R_422[0]; double QR_021001000022=Q_021001000*R_022[0]+-1*Q_021101000*R_032[0]+-1*Q_121001000*R_122[0]+Q_121101000*R_132[0]+Q_221001000*R_222[0]+-1*Q_221101000*R_232[0]+-1*Q_321001000*R_322[0]+Q_321101000*R_332[0]; double QR_020002000022=Q_020002000*R_022[0]+-1*Q_020102000*R_032[0]+Q_020202000*R_042[0]+-1*Q_120002000*R_122[0]+Q_120102000*R_132[0]+-1*Q_120202000*R_142[0]+Q_220002000*R_222[0]+-1*Q_220102000*R_232[0]+Q_220202000*R_242[0]; double QR_021000001022=Q_021000001*R_022[0]+-1*Q_021000101*R_023[0]+-1*Q_121000001*R_122[0]+Q_121000101*R_123[0]+Q_221000001*R_222[0]+-1*Q_221000101*R_223[0]+-1*Q_321000001*R_322[0]+Q_321000101*R_323[0]; double QR_020001001022=Q_020001001*R_022[0]+-1*Q_020001101*R_023[0]+-1*Q_020101001*R_032[0]+Q_020101101*R_033[0]+-1*Q_120001001*R_122[0]+Q_120001101*R_123[0]+Q_120101001*R_132[0]+-1*Q_120101101*R_133[0]+Q_220001001*R_222[0]+-1*Q_220001101*R_223[0]+-1*Q_220101001*R_232[0]+Q_220101101*R_233[0]; double QR_020000002022=Q_020000002*R_022[0]+-1*Q_020000102*R_023[0]+Q_020000202*R_024[0]+-1*Q_120000002*R_122[0]+Q_120000102*R_123[0]+-1*Q_120000202*R_124[0]+Q_220000002*R_222[0]+-1*Q_220000102*R_223[0]+Q_220000202*R_224[0]; double QR_012010000022=Q_012010000*R_022[0]+-1*Q_012110000*R_032[0]+-1*Q_112010000*R_122[0]+Q_112110000*R_132[0]+Q_212010000*R_222[0]+-1*Q_212110000*R_232[0]+-1*Q_312010000*R_322[0]+Q_312110000*R_332[0]; double QR_011011000022=Q_011011000*R_022[0]+-1*Q_011111000*R_032[0]+Q_011211000*R_042[0]+-1*Q_111011000*R_122[0]+Q_111111000*R_132[0]+-1*Q_111211000*R_142[0]+Q_211011000*R_222[0]+-1*Q_211111000*R_232[0]+Q_211211000*R_242[0]; double QR_010012000022=Q_010012000*R_022[0]+-1*Q_010112000*R_032[0]+Q_010212000*R_042[0]+-1*Q_010312000*R_052[0]+-1*Q_110012000*R_122[0]+Q_110112000*R_132[0]+-1*Q_110212000*R_142[0]+Q_110312000*R_152[0]; double QR_011010001022=Q_011010001*R_022[0]+-1*Q_011010101*R_023[0]+-1*Q_011110001*R_032[0]+Q_011110101*R_033[0]+-1*Q_111010001*R_122[0]+Q_111010101*R_123[0]+Q_111110001*R_132[0]+-1*Q_111110101*R_133[0]+Q_211010001*R_222[0]+-1*Q_211010101*R_223[0]+-1*Q_211110001*R_232[0]+Q_211110101*R_233[0]; double QR_010011001022=Q_010011001*R_022[0]+-1*Q_010011101*R_023[0]+-1*Q_010111001*R_032[0]+Q_010111101*R_033[0]+Q_010211001*R_042[0]+-1*Q_010211101*R_043[0]+-1*Q_110011001*R_122[0]+Q_110011101*R_123[0]+Q_110111001*R_132[0]+-1*Q_110111101*R_133[0]+-1*Q_110211001*R_142[0]+Q_110211101*R_143[0]; double QR_010010002022=Q_010010002*R_022[0]+-1*Q_010010102*R_023[0]+Q_010010202*R_024[0]+-1*Q_010110002*R_032[0]+Q_010110102*R_033[0]+-1*Q_010110202*R_034[0]+-1*Q_110010002*R_122[0]+Q_110010102*R_123[0]+-1*Q_110010202*R_124[0]+Q_110110002*R_132[0]+-1*Q_110110102*R_133[0]+Q_110110202*R_134[0]; double QR_002020000022=Q_002020000*R_022[0]+-1*Q_002120000*R_032[0]+Q_002220000*R_042[0]+-1*Q_102020000*R_122[0]+Q_102120000*R_132[0]+-1*Q_102220000*R_142[0]+Q_202020000*R_222[0]+-1*Q_202120000*R_232[0]+Q_202220000*R_242[0]; double QR_001021000022=Q_001021000*R_022[0]+-1*Q_001121000*R_032[0]+Q_001221000*R_042[0]+-1*Q_001321000*R_052[0]+-1*Q_101021000*R_122[0]+Q_101121000*R_132[0]+-1*Q_101221000*R_142[0]+Q_101321000*R_152[0]; double QR_000022000022=Q_000022000*R_022[0]+-1*Q_000122000*R_032[0]+Q_000222000*R_042[0]+-1*Q_000322000*R_052[0]+Q_000422000*R_062[0]; double QR_001020001022=Q_001020001*R_022[0]+-1*Q_001020101*R_023[0]+-1*Q_001120001*R_032[0]+Q_001120101*R_033[0]+Q_001220001*R_042[0]+-1*Q_001220101*R_043[0]+-1*Q_101020001*R_122[0]+Q_101020101*R_123[0]+Q_101120001*R_132[0]+-1*Q_101120101*R_133[0]+-1*Q_101220001*R_142[0]+Q_101220101*R_143[0]; double QR_000021001022=Q_000021001*R_022[0]+-1*Q_000021101*R_023[0]+-1*Q_000121001*R_032[0]+Q_000121101*R_033[0]+Q_000221001*R_042[0]+-1*Q_000221101*R_043[0]+-1*Q_000321001*R_052[0]+Q_000321101*R_053[0]; double QR_000020002022=Q_000020002*R_022[0]+-1*Q_000020102*R_023[0]+Q_000020202*R_024[0]+-1*Q_000120002*R_032[0]+Q_000120102*R_033[0]+-1*Q_000120202*R_034[0]+Q_000220002*R_042[0]+-1*Q_000220102*R_043[0]+Q_000220202*R_044[0]; double QR_012000010022=Q_012000010*R_022[0]+-1*Q_012000110*R_023[0]+-1*Q_112000010*R_122[0]+Q_112000110*R_123[0]+Q_212000010*R_222[0]+-1*Q_212000110*R_223[0]+-1*Q_312000010*R_322[0]+Q_312000110*R_323[0]; double QR_011001010022=Q_011001010*R_022[0]+-1*Q_011001110*R_023[0]+-1*Q_011101010*R_032[0]+Q_011101110*R_033[0]+-1*Q_111001010*R_122[0]+Q_111001110*R_123[0]+Q_111101010*R_132[0]+-1*Q_111101110*R_133[0]+Q_211001010*R_222[0]+-1*Q_211001110*R_223[0]+-1*Q_211101010*R_232[0]+Q_211101110*R_233[0]; double QR_010002010022=Q_010002010*R_022[0]+-1*Q_010002110*R_023[0]+-1*Q_010102010*R_032[0]+Q_010102110*R_033[0]+Q_010202010*R_042[0]+-1*Q_010202110*R_043[0]+-1*Q_110002010*R_122[0]+Q_110002110*R_123[0]+Q_110102010*R_132[0]+-1*Q_110102110*R_133[0]+-1*Q_110202010*R_142[0]+Q_110202110*R_143[0]; double QR_011000011022=Q_011000011*R_022[0]+-1*Q_011000111*R_023[0]+Q_011000211*R_024[0]+-1*Q_111000011*R_122[0]+Q_111000111*R_123[0]+-1*Q_111000211*R_124[0]+Q_211000011*R_222[0]+-1*Q_211000111*R_223[0]+Q_211000211*R_224[0]; double QR_010001011022=Q_010001011*R_022[0]+-1*Q_010001111*R_023[0]+Q_010001211*R_024[0]+-1*Q_010101011*R_032[0]+Q_010101111*R_033[0]+-1*Q_010101211*R_034[0]+-1*Q_110001011*R_122[0]+Q_110001111*R_123[0]+-1*Q_110001211*R_124[0]+Q_110101011*R_132[0]+-1*Q_110101111*R_133[0]+Q_110101211*R_134[0]; double QR_010000012022=Q_010000012*R_022[0]+-1*Q_010000112*R_023[0]+Q_010000212*R_024[0]+-1*Q_010000312*R_025[0]+-1*Q_110000012*R_122[0]+Q_110000112*R_123[0]+-1*Q_110000212*R_124[0]+Q_110000312*R_125[0]; double QR_002010010022=Q_002010010*R_022[0]+-1*Q_002010110*R_023[0]+-1*Q_002110010*R_032[0]+Q_002110110*R_033[0]+-1*Q_102010010*R_122[0]+Q_102010110*R_123[0]+Q_102110010*R_132[0]+-1*Q_102110110*R_133[0]+Q_202010010*R_222[0]+-1*Q_202010110*R_223[0]+-1*Q_202110010*R_232[0]+Q_202110110*R_233[0]; double QR_001011010022=Q_001011010*R_022[0]+-1*Q_001011110*R_023[0]+-1*Q_001111010*R_032[0]+Q_001111110*R_033[0]+Q_001211010*R_042[0]+-1*Q_001211110*R_043[0]+-1*Q_101011010*R_122[0]+Q_101011110*R_123[0]+Q_101111010*R_132[0]+-1*Q_101111110*R_133[0]+-1*Q_101211010*R_142[0]+Q_101211110*R_143[0]; double QR_000012010022=Q_000012010*R_022[0]+-1*Q_000012110*R_023[0]+-1*Q_000112010*R_032[0]+Q_000112110*R_033[0]+Q_000212010*R_042[0]+-1*Q_000212110*R_043[0]+-1*Q_000312010*R_052[0]+Q_000312110*R_053[0]; double QR_001010011022=Q_001010011*R_022[0]+-1*Q_001010111*R_023[0]+Q_001010211*R_024[0]+-1*Q_001110011*R_032[0]+Q_001110111*R_033[0]+-1*Q_001110211*R_034[0]+-1*Q_101010011*R_122[0]+Q_101010111*R_123[0]+-1*Q_101010211*R_124[0]+Q_101110011*R_132[0]+-1*Q_101110111*R_133[0]+Q_101110211*R_134[0]; double QR_000011011022=Q_000011011*R_022[0]+-1*Q_000011111*R_023[0]+Q_000011211*R_024[0]+-1*Q_000111011*R_032[0]+Q_000111111*R_033[0]+-1*Q_000111211*R_034[0]+Q_000211011*R_042[0]+-1*Q_000211111*R_043[0]+Q_000211211*R_044[0]; double QR_000010012022=Q_000010012*R_022[0]+-1*Q_000010112*R_023[0]+Q_000010212*R_024[0]+-1*Q_000010312*R_025[0]+-1*Q_000110012*R_032[0]+Q_000110112*R_033[0]+-1*Q_000110212*R_034[0]+Q_000110312*R_035[0]; double QR_002000020022=Q_002000020*R_022[0]+-1*Q_002000120*R_023[0]+Q_002000220*R_024[0]+-1*Q_102000020*R_122[0]+Q_102000120*R_123[0]+-1*Q_102000220*R_124[0]+Q_202000020*R_222[0]+-1*Q_202000120*R_223[0]+Q_202000220*R_224[0]; double QR_001001020022=Q_001001020*R_022[0]+-1*Q_001001120*R_023[0]+Q_001001220*R_024[0]+-1*Q_001101020*R_032[0]+Q_001101120*R_033[0]+-1*Q_001101220*R_034[0]+-1*Q_101001020*R_122[0]+Q_101001120*R_123[0]+-1*Q_101001220*R_124[0]+Q_101101020*R_132[0]+-1*Q_101101120*R_133[0]+Q_101101220*R_134[0]; double QR_000002020022=Q_000002020*R_022[0]+-1*Q_000002120*R_023[0]+Q_000002220*R_024[0]+-1*Q_000102020*R_032[0]+Q_000102120*R_033[0]+-1*Q_000102220*R_034[0]+Q_000202020*R_042[0]+-1*Q_000202120*R_043[0]+Q_000202220*R_044[0]; double QR_001000021022=Q_001000021*R_022[0]+-1*Q_001000121*R_023[0]+Q_001000221*R_024[0]+-1*Q_001000321*R_025[0]+-1*Q_101000021*R_122[0]+Q_101000121*R_123[0]+-1*Q_101000221*R_124[0]+Q_101000321*R_125[0]; double QR_000001021022=Q_000001021*R_022[0]+-1*Q_000001121*R_023[0]+Q_000001221*R_024[0]+-1*Q_000001321*R_025[0]+-1*Q_000101021*R_032[0]+Q_000101121*R_033[0]+-1*Q_000101221*R_034[0]+Q_000101321*R_035[0]; double QR_000000022022=Q_000000022*R_022[0]+-1*Q_000000122*R_023[0]+Q_000000222*R_024[0]+-1*Q_000000322*R_025[0]+Q_000000422*R_026[0]; double QR_022000000031=Q_022000000*R_031[0]+-1*Q_122000000*R_131[0]+Q_222000000*R_231[0]+-1*Q_322000000*R_331[0]+Q_422000000*R_431[0]; double QR_021001000031=Q_021001000*R_031[0]+-1*Q_021101000*R_041[0]+-1*Q_121001000*R_131[0]+Q_121101000*R_141[0]+Q_221001000*R_231[0]+-1*Q_221101000*R_241[0]+-1*Q_321001000*R_331[0]+Q_321101000*R_341[0]; double QR_020002000031=Q_020002000*R_031[0]+-1*Q_020102000*R_041[0]+Q_020202000*R_051[0]+-1*Q_120002000*R_131[0]+Q_120102000*R_141[0]+-1*Q_120202000*R_151[0]+Q_220002000*R_231[0]+-1*Q_220102000*R_241[0]+Q_220202000*R_251[0]; double QR_021000001031=Q_021000001*R_031[0]+-1*Q_021000101*R_032[0]+-1*Q_121000001*R_131[0]+Q_121000101*R_132[0]+Q_221000001*R_231[0]+-1*Q_221000101*R_232[0]+-1*Q_321000001*R_331[0]+Q_321000101*R_332[0]; double QR_020001001031=Q_020001001*R_031[0]+-1*Q_020001101*R_032[0]+-1*Q_020101001*R_041[0]+Q_020101101*R_042[0]+-1*Q_120001001*R_131[0]+Q_120001101*R_132[0]+Q_120101001*R_141[0]+-1*Q_120101101*R_142[0]+Q_220001001*R_231[0]+-1*Q_220001101*R_232[0]+-1*Q_220101001*R_241[0]+Q_220101101*R_242[0]; double QR_020000002031=Q_020000002*R_031[0]+-1*Q_020000102*R_032[0]+Q_020000202*R_033[0]+-1*Q_120000002*R_131[0]+Q_120000102*R_132[0]+-1*Q_120000202*R_133[0]+Q_220000002*R_231[0]+-1*Q_220000102*R_232[0]+Q_220000202*R_233[0]; double QR_012010000031=Q_012010000*R_031[0]+-1*Q_012110000*R_041[0]+-1*Q_112010000*R_131[0]+Q_112110000*R_141[0]+Q_212010000*R_231[0]+-1*Q_212110000*R_241[0]+-1*Q_312010000*R_331[0]+Q_312110000*R_341[0]; double QR_011011000031=Q_011011000*R_031[0]+-1*Q_011111000*R_041[0]+Q_011211000*R_051[0]+-1*Q_111011000*R_131[0]+Q_111111000*R_141[0]+-1*Q_111211000*R_151[0]+Q_211011000*R_231[0]+-1*Q_211111000*R_241[0]+Q_211211000*R_251[0]; double QR_010012000031=Q_010012000*R_031[0]+-1*Q_010112000*R_041[0]+Q_010212000*R_051[0]+-1*Q_010312000*R_061[0]+-1*Q_110012000*R_131[0]+Q_110112000*R_141[0]+-1*Q_110212000*R_151[0]+Q_110312000*R_161[0]; double QR_011010001031=Q_011010001*R_031[0]+-1*Q_011010101*R_032[0]+-1*Q_011110001*R_041[0]+Q_011110101*R_042[0]+-1*Q_111010001*R_131[0]+Q_111010101*R_132[0]+Q_111110001*R_141[0]+-1*Q_111110101*R_142[0]+Q_211010001*R_231[0]+-1*Q_211010101*R_232[0]+-1*Q_211110001*R_241[0]+Q_211110101*R_242[0]; double QR_010011001031=Q_010011001*R_031[0]+-1*Q_010011101*R_032[0]+-1*Q_010111001*R_041[0]+Q_010111101*R_042[0]+Q_010211001*R_051[0]+-1*Q_010211101*R_052[0]+-1*Q_110011001*R_131[0]+Q_110011101*R_132[0]+Q_110111001*R_141[0]+-1*Q_110111101*R_142[0]+-1*Q_110211001*R_151[0]+Q_110211101*R_152[0]; double QR_010010002031=Q_010010002*R_031[0]+-1*Q_010010102*R_032[0]+Q_010010202*R_033[0]+-1*Q_010110002*R_041[0]+Q_010110102*R_042[0]+-1*Q_010110202*R_043[0]+-1*Q_110010002*R_131[0]+Q_110010102*R_132[0]+-1*Q_110010202*R_133[0]+Q_110110002*R_141[0]+-1*Q_110110102*R_142[0]+Q_110110202*R_143[0]; double QR_002020000031=Q_002020000*R_031[0]+-1*Q_002120000*R_041[0]+Q_002220000*R_051[0]+-1*Q_102020000*R_131[0]+Q_102120000*R_141[0]+-1*Q_102220000*R_151[0]+Q_202020000*R_231[0]+-1*Q_202120000*R_241[0]+Q_202220000*R_251[0]; double QR_001021000031=Q_001021000*R_031[0]+-1*Q_001121000*R_041[0]+Q_001221000*R_051[0]+-1*Q_001321000*R_061[0]+-1*Q_101021000*R_131[0]+Q_101121000*R_141[0]+-1*Q_101221000*R_151[0]+Q_101321000*R_161[0]; double QR_000022000031=Q_000022000*R_031[0]+-1*Q_000122000*R_041[0]+Q_000222000*R_051[0]+-1*Q_000322000*R_061[0]+Q_000422000*R_071[0]; double QR_001020001031=Q_001020001*R_031[0]+-1*Q_001020101*R_032[0]+-1*Q_001120001*R_041[0]+Q_001120101*R_042[0]+Q_001220001*R_051[0]+-1*Q_001220101*R_052[0]+-1*Q_101020001*R_131[0]+Q_101020101*R_132[0]+Q_101120001*R_141[0]+-1*Q_101120101*R_142[0]+-1*Q_101220001*R_151[0]+Q_101220101*R_152[0]; double QR_000021001031=Q_000021001*R_031[0]+-1*Q_000021101*R_032[0]+-1*Q_000121001*R_041[0]+Q_000121101*R_042[0]+Q_000221001*R_051[0]+-1*Q_000221101*R_052[0]+-1*Q_000321001*R_061[0]+Q_000321101*R_062[0]; double QR_000020002031=Q_000020002*R_031[0]+-1*Q_000020102*R_032[0]+Q_000020202*R_033[0]+-1*Q_000120002*R_041[0]+Q_000120102*R_042[0]+-1*Q_000120202*R_043[0]+Q_000220002*R_051[0]+-1*Q_000220102*R_052[0]+Q_000220202*R_053[0]; double QR_012000010031=Q_012000010*R_031[0]+-1*Q_012000110*R_032[0]+-1*Q_112000010*R_131[0]+Q_112000110*R_132[0]+Q_212000010*R_231[0]+-1*Q_212000110*R_232[0]+-1*Q_312000010*R_331[0]+Q_312000110*R_332[0]; double QR_011001010031=Q_011001010*R_031[0]+-1*Q_011001110*R_032[0]+-1*Q_011101010*R_041[0]+Q_011101110*R_042[0]+-1*Q_111001010*R_131[0]+Q_111001110*R_132[0]+Q_111101010*R_141[0]+-1*Q_111101110*R_142[0]+Q_211001010*R_231[0]+-1*Q_211001110*R_232[0]+-1*Q_211101010*R_241[0]+Q_211101110*R_242[0]; double QR_010002010031=Q_010002010*R_031[0]+-1*Q_010002110*R_032[0]+-1*Q_010102010*R_041[0]+Q_010102110*R_042[0]+Q_010202010*R_051[0]+-1*Q_010202110*R_052[0]+-1*Q_110002010*R_131[0]+Q_110002110*R_132[0]+Q_110102010*R_141[0]+-1*Q_110102110*R_142[0]+-1*Q_110202010*R_151[0]+Q_110202110*R_152[0]; double QR_011000011031=Q_011000011*R_031[0]+-1*Q_011000111*R_032[0]+Q_011000211*R_033[0]+-1*Q_111000011*R_131[0]+Q_111000111*R_132[0]+-1*Q_111000211*R_133[0]+Q_211000011*R_231[0]+-1*Q_211000111*R_232[0]+Q_211000211*R_233[0]; double QR_010001011031=Q_010001011*R_031[0]+-1*Q_010001111*R_032[0]+Q_010001211*R_033[0]+-1*Q_010101011*R_041[0]+Q_010101111*R_042[0]+-1*Q_010101211*R_043[0]+-1*Q_110001011*R_131[0]+Q_110001111*R_132[0]+-1*Q_110001211*R_133[0]+Q_110101011*R_141[0]+-1*Q_110101111*R_142[0]+Q_110101211*R_143[0]; double QR_010000012031=Q_010000012*R_031[0]+-1*Q_010000112*R_032[0]+Q_010000212*R_033[0]+-1*Q_010000312*R_034[0]+-1*Q_110000012*R_131[0]+Q_110000112*R_132[0]+-1*Q_110000212*R_133[0]+Q_110000312*R_134[0]; double QR_002010010031=Q_002010010*R_031[0]+-1*Q_002010110*R_032[0]+-1*Q_002110010*R_041[0]+Q_002110110*R_042[0]+-1*Q_102010010*R_131[0]+Q_102010110*R_132[0]+Q_102110010*R_141[0]+-1*Q_102110110*R_142[0]+Q_202010010*R_231[0]+-1*Q_202010110*R_232[0]+-1*Q_202110010*R_241[0]+Q_202110110*R_242[0]; double QR_001011010031=Q_001011010*R_031[0]+-1*Q_001011110*R_032[0]+-1*Q_001111010*R_041[0]+Q_001111110*R_042[0]+Q_001211010*R_051[0]+-1*Q_001211110*R_052[0]+-1*Q_101011010*R_131[0]+Q_101011110*R_132[0]+Q_101111010*R_141[0]+-1*Q_101111110*R_142[0]+-1*Q_101211010*R_151[0]+Q_101211110*R_152[0]; double QR_000012010031=Q_000012010*R_031[0]+-1*Q_000012110*R_032[0]+-1*Q_000112010*R_041[0]+Q_000112110*R_042[0]+Q_000212010*R_051[0]+-1*Q_000212110*R_052[0]+-1*Q_000312010*R_061[0]+Q_000312110*R_062[0]; double QR_001010011031=Q_001010011*R_031[0]+-1*Q_001010111*R_032[0]+Q_001010211*R_033[0]+-1*Q_001110011*R_041[0]+Q_001110111*R_042[0]+-1*Q_001110211*R_043[0]+-1*Q_101010011*R_131[0]+Q_101010111*R_132[0]+-1*Q_101010211*R_133[0]+Q_101110011*R_141[0]+-1*Q_101110111*R_142[0]+Q_101110211*R_143[0]; double QR_000011011031=Q_000011011*R_031[0]+-1*Q_000011111*R_032[0]+Q_000011211*R_033[0]+-1*Q_000111011*R_041[0]+Q_000111111*R_042[0]+-1*Q_000111211*R_043[0]+Q_000211011*R_051[0]+-1*Q_000211111*R_052[0]+Q_000211211*R_053[0]; double QR_000010012031=Q_000010012*R_031[0]+-1*Q_000010112*R_032[0]+Q_000010212*R_033[0]+-1*Q_000010312*R_034[0]+-1*Q_000110012*R_041[0]+Q_000110112*R_042[0]+-1*Q_000110212*R_043[0]+Q_000110312*R_044[0]; double QR_002000020031=Q_002000020*R_031[0]+-1*Q_002000120*R_032[0]+Q_002000220*R_033[0]+-1*Q_102000020*R_131[0]+Q_102000120*R_132[0]+-1*Q_102000220*R_133[0]+Q_202000020*R_231[0]+-1*Q_202000120*R_232[0]+Q_202000220*R_233[0]; double QR_001001020031=Q_001001020*R_031[0]+-1*Q_001001120*R_032[0]+Q_001001220*R_033[0]+-1*Q_001101020*R_041[0]+Q_001101120*R_042[0]+-1*Q_001101220*R_043[0]+-1*Q_101001020*R_131[0]+Q_101001120*R_132[0]+-1*Q_101001220*R_133[0]+Q_101101020*R_141[0]+-1*Q_101101120*R_142[0]+Q_101101220*R_143[0]; double QR_000002020031=Q_000002020*R_031[0]+-1*Q_000002120*R_032[0]+Q_000002220*R_033[0]+-1*Q_000102020*R_041[0]+Q_000102120*R_042[0]+-1*Q_000102220*R_043[0]+Q_000202020*R_051[0]+-1*Q_000202120*R_052[0]+Q_000202220*R_053[0]; double QR_001000021031=Q_001000021*R_031[0]+-1*Q_001000121*R_032[0]+Q_001000221*R_033[0]+-1*Q_001000321*R_034[0]+-1*Q_101000021*R_131[0]+Q_101000121*R_132[0]+-1*Q_101000221*R_133[0]+Q_101000321*R_134[0]; double QR_000001021031=Q_000001021*R_031[0]+-1*Q_000001121*R_032[0]+Q_000001221*R_033[0]+-1*Q_000001321*R_034[0]+-1*Q_000101021*R_041[0]+Q_000101121*R_042[0]+-1*Q_000101221*R_043[0]+Q_000101321*R_044[0]; double QR_000000022031=Q_000000022*R_031[0]+-1*Q_000000122*R_032[0]+Q_000000222*R_033[0]+-1*Q_000000322*R_034[0]+Q_000000422*R_035[0]; double QR_022000000040=Q_022000000*R_040[0]+-1*Q_122000000*R_140[0]+Q_222000000*R_240[0]+-1*Q_322000000*R_340[0]+Q_422000000*R_440[0]; double QR_021001000040=Q_021001000*R_040[0]+-1*Q_021101000*R_050[0]+-1*Q_121001000*R_140[0]+Q_121101000*R_150[0]+Q_221001000*R_240[0]+-1*Q_221101000*R_250[0]+-1*Q_321001000*R_340[0]+Q_321101000*R_350[0]; double QR_020002000040=Q_020002000*R_040[0]+-1*Q_020102000*R_050[0]+Q_020202000*R_060[0]+-1*Q_120002000*R_140[0]+Q_120102000*R_150[0]+-1*Q_120202000*R_160[0]+Q_220002000*R_240[0]+-1*Q_220102000*R_250[0]+Q_220202000*R_260[0]; double QR_021000001040=Q_021000001*R_040[0]+-1*Q_021000101*R_041[0]+-1*Q_121000001*R_140[0]+Q_121000101*R_141[0]+Q_221000001*R_240[0]+-1*Q_221000101*R_241[0]+-1*Q_321000001*R_340[0]+Q_321000101*R_341[0]; double QR_020001001040=Q_020001001*R_040[0]+-1*Q_020001101*R_041[0]+-1*Q_020101001*R_050[0]+Q_020101101*R_051[0]+-1*Q_120001001*R_140[0]+Q_120001101*R_141[0]+Q_120101001*R_150[0]+-1*Q_120101101*R_151[0]+Q_220001001*R_240[0]+-1*Q_220001101*R_241[0]+-1*Q_220101001*R_250[0]+Q_220101101*R_251[0]; double QR_020000002040=Q_020000002*R_040[0]+-1*Q_020000102*R_041[0]+Q_020000202*R_042[0]+-1*Q_120000002*R_140[0]+Q_120000102*R_141[0]+-1*Q_120000202*R_142[0]+Q_220000002*R_240[0]+-1*Q_220000102*R_241[0]+Q_220000202*R_242[0]; double QR_012010000040=Q_012010000*R_040[0]+-1*Q_012110000*R_050[0]+-1*Q_112010000*R_140[0]+Q_112110000*R_150[0]+Q_212010000*R_240[0]+-1*Q_212110000*R_250[0]+-1*Q_312010000*R_340[0]+Q_312110000*R_350[0]; double QR_011011000040=Q_011011000*R_040[0]+-1*Q_011111000*R_050[0]+Q_011211000*R_060[0]+-1*Q_111011000*R_140[0]+Q_111111000*R_150[0]+-1*Q_111211000*R_160[0]+Q_211011000*R_240[0]+-1*Q_211111000*R_250[0]+Q_211211000*R_260[0]; double QR_010012000040=Q_010012000*R_040[0]+-1*Q_010112000*R_050[0]+Q_010212000*R_060[0]+-1*Q_010312000*R_070[0]+-1*Q_110012000*R_140[0]+Q_110112000*R_150[0]+-1*Q_110212000*R_160[0]+Q_110312000*R_170[0]; double QR_011010001040=Q_011010001*R_040[0]+-1*Q_011010101*R_041[0]+-1*Q_011110001*R_050[0]+Q_011110101*R_051[0]+-1*Q_111010001*R_140[0]+Q_111010101*R_141[0]+Q_111110001*R_150[0]+-1*Q_111110101*R_151[0]+Q_211010001*R_240[0]+-1*Q_211010101*R_241[0]+-1*Q_211110001*R_250[0]+Q_211110101*R_251[0]; double QR_010011001040=Q_010011001*R_040[0]+-1*Q_010011101*R_041[0]+-1*Q_010111001*R_050[0]+Q_010111101*R_051[0]+Q_010211001*R_060[0]+-1*Q_010211101*R_061[0]+-1*Q_110011001*R_140[0]+Q_110011101*R_141[0]+Q_110111001*R_150[0]+-1*Q_110111101*R_151[0]+-1*Q_110211001*R_160[0]+Q_110211101*R_161[0]; double QR_010010002040=Q_010010002*R_040[0]+-1*Q_010010102*R_041[0]+Q_010010202*R_042[0]+-1*Q_010110002*R_050[0]+Q_010110102*R_051[0]+-1*Q_010110202*R_052[0]+-1*Q_110010002*R_140[0]+Q_110010102*R_141[0]+-1*Q_110010202*R_142[0]+Q_110110002*R_150[0]+-1*Q_110110102*R_151[0]+Q_110110202*R_152[0]; double QR_002020000040=Q_002020000*R_040[0]+-1*Q_002120000*R_050[0]+Q_002220000*R_060[0]+-1*Q_102020000*R_140[0]+Q_102120000*R_150[0]+-1*Q_102220000*R_160[0]+Q_202020000*R_240[0]+-1*Q_202120000*R_250[0]+Q_202220000*R_260[0]; double QR_001021000040=Q_001021000*R_040[0]+-1*Q_001121000*R_050[0]+Q_001221000*R_060[0]+-1*Q_001321000*R_070[0]+-1*Q_101021000*R_140[0]+Q_101121000*R_150[0]+-1*Q_101221000*R_160[0]+Q_101321000*R_170[0]; double QR_000022000040=Q_000022000*R_040[0]+-1*Q_000122000*R_050[0]+Q_000222000*R_060[0]+-1*Q_000322000*R_070[0]+Q_000422000*R_080[0]; double QR_001020001040=Q_001020001*R_040[0]+-1*Q_001020101*R_041[0]+-1*Q_001120001*R_050[0]+Q_001120101*R_051[0]+Q_001220001*R_060[0]+-1*Q_001220101*R_061[0]+-1*Q_101020001*R_140[0]+Q_101020101*R_141[0]+Q_101120001*R_150[0]+-1*Q_101120101*R_151[0]+-1*Q_101220001*R_160[0]+Q_101220101*R_161[0]; double QR_000021001040=Q_000021001*R_040[0]+-1*Q_000021101*R_041[0]+-1*Q_000121001*R_050[0]+Q_000121101*R_051[0]+Q_000221001*R_060[0]+-1*Q_000221101*R_061[0]+-1*Q_000321001*R_070[0]+Q_000321101*R_071[0]; double QR_000020002040=Q_000020002*R_040[0]+-1*Q_000020102*R_041[0]+Q_000020202*R_042[0]+-1*Q_000120002*R_050[0]+Q_000120102*R_051[0]+-1*Q_000120202*R_052[0]+Q_000220002*R_060[0]+-1*Q_000220102*R_061[0]+Q_000220202*R_062[0]; double QR_012000010040=Q_012000010*R_040[0]+-1*Q_012000110*R_041[0]+-1*Q_112000010*R_140[0]+Q_112000110*R_141[0]+Q_212000010*R_240[0]+-1*Q_212000110*R_241[0]+-1*Q_312000010*R_340[0]+Q_312000110*R_341[0]; double QR_011001010040=Q_011001010*R_040[0]+-1*Q_011001110*R_041[0]+-1*Q_011101010*R_050[0]+Q_011101110*R_051[0]+-1*Q_111001010*R_140[0]+Q_111001110*R_141[0]+Q_111101010*R_150[0]+-1*Q_111101110*R_151[0]+Q_211001010*R_240[0]+-1*Q_211001110*R_241[0]+-1*Q_211101010*R_250[0]+Q_211101110*R_251[0]; double QR_010002010040=Q_010002010*R_040[0]+-1*Q_010002110*R_041[0]+-1*Q_010102010*R_050[0]+Q_010102110*R_051[0]+Q_010202010*R_060[0]+-1*Q_010202110*R_061[0]+-1*Q_110002010*R_140[0]+Q_110002110*R_141[0]+Q_110102010*R_150[0]+-1*Q_110102110*R_151[0]+-1*Q_110202010*R_160[0]+Q_110202110*R_161[0]; double QR_011000011040=Q_011000011*R_040[0]+-1*Q_011000111*R_041[0]+Q_011000211*R_042[0]+-1*Q_111000011*R_140[0]+Q_111000111*R_141[0]+-1*Q_111000211*R_142[0]+Q_211000011*R_240[0]+-1*Q_211000111*R_241[0]+Q_211000211*R_242[0]; double QR_010001011040=Q_010001011*R_040[0]+-1*Q_010001111*R_041[0]+Q_010001211*R_042[0]+-1*Q_010101011*R_050[0]+Q_010101111*R_051[0]+-1*Q_010101211*R_052[0]+-1*Q_110001011*R_140[0]+Q_110001111*R_141[0]+-1*Q_110001211*R_142[0]+Q_110101011*R_150[0]+-1*Q_110101111*R_151[0]+Q_110101211*R_152[0]; double QR_010000012040=Q_010000012*R_040[0]+-1*Q_010000112*R_041[0]+Q_010000212*R_042[0]+-1*Q_010000312*R_043[0]+-1*Q_110000012*R_140[0]+Q_110000112*R_141[0]+-1*Q_110000212*R_142[0]+Q_110000312*R_143[0]; double QR_002010010040=Q_002010010*R_040[0]+-1*Q_002010110*R_041[0]+-1*Q_002110010*R_050[0]+Q_002110110*R_051[0]+-1*Q_102010010*R_140[0]+Q_102010110*R_141[0]+Q_102110010*R_150[0]+-1*Q_102110110*R_151[0]+Q_202010010*R_240[0]+-1*Q_202010110*R_241[0]+-1*Q_202110010*R_250[0]+Q_202110110*R_251[0]; double QR_001011010040=Q_001011010*R_040[0]+-1*Q_001011110*R_041[0]+-1*Q_001111010*R_050[0]+Q_001111110*R_051[0]+Q_001211010*R_060[0]+-1*Q_001211110*R_061[0]+-1*Q_101011010*R_140[0]+Q_101011110*R_141[0]+Q_101111010*R_150[0]+-1*Q_101111110*R_151[0]+-1*Q_101211010*R_160[0]+Q_101211110*R_161[0]; double QR_000012010040=Q_000012010*R_040[0]+-1*Q_000012110*R_041[0]+-1*Q_000112010*R_050[0]+Q_000112110*R_051[0]+Q_000212010*R_060[0]+-1*Q_000212110*R_061[0]+-1*Q_000312010*R_070[0]+Q_000312110*R_071[0]; double QR_001010011040=Q_001010011*R_040[0]+-1*Q_001010111*R_041[0]+Q_001010211*R_042[0]+-1*Q_001110011*R_050[0]+Q_001110111*R_051[0]+-1*Q_001110211*R_052[0]+-1*Q_101010011*R_140[0]+Q_101010111*R_141[0]+-1*Q_101010211*R_142[0]+Q_101110011*R_150[0]+-1*Q_101110111*R_151[0]+Q_101110211*R_152[0]; double QR_000011011040=Q_000011011*R_040[0]+-1*Q_000011111*R_041[0]+Q_000011211*R_042[0]+-1*Q_000111011*R_050[0]+Q_000111111*R_051[0]+-1*Q_000111211*R_052[0]+Q_000211011*R_060[0]+-1*Q_000211111*R_061[0]+Q_000211211*R_062[0]; double QR_000010012040=Q_000010012*R_040[0]+-1*Q_000010112*R_041[0]+Q_000010212*R_042[0]+-1*Q_000010312*R_043[0]+-1*Q_000110012*R_050[0]+Q_000110112*R_051[0]+-1*Q_000110212*R_052[0]+Q_000110312*R_053[0]; double QR_002000020040=Q_002000020*R_040[0]+-1*Q_002000120*R_041[0]+Q_002000220*R_042[0]+-1*Q_102000020*R_140[0]+Q_102000120*R_141[0]+-1*Q_102000220*R_142[0]+Q_202000020*R_240[0]+-1*Q_202000120*R_241[0]+Q_202000220*R_242[0]; double QR_001001020040=Q_001001020*R_040[0]+-1*Q_001001120*R_041[0]+Q_001001220*R_042[0]+-1*Q_001101020*R_050[0]+Q_001101120*R_051[0]+-1*Q_001101220*R_052[0]+-1*Q_101001020*R_140[0]+Q_101001120*R_141[0]+-1*Q_101001220*R_142[0]+Q_101101020*R_150[0]+-1*Q_101101120*R_151[0]+Q_101101220*R_152[0]; double QR_000002020040=Q_000002020*R_040[0]+-1*Q_000002120*R_041[0]+Q_000002220*R_042[0]+-1*Q_000102020*R_050[0]+Q_000102120*R_051[0]+-1*Q_000102220*R_052[0]+Q_000202020*R_060[0]+-1*Q_000202120*R_061[0]+Q_000202220*R_062[0]; double QR_001000021040=Q_001000021*R_040[0]+-1*Q_001000121*R_041[0]+Q_001000221*R_042[0]+-1*Q_001000321*R_043[0]+-1*Q_101000021*R_140[0]+Q_101000121*R_141[0]+-1*Q_101000221*R_142[0]+Q_101000321*R_143[0]; double QR_000001021040=Q_000001021*R_040[0]+-1*Q_000001121*R_041[0]+Q_000001221*R_042[0]+-1*Q_000001321*R_043[0]+-1*Q_000101021*R_050[0]+Q_000101121*R_051[0]+-1*Q_000101221*R_052[0]+Q_000101321*R_053[0]; double QR_000000022040=Q_000000022*R_040[0]+-1*Q_000000122*R_041[0]+Q_000000222*R_042[0]+-1*Q_000000322*R_043[0]+Q_000000422*R_044[0]; double QR_022000000103=Q_022000000*R_103[0]+-1*Q_122000000*R_203[0]+Q_222000000*R_303[0]+-1*Q_322000000*R_403[0]+Q_422000000*R_503[0]; double QR_021001000103=Q_021001000*R_103[0]+-1*Q_021101000*R_113[0]+-1*Q_121001000*R_203[0]+Q_121101000*R_213[0]+Q_221001000*R_303[0]+-1*Q_221101000*R_313[0]+-1*Q_321001000*R_403[0]+Q_321101000*R_413[0]; double QR_020002000103=Q_020002000*R_103[0]+-1*Q_020102000*R_113[0]+Q_020202000*R_123[0]+-1*Q_120002000*R_203[0]+Q_120102000*R_213[0]+-1*Q_120202000*R_223[0]+Q_220002000*R_303[0]+-1*Q_220102000*R_313[0]+Q_220202000*R_323[0]; double QR_021000001103=Q_021000001*R_103[0]+-1*Q_021000101*R_104[0]+-1*Q_121000001*R_203[0]+Q_121000101*R_204[0]+Q_221000001*R_303[0]+-1*Q_221000101*R_304[0]+-1*Q_321000001*R_403[0]+Q_321000101*R_404[0]; double QR_020001001103=Q_020001001*R_103[0]+-1*Q_020001101*R_104[0]+-1*Q_020101001*R_113[0]+Q_020101101*R_114[0]+-1*Q_120001001*R_203[0]+Q_120001101*R_204[0]+Q_120101001*R_213[0]+-1*Q_120101101*R_214[0]+Q_220001001*R_303[0]+-1*Q_220001101*R_304[0]+-1*Q_220101001*R_313[0]+Q_220101101*R_314[0]; double QR_020000002103=Q_020000002*R_103[0]+-1*Q_020000102*R_104[0]+Q_020000202*R_105[0]+-1*Q_120000002*R_203[0]+Q_120000102*R_204[0]+-1*Q_120000202*R_205[0]+Q_220000002*R_303[0]+-1*Q_220000102*R_304[0]+Q_220000202*R_305[0]; double QR_012010000103=Q_012010000*R_103[0]+-1*Q_012110000*R_113[0]+-1*Q_112010000*R_203[0]+Q_112110000*R_213[0]+Q_212010000*R_303[0]+-1*Q_212110000*R_313[0]+-1*Q_312010000*R_403[0]+Q_312110000*R_413[0]; double QR_011011000103=Q_011011000*R_103[0]+-1*Q_011111000*R_113[0]+Q_011211000*R_123[0]+-1*Q_111011000*R_203[0]+Q_111111000*R_213[0]+-1*Q_111211000*R_223[0]+Q_211011000*R_303[0]+-1*Q_211111000*R_313[0]+Q_211211000*R_323[0]; double QR_010012000103=Q_010012000*R_103[0]+-1*Q_010112000*R_113[0]+Q_010212000*R_123[0]+-1*Q_010312000*R_133[0]+-1*Q_110012000*R_203[0]+Q_110112000*R_213[0]+-1*Q_110212000*R_223[0]+Q_110312000*R_233[0]; double QR_011010001103=Q_011010001*R_103[0]+-1*Q_011010101*R_104[0]+-1*Q_011110001*R_113[0]+Q_011110101*R_114[0]+-1*Q_111010001*R_203[0]+Q_111010101*R_204[0]+Q_111110001*R_213[0]+-1*Q_111110101*R_214[0]+Q_211010001*R_303[0]+-1*Q_211010101*R_304[0]+-1*Q_211110001*R_313[0]+Q_211110101*R_314[0]; double QR_010011001103=Q_010011001*R_103[0]+-1*Q_010011101*R_104[0]+-1*Q_010111001*R_113[0]+Q_010111101*R_114[0]+Q_010211001*R_123[0]+-1*Q_010211101*R_124[0]+-1*Q_110011001*R_203[0]+Q_110011101*R_204[0]+Q_110111001*R_213[0]+-1*Q_110111101*R_214[0]+-1*Q_110211001*R_223[0]+Q_110211101*R_224[0]; double QR_010010002103=Q_010010002*R_103[0]+-1*Q_010010102*R_104[0]+Q_010010202*R_105[0]+-1*Q_010110002*R_113[0]+Q_010110102*R_114[0]+-1*Q_010110202*R_115[0]+-1*Q_110010002*R_203[0]+Q_110010102*R_204[0]+-1*Q_110010202*R_205[0]+Q_110110002*R_213[0]+-1*Q_110110102*R_214[0]+Q_110110202*R_215[0]; double QR_002020000103=Q_002020000*R_103[0]+-1*Q_002120000*R_113[0]+Q_002220000*R_123[0]+-1*Q_102020000*R_203[0]+Q_102120000*R_213[0]+-1*Q_102220000*R_223[0]+Q_202020000*R_303[0]+-1*Q_202120000*R_313[0]+Q_202220000*R_323[0]; double QR_001021000103=Q_001021000*R_103[0]+-1*Q_001121000*R_113[0]+Q_001221000*R_123[0]+-1*Q_001321000*R_133[0]+-1*Q_101021000*R_203[0]+Q_101121000*R_213[0]+-1*Q_101221000*R_223[0]+Q_101321000*R_233[0]; double QR_000022000103=Q_000022000*R_103[0]+-1*Q_000122000*R_113[0]+Q_000222000*R_123[0]+-1*Q_000322000*R_133[0]+Q_000422000*R_143[0]; double QR_001020001103=Q_001020001*R_103[0]+-1*Q_001020101*R_104[0]+-1*Q_001120001*R_113[0]+Q_001120101*R_114[0]+Q_001220001*R_123[0]+-1*Q_001220101*R_124[0]+-1*Q_101020001*R_203[0]+Q_101020101*R_204[0]+Q_101120001*R_213[0]+-1*Q_101120101*R_214[0]+-1*Q_101220001*R_223[0]+Q_101220101*R_224[0]; double QR_000021001103=Q_000021001*R_103[0]+-1*Q_000021101*R_104[0]+-1*Q_000121001*R_113[0]+Q_000121101*R_114[0]+Q_000221001*R_123[0]+-1*Q_000221101*R_124[0]+-1*Q_000321001*R_133[0]+Q_000321101*R_134[0]; double QR_000020002103=Q_000020002*R_103[0]+-1*Q_000020102*R_104[0]+Q_000020202*R_105[0]+-1*Q_000120002*R_113[0]+Q_000120102*R_114[0]+-1*Q_000120202*R_115[0]+Q_000220002*R_123[0]+-1*Q_000220102*R_124[0]+Q_000220202*R_125[0]; double QR_012000010103=Q_012000010*R_103[0]+-1*Q_012000110*R_104[0]+-1*Q_112000010*R_203[0]+Q_112000110*R_204[0]+Q_212000010*R_303[0]+-1*Q_212000110*R_304[0]+-1*Q_312000010*R_403[0]+Q_312000110*R_404[0]; double QR_011001010103=Q_011001010*R_103[0]+-1*Q_011001110*R_104[0]+-1*Q_011101010*R_113[0]+Q_011101110*R_114[0]+-1*Q_111001010*R_203[0]+Q_111001110*R_204[0]+Q_111101010*R_213[0]+-1*Q_111101110*R_214[0]+Q_211001010*R_303[0]+-1*Q_211001110*R_304[0]+-1*Q_211101010*R_313[0]+Q_211101110*R_314[0]; double QR_010002010103=Q_010002010*R_103[0]+-1*Q_010002110*R_104[0]+-1*Q_010102010*R_113[0]+Q_010102110*R_114[0]+Q_010202010*R_123[0]+-1*Q_010202110*R_124[0]+-1*Q_110002010*R_203[0]+Q_110002110*R_204[0]+Q_110102010*R_213[0]+-1*Q_110102110*R_214[0]+-1*Q_110202010*R_223[0]+Q_110202110*R_224[0]; double QR_011000011103=Q_011000011*R_103[0]+-1*Q_011000111*R_104[0]+Q_011000211*R_105[0]+-1*Q_111000011*R_203[0]+Q_111000111*R_204[0]+-1*Q_111000211*R_205[0]+Q_211000011*R_303[0]+-1*Q_211000111*R_304[0]+Q_211000211*R_305[0]; double QR_010001011103=Q_010001011*R_103[0]+-1*Q_010001111*R_104[0]+Q_010001211*R_105[0]+-1*Q_010101011*R_113[0]+Q_010101111*R_114[0]+-1*Q_010101211*R_115[0]+-1*Q_110001011*R_203[0]+Q_110001111*R_204[0]+-1*Q_110001211*R_205[0]+Q_110101011*R_213[0]+-1*Q_110101111*R_214[0]+Q_110101211*R_215[0]; double QR_010000012103=Q_010000012*R_103[0]+-1*Q_010000112*R_104[0]+Q_010000212*R_105[0]+-1*Q_010000312*R_106[0]+-1*Q_110000012*R_203[0]+Q_110000112*R_204[0]+-1*Q_110000212*R_205[0]+Q_110000312*R_206[0]; double QR_002010010103=Q_002010010*R_103[0]+-1*Q_002010110*R_104[0]+-1*Q_002110010*R_113[0]+Q_002110110*R_114[0]+-1*Q_102010010*R_203[0]+Q_102010110*R_204[0]+Q_102110010*R_213[0]+-1*Q_102110110*R_214[0]+Q_202010010*R_303[0]+-1*Q_202010110*R_304[0]+-1*Q_202110010*R_313[0]+Q_202110110*R_314[0]; double QR_001011010103=Q_001011010*R_103[0]+-1*Q_001011110*R_104[0]+-1*Q_001111010*R_113[0]+Q_001111110*R_114[0]+Q_001211010*R_123[0]+-1*Q_001211110*R_124[0]+-1*Q_101011010*R_203[0]+Q_101011110*R_204[0]+Q_101111010*R_213[0]+-1*Q_101111110*R_214[0]+-1*Q_101211010*R_223[0]+Q_101211110*R_224[0]; double QR_000012010103=Q_000012010*R_103[0]+-1*Q_000012110*R_104[0]+-1*Q_000112010*R_113[0]+Q_000112110*R_114[0]+Q_000212010*R_123[0]+-1*Q_000212110*R_124[0]+-1*Q_000312010*R_133[0]+Q_000312110*R_134[0]; double QR_001010011103=Q_001010011*R_103[0]+-1*Q_001010111*R_104[0]+Q_001010211*R_105[0]+-1*Q_001110011*R_113[0]+Q_001110111*R_114[0]+-1*Q_001110211*R_115[0]+-1*Q_101010011*R_203[0]+Q_101010111*R_204[0]+-1*Q_101010211*R_205[0]+Q_101110011*R_213[0]+-1*Q_101110111*R_214[0]+Q_101110211*R_215[0]; double QR_000011011103=Q_000011011*R_103[0]+-1*Q_000011111*R_104[0]+Q_000011211*R_105[0]+-1*Q_000111011*R_113[0]+Q_000111111*R_114[0]+-1*Q_000111211*R_115[0]+Q_000211011*R_123[0]+-1*Q_000211111*R_124[0]+Q_000211211*R_125[0]; double QR_000010012103=Q_000010012*R_103[0]+-1*Q_000010112*R_104[0]+Q_000010212*R_105[0]+-1*Q_000010312*R_106[0]+-1*Q_000110012*R_113[0]+Q_000110112*R_114[0]+-1*Q_000110212*R_115[0]+Q_000110312*R_116[0]; double QR_002000020103=Q_002000020*R_103[0]+-1*Q_002000120*R_104[0]+Q_002000220*R_105[0]+-1*Q_102000020*R_203[0]+Q_102000120*R_204[0]+-1*Q_102000220*R_205[0]+Q_202000020*R_303[0]+-1*Q_202000120*R_304[0]+Q_202000220*R_305[0]; double QR_001001020103=Q_001001020*R_103[0]+-1*Q_001001120*R_104[0]+Q_001001220*R_105[0]+-1*Q_001101020*R_113[0]+Q_001101120*R_114[0]+-1*Q_001101220*R_115[0]+-1*Q_101001020*R_203[0]+Q_101001120*R_204[0]+-1*Q_101001220*R_205[0]+Q_101101020*R_213[0]+-1*Q_101101120*R_214[0]+Q_101101220*R_215[0]; double QR_000002020103=Q_000002020*R_103[0]+-1*Q_000002120*R_104[0]+Q_000002220*R_105[0]+-1*Q_000102020*R_113[0]+Q_000102120*R_114[0]+-1*Q_000102220*R_115[0]+Q_000202020*R_123[0]+-1*Q_000202120*R_124[0]+Q_000202220*R_125[0]; double QR_001000021103=Q_001000021*R_103[0]+-1*Q_001000121*R_104[0]+Q_001000221*R_105[0]+-1*Q_001000321*R_106[0]+-1*Q_101000021*R_203[0]+Q_101000121*R_204[0]+-1*Q_101000221*R_205[0]+Q_101000321*R_206[0]; double QR_000001021103=Q_000001021*R_103[0]+-1*Q_000001121*R_104[0]+Q_000001221*R_105[0]+-1*Q_000001321*R_106[0]+-1*Q_000101021*R_113[0]+Q_000101121*R_114[0]+-1*Q_000101221*R_115[0]+Q_000101321*R_116[0]; double QR_000000022103=Q_000000022*R_103[0]+-1*Q_000000122*R_104[0]+Q_000000222*R_105[0]+-1*Q_000000322*R_106[0]+Q_000000422*R_107[0]; double QR_022000000112=Q_022000000*R_112[0]+-1*Q_122000000*R_212[0]+Q_222000000*R_312[0]+-1*Q_322000000*R_412[0]+Q_422000000*R_512[0]; double QR_021001000112=Q_021001000*R_112[0]+-1*Q_021101000*R_122[0]+-1*Q_121001000*R_212[0]+Q_121101000*R_222[0]+Q_221001000*R_312[0]+-1*Q_221101000*R_322[0]+-1*Q_321001000*R_412[0]+Q_321101000*R_422[0]; double QR_020002000112=Q_020002000*R_112[0]+-1*Q_020102000*R_122[0]+Q_020202000*R_132[0]+-1*Q_120002000*R_212[0]+Q_120102000*R_222[0]+-1*Q_120202000*R_232[0]+Q_220002000*R_312[0]+-1*Q_220102000*R_322[0]+Q_220202000*R_332[0]; double QR_021000001112=Q_021000001*R_112[0]+-1*Q_021000101*R_113[0]+-1*Q_121000001*R_212[0]+Q_121000101*R_213[0]+Q_221000001*R_312[0]+-1*Q_221000101*R_313[0]+-1*Q_321000001*R_412[0]+Q_321000101*R_413[0]; double QR_020001001112=Q_020001001*R_112[0]+-1*Q_020001101*R_113[0]+-1*Q_020101001*R_122[0]+Q_020101101*R_123[0]+-1*Q_120001001*R_212[0]+Q_120001101*R_213[0]+Q_120101001*R_222[0]+-1*Q_120101101*R_223[0]+Q_220001001*R_312[0]+-1*Q_220001101*R_313[0]+-1*Q_220101001*R_322[0]+Q_220101101*R_323[0]; double QR_020000002112=Q_020000002*R_112[0]+-1*Q_020000102*R_113[0]+Q_020000202*R_114[0]+-1*Q_120000002*R_212[0]+Q_120000102*R_213[0]+-1*Q_120000202*R_214[0]+Q_220000002*R_312[0]+-1*Q_220000102*R_313[0]+Q_220000202*R_314[0]; double QR_012010000112=Q_012010000*R_112[0]+-1*Q_012110000*R_122[0]+-1*Q_112010000*R_212[0]+Q_112110000*R_222[0]+Q_212010000*R_312[0]+-1*Q_212110000*R_322[0]+-1*Q_312010000*R_412[0]+Q_312110000*R_422[0]; double QR_011011000112=Q_011011000*R_112[0]+-1*Q_011111000*R_122[0]+Q_011211000*R_132[0]+-1*Q_111011000*R_212[0]+Q_111111000*R_222[0]+-1*Q_111211000*R_232[0]+Q_211011000*R_312[0]+-1*Q_211111000*R_322[0]+Q_211211000*R_332[0]; double QR_010012000112=Q_010012000*R_112[0]+-1*Q_010112000*R_122[0]+Q_010212000*R_132[0]+-1*Q_010312000*R_142[0]+-1*Q_110012000*R_212[0]+Q_110112000*R_222[0]+-1*Q_110212000*R_232[0]+Q_110312000*R_242[0]; double QR_011010001112=Q_011010001*R_112[0]+-1*Q_011010101*R_113[0]+-1*Q_011110001*R_122[0]+Q_011110101*R_123[0]+-1*Q_111010001*R_212[0]+Q_111010101*R_213[0]+Q_111110001*R_222[0]+-1*Q_111110101*R_223[0]+Q_211010001*R_312[0]+-1*Q_211010101*R_313[0]+-1*Q_211110001*R_322[0]+Q_211110101*R_323[0]; double QR_010011001112=Q_010011001*R_112[0]+-1*Q_010011101*R_113[0]+-1*Q_010111001*R_122[0]+Q_010111101*R_123[0]+Q_010211001*R_132[0]+-1*Q_010211101*R_133[0]+-1*Q_110011001*R_212[0]+Q_110011101*R_213[0]+Q_110111001*R_222[0]+-1*Q_110111101*R_223[0]+-1*Q_110211001*R_232[0]+Q_110211101*R_233[0]; double QR_010010002112=Q_010010002*R_112[0]+-1*Q_010010102*R_113[0]+Q_010010202*R_114[0]+-1*Q_010110002*R_122[0]+Q_010110102*R_123[0]+-1*Q_010110202*R_124[0]+-1*Q_110010002*R_212[0]+Q_110010102*R_213[0]+-1*Q_110010202*R_214[0]+Q_110110002*R_222[0]+-1*Q_110110102*R_223[0]+Q_110110202*R_224[0]; double QR_002020000112=Q_002020000*R_112[0]+-1*Q_002120000*R_122[0]+Q_002220000*R_132[0]+-1*Q_102020000*R_212[0]+Q_102120000*R_222[0]+-1*Q_102220000*R_232[0]+Q_202020000*R_312[0]+-1*Q_202120000*R_322[0]+Q_202220000*R_332[0]; double QR_001021000112=Q_001021000*R_112[0]+-1*Q_001121000*R_122[0]+Q_001221000*R_132[0]+-1*Q_001321000*R_142[0]+-1*Q_101021000*R_212[0]+Q_101121000*R_222[0]+-1*Q_101221000*R_232[0]+Q_101321000*R_242[0]; double QR_000022000112=Q_000022000*R_112[0]+-1*Q_000122000*R_122[0]+Q_000222000*R_132[0]+-1*Q_000322000*R_142[0]+Q_000422000*R_152[0]; double QR_001020001112=Q_001020001*R_112[0]+-1*Q_001020101*R_113[0]+-1*Q_001120001*R_122[0]+Q_001120101*R_123[0]+Q_001220001*R_132[0]+-1*Q_001220101*R_133[0]+-1*Q_101020001*R_212[0]+Q_101020101*R_213[0]+Q_101120001*R_222[0]+-1*Q_101120101*R_223[0]+-1*Q_101220001*R_232[0]+Q_101220101*R_233[0]; double QR_000021001112=Q_000021001*R_112[0]+-1*Q_000021101*R_113[0]+-1*Q_000121001*R_122[0]+Q_000121101*R_123[0]+Q_000221001*R_132[0]+-1*Q_000221101*R_133[0]+-1*Q_000321001*R_142[0]+Q_000321101*R_143[0]; double QR_000020002112=Q_000020002*R_112[0]+-1*Q_000020102*R_113[0]+Q_000020202*R_114[0]+-1*Q_000120002*R_122[0]+Q_000120102*R_123[0]+-1*Q_000120202*R_124[0]+Q_000220002*R_132[0]+-1*Q_000220102*R_133[0]+Q_000220202*R_134[0]; double QR_012000010112=Q_012000010*R_112[0]+-1*Q_012000110*R_113[0]+-1*Q_112000010*R_212[0]+Q_112000110*R_213[0]+Q_212000010*R_312[0]+-1*Q_212000110*R_313[0]+-1*Q_312000010*R_412[0]+Q_312000110*R_413[0]; double QR_011001010112=Q_011001010*R_112[0]+-1*Q_011001110*R_113[0]+-1*Q_011101010*R_122[0]+Q_011101110*R_123[0]+-1*Q_111001010*R_212[0]+Q_111001110*R_213[0]+Q_111101010*R_222[0]+-1*Q_111101110*R_223[0]+Q_211001010*R_312[0]+-1*Q_211001110*R_313[0]+-1*Q_211101010*R_322[0]+Q_211101110*R_323[0]; double QR_010002010112=Q_010002010*R_112[0]+-1*Q_010002110*R_113[0]+-1*Q_010102010*R_122[0]+Q_010102110*R_123[0]+Q_010202010*R_132[0]+-1*Q_010202110*R_133[0]+-1*Q_110002010*R_212[0]+Q_110002110*R_213[0]+Q_110102010*R_222[0]+-1*Q_110102110*R_223[0]+-1*Q_110202010*R_232[0]+Q_110202110*R_233[0]; double QR_011000011112=Q_011000011*R_112[0]+-1*Q_011000111*R_113[0]+Q_011000211*R_114[0]+-1*Q_111000011*R_212[0]+Q_111000111*R_213[0]+-1*Q_111000211*R_214[0]+Q_211000011*R_312[0]+-1*Q_211000111*R_313[0]+Q_211000211*R_314[0]; double QR_010001011112=Q_010001011*R_112[0]+-1*Q_010001111*R_113[0]+Q_010001211*R_114[0]+-1*Q_010101011*R_122[0]+Q_010101111*R_123[0]+-1*Q_010101211*R_124[0]+-1*Q_110001011*R_212[0]+Q_110001111*R_213[0]+-1*Q_110001211*R_214[0]+Q_110101011*R_222[0]+-1*Q_110101111*R_223[0]+Q_110101211*R_224[0]; double QR_010000012112=Q_010000012*R_112[0]+-1*Q_010000112*R_113[0]+Q_010000212*R_114[0]+-1*Q_010000312*R_115[0]+-1*Q_110000012*R_212[0]+Q_110000112*R_213[0]+-1*Q_110000212*R_214[0]+Q_110000312*R_215[0]; double QR_002010010112=Q_002010010*R_112[0]+-1*Q_002010110*R_113[0]+-1*Q_002110010*R_122[0]+Q_002110110*R_123[0]+-1*Q_102010010*R_212[0]+Q_102010110*R_213[0]+Q_102110010*R_222[0]+-1*Q_102110110*R_223[0]+Q_202010010*R_312[0]+-1*Q_202010110*R_313[0]+-1*Q_202110010*R_322[0]+Q_202110110*R_323[0]; double QR_001011010112=Q_001011010*R_112[0]+-1*Q_001011110*R_113[0]+-1*Q_001111010*R_122[0]+Q_001111110*R_123[0]+Q_001211010*R_132[0]+-1*Q_001211110*R_133[0]+-1*Q_101011010*R_212[0]+Q_101011110*R_213[0]+Q_101111010*R_222[0]+-1*Q_101111110*R_223[0]+-1*Q_101211010*R_232[0]+Q_101211110*R_233[0]; double QR_000012010112=Q_000012010*R_112[0]+-1*Q_000012110*R_113[0]+-1*Q_000112010*R_122[0]+Q_000112110*R_123[0]+Q_000212010*R_132[0]+-1*Q_000212110*R_133[0]+-1*Q_000312010*R_142[0]+Q_000312110*R_143[0]; double QR_001010011112=Q_001010011*R_112[0]+-1*Q_001010111*R_113[0]+Q_001010211*R_114[0]+-1*Q_001110011*R_122[0]+Q_001110111*R_123[0]+-1*Q_001110211*R_124[0]+-1*Q_101010011*R_212[0]+Q_101010111*R_213[0]+-1*Q_101010211*R_214[0]+Q_101110011*R_222[0]+-1*Q_101110111*R_223[0]+Q_101110211*R_224[0]; double QR_000011011112=Q_000011011*R_112[0]+-1*Q_000011111*R_113[0]+Q_000011211*R_114[0]+-1*Q_000111011*R_122[0]+Q_000111111*R_123[0]+-1*Q_000111211*R_124[0]+Q_000211011*R_132[0]+-1*Q_000211111*R_133[0]+Q_000211211*R_134[0]; double QR_000010012112=Q_000010012*R_112[0]+-1*Q_000010112*R_113[0]+Q_000010212*R_114[0]+-1*Q_000010312*R_115[0]+-1*Q_000110012*R_122[0]+Q_000110112*R_123[0]+-1*Q_000110212*R_124[0]+Q_000110312*R_125[0]; double QR_002000020112=Q_002000020*R_112[0]+-1*Q_002000120*R_113[0]+Q_002000220*R_114[0]+-1*Q_102000020*R_212[0]+Q_102000120*R_213[0]+-1*Q_102000220*R_214[0]+Q_202000020*R_312[0]+-1*Q_202000120*R_313[0]+Q_202000220*R_314[0]; double QR_001001020112=Q_001001020*R_112[0]+-1*Q_001001120*R_113[0]+Q_001001220*R_114[0]+-1*Q_001101020*R_122[0]+Q_001101120*R_123[0]+-1*Q_001101220*R_124[0]+-1*Q_101001020*R_212[0]+Q_101001120*R_213[0]+-1*Q_101001220*R_214[0]+Q_101101020*R_222[0]+-1*Q_101101120*R_223[0]+Q_101101220*R_224[0]; double QR_000002020112=Q_000002020*R_112[0]+-1*Q_000002120*R_113[0]+Q_000002220*R_114[0]+-1*Q_000102020*R_122[0]+Q_000102120*R_123[0]+-1*Q_000102220*R_124[0]+Q_000202020*R_132[0]+-1*Q_000202120*R_133[0]+Q_000202220*R_134[0]; double QR_001000021112=Q_001000021*R_112[0]+-1*Q_001000121*R_113[0]+Q_001000221*R_114[0]+-1*Q_001000321*R_115[0]+-1*Q_101000021*R_212[0]+Q_101000121*R_213[0]+-1*Q_101000221*R_214[0]+Q_101000321*R_215[0]; double QR_000001021112=Q_000001021*R_112[0]+-1*Q_000001121*R_113[0]+Q_000001221*R_114[0]+-1*Q_000001321*R_115[0]+-1*Q_000101021*R_122[0]+Q_000101121*R_123[0]+-1*Q_000101221*R_124[0]+Q_000101321*R_125[0]; double QR_000000022112=Q_000000022*R_112[0]+-1*Q_000000122*R_113[0]+Q_000000222*R_114[0]+-1*Q_000000322*R_115[0]+Q_000000422*R_116[0]; double QR_022000000121=Q_022000000*R_121[0]+-1*Q_122000000*R_221[0]+Q_222000000*R_321[0]+-1*Q_322000000*R_421[0]+Q_422000000*R_521[0]; double QR_021001000121=Q_021001000*R_121[0]+-1*Q_021101000*R_131[0]+-1*Q_121001000*R_221[0]+Q_121101000*R_231[0]+Q_221001000*R_321[0]+-1*Q_221101000*R_331[0]+-1*Q_321001000*R_421[0]+Q_321101000*R_431[0]; double QR_020002000121=Q_020002000*R_121[0]+-1*Q_020102000*R_131[0]+Q_020202000*R_141[0]+-1*Q_120002000*R_221[0]+Q_120102000*R_231[0]+-1*Q_120202000*R_241[0]+Q_220002000*R_321[0]+-1*Q_220102000*R_331[0]+Q_220202000*R_341[0]; double QR_021000001121=Q_021000001*R_121[0]+-1*Q_021000101*R_122[0]+-1*Q_121000001*R_221[0]+Q_121000101*R_222[0]+Q_221000001*R_321[0]+-1*Q_221000101*R_322[0]+-1*Q_321000001*R_421[0]+Q_321000101*R_422[0]; double QR_020001001121=Q_020001001*R_121[0]+-1*Q_020001101*R_122[0]+-1*Q_020101001*R_131[0]+Q_020101101*R_132[0]+-1*Q_120001001*R_221[0]+Q_120001101*R_222[0]+Q_120101001*R_231[0]+-1*Q_120101101*R_232[0]+Q_220001001*R_321[0]+-1*Q_220001101*R_322[0]+-1*Q_220101001*R_331[0]+Q_220101101*R_332[0]; double QR_020000002121=Q_020000002*R_121[0]+-1*Q_020000102*R_122[0]+Q_020000202*R_123[0]+-1*Q_120000002*R_221[0]+Q_120000102*R_222[0]+-1*Q_120000202*R_223[0]+Q_220000002*R_321[0]+-1*Q_220000102*R_322[0]+Q_220000202*R_323[0]; double QR_012010000121=Q_012010000*R_121[0]+-1*Q_012110000*R_131[0]+-1*Q_112010000*R_221[0]+Q_112110000*R_231[0]+Q_212010000*R_321[0]+-1*Q_212110000*R_331[0]+-1*Q_312010000*R_421[0]+Q_312110000*R_431[0]; double QR_011011000121=Q_011011000*R_121[0]+-1*Q_011111000*R_131[0]+Q_011211000*R_141[0]+-1*Q_111011000*R_221[0]+Q_111111000*R_231[0]+-1*Q_111211000*R_241[0]+Q_211011000*R_321[0]+-1*Q_211111000*R_331[0]+Q_211211000*R_341[0]; double QR_010012000121=Q_010012000*R_121[0]+-1*Q_010112000*R_131[0]+Q_010212000*R_141[0]+-1*Q_010312000*R_151[0]+-1*Q_110012000*R_221[0]+Q_110112000*R_231[0]+-1*Q_110212000*R_241[0]+Q_110312000*R_251[0]; double QR_011010001121=Q_011010001*R_121[0]+-1*Q_011010101*R_122[0]+-1*Q_011110001*R_131[0]+Q_011110101*R_132[0]+-1*Q_111010001*R_221[0]+Q_111010101*R_222[0]+Q_111110001*R_231[0]+-1*Q_111110101*R_232[0]+Q_211010001*R_321[0]+-1*Q_211010101*R_322[0]+-1*Q_211110001*R_331[0]+Q_211110101*R_332[0]; double QR_010011001121=Q_010011001*R_121[0]+-1*Q_010011101*R_122[0]+-1*Q_010111001*R_131[0]+Q_010111101*R_132[0]+Q_010211001*R_141[0]+-1*Q_010211101*R_142[0]+-1*Q_110011001*R_221[0]+Q_110011101*R_222[0]+Q_110111001*R_231[0]+-1*Q_110111101*R_232[0]+-1*Q_110211001*R_241[0]+Q_110211101*R_242[0]; double QR_010010002121=Q_010010002*R_121[0]+-1*Q_010010102*R_122[0]+Q_010010202*R_123[0]+-1*Q_010110002*R_131[0]+Q_010110102*R_132[0]+-1*Q_010110202*R_133[0]+-1*Q_110010002*R_221[0]+Q_110010102*R_222[0]+-1*Q_110010202*R_223[0]+Q_110110002*R_231[0]+-1*Q_110110102*R_232[0]+Q_110110202*R_233[0]; double QR_002020000121=Q_002020000*R_121[0]+-1*Q_002120000*R_131[0]+Q_002220000*R_141[0]+-1*Q_102020000*R_221[0]+Q_102120000*R_231[0]+-1*Q_102220000*R_241[0]+Q_202020000*R_321[0]+-1*Q_202120000*R_331[0]+Q_202220000*R_341[0]; double QR_001021000121=Q_001021000*R_121[0]+-1*Q_001121000*R_131[0]+Q_001221000*R_141[0]+-1*Q_001321000*R_151[0]+-1*Q_101021000*R_221[0]+Q_101121000*R_231[0]+-1*Q_101221000*R_241[0]+Q_101321000*R_251[0]; double QR_000022000121=Q_000022000*R_121[0]+-1*Q_000122000*R_131[0]+Q_000222000*R_141[0]+-1*Q_000322000*R_151[0]+Q_000422000*R_161[0]; double QR_001020001121=Q_001020001*R_121[0]+-1*Q_001020101*R_122[0]+-1*Q_001120001*R_131[0]+Q_001120101*R_132[0]+Q_001220001*R_141[0]+-1*Q_001220101*R_142[0]+-1*Q_101020001*R_221[0]+Q_101020101*R_222[0]+Q_101120001*R_231[0]+-1*Q_101120101*R_232[0]+-1*Q_101220001*R_241[0]+Q_101220101*R_242[0]; double QR_000021001121=Q_000021001*R_121[0]+-1*Q_000021101*R_122[0]+-1*Q_000121001*R_131[0]+Q_000121101*R_132[0]+Q_000221001*R_141[0]+-1*Q_000221101*R_142[0]+-1*Q_000321001*R_151[0]+Q_000321101*R_152[0]; double QR_000020002121=Q_000020002*R_121[0]+-1*Q_000020102*R_122[0]+Q_000020202*R_123[0]+-1*Q_000120002*R_131[0]+Q_000120102*R_132[0]+-1*Q_000120202*R_133[0]+Q_000220002*R_141[0]+-1*Q_000220102*R_142[0]+Q_000220202*R_143[0]; double QR_012000010121=Q_012000010*R_121[0]+-1*Q_012000110*R_122[0]+-1*Q_112000010*R_221[0]+Q_112000110*R_222[0]+Q_212000010*R_321[0]+-1*Q_212000110*R_322[0]+-1*Q_312000010*R_421[0]+Q_312000110*R_422[0]; double QR_011001010121=Q_011001010*R_121[0]+-1*Q_011001110*R_122[0]+-1*Q_011101010*R_131[0]+Q_011101110*R_132[0]+-1*Q_111001010*R_221[0]+Q_111001110*R_222[0]+Q_111101010*R_231[0]+-1*Q_111101110*R_232[0]+Q_211001010*R_321[0]+-1*Q_211001110*R_322[0]+-1*Q_211101010*R_331[0]+Q_211101110*R_332[0]; double QR_010002010121=Q_010002010*R_121[0]+-1*Q_010002110*R_122[0]+-1*Q_010102010*R_131[0]+Q_010102110*R_132[0]+Q_010202010*R_141[0]+-1*Q_010202110*R_142[0]+-1*Q_110002010*R_221[0]+Q_110002110*R_222[0]+Q_110102010*R_231[0]+-1*Q_110102110*R_232[0]+-1*Q_110202010*R_241[0]+Q_110202110*R_242[0]; double QR_011000011121=Q_011000011*R_121[0]+-1*Q_011000111*R_122[0]+Q_011000211*R_123[0]+-1*Q_111000011*R_221[0]+Q_111000111*R_222[0]+-1*Q_111000211*R_223[0]+Q_211000011*R_321[0]+-1*Q_211000111*R_322[0]+Q_211000211*R_323[0]; double QR_010001011121=Q_010001011*R_121[0]+-1*Q_010001111*R_122[0]+Q_010001211*R_123[0]+-1*Q_010101011*R_131[0]+Q_010101111*R_132[0]+-1*Q_010101211*R_133[0]+-1*Q_110001011*R_221[0]+Q_110001111*R_222[0]+-1*Q_110001211*R_223[0]+Q_110101011*R_231[0]+-1*Q_110101111*R_232[0]+Q_110101211*R_233[0]; double QR_010000012121=Q_010000012*R_121[0]+-1*Q_010000112*R_122[0]+Q_010000212*R_123[0]+-1*Q_010000312*R_124[0]+-1*Q_110000012*R_221[0]+Q_110000112*R_222[0]+-1*Q_110000212*R_223[0]+Q_110000312*R_224[0]; double QR_002010010121=Q_002010010*R_121[0]+-1*Q_002010110*R_122[0]+-1*Q_002110010*R_131[0]+Q_002110110*R_132[0]+-1*Q_102010010*R_221[0]+Q_102010110*R_222[0]+Q_102110010*R_231[0]+-1*Q_102110110*R_232[0]+Q_202010010*R_321[0]+-1*Q_202010110*R_322[0]+-1*Q_202110010*R_331[0]+Q_202110110*R_332[0]; double QR_001011010121=Q_001011010*R_121[0]+-1*Q_001011110*R_122[0]+-1*Q_001111010*R_131[0]+Q_001111110*R_132[0]+Q_001211010*R_141[0]+-1*Q_001211110*R_142[0]+-1*Q_101011010*R_221[0]+Q_101011110*R_222[0]+Q_101111010*R_231[0]+-1*Q_101111110*R_232[0]+-1*Q_101211010*R_241[0]+Q_101211110*R_242[0]; double QR_000012010121=Q_000012010*R_121[0]+-1*Q_000012110*R_122[0]+-1*Q_000112010*R_131[0]+Q_000112110*R_132[0]+Q_000212010*R_141[0]+-1*Q_000212110*R_142[0]+-1*Q_000312010*R_151[0]+Q_000312110*R_152[0]; double QR_001010011121=Q_001010011*R_121[0]+-1*Q_001010111*R_122[0]+Q_001010211*R_123[0]+-1*Q_001110011*R_131[0]+Q_001110111*R_132[0]+-1*Q_001110211*R_133[0]+-1*Q_101010011*R_221[0]+Q_101010111*R_222[0]+-1*Q_101010211*R_223[0]+Q_101110011*R_231[0]+-1*Q_101110111*R_232[0]+Q_101110211*R_233[0]; double QR_000011011121=Q_000011011*R_121[0]+-1*Q_000011111*R_122[0]+Q_000011211*R_123[0]+-1*Q_000111011*R_131[0]+Q_000111111*R_132[0]+-1*Q_000111211*R_133[0]+Q_000211011*R_141[0]+-1*Q_000211111*R_142[0]+Q_000211211*R_143[0]; double QR_000010012121=Q_000010012*R_121[0]+-1*Q_000010112*R_122[0]+Q_000010212*R_123[0]+-1*Q_000010312*R_124[0]+-1*Q_000110012*R_131[0]+Q_000110112*R_132[0]+-1*Q_000110212*R_133[0]+Q_000110312*R_134[0]; double QR_002000020121=Q_002000020*R_121[0]+-1*Q_002000120*R_122[0]+Q_002000220*R_123[0]+-1*Q_102000020*R_221[0]+Q_102000120*R_222[0]+-1*Q_102000220*R_223[0]+Q_202000020*R_321[0]+-1*Q_202000120*R_322[0]+Q_202000220*R_323[0]; double QR_001001020121=Q_001001020*R_121[0]+-1*Q_001001120*R_122[0]+Q_001001220*R_123[0]+-1*Q_001101020*R_131[0]+Q_001101120*R_132[0]+-1*Q_001101220*R_133[0]+-1*Q_101001020*R_221[0]+Q_101001120*R_222[0]+-1*Q_101001220*R_223[0]+Q_101101020*R_231[0]+-1*Q_101101120*R_232[0]+Q_101101220*R_233[0]; double QR_000002020121=Q_000002020*R_121[0]+-1*Q_000002120*R_122[0]+Q_000002220*R_123[0]+-1*Q_000102020*R_131[0]+Q_000102120*R_132[0]+-1*Q_000102220*R_133[0]+Q_000202020*R_141[0]+-1*Q_000202120*R_142[0]+Q_000202220*R_143[0]; double QR_001000021121=Q_001000021*R_121[0]+-1*Q_001000121*R_122[0]+Q_001000221*R_123[0]+-1*Q_001000321*R_124[0]+-1*Q_101000021*R_221[0]+Q_101000121*R_222[0]+-1*Q_101000221*R_223[0]+Q_101000321*R_224[0]; double QR_000001021121=Q_000001021*R_121[0]+-1*Q_000001121*R_122[0]+Q_000001221*R_123[0]+-1*Q_000001321*R_124[0]+-1*Q_000101021*R_131[0]+Q_000101121*R_132[0]+-1*Q_000101221*R_133[0]+Q_000101321*R_134[0]; double QR_000000022121=Q_000000022*R_121[0]+-1*Q_000000122*R_122[0]+Q_000000222*R_123[0]+-1*Q_000000322*R_124[0]+Q_000000422*R_125[0]; double QR_022000000130=Q_022000000*R_130[0]+-1*Q_122000000*R_230[0]+Q_222000000*R_330[0]+-1*Q_322000000*R_430[0]+Q_422000000*R_530[0]; double QR_021001000130=Q_021001000*R_130[0]+-1*Q_021101000*R_140[0]+-1*Q_121001000*R_230[0]+Q_121101000*R_240[0]+Q_221001000*R_330[0]+-1*Q_221101000*R_340[0]+-1*Q_321001000*R_430[0]+Q_321101000*R_440[0]; double QR_020002000130=Q_020002000*R_130[0]+-1*Q_020102000*R_140[0]+Q_020202000*R_150[0]+-1*Q_120002000*R_230[0]+Q_120102000*R_240[0]+-1*Q_120202000*R_250[0]+Q_220002000*R_330[0]+-1*Q_220102000*R_340[0]+Q_220202000*R_350[0]; double QR_021000001130=Q_021000001*R_130[0]+-1*Q_021000101*R_131[0]+-1*Q_121000001*R_230[0]+Q_121000101*R_231[0]+Q_221000001*R_330[0]+-1*Q_221000101*R_331[0]+-1*Q_321000001*R_430[0]+Q_321000101*R_431[0]; double QR_020001001130=Q_020001001*R_130[0]+-1*Q_020001101*R_131[0]+-1*Q_020101001*R_140[0]+Q_020101101*R_141[0]+-1*Q_120001001*R_230[0]+Q_120001101*R_231[0]+Q_120101001*R_240[0]+-1*Q_120101101*R_241[0]+Q_220001001*R_330[0]+-1*Q_220001101*R_331[0]+-1*Q_220101001*R_340[0]+Q_220101101*R_341[0]; double QR_020000002130=Q_020000002*R_130[0]+-1*Q_020000102*R_131[0]+Q_020000202*R_132[0]+-1*Q_120000002*R_230[0]+Q_120000102*R_231[0]+-1*Q_120000202*R_232[0]+Q_220000002*R_330[0]+-1*Q_220000102*R_331[0]+Q_220000202*R_332[0]; double QR_012010000130=Q_012010000*R_130[0]+-1*Q_012110000*R_140[0]+-1*Q_112010000*R_230[0]+Q_112110000*R_240[0]+Q_212010000*R_330[0]+-1*Q_212110000*R_340[0]+-1*Q_312010000*R_430[0]+Q_312110000*R_440[0]; double QR_011011000130=Q_011011000*R_130[0]+-1*Q_011111000*R_140[0]+Q_011211000*R_150[0]+-1*Q_111011000*R_230[0]+Q_111111000*R_240[0]+-1*Q_111211000*R_250[0]+Q_211011000*R_330[0]+-1*Q_211111000*R_340[0]+Q_211211000*R_350[0]; double QR_010012000130=Q_010012000*R_130[0]+-1*Q_010112000*R_140[0]+Q_010212000*R_150[0]+-1*Q_010312000*R_160[0]+-1*Q_110012000*R_230[0]+Q_110112000*R_240[0]+-1*Q_110212000*R_250[0]+Q_110312000*R_260[0]; double QR_011010001130=Q_011010001*R_130[0]+-1*Q_011010101*R_131[0]+-1*Q_011110001*R_140[0]+Q_011110101*R_141[0]+-1*Q_111010001*R_230[0]+Q_111010101*R_231[0]+Q_111110001*R_240[0]+-1*Q_111110101*R_241[0]+Q_211010001*R_330[0]+-1*Q_211010101*R_331[0]+-1*Q_211110001*R_340[0]+Q_211110101*R_341[0]; double QR_010011001130=Q_010011001*R_130[0]+-1*Q_010011101*R_131[0]+-1*Q_010111001*R_140[0]+Q_010111101*R_141[0]+Q_010211001*R_150[0]+-1*Q_010211101*R_151[0]+-1*Q_110011001*R_230[0]+Q_110011101*R_231[0]+Q_110111001*R_240[0]+-1*Q_110111101*R_241[0]+-1*Q_110211001*R_250[0]+Q_110211101*R_251[0]; double QR_010010002130=Q_010010002*R_130[0]+-1*Q_010010102*R_131[0]+Q_010010202*R_132[0]+-1*Q_010110002*R_140[0]+Q_010110102*R_141[0]+-1*Q_010110202*R_142[0]+-1*Q_110010002*R_230[0]+Q_110010102*R_231[0]+-1*Q_110010202*R_232[0]+Q_110110002*R_240[0]+-1*Q_110110102*R_241[0]+Q_110110202*R_242[0]; double QR_002020000130=Q_002020000*R_130[0]+-1*Q_002120000*R_140[0]+Q_002220000*R_150[0]+-1*Q_102020000*R_230[0]+Q_102120000*R_240[0]+-1*Q_102220000*R_250[0]+Q_202020000*R_330[0]+-1*Q_202120000*R_340[0]+Q_202220000*R_350[0]; double QR_001021000130=Q_001021000*R_130[0]+-1*Q_001121000*R_140[0]+Q_001221000*R_150[0]+-1*Q_001321000*R_160[0]+-1*Q_101021000*R_230[0]+Q_101121000*R_240[0]+-1*Q_101221000*R_250[0]+Q_101321000*R_260[0]; double QR_000022000130=Q_000022000*R_130[0]+-1*Q_000122000*R_140[0]+Q_000222000*R_150[0]+-1*Q_000322000*R_160[0]+Q_000422000*R_170[0]; double QR_001020001130=Q_001020001*R_130[0]+-1*Q_001020101*R_131[0]+-1*Q_001120001*R_140[0]+Q_001120101*R_141[0]+Q_001220001*R_150[0]+-1*Q_001220101*R_151[0]+-1*Q_101020001*R_230[0]+Q_101020101*R_231[0]+Q_101120001*R_240[0]+-1*Q_101120101*R_241[0]+-1*Q_101220001*R_250[0]+Q_101220101*R_251[0]; double QR_000021001130=Q_000021001*R_130[0]+-1*Q_000021101*R_131[0]+-1*Q_000121001*R_140[0]+Q_000121101*R_141[0]+Q_000221001*R_150[0]+-1*Q_000221101*R_151[0]+-1*Q_000321001*R_160[0]+Q_000321101*R_161[0]; double QR_000020002130=Q_000020002*R_130[0]+-1*Q_000020102*R_131[0]+Q_000020202*R_132[0]+-1*Q_000120002*R_140[0]+Q_000120102*R_141[0]+-1*Q_000120202*R_142[0]+Q_000220002*R_150[0]+-1*Q_000220102*R_151[0]+Q_000220202*R_152[0]; double QR_012000010130=Q_012000010*R_130[0]+-1*Q_012000110*R_131[0]+-1*Q_112000010*R_230[0]+Q_112000110*R_231[0]+Q_212000010*R_330[0]+-1*Q_212000110*R_331[0]+-1*Q_312000010*R_430[0]+Q_312000110*R_431[0]; double QR_011001010130=Q_011001010*R_130[0]+-1*Q_011001110*R_131[0]+-1*Q_011101010*R_140[0]+Q_011101110*R_141[0]+-1*Q_111001010*R_230[0]+Q_111001110*R_231[0]+Q_111101010*R_240[0]+-1*Q_111101110*R_241[0]+Q_211001010*R_330[0]+-1*Q_211001110*R_331[0]+-1*Q_211101010*R_340[0]+Q_211101110*R_341[0]; double QR_010002010130=Q_010002010*R_130[0]+-1*Q_010002110*R_131[0]+-1*Q_010102010*R_140[0]+Q_010102110*R_141[0]+Q_010202010*R_150[0]+-1*Q_010202110*R_151[0]+-1*Q_110002010*R_230[0]+Q_110002110*R_231[0]+Q_110102010*R_240[0]+-1*Q_110102110*R_241[0]+-1*Q_110202010*R_250[0]+Q_110202110*R_251[0]; double QR_011000011130=Q_011000011*R_130[0]+-1*Q_011000111*R_131[0]+Q_011000211*R_132[0]+-1*Q_111000011*R_230[0]+Q_111000111*R_231[0]+-1*Q_111000211*R_232[0]+Q_211000011*R_330[0]+-1*Q_211000111*R_331[0]+Q_211000211*R_332[0]; double QR_010001011130=Q_010001011*R_130[0]+-1*Q_010001111*R_131[0]+Q_010001211*R_132[0]+-1*Q_010101011*R_140[0]+Q_010101111*R_141[0]+-1*Q_010101211*R_142[0]+-1*Q_110001011*R_230[0]+Q_110001111*R_231[0]+-1*Q_110001211*R_232[0]+Q_110101011*R_240[0]+-1*Q_110101111*R_241[0]+Q_110101211*R_242[0]; double QR_010000012130=Q_010000012*R_130[0]+-1*Q_010000112*R_131[0]+Q_010000212*R_132[0]+-1*Q_010000312*R_133[0]+-1*Q_110000012*R_230[0]+Q_110000112*R_231[0]+-1*Q_110000212*R_232[0]+Q_110000312*R_233[0]; double QR_002010010130=Q_002010010*R_130[0]+-1*Q_002010110*R_131[0]+-1*Q_002110010*R_140[0]+Q_002110110*R_141[0]+-1*Q_102010010*R_230[0]+Q_102010110*R_231[0]+Q_102110010*R_240[0]+-1*Q_102110110*R_241[0]+Q_202010010*R_330[0]+-1*Q_202010110*R_331[0]+-1*Q_202110010*R_340[0]+Q_202110110*R_341[0]; double QR_001011010130=Q_001011010*R_130[0]+-1*Q_001011110*R_131[0]+-1*Q_001111010*R_140[0]+Q_001111110*R_141[0]+Q_001211010*R_150[0]+-1*Q_001211110*R_151[0]+-1*Q_101011010*R_230[0]+Q_101011110*R_231[0]+Q_101111010*R_240[0]+-1*Q_101111110*R_241[0]+-1*Q_101211010*R_250[0]+Q_101211110*R_251[0]; double QR_000012010130=Q_000012010*R_130[0]+-1*Q_000012110*R_131[0]+-1*Q_000112010*R_140[0]+Q_000112110*R_141[0]+Q_000212010*R_150[0]+-1*Q_000212110*R_151[0]+-1*Q_000312010*R_160[0]+Q_000312110*R_161[0]; double QR_001010011130=Q_001010011*R_130[0]+-1*Q_001010111*R_131[0]+Q_001010211*R_132[0]+-1*Q_001110011*R_140[0]+Q_001110111*R_141[0]+-1*Q_001110211*R_142[0]+-1*Q_101010011*R_230[0]+Q_101010111*R_231[0]+-1*Q_101010211*R_232[0]+Q_101110011*R_240[0]+-1*Q_101110111*R_241[0]+Q_101110211*R_242[0]; double QR_000011011130=Q_000011011*R_130[0]+-1*Q_000011111*R_131[0]+Q_000011211*R_132[0]+-1*Q_000111011*R_140[0]+Q_000111111*R_141[0]+-1*Q_000111211*R_142[0]+Q_000211011*R_150[0]+-1*Q_000211111*R_151[0]+Q_000211211*R_152[0]; double QR_000010012130=Q_000010012*R_130[0]+-1*Q_000010112*R_131[0]+Q_000010212*R_132[0]+-1*Q_000010312*R_133[0]+-1*Q_000110012*R_140[0]+Q_000110112*R_141[0]+-1*Q_000110212*R_142[0]+Q_000110312*R_143[0]; double QR_002000020130=Q_002000020*R_130[0]+-1*Q_002000120*R_131[0]+Q_002000220*R_132[0]+-1*Q_102000020*R_230[0]+Q_102000120*R_231[0]+-1*Q_102000220*R_232[0]+Q_202000020*R_330[0]+-1*Q_202000120*R_331[0]+Q_202000220*R_332[0]; double QR_001001020130=Q_001001020*R_130[0]+-1*Q_001001120*R_131[0]+Q_001001220*R_132[0]+-1*Q_001101020*R_140[0]+Q_001101120*R_141[0]+-1*Q_001101220*R_142[0]+-1*Q_101001020*R_230[0]+Q_101001120*R_231[0]+-1*Q_101001220*R_232[0]+Q_101101020*R_240[0]+-1*Q_101101120*R_241[0]+Q_101101220*R_242[0]; double QR_000002020130=Q_000002020*R_130[0]+-1*Q_000002120*R_131[0]+Q_000002220*R_132[0]+-1*Q_000102020*R_140[0]+Q_000102120*R_141[0]+-1*Q_000102220*R_142[0]+Q_000202020*R_150[0]+-1*Q_000202120*R_151[0]+Q_000202220*R_152[0]; double QR_001000021130=Q_001000021*R_130[0]+-1*Q_001000121*R_131[0]+Q_001000221*R_132[0]+-1*Q_001000321*R_133[0]+-1*Q_101000021*R_230[0]+Q_101000121*R_231[0]+-1*Q_101000221*R_232[0]+Q_101000321*R_233[0]; double QR_000001021130=Q_000001021*R_130[0]+-1*Q_000001121*R_131[0]+Q_000001221*R_132[0]+-1*Q_000001321*R_133[0]+-1*Q_000101021*R_140[0]+Q_000101121*R_141[0]+-1*Q_000101221*R_142[0]+Q_000101321*R_143[0]; double QR_000000022130=Q_000000022*R_130[0]+-1*Q_000000122*R_131[0]+Q_000000222*R_132[0]+-1*Q_000000322*R_133[0]+Q_000000422*R_134[0]; double QR_022000000202=Q_022000000*R_202[0]+-1*Q_122000000*R_302[0]+Q_222000000*R_402[0]+-1*Q_322000000*R_502[0]+Q_422000000*R_602[0]; double QR_021001000202=Q_021001000*R_202[0]+-1*Q_021101000*R_212[0]+-1*Q_121001000*R_302[0]+Q_121101000*R_312[0]+Q_221001000*R_402[0]+-1*Q_221101000*R_412[0]+-1*Q_321001000*R_502[0]+Q_321101000*R_512[0]; double QR_020002000202=Q_020002000*R_202[0]+-1*Q_020102000*R_212[0]+Q_020202000*R_222[0]+-1*Q_120002000*R_302[0]+Q_120102000*R_312[0]+-1*Q_120202000*R_322[0]+Q_220002000*R_402[0]+-1*Q_220102000*R_412[0]+Q_220202000*R_422[0]; double QR_021000001202=Q_021000001*R_202[0]+-1*Q_021000101*R_203[0]+-1*Q_121000001*R_302[0]+Q_121000101*R_303[0]+Q_221000001*R_402[0]+-1*Q_221000101*R_403[0]+-1*Q_321000001*R_502[0]+Q_321000101*R_503[0]; double QR_020001001202=Q_020001001*R_202[0]+-1*Q_020001101*R_203[0]+-1*Q_020101001*R_212[0]+Q_020101101*R_213[0]+-1*Q_120001001*R_302[0]+Q_120001101*R_303[0]+Q_120101001*R_312[0]+-1*Q_120101101*R_313[0]+Q_220001001*R_402[0]+-1*Q_220001101*R_403[0]+-1*Q_220101001*R_412[0]+Q_220101101*R_413[0]; double QR_020000002202=Q_020000002*R_202[0]+-1*Q_020000102*R_203[0]+Q_020000202*R_204[0]+-1*Q_120000002*R_302[0]+Q_120000102*R_303[0]+-1*Q_120000202*R_304[0]+Q_220000002*R_402[0]+-1*Q_220000102*R_403[0]+Q_220000202*R_404[0]; double QR_012010000202=Q_012010000*R_202[0]+-1*Q_012110000*R_212[0]+-1*Q_112010000*R_302[0]+Q_112110000*R_312[0]+Q_212010000*R_402[0]+-1*Q_212110000*R_412[0]+-1*Q_312010000*R_502[0]+Q_312110000*R_512[0]; double QR_011011000202=Q_011011000*R_202[0]+-1*Q_011111000*R_212[0]+Q_011211000*R_222[0]+-1*Q_111011000*R_302[0]+Q_111111000*R_312[0]+-1*Q_111211000*R_322[0]+Q_211011000*R_402[0]+-1*Q_211111000*R_412[0]+Q_211211000*R_422[0]; double QR_010012000202=Q_010012000*R_202[0]+-1*Q_010112000*R_212[0]+Q_010212000*R_222[0]+-1*Q_010312000*R_232[0]+-1*Q_110012000*R_302[0]+Q_110112000*R_312[0]+-1*Q_110212000*R_322[0]+Q_110312000*R_332[0]; double QR_011010001202=Q_011010001*R_202[0]+-1*Q_011010101*R_203[0]+-1*Q_011110001*R_212[0]+Q_011110101*R_213[0]+-1*Q_111010001*R_302[0]+Q_111010101*R_303[0]+Q_111110001*R_312[0]+-1*Q_111110101*R_313[0]+Q_211010001*R_402[0]+-1*Q_211010101*R_403[0]+-1*Q_211110001*R_412[0]+Q_211110101*R_413[0]; double QR_010011001202=Q_010011001*R_202[0]+-1*Q_010011101*R_203[0]+-1*Q_010111001*R_212[0]+Q_010111101*R_213[0]+Q_010211001*R_222[0]+-1*Q_010211101*R_223[0]+-1*Q_110011001*R_302[0]+Q_110011101*R_303[0]+Q_110111001*R_312[0]+-1*Q_110111101*R_313[0]+-1*Q_110211001*R_322[0]+Q_110211101*R_323[0]; double QR_010010002202=Q_010010002*R_202[0]+-1*Q_010010102*R_203[0]+Q_010010202*R_204[0]+-1*Q_010110002*R_212[0]+Q_010110102*R_213[0]+-1*Q_010110202*R_214[0]+-1*Q_110010002*R_302[0]+Q_110010102*R_303[0]+-1*Q_110010202*R_304[0]+Q_110110002*R_312[0]+-1*Q_110110102*R_313[0]+Q_110110202*R_314[0]; double QR_002020000202=Q_002020000*R_202[0]+-1*Q_002120000*R_212[0]+Q_002220000*R_222[0]+-1*Q_102020000*R_302[0]+Q_102120000*R_312[0]+-1*Q_102220000*R_322[0]+Q_202020000*R_402[0]+-1*Q_202120000*R_412[0]+Q_202220000*R_422[0]; double QR_001021000202=Q_001021000*R_202[0]+-1*Q_001121000*R_212[0]+Q_001221000*R_222[0]+-1*Q_001321000*R_232[0]+-1*Q_101021000*R_302[0]+Q_101121000*R_312[0]+-1*Q_101221000*R_322[0]+Q_101321000*R_332[0]; double QR_000022000202=Q_000022000*R_202[0]+-1*Q_000122000*R_212[0]+Q_000222000*R_222[0]+-1*Q_000322000*R_232[0]+Q_000422000*R_242[0]; double QR_001020001202=Q_001020001*R_202[0]+-1*Q_001020101*R_203[0]+-1*Q_001120001*R_212[0]+Q_001120101*R_213[0]+Q_001220001*R_222[0]+-1*Q_001220101*R_223[0]+-1*Q_101020001*R_302[0]+Q_101020101*R_303[0]+Q_101120001*R_312[0]+-1*Q_101120101*R_313[0]+-1*Q_101220001*R_322[0]+Q_101220101*R_323[0]; double QR_000021001202=Q_000021001*R_202[0]+-1*Q_000021101*R_203[0]+-1*Q_000121001*R_212[0]+Q_000121101*R_213[0]+Q_000221001*R_222[0]+-1*Q_000221101*R_223[0]+-1*Q_000321001*R_232[0]+Q_000321101*R_233[0]; double QR_000020002202=Q_000020002*R_202[0]+-1*Q_000020102*R_203[0]+Q_000020202*R_204[0]+-1*Q_000120002*R_212[0]+Q_000120102*R_213[0]+-1*Q_000120202*R_214[0]+Q_000220002*R_222[0]+-1*Q_000220102*R_223[0]+Q_000220202*R_224[0]; double QR_012000010202=Q_012000010*R_202[0]+-1*Q_012000110*R_203[0]+-1*Q_112000010*R_302[0]+Q_112000110*R_303[0]+Q_212000010*R_402[0]+-1*Q_212000110*R_403[0]+-1*Q_312000010*R_502[0]+Q_312000110*R_503[0]; double QR_011001010202=Q_011001010*R_202[0]+-1*Q_011001110*R_203[0]+-1*Q_011101010*R_212[0]+Q_011101110*R_213[0]+-1*Q_111001010*R_302[0]+Q_111001110*R_303[0]+Q_111101010*R_312[0]+-1*Q_111101110*R_313[0]+Q_211001010*R_402[0]+-1*Q_211001110*R_403[0]+-1*Q_211101010*R_412[0]+Q_211101110*R_413[0]; double QR_010002010202=Q_010002010*R_202[0]+-1*Q_010002110*R_203[0]+-1*Q_010102010*R_212[0]+Q_010102110*R_213[0]+Q_010202010*R_222[0]+-1*Q_010202110*R_223[0]+-1*Q_110002010*R_302[0]+Q_110002110*R_303[0]+Q_110102010*R_312[0]+-1*Q_110102110*R_313[0]+-1*Q_110202010*R_322[0]+Q_110202110*R_323[0]; double QR_011000011202=Q_011000011*R_202[0]+-1*Q_011000111*R_203[0]+Q_011000211*R_204[0]+-1*Q_111000011*R_302[0]+Q_111000111*R_303[0]+-1*Q_111000211*R_304[0]+Q_211000011*R_402[0]+-1*Q_211000111*R_403[0]+Q_211000211*R_404[0]; double QR_010001011202=Q_010001011*R_202[0]+-1*Q_010001111*R_203[0]+Q_010001211*R_204[0]+-1*Q_010101011*R_212[0]+Q_010101111*R_213[0]+-1*Q_010101211*R_214[0]+-1*Q_110001011*R_302[0]+Q_110001111*R_303[0]+-1*Q_110001211*R_304[0]+Q_110101011*R_312[0]+-1*Q_110101111*R_313[0]+Q_110101211*R_314[0]; double QR_010000012202=Q_010000012*R_202[0]+-1*Q_010000112*R_203[0]+Q_010000212*R_204[0]+-1*Q_010000312*R_205[0]+-1*Q_110000012*R_302[0]+Q_110000112*R_303[0]+-1*Q_110000212*R_304[0]+Q_110000312*R_305[0]; double QR_002010010202=Q_002010010*R_202[0]+-1*Q_002010110*R_203[0]+-1*Q_002110010*R_212[0]+Q_002110110*R_213[0]+-1*Q_102010010*R_302[0]+Q_102010110*R_303[0]+Q_102110010*R_312[0]+-1*Q_102110110*R_313[0]+Q_202010010*R_402[0]+-1*Q_202010110*R_403[0]+-1*Q_202110010*R_412[0]+Q_202110110*R_413[0]; double QR_001011010202=Q_001011010*R_202[0]+-1*Q_001011110*R_203[0]+-1*Q_001111010*R_212[0]+Q_001111110*R_213[0]+Q_001211010*R_222[0]+-1*Q_001211110*R_223[0]+-1*Q_101011010*R_302[0]+Q_101011110*R_303[0]+Q_101111010*R_312[0]+-1*Q_101111110*R_313[0]+-1*Q_101211010*R_322[0]+Q_101211110*R_323[0]; double QR_000012010202=Q_000012010*R_202[0]+-1*Q_000012110*R_203[0]+-1*Q_000112010*R_212[0]+Q_000112110*R_213[0]+Q_000212010*R_222[0]+-1*Q_000212110*R_223[0]+-1*Q_000312010*R_232[0]+Q_000312110*R_233[0]; double QR_001010011202=Q_001010011*R_202[0]+-1*Q_001010111*R_203[0]+Q_001010211*R_204[0]+-1*Q_001110011*R_212[0]+Q_001110111*R_213[0]+-1*Q_001110211*R_214[0]+-1*Q_101010011*R_302[0]+Q_101010111*R_303[0]+-1*Q_101010211*R_304[0]+Q_101110011*R_312[0]+-1*Q_101110111*R_313[0]+Q_101110211*R_314[0]; double QR_000011011202=Q_000011011*R_202[0]+-1*Q_000011111*R_203[0]+Q_000011211*R_204[0]+-1*Q_000111011*R_212[0]+Q_000111111*R_213[0]+-1*Q_000111211*R_214[0]+Q_000211011*R_222[0]+-1*Q_000211111*R_223[0]+Q_000211211*R_224[0]; double QR_000010012202=Q_000010012*R_202[0]+-1*Q_000010112*R_203[0]+Q_000010212*R_204[0]+-1*Q_000010312*R_205[0]+-1*Q_000110012*R_212[0]+Q_000110112*R_213[0]+-1*Q_000110212*R_214[0]+Q_000110312*R_215[0]; double QR_002000020202=Q_002000020*R_202[0]+-1*Q_002000120*R_203[0]+Q_002000220*R_204[0]+-1*Q_102000020*R_302[0]+Q_102000120*R_303[0]+-1*Q_102000220*R_304[0]+Q_202000020*R_402[0]+-1*Q_202000120*R_403[0]+Q_202000220*R_404[0]; double QR_001001020202=Q_001001020*R_202[0]+-1*Q_001001120*R_203[0]+Q_001001220*R_204[0]+-1*Q_001101020*R_212[0]+Q_001101120*R_213[0]+-1*Q_001101220*R_214[0]+-1*Q_101001020*R_302[0]+Q_101001120*R_303[0]+-1*Q_101001220*R_304[0]+Q_101101020*R_312[0]+-1*Q_101101120*R_313[0]+Q_101101220*R_314[0]; double QR_000002020202=Q_000002020*R_202[0]+-1*Q_000002120*R_203[0]+Q_000002220*R_204[0]+-1*Q_000102020*R_212[0]+Q_000102120*R_213[0]+-1*Q_000102220*R_214[0]+Q_000202020*R_222[0]+-1*Q_000202120*R_223[0]+Q_000202220*R_224[0]; double QR_001000021202=Q_001000021*R_202[0]+-1*Q_001000121*R_203[0]+Q_001000221*R_204[0]+-1*Q_001000321*R_205[0]+-1*Q_101000021*R_302[0]+Q_101000121*R_303[0]+-1*Q_101000221*R_304[0]+Q_101000321*R_305[0]; double QR_000001021202=Q_000001021*R_202[0]+-1*Q_000001121*R_203[0]+Q_000001221*R_204[0]+-1*Q_000001321*R_205[0]+-1*Q_000101021*R_212[0]+Q_000101121*R_213[0]+-1*Q_000101221*R_214[0]+Q_000101321*R_215[0]; double QR_000000022202=Q_000000022*R_202[0]+-1*Q_000000122*R_203[0]+Q_000000222*R_204[0]+-1*Q_000000322*R_205[0]+Q_000000422*R_206[0]; double QR_022000000211=Q_022000000*R_211[0]+-1*Q_122000000*R_311[0]+Q_222000000*R_411[0]+-1*Q_322000000*R_511[0]+Q_422000000*R_611[0]; double QR_021001000211=Q_021001000*R_211[0]+-1*Q_021101000*R_221[0]+-1*Q_121001000*R_311[0]+Q_121101000*R_321[0]+Q_221001000*R_411[0]+-1*Q_221101000*R_421[0]+-1*Q_321001000*R_511[0]+Q_321101000*R_521[0]; double QR_020002000211=Q_020002000*R_211[0]+-1*Q_020102000*R_221[0]+Q_020202000*R_231[0]+-1*Q_120002000*R_311[0]+Q_120102000*R_321[0]+-1*Q_120202000*R_331[0]+Q_220002000*R_411[0]+-1*Q_220102000*R_421[0]+Q_220202000*R_431[0]; double QR_021000001211=Q_021000001*R_211[0]+-1*Q_021000101*R_212[0]+-1*Q_121000001*R_311[0]+Q_121000101*R_312[0]+Q_221000001*R_411[0]+-1*Q_221000101*R_412[0]+-1*Q_321000001*R_511[0]+Q_321000101*R_512[0]; double QR_020001001211=Q_020001001*R_211[0]+-1*Q_020001101*R_212[0]+-1*Q_020101001*R_221[0]+Q_020101101*R_222[0]+-1*Q_120001001*R_311[0]+Q_120001101*R_312[0]+Q_120101001*R_321[0]+-1*Q_120101101*R_322[0]+Q_220001001*R_411[0]+-1*Q_220001101*R_412[0]+-1*Q_220101001*R_421[0]+Q_220101101*R_422[0]; double QR_020000002211=Q_020000002*R_211[0]+-1*Q_020000102*R_212[0]+Q_020000202*R_213[0]+-1*Q_120000002*R_311[0]+Q_120000102*R_312[0]+-1*Q_120000202*R_313[0]+Q_220000002*R_411[0]+-1*Q_220000102*R_412[0]+Q_220000202*R_413[0]; double QR_012010000211=Q_012010000*R_211[0]+-1*Q_012110000*R_221[0]+-1*Q_112010000*R_311[0]+Q_112110000*R_321[0]+Q_212010000*R_411[0]+-1*Q_212110000*R_421[0]+-1*Q_312010000*R_511[0]+Q_312110000*R_521[0]; double QR_011011000211=Q_011011000*R_211[0]+-1*Q_011111000*R_221[0]+Q_011211000*R_231[0]+-1*Q_111011000*R_311[0]+Q_111111000*R_321[0]+-1*Q_111211000*R_331[0]+Q_211011000*R_411[0]+-1*Q_211111000*R_421[0]+Q_211211000*R_431[0]; double QR_010012000211=Q_010012000*R_211[0]+-1*Q_010112000*R_221[0]+Q_010212000*R_231[0]+-1*Q_010312000*R_241[0]+-1*Q_110012000*R_311[0]+Q_110112000*R_321[0]+-1*Q_110212000*R_331[0]+Q_110312000*R_341[0]; double QR_011010001211=Q_011010001*R_211[0]+-1*Q_011010101*R_212[0]+-1*Q_011110001*R_221[0]+Q_011110101*R_222[0]+-1*Q_111010001*R_311[0]+Q_111010101*R_312[0]+Q_111110001*R_321[0]+-1*Q_111110101*R_322[0]+Q_211010001*R_411[0]+-1*Q_211010101*R_412[0]+-1*Q_211110001*R_421[0]+Q_211110101*R_422[0]; double QR_010011001211=Q_010011001*R_211[0]+-1*Q_010011101*R_212[0]+-1*Q_010111001*R_221[0]+Q_010111101*R_222[0]+Q_010211001*R_231[0]+-1*Q_010211101*R_232[0]+-1*Q_110011001*R_311[0]+Q_110011101*R_312[0]+Q_110111001*R_321[0]+-1*Q_110111101*R_322[0]+-1*Q_110211001*R_331[0]+Q_110211101*R_332[0]; double QR_010010002211=Q_010010002*R_211[0]+-1*Q_010010102*R_212[0]+Q_010010202*R_213[0]+-1*Q_010110002*R_221[0]+Q_010110102*R_222[0]+-1*Q_010110202*R_223[0]+-1*Q_110010002*R_311[0]+Q_110010102*R_312[0]+-1*Q_110010202*R_313[0]+Q_110110002*R_321[0]+-1*Q_110110102*R_322[0]+Q_110110202*R_323[0]; double QR_002020000211=Q_002020000*R_211[0]+-1*Q_002120000*R_221[0]+Q_002220000*R_231[0]+-1*Q_102020000*R_311[0]+Q_102120000*R_321[0]+-1*Q_102220000*R_331[0]+Q_202020000*R_411[0]+-1*Q_202120000*R_421[0]+Q_202220000*R_431[0]; double QR_001021000211=Q_001021000*R_211[0]+-1*Q_001121000*R_221[0]+Q_001221000*R_231[0]+-1*Q_001321000*R_241[0]+-1*Q_101021000*R_311[0]+Q_101121000*R_321[0]+-1*Q_101221000*R_331[0]+Q_101321000*R_341[0]; double QR_000022000211=Q_000022000*R_211[0]+-1*Q_000122000*R_221[0]+Q_000222000*R_231[0]+-1*Q_000322000*R_241[0]+Q_000422000*R_251[0]; double QR_001020001211=Q_001020001*R_211[0]+-1*Q_001020101*R_212[0]+-1*Q_001120001*R_221[0]+Q_001120101*R_222[0]+Q_001220001*R_231[0]+-1*Q_001220101*R_232[0]+-1*Q_101020001*R_311[0]+Q_101020101*R_312[0]+Q_101120001*R_321[0]+-1*Q_101120101*R_322[0]+-1*Q_101220001*R_331[0]+Q_101220101*R_332[0]; double QR_000021001211=Q_000021001*R_211[0]+-1*Q_000021101*R_212[0]+-1*Q_000121001*R_221[0]+Q_000121101*R_222[0]+Q_000221001*R_231[0]+-1*Q_000221101*R_232[0]+-1*Q_000321001*R_241[0]+Q_000321101*R_242[0]; double QR_000020002211=Q_000020002*R_211[0]+-1*Q_000020102*R_212[0]+Q_000020202*R_213[0]+-1*Q_000120002*R_221[0]+Q_000120102*R_222[0]+-1*Q_000120202*R_223[0]+Q_000220002*R_231[0]+-1*Q_000220102*R_232[0]+Q_000220202*R_233[0]; double QR_012000010211=Q_012000010*R_211[0]+-1*Q_012000110*R_212[0]+-1*Q_112000010*R_311[0]+Q_112000110*R_312[0]+Q_212000010*R_411[0]+-1*Q_212000110*R_412[0]+-1*Q_312000010*R_511[0]+Q_312000110*R_512[0]; double QR_011001010211=Q_011001010*R_211[0]+-1*Q_011001110*R_212[0]+-1*Q_011101010*R_221[0]+Q_011101110*R_222[0]+-1*Q_111001010*R_311[0]+Q_111001110*R_312[0]+Q_111101010*R_321[0]+-1*Q_111101110*R_322[0]+Q_211001010*R_411[0]+-1*Q_211001110*R_412[0]+-1*Q_211101010*R_421[0]+Q_211101110*R_422[0]; double QR_010002010211=Q_010002010*R_211[0]+-1*Q_010002110*R_212[0]+-1*Q_010102010*R_221[0]+Q_010102110*R_222[0]+Q_010202010*R_231[0]+-1*Q_010202110*R_232[0]+-1*Q_110002010*R_311[0]+Q_110002110*R_312[0]+Q_110102010*R_321[0]+-1*Q_110102110*R_322[0]+-1*Q_110202010*R_331[0]+Q_110202110*R_332[0]; double QR_011000011211=Q_011000011*R_211[0]+-1*Q_011000111*R_212[0]+Q_011000211*R_213[0]+-1*Q_111000011*R_311[0]+Q_111000111*R_312[0]+-1*Q_111000211*R_313[0]+Q_211000011*R_411[0]+-1*Q_211000111*R_412[0]+Q_211000211*R_413[0]; double QR_010001011211=Q_010001011*R_211[0]+-1*Q_010001111*R_212[0]+Q_010001211*R_213[0]+-1*Q_010101011*R_221[0]+Q_010101111*R_222[0]+-1*Q_010101211*R_223[0]+-1*Q_110001011*R_311[0]+Q_110001111*R_312[0]+-1*Q_110001211*R_313[0]+Q_110101011*R_321[0]+-1*Q_110101111*R_322[0]+Q_110101211*R_323[0]; double QR_010000012211=Q_010000012*R_211[0]+-1*Q_010000112*R_212[0]+Q_010000212*R_213[0]+-1*Q_010000312*R_214[0]+-1*Q_110000012*R_311[0]+Q_110000112*R_312[0]+-1*Q_110000212*R_313[0]+Q_110000312*R_314[0]; double QR_002010010211=Q_002010010*R_211[0]+-1*Q_002010110*R_212[0]+-1*Q_002110010*R_221[0]+Q_002110110*R_222[0]+-1*Q_102010010*R_311[0]+Q_102010110*R_312[0]+Q_102110010*R_321[0]+-1*Q_102110110*R_322[0]+Q_202010010*R_411[0]+-1*Q_202010110*R_412[0]+-1*Q_202110010*R_421[0]+Q_202110110*R_422[0]; double QR_001011010211=Q_001011010*R_211[0]+-1*Q_001011110*R_212[0]+-1*Q_001111010*R_221[0]+Q_001111110*R_222[0]+Q_001211010*R_231[0]+-1*Q_001211110*R_232[0]+-1*Q_101011010*R_311[0]+Q_101011110*R_312[0]+Q_101111010*R_321[0]+-1*Q_101111110*R_322[0]+-1*Q_101211010*R_331[0]+Q_101211110*R_332[0]; double QR_000012010211=Q_000012010*R_211[0]+-1*Q_000012110*R_212[0]+-1*Q_000112010*R_221[0]+Q_000112110*R_222[0]+Q_000212010*R_231[0]+-1*Q_000212110*R_232[0]+-1*Q_000312010*R_241[0]+Q_000312110*R_242[0]; double QR_001010011211=Q_001010011*R_211[0]+-1*Q_001010111*R_212[0]+Q_001010211*R_213[0]+-1*Q_001110011*R_221[0]+Q_001110111*R_222[0]+-1*Q_001110211*R_223[0]+-1*Q_101010011*R_311[0]+Q_101010111*R_312[0]+-1*Q_101010211*R_313[0]+Q_101110011*R_321[0]+-1*Q_101110111*R_322[0]+Q_101110211*R_323[0]; double QR_000011011211=Q_000011011*R_211[0]+-1*Q_000011111*R_212[0]+Q_000011211*R_213[0]+-1*Q_000111011*R_221[0]+Q_000111111*R_222[0]+-1*Q_000111211*R_223[0]+Q_000211011*R_231[0]+-1*Q_000211111*R_232[0]+Q_000211211*R_233[0]; double QR_000010012211=Q_000010012*R_211[0]+-1*Q_000010112*R_212[0]+Q_000010212*R_213[0]+-1*Q_000010312*R_214[0]+-1*Q_000110012*R_221[0]+Q_000110112*R_222[0]+-1*Q_000110212*R_223[0]+Q_000110312*R_224[0]; double QR_002000020211=Q_002000020*R_211[0]+-1*Q_002000120*R_212[0]+Q_002000220*R_213[0]+-1*Q_102000020*R_311[0]+Q_102000120*R_312[0]+-1*Q_102000220*R_313[0]+Q_202000020*R_411[0]+-1*Q_202000120*R_412[0]+Q_202000220*R_413[0]; double QR_001001020211=Q_001001020*R_211[0]+-1*Q_001001120*R_212[0]+Q_001001220*R_213[0]+-1*Q_001101020*R_221[0]+Q_001101120*R_222[0]+-1*Q_001101220*R_223[0]+-1*Q_101001020*R_311[0]+Q_101001120*R_312[0]+-1*Q_101001220*R_313[0]+Q_101101020*R_321[0]+-1*Q_101101120*R_322[0]+Q_101101220*R_323[0]; double QR_000002020211=Q_000002020*R_211[0]+-1*Q_000002120*R_212[0]+Q_000002220*R_213[0]+-1*Q_000102020*R_221[0]+Q_000102120*R_222[0]+-1*Q_000102220*R_223[0]+Q_000202020*R_231[0]+-1*Q_000202120*R_232[0]+Q_000202220*R_233[0]; double QR_001000021211=Q_001000021*R_211[0]+-1*Q_001000121*R_212[0]+Q_001000221*R_213[0]+-1*Q_001000321*R_214[0]+-1*Q_101000021*R_311[0]+Q_101000121*R_312[0]+-1*Q_101000221*R_313[0]+Q_101000321*R_314[0]; double QR_000001021211=Q_000001021*R_211[0]+-1*Q_000001121*R_212[0]+Q_000001221*R_213[0]+-1*Q_000001321*R_214[0]+-1*Q_000101021*R_221[0]+Q_000101121*R_222[0]+-1*Q_000101221*R_223[0]+Q_000101321*R_224[0]; double QR_000000022211=Q_000000022*R_211[0]+-1*Q_000000122*R_212[0]+Q_000000222*R_213[0]+-1*Q_000000322*R_214[0]+Q_000000422*R_215[0]; double QR_022000000220=Q_022000000*R_220[0]+-1*Q_122000000*R_320[0]+Q_222000000*R_420[0]+-1*Q_322000000*R_520[0]+Q_422000000*R_620[0]; double QR_021001000220=Q_021001000*R_220[0]+-1*Q_021101000*R_230[0]+-1*Q_121001000*R_320[0]+Q_121101000*R_330[0]+Q_221001000*R_420[0]+-1*Q_221101000*R_430[0]+-1*Q_321001000*R_520[0]+Q_321101000*R_530[0]; double QR_020002000220=Q_020002000*R_220[0]+-1*Q_020102000*R_230[0]+Q_020202000*R_240[0]+-1*Q_120002000*R_320[0]+Q_120102000*R_330[0]+-1*Q_120202000*R_340[0]+Q_220002000*R_420[0]+-1*Q_220102000*R_430[0]+Q_220202000*R_440[0]; double QR_021000001220=Q_021000001*R_220[0]+-1*Q_021000101*R_221[0]+-1*Q_121000001*R_320[0]+Q_121000101*R_321[0]+Q_221000001*R_420[0]+-1*Q_221000101*R_421[0]+-1*Q_321000001*R_520[0]+Q_321000101*R_521[0]; double QR_020001001220=Q_020001001*R_220[0]+-1*Q_020001101*R_221[0]+-1*Q_020101001*R_230[0]+Q_020101101*R_231[0]+-1*Q_120001001*R_320[0]+Q_120001101*R_321[0]+Q_120101001*R_330[0]+-1*Q_120101101*R_331[0]+Q_220001001*R_420[0]+-1*Q_220001101*R_421[0]+-1*Q_220101001*R_430[0]+Q_220101101*R_431[0]; double QR_020000002220=Q_020000002*R_220[0]+-1*Q_020000102*R_221[0]+Q_020000202*R_222[0]+-1*Q_120000002*R_320[0]+Q_120000102*R_321[0]+-1*Q_120000202*R_322[0]+Q_220000002*R_420[0]+-1*Q_220000102*R_421[0]+Q_220000202*R_422[0]; double QR_012010000220=Q_012010000*R_220[0]+-1*Q_012110000*R_230[0]+-1*Q_112010000*R_320[0]+Q_112110000*R_330[0]+Q_212010000*R_420[0]+-1*Q_212110000*R_430[0]+-1*Q_312010000*R_520[0]+Q_312110000*R_530[0]; double QR_011011000220=Q_011011000*R_220[0]+-1*Q_011111000*R_230[0]+Q_011211000*R_240[0]+-1*Q_111011000*R_320[0]+Q_111111000*R_330[0]+-1*Q_111211000*R_340[0]+Q_211011000*R_420[0]+-1*Q_211111000*R_430[0]+Q_211211000*R_440[0]; double QR_010012000220=Q_010012000*R_220[0]+-1*Q_010112000*R_230[0]+Q_010212000*R_240[0]+-1*Q_010312000*R_250[0]+-1*Q_110012000*R_320[0]+Q_110112000*R_330[0]+-1*Q_110212000*R_340[0]+Q_110312000*R_350[0]; double QR_011010001220=Q_011010001*R_220[0]+-1*Q_011010101*R_221[0]+-1*Q_011110001*R_230[0]+Q_011110101*R_231[0]+-1*Q_111010001*R_320[0]+Q_111010101*R_321[0]+Q_111110001*R_330[0]+-1*Q_111110101*R_331[0]+Q_211010001*R_420[0]+-1*Q_211010101*R_421[0]+-1*Q_211110001*R_430[0]+Q_211110101*R_431[0]; double QR_010011001220=Q_010011001*R_220[0]+-1*Q_010011101*R_221[0]+-1*Q_010111001*R_230[0]+Q_010111101*R_231[0]+Q_010211001*R_240[0]+-1*Q_010211101*R_241[0]+-1*Q_110011001*R_320[0]+Q_110011101*R_321[0]+Q_110111001*R_330[0]+-1*Q_110111101*R_331[0]+-1*Q_110211001*R_340[0]+Q_110211101*R_341[0]; double QR_010010002220=Q_010010002*R_220[0]+-1*Q_010010102*R_221[0]+Q_010010202*R_222[0]+-1*Q_010110002*R_230[0]+Q_010110102*R_231[0]+-1*Q_010110202*R_232[0]+-1*Q_110010002*R_320[0]+Q_110010102*R_321[0]+-1*Q_110010202*R_322[0]+Q_110110002*R_330[0]+-1*Q_110110102*R_331[0]+Q_110110202*R_332[0]; double QR_002020000220=Q_002020000*R_220[0]+-1*Q_002120000*R_230[0]+Q_002220000*R_240[0]+-1*Q_102020000*R_320[0]+Q_102120000*R_330[0]+-1*Q_102220000*R_340[0]+Q_202020000*R_420[0]+-1*Q_202120000*R_430[0]+Q_202220000*R_440[0]; double QR_001021000220=Q_001021000*R_220[0]+-1*Q_001121000*R_230[0]+Q_001221000*R_240[0]+-1*Q_001321000*R_250[0]+-1*Q_101021000*R_320[0]+Q_101121000*R_330[0]+-1*Q_101221000*R_340[0]+Q_101321000*R_350[0]; double QR_000022000220=Q_000022000*R_220[0]+-1*Q_000122000*R_230[0]+Q_000222000*R_240[0]+-1*Q_000322000*R_250[0]+Q_000422000*R_260[0]; double QR_001020001220=Q_001020001*R_220[0]+-1*Q_001020101*R_221[0]+-1*Q_001120001*R_230[0]+Q_001120101*R_231[0]+Q_001220001*R_240[0]+-1*Q_001220101*R_241[0]+-1*Q_101020001*R_320[0]+Q_101020101*R_321[0]+Q_101120001*R_330[0]+-1*Q_101120101*R_331[0]+-1*Q_101220001*R_340[0]+Q_101220101*R_341[0]; double QR_000021001220=Q_000021001*R_220[0]+-1*Q_000021101*R_221[0]+-1*Q_000121001*R_230[0]+Q_000121101*R_231[0]+Q_000221001*R_240[0]+-1*Q_000221101*R_241[0]+-1*Q_000321001*R_250[0]+Q_000321101*R_251[0]; double QR_000020002220=Q_000020002*R_220[0]+-1*Q_000020102*R_221[0]+Q_000020202*R_222[0]+-1*Q_000120002*R_230[0]+Q_000120102*R_231[0]+-1*Q_000120202*R_232[0]+Q_000220002*R_240[0]+-1*Q_000220102*R_241[0]+Q_000220202*R_242[0]; double QR_012000010220=Q_012000010*R_220[0]+-1*Q_012000110*R_221[0]+-1*Q_112000010*R_320[0]+Q_112000110*R_321[0]+Q_212000010*R_420[0]+-1*Q_212000110*R_421[0]+-1*Q_312000010*R_520[0]+Q_312000110*R_521[0]; double QR_011001010220=Q_011001010*R_220[0]+-1*Q_011001110*R_221[0]+-1*Q_011101010*R_230[0]+Q_011101110*R_231[0]+-1*Q_111001010*R_320[0]+Q_111001110*R_321[0]+Q_111101010*R_330[0]+-1*Q_111101110*R_331[0]+Q_211001010*R_420[0]+-1*Q_211001110*R_421[0]+-1*Q_211101010*R_430[0]+Q_211101110*R_431[0]; double QR_010002010220=Q_010002010*R_220[0]+-1*Q_010002110*R_221[0]+-1*Q_010102010*R_230[0]+Q_010102110*R_231[0]+Q_010202010*R_240[0]+-1*Q_010202110*R_241[0]+-1*Q_110002010*R_320[0]+Q_110002110*R_321[0]+Q_110102010*R_330[0]+-1*Q_110102110*R_331[0]+-1*Q_110202010*R_340[0]+Q_110202110*R_341[0]; double QR_011000011220=Q_011000011*R_220[0]+-1*Q_011000111*R_221[0]+Q_011000211*R_222[0]+-1*Q_111000011*R_320[0]+Q_111000111*R_321[0]+-1*Q_111000211*R_322[0]+Q_211000011*R_420[0]+-1*Q_211000111*R_421[0]+Q_211000211*R_422[0]; double QR_010001011220=Q_010001011*R_220[0]+-1*Q_010001111*R_221[0]+Q_010001211*R_222[0]+-1*Q_010101011*R_230[0]+Q_010101111*R_231[0]+-1*Q_010101211*R_232[0]+-1*Q_110001011*R_320[0]+Q_110001111*R_321[0]+-1*Q_110001211*R_322[0]+Q_110101011*R_330[0]+-1*Q_110101111*R_331[0]+Q_110101211*R_332[0]; double QR_010000012220=Q_010000012*R_220[0]+-1*Q_010000112*R_221[0]+Q_010000212*R_222[0]+-1*Q_010000312*R_223[0]+-1*Q_110000012*R_320[0]+Q_110000112*R_321[0]+-1*Q_110000212*R_322[0]+Q_110000312*R_323[0]; double QR_002010010220=Q_002010010*R_220[0]+-1*Q_002010110*R_221[0]+-1*Q_002110010*R_230[0]+Q_002110110*R_231[0]+-1*Q_102010010*R_320[0]+Q_102010110*R_321[0]+Q_102110010*R_330[0]+-1*Q_102110110*R_331[0]+Q_202010010*R_420[0]+-1*Q_202010110*R_421[0]+-1*Q_202110010*R_430[0]+Q_202110110*R_431[0]; double QR_001011010220=Q_001011010*R_220[0]+-1*Q_001011110*R_221[0]+-1*Q_001111010*R_230[0]+Q_001111110*R_231[0]+Q_001211010*R_240[0]+-1*Q_001211110*R_241[0]+-1*Q_101011010*R_320[0]+Q_101011110*R_321[0]+Q_101111010*R_330[0]+-1*Q_101111110*R_331[0]+-1*Q_101211010*R_340[0]+Q_101211110*R_341[0]; double QR_000012010220=Q_000012010*R_220[0]+-1*Q_000012110*R_221[0]+-1*Q_000112010*R_230[0]+Q_000112110*R_231[0]+Q_000212010*R_240[0]+-1*Q_000212110*R_241[0]+-1*Q_000312010*R_250[0]+Q_000312110*R_251[0]; double QR_001010011220=Q_001010011*R_220[0]+-1*Q_001010111*R_221[0]+Q_001010211*R_222[0]+-1*Q_001110011*R_230[0]+Q_001110111*R_231[0]+-1*Q_001110211*R_232[0]+-1*Q_101010011*R_320[0]+Q_101010111*R_321[0]+-1*Q_101010211*R_322[0]+Q_101110011*R_330[0]+-1*Q_101110111*R_331[0]+Q_101110211*R_332[0]; double QR_000011011220=Q_000011011*R_220[0]+-1*Q_000011111*R_221[0]+Q_000011211*R_222[0]+-1*Q_000111011*R_230[0]+Q_000111111*R_231[0]+-1*Q_000111211*R_232[0]+Q_000211011*R_240[0]+-1*Q_000211111*R_241[0]+Q_000211211*R_242[0]; double QR_000010012220=Q_000010012*R_220[0]+-1*Q_000010112*R_221[0]+Q_000010212*R_222[0]+-1*Q_000010312*R_223[0]+-1*Q_000110012*R_230[0]+Q_000110112*R_231[0]+-1*Q_000110212*R_232[0]+Q_000110312*R_233[0]; double QR_002000020220=Q_002000020*R_220[0]+-1*Q_002000120*R_221[0]+Q_002000220*R_222[0]+-1*Q_102000020*R_320[0]+Q_102000120*R_321[0]+-1*Q_102000220*R_322[0]+Q_202000020*R_420[0]+-1*Q_202000120*R_421[0]+Q_202000220*R_422[0]; double QR_001001020220=Q_001001020*R_220[0]+-1*Q_001001120*R_221[0]+Q_001001220*R_222[0]+-1*Q_001101020*R_230[0]+Q_001101120*R_231[0]+-1*Q_001101220*R_232[0]+-1*Q_101001020*R_320[0]+Q_101001120*R_321[0]+-1*Q_101001220*R_322[0]+Q_101101020*R_330[0]+-1*Q_101101120*R_331[0]+Q_101101220*R_332[0]; double QR_000002020220=Q_000002020*R_220[0]+-1*Q_000002120*R_221[0]+Q_000002220*R_222[0]+-1*Q_000102020*R_230[0]+Q_000102120*R_231[0]+-1*Q_000102220*R_232[0]+Q_000202020*R_240[0]+-1*Q_000202120*R_241[0]+Q_000202220*R_242[0]; double QR_001000021220=Q_001000021*R_220[0]+-1*Q_001000121*R_221[0]+Q_001000221*R_222[0]+-1*Q_001000321*R_223[0]+-1*Q_101000021*R_320[0]+Q_101000121*R_321[0]+-1*Q_101000221*R_322[0]+Q_101000321*R_323[0]; double QR_000001021220=Q_000001021*R_220[0]+-1*Q_000001121*R_221[0]+Q_000001221*R_222[0]+-1*Q_000001321*R_223[0]+-1*Q_000101021*R_230[0]+Q_000101121*R_231[0]+-1*Q_000101221*R_232[0]+Q_000101321*R_233[0]; double QR_000000022220=Q_000000022*R_220[0]+-1*Q_000000122*R_221[0]+Q_000000222*R_222[0]+-1*Q_000000322*R_223[0]+Q_000000422*R_224[0]; double QR_022000000301=Q_022000000*R_301[0]+-1*Q_122000000*R_401[0]+Q_222000000*R_501[0]+-1*Q_322000000*R_601[0]+Q_422000000*R_701[0]; double QR_021001000301=Q_021001000*R_301[0]+-1*Q_021101000*R_311[0]+-1*Q_121001000*R_401[0]+Q_121101000*R_411[0]+Q_221001000*R_501[0]+-1*Q_221101000*R_511[0]+-1*Q_321001000*R_601[0]+Q_321101000*R_611[0]; double QR_020002000301=Q_020002000*R_301[0]+-1*Q_020102000*R_311[0]+Q_020202000*R_321[0]+-1*Q_120002000*R_401[0]+Q_120102000*R_411[0]+-1*Q_120202000*R_421[0]+Q_220002000*R_501[0]+-1*Q_220102000*R_511[0]+Q_220202000*R_521[0]; double QR_021000001301=Q_021000001*R_301[0]+-1*Q_021000101*R_302[0]+-1*Q_121000001*R_401[0]+Q_121000101*R_402[0]+Q_221000001*R_501[0]+-1*Q_221000101*R_502[0]+-1*Q_321000001*R_601[0]+Q_321000101*R_602[0]; double QR_020001001301=Q_020001001*R_301[0]+-1*Q_020001101*R_302[0]+-1*Q_020101001*R_311[0]+Q_020101101*R_312[0]+-1*Q_120001001*R_401[0]+Q_120001101*R_402[0]+Q_120101001*R_411[0]+-1*Q_120101101*R_412[0]+Q_220001001*R_501[0]+-1*Q_220001101*R_502[0]+-1*Q_220101001*R_511[0]+Q_220101101*R_512[0]; double QR_020000002301=Q_020000002*R_301[0]+-1*Q_020000102*R_302[0]+Q_020000202*R_303[0]+-1*Q_120000002*R_401[0]+Q_120000102*R_402[0]+-1*Q_120000202*R_403[0]+Q_220000002*R_501[0]+-1*Q_220000102*R_502[0]+Q_220000202*R_503[0]; double QR_012010000301=Q_012010000*R_301[0]+-1*Q_012110000*R_311[0]+-1*Q_112010000*R_401[0]+Q_112110000*R_411[0]+Q_212010000*R_501[0]+-1*Q_212110000*R_511[0]+-1*Q_312010000*R_601[0]+Q_312110000*R_611[0]; double QR_011011000301=Q_011011000*R_301[0]+-1*Q_011111000*R_311[0]+Q_011211000*R_321[0]+-1*Q_111011000*R_401[0]+Q_111111000*R_411[0]+-1*Q_111211000*R_421[0]+Q_211011000*R_501[0]+-1*Q_211111000*R_511[0]+Q_211211000*R_521[0]; double QR_010012000301=Q_010012000*R_301[0]+-1*Q_010112000*R_311[0]+Q_010212000*R_321[0]+-1*Q_010312000*R_331[0]+-1*Q_110012000*R_401[0]+Q_110112000*R_411[0]+-1*Q_110212000*R_421[0]+Q_110312000*R_431[0]; double QR_011010001301=Q_011010001*R_301[0]+-1*Q_011010101*R_302[0]+-1*Q_011110001*R_311[0]+Q_011110101*R_312[0]+-1*Q_111010001*R_401[0]+Q_111010101*R_402[0]+Q_111110001*R_411[0]+-1*Q_111110101*R_412[0]+Q_211010001*R_501[0]+-1*Q_211010101*R_502[0]+-1*Q_211110001*R_511[0]+Q_211110101*R_512[0]; double QR_010011001301=Q_010011001*R_301[0]+-1*Q_010011101*R_302[0]+-1*Q_010111001*R_311[0]+Q_010111101*R_312[0]+Q_010211001*R_321[0]+-1*Q_010211101*R_322[0]+-1*Q_110011001*R_401[0]+Q_110011101*R_402[0]+Q_110111001*R_411[0]+-1*Q_110111101*R_412[0]+-1*Q_110211001*R_421[0]+Q_110211101*R_422[0]; double QR_010010002301=Q_010010002*R_301[0]+-1*Q_010010102*R_302[0]+Q_010010202*R_303[0]+-1*Q_010110002*R_311[0]+Q_010110102*R_312[0]+-1*Q_010110202*R_313[0]+-1*Q_110010002*R_401[0]+Q_110010102*R_402[0]+-1*Q_110010202*R_403[0]+Q_110110002*R_411[0]+-1*Q_110110102*R_412[0]+Q_110110202*R_413[0]; double QR_002020000301=Q_002020000*R_301[0]+-1*Q_002120000*R_311[0]+Q_002220000*R_321[0]+-1*Q_102020000*R_401[0]+Q_102120000*R_411[0]+-1*Q_102220000*R_421[0]+Q_202020000*R_501[0]+-1*Q_202120000*R_511[0]+Q_202220000*R_521[0]; double QR_001021000301=Q_001021000*R_301[0]+-1*Q_001121000*R_311[0]+Q_001221000*R_321[0]+-1*Q_001321000*R_331[0]+-1*Q_101021000*R_401[0]+Q_101121000*R_411[0]+-1*Q_101221000*R_421[0]+Q_101321000*R_431[0]; double QR_000022000301=Q_000022000*R_301[0]+-1*Q_000122000*R_311[0]+Q_000222000*R_321[0]+-1*Q_000322000*R_331[0]+Q_000422000*R_341[0]; double QR_001020001301=Q_001020001*R_301[0]+-1*Q_001020101*R_302[0]+-1*Q_001120001*R_311[0]+Q_001120101*R_312[0]+Q_001220001*R_321[0]+-1*Q_001220101*R_322[0]+-1*Q_101020001*R_401[0]+Q_101020101*R_402[0]+Q_101120001*R_411[0]+-1*Q_101120101*R_412[0]+-1*Q_101220001*R_421[0]+Q_101220101*R_422[0]; double QR_000021001301=Q_000021001*R_301[0]+-1*Q_000021101*R_302[0]+-1*Q_000121001*R_311[0]+Q_000121101*R_312[0]+Q_000221001*R_321[0]+-1*Q_000221101*R_322[0]+-1*Q_000321001*R_331[0]+Q_000321101*R_332[0]; double QR_000020002301=Q_000020002*R_301[0]+-1*Q_000020102*R_302[0]+Q_000020202*R_303[0]+-1*Q_000120002*R_311[0]+Q_000120102*R_312[0]+-1*Q_000120202*R_313[0]+Q_000220002*R_321[0]+-1*Q_000220102*R_322[0]+Q_000220202*R_323[0]; double QR_012000010301=Q_012000010*R_301[0]+-1*Q_012000110*R_302[0]+-1*Q_112000010*R_401[0]+Q_112000110*R_402[0]+Q_212000010*R_501[0]+-1*Q_212000110*R_502[0]+-1*Q_312000010*R_601[0]+Q_312000110*R_602[0]; double QR_011001010301=Q_011001010*R_301[0]+-1*Q_011001110*R_302[0]+-1*Q_011101010*R_311[0]+Q_011101110*R_312[0]+-1*Q_111001010*R_401[0]+Q_111001110*R_402[0]+Q_111101010*R_411[0]+-1*Q_111101110*R_412[0]+Q_211001010*R_501[0]+-1*Q_211001110*R_502[0]+-1*Q_211101010*R_511[0]+Q_211101110*R_512[0]; double QR_010002010301=Q_010002010*R_301[0]+-1*Q_010002110*R_302[0]+-1*Q_010102010*R_311[0]+Q_010102110*R_312[0]+Q_010202010*R_321[0]+-1*Q_010202110*R_322[0]+-1*Q_110002010*R_401[0]+Q_110002110*R_402[0]+Q_110102010*R_411[0]+-1*Q_110102110*R_412[0]+-1*Q_110202010*R_421[0]+Q_110202110*R_422[0]; double QR_011000011301=Q_011000011*R_301[0]+-1*Q_011000111*R_302[0]+Q_011000211*R_303[0]+-1*Q_111000011*R_401[0]+Q_111000111*R_402[0]+-1*Q_111000211*R_403[0]+Q_211000011*R_501[0]+-1*Q_211000111*R_502[0]+Q_211000211*R_503[0]; double QR_010001011301=Q_010001011*R_301[0]+-1*Q_010001111*R_302[0]+Q_010001211*R_303[0]+-1*Q_010101011*R_311[0]+Q_010101111*R_312[0]+-1*Q_010101211*R_313[0]+-1*Q_110001011*R_401[0]+Q_110001111*R_402[0]+-1*Q_110001211*R_403[0]+Q_110101011*R_411[0]+-1*Q_110101111*R_412[0]+Q_110101211*R_413[0]; double QR_010000012301=Q_010000012*R_301[0]+-1*Q_010000112*R_302[0]+Q_010000212*R_303[0]+-1*Q_010000312*R_304[0]+-1*Q_110000012*R_401[0]+Q_110000112*R_402[0]+-1*Q_110000212*R_403[0]+Q_110000312*R_404[0]; double QR_002010010301=Q_002010010*R_301[0]+-1*Q_002010110*R_302[0]+-1*Q_002110010*R_311[0]+Q_002110110*R_312[0]+-1*Q_102010010*R_401[0]+Q_102010110*R_402[0]+Q_102110010*R_411[0]+-1*Q_102110110*R_412[0]+Q_202010010*R_501[0]+-1*Q_202010110*R_502[0]+-1*Q_202110010*R_511[0]+Q_202110110*R_512[0]; double QR_001011010301=Q_001011010*R_301[0]+-1*Q_001011110*R_302[0]+-1*Q_001111010*R_311[0]+Q_001111110*R_312[0]+Q_001211010*R_321[0]+-1*Q_001211110*R_322[0]+-1*Q_101011010*R_401[0]+Q_101011110*R_402[0]+Q_101111010*R_411[0]+-1*Q_101111110*R_412[0]+-1*Q_101211010*R_421[0]+Q_101211110*R_422[0]; double QR_000012010301=Q_000012010*R_301[0]+-1*Q_000012110*R_302[0]+-1*Q_000112010*R_311[0]+Q_000112110*R_312[0]+Q_000212010*R_321[0]+-1*Q_000212110*R_322[0]+-1*Q_000312010*R_331[0]+Q_000312110*R_332[0]; double QR_001010011301=Q_001010011*R_301[0]+-1*Q_001010111*R_302[0]+Q_001010211*R_303[0]+-1*Q_001110011*R_311[0]+Q_001110111*R_312[0]+-1*Q_001110211*R_313[0]+-1*Q_101010011*R_401[0]+Q_101010111*R_402[0]+-1*Q_101010211*R_403[0]+Q_101110011*R_411[0]+-1*Q_101110111*R_412[0]+Q_101110211*R_413[0]; double QR_000011011301=Q_000011011*R_301[0]+-1*Q_000011111*R_302[0]+Q_000011211*R_303[0]+-1*Q_000111011*R_311[0]+Q_000111111*R_312[0]+-1*Q_000111211*R_313[0]+Q_000211011*R_321[0]+-1*Q_000211111*R_322[0]+Q_000211211*R_323[0]; double QR_000010012301=Q_000010012*R_301[0]+-1*Q_000010112*R_302[0]+Q_000010212*R_303[0]+-1*Q_000010312*R_304[0]+-1*Q_000110012*R_311[0]+Q_000110112*R_312[0]+-1*Q_000110212*R_313[0]+Q_000110312*R_314[0]; double QR_002000020301=Q_002000020*R_301[0]+-1*Q_002000120*R_302[0]+Q_002000220*R_303[0]+-1*Q_102000020*R_401[0]+Q_102000120*R_402[0]+-1*Q_102000220*R_403[0]+Q_202000020*R_501[0]+-1*Q_202000120*R_502[0]+Q_202000220*R_503[0]; double QR_001001020301=Q_001001020*R_301[0]+-1*Q_001001120*R_302[0]+Q_001001220*R_303[0]+-1*Q_001101020*R_311[0]+Q_001101120*R_312[0]+-1*Q_001101220*R_313[0]+-1*Q_101001020*R_401[0]+Q_101001120*R_402[0]+-1*Q_101001220*R_403[0]+Q_101101020*R_411[0]+-1*Q_101101120*R_412[0]+Q_101101220*R_413[0]; double QR_000002020301=Q_000002020*R_301[0]+-1*Q_000002120*R_302[0]+Q_000002220*R_303[0]+-1*Q_000102020*R_311[0]+Q_000102120*R_312[0]+-1*Q_000102220*R_313[0]+Q_000202020*R_321[0]+-1*Q_000202120*R_322[0]+Q_000202220*R_323[0]; double QR_001000021301=Q_001000021*R_301[0]+-1*Q_001000121*R_302[0]+Q_001000221*R_303[0]+-1*Q_001000321*R_304[0]+-1*Q_101000021*R_401[0]+Q_101000121*R_402[0]+-1*Q_101000221*R_403[0]+Q_101000321*R_404[0]; double QR_000001021301=Q_000001021*R_301[0]+-1*Q_000001121*R_302[0]+Q_000001221*R_303[0]+-1*Q_000001321*R_304[0]+-1*Q_000101021*R_311[0]+Q_000101121*R_312[0]+-1*Q_000101221*R_313[0]+Q_000101321*R_314[0]; double QR_000000022301=Q_000000022*R_301[0]+-1*Q_000000122*R_302[0]+Q_000000222*R_303[0]+-1*Q_000000322*R_304[0]+Q_000000422*R_305[0]; double QR_022000000310=Q_022000000*R_310[0]+-1*Q_122000000*R_410[0]+Q_222000000*R_510[0]+-1*Q_322000000*R_610[0]+Q_422000000*R_710[0]; double QR_021001000310=Q_021001000*R_310[0]+-1*Q_021101000*R_320[0]+-1*Q_121001000*R_410[0]+Q_121101000*R_420[0]+Q_221001000*R_510[0]+-1*Q_221101000*R_520[0]+-1*Q_321001000*R_610[0]+Q_321101000*R_620[0]; double QR_020002000310=Q_020002000*R_310[0]+-1*Q_020102000*R_320[0]+Q_020202000*R_330[0]+-1*Q_120002000*R_410[0]+Q_120102000*R_420[0]+-1*Q_120202000*R_430[0]+Q_220002000*R_510[0]+-1*Q_220102000*R_520[0]+Q_220202000*R_530[0]; double QR_021000001310=Q_021000001*R_310[0]+-1*Q_021000101*R_311[0]+-1*Q_121000001*R_410[0]+Q_121000101*R_411[0]+Q_221000001*R_510[0]+-1*Q_221000101*R_511[0]+-1*Q_321000001*R_610[0]+Q_321000101*R_611[0]; double QR_020001001310=Q_020001001*R_310[0]+-1*Q_020001101*R_311[0]+-1*Q_020101001*R_320[0]+Q_020101101*R_321[0]+-1*Q_120001001*R_410[0]+Q_120001101*R_411[0]+Q_120101001*R_420[0]+-1*Q_120101101*R_421[0]+Q_220001001*R_510[0]+-1*Q_220001101*R_511[0]+-1*Q_220101001*R_520[0]+Q_220101101*R_521[0]; double QR_020000002310=Q_020000002*R_310[0]+-1*Q_020000102*R_311[0]+Q_020000202*R_312[0]+-1*Q_120000002*R_410[0]+Q_120000102*R_411[0]+-1*Q_120000202*R_412[0]+Q_220000002*R_510[0]+-1*Q_220000102*R_511[0]+Q_220000202*R_512[0]; double QR_012010000310=Q_012010000*R_310[0]+-1*Q_012110000*R_320[0]+-1*Q_112010000*R_410[0]+Q_112110000*R_420[0]+Q_212010000*R_510[0]+-1*Q_212110000*R_520[0]+-1*Q_312010000*R_610[0]+Q_312110000*R_620[0]; double QR_011011000310=Q_011011000*R_310[0]+-1*Q_011111000*R_320[0]+Q_011211000*R_330[0]+-1*Q_111011000*R_410[0]+Q_111111000*R_420[0]+-1*Q_111211000*R_430[0]+Q_211011000*R_510[0]+-1*Q_211111000*R_520[0]+Q_211211000*R_530[0]; double QR_010012000310=Q_010012000*R_310[0]+-1*Q_010112000*R_320[0]+Q_010212000*R_330[0]+-1*Q_010312000*R_340[0]+-1*Q_110012000*R_410[0]+Q_110112000*R_420[0]+-1*Q_110212000*R_430[0]+Q_110312000*R_440[0]; double QR_011010001310=Q_011010001*R_310[0]+-1*Q_011010101*R_311[0]+-1*Q_011110001*R_320[0]+Q_011110101*R_321[0]+-1*Q_111010001*R_410[0]+Q_111010101*R_411[0]+Q_111110001*R_420[0]+-1*Q_111110101*R_421[0]+Q_211010001*R_510[0]+-1*Q_211010101*R_511[0]+-1*Q_211110001*R_520[0]+Q_211110101*R_521[0]; double QR_010011001310=Q_010011001*R_310[0]+-1*Q_010011101*R_311[0]+-1*Q_010111001*R_320[0]+Q_010111101*R_321[0]+Q_010211001*R_330[0]+-1*Q_010211101*R_331[0]+-1*Q_110011001*R_410[0]+Q_110011101*R_411[0]+Q_110111001*R_420[0]+-1*Q_110111101*R_421[0]+-1*Q_110211001*R_430[0]+Q_110211101*R_431[0]; double QR_010010002310=Q_010010002*R_310[0]+-1*Q_010010102*R_311[0]+Q_010010202*R_312[0]+-1*Q_010110002*R_320[0]+Q_010110102*R_321[0]+-1*Q_010110202*R_322[0]+-1*Q_110010002*R_410[0]+Q_110010102*R_411[0]+-1*Q_110010202*R_412[0]+Q_110110002*R_420[0]+-1*Q_110110102*R_421[0]+Q_110110202*R_422[0]; double QR_002020000310=Q_002020000*R_310[0]+-1*Q_002120000*R_320[0]+Q_002220000*R_330[0]+-1*Q_102020000*R_410[0]+Q_102120000*R_420[0]+-1*Q_102220000*R_430[0]+Q_202020000*R_510[0]+-1*Q_202120000*R_520[0]+Q_202220000*R_530[0]; double QR_001021000310=Q_001021000*R_310[0]+-1*Q_001121000*R_320[0]+Q_001221000*R_330[0]+-1*Q_001321000*R_340[0]+-1*Q_101021000*R_410[0]+Q_101121000*R_420[0]+-1*Q_101221000*R_430[0]+Q_101321000*R_440[0]; double QR_000022000310=Q_000022000*R_310[0]+-1*Q_000122000*R_320[0]+Q_000222000*R_330[0]+-1*Q_000322000*R_340[0]+Q_000422000*R_350[0]; double QR_001020001310=Q_001020001*R_310[0]+-1*Q_001020101*R_311[0]+-1*Q_001120001*R_320[0]+Q_001120101*R_321[0]+Q_001220001*R_330[0]+-1*Q_001220101*R_331[0]+-1*Q_101020001*R_410[0]+Q_101020101*R_411[0]+Q_101120001*R_420[0]+-1*Q_101120101*R_421[0]+-1*Q_101220001*R_430[0]+Q_101220101*R_431[0]; double QR_000021001310=Q_000021001*R_310[0]+-1*Q_000021101*R_311[0]+-1*Q_000121001*R_320[0]+Q_000121101*R_321[0]+Q_000221001*R_330[0]+-1*Q_000221101*R_331[0]+-1*Q_000321001*R_340[0]+Q_000321101*R_341[0]; double QR_000020002310=Q_000020002*R_310[0]+-1*Q_000020102*R_311[0]+Q_000020202*R_312[0]+-1*Q_000120002*R_320[0]+Q_000120102*R_321[0]+-1*Q_000120202*R_322[0]+Q_000220002*R_330[0]+-1*Q_000220102*R_331[0]+Q_000220202*R_332[0]; double QR_012000010310=Q_012000010*R_310[0]+-1*Q_012000110*R_311[0]+-1*Q_112000010*R_410[0]+Q_112000110*R_411[0]+Q_212000010*R_510[0]+-1*Q_212000110*R_511[0]+-1*Q_312000010*R_610[0]+Q_312000110*R_611[0]; double QR_011001010310=Q_011001010*R_310[0]+-1*Q_011001110*R_311[0]+-1*Q_011101010*R_320[0]+Q_011101110*R_321[0]+-1*Q_111001010*R_410[0]+Q_111001110*R_411[0]+Q_111101010*R_420[0]+-1*Q_111101110*R_421[0]+Q_211001010*R_510[0]+-1*Q_211001110*R_511[0]+-1*Q_211101010*R_520[0]+Q_211101110*R_521[0]; double QR_010002010310=Q_010002010*R_310[0]+-1*Q_010002110*R_311[0]+-1*Q_010102010*R_320[0]+Q_010102110*R_321[0]+Q_010202010*R_330[0]+-1*Q_010202110*R_331[0]+-1*Q_110002010*R_410[0]+Q_110002110*R_411[0]+Q_110102010*R_420[0]+-1*Q_110102110*R_421[0]+-1*Q_110202010*R_430[0]+Q_110202110*R_431[0]; double QR_011000011310=Q_011000011*R_310[0]+-1*Q_011000111*R_311[0]+Q_011000211*R_312[0]+-1*Q_111000011*R_410[0]+Q_111000111*R_411[0]+-1*Q_111000211*R_412[0]+Q_211000011*R_510[0]+-1*Q_211000111*R_511[0]+Q_211000211*R_512[0]; double QR_010001011310=Q_010001011*R_310[0]+-1*Q_010001111*R_311[0]+Q_010001211*R_312[0]+-1*Q_010101011*R_320[0]+Q_010101111*R_321[0]+-1*Q_010101211*R_322[0]+-1*Q_110001011*R_410[0]+Q_110001111*R_411[0]+-1*Q_110001211*R_412[0]+Q_110101011*R_420[0]+-1*Q_110101111*R_421[0]+Q_110101211*R_422[0]; double QR_010000012310=Q_010000012*R_310[0]+-1*Q_010000112*R_311[0]+Q_010000212*R_312[0]+-1*Q_010000312*R_313[0]+-1*Q_110000012*R_410[0]+Q_110000112*R_411[0]+-1*Q_110000212*R_412[0]+Q_110000312*R_413[0]; double QR_002010010310=Q_002010010*R_310[0]+-1*Q_002010110*R_311[0]+-1*Q_002110010*R_320[0]+Q_002110110*R_321[0]+-1*Q_102010010*R_410[0]+Q_102010110*R_411[0]+Q_102110010*R_420[0]+-1*Q_102110110*R_421[0]+Q_202010010*R_510[0]+-1*Q_202010110*R_511[0]+-1*Q_202110010*R_520[0]+Q_202110110*R_521[0]; double QR_001011010310=Q_001011010*R_310[0]+-1*Q_001011110*R_311[0]+-1*Q_001111010*R_320[0]+Q_001111110*R_321[0]+Q_001211010*R_330[0]+-1*Q_001211110*R_331[0]+-1*Q_101011010*R_410[0]+Q_101011110*R_411[0]+Q_101111010*R_420[0]+-1*Q_101111110*R_421[0]+-1*Q_101211010*R_430[0]+Q_101211110*R_431[0]; double QR_000012010310=Q_000012010*R_310[0]+-1*Q_000012110*R_311[0]+-1*Q_000112010*R_320[0]+Q_000112110*R_321[0]+Q_000212010*R_330[0]+-1*Q_000212110*R_331[0]+-1*Q_000312010*R_340[0]+Q_000312110*R_341[0]; double QR_001010011310=Q_001010011*R_310[0]+-1*Q_001010111*R_311[0]+Q_001010211*R_312[0]+-1*Q_001110011*R_320[0]+Q_001110111*R_321[0]+-1*Q_001110211*R_322[0]+-1*Q_101010011*R_410[0]+Q_101010111*R_411[0]+-1*Q_101010211*R_412[0]+Q_101110011*R_420[0]+-1*Q_101110111*R_421[0]+Q_101110211*R_422[0]; double QR_000011011310=Q_000011011*R_310[0]+-1*Q_000011111*R_311[0]+Q_000011211*R_312[0]+-1*Q_000111011*R_320[0]+Q_000111111*R_321[0]+-1*Q_000111211*R_322[0]+Q_000211011*R_330[0]+-1*Q_000211111*R_331[0]+Q_000211211*R_332[0]; double QR_000010012310=Q_000010012*R_310[0]+-1*Q_000010112*R_311[0]+Q_000010212*R_312[0]+-1*Q_000010312*R_313[0]+-1*Q_000110012*R_320[0]+Q_000110112*R_321[0]+-1*Q_000110212*R_322[0]+Q_000110312*R_323[0]; double QR_002000020310=Q_002000020*R_310[0]+-1*Q_002000120*R_311[0]+Q_002000220*R_312[0]+-1*Q_102000020*R_410[0]+Q_102000120*R_411[0]+-1*Q_102000220*R_412[0]+Q_202000020*R_510[0]+-1*Q_202000120*R_511[0]+Q_202000220*R_512[0]; double QR_001001020310=Q_001001020*R_310[0]+-1*Q_001001120*R_311[0]+Q_001001220*R_312[0]+-1*Q_001101020*R_320[0]+Q_001101120*R_321[0]+-1*Q_001101220*R_322[0]+-1*Q_101001020*R_410[0]+Q_101001120*R_411[0]+-1*Q_101001220*R_412[0]+Q_101101020*R_420[0]+-1*Q_101101120*R_421[0]+Q_101101220*R_422[0]; double QR_000002020310=Q_000002020*R_310[0]+-1*Q_000002120*R_311[0]+Q_000002220*R_312[0]+-1*Q_000102020*R_320[0]+Q_000102120*R_321[0]+-1*Q_000102220*R_322[0]+Q_000202020*R_330[0]+-1*Q_000202120*R_331[0]+Q_000202220*R_332[0]; double QR_001000021310=Q_001000021*R_310[0]+-1*Q_001000121*R_311[0]+Q_001000221*R_312[0]+-1*Q_001000321*R_313[0]+-1*Q_101000021*R_410[0]+Q_101000121*R_411[0]+-1*Q_101000221*R_412[0]+Q_101000321*R_413[0]; double QR_000001021310=Q_000001021*R_310[0]+-1*Q_000001121*R_311[0]+Q_000001221*R_312[0]+-1*Q_000001321*R_313[0]+-1*Q_000101021*R_320[0]+Q_000101121*R_321[0]+-1*Q_000101221*R_322[0]+Q_000101321*R_323[0]; double QR_000000022310=Q_000000022*R_310[0]+-1*Q_000000122*R_311[0]+Q_000000222*R_312[0]+-1*Q_000000322*R_313[0]+Q_000000422*R_314[0]; double QR_022000000400=Q_022000000*R_400[0]+-1*Q_122000000*R_500[0]+Q_222000000*R_600[0]+-1*Q_322000000*R_700[0]+Q_422000000*R_800[0]; double QR_021001000400=Q_021001000*R_400[0]+-1*Q_021101000*R_410[0]+-1*Q_121001000*R_500[0]+Q_121101000*R_510[0]+Q_221001000*R_600[0]+-1*Q_221101000*R_610[0]+-1*Q_321001000*R_700[0]+Q_321101000*R_710[0]; double QR_020002000400=Q_020002000*R_400[0]+-1*Q_020102000*R_410[0]+Q_020202000*R_420[0]+-1*Q_120002000*R_500[0]+Q_120102000*R_510[0]+-1*Q_120202000*R_520[0]+Q_220002000*R_600[0]+-1*Q_220102000*R_610[0]+Q_220202000*R_620[0]; double QR_021000001400=Q_021000001*R_400[0]+-1*Q_021000101*R_401[0]+-1*Q_121000001*R_500[0]+Q_121000101*R_501[0]+Q_221000001*R_600[0]+-1*Q_221000101*R_601[0]+-1*Q_321000001*R_700[0]+Q_321000101*R_701[0]; double QR_020001001400=Q_020001001*R_400[0]+-1*Q_020001101*R_401[0]+-1*Q_020101001*R_410[0]+Q_020101101*R_411[0]+-1*Q_120001001*R_500[0]+Q_120001101*R_501[0]+Q_120101001*R_510[0]+-1*Q_120101101*R_511[0]+Q_220001001*R_600[0]+-1*Q_220001101*R_601[0]+-1*Q_220101001*R_610[0]+Q_220101101*R_611[0]; double QR_020000002400=Q_020000002*R_400[0]+-1*Q_020000102*R_401[0]+Q_020000202*R_402[0]+-1*Q_120000002*R_500[0]+Q_120000102*R_501[0]+-1*Q_120000202*R_502[0]+Q_220000002*R_600[0]+-1*Q_220000102*R_601[0]+Q_220000202*R_602[0]; double QR_012010000400=Q_012010000*R_400[0]+-1*Q_012110000*R_410[0]+-1*Q_112010000*R_500[0]+Q_112110000*R_510[0]+Q_212010000*R_600[0]+-1*Q_212110000*R_610[0]+-1*Q_312010000*R_700[0]+Q_312110000*R_710[0]; double QR_011011000400=Q_011011000*R_400[0]+-1*Q_011111000*R_410[0]+Q_011211000*R_420[0]+-1*Q_111011000*R_500[0]+Q_111111000*R_510[0]+-1*Q_111211000*R_520[0]+Q_211011000*R_600[0]+-1*Q_211111000*R_610[0]+Q_211211000*R_620[0]; double QR_010012000400=Q_010012000*R_400[0]+-1*Q_010112000*R_410[0]+Q_010212000*R_420[0]+-1*Q_010312000*R_430[0]+-1*Q_110012000*R_500[0]+Q_110112000*R_510[0]+-1*Q_110212000*R_520[0]+Q_110312000*R_530[0]; double QR_011010001400=Q_011010001*R_400[0]+-1*Q_011010101*R_401[0]+-1*Q_011110001*R_410[0]+Q_011110101*R_411[0]+-1*Q_111010001*R_500[0]+Q_111010101*R_501[0]+Q_111110001*R_510[0]+-1*Q_111110101*R_511[0]+Q_211010001*R_600[0]+-1*Q_211010101*R_601[0]+-1*Q_211110001*R_610[0]+Q_211110101*R_611[0]; double QR_010011001400=Q_010011001*R_400[0]+-1*Q_010011101*R_401[0]+-1*Q_010111001*R_410[0]+Q_010111101*R_411[0]+Q_010211001*R_420[0]+-1*Q_010211101*R_421[0]+-1*Q_110011001*R_500[0]+Q_110011101*R_501[0]+Q_110111001*R_510[0]+-1*Q_110111101*R_511[0]+-1*Q_110211001*R_520[0]+Q_110211101*R_521[0]; double QR_010010002400=Q_010010002*R_400[0]+-1*Q_010010102*R_401[0]+Q_010010202*R_402[0]+-1*Q_010110002*R_410[0]+Q_010110102*R_411[0]+-1*Q_010110202*R_412[0]+-1*Q_110010002*R_500[0]+Q_110010102*R_501[0]+-1*Q_110010202*R_502[0]+Q_110110002*R_510[0]+-1*Q_110110102*R_511[0]+Q_110110202*R_512[0]; double QR_002020000400=Q_002020000*R_400[0]+-1*Q_002120000*R_410[0]+Q_002220000*R_420[0]+-1*Q_102020000*R_500[0]+Q_102120000*R_510[0]+-1*Q_102220000*R_520[0]+Q_202020000*R_600[0]+-1*Q_202120000*R_610[0]+Q_202220000*R_620[0]; double QR_001021000400=Q_001021000*R_400[0]+-1*Q_001121000*R_410[0]+Q_001221000*R_420[0]+-1*Q_001321000*R_430[0]+-1*Q_101021000*R_500[0]+Q_101121000*R_510[0]+-1*Q_101221000*R_520[0]+Q_101321000*R_530[0]; double QR_000022000400=Q_000022000*R_400[0]+-1*Q_000122000*R_410[0]+Q_000222000*R_420[0]+-1*Q_000322000*R_430[0]+Q_000422000*R_440[0]; double QR_001020001400=Q_001020001*R_400[0]+-1*Q_001020101*R_401[0]+-1*Q_001120001*R_410[0]+Q_001120101*R_411[0]+Q_001220001*R_420[0]+-1*Q_001220101*R_421[0]+-1*Q_101020001*R_500[0]+Q_101020101*R_501[0]+Q_101120001*R_510[0]+-1*Q_101120101*R_511[0]+-1*Q_101220001*R_520[0]+Q_101220101*R_521[0]; double QR_000021001400=Q_000021001*R_400[0]+-1*Q_000021101*R_401[0]+-1*Q_000121001*R_410[0]+Q_000121101*R_411[0]+Q_000221001*R_420[0]+-1*Q_000221101*R_421[0]+-1*Q_000321001*R_430[0]+Q_000321101*R_431[0]; double QR_000020002400=Q_000020002*R_400[0]+-1*Q_000020102*R_401[0]+Q_000020202*R_402[0]+-1*Q_000120002*R_410[0]+Q_000120102*R_411[0]+-1*Q_000120202*R_412[0]+Q_000220002*R_420[0]+-1*Q_000220102*R_421[0]+Q_000220202*R_422[0]; double QR_012000010400=Q_012000010*R_400[0]+-1*Q_012000110*R_401[0]+-1*Q_112000010*R_500[0]+Q_112000110*R_501[0]+Q_212000010*R_600[0]+-1*Q_212000110*R_601[0]+-1*Q_312000010*R_700[0]+Q_312000110*R_701[0]; double QR_011001010400=Q_011001010*R_400[0]+-1*Q_011001110*R_401[0]+-1*Q_011101010*R_410[0]+Q_011101110*R_411[0]+-1*Q_111001010*R_500[0]+Q_111001110*R_501[0]+Q_111101010*R_510[0]+-1*Q_111101110*R_511[0]+Q_211001010*R_600[0]+-1*Q_211001110*R_601[0]+-1*Q_211101010*R_610[0]+Q_211101110*R_611[0]; double QR_010002010400=Q_010002010*R_400[0]+-1*Q_010002110*R_401[0]+-1*Q_010102010*R_410[0]+Q_010102110*R_411[0]+Q_010202010*R_420[0]+-1*Q_010202110*R_421[0]+-1*Q_110002010*R_500[0]+Q_110002110*R_501[0]+Q_110102010*R_510[0]+-1*Q_110102110*R_511[0]+-1*Q_110202010*R_520[0]+Q_110202110*R_521[0]; double QR_011000011400=Q_011000011*R_400[0]+-1*Q_011000111*R_401[0]+Q_011000211*R_402[0]+-1*Q_111000011*R_500[0]+Q_111000111*R_501[0]+-1*Q_111000211*R_502[0]+Q_211000011*R_600[0]+-1*Q_211000111*R_601[0]+Q_211000211*R_602[0]; double QR_010001011400=Q_010001011*R_400[0]+-1*Q_010001111*R_401[0]+Q_010001211*R_402[0]+-1*Q_010101011*R_410[0]+Q_010101111*R_411[0]+-1*Q_010101211*R_412[0]+-1*Q_110001011*R_500[0]+Q_110001111*R_501[0]+-1*Q_110001211*R_502[0]+Q_110101011*R_510[0]+-1*Q_110101111*R_511[0]+Q_110101211*R_512[0]; double QR_010000012400=Q_010000012*R_400[0]+-1*Q_010000112*R_401[0]+Q_010000212*R_402[0]+-1*Q_010000312*R_403[0]+-1*Q_110000012*R_500[0]+Q_110000112*R_501[0]+-1*Q_110000212*R_502[0]+Q_110000312*R_503[0]; double QR_002010010400=Q_002010010*R_400[0]+-1*Q_002010110*R_401[0]+-1*Q_002110010*R_410[0]+Q_002110110*R_411[0]+-1*Q_102010010*R_500[0]+Q_102010110*R_501[0]+Q_102110010*R_510[0]+-1*Q_102110110*R_511[0]+Q_202010010*R_600[0]+-1*Q_202010110*R_601[0]+-1*Q_202110010*R_610[0]+Q_202110110*R_611[0]; double QR_001011010400=Q_001011010*R_400[0]+-1*Q_001011110*R_401[0]+-1*Q_001111010*R_410[0]+Q_001111110*R_411[0]+Q_001211010*R_420[0]+-1*Q_001211110*R_421[0]+-1*Q_101011010*R_500[0]+Q_101011110*R_501[0]+Q_101111010*R_510[0]+-1*Q_101111110*R_511[0]+-1*Q_101211010*R_520[0]+Q_101211110*R_521[0]; double QR_000012010400=Q_000012010*R_400[0]+-1*Q_000012110*R_401[0]+-1*Q_000112010*R_410[0]+Q_000112110*R_411[0]+Q_000212010*R_420[0]+-1*Q_000212110*R_421[0]+-1*Q_000312010*R_430[0]+Q_000312110*R_431[0]; double QR_001010011400=Q_001010011*R_400[0]+-1*Q_001010111*R_401[0]+Q_001010211*R_402[0]+-1*Q_001110011*R_410[0]+Q_001110111*R_411[0]+-1*Q_001110211*R_412[0]+-1*Q_101010011*R_500[0]+Q_101010111*R_501[0]+-1*Q_101010211*R_502[0]+Q_101110011*R_510[0]+-1*Q_101110111*R_511[0]+Q_101110211*R_512[0]; double QR_000011011400=Q_000011011*R_400[0]+-1*Q_000011111*R_401[0]+Q_000011211*R_402[0]+-1*Q_000111011*R_410[0]+Q_000111111*R_411[0]+-1*Q_000111211*R_412[0]+Q_000211011*R_420[0]+-1*Q_000211111*R_421[0]+Q_000211211*R_422[0]; double QR_000010012400=Q_000010012*R_400[0]+-1*Q_000010112*R_401[0]+Q_000010212*R_402[0]+-1*Q_000010312*R_403[0]+-1*Q_000110012*R_410[0]+Q_000110112*R_411[0]+-1*Q_000110212*R_412[0]+Q_000110312*R_413[0]; double QR_002000020400=Q_002000020*R_400[0]+-1*Q_002000120*R_401[0]+Q_002000220*R_402[0]+-1*Q_102000020*R_500[0]+Q_102000120*R_501[0]+-1*Q_102000220*R_502[0]+Q_202000020*R_600[0]+-1*Q_202000120*R_601[0]+Q_202000220*R_602[0]; double QR_001001020400=Q_001001020*R_400[0]+-1*Q_001001120*R_401[0]+Q_001001220*R_402[0]+-1*Q_001101020*R_410[0]+Q_001101120*R_411[0]+-1*Q_001101220*R_412[0]+-1*Q_101001020*R_500[0]+Q_101001120*R_501[0]+-1*Q_101001220*R_502[0]+Q_101101020*R_510[0]+-1*Q_101101120*R_511[0]+Q_101101220*R_512[0]; double QR_000002020400=Q_000002020*R_400[0]+-1*Q_000002120*R_401[0]+Q_000002220*R_402[0]+-1*Q_000102020*R_410[0]+Q_000102120*R_411[0]+-1*Q_000102220*R_412[0]+Q_000202020*R_420[0]+-1*Q_000202120*R_421[0]+Q_000202220*R_422[0]; double QR_001000021400=Q_001000021*R_400[0]+-1*Q_001000121*R_401[0]+Q_001000221*R_402[0]+-1*Q_001000321*R_403[0]+-1*Q_101000021*R_500[0]+Q_101000121*R_501[0]+-1*Q_101000221*R_502[0]+Q_101000321*R_503[0]; double QR_000001021400=Q_000001021*R_400[0]+-1*Q_000001121*R_401[0]+Q_000001221*R_402[0]+-1*Q_000001321*R_403[0]+-1*Q_000101021*R_410[0]+Q_000101121*R_411[0]+-1*Q_000101221*R_412[0]+Q_000101321*R_413[0]; double QR_000000022400=Q_000000022*R_400[0]+-1*Q_000000122*R_401[0]+Q_000000222*R_402[0]+-1*Q_000000322*R_403[0]+Q_000000422*R_404[0]; double Pd_101[3]; double Pd_002[3]; double Pd_102[3]; double Pd_202[3]; double Pd_110[3]; double Pd_011[3]; double Pd_111[3]; double Pd_211[3]; double Pd_012[3]; double Pd_112[3]; double Pd_212[3]; double Pd_312[3]; double Pd_020[3]; double Pd_120[3]; double Pd_220[3]; double Pd_021[3]; double Pd_121[3]; double Pd_221[3]; double Pd_321[3]; double Pd_022[3]; double Pd_122[3]; double Pd_222[3]; double Pd_322[3]; double Pd_422[3]; for(int i=0;i<3;i++){ Pd_101[i]=aPin1; } for(int i=0;i<3;i++){ Pd_002[i]=Pd_101[i]+Pd_001[i]*Pd_001[i]; } for(int i=0;i<3;i++){ Pd_102[i]=Pd_001[i]*Pd_101[i]+aPin1*Pd_001[i]; } for(int i=0;i<3;i++){ Pd_202[i]=aPin1*Pd_101[i]; } for(int i=0;i<3;i++){ Pd_110[i]=aPin1; } for(int i=0;i<3;i++){ Pd_011[i]=Pd_101[i]+Pd_010[i]*Pd_001[i]; } for(int i=0;i<3;i++){ Pd_111[i]=Pd_010[i]*Pd_101[i]+aPin1*Pd_001[i]; } for(int i=0;i<3;i++){ Pd_211[i]=aPin1*Pd_101[i]; } for(int i=0;i<3;i++){ Pd_012[i]=Pd_111[i]+Pd_001[i]*Pd_011[i]; } for(int i=0;i<3;i++){ Pd_112[i]=2*Pd_211[i]+Pd_001[i]*Pd_111[i]+aPin1*Pd_011[i]; } for(int i=0;i<3;i++){ Pd_212[i]=Pd_001[i]*Pd_211[i]+aPin1*Pd_111[i]; } for(int i=0;i<3;i++){ Pd_312[i]=aPin1*Pd_211[i]; } for(int i=0;i<3;i++){ Pd_020[i]=Pd_110[i]+Pd_010[i]*Pd_010[i]; } for(int i=0;i<3;i++){ Pd_120[i]=Pd_010[i]*Pd_110[i]+aPin1*Pd_010[i]; } for(int i=0;i<3;i++){ Pd_220[i]=aPin1*Pd_110[i]; } for(int i=0;i<3;i++){ Pd_021[i]=Pd_111[i]+Pd_010[i]*Pd_011[i]; } for(int i=0;i<3;i++){ Pd_121[i]=2*Pd_211[i]+Pd_010[i]*Pd_111[i]+aPin1*Pd_011[i]; } for(int i=0;i<3;i++){ Pd_221[i]=Pd_010[i]*Pd_211[i]+aPin1*Pd_111[i]; } for(int i=0;i<3;i++){ Pd_321[i]=aPin1*Pd_211[i]; } for(int i=0;i<3;i++){ Pd_022[i]=Pd_112[i]+Pd_010[i]*Pd_012[i]; } for(int i=0;i<3;i++){ Pd_122[i]=2*Pd_212[i]+Pd_010[i]*Pd_112[i]+aPin1*Pd_012[i]; } for(int i=0;i<3;i++){ Pd_222[i]=3*Pd_312[i]+Pd_010[i]*Pd_212[i]+aPin1*Pd_112[i]; } for(int i=0;i<3;i++){ Pd_322[i]=Pd_010[i]*Pd_312[i]+aPin1*Pd_212[i]; } for(int i=0;i<3;i++){ Pd_422[i]=aPin1*Pd_312[i]; } double P_022000000=Pd_022[0]; double P_122000000=Pd_122[0]; double P_222000000=Pd_222[0]; double P_322000000=Pd_322[0]; double P_422000000=Pd_422[0]; double P_021001000=Pd_021[0]*Pd_001[1]; double P_021101000=Pd_021[0]*Pd_101[1]; double P_121001000=Pd_121[0]*Pd_001[1]; double P_121101000=Pd_121[0]*Pd_101[1]; double P_221001000=Pd_221[0]*Pd_001[1]; double P_221101000=Pd_221[0]*Pd_101[1]; double P_321001000=Pd_321[0]*Pd_001[1]; double P_321101000=Pd_321[0]*Pd_101[1]; double P_020002000=Pd_020[0]*Pd_002[1]; double P_020102000=Pd_020[0]*Pd_102[1]; double P_020202000=Pd_020[0]*Pd_202[1]; double P_120002000=Pd_120[0]*Pd_002[1]; double P_120102000=Pd_120[0]*Pd_102[1]; double P_120202000=Pd_120[0]*Pd_202[1]; double P_220002000=Pd_220[0]*Pd_002[1]; double P_220102000=Pd_220[0]*Pd_102[1]; double P_220202000=Pd_220[0]*Pd_202[1]; double P_021000001=Pd_021[0]*Pd_001[2]; double P_021000101=Pd_021[0]*Pd_101[2]; double P_121000001=Pd_121[0]*Pd_001[2]; double P_121000101=Pd_121[0]*Pd_101[2]; double P_221000001=Pd_221[0]*Pd_001[2]; double P_221000101=Pd_221[0]*Pd_101[2]; double P_321000001=Pd_321[0]*Pd_001[2]; double P_321000101=Pd_321[0]*Pd_101[2]; double P_020001001=Pd_020[0]*Pd_001[1]*Pd_001[2]; double P_020001101=Pd_020[0]*Pd_001[1]*Pd_101[2]; double P_020101001=Pd_020[0]*Pd_101[1]*Pd_001[2]; double P_020101101=Pd_020[0]*Pd_101[1]*Pd_101[2]; double P_120001001=Pd_120[0]*Pd_001[1]*Pd_001[2]; double P_120001101=Pd_120[0]*Pd_001[1]*Pd_101[2]; double P_120101001=Pd_120[0]*Pd_101[1]*Pd_001[2]; double P_120101101=Pd_120[0]*Pd_101[1]*Pd_101[2]; double P_220001001=Pd_220[0]*Pd_001[1]*Pd_001[2]; double P_220001101=Pd_220[0]*Pd_001[1]*Pd_101[2]; double P_220101001=Pd_220[0]*Pd_101[1]*Pd_001[2]; double P_220101101=Pd_220[0]*Pd_101[1]*Pd_101[2]; double P_020000002=Pd_020[0]*Pd_002[2]; double P_020000102=Pd_020[0]*Pd_102[2]; double P_020000202=Pd_020[0]*Pd_202[2]; double P_120000002=Pd_120[0]*Pd_002[2]; double P_120000102=Pd_120[0]*Pd_102[2]; double P_120000202=Pd_120[0]*Pd_202[2]; double P_220000002=Pd_220[0]*Pd_002[2]; double P_220000102=Pd_220[0]*Pd_102[2]; double P_220000202=Pd_220[0]*Pd_202[2]; double P_012010000=Pd_012[0]*Pd_010[1]; double P_012110000=Pd_012[0]*Pd_110[1]; double P_112010000=Pd_112[0]*Pd_010[1]; double P_112110000=Pd_112[0]*Pd_110[1]; double P_212010000=Pd_212[0]*Pd_010[1]; double P_212110000=Pd_212[0]*Pd_110[1]; double P_312010000=Pd_312[0]*Pd_010[1]; double P_312110000=Pd_312[0]*Pd_110[1]; double P_011011000=Pd_011[0]*Pd_011[1]; double P_011111000=Pd_011[0]*Pd_111[1]; double P_011211000=Pd_011[0]*Pd_211[1]; double P_111011000=Pd_111[0]*Pd_011[1]; double P_111111000=Pd_111[0]*Pd_111[1]; double P_111211000=Pd_111[0]*Pd_211[1]; double P_211011000=Pd_211[0]*Pd_011[1]; double P_211111000=Pd_211[0]*Pd_111[1]; double P_211211000=Pd_211[0]*Pd_211[1]; double P_010012000=Pd_010[0]*Pd_012[1]; double P_010112000=Pd_010[0]*Pd_112[1]; double P_010212000=Pd_010[0]*Pd_212[1]; double P_010312000=Pd_010[0]*Pd_312[1]; double P_110012000=Pd_110[0]*Pd_012[1]; double P_110112000=Pd_110[0]*Pd_112[1]; double P_110212000=Pd_110[0]*Pd_212[1]; double P_110312000=Pd_110[0]*Pd_312[1]; double P_011010001=Pd_011[0]*Pd_010[1]*Pd_001[2]; double P_011010101=Pd_011[0]*Pd_010[1]*Pd_101[2]; double P_011110001=Pd_011[0]*Pd_110[1]*Pd_001[2]; double P_011110101=Pd_011[0]*Pd_110[1]*Pd_101[2]; double P_111010001=Pd_111[0]*Pd_010[1]*Pd_001[2]; double P_111010101=Pd_111[0]*Pd_010[1]*Pd_101[2]; double P_111110001=Pd_111[0]*Pd_110[1]*Pd_001[2]; double P_111110101=Pd_111[0]*Pd_110[1]*Pd_101[2]; double P_211010001=Pd_211[0]*Pd_010[1]*Pd_001[2]; double P_211010101=Pd_211[0]*Pd_010[1]*Pd_101[2]; double P_211110001=Pd_211[0]*Pd_110[1]*Pd_001[2]; double P_211110101=Pd_211[0]*Pd_110[1]*Pd_101[2]; double P_010011001=Pd_010[0]*Pd_011[1]*Pd_001[2]; double P_010011101=Pd_010[0]*Pd_011[1]*Pd_101[2]; double P_010111001=Pd_010[0]*Pd_111[1]*Pd_001[2]; double P_010111101=Pd_010[0]*Pd_111[1]*Pd_101[2]; double P_010211001=Pd_010[0]*Pd_211[1]*Pd_001[2]; double P_010211101=Pd_010[0]*Pd_211[1]*Pd_101[2]; double P_110011001=Pd_110[0]*Pd_011[1]*Pd_001[2]; double P_110011101=Pd_110[0]*Pd_011[1]*Pd_101[2]; double P_110111001=Pd_110[0]*Pd_111[1]*Pd_001[2]; double P_110111101=Pd_110[0]*Pd_111[1]*Pd_101[2]; double P_110211001=Pd_110[0]*Pd_211[1]*Pd_001[2]; double P_110211101=Pd_110[0]*Pd_211[1]*Pd_101[2]; double P_010010002=Pd_010[0]*Pd_010[1]*Pd_002[2]; double P_010010102=Pd_010[0]*Pd_010[1]*Pd_102[2]; double P_010010202=Pd_010[0]*Pd_010[1]*Pd_202[2]; double P_010110002=Pd_010[0]*Pd_110[1]*Pd_002[2]; double P_010110102=Pd_010[0]*Pd_110[1]*Pd_102[2]; double P_010110202=Pd_010[0]*Pd_110[1]*Pd_202[2]; double P_110010002=Pd_110[0]*Pd_010[1]*Pd_002[2]; double P_110010102=Pd_110[0]*Pd_010[1]*Pd_102[2]; double P_110010202=Pd_110[0]*Pd_010[1]*Pd_202[2]; double P_110110002=Pd_110[0]*Pd_110[1]*Pd_002[2]; double P_110110102=Pd_110[0]*Pd_110[1]*Pd_102[2]; double P_110110202=Pd_110[0]*Pd_110[1]*Pd_202[2]; double P_002020000=Pd_002[0]*Pd_020[1]; double P_002120000=Pd_002[0]*Pd_120[1]; double P_002220000=Pd_002[0]*Pd_220[1]; double P_102020000=Pd_102[0]*Pd_020[1]; double P_102120000=Pd_102[0]*Pd_120[1]; double P_102220000=Pd_102[0]*Pd_220[1]; double P_202020000=Pd_202[0]*Pd_020[1]; double P_202120000=Pd_202[0]*Pd_120[1]; double P_202220000=Pd_202[0]*Pd_220[1]; double P_001021000=Pd_001[0]*Pd_021[1]; double P_001121000=Pd_001[0]*Pd_121[1]; double P_001221000=Pd_001[0]*Pd_221[1]; double P_001321000=Pd_001[0]*Pd_321[1]; double P_101021000=Pd_101[0]*Pd_021[1]; double P_101121000=Pd_101[0]*Pd_121[1]; double P_101221000=Pd_101[0]*Pd_221[1]; double P_101321000=Pd_101[0]*Pd_321[1]; double P_000022000=Pd_022[1]; double P_000122000=Pd_122[1]; double P_000222000=Pd_222[1]; double P_000322000=Pd_322[1]; double P_000422000=Pd_422[1]; double P_001020001=Pd_001[0]*Pd_020[1]*Pd_001[2]; double P_001020101=Pd_001[0]*Pd_020[1]*Pd_101[2]; double P_001120001=Pd_001[0]*Pd_120[1]*Pd_001[2]; double P_001120101=Pd_001[0]*Pd_120[1]*Pd_101[2]; double P_001220001=Pd_001[0]*Pd_220[1]*Pd_001[2]; double P_001220101=Pd_001[0]*Pd_220[1]*Pd_101[2]; double P_101020001=Pd_101[0]*Pd_020[1]*Pd_001[2]; double P_101020101=Pd_101[0]*Pd_020[1]*Pd_101[2]; double P_101120001=Pd_101[0]*Pd_120[1]*Pd_001[2]; double P_101120101=Pd_101[0]*Pd_120[1]*Pd_101[2]; double P_101220001=Pd_101[0]*Pd_220[1]*Pd_001[2]; double P_101220101=Pd_101[0]*Pd_220[1]*Pd_101[2]; double P_000021001=Pd_021[1]*Pd_001[2]; double P_000021101=Pd_021[1]*Pd_101[2]; double P_000121001=Pd_121[1]*Pd_001[2]; double P_000121101=Pd_121[1]*Pd_101[2]; double P_000221001=Pd_221[1]*Pd_001[2]; double P_000221101=Pd_221[1]*Pd_101[2]; double P_000321001=Pd_321[1]*Pd_001[2]; double P_000321101=Pd_321[1]*Pd_101[2]; double P_000020002=Pd_020[1]*Pd_002[2]; double P_000020102=Pd_020[1]*Pd_102[2]; double P_000020202=Pd_020[1]*Pd_202[2]; double P_000120002=Pd_120[1]*Pd_002[2]; double P_000120102=Pd_120[1]*Pd_102[2]; double P_000120202=Pd_120[1]*Pd_202[2]; double P_000220002=Pd_220[1]*Pd_002[2]; double P_000220102=Pd_220[1]*Pd_102[2]; double P_000220202=Pd_220[1]*Pd_202[2]; double P_012000010=Pd_012[0]*Pd_010[2]; double P_012000110=Pd_012[0]*Pd_110[2]; double P_112000010=Pd_112[0]*Pd_010[2]; double P_112000110=Pd_112[0]*Pd_110[2]; double P_212000010=Pd_212[0]*Pd_010[2]; double P_212000110=Pd_212[0]*Pd_110[2]; double P_312000010=Pd_312[0]*Pd_010[2]; double P_312000110=Pd_312[0]*Pd_110[2]; double P_011001010=Pd_011[0]*Pd_001[1]*Pd_010[2]; double P_011001110=Pd_011[0]*Pd_001[1]*Pd_110[2]; double P_011101010=Pd_011[0]*Pd_101[1]*Pd_010[2]; double P_011101110=Pd_011[0]*Pd_101[1]*Pd_110[2]; double P_111001010=Pd_111[0]*Pd_001[1]*Pd_010[2]; double P_111001110=Pd_111[0]*Pd_001[1]*Pd_110[2]; double P_111101010=Pd_111[0]*Pd_101[1]*Pd_010[2]; double P_111101110=Pd_111[0]*Pd_101[1]*Pd_110[2]; double P_211001010=Pd_211[0]*Pd_001[1]*Pd_010[2]; double P_211001110=Pd_211[0]*Pd_001[1]*Pd_110[2]; double P_211101010=Pd_211[0]*Pd_101[1]*Pd_010[2]; double P_211101110=Pd_211[0]*Pd_101[1]*Pd_110[2]; double P_010002010=Pd_010[0]*Pd_002[1]*Pd_010[2]; double P_010002110=Pd_010[0]*Pd_002[1]*Pd_110[2]; double P_010102010=Pd_010[0]*Pd_102[1]*Pd_010[2]; double P_010102110=Pd_010[0]*Pd_102[1]*Pd_110[2]; double P_010202010=Pd_010[0]*Pd_202[1]*Pd_010[2]; double P_010202110=Pd_010[0]*Pd_202[1]*Pd_110[2]; double P_110002010=Pd_110[0]*Pd_002[1]*Pd_010[2]; double P_110002110=Pd_110[0]*Pd_002[1]*Pd_110[2]; double P_110102010=Pd_110[0]*Pd_102[1]*Pd_010[2]; double P_110102110=Pd_110[0]*Pd_102[1]*Pd_110[2]; double P_110202010=Pd_110[0]*Pd_202[1]*Pd_010[2]; double P_110202110=Pd_110[0]*Pd_202[1]*Pd_110[2]; double P_011000011=Pd_011[0]*Pd_011[2]; double P_011000111=Pd_011[0]*Pd_111[2]; double P_011000211=Pd_011[0]*Pd_211[2]; double P_111000011=Pd_111[0]*Pd_011[2]; double P_111000111=Pd_111[0]*Pd_111[2]; double P_111000211=Pd_111[0]*Pd_211[2]; double P_211000011=Pd_211[0]*Pd_011[2]; double P_211000111=Pd_211[0]*Pd_111[2]; double P_211000211=Pd_211[0]*Pd_211[2]; double P_010001011=Pd_010[0]*Pd_001[1]*Pd_011[2]; double P_010001111=Pd_010[0]*Pd_001[1]*Pd_111[2]; double P_010001211=Pd_010[0]*Pd_001[1]*Pd_211[2]; double P_010101011=Pd_010[0]*Pd_101[1]*Pd_011[2]; double P_010101111=Pd_010[0]*Pd_101[1]*Pd_111[2]; double P_010101211=Pd_010[0]*Pd_101[1]*Pd_211[2]; double P_110001011=Pd_110[0]*Pd_001[1]*Pd_011[2]; double P_110001111=Pd_110[0]*Pd_001[1]*Pd_111[2]; double P_110001211=Pd_110[0]*Pd_001[1]*Pd_211[2]; double P_110101011=Pd_110[0]*Pd_101[1]*Pd_011[2]; double P_110101111=Pd_110[0]*Pd_101[1]*Pd_111[2]; double P_110101211=Pd_110[0]*Pd_101[1]*Pd_211[2]; double P_010000012=Pd_010[0]*Pd_012[2]; double P_010000112=Pd_010[0]*Pd_112[2]; double P_010000212=Pd_010[0]*Pd_212[2]; double P_010000312=Pd_010[0]*Pd_312[2]; double P_110000012=Pd_110[0]*Pd_012[2]; double P_110000112=Pd_110[0]*Pd_112[2]; double P_110000212=Pd_110[0]*Pd_212[2]; double P_110000312=Pd_110[0]*Pd_312[2]; double P_002010010=Pd_002[0]*Pd_010[1]*Pd_010[2]; double P_002010110=Pd_002[0]*Pd_010[1]*Pd_110[2]; double P_002110010=Pd_002[0]*Pd_110[1]*Pd_010[2]; double P_002110110=Pd_002[0]*Pd_110[1]*Pd_110[2]; double P_102010010=Pd_102[0]*Pd_010[1]*Pd_010[2]; double P_102010110=Pd_102[0]*Pd_010[1]*Pd_110[2]; double P_102110010=Pd_102[0]*Pd_110[1]*Pd_010[2]; double P_102110110=Pd_102[0]*Pd_110[1]*Pd_110[2]; double P_202010010=Pd_202[0]*Pd_010[1]*Pd_010[2]; double P_202010110=Pd_202[0]*Pd_010[1]*Pd_110[2]; double P_202110010=Pd_202[0]*Pd_110[1]*Pd_010[2]; double P_202110110=Pd_202[0]*Pd_110[1]*Pd_110[2]; double P_001011010=Pd_001[0]*Pd_011[1]*Pd_010[2]; double P_001011110=Pd_001[0]*Pd_011[1]*Pd_110[2]; double P_001111010=Pd_001[0]*Pd_111[1]*Pd_010[2]; double P_001111110=Pd_001[0]*Pd_111[1]*Pd_110[2]; double P_001211010=Pd_001[0]*Pd_211[1]*Pd_010[2]; double P_001211110=Pd_001[0]*Pd_211[1]*Pd_110[2]; double P_101011010=Pd_101[0]*Pd_011[1]*Pd_010[2]; double P_101011110=Pd_101[0]*Pd_011[1]*Pd_110[2]; double P_101111010=Pd_101[0]*Pd_111[1]*Pd_010[2]; double P_101111110=Pd_101[0]*Pd_111[1]*Pd_110[2]; double P_101211010=Pd_101[0]*Pd_211[1]*Pd_010[2]; double P_101211110=Pd_101[0]*Pd_211[1]*Pd_110[2]; double P_000012010=Pd_012[1]*Pd_010[2]; double P_000012110=Pd_012[1]*Pd_110[2]; double P_000112010=Pd_112[1]*Pd_010[2]; double P_000112110=Pd_112[1]*Pd_110[2]; double P_000212010=Pd_212[1]*Pd_010[2]; double P_000212110=Pd_212[1]*Pd_110[2]; double P_000312010=Pd_312[1]*Pd_010[2]; double P_000312110=Pd_312[1]*Pd_110[2]; double P_001010011=Pd_001[0]*Pd_010[1]*Pd_011[2]; double P_001010111=Pd_001[0]*Pd_010[1]*Pd_111[2]; double P_001010211=Pd_001[0]*Pd_010[1]*Pd_211[2]; double P_001110011=Pd_001[0]*Pd_110[1]*Pd_011[2]; double P_001110111=Pd_001[0]*Pd_110[1]*Pd_111[2]; double P_001110211=Pd_001[0]*Pd_110[1]*Pd_211[2]; double P_101010011=Pd_101[0]*Pd_010[1]*Pd_011[2]; double P_101010111=Pd_101[0]*Pd_010[1]*Pd_111[2]; double P_101010211=Pd_101[0]*Pd_010[1]*Pd_211[2]; double P_101110011=Pd_101[0]*Pd_110[1]*Pd_011[2]; double P_101110111=Pd_101[0]*Pd_110[1]*Pd_111[2]; double P_101110211=Pd_101[0]*Pd_110[1]*Pd_211[2]; double P_000011011=Pd_011[1]*Pd_011[2]; double P_000011111=Pd_011[1]*Pd_111[2]; double P_000011211=Pd_011[1]*Pd_211[2]; double P_000111011=Pd_111[1]*Pd_011[2]; double P_000111111=Pd_111[1]*Pd_111[2]; double P_000111211=Pd_111[1]*Pd_211[2]; double P_000211011=Pd_211[1]*Pd_011[2]; double P_000211111=Pd_211[1]*Pd_111[2]; double P_000211211=Pd_211[1]*Pd_211[2]; double P_000010012=Pd_010[1]*Pd_012[2]; double P_000010112=Pd_010[1]*Pd_112[2]; double P_000010212=Pd_010[1]*Pd_212[2]; double P_000010312=Pd_010[1]*Pd_312[2]; double P_000110012=Pd_110[1]*Pd_012[2]; double P_000110112=Pd_110[1]*Pd_112[2]; double P_000110212=Pd_110[1]*Pd_212[2]; double P_000110312=Pd_110[1]*Pd_312[2]; double P_002000020=Pd_002[0]*Pd_020[2]; double P_002000120=Pd_002[0]*Pd_120[2]; double P_002000220=Pd_002[0]*Pd_220[2]; double P_102000020=Pd_102[0]*Pd_020[2]; double P_102000120=Pd_102[0]*Pd_120[2]; double P_102000220=Pd_102[0]*Pd_220[2]; double P_202000020=Pd_202[0]*Pd_020[2]; double P_202000120=Pd_202[0]*Pd_120[2]; double P_202000220=Pd_202[0]*Pd_220[2]; double P_001001020=Pd_001[0]*Pd_001[1]*Pd_020[2]; double P_001001120=Pd_001[0]*Pd_001[1]*Pd_120[2]; double P_001001220=Pd_001[0]*Pd_001[1]*Pd_220[2]; double P_001101020=Pd_001[0]*Pd_101[1]*Pd_020[2]; double P_001101120=Pd_001[0]*Pd_101[1]*Pd_120[2]; double P_001101220=Pd_001[0]*Pd_101[1]*Pd_220[2]; double P_101001020=Pd_101[0]*Pd_001[1]*Pd_020[2]; double P_101001120=Pd_101[0]*Pd_001[1]*Pd_120[2]; double P_101001220=Pd_101[0]*Pd_001[1]*Pd_220[2]; double P_101101020=Pd_101[0]*Pd_101[1]*Pd_020[2]; double P_101101120=Pd_101[0]*Pd_101[1]*Pd_120[2]; double P_101101220=Pd_101[0]*Pd_101[1]*Pd_220[2]; double P_000002020=Pd_002[1]*Pd_020[2]; double P_000002120=Pd_002[1]*Pd_120[2]; double P_000002220=Pd_002[1]*Pd_220[2]; double P_000102020=Pd_102[1]*Pd_020[2]; double P_000102120=Pd_102[1]*Pd_120[2]; double P_000102220=Pd_102[1]*Pd_220[2]; double P_000202020=Pd_202[1]*Pd_020[2]; double P_000202120=Pd_202[1]*Pd_120[2]; double P_000202220=Pd_202[1]*Pd_220[2]; double P_001000021=Pd_001[0]*Pd_021[2]; double P_001000121=Pd_001[0]*Pd_121[2]; double P_001000221=Pd_001[0]*Pd_221[2]; double P_001000321=Pd_001[0]*Pd_321[2]; double P_101000021=Pd_101[0]*Pd_021[2]; double P_101000121=Pd_101[0]*Pd_121[2]; double P_101000221=Pd_101[0]*Pd_221[2]; double P_101000321=Pd_101[0]*Pd_321[2]; double P_000001021=Pd_001[1]*Pd_021[2]; double P_000001121=Pd_001[1]*Pd_121[2]; double P_000001221=Pd_001[1]*Pd_221[2]; double P_000001321=Pd_001[1]*Pd_321[2]; double P_000101021=Pd_101[1]*Pd_021[2]; double P_000101121=Pd_101[1]*Pd_121[2]; double P_000101221=Pd_101[1]*Pd_221[2]; double P_000101321=Pd_101[1]*Pd_321[2]; double P_000000022=Pd_022[2]; double P_000000122=Pd_122[2]; double P_000000222=Pd_222[2]; double P_000000322=Pd_322[2]; double P_000000422=Pd_422[2]; ans_temp[ans_id*36+0]+=Pmtrx[0]*(P_022000000*QR_022000000000+P_122000000*QR_022000000100+P_222000000*QR_022000000200+P_322000000*QR_022000000300+P_422000000*QR_022000000400); ans_temp[ans_id*36+0]+=Pmtrx[1]*(P_022000000*QR_021001000000+P_122000000*QR_021001000100+P_222000000*QR_021001000200+P_322000000*QR_021001000300+P_422000000*QR_021001000400); ans_temp[ans_id*36+0]+=Pmtrx[2]*(P_022000000*QR_020002000000+P_122000000*QR_020002000100+P_222000000*QR_020002000200+P_322000000*QR_020002000300+P_422000000*QR_020002000400); ans_temp[ans_id*36+0]+=Pmtrx[3]*(P_022000000*QR_021000001000+P_122000000*QR_021000001100+P_222000000*QR_021000001200+P_322000000*QR_021000001300+P_422000000*QR_021000001400); ans_temp[ans_id*36+0]+=Pmtrx[4]*(P_022000000*QR_020001001000+P_122000000*QR_020001001100+P_222000000*QR_020001001200+P_322000000*QR_020001001300+P_422000000*QR_020001001400); ans_temp[ans_id*36+0]+=Pmtrx[5]*(P_022000000*QR_020000002000+P_122000000*QR_020000002100+P_222000000*QR_020000002200+P_322000000*QR_020000002300+P_422000000*QR_020000002400); ans_temp[ans_id*36+1]+=Pmtrx[0]*(P_022000000*QR_012010000000+P_122000000*QR_012010000100+P_222000000*QR_012010000200+P_322000000*QR_012010000300+P_422000000*QR_012010000400); ans_temp[ans_id*36+1]+=Pmtrx[1]*(P_022000000*QR_011011000000+P_122000000*QR_011011000100+P_222000000*QR_011011000200+P_322000000*QR_011011000300+P_422000000*QR_011011000400); ans_temp[ans_id*36+1]+=Pmtrx[2]*(P_022000000*QR_010012000000+P_122000000*QR_010012000100+P_222000000*QR_010012000200+P_322000000*QR_010012000300+P_422000000*QR_010012000400); ans_temp[ans_id*36+1]+=Pmtrx[3]*(P_022000000*QR_011010001000+P_122000000*QR_011010001100+P_222000000*QR_011010001200+P_322000000*QR_011010001300+P_422000000*QR_011010001400); ans_temp[ans_id*36+1]+=Pmtrx[4]*(P_022000000*QR_010011001000+P_122000000*QR_010011001100+P_222000000*QR_010011001200+P_322000000*QR_010011001300+P_422000000*QR_010011001400); ans_temp[ans_id*36+1]+=Pmtrx[5]*(P_022000000*QR_010010002000+P_122000000*QR_010010002100+P_222000000*QR_010010002200+P_322000000*QR_010010002300+P_422000000*QR_010010002400); ans_temp[ans_id*36+2]+=Pmtrx[0]*(P_022000000*QR_002020000000+P_122000000*QR_002020000100+P_222000000*QR_002020000200+P_322000000*QR_002020000300+P_422000000*QR_002020000400); ans_temp[ans_id*36+2]+=Pmtrx[1]*(P_022000000*QR_001021000000+P_122000000*QR_001021000100+P_222000000*QR_001021000200+P_322000000*QR_001021000300+P_422000000*QR_001021000400); ans_temp[ans_id*36+2]+=Pmtrx[2]*(P_022000000*QR_000022000000+P_122000000*QR_000022000100+P_222000000*QR_000022000200+P_322000000*QR_000022000300+P_422000000*QR_000022000400); ans_temp[ans_id*36+2]+=Pmtrx[3]*(P_022000000*QR_001020001000+P_122000000*QR_001020001100+P_222000000*QR_001020001200+P_322000000*QR_001020001300+P_422000000*QR_001020001400); ans_temp[ans_id*36+2]+=Pmtrx[4]*(P_022000000*QR_000021001000+P_122000000*QR_000021001100+P_222000000*QR_000021001200+P_322000000*QR_000021001300+P_422000000*QR_000021001400); ans_temp[ans_id*36+2]+=Pmtrx[5]*(P_022000000*QR_000020002000+P_122000000*QR_000020002100+P_222000000*QR_000020002200+P_322000000*QR_000020002300+P_422000000*QR_000020002400); ans_temp[ans_id*36+3]+=Pmtrx[0]*(P_022000000*QR_012000010000+P_122000000*QR_012000010100+P_222000000*QR_012000010200+P_322000000*QR_012000010300+P_422000000*QR_012000010400); ans_temp[ans_id*36+3]+=Pmtrx[1]*(P_022000000*QR_011001010000+P_122000000*QR_011001010100+P_222000000*QR_011001010200+P_322000000*QR_011001010300+P_422000000*QR_011001010400); ans_temp[ans_id*36+3]+=Pmtrx[2]*(P_022000000*QR_010002010000+P_122000000*QR_010002010100+P_222000000*QR_010002010200+P_322000000*QR_010002010300+P_422000000*QR_010002010400); ans_temp[ans_id*36+3]+=Pmtrx[3]*(P_022000000*QR_011000011000+P_122000000*QR_011000011100+P_222000000*QR_011000011200+P_322000000*QR_011000011300+P_422000000*QR_011000011400); ans_temp[ans_id*36+3]+=Pmtrx[4]*(P_022000000*QR_010001011000+P_122000000*QR_010001011100+P_222000000*QR_010001011200+P_322000000*QR_010001011300+P_422000000*QR_010001011400); ans_temp[ans_id*36+3]+=Pmtrx[5]*(P_022000000*QR_010000012000+P_122000000*QR_010000012100+P_222000000*QR_010000012200+P_322000000*QR_010000012300+P_422000000*QR_010000012400); ans_temp[ans_id*36+4]+=Pmtrx[0]*(P_022000000*QR_002010010000+P_122000000*QR_002010010100+P_222000000*QR_002010010200+P_322000000*QR_002010010300+P_422000000*QR_002010010400); ans_temp[ans_id*36+4]+=Pmtrx[1]*(P_022000000*QR_001011010000+P_122000000*QR_001011010100+P_222000000*QR_001011010200+P_322000000*QR_001011010300+P_422000000*QR_001011010400); ans_temp[ans_id*36+4]+=Pmtrx[2]*(P_022000000*QR_000012010000+P_122000000*QR_000012010100+P_222000000*QR_000012010200+P_322000000*QR_000012010300+P_422000000*QR_000012010400); ans_temp[ans_id*36+4]+=Pmtrx[3]*(P_022000000*QR_001010011000+P_122000000*QR_001010011100+P_222000000*QR_001010011200+P_322000000*QR_001010011300+P_422000000*QR_001010011400); ans_temp[ans_id*36+4]+=Pmtrx[4]*(P_022000000*QR_000011011000+P_122000000*QR_000011011100+P_222000000*QR_000011011200+P_322000000*QR_000011011300+P_422000000*QR_000011011400); ans_temp[ans_id*36+4]+=Pmtrx[5]*(P_022000000*QR_000010012000+P_122000000*QR_000010012100+P_222000000*QR_000010012200+P_322000000*QR_000010012300+P_422000000*QR_000010012400); ans_temp[ans_id*36+5]+=Pmtrx[0]*(P_022000000*QR_002000020000+P_122000000*QR_002000020100+P_222000000*QR_002000020200+P_322000000*QR_002000020300+P_422000000*QR_002000020400); ans_temp[ans_id*36+5]+=Pmtrx[1]*(P_022000000*QR_001001020000+P_122000000*QR_001001020100+P_222000000*QR_001001020200+P_322000000*QR_001001020300+P_422000000*QR_001001020400); ans_temp[ans_id*36+5]+=Pmtrx[2]*(P_022000000*QR_000002020000+P_122000000*QR_000002020100+P_222000000*QR_000002020200+P_322000000*QR_000002020300+P_422000000*QR_000002020400); ans_temp[ans_id*36+5]+=Pmtrx[3]*(P_022000000*QR_001000021000+P_122000000*QR_001000021100+P_222000000*QR_001000021200+P_322000000*QR_001000021300+P_422000000*QR_001000021400); ans_temp[ans_id*36+5]+=Pmtrx[4]*(P_022000000*QR_000001021000+P_122000000*QR_000001021100+P_222000000*QR_000001021200+P_322000000*QR_000001021300+P_422000000*QR_000001021400); ans_temp[ans_id*36+5]+=Pmtrx[5]*(P_022000000*QR_000000022000+P_122000000*QR_000000022100+P_222000000*QR_000000022200+P_322000000*QR_000000022300+P_422000000*QR_000000022400); ans_temp[ans_id*36+0]+=Pmtrx[6]*(P_021001000*QR_022000000000+P_021101000*QR_022000000010+P_121001000*QR_022000000100+P_121101000*QR_022000000110+P_221001000*QR_022000000200+P_221101000*QR_022000000210+P_321001000*QR_022000000300+P_321101000*QR_022000000310); ans_temp[ans_id*36+0]+=Pmtrx[7]*(P_021001000*QR_021001000000+P_021101000*QR_021001000010+P_121001000*QR_021001000100+P_121101000*QR_021001000110+P_221001000*QR_021001000200+P_221101000*QR_021001000210+P_321001000*QR_021001000300+P_321101000*QR_021001000310); ans_temp[ans_id*36+0]+=Pmtrx[8]*(P_021001000*QR_020002000000+P_021101000*QR_020002000010+P_121001000*QR_020002000100+P_121101000*QR_020002000110+P_221001000*QR_020002000200+P_221101000*QR_020002000210+P_321001000*QR_020002000300+P_321101000*QR_020002000310); ans_temp[ans_id*36+0]+=Pmtrx[9]*(P_021001000*QR_021000001000+P_021101000*QR_021000001010+P_121001000*QR_021000001100+P_121101000*QR_021000001110+P_221001000*QR_021000001200+P_221101000*QR_021000001210+P_321001000*QR_021000001300+P_321101000*QR_021000001310); ans_temp[ans_id*36+0]+=Pmtrx[10]*(P_021001000*QR_020001001000+P_021101000*QR_020001001010+P_121001000*QR_020001001100+P_121101000*QR_020001001110+P_221001000*QR_020001001200+P_221101000*QR_020001001210+P_321001000*QR_020001001300+P_321101000*QR_020001001310); ans_temp[ans_id*36+0]+=Pmtrx[11]*(P_021001000*QR_020000002000+P_021101000*QR_020000002010+P_121001000*QR_020000002100+P_121101000*QR_020000002110+P_221001000*QR_020000002200+P_221101000*QR_020000002210+P_321001000*QR_020000002300+P_321101000*QR_020000002310); ans_temp[ans_id*36+1]+=Pmtrx[6]*(P_021001000*QR_012010000000+P_021101000*QR_012010000010+P_121001000*QR_012010000100+P_121101000*QR_012010000110+P_221001000*QR_012010000200+P_221101000*QR_012010000210+P_321001000*QR_012010000300+P_321101000*QR_012010000310); ans_temp[ans_id*36+1]+=Pmtrx[7]*(P_021001000*QR_011011000000+P_021101000*QR_011011000010+P_121001000*QR_011011000100+P_121101000*QR_011011000110+P_221001000*QR_011011000200+P_221101000*QR_011011000210+P_321001000*QR_011011000300+P_321101000*QR_011011000310); ans_temp[ans_id*36+1]+=Pmtrx[8]*(P_021001000*QR_010012000000+P_021101000*QR_010012000010+P_121001000*QR_010012000100+P_121101000*QR_010012000110+P_221001000*QR_010012000200+P_221101000*QR_010012000210+P_321001000*QR_010012000300+P_321101000*QR_010012000310); ans_temp[ans_id*36+1]+=Pmtrx[9]*(P_021001000*QR_011010001000+P_021101000*QR_011010001010+P_121001000*QR_011010001100+P_121101000*QR_011010001110+P_221001000*QR_011010001200+P_221101000*QR_011010001210+P_321001000*QR_011010001300+P_321101000*QR_011010001310); ans_temp[ans_id*36+1]+=Pmtrx[10]*(P_021001000*QR_010011001000+P_021101000*QR_010011001010+P_121001000*QR_010011001100+P_121101000*QR_010011001110+P_221001000*QR_010011001200+P_221101000*QR_010011001210+P_321001000*QR_010011001300+P_321101000*QR_010011001310); ans_temp[ans_id*36+1]+=Pmtrx[11]*(P_021001000*QR_010010002000+P_021101000*QR_010010002010+P_121001000*QR_010010002100+P_121101000*QR_010010002110+P_221001000*QR_010010002200+P_221101000*QR_010010002210+P_321001000*QR_010010002300+P_321101000*QR_010010002310); ans_temp[ans_id*36+2]+=Pmtrx[6]*(P_021001000*QR_002020000000+P_021101000*QR_002020000010+P_121001000*QR_002020000100+P_121101000*QR_002020000110+P_221001000*QR_002020000200+P_221101000*QR_002020000210+P_321001000*QR_002020000300+P_321101000*QR_002020000310); ans_temp[ans_id*36+2]+=Pmtrx[7]*(P_021001000*QR_001021000000+P_021101000*QR_001021000010+P_121001000*QR_001021000100+P_121101000*QR_001021000110+P_221001000*QR_001021000200+P_221101000*QR_001021000210+P_321001000*QR_001021000300+P_321101000*QR_001021000310); ans_temp[ans_id*36+2]+=Pmtrx[8]*(P_021001000*QR_000022000000+P_021101000*QR_000022000010+P_121001000*QR_000022000100+P_121101000*QR_000022000110+P_221001000*QR_000022000200+P_221101000*QR_000022000210+P_321001000*QR_000022000300+P_321101000*QR_000022000310); ans_temp[ans_id*36+2]+=Pmtrx[9]*(P_021001000*QR_001020001000+P_021101000*QR_001020001010+P_121001000*QR_001020001100+P_121101000*QR_001020001110+P_221001000*QR_001020001200+P_221101000*QR_001020001210+P_321001000*QR_001020001300+P_321101000*QR_001020001310); ans_temp[ans_id*36+2]+=Pmtrx[10]*(P_021001000*QR_000021001000+P_021101000*QR_000021001010+P_121001000*QR_000021001100+P_121101000*QR_000021001110+P_221001000*QR_000021001200+P_221101000*QR_000021001210+P_321001000*QR_000021001300+P_321101000*QR_000021001310); ans_temp[ans_id*36+2]+=Pmtrx[11]*(P_021001000*QR_000020002000+P_021101000*QR_000020002010+P_121001000*QR_000020002100+P_121101000*QR_000020002110+P_221001000*QR_000020002200+P_221101000*QR_000020002210+P_321001000*QR_000020002300+P_321101000*QR_000020002310); ans_temp[ans_id*36+3]+=Pmtrx[6]*(P_021001000*QR_012000010000+P_021101000*QR_012000010010+P_121001000*QR_012000010100+P_121101000*QR_012000010110+P_221001000*QR_012000010200+P_221101000*QR_012000010210+P_321001000*QR_012000010300+P_321101000*QR_012000010310); ans_temp[ans_id*36+3]+=Pmtrx[7]*(P_021001000*QR_011001010000+P_021101000*QR_011001010010+P_121001000*QR_011001010100+P_121101000*QR_011001010110+P_221001000*QR_011001010200+P_221101000*QR_011001010210+P_321001000*QR_011001010300+P_321101000*QR_011001010310); ans_temp[ans_id*36+3]+=Pmtrx[8]*(P_021001000*QR_010002010000+P_021101000*QR_010002010010+P_121001000*QR_010002010100+P_121101000*QR_010002010110+P_221001000*QR_010002010200+P_221101000*QR_010002010210+P_321001000*QR_010002010300+P_321101000*QR_010002010310); ans_temp[ans_id*36+3]+=Pmtrx[9]*(P_021001000*QR_011000011000+P_021101000*QR_011000011010+P_121001000*QR_011000011100+P_121101000*QR_011000011110+P_221001000*QR_011000011200+P_221101000*QR_011000011210+P_321001000*QR_011000011300+P_321101000*QR_011000011310); ans_temp[ans_id*36+3]+=Pmtrx[10]*(P_021001000*QR_010001011000+P_021101000*QR_010001011010+P_121001000*QR_010001011100+P_121101000*QR_010001011110+P_221001000*QR_010001011200+P_221101000*QR_010001011210+P_321001000*QR_010001011300+P_321101000*QR_010001011310); ans_temp[ans_id*36+3]+=Pmtrx[11]*(P_021001000*QR_010000012000+P_021101000*QR_010000012010+P_121001000*QR_010000012100+P_121101000*QR_010000012110+P_221001000*QR_010000012200+P_221101000*QR_010000012210+P_321001000*QR_010000012300+P_321101000*QR_010000012310); ans_temp[ans_id*36+4]+=Pmtrx[6]*(P_021001000*QR_002010010000+P_021101000*QR_002010010010+P_121001000*QR_002010010100+P_121101000*QR_002010010110+P_221001000*QR_002010010200+P_221101000*QR_002010010210+P_321001000*QR_002010010300+P_321101000*QR_002010010310); ans_temp[ans_id*36+4]+=Pmtrx[7]*(P_021001000*QR_001011010000+P_021101000*QR_001011010010+P_121001000*QR_001011010100+P_121101000*QR_001011010110+P_221001000*QR_001011010200+P_221101000*QR_001011010210+P_321001000*QR_001011010300+P_321101000*QR_001011010310); ans_temp[ans_id*36+4]+=Pmtrx[8]*(P_021001000*QR_000012010000+P_021101000*QR_000012010010+P_121001000*QR_000012010100+P_121101000*QR_000012010110+P_221001000*QR_000012010200+P_221101000*QR_000012010210+P_321001000*QR_000012010300+P_321101000*QR_000012010310); ans_temp[ans_id*36+4]+=Pmtrx[9]*(P_021001000*QR_001010011000+P_021101000*QR_001010011010+P_121001000*QR_001010011100+P_121101000*QR_001010011110+P_221001000*QR_001010011200+P_221101000*QR_001010011210+P_321001000*QR_001010011300+P_321101000*QR_001010011310); ans_temp[ans_id*36+4]+=Pmtrx[10]*(P_021001000*QR_000011011000+P_021101000*QR_000011011010+P_121001000*QR_000011011100+P_121101000*QR_000011011110+P_221001000*QR_000011011200+P_221101000*QR_000011011210+P_321001000*QR_000011011300+P_321101000*QR_000011011310); ans_temp[ans_id*36+4]+=Pmtrx[11]*(P_021001000*QR_000010012000+P_021101000*QR_000010012010+P_121001000*QR_000010012100+P_121101000*QR_000010012110+P_221001000*QR_000010012200+P_221101000*QR_000010012210+P_321001000*QR_000010012300+P_321101000*QR_000010012310); ans_temp[ans_id*36+5]+=Pmtrx[6]*(P_021001000*QR_002000020000+P_021101000*QR_002000020010+P_121001000*QR_002000020100+P_121101000*QR_002000020110+P_221001000*QR_002000020200+P_221101000*QR_002000020210+P_321001000*QR_002000020300+P_321101000*QR_002000020310); ans_temp[ans_id*36+5]+=Pmtrx[7]*(P_021001000*QR_001001020000+P_021101000*QR_001001020010+P_121001000*QR_001001020100+P_121101000*QR_001001020110+P_221001000*QR_001001020200+P_221101000*QR_001001020210+P_321001000*QR_001001020300+P_321101000*QR_001001020310); ans_temp[ans_id*36+5]+=Pmtrx[8]*(P_021001000*QR_000002020000+P_021101000*QR_000002020010+P_121001000*QR_000002020100+P_121101000*QR_000002020110+P_221001000*QR_000002020200+P_221101000*QR_000002020210+P_321001000*QR_000002020300+P_321101000*QR_000002020310); ans_temp[ans_id*36+5]+=Pmtrx[9]*(P_021001000*QR_001000021000+P_021101000*QR_001000021010+P_121001000*QR_001000021100+P_121101000*QR_001000021110+P_221001000*QR_001000021200+P_221101000*QR_001000021210+P_321001000*QR_001000021300+P_321101000*QR_001000021310); ans_temp[ans_id*36+5]+=Pmtrx[10]*(P_021001000*QR_000001021000+P_021101000*QR_000001021010+P_121001000*QR_000001021100+P_121101000*QR_000001021110+P_221001000*QR_000001021200+P_221101000*QR_000001021210+P_321001000*QR_000001021300+P_321101000*QR_000001021310); ans_temp[ans_id*36+5]+=Pmtrx[11]*(P_021001000*QR_000000022000+P_021101000*QR_000000022010+P_121001000*QR_000000022100+P_121101000*QR_000000022110+P_221001000*QR_000000022200+P_221101000*QR_000000022210+P_321001000*QR_000000022300+P_321101000*QR_000000022310); ans_temp[ans_id*36+0]+=Pmtrx[12]*(P_020002000*QR_022000000000+P_020102000*QR_022000000010+P_020202000*QR_022000000020+P_120002000*QR_022000000100+P_120102000*QR_022000000110+P_120202000*QR_022000000120+P_220002000*QR_022000000200+P_220102000*QR_022000000210+P_220202000*QR_022000000220); ans_temp[ans_id*36+0]+=Pmtrx[13]*(P_020002000*QR_021001000000+P_020102000*QR_021001000010+P_020202000*QR_021001000020+P_120002000*QR_021001000100+P_120102000*QR_021001000110+P_120202000*QR_021001000120+P_220002000*QR_021001000200+P_220102000*QR_021001000210+P_220202000*QR_021001000220); ans_temp[ans_id*36+0]+=Pmtrx[14]*(P_020002000*QR_020002000000+P_020102000*QR_020002000010+P_020202000*QR_020002000020+P_120002000*QR_020002000100+P_120102000*QR_020002000110+P_120202000*QR_020002000120+P_220002000*QR_020002000200+P_220102000*QR_020002000210+P_220202000*QR_020002000220); ans_temp[ans_id*36+0]+=Pmtrx[15]*(P_020002000*QR_021000001000+P_020102000*QR_021000001010+P_020202000*QR_021000001020+P_120002000*QR_021000001100+P_120102000*QR_021000001110+P_120202000*QR_021000001120+P_220002000*QR_021000001200+P_220102000*QR_021000001210+P_220202000*QR_021000001220); ans_temp[ans_id*36+0]+=Pmtrx[16]*(P_020002000*QR_020001001000+P_020102000*QR_020001001010+P_020202000*QR_020001001020+P_120002000*QR_020001001100+P_120102000*QR_020001001110+P_120202000*QR_020001001120+P_220002000*QR_020001001200+P_220102000*QR_020001001210+P_220202000*QR_020001001220); ans_temp[ans_id*36+0]+=Pmtrx[17]*(P_020002000*QR_020000002000+P_020102000*QR_020000002010+P_020202000*QR_020000002020+P_120002000*QR_020000002100+P_120102000*QR_020000002110+P_120202000*QR_020000002120+P_220002000*QR_020000002200+P_220102000*QR_020000002210+P_220202000*QR_020000002220); ans_temp[ans_id*36+1]+=Pmtrx[12]*(P_020002000*QR_012010000000+P_020102000*QR_012010000010+P_020202000*QR_012010000020+P_120002000*QR_012010000100+P_120102000*QR_012010000110+P_120202000*QR_012010000120+P_220002000*QR_012010000200+P_220102000*QR_012010000210+P_220202000*QR_012010000220); ans_temp[ans_id*36+1]+=Pmtrx[13]*(P_020002000*QR_011011000000+P_020102000*QR_011011000010+P_020202000*QR_011011000020+P_120002000*QR_011011000100+P_120102000*QR_011011000110+P_120202000*QR_011011000120+P_220002000*QR_011011000200+P_220102000*QR_011011000210+P_220202000*QR_011011000220); ans_temp[ans_id*36+1]+=Pmtrx[14]*(P_020002000*QR_010012000000+P_020102000*QR_010012000010+P_020202000*QR_010012000020+P_120002000*QR_010012000100+P_120102000*QR_010012000110+P_120202000*QR_010012000120+P_220002000*QR_010012000200+P_220102000*QR_010012000210+P_220202000*QR_010012000220); ans_temp[ans_id*36+1]+=Pmtrx[15]*(P_020002000*QR_011010001000+P_020102000*QR_011010001010+P_020202000*QR_011010001020+P_120002000*QR_011010001100+P_120102000*QR_011010001110+P_120202000*QR_011010001120+P_220002000*QR_011010001200+P_220102000*QR_011010001210+P_220202000*QR_011010001220); ans_temp[ans_id*36+1]+=Pmtrx[16]*(P_020002000*QR_010011001000+P_020102000*QR_010011001010+P_020202000*QR_010011001020+P_120002000*QR_010011001100+P_120102000*QR_010011001110+P_120202000*QR_010011001120+P_220002000*QR_010011001200+P_220102000*QR_010011001210+P_220202000*QR_010011001220); ans_temp[ans_id*36+1]+=Pmtrx[17]*(P_020002000*QR_010010002000+P_020102000*QR_010010002010+P_020202000*QR_010010002020+P_120002000*QR_010010002100+P_120102000*QR_010010002110+P_120202000*QR_010010002120+P_220002000*QR_010010002200+P_220102000*QR_010010002210+P_220202000*QR_010010002220); ans_temp[ans_id*36+2]+=Pmtrx[12]*(P_020002000*QR_002020000000+P_020102000*QR_002020000010+P_020202000*QR_002020000020+P_120002000*QR_002020000100+P_120102000*QR_002020000110+P_120202000*QR_002020000120+P_220002000*QR_002020000200+P_220102000*QR_002020000210+P_220202000*QR_002020000220); ans_temp[ans_id*36+2]+=Pmtrx[13]*(P_020002000*QR_001021000000+P_020102000*QR_001021000010+P_020202000*QR_001021000020+P_120002000*QR_001021000100+P_120102000*QR_001021000110+P_120202000*QR_001021000120+P_220002000*QR_001021000200+P_220102000*QR_001021000210+P_220202000*QR_001021000220); ans_temp[ans_id*36+2]+=Pmtrx[14]*(P_020002000*QR_000022000000+P_020102000*QR_000022000010+P_020202000*QR_000022000020+P_120002000*QR_000022000100+P_120102000*QR_000022000110+P_120202000*QR_000022000120+P_220002000*QR_000022000200+P_220102000*QR_000022000210+P_220202000*QR_000022000220); ans_temp[ans_id*36+2]+=Pmtrx[15]*(P_020002000*QR_001020001000+P_020102000*QR_001020001010+P_020202000*QR_001020001020+P_120002000*QR_001020001100+P_120102000*QR_001020001110+P_120202000*QR_001020001120+P_220002000*QR_001020001200+P_220102000*QR_001020001210+P_220202000*QR_001020001220); ans_temp[ans_id*36+2]+=Pmtrx[16]*(P_020002000*QR_000021001000+P_020102000*QR_000021001010+P_020202000*QR_000021001020+P_120002000*QR_000021001100+P_120102000*QR_000021001110+P_120202000*QR_000021001120+P_220002000*QR_000021001200+P_220102000*QR_000021001210+P_220202000*QR_000021001220); ans_temp[ans_id*36+2]+=Pmtrx[17]*(P_020002000*QR_000020002000+P_020102000*QR_000020002010+P_020202000*QR_000020002020+P_120002000*QR_000020002100+P_120102000*QR_000020002110+P_120202000*QR_000020002120+P_220002000*QR_000020002200+P_220102000*QR_000020002210+P_220202000*QR_000020002220); ans_temp[ans_id*36+3]+=Pmtrx[12]*(P_020002000*QR_012000010000+P_020102000*QR_012000010010+P_020202000*QR_012000010020+P_120002000*QR_012000010100+P_120102000*QR_012000010110+P_120202000*QR_012000010120+P_220002000*QR_012000010200+P_220102000*QR_012000010210+P_220202000*QR_012000010220); ans_temp[ans_id*36+3]+=Pmtrx[13]*(P_020002000*QR_011001010000+P_020102000*QR_011001010010+P_020202000*QR_011001010020+P_120002000*QR_011001010100+P_120102000*QR_011001010110+P_120202000*QR_011001010120+P_220002000*QR_011001010200+P_220102000*QR_011001010210+P_220202000*QR_011001010220); ans_temp[ans_id*36+3]+=Pmtrx[14]*(P_020002000*QR_010002010000+P_020102000*QR_010002010010+P_020202000*QR_010002010020+P_120002000*QR_010002010100+P_120102000*QR_010002010110+P_120202000*QR_010002010120+P_220002000*QR_010002010200+P_220102000*QR_010002010210+P_220202000*QR_010002010220); ans_temp[ans_id*36+3]+=Pmtrx[15]*(P_020002000*QR_011000011000+P_020102000*QR_011000011010+P_020202000*QR_011000011020+P_120002000*QR_011000011100+P_120102000*QR_011000011110+P_120202000*QR_011000011120+P_220002000*QR_011000011200+P_220102000*QR_011000011210+P_220202000*QR_011000011220); ans_temp[ans_id*36+3]+=Pmtrx[16]*(P_020002000*QR_010001011000+P_020102000*QR_010001011010+P_020202000*QR_010001011020+P_120002000*QR_010001011100+P_120102000*QR_010001011110+P_120202000*QR_010001011120+P_220002000*QR_010001011200+P_220102000*QR_010001011210+P_220202000*QR_010001011220); ans_temp[ans_id*36+3]+=Pmtrx[17]*(P_020002000*QR_010000012000+P_020102000*QR_010000012010+P_020202000*QR_010000012020+P_120002000*QR_010000012100+P_120102000*QR_010000012110+P_120202000*QR_010000012120+P_220002000*QR_010000012200+P_220102000*QR_010000012210+P_220202000*QR_010000012220); ans_temp[ans_id*36+4]+=Pmtrx[12]*(P_020002000*QR_002010010000+P_020102000*QR_002010010010+P_020202000*QR_002010010020+P_120002000*QR_002010010100+P_120102000*QR_002010010110+P_120202000*QR_002010010120+P_220002000*QR_002010010200+P_220102000*QR_002010010210+P_220202000*QR_002010010220); ans_temp[ans_id*36+4]+=Pmtrx[13]*(P_020002000*QR_001011010000+P_020102000*QR_001011010010+P_020202000*QR_001011010020+P_120002000*QR_001011010100+P_120102000*QR_001011010110+P_120202000*QR_001011010120+P_220002000*QR_001011010200+P_220102000*QR_001011010210+P_220202000*QR_001011010220); ans_temp[ans_id*36+4]+=Pmtrx[14]*(P_020002000*QR_000012010000+P_020102000*QR_000012010010+P_020202000*QR_000012010020+P_120002000*QR_000012010100+P_120102000*QR_000012010110+P_120202000*QR_000012010120+P_220002000*QR_000012010200+P_220102000*QR_000012010210+P_220202000*QR_000012010220); ans_temp[ans_id*36+4]+=Pmtrx[15]*(P_020002000*QR_001010011000+P_020102000*QR_001010011010+P_020202000*QR_001010011020+P_120002000*QR_001010011100+P_120102000*QR_001010011110+P_120202000*QR_001010011120+P_220002000*QR_001010011200+P_220102000*QR_001010011210+P_220202000*QR_001010011220); ans_temp[ans_id*36+4]+=Pmtrx[16]*(P_020002000*QR_000011011000+P_020102000*QR_000011011010+P_020202000*QR_000011011020+P_120002000*QR_000011011100+P_120102000*QR_000011011110+P_120202000*QR_000011011120+P_220002000*QR_000011011200+P_220102000*QR_000011011210+P_220202000*QR_000011011220); ans_temp[ans_id*36+4]+=Pmtrx[17]*(P_020002000*QR_000010012000+P_020102000*QR_000010012010+P_020202000*QR_000010012020+P_120002000*QR_000010012100+P_120102000*QR_000010012110+P_120202000*QR_000010012120+P_220002000*QR_000010012200+P_220102000*QR_000010012210+P_220202000*QR_000010012220); ans_temp[ans_id*36+5]+=Pmtrx[12]*(P_020002000*QR_002000020000+P_020102000*QR_002000020010+P_020202000*QR_002000020020+P_120002000*QR_002000020100+P_120102000*QR_002000020110+P_120202000*QR_002000020120+P_220002000*QR_002000020200+P_220102000*QR_002000020210+P_220202000*QR_002000020220); ans_temp[ans_id*36+5]+=Pmtrx[13]*(P_020002000*QR_001001020000+P_020102000*QR_001001020010+P_020202000*QR_001001020020+P_120002000*QR_001001020100+P_120102000*QR_001001020110+P_120202000*QR_001001020120+P_220002000*QR_001001020200+P_220102000*QR_001001020210+P_220202000*QR_001001020220); ans_temp[ans_id*36+5]+=Pmtrx[14]*(P_020002000*QR_000002020000+P_020102000*QR_000002020010+P_020202000*QR_000002020020+P_120002000*QR_000002020100+P_120102000*QR_000002020110+P_120202000*QR_000002020120+P_220002000*QR_000002020200+P_220102000*QR_000002020210+P_220202000*QR_000002020220); ans_temp[ans_id*36+5]+=Pmtrx[15]*(P_020002000*QR_001000021000+P_020102000*QR_001000021010+P_020202000*QR_001000021020+P_120002000*QR_001000021100+P_120102000*QR_001000021110+P_120202000*QR_001000021120+P_220002000*QR_001000021200+P_220102000*QR_001000021210+P_220202000*QR_001000021220); ans_temp[ans_id*36+5]+=Pmtrx[16]*(P_020002000*QR_000001021000+P_020102000*QR_000001021010+P_020202000*QR_000001021020+P_120002000*QR_000001021100+P_120102000*QR_000001021110+P_120202000*QR_000001021120+P_220002000*QR_000001021200+P_220102000*QR_000001021210+P_220202000*QR_000001021220); ans_temp[ans_id*36+5]+=Pmtrx[17]*(P_020002000*QR_000000022000+P_020102000*QR_000000022010+P_020202000*QR_000000022020+P_120002000*QR_000000022100+P_120102000*QR_000000022110+P_120202000*QR_000000022120+P_220002000*QR_000000022200+P_220102000*QR_000000022210+P_220202000*QR_000000022220); ans_temp[ans_id*36+0]+=Pmtrx[18]*(P_021000001*QR_022000000000+P_021000101*QR_022000000001+P_121000001*QR_022000000100+P_121000101*QR_022000000101+P_221000001*QR_022000000200+P_221000101*QR_022000000201+P_321000001*QR_022000000300+P_321000101*QR_022000000301); ans_temp[ans_id*36+0]+=Pmtrx[19]*(P_021000001*QR_021001000000+P_021000101*QR_021001000001+P_121000001*QR_021001000100+P_121000101*QR_021001000101+P_221000001*QR_021001000200+P_221000101*QR_021001000201+P_321000001*QR_021001000300+P_321000101*QR_021001000301); ans_temp[ans_id*36+0]+=Pmtrx[20]*(P_021000001*QR_020002000000+P_021000101*QR_020002000001+P_121000001*QR_020002000100+P_121000101*QR_020002000101+P_221000001*QR_020002000200+P_221000101*QR_020002000201+P_321000001*QR_020002000300+P_321000101*QR_020002000301); ans_temp[ans_id*36+0]+=Pmtrx[21]*(P_021000001*QR_021000001000+P_021000101*QR_021000001001+P_121000001*QR_021000001100+P_121000101*QR_021000001101+P_221000001*QR_021000001200+P_221000101*QR_021000001201+P_321000001*QR_021000001300+P_321000101*QR_021000001301); ans_temp[ans_id*36+0]+=Pmtrx[22]*(P_021000001*QR_020001001000+P_021000101*QR_020001001001+P_121000001*QR_020001001100+P_121000101*QR_020001001101+P_221000001*QR_020001001200+P_221000101*QR_020001001201+P_321000001*QR_020001001300+P_321000101*QR_020001001301); ans_temp[ans_id*36+0]+=Pmtrx[23]*(P_021000001*QR_020000002000+P_021000101*QR_020000002001+P_121000001*QR_020000002100+P_121000101*QR_020000002101+P_221000001*QR_020000002200+P_221000101*QR_020000002201+P_321000001*QR_020000002300+P_321000101*QR_020000002301); ans_temp[ans_id*36+1]+=Pmtrx[18]*(P_021000001*QR_012010000000+P_021000101*QR_012010000001+P_121000001*QR_012010000100+P_121000101*QR_012010000101+P_221000001*QR_012010000200+P_221000101*QR_012010000201+P_321000001*QR_012010000300+P_321000101*QR_012010000301); ans_temp[ans_id*36+1]+=Pmtrx[19]*(P_021000001*QR_011011000000+P_021000101*QR_011011000001+P_121000001*QR_011011000100+P_121000101*QR_011011000101+P_221000001*QR_011011000200+P_221000101*QR_011011000201+P_321000001*QR_011011000300+P_321000101*QR_011011000301); ans_temp[ans_id*36+1]+=Pmtrx[20]*(P_021000001*QR_010012000000+P_021000101*QR_010012000001+P_121000001*QR_010012000100+P_121000101*QR_010012000101+P_221000001*QR_010012000200+P_221000101*QR_010012000201+P_321000001*QR_010012000300+P_321000101*QR_010012000301); ans_temp[ans_id*36+1]+=Pmtrx[21]*(P_021000001*QR_011010001000+P_021000101*QR_011010001001+P_121000001*QR_011010001100+P_121000101*QR_011010001101+P_221000001*QR_011010001200+P_221000101*QR_011010001201+P_321000001*QR_011010001300+P_321000101*QR_011010001301); ans_temp[ans_id*36+1]+=Pmtrx[22]*(P_021000001*QR_010011001000+P_021000101*QR_010011001001+P_121000001*QR_010011001100+P_121000101*QR_010011001101+P_221000001*QR_010011001200+P_221000101*QR_010011001201+P_321000001*QR_010011001300+P_321000101*QR_010011001301); ans_temp[ans_id*36+1]+=Pmtrx[23]*(P_021000001*QR_010010002000+P_021000101*QR_010010002001+P_121000001*QR_010010002100+P_121000101*QR_010010002101+P_221000001*QR_010010002200+P_221000101*QR_010010002201+P_321000001*QR_010010002300+P_321000101*QR_010010002301); ans_temp[ans_id*36+2]+=Pmtrx[18]*(P_021000001*QR_002020000000+P_021000101*QR_002020000001+P_121000001*QR_002020000100+P_121000101*QR_002020000101+P_221000001*QR_002020000200+P_221000101*QR_002020000201+P_321000001*QR_002020000300+P_321000101*QR_002020000301); ans_temp[ans_id*36+2]+=Pmtrx[19]*(P_021000001*QR_001021000000+P_021000101*QR_001021000001+P_121000001*QR_001021000100+P_121000101*QR_001021000101+P_221000001*QR_001021000200+P_221000101*QR_001021000201+P_321000001*QR_001021000300+P_321000101*QR_001021000301); ans_temp[ans_id*36+2]+=Pmtrx[20]*(P_021000001*QR_000022000000+P_021000101*QR_000022000001+P_121000001*QR_000022000100+P_121000101*QR_000022000101+P_221000001*QR_000022000200+P_221000101*QR_000022000201+P_321000001*QR_000022000300+P_321000101*QR_000022000301); ans_temp[ans_id*36+2]+=Pmtrx[21]*(P_021000001*QR_001020001000+P_021000101*QR_001020001001+P_121000001*QR_001020001100+P_121000101*QR_001020001101+P_221000001*QR_001020001200+P_221000101*QR_001020001201+P_321000001*QR_001020001300+P_321000101*QR_001020001301); ans_temp[ans_id*36+2]+=Pmtrx[22]*(P_021000001*QR_000021001000+P_021000101*QR_000021001001+P_121000001*QR_000021001100+P_121000101*QR_000021001101+P_221000001*QR_000021001200+P_221000101*QR_000021001201+P_321000001*QR_000021001300+P_321000101*QR_000021001301); ans_temp[ans_id*36+2]+=Pmtrx[23]*(P_021000001*QR_000020002000+P_021000101*QR_000020002001+P_121000001*QR_000020002100+P_121000101*QR_000020002101+P_221000001*QR_000020002200+P_221000101*QR_000020002201+P_321000001*QR_000020002300+P_321000101*QR_000020002301); ans_temp[ans_id*36+3]+=Pmtrx[18]*(P_021000001*QR_012000010000+P_021000101*QR_012000010001+P_121000001*QR_012000010100+P_121000101*QR_012000010101+P_221000001*QR_012000010200+P_221000101*QR_012000010201+P_321000001*QR_012000010300+P_321000101*QR_012000010301); ans_temp[ans_id*36+3]+=Pmtrx[19]*(P_021000001*QR_011001010000+P_021000101*QR_011001010001+P_121000001*QR_011001010100+P_121000101*QR_011001010101+P_221000001*QR_011001010200+P_221000101*QR_011001010201+P_321000001*QR_011001010300+P_321000101*QR_011001010301); ans_temp[ans_id*36+3]+=Pmtrx[20]*(P_021000001*QR_010002010000+P_021000101*QR_010002010001+P_121000001*QR_010002010100+P_121000101*QR_010002010101+P_221000001*QR_010002010200+P_221000101*QR_010002010201+P_321000001*QR_010002010300+P_321000101*QR_010002010301); ans_temp[ans_id*36+3]+=Pmtrx[21]*(P_021000001*QR_011000011000+P_021000101*QR_011000011001+P_121000001*QR_011000011100+P_121000101*QR_011000011101+P_221000001*QR_011000011200+P_221000101*QR_011000011201+P_321000001*QR_011000011300+P_321000101*QR_011000011301); ans_temp[ans_id*36+3]+=Pmtrx[22]*(P_021000001*QR_010001011000+P_021000101*QR_010001011001+P_121000001*QR_010001011100+P_121000101*QR_010001011101+P_221000001*QR_010001011200+P_221000101*QR_010001011201+P_321000001*QR_010001011300+P_321000101*QR_010001011301); ans_temp[ans_id*36+3]+=Pmtrx[23]*(P_021000001*QR_010000012000+P_021000101*QR_010000012001+P_121000001*QR_010000012100+P_121000101*QR_010000012101+P_221000001*QR_010000012200+P_221000101*QR_010000012201+P_321000001*QR_010000012300+P_321000101*QR_010000012301); ans_temp[ans_id*36+4]+=Pmtrx[18]*(P_021000001*QR_002010010000+P_021000101*QR_002010010001+P_121000001*QR_002010010100+P_121000101*QR_002010010101+P_221000001*QR_002010010200+P_221000101*QR_002010010201+P_321000001*QR_002010010300+P_321000101*QR_002010010301); ans_temp[ans_id*36+4]+=Pmtrx[19]*(P_021000001*QR_001011010000+P_021000101*QR_001011010001+P_121000001*QR_001011010100+P_121000101*QR_001011010101+P_221000001*QR_001011010200+P_221000101*QR_001011010201+P_321000001*QR_001011010300+P_321000101*QR_001011010301); ans_temp[ans_id*36+4]+=Pmtrx[20]*(P_021000001*QR_000012010000+P_021000101*QR_000012010001+P_121000001*QR_000012010100+P_121000101*QR_000012010101+P_221000001*QR_000012010200+P_221000101*QR_000012010201+P_321000001*QR_000012010300+P_321000101*QR_000012010301); ans_temp[ans_id*36+4]+=Pmtrx[21]*(P_021000001*QR_001010011000+P_021000101*QR_001010011001+P_121000001*QR_001010011100+P_121000101*QR_001010011101+P_221000001*QR_001010011200+P_221000101*QR_001010011201+P_321000001*QR_001010011300+P_321000101*QR_001010011301); ans_temp[ans_id*36+4]+=Pmtrx[22]*(P_021000001*QR_000011011000+P_021000101*QR_000011011001+P_121000001*QR_000011011100+P_121000101*QR_000011011101+P_221000001*QR_000011011200+P_221000101*QR_000011011201+P_321000001*QR_000011011300+P_321000101*QR_000011011301); ans_temp[ans_id*36+4]+=Pmtrx[23]*(P_021000001*QR_000010012000+P_021000101*QR_000010012001+P_121000001*QR_000010012100+P_121000101*QR_000010012101+P_221000001*QR_000010012200+P_221000101*QR_000010012201+P_321000001*QR_000010012300+P_321000101*QR_000010012301); ans_temp[ans_id*36+5]+=Pmtrx[18]*(P_021000001*QR_002000020000+P_021000101*QR_002000020001+P_121000001*QR_002000020100+P_121000101*QR_002000020101+P_221000001*QR_002000020200+P_221000101*QR_002000020201+P_321000001*QR_002000020300+P_321000101*QR_002000020301); ans_temp[ans_id*36+5]+=Pmtrx[19]*(P_021000001*QR_001001020000+P_021000101*QR_001001020001+P_121000001*QR_001001020100+P_121000101*QR_001001020101+P_221000001*QR_001001020200+P_221000101*QR_001001020201+P_321000001*QR_001001020300+P_321000101*QR_001001020301); ans_temp[ans_id*36+5]+=Pmtrx[20]*(P_021000001*QR_000002020000+P_021000101*QR_000002020001+P_121000001*QR_000002020100+P_121000101*QR_000002020101+P_221000001*QR_000002020200+P_221000101*QR_000002020201+P_321000001*QR_000002020300+P_321000101*QR_000002020301); ans_temp[ans_id*36+5]+=Pmtrx[21]*(P_021000001*QR_001000021000+P_021000101*QR_001000021001+P_121000001*QR_001000021100+P_121000101*QR_001000021101+P_221000001*QR_001000021200+P_221000101*QR_001000021201+P_321000001*QR_001000021300+P_321000101*QR_001000021301); ans_temp[ans_id*36+5]+=Pmtrx[22]*(P_021000001*QR_000001021000+P_021000101*QR_000001021001+P_121000001*QR_000001021100+P_121000101*QR_000001021101+P_221000001*QR_000001021200+P_221000101*QR_000001021201+P_321000001*QR_000001021300+P_321000101*QR_000001021301); ans_temp[ans_id*36+5]+=Pmtrx[23]*(P_021000001*QR_000000022000+P_021000101*QR_000000022001+P_121000001*QR_000000022100+P_121000101*QR_000000022101+P_221000001*QR_000000022200+P_221000101*QR_000000022201+P_321000001*QR_000000022300+P_321000101*QR_000000022301); ans_temp[ans_id*36+0]+=Pmtrx[24]*(P_020001001*QR_022000000000+P_020001101*QR_022000000001+P_020101001*QR_022000000010+P_020101101*QR_022000000011+P_120001001*QR_022000000100+P_120001101*QR_022000000101+P_120101001*QR_022000000110+P_120101101*QR_022000000111+P_220001001*QR_022000000200+P_220001101*QR_022000000201+P_220101001*QR_022000000210+P_220101101*QR_022000000211); ans_temp[ans_id*36+0]+=Pmtrx[25]*(P_020001001*QR_021001000000+P_020001101*QR_021001000001+P_020101001*QR_021001000010+P_020101101*QR_021001000011+P_120001001*QR_021001000100+P_120001101*QR_021001000101+P_120101001*QR_021001000110+P_120101101*QR_021001000111+P_220001001*QR_021001000200+P_220001101*QR_021001000201+P_220101001*QR_021001000210+P_220101101*QR_021001000211); ans_temp[ans_id*36+0]+=Pmtrx[26]*(P_020001001*QR_020002000000+P_020001101*QR_020002000001+P_020101001*QR_020002000010+P_020101101*QR_020002000011+P_120001001*QR_020002000100+P_120001101*QR_020002000101+P_120101001*QR_020002000110+P_120101101*QR_020002000111+P_220001001*QR_020002000200+P_220001101*QR_020002000201+P_220101001*QR_020002000210+P_220101101*QR_020002000211); ans_temp[ans_id*36+0]+=Pmtrx[27]*(P_020001001*QR_021000001000+P_020001101*QR_021000001001+P_020101001*QR_021000001010+P_020101101*QR_021000001011+P_120001001*QR_021000001100+P_120001101*QR_021000001101+P_120101001*QR_021000001110+P_120101101*QR_021000001111+P_220001001*QR_021000001200+P_220001101*QR_021000001201+P_220101001*QR_021000001210+P_220101101*QR_021000001211); ans_temp[ans_id*36+0]+=Pmtrx[28]*(P_020001001*QR_020001001000+P_020001101*QR_020001001001+P_020101001*QR_020001001010+P_020101101*QR_020001001011+P_120001001*QR_020001001100+P_120001101*QR_020001001101+P_120101001*QR_020001001110+P_120101101*QR_020001001111+P_220001001*QR_020001001200+P_220001101*QR_020001001201+P_220101001*QR_020001001210+P_220101101*QR_020001001211); ans_temp[ans_id*36+0]+=Pmtrx[29]*(P_020001001*QR_020000002000+P_020001101*QR_020000002001+P_020101001*QR_020000002010+P_020101101*QR_020000002011+P_120001001*QR_020000002100+P_120001101*QR_020000002101+P_120101001*QR_020000002110+P_120101101*QR_020000002111+P_220001001*QR_020000002200+P_220001101*QR_020000002201+P_220101001*QR_020000002210+P_220101101*QR_020000002211); ans_temp[ans_id*36+1]+=Pmtrx[24]*(P_020001001*QR_012010000000+P_020001101*QR_012010000001+P_020101001*QR_012010000010+P_020101101*QR_012010000011+P_120001001*QR_012010000100+P_120001101*QR_012010000101+P_120101001*QR_012010000110+P_120101101*QR_012010000111+P_220001001*QR_012010000200+P_220001101*QR_012010000201+P_220101001*QR_012010000210+P_220101101*QR_012010000211); ans_temp[ans_id*36+1]+=Pmtrx[25]*(P_020001001*QR_011011000000+P_020001101*QR_011011000001+P_020101001*QR_011011000010+P_020101101*QR_011011000011+P_120001001*QR_011011000100+P_120001101*QR_011011000101+P_120101001*QR_011011000110+P_120101101*QR_011011000111+P_220001001*QR_011011000200+P_220001101*QR_011011000201+P_220101001*QR_011011000210+P_220101101*QR_011011000211); ans_temp[ans_id*36+1]+=Pmtrx[26]*(P_020001001*QR_010012000000+P_020001101*QR_010012000001+P_020101001*QR_010012000010+P_020101101*QR_010012000011+P_120001001*QR_010012000100+P_120001101*QR_010012000101+P_120101001*QR_010012000110+P_120101101*QR_010012000111+P_220001001*QR_010012000200+P_220001101*QR_010012000201+P_220101001*QR_010012000210+P_220101101*QR_010012000211); ans_temp[ans_id*36+1]+=Pmtrx[27]*(P_020001001*QR_011010001000+P_020001101*QR_011010001001+P_020101001*QR_011010001010+P_020101101*QR_011010001011+P_120001001*QR_011010001100+P_120001101*QR_011010001101+P_120101001*QR_011010001110+P_120101101*QR_011010001111+P_220001001*QR_011010001200+P_220001101*QR_011010001201+P_220101001*QR_011010001210+P_220101101*QR_011010001211); ans_temp[ans_id*36+1]+=Pmtrx[28]*(P_020001001*QR_010011001000+P_020001101*QR_010011001001+P_020101001*QR_010011001010+P_020101101*QR_010011001011+P_120001001*QR_010011001100+P_120001101*QR_010011001101+P_120101001*QR_010011001110+P_120101101*QR_010011001111+P_220001001*QR_010011001200+P_220001101*QR_010011001201+P_220101001*QR_010011001210+P_220101101*QR_010011001211); ans_temp[ans_id*36+1]+=Pmtrx[29]*(P_020001001*QR_010010002000+P_020001101*QR_010010002001+P_020101001*QR_010010002010+P_020101101*QR_010010002011+P_120001001*QR_010010002100+P_120001101*QR_010010002101+P_120101001*QR_010010002110+P_120101101*QR_010010002111+P_220001001*QR_010010002200+P_220001101*QR_010010002201+P_220101001*QR_010010002210+P_220101101*QR_010010002211); ans_temp[ans_id*36+2]+=Pmtrx[24]*(P_020001001*QR_002020000000+P_020001101*QR_002020000001+P_020101001*QR_002020000010+P_020101101*QR_002020000011+P_120001001*QR_002020000100+P_120001101*QR_002020000101+P_120101001*QR_002020000110+P_120101101*QR_002020000111+P_220001001*QR_002020000200+P_220001101*QR_002020000201+P_220101001*QR_002020000210+P_220101101*QR_002020000211); ans_temp[ans_id*36+2]+=Pmtrx[25]*(P_020001001*QR_001021000000+P_020001101*QR_001021000001+P_020101001*QR_001021000010+P_020101101*QR_001021000011+P_120001001*QR_001021000100+P_120001101*QR_001021000101+P_120101001*QR_001021000110+P_120101101*QR_001021000111+P_220001001*QR_001021000200+P_220001101*QR_001021000201+P_220101001*QR_001021000210+P_220101101*QR_001021000211); ans_temp[ans_id*36+2]+=Pmtrx[26]*(P_020001001*QR_000022000000+P_020001101*QR_000022000001+P_020101001*QR_000022000010+P_020101101*QR_000022000011+P_120001001*QR_000022000100+P_120001101*QR_000022000101+P_120101001*QR_000022000110+P_120101101*QR_000022000111+P_220001001*QR_000022000200+P_220001101*QR_000022000201+P_220101001*QR_000022000210+P_220101101*QR_000022000211); ans_temp[ans_id*36+2]+=Pmtrx[27]*(P_020001001*QR_001020001000+P_020001101*QR_001020001001+P_020101001*QR_001020001010+P_020101101*QR_001020001011+P_120001001*QR_001020001100+P_120001101*QR_001020001101+P_120101001*QR_001020001110+P_120101101*QR_001020001111+P_220001001*QR_001020001200+P_220001101*QR_001020001201+P_220101001*QR_001020001210+P_220101101*QR_001020001211); ans_temp[ans_id*36+2]+=Pmtrx[28]*(P_020001001*QR_000021001000+P_020001101*QR_000021001001+P_020101001*QR_000021001010+P_020101101*QR_000021001011+P_120001001*QR_000021001100+P_120001101*QR_000021001101+P_120101001*QR_000021001110+P_120101101*QR_000021001111+P_220001001*QR_000021001200+P_220001101*QR_000021001201+P_220101001*QR_000021001210+P_220101101*QR_000021001211); ans_temp[ans_id*36+2]+=Pmtrx[29]*(P_020001001*QR_000020002000+P_020001101*QR_000020002001+P_020101001*QR_000020002010+P_020101101*QR_000020002011+P_120001001*QR_000020002100+P_120001101*QR_000020002101+P_120101001*QR_000020002110+P_120101101*QR_000020002111+P_220001001*QR_000020002200+P_220001101*QR_000020002201+P_220101001*QR_000020002210+P_220101101*QR_000020002211); ans_temp[ans_id*36+3]+=Pmtrx[24]*(P_020001001*QR_012000010000+P_020001101*QR_012000010001+P_020101001*QR_012000010010+P_020101101*QR_012000010011+P_120001001*QR_012000010100+P_120001101*QR_012000010101+P_120101001*QR_012000010110+P_120101101*QR_012000010111+P_220001001*QR_012000010200+P_220001101*QR_012000010201+P_220101001*QR_012000010210+P_220101101*QR_012000010211); ans_temp[ans_id*36+3]+=Pmtrx[25]*(P_020001001*QR_011001010000+P_020001101*QR_011001010001+P_020101001*QR_011001010010+P_020101101*QR_011001010011+P_120001001*QR_011001010100+P_120001101*QR_011001010101+P_120101001*QR_011001010110+P_120101101*QR_011001010111+P_220001001*QR_011001010200+P_220001101*QR_011001010201+P_220101001*QR_011001010210+P_220101101*QR_011001010211); ans_temp[ans_id*36+3]+=Pmtrx[26]*(P_020001001*QR_010002010000+P_020001101*QR_010002010001+P_020101001*QR_010002010010+P_020101101*QR_010002010011+P_120001001*QR_010002010100+P_120001101*QR_010002010101+P_120101001*QR_010002010110+P_120101101*QR_010002010111+P_220001001*QR_010002010200+P_220001101*QR_010002010201+P_220101001*QR_010002010210+P_220101101*QR_010002010211); ans_temp[ans_id*36+3]+=Pmtrx[27]*(P_020001001*QR_011000011000+P_020001101*QR_011000011001+P_020101001*QR_011000011010+P_020101101*QR_011000011011+P_120001001*QR_011000011100+P_120001101*QR_011000011101+P_120101001*QR_011000011110+P_120101101*QR_011000011111+P_220001001*QR_011000011200+P_220001101*QR_011000011201+P_220101001*QR_011000011210+P_220101101*QR_011000011211); ans_temp[ans_id*36+3]+=Pmtrx[28]*(P_020001001*QR_010001011000+P_020001101*QR_010001011001+P_020101001*QR_010001011010+P_020101101*QR_010001011011+P_120001001*QR_010001011100+P_120001101*QR_010001011101+P_120101001*QR_010001011110+P_120101101*QR_010001011111+P_220001001*QR_010001011200+P_220001101*QR_010001011201+P_220101001*QR_010001011210+P_220101101*QR_010001011211); ans_temp[ans_id*36+3]+=Pmtrx[29]*(P_020001001*QR_010000012000+P_020001101*QR_010000012001+P_020101001*QR_010000012010+P_020101101*QR_010000012011+P_120001001*QR_010000012100+P_120001101*QR_010000012101+P_120101001*QR_010000012110+P_120101101*QR_010000012111+P_220001001*QR_010000012200+P_220001101*QR_010000012201+P_220101001*QR_010000012210+P_220101101*QR_010000012211); ans_temp[ans_id*36+4]+=Pmtrx[24]*(P_020001001*QR_002010010000+P_020001101*QR_002010010001+P_020101001*QR_002010010010+P_020101101*QR_002010010011+P_120001001*QR_002010010100+P_120001101*QR_002010010101+P_120101001*QR_002010010110+P_120101101*QR_002010010111+P_220001001*QR_002010010200+P_220001101*QR_002010010201+P_220101001*QR_002010010210+P_220101101*QR_002010010211); ans_temp[ans_id*36+4]+=Pmtrx[25]*(P_020001001*QR_001011010000+P_020001101*QR_001011010001+P_020101001*QR_001011010010+P_020101101*QR_001011010011+P_120001001*QR_001011010100+P_120001101*QR_001011010101+P_120101001*QR_001011010110+P_120101101*QR_001011010111+P_220001001*QR_001011010200+P_220001101*QR_001011010201+P_220101001*QR_001011010210+P_220101101*QR_001011010211); ans_temp[ans_id*36+4]+=Pmtrx[26]*(P_020001001*QR_000012010000+P_020001101*QR_000012010001+P_020101001*QR_000012010010+P_020101101*QR_000012010011+P_120001001*QR_000012010100+P_120001101*QR_000012010101+P_120101001*QR_000012010110+P_120101101*QR_000012010111+P_220001001*QR_000012010200+P_220001101*QR_000012010201+P_220101001*QR_000012010210+P_220101101*QR_000012010211); ans_temp[ans_id*36+4]+=Pmtrx[27]*(P_020001001*QR_001010011000+P_020001101*QR_001010011001+P_020101001*QR_001010011010+P_020101101*QR_001010011011+P_120001001*QR_001010011100+P_120001101*QR_001010011101+P_120101001*QR_001010011110+P_120101101*QR_001010011111+P_220001001*QR_001010011200+P_220001101*QR_001010011201+P_220101001*QR_001010011210+P_220101101*QR_001010011211); ans_temp[ans_id*36+4]+=Pmtrx[28]*(P_020001001*QR_000011011000+P_020001101*QR_000011011001+P_020101001*QR_000011011010+P_020101101*QR_000011011011+P_120001001*QR_000011011100+P_120001101*QR_000011011101+P_120101001*QR_000011011110+P_120101101*QR_000011011111+P_220001001*QR_000011011200+P_220001101*QR_000011011201+P_220101001*QR_000011011210+P_220101101*QR_000011011211); ans_temp[ans_id*36+4]+=Pmtrx[29]*(P_020001001*QR_000010012000+P_020001101*QR_000010012001+P_020101001*QR_000010012010+P_020101101*QR_000010012011+P_120001001*QR_000010012100+P_120001101*QR_000010012101+P_120101001*QR_000010012110+P_120101101*QR_000010012111+P_220001001*QR_000010012200+P_220001101*QR_000010012201+P_220101001*QR_000010012210+P_220101101*QR_000010012211); ans_temp[ans_id*36+5]+=Pmtrx[24]*(P_020001001*QR_002000020000+P_020001101*QR_002000020001+P_020101001*QR_002000020010+P_020101101*QR_002000020011+P_120001001*QR_002000020100+P_120001101*QR_002000020101+P_120101001*QR_002000020110+P_120101101*QR_002000020111+P_220001001*QR_002000020200+P_220001101*QR_002000020201+P_220101001*QR_002000020210+P_220101101*QR_002000020211); ans_temp[ans_id*36+5]+=Pmtrx[25]*(P_020001001*QR_001001020000+P_020001101*QR_001001020001+P_020101001*QR_001001020010+P_020101101*QR_001001020011+P_120001001*QR_001001020100+P_120001101*QR_001001020101+P_120101001*QR_001001020110+P_120101101*QR_001001020111+P_220001001*QR_001001020200+P_220001101*QR_001001020201+P_220101001*QR_001001020210+P_220101101*QR_001001020211); ans_temp[ans_id*36+5]+=Pmtrx[26]*(P_020001001*QR_000002020000+P_020001101*QR_000002020001+P_020101001*QR_000002020010+P_020101101*QR_000002020011+P_120001001*QR_000002020100+P_120001101*QR_000002020101+P_120101001*QR_000002020110+P_120101101*QR_000002020111+P_220001001*QR_000002020200+P_220001101*QR_000002020201+P_220101001*QR_000002020210+P_220101101*QR_000002020211); ans_temp[ans_id*36+5]+=Pmtrx[27]*(P_020001001*QR_001000021000+P_020001101*QR_001000021001+P_020101001*QR_001000021010+P_020101101*QR_001000021011+P_120001001*QR_001000021100+P_120001101*QR_001000021101+P_120101001*QR_001000021110+P_120101101*QR_001000021111+P_220001001*QR_001000021200+P_220001101*QR_001000021201+P_220101001*QR_001000021210+P_220101101*QR_001000021211); ans_temp[ans_id*36+5]+=Pmtrx[28]*(P_020001001*QR_000001021000+P_020001101*QR_000001021001+P_020101001*QR_000001021010+P_020101101*QR_000001021011+P_120001001*QR_000001021100+P_120001101*QR_000001021101+P_120101001*QR_000001021110+P_120101101*QR_000001021111+P_220001001*QR_000001021200+P_220001101*QR_000001021201+P_220101001*QR_000001021210+P_220101101*QR_000001021211); ans_temp[ans_id*36+5]+=Pmtrx[29]*(P_020001001*QR_000000022000+P_020001101*QR_000000022001+P_020101001*QR_000000022010+P_020101101*QR_000000022011+P_120001001*QR_000000022100+P_120001101*QR_000000022101+P_120101001*QR_000000022110+P_120101101*QR_000000022111+P_220001001*QR_000000022200+P_220001101*QR_000000022201+P_220101001*QR_000000022210+P_220101101*QR_000000022211); ans_temp[ans_id*36+0]+=Pmtrx[30]*(P_020000002*QR_022000000000+P_020000102*QR_022000000001+P_020000202*QR_022000000002+P_120000002*QR_022000000100+P_120000102*QR_022000000101+P_120000202*QR_022000000102+P_220000002*QR_022000000200+P_220000102*QR_022000000201+P_220000202*QR_022000000202); ans_temp[ans_id*36+0]+=Pmtrx[31]*(P_020000002*QR_021001000000+P_020000102*QR_021001000001+P_020000202*QR_021001000002+P_120000002*QR_021001000100+P_120000102*QR_021001000101+P_120000202*QR_021001000102+P_220000002*QR_021001000200+P_220000102*QR_021001000201+P_220000202*QR_021001000202); ans_temp[ans_id*36+0]+=Pmtrx[32]*(P_020000002*QR_020002000000+P_020000102*QR_020002000001+P_020000202*QR_020002000002+P_120000002*QR_020002000100+P_120000102*QR_020002000101+P_120000202*QR_020002000102+P_220000002*QR_020002000200+P_220000102*QR_020002000201+P_220000202*QR_020002000202); ans_temp[ans_id*36+0]+=Pmtrx[33]*(P_020000002*QR_021000001000+P_020000102*QR_021000001001+P_020000202*QR_021000001002+P_120000002*QR_021000001100+P_120000102*QR_021000001101+P_120000202*QR_021000001102+P_220000002*QR_021000001200+P_220000102*QR_021000001201+P_220000202*QR_021000001202); ans_temp[ans_id*36+0]+=Pmtrx[34]*(P_020000002*QR_020001001000+P_020000102*QR_020001001001+P_020000202*QR_020001001002+P_120000002*QR_020001001100+P_120000102*QR_020001001101+P_120000202*QR_020001001102+P_220000002*QR_020001001200+P_220000102*QR_020001001201+P_220000202*QR_020001001202); ans_temp[ans_id*36+0]+=Pmtrx[35]*(P_020000002*QR_020000002000+P_020000102*QR_020000002001+P_020000202*QR_020000002002+P_120000002*QR_020000002100+P_120000102*QR_020000002101+P_120000202*QR_020000002102+P_220000002*QR_020000002200+P_220000102*QR_020000002201+P_220000202*QR_020000002202); ans_temp[ans_id*36+1]+=Pmtrx[30]*(P_020000002*QR_012010000000+P_020000102*QR_012010000001+P_020000202*QR_012010000002+P_120000002*QR_012010000100+P_120000102*QR_012010000101+P_120000202*QR_012010000102+P_220000002*QR_012010000200+P_220000102*QR_012010000201+P_220000202*QR_012010000202); ans_temp[ans_id*36+1]+=Pmtrx[31]*(P_020000002*QR_011011000000+P_020000102*QR_011011000001+P_020000202*QR_011011000002+P_120000002*QR_011011000100+P_120000102*QR_011011000101+P_120000202*QR_011011000102+P_220000002*QR_011011000200+P_220000102*QR_011011000201+P_220000202*QR_011011000202); ans_temp[ans_id*36+1]+=Pmtrx[32]*(P_020000002*QR_010012000000+P_020000102*QR_010012000001+P_020000202*QR_010012000002+P_120000002*QR_010012000100+P_120000102*QR_010012000101+P_120000202*QR_010012000102+P_220000002*QR_010012000200+P_220000102*QR_010012000201+P_220000202*QR_010012000202); ans_temp[ans_id*36+1]+=Pmtrx[33]*(P_020000002*QR_011010001000+P_020000102*QR_011010001001+P_020000202*QR_011010001002+P_120000002*QR_011010001100+P_120000102*QR_011010001101+P_120000202*QR_011010001102+P_220000002*QR_011010001200+P_220000102*QR_011010001201+P_220000202*QR_011010001202); ans_temp[ans_id*36+1]+=Pmtrx[34]*(P_020000002*QR_010011001000+P_020000102*QR_010011001001+P_020000202*QR_010011001002+P_120000002*QR_010011001100+P_120000102*QR_010011001101+P_120000202*QR_010011001102+P_220000002*QR_010011001200+P_220000102*QR_010011001201+P_220000202*QR_010011001202); ans_temp[ans_id*36+1]+=Pmtrx[35]*(P_020000002*QR_010010002000+P_020000102*QR_010010002001+P_020000202*QR_010010002002+P_120000002*QR_010010002100+P_120000102*QR_010010002101+P_120000202*QR_010010002102+P_220000002*QR_010010002200+P_220000102*QR_010010002201+P_220000202*QR_010010002202); ans_temp[ans_id*36+2]+=Pmtrx[30]*(P_020000002*QR_002020000000+P_020000102*QR_002020000001+P_020000202*QR_002020000002+P_120000002*QR_002020000100+P_120000102*QR_002020000101+P_120000202*QR_002020000102+P_220000002*QR_002020000200+P_220000102*QR_002020000201+P_220000202*QR_002020000202); ans_temp[ans_id*36+2]+=Pmtrx[31]*(P_020000002*QR_001021000000+P_020000102*QR_001021000001+P_020000202*QR_001021000002+P_120000002*QR_001021000100+P_120000102*QR_001021000101+P_120000202*QR_001021000102+P_220000002*QR_001021000200+P_220000102*QR_001021000201+P_220000202*QR_001021000202); ans_temp[ans_id*36+2]+=Pmtrx[32]*(P_020000002*QR_000022000000+P_020000102*QR_000022000001+P_020000202*QR_000022000002+P_120000002*QR_000022000100+P_120000102*QR_000022000101+P_120000202*QR_000022000102+P_220000002*QR_000022000200+P_220000102*QR_000022000201+P_220000202*QR_000022000202); ans_temp[ans_id*36+2]+=Pmtrx[33]*(P_020000002*QR_001020001000+P_020000102*QR_001020001001+P_020000202*QR_001020001002+P_120000002*QR_001020001100+P_120000102*QR_001020001101+P_120000202*QR_001020001102+P_220000002*QR_001020001200+P_220000102*QR_001020001201+P_220000202*QR_001020001202); ans_temp[ans_id*36+2]+=Pmtrx[34]*(P_020000002*QR_000021001000+P_020000102*QR_000021001001+P_020000202*QR_000021001002+P_120000002*QR_000021001100+P_120000102*QR_000021001101+P_120000202*QR_000021001102+P_220000002*QR_000021001200+P_220000102*QR_000021001201+P_220000202*QR_000021001202); ans_temp[ans_id*36+2]+=Pmtrx[35]*(P_020000002*QR_000020002000+P_020000102*QR_000020002001+P_020000202*QR_000020002002+P_120000002*QR_000020002100+P_120000102*QR_000020002101+P_120000202*QR_000020002102+P_220000002*QR_000020002200+P_220000102*QR_000020002201+P_220000202*QR_000020002202); ans_temp[ans_id*36+3]+=Pmtrx[30]*(P_020000002*QR_012000010000+P_020000102*QR_012000010001+P_020000202*QR_012000010002+P_120000002*QR_012000010100+P_120000102*QR_012000010101+P_120000202*QR_012000010102+P_220000002*QR_012000010200+P_220000102*QR_012000010201+P_220000202*QR_012000010202); ans_temp[ans_id*36+3]+=Pmtrx[31]*(P_020000002*QR_011001010000+P_020000102*QR_011001010001+P_020000202*QR_011001010002+P_120000002*QR_011001010100+P_120000102*QR_011001010101+P_120000202*QR_011001010102+P_220000002*QR_011001010200+P_220000102*QR_011001010201+P_220000202*QR_011001010202); ans_temp[ans_id*36+3]+=Pmtrx[32]*(P_020000002*QR_010002010000+P_020000102*QR_010002010001+P_020000202*QR_010002010002+P_120000002*QR_010002010100+P_120000102*QR_010002010101+P_120000202*QR_010002010102+P_220000002*QR_010002010200+P_220000102*QR_010002010201+P_220000202*QR_010002010202); ans_temp[ans_id*36+3]+=Pmtrx[33]*(P_020000002*QR_011000011000+P_020000102*QR_011000011001+P_020000202*QR_011000011002+P_120000002*QR_011000011100+P_120000102*QR_011000011101+P_120000202*QR_011000011102+P_220000002*QR_011000011200+P_220000102*QR_011000011201+P_220000202*QR_011000011202); ans_temp[ans_id*36+3]+=Pmtrx[34]*(P_020000002*QR_010001011000+P_020000102*QR_010001011001+P_020000202*QR_010001011002+P_120000002*QR_010001011100+P_120000102*QR_010001011101+P_120000202*QR_010001011102+P_220000002*QR_010001011200+P_220000102*QR_010001011201+P_220000202*QR_010001011202); ans_temp[ans_id*36+3]+=Pmtrx[35]*(P_020000002*QR_010000012000+P_020000102*QR_010000012001+P_020000202*QR_010000012002+P_120000002*QR_010000012100+P_120000102*QR_010000012101+P_120000202*QR_010000012102+P_220000002*QR_010000012200+P_220000102*QR_010000012201+P_220000202*QR_010000012202); ans_temp[ans_id*36+4]+=Pmtrx[30]*(P_020000002*QR_002010010000+P_020000102*QR_002010010001+P_020000202*QR_002010010002+P_120000002*QR_002010010100+P_120000102*QR_002010010101+P_120000202*QR_002010010102+P_220000002*QR_002010010200+P_220000102*QR_002010010201+P_220000202*QR_002010010202); ans_temp[ans_id*36+4]+=Pmtrx[31]*(P_020000002*QR_001011010000+P_020000102*QR_001011010001+P_020000202*QR_001011010002+P_120000002*QR_001011010100+P_120000102*QR_001011010101+P_120000202*QR_001011010102+P_220000002*QR_001011010200+P_220000102*QR_001011010201+P_220000202*QR_001011010202); ans_temp[ans_id*36+4]+=Pmtrx[32]*(P_020000002*QR_000012010000+P_020000102*QR_000012010001+P_020000202*QR_000012010002+P_120000002*QR_000012010100+P_120000102*QR_000012010101+P_120000202*QR_000012010102+P_220000002*QR_000012010200+P_220000102*QR_000012010201+P_220000202*QR_000012010202); ans_temp[ans_id*36+4]+=Pmtrx[33]*(P_020000002*QR_001010011000+P_020000102*QR_001010011001+P_020000202*QR_001010011002+P_120000002*QR_001010011100+P_120000102*QR_001010011101+P_120000202*QR_001010011102+P_220000002*QR_001010011200+P_220000102*QR_001010011201+P_220000202*QR_001010011202); ans_temp[ans_id*36+4]+=Pmtrx[34]*(P_020000002*QR_000011011000+P_020000102*QR_000011011001+P_020000202*QR_000011011002+P_120000002*QR_000011011100+P_120000102*QR_000011011101+P_120000202*QR_000011011102+P_220000002*QR_000011011200+P_220000102*QR_000011011201+P_220000202*QR_000011011202); ans_temp[ans_id*36+4]+=Pmtrx[35]*(P_020000002*QR_000010012000+P_020000102*QR_000010012001+P_020000202*QR_000010012002+P_120000002*QR_000010012100+P_120000102*QR_000010012101+P_120000202*QR_000010012102+P_220000002*QR_000010012200+P_220000102*QR_000010012201+P_220000202*QR_000010012202); ans_temp[ans_id*36+5]+=Pmtrx[30]*(P_020000002*QR_002000020000+P_020000102*QR_002000020001+P_020000202*QR_002000020002+P_120000002*QR_002000020100+P_120000102*QR_002000020101+P_120000202*QR_002000020102+P_220000002*QR_002000020200+P_220000102*QR_002000020201+P_220000202*QR_002000020202); ans_temp[ans_id*36+5]+=Pmtrx[31]*(P_020000002*QR_001001020000+P_020000102*QR_001001020001+P_020000202*QR_001001020002+P_120000002*QR_001001020100+P_120000102*QR_001001020101+P_120000202*QR_001001020102+P_220000002*QR_001001020200+P_220000102*QR_001001020201+P_220000202*QR_001001020202); ans_temp[ans_id*36+5]+=Pmtrx[32]*(P_020000002*QR_000002020000+P_020000102*QR_000002020001+P_020000202*QR_000002020002+P_120000002*QR_000002020100+P_120000102*QR_000002020101+P_120000202*QR_000002020102+P_220000002*QR_000002020200+P_220000102*QR_000002020201+P_220000202*QR_000002020202); ans_temp[ans_id*36+5]+=Pmtrx[33]*(P_020000002*QR_001000021000+P_020000102*QR_001000021001+P_020000202*QR_001000021002+P_120000002*QR_001000021100+P_120000102*QR_001000021101+P_120000202*QR_001000021102+P_220000002*QR_001000021200+P_220000102*QR_001000021201+P_220000202*QR_001000021202); ans_temp[ans_id*36+5]+=Pmtrx[34]*(P_020000002*QR_000001021000+P_020000102*QR_000001021001+P_020000202*QR_000001021002+P_120000002*QR_000001021100+P_120000102*QR_000001021101+P_120000202*QR_000001021102+P_220000002*QR_000001021200+P_220000102*QR_000001021201+P_220000202*QR_000001021202); ans_temp[ans_id*36+5]+=Pmtrx[35]*(P_020000002*QR_000000022000+P_020000102*QR_000000022001+P_020000202*QR_000000022002+P_120000002*QR_000000022100+P_120000102*QR_000000022101+P_120000202*QR_000000022102+P_220000002*QR_000000022200+P_220000102*QR_000000022201+P_220000202*QR_000000022202); ans_temp[ans_id*36+6]+=Pmtrx[0]*(P_012010000*QR_022000000000+P_012110000*QR_022000000010+P_112010000*QR_022000000100+P_112110000*QR_022000000110+P_212010000*QR_022000000200+P_212110000*QR_022000000210+P_312010000*QR_022000000300+P_312110000*QR_022000000310); ans_temp[ans_id*36+6]+=Pmtrx[1]*(P_012010000*QR_021001000000+P_012110000*QR_021001000010+P_112010000*QR_021001000100+P_112110000*QR_021001000110+P_212010000*QR_021001000200+P_212110000*QR_021001000210+P_312010000*QR_021001000300+P_312110000*QR_021001000310); ans_temp[ans_id*36+6]+=Pmtrx[2]*(P_012010000*QR_020002000000+P_012110000*QR_020002000010+P_112010000*QR_020002000100+P_112110000*QR_020002000110+P_212010000*QR_020002000200+P_212110000*QR_020002000210+P_312010000*QR_020002000300+P_312110000*QR_020002000310); ans_temp[ans_id*36+6]+=Pmtrx[3]*(P_012010000*QR_021000001000+P_012110000*QR_021000001010+P_112010000*QR_021000001100+P_112110000*QR_021000001110+P_212010000*QR_021000001200+P_212110000*QR_021000001210+P_312010000*QR_021000001300+P_312110000*QR_021000001310); ans_temp[ans_id*36+6]+=Pmtrx[4]*(P_012010000*QR_020001001000+P_012110000*QR_020001001010+P_112010000*QR_020001001100+P_112110000*QR_020001001110+P_212010000*QR_020001001200+P_212110000*QR_020001001210+P_312010000*QR_020001001300+P_312110000*QR_020001001310); ans_temp[ans_id*36+6]+=Pmtrx[5]*(P_012010000*QR_020000002000+P_012110000*QR_020000002010+P_112010000*QR_020000002100+P_112110000*QR_020000002110+P_212010000*QR_020000002200+P_212110000*QR_020000002210+P_312010000*QR_020000002300+P_312110000*QR_020000002310); ans_temp[ans_id*36+7]+=Pmtrx[0]*(P_012010000*QR_012010000000+P_012110000*QR_012010000010+P_112010000*QR_012010000100+P_112110000*QR_012010000110+P_212010000*QR_012010000200+P_212110000*QR_012010000210+P_312010000*QR_012010000300+P_312110000*QR_012010000310); ans_temp[ans_id*36+7]+=Pmtrx[1]*(P_012010000*QR_011011000000+P_012110000*QR_011011000010+P_112010000*QR_011011000100+P_112110000*QR_011011000110+P_212010000*QR_011011000200+P_212110000*QR_011011000210+P_312010000*QR_011011000300+P_312110000*QR_011011000310); ans_temp[ans_id*36+7]+=Pmtrx[2]*(P_012010000*QR_010012000000+P_012110000*QR_010012000010+P_112010000*QR_010012000100+P_112110000*QR_010012000110+P_212010000*QR_010012000200+P_212110000*QR_010012000210+P_312010000*QR_010012000300+P_312110000*QR_010012000310); ans_temp[ans_id*36+7]+=Pmtrx[3]*(P_012010000*QR_011010001000+P_012110000*QR_011010001010+P_112010000*QR_011010001100+P_112110000*QR_011010001110+P_212010000*QR_011010001200+P_212110000*QR_011010001210+P_312010000*QR_011010001300+P_312110000*QR_011010001310); ans_temp[ans_id*36+7]+=Pmtrx[4]*(P_012010000*QR_010011001000+P_012110000*QR_010011001010+P_112010000*QR_010011001100+P_112110000*QR_010011001110+P_212010000*QR_010011001200+P_212110000*QR_010011001210+P_312010000*QR_010011001300+P_312110000*QR_010011001310); ans_temp[ans_id*36+7]+=Pmtrx[5]*(P_012010000*QR_010010002000+P_012110000*QR_010010002010+P_112010000*QR_010010002100+P_112110000*QR_010010002110+P_212010000*QR_010010002200+P_212110000*QR_010010002210+P_312010000*QR_010010002300+P_312110000*QR_010010002310); ans_temp[ans_id*36+8]+=Pmtrx[0]*(P_012010000*QR_002020000000+P_012110000*QR_002020000010+P_112010000*QR_002020000100+P_112110000*QR_002020000110+P_212010000*QR_002020000200+P_212110000*QR_002020000210+P_312010000*QR_002020000300+P_312110000*QR_002020000310); ans_temp[ans_id*36+8]+=Pmtrx[1]*(P_012010000*QR_001021000000+P_012110000*QR_001021000010+P_112010000*QR_001021000100+P_112110000*QR_001021000110+P_212010000*QR_001021000200+P_212110000*QR_001021000210+P_312010000*QR_001021000300+P_312110000*QR_001021000310); ans_temp[ans_id*36+8]+=Pmtrx[2]*(P_012010000*QR_000022000000+P_012110000*QR_000022000010+P_112010000*QR_000022000100+P_112110000*QR_000022000110+P_212010000*QR_000022000200+P_212110000*QR_000022000210+P_312010000*QR_000022000300+P_312110000*QR_000022000310); ans_temp[ans_id*36+8]+=Pmtrx[3]*(P_012010000*QR_001020001000+P_012110000*QR_001020001010+P_112010000*QR_001020001100+P_112110000*QR_001020001110+P_212010000*QR_001020001200+P_212110000*QR_001020001210+P_312010000*QR_001020001300+P_312110000*QR_001020001310); ans_temp[ans_id*36+8]+=Pmtrx[4]*(P_012010000*QR_000021001000+P_012110000*QR_000021001010+P_112010000*QR_000021001100+P_112110000*QR_000021001110+P_212010000*QR_000021001200+P_212110000*QR_000021001210+P_312010000*QR_000021001300+P_312110000*QR_000021001310); ans_temp[ans_id*36+8]+=Pmtrx[5]*(P_012010000*QR_000020002000+P_012110000*QR_000020002010+P_112010000*QR_000020002100+P_112110000*QR_000020002110+P_212010000*QR_000020002200+P_212110000*QR_000020002210+P_312010000*QR_000020002300+P_312110000*QR_000020002310); ans_temp[ans_id*36+9]+=Pmtrx[0]*(P_012010000*QR_012000010000+P_012110000*QR_012000010010+P_112010000*QR_012000010100+P_112110000*QR_012000010110+P_212010000*QR_012000010200+P_212110000*QR_012000010210+P_312010000*QR_012000010300+P_312110000*QR_012000010310); ans_temp[ans_id*36+9]+=Pmtrx[1]*(P_012010000*QR_011001010000+P_012110000*QR_011001010010+P_112010000*QR_011001010100+P_112110000*QR_011001010110+P_212010000*QR_011001010200+P_212110000*QR_011001010210+P_312010000*QR_011001010300+P_312110000*QR_011001010310); ans_temp[ans_id*36+9]+=Pmtrx[2]*(P_012010000*QR_010002010000+P_012110000*QR_010002010010+P_112010000*QR_010002010100+P_112110000*QR_010002010110+P_212010000*QR_010002010200+P_212110000*QR_010002010210+P_312010000*QR_010002010300+P_312110000*QR_010002010310); ans_temp[ans_id*36+9]+=Pmtrx[3]*(P_012010000*QR_011000011000+P_012110000*QR_011000011010+P_112010000*QR_011000011100+P_112110000*QR_011000011110+P_212010000*QR_011000011200+P_212110000*QR_011000011210+P_312010000*QR_011000011300+P_312110000*QR_011000011310); ans_temp[ans_id*36+9]+=Pmtrx[4]*(P_012010000*QR_010001011000+P_012110000*QR_010001011010+P_112010000*QR_010001011100+P_112110000*QR_010001011110+P_212010000*QR_010001011200+P_212110000*QR_010001011210+P_312010000*QR_010001011300+P_312110000*QR_010001011310); ans_temp[ans_id*36+9]+=Pmtrx[5]*(P_012010000*QR_010000012000+P_012110000*QR_010000012010+P_112010000*QR_010000012100+P_112110000*QR_010000012110+P_212010000*QR_010000012200+P_212110000*QR_010000012210+P_312010000*QR_010000012300+P_312110000*QR_010000012310); ans_temp[ans_id*36+10]+=Pmtrx[0]*(P_012010000*QR_002010010000+P_012110000*QR_002010010010+P_112010000*QR_002010010100+P_112110000*QR_002010010110+P_212010000*QR_002010010200+P_212110000*QR_002010010210+P_312010000*QR_002010010300+P_312110000*QR_002010010310); ans_temp[ans_id*36+10]+=Pmtrx[1]*(P_012010000*QR_001011010000+P_012110000*QR_001011010010+P_112010000*QR_001011010100+P_112110000*QR_001011010110+P_212010000*QR_001011010200+P_212110000*QR_001011010210+P_312010000*QR_001011010300+P_312110000*QR_001011010310); ans_temp[ans_id*36+10]+=Pmtrx[2]*(P_012010000*QR_000012010000+P_012110000*QR_000012010010+P_112010000*QR_000012010100+P_112110000*QR_000012010110+P_212010000*QR_000012010200+P_212110000*QR_000012010210+P_312010000*QR_000012010300+P_312110000*QR_000012010310); ans_temp[ans_id*36+10]+=Pmtrx[3]*(P_012010000*QR_001010011000+P_012110000*QR_001010011010+P_112010000*QR_001010011100+P_112110000*QR_001010011110+P_212010000*QR_001010011200+P_212110000*QR_001010011210+P_312010000*QR_001010011300+P_312110000*QR_001010011310); ans_temp[ans_id*36+10]+=Pmtrx[4]*(P_012010000*QR_000011011000+P_012110000*QR_000011011010+P_112010000*QR_000011011100+P_112110000*QR_000011011110+P_212010000*QR_000011011200+P_212110000*QR_000011011210+P_312010000*QR_000011011300+P_312110000*QR_000011011310); ans_temp[ans_id*36+10]+=Pmtrx[5]*(P_012010000*QR_000010012000+P_012110000*QR_000010012010+P_112010000*QR_000010012100+P_112110000*QR_000010012110+P_212010000*QR_000010012200+P_212110000*QR_000010012210+P_312010000*QR_000010012300+P_312110000*QR_000010012310); ans_temp[ans_id*36+11]+=Pmtrx[0]*(P_012010000*QR_002000020000+P_012110000*QR_002000020010+P_112010000*QR_002000020100+P_112110000*QR_002000020110+P_212010000*QR_002000020200+P_212110000*QR_002000020210+P_312010000*QR_002000020300+P_312110000*QR_002000020310); ans_temp[ans_id*36+11]+=Pmtrx[1]*(P_012010000*QR_001001020000+P_012110000*QR_001001020010+P_112010000*QR_001001020100+P_112110000*QR_001001020110+P_212010000*QR_001001020200+P_212110000*QR_001001020210+P_312010000*QR_001001020300+P_312110000*QR_001001020310); ans_temp[ans_id*36+11]+=Pmtrx[2]*(P_012010000*QR_000002020000+P_012110000*QR_000002020010+P_112010000*QR_000002020100+P_112110000*QR_000002020110+P_212010000*QR_000002020200+P_212110000*QR_000002020210+P_312010000*QR_000002020300+P_312110000*QR_000002020310); ans_temp[ans_id*36+11]+=Pmtrx[3]*(P_012010000*QR_001000021000+P_012110000*QR_001000021010+P_112010000*QR_001000021100+P_112110000*QR_001000021110+P_212010000*QR_001000021200+P_212110000*QR_001000021210+P_312010000*QR_001000021300+P_312110000*QR_001000021310); ans_temp[ans_id*36+11]+=Pmtrx[4]*(P_012010000*QR_000001021000+P_012110000*QR_000001021010+P_112010000*QR_000001021100+P_112110000*QR_000001021110+P_212010000*QR_000001021200+P_212110000*QR_000001021210+P_312010000*QR_000001021300+P_312110000*QR_000001021310); ans_temp[ans_id*36+11]+=Pmtrx[5]*(P_012010000*QR_000000022000+P_012110000*QR_000000022010+P_112010000*QR_000000022100+P_112110000*QR_000000022110+P_212010000*QR_000000022200+P_212110000*QR_000000022210+P_312010000*QR_000000022300+P_312110000*QR_000000022310); ans_temp[ans_id*36+6]+=Pmtrx[6]*(P_011011000*QR_022000000000+P_011111000*QR_022000000010+P_011211000*QR_022000000020+P_111011000*QR_022000000100+P_111111000*QR_022000000110+P_111211000*QR_022000000120+P_211011000*QR_022000000200+P_211111000*QR_022000000210+P_211211000*QR_022000000220); ans_temp[ans_id*36+6]+=Pmtrx[7]*(P_011011000*QR_021001000000+P_011111000*QR_021001000010+P_011211000*QR_021001000020+P_111011000*QR_021001000100+P_111111000*QR_021001000110+P_111211000*QR_021001000120+P_211011000*QR_021001000200+P_211111000*QR_021001000210+P_211211000*QR_021001000220); ans_temp[ans_id*36+6]+=Pmtrx[8]*(P_011011000*QR_020002000000+P_011111000*QR_020002000010+P_011211000*QR_020002000020+P_111011000*QR_020002000100+P_111111000*QR_020002000110+P_111211000*QR_020002000120+P_211011000*QR_020002000200+P_211111000*QR_020002000210+P_211211000*QR_020002000220); ans_temp[ans_id*36+6]+=Pmtrx[9]*(P_011011000*QR_021000001000+P_011111000*QR_021000001010+P_011211000*QR_021000001020+P_111011000*QR_021000001100+P_111111000*QR_021000001110+P_111211000*QR_021000001120+P_211011000*QR_021000001200+P_211111000*QR_021000001210+P_211211000*QR_021000001220); ans_temp[ans_id*36+6]+=Pmtrx[10]*(P_011011000*QR_020001001000+P_011111000*QR_020001001010+P_011211000*QR_020001001020+P_111011000*QR_020001001100+P_111111000*QR_020001001110+P_111211000*QR_020001001120+P_211011000*QR_020001001200+P_211111000*QR_020001001210+P_211211000*QR_020001001220); ans_temp[ans_id*36+6]+=Pmtrx[11]*(P_011011000*QR_020000002000+P_011111000*QR_020000002010+P_011211000*QR_020000002020+P_111011000*QR_020000002100+P_111111000*QR_020000002110+P_111211000*QR_020000002120+P_211011000*QR_020000002200+P_211111000*QR_020000002210+P_211211000*QR_020000002220); ans_temp[ans_id*36+7]+=Pmtrx[6]*(P_011011000*QR_012010000000+P_011111000*QR_012010000010+P_011211000*QR_012010000020+P_111011000*QR_012010000100+P_111111000*QR_012010000110+P_111211000*QR_012010000120+P_211011000*QR_012010000200+P_211111000*QR_012010000210+P_211211000*QR_012010000220); ans_temp[ans_id*36+7]+=Pmtrx[7]*(P_011011000*QR_011011000000+P_011111000*QR_011011000010+P_011211000*QR_011011000020+P_111011000*QR_011011000100+P_111111000*QR_011011000110+P_111211000*QR_011011000120+P_211011000*QR_011011000200+P_211111000*QR_011011000210+P_211211000*QR_011011000220); ans_temp[ans_id*36+7]+=Pmtrx[8]*(P_011011000*QR_010012000000+P_011111000*QR_010012000010+P_011211000*QR_010012000020+P_111011000*QR_010012000100+P_111111000*QR_010012000110+P_111211000*QR_010012000120+P_211011000*QR_010012000200+P_211111000*QR_010012000210+P_211211000*QR_010012000220); ans_temp[ans_id*36+7]+=Pmtrx[9]*(P_011011000*QR_011010001000+P_011111000*QR_011010001010+P_011211000*QR_011010001020+P_111011000*QR_011010001100+P_111111000*QR_011010001110+P_111211000*QR_011010001120+P_211011000*QR_011010001200+P_211111000*QR_011010001210+P_211211000*QR_011010001220); ans_temp[ans_id*36+7]+=Pmtrx[10]*(P_011011000*QR_010011001000+P_011111000*QR_010011001010+P_011211000*QR_010011001020+P_111011000*QR_010011001100+P_111111000*QR_010011001110+P_111211000*QR_010011001120+P_211011000*QR_010011001200+P_211111000*QR_010011001210+P_211211000*QR_010011001220); ans_temp[ans_id*36+7]+=Pmtrx[11]*(P_011011000*QR_010010002000+P_011111000*QR_010010002010+P_011211000*QR_010010002020+P_111011000*QR_010010002100+P_111111000*QR_010010002110+P_111211000*QR_010010002120+P_211011000*QR_010010002200+P_211111000*QR_010010002210+P_211211000*QR_010010002220); ans_temp[ans_id*36+8]+=Pmtrx[6]*(P_011011000*QR_002020000000+P_011111000*QR_002020000010+P_011211000*QR_002020000020+P_111011000*QR_002020000100+P_111111000*QR_002020000110+P_111211000*QR_002020000120+P_211011000*QR_002020000200+P_211111000*QR_002020000210+P_211211000*QR_002020000220); ans_temp[ans_id*36+8]+=Pmtrx[7]*(P_011011000*QR_001021000000+P_011111000*QR_001021000010+P_011211000*QR_001021000020+P_111011000*QR_001021000100+P_111111000*QR_001021000110+P_111211000*QR_001021000120+P_211011000*QR_001021000200+P_211111000*QR_001021000210+P_211211000*QR_001021000220); ans_temp[ans_id*36+8]+=Pmtrx[8]*(P_011011000*QR_000022000000+P_011111000*QR_000022000010+P_011211000*QR_000022000020+P_111011000*QR_000022000100+P_111111000*QR_000022000110+P_111211000*QR_000022000120+P_211011000*QR_000022000200+P_211111000*QR_000022000210+P_211211000*QR_000022000220); ans_temp[ans_id*36+8]+=Pmtrx[9]*(P_011011000*QR_001020001000+P_011111000*QR_001020001010+P_011211000*QR_001020001020+P_111011000*QR_001020001100+P_111111000*QR_001020001110+P_111211000*QR_001020001120+P_211011000*QR_001020001200+P_211111000*QR_001020001210+P_211211000*QR_001020001220); ans_temp[ans_id*36+8]+=Pmtrx[10]*(P_011011000*QR_000021001000+P_011111000*QR_000021001010+P_011211000*QR_000021001020+P_111011000*QR_000021001100+P_111111000*QR_000021001110+P_111211000*QR_000021001120+P_211011000*QR_000021001200+P_211111000*QR_000021001210+P_211211000*QR_000021001220); ans_temp[ans_id*36+8]+=Pmtrx[11]*(P_011011000*QR_000020002000+P_011111000*QR_000020002010+P_011211000*QR_000020002020+P_111011000*QR_000020002100+P_111111000*QR_000020002110+P_111211000*QR_000020002120+P_211011000*QR_000020002200+P_211111000*QR_000020002210+P_211211000*QR_000020002220); ans_temp[ans_id*36+9]+=Pmtrx[6]*(P_011011000*QR_012000010000+P_011111000*QR_012000010010+P_011211000*QR_012000010020+P_111011000*QR_012000010100+P_111111000*QR_012000010110+P_111211000*QR_012000010120+P_211011000*QR_012000010200+P_211111000*QR_012000010210+P_211211000*QR_012000010220); ans_temp[ans_id*36+9]+=Pmtrx[7]*(P_011011000*QR_011001010000+P_011111000*QR_011001010010+P_011211000*QR_011001010020+P_111011000*QR_011001010100+P_111111000*QR_011001010110+P_111211000*QR_011001010120+P_211011000*QR_011001010200+P_211111000*QR_011001010210+P_211211000*QR_011001010220); ans_temp[ans_id*36+9]+=Pmtrx[8]*(P_011011000*QR_010002010000+P_011111000*QR_010002010010+P_011211000*QR_010002010020+P_111011000*QR_010002010100+P_111111000*QR_010002010110+P_111211000*QR_010002010120+P_211011000*QR_010002010200+P_211111000*QR_010002010210+P_211211000*QR_010002010220); ans_temp[ans_id*36+9]+=Pmtrx[9]*(P_011011000*QR_011000011000+P_011111000*QR_011000011010+P_011211000*QR_011000011020+P_111011000*QR_011000011100+P_111111000*QR_011000011110+P_111211000*QR_011000011120+P_211011000*QR_011000011200+P_211111000*QR_011000011210+P_211211000*QR_011000011220); ans_temp[ans_id*36+9]+=Pmtrx[10]*(P_011011000*QR_010001011000+P_011111000*QR_010001011010+P_011211000*QR_010001011020+P_111011000*QR_010001011100+P_111111000*QR_010001011110+P_111211000*QR_010001011120+P_211011000*QR_010001011200+P_211111000*QR_010001011210+P_211211000*QR_010001011220); ans_temp[ans_id*36+9]+=Pmtrx[11]*(P_011011000*QR_010000012000+P_011111000*QR_010000012010+P_011211000*QR_010000012020+P_111011000*QR_010000012100+P_111111000*QR_010000012110+P_111211000*QR_010000012120+P_211011000*QR_010000012200+P_211111000*QR_010000012210+P_211211000*QR_010000012220); ans_temp[ans_id*36+10]+=Pmtrx[6]*(P_011011000*QR_002010010000+P_011111000*QR_002010010010+P_011211000*QR_002010010020+P_111011000*QR_002010010100+P_111111000*QR_002010010110+P_111211000*QR_002010010120+P_211011000*QR_002010010200+P_211111000*QR_002010010210+P_211211000*QR_002010010220); ans_temp[ans_id*36+10]+=Pmtrx[7]*(P_011011000*QR_001011010000+P_011111000*QR_001011010010+P_011211000*QR_001011010020+P_111011000*QR_001011010100+P_111111000*QR_001011010110+P_111211000*QR_001011010120+P_211011000*QR_001011010200+P_211111000*QR_001011010210+P_211211000*QR_001011010220); ans_temp[ans_id*36+10]+=Pmtrx[8]*(P_011011000*QR_000012010000+P_011111000*QR_000012010010+P_011211000*QR_000012010020+P_111011000*QR_000012010100+P_111111000*QR_000012010110+P_111211000*QR_000012010120+P_211011000*QR_000012010200+P_211111000*QR_000012010210+P_211211000*QR_000012010220); ans_temp[ans_id*36+10]+=Pmtrx[9]*(P_011011000*QR_001010011000+P_011111000*QR_001010011010+P_011211000*QR_001010011020+P_111011000*QR_001010011100+P_111111000*QR_001010011110+P_111211000*QR_001010011120+P_211011000*QR_001010011200+P_211111000*QR_001010011210+P_211211000*QR_001010011220); ans_temp[ans_id*36+10]+=Pmtrx[10]*(P_011011000*QR_000011011000+P_011111000*QR_000011011010+P_011211000*QR_000011011020+P_111011000*QR_000011011100+P_111111000*QR_000011011110+P_111211000*QR_000011011120+P_211011000*QR_000011011200+P_211111000*QR_000011011210+P_211211000*QR_000011011220); ans_temp[ans_id*36+10]+=Pmtrx[11]*(P_011011000*QR_000010012000+P_011111000*QR_000010012010+P_011211000*QR_000010012020+P_111011000*QR_000010012100+P_111111000*QR_000010012110+P_111211000*QR_000010012120+P_211011000*QR_000010012200+P_211111000*QR_000010012210+P_211211000*QR_000010012220); ans_temp[ans_id*36+11]+=Pmtrx[6]*(P_011011000*QR_002000020000+P_011111000*QR_002000020010+P_011211000*QR_002000020020+P_111011000*QR_002000020100+P_111111000*QR_002000020110+P_111211000*QR_002000020120+P_211011000*QR_002000020200+P_211111000*QR_002000020210+P_211211000*QR_002000020220); ans_temp[ans_id*36+11]+=Pmtrx[7]*(P_011011000*QR_001001020000+P_011111000*QR_001001020010+P_011211000*QR_001001020020+P_111011000*QR_001001020100+P_111111000*QR_001001020110+P_111211000*QR_001001020120+P_211011000*QR_001001020200+P_211111000*QR_001001020210+P_211211000*QR_001001020220); ans_temp[ans_id*36+11]+=Pmtrx[8]*(P_011011000*QR_000002020000+P_011111000*QR_000002020010+P_011211000*QR_000002020020+P_111011000*QR_000002020100+P_111111000*QR_000002020110+P_111211000*QR_000002020120+P_211011000*QR_000002020200+P_211111000*QR_000002020210+P_211211000*QR_000002020220); ans_temp[ans_id*36+11]+=Pmtrx[9]*(P_011011000*QR_001000021000+P_011111000*QR_001000021010+P_011211000*QR_001000021020+P_111011000*QR_001000021100+P_111111000*QR_001000021110+P_111211000*QR_001000021120+P_211011000*QR_001000021200+P_211111000*QR_001000021210+P_211211000*QR_001000021220); ans_temp[ans_id*36+11]+=Pmtrx[10]*(P_011011000*QR_000001021000+P_011111000*QR_000001021010+P_011211000*QR_000001021020+P_111011000*QR_000001021100+P_111111000*QR_000001021110+P_111211000*QR_000001021120+P_211011000*QR_000001021200+P_211111000*QR_000001021210+P_211211000*QR_000001021220); ans_temp[ans_id*36+11]+=Pmtrx[11]*(P_011011000*QR_000000022000+P_011111000*QR_000000022010+P_011211000*QR_000000022020+P_111011000*QR_000000022100+P_111111000*QR_000000022110+P_111211000*QR_000000022120+P_211011000*QR_000000022200+P_211111000*QR_000000022210+P_211211000*QR_000000022220); ans_temp[ans_id*36+6]+=Pmtrx[12]*(P_010012000*QR_022000000000+P_010112000*QR_022000000010+P_010212000*QR_022000000020+P_010312000*QR_022000000030+P_110012000*QR_022000000100+P_110112000*QR_022000000110+P_110212000*QR_022000000120+P_110312000*QR_022000000130); ans_temp[ans_id*36+6]+=Pmtrx[13]*(P_010012000*QR_021001000000+P_010112000*QR_021001000010+P_010212000*QR_021001000020+P_010312000*QR_021001000030+P_110012000*QR_021001000100+P_110112000*QR_021001000110+P_110212000*QR_021001000120+P_110312000*QR_021001000130); ans_temp[ans_id*36+6]+=Pmtrx[14]*(P_010012000*QR_020002000000+P_010112000*QR_020002000010+P_010212000*QR_020002000020+P_010312000*QR_020002000030+P_110012000*QR_020002000100+P_110112000*QR_020002000110+P_110212000*QR_020002000120+P_110312000*QR_020002000130); ans_temp[ans_id*36+6]+=Pmtrx[15]*(P_010012000*QR_021000001000+P_010112000*QR_021000001010+P_010212000*QR_021000001020+P_010312000*QR_021000001030+P_110012000*QR_021000001100+P_110112000*QR_021000001110+P_110212000*QR_021000001120+P_110312000*QR_021000001130); ans_temp[ans_id*36+6]+=Pmtrx[16]*(P_010012000*QR_020001001000+P_010112000*QR_020001001010+P_010212000*QR_020001001020+P_010312000*QR_020001001030+P_110012000*QR_020001001100+P_110112000*QR_020001001110+P_110212000*QR_020001001120+P_110312000*QR_020001001130); ans_temp[ans_id*36+6]+=Pmtrx[17]*(P_010012000*QR_020000002000+P_010112000*QR_020000002010+P_010212000*QR_020000002020+P_010312000*QR_020000002030+P_110012000*QR_020000002100+P_110112000*QR_020000002110+P_110212000*QR_020000002120+P_110312000*QR_020000002130); ans_temp[ans_id*36+7]+=Pmtrx[12]*(P_010012000*QR_012010000000+P_010112000*QR_012010000010+P_010212000*QR_012010000020+P_010312000*QR_012010000030+P_110012000*QR_012010000100+P_110112000*QR_012010000110+P_110212000*QR_012010000120+P_110312000*QR_012010000130); ans_temp[ans_id*36+7]+=Pmtrx[13]*(P_010012000*QR_011011000000+P_010112000*QR_011011000010+P_010212000*QR_011011000020+P_010312000*QR_011011000030+P_110012000*QR_011011000100+P_110112000*QR_011011000110+P_110212000*QR_011011000120+P_110312000*QR_011011000130); ans_temp[ans_id*36+7]+=Pmtrx[14]*(P_010012000*QR_010012000000+P_010112000*QR_010012000010+P_010212000*QR_010012000020+P_010312000*QR_010012000030+P_110012000*QR_010012000100+P_110112000*QR_010012000110+P_110212000*QR_010012000120+P_110312000*QR_010012000130); ans_temp[ans_id*36+7]+=Pmtrx[15]*(P_010012000*QR_011010001000+P_010112000*QR_011010001010+P_010212000*QR_011010001020+P_010312000*QR_011010001030+P_110012000*QR_011010001100+P_110112000*QR_011010001110+P_110212000*QR_011010001120+P_110312000*QR_011010001130); ans_temp[ans_id*36+7]+=Pmtrx[16]*(P_010012000*QR_010011001000+P_010112000*QR_010011001010+P_010212000*QR_010011001020+P_010312000*QR_010011001030+P_110012000*QR_010011001100+P_110112000*QR_010011001110+P_110212000*QR_010011001120+P_110312000*QR_010011001130); ans_temp[ans_id*36+7]+=Pmtrx[17]*(P_010012000*QR_010010002000+P_010112000*QR_010010002010+P_010212000*QR_010010002020+P_010312000*QR_010010002030+P_110012000*QR_010010002100+P_110112000*QR_010010002110+P_110212000*QR_010010002120+P_110312000*QR_010010002130); ans_temp[ans_id*36+8]+=Pmtrx[12]*(P_010012000*QR_002020000000+P_010112000*QR_002020000010+P_010212000*QR_002020000020+P_010312000*QR_002020000030+P_110012000*QR_002020000100+P_110112000*QR_002020000110+P_110212000*QR_002020000120+P_110312000*QR_002020000130); ans_temp[ans_id*36+8]+=Pmtrx[13]*(P_010012000*QR_001021000000+P_010112000*QR_001021000010+P_010212000*QR_001021000020+P_010312000*QR_001021000030+P_110012000*QR_001021000100+P_110112000*QR_001021000110+P_110212000*QR_001021000120+P_110312000*QR_001021000130); ans_temp[ans_id*36+8]+=Pmtrx[14]*(P_010012000*QR_000022000000+P_010112000*QR_000022000010+P_010212000*QR_000022000020+P_010312000*QR_000022000030+P_110012000*QR_000022000100+P_110112000*QR_000022000110+P_110212000*QR_000022000120+P_110312000*QR_000022000130); ans_temp[ans_id*36+8]+=Pmtrx[15]*(P_010012000*QR_001020001000+P_010112000*QR_001020001010+P_010212000*QR_001020001020+P_010312000*QR_001020001030+P_110012000*QR_001020001100+P_110112000*QR_001020001110+P_110212000*QR_001020001120+P_110312000*QR_001020001130); ans_temp[ans_id*36+8]+=Pmtrx[16]*(P_010012000*QR_000021001000+P_010112000*QR_000021001010+P_010212000*QR_000021001020+P_010312000*QR_000021001030+P_110012000*QR_000021001100+P_110112000*QR_000021001110+P_110212000*QR_000021001120+P_110312000*QR_000021001130); ans_temp[ans_id*36+8]+=Pmtrx[17]*(P_010012000*QR_000020002000+P_010112000*QR_000020002010+P_010212000*QR_000020002020+P_010312000*QR_000020002030+P_110012000*QR_000020002100+P_110112000*QR_000020002110+P_110212000*QR_000020002120+P_110312000*QR_000020002130); ans_temp[ans_id*36+9]+=Pmtrx[12]*(P_010012000*QR_012000010000+P_010112000*QR_012000010010+P_010212000*QR_012000010020+P_010312000*QR_012000010030+P_110012000*QR_012000010100+P_110112000*QR_012000010110+P_110212000*QR_012000010120+P_110312000*QR_012000010130); ans_temp[ans_id*36+9]+=Pmtrx[13]*(P_010012000*QR_011001010000+P_010112000*QR_011001010010+P_010212000*QR_011001010020+P_010312000*QR_011001010030+P_110012000*QR_011001010100+P_110112000*QR_011001010110+P_110212000*QR_011001010120+P_110312000*QR_011001010130); ans_temp[ans_id*36+9]+=Pmtrx[14]*(P_010012000*QR_010002010000+P_010112000*QR_010002010010+P_010212000*QR_010002010020+P_010312000*QR_010002010030+P_110012000*QR_010002010100+P_110112000*QR_010002010110+P_110212000*QR_010002010120+P_110312000*QR_010002010130); ans_temp[ans_id*36+9]+=Pmtrx[15]*(P_010012000*QR_011000011000+P_010112000*QR_011000011010+P_010212000*QR_011000011020+P_010312000*QR_011000011030+P_110012000*QR_011000011100+P_110112000*QR_011000011110+P_110212000*QR_011000011120+P_110312000*QR_011000011130); ans_temp[ans_id*36+9]+=Pmtrx[16]*(P_010012000*QR_010001011000+P_010112000*QR_010001011010+P_010212000*QR_010001011020+P_010312000*QR_010001011030+P_110012000*QR_010001011100+P_110112000*QR_010001011110+P_110212000*QR_010001011120+P_110312000*QR_010001011130); ans_temp[ans_id*36+9]+=Pmtrx[17]*(P_010012000*QR_010000012000+P_010112000*QR_010000012010+P_010212000*QR_010000012020+P_010312000*QR_010000012030+P_110012000*QR_010000012100+P_110112000*QR_010000012110+P_110212000*QR_010000012120+P_110312000*QR_010000012130); ans_temp[ans_id*36+10]+=Pmtrx[12]*(P_010012000*QR_002010010000+P_010112000*QR_002010010010+P_010212000*QR_002010010020+P_010312000*QR_002010010030+P_110012000*QR_002010010100+P_110112000*QR_002010010110+P_110212000*QR_002010010120+P_110312000*QR_002010010130); ans_temp[ans_id*36+10]+=Pmtrx[13]*(P_010012000*QR_001011010000+P_010112000*QR_001011010010+P_010212000*QR_001011010020+P_010312000*QR_001011010030+P_110012000*QR_001011010100+P_110112000*QR_001011010110+P_110212000*QR_001011010120+P_110312000*QR_001011010130); ans_temp[ans_id*36+10]+=Pmtrx[14]*(P_010012000*QR_000012010000+P_010112000*QR_000012010010+P_010212000*QR_000012010020+P_010312000*QR_000012010030+P_110012000*QR_000012010100+P_110112000*QR_000012010110+P_110212000*QR_000012010120+P_110312000*QR_000012010130); ans_temp[ans_id*36+10]+=Pmtrx[15]*(P_010012000*QR_001010011000+P_010112000*QR_001010011010+P_010212000*QR_001010011020+P_010312000*QR_001010011030+P_110012000*QR_001010011100+P_110112000*QR_001010011110+P_110212000*QR_001010011120+P_110312000*QR_001010011130); ans_temp[ans_id*36+10]+=Pmtrx[16]*(P_010012000*QR_000011011000+P_010112000*QR_000011011010+P_010212000*QR_000011011020+P_010312000*QR_000011011030+P_110012000*QR_000011011100+P_110112000*QR_000011011110+P_110212000*QR_000011011120+P_110312000*QR_000011011130); ans_temp[ans_id*36+10]+=Pmtrx[17]*(P_010012000*QR_000010012000+P_010112000*QR_000010012010+P_010212000*QR_000010012020+P_010312000*QR_000010012030+P_110012000*QR_000010012100+P_110112000*QR_000010012110+P_110212000*QR_000010012120+P_110312000*QR_000010012130); ans_temp[ans_id*36+11]+=Pmtrx[12]*(P_010012000*QR_002000020000+P_010112000*QR_002000020010+P_010212000*QR_002000020020+P_010312000*QR_002000020030+P_110012000*QR_002000020100+P_110112000*QR_002000020110+P_110212000*QR_002000020120+P_110312000*QR_002000020130); ans_temp[ans_id*36+11]+=Pmtrx[13]*(P_010012000*QR_001001020000+P_010112000*QR_001001020010+P_010212000*QR_001001020020+P_010312000*QR_001001020030+P_110012000*QR_001001020100+P_110112000*QR_001001020110+P_110212000*QR_001001020120+P_110312000*QR_001001020130); ans_temp[ans_id*36+11]+=Pmtrx[14]*(P_010012000*QR_000002020000+P_010112000*QR_000002020010+P_010212000*QR_000002020020+P_010312000*QR_000002020030+P_110012000*QR_000002020100+P_110112000*QR_000002020110+P_110212000*QR_000002020120+P_110312000*QR_000002020130); ans_temp[ans_id*36+11]+=Pmtrx[15]*(P_010012000*QR_001000021000+P_010112000*QR_001000021010+P_010212000*QR_001000021020+P_010312000*QR_001000021030+P_110012000*QR_001000021100+P_110112000*QR_001000021110+P_110212000*QR_001000021120+P_110312000*QR_001000021130); ans_temp[ans_id*36+11]+=Pmtrx[16]*(P_010012000*QR_000001021000+P_010112000*QR_000001021010+P_010212000*QR_000001021020+P_010312000*QR_000001021030+P_110012000*QR_000001021100+P_110112000*QR_000001021110+P_110212000*QR_000001021120+P_110312000*QR_000001021130); ans_temp[ans_id*36+11]+=Pmtrx[17]*(P_010012000*QR_000000022000+P_010112000*QR_000000022010+P_010212000*QR_000000022020+P_010312000*QR_000000022030+P_110012000*QR_000000022100+P_110112000*QR_000000022110+P_110212000*QR_000000022120+P_110312000*QR_000000022130); ans_temp[ans_id*36+6]+=Pmtrx[18]*(P_011010001*QR_022000000000+P_011010101*QR_022000000001+P_011110001*QR_022000000010+P_011110101*QR_022000000011+P_111010001*QR_022000000100+P_111010101*QR_022000000101+P_111110001*QR_022000000110+P_111110101*QR_022000000111+P_211010001*QR_022000000200+P_211010101*QR_022000000201+P_211110001*QR_022000000210+P_211110101*QR_022000000211); ans_temp[ans_id*36+6]+=Pmtrx[19]*(P_011010001*QR_021001000000+P_011010101*QR_021001000001+P_011110001*QR_021001000010+P_011110101*QR_021001000011+P_111010001*QR_021001000100+P_111010101*QR_021001000101+P_111110001*QR_021001000110+P_111110101*QR_021001000111+P_211010001*QR_021001000200+P_211010101*QR_021001000201+P_211110001*QR_021001000210+P_211110101*QR_021001000211); ans_temp[ans_id*36+6]+=Pmtrx[20]*(P_011010001*QR_020002000000+P_011010101*QR_020002000001+P_011110001*QR_020002000010+P_011110101*QR_020002000011+P_111010001*QR_020002000100+P_111010101*QR_020002000101+P_111110001*QR_020002000110+P_111110101*QR_020002000111+P_211010001*QR_020002000200+P_211010101*QR_020002000201+P_211110001*QR_020002000210+P_211110101*QR_020002000211); ans_temp[ans_id*36+6]+=Pmtrx[21]*(P_011010001*QR_021000001000+P_011010101*QR_021000001001+P_011110001*QR_021000001010+P_011110101*QR_021000001011+P_111010001*QR_021000001100+P_111010101*QR_021000001101+P_111110001*QR_021000001110+P_111110101*QR_021000001111+P_211010001*QR_021000001200+P_211010101*QR_021000001201+P_211110001*QR_021000001210+P_211110101*QR_021000001211); ans_temp[ans_id*36+6]+=Pmtrx[22]*(P_011010001*QR_020001001000+P_011010101*QR_020001001001+P_011110001*QR_020001001010+P_011110101*QR_020001001011+P_111010001*QR_020001001100+P_111010101*QR_020001001101+P_111110001*QR_020001001110+P_111110101*QR_020001001111+P_211010001*QR_020001001200+P_211010101*QR_020001001201+P_211110001*QR_020001001210+P_211110101*QR_020001001211); ans_temp[ans_id*36+6]+=Pmtrx[23]*(P_011010001*QR_020000002000+P_011010101*QR_020000002001+P_011110001*QR_020000002010+P_011110101*QR_020000002011+P_111010001*QR_020000002100+P_111010101*QR_020000002101+P_111110001*QR_020000002110+P_111110101*QR_020000002111+P_211010001*QR_020000002200+P_211010101*QR_020000002201+P_211110001*QR_020000002210+P_211110101*QR_020000002211); ans_temp[ans_id*36+7]+=Pmtrx[18]*(P_011010001*QR_012010000000+P_011010101*QR_012010000001+P_011110001*QR_012010000010+P_011110101*QR_012010000011+P_111010001*QR_012010000100+P_111010101*QR_012010000101+P_111110001*QR_012010000110+P_111110101*QR_012010000111+P_211010001*QR_012010000200+P_211010101*QR_012010000201+P_211110001*QR_012010000210+P_211110101*QR_012010000211); ans_temp[ans_id*36+7]+=Pmtrx[19]*(P_011010001*QR_011011000000+P_011010101*QR_011011000001+P_011110001*QR_011011000010+P_011110101*QR_011011000011+P_111010001*QR_011011000100+P_111010101*QR_011011000101+P_111110001*QR_011011000110+P_111110101*QR_011011000111+P_211010001*QR_011011000200+P_211010101*QR_011011000201+P_211110001*QR_011011000210+P_211110101*QR_011011000211); ans_temp[ans_id*36+7]+=Pmtrx[20]*(P_011010001*QR_010012000000+P_011010101*QR_010012000001+P_011110001*QR_010012000010+P_011110101*QR_010012000011+P_111010001*QR_010012000100+P_111010101*QR_010012000101+P_111110001*QR_010012000110+P_111110101*QR_010012000111+P_211010001*QR_010012000200+P_211010101*QR_010012000201+P_211110001*QR_010012000210+P_211110101*QR_010012000211); ans_temp[ans_id*36+7]+=Pmtrx[21]*(P_011010001*QR_011010001000+P_011010101*QR_011010001001+P_011110001*QR_011010001010+P_011110101*QR_011010001011+P_111010001*QR_011010001100+P_111010101*QR_011010001101+P_111110001*QR_011010001110+P_111110101*QR_011010001111+P_211010001*QR_011010001200+P_211010101*QR_011010001201+P_211110001*QR_011010001210+P_211110101*QR_011010001211); ans_temp[ans_id*36+7]+=Pmtrx[22]*(P_011010001*QR_010011001000+P_011010101*QR_010011001001+P_011110001*QR_010011001010+P_011110101*QR_010011001011+P_111010001*QR_010011001100+P_111010101*QR_010011001101+P_111110001*QR_010011001110+P_111110101*QR_010011001111+P_211010001*QR_010011001200+P_211010101*QR_010011001201+P_211110001*QR_010011001210+P_211110101*QR_010011001211); ans_temp[ans_id*36+7]+=Pmtrx[23]*(P_011010001*QR_010010002000+P_011010101*QR_010010002001+P_011110001*QR_010010002010+P_011110101*QR_010010002011+P_111010001*QR_010010002100+P_111010101*QR_010010002101+P_111110001*QR_010010002110+P_111110101*QR_010010002111+P_211010001*QR_010010002200+P_211010101*QR_010010002201+P_211110001*QR_010010002210+P_211110101*QR_010010002211); ans_temp[ans_id*36+8]+=Pmtrx[18]*(P_011010001*QR_002020000000+P_011010101*QR_002020000001+P_011110001*QR_002020000010+P_011110101*QR_002020000011+P_111010001*QR_002020000100+P_111010101*QR_002020000101+P_111110001*QR_002020000110+P_111110101*QR_002020000111+P_211010001*QR_002020000200+P_211010101*QR_002020000201+P_211110001*QR_002020000210+P_211110101*QR_002020000211); ans_temp[ans_id*36+8]+=Pmtrx[19]*(P_011010001*QR_001021000000+P_011010101*QR_001021000001+P_011110001*QR_001021000010+P_011110101*QR_001021000011+P_111010001*QR_001021000100+P_111010101*QR_001021000101+P_111110001*QR_001021000110+P_111110101*QR_001021000111+P_211010001*QR_001021000200+P_211010101*QR_001021000201+P_211110001*QR_001021000210+P_211110101*QR_001021000211); ans_temp[ans_id*36+8]+=Pmtrx[20]*(P_011010001*QR_000022000000+P_011010101*QR_000022000001+P_011110001*QR_000022000010+P_011110101*QR_000022000011+P_111010001*QR_000022000100+P_111010101*QR_000022000101+P_111110001*QR_000022000110+P_111110101*QR_000022000111+P_211010001*QR_000022000200+P_211010101*QR_000022000201+P_211110001*QR_000022000210+P_211110101*QR_000022000211); ans_temp[ans_id*36+8]+=Pmtrx[21]*(P_011010001*QR_001020001000+P_011010101*QR_001020001001+P_011110001*QR_001020001010+P_011110101*QR_001020001011+P_111010001*QR_001020001100+P_111010101*QR_001020001101+P_111110001*QR_001020001110+P_111110101*QR_001020001111+P_211010001*QR_001020001200+P_211010101*QR_001020001201+P_211110001*QR_001020001210+P_211110101*QR_001020001211); ans_temp[ans_id*36+8]+=Pmtrx[22]*(P_011010001*QR_000021001000+P_011010101*QR_000021001001+P_011110001*QR_000021001010+P_011110101*QR_000021001011+P_111010001*QR_000021001100+P_111010101*QR_000021001101+P_111110001*QR_000021001110+P_111110101*QR_000021001111+P_211010001*QR_000021001200+P_211010101*QR_000021001201+P_211110001*QR_000021001210+P_211110101*QR_000021001211); ans_temp[ans_id*36+8]+=Pmtrx[23]*(P_011010001*QR_000020002000+P_011010101*QR_000020002001+P_011110001*QR_000020002010+P_011110101*QR_000020002011+P_111010001*QR_000020002100+P_111010101*QR_000020002101+P_111110001*QR_000020002110+P_111110101*QR_000020002111+P_211010001*QR_000020002200+P_211010101*QR_000020002201+P_211110001*QR_000020002210+P_211110101*QR_000020002211); ans_temp[ans_id*36+9]+=Pmtrx[18]*(P_011010001*QR_012000010000+P_011010101*QR_012000010001+P_011110001*QR_012000010010+P_011110101*QR_012000010011+P_111010001*QR_012000010100+P_111010101*QR_012000010101+P_111110001*QR_012000010110+P_111110101*QR_012000010111+P_211010001*QR_012000010200+P_211010101*QR_012000010201+P_211110001*QR_012000010210+P_211110101*QR_012000010211); ans_temp[ans_id*36+9]+=Pmtrx[19]*(P_011010001*QR_011001010000+P_011010101*QR_011001010001+P_011110001*QR_011001010010+P_011110101*QR_011001010011+P_111010001*QR_011001010100+P_111010101*QR_011001010101+P_111110001*QR_011001010110+P_111110101*QR_011001010111+P_211010001*QR_011001010200+P_211010101*QR_011001010201+P_211110001*QR_011001010210+P_211110101*QR_011001010211); ans_temp[ans_id*36+9]+=Pmtrx[20]*(P_011010001*QR_010002010000+P_011010101*QR_010002010001+P_011110001*QR_010002010010+P_011110101*QR_010002010011+P_111010001*QR_010002010100+P_111010101*QR_010002010101+P_111110001*QR_010002010110+P_111110101*QR_010002010111+P_211010001*QR_010002010200+P_211010101*QR_010002010201+P_211110001*QR_010002010210+P_211110101*QR_010002010211); ans_temp[ans_id*36+9]+=Pmtrx[21]*(P_011010001*QR_011000011000+P_011010101*QR_011000011001+P_011110001*QR_011000011010+P_011110101*QR_011000011011+P_111010001*QR_011000011100+P_111010101*QR_011000011101+P_111110001*QR_011000011110+P_111110101*QR_011000011111+P_211010001*QR_011000011200+P_211010101*QR_011000011201+P_211110001*QR_011000011210+P_211110101*QR_011000011211); ans_temp[ans_id*36+9]+=Pmtrx[22]*(P_011010001*QR_010001011000+P_011010101*QR_010001011001+P_011110001*QR_010001011010+P_011110101*QR_010001011011+P_111010001*QR_010001011100+P_111010101*QR_010001011101+P_111110001*QR_010001011110+P_111110101*QR_010001011111+P_211010001*QR_010001011200+P_211010101*QR_010001011201+P_211110001*QR_010001011210+P_211110101*QR_010001011211); ans_temp[ans_id*36+9]+=Pmtrx[23]*(P_011010001*QR_010000012000+P_011010101*QR_010000012001+P_011110001*QR_010000012010+P_011110101*QR_010000012011+P_111010001*QR_010000012100+P_111010101*QR_010000012101+P_111110001*QR_010000012110+P_111110101*QR_010000012111+P_211010001*QR_010000012200+P_211010101*QR_010000012201+P_211110001*QR_010000012210+P_211110101*QR_010000012211); ans_temp[ans_id*36+10]+=Pmtrx[18]*(P_011010001*QR_002010010000+P_011010101*QR_002010010001+P_011110001*QR_002010010010+P_011110101*QR_002010010011+P_111010001*QR_002010010100+P_111010101*QR_002010010101+P_111110001*QR_002010010110+P_111110101*QR_002010010111+P_211010001*QR_002010010200+P_211010101*QR_002010010201+P_211110001*QR_002010010210+P_211110101*QR_002010010211); ans_temp[ans_id*36+10]+=Pmtrx[19]*(P_011010001*QR_001011010000+P_011010101*QR_001011010001+P_011110001*QR_001011010010+P_011110101*QR_001011010011+P_111010001*QR_001011010100+P_111010101*QR_001011010101+P_111110001*QR_001011010110+P_111110101*QR_001011010111+P_211010001*QR_001011010200+P_211010101*QR_001011010201+P_211110001*QR_001011010210+P_211110101*QR_001011010211); ans_temp[ans_id*36+10]+=Pmtrx[20]*(P_011010001*QR_000012010000+P_011010101*QR_000012010001+P_011110001*QR_000012010010+P_011110101*QR_000012010011+P_111010001*QR_000012010100+P_111010101*QR_000012010101+P_111110001*QR_000012010110+P_111110101*QR_000012010111+P_211010001*QR_000012010200+P_211010101*QR_000012010201+P_211110001*QR_000012010210+P_211110101*QR_000012010211); ans_temp[ans_id*36+10]+=Pmtrx[21]*(P_011010001*QR_001010011000+P_011010101*QR_001010011001+P_011110001*QR_001010011010+P_011110101*QR_001010011011+P_111010001*QR_001010011100+P_111010101*QR_001010011101+P_111110001*QR_001010011110+P_111110101*QR_001010011111+P_211010001*QR_001010011200+P_211010101*QR_001010011201+P_211110001*QR_001010011210+P_211110101*QR_001010011211); ans_temp[ans_id*36+10]+=Pmtrx[22]*(P_011010001*QR_000011011000+P_011010101*QR_000011011001+P_011110001*QR_000011011010+P_011110101*QR_000011011011+P_111010001*QR_000011011100+P_111010101*QR_000011011101+P_111110001*QR_000011011110+P_111110101*QR_000011011111+P_211010001*QR_000011011200+P_211010101*QR_000011011201+P_211110001*QR_000011011210+P_211110101*QR_000011011211); ans_temp[ans_id*36+10]+=Pmtrx[23]*(P_011010001*QR_000010012000+P_011010101*QR_000010012001+P_011110001*QR_000010012010+P_011110101*QR_000010012011+P_111010001*QR_000010012100+P_111010101*QR_000010012101+P_111110001*QR_000010012110+P_111110101*QR_000010012111+P_211010001*QR_000010012200+P_211010101*QR_000010012201+P_211110001*QR_000010012210+P_211110101*QR_000010012211); ans_temp[ans_id*36+11]+=Pmtrx[18]*(P_011010001*QR_002000020000+P_011010101*QR_002000020001+P_011110001*QR_002000020010+P_011110101*QR_002000020011+P_111010001*QR_002000020100+P_111010101*QR_002000020101+P_111110001*QR_002000020110+P_111110101*QR_002000020111+P_211010001*QR_002000020200+P_211010101*QR_002000020201+P_211110001*QR_002000020210+P_211110101*QR_002000020211); ans_temp[ans_id*36+11]+=Pmtrx[19]*(P_011010001*QR_001001020000+P_011010101*QR_001001020001+P_011110001*QR_001001020010+P_011110101*QR_001001020011+P_111010001*QR_001001020100+P_111010101*QR_001001020101+P_111110001*QR_001001020110+P_111110101*QR_001001020111+P_211010001*QR_001001020200+P_211010101*QR_001001020201+P_211110001*QR_001001020210+P_211110101*QR_001001020211); ans_temp[ans_id*36+11]+=Pmtrx[20]*(P_011010001*QR_000002020000+P_011010101*QR_000002020001+P_011110001*QR_000002020010+P_011110101*QR_000002020011+P_111010001*QR_000002020100+P_111010101*QR_000002020101+P_111110001*QR_000002020110+P_111110101*QR_000002020111+P_211010001*QR_000002020200+P_211010101*QR_000002020201+P_211110001*QR_000002020210+P_211110101*QR_000002020211); ans_temp[ans_id*36+11]+=Pmtrx[21]*(P_011010001*QR_001000021000+P_011010101*QR_001000021001+P_011110001*QR_001000021010+P_011110101*QR_001000021011+P_111010001*QR_001000021100+P_111010101*QR_001000021101+P_111110001*QR_001000021110+P_111110101*QR_001000021111+P_211010001*QR_001000021200+P_211010101*QR_001000021201+P_211110001*QR_001000021210+P_211110101*QR_001000021211); ans_temp[ans_id*36+11]+=Pmtrx[22]*(P_011010001*QR_000001021000+P_011010101*QR_000001021001+P_011110001*QR_000001021010+P_011110101*QR_000001021011+P_111010001*QR_000001021100+P_111010101*QR_000001021101+P_111110001*QR_000001021110+P_111110101*QR_000001021111+P_211010001*QR_000001021200+P_211010101*QR_000001021201+P_211110001*QR_000001021210+P_211110101*QR_000001021211); ans_temp[ans_id*36+11]+=Pmtrx[23]*(P_011010001*QR_000000022000+P_011010101*QR_000000022001+P_011110001*QR_000000022010+P_011110101*QR_000000022011+P_111010001*QR_000000022100+P_111010101*QR_000000022101+P_111110001*QR_000000022110+P_111110101*QR_000000022111+P_211010001*QR_000000022200+P_211010101*QR_000000022201+P_211110001*QR_000000022210+P_211110101*QR_000000022211); ans_temp[ans_id*36+6]+=Pmtrx[24]*(P_010011001*QR_022000000000+P_010011101*QR_022000000001+P_010111001*QR_022000000010+P_010111101*QR_022000000011+P_010211001*QR_022000000020+P_010211101*QR_022000000021+P_110011001*QR_022000000100+P_110011101*QR_022000000101+P_110111001*QR_022000000110+P_110111101*QR_022000000111+P_110211001*QR_022000000120+P_110211101*QR_022000000121); ans_temp[ans_id*36+6]+=Pmtrx[25]*(P_010011001*QR_021001000000+P_010011101*QR_021001000001+P_010111001*QR_021001000010+P_010111101*QR_021001000011+P_010211001*QR_021001000020+P_010211101*QR_021001000021+P_110011001*QR_021001000100+P_110011101*QR_021001000101+P_110111001*QR_021001000110+P_110111101*QR_021001000111+P_110211001*QR_021001000120+P_110211101*QR_021001000121); ans_temp[ans_id*36+6]+=Pmtrx[26]*(P_010011001*QR_020002000000+P_010011101*QR_020002000001+P_010111001*QR_020002000010+P_010111101*QR_020002000011+P_010211001*QR_020002000020+P_010211101*QR_020002000021+P_110011001*QR_020002000100+P_110011101*QR_020002000101+P_110111001*QR_020002000110+P_110111101*QR_020002000111+P_110211001*QR_020002000120+P_110211101*QR_020002000121); ans_temp[ans_id*36+6]+=Pmtrx[27]*(P_010011001*QR_021000001000+P_010011101*QR_021000001001+P_010111001*QR_021000001010+P_010111101*QR_021000001011+P_010211001*QR_021000001020+P_010211101*QR_021000001021+P_110011001*QR_021000001100+P_110011101*QR_021000001101+P_110111001*QR_021000001110+P_110111101*QR_021000001111+P_110211001*QR_021000001120+P_110211101*QR_021000001121); ans_temp[ans_id*36+6]+=Pmtrx[28]*(P_010011001*QR_020001001000+P_010011101*QR_020001001001+P_010111001*QR_020001001010+P_010111101*QR_020001001011+P_010211001*QR_020001001020+P_010211101*QR_020001001021+P_110011001*QR_020001001100+P_110011101*QR_020001001101+P_110111001*QR_020001001110+P_110111101*QR_020001001111+P_110211001*QR_020001001120+P_110211101*QR_020001001121); ans_temp[ans_id*36+6]+=Pmtrx[29]*(P_010011001*QR_020000002000+P_010011101*QR_020000002001+P_010111001*QR_020000002010+P_010111101*QR_020000002011+P_010211001*QR_020000002020+P_010211101*QR_020000002021+P_110011001*QR_020000002100+P_110011101*QR_020000002101+P_110111001*QR_020000002110+P_110111101*QR_020000002111+P_110211001*QR_020000002120+P_110211101*QR_020000002121); ans_temp[ans_id*36+7]+=Pmtrx[24]*(P_010011001*QR_012010000000+P_010011101*QR_012010000001+P_010111001*QR_012010000010+P_010111101*QR_012010000011+P_010211001*QR_012010000020+P_010211101*QR_012010000021+P_110011001*QR_012010000100+P_110011101*QR_012010000101+P_110111001*QR_012010000110+P_110111101*QR_012010000111+P_110211001*QR_012010000120+P_110211101*QR_012010000121); ans_temp[ans_id*36+7]+=Pmtrx[25]*(P_010011001*QR_011011000000+P_010011101*QR_011011000001+P_010111001*QR_011011000010+P_010111101*QR_011011000011+P_010211001*QR_011011000020+P_010211101*QR_011011000021+P_110011001*QR_011011000100+P_110011101*QR_011011000101+P_110111001*QR_011011000110+P_110111101*QR_011011000111+P_110211001*QR_011011000120+P_110211101*QR_011011000121); ans_temp[ans_id*36+7]+=Pmtrx[26]*(P_010011001*QR_010012000000+P_010011101*QR_010012000001+P_010111001*QR_010012000010+P_010111101*QR_010012000011+P_010211001*QR_010012000020+P_010211101*QR_010012000021+P_110011001*QR_010012000100+P_110011101*QR_010012000101+P_110111001*QR_010012000110+P_110111101*QR_010012000111+P_110211001*QR_010012000120+P_110211101*QR_010012000121); ans_temp[ans_id*36+7]+=Pmtrx[27]*(P_010011001*QR_011010001000+P_010011101*QR_011010001001+P_010111001*QR_011010001010+P_010111101*QR_011010001011+P_010211001*QR_011010001020+P_010211101*QR_011010001021+P_110011001*QR_011010001100+P_110011101*QR_011010001101+P_110111001*QR_011010001110+P_110111101*QR_011010001111+P_110211001*QR_011010001120+P_110211101*QR_011010001121); ans_temp[ans_id*36+7]+=Pmtrx[28]*(P_010011001*QR_010011001000+P_010011101*QR_010011001001+P_010111001*QR_010011001010+P_010111101*QR_010011001011+P_010211001*QR_010011001020+P_010211101*QR_010011001021+P_110011001*QR_010011001100+P_110011101*QR_010011001101+P_110111001*QR_010011001110+P_110111101*QR_010011001111+P_110211001*QR_010011001120+P_110211101*QR_010011001121); ans_temp[ans_id*36+7]+=Pmtrx[29]*(P_010011001*QR_010010002000+P_010011101*QR_010010002001+P_010111001*QR_010010002010+P_010111101*QR_010010002011+P_010211001*QR_010010002020+P_010211101*QR_010010002021+P_110011001*QR_010010002100+P_110011101*QR_010010002101+P_110111001*QR_010010002110+P_110111101*QR_010010002111+P_110211001*QR_010010002120+P_110211101*QR_010010002121); ans_temp[ans_id*36+8]+=Pmtrx[24]*(P_010011001*QR_002020000000+P_010011101*QR_002020000001+P_010111001*QR_002020000010+P_010111101*QR_002020000011+P_010211001*QR_002020000020+P_010211101*QR_002020000021+P_110011001*QR_002020000100+P_110011101*QR_002020000101+P_110111001*QR_002020000110+P_110111101*QR_002020000111+P_110211001*QR_002020000120+P_110211101*QR_002020000121); ans_temp[ans_id*36+8]+=Pmtrx[25]*(P_010011001*QR_001021000000+P_010011101*QR_001021000001+P_010111001*QR_001021000010+P_010111101*QR_001021000011+P_010211001*QR_001021000020+P_010211101*QR_001021000021+P_110011001*QR_001021000100+P_110011101*QR_001021000101+P_110111001*QR_001021000110+P_110111101*QR_001021000111+P_110211001*QR_001021000120+P_110211101*QR_001021000121); ans_temp[ans_id*36+8]+=Pmtrx[26]*(P_010011001*QR_000022000000+P_010011101*QR_000022000001+P_010111001*QR_000022000010+P_010111101*QR_000022000011+P_010211001*QR_000022000020+P_010211101*QR_000022000021+P_110011001*QR_000022000100+P_110011101*QR_000022000101+P_110111001*QR_000022000110+P_110111101*QR_000022000111+P_110211001*QR_000022000120+P_110211101*QR_000022000121); ans_temp[ans_id*36+8]+=Pmtrx[27]*(P_010011001*QR_001020001000+P_010011101*QR_001020001001+P_010111001*QR_001020001010+P_010111101*QR_001020001011+P_010211001*QR_001020001020+P_010211101*QR_001020001021+P_110011001*QR_001020001100+P_110011101*QR_001020001101+P_110111001*QR_001020001110+P_110111101*QR_001020001111+P_110211001*QR_001020001120+P_110211101*QR_001020001121); ans_temp[ans_id*36+8]+=Pmtrx[28]*(P_010011001*QR_000021001000+P_010011101*QR_000021001001+P_010111001*QR_000021001010+P_010111101*QR_000021001011+P_010211001*QR_000021001020+P_010211101*QR_000021001021+P_110011001*QR_000021001100+P_110011101*QR_000021001101+P_110111001*QR_000021001110+P_110111101*QR_000021001111+P_110211001*QR_000021001120+P_110211101*QR_000021001121); ans_temp[ans_id*36+8]+=Pmtrx[29]*(P_010011001*QR_000020002000+P_010011101*QR_000020002001+P_010111001*QR_000020002010+P_010111101*QR_000020002011+P_010211001*QR_000020002020+P_010211101*QR_000020002021+P_110011001*QR_000020002100+P_110011101*QR_000020002101+P_110111001*QR_000020002110+P_110111101*QR_000020002111+P_110211001*QR_000020002120+P_110211101*QR_000020002121); ans_temp[ans_id*36+9]+=Pmtrx[24]*(P_010011001*QR_012000010000+P_010011101*QR_012000010001+P_010111001*QR_012000010010+P_010111101*QR_012000010011+P_010211001*QR_012000010020+P_010211101*QR_012000010021+P_110011001*QR_012000010100+P_110011101*QR_012000010101+P_110111001*QR_012000010110+P_110111101*QR_012000010111+P_110211001*QR_012000010120+P_110211101*QR_012000010121); ans_temp[ans_id*36+9]+=Pmtrx[25]*(P_010011001*QR_011001010000+P_010011101*QR_011001010001+P_010111001*QR_011001010010+P_010111101*QR_011001010011+P_010211001*QR_011001010020+P_010211101*QR_011001010021+P_110011001*QR_011001010100+P_110011101*QR_011001010101+P_110111001*QR_011001010110+P_110111101*QR_011001010111+P_110211001*QR_011001010120+P_110211101*QR_011001010121); ans_temp[ans_id*36+9]+=Pmtrx[26]*(P_010011001*QR_010002010000+P_010011101*QR_010002010001+P_010111001*QR_010002010010+P_010111101*QR_010002010011+P_010211001*QR_010002010020+P_010211101*QR_010002010021+P_110011001*QR_010002010100+P_110011101*QR_010002010101+P_110111001*QR_010002010110+P_110111101*QR_010002010111+P_110211001*QR_010002010120+P_110211101*QR_010002010121); ans_temp[ans_id*36+9]+=Pmtrx[27]*(P_010011001*QR_011000011000+P_010011101*QR_011000011001+P_010111001*QR_011000011010+P_010111101*QR_011000011011+P_010211001*QR_011000011020+P_010211101*QR_011000011021+P_110011001*QR_011000011100+P_110011101*QR_011000011101+P_110111001*QR_011000011110+P_110111101*QR_011000011111+P_110211001*QR_011000011120+P_110211101*QR_011000011121); ans_temp[ans_id*36+9]+=Pmtrx[28]*(P_010011001*QR_010001011000+P_010011101*QR_010001011001+P_010111001*QR_010001011010+P_010111101*QR_010001011011+P_010211001*QR_010001011020+P_010211101*QR_010001011021+P_110011001*QR_010001011100+P_110011101*QR_010001011101+P_110111001*QR_010001011110+P_110111101*QR_010001011111+P_110211001*QR_010001011120+P_110211101*QR_010001011121); ans_temp[ans_id*36+9]+=Pmtrx[29]*(P_010011001*QR_010000012000+P_010011101*QR_010000012001+P_010111001*QR_010000012010+P_010111101*QR_010000012011+P_010211001*QR_010000012020+P_010211101*QR_010000012021+P_110011001*QR_010000012100+P_110011101*QR_010000012101+P_110111001*QR_010000012110+P_110111101*QR_010000012111+P_110211001*QR_010000012120+P_110211101*QR_010000012121); ans_temp[ans_id*36+10]+=Pmtrx[24]*(P_010011001*QR_002010010000+P_010011101*QR_002010010001+P_010111001*QR_002010010010+P_010111101*QR_002010010011+P_010211001*QR_002010010020+P_010211101*QR_002010010021+P_110011001*QR_002010010100+P_110011101*QR_002010010101+P_110111001*QR_002010010110+P_110111101*QR_002010010111+P_110211001*QR_002010010120+P_110211101*QR_002010010121); ans_temp[ans_id*36+10]+=Pmtrx[25]*(P_010011001*QR_001011010000+P_010011101*QR_001011010001+P_010111001*QR_001011010010+P_010111101*QR_001011010011+P_010211001*QR_001011010020+P_010211101*QR_001011010021+P_110011001*QR_001011010100+P_110011101*QR_001011010101+P_110111001*QR_001011010110+P_110111101*QR_001011010111+P_110211001*QR_001011010120+P_110211101*QR_001011010121); ans_temp[ans_id*36+10]+=Pmtrx[26]*(P_010011001*QR_000012010000+P_010011101*QR_000012010001+P_010111001*QR_000012010010+P_010111101*QR_000012010011+P_010211001*QR_000012010020+P_010211101*QR_000012010021+P_110011001*QR_000012010100+P_110011101*QR_000012010101+P_110111001*QR_000012010110+P_110111101*QR_000012010111+P_110211001*QR_000012010120+P_110211101*QR_000012010121); ans_temp[ans_id*36+10]+=Pmtrx[27]*(P_010011001*QR_001010011000+P_010011101*QR_001010011001+P_010111001*QR_001010011010+P_010111101*QR_001010011011+P_010211001*QR_001010011020+P_010211101*QR_001010011021+P_110011001*QR_001010011100+P_110011101*QR_001010011101+P_110111001*QR_001010011110+P_110111101*QR_001010011111+P_110211001*QR_001010011120+P_110211101*QR_001010011121); ans_temp[ans_id*36+10]+=Pmtrx[28]*(P_010011001*QR_000011011000+P_010011101*QR_000011011001+P_010111001*QR_000011011010+P_010111101*QR_000011011011+P_010211001*QR_000011011020+P_010211101*QR_000011011021+P_110011001*QR_000011011100+P_110011101*QR_000011011101+P_110111001*QR_000011011110+P_110111101*QR_000011011111+P_110211001*QR_000011011120+P_110211101*QR_000011011121); ans_temp[ans_id*36+10]+=Pmtrx[29]*(P_010011001*QR_000010012000+P_010011101*QR_000010012001+P_010111001*QR_000010012010+P_010111101*QR_000010012011+P_010211001*QR_000010012020+P_010211101*QR_000010012021+P_110011001*QR_000010012100+P_110011101*QR_000010012101+P_110111001*QR_000010012110+P_110111101*QR_000010012111+P_110211001*QR_000010012120+P_110211101*QR_000010012121); ans_temp[ans_id*36+11]+=Pmtrx[24]*(P_010011001*QR_002000020000+P_010011101*QR_002000020001+P_010111001*QR_002000020010+P_010111101*QR_002000020011+P_010211001*QR_002000020020+P_010211101*QR_002000020021+P_110011001*QR_002000020100+P_110011101*QR_002000020101+P_110111001*QR_002000020110+P_110111101*QR_002000020111+P_110211001*QR_002000020120+P_110211101*QR_002000020121); ans_temp[ans_id*36+11]+=Pmtrx[25]*(P_010011001*QR_001001020000+P_010011101*QR_001001020001+P_010111001*QR_001001020010+P_010111101*QR_001001020011+P_010211001*QR_001001020020+P_010211101*QR_001001020021+P_110011001*QR_001001020100+P_110011101*QR_001001020101+P_110111001*QR_001001020110+P_110111101*QR_001001020111+P_110211001*QR_001001020120+P_110211101*QR_001001020121); ans_temp[ans_id*36+11]+=Pmtrx[26]*(P_010011001*QR_000002020000+P_010011101*QR_000002020001+P_010111001*QR_000002020010+P_010111101*QR_000002020011+P_010211001*QR_000002020020+P_010211101*QR_000002020021+P_110011001*QR_000002020100+P_110011101*QR_000002020101+P_110111001*QR_000002020110+P_110111101*QR_000002020111+P_110211001*QR_000002020120+P_110211101*QR_000002020121); ans_temp[ans_id*36+11]+=Pmtrx[27]*(P_010011001*QR_001000021000+P_010011101*QR_001000021001+P_010111001*QR_001000021010+P_010111101*QR_001000021011+P_010211001*QR_001000021020+P_010211101*QR_001000021021+P_110011001*QR_001000021100+P_110011101*QR_001000021101+P_110111001*QR_001000021110+P_110111101*QR_001000021111+P_110211001*QR_001000021120+P_110211101*QR_001000021121); ans_temp[ans_id*36+11]+=Pmtrx[28]*(P_010011001*QR_000001021000+P_010011101*QR_000001021001+P_010111001*QR_000001021010+P_010111101*QR_000001021011+P_010211001*QR_000001021020+P_010211101*QR_000001021021+P_110011001*QR_000001021100+P_110011101*QR_000001021101+P_110111001*QR_000001021110+P_110111101*QR_000001021111+P_110211001*QR_000001021120+P_110211101*QR_000001021121); ans_temp[ans_id*36+11]+=Pmtrx[29]*(P_010011001*QR_000000022000+P_010011101*QR_000000022001+P_010111001*QR_000000022010+P_010111101*QR_000000022011+P_010211001*QR_000000022020+P_010211101*QR_000000022021+P_110011001*QR_000000022100+P_110011101*QR_000000022101+P_110111001*QR_000000022110+P_110111101*QR_000000022111+P_110211001*QR_000000022120+P_110211101*QR_000000022121); ans_temp[ans_id*36+6]+=Pmtrx[30]*(P_010010002*QR_022000000000+P_010010102*QR_022000000001+P_010010202*QR_022000000002+P_010110002*QR_022000000010+P_010110102*QR_022000000011+P_010110202*QR_022000000012+P_110010002*QR_022000000100+P_110010102*QR_022000000101+P_110010202*QR_022000000102+P_110110002*QR_022000000110+P_110110102*QR_022000000111+P_110110202*QR_022000000112); ans_temp[ans_id*36+6]+=Pmtrx[31]*(P_010010002*QR_021001000000+P_010010102*QR_021001000001+P_010010202*QR_021001000002+P_010110002*QR_021001000010+P_010110102*QR_021001000011+P_010110202*QR_021001000012+P_110010002*QR_021001000100+P_110010102*QR_021001000101+P_110010202*QR_021001000102+P_110110002*QR_021001000110+P_110110102*QR_021001000111+P_110110202*QR_021001000112); ans_temp[ans_id*36+6]+=Pmtrx[32]*(P_010010002*QR_020002000000+P_010010102*QR_020002000001+P_010010202*QR_020002000002+P_010110002*QR_020002000010+P_010110102*QR_020002000011+P_010110202*QR_020002000012+P_110010002*QR_020002000100+P_110010102*QR_020002000101+P_110010202*QR_020002000102+P_110110002*QR_020002000110+P_110110102*QR_020002000111+P_110110202*QR_020002000112); ans_temp[ans_id*36+6]+=Pmtrx[33]*(P_010010002*QR_021000001000+P_010010102*QR_021000001001+P_010010202*QR_021000001002+P_010110002*QR_021000001010+P_010110102*QR_021000001011+P_010110202*QR_021000001012+P_110010002*QR_021000001100+P_110010102*QR_021000001101+P_110010202*QR_021000001102+P_110110002*QR_021000001110+P_110110102*QR_021000001111+P_110110202*QR_021000001112); ans_temp[ans_id*36+6]+=Pmtrx[34]*(P_010010002*QR_020001001000+P_010010102*QR_020001001001+P_010010202*QR_020001001002+P_010110002*QR_020001001010+P_010110102*QR_020001001011+P_010110202*QR_020001001012+P_110010002*QR_020001001100+P_110010102*QR_020001001101+P_110010202*QR_020001001102+P_110110002*QR_020001001110+P_110110102*QR_020001001111+P_110110202*QR_020001001112); ans_temp[ans_id*36+6]+=Pmtrx[35]*(P_010010002*QR_020000002000+P_010010102*QR_020000002001+P_010010202*QR_020000002002+P_010110002*QR_020000002010+P_010110102*QR_020000002011+P_010110202*QR_020000002012+P_110010002*QR_020000002100+P_110010102*QR_020000002101+P_110010202*QR_020000002102+P_110110002*QR_020000002110+P_110110102*QR_020000002111+P_110110202*QR_020000002112); ans_temp[ans_id*36+7]+=Pmtrx[30]*(P_010010002*QR_012010000000+P_010010102*QR_012010000001+P_010010202*QR_012010000002+P_010110002*QR_012010000010+P_010110102*QR_012010000011+P_010110202*QR_012010000012+P_110010002*QR_012010000100+P_110010102*QR_012010000101+P_110010202*QR_012010000102+P_110110002*QR_012010000110+P_110110102*QR_012010000111+P_110110202*QR_012010000112); ans_temp[ans_id*36+7]+=Pmtrx[31]*(P_010010002*QR_011011000000+P_010010102*QR_011011000001+P_010010202*QR_011011000002+P_010110002*QR_011011000010+P_010110102*QR_011011000011+P_010110202*QR_011011000012+P_110010002*QR_011011000100+P_110010102*QR_011011000101+P_110010202*QR_011011000102+P_110110002*QR_011011000110+P_110110102*QR_011011000111+P_110110202*QR_011011000112); ans_temp[ans_id*36+7]+=Pmtrx[32]*(P_010010002*QR_010012000000+P_010010102*QR_010012000001+P_010010202*QR_010012000002+P_010110002*QR_010012000010+P_010110102*QR_010012000011+P_010110202*QR_010012000012+P_110010002*QR_010012000100+P_110010102*QR_010012000101+P_110010202*QR_010012000102+P_110110002*QR_010012000110+P_110110102*QR_010012000111+P_110110202*QR_010012000112); ans_temp[ans_id*36+7]+=Pmtrx[33]*(P_010010002*QR_011010001000+P_010010102*QR_011010001001+P_010010202*QR_011010001002+P_010110002*QR_011010001010+P_010110102*QR_011010001011+P_010110202*QR_011010001012+P_110010002*QR_011010001100+P_110010102*QR_011010001101+P_110010202*QR_011010001102+P_110110002*QR_011010001110+P_110110102*QR_011010001111+P_110110202*QR_011010001112); ans_temp[ans_id*36+7]+=Pmtrx[34]*(P_010010002*QR_010011001000+P_010010102*QR_010011001001+P_010010202*QR_010011001002+P_010110002*QR_010011001010+P_010110102*QR_010011001011+P_010110202*QR_010011001012+P_110010002*QR_010011001100+P_110010102*QR_010011001101+P_110010202*QR_010011001102+P_110110002*QR_010011001110+P_110110102*QR_010011001111+P_110110202*QR_010011001112); ans_temp[ans_id*36+7]+=Pmtrx[35]*(P_010010002*QR_010010002000+P_010010102*QR_010010002001+P_010010202*QR_010010002002+P_010110002*QR_010010002010+P_010110102*QR_010010002011+P_010110202*QR_010010002012+P_110010002*QR_010010002100+P_110010102*QR_010010002101+P_110010202*QR_010010002102+P_110110002*QR_010010002110+P_110110102*QR_010010002111+P_110110202*QR_010010002112); ans_temp[ans_id*36+8]+=Pmtrx[30]*(P_010010002*QR_002020000000+P_010010102*QR_002020000001+P_010010202*QR_002020000002+P_010110002*QR_002020000010+P_010110102*QR_002020000011+P_010110202*QR_002020000012+P_110010002*QR_002020000100+P_110010102*QR_002020000101+P_110010202*QR_002020000102+P_110110002*QR_002020000110+P_110110102*QR_002020000111+P_110110202*QR_002020000112); ans_temp[ans_id*36+8]+=Pmtrx[31]*(P_010010002*QR_001021000000+P_010010102*QR_001021000001+P_010010202*QR_001021000002+P_010110002*QR_001021000010+P_010110102*QR_001021000011+P_010110202*QR_001021000012+P_110010002*QR_001021000100+P_110010102*QR_001021000101+P_110010202*QR_001021000102+P_110110002*QR_001021000110+P_110110102*QR_001021000111+P_110110202*QR_001021000112); ans_temp[ans_id*36+8]+=Pmtrx[32]*(P_010010002*QR_000022000000+P_010010102*QR_000022000001+P_010010202*QR_000022000002+P_010110002*QR_000022000010+P_010110102*QR_000022000011+P_010110202*QR_000022000012+P_110010002*QR_000022000100+P_110010102*QR_000022000101+P_110010202*QR_000022000102+P_110110002*QR_000022000110+P_110110102*QR_000022000111+P_110110202*QR_000022000112); ans_temp[ans_id*36+8]+=Pmtrx[33]*(P_010010002*QR_001020001000+P_010010102*QR_001020001001+P_010010202*QR_001020001002+P_010110002*QR_001020001010+P_010110102*QR_001020001011+P_010110202*QR_001020001012+P_110010002*QR_001020001100+P_110010102*QR_001020001101+P_110010202*QR_001020001102+P_110110002*QR_001020001110+P_110110102*QR_001020001111+P_110110202*QR_001020001112); ans_temp[ans_id*36+8]+=Pmtrx[34]*(P_010010002*QR_000021001000+P_010010102*QR_000021001001+P_010010202*QR_000021001002+P_010110002*QR_000021001010+P_010110102*QR_000021001011+P_010110202*QR_000021001012+P_110010002*QR_000021001100+P_110010102*QR_000021001101+P_110010202*QR_000021001102+P_110110002*QR_000021001110+P_110110102*QR_000021001111+P_110110202*QR_000021001112); ans_temp[ans_id*36+8]+=Pmtrx[35]*(P_010010002*QR_000020002000+P_010010102*QR_000020002001+P_010010202*QR_000020002002+P_010110002*QR_000020002010+P_010110102*QR_000020002011+P_010110202*QR_000020002012+P_110010002*QR_000020002100+P_110010102*QR_000020002101+P_110010202*QR_000020002102+P_110110002*QR_000020002110+P_110110102*QR_000020002111+P_110110202*QR_000020002112); ans_temp[ans_id*36+9]+=Pmtrx[30]*(P_010010002*QR_012000010000+P_010010102*QR_012000010001+P_010010202*QR_012000010002+P_010110002*QR_012000010010+P_010110102*QR_012000010011+P_010110202*QR_012000010012+P_110010002*QR_012000010100+P_110010102*QR_012000010101+P_110010202*QR_012000010102+P_110110002*QR_012000010110+P_110110102*QR_012000010111+P_110110202*QR_012000010112); ans_temp[ans_id*36+9]+=Pmtrx[31]*(P_010010002*QR_011001010000+P_010010102*QR_011001010001+P_010010202*QR_011001010002+P_010110002*QR_011001010010+P_010110102*QR_011001010011+P_010110202*QR_011001010012+P_110010002*QR_011001010100+P_110010102*QR_011001010101+P_110010202*QR_011001010102+P_110110002*QR_011001010110+P_110110102*QR_011001010111+P_110110202*QR_011001010112); ans_temp[ans_id*36+9]+=Pmtrx[32]*(P_010010002*QR_010002010000+P_010010102*QR_010002010001+P_010010202*QR_010002010002+P_010110002*QR_010002010010+P_010110102*QR_010002010011+P_010110202*QR_010002010012+P_110010002*QR_010002010100+P_110010102*QR_010002010101+P_110010202*QR_010002010102+P_110110002*QR_010002010110+P_110110102*QR_010002010111+P_110110202*QR_010002010112); ans_temp[ans_id*36+9]+=Pmtrx[33]*(P_010010002*QR_011000011000+P_010010102*QR_011000011001+P_010010202*QR_011000011002+P_010110002*QR_011000011010+P_010110102*QR_011000011011+P_010110202*QR_011000011012+P_110010002*QR_011000011100+P_110010102*QR_011000011101+P_110010202*QR_011000011102+P_110110002*QR_011000011110+P_110110102*QR_011000011111+P_110110202*QR_011000011112); ans_temp[ans_id*36+9]+=Pmtrx[34]*(P_010010002*QR_010001011000+P_010010102*QR_010001011001+P_010010202*QR_010001011002+P_010110002*QR_010001011010+P_010110102*QR_010001011011+P_010110202*QR_010001011012+P_110010002*QR_010001011100+P_110010102*QR_010001011101+P_110010202*QR_010001011102+P_110110002*QR_010001011110+P_110110102*QR_010001011111+P_110110202*QR_010001011112); ans_temp[ans_id*36+9]+=Pmtrx[35]*(P_010010002*QR_010000012000+P_010010102*QR_010000012001+P_010010202*QR_010000012002+P_010110002*QR_010000012010+P_010110102*QR_010000012011+P_010110202*QR_010000012012+P_110010002*QR_010000012100+P_110010102*QR_010000012101+P_110010202*QR_010000012102+P_110110002*QR_010000012110+P_110110102*QR_010000012111+P_110110202*QR_010000012112); ans_temp[ans_id*36+10]+=Pmtrx[30]*(P_010010002*QR_002010010000+P_010010102*QR_002010010001+P_010010202*QR_002010010002+P_010110002*QR_002010010010+P_010110102*QR_002010010011+P_010110202*QR_002010010012+P_110010002*QR_002010010100+P_110010102*QR_002010010101+P_110010202*QR_002010010102+P_110110002*QR_002010010110+P_110110102*QR_002010010111+P_110110202*QR_002010010112); ans_temp[ans_id*36+10]+=Pmtrx[31]*(P_010010002*QR_001011010000+P_010010102*QR_001011010001+P_010010202*QR_001011010002+P_010110002*QR_001011010010+P_010110102*QR_001011010011+P_010110202*QR_001011010012+P_110010002*QR_001011010100+P_110010102*QR_001011010101+P_110010202*QR_001011010102+P_110110002*QR_001011010110+P_110110102*QR_001011010111+P_110110202*QR_001011010112); ans_temp[ans_id*36+10]+=Pmtrx[32]*(P_010010002*QR_000012010000+P_010010102*QR_000012010001+P_010010202*QR_000012010002+P_010110002*QR_000012010010+P_010110102*QR_000012010011+P_010110202*QR_000012010012+P_110010002*QR_000012010100+P_110010102*QR_000012010101+P_110010202*QR_000012010102+P_110110002*QR_000012010110+P_110110102*QR_000012010111+P_110110202*QR_000012010112); ans_temp[ans_id*36+10]+=Pmtrx[33]*(P_010010002*QR_001010011000+P_010010102*QR_001010011001+P_010010202*QR_001010011002+P_010110002*QR_001010011010+P_010110102*QR_001010011011+P_010110202*QR_001010011012+P_110010002*QR_001010011100+P_110010102*QR_001010011101+P_110010202*QR_001010011102+P_110110002*QR_001010011110+P_110110102*QR_001010011111+P_110110202*QR_001010011112); ans_temp[ans_id*36+10]+=Pmtrx[34]*(P_010010002*QR_000011011000+P_010010102*QR_000011011001+P_010010202*QR_000011011002+P_010110002*QR_000011011010+P_010110102*QR_000011011011+P_010110202*QR_000011011012+P_110010002*QR_000011011100+P_110010102*QR_000011011101+P_110010202*QR_000011011102+P_110110002*QR_000011011110+P_110110102*QR_000011011111+P_110110202*QR_000011011112); ans_temp[ans_id*36+10]+=Pmtrx[35]*(P_010010002*QR_000010012000+P_010010102*QR_000010012001+P_010010202*QR_000010012002+P_010110002*QR_000010012010+P_010110102*QR_000010012011+P_010110202*QR_000010012012+P_110010002*QR_000010012100+P_110010102*QR_000010012101+P_110010202*QR_000010012102+P_110110002*QR_000010012110+P_110110102*QR_000010012111+P_110110202*QR_000010012112); ans_temp[ans_id*36+11]+=Pmtrx[30]*(P_010010002*QR_002000020000+P_010010102*QR_002000020001+P_010010202*QR_002000020002+P_010110002*QR_002000020010+P_010110102*QR_002000020011+P_010110202*QR_002000020012+P_110010002*QR_002000020100+P_110010102*QR_002000020101+P_110010202*QR_002000020102+P_110110002*QR_002000020110+P_110110102*QR_002000020111+P_110110202*QR_002000020112); ans_temp[ans_id*36+11]+=Pmtrx[31]*(P_010010002*QR_001001020000+P_010010102*QR_001001020001+P_010010202*QR_001001020002+P_010110002*QR_001001020010+P_010110102*QR_001001020011+P_010110202*QR_001001020012+P_110010002*QR_001001020100+P_110010102*QR_001001020101+P_110010202*QR_001001020102+P_110110002*QR_001001020110+P_110110102*QR_001001020111+P_110110202*QR_001001020112); ans_temp[ans_id*36+11]+=Pmtrx[32]*(P_010010002*QR_000002020000+P_010010102*QR_000002020001+P_010010202*QR_000002020002+P_010110002*QR_000002020010+P_010110102*QR_000002020011+P_010110202*QR_000002020012+P_110010002*QR_000002020100+P_110010102*QR_000002020101+P_110010202*QR_000002020102+P_110110002*QR_000002020110+P_110110102*QR_000002020111+P_110110202*QR_000002020112); ans_temp[ans_id*36+11]+=Pmtrx[33]*(P_010010002*QR_001000021000+P_010010102*QR_001000021001+P_010010202*QR_001000021002+P_010110002*QR_001000021010+P_010110102*QR_001000021011+P_010110202*QR_001000021012+P_110010002*QR_001000021100+P_110010102*QR_001000021101+P_110010202*QR_001000021102+P_110110002*QR_001000021110+P_110110102*QR_001000021111+P_110110202*QR_001000021112); ans_temp[ans_id*36+11]+=Pmtrx[34]*(P_010010002*QR_000001021000+P_010010102*QR_000001021001+P_010010202*QR_000001021002+P_010110002*QR_000001021010+P_010110102*QR_000001021011+P_010110202*QR_000001021012+P_110010002*QR_000001021100+P_110010102*QR_000001021101+P_110010202*QR_000001021102+P_110110002*QR_000001021110+P_110110102*QR_000001021111+P_110110202*QR_000001021112); ans_temp[ans_id*36+11]+=Pmtrx[35]*(P_010010002*QR_000000022000+P_010010102*QR_000000022001+P_010010202*QR_000000022002+P_010110002*QR_000000022010+P_010110102*QR_000000022011+P_010110202*QR_000000022012+P_110010002*QR_000000022100+P_110010102*QR_000000022101+P_110010202*QR_000000022102+P_110110002*QR_000000022110+P_110110102*QR_000000022111+P_110110202*QR_000000022112); ans_temp[ans_id*36+12]+=Pmtrx[0]*(P_002020000*QR_022000000000+P_002120000*QR_022000000010+P_002220000*QR_022000000020+P_102020000*QR_022000000100+P_102120000*QR_022000000110+P_102220000*QR_022000000120+P_202020000*QR_022000000200+P_202120000*QR_022000000210+P_202220000*QR_022000000220); ans_temp[ans_id*36+12]+=Pmtrx[1]*(P_002020000*QR_021001000000+P_002120000*QR_021001000010+P_002220000*QR_021001000020+P_102020000*QR_021001000100+P_102120000*QR_021001000110+P_102220000*QR_021001000120+P_202020000*QR_021001000200+P_202120000*QR_021001000210+P_202220000*QR_021001000220); ans_temp[ans_id*36+12]+=Pmtrx[2]*(P_002020000*QR_020002000000+P_002120000*QR_020002000010+P_002220000*QR_020002000020+P_102020000*QR_020002000100+P_102120000*QR_020002000110+P_102220000*QR_020002000120+P_202020000*QR_020002000200+P_202120000*QR_020002000210+P_202220000*QR_020002000220); ans_temp[ans_id*36+12]+=Pmtrx[3]*(P_002020000*QR_021000001000+P_002120000*QR_021000001010+P_002220000*QR_021000001020+P_102020000*QR_021000001100+P_102120000*QR_021000001110+P_102220000*QR_021000001120+P_202020000*QR_021000001200+P_202120000*QR_021000001210+P_202220000*QR_021000001220); ans_temp[ans_id*36+12]+=Pmtrx[4]*(P_002020000*QR_020001001000+P_002120000*QR_020001001010+P_002220000*QR_020001001020+P_102020000*QR_020001001100+P_102120000*QR_020001001110+P_102220000*QR_020001001120+P_202020000*QR_020001001200+P_202120000*QR_020001001210+P_202220000*QR_020001001220); ans_temp[ans_id*36+12]+=Pmtrx[5]*(P_002020000*QR_020000002000+P_002120000*QR_020000002010+P_002220000*QR_020000002020+P_102020000*QR_020000002100+P_102120000*QR_020000002110+P_102220000*QR_020000002120+P_202020000*QR_020000002200+P_202120000*QR_020000002210+P_202220000*QR_020000002220); ans_temp[ans_id*36+13]+=Pmtrx[0]*(P_002020000*QR_012010000000+P_002120000*QR_012010000010+P_002220000*QR_012010000020+P_102020000*QR_012010000100+P_102120000*QR_012010000110+P_102220000*QR_012010000120+P_202020000*QR_012010000200+P_202120000*QR_012010000210+P_202220000*QR_012010000220); ans_temp[ans_id*36+13]+=Pmtrx[1]*(P_002020000*QR_011011000000+P_002120000*QR_011011000010+P_002220000*QR_011011000020+P_102020000*QR_011011000100+P_102120000*QR_011011000110+P_102220000*QR_011011000120+P_202020000*QR_011011000200+P_202120000*QR_011011000210+P_202220000*QR_011011000220); ans_temp[ans_id*36+13]+=Pmtrx[2]*(P_002020000*QR_010012000000+P_002120000*QR_010012000010+P_002220000*QR_010012000020+P_102020000*QR_010012000100+P_102120000*QR_010012000110+P_102220000*QR_010012000120+P_202020000*QR_010012000200+P_202120000*QR_010012000210+P_202220000*QR_010012000220); ans_temp[ans_id*36+13]+=Pmtrx[3]*(P_002020000*QR_011010001000+P_002120000*QR_011010001010+P_002220000*QR_011010001020+P_102020000*QR_011010001100+P_102120000*QR_011010001110+P_102220000*QR_011010001120+P_202020000*QR_011010001200+P_202120000*QR_011010001210+P_202220000*QR_011010001220); ans_temp[ans_id*36+13]+=Pmtrx[4]*(P_002020000*QR_010011001000+P_002120000*QR_010011001010+P_002220000*QR_010011001020+P_102020000*QR_010011001100+P_102120000*QR_010011001110+P_102220000*QR_010011001120+P_202020000*QR_010011001200+P_202120000*QR_010011001210+P_202220000*QR_010011001220); ans_temp[ans_id*36+13]+=Pmtrx[5]*(P_002020000*QR_010010002000+P_002120000*QR_010010002010+P_002220000*QR_010010002020+P_102020000*QR_010010002100+P_102120000*QR_010010002110+P_102220000*QR_010010002120+P_202020000*QR_010010002200+P_202120000*QR_010010002210+P_202220000*QR_010010002220); ans_temp[ans_id*36+14]+=Pmtrx[0]*(P_002020000*QR_002020000000+P_002120000*QR_002020000010+P_002220000*QR_002020000020+P_102020000*QR_002020000100+P_102120000*QR_002020000110+P_102220000*QR_002020000120+P_202020000*QR_002020000200+P_202120000*QR_002020000210+P_202220000*QR_002020000220); ans_temp[ans_id*36+14]+=Pmtrx[1]*(P_002020000*QR_001021000000+P_002120000*QR_001021000010+P_002220000*QR_001021000020+P_102020000*QR_001021000100+P_102120000*QR_001021000110+P_102220000*QR_001021000120+P_202020000*QR_001021000200+P_202120000*QR_001021000210+P_202220000*QR_001021000220); ans_temp[ans_id*36+14]+=Pmtrx[2]*(P_002020000*QR_000022000000+P_002120000*QR_000022000010+P_002220000*QR_000022000020+P_102020000*QR_000022000100+P_102120000*QR_000022000110+P_102220000*QR_000022000120+P_202020000*QR_000022000200+P_202120000*QR_000022000210+P_202220000*QR_000022000220); ans_temp[ans_id*36+14]+=Pmtrx[3]*(P_002020000*QR_001020001000+P_002120000*QR_001020001010+P_002220000*QR_001020001020+P_102020000*QR_001020001100+P_102120000*QR_001020001110+P_102220000*QR_001020001120+P_202020000*QR_001020001200+P_202120000*QR_001020001210+P_202220000*QR_001020001220); ans_temp[ans_id*36+14]+=Pmtrx[4]*(P_002020000*QR_000021001000+P_002120000*QR_000021001010+P_002220000*QR_000021001020+P_102020000*QR_000021001100+P_102120000*QR_000021001110+P_102220000*QR_000021001120+P_202020000*QR_000021001200+P_202120000*QR_000021001210+P_202220000*QR_000021001220); ans_temp[ans_id*36+14]+=Pmtrx[5]*(P_002020000*QR_000020002000+P_002120000*QR_000020002010+P_002220000*QR_000020002020+P_102020000*QR_000020002100+P_102120000*QR_000020002110+P_102220000*QR_000020002120+P_202020000*QR_000020002200+P_202120000*QR_000020002210+P_202220000*QR_000020002220); ans_temp[ans_id*36+15]+=Pmtrx[0]*(P_002020000*QR_012000010000+P_002120000*QR_012000010010+P_002220000*QR_012000010020+P_102020000*QR_012000010100+P_102120000*QR_012000010110+P_102220000*QR_012000010120+P_202020000*QR_012000010200+P_202120000*QR_012000010210+P_202220000*QR_012000010220); ans_temp[ans_id*36+15]+=Pmtrx[1]*(P_002020000*QR_011001010000+P_002120000*QR_011001010010+P_002220000*QR_011001010020+P_102020000*QR_011001010100+P_102120000*QR_011001010110+P_102220000*QR_011001010120+P_202020000*QR_011001010200+P_202120000*QR_011001010210+P_202220000*QR_011001010220); ans_temp[ans_id*36+15]+=Pmtrx[2]*(P_002020000*QR_010002010000+P_002120000*QR_010002010010+P_002220000*QR_010002010020+P_102020000*QR_010002010100+P_102120000*QR_010002010110+P_102220000*QR_010002010120+P_202020000*QR_010002010200+P_202120000*QR_010002010210+P_202220000*QR_010002010220); ans_temp[ans_id*36+15]+=Pmtrx[3]*(P_002020000*QR_011000011000+P_002120000*QR_011000011010+P_002220000*QR_011000011020+P_102020000*QR_011000011100+P_102120000*QR_011000011110+P_102220000*QR_011000011120+P_202020000*QR_011000011200+P_202120000*QR_011000011210+P_202220000*QR_011000011220); ans_temp[ans_id*36+15]+=Pmtrx[4]*(P_002020000*QR_010001011000+P_002120000*QR_010001011010+P_002220000*QR_010001011020+P_102020000*QR_010001011100+P_102120000*QR_010001011110+P_102220000*QR_010001011120+P_202020000*QR_010001011200+P_202120000*QR_010001011210+P_202220000*QR_010001011220); ans_temp[ans_id*36+15]+=Pmtrx[5]*(P_002020000*QR_010000012000+P_002120000*QR_010000012010+P_002220000*QR_010000012020+P_102020000*QR_010000012100+P_102120000*QR_010000012110+P_102220000*QR_010000012120+P_202020000*QR_010000012200+P_202120000*QR_010000012210+P_202220000*QR_010000012220); ans_temp[ans_id*36+16]+=Pmtrx[0]*(P_002020000*QR_002010010000+P_002120000*QR_002010010010+P_002220000*QR_002010010020+P_102020000*QR_002010010100+P_102120000*QR_002010010110+P_102220000*QR_002010010120+P_202020000*QR_002010010200+P_202120000*QR_002010010210+P_202220000*QR_002010010220); ans_temp[ans_id*36+16]+=Pmtrx[1]*(P_002020000*QR_001011010000+P_002120000*QR_001011010010+P_002220000*QR_001011010020+P_102020000*QR_001011010100+P_102120000*QR_001011010110+P_102220000*QR_001011010120+P_202020000*QR_001011010200+P_202120000*QR_001011010210+P_202220000*QR_001011010220); ans_temp[ans_id*36+16]+=Pmtrx[2]*(P_002020000*QR_000012010000+P_002120000*QR_000012010010+P_002220000*QR_000012010020+P_102020000*QR_000012010100+P_102120000*QR_000012010110+P_102220000*QR_000012010120+P_202020000*QR_000012010200+P_202120000*QR_000012010210+P_202220000*QR_000012010220); ans_temp[ans_id*36+16]+=Pmtrx[3]*(P_002020000*QR_001010011000+P_002120000*QR_001010011010+P_002220000*QR_001010011020+P_102020000*QR_001010011100+P_102120000*QR_001010011110+P_102220000*QR_001010011120+P_202020000*QR_001010011200+P_202120000*QR_001010011210+P_202220000*QR_001010011220); ans_temp[ans_id*36+16]+=Pmtrx[4]*(P_002020000*QR_000011011000+P_002120000*QR_000011011010+P_002220000*QR_000011011020+P_102020000*QR_000011011100+P_102120000*QR_000011011110+P_102220000*QR_000011011120+P_202020000*QR_000011011200+P_202120000*QR_000011011210+P_202220000*QR_000011011220); ans_temp[ans_id*36+16]+=Pmtrx[5]*(P_002020000*QR_000010012000+P_002120000*QR_000010012010+P_002220000*QR_000010012020+P_102020000*QR_000010012100+P_102120000*QR_000010012110+P_102220000*QR_000010012120+P_202020000*QR_000010012200+P_202120000*QR_000010012210+P_202220000*QR_000010012220); ans_temp[ans_id*36+17]+=Pmtrx[0]*(P_002020000*QR_002000020000+P_002120000*QR_002000020010+P_002220000*QR_002000020020+P_102020000*QR_002000020100+P_102120000*QR_002000020110+P_102220000*QR_002000020120+P_202020000*QR_002000020200+P_202120000*QR_002000020210+P_202220000*QR_002000020220); ans_temp[ans_id*36+17]+=Pmtrx[1]*(P_002020000*QR_001001020000+P_002120000*QR_001001020010+P_002220000*QR_001001020020+P_102020000*QR_001001020100+P_102120000*QR_001001020110+P_102220000*QR_001001020120+P_202020000*QR_001001020200+P_202120000*QR_001001020210+P_202220000*QR_001001020220); ans_temp[ans_id*36+17]+=Pmtrx[2]*(P_002020000*QR_000002020000+P_002120000*QR_000002020010+P_002220000*QR_000002020020+P_102020000*QR_000002020100+P_102120000*QR_000002020110+P_102220000*QR_000002020120+P_202020000*QR_000002020200+P_202120000*QR_000002020210+P_202220000*QR_000002020220); ans_temp[ans_id*36+17]+=Pmtrx[3]*(P_002020000*QR_001000021000+P_002120000*QR_001000021010+P_002220000*QR_001000021020+P_102020000*QR_001000021100+P_102120000*QR_001000021110+P_102220000*QR_001000021120+P_202020000*QR_001000021200+P_202120000*QR_001000021210+P_202220000*QR_001000021220); ans_temp[ans_id*36+17]+=Pmtrx[4]*(P_002020000*QR_000001021000+P_002120000*QR_000001021010+P_002220000*QR_000001021020+P_102020000*QR_000001021100+P_102120000*QR_000001021110+P_102220000*QR_000001021120+P_202020000*QR_000001021200+P_202120000*QR_000001021210+P_202220000*QR_000001021220); ans_temp[ans_id*36+17]+=Pmtrx[5]*(P_002020000*QR_000000022000+P_002120000*QR_000000022010+P_002220000*QR_000000022020+P_102020000*QR_000000022100+P_102120000*QR_000000022110+P_102220000*QR_000000022120+P_202020000*QR_000000022200+P_202120000*QR_000000022210+P_202220000*QR_000000022220); ans_temp[ans_id*36+12]+=Pmtrx[6]*(P_001021000*QR_022000000000+P_001121000*QR_022000000010+P_001221000*QR_022000000020+P_001321000*QR_022000000030+P_101021000*QR_022000000100+P_101121000*QR_022000000110+P_101221000*QR_022000000120+P_101321000*QR_022000000130); ans_temp[ans_id*36+12]+=Pmtrx[7]*(P_001021000*QR_021001000000+P_001121000*QR_021001000010+P_001221000*QR_021001000020+P_001321000*QR_021001000030+P_101021000*QR_021001000100+P_101121000*QR_021001000110+P_101221000*QR_021001000120+P_101321000*QR_021001000130); ans_temp[ans_id*36+12]+=Pmtrx[8]*(P_001021000*QR_020002000000+P_001121000*QR_020002000010+P_001221000*QR_020002000020+P_001321000*QR_020002000030+P_101021000*QR_020002000100+P_101121000*QR_020002000110+P_101221000*QR_020002000120+P_101321000*QR_020002000130); ans_temp[ans_id*36+12]+=Pmtrx[9]*(P_001021000*QR_021000001000+P_001121000*QR_021000001010+P_001221000*QR_021000001020+P_001321000*QR_021000001030+P_101021000*QR_021000001100+P_101121000*QR_021000001110+P_101221000*QR_021000001120+P_101321000*QR_021000001130); ans_temp[ans_id*36+12]+=Pmtrx[10]*(P_001021000*QR_020001001000+P_001121000*QR_020001001010+P_001221000*QR_020001001020+P_001321000*QR_020001001030+P_101021000*QR_020001001100+P_101121000*QR_020001001110+P_101221000*QR_020001001120+P_101321000*QR_020001001130); ans_temp[ans_id*36+12]+=Pmtrx[11]*(P_001021000*QR_020000002000+P_001121000*QR_020000002010+P_001221000*QR_020000002020+P_001321000*QR_020000002030+P_101021000*QR_020000002100+P_101121000*QR_020000002110+P_101221000*QR_020000002120+P_101321000*QR_020000002130); ans_temp[ans_id*36+13]+=Pmtrx[6]*(P_001021000*QR_012010000000+P_001121000*QR_012010000010+P_001221000*QR_012010000020+P_001321000*QR_012010000030+P_101021000*QR_012010000100+P_101121000*QR_012010000110+P_101221000*QR_012010000120+P_101321000*QR_012010000130); ans_temp[ans_id*36+13]+=Pmtrx[7]*(P_001021000*QR_011011000000+P_001121000*QR_011011000010+P_001221000*QR_011011000020+P_001321000*QR_011011000030+P_101021000*QR_011011000100+P_101121000*QR_011011000110+P_101221000*QR_011011000120+P_101321000*QR_011011000130); ans_temp[ans_id*36+13]+=Pmtrx[8]*(P_001021000*QR_010012000000+P_001121000*QR_010012000010+P_001221000*QR_010012000020+P_001321000*QR_010012000030+P_101021000*QR_010012000100+P_101121000*QR_010012000110+P_101221000*QR_010012000120+P_101321000*QR_010012000130); ans_temp[ans_id*36+13]+=Pmtrx[9]*(P_001021000*QR_011010001000+P_001121000*QR_011010001010+P_001221000*QR_011010001020+P_001321000*QR_011010001030+P_101021000*QR_011010001100+P_101121000*QR_011010001110+P_101221000*QR_011010001120+P_101321000*QR_011010001130); ans_temp[ans_id*36+13]+=Pmtrx[10]*(P_001021000*QR_010011001000+P_001121000*QR_010011001010+P_001221000*QR_010011001020+P_001321000*QR_010011001030+P_101021000*QR_010011001100+P_101121000*QR_010011001110+P_101221000*QR_010011001120+P_101321000*QR_010011001130); ans_temp[ans_id*36+13]+=Pmtrx[11]*(P_001021000*QR_010010002000+P_001121000*QR_010010002010+P_001221000*QR_010010002020+P_001321000*QR_010010002030+P_101021000*QR_010010002100+P_101121000*QR_010010002110+P_101221000*QR_010010002120+P_101321000*QR_010010002130); ans_temp[ans_id*36+14]+=Pmtrx[6]*(P_001021000*QR_002020000000+P_001121000*QR_002020000010+P_001221000*QR_002020000020+P_001321000*QR_002020000030+P_101021000*QR_002020000100+P_101121000*QR_002020000110+P_101221000*QR_002020000120+P_101321000*QR_002020000130); ans_temp[ans_id*36+14]+=Pmtrx[7]*(P_001021000*QR_001021000000+P_001121000*QR_001021000010+P_001221000*QR_001021000020+P_001321000*QR_001021000030+P_101021000*QR_001021000100+P_101121000*QR_001021000110+P_101221000*QR_001021000120+P_101321000*QR_001021000130); ans_temp[ans_id*36+14]+=Pmtrx[8]*(P_001021000*QR_000022000000+P_001121000*QR_000022000010+P_001221000*QR_000022000020+P_001321000*QR_000022000030+P_101021000*QR_000022000100+P_101121000*QR_000022000110+P_101221000*QR_000022000120+P_101321000*QR_000022000130); ans_temp[ans_id*36+14]+=Pmtrx[9]*(P_001021000*QR_001020001000+P_001121000*QR_001020001010+P_001221000*QR_001020001020+P_001321000*QR_001020001030+P_101021000*QR_001020001100+P_101121000*QR_001020001110+P_101221000*QR_001020001120+P_101321000*QR_001020001130); ans_temp[ans_id*36+14]+=Pmtrx[10]*(P_001021000*QR_000021001000+P_001121000*QR_000021001010+P_001221000*QR_000021001020+P_001321000*QR_000021001030+P_101021000*QR_000021001100+P_101121000*QR_000021001110+P_101221000*QR_000021001120+P_101321000*QR_000021001130); ans_temp[ans_id*36+14]+=Pmtrx[11]*(P_001021000*QR_000020002000+P_001121000*QR_000020002010+P_001221000*QR_000020002020+P_001321000*QR_000020002030+P_101021000*QR_000020002100+P_101121000*QR_000020002110+P_101221000*QR_000020002120+P_101321000*QR_000020002130); ans_temp[ans_id*36+15]+=Pmtrx[6]*(P_001021000*QR_012000010000+P_001121000*QR_012000010010+P_001221000*QR_012000010020+P_001321000*QR_012000010030+P_101021000*QR_012000010100+P_101121000*QR_012000010110+P_101221000*QR_012000010120+P_101321000*QR_012000010130); ans_temp[ans_id*36+15]+=Pmtrx[7]*(P_001021000*QR_011001010000+P_001121000*QR_011001010010+P_001221000*QR_011001010020+P_001321000*QR_011001010030+P_101021000*QR_011001010100+P_101121000*QR_011001010110+P_101221000*QR_011001010120+P_101321000*QR_011001010130); ans_temp[ans_id*36+15]+=Pmtrx[8]*(P_001021000*QR_010002010000+P_001121000*QR_010002010010+P_001221000*QR_010002010020+P_001321000*QR_010002010030+P_101021000*QR_010002010100+P_101121000*QR_010002010110+P_101221000*QR_010002010120+P_101321000*QR_010002010130); ans_temp[ans_id*36+15]+=Pmtrx[9]*(P_001021000*QR_011000011000+P_001121000*QR_011000011010+P_001221000*QR_011000011020+P_001321000*QR_011000011030+P_101021000*QR_011000011100+P_101121000*QR_011000011110+P_101221000*QR_011000011120+P_101321000*QR_011000011130); ans_temp[ans_id*36+15]+=Pmtrx[10]*(P_001021000*QR_010001011000+P_001121000*QR_010001011010+P_001221000*QR_010001011020+P_001321000*QR_010001011030+P_101021000*QR_010001011100+P_101121000*QR_010001011110+P_101221000*QR_010001011120+P_101321000*QR_010001011130); ans_temp[ans_id*36+15]+=Pmtrx[11]*(P_001021000*QR_010000012000+P_001121000*QR_010000012010+P_001221000*QR_010000012020+P_001321000*QR_010000012030+P_101021000*QR_010000012100+P_101121000*QR_010000012110+P_101221000*QR_010000012120+P_101321000*QR_010000012130); ans_temp[ans_id*36+16]+=Pmtrx[6]*(P_001021000*QR_002010010000+P_001121000*QR_002010010010+P_001221000*QR_002010010020+P_001321000*QR_002010010030+P_101021000*QR_002010010100+P_101121000*QR_002010010110+P_101221000*QR_002010010120+P_101321000*QR_002010010130); ans_temp[ans_id*36+16]+=Pmtrx[7]*(P_001021000*QR_001011010000+P_001121000*QR_001011010010+P_001221000*QR_001011010020+P_001321000*QR_001011010030+P_101021000*QR_001011010100+P_101121000*QR_001011010110+P_101221000*QR_001011010120+P_101321000*QR_001011010130); ans_temp[ans_id*36+16]+=Pmtrx[8]*(P_001021000*QR_000012010000+P_001121000*QR_000012010010+P_001221000*QR_000012010020+P_001321000*QR_000012010030+P_101021000*QR_000012010100+P_101121000*QR_000012010110+P_101221000*QR_000012010120+P_101321000*QR_000012010130); ans_temp[ans_id*36+16]+=Pmtrx[9]*(P_001021000*QR_001010011000+P_001121000*QR_001010011010+P_001221000*QR_001010011020+P_001321000*QR_001010011030+P_101021000*QR_001010011100+P_101121000*QR_001010011110+P_101221000*QR_001010011120+P_101321000*QR_001010011130); ans_temp[ans_id*36+16]+=Pmtrx[10]*(P_001021000*QR_000011011000+P_001121000*QR_000011011010+P_001221000*QR_000011011020+P_001321000*QR_000011011030+P_101021000*QR_000011011100+P_101121000*QR_000011011110+P_101221000*QR_000011011120+P_101321000*QR_000011011130); ans_temp[ans_id*36+16]+=Pmtrx[11]*(P_001021000*QR_000010012000+P_001121000*QR_000010012010+P_001221000*QR_000010012020+P_001321000*QR_000010012030+P_101021000*QR_000010012100+P_101121000*QR_000010012110+P_101221000*QR_000010012120+P_101321000*QR_000010012130); ans_temp[ans_id*36+17]+=Pmtrx[6]*(P_001021000*QR_002000020000+P_001121000*QR_002000020010+P_001221000*QR_002000020020+P_001321000*QR_002000020030+P_101021000*QR_002000020100+P_101121000*QR_002000020110+P_101221000*QR_002000020120+P_101321000*QR_002000020130); ans_temp[ans_id*36+17]+=Pmtrx[7]*(P_001021000*QR_001001020000+P_001121000*QR_001001020010+P_001221000*QR_001001020020+P_001321000*QR_001001020030+P_101021000*QR_001001020100+P_101121000*QR_001001020110+P_101221000*QR_001001020120+P_101321000*QR_001001020130); ans_temp[ans_id*36+17]+=Pmtrx[8]*(P_001021000*QR_000002020000+P_001121000*QR_000002020010+P_001221000*QR_000002020020+P_001321000*QR_000002020030+P_101021000*QR_000002020100+P_101121000*QR_000002020110+P_101221000*QR_000002020120+P_101321000*QR_000002020130); ans_temp[ans_id*36+17]+=Pmtrx[9]*(P_001021000*QR_001000021000+P_001121000*QR_001000021010+P_001221000*QR_001000021020+P_001321000*QR_001000021030+P_101021000*QR_001000021100+P_101121000*QR_001000021110+P_101221000*QR_001000021120+P_101321000*QR_001000021130); ans_temp[ans_id*36+17]+=Pmtrx[10]*(P_001021000*QR_000001021000+P_001121000*QR_000001021010+P_001221000*QR_000001021020+P_001321000*QR_000001021030+P_101021000*QR_000001021100+P_101121000*QR_000001021110+P_101221000*QR_000001021120+P_101321000*QR_000001021130); ans_temp[ans_id*36+17]+=Pmtrx[11]*(P_001021000*QR_000000022000+P_001121000*QR_000000022010+P_001221000*QR_000000022020+P_001321000*QR_000000022030+P_101021000*QR_000000022100+P_101121000*QR_000000022110+P_101221000*QR_000000022120+P_101321000*QR_000000022130); ans_temp[ans_id*36+12]+=Pmtrx[12]*(P_000022000*QR_022000000000+P_000122000*QR_022000000010+P_000222000*QR_022000000020+P_000322000*QR_022000000030+P_000422000*QR_022000000040); ans_temp[ans_id*36+12]+=Pmtrx[13]*(P_000022000*QR_021001000000+P_000122000*QR_021001000010+P_000222000*QR_021001000020+P_000322000*QR_021001000030+P_000422000*QR_021001000040); ans_temp[ans_id*36+12]+=Pmtrx[14]*(P_000022000*QR_020002000000+P_000122000*QR_020002000010+P_000222000*QR_020002000020+P_000322000*QR_020002000030+P_000422000*QR_020002000040); ans_temp[ans_id*36+12]+=Pmtrx[15]*(P_000022000*QR_021000001000+P_000122000*QR_021000001010+P_000222000*QR_021000001020+P_000322000*QR_021000001030+P_000422000*QR_021000001040); ans_temp[ans_id*36+12]+=Pmtrx[16]*(P_000022000*QR_020001001000+P_000122000*QR_020001001010+P_000222000*QR_020001001020+P_000322000*QR_020001001030+P_000422000*QR_020001001040); ans_temp[ans_id*36+12]+=Pmtrx[17]*(P_000022000*QR_020000002000+P_000122000*QR_020000002010+P_000222000*QR_020000002020+P_000322000*QR_020000002030+P_000422000*QR_020000002040); ans_temp[ans_id*36+13]+=Pmtrx[12]*(P_000022000*QR_012010000000+P_000122000*QR_012010000010+P_000222000*QR_012010000020+P_000322000*QR_012010000030+P_000422000*QR_012010000040); ans_temp[ans_id*36+13]+=Pmtrx[13]*(P_000022000*QR_011011000000+P_000122000*QR_011011000010+P_000222000*QR_011011000020+P_000322000*QR_011011000030+P_000422000*QR_011011000040); ans_temp[ans_id*36+13]+=Pmtrx[14]*(P_000022000*QR_010012000000+P_000122000*QR_010012000010+P_000222000*QR_010012000020+P_000322000*QR_010012000030+P_000422000*QR_010012000040); ans_temp[ans_id*36+13]+=Pmtrx[15]*(P_000022000*QR_011010001000+P_000122000*QR_011010001010+P_000222000*QR_011010001020+P_000322000*QR_011010001030+P_000422000*QR_011010001040); ans_temp[ans_id*36+13]+=Pmtrx[16]*(P_000022000*QR_010011001000+P_000122000*QR_010011001010+P_000222000*QR_010011001020+P_000322000*QR_010011001030+P_000422000*QR_010011001040); ans_temp[ans_id*36+13]+=Pmtrx[17]*(P_000022000*QR_010010002000+P_000122000*QR_010010002010+P_000222000*QR_010010002020+P_000322000*QR_010010002030+P_000422000*QR_010010002040); ans_temp[ans_id*36+14]+=Pmtrx[12]*(P_000022000*QR_002020000000+P_000122000*QR_002020000010+P_000222000*QR_002020000020+P_000322000*QR_002020000030+P_000422000*QR_002020000040); ans_temp[ans_id*36+14]+=Pmtrx[13]*(P_000022000*QR_001021000000+P_000122000*QR_001021000010+P_000222000*QR_001021000020+P_000322000*QR_001021000030+P_000422000*QR_001021000040); ans_temp[ans_id*36+14]+=Pmtrx[14]*(P_000022000*QR_000022000000+P_000122000*QR_000022000010+P_000222000*QR_000022000020+P_000322000*QR_000022000030+P_000422000*QR_000022000040); ans_temp[ans_id*36+14]+=Pmtrx[15]*(P_000022000*QR_001020001000+P_000122000*QR_001020001010+P_000222000*QR_001020001020+P_000322000*QR_001020001030+P_000422000*QR_001020001040); ans_temp[ans_id*36+14]+=Pmtrx[16]*(P_000022000*QR_000021001000+P_000122000*QR_000021001010+P_000222000*QR_000021001020+P_000322000*QR_000021001030+P_000422000*QR_000021001040); ans_temp[ans_id*36+14]+=Pmtrx[17]*(P_000022000*QR_000020002000+P_000122000*QR_000020002010+P_000222000*QR_000020002020+P_000322000*QR_000020002030+P_000422000*QR_000020002040); ans_temp[ans_id*36+15]+=Pmtrx[12]*(P_000022000*QR_012000010000+P_000122000*QR_012000010010+P_000222000*QR_012000010020+P_000322000*QR_012000010030+P_000422000*QR_012000010040); ans_temp[ans_id*36+15]+=Pmtrx[13]*(P_000022000*QR_011001010000+P_000122000*QR_011001010010+P_000222000*QR_011001010020+P_000322000*QR_011001010030+P_000422000*QR_011001010040); ans_temp[ans_id*36+15]+=Pmtrx[14]*(P_000022000*QR_010002010000+P_000122000*QR_010002010010+P_000222000*QR_010002010020+P_000322000*QR_010002010030+P_000422000*QR_010002010040); ans_temp[ans_id*36+15]+=Pmtrx[15]*(P_000022000*QR_011000011000+P_000122000*QR_011000011010+P_000222000*QR_011000011020+P_000322000*QR_011000011030+P_000422000*QR_011000011040); ans_temp[ans_id*36+15]+=Pmtrx[16]*(P_000022000*QR_010001011000+P_000122000*QR_010001011010+P_000222000*QR_010001011020+P_000322000*QR_010001011030+P_000422000*QR_010001011040); ans_temp[ans_id*36+15]+=Pmtrx[17]*(P_000022000*QR_010000012000+P_000122000*QR_010000012010+P_000222000*QR_010000012020+P_000322000*QR_010000012030+P_000422000*QR_010000012040); ans_temp[ans_id*36+16]+=Pmtrx[12]*(P_000022000*QR_002010010000+P_000122000*QR_002010010010+P_000222000*QR_002010010020+P_000322000*QR_002010010030+P_000422000*QR_002010010040); ans_temp[ans_id*36+16]+=Pmtrx[13]*(P_000022000*QR_001011010000+P_000122000*QR_001011010010+P_000222000*QR_001011010020+P_000322000*QR_001011010030+P_000422000*QR_001011010040); ans_temp[ans_id*36+16]+=Pmtrx[14]*(P_000022000*QR_000012010000+P_000122000*QR_000012010010+P_000222000*QR_000012010020+P_000322000*QR_000012010030+P_000422000*QR_000012010040); ans_temp[ans_id*36+16]+=Pmtrx[15]*(P_000022000*QR_001010011000+P_000122000*QR_001010011010+P_000222000*QR_001010011020+P_000322000*QR_001010011030+P_000422000*QR_001010011040); ans_temp[ans_id*36+16]+=Pmtrx[16]*(P_000022000*QR_000011011000+P_000122000*QR_000011011010+P_000222000*QR_000011011020+P_000322000*QR_000011011030+P_000422000*QR_000011011040); ans_temp[ans_id*36+16]+=Pmtrx[17]*(P_000022000*QR_000010012000+P_000122000*QR_000010012010+P_000222000*QR_000010012020+P_000322000*QR_000010012030+P_000422000*QR_000010012040); ans_temp[ans_id*36+17]+=Pmtrx[12]*(P_000022000*QR_002000020000+P_000122000*QR_002000020010+P_000222000*QR_002000020020+P_000322000*QR_002000020030+P_000422000*QR_002000020040); ans_temp[ans_id*36+17]+=Pmtrx[13]*(P_000022000*QR_001001020000+P_000122000*QR_001001020010+P_000222000*QR_001001020020+P_000322000*QR_001001020030+P_000422000*QR_001001020040); ans_temp[ans_id*36+17]+=Pmtrx[14]*(P_000022000*QR_000002020000+P_000122000*QR_000002020010+P_000222000*QR_000002020020+P_000322000*QR_000002020030+P_000422000*QR_000002020040); ans_temp[ans_id*36+17]+=Pmtrx[15]*(P_000022000*QR_001000021000+P_000122000*QR_001000021010+P_000222000*QR_001000021020+P_000322000*QR_001000021030+P_000422000*QR_001000021040); ans_temp[ans_id*36+17]+=Pmtrx[16]*(P_000022000*QR_000001021000+P_000122000*QR_000001021010+P_000222000*QR_000001021020+P_000322000*QR_000001021030+P_000422000*QR_000001021040); ans_temp[ans_id*36+17]+=Pmtrx[17]*(P_000022000*QR_000000022000+P_000122000*QR_000000022010+P_000222000*QR_000000022020+P_000322000*QR_000000022030+P_000422000*QR_000000022040); ans_temp[ans_id*36+12]+=Pmtrx[18]*(P_001020001*QR_022000000000+P_001020101*QR_022000000001+P_001120001*QR_022000000010+P_001120101*QR_022000000011+P_001220001*QR_022000000020+P_001220101*QR_022000000021+P_101020001*QR_022000000100+P_101020101*QR_022000000101+P_101120001*QR_022000000110+P_101120101*QR_022000000111+P_101220001*QR_022000000120+P_101220101*QR_022000000121); ans_temp[ans_id*36+12]+=Pmtrx[19]*(P_001020001*QR_021001000000+P_001020101*QR_021001000001+P_001120001*QR_021001000010+P_001120101*QR_021001000011+P_001220001*QR_021001000020+P_001220101*QR_021001000021+P_101020001*QR_021001000100+P_101020101*QR_021001000101+P_101120001*QR_021001000110+P_101120101*QR_021001000111+P_101220001*QR_021001000120+P_101220101*QR_021001000121); ans_temp[ans_id*36+12]+=Pmtrx[20]*(P_001020001*QR_020002000000+P_001020101*QR_020002000001+P_001120001*QR_020002000010+P_001120101*QR_020002000011+P_001220001*QR_020002000020+P_001220101*QR_020002000021+P_101020001*QR_020002000100+P_101020101*QR_020002000101+P_101120001*QR_020002000110+P_101120101*QR_020002000111+P_101220001*QR_020002000120+P_101220101*QR_020002000121); ans_temp[ans_id*36+12]+=Pmtrx[21]*(P_001020001*QR_021000001000+P_001020101*QR_021000001001+P_001120001*QR_021000001010+P_001120101*QR_021000001011+P_001220001*QR_021000001020+P_001220101*QR_021000001021+P_101020001*QR_021000001100+P_101020101*QR_021000001101+P_101120001*QR_021000001110+P_101120101*QR_021000001111+P_101220001*QR_021000001120+P_101220101*QR_021000001121); ans_temp[ans_id*36+12]+=Pmtrx[22]*(P_001020001*QR_020001001000+P_001020101*QR_020001001001+P_001120001*QR_020001001010+P_001120101*QR_020001001011+P_001220001*QR_020001001020+P_001220101*QR_020001001021+P_101020001*QR_020001001100+P_101020101*QR_020001001101+P_101120001*QR_020001001110+P_101120101*QR_020001001111+P_101220001*QR_020001001120+P_101220101*QR_020001001121); ans_temp[ans_id*36+12]+=Pmtrx[23]*(P_001020001*QR_020000002000+P_001020101*QR_020000002001+P_001120001*QR_020000002010+P_001120101*QR_020000002011+P_001220001*QR_020000002020+P_001220101*QR_020000002021+P_101020001*QR_020000002100+P_101020101*QR_020000002101+P_101120001*QR_020000002110+P_101120101*QR_020000002111+P_101220001*QR_020000002120+P_101220101*QR_020000002121); ans_temp[ans_id*36+13]+=Pmtrx[18]*(P_001020001*QR_012010000000+P_001020101*QR_012010000001+P_001120001*QR_012010000010+P_001120101*QR_012010000011+P_001220001*QR_012010000020+P_001220101*QR_012010000021+P_101020001*QR_012010000100+P_101020101*QR_012010000101+P_101120001*QR_012010000110+P_101120101*QR_012010000111+P_101220001*QR_012010000120+P_101220101*QR_012010000121); ans_temp[ans_id*36+13]+=Pmtrx[19]*(P_001020001*QR_011011000000+P_001020101*QR_011011000001+P_001120001*QR_011011000010+P_001120101*QR_011011000011+P_001220001*QR_011011000020+P_001220101*QR_011011000021+P_101020001*QR_011011000100+P_101020101*QR_011011000101+P_101120001*QR_011011000110+P_101120101*QR_011011000111+P_101220001*QR_011011000120+P_101220101*QR_011011000121); ans_temp[ans_id*36+13]+=Pmtrx[20]*(P_001020001*QR_010012000000+P_001020101*QR_010012000001+P_001120001*QR_010012000010+P_001120101*QR_010012000011+P_001220001*QR_010012000020+P_001220101*QR_010012000021+P_101020001*QR_010012000100+P_101020101*QR_010012000101+P_101120001*QR_010012000110+P_101120101*QR_010012000111+P_101220001*QR_010012000120+P_101220101*QR_010012000121); ans_temp[ans_id*36+13]+=Pmtrx[21]*(P_001020001*QR_011010001000+P_001020101*QR_011010001001+P_001120001*QR_011010001010+P_001120101*QR_011010001011+P_001220001*QR_011010001020+P_001220101*QR_011010001021+P_101020001*QR_011010001100+P_101020101*QR_011010001101+P_101120001*QR_011010001110+P_101120101*QR_011010001111+P_101220001*QR_011010001120+P_101220101*QR_011010001121); ans_temp[ans_id*36+13]+=Pmtrx[22]*(P_001020001*QR_010011001000+P_001020101*QR_010011001001+P_001120001*QR_010011001010+P_001120101*QR_010011001011+P_001220001*QR_010011001020+P_001220101*QR_010011001021+P_101020001*QR_010011001100+P_101020101*QR_010011001101+P_101120001*QR_010011001110+P_101120101*QR_010011001111+P_101220001*QR_010011001120+P_101220101*QR_010011001121); ans_temp[ans_id*36+13]+=Pmtrx[23]*(P_001020001*QR_010010002000+P_001020101*QR_010010002001+P_001120001*QR_010010002010+P_001120101*QR_010010002011+P_001220001*QR_010010002020+P_001220101*QR_010010002021+P_101020001*QR_010010002100+P_101020101*QR_010010002101+P_101120001*QR_010010002110+P_101120101*QR_010010002111+P_101220001*QR_010010002120+P_101220101*QR_010010002121); ans_temp[ans_id*36+14]+=Pmtrx[18]*(P_001020001*QR_002020000000+P_001020101*QR_002020000001+P_001120001*QR_002020000010+P_001120101*QR_002020000011+P_001220001*QR_002020000020+P_001220101*QR_002020000021+P_101020001*QR_002020000100+P_101020101*QR_002020000101+P_101120001*QR_002020000110+P_101120101*QR_002020000111+P_101220001*QR_002020000120+P_101220101*QR_002020000121); ans_temp[ans_id*36+14]+=Pmtrx[19]*(P_001020001*QR_001021000000+P_001020101*QR_001021000001+P_001120001*QR_001021000010+P_001120101*QR_001021000011+P_001220001*QR_001021000020+P_001220101*QR_001021000021+P_101020001*QR_001021000100+P_101020101*QR_001021000101+P_101120001*QR_001021000110+P_101120101*QR_001021000111+P_101220001*QR_001021000120+P_101220101*QR_001021000121); ans_temp[ans_id*36+14]+=Pmtrx[20]*(P_001020001*QR_000022000000+P_001020101*QR_000022000001+P_001120001*QR_000022000010+P_001120101*QR_000022000011+P_001220001*QR_000022000020+P_001220101*QR_000022000021+P_101020001*QR_000022000100+P_101020101*QR_000022000101+P_101120001*QR_000022000110+P_101120101*QR_000022000111+P_101220001*QR_000022000120+P_101220101*QR_000022000121); ans_temp[ans_id*36+14]+=Pmtrx[21]*(P_001020001*QR_001020001000+P_001020101*QR_001020001001+P_001120001*QR_001020001010+P_001120101*QR_001020001011+P_001220001*QR_001020001020+P_001220101*QR_001020001021+P_101020001*QR_001020001100+P_101020101*QR_001020001101+P_101120001*QR_001020001110+P_101120101*QR_001020001111+P_101220001*QR_001020001120+P_101220101*QR_001020001121); ans_temp[ans_id*36+14]+=Pmtrx[22]*(P_001020001*QR_000021001000+P_001020101*QR_000021001001+P_001120001*QR_000021001010+P_001120101*QR_000021001011+P_001220001*QR_000021001020+P_001220101*QR_000021001021+P_101020001*QR_000021001100+P_101020101*QR_000021001101+P_101120001*QR_000021001110+P_101120101*QR_000021001111+P_101220001*QR_000021001120+P_101220101*QR_000021001121); ans_temp[ans_id*36+14]+=Pmtrx[23]*(P_001020001*QR_000020002000+P_001020101*QR_000020002001+P_001120001*QR_000020002010+P_001120101*QR_000020002011+P_001220001*QR_000020002020+P_001220101*QR_000020002021+P_101020001*QR_000020002100+P_101020101*QR_000020002101+P_101120001*QR_000020002110+P_101120101*QR_000020002111+P_101220001*QR_000020002120+P_101220101*QR_000020002121); ans_temp[ans_id*36+15]+=Pmtrx[18]*(P_001020001*QR_012000010000+P_001020101*QR_012000010001+P_001120001*QR_012000010010+P_001120101*QR_012000010011+P_001220001*QR_012000010020+P_001220101*QR_012000010021+P_101020001*QR_012000010100+P_101020101*QR_012000010101+P_101120001*QR_012000010110+P_101120101*QR_012000010111+P_101220001*QR_012000010120+P_101220101*QR_012000010121); ans_temp[ans_id*36+15]+=Pmtrx[19]*(P_001020001*QR_011001010000+P_001020101*QR_011001010001+P_001120001*QR_011001010010+P_001120101*QR_011001010011+P_001220001*QR_011001010020+P_001220101*QR_011001010021+P_101020001*QR_011001010100+P_101020101*QR_011001010101+P_101120001*QR_011001010110+P_101120101*QR_011001010111+P_101220001*QR_011001010120+P_101220101*QR_011001010121); ans_temp[ans_id*36+15]+=Pmtrx[20]*(P_001020001*QR_010002010000+P_001020101*QR_010002010001+P_001120001*QR_010002010010+P_001120101*QR_010002010011+P_001220001*QR_010002010020+P_001220101*QR_010002010021+P_101020001*QR_010002010100+P_101020101*QR_010002010101+P_101120001*QR_010002010110+P_101120101*QR_010002010111+P_101220001*QR_010002010120+P_101220101*QR_010002010121); ans_temp[ans_id*36+15]+=Pmtrx[21]*(P_001020001*QR_011000011000+P_001020101*QR_011000011001+P_001120001*QR_011000011010+P_001120101*QR_011000011011+P_001220001*QR_011000011020+P_001220101*QR_011000011021+P_101020001*QR_011000011100+P_101020101*QR_011000011101+P_101120001*QR_011000011110+P_101120101*QR_011000011111+P_101220001*QR_011000011120+P_101220101*QR_011000011121); ans_temp[ans_id*36+15]+=Pmtrx[22]*(P_001020001*QR_010001011000+P_001020101*QR_010001011001+P_001120001*QR_010001011010+P_001120101*QR_010001011011+P_001220001*QR_010001011020+P_001220101*QR_010001011021+P_101020001*QR_010001011100+P_101020101*QR_010001011101+P_101120001*QR_010001011110+P_101120101*QR_010001011111+P_101220001*QR_010001011120+P_101220101*QR_010001011121); ans_temp[ans_id*36+15]+=Pmtrx[23]*(P_001020001*QR_010000012000+P_001020101*QR_010000012001+P_001120001*QR_010000012010+P_001120101*QR_010000012011+P_001220001*QR_010000012020+P_001220101*QR_010000012021+P_101020001*QR_010000012100+P_101020101*QR_010000012101+P_101120001*QR_010000012110+P_101120101*QR_010000012111+P_101220001*QR_010000012120+P_101220101*QR_010000012121); ans_temp[ans_id*36+16]+=Pmtrx[18]*(P_001020001*QR_002010010000+P_001020101*QR_002010010001+P_001120001*QR_002010010010+P_001120101*QR_002010010011+P_001220001*QR_002010010020+P_001220101*QR_002010010021+P_101020001*QR_002010010100+P_101020101*QR_002010010101+P_101120001*QR_002010010110+P_101120101*QR_002010010111+P_101220001*QR_002010010120+P_101220101*QR_002010010121); ans_temp[ans_id*36+16]+=Pmtrx[19]*(P_001020001*QR_001011010000+P_001020101*QR_001011010001+P_001120001*QR_001011010010+P_001120101*QR_001011010011+P_001220001*QR_001011010020+P_001220101*QR_001011010021+P_101020001*QR_001011010100+P_101020101*QR_001011010101+P_101120001*QR_001011010110+P_101120101*QR_001011010111+P_101220001*QR_001011010120+P_101220101*QR_001011010121); ans_temp[ans_id*36+16]+=Pmtrx[20]*(P_001020001*QR_000012010000+P_001020101*QR_000012010001+P_001120001*QR_000012010010+P_001120101*QR_000012010011+P_001220001*QR_000012010020+P_001220101*QR_000012010021+P_101020001*QR_000012010100+P_101020101*QR_000012010101+P_101120001*QR_000012010110+P_101120101*QR_000012010111+P_101220001*QR_000012010120+P_101220101*QR_000012010121); ans_temp[ans_id*36+16]+=Pmtrx[21]*(P_001020001*QR_001010011000+P_001020101*QR_001010011001+P_001120001*QR_001010011010+P_001120101*QR_001010011011+P_001220001*QR_001010011020+P_001220101*QR_001010011021+P_101020001*QR_001010011100+P_101020101*QR_001010011101+P_101120001*QR_001010011110+P_101120101*QR_001010011111+P_101220001*QR_001010011120+P_101220101*QR_001010011121); ans_temp[ans_id*36+16]+=Pmtrx[22]*(P_001020001*QR_000011011000+P_001020101*QR_000011011001+P_001120001*QR_000011011010+P_001120101*QR_000011011011+P_001220001*QR_000011011020+P_001220101*QR_000011011021+P_101020001*QR_000011011100+P_101020101*QR_000011011101+P_101120001*QR_000011011110+P_101120101*QR_000011011111+P_101220001*QR_000011011120+P_101220101*QR_000011011121); ans_temp[ans_id*36+16]+=Pmtrx[23]*(P_001020001*QR_000010012000+P_001020101*QR_000010012001+P_001120001*QR_000010012010+P_001120101*QR_000010012011+P_001220001*QR_000010012020+P_001220101*QR_000010012021+P_101020001*QR_000010012100+P_101020101*QR_000010012101+P_101120001*QR_000010012110+P_101120101*QR_000010012111+P_101220001*QR_000010012120+P_101220101*QR_000010012121); ans_temp[ans_id*36+17]+=Pmtrx[18]*(P_001020001*QR_002000020000+P_001020101*QR_002000020001+P_001120001*QR_002000020010+P_001120101*QR_002000020011+P_001220001*QR_002000020020+P_001220101*QR_002000020021+P_101020001*QR_002000020100+P_101020101*QR_002000020101+P_101120001*QR_002000020110+P_101120101*QR_002000020111+P_101220001*QR_002000020120+P_101220101*QR_002000020121); ans_temp[ans_id*36+17]+=Pmtrx[19]*(P_001020001*QR_001001020000+P_001020101*QR_001001020001+P_001120001*QR_001001020010+P_001120101*QR_001001020011+P_001220001*QR_001001020020+P_001220101*QR_001001020021+P_101020001*QR_001001020100+P_101020101*QR_001001020101+P_101120001*QR_001001020110+P_101120101*QR_001001020111+P_101220001*QR_001001020120+P_101220101*QR_001001020121); ans_temp[ans_id*36+17]+=Pmtrx[20]*(P_001020001*QR_000002020000+P_001020101*QR_000002020001+P_001120001*QR_000002020010+P_001120101*QR_000002020011+P_001220001*QR_000002020020+P_001220101*QR_000002020021+P_101020001*QR_000002020100+P_101020101*QR_000002020101+P_101120001*QR_000002020110+P_101120101*QR_000002020111+P_101220001*QR_000002020120+P_101220101*QR_000002020121); ans_temp[ans_id*36+17]+=Pmtrx[21]*(P_001020001*QR_001000021000+P_001020101*QR_001000021001+P_001120001*QR_001000021010+P_001120101*QR_001000021011+P_001220001*QR_001000021020+P_001220101*QR_001000021021+P_101020001*QR_001000021100+P_101020101*QR_001000021101+P_101120001*QR_001000021110+P_101120101*QR_001000021111+P_101220001*QR_001000021120+P_101220101*QR_001000021121); ans_temp[ans_id*36+17]+=Pmtrx[22]*(P_001020001*QR_000001021000+P_001020101*QR_000001021001+P_001120001*QR_000001021010+P_001120101*QR_000001021011+P_001220001*QR_000001021020+P_001220101*QR_000001021021+P_101020001*QR_000001021100+P_101020101*QR_000001021101+P_101120001*QR_000001021110+P_101120101*QR_000001021111+P_101220001*QR_000001021120+P_101220101*QR_000001021121); ans_temp[ans_id*36+17]+=Pmtrx[23]*(P_001020001*QR_000000022000+P_001020101*QR_000000022001+P_001120001*QR_000000022010+P_001120101*QR_000000022011+P_001220001*QR_000000022020+P_001220101*QR_000000022021+P_101020001*QR_000000022100+P_101020101*QR_000000022101+P_101120001*QR_000000022110+P_101120101*QR_000000022111+P_101220001*QR_000000022120+P_101220101*QR_000000022121); ans_temp[ans_id*36+12]+=Pmtrx[24]*(P_000021001*QR_022000000000+P_000021101*QR_022000000001+P_000121001*QR_022000000010+P_000121101*QR_022000000011+P_000221001*QR_022000000020+P_000221101*QR_022000000021+P_000321001*QR_022000000030+P_000321101*QR_022000000031); ans_temp[ans_id*36+12]+=Pmtrx[25]*(P_000021001*QR_021001000000+P_000021101*QR_021001000001+P_000121001*QR_021001000010+P_000121101*QR_021001000011+P_000221001*QR_021001000020+P_000221101*QR_021001000021+P_000321001*QR_021001000030+P_000321101*QR_021001000031); ans_temp[ans_id*36+12]+=Pmtrx[26]*(P_000021001*QR_020002000000+P_000021101*QR_020002000001+P_000121001*QR_020002000010+P_000121101*QR_020002000011+P_000221001*QR_020002000020+P_000221101*QR_020002000021+P_000321001*QR_020002000030+P_000321101*QR_020002000031); ans_temp[ans_id*36+12]+=Pmtrx[27]*(P_000021001*QR_021000001000+P_000021101*QR_021000001001+P_000121001*QR_021000001010+P_000121101*QR_021000001011+P_000221001*QR_021000001020+P_000221101*QR_021000001021+P_000321001*QR_021000001030+P_000321101*QR_021000001031); ans_temp[ans_id*36+12]+=Pmtrx[28]*(P_000021001*QR_020001001000+P_000021101*QR_020001001001+P_000121001*QR_020001001010+P_000121101*QR_020001001011+P_000221001*QR_020001001020+P_000221101*QR_020001001021+P_000321001*QR_020001001030+P_000321101*QR_020001001031); ans_temp[ans_id*36+12]+=Pmtrx[29]*(P_000021001*QR_020000002000+P_000021101*QR_020000002001+P_000121001*QR_020000002010+P_000121101*QR_020000002011+P_000221001*QR_020000002020+P_000221101*QR_020000002021+P_000321001*QR_020000002030+P_000321101*QR_020000002031); ans_temp[ans_id*36+13]+=Pmtrx[24]*(P_000021001*QR_012010000000+P_000021101*QR_012010000001+P_000121001*QR_012010000010+P_000121101*QR_012010000011+P_000221001*QR_012010000020+P_000221101*QR_012010000021+P_000321001*QR_012010000030+P_000321101*QR_012010000031); ans_temp[ans_id*36+13]+=Pmtrx[25]*(P_000021001*QR_011011000000+P_000021101*QR_011011000001+P_000121001*QR_011011000010+P_000121101*QR_011011000011+P_000221001*QR_011011000020+P_000221101*QR_011011000021+P_000321001*QR_011011000030+P_000321101*QR_011011000031); ans_temp[ans_id*36+13]+=Pmtrx[26]*(P_000021001*QR_010012000000+P_000021101*QR_010012000001+P_000121001*QR_010012000010+P_000121101*QR_010012000011+P_000221001*QR_010012000020+P_000221101*QR_010012000021+P_000321001*QR_010012000030+P_000321101*QR_010012000031); ans_temp[ans_id*36+13]+=Pmtrx[27]*(P_000021001*QR_011010001000+P_000021101*QR_011010001001+P_000121001*QR_011010001010+P_000121101*QR_011010001011+P_000221001*QR_011010001020+P_000221101*QR_011010001021+P_000321001*QR_011010001030+P_000321101*QR_011010001031); ans_temp[ans_id*36+13]+=Pmtrx[28]*(P_000021001*QR_010011001000+P_000021101*QR_010011001001+P_000121001*QR_010011001010+P_000121101*QR_010011001011+P_000221001*QR_010011001020+P_000221101*QR_010011001021+P_000321001*QR_010011001030+P_000321101*QR_010011001031); ans_temp[ans_id*36+13]+=Pmtrx[29]*(P_000021001*QR_010010002000+P_000021101*QR_010010002001+P_000121001*QR_010010002010+P_000121101*QR_010010002011+P_000221001*QR_010010002020+P_000221101*QR_010010002021+P_000321001*QR_010010002030+P_000321101*QR_010010002031); ans_temp[ans_id*36+14]+=Pmtrx[24]*(P_000021001*QR_002020000000+P_000021101*QR_002020000001+P_000121001*QR_002020000010+P_000121101*QR_002020000011+P_000221001*QR_002020000020+P_000221101*QR_002020000021+P_000321001*QR_002020000030+P_000321101*QR_002020000031); ans_temp[ans_id*36+14]+=Pmtrx[25]*(P_000021001*QR_001021000000+P_000021101*QR_001021000001+P_000121001*QR_001021000010+P_000121101*QR_001021000011+P_000221001*QR_001021000020+P_000221101*QR_001021000021+P_000321001*QR_001021000030+P_000321101*QR_001021000031); ans_temp[ans_id*36+14]+=Pmtrx[26]*(P_000021001*QR_000022000000+P_000021101*QR_000022000001+P_000121001*QR_000022000010+P_000121101*QR_000022000011+P_000221001*QR_000022000020+P_000221101*QR_000022000021+P_000321001*QR_000022000030+P_000321101*QR_000022000031); ans_temp[ans_id*36+14]+=Pmtrx[27]*(P_000021001*QR_001020001000+P_000021101*QR_001020001001+P_000121001*QR_001020001010+P_000121101*QR_001020001011+P_000221001*QR_001020001020+P_000221101*QR_001020001021+P_000321001*QR_001020001030+P_000321101*QR_001020001031); ans_temp[ans_id*36+14]+=Pmtrx[28]*(P_000021001*QR_000021001000+P_000021101*QR_000021001001+P_000121001*QR_000021001010+P_000121101*QR_000021001011+P_000221001*QR_000021001020+P_000221101*QR_000021001021+P_000321001*QR_000021001030+P_000321101*QR_000021001031); ans_temp[ans_id*36+14]+=Pmtrx[29]*(P_000021001*QR_000020002000+P_000021101*QR_000020002001+P_000121001*QR_000020002010+P_000121101*QR_000020002011+P_000221001*QR_000020002020+P_000221101*QR_000020002021+P_000321001*QR_000020002030+P_000321101*QR_000020002031); ans_temp[ans_id*36+15]+=Pmtrx[24]*(P_000021001*QR_012000010000+P_000021101*QR_012000010001+P_000121001*QR_012000010010+P_000121101*QR_012000010011+P_000221001*QR_012000010020+P_000221101*QR_012000010021+P_000321001*QR_012000010030+P_000321101*QR_012000010031); ans_temp[ans_id*36+15]+=Pmtrx[25]*(P_000021001*QR_011001010000+P_000021101*QR_011001010001+P_000121001*QR_011001010010+P_000121101*QR_011001010011+P_000221001*QR_011001010020+P_000221101*QR_011001010021+P_000321001*QR_011001010030+P_000321101*QR_011001010031); ans_temp[ans_id*36+15]+=Pmtrx[26]*(P_000021001*QR_010002010000+P_000021101*QR_010002010001+P_000121001*QR_010002010010+P_000121101*QR_010002010011+P_000221001*QR_010002010020+P_000221101*QR_010002010021+P_000321001*QR_010002010030+P_000321101*QR_010002010031); ans_temp[ans_id*36+15]+=Pmtrx[27]*(P_000021001*QR_011000011000+P_000021101*QR_011000011001+P_000121001*QR_011000011010+P_000121101*QR_011000011011+P_000221001*QR_011000011020+P_000221101*QR_011000011021+P_000321001*QR_011000011030+P_000321101*QR_011000011031); ans_temp[ans_id*36+15]+=Pmtrx[28]*(P_000021001*QR_010001011000+P_000021101*QR_010001011001+P_000121001*QR_010001011010+P_000121101*QR_010001011011+P_000221001*QR_010001011020+P_000221101*QR_010001011021+P_000321001*QR_010001011030+P_000321101*QR_010001011031); ans_temp[ans_id*36+15]+=Pmtrx[29]*(P_000021001*QR_010000012000+P_000021101*QR_010000012001+P_000121001*QR_010000012010+P_000121101*QR_010000012011+P_000221001*QR_010000012020+P_000221101*QR_010000012021+P_000321001*QR_010000012030+P_000321101*QR_010000012031); ans_temp[ans_id*36+16]+=Pmtrx[24]*(P_000021001*QR_002010010000+P_000021101*QR_002010010001+P_000121001*QR_002010010010+P_000121101*QR_002010010011+P_000221001*QR_002010010020+P_000221101*QR_002010010021+P_000321001*QR_002010010030+P_000321101*QR_002010010031); ans_temp[ans_id*36+16]+=Pmtrx[25]*(P_000021001*QR_001011010000+P_000021101*QR_001011010001+P_000121001*QR_001011010010+P_000121101*QR_001011010011+P_000221001*QR_001011010020+P_000221101*QR_001011010021+P_000321001*QR_001011010030+P_000321101*QR_001011010031); ans_temp[ans_id*36+16]+=Pmtrx[26]*(P_000021001*QR_000012010000+P_000021101*QR_000012010001+P_000121001*QR_000012010010+P_000121101*QR_000012010011+P_000221001*QR_000012010020+P_000221101*QR_000012010021+P_000321001*QR_000012010030+P_000321101*QR_000012010031); ans_temp[ans_id*36+16]+=Pmtrx[27]*(P_000021001*QR_001010011000+P_000021101*QR_001010011001+P_000121001*QR_001010011010+P_000121101*QR_001010011011+P_000221001*QR_001010011020+P_000221101*QR_001010011021+P_000321001*QR_001010011030+P_000321101*QR_001010011031); ans_temp[ans_id*36+16]+=Pmtrx[28]*(P_000021001*QR_000011011000+P_000021101*QR_000011011001+P_000121001*QR_000011011010+P_000121101*QR_000011011011+P_000221001*QR_000011011020+P_000221101*QR_000011011021+P_000321001*QR_000011011030+P_000321101*QR_000011011031); ans_temp[ans_id*36+16]+=Pmtrx[29]*(P_000021001*QR_000010012000+P_000021101*QR_000010012001+P_000121001*QR_000010012010+P_000121101*QR_000010012011+P_000221001*QR_000010012020+P_000221101*QR_000010012021+P_000321001*QR_000010012030+P_000321101*QR_000010012031); ans_temp[ans_id*36+17]+=Pmtrx[24]*(P_000021001*QR_002000020000+P_000021101*QR_002000020001+P_000121001*QR_002000020010+P_000121101*QR_002000020011+P_000221001*QR_002000020020+P_000221101*QR_002000020021+P_000321001*QR_002000020030+P_000321101*QR_002000020031); ans_temp[ans_id*36+17]+=Pmtrx[25]*(P_000021001*QR_001001020000+P_000021101*QR_001001020001+P_000121001*QR_001001020010+P_000121101*QR_001001020011+P_000221001*QR_001001020020+P_000221101*QR_001001020021+P_000321001*QR_001001020030+P_000321101*QR_001001020031); ans_temp[ans_id*36+17]+=Pmtrx[26]*(P_000021001*QR_000002020000+P_000021101*QR_000002020001+P_000121001*QR_000002020010+P_000121101*QR_000002020011+P_000221001*QR_000002020020+P_000221101*QR_000002020021+P_000321001*QR_000002020030+P_000321101*QR_000002020031); ans_temp[ans_id*36+17]+=Pmtrx[27]*(P_000021001*QR_001000021000+P_000021101*QR_001000021001+P_000121001*QR_001000021010+P_000121101*QR_001000021011+P_000221001*QR_001000021020+P_000221101*QR_001000021021+P_000321001*QR_001000021030+P_000321101*QR_001000021031); ans_temp[ans_id*36+17]+=Pmtrx[28]*(P_000021001*QR_000001021000+P_000021101*QR_000001021001+P_000121001*QR_000001021010+P_000121101*QR_000001021011+P_000221001*QR_000001021020+P_000221101*QR_000001021021+P_000321001*QR_000001021030+P_000321101*QR_000001021031); ans_temp[ans_id*36+17]+=Pmtrx[29]*(P_000021001*QR_000000022000+P_000021101*QR_000000022001+P_000121001*QR_000000022010+P_000121101*QR_000000022011+P_000221001*QR_000000022020+P_000221101*QR_000000022021+P_000321001*QR_000000022030+P_000321101*QR_000000022031); ans_temp[ans_id*36+12]+=Pmtrx[30]*(P_000020002*QR_022000000000+P_000020102*QR_022000000001+P_000020202*QR_022000000002+P_000120002*QR_022000000010+P_000120102*QR_022000000011+P_000120202*QR_022000000012+P_000220002*QR_022000000020+P_000220102*QR_022000000021+P_000220202*QR_022000000022); ans_temp[ans_id*36+12]+=Pmtrx[31]*(P_000020002*QR_021001000000+P_000020102*QR_021001000001+P_000020202*QR_021001000002+P_000120002*QR_021001000010+P_000120102*QR_021001000011+P_000120202*QR_021001000012+P_000220002*QR_021001000020+P_000220102*QR_021001000021+P_000220202*QR_021001000022); ans_temp[ans_id*36+12]+=Pmtrx[32]*(P_000020002*QR_020002000000+P_000020102*QR_020002000001+P_000020202*QR_020002000002+P_000120002*QR_020002000010+P_000120102*QR_020002000011+P_000120202*QR_020002000012+P_000220002*QR_020002000020+P_000220102*QR_020002000021+P_000220202*QR_020002000022); ans_temp[ans_id*36+12]+=Pmtrx[33]*(P_000020002*QR_021000001000+P_000020102*QR_021000001001+P_000020202*QR_021000001002+P_000120002*QR_021000001010+P_000120102*QR_021000001011+P_000120202*QR_021000001012+P_000220002*QR_021000001020+P_000220102*QR_021000001021+P_000220202*QR_021000001022); ans_temp[ans_id*36+12]+=Pmtrx[34]*(P_000020002*QR_020001001000+P_000020102*QR_020001001001+P_000020202*QR_020001001002+P_000120002*QR_020001001010+P_000120102*QR_020001001011+P_000120202*QR_020001001012+P_000220002*QR_020001001020+P_000220102*QR_020001001021+P_000220202*QR_020001001022); ans_temp[ans_id*36+12]+=Pmtrx[35]*(P_000020002*QR_020000002000+P_000020102*QR_020000002001+P_000020202*QR_020000002002+P_000120002*QR_020000002010+P_000120102*QR_020000002011+P_000120202*QR_020000002012+P_000220002*QR_020000002020+P_000220102*QR_020000002021+P_000220202*QR_020000002022); ans_temp[ans_id*36+13]+=Pmtrx[30]*(P_000020002*QR_012010000000+P_000020102*QR_012010000001+P_000020202*QR_012010000002+P_000120002*QR_012010000010+P_000120102*QR_012010000011+P_000120202*QR_012010000012+P_000220002*QR_012010000020+P_000220102*QR_012010000021+P_000220202*QR_012010000022); ans_temp[ans_id*36+13]+=Pmtrx[31]*(P_000020002*QR_011011000000+P_000020102*QR_011011000001+P_000020202*QR_011011000002+P_000120002*QR_011011000010+P_000120102*QR_011011000011+P_000120202*QR_011011000012+P_000220002*QR_011011000020+P_000220102*QR_011011000021+P_000220202*QR_011011000022); ans_temp[ans_id*36+13]+=Pmtrx[32]*(P_000020002*QR_010012000000+P_000020102*QR_010012000001+P_000020202*QR_010012000002+P_000120002*QR_010012000010+P_000120102*QR_010012000011+P_000120202*QR_010012000012+P_000220002*QR_010012000020+P_000220102*QR_010012000021+P_000220202*QR_010012000022); ans_temp[ans_id*36+13]+=Pmtrx[33]*(P_000020002*QR_011010001000+P_000020102*QR_011010001001+P_000020202*QR_011010001002+P_000120002*QR_011010001010+P_000120102*QR_011010001011+P_000120202*QR_011010001012+P_000220002*QR_011010001020+P_000220102*QR_011010001021+P_000220202*QR_011010001022); ans_temp[ans_id*36+13]+=Pmtrx[34]*(P_000020002*QR_010011001000+P_000020102*QR_010011001001+P_000020202*QR_010011001002+P_000120002*QR_010011001010+P_000120102*QR_010011001011+P_000120202*QR_010011001012+P_000220002*QR_010011001020+P_000220102*QR_010011001021+P_000220202*QR_010011001022); ans_temp[ans_id*36+13]+=Pmtrx[35]*(P_000020002*QR_010010002000+P_000020102*QR_010010002001+P_000020202*QR_010010002002+P_000120002*QR_010010002010+P_000120102*QR_010010002011+P_000120202*QR_010010002012+P_000220002*QR_010010002020+P_000220102*QR_010010002021+P_000220202*QR_010010002022); ans_temp[ans_id*36+14]+=Pmtrx[30]*(P_000020002*QR_002020000000+P_000020102*QR_002020000001+P_000020202*QR_002020000002+P_000120002*QR_002020000010+P_000120102*QR_002020000011+P_000120202*QR_002020000012+P_000220002*QR_002020000020+P_000220102*QR_002020000021+P_000220202*QR_002020000022); ans_temp[ans_id*36+14]+=Pmtrx[31]*(P_000020002*QR_001021000000+P_000020102*QR_001021000001+P_000020202*QR_001021000002+P_000120002*QR_001021000010+P_000120102*QR_001021000011+P_000120202*QR_001021000012+P_000220002*QR_001021000020+P_000220102*QR_001021000021+P_000220202*QR_001021000022); ans_temp[ans_id*36+14]+=Pmtrx[32]*(P_000020002*QR_000022000000+P_000020102*QR_000022000001+P_000020202*QR_000022000002+P_000120002*QR_000022000010+P_000120102*QR_000022000011+P_000120202*QR_000022000012+P_000220002*QR_000022000020+P_000220102*QR_000022000021+P_000220202*QR_000022000022); ans_temp[ans_id*36+14]+=Pmtrx[33]*(P_000020002*QR_001020001000+P_000020102*QR_001020001001+P_000020202*QR_001020001002+P_000120002*QR_001020001010+P_000120102*QR_001020001011+P_000120202*QR_001020001012+P_000220002*QR_001020001020+P_000220102*QR_001020001021+P_000220202*QR_001020001022); ans_temp[ans_id*36+14]+=Pmtrx[34]*(P_000020002*QR_000021001000+P_000020102*QR_000021001001+P_000020202*QR_000021001002+P_000120002*QR_000021001010+P_000120102*QR_000021001011+P_000120202*QR_000021001012+P_000220002*QR_000021001020+P_000220102*QR_000021001021+P_000220202*QR_000021001022); ans_temp[ans_id*36+14]+=Pmtrx[35]*(P_000020002*QR_000020002000+P_000020102*QR_000020002001+P_000020202*QR_000020002002+P_000120002*QR_000020002010+P_000120102*QR_000020002011+P_000120202*QR_000020002012+P_000220002*QR_000020002020+P_000220102*QR_000020002021+P_000220202*QR_000020002022); ans_temp[ans_id*36+15]+=Pmtrx[30]*(P_000020002*QR_012000010000+P_000020102*QR_012000010001+P_000020202*QR_012000010002+P_000120002*QR_012000010010+P_000120102*QR_012000010011+P_000120202*QR_012000010012+P_000220002*QR_012000010020+P_000220102*QR_012000010021+P_000220202*QR_012000010022); ans_temp[ans_id*36+15]+=Pmtrx[31]*(P_000020002*QR_011001010000+P_000020102*QR_011001010001+P_000020202*QR_011001010002+P_000120002*QR_011001010010+P_000120102*QR_011001010011+P_000120202*QR_011001010012+P_000220002*QR_011001010020+P_000220102*QR_011001010021+P_000220202*QR_011001010022); ans_temp[ans_id*36+15]+=Pmtrx[32]*(P_000020002*QR_010002010000+P_000020102*QR_010002010001+P_000020202*QR_010002010002+P_000120002*QR_010002010010+P_000120102*QR_010002010011+P_000120202*QR_010002010012+P_000220002*QR_010002010020+P_000220102*QR_010002010021+P_000220202*QR_010002010022); ans_temp[ans_id*36+15]+=Pmtrx[33]*(P_000020002*QR_011000011000+P_000020102*QR_011000011001+P_000020202*QR_011000011002+P_000120002*QR_011000011010+P_000120102*QR_011000011011+P_000120202*QR_011000011012+P_000220002*QR_011000011020+P_000220102*QR_011000011021+P_000220202*QR_011000011022); ans_temp[ans_id*36+15]+=Pmtrx[34]*(P_000020002*QR_010001011000+P_000020102*QR_010001011001+P_000020202*QR_010001011002+P_000120002*QR_010001011010+P_000120102*QR_010001011011+P_000120202*QR_010001011012+P_000220002*QR_010001011020+P_000220102*QR_010001011021+P_000220202*QR_010001011022); ans_temp[ans_id*36+15]+=Pmtrx[35]*(P_000020002*QR_010000012000+P_000020102*QR_010000012001+P_000020202*QR_010000012002+P_000120002*QR_010000012010+P_000120102*QR_010000012011+P_000120202*QR_010000012012+P_000220002*QR_010000012020+P_000220102*QR_010000012021+P_000220202*QR_010000012022); ans_temp[ans_id*36+16]+=Pmtrx[30]*(P_000020002*QR_002010010000+P_000020102*QR_002010010001+P_000020202*QR_002010010002+P_000120002*QR_002010010010+P_000120102*QR_002010010011+P_000120202*QR_002010010012+P_000220002*QR_002010010020+P_000220102*QR_002010010021+P_000220202*QR_002010010022); ans_temp[ans_id*36+16]+=Pmtrx[31]*(P_000020002*QR_001011010000+P_000020102*QR_001011010001+P_000020202*QR_001011010002+P_000120002*QR_001011010010+P_000120102*QR_001011010011+P_000120202*QR_001011010012+P_000220002*QR_001011010020+P_000220102*QR_001011010021+P_000220202*QR_001011010022); ans_temp[ans_id*36+16]+=Pmtrx[32]*(P_000020002*QR_000012010000+P_000020102*QR_000012010001+P_000020202*QR_000012010002+P_000120002*QR_000012010010+P_000120102*QR_000012010011+P_000120202*QR_000012010012+P_000220002*QR_000012010020+P_000220102*QR_000012010021+P_000220202*QR_000012010022); ans_temp[ans_id*36+16]+=Pmtrx[33]*(P_000020002*QR_001010011000+P_000020102*QR_001010011001+P_000020202*QR_001010011002+P_000120002*QR_001010011010+P_000120102*QR_001010011011+P_000120202*QR_001010011012+P_000220002*QR_001010011020+P_000220102*QR_001010011021+P_000220202*QR_001010011022); ans_temp[ans_id*36+16]+=Pmtrx[34]*(P_000020002*QR_000011011000+P_000020102*QR_000011011001+P_000020202*QR_000011011002+P_000120002*QR_000011011010+P_000120102*QR_000011011011+P_000120202*QR_000011011012+P_000220002*QR_000011011020+P_000220102*QR_000011011021+P_000220202*QR_000011011022); ans_temp[ans_id*36+16]+=Pmtrx[35]*(P_000020002*QR_000010012000+P_000020102*QR_000010012001+P_000020202*QR_000010012002+P_000120002*QR_000010012010+P_000120102*QR_000010012011+P_000120202*QR_000010012012+P_000220002*QR_000010012020+P_000220102*QR_000010012021+P_000220202*QR_000010012022); ans_temp[ans_id*36+17]+=Pmtrx[30]*(P_000020002*QR_002000020000+P_000020102*QR_002000020001+P_000020202*QR_002000020002+P_000120002*QR_002000020010+P_000120102*QR_002000020011+P_000120202*QR_002000020012+P_000220002*QR_002000020020+P_000220102*QR_002000020021+P_000220202*QR_002000020022); ans_temp[ans_id*36+17]+=Pmtrx[31]*(P_000020002*QR_001001020000+P_000020102*QR_001001020001+P_000020202*QR_001001020002+P_000120002*QR_001001020010+P_000120102*QR_001001020011+P_000120202*QR_001001020012+P_000220002*QR_001001020020+P_000220102*QR_001001020021+P_000220202*QR_001001020022); ans_temp[ans_id*36+17]+=Pmtrx[32]*(P_000020002*QR_000002020000+P_000020102*QR_000002020001+P_000020202*QR_000002020002+P_000120002*QR_000002020010+P_000120102*QR_000002020011+P_000120202*QR_000002020012+P_000220002*QR_000002020020+P_000220102*QR_000002020021+P_000220202*QR_000002020022); ans_temp[ans_id*36+17]+=Pmtrx[33]*(P_000020002*QR_001000021000+P_000020102*QR_001000021001+P_000020202*QR_001000021002+P_000120002*QR_001000021010+P_000120102*QR_001000021011+P_000120202*QR_001000021012+P_000220002*QR_001000021020+P_000220102*QR_001000021021+P_000220202*QR_001000021022); ans_temp[ans_id*36+17]+=Pmtrx[34]*(P_000020002*QR_000001021000+P_000020102*QR_000001021001+P_000020202*QR_000001021002+P_000120002*QR_000001021010+P_000120102*QR_000001021011+P_000120202*QR_000001021012+P_000220002*QR_000001021020+P_000220102*QR_000001021021+P_000220202*QR_000001021022); ans_temp[ans_id*36+17]+=Pmtrx[35]*(P_000020002*QR_000000022000+P_000020102*QR_000000022001+P_000020202*QR_000000022002+P_000120002*QR_000000022010+P_000120102*QR_000000022011+P_000120202*QR_000000022012+P_000220002*QR_000000022020+P_000220102*QR_000000022021+P_000220202*QR_000000022022); ans_temp[ans_id*36+18]+=Pmtrx[0]*(P_012000010*QR_022000000000+P_012000110*QR_022000000001+P_112000010*QR_022000000100+P_112000110*QR_022000000101+P_212000010*QR_022000000200+P_212000110*QR_022000000201+P_312000010*QR_022000000300+P_312000110*QR_022000000301); ans_temp[ans_id*36+18]+=Pmtrx[1]*(P_012000010*QR_021001000000+P_012000110*QR_021001000001+P_112000010*QR_021001000100+P_112000110*QR_021001000101+P_212000010*QR_021001000200+P_212000110*QR_021001000201+P_312000010*QR_021001000300+P_312000110*QR_021001000301); ans_temp[ans_id*36+18]+=Pmtrx[2]*(P_012000010*QR_020002000000+P_012000110*QR_020002000001+P_112000010*QR_020002000100+P_112000110*QR_020002000101+P_212000010*QR_020002000200+P_212000110*QR_020002000201+P_312000010*QR_020002000300+P_312000110*QR_020002000301); ans_temp[ans_id*36+18]+=Pmtrx[3]*(P_012000010*QR_021000001000+P_012000110*QR_021000001001+P_112000010*QR_021000001100+P_112000110*QR_021000001101+P_212000010*QR_021000001200+P_212000110*QR_021000001201+P_312000010*QR_021000001300+P_312000110*QR_021000001301); ans_temp[ans_id*36+18]+=Pmtrx[4]*(P_012000010*QR_020001001000+P_012000110*QR_020001001001+P_112000010*QR_020001001100+P_112000110*QR_020001001101+P_212000010*QR_020001001200+P_212000110*QR_020001001201+P_312000010*QR_020001001300+P_312000110*QR_020001001301); ans_temp[ans_id*36+18]+=Pmtrx[5]*(P_012000010*QR_020000002000+P_012000110*QR_020000002001+P_112000010*QR_020000002100+P_112000110*QR_020000002101+P_212000010*QR_020000002200+P_212000110*QR_020000002201+P_312000010*QR_020000002300+P_312000110*QR_020000002301); ans_temp[ans_id*36+19]+=Pmtrx[0]*(P_012000010*QR_012010000000+P_012000110*QR_012010000001+P_112000010*QR_012010000100+P_112000110*QR_012010000101+P_212000010*QR_012010000200+P_212000110*QR_012010000201+P_312000010*QR_012010000300+P_312000110*QR_012010000301); ans_temp[ans_id*36+19]+=Pmtrx[1]*(P_012000010*QR_011011000000+P_012000110*QR_011011000001+P_112000010*QR_011011000100+P_112000110*QR_011011000101+P_212000010*QR_011011000200+P_212000110*QR_011011000201+P_312000010*QR_011011000300+P_312000110*QR_011011000301); ans_temp[ans_id*36+19]+=Pmtrx[2]*(P_012000010*QR_010012000000+P_012000110*QR_010012000001+P_112000010*QR_010012000100+P_112000110*QR_010012000101+P_212000010*QR_010012000200+P_212000110*QR_010012000201+P_312000010*QR_010012000300+P_312000110*QR_010012000301); ans_temp[ans_id*36+19]+=Pmtrx[3]*(P_012000010*QR_011010001000+P_012000110*QR_011010001001+P_112000010*QR_011010001100+P_112000110*QR_011010001101+P_212000010*QR_011010001200+P_212000110*QR_011010001201+P_312000010*QR_011010001300+P_312000110*QR_011010001301); ans_temp[ans_id*36+19]+=Pmtrx[4]*(P_012000010*QR_010011001000+P_012000110*QR_010011001001+P_112000010*QR_010011001100+P_112000110*QR_010011001101+P_212000010*QR_010011001200+P_212000110*QR_010011001201+P_312000010*QR_010011001300+P_312000110*QR_010011001301); ans_temp[ans_id*36+19]+=Pmtrx[5]*(P_012000010*QR_010010002000+P_012000110*QR_010010002001+P_112000010*QR_010010002100+P_112000110*QR_010010002101+P_212000010*QR_010010002200+P_212000110*QR_010010002201+P_312000010*QR_010010002300+P_312000110*QR_010010002301); ans_temp[ans_id*36+20]+=Pmtrx[0]*(P_012000010*QR_002020000000+P_012000110*QR_002020000001+P_112000010*QR_002020000100+P_112000110*QR_002020000101+P_212000010*QR_002020000200+P_212000110*QR_002020000201+P_312000010*QR_002020000300+P_312000110*QR_002020000301); ans_temp[ans_id*36+20]+=Pmtrx[1]*(P_012000010*QR_001021000000+P_012000110*QR_001021000001+P_112000010*QR_001021000100+P_112000110*QR_001021000101+P_212000010*QR_001021000200+P_212000110*QR_001021000201+P_312000010*QR_001021000300+P_312000110*QR_001021000301); ans_temp[ans_id*36+20]+=Pmtrx[2]*(P_012000010*QR_000022000000+P_012000110*QR_000022000001+P_112000010*QR_000022000100+P_112000110*QR_000022000101+P_212000010*QR_000022000200+P_212000110*QR_000022000201+P_312000010*QR_000022000300+P_312000110*QR_000022000301); ans_temp[ans_id*36+20]+=Pmtrx[3]*(P_012000010*QR_001020001000+P_012000110*QR_001020001001+P_112000010*QR_001020001100+P_112000110*QR_001020001101+P_212000010*QR_001020001200+P_212000110*QR_001020001201+P_312000010*QR_001020001300+P_312000110*QR_001020001301); ans_temp[ans_id*36+20]+=Pmtrx[4]*(P_012000010*QR_000021001000+P_012000110*QR_000021001001+P_112000010*QR_000021001100+P_112000110*QR_000021001101+P_212000010*QR_000021001200+P_212000110*QR_000021001201+P_312000010*QR_000021001300+P_312000110*QR_000021001301); ans_temp[ans_id*36+20]+=Pmtrx[5]*(P_012000010*QR_000020002000+P_012000110*QR_000020002001+P_112000010*QR_000020002100+P_112000110*QR_000020002101+P_212000010*QR_000020002200+P_212000110*QR_000020002201+P_312000010*QR_000020002300+P_312000110*QR_000020002301); ans_temp[ans_id*36+21]+=Pmtrx[0]*(P_012000010*QR_012000010000+P_012000110*QR_012000010001+P_112000010*QR_012000010100+P_112000110*QR_012000010101+P_212000010*QR_012000010200+P_212000110*QR_012000010201+P_312000010*QR_012000010300+P_312000110*QR_012000010301); ans_temp[ans_id*36+21]+=Pmtrx[1]*(P_012000010*QR_011001010000+P_012000110*QR_011001010001+P_112000010*QR_011001010100+P_112000110*QR_011001010101+P_212000010*QR_011001010200+P_212000110*QR_011001010201+P_312000010*QR_011001010300+P_312000110*QR_011001010301); ans_temp[ans_id*36+21]+=Pmtrx[2]*(P_012000010*QR_010002010000+P_012000110*QR_010002010001+P_112000010*QR_010002010100+P_112000110*QR_010002010101+P_212000010*QR_010002010200+P_212000110*QR_010002010201+P_312000010*QR_010002010300+P_312000110*QR_010002010301); ans_temp[ans_id*36+21]+=Pmtrx[3]*(P_012000010*QR_011000011000+P_012000110*QR_011000011001+P_112000010*QR_011000011100+P_112000110*QR_011000011101+P_212000010*QR_011000011200+P_212000110*QR_011000011201+P_312000010*QR_011000011300+P_312000110*QR_011000011301); ans_temp[ans_id*36+21]+=Pmtrx[4]*(P_012000010*QR_010001011000+P_012000110*QR_010001011001+P_112000010*QR_010001011100+P_112000110*QR_010001011101+P_212000010*QR_010001011200+P_212000110*QR_010001011201+P_312000010*QR_010001011300+P_312000110*QR_010001011301); ans_temp[ans_id*36+21]+=Pmtrx[5]*(P_012000010*QR_010000012000+P_012000110*QR_010000012001+P_112000010*QR_010000012100+P_112000110*QR_010000012101+P_212000010*QR_010000012200+P_212000110*QR_010000012201+P_312000010*QR_010000012300+P_312000110*QR_010000012301); ans_temp[ans_id*36+22]+=Pmtrx[0]*(P_012000010*QR_002010010000+P_012000110*QR_002010010001+P_112000010*QR_002010010100+P_112000110*QR_002010010101+P_212000010*QR_002010010200+P_212000110*QR_002010010201+P_312000010*QR_002010010300+P_312000110*QR_002010010301); ans_temp[ans_id*36+22]+=Pmtrx[1]*(P_012000010*QR_001011010000+P_012000110*QR_001011010001+P_112000010*QR_001011010100+P_112000110*QR_001011010101+P_212000010*QR_001011010200+P_212000110*QR_001011010201+P_312000010*QR_001011010300+P_312000110*QR_001011010301); ans_temp[ans_id*36+22]+=Pmtrx[2]*(P_012000010*QR_000012010000+P_012000110*QR_000012010001+P_112000010*QR_000012010100+P_112000110*QR_000012010101+P_212000010*QR_000012010200+P_212000110*QR_000012010201+P_312000010*QR_000012010300+P_312000110*QR_000012010301); ans_temp[ans_id*36+22]+=Pmtrx[3]*(P_012000010*QR_001010011000+P_012000110*QR_001010011001+P_112000010*QR_001010011100+P_112000110*QR_001010011101+P_212000010*QR_001010011200+P_212000110*QR_001010011201+P_312000010*QR_001010011300+P_312000110*QR_001010011301); ans_temp[ans_id*36+22]+=Pmtrx[4]*(P_012000010*QR_000011011000+P_012000110*QR_000011011001+P_112000010*QR_000011011100+P_112000110*QR_000011011101+P_212000010*QR_000011011200+P_212000110*QR_000011011201+P_312000010*QR_000011011300+P_312000110*QR_000011011301); ans_temp[ans_id*36+22]+=Pmtrx[5]*(P_012000010*QR_000010012000+P_012000110*QR_000010012001+P_112000010*QR_000010012100+P_112000110*QR_000010012101+P_212000010*QR_000010012200+P_212000110*QR_000010012201+P_312000010*QR_000010012300+P_312000110*QR_000010012301); ans_temp[ans_id*36+23]+=Pmtrx[0]*(P_012000010*QR_002000020000+P_012000110*QR_002000020001+P_112000010*QR_002000020100+P_112000110*QR_002000020101+P_212000010*QR_002000020200+P_212000110*QR_002000020201+P_312000010*QR_002000020300+P_312000110*QR_002000020301); ans_temp[ans_id*36+23]+=Pmtrx[1]*(P_012000010*QR_001001020000+P_012000110*QR_001001020001+P_112000010*QR_001001020100+P_112000110*QR_001001020101+P_212000010*QR_001001020200+P_212000110*QR_001001020201+P_312000010*QR_001001020300+P_312000110*QR_001001020301); ans_temp[ans_id*36+23]+=Pmtrx[2]*(P_012000010*QR_000002020000+P_012000110*QR_000002020001+P_112000010*QR_000002020100+P_112000110*QR_000002020101+P_212000010*QR_000002020200+P_212000110*QR_000002020201+P_312000010*QR_000002020300+P_312000110*QR_000002020301); ans_temp[ans_id*36+23]+=Pmtrx[3]*(P_012000010*QR_001000021000+P_012000110*QR_001000021001+P_112000010*QR_001000021100+P_112000110*QR_001000021101+P_212000010*QR_001000021200+P_212000110*QR_001000021201+P_312000010*QR_001000021300+P_312000110*QR_001000021301); ans_temp[ans_id*36+23]+=Pmtrx[4]*(P_012000010*QR_000001021000+P_012000110*QR_000001021001+P_112000010*QR_000001021100+P_112000110*QR_000001021101+P_212000010*QR_000001021200+P_212000110*QR_000001021201+P_312000010*QR_000001021300+P_312000110*QR_000001021301); ans_temp[ans_id*36+23]+=Pmtrx[5]*(P_012000010*QR_000000022000+P_012000110*QR_000000022001+P_112000010*QR_000000022100+P_112000110*QR_000000022101+P_212000010*QR_000000022200+P_212000110*QR_000000022201+P_312000010*QR_000000022300+P_312000110*QR_000000022301); ans_temp[ans_id*36+18]+=Pmtrx[6]*(P_011001010*QR_022000000000+P_011001110*QR_022000000001+P_011101010*QR_022000000010+P_011101110*QR_022000000011+P_111001010*QR_022000000100+P_111001110*QR_022000000101+P_111101010*QR_022000000110+P_111101110*QR_022000000111+P_211001010*QR_022000000200+P_211001110*QR_022000000201+P_211101010*QR_022000000210+P_211101110*QR_022000000211); ans_temp[ans_id*36+18]+=Pmtrx[7]*(P_011001010*QR_021001000000+P_011001110*QR_021001000001+P_011101010*QR_021001000010+P_011101110*QR_021001000011+P_111001010*QR_021001000100+P_111001110*QR_021001000101+P_111101010*QR_021001000110+P_111101110*QR_021001000111+P_211001010*QR_021001000200+P_211001110*QR_021001000201+P_211101010*QR_021001000210+P_211101110*QR_021001000211); ans_temp[ans_id*36+18]+=Pmtrx[8]*(P_011001010*QR_020002000000+P_011001110*QR_020002000001+P_011101010*QR_020002000010+P_011101110*QR_020002000011+P_111001010*QR_020002000100+P_111001110*QR_020002000101+P_111101010*QR_020002000110+P_111101110*QR_020002000111+P_211001010*QR_020002000200+P_211001110*QR_020002000201+P_211101010*QR_020002000210+P_211101110*QR_020002000211); ans_temp[ans_id*36+18]+=Pmtrx[9]*(P_011001010*QR_021000001000+P_011001110*QR_021000001001+P_011101010*QR_021000001010+P_011101110*QR_021000001011+P_111001010*QR_021000001100+P_111001110*QR_021000001101+P_111101010*QR_021000001110+P_111101110*QR_021000001111+P_211001010*QR_021000001200+P_211001110*QR_021000001201+P_211101010*QR_021000001210+P_211101110*QR_021000001211); ans_temp[ans_id*36+18]+=Pmtrx[10]*(P_011001010*QR_020001001000+P_011001110*QR_020001001001+P_011101010*QR_020001001010+P_011101110*QR_020001001011+P_111001010*QR_020001001100+P_111001110*QR_020001001101+P_111101010*QR_020001001110+P_111101110*QR_020001001111+P_211001010*QR_020001001200+P_211001110*QR_020001001201+P_211101010*QR_020001001210+P_211101110*QR_020001001211); ans_temp[ans_id*36+18]+=Pmtrx[11]*(P_011001010*QR_020000002000+P_011001110*QR_020000002001+P_011101010*QR_020000002010+P_011101110*QR_020000002011+P_111001010*QR_020000002100+P_111001110*QR_020000002101+P_111101010*QR_020000002110+P_111101110*QR_020000002111+P_211001010*QR_020000002200+P_211001110*QR_020000002201+P_211101010*QR_020000002210+P_211101110*QR_020000002211); ans_temp[ans_id*36+19]+=Pmtrx[6]*(P_011001010*QR_012010000000+P_011001110*QR_012010000001+P_011101010*QR_012010000010+P_011101110*QR_012010000011+P_111001010*QR_012010000100+P_111001110*QR_012010000101+P_111101010*QR_012010000110+P_111101110*QR_012010000111+P_211001010*QR_012010000200+P_211001110*QR_012010000201+P_211101010*QR_012010000210+P_211101110*QR_012010000211); ans_temp[ans_id*36+19]+=Pmtrx[7]*(P_011001010*QR_011011000000+P_011001110*QR_011011000001+P_011101010*QR_011011000010+P_011101110*QR_011011000011+P_111001010*QR_011011000100+P_111001110*QR_011011000101+P_111101010*QR_011011000110+P_111101110*QR_011011000111+P_211001010*QR_011011000200+P_211001110*QR_011011000201+P_211101010*QR_011011000210+P_211101110*QR_011011000211); ans_temp[ans_id*36+19]+=Pmtrx[8]*(P_011001010*QR_010012000000+P_011001110*QR_010012000001+P_011101010*QR_010012000010+P_011101110*QR_010012000011+P_111001010*QR_010012000100+P_111001110*QR_010012000101+P_111101010*QR_010012000110+P_111101110*QR_010012000111+P_211001010*QR_010012000200+P_211001110*QR_010012000201+P_211101010*QR_010012000210+P_211101110*QR_010012000211); ans_temp[ans_id*36+19]+=Pmtrx[9]*(P_011001010*QR_011010001000+P_011001110*QR_011010001001+P_011101010*QR_011010001010+P_011101110*QR_011010001011+P_111001010*QR_011010001100+P_111001110*QR_011010001101+P_111101010*QR_011010001110+P_111101110*QR_011010001111+P_211001010*QR_011010001200+P_211001110*QR_011010001201+P_211101010*QR_011010001210+P_211101110*QR_011010001211); ans_temp[ans_id*36+19]+=Pmtrx[10]*(P_011001010*QR_010011001000+P_011001110*QR_010011001001+P_011101010*QR_010011001010+P_011101110*QR_010011001011+P_111001010*QR_010011001100+P_111001110*QR_010011001101+P_111101010*QR_010011001110+P_111101110*QR_010011001111+P_211001010*QR_010011001200+P_211001110*QR_010011001201+P_211101010*QR_010011001210+P_211101110*QR_010011001211); ans_temp[ans_id*36+19]+=Pmtrx[11]*(P_011001010*QR_010010002000+P_011001110*QR_010010002001+P_011101010*QR_010010002010+P_011101110*QR_010010002011+P_111001010*QR_010010002100+P_111001110*QR_010010002101+P_111101010*QR_010010002110+P_111101110*QR_010010002111+P_211001010*QR_010010002200+P_211001110*QR_010010002201+P_211101010*QR_010010002210+P_211101110*QR_010010002211); ans_temp[ans_id*36+20]+=Pmtrx[6]*(P_011001010*QR_002020000000+P_011001110*QR_002020000001+P_011101010*QR_002020000010+P_011101110*QR_002020000011+P_111001010*QR_002020000100+P_111001110*QR_002020000101+P_111101010*QR_002020000110+P_111101110*QR_002020000111+P_211001010*QR_002020000200+P_211001110*QR_002020000201+P_211101010*QR_002020000210+P_211101110*QR_002020000211); ans_temp[ans_id*36+20]+=Pmtrx[7]*(P_011001010*QR_001021000000+P_011001110*QR_001021000001+P_011101010*QR_001021000010+P_011101110*QR_001021000011+P_111001010*QR_001021000100+P_111001110*QR_001021000101+P_111101010*QR_001021000110+P_111101110*QR_001021000111+P_211001010*QR_001021000200+P_211001110*QR_001021000201+P_211101010*QR_001021000210+P_211101110*QR_001021000211); ans_temp[ans_id*36+20]+=Pmtrx[8]*(P_011001010*QR_000022000000+P_011001110*QR_000022000001+P_011101010*QR_000022000010+P_011101110*QR_000022000011+P_111001010*QR_000022000100+P_111001110*QR_000022000101+P_111101010*QR_000022000110+P_111101110*QR_000022000111+P_211001010*QR_000022000200+P_211001110*QR_000022000201+P_211101010*QR_000022000210+P_211101110*QR_000022000211); ans_temp[ans_id*36+20]+=Pmtrx[9]*(P_011001010*QR_001020001000+P_011001110*QR_001020001001+P_011101010*QR_001020001010+P_011101110*QR_001020001011+P_111001010*QR_001020001100+P_111001110*QR_001020001101+P_111101010*QR_001020001110+P_111101110*QR_001020001111+P_211001010*QR_001020001200+P_211001110*QR_001020001201+P_211101010*QR_001020001210+P_211101110*QR_001020001211); ans_temp[ans_id*36+20]+=Pmtrx[10]*(P_011001010*QR_000021001000+P_011001110*QR_000021001001+P_011101010*QR_000021001010+P_011101110*QR_000021001011+P_111001010*QR_000021001100+P_111001110*QR_000021001101+P_111101010*QR_000021001110+P_111101110*QR_000021001111+P_211001010*QR_000021001200+P_211001110*QR_000021001201+P_211101010*QR_000021001210+P_211101110*QR_000021001211); ans_temp[ans_id*36+20]+=Pmtrx[11]*(P_011001010*QR_000020002000+P_011001110*QR_000020002001+P_011101010*QR_000020002010+P_011101110*QR_000020002011+P_111001010*QR_000020002100+P_111001110*QR_000020002101+P_111101010*QR_000020002110+P_111101110*QR_000020002111+P_211001010*QR_000020002200+P_211001110*QR_000020002201+P_211101010*QR_000020002210+P_211101110*QR_000020002211); ans_temp[ans_id*36+21]+=Pmtrx[6]*(P_011001010*QR_012000010000+P_011001110*QR_012000010001+P_011101010*QR_012000010010+P_011101110*QR_012000010011+P_111001010*QR_012000010100+P_111001110*QR_012000010101+P_111101010*QR_012000010110+P_111101110*QR_012000010111+P_211001010*QR_012000010200+P_211001110*QR_012000010201+P_211101010*QR_012000010210+P_211101110*QR_012000010211); ans_temp[ans_id*36+21]+=Pmtrx[7]*(P_011001010*QR_011001010000+P_011001110*QR_011001010001+P_011101010*QR_011001010010+P_011101110*QR_011001010011+P_111001010*QR_011001010100+P_111001110*QR_011001010101+P_111101010*QR_011001010110+P_111101110*QR_011001010111+P_211001010*QR_011001010200+P_211001110*QR_011001010201+P_211101010*QR_011001010210+P_211101110*QR_011001010211); ans_temp[ans_id*36+21]+=Pmtrx[8]*(P_011001010*QR_010002010000+P_011001110*QR_010002010001+P_011101010*QR_010002010010+P_011101110*QR_010002010011+P_111001010*QR_010002010100+P_111001110*QR_010002010101+P_111101010*QR_010002010110+P_111101110*QR_010002010111+P_211001010*QR_010002010200+P_211001110*QR_010002010201+P_211101010*QR_010002010210+P_211101110*QR_010002010211); ans_temp[ans_id*36+21]+=Pmtrx[9]*(P_011001010*QR_011000011000+P_011001110*QR_011000011001+P_011101010*QR_011000011010+P_011101110*QR_011000011011+P_111001010*QR_011000011100+P_111001110*QR_011000011101+P_111101010*QR_011000011110+P_111101110*QR_011000011111+P_211001010*QR_011000011200+P_211001110*QR_011000011201+P_211101010*QR_011000011210+P_211101110*QR_011000011211); ans_temp[ans_id*36+21]+=Pmtrx[10]*(P_011001010*QR_010001011000+P_011001110*QR_010001011001+P_011101010*QR_010001011010+P_011101110*QR_010001011011+P_111001010*QR_010001011100+P_111001110*QR_010001011101+P_111101010*QR_010001011110+P_111101110*QR_010001011111+P_211001010*QR_010001011200+P_211001110*QR_010001011201+P_211101010*QR_010001011210+P_211101110*QR_010001011211); ans_temp[ans_id*36+21]+=Pmtrx[11]*(P_011001010*QR_010000012000+P_011001110*QR_010000012001+P_011101010*QR_010000012010+P_011101110*QR_010000012011+P_111001010*QR_010000012100+P_111001110*QR_010000012101+P_111101010*QR_010000012110+P_111101110*QR_010000012111+P_211001010*QR_010000012200+P_211001110*QR_010000012201+P_211101010*QR_010000012210+P_211101110*QR_010000012211); ans_temp[ans_id*36+22]+=Pmtrx[6]*(P_011001010*QR_002010010000+P_011001110*QR_002010010001+P_011101010*QR_002010010010+P_011101110*QR_002010010011+P_111001010*QR_002010010100+P_111001110*QR_002010010101+P_111101010*QR_002010010110+P_111101110*QR_002010010111+P_211001010*QR_002010010200+P_211001110*QR_002010010201+P_211101010*QR_002010010210+P_211101110*QR_002010010211); ans_temp[ans_id*36+22]+=Pmtrx[7]*(P_011001010*QR_001011010000+P_011001110*QR_001011010001+P_011101010*QR_001011010010+P_011101110*QR_001011010011+P_111001010*QR_001011010100+P_111001110*QR_001011010101+P_111101010*QR_001011010110+P_111101110*QR_001011010111+P_211001010*QR_001011010200+P_211001110*QR_001011010201+P_211101010*QR_001011010210+P_211101110*QR_001011010211); ans_temp[ans_id*36+22]+=Pmtrx[8]*(P_011001010*QR_000012010000+P_011001110*QR_000012010001+P_011101010*QR_000012010010+P_011101110*QR_000012010011+P_111001010*QR_000012010100+P_111001110*QR_000012010101+P_111101010*QR_000012010110+P_111101110*QR_000012010111+P_211001010*QR_000012010200+P_211001110*QR_000012010201+P_211101010*QR_000012010210+P_211101110*QR_000012010211); ans_temp[ans_id*36+22]+=Pmtrx[9]*(P_011001010*QR_001010011000+P_011001110*QR_001010011001+P_011101010*QR_001010011010+P_011101110*QR_001010011011+P_111001010*QR_001010011100+P_111001110*QR_001010011101+P_111101010*QR_001010011110+P_111101110*QR_001010011111+P_211001010*QR_001010011200+P_211001110*QR_001010011201+P_211101010*QR_001010011210+P_211101110*QR_001010011211); ans_temp[ans_id*36+22]+=Pmtrx[10]*(P_011001010*QR_000011011000+P_011001110*QR_000011011001+P_011101010*QR_000011011010+P_011101110*QR_000011011011+P_111001010*QR_000011011100+P_111001110*QR_000011011101+P_111101010*QR_000011011110+P_111101110*QR_000011011111+P_211001010*QR_000011011200+P_211001110*QR_000011011201+P_211101010*QR_000011011210+P_211101110*QR_000011011211); ans_temp[ans_id*36+22]+=Pmtrx[11]*(P_011001010*QR_000010012000+P_011001110*QR_000010012001+P_011101010*QR_000010012010+P_011101110*QR_000010012011+P_111001010*QR_000010012100+P_111001110*QR_000010012101+P_111101010*QR_000010012110+P_111101110*QR_000010012111+P_211001010*QR_000010012200+P_211001110*QR_000010012201+P_211101010*QR_000010012210+P_211101110*QR_000010012211); ans_temp[ans_id*36+23]+=Pmtrx[6]*(P_011001010*QR_002000020000+P_011001110*QR_002000020001+P_011101010*QR_002000020010+P_011101110*QR_002000020011+P_111001010*QR_002000020100+P_111001110*QR_002000020101+P_111101010*QR_002000020110+P_111101110*QR_002000020111+P_211001010*QR_002000020200+P_211001110*QR_002000020201+P_211101010*QR_002000020210+P_211101110*QR_002000020211); ans_temp[ans_id*36+23]+=Pmtrx[7]*(P_011001010*QR_001001020000+P_011001110*QR_001001020001+P_011101010*QR_001001020010+P_011101110*QR_001001020011+P_111001010*QR_001001020100+P_111001110*QR_001001020101+P_111101010*QR_001001020110+P_111101110*QR_001001020111+P_211001010*QR_001001020200+P_211001110*QR_001001020201+P_211101010*QR_001001020210+P_211101110*QR_001001020211); ans_temp[ans_id*36+23]+=Pmtrx[8]*(P_011001010*QR_000002020000+P_011001110*QR_000002020001+P_011101010*QR_000002020010+P_011101110*QR_000002020011+P_111001010*QR_000002020100+P_111001110*QR_000002020101+P_111101010*QR_000002020110+P_111101110*QR_000002020111+P_211001010*QR_000002020200+P_211001110*QR_000002020201+P_211101010*QR_000002020210+P_211101110*QR_000002020211); ans_temp[ans_id*36+23]+=Pmtrx[9]*(P_011001010*QR_001000021000+P_011001110*QR_001000021001+P_011101010*QR_001000021010+P_011101110*QR_001000021011+P_111001010*QR_001000021100+P_111001110*QR_001000021101+P_111101010*QR_001000021110+P_111101110*QR_001000021111+P_211001010*QR_001000021200+P_211001110*QR_001000021201+P_211101010*QR_001000021210+P_211101110*QR_001000021211); ans_temp[ans_id*36+23]+=Pmtrx[10]*(P_011001010*QR_000001021000+P_011001110*QR_000001021001+P_011101010*QR_000001021010+P_011101110*QR_000001021011+P_111001010*QR_000001021100+P_111001110*QR_000001021101+P_111101010*QR_000001021110+P_111101110*QR_000001021111+P_211001010*QR_000001021200+P_211001110*QR_000001021201+P_211101010*QR_000001021210+P_211101110*QR_000001021211); ans_temp[ans_id*36+23]+=Pmtrx[11]*(P_011001010*QR_000000022000+P_011001110*QR_000000022001+P_011101010*QR_000000022010+P_011101110*QR_000000022011+P_111001010*QR_000000022100+P_111001110*QR_000000022101+P_111101010*QR_000000022110+P_111101110*QR_000000022111+P_211001010*QR_000000022200+P_211001110*QR_000000022201+P_211101010*QR_000000022210+P_211101110*QR_000000022211); ans_temp[ans_id*36+18]+=Pmtrx[12]*(P_010002010*QR_022000000000+P_010002110*QR_022000000001+P_010102010*QR_022000000010+P_010102110*QR_022000000011+P_010202010*QR_022000000020+P_010202110*QR_022000000021+P_110002010*QR_022000000100+P_110002110*QR_022000000101+P_110102010*QR_022000000110+P_110102110*QR_022000000111+P_110202010*QR_022000000120+P_110202110*QR_022000000121); ans_temp[ans_id*36+18]+=Pmtrx[13]*(P_010002010*QR_021001000000+P_010002110*QR_021001000001+P_010102010*QR_021001000010+P_010102110*QR_021001000011+P_010202010*QR_021001000020+P_010202110*QR_021001000021+P_110002010*QR_021001000100+P_110002110*QR_021001000101+P_110102010*QR_021001000110+P_110102110*QR_021001000111+P_110202010*QR_021001000120+P_110202110*QR_021001000121); ans_temp[ans_id*36+18]+=Pmtrx[14]*(P_010002010*QR_020002000000+P_010002110*QR_020002000001+P_010102010*QR_020002000010+P_010102110*QR_020002000011+P_010202010*QR_020002000020+P_010202110*QR_020002000021+P_110002010*QR_020002000100+P_110002110*QR_020002000101+P_110102010*QR_020002000110+P_110102110*QR_020002000111+P_110202010*QR_020002000120+P_110202110*QR_020002000121); ans_temp[ans_id*36+18]+=Pmtrx[15]*(P_010002010*QR_021000001000+P_010002110*QR_021000001001+P_010102010*QR_021000001010+P_010102110*QR_021000001011+P_010202010*QR_021000001020+P_010202110*QR_021000001021+P_110002010*QR_021000001100+P_110002110*QR_021000001101+P_110102010*QR_021000001110+P_110102110*QR_021000001111+P_110202010*QR_021000001120+P_110202110*QR_021000001121); ans_temp[ans_id*36+18]+=Pmtrx[16]*(P_010002010*QR_020001001000+P_010002110*QR_020001001001+P_010102010*QR_020001001010+P_010102110*QR_020001001011+P_010202010*QR_020001001020+P_010202110*QR_020001001021+P_110002010*QR_020001001100+P_110002110*QR_020001001101+P_110102010*QR_020001001110+P_110102110*QR_020001001111+P_110202010*QR_020001001120+P_110202110*QR_020001001121); ans_temp[ans_id*36+18]+=Pmtrx[17]*(P_010002010*QR_020000002000+P_010002110*QR_020000002001+P_010102010*QR_020000002010+P_010102110*QR_020000002011+P_010202010*QR_020000002020+P_010202110*QR_020000002021+P_110002010*QR_020000002100+P_110002110*QR_020000002101+P_110102010*QR_020000002110+P_110102110*QR_020000002111+P_110202010*QR_020000002120+P_110202110*QR_020000002121); ans_temp[ans_id*36+19]+=Pmtrx[12]*(P_010002010*QR_012010000000+P_010002110*QR_012010000001+P_010102010*QR_012010000010+P_010102110*QR_012010000011+P_010202010*QR_012010000020+P_010202110*QR_012010000021+P_110002010*QR_012010000100+P_110002110*QR_012010000101+P_110102010*QR_012010000110+P_110102110*QR_012010000111+P_110202010*QR_012010000120+P_110202110*QR_012010000121); ans_temp[ans_id*36+19]+=Pmtrx[13]*(P_010002010*QR_011011000000+P_010002110*QR_011011000001+P_010102010*QR_011011000010+P_010102110*QR_011011000011+P_010202010*QR_011011000020+P_010202110*QR_011011000021+P_110002010*QR_011011000100+P_110002110*QR_011011000101+P_110102010*QR_011011000110+P_110102110*QR_011011000111+P_110202010*QR_011011000120+P_110202110*QR_011011000121); ans_temp[ans_id*36+19]+=Pmtrx[14]*(P_010002010*QR_010012000000+P_010002110*QR_010012000001+P_010102010*QR_010012000010+P_010102110*QR_010012000011+P_010202010*QR_010012000020+P_010202110*QR_010012000021+P_110002010*QR_010012000100+P_110002110*QR_010012000101+P_110102010*QR_010012000110+P_110102110*QR_010012000111+P_110202010*QR_010012000120+P_110202110*QR_010012000121); ans_temp[ans_id*36+19]+=Pmtrx[15]*(P_010002010*QR_011010001000+P_010002110*QR_011010001001+P_010102010*QR_011010001010+P_010102110*QR_011010001011+P_010202010*QR_011010001020+P_010202110*QR_011010001021+P_110002010*QR_011010001100+P_110002110*QR_011010001101+P_110102010*QR_011010001110+P_110102110*QR_011010001111+P_110202010*QR_011010001120+P_110202110*QR_011010001121); ans_temp[ans_id*36+19]+=Pmtrx[16]*(P_010002010*QR_010011001000+P_010002110*QR_010011001001+P_010102010*QR_010011001010+P_010102110*QR_010011001011+P_010202010*QR_010011001020+P_010202110*QR_010011001021+P_110002010*QR_010011001100+P_110002110*QR_010011001101+P_110102010*QR_010011001110+P_110102110*QR_010011001111+P_110202010*QR_010011001120+P_110202110*QR_010011001121); ans_temp[ans_id*36+19]+=Pmtrx[17]*(P_010002010*QR_010010002000+P_010002110*QR_010010002001+P_010102010*QR_010010002010+P_010102110*QR_010010002011+P_010202010*QR_010010002020+P_010202110*QR_010010002021+P_110002010*QR_010010002100+P_110002110*QR_010010002101+P_110102010*QR_010010002110+P_110102110*QR_010010002111+P_110202010*QR_010010002120+P_110202110*QR_010010002121); ans_temp[ans_id*36+20]+=Pmtrx[12]*(P_010002010*QR_002020000000+P_010002110*QR_002020000001+P_010102010*QR_002020000010+P_010102110*QR_002020000011+P_010202010*QR_002020000020+P_010202110*QR_002020000021+P_110002010*QR_002020000100+P_110002110*QR_002020000101+P_110102010*QR_002020000110+P_110102110*QR_002020000111+P_110202010*QR_002020000120+P_110202110*QR_002020000121); ans_temp[ans_id*36+20]+=Pmtrx[13]*(P_010002010*QR_001021000000+P_010002110*QR_001021000001+P_010102010*QR_001021000010+P_010102110*QR_001021000011+P_010202010*QR_001021000020+P_010202110*QR_001021000021+P_110002010*QR_001021000100+P_110002110*QR_001021000101+P_110102010*QR_001021000110+P_110102110*QR_001021000111+P_110202010*QR_001021000120+P_110202110*QR_001021000121); ans_temp[ans_id*36+20]+=Pmtrx[14]*(P_010002010*QR_000022000000+P_010002110*QR_000022000001+P_010102010*QR_000022000010+P_010102110*QR_000022000011+P_010202010*QR_000022000020+P_010202110*QR_000022000021+P_110002010*QR_000022000100+P_110002110*QR_000022000101+P_110102010*QR_000022000110+P_110102110*QR_000022000111+P_110202010*QR_000022000120+P_110202110*QR_000022000121); ans_temp[ans_id*36+20]+=Pmtrx[15]*(P_010002010*QR_001020001000+P_010002110*QR_001020001001+P_010102010*QR_001020001010+P_010102110*QR_001020001011+P_010202010*QR_001020001020+P_010202110*QR_001020001021+P_110002010*QR_001020001100+P_110002110*QR_001020001101+P_110102010*QR_001020001110+P_110102110*QR_001020001111+P_110202010*QR_001020001120+P_110202110*QR_001020001121); ans_temp[ans_id*36+20]+=Pmtrx[16]*(P_010002010*QR_000021001000+P_010002110*QR_000021001001+P_010102010*QR_000021001010+P_010102110*QR_000021001011+P_010202010*QR_000021001020+P_010202110*QR_000021001021+P_110002010*QR_000021001100+P_110002110*QR_000021001101+P_110102010*QR_000021001110+P_110102110*QR_000021001111+P_110202010*QR_000021001120+P_110202110*QR_000021001121); ans_temp[ans_id*36+20]+=Pmtrx[17]*(P_010002010*QR_000020002000+P_010002110*QR_000020002001+P_010102010*QR_000020002010+P_010102110*QR_000020002011+P_010202010*QR_000020002020+P_010202110*QR_000020002021+P_110002010*QR_000020002100+P_110002110*QR_000020002101+P_110102010*QR_000020002110+P_110102110*QR_000020002111+P_110202010*QR_000020002120+P_110202110*QR_000020002121); ans_temp[ans_id*36+21]+=Pmtrx[12]*(P_010002010*QR_012000010000+P_010002110*QR_012000010001+P_010102010*QR_012000010010+P_010102110*QR_012000010011+P_010202010*QR_012000010020+P_010202110*QR_012000010021+P_110002010*QR_012000010100+P_110002110*QR_012000010101+P_110102010*QR_012000010110+P_110102110*QR_012000010111+P_110202010*QR_012000010120+P_110202110*QR_012000010121); ans_temp[ans_id*36+21]+=Pmtrx[13]*(P_010002010*QR_011001010000+P_010002110*QR_011001010001+P_010102010*QR_011001010010+P_010102110*QR_011001010011+P_010202010*QR_011001010020+P_010202110*QR_011001010021+P_110002010*QR_011001010100+P_110002110*QR_011001010101+P_110102010*QR_011001010110+P_110102110*QR_011001010111+P_110202010*QR_011001010120+P_110202110*QR_011001010121); ans_temp[ans_id*36+21]+=Pmtrx[14]*(P_010002010*QR_010002010000+P_010002110*QR_010002010001+P_010102010*QR_010002010010+P_010102110*QR_010002010011+P_010202010*QR_010002010020+P_010202110*QR_010002010021+P_110002010*QR_010002010100+P_110002110*QR_010002010101+P_110102010*QR_010002010110+P_110102110*QR_010002010111+P_110202010*QR_010002010120+P_110202110*QR_010002010121); ans_temp[ans_id*36+21]+=Pmtrx[15]*(P_010002010*QR_011000011000+P_010002110*QR_011000011001+P_010102010*QR_011000011010+P_010102110*QR_011000011011+P_010202010*QR_011000011020+P_010202110*QR_011000011021+P_110002010*QR_011000011100+P_110002110*QR_011000011101+P_110102010*QR_011000011110+P_110102110*QR_011000011111+P_110202010*QR_011000011120+P_110202110*QR_011000011121); ans_temp[ans_id*36+21]+=Pmtrx[16]*(P_010002010*QR_010001011000+P_010002110*QR_010001011001+P_010102010*QR_010001011010+P_010102110*QR_010001011011+P_010202010*QR_010001011020+P_010202110*QR_010001011021+P_110002010*QR_010001011100+P_110002110*QR_010001011101+P_110102010*QR_010001011110+P_110102110*QR_010001011111+P_110202010*QR_010001011120+P_110202110*QR_010001011121); ans_temp[ans_id*36+21]+=Pmtrx[17]*(P_010002010*QR_010000012000+P_010002110*QR_010000012001+P_010102010*QR_010000012010+P_010102110*QR_010000012011+P_010202010*QR_010000012020+P_010202110*QR_010000012021+P_110002010*QR_010000012100+P_110002110*QR_010000012101+P_110102010*QR_010000012110+P_110102110*QR_010000012111+P_110202010*QR_010000012120+P_110202110*QR_010000012121); ans_temp[ans_id*36+22]+=Pmtrx[12]*(P_010002010*QR_002010010000+P_010002110*QR_002010010001+P_010102010*QR_002010010010+P_010102110*QR_002010010011+P_010202010*QR_002010010020+P_010202110*QR_002010010021+P_110002010*QR_002010010100+P_110002110*QR_002010010101+P_110102010*QR_002010010110+P_110102110*QR_002010010111+P_110202010*QR_002010010120+P_110202110*QR_002010010121); ans_temp[ans_id*36+22]+=Pmtrx[13]*(P_010002010*QR_001011010000+P_010002110*QR_001011010001+P_010102010*QR_001011010010+P_010102110*QR_001011010011+P_010202010*QR_001011010020+P_010202110*QR_001011010021+P_110002010*QR_001011010100+P_110002110*QR_001011010101+P_110102010*QR_001011010110+P_110102110*QR_001011010111+P_110202010*QR_001011010120+P_110202110*QR_001011010121); ans_temp[ans_id*36+22]+=Pmtrx[14]*(P_010002010*QR_000012010000+P_010002110*QR_000012010001+P_010102010*QR_000012010010+P_010102110*QR_000012010011+P_010202010*QR_000012010020+P_010202110*QR_000012010021+P_110002010*QR_000012010100+P_110002110*QR_000012010101+P_110102010*QR_000012010110+P_110102110*QR_000012010111+P_110202010*QR_000012010120+P_110202110*QR_000012010121); ans_temp[ans_id*36+22]+=Pmtrx[15]*(P_010002010*QR_001010011000+P_010002110*QR_001010011001+P_010102010*QR_001010011010+P_010102110*QR_001010011011+P_010202010*QR_001010011020+P_010202110*QR_001010011021+P_110002010*QR_001010011100+P_110002110*QR_001010011101+P_110102010*QR_001010011110+P_110102110*QR_001010011111+P_110202010*QR_001010011120+P_110202110*QR_001010011121); ans_temp[ans_id*36+22]+=Pmtrx[16]*(P_010002010*QR_000011011000+P_010002110*QR_000011011001+P_010102010*QR_000011011010+P_010102110*QR_000011011011+P_010202010*QR_000011011020+P_010202110*QR_000011011021+P_110002010*QR_000011011100+P_110002110*QR_000011011101+P_110102010*QR_000011011110+P_110102110*QR_000011011111+P_110202010*QR_000011011120+P_110202110*QR_000011011121); ans_temp[ans_id*36+22]+=Pmtrx[17]*(P_010002010*QR_000010012000+P_010002110*QR_000010012001+P_010102010*QR_000010012010+P_010102110*QR_000010012011+P_010202010*QR_000010012020+P_010202110*QR_000010012021+P_110002010*QR_000010012100+P_110002110*QR_000010012101+P_110102010*QR_000010012110+P_110102110*QR_000010012111+P_110202010*QR_000010012120+P_110202110*QR_000010012121); ans_temp[ans_id*36+23]+=Pmtrx[12]*(P_010002010*QR_002000020000+P_010002110*QR_002000020001+P_010102010*QR_002000020010+P_010102110*QR_002000020011+P_010202010*QR_002000020020+P_010202110*QR_002000020021+P_110002010*QR_002000020100+P_110002110*QR_002000020101+P_110102010*QR_002000020110+P_110102110*QR_002000020111+P_110202010*QR_002000020120+P_110202110*QR_002000020121); ans_temp[ans_id*36+23]+=Pmtrx[13]*(P_010002010*QR_001001020000+P_010002110*QR_001001020001+P_010102010*QR_001001020010+P_010102110*QR_001001020011+P_010202010*QR_001001020020+P_010202110*QR_001001020021+P_110002010*QR_001001020100+P_110002110*QR_001001020101+P_110102010*QR_001001020110+P_110102110*QR_001001020111+P_110202010*QR_001001020120+P_110202110*QR_001001020121); ans_temp[ans_id*36+23]+=Pmtrx[14]*(P_010002010*QR_000002020000+P_010002110*QR_000002020001+P_010102010*QR_000002020010+P_010102110*QR_000002020011+P_010202010*QR_000002020020+P_010202110*QR_000002020021+P_110002010*QR_000002020100+P_110002110*QR_000002020101+P_110102010*QR_000002020110+P_110102110*QR_000002020111+P_110202010*QR_000002020120+P_110202110*QR_000002020121); ans_temp[ans_id*36+23]+=Pmtrx[15]*(P_010002010*QR_001000021000+P_010002110*QR_001000021001+P_010102010*QR_001000021010+P_010102110*QR_001000021011+P_010202010*QR_001000021020+P_010202110*QR_001000021021+P_110002010*QR_001000021100+P_110002110*QR_001000021101+P_110102010*QR_001000021110+P_110102110*QR_001000021111+P_110202010*QR_001000021120+P_110202110*QR_001000021121); ans_temp[ans_id*36+23]+=Pmtrx[16]*(P_010002010*QR_000001021000+P_010002110*QR_000001021001+P_010102010*QR_000001021010+P_010102110*QR_000001021011+P_010202010*QR_000001021020+P_010202110*QR_000001021021+P_110002010*QR_000001021100+P_110002110*QR_000001021101+P_110102010*QR_000001021110+P_110102110*QR_000001021111+P_110202010*QR_000001021120+P_110202110*QR_000001021121); ans_temp[ans_id*36+23]+=Pmtrx[17]*(P_010002010*QR_000000022000+P_010002110*QR_000000022001+P_010102010*QR_000000022010+P_010102110*QR_000000022011+P_010202010*QR_000000022020+P_010202110*QR_000000022021+P_110002010*QR_000000022100+P_110002110*QR_000000022101+P_110102010*QR_000000022110+P_110102110*QR_000000022111+P_110202010*QR_000000022120+P_110202110*QR_000000022121); ans_temp[ans_id*36+18]+=Pmtrx[18]*(P_011000011*QR_022000000000+P_011000111*QR_022000000001+P_011000211*QR_022000000002+P_111000011*QR_022000000100+P_111000111*QR_022000000101+P_111000211*QR_022000000102+P_211000011*QR_022000000200+P_211000111*QR_022000000201+P_211000211*QR_022000000202); ans_temp[ans_id*36+18]+=Pmtrx[19]*(P_011000011*QR_021001000000+P_011000111*QR_021001000001+P_011000211*QR_021001000002+P_111000011*QR_021001000100+P_111000111*QR_021001000101+P_111000211*QR_021001000102+P_211000011*QR_021001000200+P_211000111*QR_021001000201+P_211000211*QR_021001000202); ans_temp[ans_id*36+18]+=Pmtrx[20]*(P_011000011*QR_020002000000+P_011000111*QR_020002000001+P_011000211*QR_020002000002+P_111000011*QR_020002000100+P_111000111*QR_020002000101+P_111000211*QR_020002000102+P_211000011*QR_020002000200+P_211000111*QR_020002000201+P_211000211*QR_020002000202); ans_temp[ans_id*36+18]+=Pmtrx[21]*(P_011000011*QR_021000001000+P_011000111*QR_021000001001+P_011000211*QR_021000001002+P_111000011*QR_021000001100+P_111000111*QR_021000001101+P_111000211*QR_021000001102+P_211000011*QR_021000001200+P_211000111*QR_021000001201+P_211000211*QR_021000001202); ans_temp[ans_id*36+18]+=Pmtrx[22]*(P_011000011*QR_020001001000+P_011000111*QR_020001001001+P_011000211*QR_020001001002+P_111000011*QR_020001001100+P_111000111*QR_020001001101+P_111000211*QR_020001001102+P_211000011*QR_020001001200+P_211000111*QR_020001001201+P_211000211*QR_020001001202); ans_temp[ans_id*36+18]+=Pmtrx[23]*(P_011000011*QR_020000002000+P_011000111*QR_020000002001+P_011000211*QR_020000002002+P_111000011*QR_020000002100+P_111000111*QR_020000002101+P_111000211*QR_020000002102+P_211000011*QR_020000002200+P_211000111*QR_020000002201+P_211000211*QR_020000002202); ans_temp[ans_id*36+19]+=Pmtrx[18]*(P_011000011*QR_012010000000+P_011000111*QR_012010000001+P_011000211*QR_012010000002+P_111000011*QR_012010000100+P_111000111*QR_012010000101+P_111000211*QR_012010000102+P_211000011*QR_012010000200+P_211000111*QR_012010000201+P_211000211*QR_012010000202); ans_temp[ans_id*36+19]+=Pmtrx[19]*(P_011000011*QR_011011000000+P_011000111*QR_011011000001+P_011000211*QR_011011000002+P_111000011*QR_011011000100+P_111000111*QR_011011000101+P_111000211*QR_011011000102+P_211000011*QR_011011000200+P_211000111*QR_011011000201+P_211000211*QR_011011000202); ans_temp[ans_id*36+19]+=Pmtrx[20]*(P_011000011*QR_010012000000+P_011000111*QR_010012000001+P_011000211*QR_010012000002+P_111000011*QR_010012000100+P_111000111*QR_010012000101+P_111000211*QR_010012000102+P_211000011*QR_010012000200+P_211000111*QR_010012000201+P_211000211*QR_010012000202); ans_temp[ans_id*36+19]+=Pmtrx[21]*(P_011000011*QR_011010001000+P_011000111*QR_011010001001+P_011000211*QR_011010001002+P_111000011*QR_011010001100+P_111000111*QR_011010001101+P_111000211*QR_011010001102+P_211000011*QR_011010001200+P_211000111*QR_011010001201+P_211000211*QR_011010001202); ans_temp[ans_id*36+19]+=Pmtrx[22]*(P_011000011*QR_010011001000+P_011000111*QR_010011001001+P_011000211*QR_010011001002+P_111000011*QR_010011001100+P_111000111*QR_010011001101+P_111000211*QR_010011001102+P_211000011*QR_010011001200+P_211000111*QR_010011001201+P_211000211*QR_010011001202); ans_temp[ans_id*36+19]+=Pmtrx[23]*(P_011000011*QR_010010002000+P_011000111*QR_010010002001+P_011000211*QR_010010002002+P_111000011*QR_010010002100+P_111000111*QR_010010002101+P_111000211*QR_010010002102+P_211000011*QR_010010002200+P_211000111*QR_010010002201+P_211000211*QR_010010002202); ans_temp[ans_id*36+20]+=Pmtrx[18]*(P_011000011*QR_002020000000+P_011000111*QR_002020000001+P_011000211*QR_002020000002+P_111000011*QR_002020000100+P_111000111*QR_002020000101+P_111000211*QR_002020000102+P_211000011*QR_002020000200+P_211000111*QR_002020000201+P_211000211*QR_002020000202); ans_temp[ans_id*36+20]+=Pmtrx[19]*(P_011000011*QR_001021000000+P_011000111*QR_001021000001+P_011000211*QR_001021000002+P_111000011*QR_001021000100+P_111000111*QR_001021000101+P_111000211*QR_001021000102+P_211000011*QR_001021000200+P_211000111*QR_001021000201+P_211000211*QR_001021000202); ans_temp[ans_id*36+20]+=Pmtrx[20]*(P_011000011*QR_000022000000+P_011000111*QR_000022000001+P_011000211*QR_000022000002+P_111000011*QR_000022000100+P_111000111*QR_000022000101+P_111000211*QR_000022000102+P_211000011*QR_000022000200+P_211000111*QR_000022000201+P_211000211*QR_000022000202); ans_temp[ans_id*36+20]+=Pmtrx[21]*(P_011000011*QR_001020001000+P_011000111*QR_001020001001+P_011000211*QR_001020001002+P_111000011*QR_001020001100+P_111000111*QR_001020001101+P_111000211*QR_001020001102+P_211000011*QR_001020001200+P_211000111*QR_001020001201+P_211000211*QR_001020001202); ans_temp[ans_id*36+20]+=Pmtrx[22]*(P_011000011*QR_000021001000+P_011000111*QR_000021001001+P_011000211*QR_000021001002+P_111000011*QR_000021001100+P_111000111*QR_000021001101+P_111000211*QR_000021001102+P_211000011*QR_000021001200+P_211000111*QR_000021001201+P_211000211*QR_000021001202); ans_temp[ans_id*36+20]+=Pmtrx[23]*(P_011000011*QR_000020002000+P_011000111*QR_000020002001+P_011000211*QR_000020002002+P_111000011*QR_000020002100+P_111000111*QR_000020002101+P_111000211*QR_000020002102+P_211000011*QR_000020002200+P_211000111*QR_000020002201+P_211000211*QR_000020002202); ans_temp[ans_id*36+21]+=Pmtrx[18]*(P_011000011*QR_012000010000+P_011000111*QR_012000010001+P_011000211*QR_012000010002+P_111000011*QR_012000010100+P_111000111*QR_012000010101+P_111000211*QR_012000010102+P_211000011*QR_012000010200+P_211000111*QR_012000010201+P_211000211*QR_012000010202); ans_temp[ans_id*36+21]+=Pmtrx[19]*(P_011000011*QR_011001010000+P_011000111*QR_011001010001+P_011000211*QR_011001010002+P_111000011*QR_011001010100+P_111000111*QR_011001010101+P_111000211*QR_011001010102+P_211000011*QR_011001010200+P_211000111*QR_011001010201+P_211000211*QR_011001010202); ans_temp[ans_id*36+21]+=Pmtrx[20]*(P_011000011*QR_010002010000+P_011000111*QR_010002010001+P_011000211*QR_010002010002+P_111000011*QR_010002010100+P_111000111*QR_010002010101+P_111000211*QR_010002010102+P_211000011*QR_010002010200+P_211000111*QR_010002010201+P_211000211*QR_010002010202); ans_temp[ans_id*36+21]+=Pmtrx[21]*(P_011000011*QR_011000011000+P_011000111*QR_011000011001+P_011000211*QR_011000011002+P_111000011*QR_011000011100+P_111000111*QR_011000011101+P_111000211*QR_011000011102+P_211000011*QR_011000011200+P_211000111*QR_011000011201+P_211000211*QR_011000011202); ans_temp[ans_id*36+21]+=Pmtrx[22]*(P_011000011*QR_010001011000+P_011000111*QR_010001011001+P_011000211*QR_010001011002+P_111000011*QR_010001011100+P_111000111*QR_010001011101+P_111000211*QR_010001011102+P_211000011*QR_010001011200+P_211000111*QR_010001011201+P_211000211*QR_010001011202); ans_temp[ans_id*36+21]+=Pmtrx[23]*(P_011000011*QR_010000012000+P_011000111*QR_010000012001+P_011000211*QR_010000012002+P_111000011*QR_010000012100+P_111000111*QR_010000012101+P_111000211*QR_010000012102+P_211000011*QR_010000012200+P_211000111*QR_010000012201+P_211000211*QR_010000012202); ans_temp[ans_id*36+22]+=Pmtrx[18]*(P_011000011*QR_002010010000+P_011000111*QR_002010010001+P_011000211*QR_002010010002+P_111000011*QR_002010010100+P_111000111*QR_002010010101+P_111000211*QR_002010010102+P_211000011*QR_002010010200+P_211000111*QR_002010010201+P_211000211*QR_002010010202); ans_temp[ans_id*36+22]+=Pmtrx[19]*(P_011000011*QR_001011010000+P_011000111*QR_001011010001+P_011000211*QR_001011010002+P_111000011*QR_001011010100+P_111000111*QR_001011010101+P_111000211*QR_001011010102+P_211000011*QR_001011010200+P_211000111*QR_001011010201+P_211000211*QR_001011010202); ans_temp[ans_id*36+22]+=Pmtrx[20]*(P_011000011*QR_000012010000+P_011000111*QR_000012010001+P_011000211*QR_000012010002+P_111000011*QR_000012010100+P_111000111*QR_000012010101+P_111000211*QR_000012010102+P_211000011*QR_000012010200+P_211000111*QR_000012010201+P_211000211*QR_000012010202); ans_temp[ans_id*36+22]+=Pmtrx[21]*(P_011000011*QR_001010011000+P_011000111*QR_001010011001+P_011000211*QR_001010011002+P_111000011*QR_001010011100+P_111000111*QR_001010011101+P_111000211*QR_001010011102+P_211000011*QR_001010011200+P_211000111*QR_001010011201+P_211000211*QR_001010011202); ans_temp[ans_id*36+22]+=Pmtrx[22]*(P_011000011*QR_000011011000+P_011000111*QR_000011011001+P_011000211*QR_000011011002+P_111000011*QR_000011011100+P_111000111*QR_000011011101+P_111000211*QR_000011011102+P_211000011*QR_000011011200+P_211000111*QR_000011011201+P_211000211*QR_000011011202); ans_temp[ans_id*36+22]+=Pmtrx[23]*(P_011000011*QR_000010012000+P_011000111*QR_000010012001+P_011000211*QR_000010012002+P_111000011*QR_000010012100+P_111000111*QR_000010012101+P_111000211*QR_000010012102+P_211000011*QR_000010012200+P_211000111*QR_000010012201+P_211000211*QR_000010012202); ans_temp[ans_id*36+23]+=Pmtrx[18]*(P_011000011*QR_002000020000+P_011000111*QR_002000020001+P_011000211*QR_002000020002+P_111000011*QR_002000020100+P_111000111*QR_002000020101+P_111000211*QR_002000020102+P_211000011*QR_002000020200+P_211000111*QR_002000020201+P_211000211*QR_002000020202); ans_temp[ans_id*36+23]+=Pmtrx[19]*(P_011000011*QR_001001020000+P_011000111*QR_001001020001+P_011000211*QR_001001020002+P_111000011*QR_001001020100+P_111000111*QR_001001020101+P_111000211*QR_001001020102+P_211000011*QR_001001020200+P_211000111*QR_001001020201+P_211000211*QR_001001020202); ans_temp[ans_id*36+23]+=Pmtrx[20]*(P_011000011*QR_000002020000+P_011000111*QR_000002020001+P_011000211*QR_000002020002+P_111000011*QR_000002020100+P_111000111*QR_000002020101+P_111000211*QR_000002020102+P_211000011*QR_000002020200+P_211000111*QR_000002020201+P_211000211*QR_000002020202); ans_temp[ans_id*36+23]+=Pmtrx[21]*(P_011000011*QR_001000021000+P_011000111*QR_001000021001+P_011000211*QR_001000021002+P_111000011*QR_001000021100+P_111000111*QR_001000021101+P_111000211*QR_001000021102+P_211000011*QR_001000021200+P_211000111*QR_001000021201+P_211000211*QR_001000021202); ans_temp[ans_id*36+23]+=Pmtrx[22]*(P_011000011*QR_000001021000+P_011000111*QR_000001021001+P_011000211*QR_000001021002+P_111000011*QR_000001021100+P_111000111*QR_000001021101+P_111000211*QR_000001021102+P_211000011*QR_000001021200+P_211000111*QR_000001021201+P_211000211*QR_000001021202); ans_temp[ans_id*36+23]+=Pmtrx[23]*(P_011000011*QR_000000022000+P_011000111*QR_000000022001+P_011000211*QR_000000022002+P_111000011*QR_000000022100+P_111000111*QR_000000022101+P_111000211*QR_000000022102+P_211000011*QR_000000022200+P_211000111*QR_000000022201+P_211000211*QR_000000022202); ans_temp[ans_id*36+18]+=Pmtrx[24]*(P_010001011*QR_022000000000+P_010001111*QR_022000000001+P_010001211*QR_022000000002+P_010101011*QR_022000000010+P_010101111*QR_022000000011+P_010101211*QR_022000000012+P_110001011*QR_022000000100+P_110001111*QR_022000000101+P_110001211*QR_022000000102+P_110101011*QR_022000000110+P_110101111*QR_022000000111+P_110101211*QR_022000000112); ans_temp[ans_id*36+18]+=Pmtrx[25]*(P_010001011*QR_021001000000+P_010001111*QR_021001000001+P_010001211*QR_021001000002+P_010101011*QR_021001000010+P_010101111*QR_021001000011+P_010101211*QR_021001000012+P_110001011*QR_021001000100+P_110001111*QR_021001000101+P_110001211*QR_021001000102+P_110101011*QR_021001000110+P_110101111*QR_021001000111+P_110101211*QR_021001000112); ans_temp[ans_id*36+18]+=Pmtrx[26]*(P_010001011*QR_020002000000+P_010001111*QR_020002000001+P_010001211*QR_020002000002+P_010101011*QR_020002000010+P_010101111*QR_020002000011+P_010101211*QR_020002000012+P_110001011*QR_020002000100+P_110001111*QR_020002000101+P_110001211*QR_020002000102+P_110101011*QR_020002000110+P_110101111*QR_020002000111+P_110101211*QR_020002000112); ans_temp[ans_id*36+18]+=Pmtrx[27]*(P_010001011*QR_021000001000+P_010001111*QR_021000001001+P_010001211*QR_021000001002+P_010101011*QR_021000001010+P_010101111*QR_021000001011+P_010101211*QR_021000001012+P_110001011*QR_021000001100+P_110001111*QR_021000001101+P_110001211*QR_021000001102+P_110101011*QR_021000001110+P_110101111*QR_021000001111+P_110101211*QR_021000001112); ans_temp[ans_id*36+18]+=Pmtrx[28]*(P_010001011*QR_020001001000+P_010001111*QR_020001001001+P_010001211*QR_020001001002+P_010101011*QR_020001001010+P_010101111*QR_020001001011+P_010101211*QR_020001001012+P_110001011*QR_020001001100+P_110001111*QR_020001001101+P_110001211*QR_020001001102+P_110101011*QR_020001001110+P_110101111*QR_020001001111+P_110101211*QR_020001001112); ans_temp[ans_id*36+18]+=Pmtrx[29]*(P_010001011*QR_020000002000+P_010001111*QR_020000002001+P_010001211*QR_020000002002+P_010101011*QR_020000002010+P_010101111*QR_020000002011+P_010101211*QR_020000002012+P_110001011*QR_020000002100+P_110001111*QR_020000002101+P_110001211*QR_020000002102+P_110101011*QR_020000002110+P_110101111*QR_020000002111+P_110101211*QR_020000002112); ans_temp[ans_id*36+19]+=Pmtrx[24]*(P_010001011*QR_012010000000+P_010001111*QR_012010000001+P_010001211*QR_012010000002+P_010101011*QR_012010000010+P_010101111*QR_012010000011+P_010101211*QR_012010000012+P_110001011*QR_012010000100+P_110001111*QR_012010000101+P_110001211*QR_012010000102+P_110101011*QR_012010000110+P_110101111*QR_012010000111+P_110101211*QR_012010000112); ans_temp[ans_id*36+19]+=Pmtrx[25]*(P_010001011*QR_011011000000+P_010001111*QR_011011000001+P_010001211*QR_011011000002+P_010101011*QR_011011000010+P_010101111*QR_011011000011+P_010101211*QR_011011000012+P_110001011*QR_011011000100+P_110001111*QR_011011000101+P_110001211*QR_011011000102+P_110101011*QR_011011000110+P_110101111*QR_011011000111+P_110101211*QR_011011000112); ans_temp[ans_id*36+19]+=Pmtrx[26]*(P_010001011*QR_010012000000+P_010001111*QR_010012000001+P_010001211*QR_010012000002+P_010101011*QR_010012000010+P_010101111*QR_010012000011+P_010101211*QR_010012000012+P_110001011*QR_010012000100+P_110001111*QR_010012000101+P_110001211*QR_010012000102+P_110101011*QR_010012000110+P_110101111*QR_010012000111+P_110101211*QR_010012000112); ans_temp[ans_id*36+19]+=Pmtrx[27]*(P_010001011*QR_011010001000+P_010001111*QR_011010001001+P_010001211*QR_011010001002+P_010101011*QR_011010001010+P_010101111*QR_011010001011+P_010101211*QR_011010001012+P_110001011*QR_011010001100+P_110001111*QR_011010001101+P_110001211*QR_011010001102+P_110101011*QR_011010001110+P_110101111*QR_011010001111+P_110101211*QR_011010001112); ans_temp[ans_id*36+19]+=Pmtrx[28]*(P_010001011*QR_010011001000+P_010001111*QR_010011001001+P_010001211*QR_010011001002+P_010101011*QR_010011001010+P_010101111*QR_010011001011+P_010101211*QR_010011001012+P_110001011*QR_010011001100+P_110001111*QR_010011001101+P_110001211*QR_010011001102+P_110101011*QR_010011001110+P_110101111*QR_010011001111+P_110101211*QR_010011001112); ans_temp[ans_id*36+19]+=Pmtrx[29]*(P_010001011*QR_010010002000+P_010001111*QR_010010002001+P_010001211*QR_010010002002+P_010101011*QR_010010002010+P_010101111*QR_010010002011+P_010101211*QR_010010002012+P_110001011*QR_010010002100+P_110001111*QR_010010002101+P_110001211*QR_010010002102+P_110101011*QR_010010002110+P_110101111*QR_010010002111+P_110101211*QR_010010002112); ans_temp[ans_id*36+20]+=Pmtrx[24]*(P_010001011*QR_002020000000+P_010001111*QR_002020000001+P_010001211*QR_002020000002+P_010101011*QR_002020000010+P_010101111*QR_002020000011+P_010101211*QR_002020000012+P_110001011*QR_002020000100+P_110001111*QR_002020000101+P_110001211*QR_002020000102+P_110101011*QR_002020000110+P_110101111*QR_002020000111+P_110101211*QR_002020000112); ans_temp[ans_id*36+20]+=Pmtrx[25]*(P_010001011*QR_001021000000+P_010001111*QR_001021000001+P_010001211*QR_001021000002+P_010101011*QR_001021000010+P_010101111*QR_001021000011+P_010101211*QR_001021000012+P_110001011*QR_001021000100+P_110001111*QR_001021000101+P_110001211*QR_001021000102+P_110101011*QR_001021000110+P_110101111*QR_001021000111+P_110101211*QR_001021000112); ans_temp[ans_id*36+20]+=Pmtrx[26]*(P_010001011*QR_000022000000+P_010001111*QR_000022000001+P_010001211*QR_000022000002+P_010101011*QR_000022000010+P_010101111*QR_000022000011+P_010101211*QR_000022000012+P_110001011*QR_000022000100+P_110001111*QR_000022000101+P_110001211*QR_000022000102+P_110101011*QR_000022000110+P_110101111*QR_000022000111+P_110101211*QR_000022000112); ans_temp[ans_id*36+20]+=Pmtrx[27]*(P_010001011*QR_001020001000+P_010001111*QR_001020001001+P_010001211*QR_001020001002+P_010101011*QR_001020001010+P_010101111*QR_001020001011+P_010101211*QR_001020001012+P_110001011*QR_001020001100+P_110001111*QR_001020001101+P_110001211*QR_001020001102+P_110101011*QR_001020001110+P_110101111*QR_001020001111+P_110101211*QR_001020001112); ans_temp[ans_id*36+20]+=Pmtrx[28]*(P_010001011*QR_000021001000+P_010001111*QR_000021001001+P_010001211*QR_000021001002+P_010101011*QR_000021001010+P_010101111*QR_000021001011+P_010101211*QR_000021001012+P_110001011*QR_000021001100+P_110001111*QR_000021001101+P_110001211*QR_000021001102+P_110101011*QR_000021001110+P_110101111*QR_000021001111+P_110101211*QR_000021001112); ans_temp[ans_id*36+20]+=Pmtrx[29]*(P_010001011*QR_000020002000+P_010001111*QR_000020002001+P_010001211*QR_000020002002+P_010101011*QR_000020002010+P_010101111*QR_000020002011+P_010101211*QR_000020002012+P_110001011*QR_000020002100+P_110001111*QR_000020002101+P_110001211*QR_000020002102+P_110101011*QR_000020002110+P_110101111*QR_000020002111+P_110101211*QR_000020002112); ans_temp[ans_id*36+21]+=Pmtrx[24]*(P_010001011*QR_012000010000+P_010001111*QR_012000010001+P_010001211*QR_012000010002+P_010101011*QR_012000010010+P_010101111*QR_012000010011+P_010101211*QR_012000010012+P_110001011*QR_012000010100+P_110001111*QR_012000010101+P_110001211*QR_012000010102+P_110101011*QR_012000010110+P_110101111*QR_012000010111+P_110101211*QR_012000010112); ans_temp[ans_id*36+21]+=Pmtrx[25]*(P_010001011*QR_011001010000+P_010001111*QR_011001010001+P_010001211*QR_011001010002+P_010101011*QR_011001010010+P_010101111*QR_011001010011+P_010101211*QR_011001010012+P_110001011*QR_011001010100+P_110001111*QR_011001010101+P_110001211*QR_011001010102+P_110101011*QR_011001010110+P_110101111*QR_011001010111+P_110101211*QR_011001010112); ans_temp[ans_id*36+21]+=Pmtrx[26]*(P_010001011*QR_010002010000+P_010001111*QR_010002010001+P_010001211*QR_010002010002+P_010101011*QR_010002010010+P_010101111*QR_010002010011+P_010101211*QR_010002010012+P_110001011*QR_010002010100+P_110001111*QR_010002010101+P_110001211*QR_010002010102+P_110101011*QR_010002010110+P_110101111*QR_010002010111+P_110101211*QR_010002010112); ans_temp[ans_id*36+21]+=Pmtrx[27]*(P_010001011*QR_011000011000+P_010001111*QR_011000011001+P_010001211*QR_011000011002+P_010101011*QR_011000011010+P_010101111*QR_011000011011+P_010101211*QR_011000011012+P_110001011*QR_011000011100+P_110001111*QR_011000011101+P_110001211*QR_011000011102+P_110101011*QR_011000011110+P_110101111*QR_011000011111+P_110101211*QR_011000011112); ans_temp[ans_id*36+21]+=Pmtrx[28]*(P_010001011*QR_010001011000+P_010001111*QR_010001011001+P_010001211*QR_010001011002+P_010101011*QR_010001011010+P_010101111*QR_010001011011+P_010101211*QR_010001011012+P_110001011*QR_010001011100+P_110001111*QR_010001011101+P_110001211*QR_010001011102+P_110101011*QR_010001011110+P_110101111*QR_010001011111+P_110101211*QR_010001011112); ans_temp[ans_id*36+21]+=Pmtrx[29]*(P_010001011*QR_010000012000+P_010001111*QR_010000012001+P_010001211*QR_010000012002+P_010101011*QR_010000012010+P_010101111*QR_010000012011+P_010101211*QR_010000012012+P_110001011*QR_010000012100+P_110001111*QR_010000012101+P_110001211*QR_010000012102+P_110101011*QR_010000012110+P_110101111*QR_010000012111+P_110101211*QR_010000012112); ans_temp[ans_id*36+22]+=Pmtrx[24]*(P_010001011*QR_002010010000+P_010001111*QR_002010010001+P_010001211*QR_002010010002+P_010101011*QR_002010010010+P_010101111*QR_002010010011+P_010101211*QR_002010010012+P_110001011*QR_002010010100+P_110001111*QR_002010010101+P_110001211*QR_002010010102+P_110101011*QR_002010010110+P_110101111*QR_002010010111+P_110101211*QR_002010010112); ans_temp[ans_id*36+22]+=Pmtrx[25]*(P_010001011*QR_001011010000+P_010001111*QR_001011010001+P_010001211*QR_001011010002+P_010101011*QR_001011010010+P_010101111*QR_001011010011+P_010101211*QR_001011010012+P_110001011*QR_001011010100+P_110001111*QR_001011010101+P_110001211*QR_001011010102+P_110101011*QR_001011010110+P_110101111*QR_001011010111+P_110101211*QR_001011010112); ans_temp[ans_id*36+22]+=Pmtrx[26]*(P_010001011*QR_000012010000+P_010001111*QR_000012010001+P_010001211*QR_000012010002+P_010101011*QR_000012010010+P_010101111*QR_000012010011+P_010101211*QR_000012010012+P_110001011*QR_000012010100+P_110001111*QR_000012010101+P_110001211*QR_000012010102+P_110101011*QR_000012010110+P_110101111*QR_000012010111+P_110101211*QR_000012010112); ans_temp[ans_id*36+22]+=Pmtrx[27]*(P_010001011*QR_001010011000+P_010001111*QR_001010011001+P_010001211*QR_001010011002+P_010101011*QR_001010011010+P_010101111*QR_001010011011+P_010101211*QR_001010011012+P_110001011*QR_001010011100+P_110001111*QR_001010011101+P_110001211*QR_001010011102+P_110101011*QR_001010011110+P_110101111*QR_001010011111+P_110101211*QR_001010011112); ans_temp[ans_id*36+22]+=Pmtrx[28]*(P_010001011*QR_000011011000+P_010001111*QR_000011011001+P_010001211*QR_000011011002+P_010101011*QR_000011011010+P_010101111*QR_000011011011+P_010101211*QR_000011011012+P_110001011*QR_000011011100+P_110001111*QR_000011011101+P_110001211*QR_000011011102+P_110101011*QR_000011011110+P_110101111*QR_000011011111+P_110101211*QR_000011011112); ans_temp[ans_id*36+22]+=Pmtrx[29]*(P_010001011*QR_000010012000+P_010001111*QR_000010012001+P_010001211*QR_000010012002+P_010101011*QR_000010012010+P_010101111*QR_000010012011+P_010101211*QR_000010012012+P_110001011*QR_000010012100+P_110001111*QR_000010012101+P_110001211*QR_000010012102+P_110101011*QR_000010012110+P_110101111*QR_000010012111+P_110101211*QR_000010012112); ans_temp[ans_id*36+23]+=Pmtrx[24]*(P_010001011*QR_002000020000+P_010001111*QR_002000020001+P_010001211*QR_002000020002+P_010101011*QR_002000020010+P_010101111*QR_002000020011+P_010101211*QR_002000020012+P_110001011*QR_002000020100+P_110001111*QR_002000020101+P_110001211*QR_002000020102+P_110101011*QR_002000020110+P_110101111*QR_002000020111+P_110101211*QR_002000020112); ans_temp[ans_id*36+23]+=Pmtrx[25]*(P_010001011*QR_001001020000+P_010001111*QR_001001020001+P_010001211*QR_001001020002+P_010101011*QR_001001020010+P_010101111*QR_001001020011+P_010101211*QR_001001020012+P_110001011*QR_001001020100+P_110001111*QR_001001020101+P_110001211*QR_001001020102+P_110101011*QR_001001020110+P_110101111*QR_001001020111+P_110101211*QR_001001020112); ans_temp[ans_id*36+23]+=Pmtrx[26]*(P_010001011*QR_000002020000+P_010001111*QR_000002020001+P_010001211*QR_000002020002+P_010101011*QR_000002020010+P_010101111*QR_000002020011+P_010101211*QR_000002020012+P_110001011*QR_000002020100+P_110001111*QR_000002020101+P_110001211*QR_000002020102+P_110101011*QR_000002020110+P_110101111*QR_000002020111+P_110101211*QR_000002020112); ans_temp[ans_id*36+23]+=Pmtrx[27]*(P_010001011*QR_001000021000+P_010001111*QR_001000021001+P_010001211*QR_001000021002+P_010101011*QR_001000021010+P_010101111*QR_001000021011+P_010101211*QR_001000021012+P_110001011*QR_001000021100+P_110001111*QR_001000021101+P_110001211*QR_001000021102+P_110101011*QR_001000021110+P_110101111*QR_001000021111+P_110101211*QR_001000021112); ans_temp[ans_id*36+23]+=Pmtrx[28]*(P_010001011*QR_000001021000+P_010001111*QR_000001021001+P_010001211*QR_000001021002+P_010101011*QR_000001021010+P_010101111*QR_000001021011+P_010101211*QR_000001021012+P_110001011*QR_000001021100+P_110001111*QR_000001021101+P_110001211*QR_000001021102+P_110101011*QR_000001021110+P_110101111*QR_000001021111+P_110101211*QR_000001021112); ans_temp[ans_id*36+23]+=Pmtrx[29]*(P_010001011*QR_000000022000+P_010001111*QR_000000022001+P_010001211*QR_000000022002+P_010101011*QR_000000022010+P_010101111*QR_000000022011+P_010101211*QR_000000022012+P_110001011*QR_000000022100+P_110001111*QR_000000022101+P_110001211*QR_000000022102+P_110101011*QR_000000022110+P_110101111*QR_000000022111+P_110101211*QR_000000022112); ans_temp[ans_id*36+18]+=Pmtrx[30]*(P_010000012*QR_022000000000+P_010000112*QR_022000000001+P_010000212*QR_022000000002+P_010000312*QR_022000000003+P_110000012*QR_022000000100+P_110000112*QR_022000000101+P_110000212*QR_022000000102+P_110000312*QR_022000000103); ans_temp[ans_id*36+18]+=Pmtrx[31]*(P_010000012*QR_021001000000+P_010000112*QR_021001000001+P_010000212*QR_021001000002+P_010000312*QR_021001000003+P_110000012*QR_021001000100+P_110000112*QR_021001000101+P_110000212*QR_021001000102+P_110000312*QR_021001000103); ans_temp[ans_id*36+18]+=Pmtrx[32]*(P_010000012*QR_020002000000+P_010000112*QR_020002000001+P_010000212*QR_020002000002+P_010000312*QR_020002000003+P_110000012*QR_020002000100+P_110000112*QR_020002000101+P_110000212*QR_020002000102+P_110000312*QR_020002000103); ans_temp[ans_id*36+18]+=Pmtrx[33]*(P_010000012*QR_021000001000+P_010000112*QR_021000001001+P_010000212*QR_021000001002+P_010000312*QR_021000001003+P_110000012*QR_021000001100+P_110000112*QR_021000001101+P_110000212*QR_021000001102+P_110000312*QR_021000001103); ans_temp[ans_id*36+18]+=Pmtrx[34]*(P_010000012*QR_020001001000+P_010000112*QR_020001001001+P_010000212*QR_020001001002+P_010000312*QR_020001001003+P_110000012*QR_020001001100+P_110000112*QR_020001001101+P_110000212*QR_020001001102+P_110000312*QR_020001001103); ans_temp[ans_id*36+18]+=Pmtrx[35]*(P_010000012*QR_020000002000+P_010000112*QR_020000002001+P_010000212*QR_020000002002+P_010000312*QR_020000002003+P_110000012*QR_020000002100+P_110000112*QR_020000002101+P_110000212*QR_020000002102+P_110000312*QR_020000002103); ans_temp[ans_id*36+19]+=Pmtrx[30]*(P_010000012*QR_012010000000+P_010000112*QR_012010000001+P_010000212*QR_012010000002+P_010000312*QR_012010000003+P_110000012*QR_012010000100+P_110000112*QR_012010000101+P_110000212*QR_012010000102+P_110000312*QR_012010000103); ans_temp[ans_id*36+19]+=Pmtrx[31]*(P_010000012*QR_011011000000+P_010000112*QR_011011000001+P_010000212*QR_011011000002+P_010000312*QR_011011000003+P_110000012*QR_011011000100+P_110000112*QR_011011000101+P_110000212*QR_011011000102+P_110000312*QR_011011000103); ans_temp[ans_id*36+19]+=Pmtrx[32]*(P_010000012*QR_010012000000+P_010000112*QR_010012000001+P_010000212*QR_010012000002+P_010000312*QR_010012000003+P_110000012*QR_010012000100+P_110000112*QR_010012000101+P_110000212*QR_010012000102+P_110000312*QR_010012000103); ans_temp[ans_id*36+19]+=Pmtrx[33]*(P_010000012*QR_011010001000+P_010000112*QR_011010001001+P_010000212*QR_011010001002+P_010000312*QR_011010001003+P_110000012*QR_011010001100+P_110000112*QR_011010001101+P_110000212*QR_011010001102+P_110000312*QR_011010001103); ans_temp[ans_id*36+19]+=Pmtrx[34]*(P_010000012*QR_010011001000+P_010000112*QR_010011001001+P_010000212*QR_010011001002+P_010000312*QR_010011001003+P_110000012*QR_010011001100+P_110000112*QR_010011001101+P_110000212*QR_010011001102+P_110000312*QR_010011001103); ans_temp[ans_id*36+19]+=Pmtrx[35]*(P_010000012*QR_010010002000+P_010000112*QR_010010002001+P_010000212*QR_010010002002+P_010000312*QR_010010002003+P_110000012*QR_010010002100+P_110000112*QR_010010002101+P_110000212*QR_010010002102+P_110000312*QR_010010002103); ans_temp[ans_id*36+20]+=Pmtrx[30]*(P_010000012*QR_002020000000+P_010000112*QR_002020000001+P_010000212*QR_002020000002+P_010000312*QR_002020000003+P_110000012*QR_002020000100+P_110000112*QR_002020000101+P_110000212*QR_002020000102+P_110000312*QR_002020000103); ans_temp[ans_id*36+20]+=Pmtrx[31]*(P_010000012*QR_001021000000+P_010000112*QR_001021000001+P_010000212*QR_001021000002+P_010000312*QR_001021000003+P_110000012*QR_001021000100+P_110000112*QR_001021000101+P_110000212*QR_001021000102+P_110000312*QR_001021000103); ans_temp[ans_id*36+20]+=Pmtrx[32]*(P_010000012*QR_000022000000+P_010000112*QR_000022000001+P_010000212*QR_000022000002+P_010000312*QR_000022000003+P_110000012*QR_000022000100+P_110000112*QR_000022000101+P_110000212*QR_000022000102+P_110000312*QR_000022000103); ans_temp[ans_id*36+20]+=Pmtrx[33]*(P_010000012*QR_001020001000+P_010000112*QR_001020001001+P_010000212*QR_001020001002+P_010000312*QR_001020001003+P_110000012*QR_001020001100+P_110000112*QR_001020001101+P_110000212*QR_001020001102+P_110000312*QR_001020001103); ans_temp[ans_id*36+20]+=Pmtrx[34]*(P_010000012*QR_000021001000+P_010000112*QR_000021001001+P_010000212*QR_000021001002+P_010000312*QR_000021001003+P_110000012*QR_000021001100+P_110000112*QR_000021001101+P_110000212*QR_000021001102+P_110000312*QR_000021001103); ans_temp[ans_id*36+20]+=Pmtrx[35]*(P_010000012*QR_000020002000+P_010000112*QR_000020002001+P_010000212*QR_000020002002+P_010000312*QR_000020002003+P_110000012*QR_000020002100+P_110000112*QR_000020002101+P_110000212*QR_000020002102+P_110000312*QR_000020002103); ans_temp[ans_id*36+21]+=Pmtrx[30]*(P_010000012*QR_012000010000+P_010000112*QR_012000010001+P_010000212*QR_012000010002+P_010000312*QR_012000010003+P_110000012*QR_012000010100+P_110000112*QR_012000010101+P_110000212*QR_012000010102+P_110000312*QR_012000010103); ans_temp[ans_id*36+21]+=Pmtrx[31]*(P_010000012*QR_011001010000+P_010000112*QR_011001010001+P_010000212*QR_011001010002+P_010000312*QR_011001010003+P_110000012*QR_011001010100+P_110000112*QR_011001010101+P_110000212*QR_011001010102+P_110000312*QR_011001010103); ans_temp[ans_id*36+21]+=Pmtrx[32]*(P_010000012*QR_010002010000+P_010000112*QR_010002010001+P_010000212*QR_010002010002+P_010000312*QR_010002010003+P_110000012*QR_010002010100+P_110000112*QR_010002010101+P_110000212*QR_010002010102+P_110000312*QR_010002010103); ans_temp[ans_id*36+21]+=Pmtrx[33]*(P_010000012*QR_011000011000+P_010000112*QR_011000011001+P_010000212*QR_011000011002+P_010000312*QR_011000011003+P_110000012*QR_011000011100+P_110000112*QR_011000011101+P_110000212*QR_011000011102+P_110000312*QR_011000011103); ans_temp[ans_id*36+21]+=Pmtrx[34]*(P_010000012*QR_010001011000+P_010000112*QR_010001011001+P_010000212*QR_010001011002+P_010000312*QR_010001011003+P_110000012*QR_010001011100+P_110000112*QR_010001011101+P_110000212*QR_010001011102+P_110000312*QR_010001011103); ans_temp[ans_id*36+21]+=Pmtrx[35]*(P_010000012*QR_010000012000+P_010000112*QR_010000012001+P_010000212*QR_010000012002+P_010000312*QR_010000012003+P_110000012*QR_010000012100+P_110000112*QR_010000012101+P_110000212*QR_010000012102+P_110000312*QR_010000012103); ans_temp[ans_id*36+22]+=Pmtrx[30]*(P_010000012*QR_002010010000+P_010000112*QR_002010010001+P_010000212*QR_002010010002+P_010000312*QR_002010010003+P_110000012*QR_002010010100+P_110000112*QR_002010010101+P_110000212*QR_002010010102+P_110000312*QR_002010010103); ans_temp[ans_id*36+22]+=Pmtrx[31]*(P_010000012*QR_001011010000+P_010000112*QR_001011010001+P_010000212*QR_001011010002+P_010000312*QR_001011010003+P_110000012*QR_001011010100+P_110000112*QR_001011010101+P_110000212*QR_001011010102+P_110000312*QR_001011010103); ans_temp[ans_id*36+22]+=Pmtrx[32]*(P_010000012*QR_000012010000+P_010000112*QR_000012010001+P_010000212*QR_000012010002+P_010000312*QR_000012010003+P_110000012*QR_000012010100+P_110000112*QR_000012010101+P_110000212*QR_000012010102+P_110000312*QR_000012010103); ans_temp[ans_id*36+22]+=Pmtrx[33]*(P_010000012*QR_001010011000+P_010000112*QR_001010011001+P_010000212*QR_001010011002+P_010000312*QR_001010011003+P_110000012*QR_001010011100+P_110000112*QR_001010011101+P_110000212*QR_001010011102+P_110000312*QR_001010011103); ans_temp[ans_id*36+22]+=Pmtrx[34]*(P_010000012*QR_000011011000+P_010000112*QR_000011011001+P_010000212*QR_000011011002+P_010000312*QR_000011011003+P_110000012*QR_000011011100+P_110000112*QR_000011011101+P_110000212*QR_000011011102+P_110000312*QR_000011011103); ans_temp[ans_id*36+22]+=Pmtrx[35]*(P_010000012*QR_000010012000+P_010000112*QR_000010012001+P_010000212*QR_000010012002+P_010000312*QR_000010012003+P_110000012*QR_000010012100+P_110000112*QR_000010012101+P_110000212*QR_000010012102+P_110000312*QR_000010012103); ans_temp[ans_id*36+23]+=Pmtrx[30]*(P_010000012*QR_002000020000+P_010000112*QR_002000020001+P_010000212*QR_002000020002+P_010000312*QR_002000020003+P_110000012*QR_002000020100+P_110000112*QR_002000020101+P_110000212*QR_002000020102+P_110000312*QR_002000020103); ans_temp[ans_id*36+23]+=Pmtrx[31]*(P_010000012*QR_001001020000+P_010000112*QR_001001020001+P_010000212*QR_001001020002+P_010000312*QR_001001020003+P_110000012*QR_001001020100+P_110000112*QR_001001020101+P_110000212*QR_001001020102+P_110000312*QR_001001020103); ans_temp[ans_id*36+23]+=Pmtrx[32]*(P_010000012*QR_000002020000+P_010000112*QR_000002020001+P_010000212*QR_000002020002+P_010000312*QR_000002020003+P_110000012*QR_000002020100+P_110000112*QR_000002020101+P_110000212*QR_000002020102+P_110000312*QR_000002020103); ans_temp[ans_id*36+23]+=Pmtrx[33]*(P_010000012*QR_001000021000+P_010000112*QR_001000021001+P_010000212*QR_001000021002+P_010000312*QR_001000021003+P_110000012*QR_001000021100+P_110000112*QR_001000021101+P_110000212*QR_001000021102+P_110000312*QR_001000021103); ans_temp[ans_id*36+23]+=Pmtrx[34]*(P_010000012*QR_000001021000+P_010000112*QR_000001021001+P_010000212*QR_000001021002+P_010000312*QR_000001021003+P_110000012*QR_000001021100+P_110000112*QR_000001021101+P_110000212*QR_000001021102+P_110000312*QR_000001021103); ans_temp[ans_id*36+23]+=Pmtrx[35]*(P_010000012*QR_000000022000+P_010000112*QR_000000022001+P_010000212*QR_000000022002+P_010000312*QR_000000022003+P_110000012*QR_000000022100+P_110000112*QR_000000022101+P_110000212*QR_000000022102+P_110000312*QR_000000022103); ans_temp[ans_id*36+24]+=Pmtrx[0]*(P_002010010*QR_022000000000+P_002010110*QR_022000000001+P_002110010*QR_022000000010+P_002110110*QR_022000000011+P_102010010*QR_022000000100+P_102010110*QR_022000000101+P_102110010*QR_022000000110+P_102110110*QR_022000000111+P_202010010*QR_022000000200+P_202010110*QR_022000000201+P_202110010*QR_022000000210+P_202110110*QR_022000000211); ans_temp[ans_id*36+24]+=Pmtrx[1]*(P_002010010*QR_021001000000+P_002010110*QR_021001000001+P_002110010*QR_021001000010+P_002110110*QR_021001000011+P_102010010*QR_021001000100+P_102010110*QR_021001000101+P_102110010*QR_021001000110+P_102110110*QR_021001000111+P_202010010*QR_021001000200+P_202010110*QR_021001000201+P_202110010*QR_021001000210+P_202110110*QR_021001000211); ans_temp[ans_id*36+24]+=Pmtrx[2]*(P_002010010*QR_020002000000+P_002010110*QR_020002000001+P_002110010*QR_020002000010+P_002110110*QR_020002000011+P_102010010*QR_020002000100+P_102010110*QR_020002000101+P_102110010*QR_020002000110+P_102110110*QR_020002000111+P_202010010*QR_020002000200+P_202010110*QR_020002000201+P_202110010*QR_020002000210+P_202110110*QR_020002000211); ans_temp[ans_id*36+24]+=Pmtrx[3]*(P_002010010*QR_021000001000+P_002010110*QR_021000001001+P_002110010*QR_021000001010+P_002110110*QR_021000001011+P_102010010*QR_021000001100+P_102010110*QR_021000001101+P_102110010*QR_021000001110+P_102110110*QR_021000001111+P_202010010*QR_021000001200+P_202010110*QR_021000001201+P_202110010*QR_021000001210+P_202110110*QR_021000001211); ans_temp[ans_id*36+24]+=Pmtrx[4]*(P_002010010*QR_020001001000+P_002010110*QR_020001001001+P_002110010*QR_020001001010+P_002110110*QR_020001001011+P_102010010*QR_020001001100+P_102010110*QR_020001001101+P_102110010*QR_020001001110+P_102110110*QR_020001001111+P_202010010*QR_020001001200+P_202010110*QR_020001001201+P_202110010*QR_020001001210+P_202110110*QR_020001001211); ans_temp[ans_id*36+24]+=Pmtrx[5]*(P_002010010*QR_020000002000+P_002010110*QR_020000002001+P_002110010*QR_020000002010+P_002110110*QR_020000002011+P_102010010*QR_020000002100+P_102010110*QR_020000002101+P_102110010*QR_020000002110+P_102110110*QR_020000002111+P_202010010*QR_020000002200+P_202010110*QR_020000002201+P_202110010*QR_020000002210+P_202110110*QR_020000002211); ans_temp[ans_id*36+25]+=Pmtrx[0]*(P_002010010*QR_012010000000+P_002010110*QR_012010000001+P_002110010*QR_012010000010+P_002110110*QR_012010000011+P_102010010*QR_012010000100+P_102010110*QR_012010000101+P_102110010*QR_012010000110+P_102110110*QR_012010000111+P_202010010*QR_012010000200+P_202010110*QR_012010000201+P_202110010*QR_012010000210+P_202110110*QR_012010000211); ans_temp[ans_id*36+25]+=Pmtrx[1]*(P_002010010*QR_011011000000+P_002010110*QR_011011000001+P_002110010*QR_011011000010+P_002110110*QR_011011000011+P_102010010*QR_011011000100+P_102010110*QR_011011000101+P_102110010*QR_011011000110+P_102110110*QR_011011000111+P_202010010*QR_011011000200+P_202010110*QR_011011000201+P_202110010*QR_011011000210+P_202110110*QR_011011000211); ans_temp[ans_id*36+25]+=Pmtrx[2]*(P_002010010*QR_010012000000+P_002010110*QR_010012000001+P_002110010*QR_010012000010+P_002110110*QR_010012000011+P_102010010*QR_010012000100+P_102010110*QR_010012000101+P_102110010*QR_010012000110+P_102110110*QR_010012000111+P_202010010*QR_010012000200+P_202010110*QR_010012000201+P_202110010*QR_010012000210+P_202110110*QR_010012000211); ans_temp[ans_id*36+25]+=Pmtrx[3]*(P_002010010*QR_011010001000+P_002010110*QR_011010001001+P_002110010*QR_011010001010+P_002110110*QR_011010001011+P_102010010*QR_011010001100+P_102010110*QR_011010001101+P_102110010*QR_011010001110+P_102110110*QR_011010001111+P_202010010*QR_011010001200+P_202010110*QR_011010001201+P_202110010*QR_011010001210+P_202110110*QR_011010001211); ans_temp[ans_id*36+25]+=Pmtrx[4]*(P_002010010*QR_010011001000+P_002010110*QR_010011001001+P_002110010*QR_010011001010+P_002110110*QR_010011001011+P_102010010*QR_010011001100+P_102010110*QR_010011001101+P_102110010*QR_010011001110+P_102110110*QR_010011001111+P_202010010*QR_010011001200+P_202010110*QR_010011001201+P_202110010*QR_010011001210+P_202110110*QR_010011001211); ans_temp[ans_id*36+25]+=Pmtrx[5]*(P_002010010*QR_010010002000+P_002010110*QR_010010002001+P_002110010*QR_010010002010+P_002110110*QR_010010002011+P_102010010*QR_010010002100+P_102010110*QR_010010002101+P_102110010*QR_010010002110+P_102110110*QR_010010002111+P_202010010*QR_010010002200+P_202010110*QR_010010002201+P_202110010*QR_010010002210+P_202110110*QR_010010002211); ans_temp[ans_id*36+26]+=Pmtrx[0]*(P_002010010*QR_002020000000+P_002010110*QR_002020000001+P_002110010*QR_002020000010+P_002110110*QR_002020000011+P_102010010*QR_002020000100+P_102010110*QR_002020000101+P_102110010*QR_002020000110+P_102110110*QR_002020000111+P_202010010*QR_002020000200+P_202010110*QR_002020000201+P_202110010*QR_002020000210+P_202110110*QR_002020000211); ans_temp[ans_id*36+26]+=Pmtrx[1]*(P_002010010*QR_001021000000+P_002010110*QR_001021000001+P_002110010*QR_001021000010+P_002110110*QR_001021000011+P_102010010*QR_001021000100+P_102010110*QR_001021000101+P_102110010*QR_001021000110+P_102110110*QR_001021000111+P_202010010*QR_001021000200+P_202010110*QR_001021000201+P_202110010*QR_001021000210+P_202110110*QR_001021000211); ans_temp[ans_id*36+26]+=Pmtrx[2]*(P_002010010*QR_000022000000+P_002010110*QR_000022000001+P_002110010*QR_000022000010+P_002110110*QR_000022000011+P_102010010*QR_000022000100+P_102010110*QR_000022000101+P_102110010*QR_000022000110+P_102110110*QR_000022000111+P_202010010*QR_000022000200+P_202010110*QR_000022000201+P_202110010*QR_000022000210+P_202110110*QR_000022000211); ans_temp[ans_id*36+26]+=Pmtrx[3]*(P_002010010*QR_001020001000+P_002010110*QR_001020001001+P_002110010*QR_001020001010+P_002110110*QR_001020001011+P_102010010*QR_001020001100+P_102010110*QR_001020001101+P_102110010*QR_001020001110+P_102110110*QR_001020001111+P_202010010*QR_001020001200+P_202010110*QR_001020001201+P_202110010*QR_001020001210+P_202110110*QR_001020001211); ans_temp[ans_id*36+26]+=Pmtrx[4]*(P_002010010*QR_000021001000+P_002010110*QR_000021001001+P_002110010*QR_000021001010+P_002110110*QR_000021001011+P_102010010*QR_000021001100+P_102010110*QR_000021001101+P_102110010*QR_000021001110+P_102110110*QR_000021001111+P_202010010*QR_000021001200+P_202010110*QR_000021001201+P_202110010*QR_000021001210+P_202110110*QR_000021001211); ans_temp[ans_id*36+26]+=Pmtrx[5]*(P_002010010*QR_000020002000+P_002010110*QR_000020002001+P_002110010*QR_000020002010+P_002110110*QR_000020002011+P_102010010*QR_000020002100+P_102010110*QR_000020002101+P_102110010*QR_000020002110+P_102110110*QR_000020002111+P_202010010*QR_000020002200+P_202010110*QR_000020002201+P_202110010*QR_000020002210+P_202110110*QR_000020002211); ans_temp[ans_id*36+27]+=Pmtrx[0]*(P_002010010*QR_012000010000+P_002010110*QR_012000010001+P_002110010*QR_012000010010+P_002110110*QR_012000010011+P_102010010*QR_012000010100+P_102010110*QR_012000010101+P_102110010*QR_012000010110+P_102110110*QR_012000010111+P_202010010*QR_012000010200+P_202010110*QR_012000010201+P_202110010*QR_012000010210+P_202110110*QR_012000010211); ans_temp[ans_id*36+27]+=Pmtrx[1]*(P_002010010*QR_011001010000+P_002010110*QR_011001010001+P_002110010*QR_011001010010+P_002110110*QR_011001010011+P_102010010*QR_011001010100+P_102010110*QR_011001010101+P_102110010*QR_011001010110+P_102110110*QR_011001010111+P_202010010*QR_011001010200+P_202010110*QR_011001010201+P_202110010*QR_011001010210+P_202110110*QR_011001010211); ans_temp[ans_id*36+27]+=Pmtrx[2]*(P_002010010*QR_010002010000+P_002010110*QR_010002010001+P_002110010*QR_010002010010+P_002110110*QR_010002010011+P_102010010*QR_010002010100+P_102010110*QR_010002010101+P_102110010*QR_010002010110+P_102110110*QR_010002010111+P_202010010*QR_010002010200+P_202010110*QR_010002010201+P_202110010*QR_010002010210+P_202110110*QR_010002010211); ans_temp[ans_id*36+27]+=Pmtrx[3]*(P_002010010*QR_011000011000+P_002010110*QR_011000011001+P_002110010*QR_011000011010+P_002110110*QR_011000011011+P_102010010*QR_011000011100+P_102010110*QR_011000011101+P_102110010*QR_011000011110+P_102110110*QR_011000011111+P_202010010*QR_011000011200+P_202010110*QR_011000011201+P_202110010*QR_011000011210+P_202110110*QR_011000011211); ans_temp[ans_id*36+27]+=Pmtrx[4]*(P_002010010*QR_010001011000+P_002010110*QR_010001011001+P_002110010*QR_010001011010+P_002110110*QR_010001011011+P_102010010*QR_010001011100+P_102010110*QR_010001011101+P_102110010*QR_010001011110+P_102110110*QR_010001011111+P_202010010*QR_010001011200+P_202010110*QR_010001011201+P_202110010*QR_010001011210+P_202110110*QR_010001011211); ans_temp[ans_id*36+27]+=Pmtrx[5]*(P_002010010*QR_010000012000+P_002010110*QR_010000012001+P_002110010*QR_010000012010+P_002110110*QR_010000012011+P_102010010*QR_010000012100+P_102010110*QR_010000012101+P_102110010*QR_010000012110+P_102110110*QR_010000012111+P_202010010*QR_010000012200+P_202010110*QR_010000012201+P_202110010*QR_010000012210+P_202110110*QR_010000012211); ans_temp[ans_id*36+28]+=Pmtrx[0]*(P_002010010*QR_002010010000+P_002010110*QR_002010010001+P_002110010*QR_002010010010+P_002110110*QR_002010010011+P_102010010*QR_002010010100+P_102010110*QR_002010010101+P_102110010*QR_002010010110+P_102110110*QR_002010010111+P_202010010*QR_002010010200+P_202010110*QR_002010010201+P_202110010*QR_002010010210+P_202110110*QR_002010010211); ans_temp[ans_id*36+28]+=Pmtrx[1]*(P_002010010*QR_001011010000+P_002010110*QR_001011010001+P_002110010*QR_001011010010+P_002110110*QR_001011010011+P_102010010*QR_001011010100+P_102010110*QR_001011010101+P_102110010*QR_001011010110+P_102110110*QR_001011010111+P_202010010*QR_001011010200+P_202010110*QR_001011010201+P_202110010*QR_001011010210+P_202110110*QR_001011010211); ans_temp[ans_id*36+28]+=Pmtrx[2]*(P_002010010*QR_000012010000+P_002010110*QR_000012010001+P_002110010*QR_000012010010+P_002110110*QR_000012010011+P_102010010*QR_000012010100+P_102010110*QR_000012010101+P_102110010*QR_000012010110+P_102110110*QR_000012010111+P_202010010*QR_000012010200+P_202010110*QR_000012010201+P_202110010*QR_000012010210+P_202110110*QR_000012010211); ans_temp[ans_id*36+28]+=Pmtrx[3]*(P_002010010*QR_001010011000+P_002010110*QR_001010011001+P_002110010*QR_001010011010+P_002110110*QR_001010011011+P_102010010*QR_001010011100+P_102010110*QR_001010011101+P_102110010*QR_001010011110+P_102110110*QR_001010011111+P_202010010*QR_001010011200+P_202010110*QR_001010011201+P_202110010*QR_001010011210+P_202110110*QR_001010011211); ans_temp[ans_id*36+28]+=Pmtrx[4]*(P_002010010*QR_000011011000+P_002010110*QR_000011011001+P_002110010*QR_000011011010+P_002110110*QR_000011011011+P_102010010*QR_000011011100+P_102010110*QR_000011011101+P_102110010*QR_000011011110+P_102110110*QR_000011011111+P_202010010*QR_000011011200+P_202010110*QR_000011011201+P_202110010*QR_000011011210+P_202110110*QR_000011011211); ans_temp[ans_id*36+28]+=Pmtrx[5]*(P_002010010*QR_000010012000+P_002010110*QR_000010012001+P_002110010*QR_000010012010+P_002110110*QR_000010012011+P_102010010*QR_000010012100+P_102010110*QR_000010012101+P_102110010*QR_000010012110+P_102110110*QR_000010012111+P_202010010*QR_000010012200+P_202010110*QR_000010012201+P_202110010*QR_000010012210+P_202110110*QR_000010012211); ans_temp[ans_id*36+29]+=Pmtrx[0]*(P_002010010*QR_002000020000+P_002010110*QR_002000020001+P_002110010*QR_002000020010+P_002110110*QR_002000020011+P_102010010*QR_002000020100+P_102010110*QR_002000020101+P_102110010*QR_002000020110+P_102110110*QR_002000020111+P_202010010*QR_002000020200+P_202010110*QR_002000020201+P_202110010*QR_002000020210+P_202110110*QR_002000020211); ans_temp[ans_id*36+29]+=Pmtrx[1]*(P_002010010*QR_001001020000+P_002010110*QR_001001020001+P_002110010*QR_001001020010+P_002110110*QR_001001020011+P_102010010*QR_001001020100+P_102010110*QR_001001020101+P_102110010*QR_001001020110+P_102110110*QR_001001020111+P_202010010*QR_001001020200+P_202010110*QR_001001020201+P_202110010*QR_001001020210+P_202110110*QR_001001020211); ans_temp[ans_id*36+29]+=Pmtrx[2]*(P_002010010*QR_000002020000+P_002010110*QR_000002020001+P_002110010*QR_000002020010+P_002110110*QR_000002020011+P_102010010*QR_000002020100+P_102010110*QR_000002020101+P_102110010*QR_000002020110+P_102110110*QR_000002020111+P_202010010*QR_000002020200+P_202010110*QR_000002020201+P_202110010*QR_000002020210+P_202110110*QR_000002020211); ans_temp[ans_id*36+29]+=Pmtrx[3]*(P_002010010*QR_001000021000+P_002010110*QR_001000021001+P_002110010*QR_001000021010+P_002110110*QR_001000021011+P_102010010*QR_001000021100+P_102010110*QR_001000021101+P_102110010*QR_001000021110+P_102110110*QR_001000021111+P_202010010*QR_001000021200+P_202010110*QR_001000021201+P_202110010*QR_001000021210+P_202110110*QR_001000021211); ans_temp[ans_id*36+29]+=Pmtrx[4]*(P_002010010*QR_000001021000+P_002010110*QR_000001021001+P_002110010*QR_000001021010+P_002110110*QR_000001021011+P_102010010*QR_000001021100+P_102010110*QR_000001021101+P_102110010*QR_000001021110+P_102110110*QR_000001021111+P_202010010*QR_000001021200+P_202010110*QR_000001021201+P_202110010*QR_000001021210+P_202110110*QR_000001021211); ans_temp[ans_id*36+29]+=Pmtrx[5]*(P_002010010*QR_000000022000+P_002010110*QR_000000022001+P_002110010*QR_000000022010+P_002110110*QR_000000022011+P_102010010*QR_000000022100+P_102010110*QR_000000022101+P_102110010*QR_000000022110+P_102110110*QR_000000022111+P_202010010*QR_000000022200+P_202010110*QR_000000022201+P_202110010*QR_000000022210+P_202110110*QR_000000022211); ans_temp[ans_id*36+24]+=Pmtrx[6]*(P_001011010*QR_022000000000+P_001011110*QR_022000000001+P_001111010*QR_022000000010+P_001111110*QR_022000000011+P_001211010*QR_022000000020+P_001211110*QR_022000000021+P_101011010*QR_022000000100+P_101011110*QR_022000000101+P_101111010*QR_022000000110+P_101111110*QR_022000000111+P_101211010*QR_022000000120+P_101211110*QR_022000000121); ans_temp[ans_id*36+24]+=Pmtrx[7]*(P_001011010*QR_021001000000+P_001011110*QR_021001000001+P_001111010*QR_021001000010+P_001111110*QR_021001000011+P_001211010*QR_021001000020+P_001211110*QR_021001000021+P_101011010*QR_021001000100+P_101011110*QR_021001000101+P_101111010*QR_021001000110+P_101111110*QR_021001000111+P_101211010*QR_021001000120+P_101211110*QR_021001000121); ans_temp[ans_id*36+24]+=Pmtrx[8]*(P_001011010*QR_020002000000+P_001011110*QR_020002000001+P_001111010*QR_020002000010+P_001111110*QR_020002000011+P_001211010*QR_020002000020+P_001211110*QR_020002000021+P_101011010*QR_020002000100+P_101011110*QR_020002000101+P_101111010*QR_020002000110+P_101111110*QR_020002000111+P_101211010*QR_020002000120+P_101211110*QR_020002000121); ans_temp[ans_id*36+24]+=Pmtrx[9]*(P_001011010*QR_021000001000+P_001011110*QR_021000001001+P_001111010*QR_021000001010+P_001111110*QR_021000001011+P_001211010*QR_021000001020+P_001211110*QR_021000001021+P_101011010*QR_021000001100+P_101011110*QR_021000001101+P_101111010*QR_021000001110+P_101111110*QR_021000001111+P_101211010*QR_021000001120+P_101211110*QR_021000001121); ans_temp[ans_id*36+24]+=Pmtrx[10]*(P_001011010*QR_020001001000+P_001011110*QR_020001001001+P_001111010*QR_020001001010+P_001111110*QR_020001001011+P_001211010*QR_020001001020+P_001211110*QR_020001001021+P_101011010*QR_020001001100+P_101011110*QR_020001001101+P_101111010*QR_020001001110+P_101111110*QR_020001001111+P_101211010*QR_020001001120+P_101211110*QR_020001001121); ans_temp[ans_id*36+24]+=Pmtrx[11]*(P_001011010*QR_020000002000+P_001011110*QR_020000002001+P_001111010*QR_020000002010+P_001111110*QR_020000002011+P_001211010*QR_020000002020+P_001211110*QR_020000002021+P_101011010*QR_020000002100+P_101011110*QR_020000002101+P_101111010*QR_020000002110+P_101111110*QR_020000002111+P_101211010*QR_020000002120+P_101211110*QR_020000002121); ans_temp[ans_id*36+25]+=Pmtrx[6]*(P_001011010*QR_012010000000+P_001011110*QR_012010000001+P_001111010*QR_012010000010+P_001111110*QR_012010000011+P_001211010*QR_012010000020+P_001211110*QR_012010000021+P_101011010*QR_012010000100+P_101011110*QR_012010000101+P_101111010*QR_012010000110+P_101111110*QR_012010000111+P_101211010*QR_012010000120+P_101211110*QR_012010000121); ans_temp[ans_id*36+25]+=Pmtrx[7]*(P_001011010*QR_011011000000+P_001011110*QR_011011000001+P_001111010*QR_011011000010+P_001111110*QR_011011000011+P_001211010*QR_011011000020+P_001211110*QR_011011000021+P_101011010*QR_011011000100+P_101011110*QR_011011000101+P_101111010*QR_011011000110+P_101111110*QR_011011000111+P_101211010*QR_011011000120+P_101211110*QR_011011000121); ans_temp[ans_id*36+25]+=Pmtrx[8]*(P_001011010*QR_010012000000+P_001011110*QR_010012000001+P_001111010*QR_010012000010+P_001111110*QR_010012000011+P_001211010*QR_010012000020+P_001211110*QR_010012000021+P_101011010*QR_010012000100+P_101011110*QR_010012000101+P_101111010*QR_010012000110+P_101111110*QR_010012000111+P_101211010*QR_010012000120+P_101211110*QR_010012000121); ans_temp[ans_id*36+25]+=Pmtrx[9]*(P_001011010*QR_011010001000+P_001011110*QR_011010001001+P_001111010*QR_011010001010+P_001111110*QR_011010001011+P_001211010*QR_011010001020+P_001211110*QR_011010001021+P_101011010*QR_011010001100+P_101011110*QR_011010001101+P_101111010*QR_011010001110+P_101111110*QR_011010001111+P_101211010*QR_011010001120+P_101211110*QR_011010001121); ans_temp[ans_id*36+25]+=Pmtrx[10]*(P_001011010*QR_010011001000+P_001011110*QR_010011001001+P_001111010*QR_010011001010+P_001111110*QR_010011001011+P_001211010*QR_010011001020+P_001211110*QR_010011001021+P_101011010*QR_010011001100+P_101011110*QR_010011001101+P_101111010*QR_010011001110+P_101111110*QR_010011001111+P_101211010*QR_010011001120+P_101211110*QR_010011001121); ans_temp[ans_id*36+25]+=Pmtrx[11]*(P_001011010*QR_010010002000+P_001011110*QR_010010002001+P_001111010*QR_010010002010+P_001111110*QR_010010002011+P_001211010*QR_010010002020+P_001211110*QR_010010002021+P_101011010*QR_010010002100+P_101011110*QR_010010002101+P_101111010*QR_010010002110+P_101111110*QR_010010002111+P_101211010*QR_010010002120+P_101211110*QR_010010002121); ans_temp[ans_id*36+26]+=Pmtrx[6]*(P_001011010*QR_002020000000+P_001011110*QR_002020000001+P_001111010*QR_002020000010+P_001111110*QR_002020000011+P_001211010*QR_002020000020+P_001211110*QR_002020000021+P_101011010*QR_002020000100+P_101011110*QR_002020000101+P_101111010*QR_002020000110+P_101111110*QR_002020000111+P_101211010*QR_002020000120+P_101211110*QR_002020000121); ans_temp[ans_id*36+26]+=Pmtrx[7]*(P_001011010*QR_001021000000+P_001011110*QR_001021000001+P_001111010*QR_001021000010+P_001111110*QR_001021000011+P_001211010*QR_001021000020+P_001211110*QR_001021000021+P_101011010*QR_001021000100+P_101011110*QR_001021000101+P_101111010*QR_001021000110+P_101111110*QR_001021000111+P_101211010*QR_001021000120+P_101211110*QR_001021000121); ans_temp[ans_id*36+26]+=Pmtrx[8]*(P_001011010*QR_000022000000+P_001011110*QR_000022000001+P_001111010*QR_000022000010+P_001111110*QR_000022000011+P_001211010*QR_000022000020+P_001211110*QR_000022000021+P_101011010*QR_000022000100+P_101011110*QR_000022000101+P_101111010*QR_000022000110+P_101111110*QR_000022000111+P_101211010*QR_000022000120+P_101211110*QR_000022000121); ans_temp[ans_id*36+26]+=Pmtrx[9]*(P_001011010*QR_001020001000+P_001011110*QR_001020001001+P_001111010*QR_001020001010+P_001111110*QR_001020001011+P_001211010*QR_001020001020+P_001211110*QR_001020001021+P_101011010*QR_001020001100+P_101011110*QR_001020001101+P_101111010*QR_001020001110+P_101111110*QR_001020001111+P_101211010*QR_001020001120+P_101211110*QR_001020001121); ans_temp[ans_id*36+26]+=Pmtrx[10]*(P_001011010*QR_000021001000+P_001011110*QR_000021001001+P_001111010*QR_000021001010+P_001111110*QR_000021001011+P_001211010*QR_000021001020+P_001211110*QR_000021001021+P_101011010*QR_000021001100+P_101011110*QR_000021001101+P_101111010*QR_000021001110+P_101111110*QR_000021001111+P_101211010*QR_000021001120+P_101211110*QR_000021001121); ans_temp[ans_id*36+26]+=Pmtrx[11]*(P_001011010*QR_000020002000+P_001011110*QR_000020002001+P_001111010*QR_000020002010+P_001111110*QR_000020002011+P_001211010*QR_000020002020+P_001211110*QR_000020002021+P_101011010*QR_000020002100+P_101011110*QR_000020002101+P_101111010*QR_000020002110+P_101111110*QR_000020002111+P_101211010*QR_000020002120+P_101211110*QR_000020002121); ans_temp[ans_id*36+27]+=Pmtrx[6]*(P_001011010*QR_012000010000+P_001011110*QR_012000010001+P_001111010*QR_012000010010+P_001111110*QR_012000010011+P_001211010*QR_012000010020+P_001211110*QR_012000010021+P_101011010*QR_012000010100+P_101011110*QR_012000010101+P_101111010*QR_012000010110+P_101111110*QR_012000010111+P_101211010*QR_012000010120+P_101211110*QR_012000010121); ans_temp[ans_id*36+27]+=Pmtrx[7]*(P_001011010*QR_011001010000+P_001011110*QR_011001010001+P_001111010*QR_011001010010+P_001111110*QR_011001010011+P_001211010*QR_011001010020+P_001211110*QR_011001010021+P_101011010*QR_011001010100+P_101011110*QR_011001010101+P_101111010*QR_011001010110+P_101111110*QR_011001010111+P_101211010*QR_011001010120+P_101211110*QR_011001010121); ans_temp[ans_id*36+27]+=Pmtrx[8]*(P_001011010*QR_010002010000+P_001011110*QR_010002010001+P_001111010*QR_010002010010+P_001111110*QR_010002010011+P_001211010*QR_010002010020+P_001211110*QR_010002010021+P_101011010*QR_010002010100+P_101011110*QR_010002010101+P_101111010*QR_010002010110+P_101111110*QR_010002010111+P_101211010*QR_010002010120+P_101211110*QR_010002010121); ans_temp[ans_id*36+27]+=Pmtrx[9]*(P_001011010*QR_011000011000+P_001011110*QR_011000011001+P_001111010*QR_011000011010+P_001111110*QR_011000011011+P_001211010*QR_011000011020+P_001211110*QR_011000011021+P_101011010*QR_011000011100+P_101011110*QR_011000011101+P_101111010*QR_011000011110+P_101111110*QR_011000011111+P_101211010*QR_011000011120+P_101211110*QR_011000011121); ans_temp[ans_id*36+27]+=Pmtrx[10]*(P_001011010*QR_010001011000+P_001011110*QR_010001011001+P_001111010*QR_010001011010+P_001111110*QR_010001011011+P_001211010*QR_010001011020+P_001211110*QR_010001011021+P_101011010*QR_010001011100+P_101011110*QR_010001011101+P_101111010*QR_010001011110+P_101111110*QR_010001011111+P_101211010*QR_010001011120+P_101211110*QR_010001011121); ans_temp[ans_id*36+27]+=Pmtrx[11]*(P_001011010*QR_010000012000+P_001011110*QR_010000012001+P_001111010*QR_010000012010+P_001111110*QR_010000012011+P_001211010*QR_010000012020+P_001211110*QR_010000012021+P_101011010*QR_010000012100+P_101011110*QR_010000012101+P_101111010*QR_010000012110+P_101111110*QR_010000012111+P_101211010*QR_010000012120+P_101211110*QR_010000012121); ans_temp[ans_id*36+28]+=Pmtrx[6]*(P_001011010*QR_002010010000+P_001011110*QR_002010010001+P_001111010*QR_002010010010+P_001111110*QR_002010010011+P_001211010*QR_002010010020+P_001211110*QR_002010010021+P_101011010*QR_002010010100+P_101011110*QR_002010010101+P_101111010*QR_002010010110+P_101111110*QR_002010010111+P_101211010*QR_002010010120+P_101211110*QR_002010010121); ans_temp[ans_id*36+28]+=Pmtrx[7]*(P_001011010*QR_001011010000+P_001011110*QR_001011010001+P_001111010*QR_001011010010+P_001111110*QR_001011010011+P_001211010*QR_001011010020+P_001211110*QR_001011010021+P_101011010*QR_001011010100+P_101011110*QR_001011010101+P_101111010*QR_001011010110+P_101111110*QR_001011010111+P_101211010*QR_001011010120+P_101211110*QR_001011010121); ans_temp[ans_id*36+28]+=Pmtrx[8]*(P_001011010*QR_000012010000+P_001011110*QR_000012010001+P_001111010*QR_000012010010+P_001111110*QR_000012010011+P_001211010*QR_000012010020+P_001211110*QR_000012010021+P_101011010*QR_000012010100+P_101011110*QR_000012010101+P_101111010*QR_000012010110+P_101111110*QR_000012010111+P_101211010*QR_000012010120+P_101211110*QR_000012010121); ans_temp[ans_id*36+28]+=Pmtrx[9]*(P_001011010*QR_001010011000+P_001011110*QR_001010011001+P_001111010*QR_001010011010+P_001111110*QR_001010011011+P_001211010*QR_001010011020+P_001211110*QR_001010011021+P_101011010*QR_001010011100+P_101011110*QR_001010011101+P_101111010*QR_001010011110+P_101111110*QR_001010011111+P_101211010*QR_001010011120+P_101211110*QR_001010011121); ans_temp[ans_id*36+28]+=Pmtrx[10]*(P_001011010*QR_000011011000+P_001011110*QR_000011011001+P_001111010*QR_000011011010+P_001111110*QR_000011011011+P_001211010*QR_000011011020+P_001211110*QR_000011011021+P_101011010*QR_000011011100+P_101011110*QR_000011011101+P_101111010*QR_000011011110+P_101111110*QR_000011011111+P_101211010*QR_000011011120+P_101211110*QR_000011011121); ans_temp[ans_id*36+28]+=Pmtrx[11]*(P_001011010*QR_000010012000+P_001011110*QR_000010012001+P_001111010*QR_000010012010+P_001111110*QR_000010012011+P_001211010*QR_000010012020+P_001211110*QR_000010012021+P_101011010*QR_000010012100+P_101011110*QR_000010012101+P_101111010*QR_000010012110+P_101111110*QR_000010012111+P_101211010*QR_000010012120+P_101211110*QR_000010012121); ans_temp[ans_id*36+29]+=Pmtrx[6]*(P_001011010*QR_002000020000+P_001011110*QR_002000020001+P_001111010*QR_002000020010+P_001111110*QR_002000020011+P_001211010*QR_002000020020+P_001211110*QR_002000020021+P_101011010*QR_002000020100+P_101011110*QR_002000020101+P_101111010*QR_002000020110+P_101111110*QR_002000020111+P_101211010*QR_002000020120+P_101211110*QR_002000020121); ans_temp[ans_id*36+29]+=Pmtrx[7]*(P_001011010*QR_001001020000+P_001011110*QR_001001020001+P_001111010*QR_001001020010+P_001111110*QR_001001020011+P_001211010*QR_001001020020+P_001211110*QR_001001020021+P_101011010*QR_001001020100+P_101011110*QR_001001020101+P_101111010*QR_001001020110+P_101111110*QR_001001020111+P_101211010*QR_001001020120+P_101211110*QR_001001020121); ans_temp[ans_id*36+29]+=Pmtrx[8]*(P_001011010*QR_000002020000+P_001011110*QR_000002020001+P_001111010*QR_000002020010+P_001111110*QR_000002020011+P_001211010*QR_000002020020+P_001211110*QR_000002020021+P_101011010*QR_000002020100+P_101011110*QR_000002020101+P_101111010*QR_000002020110+P_101111110*QR_000002020111+P_101211010*QR_000002020120+P_101211110*QR_000002020121); ans_temp[ans_id*36+29]+=Pmtrx[9]*(P_001011010*QR_001000021000+P_001011110*QR_001000021001+P_001111010*QR_001000021010+P_001111110*QR_001000021011+P_001211010*QR_001000021020+P_001211110*QR_001000021021+P_101011010*QR_001000021100+P_101011110*QR_001000021101+P_101111010*QR_001000021110+P_101111110*QR_001000021111+P_101211010*QR_001000021120+P_101211110*QR_001000021121); ans_temp[ans_id*36+29]+=Pmtrx[10]*(P_001011010*QR_000001021000+P_001011110*QR_000001021001+P_001111010*QR_000001021010+P_001111110*QR_000001021011+P_001211010*QR_000001021020+P_001211110*QR_000001021021+P_101011010*QR_000001021100+P_101011110*QR_000001021101+P_101111010*QR_000001021110+P_101111110*QR_000001021111+P_101211010*QR_000001021120+P_101211110*QR_000001021121); ans_temp[ans_id*36+29]+=Pmtrx[11]*(P_001011010*QR_000000022000+P_001011110*QR_000000022001+P_001111010*QR_000000022010+P_001111110*QR_000000022011+P_001211010*QR_000000022020+P_001211110*QR_000000022021+P_101011010*QR_000000022100+P_101011110*QR_000000022101+P_101111010*QR_000000022110+P_101111110*QR_000000022111+P_101211010*QR_000000022120+P_101211110*QR_000000022121); ans_temp[ans_id*36+24]+=Pmtrx[12]*(P_000012010*QR_022000000000+P_000012110*QR_022000000001+P_000112010*QR_022000000010+P_000112110*QR_022000000011+P_000212010*QR_022000000020+P_000212110*QR_022000000021+P_000312010*QR_022000000030+P_000312110*QR_022000000031); ans_temp[ans_id*36+24]+=Pmtrx[13]*(P_000012010*QR_021001000000+P_000012110*QR_021001000001+P_000112010*QR_021001000010+P_000112110*QR_021001000011+P_000212010*QR_021001000020+P_000212110*QR_021001000021+P_000312010*QR_021001000030+P_000312110*QR_021001000031); ans_temp[ans_id*36+24]+=Pmtrx[14]*(P_000012010*QR_020002000000+P_000012110*QR_020002000001+P_000112010*QR_020002000010+P_000112110*QR_020002000011+P_000212010*QR_020002000020+P_000212110*QR_020002000021+P_000312010*QR_020002000030+P_000312110*QR_020002000031); ans_temp[ans_id*36+24]+=Pmtrx[15]*(P_000012010*QR_021000001000+P_000012110*QR_021000001001+P_000112010*QR_021000001010+P_000112110*QR_021000001011+P_000212010*QR_021000001020+P_000212110*QR_021000001021+P_000312010*QR_021000001030+P_000312110*QR_021000001031); ans_temp[ans_id*36+24]+=Pmtrx[16]*(P_000012010*QR_020001001000+P_000012110*QR_020001001001+P_000112010*QR_020001001010+P_000112110*QR_020001001011+P_000212010*QR_020001001020+P_000212110*QR_020001001021+P_000312010*QR_020001001030+P_000312110*QR_020001001031); ans_temp[ans_id*36+24]+=Pmtrx[17]*(P_000012010*QR_020000002000+P_000012110*QR_020000002001+P_000112010*QR_020000002010+P_000112110*QR_020000002011+P_000212010*QR_020000002020+P_000212110*QR_020000002021+P_000312010*QR_020000002030+P_000312110*QR_020000002031); ans_temp[ans_id*36+25]+=Pmtrx[12]*(P_000012010*QR_012010000000+P_000012110*QR_012010000001+P_000112010*QR_012010000010+P_000112110*QR_012010000011+P_000212010*QR_012010000020+P_000212110*QR_012010000021+P_000312010*QR_012010000030+P_000312110*QR_012010000031); ans_temp[ans_id*36+25]+=Pmtrx[13]*(P_000012010*QR_011011000000+P_000012110*QR_011011000001+P_000112010*QR_011011000010+P_000112110*QR_011011000011+P_000212010*QR_011011000020+P_000212110*QR_011011000021+P_000312010*QR_011011000030+P_000312110*QR_011011000031); ans_temp[ans_id*36+25]+=Pmtrx[14]*(P_000012010*QR_010012000000+P_000012110*QR_010012000001+P_000112010*QR_010012000010+P_000112110*QR_010012000011+P_000212010*QR_010012000020+P_000212110*QR_010012000021+P_000312010*QR_010012000030+P_000312110*QR_010012000031); ans_temp[ans_id*36+25]+=Pmtrx[15]*(P_000012010*QR_011010001000+P_000012110*QR_011010001001+P_000112010*QR_011010001010+P_000112110*QR_011010001011+P_000212010*QR_011010001020+P_000212110*QR_011010001021+P_000312010*QR_011010001030+P_000312110*QR_011010001031); ans_temp[ans_id*36+25]+=Pmtrx[16]*(P_000012010*QR_010011001000+P_000012110*QR_010011001001+P_000112010*QR_010011001010+P_000112110*QR_010011001011+P_000212010*QR_010011001020+P_000212110*QR_010011001021+P_000312010*QR_010011001030+P_000312110*QR_010011001031); ans_temp[ans_id*36+25]+=Pmtrx[17]*(P_000012010*QR_010010002000+P_000012110*QR_010010002001+P_000112010*QR_010010002010+P_000112110*QR_010010002011+P_000212010*QR_010010002020+P_000212110*QR_010010002021+P_000312010*QR_010010002030+P_000312110*QR_010010002031); ans_temp[ans_id*36+26]+=Pmtrx[12]*(P_000012010*QR_002020000000+P_000012110*QR_002020000001+P_000112010*QR_002020000010+P_000112110*QR_002020000011+P_000212010*QR_002020000020+P_000212110*QR_002020000021+P_000312010*QR_002020000030+P_000312110*QR_002020000031); ans_temp[ans_id*36+26]+=Pmtrx[13]*(P_000012010*QR_001021000000+P_000012110*QR_001021000001+P_000112010*QR_001021000010+P_000112110*QR_001021000011+P_000212010*QR_001021000020+P_000212110*QR_001021000021+P_000312010*QR_001021000030+P_000312110*QR_001021000031); ans_temp[ans_id*36+26]+=Pmtrx[14]*(P_000012010*QR_000022000000+P_000012110*QR_000022000001+P_000112010*QR_000022000010+P_000112110*QR_000022000011+P_000212010*QR_000022000020+P_000212110*QR_000022000021+P_000312010*QR_000022000030+P_000312110*QR_000022000031); ans_temp[ans_id*36+26]+=Pmtrx[15]*(P_000012010*QR_001020001000+P_000012110*QR_001020001001+P_000112010*QR_001020001010+P_000112110*QR_001020001011+P_000212010*QR_001020001020+P_000212110*QR_001020001021+P_000312010*QR_001020001030+P_000312110*QR_001020001031); ans_temp[ans_id*36+26]+=Pmtrx[16]*(P_000012010*QR_000021001000+P_000012110*QR_000021001001+P_000112010*QR_000021001010+P_000112110*QR_000021001011+P_000212010*QR_000021001020+P_000212110*QR_000021001021+P_000312010*QR_000021001030+P_000312110*QR_000021001031); ans_temp[ans_id*36+26]+=Pmtrx[17]*(P_000012010*QR_000020002000+P_000012110*QR_000020002001+P_000112010*QR_000020002010+P_000112110*QR_000020002011+P_000212010*QR_000020002020+P_000212110*QR_000020002021+P_000312010*QR_000020002030+P_000312110*QR_000020002031); ans_temp[ans_id*36+27]+=Pmtrx[12]*(P_000012010*QR_012000010000+P_000012110*QR_012000010001+P_000112010*QR_012000010010+P_000112110*QR_012000010011+P_000212010*QR_012000010020+P_000212110*QR_012000010021+P_000312010*QR_012000010030+P_000312110*QR_012000010031); ans_temp[ans_id*36+27]+=Pmtrx[13]*(P_000012010*QR_011001010000+P_000012110*QR_011001010001+P_000112010*QR_011001010010+P_000112110*QR_011001010011+P_000212010*QR_011001010020+P_000212110*QR_011001010021+P_000312010*QR_011001010030+P_000312110*QR_011001010031); ans_temp[ans_id*36+27]+=Pmtrx[14]*(P_000012010*QR_010002010000+P_000012110*QR_010002010001+P_000112010*QR_010002010010+P_000112110*QR_010002010011+P_000212010*QR_010002010020+P_000212110*QR_010002010021+P_000312010*QR_010002010030+P_000312110*QR_010002010031); ans_temp[ans_id*36+27]+=Pmtrx[15]*(P_000012010*QR_011000011000+P_000012110*QR_011000011001+P_000112010*QR_011000011010+P_000112110*QR_011000011011+P_000212010*QR_011000011020+P_000212110*QR_011000011021+P_000312010*QR_011000011030+P_000312110*QR_011000011031); ans_temp[ans_id*36+27]+=Pmtrx[16]*(P_000012010*QR_010001011000+P_000012110*QR_010001011001+P_000112010*QR_010001011010+P_000112110*QR_010001011011+P_000212010*QR_010001011020+P_000212110*QR_010001011021+P_000312010*QR_010001011030+P_000312110*QR_010001011031); ans_temp[ans_id*36+27]+=Pmtrx[17]*(P_000012010*QR_010000012000+P_000012110*QR_010000012001+P_000112010*QR_010000012010+P_000112110*QR_010000012011+P_000212010*QR_010000012020+P_000212110*QR_010000012021+P_000312010*QR_010000012030+P_000312110*QR_010000012031); ans_temp[ans_id*36+28]+=Pmtrx[12]*(P_000012010*QR_002010010000+P_000012110*QR_002010010001+P_000112010*QR_002010010010+P_000112110*QR_002010010011+P_000212010*QR_002010010020+P_000212110*QR_002010010021+P_000312010*QR_002010010030+P_000312110*QR_002010010031); ans_temp[ans_id*36+28]+=Pmtrx[13]*(P_000012010*QR_001011010000+P_000012110*QR_001011010001+P_000112010*QR_001011010010+P_000112110*QR_001011010011+P_000212010*QR_001011010020+P_000212110*QR_001011010021+P_000312010*QR_001011010030+P_000312110*QR_001011010031); ans_temp[ans_id*36+28]+=Pmtrx[14]*(P_000012010*QR_000012010000+P_000012110*QR_000012010001+P_000112010*QR_000012010010+P_000112110*QR_000012010011+P_000212010*QR_000012010020+P_000212110*QR_000012010021+P_000312010*QR_000012010030+P_000312110*QR_000012010031); ans_temp[ans_id*36+28]+=Pmtrx[15]*(P_000012010*QR_001010011000+P_000012110*QR_001010011001+P_000112010*QR_001010011010+P_000112110*QR_001010011011+P_000212010*QR_001010011020+P_000212110*QR_001010011021+P_000312010*QR_001010011030+P_000312110*QR_001010011031); ans_temp[ans_id*36+28]+=Pmtrx[16]*(P_000012010*QR_000011011000+P_000012110*QR_000011011001+P_000112010*QR_000011011010+P_000112110*QR_000011011011+P_000212010*QR_000011011020+P_000212110*QR_000011011021+P_000312010*QR_000011011030+P_000312110*QR_000011011031); ans_temp[ans_id*36+28]+=Pmtrx[17]*(P_000012010*QR_000010012000+P_000012110*QR_000010012001+P_000112010*QR_000010012010+P_000112110*QR_000010012011+P_000212010*QR_000010012020+P_000212110*QR_000010012021+P_000312010*QR_000010012030+P_000312110*QR_000010012031); ans_temp[ans_id*36+29]+=Pmtrx[12]*(P_000012010*QR_002000020000+P_000012110*QR_002000020001+P_000112010*QR_002000020010+P_000112110*QR_002000020011+P_000212010*QR_002000020020+P_000212110*QR_002000020021+P_000312010*QR_002000020030+P_000312110*QR_002000020031); ans_temp[ans_id*36+29]+=Pmtrx[13]*(P_000012010*QR_001001020000+P_000012110*QR_001001020001+P_000112010*QR_001001020010+P_000112110*QR_001001020011+P_000212010*QR_001001020020+P_000212110*QR_001001020021+P_000312010*QR_001001020030+P_000312110*QR_001001020031); ans_temp[ans_id*36+29]+=Pmtrx[14]*(P_000012010*QR_000002020000+P_000012110*QR_000002020001+P_000112010*QR_000002020010+P_000112110*QR_000002020011+P_000212010*QR_000002020020+P_000212110*QR_000002020021+P_000312010*QR_000002020030+P_000312110*QR_000002020031); ans_temp[ans_id*36+29]+=Pmtrx[15]*(P_000012010*QR_001000021000+P_000012110*QR_001000021001+P_000112010*QR_001000021010+P_000112110*QR_001000021011+P_000212010*QR_001000021020+P_000212110*QR_001000021021+P_000312010*QR_001000021030+P_000312110*QR_001000021031); ans_temp[ans_id*36+29]+=Pmtrx[16]*(P_000012010*QR_000001021000+P_000012110*QR_000001021001+P_000112010*QR_000001021010+P_000112110*QR_000001021011+P_000212010*QR_000001021020+P_000212110*QR_000001021021+P_000312010*QR_000001021030+P_000312110*QR_000001021031); ans_temp[ans_id*36+29]+=Pmtrx[17]*(P_000012010*QR_000000022000+P_000012110*QR_000000022001+P_000112010*QR_000000022010+P_000112110*QR_000000022011+P_000212010*QR_000000022020+P_000212110*QR_000000022021+P_000312010*QR_000000022030+P_000312110*QR_000000022031); ans_temp[ans_id*36+24]+=Pmtrx[18]*(P_001010011*QR_022000000000+P_001010111*QR_022000000001+P_001010211*QR_022000000002+P_001110011*QR_022000000010+P_001110111*QR_022000000011+P_001110211*QR_022000000012+P_101010011*QR_022000000100+P_101010111*QR_022000000101+P_101010211*QR_022000000102+P_101110011*QR_022000000110+P_101110111*QR_022000000111+P_101110211*QR_022000000112); ans_temp[ans_id*36+24]+=Pmtrx[19]*(P_001010011*QR_021001000000+P_001010111*QR_021001000001+P_001010211*QR_021001000002+P_001110011*QR_021001000010+P_001110111*QR_021001000011+P_001110211*QR_021001000012+P_101010011*QR_021001000100+P_101010111*QR_021001000101+P_101010211*QR_021001000102+P_101110011*QR_021001000110+P_101110111*QR_021001000111+P_101110211*QR_021001000112); ans_temp[ans_id*36+24]+=Pmtrx[20]*(P_001010011*QR_020002000000+P_001010111*QR_020002000001+P_001010211*QR_020002000002+P_001110011*QR_020002000010+P_001110111*QR_020002000011+P_001110211*QR_020002000012+P_101010011*QR_020002000100+P_101010111*QR_020002000101+P_101010211*QR_020002000102+P_101110011*QR_020002000110+P_101110111*QR_020002000111+P_101110211*QR_020002000112); ans_temp[ans_id*36+24]+=Pmtrx[21]*(P_001010011*QR_021000001000+P_001010111*QR_021000001001+P_001010211*QR_021000001002+P_001110011*QR_021000001010+P_001110111*QR_021000001011+P_001110211*QR_021000001012+P_101010011*QR_021000001100+P_101010111*QR_021000001101+P_101010211*QR_021000001102+P_101110011*QR_021000001110+P_101110111*QR_021000001111+P_101110211*QR_021000001112); ans_temp[ans_id*36+24]+=Pmtrx[22]*(P_001010011*QR_020001001000+P_001010111*QR_020001001001+P_001010211*QR_020001001002+P_001110011*QR_020001001010+P_001110111*QR_020001001011+P_001110211*QR_020001001012+P_101010011*QR_020001001100+P_101010111*QR_020001001101+P_101010211*QR_020001001102+P_101110011*QR_020001001110+P_101110111*QR_020001001111+P_101110211*QR_020001001112); ans_temp[ans_id*36+24]+=Pmtrx[23]*(P_001010011*QR_020000002000+P_001010111*QR_020000002001+P_001010211*QR_020000002002+P_001110011*QR_020000002010+P_001110111*QR_020000002011+P_001110211*QR_020000002012+P_101010011*QR_020000002100+P_101010111*QR_020000002101+P_101010211*QR_020000002102+P_101110011*QR_020000002110+P_101110111*QR_020000002111+P_101110211*QR_020000002112); ans_temp[ans_id*36+25]+=Pmtrx[18]*(P_001010011*QR_012010000000+P_001010111*QR_012010000001+P_001010211*QR_012010000002+P_001110011*QR_012010000010+P_001110111*QR_012010000011+P_001110211*QR_012010000012+P_101010011*QR_012010000100+P_101010111*QR_012010000101+P_101010211*QR_012010000102+P_101110011*QR_012010000110+P_101110111*QR_012010000111+P_101110211*QR_012010000112); ans_temp[ans_id*36+25]+=Pmtrx[19]*(P_001010011*QR_011011000000+P_001010111*QR_011011000001+P_001010211*QR_011011000002+P_001110011*QR_011011000010+P_001110111*QR_011011000011+P_001110211*QR_011011000012+P_101010011*QR_011011000100+P_101010111*QR_011011000101+P_101010211*QR_011011000102+P_101110011*QR_011011000110+P_101110111*QR_011011000111+P_101110211*QR_011011000112); ans_temp[ans_id*36+25]+=Pmtrx[20]*(P_001010011*QR_010012000000+P_001010111*QR_010012000001+P_001010211*QR_010012000002+P_001110011*QR_010012000010+P_001110111*QR_010012000011+P_001110211*QR_010012000012+P_101010011*QR_010012000100+P_101010111*QR_010012000101+P_101010211*QR_010012000102+P_101110011*QR_010012000110+P_101110111*QR_010012000111+P_101110211*QR_010012000112); ans_temp[ans_id*36+25]+=Pmtrx[21]*(P_001010011*QR_011010001000+P_001010111*QR_011010001001+P_001010211*QR_011010001002+P_001110011*QR_011010001010+P_001110111*QR_011010001011+P_001110211*QR_011010001012+P_101010011*QR_011010001100+P_101010111*QR_011010001101+P_101010211*QR_011010001102+P_101110011*QR_011010001110+P_101110111*QR_011010001111+P_101110211*QR_011010001112); ans_temp[ans_id*36+25]+=Pmtrx[22]*(P_001010011*QR_010011001000+P_001010111*QR_010011001001+P_001010211*QR_010011001002+P_001110011*QR_010011001010+P_001110111*QR_010011001011+P_001110211*QR_010011001012+P_101010011*QR_010011001100+P_101010111*QR_010011001101+P_101010211*QR_010011001102+P_101110011*QR_010011001110+P_101110111*QR_010011001111+P_101110211*QR_010011001112); ans_temp[ans_id*36+25]+=Pmtrx[23]*(P_001010011*QR_010010002000+P_001010111*QR_010010002001+P_001010211*QR_010010002002+P_001110011*QR_010010002010+P_001110111*QR_010010002011+P_001110211*QR_010010002012+P_101010011*QR_010010002100+P_101010111*QR_010010002101+P_101010211*QR_010010002102+P_101110011*QR_010010002110+P_101110111*QR_010010002111+P_101110211*QR_010010002112); ans_temp[ans_id*36+26]+=Pmtrx[18]*(P_001010011*QR_002020000000+P_001010111*QR_002020000001+P_001010211*QR_002020000002+P_001110011*QR_002020000010+P_001110111*QR_002020000011+P_001110211*QR_002020000012+P_101010011*QR_002020000100+P_101010111*QR_002020000101+P_101010211*QR_002020000102+P_101110011*QR_002020000110+P_101110111*QR_002020000111+P_101110211*QR_002020000112); ans_temp[ans_id*36+26]+=Pmtrx[19]*(P_001010011*QR_001021000000+P_001010111*QR_001021000001+P_001010211*QR_001021000002+P_001110011*QR_001021000010+P_001110111*QR_001021000011+P_001110211*QR_001021000012+P_101010011*QR_001021000100+P_101010111*QR_001021000101+P_101010211*QR_001021000102+P_101110011*QR_001021000110+P_101110111*QR_001021000111+P_101110211*QR_001021000112); ans_temp[ans_id*36+26]+=Pmtrx[20]*(P_001010011*QR_000022000000+P_001010111*QR_000022000001+P_001010211*QR_000022000002+P_001110011*QR_000022000010+P_001110111*QR_000022000011+P_001110211*QR_000022000012+P_101010011*QR_000022000100+P_101010111*QR_000022000101+P_101010211*QR_000022000102+P_101110011*QR_000022000110+P_101110111*QR_000022000111+P_101110211*QR_000022000112); ans_temp[ans_id*36+26]+=Pmtrx[21]*(P_001010011*QR_001020001000+P_001010111*QR_001020001001+P_001010211*QR_001020001002+P_001110011*QR_001020001010+P_001110111*QR_001020001011+P_001110211*QR_001020001012+P_101010011*QR_001020001100+P_101010111*QR_001020001101+P_101010211*QR_001020001102+P_101110011*QR_001020001110+P_101110111*QR_001020001111+P_101110211*QR_001020001112); ans_temp[ans_id*36+26]+=Pmtrx[22]*(P_001010011*QR_000021001000+P_001010111*QR_000021001001+P_001010211*QR_000021001002+P_001110011*QR_000021001010+P_001110111*QR_000021001011+P_001110211*QR_000021001012+P_101010011*QR_000021001100+P_101010111*QR_000021001101+P_101010211*QR_000021001102+P_101110011*QR_000021001110+P_101110111*QR_000021001111+P_101110211*QR_000021001112); ans_temp[ans_id*36+26]+=Pmtrx[23]*(P_001010011*QR_000020002000+P_001010111*QR_000020002001+P_001010211*QR_000020002002+P_001110011*QR_000020002010+P_001110111*QR_000020002011+P_001110211*QR_000020002012+P_101010011*QR_000020002100+P_101010111*QR_000020002101+P_101010211*QR_000020002102+P_101110011*QR_000020002110+P_101110111*QR_000020002111+P_101110211*QR_000020002112); ans_temp[ans_id*36+27]+=Pmtrx[18]*(P_001010011*QR_012000010000+P_001010111*QR_012000010001+P_001010211*QR_012000010002+P_001110011*QR_012000010010+P_001110111*QR_012000010011+P_001110211*QR_012000010012+P_101010011*QR_012000010100+P_101010111*QR_012000010101+P_101010211*QR_012000010102+P_101110011*QR_012000010110+P_101110111*QR_012000010111+P_101110211*QR_012000010112); ans_temp[ans_id*36+27]+=Pmtrx[19]*(P_001010011*QR_011001010000+P_001010111*QR_011001010001+P_001010211*QR_011001010002+P_001110011*QR_011001010010+P_001110111*QR_011001010011+P_001110211*QR_011001010012+P_101010011*QR_011001010100+P_101010111*QR_011001010101+P_101010211*QR_011001010102+P_101110011*QR_011001010110+P_101110111*QR_011001010111+P_101110211*QR_011001010112); ans_temp[ans_id*36+27]+=Pmtrx[20]*(P_001010011*QR_010002010000+P_001010111*QR_010002010001+P_001010211*QR_010002010002+P_001110011*QR_010002010010+P_001110111*QR_010002010011+P_001110211*QR_010002010012+P_101010011*QR_010002010100+P_101010111*QR_010002010101+P_101010211*QR_010002010102+P_101110011*QR_010002010110+P_101110111*QR_010002010111+P_101110211*QR_010002010112); ans_temp[ans_id*36+27]+=Pmtrx[21]*(P_001010011*QR_011000011000+P_001010111*QR_011000011001+P_001010211*QR_011000011002+P_001110011*QR_011000011010+P_001110111*QR_011000011011+P_001110211*QR_011000011012+P_101010011*QR_011000011100+P_101010111*QR_011000011101+P_101010211*QR_011000011102+P_101110011*QR_011000011110+P_101110111*QR_011000011111+P_101110211*QR_011000011112); ans_temp[ans_id*36+27]+=Pmtrx[22]*(P_001010011*QR_010001011000+P_001010111*QR_010001011001+P_001010211*QR_010001011002+P_001110011*QR_010001011010+P_001110111*QR_010001011011+P_001110211*QR_010001011012+P_101010011*QR_010001011100+P_101010111*QR_010001011101+P_101010211*QR_010001011102+P_101110011*QR_010001011110+P_101110111*QR_010001011111+P_101110211*QR_010001011112); ans_temp[ans_id*36+27]+=Pmtrx[23]*(P_001010011*QR_010000012000+P_001010111*QR_010000012001+P_001010211*QR_010000012002+P_001110011*QR_010000012010+P_001110111*QR_010000012011+P_001110211*QR_010000012012+P_101010011*QR_010000012100+P_101010111*QR_010000012101+P_101010211*QR_010000012102+P_101110011*QR_010000012110+P_101110111*QR_010000012111+P_101110211*QR_010000012112); ans_temp[ans_id*36+28]+=Pmtrx[18]*(P_001010011*QR_002010010000+P_001010111*QR_002010010001+P_001010211*QR_002010010002+P_001110011*QR_002010010010+P_001110111*QR_002010010011+P_001110211*QR_002010010012+P_101010011*QR_002010010100+P_101010111*QR_002010010101+P_101010211*QR_002010010102+P_101110011*QR_002010010110+P_101110111*QR_002010010111+P_101110211*QR_002010010112); ans_temp[ans_id*36+28]+=Pmtrx[19]*(P_001010011*QR_001011010000+P_001010111*QR_001011010001+P_001010211*QR_001011010002+P_001110011*QR_001011010010+P_001110111*QR_001011010011+P_001110211*QR_001011010012+P_101010011*QR_001011010100+P_101010111*QR_001011010101+P_101010211*QR_001011010102+P_101110011*QR_001011010110+P_101110111*QR_001011010111+P_101110211*QR_001011010112); ans_temp[ans_id*36+28]+=Pmtrx[20]*(P_001010011*QR_000012010000+P_001010111*QR_000012010001+P_001010211*QR_000012010002+P_001110011*QR_000012010010+P_001110111*QR_000012010011+P_001110211*QR_000012010012+P_101010011*QR_000012010100+P_101010111*QR_000012010101+P_101010211*QR_000012010102+P_101110011*QR_000012010110+P_101110111*QR_000012010111+P_101110211*QR_000012010112); ans_temp[ans_id*36+28]+=Pmtrx[21]*(P_001010011*QR_001010011000+P_001010111*QR_001010011001+P_001010211*QR_001010011002+P_001110011*QR_001010011010+P_001110111*QR_001010011011+P_001110211*QR_001010011012+P_101010011*QR_001010011100+P_101010111*QR_001010011101+P_101010211*QR_001010011102+P_101110011*QR_001010011110+P_101110111*QR_001010011111+P_101110211*QR_001010011112); ans_temp[ans_id*36+28]+=Pmtrx[22]*(P_001010011*QR_000011011000+P_001010111*QR_000011011001+P_001010211*QR_000011011002+P_001110011*QR_000011011010+P_001110111*QR_000011011011+P_001110211*QR_000011011012+P_101010011*QR_000011011100+P_101010111*QR_000011011101+P_101010211*QR_000011011102+P_101110011*QR_000011011110+P_101110111*QR_000011011111+P_101110211*QR_000011011112); ans_temp[ans_id*36+28]+=Pmtrx[23]*(P_001010011*QR_000010012000+P_001010111*QR_000010012001+P_001010211*QR_000010012002+P_001110011*QR_000010012010+P_001110111*QR_000010012011+P_001110211*QR_000010012012+P_101010011*QR_000010012100+P_101010111*QR_000010012101+P_101010211*QR_000010012102+P_101110011*QR_000010012110+P_101110111*QR_000010012111+P_101110211*QR_000010012112); ans_temp[ans_id*36+29]+=Pmtrx[18]*(P_001010011*QR_002000020000+P_001010111*QR_002000020001+P_001010211*QR_002000020002+P_001110011*QR_002000020010+P_001110111*QR_002000020011+P_001110211*QR_002000020012+P_101010011*QR_002000020100+P_101010111*QR_002000020101+P_101010211*QR_002000020102+P_101110011*QR_002000020110+P_101110111*QR_002000020111+P_101110211*QR_002000020112); ans_temp[ans_id*36+29]+=Pmtrx[19]*(P_001010011*QR_001001020000+P_001010111*QR_001001020001+P_001010211*QR_001001020002+P_001110011*QR_001001020010+P_001110111*QR_001001020011+P_001110211*QR_001001020012+P_101010011*QR_001001020100+P_101010111*QR_001001020101+P_101010211*QR_001001020102+P_101110011*QR_001001020110+P_101110111*QR_001001020111+P_101110211*QR_001001020112); ans_temp[ans_id*36+29]+=Pmtrx[20]*(P_001010011*QR_000002020000+P_001010111*QR_000002020001+P_001010211*QR_000002020002+P_001110011*QR_000002020010+P_001110111*QR_000002020011+P_001110211*QR_000002020012+P_101010011*QR_000002020100+P_101010111*QR_000002020101+P_101010211*QR_000002020102+P_101110011*QR_000002020110+P_101110111*QR_000002020111+P_101110211*QR_000002020112); ans_temp[ans_id*36+29]+=Pmtrx[21]*(P_001010011*QR_001000021000+P_001010111*QR_001000021001+P_001010211*QR_001000021002+P_001110011*QR_001000021010+P_001110111*QR_001000021011+P_001110211*QR_001000021012+P_101010011*QR_001000021100+P_101010111*QR_001000021101+P_101010211*QR_001000021102+P_101110011*QR_001000021110+P_101110111*QR_001000021111+P_101110211*QR_001000021112); ans_temp[ans_id*36+29]+=Pmtrx[22]*(P_001010011*QR_000001021000+P_001010111*QR_000001021001+P_001010211*QR_000001021002+P_001110011*QR_000001021010+P_001110111*QR_000001021011+P_001110211*QR_000001021012+P_101010011*QR_000001021100+P_101010111*QR_000001021101+P_101010211*QR_000001021102+P_101110011*QR_000001021110+P_101110111*QR_000001021111+P_101110211*QR_000001021112); ans_temp[ans_id*36+29]+=Pmtrx[23]*(P_001010011*QR_000000022000+P_001010111*QR_000000022001+P_001010211*QR_000000022002+P_001110011*QR_000000022010+P_001110111*QR_000000022011+P_001110211*QR_000000022012+P_101010011*QR_000000022100+P_101010111*QR_000000022101+P_101010211*QR_000000022102+P_101110011*QR_000000022110+P_101110111*QR_000000022111+P_101110211*QR_000000022112); ans_temp[ans_id*36+24]+=Pmtrx[24]*(P_000011011*QR_022000000000+P_000011111*QR_022000000001+P_000011211*QR_022000000002+P_000111011*QR_022000000010+P_000111111*QR_022000000011+P_000111211*QR_022000000012+P_000211011*QR_022000000020+P_000211111*QR_022000000021+P_000211211*QR_022000000022); ans_temp[ans_id*36+24]+=Pmtrx[25]*(P_000011011*QR_021001000000+P_000011111*QR_021001000001+P_000011211*QR_021001000002+P_000111011*QR_021001000010+P_000111111*QR_021001000011+P_000111211*QR_021001000012+P_000211011*QR_021001000020+P_000211111*QR_021001000021+P_000211211*QR_021001000022); ans_temp[ans_id*36+24]+=Pmtrx[26]*(P_000011011*QR_020002000000+P_000011111*QR_020002000001+P_000011211*QR_020002000002+P_000111011*QR_020002000010+P_000111111*QR_020002000011+P_000111211*QR_020002000012+P_000211011*QR_020002000020+P_000211111*QR_020002000021+P_000211211*QR_020002000022); ans_temp[ans_id*36+24]+=Pmtrx[27]*(P_000011011*QR_021000001000+P_000011111*QR_021000001001+P_000011211*QR_021000001002+P_000111011*QR_021000001010+P_000111111*QR_021000001011+P_000111211*QR_021000001012+P_000211011*QR_021000001020+P_000211111*QR_021000001021+P_000211211*QR_021000001022); ans_temp[ans_id*36+24]+=Pmtrx[28]*(P_000011011*QR_020001001000+P_000011111*QR_020001001001+P_000011211*QR_020001001002+P_000111011*QR_020001001010+P_000111111*QR_020001001011+P_000111211*QR_020001001012+P_000211011*QR_020001001020+P_000211111*QR_020001001021+P_000211211*QR_020001001022); ans_temp[ans_id*36+24]+=Pmtrx[29]*(P_000011011*QR_020000002000+P_000011111*QR_020000002001+P_000011211*QR_020000002002+P_000111011*QR_020000002010+P_000111111*QR_020000002011+P_000111211*QR_020000002012+P_000211011*QR_020000002020+P_000211111*QR_020000002021+P_000211211*QR_020000002022); ans_temp[ans_id*36+25]+=Pmtrx[24]*(P_000011011*QR_012010000000+P_000011111*QR_012010000001+P_000011211*QR_012010000002+P_000111011*QR_012010000010+P_000111111*QR_012010000011+P_000111211*QR_012010000012+P_000211011*QR_012010000020+P_000211111*QR_012010000021+P_000211211*QR_012010000022); ans_temp[ans_id*36+25]+=Pmtrx[25]*(P_000011011*QR_011011000000+P_000011111*QR_011011000001+P_000011211*QR_011011000002+P_000111011*QR_011011000010+P_000111111*QR_011011000011+P_000111211*QR_011011000012+P_000211011*QR_011011000020+P_000211111*QR_011011000021+P_000211211*QR_011011000022); ans_temp[ans_id*36+25]+=Pmtrx[26]*(P_000011011*QR_010012000000+P_000011111*QR_010012000001+P_000011211*QR_010012000002+P_000111011*QR_010012000010+P_000111111*QR_010012000011+P_000111211*QR_010012000012+P_000211011*QR_010012000020+P_000211111*QR_010012000021+P_000211211*QR_010012000022); ans_temp[ans_id*36+25]+=Pmtrx[27]*(P_000011011*QR_011010001000+P_000011111*QR_011010001001+P_000011211*QR_011010001002+P_000111011*QR_011010001010+P_000111111*QR_011010001011+P_000111211*QR_011010001012+P_000211011*QR_011010001020+P_000211111*QR_011010001021+P_000211211*QR_011010001022); ans_temp[ans_id*36+25]+=Pmtrx[28]*(P_000011011*QR_010011001000+P_000011111*QR_010011001001+P_000011211*QR_010011001002+P_000111011*QR_010011001010+P_000111111*QR_010011001011+P_000111211*QR_010011001012+P_000211011*QR_010011001020+P_000211111*QR_010011001021+P_000211211*QR_010011001022); ans_temp[ans_id*36+25]+=Pmtrx[29]*(P_000011011*QR_010010002000+P_000011111*QR_010010002001+P_000011211*QR_010010002002+P_000111011*QR_010010002010+P_000111111*QR_010010002011+P_000111211*QR_010010002012+P_000211011*QR_010010002020+P_000211111*QR_010010002021+P_000211211*QR_010010002022); ans_temp[ans_id*36+26]+=Pmtrx[24]*(P_000011011*QR_002020000000+P_000011111*QR_002020000001+P_000011211*QR_002020000002+P_000111011*QR_002020000010+P_000111111*QR_002020000011+P_000111211*QR_002020000012+P_000211011*QR_002020000020+P_000211111*QR_002020000021+P_000211211*QR_002020000022); ans_temp[ans_id*36+26]+=Pmtrx[25]*(P_000011011*QR_001021000000+P_000011111*QR_001021000001+P_000011211*QR_001021000002+P_000111011*QR_001021000010+P_000111111*QR_001021000011+P_000111211*QR_001021000012+P_000211011*QR_001021000020+P_000211111*QR_001021000021+P_000211211*QR_001021000022); ans_temp[ans_id*36+26]+=Pmtrx[26]*(P_000011011*QR_000022000000+P_000011111*QR_000022000001+P_000011211*QR_000022000002+P_000111011*QR_000022000010+P_000111111*QR_000022000011+P_000111211*QR_000022000012+P_000211011*QR_000022000020+P_000211111*QR_000022000021+P_000211211*QR_000022000022); ans_temp[ans_id*36+26]+=Pmtrx[27]*(P_000011011*QR_001020001000+P_000011111*QR_001020001001+P_000011211*QR_001020001002+P_000111011*QR_001020001010+P_000111111*QR_001020001011+P_000111211*QR_001020001012+P_000211011*QR_001020001020+P_000211111*QR_001020001021+P_000211211*QR_001020001022); ans_temp[ans_id*36+26]+=Pmtrx[28]*(P_000011011*QR_000021001000+P_000011111*QR_000021001001+P_000011211*QR_000021001002+P_000111011*QR_000021001010+P_000111111*QR_000021001011+P_000111211*QR_000021001012+P_000211011*QR_000021001020+P_000211111*QR_000021001021+P_000211211*QR_000021001022); ans_temp[ans_id*36+26]+=Pmtrx[29]*(P_000011011*QR_000020002000+P_000011111*QR_000020002001+P_000011211*QR_000020002002+P_000111011*QR_000020002010+P_000111111*QR_000020002011+P_000111211*QR_000020002012+P_000211011*QR_000020002020+P_000211111*QR_000020002021+P_000211211*QR_000020002022); ans_temp[ans_id*36+27]+=Pmtrx[24]*(P_000011011*QR_012000010000+P_000011111*QR_012000010001+P_000011211*QR_012000010002+P_000111011*QR_012000010010+P_000111111*QR_012000010011+P_000111211*QR_012000010012+P_000211011*QR_012000010020+P_000211111*QR_012000010021+P_000211211*QR_012000010022); ans_temp[ans_id*36+27]+=Pmtrx[25]*(P_000011011*QR_011001010000+P_000011111*QR_011001010001+P_000011211*QR_011001010002+P_000111011*QR_011001010010+P_000111111*QR_011001010011+P_000111211*QR_011001010012+P_000211011*QR_011001010020+P_000211111*QR_011001010021+P_000211211*QR_011001010022); ans_temp[ans_id*36+27]+=Pmtrx[26]*(P_000011011*QR_010002010000+P_000011111*QR_010002010001+P_000011211*QR_010002010002+P_000111011*QR_010002010010+P_000111111*QR_010002010011+P_000111211*QR_010002010012+P_000211011*QR_010002010020+P_000211111*QR_010002010021+P_000211211*QR_010002010022); ans_temp[ans_id*36+27]+=Pmtrx[27]*(P_000011011*QR_011000011000+P_000011111*QR_011000011001+P_000011211*QR_011000011002+P_000111011*QR_011000011010+P_000111111*QR_011000011011+P_000111211*QR_011000011012+P_000211011*QR_011000011020+P_000211111*QR_011000011021+P_000211211*QR_011000011022); ans_temp[ans_id*36+27]+=Pmtrx[28]*(P_000011011*QR_010001011000+P_000011111*QR_010001011001+P_000011211*QR_010001011002+P_000111011*QR_010001011010+P_000111111*QR_010001011011+P_000111211*QR_010001011012+P_000211011*QR_010001011020+P_000211111*QR_010001011021+P_000211211*QR_010001011022); ans_temp[ans_id*36+27]+=Pmtrx[29]*(P_000011011*QR_010000012000+P_000011111*QR_010000012001+P_000011211*QR_010000012002+P_000111011*QR_010000012010+P_000111111*QR_010000012011+P_000111211*QR_010000012012+P_000211011*QR_010000012020+P_000211111*QR_010000012021+P_000211211*QR_010000012022); ans_temp[ans_id*36+28]+=Pmtrx[24]*(P_000011011*QR_002010010000+P_000011111*QR_002010010001+P_000011211*QR_002010010002+P_000111011*QR_002010010010+P_000111111*QR_002010010011+P_000111211*QR_002010010012+P_000211011*QR_002010010020+P_000211111*QR_002010010021+P_000211211*QR_002010010022); ans_temp[ans_id*36+28]+=Pmtrx[25]*(P_000011011*QR_001011010000+P_000011111*QR_001011010001+P_000011211*QR_001011010002+P_000111011*QR_001011010010+P_000111111*QR_001011010011+P_000111211*QR_001011010012+P_000211011*QR_001011010020+P_000211111*QR_001011010021+P_000211211*QR_001011010022); ans_temp[ans_id*36+28]+=Pmtrx[26]*(P_000011011*QR_000012010000+P_000011111*QR_000012010001+P_000011211*QR_000012010002+P_000111011*QR_000012010010+P_000111111*QR_000012010011+P_000111211*QR_000012010012+P_000211011*QR_000012010020+P_000211111*QR_000012010021+P_000211211*QR_000012010022); ans_temp[ans_id*36+28]+=Pmtrx[27]*(P_000011011*QR_001010011000+P_000011111*QR_001010011001+P_000011211*QR_001010011002+P_000111011*QR_001010011010+P_000111111*QR_001010011011+P_000111211*QR_001010011012+P_000211011*QR_001010011020+P_000211111*QR_001010011021+P_000211211*QR_001010011022); ans_temp[ans_id*36+28]+=Pmtrx[28]*(P_000011011*QR_000011011000+P_000011111*QR_000011011001+P_000011211*QR_000011011002+P_000111011*QR_000011011010+P_000111111*QR_000011011011+P_000111211*QR_000011011012+P_000211011*QR_000011011020+P_000211111*QR_000011011021+P_000211211*QR_000011011022); ans_temp[ans_id*36+28]+=Pmtrx[29]*(P_000011011*QR_000010012000+P_000011111*QR_000010012001+P_000011211*QR_000010012002+P_000111011*QR_000010012010+P_000111111*QR_000010012011+P_000111211*QR_000010012012+P_000211011*QR_000010012020+P_000211111*QR_000010012021+P_000211211*QR_000010012022); ans_temp[ans_id*36+29]+=Pmtrx[24]*(P_000011011*QR_002000020000+P_000011111*QR_002000020001+P_000011211*QR_002000020002+P_000111011*QR_002000020010+P_000111111*QR_002000020011+P_000111211*QR_002000020012+P_000211011*QR_002000020020+P_000211111*QR_002000020021+P_000211211*QR_002000020022); ans_temp[ans_id*36+29]+=Pmtrx[25]*(P_000011011*QR_001001020000+P_000011111*QR_001001020001+P_000011211*QR_001001020002+P_000111011*QR_001001020010+P_000111111*QR_001001020011+P_000111211*QR_001001020012+P_000211011*QR_001001020020+P_000211111*QR_001001020021+P_000211211*QR_001001020022); ans_temp[ans_id*36+29]+=Pmtrx[26]*(P_000011011*QR_000002020000+P_000011111*QR_000002020001+P_000011211*QR_000002020002+P_000111011*QR_000002020010+P_000111111*QR_000002020011+P_000111211*QR_000002020012+P_000211011*QR_000002020020+P_000211111*QR_000002020021+P_000211211*QR_000002020022); ans_temp[ans_id*36+29]+=Pmtrx[27]*(P_000011011*QR_001000021000+P_000011111*QR_001000021001+P_000011211*QR_001000021002+P_000111011*QR_001000021010+P_000111111*QR_001000021011+P_000111211*QR_001000021012+P_000211011*QR_001000021020+P_000211111*QR_001000021021+P_000211211*QR_001000021022); ans_temp[ans_id*36+29]+=Pmtrx[28]*(P_000011011*QR_000001021000+P_000011111*QR_000001021001+P_000011211*QR_000001021002+P_000111011*QR_000001021010+P_000111111*QR_000001021011+P_000111211*QR_000001021012+P_000211011*QR_000001021020+P_000211111*QR_000001021021+P_000211211*QR_000001021022); ans_temp[ans_id*36+29]+=Pmtrx[29]*(P_000011011*QR_000000022000+P_000011111*QR_000000022001+P_000011211*QR_000000022002+P_000111011*QR_000000022010+P_000111111*QR_000000022011+P_000111211*QR_000000022012+P_000211011*QR_000000022020+P_000211111*QR_000000022021+P_000211211*QR_000000022022); ans_temp[ans_id*36+24]+=Pmtrx[30]*(P_000010012*QR_022000000000+P_000010112*QR_022000000001+P_000010212*QR_022000000002+P_000010312*QR_022000000003+P_000110012*QR_022000000010+P_000110112*QR_022000000011+P_000110212*QR_022000000012+P_000110312*QR_022000000013); ans_temp[ans_id*36+24]+=Pmtrx[31]*(P_000010012*QR_021001000000+P_000010112*QR_021001000001+P_000010212*QR_021001000002+P_000010312*QR_021001000003+P_000110012*QR_021001000010+P_000110112*QR_021001000011+P_000110212*QR_021001000012+P_000110312*QR_021001000013); ans_temp[ans_id*36+24]+=Pmtrx[32]*(P_000010012*QR_020002000000+P_000010112*QR_020002000001+P_000010212*QR_020002000002+P_000010312*QR_020002000003+P_000110012*QR_020002000010+P_000110112*QR_020002000011+P_000110212*QR_020002000012+P_000110312*QR_020002000013); ans_temp[ans_id*36+24]+=Pmtrx[33]*(P_000010012*QR_021000001000+P_000010112*QR_021000001001+P_000010212*QR_021000001002+P_000010312*QR_021000001003+P_000110012*QR_021000001010+P_000110112*QR_021000001011+P_000110212*QR_021000001012+P_000110312*QR_021000001013); ans_temp[ans_id*36+24]+=Pmtrx[34]*(P_000010012*QR_020001001000+P_000010112*QR_020001001001+P_000010212*QR_020001001002+P_000010312*QR_020001001003+P_000110012*QR_020001001010+P_000110112*QR_020001001011+P_000110212*QR_020001001012+P_000110312*QR_020001001013); ans_temp[ans_id*36+24]+=Pmtrx[35]*(P_000010012*QR_020000002000+P_000010112*QR_020000002001+P_000010212*QR_020000002002+P_000010312*QR_020000002003+P_000110012*QR_020000002010+P_000110112*QR_020000002011+P_000110212*QR_020000002012+P_000110312*QR_020000002013); ans_temp[ans_id*36+25]+=Pmtrx[30]*(P_000010012*QR_012010000000+P_000010112*QR_012010000001+P_000010212*QR_012010000002+P_000010312*QR_012010000003+P_000110012*QR_012010000010+P_000110112*QR_012010000011+P_000110212*QR_012010000012+P_000110312*QR_012010000013); ans_temp[ans_id*36+25]+=Pmtrx[31]*(P_000010012*QR_011011000000+P_000010112*QR_011011000001+P_000010212*QR_011011000002+P_000010312*QR_011011000003+P_000110012*QR_011011000010+P_000110112*QR_011011000011+P_000110212*QR_011011000012+P_000110312*QR_011011000013); ans_temp[ans_id*36+25]+=Pmtrx[32]*(P_000010012*QR_010012000000+P_000010112*QR_010012000001+P_000010212*QR_010012000002+P_000010312*QR_010012000003+P_000110012*QR_010012000010+P_000110112*QR_010012000011+P_000110212*QR_010012000012+P_000110312*QR_010012000013); ans_temp[ans_id*36+25]+=Pmtrx[33]*(P_000010012*QR_011010001000+P_000010112*QR_011010001001+P_000010212*QR_011010001002+P_000010312*QR_011010001003+P_000110012*QR_011010001010+P_000110112*QR_011010001011+P_000110212*QR_011010001012+P_000110312*QR_011010001013); ans_temp[ans_id*36+25]+=Pmtrx[34]*(P_000010012*QR_010011001000+P_000010112*QR_010011001001+P_000010212*QR_010011001002+P_000010312*QR_010011001003+P_000110012*QR_010011001010+P_000110112*QR_010011001011+P_000110212*QR_010011001012+P_000110312*QR_010011001013); ans_temp[ans_id*36+25]+=Pmtrx[35]*(P_000010012*QR_010010002000+P_000010112*QR_010010002001+P_000010212*QR_010010002002+P_000010312*QR_010010002003+P_000110012*QR_010010002010+P_000110112*QR_010010002011+P_000110212*QR_010010002012+P_000110312*QR_010010002013); ans_temp[ans_id*36+26]+=Pmtrx[30]*(P_000010012*QR_002020000000+P_000010112*QR_002020000001+P_000010212*QR_002020000002+P_000010312*QR_002020000003+P_000110012*QR_002020000010+P_000110112*QR_002020000011+P_000110212*QR_002020000012+P_000110312*QR_002020000013); ans_temp[ans_id*36+26]+=Pmtrx[31]*(P_000010012*QR_001021000000+P_000010112*QR_001021000001+P_000010212*QR_001021000002+P_000010312*QR_001021000003+P_000110012*QR_001021000010+P_000110112*QR_001021000011+P_000110212*QR_001021000012+P_000110312*QR_001021000013); ans_temp[ans_id*36+26]+=Pmtrx[32]*(P_000010012*QR_000022000000+P_000010112*QR_000022000001+P_000010212*QR_000022000002+P_000010312*QR_000022000003+P_000110012*QR_000022000010+P_000110112*QR_000022000011+P_000110212*QR_000022000012+P_000110312*QR_000022000013); ans_temp[ans_id*36+26]+=Pmtrx[33]*(P_000010012*QR_001020001000+P_000010112*QR_001020001001+P_000010212*QR_001020001002+P_000010312*QR_001020001003+P_000110012*QR_001020001010+P_000110112*QR_001020001011+P_000110212*QR_001020001012+P_000110312*QR_001020001013); ans_temp[ans_id*36+26]+=Pmtrx[34]*(P_000010012*QR_000021001000+P_000010112*QR_000021001001+P_000010212*QR_000021001002+P_000010312*QR_000021001003+P_000110012*QR_000021001010+P_000110112*QR_000021001011+P_000110212*QR_000021001012+P_000110312*QR_000021001013); ans_temp[ans_id*36+26]+=Pmtrx[35]*(P_000010012*QR_000020002000+P_000010112*QR_000020002001+P_000010212*QR_000020002002+P_000010312*QR_000020002003+P_000110012*QR_000020002010+P_000110112*QR_000020002011+P_000110212*QR_000020002012+P_000110312*QR_000020002013); ans_temp[ans_id*36+27]+=Pmtrx[30]*(P_000010012*QR_012000010000+P_000010112*QR_012000010001+P_000010212*QR_012000010002+P_000010312*QR_012000010003+P_000110012*QR_012000010010+P_000110112*QR_012000010011+P_000110212*QR_012000010012+P_000110312*QR_012000010013); ans_temp[ans_id*36+27]+=Pmtrx[31]*(P_000010012*QR_011001010000+P_000010112*QR_011001010001+P_000010212*QR_011001010002+P_000010312*QR_011001010003+P_000110012*QR_011001010010+P_000110112*QR_011001010011+P_000110212*QR_011001010012+P_000110312*QR_011001010013); ans_temp[ans_id*36+27]+=Pmtrx[32]*(P_000010012*QR_010002010000+P_000010112*QR_010002010001+P_000010212*QR_010002010002+P_000010312*QR_010002010003+P_000110012*QR_010002010010+P_000110112*QR_010002010011+P_000110212*QR_010002010012+P_000110312*QR_010002010013); ans_temp[ans_id*36+27]+=Pmtrx[33]*(P_000010012*QR_011000011000+P_000010112*QR_011000011001+P_000010212*QR_011000011002+P_000010312*QR_011000011003+P_000110012*QR_011000011010+P_000110112*QR_011000011011+P_000110212*QR_011000011012+P_000110312*QR_011000011013); ans_temp[ans_id*36+27]+=Pmtrx[34]*(P_000010012*QR_010001011000+P_000010112*QR_010001011001+P_000010212*QR_010001011002+P_000010312*QR_010001011003+P_000110012*QR_010001011010+P_000110112*QR_010001011011+P_000110212*QR_010001011012+P_000110312*QR_010001011013); ans_temp[ans_id*36+27]+=Pmtrx[35]*(P_000010012*QR_010000012000+P_000010112*QR_010000012001+P_000010212*QR_010000012002+P_000010312*QR_010000012003+P_000110012*QR_010000012010+P_000110112*QR_010000012011+P_000110212*QR_010000012012+P_000110312*QR_010000012013); ans_temp[ans_id*36+28]+=Pmtrx[30]*(P_000010012*QR_002010010000+P_000010112*QR_002010010001+P_000010212*QR_002010010002+P_000010312*QR_002010010003+P_000110012*QR_002010010010+P_000110112*QR_002010010011+P_000110212*QR_002010010012+P_000110312*QR_002010010013); ans_temp[ans_id*36+28]+=Pmtrx[31]*(P_000010012*QR_001011010000+P_000010112*QR_001011010001+P_000010212*QR_001011010002+P_000010312*QR_001011010003+P_000110012*QR_001011010010+P_000110112*QR_001011010011+P_000110212*QR_001011010012+P_000110312*QR_001011010013); ans_temp[ans_id*36+28]+=Pmtrx[32]*(P_000010012*QR_000012010000+P_000010112*QR_000012010001+P_000010212*QR_000012010002+P_000010312*QR_000012010003+P_000110012*QR_000012010010+P_000110112*QR_000012010011+P_000110212*QR_000012010012+P_000110312*QR_000012010013); ans_temp[ans_id*36+28]+=Pmtrx[33]*(P_000010012*QR_001010011000+P_000010112*QR_001010011001+P_000010212*QR_001010011002+P_000010312*QR_001010011003+P_000110012*QR_001010011010+P_000110112*QR_001010011011+P_000110212*QR_001010011012+P_000110312*QR_001010011013); ans_temp[ans_id*36+28]+=Pmtrx[34]*(P_000010012*QR_000011011000+P_000010112*QR_000011011001+P_000010212*QR_000011011002+P_000010312*QR_000011011003+P_000110012*QR_000011011010+P_000110112*QR_000011011011+P_000110212*QR_000011011012+P_000110312*QR_000011011013); ans_temp[ans_id*36+28]+=Pmtrx[35]*(P_000010012*QR_000010012000+P_000010112*QR_000010012001+P_000010212*QR_000010012002+P_000010312*QR_000010012003+P_000110012*QR_000010012010+P_000110112*QR_000010012011+P_000110212*QR_000010012012+P_000110312*QR_000010012013); ans_temp[ans_id*36+29]+=Pmtrx[30]*(P_000010012*QR_002000020000+P_000010112*QR_002000020001+P_000010212*QR_002000020002+P_000010312*QR_002000020003+P_000110012*QR_002000020010+P_000110112*QR_002000020011+P_000110212*QR_002000020012+P_000110312*QR_002000020013); ans_temp[ans_id*36+29]+=Pmtrx[31]*(P_000010012*QR_001001020000+P_000010112*QR_001001020001+P_000010212*QR_001001020002+P_000010312*QR_001001020003+P_000110012*QR_001001020010+P_000110112*QR_001001020011+P_000110212*QR_001001020012+P_000110312*QR_001001020013); ans_temp[ans_id*36+29]+=Pmtrx[32]*(P_000010012*QR_000002020000+P_000010112*QR_000002020001+P_000010212*QR_000002020002+P_000010312*QR_000002020003+P_000110012*QR_000002020010+P_000110112*QR_000002020011+P_000110212*QR_000002020012+P_000110312*QR_000002020013); ans_temp[ans_id*36+29]+=Pmtrx[33]*(P_000010012*QR_001000021000+P_000010112*QR_001000021001+P_000010212*QR_001000021002+P_000010312*QR_001000021003+P_000110012*QR_001000021010+P_000110112*QR_001000021011+P_000110212*QR_001000021012+P_000110312*QR_001000021013); ans_temp[ans_id*36+29]+=Pmtrx[34]*(P_000010012*QR_000001021000+P_000010112*QR_000001021001+P_000010212*QR_000001021002+P_000010312*QR_000001021003+P_000110012*QR_000001021010+P_000110112*QR_000001021011+P_000110212*QR_000001021012+P_000110312*QR_000001021013); ans_temp[ans_id*36+29]+=Pmtrx[35]*(P_000010012*QR_000000022000+P_000010112*QR_000000022001+P_000010212*QR_000000022002+P_000010312*QR_000000022003+P_000110012*QR_000000022010+P_000110112*QR_000000022011+P_000110212*QR_000000022012+P_000110312*QR_000000022013); ans_temp[ans_id*36+30]+=Pmtrx[0]*(P_002000020*QR_022000000000+P_002000120*QR_022000000001+P_002000220*QR_022000000002+P_102000020*QR_022000000100+P_102000120*QR_022000000101+P_102000220*QR_022000000102+P_202000020*QR_022000000200+P_202000120*QR_022000000201+P_202000220*QR_022000000202); ans_temp[ans_id*36+30]+=Pmtrx[1]*(P_002000020*QR_021001000000+P_002000120*QR_021001000001+P_002000220*QR_021001000002+P_102000020*QR_021001000100+P_102000120*QR_021001000101+P_102000220*QR_021001000102+P_202000020*QR_021001000200+P_202000120*QR_021001000201+P_202000220*QR_021001000202); ans_temp[ans_id*36+30]+=Pmtrx[2]*(P_002000020*QR_020002000000+P_002000120*QR_020002000001+P_002000220*QR_020002000002+P_102000020*QR_020002000100+P_102000120*QR_020002000101+P_102000220*QR_020002000102+P_202000020*QR_020002000200+P_202000120*QR_020002000201+P_202000220*QR_020002000202); ans_temp[ans_id*36+30]+=Pmtrx[3]*(P_002000020*QR_021000001000+P_002000120*QR_021000001001+P_002000220*QR_021000001002+P_102000020*QR_021000001100+P_102000120*QR_021000001101+P_102000220*QR_021000001102+P_202000020*QR_021000001200+P_202000120*QR_021000001201+P_202000220*QR_021000001202); ans_temp[ans_id*36+30]+=Pmtrx[4]*(P_002000020*QR_020001001000+P_002000120*QR_020001001001+P_002000220*QR_020001001002+P_102000020*QR_020001001100+P_102000120*QR_020001001101+P_102000220*QR_020001001102+P_202000020*QR_020001001200+P_202000120*QR_020001001201+P_202000220*QR_020001001202); ans_temp[ans_id*36+30]+=Pmtrx[5]*(P_002000020*QR_020000002000+P_002000120*QR_020000002001+P_002000220*QR_020000002002+P_102000020*QR_020000002100+P_102000120*QR_020000002101+P_102000220*QR_020000002102+P_202000020*QR_020000002200+P_202000120*QR_020000002201+P_202000220*QR_020000002202); ans_temp[ans_id*36+31]+=Pmtrx[0]*(P_002000020*QR_012010000000+P_002000120*QR_012010000001+P_002000220*QR_012010000002+P_102000020*QR_012010000100+P_102000120*QR_012010000101+P_102000220*QR_012010000102+P_202000020*QR_012010000200+P_202000120*QR_012010000201+P_202000220*QR_012010000202); ans_temp[ans_id*36+31]+=Pmtrx[1]*(P_002000020*QR_011011000000+P_002000120*QR_011011000001+P_002000220*QR_011011000002+P_102000020*QR_011011000100+P_102000120*QR_011011000101+P_102000220*QR_011011000102+P_202000020*QR_011011000200+P_202000120*QR_011011000201+P_202000220*QR_011011000202); ans_temp[ans_id*36+31]+=Pmtrx[2]*(P_002000020*QR_010012000000+P_002000120*QR_010012000001+P_002000220*QR_010012000002+P_102000020*QR_010012000100+P_102000120*QR_010012000101+P_102000220*QR_010012000102+P_202000020*QR_010012000200+P_202000120*QR_010012000201+P_202000220*QR_010012000202); ans_temp[ans_id*36+31]+=Pmtrx[3]*(P_002000020*QR_011010001000+P_002000120*QR_011010001001+P_002000220*QR_011010001002+P_102000020*QR_011010001100+P_102000120*QR_011010001101+P_102000220*QR_011010001102+P_202000020*QR_011010001200+P_202000120*QR_011010001201+P_202000220*QR_011010001202); ans_temp[ans_id*36+31]+=Pmtrx[4]*(P_002000020*QR_010011001000+P_002000120*QR_010011001001+P_002000220*QR_010011001002+P_102000020*QR_010011001100+P_102000120*QR_010011001101+P_102000220*QR_010011001102+P_202000020*QR_010011001200+P_202000120*QR_010011001201+P_202000220*QR_010011001202); ans_temp[ans_id*36+31]+=Pmtrx[5]*(P_002000020*QR_010010002000+P_002000120*QR_010010002001+P_002000220*QR_010010002002+P_102000020*QR_010010002100+P_102000120*QR_010010002101+P_102000220*QR_010010002102+P_202000020*QR_010010002200+P_202000120*QR_010010002201+P_202000220*QR_010010002202); ans_temp[ans_id*36+32]+=Pmtrx[0]*(P_002000020*QR_002020000000+P_002000120*QR_002020000001+P_002000220*QR_002020000002+P_102000020*QR_002020000100+P_102000120*QR_002020000101+P_102000220*QR_002020000102+P_202000020*QR_002020000200+P_202000120*QR_002020000201+P_202000220*QR_002020000202); ans_temp[ans_id*36+32]+=Pmtrx[1]*(P_002000020*QR_001021000000+P_002000120*QR_001021000001+P_002000220*QR_001021000002+P_102000020*QR_001021000100+P_102000120*QR_001021000101+P_102000220*QR_001021000102+P_202000020*QR_001021000200+P_202000120*QR_001021000201+P_202000220*QR_001021000202); ans_temp[ans_id*36+32]+=Pmtrx[2]*(P_002000020*QR_000022000000+P_002000120*QR_000022000001+P_002000220*QR_000022000002+P_102000020*QR_000022000100+P_102000120*QR_000022000101+P_102000220*QR_000022000102+P_202000020*QR_000022000200+P_202000120*QR_000022000201+P_202000220*QR_000022000202); ans_temp[ans_id*36+32]+=Pmtrx[3]*(P_002000020*QR_001020001000+P_002000120*QR_001020001001+P_002000220*QR_001020001002+P_102000020*QR_001020001100+P_102000120*QR_001020001101+P_102000220*QR_001020001102+P_202000020*QR_001020001200+P_202000120*QR_001020001201+P_202000220*QR_001020001202); ans_temp[ans_id*36+32]+=Pmtrx[4]*(P_002000020*QR_000021001000+P_002000120*QR_000021001001+P_002000220*QR_000021001002+P_102000020*QR_000021001100+P_102000120*QR_000021001101+P_102000220*QR_000021001102+P_202000020*QR_000021001200+P_202000120*QR_000021001201+P_202000220*QR_000021001202); ans_temp[ans_id*36+32]+=Pmtrx[5]*(P_002000020*QR_000020002000+P_002000120*QR_000020002001+P_002000220*QR_000020002002+P_102000020*QR_000020002100+P_102000120*QR_000020002101+P_102000220*QR_000020002102+P_202000020*QR_000020002200+P_202000120*QR_000020002201+P_202000220*QR_000020002202); ans_temp[ans_id*36+33]+=Pmtrx[0]*(P_002000020*QR_012000010000+P_002000120*QR_012000010001+P_002000220*QR_012000010002+P_102000020*QR_012000010100+P_102000120*QR_012000010101+P_102000220*QR_012000010102+P_202000020*QR_012000010200+P_202000120*QR_012000010201+P_202000220*QR_012000010202); ans_temp[ans_id*36+33]+=Pmtrx[1]*(P_002000020*QR_011001010000+P_002000120*QR_011001010001+P_002000220*QR_011001010002+P_102000020*QR_011001010100+P_102000120*QR_011001010101+P_102000220*QR_011001010102+P_202000020*QR_011001010200+P_202000120*QR_011001010201+P_202000220*QR_011001010202); ans_temp[ans_id*36+33]+=Pmtrx[2]*(P_002000020*QR_010002010000+P_002000120*QR_010002010001+P_002000220*QR_010002010002+P_102000020*QR_010002010100+P_102000120*QR_010002010101+P_102000220*QR_010002010102+P_202000020*QR_010002010200+P_202000120*QR_010002010201+P_202000220*QR_010002010202); ans_temp[ans_id*36+33]+=Pmtrx[3]*(P_002000020*QR_011000011000+P_002000120*QR_011000011001+P_002000220*QR_011000011002+P_102000020*QR_011000011100+P_102000120*QR_011000011101+P_102000220*QR_011000011102+P_202000020*QR_011000011200+P_202000120*QR_011000011201+P_202000220*QR_011000011202); ans_temp[ans_id*36+33]+=Pmtrx[4]*(P_002000020*QR_010001011000+P_002000120*QR_010001011001+P_002000220*QR_010001011002+P_102000020*QR_010001011100+P_102000120*QR_010001011101+P_102000220*QR_010001011102+P_202000020*QR_010001011200+P_202000120*QR_010001011201+P_202000220*QR_010001011202); ans_temp[ans_id*36+33]+=Pmtrx[5]*(P_002000020*QR_010000012000+P_002000120*QR_010000012001+P_002000220*QR_010000012002+P_102000020*QR_010000012100+P_102000120*QR_010000012101+P_102000220*QR_010000012102+P_202000020*QR_010000012200+P_202000120*QR_010000012201+P_202000220*QR_010000012202); ans_temp[ans_id*36+34]+=Pmtrx[0]*(P_002000020*QR_002010010000+P_002000120*QR_002010010001+P_002000220*QR_002010010002+P_102000020*QR_002010010100+P_102000120*QR_002010010101+P_102000220*QR_002010010102+P_202000020*QR_002010010200+P_202000120*QR_002010010201+P_202000220*QR_002010010202); ans_temp[ans_id*36+34]+=Pmtrx[1]*(P_002000020*QR_001011010000+P_002000120*QR_001011010001+P_002000220*QR_001011010002+P_102000020*QR_001011010100+P_102000120*QR_001011010101+P_102000220*QR_001011010102+P_202000020*QR_001011010200+P_202000120*QR_001011010201+P_202000220*QR_001011010202); ans_temp[ans_id*36+34]+=Pmtrx[2]*(P_002000020*QR_000012010000+P_002000120*QR_000012010001+P_002000220*QR_000012010002+P_102000020*QR_000012010100+P_102000120*QR_000012010101+P_102000220*QR_000012010102+P_202000020*QR_000012010200+P_202000120*QR_000012010201+P_202000220*QR_000012010202); ans_temp[ans_id*36+34]+=Pmtrx[3]*(P_002000020*QR_001010011000+P_002000120*QR_001010011001+P_002000220*QR_001010011002+P_102000020*QR_001010011100+P_102000120*QR_001010011101+P_102000220*QR_001010011102+P_202000020*QR_001010011200+P_202000120*QR_001010011201+P_202000220*QR_001010011202); ans_temp[ans_id*36+34]+=Pmtrx[4]*(P_002000020*QR_000011011000+P_002000120*QR_000011011001+P_002000220*QR_000011011002+P_102000020*QR_000011011100+P_102000120*QR_000011011101+P_102000220*QR_000011011102+P_202000020*QR_000011011200+P_202000120*QR_000011011201+P_202000220*QR_000011011202); ans_temp[ans_id*36+34]+=Pmtrx[5]*(P_002000020*QR_000010012000+P_002000120*QR_000010012001+P_002000220*QR_000010012002+P_102000020*QR_000010012100+P_102000120*QR_000010012101+P_102000220*QR_000010012102+P_202000020*QR_000010012200+P_202000120*QR_000010012201+P_202000220*QR_000010012202); ans_temp[ans_id*36+35]+=Pmtrx[0]*(P_002000020*QR_002000020000+P_002000120*QR_002000020001+P_002000220*QR_002000020002+P_102000020*QR_002000020100+P_102000120*QR_002000020101+P_102000220*QR_002000020102+P_202000020*QR_002000020200+P_202000120*QR_002000020201+P_202000220*QR_002000020202); ans_temp[ans_id*36+35]+=Pmtrx[1]*(P_002000020*QR_001001020000+P_002000120*QR_001001020001+P_002000220*QR_001001020002+P_102000020*QR_001001020100+P_102000120*QR_001001020101+P_102000220*QR_001001020102+P_202000020*QR_001001020200+P_202000120*QR_001001020201+P_202000220*QR_001001020202); ans_temp[ans_id*36+35]+=Pmtrx[2]*(P_002000020*QR_000002020000+P_002000120*QR_000002020001+P_002000220*QR_000002020002+P_102000020*QR_000002020100+P_102000120*QR_000002020101+P_102000220*QR_000002020102+P_202000020*QR_000002020200+P_202000120*QR_000002020201+P_202000220*QR_000002020202); ans_temp[ans_id*36+35]+=Pmtrx[3]*(P_002000020*QR_001000021000+P_002000120*QR_001000021001+P_002000220*QR_001000021002+P_102000020*QR_001000021100+P_102000120*QR_001000021101+P_102000220*QR_001000021102+P_202000020*QR_001000021200+P_202000120*QR_001000021201+P_202000220*QR_001000021202); ans_temp[ans_id*36+35]+=Pmtrx[4]*(P_002000020*QR_000001021000+P_002000120*QR_000001021001+P_002000220*QR_000001021002+P_102000020*QR_000001021100+P_102000120*QR_000001021101+P_102000220*QR_000001021102+P_202000020*QR_000001021200+P_202000120*QR_000001021201+P_202000220*QR_000001021202); ans_temp[ans_id*36+35]+=Pmtrx[5]*(P_002000020*QR_000000022000+P_002000120*QR_000000022001+P_002000220*QR_000000022002+P_102000020*QR_000000022100+P_102000120*QR_000000022101+P_102000220*QR_000000022102+P_202000020*QR_000000022200+P_202000120*QR_000000022201+P_202000220*QR_000000022202); ans_temp[ans_id*36+30]+=Pmtrx[6]*(P_001001020*QR_022000000000+P_001001120*QR_022000000001+P_001001220*QR_022000000002+P_001101020*QR_022000000010+P_001101120*QR_022000000011+P_001101220*QR_022000000012+P_101001020*QR_022000000100+P_101001120*QR_022000000101+P_101001220*QR_022000000102+P_101101020*QR_022000000110+P_101101120*QR_022000000111+P_101101220*QR_022000000112); ans_temp[ans_id*36+30]+=Pmtrx[7]*(P_001001020*QR_021001000000+P_001001120*QR_021001000001+P_001001220*QR_021001000002+P_001101020*QR_021001000010+P_001101120*QR_021001000011+P_001101220*QR_021001000012+P_101001020*QR_021001000100+P_101001120*QR_021001000101+P_101001220*QR_021001000102+P_101101020*QR_021001000110+P_101101120*QR_021001000111+P_101101220*QR_021001000112); ans_temp[ans_id*36+30]+=Pmtrx[8]*(P_001001020*QR_020002000000+P_001001120*QR_020002000001+P_001001220*QR_020002000002+P_001101020*QR_020002000010+P_001101120*QR_020002000011+P_001101220*QR_020002000012+P_101001020*QR_020002000100+P_101001120*QR_020002000101+P_101001220*QR_020002000102+P_101101020*QR_020002000110+P_101101120*QR_020002000111+P_101101220*QR_020002000112); ans_temp[ans_id*36+30]+=Pmtrx[9]*(P_001001020*QR_021000001000+P_001001120*QR_021000001001+P_001001220*QR_021000001002+P_001101020*QR_021000001010+P_001101120*QR_021000001011+P_001101220*QR_021000001012+P_101001020*QR_021000001100+P_101001120*QR_021000001101+P_101001220*QR_021000001102+P_101101020*QR_021000001110+P_101101120*QR_021000001111+P_101101220*QR_021000001112); ans_temp[ans_id*36+30]+=Pmtrx[10]*(P_001001020*QR_020001001000+P_001001120*QR_020001001001+P_001001220*QR_020001001002+P_001101020*QR_020001001010+P_001101120*QR_020001001011+P_001101220*QR_020001001012+P_101001020*QR_020001001100+P_101001120*QR_020001001101+P_101001220*QR_020001001102+P_101101020*QR_020001001110+P_101101120*QR_020001001111+P_101101220*QR_020001001112); ans_temp[ans_id*36+30]+=Pmtrx[11]*(P_001001020*QR_020000002000+P_001001120*QR_020000002001+P_001001220*QR_020000002002+P_001101020*QR_020000002010+P_001101120*QR_020000002011+P_001101220*QR_020000002012+P_101001020*QR_020000002100+P_101001120*QR_020000002101+P_101001220*QR_020000002102+P_101101020*QR_020000002110+P_101101120*QR_020000002111+P_101101220*QR_020000002112); ans_temp[ans_id*36+31]+=Pmtrx[6]*(P_001001020*QR_012010000000+P_001001120*QR_012010000001+P_001001220*QR_012010000002+P_001101020*QR_012010000010+P_001101120*QR_012010000011+P_001101220*QR_012010000012+P_101001020*QR_012010000100+P_101001120*QR_012010000101+P_101001220*QR_012010000102+P_101101020*QR_012010000110+P_101101120*QR_012010000111+P_101101220*QR_012010000112); ans_temp[ans_id*36+31]+=Pmtrx[7]*(P_001001020*QR_011011000000+P_001001120*QR_011011000001+P_001001220*QR_011011000002+P_001101020*QR_011011000010+P_001101120*QR_011011000011+P_001101220*QR_011011000012+P_101001020*QR_011011000100+P_101001120*QR_011011000101+P_101001220*QR_011011000102+P_101101020*QR_011011000110+P_101101120*QR_011011000111+P_101101220*QR_011011000112); ans_temp[ans_id*36+31]+=Pmtrx[8]*(P_001001020*QR_010012000000+P_001001120*QR_010012000001+P_001001220*QR_010012000002+P_001101020*QR_010012000010+P_001101120*QR_010012000011+P_001101220*QR_010012000012+P_101001020*QR_010012000100+P_101001120*QR_010012000101+P_101001220*QR_010012000102+P_101101020*QR_010012000110+P_101101120*QR_010012000111+P_101101220*QR_010012000112); ans_temp[ans_id*36+31]+=Pmtrx[9]*(P_001001020*QR_011010001000+P_001001120*QR_011010001001+P_001001220*QR_011010001002+P_001101020*QR_011010001010+P_001101120*QR_011010001011+P_001101220*QR_011010001012+P_101001020*QR_011010001100+P_101001120*QR_011010001101+P_101001220*QR_011010001102+P_101101020*QR_011010001110+P_101101120*QR_011010001111+P_101101220*QR_011010001112); ans_temp[ans_id*36+31]+=Pmtrx[10]*(P_001001020*QR_010011001000+P_001001120*QR_010011001001+P_001001220*QR_010011001002+P_001101020*QR_010011001010+P_001101120*QR_010011001011+P_001101220*QR_010011001012+P_101001020*QR_010011001100+P_101001120*QR_010011001101+P_101001220*QR_010011001102+P_101101020*QR_010011001110+P_101101120*QR_010011001111+P_101101220*QR_010011001112); ans_temp[ans_id*36+31]+=Pmtrx[11]*(P_001001020*QR_010010002000+P_001001120*QR_010010002001+P_001001220*QR_010010002002+P_001101020*QR_010010002010+P_001101120*QR_010010002011+P_001101220*QR_010010002012+P_101001020*QR_010010002100+P_101001120*QR_010010002101+P_101001220*QR_010010002102+P_101101020*QR_010010002110+P_101101120*QR_010010002111+P_101101220*QR_010010002112); ans_temp[ans_id*36+32]+=Pmtrx[6]*(P_001001020*QR_002020000000+P_001001120*QR_002020000001+P_001001220*QR_002020000002+P_001101020*QR_002020000010+P_001101120*QR_002020000011+P_001101220*QR_002020000012+P_101001020*QR_002020000100+P_101001120*QR_002020000101+P_101001220*QR_002020000102+P_101101020*QR_002020000110+P_101101120*QR_002020000111+P_101101220*QR_002020000112); ans_temp[ans_id*36+32]+=Pmtrx[7]*(P_001001020*QR_001021000000+P_001001120*QR_001021000001+P_001001220*QR_001021000002+P_001101020*QR_001021000010+P_001101120*QR_001021000011+P_001101220*QR_001021000012+P_101001020*QR_001021000100+P_101001120*QR_001021000101+P_101001220*QR_001021000102+P_101101020*QR_001021000110+P_101101120*QR_001021000111+P_101101220*QR_001021000112); ans_temp[ans_id*36+32]+=Pmtrx[8]*(P_001001020*QR_000022000000+P_001001120*QR_000022000001+P_001001220*QR_000022000002+P_001101020*QR_000022000010+P_001101120*QR_000022000011+P_001101220*QR_000022000012+P_101001020*QR_000022000100+P_101001120*QR_000022000101+P_101001220*QR_000022000102+P_101101020*QR_000022000110+P_101101120*QR_000022000111+P_101101220*QR_000022000112); ans_temp[ans_id*36+32]+=Pmtrx[9]*(P_001001020*QR_001020001000+P_001001120*QR_001020001001+P_001001220*QR_001020001002+P_001101020*QR_001020001010+P_001101120*QR_001020001011+P_001101220*QR_001020001012+P_101001020*QR_001020001100+P_101001120*QR_001020001101+P_101001220*QR_001020001102+P_101101020*QR_001020001110+P_101101120*QR_001020001111+P_101101220*QR_001020001112); ans_temp[ans_id*36+32]+=Pmtrx[10]*(P_001001020*QR_000021001000+P_001001120*QR_000021001001+P_001001220*QR_000021001002+P_001101020*QR_000021001010+P_001101120*QR_000021001011+P_001101220*QR_000021001012+P_101001020*QR_000021001100+P_101001120*QR_000021001101+P_101001220*QR_000021001102+P_101101020*QR_000021001110+P_101101120*QR_000021001111+P_101101220*QR_000021001112); ans_temp[ans_id*36+32]+=Pmtrx[11]*(P_001001020*QR_000020002000+P_001001120*QR_000020002001+P_001001220*QR_000020002002+P_001101020*QR_000020002010+P_001101120*QR_000020002011+P_001101220*QR_000020002012+P_101001020*QR_000020002100+P_101001120*QR_000020002101+P_101001220*QR_000020002102+P_101101020*QR_000020002110+P_101101120*QR_000020002111+P_101101220*QR_000020002112); ans_temp[ans_id*36+33]+=Pmtrx[6]*(P_001001020*QR_012000010000+P_001001120*QR_012000010001+P_001001220*QR_012000010002+P_001101020*QR_012000010010+P_001101120*QR_012000010011+P_001101220*QR_012000010012+P_101001020*QR_012000010100+P_101001120*QR_012000010101+P_101001220*QR_012000010102+P_101101020*QR_012000010110+P_101101120*QR_012000010111+P_101101220*QR_012000010112); ans_temp[ans_id*36+33]+=Pmtrx[7]*(P_001001020*QR_011001010000+P_001001120*QR_011001010001+P_001001220*QR_011001010002+P_001101020*QR_011001010010+P_001101120*QR_011001010011+P_001101220*QR_011001010012+P_101001020*QR_011001010100+P_101001120*QR_011001010101+P_101001220*QR_011001010102+P_101101020*QR_011001010110+P_101101120*QR_011001010111+P_101101220*QR_011001010112); ans_temp[ans_id*36+33]+=Pmtrx[8]*(P_001001020*QR_010002010000+P_001001120*QR_010002010001+P_001001220*QR_010002010002+P_001101020*QR_010002010010+P_001101120*QR_010002010011+P_001101220*QR_010002010012+P_101001020*QR_010002010100+P_101001120*QR_010002010101+P_101001220*QR_010002010102+P_101101020*QR_010002010110+P_101101120*QR_010002010111+P_101101220*QR_010002010112); ans_temp[ans_id*36+33]+=Pmtrx[9]*(P_001001020*QR_011000011000+P_001001120*QR_011000011001+P_001001220*QR_011000011002+P_001101020*QR_011000011010+P_001101120*QR_011000011011+P_001101220*QR_011000011012+P_101001020*QR_011000011100+P_101001120*QR_011000011101+P_101001220*QR_011000011102+P_101101020*QR_011000011110+P_101101120*QR_011000011111+P_101101220*QR_011000011112); ans_temp[ans_id*36+33]+=Pmtrx[10]*(P_001001020*QR_010001011000+P_001001120*QR_010001011001+P_001001220*QR_010001011002+P_001101020*QR_010001011010+P_001101120*QR_010001011011+P_001101220*QR_010001011012+P_101001020*QR_010001011100+P_101001120*QR_010001011101+P_101001220*QR_010001011102+P_101101020*QR_010001011110+P_101101120*QR_010001011111+P_101101220*QR_010001011112); ans_temp[ans_id*36+33]+=Pmtrx[11]*(P_001001020*QR_010000012000+P_001001120*QR_010000012001+P_001001220*QR_010000012002+P_001101020*QR_010000012010+P_001101120*QR_010000012011+P_001101220*QR_010000012012+P_101001020*QR_010000012100+P_101001120*QR_010000012101+P_101001220*QR_010000012102+P_101101020*QR_010000012110+P_101101120*QR_010000012111+P_101101220*QR_010000012112); ans_temp[ans_id*36+34]+=Pmtrx[6]*(P_001001020*QR_002010010000+P_001001120*QR_002010010001+P_001001220*QR_002010010002+P_001101020*QR_002010010010+P_001101120*QR_002010010011+P_001101220*QR_002010010012+P_101001020*QR_002010010100+P_101001120*QR_002010010101+P_101001220*QR_002010010102+P_101101020*QR_002010010110+P_101101120*QR_002010010111+P_101101220*QR_002010010112); ans_temp[ans_id*36+34]+=Pmtrx[7]*(P_001001020*QR_001011010000+P_001001120*QR_001011010001+P_001001220*QR_001011010002+P_001101020*QR_001011010010+P_001101120*QR_001011010011+P_001101220*QR_001011010012+P_101001020*QR_001011010100+P_101001120*QR_001011010101+P_101001220*QR_001011010102+P_101101020*QR_001011010110+P_101101120*QR_001011010111+P_101101220*QR_001011010112); ans_temp[ans_id*36+34]+=Pmtrx[8]*(P_001001020*QR_000012010000+P_001001120*QR_000012010001+P_001001220*QR_000012010002+P_001101020*QR_000012010010+P_001101120*QR_000012010011+P_001101220*QR_000012010012+P_101001020*QR_000012010100+P_101001120*QR_000012010101+P_101001220*QR_000012010102+P_101101020*QR_000012010110+P_101101120*QR_000012010111+P_101101220*QR_000012010112); ans_temp[ans_id*36+34]+=Pmtrx[9]*(P_001001020*QR_001010011000+P_001001120*QR_001010011001+P_001001220*QR_001010011002+P_001101020*QR_001010011010+P_001101120*QR_001010011011+P_001101220*QR_001010011012+P_101001020*QR_001010011100+P_101001120*QR_001010011101+P_101001220*QR_001010011102+P_101101020*QR_001010011110+P_101101120*QR_001010011111+P_101101220*QR_001010011112); ans_temp[ans_id*36+34]+=Pmtrx[10]*(P_001001020*QR_000011011000+P_001001120*QR_000011011001+P_001001220*QR_000011011002+P_001101020*QR_000011011010+P_001101120*QR_000011011011+P_001101220*QR_000011011012+P_101001020*QR_000011011100+P_101001120*QR_000011011101+P_101001220*QR_000011011102+P_101101020*QR_000011011110+P_101101120*QR_000011011111+P_101101220*QR_000011011112); ans_temp[ans_id*36+34]+=Pmtrx[11]*(P_001001020*QR_000010012000+P_001001120*QR_000010012001+P_001001220*QR_000010012002+P_001101020*QR_000010012010+P_001101120*QR_000010012011+P_001101220*QR_000010012012+P_101001020*QR_000010012100+P_101001120*QR_000010012101+P_101001220*QR_000010012102+P_101101020*QR_000010012110+P_101101120*QR_000010012111+P_101101220*QR_000010012112); ans_temp[ans_id*36+35]+=Pmtrx[6]*(P_001001020*QR_002000020000+P_001001120*QR_002000020001+P_001001220*QR_002000020002+P_001101020*QR_002000020010+P_001101120*QR_002000020011+P_001101220*QR_002000020012+P_101001020*QR_002000020100+P_101001120*QR_002000020101+P_101001220*QR_002000020102+P_101101020*QR_002000020110+P_101101120*QR_002000020111+P_101101220*QR_002000020112); ans_temp[ans_id*36+35]+=Pmtrx[7]*(P_001001020*QR_001001020000+P_001001120*QR_001001020001+P_001001220*QR_001001020002+P_001101020*QR_001001020010+P_001101120*QR_001001020011+P_001101220*QR_001001020012+P_101001020*QR_001001020100+P_101001120*QR_001001020101+P_101001220*QR_001001020102+P_101101020*QR_001001020110+P_101101120*QR_001001020111+P_101101220*QR_001001020112); ans_temp[ans_id*36+35]+=Pmtrx[8]*(P_001001020*QR_000002020000+P_001001120*QR_000002020001+P_001001220*QR_000002020002+P_001101020*QR_000002020010+P_001101120*QR_000002020011+P_001101220*QR_000002020012+P_101001020*QR_000002020100+P_101001120*QR_000002020101+P_101001220*QR_000002020102+P_101101020*QR_000002020110+P_101101120*QR_000002020111+P_101101220*QR_000002020112); ans_temp[ans_id*36+35]+=Pmtrx[9]*(P_001001020*QR_001000021000+P_001001120*QR_001000021001+P_001001220*QR_001000021002+P_001101020*QR_001000021010+P_001101120*QR_001000021011+P_001101220*QR_001000021012+P_101001020*QR_001000021100+P_101001120*QR_001000021101+P_101001220*QR_001000021102+P_101101020*QR_001000021110+P_101101120*QR_001000021111+P_101101220*QR_001000021112); ans_temp[ans_id*36+35]+=Pmtrx[10]*(P_001001020*QR_000001021000+P_001001120*QR_000001021001+P_001001220*QR_000001021002+P_001101020*QR_000001021010+P_001101120*QR_000001021011+P_001101220*QR_000001021012+P_101001020*QR_000001021100+P_101001120*QR_000001021101+P_101001220*QR_000001021102+P_101101020*QR_000001021110+P_101101120*QR_000001021111+P_101101220*QR_000001021112); ans_temp[ans_id*36+35]+=Pmtrx[11]*(P_001001020*QR_000000022000+P_001001120*QR_000000022001+P_001001220*QR_000000022002+P_001101020*QR_000000022010+P_001101120*QR_000000022011+P_001101220*QR_000000022012+P_101001020*QR_000000022100+P_101001120*QR_000000022101+P_101001220*QR_000000022102+P_101101020*QR_000000022110+P_101101120*QR_000000022111+P_101101220*QR_000000022112); ans_temp[ans_id*36+30]+=Pmtrx[12]*(P_000002020*QR_022000000000+P_000002120*QR_022000000001+P_000002220*QR_022000000002+P_000102020*QR_022000000010+P_000102120*QR_022000000011+P_000102220*QR_022000000012+P_000202020*QR_022000000020+P_000202120*QR_022000000021+P_000202220*QR_022000000022); ans_temp[ans_id*36+30]+=Pmtrx[13]*(P_000002020*QR_021001000000+P_000002120*QR_021001000001+P_000002220*QR_021001000002+P_000102020*QR_021001000010+P_000102120*QR_021001000011+P_000102220*QR_021001000012+P_000202020*QR_021001000020+P_000202120*QR_021001000021+P_000202220*QR_021001000022); ans_temp[ans_id*36+30]+=Pmtrx[14]*(P_000002020*QR_020002000000+P_000002120*QR_020002000001+P_000002220*QR_020002000002+P_000102020*QR_020002000010+P_000102120*QR_020002000011+P_000102220*QR_020002000012+P_000202020*QR_020002000020+P_000202120*QR_020002000021+P_000202220*QR_020002000022); ans_temp[ans_id*36+30]+=Pmtrx[15]*(P_000002020*QR_021000001000+P_000002120*QR_021000001001+P_000002220*QR_021000001002+P_000102020*QR_021000001010+P_000102120*QR_021000001011+P_000102220*QR_021000001012+P_000202020*QR_021000001020+P_000202120*QR_021000001021+P_000202220*QR_021000001022); ans_temp[ans_id*36+30]+=Pmtrx[16]*(P_000002020*QR_020001001000+P_000002120*QR_020001001001+P_000002220*QR_020001001002+P_000102020*QR_020001001010+P_000102120*QR_020001001011+P_000102220*QR_020001001012+P_000202020*QR_020001001020+P_000202120*QR_020001001021+P_000202220*QR_020001001022); ans_temp[ans_id*36+30]+=Pmtrx[17]*(P_000002020*QR_020000002000+P_000002120*QR_020000002001+P_000002220*QR_020000002002+P_000102020*QR_020000002010+P_000102120*QR_020000002011+P_000102220*QR_020000002012+P_000202020*QR_020000002020+P_000202120*QR_020000002021+P_000202220*QR_020000002022); ans_temp[ans_id*36+31]+=Pmtrx[12]*(P_000002020*QR_012010000000+P_000002120*QR_012010000001+P_000002220*QR_012010000002+P_000102020*QR_012010000010+P_000102120*QR_012010000011+P_000102220*QR_012010000012+P_000202020*QR_012010000020+P_000202120*QR_012010000021+P_000202220*QR_012010000022); ans_temp[ans_id*36+31]+=Pmtrx[13]*(P_000002020*QR_011011000000+P_000002120*QR_011011000001+P_000002220*QR_011011000002+P_000102020*QR_011011000010+P_000102120*QR_011011000011+P_000102220*QR_011011000012+P_000202020*QR_011011000020+P_000202120*QR_011011000021+P_000202220*QR_011011000022); ans_temp[ans_id*36+31]+=Pmtrx[14]*(P_000002020*QR_010012000000+P_000002120*QR_010012000001+P_000002220*QR_010012000002+P_000102020*QR_010012000010+P_000102120*QR_010012000011+P_000102220*QR_010012000012+P_000202020*QR_010012000020+P_000202120*QR_010012000021+P_000202220*QR_010012000022); ans_temp[ans_id*36+31]+=Pmtrx[15]*(P_000002020*QR_011010001000+P_000002120*QR_011010001001+P_000002220*QR_011010001002+P_000102020*QR_011010001010+P_000102120*QR_011010001011+P_000102220*QR_011010001012+P_000202020*QR_011010001020+P_000202120*QR_011010001021+P_000202220*QR_011010001022); ans_temp[ans_id*36+31]+=Pmtrx[16]*(P_000002020*QR_010011001000+P_000002120*QR_010011001001+P_000002220*QR_010011001002+P_000102020*QR_010011001010+P_000102120*QR_010011001011+P_000102220*QR_010011001012+P_000202020*QR_010011001020+P_000202120*QR_010011001021+P_000202220*QR_010011001022); ans_temp[ans_id*36+31]+=Pmtrx[17]*(P_000002020*QR_010010002000+P_000002120*QR_010010002001+P_000002220*QR_010010002002+P_000102020*QR_010010002010+P_000102120*QR_010010002011+P_000102220*QR_010010002012+P_000202020*QR_010010002020+P_000202120*QR_010010002021+P_000202220*QR_010010002022); ans_temp[ans_id*36+32]+=Pmtrx[12]*(P_000002020*QR_002020000000+P_000002120*QR_002020000001+P_000002220*QR_002020000002+P_000102020*QR_002020000010+P_000102120*QR_002020000011+P_000102220*QR_002020000012+P_000202020*QR_002020000020+P_000202120*QR_002020000021+P_000202220*QR_002020000022); ans_temp[ans_id*36+32]+=Pmtrx[13]*(P_000002020*QR_001021000000+P_000002120*QR_001021000001+P_000002220*QR_001021000002+P_000102020*QR_001021000010+P_000102120*QR_001021000011+P_000102220*QR_001021000012+P_000202020*QR_001021000020+P_000202120*QR_001021000021+P_000202220*QR_001021000022); ans_temp[ans_id*36+32]+=Pmtrx[14]*(P_000002020*QR_000022000000+P_000002120*QR_000022000001+P_000002220*QR_000022000002+P_000102020*QR_000022000010+P_000102120*QR_000022000011+P_000102220*QR_000022000012+P_000202020*QR_000022000020+P_000202120*QR_000022000021+P_000202220*QR_000022000022); ans_temp[ans_id*36+32]+=Pmtrx[15]*(P_000002020*QR_001020001000+P_000002120*QR_001020001001+P_000002220*QR_001020001002+P_000102020*QR_001020001010+P_000102120*QR_001020001011+P_000102220*QR_001020001012+P_000202020*QR_001020001020+P_000202120*QR_001020001021+P_000202220*QR_001020001022); ans_temp[ans_id*36+32]+=Pmtrx[16]*(P_000002020*QR_000021001000+P_000002120*QR_000021001001+P_000002220*QR_000021001002+P_000102020*QR_000021001010+P_000102120*QR_000021001011+P_000102220*QR_000021001012+P_000202020*QR_000021001020+P_000202120*QR_000021001021+P_000202220*QR_000021001022); ans_temp[ans_id*36+32]+=Pmtrx[17]*(P_000002020*QR_000020002000+P_000002120*QR_000020002001+P_000002220*QR_000020002002+P_000102020*QR_000020002010+P_000102120*QR_000020002011+P_000102220*QR_000020002012+P_000202020*QR_000020002020+P_000202120*QR_000020002021+P_000202220*QR_000020002022); ans_temp[ans_id*36+33]+=Pmtrx[12]*(P_000002020*QR_012000010000+P_000002120*QR_012000010001+P_000002220*QR_012000010002+P_000102020*QR_012000010010+P_000102120*QR_012000010011+P_000102220*QR_012000010012+P_000202020*QR_012000010020+P_000202120*QR_012000010021+P_000202220*QR_012000010022); ans_temp[ans_id*36+33]+=Pmtrx[13]*(P_000002020*QR_011001010000+P_000002120*QR_011001010001+P_000002220*QR_011001010002+P_000102020*QR_011001010010+P_000102120*QR_011001010011+P_000102220*QR_011001010012+P_000202020*QR_011001010020+P_000202120*QR_011001010021+P_000202220*QR_011001010022); ans_temp[ans_id*36+33]+=Pmtrx[14]*(P_000002020*QR_010002010000+P_000002120*QR_010002010001+P_000002220*QR_010002010002+P_000102020*QR_010002010010+P_000102120*QR_010002010011+P_000102220*QR_010002010012+P_000202020*QR_010002010020+P_000202120*QR_010002010021+P_000202220*QR_010002010022); ans_temp[ans_id*36+33]+=Pmtrx[15]*(P_000002020*QR_011000011000+P_000002120*QR_011000011001+P_000002220*QR_011000011002+P_000102020*QR_011000011010+P_000102120*QR_011000011011+P_000102220*QR_011000011012+P_000202020*QR_011000011020+P_000202120*QR_011000011021+P_000202220*QR_011000011022); ans_temp[ans_id*36+33]+=Pmtrx[16]*(P_000002020*QR_010001011000+P_000002120*QR_010001011001+P_000002220*QR_010001011002+P_000102020*QR_010001011010+P_000102120*QR_010001011011+P_000102220*QR_010001011012+P_000202020*QR_010001011020+P_000202120*QR_010001011021+P_000202220*QR_010001011022); ans_temp[ans_id*36+33]+=Pmtrx[17]*(P_000002020*QR_010000012000+P_000002120*QR_010000012001+P_000002220*QR_010000012002+P_000102020*QR_010000012010+P_000102120*QR_010000012011+P_000102220*QR_010000012012+P_000202020*QR_010000012020+P_000202120*QR_010000012021+P_000202220*QR_010000012022); ans_temp[ans_id*36+34]+=Pmtrx[12]*(P_000002020*QR_002010010000+P_000002120*QR_002010010001+P_000002220*QR_002010010002+P_000102020*QR_002010010010+P_000102120*QR_002010010011+P_000102220*QR_002010010012+P_000202020*QR_002010010020+P_000202120*QR_002010010021+P_000202220*QR_002010010022); ans_temp[ans_id*36+34]+=Pmtrx[13]*(P_000002020*QR_001011010000+P_000002120*QR_001011010001+P_000002220*QR_001011010002+P_000102020*QR_001011010010+P_000102120*QR_001011010011+P_000102220*QR_001011010012+P_000202020*QR_001011010020+P_000202120*QR_001011010021+P_000202220*QR_001011010022); ans_temp[ans_id*36+34]+=Pmtrx[14]*(P_000002020*QR_000012010000+P_000002120*QR_000012010001+P_000002220*QR_000012010002+P_000102020*QR_000012010010+P_000102120*QR_000012010011+P_000102220*QR_000012010012+P_000202020*QR_000012010020+P_000202120*QR_000012010021+P_000202220*QR_000012010022); ans_temp[ans_id*36+34]+=Pmtrx[15]*(P_000002020*QR_001010011000+P_000002120*QR_001010011001+P_000002220*QR_001010011002+P_000102020*QR_001010011010+P_000102120*QR_001010011011+P_000102220*QR_001010011012+P_000202020*QR_001010011020+P_000202120*QR_001010011021+P_000202220*QR_001010011022); ans_temp[ans_id*36+34]+=Pmtrx[16]*(P_000002020*QR_000011011000+P_000002120*QR_000011011001+P_000002220*QR_000011011002+P_000102020*QR_000011011010+P_000102120*QR_000011011011+P_000102220*QR_000011011012+P_000202020*QR_000011011020+P_000202120*QR_000011011021+P_000202220*QR_000011011022); ans_temp[ans_id*36+34]+=Pmtrx[17]*(P_000002020*QR_000010012000+P_000002120*QR_000010012001+P_000002220*QR_000010012002+P_000102020*QR_000010012010+P_000102120*QR_000010012011+P_000102220*QR_000010012012+P_000202020*QR_000010012020+P_000202120*QR_000010012021+P_000202220*QR_000010012022); ans_temp[ans_id*36+35]+=Pmtrx[12]*(P_000002020*QR_002000020000+P_000002120*QR_002000020001+P_000002220*QR_002000020002+P_000102020*QR_002000020010+P_000102120*QR_002000020011+P_000102220*QR_002000020012+P_000202020*QR_002000020020+P_000202120*QR_002000020021+P_000202220*QR_002000020022); ans_temp[ans_id*36+35]+=Pmtrx[13]*(P_000002020*QR_001001020000+P_000002120*QR_001001020001+P_000002220*QR_001001020002+P_000102020*QR_001001020010+P_000102120*QR_001001020011+P_000102220*QR_001001020012+P_000202020*QR_001001020020+P_000202120*QR_001001020021+P_000202220*QR_001001020022); ans_temp[ans_id*36+35]+=Pmtrx[14]*(P_000002020*QR_000002020000+P_000002120*QR_000002020001+P_000002220*QR_000002020002+P_000102020*QR_000002020010+P_000102120*QR_000002020011+P_000102220*QR_000002020012+P_000202020*QR_000002020020+P_000202120*QR_000002020021+P_000202220*QR_000002020022); ans_temp[ans_id*36+35]+=Pmtrx[15]*(P_000002020*QR_001000021000+P_000002120*QR_001000021001+P_000002220*QR_001000021002+P_000102020*QR_001000021010+P_000102120*QR_001000021011+P_000102220*QR_001000021012+P_000202020*QR_001000021020+P_000202120*QR_001000021021+P_000202220*QR_001000021022); ans_temp[ans_id*36+35]+=Pmtrx[16]*(P_000002020*QR_000001021000+P_000002120*QR_000001021001+P_000002220*QR_000001021002+P_000102020*QR_000001021010+P_000102120*QR_000001021011+P_000102220*QR_000001021012+P_000202020*QR_000001021020+P_000202120*QR_000001021021+P_000202220*QR_000001021022); ans_temp[ans_id*36+35]+=Pmtrx[17]*(P_000002020*QR_000000022000+P_000002120*QR_000000022001+P_000002220*QR_000000022002+P_000102020*QR_000000022010+P_000102120*QR_000000022011+P_000102220*QR_000000022012+P_000202020*QR_000000022020+P_000202120*QR_000000022021+P_000202220*QR_000000022022); ans_temp[ans_id*36+30]+=Pmtrx[18]*(P_001000021*QR_022000000000+P_001000121*QR_022000000001+P_001000221*QR_022000000002+P_001000321*QR_022000000003+P_101000021*QR_022000000100+P_101000121*QR_022000000101+P_101000221*QR_022000000102+P_101000321*QR_022000000103); ans_temp[ans_id*36+30]+=Pmtrx[19]*(P_001000021*QR_021001000000+P_001000121*QR_021001000001+P_001000221*QR_021001000002+P_001000321*QR_021001000003+P_101000021*QR_021001000100+P_101000121*QR_021001000101+P_101000221*QR_021001000102+P_101000321*QR_021001000103); ans_temp[ans_id*36+30]+=Pmtrx[20]*(P_001000021*QR_020002000000+P_001000121*QR_020002000001+P_001000221*QR_020002000002+P_001000321*QR_020002000003+P_101000021*QR_020002000100+P_101000121*QR_020002000101+P_101000221*QR_020002000102+P_101000321*QR_020002000103); ans_temp[ans_id*36+30]+=Pmtrx[21]*(P_001000021*QR_021000001000+P_001000121*QR_021000001001+P_001000221*QR_021000001002+P_001000321*QR_021000001003+P_101000021*QR_021000001100+P_101000121*QR_021000001101+P_101000221*QR_021000001102+P_101000321*QR_021000001103); ans_temp[ans_id*36+30]+=Pmtrx[22]*(P_001000021*QR_020001001000+P_001000121*QR_020001001001+P_001000221*QR_020001001002+P_001000321*QR_020001001003+P_101000021*QR_020001001100+P_101000121*QR_020001001101+P_101000221*QR_020001001102+P_101000321*QR_020001001103); ans_temp[ans_id*36+30]+=Pmtrx[23]*(P_001000021*QR_020000002000+P_001000121*QR_020000002001+P_001000221*QR_020000002002+P_001000321*QR_020000002003+P_101000021*QR_020000002100+P_101000121*QR_020000002101+P_101000221*QR_020000002102+P_101000321*QR_020000002103); ans_temp[ans_id*36+31]+=Pmtrx[18]*(P_001000021*QR_012010000000+P_001000121*QR_012010000001+P_001000221*QR_012010000002+P_001000321*QR_012010000003+P_101000021*QR_012010000100+P_101000121*QR_012010000101+P_101000221*QR_012010000102+P_101000321*QR_012010000103); ans_temp[ans_id*36+31]+=Pmtrx[19]*(P_001000021*QR_011011000000+P_001000121*QR_011011000001+P_001000221*QR_011011000002+P_001000321*QR_011011000003+P_101000021*QR_011011000100+P_101000121*QR_011011000101+P_101000221*QR_011011000102+P_101000321*QR_011011000103); ans_temp[ans_id*36+31]+=Pmtrx[20]*(P_001000021*QR_010012000000+P_001000121*QR_010012000001+P_001000221*QR_010012000002+P_001000321*QR_010012000003+P_101000021*QR_010012000100+P_101000121*QR_010012000101+P_101000221*QR_010012000102+P_101000321*QR_010012000103); ans_temp[ans_id*36+31]+=Pmtrx[21]*(P_001000021*QR_011010001000+P_001000121*QR_011010001001+P_001000221*QR_011010001002+P_001000321*QR_011010001003+P_101000021*QR_011010001100+P_101000121*QR_011010001101+P_101000221*QR_011010001102+P_101000321*QR_011010001103); ans_temp[ans_id*36+31]+=Pmtrx[22]*(P_001000021*QR_010011001000+P_001000121*QR_010011001001+P_001000221*QR_010011001002+P_001000321*QR_010011001003+P_101000021*QR_010011001100+P_101000121*QR_010011001101+P_101000221*QR_010011001102+P_101000321*QR_010011001103); ans_temp[ans_id*36+31]+=Pmtrx[23]*(P_001000021*QR_010010002000+P_001000121*QR_010010002001+P_001000221*QR_010010002002+P_001000321*QR_010010002003+P_101000021*QR_010010002100+P_101000121*QR_010010002101+P_101000221*QR_010010002102+P_101000321*QR_010010002103); ans_temp[ans_id*36+32]+=Pmtrx[18]*(P_001000021*QR_002020000000+P_001000121*QR_002020000001+P_001000221*QR_002020000002+P_001000321*QR_002020000003+P_101000021*QR_002020000100+P_101000121*QR_002020000101+P_101000221*QR_002020000102+P_101000321*QR_002020000103); ans_temp[ans_id*36+32]+=Pmtrx[19]*(P_001000021*QR_001021000000+P_001000121*QR_001021000001+P_001000221*QR_001021000002+P_001000321*QR_001021000003+P_101000021*QR_001021000100+P_101000121*QR_001021000101+P_101000221*QR_001021000102+P_101000321*QR_001021000103); ans_temp[ans_id*36+32]+=Pmtrx[20]*(P_001000021*QR_000022000000+P_001000121*QR_000022000001+P_001000221*QR_000022000002+P_001000321*QR_000022000003+P_101000021*QR_000022000100+P_101000121*QR_000022000101+P_101000221*QR_000022000102+P_101000321*QR_000022000103); ans_temp[ans_id*36+32]+=Pmtrx[21]*(P_001000021*QR_001020001000+P_001000121*QR_001020001001+P_001000221*QR_001020001002+P_001000321*QR_001020001003+P_101000021*QR_001020001100+P_101000121*QR_001020001101+P_101000221*QR_001020001102+P_101000321*QR_001020001103); ans_temp[ans_id*36+32]+=Pmtrx[22]*(P_001000021*QR_000021001000+P_001000121*QR_000021001001+P_001000221*QR_000021001002+P_001000321*QR_000021001003+P_101000021*QR_000021001100+P_101000121*QR_000021001101+P_101000221*QR_000021001102+P_101000321*QR_000021001103); ans_temp[ans_id*36+32]+=Pmtrx[23]*(P_001000021*QR_000020002000+P_001000121*QR_000020002001+P_001000221*QR_000020002002+P_001000321*QR_000020002003+P_101000021*QR_000020002100+P_101000121*QR_000020002101+P_101000221*QR_000020002102+P_101000321*QR_000020002103); ans_temp[ans_id*36+33]+=Pmtrx[18]*(P_001000021*QR_012000010000+P_001000121*QR_012000010001+P_001000221*QR_012000010002+P_001000321*QR_012000010003+P_101000021*QR_012000010100+P_101000121*QR_012000010101+P_101000221*QR_012000010102+P_101000321*QR_012000010103); ans_temp[ans_id*36+33]+=Pmtrx[19]*(P_001000021*QR_011001010000+P_001000121*QR_011001010001+P_001000221*QR_011001010002+P_001000321*QR_011001010003+P_101000021*QR_011001010100+P_101000121*QR_011001010101+P_101000221*QR_011001010102+P_101000321*QR_011001010103); ans_temp[ans_id*36+33]+=Pmtrx[20]*(P_001000021*QR_010002010000+P_001000121*QR_010002010001+P_001000221*QR_010002010002+P_001000321*QR_010002010003+P_101000021*QR_010002010100+P_101000121*QR_010002010101+P_101000221*QR_010002010102+P_101000321*QR_010002010103); ans_temp[ans_id*36+33]+=Pmtrx[21]*(P_001000021*QR_011000011000+P_001000121*QR_011000011001+P_001000221*QR_011000011002+P_001000321*QR_011000011003+P_101000021*QR_011000011100+P_101000121*QR_011000011101+P_101000221*QR_011000011102+P_101000321*QR_011000011103); ans_temp[ans_id*36+33]+=Pmtrx[22]*(P_001000021*QR_010001011000+P_001000121*QR_010001011001+P_001000221*QR_010001011002+P_001000321*QR_010001011003+P_101000021*QR_010001011100+P_101000121*QR_010001011101+P_101000221*QR_010001011102+P_101000321*QR_010001011103); ans_temp[ans_id*36+33]+=Pmtrx[23]*(P_001000021*QR_010000012000+P_001000121*QR_010000012001+P_001000221*QR_010000012002+P_001000321*QR_010000012003+P_101000021*QR_010000012100+P_101000121*QR_010000012101+P_101000221*QR_010000012102+P_101000321*QR_010000012103); ans_temp[ans_id*36+34]+=Pmtrx[18]*(P_001000021*QR_002010010000+P_001000121*QR_002010010001+P_001000221*QR_002010010002+P_001000321*QR_002010010003+P_101000021*QR_002010010100+P_101000121*QR_002010010101+P_101000221*QR_002010010102+P_101000321*QR_002010010103); ans_temp[ans_id*36+34]+=Pmtrx[19]*(P_001000021*QR_001011010000+P_001000121*QR_001011010001+P_001000221*QR_001011010002+P_001000321*QR_001011010003+P_101000021*QR_001011010100+P_101000121*QR_001011010101+P_101000221*QR_001011010102+P_101000321*QR_001011010103); ans_temp[ans_id*36+34]+=Pmtrx[20]*(P_001000021*QR_000012010000+P_001000121*QR_000012010001+P_001000221*QR_000012010002+P_001000321*QR_000012010003+P_101000021*QR_000012010100+P_101000121*QR_000012010101+P_101000221*QR_000012010102+P_101000321*QR_000012010103); ans_temp[ans_id*36+34]+=Pmtrx[21]*(P_001000021*QR_001010011000+P_001000121*QR_001010011001+P_001000221*QR_001010011002+P_001000321*QR_001010011003+P_101000021*QR_001010011100+P_101000121*QR_001010011101+P_101000221*QR_001010011102+P_101000321*QR_001010011103); ans_temp[ans_id*36+34]+=Pmtrx[22]*(P_001000021*QR_000011011000+P_001000121*QR_000011011001+P_001000221*QR_000011011002+P_001000321*QR_000011011003+P_101000021*QR_000011011100+P_101000121*QR_000011011101+P_101000221*QR_000011011102+P_101000321*QR_000011011103); ans_temp[ans_id*36+34]+=Pmtrx[23]*(P_001000021*QR_000010012000+P_001000121*QR_000010012001+P_001000221*QR_000010012002+P_001000321*QR_000010012003+P_101000021*QR_000010012100+P_101000121*QR_000010012101+P_101000221*QR_000010012102+P_101000321*QR_000010012103); ans_temp[ans_id*36+35]+=Pmtrx[18]*(P_001000021*QR_002000020000+P_001000121*QR_002000020001+P_001000221*QR_002000020002+P_001000321*QR_002000020003+P_101000021*QR_002000020100+P_101000121*QR_002000020101+P_101000221*QR_002000020102+P_101000321*QR_002000020103); ans_temp[ans_id*36+35]+=Pmtrx[19]*(P_001000021*QR_001001020000+P_001000121*QR_001001020001+P_001000221*QR_001001020002+P_001000321*QR_001001020003+P_101000021*QR_001001020100+P_101000121*QR_001001020101+P_101000221*QR_001001020102+P_101000321*QR_001001020103); ans_temp[ans_id*36+35]+=Pmtrx[20]*(P_001000021*QR_000002020000+P_001000121*QR_000002020001+P_001000221*QR_000002020002+P_001000321*QR_000002020003+P_101000021*QR_000002020100+P_101000121*QR_000002020101+P_101000221*QR_000002020102+P_101000321*QR_000002020103); ans_temp[ans_id*36+35]+=Pmtrx[21]*(P_001000021*QR_001000021000+P_001000121*QR_001000021001+P_001000221*QR_001000021002+P_001000321*QR_001000021003+P_101000021*QR_001000021100+P_101000121*QR_001000021101+P_101000221*QR_001000021102+P_101000321*QR_001000021103); ans_temp[ans_id*36+35]+=Pmtrx[22]*(P_001000021*QR_000001021000+P_001000121*QR_000001021001+P_001000221*QR_000001021002+P_001000321*QR_000001021003+P_101000021*QR_000001021100+P_101000121*QR_000001021101+P_101000221*QR_000001021102+P_101000321*QR_000001021103); ans_temp[ans_id*36+35]+=Pmtrx[23]*(P_001000021*QR_000000022000+P_001000121*QR_000000022001+P_001000221*QR_000000022002+P_001000321*QR_000000022003+P_101000021*QR_000000022100+P_101000121*QR_000000022101+P_101000221*QR_000000022102+P_101000321*QR_000000022103); ans_temp[ans_id*36+30]+=Pmtrx[24]*(P_000001021*QR_022000000000+P_000001121*QR_022000000001+P_000001221*QR_022000000002+P_000001321*QR_022000000003+P_000101021*QR_022000000010+P_000101121*QR_022000000011+P_000101221*QR_022000000012+P_000101321*QR_022000000013); ans_temp[ans_id*36+30]+=Pmtrx[25]*(P_000001021*QR_021001000000+P_000001121*QR_021001000001+P_000001221*QR_021001000002+P_000001321*QR_021001000003+P_000101021*QR_021001000010+P_000101121*QR_021001000011+P_000101221*QR_021001000012+P_000101321*QR_021001000013); ans_temp[ans_id*36+30]+=Pmtrx[26]*(P_000001021*QR_020002000000+P_000001121*QR_020002000001+P_000001221*QR_020002000002+P_000001321*QR_020002000003+P_000101021*QR_020002000010+P_000101121*QR_020002000011+P_000101221*QR_020002000012+P_000101321*QR_020002000013); ans_temp[ans_id*36+30]+=Pmtrx[27]*(P_000001021*QR_021000001000+P_000001121*QR_021000001001+P_000001221*QR_021000001002+P_000001321*QR_021000001003+P_000101021*QR_021000001010+P_000101121*QR_021000001011+P_000101221*QR_021000001012+P_000101321*QR_021000001013); ans_temp[ans_id*36+30]+=Pmtrx[28]*(P_000001021*QR_020001001000+P_000001121*QR_020001001001+P_000001221*QR_020001001002+P_000001321*QR_020001001003+P_000101021*QR_020001001010+P_000101121*QR_020001001011+P_000101221*QR_020001001012+P_000101321*QR_020001001013); ans_temp[ans_id*36+30]+=Pmtrx[29]*(P_000001021*QR_020000002000+P_000001121*QR_020000002001+P_000001221*QR_020000002002+P_000001321*QR_020000002003+P_000101021*QR_020000002010+P_000101121*QR_020000002011+P_000101221*QR_020000002012+P_000101321*QR_020000002013); ans_temp[ans_id*36+31]+=Pmtrx[24]*(P_000001021*QR_012010000000+P_000001121*QR_012010000001+P_000001221*QR_012010000002+P_000001321*QR_012010000003+P_000101021*QR_012010000010+P_000101121*QR_012010000011+P_000101221*QR_012010000012+P_000101321*QR_012010000013); ans_temp[ans_id*36+31]+=Pmtrx[25]*(P_000001021*QR_011011000000+P_000001121*QR_011011000001+P_000001221*QR_011011000002+P_000001321*QR_011011000003+P_000101021*QR_011011000010+P_000101121*QR_011011000011+P_000101221*QR_011011000012+P_000101321*QR_011011000013); ans_temp[ans_id*36+31]+=Pmtrx[26]*(P_000001021*QR_010012000000+P_000001121*QR_010012000001+P_000001221*QR_010012000002+P_000001321*QR_010012000003+P_000101021*QR_010012000010+P_000101121*QR_010012000011+P_000101221*QR_010012000012+P_000101321*QR_010012000013); ans_temp[ans_id*36+31]+=Pmtrx[27]*(P_000001021*QR_011010001000+P_000001121*QR_011010001001+P_000001221*QR_011010001002+P_000001321*QR_011010001003+P_000101021*QR_011010001010+P_000101121*QR_011010001011+P_000101221*QR_011010001012+P_000101321*QR_011010001013); ans_temp[ans_id*36+31]+=Pmtrx[28]*(P_000001021*QR_010011001000+P_000001121*QR_010011001001+P_000001221*QR_010011001002+P_000001321*QR_010011001003+P_000101021*QR_010011001010+P_000101121*QR_010011001011+P_000101221*QR_010011001012+P_000101321*QR_010011001013); ans_temp[ans_id*36+31]+=Pmtrx[29]*(P_000001021*QR_010010002000+P_000001121*QR_010010002001+P_000001221*QR_010010002002+P_000001321*QR_010010002003+P_000101021*QR_010010002010+P_000101121*QR_010010002011+P_000101221*QR_010010002012+P_000101321*QR_010010002013); ans_temp[ans_id*36+32]+=Pmtrx[24]*(P_000001021*QR_002020000000+P_000001121*QR_002020000001+P_000001221*QR_002020000002+P_000001321*QR_002020000003+P_000101021*QR_002020000010+P_000101121*QR_002020000011+P_000101221*QR_002020000012+P_000101321*QR_002020000013); ans_temp[ans_id*36+32]+=Pmtrx[25]*(P_000001021*QR_001021000000+P_000001121*QR_001021000001+P_000001221*QR_001021000002+P_000001321*QR_001021000003+P_000101021*QR_001021000010+P_000101121*QR_001021000011+P_000101221*QR_001021000012+P_000101321*QR_001021000013); ans_temp[ans_id*36+32]+=Pmtrx[26]*(P_000001021*QR_000022000000+P_000001121*QR_000022000001+P_000001221*QR_000022000002+P_000001321*QR_000022000003+P_000101021*QR_000022000010+P_000101121*QR_000022000011+P_000101221*QR_000022000012+P_000101321*QR_000022000013); ans_temp[ans_id*36+32]+=Pmtrx[27]*(P_000001021*QR_001020001000+P_000001121*QR_001020001001+P_000001221*QR_001020001002+P_000001321*QR_001020001003+P_000101021*QR_001020001010+P_000101121*QR_001020001011+P_000101221*QR_001020001012+P_000101321*QR_001020001013); ans_temp[ans_id*36+32]+=Pmtrx[28]*(P_000001021*QR_000021001000+P_000001121*QR_000021001001+P_000001221*QR_000021001002+P_000001321*QR_000021001003+P_000101021*QR_000021001010+P_000101121*QR_000021001011+P_000101221*QR_000021001012+P_000101321*QR_000021001013); ans_temp[ans_id*36+32]+=Pmtrx[29]*(P_000001021*QR_000020002000+P_000001121*QR_000020002001+P_000001221*QR_000020002002+P_000001321*QR_000020002003+P_000101021*QR_000020002010+P_000101121*QR_000020002011+P_000101221*QR_000020002012+P_000101321*QR_000020002013); ans_temp[ans_id*36+33]+=Pmtrx[24]*(P_000001021*QR_012000010000+P_000001121*QR_012000010001+P_000001221*QR_012000010002+P_000001321*QR_012000010003+P_000101021*QR_012000010010+P_000101121*QR_012000010011+P_000101221*QR_012000010012+P_000101321*QR_012000010013); ans_temp[ans_id*36+33]+=Pmtrx[25]*(P_000001021*QR_011001010000+P_000001121*QR_011001010001+P_000001221*QR_011001010002+P_000001321*QR_011001010003+P_000101021*QR_011001010010+P_000101121*QR_011001010011+P_000101221*QR_011001010012+P_000101321*QR_011001010013); ans_temp[ans_id*36+33]+=Pmtrx[26]*(P_000001021*QR_010002010000+P_000001121*QR_010002010001+P_000001221*QR_010002010002+P_000001321*QR_010002010003+P_000101021*QR_010002010010+P_000101121*QR_010002010011+P_000101221*QR_010002010012+P_000101321*QR_010002010013); ans_temp[ans_id*36+33]+=Pmtrx[27]*(P_000001021*QR_011000011000+P_000001121*QR_011000011001+P_000001221*QR_011000011002+P_000001321*QR_011000011003+P_000101021*QR_011000011010+P_000101121*QR_011000011011+P_000101221*QR_011000011012+P_000101321*QR_011000011013); ans_temp[ans_id*36+33]+=Pmtrx[28]*(P_000001021*QR_010001011000+P_000001121*QR_010001011001+P_000001221*QR_010001011002+P_000001321*QR_010001011003+P_000101021*QR_010001011010+P_000101121*QR_010001011011+P_000101221*QR_010001011012+P_000101321*QR_010001011013); ans_temp[ans_id*36+33]+=Pmtrx[29]*(P_000001021*QR_010000012000+P_000001121*QR_010000012001+P_000001221*QR_010000012002+P_000001321*QR_010000012003+P_000101021*QR_010000012010+P_000101121*QR_010000012011+P_000101221*QR_010000012012+P_000101321*QR_010000012013); ans_temp[ans_id*36+34]+=Pmtrx[24]*(P_000001021*QR_002010010000+P_000001121*QR_002010010001+P_000001221*QR_002010010002+P_000001321*QR_002010010003+P_000101021*QR_002010010010+P_000101121*QR_002010010011+P_000101221*QR_002010010012+P_000101321*QR_002010010013); ans_temp[ans_id*36+34]+=Pmtrx[25]*(P_000001021*QR_001011010000+P_000001121*QR_001011010001+P_000001221*QR_001011010002+P_000001321*QR_001011010003+P_000101021*QR_001011010010+P_000101121*QR_001011010011+P_000101221*QR_001011010012+P_000101321*QR_001011010013); ans_temp[ans_id*36+34]+=Pmtrx[26]*(P_000001021*QR_000012010000+P_000001121*QR_000012010001+P_000001221*QR_000012010002+P_000001321*QR_000012010003+P_000101021*QR_000012010010+P_000101121*QR_000012010011+P_000101221*QR_000012010012+P_000101321*QR_000012010013); ans_temp[ans_id*36+34]+=Pmtrx[27]*(P_000001021*QR_001010011000+P_000001121*QR_001010011001+P_000001221*QR_001010011002+P_000001321*QR_001010011003+P_000101021*QR_001010011010+P_000101121*QR_001010011011+P_000101221*QR_001010011012+P_000101321*QR_001010011013); ans_temp[ans_id*36+34]+=Pmtrx[28]*(P_000001021*QR_000011011000+P_000001121*QR_000011011001+P_000001221*QR_000011011002+P_000001321*QR_000011011003+P_000101021*QR_000011011010+P_000101121*QR_000011011011+P_000101221*QR_000011011012+P_000101321*QR_000011011013); ans_temp[ans_id*36+34]+=Pmtrx[29]*(P_000001021*QR_000010012000+P_000001121*QR_000010012001+P_000001221*QR_000010012002+P_000001321*QR_000010012003+P_000101021*QR_000010012010+P_000101121*QR_000010012011+P_000101221*QR_000010012012+P_000101321*QR_000010012013); ans_temp[ans_id*36+35]+=Pmtrx[24]*(P_000001021*QR_002000020000+P_000001121*QR_002000020001+P_000001221*QR_002000020002+P_000001321*QR_002000020003+P_000101021*QR_002000020010+P_000101121*QR_002000020011+P_000101221*QR_002000020012+P_000101321*QR_002000020013); ans_temp[ans_id*36+35]+=Pmtrx[25]*(P_000001021*QR_001001020000+P_000001121*QR_001001020001+P_000001221*QR_001001020002+P_000001321*QR_001001020003+P_000101021*QR_001001020010+P_000101121*QR_001001020011+P_000101221*QR_001001020012+P_000101321*QR_001001020013); ans_temp[ans_id*36+35]+=Pmtrx[26]*(P_000001021*QR_000002020000+P_000001121*QR_000002020001+P_000001221*QR_000002020002+P_000001321*QR_000002020003+P_000101021*QR_000002020010+P_000101121*QR_000002020011+P_000101221*QR_000002020012+P_000101321*QR_000002020013); ans_temp[ans_id*36+35]+=Pmtrx[27]*(P_000001021*QR_001000021000+P_000001121*QR_001000021001+P_000001221*QR_001000021002+P_000001321*QR_001000021003+P_000101021*QR_001000021010+P_000101121*QR_001000021011+P_000101221*QR_001000021012+P_000101321*QR_001000021013); ans_temp[ans_id*36+35]+=Pmtrx[28]*(P_000001021*QR_000001021000+P_000001121*QR_000001021001+P_000001221*QR_000001021002+P_000001321*QR_000001021003+P_000101021*QR_000001021010+P_000101121*QR_000001021011+P_000101221*QR_000001021012+P_000101321*QR_000001021013); ans_temp[ans_id*36+35]+=Pmtrx[29]*(P_000001021*QR_000000022000+P_000001121*QR_000000022001+P_000001221*QR_000000022002+P_000001321*QR_000000022003+P_000101021*QR_000000022010+P_000101121*QR_000000022011+P_000101221*QR_000000022012+P_000101321*QR_000000022013); ans_temp[ans_id*36+30]+=Pmtrx[30]*(P_000000022*QR_022000000000+P_000000122*QR_022000000001+P_000000222*QR_022000000002+P_000000322*QR_022000000003+P_000000422*QR_022000000004); ans_temp[ans_id*36+30]+=Pmtrx[31]*(P_000000022*QR_021001000000+P_000000122*QR_021001000001+P_000000222*QR_021001000002+P_000000322*QR_021001000003+P_000000422*QR_021001000004); ans_temp[ans_id*36+30]+=Pmtrx[32]*(P_000000022*QR_020002000000+P_000000122*QR_020002000001+P_000000222*QR_020002000002+P_000000322*QR_020002000003+P_000000422*QR_020002000004); ans_temp[ans_id*36+30]+=Pmtrx[33]*(P_000000022*QR_021000001000+P_000000122*QR_021000001001+P_000000222*QR_021000001002+P_000000322*QR_021000001003+P_000000422*QR_021000001004); ans_temp[ans_id*36+30]+=Pmtrx[34]*(P_000000022*QR_020001001000+P_000000122*QR_020001001001+P_000000222*QR_020001001002+P_000000322*QR_020001001003+P_000000422*QR_020001001004); ans_temp[ans_id*36+30]+=Pmtrx[35]*(P_000000022*QR_020000002000+P_000000122*QR_020000002001+P_000000222*QR_020000002002+P_000000322*QR_020000002003+P_000000422*QR_020000002004); ans_temp[ans_id*36+31]+=Pmtrx[30]*(P_000000022*QR_012010000000+P_000000122*QR_012010000001+P_000000222*QR_012010000002+P_000000322*QR_012010000003+P_000000422*QR_012010000004); ans_temp[ans_id*36+31]+=Pmtrx[31]*(P_000000022*QR_011011000000+P_000000122*QR_011011000001+P_000000222*QR_011011000002+P_000000322*QR_011011000003+P_000000422*QR_011011000004); ans_temp[ans_id*36+31]+=Pmtrx[32]*(P_000000022*QR_010012000000+P_000000122*QR_010012000001+P_000000222*QR_010012000002+P_000000322*QR_010012000003+P_000000422*QR_010012000004); ans_temp[ans_id*36+31]+=Pmtrx[33]*(P_000000022*QR_011010001000+P_000000122*QR_011010001001+P_000000222*QR_011010001002+P_000000322*QR_011010001003+P_000000422*QR_011010001004); ans_temp[ans_id*36+31]+=Pmtrx[34]*(P_000000022*QR_010011001000+P_000000122*QR_010011001001+P_000000222*QR_010011001002+P_000000322*QR_010011001003+P_000000422*QR_010011001004); ans_temp[ans_id*36+31]+=Pmtrx[35]*(P_000000022*QR_010010002000+P_000000122*QR_010010002001+P_000000222*QR_010010002002+P_000000322*QR_010010002003+P_000000422*QR_010010002004); ans_temp[ans_id*36+32]+=Pmtrx[30]*(P_000000022*QR_002020000000+P_000000122*QR_002020000001+P_000000222*QR_002020000002+P_000000322*QR_002020000003+P_000000422*QR_002020000004); ans_temp[ans_id*36+32]+=Pmtrx[31]*(P_000000022*QR_001021000000+P_000000122*QR_001021000001+P_000000222*QR_001021000002+P_000000322*QR_001021000003+P_000000422*QR_001021000004); ans_temp[ans_id*36+32]+=Pmtrx[32]*(P_000000022*QR_000022000000+P_000000122*QR_000022000001+P_000000222*QR_000022000002+P_000000322*QR_000022000003+P_000000422*QR_000022000004); ans_temp[ans_id*36+32]+=Pmtrx[33]*(P_000000022*QR_001020001000+P_000000122*QR_001020001001+P_000000222*QR_001020001002+P_000000322*QR_001020001003+P_000000422*QR_001020001004); ans_temp[ans_id*36+32]+=Pmtrx[34]*(P_000000022*QR_000021001000+P_000000122*QR_000021001001+P_000000222*QR_000021001002+P_000000322*QR_000021001003+P_000000422*QR_000021001004); ans_temp[ans_id*36+32]+=Pmtrx[35]*(P_000000022*QR_000020002000+P_000000122*QR_000020002001+P_000000222*QR_000020002002+P_000000322*QR_000020002003+P_000000422*QR_000020002004); ans_temp[ans_id*36+33]+=Pmtrx[30]*(P_000000022*QR_012000010000+P_000000122*QR_012000010001+P_000000222*QR_012000010002+P_000000322*QR_012000010003+P_000000422*QR_012000010004); ans_temp[ans_id*36+33]+=Pmtrx[31]*(P_000000022*QR_011001010000+P_000000122*QR_011001010001+P_000000222*QR_011001010002+P_000000322*QR_011001010003+P_000000422*QR_011001010004); ans_temp[ans_id*36+33]+=Pmtrx[32]*(P_000000022*QR_010002010000+P_000000122*QR_010002010001+P_000000222*QR_010002010002+P_000000322*QR_010002010003+P_000000422*QR_010002010004); ans_temp[ans_id*36+33]+=Pmtrx[33]*(P_000000022*QR_011000011000+P_000000122*QR_011000011001+P_000000222*QR_011000011002+P_000000322*QR_011000011003+P_000000422*QR_011000011004); ans_temp[ans_id*36+33]+=Pmtrx[34]*(P_000000022*QR_010001011000+P_000000122*QR_010001011001+P_000000222*QR_010001011002+P_000000322*QR_010001011003+P_000000422*QR_010001011004); ans_temp[ans_id*36+33]+=Pmtrx[35]*(P_000000022*QR_010000012000+P_000000122*QR_010000012001+P_000000222*QR_010000012002+P_000000322*QR_010000012003+P_000000422*QR_010000012004); ans_temp[ans_id*36+34]+=Pmtrx[30]*(P_000000022*QR_002010010000+P_000000122*QR_002010010001+P_000000222*QR_002010010002+P_000000322*QR_002010010003+P_000000422*QR_002010010004); ans_temp[ans_id*36+34]+=Pmtrx[31]*(P_000000022*QR_001011010000+P_000000122*QR_001011010001+P_000000222*QR_001011010002+P_000000322*QR_001011010003+P_000000422*QR_001011010004); ans_temp[ans_id*36+34]+=Pmtrx[32]*(P_000000022*QR_000012010000+P_000000122*QR_000012010001+P_000000222*QR_000012010002+P_000000322*QR_000012010003+P_000000422*QR_000012010004); ans_temp[ans_id*36+34]+=Pmtrx[33]*(P_000000022*QR_001010011000+P_000000122*QR_001010011001+P_000000222*QR_001010011002+P_000000322*QR_001010011003+P_000000422*QR_001010011004); ans_temp[ans_id*36+34]+=Pmtrx[34]*(P_000000022*QR_000011011000+P_000000122*QR_000011011001+P_000000222*QR_000011011002+P_000000322*QR_000011011003+P_000000422*QR_000011011004); ans_temp[ans_id*36+34]+=Pmtrx[35]*(P_000000022*QR_000010012000+P_000000122*QR_000010012001+P_000000222*QR_000010012002+P_000000322*QR_000010012003+P_000000422*QR_000010012004); ans_temp[ans_id*36+35]+=Pmtrx[30]*(P_000000022*QR_002000020000+P_000000122*QR_002000020001+P_000000222*QR_002000020002+P_000000322*QR_002000020003+P_000000422*QR_002000020004); ans_temp[ans_id*36+35]+=Pmtrx[31]*(P_000000022*QR_001001020000+P_000000122*QR_001001020001+P_000000222*QR_001001020002+P_000000322*QR_001001020003+P_000000422*QR_001001020004); ans_temp[ans_id*36+35]+=Pmtrx[32]*(P_000000022*QR_000002020000+P_000000122*QR_000002020001+P_000000222*QR_000002020002+P_000000322*QR_000002020003+P_000000422*QR_000002020004); ans_temp[ans_id*36+35]+=Pmtrx[33]*(P_000000022*QR_001000021000+P_000000122*QR_001000021001+P_000000222*QR_001000021002+P_000000322*QR_001000021003+P_000000422*QR_001000021004); ans_temp[ans_id*36+35]+=Pmtrx[34]*(P_000000022*QR_000001021000+P_000000122*QR_000001021001+P_000000222*QR_000001021002+P_000000322*QR_000001021003+P_000000422*QR_000001021004); ans_temp[ans_id*36+35]+=Pmtrx[35]*(P_000000022*QR_000000022000+P_000000122*QR_000000022001+P_000000222*QR_000000022002+P_000000322*QR_000000022003+P_000000422*QR_000000022004); } } __syncthreads(); int num_thread=NTHREAD/2; while (num_thread!=0){ __syncthreads(); if(tId_x<num_thread){ for(int ians=0;ians<36;ians++){ ans_temp[tId_x*36+ians]+=ans_temp[(tId_x+num_thread)*36+ians]; } } num_thread/=2; } if(tId_x==0){ for(int ians=0;ians<36;ians++){ ans[(i_contrc_bra*contrc_ket_num+j_contrc_ket)*36+ians]=ans_temp[(tId_x)*36+ians]; } } } } }
576827912c940c65dfae63c93efcb8e6814ad42f.cu
#include<math.h> #include"Boys_gpu.h" #define PI 3.1415926535897932 #define P25 17.4934183276248620 #define NTHREAD 64 texture<int2,1,cudaReadModeElementType> tex_P; texture<int2,1,cudaReadModeElementType> tex_Zta; texture<int2,1,cudaReadModeElementType> tex_pp; texture<float,1,cudaReadModeElementType> tex_K2_p; texture<int2,1,cudaReadModeElementType> tex_PA; texture<int2,1,cudaReadModeElementType> tex_PB; texture<unsigned int,1,cudaReadModeElementType> tex_id_bra; texture<int2,1,cudaReadModeElementType> tex_Q; texture<int2,1,cudaReadModeElementType> tex_Eta; texture<int2,1,cudaReadModeElementType> tex_pq; texture<float,1,cudaReadModeElementType> tex_K2_q; texture<int2,1,cudaReadModeElementType> tex_QC; texture<int2,1,cudaReadModeElementType> tex_QD; texture<unsigned int,1,cudaReadModeElementType> tex_id_ket; void MD_texture_binding_bra_dd(double * P_d,double * PA_d,double * PB_d,\ double * alphaP_d,double * pp_d,float * K2_p_d,unsigned int * id_bra_d,\ unsigned int primit_len){ cudaBindTexture(0, tex_P, P_d, sizeof(double)*primit_len*3); cudaBindTexture(0, tex_Zta, alphaP_d, sizeof(double)*primit_len); cudaBindTexture(0, tex_pp, pp_d, sizeof(double)*primit_len); cudaBindTexture(0, tex_K2_p, K2_p_d, sizeof(float)*primit_len); cudaBindTexture(0, tex_PA, PA_d, sizeof(double)*primit_len*3); cudaBindTexture(0, tex_PB, PB_d, sizeof(double)*primit_len*3); cudaBindTexture(0, tex_id_bra, id_bra_d, sizeof(unsigned int)*primit_len); } void MD_texture_unbind_bra_dd(){ cudaUnbindTexture(tex_P); cudaUnbindTexture(tex_Zta); cudaUnbindTexture(tex_pp); cudaUnbindTexture(tex_K2_p); cudaUnbindTexture(tex_PA); cudaUnbindTexture(tex_PB); cudaUnbindTexture(tex_id_bra); } void MD_texture_binding_ket_dd(double * Q_d,double * QC_d,double * QD_d,\ double * alphaQ_d,double * pq_d,float * K2_q_d,unsigned int * id_ket_d,\ unsigned int primit_len){ cudaBindTexture(0, tex_Q, Q_d, sizeof(double)*primit_len*3); cudaBindTexture(0, tex_Eta, alphaQ_d, sizeof(double)*primit_len); cudaBindTexture(0, tex_pq, pq_d, sizeof(double)*primit_len); cudaBindTexture(0, tex_K2_q, K2_q_d, sizeof(float)*primit_len); cudaBindTexture(0, tex_QC, QC_d, sizeof(double)*primit_len*3); cudaBindTexture(0, tex_QD, QD_d, sizeof(double)*primit_len*3); cudaBindTexture(0, tex_id_ket, id_ket_d, sizeof(unsigned int)*primit_len); } void MD_texture_unbind_ket_dd(){ cudaUnbindTexture(tex_Q); cudaUnbindTexture(tex_Eta); cudaUnbindTexture(tex_pq); cudaUnbindTexture(tex_K2_q); cudaUnbindTexture(tex_QC); cudaUnbindTexture(tex_QD); cudaUnbindTexture(tex_id_ket); } __global__ void MD_Kp_dddd_fs(unsigned int contrc_bra_num,unsigned int contrc_ket_num,\ unsigned int * contrc_bra_id,\ unsigned int * contrc_ket_id,\ unsigned int mtrx_len,\ double * Pmtrx_in,\ double * P,\ double * PA,\ double * PB,\ double * Zta_in,\ double * pp_in,\ float * K2_p_in,\ unsigned int * id_bra_in,\ double * Q,\ double * QC,\ double * QD,\ double * Eta_in,\ double * pq_in,\ float * K2_q_in,\ unsigned int * id_ket_in,\ double * ans){ unsigned int tId_x = threadIdx.x; unsigned int bId_x = blockIdx.x; unsigned int bId_y = blockIdx.y; unsigned int tdis = blockDim.x; unsigned int bdis_x = gridDim.x; unsigned int bdis_y = gridDim.y; unsigned int ans_id=tId_x; double Pmtrx[36]={0.0}; __shared__ double ans_temp[NTHREAD*36]; for(int i=0;i<36;i++){ ans_temp[i*tdis+tId_x]=0.0; } for(unsigned int i_contrc_bra=bId_x;i_contrc_bra<contrc_bra_num;i_contrc_bra+=bdis_x){ for(unsigned int j_contrc_ket=bId_y;j_contrc_ket<contrc_ket_num;j_contrc_ket+=bdis_y){ unsigned int primit_bra_start = contrc_bra_id[i_contrc_bra ]; unsigned int primit_bra_end = contrc_bra_id[i_contrc_bra+1]; unsigned int primit_ket_start = contrc_ket_id[j_contrc_ket ]; unsigned int primit_ket_end = contrc_ket_id[j_contrc_ket+1]; if(i_contrc_bra>j_contrc_ket){ if(tId_x==0){ for(int ians=0;ians<36;ians++){ ans[(i_contrc_bra*contrc_ket_num+j_contrc_ket)*36+ians]=0.0; } } continue; } for(unsigned int ii=primit_ket_start;ii<primit_ket_end;ii++){ unsigned int id_ket=id_ket_in[ii]; double QX=Q[ii*3+0]; double QY=Q[ii*3+1]; double QZ=Q[ii*3+2]; double Qd_010[3]; Qd_010[0]=QC[ii*3+0]; Qd_010[1]=QC[ii*3+1]; Qd_010[2]=QC[ii*3+2]; double Qd_001[3]; Qd_001[0]=QD[ii*3+0]; Qd_001[1]=QD[ii*3+1]; Qd_001[2]=QD[ii*3+2]; double Eta=Eta_in[ii]; double pq=pq_in[ii]; float K2_q=K2_q_in[ii]; double aQin1=1/(2*Eta); for(unsigned int j=tId_x;j<primit_bra_end-primit_bra_start;j+=tdis){ unsigned int jj=primit_bra_start+j; unsigned int id_bra=tex1Dfetch(tex_id_bra,jj); double P_max=0.0; for(int p_j=0;p_j<6;p_j++){ for(int p_i=0;p_i<6;p_i++){ Pmtrx[p_i*6+p_j]=Pmtrx_in[(id_ket+p_j)*mtrx_len+(id_bra+p_i)]; double temp_P=fabsf(Pmtrx[p_i*6+p_j]); if(temp_P>P_max) P_max=temp_P; } } float K2_p=tex1Dfetch(tex_K2_p,jj); if(fabsf(K2_p*K2_q)<1.0E-14){ break; } if(fabsf(P_max*K2_p*K2_q)<1.0E-14) continue; int2 temp_int2; temp_int2=tex1Dfetch(tex_Zta,jj); double Zta=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_pp,jj); double pp=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_P,jj*3+0); double PX=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_P,jj*3+1); double PY=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_P,jj*3+2); double PZ=__hiloint2double(temp_int2.y,temp_int2.x); double Pd_010[3]; temp_int2=tex1Dfetch(tex_PA,jj*3+0); Pd_010[0]=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_PA,jj*3+1); Pd_010[1]=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_PA,jj*3+2); Pd_010[2]=__hiloint2double(temp_int2.y,temp_int2.x); double Pd_001[3]; temp_int2=tex1Dfetch(tex_PB,jj*3+0); Pd_001[0]=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_PB,jj*3+1); Pd_001[1]=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_PB,jj*3+2); Pd_001[2]=__hiloint2double(temp_int2.y,temp_int2.x); double alphaT=rsqrt(Eta+Zta); double lmd=2*P25*pp*pq*alphaT; alphaT=Eta*Zta*alphaT*alphaT; double TX=PX-QX; double TY=PY-QY; double TZ=PZ-QZ; double T=alphaT*(TX*TX+TY*TY+TZ*TZ); double R_000[9]; Ft_fs_8(8,T,R_000); R_000[0]*=lmd; R_000[1]*=-2*alphaT*lmd; R_000[2]*=4*alphaT*alphaT*lmd; R_000[3]*=-8*alphaT*alphaT*alphaT*lmd; R_000[4]*=16*alphaT*alphaT*alphaT*alphaT*lmd; R_000[5]*=-32*alphaT*alphaT*alphaT*alphaT*alphaT*lmd; R_000[6]*=64*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*lmd; R_000[7]*=-128*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*lmd; R_000[8]*=256*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*lmd; double aPin1=1/(2*Zta); double R_100[8]; double R_200[7]; double R_300[6]; double R_400[5]; double R_500[4]; double R_600[3]; double R_700[2]; double R_800[1]; double R_010[8]; double R_110[7]; double R_210[6]; double R_310[5]; double R_410[4]; double R_510[3]; double R_610[2]; double R_710[1]; double R_020[7]; double R_120[6]; double R_220[5]; double R_320[4]; double R_420[3]; double R_520[2]; double R_620[1]; double R_030[6]; double R_130[5]; double R_230[4]; double R_330[3]; double R_430[2]; double R_530[1]; double R_040[5]; double R_140[4]; double R_240[3]; double R_340[2]; double R_440[1]; double R_050[4]; double R_150[3]; double R_250[2]; double R_350[1]; double R_060[3]; double R_160[2]; double R_260[1]; double R_070[2]; double R_170[1]; double R_080[1]; double R_001[8]; double R_101[7]; double R_201[6]; double R_301[5]; double R_401[4]; double R_501[3]; double R_601[2]; double R_701[1]; double R_011[7]; double R_111[6]; double R_211[5]; double R_311[4]; double R_411[3]; double R_511[2]; double R_611[1]; double R_021[6]; double R_121[5]; double R_221[4]; double R_321[3]; double R_421[2]; double R_521[1]; double R_031[5]; double R_131[4]; double R_231[3]; double R_331[2]; double R_431[1]; double R_041[4]; double R_141[3]; double R_241[2]; double R_341[1]; double R_051[3]; double R_151[2]; double R_251[1]; double R_061[2]; double R_161[1]; double R_071[1]; double R_002[7]; double R_102[6]; double R_202[5]; double R_302[4]; double R_402[3]; double R_502[2]; double R_602[1]; double R_012[6]; double R_112[5]; double R_212[4]; double R_312[3]; double R_412[2]; double R_512[1]; double R_022[5]; double R_122[4]; double R_222[3]; double R_322[2]; double R_422[1]; double R_032[4]; double R_132[3]; double R_232[2]; double R_332[1]; double R_042[3]; double R_142[2]; double R_242[1]; double R_052[2]; double R_152[1]; double R_062[1]; double R_003[6]; double R_103[5]; double R_203[4]; double R_303[3]; double R_403[2]; double R_503[1]; double R_013[5]; double R_113[4]; double R_213[3]; double R_313[2]; double R_413[1]; double R_023[4]; double R_123[3]; double R_223[2]; double R_323[1]; double R_033[3]; double R_133[2]; double R_233[1]; double R_043[2]; double R_143[1]; double R_053[1]; double R_004[5]; double R_104[4]; double R_204[3]; double R_304[2]; double R_404[1]; double R_014[4]; double R_114[3]; double R_214[2]; double R_314[1]; double R_024[3]; double R_124[2]; double R_224[1]; double R_034[2]; double R_134[1]; double R_044[1]; double R_005[4]; double R_105[3]; double R_205[2]; double R_305[1]; double R_015[3]; double R_115[2]; double R_215[1]; double R_025[2]; double R_125[1]; double R_035[1]; double R_006[3]; double R_106[2]; double R_206[1]; double R_016[2]; double R_116[1]; double R_026[1]; double R_007[2]; double R_107[1]; double R_017[1]; double R_008[1]; for(int i=0;i<8;i++){ R_100[i]=TX*R_000[i+1]; } for(int i=0;i<8;i++){ R_010[i]=TY*R_000[i+1]; } for(int i=0;i<8;i++){ R_001[i]=TZ*R_000[i+1]; } for(int i=0;i<7;i++){ R_200[i]=TX*R_100[i+1]+R_000[i+1]; } for(int i=0;i<7;i++){ R_110[i]=TX*R_010[i+1]; } for(int i=0;i<7;i++){ R_020[i]=TY*R_010[i+1]+R_000[i+1]; } for(int i=0;i<7;i++){ R_101[i]=TX*R_001[i+1]; } for(int i=0;i<7;i++){ R_011[i]=TY*R_001[i+1]; } for(int i=0;i<7;i++){ R_002[i]=TZ*R_001[i+1]+R_000[i+1]; } for(int i=0;i<6;i++){ R_300[i]=TX*R_200[i+1]+2*R_100[i+1]; } for(int i=0;i<6;i++){ R_210[i]=TY*R_200[i+1]; } for(int i=0;i<6;i++){ R_120[i]=TX*R_020[i+1]; } for(int i=0;i<6;i++){ R_030[i]=TY*R_020[i+1]+2*R_010[i+1]; } for(int i=0;i<6;i++){ R_201[i]=TZ*R_200[i+1]; } for(int i=0;i<6;i++){ R_111[i]=TX*R_011[i+1]; } for(int i=0;i<6;i++){ R_021[i]=TZ*R_020[i+1]; } for(int i=0;i<6;i++){ R_102[i]=TX*R_002[i+1]; } for(int i=0;i<6;i++){ R_012[i]=TY*R_002[i+1]; } for(int i=0;i<6;i++){ R_003[i]=TZ*R_002[i+1]+2*R_001[i+1]; } for(int i=0;i<5;i++){ R_400[i]=TX*R_300[i+1]+3*R_200[i+1]; } for(int i=0;i<5;i++){ R_310[i]=TY*R_300[i+1]; } for(int i=0;i<5;i++){ R_220[i]=TX*R_120[i+1]+R_020[i+1]; } for(int i=0;i<5;i++){ R_130[i]=TX*R_030[i+1]; } for(int i=0;i<5;i++){ R_040[i]=TY*R_030[i+1]+3*R_020[i+1]; } for(int i=0;i<5;i++){ R_301[i]=TZ*R_300[i+1]; } for(int i=0;i<5;i++){ R_211[i]=TY*R_201[i+1]; } for(int i=0;i<5;i++){ R_121[i]=TX*R_021[i+1]; } for(int i=0;i<5;i++){ R_031[i]=TZ*R_030[i+1]; } for(int i=0;i<5;i++){ R_202[i]=TX*R_102[i+1]+R_002[i+1]; } for(int i=0;i<5;i++){ R_112[i]=TX*R_012[i+1]; } for(int i=0;i<5;i++){ R_022[i]=TY*R_012[i+1]+R_002[i+1]; } for(int i=0;i<5;i++){ R_103[i]=TX*R_003[i+1]; } for(int i=0;i<5;i++){ R_013[i]=TY*R_003[i+1]; } for(int i=0;i<5;i++){ R_004[i]=TZ*R_003[i+1]+3*R_002[i+1]; } for(int i=0;i<4;i++){ R_500[i]=TX*R_400[i+1]+4*R_300[i+1]; } for(int i=0;i<4;i++){ R_410[i]=TY*R_400[i+1]; } for(int i=0;i<4;i++){ R_320[i]=TX*R_220[i+1]+2*R_120[i+1]; } for(int i=0;i<4;i++){ R_230[i]=TY*R_220[i+1]+2*R_210[i+1]; } for(int i=0;i<4;i++){ R_140[i]=TX*R_040[i+1]; } for(int i=0;i<4;i++){ R_050[i]=TY*R_040[i+1]+4*R_030[i+1]; } for(int i=0;i<4;i++){ R_401[i]=TZ*R_400[i+1]; } for(int i=0;i<4;i++){ R_311[i]=TY*R_301[i+1]; } for(int i=0;i<4;i++){ R_221[i]=TZ*R_220[i+1]; } for(int i=0;i<4;i++){ R_131[i]=TX*R_031[i+1]; } for(int i=0;i<4;i++){ R_041[i]=TZ*R_040[i+1]; } for(int i=0;i<4;i++){ R_302[i]=TX*R_202[i+1]+2*R_102[i+1]; } for(int i=0;i<4;i++){ R_212[i]=TY*R_202[i+1]; } for(int i=0;i<4;i++){ R_122[i]=TX*R_022[i+1]; } for(int i=0;i<4;i++){ R_032[i]=TY*R_022[i+1]+2*R_012[i+1]; } for(int i=0;i<4;i++){ R_203[i]=TZ*R_202[i+1]+2*R_201[i+1]; } for(int i=0;i<4;i++){ R_113[i]=TX*R_013[i+1]; } for(int i=0;i<4;i++){ R_023[i]=TZ*R_022[i+1]+2*R_021[i+1]; } for(int i=0;i<4;i++){ R_104[i]=TX*R_004[i+1]; } for(int i=0;i<4;i++){ R_014[i]=TY*R_004[i+1]; } for(int i=0;i<4;i++){ R_005[i]=TZ*R_004[i+1]+4*R_003[i+1]; } for(int i=0;i<3;i++){ R_600[i]=TX*R_500[i+1]+5*R_400[i+1]; } for(int i=0;i<3;i++){ R_510[i]=TY*R_500[i+1]; } for(int i=0;i<3;i++){ R_420[i]=TX*R_320[i+1]+3*R_220[i+1]; } for(int i=0;i<3;i++){ R_330[i]=TX*R_230[i+1]+2*R_130[i+1]; } for(int i=0;i<3;i++){ R_240[i]=TY*R_230[i+1]+3*R_220[i+1]; } for(int i=0;i<3;i++){ R_150[i]=TX*R_050[i+1]; } for(int i=0;i<3;i++){ R_060[i]=TY*R_050[i+1]+5*R_040[i+1]; } for(int i=0;i<3;i++){ R_501[i]=TZ*R_500[i+1]; } for(int i=0;i<3;i++){ R_411[i]=TY*R_401[i+1]; } for(int i=0;i<3;i++){ R_321[i]=TZ*R_320[i+1]; } for(int i=0;i<3;i++){ R_231[i]=TZ*R_230[i+1]; } for(int i=0;i<3;i++){ R_141[i]=TX*R_041[i+1]; } for(int i=0;i<3;i++){ R_051[i]=TZ*R_050[i+1]; } for(int i=0;i<3;i++){ R_402[i]=TX*R_302[i+1]+3*R_202[i+1]; } for(int i=0;i<3;i++){ R_312[i]=TY*R_302[i+1]; } for(int i=0;i<3;i++){ R_222[i]=TX*R_122[i+1]+R_022[i+1]; } for(int i=0;i<3;i++){ R_132[i]=TX*R_032[i+1]; } for(int i=0;i<3;i++){ R_042[i]=TY*R_032[i+1]+3*R_022[i+1]; } for(int i=0;i<3;i++){ R_303[i]=TX*R_203[i+1]+2*R_103[i+1]; } for(int i=0;i<3;i++){ R_213[i]=TY*R_203[i+1]; } for(int i=0;i<3;i++){ R_123[i]=TX*R_023[i+1]; } for(int i=0;i<3;i++){ R_033[i]=TY*R_023[i+1]+2*R_013[i+1]; } for(int i=0;i<3;i++){ R_204[i]=TZ*R_203[i+1]+3*R_202[i+1]; } for(int i=0;i<3;i++){ R_114[i]=TX*R_014[i+1]; } for(int i=0;i<3;i++){ R_024[i]=TZ*R_023[i+1]+3*R_022[i+1]; } for(int i=0;i<3;i++){ R_105[i]=TX*R_005[i+1]; } for(int i=0;i<3;i++){ R_015[i]=TY*R_005[i+1]; } for(int i=0;i<3;i++){ R_006[i]=TZ*R_005[i+1]+5*R_004[i+1]; } for(int i=0;i<2;i++){ R_700[i]=TX*R_600[i+1]+6*R_500[i+1]; } for(int i=0;i<2;i++){ R_610[i]=TY*R_600[i+1]; } for(int i=0;i<2;i++){ R_520[i]=TX*R_420[i+1]+4*R_320[i+1]; } for(int i=0;i<2;i++){ R_430[i]=TX*R_330[i+1]+3*R_230[i+1]; } for(int i=0;i<2;i++){ R_340[i]=TY*R_330[i+1]+3*R_320[i+1]; } for(int i=0;i<2;i++){ R_250[i]=TY*R_240[i+1]+4*R_230[i+1]; } for(int i=0;i<2;i++){ R_160[i]=TX*R_060[i+1]; } for(int i=0;i<2;i++){ R_070[i]=TY*R_060[i+1]+6*R_050[i+1]; } for(int i=0;i<2;i++){ R_601[i]=TZ*R_600[i+1]; } for(int i=0;i<2;i++){ R_511[i]=TY*R_501[i+1]; } for(int i=0;i<2;i++){ R_421[i]=TZ*R_420[i+1]; } for(int i=0;i<2;i++){ R_331[i]=TZ*R_330[i+1]; } for(int i=0;i<2;i++){ R_241[i]=TZ*R_240[i+1]; } for(int i=0;i<2;i++){ R_151[i]=TX*R_051[i+1]; } for(int i=0;i<2;i++){ R_061[i]=TZ*R_060[i+1]; } for(int i=0;i<2;i++){ R_502[i]=TX*R_402[i+1]+4*R_302[i+1]; } for(int i=0;i<2;i++){ R_412[i]=TY*R_402[i+1]; } for(int i=0;i<2;i++){ R_322[i]=TX*R_222[i+1]+2*R_122[i+1]; } for(int i=0;i<2;i++){ R_232[i]=TY*R_222[i+1]+2*R_212[i+1]; } for(int i=0;i<2;i++){ R_142[i]=TX*R_042[i+1]; } for(int i=0;i<2;i++){ R_052[i]=TY*R_042[i+1]+4*R_032[i+1]; } for(int i=0;i<2;i++){ R_403[i]=TX*R_303[i+1]+3*R_203[i+1]; } for(int i=0;i<2;i++){ R_313[i]=TY*R_303[i+1]; } for(int i=0;i<2;i++){ R_223[i]=TZ*R_222[i+1]+2*R_221[i+1]; } for(int i=0;i<2;i++){ R_133[i]=TX*R_033[i+1]; } for(int i=0;i<2;i++){ R_043[i]=TY*R_033[i+1]+3*R_023[i+1]; } for(int i=0;i<2;i++){ R_304[i]=TZ*R_303[i+1]+3*R_302[i+1]; } for(int i=0;i<2;i++){ R_214[i]=TY*R_204[i+1]; } for(int i=0;i<2;i++){ R_124[i]=TX*R_024[i+1]; } for(int i=0;i<2;i++){ R_034[i]=TZ*R_033[i+1]+3*R_032[i+1]; } for(int i=0;i<2;i++){ R_205[i]=TZ*R_204[i+1]+4*R_203[i+1]; } for(int i=0;i<2;i++){ R_115[i]=TX*R_015[i+1]; } for(int i=0;i<2;i++){ R_025[i]=TZ*R_024[i+1]+4*R_023[i+1]; } for(int i=0;i<2;i++){ R_106[i]=TX*R_006[i+1]; } for(int i=0;i<2;i++){ R_016[i]=TY*R_006[i+1]; } for(int i=0;i<2;i++){ R_007[i]=TZ*R_006[i+1]+6*R_005[i+1]; } for(int i=0;i<1;i++){ R_800[i]=TX*R_700[i+1]+7*R_600[i+1]; } for(int i=0;i<1;i++){ R_710[i]=TY*R_700[i+1]; } for(int i=0;i<1;i++){ R_620[i]=TX*R_520[i+1]+5*R_420[i+1]; } for(int i=0;i<1;i++){ R_530[i]=TX*R_430[i+1]+4*R_330[i+1]; } for(int i=0;i<1;i++){ R_440[i]=TX*R_340[i+1]+3*R_240[i+1]; } for(int i=0;i<1;i++){ R_350[i]=TY*R_340[i+1]+4*R_330[i+1]; } for(int i=0;i<1;i++){ R_260[i]=TY*R_250[i+1]+5*R_240[i+1]; } for(int i=0;i<1;i++){ R_170[i]=TX*R_070[i+1]; } for(int i=0;i<1;i++){ R_080[i]=TY*R_070[i+1]+7*R_060[i+1]; } for(int i=0;i<1;i++){ R_701[i]=TZ*R_700[i+1]; } for(int i=0;i<1;i++){ R_611[i]=TY*R_601[i+1]; } for(int i=0;i<1;i++){ R_521[i]=TZ*R_520[i+1]; } for(int i=0;i<1;i++){ R_431[i]=TZ*R_430[i+1]; } for(int i=0;i<1;i++){ R_341[i]=TZ*R_340[i+1]; } for(int i=0;i<1;i++){ R_251[i]=TZ*R_250[i+1]; } for(int i=0;i<1;i++){ R_161[i]=TX*R_061[i+1]; } for(int i=0;i<1;i++){ R_071[i]=TZ*R_070[i+1]; } for(int i=0;i<1;i++){ R_602[i]=TX*R_502[i+1]+5*R_402[i+1]; } for(int i=0;i<1;i++){ R_512[i]=TY*R_502[i+1]; } for(int i=0;i<1;i++){ R_422[i]=TX*R_322[i+1]+3*R_222[i+1]; } for(int i=0;i<1;i++){ R_332[i]=TX*R_232[i+1]+2*R_132[i+1]; } for(int i=0;i<1;i++){ R_242[i]=TY*R_232[i+1]+3*R_222[i+1]; } for(int i=0;i<1;i++){ R_152[i]=TX*R_052[i+1]; } for(int i=0;i<1;i++){ R_062[i]=TY*R_052[i+1]+5*R_042[i+1]; } for(int i=0;i<1;i++){ R_503[i]=TX*R_403[i+1]+4*R_303[i+1]; } for(int i=0;i<1;i++){ R_413[i]=TY*R_403[i+1]; } for(int i=0;i<1;i++){ R_323[i]=TX*R_223[i+1]+2*R_123[i+1]; } for(int i=0;i<1;i++){ R_233[i]=TY*R_223[i+1]+2*R_213[i+1]; } for(int i=0;i<1;i++){ R_143[i]=TX*R_043[i+1]; } for(int i=0;i<1;i++){ R_053[i]=TY*R_043[i+1]+4*R_033[i+1]; } for(int i=0;i<1;i++){ R_404[i]=TX*R_304[i+1]+3*R_204[i+1]; } for(int i=0;i<1;i++){ R_314[i]=TY*R_304[i+1]; } for(int i=0;i<1;i++){ R_224[i]=TZ*R_223[i+1]+3*R_222[i+1]; } for(int i=0;i<1;i++){ R_134[i]=TX*R_034[i+1]; } for(int i=0;i<1;i++){ R_044[i]=TY*R_034[i+1]+3*R_024[i+1]; } for(int i=0;i<1;i++){ R_305[i]=TZ*R_304[i+1]+4*R_303[i+1]; } for(int i=0;i<1;i++){ R_215[i]=TY*R_205[i+1]; } for(int i=0;i<1;i++){ R_125[i]=TX*R_025[i+1]; } for(int i=0;i<1;i++){ R_035[i]=TZ*R_034[i+1]+4*R_033[i+1]; } for(int i=0;i<1;i++){ R_206[i]=TZ*R_205[i+1]+5*R_204[i+1]; } for(int i=0;i<1;i++){ R_116[i]=TX*R_016[i+1]; } for(int i=0;i<1;i++){ R_026[i]=TZ*R_025[i+1]+5*R_024[i+1]; } for(int i=0;i<1;i++){ R_107[i]=TX*R_007[i+1]; } for(int i=0;i<1;i++){ R_017[i]=TY*R_007[i+1]; } for(int i=0;i<1;i++){ R_008[i]=TZ*R_007[i+1]+7*R_006[i+1]; } double Pd_101[3]; double Pd_002[3]; double Pd_102[3]; double Pd_202[3]; double Pd_110[3]; double Pd_011[3]; double Pd_111[3]; double Pd_211[3]; double Pd_012[3]; double Pd_112[3]; double Pd_212[3]; double Pd_312[3]; double Pd_020[3]; double Pd_120[3]; double Pd_220[3]; double Pd_021[3]; double Pd_121[3]; double Pd_221[3]; double Pd_321[3]; double Pd_022[3]; double Pd_122[3]; double Pd_222[3]; double Pd_322[3]; double Pd_422[3]; for(int i=0;i<3;i++){ Pd_101[i]=aPin1; } for(int i=0;i<3;i++){ Pd_002[i]=Pd_101[i]+Pd_001[i]*Pd_001[i]; } for(int i=0;i<3;i++){ Pd_102[i]=Pd_001[i]*Pd_101[i]+aPin1*Pd_001[i]; } for(int i=0;i<3;i++){ Pd_202[i]=aPin1*Pd_101[i]; } for(int i=0;i<3;i++){ Pd_110[i]=aPin1; } for(int i=0;i<3;i++){ Pd_011[i]=Pd_101[i]+Pd_010[i]*Pd_001[i]; } for(int i=0;i<3;i++){ Pd_111[i]=Pd_010[i]*Pd_101[i]+aPin1*Pd_001[i]; } for(int i=0;i<3;i++){ Pd_211[i]=aPin1*Pd_101[i]; } for(int i=0;i<3;i++){ Pd_012[i]=Pd_111[i]+Pd_001[i]*Pd_011[i]; } for(int i=0;i<3;i++){ Pd_112[i]=2*Pd_211[i]+Pd_001[i]*Pd_111[i]+aPin1*Pd_011[i]; } for(int i=0;i<3;i++){ Pd_212[i]=Pd_001[i]*Pd_211[i]+aPin1*Pd_111[i]; } for(int i=0;i<3;i++){ Pd_312[i]=aPin1*Pd_211[i]; } for(int i=0;i<3;i++){ Pd_020[i]=Pd_110[i]+Pd_010[i]*Pd_010[i]; } for(int i=0;i<3;i++){ Pd_120[i]=Pd_010[i]*Pd_110[i]+aPin1*Pd_010[i]; } for(int i=0;i<3;i++){ Pd_220[i]=aPin1*Pd_110[i]; } for(int i=0;i<3;i++){ Pd_021[i]=Pd_111[i]+Pd_010[i]*Pd_011[i]; } for(int i=0;i<3;i++){ Pd_121[i]=2*Pd_211[i]+Pd_010[i]*Pd_111[i]+aPin1*Pd_011[i]; } for(int i=0;i<3;i++){ Pd_221[i]=Pd_010[i]*Pd_211[i]+aPin1*Pd_111[i]; } for(int i=0;i<3;i++){ Pd_321[i]=aPin1*Pd_211[i]; } for(int i=0;i<3;i++){ Pd_022[i]=Pd_112[i]+Pd_010[i]*Pd_012[i]; } for(int i=0;i<3;i++){ Pd_122[i]=2*Pd_212[i]+Pd_010[i]*Pd_112[i]+aPin1*Pd_012[i]; } for(int i=0;i<3;i++){ Pd_222[i]=3*Pd_312[i]+Pd_010[i]*Pd_212[i]+aPin1*Pd_112[i]; } for(int i=0;i<3;i++){ Pd_322[i]=Pd_010[i]*Pd_312[i]+aPin1*Pd_212[i]; } for(int i=0;i<3;i++){ Pd_422[i]=aPin1*Pd_312[i]; } double P_022000000=Pd_022[0]; double P_122000000=Pd_122[0]; double P_222000000=Pd_222[0]; double P_322000000=Pd_322[0]; double P_422000000=Pd_422[0]; double P_021001000=Pd_021[0]*Pd_001[1]; double P_021101000=Pd_021[0]*Pd_101[1]; double P_121001000=Pd_121[0]*Pd_001[1]; double P_121101000=Pd_121[0]*Pd_101[1]; double P_221001000=Pd_221[0]*Pd_001[1]; double P_221101000=Pd_221[0]*Pd_101[1]; double P_321001000=Pd_321[0]*Pd_001[1]; double P_321101000=Pd_321[0]*Pd_101[1]; double P_020002000=Pd_020[0]*Pd_002[1]; double P_020102000=Pd_020[0]*Pd_102[1]; double P_020202000=Pd_020[0]*Pd_202[1]; double P_120002000=Pd_120[0]*Pd_002[1]; double P_120102000=Pd_120[0]*Pd_102[1]; double P_120202000=Pd_120[0]*Pd_202[1]; double P_220002000=Pd_220[0]*Pd_002[1]; double P_220102000=Pd_220[0]*Pd_102[1]; double P_220202000=Pd_220[0]*Pd_202[1]; double P_021000001=Pd_021[0]*Pd_001[2]; double P_021000101=Pd_021[0]*Pd_101[2]; double P_121000001=Pd_121[0]*Pd_001[2]; double P_121000101=Pd_121[0]*Pd_101[2]; double P_221000001=Pd_221[0]*Pd_001[2]; double P_221000101=Pd_221[0]*Pd_101[2]; double P_321000001=Pd_321[0]*Pd_001[2]; double P_321000101=Pd_321[0]*Pd_101[2]; double P_020001001=Pd_020[0]*Pd_001[1]*Pd_001[2]; double P_020001101=Pd_020[0]*Pd_001[1]*Pd_101[2]; double P_020101001=Pd_020[0]*Pd_101[1]*Pd_001[2]; double P_020101101=Pd_020[0]*Pd_101[1]*Pd_101[2]; double P_120001001=Pd_120[0]*Pd_001[1]*Pd_001[2]; double P_120001101=Pd_120[0]*Pd_001[1]*Pd_101[2]; double P_120101001=Pd_120[0]*Pd_101[1]*Pd_001[2]; double P_120101101=Pd_120[0]*Pd_101[1]*Pd_101[2]; double P_220001001=Pd_220[0]*Pd_001[1]*Pd_001[2]; double P_220001101=Pd_220[0]*Pd_001[1]*Pd_101[2]; double P_220101001=Pd_220[0]*Pd_101[1]*Pd_001[2]; double P_220101101=Pd_220[0]*Pd_101[1]*Pd_101[2]; double P_020000002=Pd_020[0]*Pd_002[2]; double P_020000102=Pd_020[0]*Pd_102[2]; double P_020000202=Pd_020[0]*Pd_202[2]; double P_120000002=Pd_120[0]*Pd_002[2]; double P_120000102=Pd_120[0]*Pd_102[2]; double P_120000202=Pd_120[0]*Pd_202[2]; double P_220000002=Pd_220[0]*Pd_002[2]; double P_220000102=Pd_220[0]*Pd_102[2]; double P_220000202=Pd_220[0]*Pd_202[2]; double P_012010000=Pd_012[0]*Pd_010[1]; double P_012110000=Pd_012[0]*Pd_110[1]; double P_112010000=Pd_112[0]*Pd_010[1]; double P_112110000=Pd_112[0]*Pd_110[1]; double P_212010000=Pd_212[0]*Pd_010[1]; double P_212110000=Pd_212[0]*Pd_110[1]; double P_312010000=Pd_312[0]*Pd_010[1]; double P_312110000=Pd_312[0]*Pd_110[1]; double P_011011000=Pd_011[0]*Pd_011[1]; double P_011111000=Pd_011[0]*Pd_111[1]; double P_011211000=Pd_011[0]*Pd_211[1]; double P_111011000=Pd_111[0]*Pd_011[1]; double P_111111000=Pd_111[0]*Pd_111[1]; double P_111211000=Pd_111[0]*Pd_211[1]; double P_211011000=Pd_211[0]*Pd_011[1]; double P_211111000=Pd_211[0]*Pd_111[1]; double P_211211000=Pd_211[0]*Pd_211[1]; double P_010012000=Pd_010[0]*Pd_012[1]; double P_010112000=Pd_010[0]*Pd_112[1]; double P_010212000=Pd_010[0]*Pd_212[1]; double P_010312000=Pd_010[0]*Pd_312[1]; double P_110012000=Pd_110[0]*Pd_012[1]; double P_110112000=Pd_110[0]*Pd_112[1]; double P_110212000=Pd_110[0]*Pd_212[1]; double P_110312000=Pd_110[0]*Pd_312[1]; double P_011010001=Pd_011[0]*Pd_010[1]*Pd_001[2]; double P_011010101=Pd_011[0]*Pd_010[1]*Pd_101[2]; double P_011110001=Pd_011[0]*Pd_110[1]*Pd_001[2]; double P_011110101=Pd_011[0]*Pd_110[1]*Pd_101[2]; double P_111010001=Pd_111[0]*Pd_010[1]*Pd_001[2]; double P_111010101=Pd_111[0]*Pd_010[1]*Pd_101[2]; double P_111110001=Pd_111[0]*Pd_110[1]*Pd_001[2]; double P_111110101=Pd_111[0]*Pd_110[1]*Pd_101[2]; double P_211010001=Pd_211[0]*Pd_010[1]*Pd_001[2]; double P_211010101=Pd_211[0]*Pd_010[1]*Pd_101[2]; double P_211110001=Pd_211[0]*Pd_110[1]*Pd_001[2]; double P_211110101=Pd_211[0]*Pd_110[1]*Pd_101[2]; double P_010011001=Pd_010[0]*Pd_011[1]*Pd_001[2]; double P_010011101=Pd_010[0]*Pd_011[1]*Pd_101[2]; double P_010111001=Pd_010[0]*Pd_111[1]*Pd_001[2]; double P_010111101=Pd_010[0]*Pd_111[1]*Pd_101[2]; double P_010211001=Pd_010[0]*Pd_211[1]*Pd_001[2]; double P_010211101=Pd_010[0]*Pd_211[1]*Pd_101[2]; double P_110011001=Pd_110[0]*Pd_011[1]*Pd_001[2]; double P_110011101=Pd_110[0]*Pd_011[1]*Pd_101[2]; double P_110111001=Pd_110[0]*Pd_111[1]*Pd_001[2]; double P_110111101=Pd_110[0]*Pd_111[1]*Pd_101[2]; double P_110211001=Pd_110[0]*Pd_211[1]*Pd_001[2]; double P_110211101=Pd_110[0]*Pd_211[1]*Pd_101[2]; double P_010010002=Pd_010[0]*Pd_010[1]*Pd_002[2]; double P_010010102=Pd_010[0]*Pd_010[1]*Pd_102[2]; double P_010010202=Pd_010[0]*Pd_010[1]*Pd_202[2]; double P_010110002=Pd_010[0]*Pd_110[1]*Pd_002[2]; double P_010110102=Pd_010[0]*Pd_110[1]*Pd_102[2]; double P_010110202=Pd_010[0]*Pd_110[1]*Pd_202[2]; double P_110010002=Pd_110[0]*Pd_010[1]*Pd_002[2]; double P_110010102=Pd_110[0]*Pd_010[1]*Pd_102[2]; double P_110010202=Pd_110[0]*Pd_010[1]*Pd_202[2]; double P_110110002=Pd_110[0]*Pd_110[1]*Pd_002[2]; double P_110110102=Pd_110[0]*Pd_110[1]*Pd_102[2]; double P_110110202=Pd_110[0]*Pd_110[1]*Pd_202[2]; double P_002020000=Pd_002[0]*Pd_020[1]; double P_002120000=Pd_002[0]*Pd_120[1]; double P_002220000=Pd_002[0]*Pd_220[1]; double P_102020000=Pd_102[0]*Pd_020[1]; double P_102120000=Pd_102[0]*Pd_120[1]; double P_102220000=Pd_102[0]*Pd_220[1]; double P_202020000=Pd_202[0]*Pd_020[1]; double P_202120000=Pd_202[0]*Pd_120[1]; double P_202220000=Pd_202[0]*Pd_220[1]; double P_001021000=Pd_001[0]*Pd_021[1]; double P_001121000=Pd_001[0]*Pd_121[1]; double P_001221000=Pd_001[0]*Pd_221[1]; double P_001321000=Pd_001[0]*Pd_321[1]; double P_101021000=Pd_101[0]*Pd_021[1]; double P_101121000=Pd_101[0]*Pd_121[1]; double P_101221000=Pd_101[0]*Pd_221[1]; double P_101321000=Pd_101[0]*Pd_321[1]; double P_000022000=Pd_022[1]; double P_000122000=Pd_122[1]; double P_000222000=Pd_222[1]; double P_000322000=Pd_322[1]; double P_000422000=Pd_422[1]; double P_001020001=Pd_001[0]*Pd_020[1]*Pd_001[2]; double P_001020101=Pd_001[0]*Pd_020[1]*Pd_101[2]; double P_001120001=Pd_001[0]*Pd_120[1]*Pd_001[2]; double P_001120101=Pd_001[0]*Pd_120[1]*Pd_101[2]; double P_001220001=Pd_001[0]*Pd_220[1]*Pd_001[2]; double P_001220101=Pd_001[0]*Pd_220[1]*Pd_101[2]; double P_101020001=Pd_101[0]*Pd_020[1]*Pd_001[2]; double P_101020101=Pd_101[0]*Pd_020[1]*Pd_101[2]; double P_101120001=Pd_101[0]*Pd_120[1]*Pd_001[2]; double P_101120101=Pd_101[0]*Pd_120[1]*Pd_101[2]; double P_101220001=Pd_101[0]*Pd_220[1]*Pd_001[2]; double P_101220101=Pd_101[0]*Pd_220[1]*Pd_101[2]; double P_000021001=Pd_021[1]*Pd_001[2]; double P_000021101=Pd_021[1]*Pd_101[2]; double P_000121001=Pd_121[1]*Pd_001[2]; double P_000121101=Pd_121[1]*Pd_101[2]; double P_000221001=Pd_221[1]*Pd_001[2]; double P_000221101=Pd_221[1]*Pd_101[2]; double P_000321001=Pd_321[1]*Pd_001[2]; double P_000321101=Pd_321[1]*Pd_101[2]; double P_000020002=Pd_020[1]*Pd_002[2]; double P_000020102=Pd_020[1]*Pd_102[2]; double P_000020202=Pd_020[1]*Pd_202[2]; double P_000120002=Pd_120[1]*Pd_002[2]; double P_000120102=Pd_120[1]*Pd_102[2]; double P_000120202=Pd_120[1]*Pd_202[2]; double P_000220002=Pd_220[1]*Pd_002[2]; double P_000220102=Pd_220[1]*Pd_102[2]; double P_000220202=Pd_220[1]*Pd_202[2]; double P_012000010=Pd_012[0]*Pd_010[2]; double P_012000110=Pd_012[0]*Pd_110[2]; double P_112000010=Pd_112[0]*Pd_010[2]; double P_112000110=Pd_112[0]*Pd_110[2]; double P_212000010=Pd_212[0]*Pd_010[2]; double P_212000110=Pd_212[0]*Pd_110[2]; double P_312000010=Pd_312[0]*Pd_010[2]; double P_312000110=Pd_312[0]*Pd_110[2]; double P_011001010=Pd_011[0]*Pd_001[1]*Pd_010[2]; double P_011001110=Pd_011[0]*Pd_001[1]*Pd_110[2]; double P_011101010=Pd_011[0]*Pd_101[1]*Pd_010[2]; double P_011101110=Pd_011[0]*Pd_101[1]*Pd_110[2]; double P_111001010=Pd_111[0]*Pd_001[1]*Pd_010[2]; double P_111001110=Pd_111[0]*Pd_001[1]*Pd_110[2]; double P_111101010=Pd_111[0]*Pd_101[1]*Pd_010[2]; double P_111101110=Pd_111[0]*Pd_101[1]*Pd_110[2]; double P_211001010=Pd_211[0]*Pd_001[1]*Pd_010[2]; double P_211001110=Pd_211[0]*Pd_001[1]*Pd_110[2]; double P_211101010=Pd_211[0]*Pd_101[1]*Pd_010[2]; double P_211101110=Pd_211[0]*Pd_101[1]*Pd_110[2]; double P_010002010=Pd_010[0]*Pd_002[1]*Pd_010[2]; double P_010002110=Pd_010[0]*Pd_002[1]*Pd_110[2]; double P_010102010=Pd_010[0]*Pd_102[1]*Pd_010[2]; double P_010102110=Pd_010[0]*Pd_102[1]*Pd_110[2]; double P_010202010=Pd_010[0]*Pd_202[1]*Pd_010[2]; double P_010202110=Pd_010[0]*Pd_202[1]*Pd_110[2]; double P_110002010=Pd_110[0]*Pd_002[1]*Pd_010[2]; double P_110002110=Pd_110[0]*Pd_002[1]*Pd_110[2]; double P_110102010=Pd_110[0]*Pd_102[1]*Pd_010[2]; double P_110102110=Pd_110[0]*Pd_102[1]*Pd_110[2]; double P_110202010=Pd_110[0]*Pd_202[1]*Pd_010[2]; double P_110202110=Pd_110[0]*Pd_202[1]*Pd_110[2]; double P_011000011=Pd_011[0]*Pd_011[2]; double P_011000111=Pd_011[0]*Pd_111[2]; double P_011000211=Pd_011[0]*Pd_211[2]; double P_111000011=Pd_111[0]*Pd_011[2]; double P_111000111=Pd_111[0]*Pd_111[2]; double P_111000211=Pd_111[0]*Pd_211[2]; double P_211000011=Pd_211[0]*Pd_011[2]; double P_211000111=Pd_211[0]*Pd_111[2]; double P_211000211=Pd_211[0]*Pd_211[2]; double P_010001011=Pd_010[0]*Pd_001[1]*Pd_011[2]; double P_010001111=Pd_010[0]*Pd_001[1]*Pd_111[2]; double P_010001211=Pd_010[0]*Pd_001[1]*Pd_211[2]; double P_010101011=Pd_010[0]*Pd_101[1]*Pd_011[2]; double P_010101111=Pd_010[0]*Pd_101[1]*Pd_111[2]; double P_010101211=Pd_010[0]*Pd_101[1]*Pd_211[2]; double P_110001011=Pd_110[0]*Pd_001[1]*Pd_011[2]; double P_110001111=Pd_110[0]*Pd_001[1]*Pd_111[2]; double P_110001211=Pd_110[0]*Pd_001[1]*Pd_211[2]; double P_110101011=Pd_110[0]*Pd_101[1]*Pd_011[2]; double P_110101111=Pd_110[0]*Pd_101[1]*Pd_111[2]; double P_110101211=Pd_110[0]*Pd_101[1]*Pd_211[2]; double P_010000012=Pd_010[0]*Pd_012[2]; double P_010000112=Pd_010[0]*Pd_112[2]; double P_010000212=Pd_010[0]*Pd_212[2]; double P_010000312=Pd_010[0]*Pd_312[2]; double P_110000012=Pd_110[0]*Pd_012[2]; double P_110000112=Pd_110[0]*Pd_112[2]; double P_110000212=Pd_110[0]*Pd_212[2]; double P_110000312=Pd_110[0]*Pd_312[2]; double P_002010010=Pd_002[0]*Pd_010[1]*Pd_010[2]; double P_002010110=Pd_002[0]*Pd_010[1]*Pd_110[2]; double P_002110010=Pd_002[0]*Pd_110[1]*Pd_010[2]; double P_002110110=Pd_002[0]*Pd_110[1]*Pd_110[2]; double P_102010010=Pd_102[0]*Pd_010[1]*Pd_010[2]; double P_102010110=Pd_102[0]*Pd_010[1]*Pd_110[2]; double P_102110010=Pd_102[0]*Pd_110[1]*Pd_010[2]; double P_102110110=Pd_102[0]*Pd_110[1]*Pd_110[2]; double P_202010010=Pd_202[0]*Pd_010[1]*Pd_010[2]; double P_202010110=Pd_202[0]*Pd_010[1]*Pd_110[2]; double P_202110010=Pd_202[0]*Pd_110[1]*Pd_010[2]; double P_202110110=Pd_202[0]*Pd_110[1]*Pd_110[2]; double P_001011010=Pd_001[0]*Pd_011[1]*Pd_010[2]; double P_001011110=Pd_001[0]*Pd_011[1]*Pd_110[2]; double P_001111010=Pd_001[0]*Pd_111[1]*Pd_010[2]; double P_001111110=Pd_001[0]*Pd_111[1]*Pd_110[2]; double P_001211010=Pd_001[0]*Pd_211[1]*Pd_010[2]; double P_001211110=Pd_001[0]*Pd_211[1]*Pd_110[2]; double P_101011010=Pd_101[0]*Pd_011[1]*Pd_010[2]; double P_101011110=Pd_101[0]*Pd_011[1]*Pd_110[2]; double P_101111010=Pd_101[0]*Pd_111[1]*Pd_010[2]; double P_101111110=Pd_101[0]*Pd_111[1]*Pd_110[2]; double P_101211010=Pd_101[0]*Pd_211[1]*Pd_010[2]; double P_101211110=Pd_101[0]*Pd_211[1]*Pd_110[2]; double P_000012010=Pd_012[1]*Pd_010[2]; double P_000012110=Pd_012[1]*Pd_110[2]; double P_000112010=Pd_112[1]*Pd_010[2]; double P_000112110=Pd_112[1]*Pd_110[2]; double P_000212010=Pd_212[1]*Pd_010[2]; double P_000212110=Pd_212[1]*Pd_110[2]; double P_000312010=Pd_312[1]*Pd_010[2]; double P_000312110=Pd_312[1]*Pd_110[2]; double P_001010011=Pd_001[0]*Pd_010[1]*Pd_011[2]; double P_001010111=Pd_001[0]*Pd_010[1]*Pd_111[2]; double P_001010211=Pd_001[0]*Pd_010[1]*Pd_211[2]; double P_001110011=Pd_001[0]*Pd_110[1]*Pd_011[2]; double P_001110111=Pd_001[0]*Pd_110[1]*Pd_111[2]; double P_001110211=Pd_001[0]*Pd_110[1]*Pd_211[2]; double P_101010011=Pd_101[0]*Pd_010[1]*Pd_011[2]; double P_101010111=Pd_101[0]*Pd_010[1]*Pd_111[2]; double P_101010211=Pd_101[0]*Pd_010[1]*Pd_211[2]; double P_101110011=Pd_101[0]*Pd_110[1]*Pd_011[2]; double P_101110111=Pd_101[0]*Pd_110[1]*Pd_111[2]; double P_101110211=Pd_101[0]*Pd_110[1]*Pd_211[2]; double P_000011011=Pd_011[1]*Pd_011[2]; double P_000011111=Pd_011[1]*Pd_111[2]; double P_000011211=Pd_011[1]*Pd_211[2]; double P_000111011=Pd_111[1]*Pd_011[2]; double P_000111111=Pd_111[1]*Pd_111[2]; double P_000111211=Pd_111[1]*Pd_211[2]; double P_000211011=Pd_211[1]*Pd_011[2]; double P_000211111=Pd_211[1]*Pd_111[2]; double P_000211211=Pd_211[1]*Pd_211[2]; double P_000010012=Pd_010[1]*Pd_012[2]; double P_000010112=Pd_010[1]*Pd_112[2]; double P_000010212=Pd_010[1]*Pd_212[2]; double P_000010312=Pd_010[1]*Pd_312[2]; double P_000110012=Pd_110[1]*Pd_012[2]; double P_000110112=Pd_110[1]*Pd_112[2]; double P_000110212=Pd_110[1]*Pd_212[2]; double P_000110312=Pd_110[1]*Pd_312[2]; double P_002000020=Pd_002[0]*Pd_020[2]; double P_002000120=Pd_002[0]*Pd_120[2]; double P_002000220=Pd_002[0]*Pd_220[2]; double P_102000020=Pd_102[0]*Pd_020[2]; double P_102000120=Pd_102[0]*Pd_120[2]; double P_102000220=Pd_102[0]*Pd_220[2]; double P_202000020=Pd_202[0]*Pd_020[2]; double P_202000120=Pd_202[0]*Pd_120[2]; double P_202000220=Pd_202[0]*Pd_220[2]; double P_001001020=Pd_001[0]*Pd_001[1]*Pd_020[2]; double P_001001120=Pd_001[0]*Pd_001[1]*Pd_120[2]; double P_001001220=Pd_001[0]*Pd_001[1]*Pd_220[2]; double P_001101020=Pd_001[0]*Pd_101[1]*Pd_020[2]; double P_001101120=Pd_001[0]*Pd_101[1]*Pd_120[2]; double P_001101220=Pd_001[0]*Pd_101[1]*Pd_220[2]; double P_101001020=Pd_101[0]*Pd_001[1]*Pd_020[2]; double P_101001120=Pd_101[0]*Pd_001[1]*Pd_120[2]; double P_101001220=Pd_101[0]*Pd_001[1]*Pd_220[2]; double P_101101020=Pd_101[0]*Pd_101[1]*Pd_020[2]; double P_101101120=Pd_101[0]*Pd_101[1]*Pd_120[2]; double P_101101220=Pd_101[0]*Pd_101[1]*Pd_220[2]; double P_000002020=Pd_002[1]*Pd_020[2]; double P_000002120=Pd_002[1]*Pd_120[2]; double P_000002220=Pd_002[1]*Pd_220[2]; double P_000102020=Pd_102[1]*Pd_020[2]; double P_000102120=Pd_102[1]*Pd_120[2]; double P_000102220=Pd_102[1]*Pd_220[2]; double P_000202020=Pd_202[1]*Pd_020[2]; double P_000202120=Pd_202[1]*Pd_120[2]; double P_000202220=Pd_202[1]*Pd_220[2]; double P_001000021=Pd_001[0]*Pd_021[2]; double P_001000121=Pd_001[0]*Pd_121[2]; double P_001000221=Pd_001[0]*Pd_221[2]; double P_001000321=Pd_001[0]*Pd_321[2]; double P_101000021=Pd_101[0]*Pd_021[2]; double P_101000121=Pd_101[0]*Pd_121[2]; double P_101000221=Pd_101[0]*Pd_221[2]; double P_101000321=Pd_101[0]*Pd_321[2]; double P_000001021=Pd_001[1]*Pd_021[2]; double P_000001121=Pd_001[1]*Pd_121[2]; double P_000001221=Pd_001[1]*Pd_221[2]; double P_000001321=Pd_001[1]*Pd_321[2]; double P_000101021=Pd_101[1]*Pd_021[2]; double P_000101121=Pd_101[1]*Pd_121[2]; double P_000101221=Pd_101[1]*Pd_221[2]; double P_000101321=Pd_101[1]*Pd_321[2]; double P_000000022=Pd_022[2]; double P_000000122=Pd_122[2]; double P_000000222=Pd_222[2]; double P_000000322=Pd_322[2]; double P_000000422=Pd_422[2]; double PR_022000000000=P_022000000*R_000[0]+-1*P_122000000*R_100[0]+P_222000000*R_200[0]+-1*P_322000000*R_300[0]+P_422000000*R_400[0]; double PR_021001000000=P_021001000*R_000[0]+-1*P_021101000*R_010[0]+-1*P_121001000*R_100[0]+P_121101000*R_110[0]+P_221001000*R_200[0]+-1*P_221101000*R_210[0]+-1*P_321001000*R_300[0]+P_321101000*R_310[0]; double PR_020002000000=P_020002000*R_000[0]+-1*P_020102000*R_010[0]+P_020202000*R_020[0]+-1*P_120002000*R_100[0]+P_120102000*R_110[0]+-1*P_120202000*R_120[0]+P_220002000*R_200[0]+-1*P_220102000*R_210[0]+P_220202000*R_220[0]; double PR_021000001000=P_021000001*R_000[0]+-1*P_021000101*R_001[0]+-1*P_121000001*R_100[0]+P_121000101*R_101[0]+P_221000001*R_200[0]+-1*P_221000101*R_201[0]+-1*P_321000001*R_300[0]+P_321000101*R_301[0]; double PR_020001001000=P_020001001*R_000[0]+-1*P_020001101*R_001[0]+-1*P_020101001*R_010[0]+P_020101101*R_011[0]+-1*P_120001001*R_100[0]+P_120001101*R_101[0]+P_120101001*R_110[0]+-1*P_120101101*R_111[0]+P_220001001*R_200[0]+-1*P_220001101*R_201[0]+-1*P_220101001*R_210[0]+P_220101101*R_211[0]; double PR_020000002000=P_020000002*R_000[0]+-1*P_020000102*R_001[0]+P_020000202*R_002[0]+-1*P_120000002*R_100[0]+P_120000102*R_101[0]+-1*P_120000202*R_102[0]+P_220000002*R_200[0]+-1*P_220000102*R_201[0]+P_220000202*R_202[0]; double PR_012010000000=P_012010000*R_000[0]+-1*P_012110000*R_010[0]+-1*P_112010000*R_100[0]+P_112110000*R_110[0]+P_212010000*R_200[0]+-1*P_212110000*R_210[0]+-1*P_312010000*R_300[0]+P_312110000*R_310[0]; double PR_011011000000=P_011011000*R_000[0]+-1*P_011111000*R_010[0]+P_011211000*R_020[0]+-1*P_111011000*R_100[0]+P_111111000*R_110[0]+-1*P_111211000*R_120[0]+P_211011000*R_200[0]+-1*P_211111000*R_210[0]+P_211211000*R_220[0]; double PR_010012000000=P_010012000*R_000[0]+-1*P_010112000*R_010[0]+P_010212000*R_020[0]+-1*P_010312000*R_030[0]+-1*P_110012000*R_100[0]+P_110112000*R_110[0]+-1*P_110212000*R_120[0]+P_110312000*R_130[0]; double PR_011010001000=P_011010001*R_000[0]+-1*P_011010101*R_001[0]+-1*P_011110001*R_010[0]+P_011110101*R_011[0]+-1*P_111010001*R_100[0]+P_111010101*R_101[0]+P_111110001*R_110[0]+-1*P_111110101*R_111[0]+P_211010001*R_200[0]+-1*P_211010101*R_201[0]+-1*P_211110001*R_210[0]+P_211110101*R_211[0]; double PR_010011001000=P_010011001*R_000[0]+-1*P_010011101*R_001[0]+-1*P_010111001*R_010[0]+P_010111101*R_011[0]+P_010211001*R_020[0]+-1*P_010211101*R_021[0]+-1*P_110011001*R_100[0]+P_110011101*R_101[0]+P_110111001*R_110[0]+-1*P_110111101*R_111[0]+-1*P_110211001*R_120[0]+P_110211101*R_121[0]; double PR_010010002000=P_010010002*R_000[0]+-1*P_010010102*R_001[0]+P_010010202*R_002[0]+-1*P_010110002*R_010[0]+P_010110102*R_011[0]+-1*P_010110202*R_012[0]+-1*P_110010002*R_100[0]+P_110010102*R_101[0]+-1*P_110010202*R_102[0]+P_110110002*R_110[0]+-1*P_110110102*R_111[0]+P_110110202*R_112[0]; double PR_002020000000=P_002020000*R_000[0]+-1*P_002120000*R_010[0]+P_002220000*R_020[0]+-1*P_102020000*R_100[0]+P_102120000*R_110[0]+-1*P_102220000*R_120[0]+P_202020000*R_200[0]+-1*P_202120000*R_210[0]+P_202220000*R_220[0]; double PR_001021000000=P_001021000*R_000[0]+-1*P_001121000*R_010[0]+P_001221000*R_020[0]+-1*P_001321000*R_030[0]+-1*P_101021000*R_100[0]+P_101121000*R_110[0]+-1*P_101221000*R_120[0]+P_101321000*R_130[0]; double PR_000022000000=P_000022000*R_000[0]+-1*P_000122000*R_010[0]+P_000222000*R_020[0]+-1*P_000322000*R_030[0]+P_000422000*R_040[0]; double PR_001020001000=P_001020001*R_000[0]+-1*P_001020101*R_001[0]+-1*P_001120001*R_010[0]+P_001120101*R_011[0]+P_001220001*R_020[0]+-1*P_001220101*R_021[0]+-1*P_101020001*R_100[0]+P_101020101*R_101[0]+P_101120001*R_110[0]+-1*P_101120101*R_111[0]+-1*P_101220001*R_120[0]+P_101220101*R_121[0]; double PR_000021001000=P_000021001*R_000[0]+-1*P_000021101*R_001[0]+-1*P_000121001*R_010[0]+P_000121101*R_011[0]+P_000221001*R_020[0]+-1*P_000221101*R_021[0]+-1*P_000321001*R_030[0]+P_000321101*R_031[0]; double PR_000020002000=P_000020002*R_000[0]+-1*P_000020102*R_001[0]+P_000020202*R_002[0]+-1*P_000120002*R_010[0]+P_000120102*R_011[0]+-1*P_000120202*R_012[0]+P_000220002*R_020[0]+-1*P_000220102*R_021[0]+P_000220202*R_022[0]; double PR_012000010000=P_012000010*R_000[0]+-1*P_012000110*R_001[0]+-1*P_112000010*R_100[0]+P_112000110*R_101[0]+P_212000010*R_200[0]+-1*P_212000110*R_201[0]+-1*P_312000010*R_300[0]+P_312000110*R_301[0]; double PR_011001010000=P_011001010*R_000[0]+-1*P_011001110*R_001[0]+-1*P_011101010*R_010[0]+P_011101110*R_011[0]+-1*P_111001010*R_100[0]+P_111001110*R_101[0]+P_111101010*R_110[0]+-1*P_111101110*R_111[0]+P_211001010*R_200[0]+-1*P_211001110*R_201[0]+-1*P_211101010*R_210[0]+P_211101110*R_211[0]; double PR_010002010000=P_010002010*R_000[0]+-1*P_010002110*R_001[0]+-1*P_010102010*R_010[0]+P_010102110*R_011[0]+P_010202010*R_020[0]+-1*P_010202110*R_021[0]+-1*P_110002010*R_100[0]+P_110002110*R_101[0]+P_110102010*R_110[0]+-1*P_110102110*R_111[0]+-1*P_110202010*R_120[0]+P_110202110*R_121[0]; double PR_011000011000=P_011000011*R_000[0]+-1*P_011000111*R_001[0]+P_011000211*R_002[0]+-1*P_111000011*R_100[0]+P_111000111*R_101[0]+-1*P_111000211*R_102[0]+P_211000011*R_200[0]+-1*P_211000111*R_201[0]+P_211000211*R_202[0]; double PR_010001011000=P_010001011*R_000[0]+-1*P_010001111*R_001[0]+P_010001211*R_002[0]+-1*P_010101011*R_010[0]+P_010101111*R_011[0]+-1*P_010101211*R_012[0]+-1*P_110001011*R_100[0]+P_110001111*R_101[0]+-1*P_110001211*R_102[0]+P_110101011*R_110[0]+-1*P_110101111*R_111[0]+P_110101211*R_112[0]; double PR_010000012000=P_010000012*R_000[0]+-1*P_010000112*R_001[0]+P_010000212*R_002[0]+-1*P_010000312*R_003[0]+-1*P_110000012*R_100[0]+P_110000112*R_101[0]+-1*P_110000212*R_102[0]+P_110000312*R_103[0]; double PR_002010010000=P_002010010*R_000[0]+-1*P_002010110*R_001[0]+-1*P_002110010*R_010[0]+P_002110110*R_011[0]+-1*P_102010010*R_100[0]+P_102010110*R_101[0]+P_102110010*R_110[0]+-1*P_102110110*R_111[0]+P_202010010*R_200[0]+-1*P_202010110*R_201[0]+-1*P_202110010*R_210[0]+P_202110110*R_211[0]; double PR_001011010000=P_001011010*R_000[0]+-1*P_001011110*R_001[0]+-1*P_001111010*R_010[0]+P_001111110*R_011[0]+P_001211010*R_020[0]+-1*P_001211110*R_021[0]+-1*P_101011010*R_100[0]+P_101011110*R_101[0]+P_101111010*R_110[0]+-1*P_101111110*R_111[0]+-1*P_101211010*R_120[0]+P_101211110*R_121[0]; double PR_000012010000=P_000012010*R_000[0]+-1*P_000012110*R_001[0]+-1*P_000112010*R_010[0]+P_000112110*R_011[0]+P_000212010*R_020[0]+-1*P_000212110*R_021[0]+-1*P_000312010*R_030[0]+P_000312110*R_031[0]; double PR_001010011000=P_001010011*R_000[0]+-1*P_001010111*R_001[0]+P_001010211*R_002[0]+-1*P_001110011*R_010[0]+P_001110111*R_011[0]+-1*P_001110211*R_012[0]+-1*P_101010011*R_100[0]+P_101010111*R_101[0]+-1*P_101010211*R_102[0]+P_101110011*R_110[0]+-1*P_101110111*R_111[0]+P_101110211*R_112[0]; double PR_000011011000=P_000011011*R_000[0]+-1*P_000011111*R_001[0]+P_000011211*R_002[0]+-1*P_000111011*R_010[0]+P_000111111*R_011[0]+-1*P_000111211*R_012[0]+P_000211011*R_020[0]+-1*P_000211111*R_021[0]+P_000211211*R_022[0]; double PR_000010012000=P_000010012*R_000[0]+-1*P_000010112*R_001[0]+P_000010212*R_002[0]+-1*P_000010312*R_003[0]+-1*P_000110012*R_010[0]+P_000110112*R_011[0]+-1*P_000110212*R_012[0]+P_000110312*R_013[0]; double PR_002000020000=P_002000020*R_000[0]+-1*P_002000120*R_001[0]+P_002000220*R_002[0]+-1*P_102000020*R_100[0]+P_102000120*R_101[0]+-1*P_102000220*R_102[0]+P_202000020*R_200[0]+-1*P_202000120*R_201[0]+P_202000220*R_202[0]; double PR_001001020000=P_001001020*R_000[0]+-1*P_001001120*R_001[0]+P_001001220*R_002[0]+-1*P_001101020*R_010[0]+P_001101120*R_011[0]+-1*P_001101220*R_012[0]+-1*P_101001020*R_100[0]+P_101001120*R_101[0]+-1*P_101001220*R_102[0]+P_101101020*R_110[0]+-1*P_101101120*R_111[0]+P_101101220*R_112[0]; double PR_000002020000=P_000002020*R_000[0]+-1*P_000002120*R_001[0]+P_000002220*R_002[0]+-1*P_000102020*R_010[0]+P_000102120*R_011[0]+-1*P_000102220*R_012[0]+P_000202020*R_020[0]+-1*P_000202120*R_021[0]+P_000202220*R_022[0]; double PR_001000021000=P_001000021*R_000[0]+-1*P_001000121*R_001[0]+P_001000221*R_002[0]+-1*P_001000321*R_003[0]+-1*P_101000021*R_100[0]+P_101000121*R_101[0]+-1*P_101000221*R_102[0]+P_101000321*R_103[0]; double PR_000001021000=P_000001021*R_000[0]+-1*P_000001121*R_001[0]+P_000001221*R_002[0]+-1*P_000001321*R_003[0]+-1*P_000101021*R_010[0]+P_000101121*R_011[0]+-1*P_000101221*R_012[0]+P_000101321*R_013[0]; double PR_000000022000=P_000000022*R_000[0]+-1*P_000000122*R_001[0]+P_000000222*R_002[0]+-1*P_000000322*R_003[0]+P_000000422*R_004[0]; double PR_022000000001=P_022000000*R_001[0]+-1*P_122000000*R_101[0]+P_222000000*R_201[0]+-1*P_322000000*R_301[0]+P_422000000*R_401[0]; double PR_021001000001=P_021001000*R_001[0]+-1*P_021101000*R_011[0]+-1*P_121001000*R_101[0]+P_121101000*R_111[0]+P_221001000*R_201[0]+-1*P_221101000*R_211[0]+-1*P_321001000*R_301[0]+P_321101000*R_311[0]; double PR_020002000001=P_020002000*R_001[0]+-1*P_020102000*R_011[0]+P_020202000*R_021[0]+-1*P_120002000*R_101[0]+P_120102000*R_111[0]+-1*P_120202000*R_121[0]+P_220002000*R_201[0]+-1*P_220102000*R_211[0]+P_220202000*R_221[0]; double PR_021000001001=P_021000001*R_001[0]+-1*P_021000101*R_002[0]+-1*P_121000001*R_101[0]+P_121000101*R_102[0]+P_221000001*R_201[0]+-1*P_221000101*R_202[0]+-1*P_321000001*R_301[0]+P_321000101*R_302[0]; double PR_020001001001=P_020001001*R_001[0]+-1*P_020001101*R_002[0]+-1*P_020101001*R_011[0]+P_020101101*R_012[0]+-1*P_120001001*R_101[0]+P_120001101*R_102[0]+P_120101001*R_111[0]+-1*P_120101101*R_112[0]+P_220001001*R_201[0]+-1*P_220001101*R_202[0]+-1*P_220101001*R_211[0]+P_220101101*R_212[0]; double PR_020000002001=P_020000002*R_001[0]+-1*P_020000102*R_002[0]+P_020000202*R_003[0]+-1*P_120000002*R_101[0]+P_120000102*R_102[0]+-1*P_120000202*R_103[0]+P_220000002*R_201[0]+-1*P_220000102*R_202[0]+P_220000202*R_203[0]; double PR_012010000001=P_012010000*R_001[0]+-1*P_012110000*R_011[0]+-1*P_112010000*R_101[0]+P_112110000*R_111[0]+P_212010000*R_201[0]+-1*P_212110000*R_211[0]+-1*P_312010000*R_301[0]+P_312110000*R_311[0]; double PR_011011000001=P_011011000*R_001[0]+-1*P_011111000*R_011[0]+P_011211000*R_021[0]+-1*P_111011000*R_101[0]+P_111111000*R_111[0]+-1*P_111211000*R_121[0]+P_211011000*R_201[0]+-1*P_211111000*R_211[0]+P_211211000*R_221[0]; double PR_010012000001=P_010012000*R_001[0]+-1*P_010112000*R_011[0]+P_010212000*R_021[0]+-1*P_010312000*R_031[0]+-1*P_110012000*R_101[0]+P_110112000*R_111[0]+-1*P_110212000*R_121[0]+P_110312000*R_131[0]; double PR_011010001001=P_011010001*R_001[0]+-1*P_011010101*R_002[0]+-1*P_011110001*R_011[0]+P_011110101*R_012[0]+-1*P_111010001*R_101[0]+P_111010101*R_102[0]+P_111110001*R_111[0]+-1*P_111110101*R_112[0]+P_211010001*R_201[0]+-1*P_211010101*R_202[0]+-1*P_211110001*R_211[0]+P_211110101*R_212[0]; double PR_010011001001=P_010011001*R_001[0]+-1*P_010011101*R_002[0]+-1*P_010111001*R_011[0]+P_010111101*R_012[0]+P_010211001*R_021[0]+-1*P_010211101*R_022[0]+-1*P_110011001*R_101[0]+P_110011101*R_102[0]+P_110111001*R_111[0]+-1*P_110111101*R_112[0]+-1*P_110211001*R_121[0]+P_110211101*R_122[0]; double PR_010010002001=P_010010002*R_001[0]+-1*P_010010102*R_002[0]+P_010010202*R_003[0]+-1*P_010110002*R_011[0]+P_010110102*R_012[0]+-1*P_010110202*R_013[0]+-1*P_110010002*R_101[0]+P_110010102*R_102[0]+-1*P_110010202*R_103[0]+P_110110002*R_111[0]+-1*P_110110102*R_112[0]+P_110110202*R_113[0]; double PR_002020000001=P_002020000*R_001[0]+-1*P_002120000*R_011[0]+P_002220000*R_021[0]+-1*P_102020000*R_101[0]+P_102120000*R_111[0]+-1*P_102220000*R_121[0]+P_202020000*R_201[0]+-1*P_202120000*R_211[0]+P_202220000*R_221[0]; double PR_001021000001=P_001021000*R_001[0]+-1*P_001121000*R_011[0]+P_001221000*R_021[0]+-1*P_001321000*R_031[0]+-1*P_101021000*R_101[0]+P_101121000*R_111[0]+-1*P_101221000*R_121[0]+P_101321000*R_131[0]; double PR_000022000001=P_000022000*R_001[0]+-1*P_000122000*R_011[0]+P_000222000*R_021[0]+-1*P_000322000*R_031[0]+P_000422000*R_041[0]; double PR_001020001001=P_001020001*R_001[0]+-1*P_001020101*R_002[0]+-1*P_001120001*R_011[0]+P_001120101*R_012[0]+P_001220001*R_021[0]+-1*P_001220101*R_022[0]+-1*P_101020001*R_101[0]+P_101020101*R_102[0]+P_101120001*R_111[0]+-1*P_101120101*R_112[0]+-1*P_101220001*R_121[0]+P_101220101*R_122[0]; double PR_000021001001=P_000021001*R_001[0]+-1*P_000021101*R_002[0]+-1*P_000121001*R_011[0]+P_000121101*R_012[0]+P_000221001*R_021[0]+-1*P_000221101*R_022[0]+-1*P_000321001*R_031[0]+P_000321101*R_032[0]; double PR_000020002001=P_000020002*R_001[0]+-1*P_000020102*R_002[0]+P_000020202*R_003[0]+-1*P_000120002*R_011[0]+P_000120102*R_012[0]+-1*P_000120202*R_013[0]+P_000220002*R_021[0]+-1*P_000220102*R_022[0]+P_000220202*R_023[0]; double PR_012000010001=P_012000010*R_001[0]+-1*P_012000110*R_002[0]+-1*P_112000010*R_101[0]+P_112000110*R_102[0]+P_212000010*R_201[0]+-1*P_212000110*R_202[0]+-1*P_312000010*R_301[0]+P_312000110*R_302[0]; double PR_011001010001=P_011001010*R_001[0]+-1*P_011001110*R_002[0]+-1*P_011101010*R_011[0]+P_011101110*R_012[0]+-1*P_111001010*R_101[0]+P_111001110*R_102[0]+P_111101010*R_111[0]+-1*P_111101110*R_112[0]+P_211001010*R_201[0]+-1*P_211001110*R_202[0]+-1*P_211101010*R_211[0]+P_211101110*R_212[0]; double PR_010002010001=P_010002010*R_001[0]+-1*P_010002110*R_002[0]+-1*P_010102010*R_011[0]+P_010102110*R_012[0]+P_010202010*R_021[0]+-1*P_010202110*R_022[0]+-1*P_110002010*R_101[0]+P_110002110*R_102[0]+P_110102010*R_111[0]+-1*P_110102110*R_112[0]+-1*P_110202010*R_121[0]+P_110202110*R_122[0]; double PR_011000011001=P_011000011*R_001[0]+-1*P_011000111*R_002[0]+P_011000211*R_003[0]+-1*P_111000011*R_101[0]+P_111000111*R_102[0]+-1*P_111000211*R_103[0]+P_211000011*R_201[0]+-1*P_211000111*R_202[0]+P_211000211*R_203[0]; double PR_010001011001=P_010001011*R_001[0]+-1*P_010001111*R_002[0]+P_010001211*R_003[0]+-1*P_010101011*R_011[0]+P_010101111*R_012[0]+-1*P_010101211*R_013[0]+-1*P_110001011*R_101[0]+P_110001111*R_102[0]+-1*P_110001211*R_103[0]+P_110101011*R_111[0]+-1*P_110101111*R_112[0]+P_110101211*R_113[0]; double PR_010000012001=P_010000012*R_001[0]+-1*P_010000112*R_002[0]+P_010000212*R_003[0]+-1*P_010000312*R_004[0]+-1*P_110000012*R_101[0]+P_110000112*R_102[0]+-1*P_110000212*R_103[0]+P_110000312*R_104[0]; double PR_002010010001=P_002010010*R_001[0]+-1*P_002010110*R_002[0]+-1*P_002110010*R_011[0]+P_002110110*R_012[0]+-1*P_102010010*R_101[0]+P_102010110*R_102[0]+P_102110010*R_111[0]+-1*P_102110110*R_112[0]+P_202010010*R_201[0]+-1*P_202010110*R_202[0]+-1*P_202110010*R_211[0]+P_202110110*R_212[0]; double PR_001011010001=P_001011010*R_001[0]+-1*P_001011110*R_002[0]+-1*P_001111010*R_011[0]+P_001111110*R_012[0]+P_001211010*R_021[0]+-1*P_001211110*R_022[0]+-1*P_101011010*R_101[0]+P_101011110*R_102[0]+P_101111010*R_111[0]+-1*P_101111110*R_112[0]+-1*P_101211010*R_121[0]+P_101211110*R_122[0]; double PR_000012010001=P_000012010*R_001[0]+-1*P_000012110*R_002[0]+-1*P_000112010*R_011[0]+P_000112110*R_012[0]+P_000212010*R_021[0]+-1*P_000212110*R_022[0]+-1*P_000312010*R_031[0]+P_000312110*R_032[0]; double PR_001010011001=P_001010011*R_001[0]+-1*P_001010111*R_002[0]+P_001010211*R_003[0]+-1*P_001110011*R_011[0]+P_001110111*R_012[0]+-1*P_001110211*R_013[0]+-1*P_101010011*R_101[0]+P_101010111*R_102[0]+-1*P_101010211*R_103[0]+P_101110011*R_111[0]+-1*P_101110111*R_112[0]+P_101110211*R_113[0]; double PR_000011011001=P_000011011*R_001[0]+-1*P_000011111*R_002[0]+P_000011211*R_003[0]+-1*P_000111011*R_011[0]+P_000111111*R_012[0]+-1*P_000111211*R_013[0]+P_000211011*R_021[0]+-1*P_000211111*R_022[0]+P_000211211*R_023[0]; double PR_000010012001=P_000010012*R_001[0]+-1*P_000010112*R_002[0]+P_000010212*R_003[0]+-1*P_000010312*R_004[0]+-1*P_000110012*R_011[0]+P_000110112*R_012[0]+-1*P_000110212*R_013[0]+P_000110312*R_014[0]; double PR_002000020001=P_002000020*R_001[0]+-1*P_002000120*R_002[0]+P_002000220*R_003[0]+-1*P_102000020*R_101[0]+P_102000120*R_102[0]+-1*P_102000220*R_103[0]+P_202000020*R_201[0]+-1*P_202000120*R_202[0]+P_202000220*R_203[0]; double PR_001001020001=P_001001020*R_001[0]+-1*P_001001120*R_002[0]+P_001001220*R_003[0]+-1*P_001101020*R_011[0]+P_001101120*R_012[0]+-1*P_001101220*R_013[0]+-1*P_101001020*R_101[0]+P_101001120*R_102[0]+-1*P_101001220*R_103[0]+P_101101020*R_111[0]+-1*P_101101120*R_112[0]+P_101101220*R_113[0]; double PR_000002020001=P_000002020*R_001[0]+-1*P_000002120*R_002[0]+P_000002220*R_003[0]+-1*P_000102020*R_011[0]+P_000102120*R_012[0]+-1*P_000102220*R_013[0]+P_000202020*R_021[0]+-1*P_000202120*R_022[0]+P_000202220*R_023[0]; double PR_001000021001=P_001000021*R_001[0]+-1*P_001000121*R_002[0]+P_001000221*R_003[0]+-1*P_001000321*R_004[0]+-1*P_101000021*R_101[0]+P_101000121*R_102[0]+-1*P_101000221*R_103[0]+P_101000321*R_104[0]; double PR_000001021001=P_000001021*R_001[0]+-1*P_000001121*R_002[0]+P_000001221*R_003[0]+-1*P_000001321*R_004[0]+-1*P_000101021*R_011[0]+P_000101121*R_012[0]+-1*P_000101221*R_013[0]+P_000101321*R_014[0]; double PR_000000022001=P_000000022*R_001[0]+-1*P_000000122*R_002[0]+P_000000222*R_003[0]+-1*P_000000322*R_004[0]+P_000000422*R_005[0]; double PR_022000000010=P_022000000*R_010[0]+-1*P_122000000*R_110[0]+P_222000000*R_210[0]+-1*P_322000000*R_310[0]+P_422000000*R_410[0]; double PR_021001000010=P_021001000*R_010[0]+-1*P_021101000*R_020[0]+-1*P_121001000*R_110[0]+P_121101000*R_120[0]+P_221001000*R_210[0]+-1*P_221101000*R_220[0]+-1*P_321001000*R_310[0]+P_321101000*R_320[0]; double PR_020002000010=P_020002000*R_010[0]+-1*P_020102000*R_020[0]+P_020202000*R_030[0]+-1*P_120002000*R_110[0]+P_120102000*R_120[0]+-1*P_120202000*R_130[0]+P_220002000*R_210[0]+-1*P_220102000*R_220[0]+P_220202000*R_230[0]; double PR_021000001010=P_021000001*R_010[0]+-1*P_021000101*R_011[0]+-1*P_121000001*R_110[0]+P_121000101*R_111[0]+P_221000001*R_210[0]+-1*P_221000101*R_211[0]+-1*P_321000001*R_310[0]+P_321000101*R_311[0]; double PR_020001001010=P_020001001*R_010[0]+-1*P_020001101*R_011[0]+-1*P_020101001*R_020[0]+P_020101101*R_021[0]+-1*P_120001001*R_110[0]+P_120001101*R_111[0]+P_120101001*R_120[0]+-1*P_120101101*R_121[0]+P_220001001*R_210[0]+-1*P_220001101*R_211[0]+-1*P_220101001*R_220[0]+P_220101101*R_221[0]; double PR_020000002010=P_020000002*R_010[0]+-1*P_020000102*R_011[0]+P_020000202*R_012[0]+-1*P_120000002*R_110[0]+P_120000102*R_111[0]+-1*P_120000202*R_112[0]+P_220000002*R_210[0]+-1*P_220000102*R_211[0]+P_220000202*R_212[0]; double PR_012010000010=P_012010000*R_010[0]+-1*P_012110000*R_020[0]+-1*P_112010000*R_110[0]+P_112110000*R_120[0]+P_212010000*R_210[0]+-1*P_212110000*R_220[0]+-1*P_312010000*R_310[0]+P_312110000*R_320[0]; double PR_011011000010=P_011011000*R_010[0]+-1*P_011111000*R_020[0]+P_011211000*R_030[0]+-1*P_111011000*R_110[0]+P_111111000*R_120[0]+-1*P_111211000*R_130[0]+P_211011000*R_210[0]+-1*P_211111000*R_220[0]+P_211211000*R_230[0]; double PR_010012000010=P_010012000*R_010[0]+-1*P_010112000*R_020[0]+P_010212000*R_030[0]+-1*P_010312000*R_040[0]+-1*P_110012000*R_110[0]+P_110112000*R_120[0]+-1*P_110212000*R_130[0]+P_110312000*R_140[0]; double PR_011010001010=P_011010001*R_010[0]+-1*P_011010101*R_011[0]+-1*P_011110001*R_020[0]+P_011110101*R_021[0]+-1*P_111010001*R_110[0]+P_111010101*R_111[0]+P_111110001*R_120[0]+-1*P_111110101*R_121[0]+P_211010001*R_210[0]+-1*P_211010101*R_211[0]+-1*P_211110001*R_220[0]+P_211110101*R_221[0]; double PR_010011001010=P_010011001*R_010[0]+-1*P_010011101*R_011[0]+-1*P_010111001*R_020[0]+P_010111101*R_021[0]+P_010211001*R_030[0]+-1*P_010211101*R_031[0]+-1*P_110011001*R_110[0]+P_110011101*R_111[0]+P_110111001*R_120[0]+-1*P_110111101*R_121[0]+-1*P_110211001*R_130[0]+P_110211101*R_131[0]; double PR_010010002010=P_010010002*R_010[0]+-1*P_010010102*R_011[0]+P_010010202*R_012[0]+-1*P_010110002*R_020[0]+P_010110102*R_021[0]+-1*P_010110202*R_022[0]+-1*P_110010002*R_110[0]+P_110010102*R_111[0]+-1*P_110010202*R_112[0]+P_110110002*R_120[0]+-1*P_110110102*R_121[0]+P_110110202*R_122[0]; double PR_002020000010=P_002020000*R_010[0]+-1*P_002120000*R_020[0]+P_002220000*R_030[0]+-1*P_102020000*R_110[0]+P_102120000*R_120[0]+-1*P_102220000*R_130[0]+P_202020000*R_210[0]+-1*P_202120000*R_220[0]+P_202220000*R_230[0]; double PR_001021000010=P_001021000*R_010[0]+-1*P_001121000*R_020[0]+P_001221000*R_030[0]+-1*P_001321000*R_040[0]+-1*P_101021000*R_110[0]+P_101121000*R_120[0]+-1*P_101221000*R_130[0]+P_101321000*R_140[0]; double PR_000022000010=P_000022000*R_010[0]+-1*P_000122000*R_020[0]+P_000222000*R_030[0]+-1*P_000322000*R_040[0]+P_000422000*R_050[0]; double PR_001020001010=P_001020001*R_010[0]+-1*P_001020101*R_011[0]+-1*P_001120001*R_020[0]+P_001120101*R_021[0]+P_001220001*R_030[0]+-1*P_001220101*R_031[0]+-1*P_101020001*R_110[0]+P_101020101*R_111[0]+P_101120001*R_120[0]+-1*P_101120101*R_121[0]+-1*P_101220001*R_130[0]+P_101220101*R_131[0]; double PR_000021001010=P_000021001*R_010[0]+-1*P_000021101*R_011[0]+-1*P_000121001*R_020[0]+P_000121101*R_021[0]+P_000221001*R_030[0]+-1*P_000221101*R_031[0]+-1*P_000321001*R_040[0]+P_000321101*R_041[0]; double PR_000020002010=P_000020002*R_010[0]+-1*P_000020102*R_011[0]+P_000020202*R_012[0]+-1*P_000120002*R_020[0]+P_000120102*R_021[0]+-1*P_000120202*R_022[0]+P_000220002*R_030[0]+-1*P_000220102*R_031[0]+P_000220202*R_032[0]; double PR_012000010010=P_012000010*R_010[0]+-1*P_012000110*R_011[0]+-1*P_112000010*R_110[0]+P_112000110*R_111[0]+P_212000010*R_210[0]+-1*P_212000110*R_211[0]+-1*P_312000010*R_310[0]+P_312000110*R_311[0]; double PR_011001010010=P_011001010*R_010[0]+-1*P_011001110*R_011[0]+-1*P_011101010*R_020[0]+P_011101110*R_021[0]+-1*P_111001010*R_110[0]+P_111001110*R_111[0]+P_111101010*R_120[0]+-1*P_111101110*R_121[0]+P_211001010*R_210[0]+-1*P_211001110*R_211[0]+-1*P_211101010*R_220[0]+P_211101110*R_221[0]; double PR_010002010010=P_010002010*R_010[0]+-1*P_010002110*R_011[0]+-1*P_010102010*R_020[0]+P_010102110*R_021[0]+P_010202010*R_030[0]+-1*P_010202110*R_031[0]+-1*P_110002010*R_110[0]+P_110002110*R_111[0]+P_110102010*R_120[0]+-1*P_110102110*R_121[0]+-1*P_110202010*R_130[0]+P_110202110*R_131[0]; double PR_011000011010=P_011000011*R_010[0]+-1*P_011000111*R_011[0]+P_011000211*R_012[0]+-1*P_111000011*R_110[0]+P_111000111*R_111[0]+-1*P_111000211*R_112[0]+P_211000011*R_210[0]+-1*P_211000111*R_211[0]+P_211000211*R_212[0]; double PR_010001011010=P_010001011*R_010[0]+-1*P_010001111*R_011[0]+P_010001211*R_012[0]+-1*P_010101011*R_020[0]+P_010101111*R_021[0]+-1*P_010101211*R_022[0]+-1*P_110001011*R_110[0]+P_110001111*R_111[0]+-1*P_110001211*R_112[0]+P_110101011*R_120[0]+-1*P_110101111*R_121[0]+P_110101211*R_122[0]; double PR_010000012010=P_010000012*R_010[0]+-1*P_010000112*R_011[0]+P_010000212*R_012[0]+-1*P_010000312*R_013[0]+-1*P_110000012*R_110[0]+P_110000112*R_111[0]+-1*P_110000212*R_112[0]+P_110000312*R_113[0]; double PR_002010010010=P_002010010*R_010[0]+-1*P_002010110*R_011[0]+-1*P_002110010*R_020[0]+P_002110110*R_021[0]+-1*P_102010010*R_110[0]+P_102010110*R_111[0]+P_102110010*R_120[0]+-1*P_102110110*R_121[0]+P_202010010*R_210[0]+-1*P_202010110*R_211[0]+-1*P_202110010*R_220[0]+P_202110110*R_221[0]; double PR_001011010010=P_001011010*R_010[0]+-1*P_001011110*R_011[0]+-1*P_001111010*R_020[0]+P_001111110*R_021[0]+P_001211010*R_030[0]+-1*P_001211110*R_031[0]+-1*P_101011010*R_110[0]+P_101011110*R_111[0]+P_101111010*R_120[0]+-1*P_101111110*R_121[0]+-1*P_101211010*R_130[0]+P_101211110*R_131[0]; double PR_000012010010=P_000012010*R_010[0]+-1*P_000012110*R_011[0]+-1*P_000112010*R_020[0]+P_000112110*R_021[0]+P_000212010*R_030[0]+-1*P_000212110*R_031[0]+-1*P_000312010*R_040[0]+P_000312110*R_041[0]; double PR_001010011010=P_001010011*R_010[0]+-1*P_001010111*R_011[0]+P_001010211*R_012[0]+-1*P_001110011*R_020[0]+P_001110111*R_021[0]+-1*P_001110211*R_022[0]+-1*P_101010011*R_110[0]+P_101010111*R_111[0]+-1*P_101010211*R_112[0]+P_101110011*R_120[0]+-1*P_101110111*R_121[0]+P_101110211*R_122[0]; double PR_000011011010=P_000011011*R_010[0]+-1*P_000011111*R_011[0]+P_000011211*R_012[0]+-1*P_000111011*R_020[0]+P_000111111*R_021[0]+-1*P_000111211*R_022[0]+P_000211011*R_030[0]+-1*P_000211111*R_031[0]+P_000211211*R_032[0]; double PR_000010012010=P_000010012*R_010[0]+-1*P_000010112*R_011[0]+P_000010212*R_012[0]+-1*P_000010312*R_013[0]+-1*P_000110012*R_020[0]+P_000110112*R_021[0]+-1*P_000110212*R_022[0]+P_000110312*R_023[0]; double PR_002000020010=P_002000020*R_010[0]+-1*P_002000120*R_011[0]+P_002000220*R_012[0]+-1*P_102000020*R_110[0]+P_102000120*R_111[0]+-1*P_102000220*R_112[0]+P_202000020*R_210[0]+-1*P_202000120*R_211[0]+P_202000220*R_212[0]; double PR_001001020010=P_001001020*R_010[0]+-1*P_001001120*R_011[0]+P_001001220*R_012[0]+-1*P_001101020*R_020[0]+P_001101120*R_021[0]+-1*P_001101220*R_022[0]+-1*P_101001020*R_110[0]+P_101001120*R_111[0]+-1*P_101001220*R_112[0]+P_101101020*R_120[0]+-1*P_101101120*R_121[0]+P_101101220*R_122[0]; double PR_000002020010=P_000002020*R_010[0]+-1*P_000002120*R_011[0]+P_000002220*R_012[0]+-1*P_000102020*R_020[0]+P_000102120*R_021[0]+-1*P_000102220*R_022[0]+P_000202020*R_030[0]+-1*P_000202120*R_031[0]+P_000202220*R_032[0]; double PR_001000021010=P_001000021*R_010[0]+-1*P_001000121*R_011[0]+P_001000221*R_012[0]+-1*P_001000321*R_013[0]+-1*P_101000021*R_110[0]+P_101000121*R_111[0]+-1*P_101000221*R_112[0]+P_101000321*R_113[0]; double PR_000001021010=P_000001021*R_010[0]+-1*P_000001121*R_011[0]+P_000001221*R_012[0]+-1*P_000001321*R_013[0]+-1*P_000101021*R_020[0]+P_000101121*R_021[0]+-1*P_000101221*R_022[0]+P_000101321*R_023[0]; double PR_000000022010=P_000000022*R_010[0]+-1*P_000000122*R_011[0]+P_000000222*R_012[0]+-1*P_000000322*R_013[0]+P_000000422*R_014[0]; double PR_022000000100=P_022000000*R_100[0]+-1*P_122000000*R_200[0]+P_222000000*R_300[0]+-1*P_322000000*R_400[0]+P_422000000*R_500[0]; double PR_021001000100=P_021001000*R_100[0]+-1*P_021101000*R_110[0]+-1*P_121001000*R_200[0]+P_121101000*R_210[0]+P_221001000*R_300[0]+-1*P_221101000*R_310[0]+-1*P_321001000*R_400[0]+P_321101000*R_410[0]; double PR_020002000100=P_020002000*R_100[0]+-1*P_020102000*R_110[0]+P_020202000*R_120[0]+-1*P_120002000*R_200[0]+P_120102000*R_210[0]+-1*P_120202000*R_220[0]+P_220002000*R_300[0]+-1*P_220102000*R_310[0]+P_220202000*R_320[0]; double PR_021000001100=P_021000001*R_100[0]+-1*P_021000101*R_101[0]+-1*P_121000001*R_200[0]+P_121000101*R_201[0]+P_221000001*R_300[0]+-1*P_221000101*R_301[0]+-1*P_321000001*R_400[0]+P_321000101*R_401[0]; double PR_020001001100=P_020001001*R_100[0]+-1*P_020001101*R_101[0]+-1*P_020101001*R_110[0]+P_020101101*R_111[0]+-1*P_120001001*R_200[0]+P_120001101*R_201[0]+P_120101001*R_210[0]+-1*P_120101101*R_211[0]+P_220001001*R_300[0]+-1*P_220001101*R_301[0]+-1*P_220101001*R_310[0]+P_220101101*R_311[0]; double PR_020000002100=P_020000002*R_100[0]+-1*P_020000102*R_101[0]+P_020000202*R_102[0]+-1*P_120000002*R_200[0]+P_120000102*R_201[0]+-1*P_120000202*R_202[0]+P_220000002*R_300[0]+-1*P_220000102*R_301[0]+P_220000202*R_302[0]; double PR_012010000100=P_012010000*R_100[0]+-1*P_012110000*R_110[0]+-1*P_112010000*R_200[0]+P_112110000*R_210[0]+P_212010000*R_300[0]+-1*P_212110000*R_310[0]+-1*P_312010000*R_400[0]+P_312110000*R_410[0]; double PR_011011000100=P_011011000*R_100[0]+-1*P_011111000*R_110[0]+P_011211000*R_120[0]+-1*P_111011000*R_200[0]+P_111111000*R_210[0]+-1*P_111211000*R_220[0]+P_211011000*R_300[0]+-1*P_211111000*R_310[0]+P_211211000*R_320[0]; double PR_010012000100=P_010012000*R_100[0]+-1*P_010112000*R_110[0]+P_010212000*R_120[0]+-1*P_010312000*R_130[0]+-1*P_110012000*R_200[0]+P_110112000*R_210[0]+-1*P_110212000*R_220[0]+P_110312000*R_230[0]; double PR_011010001100=P_011010001*R_100[0]+-1*P_011010101*R_101[0]+-1*P_011110001*R_110[0]+P_011110101*R_111[0]+-1*P_111010001*R_200[0]+P_111010101*R_201[0]+P_111110001*R_210[0]+-1*P_111110101*R_211[0]+P_211010001*R_300[0]+-1*P_211010101*R_301[0]+-1*P_211110001*R_310[0]+P_211110101*R_311[0]; double PR_010011001100=P_010011001*R_100[0]+-1*P_010011101*R_101[0]+-1*P_010111001*R_110[0]+P_010111101*R_111[0]+P_010211001*R_120[0]+-1*P_010211101*R_121[0]+-1*P_110011001*R_200[0]+P_110011101*R_201[0]+P_110111001*R_210[0]+-1*P_110111101*R_211[0]+-1*P_110211001*R_220[0]+P_110211101*R_221[0]; double PR_010010002100=P_010010002*R_100[0]+-1*P_010010102*R_101[0]+P_010010202*R_102[0]+-1*P_010110002*R_110[0]+P_010110102*R_111[0]+-1*P_010110202*R_112[0]+-1*P_110010002*R_200[0]+P_110010102*R_201[0]+-1*P_110010202*R_202[0]+P_110110002*R_210[0]+-1*P_110110102*R_211[0]+P_110110202*R_212[0]; double PR_002020000100=P_002020000*R_100[0]+-1*P_002120000*R_110[0]+P_002220000*R_120[0]+-1*P_102020000*R_200[0]+P_102120000*R_210[0]+-1*P_102220000*R_220[0]+P_202020000*R_300[0]+-1*P_202120000*R_310[0]+P_202220000*R_320[0]; double PR_001021000100=P_001021000*R_100[0]+-1*P_001121000*R_110[0]+P_001221000*R_120[0]+-1*P_001321000*R_130[0]+-1*P_101021000*R_200[0]+P_101121000*R_210[0]+-1*P_101221000*R_220[0]+P_101321000*R_230[0]; double PR_000022000100=P_000022000*R_100[0]+-1*P_000122000*R_110[0]+P_000222000*R_120[0]+-1*P_000322000*R_130[0]+P_000422000*R_140[0]; double PR_001020001100=P_001020001*R_100[0]+-1*P_001020101*R_101[0]+-1*P_001120001*R_110[0]+P_001120101*R_111[0]+P_001220001*R_120[0]+-1*P_001220101*R_121[0]+-1*P_101020001*R_200[0]+P_101020101*R_201[0]+P_101120001*R_210[0]+-1*P_101120101*R_211[0]+-1*P_101220001*R_220[0]+P_101220101*R_221[0]; double PR_000021001100=P_000021001*R_100[0]+-1*P_000021101*R_101[0]+-1*P_000121001*R_110[0]+P_000121101*R_111[0]+P_000221001*R_120[0]+-1*P_000221101*R_121[0]+-1*P_000321001*R_130[0]+P_000321101*R_131[0]; double PR_000020002100=P_000020002*R_100[0]+-1*P_000020102*R_101[0]+P_000020202*R_102[0]+-1*P_000120002*R_110[0]+P_000120102*R_111[0]+-1*P_000120202*R_112[0]+P_000220002*R_120[0]+-1*P_000220102*R_121[0]+P_000220202*R_122[0]; double PR_012000010100=P_012000010*R_100[0]+-1*P_012000110*R_101[0]+-1*P_112000010*R_200[0]+P_112000110*R_201[0]+P_212000010*R_300[0]+-1*P_212000110*R_301[0]+-1*P_312000010*R_400[0]+P_312000110*R_401[0]; double PR_011001010100=P_011001010*R_100[0]+-1*P_011001110*R_101[0]+-1*P_011101010*R_110[0]+P_011101110*R_111[0]+-1*P_111001010*R_200[0]+P_111001110*R_201[0]+P_111101010*R_210[0]+-1*P_111101110*R_211[0]+P_211001010*R_300[0]+-1*P_211001110*R_301[0]+-1*P_211101010*R_310[0]+P_211101110*R_311[0]; double PR_010002010100=P_010002010*R_100[0]+-1*P_010002110*R_101[0]+-1*P_010102010*R_110[0]+P_010102110*R_111[0]+P_010202010*R_120[0]+-1*P_010202110*R_121[0]+-1*P_110002010*R_200[0]+P_110002110*R_201[0]+P_110102010*R_210[0]+-1*P_110102110*R_211[0]+-1*P_110202010*R_220[0]+P_110202110*R_221[0]; double PR_011000011100=P_011000011*R_100[0]+-1*P_011000111*R_101[0]+P_011000211*R_102[0]+-1*P_111000011*R_200[0]+P_111000111*R_201[0]+-1*P_111000211*R_202[0]+P_211000011*R_300[0]+-1*P_211000111*R_301[0]+P_211000211*R_302[0]; double PR_010001011100=P_010001011*R_100[0]+-1*P_010001111*R_101[0]+P_010001211*R_102[0]+-1*P_010101011*R_110[0]+P_010101111*R_111[0]+-1*P_010101211*R_112[0]+-1*P_110001011*R_200[0]+P_110001111*R_201[0]+-1*P_110001211*R_202[0]+P_110101011*R_210[0]+-1*P_110101111*R_211[0]+P_110101211*R_212[0]; double PR_010000012100=P_010000012*R_100[0]+-1*P_010000112*R_101[0]+P_010000212*R_102[0]+-1*P_010000312*R_103[0]+-1*P_110000012*R_200[0]+P_110000112*R_201[0]+-1*P_110000212*R_202[0]+P_110000312*R_203[0]; double PR_002010010100=P_002010010*R_100[0]+-1*P_002010110*R_101[0]+-1*P_002110010*R_110[0]+P_002110110*R_111[0]+-1*P_102010010*R_200[0]+P_102010110*R_201[0]+P_102110010*R_210[0]+-1*P_102110110*R_211[0]+P_202010010*R_300[0]+-1*P_202010110*R_301[0]+-1*P_202110010*R_310[0]+P_202110110*R_311[0]; double PR_001011010100=P_001011010*R_100[0]+-1*P_001011110*R_101[0]+-1*P_001111010*R_110[0]+P_001111110*R_111[0]+P_001211010*R_120[0]+-1*P_001211110*R_121[0]+-1*P_101011010*R_200[0]+P_101011110*R_201[0]+P_101111010*R_210[0]+-1*P_101111110*R_211[0]+-1*P_101211010*R_220[0]+P_101211110*R_221[0]; double PR_000012010100=P_000012010*R_100[0]+-1*P_000012110*R_101[0]+-1*P_000112010*R_110[0]+P_000112110*R_111[0]+P_000212010*R_120[0]+-1*P_000212110*R_121[0]+-1*P_000312010*R_130[0]+P_000312110*R_131[0]; double PR_001010011100=P_001010011*R_100[0]+-1*P_001010111*R_101[0]+P_001010211*R_102[0]+-1*P_001110011*R_110[0]+P_001110111*R_111[0]+-1*P_001110211*R_112[0]+-1*P_101010011*R_200[0]+P_101010111*R_201[0]+-1*P_101010211*R_202[0]+P_101110011*R_210[0]+-1*P_101110111*R_211[0]+P_101110211*R_212[0]; double PR_000011011100=P_000011011*R_100[0]+-1*P_000011111*R_101[0]+P_000011211*R_102[0]+-1*P_000111011*R_110[0]+P_000111111*R_111[0]+-1*P_000111211*R_112[0]+P_000211011*R_120[0]+-1*P_000211111*R_121[0]+P_000211211*R_122[0]; double PR_000010012100=P_000010012*R_100[0]+-1*P_000010112*R_101[0]+P_000010212*R_102[0]+-1*P_000010312*R_103[0]+-1*P_000110012*R_110[0]+P_000110112*R_111[0]+-1*P_000110212*R_112[0]+P_000110312*R_113[0]; double PR_002000020100=P_002000020*R_100[0]+-1*P_002000120*R_101[0]+P_002000220*R_102[0]+-1*P_102000020*R_200[0]+P_102000120*R_201[0]+-1*P_102000220*R_202[0]+P_202000020*R_300[0]+-1*P_202000120*R_301[0]+P_202000220*R_302[0]; double PR_001001020100=P_001001020*R_100[0]+-1*P_001001120*R_101[0]+P_001001220*R_102[0]+-1*P_001101020*R_110[0]+P_001101120*R_111[0]+-1*P_001101220*R_112[0]+-1*P_101001020*R_200[0]+P_101001120*R_201[0]+-1*P_101001220*R_202[0]+P_101101020*R_210[0]+-1*P_101101120*R_211[0]+P_101101220*R_212[0]; double PR_000002020100=P_000002020*R_100[0]+-1*P_000002120*R_101[0]+P_000002220*R_102[0]+-1*P_000102020*R_110[0]+P_000102120*R_111[0]+-1*P_000102220*R_112[0]+P_000202020*R_120[0]+-1*P_000202120*R_121[0]+P_000202220*R_122[0]; double PR_001000021100=P_001000021*R_100[0]+-1*P_001000121*R_101[0]+P_001000221*R_102[0]+-1*P_001000321*R_103[0]+-1*P_101000021*R_200[0]+P_101000121*R_201[0]+-1*P_101000221*R_202[0]+P_101000321*R_203[0]; double PR_000001021100=P_000001021*R_100[0]+-1*P_000001121*R_101[0]+P_000001221*R_102[0]+-1*P_000001321*R_103[0]+-1*P_000101021*R_110[0]+P_000101121*R_111[0]+-1*P_000101221*R_112[0]+P_000101321*R_113[0]; double PR_000000022100=P_000000022*R_100[0]+-1*P_000000122*R_101[0]+P_000000222*R_102[0]+-1*P_000000322*R_103[0]+P_000000422*R_104[0]; double PR_022000000002=P_022000000*R_002[0]+-1*P_122000000*R_102[0]+P_222000000*R_202[0]+-1*P_322000000*R_302[0]+P_422000000*R_402[0]; double PR_021001000002=P_021001000*R_002[0]+-1*P_021101000*R_012[0]+-1*P_121001000*R_102[0]+P_121101000*R_112[0]+P_221001000*R_202[0]+-1*P_221101000*R_212[0]+-1*P_321001000*R_302[0]+P_321101000*R_312[0]; double PR_020002000002=P_020002000*R_002[0]+-1*P_020102000*R_012[0]+P_020202000*R_022[0]+-1*P_120002000*R_102[0]+P_120102000*R_112[0]+-1*P_120202000*R_122[0]+P_220002000*R_202[0]+-1*P_220102000*R_212[0]+P_220202000*R_222[0]; double PR_021000001002=P_021000001*R_002[0]+-1*P_021000101*R_003[0]+-1*P_121000001*R_102[0]+P_121000101*R_103[0]+P_221000001*R_202[0]+-1*P_221000101*R_203[0]+-1*P_321000001*R_302[0]+P_321000101*R_303[0]; double PR_020001001002=P_020001001*R_002[0]+-1*P_020001101*R_003[0]+-1*P_020101001*R_012[0]+P_020101101*R_013[0]+-1*P_120001001*R_102[0]+P_120001101*R_103[0]+P_120101001*R_112[0]+-1*P_120101101*R_113[0]+P_220001001*R_202[0]+-1*P_220001101*R_203[0]+-1*P_220101001*R_212[0]+P_220101101*R_213[0]; double PR_020000002002=P_020000002*R_002[0]+-1*P_020000102*R_003[0]+P_020000202*R_004[0]+-1*P_120000002*R_102[0]+P_120000102*R_103[0]+-1*P_120000202*R_104[0]+P_220000002*R_202[0]+-1*P_220000102*R_203[0]+P_220000202*R_204[0]; double PR_012010000002=P_012010000*R_002[0]+-1*P_012110000*R_012[0]+-1*P_112010000*R_102[0]+P_112110000*R_112[0]+P_212010000*R_202[0]+-1*P_212110000*R_212[0]+-1*P_312010000*R_302[0]+P_312110000*R_312[0]; double PR_011011000002=P_011011000*R_002[0]+-1*P_011111000*R_012[0]+P_011211000*R_022[0]+-1*P_111011000*R_102[0]+P_111111000*R_112[0]+-1*P_111211000*R_122[0]+P_211011000*R_202[0]+-1*P_211111000*R_212[0]+P_211211000*R_222[0]; double PR_010012000002=P_010012000*R_002[0]+-1*P_010112000*R_012[0]+P_010212000*R_022[0]+-1*P_010312000*R_032[0]+-1*P_110012000*R_102[0]+P_110112000*R_112[0]+-1*P_110212000*R_122[0]+P_110312000*R_132[0]; double PR_011010001002=P_011010001*R_002[0]+-1*P_011010101*R_003[0]+-1*P_011110001*R_012[0]+P_011110101*R_013[0]+-1*P_111010001*R_102[0]+P_111010101*R_103[0]+P_111110001*R_112[0]+-1*P_111110101*R_113[0]+P_211010001*R_202[0]+-1*P_211010101*R_203[0]+-1*P_211110001*R_212[0]+P_211110101*R_213[0]; double PR_010011001002=P_010011001*R_002[0]+-1*P_010011101*R_003[0]+-1*P_010111001*R_012[0]+P_010111101*R_013[0]+P_010211001*R_022[0]+-1*P_010211101*R_023[0]+-1*P_110011001*R_102[0]+P_110011101*R_103[0]+P_110111001*R_112[0]+-1*P_110111101*R_113[0]+-1*P_110211001*R_122[0]+P_110211101*R_123[0]; double PR_010010002002=P_010010002*R_002[0]+-1*P_010010102*R_003[0]+P_010010202*R_004[0]+-1*P_010110002*R_012[0]+P_010110102*R_013[0]+-1*P_010110202*R_014[0]+-1*P_110010002*R_102[0]+P_110010102*R_103[0]+-1*P_110010202*R_104[0]+P_110110002*R_112[0]+-1*P_110110102*R_113[0]+P_110110202*R_114[0]; double PR_002020000002=P_002020000*R_002[0]+-1*P_002120000*R_012[0]+P_002220000*R_022[0]+-1*P_102020000*R_102[0]+P_102120000*R_112[0]+-1*P_102220000*R_122[0]+P_202020000*R_202[0]+-1*P_202120000*R_212[0]+P_202220000*R_222[0]; double PR_001021000002=P_001021000*R_002[0]+-1*P_001121000*R_012[0]+P_001221000*R_022[0]+-1*P_001321000*R_032[0]+-1*P_101021000*R_102[0]+P_101121000*R_112[0]+-1*P_101221000*R_122[0]+P_101321000*R_132[0]; double PR_000022000002=P_000022000*R_002[0]+-1*P_000122000*R_012[0]+P_000222000*R_022[0]+-1*P_000322000*R_032[0]+P_000422000*R_042[0]; double PR_001020001002=P_001020001*R_002[0]+-1*P_001020101*R_003[0]+-1*P_001120001*R_012[0]+P_001120101*R_013[0]+P_001220001*R_022[0]+-1*P_001220101*R_023[0]+-1*P_101020001*R_102[0]+P_101020101*R_103[0]+P_101120001*R_112[0]+-1*P_101120101*R_113[0]+-1*P_101220001*R_122[0]+P_101220101*R_123[0]; double PR_000021001002=P_000021001*R_002[0]+-1*P_000021101*R_003[0]+-1*P_000121001*R_012[0]+P_000121101*R_013[0]+P_000221001*R_022[0]+-1*P_000221101*R_023[0]+-1*P_000321001*R_032[0]+P_000321101*R_033[0]; double PR_000020002002=P_000020002*R_002[0]+-1*P_000020102*R_003[0]+P_000020202*R_004[0]+-1*P_000120002*R_012[0]+P_000120102*R_013[0]+-1*P_000120202*R_014[0]+P_000220002*R_022[0]+-1*P_000220102*R_023[0]+P_000220202*R_024[0]; double PR_012000010002=P_012000010*R_002[0]+-1*P_012000110*R_003[0]+-1*P_112000010*R_102[0]+P_112000110*R_103[0]+P_212000010*R_202[0]+-1*P_212000110*R_203[0]+-1*P_312000010*R_302[0]+P_312000110*R_303[0]; double PR_011001010002=P_011001010*R_002[0]+-1*P_011001110*R_003[0]+-1*P_011101010*R_012[0]+P_011101110*R_013[0]+-1*P_111001010*R_102[0]+P_111001110*R_103[0]+P_111101010*R_112[0]+-1*P_111101110*R_113[0]+P_211001010*R_202[0]+-1*P_211001110*R_203[0]+-1*P_211101010*R_212[0]+P_211101110*R_213[0]; double PR_010002010002=P_010002010*R_002[0]+-1*P_010002110*R_003[0]+-1*P_010102010*R_012[0]+P_010102110*R_013[0]+P_010202010*R_022[0]+-1*P_010202110*R_023[0]+-1*P_110002010*R_102[0]+P_110002110*R_103[0]+P_110102010*R_112[0]+-1*P_110102110*R_113[0]+-1*P_110202010*R_122[0]+P_110202110*R_123[0]; double PR_011000011002=P_011000011*R_002[0]+-1*P_011000111*R_003[0]+P_011000211*R_004[0]+-1*P_111000011*R_102[0]+P_111000111*R_103[0]+-1*P_111000211*R_104[0]+P_211000011*R_202[0]+-1*P_211000111*R_203[0]+P_211000211*R_204[0]; double PR_010001011002=P_010001011*R_002[0]+-1*P_010001111*R_003[0]+P_010001211*R_004[0]+-1*P_010101011*R_012[0]+P_010101111*R_013[0]+-1*P_010101211*R_014[0]+-1*P_110001011*R_102[0]+P_110001111*R_103[0]+-1*P_110001211*R_104[0]+P_110101011*R_112[0]+-1*P_110101111*R_113[0]+P_110101211*R_114[0]; double PR_010000012002=P_010000012*R_002[0]+-1*P_010000112*R_003[0]+P_010000212*R_004[0]+-1*P_010000312*R_005[0]+-1*P_110000012*R_102[0]+P_110000112*R_103[0]+-1*P_110000212*R_104[0]+P_110000312*R_105[0]; double PR_002010010002=P_002010010*R_002[0]+-1*P_002010110*R_003[0]+-1*P_002110010*R_012[0]+P_002110110*R_013[0]+-1*P_102010010*R_102[0]+P_102010110*R_103[0]+P_102110010*R_112[0]+-1*P_102110110*R_113[0]+P_202010010*R_202[0]+-1*P_202010110*R_203[0]+-1*P_202110010*R_212[0]+P_202110110*R_213[0]; double PR_001011010002=P_001011010*R_002[0]+-1*P_001011110*R_003[0]+-1*P_001111010*R_012[0]+P_001111110*R_013[0]+P_001211010*R_022[0]+-1*P_001211110*R_023[0]+-1*P_101011010*R_102[0]+P_101011110*R_103[0]+P_101111010*R_112[0]+-1*P_101111110*R_113[0]+-1*P_101211010*R_122[0]+P_101211110*R_123[0]; double PR_000012010002=P_000012010*R_002[0]+-1*P_000012110*R_003[0]+-1*P_000112010*R_012[0]+P_000112110*R_013[0]+P_000212010*R_022[0]+-1*P_000212110*R_023[0]+-1*P_000312010*R_032[0]+P_000312110*R_033[0]; double PR_001010011002=P_001010011*R_002[0]+-1*P_001010111*R_003[0]+P_001010211*R_004[0]+-1*P_001110011*R_012[0]+P_001110111*R_013[0]+-1*P_001110211*R_014[0]+-1*P_101010011*R_102[0]+P_101010111*R_103[0]+-1*P_101010211*R_104[0]+P_101110011*R_112[0]+-1*P_101110111*R_113[0]+P_101110211*R_114[0]; double PR_000011011002=P_000011011*R_002[0]+-1*P_000011111*R_003[0]+P_000011211*R_004[0]+-1*P_000111011*R_012[0]+P_000111111*R_013[0]+-1*P_000111211*R_014[0]+P_000211011*R_022[0]+-1*P_000211111*R_023[0]+P_000211211*R_024[0]; double PR_000010012002=P_000010012*R_002[0]+-1*P_000010112*R_003[0]+P_000010212*R_004[0]+-1*P_000010312*R_005[0]+-1*P_000110012*R_012[0]+P_000110112*R_013[0]+-1*P_000110212*R_014[0]+P_000110312*R_015[0]; double PR_002000020002=P_002000020*R_002[0]+-1*P_002000120*R_003[0]+P_002000220*R_004[0]+-1*P_102000020*R_102[0]+P_102000120*R_103[0]+-1*P_102000220*R_104[0]+P_202000020*R_202[0]+-1*P_202000120*R_203[0]+P_202000220*R_204[0]; double PR_001001020002=P_001001020*R_002[0]+-1*P_001001120*R_003[0]+P_001001220*R_004[0]+-1*P_001101020*R_012[0]+P_001101120*R_013[0]+-1*P_001101220*R_014[0]+-1*P_101001020*R_102[0]+P_101001120*R_103[0]+-1*P_101001220*R_104[0]+P_101101020*R_112[0]+-1*P_101101120*R_113[0]+P_101101220*R_114[0]; double PR_000002020002=P_000002020*R_002[0]+-1*P_000002120*R_003[0]+P_000002220*R_004[0]+-1*P_000102020*R_012[0]+P_000102120*R_013[0]+-1*P_000102220*R_014[0]+P_000202020*R_022[0]+-1*P_000202120*R_023[0]+P_000202220*R_024[0]; double PR_001000021002=P_001000021*R_002[0]+-1*P_001000121*R_003[0]+P_001000221*R_004[0]+-1*P_001000321*R_005[0]+-1*P_101000021*R_102[0]+P_101000121*R_103[0]+-1*P_101000221*R_104[0]+P_101000321*R_105[0]; double PR_000001021002=P_000001021*R_002[0]+-1*P_000001121*R_003[0]+P_000001221*R_004[0]+-1*P_000001321*R_005[0]+-1*P_000101021*R_012[0]+P_000101121*R_013[0]+-1*P_000101221*R_014[0]+P_000101321*R_015[0]; double PR_000000022002=P_000000022*R_002[0]+-1*P_000000122*R_003[0]+P_000000222*R_004[0]+-1*P_000000322*R_005[0]+P_000000422*R_006[0]; double PR_022000000011=P_022000000*R_011[0]+-1*P_122000000*R_111[0]+P_222000000*R_211[0]+-1*P_322000000*R_311[0]+P_422000000*R_411[0]; double PR_021001000011=P_021001000*R_011[0]+-1*P_021101000*R_021[0]+-1*P_121001000*R_111[0]+P_121101000*R_121[0]+P_221001000*R_211[0]+-1*P_221101000*R_221[0]+-1*P_321001000*R_311[0]+P_321101000*R_321[0]; double PR_020002000011=P_020002000*R_011[0]+-1*P_020102000*R_021[0]+P_020202000*R_031[0]+-1*P_120002000*R_111[0]+P_120102000*R_121[0]+-1*P_120202000*R_131[0]+P_220002000*R_211[0]+-1*P_220102000*R_221[0]+P_220202000*R_231[0]; double PR_021000001011=P_021000001*R_011[0]+-1*P_021000101*R_012[0]+-1*P_121000001*R_111[0]+P_121000101*R_112[0]+P_221000001*R_211[0]+-1*P_221000101*R_212[0]+-1*P_321000001*R_311[0]+P_321000101*R_312[0]; double PR_020001001011=P_020001001*R_011[0]+-1*P_020001101*R_012[0]+-1*P_020101001*R_021[0]+P_020101101*R_022[0]+-1*P_120001001*R_111[0]+P_120001101*R_112[0]+P_120101001*R_121[0]+-1*P_120101101*R_122[0]+P_220001001*R_211[0]+-1*P_220001101*R_212[0]+-1*P_220101001*R_221[0]+P_220101101*R_222[0]; double PR_020000002011=P_020000002*R_011[0]+-1*P_020000102*R_012[0]+P_020000202*R_013[0]+-1*P_120000002*R_111[0]+P_120000102*R_112[0]+-1*P_120000202*R_113[0]+P_220000002*R_211[0]+-1*P_220000102*R_212[0]+P_220000202*R_213[0]; double PR_012010000011=P_012010000*R_011[0]+-1*P_012110000*R_021[0]+-1*P_112010000*R_111[0]+P_112110000*R_121[0]+P_212010000*R_211[0]+-1*P_212110000*R_221[0]+-1*P_312010000*R_311[0]+P_312110000*R_321[0]; double PR_011011000011=P_011011000*R_011[0]+-1*P_011111000*R_021[0]+P_011211000*R_031[0]+-1*P_111011000*R_111[0]+P_111111000*R_121[0]+-1*P_111211000*R_131[0]+P_211011000*R_211[0]+-1*P_211111000*R_221[0]+P_211211000*R_231[0]; double PR_010012000011=P_010012000*R_011[0]+-1*P_010112000*R_021[0]+P_010212000*R_031[0]+-1*P_010312000*R_041[0]+-1*P_110012000*R_111[0]+P_110112000*R_121[0]+-1*P_110212000*R_131[0]+P_110312000*R_141[0]; double PR_011010001011=P_011010001*R_011[0]+-1*P_011010101*R_012[0]+-1*P_011110001*R_021[0]+P_011110101*R_022[0]+-1*P_111010001*R_111[0]+P_111010101*R_112[0]+P_111110001*R_121[0]+-1*P_111110101*R_122[0]+P_211010001*R_211[0]+-1*P_211010101*R_212[0]+-1*P_211110001*R_221[0]+P_211110101*R_222[0]; double PR_010011001011=P_010011001*R_011[0]+-1*P_010011101*R_012[0]+-1*P_010111001*R_021[0]+P_010111101*R_022[0]+P_010211001*R_031[0]+-1*P_010211101*R_032[0]+-1*P_110011001*R_111[0]+P_110011101*R_112[0]+P_110111001*R_121[0]+-1*P_110111101*R_122[0]+-1*P_110211001*R_131[0]+P_110211101*R_132[0]; double PR_010010002011=P_010010002*R_011[0]+-1*P_010010102*R_012[0]+P_010010202*R_013[0]+-1*P_010110002*R_021[0]+P_010110102*R_022[0]+-1*P_010110202*R_023[0]+-1*P_110010002*R_111[0]+P_110010102*R_112[0]+-1*P_110010202*R_113[0]+P_110110002*R_121[0]+-1*P_110110102*R_122[0]+P_110110202*R_123[0]; double PR_002020000011=P_002020000*R_011[0]+-1*P_002120000*R_021[0]+P_002220000*R_031[0]+-1*P_102020000*R_111[0]+P_102120000*R_121[0]+-1*P_102220000*R_131[0]+P_202020000*R_211[0]+-1*P_202120000*R_221[0]+P_202220000*R_231[0]; double PR_001021000011=P_001021000*R_011[0]+-1*P_001121000*R_021[0]+P_001221000*R_031[0]+-1*P_001321000*R_041[0]+-1*P_101021000*R_111[0]+P_101121000*R_121[0]+-1*P_101221000*R_131[0]+P_101321000*R_141[0]; double PR_000022000011=P_000022000*R_011[0]+-1*P_000122000*R_021[0]+P_000222000*R_031[0]+-1*P_000322000*R_041[0]+P_000422000*R_051[0]; double PR_001020001011=P_001020001*R_011[0]+-1*P_001020101*R_012[0]+-1*P_001120001*R_021[0]+P_001120101*R_022[0]+P_001220001*R_031[0]+-1*P_001220101*R_032[0]+-1*P_101020001*R_111[0]+P_101020101*R_112[0]+P_101120001*R_121[0]+-1*P_101120101*R_122[0]+-1*P_101220001*R_131[0]+P_101220101*R_132[0]; double PR_000021001011=P_000021001*R_011[0]+-1*P_000021101*R_012[0]+-1*P_000121001*R_021[0]+P_000121101*R_022[0]+P_000221001*R_031[0]+-1*P_000221101*R_032[0]+-1*P_000321001*R_041[0]+P_000321101*R_042[0]; double PR_000020002011=P_000020002*R_011[0]+-1*P_000020102*R_012[0]+P_000020202*R_013[0]+-1*P_000120002*R_021[0]+P_000120102*R_022[0]+-1*P_000120202*R_023[0]+P_000220002*R_031[0]+-1*P_000220102*R_032[0]+P_000220202*R_033[0]; double PR_012000010011=P_012000010*R_011[0]+-1*P_012000110*R_012[0]+-1*P_112000010*R_111[0]+P_112000110*R_112[0]+P_212000010*R_211[0]+-1*P_212000110*R_212[0]+-1*P_312000010*R_311[0]+P_312000110*R_312[0]; double PR_011001010011=P_011001010*R_011[0]+-1*P_011001110*R_012[0]+-1*P_011101010*R_021[0]+P_011101110*R_022[0]+-1*P_111001010*R_111[0]+P_111001110*R_112[0]+P_111101010*R_121[0]+-1*P_111101110*R_122[0]+P_211001010*R_211[0]+-1*P_211001110*R_212[0]+-1*P_211101010*R_221[0]+P_211101110*R_222[0]; double PR_010002010011=P_010002010*R_011[0]+-1*P_010002110*R_012[0]+-1*P_010102010*R_021[0]+P_010102110*R_022[0]+P_010202010*R_031[0]+-1*P_010202110*R_032[0]+-1*P_110002010*R_111[0]+P_110002110*R_112[0]+P_110102010*R_121[0]+-1*P_110102110*R_122[0]+-1*P_110202010*R_131[0]+P_110202110*R_132[0]; double PR_011000011011=P_011000011*R_011[0]+-1*P_011000111*R_012[0]+P_011000211*R_013[0]+-1*P_111000011*R_111[0]+P_111000111*R_112[0]+-1*P_111000211*R_113[0]+P_211000011*R_211[0]+-1*P_211000111*R_212[0]+P_211000211*R_213[0]; double PR_010001011011=P_010001011*R_011[0]+-1*P_010001111*R_012[0]+P_010001211*R_013[0]+-1*P_010101011*R_021[0]+P_010101111*R_022[0]+-1*P_010101211*R_023[0]+-1*P_110001011*R_111[0]+P_110001111*R_112[0]+-1*P_110001211*R_113[0]+P_110101011*R_121[0]+-1*P_110101111*R_122[0]+P_110101211*R_123[0]; double PR_010000012011=P_010000012*R_011[0]+-1*P_010000112*R_012[0]+P_010000212*R_013[0]+-1*P_010000312*R_014[0]+-1*P_110000012*R_111[0]+P_110000112*R_112[0]+-1*P_110000212*R_113[0]+P_110000312*R_114[0]; double PR_002010010011=P_002010010*R_011[0]+-1*P_002010110*R_012[0]+-1*P_002110010*R_021[0]+P_002110110*R_022[0]+-1*P_102010010*R_111[0]+P_102010110*R_112[0]+P_102110010*R_121[0]+-1*P_102110110*R_122[0]+P_202010010*R_211[0]+-1*P_202010110*R_212[0]+-1*P_202110010*R_221[0]+P_202110110*R_222[0]; double PR_001011010011=P_001011010*R_011[0]+-1*P_001011110*R_012[0]+-1*P_001111010*R_021[0]+P_001111110*R_022[0]+P_001211010*R_031[0]+-1*P_001211110*R_032[0]+-1*P_101011010*R_111[0]+P_101011110*R_112[0]+P_101111010*R_121[0]+-1*P_101111110*R_122[0]+-1*P_101211010*R_131[0]+P_101211110*R_132[0]; double PR_000012010011=P_000012010*R_011[0]+-1*P_000012110*R_012[0]+-1*P_000112010*R_021[0]+P_000112110*R_022[0]+P_000212010*R_031[0]+-1*P_000212110*R_032[0]+-1*P_000312010*R_041[0]+P_000312110*R_042[0]; double PR_001010011011=P_001010011*R_011[0]+-1*P_001010111*R_012[0]+P_001010211*R_013[0]+-1*P_001110011*R_021[0]+P_001110111*R_022[0]+-1*P_001110211*R_023[0]+-1*P_101010011*R_111[0]+P_101010111*R_112[0]+-1*P_101010211*R_113[0]+P_101110011*R_121[0]+-1*P_101110111*R_122[0]+P_101110211*R_123[0]; double PR_000011011011=P_000011011*R_011[0]+-1*P_000011111*R_012[0]+P_000011211*R_013[0]+-1*P_000111011*R_021[0]+P_000111111*R_022[0]+-1*P_000111211*R_023[0]+P_000211011*R_031[0]+-1*P_000211111*R_032[0]+P_000211211*R_033[0]; double PR_000010012011=P_000010012*R_011[0]+-1*P_000010112*R_012[0]+P_000010212*R_013[0]+-1*P_000010312*R_014[0]+-1*P_000110012*R_021[0]+P_000110112*R_022[0]+-1*P_000110212*R_023[0]+P_000110312*R_024[0]; double PR_002000020011=P_002000020*R_011[0]+-1*P_002000120*R_012[0]+P_002000220*R_013[0]+-1*P_102000020*R_111[0]+P_102000120*R_112[0]+-1*P_102000220*R_113[0]+P_202000020*R_211[0]+-1*P_202000120*R_212[0]+P_202000220*R_213[0]; double PR_001001020011=P_001001020*R_011[0]+-1*P_001001120*R_012[0]+P_001001220*R_013[0]+-1*P_001101020*R_021[0]+P_001101120*R_022[0]+-1*P_001101220*R_023[0]+-1*P_101001020*R_111[0]+P_101001120*R_112[0]+-1*P_101001220*R_113[0]+P_101101020*R_121[0]+-1*P_101101120*R_122[0]+P_101101220*R_123[0]; double PR_000002020011=P_000002020*R_011[0]+-1*P_000002120*R_012[0]+P_000002220*R_013[0]+-1*P_000102020*R_021[0]+P_000102120*R_022[0]+-1*P_000102220*R_023[0]+P_000202020*R_031[0]+-1*P_000202120*R_032[0]+P_000202220*R_033[0]; double PR_001000021011=P_001000021*R_011[0]+-1*P_001000121*R_012[0]+P_001000221*R_013[0]+-1*P_001000321*R_014[0]+-1*P_101000021*R_111[0]+P_101000121*R_112[0]+-1*P_101000221*R_113[0]+P_101000321*R_114[0]; double PR_000001021011=P_000001021*R_011[0]+-1*P_000001121*R_012[0]+P_000001221*R_013[0]+-1*P_000001321*R_014[0]+-1*P_000101021*R_021[0]+P_000101121*R_022[0]+-1*P_000101221*R_023[0]+P_000101321*R_024[0]; double PR_000000022011=P_000000022*R_011[0]+-1*P_000000122*R_012[0]+P_000000222*R_013[0]+-1*P_000000322*R_014[0]+P_000000422*R_015[0]; double PR_022000000020=P_022000000*R_020[0]+-1*P_122000000*R_120[0]+P_222000000*R_220[0]+-1*P_322000000*R_320[0]+P_422000000*R_420[0]; double PR_021001000020=P_021001000*R_020[0]+-1*P_021101000*R_030[0]+-1*P_121001000*R_120[0]+P_121101000*R_130[0]+P_221001000*R_220[0]+-1*P_221101000*R_230[0]+-1*P_321001000*R_320[0]+P_321101000*R_330[0]; double PR_020002000020=P_020002000*R_020[0]+-1*P_020102000*R_030[0]+P_020202000*R_040[0]+-1*P_120002000*R_120[0]+P_120102000*R_130[0]+-1*P_120202000*R_140[0]+P_220002000*R_220[0]+-1*P_220102000*R_230[0]+P_220202000*R_240[0]; double PR_021000001020=P_021000001*R_020[0]+-1*P_021000101*R_021[0]+-1*P_121000001*R_120[0]+P_121000101*R_121[0]+P_221000001*R_220[0]+-1*P_221000101*R_221[0]+-1*P_321000001*R_320[0]+P_321000101*R_321[0]; double PR_020001001020=P_020001001*R_020[0]+-1*P_020001101*R_021[0]+-1*P_020101001*R_030[0]+P_020101101*R_031[0]+-1*P_120001001*R_120[0]+P_120001101*R_121[0]+P_120101001*R_130[0]+-1*P_120101101*R_131[0]+P_220001001*R_220[0]+-1*P_220001101*R_221[0]+-1*P_220101001*R_230[0]+P_220101101*R_231[0]; double PR_020000002020=P_020000002*R_020[0]+-1*P_020000102*R_021[0]+P_020000202*R_022[0]+-1*P_120000002*R_120[0]+P_120000102*R_121[0]+-1*P_120000202*R_122[0]+P_220000002*R_220[0]+-1*P_220000102*R_221[0]+P_220000202*R_222[0]; double PR_012010000020=P_012010000*R_020[0]+-1*P_012110000*R_030[0]+-1*P_112010000*R_120[0]+P_112110000*R_130[0]+P_212010000*R_220[0]+-1*P_212110000*R_230[0]+-1*P_312010000*R_320[0]+P_312110000*R_330[0]; double PR_011011000020=P_011011000*R_020[0]+-1*P_011111000*R_030[0]+P_011211000*R_040[0]+-1*P_111011000*R_120[0]+P_111111000*R_130[0]+-1*P_111211000*R_140[0]+P_211011000*R_220[0]+-1*P_211111000*R_230[0]+P_211211000*R_240[0]; double PR_010012000020=P_010012000*R_020[0]+-1*P_010112000*R_030[0]+P_010212000*R_040[0]+-1*P_010312000*R_050[0]+-1*P_110012000*R_120[0]+P_110112000*R_130[0]+-1*P_110212000*R_140[0]+P_110312000*R_150[0]; double PR_011010001020=P_011010001*R_020[0]+-1*P_011010101*R_021[0]+-1*P_011110001*R_030[0]+P_011110101*R_031[0]+-1*P_111010001*R_120[0]+P_111010101*R_121[0]+P_111110001*R_130[0]+-1*P_111110101*R_131[0]+P_211010001*R_220[0]+-1*P_211010101*R_221[0]+-1*P_211110001*R_230[0]+P_211110101*R_231[0]; double PR_010011001020=P_010011001*R_020[0]+-1*P_010011101*R_021[0]+-1*P_010111001*R_030[0]+P_010111101*R_031[0]+P_010211001*R_040[0]+-1*P_010211101*R_041[0]+-1*P_110011001*R_120[0]+P_110011101*R_121[0]+P_110111001*R_130[0]+-1*P_110111101*R_131[0]+-1*P_110211001*R_140[0]+P_110211101*R_141[0]; double PR_010010002020=P_010010002*R_020[0]+-1*P_010010102*R_021[0]+P_010010202*R_022[0]+-1*P_010110002*R_030[0]+P_010110102*R_031[0]+-1*P_010110202*R_032[0]+-1*P_110010002*R_120[0]+P_110010102*R_121[0]+-1*P_110010202*R_122[0]+P_110110002*R_130[0]+-1*P_110110102*R_131[0]+P_110110202*R_132[0]; double PR_002020000020=P_002020000*R_020[0]+-1*P_002120000*R_030[0]+P_002220000*R_040[0]+-1*P_102020000*R_120[0]+P_102120000*R_130[0]+-1*P_102220000*R_140[0]+P_202020000*R_220[0]+-1*P_202120000*R_230[0]+P_202220000*R_240[0]; double PR_001021000020=P_001021000*R_020[0]+-1*P_001121000*R_030[0]+P_001221000*R_040[0]+-1*P_001321000*R_050[0]+-1*P_101021000*R_120[0]+P_101121000*R_130[0]+-1*P_101221000*R_140[0]+P_101321000*R_150[0]; double PR_000022000020=P_000022000*R_020[0]+-1*P_000122000*R_030[0]+P_000222000*R_040[0]+-1*P_000322000*R_050[0]+P_000422000*R_060[0]; double PR_001020001020=P_001020001*R_020[0]+-1*P_001020101*R_021[0]+-1*P_001120001*R_030[0]+P_001120101*R_031[0]+P_001220001*R_040[0]+-1*P_001220101*R_041[0]+-1*P_101020001*R_120[0]+P_101020101*R_121[0]+P_101120001*R_130[0]+-1*P_101120101*R_131[0]+-1*P_101220001*R_140[0]+P_101220101*R_141[0]; double PR_000021001020=P_000021001*R_020[0]+-1*P_000021101*R_021[0]+-1*P_000121001*R_030[0]+P_000121101*R_031[0]+P_000221001*R_040[0]+-1*P_000221101*R_041[0]+-1*P_000321001*R_050[0]+P_000321101*R_051[0]; double PR_000020002020=P_000020002*R_020[0]+-1*P_000020102*R_021[0]+P_000020202*R_022[0]+-1*P_000120002*R_030[0]+P_000120102*R_031[0]+-1*P_000120202*R_032[0]+P_000220002*R_040[0]+-1*P_000220102*R_041[0]+P_000220202*R_042[0]; double PR_012000010020=P_012000010*R_020[0]+-1*P_012000110*R_021[0]+-1*P_112000010*R_120[0]+P_112000110*R_121[0]+P_212000010*R_220[0]+-1*P_212000110*R_221[0]+-1*P_312000010*R_320[0]+P_312000110*R_321[0]; double PR_011001010020=P_011001010*R_020[0]+-1*P_011001110*R_021[0]+-1*P_011101010*R_030[0]+P_011101110*R_031[0]+-1*P_111001010*R_120[0]+P_111001110*R_121[0]+P_111101010*R_130[0]+-1*P_111101110*R_131[0]+P_211001010*R_220[0]+-1*P_211001110*R_221[0]+-1*P_211101010*R_230[0]+P_211101110*R_231[0]; double PR_010002010020=P_010002010*R_020[0]+-1*P_010002110*R_021[0]+-1*P_010102010*R_030[0]+P_010102110*R_031[0]+P_010202010*R_040[0]+-1*P_010202110*R_041[0]+-1*P_110002010*R_120[0]+P_110002110*R_121[0]+P_110102010*R_130[0]+-1*P_110102110*R_131[0]+-1*P_110202010*R_140[0]+P_110202110*R_141[0]; double PR_011000011020=P_011000011*R_020[0]+-1*P_011000111*R_021[0]+P_011000211*R_022[0]+-1*P_111000011*R_120[0]+P_111000111*R_121[0]+-1*P_111000211*R_122[0]+P_211000011*R_220[0]+-1*P_211000111*R_221[0]+P_211000211*R_222[0]; double PR_010001011020=P_010001011*R_020[0]+-1*P_010001111*R_021[0]+P_010001211*R_022[0]+-1*P_010101011*R_030[0]+P_010101111*R_031[0]+-1*P_010101211*R_032[0]+-1*P_110001011*R_120[0]+P_110001111*R_121[0]+-1*P_110001211*R_122[0]+P_110101011*R_130[0]+-1*P_110101111*R_131[0]+P_110101211*R_132[0]; double PR_010000012020=P_010000012*R_020[0]+-1*P_010000112*R_021[0]+P_010000212*R_022[0]+-1*P_010000312*R_023[0]+-1*P_110000012*R_120[0]+P_110000112*R_121[0]+-1*P_110000212*R_122[0]+P_110000312*R_123[0]; double PR_002010010020=P_002010010*R_020[0]+-1*P_002010110*R_021[0]+-1*P_002110010*R_030[0]+P_002110110*R_031[0]+-1*P_102010010*R_120[0]+P_102010110*R_121[0]+P_102110010*R_130[0]+-1*P_102110110*R_131[0]+P_202010010*R_220[0]+-1*P_202010110*R_221[0]+-1*P_202110010*R_230[0]+P_202110110*R_231[0]; double PR_001011010020=P_001011010*R_020[0]+-1*P_001011110*R_021[0]+-1*P_001111010*R_030[0]+P_001111110*R_031[0]+P_001211010*R_040[0]+-1*P_001211110*R_041[0]+-1*P_101011010*R_120[0]+P_101011110*R_121[0]+P_101111010*R_130[0]+-1*P_101111110*R_131[0]+-1*P_101211010*R_140[0]+P_101211110*R_141[0]; double PR_000012010020=P_000012010*R_020[0]+-1*P_000012110*R_021[0]+-1*P_000112010*R_030[0]+P_000112110*R_031[0]+P_000212010*R_040[0]+-1*P_000212110*R_041[0]+-1*P_000312010*R_050[0]+P_000312110*R_051[0]; double PR_001010011020=P_001010011*R_020[0]+-1*P_001010111*R_021[0]+P_001010211*R_022[0]+-1*P_001110011*R_030[0]+P_001110111*R_031[0]+-1*P_001110211*R_032[0]+-1*P_101010011*R_120[0]+P_101010111*R_121[0]+-1*P_101010211*R_122[0]+P_101110011*R_130[0]+-1*P_101110111*R_131[0]+P_101110211*R_132[0]; double PR_000011011020=P_000011011*R_020[0]+-1*P_000011111*R_021[0]+P_000011211*R_022[0]+-1*P_000111011*R_030[0]+P_000111111*R_031[0]+-1*P_000111211*R_032[0]+P_000211011*R_040[0]+-1*P_000211111*R_041[0]+P_000211211*R_042[0]; double PR_000010012020=P_000010012*R_020[0]+-1*P_000010112*R_021[0]+P_000010212*R_022[0]+-1*P_000010312*R_023[0]+-1*P_000110012*R_030[0]+P_000110112*R_031[0]+-1*P_000110212*R_032[0]+P_000110312*R_033[0]; double PR_002000020020=P_002000020*R_020[0]+-1*P_002000120*R_021[0]+P_002000220*R_022[0]+-1*P_102000020*R_120[0]+P_102000120*R_121[0]+-1*P_102000220*R_122[0]+P_202000020*R_220[0]+-1*P_202000120*R_221[0]+P_202000220*R_222[0]; double PR_001001020020=P_001001020*R_020[0]+-1*P_001001120*R_021[0]+P_001001220*R_022[0]+-1*P_001101020*R_030[0]+P_001101120*R_031[0]+-1*P_001101220*R_032[0]+-1*P_101001020*R_120[0]+P_101001120*R_121[0]+-1*P_101001220*R_122[0]+P_101101020*R_130[0]+-1*P_101101120*R_131[0]+P_101101220*R_132[0]; double PR_000002020020=P_000002020*R_020[0]+-1*P_000002120*R_021[0]+P_000002220*R_022[0]+-1*P_000102020*R_030[0]+P_000102120*R_031[0]+-1*P_000102220*R_032[0]+P_000202020*R_040[0]+-1*P_000202120*R_041[0]+P_000202220*R_042[0]; double PR_001000021020=P_001000021*R_020[0]+-1*P_001000121*R_021[0]+P_001000221*R_022[0]+-1*P_001000321*R_023[0]+-1*P_101000021*R_120[0]+P_101000121*R_121[0]+-1*P_101000221*R_122[0]+P_101000321*R_123[0]; double PR_000001021020=P_000001021*R_020[0]+-1*P_000001121*R_021[0]+P_000001221*R_022[0]+-1*P_000001321*R_023[0]+-1*P_000101021*R_030[0]+P_000101121*R_031[0]+-1*P_000101221*R_032[0]+P_000101321*R_033[0]; double PR_000000022020=P_000000022*R_020[0]+-1*P_000000122*R_021[0]+P_000000222*R_022[0]+-1*P_000000322*R_023[0]+P_000000422*R_024[0]; double PR_022000000101=P_022000000*R_101[0]+-1*P_122000000*R_201[0]+P_222000000*R_301[0]+-1*P_322000000*R_401[0]+P_422000000*R_501[0]; double PR_021001000101=P_021001000*R_101[0]+-1*P_021101000*R_111[0]+-1*P_121001000*R_201[0]+P_121101000*R_211[0]+P_221001000*R_301[0]+-1*P_221101000*R_311[0]+-1*P_321001000*R_401[0]+P_321101000*R_411[0]; double PR_020002000101=P_020002000*R_101[0]+-1*P_020102000*R_111[0]+P_020202000*R_121[0]+-1*P_120002000*R_201[0]+P_120102000*R_211[0]+-1*P_120202000*R_221[0]+P_220002000*R_301[0]+-1*P_220102000*R_311[0]+P_220202000*R_321[0]; double PR_021000001101=P_021000001*R_101[0]+-1*P_021000101*R_102[0]+-1*P_121000001*R_201[0]+P_121000101*R_202[0]+P_221000001*R_301[0]+-1*P_221000101*R_302[0]+-1*P_321000001*R_401[0]+P_321000101*R_402[0]; double PR_020001001101=P_020001001*R_101[0]+-1*P_020001101*R_102[0]+-1*P_020101001*R_111[0]+P_020101101*R_112[0]+-1*P_120001001*R_201[0]+P_120001101*R_202[0]+P_120101001*R_211[0]+-1*P_120101101*R_212[0]+P_220001001*R_301[0]+-1*P_220001101*R_302[0]+-1*P_220101001*R_311[0]+P_220101101*R_312[0]; double PR_020000002101=P_020000002*R_101[0]+-1*P_020000102*R_102[0]+P_020000202*R_103[0]+-1*P_120000002*R_201[0]+P_120000102*R_202[0]+-1*P_120000202*R_203[0]+P_220000002*R_301[0]+-1*P_220000102*R_302[0]+P_220000202*R_303[0]; double PR_012010000101=P_012010000*R_101[0]+-1*P_012110000*R_111[0]+-1*P_112010000*R_201[0]+P_112110000*R_211[0]+P_212010000*R_301[0]+-1*P_212110000*R_311[0]+-1*P_312010000*R_401[0]+P_312110000*R_411[0]; double PR_011011000101=P_011011000*R_101[0]+-1*P_011111000*R_111[0]+P_011211000*R_121[0]+-1*P_111011000*R_201[0]+P_111111000*R_211[0]+-1*P_111211000*R_221[0]+P_211011000*R_301[0]+-1*P_211111000*R_311[0]+P_211211000*R_321[0]; double PR_010012000101=P_010012000*R_101[0]+-1*P_010112000*R_111[0]+P_010212000*R_121[0]+-1*P_010312000*R_131[0]+-1*P_110012000*R_201[0]+P_110112000*R_211[0]+-1*P_110212000*R_221[0]+P_110312000*R_231[0]; double PR_011010001101=P_011010001*R_101[0]+-1*P_011010101*R_102[0]+-1*P_011110001*R_111[0]+P_011110101*R_112[0]+-1*P_111010001*R_201[0]+P_111010101*R_202[0]+P_111110001*R_211[0]+-1*P_111110101*R_212[0]+P_211010001*R_301[0]+-1*P_211010101*R_302[0]+-1*P_211110001*R_311[0]+P_211110101*R_312[0]; double PR_010011001101=P_010011001*R_101[0]+-1*P_010011101*R_102[0]+-1*P_010111001*R_111[0]+P_010111101*R_112[0]+P_010211001*R_121[0]+-1*P_010211101*R_122[0]+-1*P_110011001*R_201[0]+P_110011101*R_202[0]+P_110111001*R_211[0]+-1*P_110111101*R_212[0]+-1*P_110211001*R_221[0]+P_110211101*R_222[0]; double PR_010010002101=P_010010002*R_101[0]+-1*P_010010102*R_102[0]+P_010010202*R_103[0]+-1*P_010110002*R_111[0]+P_010110102*R_112[0]+-1*P_010110202*R_113[0]+-1*P_110010002*R_201[0]+P_110010102*R_202[0]+-1*P_110010202*R_203[0]+P_110110002*R_211[0]+-1*P_110110102*R_212[0]+P_110110202*R_213[0]; double PR_002020000101=P_002020000*R_101[0]+-1*P_002120000*R_111[0]+P_002220000*R_121[0]+-1*P_102020000*R_201[0]+P_102120000*R_211[0]+-1*P_102220000*R_221[0]+P_202020000*R_301[0]+-1*P_202120000*R_311[0]+P_202220000*R_321[0]; double PR_001021000101=P_001021000*R_101[0]+-1*P_001121000*R_111[0]+P_001221000*R_121[0]+-1*P_001321000*R_131[0]+-1*P_101021000*R_201[0]+P_101121000*R_211[0]+-1*P_101221000*R_221[0]+P_101321000*R_231[0]; double PR_000022000101=P_000022000*R_101[0]+-1*P_000122000*R_111[0]+P_000222000*R_121[0]+-1*P_000322000*R_131[0]+P_000422000*R_141[0]; double PR_001020001101=P_001020001*R_101[0]+-1*P_001020101*R_102[0]+-1*P_001120001*R_111[0]+P_001120101*R_112[0]+P_001220001*R_121[0]+-1*P_001220101*R_122[0]+-1*P_101020001*R_201[0]+P_101020101*R_202[0]+P_101120001*R_211[0]+-1*P_101120101*R_212[0]+-1*P_101220001*R_221[0]+P_101220101*R_222[0]; double PR_000021001101=P_000021001*R_101[0]+-1*P_000021101*R_102[0]+-1*P_000121001*R_111[0]+P_000121101*R_112[0]+P_000221001*R_121[0]+-1*P_000221101*R_122[0]+-1*P_000321001*R_131[0]+P_000321101*R_132[0]; double PR_000020002101=P_000020002*R_101[0]+-1*P_000020102*R_102[0]+P_000020202*R_103[0]+-1*P_000120002*R_111[0]+P_000120102*R_112[0]+-1*P_000120202*R_113[0]+P_000220002*R_121[0]+-1*P_000220102*R_122[0]+P_000220202*R_123[0]; double PR_012000010101=P_012000010*R_101[0]+-1*P_012000110*R_102[0]+-1*P_112000010*R_201[0]+P_112000110*R_202[0]+P_212000010*R_301[0]+-1*P_212000110*R_302[0]+-1*P_312000010*R_401[0]+P_312000110*R_402[0]; double PR_011001010101=P_011001010*R_101[0]+-1*P_011001110*R_102[0]+-1*P_011101010*R_111[0]+P_011101110*R_112[0]+-1*P_111001010*R_201[0]+P_111001110*R_202[0]+P_111101010*R_211[0]+-1*P_111101110*R_212[0]+P_211001010*R_301[0]+-1*P_211001110*R_302[0]+-1*P_211101010*R_311[0]+P_211101110*R_312[0]; double PR_010002010101=P_010002010*R_101[0]+-1*P_010002110*R_102[0]+-1*P_010102010*R_111[0]+P_010102110*R_112[0]+P_010202010*R_121[0]+-1*P_010202110*R_122[0]+-1*P_110002010*R_201[0]+P_110002110*R_202[0]+P_110102010*R_211[0]+-1*P_110102110*R_212[0]+-1*P_110202010*R_221[0]+P_110202110*R_222[0]; double PR_011000011101=P_011000011*R_101[0]+-1*P_011000111*R_102[0]+P_011000211*R_103[0]+-1*P_111000011*R_201[0]+P_111000111*R_202[0]+-1*P_111000211*R_203[0]+P_211000011*R_301[0]+-1*P_211000111*R_302[0]+P_211000211*R_303[0]; double PR_010001011101=P_010001011*R_101[0]+-1*P_010001111*R_102[0]+P_010001211*R_103[0]+-1*P_010101011*R_111[0]+P_010101111*R_112[0]+-1*P_010101211*R_113[0]+-1*P_110001011*R_201[0]+P_110001111*R_202[0]+-1*P_110001211*R_203[0]+P_110101011*R_211[0]+-1*P_110101111*R_212[0]+P_110101211*R_213[0]; double PR_010000012101=P_010000012*R_101[0]+-1*P_010000112*R_102[0]+P_010000212*R_103[0]+-1*P_010000312*R_104[0]+-1*P_110000012*R_201[0]+P_110000112*R_202[0]+-1*P_110000212*R_203[0]+P_110000312*R_204[0]; double PR_002010010101=P_002010010*R_101[0]+-1*P_002010110*R_102[0]+-1*P_002110010*R_111[0]+P_002110110*R_112[0]+-1*P_102010010*R_201[0]+P_102010110*R_202[0]+P_102110010*R_211[0]+-1*P_102110110*R_212[0]+P_202010010*R_301[0]+-1*P_202010110*R_302[0]+-1*P_202110010*R_311[0]+P_202110110*R_312[0]; double PR_001011010101=P_001011010*R_101[0]+-1*P_001011110*R_102[0]+-1*P_001111010*R_111[0]+P_001111110*R_112[0]+P_001211010*R_121[0]+-1*P_001211110*R_122[0]+-1*P_101011010*R_201[0]+P_101011110*R_202[0]+P_101111010*R_211[0]+-1*P_101111110*R_212[0]+-1*P_101211010*R_221[0]+P_101211110*R_222[0]; double PR_000012010101=P_000012010*R_101[0]+-1*P_000012110*R_102[0]+-1*P_000112010*R_111[0]+P_000112110*R_112[0]+P_000212010*R_121[0]+-1*P_000212110*R_122[0]+-1*P_000312010*R_131[0]+P_000312110*R_132[0]; double PR_001010011101=P_001010011*R_101[0]+-1*P_001010111*R_102[0]+P_001010211*R_103[0]+-1*P_001110011*R_111[0]+P_001110111*R_112[0]+-1*P_001110211*R_113[0]+-1*P_101010011*R_201[0]+P_101010111*R_202[0]+-1*P_101010211*R_203[0]+P_101110011*R_211[0]+-1*P_101110111*R_212[0]+P_101110211*R_213[0]; double PR_000011011101=P_000011011*R_101[0]+-1*P_000011111*R_102[0]+P_000011211*R_103[0]+-1*P_000111011*R_111[0]+P_000111111*R_112[0]+-1*P_000111211*R_113[0]+P_000211011*R_121[0]+-1*P_000211111*R_122[0]+P_000211211*R_123[0]; double PR_000010012101=P_000010012*R_101[0]+-1*P_000010112*R_102[0]+P_000010212*R_103[0]+-1*P_000010312*R_104[0]+-1*P_000110012*R_111[0]+P_000110112*R_112[0]+-1*P_000110212*R_113[0]+P_000110312*R_114[0]; double PR_002000020101=P_002000020*R_101[0]+-1*P_002000120*R_102[0]+P_002000220*R_103[0]+-1*P_102000020*R_201[0]+P_102000120*R_202[0]+-1*P_102000220*R_203[0]+P_202000020*R_301[0]+-1*P_202000120*R_302[0]+P_202000220*R_303[0]; double PR_001001020101=P_001001020*R_101[0]+-1*P_001001120*R_102[0]+P_001001220*R_103[0]+-1*P_001101020*R_111[0]+P_001101120*R_112[0]+-1*P_001101220*R_113[0]+-1*P_101001020*R_201[0]+P_101001120*R_202[0]+-1*P_101001220*R_203[0]+P_101101020*R_211[0]+-1*P_101101120*R_212[0]+P_101101220*R_213[0]; double PR_000002020101=P_000002020*R_101[0]+-1*P_000002120*R_102[0]+P_000002220*R_103[0]+-1*P_000102020*R_111[0]+P_000102120*R_112[0]+-1*P_000102220*R_113[0]+P_000202020*R_121[0]+-1*P_000202120*R_122[0]+P_000202220*R_123[0]; double PR_001000021101=P_001000021*R_101[0]+-1*P_001000121*R_102[0]+P_001000221*R_103[0]+-1*P_001000321*R_104[0]+-1*P_101000021*R_201[0]+P_101000121*R_202[0]+-1*P_101000221*R_203[0]+P_101000321*R_204[0]; double PR_000001021101=P_000001021*R_101[0]+-1*P_000001121*R_102[0]+P_000001221*R_103[0]+-1*P_000001321*R_104[0]+-1*P_000101021*R_111[0]+P_000101121*R_112[0]+-1*P_000101221*R_113[0]+P_000101321*R_114[0]; double PR_000000022101=P_000000022*R_101[0]+-1*P_000000122*R_102[0]+P_000000222*R_103[0]+-1*P_000000322*R_104[0]+P_000000422*R_105[0]; double PR_022000000110=P_022000000*R_110[0]+-1*P_122000000*R_210[0]+P_222000000*R_310[0]+-1*P_322000000*R_410[0]+P_422000000*R_510[0]; double PR_021001000110=P_021001000*R_110[0]+-1*P_021101000*R_120[0]+-1*P_121001000*R_210[0]+P_121101000*R_220[0]+P_221001000*R_310[0]+-1*P_221101000*R_320[0]+-1*P_321001000*R_410[0]+P_321101000*R_420[0]; double PR_020002000110=P_020002000*R_110[0]+-1*P_020102000*R_120[0]+P_020202000*R_130[0]+-1*P_120002000*R_210[0]+P_120102000*R_220[0]+-1*P_120202000*R_230[0]+P_220002000*R_310[0]+-1*P_220102000*R_320[0]+P_220202000*R_330[0]; double PR_021000001110=P_021000001*R_110[0]+-1*P_021000101*R_111[0]+-1*P_121000001*R_210[0]+P_121000101*R_211[0]+P_221000001*R_310[0]+-1*P_221000101*R_311[0]+-1*P_321000001*R_410[0]+P_321000101*R_411[0]; double PR_020001001110=P_020001001*R_110[0]+-1*P_020001101*R_111[0]+-1*P_020101001*R_120[0]+P_020101101*R_121[0]+-1*P_120001001*R_210[0]+P_120001101*R_211[0]+P_120101001*R_220[0]+-1*P_120101101*R_221[0]+P_220001001*R_310[0]+-1*P_220001101*R_311[0]+-1*P_220101001*R_320[0]+P_220101101*R_321[0]; double PR_020000002110=P_020000002*R_110[0]+-1*P_020000102*R_111[0]+P_020000202*R_112[0]+-1*P_120000002*R_210[0]+P_120000102*R_211[0]+-1*P_120000202*R_212[0]+P_220000002*R_310[0]+-1*P_220000102*R_311[0]+P_220000202*R_312[0]; double PR_012010000110=P_012010000*R_110[0]+-1*P_012110000*R_120[0]+-1*P_112010000*R_210[0]+P_112110000*R_220[0]+P_212010000*R_310[0]+-1*P_212110000*R_320[0]+-1*P_312010000*R_410[0]+P_312110000*R_420[0]; double PR_011011000110=P_011011000*R_110[0]+-1*P_011111000*R_120[0]+P_011211000*R_130[0]+-1*P_111011000*R_210[0]+P_111111000*R_220[0]+-1*P_111211000*R_230[0]+P_211011000*R_310[0]+-1*P_211111000*R_320[0]+P_211211000*R_330[0]; double PR_010012000110=P_010012000*R_110[0]+-1*P_010112000*R_120[0]+P_010212000*R_130[0]+-1*P_010312000*R_140[0]+-1*P_110012000*R_210[0]+P_110112000*R_220[0]+-1*P_110212000*R_230[0]+P_110312000*R_240[0]; double PR_011010001110=P_011010001*R_110[0]+-1*P_011010101*R_111[0]+-1*P_011110001*R_120[0]+P_011110101*R_121[0]+-1*P_111010001*R_210[0]+P_111010101*R_211[0]+P_111110001*R_220[0]+-1*P_111110101*R_221[0]+P_211010001*R_310[0]+-1*P_211010101*R_311[0]+-1*P_211110001*R_320[0]+P_211110101*R_321[0]; double PR_010011001110=P_010011001*R_110[0]+-1*P_010011101*R_111[0]+-1*P_010111001*R_120[0]+P_010111101*R_121[0]+P_010211001*R_130[0]+-1*P_010211101*R_131[0]+-1*P_110011001*R_210[0]+P_110011101*R_211[0]+P_110111001*R_220[0]+-1*P_110111101*R_221[0]+-1*P_110211001*R_230[0]+P_110211101*R_231[0]; double PR_010010002110=P_010010002*R_110[0]+-1*P_010010102*R_111[0]+P_010010202*R_112[0]+-1*P_010110002*R_120[0]+P_010110102*R_121[0]+-1*P_010110202*R_122[0]+-1*P_110010002*R_210[0]+P_110010102*R_211[0]+-1*P_110010202*R_212[0]+P_110110002*R_220[0]+-1*P_110110102*R_221[0]+P_110110202*R_222[0]; double PR_002020000110=P_002020000*R_110[0]+-1*P_002120000*R_120[0]+P_002220000*R_130[0]+-1*P_102020000*R_210[0]+P_102120000*R_220[0]+-1*P_102220000*R_230[0]+P_202020000*R_310[0]+-1*P_202120000*R_320[0]+P_202220000*R_330[0]; double PR_001021000110=P_001021000*R_110[0]+-1*P_001121000*R_120[0]+P_001221000*R_130[0]+-1*P_001321000*R_140[0]+-1*P_101021000*R_210[0]+P_101121000*R_220[0]+-1*P_101221000*R_230[0]+P_101321000*R_240[0]; double PR_000022000110=P_000022000*R_110[0]+-1*P_000122000*R_120[0]+P_000222000*R_130[0]+-1*P_000322000*R_140[0]+P_000422000*R_150[0]; double PR_001020001110=P_001020001*R_110[0]+-1*P_001020101*R_111[0]+-1*P_001120001*R_120[0]+P_001120101*R_121[0]+P_001220001*R_130[0]+-1*P_001220101*R_131[0]+-1*P_101020001*R_210[0]+P_101020101*R_211[0]+P_101120001*R_220[0]+-1*P_101120101*R_221[0]+-1*P_101220001*R_230[0]+P_101220101*R_231[0]; double PR_000021001110=P_000021001*R_110[0]+-1*P_000021101*R_111[0]+-1*P_000121001*R_120[0]+P_000121101*R_121[0]+P_000221001*R_130[0]+-1*P_000221101*R_131[0]+-1*P_000321001*R_140[0]+P_000321101*R_141[0]; double PR_000020002110=P_000020002*R_110[0]+-1*P_000020102*R_111[0]+P_000020202*R_112[0]+-1*P_000120002*R_120[0]+P_000120102*R_121[0]+-1*P_000120202*R_122[0]+P_000220002*R_130[0]+-1*P_000220102*R_131[0]+P_000220202*R_132[0]; double PR_012000010110=P_012000010*R_110[0]+-1*P_012000110*R_111[0]+-1*P_112000010*R_210[0]+P_112000110*R_211[0]+P_212000010*R_310[0]+-1*P_212000110*R_311[0]+-1*P_312000010*R_410[0]+P_312000110*R_411[0]; double PR_011001010110=P_011001010*R_110[0]+-1*P_011001110*R_111[0]+-1*P_011101010*R_120[0]+P_011101110*R_121[0]+-1*P_111001010*R_210[0]+P_111001110*R_211[0]+P_111101010*R_220[0]+-1*P_111101110*R_221[0]+P_211001010*R_310[0]+-1*P_211001110*R_311[0]+-1*P_211101010*R_320[0]+P_211101110*R_321[0]; double PR_010002010110=P_010002010*R_110[0]+-1*P_010002110*R_111[0]+-1*P_010102010*R_120[0]+P_010102110*R_121[0]+P_010202010*R_130[0]+-1*P_010202110*R_131[0]+-1*P_110002010*R_210[0]+P_110002110*R_211[0]+P_110102010*R_220[0]+-1*P_110102110*R_221[0]+-1*P_110202010*R_230[0]+P_110202110*R_231[0]; double PR_011000011110=P_011000011*R_110[0]+-1*P_011000111*R_111[0]+P_011000211*R_112[0]+-1*P_111000011*R_210[0]+P_111000111*R_211[0]+-1*P_111000211*R_212[0]+P_211000011*R_310[0]+-1*P_211000111*R_311[0]+P_211000211*R_312[0]; double PR_010001011110=P_010001011*R_110[0]+-1*P_010001111*R_111[0]+P_010001211*R_112[0]+-1*P_010101011*R_120[0]+P_010101111*R_121[0]+-1*P_010101211*R_122[0]+-1*P_110001011*R_210[0]+P_110001111*R_211[0]+-1*P_110001211*R_212[0]+P_110101011*R_220[0]+-1*P_110101111*R_221[0]+P_110101211*R_222[0]; double PR_010000012110=P_010000012*R_110[0]+-1*P_010000112*R_111[0]+P_010000212*R_112[0]+-1*P_010000312*R_113[0]+-1*P_110000012*R_210[0]+P_110000112*R_211[0]+-1*P_110000212*R_212[0]+P_110000312*R_213[0]; double PR_002010010110=P_002010010*R_110[0]+-1*P_002010110*R_111[0]+-1*P_002110010*R_120[0]+P_002110110*R_121[0]+-1*P_102010010*R_210[0]+P_102010110*R_211[0]+P_102110010*R_220[0]+-1*P_102110110*R_221[0]+P_202010010*R_310[0]+-1*P_202010110*R_311[0]+-1*P_202110010*R_320[0]+P_202110110*R_321[0]; double PR_001011010110=P_001011010*R_110[0]+-1*P_001011110*R_111[0]+-1*P_001111010*R_120[0]+P_001111110*R_121[0]+P_001211010*R_130[0]+-1*P_001211110*R_131[0]+-1*P_101011010*R_210[0]+P_101011110*R_211[0]+P_101111010*R_220[0]+-1*P_101111110*R_221[0]+-1*P_101211010*R_230[0]+P_101211110*R_231[0]; double PR_000012010110=P_000012010*R_110[0]+-1*P_000012110*R_111[0]+-1*P_000112010*R_120[0]+P_000112110*R_121[0]+P_000212010*R_130[0]+-1*P_000212110*R_131[0]+-1*P_000312010*R_140[0]+P_000312110*R_141[0]; double PR_001010011110=P_001010011*R_110[0]+-1*P_001010111*R_111[0]+P_001010211*R_112[0]+-1*P_001110011*R_120[0]+P_001110111*R_121[0]+-1*P_001110211*R_122[0]+-1*P_101010011*R_210[0]+P_101010111*R_211[0]+-1*P_101010211*R_212[0]+P_101110011*R_220[0]+-1*P_101110111*R_221[0]+P_101110211*R_222[0]; double PR_000011011110=P_000011011*R_110[0]+-1*P_000011111*R_111[0]+P_000011211*R_112[0]+-1*P_000111011*R_120[0]+P_000111111*R_121[0]+-1*P_000111211*R_122[0]+P_000211011*R_130[0]+-1*P_000211111*R_131[0]+P_000211211*R_132[0]; double PR_000010012110=P_000010012*R_110[0]+-1*P_000010112*R_111[0]+P_000010212*R_112[0]+-1*P_000010312*R_113[0]+-1*P_000110012*R_120[0]+P_000110112*R_121[0]+-1*P_000110212*R_122[0]+P_000110312*R_123[0]; double PR_002000020110=P_002000020*R_110[0]+-1*P_002000120*R_111[0]+P_002000220*R_112[0]+-1*P_102000020*R_210[0]+P_102000120*R_211[0]+-1*P_102000220*R_212[0]+P_202000020*R_310[0]+-1*P_202000120*R_311[0]+P_202000220*R_312[0]; double PR_001001020110=P_001001020*R_110[0]+-1*P_001001120*R_111[0]+P_001001220*R_112[0]+-1*P_001101020*R_120[0]+P_001101120*R_121[0]+-1*P_001101220*R_122[0]+-1*P_101001020*R_210[0]+P_101001120*R_211[0]+-1*P_101001220*R_212[0]+P_101101020*R_220[0]+-1*P_101101120*R_221[0]+P_101101220*R_222[0]; double PR_000002020110=P_000002020*R_110[0]+-1*P_000002120*R_111[0]+P_000002220*R_112[0]+-1*P_000102020*R_120[0]+P_000102120*R_121[0]+-1*P_000102220*R_122[0]+P_000202020*R_130[0]+-1*P_000202120*R_131[0]+P_000202220*R_132[0]; double PR_001000021110=P_001000021*R_110[0]+-1*P_001000121*R_111[0]+P_001000221*R_112[0]+-1*P_001000321*R_113[0]+-1*P_101000021*R_210[0]+P_101000121*R_211[0]+-1*P_101000221*R_212[0]+P_101000321*R_213[0]; double PR_000001021110=P_000001021*R_110[0]+-1*P_000001121*R_111[0]+P_000001221*R_112[0]+-1*P_000001321*R_113[0]+-1*P_000101021*R_120[0]+P_000101121*R_121[0]+-1*P_000101221*R_122[0]+P_000101321*R_123[0]; double PR_000000022110=P_000000022*R_110[0]+-1*P_000000122*R_111[0]+P_000000222*R_112[0]+-1*P_000000322*R_113[0]+P_000000422*R_114[0]; double PR_022000000200=P_022000000*R_200[0]+-1*P_122000000*R_300[0]+P_222000000*R_400[0]+-1*P_322000000*R_500[0]+P_422000000*R_600[0]; double PR_021001000200=P_021001000*R_200[0]+-1*P_021101000*R_210[0]+-1*P_121001000*R_300[0]+P_121101000*R_310[0]+P_221001000*R_400[0]+-1*P_221101000*R_410[0]+-1*P_321001000*R_500[0]+P_321101000*R_510[0]; double PR_020002000200=P_020002000*R_200[0]+-1*P_020102000*R_210[0]+P_020202000*R_220[0]+-1*P_120002000*R_300[0]+P_120102000*R_310[0]+-1*P_120202000*R_320[0]+P_220002000*R_400[0]+-1*P_220102000*R_410[0]+P_220202000*R_420[0]; double PR_021000001200=P_021000001*R_200[0]+-1*P_021000101*R_201[0]+-1*P_121000001*R_300[0]+P_121000101*R_301[0]+P_221000001*R_400[0]+-1*P_221000101*R_401[0]+-1*P_321000001*R_500[0]+P_321000101*R_501[0]; double PR_020001001200=P_020001001*R_200[0]+-1*P_020001101*R_201[0]+-1*P_020101001*R_210[0]+P_020101101*R_211[0]+-1*P_120001001*R_300[0]+P_120001101*R_301[0]+P_120101001*R_310[0]+-1*P_120101101*R_311[0]+P_220001001*R_400[0]+-1*P_220001101*R_401[0]+-1*P_220101001*R_410[0]+P_220101101*R_411[0]; double PR_020000002200=P_020000002*R_200[0]+-1*P_020000102*R_201[0]+P_020000202*R_202[0]+-1*P_120000002*R_300[0]+P_120000102*R_301[0]+-1*P_120000202*R_302[0]+P_220000002*R_400[0]+-1*P_220000102*R_401[0]+P_220000202*R_402[0]; double PR_012010000200=P_012010000*R_200[0]+-1*P_012110000*R_210[0]+-1*P_112010000*R_300[0]+P_112110000*R_310[0]+P_212010000*R_400[0]+-1*P_212110000*R_410[0]+-1*P_312010000*R_500[0]+P_312110000*R_510[0]; double PR_011011000200=P_011011000*R_200[0]+-1*P_011111000*R_210[0]+P_011211000*R_220[0]+-1*P_111011000*R_300[0]+P_111111000*R_310[0]+-1*P_111211000*R_320[0]+P_211011000*R_400[0]+-1*P_211111000*R_410[0]+P_211211000*R_420[0]; double PR_010012000200=P_010012000*R_200[0]+-1*P_010112000*R_210[0]+P_010212000*R_220[0]+-1*P_010312000*R_230[0]+-1*P_110012000*R_300[0]+P_110112000*R_310[0]+-1*P_110212000*R_320[0]+P_110312000*R_330[0]; double PR_011010001200=P_011010001*R_200[0]+-1*P_011010101*R_201[0]+-1*P_011110001*R_210[0]+P_011110101*R_211[0]+-1*P_111010001*R_300[0]+P_111010101*R_301[0]+P_111110001*R_310[0]+-1*P_111110101*R_311[0]+P_211010001*R_400[0]+-1*P_211010101*R_401[0]+-1*P_211110001*R_410[0]+P_211110101*R_411[0]; double PR_010011001200=P_010011001*R_200[0]+-1*P_010011101*R_201[0]+-1*P_010111001*R_210[0]+P_010111101*R_211[0]+P_010211001*R_220[0]+-1*P_010211101*R_221[0]+-1*P_110011001*R_300[0]+P_110011101*R_301[0]+P_110111001*R_310[0]+-1*P_110111101*R_311[0]+-1*P_110211001*R_320[0]+P_110211101*R_321[0]; double PR_010010002200=P_010010002*R_200[0]+-1*P_010010102*R_201[0]+P_010010202*R_202[0]+-1*P_010110002*R_210[0]+P_010110102*R_211[0]+-1*P_010110202*R_212[0]+-1*P_110010002*R_300[0]+P_110010102*R_301[0]+-1*P_110010202*R_302[0]+P_110110002*R_310[0]+-1*P_110110102*R_311[0]+P_110110202*R_312[0]; double PR_002020000200=P_002020000*R_200[0]+-1*P_002120000*R_210[0]+P_002220000*R_220[0]+-1*P_102020000*R_300[0]+P_102120000*R_310[0]+-1*P_102220000*R_320[0]+P_202020000*R_400[0]+-1*P_202120000*R_410[0]+P_202220000*R_420[0]; double PR_001021000200=P_001021000*R_200[0]+-1*P_001121000*R_210[0]+P_001221000*R_220[0]+-1*P_001321000*R_230[0]+-1*P_101021000*R_300[0]+P_101121000*R_310[0]+-1*P_101221000*R_320[0]+P_101321000*R_330[0]; double PR_000022000200=P_000022000*R_200[0]+-1*P_000122000*R_210[0]+P_000222000*R_220[0]+-1*P_000322000*R_230[0]+P_000422000*R_240[0]; double PR_001020001200=P_001020001*R_200[0]+-1*P_001020101*R_201[0]+-1*P_001120001*R_210[0]+P_001120101*R_211[0]+P_001220001*R_220[0]+-1*P_001220101*R_221[0]+-1*P_101020001*R_300[0]+P_101020101*R_301[0]+P_101120001*R_310[0]+-1*P_101120101*R_311[0]+-1*P_101220001*R_320[0]+P_101220101*R_321[0]; double PR_000021001200=P_000021001*R_200[0]+-1*P_000021101*R_201[0]+-1*P_000121001*R_210[0]+P_000121101*R_211[0]+P_000221001*R_220[0]+-1*P_000221101*R_221[0]+-1*P_000321001*R_230[0]+P_000321101*R_231[0]; double PR_000020002200=P_000020002*R_200[0]+-1*P_000020102*R_201[0]+P_000020202*R_202[0]+-1*P_000120002*R_210[0]+P_000120102*R_211[0]+-1*P_000120202*R_212[0]+P_000220002*R_220[0]+-1*P_000220102*R_221[0]+P_000220202*R_222[0]; double PR_012000010200=P_012000010*R_200[0]+-1*P_012000110*R_201[0]+-1*P_112000010*R_300[0]+P_112000110*R_301[0]+P_212000010*R_400[0]+-1*P_212000110*R_401[0]+-1*P_312000010*R_500[0]+P_312000110*R_501[0]; double PR_011001010200=P_011001010*R_200[0]+-1*P_011001110*R_201[0]+-1*P_011101010*R_210[0]+P_011101110*R_211[0]+-1*P_111001010*R_300[0]+P_111001110*R_301[0]+P_111101010*R_310[0]+-1*P_111101110*R_311[0]+P_211001010*R_400[0]+-1*P_211001110*R_401[0]+-1*P_211101010*R_410[0]+P_211101110*R_411[0]; double PR_010002010200=P_010002010*R_200[0]+-1*P_010002110*R_201[0]+-1*P_010102010*R_210[0]+P_010102110*R_211[0]+P_010202010*R_220[0]+-1*P_010202110*R_221[0]+-1*P_110002010*R_300[0]+P_110002110*R_301[0]+P_110102010*R_310[0]+-1*P_110102110*R_311[0]+-1*P_110202010*R_320[0]+P_110202110*R_321[0]; double PR_011000011200=P_011000011*R_200[0]+-1*P_011000111*R_201[0]+P_011000211*R_202[0]+-1*P_111000011*R_300[0]+P_111000111*R_301[0]+-1*P_111000211*R_302[0]+P_211000011*R_400[0]+-1*P_211000111*R_401[0]+P_211000211*R_402[0]; double PR_010001011200=P_010001011*R_200[0]+-1*P_010001111*R_201[0]+P_010001211*R_202[0]+-1*P_010101011*R_210[0]+P_010101111*R_211[0]+-1*P_010101211*R_212[0]+-1*P_110001011*R_300[0]+P_110001111*R_301[0]+-1*P_110001211*R_302[0]+P_110101011*R_310[0]+-1*P_110101111*R_311[0]+P_110101211*R_312[0]; double PR_010000012200=P_010000012*R_200[0]+-1*P_010000112*R_201[0]+P_010000212*R_202[0]+-1*P_010000312*R_203[0]+-1*P_110000012*R_300[0]+P_110000112*R_301[0]+-1*P_110000212*R_302[0]+P_110000312*R_303[0]; double PR_002010010200=P_002010010*R_200[0]+-1*P_002010110*R_201[0]+-1*P_002110010*R_210[0]+P_002110110*R_211[0]+-1*P_102010010*R_300[0]+P_102010110*R_301[0]+P_102110010*R_310[0]+-1*P_102110110*R_311[0]+P_202010010*R_400[0]+-1*P_202010110*R_401[0]+-1*P_202110010*R_410[0]+P_202110110*R_411[0]; double PR_001011010200=P_001011010*R_200[0]+-1*P_001011110*R_201[0]+-1*P_001111010*R_210[0]+P_001111110*R_211[0]+P_001211010*R_220[0]+-1*P_001211110*R_221[0]+-1*P_101011010*R_300[0]+P_101011110*R_301[0]+P_101111010*R_310[0]+-1*P_101111110*R_311[0]+-1*P_101211010*R_320[0]+P_101211110*R_321[0]; double PR_000012010200=P_000012010*R_200[0]+-1*P_000012110*R_201[0]+-1*P_000112010*R_210[0]+P_000112110*R_211[0]+P_000212010*R_220[0]+-1*P_000212110*R_221[0]+-1*P_000312010*R_230[0]+P_000312110*R_231[0]; double PR_001010011200=P_001010011*R_200[0]+-1*P_001010111*R_201[0]+P_001010211*R_202[0]+-1*P_001110011*R_210[0]+P_001110111*R_211[0]+-1*P_001110211*R_212[0]+-1*P_101010011*R_300[0]+P_101010111*R_301[0]+-1*P_101010211*R_302[0]+P_101110011*R_310[0]+-1*P_101110111*R_311[0]+P_101110211*R_312[0]; double PR_000011011200=P_000011011*R_200[0]+-1*P_000011111*R_201[0]+P_000011211*R_202[0]+-1*P_000111011*R_210[0]+P_000111111*R_211[0]+-1*P_000111211*R_212[0]+P_000211011*R_220[0]+-1*P_000211111*R_221[0]+P_000211211*R_222[0]; double PR_000010012200=P_000010012*R_200[0]+-1*P_000010112*R_201[0]+P_000010212*R_202[0]+-1*P_000010312*R_203[0]+-1*P_000110012*R_210[0]+P_000110112*R_211[0]+-1*P_000110212*R_212[0]+P_000110312*R_213[0]; double PR_002000020200=P_002000020*R_200[0]+-1*P_002000120*R_201[0]+P_002000220*R_202[0]+-1*P_102000020*R_300[0]+P_102000120*R_301[0]+-1*P_102000220*R_302[0]+P_202000020*R_400[0]+-1*P_202000120*R_401[0]+P_202000220*R_402[0]; double PR_001001020200=P_001001020*R_200[0]+-1*P_001001120*R_201[0]+P_001001220*R_202[0]+-1*P_001101020*R_210[0]+P_001101120*R_211[0]+-1*P_001101220*R_212[0]+-1*P_101001020*R_300[0]+P_101001120*R_301[0]+-1*P_101001220*R_302[0]+P_101101020*R_310[0]+-1*P_101101120*R_311[0]+P_101101220*R_312[0]; double PR_000002020200=P_000002020*R_200[0]+-1*P_000002120*R_201[0]+P_000002220*R_202[0]+-1*P_000102020*R_210[0]+P_000102120*R_211[0]+-1*P_000102220*R_212[0]+P_000202020*R_220[0]+-1*P_000202120*R_221[0]+P_000202220*R_222[0]; double PR_001000021200=P_001000021*R_200[0]+-1*P_001000121*R_201[0]+P_001000221*R_202[0]+-1*P_001000321*R_203[0]+-1*P_101000021*R_300[0]+P_101000121*R_301[0]+-1*P_101000221*R_302[0]+P_101000321*R_303[0]; double PR_000001021200=P_000001021*R_200[0]+-1*P_000001121*R_201[0]+P_000001221*R_202[0]+-1*P_000001321*R_203[0]+-1*P_000101021*R_210[0]+P_000101121*R_211[0]+-1*P_000101221*R_212[0]+P_000101321*R_213[0]; double PR_000000022200=P_000000022*R_200[0]+-1*P_000000122*R_201[0]+P_000000222*R_202[0]+-1*P_000000322*R_203[0]+P_000000422*R_204[0]; double PR_022000000003=P_022000000*R_003[0]+-1*P_122000000*R_103[0]+P_222000000*R_203[0]+-1*P_322000000*R_303[0]+P_422000000*R_403[0]; double PR_021001000003=P_021001000*R_003[0]+-1*P_021101000*R_013[0]+-1*P_121001000*R_103[0]+P_121101000*R_113[0]+P_221001000*R_203[0]+-1*P_221101000*R_213[0]+-1*P_321001000*R_303[0]+P_321101000*R_313[0]; double PR_020002000003=P_020002000*R_003[0]+-1*P_020102000*R_013[0]+P_020202000*R_023[0]+-1*P_120002000*R_103[0]+P_120102000*R_113[0]+-1*P_120202000*R_123[0]+P_220002000*R_203[0]+-1*P_220102000*R_213[0]+P_220202000*R_223[0]; double PR_021000001003=P_021000001*R_003[0]+-1*P_021000101*R_004[0]+-1*P_121000001*R_103[0]+P_121000101*R_104[0]+P_221000001*R_203[0]+-1*P_221000101*R_204[0]+-1*P_321000001*R_303[0]+P_321000101*R_304[0]; double PR_020001001003=P_020001001*R_003[0]+-1*P_020001101*R_004[0]+-1*P_020101001*R_013[0]+P_020101101*R_014[0]+-1*P_120001001*R_103[0]+P_120001101*R_104[0]+P_120101001*R_113[0]+-1*P_120101101*R_114[0]+P_220001001*R_203[0]+-1*P_220001101*R_204[0]+-1*P_220101001*R_213[0]+P_220101101*R_214[0]; double PR_020000002003=P_020000002*R_003[0]+-1*P_020000102*R_004[0]+P_020000202*R_005[0]+-1*P_120000002*R_103[0]+P_120000102*R_104[0]+-1*P_120000202*R_105[0]+P_220000002*R_203[0]+-1*P_220000102*R_204[0]+P_220000202*R_205[0]; double PR_012010000003=P_012010000*R_003[0]+-1*P_012110000*R_013[0]+-1*P_112010000*R_103[0]+P_112110000*R_113[0]+P_212010000*R_203[0]+-1*P_212110000*R_213[0]+-1*P_312010000*R_303[0]+P_312110000*R_313[0]; double PR_011011000003=P_011011000*R_003[0]+-1*P_011111000*R_013[0]+P_011211000*R_023[0]+-1*P_111011000*R_103[0]+P_111111000*R_113[0]+-1*P_111211000*R_123[0]+P_211011000*R_203[0]+-1*P_211111000*R_213[0]+P_211211000*R_223[0]; double PR_010012000003=P_010012000*R_003[0]+-1*P_010112000*R_013[0]+P_010212000*R_023[0]+-1*P_010312000*R_033[0]+-1*P_110012000*R_103[0]+P_110112000*R_113[0]+-1*P_110212000*R_123[0]+P_110312000*R_133[0]; double PR_011010001003=P_011010001*R_003[0]+-1*P_011010101*R_004[0]+-1*P_011110001*R_013[0]+P_011110101*R_014[0]+-1*P_111010001*R_103[0]+P_111010101*R_104[0]+P_111110001*R_113[0]+-1*P_111110101*R_114[0]+P_211010001*R_203[0]+-1*P_211010101*R_204[0]+-1*P_211110001*R_213[0]+P_211110101*R_214[0]; double PR_010011001003=P_010011001*R_003[0]+-1*P_010011101*R_004[0]+-1*P_010111001*R_013[0]+P_010111101*R_014[0]+P_010211001*R_023[0]+-1*P_010211101*R_024[0]+-1*P_110011001*R_103[0]+P_110011101*R_104[0]+P_110111001*R_113[0]+-1*P_110111101*R_114[0]+-1*P_110211001*R_123[0]+P_110211101*R_124[0]; double PR_010010002003=P_010010002*R_003[0]+-1*P_010010102*R_004[0]+P_010010202*R_005[0]+-1*P_010110002*R_013[0]+P_010110102*R_014[0]+-1*P_010110202*R_015[0]+-1*P_110010002*R_103[0]+P_110010102*R_104[0]+-1*P_110010202*R_105[0]+P_110110002*R_113[0]+-1*P_110110102*R_114[0]+P_110110202*R_115[0]; double PR_002020000003=P_002020000*R_003[0]+-1*P_002120000*R_013[0]+P_002220000*R_023[0]+-1*P_102020000*R_103[0]+P_102120000*R_113[0]+-1*P_102220000*R_123[0]+P_202020000*R_203[0]+-1*P_202120000*R_213[0]+P_202220000*R_223[0]; double PR_001021000003=P_001021000*R_003[0]+-1*P_001121000*R_013[0]+P_001221000*R_023[0]+-1*P_001321000*R_033[0]+-1*P_101021000*R_103[0]+P_101121000*R_113[0]+-1*P_101221000*R_123[0]+P_101321000*R_133[0]; double PR_000022000003=P_000022000*R_003[0]+-1*P_000122000*R_013[0]+P_000222000*R_023[0]+-1*P_000322000*R_033[0]+P_000422000*R_043[0]; double PR_001020001003=P_001020001*R_003[0]+-1*P_001020101*R_004[0]+-1*P_001120001*R_013[0]+P_001120101*R_014[0]+P_001220001*R_023[0]+-1*P_001220101*R_024[0]+-1*P_101020001*R_103[0]+P_101020101*R_104[0]+P_101120001*R_113[0]+-1*P_101120101*R_114[0]+-1*P_101220001*R_123[0]+P_101220101*R_124[0]; double PR_000021001003=P_000021001*R_003[0]+-1*P_000021101*R_004[0]+-1*P_000121001*R_013[0]+P_000121101*R_014[0]+P_000221001*R_023[0]+-1*P_000221101*R_024[0]+-1*P_000321001*R_033[0]+P_000321101*R_034[0]; double PR_000020002003=P_000020002*R_003[0]+-1*P_000020102*R_004[0]+P_000020202*R_005[0]+-1*P_000120002*R_013[0]+P_000120102*R_014[0]+-1*P_000120202*R_015[0]+P_000220002*R_023[0]+-1*P_000220102*R_024[0]+P_000220202*R_025[0]; double PR_012000010003=P_012000010*R_003[0]+-1*P_012000110*R_004[0]+-1*P_112000010*R_103[0]+P_112000110*R_104[0]+P_212000010*R_203[0]+-1*P_212000110*R_204[0]+-1*P_312000010*R_303[0]+P_312000110*R_304[0]; double PR_011001010003=P_011001010*R_003[0]+-1*P_011001110*R_004[0]+-1*P_011101010*R_013[0]+P_011101110*R_014[0]+-1*P_111001010*R_103[0]+P_111001110*R_104[0]+P_111101010*R_113[0]+-1*P_111101110*R_114[0]+P_211001010*R_203[0]+-1*P_211001110*R_204[0]+-1*P_211101010*R_213[0]+P_211101110*R_214[0]; double PR_010002010003=P_010002010*R_003[0]+-1*P_010002110*R_004[0]+-1*P_010102010*R_013[0]+P_010102110*R_014[0]+P_010202010*R_023[0]+-1*P_010202110*R_024[0]+-1*P_110002010*R_103[0]+P_110002110*R_104[0]+P_110102010*R_113[0]+-1*P_110102110*R_114[0]+-1*P_110202010*R_123[0]+P_110202110*R_124[0]; double PR_011000011003=P_011000011*R_003[0]+-1*P_011000111*R_004[0]+P_011000211*R_005[0]+-1*P_111000011*R_103[0]+P_111000111*R_104[0]+-1*P_111000211*R_105[0]+P_211000011*R_203[0]+-1*P_211000111*R_204[0]+P_211000211*R_205[0]; double PR_010001011003=P_010001011*R_003[0]+-1*P_010001111*R_004[0]+P_010001211*R_005[0]+-1*P_010101011*R_013[0]+P_010101111*R_014[0]+-1*P_010101211*R_015[0]+-1*P_110001011*R_103[0]+P_110001111*R_104[0]+-1*P_110001211*R_105[0]+P_110101011*R_113[0]+-1*P_110101111*R_114[0]+P_110101211*R_115[0]; double PR_010000012003=P_010000012*R_003[0]+-1*P_010000112*R_004[0]+P_010000212*R_005[0]+-1*P_010000312*R_006[0]+-1*P_110000012*R_103[0]+P_110000112*R_104[0]+-1*P_110000212*R_105[0]+P_110000312*R_106[0]; double PR_002010010003=P_002010010*R_003[0]+-1*P_002010110*R_004[0]+-1*P_002110010*R_013[0]+P_002110110*R_014[0]+-1*P_102010010*R_103[0]+P_102010110*R_104[0]+P_102110010*R_113[0]+-1*P_102110110*R_114[0]+P_202010010*R_203[0]+-1*P_202010110*R_204[0]+-1*P_202110010*R_213[0]+P_202110110*R_214[0]; double PR_001011010003=P_001011010*R_003[0]+-1*P_001011110*R_004[0]+-1*P_001111010*R_013[0]+P_001111110*R_014[0]+P_001211010*R_023[0]+-1*P_001211110*R_024[0]+-1*P_101011010*R_103[0]+P_101011110*R_104[0]+P_101111010*R_113[0]+-1*P_101111110*R_114[0]+-1*P_101211010*R_123[0]+P_101211110*R_124[0]; double PR_000012010003=P_000012010*R_003[0]+-1*P_000012110*R_004[0]+-1*P_000112010*R_013[0]+P_000112110*R_014[0]+P_000212010*R_023[0]+-1*P_000212110*R_024[0]+-1*P_000312010*R_033[0]+P_000312110*R_034[0]; double PR_001010011003=P_001010011*R_003[0]+-1*P_001010111*R_004[0]+P_001010211*R_005[0]+-1*P_001110011*R_013[0]+P_001110111*R_014[0]+-1*P_001110211*R_015[0]+-1*P_101010011*R_103[0]+P_101010111*R_104[0]+-1*P_101010211*R_105[0]+P_101110011*R_113[0]+-1*P_101110111*R_114[0]+P_101110211*R_115[0]; double PR_000011011003=P_000011011*R_003[0]+-1*P_000011111*R_004[0]+P_000011211*R_005[0]+-1*P_000111011*R_013[0]+P_000111111*R_014[0]+-1*P_000111211*R_015[0]+P_000211011*R_023[0]+-1*P_000211111*R_024[0]+P_000211211*R_025[0]; double PR_000010012003=P_000010012*R_003[0]+-1*P_000010112*R_004[0]+P_000010212*R_005[0]+-1*P_000010312*R_006[0]+-1*P_000110012*R_013[0]+P_000110112*R_014[0]+-1*P_000110212*R_015[0]+P_000110312*R_016[0]; double PR_002000020003=P_002000020*R_003[0]+-1*P_002000120*R_004[0]+P_002000220*R_005[0]+-1*P_102000020*R_103[0]+P_102000120*R_104[0]+-1*P_102000220*R_105[0]+P_202000020*R_203[0]+-1*P_202000120*R_204[0]+P_202000220*R_205[0]; double PR_001001020003=P_001001020*R_003[0]+-1*P_001001120*R_004[0]+P_001001220*R_005[0]+-1*P_001101020*R_013[0]+P_001101120*R_014[0]+-1*P_001101220*R_015[0]+-1*P_101001020*R_103[0]+P_101001120*R_104[0]+-1*P_101001220*R_105[0]+P_101101020*R_113[0]+-1*P_101101120*R_114[0]+P_101101220*R_115[0]; double PR_000002020003=P_000002020*R_003[0]+-1*P_000002120*R_004[0]+P_000002220*R_005[0]+-1*P_000102020*R_013[0]+P_000102120*R_014[0]+-1*P_000102220*R_015[0]+P_000202020*R_023[0]+-1*P_000202120*R_024[0]+P_000202220*R_025[0]; double PR_001000021003=P_001000021*R_003[0]+-1*P_001000121*R_004[0]+P_001000221*R_005[0]+-1*P_001000321*R_006[0]+-1*P_101000021*R_103[0]+P_101000121*R_104[0]+-1*P_101000221*R_105[0]+P_101000321*R_106[0]; double PR_000001021003=P_000001021*R_003[0]+-1*P_000001121*R_004[0]+P_000001221*R_005[0]+-1*P_000001321*R_006[0]+-1*P_000101021*R_013[0]+P_000101121*R_014[0]+-1*P_000101221*R_015[0]+P_000101321*R_016[0]; double PR_000000022003=P_000000022*R_003[0]+-1*P_000000122*R_004[0]+P_000000222*R_005[0]+-1*P_000000322*R_006[0]+P_000000422*R_007[0]; double PR_022000000012=P_022000000*R_012[0]+-1*P_122000000*R_112[0]+P_222000000*R_212[0]+-1*P_322000000*R_312[0]+P_422000000*R_412[0]; double PR_021001000012=P_021001000*R_012[0]+-1*P_021101000*R_022[0]+-1*P_121001000*R_112[0]+P_121101000*R_122[0]+P_221001000*R_212[0]+-1*P_221101000*R_222[0]+-1*P_321001000*R_312[0]+P_321101000*R_322[0]; double PR_020002000012=P_020002000*R_012[0]+-1*P_020102000*R_022[0]+P_020202000*R_032[0]+-1*P_120002000*R_112[0]+P_120102000*R_122[0]+-1*P_120202000*R_132[0]+P_220002000*R_212[0]+-1*P_220102000*R_222[0]+P_220202000*R_232[0]; double PR_021000001012=P_021000001*R_012[0]+-1*P_021000101*R_013[0]+-1*P_121000001*R_112[0]+P_121000101*R_113[0]+P_221000001*R_212[0]+-1*P_221000101*R_213[0]+-1*P_321000001*R_312[0]+P_321000101*R_313[0]; double PR_020001001012=P_020001001*R_012[0]+-1*P_020001101*R_013[0]+-1*P_020101001*R_022[0]+P_020101101*R_023[0]+-1*P_120001001*R_112[0]+P_120001101*R_113[0]+P_120101001*R_122[0]+-1*P_120101101*R_123[0]+P_220001001*R_212[0]+-1*P_220001101*R_213[0]+-1*P_220101001*R_222[0]+P_220101101*R_223[0]; double PR_020000002012=P_020000002*R_012[0]+-1*P_020000102*R_013[0]+P_020000202*R_014[0]+-1*P_120000002*R_112[0]+P_120000102*R_113[0]+-1*P_120000202*R_114[0]+P_220000002*R_212[0]+-1*P_220000102*R_213[0]+P_220000202*R_214[0]; double PR_012010000012=P_012010000*R_012[0]+-1*P_012110000*R_022[0]+-1*P_112010000*R_112[0]+P_112110000*R_122[0]+P_212010000*R_212[0]+-1*P_212110000*R_222[0]+-1*P_312010000*R_312[0]+P_312110000*R_322[0]; double PR_011011000012=P_011011000*R_012[0]+-1*P_011111000*R_022[0]+P_011211000*R_032[0]+-1*P_111011000*R_112[0]+P_111111000*R_122[0]+-1*P_111211000*R_132[0]+P_211011000*R_212[0]+-1*P_211111000*R_222[0]+P_211211000*R_232[0]; double PR_010012000012=P_010012000*R_012[0]+-1*P_010112000*R_022[0]+P_010212000*R_032[0]+-1*P_010312000*R_042[0]+-1*P_110012000*R_112[0]+P_110112000*R_122[0]+-1*P_110212000*R_132[0]+P_110312000*R_142[0]; double PR_011010001012=P_011010001*R_012[0]+-1*P_011010101*R_013[0]+-1*P_011110001*R_022[0]+P_011110101*R_023[0]+-1*P_111010001*R_112[0]+P_111010101*R_113[0]+P_111110001*R_122[0]+-1*P_111110101*R_123[0]+P_211010001*R_212[0]+-1*P_211010101*R_213[0]+-1*P_211110001*R_222[0]+P_211110101*R_223[0]; double PR_010011001012=P_010011001*R_012[0]+-1*P_010011101*R_013[0]+-1*P_010111001*R_022[0]+P_010111101*R_023[0]+P_010211001*R_032[0]+-1*P_010211101*R_033[0]+-1*P_110011001*R_112[0]+P_110011101*R_113[0]+P_110111001*R_122[0]+-1*P_110111101*R_123[0]+-1*P_110211001*R_132[0]+P_110211101*R_133[0]; double PR_010010002012=P_010010002*R_012[0]+-1*P_010010102*R_013[0]+P_010010202*R_014[0]+-1*P_010110002*R_022[0]+P_010110102*R_023[0]+-1*P_010110202*R_024[0]+-1*P_110010002*R_112[0]+P_110010102*R_113[0]+-1*P_110010202*R_114[0]+P_110110002*R_122[0]+-1*P_110110102*R_123[0]+P_110110202*R_124[0]; double PR_002020000012=P_002020000*R_012[0]+-1*P_002120000*R_022[0]+P_002220000*R_032[0]+-1*P_102020000*R_112[0]+P_102120000*R_122[0]+-1*P_102220000*R_132[0]+P_202020000*R_212[0]+-1*P_202120000*R_222[0]+P_202220000*R_232[0]; double PR_001021000012=P_001021000*R_012[0]+-1*P_001121000*R_022[0]+P_001221000*R_032[0]+-1*P_001321000*R_042[0]+-1*P_101021000*R_112[0]+P_101121000*R_122[0]+-1*P_101221000*R_132[0]+P_101321000*R_142[0]; double PR_000022000012=P_000022000*R_012[0]+-1*P_000122000*R_022[0]+P_000222000*R_032[0]+-1*P_000322000*R_042[0]+P_000422000*R_052[0]; double PR_001020001012=P_001020001*R_012[0]+-1*P_001020101*R_013[0]+-1*P_001120001*R_022[0]+P_001120101*R_023[0]+P_001220001*R_032[0]+-1*P_001220101*R_033[0]+-1*P_101020001*R_112[0]+P_101020101*R_113[0]+P_101120001*R_122[0]+-1*P_101120101*R_123[0]+-1*P_101220001*R_132[0]+P_101220101*R_133[0]; double PR_000021001012=P_000021001*R_012[0]+-1*P_000021101*R_013[0]+-1*P_000121001*R_022[0]+P_000121101*R_023[0]+P_000221001*R_032[0]+-1*P_000221101*R_033[0]+-1*P_000321001*R_042[0]+P_000321101*R_043[0]; double PR_000020002012=P_000020002*R_012[0]+-1*P_000020102*R_013[0]+P_000020202*R_014[0]+-1*P_000120002*R_022[0]+P_000120102*R_023[0]+-1*P_000120202*R_024[0]+P_000220002*R_032[0]+-1*P_000220102*R_033[0]+P_000220202*R_034[0]; double PR_012000010012=P_012000010*R_012[0]+-1*P_012000110*R_013[0]+-1*P_112000010*R_112[0]+P_112000110*R_113[0]+P_212000010*R_212[0]+-1*P_212000110*R_213[0]+-1*P_312000010*R_312[0]+P_312000110*R_313[0]; double PR_011001010012=P_011001010*R_012[0]+-1*P_011001110*R_013[0]+-1*P_011101010*R_022[0]+P_011101110*R_023[0]+-1*P_111001010*R_112[0]+P_111001110*R_113[0]+P_111101010*R_122[0]+-1*P_111101110*R_123[0]+P_211001010*R_212[0]+-1*P_211001110*R_213[0]+-1*P_211101010*R_222[0]+P_211101110*R_223[0]; double PR_010002010012=P_010002010*R_012[0]+-1*P_010002110*R_013[0]+-1*P_010102010*R_022[0]+P_010102110*R_023[0]+P_010202010*R_032[0]+-1*P_010202110*R_033[0]+-1*P_110002010*R_112[0]+P_110002110*R_113[0]+P_110102010*R_122[0]+-1*P_110102110*R_123[0]+-1*P_110202010*R_132[0]+P_110202110*R_133[0]; double PR_011000011012=P_011000011*R_012[0]+-1*P_011000111*R_013[0]+P_011000211*R_014[0]+-1*P_111000011*R_112[0]+P_111000111*R_113[0]+-1*P_111000211*R_114[0]+P_211000011*R_212[0]+-1*P_211000111*R_213[0]+P_211000211*R_214[0]; double PR_010001011012=P_010001011*R_012[0]+-1*P_010001111*R_013[0]+P_010001211*R_014[0]+-1*P_010101011*R_022[0]+P_010101111*R_023[0]+-1*P_010101211*R_024[0]+-1*P_110001011*R_112[0]+P_110001111*R_113[0]+-1*P_110001211*R_114[0]+P_110101011*R_122[0]+-1*P_110101111*R_123[0]+P_110101211*R_124[0]; double PR_010000012012=P_010000012*R_012[0]+-1*P_010000112*R_013[0]+P_010000212*R_014[0]+-1*P_010000312*R_015[0]+-1*P_110000012*R_112[0]+P_110000112*R_113[0]+-1*P_110000212*R_114[0]+P_110000312*R_115[0]; double PR_002010010012=P_002010010*R_012[0]+-1*P_002010110*R_013[0]+-1*P_002110010*R_022[0]+P_002110110*R_023[0]+-1*P_102010010*R_112[0]+P_102010110*R_113[0]+P_102110010*R_122[0]+-1*P_102110110*R_123[0]+P_202010010*R_212[0]+-1*P_202010110*R_213[0]+-1*P_202110010*R_222[0]+P_202110110*R_223[0]; double PR_001011010012=P_001011010*R_012[0]+-1*P_001011110*R_013[0]+-1*P_001111010*R_022[0]+P_001111110*R_023[0]+P_001211010*R_032[0]+-1*P_001211110*R_033[0]+-1*P_101011010*R_112[0]+P_101011110*R_113[0]+P_101111010*R_122[0]+-1*P_101111110*R_123[0]+-1*P_101211010*R_132[0]+P_101211110*R_133[0]; double PR_000012010012=P_000012010*R_012[0]+-1*P_000012110*R_013[0]+-1*P_000112010*R_022[0]+P_000112110*R_023[0]+P_000212010*R_032[0]+-1*P_000212110*R_033[0]+-1*P_000312010*R_042[0]+P_000312110*R_043[0]; double PR_001010011012=P_001010011*R_012[0]+-1*P_001010111*R_013[0]+P_001010211*R_014[0]+-1*P_001110011*R_022[0]+P_001110111*R_023[0]+-1*P_001110211*R_024[0]+-1*P_101010011*R_112[0]+P_101010111*R_113[0]+-1*P_101010211*R_114[0]+P_101110011*R_122[0]+-1*P_101110111*R_123[0]+P_101110211*R_124[0]; double PR_000011011012=P_000011011*R_012[0]+-1*P_000011111*R_013[0]+P_000011211*R_014[0]+-1*P_000111011*R_022[0]+P_000111111*R_023[0]+-1*P_000111211*R_024[0]+P_000211011*R_032[0]+-1*P_000211111*R_033[0]+P_000211211*R_034[0]; double PR_000010012012=P_000010012*R_012[0]+-1*P_000010112*R_013[0]+P_000010212*R_014[0]+-1*P_000010312*R_015[0]+-1*P_000110012*R_022[0]+P_000110112*R_023[0]+-1*P_000110212*R_024[0]+P_000110312*R_025[0]; double PR_002000020012=P_002000020*R_012[0]+-1*P_002000120*R_013[0]+P_002000220*R_014[0]+-1*P_102000020*R_112[0]+P_102000120*R_113[0]+-1*P_102000220*R_114[0]+P_202000020*R_212[0]+-1*P_202000120*R_213[0]+P_202000220*R_214[0]; double PR_001001020012=P_001001020*R_012[0]+-1*P_001001120*R_013[0]+P_001001220*R_014[0]+-1*P_001101020*R_022[0]+P_001101120*R_023[0]+-1*P_001101220*R_024[0]+-1*P_101001020*R_112[0]+P_101001120*R_113[0]+-1*P_101001220*R_114[0]+P_101101020*R_122[0]+-1*P_101101120*R_123[0]+P_101101220*R_124[0]; double PR_000002020012=P_000002020*R_012[0]+-1*P_000002120*R_013[0]+P_000002220*R_014[0]+-1*P_000102020*R_022[0]+P_000102120*R_023[0]+-1*P_000102220*R_024[0]+P_000202020*R_032[0]+-1*P_000202120*R_033[0]+P_000202220*R_034[0]; double PR_001000021012=P_001000021*R_012[0]+-1*P_001000121*R_013[0]+P_001000221*R_014[0]+-1*P_001000321*R_015[0]+-1*P_101000021*R_112[0]+P_101000121*R_113[0]+-1*P_101000221*R_114[0]+P_101000321*R_115[0]; double PR_000001021012=P_000001021*R_012[0]+-1*P_000001121*R_013[0]+P_000001221*R_014[0]+-1*P_000001321*R_015[0]+-1*P_000101021*R_022[0]+P_000101121*R_023[0]+-1*P_000101221*R_024[0]+P_000101321*R_025[0]; double PR_000000022012=P_000000022*R_012[0]+-1*P_000000122*R_013[0]+P_000000222*R_014[0]+-1*P_000000322*R_015[0]+P_000000422*R_016[0]; double PR_022000000021=P_022000000*R_021[0]+-1*P_122000000*R_121[0]+P_222000000*R_221[0]+-1*P_322000000*R_321[0]+P_422000000*R_421[0]; double PR_021001000021=P_021001000*R_021[0]+-1*P_021101000*R_031[0]+-1*P_121001000*R_121[0]+P_121101000*R_131[0]+P_221001000*R_221[0]+-1*P_221101000*R_231[0]+-1*P_321001000*R_321[0]+P_321101000*R_331[0]; double PR_020002000021=P_020002000*R_021[0]+-1*P_020102000*R_031[0]+P_020202000*R_041[0]+-1*P_120002000*R_121[0]+P_120102000*R_131[0]+-1*P_120202000*R_141[0]+P_220002000*R_221[0]+-1*P_220102000*R_231[0]+P_220202000*R_241[0]; double PR_021000001021=P_021000001*R_021[0]+-1*P_021000101*R_022[0]+-1*P_121000001*R_121[0]+P_121000101*R_122[0]+P_221000001*R_221[0]+-1*P_221000101*R_222[0]+-1*P_321000001*R_321[0]+P_321000101*R_322[0]; double PR_020001001021=P_020001001*R_021[0]+-1*P_020001101*R_022[0]+-1*P_020101001*R_031[0]+P_020101101*R_032[0]+-1*P_120001001*R_121[0]+P_120001101*R_122[0]+P_120101001*R_131[0]+-1*P_120101101*R_132[0]+P_220001001*R_221[0]+-1*P_220001101*R_222[0]+-1*P_220101001*R_231[0]+P_220101101*R_232[0]; double PR_020000002021=P_020000002*R_021[0]+-1*P_020000102*R_022[0]+P_020000202*R_023[0]+-1*P_120000002*R_121[0]+P_120000102*R_122[0]+-1*P_120000202*R_123[0]+P_220000002*R_221[0]+-1*P_220000102*R_222[0]+P_220000202*R_223[0]; double PR_012010000021=P_012010000*R_021[0]+-1*P_012110000*R_031[0]+-1*P_112010000*R_121[0]+P_112110000*R_131[0]+P_212010000*R_221[0]+-1*P_212110000*R_231[0]+-1*P_312010000*R_321[0]+P_312110000*R_331[0]; double PR_011011000021=P_011011000*R_021[0]+-1*P_011111000*R_031[0]+P_011211000*R_041[0]+-1*P_111011000*R_121[0]+P_111111000*R_131[0]+-1*P_111211000*R_141[0]+P_211011000*R_221[0]+-1*P_211111000*R_231[0]+P_211211000*R_241[0]; double PR_010012000021=P_010012000*R_021[0]+-1*P_010112000*R_031[0]+P_010212000*R_041[0]+-1*P_010312000*R_051[0]+-1*P_110012000*R_121[0]+P_110112000*R_131[0]+-1*P_110212000*R_141[0]+P_110312000*R_151[0]; double PR_011010001021=P_011010001*R_021[0]+-1*P_011010101*R_022[0]+-1*P_011110001*R_031[0]+P_011110101*R_032[0]+-1*P_111010001*R_121[0]+P_111010101*R_122[0]+P_111110001*R_131[0]+-1*P_111110101*R_132[0]+P_211010001*R_221[0]+-1*P_211010101*R_222[0]+-1*P_211110001*R_231[0]+P_211110101*R_232[0]; double PR_010011001021=P_010011001*R_021[0]+-1*P_010011101*R_022[0]+-1*P_010111001*R_031[0]+P_010111101*R_032[0]+P_010211001*R_041[0]+-1*P_010211101*R_042[0]+-1*P_110011001*R_121[0]+P_110011101*R_122[0]+P_110111001*R_131[0]+-1*P_110111101*R_132[0]+-1*P_110211001*R_141[0]+P_110211101*R_142[0]; double PR_010010002021=P_010010002*R_021[0]+-1*P_010010102*R_022[0]+P_010010202*R_023[0]+-1*P_010110002*R_031[0]+P_010110102*R_032[0]+-1*P_010110202*R_033[0]+-1*P_110010002*R_121[0]+P_110010102*R_122[0]+-1*P_110010202*R_123[0]+P_110110002*R_131[0]+-1*P_110110102*R_132[0]+P_110110202*R_133[0]; double PR_002020000021=P_002020000*R_021[0]+-1*P_002120000*R_031[0]+P_002220000*R_041[0]+-1*P_102020000*R_121[0]+P_102120000*R_131[0]+-1*P_102220000*R_141[0]+P_202020000*R_221[0]+-1*P_202120000*R_231[0]+P_202220000*R_241[0]; double PR_001021000021=P_001021000*R_021[0]+-1*P_001121000*R_031[0]+P_001221000*R_041[0]+-1*P_001321000*R_051[0]+-1*P_101021000*R_121[0]+P_101121000*R_131[0]+-1*P_101221000*R_141[0]+P_101321000*R_151[0]; double PR_000022000021=P_000022000*R_021[0]+-1*P_000122000*R_031[0]+P_000222000*R_041[0]+-1*P_000322000*R_051[0]+P_000422000*R_061[0]; double PR_001020001021=P_001020001*R_021[0]+-1*P_001020101*R_022[0]+-1*P_001120001*R_031[0]+P_001120101*R_032[0]+P_001220001*R_041[0]+-1*P_001220101*R_042[0]+-1*P_101020001*R_121[0]+P_101020101*R_122[0]+P_101120001*R_131[0]+-1*P_101120101*R_132[0]+-1*P_101220001*R_141[0]+P_101220101*R_142[0]; double PR_000021001021=P_000021001*R_021[0]+-1*P_000021101*R_022[0]+-1*P_000121001*R_031[0]+P_000121101*R_032[0]+P_000221001*R_041[0]+-1*P_000221101*R_042[0]+-1*P_000321001*R_051[0]+P_000321101*R_052[0]; double PR_000020002021=P_000020002*R_021[0]+-1*P_000020102*R_022[0]+P_000020202*R_023[0]+-1*P_000120002*R_031[0]+P_000120102*R_032[0]+-1*P_000120202*R_033[0]+P_000220002*R_041[0]+-1*P_000220102*R_042[0]+P_000220202*R_043[0]; double PR_012000010021=P_012000010*R_021[0]+-1*P_012000110*R_022[0]+-1*P_112000010*R_121[0]+P_112000110*R_122[0]+P_212000010*R_221[0]+-1*P_212000110*R_222[0]+-1*P_312000010*R_321[0]+P_312000110*R_322[0]; double PR_011001010021=P_011001010*R_021[0]+-1*P_011001110*R_022[0]+-1*P_011101010*R_031[0]+P_011101110*R_032[0]+-1*P_111001010*R_121[0]+P_111001110*R_122[0]+P_111101010*R_131[0]+-1*P_111101110*R_132[0]+P_211001010*R_221[0]+-1*P_211001110*R_222[0]+-1*P_211101010*R_231[0]+P_211101110*R_232[0]; double PR_010002010021=P_010002010*R_021[0]+-1*P_010002110*R_022[0]+-1*P_010102010*R_031[0]+P_010102110*R_032[0]+P_010202010*R_041[0]+-1*P_010202110*R_042[0]+-1*P_110002010*R_121[0]+P_110002110*R_122[0]+P_110102010*R_131[0]+-1*P_110102110*R_132[0]+-1*P_110202010*R_141[0]+P_110202110*R_142[0]; double PR_011000011021=P_011000011*R_021[0]+-1*P_011000111*R_022[0]+P_011000211*R_023[0]+-1*P_111000011*R_121[0]+P_111000111*R_122[0]+-1*P_111000211*R_123[0]+P_211000011*R_221[0]+-1*P_211000111*R_222[0]+P_211000211*R_223[0]; double PR_010001011021=P_010001011*R_021[0]+-1*P_010001111*R_022[0]+P_010001211*R_023[0]+-1*P_010101011*R_031[0]+P_010101111*R_032[0]+-1*P_010101211*R_033[0]+-1*P_110001011*R_121[0]+P_110001111*R_122[0]+-1*P_110001211*R_123[0]+P_110101011*R_131[0]+-1*P_110101111*R_132[0]+P_110101211*R_133[0]; double PR_010000012021=P_010000012*R_021[0]+-1*P_010000112*R_022[0]+P_010000212*R_023[0]+-1*P_010000312*R_024[0]+-1*P_110000012*R_121[0]+P_110000112*R_122[0]+-1*P_110000212*R_123[0]+P_110000312*R_124[0]; double PR_002010010021=P_002010010*R_021[0]+-1*P_002010110*R_022[0]+-1*P_002110010*R_031[0]+P_002110110*R_032[0]+-1*P_102010010*R_121[0]+P_102010110*R_122[0]+P_102110010*R_131[0]+-1*P_102110110*R_132[0]+P_202010010*R_221[0]+-1*P_202010110*R_222[0]+-1*P_202110010*R_231[0]+P_202110110*R_232[0]; double PR_001011010021=P_001011010*R_021[0]+-1*P_001011110*R_022[0]+-1*P_001111010*R_031[0]+P_001111110*R_032[0]+P_001211010*R_041[0]+-1*P_001211110*R_042[0]+-1*P_101011010*R_121[0]+P_101011110*R_122[0]+P_101111010*R_131[0]+-1*P_101111110*R_132[0]+-1*P_101211010*R_141[0]+P_101211110*R_142[0]; double PR_000012010021=P_000012010*R_021[0]+-1*P_000012110*R_022[0]+-1*P_000112010*R_031[0]+P_000112110*R_032[0]+P_000212010*R_041[0]+-1*P_000212110*R_042[0]+-1*P_000312010*R_051[0]+P_000312110*R_052[0]; double PR_001010011021=P_001010011*R_021[0]+-1*P_001010111*R_022[0]+P_001010211*R_023[0]+-1*P_001110011*R_031[0]+P_001110111*R_032[0]+-1*P_001110211*R_033[0]+-1*P_101010011*R_121[0]+P_101010111*R_122[0]+-1*P_101010211*R_123[0]+P_101110011*R_131[0]+-1*P_101110111*R_132[0]+P_101110211*R_133[0]; double PR_000011011021=P_000011011*R_021[0]+-1*P_000011111*R_022[0]+P_000011211*R_023[0]+-1*P_000111011*R_031[0]+P_000111111*R_032[0]+-1*P_000111211*R_033[0]+P_000211011*R_041[0]+-1*P_000211111*R_042[0]+P_000211211*R_043[0]; double PR_000010012021=P_000010012*R_021[0]+-1*P_000010112*R_022[0]+P_000010212*R_023[0]+-1*P_000010312*R_024[0]+-1*P_000110012*R_031[0]+P_000110112*R_032[0]+-1*P_000110212*R_033[0]+P_000110312*R_034[0]; double PR_002000020021=P_002000020*R_021[0]+-1*P_002000120*R_022[0]+P_002000220*R_023[0]+-1*P_102000020*R_121[0]+P_102000120*R_122[0]+-1*P_102000220*R_123[0]+P_202000020*R_221[0]+-1*P_202000120*R_222[0]+P_202000220*R_223[0]; double PR_001001020021=P_001001020*R_021[0]+-1*P_001001120*R_022[0]+P_001001220*R_023[0]+-1*P_001101020*R_031[0]+P_001101120*R_032[0]+-1*P_001101220*R_033[0]+-1*P_101001020*R_121[0]+P_101001120*R_122[0]+-1*P_101001220*R_123[0]+P_101101020*R_131[0]+-1*P_101101120*R_132[0]+P_101101220*R_133[0]; double PR_000002020021=P_000002020*R_021[0]+-1*P_000002120*R_022[0]+P_000002220*R_023[0]+-1*P_000102020*R_031[0]+P_000102120*R_032[0]+-1*P_000102220*R_033[0]+P_000202020*R_041[0]+-1*P_000202120*R_042[0]+P_000202220*R_043[0]; double PR_001000021021=P_001000021*R_021[0]+-1*P_001000121*R_022[0]+P_001000221*R_023[0]+-1*P_001000321*R_024[0]+-1*P_101000021*R_121[0]+P_101000121*R_122[0]+-1*P_101000221*R_123[0]+P_101000321*R_124[0]; double PR_000001021021=P_000001021*R_021[0]+-1*P_000001121*R_022[0]+P_000001221*R_023[0]+-1*P_000001321*R_024[0]+-1*P_000101021*R_031[0]+P_000101121*R_032[0]+-1*P_000101221*R_033[0]+P_000101321*R_034[0]; double PR_000000022021=P_000000022*R_021[0]+-1*P_000000122*R_022[0]+P_000000222*R_023[0]+-1*P_000000322*R_024[0]+P_000000422*R_025[0]; double PR_022000000030=P_022000000*R_030[0]+-1*P_122000000*R_130[0]+P_222000000*R_230[0]+-1*P_322000000*R_330[0]+P_422000000*R_430[0]; double PR_021001000030=P_021001000*R_030[0]+-1*P_021101000*R_040[0]+-1*P_121001000*R_130[0]+P_121101000*R_140[0]+P_221001000*R_230[0]+-1*P_221101000*R_240[0]+-1*P_321001000*R_330[0]+P_321101000*R_340[0]; double PR_020002000030=P_020002000*R_030[0]+-1*P_020102000*R_040[0]+P_020202000*R_050[0]+-1*P_120002000*R_130[0]+P_120102000*R_140[0]+-1*P_120202000*R_150[0]+P_220002000*R_230[0]+-1*P_220102000*R_240[0]+P_220202000*R_250[0]; double PR_021000001030=P_021000001*R_030[0]+-1*P_021000101*R_031[0]+-1*P_121000001*R_130[0]+P_121000101*R_131[0]+P_221000001*R_230[0]+-1*P_221000101*R_231[0]+-1*P_321000001*R_330[0]+P_321000101*R_331[0]; double PR_020001001030=P_020001001*R_030[0]+-1*P_020001101*R_031[0]+-1*P_020101001*R_040[0]+P_020101101*R_041[0]+-1*P_120001001*R_130[0]+P_120001101*R_131[0]+P_120101001*R_140[0]+-1*P_120101101*R_141[0]+P_220001001*R_230[0]+-1*P_220001101*R_231[0]+-1*P_220101001*R_240[0]+P_220101101*R_241[0]; double PR_020000002030=P_020000002*R_030[0]+-1*P_020000102*R_031[0]+P_020000202*R_032[0]+-1*P_120000002*R_130[0]+P_120000102*R_131[0]+-1*P_120000202*R_132[0]+P_220000002*R_230[0]+-1*P_220000102*R_231[0]+P_220000202*R_232[0]; double PR_012010000030=P_012010000*R_030[0]+-1*P_012110000*R_040[0]+-1*P_112010000*R_130[0]+P_112110000*R_140[0]+P_212010000*R_230[0]+-1*P_212110000*R_240[0]+-1*P_312010000*R_330[0]+P_312110000*R_340[0]; double PR_011011000030=P_011011000*R_030[0]+-1*P_011111000*R_040[0]+P_011211000*R_050[0]+-1*P_111011000*R_130[0]+P_111111000*R_140[0]+-1*P_111211000*R_150[0]+P_211011000*R_230[0]+-1*P_211111000*R_240[0]+P_211211000*R_250[0]; double PR_010012000030=P_010012000*R_030[0]+-1*P_010112000*R_040[0]+P_010212000*R_050[0]+-1*P_010312000*R_060[0]+-1*P_110012000*R_130[0]+P_110112000*R_140[0]+-1*P_110212000*R_150[0]+P_110312000*R_160[0]; double PR_011010001030=P_011010001*R_030[0]+-1*P_011010101*R_031[0]+-1*P_011110001*R_040[0]+P_011110101*R_041[0]+-1*P_111010001*R_130[0]+P_111010101*R_131[0]+P_111110001*R_140[0]+-1*P_111110101*R_141[0]+P_211010001*R_230[0]+-1*P_211010101*R_231[0]+-1*P_211110001*R_240[0]+P_211110101*R_241[0]; double PR_010011001030=P_010011001*R_030[0]+-1*P_010011101*R_031[0]+-1*P_010111001*R_040[0]+P_010111101*R_041[0]+P_010211001*R_050[0]+-1*P_010211101*R_051[0]+-1*P_110011001*R_130[0]+P_110011101*R_131[0]+P_110111001*R_140[0]+-1*P_110111101*R_141[0]+-1*P_110211001*R_150[0]+P_110211101*R_151[0]; double PR_010010002030=P_010010002*R_030[0]+-1*P_010010102*R_031[0]+P_010010202*R_032[0]+-1*P_010110002*R_040[0]+P_010110102*R_041[0]+-1*P_010110202*R_042[0]+-1*P_110010002*R_130[0]+P_110010102*R_131[0]+-1*P_110010202*R_132[0]+P_110110002*R_140[0]+-1*P_110110102*R_141[0]+P_110110202*R_142[0]; double PR_002020000030=P_002020000*R_030[0]+-1*P_002120000*R_040[0]+P_002220000*R_050[0]+-1*P_102020000*R_130[0]+P_102120000*R_140[0]+-1*P_102220000*R_150[0]+P_202020000*R_230[0]+-1*P_202120000*R_240[0]+P_202220000*R_250[0]; double PR_001021000030=P_001021000*R_030[0]+-1*P_001121000*R_040[0]+P_001221000*R_050[0]+-1*P_001321000*R_060[0]+-1*P_101021000*R_130[0]+P_101121000*R_140[0]+-1*P_101221000*R_150[0]+P_101321000*R_160[0]; double PR_000022000030=P_000022000*R_030[0]+-1*P_000122000*R_040[0]+P_000222000*R_050[0]+-1*P_000322000*R_060[0]+P_000422000*R_070[0]; double PR_001020001030=P_001020001*R_030[0]+-1*P_001020101*R_031[0]+-1*P_001120001*R_040[0]+P_001120101*R_041[0]+P_001220001*R_050[0]+-1*P_001220101*R_051[0]+-1*P_101020001*R_130[0]+P_101020101*R_131[0]+P_101120001*R_140[0]+-1*P_101120101*R_141[0]+-1*P_101220001*R_150[0]+P_101220101*R_151[0]; double PR_000021001030=P_000021001*R_030[0]+-1*P_000021101*R_031[0]+-1*P_000121001*R_040[0]+P_000121101*R_041[0]+P_000221001*R_050[0]+-1*P_000221101*R_051[0]+-1*P_000321001*R_060[0]+P_000321101*R_061[0]; double PR_000020002030=P_000020002*R_030[0]+-1*P_000020102*R_031[0]+P_000020202*R_032[0]+-1*P_000120002*R_040[0]+P_000120102*R_041[0]+-1*P_000120202*R_042[0]+P_000220002*R_050[0]+-1*P_000220102*R_051[0]+P_000220202*R_052[0]; double PR_012000010030=P_012000010*R_030[0]+-1*P_012000110*R_031[0]+-1*P_112000010*R_130[0]+P_112000110*R_131[0]+P_212000010*R_230[0]+-1*P_212000110*R_231[0]+-1*P_312000010*R_330[0]+P_312000110*R_331[0]; double PR_011001010030=P_011001010*R_030[0]+-1*P_011001110*R_031[0]+-1*P_011101010*R_040[0]+P_011101110*R_041[0]+-1*P_111001010*R_130[0]+P_111001110*R_131[0]+P_111101010*R_140[0]+-1*P_111101110*R_141[0]+P_211001010*R_230[0]+-1*P_211001110*R_231[0]+-1*P_211101010*R_240[0]+P_211101110*R_241[0]; double PR_010002010030=P_010002010*R_030[0]+-1*P_010002110*R_031[0]+-1*P_010102010*R_040[0]+P_010102110*R_041[0]+P_010202010*R_050[0]+-1*P_010202110*R_051[0]+-1*P_110002010*R_130[0]+P_110002110*R_131[0]+P_110102010*R_140[0]+-1*P_110102110*R_141[0]+-1*P_110202010*R_150[0]+P_110202110*R_151[0]; double PR_011000011030=P_011000011*R_030[0]+-1*P_011000111*R_031[0]+P_011000211*R_032[0]+-1*P_111000011*R_130[0]+P_111000111*R_131[0]+-1*P_111000211*R_132[0]+P_211000011*R_230[0]+-1*P_211000111*R_231[0]+P_211000211*R_232[0]; double PR_010001011030=P_010001011*R_030[0]+-1*P_010001111*R_031[0]+P_010001211*R_032[0]+-1*P_010101011*R_040[0]+P_010101111*R_041[0]+-1*P_010101211*R_042[0]+-1*P_110001011*R_130[0]+P_110001111*R_131[0]+-1*P_110001211*R_132[0]+P_110101011*R_140[0]+-1*P_110101111*R_141[0]+P_110101211*R_142[0]; double PR_010000012030=P_010000012*R_030[0]+-1*P_010000112*R_031[0]+P_010000212*R_032[0]+-1*P_010000312*R_033[0]+-1*P_110000012*R_130[0]+P_110000112*R_131[0]+-1*P_110000212*R_132[0]+P_110000312*R_133[0]; double PR_002010010030=P_002010010*R_030[0]+-1*P_002010110*R_031[0]+-1*P_002110010*R_040[0]+P_002110110*R_041[0]+-1*P_102010010*R_130[0]+P_102010110*R_131[0]+P_102110010*R_140[0]+-1*P_102110110*R_141[0]+P_202010010*R_230[0]+-1*P_202010110*R_231[0]+-1*P_202110010*R_240[0]+P_202110110*R_241[0]; double PR_001011010030=P_001011010*R_030[0]+-1*P_001011110*R_031[0]+-1*P_001111010*R_040[0]+P_001111110*R_041[0]+P_001211010*R_050[0]+-1*P_001211110*R_051[0]+-1*P_101011010*R_130[0]+P_101011110*R_131[0]+P_101111010*R_140[0]+-1*P_101111110*R_141[0]+-1*P_101211010*R_150[0]+P_101211110*R_151[0]; double PR_000012010030=P_000012010*R_030[0]+-1*P_000012110*R_031[0]+-1*P_000112010*R_040[0]+P_000112110*R_041[0]+P_000212010*R_050[0]+-1*P_000212110*R_051[0]+-1*P_000312010*R_060[0]+P_000312110*R_061[0]; double PR_001010011030=P_001010011*R_030[0]+-1*P_001010111*R_031[0]+P_001010211*R_032[0]+-1*P_001110011*R_040[0]+P_001110111*R_041[0]+-1*P_001110211*R_042[0]+-1*P_101010011*R_130[0]+P_101010111*R_131[0]+-1*P_101010211*R_132[0]+P_101110011*R_140[0]+-1*P_101110111*R_141[0]+P_101110211*R_142[0]; double PR_000011011030=P_000011011*R_030[0]+-1*P_000011111*R_031[0]+P_000011211*R_032[0]+-1*P_000111011*R_040[0]+P_000111111*R_041[0]+-1*P_000111211*R_042[0]+P_000211011*R_050[0]+-1*P_000211111*R_051[0]+P_000211211*R_052[0]; double PR_000010012030=P_000010012*R_030[0]+-1*P_000010112*R_031[0]+P_000010212*R_032[0]+-1*P_000010312*R_033[0]+-1*P_000110012*R_040[0]+P_000110112*R_041[0]+-1*P_000110212*R_042[0]+P_000110312*R_043[0]; double PR_002000020030=P_002000020*R_030[0]+-1*P_002000120*R_031[0]+P_002000220*R_032[0]+-1*P_102000020*R_130[0]+P_102000120*R_131[0]+-1*P_102000220*R_132[0]+P_202000020*R_230[0]+-1*P_202000120*R_231[0]+P_202000220*R_232[0]; double PR_001001020030=P_001001020*R_030[0]+-1*P_001001120*R_031[0]+P_001001220*R_032[0]+-1*P_001101020*R_040[0]+P_001101120*R_041[0]+-1*P_001101220*R_042[0]+-1*P_101001020*R_130[0]+P_101001120*R_131[0]+-1*P_101001220*R_132[0]+P_101101020*R_140[0]+-1*P_101101120*R_141[0]+P_101101220*R_142[0]; double PR_000002020030=P_000002020*R_030[0]+-1*P_000002120*R_031[0]+P_000002220*R_032[0]+-1*P_000102020*R_040[0]+P_000102120*R_041[0]+-1*P_000102220*R_042[0]+P_000202020*R_050[0]+-1*P_000202120*R_051[0]+P_000202220*R_052[0]; double PR_001000021030=P_001000021*R_030[0]+-1*P_001000121*R_031[0]+P_001000221*R_032[0]+-1*P_001000321*R_033[0]+-1*P_101000021*R_130[0]+P_101000121*R_131[0]+-1*P_101000221*R_132[0]+P_101000321*R_133[0]; double PR_000001021030=P_000001021*R_030[0]+-1*P_000001121*R_031[0]+P_000001221*R_032[0]+-1*P_000001321*R_033[0]+-1*P_000101021*R_040[0]+P_000101121*R_041[0]+-1*P_000101221*R_042[0]+P_000101321*R_043[0]; double PR_000000022030=P_000000022*R_030[0]+-1*P_000000122*R_031[0]+P_000000222*R_032[0]+-1*P_000000322*R_033[0]+P_000000422*R_034[0]; double PR_022000000102=P_022000000*R_102[0]+-1*P_122000000*R_202[0]+P_222000000*R_302[0]+-1*P_322000000*R_402[0]+P_422000000*R_502[0]; double PR_021001000102=P_021001000*R_102[0]+-1*P_021101000*R_112[0]+-1*P_121001000*R_202[0]+P_121101000*R_212[0]+P_221001000*R_302[0]+-1*P_221101000*R_312[0]+-1*P_321001000*R_402[0]+P_321101000*R_412[0]; double PR_020002000102=P_020002000*R_102[0]+-1*P_020102000*R_112[0]+P_020202000*R_122[0]+-1*P_120002000*R_202[0]+P_120102000*R_212[0]+-1*P_120202000*R_222[0]+P_220002000*R_302[0]+-1*P_220102000*R_312[0]+P_220202000*R_322[0]; double PR_021000001102=P_021000001*R_102[0]+-1*P_021000101*R_103[0]+-1*P_121000001*R_202[0]+P_121000101*R_203[0]+P_221000001*R_302[0]+-1*P_221000101*R_303[0]+-1*P_321000001*R_402[0]+P_321000101*R_403[0]; double PR_020001001102=P_020001001*R_102[0]+-1*P_020001101*R_103[0]+-1*P_020101001*R_112[0]+P_020101101*R_113[0]+-1*P_120001001*R_202[0]+P_120001101*R_203[0]+P_120101001*R_212[0]+-1*P_120101101*R_213[0]+P_220001001*R_302[0]+-1*P_220001101*R_303[0]+-1*P_220101001*R_312[0]+P_220101101*R_313[0]; double PR_020000002102=P_020000002*R_102[0]+-1*P_020000102*R_103[0]+P_020000202*R_104[0]+-1*P_120000002*R_202[0]+P_120000102*R_203[0]+-1*P_120000202*R_204[0]+P_220000002*R_302[0]+-1*P_220000102*R_303[0]+P_220000202*R_304[0]; double PR_012010000102=P_012010000*R_102[0]+-1*P_012110000*R_112[0]+-1*P_112010000*R_202[0]+P_112110000*R_212[0]+P_212010000*R_302[0]+-1*P_212110000*R_312[0]+-1*P_312010000*R_402[0]+P_312110000*R_412[0]; double PR_011011000102=P_011011000*R_102[0]+-1*P_011111000*R_112[0]+P_011211000*R_122[0]+-1*P_111011000*R_202[0]+P_111111000*R_212[0]+-1*P_111211000*R_222[0]+P_211011000*R_302[0]+-1*P_211111000*R_312[0]+P_211211000*R_322[0]; double PR_010012000102=P_010012000*R_102[0]+-1*P_010112000*R_112[0]+P_010212000*R_122[0]+-1*P_010312000*R_132[0]+-1*P_110012000*R_202[0]+P_110112000*R_212[0]+-1*P_110212000*R_222[0]+P_110312000*R_232[0]; double PR_011010001102=P_011010001*R_102[0]+-1*P_011010101*R_103[0]+-1*P_011110001*R_112[0]+P_011110101*R_113[0]+-1*P_111010001*R_202[0]+P_111010101*R_203[0]+P_111110001*R_212[0]+-1*P_111110101*R_213[0]+P_211010001*R_302[0]+-1*P_211010101*R_303[0]+-1*P_211110001*R_312[0]+P_211110101*R_313[0]; double PR_010011001102=P_010011001*R_102[0]+-1*P_010011101*R_103[0]+-1*P_010111001*R_112[0]+P_010111101*R_113[0]+P_010211001*R_122[0]+-1*P_010211101*R_123[0]+-1*P_110011001*R_202[0]+P_110011101*R_203[0]+P_110111001*R_212[0]+-1*P_110111101*R_213[0]+-1*P_110211001*R_222[0]+P_110211101*R_223[0]; double PR_010010002102=P_010010002*R_102[0]+-1*P_010010102*R_103[0]+P_010010202*R_104[0]+-1*P_010110002*R_112[0]+P_010110102*R_113[0]+-1*P_010110202*R_114[0]+-1*P_110010002*R_202[0]+P_110010102*R_203[0]+-1*P_110010202*R_204[0]+P_110110002*R_212[0]+-1*P_110110102*R_213[0]+P_110110202*R_214[0]; double PR_002020000102=P_002020000*R_102[0]+-1*P_002120000*R_112[0]+P_002220000*R_122[0]+-1*P_102020000*R_202[0]+P_102120000*R_212[0]+-1*P_102220000*R_222[0]+P_202020000*R_302[0]+-1*P_202120000*R_312[0]+P_202220000*R_322[0]; double PR_001021000102=P_001021000*R_102[0]+-1*P_001121000*R_112[0]+P_001221000*R_122[0]+-1*P_001321000*R_132[0]+-1*P_101021000*R_202[0]+P_101121000*R_212[0]+-1*P_101221000*R_222[0]+P_101321000*R_232[0]; double PR_000022000102=P_000022000*R_102[0]+-1*P_000122000*R_112[0]+P_000222000*R_122[0]+-1*P_000322000*R_132[0]+P_000422000*R_142[0]; double PR_001020001102=P_001020001*R_102[0]+-1*P_001020101*R_103[0]+-1*P_001120001*R_112[0]+P_001120101*R_113[0]+P_001220001*R_122[0]+-1*P_001220101*R_123[0]+-1*P_101020001*R_202[0]+P_101020101*R_203[0]+P_101120001*R_212[0]+-1*P_101120101*R_213[0]+-1*P_101220001*R_222[0]+P_101220101*R_223[0]; double PR_000021001102=P_000021001*R_102[0]+-1*P_000021101*R_103[0]+-1*P_000121001*R_112[0]+P_000121101*R_113[0]+P_000221001*R_122[0]+-1*P_000221101*R_123[0]+-1*P_000321001*R_132[0]+P_000321101*R_133[0]; double PR_000020002102=P_000020002*R_102[0]+-1*P_000020102*R_103[0]+P_000020202*R_104[0]+-1*P_000120002*R_112[0]+P_000120102*R_113[0]+-1*P_000120202*R_114[0]+P_000220002*R_122[0]+-1*P_000220102*R_123[0]+P_000220202*R_124[0]; double PR_012000010102=P_012000010*R_102[0]+-1*P_012000110*R_103[0]+-1*P_112000010*R_202[0]+P_112000110*R_203[0]+P_212000010*R_302[0]+-1*P_212000110*R_303[0]+-1*P_312000010*R_402[0]+P_312000110*R_403[0]; double PR_011001010102=P_011001010*R_102[0]+-1*P_011001110*R_103[0]+-1*P_011101010*R_112[0]+P_011101110*R_113[0]+-1*P_111001010*R_202[0]+P_111001110*R_203[0]+P_111101010*R_212[0]+-1*P_111101110*R_213[0]+P_211001010*R_302[0]+-1*P_211001110*R_303[0]+-1*P_211101010*R_312[0]+P_211101110*R_313[0]; double PR_010002010102=P_010002010*R_102[0]+-1*P_010002110*R_103[0]+-1*P_010102010*R_112[0]+P_010102110*R_113[0]+P_010202010*R_122[0]+-1*P_010202110*R_123[0]+-1*P_110002010*R_202[0]+P_110002110*R_203[0]+P_110102010*R_212[0]+-1*P_110102110*R_213[0]+-1*P_110202010*R_222[0]+P_110202110*R_223[0]; double PR_011000011102=P_011000011*R_102[0]+-1*P_011000111*R_103[0]+P_011000211*R_104[0]+-1*P_111000011*R_202[0]+P_111000111*R_203[0]+-1*P_111000211*R_204[0]+P_211000011*R_302[0]+-1*P_211000111*R_303[0]+P_211000211*R_304[0]; double PR_010001011102=P_010001011*R_102[0]+-1*P_010001111*R_103[0]+P_010001211*R_104[0]+-1*P_010101011*R_112[0]+P_010101111*R_113[0]+-1*P_010101211*R_114[0]+-1*P_110001011*R_202[0]+P_110001111*R_203[0]+-1*P_110001211*R_204[0]+P_110101011*R_212[0]+-1*P_110101111*R_213[0]+P_110101211*R_214[0]; double PR_010000012102=P_010000012*R_102[0]+-1*P_010000112*R_103[0]+P_010000212*R_104[0]+-1*P_010000312*R_105[0]+-1*P_110000012*R_202[0]+P_110000112*R_203[0]+-1*P_110000212*R_204[0]+P_110000312*R_205[0]; double PR_002010010102=P_002010010*R_102[0]+-1*P_002010110*R_103[0]+-1*P_002110010*R_112[0]+P_002110110*R_113[0]+-1*P_102010010*R_202[0]+P_102010110*R_203[0]+P_102110010*R_212[0]+-1*P_102110110*R_213[0]+P_202010010*R_302[0]+-1*P_202010110*R_303[0]+-1*P_202110010*R_312[0]+P_202110110*R_313[0]; double PR_001011010102=P_001011010*R_102[0]+-1*P_001011110*R_103[0]+-1*P_001111010*R_112[0]+P_001111110*R_113[0]+P_001211010*R_122[0]+-1*P_001211110*R_123[0]+-1*P_101011010*R_202[0]+P_101011110*R_203[0]+P_101111010*R_212[0]+-1*P_101111110*R_213[0]+-1*P_101211010*R_222[0]+P_101211110*R_223[0]; double PR_000012010102=P_000012010*R_102[0]+-1*P_000012110*R_103[0]+-1*P_000112010*R_112[0]+P_000112110*R_113[0]+P_000212010*R_122[0]+-1*P_000212110*R_123[0]+-1*P_000312010*R_132[0]+P_000312110*R_133[0]; double PR_001010011102=P_001010011*R_102[0]+-1*P_001010111*R_103[0]+P_001010211*R_104[0]+-1*P_001110011*R_112[0]+P_001110111*R_113[0]+-1*P_001110211*R_114[0]+-1*P_101010011*R_202[0]+P_101010111*R_203[0]+-1*P_101010211*R_204[0]+P_101110011*R_212[0]+-1*P_101110111*R_213[0]+P_101110211*R_214[0]; double PR_000011011102=P_000011011*R_102[0]+-1*P_000011111*R_103[0]+P_000011211*R_104[0]+-1*P_000111011*R_112[0]+P_000111111*R_113[0]+-1*P_000111211*R_114[0]+P_000211011*R_122[0]+-1*P_000211111*R_123[0]+P_000211211*R_124[0]; double PR_000010012102=P_000010012*R_102[0]+-1*P_000010112*R_103[0]+P_000010212*R_104[0]+-1*P_000010312*R_105[0]+-1*P_000110012*R_112[0]+P_000110112*R_113[0]+-1*P_000110212*R_114[0]+P_000110312*R_115[0]; double PR_002000020102=P_002000020*R_102[0]+-1*P_002000120*R_103[0]+P_002000220*R_104[0]+-1*P_102000020*R_202[0]+P_102000120*R_203[0]+-1*P_102000220*R_204[0]+P_202000020*R_302[0]+-1*P_202000120*R_303[0]+P_202000220*R_304[0]; double PR_001001020102=P_001001020*R_102[0]+-1*P_001001120*R_103[0]+P_001001220*R_104[0]+-1*P_001101020*R_112[0]+P_001101120*R_113[0]+-1*P_001101220*R_114[0]+-1*P_101001020*R_202[0]+P_101001120*R_203[0]+-1*P_101001220*R_204[0]+P_101101020*R_212[0]+-1*P_101101120*R_213[0]+P_101101220*R_214[0]; double PR_000002020102=P_000002020*R_102[0]+-1*P_000002120*R_103[0]+P_000002220*R_104[0]+-1*P_000102020*R_112[0]+P_000102120*R_113[0]+-1*P_000102220*R_114[0]+P_000202020*R_122[0]+-1*P_000202120*R_123[0]+P_000202220*R_124[0]; double PR_001000021102=P_001000021*R_102[0]+-1*P_001000121*R_103[0]+P_001000221*R_104[0]+-1*P_001000321*R_105[0]+-1*P_101000021*R_202[0]+P_101000121*R_203[0]+-1*P_101000221*R_204[0]+P_101000321*R_205[0]; double PR_000001021102=P_000001021*R_102[0]+-1*P_000001121*R_103[0]+P_000001221*R_104[0]+-1*P_000001321*R_105[0]+-1*P_000101021*R_112[0]+P_000101121*R_113[0]+-1*P_000101221*R_114[0]+P_000101321*R_115[0]; double PR_000000022102=P_000000022*R_102[0]+-1*P_000000122*R_103[0]+P_000000222*R_104[0]+-1*P_000000322*R_105[0]+P_000000422*R_106[0]; double PR_022000000111=P_022000000*R_111[0]+-1*P_122000000*R_211[0]+P_222000000*R_311[0]+-1*P_322000000*R_411[0]+P_422000000*R_511[0]; double PR_021001000111=P_021001000*R_111[0]+-1*P_021101000*R_121[0]+-1*P_121001000*R_211[0]+P_121101000*R_221[0]+P_221001000*R_311[0]+-1*P_221101000*R_321[0]+-1*P_321001000*R_411[0]+P_321101000*R_421[0]; double PR_020002000111=P_020002000*R_111[0]+-1*P_020102000*R_121[0]+P_020202000*R_131[0]+-1*P_120002000*R_211[0]+P_120102000*R_221[0]+-1*P_120202000*R_231[0]+P_220002000*R_311[0]+-1*P_220102000*R_321[0]+P_220202000*R_331[0]; double PR_021000001111=P_021000001*R_111[0]+-1*P_021000101*R_112[0]+-1*P_121000001*R_211[0]+P_121000101*R_212[0]+P_221000001*R_311[0]+-1*P_221000101*R_312[0]+-1*P_321000001*R_411[0]+P_321000101*R_412[0]; double PR_020001001111=P_020001001*R_111[0]+-1*P_020001101*R_112[0]+-1*P_020101001*R_121[0]+P_020101101*R_122[0]+-1*P_120001001*R_211[0]+P_120001101*R_212[0]+P_120101001*R_221[0]+-1*P_120101101*R_222[0]+P_220001001*R_311[0]+-1*P_220001101*R_312[0]+-1*P_220101001*R_321[0]+P_220101101*R_322[0]; double PR_020000002111=P_020000002*R_111[0]+-1*P_020000102*R_112[0]+P_020000202*R_113[0]+-1*P_120000002*R_211[0]+P_120000102*R_212[0]+-1*P_120000202*R_213[0]+P_220000002*R_311[0]+-1*P_220000102*R_312[0]+P_220000202*R_313[0]; double PR_012010000111=P_012010000*R_111[0]+-1*P_012110000*R_121[0]+-1*P_112010000*R_211[0]+P_112110000*R_221[0]+P_212010000*R_311[0]+-1*P_212110000*R_321[0]+-1*P_312010000*R_411[0]+P_312110000*R_421[0]; double PR_011011000111=P_011011000*R_111[0]+-1*P_011111000*R_121[0]+P_011211000*R_131[0]+-1*P_111011000*R_211[0]+P_111111000*R_221[0]+-1*P_111211000*R_231[0]+P_211011000*R_311[0]+-1*P_211111000*R_321[0]+P_211211000*R_331[0]; double PR_010012000111=P_010012000*R_111[0]+-1*P_010112000*R_121[0]+P_010212000*R_131[0]+-1*P_010312000*R_141[0]+-1*P_110012000*R_211[0]+P_110112000*R_221[0]+-1*P_110212000*R_231[0]+P_110312000*R_241[0]; double PR_011010001111=P_011010001*R_111[0]+-1*P_011010101*R_112[0]+-1*P_011110001*R_121[0]+P_011110101*R_122[0]+-1*P_111010001*R_211[0]+P_111010101*R_212[0]+P_111110001*R_221[0]+-1*P_111110101*R_222[0]+P_211010001*R_311[0]+-1*P_211010101*R_312[0]+-1*P_211110001*R_321[0]+P_211110101*R_322[0]; double PR_010011001111=P_010011001*R_111[0]+-1*P_010011101*R_112[0]+-1*P_010111001*R_121[0]+P_010111101*R_122[0]+P_010211001*R_131[0]+-1*P_010211101*R_132[0]+-1*P_110011001*R_211[0]+P_110011101*R_212[0]+P_110111001*R_221[0]+-1*P_110111101*R_222[0]+-1*P_110211001*R_231[0]+P_110211101*R_232[0]; double PR_010010002111=P_010010002*R_111[0]+-1*P_010010102*R_112[0]+P_010010202*R_113[0]+-1*P_010110002*R_121[0]+P_010110102*R_122[0]+-1*P_010110202*R_123[0]+-1*P_110010002*R_211[0]+P_110010102*R_212[0]+-1*P_110010202*R_213[0]+P_110110002*R_221[0]+-1*P_110110102*R_222[0]+P_110110202*R_223[0]; double PR_002020000111=P_002020000*R_111[0]+-1*P_002120000*R_121[0]+P_002220000*R_131[0]+-1*P_102020000*R_211[0]+P_102120000*R_221[0]+-1*P_102220000*R_231[0]+P_202020000*R_311[0]+-1*P_202120000*R_321[0]+P_202220000*R_331[0]; double PR_001021000111=P_001021000*R_111[0]+-1*P_001121000*R_121[0]+P_001221000*R_131[0]+-1*P_001321000*R_141[0]+-1*P_101021000*R_211[0]+P_101121000*R_221[0]+-1*P_101221000*R_231[0]+P_101321000*R_241[0]; double PR_000022000111=P_000022000*R_111[0]+-1*P_000122000*R_121[0]+P_000222000*R_131[0]+-1*P_000322000*R_141[0]+P_000422000*R_151[0]; double PR_001020001111=P_001020001*R_111[0]+-1*P_001020101*R_112[0]+-1*P_001120001*R_121[0]+P_001120101*R_122[0]+P_001220001*R_131[0]+-1*P_001220101*R_132[0]+-1*P_101020001*R_211[0]+P_101020101*R_212[0]+P_101120001*R_221[0]+-1*P_101120101*R_222[0]+-1*P_101220001*R_231[0]+P_101220101*R_232[0]; double PR_000021001111=P_000021001*R_111[0]+-1*P_000021101*R_112[0]+-1*P_000121001*R_121[0]+P_000121101*R_122[0]+P_000221001*R_131[0]+-1*P_000221101*R_132[0]+-1*P_000321001*R_141[0]+P_000321101*R_142[0]; double PR_000020002111=P_000020002*R_111[0]+-1*P_000020102*R_112[0]+P_000020202*R_113[0]+-1*P_000120002*R_121[0]+P_000120102*R_122[0]+-1*P_000120202*R_123[0]+P_000220002*R_131[0]+-1*P_000220102*R_132[0]+P_000220202*R_133[0]; double PR_012000010111=P_012000010*R_111[0]+-1*P_012000110*R_112[0]+-1*P_112000010*R_211[0]+P_112000110*R_212[0]+P_212000010*R_311[0]+-1*P_212000110*R_312[0]+-1*P_312000010*R_411[0]+P_312000110*R_412[0]; double PR_011001010111=P_011001010*R_111[0]+-1*P_011001110*R_112[0]+-1*P_011101010*R_121[0]+P_011101110*R_122[0]+-1*P_111001010*R_211[0]+P_111001110*R_212[0]+P_111101010*R_221[0]+-1*P_111101110*R_222[0]+P_211001010*R_311[0]+-1*P_211001110*R_312[0]+-1*P_211101010*R_321[0]+P_211101110*R_322[0]; double PR_010002010111=P_010002010*R_111[0]+-1*P_010002110*R_112[0]+-1*P_010102010*R_121[0]+P_010102110*R_122[0]+P_010202010*R_131[0]+-1*P_010202110*R_132[0]+-1*P_110002010*R_211[0]+P_110002110*R_212[0]+P_110102010*R_221[0]+-1*P_110102110*R_222[0]+-1*P_110202010*R_231[0]+P_110202110*R_232[0]; double PR_011000011111=P_011000011*R_111[0]+-1*P_011000111*R_112[0]+P_011000211*R_113[0]+-1*P_111000011*R_211[0]+P_111000111*R_212[0]+-1*P_111000211*R_213[0]+P_211000011*R_311[0]+-1*P_211000111*R_312[0]+P_211000211*R_313[0]; double PR_010001011111=P_010001011*R_111[0]+-1*P_010001111*R_112[0]+P_010001211*R_113[0]+-1*P_010101011*R_121[0]+P_010101111*R_122[0]+-1*P_010101211*R_123[0]+-1*P_110001011*R_211[0]+P_110001111*R_212[0]+-1*P_110001211*R_213[0]+P_110101011*R_221[0]+-1*P_110101111*R_222[0]+P_110101211*R_223[0]; double PR_010000012111=P_010000012*R_111[0]+-1*P_010000112*R_112[0]+P_010000212*R_113[0]+-1*P_010000312*R_114[0]+-1*P_110000012*R_211[0]+P_110000112*R_212[0]+-1*P_110000212*R_213[0]+P_110000312*R_214[0]; double PR_002010010111=P_002010010*R_111[0]+-1*P_002010110*R_112[0]+-1*P_002110010*R_121[0]+P_002110110*R_122[0]+-1*P_102010010*R_211[0]+P_102010110*R_212[0]+P_102110010*R_221[0]+-1*P_102110110*R_222[0]+P_202010010*R_311[0]+-1*P_202010110*R_312[0]+-1*P_202110010*R_321[0]+P_202110110*R_322[0]; double PR_001011010111=P_001011010*R_111[0]+-1*P_001011110*R_112[0]+-1*P_001111010*R_121[0]+P_001111110*R_122[0]+P_001211010*R_131[0]+-1*P_001211110*R_132[0]+-1*P_101011010*R_211[0]+P_101011110*R_212[0]+P_101111010*R_221[0]+-1*P_101111110*R_222[0]+-1*P_101211010*R_231[0]+P_101211110*R_232[0]; double PR_000012010111=P_000012010*R_111[0]+-1*P_000012110*R_112[0]+-1*P_000112010*R_121[0]+P_000112110*R_122[0]+P_000212010*R_131[0]+-1*P_000212110*R_132[0]+-1*P_000312010*R_141[0]+P_000312110*R_142[0]; double PR_001010011111=P_001010011*R_111[0]+-1*P_001010111*R_112[0]+P_001010211*R_113[0]+-1*P_001110011*R_121[0]+P_001110111*R_122[0]+-1*P_001110211*R_123[0]+-1*P_101010011*R_211[0]+P_101010111*R_212[0]+-1*P_101010211*R_213[0]+P_101110011*R_221[0]+-1*P_101110111*R_222[0]+P_101110211*R_223[0]; double PR_000011011111=P_000011011*R_111[0]+-1*P_000011111*R_112[0]+P_000011211*R_113[0]+-1*P_000111011*R_121[0]+P_000111111*R_122[0]+-1*P_000111211*R_123[0]+P_000211011*R_131[0]+-1*P_000211111*R_132[0]+P_000211211*R_133[0]; double PR_000010012111=P_000010012*R_111[0]+-1*P_000010112*R_112[0]+P_000010212*R_113[0]+-1*P_000010312*R_114[0]+-1*P_000110012*R_121[0]+P_000110112*R_122[0]+-1*P_000110212*R_123[0]+P_000110312*R_124[0]; double PR_002000020111=P_002000020*R_111[0]+-1*P_002000120*R_112[0]+P_002000220*R_113[0]+-1*P_102000020*R_211[0]+P_102000120*R_212[0]+-1*P_102000220*R_213[0]+P_202000020*R_311[0]+-1*P_202000120*R_312[0]+P_202000220*R_313[0]; double PR_001001020111=P_001001020*R_111[0]+-1*P_001001120*R_112[0]+P_001001220*R_113[0]+-1*P_001101020*R_121[0]+P_001101120*R_122[0]+-1*P_001101220*R_123[0]+-1*P_101001020*R_211[0]+P_101001120*R_212[0]+-1*P_101001220*R_213[0]+P_101101020*R_221[0]+-1*P_101101120*R_222[0]+P_101101220*R_223[0]; double PR_000002020111=P_000002020*R_111[0]+-1*P_000002120*R_112[0]+P_000002220*R_113[0]+-1*P_000102020*R_121[0]+P_000102120*R_122[0]+-1*P_000102220*R_123[0]+P_000202020*R_131[0]+-1*P_000202120*R_132[0]+P_000202220*R_133[0]; double PR_001000021111=P_001000021*R_111[0]+-1*P_001000121*R_112[0]+P_001000221*R_113[0]+-1*P_001000321*R_114[0]+-1*P_101000021*R_211[0]+P_101000121*R_212[0]+-1*P_101000221*R_213[0]+P_101000321*R_214[0]; double PR_000001021111=P_000001021*R_111[0]+-1*P_000001121*R_112[0]+P_000001221*R_113[0]+-1*P_000001321*R_114[0]+-1*P_000101021*R_121[0]+P_000101121*R_122[0]+-1*P_000101221*R_123[0]+P_000101321*R_124[0]; double PR_000000022111=P_000000022*R_111[0]+-1*P_000000122*R_112[0]+P_000000222*R_113[0]+-1*P_000000322*R_114[0]+P_000000422*R_115[0]; double PR_022000000120=P_022000000*R_120[0]+-1*P_122000000*R_220[0]+P_222000000*R_320[0]+-1*P_322000000*R_420[0]+P_422000000*R_520[0]; double PR_021001000120=P_021001000*R_120[0]+-1*P_021101000*R_130[0]+-1*P_121001000*R_220[0]+P_121101000*R_230[0]+P_221001000*R_320[0]+-1*P_221101000*R_330[0]+-1*P_321001000*R_420[0]+P_321101000*R_430[0]; double PR_020002000120=P_020002000*R_120[0]+-1*P_020102000*R_130[0]+P_020202000*R_140[0]+-1*P_120002000*R_220[0]+P_120102000*R_230[0]+-1*P_120202000*R_240[0]+P_220002000*R_320[0]+-1*P_220102000*R_330[0]+P_220202000*R_340[0]; double PR_021000001120=P_021000001*R_120[0]+-1*P_021000101*R_121[0]+-1*P_121000001*R_220[0]+P_121000101*R_221[0]+P_221000001*R_320[0]+-1*P_221000101*R_321[0]+-1*P_321000001*R_420[0]+P_321000101*R_421[0]; double PR_020001001120=P_020001001*R_120[0]+-1*P_020001101*R_121[0]+-1*P_020101001*R_130[0]+P_020101101*R_131[0]+-1*P_120001001*R_220[0]+P_120001101*R_221[0]+P_120101001*R_230[0]+-1*P_120101101*R_231[0]+P_220001001*R_320[0]+-1*P_220001101*R_321[0]+-1*P_220101001*R_330[0]+P_220101101*R_331[0]; double PR_020000002120=P_020000002*R_120[0]+-1*P_020000102*R_121[0]+P_020000202*R_122[0]+-1*P_120000002*R_220[0]+P_120000102*R_221[0]+-1*P_120000202*R_222[0]+P_220000002*R_320[0]+-1*P_220000102*R_321[0]+P_220000202*R_322[0]; double PR_012010000120=P_012010000*R_120[0]+-1*P_012110000*R_130[0]+-1*P_112010000*R_220[0]+P_112110000*R_230[0]+P_212010000*R_320[0]+-1*P_212110000*R_330[0]+-1*P_312010000*R_420[0]+P_312110000*R_430[0]; double PR_011011000120=P_011011000*R_120[0]+-1*P_011111000*R_130[0]+P_011211000*R_140[0]+-1*P_111011000*R_220[0]+P_111111000*R_230[0]+-1*P_111211000*R_240[0]+P_211011000*R_320[0]+-1*P_211111000*R_330[0]+P_211211000*R_340[0]; double PR_010012000120=P_010012000*R_120[0]+-1*P_010112000*R_130[0]+P_010212000*R_140[0]+-1*P_010312000*R_150[0]+-1*P_110012000*R_220[0]+P_110112000*R_230[0]+-1*P_110212000*R_240[0]+P_110312000*R_250[0]; double PR_011010001120=P_011010001*R_120[0]+-1*P_011010101*R_121[0]+-1*P_011110001*R_130[0]+P_011110101*R_131[0]+-1*P_111010001*R_220[0]+P_111010101*R_221[0]+P_111110001*R_230[0]+-1*P_111110101*R_231[0]+P_211010001*R_320[0]+-1*P_211010101*R_321[0]+-1*P_211110001*R_330[0]+P_211110101*R_331[0]; double PR_010011001120=P_010011001*R_120[0]+-1*P_010011101*R_121[0]+-1*P_010111001*R_130[0]+P_010111101*R_131[0]+P_010211001*R_140[0]+-1*P_010211101*R_141[0]+-1*P_110011001*R_220[0]+P_110011101*R_221[0]+P_110111001*R_230[0]+-1*P_110111101*R_231[0]+-1*P_110211001*R_240[0]+P_110211101*R_241[0]; double PR_010010002120=P_010010002*R_120[0]+-1*P_010010102*R_121[0]+P_010010202*R_122[0]+-1*P_010110002*R_130[0]+P_010110102*R_131[0]+-1*P_010110202*R_132[0]+-1*P_110010002*R_220[0]+P_110010102*R_221[0]+-1*P_110010202*R_222[0]+P_110110002*R_230[0]+-1*P_110110102*R_231[0]+P_110110202*R_232[0]; double PR_002020000120=P_002020000*R_120[0]+-1*P_002120000*R_130[0]+P_002220000*R_140[0]+-1*P_102020000*R_220[0]+P_102120000*R_230[0]+-1*P_102220000*R_240[0]+P_202020000*R_320[0]+-1*P_202120000*R_330[0]+P_202220000*R_340[0]; double PR_001021000120=P_001021000*R_120[0]+-1*P_001121000*R_130[0]+P_001221000*R_140[0]+-1*P_001321000*R_150[0]+-1*P_101021000*R_220[0]+P_101121000*R_230[0]+-1*P_101221000*R_240[0]+P_101321000*R_250[0]; double PR_000022000120=P_000022000*R_120[0]+-1*P_000122000*R_130[0]+P_000222000*R_140[0]+-1*P_000322000*R_150[0]+P_000422000*R_160[0]; double PR_001020001120=P_001020001*R_120[0]+-1*P_001020101*R_121[0]+-1*P_001120001*R_130[0]+P_001120101*R_131[0]+P_001220001*R_140[0]+-1*P_001220101*R_141[0]+-1*P_101020001*R_220[0]+P_101020101*R_221[0]+P_101120001*R_230[0]+-1*P_101120101*R_231[0]+-1*P_101220001*R_240[0]+P_101220101*R_241[0]; double PR_000021001120=P_000021001*R_120[0]+-1*P_000021101*R_121[0]+-1*P_000121001*R_130[0]+P_000121101*R_131[0]+P_000221001*R_140[0]+-1*P_000221101*R_141[0]+-1*P_000321001*R_150[0]+P_000321101*R_151[0]; double PR_000020002120=P_000020002*R_120[0]+-1*P_000020102*R_121[0]+P_000020202*R_122[0]+-1*P_000120002*R_130[0]+P_000120102*R_131[0]+-1*P_000120202*R_132[0]+P_000220002*R_140[0]+-1*P_000220102*R_141[0]+P_000220202*R_142[0]; double PR_012000010120=P_012000010*R_120[0]+-1*P_012000110*R_121[0]+-1*P_112000010*R_220[0]+P_112000110*R_221[0]+P_212000010*R_320[0]+-1*P_212000110*R_321[0]+-1*P_312000010*R_420[0]+P_312000110*R_421[0]; double PR_011001010120=P_011001010*R_120[0]+-1*P_011001110*R_121[0]+-1*P_011101010*R_130[0]+P_011101110*R_131[0]+-1*P_111001010*R_220[0]+P_111001110*R_221[0]+P_111101010*R_230[0]+-1*P_111101110*R_231[0]+P_211001010*R_320[0]+-1*P_211001110*R_321[0]+-1*P_211101010*R_330[0]+P_211101110*R_331[0]; double PR_010002010120=P_010002010*R_120[0]+-1*P_010002110*R_121[0]+-1*P_010102010*R_130[0]+P_010102110*R_131[0]+P_010202010*R_140[0]+-1*P_010202110*R_141[0]+-1*P_110002010*R_220[0]+P_110002110*R_221[0]+P_110102010*R_230[0]+-1*P_110102110*R_231[0]+-1*P_110202010*R_240[0]+P_110202110*R_241[0]; double PR_011000011120=P_011000011*R_120[0]+-1*P_011000111*R_121[0]+P_011000211*R_122[0]+-1*P_111000011*R_220[0]+P_111000111*R_221[0]+-1*P_111000211*R_222[0]+P_211000011*R_320[0]+-1*P_211000111*R_321[0]+P_211000211*R_322[0]; double PR_010001011120=P_010001011*R_120[0]+-1*P_010001111*R_121[0]+P_010001211*R_122[0]+-1*P_010101011*R_130[0]+P_010101111*R_131[0]+-1*P_010101211*R_132[0]+-1*P_110001011*R_220[0]+P_110001111*R_221[0]+-1*P_110001211*R_222[0]+P_110101011*R_230[0]+-1*P_110101111*R_231[0]+P_110101211*R_232[0]; double PR_010000012120=P_010000012*R_120[0]+-1*P_010000112*R_121[0]+P_010000212*R_122[0]+-1*P_010000312*R_123[0]+-1*P_110000012*R_220[0]+P_110000112*R_221[0]+-1*P_110000212*R_222[0]+P_110000312*R_223[0]; double PR_002010010120=P_002010010*R_120[0]+-1*P_002010110*R_121[0]+-1*P_002110010*R_130[0]+P_002110110*R_131[0]+-1*P_102010010*R_220[0]+P_102010110*R_221[0]+P_102110010*R_230[0]+-1*P_102110110*R_231[0]+P_202010010*R_320[0]+-1*P_202010110*R_321[0]+-1*P_202110010*R_330[0]+P_202110110*R_331[0]; double PR_001011010120=P_001011010*R_120[0]+-1*P_001011110*R_121[0]+-1*P_001111010*R_130[0]+P_001111110*R_131[0]+P_001211010*R_140[0]+-1*P_001211110*R_141[0]+-1*P_101011010*R_220[0]+P_101011110*R_221[0]+P_101111010*R_230[0]+-1*P_101111110*R_231[0]+-1*P_101211010*R_240[0]+P_101211110*R_241[0]; double PR_000012010120=P_000012010*R_120[0]+-1*P_000012110*R_121[0]+-1*P_000112010*R_130[0]+P_000112110*R_131[0]+P_000212010*R_140[0]+-1*P_000212110*R_141[0]+-1*P_000312010*R_150[0]+P_000312110*R_151[0]; double PR_001010011120=P_001010011*R_120[0]+-1*P_001010111*R_121[0]+P_001010211*R_122[0]+-1*P_001110011*R_130[0]+P_001110111*R_131[0]+-1*P_001110211*R_132[0]+-1*P_101010011*R_220[0]+P_101010111*R_221[0]+-1*P_101010211*R_222[0]+P_101110011*R_230[0]+-1*P_101110111*R_231[0]+P_101110211*R_232[0]; double PR_000011011120=P_000011011*R_120[0]+-1*P_000011111*R_121[0]+P_000011211*R_122[0]+-1*P_000111011*R_130[0]+P_000111111*R_131[0]+-1*P_000111211*R_132[0]+P_000211011*R_140[0]+-1*P_000211111*R_141[0]+P_000211211*R_142[0]; double PR_000010012120=P_000010012*R_120[0]+-1*P_000010112*R_121[0]+P_000010212*R_122[0]+-1*P_000010312*R_123[0]+-1*P_000110012*R_130[0]+P_000110112*R_131[0]+-1*P_000110212*R_132[0]+P_000110312*R_133[0]; double PR_002000020120=P_002000020*R_120[0]+-1*P_002000120*R_121[0]+P_002000220*R_122[0]+-1*P_102000020*R_220[0]+P_102000120*R_221[0]+-1*P_102000220*R_222[0]+P_202000020*R_320[0]+-1*P_202000120*R_321[0]+P_202000220*R_322[0]; double PR_001001020120=P_001001020*R_120[0]+-1*P_001001120*R_121[0]+P_001001220*R_122[0]+-1*P_001101020*R_130[0]+P_001101120*R_131[0]+-1*P_001101220*R_132[0]+-1*P_101001020*R_220[0]+P_101001120*R_221[0]+-1*P_101001220*R_222[0]+P_101101020*R_230[0]+-1*P_101101120*R_231[0]+P_101101220*R_232[0]; double PR_000002020120=P_000002020*R_120[0]+-1*P_000002120*R_121[0]+P_000002220*R_122[0]+-1*P_000102020*R_130[0]+P_000102120*R_131[0]+-1*P_000102220*R_132[0]+P_000202020*R_140[0]+-1*P_000202120*R_141[0]+P_000202220*R_142[0]; double PR_001000021120=P_001000021*R_120[0]+-1*P_001000121*R_121[0]+P_001000221*R_122[0]+-1*P_001000321*R_123[0]+-1*P_101000021*R_220[0]+P_101000121*R_221[0]+-1*P_101000221*R_222[0]+P_101000321*R_223[0]; double PR_000001021120=P_000001021*R_120[0]+-1*P_000001121*R_121[0]+P_000001221*R_122[0]+-1*P_000001321*R_123[0]+-1*P_000101021*R_130[0]+P_000101121*R_131[0]+-1*P_000101221*R_132[0]+P_000101321*R_133[0]; double PR_000000022120=P_000000022*R_120[0]+-1*P_000000122*R_121[0]+P_000000222*R_122[0]+-1*P_000000322*R_123[0]+P_000000422*R_124[0]; double PR_022000000201=P_022000000*R_201[0]+-1*P_122000000*R_301[0]+P_222000000*R_401[0]+-1*P_322000000*R_501[0]+P_422000000*R_601[0]; double PR_021001000201=P_021001000*R_201[0]+-1*P_021101000*R_211[0]+-1*P_121001000*R_301[0]+P_121101000*R_311[0]+P_221001000*R_401[0]+-1*P_221101000*R_411[0]+-1*P_321001000*R_501[0]+P_321101000*R_511[0]; double PR_020002000201=P_020002000*R_201[0]+-1*P_020102000*R_211[0]+P_020202000*R_221[0]+-1*P_120002000*R_301[0]+P_120102000*R_311[0]+-1*P_120202000*R_321[0]+P_220002000*R_401[0]+-1*P_220102000*R_411[0]+P_220202000*R_421[0]; double PR_021000001201=P_021000001*R_201[0]+-1*P_021000101*R_202[0]+-1*P_121000001*R_301[0]+P_121000101*R_302[0]+P_221000001*R_401[0]+-1*P_221000101*R_402[0]+-1*P_321000001*R_501[0]+P_321000101*R_502[0]; double PR_020001001201=P_020001001*R_201[0]+-1*P_020001101*R_202[0]+-1*P_020101001*R_211[0]+P_020101101*R_212[0]+-1*P_120001001*R_301[0]+P_120001101*R_302[0]+P_120101001*R_311[0]+-1*P_120101101*R_312[0]+P_220001001*R_401[0]+-1*P_220001101*R_402[0]+-1*P_220101001*R_411[0]+P_220101101*R_412[0]; double PR_020000002201=P_020000002*R_201[0]+-1*P_020000102*R_202[0]+P_020000202*R_203[0]+-1*P_120000002*R_301[0]+P_120000102*R_302[0]+-1*P_120000202*R_303[0]+P_220000002*R_401[0]+-1*P_220000102*R_402[0]+P_220000202*R_403[0]; double PR_012010000201=P_012010000*R_201[0]+-1*P_012110000*R_211[0]+-1*P_112010000*R_301[0]+P_112110000*R_311[0]+P_212010000*R_401[0]+-1*P_212110000*R_411[0]+-1*P_312010000*R_501[0]+P_312110000*R_511[0]; double PR_011011000201=P_011011000*R_201[0]+-1*P_011111000*R_211[0]+P_011211000*R_221[0]+-1*P_111011000*R_301[0]+P_111111000*R_311[0]+-1*P_111211000*R_321[0]+P_211011000*R_401[0]+-1*P_211111000*R_411[0]+P_211211000*R_421[0]; double PR_010012000201=P_010012000*R_201[0]+-1*P_010112000*R_211[0]+P_010212000*R_221[0]+-1*P_010312000*R_231[0]+-1*P_110012000*R_301[0]+P_110112000*R_311[0]+-1*P_110212000*R_321[0]+P_110312000*R_331[0]; double PR_011010001201=P_011010001*R_201[0]+-1*P_011010101*R_202[0]+-1*P_011110001*R_211[0]+P_011110101*R_212[0]+-1*P_111010001*R_301[0]+P_111010101*R_302[0]+P_111110001*R_311[0]+-1*P_111110101*R_312[0]+P_211010001*R_401[0]+-1*P_211010101*R_402[0]+-1*P_211110001*R_411[0]+P_211110101*R_412[0]; double PR_010011001201=P_010011001*R_201[0]+-1*P_010011101*R_202[0]+-1*P_010111001*R_211[0]+P_010111101*R_212[0]+P_010211001*R_221[0]+-1*P_010211101*R_222[0]+-1*P_110011001*R_301[0]+P_110011101*R_302[0]+P_110111001*R_311[0]+-1*P_110111101*R_312[0]+-1*P_110211001*R_321[0]+P_110211101*R_322[0]; double PR_010010002201=P_010010002*R_201[0]+-1*P_010010102*R_202[0]+P_010010202*R_203[0]+-1*P_010110002*R_211[0]+P_010110102*R_212[0]+-1*P_010110202*R_213[0]+-1*P_110010002*R_301[0]+P_110010102*R_302[0]+-1*P_110010202*R_303[0]+P_110110002*R_311[0]+-1*P_110110102*R_312[0]+P_110110202*R_313[0]; double PR_002020000201=P_002020000*R_201[0]+-1*P_002120000*R_211[0]+P_002220000*R_221[0]+-1*P_102020000*R_301[0]+P_102120000*R_311[0]+-1*P_102220000*R_321[0]+P_202020000*R_401[0]+-1*P_202120000*R_411[0]+P_202220000*R_421[0]; double PR_001021000201=P_001021000*R_201[0]+-1*P_001121000*R_211[0]+P_001221000*R_221[0]+-1*P_001321000*R_231[0]+-1*P_101021000*R_301[0]+P_101121000*R_311[0]+-1*P_101221000*R_321[0]+P_101321000*R_331[0]; double PR_000022000201=P_000022000*R_201[0]+-1*P_000122000*R_211[0]+P_000222000*R_221[0]+-1*P_000322000*R_231[0]+P_000422000*R_241[0]; double PR_001020001201=P_001020001*R_201[0]+-1*P_001020101*R_202[0]+-1*P_001120001*R_211[0]+P_001120101*R_212[0]+P_001220001*R_221[0]+-1*P_001220101*R_222[0]+-1*P_101020001*R_301[0]+P_101020101*R_302[0]+P_101120001*R_311[0]+-1*P_101120101*R_312[0]+-1*P_101220001*R_321[0]+P_101220101*R_322[0]; double PR_000021001201=P_000021001*R_201[0]+-1*P_000021101*R_202[0]+-1*P_000121001*R_211[0]+P_000121101*R_212[0]+P_000221001*R_221[0]+-1*P_000221101*R_222[0]+-1*P_000321001*R_231[0]+P_000321101*R_232[0]; double PR_000020002201=P_000020002*R_201[0]+-1*P_000020102*R_202[0]+P_000020202*R_203[0]+-1*P_000120002*R_211[0]+P_000120102*R_212[0]+-1*P_000120202*R_213[0]+P_000220002*R_221[0]+-1*P_000220102*R_222[0]+P_000220202*R_223[0]; double PR_012000010201=P_012000010*R_201[0]+-1*P_012000110*R_202[0]+-1*P_112000010*R_301[0]+P_112000110*R_302[0]+P_212000010*R_401[0]+-1*P_212000110*R_402[0]+-1*P_312000010*R_501[0]+P_312000110*R_502[0]; double PR_011001010201=P_011001010*R_201[0]+-1*P_011001110*R_202[0]+-1*P_011101010*R_211[0]+P_011101110*R_212[0]+-1*P_111001010*R_301[0]+P_111001110*R_302[0]+P_111101010*R_311[0]+-1*P_111101110*R_312[0]+P_211001010*R_401[0]+-1*P_211001110*R_402[0]+-1*P_211101010*R_411[0]+P_211101110*R_412[0]; double PR_010002010201=P_010002010*R_201[0]+-1*P_010002110*R_202[0]+-1*P_010102010*R_211[0]+P_010102110*R_212[0]+P_010202010*R_221[0]+-1*P_010202110*R_222[0]+-1*P_110002010*R_301[0]+P_110002110*R_302[0]+P_110102010*R_311[0]+-1*P_110102110*R_312[0]+-1*P_110202010*R_321[0]+P_110202110*R_322[0]; double PR_011000011201=P_011000011*R_201[0]+-1*P_011000111*R_202[0]+P_011000211*R_203[0]+-1*P_111000011*R_301[0]+P_111000111*R_302[0]+-1*P_111000211*R_303[0]+P_211000011*R_401[0]+-1*P_211000111*R_402[0]+P_211000211*R_403[0]; double PR_010001011201=P_010001011*R_201[0]+-1*P_010001111*R_202[0]+P_010001211*R_203[0]+-1*P_010101011*R_211[0]+P_010101111*R_212[0]+-1*P_010101211*R_213[0]+-1*P_110001011*R_301[0]+P_110001111*R_302[0]+-1*P_110001211*R_303[0]+P_110101011*R_311[0]+-1*P_110101111*R_312[0]+P_110101211*R_313[0]; double PR_010000012201=P_010000012*R_201[0]+-1*P_010000112*R_202[0]+P_010000212*R_203[0]+-1*P_010000312*R_204[0]+-1*P_110000012*R_301[0]+P_110000112*R_302[0]+-1*P_110000212*R_303[0]+P_110000312*R_304[0]; double PR_002010010201=P_002010010*R_201[0]+-1*P_002010110*R_202[0]+-1*P_002110010*R_211[0]+P_002110110*R_212[0]+-1*P_102010010*R_301[0]+P_102010110*R_302[0]+P_102110010*R_311[0]+-1*P_102110110*R_312[0]+P_202010010*R_401[0]+-1*P_202010110*R_402[0]+-1*P_202110010*R_411[0]+P_202110110*R_412[0]; double PR_001011010201=P_001011010*R_201[0]+-1*P_001011110*R_202[0]+-1*P_001111010*R_211[0]+P_001111110*R_212[0]+P_001211010*R_221[0]+-1*P_001211110*R_222[0]+-1*P_101011010*R_301[0]+P_101011110*R_302[0]+P_101111010*R_311[0]+-1*P_101111110*R_312[0]+-1*P_101211010*R_321[0]+P_101211110*R_322[0]; double PR_000012010201=P_000012010*R_201[0]+-1*P_000012110*R_202[0]+-1*P_000112010*R_211[0]+P_000112110*R_212[0]+P_000212010*R_221[0]+-1*P_000212110*R_222[0]+-1*P_000312010*R_231[0]+P_000312110*R_232[0]; double PR_001010011201=P_001010011*R_201[0]+-1*P_001010111*R_202[0]+P_001010211*R_203[0]+-1*P_001110011*R_211[0]+P_001110111*R_212[0]+-1*P_001110211*R_213[0]+-1*P_101010011*R_301[0]+P_101010111*R_302[0]+-1*P_101010211*R_303[0]+P_101110011*R_311[0]+-1*P_101110111*R_312[0]+P_101110211*R_313[0]; double PR_000011011201=P_000011011*R_201[0]+-1*P_000011111*R_202[0]+P_000011211*R_203[0]+-1*P_000111011*R_211[0]+P_000111111*R_212[0]+-1*P_000111211*R_213[0]+P_000211011*R_221[0]+-1*P_000211111*R_222[0]+P_000211211*R_223[0]; double PR_000010012201=P_000010012*R_201[0]+-1*P_000010112*R_202[0]+P_000010212*R_203[0]+-1*P_000010312*R_204[0]+-1*P_000110012*R_211[0]+P_000110112*R_212[0]+-1*P_000110212*R_213[0]+P_000110312*R_214[0]; double PR_002000020201=P_002000020*R_201[0]+-1*P_002000120*R_202[0]+P_002000220*R_203[0]+-1*P_102000020*R_301[0]+P_102000120*R_302[0]+-1*P_102000220*R_303[0]+P_202000020*R_401[0]+-1*P_202000120*R_402[0]+P_202000220*R_403[0]; double PR_001001020201=P_001001020*R_201[0]+-1*P_001001120*R_202[0]+P_001001220*R_203[0]+-1*P_001101020*R_211[0]+P_001101120*R_212[0]+-1*P_001101220*R_213[0]+-1*P_101001020*R_301[0]+P_101001120*R_302[0]+-1*P_101001220*R_303[0]+P_101101020*R_311[0]+-1*P_101101120*R_312[0]+P_101101220*R_313[0]; double PR_000002020201=P_000002020*R_201[0]+-1*P_000002120*R_202[0]+P_000002220*R_203[0]+-1*P_000102020*R_211[0]+P_000102120*R_212[0]+-1*P_000102220*R_213[0]+P_000202020*R_221[0]+-1*P_000202120*R_222[0]+P_000202220*R_223[0]; double PR_001000021201=P_001000021*R_201[0]+-1*P_001000121*R_202[0]+P_001000221*R_203[0]+-1*P_001000321*R_204[0]+-1*P_101000021*R_301[0]+P_101000121*R_302[0]+-1*P_101000221*R_303[0]+P_101000321*R_304[0]; double PR_000001021201=P_000001021*R_201[0]+-1*P_000001121*R_202[0]+P_000001221*R_203[0]+-1*P_000001321*R_204[0]+-1*P_000101021*R_211[0]+P_000101121*R_212[0]+-1*P_000101221*R_213[0]+P_000101321*R_214[0]; double PR_000000022201=P_000000022*R_201[0]+-1*P_000000122*R_202[0]+P_000000222*R_203[0]+-1*P_000000322*R_204[0]+P_000000422*R_205[0]; double PR_022000000210=P_022000000*R_210[0]+-1*P_122000000*R_310[0]+P_222000000*R_410[0]+-1*P_322000000*R_510[0]+P_422000000*R_610[0]; double PR_021001000210=P_021001000*R_210[0]+-1*P_021101000*R_220[0]+-1*P_121001000*R_310[0]+P_121101000*R_320[0]+P_221001000*R_410[0]+-1*P_221101000*R_420[0]+-1*P_321001000*R_510[0]+P_321101000*R_520[0]; double PR_020002000210=P_020002000*R_210[0]+-1*P_020102000*R_220[0]+P_020202000*R_230[0]+-1*P_120002000*R_310[0]+P_120102000*R_320[0]+-1*P_120202000*R_330[0]+P_220002000*R_410[0]+-1*P_220102000*R_420[0]+P_220202000*R_430[0]; double PR_021000001210=P_021000001*R_210[0]+-1*P_021000101*R_211[0]+-1*P_121000001*R_310[0]+P_121000101*R_311[0]+P_221000001*R_410[0]+-1*P_221000101*R_411[0]+-1*P_321000001*R_510[0]+P_321000101*R_511[0]; double PR_020001001210=P_020001001*R_210[0]+-1*P_020001101*R_211[0]+-1*P_020101001*R_220[0]+P_020101101*R_221[0]+-1*P_120001001*R_310[0]+P_120001101*R_311[0]+P_120101001*R_320[0]+-1*P_120101101*R_321[0]+P_220001001*R_410[0]+-1*P_220001101*R_411[0]+-1*P_220101001*R_420[0]+P_220101101*R_421[0]; double PR_020000002210=P_020000002*R_210[0]+-1*P_020000102*R_211[0]+P_020000202*R_212[0]+-1*P_120000002*R_310[0]+P_120000102*R_311[0]+-1*P_120000202*R_312[0]+P_220000002*R_410[0]+-1*P_220000102*R_411[0]+P_220000202*R_412[0]; double PR_012010000210=P_012010000*R_210[0]+-1*P_012110000*R_220[0]+-1*P_112010000*R_310[0]+P_112110000*R_320[0]+P_212010000*R_410[0]+-1*P_212110000*R_420[0]+-1*P_312010000*R_510[0]+P_312110000*R_520[0]; double PR_011011000210=P_011011000*R_210[0]+-1*P_011111000*R_220[0]+P_011211000*R_230[0]+-1*P_111011000*R_310[0]+P_111111000*R_320[0]+-1*P_111211000*R_330[0]+P_211011000*R_410[0]+-1*P_211111000*R_420[0]+P_211211000*R_430[0]; double PR_010012000210=P_010012000*R_210[0]+-1*P_010112000*R_220[0]+P_010212000*R_230[0]+-1*P_010312000*R_240[0]+-1*P_110012000*R_310[0]+P_110112000*R_320[0]+-1*P_110212000*R_330[0]+P_110312000*R_340[0]; double PR_011010001210=P_011010001*R_210[0]+-1*P_011010101*R_211[0]+-1*P_011110001*R_220[0]+P_011110101*R_221[0]+-1*P_111010001*R_310[0]+P_111010101*R_311[0]+P_111110001*R_320[0]+-1*P_111110101*R_321[0]+P_211010001*R_410[0]+-1*P_211010101*R_411[0]+-1*P_211110001*R_420[0]+P_211110101*R_421[0]; double PR_010011001210=P_010011001*R_210[0]+-1*P_010011101*R_211[0]+-1*P_010111001*R_220[0]+P_010111101*R_221[0]+P_010211001*R_230[0]+-1*P_010211101*R_231[0]+-1*P_110011001*R_310[0]+P_110011101*R_311[0]+P_110111001*R_320[0]+-1*P_110111101*R_321[0]+-1*P_110211001*R_330[0]+P_110211101*R_331[0]; double PR_010010002210=P_010010002*R_210[0]+-1*P_010010102*R_211[0]+P_010010202*R_212[0]+-1*P_010110002*R_220[0]+P_010110102*R_221[0]+-1*P_010110202*R_222[0]+-1*P_110010002*R_310[0]+P_110010102*R_311[0]+-1*P_110010202*R_312[0]+P_110110002*R_320[0]+-1*P_110110102*R_321[0]+P_110110202*R_322[0]; double PR_002020000210=P_002020000*R_210[0]+-1*P_002120000*R_220[0]+P_002220000*R_230[0]+-1*P_102020000*R_310[0]+P_102120000*R_320[0]+-1*P_102220000*R_330[0]+P_202020000*R_410[0]+-1*P_202120000*R_420[0]+P_202220000*R_430[0]; double PR_001021000210=P_001021000*R_210[0]+-1*P_001121000*R_220[0]+P_001221000*R_230[0]+-1*P_001321000*R_240[0]+-1*P_101021000*R_310[0]+P_101121000*R_320[0]+-1*P_101221000*R_330[0]+P_101321000*R_340[0]; double PR_000022000210=P_000022000*R_210[0]+-1*P_000122000*R_220[0]+P_000222000*R_230[0]+-1*P_000322000*R_240[0]+P_000422000*R_250[0]; double PR_001020001210=P_001020001*R_210[0]+-1*P_001020101*R_211[0]+-1*P_001120001*R_220[0]+P_001120101*R_221[0]+P_001220001*R_230[0]+-1*P_001220101*R_231[0]+-1*P_101020001*R_310[0]+P_101020101*R_311[0]+P_101120001*R_320[0]+-1*P_101120101*R_321[0]+-1*P_101220001*R_330[0]+P_101220101*R_331[0]; double PR_000021001210=P_000021001*R_210[0]+-1*P_000021101*R_211[0]+-1*P_000121001*R_220[0]+P_000121101*R_221[0]+P_000221001*R_230[0]+-1*P_000221101*R_231[0]+-1*P_000321001*R_240[0]+P_000321101*R_241[0]; double PR_000020002210=P_000020002*R_210[0]+-1*P_000020102*R_211[0]+P_000020202*R_212[0]+-1*P_000120002*R_220[0]+P_000120102*R_221[0]+-1*P_000120202*R_222[0]+P_000220002*R_230[0]+-1*P_000220102*R_231[0]+P_000220202*R_232[0]; double PR_012000010210=P_012000010*R_210[0]+-1*P_012000110*R_211[0]+-1*P_112000010*R_310[0]+P_112000110*R_311[0]+P_212000010*R_410[0]+-1*P_212000110*R_411[0]+-1*P_312000010*R_510[0]+P_312000110*R_511[0]; double PR_011001010210=P_011001010*R_210[0]+-1*P_011001110*R_211[0]+-1*P_011101010*R_220[0]+P_011101110*R_221[0]+-1*P_111001010*R_310[0]+P_111001110*R_311[0]+P_111101010*R_320[0]+-1*P_111101110*R_321[0]+P_211001010*R_410[0]+-1*P_211001110*R_411[0]+-1*P_211101010*R_420[0]+P_211101110*R_421[0]; double PR_010002010210=P_010002010*R_210[0]+-1*P_010002110*R_211[0]+-1*P_010102010*R_220[0]+P_010102110*R_221[0]+P_010202010*R_230[0]+-1*P_010202110*R_231[0]+-1*P_110002010*R_310[0]+P_110002110*R_311[0]+P_110102010*R_320[0]+-1*P_110102110*R_321[0]+-1*P_110202010*R_330[0]+P_110202110*R_331[0]; double PR_011000011210=P_011000011*R_210[0]+-1*P_011000111*R_211[0]+P_011000211*R_212[0]+-1*P_111000011*R_310[0]+P_111000111*R_311[0]+-1*P_111000211*R_312[0]+P_211000011*R_410[0]+-1*P_211000111*R_411[0]+P_211000211*R_412[0]; double PR_010001011210=P_010001011*R_210[0]+-1*P_010001111*R_211[0]+P_010001211*R_212[0]+-1*P_010101011*R_220[0]+P_010101111*R_221[0]+-1*P_010101211*R_222[0]+-1*P_110001011*R_310[0]+P_110001111*R_311[0]+-1*P_110001211*R_312[0]+P_110101011*R_320[0]+-1*P_110101111*R_321[0]+P_110101211*R_322[0]; double PR_010000012210=P_010000012*R_210[0]+-1*P_010000112*R_211[0]+P_010000212*R_212[0]+-1*P_010000312*R_213[0]+-1*P_110000012*R_310[0]+P_110000112*R_311[0]+-1*P_110000212*R_312[0]+P_110000312*R_313[0]; double PR_002010010210=P_002010010*R_210[0]+-1*P_002010110*R_211[0]+-1*P_002110010*R_220[0]+P_002110110*R_221[0]+-1*P_102010010*R_310[0]+P_102010110*R_311[0]+P_102110010*R_320[0]+-1*P_102110110*R_321[0]+P_202010010*R_410[0]+-1*P_202010110*R_411[0]+-1*P_202110010*R_420[0]+P_202110110*R_421[0]; double PR_001011010210=P_001011010*R_210[0]+-1*P_001011110*R_211[0]+-1*P_001111010*R_220[0]+P_001111110*R_221[0]+P_001211010*R_230[0]+-1*P_001211110*R_231[0]+-1*P_101011010*R_310[0]+P_101011110*R_311[0]+P_101111010*R_320[0]+-1*P_101111110*R_321[0]+-1*P_101211010*R_330[0]+P_101211110*R_331[0]; double PR_000012010210=P_000012010*R_210[0]+-1*P_000012110*R_211[0]+-1*P_000112010*R_220[0]+P_000112110*R_221[0]+P_000212010*R_230[0]+-1*P_000212110*R_231[0]+-1*P_000312010*R_240[0]+P_000312110*R_241[0]; double PR_001010011210=P_001010011*R_210[0]+-1*P_001010111*R_211[0]+P_001010211*R_212[0]+-1*P_001110011*R_220[0]+P_001110111*R_221[0]+-1*P_001110211*R_222[0]+-1*P_101010011*R_310[0]+P_101010111*R_311[0]+-1*P_101010211*R_312[0]+P_101110011*R_320[0]+-1*P_101110111*R_321[0]+P_101110211*R_322[0]; double PR_000011011210=P_000011011*R_210[0]+-1*P_000011111*R_211[0]+P_000011211*R_212[0]+-1*P_000111011*R_220[0]+P_000111111*R_221[0]+-1*P_000111211*R_222[0]+P_000211011*R_230[0]+-1*P_000211111*R_231[0]+P_000211211*R_232[0]; double PR_000010012210=P_000010012*R_210[0]+-1*P_000010112*R_211[0]+P_000010212*R_212[0]+-1*P_000010312*R_213[0]+-1*P_000110012*R_220[0]+P_000110112*R_221[0]+-1*P_000110212*R_222[0]+P_000110312*R_223[0]; double PR_002000020210=P_002000020*R_210[0]+-1*P_002000120*R_211[0]+P_002000220*R_212[0]+-1*P_102000020*R_310[0]+P_102000120*R_311[0]+-1*P_102000220*R_312[0]+P_202000020*R_410[0]+-1*P_202000120*R_411[0]+P_202000220*R_412[0]; double PR_001001020210=P_001001020*R_210[0]+-1*P_001001120*R_211[0]+P_001001220*R_212[0]+-1*P_001101020*R_220[0]+P_001101120*R_221[0]+-1*P_001101220*R_222[0]+-1*P_101001020*R_310[0]+P_101001120*R_311[0]+-1*P_101001220*R_312[0]+P_101101020*R_320[0]+-1*P_101101120*R_321[0]+P_101101220*R_322[0]; double PR_000002020210=P_000002020*R_210[0]+-1*P_000002120*R_211[0]+P_000002220*R_212[0]+-1*P_000102020*R_220[0]+P_000102120*R_221[0]+-1*P_000102220*R_222[0]+P_000202020*R_230[0]+-1*P_000202120*R_231[0]+P_000202220*R_232[0]; double PR_001000021210=P_001000021*R_210[0]+-1*P_001000121*R_211[0]+P_001000221*R_212[0]+-1*P_001000321*R_213[0]+-1*P_101000021*R_310[0]+P_101000121*R_311[0]+-1*P_101000221*R_312[0]+P_101000321*R_313[0]; double PR_000001021210=P_000001021*R_210[0]+-1*P_000001121*R_211[0]+P_000001221*R_212[0]+-1*P_000001321*R_213[0]+-1*P_000101021*R_220[0]+P_000101121*R_221[0]+-1*P_000101221*R_222[0]+P_000101321*R_223[0]; double PR_000000022210=P_000000022*R_210[0]+-1*P_000000122*R_211[0]+P_000000222*R_212[0]+-1*P_000000322*R_213[0]+P_000000422*R_214[0]; double PR_022000000300=P_022000000*R_300[0]+-1*P_122000000*R_400[0]+P_222000000*R_500[0]+-1*P_322000000*R_600[0]+P_422000000*R_700[0]; double PR_021001000300=P_021001000*R_300[0]+-1*P_021101000*R_310[0]+-1*P_121001000*R_400[0]+P_121101000*R_410[0]+P_221001000*R_500[0]+-1*P_221101000*R_510[0]+-1*P_321001000*R_600[0]+P_321101000*R_610[0]; double PR_020002000300=P_020002000*R_300[0]+-1*P_020102000*R_310[0]+P_020202000*R_320[0]+-1*P_120002000*R_400[0]+P_120102000*R_410[0]+-1*P_120202000*R_420[0]+P_220002000*R_500[0]+-1*P_220102000*R_510[0]+P_220202000*R_520[0]; double PR_021000001300=P_021000001*R_300[0]+-1*P_021000101*R_301[0]+-1*P_121000001*R_400[0]+P_121000101*R_401[0]+P_221000001*R_500[0]+-1*P_221000101*R_501[0]+-1*P_321000001*R_600[0]+P_321000101*R_601[0]; double PR_020001001300=P_020001001*R_300[0]+-1*P_020001101*R_301[0]+-1*P_020101001*R_310[0]+P_020101101*R_311[0]+-1*P_120001001*R_400[0]+P_120001101*R_401[0]+P_120101001*R_410[0]+-1*P_120101101*R_411[0]+P_220001001*R_500[0]+-1*P_220001101*R_501[0]+-1*P_220101001*R_510[0]+P_220101101*R_511[0]; double PR_020000002300=P_020000002*R_300[0]+-1*P_020000102*R_301[0]+P_020000202*R_302[0]+-1*P_120000002*R_400[0]+P_120000102*R_401[0]+-1*P_120000202*R_402[0]+P_220000002*R_500[0]+-1*P_220000102*R_501[0]+P_220000202*R_502[0]; double PR_012010000300=P_012010000*R_300[0]+-1*P_012110000*R_310[0]+-1*P_112010000*R_400[0]+P_112110000*R_410[0]+P_212010000*R_500[0]+-1*P_212110000*R_510[0]+-1*P_312010000*R_600[0]+P_312110000*R_610[0]; double PR_011011000300=P_011011000*R_300[0]+-1*P_011111000*R_310[0]+P_011211000*R_320[0]+-1*P_111011000*R_400[0]+P_111111000*R_410[0]+-1*P_111211000*R_420[0]+P_211011000*R_500[0]+-1*P_211111000*R_510[0]+P_211211000*R_520[0]; double PR_010012000300=P_010012000*R_300[0]+-1*P_010112000*R_310[0]+P_010212000*R_320[0]+-1*P_010312000*R_330[0]+-1*P_110012000*R_400[0]+P_110112000*R_410[0]+-1*P_110212000*R_420[0]+P_110312000*R_430[0]; double PR_011010001300=P_011010001*R_300[0]+-1*P_011010101*R_301[0]+-1*P_011110001*R_310[0]+P_011110101*R_311[0]+-1*P_111010001*R_400[0]+P_111010101*R_401[0]+P_111110001*R_410[0]+-1*P_111110101*R_411[0]+P_211010001*R_500[0]+-1*P_211010101*R_501[0]+-1*P_211110001*R_510[0]+P_211110101*R_511[0]; double PR_010011001300=P_010011001*R_300[0]+-1*P_010011101*R_301[0]+-1*P_010111001*R_310[0]+P_010111101*R_311[0]+P_010211001*R_320[0]+-1*P_010211101*R_321[0]+-1*P_110011001*R_400[0]+P_110011101*R_401[0]+P_110111001*R_410[0]+-1*P_110111101*R_411[0]+-1*P_110211001*R_420[0]+P_110211101*R_421[0]; double PR_010010002300=P_010010002*R_300[0]+-1*P_010010102*R_301[0]+P_010010202*R_302[0]+-1*P_010110002*R_310[0]+P_010110102*R_311[0]+-1*P_010110202*R_312[0]+-1*P_110010002*R_400[0]+P_110010102*R_401[0]+-1*P_110010202*R_402[0]+P_110110002*R_410[0]+-1*P_110110102*R_411[0]+P_110110202*R_412[0]; double PR_002020000300=P_002020000*R_300[0]+-1*P_002120000*R_310[0]+P_002220000*R_320[0]+-1*P_102020000*R_400[0]+P_102120000*R_410[0]+-1*P_102220000*R_420[0]+P_202020000*R_500[0]+-1*P_202120000*R_510[0]+P_202220000*R_520[0]; double PR_001021000300=P_001021000*R_300[0]+-1*P_001121000*R_310[0]+P_001221000*R_320[0]+-1*P_001321000*R_330[0]+-1*P_101021000*R_400[0]+P_101121000*R_410[0]+-1*P_101221000*R_420[0]+P_101321000*R_430[0]; double PR_000022000300=P_000022000*R_300[0]+-1*P_000122000*R_310[0]+P_000222000*R_320[0]+-1*P_000322000*R_330[0]+P_000422000*R_340[0]; double PR_001020001300=P_001020001*R_300[0]+-1*P_001020101*R_301[0]+-1*P_001120001*R_310[0]+P_001120101*R_311[0]+P_001220001*R_320[0]+-1*P_001220101*R_321[0]+-1*P_101020001*R_400[0]+P_101020101*R_401[0]+P_101120001*R_410[0]+-1*P_101120101*R_411[0]+-1*P_101220001*R_420[0]+P_101220101*R_421[0]; double PR_000021001300=P_000021001*R_300[0]+-1*P_000021101*R_301[0]+-1*P_000121001*R_310[0]+P_000121101*R_311[0]+P_000221001*R_320[0]+-1*P_000221101*R_321[0]+-1*P_000321001*R_330[0]+P_000321101*R_331[0]; double PR_000020002300=P_000020002*R_300[0]+-1*P_000020102*R_301[0]+P_000020202*R_302[0]+-1*P_000120002*R_310[0]+P_000120102*R_311[0]+-1*P_000120202*R_312[0]+P_000220002*R_320[0]+-1*P_000220102*R_321[0]+P_000220202*R_322[0]; double PR_012000010300=P_012000010*R_300[0]+-1*P_012000110*R_301[0]+-1*P_112000010*R_400[0]+P_112000110*R_401[0]+P_212000010*R_500[0]+-1*P_212000110*R_501[0]+-1*P_312000010*R_600[0]+P_312000110*R_601[0]; double PR_011001010300=P_011001010*R_300[0]+-1*P_011001110*R_301[0]+-1*P_011101010*R_310[0]+P_011101110*R_311[0]+-1*P_111001010*R_400[0]+P_111001110*R_401[0]+P_111101010*R_410[0]+-1*P_111101110*R_411[0]+P_211001010*R_500[0]+-1*P_211001110*R_501[0]+-1*P_211101010*R_510[0]+P_211101110*R_511[0]; double PR_010002010300=P_010002010*R_300[0]+-1*P_010002110*R_301[0]+-1*P_010102010*R_310[0]+P_010102110*R_311[0]+P_010202010*R_320[0]+-1*P_010202110*R_321[0]+-1*P_110002010*R_400[0]+P_110002110*R_401[0]+P_110102010*R_410[0]+-1*P_110102110*R_411[0]+-1*P_110202010*R_420[0]+P_110202110*R_421[0]; double PR_011000011300=P_011000011*R_300[0]+-1*P_011000111*R_301[0]+P_011000211*R_302[0]+-1*P_111000011*R_400[0]+P_111000111*R_401[0]+-1*P_111000211*R_402[0]+P_211000011*R_500[0]+-1*P_211000111*R_501[0]+P_211000211*R_502[0]; double PR_010001011300=P_010001011*R_300[0]+-1*P_010001111*R_301[0]+P_010001211*R_302[0]+-1*P_010101011*R_310[0]+P_010101111*R_311[0]+-1*P_010101211*R_312[0]+-1*P_110001011*R_400[0]+P_110001111*R_401[0]+-1*P_110001211*R_402[0]+P_110101011*R_410[0]+-1*P_110101111*R_411[0]+P_110101211*R_412[0]; double PR_010000012300=P_010000012*R_300[0]+-1*P_010000112*R_301[0]+P_010000212*R_302[0]+-1*P_010000312*R_303[0]+-1*P_110000012*R_400[0]+P_110000112*R_401[0]+-1*P_110000212*R_402[0]+P_110000312*R_403[0]; double PR_002010010300=P_002010010*R_300[0]+-1*P_002010110*R_301[0]+-1*P_002110010*R_310[0]+P_002110110*R_311[0]+-1*P_102010010*R_400[0]+P_102010110*R_401[0]+P_102110010*R_410[0]+-1*P_102110110*R_411[0]+P_202010010*R_500[0]+-1*P_202010110*R_501[0]+-1*P_202110010*R_510[0]+P_202110110*R_511[0]; double PR_001011010300=P_001011010*R_300[0]+-1*P_001011110*R_301[0]+-1*P_001111010*R_310[0]+P_001111110*R_311[0]+P_001211010*R_320[0]+-1*P_001211110*R_321[0]+-1*P_101011010*R_400[0]+P_101011110*R_401[0]+P_101111010*R_410[0]+-1*P_101111110*R_411[0]+-1*P_101211010*R_420[0]+P_101211110*R_421[0]; double PR_000012010300=P_000012010*R_300[0]+-1*P_000012110*R_301[0]+-1*P_000112010*R_310[0]+P_000112110*R_311[0]+P_000212010*R_320[0]+-1*P_000212110*R_321[0]+-1*P_000312010*R_330[0]+P_000312110*R_331[0]; double PR_001010011300=P_001010011*R_300[0]+-1*P_001010111*R_301[0]+P_001010211*R_302[0]+-1*P_001110011*R_310[0]+P_001110111*R_311[0]+-1*P_001110211*R_312[0]+-1*P_101010011*R_400[0]+P_101010111*R_401[0]+-1*P_101010211*R_402[0]+P_101110011*R_410[0]+-1*P_101110111*R_411[0]+P_101110211*R_412[0]; double PR_000011011300=P_000011011*R_300[0]+-1*P_000011111*R_301[0]+P_000011211*R_302[0]+-1*P_000111011*R_310[0]+P_000111111*R_311[0]+-1*P_000111211*R_312[0]+P_000211011*R_320[0]+-1*P_000211111*R_321[0]+P_000211211*R_322[0]; double PR_000010012300=P_000010012*R_300[0]+-1*P_000010112*R_301[0]+P_000010212*R_302[0]+-1*P_000010312*R_303[0]+-1*P_000110012*R_310[0]+P_000110112*R_311[0]+-1*P_000110212*R_312[0]+P_000110312*R_313[0]; double PR_002000020300=P_002000020*R_300[0]+-1*P_002000120*R_301[0]+P_002000220*R_302[0]+-1*P_102000020*R_400[0]+P_102000120*R_401[0]+-1*P_102000220*R_402[0]+P_202000020*R_500[0]+-1*P_202000120*R_501[0]+P_202000220*R_502[0]; double PR_001001020300=P_001001020*R_300[0]+-1*P_001001120*R_301[0]+P_001001220*R_302[0]+-1*P_001101020*R_310[0]+P_001101120*R_311[0]+-1*P_001101220*R_312[0]+-1*P_101001020*R_400[0]+P_101001120*R_401[0]+-1*P_101001220*R_402[0]+P_101101020*R_410[0]+-1*P_101101120*R_411[0]+P_101101220*R_412[0]; double PR_000002020300=P_000002020*R_300[0]+-1*P_000002120*R_301[0]+P_000002220*R_302[0]+-1*P_000102020*R_310[0]+P_000102120*R_311[0]+-1*P_000102220*R_312[0]+P_000202020*R_320[0]+-1*P_000202120*R_321[0]+P_000202220*R_322[0]; double PR_001000021300=P_001000021*R_300[0]+-1*P_001000121*R_301[0]+P_001000221*R_302[0]+-1*P_001000321*R_303[0]+-1*P_101000021*R_400[0]+P_101000121*R_401[0]+-1*P_101000221*R_402[0]+P_101000321*R_403[0]; double PR_000001021300=P_000001021*R_300[0]+-1*P_000001121*R_301[0]+P_000001221*R_302[0]+-1*P_000001321*R_303[0]+-1*P_000101021*R_310[0]+P_000101121*R_311[0]+-1*P_000101221*R_312[0]+P_000101321*R_313[0]; double PR_000000022300=P_000000022*R_300[0]+-1*P_000000122*R_301[0]+P_000000222*R_302[0]+-1*P_000000322*R_303[0]+P_000000422*R_304[0]; double PR_022000000004=P_022000000*R_004[0]+-1*P_122000000*R_104[0]+P_222000000*R_204[0]+-1*P_322000000*R_304[0]+P_422000000*R_404[0]; double PR_021001000004=P_021001000*R_004[0]+-1*P_021101000*R_014[0]+-1*P_121001000*R_104[0]+P_121101000*R_114[0]+P_221001000*R_204[0]+-1*P_221101000*R_214[0]+-1*P_321001000*R_304[0]+P_321101000*R_314[0]; double PR_020002000004=P_020002000*R_004[0]+-1*P_020102000*R_014[0]+P_020202000*R_024[0]+-1*P_120002000*R_104[0]+P_120102000*R_114[0]+-1*P_120202000*R_124[0]+P_220002000*R_204[0]+-1*P_220102000*R_214[0]+P_220202000*R_224[0]; double PR_021000001004=P_021000001*R_004[0]+-1*P_021000101*R_005[0]+-1*P_121000001*R_104[0]+P_121000101*R_105[0]+P_221000001*R_204[0]+-1*P_221000101*R_205[0]+-1*P_321000001*R_304[0]+P_321000101*R_305[0]; double PR_020001001004=P_020001001*R_004[0]+-1*P_020001101*R_005[0]+-1*P_020101001*R_014[0]+P_020101101*R_015[0]+-1*P_120001001*R_104[0]+P_120001101*R_105[0]+P_120101001*R_114[0]+-1*P_120101101*R_115[0]+P_220001001*R_204[0]+-1*P_220001101*R_205[0]+-1*P_220101001*R_214[0]+P_220101101*R_215[0]; double PR_020000002004=P_020000002*R_004[0]+-1*P_020000102*R_005[0]+P_020000202*R_006[0]+-1*P_120000002*R_104[0]+P_120000102*R_105[0]+-1*P_120000202*R_106[0]+P_220000002*R_204[0]+-1*P_220000102*R_205[0]+P_220000202*R_206[0]; double PR_012010000004=P_012010000*R_004[0]+-1*P_012110000*R_014[0]+-1*P_112010000*R_104[0]+P_112110000*R_114[0]+P_212010000*R_204[0]+-1*P_212110000*R_214[0]+-1*P_312010000*R_304[0]+P_312110000*R_314[0]; double PR_011011000004=P_011011000*R_004[0]+-1*P_011111000*R_014[0]+P_011211000*R_024[0]+-1*P_111011000*R_104[0]+P_111111000*R_114[0]+-1*P_111211000*R_124[0]+P_211011000*R_204[0]+-1*P_211111000*R_214[0]+P_211211000*R_224[0]; double PR_010012000004=P_010012000*R_004[0]+-1*P_010112000*R_014[0]+P_010212000*R_024[0]+-1*P_010312000*R_034[0]+-1*P_110012000*R_104[0]+P_110112000*R_114[0]+-1*P_110212000*R_124[0]+P_110312000*R_134[0]; double PR_011010001004=P_011010001*R_004[0]+-1*P_011010101*R_005[0]+-1*P_011110001*R_014[0]+P_011110101*R_015[0]+-1*P_111010001*R_104[0]+P_111010101*R_105[0]+P_111110001*R_114[0]+-1*P_111110101*R_115[0]+P_211010001*R_204[0]+-1*P_211010101*R_205[0]+-1*P_211110001*R_214[0]+P_211110101*R_215[0]; double PR_010011001004=P_010011001*R_004[0]+-1*P_010011101*R_005[0]+-1*P_010111001*R_014[0]+P_010111101*R_015[0]+P_010211001*R_024[0]+-1*P_010211101*R_025[0]+-1*P_110011001*R_104[0]+P_110011101*R_105[0]+P_110111001*R_114[0]+-1*P_110111101*R_115[0]+-1*P_110211001*R_124[0]+P_110211101*R_125[0]; double PR_010010002004=P_010010002*R_004[0]+-1*P_010010102*R_005[0]+P_010010202*R_006[0]+-1*P_010110002*R_014[0]+P_010110102*R_015[0]+-1*P_010110202*R_016[0]+-1*P_110010002*R_104[0]+P_110010102*R_105[0]+-1*P_110010202*R_106[0]+P_110110002*R_114[0]+-1*P_110110102*R_115[0]+P_110110202*R_116[0]; double PR_002020000004=P_002020000*R_004[0]+-1*P_002120000*R_014[0]+P_002220000*R_024[0]+-1*P_102020000*R_104[0]+P_102120000*R_114[0]+-1*P_102220000*R_124[0]+P_202020000*R_204[0]+-1*P_202120000*R_214[0]+P_202220000*R_224[0]; double PR_001021000004=P_001021000*R_004[0]+-1*P_001121000*R_014[0]+P_001221000*R_024[0]+-1*P_001321000*R_034[0]+-1*P_101021000*R_104[0]+P_101121000*R_114[0]+-1*P_101221000*R_124[0]+P_101321000*R_134[0]; double PR_000022000004=P_000022000*R_004[0]+-1*P_000122000*R_014[0]+P_000222000*R_024[0]+-1*P_000322000*R_034[0]+P_000422000*R_044[0]; double PR_001020001004=P_001020001*R_004[0]+-1*P_001020101*R_005[0]+-1*P_001120001*R_014[0]+P_001120101*R_015[0]+P_001220001*R_024[0]+-1*P_001220101*R_025[0]+-1*P_101020001*R_104[0]+P_101020101*R_105[0]+P_101120001*R_114[0]+-1*P_101120101*R_115[0]+-1*P_101220001*R_124[0]+P_101220101*R_125[0]; double PR_000021001004=P_000021001*R_004[0]+-1*P_000021101*R_005[0]+-1*P_000121001*R_014[0]+P_000121101*R_015[0]+P_000221001*R_024[0]+-1*P_000221101*R_025[0]+-1*P_000321001*R_034[0]+P_000321101*R_035[0]; double PR_000020002004=P_000020002*R_004[0]+-1*P_000020102*R_005[0]+P_000020202*R_006[0]+-1*P_000120002*R_014[0]+P_000120102*R_015[0]+-1*P_000120202*R_016[0]+P_000220002*R_024[0]+-1*P_000220102*R_025[0]+P_000220202*R_026[0]; double PR_012000010004=P_012000010*R_004[0]+-1*P_012000110*R_005[0]+-1*P_112000010*R_104[0]+P_112000110*R_105[0]+P_212000010*R_204[0]+-1*P_212000110*R_205[0]+-1*P_312000010*R_304[0]+P_312000110*R_305[0]; double PR_011001010004=P_011001010*R_004[0]+-1*P_011001110*R_005[0]+-1*P_011101010*R_014[0]+P_011101110*R_015[0]+-1*P_111001010*R_104[0]+P_111001110*R_105[0]+P_111101010*R_114[0]+-1*P_111101110*R_115[0]+P_211001010*R_204[0]+-1*P_211001110*R_205[0]+-1*P_211101010*R_214[0]+P_211101110*R_215[0]; double PR_010002010004=P_010002010*R_004[0]+-1*P_010002110*R_005[0]+-1*P_010102010*R_014[0]+P_010102110*R_015[0]+P_010202010*R_024[0]+-1*P_010202110*R_025[0]+-1*P_110002010*R_104[0]+P_110002110*R_105[0]+P_110102010*R_114[0]+-1*P_110102110*R_115[0]+-1*P_110202010*R_124[0]+P_110202110*R_125[0]; double PR_011000011004=P_011000011*R_004[0]+-1*P_011000111*R_005[0]+P_011000211*R_006[0]+-1*P_111000011*R_104[0]+P_111000111*R_105[0]+-1*P_111000211*R_106[0]+P_211000011*R_204[0]+-1*P_211000111*R_205[0]+P_211000211*R_206[0]; double PR_010001011004=P_010001011*R_004[0]+-1*P_010001111*R_005[0]+P_010001211*R_006[0]+-1*P_010101011*R_014[0]+P_010101111*R_015[0]+-1*P_010101211*R_016[0]+-1*P_110001011*R_104[0]+P_110001111*R_105[0]+-1*P_110001211*R_106[0]+P_110101011*R_114[0]+-1*P_110101111*R_115[0]+P_110101211*R_116[0]; double PR_010000012004=P_010000012*R_004[0]+-1*P_010000112*R_005[0]+P_010000212*R_006[0]+-1*P_010000312*R_007[0]+-1*P_110000012*R_104[0]+P_110000112*R_105[0]+-1*P_110000212*R_106[0]+P_110000312*R_107[0]; double PR_002010010004=P_002010010*R_004[0]+-1*P_002010110*R_005[0]+-1*P_002110010*R_014[0]+P_002110110*R_015[0]+-1*P_102010010*R_104[0]+P_102010110*R_105[0]+P_102110010*R_114[0]+-1*P_102110110*R_115[0]+P_202010010*R_204[0]+-1*P_202010110*R_205[0]+-1*P_202110010*R_214[0]+P_202110110*R_215[0]; double PR_001011010004=P_001011010*R_004[0]+-1*P_001011110*R_005[0]+-1*P_001111010*R_014[0]+P_001111110*R_015[0]+P_001211010*R_024[0]+-1*P_001211110*R_025[0]+-1*P_101011010*R_104[0]+P_101011110*R_105[0]+P_101111010*R_114[0]+-1*P_101111110*R_115[0]+-1*P_101211010*R_124[0]+P_101211110*R_125[0]; double PR_000012010004=P_000012010*R_004[0]+-1*P_000012110*R_005[0]+-1*P_000112010*R_014[0]+P_000112110*R_015[0]+P_000212010*R_024[0]+-1*P_000212110*R_025[0]+-1*P_000312010*R_034[0]+P_000312110*R_035[0]; double PR_001010011004=P_001010011*R_004[0]+-1*P_001010111*R_005[0]+P_001010211*R_006[0]+-1*P_001110011*R_014[0]+P_001110111*R_015[0]+-1*P_001110211*R_016[0]+-1*P_101010011*R_104[0]+P_101010111*R_105[0]+-1*P_101010211*R_106[0]+P_101110011*R_114[0]+-1*P_101110111*R_115[0]+P_101110211*R_116[0]; double PR_000011011004=P_000011011*R_004[0]+-1*P_000011111*R_005[0]+P_000011211*R_006[0]+-1*P_000111011*R_014[0]+P_000111111*R_015[0]+-1*P_000111211*R_016[0]+P_000211011*R_024[0]+-1*P_000211111*R_025[0]+P_000211211*R_026[0]; double PR_000010012004=P_000010012*R_004[0]+-1*P_000010112*R_005[0]+P_000010212*R_006[0]+-1*P_000010312*R_007[0]+-1*P_000110012*R_014[0]+P_000110112*R_015[0]+-1*P_000110212*R_016[0]+P_000110312*R_017[0]; double PR_002000020004=P_002000020*R_004[0]+-1*P_002000120*R_005[0]+P_002000220*R_006[0]+-1*P_102000020*R_104[0]+P_102000120*R_105[0]+-1*P_102000220*R_106[0]+P_202000020*R_204[0]+-1*P_202000120*R_205[0]+P_202000220*R_206[0]; double PR_001001020004=P_001001020*R_004[0]+-1*P_001001120*R_005[0]+P_001001220*R_006[0]+-1*P_001101020*R_014[0]+P_001101120*R_015[0]+-1*P_001101220*R_016[0]+-1*P_101001020*R_104[0]+P_101001120*R_105[0]+-1*P_101001220*R_106[0]+P_101101020*R_114[0]+-1*P_101101120*R_115[0]+P_101101220*R_116[0]; double PR_000002020004=P_000002020*R_004[0]+-1*P_000002120*R_005[0]+P_000002220*R_006[0]+-1*P_000102020*R_014[0]+P_000102120*R_015[0]+-1*P_000102220*R_016[0]+P_000202020*R_024[0]+-1*P_000202120*R_025[0]+P_000202220*R_026[0]; double PR_001000021004=P_001000021*R_004[0]+-1*P_001000121*R_005[0]+P_001000221*R_006[0]+-1*P_001000321*R_007[0]+-1*P_101000021*R_104[0]+P_101000121*R_105[0]+-1*P_101000221*R_106[0]+P_101000321*R_107[0]; double PR_000001021004=P_000001021*R_004[0]+-1*P_000001121*R_005[0]+P_000001221*R_006[0]+-1*P_000001321*R_007[0]+-1*P_000101021*R_014[0]+P_000101121*R_015[0]+-1*P_000101221*R_016[0]+P_000101321*R_017[0]; double PR_000000022004=P_000000022*R_004[0]+-1*P_000000122*R_005[0]+P_000000222*R_006[0]+-1*P_000000322*R_007[0]+P_000000422*R_008[0]; double PR_022000000013=P_022000000*R_013[0]+-1*P_122000000*R_113[0]+P_222000000*R_213[0]+-1*P_322000000*R_313[0]+P_422000000*R_413[0]; double PR_021001000013=P_021001000*R_013[0]+-1*P_021101000*R_023[0]+-1*P_121001000*R_113[0]+P_121101000*R_123[0]+P_221001000*R_213[0]+-1*P_221101000*R_223[0]+-1*P_321001000*R_313[0]+P_321101000*R_323[0]; double PR_020002000013=P_020002000*R_013[0]+-1*P_020102000*R_023[0]+P_020202000*R_033[0]+-1*P_120002000*R_113[0]+P_120102000*R_123[0]+-1*P_120202000*R_133[0]+P_220002000*R_213[0]+-1*P_220102000*R_223[0]+P_220202000*R_233[0]; double PR_021000001013=P_021000001*R_013[0]+-1*P_021000101*R_014[0]+-1*P_121000001*R_113[0]+P_121000101*R_114[0]+P_221000001*R_213[0]+-1*P_221000101*R_214[0]+-1*P_321000001*R_313[0]+P_321000101*R_314[0]; double PR_020001001013=P_020001001*R_013[0]+-1*P_020001101*R_014[0]+-1*P_020101001*R_023[0]+P_020101101*R_024[0]+-1*P_120001001*R_113[0]+P_120001101*R_114[0]+P_120101001*R_123[0]+-1*P_120101101*R_124[0]+P_220001001*R_213[0]+-1*P_220001101*R_214[0]+-1*P_220101001*R_223[0]+P_220101101*R_224[0]; double PR_020000002013=P_020000002*R_013[0]+-1*P_020000102*R_014[0]+P_020000202*R_015[0]+-1*P_120000002*R_113[0]+P_120000102*R_114[0]+-1*P_120000202*R_115[0]+P_220000002*R_213[0]+-1*P_220000102*R_214[0]+P_220000202*R_215[0]; double PR_012010000013=P_012010000*R_013[0]+-1*P_012110000*R_023[0]+-1*P_112010000*R_113[0]+P_112110000*R_123[0]+P_212010000*R_213[0]+-1*P_212110000*R_223[0]+-1*P_312010000*R_313[0]+P_312110000*R_323[0]; double PR_011011000013=P_011011000*R_013[0]+-1*P_011111000*R_023[0]+P_011211000*R_033[0]+-1*P_111011000*R_113[0]+P_111111000*R_123[0]+-1*P_111211000*R_133[0]+P_211011000*R_213[0]+-1*P_211111000*R_223[0]+P_211211000*R_233[0]; double PR_010012000013=P_010012000*R_013[0]+-1*P_010112000*R_023[0]+P_010212000*R_033[0]+-1*P_010312000*R_043[0]+-1*P_110012000*R_113[0]+P_110112000*R_123[0]+-1*P_110212000*R_133[0]+P_110312000*R_143[0]; double PR_011010001013=P_011010001*R_013[0]+-1*P_011010101*R_014[0]+-1*P_011110001*R_023[0]+P_011110101*R_024[0]+-1*P_111010001*R_113[0]+P_111010101*R_114[0]+P_111110001*R_123[0]+-1*P_111110101*R_124[0]+P_211010001*R_213[0]+-1*P_211010101*R_214[0]+-1*P_211110001*R_223[0]+P_211110101*R_224[0]; double PR_010011001013=P_010011001*R_013[0]+-1*P_010011101*R_014[0]+-1*P_010111001*R_023[0]+P_010111101*R_024[0]+P_010211001*R_033[0]+-1*P_010211101*R_034[0]+-1*P_110011001*R_113[0]+P_110011101*R_114[0]+P_110111001*R_123[0]+-1*P_110111101*R_124[0]+-1*P_110211001*R_133[0]+P_110211101*R_134[0]; double PR_010010002013=P_010010002*R_013[0]+-1*P_010010102*R_014[0]+P_010010202*R_015[0]+-1*P_010110002*R_023[0]+P_010110102*R_024[0]+-1*P_010110202*R_025[0]+-1*P_110010002*R_113[0]+P_110010102*R_114[0]+-1*P_110010202*R_115[0]+P_110110002*R_123[0]+-1*P_110110102*R_124[0]+P_110110202*R_125[0]; double PR_002020000013=P_002020000*R_013[0]+-1*P_002120000*R_023[0]+P_002220000*R_033[0]+-1*P_102020000*R_113[0]+P_102120000*R_123[0]+-1*P_102220000*R_133[0]+P_202020000*R_213[0]+-1*P_202120000*R_223[0]+P_202220000*R_233[0]; double PR_001021000013=P_001021000*R_013[0]+-1*P_001121000*R_023[0]+P_001221000*R_033[0]+-1*P_001321000*R_043[0]+-1*P_101021000*R_113[0]+P_101121000*R_123[0]+-1*P_101221000*R_133[0]+P_101321000*R_143[0]; double PR_000022000013=P_000022000*R_013[0]+-1*P_000122000*R_023[0]+P_000222000*R_033[0]+-1*P_000322000*R_043[0]+P_000422000*R_053[0]; double PR_001020001013=P_001020001*R_013[0]+-1*P_001020101*R_014[0]+-1*P_001120001*R_023[0]+P_001120101*R_024[0]+P_001220001*R_033[0]+-1*P_001220101*R_034[0]+-1*P_101020001*R_113[0]+P_101020101*R_114[0]+P_101120001*R_123[0]+-1*P_101120101*R_124[0]+-1*P_101220001*R_133[0]+P_101220101*R_134[0]; double PR_000021001013=P_000021001*R_013[0]+-1*P_000021101*R_014[0]+-1*P_000121001*R_023[0]+P_000121101*R_024[0]+P_000221001*R_033[0]+-1*P_000221101*R_034[0]+-1*P_000321001*R_043[0]+P_000321101*R_044[0]; double PR_000020002013=P_000020002*R_013[0]+-1*P_000020102*R_014[0]+P_000020202*R_015[0]+-1*P_000120002*R_023[0]+P_000120102*R_024[0]+-1*P_000120202*R_025[0]+P_000220002*R_033[0]+-1*P_000220102*R_034[0]+P_000220202*R_035[0]; double PR_012000010013=P_012000010*R_013[0]+-1*P_012000110*R_014[0]+-1*P_112000010*R_113[0]+P_112000110*R_114[0]+P_212000010*R_213[0]+-1*P_212000110*R_214[0]+-1*P_312000010*R_313[0]+P_312000110*R_314[0]; double PR_011001010013=P_011001010*R_013[0]+-1*P_011001110*R_014[0]+-1*P_011101010*R_023[0]+P_011101110*R_024[0]+-1*P_111001010*R_113[0]+P_111001110*R_114[0]+P_111101010*R_123[0]+-1*P_111101110*R_124[0]+P_211001010*R_213[0]+-1*P_211001110*R_214[0]+-1*P_211101010*R_223[0]+P_211101110*R_224[0]; double PR_010002010013=P_010002010*R_013[0]+-1*P_010002110*R_014[0]+-1*P_010102010*R_023[0]+P_010102110*R_024[0]+P_010202010*R_033[0]+-1*P_010202110*R_034[0]+-1*P_110002010*R_113[0]+P_110002110*R_114[0]+P_110102010*R_123[0]+-1*P_110102110*R_124[0]+-1*P_110202010*R_133[0]+P_110202110*R_134[0]; double PR_011000011013=P_011000011*R_013[0]+-1*P_011000111*R_014[0]+P_011000211*R_015[0]+-1*P_111000011*R_113[0]+P_111000111*R_114[0]+-1*P_111000211*R_115[0]+P_211000011*R_213[0]+-1*P_211000111*R_214[0]+P_211000211*R_215[0]; double PR_010001011013=P_010001011*R_013[0]+-1*P_010001111*R_014[0]+P_010001211*R_015[0]+-1*P_010101011*R_023[0]+P_010101111*R_024[0]+-1*P_010101211*R_025[0]+-1*P_110001011*R_113[0]+P_110001111*R_114[0]+-1*P_110001211*R_115[0]+P_110101011*R_123[0]+-1*P_110101111*R_124[0]+P_110101211*R_125[0]; double PR_010000012013=P_010000012*R_013[0]+-1*P_010000112*R_014[0]+P_010000212*R_015[0]+-1*P_010000312*R_016[0]+-1*P_110000012*R_113[0]+P_110000112*R_114[0]+-1*P_110000212*R_115[0]+P_110000312*R_116[0]; double PR_002010010013=P_002010010*R_013[0]+-1*P_002010110*R_014[0]+-1*P_002110010*R_023[0]+P_002110110*R_024[0]+-1*P_102010010*R_113[0]+P_102010110*R_114[0]+P_102110010*R_123[0]+-1*P_102110110*R_124[0]+P_202010010*R_213[0]+-1*P_202010110*R_214[0]+-1*P_202110010*R_223[0]+P_202110110*R_224[0]; double PR_001011010013=P_001011010*R_013[0]+-1*P_001011110*R_014[0]+-1*P_001111010*R_023[0]+P_001111110*R_024[0]+P_001211010*R_033[0]+-1*P_001211110*R_034[0]+-1*P_101011010*R_113[0]+P_101011110*R_114[0]+P_101111010*R_123[0]+-1*P_101111110*R_124[0]+-1*P_101211010*R_133[0]+P_101211110*R_134[0]; double PR_000012010013=P_000012010*R_013[0]+-1*P_000012110*R_014[0]+-1*P_000112010*R_023[0]+P_000112110*R_024[0]+P_000212010*R_033[0]+-1*P_000212110*R_034[0]+-1*P_000312010*R_043[0]+P_000312110*R_044[0]; double PR_001010011013=P_001010011*R_013[0]+-1*P_001010111*R_014[0]+P_001010211*R_015[0]+-1*P_001110011*R_023[0]+P_001110111*R_024[0]+-1*P_001110211*R_025[0]+-1*P_101010011*R_113[0]+P_101010111*R_114[0]+-1*P_101010211*R_115[0]+P_101110011*R_123[0]+-1*P_101110111*R_124[0]+P_101110211*R_125[0]; double PR_000011011013=P_000011011*R_013[0]+-1*P_000011111*R_014[0]+P_000011211*R_015[0]+-1*P_000111011*R_023[0]+P_000111111*R_024[0]+-1*P_000111211*R_025[0]+P_000211011*R_033[0]+-1*P_000211111*R_034[0]+P_000211211*R_035[0]; double PR_000010012013=P_000010012*R_013[0]+-1*P_000010112*R_014[0]+P_000010212*R_015[0]+-1*P_000010312*R_016[0]+-1*P_000110012*R_023[0]+P_000110112*R_024[0]+-1*P_000110212*R_025[0]+P_000110312*R_026[0]; double PR_002000020013=P_002000020*R_013[0]+-1*P_002000120*R_014[0]+P_002000220*R_015[0]+-1*P_102000020*R_113[0]+P_102000120*R_114[0]+-1*P_102000220*R_115[0]+P_202000020*R_213[0]+-1*P_202000120*R_214[0]+P_202000220*R_215[0]; double PR_001001020013=P_001001020*R_013[0]+-1*P_001001120*R_014[0]+P_001001220*R_015[0]+-1*P_001101020*R_023[0]+P_001101120*R_024[0]+-1*P_001101220*R_025[0]+-1*P_101001020*R_113[0]+P_101001120*R_114[0]+-1*P_101001220*R_115[0]+P_101101020*R_123[0]+-1*P_101101120*R_124[0]+P_101101220*R_125[0]; double PR_000002020013=P_000002020*R_013[0]+-1*P_000002120*R_014[0]+P_000002220*R_015[0]+-1*P_000102020*R_023[0]+P_000102120*R_024[0]+-1*P_000102220*R_025[0]+P_000202020*R_033[0]+-1*P_000202120*R_034[0]+P_000202220*R_035[0]; double PR_001000021013=P_001000021*R_013[0]+-1*P_001000121*R_014[0]+P_001000221*R_015[0]+-1*P_001000321*R_016[0]+-1*P_101000021*R_113[0]+P_101000121*R_114[0]+-1*P_101000221*R_115[0]+P_101000321*R_116[0]; double PR_000001021013=P_000001021*R_013[0]+-1*P_000001121*R_014[0]+P_000001221*R_015[0]+-1*P_000001321*R_016[0]+-1*P_000101021*R_023[0]+P_000101121*R_024[0]+-1*P_000101221*R_025[0]+P_000101321*R_026[0]; double PR_000000022013=P_000000022*R_013[0]+-1*P_000000122*R_014[0]+P_000000222*R_015[0]+-1*P_000000322*R_016[0]+P_000000422*R_017[0]; double PR_022000000022=P_022000000*R_022[0]+-1*P_122000000*R_122[0]+P_222000000*R_222[0]+-1*P_322000000*R_322[0]+P_422000000*R_422[0]; double PR_021001000022=P_021001000*R_022[0]+-1*P_021101000*R_032[0]+-1*P_121001000*R_122[0]+P_121101000*R_132[0]+P_221001000*R_222[0]+-1*P_221101000*R_232[0]+-1*P_321001000*R_322[0]+P_321101000*R_332[0]; double PR_020002000022=P_020002000*R_022[0]+-1*P_020102000*R_032[0]+P_020202000*R_042[0]+-1*P_120002000*R_122[0]+P_120102000*R_132[0]+-1*P_120202000*R_142[0]+P_220002000*R_222[0]+-1*P_220102000*R_232[0]+P_220202000*R_242[0]; double PR_021000001022=P_021000001*R_022[0]+-1*P_021000101*R_023[0]+-1*P_121000001*R_122[0]+P_121000101*R_123[0]+P_221000001*R_222[0]+-1*P_221000101*R_223[0]+-1*P_321000001*R_322[0]+P_321000101*R_323[0]; double PR_020001001022=P_020001001*R_022[0]+-1*P_020001101*R_023[0]+-1*P_020101001*R_032[0]+P_020101101*R_033[0]+-1*P_120001001*R_122[0]+P_120001101*R_123[0]+P_120101001*R_132[0]+-1*P_120101101*R_133[0]+P_220001001*R_222[0]+-1*P_220001101*R_223[0]+-1*P_220101001*R_232[0]+P_220101101*R_233[0]; double PR_020000002022=P_020000002*R_022[0]+-1*P_020000102*R_023[0]+P_020000202*R_024[0]+-1*P_120000002*R_122[0]+P_120000102*R_123[0]+-1*P_120000202*R_124[0]+P_220000002*R_222[0]+-1*P_220000102*R_223[0]+P_220000202*R_224[0]; double PR_012010000022=P_012010000*R_022[0]+-1*P_012110000*R_032[0]+-1*P_112010000*R_122[0]+P_112110000*R_132[0]+P_212010000*R_222[0]+-1*P_212110000*R_232[0]+-1*P_312010000*R_322[0]+P_312110000*R_332[0]; double PR_011011000022=P_011011000*R_022[0]+-1*P_011111000*R_032[0]+P_011211000*R_042[0]+-1*P_111011000*R_122[0]+P_111111000*R_132[0]+-1*P_111211000*R_142[0]+P_211011000*R_222[0]+-1*P_211111000*R_232[0]+P_211211000*R_242[0]; double PR_010012000022=P_010012000*R_022[0]+-1*P_010112000*R_032[0]+P_010212000*R_042[0]+-1*P_010312000*R_052[0]+-1*P_110012000*R_122[0]+P_110112000*R_132[0]+-1*P_110212000*R_142[0]+P_110312000*R_152[0]; double PR_011010001022=P_011010001*R_022[0]+-1*P_011010101*R_023[0]+-1*P_011110001*R_032[0]+P_011110101*R_033[0]+-1*P_111010001*R_122[0]+P_111010101*R_123[0]+P_111110001*R_132[0]+-1*P_111110101*R_133[0]+P_211010001*R_222[0]+-1*P_211010101*R_223[0]+-1*P_211110001*R_232[0]+P_211110101*R_233[0]; double PR_010011001022=P_010011001*R_022[0]+-1*P_010011101*R_023[0]+-1*P_010111001*R_032[0]+P_010111101*R_033[0]+P_010211001*R_042[0]+-1*P_010211101*R_043[0]+-1*P_110011001*R_122[0]+P_110011101*R_123[0]+P_110111001*R_132[0]+-1*P_110111101*R_133[0]+-1*P_110211001*R_142[0]+P_110211101*R_143[0]; double PR_010010002022=P_010010002*R_022[0]+-1*P_010010102*R_023[0]+P_010010202*R_024[0]+-1*P_010110002*R_032[0]+P_010110102*R_033[0]+-1*P_010110202*R_034[0]+-1*P_110010002*R_122[0]+P_110010102*R_123[0]+-1*P_110010202*R_124[0]+P_110110002*R_132[0]+-1*P_110110102*R_133[0]+P_110110202*R_134[0]; double PR_002020000022=P_002020000*R_022[0]+-1*P_002120000*R_032[0]+P_002220000*R_042[0]+-1*P_102020000*R_122[0]+P_102120000*R_132[0]+-1*P_102220000*R_142[0]+P_202020000*R_222[0]+-1*P_202120000*R_232[0]+P_202220000*R_242[0]; double PR_001021000022=P_001021000*R_022[0]+-1*P_001121000*R_032[0]+P_001221000*R_042[0]+-1*P_001321000*R_052[0]+-1*P_101021000*R_122[0]+P_101121000*R_132[0]+-1*P_101221000*R_142[0]+P_101321000*R_152[0]; double PR_000022000022=P_000022000*R_022[0]+-1*P_000122000*R_032[0]+P_000222000*R_042[0]+-1*P_000322000*R_052[0]+P_000422000*R_062[0]; double PR_001020001022=P_001020001*R_022[0]+-1*P_001020101*R_023[0]+-1*P_001120001*R_032[0]+P_001120101*R_033[0]+P_001220001*R_042[0]+-1*P_001220101*R_043[0]+-1*P_101020001*R_122[0]+P_101020101*R_123[0]+P_101120001*R_132[0]+-1*P_101120101*R_133[0]+-1*P_101220001*R_142[0]+P_101220101*R_143[0]; double PR_000021001022=P_000021001*R_022[0]+-1*P_000021101*R_023[0]+-1*P_000121001*R_032[0]+P_000121101*R_033[0]+P_000221001*R_042[0]+-1*P_000221101*R_043[0]+-1*P_000321001*R_052[0]+P_000321101*R_053[0]; double PR_000020002022=P_000020002*R_022[0]+-1*P_000020102*R_023[0]+P_000020202*R_024[0]+-1*P_000120002*R_032[0]+P_000120102*R_033[0]+-1*P_000120202*R_034[0]+P_000220002*R_042[0]+-1*P_000220102*R_043[0]+P_000220202*R_044[0]; double PR_012000010022=P_012000010*R_022[0]+-1*P_012000110*R_023[0]+-1*P_112000010*R_122[0]+P_112000110*R_123[0]+P_212000010*R_222[0]+-1*P_212000110*R_223[0]+-1*P_312000010*R_322[0]+P_312000110*R_323[0]; double PR_011001010022=P_011001010*R_022[0]+-1*P_011001110*R_023[0]+-1*P_011101010*R_032[0]+P_011101110*R_033[0]+-1*P_111001010*R_122[0]+P_111001110*R_123[0]+P_111101010*R_132[0]+-1*P_111101110*R_133[0]+P_211001010*R_222[0]+-1*P_211001110*R_223[0]+-1*P_211101010*R_232[0]+P_211101110*R_233[0]; double PR_010002010022=P_010002010*R_022[0]+-1*P_010002110*R_023[0]+-1*P_010102010*R_032[0]+P_010102110*R_033[0]+P_010202010*R_042[0]+-1*P_010202110*R_043[0]+-1*P_110002010*R_122[0]+P_110002110*R_123[0]+P_110102010*R_132[0]+-1*P_110102110*R_133[0]+-1*P_110202010*R_142[0]+P_110202110*R_143[0]; double PR_011000011022=P_011000011*R_022[0]+-1*P_011000111*R_023[0]+P_011000211*R_024[0]+-1*P_111000011*R_122[0]+P_111000111*R_123[0]+-1*P_111000211*R_124[0]+P_211000011*R_222[0]+-1*P_211000111*R_223[0]+P_211000211*R_224[0]; double PR_010001011022=P_010001011*R_022[0]+-1*P_010001111*R_023[0]+P_010001211*R_024[0]+-1*P_010101011*R_032[0]+P_010101111*R_033[0]+-1*P_010101211*R_034[0]+-1*P_110001011*R_122[0]+P_110001111*R_123[0]+-1*P_110001211*R_124[0]+P_110101011*R_132[0]+-1*P_110101111*R_133[0]+P_110101211*R_134[0]; double PR_010000012022=P_010000012*R_022[0]+-1*P_010000112*R_023[0]+P_010000212*R_024[0]+-1*P_010000312*R_025[0]+-1*P_110000012*R_122[0]+P_110000112*R_123[0]+-1*P_110000212*R_124[0]+P_110000312*R_125[0]; double PR_002010010022=P_002010010*R_022[0]+-1*P_002010110*R_023[0]+-1*P_002110010*R_032[0]+P_002110110*R_033[0]+-1*P_102010010*R_122[0]+P_102010110*R_123[0]+P_102110010*R_132[0]+-1*P_102110110*R_133[0]+P_202010010*R_222[0]+-1*P_202010110*R_223[0]+-1*P_202110010*R_232[0]+P_202110110*R_233[0]; double PR_001011010022=P_001011010*R_022[0]+-1*P_001011110*R_023[0]+-1*P_001111010*R_032[0]+P_001111110*R_033[0]+P_001211010*R_042[0]+-1*P_001211110*R_043[0]+-1*P_101011010*R_122[0]+P_101011110*R_123[0]+P_101111010*R_132[0]+-1*P_101111110*R_133[0]+-1*P_101211010*R_142[0]+P_101211110*R_143[0]; double PR_000012010022=P_000012010*R_022[0]+-1*P_000012110*R_023[0]+-1*P_000112010*R_032[0]+P_000112110*R_033[0]+P_000212010*R_042[0]+-1*P_000212110*R_043[0]+-1*P_000312010*R_052[0]+P_000312110*R_053[0]; double PR_001010011022=P_001010011*R_022[0]+-1*P_001010111*R_023[0]+P_001010211*R_024[0]+-1*P_001110011*R_032[0]+P_001110111*R_033[0]+-1*P_001110211*R_034[0]+-1*P_101010011*R_122[0]+P_101010111*R_123[0]+-1*P_101010211*R_124[0]+P_101110011*R_132[0]+-1*P_101110111*R_133[0]+P_101110211*R_134[0]; double PR_000011011022=P_000011011*R_022[0]+-1*P_000011111*R_023[0]+P_000011211*R_024[0]+-1*P_000111011*R_032[0]+P_000111111*R_033[0]+-1*P_000111211*R_034[0]+P_000211011*R_042[0]+-1*P_000211111*R_043[0]+P_000211211*R_044[0]; double PR_000010012022=P_000010012*R_022[0]+-1*P_000010112*R_023[0]+P_000010212*R_024[0]+-1*P_000010312*R_025[0]+-1*P_000110012*R_032[0]+P_000110112*R_033[0]+-1*P_000110212*R_034[0]+P_000110312*R_035[0]; double PR_002000020022=P_002000020*R_022[0]+-1*P_002000120*R_023[0]+P_002000220*R_024[0]+-1*P_102000020*R_122[0]+P_102000120*R_123[0]+-1*P_102000220*R_124[0]+P_202000020*R_222[0]+-1*P_202000120*R_223[0]+P_202000220*R_224[0]; double PR_001001020022=P_001001020*R_022[0]+-1*P_001001120*R_023[0]+P_001001220*R_024[0]+-1*P_001101020*R_032[0]+P_001101120*R_033[0]+-1*P_001101220*R_034[0]+-1*P_101001020*R_122[0]+P_101001120*R_123[0]+-1*P_101001220*R_124[0]+P_101101020*R_132[0]+-1*P_101101120*R_133[0]+P_101101220*R_134[0]; double PR_000002020022=P_000002020*R_022[0]+-1*P_000002120*R_023[0]+P_000002220*R_024[0]+-1*P_000102020*R_032[0]+P_000102120*R_033[0]+-1*P_000102220*R_034[0]+P_000202020*R_042[0]+-1*P_000202120*R_043[0]+P_000202220*R_044[0]; double PR_001000021022=P_001000021*R_022[0]+-1*P_001000121*R_023[0]+P_001000221*R_024[0]+-1*P_001000321*R_025[0]+-1*P_101000021*R_122[0]+P_101000121*R_123[0]+-1*P_101000221*R_124[0]+P_101000321*R_125[0]; double PR_000001021022=P_000001021*R_022[0]+-1*P_000001121*R_023[0]+P_000001221*R_024[0]+-1*P_000001321*R_025[0]+-1*P_000101021*R_032[0]+P_000101121*R_033[0]+-1*P_000101221*R_034[0]+P_000101321*R_035[0]; double PR_000000022022=P_000000022*R_022[0]+-1*P_000000122*R_023[0]+P_000000222*R_024[0]+-1*P_000000322*R_025[0]+P_000000422*R_026[0]; double PR_022000000031=P_022000000*R_031[0]+-1*P_122000000*R_131[0]+P_222000000*R_231[0]+-1*P_322000000*R_331[0]+P_422000000*R_431[0]; double PR_021001000031=P_021001000*R_031[0]+-1*P_021101000*R_041[0]+-1*P_121001000*R_131[0]+P_121101000*R_141[0]+P_221001000*R_231[0]+-1*P_221101000*R_241[0]+-1*P_321001000*R_331[0]+P_321101000*R_341[0]; double PR_020002000031=P_020002000*R_031[0]+-1*P_020102000*R_041[0]+P_020202000*R_051[0]+-1*P_120002000*R_131[0]+P_120102000*R_141[0]+-1*P_120202000*R_151[0]+P_220002000*R_231[0]+-1*P_220102000*R_241[0]+P_220202000*R_251[0]; double PR_021000001031=P_021000001*R_031[0]+-1*P_021000101*R_032[0]+-1*P_121000001*R_131[0]+P_121000101*R_132[0]+P_221000001*R_231[0]+-1*P_221000101*R_232[0]+-1*P_321000001*R_331[0]+P_321000101*R_332[0]; double PR_020001001031=P_020001001*R_031[0]+-1*P_020001101*R_032[0]+-1*P_020101001*R_041[0]+P_020101101*R_042[0]+-1*P_120001001*R_131[0]+P_120001101*R_132[0]+P_120101001*R_141[0]+-1*P_120101101*R_142[0]+P_220001001*R_231[0]+-1*P_220001101*R_232[0]+-1*P_220101001*R_241[0]+P_220101101*R_242[0]; double PR_020000002031=P_020000002*R_031[0]+-1*P_020000102*R_032[0]+P_020000202*R_033[0]+-1*P_120000002*R_131[0]+P_120000102*R_132[0]+-1*P_120000202*R_133[0]+P_220000002*R_231[0]+-1*P_220000102*R_232[0]+P_220000202*R_233[0]; double PR_012010000031=P_012010000*R_031[0]+-1*P_012110000*R_041[0]+-1*P_112010000*R_131[0]+P_112110000*R_141[0]+P_212010000*R_231[0]+-1*P_212110000*R_241[0]+-1*P_312010000*R_331[0]+P_312110000*R_341[0]; double PR_011011000031=P_011011000*R_031[0]+-1*P_011111000*R_041[0]+P_011211000*R_051[0]+-1*P_111011000*R_131[0]+P_111111000*R_141[0]+-1*P_111211000*R_151[0]+P_211011000*R_231[0]+-1*P_211111000*R_241[0]+P_211211000*R_251[0]; double PR_010012000031=P_010012000*R_031[0]+-1*P_010112000*R_041[0]+P_010212000*R_051[0]+-1*P_010312000*R_061[0]+-1*P_110012000*R_131[0]+P_110112000*R_141[0]+-1*P_110212000*R_151[0]+P_110312000*R_161[0]; double PR_011010001031=P_011010001*R_031[0]+-1*P_011010101*R_032[0]+-1*P_011110001*R_041[0]+P_011110101*R_042[0]+-1*P_111010001*R_131[0]+P_111010101*R_132[0]+P_111110001*R_141[0]+-1*P_111110101*R_142[0]+P_211010001*R_231[0]+-1*P_211010101*R_232[0]+-1*P_211110001*R_241[0]+P_211110101*R_242[0]; double PR_010011001031=P_010011001*R_031[0]+-1*P_010011101*R_032[0]+-1*P_010111001*R_041[0]+P_010111101*R_042[0]+P_010211001*R_051[0]+-1*P_010211101*R_052[0]+-1*P_110011001*R_131[0]+P_110011101*R_132[0]+P_110111001*R_141[0]+-1*P_110111101*R_142[0]+-1*P_110211001*R_151[0]+P_110211101*R_152[0]; double PR_010010002031=P_010010002*R_031[0]+-1*P_010010102*R_032[0]+P_010010202*R_033[0]+-1*P_010110002*R_041[0]+P_010110102*R_042[0]+-1*P_010110202*R_043[0]+-1*P_110010002*R_131[0]+P_110010102*R_132[0]+-1*P_110010202*R_133[0]+P_110110002*R_141[0]+-1*P_110110102*R_142[0]+P_110110202*R_143[0]; double PR_002020000031=P_002020000*R_031[0]+-1*P_002120000*R_041[0]+P_002220000*R_051[0]+-1*P_102020000*R_131[0]+P_102120000*R_141[0]+-1*P_102220000*R_151[0]+P_202020000*R_231[0]+-1*P_202120000*R_241[0]+P_202220000*R_251[0]; double PR_001021000031=P_001021000*R_031[0]+-1*P_001121000*R_041[0]+P_001221000*R_051[0]+-1*P_001321000*R_061[0]+-1*P_101021000*R_131[0]+P_101121000*R_141[0]+-1*P_101221000*R_151[0]+P_101321000*R_161[0]; double PR_000022000031=P_000022000*R_031[0]+-1*P_000122000*R_041[0]+P_000222000*R_051[0]+-1*P_000322000*R_061[0]+P_000422000*R_071[0]; double PR_001020001031=P_001020001*R_031[0]+-1*P_001020101*R_032[0]+-1*P_001120001*R_041[0]+P_001120101*R_042[0]+P_001220001*R_051[0]+-1*P_001220101*R_052[0]+-1*P_101020001*R_131[0]+P_101020101*R_132[0]+P_101120001*R_141[0]+-1*P_101120101*R_142[0]+-1*P_101220001*R_151[0]+P_101220101*R_152[0]; double PR_000021001031=P_000021001*R_031[0]+-1*P_000021101*R_032[0]+-1*P_000121001*R_041[0]+P_000121101*R_042[0]+P_000221001*R_051[0]+-1*P_000221101*R_052[0]+-1*P_000321001*R_061[0]+P_000321101*R_062[0]; double PR_000020002031=P_000020002*R_031[0]+-1*P_000020102*R_032[0]+P_000020202*R_033[0]+-1*P_000120002*R_041[0]+P_000120102*R_042[0]+-1*P_000120202*R_043[0]+P_000220002*R_051[0]+-1*P_000220102*R_052[0]+P_000220202*R_053[0]; double PR_012000010031=P_012000010*R_031[0]+-1*P_012000110*R_032[0]+-1*P_112000010*R_131[0]+P_112000110*R_132[0]+P_212000010*R_231[0]+-1*P_212000110*R_232[0]+-1*P_312000010*R_331[0]+P_312000110*R_332[0]; double PR_011001010031=P_011001010*R_031[0]+-1*P_011001110*R_032[0]+-1*P_011101010*R_041[0]+P_011101110*R_042[0]+-1*P_111001010*R_131[0]+P_111001110*R_132[0]+P_111101010*R_141[0]+-1*P_111101110*R_142[0]+P_211001010*R_231[0]+-1*P_211001110*R_232[0]+-1*P_211101010*R_241[0]+P_211101110*R_242[0]; double PR_010002010031=P_010002010*R_031[0]+-1*P_010002110*R_032[0]+-1*P_010102010*R_041[0]+P_010102110*R_042[0]+P_010202010*R_051[0]+-1*P_010202110*R_052[0]+-1*P_110002010*R_131[0]+P_110002110*R_132[0]+P_110102010*R_141[0]+-1*P_110102110*R_142[0]+-1*P_110202010*R_151[0]+P_110202110*R_152[0]; double PR_011000011031=P_011000011*R_031[0]+-1*P_011000111*R_032[0]+P_011000211*R_033[0]+-1*P_111000011*R_131[0]+P_111000111*R_132[0]+-1*P_111000211*R_133[0]+P_211000011*R_231[0]+-1*P_211000111*R_232[0]+P_211000211*R_233[0]; double PR_010001011031=P_010001011*R_031[0]+-1*P_010001111*R_032[0]+P_010001211*R_033[0]+-1*P_010101011*R_041[0]+P_010101111*R_042[0]+-1*P_010101211*R_043[0]+-1*P_110001011*R_131[0]+P_110001111*R_132[0]+-1*P_110001211*R_133[0]+P_110101011*R_141[0]+-1*P_110101111*R_142[0]+P_110101211*R_143[0]; double PR_010000012031=P_010000012*R_031[0]+-1*P_010000112*R_032[0]+P_010000212*R_033[0]+-1*P_010000312*R_034[0]+-1*P_110000012*R_131[0]+P_110000112*R_132[0]+-1*P_110000212*R_133[0]+P_110000312*R_134[0]; double PR_002010010031=P_002010010*R_031[0]+-1*P_002010110*R_032[0]+-1*P_002110010*R_041[0]+P_002110110*R_042[0]+-1*P_102010010*R_131[0]+P_102010110*R_132[0]+P_102110010*R_141[0]+-1*P_102110110*R_142[0]+P_202010010*R_231[0]+-1*P_202010110*R_232[0]+-1*P_202110010*R_241[0]+P_202110110*R_242[0]; double PR_001011010031=P_001011010*R_031[0]+-1*P_001011110*R_032[0]+-1*P_001111010*R_041[0]+P_001111110*R_042[0]+P_001211010*R_051[0]+-1*P_001211110*R_052[0]+-1*P_101011010*R_131[0]+P_101011110*R_132[0]+P_101111010*R_141[0]+-1*P_101111110*R_142[0]+-1*P_101211010*R_151[0]+P_101211110*R_152[0]; double PR_000012010031=P_000012010*R_031[0]+-1*P_000012110*R_032[0]+-1*P_000112010*R_041[0]+P_000112110*R_042[0]+P_000212010*R_051[0]+-1*P_000212110*R_052[0]+-1*P_000312010*R_061[0]+P_000312110*R_062[0]; double PR_001010011031=P_001010011*R_031[0]+-1*P_001010111*R_032[0]+P_001010211*R_033[0]+-1*P_001110011*R_041[0]+P_001110111*R_042[0]+-1*P_001110211*R_043[0]+-1*P_101010011*R_131[0]+P_101010111*R_132[0]+-1*P_101010211*R_133[0]+P_101110011*R_141[0]+-1*P_101110111*R_142[0]+P_101110211*R_143[0]; double PR_000011011031=P_000011011*R_031[0]+-1*P_000011111*R_032[0]+P_000011211*R_033[0]+-1*P_000111011*R_041[0]+P_000111111*R_042[0]+-1*P_000111211*R_043[0]+P_000211011*R_051[0]+-1*P_000211111*R_052[0]+P_000211211*R_053[0]; double PR_000010012031=P_000010012*R_031[0]+-1*P_000010112*R_032[0]+P_000010212*R_033[0]+-1*P_000010312*R_034[0]+-1*P_000110012*R_041[0]+P_000110112*R_042[0]+-1*P_000110212*R_043[0]+P_000110312*R_044[0]; double PR_002000020031=P_002000020*R_031[0]+-1*P_002000120*R_032[0]+P_002000220*R_033[0]+-1*P_102000020*R_131[0]+P_102000120*R_132[0]+-1*P_102000220*R_133[0]+P_202000020*R_231[0]+-1*P_202000120*R_232[0]+P_202000220*R_233[0]; double PR_001001020031=P_001001020*R_031[0]+-1*P_001001120*R_032[0]+P_001001220*R_033[0]+-1*P_001101020*R_041[0]+P_001101120*R_042[0]+-1*P_001101220*R_043[0]+-1*P_101001020*R_131[0]+P_101001120*R_132[0]+-1*P_101001220*R_133[0]+P_101101020*R_141[0]+-1*P_101101120*R_142[0]+P_101101220*R_143[0]; double PR_000002020031=P_000002020*R_031[0]+-1*P_000002120*R_032[0]+P_000002220*R_033[0]+-1*P_000102020*R_041[0]+P_000102120*R_042[0]+-1*P_000102220*R_043[0]+P_000202020*R_051[0]+-1*P_000202120*R_052[0]+P_000202220*R_053[0]; double PR_001000021031=P_001000021*R_031[0]+-1*P_001000121*R_032[0]+P_001000221*R_033[0]+-1*P_001000321*R_034[0]+-1*P_101000021*R_131[0]+P_101000121*R_132[0]+-1*P_101000221*R_133[0]+P_101000321*R_134[0]; double PR_000001021031=P_000001021*R_031[0]+-1*P_000001121*R_032[0]+P_000001221*R_033[0]+-1*P_000001321*R_034[0]+-1*P_000101021*R_041[0]+P_000101121*R_042[0]+-1*P_000101221*R_043[0]+P_000101321*R_044[0]; double PR_000000022031=P_000000022*R_031[0]+-1*P_000000122*R_032[0]+P_000000222*R_033[0]+-1*P_000000322*R_034[0]+P_000000422*R_035[0]; double PR_022000000040=P_022000000*R_040[0]+-1*P_122000000*R_140[0]+P_222000000*R_240[0]+-1*P_322000000*R_340[0]+P_422000000*R_440[0]; double PR_021001000040=P_021001000*R_040[0]+-1*P_021101000*R_050[0]+-1*P_121001000*R_140[0]+P_121101000*R_150[0]+P_221001000*R_240[0]+-1*P_221101000*R_250[0]+-1*P_321001000*R_340[0]+P_321101000*R_350[0]; double PR_020002000040=P_020002000*R_040[0]+-1*P_020102000*R_050[0]+P_020202000*R_060[0]+-1*P_120002000*R_140[0]+P_120102000*R_150[0]+-1*P_120202000*R_160[0]+P_220002000*R_240[0]+-1*P_220102000*R_250[0]+P_220202000*R_260[0]; double PR_021000001040=P_021000001*R_040[0]+-1*P_021000101*R_041[0]+-1*P_121000001*R_140[0]+P_121000101*R_141[0]+P_221000001*R_240[0]+-1*P_221000101*R_241[0]+-1*P_321000001*R_340[0]+P_321000101*R_341[0]; double PR_020001001040=P_020001001*R_040[0]+-1*P_020001101*R_041[0]+-1*P_020101001*R_050[0]+P_020101101*R_051[0]+-1*P_120001001*R_140[0]+P_120001101*R_141[0]+P_120101001*R_150[0]+-1*P_120101101*R_151[0]+P_220001001*R_240[0]+-1*P_220001101*R_241[0]+-1*P_220101001*R_250[0]+P_220101101*R_251[0]; double PR_020000002040=P_020000002*R_040[0]+-1*P_020000102*R_041[0]+P_020000202*R_042[0]+-1*P_120000002*R_140[0]+P_120000102*R_141[0]+-1*P_120000202*R_142[0]+P_220000002*R_240[0]+-1*P_220000102*R_241[0]+P_220000202*R_242[0]; double PR_012010000040=P_012010000*R_040[0]+-1*P_012110000*R_050[0]+-1*P_112010000*R_140[0]+P_112110000*R_150[0]+P_212010000*R_240[0]+-1*P_212110000*R_250[0]+-1*P_312010000*R_340[0]+P_312110000*R_350[0]; double PR_011011000040=P_011011000*R_040[0]+-1*P_011111000*R_050[0]+P_011211000*R_060[0]+-1*P_111011000*R_140[0]+P_111111000*R_150[0]+-1*P_111211000*R_160[0]+P_211011000*R_240[0]+-1*P_211111000*R_250[0]+P_211211000*R_260[0]; double PR_010012000040=P_010012000*R_040[0]+-1*P_010112000*R_050[0]+P_010212000*R_060[0]+-1*P_010312000*R_070[0]+-1*P_110012000*R_140[0]+P_110112000*R_150[0]+-1*P_110212000*R_160[0]+P_110312000*R_170[0]; double PR_011010001040=P_011010001*R_040[0]+-1*P_011010101*R_041[0]+-1*P_011110001*R_050[0]+P_011110101*R_051[0]+-1*P_111010001*R_140[0]+P_111010101*R_141[0]+P_111110001*R_150[0]+-1*P_111110101*R_151[0]+P_211010001*R_240[0]+-1*P_211010101*R_241[0]+-1*P_211110001*R_250[0]+P_211110101*R_251[0]; double PR_010011001040=P_010011001*R_040[0]+-1*P_010011101*R_041[0]+-1*P_010111001*R_050[0]+P_010111101*R_051[0]+P_010211001*R_060[0]+-1*P_010211101*R_061[0]+-1*P_110011001*R_140[0]+P_110011101*R_141[0]+P_110111001*R_150[0]+-1*P_110111101*R_151[0]+-1*P_110211001*R_160[0]+P_110211101*R_161[0]; double PR_010010002040=P_010010002*R_040[0]+-1*P_010010102*R_041[0]+P_010010202*R_042[0]+-1*P_010110002*R_050[0]+P_010110102*R_051[0]+-1*P_010110202*R_052[0]+-1*P_110010002*R_140[0]+P_110010102*R_141[0]+-1*P_110010202*R_142[0]+P_110110002*R_150[0]+-1*P_110110102*R_151[0]+P_110110202*R_152[0]; double PR_002020000040=P_002020000*R_040[0]+-1*P_002120000*R_050[0]+P_002220000*R_060[0]+-1*P_102020000*R_140[0]+P_102120000*R_150[0]+-1*P_102220000*R_160[0]+P_202020000*R_240[0]+-1*P_202120000*R_250[0]+P_202220000*R_260[0]; double PR_001021000040=P_001021000*R_040[0]+-1*P_001121000*R_050[0]+P_001221000*R_060[0]+-1*P_001321000*R_070[0]+-1*P_101021000*R_140[0]+P_101121000*R_150[0]+-1*P_101221000*R_160[0]+P_101321000*R_170[0]; double PR_000022000040=P_000022000*R_040[0]+-1*P_000122000*R_050[0]+P_000222000*R_060[0]+-1*P_000322000*R_070[0]+P_000422000*R_080[0]; double PR_001020001040=P_001020001*R_040[0]+-1*P_001020101*R_041[0]+-1*P_001120001*R_050[0]+P_001120101*R_051[0]+P_001220001*R_060[0]+-1*P_001220101*R_061[0]+-1*P_101020001*R_140[0]+P_101020101*R_141[0]+P_101120001*R_150[0]+-1*P_101120101*R_151[0]+-1*P_101220001*R_160[0]+P_101220101*R_161[0]; double PR_000021001040=P_000021001*R_040[0]+-1*P_000021101*R_041[0]+-1*P_000121001*R_050[0]+P_000121101*R_051[0]+P_000221001*R_060[0]+-1*P_000221101*R_061[0]+-1*P_000321001*R_070[0]+P_000321101*R_071[0]; double PR_000020002040=P_000020002*R_040[0]+-1*P_000020102*R_041[0]+P_000020202*R_042[0]+-1*P_000120002*R_050[0]+P_000120102*R_051[0]+-1*P_000120202*R_052[0]+P_000220002*R_060[0]+-1*P_000220102*R_061[0]+P_000220202*R_062[0]; double PR_012000010040=P_012000010*R_040[0]+-1*P_012000110*R_041[0]+-1*P_112000010*R_140[0]+P_112000110*R_141[0]+P_212000010*R_240[0]+-1*P_212000110*R_241[0]+-1*P_312000010*R_340[0]+P_312000110*R_341[0]; double PR_011001010040=P_011001010*R_040[0]+-1*P_011001110*R_041[0]+-1*P_011101010*R_050[0]+P_011101110*R_051[0]+-1*P_111001010*R_140[0]+P_111001110*R_141[0]+P_111101010*R_150[0]+-1*P_111101110*R_151[0]+P_211001010*R_240[0]+-1*P_211001110*R_241[0]+-1*P_211101010*R_250[0]+P_211101110*R_251[0]; double PR_010002010040=P_010002010*R_040[0]+-1*P_010002110*R_041[0]+-1*P_010102010*R_050[0]+P_010102110*R_051[0]+P_010202010*R_060[0]+-1*P_010202110*R_061[0]+-1*P_110002010*R_140[0]+P_110002110*R_141[0]+P_110102010*R_150[0]+-1*P_110102110*R_151[0]+-1*P_110202010*R_160[0]+P_110202110*R_161[0]; double PR_011000011040=P_011000011*R_040[0]+-1*P_011000111*R_041[0]+P_011000211*R_042[0]+-1*P_111000011*R_140[0]+P_111000111*R_141[0]+-1*P_111000211*R_142[0]+P_211000011*R_240[0]+-1*P_211000111*R_241[0]+P_211000211*R_242[0]; double PR_010001011040=P_010001011*R_040[0]+-1*P_010001111*R_041[0]+P_010001211*R_042[0]+-1*P_010101011*R_050[0]+P_010101111*R_051[0]+-1*P_010101211*R_052[0]+-1*P_110001011*R_140[0]+P_110001111*R_141[0]+-1*P_110001211*R_142[0]+P_110101011*R_150[0]+-1*P_110101111*R_151[0]+P_110101211*R_152[0]; double PR_010000012040=P_010000012*R_040[0]+-1*P_010000112*R_041[0]+P_010000212*R_042[0]+-1*P_010000312*R_043[0]+-1*P_110000012*R_140[0]+P_110000112*R_141[0]+-1*P_110000212*R_142[0]+P_110000312*R_143[0]; double PR_002010010040=P_002010010*R_040[0]+-1*P_002010110*R_041[0]+-1*P_002110010*R_050[0]+P_002110110*R_051[0]+-1*P_102010010*R_140[0]+P_102010110*R_141[0]+P_102110010*R_150[0]+-1*P_102110110*R_151[0]+P_202010010*R_240[0]+-1*P_202010110*R_241[0]+-1*P_202110010*R_250[0]+P_202110110*R_251[0]; double PR_001011010040=P_001011010*R_040[0]+-1*P_001011110*R_041[0]+-1*P_001111010*R_050[0]+P_001111110*R_051[0]+P_001211010*R_060[0]+-1*P_001211110*R_061[0]+-1*P_101011010*R_140[0]+P_101011110*R_141[0]+P_101111010*R_150[0]+-1*P_101111110*R_151[0]+-1*P_101211010*R_160[0]+P_101211110*R_161[0]; double PR_000012010040=P_000012010*R_040[0]+-1*P_000012110*R_041[0]+-1*P_000112010*R_050[0]+P_000112110*R_051[0]+P_000212010*R_060[0]+-1*P_000212110*R_061[0]+-1*P_000312010*R_070[0]+P_000312110*R_071[0]; double PR_001010011040=P_001010011*R_040[0]+-1*P_001010111*R_041[0]+P_001010211*R_042[0]+-1*P_001110011*R_050[0]+P_001110111*R_051[0]+-1*P_001110211*R_052[0]+-1*P_101010011*R_140[0]+P_101010111*R_141[0]+-1*P_101010211*R_142[0]+P_101110011*R_150[0]+-1*P_101110111*R_151[0]+P_101110211*R_152[0]; double PR_000011011040=P_000011011*R_040[0]+-1*P_000011111*R_041[0]+P_000011211*R_042[0]+-1*P_000111011*R_050[0]+P_000111111*R_051[0]+-1*P_000111211*R_052[0]+P_000211011*R_060[0]+-1*P_000211111*R_061[0]+P_000211211*R_062[0]; double PR_000010012040=P_000010012*R_040[0]+-1*P_000010112*R_041[0]+P_000010212*R_042[0]+-1*P_000010312*R_043[0]+-1*P_000110012*R_050[0]+P_000110112*R_051[0]+-1*P_000110212*R_052[0]+P_000110312*R_053[0]; double PR_002000020040=P_002000020*R_040[0]+-1*P_002000120*R_041[0]+P_002000220*R_042[0]+-1*P_102000020*R_140[0]+P_102000120*R_141[0]+-1*P_102000220*R_142[0]+P_202000020*R_240[0]+-1*P_202000120*R_241[0]+P_202000220*R_242[0]; double PR_001001020040=P_001001020*R_040[0]+-1*P_001001120*R_041[0]+P_001001220*R_042[0]+-1*P_001101020*R_050[0]+P_001101120*R_051[0]+-1*P_001101220*R_052[0]+-1*P_101001020*R_140[0]+P_101001120*R_141[0]+-1*P_101001220*R_142[0]+P_101101020*R_150[0]+-1*P_101101120*R_151[0]+P_101101220*R_152[0]; double PR_000002020040=P_000002020*R_040[0]+-1*P_000002120*R_041[0]+P_000002220*R_042[0]+-1*P_000102020*R_050[0]+P_000102120*R_051[0]+-1*P_000102220*R_052[0]+P_000202020*R_060[0]+-1*P_000202120*R_061[0]+P_000202220*R_062[0]; double PR_001000021040=P_001000021*R_040[0]+-1*P_001000121*R_041[0]+P_001000221*R_042[0]+-1*P_001000321*R_043[0]+-1*P_101000021*R_140[0]+P_101000121*R_141[0]+-1*P_101000221*R_142[0]+P_101000321*R_143[0]; double PR_000001021040=P_000001021*R_040[0]+-1*P_000001121*R_041[0]+P_000001221*R_042[0]+-1*P_000001321*R_043[0]+-1*P_000101021*R_050[0]+P_000101121*R_051[0]+-1*P_000101221*R_052[0]+P_000101321*R_053[0]; double PR_000000022040=P_000000022*R_040[0]+-1*P_000000122*R_041[0]+P_000000222*R_042[0]+-1*P_000000322*R_043[0]+P_000000422*R_044[0]; double PR_022000000103=P_022000000*R_103[0]+-1*P_122000000*R_203[0]+P_222000000*R_303[0]+-1*P_322000000*R_403[0]+P_422000000*R_503[0]; double PR_021001000103=P_021001000*R_103[0]+-1*P_021101000*R_113[0]+-1*P_121001000*R_203[0]+P_121101000*R_213[0]+P_221001000*R_303[0]+-1*P_221101000*R_313[0]+-1*P_321001000*R_403[0]+P_321101000*R_413[0]; double PR_020002000103=P_020002000*R_103[0]+-1*P_020102000*R_113[0]+P_020202000*R_123[0]+-1*P_120002000*R_203[0]+P_120102000*R_213[0]+-1*P_120202000*R_223[0]+P_220002000*R_303[0]+-1*P_220102000*R_313[0]+P_220202000*R_323[0]; double PR_021000001103=P_021000001*R_103[0]+-1*P_021000101*R_104[0]+-1*P_121000001*R_203[0]+P_121000101*R_204[0]+P_221000001*R_303[0]+-1*P_221000101*R_304[0]+-1*P_321000001*R_403[0]+P_321000101*R_404[0]; double PR_020001001103=P_020001001*R_103[0]+-1*P_020001101*R_104[0]+-1*P_020101001*R_113[0]+P_020101101*R_114[0]+-1*P_120001001*R_203[0]+P_120001101*R_204[0]+P_120101001*R_213[0]+-1*P_120101101*R_214[0]+P_220001001*R_303[0]+-1*P_220001101*R_304[0]+-1*P_220101001*R_313[0]+P_220101101*R_314[0]; double PR_020000002103=P_020000002*R_103[0]+-1*P_020000102*R_104[0]+P_020000202*R_105[0]+-1*P_120000002*R_203[0]+P_120000102*R_204[0]+-1*P_120000202*R_205[0]+P_220000002*R_303[0]+-1*P_220000102*R_304[0]+P_220000202*R_305[0]; double PR_012010000103=P_012010000*R_103[0]+-1*P_012110000*R_113[0]+-1*P_112010000*R_203[0]+P_112110000*R_213[0]+P_212010000*R_303[0]+-1*P_212110000*R_313[0]+-1*P_312010000*R_403[0]+P_312110000*R_413[0]; double PR_011011000103=P_011011000*R_103[0]+-1*P_011111000*R_113[0]+P_011211000*R_123[0]+-1*P_111011000*R_203[0]+P_111111000*R_213[0]+-1*P_111211000*R_223[0]+P_211011000*R_303[0]+-1*P_211111000*R_313[0]+P_211211000*R_323[0]; double PR_010012000103=P_010012000*R_103[0]+-1*P_010112000*R_113[0]+P_010212000*R_123[0]+-1*P_010312000*R_133[0]+-1*P_110012000*R_203[0]+P_110112000*R_213[0]+-1*P_110212000*R_223[0]+P_110312000*R_233[0]; double PR_011010001103=P_011010001*R_103[0]+-1*P_011010101*R_104[0]+-1*P_011110001*R_113[0]+P_011110101*R_114[0]+-1*P_111010001*R_203[0]+P_111010101*R_204[0]+P_111110001*R_213[0]+-1*P_111110101*R_214[0]+P_211010001*R_303[0]+-1*P_211010101*R_304[0]+-1*P_211110001*R_313[0]+P_211110101*R_314[0]; double PR_010011001103=P_010011001*R_103[0]+-1*P_010011101*R_104[0]+-1*P_010111001*R_113[0]+P_010111101*R_114[0]+P_010211001*R_123[0]+-1*P_010211101*R_124[0]+-1*P_110011001*R_203[0]+P_110011101*R_204[0]+P_110111001*R_213[0]+-1*P_110111101*R_214[0]+-1*P_110211001*R_223[0]+P_110211101*R_224[0]; double PR_010010002103=P_010010002*R_103[0]+-1*P_010010102*R_104[0]+P_010010202*R_105[0]+-1*P_010110002*R_113[0]+P_010110102*R_114[0]+-1*P_010110202*R_115[0]+-1*P_110010002*R_203[0]+P_110010102*R_204[0]+-1*P_110010202*R_205[0]+P_110110002*R_213[0]+-1*P_110110102*R_214[0]+P_110110202*R_215[0]; double PR_002020000103=P_002020000*R_103[0]+-1*P_002120000*R_113[0]+P_002220000*R_123[0]+-1*P_102020000*R_203[0]+P_102120000*R_213[0]+-1*P_102220000*R_223[0]+P_202020000*R_303[0]+-1*P_202120000*R_313[0]+P_202220000*R_323[0]; double PR_001021000103=P_001021000*R_103[0]+-1*P_001121000*R_113[0]+P_001221000*R_123[0]+-1*P_001321000*R_133[0]+-1*P_101021000*R_203[0]+P_101121000*R_213[0]+-1*P_101221000*R_223[0]+P_101321000*R_233[0]; double PR_000022000103=P_000022000*R_103[0]+-1*P_000122000*R_113[0]+P_000222000*R_123[0]+-1*P_000322000*R_133[0]+P_000422000*R_143[0]; double PR_001020001103=P_001020001*R_103[0]+-1*P_001020101*R_104[0]+-1*P_001120001*R_113[0]+P_001120101*R_114[0]+P_001220001*R_123[0]+-1*P_001220101*R_124[0]+-1*P_101020001*R_203[0]+P_101020101*R_204[0]+P_101120001*R_213[0]+-1*P_101120101*R_214[0]+-1*P_101220001*R_223[0]+P_101220101*R_224[0]; double PR_000021001103=P_000021001*R_103[0]+-1*P_000021101*R_104[0]+-1*P_000121001*R_113[0]+P_000121101*R_114[0]+P_000221001*R_123[0]+-1*P_000221101*R_124[0]+-1*P_000321001*R_133[0]+P_000321101*R_134[0]; double PR_000020002103=P_000020002*R_103[0]+-1*P_000020102*R_104[0]+P_000020202*R_105[0]+-1*P_000120002*R_113[0]+P_000120102*R_114[0]+-1*P_000120202*R_115[0]+P_000220002*R_123[0]+-1*P_000220102*R_124[0]+P_000220202*R_125[0]; double PR_012000010103=P_012000010*R_103[0]+-1*P_012000110*R_104[0]+-1*P_112000010*R_203[0]+P_112000110*R_204[0]+P_212000010*R_303[0]+-1*P_212000110*R_304[0]+-1*P_312000010*R_403[0]+P_312000110*R_404[0]; double PR_011001010103=P_011001010*R_103[0]+-1*P_011001110*R_104[0]+-1*P_011101010*R_113[0]+P_011101110*R_114[0]+-1*P_111001010*R_203[0]+P_111001110*R_204[0]+P_111101010*R_213[0]+-1*P_111101110*R_214[0]+P_211001010*R_303[0]+-1*P_211001110*R_304[0]+-1*P_211101010*R_313[0]+P_211101110*R_314[0]; double PR_010002010103=P_010002010*R_103[0]+-1*P_010002110*R_104[0]+-1*P_010102010*R_113[0]+P_010102110*R_114[0]+P_010202010*R_123[0]+-1*P_010202110*R_124[0]+-1*P_110002010*R_203[0]+P_110002110*R_204[0]+P_110102010*R_213[0]+-1*P_110102110*R_214[0]+-1*P_110202010*R_223[0]+P_110202110*R_224[0]; double PR_011000011103=P_011000011*R_103[0]+-1*P_011000111*R_104[0]+P_011000211*R_105[0]+-1*P_111000011*R_203[0]+P_111000111*R_204[0]+-1*P_111000211*R_205[0]+P_211000011*R_303[0]+-1*P_211000111*R_304[0]+P_211000211*R_305[0]; double PR_010001011103=P_010001011*R_103[0]+-1*P_010001111*R_104[0]+P_010001211*R_105[0]+-1*P_010101011*R_113[0]+P_010101111*R_114[0]+-1*P_010101211*R_115[0]+-1*P_110001011*R_203[0]+P_110001111*R_204[0]+-1*P_110001211*R_205[0]+P_110101011*R_213[0]+-1*P_110101111*R_214[0]+P_110101211*R_215[0]; double PR_010000012103=P_010000012*R_103[0]+-1*P_010000112*R_104[0]+P_010000212*R_105[0]+-1*P_010000312*R_106[0]+-1*P_110000012*R_203[0]+P_110000112*R_204[0]+-1*P_110000212*R_205[0]+P_110000312*R_206[0]; double PR_002010010103=P_002010010*R_103[0]+-1*P_002010110*R_104[0]+-1*P_002110010*R_113[0]+P_002110110*R_114[0]+-1*P_102010010*R_203[0]+P_102010110*R_204[0]+P_102110010*R_213[0]+-1*P_102110110*R_214[0]+P_202010010*R_303[0]+-1*P_202010110*R_304[0]+-1*P_202110010*R_313[0]+P_202110110*R_314[0]; double PR_001011010103=P_001011010*R_103[0]+-1*P_001011110*R_104[0]+-1*P_001111010*R_113[0]+P_001111110*R_114[0]+P_001211010*R_123[0]+-1*P_001211110*R_124[0]+-1*P_101011010*R_203[0]+P_101011110*R_204[0]+P_101111010*R_213[0]+-1*P_101111110*R_214[0]+-1*P_101211010*R_223[0]+P_101211110*R_224[0]; double PR_000012010103=P_000012010*R_103[0]+-1*P_000012110*R_104[0]+-1*P_000112010*R_113[0]+P_000112110*R_114[0]+P_000212010*R_123[0]+-1*P_000212110*R_124[0]+-1*P_000312010*R_133[0]+P_000312110*R_134[0]; double PR_001010011103=P_001010011*R_103[0]+-1*P_001010111*R_104[0]+P_001010211*R_105[0]+-1*P_001110011*R_113[0]+P_001110111*R_114[0]+-1*P_001110211*R_115[0]+-1*P_101010011*R_203[0]+P_101010111*R_204[0]+-1*P_101010211*R_205[0]+P_101110011*R_213[0]+-1*P_101110111*R_214[0]+P_101110211*R_215[0]; double PR_000011011103=P_000011011*R_103[0]+-1*P_000011111*R_104[0]+P_000011211*R_105[0]+-1*P_000111011*R_113[0]+P_000111111*R_114[0]+-1*P_000111211*R_115[0]+P_000211011*R_123[0]+-1*P_000211111*R_124[0]+P_000211211*R_125[0]; double PR_000010012103=P_000010012*R_103[0]+-1*P_000010112*R_104[0]+P_000010212*R_105[0]+-1*P_000010312*R_106[0]+-1*P_000110012*R_113[0]+P_000110112*R_114[0]+-1*P_000110212*R_115[0]+P_000110312*R_116[0]; double PR_002000020103=P_002000020*R_103[0]+-1*P_002000120*R_104[0]+P_002000220*R_105[0]+-1*P_102000020*R_203[0]+P_102000120*R_204[0]+-1*P_102000220*R_205[0]+P_202000020*R_303[0]+-1*P_202000120*R_304[0]+P_202000220*R_305[0]; double PR_001001020103=P_001001020*R_103[0]+-1*P_001001120*R_104[0]+P_001001220*R_105[0]+-1*P_001101020*R_113[0]+P_001101120*R_114[0]+-1*P_001101220*R_115[0]+-1*P_101001020*R_203[0]+P_101001120*R_204[0]+-1*P_101001220*R_205[0]+P_101101020*R_213[0]+-1*P_101101120*R_214[0]+P_101101220*R_215[0]; double PR_000002020103=P_000002020*R_103[0]+-1*P_000002120*R_104[0]+P_000002220*R_105[0]+-1*P_000102020*R_113[0]+P_000102120*R_114[0]+-1*P_000102220*R_115[0]+P_000202020*R_123[0]+-1*P_000202120*R_124[0]+P_000202220*R_125[0]; double PR_001000021103=P_001000021*R_103[0]+-1*P_001000121*R_104[0]+P_001000221*R_105[0]+-1*P_001000321*R_106[0]+-1*P_101000021*R_203[0]+P_101000121*R_204[0]+-1*P_101000221*R_205[0]+P_101000321*R_206[0]; double PR_000001021103=P_000001021*R_103[0]+-1*P_000001121*R_104[0]+P_000001221*R_105[0]+-1*P_000001321*R_106[0]+-1*P_000101021*R_113[0]+P_000101121*R_114[0]+-1*P_000101221*R_115[0]+P_000101321*R_116[0]; double PR_000000022103=P_000000022*R_103[0]+-1*P_000000122*R_104[0]+P_000000222*R_105[0]+-1*P_000000322*R_106[0]+P_000000422*R_107[0]; double PR_022000000112=P_022000000*R_112[0]+-1*P_122000000*R_212[0]+P_222000000*R_312[0]+-1*P_322000000*R_412[0]+P_422000000*R_512[0]; double PR_021001000112=P_021001000*R_112[0]+-1*P_021101000*R_122[0]+-1*P_121001000*R_212[0]+P_121101000*R_222[0]+P_221001000*R_312[0]+-1*P_221101000*R_322[0]+-1*P_321001000*R_412[0]+P_321101000*R_422[0]; double PR_020002000112=P_020002000*R_112[0]+-1*P_020102000*R_122[0]+P_020202000*R_132[0]+-1*P_120002000*R_212[0]+P_120102000*R_222[0]+-1*P_120202000*R_232[0]+P_220002000*R_312[0]+-1*P_220102000*R_322[0]+P_220202000*R_332[0]; double PR_021000001112=P_021000001*R_112[0]+-1*P_021000101*R_113[0]+-1*P_121000001*R_212[0]+P_121000101*R_213[0]+P_221000001*R_312[0]+-1*P_221000101*R_313[0]+-1*P_321000001*R_412[0]+P_321000101*R_413[0]; double PR_020001001112=P_020001001*R_112[0]+-1*P_020001101*R_113[0]+-1*P_020101001*R_122[0]+P_020101101*R_123[0]+-1*P_120001001*R_212[0]+P_120001101*R_213[0]+P_120101001*R_222[0]+-1*P_120101101*R_223[0]+P_220001001*R_312[0]+-1*P_220001101*R_313[0]+-1*P_220101001*R_322[0]+P_220101101*R_323[0]; double PR_020000002112=P_020000002*R_112[0]+-1*P_020000102*R_113[0]+P_020000202*R_114[0]+-1*P_120000002*R_212[0]+P_120000102*R_213[0]+-1*P_120000202*R_214[0]+P_220000002*R_312[0]+-1*P_220000102*R_313[0]+P_220000202*R_314[0]; double PR_012010000112=P_012010000*R_112[0]+-1*P_012110000*R_122[0]+-1*P_112010000*R_212[0]+P_112110000*R_222[0]+P_212010000*R_312[0]+-1*P_212110000*R_322[0]+-1*P_312010000*R_412[0]+P_312110000*R_422[0]; double PR_011011000112=P_011011000*R_112[0]+-1*P_011111000*R_122[0]+P_011211000*R_132[0]+-1*P_111011000*R_212[0]+P_111111000*R_222[0]+-1*P_111211000*R_232[0]+P_211011000*R_312[0]+-1*P_211111000*R_322[0]+P_211211000*R_332[0]; double PR_010012000112=P_010012000*R_112[0]+-1*P_010112000*R_122[0]+P_010212000*R_132[0]+-1*P_010312000*R_142[0]+-1*P_110012000*R_212[0]+P_110112000*R_222[0]+-1*P_110212000*R_232[0]+P_110312000*R_242[0]; double PR_011010001112=P_011010001*R_112[0]+-1*P_011010101*R_113[0]+-1*P_011110001*R_122[0]+P_011110101*R_123[0]+-1*P_111010001*R_212[0]+P_111010101*R_213[0]+P_111110001*R_222[0]+-1*P_111110101*R_223[0]+P_211010001*R_312[0]+-1*P_211010101*R_313[0]+-1*P_211110001*R_322[0]+P_211110101*R_323[0]; double PR_010011001112=P_010011001*R_112[0]+-1*P_010011101*R_113[0]+-1*P_010111001*R_122[0]+P_010111101*R_123[0]+P_010211001*R_132[0]+-1*P_010211101*R_133[0]+-1*P_110011001*R_212[0]+P_110011101*R_213[0]+P_110111001*R_222[0]+-1*P_110111101*R_223[0]+-1*P_110211001*R_232[0]+P_110211101*R_233[0]; double PR_010010002112=P_010010002*R_112[0]+-1*P_010010102*R_113[0]+P_010010202*R_114[0]+-1*P_010110002*R_122[0]+P_010110102*R_123[0]+-1*P_010110202*R_124[0]+-1*P_110010002*R_212[0]+P_110010102*R_213[0]+-1*P_110010202*R_214[0]+P_110110002*R_222[0]+-1*P_110110102*R_223[0]+P_110110202*R_224[0]; double PR_002020000112=P_002020000*R_112[0]+-1*P_002120000*R_122[0]+P_002220000*R_132[0]+-1*P_102020000*R_212[0]+P_102120000*R_222[0]+-1*P_102220000*R_232[0]+P_202020000*R_312[0]+-1*P_202120000*R_322[0]+P_202220000*R_332[0]; double PR_001021000112=P_001021000*R_112[0]+-1*P_001121000*R_122[0]+P_001221000*R_132[0]+-1*P_001321000*R_142[0]+-1*P_101021000*R_212[0]+P_101121000*R_222[0]+-1*P_101221000*R_232[0]+P_101321000*R_242[0]; double PR_000022000112=P_000022000*R_112[0]+-1*P_000122000*R_122[0]+P_000222000*R_132[0]+-1*P_000322000*R_142[0]+P_000422000*R_152[0]; double PR_001020001112=P_001020001*R_112[0]+-1*P_001020101*R_113[0]+-1*P_001120001*R_122[0]+P_001120101*R_123[0]+P_001220001*R_132[0]+-1*P_001220101*R_133[0]+-1*P_101020001*R_212[0]+P_101020101*R_213[0]+P_101120001*R_222[0]+-1*P_101120101*R_223[0]+-1*P_101220001*R_232[0]+P_101220101*R_233[0]; double PR_000021001112=P_000021001*R_112[0]+-1*P_000021101*R_113[0]+-1*P_000121001*R_122[0]+P_000121101*R_123[0]+P_000221001*R_132[0]+-1*P_000221101*R_133[0]+-1*P_000321001*R_142[0]+P_000321101*R_143[0]; double PR_000020002112=P_000020002*R_112[0]+-1*P_000020102*R_113[0]+P_000020202*R_114[0]+-1*P_000120002*R_122[0]+P_000120102*R_123[0]+-1*P_000120202*R_124[0]+P_000220002*R_132[0]+-1*P_000220102*R_133[0]+P_000220202*R_134[0]; double PR_012000010112=P_012000010*R_112[0]+-1*P_012000110*R_113[0]+-1*P_112000010*R_212[0]+P_112000110*R_213[0]+P_212000010*R_312[0]+-1*P_212000110*R_313[0]+-1*P_312000010*R_412[0]+P_312000110*R_413[0]; double PR_011001010112=P_011001010*R_112[0]+-1*P_011001110*R_113[0]+-1*P_011101010*R_122[0]+P_011101110*R_123[0]+-1*P_111001010*R_212[0]+P_111001110*R_213[0]+P_111101010*R_222[0]+-1*P_111101110*R_223[0]+P_211001010*R_312[0]+-1*P_211001110*R_313[0]+-1*P_211101010*R_322[0]+P_211101110*R_323[0]; double PR_010002010112=P_010002010*R_112[0]+-1*P_010002110*R_113[0]+-1*P_010102010*R_122[0]+P_010102110*R_123[0]+P_010202010*R_132[0]+-1*P_010202110*R_133[0]+-1*P_110002010*R_212[0]+P_110002110*R_213[0]+P_110102010*R_222[0]+-1*P_110102110*R_223[0]+-1*P_110202010*R_232[0]+P_110202110*R_233[0]; double PR_011000011112=P_011000011*R_112[0]+-1*P_011000111*R_113[0]+P_011000211*R_114[0]+-1*P_111000011*R_212[0]+P_111000111*R_213[0]+-1*P_111000211*R_214[0]+P_211000011*R_312[0]+-1*P_211000111*R_313[0]+P_211000211*R_314[0]; double PR_010001011112=P_010001011*R_112[0]+-1*P_010001111*R_113[0]+P_010001211*R_114[0]+-1*P_010101011*R_122[0]+P_010101111*R_123[0]+-1*P_010101211*R_124[0]+-1*P_110001011*R_212[0]+P_110001111*R_213[0]+-1*P_110001211*R_214[0]+P_110101011*R_222[0]+-1*P_110101111*R_223[0]+P_110101211*R_224[0]; double PR_010000012112=P_010000012*R_112[0]+-1*P_010000112*R_113[0]+P_010000212*R_114[0]+-1*P_010000312*R_115[0]+-1*P_110000012*R_212[0]+P_110000112*R_213[0]+-1*P_110000212*R_214[0]+P_110000312*R_215[0]; double PR_002010010112=P_002010010*R_112[0]+-1*P_002010110*R_113[0]+-1*P_002110010*R_122[0]+P_002110110*R_123[0]+-1*P_102010010*R_212[0]+P_102010110*R_213[0]+P_102110010*R_222[0]+-1*P_102110110*R_223[0]+P_202010010*R_312[0]+-1*P_202010110*R_313[0]+-1*P_202110010*R_322[0]+P_202110110*R_323[0]; double PR_001011010112=P_001011010*R_112[0]+-1*P_001011110*R_113[0]+-1*P_001111010*R_122[0]+P_001111110*R_123[0]+P_001211010*R_132[0]+-1*P_001211110*R_133[0]+-1*P_101011010*R_212[0]+P_101011110*R_213[0]+P_101111010*R_222[0]+-1*P_101111110*R_223[0]+-1*P_101211010*R_232[0]+P_101211110*R_233[0]; double PR_000012010112=P_000012010*R_112[0]+-1*P_000012110*R_113[0]+-1*P_000112010*R_122[0]+P_000112110*R_123[0]+P_000212010*R_132[0]+-1*P_000212110*R_133[0]+-1*P_000312010*R_142[0]+P_000312110*R_143[0]; double PR_001010011112=P_001010011*R_112[0]+-1*P_001010111*R_113[0]+P_001010211*R_114[0]+-1*P_001110011*R_122[0]+P_001110111*R_123[0]+-1*P_001110211*R_124[0]+-1*P_101010011*R_212[0]+P_101010111*R_213[0]+-1*P_101010211*R_214[0]+P_101110011*R_222[0]+-1*P_101110111*R_223[0]+P_101110211*R_224[0]; double PR_000011011112=P_000011011*R_112[0]+-1*P_000011111*R_113[0]+P_000011211*R_114[0]+-1*P_000111011*R_122[0]+P_000111111*R_123[0]+-1*P_000111211*R_124[0]+P_000211011*R_132[0]+-1*P_000211111*R_133[0]+P_000211211*R_134[0]; double PR_000010012112=P_000010012*R_112[0]+-1*P_000010112*R_113[0]+P_000010212*R_114[0]+-1*P_000010312*R_115[0]+-1*P_000110012*R_122[0]+P_000110112*R_123[0]+-1*P_000110212*R_124[0]+P_000110312*R_125[0]; double PR_002000020112=P_002000020*R_112[0]+-1*P_002000120*R_113[0]+P_002000220*R_114[0]+-1*P_102000020*R_212[0]+P_102000120*R_213[0]+-1*P_102000220*R_214[0]+P_202000020*R_312[0]+-1*P_202000120*R_313[0]+P_202000220*R_314[0]; double PR_001001020112=P_001001020*R_112[0]+-1*P_001001120*R_113[0]+P_001001220*R_114[0]+-1*P_001101020*R_122[0]+P_001101120*R_123[0]+-1*P_001101220*R_124[0]+-1*P_101001020*R_212[0]+P_101001120*R_213[0]+-1*P_101001220*R_214[0]+P_101101020*R_222[0]+-1*P_101101120*R_223[0]+P_101101220*R_224[0]; double PR_000002020112=P_000002020*R_112[0]+-1*P_000002120*R_113[0]+P_000002220*R_114[0]+-1*P_000102020*R_122[0]+P_000102120*R_123[0]+-1*P_000102220*R_124[0]+P_000202020*R_132[0]+-1*P_000202120*R_133[0]+P_000202220*R_134[0]; double PR_001000021112=P_001000021*R_112[0]+-1*P_001000121*R_113[0]+P_001000221*R_114[0]+-1*P_001000321*R_115[0]+-1*P_101000021*R_212[0]+P_101000121*R_213[0]+-1*P_101000221*R_214[0]+P_101000321*R_215[0]; double PR_000001021112=P_000001021*R_112[0]+-1*P_000001121*R_113[0]+P_000001221*R_114[0]+-1*P_000001321*R_115[0]+-1*P_000101021*R_122[0]+P_000101121*R_123[0]+-1*P_000101221*R_124[0]+P_000101321*R_125[0]; double PR_000000022112=P_000000022*R_112[0]+-1*P_000000122*R_113[0]+P_000000222*R_114[0]+-1*P_000000322*R_115[0]+P_000000422*R_116[0]; double PR_022000000121=P_022000000*R_121[0]+-1*P_122000000*R_221[0]+P_222000000*R_321[0]+-1*P_322000000*R_421[0]+P_422000000*R_521[0]; double PR_021001000121=P_021001000*R_121[0]+-1*P_021101000*R_131[0]+-1*P_121001000*R_221[0]+P_121101000*R_231[0]+P_221001000*R_321[0]+-1*P_221101000*R_331[0]+-1*P_321001000*R_421[0]+P_321101000*R_431[0]; double PR_020002000121=P_020002000*R_121[0]+-1*P_020102000*R_131[0]+P_020202000*R_141[0]+-1*P_120002000*R_221[0]+P_120102000*R_231[0]+-1*P_120202000*R_241[0]+P_220002000*R_321[0]+-1*P_220102000*R_331[0]+P_220202000*R_341[0]; double PR_021000001121=P_021000001*R_121[0]+-1*P_021000101*R_122[0]+-1*P_121000001*R_221[0]+P_121000101*R_222[0]+P_221000001*R_321[0]+-1*P_221000101*R_322[0]+-1*P_321000001*R_421[0]+P_321000101*R_422[0]; double PR_020001001121=P_020001001*R_121[0]+-1*P_020001101*R_122[0]+-1*P_020101001*R_131[0]+P_020101101*R_132[0]+-1*P_120001001*R_221[0]+P_120001101*R_222[0]+P_120101001*R_231[0]+-1*P_120101101*R_232[0]+P_220001001*R_321[0]+-1*P_220001101*R_322[0]+-1*P_220101001*R_331[0]+P_220101101*R_332[0]; double PR_020000002121=P_020000002*R_121[0]+-1*P_020000102*R_122[0]+P_020000202*R_123[0]+-1*P_120000002*R_221[0]+P_120000102*R_222[0]+-1*P_120000202*R_223[0]+P_220000002*R_321[0]+-1*P_220000102*R_322[0]+P_220000202*R_323[0]; double PR_012010000121=P_012010000*R_121[0]+-1*P_012110000*R_131[0]+-1*P_112010000*R_221[0]+P_112110000*R_231[0]+P_212010000*R_321[0]+-1*P_212110000*R_331[0]+-1*P_312010000*R_421[0]+P_312110000*R_431[0]; double PR_011011000121=P_011011000*R_121[0]+-1*P_011111000*R_131[0]+P_011211000*R_141[0]+-1*P_111011000*R_221[0]+P_111111000*R_231[0]+-1*P_111211000*R_241[0]+P_211011000*R_321[0]+-1*P_211111000*R_331[0]+P_211211000*R_341[0]; double PR_010012000121=P_010012000*R_121[0]+-1*P_010112000*R_131[0]+P_010212000*R_141[0]+-1*P_010312000*R_151[0]+-1*P_110012000*R_221[0]+P_110112000*R_231[0]+-1*P_110212000*R_241[0]+P_110312000*R_251[0]; double PR_011010001121=P_011010001*R_121[0]+-1*P_011010101*R_122[0]+-1*P_011110001*R_131[0]+P_011110101*R_132[0]+-1*P_111010001*R_221[0]+P_111010101*R_222[0]+P_111110001*R_231[0]+-1*P_111110101*R_232[0]+P_211010001*R_321[0]+-1*P_211010101*R_322[0]+-1*P_211110001*R_331[0]+P_211110101*R_332[0]; double PR_010011001121=P_010011001*R_121[0]+-1*P_010011101*R_122[0]+-1*P_010111001*R_131[0]+P_010111101*R_132[0]+P_010211001*R_141[0]+-1*P_010211101*R_142[0]+-1*P_110011001*R_221[0]+P_110011101*R_222[0]+P_110111001*R_231[0]+-1*P_110111101*R_232[0]+-1*P_110211001*R_241[0]+P_110211101*R_242[0]; double PR_010010002121=P_010010002*R_121[0]+-1*P_010010102*R_122[0]+P_010010202*R_123[0]+-1*P_010110002*R_131[0]+P_010110102*R_132[0]+-1*P_010110202*R_133[0]+-1*P_110010002*R_221[0]+P_110010102*R_222[0]+-1*P_110010202*R_223[0]+P_110110002*R_231[0]+-1*P_110110102*R_232[0]+P_110110202*R_233[0]; double PR_002020000121=P_002020000*R_121[0]+-1*P_002120000*R_131[0]+P_002220000*R_141[0]+-1*P_102020000*R_221[0]+P_102120000*R_231[0]+-1*P_102220000*R_241[0]+P_202020000*R_321[0]+-1*P_202120000*R_331[0]+P_202220000*R_341[0]; double PR_001021000121=P_001021000*R_121[0]+-1*P_001121000*R_131[0]+P_001221000*R_141[0]+-1*P_001321000*R_151[0]+-1*P_101021000*R_221[0]+P_101121000*R_231[0]+-1*P_101221000*R_241[0]+P_101321000*R_251[0]; double PR_000022000121=P_000022000*R_121[0]+-1*P_000122000*R_131[0]+P_000222000*R_141[0]+-1*P_000322000*R_151[0]+P_000422000*R_161[0]; double PR_001020001121=P_001020001*R_121[0]+-1*P_001020101*R_122[0]+-1*P_001120001*R_131[0]+P_001120101*R_132[0]+P_001220001*R_141[0]+-1*P_001220101*R_142[0]+-1*P_101020001*R_221[0]+P_101020101*R_222[0]+P_101120001*R_231[0]+-1*P_101120101*R_232[0]+-1*P_101220001*R_241[0]+P_101220101*R_242[0]; double PR_000021001121=P_000021001*R_121[0]+-1*P_000021101*R_122[0]+-1*P_000121001*R_131[0]+P_000121101*R_132[0]+P_000221001*R_141[0]+-1*P_000221101*R_142[0]+-1*P_000321001*R_151[0]+P_000321101*R_152[0]; double PR_000020002121=P_000020002*R_121[0]+-1*P_000020102*R_122[0]+P_000020202*R_123[0]+-1*P_000120002*R_131[0]+P_000120102*R_132[0]+-1*P_000120202*R_133[0]+P_000220002*R_141[0]+-1*P_000220102*R_142[0]+P_000220202*R_143[0]; double PR_012000010121=P_012000010*R_121[0]+-1*P_012000110*R_122[0]+-1*P_112000010*R_221[0]+P_112000110*R_222[0]+P_212000010*R_321[0]+-1*P_212000110*R_322[0]+-1*P_312000010*R_421[0]+P_312000110*R_422[0]; double PR_011001010121=P_011001010*R_121[0]+-1*P_011001110*R_122[0]+-1*P_011101010*R_131[0]+P_011101110*R_132[0]+-1*P_111001010*R_221[0]+P_111001110*R_222[0]+P_111101010*R_231[0]+-1*P_111101110*R_232[0]+P_211001010*R_321[0]+-1*P_211001110*R_322[0]+-1*P_211101010*R_331[0]+P_211101110*R_332[0]; double PR_010002010121=P_010002010*R_121[0]+-1*P_010002110*R_122[0]+-1*P_010102010*R_131[0]+P_010102110*R_132[0]+P_010202010*R_141[0]+-1*P_010202110*R_142[0]+-1*P_110002010*R_221[0]+P_110002110*R_222[0]+P_110102010*R_231[0]+-1*P_110102110*R_232[0]+-1*P_110202010*R_241[0]+P_110202110*R_242[0]; double PR_011000011121=P_011000011*R_121[0]+-1*P_011000111*R_122[0]+P_011000211*R_123[0]+-1*P_111000011*R_221[0]+P_111000111*R_222[0]+-1*P_111000211*R_223[0]+P_211000011*R_321[0]+-1*P_211000111*R_322[0]+P_211000211*R_323[0]; double PR_010001011121=P_010001011*R_121[0]+-1*P_010001111*R_122[0]+P_010001211*R_123[0]+-1*P_010101011*R_131[0]+P_010101111*R_132[0]+-1*P_010101211*R_133[0]+-1*P_110001011*R_221[0]+P_110001111*R_222[0]+-1*P_110001211*R_223[0]+P_110101011*R_231[0]+-1*P_110101111*R_232[0]+P_110101211*R_233[0]; double PR_010000012121=P_010000012*R_121[0]+-1*P_010000112*R_122[0]+P_010000212*R_123[0]+-1*P_010000312*R_124[0]+-1*P_110000012*R_221[0]+P_110000112*R_222[0]+-1*P_110000212*R_223[0]+P_110000312*R_224[0]; double PR_002010010121=P_002010010*R_121[0]+-1*P_002010110*R_122[0]+-1*P_002110010*R_131[0]+P_002110110*R_132[0]+-1*P_102010010*R_221[0]+P_102010110*R_222[0]+P_102110010*R_231[0]+-1*P_102110110*R_232[0]+P_202010010*R_321[0]+-1*P_202010110*R_322[0]+-1*P_202110010*R_331[0]+P_202110110*R_332[0]; double PR_001011010121=P_001011010*R_121[0]+-1*P_001011110*R_122[0]+-1*P_001111010*R_131[0]+P_001111110*R_132[0]+P_001211010*R_141[0]+-1*P_001211110*R_142[0]+-1*P_101011010*R_221[0]+P_101011110*R_222[0]+P_101111010*R_231[0]+-1*P_101111110*R_232[0]+-1*P_101211010*R_241[0]+P_101211110*R_242[0]; double PR_000012010121=P_000012010*R_121[0]+-1*P_000012110*R_122[0]+-1*P_000112010*R_131[0]+P_000112110*R_132[0]+P_000212010*R_141[0]+-1*P_000212110*R_142[0]+-1*P_000312010*R_151[0]+P_000312110*R_152[0]; double PR_001010011121=P_001010011*R_121[0]+-1*P_001010111*R_122[0]+P_001010211*R_123[0]+-1*P_001110011*R_131[0]+P_001110111*R_132[0]+-1*P_001110211*R_133[0]+-1*P_101010011*R_221[0]+P_101010111*R_222[0]+-1*P_101010211*R_223[0]+P_101110011*R_231[0]+-1*P_101110111*R_232[0]+P_101110211*R_233[0]; double PR_000011011121=P_000011011*R_121[0]+-1*P_000011111*R_122[0]+P_000011211*R_123[0]+-1*P_000111011*R_131[0]+P_000111111*R_132[0]+-1*P_000111211*R_133[0]+P_000211011*R_141[0]+-1*P_000211111*R_142[0]+P_000211211*R_143[0]; double PR_000010012121=P_000010012*R_121[0]+-1*P_000010112*R_122[0]+P_000010212*R_123[0]+-1*P_000010312*R_124[0]+-1*P_000110012*R_131[0]+P_000110112*R_132[0]+-1*P_000110212*R_133[0]+P_000110312*R_134[0]; double PR_002000020121=P_002000020*R_121[0]+-1*P_002000120*R_122[0]+P_002000220*R_123[0]+-1*P_102000020*R_221[0]+P_102000120*R_222[0]+-1*P_102000220*R_223[0]+P_202000020*R_321[0]+-1*P_202000120*R_322[0]+P_202000220*R_323[0]; double PR_001001020121=P_001001020*R_121[0]+-1*P_001001120*R_122[0]+P_001001220*R_123[0]+-1*P_001101020*R_131[0]+P_001101120*R_132[0]+-1*P_001101220*R_133[0]+-1*P_101001020*R_221[0]+P_101001120*R_222[0]+-1*P_101001220*R_223[0]+P_101101020*R_231[0]+-1*P_101101120*R_232[0]+P_101101220*R_233[0]; double PR_000002020121=P_000002020*R_121[0]+-1*P_000002120*R_122[0]+P_000002220*R_123[0]+-1*P_000102020*R_131[0]+P_000102120*R_132[0]+-1*P_000102220*R_133[0]+P_000202020*R_141[0]+-1*P_000202120*R_142[0]+P_000202220*R_143[0]; double PR_001000021121=P_001000021*R_121[0]+-1*P_001000121*R_122[0]+P_001000221*R_123[0]+-1*P_001000321*R_124[0]+-1*P_101000021*R_221[0]+P_101000121*R_222[0]+-1*P_101000221*R_223[0]+P_101000321*R_224[0]; double PR_000001021121=P_000001021*R_121[0]+-1*P_000001121*R_122[0]+P_000001221*R_123[0]+-1*P_000001321*R_124[0]+-1*P_000101021*R_131[0]+P_000101121*R_132[0]+-1*P_000101221*R_133[0]+P_000101321*R_134[0]; double PR_000000022121=P_000000022*R_121[0]+-1*P_000000122*R_122[0]+P_000000222*R_123[0]+-1*P_000000322*R_124[0]+P_000000422*R_125[0]; double PR_022000000130=P_022000000*R_130[0]+-1*P_122000000*R_230[0]+P_222000000*R_330[0]+-1*P_322000000*R_430[0]+P_422000000*R_530[0]; double PR_021001000130=P_021001000*R_130[0]+-1*P_021101000*R_140[0]+-1*P_121001000*R_230[0]+P_121101000*R_240[0]+P_221001000*R_330[0]+-1*P_221101000*R_340[0]+-1*P_321001000*R_430[0]+P_321101000*R_440[0]; double PR_020002000130=P_020002000*R_130[0]+-1*P_020102000*R_140[0]+P_020202000*R_150[0]+-1*P_120002000*R_230[0]+P_120102000*R_240[0]+-1*P_120202000*R_250[0]+P_220002000*R_330[0]+-1*P_220102000*R_340[0]+P_220202000*R_350[0]; double PR_021000001130=P_021000001*R_130[0]+-1*P_021000101*R_131[0]+-1*P_121000001*R_230[0]+P_121000101*R_231[0]+P_221000001*R_330[0]+-1*P_221000101*R_331[0]+-1*P_321000001*R_430[0]+P_321000101*R_431[0]; double PR_020001001130=P_020001001*R_130[0]+-1*P_020001101*R_131[0]+-1*P_020101001*R_140[0]+P_020101101*R_141[0]+-1*P_120001001*R_230[0]+P_120001101*R_231[0]+P_120101001*R_240[0]+-1*P_120101101*R_241[0]+P_220001001*R_330[0]+-1*P_220001101*R_331[0]+-1*P_220101001*R_340[0]+P_220101101*R_341[0]; double PR_020000002130=P_020000002*R_130[0]+-1*P_020000102*R_131[0]+P_020000202*R_132[0]+-1*P_120000002*R_230[0]+P_120000102*R_231[0]+-1*P_120000202*R_232[0]+P_220000002*R_330[0]+-1*P_220000102*R_331[0]+P_220000202*R_332[0]; double PR_012010000130=P_012010000*R_130[0]+-1*P_012110000*R_140[0]+-1*P_112010000*R_230[0]+P_112110000*R_240[0]+P_212010000*R_330[0]+-1*P_212110000*R_340[0]+-1*P_312010000*R_430[0]+P_312110000*R_440[0]; double PR_011011000130=P_011011000*R_130[0]+-1*P_011111000*R_140[0]+P_011211000*R_150[0]+-1*P_111011000*R_230[0]+P_111111000*R_240[0]+-1*P_111211000*R_250[0]+P_211011000*R_330[0]+-1*P_211111000*R_340[0]+P_211211000*R_350[0]; double PR_010012000130=P_010012000*R_130[0]+-1*P_010112000*R_140[0]+P_010212000*R_150[0]+-1*P_010312000*R_160[0]+-1*P_110012000*R_230[0]+P_110112000*R_240[0]+-1*P_110212000*R_250[0]+P_110312000*R_260[0]; double PR_011010001130=P_011010001*R_130[0]+-1*P_011010101*R_131[0]+-1*P_011110001*R_140[0]+P_011110101*R_141[0]+-1*P_111010001*R_230[0]+P_111010101*R_231[0]+P_111110001*R_240[0]+-1*P_111110101*R_241[0]+P_211010001*R_330[0]+-1*P_211010101*R_331[0]+-1*P_211110001*R_340[0]+P_211110101*R_341[0]; double PR_010011001130=P_010011001*R_130[0]+-1*P_010011101*R_131[0]+-1*P_010111001*R_140[0]+P_010111101*R_141[0]+P_010211001*R_150[0]+-1*P_010211101*R_151[0]+-1*P_110011001*R_230[0]+P_110011101*R_231[0]+P_110111001*R_240[0]+-1*P_110111101*R_241[0]+-1*P_110211001*R_250[0]+P_110211101*R_251[0]; double PR_010010002130=P_010010002*R_130[0]+-1*P_010010102*R_131[0]+P_010010202*R_132[0]+-1*P_010110002*R_140[0]+P_010110102*R_141[0]+-1*P_010110202*R_142[0]+-1*P_110010002*R_230[0]+P_110010102*R_231[0]+-1*P_110010202*R_232[0]+P_110110002*R_240[0]+-1*P_110110102*R_241[0]+P_110110202*R_242[0]; double PR_002020000130=P_002020000*R_130[0]+-1*P_002120000*R_140[0]+P_002220000*R_150[0]+-1*P_102020000*R_230[0]+P_102120000*R_240[0]+-1*P_102220000*R_250[0]+P_202020000*R_330[0]+-1*P_202120000*R_340[0]+P_202220000*R_350[0]; double PR_001021000130=P_001021000*R_130[0]+-1*P_001121000*R_140[0]+P_001221000*R_150[0]+-1*P_001321000*R_160[0]+-1*P_101021000*R_230[0]+P_101121000*R_240[0]+-1*P_101221000*R_250[0]+P_101321000*R_260[0]; double PR_000022000130=P_000022000*R_130[0]+-1*P_000122000*R_140[0]+P_000222000*R_150[0]+-1*P_000322000*R_160[0]+P_000422000*R_170[0]; double PR_001020001130=P_001020001*R_130[0]+-1*P_001020101*R_131[0]+-1*P_001120001*R_140[0]+P_001120101*R_141[0]+P_001220001*R_150[0]+-1*P_001220101*R_151[0]+-1*P_101020001*R_230[0]+P_101020101*R_231[0]+P_101120001*R_240[0]+-1*P_101120101*R_241[0]+-1*P_101220001*R_250[0]+P_101220101*R_251[0]; double PR_000021001130=P_000021001*R_130[0]+-1*P_000021101*R_131[0]+-1*P_000121001*R_140[0]+P_000121101*R_141[0]+P_000221001*R_150[0]+-1*P_000221101*R_151[0]+-1*P_000321001*R_160[0]+P_000321101*R_161[0]; double PR_000020002130=P_000020002*R_130[0]+-1*P_000020102*R_131[0]+P_000020202*R_132[0]+-1*P_000120002*R_140[0]+P_000120102*R_141[0]+-1*P_000120202*R_142[0]+P_000220002*R_150[0]+-1*P_000220102*R_151[0]+P_000220202*R_152[0]; double PR_012000010130=P_012000010*R_130[0]+-1*P_012000110*R_131[0]+-1*P_112000010*R_230[0]+P_112000110*R_231[0]+P_212000010*R_330[0]+-1*P_212000110*R_331[0]+-1*P_312000010*R_430[0]+P_312000110*R_431[0]; double PR_011001010130=P_011001010*R_130[0]+-1*P_011001110*R_131[0]+-1*P_011101010*R_140[0]+P_011101110*R_141[0]+-1*P_111001010*R_230[0]+P_111001110*R_231[0]+P_111101010*R_240[0]+-1*P_111101110*R_241[0]+P_211001010*R_330[0]+-1*P_211001110*R_331[0]+-1*P_211101010*R_340[0]+P_211101110*R_341[0]; double PR_010002010130=P_010002010*R_130[0]+-1*P_010002110*R_131[0]+-1*P_010102010*R_140[0]+P_010102110*R_141[0]+P_010202010*R_150[0]+-1*P_010202110*R_151[0]+-1*P_110002010*R_230[0]+P_110002110*R_231[0]+P_110102010*R_240[0]+-1*P_110102110*R_241[0]+-1*P_110202010*R_250[0]+P_110202110*R_251[0]; double PR_011000011130=P_011000011*R_130[0]+-1*P_011000111*R_131[0]+P_011000211*R_132[0]+-1*P_111000011*R_230[0]+P_111000111*R_231[0]+-1*P_111000211*R_232[0]+P_211000011*R_330[0]+-1*P_211000111*R_331[0]+P_211000211*R_332[0]; double PR_010001011130=P_010001011*R_130[0]+-1*P_010001111*R_131[0]+P_010001211*R_132[0]+-1*P_010101011*R_140[0]+P_010101111*R_141[0]+-1*P_010101211*R_142[0]+-1*P_110001011*R_230[0]+P_110001111*R_231[0]+-1*P_110001211*R_232[0]+P_110101011*R_240[0]+-1*P_110101111*R_241[0]+P_110101211*R_242[0]; double PR_010000012130=P_010000012*R_130[0]+-1*P_010000112*R_131[0]+P_010000212*R_132[0]+-1*P_010000312*R_133[0]+-1*P_110000012*R_230[0]+P_110000112*R_231[0]+-1*P_110000212*R_232[0]+P_110000312*R_233[0]; double PR_002010010130=P_002010010*R_130[0]+-1*P_002010110*R_131[0]+-1*P_002110010*R_140[0]+P_002110110*R_141[0]+-1*P_102010010*R_230[0]+P_102010110*R_231[0]+P_102110010*R_240[0]+-1*P_102110110*R_241[0]+P_202010010*R_330[0]+-1*P_202010110*R_331[0]+-1*P_202110010*R_340[0]+P_202110110*R_341[0]; double PR_001011010130=P_001011010*R_130[0]+-1*P_001011110*R_131[0]+-1*P_001111010*R_140[0]+P_001111110*R_141[0]+P_001211010*R_150[0]+-1*P_001211110*R_151[0]+-1*P_101011010*R_230[0]+P_101011110*R_231[0]+P_101111010*R_240[0]+-1*P_101111110*R_241[0]+-1*P_101211010*R_250[0]+P_101211110*R_251[0]; double PR_000012010130=P_000012010*R_130[0]+-1*P_000012110*R_131[0]+-1*P_000112010*R_140[0]+P_000112110*R_141[0]+P_000212010*R_150[0]+-1*P_000212110*R_151[0]+-1*P_000312010*R_160[0]+P_000312110*R_161[0]; double PR_001010011130=P_001010011*R_130[0]+-1*P_001010111*R_131[0]+P_001010211*R_132[0]+-1*P_001110011*R_140[0]+P_001110111*R_141[0]+-1*P_001110211*R_142[0]+-1*P_101010011*R_230[0]+P_101010111*R_231[0]+-1*P_101010211*R_232[0]+P_101110011*R_240[0]+-1*P_101110111*R_241[0]+P_101110211*R_242[0]; double PR_000011011130=P_000011011*R_130[0]+-1*P_000011111*R_131[0]+P_000011211*R_132[0]+-1*P_000111011*R_140[0]+P_000111111*R_141[0]+-1*P_000111211*R_142[0]+P_000211011*R_150[0]+-1*P_000211111*R_151[0]+P_000211211*R_152[0]; double PR_000010012130=P_000010012*R_130[0]+-1*P_000010112*R_131[0]+P_000010212*R_132[0]+-1*P_000010312*R_133[0]+-1*P_000110012*R_140[0]+P_000110112*R_141[0]+-1*P_000110212*R_142[0]+P_000110312*R_143[0]; double PR_002000020130=P_002000020*R_130[0]+-1*P_002000120*R_131[0]+P_002000220*R_132[0]+-1*P_102000020*R_230[0]+P_102000120*R_231[0]+-1*P_102000220*R_232[0]+P_202000020*R_330[0]+-1*P_202000120*R_331[0]+P_202000220*R_332[0]; double PR_001001020130=P_001001020*R_130[0]+-1*P_001001120*R_131[0]+P_001001220*R_132[0]+-1*P_001101020*R_140[0]+P_001101120*R_141[0]+-1*P_001101220*R_142[0]+-1*P_101001020*R_230[0]+P_101001120*R_231[0]+-1*P_101001220*R_232[0]+P_101101020*R_240[0]+-1*P_101101120*R_241[0]+P_101101220*R_242[0]; double PR_000002020130=P_000002020*R_130[0]+-1*P_000002120*R_131[0]+P_000002220*R_132[0]+-1*P_000102020*R_140[0]+P_000102120*R_141[0]+-1*P_000102220*R_142[0]+P_000202020*R_150[0]+-1*P_000202120*R_151[0]+P_000202220*R_152[0]; double PR_001000021130=P_001000021*R_130[0]+-1*P_001000121*R_131[0]+P_001000221*R_132[0]+-1*P_001000321*R_133[0]+-1*P_101000021*R_230[0]+P_101000121*R_231[0]+-1*P_101000221*R_232[0]+P_101000321*R_233[0]; double PR_000001021130=P_000001021*R_130[0]+-1*P_000001121*R_131[0]+P_000001221*R_132[0]+-1*P_000001321*R_133[0]+-1*P_000101021*R_140[0]+P_000101121*R_141[0]+-1*P_000101221*R_142[0]+P_000101321*R_143[0]; double PR_000000022130=P_000000022*R_130[0]+-1*P_000000122*R_131[0]+P_000000222*R_132[0]+-1*P_000000322*R_133[0]+P_000000422*R_134[0]; double PR_022000000202=P_022000000*R_202[0]+-1*P_122000000*R_302[0]+P_222000000*R_402[0]+-1*P_322000000*R_502[0]+P_422000000*R_602[0]; double PR_021001000202=P_021001000*R_202[0]+-1*P_021101000*R_212[0]+-1*P_121001000*R_302[0]+P_121101000*R_312[0]+P_221001000*R_402[0]+-1*P_221101000*R_412[0]+-1*P_321001000*R_502[0]+P_321101000*R_512[0]; double PR_020002000202=P_020002000*R_202[0]+-1*P_020102000*R_212[0]+P_020202000*R_222[0]+-1*P_120002000*R_302[0]+P_120102000*R_312[0]+-1*P_120202000*R_322[0]+P_220002000*R_402[0]+-1*P_220102000*R_412[0]+P_220202000*R_422[0]; double PR_021000001202=P_021000001*R_202[0]+-1*P_021000101*R_203[0]+-1*P_121000001*R_302[0]+P_121000101*R_303[0]+P_221000001*R_402[0]+-1*P_221000101*R_403[0]+-1*P_321000001*R_502[0]+P_321000101*R_503[0]; double PR_020001001202=P_020001001*R_202[0]+-1*P_020001101*R_203[0]+-1*P_020101001*R_212[0]+P_020101101*R_213[0]+-1*P_120001001*R_302[0]+P_120001101*R_303[0]+P_120101001*R_312[0]+-1*P_120101101*R_313[0]+P_220001001*R_402[0]+-1*P_220001101*R_403[0]+-1*P_220101001*R_412[0]+P_220101101*R_413[0]; double PR_020000002202=P_020000002*R_202[0]+-1*P_020000102*R_203[0]+P_020000202*R_204[0]+-1*P_120000002*R_302[0]+P_120000102*R_303[0]+-1*P_120000202*R_304[0]+P_220000002*R_402[0]+-1*P_220000102*R_403[0]+P_220000202*R_404[0]; double PR_012010000202=P_012010000*R_202[0]+-1*P_012110000*R_212[0]+-1*P_112010000*R_302[0]+P_112110000*R_312[0]+P_212010000*R_402[0]+-1*P_212110000*R_412[0]+-1*P_312010000*R_502[0]+P_312110000*R_512[0]; double PR_011011000202=P_011011000*R_202[0]+-1*P_011111000*R_212[0]+P_011211000*R_222[0]+-1*P_111011000*R_302[0]+P_111111000*R_312[0]+-1*P_111211000*R_322[0]+P_211011000*R_402[0]+-1*P_211111000*R_412[0]+P_211211000*R_422[0]; double PR_010012000202=P_010012000*R_202[0]+-1*P_010112000*R_212[0]+P_010212000*R_222[0]+-1*P_010312000*R_232[0]+-1*P_110012000*R_302[0]+P_110112000*R_312[0]+-1*P_110212000*R_322[0]+P_110312000*R_332[0]; double PR_011010001202=P_011010001*R_202[0]+-1*P_011010101*R_203[0]+-1*P_011110001*R_212[0]+P_011110101*R_213[0]+-1*P_111010001*R_302[0]+P_111010101*R_303[0]+P_111110001*R_312[0]+-1*P_111110101*R_313[0]+P_211010001*R_402[0]+-1*P_211010101*R_403[0]+-1*P_211110001*R_412[0]+P_211110101*R_413[0]; double PR_010011001202=P_010011001*R_202[0]+-1*P_010011101*R_203[0]+-1*P_010111001*R_212[0]+P_010111101*R_213[0]+P_010211001*R_222[0]+-1*P_010211101*R_223[0]+-1*P_110011001*R_302[0]+P_110011101*R_303[0]+P_110111001*R_312[0]+-1*P_110111101*R_313[0]+-1*P_110211001*R_322[0]+P_110211101*R_323[0]; double PR_010010002202=P_010010002*R_202[0]+-1*P_010010102*R_203[0]+P_010010202*R_204[0]+-1*P_010110002*R_212[0]+P_010110102*R_213[0]+-1*P_010110202*R_214[0]+-1*P_110010002*R_302[0]+P_110010102*R_303[0]+-1*P_110010202*R_304[0]+P_110110002*R_312[0]+-1*P_110110102*R_313[0]+P_110110202*R_314[0]; double PR_002020000202=P_002020000*R_202[0]+-1*P_002120000*R_212[0]+P_002220000*R_222[0]+-1*P_102020000*R_302[0]+P_102120000*R_312[0]+-1*P_102220000*R_322[0]+P_202020000*R_402[0]+-1*P_202120000*R_412[0]+P_202220000*R_422[0]; double PR_001021000202=P_001021000*R_202[0]+-1*P_001121000*R_212[0]+P_001221000*R_222[0]+-1*P_001321000*R_232[0]+-1*P_101021000*R_302[0]+P_101121000*R_312[0]+-1*P_101221000*R_322[0]+P_101321000*R_332[0]; double PR_000022000202=P_000022000*R_202[0]+-1*P_000122000*R_212[0]+P_000222000*R_222[0]+-1*P_000322000*R_232[0]+P_000422000*R_242[0]; double PR_001020001202=P_001020001*R_202[0]+-1*P_001020101*R_203[0]+-1*P_001120001*R_212[0]+P_001120101*R_213[0]+P_001220001*R_222[0]+-1*P_001220101*R_223[0]+-1*P_101020001*R_302[0]+P_101020101*R_303[0]+P_101120001*R_312[0]+-1*P_101120101*R_313[0]+-1*P_101220001*R_322[0]+P_101220101*R_323[0]; double PR_000021001202=P_000021001*R_202[0]+-1*P_000021101*R_203[0]+-1*P_000121001*R_212[0]+P_000121101*R_213[0]+P_000221001*R_222[0]+-1*P_000221101*R_223[0]+-1*P_000321001*R_232[0]+P_000321101*R_233[0]; double PR_000020002202=P_000020002*R_202[0]+-1*P_000020102*R_203[0]+P_000020202*R_204[0]+-1*P_000120002*R_212[0]+P_000120102*R_213[0]+-1*P_000120202*R_214[0]+P_000220002*R_222[0]+-1*P_000220102*R_223[0]+P_000220202*R_224[0]; double PR_012000010202=P_012000010*R_202[0]+-1*P_012000110*R_203[0]+-1*P_112000010*R_302[0]+P_112000110*R_303[0]+P_212000010*R_402[0]+-1*P_212000110*R_403[0]+-1*P_312000010*R_502[0]+P_312000110*R_503[0]; double PR_011001010202=P_011001010*R_202[0]+-1*P_011001110*R_203[0]+-1*P_011101010*R_212[0]+P_011101110*R_213[0]+-1*P_111001010*R_302[0]+P_111001110*R_303[0]+P_111101010*R_312[0]+-1*P_111101110*R_313[0]+P_211001010*R_402[0]+-1*P_211001110*R_403[0]+-1*P_211101010*R_412[0]+P_211101110*R_413[0]; double PR_010002010202=P_010002010*R_202[0]+-1*P_010002110*R_203[0]+-1*P_010102010*R_212[0]+P_010102110*R_213[0]+P_010202010*R_222[0]+-1*P_010202110*R_223[0]+-1*P_110002010*R_302[0]+P_110002110*R_303[0]+P_110102010*R_312[0]+-1*P_110102110*R_313[0]+-1*P_110202010*R_322[0]+P_110202110*R_323[0]; double PR_011000011202=P_011000011*R_202[0]+-1*P_011000111*R_203[0]+P_011000211*R_204[0]+-1*P_111000011*R_302[0]+P_111000111*R_303[0]+-1*P_111000211*R_304[0]+P_211000011*R_402[0]+-1*P_211000111*R_403[0]+P_211000211*R_404[0]; double PR_010001011202=P_010001011*R_202[0]+-1*P_010001111*R_203[0]+P_010001211*R_204[0]+-1*P_010101011*R_212[0]+P_010101111*R_213[0]+-1*P_010101211*R_214[0]+-1*P_110001011*R_302[0]+P_110001111*R_303[0]+-1*P_110001211*R_304[0]+P_110101011*R_312[0]+-1*P_110101111*R_313[0]+P_110101211*R_314[0]; double PR_010000012202=P_010000012*R_202[0]+-1*P_010000112*R_203[0]+P_010000212*R_204[0]+-1*P_010000312*R_205[0]+-1*P_110000012*R_302[0]+P_110000112*R_303[0]+-1*P_110000212*R_304[0]+P_110000312*R_305[0]; double PR_002010010202=P_002010010*R_202[0]+-1*P_002010110*R_203[0]+-1*P_002110010*R_212[0]+P_002110110*R_213[0]+-1*P_102010010*R_302[0]+P_102010110*R_303[0]+P_102110010*R_312[0]+-1*P_102110110*R_313[0]+P_202010010*R_402[0]+-1*P_202010110*R_403[0]+-1*P_202110010*R_412[0]+P_202110110*R_413[0]; double PR_001011010202=P_001011010*R_202[0]+-1*P_001011110*R_203[0]+-1*P_001111010*R_212[0]+P_001111110*R_213[0]+P_001211010*R_222[0]+-1*P_001211110*R_223[0]+-1*P_101011010*R_302[0]+P_101011110*R_303[0]+P_101111010*R_312[0]+-1*P_101111110*R_313[0]+-1*P_101211010*R_322[0]+P_101211110*R_323[0]; double PR_000012010202=P_000012010*R_202[0]+-1*P_000012110*R_203[0]+-1*P_000112010*R_212[0]+P_000112110*R_213[0]+P_000212010*R_222[0]+-1*P_000212110*R_223[0]+-1*P_000312010*R_232[0]+P_000312110*R_233[0]; double PR_001010011202=P_001010011*R_202[0]+-1*P_001010111*R_203[0]+P_001010211*R_204[0]+-1*P_001110011*R_212[0]+P_001110111*R_213[0]+-1*P_001110211*R_214[0]+-1*P_101010011*R_302[0]+P_101010111*R_303[0]+-1*P_101010211*R_304[0]+P_101110011*R_312[0]+-1*P_101110111*R_313[0]+P_101110211*R_314[0]; double PR_000011011202=P_000011011*R_202[0]+-1*P_000011111*R_203[0]+P_000011211*R_204[0]+-1*P_000111011*R_212[0]+P_000111111*R_213[0]+-1*P_000111211*R_214[0]+P_000211011*R_222[0]+-1*P_000211111*R_223[0]+P_000211211*R_224[0]; double PR_000010012202=P_000010012*R_202[0]+-1*P_000010112*R_203[0]+P_000010212*R_204[0]+-1*P_000010312*R_205[0]+-1*P_000110012*R_212[0]+P_000110112*R_213[0]+-1*P_000110212*R_214[0]+P_000110312*R_215[0]; double PR_002000020202=P_002000020*R_202[0]+-1*P_002000120*R_203[0]+P_002000220*R_204[0]+-1*P_102000020*R_302[0]+P_102000120*R_303[0]+-1*P_102000220*R_304[0]+P_202000020*R_402[0]+-1*P_202000120*R_403[0]+P_202000220*R_404[0]; double PR_001001020202=P_001001020*R_202[0]+-1*P_001001120*R_203[0]+P_001001220*R_204[0]+-1*P_001101020*R_212[0]+P_001101120*R_213[0]+-1*P_001101220*R_214[0]+-1*P_101001020*R_302[0]+P_101001120*R_303[0]+-1*P_101001220*R_304[0]+P_101101020*R_312[0]+-1*P_101101120*R_313[0]+P_101101220*R_314[0]; double PR_000002020202=P_000002020*R_202[0]+-1*P_000002120*R_203[0]+P_000002220*R_204[0]+-1*P_000102020*R_212[0]+P_000102120*R_213[0]+-1*P_000102220*R_214[0]+P_000202020*R_222[0]+-1*P_000202120*R_223[0]+P_000202220*R_224[0]; double PR_001000021202=P_001000021*R_202[0]+-1*P_001000121*R_203[0]+P_001000221*R_204[0]+-1*P_001000321*R_205[0]+-1*P_101000021*R_302[0]+P_101000121*R_303[0]+-1*P_101000221*R_304[0]+P_101000321*R_305[0]; double PR_000001021202=P_000001021*R_202[0]+-1*P_000001121*R_203[0]+P_000001221*R_204[0]+-1*P_000001321*R_205[0]+-1*P_000101021*R_212[0]+P_000101121*R_213[0]+-1*P_000101221*R_214[0]+P_000101321*R_215[0]; double PR_000000022202=P_000000022*R_202[0]+-1*P_000000122*R_203[0]+P_000000222*R_204[0]+-1*P_000000322*R_205[0]+P_000000422*R_206[0]; double PR_022000000211=P_022000000*R_211[0]+-1*P_122000000*R_311[0]+P_222000000*R_411[0]+-1*P_322000000*R_511[0]+P_422000000*R_611[0]; double PR_021001000211=P_021001000*R_211[0]+-1*P_021101000*R_221[0]+-1*P_121001000*R_311[0]+P_121101000*R_321[0]+P_221001000*R_411[0]+-1*P_221101000*R_421[0]+-1*P_321001000*R_511[0]+P_321101000*R_521[0]; double PR_020002000211=P_020002000*R_211[0]+-1*P_020102000*R_221[0]+P_020202000*R_231[0]+-1*P_120002000*R_311[0]+P_120102000*R_321[0]+-1*P_120202000*R_331[0]+P_220002000*R_411[0]+-1*P_220102000*R_421[0]+P_220202000*R_431[0]; double PR_021000001211=P_021000001*R_211[0]+-1*P_021000101*R_212[0]+-1*P_121000001*R_311[0]+P_121000101*R_312[0]+P_221000001*R_411[0]+-1*P_221000101*R_412[0]+-1*P_321000001*R_511[0]+P_321000101*R_512[0]; double PR_020001001211=P_020001001*R_211[0]+-1*P_020001101*R_212[0]+-1*P_020101001*R_221[0]+P_020101101*R_222[0]+-1*P_120001001*R_311[0]+P_120001101*R_312[0]+P_120101001*R_321[0]+-1*P_120101101*R_322[0]+P_220001001*R_411[0]+-1*P_220001101*R_412[0]+-1*P_220101001*R_421[0]+P_220101101*R_422[0]; double PR_020000002211=P_020000002*R_211[0]+-1*P_020000102*R_212[0]+P_020000202*R_213[0]+-1*P_120000002*R_311[0]+P_120000102*R_312[0]+-1*P_120000202*R_313[0]+P_220000002*R_411[0]+-1*P_220000102*R_412[0]+P_220000202*R_413[0]; double PR_012010000211=P_012010000*R_211[0]+-1*P_012110000*R_221[0]+-1*P_112010000*R_311[0]+P_112110000*R_321[0]+P_212010000*R_411[0]+-1*P_212110000*R_421[0]+-1*P_312010000*R_511[0]+P_312110000*R_521[0]; double PR_011011000211=P_011011000*R_211[0]+-1*P_011111000*R_221[0]+P_011211000*R_231[0]+-1*P_111011000*R_311[0]+P_111111000*R_321[0]+-1*P_111211000*R_331[0]+P_211011000*R_411[0]+-1*P_211111000*R_421[0]+P_211211000*R_431[0]; double PR_010012000211=P_010012000*R_211[0]+-1*P_010112000*R_221[0]+P_010212000*R_231[0]+-1*P_010312000*R_241[0]+-1*P_110012000*R_311[0]+P_110112000*R_321[0]+-1*P_110212000*R_331[0]+P_110312000*R_341[0]; double PR_011010001211=P_011010001*R_211[0]+-1*P_011010101*R_212[0]+-1*P_011110001*R_221[0]+P_011110101*R_222[0]+-1*P_111010001*R_311[0]+P_111010101*R_312[0]+P_111110001*R_321[0]+-1*P_111110101*R_322[0]+P_211010001*R_411[0]+-1*P_211010101*R_412[0]+-1*P_211110001*R_421[0]+P_211110101*R_422[0]; double PR_010011001211=P_010011001*R_211[0]+-1*P_010011101*R_212[0]+-1*P_010111001*R_221[0]+P_010111101*R_222[0]+P_010211001*R_231[0]+-1*P_010211101*R_232[0]+-1*P_110011001*R_311[0]+P_110011101*R_312[0]+P_110111001*R_321[0]+-1*P_110111101*R_322[0]+-1*P_110211001*R_331[0]+P_110211101*R_332[0]; double PR_010010002211=P_010010002*R_211[0]+-1*P_010010102*R_212[0]+P_010010202*R_213[0]+-1*P_010110002*R_221[0]+P_010110102*R_222[0]+-1*P_010110202*R_223[0]+-1*P_110010002*R_311[0]+P_110010102*R_312[0]+-1*P_110010202*R_313[0]+P_110110002*R_321[0]+-1*P_110110102*R_322[0]+P_110110202*R_323[0]; double PR_002020000211=P_002020000*R_211[0]+-1*P_002120000*R_221[0]+P_002220000*R_231[0]+-1*P_102020000*R_311[0]+P_102120000*R_321[0]+-1*P_102220000*R_331[0]+P_202020000*R_411[0]+-1*P_202120000*R_421[0]+P_202220000*R_431[0]; double PR_001021000211=P_001021000*R_211[0]+-1*P_001121000*R_221[0]+P_001221000*R_231[0]+-1*P_001321000*R_241[0]+-1*P_101021000*R_311[0]+P_101121000*R_321[0]+-1*P_101221000*R_331[0]+P_101321000*R_341[0]; double PR_000022000211=P_000022000*R_211[0]+-1*P_000122000*R_221[0]+P_000222000*R_231[0]+-1*P_000322000*R_241[0]+P_000422000*R_251[0]; double PR_001020001211=P_001020001*R_211[0]+-1*P_001020101*R_212[0]+-1*P_001120001*R_221[0]+P_001120101*R_222[0]+P_001220001*R_231[0]+-1*P_001220101*R_232[0]+-1*P_101020001*R_311[0]+P_101020101*R_312[0]+P_101120001*R_321[0]+-1*P_101120101*R_322[0]+-1*P_101220001*R_331[0]+P_101220101*R_332[0]; double PR_000021001211=P_000021001*R_211[0]+-1*P_000021101*R_212[0]+-1*P_000121001*R_221[0]+P_000121101*R_222[0]+P_000221001*R_231[0]+-1*P_000221101*R_232[0]+-1*P_000321001*R_241[0]+P_000321101*R_242[0]; double PR_000020002211=P_000020002*R_211[0]+-1*P_000020102*R_212[0]+P_000020202*R_213[0]+-1*P_000120002*R_221[0]+P_000120102*R_222[0]+-1*P_000120202*R_223[0]+P_000220002*R_231[0]+-1*P_000220102*R_232[0]+P_000220202*R_233[0]; double PR_012000010211=P_012000010*R_211[0]+-1*P_012000110*R_212[0]+-1*P_112000010*R_311[0]+P_112000110*R_312[0]+P_212000010*R_411[0]+-1*P_212000110*R_412[0]+-1*P_312000010*R_511[0]+P_312000110*R_512[0]; double PR_011001010211=P_011001010*R_211[0]+-1*P_011001110*R_212[0]+-1*P_011101010*R_221[0]+P_011101110*R_222[0]+-1*P_111001010*R_311[0]+P_111001110*R_312[0]+P_111101010*R_321[0]+-1*P_111101110*R_322[0]+P_211001010*R_411[0]+-1*P_211001110*R_412[0]+-1*P_211101010*R_421[0]+P_211101110*R_422[0]; double PR_010002010211=P_010002010*R_211[0]+-1*P_010002110*R_212[0]+-1*P_010102010*R_221[0]+P_010102110*R_222[0]+P_010202010*R_231[0]+-1*P_010202110*R_232[0]+-1*P_110002010*R_311[0]+P_110002110*R_312[0]+P_110102010*R_321[0]+-1*P_110102110*R_322[0]+-1*P_110202010*R_331[0]+P_110202110*R_332[0]; double PR_011000011211=P_011000011*R_211[0]+-1*P_011000111*R_212[0]+P_011000211*R_213[0]+-1*P_111000011*R_311[0]+P_111000111*R_312[0]+-1*P_111000211*R_313[0]+P_211000011*R_411[0]+-1*P_211000111*R_412[0]+P_211000211*R_413[0]; double PR_010001011211=P_010001011*R_211[0]+-1*P_010001111*R_212[0]+P_010001211*R_213[0]+-1*P_010101011*R_221[0]+P_010101111*R_222[0]+-1*P_010101211*R_223[0]+-1*P_110001011*R_311[0]+P_110001111*R_312[0]+-1*P_110001211*R_313[0]+P_110101011*R_321[0]+-1*P_110101111*R_322[0]+P_110101211*R_323[0]; double PR_010000012211=P_010000012*R_211[0]+-1*P_010000112*R_212[0]+P_010000212*R_213[0]+-1*P_010000312*R_214[0]+-1*P_110000012*R_311[0]+P_110000112*R_312[0]+-1*P_110000212*R_313[0]+P_110000312*R_314[0]; double PR_002010010211=P_002010010*R_211[0]+-1*P_002010110*R_212[0]+-1*P_002110010*R_221[0]+P_002110110*R_222[0]+-1*P_102010010*R_311[0]+P_102010110*R_312[0]+P_102110010*R_321[0]+-1*P_102110110*R_322[0]+P_202010010*R_411[0]+-1*P_202010110*R_412[0]+-1*P_202110010*R_421[0]+P_202110110*R_422[0]; double PR_001011010211=P_001011010*R_211[0]+-1*P_001011110*R_212[0]+-1*P_001111010*R_221[0]+P_001111110*R_222[0]+P_001211010*R_231[0]+-1*P_001211110*R_232[0]+-1*P_101011010*R_311[0]+P_101011110*R_312[0]+P_101111010*R_321[0]+-1*P_101111110*R_322[0]+-1*P_101211010*R_331[0]+P_101211110*R_332[0]; double PR_000012010211=P_000012010*R_211[0]+-1*P_000012110*R_212[0]+-1*P_000112010*R_221[0]+P_000112110*R_222[0]+P_000212010*R_231[0]+-1*P_000212110*R_232[0]+-1*P_000312010*R_241[0]+P_000312110*R_242[0]; double PR_001010011211=P_001010011*R_211[0]+-1*P_001010111*R_212[0]+P_001010211*R_213[0]+-1*P_001110011*R_221[0]+P_001110111*R_222[0]+-1*P_001110211*R_223[0]+-1*P_101010011*R_311[0]+P_101010111*R_312[0]+-1*P_101010211*R_313[0]+P_101110011*R_321[0]+-1*P_101110111*R_322[0]+P_101110211*R_323[0]; double PR_000011011211=P_000011011*R_211[0]+-1*P_000011111*R_212[0]+P_000011211*R_213[0]+-1*P_000111011*R_221[0]+P_000111111*R_222[0]+-1*P_000111211*R_223[0]+P_000211011*R_231[0]+-1*P_000211111*R_232[0]+P_000211211*R_233[0]; double PR_000010012211=P_000010012*R_211[0]+-1*P_000010112*R_212[0]+P_000010212*R_213[0]+-1*P_000010312*R_214[0]+-1*P_000110012*R_221[0]+P_000110112*R_222[0]+-1*P_000110212*R_223[0]+P_000110312*R_224[0]; double PR_002000020211=P_002000020*R_211[0]+-1*P_002000120*R_212[0]+P_002000220*R_213[0]+-1*P_102000020*R_311[0]+P_102000120*R_312[0]+-1*P_102000220*R_313[0]+P_202000020*R_411[0]+-1*P_202000120*R_412[0]+P_202000220*R_413[0]; double PR_001001020211=P_001001020*R_211[0]+-1*P_001001120*R_212[0]+P_001001220*R_213[0]+-1*P_001101020*R_221[0]+P_001101120*R_222[0]+-1*P_001101220*R_223[0]+-1*P_101001020*R_311[0]+P_101001120*R_312[0]+-1*P_101001220*R_313[0]+P_101101020*R_321[0]+-1*P_101101120*R_322[0]+P_101101220*R_323[0]; double PR_000002020211=P_000002020*R_211[0]+-1*P_000002120*R_212[0]+P_000002220*R_213[0]+-1*P_000102020*R_221[0]+P_000102120*R_222[0]+-1*P_000102220*R_223[0]+P_000202020*R_231[0]+-1*P_000202120*R_232[0]+P_000202220*R_233[0]; double PR_001000021211=P_001000021*R_211[0]+-1*P_001000121*R_212[0]+P_001000221*R_213[0]+-1*P_001000321*R_214[0]+-1*P_101000021*R_311[0]+P_101000121*R_312[0]+-1*P_101000221*R_313[0]+P_101000321*R_314[0]; double PR_000001021211=P_000001021*R_211[0]+-1*P_000001121*R_212[0]+P_000001221*R_213[0]+-1*P_000001321*R_214[0]+-1*P_000101021*R_221[0]+P_000101121*R_222[0]+-1*P_000101221*R_223[0]+P_000101321*R_224[0]; double PR_000000022211=P_000000022*R_211[0]+-1*P_000000122*R_212[0]+P_000000222*R_213[0]+-1*P_000000322*R_214[0]+P_000000422*R_215[0]; double PR_022000000220=P_022000000*R_220[0]+-1*P_122000000*R_320[0]+P_222000000*R_420[0]+-1*P_322000000*R_520[0]+P_422000000*R_620[0]; double PR_021001000220=P_021001000*R_220[0]+-1*P_021101000*R_230[0]+-1*P_121001000*R_320[0]+P_121101000*R_330[0]+P_221001000*R_420[0]+-1*P_221101000*R_430[0]+-1*P_321001000*R_520[0]+P_321101000*R_530[0]; double PR_020002000220=P_020002000*R_220[0]+-1*P_020102000*R_230[0]+P_020202000*R_240[0]+-1*P_120002000*R_320[0]+P_120102000*R_330[0]+-1*P_120202000*R_340[0]+P_220002000*R_420[0]+-1*P_220102000*R_430[0]+P_220202000*R_440[0]; double PR_021000001220=P_021000001*R_220[0]+-1*P_021000101*R_221[0]+-1*P_121000001*R_320[0]+P_121000101*R_321[0]+P_221000001*R_420[0]+-1*P_221000101*R_421[0]+-1*P_321000001*R_520[0]+P_321000101*R_521[0]; double PR_020001001220=P_020001001*R_220[0]+-1*P_020001101*R_221[0]+-1*P_020101001*R_230[0]+P_020101101*R_231[0]+-1*P_120001001*R_320[0]+P_120001101*R_321[0]+P_120101001*R_330[0]+-1*P_120101101*R_331[0]+P_220001001*R_420[0]+-1*P_220001101*R_421[0]+-1*P_220101001*R_430[0]+P_220101101*R_431[0]; double PR_020000002220=P_020000002*R_220[0]+-1*P_020000102*R_221[0]+P_020000202*R_222[0]+-1*P_120000002*R_320[0]+P_120000102*R_321[0]+-1*P_120000202*R_322[0]+P_220000002*R_420[0]+-1*P_220000102*R_421[0]+P_220000202*R_422[0]; double PR_012010000220=P_012010000*R_220[0]+-1*P_012110000*R_230[0]+-1*P_112010000*R_320[0]+P_112110000*R_330[0]+P_212010000*R_420[0]+-1*P_212110000*R_430[0]+-1*P_312010000*R_520[0]+P_312110000*R_530[0]; double PR_011011000220=P_011011000*R_220[0]+-1*P_011111000*R_230[0]+P_011211000*R_240[0]+-1*P_111011000*R_320[0]+P_111111000*R_330[0]+-1*P_111211000*R_340[0]+P_211011000*R_420[0]+-1*P_211111000*R_430[0]+P_211211000*R_440[0]; double PR_010012000220=P_010012000*R_220[0]+-1*P_010112000*R_230[0]+P_010212000*R_240[0]+-1*P_010312000*R_250[0]+-1*P_110012000*R_320[0]+P_110112000*R_330[0]+-1*P_110212000*R_340[0]+P_110312000*R_350[0]; double PR_011010001220=P_011010001*R_220[0]+-1*P_011010101*R_221[0]+-1*P_011110001*R_230[0]+P_011110101*R_231[0]+-1*P_111010001*R_320[0]+P_111010101*R_321[0]+P_111110001*R_330[0]+-1*P_111110101*R_331[0]+P_211010001*R_420[0]+-1*P_211010101*R_421[0]+-1*P_211110001*R_430[0]+P_211110101*R_431[0]; double PR_010011001220=P_010011001*R_220[0]+-1*P_010011101*R_221[0]+-1*P_010111001*R_230[0]+P_010111101*R_231[0]+P_010211001*R_240[0]+-1*P_010211101*R_241[0]+-1*P_110011001*R_320[0]+P_110011101*R_321[0]+P_110111001*R_330[0]+-1*P_110111101*R_331[0]+-1*P_110211001*R_340[0]+P_110211101*R_341[0]; double PR_010010002220=P_010010002*R_220[0]+-1*P_010010102*R_221[0]+P_010010202*R_222[0]+-1*P_010110002*R_230[0]+P_010110102*R_231[0]+-1*P_010110202*R_232[0]+-1*P_110010002*R_320[0]+P_110010102*R_321[0]+-1*P_110010202*R_322[0]+P_110110002*R_330[0]+-1*P_110110102*R_331[0]+P_110110202*R_332[0]; double PR_002020000220=P_002020000*R_220[0]+-1*P_002120000*R_230[0]+P_002220000*R_240[0]+-1*P_102020000*R_320[0]+P_102120000*R_330[0]+-1*P_102220000*R_340[0]+P_202020000*R_420[0]+-1*P_202120000*R_430[0]+P_202220000*R_440[0]; double PR_001021000220=P_001021000*R_220[0]+-1*P_001121000*R_230[0]+P_001221000*R_240[0]+-1*P_001321000*R_250[0]+-1*P_101021000*R_320[0]+P_101121000*R_330[0]+-1*P_101221000*R_340[0]+P_101321000*R_350[0]; double PR_000022000220=P_000022000*R_220[0]+-1*P_000122000*R_230[0]+P_000222000*R_240[0]+-1*P_000322000*R_250[0]+P_000422000*R_260[0]; double PR_001020001220=P_001020001*R_220[0]+-1*P_001020101*R_221[0]+-1*P_001120001*R_230[0]+P_001120101*R_231[0]+P_001220001*R_240[0]+-1*P_001220101*R_241[0]+-1*P_101020001*R_320[0]+P_101020101*R_321[0]+P_101120001*R_330[0]+-1*P_101120101*R_331[0]+-1*P_101220001*R_340[0]+P_101220101*R_341[0]; double PR_000021001220=P_000021001*R_220[0]+-1*P_000021101*R_221[0]+-1*P_000121001*R_230[0]+P_000121101*R_231[0]+P_000221001*R_240[0]+-1*P_000221101*R_241[0]+-1*P_000321001*R_250[0]+P_000321101*R_251[0]; double PR_000020002220=P_000020002*R_220[0]+-1*P_000020102*R_221[0]+P_000020202*R_222[0]+-1*P_000120002*R_230[0]+P_000120102*R_231[0]+-1*P_000120202*R_232[0]+P_000220002*R_240[0]+-1*P_000220102*R_241[0]+P_000220202*R_242[0]; double PR_012000010220=P_012000010*R_220[0]+-1*P_012000110*R_221[0]+-1*P_112000010*R_320[0]+P_112000110*R_321[0]+P_212000010*R_420[0]+-1*P_212000110*R_421[0]+-1*P_312000010*R_520[0]+P_312000110*R_521[0]; double PR_011001010220=P_011001010*R_220[0]+-1*P_011001110*R_221[0]+-1*P_011101010*R_230[0]+P_011101110*R_231[0]+-1*P_111001010*R_320[0]+P_111001110*R_321[0]+P_111101010*R_330[0]+-1*P_111101110*R_331[0]+P_211001010*R_420[0]+-1*P_211001110*R_421[0]+-1*P_211101010*R_430[0]+P_211101110*R_431[0]; double PR_010002010220=P_010002010*R_220[0]+-1*P_010002110*R_221[0]+-1*P_010102010*R_230[0]+P_010102110*R_231[0]+P_010202010*R_240[0]+-1*P_010202110*R_241[0]+-1*P_110002010*R_320[0]+P_110002110*R_321[0]+P_110102010*R_330[0]+-1*P_110102110*R_331[0]+-1*P_110202010*R_340[0]+P_110202110*R_341[0]; double PR_011000011220=P_011000011*R_220[0]+-1*P_011000111*R_221[0]+P_011000211*R_222[0]+-1*P_111000011*R_320[0]+P_111000111*R_321[0]+-1*P_111000211*R_322[0]+P_211000011*R_420[0]+-1*P_211000111*R_421[0]+P_211000211*R_422[0]; double PR_010001011220=P_010001011*R_220[0]+-1*P_010001111*R_221[0]+P_010001211*R_222[0]+-1*P_010101011*R_230[0]+P_010101111*R_231[0]+-1*P_010101211*R_232[0]+-1*P_110001011*R_320[0]+P_110001111*R_321[0]+-1*P_110001211*R_322[0]+P_110101011*R_330[0]+-1*P_110101111*R_331[0]+P_110101211*R_332[0]; double PR_010000012220=P_010000012*R_220[0]+-1*P_010000112*R_221[0]+P_010000212*R_222[0]+-1*P_010000312*R_223[0]+-1*P_110000012*R_320[0]+P_110000112*R_321[0]+-1*P_110000212*R_322[0]+P_110000312*R_323[0]; double PR_002010010220=P_002010010*R_220[0]+-1*P_002010110*R_221[0]+-1*P_002110010*R_230[0]+P_002110110*R_231[0]+-1*P_102010010*R_320[0]+P_102010110*R_321[0]+P_102110010*R_330[0]+-1*P_102110110*R_331[0]+P_202010010*R_420[0]+-1*P_202010110*R_421[0]+-1*P_202110010*R_430[0]+P_202110110*R_431[0]; double PR_001011010220=P_001011010*R_220[0]+-1*P_001011110*R_221[0]+-1*P_001111010*R_230[0]+P_001111110*R_231[0]+P_001211010*R_240[0]+-1*P_001211110*R_241[0]+-1*P_101011010*R_320[0]+P_101011110*R_321[0]+P_101111010*R_330[0]+-1*P_101111110*R_331[0]+-1*P_101211010*R_340[0]+P_101211110*R_341[0]; double PR_000012010220=P_000012010*R_220[0]+-1*P_000012110*R_221[0]+-1*P_000112010*R_230[0]+P_000112110*R_231[0]+P_000212010*R_240[0]+-1*P_000212110*R_241[0]+-1*P_000312010*R_250[0]+P_000312110*R_251[0]; double PR_001010011220=P_001010011*R_220[0]+-1*P_001010111*R_221[0]+P_001010211*R_222[0]+-1*P_001110011*R_230[0]+P_001110111*R_231[0]+-1*P_001110211*R_232[0]+-1*P_101010011*R_320[0]+P_101010111*R_321[0]+-1*P_101010211*R_322[0]+P_101110011*R_330[0]+-1*P_101110111*R_331[0]+P_101110211*R_332[0]; double PR_000011011220=P_000011011*R_220[0]+-1*P_000011111*R_221[0]+P_000011211*R_222[0]+-1*P_000111011*R_230[0]+P_000111111*R_231[0]+-1*P_000111211*R_232[0]+P_000211011*R_240[0]+-1*P_000211111*R_241[0]+P_000211211*R_242[0]; double PR_000010012220=P_000010012*R_220[0]+-1*P_000010112*R_221[0]+P_000010212*R_222[0]+-1*P_000010312*R_223[0]+-1*P_000110012*R_230[0]+P_000110112*R_231[0]+-1*P_000110212*R_232[0]+P_000110312*R_233[0]; double PR_002000020220=P_002000020*R_220[0]+-1*P_002000120*R_221[0]+P_002000220*R_222[0]+-1*P_102000020*R_320[0]+P_102000120*R_321[0]+-1*P_102000220*R_322[0]+P_202000020*R_420[0]+-1*P_202000120*R_421[0]+P_202000220*R_422[0]; double PR_001001020220=P_001001020*R_220[0]+-1*P_001001120*R_221[0]+P_001001220*R_222[0]+-1*P_001101020*R_230[0]+P_001101120*R_231[0]+-1*P_001101220*R_232[0]+-1*P_101001020*R_320[0]+P_101001120*R_321[0]+-1*P_101001220*R_322[0]+P_101101020*R_330[0]+-1*P_101101120*R_331[0]+P_101101220*R_332[0]; double PR_000002020220=P_000002020*R_220[0]+-1*P_000002120*R_221[0]+P_000002220*R_222[0]+-1*P_000102020*R_230[0]+P_000102120*R_231[0]+-1*P_000102220*R_232[0]+P_000202020*R_240[0]+-1*P_000202120*R_241[0]+P_000202220*R_242[0]; double PR_001000021220=P_001000021*R_220[0]+-1*P_001000121*R_221[0]+P_001000221*R_222[0]+-1*P_001000321*R_223[0]+-1*P_101000021*R_320[0]+P_101000121*R_321[0]+-1*P_101000221*R_322[0]+P_101000321*R_323[0]; double PR_000001021220=P_000001021*R_220[0]+-1*P_000001121*R_221[0]+P_000001221*R_222[0]+-1*P_000001321*R_223[0]+-1*P_000101021*R_230[0]+P_000101121*R_231[0]+-1*P_000101221*R_232[0]+P_000101321*R_233[0]; double PR_000000022220=P_000000022*R_220[0]+-1*P_000000122*R_221[0]+P_000000222*R_222[0]+-1*P_000000322*R_223[0]+P_000000422*R_224[0]; double PR_022000000301=P_022000000*R_301[0]+-1*P_122000000*R_401[0]+P_222000000*R_501[0]+-1*P_322000000*R_601[0]+P_422000000*R_701[0]; double PR_021001000301=P_021001000*R_301[0]+-1*P_021101000*R_311[0]+-1*P_121001000*R_401[0]+P_121101000*R_411[0]+P_221001000*R_501[0]+-1*P_221101000*R_511[0]+-1*P_321001000*R_601[0]+P_321101000*R_611[0]; double PR_020002000301=P_020002000*R_301[0]+-1*P_020102000*R_311[0]+P_020202000*R_321[0]+-1*P_120002000*R_401[0]+P_120102000*R_411[0]+-1*P_120202000*R_421[0]+P_220002000*R_501[0]+-1*P_220102000*R_511[0]+P_220202000*R_521[0]; double PR_021000001301=P_021000001*R_301[0]+-1*P_021000101*R_302[0]+-1*P_121000001*R_401[0]+P_121000101*R_402[0]+P_221000001*R_501[0]+-1*P_221000101*R_502[0]+-1*P_321000001*R_601[0]+P_321000101*R_602[0]; double PR_020001001301=P_020001001*R_301[0]+-1*P_020001101*R_302[0]+-1*P_020101001*R_311[0]+P_020101101*R_312[0]+-1*P_120001001*R_401[0]+P_120001101*R_402[0]+P_120101001*R_411[0]+-1*P_120101101*R_412[0]+P_220001001*R_501[0]+-1*P_220001101*R_502[0]+-1*P_220101001*R_511[0]+P_220101101*R_512[0]; double PR_020000002301=P_020000002*R_301[0]+-1*P_020000102*R_302[0]+P_020000202*R_303[0]+-1*P_120000002*R_401[0]+P_120000102*R_402[0]+-1*P_120000202*R_403[0]+P_220000002*R_501[0]+-1*P_220000102*R_502[0]+P_220000202*R_503[0]; double PR_012010000301=P_012010000*R_301[0]+-1*P_012110000*R_311[0]+-1*P_112010000*R_401[0]+P_112110000*R_411[0]+P_212010000*R_501[0]+-1*P_212110000*R_511[0]+-1*P_312010000*R_601[0]+P_312110000*R_611[0]; double PR_011011000301=P_011011000*R_301[0]+-1*P_011111000*R_311[0]+P_011211000*R_321[0]+-1*P_111011000*R_401[0]+P_111111000*R_411[0]+-1*P_111211000*R_421[0]+P_211011000*R_501[0]+-1*P_211111000*R_511[0]+P_211211000*R_521[0]; double PR_010012000301=P_010012000*R_301[0]+-1*P_010112000*R_311[0]+P_010212000*R_321[0]+-1*P_010312000*R_331[0]+-1*P_110012000*R_401[0]+P_110112000*R_411[0]+-1*P_110212000*R_421[0]+P_110312000*R_431[0]; double PR_011010001301=P_011010001*R_301[0]+-1*P_011010101*R_302[0]+-1*P_011110001*R_311[0]+P_011110101*R_312[0]+-1*P_111010001*R_401[0]+P_111010101*R_402[0]+P_111110001*R_411[0]+-1*P_111110101*R_412[0]+P_211010001*R_501[0]+-1*P_211010101*R_502[0]+-1*P_211110001*R_511[0]+P_211110101*R_512[0]; double PR_010011001301=P_010011001*R_301[0]+-1*P_010011101*R_302[0]+-1*P_010111001*R_311[0]+P_010111101*R_312[0]+P_010211001*R_321[0]+-1*P_010211101*R_322[0]+-1*P_110011001*R_401[0]+P_110011101*R_402[0]+P_110111001*R_411[0]+-1*P_110111101*R_412[0]+-1*P_110211001*R_421[0]+P_110211101*R_422[0]; double PR_010010002301=P_010010002*R_301[0]+-1*P_010010102*R_302[0]+P_010010202*R_303[0]+-1*P_010110002*R_311[0]+P_010110102*R_312[0]+-1*P_010110202*R_313[0]+-1*P_110010002*R_401[0]+P_110010102*R_402[0]+-1*P_110010202*R_403[0]+P_110110002*R_411[0]+-1*P_110110102*R_412[0]+P_110110202*R_413[0]; double PR_002020000301=P_002020000*R_301[0]+-1*P_002120000*R_311[0]+P_002220000*R_321[0]+-1*P_102020000*R_401[0]+P_102120000*R_411[0]+-1*P_102220000*R_421[0]+P_202020000*R_501[0]+-1*P_202120000*R_511[0]+P_202220000*R_521[0]; double PR_001021000301=P_001021000*R_301[0]+-1*P_001121000*R_311[0]+P_001221000*R_321[0]+-1*P_001321000*R_331[0]+-1*P_101021000*R_401[0]+P_101121000*R_411[0]+-1*P_101221000*R_421[0]+P_101321000*R_431[0]; double PR_000022000301=P_000022000*R_301[0]+-1*P_000122000*R_311[0]+P_000222000*R_321[0]+-1*P_000322000*R_331[0]+P_000422000*R_341[0]; double PR_001020001301=P_001020001*R_301[0]+-1*P_001020101*R_302[0]+-1*P_001120001*R_311[0]+P_001120101*R_312[0]+P_001220001*R_321[0]+-1*P_001220101*R_322[0]+-1*P_101020001*R_401[0]+P_101020101*R_402[0]+P_101120001*R_411[0]+-1*P_101120101*R_412[0]+-1*P_101220001*R_421[0]+P_101220101*R_422[0]; double PR_000021001301=P_000021001*R_301[0]+-1*P_000021101*R_302[0]+-1*P_000121001*R_311[0]+P_000121101*R_312[0]+P_000221001*R_321[0]+-1*P_000221101*R_322[0]+-1*P_000321001*R_331[0]+P_000321101*R_332[0]; double PR_000020002301=P_000020002*R_301[0]+-1*P_000020102*R_302[0]+P_000020202*R_303[0]+-1*P_000120002*R_311[0]+P_000120102*R_312[0]+-1*P_000120202*R_313[0]+P_000220002*R_321[0]+-1*P_000220102*R_322[0]+P_000220202*R_323[0]; double PR_012000010301=P_012000010*R_301[0]+-1*P_012000110*R_302[0]+-1*P_112000010*R_401[0]+P_112000110*R_402[0]+P_212000010*R_501[0]+-1*P_212000110*R_502[0]+-1*P_312000010*R_601[0]+P_312000110*R_602[0]; double PR_011001010301=P_011001010*R_301[0]+-1*P_011001110*R_302[0]+-1*P_011101010*R_311[0]+P_011101110*R_312[0]+-1*P_111001010*R_401[0]+P_111001110*R_402[0]+P_111101010*R_411[0]+-1*P_111101110*R_412[0]+P_211001010*R_501[0]+-1*P_211001110*R_502[0]+-1*P_211101010*R_511[0]+P_211101110*R_512[0]; double PR_010002010301=P_010002010*R_301[0]+-1*P_010002110*R_302[0]+-1*P_010102010*R_311[0]+P_010102110*R_312[0]+P_010202010*R_321[0]+-1*P_010202110*R_322[0]+-1*P_110002010*R_401[0]+P_110002110*R_402[0]+P_110102010*R_411[0]+-1*P_110102110*R_412[0]+-1*P_110202010*R_421[0]+P_110202110*R_422[0]; double PR_011000011301=P_011000011*R_301[0]+-1*P_011000111*R_302[0]+P_011000211*R_303[0]+-1*P_111000011*R_401[0]+P_111000111*R_402[0]+-1*P_111000211*R_403[0]+P_211000011*R_501[0]+-1*P_211000111*R_502[0]+P_211000211*R_503[0]; double PR_010001011301=P_010001011*R_301[0]+-1*P_010001111*R_302[0]+P_010001211*R_303[0]+-1*P_010101011*R_311[0]+P_010101111*R_312[0]+-1*P_010101211*R_313[0]+-1*P_110001011*R_401[0]+P_110001111*R_402[0]+-1*P_110001211*R_403[0]+P_110101011*R_411[0]+-1*P_110101111*R_412[0]+P_110101211*R_413[0]; double PR_010000012301=P_010000012*R_301[0]+-1*P_010000112*R_302[0]+P_010000212*R_303[0]+-1*P_010000312*R_304[0]+-1*P_110000012*R_401[0]+P_110000112*R_402[0]+-1*P_110000212*R_403[0]+P_110000312*R_404[0]; double PR_002010010301=P_002010010*R_301[0]+-1*P_002010110*R_302[0]+-1*P_002110010*R_311[0]+P_002110110*R_312[0]+-1*P_102010010*R_401[0]+P_102010110*R_402[0]+P_102110010*R_411[0]+-1*P_102110110*R_412[0]+P_202010010*R_501[0]+-1*P_202010110*R_502[0]+-1*P_202110010*R_511[0]+P_202110110*R_512[0]; double PR_001011010301=P_001011010*R_301[0]+-1*P_001011110*R_302[0]+-1*P_001111010*R_311[0]+P_001111110*R_312[0]+P_001211010*R_321[0]+-1*P_001211110*R_322[0]+-1*P_101011010*R_401[0]+P_101011110*R_402[0]+P_101111010*R_411[0]+-1*P_101111110*R_412[0]+-1*P_101211010*R_421[0]+P_101211110*R_422[0]; double PR_000012010301=P_000012010*R_301[0]+-1*P_000012110*R_302[0]+-1*P_000112010*R_311[0]+P_000112110*R_312[0]+P_000212010*R_321[0]+-1*P_000212110*R_322[0]+-1*P_000312010*R_331[0]+P_000312110*R_332[0]; double PR_001010011301=P_001010011*R_301[0]+-1*P_001010111*R_302[0]+P_001010211*R_303[0]+-1*P_001110011*R_311[0]+P_001110111*R_312[0]+-1*P_001110211*R_313[0]+-1*P_101010011*R_401[0]+P_101010111*R_402[0]+-1*P_101010211*R_403[0]+P_101110011*R_411[0]+-1*P_101110111*R_412[0]+P_101110211*R_413[0]; double PR_000011011301=P_000011011*R_301[0]+-1*P_000011111*R_302[0]+P_000011211*R_303[0]+-1*P_000111011*R_311[0]+P_000111111*R_312[0]+-1*P_000111211*R_313[0]+P_000211011*R_321[0]+-1*P_000211111*R_322[0]+P_000211211*R_323[0]; double PR_000010012301=P_000010012*R_301[0]+-1*P_000010112*R_302[0]+P_000010212*R_303[0]+-1*P_000010312*R_304[0]+-1*P_000110012*R_311[0]+P_000110112*R_312[0]+-1*P_000110212*R_313[0]+P_000110312*R_314[0]; double PR_002000020301=P_002000020*R_301[0]+-1*P_002000120*R_302[0]+P_002000220*R_303[0]+-1*P_102000020*R_401[0]+P_102000120*R_402[0]+-1*P_102000220*R_403[0]+P_202000020*R_501[0]+-1*P_202000120*R_502[0]+P_202000220*R_503[0]; double PR_001001020301=P_001001020*R_301[0]+-1*P_001001120*R_302[0]+P_001001220*R_303[0]+-1*P_001101020*R_311[0]+P_001101120*R_312[0]+-1*P_001101220*R_313[0]+-1*P_101001020*R_401[0]+P_101001120*R_402[0]+-1*P_101001220*R_403[0]+P_101101020*R_411[0]+-1*P_101101120*R_412[0]+P_101101220*R_413[0]; double PR_000002020301=P_000002020*R_301[0]+-1*P_000002120*R_302[0]+P_000002220*R_303[0]+-1*P_000102020*R_311[0]+P_000102120*R_312[0]+-1*P_000102220*R_313[0]+P_000202020*R_321[0]+-1*P_000202120*R_322[0]+P_000202220*R_323[0]; double PR_001000021301=P_001000021*R_301[0]+-1*P_001000121*R_302[0]+P_001000221*R_303[0]+-1*P_001000321*R_304[0]+-1*P_101000021*R_401[0]+P_101000121*R_402[0]+-1*P_101000221*R_403[0]+P_101000321*R_404[0]; double PR_000001021301=P_000001021*R_301[0]+-1*P_000001121*R_302[0]+P_000001221*R_303[0]+-1*P_000001321*R_304[0]+-1*P_000101021*R_311[0]+P_000101121*R_312[0]+-1*P_000101221*R_313[0]+P_000101321*R_314[0]; double PR_000000022301=P_000000022*R_301[0]+-1*P_000000122*R_302[0]+P_000000222*R_303[0]+-1*P_000000322*R_304[0]+P_000000422*R_305[0]; double PR_022000000310=P_022000000*R_310[0]+-1*P_122000000*R_410[0]+P_222000000*R_510[0]+-1*P_322000000*R_610[0]+P_422000000*R_710[0]; double PR_021001000310=P_021001000*R_310[0]+-1*P_021101000*R_320[0]+-1*P_121001000*R_410[0]+P_121101000*R_420[0]+P_221001000*R_510[0]+-1*P_221101000*R_520[0]+-1*P_321001000*R_610[0]+P_321101000*R_620[0]; double PR_020002000310=P_020002000*R_310[0]+-1*P_020102000*R_320[0]+P_020202000*R_330[0]+-1*P_120002000*R_410[0]+P_120102000*R_420[0]+-1*P_120202000*R_430[0]+P_220002000*R_510[0]+-1*P_220102000*R_520[0]+P_220202000*R_530[0]; double PR_021000001310=P_021000001*R_310[0]+-1*P_021000101*R_311[0]+-1*P_121000001*R_410[0]+P_121000101*R_411[0]+P_221000001*R_510[0]+-1*P_221000101*R_511[0]+-1*P_321000001*R_610[0]+P_321000101*R_611[0]; double PR_020001001310=P_020001001*R_310[0]+-1*P_020001101*R_311[0]+-1*P_020101001*R_320[0]+P_020101101*R_321[0]+-1*P_120001001*R_410[0]+P_120001101*R_411[0]+P_120101001*R_420[0]+-1*P_120101101*R_421[0]+P_220001001*R_510[0]+-1*P_220001101*R_511[0]+-1*P_220101001*R_520[0]+P_220101101*R_521[0]; double PR_020000002310=P_020000002*R_310[0]+-1*P_020000102*R_311[0]+P_020000202*R_312[0]+-1*P_120000002*R_410[0]+P_120000102*R_411[0]+-1*P_120000202*R_412[0]+P_220000002*R_510[0]+-1*P_220000102*R_511[0]+P_220000202*R_512[0]; double PR_012010000310=P_012010000*R_310[0]+-1*P_012110000*R_320[0]+-1*P_112010000*R_410[0]+P_112110000*R_420[0]+P_212010000*R_510[0]+-1*P_212110000*R_520[0]+-1*P_312010000*R_610[0]+P_312110000*R_620[0]; double PR_011011000310=P_011011000*R_310[0]+-1*P_011111000*R_320[0]+P_011211000*R_330[0]+-1*P_111011000*R_410[0]+P_111111000*R_420[0]+-1*P_111211000*R_430[0]+P_211011000*R_510[0]+-1*P_211111000*R_520[0]+P_211211000*R_530[0]; double PR_010012000310=P_010012000*R_310[0]+-1*P_010112000*R_320[0]+P_010212000*R_330[0]+-1*P_010312000*R_340[0]+-1*P_110012000*R_410[0]+P_110112000*R_420[0]+-1*P_110212000*R_430[0]+P_110312000*R_440[0]; double PR_011010001310=P_011010001*R_310[0]+-1*P_011010101*R_311[0]+-1*P_011110001*R_320[0]+P_011110101*R_321[0]+-1*P_111010001*R_410[0]+P_111010101*R_411[0]+P_111110001*R_420[0]+-1*P_111110101*R_421[0]+P_211010001*R_510[0]+-1*P_211010101*R_511[0]+-1*P_211110001*R_520[0]+P_211110101*R_521[0]; double PR_010011001310=P_010011001*R_310[0]+-1*P_010011101*R_311[0]+-1*P_010111001*R_320[0]+P_010111101*R_321[0]+P_010211001*R_330[0]+-1*P_010211101*R_331[0]+-1*P_110011001*R_410[0]+P_110011101*R_411[0]+P_110111001*R_420[0]+-1*P_110111101*R_421[0]+-1*P_110211001*R_430[0]+P_110211101*R_431[0]; double PR_010010002310=P_010010002*R_310[0]+-1*P_010010102*R_311[0]+P_010010202*R_312[0]+-1*P_010110002*R_320[0]+P_010110102*R_321[0]+-1*P_010110202*R_322[0]+-1*P_110010002*R_410[0]+P_110010102*R_411[0]+-1*P_110010202*R_412[0]+P_110110002*R_420[0]+-1*P_110110102*R_421[0]+P_110110202*R_422[0]; double PR_002020000310=P_002020000*R_310[0]+-1*P_002120000*R_320[0]+P_002220000*R_330[0]+-1*P_102020000*R_410[0]+P_102120000*R_420[0]+-1*P_102220000*R_430[0]+P_202020000*R_510[0]+-1*P_202120000*R_520[0]+P_202220000*R_530[0]; double PR_001021000310=P_001021000*R_310[0]+-1*P_001121000*R_320[0]+P_001221000*R_330[0]+-1*P_001321000*R_340[0]+-1*P_101021000*R_410[0]+P_101121000*R_420[0]+-1*P_101221000*R_430[0]+P_101321000*R_440[0]; double PR_000022000310=P_000022000*R_310[0]+-1*P_000122000*R_320[0]+P_000222000*R_330[0]+-1*P_000322000*R_340[0]+P_000422000*R_350[0]; double PR_001020001310=P_001020001*R_310[0]+-1*P_001020101*R_311[0]+-1*P_001120001*R_320[0]+P_001120101*R_321[0]+P_001220001*R_330[0]+-1*P_001220101*R_331[0]+-1*P_101020001*R_410[0]+P_101020101*R_411[0]+P_101120001*R_420[0]+-1*P_101120101*R_421[0]+-1*P_101220001*R_430[0]+P_101220101*R_431[0]; double PR_000021001310=P_000021001*R_310[0]+-1*P_000021101*R_311[0]+-1*P_000121001*R_320[0]+P_000121101*R_321[0]+P_000221001*R_330[0]+-1*P_000221101*R_331[0]+-1*P_000321001*R_340[0]+P_000321101*R_341[0]; double PR_000020002310=P_000020002*R_310[0]+-1*P_000020102*R_311[0]+P_000020202*R_312[0]+-1*P_000120002*R_320[0]+P_000120102*R_321[0]+-1*P_000120202*R_322[0]+P_000220002*R_330[0]+-1*P_000220102*R_331[0]+P_000220202*R_332[0]; double PR_012000010310=P_012000010*R_310[0]+-1*P_012000110*R_311[0]+-1*P_112000010*R_410[0]+P_112000110*R_411[0]+P_212000010*R_510[0]+-1*P_212000110*R_511[0]+-1*P_312000010*R_610[0]+P_312000110*R_611[0]; double PR_011001010310=P_011001010*R_310[0]+-1*P_011001110*R_311[0]+-1*P_011101010*R_320[0]+P_011101110*R_321[0]+-1*P_111001010*R_410[0]+P_111001110*R_411[0]+P_111101010*R_420[0]+-1*P_111101110*R_421[0]+P_211001010*R_510[0]+-1*P_211001110*R_511[0]+-1*P_211101010*R_520[0]+P_211101110*R_521[0]; double PR_010002010310=P_010002010*R_310[0]+-1*P_010002110*R_311[0]+-1*P_010102010*R_320[0]+P_010102110*R_321[0]+P_010202010*R_330[0]+-1*P_010202110*R_331[0]+-1*P_110002010*R_410[0]+P_110002110*R_411[0]+P_110102010*R_420[0]+-1*P_110102110*R_421[0]+-1*P_110202010*R_430[0]+P_110202110*R_431[0]; double PR_011000011310=P_011000011*R_310[0]+-1*P_011000111*R_311[0]+P_011000211*R_312[0]+-1*P_111000011*R_410[0]+P_111000111*R_411[0]+-1*P_111000211*R_412[0]+P_211000011*R_510[0]+-1*P_211000111*R_511[0]+P_211000211*R_512[0]; double PR_010001011310=P_010001011*R_310[0]+-1*P_010001111*R_311[0]+P_010001211*R_312[0]+-1*P_010101011*R_320[0]+P_010101111*R_321[0]+-1*P_010101211*R_322[0]+-1*P_110001011*R_410[0]+P_110001111*R_411[0]+-1*P_110001211*R_412[0]+P_110101011*R_420[0]+-1*P_110101111*R_421[0]+P_110101211*R_422[0]; double PR_010000012310=P_010000012*R_310[0]+-1*P_010000112*R_311[0]+P_010000212*R_312[0]+-1*P_010000312*R_313[0]+-1*P_110000012*R_410[0]+P_110000112*R_411[0]+-1*P_110000212*R_412[0]+P_110000312*R_413[0]; double PR_002010010310=P_002010010*R_310[0]+-1*P_002010110*R_311[0]+-1*P_002110010*R_320[0]+P_002110110*R_321[0]+-1*P_102010010*R_410[0]+P_102010110*R_411[0]+P_102110010*R_420[0]+-1*P_102110110*R_421[0]+P_202010010*R_510[0]+-1*P_202010110*R_511[0]+-1*P_202110010*R_520[0]+P_202110110*R_521[0]; double PR_001011010310=P_001011010*R_310[0]+-1*P_001011110*R_311[0]+-1*P_001111010*R_320[0]+P_001111110*R_321[0]+P_001211010*R_330[0]+-1*P_001211110*R_331[0]+-1*P_101011010*R_410[0]+P_101011110*R_411[0]+P_101111010*R_420[0]+-1*P_101111110*R_421[0]+-1*P_101211010*R_430[0]+P_101211110*R_431[0]; double PR_000012010310=P_000012010*R_310[0]+-1*P_000012110*R_311[0]+-1*P_000112010*R_320[0]+P_000112110*R_321[0]+P_000212010*R_330[0]+-1*P_000212110*R_331[0]+-1*P_000312010*R_340[0]+P_000312110*R_341[0]; double PR_001010011310=P_001010011*R_310[0]+-1*P_001010111*R_311[0]+P_001010211*R_312[0]+-1*P_001110011*R_320[0]+P_001110111*R_321[0]+-1*P_001110211*R_322[0]+-1*P_101010011*R_410[0]+P_101010111*R_411[0]+-1*P_101010211*R_412[0]+P_101110011*R_420[0]+-1*P_101110111*R_421[0]+P_101110211*R_422[0]; double PR_000011011310=P_000011011*R_310[0]+-1*P_000011111*R_311[0]+P_000011211*R_312[0]+-1*P_000111011*R_320[0]+P_000111111*R_321[0]+-1*P_000111211*R_322[0]+P_000211011*R_330[0]+-1*P_000211111*R_331[0]+P_000211211*R_332[0]; double PR_000010012310=P_000010012*R_310[0]+-1*P_000010112*R_311[0]+P_000010212*R_312[0]+-1*P_000010312*R_313[0]+-1*P_000110012*R_320[0]+P_000110112*R_321[0]+-1*P_000110212*R_322[0]+P_000110312*R_323[0]; double PR_002000020310=P_002000020*R_310[0]+-1*P_002000120*R_311[0]+P_002000220*R_312[0]+-1*P_102000020*R_410[0]+P_102000120*R_411[0]+-1*P_102000220*R_412[0]+P_202000020*R_510[0]+-1*P_202000120*R_511[0]+P_202000220*R_512[0]; double PR_001001020310=P_001001020*R_310[0]+-1*P_001001120*R_311[0]+P_001001220*R_312[0]+-1*P_001101020*R_320[0]+P_001101120*R_321[0]+-1*P_001101220*R_322[0]+-1*P_101001020*R_410[0]+P_101001120*R_411[0]+-1*P_101001220*R_412[0]+P_101101020*R_420[0]+-1*P_101101120*R_421[0]+P_101101220*R_422[0]; double PR_000002020310=P_000002020*R_310[0]+-1*P_000002120*R_311[0]+P_000002220*R_312[0]+-1*P_000102020*R_320[0]+P_000102120*R_321[0]+-1*P_000102220*R_322[0]+P_000202020*R_330[0]+-1*P_000202120*R_331[0]+P_000202220*R_332[0]; double PR_001000021310=P_001000021*R_310[0]+-1*P_001000121*R_311[0]+P_001000221*R_312[0]+-1*P_001000321*R_313[0]+-1*P_101000021*R_410[0]+P_101000121*R_411[0]+-1*P_101000221*R_412[0]+P_101000321*R_413[0]; double PR_000001021310=P_000001021*R_310[0]+-1*P_000001121*R_311[0]+P_000001221*R_312[0]+-1*P_000001321*R_313[0]+-1*P_000101021*R_320[0]+P_000101121*R_321[0]+-1*P_000101221*R_322[0]+P_000101321*R_323[0]; double PR_000000022310=P_000000022*R_310[0]+-1*P_000000122*R_311[0]+P_000000222*R_312[0]+-1*P_000000322*R_313[0]+P_000000422*R_314[0]; double PR_022000000400=P_022000000*R_400[0]+-1*P_122000000*R_500[0]+P_222000000*R_600[0]+-1*P_322000000*R_700[0]+P_422000000*R_800[0]; double PR_021001000400=P_021001000*R_400[0]+-1*P_021101000*R_410[0]+-1*P_121001000*R_500[0]+P_121101000*R_510[0]+P_221001000*R_600[0]+-1*P_221101000*R_610[0]+-1*P_321001000*R_700[0]+P_321101000*R_710[0]; double PR_020002000400=P_020002000*R_400[0]+-1*P_020102000*R_410[0]+P_020202000*R_420[0]+-1*P_120002000*R_500[0]+P_120102000*R_510[0]+-1*P_120202000*R_520[0]+P_220002000*R_600[0]+-1*P_220102000*R_610[0]+P_220202000*R_620[0]; double PR_021000001400=P_021000001*R_400[0]+-1*P_021000101*R_401[0]+-1*P_121000001*R_500[0]+P_121000101*R_501[0]+P_221000001*R_600[0]+-1*P_221000101*R_601[0]+-1*P_321000001*R_700[0]+P_321000101*R_701[0]; double PR_020001001400=P_020001001*R_400[0]+-1*P_020001101*R_401[0]+-1*P_020101001*R_410[0]+P_020101101*R_411[0]+-1*P_120001001*R_500[0]+P_120001101*R_501[0]+P_120101001*R_510[0]+-1*P_120101101*R_511[0]+P_220001001*R_600[0]+-1*P_220001101*R_601[0]+-1*P_220101001*R_610[0]+P_220101101*R_611[0]; double PR_020000002400=P_020000002*R_400[0]+-1*P_020000102*R_401[0]+P_020000202*R_402[0]+-1*P_120000002*R_500[0]+P_120000102*R_501[0]+-1*P_120000202*R_502[0]+P_220000002*R_600[0]+-1*P_220000102*R_601[0]+P_220000202*R_602[0]; double PR_012010000400=P_012010000*R_400[0]+-1*P_012110000*R_410[0]+-1*P_112010000*R_500[0]+P_112110000*R_510[0]+P_212010000*R_600[0]+-1*P_212110000*R_610[0]+-1*P_312010000*R_700[0]+P_312110000*R_710[0]; double PR_011011000400=P_011011000*R_400[0]+-1*P_011111000*R_410[0]+P_011211000*R_420[0]+-1*P_111011000*R_500[0]+P_111111000*R_510[0]+-1*P_111211000*R_520[0]+P_211011000*R_600[0]+-1*P_211111000*R_610[0]+P_211211000*R_620[0]; double PR_010012000400=P_010012000*R_400[0]+-1*P_010112000*R_410[0]+P_010212000*R_420[0]+-1*P_010312000*R_430[0]+-1*P_110012000*R_500[0]+P_110112000*R_510[0]+-1*P_110212000*R_520[0]+P_110312000*R_530[0]; double PR_011010001400=P_011010001*R_400[0]+-1*P_011010101*R_401[0]+-1*P_011110001*R_410[0]+P_011110101*R_411[0]+-1*P_111010001*R_500[0]+P_111010101*R_501[0]+P_111110001*R_510[0]+-1*P_111110101*R_511[0]+P_211010001*R_600[0]+-1*P_211010101*R_601[0]+-1*P_211110001*R_610[0]+P_211110101*R_611[0]; double PR_010011001400=P_010011001*R_400[0]+-1*P_010011101*R_401[0]+-1*P_010111001*R_410[0]+P_010111101*R_411[0]+P_010211001*R_420[0]+-1*P_010211101*R_421[0]+-1*P_110011001*R_500[0]+P_110011101*R_501[0]+P_110111001*R_510[0]+-1*P_110111101*R_511[0]+-1*P_110211001*R_520[0]+P_110211101*R_521[0]; double PR_010010002400=P_010010002*R_400[0]+-1*P_010010102*R_401[0]+P_010010202*R_402[0]+-1*P_010110002*R_410[0]+P_010110102*R_411[0]+-1*P_010110202*R_412[0]+-1*P_110010002*R_500[0]+P_110010102*R_501[0]+-1*P_110010202*R_502[0]+P_110110002*R_510[0]+-1*P_110110102*R_511[0]+P_110110202*R_512[0]; double PR_002020000400=P_002020000*R_400[0]+-1*P_002120000*R_410[0]+P_002220000*R_420[0]+-1*P_102020000*R_500[0]+P_102120000*R_510[0]+-1*P_102220000*R_520[0]+P_202020000*R_600[0]+-1*P_202120000*R_610[0]+P_202220000*R_620[0]; double PR_001021000400=P_001021000*R_400[0]+-1*P_001121000*R_410[0]+P_001221000*R_420[0]+-1*P_001321000*R_430[0]+-1*P_101021000*R_500[0]+P_101121000*R_510[0]+-1*P_101221000*R_520[0]+P_101321000*R_530[0]; double PR_000022000400=P_000022000*R_400[0]+-1*P_000122000*R_410[0]+P_000222000*R_420[0]+-1*P_000322000*R_430[0]+P_000422000*R_440[0]; double PR_001020001400=P_001020001*R_400[0]+-1*P_001020101*R_401[0]+-1*P_001120001*R_410[0]+P_001120101*R_411[0]+P_001220001*R_420[0]+-1*P_001220101*R_421[0]+-1*P_101020001*R_500[0]+P_101020101*R_501[0]+P_101120001*R_510[0]+-1*P_101120101*R_511[0]+-1*P_101220001*R_520[0]+P_101220101*R_521[0]; double PR_000021001400=P_000021001*R_400[0]+-1*P_000021101*R_401[0]+-1*P_000121001*R_410[0]+P_000121101*R_411[0]+P_000221001*R_420[0]+-1*P_000221101*R_421[0]+-1*P_000321001*R_430[0]+P_000321101*R_431[0]; double PR_000020002400=P_000020002*R_400[0]+-1*P_000020102*R_401[0]+P_000020202*R_402[0]+-1*P_000120002*R_410[0]+P_000120102*R_411[0]+-1*P_000120202*R_412[0]+P_000220002*R_420[0]+-1*P_000220102*R_421[0]+P_000220202*R_422[0]; double PR_012000010400=P_012000010*R_400[0]+-1*P_012000110*R_401[0]+-1*P_112000010*R_500[0]+P_112000110*R_501[0]+P_212000010*R_600[0]+-1*P_212000110*R_601[0]+-1*P_312000010*R_700[0]+P_312000110*R_701[0]; double PR_011001010400=P_011001010*R_400[0]+-1*P_011001110*R_401[0]+-1*P_011101010*R_410[0]+P_011101110*R_411[0]+-1*P_111001010*R_500[0]+P_111001110*R_501[0]+P_111101010*R_510[0]+-1*P_111101110*R_511[0]+P_211001010*R_600[0]+-1*P_211001110*R_601[0]+-1*P_211101010*R_610[0]+P_211101110*R_611[0]; double PR_010002010400=P_010002010*R_400[0]+-1*P_010002110*R_401[0]+-1*P_010102010*R_410[0]+P_010102110*R_411[0]+P_010202010*R_420[0]+-1*P_010202110*R_421[0]+-1*P_110002010*R_500[0]+P_110002110*R_501[0]+P_110102010*R_510[0]+-1*P_110102110*R_511[0]+-1*P_110202010*R_520[0]+P_110202110*R_521[0]; double PR_011000011400=P_011000011*R_400[0]+-1*P_011000111*R_401[0]+P_011000211*R_402[0]+-1*P_111000011*R_500[0]+P_111000111*R_501[0]+-1*P_111000211*R_502[0]+P_211000011*R_600[0]+-1*P_211000111*R_601[0]+P_211000211*R_602[0]; double PR_010001011400=P_010001011*R_400[0]+-1*P_010001111*R_401[0]+P_010001211*R_402[0]+-1*P_010101011*R_410[0]+P_010101111*R_411[0]+-1*P_010101211*R_412[0]+-1*P_110001011*R_500[0]+P_110001111*R_501[0]+-1*P_110001211*R_502[0]+P_110101011*R_510[0]+-1*P_110101111*R_511[0]+P_110101211*R_512[0]; double PR_010000012400=P_010000012*R_400[0]+-1*P_010000112*R_401[0]+P_010000212*R_402[0]+-1*P_010000312*R_403[0]+-1*P_110000012*R_500[0]+P_110000112*R_501[0]+-1*P_110000212*R_502[0]+P_110000312*R_503[0]; double PR_002010010400=P_002010010*R_400[0]+-1*P_002010110*R_401[0]+-1*P_002110010*R_410[0]+P_002110110*R_411[0]+-1*P_102010010*R_500[0]+P_102010110*R_501[0]+P_102110010*R_510[0]+-1*P_102110110*R_511[0]+P_202010010*R_600[0]+-1*P_202010110*R_601[0]+-1*P_202110010*R_610[0]+P_202110110*R_611[0]; double PR_001011010400=P_001011010*R_400[0]+-1*P_001011110*R_401[0]+-1*P_001111010*R_410[0]+P_001111110*R_411[0]+P_001211010*R_420[0]+-1*P_001211110*R_421[0]+-1*P_101011010*R_500[0]+P_101011110*R_501[0]+P_101111010*R_510[0]+-1*P_101111110*R_511[0]+-1*P_101211010*R_520[0]+P_101211110*R_521[0]; double PR_000012010400=P_000012010*R_400[0]+-1*P_000012110*R_401[0]+-1*P_000112010*R_410[0]+P_000112110*R_411[0]+P_000212010*R_420[0]+-1*P_000212110*R_421[0]+-1*P_000312010*R_430[0]+P_000312110*R_431[0]; double PR_001010011400=P_001010011*R_400[0]+-1*P_001010111*R_401[0]+P_001010211*R_402[0]+-1*P_001110011*R_410[0]+P_001110111*R_411[0]+-1*P_001110211*R_412[0]+-1*P_101010011*R_500[0]+P_101010111*R_501[0]+-1*P_101010211*R_502[0]+P_101110011*R_510[0]+-1*P_101110111*R_511[0]+P_101110211*R_512[0]; double PR_000011011400=P_000011011*R_400[0]+-1*P_000011111*R_401[0]+P_000011211*R_402[0]+-1*P_000111011*R_410[0]+P_000111111*R_411[0]+-1*P_000111211*R_412[0]+P_000211011*R_420[0]+-1*P_000211111*R_421[0]+P_000211211*R_422[0]; double PR_000010012400=P_000010012*R_400[0]+-1*P_000010112*R_401[0]+P_000010212*R_402[0]+-1*P_000010312*R_403[0]+-1*P_000110012*R_410[0]+P_000110112*R_411[0]+-1*P_000110212*R_412[0]+P_000110312*R_413[0]; double PR_002000020400=P_002000020*R_400[0]+-1*P_002000120*R_401[0]+P_002000220*R_402[0]+-1*P_102000020*R_500[0]+P_102000120*R_501[0]+-1*P_102000220*R_502[0]+P_202000020*R_600[0]+-1*P_202000120*R_601[0]+P_202000220*R_602[0]; double PR_001001020400=P_001001020*R_400[0]+-1*P_001001120*R_401[0]+P_001001220*R_402[0]+-1*P_001101020*R_410[0]+P_001101120*R_411[0]+-1*P_001101220*R_412[0]+-1*P_101001020*R_500[0]+P_101001120*R_501[0]+-1*P_101001220*R_502[0]+P_101101020*R_510[0]+-1*P_101101120*R_511[0]+P_101101220*R_512[0]; double PR_000002020400=P_000002020*R_400[0]+-1*P_000002120*R_401[0]+P_000002220*R_402[0]+-1*P_000102020*R_410[0]+P_000102120*R_411[0]+-1*P_000102220*R_412[0]+P_000202020*R_420[0]+-1*P_000202120*R_421[0]+P_000202220*R_422[0]; double PR_001000021400=P_001000021*R_400[0]+-1*P_001000121*R_401[0]+P_001000221*R_402[0]+-1*P_001000321*R_403[0]+-1*P_101000021*R_500[0]+P_101000121*R_501[0]+-1*P_101000221*R_502[0]+P_101000321*R_503[0]; double PR_000001021400=P_000001021*R_400[0]+-1*P_000001121*R_401[0]+P_000001221*R_402[0]+-1*P_000001321*R_403[0]+-1*P_000101021*R_410[0]+P_000101121*R_411[0]+-1*P_000101221*R_412[0]+P_000101321*R_413[0]; double PR_000000022400=P_000000022*R_400[0]+-1*P_000000122*R_401[0]+P_000000222*R_402[0]+-1*P_000000322*R_403[0]+P_000000422*R_404[0]; double Qd_101[3]; double Qd_002[3]; double Qd_102[3]; double Qd_202[3]; double Qd_110[3]; double Qd_011[3]; double Qd_111[3]; double Qd_211[3]; double Qd_012[3]; double Qd_112[3]; double Qd_212[3]; double Qd_312[3]; double Qd_020[3]; double Qd_120[3]; double Qd_220[3]; double Qd_021[3]; double Qd_121[3]; double Qd_221[3]; double Qd_321[3]; double Qd_022[3]; double Qd_122[3]; double Qd_222[3]; double Qd_322[3]; double Qd_422[3]; for(int i=0;i<3;i++){ Qd_101[i]=aQin1; } for(int i=0;i<3;i++){ Qd_002[i]=Qd_101[i]+Qd_001[i]*Qd_001[i]; } for(int i=0;i<3;i++){ Qd_102[i]=Qd_001[i]*Qd_101[i]+aQin1*Qd_001[i]; } for(int i=0;i<3;i++){ Qd_202[i]=aQin1*Qd_101[i]; } for(int i=0;i<3;i++){ Qd_110[i]=aQin1; } for(int i=0;i<3;i++){ Qd_011[i]=Qd_101[i]+Qd_010[i]*Qd_001[i]; } for(int i=0;i<3;i++){ Qd_111[i]=Qd_010[i]*Qd_101[i]+aQin1*Qd_001[i]; } for(int i=0;i<3;i++){ Qd_211[i]=aQin1*Qd_101[i]; } for(int i=0;i<3;i++){ Qd_012[i]=Qd_111[i]+Qd_001[i]*Qd_011[i]; } for(int i=0;i<3;i++){ Qd_112[i]=2*Qd_211[i]+Qd_001[i]*Qd_111[i]+aQin1*Qd_011[i]; } for(int i=0;i<3;i++){ Qd_212[i]=Qd_001[i]*Qd_211[i]+aQin1*Qd_111[i]; } for(int i=0;i<3;i++){ Qd_312[i]=aQin1*Qd_211[i]; } for(int i=0;i<3;i++){ Qd_020[i]=Qd_110[i]+Qd_010[i]*Qd_010[i]; } for(int i=0;i<3;i++){ Qd_120[i]=Qd_010[i]*Qd_110[i]+aQin1*Qd_010[i]; } for(int i=0;i<3;i++){ Qd_220[i]=aQin1*Qd_110[i]; } for(int i=0;i<3;i++){ Qd_021[i]=Qd_111[i]+Qd_010[i]*Qd_011[i]; } for(int i=0;i<3;i++){ Qd_121[i]=2*Qd_211[i]+Qd_010[i]*Qd_111[i]+aQin1*Qd_011[i]; } for(int i=0;i<3;i++){ Qd_221[i]=Qd_010[i]*Qd_211[i]+aQin1*Qd_111[i]; } for(int i=0;i<3;i++){ Qd_321[i]=aQin1*Qd_211[i]; } for(int i=0;i<3;i++){ Qd_022[i]=Qd_112[i]+Qd_010[i]*Qd_012[i]; } for(int i=0;i<3;i++){ Qd_122[i]=2*Qd_212[i]+Qd_010[i]*Qd_112[i]+aQin1*Qd_012[i]; } for(int i=0;i<3;i++){ Qd_222[i]=3*Qd_312[i]+Qd_010[i]*Qd_212[i]+aQin1*Qd_112[i]; } for(int i=0;i<3;i++){ Qd_322[i]=Qd_010[i]*Qd_312[i]+aQin1*Qd_212[i]; } for(int i=0;i<3;i++){ Qd_422[i]=aQin1*Qd_312[i]; } double Q_022000000=Qd_022[0]; double Q_122000000=Qd_122[0]; double Q_222000000=Qd_222[0]; double Q_322000000=Qd_322[0]; double Q_422000000=Qd_422[0]; double Q_021001000=Qd_021[0]*Qd_001[1]; double Q_021101000=Qd_021[0]*Qd_101[1]; double Q_121001000=Qd_121[0]*Qd_001[1]; double Q_121101000=Qd_121[0]*Qd_101[1]; double Q_221001000=Qd_221[0]*Qd_001[1]; double Q_221101000=Qd_221[0]*Qd_101[1]; double Q_321001000=Qd_321[0]*Qd_001[1]; double Q_321101000=Qd_321[0]*Qd_101[1]; double Q_020002000=Qd_020[0]*Qd_002[1]; double Q_020102000=Qd_020[0]*Qd_102[1]; double Q_020202000=Qd_020[0]*Qd_202[1]; double Q_120002000=Qd_120[0]*Qd_002[1]; double Q_120102000=Qd_120[0]*Qd_102[1]; double Q_120202000=Qd_120[0]*Qd_202[1]; double Q_220002000=Qd_220[0]*Qd_002[1]; double Q_220102000=Qd_220[0]*Qd_102[1]; double Q_220202000=Qd_220[0]*Qd_202[1]; double Q_021000001=Qd_021[0]*Qd_001[2]; double Q_021000101=Qd_021[0]*Qd_101[2]; double Q_121000001=Qd_121[0]*Qd_001[2]; double Q_121000101=Qd_121[0]*Qd_101[2]; double Q_221000001=Qd_221[0]*Qd_001[2]; double Q_221000101=Qd_221[0]*Qd_101[2]; double Q_321000001=Qd_321[0]*Qd_001[2]; double Q_321000101=Qd_321[0]*Qd_101[2]; double Q_020001001=Qd_020[0]*Qd_001[1]*Qd_001[2]; double Q_020001101=Qd_020[0]*Qd_001[1]*Qd_101[2]; double Q_020101001=Qd_020[0]*Qd_101[1]*Qd_001[2]; double Q_020101101=Qd_020[0]*Qd_101[1]*Qd_101[2]; double Q_120001001=Qd_120[0]*Qd_001[1]*Qd_001[2]; double Q_120001101=Qd_120[0]*Qd_001[1]*Qd_101[2]; double Q_120101001=Qd_120[0]*Qd_101[1]*Qd_001[2]; double Q_120101101=Qd_120[0]*Qd_101[1]*Qd_101[2]; double Q_220001001=Qd_220[0]*Qd_001[1]*Qd_001[2]; double Q_220001101=Qd_220[0]*Qd_001[1]*Qd_101[2]; double Q_220101001=Qd_220[0]*Qd_101[1]*Qd_001[2]; double Q_220101101=Qd_220[0]*Qd_101[1]*Qd_101[2]; double Q_020000002=Qd_020[0]*Qd_002[2]; double Q_020000102=Qd_020[0]*Qd_102[2]; double Q_020000202=Qd_020[0]*Qd_202[2]; double Q_120000002=Qd_120[0]*Qd_002[2]; double Q_120000102=Qd_120[0]*Qd_102[2]; double Q_120000202=Qd_120[0]*Qd_202[2]; double Q_220000002=Qd_220[0]*Qd_002[2]; double Q_220000102=Qd_220[0]*Qd_102[2]; double Q_220000202=Qd_220[0]*Qd_202[2]; double Q_012010000=Qd_012[0]*Qd_010[1]; double Q_012110000=Qd_012[0]*Qd_110[1]; double Q_112010000=Qd_112[0]*Qd_010[1]; double Q_112110000=Qd_112[0]*Qd_110[1]; double Q_212010000=Qd_212[0]*Qd_010[1]; double Q_212110000=Qd_212[0]*Qd_110[1]; double Q_312010000=Qd_312[0]*Qd_010[1]; double Q_312110000=Qd_312[0]*Qd_110[1]; double Q_011011000=Qd_011[0]*Qd_011[1]; double Q_011111000=Qd_011[0]*Qd_111[1]; double Q_011211000=Qd_011[0]*Qd_211[1]; double Q_111011000=Qd_111[0]*Qd_011[1]; double Q_111111000=Qd_111[0]*Qd_111[1]; double Q_111211000=Qd_111[0]*Qd_211[1]; double Q_211011000=Qd_211[0]*Qd_011[1]; double Q_211111000=Qd_211[0]*Qd_111[1]; double Q_211211000=Qd_211[0]*Qd_211[1]; double Q_010012000=Qd_010[0]*Qd_012[1]; double Q_010112000=Qd_010[0]*Qd_112[1]; double Q_010212000=Qd_010[0]*Qd_212[1]; double Q_010312000=Qd_010[0]*Qd_312[1]; double Q_110012000=Qd_110[0]*Qd_012[1]; double Q_110112000=Qd_110[0]*Qd_112[1]; double Q_110212000=Qd_110[0]*Qd_212[1]; double Q_110312000=Qd_110[0]*Qd_312[1]; double Q_011010001=Qd_011[0]*Qd_010[1]*Qd_001[2]; double Q_011010101=Qd_011[0]*Qd_010[1]*Qd_101[2]; double Q_011110001=Qd_011[0]*Qd_110[1]*Qd_001[2]; double Q_011110101=Qd_011[0]*Qd_110[1]*Qd_101[2]; double Q_111010001=Qd_111[0]*Qd_010[1]*Qd_001[2]; double Q_111010101=Qd_111[0]*Qd_010[1]*Qd_101[2]; double Q_111110001=Qd_111[0]*Qd_110[1]*Qd_001[2]; double Q_111110101=Qd_111[0]*Qd_110[1]*Qd_101[2]; double Q_211010001=Qd_211[0]*Qd_010[1]*Qd_001[2]; double Q_211010101=Qd_211[0]*Qd_010[1]*Qd_101[2]; double Q_211110001=Qd_211[0]*Qd_110[1]*Qd_001[2]; double Q_211110101=Qd_211[0]*Qd_110[1]*Qd_101[2]; double Q_010011001=Qd_010[0]*Qd_011[1]*Qd_001[2]; double Q_010011101=Qd_010[0]*Qd_011[1]*Qd_101[2]; double Q_010111001=Qd_010[0]*Qd_111[1]*Qd_001[2]; double Q_010111101=Qd_010[0]*Qd_111[1]*Qd_101[2]; double Q_010211001=Qd_010[0]*Qd_211[1]*Qd_001[2]; double Q_010211101=Qd_010[0]*Qd_211[1]*Qd_101[2]; double Q_110011001=Qd_110[0]*Qd_011[1]*Qd_001[2]; double Q_110011101=Qd_110[0]*Qd_011[1]*Qd_101[2]; double Q_110111001=Qd_110[0]*Qd_111[1]*Qd_001[2]; double Q_110111101=Qd_110[0]*Qd_111[1]*Qd_101[2]; double Q_110211001=Qd_110[0]*Qd_211[1]*Qd_001[2]; double Q_110211101=Qd_110[0]*Qd_211[1]*Qd_101[2]; double Q_010010002=Qd_010[0]*Qd_010[1]*Qd_002[2]; double Q_010010102=Qd_010[0]*Qd_010[1]*Qd_102[2]; double Q_010010202=Qd_010[0]*Qd_010[1]*Qd_202[2]; double Q_010110002=Qd_010[0]*Qd_110[1]*Qd_002[2]; double Q_010110102=Qd_010[0]*Qd_110[1]*Qd_102[2]; double Q_010110202=Qd_010[0]*Qd_110[1]*Qd_202[2]; double Q_110010002=Qd_110[0]*Qd_010[1]*Qd_002[2]; double Q_110010102=Qd_110[0]*Qd_010[1]*Qd_102[2]; double Q_110010202=Qd_110[0]*Qd_010[1]*Qd_202[2]; double Q_110110002=Qd_110[0]*Qd_110[1]*Qd_002[2]; double Q_110110102=Qd_110[0]*Qd_110[1]*Qd_102[2]; double Q_110110202=Qd_110[0]*Qd_110[1]*Qd_202[2]; double Q_002020000=Qd_002[0]*Qd_020[1]; double Q_002120000=Qd_002[0]*Qd_120[1]; double Q_002220000=Qd_002[0]*Qd_220[1]; double Q_102020000=Qd_102[0]*Qd_020[1]; double Q_102120000=Qd_102[0]*Qd_120[1]; double Q_102220000=Qd_102[0]*Qd_220[1]; double Q_202020000=Qd_202[0]*Qd_020[1]; double Q_202120000=Qd_202[0]*Qd_120[1]; double Q_202220000=Qd_202[0]*Qd_220[1]; double Q_001021000=Qd_001[0]*Qd_021[1]; double Q_001121000=Qd_001[0]*Qd_121[1]; double Q_001221000=Qd_001[0]*Qd_221[1]; double Q_001321000=Qd_001[0]*Qd_321[1]; double Q_101021000=Qd_101[0]*Qd_021[1]; double Q_101121000=Qd_101[0]*Qd_121[1]; double Q_101221000=Qd_101[0]*Qd_221[1]; double Q_101321000=Qd_101[0]*Qd_321[1]; double Q_000022000=Qd_022[1]; double Q_000122000=Qd_122[1]; double Q_000222000=Qd_222[1]; double Q_000322000=Qd_322[1]; double Q_000422000=Qd_422[1]; double Q_001020001=Qd_001[0]*Qd_020[1]*Qd_001[2]; double Q_001020101=Qd_001[0]*Qd_020[1]*Qd_101[2]; double Q_001120001=Qd_001[0]*Qd_120[1]*Qd_001[2]; double Q_001120101=Qd_001[0]*Qd_120[1]*Qd_101[2]; double Q_001220001=Qd_001[0]*Qd_220[1]*Qd_001[2]; double Q_001220101=Qd_001[0]*Qd_220[1]*Qd_101[2]; double Q_101020001=Qd_101[0]*Qd_020[1]*Qd_001[2]; double Q_101020101=Qd_101[0]*Qd_020[1]*Qd_101[2]; double Q_101120001=Qd_101[0]*Qd_120[1]*Qd_001[2]; double Q_101120101=Qd_101[0]*Qd_120[1]*Qd_101[2]; double Q_101220001=Qd_101[0]*Qd_220[1]*Qd_001[2]; double Q_101220101=Qd_101[0]*Qd_220[1]*Qd_101[2]; double Q_000021001=Qd_021[1]*Qd_001[2]; double Q_000021101=Qd_021[1]*Qd_101[2]; double Q_000121001=Qd_121[1]*Qd_001[2]; double Q_000121101=Qd_121[1]*Qd_101[2]; double Q_000221001=Qd_221[1]*Qd_001[2]; double Q_000221101=Qd_221[1]*Qd_101[2]; double Q_000321001=Qd_321[1]*Qd_001[2]; double Q_000321101=Qd_321[1]*Qd_101[2]; double Q_000020002=Qd_020[1]*Qd_002[2]; double Q_000020102=Qd_020[1]*Qd_102[2]; double Q_000020202=Qd_020[1]*Qd_202[2]; double Q_000120002=Qd_120[1]*Qd_002[2]; double Q_000120102=Qd_120[1]*Qd_102[2]; double Q_000120202=Qd_120[1]*Qd_202[2]; double Q_000220002=Qd_220[1]*Qd_002[2]; double Q_000220102=Qd_220[1]*Qd_102[2]; double Q_000220202=Qd_220[1]*Qd_202[2]; double Q_012000010=Qd_012[0]*Qd_010[2]; double Q_012000110=Qd_012[0]*Qd_110[2]; double Q_112000010=Qd_112[0]*Qd_010[2]; double Q_112000110=Qd_112[0]*Qd_110[2]; double Q_212000010=Qd_212[0]*Qd_010[2]; double Q_212000110=Qd_212[0]*Qd_110[2]; double Q_312000010=Qd_312[0]*Qd_010[2]; double Q_312000110=Qd_312[0]*Qd_110[2]; double Q_011001010=Qd_011[0]*Qd_001[1]*Qd_010[2]; double Q_011001110=Qd_011[0]*Qd_001[1]*Qd_110[2]; double Q_011101010=Qd_011[0]*Qd_101[1]*Qd_010[2]; double Q_011101110=Qd_011[0]*Qd_101[1]*Qd_110[2]; double Q_111001010=Qd_111[0]*Qd_001[1]*Qd_010[2]; double Q_111001110=Qd_111[0]*Qd_001[1]*Qd_110[2]; double Q_111101010=Qd_111[0]*Qd_101[1]*Qd_010[2]; double Q_111101110=Qd_111[0]*Qd_101[1]*Qd_110[2]; double Q_211001010=Qd_211[0]*Qd_001[1]*Qd_010[2]; double Q_211001110=Qd_211[0]*Qd_001[1]*Qd_110[2]; double Q_211101010=Qd_211[0]*Qd_101[1]*Qd_010[2]; double Q_211101110=Qd_211[0]*Qd_101[1]*Qd_110[2]; double Q_010002010=Qd_010[0]*Qd_002[1]*Qd_010[2]; double Q_010002110=Qd_010[0]*Qd_002[1]*Qd_110[2]; double Q_010102010=Qd_010[0]*Qd_102[1]*Qd_010[2]; double Q_010102110=Qd_010[0]*Qd_102[1]*Qd_110[2]; double Q_010202010=Qd_010[0]*Qd_202[1]*Qd_010[2]; double Q_010202110=Qd_010[0]*Qd_202[1]*Qd_110[2]; double Q_110002010=Qd_110[0]*Qd_002[1]*Qd_010[2]; double Q_110002110=Qd_110[0]*Qd_002[1]*Qd_110[2]; double Q_110102010=Qd_110[0]*Qd_102[1]*Qd_010[2]; double Q_110102110=Qd_110[0]*Qd_102[1]*Qd_110[2]; double Q_110202010=Qd_110[0]*Qd_202[1]*Qd_010[2]; double Q_110202110=Qd_110[0]*Qd_202[1]*Qd_110[2]; double Q_011000011=Qd_011[0]*Qd_011[2]; double Q_011000111=Qd_011[0]*Qd_111[2]; double Q_011000211=Qd_011[0]*Qd_211[2]; double Q_111000011=Qd_111[0]*Qd_011[2]; double Q_111000111=Qd_111[0]*Qd_111[2]; double Q_111000211=Qd_111[0]*Qd_211[2]; double Q_211000011=Qd_211[0]*Qd_011[2]; double Q_211000111=Qd_211[0]*Qd_111[2]; double Q_211000211=Qd_211[0]*Qd_211[2]; double Q_010001011=Qd_010[0]*Qd_001[1]*Qd_011[2]; double Q_010001111=Qd_010[0]*Qd_001[1]*Qd_111[2]; double Q_010001211=Qd_010[0]*Qd_001[1]*Qd_211[2]; double Q_010101011=Qd_010[0]*Qd_101[1]*Qd_011[2]; double Q_010101111=Qd_010[0]*Qd_101[1]*Qd_111[2]; double Q_010101211=Qd_010[0]*Qd_101[1]*Qd_211[2]; double Q_110001011=Qd_110[0]*Qd_001[1]*Qd_011[2]; double Q_110001111=Qd_110[0]*Qd_001[1]*Qd_111[2]; double Q_110001211=Qd_110[0]*Qd_001[1]*Qd_211[2]; double Q_110101011=Qd_110[0]*Qd_101[1]*Qd_011[2]; double Q_110101111=Qd_110[0]*Qd_101[1]*Qd_111[2]; double Q_110101211=Qd_110[0]*Qd_101[1]*Qd_211[2]; double Q_010000012=Qd_010[0]*Qd_012[2]; double Q_010000112=Qd_010[0]*Qd_112[2]; double Q_010000212=Qd_010[0]*Qd_212[2]; double Q_010000312=Qd_010[0]*Qd_312[2]; double Q_110000012=Qd_110[0]*Qd_012[2]; double Q_110000112=Qd_110[0]*Qd_112[2]; double Q_110000212=Qd_110[0]*Qd_212[2]; double Q_110000312=Qd_110[0]*Qd_312[2]; double Q_002010010=Qd_002[0]*Qd_010[1]*Qd_010[2]; double Q_002010110=Qd_002[0]*Qd_010[1]*Qd_110[2]; double Q_002110010=Qd_002[0]*Qd_110[1]*Qd_010[2]; double Q_002110110=Qd_002[0]*Qd_110[1]*Qd_110[2]; double Q_102010010=Qd_102[0]*Qd_010[1]*Qd_010[2]; double Q_102010110=Qd_102[0]*Qd_010[1]*Qd_110[2]; double Q_102110010=Qd_102[0]*Qd_110[1]*Qd_010[2]; double Q_102110110=Qd_102[0]*Qd_110[1]*Qd_110[2]; double Q_202010010=Qd_202[0]*Qd_010[1]*Qd_010[2]; double Q_202010110=Qd_202[0]*Qd_010[1]*Qd_110[2]; double Q_202110010=Qd_202[0]*Qd_110[1]*Qd_010[2]; double Q_202110110=Qd_202[0]*Qd_110[1]*Qd_110[2]; double Q_001011010=Qd_001[0]*Qd_011[1]*Qd_010[2]; double Q_001011110=Qd_001[0]*Qd_011[1]*Qd_110[2]; double Q_001111010=Qd_001[0]*Qd_111[1]*Qd_010[2]; double Q_001111110=Qd_001[0]*Qd_111[1]*Qd_110[2]; double Q_001211010=Qd_001[0]*Qd_211[1]*Qd_010[2]; double Q_001211110=Qd_001[0]*Qd_211[1]*Qd_110[2]; double Q_101011010=Qd_101[0]*Qd_011[1]*Qd_010[2]; double Q_101011110=Qd_101[0]*Qd_011[1]*Qd_110[2]; double Q_101111010=Qd_101[0]*Qd_111[1]*Qd_010[2]; double Q_101111110=Qd_101[0]*Qd_111[1]*Qd_110[2]; double Q_101211010=Qd_101[0]*Qd_211[1]*Qd_010[2]; double Q_101211110=Qd_101[0]*Qd_211[1]*Qd_110[2]; double Q_000012010=Qd_012[1]*Qd_010[2]; double Q_000012110=Qd_012[1]*Qd_110[2]; double Q_000112010=Qd_112[1]*Qd_010[2]; double Q_000112110=Qd_112[1]*Qd_110[2]; double Q_000212010=Qd_212[1]*Qd_010[2]; double Q_000212110=Qd_212[1]*Qd_110[2]; double Q_000312010=Qd_312[1]*Qd_010[2]; double Q_000312110=Qd_312[1]*Qd_110[2]; double Q_001010011=Qd_001[0]*Qd_010[1]*Qd_011[2]; double Q_001010111=Qd_001[0]*Qd_010[1]*Qd_111[2]; double Q_001010211=Qd_001[0]*Qd_010[1]*Qd_211[2]; double Q_001110011=Qd_001[0]*Qd_110[1]*Qd_011[2]; double Q_001110111=Qd_001[0]*Qd_110[1]*Qd_111[2]; double Q_001110211=Qd_001[0]*Qd_110[1]*Qd_211[2]; double Q_101010011=Qd_101[0]*Qd_010[1]*Qd_011[2]; double Q_101010111=Qd_101[0]*Qd_010[1]*Qd_111[2]; double Q_101010211=Qd_101[0]*Qd_010[1]*Qd_211[2]; double Q_101110011=Qd_101[0]*Qd_110[1]*Qd_011[2]; double Q_101110111=Qd_101[0]*Qd_110[1]*Qd_111[2]; double Q_101110211=Qd_101[0]*Qd_110[1]*Qd_211[2]; double Q_000011011=Qd_011[1]*Qd_011[2]; double Q_000011111=Qd_011[1]*Qd_111[2]; double Q_000011211=Qd_011[1]*Qd_211[2]; double Q_000111011=Qd_111[1]*Qd_011[2]; double Q_000111111=Qd_111[1]*Qd_111[2]; double Q_000111211=Qd_111[1]*Qd_211[2]; double Q_000211011=Qd_211[1]*Qd_011[2]; double Q_000211111=Qd_211[1]*Qd_111[2]; double Q_000211211=Qd_211[1]*Qd_211[2]; double Q_000010012=Qd_010[1]*Qd_012[2]; double Q_000010112=Qd_010[1]*Qd_112[2]; double Q_000010212=Qd_010[1]*Qd_212[2]; double Q_000010312=Qd_010[1]*Qd_312[2]; double Q_000110012=Qd_110[1]*Qd_012[2]; double Q_000110112=Qd_110[1]*Qd_112[2]; double Q_000110212=Qd_110[1]*Qd_212[2]; double Q_000110312=Qd_110[1]*Qd_312[2]; double Q_002000020=Qd_002[0]*Qd_020[2]; double Q_002000120=Qd_002[0]*Qd_120[2]; double Q_002000220=Qd_002[0]*Qd_220[2]; double Q_102000020=Qd_102[0]*Qd_020[2]; double Q_102000120=Qd_102[0]*Qd_120[2]; double Q_102000220=Qd_102[0]*Qd_220[2]; double Q_202000020=Qd_202[0]*Qd_020[2]; double Q_202000120=Qd_202[0]*Qd_120[2]; double Q_202000220=Qd_202[0]*Qd_220[2]; double Q_001001020=Qd_001[0]*Qd_001[1]*Qd_020[2]; double Q_001001120=Qd_001[0]*Qd_001[1]*Qd_120[2]; double Q_001001220=Qd_001[0]*Qd_001[1]*Qd_220[2]; double Q_001101020=Qd_001[0]*Qd_101[1]*Qd_020[2]; double Q_001101120=Qd_001[0]*Qd_101[1]*Qd_120[2]; double Q_001101220=Qd_001[0]*Qd_101[1]*Qd_220[2]; double Q_101001020=Qd_101[0]*Qd_001[1]*Qd_020[2]; double Q_101001120=Qd_101[0]*Qd_001[1]*Qd_120[2]; double Q_101001220=Qd_101[0]*Qd_001[1]*Qd_220[2]; double Q_101101020=Qd_101[0]*Qd_101[1]*Qd_020[2]; double Q_101101120=Qd_101[0]*Qd_101[1]*Qd_120[2]; double Q_101101220=Qd_101[0]*Qd_101[1]*Qd_220[2]; double Q_000002020=Qd_002[1]*Qd_020[2]; double Q_000002120=Qd_002[1]*Qd_120[2]; double Q_000002220=Qd_002[1]*Qd_220[2]; double Q_000102020=Qd_102[1]*Qd_020[2]; double Q_000102120=Qd_102[1]*Qd_120[2]; double Q_000102220=Qd_102[1]*Qd_220[2]; double Q_000202020=Qd_202[1]*Qd_020[2]; double Q_000202120=Qd_202[1]*Qd_120[2]; double Q_000202220=Qd_202[1]*Qd_220[2]; double Q_001000021=Qd_001[0]*Qd_021[2]; double Q_001000121=Qd_001[0]*Qd_121[2]; double Q_001000221=Qd_001[0]*Qd_221[2]; double Q_001000321=Qd_001[0]*Qd_321[2]; double Q_101000021=Qd_101[0]*Qd_021[2]; double Q_101000121=Qd_101[0]*Qd_121[2]; double Q_101000221=Qd_101[0]*Qd_221[2]; double Q_101000321=Qd_101[0]*Qd_321[2]; double Q_000001021=Qd_001[1]*Qd_021[2]; double Q_000001121=Qd_001[1]*Qd_121[2]; double Q_000001221=Qd_001[1]*Qd_221[2]; double Q_000001321=Qd_001[1]*Qd_321[2]; double Q_000101021=Qd_101[1]*Qd_021[2]; double Q_000101121=Qd_101[1]*Qd_121[2]; double Q_000101221=Qd_101[1]*Qd_221[2]; double Q_000101321=Qd_101[1]*Qd_321[2]; double Q_000000022=Qd_022[2]; double Q_000000122=Qd_122[2]; double Q_000000222=Qd_222[2]; double Q_000000322=Qd_322[2]; double Q_000000422=Qd_422[2]; ans_temp[ans_id*36+0]+=Pmtrx[0]*(Q_022000000*PR_022000000000+Q_122000000*PR_022000000100+Q_222000000*PR_022000000200+Q_322000000*PR_022000000300+Q_422000000*PR_022000000400); ans_temp[ans_id*36+0]+=Pmtrx[1]*(Q_021001000*PR_022000000000+Q_021101000*PR_022000000010+Q_121001000*PR_022000000100+Q_121101000*PR_022000000110+Q_221001000*PR_022000000200+Q_221101000*PR_022000000210+Q_321001000*PR_022000000300+Q_321101000*PR_022000000310); ans_temp[ans_id*36+0]+=Pmtrx[2]*(Q_020002000*PR_022000000000+Q_020102000*PR_022000000010+Q_020202000*PR_022000000020+Q_120002000*PR_022000000100+Q_120102000*PR_022000000110+Q_120202000*PR_022000000120+Q_220002000*PR_022000000200+Q_220102000*PR_022000000210+Q_220202000*PR_022000000220); ans_temp[ans_id*36+0]+=Pmtrx[3]*(Q_021000001*PR_022000000000+Q_021000101*PR_022000000001+Q_121000001*PR_022000000100+Q_121000101*PR_022000000101+Q_221000001*PR_022000000200+Q_221000101*PR_022000000201+Q_321000001*PR_022000000300+Q_321000101*PR_022000000301); ans_temp[ans_id*36+0]+=Pmtrx[4]*(Q_020001001*PR_022000000000+Q_020001101*PR_022000000001+Q_020101001*PR_022000000010+Q_020101101*PR_022000000011+Q_120001001*PR_022000000100+Q_120001101*PR_022000000101+Q_120101001*PR_022000000110+Q_120101101*PR_022000000111+Q_220001001*PR_022000000200+Q_220001101*PR_022000000201+Q_220101001*PR_022000000210+Q_220101101*PR_022000000211); ans_temp[ans_id*36+0]+=Pmtrx[5]*(Q_020000002*PR_022000000000+Q_020000102*PR_022000000001+Q_020000202*PR_022000000002+Q_120000002*PR_022000000100+Q_120000102*PR_022000000101+Q_120000202*PR_022000000102+Q_220000002*PR_022000000200+Q_220000102*PR_022000000201+Q_220000202*PR_022000000202); ans_temp[ans_id*36+1]+=Pmtrx[0]*(Q_012010000*PR_022000000000+Q_012110000*PR_022000000010+Q_112010000*PR_022000000100+Q_112110000*PR_022000000110+Q_212010000*PR_022000000200+Q_212110000*PR_022000000210+Q_312010000*PR_022000000300+Q_312110000*PR_022000000310); ans_temp[ans_id*36+1]+=Pmtrx[1]*(Q_011011000*PR_022000000000+Q_011111000*PR_022000000010+Q_011211000*PR_022000000020+Q_111011000*PR_022000000100+Q_111111000*PR_022000000110+Q_111211000*PR_022000000120+Q_211011000*PR_022000000200+Q_211111000*PR_022000000210+Q_211211000*PR_022000000220); ans_temp[ans_id*36+1]+=Pmtrx[2]*(Q_010012000*PR_022000000000+Q_010112000*PR_022000000010+Q_010212000*PR_022000000020+Q_010312000*PR_022000000030+Q_110012000*PR_022000000100+Q_110112000*PR_022000000110+Q_110212000*PR_022000000120+Q_110312000*PR_022000000130); ans_temp[ans_id*36+1]+=Pmtrx[3]*(Q_011010001*PR_022000000000+Q_011010101*PR_022000000001+Q_011110001*PR_022000000010+Q_011110101*PR_022000000011+Q_111010001*PR_022000000100+Q_111010101*PR_022000000101+Q_111110001*PR_022000000110+Q_111110101*PR_022000000111+Q_211010001*PR_022000000200+Q_211010101*PR_022000000201+Q_211110001*PR_022000000210+Q_211110101*PR_022000000211); ans_temp[ans_id*36+1]+=Pmtrx[4]*(Q_010011001*PR_022000000000+Q_010011101*PR_022000000001+Q_010111001*PR_022000000010+Q_010111101*PR_022000000011+Q_010211001*PR_022000000020+Q_010211101*PR_022000000021+Q_110011001*PR_022000000100+Q_110011101*PR_022000000101+Q_110111001*PR_022000000110+Q_110111101*PR_022000000111+Q_110211001*PR_022000000120+Q_110211101*PR_022000000121); ans_temp[ans_id*36+1]+=Pmtrx[5]*(Q_010010002*PR_022000000000+Q_010010102*PR_022000000001+Q_010010202*PR_022000000002+Q_010110002*PR_022000000010+Q_010110102*PR_022000000011+Q_010110202*PR_022000000012+Q_110010002*PR_022000000100+Q_110010102*PR_022000000101+Q_110010202*PR_022000000102+Q_110110002*PR_022000000110+Q_110110102*PR_022000000111+Q_110110202*PR_022000000112); ans_temp[ans_id*36+2]+=Pmtrx[0]*(Q_002020000*PR_022000000000+Q_002120000*PR_022000000010+Q_002220000*PR_022000000020+Q_102020000*PR_022000000100+Q_102120000*PR_022000000110+Q_102220000*PR_022000000120+Q_202020000*PR_022000000200+Q_202120000*PR_022000000210+Q_202220000*PR_022000000220); ans_temp[ans_id*36+2]+=Pmtrx[1]*(Q_001021000*PR_022000000000+Q_001121000*PR_022000000010+Q_001221000*PR_022000000020+Q_001321000*PR_022000000030+Q_101021000*PR_022000000100+Q_101121000*PR_022000000110+Q_101221000*PR_022000000120+Q_101321000*PR_022000000130); ans_temp[ans_id*36+2]+=Pmtrx[2]*(Q_000022000*PR_022000000000+Q_000122000*PR_022000000010+Q_000222000*PR_022000000020+Q_000322000*PR_022000000030+Q_000422000*PR_022000000040); ans_temp[ans_id*36+2]+=Pmtrx[3]*(Q_001020001*PR_022000000000+Q_001020101*PR_022000000001+Q_001120001*PR_022000000010+Q_001120101*PR_022000000011+Q_001220001*PR_022000000020+Q_001220101*PR_022000000021+Q_101020001*PR_022000000100+Q_101020101*PR_022000000101+Q_101120001*PR_022000000110+Q_101120101*PR_022000000111+Q_101220001*PR_022000000120+Q_101220101*PR_022000000121); ans_temp[ans_id*36+2]+=Pmtrx[4]*(Q_000021001*PR_022000000000+Q_000021101*PR_022000000001+Q_000121001*PR_022000000010+Q_000121101*PR_022000000011+Q_000221001*PR_022000000020+Q_000221101*PR_022000000021+Q_000321001*PR_022000000030+Q_000321101*PR_022000000031); ans_temp[ans_id*36+2]+=Pmtrx[5]*(Q_000020002*PR_022000000000+Q_000020102*PR_022000000001+Q_000020202*PR_022000000002+Q_000120002*PR_022000000010+Q_000120102*PR_022000000011+Q_000120202*PR_022000000012+Q_000220002*PR_022000000020+Q_000220102*PR_022000000021+Q_000220202*PR_022000000022); ans_temp[ans_id*36+3]+=Pmtrx[0]*(Q_012000010*PR_022000000000+Q_012000110*PR_022000000001+Q_112000010*PR_022000000100+Q_112000110*PR_022000000101+Q_212000010*PR_022000000200+Q_212000110*PR_022000000201+Q_312000010*PR_022000000300+Q_312000110*PR_022000000301); ans_temp[ans_id*36+3]+=Pmtrx[1]*(Q_011001010*PR_022000000000+Q_011001110*PR_022000000001+Q_011101010*PR_022000000010+Q_011101110*PR_022000000011+Q_111001010*PR_022000000100+Q_111001110*PR_022000000101+Q_111101010*PR_022000000110+Q_111101110*PR_022000000111+Q_211001010*PR_022000000200+Q_211001110*PR_022000000201+Q_211101010*PR_022000000210+Q_211101110*PR_022000000211); ans_temp[ans_id*36+3]+=Pmtrx[2]*(Q_010002010*PR_022000000000+Q_010002110*PR_022000000001+Q_010102010*PR_022000000010+Q_010102110*PR_022000000011+Q_010202010*PR_022000000020+Q_010202110*PR_022000000021+Q_110002010*PR_022000000100+Q_110002110*PR_022000000101+Q_110102010*PR_022000000110+Q_110102110*PR_022000000111+Q_110202010*PR_022000000120+Q_110202110*PR_022000000121); ans_temp[ans_id*36+3]+=Pmtrx[3]*(Q_011000011*PR_022000000000+Q_011000111*PR_022000000001+Q_011000211*PR_022000000002+Q_111000011*PR_022000000100+Q_111000111*PR_022000000101+Q_111000211*PR_022000000102+Q_211000011*PR_022000000200+Q_211000111*PR_022000000201+Q_211000211*PR_022000000202); ans_temp[ans_id*36+3]+=Pmtrx[4]*(Q_010001011*PR_022000000000+Q_010001111*PR_022000000001+Q_010001211*PR_022000000002+Q_010101011*PR_022000000010+Q_010101111*PR_022000000011+Q_010101211*PR_022000000012+Q_110001011*PR_022000000100+Q_110001111*PR_022000000101+Q_110001211*PR_022000000102+Q_110101011*PR_022000000110+Q_110101111*PR_022000000111+Q_110101211*PR_022000000112); ans_temp[ans_id*36+3]+=Pmtrx[5]*(Q_010000012*PR_022000000000+Q_010000112*PR_022000000001+Q_010000212*PR_022000000002+Q_010000312*PR_022000000003+Q_110000012*PR_022000000100+Q_110000112*PR_022000000101+Q_110000212*PR_022000000102+Q_110000312*PR_022000000103); ans_temp[ans_id*36+4]+=Pmtrx[0]*(Q_002010010*PR_022000000000+Q_002010110*PR_022000000001+Q_002110010*PR_022000000010+Q_002110110*PR_022000000011+Q_102010010*PR_022000000100+Q_102010110*PR_022000000101+Q_102110010*PR_022000000110+Q_102110110*PR_022000000111+Q_202010010*PR_022000000200+Q_202010110*PR_022000000201+Q_202110010*PR_022000000210+Q_202110110*PR_022000000211); ans_temp[ans_id*36+4]+=Pmtrx[1]*(Q_001011010*PR_022000000000+Q_001011110*PR_022000000001+Q_001111010*PR_022000000010+Q_001111110*PR_022000000011+Q_001211010*PR_022000000020+Q_001211110*PR_022000000021+Q_101011010*PR_022000000100+Q_101011110*PR_022000000101+Q_101111010*PR_022000000110+Q_101111110*PR_022000000111+Q_101211010*PR_022000000120+Q_101211110*PR_022000000121); ans_temp[ans_id*36+4]+=Pmtrx[2]*(Q_000012010*PR_022000000000+Q_000012110*PR_022000000001+Q_000112010*PR_022000000010+Q_000112110*PR_022000000011+Q_000212010*PR_022000000020+Q_000212110*PR_022000000021+Q_000312010*PR_022000000030+Q_000312110*PR_022000000031); ans_temp[ans_id*36+4]+=Pmtrx[3]*(Q_001010011*PR_022000000000+Q_001010111*PR_022000000001+Q_001010211*PR_022000000002+Q_001110011*PR_022000000010+Q_001110111*PR_022000000011+Q_001110211*PR_022000000012+Q_101010011*PR_022000000100+Q_101010111*PR_022000000101+Q_101010211*PR_022000000102+Q_101110011*PR_022000000110+Q_101110111*PR_022000000111+Q_101110211*PR_022000000112); ans_temp[ans_id*36+4]+=Pmtrx[4]*(Q_000011011*PR_022000000000+Q_000011111*PR_022000000001+Q_000011211*PR_022000000002+Q_000111011*PR_022000000010+Q_000111111*PR_022000000011+Q_000111211*PR_022000000012+Q_000211011*PR_022000000020+Q_000211111*PR_022000000021+Q_000211211*PR_022000000022); ans_temp[ans_id*36+4]+=Pmtrx[5]*(Q_000010012*PR_022000000000+Q_000010112*PR_022000000001+Q_000010212*PR_022000000002+Q_000010312*PR_022000000003+Q_000110012*PR_022000000010+Q_000110112*PR_022000000011+Q_000110212*PR_022000000012+Q_000110312*PR_022000000013); ans_temp[ans_id*36+5]+=Pmtrx[0]*(Q_002000020*PR_022000000000+Q_002000120*PR_022000000001+Q_002000220*PR_022000000002+Q_102000020*PR_022000000100+Q_102000120*PR_022000000101+Q_102000220*PR_022000000102+Q_202000020*PR_022000000200+Q_202000120*PR_022000000201+Q_202000220*PR_022000000202); ans_temp[ans_id*36+5]+=Pmtrx[1]*(Q_001001020*PR_022000000000+Q_001001120*PR_022000000001+Q_001001220*PR_022000000002+Q_001101020*PR_022000000010+Q_001101120*PR_022000000011+Q_001101220*PR_022000000012+Q_101001020*PR_022000000100+Q_101001120*PR_022000000101+Q_101001220*PR_022000000102+Q_101101020*PR_022000000110+Q_101101120*PR_022000000111+Q_101101220*PR_022000000112); ans_temp[ans_id*36+5]+=Pmtrx[2]*(Q_000002020*PR_022000000000+Q_000002120*PR_022000000001+Q_000002220*PR_022000000002+Q_000102020*PR_022000000010+Q_000102120*PR_022000000011+Q_000102220*PR_022000000012+Q_000202020*PR_022000000020+Q_000202120*PR_022000000021+Q_000202220*PR_022000000022); ans_temp[ans_id*36+5]+=Pmtrx[3]*(Q_001000021*PR_022000000000+Q_001000121*PR_022000000001+Q_001000221*PR_022000000002+Q_001000321*PR_022000000003+Q_101000021*PR_022000000100+Q_101000121*PR_022000000101+Q_101000221*PR_022000000102+Q_101000321*PR_022000000103); ans_temp[ans_id*36+5]+=Pmtrx[4]*(Q_000001021*PR_022000000000+Q_000001121*PR_022000000001+Q_000001221*PR_022000000002+Q_000001321*PR_022000000003+Q_000101021*PR_022000000010+Q_000101121*PR_022000000011+Q_000101221*PR_022000000012+Q_000101321*PR_022000000013); ans_temp[ans_id*36+5]+=Pmtrx[5]*(Q_000000022*PR_022000000000+Q_000000122*PR_022000000001+Q_000000222*PR_022000000002+Q_000000322*PR_022000000003+Q_000000422*PR_022000000004); ans_temp[ans_id*36+0]+=Pmtrx[6]*(Q_022000000*PR_021001000000+Q_122000000*PR_021001000100+Q_222000000*PR_021001000200+Q_322000000*PR_021001000300+Q_422000000*PR_021001000400); ans_temp[ans_id*36+0]+=Pmtrx[7]*(Q_021001000*PR_021001000000+Q_021101000*PR_021001000010+Q_121001000*PR_021001000100+Q_121101000*PR_021001000110+Q_221001000*PR_021001000200+Q_221101000*PR_021001000210+Q_321001000*PR_021001000300+Q_321101000*PR_021001000310); ans_temp[ans_id*36+0]+=Pmtrx[8]*(Q_020002000*PR_021001000000+Q_020102000*PR_021001000010+Q_020202000*PR_021001000020+Q_120002000*PR_021001000100+Q_120102000*PR_021001000110+Q_120202000*PR_021001000120+Q_220002000*PR_021001000200+Q_220102000*PR_021001000210+Q_220202000*PR_021001000220); ans_temp[ans_id*36+0]+=Pmtrx[9]*(Q_021000001*PR_021001000000+Q_021000101*PR_021001000001+Q_121000001*PR_021001000100+Q_121000101*PR_021001000101+Q_221000001*PR_021001000200+Q_221000101*PR_021001000201+Q_321000001*PR_021001000300+Q_321000101*PR_021001000301); ans_temp[ans_id*36+0]+=Pmtrx[10]*(Q_020001001*PR_021001000000+Q_020001101*PR_021001000001+Q_020101001*PR_021001000010+Q_020101101*PR_021001000011+Q_120001001*PR_021001000100+Q_120001101*PR_021001000101+Q_120101001*PR_021001000110+Q_120101101*PR_021001000111+Q_220001001*PR_021001000200+Q_220001101*PR_021001000201+Q_220101001*PR_021001000210+Q_220101101*PR_021001000211); ans_temp[ans_id*36+0]+=Pmtrx[11]*(Q_020000002*PR_021001000000+Q_020000102*PR_021001000001+Q_020000202*PR_021001000002+Q_120000002*PR_021001000100+Q_120000102*PR_021001000101+Q_120000202*PR_021001000102+Q_220000002*PR_021001000200+Q_220000102*PR_021001000201+Q_220000202*PR_021001000202); ans_temp[ans_id*36+1]+=Pmtrx[6]*(Q_012010000*PR_021001000000+Q_012110000*PR_021001000010+Q_112010000*PR_021001000100+Q_112110000*PR_021001000110+Q_212010000*PR_021001000200+Q_212110000*PR_021001000210+Q_312010000*PR_021001000300+Q_312110000*PR_021001000310); ans_temp[ans_id*36+1]+=Pmtrx[7]*(Q_011011000*PR_021001000000+Q_011111000*PR_021001000010+Q_011211000*PR_021001000020+Q_111011000*PR_021001000100+Q_111111000*PR_021001000110+Q_111211000*PR_021001000120+Q_211011000*PR_021001000200+Q_211111000*PR_021001000210+Q_211211000*PR_021001000220); ans_temp[ans_id*36+1]+=Pmtrx[8]*(Q_010012000*PR_021001000000+Q_010112000*PR_021001000010+Q_010212000*PR_021001000020+Q_010312000*PR_021001000030+Q_110012000*PR_021001000100+Q_110112000*PR_021001000110+Q_110212000*PR_021001000120+Q_110312000*PR_021001000130); ans_temp[ans_id*36+1]+=Pmtrx[9]*(Q_011010001*PR_021001000000+Q_011010101*PR_021001000001+Q_011110001*PR_021001000010+Q_011110101*PR_021001000011+Q_111010001*PR_021001000100+Q_111010101*PR_021001000101+Q_111110001*PR_021001000110+Q_111110101*PR_021001000111+Q_211010001*PR_021001000200+Q_211010101*PR_021001000201+Q_211110001*PR_021001000210+Q_211110101*PR_021001000211); ans_temp[ans_id*36+1]+=Pmtrx[10]*(Q_010011001*PR_021001000000+Q_010011101*PR_021001000001+Q_010111001*PR_021001000010+Q_010111101*PR_021001000011+Q_010211001*PR_021001000020+Q_010211101*PR_021001000021+Q_110011001*PR_021001000100+Q_110011101*PR_021001000101+Q_110111001*PR_021001000110+Q_110111101*PR_021001000111+Q_110211001*PR_021001000120+Q_110211101*PR_021001000121); ans_temp[ans_id*36+1]+=Pmtrx[11]*(Q_010010002*PR_021001000000+Q_010010102*PR_021001000001+Q_010010202*PR_021001000002+Q_010110002*PR_021001000010+Q_010110102*PR_021001000011+Q_010110202*PR_021001000012+Q_110010002*PR_021001000100+Q_110010102*PR_021001000101+Q_110010202*PR_021001000102+Q_110110002*PR_021001000110+Q_110110102*PR_021001000111+Q_110110202*PR_021001000112); ans_temp[ans_id*36+2]+=Pmtrx[6]*(Q_002020000*PR_021001000000+Q_002120000*PR_021001000010+Q_002220000*PR_021001000020+Q_102020000*PR_021001000100+Q_102120000*PR_021001000110+Q_102220000*PR_021001000120+Q_202020000*PR_021001000200+Q_202120000*PR_021001000210+Q_202220000*PR_021001000220); ans_temp[ans_id*36+2]+=Pmtrx[7]*(Q_001021000*PR_021001000000+Q_001121000*PR_021001000010+Q_001221000*PR_021001000020+Q_001321000*PR_021001000030+Q_101021000*PR_021001000100+Q_101121000*PR_021001000110+Q_101221000*PR_021001000120+Q_101321000*PR_021001000130); ans_temp[ans_id*36+2]+=Pmtrx[8]*(Q_000022000*PR_021001000000+Q_000122000*PR_021001000010+Q_000222000*PR_021001000020+Q_000322000*PR_021001000030+Q_000422000*PR_021001000040); ans_temp[ans_id*36+2]+=Pmtrx[9]*(Q_001020001*PR_021001000000+Q_001020101*PR_021001000001+Q_001120001*PR_021001000010+Q_001120101*PR_021001000011+Q_001220001*PR_021001000020+Q_001220101*PR_021001000021+Q_101020001*PR_021001000100+Q_101020101*PR_021001000101+Q_101120001*PR_021001000110+Q_101120101*PR_021001000111+Q_101220001*PR_021001000120+Q_101220101*PR_021001000121); ans_temp[ans_id*36+2]+=Pmtrx[10]*(Q_000021001*PR_021001000000+Q_000021101*PR_021001000001+Q_000121001*PR_021001000010+Q_000121101*PR_021001000011+Q_000221001*PR_021001000020+Q_000221101*PR_021001000021+Q_000321001*PR_021001000030+Q_000321101*PR_021001000031); ans_temp[ans_id*36+2]+=Pmtrx[11]*(Q_000020002*PR_021001000000+Q_000020102*PR_021001000001+Q_000020202*PR_021001000002+Q_000120002*PR_021001000010+Q_000120102*PR_021001000011+Q_000120202*PR_021001000012+Q_000220002*PR_021001000020+Q_000220102*PR_021001000021+Q_000220202*PR_021001000022); ans_temp[ans_id*36+3]+=Pmtrx[6]*(Q_012000010*PR_021001000000+Q_012000110*PR_021001000001+Q_112000010*PR_021001000100+Q_112000110*PR_021001000101+Q_212000010*PR_021001000200+Q_212000110*PR_021001000201+Q_312000010*PR_021001000300+Q_312000110*PR_021001000301); ans_temp[ans_id*36+3]+=Pmtrx[7]*(Q_011001010*PR_021001000000+Q_011001110*PR_021001000001+Q_011101010*PR_021001000010+Q_011101110*PR_021001000011+Q_111001010*PR_021001000100+Q_111001110*PR_021001000101+Q_111101010*PR_021001000110+Q_111101110*PR_021001000111+Q_211001010*PR_021001000200+Q_211001110*PR_021001000201+Q_211101010*PR_021001000210+Q_211101110*PR_021001000211); ans_temp[ans_id*36+3]+=Pmtrx[8]*(Q_010002010*PR_021001000000+Q_010002110*PR_021001000001+Q_010102010*PR_021001000010+Q_010102110*PR_021001000011+Q_010202010*PR_021001000020+Q_010202110*PR_021001000021+Q_110002010*PR_021001000100+Q_110002110*PR_021001000101+Q_110102010*PR_021001000110+Q_110102110*PR_021001000111+Q_110202010*PR_021001000120+Q_110202110*PR_021001000121); ans_temp[ans_id*36+3]+=Pmtrx[9]*(Q_011000011*PR_021001000000+Q_011000111*PR_021001000001+Q_011000211*PR_021001000002+Q_111000011*PR_021001000100+Q_111000111*PR_021001000101+Q_111000211*PR_021001000102+Q_211000011*PR_021001000200+Q_211000111*PR_021001000201+Q_211000211*PR_021001000202); ans_temp[ans_id*36+3]+=Pmtrx[10]*(Q_010001011*PR_021001000000+Q_010001111*PR_021001000001+Q_010001211*PR_021001000002+Q_010101011*PR_021001000010+Q_010101111*PR_021001000011+Q_010101211*PR_021001000012+Q_110001011*PR_021001000100+Q_110001111*PR_021001000101+Q_110001211*PR_021001000102+Q_110101011*PR_021001000110+Q_110101111*PR_021001000111+Q_110101211*PR_021001000112); ans_temp[ans_id*36+3]+=Pmtrx[11]*(Q_010000012*PR_021001000000+Q_010000112*PR_021001000001+Q_010000212*PR_021001000002+Q_010000312*PR_021001000003+Q_110000012*PR_021001000100+Q_110000112*PR_021001000101+Q_110000212*PR_021001000102+Q_110000312*PR_021001000103); ans_temp[ans_id*36+4]+=Pmtrx[6]*(Q_002010010*PR_021001000000+Q_002010110*PR_021001000001+Q_002110010*PR_021001000010+Q_002110110*PR_021001000011+Q_102010010*PR_021001000100+Q_102010110*PR_021001000101+Q_102110010*PR_021001000110+Q_102110110*PR_021001000111+Q_202010010*PR_021001000200+Q_202010110*PR_021001000201+Q_202110010*PR_021001000210+Q_202110110*PR_021001000211); ans_temp[ans_id*36+4]+=Pmtrx[7]*(Q_001011010*PR_021001000000+Q_001011110*PR_021001000001+Q_001111010*PR_021001000010+Q_001111110*PR_021001000011+Q_001211010*PR_021001000020+Q_001211110*PR_021001000021+Q_101011010*PR_021001000100+Q_101011110*PR_021001000101+Q_101111010*PR_021001000110+Q_101111110*PR_021001000111+Q_101211010*PR_021001000120+Q_101211110*PR_021001000121); ans_temp[ans_id*36+4]+=Pmtrx[8]*(Q_000012010*PR_021001000000+Q_000012110*PR_021001000001+Q_000112010*PR_021001000010+Q_000112110*PR_021001000011+Q_000212010*PR_021001000020+Q_000212110*PR_021001000021+Q_000312010*PR_021001000030+Q_000312110*PR_021001000031); ans_temp[ans_id*36+4]+=Pmtrx[9]*(Q_001010011*PR_021001000000+Q_001010111*PR_021001000001+Q_001010211*PR_021001000002+Q_001110011*PR_021001000010+Q_001110111*PR_021001000011+Q_001110211*PR_021001000012+Q_101010011*PR_021001000100+Q_101010111*PR_021001000101+Q_101010211*PR_021001000102+Q_101110011*PR_021001000110+Q_101110111*PR_021001000111+Q_101110211*PR_021001000112); ans_temp[ans_id*36+4]+=Pmtrx[10]*(Q_000011011*PR_021001000000+Q_000011111*PR_021001000001+Q_000011211*PR_021001000002+Q_000111011*PR_021001000010+Q_000111111*PR_021001000011+Q_000111211*PR_021001000012+Q_000211011*PR_021001000020+Q_000211111*PR_021001000021+Q_000211211*PR_021001000022); ans_temp[ans_id*36+4]+=Pmtrx[11]*(Q_000010012*PR_021001000000+Q_000010112*PR_021001000001+Q_000010212*PR_021001000002+Q_000010312*PR_021001000003+Q_000110012*PR_021001000010+Q_000110112*PR_021001000011+Q_000110212*PR_021001000012+Q_000110312*PR_021001000013); ans_temp[ans_id*36+5]+=Pmtrx[6]*(Q_002000020*PR_021001000000+Q_002000120*PR_021001000001+Q_002000220*PR_021001000002+Q_102000020*PR_021001000100+Q_102000120*PR_021001000101+Q_102000220*PR_021001000102+Q_202000020*PR_021001000200+Q_202000120*PR_021001000201+Q_202000220*PR_021001000202); ans_temp[ans_id*36+5]+=Pmtrx[7]*(Q_001001020*PR_021001000000+Q_001001120*PR_021001000001+Q_001001220*PR_021001000002+Q_001101020*PR_021001000010+Q_001101120*PR_021001000011+Q_001101220*PR_021001000012+Q_101001020*PR_021001000100+Q_101001120*PR_021001000101+Q_101001220*PR_021001000102+Q_101101020*PR_021001000110+Q_101101120*PR_021001000111+Q_101101220*PR_021001000112); ans_temp[ans_id*36+5]+=Pmtrx[8]*(Q_000002020*PR_021001000000+Q_000002120*PR_021001000001+Q_000002220*PR_021001000002+Q_000102020*PR_021001000010+Q_000102120*PR_021001000011+Q_000102220*PR_021001000012+Q_000202020*PR_021001000020+Q_000202120*PR_021001000021+Q_000202220*PR_021001000022); ans_temp[ans_id*36+5]+=Pmtrx[9]*(Q_001000021*PR_021001000000+Q_001000121*PR_021001000001+Q_001000221*PR_021001000002+Q_001000321*PR_021001000003+Q_101000021*PR_021001000100+Q_101000121*PR_021001000101+Q_101000221*PR_021001000102+Q_101000321*PR_021001000103); ans_temp[ans_id*36+5]+=Pmtrx[10]*(Q_000001021*PR_021001000000+Q_000001121*PR_021001000001+Q_000001221*PR_021001000002+Q_000001321*PR_021001000003+Q_000101021*PR_021001000010+Q_000101121*PR_021001000011+Q_000101221*PR_021001000012+Q_000101321*PR_021001000013); ans_temp[ans_id*36+5]+=Pmtrx[11]*(Q_000000022*PR_021001000000+Q_000000122*PR_021001000001+Q_000000222*PR_021001000002+Q_000000322*PR_021001000003+Q_000000422*PR_021001000004); ans_temp[ans_id*36+0]+=Pmtrx[12]*(Q_022000000*PR_020002000000+Q_122000000*PR_020002000100+Q_222000000*PR_020002000200+Q_322000000*PR_020002000300+Q_422000000*PR_020002000400); ans_temp[ans_id*36+0]+=Pmtrx[13]*(Q_021001000*PR_020002000000+Q_021101000*PR_020002000010+Q_121001000*PR_020002000100+Q_121101000*PR_020002000110+Q_221001000*PR_020002000200+Q_221101000*PR_020002000210+Q_321001000*PR_020002000300+Q_321101000*PR_020002000310); ans_temp[ans_id*36+0]+=Pmtrx[14]*(Q_020002000*PR_020002000000+Q_020102000*PR_020002000010+Q_020202000*PR_020002000020+Q_120002000*PR_020002000100+Q_120102000*PR_020002000110+Q_120202000*PR_020002000120+Q_220002000*PR_020002000200+Q_220102000*PR_020002000210+Q_220202000*PR_020002000220); ans_temp[ans_id*36+0]+=Pmtrx[15]*(Q_021000001*PR_020002000000+Q_021000101*PR_020002000001+Q_121000001*PR_020002000100+Q_121000101*PR_020002000101+Q_221000001*PR_020002000200+Q_221000101*PR_020002000201+Q_321000001*PR_020002000300+Q_321000101*PR_020002000301); ans_temp[ans_id*36+0]+=Pmtrx[16]*(Q_020001001*PR_020002000000+Q_020001101*PR_020002000001+Q_020101001*PR_020002000010+Q_020101101*PR_020002000011+Q_120001001*PR_020002000100+Q_120001101*PR_020002000101+Q_120101001*PR_020002000110+Q_120101101*PR_020002000111+Q_220001001*PR_020002000200+Q_220001101*PR_020002000201+Q_220101001*PR_020002000210+Q_220101101*PR_020002000211); ans_temp[ans_id*36+0]+=Pmtrx[17]*(Q_020000002*PR_020002000000+Q_020000102*PR_020002000001+Q_020000202*PR_020002000002+Q_120000002*PR_020002000100+Q_120000102*PR_020002000101+Q_120000202*PR_020002000102+Q_220000002*PR_020002000200+Q_220000102*PR_020002000201+Q_220000202*PR_020002000202); ans_temp[ans_id*36+1]+=Pmtrx[12]*(Q_012010000*PR_020002000000+Q_012110000*PR_020002000010+Q_112010000*PR_020002000100+Q_112110000*PR_020002000110+Q_212010000*PR_020002000200+Q_212110000*PR_020002000210+Q_312010000*PR_020002000300+Q_312110000*PR_020002000310); ans_temp[ans_id*36+1]+=Pmtrx[13]*(Q_011011000*PR_020002000000+Q_011111000*PR_020002000010+Q_011211000*PR_020002000020+Q_111011000*PR_020002000100+Q_111111000*PR_020002000110+Q_111211000*PR_020002000120+Q_211011000*PR_020002000200+Q_211111000*PR_020002000210+Q_211211000*PR_020002000220); ans_temp[ans_id*36+1]+=Pmtrx[14]*(Q_010012000*PR_020002000000+Q_010112000*PR_020002000010+Q_010212000*PR_020002000020+Q_010312000*PR_020002000030+Q_110012000*PR_020002000100+Q_110112000*PR_020002000110+Q_110212000*PR_020002000120+Q_110312000*PR_020002000130); ans_temp[ans_id*36+1]+=Pmtrx[15]*(Q_011010001*PR_020002000000+Q_011010101*PR_020002000001+Q_011110001*PR_020002000010+Q_011110101*PR_020002000011+Q_111010001*PR_020002000100+Q_111010101*PR_020002000101+Q_111110001*PR_020002000110+Q_111110101*PR_020002000111+Q_211010001*PR_020002000200+Q_211010101*PR_020002000201+Q_211110001*PR_020002000210+Q_211110101*PR_020002000211); ans_temp[ans_id*36+1]+=Pmtrx[16]*(Q_010011001*PR_020002000000+Q_010011101*PR_020002000001+Q_010111001*PR_020002000010+Q_010111101*PR_020002000011+Q_010211001*PR_020002000020+Q_010211101*PR_020002000021+Q_110011001*PR_020002000100+Q_110011101*PR_020002000101+Q_110111001*PR_020002000110+Q_110111101*PR_020002000111+Q_110211001*PR_020002000120+Q_110211101*PR_020002000121); ans_temp[ans_id*36+1]+=Pmtrx[17]*(Q_010010002*PR_020002000000+Q_010010102*PR_020002000001+Q_010010202*PR_020002000002+Q_010110002*PR_020002000010+Q_010110102*PR_020002000011+Q_010110202*PR_020002000012+Q_110010002*PR_020002000100+Q_110010102*PR_020002000101+Q_110010202*PR_020002000102+Q_110110002*PR_020002000110+Q_110110102*PR_020002000111+Q_110110202*PR_020002000112); ans_temp[ans_id*36+2]+=Pmtrx[12]*(Q_002020000*PR_020002000000+Q_002120000*PR_020002000010+Q_002220000*PR_020002000020+Q_102020000*PR_020002000100+Q_102120000*PR_020002000110+Q_102220000*PR_020002000120+Q_202020000*PR_020002000200+Q_202120000*PR_020002000210+Q_202220000*PR_020002000220); ans_temp[ans_id*36+2]+=Pmtrx[13]*(Q_001021000*PR_020002000000+Q_001121000*PR_020002000010+Q_001221000*PR_020002000020+Q_001321000*PR_020002000030+Q_101021000*PR_020002000100+Q_101121000*PR_020002000110+Q_101221000*PR_020002000120+Q_101321000*PR_020002000130); ans_temp[ans_id*36+2]+=Pmtrx[14]*(Q_000022000*PR_020002000000+Q_000122000*PR_020002000010+Q_000222000*PR_020002000020+Q_000322000*PR_020002000030+Q_000422000*PR_020002000040); ans_temp[ans_id*36+2]+=Pmtrx[15]*(Q_001020001*PR_020002000000+Q_001020101*PR_020002000001+Q_001120001*PR_020002000010+Q_001120101*PR_020002000011+Q_001220001*PR_020002000020+Q_001220101*PR_020002000021+Q_101020001*PR_020002000100+Q_101020101*PR_020002000101+Q_101120001*PR_020002000110+Q_101120101*PR_020002000111+Q_101220001*PR_020002000120+Q_101220101*PR_020002000121); ans_temp[ans_id*36+2]+=Pmtrx[16]*(Q_000021001*PR_020002000000+Q_000021101*PR_020002000001+Q_000121001*PR_020002000010+Q_000121101*PR_020002000011+Q_000221001*PR_020002000020+Q_000221101*PR_020002000021+Q_000321001*PR_020002000030+Q_000321101*PR_020002000031); ans_temp[ans_id*36+2]+=Pmtrx[17]*(Q_000020002*PR_020002000000+Q_000020102*PR_020002000001+Q_000020202*PR_020002000002+Q_000120002*PR_020002000010+Q_000120102*PR_020002000011+Q_000120202*PR_020002000012+Q_000220002*PR_020002000020+Q_000220102*PR_020002000021+Q_000220202*PR_020002000022); ans_temp[ans_id*36+3]+=Pmtrx[12]*(Q_012000010*PR_020002000000+Q_012000110*PR_020002000001+Q_112000010*PR_020002000100+Q_112000110*PR_020002000101+Q_212000010*PR_020002000200+Q_212000110*PR_020002000201+Q_312000010*PR_020002000300+Q_312000110*PR_020002000301); ans_temp[ans_id*36+3]+=Pmtrx[13]*(Q_011001010*PR_020002000000+Q_011001110*PR_020002000001+Q_011101010*PR_020002000010+Q_011101110*PR_020002000011+Q_111001010*PR_020002000100+Q_111001110*PR_020002000101+Q_111101010*PR_020002000110+Q_111101110*PR_020002000111+Q_211001010*PR_020002000200+Q_211001110*PR_020002000201+Q_211101010*PR_020002000210+Q_211101110*PR_020002000211); ans_temp[ans_id*36+3]+=Pmtrx[14]*(Q_010002010*PR_020002000000+Q_010002110*PR_020002000001+Q_010102010*PR_020002000010+Q_010102110*PR_020002000011+Q_010202010*PR_020002000020+Q_010202110*PR_020002000021+Q_110002010*PR_020002000100+Q_110002110*PR_020002000101+Q_110102010*PR_020002000110+Q_110102110*PR_020002000111+Q_110202010*PR_020002000120+Q_110202110*PR_020002000121); ans_temp[ans_id*36+3]+=Pmtrx[15]*(Q_011000011*PR_020002000000+Q_011000111*PR_020002000001+Q_011000211*PR_020002000002+Q_111000011*PR_020002000100+Q_111000111*PR_020002000101+Q_111000211*PR_020002000102+Q_211000011*PR_020002000200+Q_211000111*PR_020002000201+Q_211000211*PR_020002000202); ans_temp[ans_id*36+3]+=Pmtrx[16]*(Q_010001011*PR_020002000000+Q_010001111*PR_020002000001+Q_010001211*PR_020002000002+Q_010101011*PR_020002000010+Q_010101111*PR_020002000011+Q_010101211*PR_020002000012+Q_110001011*PR_020002000100+Q_110001111*PR_020002000101+Q_110001211*PR_020002000102+Q_110101011*PR_020002000110+Q_110101111*PR_020002000111+Q_110101211*PR_020002000112); ans_temp[ans_id*36+3]+=Pmtrx[17]*(Q_010000012*PR_020002000000+Q_010000112*PR_020002000001+Q_010000212*PR_020002000002+Q_010000312*PR_020002000003+Q_110000012*PR_020002000100+Q_110000112*PR_020002000101+Q_110000212*PR_020002000102+Q_110000312*PR_020002000103); ans_temp[ans_id*36+4]+=Pmtrx[12]*(Q_002010010*PR_020002000000+Q_002010110*PR_020002000001+Q_002110010*PR_020002000010+Q_002110110*PR_020002000011+Q_102010010*PR_020002000100+Q_102010110*PR_020002000101+Q_102110010*PR_020002000110+Q_102110110*PR_020002000111+Q_202010010*PR_020002000200+Q_202010110*PR_020002000201+Q_202110010*PR_020002000210+Q_202110110*PR_020002000211); ans_temp[ans_id*36+4]+=Pmtrx[13]*(Q_001011010*PR_020002000000+Q_001011110*PR_020002000001+Q_001111010*PR_020002000010+Q_001111110*PR_020002000011+Q_001211010*PR_020002000020+Q_001211110*PR_020002000021+Q_101011010*PR_020002000100+Q_101011110*PR_020002000101+Q_101111010*PR_020002000110+Q_101111110*PR_020002000111+Q_101211010*PR_020002000120+Q_101211110*PR_020002000121); ans_temp[ans_id*36+4]+=Pmtrx[14]*(Q_000012010*PR_020002000000+Q_000012110*PR_020002000001+Q_000112010*PR_020002000010+Q_000112110*PR_020002000011+Q_000212010*PR_020002000020+Q_000212110*PR_020002000021+Q_000312010*PR_020002000030+Q_000312110*PR_020002000031); ans_temp[ans_id*36+4]+=Pmtrx[15]*(Q_001010011*PR_020002000000+Q_001010111*PR_020002000001+Q_001010211*PR_020002000002+Q_001110011*PR_020002000010+Q_001110111*PR_020002000011+Q_001110211*PR_020002000012+Q_101010011*PR_020002000100+Q_101010111*PR_020002000101+Q_101010211*PR_020002000102+Q_101110011*PR_020002000110+Q_101110111*PR_020002000111+Q_101110211*PR_020002000112); ans_temp[ans_id*36+4]+=Pmtrx[16]*(Q_000011011*PR_020002000000+Q_000011111*PR_020002000001+Q_000011211*PR_020002000002+Q_000111011*PR_020002000010+Q_000111111*PR_020002000011+Q_000111211*PR_020002000012+Q_000211011*PR_020002000020+Q_000211111*PR_020002000021+Q_000211211*PR_020002000022); ans_temp[ans_id*36+4]+=Pmtrx[17]*(Q_000010012*PR_020002000000+Q_000010112*PR_020002000001+Q_000010212*PR_020002000002+Q_000010312*PR_020002000003+Q_000110012*PR_020002000010+Q_000110112*PR_020002000011+Q_000110212*PR_020002000012+Q_000110312*PR_020002000013); ans_temp[ans_id*36+5]+=Pmtrx[12]*(Q_002000020*PR_020002000000+Q_002000120*PR_020002000001+Q_002000220*PR_020002000002+Q_102000020*PR_020002000100+Q_102000120*PR_020002000101+Q_102000220*PR_020002000102+Q_202000020*PR_020002000200+Q_202000120*PR_020002000201+Q_202000220*PR_020002000202); ans_temp[ans_id*36+5]+=Pmtrx[13]*(Q_001001020*PR_020002000000+Q_001001120*PR_020002000001+Q_001001220*PR_020002000002+Q_001101020*PR_020002000010+Q_001101120*PR_020002000011+Q_001101220*PR_020002000012+Q_101001020*PR_020002000100+Q_101001120*PR_020002000101+Q_101001220*PR_020002000102+Q_101101020*PR_020002000110+Q_101101120*PR_020002000111+Q_101101220*PR_020002000112); ans_temp[ans_id*36+5]+=Pmtrx[14]*(Q_000002020*PR_020002000000+Q_000002120*PR_020002000001+Q_000002220*PR_020002000002+Q_000102020*PR_020002000010+Q_000102120*PR_020002000011+Q_000102220*PR_020002000012+Q_000202020*PR_020002000020+Q_000202120*PR_020002000021+Q_000202220*PR_020002000022); ans_temp[ans_id*36+5]+=Pmtrx[15]*(Q_001000021*PR_020002000000+Q_001000121*PR_020002000001+Q_001000221*PR_020002000002+Q_001000321*PR_020002000003+Q_101000021*PR_020002000100+Q_101000121*PR_020002000101+Q_101000221*PR_020002000102+Q_101000321*PR_020002000103); ans_temp[ans_id*36+5]+=Pmtrx[16]*(Q_000001021*PR_020002000000+Q_000001121*PR_020002000001+Q_000001221*PR_020002000002+Q_000001321*PR_020002000003+Q_000101021*PR_020002000010+Q_000101121*PR_020002000011+Q_000101221*PR_020002000012+Q_000101321*PR_020002000013); ans_temp[ans_id*36+5]+=Pmtrx[17]*(Q_000000022*PR_020002000000+Q_000000122*PR_020002000001+Q_000000222*PR_020002000002+Q_000000322*PR_020002000003+Q_000000422*PR_020002000004); ans_temp[ans_id*36+0]+=Pmtrx[18]*(Q_022000000*PR_021000001000+Q_122000000*PR_021000001100+Q_222000000*PR_021000001200+Q_322000000*PR_021000001300+Q_422000000*PR_021000001400); ans_temp[ans_id*36+0]+=Pmtrx[19]*(Q_021001000*PR_021000001000+Q_021101000*PR_021000001010+Q_121001000*PR_021000001100+Q_121101000*PR_021000001110+Q_221001000*PR_021000001200+Q_221101000*PR_021000001210+Q_321001000*PR_021000001300+Q_321101000*PR_021000001310); ans_temp[ans_id*36+0]+=Pmtrx[20]*(Q_020002000*PR_021000001000+Q_020102000*PR_021000001010+Q_020202000*PR_021000001020+Q_120002000*PR_021000001100+Q_120102000*PR_021000001110+Q_120202000*PR_021000001120+Q_220002000*PR_021000001200+Q_220102000*PR_021000001210+Q_220202000*PR_021000001220); ans_temp[ans_id*36+0]+=Pmtrx[21]*(Q_021000001*PR_021000001000+Q_021000101*PR_021000001001+Q_121000001*PR_021000001100+Q_121000101*PR_021000001101+Q_221000001*PR_021000001200+Q_221000101*PR_021000001201+Q_321000001*PR_021000001300+Q_321000101*PR_021000001301); ans_temp[ans_id*36+0]+=Pmtrx[22]*(Q_020001001*PR_021000001000+Q_020001101*PR_021000001001+Q_020101001*PR_021000001010+Q_020101101*PR_021000001011+Q_120001001*PR_021000001100+Q_120001101*PR_021000001101+Q_120101001*PR_021000001110+Q_120101101*PR_021000001111+Q_220001001*PR_021000001200+Q_220001101*PR_021000001201+Q_220101001*PR_021000001210+Q_220101101*PR_021000001211); ans_temp[ans_id*36+0]+=Pmtrx[23]*(Q_020000002*PR_021000001000+Q_020000102*PR_021000001001+Q_020000202*PR_021000001002+Q_120000002*PR_021000001100+Q_120000102*PR_021000001101+Q_120000202*PR_021000001102+Q_220000002*PR_021000001200+Q_220000102*PR_021000001201+Q_220000202*PR_021000001202); ans_temp[ans_id*36+1]+=Pmtrx[18]*(Q_012010000*PR_021000001000+Q_012110000*PR_021000001010+Q_112010000*PR_021000001100+Q_112110000*PR_021000001110+Q_212010000*PR_021000001200+Q_212110000*PR_021000001210+Q_312010000*PR_021000001300+Q_312110000*PR_021000001310); ans_temp[ans_id*36+1]+=Pmtrx[19]*(Q_011011000*PR_021000001000+Q_011111000*PR_021000001010+Q_011211000*PR_021000001020+Q_111011000*PR_021000001100+Q_111111000*PR_021000001110+Q_111211000*PR_021000001120+Q_211011000*PR_021000001200+Q_211111000*PR_021000001210+Q_211211000*PR_021000001220); ans_temp[ans_id*36+1]+=Pmtrx[20]*(Q_010012000*PR_021000001000+Q_010112000*PR_021000001010+Q_010212000*PR_021000001020+Q_010312000*PR_021000001030+Q_110012000*PR_021000001100+Q_110112000*PR_021000001110+Q_110212000*PR_021000001120+Q_110312000*PR_021000001130); ans_temp[ans_id*36+1]+=Pmtrx[21]*(Q_011010001*PR_021000001000+Q_011010101*PR_021000001001+Q_011110001*PR_021000001010+Q_011110101*PR_021000001011+Q_111010001*PR_021000001100+Q_111010101*PR_021000001101+Q_111110001*PR_021000001110+Q_111110101*PR_021000001111+Q_211010001*PR_021000001200+Q_211010101*PR_021000001201+Q_211110001*PR_021000001210+Q_211110101*PR_021000001211); ans_temp[ans_id*36+1]+=Pmtrx[22]*(Q_010011001*PR_021000001000+Q_010011101*PR_021000001001+Q_010111001*PR_021000001010+Q_010111101*PR_021000001011+Q_010211001*PR_021000001020+Q_010211101*PR_021000001021+Q_110011001*PR_021000001100+Q_110011101*PR_021000001101+Q_110111001*PR_021000001110+Q_110111101*PR_021000001111+Q_110211001*PR_021000001120+Q_110211101*PR_021000001121); ans_temp[ans_id*36+1]+=Pmtrx[23]*(Q_010010002*PR_021000001000+Q_010010102*PR_021000001001+Q_010010202*PR_021000001002+Q_010110002*PR_021000001010+Q_010110102*PR_021000001011+Q_010110202*PR_021000001012+Q_110010002*PR_021000001100+Q_110010102*PR_021000001101+Q_110010202*PR_021000001102+Q_110110002*PR_021000001110+Q_110110102*PR_021000001111+Q_110110202*PR_021000001112); ans_temp[ans_id*36+2]+=Pmtrx[18]*(Q_002020000*PR_021000001000+Q_002120000*PR_021000001010+Q_002220000*PR_021000001020+Q_102020000*PR_021000001100+Q_102120000*PR_021000001110+Q_102220000*PR_021000001120+Q_202020000*PR_021000001200+Q_202120000*PR_021000001210+Q_202220000*PR_021000001220); ans_temp[ans_id*36+2]+=Pmtrx[19]*(Q_001021000*PR_021000001000+Q_001121000*PR_021000001010+Q_001221000*PR_021000001020+Q_001321000*PR_021000001030+Q_101021000*PR_021000001100+Q_101121000*PR_021000001110+Q_101221000*PR_021000001120+Q_101321000*PR_021000001130); ans_temp[ans_id*36+2]+=Pmtrx[20]*(Q_000022000*PR_021000001000+Q_000122000*PR_021000001010+Q_000222000*PR_021000001020+Q_000322000*PR_021000001030+Q_000422000*PR_021000001040); ans_temp[ans_id*36+2]+=Pmtrx[21]*(Q_001020001*PR_021000001000+Q_001020101*PR_021000001001+Q_001120001*PR_021000001010+Q_001120101*PR_021000001011+Q_001220001*PR_021000001020+Q_001220101*PR_021000001021+Q_101020001*PR_021000001100+Q_101020101*PR_021000001101+Q_101120001*PR_021000001110+Q_101120101*PR_021000001111+Q_101220001*PR_021000001120+Q_101220101*PR_021000001121); ans_temp[ans_id*36+2]+=Pmtrx[22]*(Q_000021001*PR_021000001000+Q_000021101*PR_021000001001+Q_000121001*PR_021000001010+Q_000121101*PR_021000001011+Q_000221001*PR_021000001020+Q_000221101*PR_021000001021+Q_000321001*PR_021000001030+Q_000321101*PR_021000001031); ans_temp[ans_id*36+2]+=Pmtrx[23]*(Q_000020002*PR_021000001000+Q_000020102*PR_021000001001+Q_000020202*PR_021000001002+Q_000120002*PR_021000001010+Q_000120102*PR_021000001011+Q_000120202*PR_021000001012+Q_000220002*PR_021000001020+Q_000220102*PR_021000001021+Q_000220202*PR_021000001022); ans_temp[ans_id*36+3]+=Pmtrx[18]*(Q_012000010*PR_021000001000+Q_012000110*PR_021000001001+Q_112000010*PR_021000001100+Q_112000110*PR_021000001101+Q_212000010*PR_021000001200+Q_212000110*PR_021000001201+Q_312000010*PR_021000001300+Q_312000110*PR_021000001301); ans_temp[ans_id*36+3]+=Pmtrx[19]*(Q_011001010*PR_021000001000+Q_011001110*PR_021000001001+Q_011101010*PR_021000001010+Q_011101110*PR_021000001011+Q_111001010*PR_021000001100+Q_111001110*PR_021000001101+Q_111101010*PR_021000001110+Q_111101110*PR_021000001111+Q_211001010*PR_021000001200+Q_211001110*PR_021000001201+Q_211101010*PR_021000001210+Q_211101110*PR_021000001211); ans_temp[ans_id*36+3]+=Pmtrx[20]*(Q_010002010*PR_021000001000+Q_010002110*PR_021000001001+Q_010102010*PR_021000001010+Q_010102110*PR_021000001011+Q_010202010*PR_021000001020+Q_010202110*PR_021000001021+Q_110002010*PR_021000001100+Q_110002110*PR_021000001101+Q_110102010*PR_021000001110+Q_110102110*PR_021000001111+Q_110202010*PR_021000001120+Q_110202110*PR_021000001121); ans_temp[ans_id*36+3]+=Pmtrx[21]*(Q_011000011*PR_021000001000+Q_011000111*PR_021000001001+Q_011000211*PR_021000001002+Q_111000011*PR_021000001100+Q_111000111*PR_021000001101+Q_111000211*PR_021000001102+Q_211000011*PR_021000001200+Q_211000111*PR_021000001201+Q_211000211*PR_021000001202); ans_temp[ans_id*36+3]+=Pmtrx[22]*(Q_010001011*PR_021000001000+Q_010001111*PR_021000001001+Q_010001211*PR_021000001002+Q_010101011*PR_021000001010+Q_010101111*PR_021000001011+Q_010101211*PR_021000001012+Q_110001011*PR_021000001100+Q_110001111*PR_021000001101+Q_110001211*PR_021000001102+Q_110101011*PR_021000001110+Q_110101111*PR_021000001111+Q_110101211*PR_021000001112); ans_temp[ans_id*36+3]+=Pmtrx[23]*(Q_010000012*PR_021000001000+Q_010000112*PR_021000001001+Q_010000212*PR_021000001002+Q_010000312*PR_021000001003+Q_110000012*PR_021000001100+Q_110000112*PR_021000001101+Q_110000212*PR_021000001102+Q_110000312*PR_021000001103); ans_temp[ans_id*36+4]+=Pmtrx[18]*(Q_002010010*PR_021000001000+Q_002010110*PR_021000001001+Q_002110010*PR_021000001010+Q_002110110*PR_021000001011+Q_102010010*PR_021000001100+Q_102010110*PR_021000001101+Q_102110010*PR_021000001110+Q_102110110*PR_021000001111+Q_202010010*PR_021000001200+Q_202010110*PR_021000001201+Q_202110010*PR_021000001210+Q_202110110*PR_021000001211); ans_temp[ans_id*36+4]+=Pmtrx[19]*(Q_001011010*PR_021000001000+Q_001011110*PR_021000001001+Q_001111010*PR_021000001010+Q_001111110*PR_021000001011+Q_001211010*PR_021000001020+Q_001211110*PR_021000001021+Q_101011010*PR_021000001100+Q_101011110*PR_021000001101+Q_101111010*PR_021000001110+Q_101111110*PR_021000001111+Q_101211010*PR_021000001120+Q_101211110*PR_021000001121); ans_temp[ans_id*36+4]+=Pmtrx[20]*(Q_000012010*PR_021000001000+Q_000012110*PR_021000001001+Q_000112010*PR_021000001010+Q_000112110*PR_021000001011+Q_000212010*PR_021000001020+Q_000212110*PR_021000001021+Q_000312010*PR_021000001030+Q_000312110*PR_021000001031); ans_temp[ans_id*36+4]+=Pmtrx[21]*(Q_001010011*PR_021000001000+Q_001010111*PR_021000001001+Q_001010211*PR_021000001002+Q_001110011*PR_021000001010+Q_001110111*PR_021000001011+Q_001110211*PR_021000001012+Q_101010011*PR_021000001100+Q_101010111*PR_021000001101+Q_101010211*PR_021000001102+Q_101110011*PR_021000001110+Q_101110111*PR_021000001111+Q_101110211*PR_021000001112); ans_temp[ans_id*36+4]+=Pmtrx[22]*(Q_000011011*PR_021000001000+Q_000011111*PR_021000001001+Q_000011211*PR_021000001002+Q_000111011*PR_021000001010+Q_000111111*PR_021000001011+Q_000111211*PR_021000001012+Q_000211011*PR_021000001020+Q_000211111*PR_021000001021+Q_000211211*PR_021000001022); ans_temp[ans_id*36+4]+=Pmtrx[23]*(Q_000010012*PR_021000001000+Q_000010112*PR_021000001001+Q_000010212*PR_021000001002+Q_000010312*PR_021000001003+Q_000110012*PR_021000001010+Q_000110112*PR_021000001011+Q_000110212*PR_021000001012+Q_000110312*PR_021000001013); ans_temp[ans_id*36+5]+=Pmtrx[18]*(Q_002000020*PR_021000001000+Q_002000120*PR_021000001001+Q_002000220*PR_021000001002+Q_102000020*PR_021000001100+Q_102000120*PR_021000001101+Q_102000220*PR_021000001102+Q_202000020*PR_021000001200+Q_202000120*PR_021000001201+Q_202000220*PR_021000001202); ans_temp[ans_id*36+5]+=Pmtrx[19]*(Q_001001020*PR_021000001000+Q_001001120*PR_021000001001+Q_001001220*PR_021000001002+Q_001101020*PR_021000001010+Q_001101120*PR_021000001011+Q_001101220*PR_021000001012+Q_101001020*PR_021000001100+Q_101001120*PR_021000001101+Q_101001220*PR_021000001102+Q_101101020*PR_021000001110+Q_101101120*PR_021000001111+Q_101101220*PR_021000001112); ans_temp[ans_id*36+5]+=Pmtrx[20]*(Q_000002020*PR_021000001000+Q_000002120*PR_021000001001+Q_000002220*PR_021000001002+Q_000102020*PR_021000001010+Q_000102120*PR_021000001011+Q_000102220*PR_021000001012+Q_000202020*PR_021000001020+Q_000202120*PR_021000001021+Q_000202220*PR_021000001022); ans_temp[ans_id*36+5]+=Pmtrx[21]*(Q_001000021*PR_021000001000+Q_001000121*PR_021000001001+Q_001000221*PR_021000001002+Q_001000321*PR_021000001003+Q_101000021*PR_021000001100+Q_101000121*PR_021000001101+Q_101000221*PR_021000001102+Q_101000321*PR_021000001103); ans_temp[ans_id*36+5]+=Pmtrx[22]*(Q_000001021*PR_021000001000+Q_000001121*PR_021000001001+Q_000001221*PR_021000001002+Q_000001321*PR_021000001003+Q_000101021*PR_021000001010+Q_000101121*PR_021000001011+Q_000101221*PR_021000001012+Q_000101321*PR_021000001013); ans_temp[ans_id*36+5]+=Pmtrx[23]*(Q_000000022*PR_021000001000+Q_000000122*PR_021000001001+Q_000000222*PR_021000001002+Q_000000322*PR_021000001003+Q_000000422*PR_021000001004); ans_temp[ans_id*36+0]+=Pmtrx[24]*(Q_022000000*PR_020001001000+Q_122000000*PR_020001001100+Q_222000000*PR_020001001200+Q_322000000*PR_020001001300+Q_422000000*PR_020001001400); ans_temp[ans_id*36+0]+=Pmtrx[25]*(Q_021001000*PR_020001001000+Q_021101000*PR_020001001010+Q_121001000*PR_020001001100+Q_121101000*PR_020001001110+Q_221001000*PR_020001001200+Q_221101000*PR_020001001210+Q_321001000*PR_020001001300+Q_321101000*PR_020001001310); ans_temp[ans_id*36+0]+=Pmtrx[26]*(Q_020002000*PR_020001001000+Q_020102000*PR_020001001010+Q_020202000*PR_020001001020+Q_120002000*PR_020001001100+Q_120102000*PR_020001001110+Q_120202000*PR_020001001120+Q_220002000*PR_020001001200+Q_220102000*PR_020001001210+Q_220202000*PR_020001001220); ans_temp[ans_id*36+0]+=Pmtrx[27]*(Q_021000001*PR_020001001000+Q_021000101*PR_020001001001+Q_121000001*PR_020001001100+Q_121000101*PR_020001001101+Q_221000001*PR_020001001200+Q_221000101*PR_020001001201+Q_321000001*PR_020001001300+Q_321000101*PR_020001001301); ans_temp[ans_id*36+0]+=Pmtrx[28]*(Q_020001001*PR_020001001000+Q_020001101*PR_020001001001+Q_020101001*PR_020001001010+Q_020101101*PR_020001001011+Q_120001001*PR_020001001100+Q_120001101*PR_020001001101+Q_120101001*PR_020001001110+Q_120101101*PR_020001001111+Q_220001001*PR_020001001200+Q_220001101*PR_020001001201+Q_220101001*PR_020001001210+Q_220101101*PR_020001001211); ans_temp[ans_id*36+0]+=Pmtrx[29]*(Q_020000002*PR_020001001000+Q_020000102*PR_020001001001+Q_020000202*PR_020001001002+Q_120000002*PR_020001001100+Q_120000102*PR_020001001101+Q_120000202*PR_020001001102+Q_220000002*PR_020001001200+Q_220000102*PR_020001001201+Q_220000202*PR_020001001202); ans_temp[ans_id*36+1]+=Pmtrx[24]*(Q_012010000*PR_020001001000+Q_012110000*PR_020001001010+Q_112010000*PR_020001001100+Q_112110000*PR_020001001110+Q_212010000*PR_020001001200+Q_212110000*PR_020001001210+Q_312010000*PR_020001001300+Q_312110000*PR_020001001310); ans_temp[ans_id*36+1]+=Pmtrx[25]*(Q_011011000*PR_020001001000+Q_011111000*PR_020001001010+Q_011211000*PR_020001001020+Q_111011000*PR_020001001100+Q_111111000*PR_020001001110+Q_111211000*PR_020001001120+Q_211011000*PR_020001001200+Q_211111000*PR_020001001210+Q_211211000*PR_020001001220); ans_temp[ans_id*36+1]+=Pmtrx[26]*(Q_010012000*PR_020001001000+Q_010112000*PR_020001001010+Q_010212000*PR_020001001020+Q_010312000*PR_020001001030+Q_110012000*PR_020001001100+Q_110112000*PR_020001001110+Q_110212000*PR_020001001120+Q_110312000*PR_020001001130); ans_temp[ans_id*36+1]+=Pmtrx[27]*(Q_011010001*PR_020001001000+Q_011010101*PR_020001001001+Q_011110001*PR_020001001010+Q_011110101*PR_020001001011+Q_111010001*PR_020001001100+Q_111010101*PR_020001001101+Q_111110001*PR_020001001110+Q_111110101*PR_020001001111+Q_211010001*PR_020001001200+Q_211010101*PR_020001001201+Q_211110001*PR_020001001210+Q_211110101*PR_020001001211); ans_temp[ans_id*36+1]+=Pmtrx[28]*(Q_010011001*PR_020001001000+Q_010011101*PR_020001001001+Q_010111001*PR_020001001010+Q_010111101*PR_020001001011+Q_010211001*PR_020001001020+Q_010211101*PR_020001001021+Q_110011001*PR_020001001100+Q_110011101*PR_020001001101+Q_110111001*PR_020001001110+Q_110111101*PR_020001001111+Q_110211001*PR_020001001120+Q_110211101*PR_020001001121); ans_temp[ans_id*36+1]+=Pmtrx[29]*(Q_010010002*PR_020001001000+Q_010010102*PR_020001001001+Q_010010202*PR_020001001002+Q_010110002*PR_020001001010+Q_010110102*PR_020001001011+Q_010110202*PR_020001001012+Q_110010002*PR_020001001100+Q_110010102*PR_020001001101+Q_110010202*PR_020001001102+Q_110110002*PR_020001001110+Q_110110102*PR_020001001111+Q_110110202*PR_020001001112); ans_temp[ans_id*36+2]+=Pmtrx[24]*(Q_002020000*PR_020001001000+Q_002120000*PR_020001001010+Q_002220000*PR_020001001020+Q_102020000*PR_020001001100+Q_102120000*PR_020001001110+Q_102220000*PR_020001001120+Q_202020000*PR_020001001200+Q_202120000*PR_020001001210+Q_202220000*PR_020001001220); ans_temp[ans_id*36+2]+=Pmtrx[25]*(Q_001021000*PR_020001001000+Q_001121000*PR_020001001010+Q_001221000*PR_020001001020+Q_001321000*PR_020001001030+Q_101021000*PR_020001001100+Q_101121000*PR_020001001110+Q_101221000*PR_020001001120+Q_101321000*PR_020001001130); ans_temp[ans_id*36+2]+=Pmtrx[26]*(Q_000022000*PR_020001001000+Q_000122000*PR_020001001010+Q_000222000*PR_020001001020+Q_000322000*PR_020001001030+Q_000422000*PR_020001001040); ans_temp[ans_id*36+2]+=Pmtrx[27]*(Q_001020001*PR_020001001000+Q_001020101*PR_020001001001+Q_001120001*PR_020001001010+Q_001120101*PR_020001001011+Q_001220001*PR_020001001020+Q_001220101*PR_020001001021+Q_101020001*PR_020001001100+Q_101020101*PR_020001001101+Q_101120001*PR_020001001110+Q_101120101*PR_020001001111+Q_101220001*PR_020001001120+Q_101220101*PR_020001001121); ans_temp[ans_id*36+2]+=Pmtrx[28]*(Q_000021001*PR_020001001000+Q_000021101*PR_020001001001+Q_000121001*PR_020001001010+Q_000121101*PR_020001001011+Q_000221001*PR_020001001020+Q_000221101*PR_020001001021+Q_000321001*PR_020001001030+Q_000321101*PR_020001001031); ans_temp[ans_id*36+2]+=Pmtrx[29]*(Q_000020002*PR_020001001000+Q_000020102*PR_020001001001+Q_000020202*PR_020001001002+Q_000120002*PR_020001001010+Q_000120102*PR_020001001011+Q_000120202*PR_020001001012+Q_000220002*PR_020001001020+Q_000220102*PR_020001001021+Q_000220202*PR_020001001022); ans_temp[ans_id*36+3]+=Pmtrx[24]*(Q_012000010*PR_020001001000+Q_012000110*PR_020001001001+Q_112000010*PR_020001001100+Q_112000110*PR_020001001101+Q_212000010*PR_020001001200+Q_212000110*PR_020001001201+Q_312000010*PR_020001001300+Q_312000110*PR_020001001301); ans_temp[ans_id*36+3]+=Pmtrx[25]*(Q_011001010*PR_020001001000+Q_011001110*PR_020001001001+Q_011101010*PR_020001001010+Q_011101110*PR_020001001011+Q_111001010*PR_020001001100+Q_111001110*PR_020001001101+Q_111101010*PR_020001001110+Q_111101110*PR_020001001111+Q_211001010*PR_020001001200+Q_211001110*PR_020001001201+Q_211101010*PR_020001001210+Q_211101110*PR_020001001211); ans_temp[ans_id*36+3]+=Pmtrx[26]*(Q_010002010*PR_020001001000+Q_010002110*PR_020001001001+Q_010102010*PR_020001001010+Q_010102110*PR_020001001011+Q_010202010*PR_020001001020+Q_010202110*PR_020001001021+Q_110002010*PR_020001001100+Q_110002110*PR_020001001101+Q_110102010*PR_020001001110+Q_110102110*PR_020001001111+Q_110202010*PR_020001001120+Q_110202110*PR_020001001121); ans_temp[ans_id*36+3]+=Pmtrx[27]*(Q_011000011*PR_020001001000+Q_011000111*PR_020001001001+Q_011000211*PR_020001001002+Q_111000011*PR_020001001100+Q_111000111*PR_020001001101+Q_111000211*PR_020001001102+Q_211000011*PR_020001001200+Q_211000111*PR_020001001201+Q_211000211*PR_020001001202); ans_temp[ans_id*36+3]+=Pmtrx[28]*(Q_010001011*PR_020001001000+Q_010001111*PR_020001001001+Q_010001211*PR_020001001002+Q_010101011*PR_020001001010+Q_010101111*PR_020001001011+Q_010101211*PR_020001001012+Q_110001011*PR_020001001100+Q_110001111*PR_020001001101+Q_110001211*PR_020001001102+Q_110101011*PR_020001001110+Q_110101111*PR_020001001111+Q_110101211*PR_020001001112); ans_temp[ans_id*36+3]+=Pmtrx[29]*(Q_010000012*PR_020001001000+Q_010000112*PR_020001001001+Q_010000212*PR_020001001002+Q_010000312*PR_020001001003+Q_110000012*PR_020001001100+Q_110000112*PR_020001001101+Q_110000212*PR_020001001102+Q_110000312*PR_020001001103); ans_temp[ans_id*36+4]+=Pmtrx[24]*(Q_002010010*PR_020001001000+Q_002010110*PR_020001001001+Q_002110010*PR_020001001010+Q_002110110*PR_020001001011+Q_102010010*PR_020001001100+Q_102010110*PR_020001001101+Q_102110010*PR_020001001110+Q_102110110*PR_020001001111+Q_202010010*PR_020001001200+Q_202010110*PR_020001001201+Q_202110010*PR_020001001210+Q_202110110*PR_020001001211); ans_temp[ans_id*36+4]+=Pmtrx[25]*(Q_001011010*PR_020001001000+Q_001011110*PR_020001001001+Q_001111010*PR_020001001010+Q_001111110*PR_020001001011+Q_001211010*PR_020001001020+Q_001211110*PR_020001001021+Q_101011010*PR_020001001100+Q_101011110*PR_020001001101+Q_101111010*PR_020001001110+Q_101111110*PR_020001001111+Q_101211010*PR_020001001120+Q_101211110*PR_020001001121); ans_temp[ans_id*36+4]+=Pmtrx[26]*(Q_000012010*PR_020001001000+Q_000012110*PR_020001001001+Q_000112010*PR_020001001010+Q_000112110*PR_020001001011+Q_000212010*PR_020001001020+Q_000212110*PR_020001001021+Q_000312010*PR_020001001030+Q_000312110*PR_020001001031); ans_temp[ans_id*36+4]+=Pmtrx[27]*(Q_001010011*PR_020001001000+Q_001010111*PR_020001001001+Q_001010211*PR_020001001002+Q_001110011*PR_020001001010+Q_001110111*PR_020001001011+Q_001110211*PR_020001001012+Q_101010011*PR_020001001100+Q_101010111*PR_020001001101+Q_101010211*PR_020001001102+Q_101110011*PR_020001001110+Q_101110111*PR_020001001111+Q_101110211*PR_020001001112); ans_temp[ans_id*36+4]+=Pmtrx[28]*(Q_000011011*PR_020001001000+Q_000011111*PR_020001001001+Q_000011211*PR_020001001002+Q_000111011*PR_020001001010+Q_000111111*PR_020001001011+Q_000111211*PR_020001001012+Q_000211011*PR_020001001020+Q_000211111*PR_020001001021+Q_000211211*PR_020001001022); ans_temp[ans_id*36+4]+=Pmtrx[29]*(Q_000010012*PR_020001001000+Q_000010112*PR_020001001001+Q_000010212*PR_020001001002+Q_000010312*PR_020001001003+Q_000110012*PR_020001001010+Q_000110112*PR_020001001011+Q_000110212*PR_020001001012+Q_000110312*PR_020001001013); ans_temp[ans_id*36+5]+=Pmtrx[24]*(Q_002000020*PR_020001001000+Q_002000120*PR_020001001001+Q_002000220*PR_020001001002+Q_102000020*PR_020001001100+Q_102000120*PR_020001001101+Q_102000220*PR_020001001102+Q_202000020*PR_020001001200+Q_202000120*PR_020001001201+Q_202000220*PR_020001001202); ans_temp[ans_id*36+5]+=Pmtrx[25]*(Q_001001020*PR_020001001000+Q_001001120*PR_020001001001+Q_001001220*PR_020001001002+Q_001101020*PR_020001001010+Q_001101120*PR_020001001011+Q_001101220*PR_020001001012+Q_101001020*PR_020001001100+Q_101001120*PR_020001001101+Q_101001220*PR_020001001102+Q_101101020*PR_020001001110+Q_101101120*PR_020001001111+Q_101101220*PR_020001001112); ans_temp[ans_id*36+5]+=Pmtrx[26]*(Q_000002020*PR_020001001000+Q_000002120*PR_020001001001+Q_000002220*PR_020001001002+Q_000102020*PR_020001001010+Q_000102120*PR_020001001011+Q_000102220*PR_020001001012+Q_000202020*PR_020001001020+Q_000202120*PR_020001001021+Q_000202220*PR_020001001022); ans_temp[ans_id*36+5]+=Pmtrx[27]*(Q_001000021*PR_020001001000+Q_001000121*PR_020001001001+Q_001000221*PR_020001001002+Q_001000321*PR_020001001003+Q_101000021*PR_020001001100+Q_101000121*PR_020001001101+Q_101000221*PR_020001001102+Q_101000321*PR_020001001103); ans_temp[ans_id*36+5]+=Pmtrx[28]*(Q_000001021*PR_020001001000+Q_000001121*PR_020001001001+Q_000001221*PR_020001001002+Q_000001321*PR_020001001003+Q_000101021*PR_020001001010+Q_000101121*PR_020001001011+Q_000101221*PR_020001001012+Q_000101321*PR_020001001013); ans_temp[ans_id*36+5]+=Pmtrx[29]*(Q_000000022*PR_020001001000+Q_000000122*PR_020001001001+Q_000000222*PR_020001001002+Q_000000322*PR_020001001003+Q_000000422*PR_020001001004); ans_temp[ans_id*36+0]+=Pmtrx[30]*(Q_022000000*PR_020000002000+Q_122000000*PR_020000002100+Q_222000000*PR_020000002200+Q_322000000*PR_020000002300+Q_422000000*PR_020000002400); ans_temp[ans_id*36+0]+=Pmtrx[31]*(Q_021001000*PR_020000002000+Q_021101000*PR_020000002010+Q_121001000*PR_020000002100+Q_121101000*PR_020000002110+Q_221001000*PR_020000002200+Q_221101000*PR_020000002210+Q_321001000*PR_020000002300+Q_321101000*PR_020000002310); ans_temp[ans_id*36+0]+=Pmtrx[32]*(Q_020002000*PR_020000002000+Q_020102000*PR_020000002010+Q_020202000*PR_020000002020+Q_120002000*PR_020000002100+Q_120102000*PR_020000002110+Q_120202000*PR_020000002120+Q_220002000*PR_020000002200+Q_220102000*PR_020000002210+Q_220202000*PR_020000002220); ans_temp[ans_id*36+0]+=Pmtrx[33]*(Q_021000001*PR_020000002000+Q_021000101*PR_020000002001+Q_121000001*PR_020000002100+Q_121000101*PR_020000002101+Q_221000001*PR_020000002200+Q_221000101*PR_020000002201+Q_321000001*PR_020000002300+Q_321000101*PR_020000002301); ans_temp[ans_id*36+0]+=Pmtrx[34]*(Q_020001001*PR_020000002000+Q_020001101*PR_020000002001+Q_020101001*PR_020000002010+Q_020101101*PR_020000002011+Q_120001001*PR_020000002100+Q_120001101*PR_020000002101+Q_120101001*PR_020000002110+Q_120101101*PR_020000002111+Q_220001001*PR_020000002200+Q_220001101*PR_020000002201+Q_220101001*PR_020000002210+Q_220101101*PR_020000002211); ans_temp[ans_id*36+0]+=Pmtrx[35]*(Q_020000002*PR_020000002000+Q_020000102*PR_020000002001+Q_020000202*PR_020000002002+Q_120000002*PR_020000002100+Q_120000102*PR_020000002101+Q_120000202*PR_020000002102+Q_220000002*PR_020000002200+Q_220000102*PR_020000002201+Q_220000202*PR_020000002202); ans_temp[ans_id*36+1]+=Pmtrx[30]*(Q_012010000*PR_020000002000+Q_012110000*PR_020000002010+Q_112010000*PR_020000002100+Q_112110000*PR_020000002110+Q_212010000*PR_020000002200+Q_212110000*PR_020000002210+Q_312010000*PR_020000002300+Q_312110000*PR_020000002310); ans_temp[ans_id*36+1]+=Pmtrx[31]*(Q_011011000*PR_020000002000+Q_011111000*PR_020000002010+Q_011211000*PR_020000002020+Q_111011000*PR_020000002100+Q_111111000*PR_020000002110+Q_111211000*PR_020000002120+Q_211011000*PR_020000002200+Q_211111000*PR_020000002210+Q_211211000*PR_020000002220); ans_temp[ans_id*36+1]+=Pmtrx[32]*(Q_010012000*PR_020000002000+Q_010112000*PR_020000002010+Q_010212000*PR_020000002020+Q_010312000*PR_020000002030+Q_110012000*PR_020000002100+Q_110112000*PR_020000002110+Q_110212000*PR_020000002120+Q_110312000*PR_020000002130); ans_temp[ans_id*36+1]+=Pmtrx[33]*(Q_011010001*PR_020000002000+Q_011010101*PR_020000002001+Q_011110001*PR_020000002010+Q_011110101*PR_020000002011+Q_111010001*PR_020000002100+Q_111010101*PR_020000002101+Q_111110001*PR_020000002110+Q_111110101*PR_020000002111+Q_211010001*PR_020000002200+Q_211010101*PR_020000002201+Q_211110001*PR_020000002210+Q_211110101*PR_020000002211); ans_temp[ans_id*36+1]+=Pmtrx[34]*(Q_010011001*PR_020000002000+Q_010011101*PR_020000002001+Q_010111001*PR_020000002010+Q_010111101*PR_020000002011+Q_010211001*PR_020000002020+Q_010211101*PR_020000002021+Q_110011001*PR_020000002100+Q_110011101*PR_020000002101+Q_110111001*PR_020000002110+Q_110111101*PR_020000002111+Q_110211001*PR_020000002120+Q_110211101*PR_020000002121); ans_temp[ans_id*36+1]+=Pmtrx[35]*(Q_010010002*PR_020000002000+Q_010010102*PR_020000002001+Q_010010202*PR_020000002002+Q_010110002*PR_020000002010+Q_010110102*PR_020000002011+Q_010110202*PR_020000002012+Q_110010002*PR_020000002100+Q_110010102*PR_020000002101+Q_110010202*PR_020000002102+Q_110110002*PR_020000002110+Q_110110102*PR_020000002111+Q_110110202*PR_020000002112); ans_temp[ans_id*36+2]+=Pmtrx[30]*(Q_002020000*PR_020000002000+Q_002120000*PR_020000002010+Q_002220000*PR_020000002020+Q_102020000*PR_020000002100+Q_102120000*PR_020000002110+Q_102220000*PR_020000002120+Q_202020000*PR_020000002200+Q_202120000*PR_020000002210+Q_202220000*PR_020000002220); ans_temp[ans_id*36+2]+=Pmtrx[31]*(Q_001021000*PR_020000002000+Q_001121000*PR_020000002010+Q_001221000*PR_020000002020+Q_001321000*PR_020000002030+Q_101021000*PR_020000002100+Q_101121000*PR_020000002110+Q_101221000*PR_020000002120+Q_101321000*PR_020000002130); ans_temp[ans_id*36+2]+=Pmtrx[32]*(Q_000022000*PR_020000002000+Q_000122000*PR_020000002010+Q_000222000*PR_020000002020+Q_000322000*PR_020000002030+Q_000422000*PR_020000002040); ans_temp[ans_id*36+2]+=Pmtrx[33]*(Q_001020001*PR_020000002000+Q_001020101*PR_020000002001+Q_001120001*PR_020000002010+Q_001120101*PR_020000002011+Q_001220001*PR_020000002020+Q_001220101*PR_020000002021+Q_101020001*PR_020000002100+Q_101020101*PR_020000002101+Q_101120001*PR_020000002110+Q_101120101*PR_020000002111+Q_101220001*PR_020000002120+Q_101220101*PR_020000002121); ans_temp[ans_id*36+2]+=Pmtrx[34]*(Q_000021001*PR_020000002000+Q_000021101*PR_020000002001+Q_000121001*PR_020000002010+Q_000121101*PR_020000002011+Q_000221001*PR_020000002020+Q_000221101*PR_020000002021+Q_000321001*PR_020000002030+Q_000321101*PR_020000002031); ans_temp[ans_id*36+2]+=Pmtrx[35]*(Q_000020002*PR_020000002000+Q_000020102*PR_020000002001+Q_000020202*PR_020000002002+Q_000120002*PR_020000002010+Q_000120102*PR_020000002011+Q_000120202*PR_020000002012+Q_000220002*PR_020000002020+Q_000220102*PR_020000002021+Q_000220202*PR_020000002022); ans_temp[ans_id*36+3]+=Pmtrx[30]*(Q_012000010*PR_020000002000+Q_012000110*PR_020000002001+Q_112000010*PR_020000002100+Q_112000110*PR_020000002101+Q_212000010*PR_020000002200+Q_212000110*PR_020000002201+Q_312000010*PR_020000002300+Q_312000110*PR_020000002301); ans_temp[ans_id*36+3]+=Pmtrx[31]*(Q_011001010*PR_020000002000+Q_011001110*PR_020000002001+Q_011101010*PR_020000002010+Q_011101110*PR_020000002011+Q_111001010*PR_020000002100+Q_111001110*PR_020000002101+Q_111101010*PR_020000002110+Q_111101110*PR_020000002111+Q_211001010*PR_020000002200+Q_211001110*PR_020000002201+Q_211101010*PR_020000002210+Q_211101110*PR_020000002211); ans_temp[ans_id*36+3]+=Pmtrx[32]*(Q_010002010*PR_020000002000+Q_010002110*PR_020000002001+Q_010102010*PR_020000002010+Q_010102110*PR_020000002011+Q_010202010*PR_020000002020+Q_010202110*PR_020000002021+Q_110002010*PR_020000002100+Q_110002110*PR_020000002101+Q_110102010*PR_020000002110+Q_110102110*PR_020000002111+Q_110202010*PR_020000002120+Q_110202110*PR_020000002121); ans_temp[ans_id*36+3]+=Pmtrx[33]*(Q_011000011*PR_020000002000+Q_011000111*PR_020000002001+Q_011000211*PR_020000002002+Q_111000011*PR_020000002100+Q_111000111*PR_020000002101+Q_111000211*PR_020000002102+Q_211000011*PR_020000002200+Q_211000111*PR_020000002201+Q_211000211*PR_020000002202); ans_temp[ans_id*36+3]+=Pmtrx[34]*(Q_010001011*PR_020000002000+Q_010001111*PR_020000002001+Q_010001211*PR_020000002002+Q_010101011*PR_020000002010+Q_010101111*PR_020000002011+Q_010101211*PR_020000002012+Q_110001011*PR_020000002100+Q_110001111*PR_020000002101+Q_110001211*PR_020000002102+Q_110101011*PR_020000002110+Q_110101111*PR_020000002111+Q_110101211*PR_020000002112); ans_temp[ans_id*36+3]+=Pmtrx[35]*(Q_010000012*PR_020000002000+Q_010000112*PR_020000002001+Q_010000212*PR_020000002002+Q_010000312*PR_020000002003+Q_110000012*PR_020000002100+Q_110000112*PR_020000002101+Q_110000212*PR_020000002102+Q_110000312*PR_020000002103); ans_temp[ans_id*36+4]+=Pmtrx[30]*(Q_002010010*PR_020000002000+Q_002010110*PR_020000002001+Q_002110010*PR_020000002010+Q_002110110*PR_020000002011+Q_102010010*PR_020000002100+Q_102010110*PR_020000002101+Q_102110010*PR_020000002110+Q_102110110*PR_020000002111+Q_202010010*PR_020000002200+Q_202010110*PR_020000002201+Q_202110010*PR_020000002210+Q_202110110*PR_020000002211); ans_temp[ans_id*36+4]+=Pmtrx[31]*(Q_001011010*PR_020000002000+Q_001011110*PR_020000002001+Q_001111010*PR_020000002010+Q_001111110*PR_020000002011+Q_001211010*PR_020000002020+Q_001211110*PR_020000002021+Q_101011010*PR_020000002100+Q_101011110*PR_020000002101+Q_101111010*PR_020000002110+Q_101111110*PR_020000002111+Q_101211010*PR_020000002120+Q_101211110*PR_020000002121); ans_temp[ans_id*36+4]+=Pmtrx[32]*(Q_000012010*PR_020000002000+Q_000012110*PR_020000002001+Q_000112010*PR_020000002010+Q_000112110*PR_020000002011+Q_000212010*PR_020000002020+Q_000212110*PR_020000002021+Q_000312010*PR_020000002030+Q_000312110*PR_020000002031); ans_temp[ans_id*36+4]+=Pmtrx[33]*(Q_001010011*PR_020000002000+Q_001010111*PR_020000002001+Q_001010211*PR_020000002002+Q_001110011*PR_020000002010+Q_001110111*PR_020000002011+Q_001110211*PR_020000002012+Q_101010011*PR_020000002100+Q_101010111*PR_020000002101+Q_101010211*PR_020000002102+Q_101110011*PR_020000002110+Q_101110111*PR_020000002111+Q_101110211*PR_020000002112); ans_temp[ans_id*36+4]+=Pmtrx[34]*(Q_000011011*PR_020000002000+Q_000011111*PR_020000002001+Q_000011211*PR_020000002002+Q_000111011*PR_020000002010+Q_000111111*PR_020000002011+Q_000111211*PR_020000002012+Q_000211011*PR_020000002020+Q_000211111*PR_020000002021+Q_000211211*PR_020000002022); ans_temp[ans_id*36+4]+=Pmtrx[35]*(Q_000010012*PR_020000002000+Q_000010112*PR_020000002001+Q_000010212*PR_020000002002+Q_000010312*PR_020000002003+Q_000110012*PR_020000002010+Q_000110112*PR_020000002011+Q_000110212*PR_020000002012+Q_000110312*PR_020000002013); ans_temp[ans_id*36+5]+=Pmtrx[30]*(Q_002000020*PR_020000002000+Q_002000120*PR_020000002001+Q_002000220*PR_020000002002+Q_102000020*PR_020000002100+Q_102000120*PR_020000002101+Q_102000220*PR_020000002102+Q_202000020*PR_020000002200+Q_202000120*PR_020000002201+Q_202000220*PR_020000002202); ans_temp[ans_id*36+5]+=Pmtrx[31]*(Q_001001020*PR_020000002000+Q_001001120*PR_020000002001+Q_001001220*PR_020000002002+Q_001101020*PR_020000002010+Q_001101120*PR_020000002011+Q_001101220*PR_020000002012+Q_101001020*PR_020000002100+Q_101001120*PR_020000002101+Q_101001220*PR_020000002102+Q_101101020*PR_020000002110+Q_101101120*PR_020000002111+Q_101101220*PR_020000002112); ans_temp[ans_id*36+5]+=Pmtrx[32]*(Q_000002020*PR_020000002000+Q_000002120*PR_020000002001+Q_000002220*PR_020000002002+Q_000102020*PR_020000002010+Q_000102120*PR_020000002011+Q_000102220*PR_020000002012+Q_000202020*PR_020000002020+Q_000202120*PR_020000002021+Q_000202220*PR_020000002022); ans_temp[ans_id*36+5]+=Pmtrx[33]*(Q_001000021*PR_020000002000+Q_001000121*PR_020000002001+Q_001000221*PR_020000002002+Q_001000321*PR_020000002003+Q_101000021*PR_020000002100+Q_101000121*PR_020000002101+Q_101000221*PR_020000002102+Q_101000321*PR_020000002103); ans_temp[ans_id*36+5]+=Pmtrx[34]*(Q_000001021*PR_020000002000+Q_000001121*PR_020000002001+Q_000001221*PR_020000002002+Q_000001321*PR_020000002003+Q_000101021*PR_020000002010+Q_000101121*PR_020000002011+Q_000101221*PR_020000002012+Q_000101321*PR_020000002013); ans_temp[ans_id*36+5]+=Pmtrx[35]*(Q_000000022*PR_020000002000+Q_000000122*PR_020000002001+Q_000000222*PR_020000002002+Q_000000322*PR_020000002003+Q_000000422*PR_020000002004); ans_temp[ans_id*36+6]+=Pmtrx[0]*(Q_022000000*PR_012010000000+Q_122000000*PR_012010000100+Q_222000000*PR_012010000200+Q_322000000*PR_012010000300+Q_422000000*PR_012010000400); ans_temp[ans_id*36+6]+=Pmtrx[1]*(Q_021001000*PR_012010000000+Q_021101000*PR_012010000010+Q_121001000*PR_012010000100+Q_121101000*PR_012010000110+Q_221001000*PR_012010000200+Q_221101000*PR_012010000210+Q_321001000*PR_012010000300+Q_321101000*PR_012010000310); ans_temp[ans_id*36+6]+=Pmtrx[2]*(Q_020002000*PR_012010000000+Q_020102000*PR_012010000010+Q_020202000*PR_012010000020+Q_120002000*PR_012010000100+Q_120102000*PR_012010000110+Q_120202000*PR_012010000120+Q_220002000*PR_012010000200+Q_220102000*PR_012010000210+Q_220202000*PR_012010000220); ans_temp[ans_id*36+6]+=Pmtrx[3]*(Q_021000001*PR_012010000000+Q_021000101*PR_012010000001+Q_121000001*PR_012010000100+Q_121000101*PR_012010000101+Q_221000001*PR_012010000200+Q_221000101*PR_012010000201+Q_321000001*PR_012010000300+Q_321000101*PR_012010000301); ans_temp[ans_id*36+6]+=Pmtrx[4]*(Q_020001001*PR_012010000000+Q_020001101*PR_012010000001+Q_020101001*PR_012010000010+Q_020101101*PR_012010000011+Q_120001001*PR_012010000100+Q_120001101*PR_012010000101+Q_120101001*PR_012010000110+Q_120101101*PR_012010000111+Q_220001001*PR_012010000200+Q_220001101*PR_012010000201+Q_220101001*PR_012010000210+Q_220101101*PR_012010000211); ans_temp[ans_id*36+6]+=Pmtrx[5]*(Q_020000002*PR_012010000000+Q_020000102*PR_012010000001+Q_020000202*PR_012010000002+Q_120000002*PR_012010000100+Q_120000102*PR_012010000101+Q_120000202*PR_012010000102+Q_220000002*PR_012010000200+Q_220000102*PR_012010000201+Q_220000202*PR_012010000202); ans_temp[ans_id*36+7]+=Pmtrx[0]*(Q_012010000*PR_012010000000+Q_012110000*PR_012010000010+Q_112010000*PR_012010000100+Q_112110000*PR_012010000110+Q_212010000*PR_012010000200+Q_212110000*PR_012010000210+Q_312010000*PR_012010000300+Q_312110000*PR_012010000310); ans_temp[ans_id*36+7]+=Pmtrx[1]*(Q_011011000*PR_012010000000+Q_011111000*PR_012010000010+Q_011211000*PR_012010000020+Q_111011000*PR_012010000100+Q_111111000*PR_012010000110+Q_111211000*PR_012010000120+Q_211011000*PR_012010000200+Q_211111000*PR_012010000210+Q_211211000*PR_012010000220); ans_temp[ans_id*36+7]+=Pmtrx[2]*(Q_010012000*PR_012010000000+Q_010112000*PR_012010000010+Q_010212000*PR_012010000020+Q_010312000*PR_012010000030+Q_110012000*PR_012010000100+Q_110112000*PR_012010000110+Q_110212000*PR_012010000120+Q_110312000*PR_012010000130); ans_temp[ans_id*36+7]+=Pmtrx[3]*(Q_011010001*PR_012010000000+Q_011010101*PR_012010000001+Q_011110001*PR_012010000010+Q_011110101*PR_012010000011+Q_111010001*PR_012010000100+Q_111010101*PR_012010000101+Q_111110001*PR_012010000110+Q_111110101*PR_012010000111+Q_211010001*PR_012010000200+Q_211010101*PR_012010000201+Q_211110001*PR_012010000210+Q_211110101*PR_012010000211); ans_temp[ans_id*36+7]+=Pmtrx[4]*(Q_010011001*PR_012010000000+Q_010011101*PR_012010000001+Q_010111001*PR_012010000010+Q_010111101*PR_012010000011+Q_010211001*PR_012010000020+Q_010211101*PR_012010000021+Q_110011001*PR_012010000100+Q_110011101*PR_012010000101+Q_110111001*PR_012010000110+Q_110111101*PR_012010000111+Q_110211001*PR_012010000120+Q_110211101*PR_012010000121); ans_temp[ans_id*36+7]+=Pmtrx[5]*(Q_010010002*PR_012010000000+Q_010010102*PR_012010000001+Q_010010202*PR_012010000002+Q_010110002*PR_012010000010+Q_010110102*PR_012010000011+Q_010110202*PR_012010000012+Q_110010002*PR_012010000100+Q_110010102*PR_012010000101+Q_110010202*PR_012010000102+Q_110110002*PR_012010000110+Q_110110102*PR_012010000111+Q_110110202*PR_012010000112); ans_temp[ans_id*36+8]+=Pmtrx[0]*(Q_002020000*PR_012010000000+Q_002120000*PR_012010000010+Q_002220000*PR_012010000020+Q_102020000*PR_012010000100+Q_102120000*PR_012010000110+Q_102220000*PR_012010000120+Q_202020000*PR_012010000200+Q_202120000*PR_012010000210+Q_202220000*PR_012010000220); ans_temp[ans_id*36+8]+=Pmtrx[1]*(Q_001021000*PR_012010000000+Q_001121000*PR_012010000010+Q_001221000*PR_012010000020+Q_001321000*PR_012010000030+Q_101021000*PR_012010000100+Q_101121000*PR_012010000110+Q_101221000*PR_012010000120+Q_101321000*PR_012010000130); ans_temp[ans_id*36+8]+=Pmtrx[2]*(Q_000022000*PR_012010000000+Q_000122000*PR_012010000010+Q_000222000*PR_012010000020+Q_000322000*PR_012010000030+Q_000422000*PR_012010000040); ans_temp[ans_id*36+8]+=Pmtrx[3]*(Q_001020001*PR_012010000000+Q_001020101*PR_012010000001+Q_001120001*PR_012010000010+Q_001120101*PR_012010000011+Q_001220001*PR_012010000020+Q_001220101*PR_012010000021+Q_101020001*PR_012010000100+Q_101020101*PR_012010000101+Q_101120001*PR_012010000110+Q_101120101*PR_012010000111+Q_101220001*PR_012010000120+Q_101220101*PR_012010000121); ans_temp[ans_id*36+8]+=Pmtrx[4]*(Q_000021001*PR_012010000000+Q_000021101*PR_012010000001+Q_000121001*PR_012010000010+Q_000121101*PR_012010000011+Q_000221001*PR_012010000020+Q_000221101*PR_012010000021+Q_000321001*PR_012010000030+Q_000321101*PR_012010000031); ans_temp[ans_id*36+8]+=Pmtrx[5]*(Q_000020002*PR_012010000000+Q_000020102*PR_012010000001+Q_000020202*PR_012010000002+Q_000120002*PR_012010000010+Q_000120102*PR_012010000011+Q_000120202*PR_012010000012+Q_000220002*PR_012010000020+Q_000220102*PR_012010000021+Q_000220202*PR_012010000022); ans_temp[ans_id*36+9]+=Pmtrx[0]*(Q_012000010*PR_012010000000+Q_012000110*PR_012010000001+Q_112000010*PR_012010000100+Q_112000110*PR_012010000101+Q_212000010*PR_012010000200+Q_212000110*PR_012010000201+Q_312000010*PR_012010000300+Q_312000110*PR_012010000301); ans_temp[ans_id*36+9]+=Pmtrx[1]*(Q_011001010*PR_012010000000+Q_011001110*PR_012010000001+Q_011101010*PR_012010000010+Q_011101110*PR_012010000011+Q_111001010*PR_012010000100+Q_111001110*PR_012010000101+Q_111101010*PR_012010000110+Q_111101110*PR_012010000111+Q_211001010*PR_012010000200+Q_211001110*PR_012010000201+Q_211101010*PR_012010000210+Q_211101110*PR_012010000211); ans_temp[ans_id*36+9]+=Pmtrx[2]*(Q_010002010*PR_012010000000+Q_010002110*PR_012010000001+Q_010102010*PR_012010000010+Q_010102110*PR_012010000011+Q_010202010*PR_012010000020+Q_010202110*PR_012010000021+Q_110002010*PR_012010000100+Q_110002110*PR_012010000101+Q_110102010*PR_012010000110+Q_110102110*PR_012010000111+Q_110202010*PR_012010000120+Q_110202110*PR_012010000121); ans_temp[ans_id*36+9]+=Pmtrx[3]*(Q_011000011*PR_012010000000+Q_011000111*PR_012010000001+Q_011000211*PR_012010000002+Q_111000011*PR_012010000100+Q_111000111*PR_012010000101+Q_111000211*PR_012010000102+Q_211000011*PR_012010000200+Q_211000111*PR_012010000201+Q_211000211*PR_012010000202); ans_temp[ans_id*36+9]+=Pmtrx[4]*(Q_010001011*PR_012010000000+Q_010001111*PR_012010000001+Q_010001211*PR_012010000002+Q_010101011*PR_012010000010+Q_010101111*PR_012010000011+Q_010101211*PR_012010000012+Q_110001011*PR_012010000100+Q_110001111*PR_012010000101+Q_110001211*PR_012010000102+Q_110101011*PR_012010000110+Q_110101111*PR_012010000111+Q_110101211*PR_012010000112); ans_temp[ans_id*36+9]+=Pmtrx[5]*(Q_010000012*PR_012010000000+Q_010000112*PR_012010000001+Q_010000212*PR_012010000002+Q_010000312*PR_012010000003+Q_110000012*PR_012010000100+Q_110000112*PR_012010000101+Q_110000212*PR_012010000102+Q_110000312*PR_012010000103); ans_temp[ans_id*36+10]+=Pmtrx[0]*(Q_002010010*PR_012010000000+Q_002010110*PR_012010000001+Q_002110010*PR_012010000010+Q_002110110*PR_012010000011+Q_102010010*PR_012010000100+Q_102010110*PR_012010000101+Q_102110010*PR_012010000110+Q_102110110*PR_012010000111+Q_202010010*PR_012010000200+Q_202010110*PR_012010000201+Q_202110010*PR_012010000210+Q_202110110*PR_012010000211); ans_temp[ans_id*36+10]+=Pmtrx[1]*(Q_001011010*PR_012010000000+Q_001011110*PR_012010000001+Q_001111010*PR_012010000010+Q_001111110*PR_012010000011+Q_001211010*PR_012010000020+Q_001211110*PR_012010000021+Q_101011010*PR_012010000100+Q_101011110*PR_012010000101+Q_101111010*PR_012010000110+Q_101111110*PR_012010000111+Q_101211010*PR_012010000120+Q_101211110*PR_012010000121); ans_temp[ans_id*36+10]+=Pmtrx[2]*(Q_000012010*PR_012010000000+Q_000012110*PR_012010000001+Q_000112010*PR_012010000010+Q_000112110*PR_012010000011+Q_000212010*PR_012010000020+Q_000212110*PR_012010000021+Q_000312010*PR_012010000030+Q_000312110*PR_012010000031); ans_temp[ans_id*36+10]+=Pmtrx[3]*(Q_001010011*PR_012010000000+Q_001010111*PR_012010000001+Q_001010211*PR_012010000002+Q_001110011*PR_012010000010+Q_001110111*PR_012010000011+Q_001110211*PR_012010000012+Q_101010011*PR_012010000100+Q_101010111*PR_012010000101+Q_101010211*PR_012010000102+Q_101110011*PR_012010000110+Q_101110111*PR_012010000111+Q_101110211*PR_012010000112); ans_temp[ans_id*36+10]+=Pmtrx[4]*(Q_000011011*PR_012010000000+Q_000011111*PR_012010000001+Q_000011211*PR_012010000002+Q_000111011*PR_012010000010+Q_000111111*PR_012010000011+Q_000111211*PR_012010000012+Q_000211011*PR_012010000020+Q_000211111*PR_012010000021+Q_000211211*PR_012010000022); ans_temp[ans_id*36+10]+=Pmtrx[5]*(Q_000010012*PR_012010000000+Q_000010112*PR_012010000001+Q_000010212*PR_012010000002+Q_000010312*PR_012010000003+Q_000110012*PR_012010000010+Q_000110112*PR_012010000011+Q_000110212*PR_012010000012+Q_000110312*PR_012010000013); ans_temp[ans_id*36+11]+=Pmtrx[0]*(Q_002000020*PR_012010000000+Q_002000120*PR_012010000001+Q_002000220*PR_012010000002+Q_102000020*PR_012010000100+Q_102000120*PR_012010000101+Q_102000220*PR_012010000102+Q_202000020*PR_012010000200+Q_202000120*PR_012010000201+Q_202000220*PR_012010000202); ans_temp[ans_id*36+11]+=Pmtrx[1]*(Q_001001020*PR_012010000000+Q_001001120*PR_012010000001+Q_001001220*PR_012010000002+Q_001101020*PR_012010000010+Q_001101120*PR_012010000011+Q_001101220*PR_012010000012+Q_101001020*PR_012010000100+Q_101001120*PR_012010000101+Q_101001220*PR_012010000102+Q_101101020*PR_012010000110+Q_101101120*PR_012010000111+Q_101101220*PR_012010000112); ans_temp[ans_id*36+11]+=Pmtrx[2]*(Q_000002020*PR_012010000000+Q_000002120*PR_012010000001+Q_000002220*PR_012010000002+Q_000102020*PR_012010000010+Q_000102120*PR_012010000011+Q_000102220*PR_012010000012+Q_000202020*PR_012010000020+Q_000202120*PR_012010000021+Q_000202220*PR_012010000022); ans_temp[ans_id*36+11]+=Pmtrx[3]*(Q_001000021*PR_012010000000+Q_001000121*PR_012010000001+Q_001000221*PR_012010000002+Q_001000321*PR_012010000003+Q_101000021*PR_012010000100+Q_101000121*PR_012010000101+Q_101000221*PR_012010000102+Q_101000321*PR_012010000103); ans_temp[ans_id*36+11]+=Pmtrx[4]*(Q_000001021*PR_012010000000+Q_000001121*PR_012010000001+Q_000001221*PR_012010000002+Q_000001321*PR_012010000003+Q_000101021*PR_012010000010+Q_000101121*PR_012010000011+Q_000101221*PR_012010000012+Q_000101321*PR_012010000013); ans_temp[ans_id*36+11]+=Pmtrx[5]*(Q_000000022*PR_012010000000+Q_000000122*PR_012010000001+Q_000000222*PR_012010000002+Q_000000322*PR_012010000003+Q_000000422*PR_012010000004); ans_temp[ans_id*36+6]+=Pmtrx[6]*(Q_022000000*PR_011011000000+Q_122000000*PR_011011000100+Q_222000000*PR_011011000200+Q_322000000*PR_011011000300+Q_422000000*PR_011011000400); ans_temp[ans_id*36+6]+=Pmtrx[7]*(Q_021001000*PR_011011000000+Q_021101000*PR_011011000010+Q_121001000*PR_011011000100+Q_121101000*PR_011011000110+Q_221001000*PR_011011000200+Q_221101000*PR_011011000210+Q_321001000*PR_011011000300+Q_321101000*PR_011011000310); ans_temp[ans_id*36+6]+=Pmtrx[8]*(Q_020002000*PR_011011000000+Q_020102000*PR_011011000010+Q_020202000*PR_011011000020+Q_120002000*PR_011011000100+Q_120102000*PR_011011000110+Q_120202000*PR_011011000120+Q_220002000*PR_011011000200+Q_220102000*PR_011011000210+Q_220202000*PR_011011000220); ans_temp[ans_id*36+6]+=Pmtrx[9]*(Q_021000001*PR_011011000000+Q_021000101*PR_011011000001+Q_121000001*PR_011011000100+Q_121000101*PR_011011000101+Q_221000001*PR_011011000200+Q_221000101*PR_011011000201+Q_321000001*PR_011011000300+Q_321000101*PR_011011000301); ans_temp[ans_id*36+6]+=Pmtrx[10]*(Q_020001001*PR_011011000000+Q_020001101*PR_011011000001+Q_020101001*PR_011011000010+Q_020101101*PR_011011000011+Q_120001001*PR_011011000100+Q_120001101*PR_011011000101+Q_120101001*PR_011011000110+Q_120101101*PR_011011000111+Q_220001001*PR_011011000200+Q_220001101*PR_011011000201+Q_220101001*PR_011011000210+Q_220101101*PR_011011000211); ans_temp[ans_id*36+6]+=Pmtrx[11]*(Q_020000002*PR_011011000000+Q_020000102*PR_011011000001+Q_020000202*PR_011011000002+Q_120000002*PR_011011000100+Q_120000102*PR_011011000101+Q_120000202*PR_011011000102+Q_220000002*PR_011011000200+Q_220000102*PR_011011000201+Q_220000202*PR_011011000202); ans_temp[ans_id*36+7]+=Pmtrx[6]*(Q_012010000*PR_011011000000+Q_012110000*PR_011011000010+Q_112010000*PR_011011000100+Q_112110000*PR_011011000110+Q_212010000*PR_011011000200+Q_212110000*PR_011011000210+Q_312010000*PR_011011000300+Q_312110000*PR_011011000310); ans_temp[ans_id*36+7]+=Pmtrx[7]*(Q_011011000*PR_011011000000+Q_011111000*PR_011011000010+Q_011211000*PR_011011000020+Q_111011000*PR_011011000100+Q_111111000*PR_011011000110+Q_111211000*PR_011011000120+Q_211011000*PR_011011000200+Q_211111000*PR_011011000210+Q_211211000*PR_011011000220); ans_temp[ans_id*36+7]+=Pmtrx[8]*(Q_010012000*PR_011011000000+Q_010112000*PR_011011000010+Q_010212000*PR_011011000020+Q_010312000*PR_011011000030+Q_110012000*PR_011011000100+Q_110112000*PR_011011000110+Q_110212000*PR_011011000120+Q_110312000*PR_011011000130); ans_temp[ans_id*36+7]+=Pmtrx[9]*(Q_011010001*PR_011011000000+Q_011010101*PR_011011000001+Q_011110001*PR_011011000010+Q_011110101*PR_011011000011+Q_111010001*PR_011011000100+Q_111010101*PR_011011000101+Q_111110001*PR_011011000110+Q_111110101*PR_011011000111+Q_211010001*PR_011011000200+Q_211010101*PR_011011000201+Q_211110001*PR_011011000210+Q_211110101*PR_011011000211); ans_temp[ans_id*36+7]+=Pmtrx[10]*(Q_010011001*PR_011011000000+Q_010011101*PR_011011000001+Q_010111001*PR_011011000010+Q_010111101*PR_011011000011+Q_010211001*PR_011011000020+Q_010211101*PR_011011000021+Q_110011001*PR_011011000100+Q_110011101*PR_011011000101+Q_110111001*PR_011011000110+Q_110111101*PR_011011000111+Q_110211001*PR_011011000120+Q_110211101*PR_011011000121); ans_temp[ans_id*36+7]+=Pmtrx[11]*(Q_010010002*PR_011011000000+Q_010010102*PR_011011000001+Q_010010202*PR_011011000002+Q_010110002*PR_011011000010+Q_010110102*PR_011011000011+Q_010110202*PR_011011000012+Q_110010002*PR_011011000100+Q_110010102*PR_011011000101+Q_110010202*PR_011011000102+Q_110110002*PR_011011000110+Q_110110102*PR_011011000111+Q_110110202*PR_011011000112); ans_temp[ans_id*36+8]+=Pmtrx[6]*(Q_002020000*PR_011011000000+Q_002120000*PR_011011000010+Q_002220000*PR_011011000020+Q_102020000*PR_011011000100+Q_102120000*PR_011011000110+Q_102220000*PR_011011000120+Q_202020000*PR_011011000200+Q_202120000*PR_011011000210+Q_202220000*PR_011011000220); ans_temp[ans_id*36+8]+=Pmtrx[7]*(Q_001021000*PR_011011000000+Q_001121000*PR_011011000010+Q_001221000*PR_011011000020+Q_001321000*PR_011011000030+Q_101021000*PR_011011000100+Q_101121000*PR_011011000110+Q_101221000*PR_011011000120+Q_101321000*PR_011011000130); ans_temp[ans_id*36+8]+=Pmtrx[8]*(Q_000022000*PR_011011000000+Q_000122000*PR_011011000010+Q_000222000*PR_011011000020+Q_000322000*PR_011011000030+Q_000422000*PR_011011000040); ans_temp[ans_id*36+8]+=Pmtrx[9]*(Q_001020001*PR_011011000000+Q_001020101*PR_011011000001+Q_001120001*PR_011011000010+Q_001120101*PR_011011000011+Q_001220001*PR_011011000020+Q_001220101*PR_011011000021+Q_101020001*PR_011011000100+Q_101020101*PR_011011000101+Q_101120001*PR_011011000110+Q_101120101*PR_011011000111+Q_101220001*PR_011011000120+Q_101220101*PR_011011000121); ans_temp[ans_id*36+8]+=Pmtrx[10]*(Q_000021001*PR_011011000000+Q_000021101*PR_011011000001+Q_000121001*PR_011011000010+Q_000121101*PR_011011000011+Q_000221001*PR_011011000020+Q_000221101*PR_011011000021+Q_000321001*PR_011011000030+Q_000321101*PR_011011000031); ans_temp[ans_id*36+8]+=Pmtrx[11]*(Q_000020002*PR_011011000000+Q_000020102*PR_011011000001+Q_000020202*PR_011011000002+Q_000120002*PR_011011000010+Q_000120102*PR_011011000011+Q_000120202*PR_011011000012+Q_000220002*PR_011011000020+Q_000220102*PR_011011000021+Q_000220202*PR_011011000022); ans_temp[ans_id*36+9]+=Pmtrx[6]*(Q_012000010*PR_011011000000+Q_012000110*PR_011011000001+Q_112000010*PR_011011000100+Q_112000110*PR_011011000101+Q_212000010*PR_011011000200+Q_212000110*PR_011011000201+Q_312000010*PR_011011000300+Q_312000110*PR_011011000301); ans_temp[ans_id*36+9]+=Pmtrx[7]*(Q_011001010*PR_011011000000+Q_011001110*PR_011011000001+Q_011101010*PR_011011000010+Q_011101110*PR_011011000011+Q_111001010*PR_011011000100+Q_111001110*PR_011011000101+Q_111101010*PR_011011000110+Q_111101110*PR_011011000111+Q_211001010*PR_011011000200+Q_211001110*PR_011011000201+Q_211101010*PR_011011000210+Q_211101110*PR_011011000211); ans_temp[ans_id*36+9]+=Pmtrx[8]*(Q_010002010*PR_011011000000+Q_010002110*PR_011011000001+Q_010102010*PR_011011000010+Q_010102110*PR_011011000011+Q_010202010*PR_011011000020+Q_010202110*PR_011011000021+Q_110002010*PR_011011000100+Q_110002110*PR_011011000101+Q_110102010*PR_011011000110+Q_110102110*PR_011011000111+Q_110202010*PR_011011000120+Q_110202110*PR_011011000121); ans_temp[ans_id*36+9]+=Pmtrx[9]*(Q_011000011*PR_011011000000+Q_011000111*PR_011011000001+Q_011000211*PR_011011000002+Q_111000011*PR_011011000100+Q_111000111*PR_011011000101+Q_111000211*PR_011011000102+Q_211000011*PR_011011000200+Q_211000111*PR_011011000201+Q_211000211*PR_011011000202); ans_temp[ans_id*36+9]+=Pmtrx[10]*(Q_010001011*PR_011011000000+Q_010001111*PR_011011000001+Q_010001211*PR_011011000002+Q_010101011*PR_011011000010+Q_010101111*PR_011011000011+Q_010101211*PR_011011000012+Q_110001011*PR_011011000100+Q_110001111*PR_011011000101+Q_110001211*PR_011011000102+Q_110101011*PR_011011000110+Q_110101111*PR_011011000111+Q_110101211*PR_011011000112); ans_temp[ans_id*36+9]+=Pmtrx[11]*(Q_010000012*PR_011011000000+Q_010000112*PR_011011000001+Q_010000212*PR_011011000002+Q_010000312*PR_011011000003+Q_110000012*PR_011011000100+Q_110000112*PR_011011000101+Q_110000212*PR_011011000102+Q_110000312*PR_011011000103); ans_temp[ans_id*36+10]+=Pmtrx[6]*(Q_002010010*PR_011011000000+Q_002010110*PR_011011000001+Q_002110010*PR_011011000010+Q_002110110*PR_011011000011+Q_102010010*PR_011011000100+Q_102010110*PR_011011000101+Q_102110010*PR_011011000110+Q_102110110*PR_011011000111+Q_202010010*PR_011011000200+Q_202010110*PR_011011000201+Q_202110010*PR_011011000210+Q_202110110*PR_011011000211); ans_temp[ans_id*36+10]+=Pmtrx[7]*(Q_001011010*PR_011011000000+Q_001011110*PR_011011000001+Q_001111010*PR_011011000010+Q_001111110*PR_011011000011+Q_001211010*PR_011011000020+Q_001211110*PR_011011000021+Q_101011010*PR_011011000100+Q_101011110*PR_011011000101+Q_101111010*PR_011011000110+Q_101111110*PR_011011000111+Q_101211010*PR_011011000120+Q_101211110*PR_011011000121); ans_temp[ans_id*36+10]+=Pmtrx[8]*(Q_000012010*PR_011011000000+Q_000012110*PR_011011000001+Q_000112010*PR_011011000010+Q_000112110*PR_011011000011+Q_000212010*PR_011011000020+Q_000212110*PR_011011000021+Q_000312010*PR_011011000030+Q_000312110*PR_011011000031); ans_temp[ans_id*36+10]+=Pmtrx[9]*(Q_001010011*PR_011011000000+Q_001010111*PR_011011000001+Q_001010211*PR_011011000002+Q_001110011*PR_011011000010+Q_001110111*PR_011011000011+Q_001110211*PR_011011000012+Q_101010011*PR_011011000100+Q_101010111*PR_011011000101+Q_101010211*PR_011011000102+Q_101110011*PR_011011000110+Q_101110111*PR_011011000111+Q_101110211*PR_011011000112); ans_temp[ans_id*36+10]+=Pmtrx[10]*(Q_000011011*PR_011011000000+Q_000011111*PR_011011000001+Q_000011211*PR_011011000002+Q_000111011*PR_011011000010+Q_000111111*PR_011011000011+Q_000111211*PR_011011000012+Q_000211011*PR_011011000020+Q_000211111*PR_011011000021+Q_000211211*PR_011011000022); ans_temp[ans_id*36+10]+=Pmtrx[11]*(Q_000010012*PR_011011000000+Q_000010112*PR_011011000001+Q_000010212*PR_011011000002+Q_000010312*PR_011011000003+Q_000110012*PR_011011000010+Q_000110112*PR_011011000011+Q_000110212*PR_011011000012+Q_000110312*PR_011011000013); ans_temp[ans_id*36+11]+=Pmtrx[6]*(Q_002000020*PR_011011000000+Q_002000120*PR_011011000001+Q_002000220*PR_011011000002+Q_102000020*PR_011011000100+Q_102000120*PR_011011000101+Q_102000220*PR_011011000102+Q_202000020*PR_011011000200+Q_202000120*PR_011011000201+Q_202000220*PR_011011000202); ans_temp[ans_id*36+11]+=Pmtrx[7]*(Q_001001020*PR_011011000000+Q_001001120*PR_011011000001+Q_001001220*PR_011011000002+Q_001101020*PR_011011000010+Q_001101120*PR_011011000011+Q_001101220*PR_011011000012+Q_101001020*PR_011011000100+Q_101001120*PR_011011000101+Q_101001220*PR_011011000102+Q_101101020*PR_011011000110+Q_101101120*PR_011011000111+Q_101101220*PR_011011000112); ans_temp[ans_id*36+11]+=Pmtrx[8]*(Q_000002020*PR_011011000000+Q_000002120*PR_011011000001+Q_000002220*PR_011011000002+Q_000102020*PR_011011000010+Q_000102120*PR_011011000011+Q_000102220*PR_011011000012+Q_000202020*PR_011011000020+Q_000202120*PR_011011000021+Q_000202220*PR_011011000022); ans_temp[ans_id*36+11]+=Pmtrx[9]*(Q_001000021*PR_011011000000+Q_001000121*PR_011011000001+Q_001000221*PR_011011000002+Q_001000321*PR_011011000003+Q_101000021*PR_011011000100+Q_101000121*PR_011011000101+Q_101000221*PR_011011000102+Q_101000321*PR_011011000103); ans_temp[ans_id*36+11]+=Pmtrx[10]*(Q_000001021*PR_011011000000+Q_000001121*PR_011011000001+Q_000001221*PR_011011000002+Q_000001321*PR_011011000003+Q_000101021*PR_011011000010+Q_000101121*PR_011011000011+Q_000101221*PR_011011000012+Q_000101321*PR_011011000013); ans_temp[ans_id*36+11]+=Pmtrx[11]*(Q_000000022*PR_011011000000+Q_000000122*PR_011011000001+Q_000000222*PR_011011000002+Q_000000322*PR_011011000003+Q_000000422*PR_011011000004); ans_temp[ans_id*36+6]+=Pmtrx[12]*(Q_022000000*PR_010012000000+Q_122000000*PR_010012000100+Q_222000000*PR_010012000200+Q_322000000*PR_010012000300+Q_422000000*PR_010012000400); ans_temp[ans_id*36+6]+=Pmtrx[13]*(Q_021001000*PR_010012000000+Q_021101000*PR_010012000010+Q_121001000*PR_010012000100+Q_121101000*PR_010012000110+Q_221001000*PR_010012000200+Q_221101000*PR_010012000210+Q_321001000*PR_010012000300+Q_321101000*PR_010012000310); ans_temp[ans_id*36+6]+=Pmtrx[14]*(Q_020002000*PR_010012000000+Q_020102000*PR_010012000010+Q_020202000*PR_010012000020+Q_120002000*PR_010012000100+Q_120102000*PR_010012000110+Q_120202000*PR_010012000120+Q_220002000*PR_010012000200+Q_220102000*PR_010012000210+Q_220202000*PR_010012000220); ans_temp[ans_id*36+6]+=Pmtrx[15]*(Q_021000001*PR_010012000000+Q_021000101*PR_010012000001+Q_121000001*PR_010012000100+Q_121000101*PR_010012000101+Q_221000001*PR_010012000200+Q_221000101*PR_010012000201+Q_321000001*PR_010012000300+Q_321000101*PR_010012000301); ans_temp[ans_id*36+6]+=Pmtrx[16]*(Q_020001001*PR_010012000000+Q_020001101*PR_010012000001+Q_020101001*PR_010012000010+Q_020101101*PR_010012000011+Q_120001001*PR_010012000100+Q_120001101*PR_010012000101+Q_120101001*PR_010012000110+Q_120101101*PR_010012000111+Q_220001001*PR_010012000200+Q_220001101*PR_010012000201+Q_220101001*PR_010012000210+Q_220101101*PR_010012000211); ans_temp[ans_id*36+6]+=Pmtrx[17]*(Q_020000002*PR_010012000000+Q_020000102*PR_010012000001+Q_020000202*PR_010012000002+Q_120000002*PR_010012000100+Q_120000102*PR_010012000101+Q_120000202*PR_010012000102+Q_220000002*PR_010012000200+Q_220000102*PR_010012000201+Q_220000202*PR_010012000202); ans_temp[ans_id*36+7]+=Pmtrx[12]*(Q_012010000*PR_010012000000+Q_012110000*PR_010012000010+Q_112010000*PR_010012000100+Q_112110000*PR_010012000110+Q_212010000*PR_010012000200+Q_212110000*PR_010012000210+Q_312010000*PR_010012000300+Q_312110000*PR_010012000310); ans_temp[ans_id*36+7]+=Pmtrx[13]*(Q_011011000*PR_010012000000+Q_011111000*PR_010012000010+Q_011211000*PR_010012000020+Q_111011000*PR_010012000100+Q_111111000*PR_010012000110+Q_111211000*PR_010012000120+Q_211011000*PR_010012000200+Q_211111000*PR_010012000210+Q_211211000*PR_010012000220); ans_temp[ans_id*36+7]+=Pmtrx[14]*(Q_010012000*PR_010012000000+Q_010112000*PR_010012000010+Q_010212000*PR_010012000020+Q_010312000*PR_010012000030+Q_110012000*PR_010012000100+Q_110112000*PR_010012000110+Q_110212000*PR_010012000120+Q_110312000*PR_010012000130); ans_temp[ans_id*36+7]+=Pmtrx[15]*(Q_011010001*PR_010012000000+Q_011010101*PR_010012000001+Q_011110001*PR_010012000010+Q_011110101*PR_010012000011+Q_111010001*PR_010012000100+Q_111010101*PR_010012000101+Q_111110001*PR_010012000110+Q_111110101*PR_010012000111+Q_211010001*PR_010012000200+Q_211010101*PR_010012000201+Q_211110001*PR_010012000210+Q_211110101*PR_010012000211); ans_temp[ans_id*36+7]+=Pmtrx[16]*(Q_010011001*PR_010012000000+Q_010011101*PR_010012000001+Q_010111001*PR_010012000010+Q_010111101*PR_010012000011+Q_010211001*PR_010012000020+Q_010211101*PR_010012000021+Q_110011001*PR_010012000100+Q_110011101*PR_010012000101+Q_110111001*PR_010012000110+Q_110111101*PR_010012000111+Q_110211001*PR_010012000120+Q_110211101*PR_010012000121); ans_temp[ans_id*36+7]+=Pmtrx[17]*(Q_010010002*PR_010012000000+Q_010010102*PR_010012000001+Q_010010202*PR_010012000002+Q_010110002*PR_010012000010+Q_010110102*PR_010012000011+Q_010110202*PR_010012000012+Q_110010002*PR_010012000100+Q_110010102*PR_010012000101+Q_110010202*PR_010012000102+Q_110110002*PR_010012000110+Q_110110102*PR_010012000111+Q_110110202*PR_010012000112); ans_temp[ans_id*36+8]+=Pmtrx[12]*(Q_002020000*PR_010012000000+Q_002120000*PR_010012000010+Q_002220000*PR_010012000020+Q_102020000*PR_010012000100+Q_102120000*PR_010012000110+Q_102220000*PR_010012000120+Q_202020000*PR_010012000200+Q_202120000*PR_010012000210+Q_202220000*PR_010012000220); ans_temp[ans_id*36+8]+=Pmtrx[13]*(Q_001021000*PR_010012000000+Q_001121000*PR_010012000010+Q_001221000*PR_010012000020+Q_001321000*PR_010012000030+Q_101021000*PR_010012000100+Q_101121000*PR_010012000110+Q_101221000*PR_010012000120+Q_101321000*PR_010012000130); ans_temp[ans_id*36+8]+=Pmtrx[14]*(Q_000022000*PR_010012000000+Q_000122000*PR_010012000010+Q_000222000*PR_010012000020+Q_000322000*PR_010012000030+Q_000422000*PR_010012000040); ans_temp[ans_id*36+8]+=Pmtrx[15]*(Q_001020001*PR_010012000000+Q_001020101*PR_010012000001+Q_001120001*PR_010012000010+Q_001120101*PR_010012000011+Q_001220001*PR_010012000020+Q_001220101*PR_010012000021+Q_101020001*PR_010012000100+Q_101020101*PR_010012000101+Q_101120001*PR_010012000110+Q_101120101*PR_010012000111+Q_101220001*PR_010012000120+Q_101220101*PR_010012000121); ans_temp[ans_id*36+8]+=Pmtrx[16]*(Q_000021001*PR_010012000000+Q_000021101*PR_010012000001+Q_000121001*PR_010012000010+Q_000121101*PR_010012000011+Q_000221001*PR_010012000020+Q_000221101*PR_010012000021+Q_000321001*PR_010012000030+Q_000321101*PR_010012000031); ans_temp[ans_id*36+8]+=Pmtrx[17]*(Q_000020002*PR_010012000000+Q_000020102*PR_010012000001+Q_000020202*PR_010012000002+Q_000120002*PR_010012000010+Q_000120102*PR_010012000011+Q_000120202*PR_010012000012+Q_000220002*PR_010012000020+Q_000220102*PR_010012000021+Q_000220202*PR_010012000022); ans_temp[ans_id*36+9]+=Pmtrx[12]*(Q_012000010*PR_010012000000+Q_012000110*PR_010012000001+Q_112000010*PR_010012000100+Q_112000110*PR_010012000101+Q_212000010*PR_010012000200+Q_212000110*PR_010012000201+Q_312000010*PR_010012000300+Q_312000110*PR_010012000301); ans_temp[ans_id*36+9]+=Pmtrx[13]*(Q_011001010*PR_010012000000+Q_011001110*PR_010012000001+Q_011101010*PR_010012000010+Q_011101110*PR_010012000011+Q_111001010*PR_010012000100+Q_111001110*PR_010012000101+Q_111101010*PR_010012000110+Q_111101110*PR_010012000111+Q_211001010*PR_010012000200+Q_211001110*PR_010012000201+Q_211101010*PR_010012000210+Q_211101110*PR_010012000211); ans_temp[ans_id*36+9]+=Pmtrx[14]*(Q_010002010*PR_010012000000+Q_010002110*PR_010012000001+Q_010102010*PR_010012000010+Q_010102110*PR_010012000011+Q_010202010*PR_010012000020+Q_010202110*PR_010012000021+Q_110002010*PR_010012000100+Q_110002110*PR_010012000101+Q_110102010*PR_010012000110+Q_110102110*PR_010012000111+Q_110202010*PR_010012000120+Q_110202110*PR_010012000121); ans_temp[ans_id*36+9]+=Pmtrx[15]*(Q_011000011*PR_010012000000+Q_011000111*PR_010012000001+Q_011000211*PR_010012000002+Q_111000011*PR_010012000100+Q_111000111*PR_010012000101+Q_111000211*PR_010012000102+Q_211000011*PR_010012000200+Q_211000111*PR_010012000201+Q_211000211*PR_010012000202); ans_temp[ans_id*36+9]+=Pmtrx[16]*(Q_010001011*PR_010012000000+Q_010001111*PR_010012000001+Q_010001211*PR_010012000002+Q_010101011*PR_010012000010+Q_010101111*PR_010012000011+Q_010101211*PR_010012000012+Q_110001011*PR_010012000100+Q_110001111*PR_010012000101+Q_110001211*PR_010012000102+Q_110101011*PR_010012000110+Q_110101111*PR_010012000111+Q_110101211*PR_010012000112); ans_temp[ans_id*36+9]+=Pmtrx[17]*(Q_010000012*PR_010012000000+Q_010000112*PR_010012000001+Q_010000212*PR_010012000002+Q_010000312*PR_010012000003+Q_110000012*PR_010012000100+Q_110000112*PR_010012000101+Q_110000212*PR_010012000102+Q_110000312*PR_010012000103); ans_temp[ans_id*36+10]+=Pmtrx[12]*(Q_002010010*PR_010012000000+Q_002010110*PR_010012000001+Q_002110010*PR_010012000010+Q_002110110*PR_010012000011+Q_102010010*PR_010012000100+Q_102010110*PR_010012000101+Q_102110010*PR_010012000110+Q_102110110*PR_010012000111+Q_202010010*PR_010012000200+Q_202010110*PR_010012000201+Q_202110010*PR_010012000210+Q_202110110*PR_010012000211); ans_temp[ans_id*36+10]+=Pmtrx[13]*(Q_001011010*PR_010012000000+Q_001011110*PR_010012000001+Q_001111010*PR_010012000010+Q_001111110*PR_010012000011+Q_001211010*PR_010012000020+Q_001211110*PR_010012000021+Q_101011010*PR_010012000100+Q_101011110*PR_010012000101+Q_101111010*PR_010012000110+Q_101111110*PR_010012000111+Q_101211010*PR_010012000120+Q_101211110*PR_010012000121); ans_temp[ans_id*36+10]+=Pmtrx[14]*(Q_000012010*PR_010012000000+Q_000012110*PR_010012000001+Q_000112010*PR_010012000010+Q_000112110*PR_010012000011+Q_000212010*PR_010012000020+Q_000212110*PR_010012000021+Q_000312010*PR_010012000030+Q_000312110*PR_010012000031); ans_temp[ans_id*36+10]+=Pmtrx[15]*(Q_001010011*PR_010012000000+Q_001010111*PR_010012000001+Q_001010211*PR_010012000002+Q_001110011*PR_010012000010+Q_001110111*PR_010012000011+Q_001110211*PR_010012000012+Q_101010011*PR_010012000100+Q_101010111*PR_010012000101+Q_101010211*PR_010012000102+Q_101110011*PR_010012000110+Q_101110111*PR_010012000111+Q_101110211*PR_010012000112); ans_temp[ans_id*36+10]+=Pmtrx[16]*(Q_000011011*PR_010012000000+Q_000011111*PR_010012000001+Q_000011211*PR_010012000002+Q_000111011*PR_010012000010+Q_000111111*PR_010012000011+Q_000111211*PR_010012000012+Q_000211011*PR_010012000020+Q_000211111*PR_010012000021+Q_000211211*PR_010012000022); ans_temp[ans_id*36+10]+=Pmtrx[17]*(Q_000010012*PR_010012000000+Q_000010112*PR_010012000001+Q_000010212*PR_010012000002+Q_000010312*PR_010012000003+Q_000110012*PR_010012000010+Q_000110112*PR_010012000011+Q_000110212*PR_010012000012+Q_000110312*PR_010012000013); ans_temp[ans_id*36+11]+=Pmtrx[12]*(Q_002000020*PR_010012000000+Q_002000120*PR_010012000001+Q_002000220*PR_010012000002+Q_102000020*PR_010012000100+Q_102000120*PR_010012000101+Q_102000220*PR_010012000102+Q_202000020*PR_010012000200+Q_202000120*PR_010012000201+Q_202000220*PR_010012000202); ans_temp[ans_id*36+11]+=Pmtrx[13]*(Q_001001020*PR_010012000000+Q_001001120*PR_010012000001+Q_001001220*PR_010012000002+Q_001101020*PR_010012000010+Q_001101120*PR_010012000011+Q_001101220*PR_010012000012+Q_101001020*PR_010012000100+Q_101001120*PR_010012000101+Q_101001220*PR_010012000102+Q_101101020*PR_010012000110+Q_101101120*PR_010012000111+Q_101101220*PR_010012000112); ans_temp[ans_id*36+11]+=Pmtrx[14]*(Q_000002020*PR_010012000000+Q_000002120*PR_010012000001+Q_000002220*PR_010012000002+Q_000102020*PR_010012000010+Q_000102120*PR_010012000011+Q_000102220*PR_010012000012+Q_000202020*PR_010012000020+Q_000202120*PR_010012000021+Q_000202220*PR_010012000022); ans_temp[ans_id*36+11]+=Pmtrx[15]*(Q_001000021*PR_010012000000+Q_001000121*PR_010012000001+Q_001000221*PR_010012000002+Q_001000321*PR_010012000003+Q_101000021*PR_010012000100+Q_101000121*PR_010012000101+Q_101000221*PR_010012000102+Q_101000321*PR_010012000103); ans_temp[ans_id*36+11]+=Pmtrx[16]*(Q_000001021*PR_010012000000+Q_000001121*PR_010012000001+Q_000001221*PR_010012000002+Q_000001321*PR_010012000003+Q_000101021*PR_010012000010+Q_000101121*PR_010012000011+Q_000101221*PR_010012000012+Q_000101321*PR_010012000013); ans_temp[ans_id*36+11]+=Pmtrx[17]*(Q_000000022*PR_010012000000+Q_000000122*PR_010012000001+Q_000000222*PR_010012000002+Q_000000322*PR_010012000003+Q_000000422*PR_010012000004); ans_temp[ans_id*36+6]+=Pmtrx[18]*(Q_022000000*PR_011010001000+Q_122000000*PR_011010001100+Q_222000000*PR_011010001200+Q_322000000*PR_011010001300+Q_422000000*PR_011010001400); ans_temp[ans_id*36+6]+=Pmtrx[19]*(Q_021001000*PR_011010001000+Q_021101000*PR_011010001010+Q_121001000*PR_011010001100+Q_121101000*PR_011010001110+Q_221001000*PR_011010001200+Q_221101000*PR_011010001210+Q_321001000*PR_011010001300+Q_321101000*PR_011010001310); ans_temp[ans_id*36+6]+=Pmtrx[20]*(Q_020002000*PR_011010001000+Q_020102000*PR_011010001010+Q_020202000*PR_011010001020+Q_120002000*PR_011010001100+Q_120102000*PR_011010001110+Q_120202000*PR_011010001120+Q_220002000*PR_011010001200+Q_220102000*PR_011010001210+Q_220202000*PR_011010001220); ans_temp[ans_id*36+6]+=Pmtrx[21]*(Q_021000001*PR_011010001000+Q_021000101*PR_011010001001+Q_121000001*PR_011010001100+Q_121000101*PR_011010001101+Q_221000001*PR_011010001200+Q_221000101*PR_011010001201+Q_321000001*PR_011010001300+Q_321000101*PR_011010001301); ans_temp[ans_id*36+6]+=Pmtrx[22]*(Q_020001001*PR_011010001000+Q_020001101*PR_011010001001+Q_020101001*PR_011010001010+Q_020101101*PR_011010001011+Q_120001001*PR_011010001100+Q_120001101*PR_011010001101+Q_120101001*PR_011010001110+Q_120101101*PR_011010001111+Q_220001001*PR_011010001200+Q_220001101*PR_011010001201+Q_220101001*PR_011010001210+Q_220101101*PR_011010001211); ans_temp[ans_id*36+6]+=Pmtrx[23]*(Q_020000002*PR_011010001000+Q_020000102*PR_011010001001+Q_020000202*PR_011010001002+Q_120000002*PR_011010001100+Q_120000102*PR_011010001101+Q_120000202*PR_011010001102+Q_220000002*PR_011010001200+Q_220000102*PR_011010001201+Q_220000202*PR_011010001202); ans_temp[ans_id*36+7]+=Pmtrx[18]*(Q_012010000*PR_011010001000+Q_012110000*PR_011010001010+Q_112010000*PR_011010001100+Q_112110000*PR_011010001110+Q_212010000*PR_011010001200+Q_212110000*PR_011010001210+Q_312010000*PR_011010001300+Q_312110000*PR_011010001310); ans_temp[ans_id*36+7]+=Pmtrx[19]*(Q_011011000*PR_011010001000+Q_011111000*PR_011010001010+Q_011211000*PR_011010001020+Q_111011000*PR_011010001100+Q_111111000*PR_011010001110+Q_111211000*PR_011010001120+Q_211011000*PR_011010001200+Q_211111000*PR_011010001210+Q_211211000*PR_011010001220); ans_temp[ans_id*36+7]+=Pmtrx[20]*(Q_010012000*PR_011010001000+Q_010112000*PR_011010001010+Q_010212000*PR_011010001020+Q_010312000*PR_011010001030+Q_110012000*PR_011010001100+Q_110112000*PR_011010001110+Q_110212000*PR_011010001120+Q_110312000*PR_011010001130); ans_temp[ans_id*36+7]+=Pmtrx[21]*(Q_011010001*PR_011010001000+Q_011010101*PR_011010001001+Q_011110001*PR_011010001010+Q_011110101*PR_011010001011+Q_111010001*PR_011010001100+Q_111010101*PR_011010001101+Q_111110001*PR_011010001110+Q_111110101*PR_011010001111+Q_211010001*PR_011010001200+Q_211010101*PR_011010001201+Q_211110001*PR_011010001210+Q_211110101*PR_011010001211); ans_temp[ans_id*36+7]+=Pmtrx[22]*(Q_010011001*PR_011010001000+Q_010011101*PR_011010001001+Q_010111001*PR_011010001010+Q_010111101*PR_011010001011+Q_010211001*PR_011010001020+Q_010211101*PR_011010001021+Q_110011001*PR_011010001100+Q_110011101*PR_011010001101+Q_110111001*PR_011010001110+Q_110111101*PR_011010001111+Q_110211001*PR_011010001120+Q_110211101*PR_011010001121); ans_temp[ans_id*36+7]+=Pmtrx[23]*(Q_010010002*PR_011010001000+Q_010010102*PR_011010001001+Q_010010202*PR_011010001002+Q_010110002*PR_011010001010+Q_010110102*PR_011010001011+Q_010110202*PR_011010001012+Q_110010002*PR_011010001100+Q_110010102*PR_011010001101+Q_110010202*PR_011010001102+Q_110110002*PR_011010001110+Q_110110102*PR_011010001111+Q_110110202*PR_011010001112); ans_temp[ans_id*36+8]+=Pmtrx[18]*(Q_002020000*PR_011010001000+Q_002120000*PR_011010001010+Q_002220000*PR_011010001020+Q_102020000*PR_011010001100+Q_102120000*PR_011010001110+Q_102220000*PR_011010001120+Q_202020000*PR_011010001200+Q_202120000*PR_011010001210+Q_202220000*PR_011010001220); ans_temp[ans_id*36+8]+=Pmtrx[19]*(Q_001021000*PR_011010001000+Q_001121000*PR_011010001010+Q_001221000*PR_011010001020+Q_001321000*PR_011010001030+Q_101021000*PR_011010001100+Q_101121000*PR_011010001110+Q_101221000*PR_011010001120+Q_101321000*PR_011010001130); ans_temp[ans_id*36+8]+=Pmtrx[20]*(Q_000022000*PR_011010001000+Q_000122000*PR_011010001010+Q_000222000*PR_011010001020+Q_000322000*PR_011010001030+Q_000422000*PR_011010001040); ans_temp[ans_id*36+8]+=Pmtrx[21]*(Q_001020001*PR_011010001000+Q_001020101*PR_011010001001+Q_001120001*PR_011010001010+Q_001120101*PR_011010001011+Q_001220001*PR_011010001020+Q_001220101*PR_011010001021+Q_101020001*PR_011010001100+Q_101020101*PR_011010001101+Q_101120001*PR_011010001110+Q_101120101*PR_011010001111+Q_101220001*PR_011010001120+Q_101220101*PR_011010001121); ans_temp[ans_id*36+8]+=Pmtrx[22]*(Q_000021001*PR_011010001000+Q_000021101*PR_011010001001+Q_000121001*PR_011010001010+Q_000121101*PR_011010001011+Q_000221001*PR_011010001020+Q_000221101*PR_011010001021+Q_000321001*PR_011010001030+Q_000321101*PR_011010001031); ans_temp[ans_id*36+8]+=Pmtrx[23]*(Q_000020002*PR_011010001000+Q_000020102*PR_011010001001+Q_000020202*PR_011010001002+Q_000120002*PR_011010001010+Q_000120102*PR_011010001011+Q_000120202*PR_011010001012+Q_000220002*PR_011010001020+Q_000220102*PR_011010001021+Q_000220202*PR_011010001022); ans_temp[ans_id*36+9]+=Pmtrx[18]*(Q_012000010*PR_011010001000+Q_012000110*PR_011010001001+Q_112000010*PR_011010001100+Q_112000110*PR_011010001101+Q_212000010*PR_011010001200+Q_212000110*PR_011010001201+Q_312000010*PR_011010001300+Q_312000110*PR_011010001301); ans_temp[ans_id*36+9]+=Pmtrx[19]*(Q_011001010*PR_011010001000+Q_011001110*PR_011010001001+Q_011101010*PR_011010001010+Q_011101110*PR_011010001011+Q_111001010*PR_011010001100+Q_111001110*PR_011010001101+Q_111101010*PR_011010001110+Q_111101110*PR_011010001111+Q_211001010*PR_011010001200+Q_211001110*PR_011010001201+Q_211101010*PR_011010001210+Q_211101110*PR_011010001211); ans_temp[ans_id*36+9]+=Pmtrx[20]*(Q_010002010*PR_011010001000+Q_010002110*PR_011010001001+Q_010102010*PR_011010001010+Q_010102110*PR_011010001011+Q_010202010*PR_011010001020+Q_010202110*PR_011010001021+Q_110002010*PR_011010001100+Q_110002110*PR_011010001101+Q_110102010*PR_011010001110+Q_110102110*PR_011010001111+Q_110202010*PR_011010001120+Q_110202110*PR_011010001121); ans_temp[ans_id*36+9]+=Pmtrx[21]*(Q_011000011*PR_011010001000+Q_011000111*PR_011010001001+Q_011000211*PR_011010001002+Q_111000011*PR_011010001100+Q_111000111*PR_011010001101+Q_111000211*PR_011010001102+Q_211000011*PR_011010001200+Q_211000111*PR_011010001201+Q_211000211*PR_011010001202); ans_temp[ans_id*36+9]+=Pmtrx[22]*(Q_010001011*PR_011010001000+Q_010001111*PR_011010001001+Q_010001211*PR_011010001002+Q_010101011*PR_011010001010+Q_010101111*PR_011010001011+Q_010101211*PR_011010001012+Q_110001011*PR_011010001100+Q_110001111*PR_011010001101+Q_110001211*PR_011010001102+Q_110101011*PR_011010001110+Q_110101111*PR_011010001111+Q_110101211*PR_011010001112); ans_temp[ans_id*36+9]+=Pmtrx[23]*(Q_010000012*PR_011010001000+Q_010000112*PR_011010001001+Q_010000212*PR_011010001002+Q_010000312*PR_011010001003+Q_110000012*PR_011010001100+Q_110000112*PR_011010001101+Q_110000212*PR_011010001102+Q_110000312*PR_011010001103); ans_temp[ans_id*36+10]+=Pmtrx[18]*(Q_002010010*PR_011010001000+Q_002010110*PR_011010001001+Q_002110010*PR_011010001010+Q_002110110*PR_011010001011+Q_102010010*PR_011010001100+Q_102010110*PR_011010001101+Q_102110010*PR_011010001110+Q_102110110*PR_011010001111+Q_202010010*PR_011010001200+Q_202010110*PR_011010001201+Q_202110010*PR_011010001210+Q_202110110*PR_011010001211); ans_temp[ans_id*36+10]+=Pmtrx[19]*(Q_001011010*PR_011010001000+Q_001011110*PR_011010001001+Q_001111010*PR_011010001010+Q_001111110*PR_011010001011+Q_001211010*PR_011010001020+Q_001211110*PR_011010001021+Q_101011010*PR_011010001100+Q_101011110*PR_011010001101+Q_101111010*PR_011010001110+Q_101111110*PR_011010001111+Q_101211010*PR_011010001120+Q_101211110*PR_011010001121); ans_temp[ans_id*36+10]+=Pmtrx[20]*(Q_000012010*PR_011010001000+Q_000012110*PR_011010001001+Q_000112010*PR_011010001010+Q_000112110*PR_011010001011+Q_000212010*PR_011010001020+Q_000212110*PR_011010001021+Q_000312010*PR_011010001030+Q_000312110*PR_011010001031); ans_temp[ans_id*36+10]+=Pmtrx[21]*(Q_001010011*PR_011010001000+Q_001010111*PR_011010001001+Q_001010211*PR_011010001002+Q_001110011*PR_011010001010+Q_001110111*PR_011010001011+Q_001110211*PR_011010001012+Q_101010011*PR_011010001100+Q_101010111*PR_011010001101+Q_101010211*PR_011010001102+Q_101110011*PR_011010001110+Q_101110111*PR_011010001111+Q_101110211*PR_011010001112); ans_temp[ans_id*36+10]+=Pmtrx[22]*(Q_000011011*PR_011010001000+Q_000011111*PR_011010001001+Q_000011211*PR_011010001002+Q_000111011*PR_011010001010+Q_000111111*PR_011010001011+Q_000111211*PR_011010001012+Q_000211011*PR_011010001020+Q_000211111*PR_011010001021+Q_000211211*PR_011010001022); ans_temp[ans_id*36+10]+=Pmtrx[23]*(Q_000010012*PR_011010001000+Q_000010112*PR_011010001001+Q_000010212*PR_011010001002+Q_000010312*PR_011010001003+Q_000110012*PR_011010001010+Q_000110112*PR_011010001011+Q_000110212*PR_011010001012+Q_000110312*PR_011010001013); ans_temp[ans_id*36+11]+=Pmtrx[18]*(Q_002000020*PR_011010001000+Q_002000120*PR_011010001001+Q_002000220*PR_011010001002+Q_102000020*PR_011010001100+Q_102000120*PR_011010001101+Q_102000220*PR_011010001102+Q_202000020*PR_011010001200+Q_202000120*PR_011010001201+Q_202000220*PR_011010001202); ans_temp[ans_id*36+11]+=Pmtrx[19]*(Q_001001020*PR_011010001000+Q_001001120*PR_011010001001+Q_001001220*PR_011010001002+Q_001101020*PR_011010001010+Q_001101120*PR_011010001011+Q_001101220*PR_011010001012+Q_101001020*PR_011010001100+Q_101001120*PR_011010001101+Q_101001220*PR_011010001102+Q_101101020*PR_011010001110+Q_101101120*PR_011010001111+Q_101101220*PR_011010001112); ans_temp[ans_id*36+11]+=Pmtrx[20]*(Q_000002020*PR_011010001000+Q_000002120*PR_011010001001+Q_000002220*PR_011010001002+Q_000102020*PR_011010001010+Q_000102120*PR_011010001011+Q_000102220*PR_011010001012+Q_000202020*PR_011010001020+Q_000202120*PR_011010001021+Q_000202220*PR_011010001022); ans_temp[ans_id*36+11]+=Pmtrx[21]*(Q_001000021*PR_011010001000+Q_001000121*PR_011010001001+Q_001000221*PR_011010001002+Q_001000321*PR_011010001003+Q_101000021*PR_011010001100+Q_101000121*PR_011010001101+Q_101000221*PR_011010001102+Q_101000321*PR_011010001103); ans_temp[ans_id*36+11]+=Pmtrx[22]*(Q_000001021*PR_011010001000+Q_000001121*PR_011010001001+Q_000001221*PR_011010001002+Q_000001321*PR_011010001003+Q_000101021*PR_011010001010+Q_000101121*PR_011010001011+Q_000101221*PR_011010001012+Q_000101321*PR_011010001013); ans_temp[ans_id*36+11]+=Pmtrx[23]*(Q_000000022*PR_011010001000+Q_000000122*PR_011010001001+Q_000000222*PR_011010001002+Q_000000322*PR_011010001003+Q_000000422*PR_011010001004); ans_temp[ans_id*36+6]+=Pmtrx[24]*(Q_022000000*PR_010011001000+Q_122000000*PR_010011001100+Q_222000000*PR_010011001200+Q_322000000*PR_010011001300+Q_422000000*PR_010011001400); ans_temp[ans_id*36+6]+=Pmtrx[25]*(Q_021001000*PR_010011001000+Q_021101000*PR_010011001010+Q_121001000*PR_010011001100+Q_121101000*PR_010011001110+Q_221001000*PR_010011001200+Q_221101000*PR_010011001210+Q_321001000*PR_010011001300+Q_321101000*PR_010011001310); ans_temp[ans_id*36+6]+=Pmtrx[26]*(Q_020002000*PR_010011001000+Q_020102000*PR_010011001010+Q_020202000*PR_010011001020+Q_120002000*PR_010011001100+Q_120102000*PR_010011001110+Q_120202000*PR_010011001120+Q_220002000*PR_010011001200+Q_220102000*PR_010011001210+Q_220202000*PR_010011001220); ans_temp[ans_id*36+6]+=Pmtrx[27]*(Q_021000001*PR_010011001000+Q_021000101*PR_010011001001+Q_121000001*PR_010011001100+Q_121000101*PR_010011001101+Q_221000001*PR_010011001200+Q_221000101*PR_010011001201+Q_321000001*PR_010011001300+Q_321000101*PR_010011001301); ans_temp[ans_id*36+6]+=Pmtrx[28]*(Q_020001001*PR_010011001000+Q_020001101*PR_010011001001+Q_020101001*PR_010011001010+Q_020101101*PR_010011001011+Q_120001001*PR_010011001100+Q_120001101*PR_010011001101+Q_120101001*PR_010011001110+Q_120101101*PR_010011001111+Q_220001001*PR_010011001200+Q_220001101*PR_010011001201+Q_220101001*PR_010011001210+Q_220101101*PR_010011001211); ans_temp[ans_id*36+6]+=Pmtrx[29]*(Q_020000002*PR_010011001000+Q_020000102*PR_010011001001+Q_020000202*PR_010011001002+Q_120000002*PR_010011001100+Q_120000102*PR_010011001101+Q_120000202*PR_010011001102+Q_220000002*PR_010011001200+Q_220000102*PR_010011001201+Q_220000202*PR_010011001202); ans_temp[ans_id*36+7]+=Pmtrx[24]*(Q_012010000*PR_010011001000+Q_012110000*PR_010011001010+Q_112010000*PR_010011001100+Q_112110000*PR_010011001110+Q_212010000*PR_010011001200+Q_212110000*PR_010011001210+Q_312010000*PR_010011001300+Q_312110000*PR_010011001310); ans_temp[ans_id*36+7]+=Pmtrx[25]*(Q_011011000*PR_010011001000+Q_011111000*PR_010011001010+Q_011211000*PR_010011001020+Q_111011000*PR_010011001100+Q_111111000*PR_010011001110+Q_111211000*PR_010011001120+Q_211011000*PR_010011001200+Q_211111000*PR_010011001210+Q_211211000*PR_010011001220); ans_temp[ans_id*36+7]+=Pmtrx[26]*(Q_010012000*PR_010011001000+Q_010112000*PR_010011001010+Q_010212000*PR_010011001020+Q_010312000*PR_010011001030+Q_110012000*PR_010011001100+Q_110112000*PR_010011001110+Q_110212000*PR_010011001120+Q_110312000*PR_010011001130); ans_temp[ans_id*36+7]+=Pmtrx[27]*(Q_011010001*PR_010011001000+Q_011010101*PR_010011001001+Q_011110001*PR_010011001010+Q_011110101*PR_010011001011+Q_111010001*PR_010011001100+Q_111010101*PR_010011001101+Q_111110001*PR_010011001110+Q_111110101*PR_010011001111+Q_211010001*PR_010011001200+Q_211010101*PR_010011001201+Q_211110001*PR_010011001210+Q_211110101*PR_010011001211); ans_temp[ans_id*36+7]+=Pmtrx[28]*(Q_010011001*PR_010011001000+Q_010011101*PR_010011001001+Q_010111001*PR_010011001010+Q_010111101*PR_010011001011+Q_010211001*PR_010011001020+Q_010211101*PR_010011001021+Q_110011001*PR_010011001100+Q_110011101*PR_010011001101+Q_110111001*PR_010011001110+Q_110111101*PR_010011001111+Q_110211001*PR_010011001120+Q_110211101*PR_010011001121); ans_temp[ans_id*36+7]+=Pmtrx[29]*(Q_010010002*PR_010011001000+Q_010010102*PR_010011001001+Q_010010202*PR_010011001002+Q_010110002*PR_010011001010+Q_010110102*PR_010011001011+Q_010110202*PR_010011001012+Q_110010002*PR_010011001100+Q_110010102*PR_010011001101+Q_110010202*PR_010011001102+Q_110110002*PR_010011001110+Q_110110102*PR_010011001111+Q_110110202*PR_010011001112); ans_temp[ans_id*36+8]+=Pmtrx[24]*(Q_002020000*PR_010011001000+Q_002120000*PR_010011001010+Q_002220000*PR_010011001020+Q_102020000*PR_010011001100+Q_102120000*PR_010011001110+Q_102220000*PR_010011001120+Q_202020000*PR_010011001200+Q_202120000*PR_010011001210+Q_202220000*PR_010011001220); ans_temp[ans_id*36+8]+=Pmtrx[25]*(Q_001021000*PR_010011001000+Q_001121000*PR_010011001010+Q_001221000*PR_010011001020+Q_001321000*PR_010011001030+Q_101021000*PR_010011001100+Q_101121000*PR_010011001110+Q_101221000*PR_010011001120+Q_101321000*PR_010011001130); ans_temp[ans_id*36+8]+=Pmtrx[26]*(Q_000022000*PR_010011001000+Q_000122000*PR_010011001010+Q_000222000*PR_010011001020+Q_000322000*PR_010011001030+Q_000422000*PR_010011001040); ans_temp[ans_id*36+8]+=Pmtrx[27]*(Q_001020001*PR_010011001000+Q_001020101*PR_010011001001+Q_001120001*PR_010011001010+Q_001120101*PR_010011001011+Q_001220001*PR_010011001020+Q_001220101*PR_010011001021+Q_101020001*PR_010011001100+Q_101020101*PR_010011001101+Q_101120001*PR_010011001110+Q_101120101*PR_010011001111+Q_101220001*PR_010011001120+Q_101220101*PR_010011001121); ans_temp[ans_id*36+8]+=Pmtrx[28]*(Q_000021001*PR_010011001000+Q_000021101*PR_010011001001+Q_000121001*PR_010011001010+Q_000121101*PR_010011001011+Q_000221001*PR_010011001020+Q_000221101*PR_010011001021+Q_000321001*PR_010011001030+Q_000321101*PR_010011001031); ans_temp[ans_id*36+8]+=Pmtrx[29]*(Q_000020002*PR_010011001000+Q_000020102*PR_010011001001+Q_000020202*PR_010011001002+Q_000120002*PR_010011001010+Q_000120102*PR_010011001011+Q_000120202*PR_010011001012+Q_000220002*PR_010011001020+Q_000220102*PR_010011001021+Q_000220202*PR_010011001022); ans_temp[ans_id*36+9]+=Pmtrx[24]*(Q_012000010*PR_010011001000+Q_012000110*PR_010011001001+Q_112000010*PR_010011001100+Q_112000110*PR_010011001101+Q_212000010*PR_010011001200+Q_212000110*PR_010011001201+Q_312000010*PR_010011001300+Q_312000110*PR_010011001301); ans_temp[ans_id*36+9]+=Pmtrx[25]*(Q_011001010*PR_010011001000+Q_011001110*PR_010011001001+Q_011101010*PR_010011001010+Q_011101110*PR_010011001011+Q_111001010*PR_010011001100+Q_111001110*PR_010011001101+Q_111101010*PR_010011001110+Q_111101110*PR_010011001111+Q_211001010*PR_010011001200+Q_211001110*PR_010011001201+Q_211101010*PR_010011001210+Q_211101110*PR_010011001211); ans_temp[ans_id*36+9]+=Pmtrx[26]*(Q_010002010*PR_010011001000+Q_010002110*PR_010011001001+Q_010102010*PR_010011001010+Q_010102110*PR_010011001011+Q_010202010*PR_010011001020+Q_010202110*PR_010011001021+Q_110002010*PR_010011001100+Q_110002110*PR_010011001101+Q_110102010*PR_010011001110+Q_110102110*PR_010011001111+Q_110202010*PR_010011001120+Q_110202110*PR_010011001121); ans_temp[ans_id*36+9]+=Pmtrx[27]*(Q_011000011*PR_010011001000+Q_011000111*PR_010011001001+Q_011000211*PR_010011001002+Q_111000011*PR_010011001100+Q_111000111*PR_010011001101+Q_111000211*PR_010011001102+Q_211000011*PR_010011001200+Q_211000111*PR_010011001201+Q_211000211*PR_010011001202); ans_temp[ans_id*36+9]+=Pmtrx[28]*(Q_010001011*PR_010011001000+Q_010001111*PR_010011001001+Q_010001211*PR_010011001002+Q_010101011*PR_010011001010+Q_010101111*PR_010011001011+Q_010101211*PR_010011001012+Q_110001011*PR_010011001100+Q_110001111*PR_010011001101+Q_110001211*PR_010011001102+Q_110101011*PR_010011001110+Q_110101111*PR_010011001111+Q_110101211*PR_010011001112); ans_temp[ans_id*36+9]+=Pmtrx[29]*(Q_010000012*PR_010011001000+Q_010000112*PR_010011001001+Q_010000212*PR_010011001002+Q_010000312*PR_010011001003+Q_110000012*PR_010011001100+Q_110000112*PR_010011001101+Q_110000212*PR_010011001102+Q_110000312*PR_010011001103); ans_temp[ans_id*36+10]+=Pmtrx[24]*(Q_002010010*PR_010011001000+Q_002010110*PR_010011001001+Q_002110010*PR_010011001010+Q_002110110*PR_010011001011+Q_102010010*PR_010011001100+Q_102010110*PR_010011001101+Q_102110010*PR_010011001110+Q_102110110*PR_010011001111+Q_202010010*PR_010011001200+Q_202010110*PR_010011001201+Q_202110010*PR_010011001210+Q_202110110*PR_010011001211); ans_temp[ans_id*36+10]+=Pmtrx[25]*(Q_001011010*PR_010011001000+Q_001011110*PR_010011001001+Q_001111010*PR_010011001010+Q_001111110*PR_010011001011+Q_001211010*PR_010011001020+Q_001211110*PR_010011001021+Q_101011010*PR_010011001100+Q_101011110*PR_010011001101+Q_101111010*PR_010011001110+Q_101111110*PR_010011001111+Q_101211010*PR_010011001120+Q_101211110*PR_010011001121); ans_temp[ans_id*36+10]+=Pmtrx[26]*(Q_000012010*PR_010011001000+Q_000012110*PR_010011001001+Q_000112010*PR_010011001010+Q_000112110*PR_010011001011+Q_000212010*PR_010011001020+Q_000212110*PR_010011001021+Q_000312010*PR_010011001030+Q_000312110*PR_010011001031); ans_temp[ans_id*36+10]+=Pmtrx[27]*(Q_001010011*PR_010011001000+Q_001010111*PR_010011001001+Q_001010211*PR_010011001002+Q_001110011*PR_010011001010+Q_001110111*PR_010011001011+Q_001110211*PR_010011001012+Q_101010011*PR_010011001100+Q_101010111*PR_010011001101+Q_101010211*PR_010011001102+Q_101110011*PR_010011001110+Q_101110111*PR_010011001111+Q_101110211*PR_010011001112); ans_temp[ans_id*36+10]+=Pmtrx[28]*(Q_000011011*PR_010011001000+Q_000011111*PR_010011001001+Q_000011211*PR_010011001002+Q_000111011*PR_010011001010+Q_000111111*PR_010011001011+Q_000111211*PR_010011001012+Q_000211011*PR_010011001020+Q_000211111*PR_010011001021+Q_000211211*PR_010011001022); ans_temp[ans_id*36+10]+=Pmtrx[29]*(Q_000010012*PR_010011001000+Q_000010112*PR_010011001001+Q_000010212*PR_010011001002+Q_000010312*PR_010011001003+Q_000110012*PR_010011001010+Q_000110112*PR_010011001011+Q_000110212*PR_010011001012+Q_000110312*PR_010011001013); ans_temp[ans_id*36+11]+=Pmtrx[24]*(Q_002000020*PR_010011001000+Q_002000120*PR_010011001001+Q_002000220*PR_010011001002+Q_102000020*PR_010011001100+Q_102000120*PR_010011001101+Q_102000220*PR_010011001102+Q_202000020*PR_010011001200+Q_202000120*PR_010011001201+Q_202000220*PR_010011001202); ans_temp[ans_id*36+11]+=Pmtrx[25]*(Q_001001020*PR_010011001000+Q_001001120*PR_010011001001+Q_001001220*PR_010011001002+Q_001101020*PR_010011001010+Q_001101120*PR_010011001011+Q_001101220*PR_010011001012+Q_101001020*PR_010011001100+Q_101001120*PR_010011001101+Q_101001220*PR_010011001102+Q_101101020*PR_010011001110+Q_101101120*PR_010011001111+Q_101101220*PR_010011001112); ans_temp[ans_id*36+11]+=Pmtrx[26]*(Q_000002020*PR_010011001000+Q_000002120*PR_010011001001+Q_000002220*PR_010011001002+Q_000102020*PR_010011001010+Q_000102120*PR_010011001011+Q_000102220*PR_010011001012+Q_000202020*PR_010011001020+Q_000202120*PR_010011001021+Q_000202220*PR_010011001022); ans_temp[ans_id*36+11]+=Pmtrx[27]*(Q_001000021*PR_010011001000+Q_001000121*PR_010011001001+Q_001000221*PR_010011001002+Q_001000321*PR_010011001003+Q_101000021*PR_010011001100+Q_101000121*PR_010011001101+Q_101000221*PR_010011001102+Q_101000321*PR_010011001103); ans_temp[ans_id*36+11]+=Pmtrx[28]*(Q_000001021*PR_010011001000+Q_000001121*PR_010011001001+Q_000001221*PR_010011001002+Q_000001321*PR_010011001003+Q_000101021*PR_010011001010+Q_000101121*PR_010011001011+Q_000101221*PR_010011001012+Q_000101321*PR_010011001013); ans_temp[ans_id*36+11]+=Pmtrx[29]*(Q_000000022*PR_010011001000+Q_000000122*PR_010011001001+Q_000000222*PR_010011001002+Q_000000322*PR_010011001003+Q_000000422*PR_010011001004); ans_temp[ans_id*36+6]+=Pmtrx[30]*(Q_022000000*PR_010010002000+Q_122000000*PR_010010002100+Q_222000000*PR_010010002200+Q_322000000*PR_010010002300+Q_422000000*PR_010010002400); ans_temp[ans_id*36+6]+=Pmtrx[31]*(Q_021001000*PR_010010002000+Q_021101000*PR_010010002010+Q_121001000*PR_010010002100+Q_121101000*PR_010010002110+Q_221001000*PR_010010002200+Q_221101000*PR_010010002210+Q_321001000*PR_010010002300+Q_321101000*PR_010010002310); ans_temp[ans_id*36+6]+=Pmtrx[32]*(Q_020002000*PR_010010002000+Q_020102000*PR_010010002010+Q_020202000*PR_010010002020+Q_120002000*PR_010010002100+Q_120102000*PR_010010002110+Q_120202000*PR_010010002120+Q_220002000*PR_010010002200+Q_220102000*PR_010010002210+Q_220202000*PR_010010002220); ans_temp[ans_id*36+6]+=Pmtrx[33]*(Q_021000001*PR_010010002000+Q_021000101*PR_010010002001+Q_121000001*PR_010010002100+Q_121000101*PR_010010002101+Q_221000001*PR_010010002200+Q_221000101*PR_010010002201+Q_321000001*PR_010010002300+Q_321000101*PR_010010002301); ans_temp[ans_id*36+6]+=Pmtrx[34]*(Q_020001001*PR_010010002000+Q_020001101*PR_010010002001+Q_020101001*PR_010010002010+Q_020101101*PR_010010002011+Q_120001001*PR_010010002100+Q_120001101*PR_010010002101+Q_120101001*PR_010010002110+Q_120101101*PR_010010002111+Q_220001001*PR_010010002200+Q_220001101*PR_010010002201+Q_220101001*PR_010010002210+Q_220101101*PR_010010002211); ans_temp[ans_id*36+6]+=Pmtrx[35]*(Q_020000002*PR_010010002000+Q_020000102*PR_010010002001+Q_020000202*PR_010010002002+Q_120000002*PR_010010002100+Q_120000102*PR_010010002101+Q_120000202*PR_010010002102+Q_220000002*PR_010010002200+Q_220000102*PR_010010002201+Q_220000202*PR_010010002202); ans_temp[ans_id*36+7]+=Pmtrx[30]*(Q_012010000*PR_010010002000+Q_012110000*PR_010010002010+Q_112010000*PR_010010002100+Q_112110000*PR_010010002110+Q_212010000*PR_010010002200+Q_212110000*PR_010010002210+Q_312010000*PR_010010002300+Q_312110000*PR_010010002310); ans_temp[ans_id*36+7]+=Pmtrx[31]*(Q_011011000*PR_010010002000+Q_011111000*PR_010010002010+Q_011211000*PR_010010002020+Q_111011000*PR_010010002100+Q_111111000*PR_010010002110+Q_111211000*PR_010010002120+Q_211011000*PR_010010002200+Q_211111000*PR_010010002210+Q_211211000*PR_010010002220); ans_temp[ans_id*36+7]+=Pmtrx[32]*(Q_010012000*PR_010010002000+Q_010112000*PR_010010002010+Q_010212000*PR_010010002020+Q_010312000*PR_010010002030+Q_110012000*PR_010010002100+Q_110112000*PR_010010002110+Q_110212000*PR_010010002120+Q_110312000*PR_010010002130); ans_temp[ans_id*36+7]+=Pmtrx[33]*(Q_011010001*PR_010010002000+Q_011010101*PR_010010002001+Q_011110001*PR_010010002010+Q_011110101*PR_010010002011+Q_111010001*PR_010010002100+Q_111010101*PR_010010002101+Q_111110001*PR_010010002110+Q_111110101*PR_010010002111+Q_211010001*PR_010010002200+Q_211010101*PR_010010002201+Q_211110001*PR_010010002210+Q_211110101*PR_010010002211); ans_temp[ans_id*36+7]+=Pmtrx[34]*(Q_010011001*PR_010010002000+Q_010011101*PR_010010002001+Q_010111001*PR_010010002010+Q_010111101*PR_010010002011+Q_010211001*PR_010010002020+Q_010211101*PR_010010002021+Q_110011001*PR_010010002100+Q_110011101*PR_010010002101+Q_110111001*PR_010010002110+Q_110111101*PR_010010002111+Q_110211001*PR_010010002120+Q_110211101*PR_010010002121); ans_temp[ans_id*36+7]+=Pmtrx[35]*(Q_010010002*PR_010010002000+Q_010010102*PR_010010002001+Q_010010202*PR_010010002002+Q_010110002*PR_010010002010+Q_010110102*PR_010010002011+Q_010110202*PR_010010002012+Q_110010002*PR_010010002100+Q_110010102*PR_010010002101+Q_110010202*PR_010010002102+Q_110110002*PR_010010002110+Q_110110102*PR_010010002111+Q_110110202*PR_010010002112); ans_temp[ans_id*36+8]+=Pmtrx[30]*(Q_002020000*PR_010010002000+Q_002120000*PR_010010002010+Q_002220000*PR_010010002020+Q_102020000*PR_010010002100+Q_102120000*PR_010010002110+Q_102220000*PR_010010002120+Q_202020000*PR_010010002200+Q_202120000*PR_010010002210+Q_202220000*PR_010010002220); ans_temp[ans_id*36+8]+=Pmtrx[31]*(Q_001021000*PR_010010002000+Q_001121000*PR_010010002010+Q_001221000*PR_010010002020+Q_001321000*PR_010010002030+Q_101021000*PR_010010002100+Q_101121000*PR_010010002110+Q_101221000*PR_010010002120+Q_101321000*PR_010010002130); ans_temp[ans_id*36+8]+=Pmtrx[32]*(Q_000022000*PR_010010002000+Q_000122000*PR_010010002010+Q_000222000*PR_010010002020+Q_000322000*PR_010010002030+Q_000422000*PR_010010002040); ans_temp[ans_id*36+8]+=Pmtrx[33]*(Q_001020001*PR_010010002000+Q_001020101*PR_010010002001+Q_001120001*PR_010010002010+Q_001120101*PR_010010002011+Q_001220001*PR_010010002020+Q_001220101*PR_010010002021+Q_101020001*PR_010010002100+Q_101020101*PR_010010002101+Q_101120001*PR_010010002110+Q_101120101*PR_010010002111+Q_101220001*PR_010010002120+Q_101220101*PR_010010002121); ans_temp[ans_id*36+8]+=Pmtrx[34]*(Q_000021001*PR_010010002000+Q_000021101*PR_010010002001+Q_000121001*PR_010010002010+Q_000121101*PR_010010002011+Q_000221001*PR_010010002020+Q_000221101*PR_010010002021+Q_000321001*PR_010010002030+Q_000321101*PR_010010002031); ans_temp[ans_id*36+8]+=Pmtrx[35]*(Q_000020002*PR_010010002000+Q_000020102*PR_010010002001+Q_000020202*PR_010010002002+Q_000120002*PR_010010002010+Q_000120102*PR_010010002011+Q_000120202*PR_010010002012+Q_000220002*PR_010010002020+Q_000220102*PR_010010002021+Q_000220202*PR_010010002022); ans_temp[ans_id*36+9]+=Pmtrx[30]*(Q_012000010*PR_010010002000+Q_012000110*PR_010010002001+Q_112000010*PR_010010002100+Q_112000110*PR_010010002101+Q_212000010*PR_010010002200+Q_212000110*PR_010010002201+Q_312000010*PR_010010002300+Q_312000110*PR_010010002301); ans_temp[ans_id*36+9]+=Pmtrx[31]*(Q_011001010*PR_010010002000+Q_011001110*PR_010010002001+Q_011101010*PR_010010002010+Q_011101110*PR_010010002011+Q_111001010*PR_010010002100+Q_111001110*PR_010010002101+Q_111101010*PR_010010002110+Q_111101110*PR_010010002111+Q_211001010*PR_010010002200+Q_211001110*PR_010010002201+Q_211101010*PR_010010002210+Q_211101110*PR_010010002211); ans_temp[ans_id*36+9]+=Pmtrx[32]*(Q_010002010*PR_010010002000+Q_010002110*PR_010010002001+Q_010102010*PR_010010002010+Q_010102110*PR_010010002011+Q_010202010*PR_010010002020+Q_010202110*PR_010010002021+Q_110002010*PR_010010002100+Q_110002110*PR_010010002101+Q_110102010*PR_010010002110+Q_110102110*PR_010010002111+Q_110202010*PR_010010002120+Q_110202110*PR_010010002121); ans_temp[ans_id*36+9]+=Pmtrx[33]*(Q_011000011*PR_010010002000+Q_011000111*PR_010010002001+Q_011000211*PR_010010002002+Q_111000011*PR_010010002100+Q_111000111*PR_010010002101+Q_111000211*PR_010010002102+Q_211000011*PR_010010002200+Q_211000111*PR_010010002201+Q_211000211*PR_010010002202); ans_temp[ans_id*36+9]+=Pmtrx[34]*(Q_010001011*PR_010010002000+Q_010001111*PR_010010002001+Q_010001211*PR_010010002002+Q_010101011*PR_010010002010+Q_010101111*PR_010010002011+Q_010101211*PR_010010002012+Q_110001011*PR_010010002100+Q_110001111*PR_010010002101+Q_110001211*PR_010010002102+Q_110101011*PR_010010002110+Q_110101111*PR_010010002111+Q_110101211*PR_010010002112); ans_temp[ans_id*36+9]+=Pmtrx[35]*(Q_010000012*PR_010010002000+Q_010000112*PR_010010002001+Q_010000212*PR_010010002002+Q_010000312*PR_010010002003+Q_110000012*PR_010010002100+Q_110000112*PR_010010002101+Q_110000212*PR_010010002102+Q_110000312*PR_010010002103); ans_temp[ans_id*36+10]+=Pmtrx[30]*(Q_002010010*PR_010010002000+Q_002010110*PR_010010002001+Q_002110010*PR_010010002010+Q_002110110*PR_010010002011+Q_102010010*PR_010010002100+Q_102010110*PR_010010002101+Q_102110010*PR_010010002110+Q_102110110*PR_010010002111+Q_202010010*PR_010010002200+Q_202010110*PR_010010002201+Q_202110010*PR_010010002210+Q_202110110*PR_010010002211); ans_temp[ans_id*36+10]+=Pmtrx[31]*(Q_001011010*PR_010010002000+Q_001011110*PR_010010002001+Q_001111010*PR_010010002010+Q_001111110*PR_010010002011+Q_001211010*PR_010010002020+Q_001211110*PR_010010002021+Q_101011010*PR_010010002100+Q_101011110*PR_010010002101+Q_101111010*PR_010010002110+Q_101111110*PR_010010002111+Q_101211010*PR_010010002120+Q_101211110*PR_010010002121); ans_temp[ans_id*36+10]+=Pmtrx[32]*(Q_000012010*PR_010010002000+Q_000012110*PR_010010002001+Q_000112010*PR_010010002010+Q_000112110*PR_010010002011+Q_000212010*PR_010010002020+Q_000212110*PR_010010002021+Q_000312010*PR_010010002030+Q_000312110*PR_010010002031); ans_temp[ans_id*36+10]+=Pmtrx[33]*(Q_001010011*PR_010010002000+Q_001010111*PR_010010002001+Q_001010211*PR_010010002002+Q_001110011*PR_010010002010+Q_001110111*PR_010010002011+Q_001110211*PR_010010002012+Q_101010011*PR_010010002100+Q_101010111*PR_010010002101+Q_101010211*PR_010010002102+Q_101110011*PR_010010002110+Q_101110111*PR_010010002111+Q_101110211*PR_010010002112); ans_temp[ans_id*36+10]+=Pmtrx[34]*(Q_000011011*PR_010010002000+Q_000011111*PR_010010002001+Q_000011211*PR_010010002002+Q_000111011*PR_010010002010+Q_000111111*PR_010010002011+Q_000111211*PR_010010002012+Q_000211011*PR_010010002020+Q_000211111*PR_010010002021+Q_000211211*PR_010010002022); ans_temp[ans_id*36+10]+=Pmtrx[35]*(Q_000010012*PR_010010002000+Q_000010112*PR_010010002001+Q_000010212*PR_010010002002+Q_000010312*PR_010010002003+Q_000110012*PR_010010002010+Q_000110112*PR_010010002011+Q_000110212*PR_010010002012+Q_000110312*PR_010010002013); ans_temp[ans_id*36+11]+=Pmtrx[30]*(Q_002000020*PR_010010002000+Q_002000120*PR_010010002001+Q_002000220*PR_010010002002+Q_102000020*PR_010010002100+Q_102000120*PR_010010002101+Q_102000220*PR_010010002102+Q_202000020*PR_010010002200+Q_202000120*PR_010010002201+Q_202000220*PR_010010002202); ans_temp[ans_id*36+11]+=Pmtrx[31]*(Q_001001020*PR_010010002000+Q_001001120*PR_010010002001+Q_001001220*PR_010010002002+Q_001101020*PR_010010002010+Q_001101120*PR_010010002011+Q_001101220*PR_010010002012+Q_101001020*PR_010010002100+Q_101001120*PR_010010002101+Q_101001220*PR_010010002102+Q_101101020*PR_010010002110+Q_101101120*PR_010010002111+Q_101101220*PR_010010002112); ans_temp[ans_id*36+11]+=Pmtrx[32]*(Q_000002020*PR_010010002000+Q_000002120*PR_010010002001+Q_000002220*PR_010010002002+Q_000102020*PR_010010002010+Q_000102120*PR_010010002011+Q_000102220*PR_010010002012+Q_000202020*PR_010010002020+Q_000202120*PR_010010002021+Q_000202220*PR_010010002022); ans_temp[ans_id*36+11]+=Pmtrx[33]*(Q_001000021*PR_010010002000+Q_001000121*PR_010010002001+Q_001000221*PR_010010002002+Q_001000321*PR_010010002003+Q_101000021*PR_010010002100+Q_101000121*PR_010010002101+Q_101000221*PR_010010002102+Q_101000321*PR_010010002103); ans_temp[ans_id*36+11]+=Pmtrx[34]*(Q_000001021*PR_010010002000+Q_000001121*PR_010010002001+Q_000001221*PR_010010002002+Q_000001321*PR_010010002003+Q_000101021*PR_010010002010+Q_000101121*PR_010010002011+Q_000101221*PR_010010002012+Q_000101321*PR_010010002013); ans_temp[ans_id*36+11]+=Pmtrx[35]*(Q_000000022*PR_010010002000+Q_000000122*PR_010010002001+Q_000000222*PR_010010002002+Q_000000322*PR_010010002003+Q_000000422*PR_010010002004); ans_temp[ans_id*36+12]+=Pmtrx[0]*(Q_022000000*PR_002020000000+Q_122000000*PR_002020000100+Q_222000000*PR_002020000200+Q_322000000*PR_002020000300+Q_422000000*PR_002020000400); ans_temp[ans_id*36+12]+=Pmtrx[1]*(Q_021001000*PR_002020000000+Q_021101000*PR_002020000010+Q_121001000*PR_002020000100+Q_121101000*PR_002020000110+Q_221001000*PR_002020000200+Q_221101000*PR_002020000210+Q_321001000*PR_002020000300+Q_321101000*PR_002020000310); ans_temp[ans_id*36+12]+=Pmtrx[2]*(Q_020002000*PR_002020000000+Q_020102000*PR_002020000010+Q_020202000*PR_002020000020+Q_120002000*PR_002020000100+Q_120102000*PR_002020000110+Q_120202000*PR_002020000120+Q_220002000*PR_002020000200+Q_220102000*PR_002020000210+Q_220202000*PR_002020000220); ans_temp[ans_id*36+12]+=Pmtrx[3]*(Q_021000001*PR_002020000000+Q_021000101*PR_002020000001+Q_121000001*PR_002020000100+Q_121000101*PR_002020000101+Q_221000001*PR_002020000200+Q_221000101*PR_002020000201+Q_321000001*PR_002020000300+Q_321000101*PR_002020000301); ans_temp[ans_id*36+12]+=Pmtrx[4]*(Q_020001001*PR_002020000000+Q_020001101*PR_002020000001+Q_020101001*PR_002020000010+Q_020101101*PR_002020000011+Q_120001001*PR_002020000100+Q_120001101*PR_002020000101+Q_120101001*PR_002020000110+Q_120101101*PR_002020000111+Q_220001001*PR_002020000200+Q_220001101*PR_002020000201+Q_220101001*PR_002020000210+Q_220101101*PR_002020000211); ans_temp[ans_id*36+12]+=Pmtrx[5]*(Q_020000002*PR_002020000000+Q_020000102*PR_002020000001+Q_020000202*PR_002020000002+Q_120000002*PR_002020000100+Q_120000102*PR_002020000101+Q_120000202*PR_002020000102+Q_220000002*PR_002020000200+Q_220000102*PR_002020000201+Q_220000202*PR_002020000202); ans_temp[ans_id*36+13]+=Pmtrx[0]*(Q_012010000*PR_002020000000+Q_012110000*PR_002020000010+Q_112010000*PR_002020000100+Q_112110000*PR_002020000110+Q_212010000*PR_002020000200+Q_212110000*PR_002020000210+Q_312010000*PR_002020000300+Q_312110000*PR_002020000310); ans_temp[ans_id*36+13]+=Pmtrx[1]*(Q_011011000*PR_002020000000+Q_011111000*PR_002020000010+Q_011211000*PR_002020000020+Q_111011000*PR_002020000100+Q_111111000*PR_002020000110+Q_111211000*PR_002020000120+Q_211011000*PR_002020000200+Q_211111000*PR_002020000210+Q_211211000*PR_002020000220); ans_temp[ans_id*36+13]+=Pmtrx[2]*(Q_010012000*PR_002020000000+Q_010112000*PR_002020000010+Q_010212000*PR_002020000020+Q_010312000*PR_002020000030+Q_110012000*PR_002020000100+Q_110112000*PR_002020000110+Q_110212000*PR_002020000120+Q_110312000*PR_002020000130); ans_temp[ans_id*36+13]+=Pmtrx[3]*(Q_011010001*PR_002020000000+Q_011010101*PR_002020000001+Q_011110001*PR_002020000010+Q_011110101*PR_002020000011+Q_111010001*PR_002020000100+Q_111010101*PR_002020000101+Q_111110001*PR_002020000110+Q_111110101*PR_002020000111+Q_211010001*PR_002020000200+Q_211010101*PR_002020000201+Q_211110001*PR_002020000210+Q_211110101*PR_002020000211); ans_temp[ans_id*36+13]+=Pmtrx[4]*(Q_010011001*PR_002020000000+Q_010011101*PR_002020000001+Q_010111001*PR_002020000010+Q_010111101*PR_002020000011+Q_010211001*PR_002020000020+Q_010211101*PR_002020000021+Q_110011001*PR_002020000100+Q_110011101*PR_002020000101+Q_110111001*PR_002020000110+Q_110111101*PR_002020000111+Q_110211001*PR_002020000120+Q_110211101*PR_002020000121); ans_temp[ans_id*36+13]+=Pmtrx[5]*(Q_010010002*PR_002020000000+Q_010010102*PR_002020000001+Q_010010202*PR_002020000002+Q_010110002*PR_002020000010+Q_010110102*PR_002020000011+Q_010110202*PR_002020000012+Q_110010002*PR_002020000100+Q_110010102*PR_002020000101+Q_110010202*PR_002020000102+Q_110110002*PR_002020000110+Q_110110102*PR_002020000111+Q_110110202*PR_002020000112); ans_temp[ans_id*36+14]+=Pmtrx[0]*(Q_002020000*PR_002020000000+Q_002120000*PR_002020000010+Q_002220000*PR_002020000020+Q_102020000*PR_002020000100+Q_102120000*PR_002020000110+Q_102220000*PR_002020000120+Q_202020000*PR_002020000200+Q_202120000*PR_002020000210+Q_202220000*PR_002020000220); ans_temp[ans_id*36+14]+=Pmtrx[1]*(Q_001021000*PR_002020000000+Q_001121000*PR_002020000010+Q_001221000*PR_002020000020+Q_001321000*PR_002020000030+Q_101021000*PR_002020000100+Q_101121000*PR_002020000110+Q_101221000*PR_002020000120+Q_101321000*PR_002020000130); ans_temp[ans_id*36+14]+=Pmtrx[2]*(Q_000022000*PR_002020000000+Q_000122000*PR_002020000010+Q_000222000*PR_002020000020+Q_000322000*PR_002020000030+Q_000422000*PR_002020000040); ans_temp[ans_id*36+14]+=Pmtrx[3]*(Q_001020001*PR_002020000000+Q_001020101*PR_002020000001+Q_001120001*PR_002020000010+Q_001120101*PR_002020000011+Q_001220001*PR_002020000020+Q_001220101*PR_002020000021+Q_101020001*PR_002020000100+Q_101020101*PR_002020000101+Q_101120001*PR_002020000110+Q_101120101*PR_002020000111+Q_101220001*PR_002020000120+Q_101220101*PR_002020000121); ans_temp[ans_id*36+14]+=Pmtrx[4]*(Q_000021001*PR_002020000000+Q_000021101*PR_002020000001+Q_000121001*PR_002020000010+Q_000121101*PR_002020000011+Q_000221001*PR_002020000020+Q_000221101*PR_002020000021+Q_000321001*PR_002020000030+Q_000321101*PR_002020000031); ans_temp[ans_id*36+14]+=Pmtrx[5]*(Q_000020002*PR_002020000000+Q_000020102*PR_002020000001+Q_000020202*PR_002020000002+Q_000120002*PR_002020000010+Q_000120102*PR_002020000011+Q_000120202*PR_002020000012+Q_000220002*PR_002020000020+Q_000220102*PR_002020000021+Q_000220202*PR_002020000022); ans_temp[ans_id*36+15]+=Pmtrx[0]*(Q_012000010*PR_002020000000+Q_012000110*PR_002020000001+Q_112000010*PR_002020000100+Q_112000110*PR_002020000101+Q_212000010*PR_002020000200+Q_212000110*PR_002020000201+Q_312000010*PR_002020000300+Q_312000110*PR_002020000301); ans_temp[ans_id*36+15]+=Pmtrx[1]*(Q_011001010*PR_002020000000+Q_011001110*PR_002020000001+Q_011101010*PR_002020000010+Q_011101110*PR_002020000011+Q_111001010*PR_002020000100+Q_111001110*PR_002020000101+Q_111101010*PR_002020000110+Q_111101110*PR_002020000111+Q_211001010*PR_002020000200+Q_211001110*PR_002020000201+Q_211101010*PR_002020000210+Q_211101110*PR_002020000211); ans_temp[ans_id*36+15]+=Pmtrx[2]*(Q_010002010*PR_002020000000+Q_010002110*PR_002020000001+Q_010102010*PR_002020000010+Q_010102110*PR_002020000011+Q_010202010*PR_002020000020+Q_010202110*PR_002020000021+Q_110002010*PR_002020000100+Q_110002110*PR_002020000101+Q_110102010*PR_002020000110+Q_110102110*PR_002020000111+Q_110202010*PR_002020000120+Q_110202110*PR_002020000121); ans_temp[ans_id*36+15]+=Pmtrx[3]*(Q_011000011*PR_002020000000+Q_011000111*PR_002020000001+Q_011000211*PR_002020000002+Q_111000011*PR_002020000100+Q_111000111*PR_002020000101+Q_111000211*PR_002020000102+Q_211000011*PR_002020000200+Q_211000111*PR_002020000201+Q_211000211*PR_002020000202); ans_temp[ans_id*36+15]+=Pmtrx[4]*(Q_010001011*PR_002020000000+Q_010001111*PR_002020000001+Q_010001211*PR_002020000002+Q_010101011*PR_002020000010+Q_010101111*PR_002020000011+Q_010101211*PR_002020000012+Q_110001011*PR_002020000100+Q_110001111*PR_002020000101+Q_110001211*PR_002020000102+Q_110101011*PR_002020000110+Q_110101111*PR_002020000111+Q_110101211*PR_002020000112); ans_temp[ans_id*36+15]+=Pmtrx[5]*(Q_010000012*PR_002020000000+Q_010000112*PR_002020000001+Q_010000212*PR_002020000002+Q_010000312*PR_002020000003+Q_110000012*PR_002020000100+Q_110000112*PR_002020000101+Q_110000212*PR_002020000102+Q_110000312*PR_002020000103); ans_temp[ans_id*36+16]+=Pmtrx[0]*(Q_002010010*PR_002020000000+Q_002010110*PR_002020000001+Q_002110010*PR_002020000010+Q_002110110*PR_002020000011+Q_102010010*PR_002020000100+Q_102010110*PR_002020000101+Q_102110010*PR_002020000110+Q_102110110*PR_002020000111+Q_202010010*PR_002020000200+Q_202010110*PR_002020000201+Q_202110010*PR_002020000210+Q_202110110*PR_002020000211); ans_temp[ans_id*36+16]+=Pmtrx[1]*(Q_001011010*PR_002020000000+Q_001011110*PR_002020000001+Q_001111010*PR_002020000010+Q_001111110*PR_002020000011+Q_001211010*PR_002020000020+Q_001211110*PR_002020000021+Q_101011010*PR_002020000100+Q_101011110*PR_002020000101+Q_101111010*PR_002020000110+Q_101111110*PR_002020000111+Q_101211010*PR_002020000120+Q_101211110*PR_002020000121); ans_temp[ans_id*36+16]+=Pmtrx[2]*(Q_000012010*PR_002020000000+Q_000012110*PR_002020000001+Q_000112010*PR_002020000010+Q_000112110*PR_002020000011+Q_000212010*PR_002020000020+Q_000212110*PR_002020000021+Q_000312010*PR_002020000030+Q_000312110*PR_002020000031); ans_temp[ans_id*36+16]+=Pmtrx[3]*(Q_001010011*PR_002020000000+Q_001010111*PR_002020000001+Q_001010211*PR_002020000002+Q_001110011*PR_002020000010+Q_001110111*PR_002020000011+Q_001110211*PR_002020000012+Q_101010011*PR_002020000100+Q_101010111*PR_002020000101+Q_101010211*PR_002020000102+Q_101110011*PR_002020000110+Q_101110111*PR_002020000111+Q_101110211*PR_002020000112); ans_temp[ans_id*36+16]+=Pmtrx[4]*(Q_000011011*PR_002020000000+Q_000011111*PR_002020000001+Q_000011211*PR_002020000002+Q_000111011*PR_002020000010+Q_000111111*PR_002020000011+Q_000111211*PR_002020000012+Q_000211011*PR_002020000020+Q_000211111*PR_002020000021+Q_000211211*PR_002020000022); ans_temp[ans_id*36+16]+=Pmtrx[5]*(Q_000010012*PR_002020000000+Q_000010112*PR_002020000001+Q_000010212*PR_002020000002+Q_000010312*PR_002020000003+Q_000110012*PR_002020000010+Q_000110112*PR_002020000011+Q_000110212*PR_002020000012+Q_000110312*PR_002020000013); ans_temp[ans_id*36+17]+=Pmtrx[0]*(Q_002000020*PR_002020000000+Q_002000120*PR_002020000001+Q_002000220*PR_002020000002+Q_102000020*PR_002020000100+Q_102000120*PR_002020000101+Q_102000220*PR_002020000102+Q_202000020*PR_002020000200+Q_202000120*PR_002020000201+Q_202000220*PR_002020000202); ans_temp[ans_id*36+17]+=Pmtrx[1]*(Q_001001020*PR_002020000000+Q_001001120*PR_002020000001+Q_001001220*PR_002020000002+Q_001101020*PR_002020000010+Q_001101120*PR_002020000011+Q_001101220*PR_002020000012+Q_101001020*PR_002020000100+Q_101001120*PR_002020000101+Q_101001220*PR_002020000102+Q_101101020*PR_002020000110+Q_101101120*PR_002020000111+Q_101101220*PR_002020000112); ans_temp[ans_id*36+17]+=Pmtrx[2]*(Q_000002020*PR_002020000000+Q_000002120*PR_002020000001+Q_000002220*PR_002020000002+Q_000102020*PR_002020000010+Q_000102120*PR_002020000011+Q_000102220*PR_002020000012+Q_000202020*PR_002020000020+Q_000202120*PR_002020000021+Q_000202220*PR_002020000022); ans_temp[ans_id*36+17]+=Pmtrx[3]*(Q_001000021*PR_002020000000+Q_001000121*PR_002020000001+Q_001000221*PR_002020000002+Q_001000321*PR_002020000003+Q_101000021*PR_002020000100+Q_101000121*PR_002020000101+Q_101000221*PR_002020000102+Q_101000321*PR_002020000103); ans_temp[ans_id*36+17]+=Pmtrx[4]*(Q_000001021*PR_002020000000+Q_000001121*PR_002020000001+Q_000001221*PR_002020000002+Q_000001321*PR_002020000003+Q_000101021*PR_002020000010+Q_000101121*PR_002020000011+Q_000101221*PR_002020000012+Q_000101321*PR_002020000013); ans_temp[ans_id*36+17]+=Pmtrx[5]*(Q_000000022*PR_002020000000+Q_000000122*PR_002020000001+Q_000000222*PR_002020000002+Q_000000322*PR_002020000003+Q_000000422*PR_002020000004); ans_temp[ans_id*36+12]+=Pmtrx[6]*(Q_022000000*PR_001021000000+Q_122000000*PR_001021000100+Q_222000000*PR_001021000200+Q_322000000*PR_001021000300+Q_422000000*PR_001021000400); ans_temp[ans_id*36+12]+=Pmtrx[7]*(Q_021001000*PR_001021000000+Q_021101000*PR_001021000010+Q_121001000*PR_001021000100+Q_121101000*PR_001021000110+Q_221001000*PR_001021000200+Q_221101000*PR_001021000210+Q_321001000*PR_001021000300+Q_321101000*PR_001021000310); ans_temp[ans_id*36+12]+=Pmtrx[8]*(Q_020002000*PR_001021000000+Q_020102000*PR_001021000010+Q_020202000*PR_001021000020+Q_120002000*PR_001021000100+Q_120102000*PR_001021000110+Q_120202000*PR_001021000120+Q_220002000*PR_001021000200+Q_220102000*PR_001021000210+Q_220202000*PR_001021000220); ans_temp[ans_id*36+12]+=Pmtrx[9]*(Q_021000001*PR_001021000000+Q_021000101*PR_001021000001+Q_121000001*PR_001021000100+Q_121000101*PR_001021000101+Q_221000001*PR_001021000200+Q_221000101*PR_001021000201+Q_321000001*PR_001021000300+Q_321000101*PR_001021000301); ans_temp[ans_id*36+12]+=Pmtrx[10]*(Q_020001001*PR_001021000000+Q_020001101*PR_001021000001+Q_020101001*PR_001021000010+Q_020101101*PR_001021000011+Q_120001001*PR_001021000100+Q_120001101*PR_001021000101+Q_120101001*PR_001021000110+Q_120101101*PR_001021000111+Q_220001001*PR_001021000200+Q_220001101*PR_001021000201+Q_220101001*PR_001021000210+Q_220101101*PR_001021000211); ans_temp[ans_id*36+12]+=Pmtrx[11]*(Q_020000002*PR_001021000000+Q_020000102*PR_001021000001+Q_020000202*PR_001021000002+Q_120000002*PR_001021000100+Q_120000102*PR_001021000101+Q_120000202*PR_001021000102+Q_220000002*PR_001021000200+Q_220000102*PR_001021000201+Q_220000202*PR_001021000202); ans_temp[ans_id*36+13]+=Pmtrx[6]*(Q_012010000*PR_001021000000+Q_012110000*PR_001021000010+Q_112010000*PR_001021000100+Q_112110000*PR_001021000110+Q_212010000*PR_001021000200+Q_212110000*PR_001021000210+Q_312010000*PR_001021000300+Q_312110000*PR_001021000310); ans_temp[ans_id*36+13]+=Pmtrx[7]*(Q_011011000*PR_001021000000+Q_011111000*PR_001021000010+Q_011211000*PR_001021000020+Q_111011000*PR_001021000100+Q_111111000*PR_001021000110+Q_111211000*PR_001021000120+Q_211011000*PR_001021000200+Q_211111000*PR_001021000210+Q_211211000*PR_001021000220); ans_temp[ans_id*36+13]+=Pmtrx[8]*(Q_010012000*PR_001021000000+Q_010112000*PR_001021000010+Q_010212000*PR_001021000020+Q_010312000*PR_001021000030+Q_110012000*PR_001021000100+Q_110112000*PR_001021000110+Q_110212000*PR_001021000120+Q_110312000*PR_001021000130); ans_temp[ans_id*36+13]+=Pmtrx[9]*(Q_011010001*PR_001021000000+Q_011010101*PR_001021000001+Q_011110001*PR_001021000010+Q_011110101*PR_001021000011+Q_111010001*PR_001021000100+Q_111010101*PR_001021000101+Q_111110001*PR_001021000110+Q_111110101*PR_001021000111+Q_211010001*PR_001021000200+Q_211010101*PR_001021000201+Q_211110001*PR_001021000210+Q_211110101*PR_001021000211); ans_temp[ans_id*36+13]+=Pmtrx[10]*(Q_010011001*PR_001021000000+Q_010011101*PR_001021000001+Q_010111001*PR_001021000010+Q_010111101*PR_001021000011+Q_010211001*PR_001021000020+Q_010211101*PR_001021000021+Q_110011001*PR_001021000100+Q_110011101*PR_001021000101+Q_110111001*PR_001021000110+Q_110111101*PR_001021000111+Q_110211001*PR_001021000120+Q_110211101*PR_001021000121); ans_temp[ans_id*36+13]+=Pmtrx[11]*(Q_010010002*PR_001021000000+Q_010010102*PR_001021000001+Q_010010202*PR_001021000002+Q_010110002*PR_001021000010+Q_010110102*PR_001021000011+Q_010110202*PR_001021000012+Q_110010002*PR_001021000100+Q_110010102*PR_001021000101+Q_110010202*PR_001021000102+Q_110110002*PR_001021000110+Q_110110102*PR_001021000111+Q_110110202*PR_001021000112); ans_temp[ans_id*36+14]+=Pmtrx[6]*(Q_002020000*PR_001021000000+Q_002120000*PR_001021000010+Q_002220000*PR_001021000020+Q_102020000*PR_001021000100+Q_102120000*PR_001021000110+Q_102220000*PR_001021000120+Q_202020000*PR_001021000200+Q_202120000*PR_001021000210+Q_202220000*PR_001021000220); ans_temp[ans_id*36+14]+=Pmtrx[7]*(Q_001021000*PR_001021000000+Q_001121000*PR_001021000010+Q_001221000*PR_001021000020+Q_001321000*PR_001021000030+Q_101021000*PR_001021000100+Q_101121000*PR_001021000110+Q_101221000*PR_001021000120+Q_101321000*PR_001021000130); ans_temp[ans_id*36+14]+=Pmtrx[8]*(Q_000022000*PR_001021000000+Q_000122000*PR_001021000010+Q_000222000*PR_001021000020+Q_000322000*PR_001021000030+Q_000422000*PR_001021000040); ans_temp[ans_id*36+14]+=Pmtrx[9]*(Q_001020001*PR_001021000000+Q_001020101*PR_001021000001+Q_001120001*PR_001021000010+Q_001120101*PR_001021000011+Q_001220001*PR_001021000020+Q_001220101*PR_001021000021+Q_101020001*PR_001021000100+Q_101020101*PR_001021000101+Q_101120001*PR_001021000110+Q_101120101*PR_001021000111+Q_101220001*PR_001021000120+Q_101220101*PR_001021000121); ans_temp[ans_id*36+14]+=Pmtrx[10]*(Q_000021001*PR_001021000000+Q_000021101*PR_001021000001+Q_000121001*PR_001021000010+Q_000121101*PR_001021000011+Q_000221001*PR_001021000020+Q_000221101*PR_001021000021+Q_000321001*PR_001021000030+Q_000321101*PR_001021000031); ans_temp[ans_id*36+14]+=Pmtrx[11]*(Q_000020002*PR_001021000000+Q_000020102*PR_001021000001+Q_000020202*PR_001021000002+Q_000120002*PR_001021000010+Q_000120102*PR_001021000011+Q_000120202*PR_001021000012+Q_000220002*PR_001021000020+Q_000220102*PR_001021000021+Q_000220202*PR_001021000022); ans_temp[ans_id*36+15]+=Pmtrx[6]*(Q_012000010*PR_001021000000+Q_012000110*PR_001021000001+Q_112000010*PR_001021000100+Q_112000110*PR_001021000101+Q_212000010*PR_001021000200+Q_212000110*PR_001021000201+Q_312000010*PR_001021000300+Q_312000110*PR_001021000301); ans_temp[ans_id*36+15]+=Pmtrx[7]*(Q_011001010*PR_001021000000+Q_011001110*PR_001021000001+Q_011101010*PR_001021000010+Q_011101110*PR_001021000011+Q_111001010*PR_001021000100+Q_111001110*PR_001021000101+Q_111101010*PR_001021000110+Q_111101110*PR_001021000111+Q_211001010*PR_001021000200+Q_211001110*PR_001021000201+Q_211101010*PR_001021000210+Q_211101110*PR_001021000211); ans_temp[ans_id*36+15]+=Pmtrx[8]*(Q_010002010*PR_001021000000+Q_010002110*PR_001021000001+Q_010102010*PR_001021000010+Q_010102110*PR_001021000011+Q_010202010*PR_001021000020+Q_010202110*PR_001021000021+Q_110002010*PR_001021000100+Q_110002110*PR_001021000101+Q_110102010*PR_001021000110+Q_110102110*PR_001021000111+Q_110202010*PR_001021000120+Q_110202110*PR_001021000121); ans_temp[ans_id*36+15]+=Pmtrx[9]*(Q_011000011*PR_001021000000+Q_011000111*PR_001021000001+Q_011000211*PR_001021000002+Q_111000011*PR_001021000100+Q_111000111*PR_001021000101+Q_111000211*PR_001021000102+Q_211000011*PR_001021000200+Q_211000111*PR_001021000201+Q_211000211*PR_001021000202); ans_temp[ans_id*36+15]+=Pmtrx[10]*(Q_010001011*PR_001021000000+Q_010001111*PR_001021000001+Q_010001211*PR_001021000002+Q_010101011*PR_001021000010+Q_010101111*PR_001021000011+Q_010101211*PR_001021000012+Q_110001011*PR_001021000100+Q_110001111*PR_001021000101+Q_110001211*PR_001021000102+Q_110101011*PR_001021000110+Q_110101111*PR_001021000111+Q_110101211*PR_001021000112); ans_temp[ans_id*36+15]+=Pmtrx[11]*(Q_010000012*PR_001021000000+Q_010000112*PR_001021000001+Q_010000212*PR_001021000002+Q_010000312*PR_001021000003+Q_110000012*PR_001021000100+Q_110000112*PR_001021000101+Q_110000212*PR_001021000102+Q_110000312*PR_001021000103); ans_temp[ans_id*36+16]+=Pmtrx[6]*(Q_002010010*PR_001021000000+Q_002010110*PR_001021000001+Q_002110010*PR_001021000010+Q_002110110*PR_001021000011+Q_102010010*PR_001021000100+Q_102010110*PR_001021000101+Q_102110010*PR_001021000110+Q_102110110*PR_001021000111+Q_202010010*PR_001021000200+Q_202010110*PR_001021000201+Q_202110010*PR_001021000210+Q_202110110*PR_001021000211); ans_temp[ans_id*36+16]+=Pmtrx[7]*(Q_001011010*PR_001021000000+Q_001011110*PR_001021000001+Q_001111010*PR_001021000010+Q_001111110*PR_001021000011+Q_001211010*PR_001021000020+Q_001211110*PR_001021000021+Q_101011010*PR_001021000100+Q_101011110*PR_001021000101+Q_101111010*PR_001021000110+Q_101111110*PR_001021000111+Q_101211010*PR_001021000120+Q_101211110*PR_001021000121); ans_temp[ans_id*36+16]+=Pmtrx[8]*(Q_000012010*PR_001021000000+Q_000012110*PR_001021000001+Q_000112010*PR_001021000010+Q_000112110*PR_001021000011+Q_000212010*PR_001021000020+Q_000212110*PR_001021000021+Q_000312010*PR_001021000030+Q_000312110*PR_001021000031); ans_temp[ans_id*36+16]+=Pmtrx[9]*(Q_001010011*PR_001021000000+Q_001010111*PR_001021000001+Q_001010211*PR_001021000002+Q_001110011*PR_001021000010+Q_001110111*PR_001021000011+Q_001110211*PR_001021000012+Q_101010011*PR_001021000100+Q_101010111*PR_001021000101+Q_101010211*PR_001021000102+Q_101110011*PR_001021000110+Q_101110111*PR_001021000111+Q_101110211*PR_001021000112); ans_temp[ans_id*36+16]+=Pmtrx[10]*(Q_000011011*PR_001021000000+Q_000011111*PR_001021000001+Q_000011211*PR_001021000002+Q_000111011*PR_001021000010+Q_000111111*PR_001021000011+Q_000111211*PR_001021000012+Q_000211011*PR_001021000020+Q_000211111*PR_001021000021+Q_000211211*PR_001021000022); ans_temp[ans_id*36+16]+=Pmtrx[11]*(Q_000010012*PR_001021000000+Q_000010112*PR_001021000001+Q_000010212*PR_001021000002+Q_000010312*PR_001021000003+Q_000110012*PR_001021000010+Q_000110112*PR_001021000011+Q_000110212*PR_001021000012+Q_000110312*PR_001021000013); ans_temp[ans_id*36+17]+=Pmtrx[6]*(Q_002000020*PR_001021000000+Q_002000120*PR_001021000001+Q_002000220*PR_001021000002+Q_102000020*PR_001021000100+Q_102000120*PR_001021000101+Q_102000220*PR_001021000102+Q_202000020*PR_001021000200+Q_202000120*PR_001021000201+Q_202000220*PR_001021000202); ans_temp[ans_id*36+17]+=Pmtrx[7]*(Q_001001020*PR_001021000000+Q_001001120*PR_001021000001+Q_001001220*PR_001021000002+Q_001101020*PR_001021000010+Q_001101120*PR_001021000011+Q_001101220*PR_001021000012+Q_101001020*PR_001021000100+Q_101001120*PR_001021000101+Q_101001220*PR_001021000102+Q_101101020*PR_001021000110+Q_101101120*PR_001021000111+Q_101101220*PR_001021000112); ans_temp[ans_id*36+17]+=Pmtrx[8]*(Q_000002020*PR_001021000000+Q_000002120*PR_001021000001+Q_000002220*PR_001021000002+Q_000102020*PR_001021000010+Q_000102120*PR_001021000011+Q_000102220*PR_001021000012+Q_000202020*PR_001021000020+Q_000202120*PR_001021000021+Q_000202220*PR_001021000022); ans_temp[ans_id*36+17]+=Pmtrx[9]*(Q_001000021*PR_001021000000+Q_001000121*PR_001021000001+Q_001000221*PR_001021000002+Q_001000321*PR_001021000003+Q_101000021*PR_001021000100+Q_101000121*PR_001021000101+Q_101000221*PR_001021000102+Q_101000321*PR_001021000103); ans_temp[ans_id*36+17]+=Pmtrx[10]*(Q_000001021*PR_001021000000+Q_000001121*PR_001021000001+Q_000001221*PR_001021000002+Q_000001321*PR_001021000003+Q_000101021*PR_001021000010+Q_000101121*PR_001021000011+Q_000101221*PR_001021000012+Q_000101321*PR_001021000013); ans_temp[ans_id*36+17]+=Pmtrx[11]*(Q_000000022*PR_001021000000+Q_000000122*PR_001021000001+Q_000000222*PR_001021000002+Q_000000322*PR_001021000003+Q_000000422*PR_001021000004); ans_temp[ans_id*36+12]+=Pmtrx[12]*(Q_022000000*PR_000022000000+Q_122000000*PR_000022000100+Q_222000000*PR_000022000200+Q_322000000*PR_000022000300+Q_422000000*PR_000022000400); ans_temp[ans_id*36+12]+=Pmtrx[13]*(Q_021001000*PR_000022000000+Q_021101000*PR_000022000010+Q_121001000*PR_000022000100+Q_121101000*PR_000022000110+Q_221001000*PR_000022000200+Q_221101000*PR_000022000210+Q_321001000*PR_000022000300+Q_321101000*PR_000022000310); ans_temp[ans_id*36+12]+=Pmtrx[14]*(Q_020002000*PR_000022000000+Q_020102000*PR_000022000010+Q_020202000*PR_000022000020+Q_120002000*PR_000022000100+Q_120102000*PR_000022000110+Q_120202000*PR_000022000120+Q_220002000*PR_000022000200+Q_220102000*PR_000022000210+Q_220202000*PR_000022000220); ans_temp[ans_id*36+12]+=Pmtrx[15]*(Q_021000001*PR_000022000000+Q_021000101*PR_000022000001+Q_121000001*PR_000022000100+Q_121000101*PR_000022000101+Q_221000001*PR_000022000200+Q_221000101*PR_000022000201+Q_321000001*PR_000022000300+Q_321000101*PR_000022000301); ans_temp[ans_id*36+12]+=Pmtrx[16]*(Q_020001001*PR_000022000000+Q_020001101*PR_000022000001+Q_020101001*PR_000022000010+Q_020101101*PR_000022000011+Q_120001001*PR_000022000100+Q_120001101*PR_000022000101+Q_120101001*PR_000022000110+Q_120101101*PR_000022000111+Q_220001001*PR_000022000200+Q_220001101*PR_000022000201+Q_220101001*PR_000022000210+Q_220101101*PR_000022000211); ans_temp[ans_id*36+12]+=Pmtrx[17]*(Q_020000002*PR_000022000000+Q_020000102*PR_000022000001+Q_020000202*PR_000022000002+Q_120000002*PR_000022000100+Q_120000102*PR_000022000101+Q_120000202*PR_000022000102+Q_220000002*PR_000022000200+Q_220000102*PR_000022000201+Q_220000202*PR_000022000202); ans_temp[ans_id*36+13]+=Pmtrx[12]*(Q_012010000*PR_000022000000+Q_012110000*PR_000022000010+Q_112010000*PR_000022000100+Q_112110000*PR_000022000110+Q_212010000*PR_000022000200+Q_212110000*PR_000022000210+Q_312010000*PR_000022000300+Q_312110000*PR_000022000310); ans_temp[ans_id*36+13]+=Pmtrx[13]*(Q_011011000*PR_000022000000+Q_011111000*PR_000022000010+Q_011211000*PR_000022000020+Q_111011000*PR_000022000100+Q_111111000*PR_000022000110+Q_111211000*PR_000022000120+Q_211011000*PR_000022000200+Q_211111000*PR_000022000210+Q_211211000*PR_000022000220); ans_temp[ans_id*36+13]+=Pmtrx[14]*(Q_010012000*PR_000022000000+Q_010112000*PR_000022000010+Q_010212000*PR_000022000020+Q_010312000*PR_000022000030+Q_110012000*PR_000022000100+Q_110112000*PR_000022000110+Q_110212000*PR_000022000120+Q_110312000*PR_000022000130); ans_temp[ans_id*36+13]+=Pmtrx[15]*(Q_011010001*PR_000022000000+Q_011010101*PR_000022000001+Q_011110001*PR_000022000010+Q_011110101*PR_000022000011+Q_111010001*PR_000022000100+Q_111010101*PR_000022000101+Q_111110001*PR_000022000110+Q_111110101*PR_000022000111+Q_211010001*PR_000022000200+Q_211010101*PR_000022000201+Q_211110001*PR_000022000210+Q_211110101*PR_000022000211); ans_temp[ans_id*36+13]+=Pmtrx[16]*(Q_010011001*PR_000022000000+Q_010011101*PR_000022000001+Q_010111001*PR_000022000010+Q_010111101*PR_000022000011+Q_010211001*PR_000022000020+Q_010211101*PR_000022000021+Q_110011001*PR_000022000100+Q_110011101*PR_000022000101+Q_110111001*PR_000022000110+Q_110111101*PR_000022000111+Q_110211001*PR_000022000120+Q_110211101*PR_000022000121); ans_temp[ans_id*36+13]+=Pmtrx[17]*(Q_010010002*PR_000022000000+Q_010010102*PR_000022000001+Q_010010202*PR_000022000002+Q_010110002*PR_000022000010+Q_010110102*PR_000022000011+Q_010110202*PR_000022000012+Q_110010002*PR_000022000100+Q_110010102*PR_000022000101+Q_110010202*PR_000022000102+Q_110110002*PR_000022000110+Q_110110102*PR_000022000111+Q_110110202*PR_000022000112); ans_temp[ans_id*36+14]+=Pmtrx[12]*(Q_002020000*PR_000022000000+Q_002120000*PR_000022000010+Q_002220000*PR_000022000020+Q_102020000*PR_000022000100+Q_102120000*PR_000022000110+Q_102220000*PR_000022000120+Q_202020000*PR_000022000200+Q_202120000*PR_000022000210+Q_202220000*PR_000022000220); ans_temp[ans_id*36+14]+=Pmtrx[13]*(Q_001021000*PR_000022000000+Q_001121000*PR_000022000010+Q_001221000*PR_000022000020+Q_001321000*PR_000022000030+Q_101021000*PR_000022000100+Q_101121000*PR_000022000110+Q_101221000*PR_000022000120+Q_101321000*PR_000022000130); ans_temp[ans_id*36+14]+=Pmtrx[14]*(Q_000022000*PR_000022000000+Q_000122000*PR_000022000010+Q_000222000*PR_000022000020+Q_000322000*PR_000022000030+Q_000422000*PR_000022000040); ans_temp[ans_id*36+14]+=Pmtrx[15]*(Q_001020001*PR_000022000000+Q_001020101*PR_000022000001+Q_001120001*PR_000022000010+Q_001120101*PR_000022000011+Q_001220001*PR_000022000020+Q_001220101*PR_000022000021+Q_101020001*PR_000022000100+Q_101020101*PR_000022000101+Q_101120001*PR_000022000110+Q_101120101*PR_000022000111+Q_101220001*PR_000022000120+Q_101220101*PR_000022000121); ans_temp[ans_id*36+14]+=Pmtrx[16]*(Q_000021001*PR_000022000000+Q_000021101*PR_000022000001+Q_000121001*PR_000022000010+Q_000121101*PR_000022000011+Q_000221001*PR_000022000020+Q_000221101*PR_000022000021+Q_000321001*PR_000022000030+Q_000321101*PR_000022000031); ans_temp[ans_id*36+14]+=Pmtrx[17]*(Q_000020002*PR_000022000000+Q_000020102*PR_000022000001+Q_000020202*PR_000022000002+Q_000120002*PR_000022000010+Q_000120102*PR_000022000011+Q_000120202*PR_000022000012+Q_000220002*PR_000022000020+Q_000220102*PR_000022000021+Q_000220202*PR_000022000022); ans_temp[ans_id*36+15]+=Pmtrx[12]*(Q_012000010*PR_000022000000+Q_012000110*PR_000022000001+Q_112000010*PR_000022000100+Q_112000110*PR_000022000101+Q_212000010*PR_000022000200+Q_212000110*PR_000022000201+Q_312000010*PR_000022000300+Q_312000110*PR_000022000301); ans_temp[ans_id*36+15]+=Pmtrx[13]*(Q_011001010*PR_000022000000+Q_011001110*PR_000022000001+Q_011101010*PR_000022000010+Q_011101110*PR_000022000011+Q_111001010*PR_000022000100+Q_111001110*PR_000022000101+Q_111101010*PR_000022000110+Q_111101110*PR_000022000111+Q_211001010*PR_000022000200+Q_211001110*PR_000022000201+Q_211101010*PR_000022000210+Q_211101110*PR_000022000211); ans_temp[ans_id*36+15]+=Pmtrx[14]*(Q_010002010*PR_000022000000+Q_010002110*PR_000022000001+Q_010102010*PR_000022000010+Q_010102110*PR_000022000011+Q_010202010*PR_000022000020+Q_010202110*PR_000022000021+Q_110002010*PR_000022000100+Q_110002110*PR_000022000101+Q_110102010*PR_000022000110+Q_110102110*PR_000022000111+Q_110202010*PR_000022000120+Q_110202110*PR_000022000121); ans_temp[ans_id*36+15]+=Pmtrx[15]*(Q_011000011*PR_000022000000+Q_011000111*PR_000022000001+Q_011000211*PR_000022000002+Q_111000011*PR_000022000100+Q_111000111*PR_000022000101+Q_111000211*PR_000022000102+Q_211000011*PR_000022000200+Q_211000111*PR_000022000201+Q_211000211*PR_000022000202); ans_temp[ans_id*36+15]+=Pmtrx[16]*(Q_010001011*PR_000022000000+Q_010001111*PR_000022000001+Q_010001211*PR_000022000002+Q_010101011*PR_000022000010+Q_010101111*PR_000022000011+Q_010101211*PR_000022000012+Q_110001011*PR_000022000100+Q_110001111*PR_000022000101+Q_110001211*PR_000022000102+Q_110101011*PR_000022000110+Q_110101111*PR_000022000111+Q_110101211*PR_000022000112); ans_temp[ans_id*36+15]+=Pmtrx[17]*(Q_010000012*PR_000022000000+Q_010000112*PR_000022000001+Q_010000212*PR_000022000002+Q_010000312*PR_000022000003+Q_110000012*PR_000022000100+Q_110000112*PR_000022000101+Q_110000212*PR_000022000102+Q_110000312*PR_000022000103); ans_temp[ans_id*36+16]+=Pmtrx[12]*(Q_002010010*PR_000022000000+Q_002010110*PR_000022000001+Q_002110010*PR_000022000010+Q_002110110*PR_000022000011+Q_102010010*PR_000022000100+Q_102010110*PR_000022000101+Q_102110010*PR_000022000110+Q_102110110*PR_000022000111+Q_202010010*PR_000022000200+Q_202010110*PR_000022000201+Q_202110010*PR_000022000210+Q_202110110*PR_000022000211); ans_temp[ans_id*36+16]+=Pmtrx[13]*(Q_001011010*PR_000022000000+Q_001011110*PR_000022000001+Q_001111010*PR_000022000010+Q_001111110*PR_000022000011+Q_001211010*PR_000022000020+Q_001211110*PR_000022000021+Q_101011010*PR_000022000100+Q_101011110*PR_000022000101+Q_101111010*PR_000022000110+Q_101111110*PR_000022000111+Q_101211010*PR_000022000120+Q_101211110*PR_000022000121); ans_temp[ans_id*36+16]+=Pmtrx[14]*(Q_000012010*PR_000022000000+Q_000012110*PR_000022000001+Q_000112010*PR_000022000010+Q_000112110*PR_000022000011+Q_000212010*PR_000022000020+Q_000212110*PR_000022000021+Q_000312010*PR_000022000030+Q_000312110*PR_000022000031); ans_temp[ans_id*36+16]+=Pmtrx[15]*(Q_001010011*PR_000022000000+Q_001010111*PR_000022000001+Q_001010211*PR_000022000002+Q_001110011*PR_000022000010+Q_001110111*PR_000022000011+Q_001110211*PR_000022000012+Q_101010011*PR_000022000100+Q_101010111*PR_000022000101+Q_101010211*PR_000022000102+Q_101110011*PR_000022000110+Q_101110111*PR_000022000111+Q_101110211*PR_000022000112); ans_temp[ans_id*36+16]+=Pmtrx[16]*(Q_000011011*PR_000022000000+Q_000011111*PR_000022000001+Q_000011211*PR_000022000002+Q_000111011*PR_000022000010+Q_000111111*PR_000022000011+Q_000111211*PR_000022000012+Q_000211011*PR_000022000020+Q_000211111*PR_000022000021+Q_000211211*PR_000022000022); ans_temp[ans_id*36+16]+=Pmtrx[17]*(Q_000010012*PR_000022000000+Q_000010112*PR_000022000001+Q_000010212*PR_000022000002+Q_000010312*PR_000022000003+Q_000110012*PR_000022000010+Q_000110112*PR_000022000011+Q_000110212*PR_000022000012+Q_000110312*PR_000022000013); ans_temp[ans_id*36+17]+=Pmtrx[12]*(Q_002000020*PR_000022000000+Q_002000120*PR_000022000001+Q_002000220*PR_000022000002+Q_102000020*PR_000022000100+Q_102000120*PR_000022000101+Q_102000220*PR_000022000102+Q_202000020*PR_000022000200+Q_202000120*PR_000022000201+Q_202000220*PR_000022000202); ans_temp[ans_id*36+17]+=Pmtrx[13]*(Q_001001020*PR_000022000000+Q_001001120*PR_000022000001+Q_001001220*PR_000022000002+Q_001101020*PR_000022000010+Q_001101120*PR_000022000011+Q_001101220*PR_000022000012+Q_101001020*PR_000022000100+Q_101001120*PR_000022000101+Q_101001220*PR_000022000102+Q_101101020*PR_000022000110+Q_101101120*PR_000022000111+Q_101101220*PR_000022000112); ans_temp[ans_id*36+17]+=Pmtrx[14]*(Q_000002020*PR_000022000000+Q_000002120*PR_000022000001+Q_000002220*PR_000022000002+Q_000102020*PR_000022000010+Q_000102120*PR_000022000011+Q_000102220*PR_000022000012+Q_000202020*PR_000022000020+Q_000202120*PR_000022000021+Q_000202220*PR_000022000022); ans_temp[ans_id*36+17]+=Pmtrx[15]*(Q_001000021*PR_000022000000+Q_001000121*PR_000022000001+Q_001000221*PR_000022000002+Q_001000321*PR_000022000003+Q_101000021*PR_000022000100+Q_101000121*PR_000022000101+Q_101000221*PR_000022000102+Q_101000321*PR_000022000103); ans_temp[ans_id*36+17]+=Pmtrx[16]*(Q_000001021*PR_000022000000+Q_000001121*PR_000022000001+Q_000001221*PR_000022000002+Q_000001321*PR_000022000003+Q_000101021*PR_000022000010+Q_000101121*PR_000022000011+Q_000101221*PR_000022000012+Q_000101321*PR_000022000013); ans_temp[ans_id*36+17]+=Pmtrx[17]*(Q_000000022*PR_000022000000+Q_000000122*PR_000022000001+Q_000000222*PR_000022000002+Q_000000322*PR_000022000003+Q_000000422*PR_000022000004); ans_temp[ans_id*36+12]+=Pmtrx[18]*(Q_022000000*PR_001020001000+Q_122000000*PR_001020001100+Q_222000000*PR_001020001200+Q_322000000*PR_001020001300+Q_422000000*PR_001020001400); ans_temp[ans_id*36+12]+=Pmtrx[19]*(Q_021001000*PR_001020001000+Q_021101000*PR_001020001010+Q_121001000*PR_001020001100+Q_121101000*PR_001020001110+Q_221001000*PR_001020001200+Q_221101000*PR_001020001210+Q_321001000*PR_001020001300+Q_321101000*PR_001020001310); ans_temp[ans_id*36+12]+=Pmtrx[20]*(Q_020002000*PR_001020001000+Q_020102000*PR_001020001010+Q_020202000*PR_001020001020+Q_120002000*PR_001020001100+Q_120102000*PR_001020001110+Q_120202000*PR_001020001120+Q_220002000*PR_001020001200+Q_220102000*PR_001020001210+Q_220202000*PR_001020001220); ans_temp[ans_id*36+12]+=Pmtrx[21]*(Q_021000001*PR_001020001000+Q_021000101*PR_001020001001+Q_121000001*PR_001020001100+Q_121000101*PR_001020001101+Q_221000001*PR_001020001200+Q_221000101*PR_001020001201+Q_321000001*PR_001020001300+Q_321000101*PR_001020001301); ans_temp[ans_id*36+12]+=Pmtrx[22]*(Q_020001001*PR_001020001000+Q_020001101*PR_001020001001+Q_020101001*PR_001020001010+Q_020101101*PR_001020001011+Q_120001001*PR_001020001100+Q_120001101*PR_001020001101+Q_120101001*PR_001020001110+Q_120101101*PR_001020001111+Q_220001001*PR_001020001200+Q_220001101*PR_001020001201+Q_220101001*PR_001020001210+Q_220101101*PR_001020001211); ans_temp[ans_id*36+12]+=Pmtrx[23]*(Q_020000002*PR_001020001000+Q_020000102*PR_001020001001+Q_020000202*PR_001020001002+Q_120000002*PR_001020001100+Q_120000102*PR_001020001101+Q_120000202*PR_001020001102+Q_220000002*PR_001020001200+Q_220000102*PR_001020001201+Q_220000202*PR_001020001202); ans_temp[ans_id*36+13]+=Pmtrx[18]*(Q_012010000*PR_001020001000+Q_012110000*PR_001020001010+Q_112010000*PR_001020001100+Q_112110000*PR_001020001110+Q_212010000*PR_001020001200+Q_212110000*PR_001020001210+Q_312010000*PR_001020001300+Q_312110000*PR_001020001310); ans_temp[ans_id*36+13]+=Pmtrx[19]*(Q_011011000*PR_001020001000+Q_011111000*PR_001020001010+Q_011211000*PR_001020001020+Q_111011000*PR_001020001100+Q_111111000*PR_001020001110+Q_111211000*PR_001020001120+Q_211011000*PR_001020001200+Q_211111000*PR_001020001210+Q_211211000*PR_001020001220); ans_temp[ans_id*36+13]+=Pmtrx[20]*(Q_010012000*PR_001020001000+Q_010112000*PR_001020001010+Q_010212000*PR_001020001020+Q_010312000*PR_001020001030+Q_110012000*PR_001020001100+Q_110112000*PR_001020001110+Q_110212000*PR_001020001120+Q_110312000*PR_001020001130); ans_temp[ans_id*36+13]+=Pmtrx[21]*(Q_011010001*PR_001020001000+Q_011010101*PR_001020001001+Q_011110001*PR_001020001010+Q_011110101*PR_001020001011+Q_111010001*PR_001020001100+Q_111010101*PR_001020001101+Q_111110001*PR_001020001110+Q_111110101*PR_001020001111+Q_211010001*PR_001020001200+Q_211010101*PR_001020001201+Q_211110001*PR_001020001210+Q_211110101*PR_001020001211); ans_temp[ans_id*36+13]+=Pmtrx[22]*(Q_010011001*PR_001020001000+Q_010011101*PR_001020001001+Q_010111001*PR_001020001010+Q_010111101*PR_001020001011+Q_010211001*PR_001020001020+Q_010211101*PR_001020001021+Q_110011001*PR_001020001100+Q_110011101*PR_001020001101+Q_110111001*PR_001020001110+Q_110111101*PR_001020001111+Q_110211001*PR_001020001120+Q_110211101*PR_001020001121); ans_temp[ans_id*36+13]+=Pmtrx[23]*(Q_010010002*PR_001020001000+Q_010010102*PR_001020001001+Q_010010202*PR_001020001002+Q_010110002*PR_001020001010+Q_010110102*PR_001020001011+Q_010110202*PR_001020001012+Q_110010002*PR_001020001100+Q_110010102*PR_001020001101+Q_110010202*PR_001020001102+Q_110110002*PR_001020001110+Q_110110102*PR_001020001111+Q_110110202*PR_001020001112); ans_temp[ans_id*36+14]+=Pmtrx[18]*(Q_002020000*PR_001020001000+Q_002120000*PR_001020001010+Q_002220000*PR_001020001020+Q_102020000*PR_001020001100+Q_102120000*PR_001020001110+Q_102220000*PR_001020001120+Q_202020000*PR_001020001200+Q_202120000*PR_001020001210+Q_202220000*PR_001020001220); ans_temp[ans_id*36+14]+=Pmtrx[19]*(Q_001021000*PR_001020001000+Q_001121000*PR_001020001010+Q_001221000*PR_001020001020+Q_001321000*PR_001020001030+Q_101021000*PR_001020001100+Q_101121000*PR_001020001110+Q_101221000*PR_001020001120+Q_101321000*PR_001020001130); ans_temp[ans_id*36+14]+=Pmtrx[20]*(Q_000022000*PR_001020001000+Q_000122000*PR_001020001010+Q_000222000*PR_001020001020+Q_000322000*PR_001020001030+Q_000422000*PR_001020001040); ans_temp[ans_id*36+14]+=Pmtrx[21]*(Q_001020001*PR_001020001000+Q_001020101*PR_001020001001+Q_001120001*PR_001020001010+Q_001120101*PR_001020001011+Q_001220001*PR_001020001020+Q_001220101*PR_001020001021+Q_101020001*PR_001020001100+Q_101020101*PR_001020001101+Q_101120001*PR_001020001110+Q_101120101*PR_001020001111+Q_101220001*PR_001020001120+Q_101220101*PR_001020001121); ans_temp[ans_id*36+14]+=Pmtrx[22]*(Q_000021001*PR_001020001000+Q_000021101*PR_001020001001+Q_000121001*PR_001020001010+Q_000121101*PR_001020001011+Q_000221001*PR_001020001020+Q_000221101*PR_001020001021+Q_000321001*PR_001020001030+Q_000321101*PR_001020001031); ans_temp[ans_id*36+14]+=Pmtrx[23]*(Q_000020002*PR_001020001000+Q_000020102*PR_001020001001+Q_000020202*PR_001020001002+Q_000120002*PR_001020001010+Q_000120102*PR_001020001011+Q_000120202*PR_001020001012+Q_000220002*PR_001020001020+Q_000220102*PR_001020001021+Q_000220202*PR_001020001022); ans_temp[ans_id*36+15]+=Pmtrx[18]*(Q_012000010*PR_001020001000+Q_012000110*PR_001020001001+Q_112000010*PR_001020001100+Q_112000110*PR_001020001101+Q_212000010*PR_001020001200+Q_212000110*PR_001020001201+Q_312000010*PR_001020001300+Q_312000110*PR_001020001301); ans_temp[ans_id*36+15]+=Pmtrx[19]*(Q_011001010*PR_001020001000+Q_011001110*PR_001020001001+Q_011101010*PR_001020001010+Q_011101110*PR_001020001011+Q_111001010*PR_001020001100+Q_111001110*PR_001020001101+Q_111101010*PR_001020001110+Q_111101110*PR_001020001111+Q_211001010*PR_001020001200+Q_211001110*PR_001020001201+Q_211101010*PR_001020001210+Q_211101110*PR_001020001211); ans_temp[ans_id*36+15]+=Pmtrx[20]*(Q_010002010*PR_001020001000+Q_010002110*PR_001020001001+Q_010102010*PR_001020001010+Q_010102110*PR_001020001011+Q_010202010*PR_001020001020+Q_010202110*PR_001020001021+Q_110002010*PR_001020001100+Q_110002110*PR_001020001101+Q_110102010*PR_001020001110+Q_110102110*PR_001020001111+Q_110202010*PR_001020001120+Q_110202110*PR_001020001121); ans_temp[ans_id*36+15]+=Pmtrx[21]*(Q_011000011*PR_001020001000+Q_011000111*PR_001020001001+Q_011000211*PR_001020001002+Q_111000011*PR_001020001100+Q_111000111*PR_001020001101+Q_111000211*PR_001020001102+Q_211000011*PR_001020001200+Q_211000111*PR_001020001201+Q_211000211*PR_001020001202); ans_temp[ans_id*36+15]+=Pmtrx[22]*(Q_010001011*PR_001020001000+Q_010001111*PR_001020001001+Q_010001211*PR_001020001002+Q_010101011*PR_001020001010+Q_010101111*PR_001020001011+Q_010101211*PR_001020001012+Q_110001011*PR_001020001100+Q_110001111*PR_001020001101+Q_110001211*PR_001020001102+Q_110101011*PR_001020001110+Q_110101111*PR_001020001111+Q_110101211*PR_001020001112); ans_temp[ans_id*36+15]+=Pmtrx[23]*(Q_010000012*PR_001020001000+Q_010000112*PR_001020001001+Q_010000212*PR_001020001002+Q_010000312*PR_001020001003+Q_110000012*PR_001020001100+Q_110000112*PR_001020001101+Q_110000212*PR_001020001102+Q_110000312*PR_001020001103); ans_temp[ans_id*36+16]+=Pmtrx[18]*(Q_002010010*PR_001020001000+Q_002010110*PR_001020001001+Q_002110010*PR_001020001010+Q_002110110*PR_001020001011+Q_102010010*PR_001020001100+Q_102010110*PR_001020001101+Q_102110010*PR_001020001110+Q_102110110*PR_001020001111+Q_202010010*PR_001020001200+Q_202010110*PR_001020001201+Q_202110010*PR_001020001210+Q_202110110*PR_001020001211); ans_temp[ans_id*36+16]+=Pmtrx[19]*(Q_001011010*PR_001020001000+Q_001011110*PR_001020001001+Q_001111010*PR_001020001010+Q_001111110*PR_001020001011+Q_001211010*PR_001020001020+Q_001211110*PR_001020001021+Q_101011010*PR_001020001100+Q_101011110*PR_001020001101+Q_101111010*PR_001020001110+Q_101111110*PR_001020001111+Q_101211010*PR_001020001120+Q_101211110*PR_001020001121); ans_temp[ans_id*36+16]+=Pmtrx[20]*(Q_000012010*PR_001020001000+Q_000012110*PR_001020001001+Q_000112010*PR_001020001010+Q_000112110*PR_001020001011+Q_000212010*PR_001020001020+Q_000212110*PR_001020001021+Q_000312010*PR_001020001030+Q_000312110*PR_001020001031); ans_temp[ans_id*36+16]+=Pmtrx[21]*(Q_001010011*PR_001020001000+Q_001010111*PR_001020001001+Q_001010211*PR_001020001002+Q_001110011*PR_001020001010+Q_001110111*PR_001020001011+Q_001110211*PR_001020001012+Q_101010011*PR_001020001100+Q_101010111*PR_001020001101+Q_101010211*PR_001020001102+Q_101110011*PR_001020001110+Q_101110111*PR_001020001111+Q_101110211*PR_001020001112); ans_temp[ans_id*36+16]+=Pmtrx[22]*(Q_000011011*PR_001020001000+Q_000011111*PR_001020001001+Q_000011211*PR_001020001002+Q_000111011*PR_001020001010+Q_000111111*PR_001020001011+Q_000111211*PR_001020001012+Q_000211011*PR_001020001020+Q_000211111*PR_001020001021+Q_000211211*PR_001020001022); ans_temp[ans_id*36+16]+=Pmtrx[23]*(Q_000010012*PR_001020001000+Q_000010112*PR_001020001001+Q_000010212*PR_001020001002+Q_000010312*PR_001020001003+Q_000110012*PR_001020001010+Q_000110112*PR_001020001011+Q_000110212*PR_001020001012+Q_000110312*PR_001020001013); ans_temp[ans_id*36+17]+=Pmtrx[18]*(Q_002000020*PR_001020001000+Q_002000120*PR_001020001001+Q_002000220*PR_001020001002+Q_102000020*PR_001020001100+Q_102000120*PR_001020001101+Q_102000220*PR_001020001102+Q_202000020*PR_001020001200+Q_202000120*PR_001020001201+Q_202000220*PR_001020001202); ans_temp[ans_id*36+17]+=Pmtrx[19]*(Q_001001020*PR_001020001000+Q_001001120*PR_001020001001+Q_001001220*PR_001020001002+Q_001101020*PR_001020001010+Q_001101120*PR_001020001011+Q_001101220*PR_001020001012+Q_101001020*PR_001020001100+Q_101001120*PR_001020001101+Q_101001220*PR_001020001102+Q_101101020*PR_001020001110+Q_101101120*PR_001020001111+Q_101101220*PR_001020001112); ans_temp[ans_id*36+17]+=Pmtrx[20]*(Q_000002020*PR_001020001000+Q_000002120*PR_001020001001+Q_000002220*PR_001020001002+Q_000102020*PR_001020001010+Q_000102120*PR_001020001011+Q_000102220*PR_001020001012+Q_000202020*PR_001020001020+Q_000202120*PR_001020001021+Q_000202220*PR_001020001022); ans_temp[ans_id*36+17]+=Pmtrx[21]*(Q_001000021*PR_001020001000+Q_001000121*PR_001020001001+Q_001000221*PR_001020001002+Q_001000321*PR_001020001003+Q_101000021*PR_001020001100+Q_101000121*PR_001020001101+Q_101000221*PR_001020001102+Q_101000321*PR_001020001103); ans_temp[ans_id*36+17]+=Pmtrx[22]*(Q_000001021*PR_001020001000+Q_000001121*PR_001020001001+Q_000001221*PR_001020001002+Q_000001321*PR_001020001003+Q_000101021*PR_001020001010+Q_000101121*PR_001020001011+Q_000101221*PR_001020001012+Q_000101321*PR_001020001013); ans_temp[ans_id*36+17]+=Pmtrx[23]*(Q_000000022*PR_001020001000+Q_000000122*PR_001020001001+Q_000000222*PR_001020001002+Q_000000322*PR_001020001003+Q_000000422*PR_001020001004); ans_temp[ans_id*36+12]+=Pmtrx[24]*(Q_022000000*PR_000021001000+Q_122000000*PR_000021001100+Q_222000000*PR_000021001200+Q_322000000*PR_000021001300+Q_422000000*PR_000021001400); ans_temp[ans_id*36+12]+=Pmtrx[25]*(Q_021001000*PR_000021001000+Q_021101000*PR_000021001010+Q_121001000*PR_000021001100+Q_121101000*PR_000021001110+Q_221001000*PR_000021001200+Q_221101000*PR_000021001210+Q_321001000*PR_000021001300+Q_321101000*PR_000021001310); ans_temp[ans_id*36+12]+=Pmtrx[26]*(Q_020002000*PR_000021001000+Q_020102000*PR_000021001010+Q_020202000*PR_000021001020+Q_120002000*PR_000021001100+Q_120102000*PR_000021001110+Q_120202000*PR_000021001120+Q_220002000*PR_000021001200+Q_220102000*PR_000021001210+Q_220202000*PR_000021001220); ans_temp[ans_id*36+12]+=Pmtrx[27]*(Q_021000001*PR_000021001000+Q_021000101*PR_000021001001+Q_121000001*PR_000021001100+Q_121000101*PR_000021001101+Q_221000001*PR_000021001200+Q_221000101*PR_000021001201+Q_321000001*PR_000021001300+Q_321000101*PR_000021001301); ans_temp[ans_id*36+12]+=Pmtrx[28]*(Q_020001001*PR_000021001000+Q_020001101*PR_000021001001+Q_020101001*PR_000021001010+Q_020101101*PR_000021001011+Q_120001001*PR_000021001100+Q_120001101*PR_000021001101+Q_120101001*PR_000021001110+Q_120101101*PR_000021001111+Q_220001001*PR_000021001200+Q_220001101*PR_000021001201+Q_220101001*PR_000021001210+Q_220101101*PR_000021001211); ans_temp[ans_id*36+12]+=Pmtrx[29]*(Q_020000002*PR_000021001000+Q_020000102*PR_000021001001+Q_020000202*PR_000021001002+Q_120000002*PR_000021001100+Q_120000102*PR_000021001101+Q_120000202*PR_000021001102+Q_220000002*PR_000021001200+Q_220000102*PR_000021001201+Q_220000202*PR_000021001202); ans_temp[ans_id*36+13]+=Pmtrx[24]*(Q_012010000*PR_000021001000+Q_012110000*PR_000021001010+Q_112010000*PR_000021001100+Q_112110000*PR_000021001110+Q_212010000*PR_000021001200+Q_212110000*PR_000021001210+Q_312010000*PR_000021001300+Q_312110000*PR_000021001310); ans_temp[ans_id*36+13]+=Pmtrx[25]*(Q_011011000*PR_000021001000+Q_011111000*PR_000021001010+Q_011211000*PR_000021001020+Q_111011000*PR_000021001100+Q_111111000*PR_000021001110+Q_111211000*PR_000021001120+Q_211011000*PR_000021001200+Q_211111000*PR_000021001210+Q_211211000*PR_000021001220); ans_temp[ans_id*36+13]+=Pmtrx[26]*(Q_010012000*PR_000021001000+Q_010112000*PR_000021001010+Q_010212000*PR_000021001020+Q_010312000*PR_000021001030+Q_110012000*PR_000021001100+Q_110112000*PR_000021001110+Q_110212000*PR_000021001120+Q_110312000*PR_000021001130); ans_temp[ans_id*36+13]+=Pmtrx[27]*(Q_011010001*PR_000021001000+Q_011010101*PR_000021001001+Q_011110001*PR_000021001010+Q_011110101*PR_000021001011+Q_111010001*PR_000021001100+Q_111010101*PR_000021001101+Q_111110001*PR_000021001110+Q_111110101*PR_000021001111+Q_211010001*PR_000021001200+Q_211010101*PR_000021001201+Q_211110001*PR_000021001210+Q_211110101*PR_000021001211); ans_temp[ans_id*36+13]+=Pmtrx[28]*(Q_010011001*PR_000021001000+Q_010011101*PR_000021001001+Q_010111001*PR_000021001010+Q_010111101*PR_000021001011+Q_010211001*PR_000021001020+Q_010211101*PR_000021001021+Q_110011001*PR_000021001100+Q_110011101*PR_000021001101+Q_110111001*PR_000021001110+Q_110111101*PR_000021001111+Q_110211001*PR_000021001120+Q_110211101*PR_000021001121); ans_temp[ans_id*36+13]+=Pmtrx[29]*(Q_010010002*PR_000021001000+Q_010010102*PR_000021001001+Q_010010202*PR_000021001002+Q_010110002*PR_000021001010+Q_010110102*PR_000021001011+Q_010110202*PR_000021001012+Q_110010002*PR_000021001100+Q_110010102*PR_000021001101+Q_110010202*PR_000021001102+Q_110110002*PR_000021001110+Q_110110102*PR_000021001111+Q_110110202*PR_000021001112); ans_temp[ans_id*36+14]+=Pmtrx[24]*(Q_002020000*PR_000021001000+Q_002120000*PR_000021001010+Q_002220000*PR_000021001020+Q_102020000*PR_000021001100+Q_102120000*PR_000021001110+Q_102220000*PR_000021001120+Q_202020000*PR_000021001200+Q_202120000*PR_000021001210+Q_202220000*PR_000021001220); ans_temp[ans_id*36+14]+=Pmtrx[25]*(Q_001021000*PR_000021001000+Q_001121000*PR_000021001010+Q_001221000*PR_000021001020+Q_001321000*PR_000021001030+Q_101021000*PR_000021001100+Q_101121000*PR_000021001110+Q_101221000*PR_000021001120+Q_101321000*PR_000021001130); ans_temp[ans_id*36+14]+=Pmtrx[26]*(Q_000022000*PR_000021001000+Q_000122000*PR_000021001010+Q_000222000*PR_000021001020+Q_000322000*PR_000021001030+Q_000422000*PR_000021001040); ans_temp[ans_id*36+14]+=Pmtrx[27]*(Q_001020001*PR_000021001000+Q_001020101*PR_000021001001+Q_001120001*PR_000021001010+Q_001120101*PR_000021001011+Q_001220001*PR_000021001020+Q_001220101*PR_000021001021+Q_101020001*PR_000021001100+Q_101020101*PR_000021001101+Q_101120001*PR_000021001110+Q_101120101*PR_000021001111+Q_101220001*PR_000021001120+Q_101220101*PR_000021001121); ans_temp[ans_id*36+14]+=Pmtrx[28]*(Q_000021001*PR_000021001000+Q_000021101*PR_000021001001+Q_000121001*PR_000021001010+Q_000121101*PR_000021001011+Q_000221001*PR_000021001020+Q_000221101*PR_000021001021+Q_000321001*PR_000021001030+Q_000321101*PR_000021001031); ans_temp[ans_id*36+14]+=Pmtrx[29]*(Q_000020002*PR_000021001000+Q_000020102*PR_000021001001+Q_000020202*PR_000021001002+Q_000120002*PR_000021001010+Q_000120102*PR_000021001011+Q_000120202*PR_000021001012+Q_000220002*PR_000021001020+Q_000220102*PR_000021001021+Q_000220202*PR_000021001022); ans_temp[ans_id*36+15]+=Pmtrx[24]*(Q_012000010*PR_000021001000+Q_012000110*PR_000021001001+Q_112000010*PR_000021001100+Q_112000110*PR_000021001101+Q_212000010*PR_000021001200+Q_212000110*PR_000021001201+Q_312000010*PR_000021001300+Q_312000110*PR_000021001301); ans_temp[ans_id*36+15]+=Pmtrx[25]*(Q_011001010*PR_000021001000+Q_011001110*PR_000021001001+Q_011101010*PR_000021001010+Q_011101110*PR_000021001011+Q_111001010*PR_000021001100+Q_111001110*PR_000021001101+Q_111101010*PR_000021001110+Q_111101110*PR_000021001111+Q_211001010*PR_000021001200+Q_211001110*PR_000021001201+Q_211101010*PR_000021001210+Q_211101110*PR_000021001211); ans_temp[ans_id*36+15]+=Pmtrx[26]*(Q_010002010*PR_000021001000+Q_010002110*PR_000021001001+Q_010102010*PR_000021001010+Q_010102110*PR_000021001011+Q_010202010*PR_000021001020+Q_010202110*PR_000021001021+Q_110002010*PR_000021001100+Q_110002110*PR_000021001101+Q_110102010*PR_000021001110+Q_110102110*PR_000021001111+Q_110202010*PR_000021001120+Q_110202110*PR_000021001121); ans_temp[ans_id*36+15]+=Pmtrx[27]*(Q_011000011*PR_000021001000+Q_011000111*PR_000021001001+Q_011000211*PR_000021001002+Q_111000011*PR_000021001100+Q_111000111*PR_000021001101+Q_111000211*PR_000021001102+Q_211000011*PR_000021001200+Q_211000111*PR_000021001201+Q_211000211*PR_000021001202); ans_temp[ans_id*36+15]+=Pmtrx[28]*(Q_010001011*PR_000021001000+Q_010001111*PR_000021001001+Q_010001211*PR_000021001002+Q_010101011*PR_000021001010+Q_010101111*PR_000021001011+Q_010101211*PR_000021001012+Q_110001011*PR_000021001100+Q_110001111*PR_000021001101+Q_110001211*PR_000021001102+Q_110101011*PR_000021001110+Q_110101111*PR_000021001111+Q_110101211*PR_000021001112); ans_temp[ans_id*36+15]+=Pmtrx[29]*(Q_010000012*PR_000021001000+Q_010000112*PR_000021001001+Q_010000212*PR_000021001002+Q_010000312*PR_000021001003+Q_110000012*PR_000021001100+Q_110000112*PR_000021001101+Q_110000212*PR_000021001102+Q_110000312*PR_000021001103); ans_temp[ans_id*36+16]+=Pmtrx[24]*(Q_002010010*PR_000021001000+Q_002010110*PR_000021001001+Q_002110010*PR_000021001010+Q_002110110*PR_000021001011+Q_102010010*PR_000021001100+Q_102010110*PR_000021001101+Q_102110010*PR_000021001110+Q_102110110*PR_000021001111+Q_202010010*PR_000021001200+Q_202010110*PR_000021001201+Q_202110010*PR_000021001210+Q_202110110*PR_000021001211); ans_temp[ans_id*36+16]+=Pmtrx[25]*(Q_001011010*PR_000021001000+Q_001011110*PR_000021001001+Q_001111010*PR_000021001010+Q_001111110*PR_000021001011+Q_001211010*PR_000021001020+Q_001211110*PR_000021001021+Q_101011010*PR_000021001100+Q_101011110*PR_000021001101+Q_101111010*PR_000021001110+Q_101111110*PR_000021001111+Q_101211010*PR_000021001120+Q_101211110*PR_000021001121); ans_temp[ans_id*36+16]+=Pmtrx[26]*(Q_000012010*PR_000021001000+Q_000012110*PR_000021001001+Q_000112010*PR_000021001010+Q_000112110*PR_000021001011+Q_000212010*PR_000021001020+Q_000212110*PR_000021001021+Q_000312010*PR_000021001030+Q_000312110*PR_000021001031); ans_temp[ans_id*36+16]+=Pmtrx[27]*(Q_001010011*PR_000021001000+Q_001010111*PR_000021001001+Q_001010211*PR_000021001002+Q_001110011*PR_000021001010+Q_001110111*PR_000021001011+Q_001110211*PR_000021001012+Q_101010011*PR_000021001100+Q_101010111*PR_000021001101+Q_101010211*PR_000021001102+Q_101110011*PR_000021001110+Q_101110111*PR_000021001111+Q_101110211*PR_000021001112); ans_temp[ans_id*36+16]+=Pmtrx[28]*(Q_000011011*PR_000021001000+Q_000011111*PR_000021001001+Q_000011211*PR_000021001002+Q_000111011*PR_000021001010+Q_000111111*PR_000021001011+Q_000111211*PR_000021001012+Q_000211011*PR_000021001020+Q_000211111*PR_000021001021+Q_000211211*PR_000021001022); ans_temp[ans_id*36+16]+=Pmtrx[29]*(Q_000010012*PR_000021001000+Q_000010112*PR_000021001001+Q_000010212*PR_000021001002+Q_000010312*PR_000021001003+Q_000110012*PR_000021001010+Q_000110112*PR_000021001011+Q_000110212*PR_000021001012+Q_000110312*PR_000021001013); ans_temp[ans_id*36+17]+=Pmtrx[24]*(Q_002000020*PR_000021001000+Q_002000120*PR_000021001001+Q_002000220*PR_000021001002+Q_102000020*PR_000021001100+Q_102000120*PR_000021001101+Q_102000220*PR_000021001102+Q_202000020*PR_000021001200+Q_202000120*PR_000021001201+Q_202000220*PR_000021001202); ans_temp[ans_id*36+17]+=Pmtrx[25]*(Q_001001020*PR_000021001000+Q_001001120*PR_000021001001+Q_001001220*PR_000021001002+Q_001101020*PR_000021001010+Q_001101120*PR_000021001011+Q_001101220*PR_000021001012+Q_101001020*PR_000021001100+Q_101001120*PR_000021001101+Q_101001220*PR_000021001102+Q_101101020*PR_000021001110+Q_101101120*PR_000021001111+Q_101101220*PR_000021001112); ans_temp[ans_id*36+17]+=Pmtrx[26]*(Q_000002020*PR_000021001000+Q_000002120*PR_000021001001+Q_000002220*PR_000021001002+Q_000102020*PR_000021001010+Q_000102120*PR_000021001011+Q_000102220*PR_000021001012+Q_000202020*PR_000021001020+Q_000202120*PR_000021001021+Q_000202220*PR_000021001022); ans_temp[ans_id*36+17]+=Pmtrx[27]*(Q_001000021*PR_000021001000+Q_001000121*PR_000021001001+Q_001000221*PR_000021001002+Q_001000321*PR_000021001003+Q_101000021*PR_000021001100+Q_101000121*PR_000021001101+Q_101000221*PR_000021001102+Q_101000321*PR_000021001103); ans_temp[ans_id*36+17]+=Pmtrx[28]*(Q_000001021*PR_000021001000+Q_000001121*PR_000021001001+Q_000001221*PR_000021001002+Q_000001321*PR_000021001003+Q_000101021*PR_000021001010+Q_000101121*PR_000021001011+Q_000101221*PR_000021001012+Q_000101321*PR_000021001013); ans_temp[ans_id*36+17]+=Pmtrx[29]*(Q_000000022*PR_000021001000+Q_000000122*PR_000021001001+Q_000000222*PR_000021001002+Q_000000322*PR_000021001003+Q_000000422*PR_000021001004); ans_temp[ans_id*36+12]+=Pmtrx[30]*(Q_022000000*PR_000020002000+Q_122000000*PR_000020002100+Q_222000000*PR_000020002200+Q_322000000*PR_000020002300+Q_422000000*PR_000020002400); ans_temp[ans_id*36+12]+=Pmtrx[31]*(Q_021001000*PR_000020002000+Q_021101000*PR_000020002010+Q_121001000*PR_000020002100+Q_121101000*PR_000020002110+Q_221001000*PR_000020002200+Q_221101000*PR_000020002210+Q_321001000*PR_000020002300+Q_321101000*PR_000020002310); ans_temp[ans_id*36+12]+=Pmtrx[32]*(Q_020002000*PR_000020002000+Q_020102000*PR_000020002010+Q_020202000*PR_000020002020+Q_120002000*PR_000020002100+Q_120102000*PR_000020002110+Q_120202000*PR_000020002120+Q_220002000*PR_000020002200+Q_220102000*PR_000020002210+Q_220202000*PR_000020002220); ans_temp[ans_id*36+12]+=Pmtrx[33]*(Q_021000001*PR_000020002000+Q_021000101*PR_000020002001+Q_121000001*PR_000020002100+Q_121000101*PR_000020002101+Q_221000001*PR_000020002200+Q_221000101*PR_000020002201+Q_321000001*PR_000020002300+Q_321000101*PR_000020002301); ans_temp[ans_id*36+12]+=Pmtrx[34]*(Q_020001001*PR_000020002000+Q_020001101*PR_000020002001+Q_020101001*PR_000020002010+Q_020101101*PR_000020002011+Q_120001001*PR_000020002100+Q_120001101*PR_000020002101+Q_120101001*PR_000020002110+Q_120101101*PR_000020002111+Q_220001001*PR_000020002200+Q_220001101*PR_000020002201+Q_220101001*PR_000020002210+Q_220101101*PR_000020002211); ans_temp[ans_id*36+12]+=Pmtrx[35]*(Q_020000002*PR_000020002000+Q_020000102*PR_000020002001+Q_020000202*PR_000020002002+Q_120000002*PR_000020002100+Q_120000102*PR_000020002101+Q_120000202*PR_000020002102+Q_220000002*PR_000020002200+Q_220000102*PR_000020002201+Q_220000202*PR_000020002202); ans_temp[ans_id*36+13]+=Pmtrx[30]*(Q_012010000*PR_000020002000+Q_012110000*PR_000020002010+Q_112010000*PR_000020002100+Q_112110000*PR_000020002110+Q_212010000*PR_000020002200+Q_212110000*PR_000020002210+Q_312010000*PR_000020002300+Q_312110000*PR_000020002310); ans_temp[ans_id*36+13]+=Pmtrx[31]*(Q_011011000*PR_000020002000+Q_011111000*PR_000020002010+Q_011211000*PR_000020002020+Q_111011000*PR_000020002100+Q_111111000*PR_000020002110+Q_111211000*PR_000020002120+Q_211011000*PR_000020002200+Q_211111000*PR_000020002210+Q_211211000*PR_000020002220); ans_temp[ans_id*36+13]+=Pmtrx[32]*(Q_010012000*PR_000020002000+Q_010112000*PR_000020002010+Q_010212000*PR_000020002020+Q_010312000*PR_000020002030+Q_110012000*PR_000020002100+Q_110112000*PR_000020002110+Q_110212000*PR_000020002120+Q_110312000*PR_000020002130); ans_temp[ans_id*36+13]+=Pmtrx[33]*(Q_011010001*PR_000020002000+Q_011010101*PR_000020002001+Q_011110001*PR_000020002010+Q_011110101*PR_000020002011+Q_111010001*PR_000020002100+Q_111010101*PR_000020002101+Q_111110001*PR_000020002110+Q_111110101*PR_000020002111+Q_211010001*PR_000020002200+Q_211010101*PR_000020002201+Q_211110001*PR_000020002210+Q_211110101*PR_000020002211); ans_temp[ans_id*36+13]+=Pmtrx[34]*(Q_010011001*PR_000020002000+Q_010011101*PR_000020002001+Q_010111001*PR_000020002010+Q_010111101*PR_000020002011+Q_010211001*PR_000020002020+Q_010211101*PR_000020002021+Q_110011001*PR_000020002100+Q_110011101*PR_000020002101+Q_110111001*PR_000020002110+Q_110111101*PR_000020002111+Q_110211001*PR_000020002120+Q_110211101*PR_000020002121); ans_temp[ans_id*36+13]+=Pmtrx[35]*(Q_010010002*PR_000020002000+Q_010010102*PR_000020002001+Q_010010202*PR_000020002002+Q_010110002*PR_000020002010+Q_010110102*PR_000020002011+Q_010110202*PR_000020002012+Q_110010002*PR_000020002100+Q_110010102*PR_000020002101+Q_110010202*PR_000020002102+Q_110110002*PR_000020002110+Q_110110102*PR_000020002111+Q_110110202*PR_000020002112); ans_temp[ans_id*36+14]+=Pmtrx[30]*(Q_002020000*PR_000020002000+Q_002120000*PR_000020002010+Q_002220000*PR_000020002020+Q_102020000*PR_000020002100+Q_102120000*PR_000020002110+Q_102220000*PR_000020002120+Q_202020000*PR_000020002200+Q_202120000*PR_000020002210+Q_202220000*PR_000020002220); ans_temp[ans_id*36+14]+=Pmtrx[31]*(Q_001021000*PR_000020002000+Q_001121000*PR_000020002010+Q_001221000*PR_000020002020+Q_001321000*PR_000020002030+Q_101021000*PR_000020002100+Q_101121000*PR_000020002110+Q_101221000*PR_000020002120+Q_101321000*PR_000020002130); ans_temp[ans_id*36+14]+=Pmtrx[32]*(Q_000022000*PR_000020002000+Q_000122000*PR_000020002010+Q_000222000*PR_000020002020+Q_000322000*PR_000020002030+Q_000422000*PR_000020002040); ans_temp[ans_id*36+14]+=Pmtrx[33]*(Q_001020001*PR_000020002000+Q_001020101*PR_000020002001+Q_001120001*PR_000020002010+Q_001120101*PR_000020002011+Q_001220001*PR_000020002020+Q_001220101*PR_000020002021+Q_101020001*PR_000020002100+Q_101020101*PR_000020002101+Q_101120001*PR_000020002110+Q_101120101*PR_000020002111+Q_101220001*PR_000020002120+Q_101220101*PR_000020002121); ans_temp[ans_id*36+14]+=Pmtrx[34]*(Q_000021001*PR_000020002000+Q_000021101*PR_000020002001+Q_000121001*PR_000020002010+Q_000121101*PR_000020002011+Q_000221001*PR_000020002020+Q_000221101*PR_000020002021+Q_000321001*PR_000020002030+Q_000321101*PR_000020002031); ans_temp[ans_id*36+14]+=Pmtrx[35]*(Q_000020002*PR_000020002000+Q_000020102*PR_000020002001+Q_000020202*PR_000020002002+Q_000120002*PR_000020002010+Q_000120102*PR_000020002011+Q_000120202*PR_000020002012+Q_000220002*PR_000020002020+Q_000220102*PR_000020002021+Q_000220202*PR_000020002022); ans_temp[ans_id*36+15]+=Pmtrx[30]*(Q_012000010*PR_000020002000+Q_012000110*PR_000020002001+Q_112000010*PR_000020002100+Q_112000110*PR_000020002101+Q_212000010*PR_000020002200+Q_212000110*PR_000020002201+Q_312000010*PR_000020002300+Q_312000110*PR_000020002301); ans_temp[ans_id*36+15]+=Pmtrx[31]*(Q_011001010*PR_000020002000+Q_011001110*PR_000020002001+Q_011101010*PR_000020002010+Q_011101110*PR_000020002011+Q_111001010*PR_000020002100+Q_111001110*PR_000020002101+Q_111101010*PR_000020002110+Q_111101110*PR_000020002111+Q_211001010*PR_000020002200+Q_211001110*PR_000020002201+Q_211101010*PR_000020002210+Q_211101110*PR_000020002211); ans_temp[ans_id*36+15]+=Pmtrx[32]*(Q_010002010*PR_000020002000+Q_010002110*PR_000020002001+Q_010102010*PR_000020002010+Q_010102110*PR_000020002011+Q_010202010*PR_000020002020+Q_010202110*PR_000020002021+Q_110002010*PR_000020002100+Q_110002110*PR_000020002101+Q_110102010*PR_000020002110+Q_110102110*PR_000020002111+Q_110202010*PR_000020002120+Q_110202110*PR_000020002121); ans_temp[ans_id*36+15]+=Pmtrx[33]*(Q_011000011*PR_000020002000+Q_011000111*PR_000020002001+Q_011000211*PR_000020002002+Q_111000011*PR_000020002100+Q_111000111*PR_000020002101+Q_111000211*PR_000020002102+Q_211000011*PR_000020002200+Q_211000111*PR_000020002201+Q_211000211*PR_000020002202); ans_temp[ans_id*36+15]+=Pmtrx[34]*(Q_010001011*PR_000020002000+Q_010001111*PR_000020002001+Q_010001211*PR_000020002002+Q_010101011*PR_000020002010+Q_010101111*PR_000020002011+Q_010101211*PR_000020002012+Q_110001011*PR_000020002100+Q_110001111*PR_000020002101+Q_110001211*PR_000020002102+Q_110101011*PR_000020002110+Q_110101111*PR_000020002111+Q_110101211*PR_000020002112); ans_temp[ans_id*36+15]+=Pmtrx[35]*(Q_010000012*PR_000020002000+Q_010000112*PR_000020002001+Q_010000212*PR_000020002002+Q_010000312*PR_000020002003+Q_110000012*PR_000020002100+Q_110000112*PR_000020002101+Q_110000212*PR_000020002102+Q_110000312*PR_000020002103); ans_temp[ans_id*36+16]+=Pmtrx[30]*(Q_002010010*PR_000020002000+Q_002010110*PR_000020002001+Q_002110010*PR_000020002010+Q_002110110*PR_000020002011+Q_102010010*PR_000020002100+Q_102010110*PR_000020002101+Q_102110010*PR_000020002110+Q_102110110*PR_000020002111+Q_202010010*PR_000020002200+Q_202010110*PR_000020002201+Q_202110010*PR_000020002210+Q_202110110*PR_000020002211); ans_temp[ans_id*36+16]+=Pmtrx[31]*(Q_001011010*PR_000020002000+Q_001011110*PR_000020002001+Q_001111010*PR_000020002010+Q_001111110*PR_000020002011+Q_001211010*PR_000020002020+Q_001211110*PR_000020002021+Q_101011010*PR_000020002100+Q_101011110*PR_000020002101+Q_101111010*PR_000020002110+Q_101111110*PR_000020002111+Q_101211010*PR_000020002120+Q_101211110*PR_000020002121); ans_temp[ans_id*36+16]+=Pmtrx[32]*(Q_000012010*PR_000020002000+Q_000012110*PR_000020002001+Q_000112010*PR_000020002010+Q_000112110*PR_000020002011+Q_000212010*PR_000020002020+Q_000212110*PR_000020002021+Q_000312010*PR_000020002030+Q_000312110*PR_000020002031); ans_temp[ans_id*36+16]+=Pmtrx[33]*(Q_001010011*PR_000020002000+Q_001010111*PR_000020002001+Q_001010211*PR_000020002002+Q_001110011*PR_000020002010+Q_001110111*PR_000020002011+Q_001110211*PR_000020002012+Q_101010011*PR_000020002100+Q_101010111*PR_000020002101+Q_101010211*PR_000020002102+Q_101110011*PR_000020002110+Q_101110111*PR_000020002111+Q_101110211*PR_000020002112); ans_temp[ans_id*36+16]+=Pmtrx[34]*(Q_000011011*PR_000020002000+Q_000011111*PR_000020002001+Q_000011211*PR_000020002002+Q_000111011*PR_000020002010+Q_000111111*PR_000020002011+Q_000111211*PR_000020002012+Q_000211011*PR_000020002020+Q_000211111*PR_000020002021+Q_000211211*PR_000020002022); ans_temp[ans_id*36+16]+=Pmtrx[35]*(Q_000010012*PR_000020002000+Q_000010112*PR_000020002001+Q_000010212*PR_000020002002+Q_000010312*PR_000020002003+Q_000110012*PR_000020002010+Q_000110112*PR_000020002011+Q_000110212*PR_000020002012+Q_000110312*PR_000020002013); ans_temp[ans_id*36+17]+=Pmtrx[30]*(Q_002000020*PR_000020002000+Q_002000120*PR_000020002001+Q_002000220*PR_000020002002+Q_102000020*PR_000020002100+Q_102000120*PR_000020002101+Q_102000220*PR_000020002102+Q_202000020*PR_000020002200+Q_202000120*PR_000020002201+Q_202000220*PR_000020002202); ans_temp[ans_id*36+17]+=Pmtrx[31]*(Q_001001020*PR_000020002000+Q_001001120*PR_000020002001+Q_001001220*PR_000020002002+Q_001101020*PR_000020002010+Q_001101120*PR_000020002011+Q_001101220*PR_000020002012+Q_101001020*PR_000020002100+Q_101001120*PR_000020002101+Q_101001220*PR_000020002102+Q_101101020*PR_000020002110+Q_101101120*PR_000020002111+Q_101101220*PR_000020002112); ans_temp[ans_id*36+17]+=Pmtrx[32]*(Q_000002020*PR_000020002000+Q_000002120*PR_000020002001+Q_000002220*PR_000020002002+Q_000102020*PR_000020002010+Q_000102120*PR_000020002011+Q_000102220*PR_000020002012+Q_000202020*PR_000020002020+Q_000202120*PR_000020002021+Q_000202220*PR_000020002022); ans_temp[ans_id*36+17]+=Pmtrx[33]*(Q_001000021*PR_000020002000+Q_001000121*PR_000020002001+Q_001000221*PR_000020002002+Q_001000321*PR_000020002003+Q_101000021*PR_000020002100+Q_101000121*PR_000020002101+Q_101000221*PR_000020002102+Q_101000321*PR_000020002103); ans_temp[ans_id*36+17]+=Pmtrx[34]*(Q_000001021*PR_000020002000+Q_000001121*PR_000020002001+Q_000001221*PR_000020002002+Q_000001321*PR_000020002003+Q_000101021*PR_000020002010+Q_000101121*PR_000020002011+Q_000101221*PR_000020002012+Q_000101321*PR_000020002013); ans_temp[ans_id*36+17]+=Pmtrx[35]*(Q_000000022*PR_000020002000+Q_000000122*PR_000020002001+Q_000000222*PR_000020002002+Q_000000322*PR_000020002003+Q_000000422*PR_000020002004); ans_temp[ans_id*36+18]+=Pmtrx[0]*(Q_022000000*PR_012000010000+Q_122000000*PR_012000010100+Q_222000000*PR_012000010200+Q_322000000*PR_012000010300+Q_422000000*PR_012000010400); ans_temp[ans_id*36+18]+=Pmtrx[1]*(Q_021001000*PR_012000010000+Q_021101000*PR_012000010010+Q_121001000*PR_012000010100+Q_121101000*PR_012000010110+Q_221001000*PR_012000010200+Q_221101000*PR_012000010210+Q_321001000*PR_012000010300+Q_321101000*PR_012000010310); ans_temp[ans_id*36+18]+=Pmtrx[2]*(Q_020002000*PR_012000010000+Q_020102000*PR_012000010010+Q_020202000*PR_012000010020+Q_120002000*PR_012000010100+Q_120102000*PR_012000010110+Q_120202000*PR_012000010120+Q_220002000*PR_012000010200+Q_220102000*PR_012000010210+Q_220202000*PR_012000010220); ans_temp[ans_id*36+18]+=Pmtrx[3]*(Q_021000001*PR_012000010000+Q_021000101*PR_012000010001+Q_121000001*PR_012000010100+Q_121000101*PR_012000010101+Q_221000001*PR_012000010200+Q_221000101*PR_012000010201+Q_321000001*PR_012000010300+Q_321000101*PR_012000010301); ans_temp[ans_id*36+18]+=Pmtrx[4]*(Q_020001001*PR_012000010000+Q_020001101*PR_012000010001+Q_020101001*PR_012000010010+Q_020101101*PR_012000010011+Q_120001001*PR_012000010100+Q_120001101*PR_012000010101+Q_120101001*PR_012000010110+Q_120101101*PR_012000010111+Q_220001001*PR_012000010200+Q_220001101*PR_012000010201+Q_220101001*PR_012000010210+Q_220101101*PR_012000010211); ans_temp[ans_id*36+18]+=Pmtrx[5]*(Q_020000002*PR_012000010000+Q_020000102*PR_012000010001+Q_020000202*PR_012000010002+Q_120000002*PR_012000010100+Q_120000102*PR_012000010101+Q_120000202*PR_012000010102+Q_220000002*PR_012000010200+Q_220000102*PR_012000010201+Q_220000202*PR_012000010202); ans_temp[ans_id*36+19]+=Pmtrx[0]*(Q_012010000*PR_012000010000+Q_012110000*PR_012000010010+Q_112010000*PR_012000010100+Q_112110000*PR_012000010110+Q_212010000*PR_012000010200+Q_212110000*PR_012000010210+Q_312010000*PR_012000010300+Q_312110000*PR_012000010310); ans_temp[ans_id*36+19]+=Pmtrx[1]*(Q_011011000*PR_012000010000+Q_011111000*PR_012000010010+Q_011211000*PR_012000010020+Q_111011000*PR_012000010100+Q_111111000*PR_012000010110+Q_111211000*PR_012000010120+Q_211011000*PR_012000010200+Q_211111000*PR_012000010210+Q_211211000*PR_012000010220); ans_temp[ans_id*36+19]+=Pmtrx[2]*(Q_010012000*PR_012000010000+Q_010112000*PR_012000010010+Q_010212000*PR_012000010020+Q_010312000*PR_012000010030+Q_110012000*PR_012000010100+Q_110112000*PR_012000010110+Q_110212000*PR_012000010120+Q_110312000*PR_012000010130); ans_temp[ans_id*36+19]+=Pmtrx[3]*(Q_011010001*PR_012000010000+Q_011010101*PR_012000010001+Q_011110001*PR_012000010010+Q_011110101*PR_012000010011+Q_111010001*PR_012000010100+Q_111010101*PR_012000010101+Q_111110001*PR_012000010110+Q_111110101*PR_012000010111+Q_211010001*PR_012000010200+Q_211010101*PR_012000010201+Q_211110001*PR_012000010210+Q_211110101*PR_012000010211); ans_temp[ans_id*36+19]+=Pmtrx[4]*(Q_010011001*PR_012000010000+Q_010011101*PR_012000010001+Q_010111001*PR_012000010010+Q_010111101*PR_012000010011+Q_010211001*PR_012000010020+Q_010211101*PR_012000010021+Q_110011001*PR_012000010100+Q_110011101*PR_012000010101+Q_110111001*PR_012000010110+Q_110111101*PR_012000010111+Q_110211001*PR_012000010120+Q_110211101*PR_012000010121); ans_temp[ans_id*36+19]+=Pmtrx[5]*(Q_010010002*PR_012000010000+Q_010010102*PR_012000010001+Q_010010202*PR_012000010002+Q_010110002*PR_012000010010+Q_010110102*PR_012000010011+Q_010110202*PR_012000010012+Q_110010002*PR_012000010100+Q_110010102*PR_012000010101+Q_110010202*PR_012000010102+Q_110110002*PR_012000010110+Q_110110102*PR_012000010111+Q_110110202*PR_012000010112); ans_temp[ans_id*36+20]+=Pmtrx[0]*(Q_002020000*PR_012000010000+Q_002120000*PR_012000010010+Q_002220000*PR_012000010020+Q_102020000*PR_012000010100+Q_102120000*PR_012000010110+Q_102220000*PR_012000010120+Q_202020000*PR_012000010200+Q_202120000*PR_012000010210+Q_202220000*PR_012000010220); ans_temp[ans_id*36+20]+=Pmtrx[1]*(Q_001021000*PR_012000010000+Q_001121000*PR_012000010010+Q_001221000*PR_012000010020+Q_001321000*PR_012000010030+Q_101021000*PR_012000010100+Q_101121000*PR_012000010110+Q_101221000*PR_012000010120+Q_101321000*PR_012000010130); ans_temp[ans_id*36+20]+=Pmtrx[2]*(Q_000022000*PR_012000010000+Q_000122000*PR_012000010010+Q_000222000*PR_012000010020+Q_000322000*PR_012000010030+Q_000422000*PR_012000010040); ans_temp[ans_id*36+20]+=Pmtrx[3]*(Q_001020001*PR_012000010000+Q_001020101*PR_012000010001+Q_001120001*PR_012000010010+Q_001120101*PR_012000010011+Q_001220001*PR_012000010020+Q_001220101*PR_012000010021+Q_101020001*PR_012000010100+Q_101020101*PR_012000010101+Q_101120001*PR_012000010110+Q_101120101*PR_012000010111+Q_101220001*PR_012000010120+Q_101220101*PR_012000010121); ans_temp[ans_id*36+20]+=Pmtrx[4]*(Q_000021001*PR_012000010000+Q_000021101*PR_012000010001+Q_000121001*PR_012000010010+Q_000121101*PR_012000010011+Q_000221001*PR_012000010020+Q_000221101*PR_012000010021+Q_000321001*PR_012000010030+Q_000321101*PR_012000010031); ans_temp[ans_id*36+20]+=Pmtrx[5]*(Q_000020002*PR_012000010000+Q_000020102*PR_012000010001+Q_000020202*PR_012000010002+Q_000120002*PR_012000010010+Q_000120102*PR_012000010011+Q_000120202*PR_012000010012+Q_000220002*PR_012000010020+Q_000220102*PR_012000010021+Q_000220202*PR_012000010022); ans_temp[ans_id*36+21]+=Pmtrx[0]*(Q_012000010*PR_012000010000+Q_012000110*PR_012000010001+Q_112000010*PR_012000010100+Q_112000110*PR_012000010101+Q_212000010*PR_012000010200+Q_212000110*PR_012000010201+Q_312000010*PR_012000010300+Q_312000110*PR_012000010301); ans_temp[ans_id*36+21]+=Pmtrx[1]*(Q_011001010*PR_012000010000+Q_011001110*PR_012000010001+Q_011101010*PR_012000010010+Q_011101110*PR_012000010011+Q_111001010*PR_012000010100+Q_111001110*PR_012000010101+Q_111101010*PR_012000010110+Q_111101110*PR_012000010111+Q_211001010*PR_012000010200+Q_211001110*PR_012000010201+Q_211101010*PR_012000010210+Q_211101110*PR_012000010211); ans_temp[ans_id*36+21]+=Pmtrx[2]*(Q_010002010*PR_012000010000+Q_010002110*PR_012000010001+Q_010102010*PR_012000010010+Q_010102110*PR_012000010011+Q_010202010*PR_012000010020+Q_010202110*PR_012000010021+Q_110002010*PR_012000010100+Q_110002110*PR_012000010101+Q_110102010*PR_012000010110+Q_110102110*PR_012000010111+Q_110202010*PR_012000010120+Q_110202110*PR_012000010121); ans_temp[ans_id*36+21]+=Pmtrx[3]*(Q_011000011*PR_012000010000+Q_011000111*PR_012000010001+Q_011000211*PR_012000010002+Q_111000011*PR_012000010100+Q_111000111*PR_012000010101+Q_111000211*PR_012000010102+Q_211000011*PR_012000010200+Q_211000111*PR_012000010201+Q_211000211*PR_012000010202); ans_temp[ans_id*36+21]+=Pmtrx[4]*(Q_010001011*PR_012000010000+Q_010001111*PR_012000010001+Q_010001211*PR_012000010002+Q_010101011*PR_012000010010+Q_010101111*PR_012000010011+Q_010101211*PR_012000010012+Q_110001011*PR_012000010100+Q_110001111*PR_012000010101+Q_110001211*PR_012000010102+Q_110101011*PR_012000010110+Q_110101111*PR_012000010111+Q_110101211*PR_012000010112); ans_temp[ans_id*36+21]+=Pmtrx[5]*(Q_010000012*PR_012000010000+Q_010000112*PR_012000010001+Q_010000212*PR_012000010002+Q_010000312*PR_012000010003+Q_110000012*PR_012000010100+Q_110000112*PR_012000010101+Q_110000212*PR_012000010102+Q_110000312*PR_012000010103); ans_temp[ans_id*36+22]+=Pmtrx[0]*(Q_002010010*PR_012000010000+Q_002010110*PR_012000010001+Q_002110010*PR_012000010010+Q_002110110*PR_012000010011+Q_102010010*PR_012000010100+Q_102010110*PR_012000010101+Q_102110010*PR_012000010110+Q_102110110*PR_012000010111+Q_202010010*PR_012000010200+Q_202010110*PR_012000010201+Q_202110010*PR_012000010210+Q_202110110*PR_012000010211); ans_temp[ans_id*36+22]+=Pmtrx[1]*(Q_001011010*PR_012000010000+Q_001011110*PR_012000010001+Q_001111010*PR_012000010010+Q_001111110*PR_012000010011+Q_001211010*PR_012000010020+Q_001211110*PR_012000010021+Q_101011010*PR_012000010100+Q_101011110*PR_012000010101+Q_101111010*PR_012000010110+Q_101111110*PR_012000010111+Q_101211010*PR_012000010120+Q_101211110*PR_012000010121); ans_temp[ans_id*36+22]+=Pmtrx[2]*(Q_000012010*PR_012000010000+Q_000012110*PR_012000010001+Q_000112010*PR_012000010010+Q_000112110*PR_012000010011+Q_000212010*PR_012000010020+Q_000212110*PR_012000010021+Q_000312010*PR_012000010030+Q_000312110*PR_012000010031); ans_temp[ans_id*36+22]+=Pmtrx[3]*(Q_001010011*PR_012000010000+Q_001010111*PR_012000010001+Q_001010211*PR_012000010002+Q_001110011*PR_012000010010+Q_001110111*PR_012000010011+Q_001110211*PR_012000010012+Q_101010011*PR_012000010100+Q_101010111*PR_012000010101+Q_101010211*PR_012000010102+Q_101110011*PR_012000010110+Q_101110111*PR_012000010111+Q_101110211*PR_012000010112); ans_temp[ans_id*36+22]+=Pmtrx[4]*(Q_000011011*PR_012000010000+Q_000011111*PR_012000010001+Q_000011211*PR_012000010002+Q_000111011*PR_012000010010+Q_000111111*PR_012000010011+Q_000111211*PR_012000010012+Q_000211011*PR_012000010020+Q_000211111*PR_012000010021+Q_000211211*PR_012000010022); ans_temp[ans_id*36+22]+=Pmtrx[5]*(Q_000010012*PR_012000010000+Q_000010112*PR_012000010001+Q_000010212*PR_012000010002+Q_000010312*PR_012000010003+Q_000110012*PR_012000010010+Q_000110112*PR_012000010011+Q_000110212*PR_012000010012+Q_000110312*PR_012000010013); ans_temp[ans_id*36+23]+=Pmtrx[0]*(Q_002000020*PR_012000010000+Q_002000120*PR_012000010001+Q_002000220*PR_012000010002+Q_102000020*PR_012000010100+Q_102000120*PR_012000010101+Q_102000220*PR_012000010102+Q_202000020*PR_012000010200+Q_202000120*PR_012000010201+Q_202000220*PR_012000010202); ans_temp[ans_id*36+23]+=Pmtrx[1]*(Q_001001020*PR_012000010000+Q_001001120*PR_012000010001+Q_001001220*PR_012000010002+Q_001101020*PR_012000010010+Q_001101120*PR_012000010011+Q_001101220*PR_012000010012+Q_101001020*PR_012000010100+Q_101001120*PR_012000010101+Q_101001220*PR_012000010102+Q_101101020*PR_012000010110+Q_101101120*PR_012000010111+Q_101101220*PR_012000010112); ans_temp[ans_id*36+23]+=Pmtrx[2]*(Q_000002020*PR_012000010000+Q_000002120*PR_012000010001+Q_000002220*PR_012000010002+Q_000102020*PR_012000010010+Q_000102120*PR_012000010011+Q_000102220*PR_012000010012+Q_000202020*PR_012000010020+Q_000202120*PR_012000010021+Q_000202220*PR_012000010022); ans_temp[ans_id*36+23]+=Pmtrx[3]*(Q_001000021*PR_012000010000+Q_001000121*PR_012000010001+Q_001000221*PR_012000010002+Q_001000321*PR_012000010003+Q_101000021*PR_012000010100+Q_101000121*PR_012000010101+Q_101000221*PR_012000010102+Q_101000321*PR_012000010103); ans_temp[ans_id*36+23]+=Pmtrx[4]*(Q_000001021*PR_012000010000+Q_000001121*PR_012000010001+Q_000001221*PR_012000010002+Q_000001321*PR_012000010003+Q_000101021*PR_012000010010+Q_000101121*PR_012000010011+Q_000101221*PR_012000010012+Q_000101321*PR_012000010013); ans_temp[ans_id*36+23]+=Pmtrx[5]*(Q_000000022*PR_012000010000+Q_000000122*PR_012000010001+Q_000000222*PR_012000010002+Q_000000322*PR_012000010003+Q_000000422*PR_012000010004); ans_temp[ans_id*36+18]+=Pmtrx[6]*(Q_022000000*PR_011001010000+Q_122000000*PR_011001010100+Q_222000000*PR_011001010200+Q_322000000*PR_011001010300+Q_422000000*PR_011001010400); ans_temp[ans_id*36+18]+=Pmtrx[7]*(Q_021001000*PR_011001010000+Q_021101000*PR_011001010010+Q_121001000*PR_011001010100+Q_121101000*PR_011001010110+Q_221001000*PR_011001010200+Q_221101000*PR_011001010210+Q_321001000*PR_011001010300+Q_321101000*PR_011001010310); ans_temp[ans_id*36+18]+=Pmtrx[8]*(Q_020002000*PR_011001010000+Q_020102000*PR_011001010010+Q_020202000*PR_011001010020+Q_120002000*PR_011001010100+Q_120102000*PR_011001010110+Q_120202000*PR_011001010120+Q_220002000*PR_011001010200+Q_220102000*PR_011001010210+Q_220202000*PR_011001010220); ans_temp[ans_id*36+18]+=Pmtrx[9]*(Q_021000001*PR_011001010000+Q_021000101*PR_011001010001+Q_121000001*PR_011001010100+Q_121000101*PR_011001010101+Q_221000001*PR_011001010200+Q_221000101*PR_011001010201+Q_321000001*PR_011001010300+Q_321000101*PR_011001010301); ans_temp[ans_id*36+18]+=Pmtrx[10]*(Q_020001001*PR_011001010000+Q_020001101*PR_011001010001+Q_020101001*PR_011001010010+Q_020101101*PR_011001010011+Q_120001001*PR_011001010100+Q_120001101*PR_011001010101+Q_120101001*PR_011001010110+Q_120101101*PR_011001010111+Q_220001001*PR_011001010200+Q_220001101*PR_011001010201+Q_220101001*PR_011001010210+Q_220101101*PR_011001010211); ans_temp[ans_id*36+18]+=Pmtrx[11]*(Q_020000002*PR_011001010000+Q_020000102*PR_011001010001+Q_020000202*PR_011001010002+Q_120000002*PR_011001010100+Q_120000102*PR_011001010101+Q_120000202*PR_011001010102+Q_220000002*PR_011001010200+Q_220000102*PR_011001010201+Q_220000202*PR_011001010202); ans_temp[ans_id*36+19]+=Pmtrx[6]*(Q_012010000*PR_011001010000+Q_012110000*PR_011001010010+Q_112010000*PR_011001010100+Q_112110000*PR_011001010110+Q_212010000*PR_011001010200+Q_212110000*PR_011001010210+Q_312010000*PR_011001010300+Q_312110000*PR_011001010310); ans_temp[ans_id*36+19]+=Pmtrx[7]*(Q_011011000*PR_011001010000+Q_011111000*PR_011001010010+Q_011211000*PR_011001010020+Q_111011000*PR_011001010100+Q_111111000*PR_011001010110+Q_111211000*PR_011001010120+Q_211011000*PR_011001010200+Q_211111000*PR_011001010210+Q_211211000*PR_011001010220); ans_temp[ans_id*36+19]+=Pmtrx[8]*(Q_010012000*PR_011001010000+Q_010112000*PR_011001010010+Q_010212000*PR_011001010020+Q_010312000*PR_011001010030+Q_110012000*PR_011001010100+Q_110112000*PR_011001010110+Q_110212000*PR_011001010120+Q_110312000*PR_011001010130); ans_temp[ans_id*36+19]+=Pmtrx[9]*(Q_011010001*PR_011001010000+Q_011010101*PR_011001010001+Q_011110001*PR_011001010010+Q_011110101*PR_011001010011+Q_111010001*PR_011001010100+Q_111010101*PR_011001010101+Q_111110001*PR_011001010110+Q_111110101*PR_011001010111+Q_211010001*PR_011001010200+Q_211010101*PR_011001010201+Q_211110001*PR_011001010210+Q_211110101*PR_011001010211); ans_temp[ans_id*36+19]+=Pmtrx[10]*(Q_010011001*PR_011001010000+Q_010011101*PR_011001010001+Q_010111001*PR_011001010010+Q_010111101*PR_011001010011+Q_010211001*PR_011001010020+Q_010211101*PR_011001010021+Q_110011001*PR_011001010100+Q_110011101*PR_011001010101+Q_110111001*PR_011001010110+Q_110111101*PR_011001010111+Q_110211001*PR_011001010120+Q_110211101*PR_011001010121); ans_temp[ans_id*36+19]+=Pmtrx[11]*(Q_010010002*PR_011001010000+Q_010010102*PR_011001010001+Q_010010202*PR_011001010002+Q_010110002*PR_011001010010+Q_010110102*PR_011001010011+Q_010110202*PR_011001010012+Q_110010002*PR_011001010100+Q_110010102*PR_011001010101+Q_110010202*PR_011001010102+Q_110110002*PR_011001010110+Q_110110102*PR_011001010111+Q_110110202*PR_011001010112); ans_temp[ans_id*36+20]+=Pmtrx[6]*(Q_002020000*PR_011001010000+Q_002120000*PR_011001010010+Q_002220000*PR_011001010020+Q_102020000*PR_011001010100+Q_102120000*PR_011001010110+Q_102220000*PR_011001010120+Q_202020000*PR_011001010200+Q_202120000*PR_011001010210+Q_202220000*PR_011001010220); ans_temp[ans_id*36+20]+=Pmtrx[7]*(Q_001021000*PR_011001010000+Q_001121000*PR_011001010010+Q_001221000*PR_011001010020+Q_001321000*PR_011001010030+Q_101021000*PR_011001010100+Q_101121000*PR_011001010110+Q_101221000*PR_011001010120+Q_101321000*PR_011001010130); ans_temp[ans_id*36+20]+=Pmtrx[8]*(Q_000022000*PR_011001010000+Q_000122000*PR_011001010010+Q_000222000*PR_011001010020+Q_000322000*PR_011001010030+Q_000422000*PR_011001010040); ans_temp[ans_id*36+20]+=Pmtrx[9]*(Q_001020001*PR_011001010000+Q_001020101*PR_011001010001+Q_001120001*PR_011001010010+Q_001120101*PR_011001010011+Q_001220001*PR_011001010020+Q_001220101*PR_011001010021+Q_101020001*PR_011001010100+Q_101020101*PR_011001010101+Q_101120001*PR_011001010110+Q_101120101*PR_011001010111+Q_101220001*PR_011001010120+Q_101220101*PR_011001010121); ans_temp[ans_id*36+20]+=Pmtrx[10]*(Q_000021001*PR_011001010000+Q_000021101*PR_011001010001+Q_000121001*PR_011001010010+Q_000121101*PR_011001010011+Q_000221001*PR_011001010020+Q_000221101*PR_011001010021+Q_000321001*PR_011001010030+Q_000321101*PR_011001010031); ans_temp[ans_id*36+20]+=Pmtrx[11]*(Q_000020002*PR_011001010000+Q_000020102*PR_011001010001+Q_000020202*PR_011001010002+Q_000120002*PR_011001010010+Q_000120102*PR_011001010011+Q_000120202*PR_011001010012+Q_000220002*PR_011001010020+Q_000220102*PR_011001010021+Q_000220202*PR_011001010022); ans_temp[ans_id*36+21]+=Pmtrx[6]*(Q_012000010*PR_011001010000+Q_012000110*PR_011001010001+Q_112000010*PR_011001010100+Q_112000110*PR_011001010101+Q_212000010*PR_011001010200+Q_212000110*PR_011001010201+Q_312000010*PR_011001010300+Q_312000110*PR_011001010301); ans_temp[ans_id*36+21]+=Pmtrx[7]*(Q_011001010*PR_011001010000+Q_011001110*PR_011001010001+Q_011101010*PR_011001010010+Q_011101110*PR_011001010011+Q_111001010*PR_011001010100+Q_111001110*PR_011001010101+Q_111101010*PR_011001010110+Q_111101110*PR_011001010111+Q_211001010*PR_011001010200+Q_211001110*PR_011001010201+Q_211101010*PR_011001010210+Q_211101110*PR_011001010211); ans_temp[ans_id*36+21]+=Pmtrx[8]*(Q_010002010*PR_011001010000+Q_010002110*PR_011001010001+Q_010102010*PR_011001010010+Q_010102110*PR_011001010011+Q_010202010*PR_011001010020+Q_010202110*PR_011001010021+Q_110002010*PR_011001010100+Q_110002110*PR_011001010101+Q_110102010*PR_011001010110+Q_110102110*PR_011001010111+Q_110202010*PR_011001010120+Q_110202110*PR_011001010121); ans_temp[ans_id*36+21]+=Pmtrx[9]*(Q_011000011*PR_011001010000+Q_011000111*PR_011001010001+Q_011000211*PR_011001010002+Q_111000011*PR_011001010100+Q_111000111*PR_011001010101+Q_111000211*PR_011001010102+Q_211000011*PR_011001010200+Q_211000111*PR_011001010201+Q_211000211*PR_011001010202); ans_temp[ans_id*36+21]+=Pmtrx[10]*(Q_010001011*PR_011001010000+Q_010001111*PR_011001010001+Q_010001211*PR_011001010002+Q_010101011*PR_011001010010+Q_010101111*PR_011001010011+Q_010101211*PR_011001010012+Q_110001011*PR_011001010100+Q_110001111*PR_011001010101+Q_110001211*PR_011001010102+Q_110101011*PR_011001010110+Q_110101111*PR_011001010111+Q_110101211*PR_011001010112); ans_temp[ans_id*36+21]+=Pmtrx[11]*(Q_010000012*PR_011001010000+Q_010000112*PR_011001010001+Q_010000212*PR_011001010002+Q_010000312*PR_011001010003+Q_110000012*PR_011001010100+Q_110000112*PR_011001010101+Q_110000212*PR_011001010102+Q_110000312*PR_011001010103); ans_temp[ans_id*36+22]+=Pmtrx[6]*(Q_002010010*PR_011001010000+Q_002010110*PR_011001010001+Q_002110010*PR_011001010010+Q_002110110*PR_011001010011+Q_102010010*PR_011001010100+Q_102010110*PR_011001010101+Q_102110010*PR_011001010110+Q_102110110*PR_011001010111+Q_202010010*PR_011001010200+Q_202010110*PR_011001010201+Q_202110010*PR_011001010210+Q_202110110*PR_011001010211); ans_temp[ans_id*36+22]+=Pmtrx[7]*(Q_001011010*PR_011001010000+Q_001011110*PR_011001010001+Q_001111010*PR_011001010010+Q_001111110*PR_011001010011+Q_001211010*PR_011001010020+Q_001211110*PR_011001010021+Q_101011010*PR_011001010100+Q_101011110*PR_011001010101+Q_101111010*PR_011001010110+Q_101111110*PR_011001010111+Q_101211010*PR_011001010120+Q_101211110*PR_011001010121); ans_temp[ans_id*36+22]+=Pmtrx[8]*(Q_000012010*PR_011001010000+Q_000012110*PR_011001010001+Q_000112010*PR_011001010010+Q_000112110*PR_011001010011+Q_000212010*PR_011001010020+Q_000212110*PR_011001010021+Q_000312010*PR_011001010030+Q_000312110*PR_011001010031); ans_temp[ans_id*36+22]+=Pmtrx[9]*(Q_001010011*PR_011001010000+Q_001010111*PR_011001010001+Q_001010211*PR_011001010002+Q_001110011*PR_011001010010+Q_001110111*PR_011001010011+Q_001110211*PR_011001010012+Q_101010011*PR_011001010100+Q_101010111*PR_011001010101+Q_101010211*PR_011001010102+Q_101110011*PR_011001010110+Q_101110111*PR_011001010111+Q_101110211*PR_011001010112); ans_temp[ans_id*36+22]+=Pmtrx[10]*(Q_000011011*PR_011001010000+Q_000011111*PR_011001010001+Q_000011211*PR_011001010002+Q_000111011*PR_011001010010+Q_000111111*PR_011001010011+Q_000111211*PR_011001010012+Q_000211011*PR_011001010020+Q_000211111*PR_011001010021+Q_000211211*PR_011001010022); ans_temp[ans_id*36+22]+=Pmtrx[11]*(Q_000010012*PR_011001010000+Q_000010112*PR_011001010001+Q_000010212*PR_011001010002+Q_000010312*PR_011001010003+Q_000110012*PR_011001010010+Q_000110112*PR_011001010011+Q_000110212*PR_011001010012+Q_000110312*PR_011001010013); ans_temp[ans_id*36+23]+=Pmtrx[6]*(Q_002000020*PR_011001010000+Q_002000120*PR_011001010001+Q_002000220*PR_011001010002+Q_102000020*PR_011001010100+Q_102000120*PR_011001010101+Q_102000220*PR_011001010102+Q_202000020*PR_011001010200+Q_202000120*PR_011001010201+Q_202000220*PR_011001010202); ans_temp[ans_id*36+23]+=Pmtrx[7]*(Q_001001020*PR_011001010000+Q_001001120*PR_011001010001+Q_001001220*PR_011001010002+Q_001101020*PR_011001010010+Q_001101120*PR_011001010011+Q_001101220*PR_011001010012+Q_101001020*PR_011001010100+Q_101001120*PR_011001010101+Q_101001220*PR_011001010102+Q_101101020*PR_011001010110+Q_101101120*PR_011001010111+Q_101101220*PR_011001010112); ans_temp[ans_id*36+23]+=Pmtrx[8]*(Q_000002020*PR_011001010000+Q_000002120*PR_011001010001+Q_000002220*PR_011001010002+Q_000102020*PR_011001010010+Q_000102120*PR_011001010011+Q_000102220*PR_011001010012+Q_000202020*PR_011001010020+Q_000202120*PR_011001010021+Q_000202220*PR_011001010022); ans_temp[ans_id*36+23]+=Pmtrx[9]*(Q_001000021*PR_011001010000+Q_001000121*PR_011001010001+Q_001000221*PR_011001010002+Q_001000321*PR_011001010003+Q_101000021*PR_011001010100+Q_101000121*PR_011001010101+Q_101000221*PR_011001010102+Q_101000321*PR_011001010103); ans_temp[ans_id*36+23]+=Pmtrx[10]*(Q_000001021*PR_011001010000+Q_000001121*PR_011001010001+Q_000001221*PR_011001010002+Q_000001321*PR_011001010003+Q_000101021*PR_011001010010+Q_000101121*PR_011001010011+Q_000101221*PR_011001010012+Q_000101321*PR_011001010013); ans_temp[ans_id*36+23]+=Pmtrx[11]*(Q_000000022*PR_011001010000+Q_000000122*PR_011001010001+Q_000000222*PR_011001010002+Q_000000322*PR_011001010003+Q_000000422*PR_011001010004); ans_temp[ans_id*36+18]+=Pmtrx[12]*(Q_022000000*PR_010002010000+Q_122000000*PR_010002010100+Q_222000000*PR_010002010200+Q_322000000*PR_010002010300+Q_422000000*PR_010002010400); ans_temp[ans_id*36+18]+=Pmtrx[13]*(Q_021001000*PR_010002010000+Q_021101000*PR_010002010010+Q_121001000*PR_010002010100+Q_121101000*PR_010002010110+Q_221001000*PR_010002010200+Q_221101000*PR_010002010210+Q_321001000*PR_010002010300+Q_321101000*PR_010002010310); ans_temp[ans_id*36+18]+=Pmtrx[14]*(Q_020002000*PR_010002010000+Q_020102000*PR_010002010010+Q_020202000*PR_010002010020+Q_120002000*PR_010002010100+Q_120102000*PR_010002010110+Q_120202000*PR_010002010120+Q_220002000*PR_010002010200+Q_220102000*PR_010002010210+Q_220202000*PR_010002010220); ans_temp[ans_id*36+18]+=Pmtrx[15]*(Q_021000001*PR_010002010000+Q_021000101*PR_010002010001+Q_121000001*PR_010002010100+Q_121000101*PR_010002010101+Q_221000001*PR_010002010200+Q_221000101*PR_010002010201+Q_321000001*PR_010002010300+Q_321000101*PR_010002010301); ans_temp[ans_id*36+18]+=Pmtrx[16]*(Q_020001001*PR_010002010000+Q_020001101*PR_010002010001+Q_020101001*PR_010002010010+Q_020101101*PR_010002010011+Q_120001001*PR_010002010100+Q_120001101*PR_010002010101+Q_120101001*PR_010002010110+Q_120101101*PR_010002010111+Q_220001001*PR_010002010200+Q_220001101*PR_010002010201+Q_220101001*PR_010002010210+Q_220101101*PR_010002010211); ans_temp[ans_id*36+18]+=Pmtrx[17]*(Q_020000002*PR_010002010000+Q_020000102*PR_010002010001+Q_020000202*PR_010002010002+Q_120000002*PR_010002010100+Q_120000102*PR_010002010101+Q_120000202*PR_010002010102+Q_220000002*PR_010002010200+Q_220000102*PR_010002010201+Q_220000202*PR_010002010202); ans_temp[ans_id*36+19]+=Pmtrx[12]*(Q_012010000*PR_010002010000+Q_012110000*PR_010002010010+Q_112010000*PR_010002010100+Q_112110000*PR_010002010110+Q_212010000*PR_010002010200+Q_212110000*PR_010002010210+Q_312010000*PR_010002010300+Q_312110000*PR_010002010310); ans_temp[ans_id*36+19]+=Pmtrx[13]*(Q_011011000*PR_010002010000+Q_011111000*PR_010002010010+Q_011211000*PR_010002010020+Q_111011000*PR_010002010100+Q_111111000*PR_010002010110+Q_111211000*PR_010002010120+Q_211011000*PR_010002010200+Q_211111000*PR_010002010210+Q_211211000*PR_010002010220); ans_temp[ans_id*36+19]+=Pmtrx[14]*(Q_010012000*PR_010002010000+Q_010112000*PR_010002010010+Q_010212000*PR_010002010020+Q_010312000*PR_010002010030+Q_110012000*PR_010002010100+Q_110112000*PR_010002010110+Q_110212000*PR_010002010120+Q_110312000*PR_010002010130); ans_temp[ans_id*36+19]+=Pmtrx[15]*(Q_011010001*PR_010002010000+Q_011010101*PR_010002010001+Q_011110001*PR_010002010010+Q_011110101*PR_010002010011+Q_111010001*PR_010002010100+Q_111010101*PR_010002010101+Q_111110001*PR_010002010110+Q_111110101*PR_010002010111+Q_211010001*PR_010002010200+Q_211010101*PR_010002010201+Q_211110001*PR_010002010210+Q_211110101*PR_010002010211); ans_temp[ans_id*36+19]+=Pmtrx[16]*(Q_010011001*PR_010002010000+Q_010011101*PR_010002010001+Q_010111001*PR_010002010010+Q_010111101*PR_010002010011+Q_010211001*PR_010002010020+Q_010211101*PR_010002010021+Q_110011001*PR_010002010100+Q_110011101*PR_010002010101+Q_110111001*PR_010002010110+Q_110111101*PR_010002010111+Q_110211001*PR_010002010120+Q_110211101*PR_010002010121); ans_temp[ans_id*36+19]+=Pmtrx[17]*(Q_010010002*PR_010002010000+Q_010010102*PR_010002010001+Q_010010202*PR_010002010002+Q_010110002*PR_010002010010+Q_010110102*PR_010002010011+Q_010110202*PR_010002010012+Q_110010002*PR_010002010100+Q_110010102*PR_010002010101+Q_110010202*PR_010002010102+Q_110110002*PR_010002010110+Q_110110102*PR_010002010111+Q_110110202*PR_010002010112); ans_temp[ans_id*36+20]+=Pmtrx[12]*(Q_002020000*PR_010002010000+Q_002120000*PR_010002010010+Q_002220000*PR_010002010020+Q_102020000*PR_010002010100+Q_102120000*PR_010002010110+Q_102220000*PR_010002010120+Q_202020000*PR_010002010200+Q_202120000*PR_010002010210+Q_202220000*PR_010002010220); ans_temp[ans_id*36+20]+=Pmtrx[13]*(Q_001021000*PR_010002010000+Q_001121000*PR_010002010010+Q_001221000*PR_010002010020+Q_001321000*PR_010002010030+Q_101021000*PR_010002010100+Q_101121000*PR_010002010110+Q_101221000*PR_010002010120+Q_101321000*PR_010002010130); ans_temp[ans_id*36+20]+=Pmtrx[14]*(Q_000022000*PR_010002010000+Q_000122000*PR_010002010010+Q_000222000*PR_010002010020+Q_000322000*PR_010002010030+Q_000422000*PR_010002010040); ans_temp[ans_id*36+20]+=Pmtrx[15]*(Q_001020001*PR_010002010000+Q_001020101*PR_010002010001+Q_001120001*PR_010002010010+Q_001120101*PR_010002010011+Q_001220001*PR_010002010020+Q_001220101*PR_010002010021+Q_101020001*PR_010002010100+Q_101020101*PR_010002010101+Q_101120001*PR_010002010110+Q_101120101*PR_010002010111+Q_101220001*PR_010002010120+Q_101220101*PR_010002010121); ans_temp[ans_id*36+20]+=Pmtrx[16]*(Q_000021001*PR_010002010000+Q_000021101*PR_010002010001+Q_000121001*PR_010002010010+Q_000121101*PR_010002010011+Q_000221001*PR_010002010020+Q_000221101*PR_010002010021+Q_000321001*PR_010002010030+Q_000321101*PR_010002010031); ans_temp[ans_id*36+20]+=Pmtrx[17]*(Q_000020002*PR_010002010000+Q_000020102*PR_010002010001+Q_000020202*PR_010002010002+Q_000120002*PR_010002010010+Q_000120102*PR_010002010011+Q_000120202*PR_010002010012+Q_000220002*PR_010002010020+Q_000220102*PR_010002010021+Q_000220202*PR_010002010022); ans_temp[ans_id*36+21]+=Pmtrx[12]*(Q_012000010*PR_010002010000+Q_012000110*PR_010002010001+Q_112000010*PR_010002010100+Q_112000110*PR_010002010101+Q_212000010*PR_010002010200+Q_212000110*PR_010002010201+Q_312000010*PR_010002010300+Q_312000110*PR_010002010301); ans_temp[ans_id*36+21]+=Pmtrx[13]*(Q_011001010*PR_010002010000+Q_011001110*PR_010002010001+Q_011101010*PR_010002010010+Q_011101110*PR_010002010011+Q_111001010*PR_010002010100+Q_111001110*PR_010002010101+Q_111101010*PR_010002010110+Q_111101110*PR_010002010111+Q_211001010*PR_010002010200+Q_211001110*PR_010002010201+Q_211101010*PR_010002010210+Q_211101110*PR_010002010211); ans_temp[ans_id*36+21]+=Pmtrx[14]*(Q_010002010*PR_010002010000+Q_010002110*PR_010002010001+Q_010102010*PR_010002010010+Q_010102110*PR_010002010011+Q_010202010*PR_010002010020+Q_010202110*PR_010002010021+Q_110002010*PR_010002010100+Q_110002110*PR_010002010101+Q_110102010*PR_010002010110+Q_110102110*PR_010002010111+Q_110202010*PR_010002010120+Q_110202110*PR_010002010121); ans_temp[ans_id*36+21]+=Pmtrx[15]*(Q_011000011*PR_010002010000+Q_011000111*PR_010002010001+Q_011000211*PR_010002010002+Q_111000011*PR_010002010100+Q_111000111*PR_010002010101+Q_111000211*PR_010002010102+Q_211000011*PR_010002010200+Q_211000111*PR_010002010201+Q_211000211*PR_010002010202); ans_temp[ans_id*36+21]+=Pmtrx[16]*(Q_010001011*PR_010002010000+Q_010001111*PR_010002010001+Q_010001211*PR_010002010002+Q_010101011*PR_010002010010+Q_010101111*PR_010002010011+Q_010101211*PR_010002010012+Q_110001011*PR_010002010100+Q_110001111*PR_010002010101+Q_110001211*PR_010002010102+Q_110101011*PR_010002010110+Q_110101111*PR_010002010111+Q_110101211*PR_010002010112); ans_temp[ans_id*36+21]+=Pmtrx[17]*(Q_010000012*PR_010002010000+Q_010000112*PR_010002010001+Q_010000212*PR_010002010002+Q_010000312*PR_010002010003+Q_110000012*PR_010002010100+Q_110000112*PR_010002010101+Q_110000212*PR_010002010102+Q_110000312*PR_010002010103); ans_temp[ans_id*36+22]+=Pmtrx[12]*(Q_002010010*PR_010002010000+Q_002010110*PR_010002010001+Q_002110010*PR_010002010010+Q_002110110*PR_010002010011+Q_102010010*PR_010002010100+Q_102010110*PR_010002010101+Q_102110010*PR_010002010110+Q_102110110*PR_010002010111+Q_202010010*PR_010002010200+Q_202010110*PR_010002010201+Q_202110010*PR_010002010210+Q_202110110*PR_010002010211); ans_temp[ans_id*36+22]+=Pmtrx[13]*(Q_001011010*PR_010002010000+Q_001011110*PR_010002010001+Q_001111010*PR_010002010010+Q_001111110*PR_010002010011+Q_001211010*PR_010002010020+Q_001211110*PR_010002010021+Q_101011010*PR_010002010100+Q_101011110*PR_010002010101+Q_101111010*PR_010002010110+Q_101111110*PR_010002010111+Q_101211010*PR_010002010120+Q_101211110*PR_010002010121); ans_temp[ans_id*36+22]+=Pmtrx[14]*(Q_000012010*PR_010002010000+Q_000012110*PR_010002010001+Q_000112010*PR_010002010010+Q_000112110*PR_010002010011+Q_000212010*PR_010002010020+Q_000212110*PR_010002010021+Q_000312010*PR_010002010030+Q_000312110*PR_010002010031); ans_temp[ans_id*36+22]+=Pmtrx[15]*(Q_001010011*PR_010002010000+Q_001010111*PR_010002010001+Q_001010211*PR_010002010002+Q_001110011*PR_010002010010+Q_001110111*PR_010002010011+Q_001110211*PR_010002010012+Q_101010011*PR_010002010100+Q_101010111*PR_010002010101+Q_101010211*PR_010002010102+Q_101110011*PR_010002010110+Q_101110111*PR_010002010111+Q_101110211*PR_010002010112); ans_temp[ans_id*36+22]+=Pmtrx[16]*(Q_000011011*PR_010002010000+Q_000011111*PR_010002010001+Q_000011211*PR_010002010002+Q_000111011*PR_010002010010+Q_000111111*PR_010002010011+Q_000111211*PR_010002010012+Q_000211011*PR_010002010020+Q_000211111*PR_010002010021+Q_000211211*PR_010002010022); ans_temp[ans_id*36+22]+=Pmtrx[17]*(Q_000010012*PR_010002010000+Q_000010112*PR_010002010001+Q_000010212*PR_010002010002+Q_000010312*PR_010002010003+Q_000110012*PR_010002010010+Q_000110112*PR_010002010011+Q_000110212*PR_010002010012+Q_000110312*PR_010002010013); ans_temp[ans_id*36+23]+=Pmtrx[12]*(Q_002000020*PR_010002010000+Q_002000120*PR_010002010001+Q_002000220*PR_010002010002+Q_102000020*PR_010002010100+Q_102000120*PR_010002010101+Q_102000220*PR_010002010102+Q_202000020*PR_010002010200+Q_202000120*PR_010002010201+Q_202000220*PR_010002010202); ans_temp[ans_id*36+23]+=Pmtrx[13]*(Q_001001020*PR_010002010000+Q_001001120*PR_010002010001+Q_001001220*PR_010002010002+Q_001101020*PR_010002010010+Q_001101120*PR_010002010011+Q_001101220*PR_010002010012+Q_101001020*PR_010002010100+Q_101001120*PR_010002010101+Q_101001220*PR_010002010102+Q_101101020*PR_010002010110+Q_101101120*PR_010002010111+Q_101101220*PR_010002010112); ans_temp[ans_id*36+23]+=Pmtrx[14]*(Q_000002020*PR_010002010000+Q_000002120*PR_010002010001+Q_000002220*PR_010002010002+Q_000102020*PR_010002010010+Q_000102120*PR_010002010011+Q_000102220*PR_010002010012+Q_000202020*PR_010002010020+Q_000202120*PR_010002010021+Q_000202220*PR_010002010022); ans_temp[ans_id*36+23]+=Pmtrx[15]*(Q_001000021*PR_010002010000+Q_001000121*PR_010002010001+Q_001000221*PR_010002010002+Q_001000321*PR_010002010003+Q_101000021*PR_010002010100+Q_101000121*PR_010002010101+Q_101000221*PR_010002010102+Q_101000321*PR_010002010103); ans_temp[ans_id*36+23]+=Pmtrx[16]*(Q_000001021*PR_010002010000+Q_000001121*PR_010002010001+Q_000001221*PR_010002010002+Q_000001321*PR_010002010003+Q_000101021*PR_010002010010+Q_000101121*PR_010002010011+Q_000101221*PR_010002010012+Q_000101321*PR_010002010013); ans_temp[ans_id*36+23]+=Pmtrx[17]*(Q_000000022*PR_010002010000+Q_000000122*PR_010002010001+Q_000000222*PR_010002010002+Q_000000322*PR_010002010003+Q_000000422*PR_010002010004); ans_temp[ans_id*36+18]+=Pmtrx[18]*(Q_022000000*PR_011000011000+Q_122000000*PR_011000011100+Q_222000000*PR_011000011200+Q_322000000*PR_011000011300+Q_422000000*PR_011000011400); ans_temp[ans_id*36+18]+=Pmtrx[19]*(Q_021001000*PR_011000011000+Q_021101000*PR_011000011010+Q_121001000*PR_011000011100+Q_121101000*PR_011000011110+Q_221001000*PR_011000011200+Q_221101000*PR_011000011210+Q_321001000*PR_011000011300+Q_321101000*PR_011000011310); ans_temp[ans_id*36+18]+=Pmtrx[20]*(Q_020002000*PR_011000011000+Q_020102000*PR_011000011010+Q_020202000*PR_011000011020+Q_120002000*PR_011000011100+Q_120102000*PR_011000011110+Q_120202000*PR_011000011120+Q_220002000*PR_011000011200+Q_220102000*PR_011000011210+Q_220202000*PR_011000011220); ans_temp[ans_id*36+18]+=Pmtrx[21]*(Q_021000001*PR_011000011000+Q_021000101*PR_011000011001+Q_121000001*PR_011000011100+Q_121000101*PR_011000011101+Q_221000001*PR_011000011200+Q_221000101*PR_011000011201+Q_321000001*PR_011000011300+Q_321000101*PR_011000011301); ans_temp[ans_id*36+18]+=Pmtrx[22]*(Q_020001001*PR_011000011000+Q_020001101*PR_011000011001+Q_020101001*PR_011000011010+Q_020101101*PR_011000011011+Q_120001001*PR_011000011100+Q_120001101*PR_011000011101+Q_120101001*PR_011000011110+Q_120101101*PR_011000011111+Q_220001001*PR_011000011200+Q_220001101*PR_011000011201+Q_220101001*PR_011000011210+Q_220101101*PR_011000011211); ans_temp[ans_id*36+18]+=Pmtrx[23]*(Q_020000002*PR_011000011000+Q_020000102*PR_011000011001+Q_020000202*PR_011000011002+Q_120000002*PR_011000011100+Q_120000102*PR_011000011101+Q_120000202*PR_011000011102+Q_220000002*PR_011000011200+Q_220000102*PR_011000011201+Q_220000202*PR_011000011202); ans_temp[ans_id*36+19]+=Pmtrx[18]*(Q_012010000*PR_011000011000+Q_012110000*PR_011000011010+Q_112010000*PR_011000011100+Q_112110000*PR_011000011110+Q_212010000*PR_011000011200+Q_212110000*PR_011000011210+Q_312010000*PR_011000011300+Q_312110000*PR_011000011310); ans_temp[ans_id*36+19]+=Pmtrx[19]*(Q_011011000*PR_011000011000+Q_011111000*PR_011000011010+Q_011211000*PR_011000011020+Q_111011000*PR_011000011100+Q_111111000*PR_011000011110+Q_111211000*PR_011000011120+Q_211011000*PR_011000011200+Q_211111000*PR_011000011210+Q_211211000*PR_011000011220); ans_temp[ans_id*36+19]+=Pmtrx[20]*(Q_010012000*PR_011000011000+Q_010112000*PR_011000011010+Q_010212000*PR_011000011020+Q_010312000*PR_011000011030+Q_110012000*PR_011000011100+Q_110112000*PR_011000011110+Q_110212000*PR_011000011120+Q_110312000*PR_011000011130); ans_temp[ans_id*36+19]+=Pmtrx[21]*(Q_011010001*PR_011000011000+Q_011010101*PR_011000011001+Q_011110001*PR_011000011010+Q_011110101*PR_011000011011+Q_111010001*PR_011000011100+Q_111010101*PR_011000011101+Q_111110001*PR_011000011110+Q_111110101*PR_011000011111+Q_211010001*PR_011000011200+Q_211010101*PR_011000011201+Q_211110001*PR_011000011210+Q_211110101*PR_011000011211); ans_temp[ans_id*36+19]+=Pmtrx[22]*(Q_010011001*PR_011000011000+Q_010011101*PR_011000011001+Q_010111001*PR_011000011010+Q_010111101*PR_011000011011+Q_010211001*PR_011000011020+Q_010211101*PR_011000011021+Q_110011001*PR_011000011100+Q_110011101*PR_011000011101+Q_110111001*PR_011000011110+Q_110111101*PR_011000011111+Q_110211001*PR_011000011120+Q_110211101*PR_011000011121); ans_temp[ans_id*36+19]+=Pmtrx[23]*(Q_010010002*PR_011000011000+Q_010010102*PR_011000011001+Q_010010202*PR_011000011002+Q_010110002*PR_011000011010+Q_010110102*PR_011000011011+Q_010110202*PR_011000011012+Q_110010002*PR_011000011100+Q_110010102*PR_011000011101+Q_110010202*PR_011000011102+Q_110110002*PR_011000011110+Q_110110102*PR_011000011111+Q_110110202*PR_011000011112); ans_temp[ans_id*36+20]+=Pmtrx[18]*(Q_002020000*PR_011000011000+Q_002120000*PR_011000011010+Q_002220000*PR_011000011020+Q_102020000*PR_011000011100+Q_102120000*PR_011000011110+Q_102220000*PR_011000011120+Q_202020000*PR_011000011200+Q_202120000*PR_011000011210+Q_202220000*PR_011000011220); ans_temp[ans_id*36+20]+=Pmtrx[19]*(Q_001021000*PR_011000011000+Q_001121000*PR_011000011010+Q_001221000*PR_011000011020+Q_001321000*PR_011000011030+Q_101021000*PR_011000011100+Q_101121000*PR_011000011110+Q_101221000*PR_011000011120+Q_101321000*PR_011000011130); ans_temp[ans_id*36+20]+=Pmtrx[20]*(Q_000022000*PR_011000011000+Q_000122000*PR_011000011010+Q_000222000*PR_011000011020+Q_000322000*PR_011000011030+Q_000422000*PR_011000011040); ans_temp[ans_id*36+20]+=Pmtrx[21]*(Q_001020001*PR_011000011000+Q_001020101*PR_011000011001+Q_001120001*PR_011000011010+Q_001120101*PR_011000011011+Q_001220001*PR_011000011020+Q_001220101*PR_011000011021+Q_101020001*PR_011000011100+Q_101020101*PR_011000011101+Q_101120001*PR_011000011110+Q_101120101*PR_011000011111+Q_101220001*PR_011000011120+Q_101220101*PR_011000011121); ans_temp[ans_id*36+20]+=Pmtrx[22]*(Q_000021001*PR_011000011000+Q_000021101*PR_011000011001+Q_000121001*PR_011000011010+Q_000121101*PR_011000011011+Q_000221001*PR_011000011020+Q_000221101*PR_011000011021+Q_000321001*PR_011000011030+Q_000321101*PR_011000011031); ans_temp[ans_id*36+20]+=Pmtrx[23]*(Q_000020002*PR_011000011000+Q_000020102*PR_011000011001+Q_000020202*PR_011000011002+Q_000120002*PR_011000011010+Q_000120102*PR_011000011011+Q_000120202*PR_011000011012+Q_000220002*PR_011000011020+Q_000220102*PR_011000011021+Q_000220202*PR_011000011022); ans_temp[ans_id*36+21]+=Pmtrx[18]*(Q_012000010*PR_011000011000+Q_012000110*PR_011000011001+Q_112000010*PR_011000011100+Q_112000110*PR_011000011101+Q_212000010*PR_011000011200+Q_212000110*PR_011000011201+Q_312000010*PR_011000011300+Q_312000110*PR_011000011301); ans_temp[ans_id*36+21]+=Pmtrx[19]*(Q_011001010*PR_011000011000+Q_011001110*PR_011000011001+Q_011101010*PR_011000011010+Q_011101110*PR_011000011011+Q_111001010*PR_011000011100+Q_111001110*PR_011000011101+Q_111101010*PR_011000011110+Q_111101110*PR_011000011111+Q_211001010*PR_011000011200+Q_211001110*PR_011000011201+Q_211101010*PR_011000011210+Q_211101110*PR_011000011211); ans_temp[ans_id*36+21]+=Pmtrx[20]*(Q_010002010*PR_011000011000+Q_010002110*PR_011000011001+Q_010102010*PR_011000011010+Q_010102110*PR_011000011011+Q_010202010*PR_011000011020+Q_010202110*PR_011000011021+Q_110002010*PR_011000011100+Q_110002110*PR_011000011101+Q_110102010*PR_011000011110+Q_110102110*PR_011000011111+Q_110202010*PR_011000011120+Q_110202110*PR_011000011121); ans_temp[ans_id*36+21]+=Pmtrx[21]*(Q_011000011*PR_011000011000+Q_011000111*PR_011000011001+Q_011000211*PR_011000011002+Q_111000011*PR_011000011100+Q_111000111*PR_011000011101+Q_111000211*PR_011000011102+Q_211000011*PR_011000011200+Q_211000111*PR_011000011201+Q_211000211*PR_011000011202); ans_temp[ans_id*36+21]+=Pmtrx[22]*(Q_010001011*PR_011000011000+Q_010001111*PR_011000011001+Q_010001211*PR_011000011002+Q_010101011*PR_011000011010+Q_010101111*PR_011000011011+Q_010101211*PR_011000011012+Q_110001011*PR_011000011100+Q_110001111*PR_011000011101+Q_110001211*PR_011000011102+Q_110101011*PR_011000011110+Q_110101111*PR_011000011111+Q_110101211*PR_011000011112); ans_temp[ans_id*36+21]+=Pmtrx[23]*(Q_010000012*PR_011000011000+Q_010000112*PR_011000011001+Q_010000212*PR_011000011002+Q_010000312*PR_011000011003+Q_110000012*PR_011000011100+Q_110000112*PR_011000011101+Q_110000212*PR_011000011102+Q_110000312*PR_011000011103); ans_temp[ans_id*36+22]+=Pmtrx[18]*(Q_002010010*PR_011000011000+Q_002010110*PR_011000011001+Q_002110010*PR_011000011010+Q_002110110*PR_011000011011+Q_102010010*PR_011000011100+Q_102010110*PR_011000011101+Q_102110010*PR_011000011110+Q_102110110*PR_011000011111+Q_202010010*PR_011000011200+Q_202010110*PR_011000011201+Q_202110010*PR_011000011210+Q_202110110*PR_011000011211); ans_temp[ans_id*36+22]+=Pmtrx[19]*(Q_001011010*PR_011000011000+Q_001011110*PR_011000011001+Q_001111010*PR_011000011010+Q_001111110*PR_011000011011+Q_001211010*PR_011000011020+Q_001211110*PR_011000011021+Q_101011010*PR_011000011100+Q_101011110*PR_011000011101+Q_101111010*PR_011000011110+Q_101111110*PR_011000011111+Q_101211010*PR_011000011120+Q_101211110*PR_011000011121); ans_temp[ans_id*36+22]+=Pmtrx[20]*(Q_000012010*PR_011000011000+Q_000012110*PR_011000011001+Q_000112010*PR_011000011010+Q_000112110*PR_011000011011+Q_000212010*PR_011000011020+Q_000212110*PR_011000011021+Q_000312010*PR_011000011030+Q_000312110*PR_011000011031); ans_temp[ans_id*36+22]+=Pmtrx[21]*(Q_001010011*PR_011000011000+Q_001010111*PR_011000011001+Q_001010211*PR_011000011002+Q_001110011*PR_011000011010+Q_001110111*PR_011000011011+Q_001110211*PR_011000011012+Q_101010011*PR_011000011100+Q_101010111*PR_011000011101+Q_101010211*PR_011000011102+Q_101110011*PR_011000011110+Q_101110111*PR_011000011111+Q_101110211*PR_011000011112); ans_temp[ans_id*36+22]+=Pmtrx[22]*(Q_000011011*PR_011000011000+Q_000011111*PR_011000011001+Q_000011211*PR_011000011002+Q_000111011*PR_011000011010+Q_000111111*PR_011000011011+Q_000111211*PR_011000011012+Q_000211011*PR_011000011020+Q_000211111*PR_011000011021+Q_000211211*PR_011000011022); ans_temp[ans_id*36+22]+=Pmtrx[23]*(Q_000010012*PR_011000011000+Q_000010112*PR_011000011001+Q_000010212*PR_011000011002+Q_000010312*PR_011000011003+Q_000110012*PR_011000011010+Q_000110112*PR_011000011011+Q_000110212*PR_011000011012+Q_000110312*PR_011000011013); ans_temp[ans_id*36+23]+=Pmtrx[18]*(Q_002000020*PR_011000011000+Q_002000120*PR_011000011001+Q_002000220*PR_011000011002+Q_102000020*PR_011000011100+Q_102000120*PR_011000011101+Q_102000220*PR_011000011102+Q_202000020*PR_011000011200+Q_202000120*PR_011000011201+Q_202000220*PR_011000011202); ans_temp[ans_id*36+23]+=Pmtrx[19]*(Q_001001020*PR_011000011000+Q_001001120*PR_011000011001+Q_001001220*PR_011000011002+Q_001101020*PR_011000011010+Q_001101120*PR_011000011011+Q_001101220*PR_011000011012+Q_101001020*PR_011000011100+Q_101001120*PR_011000011101+Q_101001220*PR_011000011102+Q_101101020*PR_011000011110+Q_101101120*PR_011000011111+Q_101101220*PR_011000011112); ans_temp[ans_id*36+23]+=Pmtrx[20]*(Q_000002020*PR_011000011000+Q_000002120*PR_011000011001+Q_000002220*PR_011000011002+Q_000102020*PR_011000011010+Q_000102120*PR_011000011011+Q_000102220*PR_011000011012+Q_000202020*PR_011000011020+Q_000202120*PR_011000011021+Q_000202220*PR_011000011022); ans_temp[ans_id*36+23]+=Pmtrx[21]*(Q_001000021*PR_011000011000+Q_001000121*PR_011000011001+Q_001000221*PR_011000011002+Q_001000321*PR_011000011003+Q_101000021*PR_011000011100+Q_101000121*PR_011000011101+Q_101000221*PR_011000011102+Q_101000321*PR_011000011103); ans_temp[ans_id*36+23]+=Pmtrx[22]*(Q_000001021*PR_011000011000+Q_000001121*PR_011000011001+Q_000001221*PR_011000011002+Q_000001321*PR_011000011003+Q_000101021*PR_011000011010+Q_000101121*PR_011000011011+Q_000101221*PR_011000011012+Q_000101321*PR_011000011013); ans_temp[ans_id*36+23]+=Pmtrx[23]*(Q_000000022*PR_011000011000+Q_000000122*PR_011000011001+Q_000000222*PR_011000011002+Q_000000322*PR_011000011003+Q_000000422*PR_011000011004); ans_temp[ans_id*36+18]+=Pmtrx[24]*(Q_022000000*PR_010001011000+Q_122000000*PR_010001011100+Q_222000000*PR_010001011200+Q_322000000*PR_010001011300+Q_422000000*PR_010001011400); ans_temp[ans_id*36+18]+=Pmtrx[25]*(Q_021001000*PR_010001011000+Q_021101000*PR_010001011010+Q_121001000*PR_010001011100+Q_121101000*PR_010001011110+Q_221001000*PR_010001011200+Q_221101000*PR_010001011210+Q_321001000*PR_010001011300+Q_321101000*PR_010001011310); ans_temp[ans_id*36+18]+=Pmtrx[26]*(Q_020002000*PR_010001011000+Q_020102000*PR_010001011010+Q_020202000*PR_010001011020+Q_120002000*PR_010001011100+Q_120102000*PR_010001011110+Q_120202000*PR_010001011120+Q_220002000*PR_010001011200+Q_220102000*PR_010001011210+Q_220202000*PR_010001011220); ans_temp[ans_id*36+18]+=Pmtrx[27]*(Q_021000001*PR_010001011000+Q_021000101*PR_010001011001+Q_121000001*PR_010001011100+Q_121000101*PR_010001011101+Q_221000001*PR_010001011200+Q_221000101*PR_010001011201+Q_321000001*PR_010001011300+Q_321000101*PR_010001011301); ans_temp[ans_id*36+18]+=Pmtrx[28]*(Q_020001001*PR_010001011000+Q_020001101*PR_010001011001+Q_020101001*PR_010001011010+Q_020101101*PR_010001011011+Q_120001001*PR_010001011100+Q_120001101*PR_010001011101+Q_120101001*PR_010001011110+Q_120101101*PR_010001011111+Q_220001001*PR_010001011200+Q_220001101*PR_010001011201+Q_220101001*PR_010001011210+Q_220101101*PR_010001011211); ans_temp[ans_id*36+18]+=Pmtrx[29]*(Q_020000002*PR_010001011000+Q_020000102*PR_010001011001+Q_020000202*PR_010001011002+Q_120000002*PR_010001011100+Q_120000102*PR_010001011101+Q_120000202*PR_010001011102+Q_220000002*PR_010001011200+Q_220000102*PR_010001011201+Q_220000202*PR_010001011202); ans_temp[ans_id*36+19]+=Pmtrx[24]*(Q_012010000*PR_010001011000+Q_012110000*PR_010001011010+Q_112010000*PR_010001011100+Q_112110000*PR_010001011110+Q_212010000*PR_010001011200+Q_212110000*PR_010001011210+Q_312010000*PR_010001011300+Q_312110000*PR_010001011310); ans_temp[ans_id*36+19]+=Pmtrx[25]*(Q_011011000*PR_010001011000+Q_011111000*PR_010001011010+Q_011211000*PR_010001011020+Q_111011000*PR_010001011100+Q_111111000*PR_010001011110+Q_111211000*PR_010001011120+Q_211011000*PR_010001011200+Q_211111000*PR_010001011210+Q_211211000*PR_010001011220); ans_temp[ans_id*36+19]+=Pmtrx[26]*(Q_010012000*PR_010001011000+Q_010112000*PR_010001011010+Q_010212000*PR_010001011020+Q_010312000*PR_010001011030+Q_110012000*PR_010001011100+Q_110112000*PR_010001011110+Q_110212000*PR_010001011120+Q_110312000*PR_010001011130); ans_temp[ans_id*36+19]+=Pmtrx[27]*(Q_011010001*PR_010001011000+Q_011010101*PR_010001011001+Q_011110001*PR_010001011010+Q_011110101*PR_010001011011+Q_111010001*PR_010001011100+Q_111010101*PR_010001011101+Q_111110001*PR_010001011110+Q_111110101*PR_010001011111+Q_211010001*PR_010001011200+Q_211010101*PR_010001011201+Q_211110001*PR_010001011210+Q_211110101*PR_010001011211); ans_temp[ans_id*36+19]+=Pmtrx[28]*(Q_010011001*PR_010001011000+Q_010011101*PR_010001011001+Q_010111001*PR_010001011010+Q_010111101*PR_010001011011+Q_010211001*PR_010001011020+Q_010211101*PR_010001011021+Q_110011001*PR_010001011100+Q_110011101*PR_010001011101+Q_110111001*PR_010001011110+Q_110111101*PR_010001011111+Q_110211001*PR_010001011120+Q_110211101*PR_010001011121); ans_temp[ans_id*36+19]+=Pmtrx[29]*(Q_010010002*PR_010001011000+Q_010010102*PR_010001011001+Q_010010202*PR_010001011002+Q_010110002*PR_010001011010+Q_010110102*PR_010001011011+Q_010110202*PR_010001011012+Q_110010002*PR_010001011100+Q_110010102*PR_010001011101+Q_110010202*PR_010001011102+Q_110110002*PR_010001011110+Q_110110102*PR_010001011111+Q_110110202*PR_010001011112); ans_temp[ans_id*36+20]+=Pmtrx[24]*(Q_002020000*PR_010001011000+Q_002120000*PR_010001011010+Q_002220000*PR_010001011020+Q_102020000*PR_010001011100+Q_102120000*PR_010001011110+Q_102220000*PR_010001011120+Q_202020000*PR_010001011200+Q_202120000*PR_010001011210+Q_202220000*PR_010001011220); ans_temp[ans_id*36+20]+=Pmtrx[25]*(Q_001021000*PR_010001011000+Q_001121000*PR_010001011010+Q_001221000*PR_010001011020+Q_001321000*PR_010001011030+Q_101021000*PR_010001011100+Q_101121000*PR_010001011110+Q_101221000*PR_010001011120+Q_101321000*PR_010001011130); ans_temp[ans_id*36+20]+=Pmtrx[26]*(Q_000022000*PR_010001011000+Q_000122000*PR_010001011010+Q_000222000*PR_010001011020+Q_000322000*PR_010001011030+Q_000422000*PR_010001011040); ans_temp[ans_id*36+20]+=Pmtrx[27]*(Q_001020001*PR_010001011000+Q_001020101*PR_010001011001+Q_001120001*PR_010001011010+Q_001120101*PR_010001011011+Q_001220001*PR_010001011020+Q_001220101*PR_010001011021+Q_101020001*PR_010001011100+Q_101020101*PR_010001011101+Q_101120001*PR_010001011110+Q_101120101*PR_010001011111+Q_101220001*PR_010001011120+Q_101220101*PR_010001011121); ans_temp[ans_id*36+20]+=Pmtrx[28]*(Q_000021001*PR_010001011000+Q_000021101*PR_010001011001+Q_000121001*PR_010001011010+Q_000121101*PR_010001011011+Q_000221001*PR_010001011020+Q_000221101*PR_010001011021+Q_000321001*PR_010001011030+Q_000321101*PR_010001011031); ans_temp[ans_id*36+20]+=Pmtrx[29]*(Q_000020002*PR_010001011000+Q_000020102*PR_010001011001+Q_000020202*PR_010001011002+Q_000120002*PR_010001011010+Q_000120102*PR_010001011011+Q_000120202*PR_010001011012+Q_000220002*PR_010001011020+Q_000220102*PR_010001011021+Q_000220202*PR_010001011022); ans_temp[ans_id*36+21]+=Pmtrx[24]*(Q_012000010*PR_010001011000+Q_012000110*PR_010001011001+Q_112000010*PR_010001011100+Q_112000110*PR_010001011101+Q_212000010*PR_010001011200+Q_212000110*PR_010001011201+Q_312000010*PR_010001011300+Q_312000110*PR_010001011301); ans_temp[ans_id*36+21]+=Pmtrx[25]*(Q_011001010*PR_010001011000+Q_011001110*PR_010001011001+Q_011101010*PR_010001011010+Q_011101110*PR_010001011011+Q_111001010*PR_010001011100+Q_111001110*PR_010001011101+Q_111101010*PR_010001011110+Q_111101110*PR_010001011111+Q_211001010*PR_010001011200+Q_211001110*PR_010001011201+Q_211101010*PR_010001011210+Q_211101110*PR_010001011211); ans_temp[ans_id*36+21]+=Pmtrx[26]*(Q_010002010*PR_010001011000+Q_010002110*PR_010001011001+Q_010102010*PR_010001011010+Q_010102110*PR_010001011011+Q_010202010*PR_010001011020+Q_010202110*PR_010001011021+Q_110002010*PR_010001011100+Q_110002110*PR_010001011101+Q_110102010*PR_010001011110+Q_110102110*PR_010001011111+Q_110202010*PR_010001011120+Q_110202110*PR_010001011121); ans_temp[ans_id*36+21]+=Pmtrx[27]*(Q_011000011*PR_010001011000+Q_011000111*PR_010001011001+Q_011000211*PR_010001011002+Q_111000011*PR_010001011100+Q_111000111*PR_010001011101+Q_111000211*PR_010001011102+Q_211000011*PR_010001011200+Q_211000111*PR_010001011201+Q_211000211*PR_010001011202); ans_temp[ans_id*36+21]+=Pmtrx[28]*(Q_010001011*PR_010001011000+Q_010001111*PR_010001011001+Q_010001211*PR_010001011002+Q_010101011*PR_010001011010+Q_010101111*PR_010001011011+Q_010101211*PR_010001011012+Q_110001011*PR_010001011100+Q_110001111*PR_010001011101+Q_110001211*PR_010001011102+Q_110101011*PR_010001011110+Q_110101111*PR_010001011111+Q_110101211*PR_010001011112); ans_temp[ans_id*36+21]+=Pmtrx[29]*(Q_010000012*PR_010001011000+Q_010000112*PR_010001011001+Q_010000212*PR_010001011002+Q_010000312*PR_010001011003+Q_110000012*PR_010001011100+Q_110000112*PR_010001011101+Q_110000212*PR_010001011102+Q_110000312*PR_010001011103); ans_temp[ans_id*36+22]+=Pmtrx[24]*(Q_002010010*PR_010001011000+Q_002010110*PR_010001011001+Q_002110010*PR_010001011010+Q_002110110*PR_010001011011+Q_102010010*PR_010001011100+Q_102010110*PR_010001011101+Q_102110010*PR_010001011110+Q_102110110*PR_010001011111+Q_202010010*PR_010001011200+Q_202010110*PR_010001011201+Q_202110010*PR_010001011210+Q_202110110*PR_010001011211); ans_temp[ans_id*36+22]+=Pmtrx[25]*(Q_001011010*PR_010001011000+Q_001011110*PR_010001011001+Q_001111010*PR_010001011010+Q_001111110*PR_010001011011+Q_001211010*PR_010001011020+Q_001211110*PR_010001011021+Q_101011010*PR_010001011100+Q_101011110*PR_010001011101+Q_101111010*PR_010001011110+Q_101111110*PR_010001011111+Q_101211010*PR_010001011120+Q_101211110*PR_010001011121); ans_temp[ans_id*36+22]+=Pmtrx[26]*(Q_000012010*PR_010001011000+Q_000012110*PR_010001011001+Q_000112010*PR_010001011010+Q_000112110*PR_010001011011+Q_000212010*PR_010001011020+Q_000212110*PR_010001011021+Q_000312010*PR_010001011030+Q_000312110*PR_010001011031); ans_temp[ans_id*36+22]+=Pmtrx[27]*(Q_001010011*PR_010001011000+Q_001010111*PR_010001011001+Q_001010211*PR_010001011002+Q_001110011*PR_010001011010+Q_001110111*PR_010001011011+Q_001110211*PR_010001011012+Q_101010011*PR_010001011100+Q_101010111*PR_010001011101+Q_101010211*PR_010001011102+Q_101110011*PR_010001011110+Q_101110111*PR_010001011111+Q_101110211*PR_010001011112); ans_temp[ans_id*36+22]+=Pmtrx[28]*(Q_000011011*PR_010001011000+Q_000011111*PR_010001011001+Q_000011211*PR_010001011002+Q_000111011*PR_010001011010+Q_000111111*PR_010001011011+Q_000111211*PR_010001011012+Q_000211011*PR_010001011020+Q_000211111*PR_010001011021+Q_000211211*PR_010001011022); ans_temp[ans_id*36+22]+=Pmtrx[29]*(Q_000010012*PR_010001011000+Q_000010112*PR_010001011001+Q_000010212*PR_010001011002+Q_000010312*PR_010001011003+Q_000110012*PR_010001011010+Q_000110112*PR_010001011011+Q_000110212*PR_010001011012+Q_000110312*PR_010001011013); ans_temp[ans_id*36+23]+=Pmtrx[24]*(Q_002000020*PR_010001011000+Q_002000120*PR_010001011001+Q_002000220*PR_010001011002+Q_102000020*PR_010001011100+Q_102000120*PR_010001011101+Q_102000220*PR_010001011102+Q_202000020*PR_010001011200+Q_202000120*PR_010001011201+Q_202000220*PR_010001011202); ans_temp[ans_id*36+23]+=Pmtrx[25]*(Q_001001020*PR_010001011000+Q_001001120*PR_010001011001+Q_001001220*PR_010001011002+Q_001101020*PR_010001011010+Q_001101120*PR_010001011011+Q_001101220*PR_010001011012+Q_101001020*PR_010001011100+Q_101001120*PR_010001011101+Q_101001220*PR_010001011102+Q_101101020*PR_010001011110+Q_101101120*PR_010001011111+Q_101101220*PR_010001011112); ans_temp[ans_id*36+23]+=Pmtrx[26]*(Q_000002020*PR_010001011000+Q_000002120*PR_010001011001+Q_000002220*PR_010001011002+Q_000102020*PR_010001011010+Q_000102120*PR_010001011011+Q_000102220*PR_010001011012+Q_000202020*PR_010001011020+Q_000202120*PR_010001011021+Q_000202220*PR_010001011022); ans_temp[ans_id*36+23]+=Pmtrx[27]*(Q_001000021*PR_010001011000+Q_001000121*PR_010001011001+Q_001000221*PR_010001011002+Q_001000321*PR_010001011003+Q_101000021*PR_010001011100+Q_101000121*PR_010001011101+Q_101000221*PR_010001011102+Q_101000321*PR_010001011103); ans_temp[ans_id*36+23]+=Pmtrx[28]*(Q_000001021*PR_010001011000+Q_000001121*PR_010001011001+Q_000001221*PR_010001011002+Q_000001321*PR_010001011003+Q_000101021*PR_010001011010+Q_000101121*PR_010001011011+Q_000101221*PR_010001011012+Q_000101321*PR_010001011013); ans_temp[ans_id*36+23]+=Pmtrx[29]*(Q_000000022*PR_010001011000+Q_000000122*PR_010001011001+Q_000000222*PR_010001011002+Q_000000322*PR_010001011003+Q_000000422*PR_010001011004); ans_temp[ans_id*36+18]+=Pmtrx[30]*(Q_022000000*PR_010000012000+Q_122000000*PR_010000012100+Q_222000000*PR_010000012200+Q_322000000*PR_010000012300+Q_422000000*PR_010000012400); ans_temp[ans_id*36+18]+=Pmtrx[31]*(Q_021001000*PR_010000012000+Q_021101000*PR_010000012010+Q_121001000*PR_010000012100+Q_121101000*PR_010000012110+Q_221001000*PR_010000012200+Q_221101000*PR_010000012210+Q_321001000*PR_010000012300+Q_321101000*PR_010000012310); ans_temp[ans_id*36+18]+=Pmtrx[32]*(Q_020002000*PR_010000012000+Q_020102000*PR_010000012010+Q_020202000*PR_010000012020+Q_120002000*PR_010000012100+Q_120102000*PR_010000012110+Q_120202000*PR_010000012120+Q_220002000*PR_010000012200+Q_220102000*PR_010000012210+Q_220202000*PR_010000012220); ans_temp[ans_id*36+18]+=Pmtrx[33]*(Q_021000001*PR_010000012000+Q_021000101*PR_010000012001+Q_121000001*PR_010000012100+Q_121000101*PR_010000012101+Q_221000001*PR_010000012200+Q_221000101*PR_010000012201+Q_321000001*PR_010000012300+Q_321000101*PR_010000012301); ans_temp[ans_id*36+18]+=Pmtrx[34]*(Q_020001001*PR_010000012000+Q_020001101*PR_010000012001+Q_020101001*PR_010000012010+Q_020101101*PR_010000012011+Q_120001001*PR_010000012100+Q_120001101*PR_010000012101+Q_120101001*PR_010000012110+Q_120101101*PR_010000012111+Q_220001001*PR_010000012200+Q_220001101*PR_010000012201+Q_220101001*PR_010000012210+Q_220101101*PR_010000012211); ans_temp[ans_id*36+18]+=Pmtrx[35]*(Q_020000002*PR_010000012000+Q_020000102*PR_010000012001+Q_020000202*PR_010000012002+Q_120000002*PR_010000012100+Q_120000102*PR_010000012101+Q_120000202*PR_010000012102+Q_220000002*PR_010000012200+Q_220000102*PR_010000012201+Q_220000202*PR_010000012202); ans_temp[ans_id*36+19]+=Pmtrx[30]*(Q_012010000*PR_010000012000+Q_012110000*PR_010000012010+Q_112010000*PR_010000012100+Q_112110000*PR_010000012110+Q_212010000*PR_010000012200+Q_212110000*PR_010000012210+Q_312010000*PR_010000012300+Q_312110000*PR_010000012310); ans_temp[ans_id*36+19]+=Pmtrx[31]*(Q_011011000*PR_010000012000+Q_011111000*PR_010000012010+Q_011211000*PR_010000012020+Q_111011000*PR_010000012100+Q_111111000*PR_010000012110+Q_111211000*PR_010000012120+Q_211011000*PR_010000012200+Q_211111000*PR_010000012210+Q_211211000*PR_010000012220); ans_temp[ans_id*36+19]+=Pmtrx[32]*(Q_010012000*PR_010000012000+Q_010112000*PR_010000012010+Q_010212000*PR_010000012020+Q_010312000*PR_010000012030+Q_110012000*PR_010000012100+Q_110112000*PR_010000012110+Q_110212000*PR_010000012120+Q_110312000*PR_010000012130); ans_temp[ans_id*36+19]+=Pmtrx[33]*(Q_011010001*PR_010000012000+Q_011010101*PR_010000012001+Q_011110001*PR_010000012010+Q_011110101*PR_010000012011+Q_111010001*PR_010000012100+Q_111010101*PR_010000012101+Q_111110001*PR_010000012110+Q_111110101*PR_010000012111+Q_211010001*PR_010000012200+Q_211010101*PR_010000012201+Q_211110001*PR_010000012210+Q_211110101*PR_010000012211); ans_temp[ans_id*36+19]+=Pmtrx[34]*(Q_010011001*PR_010000012000+Q_010011101*PR_010000012001+Q_010111001*PR_010000012010+Q_010111101*PR_010000012011+Q_010211001*PR_010000012020+Q_010211101*PR_010000012021+Q_110011001*PR_010000012100+Q_110011101*PR_010000012101+Q_110111001*PR_010000012110+Q_110111101*PR_010000012111+Q_110211001*PR_010000012120+Q_110211101*PR_010000012121); ans_temp[ans_id*36+19]+=Pmtrx[35]*(Q_010010002*PR_010000012000+Q_010010102*PR_010000012001+Q_010010202*PR_010000012002+Q_010110002*PR_010000012010+Q_010110102*PR_010000012011+Q_010110202*PR_010000012012+Q_110010002*PR_010000012100+Q_110010102*PR_010000012101+Q_110010202*PR_010000012102+Q_110110002*PR_010000012110+Q_110110102*PR_010000012111+Q_110110202*PR_010000012112); ans_temp[ans_id*36+20]+=Pmtrx[30]*(Q_002020000*PR_010000012000+Q_002120000*PR_010000012010+Q_002220000*PR_010000012020+Q_102020000*PR_010000012100+Q_102120000*PR_010000012110+Q_102220000*PR_010000012120+Q_202020000*PR_010000012200+Q_202120000*PR_010000012210+Q_202220000*PR_010000012220); ans_temp[ans_id*36+20]+=Pmtrx[31]*(Q_001021000*PR_010000012000+Q_001121000*PR_010000012010+Q_001221000*PR_010000012020+Q_001321000*PR_010000012030+Q_101021000*PR_010000012100+Q_101121000*PR_010000012110+Q_101221000*PR_010000012120+Q_101321000*PR_010000012130); ans_temp[ans_id*36+20]+=Pmtrx[32]*(Q_000022000*PR_010000012000+Q_000122000*PR_010000012010+Q_000222000*PR_010000012020+Q_000322000*PR_010000012030+Q_000422000*PR_010000012040); ans_temp[ans_id*36+20]+=Pmtrx[33]*(Q_001020001*PR_010000012000+Q_001020101*PR_010000012001+Q_001120001*PR_010000012010+Q_001120101*PR_010000012011+Q_001220001*PR_010000012020+Q_001220101*PR_010000012021+Q_101020001*PR_010000012100+Q_101020101*PR_010000012101+Q_101120001*PR_010000012110+Q_101120101*PR_010000012111+Q_101220001*PR_010000012120+Q_101220101*PR_010000012121); ans_temp[ans_id*36+20]+=Pmtrx[34]*(Q_000021001*PR_010000012000+Q_000021101*PR_010000012001+Q_000121001*PR_010000012010+Q_000121101*PR_010000012011+Q_000221001*PR_010000012020+Q_000221101*PR_010000012021+Q_000321001*PR_010000012030+Q_000321101*PR_010000012031); ans_temp[ans_id*36+20]+=Pmtrx[35]*(Q_000020002*PR_010000012000+Q_000020102*PR_010000012001+Q_000020202*PR_010000012002+Q_000120002*PR_010000012010+Q_000120102*PR_010000012011+Q_000120202*PR_010000012012+Q_000220002*PR_010000012020+Q_000220102*PR_010000012021+Q_000220202*PR_010000012022); ans_temp[ans_id*36+21]+=Pmtrx[30]*(Q_012000010*PR_010000012000+Q_012000110*PR_010000012001+Q_112000010*PR_010000012100+Q_112000110*PR_010000012101+Q_212000010*PR_010000012200+Q_212000110*PR_010000012201+Q_312000010*PR_010000012300+Q_312000110*PR_010000012301); ans_temp[ans_id*36+21]+=Pmtrx[31]*(Q_011001010*PR_010000012000+Q_011001110*PR_010000012001+Q_011101010*PR_010000012010+Q_011101110*PR_010000012011+Q_111001010*PR_010000012100+Q_111001110*PR_010000012101+Q_111101010*PR_010000012110+Q_111101110*PR_010000012111+Q_211001010*PR_010000012200+Q_211001110*PR_010000012201+Q_211101010*PR_010000012210+Q_211101110*PR_010000012211); ans_temp[ans_id*36+21]+=Pmtrx[32]*(Q_010002010*PR_010000012000+Q_010002110*PR_010000012001+Q_010102010*PR_010000012010+Q_010102110*PR_010000012011+Q_010202010*PR_010000012020+Q_010202110*PR_010000012021+Q_110002010*PR_010000012100+Q_110002110*PR_010000012101+Q_110102010*PR_010000012110+Q_110102110*PR_010000012111+Q_110202010*PR_010000012120+Q_110202110*PR_010000012121); ans_temp[ans_id*36+21]+=Pmtrx[33]*(Q_011000011*PR_010000012000+Q_011000111*PR_010000012001+Q_011000211*PR_010000012002+Q_111000011*PR_010000012100+Q_111000111*PR_010000012101+Q_111000211*PR_010000012102+Q_211000011*PR_010000012200+Q_211000111*PR_010000012201+Q_211000211*PR_010000012202); ans_temp[ans_id*36+21]+=Pmtrx[34]*(Q_010001011*PR_010000012000+Q_010001111*PR_010000012001+Q_010001211*PR_010000012002+Q_010101011*PR_010000012010+Q_010101111*PR_010000012011+Q_010101211*PR_010000012012+Q_110001011*PR_010000012100+Q_110001111*PR_010000012101+Q_110001211*PR_010000012102+Q_110101011*PR_010000012110+Q_110101111*PR_010000012111+Q_110101211*PR_010000012112); ans_temp[ans_id*36+21]+=Pmtrx[35]*(Q_010000012*PR_010000012000+Q_010000112*PR_010000012001+Q_010000212*PR_010000012002+Q_010000312*PR_010000012003+Q_110000012*PR_010000012100+Q_110000112*PR_010000012101+Q_110000212*PR_010000012102+Q_110000312*PR_010000012103); ans_temp[ans_id*36+22]+=Pmtrx[30]*(Q_002010010*PR_010000012000+Q_002010110*PR_010000012001+Q_002110010*PR_010000012010+Q_002110110*PR_010000012011+Q_102010010*PR_010000012100+Q_102010110*PR_010000012101+Q_102110010*PR_010000012110+Q_102110110*PR_010000012111+Q_202010010*PR_010000012200+Q_202010110*PR_010000012201+Q_202110010*PR_010000012210+Q_202110110*PR_010000012211); ans_temp[ans_id*36+22]+=Pmtrx[31]*(Q_001011010*PR_010000012000+Q_001011110*PR_010000012001+Q_001111010*PR_010000012010+Q_001111110*PR_010000012011+Q_001211010*PR_010000012020+Q_001211110*PR_010000012021+Q_101011010*PR_010000012100+Q_101011110*PR_010000012101+Q_101111010*PR_010000012110+Q_101111110*PR_010000012111+Q_101211010*PR_010000012120+Q_101211110*PR_010000012121); ans_temp[ans_id*36+22]+=Pmtrx[32]*(Q_000012010*PR_010000012000+Q_000012110*PR_010000012001+Q_000112010*PR_010000012010+Q_000112110*PR_010000012011+Q_000212010*PR_010000012020+Q_000212110*PR_010000012021+Q_000312010*PR_010000012030+Q_000312110*PR_010000012031); ans_temp[ans_id*36+22]+=Pmtrx[33]*(Q_001010011*PR_010000012000+Q_001010111*PR_010000012001+Q_001010211*PR_010000012002+Q_001110011*PR_010000012010+Q_001110111*PR_010000012011+Q_001110211*PR_010000012012+Q_101010011*PR_010000012100+Q_101010111*PR_010000012101+Q_101010211*PR_010000012102+Q_101110011*PR_010000012110+Q_101110111*PR_010000012111+Q_101110211*PR_010000012112); ans_temp[ans_id*36+22]+=Pmtrx[34]*(Q_000011011*PR_010000012000+Q_000011111*PR_010000012001+Q_000011211*PR_010000012002+Q_000111011*PR_010000012010+Q_000111111*PR_010000012011+Q_000111211*PR_010000012012+Q_000211011*PR_010000012020+Q_000211111*PR_010000012021+Q_000211211*PR_010000012022); ans_temp[ans_id*36+22]+=Pmtrx[35]*(Q_000010012*PR_010000012000+Q_000010112*PR_010000012001+Q_000010212*PR_010000012002+Q_000010312*PR_010000012003+Q_000110012*PR_010000012010+Q_000110112*PR_010000012011+Q_000110212*PR_010000012012+Q_000110312*PR_010000012013); ans_temp[ans_id*36+23]+=Pmtrx[30]*(Q_002000020*PR_010000012000+Q_002000120*PR_010000012001+Q_002000220*PR_010000012002+Q_102000020*PR_010000012100+Q_102000120*PR_010000012101+Q_102000220*PR_010000012102+Q_202000020*PR_010000012200+Q_202000120*PR_010000012201+Q_202000220*PR_010000012202); ans_temp[ans_id*36+23]+=Pmtrx[31]*(Q_001001020*PR_010000012000+Q_001001120*PR_010000012001+Q_001001220*PR_010000012002+Q_001101020*PR_010000012010+Q_001101120*PR_010000012011+Q_001101220*PR_010000012012+Q_101001020*PR_010000012100+Q_101001120*PR_010000012101+Q_101001220*PR_010000012102+Q_101101020*PR_010000012110+Q_101101120*PR_010000012111+Q_101101220*PR_010000012112); ans_temp[ans_id*36+23]+=Pmtrx[32]*(Q_000002020*PR_010000012000+Q_000002120*PR_010000012001+Q_000002220*PR_010000012002+Q_000102020*PR_010000012010+Q_000102120*PR_010000012011+Q_000102220*PR_010000012012+Q_000202020*PR_010000012020+Q_000202120*PR_010000012021+Q_000202220*PR_010000012022); ans_temp[ans_id*36+23]+=Pmtrx[33]*(Q_001000021*PR_010000012000+Q_001000121*PR_010000012001+Q_001000221*PR_010000012002+Q_001000321*PR_010000012003+Q_101000021*PR_010000012100+Q_101000121*PR_010000012101+Q_101000221*PR_010000012102+Q_101000321*PR_010000012103); ans_temp[ans_id*36+23]+=Pmtrx[34]*(Q_000001021*PR_010000012000+Q_000001121*PR_010000012001+Q_000001221*PR_010000012002+Q_000001321*PR_010000012003+Q_000101021*PR_010000012010+Q_000101121*PR_010000012011+Q_000101221*PR_010000012012+Q_000101321*PR_010000012013); ans_temp[ans_id*36+23]+=Pmtrx[35]*(Q_000000022*PR_010000012000+Q_000000122*PR_010000012001+Q_000000222*PR_010000012002+Q_000000322*PR_010000012003+Q_000000422*PR_010000012004); ans_temp[ans_id*36+24]+=Pmtrx[0]*(Q_022000000*PR_002010010000+Q_122000000*PR_002010010100+Q_222000000*PR_002010010200+Q_322000000*PR_002010010300+Q_422000000*PR_002010010400); ans_temp[ans_id*36+24]+=Pmtrx[1]*(Q_021001000*PR_002010010000+Q_021101000*PR_002010010010+Q_121001000*PR_002010010100+Q_121101000*PR_002010010110+Q_221001000*PR_002010010200+Q_221101000*PR_002010010210+Q_321001000*PR_002010010300+Q_321101000*PR_002010010310); ans_temp[ans_id*36+24]+=Pmtrx[2]*(Q_020002000*PR_002010010000+Q_020102000*PR_002010010010+Q_020202000*PR_002010010020+Q_120002000*PR_002010010100+Q_120102000*PR_002010010110+Q_120202000*PR_002010010120+Q_220002000*PR_002010010200+Q_220102000*PR_002010010210+Q_220202000*PR_002010010220); ans_temp[ans_id*36+24]+=Pmtrx[3]*(Q_021000001*PR_002010010000+Q_021000101*PR_002010010001+Q_121000001*PR_002010010100+Q_121000101*PR_002010010101+Q_221000001*PR_002010010200+Q_221000101*PR_002010010201+Q_321000001*PR_002010010300+Q_321000101*PR_002010010301); ans_temp[ans_id*36+24]+=Pmtrx[4]*(Q_020001001*PR_002010010000+Q_020001101*PR_002010010001+Q_020101001*PR_002010010010+Q_020101101*PR_002010010011+Q_120001001*PR_002010010100+Q_120001101*PR_002010010101+Q_120101001*PR_002010010110+Q_120101101*PR_002010010111+Q_220001001*PR_002010010200+Q_220001101*PR_002010010201+Q_220101001*PR_002010010210+Q_220101101*PR_002010010211); ans_temp[ans_id*36+24]+=Pmtrx[5]*(Q_020000002*PR_002010010000+Q_020000102*PR_002010010001+Q_020000202*PR_002010010002+Q_120000002*PR_002010010100+Q_120000102*PR_002010010101+Q_120000202*PR_002010010102+Q_220000002*PR_002010010200+Q_220000102*PR_002010010201+Q_220000202*PR_002010010202); ans_temp[ans_id*36+25]+=Pmtrx[0]*(Q_012010000*PR_002010010000+Q_012110000*PR_002010010010+Q_112010000*PR_002010010100+Q_112110000*PR_002010010110+Q_212010000*PR_002010010200+Q_212110000*PR_002010010210+Q_312010000*PR_002010010300+Q_312110000*PR_002010010310); ans_temp[ans_id*36+25]+=Pmtrx[1]*(Q_011011000*PR_002010010000+Q_011111000*PR_002010010010+Q_011211000*PR_002010010020+Q_111011000*PR_002010010100+Q_111111000*PR_002010010110+Q_111211000*PR_002010010120+Q_211011000*PR_002010010200+Q_211111000*PR_002010010210+Q_211211000*PR_002010010220); ans_temp[ans_id*36+25]+=Pmtrx[2]*(Q_010012000*PR_002010010000+Q_010112000*PR_002010010010+Q_010212000*PR_002010010020+Q_010312000*PR_002010010030+Q_110012000*PR_002010010100+Q_110112000*PR_002010010110+Q_110212000*PR_002010010120+Q_110312000*PR_002010010130); ans_temp[ans_id*36+25]+=Pmtrx[3]*(Q_011010001*PR_002010010000+Q_011010101*PR_002010010001+Q_011110001*PR_002010010010+Q_011110101*PR_002010010011+Q_111010001*PR_002010010100+Q_111010101*PR_002010010101+Q_111110001*PR_002010010110+Q_111110101*PR_002010010111+Q_211010001*PR_002010010200+Q_211010101*PR_002010010201+Q_211110001*PR_002010010210+Q_211110101*PR_002010010211); ans_temp[ans_id*36+25]+=Pmtrx[4]*(Q_010011001*PR_002010010000+Q_010011101*PR_002010010001+Q_010111001*PR_002010010010+Q_010111101*PR_002010010011+Q_010211001*PR_002010010020+Q_010211101*PR_002010010021+Q_110011001*PR_002010010100+Q_110011101*PR_002010010101+Q_110111001*PR_002010010110+Q_110111101*PR_002010010111+Q_110211001*PR_002010010120+Q_110211101*PR_002010010121); ans_temp[ans_id*36+25]+=Pmtrx[5]*(Q_010010002*PR_002010010000+Q_010010102*PR_002010010001+Q_010010202*PR_002010010002+Q_010110002*PR_002010010010+Q_010110102*PR_002010010011+Q_010110202*PR_002010010012+Q_110010002*PR_002010010100+Q_110010102*PR_002010010101+Q_110010202*PR_002010010102+Q_110110002*PR_002010010110+Q_110110102*PR_002010010111+Q_110110202*PR_002010010112); ans_temp[ans_id*36+26]+=Pmtrx[0]*(Q_002020000*PR_002010010000+Q_002120000*PR_002010010010+Q_002220000*PR_002010010020+Q_102020000*PR_002010010100+Q_102120000*PR_002010010110+Q_102220000*PR_002010010120+Q_202020000*PR_002010010200+Q_202120000*PR_002010010210+Q_202220000*PR_002010010220); ans_temp[ans_id*36+26]+=Pmtrx[1]*(Q_001021000*PR_002010010000+Q_001121000*PR_002010010010+Q_001221000*PR_002010010020+Q_001321000*PR_002010010030+Q_101021000*PR_002010010100+Q_101121000*PR_002010010110+Q_101221000*PR_002010010120+Q_101321000*PR_002010010130); ans_temp[ans_id*36+26]+=Pmtrx[2]*(Q_000022000*PR_002010010000+Q_000122000*PR_002010010010+Q_000222000*PR_002010010020+Q_000322000*PR_002010010030+Q_000422000*PR_002010010040); ans_temp[ans_id*36+26]+=Pmtrx[3]*(Q_001020001*PR_002010010000+Q_001020101*PR_002010010001+Q_001120001*PR_002010010010+Q_001120101*PR_002010010011+Q_001220001*PR_002010010020+Q_001220101*PR_002010010021+Q_101020001*PR_002010010100+Q_101020101*PR_002010010101+Q_101120001*PR_002010010110+Q_101120101*PR_002010010111+Q_101220001*PR_002010010120+Q_101220101*PR_002010010121); ans_temp[ans_id*36+26]+=Pmtrx[4]*(Q_000021001*PR_002010010000+Q_000021101*PR_002010010001+Q_000121001*PR_002010010010+Q_000121101*PR_002010010011+Q_000221001*PR_002010010020+Q_000221101*PR_002010010021+Q_000321001*PR_002010010030+Q_000321101*PR_002010010031); ans_temp[ans_id*36+26]+=Pmtrx[5]*(Q_000020002*PR_002010010000+Q_000020102*PR_002010010001+Q_000020202*PR_002010010002+Q_000120002*PR_002010010010+Q_000120102*PR_002010010011+Q_000120202*PR_002010010012+Q_000220002*PR_002010010020+Q_000220102*PR_002010010021+Q_000220202*PR_002010010022); ans_temp[ans_id*36+27]+=Pmtrx[0]*(Q_012000010*PR_002010010000+Q_012000110*PR_002010010001+Q_112000010*PR_002010010100+Q_112000110*PR_002010010101+Q_212000010*PR_002010010200+Q_212000110*PR_002010010201+Q_312000010*PR_002010010300+Q_312000110*PR_002010010301); ans_temp[ans_id*36+27]+=Pmtrx[1]*(Q_011001010*PR_002010010000+Q_011001110*PR_002010010001+Q_011101010*PR_002010010010+Q_011101110*PR_002010010011+Q_111001010*PR_002010010100+Q_111001110*PR_002010010101+Q_111101010*PR_002010010110+Q_111101110*PR_002010010111+Q_211001010*PR_002010010200+Q_211001110*PR_002010010201+Q_211101010*PR_002010010210+Q_211101110*PR_002010010211); ans_temp[ans_id*36+27]+=Pmtrx[2]*(Q_010002010*PR_002010010000+Q_010002110*PR_002010010001+Q_010102010*PR_002010010010+Q_010102110*PR_002010010011+Q_010202010*PR_002010010020+Q_010202110*PR_002010010021+Q_110002010*PR_002010010100+Q_110002110*PR_002010010101+Q_110102010*PR_002010010110+Q_110102110*PR_002010010111+Q_110202010*PR_002010010120+Q_110202110*PR_002010010121); ans_temp[ans_id*36+27]+=Pmtrx[3]*(Q_011000011*PR_002010010000+Q_011000111*PR_002010010001+Q_011000211*PR_002010010002+Q_111000011*PR_002010010100+Q_111000111*PR_002010010101+Q_111000211*PR_002010010102+Q_211000011*PR_002010010200+Q_211000111*PR_002010010201+Q_211000211*PR_002010010202); ans_temp[ans_id*36+27]+=Pmtrx[4]*(Q_010001011*PR_002010010000+Q_010001111*PR_002010010001+Q_010001211*PR_002010010002+Q_010101011*PR_002010010010+Q_010101111*PR_002010010011+Q_010101211*PR_002010010012+Q_110001011*PR_002010010100+Q_110001111*PR_002010010101+Q_110001211*PR_002010010102+Q_110101011*PR_002010010110+Q_110101111*PR_002010010111+Q_110101211*PR_002010010112); ans_temp[ans_id*36+27]+=Pmtrx[5]*(Q_010000012*PR_002010010000+Q_010000112*PR_002010010001+Q_010000212*PR_002010010002+Q_010000312*PR_002010010003+Q_110000012*PR_002010010100+Q_110000112*PR_002010010101+Q_110000212*PR_002010010102+Q_110000312*PR_002010010103); ans_temp[ans_id*36+28]+=Pmtrx[0]*(Q_002010010*PR_002010010000+Q_002010110*PR_002010010001+Q_002110010*PR_002010010010+Q_002110110*PR_002010010011+Q_102010010*PR_002010010100+Q_102010110*PR_002010010101+Q_102110010*PR_002010010110+Q_102110110*PR_002010010111+Q_202010010*PR_002010010200+Q_202010110*PR_002010010201+Q_202110010*PR_002010010210+Q_202110110*PR_002010010211); ans_temp[ans_id*36+28]+=Pmtrx[1]*(Q_001011010*PR_002010010000+Q_001011110*PR_002010010001+Q_001111010*PR_002010010010+Q_001111110*PR_002010010011+Q_001211010*PR_002010010020+Q_001211110*PR_002010010021+Q_101011010*PR_002010010100+Q_101011110*PR_002010010101+Q_101111010*PR_002010010110+Q_101111110*PR_002010010111+Q_101211010*PR_002010010120+Q_101211110*PR_002010010121); ans_temp[ans_id*36+28]+=Pmtrx[2]*(Q_000012010*PR_002010010000+Q_000012110*PR_002010010001+Q_000112010*PR_002010010010+Q_000112110*PR_002010010011+Q_000212010*PR_002010010020+Q_000212110*PR_002010010021+Q_000312010*PR_002010010030+Q_000312110*PR_002010010031); ans_temp[ans_id*36+28]+=Pmtrx[3]*(Q_001010011*PR_002010010000+Q_001010111*PR_002010010001+Q_001010211*PR_002010010002+Q_001110011*PR_002010010010+Q_001110111*PR_002010010011+Q_001110211*PR_002010010012+Q_101010011*PR_002010010100+Q_101010111*PR_002010010101+Q_101010211*PR_002010010102+Q_101110011*PR_002010010110+Q_101110111*PR_002010010111+Q_101110211*PR_002010010112); ans_temp[ans_id*36+28]+=Pmtrx[4]*(Q_000011011*PR_002010010000+Q_000011111*PR_002010010001+Q_000011211*PR_002010010002+Q_000111011*PR_002010010010+Q_000111111*PR_002010010011+Q_000111211*PR_002010010012+Q_000211011*PR_002010010020+Q_000211111*PR_002010010021+Q_000211211*PR_002010010022); ans_temp[ans_id*36+28]+=Pmtrx[5]*(Q_000010012*PR_002010010000+Q_000010112*PR_002010010001+Q_000010212*PR_002010010002+Q_000010312*PR_002010010003+Q_000110012*PR_002010010010+Q_000110112*PR_002010010011+Q_000110212*PR_002010010012+Q_000110312*PR_002010010013); ans_temp[ans_id*36+29]+=Pmtrx[0]*(Q_002000020*PR_002010010000+Q_002000120*PR_002010010001+Q_002000220*PR_002010010002+Q_102000020*PR_002010010100+Q_102000120*PR_002010010101+Q_102000220*PR_002010010102+Q_202000020*PR_002010010200+Q_202000120*PR_002010010201+Q_202000220*PR_002010010202); ans_temp[ans_id*36+29]+=Pmtrx[1]*(Q_001001020*PR_002010010000+Q_001001120*PR_002010010001+Q_001001220*PR_002010010002+Q_001101020*PR_002010010010+Q_001101120*PR_002010010011+Q_001101220*PR_002010010012+Q_101001020*PR_002010010100+Q_101001120*PR_002010010101+Q_101001220*PR_002010010102+Q_101101020*PR_002010010110+Q_101101120*PR_002010010111+Q_101101220*PR_002010010112); ans_temp[ans_id*36+29]+=Pmtrx[2]*(Q_000002020*PR_002010010000+Q_000002120*PR_002010010001+Q_000002220*PR_002010010002+Q_000102020*PR_002010010010+Q_000102120*PR_002010010011+Q_000102220*PR_002010010012+Q_000202020*PR_002010010020+Q_000202120*PR_002010010021+Q_000202220*PR_002010010022); ans_temp[ans_id*36+29]+=Pmtrx[3]*(Q_001000021*PR_002010010000+Q_001000121*PR_002010010001+Q_001000221*PR_002010010002+Q_001000321*PR_002010010003+Q_101000021*PR_002010010100+Q_101000121*PR_002010010101+Q_101000221*PR_002010010102+Q_101000321*PR_002010010103); ans_temp[ans_id*36+29]+=Pmtrx[4]*(Q_000001021*PR_002010010000+Q_000001121*PR_002010010001+Q_000001221*PR_002010010002+Q_000001321*PR_002010010003+Q_000101021*PR_002010010010+Q_000101121*PR_002010010011+Q_000101221*PR_002010010012+Q_000101321*PR_002010010013); ans_temp[ans_id*36+29]+=Pmtrx[5]*(Q_000000022*PR_002010010000+Q_000000122*PR_002010010001+Q_000000222*PR_002010010002+Q_000000322*PR_002010010003+Q_000000422*PR_002010010004); ans_temp[ans_id*36+24]+=Pmtrx[6]*(Q_022000000*PR_001011010000+Q_122000000*PR_001011010100+Q_222000000*PR_001011010200+Q_322000000*PR_001011010300+Q_422000000*PR_001011010400); ans_temp[ans_id*36+24]+=Pmtrx[7]*(Q_021001000*PR_001011010000+Q_021101000*PR_001011010010+Q_121001000*PR_001011010100+Q_121101000*PR_001011010110+Q_221001000*PR_001011010200+Q_221101000*PR_001011010210+Q_321001000*PR_001011010300+Q_321101000*PR_001011010310); ans_temp[ans_id*36+24]+=Pmtrx[8]*(Q_020002000*PR_001011010000+Q_020102000*PR_001011010010+Q_020202000*PR_001011010020+Q_120002000*PR_001011010100+Q_120102000*PR_001011010110+Q_120202000*PR_001011010120+Q_220002000*PR_001011010200+Q_220102000*PR_001011010210+Q_220202000*PR_001011010220); ans_temp[ans_id*36+24]+=Pmtrx[9]*(Q_021000001*PR_001011010000+Q_021000101*PR_001011010001+Q_121000001*PR_001011010100+Q_121000101*PR_001011010101+Q_221000001*PR_001011010200+Q_221000101*PR_001011010201+Q_321000001*PR_001011010300+Q_321000101*PR_001011010301); ans_temp[ans_id*36+24]+=Pmtrx[10]*(Q_020001001*PR_001011010000+Q_020001101*PR_001011010001+Q_020101001*PR_001011010010+Q_020101101*PR_001011010011+Q_120001001*PR_001011010100+Q_120001101*PR_001011010101+Q_120101001*PR_001011010110+Q_120101101*PR_001011010111+Q_220001001*PR_001011010200+Q_220001101*PR_001011010201+Q_220101001*PR_001011010210+Q_220101101*PR_001011010211); ans_temp[ans_id*36+24]+=Pmtrx[11]*(Q_020000002*PR_001011010000+Q_020000102*PR_001011010001+Q_020000202*PR_001011010002+Q_120000002*PR_001011010100+Q_120000102*PR_001011010101+Q_120000202*PR_001011010102+Q_220000002*PR_001011010200+Q_220000102*PR_001011010201+Q_220000202*PR_001011010202); ans_temp[ans_id*36+25]+=Pmtrx[6]*(Q_012010000*PR_001011010000+Q_012110000*PR_001011010010+Q_112010000*PR_001011010100+Q_112110000*PR_001011010110+Q_212010000*PR_001011010200+Q_212110000*PR_001011010210+Q_312010000*PR_001011010300+Q_312110000*PR_001011010310); ans_temp[ans_id*36+25]+=Pmtrx[7]*(Q_011011000*PR_001011010000+Q_011111000*PR_001011010010+Q_011211000*PR_001011010020+Q_111011000*PR_001011010100+Q_111111000*PR_001011010110+Q_111211000*PR_001011010120+Q_211011000*PR_001011010200+Q_211111000*PR_001011010210+Q_211211000*PR_001011010220); ans_temp[ans_id*36+25]+=Pmtrx[8]*(Q_010012000*PR_001011010000+Q_010112000*PR_001011010010+Q_010212000*PR_001011010020+Q_010312000*PR_001011010030+Q_110012000*PR_001011010100+Q_110112000*PR_001011010110+Q_110212000*PR_001011010120+Q_110312000*PR_001011010130); ans_temp[ans_id*36+25]+=Pmtrx[9]*(Q_011010001*PR_001011010000+Q_011010101*PR_001011010001+Q_011110001*PR_001011010010+Q_011110101*PR_001011010011+Q_111010001*PR_001011010100+Q_111010101*PR_001011010101+Q_111110001*PR_001011010110+Q_111110101*PR_001011010111+Q_211010001*PR_001011010200+Q_211010101*PR_001011010201+Q_211110001*PR_001011010210+Q_211110101*PR_001011010211); ans_temp[ans_id*36+25]+=Pmtrx[10]*(Q_010011001*PR_001011010000+Q_010011101*PR_001011010001+Q_010111001*PR_001011010010+Q_010111101*PR_001011010011+Q_010211001*PR_001011010020+Q_010211101*PR_001011010021+Q_110011001*PR_001011010100+Q_110011101*PR_001011010101+Q_110111001*PR_001011010110+Q_110111101*PR_001011010111+Q_110211001*PR_001011010120+Q_110211101*PR_001011010121); ans_temp[ans_id*36+25]+=Pmtrx[11]*(Q_010010002*PR_001011010000+Q_010010102*PR_001011010001+Q_010010202*PR_001011010002+Q_010110002*PR_001011010010+Q_010110102*PR_001011010011+Q_010110202*PR_001011010012+Q_110010002*PR_001011010100+Q_110010102*PR_001011010101+Q_110010202*PR_001011010102+Q_110110002*PR_001011010110+Q_110110102*PR_001011010111+Q_110110202*PR_001011010112); ans_temp[ans_id*36+26]+=Pmtrx[6]*(Q_002020000*PR_001011010000+Q_002120000*PR_001011010010+Q_002220000*PR_001011010020+Q_102020000*PR_001011010100+Q_102120000*PR_001011010110+Q_102220000*PR_001011010120+Q_202020000*PR_001011010200+Q_202120000*PR_001011010210+Q_202220000*PR_001011010220); ans_temp[ans_id*36+26]+=Pmtrx[7]*(Q_001021000*PR_001011010000+Q_001121000*PR_001011010010+Q_001221000*PR_001011010020+Q_001321000*PR_001011010030+Q_101021000*PR_001011010100+Q_101121000*PR_001011010110+Q_101221000*PR_001011010120+Q_101321000*PR_001011010130); ans_temp[ans_id*36+26]+=Pmtrx[8]*(Q_000022000*PR_001011010000+Q_000122000*PR_001011010010+Q_000222000*PR_001011010020+Q_000322000*PR_001011010030+Q_000422000*PR_001011010040); ans_temp[ans_id*36+26]+=Pmtrx[9]*(Q_001020001*PR_001011010000+Q_001020101*PR_001011010001+Q_001120001*PR_001011010010+Q_001120101*PR_001011010011+Q_001220001*PR_001011010020+Q_001220101*PR_001011010021+Q_101020001*PR_001011010100+Q_101020101*PR_001011010101+Q_101120001*PR_001011010110+Q_101120101*PR_001011010111+Q_101220001*PR_001011010120+Q_101220101*PR_001011010121); ans_temp[ans_id*36+26]+=Pmtrx[10]*(Q_000021001*PR_001011010000+Q_000021101*PR_001011010001+Q_000121001*PR_001011010010+Q_000121101*PR_001011010011+Q_000221001*PR_001011010020+Q_000221101*PR_001011010021+Q_000321001*PR_001011010030+Q_000321101*PR_001011010031); ans_temp[ans_id*36+26]+=Pmtrx[11]*(Q_000020002*PR_001011010000+Q_000020102*PR_001011010001+Q_000020202*PR_001011010002+Q_000120002*PR_001011010010+Q_000120102*PR_001011010011+Q_000120202*PR_001011010012+Q_000220002*PR_001011010020+Q_000220102*PR_001011010021+Q_000220202*PR_001011010022); ans_temp[ans_id*36+27]+=Pmtrx[6]*(Q_012000010*PR_001011010000+Q_012000110*PR_001011010001+Q_112000010*PR_001011010100+Q_112000110*PR_001011010101+Q_212000010*PR_001011010200+Q_212000110*PR_001011010201+Q_312000010*PR_001011010300+Q_312000110*PR_001011010301); ans_temp[ans_id*36+27]+=Pmtrx[7]*(Q_011001010*PR_001011010000+Q_011001110*PR_001011010001+Q_011101010*PR_001011010010+Q_011101110*PR_001011010011+Q_111001010*PR_001011010100+Q_111001110*PR_001011010101+Q_111101010*PR_001011010110+Q_111101110*PR_001011010111+Q_211001010*PR_001011010200+Q_211001110*PR_001011010201+Q_211101010*PR_001011010210+Q_211101110*PR_001011010211); ans_temp[ans_id*36+27]+=Pmtrx[8]*(Q_010002010*PR_001011010000+Q_010002110*PR_001011010001+Q_010102010*PR_001011010010+Q_010102110*PR_001011010011+Q_010202010*PR_001011010020+Q_010202110*PR_001011010021+Q_110002010*PR_001011010100+Q_110002110*PR_001011010101+Q_110102010*PR_001011010110+Q_110102110*PR_001011010111+Q_110202010*PR_001011010120+Q_110202110*PR_001011010121); ans_temp[ans_id*36+27]+=Pmtrx[9]*(Q_011000011*PR_001011010000+Q_011000111*PR_001011010001+Q_011000211*PR_001011010002+Q_111000011*PR_001011010100+Q_111000111*PR_001011010101+Q_111000211*PR_001011010102+Q_211000011*PR_001011010200+Q_211000111*PR_001011010201+Q_211000211*PR_001011010202); ans_temp[ans_id*36+27]+=Pmtrx[10]*(Q_010001011*PR_001011010000+Q_010001111*PR_001011010001+Q_010001211*PR_001011010002+Q_010101011*PR_001011010010+Q_010101111*PR_001011010011+Q_010101211*PR_001011010012+Q_110001011*PR_001011010100+Q_110001111*PR_001011010101+Q_110001211*PR_001011010102+Q_110101011*PR_001011010110+Q_110101111*PR_001011010111+Q_110101211*PR_001011010112); ans_temp[ans_id*36+27]+=Pmtrx[11]*(Q_010000012*PR_001011010000+Q_010000112*PR_001011010001+Q_010000212*PR_001011010002+Q_010000312*PR_001011010003+Q_110000012*PR_001011010100+Q_110000112*PR_001011010101+Q_110000212*PR_001011010102+Q_110000312*PR_001011010103); ans_temp[ans_id*36+28]+=Pmtrx[6]*(Q_002010010*PR_001011010000+Q_002010110*PR_001011010001+Q_002110010*PR_001011010010+Q_002110110*PR_001011010011+Q_102010010*PR_001011010100+Q_102010110*PR_001011010101+Q_102110010*PR_001011010110+Q_102110110*PR_001011010111+Q_202010010*PR_001011010200+Q_202010110*PR_001011010201+Q_202110010*PR_001011010210+Q_202110110*PR_001011010211); ans_temp[ans_id*36+28]+=Pmtrx[7]*(Q_001011010*PR_001011010000+Q_001011110*PR_001011010001+Q_001111010*PR_001011010010+Q_001111110*PR_001011010011+Q_001211010*PR_001011010020+Q_001211110*PR_001011010021+Q_101011010*PR_001011010100+Q_101011110*PR_001011010101+Q_101111010*PR_001011010110+Q_101111110*PR_001011010111+Q_101211010*PR_001011010120+Q_101211110*PR_001011010121); ans_temp[ans_id*36+28]+=Pmtrx[8]*(Q_000012010*PR_001011010000+Q_000012110*PR_001011010001+Q_000112010*PR_001011010010+Q_000112110*PR_001011010011+Q_000212010*PR_001011010020+Q_000212110*PR_001011010021+Q_000312010*PR_001011010030+Q_000312110*PR_001011010031); ans_temp[ans_id*36+28]+=Pmtrx[9]*(Q_001010011*PR_001011010000+Q_001010111*PR_001011010001+Q_001010211*PR_001011010002+Q_001110011*PR_001011010010+Q_001110111*PR_001011010011+Q_001110211*PR_001011010012+Q_101010011*PR_001011010100+Q_101010111*PR_001011010101+Q_101010211*PR_001011010102+Q_101110011*PR_001011010110+Q_101110111*PR_001011010111+Q_101110211*PR_001011010112); ans_temp[ans_id*36+28]+=Pmtrx[10]*(Q_000011011*PR_001011010000+Q_000011111*PR_001011010001+Q_000011211*PR_001011010002+Q_000111011*PR_001011010010+Q_000111111*PR_001011010011+Q_000111211*PR_001011010012+Q_000211011*PR_001011010020+Q_000211111*PR_001011010021+Q_000211211*PR_001011010022); ans_temp[ans_id*36+28]+=Pmtrx[11]*(Q_000010012*PR_001011010000+Q_000010112*PR_001011010001+Q_000010212*PR_001011010002+Q_000010312*PR_001011010003+Q_000110012*PR_001011010010+Q_000110112*PR_001011010011+Q_000110212*PR_001011010012+Q_000110312*PR_001011010013); ans_temp[ans_id*36+29]+=Pmtrx[6]*(Q_002000020*PR_001011010000+Q_002000120*PR_001011010001+Q_002000220*PR_001011010002+Q_102000020*PR_001011010100+Q_102000120*PR_001011010101+Q_102000220*PR_001011010102+Q_202000020*PR_001011010200+Q_202000120*PR_001011010201+Q_202000220*PR_001011010202); ans_temp[ans_id*36+29]+=Pmtrx[7]*(Q_001001020*PR_001011010000+Q_001001120*PR_001011010001+Q_001001220*PR_001011010002+Q_001101020*PR_001011010010+Q_001101120*PR_001011010011+Q_001101220*PR_001011010012+Q_101001020*PR_001011010100+Q_101001120*PR_001011010101+Q_101001220*PR_001011010102+Q_101101020*PR_001011010110+Q_101101120*PR_001011010111+Q_101101220*PR_001011010112); ans_temp[ans_id*36+29]+=Pmtrx[8]*(Q_000002020*PR_001011010000+Q_000002120*PR_001011010001+Q_000002220*PR_001011010002+Q_000102020*PR_001011010010+Q_000102120*PR_001011010011+Q_000102220*PR_001011010012+Q_000202020*PR_001011010020+Q_000202120*PR_001011010021+Q_000202220*PR_001011010022); ans_temp[ans_id*36+29]+=Pmtrx[9]*(Q_001000021*PR_001011010000+Q_001000121*PR_001011010001+Q_001000221*PR_001011010002+Q_001000321*PR_001011010003+Q_101000021*PR_001011010100+Q_101000121*PR_001011010101+Q_101000221*PR_001011010102+Q_101000321*PR_001011010103); ans_temp[ans_id*36+29]+=Pmtrx[10]*(Q_000001021*PR_001011010000+Q_000001121*PR_001011010001+Q_000001221*PR_001011010002+Q_000001321*PR_001011010003+Q_000101021*PR_001011010010+Q_000101121*PR_001011010011+Q_000101221*PR_001011010012+Q_000101321*PR_001011010013); ans_temp[ans_id*36+29]+=Pmtrx[11]*(Q_000000022*PR_001011010000+Q_000000122*PR_001011010001+Q_000000222*PR_001011010002+Q_000000322*PR_001011010003+Q_000000422*PR_001011010004); ans_temp[ans_id*36+24]+=Pmtrx[12]*(Q_022000000*PR_000012010000+Q_122000000*PR_000012010100+Q_222000000*PR_000012010200+Q_322000000*PR_000012010300+Q_422000000*PR_000012010400); ans_temp[ans_id*36+24]+=Pmtrx[13]*(Q_021001000*PR_000012010000+Q_021101000*PR_000012010010+Q_121001000*PR_000012010100+Q_121101000*PR_000012010110+Q_221001000*PR_000012010200+Q_221101000*PR_000012010210+Q_321001000*PR_000012010300+Q_321101000*PR_000012010310); ans_temp[ans_id*36+24]+=Pmtrx[14]*(Q_020002000*PR_000012010000+Q_020102000*PR_000012010010+Q_020202000*PR_000012010020+Q_120002000*PR_000012010100+Q_120102000*PR_000012010110+Q_120202000*PR_000012010120+Q_220002000*PR_000012010200+Q_220102000*PR_000012010210+Q_220202000*PR_000012010220); ans_temp[ans_id*36+24]+=Pmtrx[15]*(Q_021000001*PR_000012010000+Q_021000101*PR_000012010001+Q_121000001*PR_000012010100+Q_121000101*PR_000012010101+Q_221000001*PR_000012010200+Q_221000101*PR_000012010201+Q_321000001*PR_000012010300+Q_321000101*PR_000012010301); ans_temp[ans_id*36+24]+=Pmtrx[16]*(Q_020001001*PR_000012010000+Q_020001101*PR_000012010001+Q_020101001*PR_000012010010+Q_020101101*PR_000012010011+Q_120001001*PR_000012010100+Q_120001101*PR_000012010101+Q_120101001*PR_000012010110+Q_120101101*PR_000012010111+Q_220001001*PR_000012010200+Q_220001101*PR_000012010201+Q_220101001*PR_000012010210+Q_220101101*PR_000012010211); ans_temp[ans_id*36+24]+=Pmtrx[17]*(Q_020000002*PR_000012010000+Q_020000102*PR_000012010001+Q_020000202*PR_000012010002+Q_120000002*PR_000012010100+Q_120000102*PR_000012010101+Q_120000202*PR_000012010102+Q_220000002*PR_000012010200+Q_220000102*PR_000012010201+Q_220000202*PR_000012010202); ans_temp[ans_id*36+25]+=Pmtrx[12]*(Q_012010000*PR_000012010000+Q_012110000*PR_000012010010+Q_112010000*PR_000012010100+Q_112110000*PR_000012010110+Q_212010000*PR_000012010200+Q_212110000*PR_000012010210+Q_312010000*PR_000012010300+Q_312110000*PR_000012010310); ans_temp[ans_id*36+25]+=Pmtrx[13]*(Q_011011000*PR_000012010000+Q_011111000*PR_000012010010+Q_011211000*PR_000012010020+Q_111011000*PR_000012010100+Q_111111000*PR_000012010110+Q_111211000*PR_000012010120+Q_211011000*PR_000012010200+Q_211111000*PR_000012010210+Q_211211000*PR_000012010220); ans_temp[ans_id*36+25]+=Pmtrx[14]*(Q_010012000*PR_000012010000+Q_010112000*PR_000012010010+Q_010212000*PR_000012010020+Q_010312000*PR_000012010030+Q_110012000*PR_000012010100+Q_110112000*PR_000012010110+Q_110212000*PR_000012010120+Q_110312000*PR_000012010130); ans_temp[ans_id*36+25]+=Pmtrx[15]*(Q_011010001*PR_000012010000+Q_011010101*PR_000012010001+Q_011110001*PR_000012010010+Q_011110101*PR_000012010011+Q_111010001*PR_000012010100+Q_111010101*PR_000012010101+Q_111110001*PR_000012010110+Q_111110101*PR_000012010111+Q_211010001*PR_000012010200+Q_211010101*PR_000012010201+Q_211110001*PR_000012010210+Q_211110101*PR_000012010211); ans_temp[ans_id*36+25]+=Pmtrx[16]*(Q_010011001*PR_000012010000+Q_010011101*PR_000012010001+Q_010111001*PR_000012010010+Q_010111101*PR_000012010011+Q_010211001*PR_000012010020+Q_010211101*PR_000012010021+Q_110011001*PR_000012010100+Q_110011101*PR_000012010101+Q_110111001*PR_000012010110+Q_110111101*PR_000012010111+Q_110211001*PR_000012010120+Q_110211101*PR_000012010121); ans_temp[ans_id*36+25]+=Pmtrx[17]*(Q_010010002*PR_000012010000+Q_010010102*PR_000012010001+Q_010010202*PR_000012010002+Q_010110002*PR_000012010010+Q_010110102*PR_000012010011+Q_010110202*PR_000012010012+Q_110010002*PR_000012010100+Q_110010102*PR_000012010101+Q_110010202*PR_000012010102+Q_110110002*PR_000012010110+Q_110110102*PR_000012010111+Q_110110202*PR_000012010112); ans_temp[ans_id*36+26]+=Pmtrx[12]*(Q_002020000*PR_000012010000+Q_002120000*PR_000012010010+Q_002220000*PR_000012010020+Q_102020000*PR_000012010100+Q_102120000*PR_000012010110+Q_102220000*PR_000012010120+Q_202020000*PR_000012010200+Q_202120000*PR_000012010210+Q_202220000*PR_000012010220); ans_temp[ans_id*36+26]+=Pmtrx[13]*(Q_001021000*PR_000012010000+Q_001121000*PR_000012010010+Q_001221000*PR_000012010020+Q_001321000*PR_000012010030+Q_101021000*PR_000012010100+Q_101121000*PR_000012010110+Q_101221000*PR_000012010120+Q_101321000*PR_000012010130); ans_temp[ans_id*36+26]+=Pmtrx[14]*(Q_000022000*PR_000012010000+Q_000122000*PR_000012010010+Q_000222000*PR_000012010020+Q_000322000*PR_000012010030+Q_000422000*PR_000012010040); ans_temp[ans_id*36+26]+=Pmtrx[15]*(Q_001020001*PR_000012010000+Q_001020101*PR_000012010001+Q_001120001*PR_000012010010+Q_001120101*PR_000012010011+Q_001220001*PR_000012010020+Q_001220101*PR_000012010021+Q_101020001*PR_000012010100+Q_101020101*PR_000012010101+Q_101120001*PR_000012010110+Q_101120101*PR_000012010111+Q_101220001*PR_000012010120+Q_101220101*PR_000012010121); ans_temp[ans_id*36+26]+=Pmtrx[16]*(Q_000021001*PR_000012010000+Q_000021101*PR_000012010001+Q_000121001*PR_000012010010+Q_000121101*PR_000012010011+Q_000221001*PR_000012010020+Q_000221101*PR_000012010021+Q_000321001*PR_000012010030+Q_000321101*PR_000012010031); ans_temp[ans_id*36+26]+=Pmtrx[17]*(Q_000020002*PR_000012010000+Q_000020102*PR_000012010001+Q_000020202*PR_000012010002+Q_000120002*PR_000012010010+Q_000120102*PR_000012010011+Q_000120202*PR_000012010012+Q_000220002*PR_000012010020+Q_000220102*PR_000012010021+Q_000220202*PR_000012010022); ans_temp[ans_id*36+27]+=Pmtrx[12]*(Q_012000010*PR_000012010000+Q_012000110*PR_000012010001+Q_112000010*PR_000012010100+Q_112000110*PR_000012010101+Q_212000010*PR_000012010200+Q_212000110*PR_000012010201+Q_312000010*PR_000012010300+Q_312000110*PR_000012010301); ans_temp[ans_id*36+27]+=Pmtrx[13]*(Q_011001010*PR_000012010000+Q_011001110*PR_000012010001+Q_011101010*PR_000012010010+Q_011101110*PR_000012010011+Q_111001010*PR_000012010100+Q_111001110*PR_000012010101+Q_111101010*PR_000012010110+Q_111101110*PR_000012010111+Q_211001010*PR_000012010200+Q_211001110*PR_000012010201+Q_211101010*PR_000012010210+Q_211101110*PR_000012010211); ans_temp[ans_id*36+27]+=Pmtrx[14]*(Q_010002010*PR_000012010000+Q_010002110*PR_000012010001+Q_010102010*PR_000012010010+Q_010102110*PR_000012010011+Q_010202010*PR_000012010020+Q_010202110*PR_000012010021+Q_110002010*PR_000012010100+Q_110002110*PR_000012010101+Q_110102010*PR_000012010110+Q_110102110*PR_000012010111+Q_110202010*PR_000012010120+Q_110202110*PR_000012010121); ans_temp[ans_id*36+27]+=Pmtrx[15]*(Q_011000011*PR_000012010000+Q_011000111*PR_000012010001+Q_011000211*PR_000012010002+Q_111000011*PR_000012010100+Q_111000111*PR_000012010101+Q_111000211*PR_000012010102+Q_211000011*PR_000012010200+Q_211000111*PR_000012010201+Q_211000211*PR_000012010202); ans_temp[ans_id*36+27]+=Pmtrx[16]*(Q_010001011*PR_000012010000+Q_010001111*PR_000012010001+Q_010001211*PR_000012010002+Q_010101011*PR_000012010010+Q_010101111*PR_000012010011+Q_010101211*PR_000012010012+Q_110001011*PR_000012010100+Q_110001111*PR_000012010101+Q_110001211*PR_000012010102+Q_110101011*PR_000012010110+Q_110101111*PR_000012010111+Q_110101211*PR_000012010112); ans_temp[ans_id*36+27]+=Pmtrx[17]*(Q_010000012*PR_000012010000+Q_010000112*PR_000012010001+Q_010000212*PR_000012010002+Q_010000312*PR_000012010003+Q_110000012*PR_000012010100+Q_110000112*PR_000012010101+Q_110000212*PR_000012010102+Q_110000312*PR_000012010103); ans_temp[ans_id*36+28]+=Pmtrx[12]*(Q_002010010*PR_000012010000+Q_002010110*PR_000012010001+Q_002110010*PR_000012010010+Q_002110110*PR_000012010011+Q_102010010*PR_000012010100+Q_102010110*PR_000012010101+Q_102110010*PR_000012010110+Q_102110110*PR_000012010111+Q_202010010*PR_000012010200+Q_202010110*PR_000012010201+Q_202110010*PR_000012010210+Q_202110110*PR_000012010211); ans_temp[ans_id*36+28]+=Pmtrx[13]*(Q_001011010*PR_000012010000+Q_001011110*PR_000012010001+Q_001111010*PR_000012010010+Q_001111110*PR_000012010011+Q_001211010*PR_000012010020+Q_001211110*PR_000012010021+Q_101011010*PR_000012010100+Q_101011110*PR_000012010101+Q_101111010*PR_000012010110+Q_101111110*PR_000012010111+Q_101211010*PR_000012010120+Q_101211110*PR_000012010121); ans_temp[ans_id*36+28]+=Pmtrx[14]*(Q_000012010*PR_000012010000+Q_000012110*PR_000012010001+Q_000112010*PR_000012010010+Q_000112110*PR_000012010011+Q_000212010*PR_000012010020+Q_000212110*PR_000012010021+Q_000312010*PR_000012010030+Q_000312110*PR_000012010031); ans_temp[ans_id*36+28]+=Pmtrx[15]*(Q_001010011*PR_000012010000+Q_001010111*PR_000012010001+Q_001010211*PR_000012010002+Q_001110011*PR_000012010010+Q_001110111*PR_000012010011+Q_001110211*PR_000012010012+Q_101010011*PR_000012010100+Q_101010111*PR_000012010101+Q_101010211*PR_000012010102+Q_101110011*PR_000012010110+Q_101110111*PR_000012010111+Q_101110211*PR_000012010112); ans_temp[ans_id*36+28]+=Pmtrx[16]*(Q_000011011*PR_000012010000+Q_000011111*PR_000012010001+Q_000011211*PR_000012010002+Q_000111011*PR_000012010010+Q_000111111*PR_000012010011+Q_000111211*PR_000012010012+Q_000211011*PR_000012010020+Q_000211111*PR_000012010021+Q_000211211*PR_000012010022); ans_temp[ans_id*36+28]+=Pmtrx[17]*(Q_000010012*PR_000012010000+Q_000010112*PR_000012010001+Q_000010212*PR_000012010002+Q_000010312*PR_000012010003+Q_000110012*PR_000012010010+Q_000110112*PR_000012010011+Q_000110212*PR_000012010012+Q_000110312*PR_000012010013); ans_temp[ans_id*36+29]+=Pmtrx[12]*(Q_002000020*PR_000012010000+Q_002000120*PR_000012010001+Q_002000220*PR_000012010002+Q_102000020*PR_000012010100+Q_102000120*PR_000012010101+Q_102000220*PR_000012010102+Q_202000020*PR_000012010200+Q_202000120*PR_000012010201+Q_202000220*PR_000012010202); ans_temp[ans_id*36+29]+=Pmtrx[13]*(Q_001001020*PR_000012010000+Q_001001120*PR_000012010001+Q_001001220*PR_000012010002+Q_001101020*PR_000012010010+Q_001101120*PR_000012010011+Q_001101220*PR_000012010012+Q_101001020*PR_000012010100+Q_101001120*PR_000012010101+Q_101001220*PR_000012010102+Q_101101020*PR_000012010110+Q_101101120*PR_000012010111+Q_101101220*PR_000012010112); ans_temp[ans_id*36+29]+=Pmtrx[14]*(Q_000002020*PR_000012010000+Q_000002120*PR_000012010001+Q_000002220*PR_000012010002+Q_000102020*PR_000012010010+Q_000102120*PR_000012010011+Q_000102220*PR_000012010012+Q_000202020*PR_000012010020+Q_000202120*PR_000012010021+Q_000202220*PR_000012010022); ans_temp[ans_id*36+29]+=Pmtrx[15]*(Q_001000021*PR_000012010000+Q_001000121*PR_000012010001+Q_001000221*PR_000012010002+Q_001000321*PR_000012010003+Q_101000021*PR_000012010100+Q_101000121*PR_000012010101+Q_101000221*PR_000012010102+Q_101000321*PR_000012010103); ans_temp[ans_id*36+29]+=Pmtrx[16]*(Q_000001021*PR_000012010000+Q_000001121*PR_000012010001+Q_000001221*PR_000012010002+Q_000001321*PR_000012010003+Q_000101021*PR_000012010010+Q_000101121*PR_000012010011+Q_000101221*PR_000012010012+Q_000101321*PR_000012010013); ans_temp[ans_id*36+29]+=Pmtrx[17]*(Q_000000022*PR_000012010000+Q_000000122*PR_000012010001+Q_000000222*PR_000012010002+Q_000000322*PR_000012010003+Q_000000422*PR_000012010004); ans_temp[ans_id*36+24]+=Pmtrx[18]*(Q_022000000*PR_001010011000+Q_122000000*PR_001010011100+Q_222000000*PR_001010011200+Q_322000000*PR_001010011300+Q_422000000*PR_001010011400); ans_temp[ans_id*36+24]+=Pmtrx[19]*(Q_021001000*PR_001010011000+Q_021101000*PR_001010011010+Q_121001000*PR_001010011100+Q_121101000*PR_001010011110+Q_221001000*PR_001010011200+Q_221101000*PR_001010011210+Q_321001000*PR_001010011300+Q_321101000*PR_001010011310); ans_temp[ans_id*36+24]+=Pmtrx[20]*(Q_020002000*PR_001010011000+Q_020102000*PR_001010011010+Q_020202000*PR_001010011020+Q_120002000*PR_001010011100+Q_120102000*PR_001010011110+Q_120202000*PR_001010011120+Q_220002000*PR_001010011200+Q_220102000*PR_001010011210+Q_220202000*PR_001010011220); ans_temp[ans_id*36+24]+=Pmtrx[21]*(Q_021000001*PR_001010011000+Q_021000101*PR_001010011001+Q_121000001*PR_001010011100+Q_121000101*PR_001010011101+Q_221000001*PR_001010011200+Q_221000101*PR_001010011201+Q_321000001*PR_001010011300+Q_321000101*PR_001010011301); ans_temp[ans_id*36+24]+=Pmtrx[22]*(Q_020001001*PR_001010011000+Q_020001101*PR_001010011001+Q_020101001*PR_001010011010+Q_020101101*PR_001010011011+Q_120001001*PR_001010011100+Q_120001101*PR_001010011101+Q_120101001*PR_001010011110+Q_120101101*PR_001010011111+Q_220001001*PR_001010011200+Q_220001101*PR_001010011201+Q_220101001*PR_001010011210+Q_220101101*PR_001010011211); ans_temp[ans_id*36+24]+=Pmtrx[23]*(Q_020000002*PR_001010011000+Q_020000102*PR_001010011001+Q_020000202*PR_001010011002+Q_120000002*PR_001010011100+Q_120000102*PR_001010011101+Q_120000202*PR_001010011102+Q_220000002*PR_001010011200+Q_220000102*PR_001010011201+Q_220000202*PR_001010011202); ans_temp[ans_id*36+25]+=Pmtrx[18]*(Q_012010000*PR_001010011000+Q_012110000*PR_001010011010+Q_112010000*PR_001010011100+Q_112110000*PR_001010011110+Q_212010000*PR_001010011200+Q_212110000*PR_001010011210+Q_312010000*PR_001010011300+Q_312110000*PR_001010011310); ans_temp[ans_id*36+25]+=Pmtrx[19]*(Q_011011000*PR_001010011000+Q_011111000*PR_001010011010+Q_011211000*PR_001010011020+Q_111011000*PR_001010011100+Q_111111000*PR_001010011110+Q_111211000*PR_001010011120+Q_211011000*PR_001010011200+Q_211111000*PR_001010011210+Q_211211000*PR_001010011220); ans_temp[ans_id*36+25]+=Pmtrx[20]*(Q_010012000*PR_001010011000+Q_010112000*PR_001010011010+Q_010212000*PR_001010011020+Q_010312000*PR_001010011030+Q_110012000*PR_001010011100+Q_110112000*PR_001010011110+Q_110212000*PR_001010011120+Q_110312000*PR_001010011130); ans_temp[ans_id*36+25]+=Pmtrx[21]*(Q_011010001*PR_001010011000+Q_011010101*PR_001010011001+Q_011110001*PR_001010011010+Q_011110101*PR_001010011011+Q_111010001*PR_001010011100+Q_111010101*PR_001010011101+Q_111110001*PR_001010011110+Q_111110101*PR_001010011111+Q_211010001*PR_001010011200+Q_211010101*PR_001010011201+Q_211110001*PR_001010011210+Q_211110101*PR_001010011211); ans_temp[ans_id*36+25]+=Pmtrx[22]*(Q_010011001*PR_001010011000+Q_010011101*PR_001010011001+Q_010111001*PR_001010011010+Q_010111101*PR_001010011011+Q_010211001*PR_001010011020+Q_010211101*PR_001010011021+Q_110011001*PR_001010011100+Q_110011101*PR_001010011101+Q_110111001*PR_001010011110+Q_110111101*PR_001010011111+Q_110211001*PR_001010011120+Q_110211101*PR_001010011121); ans_temp[ans_id*36+25]+=Pmtrx[23]*(Q_010010002*PR_001010011000+Q_010010102*PR_001010011001+Q_010010202*PR_001010011002+Q_010110002*PR_001010011010+Q_010110102*PR_001010011011+Q_010110202*PR_001010011012+Q_110010002*PR_001010011100+Q_110010102*PR_001010011101+Q_110010202*PR_001010011102+Q_110110002*PR_001010011110+Q_110110102*PR_001010011111+Q_110110202*PR_001010011112); ans_temp[ans_id*36+26]+=Pmtrx[18]*(Q_002020000*PR_001010011000+Q_002120000*PR_001010011010+Q_002220000*PR_001010011020+Q_102020000*PR_001010011100+Q_102120000*PR_001010011110+Q_102220000*PR_001010011120+Q_202020000*PR_001010011200+Q_202120000*PR_001010011210+Q_202220000*PR_001010011220); ans_temp[ans_id*36+26]+=Pmtrx[19]*(Q_001021000*PR_001010011000+Q_001121000*PR_001010011010+Q_001221000*PR_001010011020+Q_001321000*PR_001010011030+Q_101021000*PR_001010011100+Q_101121000*PR_001010011110+Q_101221000*PR_001010011120+Q_101321000*PR_001010011130); ans_temp[ans_id*36+26]+=Pmtrx[20]*(Q_000022000*PR_001010011000+Q_000122000*PR_001010011010+Q_000222000*PR_001010011020+Q_000322000*PR_001010011030+Q_000422000*PR_001010011040); ans_temp[ans_id*36+26]+=Pmtrx[21]*(Q_001020001*PR_001010011000+Q_001020101*PR_001010011001+Q_001120001*PR_001010011010+Q_001120101*PR_001010011011+Q_001220001*PR_001010011020+Q_001220101*PR_001010011021+Q_101020001*PR_001010011100+Q_101020101*PR_001010011101+Q_101120001*PR_001010011110+Q_101120101*PR_001010011111+Q_101220001*PR_001010011120+Q_101220101*PR_001010011121); ans_temp[ans_id*36+26]+=Pmtrx[22]*(Q_000021001*PR_001010011000+Q_000021101*PR_001010011001+Q_000121001*PR_001010011010+Q_000121101*PR_001010011011+Q_000221001*PR_001010011020+Q_000221101*PR_001010011021+Q_000321001*PR_001010011030+Q_000321101*PR_001010011031); ans_temp[ans_id*36+26]+=Pmtrx[23]*(Q_000020002*PR_001010011000+Q_000020102*PR_001010011001+Q_000020202*PR_001010011002+Q_000120002*PR_001010011010+Q_000120102*PR_001010011011+Q_000120202*PR_001010011012+Q_000220002*PR_001010011020+Q_000220102*PR_001010011021+Q_000220202*PR_001010011022); ans_temp[ans_id*36+27]+=Pmtrx[18]*(Q_012000010*PR_001010011000+Q_012000110*PR_001010011001+Q_112000010*PR_001010011100+Q_112000110*PR_001010011101+Q_212000010*PR_001010011200+Q_212000110*PR_001010011201+Q_312000010*PR_001010011300+Q_312000110*PR_001010011301); ans_temp[ans_id*36+27]+=Pmtrx[19]*(Q_011001010*PR_001010011000+Q_011001110*PR_001010011001+Q_011101010*PR_001010011010+Q_011101110*PR_001010011011+Q_111001010*PR_001010011100+Q_111001110*PR_001010011101+Q_111101010*PR_001010011110+Q_111101110*PR_001010011111+Q_211001010*PR_001010011200+Q_211001110*PR_001010011201+Q_211101010*PR_001010011210+Q_211101110*PR_001010011211); ans_temp[ans_id*36+27]+=Pmtrx[20]*(Q_010002010*PR_001010011000+Q_010002110*PR_001010011001+Q_010102010*PR_001010011010+Q_010102110*PR_001010011011+Q_010202010*PR_001010011020+Q_010202110*PR_001010011021+Q_110002010*PR_001010011100+Q_110002110*PR_001010011101+Q_110102010*PR_001010011110+Q_110102110*PR_001010011111+Q_110202010*PR_001010011120+Q_110202110*PR_001010011121); ans_temp[ans_id*36+27]+=Pmtrx[21]*(Q_011000011*PR_001010011000+Q_011000111*PR_001010011001+Q_011000211*PR_001010011002+Q_111000011*PR_001010011100+Q_111000111*PR_001010011101+Q_111000211*PR_001010011102+Q_211000011*PR_001010011200+Q_211000111*PR_001010011201+Q_211000211*PR_001010011202); ans_temp[ans_id*36+27]+=Pmtrx[22]*(Q_010001011*PR_001010011000+Q_010001111*PR_001010011001+Q_010001211*PR_001010011002+Q_010101011*PR_001010011010+Q_010101111*PR_001010011011+Q_010101211*PR_001010011012+Q_110001011*PR_001010011100+Q_110001111*PR_001010011101+Q_110001211*PR_001010011102+Q_110101011*PR_001010011110+Q_110101111*PR_001010011111+Q_110101211*PR_001010011112); ans_temp[ans_id*36+27]+=Pmtrx[23]*(Q_010000012*PR_001010011000+Q_010000112*PR_001010011001+Q_010000212*PR_001010011002+Q_010000312*PR_001010011003+Q_110000012*PR_001010011100+Q_110000112*PR_001010011101+Q_110000212*PR_001010011102+Q_110000312*PR_001010011103); ans_temp[ans_id*36+28]+=Pmtrx[18]*(Q_002010010*PR_001010011000+Q_002010110*PR_001010011001+Q_002110010*PR_001010011010+Q_002110110*PR_001010011011+Q_102010010*PR_001010011100+Q_102010110*PR_001010011101+Q_102110010*PR_001010011110+Q_102110110*PR_001010011111+Q_202010010*PR_001010011200+Q_202010110*PR_001010011201+Q_202110010*PR_001010011210+Q_202110110*PR_001010011211); ans_temp[ans_id*36+28]+=Pmtrx[19]*(Q_001011010*PR_001010011000+Q_001011110*PR_001010011001+Q_001111010*PR_001010011010+Q_001111110*PR_001010011011+Q_001211010*PR_001010011020+Q_001211110*PR_001010011021+Q_101011010*PR_001010011100+Q_101011110*PR_001010011101+Q_101111010*PR_001010011110+Q_101111110*PR_001010011111+Q_101211010*PR_001010011120+Q_101211110*PR_001010011121); ans_temp[ans_id*36+28]+=Pmtrx[20]*(Q_000012010*PR_001010011000+Q_000012110*PR_001010011001+Q_000112010*PR_001010011010+Q_000112110*PR_001010011011+Q_000212010*PR_001010011020+Q_000212110*PR_001010011021+Q_000312010*PR_001010011030+Q_000312110*PR_001010011031); ans_temp[ans_id*36+28]+=Pmtrx[21]*(Q_001010011*PR_001010011000+Q_001010111*PR_001010011001+Q_001010211*PR_001010011002+Q_001110011*PR_001010011010+Q_001110111*PR_001010011011+Q_001110211*PR_001010011012+Q_101010011*PR_001010011100+Q_101010111*PR_001010011101+Q_101010211*PR_001010011102+Q_101110011*PR_001010011110+Q_101110111*PR_001010011111+Q_101110211*PR_001010011112); ans_temp[ans_id*36+28]+=Pmtrx[22]*(Q_000011011*PR_001010011000+Q_000011111*PR_001010011001+Q_000011211*PR_001010011002+Q_000111011*PR_001010011010+Q_000111111*PR_001010011011+Q_000111211*PR_001010011012+Q_000211011*PR_001010011020+Q_000211111*PR_001010011021+Q_000211211*PR_001010011022); ans_temp[ans_id*36+28]+=Pmtrx[23]*(Q_000010012*PR_001010011000+Q_000010112*PR_001010011001+Q_000010212*PR_001010011002+Q_000010312*PR_001010011003+Q_000110012*PR_001010011010+Q_000110112*PR_001010011011+Q_000110212*PR_001010011012+Q_000110312*PR_001010011013); ans_temp[ans_id*36+29]+=Pmtrx[18]*(Q_002000020*PR_001010011000+Q_002000120*PR_001010011001+Q_002000220*PR_001010011002+Q_102000020*PR_001010011100+Q_102000120*PR_001010011101+Q_102000220*PR_001010011102+Q_202000020*PR_001010011200+Q_202000120*PR_001010011201+Q_202000220*PR_001010011202); ans_temp[ans_id*36+29]+=Pmtrx[19]*(Q_001001020*PR_001010011000+Q_001001120*PR_001010011001+Q_001001220*PR_001010011002+Q_001101020*PR_001010011010+Q_001101120*PR_001010011011+Q_001101220*PR_001010011012+Q_101001020*PR_001010011100+Q_101001120*PR_001010011101+Q_101001220*PR_001010011102+Q_101101020*PR_001010011110+Q_101101120*PR_001010011111+Q_101101220*PR_001010011112); ans_temp[ans_id*36+29]+=Pmtrx[20]*(Q_000002020*PR_001010011000+Q_000002120*PR_001010011001+Q_000002220*PR_001010011002+Q_000102020*PR_001010011010+Q_000102120*PR_001010011011+Q_000102220*PR_001010011012+Q_000202020*PR_001010011020+Q_000202120*PR_001010011021+Q_000202220*PR_001010011022); ans_temp[ans_id*36+29]+=Pmtrx[21]*(Q_001000021*PR_001010011000+Q_001000121*PR_001010011001+Q_001000221*PR_001010011002+Q_001000321*PR_001010011003+Q_101000021*PR_001010011100+Q_101000121*PR_001010011101+Q_101000221*PR_001010011102+Q_101000321*PR_001010011103); ans_temp[ans_id*36+29]+=Pmtrx[22]*(Q_000001021*PR_001010011000+Q_000001121*PR_001010011001+Q_000001221*PR_001010011002+Q_000001321*PR_001010011003+Q_000101021*PR_001010011010+Q_000101121*PR_001010011011+Q_000101221*PR_001010011012+Q_000101321*PR_001010011013); ans_temp[ans_id*36+29]+=Pmtrx[23]*(Q_000000022*PR_001010011000+Q_000000122*PR_001010011001+Q_000000222*PR_001010011002+Q_000000322*PR_001010011003+Q_000000422*PR_001010011004); ans_temp[ans_id*36+24]+=Pmtrx[24]*(Q_022000000*PR_000011011000+Q_122000000*PR_000011011100+Q_222000000*PR_000011011200+Q_322000000*PR_000011011300+Q_422000000*PR_000011011400); ans_temp[ans_id*36+24]+=Pmtrx[25]*(Q_021001000*PR_000011011000+Q_021101000*PR_000011011010+Q_121001000*PR_000011011100+Q_121101000*PR_000011011110+Q_221001000*PR_000011011200+Q_221101000*PR_000011011210+Q_321001000*PR_000011011300+Q_321101000*PR_000011011310); ans_temp[ans_id*36+24]+=Pmtrx[26]*(Q_020002000*PR_000011011000+Q_020102000*PR_000011011010+Q_020202000*PR_000011011020+Q_120002000*PR_000011011100+Q_120102000*PR_000011011110+Q_120202000*PR_000011011120+Q_220002000*PR_000011011200+Q_220102000*PR_000011011210+Q_220202000*PR_000011011220); ans_temp[ans_id*36+24]+=Pmtrx[27]*(Q_021000001*PR_000011011000+Q_021000101*PR_000011011001+Q_121000001*PR_000011011100+Q_121000101*PR_000011011101+Q_221000001*PR_000011011200+Q_221000101*PR_000011011201+Q_321000001*PR_000011011300+Q_321000101*PR_000011011301); ans_temp[ans_id*36+24]+=Pmtrx[28]*(Q_020001001*PR_000011011000+Q_020001101*PR_000011011001+Q_020101001*PR_000011011010+Q_020101101*PR_000011011011+Q_120001001*PR_000011011100+Q_120001101*PR_000011011101+Q_120101001*PR_000011011110+Q_120101101*PR_000011011111+Q_220001001*PR_000011011200+Q_220001101*PR_000011011201+Q_220101001*PR_000011011210+Q_220101101*PR_000011011211); ans_temp[ans_id*36+24]+=Pmtrx[29]*(Q_020000002*PR_000011011000+Q_020000102*PR_000011011001+Q_020000202*PR_000011011002+Q_120000002*PR_000011011100+Q_120000102*PR_000011011101+Q_120000202*PR_000011011102+Q_220000002*PR_000011011200+Q_220000102*PR_000011011201+Q_220000202*PR_000011011202); ans_temp[ans_id*36+25]+=Pmtrx[24]*(Q_012010000*PR_000011011000+Q_012110000*PR_000011011010+Q_112010000*PR_000011011100+Q_112110000*PR_000011011110+Q_212010000*PR_000011011200+Q_212110000*PR_000011011210+Q_312010000*PR_000011011300+Q_312110000*PR_000011011310); ans_temp[ans_id*36+25]+=Pmtrx[25]*(Q_011011000*PR_000011011000+Q_011111000*PR_000011011010+Q_011211000*PR_000011011020+Q_111011000*PR_000011011100+Q_111111000*PR_000011011110+Q_111211000*PR_000011011120+Q_211011000*PR_000011011200+Q_211111000*PR_000011011210+Q_211211000*PR_000011011220); ans_temp[ans_id*36+25]+=Pmtrx[26]*(Q_010012000*PR_000011011000+Q_010112000*PR_000011011010+Q_010212000*PR_000011011020+Q_010312000*PR_000011011030+Q_110012000*PR_000011011100+Q_110112000*PR_000011011110+Q_110212000*PR_000011011120+Q_110312000*PR_000011011130); ans_temp[ans_id*36+25]+=Pmtrx[27]*(Q_011010001*PR_000011011000+Q_011010101*PR_000011011001+Q_011110001*PR_000011011010+Q_011110101*PR_000011011011+Q_111010001*PR_000011011100+Q_111010101*PR_000011011101+Q_111110001*PR_000011011110+Q_111110101*PR_000011011111+Q_211010001*PR_000011011200+Q_211010101*PR_000011011201+Q_211110001*PR_000011011210+Q_211110101*PR_000011011211); ans_temp[ans_id*36+25]+=Pmtrx[28]*(Q_010011001*PR_000011011000+Q_010011101*PR_000011011001+Q_010111001*PR_000011011010+Q_010111101*PR_000011011011+Q_010211001*PR_000011011020+Q_010211101*PR_000011011021+Q_110011001*PR_000011011100+Q_110011101*PR_000011011101+Q_110111001*PR_000011011110+Q_110111101*PR_000011011111+Q_110211001*PR_000011011120+Q_110211101*PR_000011011121); ans_temp[ans_id*36+25]+=Pmtrx[29]*(Q_010010002*PR_000011011000+Q_010010102*PR_000011011001+Q_010010202*PR_000011011002+Q_010110002*PR_000011011010+Q_010110102*PR_000011011011+Q_010110202*PR_000011011012+Q_110010002*PR_000011011100+Q_110010102*PR_000011011101+Q_110010202*PR_000011011102+Q_110110002*PR_000011011110+Q_110110102*PR_000011011111+Q_110110202*PR_000011011112); ans_temp[ans_id*36+26]+=Pmtrx[24]*(Q_002020000*PR_000011011000+Q_002120000*PR_000011011010+Q_002220000*PR_000011011020+Q_102020000*PR_000011011100+Q_102120000*PR_000011011110+Q_102220000*PR_000011011120+Q_202020000*PR_000011011200+Q_202120000*PR_000011011210+Q_202220000*PR_000011011220); ans_temp[ans_id*36+26]+=Pmtrx[25]*(Q_001021000*PR_000011011000+Q_001121000*PR_000011011010+Q_001221000*PR_000011011020+Q_001321000*PR_000011011030+Q_101021000*PR_000011011100+Q_101121000*PR_000011011110+Q_101221000*PR_000011011120+Q_101321000*PR_000011011130); ans_temp[ans_id*36+26]+=Pmtrx[26]*(Q_000022000*PR_000011011000+Q_000122000*PR_000011011010+Q_000222000*PR_000011011020+Q_000322000*PR_000011011030+Q_000422000*PR_000011011040); ans_temp[ans_id*36+26]+=Pmtrx[27]*(Q_001020001*PR_000011011000+Q_001020101*PR_000011011001+Q_001120001*PR_000011011010+Q_001120101*PR_000011011011+Q_001220001*PR_000011011020+Q_001220101*PR_000011011021+Q_101020001*PR_000011011100+Q_101020101*PR_000011011101+Q_101120001*PR_000011011110+Q_101120101*PR_000011011111+Q_101220001*PR_000011011120+Q_101220101*PR_000011011121); ans_temp[ans_id*36+26]+=Pmtrx[28]*(Q_000021001*PR_000011011000+Q_000021101*PR_000011011001+Q_000121001*PR_000011011010+Q_000121101*PR_000011011011+Q_000221001*PR_000011011020+Q_000221101*PR_000011011021+Q_000321001*PR_000011011030+Q_000321101*PR_000011011031); ans_temp[ans_id*36+26]+=Pmtrx[29]*(Q_000020002*PR_000011011000+Q_000020102*PR_000011011001+Q_000020202*PR_000011011002+Q_000120002*PR_000011011010+Q_000120102*PR_000011011011+Q_000120202*PR_000011011012+Q_000220002*PR_000011011020+Q_000220102*PR_000011011021+Q_000220202*PR_000011011022); ans_temp[ans_id*36+27]+=Pmtrx[24]*(Q_012000010*PR_000011011000+Q_012000110*PR_000011011001+Q_112000010*PR_000011011100+Q_112000110*PR_000011011101+Q_212000010*PR_000011011200+Q_212000110*PR_000011011201+Q_312000010*PR_000011011300+Q_312000110*PR_000011011301); ans_temp[ans_id*36+27]+=Pmtrx[25]*(Q_011001010*PR_000011011000+Q_011001110*PR_000011011001+Q_011101010*PR_000011011010+Q_011101110*PR_000011011011+Q_111001010*PR_000011011100+Q_111001110*PR_000011011101+Q_111101010*PR_000011011110+Q_111101110*PR_000011011111+Q_211001010*PR_000011011200+Q_211001110*PR_000011011201+Q_211101010*PR_000011011210+Q_211101110*PR_000011011211); ans_temp[ans_id*36+27]+=Pmtrx[26]*(Q_010002010*PR_000011011000+Q_010002110*PR_000011011001+Q_010102010*PR_000011011010+Q_010102110*PR_000011011011+Q_010202010*PR_000011011020+Q_010202110*PR_000011011021+Q_110002010*PR_000011011100+Q_110002110*PR_000011011101+Q_110102010*PR_000011011110+Q_110102110*PR_000011011111+Q_110202010*PR_000011011120+Q_110202110*PR_000011011121); ans_temp[ans_id*36+27]+=Pmtrx[27]*(Q_011000011*PR_000011011000+Q_011000111*PR_000011011001+Q_011000211*PR_000011011002+Q_111000011*PR_000011011100+Q_111000111*PR_000011011101+Q_111000211*PR_000011011102+Q_211000011*PR_000011011200+Q_211000111*PR_000011011201+Q_211000211*PR_000011011202); ans_temp[ans_id*36+27]+=Pmtrx[28]*(Q_010001011*PR_000011011000+Q_010001111*PR_000011011001+Q_010001211*PR_000011011002+Q_010101011*PR_000011011010+Q_010101111*PR_000011011011+Q_010101211*PR_000011011012+Q_110001011*PR_000011011100+Q_110001111*PR_000011011101+Q_110001211*PR_000011011102+Q_110101011*PR_000011011110+Q_110101111*PR_000011011111+Q_110101211*PR_000011011112); ans_temp[ans_id*36+27]+=Pmtrx[29]*(Q_010000012*PR_000011011000+Q_010000112*PR_000011011001+Q_010000212*PR_000011011002+Q_010000312*PR_000011011003+Q_110000012*PR_000011011100+Q_110000112*PR_000011011101+Q_110000212*PR_000011011102+Q_110000312*PR_000011011103); ans_temp[ans_id*36+28]+=Pmtrx[24]*(Q_002010010*PR_000011011000+Q_002010110*PR_000011011001+Q_002110010*PR_000011011010+Q_002110110*PR_000011011011+Q_102010010*PR_000011011100+Q_102010110*PR_000011011101+Q_102110010*PR_000011011110+Q_102110110*PR_000011011111+Q_202010010*PR_000011011200+Q_202010110*PR_000011011201+Q_202110010*PR_000011011210+Q_202110110*PR_000011011211); ans_temp[ans_id*36+28]+=Pmtrx[25]*(Q_001011010*PR_000011011000+Q_001011110*PR_000011011001+Q_001111010*PR_000011011010+Q_001111110*PR_000011011011+Q_001211010*PR_000011011020+Q_001211110*PR_000011011021+Q_101011010*PR_000011011100+Q_101011110*PR_000011011101+Q_101111010*PR_000011011110+Q_101111110*PR_000011011111+Q_101211010*PR_000011011120+Q_101211110*PR_000011011121); ans_temp[ans_id*36+28]+=Pmtrx[26]*(Q_000012010*PR_000011011000+Q_000012110*PR_000011011001+Q_000112010*PR_000011011010+Q_000112110*PR_000011011011+Q_000212010*PR_000011011020+Q_000212110*PR_000011011021+Q_000312010*PR_000011011030+Q_000312110*PR_000011011031); ans_temp[ans_id*36+28]+=Pmtrx[27]*(Q_001010011*PR_000011011000+Q_001010111*PR_000011011001+Q_001010211*PR_000011011002+Q_001110011*PR_000011011010+Q_001110111*PR_000011011011+Q_001110211*PR_000011011012+Q_101010011*PR_000011011100+Q_101010111*PR_000011011101+Q_101010211*PR_000011011102+Q_101110011*PR_000011011110+Q_101110111*PR_000011011111+Q_101110211*PR_000011011112); ans_temp[ans_id*36+28]+=Pmtrx[28]*(Q_000011011*PR_000011011000+Q_000011111*PR_000011011001+Q_000011211*PR_000011011002+Q_000111011*PR_000011011010+Q_000111111*PR_000011011011+Q_000111211*PR_000011011012+Q_000211011*PR_000011011020+Q_000211111*PR_000011011021+Q_000211211*PR_000011011022); ans_temp[ans_id*36+28]+=Pmtrx[29]*(Q_000010012*PR_000011011000+Q_000010112*PR_000011011001+Q_000010212*PR_000011011002+Q_000010312*PR_000011011003+Q_000110012*PR_000011011010+Q_000110112*PR_000011011011+Q_000110212*PR_000011011012+Q_000110312*PR_000011011013); ans_temp[ans_id*36+29]+=Pmtrx[24]*(Q_002000020*PR_000011011000+Q_002000120*PR_000011011001+Q_002000220*PR_000011011002+Q_102000020*PR_000011011100+Q_102000120*PR_000011011101+Q_102000220*PR_000011011102+Q_202000020*PR_000011011200+Q_202000120*PR_000011011201+Q_202000220*PR_000011011202); ans_temp[ans_id*36+29]+=Pmtrx[25]*(Q_001001020*PR_000011011000+Q_001001120*PR_000011011001+Q_001001220*PR_000011011002+Q_001101020*PR_000011011010+Q_001101120*PR_000011011011+Q_001101220*PR_000011011012+Q_101001020*PR_000011011100+Q_101001120*PR_000011011101+Q_101001220*PR_000011011102+Q_101101020*PR_000011011110+Q_101101120*PR_000011011111+Q_101101220*PR_000011011112); ans_temp[ans_id*36+29]+=Pmtrx[26]*(Q_000002020*PR_000011011000+Q_000002120*PR_000011011001+Q_000002220*PR_000011011002+Q_000102020*PR_000011011010+Q_000102120*PR_000011011011+Q_000102220*PR_000011011012+Q_000202020*PR_000011011020+Q_000202120*PR_000011011021+Q_000202220*PR_000011011022); ans_temp[ans_id*36+29]+=Pmtrx[27]*(Q_001000021*PR_000011011000+Q_001000121*PR_000011011001+Q_001000221*PR_000011011002+Q_001000321*PR_000011011003+Q_101000021*PR_000011011100+Q_101000121*PR_000011011101+Q_101000221*PR_000011011102+Q_101000321*PR_000011011103); ans_temp[ans_id*36+29]+=Pmtrx[28]*(Q_000001021*PR_000011011000+Q_000001121*PR_000011011001+Q_000001221*PR_000011011002+Q_000001321*PR_000011011003+Q_000101021*PR_000011011010+Q_000101121*PR_000011011011+Q_000101221*PR_000011011012+Q_000101321*PR_000011011013); ans_temp[ans_id*36+29]+=Pmtrx[29]*(Q_000000022*PR_000011011000+Q_000000122*PR_000011011001+Q_000000222*PR_000011011002+Q_000000322*PR_000011011003+Q_000000422*PR_000011011004); ans_temp[ans_id*36+24]+=Pmtrx[30]*(Q_022000000*PR_000010012000+Q_122000000*PR_000010012100+Q_222000000*PR_000010012200+Q_322000000*PR_000010012300+Q_422000000*PR_000010012400); ans_temp[ans_id*36+24]+=Pmtrx[31]*(Q_021001000*PR_000010012000+Q_021101000*PR_000010012010+Q_121001000*PR_000010012100+Q_121101000*PR_000010012110+Q_221001000*PR_000010012200+Q_221101000*PR_000010012210+Q_321001000*PR_000010012300+Q_321101000*PR_000010012310); ans_temp[ans_id*36+24]+=Pmtrx[32]*(Q_020002000*PR_000010012000+Q_020102000*PR_000010012010+Q_020202000*PR_000010012020+Q_120002000*PR_000010012100+Q_120102000*PR_000010012110+Q_120202000*PR_000010012120+Q_220002000*PR_000010012200+Q_220102000*PR_000010012210+Q_220202000*PR_000010012220); ans_temp[ans_id*36+24]+=Pmtrx[33]*(Q_021000001*PR_000010012000+Q_021000101*PR_000010012001+Q_121000001*PR_000010012100+Q_121000101*PR_000010012101+Q_221000001*PR_000010012200+Q_221000101*PR_000010012201+Q_321000001*PR_000010012300+Q_321000101*PR_000010012301); ans_temp[ans_id*36+24]+=Pmtrx[34]*(Q_020001001*PR_000010012000+Q_020001101*PR_000010012001+Q_020101001*PR_000010012010+Q_020101101*PR_000010012011+Q_120001001*PR_000010012100+Q_120001101*PR_000010012101+Q_120101001*PR_000010012110+Q_120101101*PR_000010012111+Q_220001001*PR_000010012200+Q_220001101*PR_000010012201+Q_220101001*PR_000010012210+Q_220101101*PR_000010012211); ans_temp[ans_id*36+24]+=Pmtrx[35]*(Q_020000002*PR_000010012000+Q_020000102*PR_000010012001+Q_020000202*PR_000010012002+Q_120000002*PR_000010012100+Q_120000102*PR_000010012101+Q_120000202*PR_000010012102+Q_220000002*PR_000010012200+Q_220000102*PR_000010012201+Q_220000202*PR_000010012202); ans_temp[ans_id*36+25]+=Pmtrx[30]*(Q_012010000*PR_000010012000+Q_012110000*PR_000010012010+Q_112010000*PR_000010012100+Q_112110000*PR_000010012110+Q_212010000*PR_000010012200+Q_212110000*PR_000010012210+Q_312010000*PR_000010012300+Q_312110000*PR_000010012310); ans_temp[ans_id*36+25]+=Pmtrx[31]*(Q_011011000*PR_000010012000+Q_011111000*PR_000010012010+Q_011211000*PR_000010012020+Q_111011000*PR_000010012100+Q_111111000*PR_000010012110+Q_111211000*PR_000010012120+Q_211011000*PR_000010012200+Q_211111000*PR_000010012210+Q_211211000*PR_000010012220); ans_temp[ans_id*36+25]+=Pmtrx[32]*(Q_010012000*PR_000010012000+Q_010112000*PR_000010012010+Q_010212000*PR_000010012020+Q_010312000*PR_000010012030+Q_110012000*PR_000010012100+Q_110112000*PR_000010012110+Q_110212000*PR_000010012120+Q_110312000*PR_000010012130); ans_temp[ans_id*36+25]+=Pmtrx[33]*(Q_011010001*PR_000010012000+Q_011010101*PR_000010012001+Q_011110001*PR_000010012010+Q_011110101*PR_000010012011+Q_111010001*PR_000010012100+Q_111010101*PR_000010012101+Q_111110001*PR_000010012110+Q_111110101*PR_000010012111+Q_211010001*PR_000010012200+Q_211010101*PR_000010012201+Q_211110001*PR_000010012210+Q_211110101*PR_000010012211); ans_temp[ans_id*36+25]+=Pmtrx[34]*(Q_010011001*PR_000010012000+Q_010011101*PR_000010012001+Q_010111001*PR_000010012010+Q_010111101*PR_000010012011+Q_010211001*PR_000010012020+Q_010211101*PR_000010012021+Q_110011001*PR_000010012100+Q_110011101*PR_000010012101+Q_110111001*PR_000010012110+Q_110111101*PR_000010012111+Q_110211001*PR_000010012120+Q_110211101*PR_000010012121); ans_temp[ans_id*36+25]+=Pmtrx[35]*(Q_010010002*PR_000010012000+Q_010010102*PR_000010012001+Q_010010202*PR_000010012002+Q_010110002*PR_000010012010+Q_010110102*PR_000010012011+Q_010110202*PR_000010012012+Q_110010002*PR_000010012100+Q_110010102*PR_000010012101+Q_110010202*PR_000010012102+Q_110110002*PR_000010012110+Q_110110102*PR_000010012111+Q_110110202*PR_000010012112); ans_temp[ans_id*36+26]+=Pmtrx[30]*(Q_002020000*PR_000010012000+Q_002120000*PR_000010012010+Q_002220000*PR_000010012020+Q_102020000*PR_000010012100+Q_102120000*PR_000010012110+Q_102220000*PR_000010012120+Q_202020000*PR_000010012200+Q_202120000*PR_000010012210+Q_202220000*PR_000010012220); ans_temp[ans_id*36+26]+=Pmtrx[31]*(Q_001021000*PR_000010012000+Q_001121000*PR_000010012010+Q_001221000*PR_000010012020+Q_001321000*PR_000010012030+Q_101021000*PR_000010012100+Q_101121000*PR_000010012110+Q_101221000*PR_000010012120+Q_101321000*PR_000010012130); ans_temp[ans_id*36+26]+=Pmtrx[32]*(Q_000022000*PR_000010012000+Q_000122000*PR_000010012010+Q_000222000*PR_000010012020+Q_000322000*PR_000010012030+Q_000422000*PR_000010012040); ans_temp[ans_id*36+26]+=Pmtrx[33]*(Q_001020001*PR_000010012000+Q_001020101*PR_000010012001+Q_001120001*PR_000010012010+Q_001120101*PR_000010012011+Q_001220001*PR_000010012020+Q_001220101*PR_000010012021+Q_101020001*PR_000010012100+Q_101020101*PR_000010012101+Q_101120001*PR_000010012110+Q_101120101*PR_000010012111+Q_101220001*PR_000010012120+Q_101220101*PR_000010012121); ans_temp[ans_id*36+26]+=Pmtrx[34]*(Q_000021001*PR_000010012000+Q_000021101*PR_000010012001+Q_000121001*PR_000010012010+Q_000121101*PR_000010012011+Q_000221001*PR_000010012020+Q_000221101*PR_000010012021+Q_000321001*PR_000010012030+Q_000321101*PR_000010012031); ans_temp[ans_id*36+26]+=Pmtrx[35]*(Q_000020002*PR_000010012000+Q_000020102*PR_000010012001+Q_000020202*PR_000010012002+Q_000120002*PR_000010012010+Q_000120102*PR_000010012011+Q_000120202*PR_000010012012+Q_000220002*PR_000010012020+Q_000220102*PR_000010012021+Q_000220202*PR_000010012022); ans_temp[ans_id*36+27]+=Pmtrx[30]*(Q_012000010*PR_000010012000+Q_012000110*PR_000010012001+Q_112000010*PR_000010012100+Q_112000110*PR_000010012101+Q_212000010*PR_000010012200+Q_212000110*PR_000010012201+Q_312000010*PR_000010012300+Q_312000110*PR_000010012301); ans_temp[ans_id*36+27]+=Pmtrx[31]*(Q_011001010*PR_000010012000+Q_011001110*PR_000010012001+Q_011101010*PR_000010012010+Q_011101110*PR_000010012011+Q_111001010*PR_000010012100+Q_111001110*PR_000010012101+Q_111101010*PR_000010012110+Q_111101110*PR_000010012111+Q_211001010*PR_000010012200+Q_211001110*PR_000010012201+Q_211101010*PR_000010012210+Q_211101110*PR_000010012211); ans_temp[ans_id*36+27]+=Pmtrx[32]*(Q_010002010*PR_000010012000+Q_010002110*PR_000010012001+Q_010102010*PR_000010012010+Q_010102110*PR_000010012011+Q_010202010*PR_000010012020+Q_010202110*PR_000010012021+Q_110002010*PR_000010012100+Q_110002110*PR_000010012101+Q_110102010*PR_000010012110+Q_110102110*PR_000010012111+Q_110202010*PR_000010012120+Q_110202110*PR_000010012121); ans_temp[ans_id*36+27]+=Pmtrx[33]*(Q_011000011*PR_000010012000+Q_011000111*PR_000010012001+Q_011000211*PR_000010012002+Q_111000011*PR_000010012100+Q_111000111*PR_000010012101+Q_111000211*PR_000010012102+Q_211000011*PR_000010012200+Q_211000111*PR_000010012201+Q_211000211*PR_000010012202); ans_temp[ans_id*36+27]+=Pmtrx[34]*(Q_010001011*PR_000010012000+Q_010001111*PR_000010012001+Q_010001211*PR_000010012002+Q_010101011*PR_000010012010+Q_010101111*PR_000010012011+Q_010101211*PR_000010012012+Q_110001011*PR_000010012100+Q_110001111*PR_000010012101+Q_110001211*PR_000010012102+Q_110101011*PR_000010012110+Q_110101111*PR_000010012111+Q_110101211*PR_000010012112); ans_temp[ans_id*36+27]+=Pmtrx[35]*(Q_010000012*PR_000010012000+Q_010000112*PR_000010012001+Q_010000212*PR_000010012002+Q_010000312*PR_000010012003+Q_110000012*PR_000010012100+Q_110000112*PR_000010012101+Q_110000212*PR_000010012102+Q_110000312*PR_000010012103); ans_temp[ans_id*36+28]+=Pmtrx[30]*(Q_002010010*PR_000010012000+Q_002010110*PR_000010012001+Q_002110010*PR_000010012010+Q_002110110*PR_000010012011+Q_102010010*PR_000010012100+Q_102010110*PR_000010012101+Q_102110010*PR_000010012110+Q_102110110*PR_000010012111+Q_202010010*PR_000010012200+Q_202010110*PR_000010012201+Q_202110010*PR_000010012210+Q_202110110*PR_000010012211); ans_temp[ans_id*36+28]+=Pmtrx[31]*(Q_001011010*PR_000010012000+Q_001011110*PR_000010012001+Q_001111010*PR_000010012010+Q_001111110*PR_000010012011+Q_001211010*PR_000010012020+Q_001211110*PR_000010012021+Q_101011010*PR_000010012100+Q_101011110*PR_000010012101+Q_101111010*PR_000010012110+Q_101111110*PR_000010012111+Q_101211010*PR_000010012120+Q_101211110*PR_000010012121); ans_temp[ans_id*36+28]+=Pmtrx[32]*(Q_000012010*PR_000010012000+Q_000012110*PR_000010012001+Q_000112010*PR_000010012010+Q_000112110*PR_000010012011+Q_000212010*PR_000010012020+Q_000212110*PR_000010012021+Q_000312010*PR_000010012030+Q_000312110*PR_000010012031); ans_temp[ans_id*36+28]+=Pmtrx[33]*(Q_001010011*PR_000010012000+Q_001010111*PR_000010012001+Q_001010211*PR_000010012002+Q_001110011*PR_000010012010+Q_001110111*PR_000010012011+Q_001110211*PR_000010012012+Q_101010011*PR_000010012100+Q_101010111*PR_000010012101+Q_101010211*PR_000010012102+Q_101110011*PR_000010012110+Q_101110111*PR_000010012111+Q_101110211*PR_000010012112); ans_temp[ans_id*36+28]+=Pmtrx[34]*(Q_000011011*PR_000010012000+Q_000011111*PR_000010012001+Q_000011211*PR_000010012002+Q_000111011*PR_000010012010+Q_000111111*PR_000010012011+Q_000111211*PR_000010012012+Q_000211011*PR_000010012020+Q_000211111*PR_000010012021+Q_000211211*PR_000010012022); ans_temp[ans_id*36+28]+=Pmtrx[35]*(Q_000010012*PR_000010012000+Q_000010112*PR_000010012001+Q_000010212*PR_000010012002+Q_000010312*PR_000010012003+Q_000110012*PR_000010012010+Q_000110112*PR_000010012011+Q_000110212*PR_000010012012+Q_000110312*PR_000010012013); ans_temp[ans_id*36+29]+=Pmtrx[30]*(Q_002000020*PR_000010012000+Q_002000120*PR_000010012001+Q_002000220*PR_000010012002+Q_102000020*PR_000010012100+Q_102000120*PR_000010012101+Q_102000220*PR_000010012102+Q_202000020*PR_000010012200+Q_202000120*PR_000010012201+Q_202000220*PR_000010012202); ans_temp[ans_id*36+29]+=Pmtrx[31]*(Q_001001020*PR_000010012000+Q_001001120*PR_000010012001+Q_001001220*PR_000010012002+Q_001101020*PR_000010012010+Q_001101120*PR_000010012011+Q_001101220*PR_000010012012+Q_101001020*PR_000010012100+Q_101001120*PR_000010012101+Q_101001220*PR_000010012102+Q_101101020*PR_000010012110+Q_101101120*PR_000010012111+Q_101101220*PR_000010012112); ans_temp[ans_id*36+29]+=Pmtrx[32]*(Q_000002020*PR_000010012000+Q_000002120*PR_000010012001+Q_000002220*PR_000010012002+Q_000102020*PR_000010012010+Q_000102120*PR_000010012011+Q_000102220*PR_000010012012+Q_000202020*PR_000010012020+Q_000202120*PR_000010012021+Q_000202220*PR_000010012022); ans_temp[ans_id*36+29]+=Pmtrx[33]*(Q_001000021*PR_000010012000+Q_001000121*PR_000010012001+Q_001000221*PR_000010012002+Q_001000321*PR_000010012003+Q_101000021*PR_000010012100+Q_101000121*PR_000010012101+Q_101000221*PR_000010012102+Q_101000321*PR_000010012103); ans_temp[ans_id*36+29]+=Pmtrx[34]*(Q_000001021*PR_000010012000+Q_000001121*PR_000010012001+Q_000001221*PR_000010012002+Q_000001321*PR_000010012003+Q_000101021*PR_000010012010+Q_000101121*PR_000010012011+Q_000101221*PR_000010012012+Q_000101321*PR_000010012013); ans_temp[ans_id*36+29]+=Pmtrx[35]*(Q_000000022*PR_000010012000+Q_000000122*PR_000010012001+Q_000000222*PR_000010012002+Q_000000322*PR_000010012003+Q_000000422*PR_000010012004); ans_temp[ans_id*36+30]+=Pmtrx[0]*(Q_022000000*PR_002000020000+Q_122000000*PR_002000020100+Q_222000000*PR_002000020200+Q_322000000*PR_002000020300+Q_422000000*PR_002000020400); ans_temp[ans_id*36+30]+=Pmtrx[1]*(Q_021001000*PR_002000020000+Q_021101000*PR_002000020010+Q_121001000*PR_002000020100+Q_121101000*PR_002000020110+Q_221001000*PR_002000020200+Q_221101000*PR_002000020210+Q_321001000*PR_002000020300+Q_321101000*PR_002000020310); ans_temp[ans_id*36+30]+=Pmtrx[2]*(Q_020002000*PR_002000020000+Q_020102000*PR_002000020010+Q_020202000*PR_002000020020+Q_120002000*PR_002000020100+Q_120102000*PR_002000020110+Q_120202000*PR_002000020120+Q_220002000*PR_002000020200+Q_220102000*PR_002000020210+Q_220202000*PR_002000020220); ans_temp[ans_id*36+30]+=Pmtrx[3]*(Q_021000001*PR_002000020000+Q_021000101*PR_002000020001+Q_121000001*PR_002000020100+Q_121000101*PR_002000020101+Q_221000001*PR_002000020200+Q_221000101*PR_002000020201+Q_321000001*PR_002000020300+Q_321000101*PR_002000020301); ans_temp[ans_id*36+30]+=Pmtrx[4]*(Q_020001001*PR_002000020000+Q_020001101*PR_002000020001+Q_020101001*PR_002000020010+Q_020101101*PR_002000020011+Q_120001001*PR_002000020100+Q_120001101*PR_002000020101+Q_120101001*PR_002000020110+Q_120101101*PR_002000020111+Q_220001001*PR_002000020200+Q_220001101*PR_002000020201+Q_220101001*PR_002000020210+Q_220101101*PR_002000020211); ans_temp[ans_id*36+30]+=Pmtrx[5]*(Q_020000002*PR_002000020000+Q_020000102*PR_002000020001+Q_020000202*PR_002000020002+Q_120000002*PR_002000020100+Q_120000102*PR_002000020101+Q_120000202*PR_002000020102+Q_220000002*PR_002000020200+Q_220000102*PR_002000020201+Q_220000202*PR_002000020202); ans_temp[ans_id*36+31]+=Pmtrx[0]*(Q_012010000*PR_002000020000+Q_012110000*PR_002000020010+Q_112010000*PR_002000020100+Q_112110000*PR_002000020110+Q_212010000*PR_002000020200+Q_212110000*PR_002000020210+Q_312010000*PR_002000020300+Q_312110000*PR_002000020310); ans_temp[ans_id*36+31]+=Pmtrx[1]*(Q_011011000*PR_002000020000+Q_011111000*PR_002000020010+Q_011211000*PR_002000020020+Q_111011000*PR_002000020100+Q_111111000*PR_002000020110+Q_111211000*PR_002000020120+Q_211011000*PR_002000020200+Q_211111000*PR_002000020210+Q_211211000*PR_002000020220); ans_temp[ans_id*36+31]+=Pmtrx[2]*(Q_010012000*PR_002000020000+Q_010112000*PR_002000020010+Q_010212000*PR_002000020020+Q_010312000*PR_002000020030+Q_110012000*PR_002000020100+Q_110112000*PR_002000020110+Q_110212000*PR_002000020120+Q_110312000*PR_002000020130); ans_temp[ans_id*36+31]+=Pmtrx[3]*(Q_011010001*PR_002000020000+Q_011010101*PR_002000020001+Q_011110001*PR_002000020010+Q_011110101*PR_002000020011+Q_111010001*PR_002000020100+Q_111010101*PR_002000020101+Q_111110001*PR_002000020110+Q_111110101*PR_002000020111+Q_211010001*PR_002000020200+Q_211010101*PR_002000020201+Q_211110001*PR_002000020210+Q_211110101*PR_002000020211); ans_temp[ans_id*36+31]+=Pmtrx[4]*(Q_010011001*PR_002000020000+Q_010011101*PR_002000020001+Q_010111001*PR_002000020010+Q_010111101*PR_002000020011+Q_010211001*PR_002000020020+Q_010211101*PR_002000020021+Q_110011001*PR_002000020100+Q_110011101*PR_002000020101+Q_110111001*PR_002000020110+Q_110111101*PR_002000020111+Q_110211001*PR_002000020120+Q_110211101*PR_002000020121); ans_temp[ans_id*36+31]+=Pmtrx[5]*(Q_010010002*PR_002000020000+Q_010010102*PR_002000020001+Q_010010202*PR_002000020002+Q_010110002*PR_002000020010+Q_010110102*PR_002000020011+Q_010110202*PR_002000020012+Q_110010002*PR_002000020100+Q_110010102*PR_002000020101+Q_110010202*PR_002000020102+Q_110110002*PR_002000020110+Q_110110102*PR_002000020111+Q_110110202*PR_002000020112); ans_temp[ans_id*36+32]+=Pmtrx[0]*(Q_002020000*PR_002000020000+Q_002120000*PR_002000020010+Q_002220000*PR_002000020020+Q_102020000*PR_002000020100+Q_102120000*PR_002000020110+Q_102220000*PR_002000020120+Q_202020000*PR_002000020200+Q_202120000*PR_002000020210+Q_202220000*PR_002000020220); ans_temp[ans_id*36+32]+=Pmtrx[1]*(Q_001021000*PR_002000020000+Q_001121000*PR_002000020010+Q_001221000*PR_002000020020+Q_001321000*PR_002000020030+Q_101021000*PR_002000020100+Q_101121000*PR_002000020110+Q_101221000*PR_002000020120+Q_101321000*PR_002000020130); ans_temp[ans_id*36+32]+=Pmtrx[2]*(Q_000022000*PR_002000020000+Q_000122000*PR_002000020010+Q_000222000*PR_002000020020+Q_000322000*PR_002000020030+Q_000422000*PR_002000020040); ans_temp[ans_id*36+32]+=Pmtrx[3]*(Q_001020001*PR_002000020000+Q_001020101*PR_002000020001+Q_001120001*PR_002000020010+Q_001120101*PR_002000020011+Q_001220001*PR_002000020020+Q_001220101*PR_002000020021+Q_101020001*PR_002000020100+Q_101020101*PR_002000020101+Q_101120001*PR_002000020110+Q_101120101*PR_002000020111+Q_101220001*PR_002000020120+Q_101220101*PR_002000020121); ans_temp[ans_id*36+32]+=Pmtrx[4]*(Q_000021001*PR_002000020000+Q_000021101*PR_002000020001+Q_000121001*PR_002000020010+Q_000121101*PR_002000020011+Q_000221001*PR_002000020020+Q_000221101*PR_002000020021+Q_000321001*PR_002000020030+Q_000321101*PR_002000020031); ans_temp[ans_id*36+32]+=Pmtrx[5]*(Q_000020002*PR_002000020000+Q_000020102*PR_002000020001+Q_000020202*PR_002000020002+Q_000120002*PR_002000020010+Q_000120102*PR_002000020011+Q_000120202*PR_002000020012+Q_000220002*PR_002000020020+Q_000220102*PR_002000020021+Q_000220202*PR_002000020022); ans_temp[ans_id*36+33]+=Pmtrx[0]*(Q_012000010*PR_002000020000+Q_012000110*PR_002000020001+Q_112000010*PR_002000020100+Q_112000110*PR_002000020101+Q_212000010*PR_002000020200+Q_212000110*PR_002000020201+Q_312000010*PR_002000020300+Q_312000110*PR_002000020301); ans_temp[ans_id*36+33]+=Pmtrx[1]*(Q_011001010*PR_002000020000+Q_011001110*PR_002000020001+Q_011101010*PR_002000020010+Q_011101110*PR_002000020011+Q_111001010*PR_002000020100+Q_111001110*PR_002000020101+Q_111101010*PR_002000020110+Q_111101110*PR_002000020111+Q_211001010*PR_002000020200+Q_211001110*PR_002000020201+Q_211101010*PR_002000020210+Q_211101110*PR_002000020211); ans_temp[ans_id*36+33]+=Pmtrx[2]*(Q_010002010*PR_002000020000+Q_010002110*PR_002000020001+Q_010102010*PR_002000020010+Q_010102110*PR_002000020011+Q_010202010*PR_002000020020+Q_010202110*PR_002000020021+Q_110002010*PR_002000020100+Q_110002110*PR_002000020101+Q_110102010*PR_002000020110+Q_110102110*PR_002000020111+Q_110202010*PR_002000020120+Q_110202110*PR_002000020121); ans_temp[ans_id*36+33]+=Pmtrx[3]*(Q_011000011*PR_002000020000+Q_011000111*PR_002000020001+Q_011000211*PR_002000020002+Q_111000011*PR_002000020100+Q_111000111*PR_002000020101+Q_111000211*PR_002000020102+Q_211000011*PR_002000020200+Q_211000111*PR_002000020201+Q_211000211*PR_002000020202); ans_temp[ans_id*36+33]+=Pmtrx[4]*(Q_010001011*PR_002000020000+Q_010001111*PR_002000020001+Q_010001211*PR_002000020002+Q_010101011*PR_002000020010+Q_010101111*PR_002000020011+Q_010101211*PR_002000020012+Q_110001011*PR_002000020100+Q_110001111*PR_002000020101+Q_110001211*PR_002000020102+Q_110101011*PR_002000020110+Q_110101111*PR_002000020111+Q_110101211*PR_002000020112); ans_temp[ans_id*36+33]+=Pmtrx[5]*(Q_010000012*PR_002000020000+Q_010000112*PR_002000020001+Q_010000212*PR_002000020002+Q_010000312*PR_002000020003+Q_110000012*PR_002000020100+Q_110000112*PR_002000020101+Q_110000212*PR_002000020102+Q_110000312*PR_002000020103); ans_temp[ans_id*36+34]+=Pmtrx[0]*(Q_002010010*PR_002000020000+Q_002010110*PR_002000020001+Q_002110010*PR_002000020010+Q_002110110*PR_002000020011+Q_102010010*PR_002000020100+Q_102010110*PR_002000020101+Q_102110010*PR_002000020110+Q_102110110*PR_002000020111+Q_202010010*PR_002000020200+Q_202010110*PR_002000020201+Q_202110010*PR_002000020210+Q_202110110*PR_002000020211); ans_temp[ans_id*36+34]+=Pmtrx[1]*(Q_001011010*PR_002000020000+Q_001011110*PR_002000020001+Q_001111010*PR_002000020010+Q_001111110*PR_002000020011+Q_001211010*PR_002000020020+Q_001211110*PR_002000020021+Q_101011010*PR_002000020100+Q_101011110*PR_002000020101+Q_101111010*PR_002000020110+Q_101111110*PR_002000020111+Q_101211010*PR_002000020120+Q_101211110*PR_002000020121); ans_temp[ans_id*36+34]+=Pmtrx[2]*(Q_000012010*PR_002000020000+Q_000012110*PR_002000020001+Q_000112010*PR_002000020010+Q_000112110*PR_002000020011+Q_000212010*PR_002000020020+Q_000212110*PR_002000020021+Q_000312010*PR_002000020030+Q_000312110*PR_002000020031); ans_temp[ans_id*36+34]+=Pmtrx[3]*(Q_001010011*PR_002000020000+Q_001010111*PR_002000020001+Q_001010211*PR_002000020002+Q_001110011*PR_002000020010+Q_001110111*PR_002000020011+Q_001110211*PR_002000020012+Q_101010011*PR_002000020100+Q_101010111*PR_002000020101+Q_101010211*PR_002000020102+Q_101110011*PR_002000020110+Q_101110111*PR_002000020111+Q_101110211*PR_002000020112); ans_temp[ans_id*36+34]+=Pmtrx[4]*(Q_000011011*PR_002000020000+Q_000011111*PR_002000020001+Q_000011211*PR_002000020002+Q_000111011*PR_002000020010+Q_000111111*PR_002000020011+Q_000111211*PR_002000020012+Q_000211011*PR_002000020020+Q_000211111*PR_002000020021+Q_000211211*PR_002000020022); ans_temp[ans_id*36+34]+=Pmtrx[5]*(Q_000010012*PR_002000020000+Q_000010112*PR_002000020001+Q_000010212*PR_002000020002+Q_000010312*PR_002000020003+Q_000110012*PR_002000020010+Q_000110112*PR_002000020011+Q_000110212*PR_002000020012+Q_000110312*PR_002000020013); ans_temp[ans_id*36+35]+=Pmtrx[0]*(Q_002000020*PR_002000020000+Q_002000120*PR_002000020001+Q_002000220*PR_002000020002+Q_102000020*PR_002000020100+Q_102000120*PR_002000020101+Q_102000220*PR_002000020102+Q_202000020*PR_002000020200+Q_202000120*PR_002000020201+Q_202000220*PR_002000020202); ans_temp[ans_id*36+35]+=Pmtrx[1]*(Q_001001020*PR_002000020000+Q_001001120*PR_002000020001+Q_001001220*PR_002000020002+Q_001101020*PR_002000020010+Q_001101120*PR_002000020011+Q_001101220*PR_002000020012+Q_101001020*PR_002000020100+Q_101001120*PR_002000020101+Q_101001220*PR_002000020102+Q_101101020*PR_002000020110+Q_101101120*PR_002000020111+Q_101101220*PR_002000020112); ans_temp[ans_id*36+35]+=Pmtrx[2]*(Q_000002020*PR_002000020000+Q_000002120*PR_002000020001+Q_000002220*PR_002000020002+Q_000102020*PR_002000020010+Q_000102120*PR_002000020011+Q_000102220*PR_002000020012+Q_000202020*PR_002000020020+Q_000202120*PR_002000020021+Q_000202220*PR_002000020022); ans_temp[ans_id*36+35]+=Pmtrx[3]*(Q_001000021*PR_002000020000+Q_001000121*PR_002000020001+Q_001000221*PR_002000020002+Q_001000321*PR_002000020003+Q_101000021*PR_002000020100+Q_101000121*PR_002000020101+Q_101000221*PR_002000020102+Q_101000321*PR_002000020103); ans_temp[ans_id*36+35]+=Pmtrx[4]*(Q_000001021*PR_002000020000+Q_000001121*PR_002000020001+Q_000001221*PR_002000020002+Q_000001321*PR_002000020003+Q_000101021*PR_002000020010+Q_000101121*PR_002000020011+Q_000101221*PR_002000020012+Q_000101321*PR_002000020013); ans_temp[ans_id*36+35]+=Pmtrx[5]*(Q_000000022*PR_002000020000+Q_000000122*PR_002000020001+Q_000000222*PR_002000020002+Q_000000322*PR_002000020003+Q_000000422*PR_002000020004); ans_temp[ans_id*36+30]+=Pmtrx[6]*(Q_022000000*PR_001001020000+Q_122000000*PR_001001020100+Q_222000000*PR_001001020200+Q_322000000*PR_001001020300+Q_422000000*PR_001001020400); ans_temp[ans_id*36+30]+=Pmtrx[7]*(Q_021001000*PR_001001020000+Q_021101000*PR_001001020010+Q_121001000*PR_001001020100+Q_121101000*PR_001001020110+Q_221001000*PR_001001020200+Q_221101000*PR_001001020210+Q_321001000*PR_001001020300+Q_321101000*PR_001001020310); ans_temp[ans_id*36+30]+=Pmtrx[8]*(Q_020002000*PR_001001020000+Q_020102000*PR_001001020010+Q_020202000*PR_001001020020+Q_120002000*PR_001001020100+Q_120102000*PR_001001020110+Q_120202000*PR_001001020120+Q_220002000*PR_001001020200+Q_220102000*PR_001001020210+Q_220202000*PR_001001020220); ans_temp[ans_id*36+30]+=Pmtrx[9]*(Q_021000001*PR_001001020000+Q_021000101*PR_001001020001+Q_121000001*PR_001001020100+Q_121000101*PR_001001020101+Q_221000001*PR_001001020200+Q_221000101*PR_001001020201+Q_321000001*PR_001001020300+Q_321000101*PR_001001020301); ans_temp[ans_id*36+30]+=Pmtrx[10]*(Q_020001001*PR_001001020000+Q_020001101*PR_001001020001+Q_020101001*PR_001001020010+Q_020101101*PR_001001020011+Q_120001001*PR_001001020100+Q_120001101*PR_001001020101+Q_120101001*PR_001001020110+Q_120101101*PR_001001020111+Q_220001001*PR_001001020200+Q_220001101*PR_001001020201+Q_220101001*PR_001001020210+Q_220101101*PR_001001020211); ans_temp[ans_id*36+30]+=Pmtrx[11]*(Q_020000002*PR_001001020000+Q_020000102*PR_001001020001+Q_020000202*PR_001001020002+Q_120000002*PR_001001020100+Q_120000102*PR_001001020101+Q_120000202*PR_001001020102+Q_220000002*PR_001001020200+Q_220000102*PR_001001020201+Q_220000202*PR_001001020202); ans_temp[ans_id*36+31]+=Pmtrx[6]*(Q_012010000*PR_001001020000+Q_012110000*PR_001001020010+Q_112010000*PR_001001020100+Q_112110000*PR_001001020110+Q_212010000*PR_001001020200+Q_212110000*PR_001001020210+Q_312010000*PR_001001020300+Q_312110000*PR_001001020310); ans_temp[ans_id*36+31]+=Pmtrx[7]*(Q_011011000*PR_001001020000+Q_011111000*PR_001001020010+Q_011211000*PR_001001020020+Q_111011000*PR_001001020100+Q_111111000*PR_001001020110+Q_111211000*PR_001001020120+Q_211011000*PR_001001020200+Q_211111000*PR_001001020210+Q_211211000*PR_001001020220); ans_temp[ans_id*36+31]+=Pmtrx[8]*(Q_010012000*PR_001001020000+Q_010112000*PR_001001020010+Q_010212000*PR_001001020020+Q_010312000*PR_001001020030+Q_110012000*PR_001001020100+Q_110112000*PR_001001020110+Q_110212000*PR_001001020120+Q_110312000*PR_001001020130); ans_temp[ans_id*36+31]+=Pmtrx[9]*(Q_011010001*PR_001001020000+Q_011010101*PR_001001020001+Q_011110001*PR_001001020010+Q_011110101*PR_001001020011+Q_111010001*PR_001001020100+Q_111010101*PR_001001020101+Q_111110001*PR_001001020110+Q_111110101*PR_001001020111+Q_211010001*PR_001001020200+Q_211010101*PR_001001020201+Q_211110001*PR_001001020210+Q_211110101*PR_001001020211); ans_temp[ans_id*36+31]+=Pmtrx[10]*(Q_010011001*PR_001001020000+Q_010011101*PR_001001020001+Q_010111001*PR_001001020010+Q_010111101*PR_001001020011+Q_010211001*PR_001001020020+Q_010211101*PR_001001020021+Q_110011001*PR_001001020100+Q_110011101*PR_001001020101+Q_110111001*PR_001001020110+Q_110111101*PR_001001020111+Q_110211001*PR_001001020120+Q_110211101*PR_001001020121); ans_temp[ans_id*36+31]+=Pmtrx[11]*(Q_010010002*PR_001001020000+Q_010010102*PR_001001020001+Q_010010202*PR_001001020002+Q_010110002*PR_001001020010+Q_010110102*PR_001001020011+Q_010110202*PR_001001020012+Q_110010002*PR_001001020100+Q_110010102*PR_001001020101+Q_110010202*PR_001001020102+Q_110110002*PR_001001020110+Q_110110102*PR_001001020111+Q_110110202*PR_001001020112); ans_temp[ans_id*36+32]+=Pmtrx[6]*(Q_002020000*PR_001001020000+Q_002120000*PR_001001020010+Q_002220000*PR_001001020020+Q_102020000*PR_001001020100+Q_102120000*PR_001001020110+Q_102220000*PR_001001020120+Q_202020000*PR_001001020200+Q_202120000*PR_001001020210+Q_202220000*PR_001001020220); ans_temp[ans_id*36+32]+=Pmtrx[7]*(Q_001021000*PR_001001020000+Q_001121000*PR_001001020010+Q_001221000*PR_001001020020+Q_001321000*PR_001001020030+Q_101021000*PR_001001020100+Q_101121000*PR_001001020110+Q_101221000*PR_001001020120+Q_101321000*PR_001001020130); ans_temp[ans_id*36+32]+=Pmtrx[8]*(Q_000022000*PR_001001020000+Q_000122000*PR_001001020010+Q_000222000*PR_001001020020+Q_000322000*PR_001001020030+Q_000422000*PR_001001020040); ans_temp[ans_id*36+32]+=Pmtrx[9]*(Q_001020001*PR_001001020000+Q_001020101*PR_001001020001+Q_001120001*PR_001001020010+Q_001120101*PR_001001020011+Q_001220001*PR_001001020020+Q_001220101*PR_001001020021+Q_101020001*PR_001001020100+Q_101020101*PR_001001020101+Q_101120001*PR_001001020110+Q_101120101*PR_001001020111+Q_101220001*PR_001001020120+Q_101220101*PR_001001020121); ans_temp[ans_id*36+32]+=Pmtrx[10]*(Q_000021001*PR_001001020000+Q_000021101*PR_001001020001+Q_000121001*PR_001001020010+Q_000121101*PR_001001020011+Q_000221001*PR_001001020020+Q_000221101*PR_001001020021+Q_000321001*PR_001001020030+Q_000321101*PR_001001020031); ans_temp[ans_id*36+32]+=Pmtrx[11]*(Q_000020002*PR_001001020000+Q_000020102*PR_001001020001+Q_000020202*PR_001001020002+Q_000120002*PR_001001020010+Q_000120102*PR_001001020011+Q_000120202*PR_001001020012+Q_000220002*PR_001001020020+Q_000220102*PR_001001020021+Q_000220202*PR_001001020022); ans_temp[ans_id*36+33]+=Pmtrx[6]*(Q_012000010*PR_001001020000+Q_012000110*PR_001001020001+Q_112000010*PR_001001020100+Q_112000110*PR_001001020101+Q_212000010*PR_001001020200+Q_212000110*PR_001001020201+Q_312000010*PR_001001020300+Q_312000110*PR_001001020301); ans_temp[ans_id*36+33]+=Pmtrx[7]*(Q_011001010*PR_001001020000+Q_011001110*PR_001001020001+Q_011101010*PR_001001020010+Q_011101110*PR_001001020011+Q_111001010*PR_001001020100+Q_111001110*PR_001001020101+Q_111101010*PR_001001020110+Q_111101110*PR_001001020111+Q_211001010*PR_001001020200+Q_211001110*PR_001001020201+Q_211101010*PR_001001020210+Q_211101110*PR_001001020211); ans_temp[ans_id*36+33]+=Pmtrx[8]*(Q_010002010*PR_001001020000+Q_010002110*PR_001001020001+Q_010102010*PR_001001020010+Q_010102110*PR_001001020011+Q_010202010*PR_001001020020+Q_010202110*PR_001001020021+Q_110002010*PR_001001020100+Q_110002110*PR_001001020101+Q_110102010*PR_001001020110+Q_110102110*PR_001001020111+Q_110202010*PR_001001020120+Q_110202110*PR_001001020121); ans_temp[ans_id*36+33]+=Pmtrx[9]*(Q_011000011*PR_001001020000+Q_011000111*PR_001001020001+Q_011000211*PR_001001020002+Q_111000011*PR_001001020100+Q_111000111*PR_001001020101+Q_111000211*PR_001001020102+Q_211000011*PR_001001020200+Q_211000111*PR_001001020201+Q_211000211*PR_001001020202); ans_temp[ans_id*36+33]+=Pmtrx[10]*(Q_010001011*PR_001001020000+Q_010001111*PR_001001020001+Q_010001211*PR_001001020002+Q_010101011*PR_001001020010+Q_010101111*PR_001001020011+Q_010101211*PR_001001020012+Q_110001011*PR_001001020100+Q_110001111*PR_001001020101+Q_110001211*PR_001001020102+Q_110101011*PR_001001020110+Q_110101111*PR_001001020111+Q_110101211*PR_001001020112); ans_temp[ans_id*36+33]+=Pmtrx[11]*(Q_010000012*PR_001001020000+Q_010000112*PR_001001020001+Q_010000212*PR_001001020002+Q_010000312*PR_001001020003+Q_110000012*PR_001001020100+Q_110000112*PR_001001020101+Q_110000212*PR_001001020102+Q_110000312*PR_001001020103); ans_temp[ans_id*36+34]+=Pmtrx[6]*(Q_002010010*PR_001001020000+Q_002010110*PR_001001020001+Q_002110010*PR_001001020010+Q_002110110*PR_001001020011+Q_102010010*PR_001001020100+Q_102010110*PR_001001020101+Q_102110010*PR_001001020110+Q_102110110*PR_001001020111+Q_202010010*PR_001001020200+Q_202010110*PR_001001020201+Q_202110010*PR_001001020210+Q_202110110*PR_001001020211); ans_temp[ans_id*36+34]+=Pmtrx[7]*(Q_001011010*PR_001001020000+Q_001011110*PR_001001020001+Q_001111010*PR_001001020010+Q_001111110*PR_001001020011+Q_001211010*PR_001001020020+Q_001211110*PR_001001020021+Q_101011010*PR_001001020100+Q_101011110*PR_001001020101+Q_101111010*PR_001001020110+Q_101111110*PR_001001020111+Q_101211010*PR_001001020120+Q_101211110*PR_001001020121); ans_temp[ans_id*36+34]+=Pmtrx[8]*(Q_000012010*PR_001001020000+Q_000012110*PR_001001020001+Q_000112010*PR_001001020010+Q_000112110*PR_001001020011+Q_000212010*PR_001001020020+Q_000212110*PR_001001020021+Q_000312010*PR_001001020030+Q_000312110*PR_001001020031); ans_temp[ans_id*36+34]+=Pmtrx[9]*(Q_001010011*PR_001001020000+Q_001010111*PR_001001020001+Q_001010211*PR_001001020002+Q_001110011*PR_001001020010+Q_001110111*PR_001001020011+Q_001110211*PR_001001020012+Q_101010011*PR_001001020100+Q_101010111*PR_001001020101+Q_101010211*PR_001001020102+Q_101110011*PR_001001020110+Q_101110111*PR_001001020111+Q_101110211*PR_001001020112); ans_temp[ans_id*36+34]+=Pmtrx[10]*(Q_000011011*PR_001001020000+Q_000011111*PR_001001020001+Q_000011211*PR_001001020002+Q_000111011*PR_001001020010+Q_000111111*PR_001001020011+Q_000111211*PR_001001020012+Q_000211011*PR_001001020020+Q_000211111*PR_001001020021+Q_000211211*PR_001001020022); ans_temp[ans_id*36+34]+=Pmtrx[11]*(Q_000010012*PR_001001020000+Q_000010112*PR_001001020001+Q_000010212*PR_001001020002+Q_000010312*PR_001001020003+Q_000110012*PR_001001020010+Q_000110112*PR_001001020011+Q_000110212*PR_001001020012+Q_000110312*PR_001001020013); ans_temp[ans_id*36+35]+=Pmtrx[6]*(Q_002000020*PR_001001020000+Q_002000120*PR_001001020001+Q_002000220*PR_001001020002+Q_102000020*PR_001001020100+Q_102000120*PR_001001020101+Q_102000220*PR_001001020102+Q_202000020*PR_001001020200+Q_202000120*PR_001001020201+Q_202000220*PR_001001020202); ans_temp[ans_id*36+35]+=Pmtrx[7]*(Q_001001020*PR_001001020000+Q_001001120*PR_001001020001+Q_001001220*PR_001001020002+Q_001101020*PR_001001020010+Q_001101120*PR_001001020011+Q_001101220*PR_001001020012+Q_101001020*PR_001001020100+Q_101001120*PR_001001020101+Q_101001220*PR_001001020102+Q_101101020*PR_001001020110+Q_101101120*PR_001001020111+Q_101101220*PR_001001020112); ans_temp[ans_id*36+35]+=Pmtrx[8]*(Q_000002020*PR_001001020000+Q_000002120*PR_001001020001+Q_000002220*PR_001001020002+Q_000102020*PR_001001020010+Q_000102120*PR_001001020011+Q_000102220*PR_001001020012+Q_000202020*PR_001001020020+Q_000202120*PR_001001020021+Q_000202220*PR_001001020022); ans_temp[ans_id*36+35]+=Pmtrx[9]*(Q_001000021*PR_001001020000+Q_001000121*PR_001001020001+Q_001000221*PR_001001020002+Q_001000321*PR_001001020003+Q_101000021*PR_001001020100+Q_101000121*PR_001001020101+Q_101000221*PR_001001020102+Q_101000321*PR_001001020103); ans_temp[ans_id*36+35]+=Pmtrx[10]*(Q_000001021*PR_001001020000+Q_000001121*PR_001001020001+Q_000001221*PR_001001020002+Q_000001321*PR_001001020003+Q_000101021*PR_001001020010+Q_000101121*PR_001001020011+Q_000101221*PR_001001020012+Q_000101321*PR_001001020013); ans_temp[ans_id*36+35]+=Pmtrx[11]*(Q_000000022*PR_001001020000+Q_000000122*PR_001001020001+Q_000000222*PR_001001020002+Q_000000322*PR_001001020003+Q_000000422*PR_001001020004); ans_temp[ans_id*36+30]+=Pmtrx[12]*(Q_022000000*PR_000002020000+Q_122000000*PR_000002020100+Q_222000000*PR_000002020200+Q_322000000*PR_000002020300+Q_422000000*PR_000002020400); ans_temp[ans_id*36+30]+=Pmtrx[13]*(Q_021001000*PR_000002020000+Q_021101000*PR_000002020010+Q_121001000*PR_000002020100+Q_121101000*PR_000002020110+Q_221001000*PR_000002020200+Q_221101000*PR_000002020210+Q_321001000*PR_000002020300+Q_321101000*PR_000002020310); ans_temp[ans_id*36+30]+=Pmtrx[14]*(Q_020002000*PR_000002020000+Q_020102000*PR_000002020010+Q_020202000*PR_000002020020+Q_120002000*PR_000002020100+Q_120102000*PR_000002020110+Q_120202000*PR_000002020120+Q_220002000*PR_000002020200+Q_220102000*PR_000002020210+Q_220202000*PR_000002020220); ans_temp[ans_id*36+30]+=Pmtrx[15]*(Q_021000001*PR_000002020000+Q_021000101*PR_000002020001+Q_121000001*PR_000002020100+Q_121000101*PR_000002020101+Q_221000001*PR_000002020200+Q_221000101*PR_000002020201+Q_321000001*PR_000002020300+Q_321000101*PR_000002020301); ans_temp[ans_id*36+30]+=Pmtrx[16]*(Q_020001001*PR_000002020000+Q_020001101*PR_000002020001+Q_020101001*PR_000002020010+Q_020101101*PR_000002020011+Q_120001001*PR_000002020100+Q_120001101*PR_000002020101+Q_120101001*PR_000002020110+Q_120101101*PR_000002020111+Q_220001001*PR_000002020200+Q_220001101*PR_000002020201+Q_220101001*PR_000002020210+Q_220101101*PR_000002020211); ans_temp[ans_id*36+30]+=Pmtrx[17]*(Q_020000002*PR_000002020000+Q_020000102*PR_000002020001+Q_020000202*PR_000002020002+Q_120000002*PR_000002020100+Q_120000102*PR_000002020101+Q_120000202*PR_000002020102+Q_220000002*PR_000002020200+Q_220000102*PR_000002020201+Q_220000202*PR_000002020202); ans_temp[ans_id*36+31]+=Pmtrx[12]*(Q_012010000*PR_000002020000+Q_012110000*PR_000002020010+Q_112010000*PR_000002020100+Q_112110000*PR_000002020110+Q_212010000*PR_000002020200+Q_212110000*PR_000002020210+Q_312010000*PR_000002020300+Q_312110000*PR_000002020310); ans_temp[ans_id*36+31]+=Pmtrx[13]*(Q_011011000*PR_000002020000+Q_011111000*PR_000002020010+Q_011211000*PR_000002020020+Q_111011000*PR_000002020100+Q_111111000*PR_000002020110+Q_111211000*PR_000002020120+Q_211011000*PR_000002020200+Q_211111000*PR_000002020210+Q_211211000*PR_000002020220); ans_temp[ans_id*36+31]+=Pmtrx[14]*(Q_010012000*PR_000002020000+Q_010112000*PR_000002020010+Q_010212000*PR_000002020020+Q_010312000*PR_000002020030+Q_110012000*PR_000002020100+Q_110112000*PR_000002020110+Q_110212000*PR_000002020120+Q_110312000*PR_000002020130); ans_temp[ans_id*36+31]+=Pmtrx[15]*(Q_011010001*PR_000002020000+Q_011010101*PR_000002020001+Q_011110001*PR_000002020010+Q_011110101*PR_000002020011+Q_111010001*PR_000002020100+Q_111010101*PR_000002020101+Q_111110001*PR_000002020110+Q_111110101*PR_000002020111+Q_211010001*PR_000002020200+Q_211010101*PR_000002020201+Q_211110001*PR_000002020210+Q_211110101*PR_000002020211); ans_temp[ans_id*36+31]+=Pmtrx[16]*(Q_010011001*PR_000002020000+Q_010011101*PR_000002020001+Q_010111001*PR_000002020010+Q_010111101*PR_000002020011+Q_010211001*PR_000002020020+Q_010211101*PR_000002020021+Q_110011001*PR_000002020100+Q_110011101*PR_000002020101+Q_110111001*PR_000002020110+Q_110111101*PR_000002020111+Q_110211001*PR_000002020120+Q_110211101*PR_000002020121); ans_temp[ans_id*36+31]+=Pmtrx[17]*(Q_010010002*PR_000002020000+Q_010010102*PR_000002020001+Q_010010202*PR_000002020002+Q_010110002*PR_000002020010+Q_010110102*PR_000002020011+Q_010110202*PR_000002020012+Q_110010002*PR_000002020100+Q_110010102*PR_000002020101+Q_110010202*PR_000002020102+Q_110110002*PR_000002020110+Q_110110102*PR_000002020111+Q_110110202*PR_000002020112); ans_temp[ans_id*36+32]+=Pmtrx[12]*(Q_002020000*PR_000002020000+Q_002120000*PR_000002020010+Q_002220000*PR_000002020020+Q_102020000*PR_000002020100+Q_102120000*PR_000002020110+Q_102220000*PR_000002020120+Q_202020000*PR_000002020200+Q_202120000*PR_000002020210+Q_202220000*PR_000002020220); ans_temp[ans_id*36+32]+=Pmtrx[13]*(Q_001021000*PR_000002020000+Q_001121000*PR_000002020010+Q_001221000*PR_000002020020+Q_001321000*PR_000002020030+Q_101021000*PR_000002020100+Q_101121000*PR_000002020110+Q_101221000*PR_000002020120+Q_101321000*PR_000002020130); ans_temp[ans_id*36+32]+=Pmtrx[14]*(Q_000022000*PR_000002020000+Q_000122000*PR_000002020010+Q_000222000*PR_000002020020+Q_000322000*PR_000002020030+Q_000422000*PR_000002020040); ans_temp[ans_id*36+32]+=Pmtrx[15]*(Q_001020001*PR_000002020000+Q_001020101*PR_000002020001+Q_001120001*PR_000002020010+Q_001120101*PR_000002020011+Q_001220001*PR_000002020020+Q_001220101*PR_000002020021+Q_101020001*PR_000002020100+Q_101020101*PR_000002020101+Q_101120001*PR_000002020110+Q_101120101*PR_000002020111+Q_101220001*PR_000002020120+Q_101220101*PR_000002020121); ans_temp[ans_id*36+32]+=Pmtrx[16]*(Q_000021001*PR_000002020000+Q_000021101*PR_000002020001+Q_000121001*PR_000002020010+Q_000121101*PR_000002020011+Q_000221001*PR_000002020020+Q_000221101*PR_000002020021+Q_000321001*PR_000002020030+Q_000321101*PR_000002020031); ans_temp[ans_id*36+32]+=Pmtrx[17]*(Q_000020002*PR_000002020000+Q_000020102*PR_000002020001+Q_000020202*PR_000002020002+Q_000120002*PR_000002020010+Q_000120102*PR_000002020011+Q_000120202*PR_000002020012+Q_000220002*PR_000002020020+Q_000220102*PR_000002020021+Q_000220202*PR_000002020022); ans_temp[ans_id*36+33]+=Pmtrx[12]*(Q_012000010*PR_000002020000+Q_012000110*PR_000002020001+Q_112000010*PR_000002020100+Q_112000110*PR_000002020101+Q_212000010*PR_000002020200+Q_212000110*PR_000002020201+Q_312000010*PR_000002020300+Q_312000110*PR_000002020301); ans_temp[ans_id*36+33]+=Pmtrx[13]*(Q_011001010*PR_000002020000+Q_011001110*PR_000002020001+Q_011101010*PR_000002020010+Q_011101110*PR_000002020011+Q_111001010*PR_000002020100+Q_111001110*PR_000002020101+Q_111101010*PR_000002020110+Q_111101110*PR_000002020111+Q_211001010*PR_000002020200+Q_211001110*PR_000002020201+Q_211101010*PR_000002020210+Q_211101110*PR_000002020211); ans_temp[ans_id*36+33]+=Pmtrx[14]*(Q_010002010*PR_000002020000+Q_010002110*PR_000002020001+Q_010102010*PR_000002020010+Q_010102110*PR_000002020011+Q_010202010*PR_000002020020+Q_010202110*PR_000002020021+Q_110002010*PR_000002020100+Q_110002110*PR_000002020101+Q_110102010*PR_000002020110+Q_110102110*PR_000002020111+Q_110202010*PR_000002020120+Q_110202110*PR_000002020121); ans_temp[ans_id*36+33]+=Pmtrx[15]*(Q_011000011*PR_000002020000+Q_011000111*PR_000002020001+Q_011000211*PR_000002020002+Q_111000011*PR_000002020100+Q_111000111*PR_000002020101+Q_111000211*PR_000002020102+Q_211000011*PR_000002020200+Q_211000111*PR_000002020201+Q_211000211*PR_000002020202); ans_temp[ans_id*36+33]+=Pmtrx[16]*(Q_010001011*PR_000002020000+Q_010001111*PR_000002020001+Q_010001211*PR_000002020002+Q_010101011*PR_000002020010+Q_010101111*PR_000002020011+Q_010101211*PR_000002020012+Q_110001011*PR_000002020100+Q_110001111*PR_000002020101+Q_110001211*PR_000002020102+Q_110101011*PR_000002020110+Q_110101111*PR_000002020111+Q_110101211*PR_000002020112); ans_temp[ans_id*36+33]+=Pmtrx[17]*(Q_010000012*PR_000002020000+Q_010000112*PR_000002020001+Q_010000212*PR_000002020002+Q_010000312*PR_000002020003+Q_110000012*PR_000002020100+Q_110000112*PR_000002020101+Q_110000212*PR_000002020102+Q_110000312*PR_000002020103); ans_temp[ans_id*36+34]+=Pmtrx[12]*(Q_002010010*PR_000002020000+Q_002010110*PR_000002020001+Q_002110010*PR_000002020010+Q_002110110*PR_000002020011+Q_102010010*PR_000002020100+Q_102010110*PR_000002020101+Q_102110010*PR_000002020110+Q_102110110*PR_000002020111+Q_202010010*PR_000002020200+Q_202010110*PR_000002020201+Q_202110010*PR_000002020210+Q_202110110*PR_000002020211); ans_temp[ans_id*36+34]+=Pmtrx[13]*(Q_001011010*PR_000002020000+Q_001011110*PR_000002020001+Q_001111010*PR_000002020010+Q_001111110*PR_000002020011+Q_001211010*PR_000002020020+Q_001211110*PR_000002020021+Q_101011010*PR_000002020100+Q_101011110*PR_000002020101+Q_101111010*PR_000002020110+Q_101111110*PR_000002020111+Q_101211010*PR_000002020120+Q_101211110*PR_000002020121); ans_temp[ans_id*36+34]+=Pmtrx[14]*(Q_000012010*PR_000002020000+Q_000012110*PR_000002020001+Q_000112010*PR_000002020010+Q_000112110*PR_000002020011+Q_000212010*PR_000002020020+Q_000212110*PR_000002020021+Q_000312010*PR_000002020030+Q_000312110*PR_000002020031); ans_temp[ans_id*36+34]+=Pmtrx[15]*(Q_001010011*PR_000002020000+Q_001010111*PR_000002020001+Q_001010211*PR_000002020002+Q_001110011*PR_000002020010+Q_001110111*PR_000002020011+Q_001110211*PR_000002020012+Q_101010011*PR_000002020100+Q_101010111*PR_000002020101+Q_101010211*PR_000002020102+Q_101110011*PR_000002020110+Q_101110111*PR_000002020111+Q_101110211*PR_000002020112); ans_temp[ans_id*36+34]+=Pmtrx[16]*(Q_000011011*PR_000002020000+Q_000011111*PR_000002020001+Q_000011211*PR_000002020002+Q_000111011*PR_000002020010+Q_000111111*PR_000002020011+Q_000111211*PR_000002020012+Q_000211011*PR_000002020020+Q_000211111*PR_000002020021+Q_000211211*PR_000002020022); ans_temp[ans_id*36+34]+=Pmtrx[17]*(Q_000010012*PR_000002020000+Q_000010112*PR_000002020001+Q_000010212*PR_000002020002+Q_000010312*PR_000002020003+Q_000110012*PR_000002020010+Q_000110112*PR_000002020011+Q_000110212*PR_000002020012+Q_000110312*PR_000002020013); ans_temp[ans_id*36+35]+=Pmtrx[12]*(Q_002000020*PR_000002020000+Q_002000120*PR_000002020001+Q_002000220*PR_000002020002+Q_102000020*PR_000002020100+Q_102000120*PR_000002020101+Q_102000220*PR_000002020102+Q_202000020*PR_000002020200+Q_202000120*PR_000002020201+Q_202000220*PR_000002020202); ans_temp[ans_id*36+35]+=Pmtrx[13]*(Q_001001020*PR_000002020000+Q_001001120*PR_000002020001+Q_001001220*PR_000002020002+Q_001101020*PR_000002020010+Q_001101120*PR_000002020011+Q_001101220*PR_000002020012+Q_101001020*PR_000002020100+Q_101001120*PR_000002020101+Q_101001220*PR_000002020102+Q_101101020*PR_000002020110+Q_101101120*PR_000002020111+Q_101101220*PR_000002020112); ans_temp[ans_id*36+35]+=Pmtrx[14]*(Q_000002020*PR_000002020000+Q_000002120*PR_000002020001+Q_000002220*PR_000002020002+Q_000102020*PR_000002020010+Q_000102120*PR_000002020011+Q_000102220*PR_000002020012+Q_000202020*PR_000002020020+Q_000202120*PR_000002020021+Q_000202220*PR_000002020022); ans_temp[ans_id*36+35]+=Pmtrx[15]*(Q_001000021*PR_000002020000+Q_001000121*PR_000002020001+Q_001000221*PR_000002020002+Q_001000321*PR_000002020003+Q_101000021*PR_000002020100+Q_101000121*PR_000002020101+Q_101000221*PR_000002020102+Q_101000321*PR_000002020103); ans_temp[ans_id*36+35]+=Pmtrx[16]*(Q_000001021*PR_000002020000+Q_000001121*PR_000002020001+Q_000001221*PR_000002020002+Q_000001321*PR_000002020003+Q_000101021*PR_000002020010+Q_000101121*PR_000002020011+Q_000101221*PR_000002020012+Q_000101321*PR_000002020013); ans_temp[ans_id*36+35]+=Pmtrx[17]*(Q_000000022*PR_000002020000+Q_000000122*PR_000002020001+Q_000000222*PR_000002020002+Q_000000322*PR_000002020003+Q_000000422*PR_000002020004); ans_temp[ans_id*36+30]+=Pmtrx[18]*(Q_022000000*PR_001000021000+Q_122000000*PR_001000021100+Q_222000000*PR_001000021200+Q_322000000*PR_001000021300+Q_422000000*PR_001000021400); ans_temp[ans_id*36+30]+=Pmtrx[19]*(Q_021001000*PR_001000021000+Q_021101000*PR_001000021010+Q_121001000*PR_001000021100+Q_121101000*PR_001000021110+Q_221001000*PR_001000021200+Q_221101000*PR_001000021210+Q_321001000*PR_001000021300+Q_321101000*PR_001000021310); ans_temp[ans_id*36+30]+=Pmtrx[20]*(Q_020002000*PR_001000021000+Q_020102000*PR_001000021010+Q_020202000*PR_001000021020+Q_120002000*PR_001000021100+Q_120102000*PR_001000021110+Q_120202000*PR_001000021120+Q_220002000*PR_001000021200+Q_220102000*PR_001000021210+Q_220202000*PR_001000021220); ans_temp[ans_id*36+30]+=Pmtrx[21]*(Q_021000001*PR_001000021000+Q_021000101*PR_001000021001+Q_121000001*PR_001000021100+Q_121000101*PR_001000021101+Q_221000001*PR_001000021200+Q_221000101*PR_001000021201+Q_321000001*PR_001000021300+Q_321000101*PR_001000021301); ans_temp[ans_id*36+30]+=Pmtrx[22]*(Q_020001001*PR_001000021000+Q_020001101*PR_001000021001+Q_020101001*PR_001000021010+Q_020101101*PR_001000021011+Q_120001001*PR_001000021100+Q_120001101*PR_001000021101+Q_120101001*PR_001000021110+Q_120101101*PR_001000021111+Q_220001001*PR_001000021200+Q_220001101*PR_001000021201+Q_220101001*PR_001000021210+Q_220101101*PR_001000021211); ans_temp[ans_id*36+30]+=Pmtrx[23]*(Q_020000002*PR_001000021000+Q_020000102*PR_001000021001+Q_020000202*PR_001000021002+Q_120000002*PR_001000021100+Q_120000102*PR_001000021101+Q_120000202*PR_001000021102+Q_220000002*PR_001000021200+Q_220000102*PR_001000021201+Q_220000202*PR_001000021202); ans_temp[ans_id*36+31]+=Pmtrx[18]*(Q_012010000*PR_001000021000+Q_012110000*PR_001000021010+Q_112010000*PR_001000021100+Q_112110000*PR_001000021110+Q_212010000*PR_001000021200+Q_212110000*PR_001000021210+Q_312010000*PR_001000021300+Q_312110000*PR_001000021310); ans_temp[ans_id*36+31]+=Pmtrx[19]*(Q_011011000*PR_001000021000+Q_011111000*PR_001000021010+Q_011211000*PR_001000021020+Q_111011000*PR_001000021100+Q_111111000*PR_001000021110+Q_111211000*PR_001000021120+Q_211011000*PR_001000021200+Q_211111000*PR_001000021210+Q_211211000*PR_001000021220); ans_temp[ans_id*36+31]+=Pmtrx[20]*(Q_010012000*PR_001000021000+Q_010112000*PR_001000021010+Q_010212000*PR_001000021020+Q_010312000*PR_001000021030+Q_110012000*PR_001000021100+Q_110112000*PR_001000021110+Q_110212000*PR_001000021120+Q_110312000*PR_001000021130); ans_temp[ans_id*36+31]+=Pmtrx[21]*(Q_011010001*PR_001000021000+Q_011010101*PR_001000021001+Q_011110001*PR_001000021010+Q_011110101*PR_001000021011+Q_111010001*PR_001000021100+Q_111010101*PR_001000021101+Q_111110001*PR_001000021110+Q_111110101*PR_001000021111+Q_211010001*PR_001000021200+Q_211010101*PR_001000021201+Q_211110001*PR_001000021210+Q_211110101*PR_001000021211); ans_temp[ans_id*36+31]+=Pmtrx[22]*(Q_010011001*PR_001000021000+Q_010011101*PR_001000021001+Q_010111001*PR_001000021010+Q_010111101*PR_001000021011+Q_010211001*PR_001000021020+Q_010211101*PR_001000021021+Q_110011001*PR_001000021100+Q_110011101*PR_001000021101+Q_110111001*PR_001000021110+Q_110111101*PR_001000021111+Q_110211001*PR_001000021120+Q_110211101*PR_001000021121); ans_temp[ans_id*36+31]+=Pmtrx[23]*(Q_010010002*PR_001000021000+Q_010010102*PR_001000021001+Q_010010202*PR_001000021002+Q_010110002*PR_001000021010+Q_010110102*PR_001000021011+Q_010110202*PR_001000021012+Q_110010002*PR_001000021100+Q_110010102*PR_001000021101+Q_110010202*PR_001000021102+Q_110110002*PR_001000021110+Q_110110102*PR_001000021111+Q_110110202*PR_001000021112); ans_temp[ans_id*36+32]+=Pmtrx[18]*(Q_002020000*PR_001000021000+Q_002120000*PR_001000021010+Q_002220000*PR_001000021020+Q_102020000*PR_001000021100+Q_102120000*PR_001000021110+Q_102220000*PR_001000021120+Q_202020000*PR_001000021200+Q_202120000*PR_001000021210+Q_202220000*PR_001000021220); ans_temp[ans_id*36+32]+=Pmtrx[19]*(Q_001021000*PR_001000021000+Q_001121000*PR_001000021010+Q_001221000*PR_001000021020+Q_001321000*PR_001000021030+Q_101021000*PR_001000021100+Q_101121000*PR_001000021110+Q_101221000*PR_001000021120+Q_101321000*PR_001000021130); ans_temp[ans_id*36+32]+=Pmtrx[20]*(Q_000022000*PR_001000021000+Q_000122000*PR_001000021010+Q_000222000*PR_001000021020+Q_000322000*PR_001000021030+Q_000422000*PR_001000021040); ans_temp[ans_id*36+32]+=Pmtrx[21]*(Q_001020001*PR_001000021000+Q_001020101*PR_001000021001+Q_001120001*PR_001000021010+Q_001120101*PR_001000021011+Q_001220001*PR_001000021020+Q_001220101*PR_001000021021+Q_101020001*PR_001000021100+Q_101020101*PR_001000021101+Q_101120001*PR_001000021110+Q_101120101*PR_001000021111+Q_101220001*PR_001000021120+Q_101220101*PR_001000021121); ans_temp[ans_id*36+32]+=Pmtrx[22]*(Q_000021001*PR_001000021000+Q_000021101*PR_001000021001+Q_000121001*PR_001000021010+Q_000121101*PR_001000021011+Q_000221001*PR_001000021020+Q_000221101*PR_001000021021+Q_000321001*PR_001000021030+Q_000321101*PR_001000021031); ans_temp[ans_id*36+32]+=Pmtrx[23]*(Q_000020002*PR_001000021000+Q_000020102*PR_001000021001+Q_000020202*PR_001000021002+Q_000120002*PR_001000021010+Q_000120102*PR_001000021011+Q_000120202*PR_001000021012+Q_000220002*PR_001000021020+Q_000220102*PR_001000021021+Q_000220202*PR_001000021022); ans_temp[ans_id*36+33]+=Pmtrx[18]*(Q_012000010*PR_001000021000+Q_012000110*PR_001000021001+Q_112000010*PR_001000021100+Q_112000110*PR_001000021101+Q_212000010*PR_001000021200+Q_212000110*PR_001000021201+Q_312000010*PR_001000021300+Q_312000110*PR_001000021301); ans_temp[ans_id*36+33]+=Pmtrx[19]*(Q_011001010*PR_001000021000+Q_011001110*PR_001000021001+Q_011101010*PR_001000021010+Q_011101110*PR_001000021011+Q_111001010*PR_001000021100+Q_111001110*PR_001000021101+Q_111101010*PR_001000021110+Q_111101110*PR_001000021111+Q_211001010*PR_001000021200+Q_211001110*PR_001000021201+Q_211101010*PR_001000021210+Q_211101110*PR_001000021211); ans_temp[ans_id*36+33]+=Pmtrx[20]*(Q_010002010*PR_001000021000+Q_010002110*PR_001000021001+Q_010102010*PR_001000021010+Q_010102110*PR_001000021011+Q_010202010*PR_001000021020+Q_010202110*PR_001000021021+Q_110002010*PR_001000021100+Q_110002110*PR_001000021101+Q_110102010*PR_001000021110+Q_110102110*PR_001000021111+Q_110202010*PR_001000021120+Q_110202110*PR_001000021121); ans_temp[ans_id*36+33]+=Pmtrx[21]*(Q_011000011*PR_001000021000+Q_011000111*PR_001000021001+Q_011000211*PR_001000021002+Q_111000011*PR_001000021100+Q_111000111*PR_001000021101+Q_111000211*PR_001000021102+Q_211000011*PR_001000021200+Q_211000111*PR_001000021201+Q_211000211*PR_001000021202); ans_temp[ans_id*36+33]+=Pmtrx[22]*(Q_010001011*PR_001000021000+Q_010001111*PR_001000021001+Q_010001211*PR_001000021002+Q_010101011*PR_001000021010+Q_010101111*PR_001000021011+Q_010101211*PR_001000021012+Q_110001011*PR_001000021100+Q_110001111*PR_001000021101+Q_110001211*PR_001000021102+Q_110101011*PR_001000021110+Q_110101111*PR_001000021111+Q_110101211*PR_001000021112); ans_temp[ans_id*36+33]+=Pmtrx[23]*(Q_010000012*PR_001000021000+Q_010000112*PR_001000021001+Q_010000212*PR_001000021002+Q_010000312*PR_001000021003+Q_110000012*PR_001000021100+Q_110000112*PR_001000021101+Q_110000212*PR_001000021102+Q_110000312*PR_001000021103); ans_temp[ans_id*36+34]+=Pmtrx[18]*(Q_002010010*PR_001000021000+Q_002010110*PR_001000021001+Q_002110010*PR_001000021010+Q_002110110*PR_001000021011+Q_102010010*PR_001000021100+Q_102010110*PR_001000021101+Q_102110010*PR_001000021110+Q_102110110*PR_001000021111+Q_202010010*PR_001000021200+Q_202010110*PR_001000021201+Q_202110010*PR_001000021210+Q_202110110*PR_001000021211); ans_temp[ans_id*36+34]+=Pmtrx[19]*(Q_001011010*PR_001000021000+Q_001011110*PR_001000021001+Q_001111010*PR_001000021010+Q_001111110*PR_001000021011+Q_001211010*PR_001000021020+Q_001211110*PR_001000021021+Q_101011010*PR_001000021100+Q_101011110*PR_001000021101+Q_101111010*PR_001000021110+Q_101111110*PR_001000021111+Q_101211010*PR_001000021120+Q_101211110*PR_001000021121); ans_temp[ans_id*36+34]+=Pmtrx[20]*(Q_000012010*PR_001000021000+Q_000012110*PR_001000021001+Q_000112010*PR_001000021010+Q_000112110*PR_001000021011+Q_000212010*PR_001000021020+Q_000212110*PR_001000021021+Q_000312010*PR_001000021030+Q_000312110*PR_001000021031); ans_temp[ans_id*36+34]+=Pmtrx[21]*(Q_001010011*PR_001000021000+Q_001010111*PR_001000021001+Q_001010211*PR_001000021002+Q_001110011*PR_001000021010+Q_001110111*PR_001000021011+Q_001110211*PR_001000021012+Q_101010011*PR_001000021100+Q_101010111*PR_001000021101+Q_101010211*PR_001000021102+Q_101110011*PR_001000021110+Q_101110111*PR_001000021111+Q_101110211*PR_001000021112); ans_temp[ans_id*36+34]+=Pmtrx[22]*(Q_000011011*PR_001000021000+Q_000011111*PR_001000021001+Q_000011211*PR_001000021002+Q_000111011*PR_001000021010+Q_000111111*PR_001000021011+Q_000111211*PR_001000021012+Q_000211011*PR_001000021020+Q_000211111*PR_001000021021+Q_000211211*PR_001000021022); ans_temp[ans_id*36+34]+=Pmtrx[23]*(Q_000010012*PR_001000021000+Q_000010112*PR_001000021001+Q_000010212*PR_001000021002+Q_000010312*PR_001000021003+Q_000110012*PR_001000021010+Q_000110112*PR_001000021011+Q_000110212*PR_001000021012+Q_000110312*PR_001000021013); ans_temp[ans_id*36+35]+=Pmtrx[18]*(Q_002000020*PR_001000021000+Q_002000120*PR_001000021001+Q_002000220*PR_001000021002+Q_102000020*PR_001000021100+Q_102000120*PR_001000021101+Q_102000220*PR_001000021102+Q_202000020*PR_001000021200+Q_202000120*PR_001000021201+Q_202000220*PR_001000021202); ans_temp[ans_id*36+35]+=Pmtrx[19]*(Q_001001020*PR_001000021000+Q_001001120*PR_001000021001+Q_001001220*PR_001000021002+Q_001101020*PR_001000021010+Q_001101120*PR_001000021011+Q_001101220*PR_001000021012+Q_101001020*PR_001000021100+Q_101001120*PR_001000021101+Q_101001220*PR_001000021102+Q_101101020*PR_001000021110+Q_101101120*PR_001000021111+Q_101101220*PR_001000021112); ans_temp[ans_id*36+35]+=Pmtrx[20]*(Q_000002020*PR_001000021000+Q_000002120*PR_001000021001+Q_000002220*PR_001000021002+Q_000102020*PR_001000021010+Q_000102120*PR_001000021011+Q_000102220*PR_001000021012+Q_000202020*PR_001000021020+Q_000202120*PR_001000021021+Q_000202220*PR_001000021022); ans_temp[ans_id*36+35]+=Pmtrx[21]*(Q_001000021*PR_001000021000+Q_001000121*PR_001000021001+Q_001000221*PR_001000021002+Q_001000321*PR_001000021003+Q_101000021*PR_001000021100+Q_101000121*PR_001000021101+Q_101000221*PR_001000021102+Q_101000321*PR_001000021103); ans_temp[ans_id*36+35]+=Pmtrx[22]*(Q_000001021*PR_001000021000+Q_000001121*PR_001000021001+Q_000001221*PR_001000021002+Q_000001321*PR_001000021003+Q_000101021*PR_001000021010+Q_000101121*PR_001000021011+Q_000101221*PR_001000021012+Q_000101321*PR_001000021013); ans_temp[ans_id*36+35]+=Pmtrx[23]*(Q_000000022*PR_001000021000+Q_000000122*PR_001000021001+Q_000000222*PR_001000021002+Q_000000322*PR_001000021003+Q_000000422*PR_001000021004); ans_temp[ans_id*36+30]+=Pmtrx[24]*(Q_022000000*PR_000001021000+Q_122000000*PR_000001021100+Q_222000000*PR_000001021200+Q_322000000*PR_000001021300+Q_422000000*PR_000001021400); ans_temp[ans_id*36+30]+=Pmtrx[25]*(Q_021001000*PR_000001021000+Q_021101000*PR_000001021010+Q_121001000*PR_000001021100+Q_121101000*PR_000001021110+Q_221001000*PR_000001021200+Q_221101000*PR_000001021210+Q_321001000*PR_000001021300+Q_321101000*PR_000001021310); ans_temp[ans_id*36+30]+=Pmtrx[26]*(Q_020002000*PR_000001021000+Q_020102000*PR_000001021010+Q_020202000*PR_000001021020+Q_120002000*PR_000001021100+Q_120102000*PR_000001021110+Q_120202000*PR_000001021120+Q_220002000*PR_000001021200+Q_220102000*PR_000001021210+Q_220202000*PR_000001021220); ans_temp[ans_id*36+30]+=Pmtrx[27]*(Q_021000001*PR_000001021000+Q_021000101*PR_000001021001+Q_121000001*PR_000001021100+Q_121000101*PR_000001021101+Q_221000001*PR_000001021200+Q_221000101*PR_000001021201+Q_321000001*PR_000001021300+Q_321000101*PR_000001021301); ans_temp[ans_id*36+30]+=Pmtrx[28]*(Q_020001001*PR_000001021000+Q_020001101*PR_000001021001+Q_020101001*PR_000001021010+Q_020101101*PR_000001021011+Q_120001001*PR_000001021100+Q_120001101*PR_000001021101+Q_120101001*PR_000001021110+Q_120101101*PR_000001021111+Q_220001001*PR_000001021200+Q_220001101*PR_000001021201+Q_220101001*PR_000001021210+Q_220101101*PR_000001021211); ans_temp[ans_id*36+30]+=Pmtrx[29]*(Q_020000002*PR_000001021000+Q_020000102*PR_000001021001+Q_020000202*PR_000001021002+Q_120000002*PR_000001021100+Q_120000102*PR_000001021101+Q_120000202*PR_000001021102+Q_220000002*PR_000001021200+Q_220000102*PR_000001021201+Q_220000202*PR_000001021202); ans_temp[ans_id*36+31]+=Pmtrx[24]*(Q_012010000*PR_000001021000+Q_012110000*PR_000001021010+Q_112010000*PR_000001021100+Q_112110000*PR_000001021110+Q_212010000*PR_000001021200+Q_212110000*PR_000001021210+Q_312010000*PR_000001021300+Q_312110000*PR_000001021310); ans_temp[ans_id*36+31]+=Pmtrx[25]*(Q_011011000*PR_000001021000+Q_011111000*PR_000001021010+Q_011211000*PR_000001021020+Q_111011000*PR_000001021100+Q_111111000*PR_000001021110+Q_111211000*PR_000001021120+Q_211011000*PR_000001021200+Q_211111000*PR_000001021210+Q_211211000*PR_000001021220); ans_temp[ans_id*36+31]+=Pmtrx[26]*(Q_010012000*PR_000001021000+Q_010112000*PR_000001021010+Q_010212000*PR_000001021020+Q_010312000*PR_000001021030+Q_110012000*PR_000001021100+Q_110112000*PR_000001021110+Q_110212000*PR_000001021120+Q_110312000*PR_000001021130); ans_temp[ans_id*36+31]+=Pmtrx[27]*(Q_011010001*PR_000001021000+Q_011010101*PR_000001021001+Q_011110001*PR_000001021010+Q_011110101*PR_000001021011+Q_111010001*PR_000001021100+Q_111010101*PR_000001021101+Q_111110001*PR_000001021110+Q_111110101*PR_000001021111+Q_211010001*PR_000001021200+Q_211010101*PR_000001021201+Q_211110001*PR_000001021210+Q_211110101*PR_000001021211); ans_temp[ans_id*36+31]+=Pmtrx[28]*(Q_010011001*PR_000001021000+Q_010011101*PR_000001021001+Q_010111001*PR_000001021010+Q_010111101*PR_000001021011+Q_010211001*PR_000001021020+Q_010211101*PR_000001021021+Q_110011001*PR_000001021100+Q_110011101*PR_000001021101+Q_110111001*PR_000001021110+Q_110111101*PR_000001021111+Q_110211001*PR_000001021120+Q_110211101*PR_000001021121); ans_temp[ans_id*36+31]+=Pmtrx[29]*(Q_010010002*PR_000001021000+Q_010010102*PR_000001021001+Q_010010202*PR_000001021002+Q_010110002*PR_000001021010+Q_010110102*PR_000001021011+Q_010110202*PR_000001021012+Q_110010002*PR_000001021100+Q_110010102*PR_000001021101+Q_110010202*PR_000001021102+Q_110110002*PR_000001021110+Q_110110102*PR_000001021111+Q_110110202*PR_000001021112); ans_temp[ans_id*36+32]+=Pmtrx[24]*(Q_002020000*PR_000001021000+Q_002120000*PR_000001021010+Q_002220000*PR_000001021020+Q_102020000*PR_000001021100+Q_102120000*PR_000001021110+Q_102220000*PR_000001021120+Q_202020000*PR_000001021200+Q_202120000*PR_000001021210+Q_202220000*PR_000001021220); ans_temp[ans_id*36+32]+=Pmtrx[25]*(Q_001021000*PR_000001021000+Q_001121000*PR_000001021010+Q_001221000*PR_000001021020+Q_001321000*PR_000001021030+Q_101021000*PR_000001021100+Q_101121000*PR_000001021110+Q_101221000*PR_000001021120+Q_101321000*PR_000001021130); ans_temp[ans_id*36+32]+=Pmtrx[26]*(Q_000022000*PR_000001021000+Q_000122000*PR_000001021010+Q_000222000*PR_000001021020+Q_000322000*PR_000001021030+Q_000422000*PR_000001021040); ans_temp[ans_id*36+32]+=Pmtrx[27]*(Q_001020001*PR_000001021000+Q_001020101*PR_000001021001+Q_001120001*PR_000001021010+Q_001120101*PR_000001021011+Q_001220001*PR_000001021020+Q_001220101*PR_000001021021+Q_101020001*PR_000001021100+Q_101020101*PR_000001021101+Q_101120001*PR_000001021110+Q_101120101*PR_000001021111+Q_101220001*PR_000001021120+Q_101220101*PR_000001021121); ans_temp[ans_id*36+32]+=Pmtrx[28]*(Q_000021001*PR_000001021000+Q_000021101*PR_000001021001+Q_000121001*PR_000001021010+Q_000121101*PR_000001021011+Q_000221001*PR_000001021020+Q_000221101*PR_000001021021+Q_000321001*PR_000001021030+Q_000321101*PR_000001021031); ans_temp[ans_id*36+32]+=Pmtrx[29]*(Q_000020002*PR_000001021000+Q_000020102*PR_000001021001+Q_000020202*PR_000001021002+Q_000120002*PR_000001021010+Q_000120102*PR_000001021011+Q_000120202*PR_000001021012+Q_000220002*PR_000001021020+Q_000220102*PR_000001021021+Q_000220202*PR_000001021022); ans_temp[ans_id*36+33]+=Pmtrx[24]*(Q_012000010*PR_000001021000+Q_012000110*PR_000001021001+Q_112000010*PR_000001021100+Q_112000110*PR_000001021101+Q_212000010*PR_000001021200+Q_212000110*PR_000001021201+Q_312000010*PR_000001021300+Q_312000110*PR_000001021301); ans_temp[ans_id*36+33]+=Pmtrx[25]*(Q_011001010*PR_000001021000+Q_011001110*PR_000001021001+Q_011101010*PR_000001021010+Q_011101110*PR_000001021011+Q_111001010*PR_000001021100+Q_111001110*PR_000001021101+Q_111101010*PR_000001021110+Q_111101110*PR_000001021111+Q_211001010*PR_000001021200+Q_211001110*PR_000001021201+Q_211101010*PR_000001021210+Q_211101110*PR_000001021211); ans_temp[ans_id*36+33]+=Pmtrx[26]*(Q_010002010*PR_000001021000+Q_010002110*PR_000001021001+Q_010102010*PR_000001021010+Q_010102110*PR_000001021011+Q_010202010*PR_000001021020+Q_010202110*PR_000001021021+Q_110002010*PR_000001021100+Q_110002110*PR_000001021101+Q_110102010*PR_000001021110+Q_110102110*PR_000001021111+Q_110202010*PR_000001021120+Q_110202110*PR_000001021121); ans_temp[ans_id*36+33]+=Pmtrx[27]*(Q_011000011*PR_000001021000+Q_011000111*PR_000001021001+Q_011000211*PR_000001021002+Q_111000011*PR_000001021100+Q_111000111*PR_000001021101+Q_111000211*PR_000001021102+Q_211000011*PR_000001021200+Q_211000111*PR_000001021201+Q_211000211*PR_000001021202); ans_temp[ans_id*36+33]+=Pmtrx[28]*(Q_010001011*PR_000001021000+Q_010001111*PR_000001021001+Q_010001211*PR_000001021002+Q_010101011*PR_000001021010+Q_010101111*PR_000001021011+Q_010101211*PR_000001021012+Q_110001011*PR_000001021100+Q_110001111*PR_000001021101+Q_110001211*PR_000001021102+Q_110101011*PR_000001021110+Q_110101111*PR_000001021111+Q_110101211*PR_000001021112); ans_temp[ans_id*36+33]+=Pmtrx[29]*(Q_010000012*PR_000001021000+Q_010000112*PR_000001021001+Q_010000212*PR_000001021002+Q_010000312*PR_000001021003+Q_110000012*PR_000001021100+Q_110000112*PR_000001021101+Q_110000212*PR_000001021102+Q_110000312*PR_000001021103); ans_temp[ans_id*36+34]+=Pmtrx[24]*(Q_002010010*PR_000001021000+Q_002010110*PR_000001021001+Q_002110010*PR_000001021010+Q_002110110*PR_000001021011+Q_102010010*PR_000001021100+Q_102010110*PR_000001021101+Q_102110010*PR_000001021110+Q_102110110*PR_000001021111+Q_202010010*PR_000001021200+Q_202010110*PR_000001021201+Q_202110010*PR_000001021210+Q_202110110*PR_000001021211); ans_temp[ans_id*36+34]+=Pmtrx[25]*(Q_001011010*PR_000001021000+Q_001011110*PR_000001021001+Q_001111010*PR_000001021010+Q_001111110*PR_000001021011+Q_001211010*PR_000001021020+Q_001211110*PR_000001021021+Q_101011010*PR_000001021100+Q_101011110*PR_000001021101+Q_101111010*PR_000001021110+Q_101111110*PR_000001021111+Q_101211010*PR_000001021120+Q_101211110*PR_000001021121); ans_temp[ans_id*36+34]+=Pmtrx[26]*(Q_000012010*PR_000001021000+Q_000012110*PR_000001021001+Q_000112010*PR_000001021010+Q_000112110*PR_000001021011+Q_000212010*PR_000001021020+Q_000212110*PR_000001021021+Q_000312010*PR_000001021030+Q_000312110*PR_000001021031); ans_temp[ans_id*36+34]+=Pmtrx[27]*(Q_001010011*PR_000001021000+Q_001010111*PR_000001021001+Q_001010211*PR_000001021002+Q_001110011*PR_000001021010+Q_001110111*PR_000001021011+Q_001110211*PR_000001021012+Q_101010011*PR_000001021100+Q_101010111*PR_000001021101+Q_101010211*PR_000001021102+Q_101110011*PR_000001021110+Q_101110111*PR_000001021111+Q_101110211*PR_000001021112); ans_temp[ans_id*36+34]+=Pmtrx[28]*(Q_000011011*PR_000001021000+Q_000011111*PR_000001021001+Q_000011211*PR_000001021002+Q_000111011*PR_000001021010+Q_000111111*PR_000001021011+Q_000111211*PR_000001021012+Q_000211011*PR_000001021020+Q_000211111*PR_000001021021+Q_000211211*PR_000001021022); ans_temp[ans_id*36+34]+=Pmtrx[29]*(Q_000010012*PR_000001021000+Q_000010112*PR_000001021001+Q_000010212*PR_000001021002+Q_000010312*PR_000001021003+Q_000110012*PR_000001021010+Q_000110112*PR_000001021011+Q_000110212*PR_000001021012+Q_000110312*PR_000001021013); ans_temp[ans_id*36+35]+=Pmtrx[24]*(Q_002000020*PR_000001021000+Q_002000120*PR_000001021001+Q_002000220*PR_000001021002+Q_102000020*PR_000001021100+Q_102000120*PR_000001021101+Q_102000220*PR_000001021102+Q_202000020*PR_000001021200+Q_202000120*PR_000001021201+Q_202000220*PR_000001021202); ans_temp[ans_id*36+35]+=Pmtrx[25]*(Q_001001020*PR_000001021000+Q_001001120*PR_000001021001+Q_001001220*PR_000001021002+Q_001101020*PR_000001021010+Q_001101120*PR_000001021011+Q_001101220*PR_000001021012+Q_101001020*PR_000001021100+Q_101001120*PR_000001021101+Q_101001220*PR_000001021102+Q_101101020*PR_000001021110+Q_101101120*PR_000001021111+Q_101101220*PR_000001021112); ans_temp[ans_id*36+35]+=Pmtrx[26]*(Q_000002020*PR_000001021000+Q_000002120*PR_000001021001+Q_000002220*PR_000001021002+Q_000102020*PR_000001021010+Q_000102120*PR_000001021011+Q_000102220*PR_000001021012+Q_000202020*PR_000001021020+Q_000202120*PR_000001021021+Q_000202220*PR_000001021022); ans_temp[ans_id*36+35]+=Pmtrx[27]*(Q_001000021*PR_000001021000+Q_001000121*PR_000001021001+Q_001000221*PR_000001021002+Q_001000321*PR_000001021003+Q_101000021*PR_000001021100+Q_101000121*PR_000001021101+Q_101000221*PR_000001021102+Q_101000321*PR_000001021103); ans_temp[ans_id*36+35]+=Pmtrx[28]*(Q_000001021*PR_000001021000+Q_000001121*PR_000001021001+Q_000001221*PR_000001021002+Q_000001321*PR_000001021003+Q_000101021*PR_000001021010+Q_000101121*PR_000001021011+Q_000101221*PR_000001021012+Q_000101321*PR_000001021013); ans_temp[ans_id*36+35]+=Pmtrx[29]*(Q_000000022*PR_000001021000+Q_000000122*PR_000001021001+Q_000000222*PR_000001021002+Q_000000322*PR_000001021003+Q_000000422*PR_000001021004); ans_temp[ans_id*36+30]+=Pmtrx[30]*(Q_022000000*PR_000000022000+Q_122000000*PR_000000022100+Q_222000000*PR_000000022200+Q_322000000*PR_000000022300+Q_422000000*PR_000000022400); ans_temp[ans_id*36+30]+=Pmtrx[31]*(Q_021001000*PR_000000022000+Q_021101000*PR_000000022010+Q_121001000*PR_000000022100+Q_121101000*PR_000000022110+Q_221001000*PR_000000022200+Q_221101000*PR_000000022210+Q_321001000*PR_000000022300+Q_321101000*PR_000000022310); ans_temp[ans_id*36+30]+=Pmtrx[32]*(Q_020002000*PR_000000022000+Q_020102000*PR_000000022010+Q_020202000*PR_000000022020+Q_120002000*PR_000000022100+Q_120102000*PR_000000022110+Q_120202000*PR_000000022120+Q_220002000*PR_000000022200+Q_220102000*PR_000000022210+Q_220202000*PR_000000022220); ans_temp[ans_id*36+30]+=Pmtrx[33]*(Q_021000001*PR_000000022000+Q_021000101*PR_000000022001+Q_121000001*PR_000000022100+Q_121000101*PR_000000022101+Q_221000001*PR_000000022200+Q_221000101*PR_000000022201+Q_321000001*PR_000000022300+Q_321000101*PR_000000022301); ans_temp[ans_id*36+30]+=Pmtrx[34]*(Q_020001001*PR_000000022000+Q_020001101*PR_000000022001+Q_020101001*PR_000000022010+Q_020101101*PR_000000022011+Q_120001001*PR_000000022100+Q_120001101*PR_000000022101+Q_120101001*PR_000000022110+Q_120101101*PR_000000022111+Q_220001001*PR_000000022200+Q_220001101*PR_000000022201+Q_220101001*PR_000000022210+Q_220101101*PR_000000022211); ans_temp[ans_id*36+30]+=Pmtrx[35]*(Q_020000002*PR_000000022000+Q_020000102*PR_000000022001+Q_020000202*PR_000000022002+Q_120000002*PR_000000022100+Q_120000102*PR_000000022101+Q_120000202*PR_000000022102+Q_220000002*PR_000000022200+Q_220000102*PR_000000022201+Q_220000202*PR_000000022202); ans_temp[ans_id*36+31]+=Pmtrx[30]*(Q_012010000*PR_000000022000+Q_012110000*PR_000000022010+Q_112010000*PR_000000022100+Q_112110000*PR_000000022110+Q_212010000*PR_000000022200+Q_212110000*PR_000000022210+Q_312010000*PR_000000022300+Q_312110000*PR_000000022310); ans_temp[ans_id*36+31]+=Pmtrx[31]*(Q_011011000*PR_000000022000+Q_011111000*PR_000000022010+Q_011211000*PR_000000022020+Q_111011000*PR_000000022100+Q_111111000*PR_000000022110+Q_111211000*PR_000000022120+Q_211011000*PR_000000022200+Q_211111000*PR_000000022210+Q_211211000*PR_000000022220); ans_temp[ans_id*36+31]+=Pmtrx[32]*(Q_010012000*PR_000000022000+Q_010112000*PR_000000022010+Q_010212000*PR_000000022020+Q_010312000*PR_000000022030+Q_110012000*PR_000000022100+Q_110112000*PR_000000022110+Q_110212000*PR_000000022120+Q_110312000*PR_000000022130); ans_temp[ans_id*36+31]+=Pmtrx[33]*(Q_011010001*PR_000000022000+Q_011010101*PR_000000022001+Q_011110001*PR_000000022010+Q_011110101*PR_000000022011+Q_111010001*PR_000000022100+Q_111010101*PR_000000022101+Q_111110001*PR_000000022110+Q_111110101*PR_000000022111+Q_211010001*PR_000000022200+Q_211010101*PR_000000022201+Q_211110001*PR_000000022210+Q_211110101*PR_000000022211); ans_temp[ans_id*36+31]+=Pmtrx[34]*(Q_010011001*PR_000000022000+Q_010011101*PR_000000022001+Q_010111001*PR_000000022010+Q_010111101*PR_000000022011+Q_010211001*PR_000000022020+Q_010211101*PR_000000022021+Q_110011001*PR_000000022100+Q_110011101*PR_000000022101+Q_110111001*PR_000000022110+Q_110111101*PR_000000022111+Q_110211001*PR_000000022120+Q_110211101*PR_000000022121); ans_temp[ans_id*36+31]+=Pmtrx[35]*(Q_010010002*PR_000000022000+Q_010010102*PR_000000022001+Q_010010202*PR_000000022002+Q_010110002*PR_000000022010+Q_010110102*PR_000000022011+Q_010110202*PR_000000022012+Q_110010002*PR_000000022100+Q_110010102*PR_000000022101+Q_110010202*PR_000000022102+Q_110110002*PR_000000022110+Q_110110102*PR_000000022111+Q_110110202*PR_000000022112); ans_temp[ans_id*36+32]+=Pmtrx[30]*(Q_002020000*PR_000000022000+Q_002120000*PR_000000022010+Q_002220000*PR_000000022020+Q_102020000*PR_000000022100+Q_102120000*PR_000000022110+Q_102220000*PR_000000022120+Q_202020000*PR_000000022200+Q_202120000*PR_000000022210+Q_202220000*PR_000000022220); ans_temp[ans_id*36+32]+=Pmtrx[31]*(Q_001021000*PR_000000022000+Q_001121000*PR_000000022010+Q_001221000*PR_000000022020+Q_001321000*PR_000000022030+Q_101021000*PR_000000022100+Q_101121000*PR_000000022110+Q_101221000*PR_000000022120+Q_101321000*PR_000000022130); ans_temp[ans_id*36+32]+=Pmtrx[32]*(Q_000022000*PR_000000022000+Q_000122000*PR_000000022010+Q_000222000*PR_000000022020+Q_000322000*PR_000000022030+Q_000422000*PR_000000022040); ans_temp[ans_id*36+32]+=Pmtrx[33]*(Q_001020001*PR_000000022000+Q_001020101*PR_000000022001+Q_001120001*PR_000000022010+Q_001120101*PR_000000022011+Q_001220001*PR_000000022020+Q_001220101*PR_000000022021+Q_101020001*PR_000000022100+Q_101020101*PR_000000022101+Q_101120001*PR_000000022110+Q_101120101*PR_000000022111+Q_101220001*PR_000000022120+Q_101220101*PR_000000022121); ans_temp[ans_id*36+32]+=Pmtrx[34]*(Q_000021001*PR_000000022000+Q_000021101*PR_000000022001+Q_000121001*PR_000000022010+Q_000121101*PR_000000022011+Q_000221001*PR_000000022020+Q_000221101*PR_000000022021+Q_000321001*PR_000000022030+Q_000321101*PR_000000022031); ans_temp[ans_id*36+32]+=Pmtrx[35]*(Q_000020002*PR_000000022000+Q_000020102*PR_000000022001+Q_000020202*PR_000000022002+Q_000120002*PR_000000022010+Q_000120102*PR_000000022011+Q_000120202*PR_000000022012+Q_000220002*PR_000000022020+Q_000220102*PR_000000022021+Q_000220202*PR_000000022022); ans_temp[ans_id*36+33]+=Pmtrx[30]*(Q_012000010*PR_000000022000+Q_012000110*PR_000000022001+Q_112000010*PR_000000022100+Q_112000110*PR_000000022101+Q_212000010*PR_000000022200+Q_212000110*PR_000000022201+Q_312000010*PR_000000022300+Q_312000110*PR_000000022301); ans_temp[ans_id*36+33]+=Pmtrx[31]*(Q_011001010*PR_000000022000+Q_011001110*PR_000000022001+Q_011101010*PR_000000022010+Q_011101110*PR_000000022011+Q_111001010*PR_000000022100+Q_111001110*PR_000000022101+Q_111101010*PR_000000022110+Q_111101110*PR_000000022111+Q_211001010*PR_000000022200+Q_211001110*PR_000000022201+Q_211101010*PR_000000022210+Q_211101110*PR_000000022211); ans_temp[ans_id*36+33]+=Pmtrx[32]*(Q_010002010*PR_000000022000+Q_010002110*PR_000000022001+Q_010102010*PR_000000022010+Q_010102110*PR_000000022011+Q_010202010*PR_000000022020+Q_010202110*PR_000000022021+Q_110002010*PR_000000022100+Q_110002110*PR_000000022101+Q_110102010*PR_000000022110+Q_110102110*PR_000000022111+Q_110202010*PR_000000022120+Q_110202110*PR_000000022121); ans_temp[ans_id*36+33]+=Pmtrx[33]*(Q_011000011*PR_000000022000+Q_011000111*PR_000000022001+Q_011000211*PR_000000022002+Q_111000011*PR_000000022100+Q_111000111*PR_000000022101+Q_111000211*PR_000000022102+Q_211000011*PR_000000022200+Q_211000111*PR_000000022201+Q_211000211*PR_000000022202); ans_temp[ans_id*36+33]+=Pmtrx[34]*(Q_010001011*PR_000000022000+Q_010001111*PR_000000022001+Q_010001211*PR_000000022002+Q_010101011*PR_000000022010+Q_010101111*PR_000000022011+Q_010101211*PR_000000022012+Q_110001011*PR_000000022100+Q_110001111*PR_000000022101+Q_110001211*PR_000000022102+Q_110101011*PR_000000022110+Q_110101111*PR_000000022111+Q_110101211*PR_000000022112); ans_temp[ans_id*36+33]+=Pmtrx[35]*(Q_010000012*PR_000000022000+Q_010000112*PR_000000022001+Q_010000212*PR_000000022002+Q_010000312*PR_000000022003+Q_110000012*PR_000000022100+Q_110000112*PR_000000022101+Q_110000212*PR_000000022102+Q_110000312*PR_000000022103); ans_temp[ans_id*36+34]+=Pmtrx[30]*(Q_002010010*PR_000000022000+Q_002010110*PR_000000022001+Q_002110010*PR_000000022010+Q_002110110*PR_000000022011+Q_102010010*PR_000000022100+Q_102010110*PR_000000022101+Q_102110010*PR_000000022110+Q_102110110*PR_000000022111+Q_202010010*PR_000000022200+Q_202010110*PR_000000022201+Q_202110010*PR_000000022210+Q_202110110*PR_000000022211); ans_temp[ans_id*36+34]+=Pmtrx[31]*(Q_001011010*PR_000000022000+Q_001011110*PR_000000022001+Q_001111010*PR_000000022010+Q_001111110*PR_000000022011+Q_001211010*PR_000000022020+Q_001211110*PR_000000022021+Q_101011010*PR_000000022100+Q_101011110*PR_000000022101+Q_101111010*PR_000000022110+Q_101111110*PR_000000022111+Q_101211010*PR_000000022120+Q_101211110*PR_000000022121); ans_temp[ans_id*36+34]+=Pmtrx[32]*(Q_000012010*PR_000000022000+Q_000012110*PR_000000022001+Q_000112010*PR_000000022010+Q_000112110*PR_000000022011+Q_000212010*PR_000000022020+Q_000212110*PR_000000022021+Q_000312010*PR_000000022030+Q_000312110*PR_000000022031); ans_temp[ans_id*36+34]+=Pmtrx[33]*(Q_001010011*PR_000000022000+Q_001010111*PR_000000022001+Q_001010211*PR_000000022002+Q_001110011*PR_000000022010+Q_001110111*PR_000000022011+Q_001110211*PR_000000022012+Q_101010011*PR_000000022100+Q_101010111*PR_000000022101+Q_101010211*PR_000000022102+Q_101110011*PR_000000022110+Q_101110111*PR_000000022111+Q_101110211*PR_000000022112); ans_temp[ans_id*36+34]+=Pmtrx[34]*(Q_000011011*PR_000000022000+Q_000011111*PR_000000022001+Q_000011211*PR_000000022002+Q_000111011*PR_000000022010+Q_000111111*PR_000000022011+Q_000111211*PR_000000022012+Q_000211011*PR_000000022020+Q_000211111*PR_000000022021+Q_000211211*PR_000000022022); ans_temp[ans_id*36+34]+=Pmtrx[35]*(Q_000010012*PR_000000022000+Q_000010112*PR_000000022001+Q_000010212*PR_000000022002+Q_000010312*PR_000000022003+Q_000110012*PR_000000022010+Q_000110112*PR_000000022011+Q_000110212*PR_000000022012+Q_000110312*PR_000000022013); ans_temp[ans_id*36+35]+=Pmtrx[30]*(Q_002000020*PR_000000022000+Q_002000120*PR_000000022001+Q_002000220*PR_000000022002+Q_102000020*PR_000000022100+Q_102000120*PR_000000022101+Q_102000220*PR_000000022102+Q_202000020*PR_000000022200+Q_202000120*PR_000000022201+Q_202000220*PR_000000022202); ans_temp[ans_id*36+35]+=Pmtrx[31]*(Q_001001020*PR_000000022000+Q_001001120*PR_000000022001+Q_001001220*PR_000000022002+Q_001101020*PR_000000022010+Q_001101120*PR_000000022011+Q_001101220*PR_000000022012+Q_101001020*PR_000000022100+Q_101001120*PR_000000022101+Q_101001220*PR_000000022102+Q_101101020*PR_000000022110+Q_101101120*PR_000000022111+Q_101101220*PR_000000022112); ans_temp[ans_id*36+35]+=Pmtrx[32]*(Q_000002020*PR_000000022000+Q_000002120*PR_000000022001+Q_000002220*PR_000000022002+Q_000102020*PR_000000022010+Q_000102120*PR_000000022011+Q_000102220*PR_000000022012+Q_000202020*PR_000000022020+Q_000202120*PR_000000022021+Q_000202220*PR_000000022022); ans_temp[ans_id*36+35]+=Pmtrx[33]*(Q_001000021*PR_000000022000+Q_001000121*PR_000000022001+Q_001000221*PR_000000022002+Q_001000321*PR_000000022003+Q_101000021*PR_000000022100+Q_101000121*PR_000000022101+Q_101000221*PR_000000022102+Q_101000321*PR_000000022103); ans_temp[ans_id*36+35]+=Pmtrx[34]*(Q_000001021*PR_000000022000+Q_000001121*PR_000000022001+Q_000001221*PR_000000022002+Q_000001321*PR_000000022003+Q_000101021*PR_000000022010+Q_000101121*PR_000000022011+Q_000101221*PR_000000022012+Q_000101321*PR_000000022013); ans_temp[ans_id*36+35]+=Pmtrx[35]*(Q_000000022*PR_000000022000+Q_000000122*PR_000000022001+Q_000000222*PR_000000022002+Q_000000322*PR_000000022003+Q_000000422*PR_000000022004); } } __syncthreads(); int num_thread=NTHREAD/2; while (num_thread!=0){ __syncthreads(); if(tId_x<num_thread){ for(int ians=0;ians<36;ians++){ ans_temp[tId_x*36+ians]+=ans_temp[(tId_x+num_thread)*36+ians]; } } num_thread/=2; } if(tId_x==0){ for(int ians=0;ians<36;ians++){ ans[(i_contrc_bra*contrc_ket_num+j_contrc_ket)*36+ians]=ans_temp[(tId_x)*36+ians]; } } } } } __global__ void MD_Kq_dddd_fs(unsigned int contrc_bra_num,unsigned int contrc_ket_num,\ unsigned int * contrc_bra_id,\ unsigned int * contrc_ket_id,\ unsigned int mtrx_len,\ double * Pmtrx_in,\ double * P,\ double * PA,\ double * PB,\ double * Zta_in,\ double * pp_in,\ float * K2_p_in,\ unsigned int * id_bra_in,\ double * Q,\ double * QC,\ double * QD,\ double * Eta_in,\ double * pq_in,\ float * K2_q_in,\ unsigned int * id_ket_in,\ double * ans){ unsigned int tId_x = threadIdx.x; unsigned int bId_x = blockIdx.x; unsigned int bId_y = blockIdx.y; unsigned int tdis = blockDim.x; unsigned int bdis_x = gridDim.x; unsigned int bdis_y = gridDim.y; unsigned int ans_id=tId_x; double Pmtrx[36]={0.0}; __shared__ double ans_temp[NTHREAD*36]; for(int i=0;i<36;i++){ ans_temp[i*tdis+tId_x]=0.0; } for(unsigned int i_contrc_bra=bId_x;i_contrc_bra<contrc_bra_num;i_contrc_bra+=bdis_x){ for(unsigned int j_contrc_ket=bId_y;j_contrc_ket<contrc_ket_num;j_contrc_ket+=bdis_y){ unsigned int primit_bra_start = contrc_bra_id[i_contrc_bra ]; unsigned int primit_bra_end = contrc_bra_id[i_contrc_bra+1]; unsigned int primit_ket_start = contrc_ket_id[j_contrc_ket ]; unsigned int primit_ket_end = contrc_ket_id[j_contrc_ket+1]; if(i_contrc_bra>j_contrc_ket){ if(tId_x==0){ for(int ians=0;ians<36;ians++){ ans[(i_contrc_bra*contrc_ket_num+j_contrc_ket)*36+ians]=0.0; } } continue; } for(unsigned int ii=primit_bra_start;ii<primit_bra_end;ii++){ unsigned int id_bra=id_bra_in[ii]; double PX=P[ii*3+0]; double PY=P[ii*3+1]; double PZ=P[ii*3+2]; double Pd_010[3]; Pd_010[0]=PA[ii*3+0]; Pd_010[1]=PA[ii*3+1]; Pd_010[2]=PA[ii*3+2]; double Pd_001[3]; Pd_001[0]=PB[ii*3+0]; Pd_001[1]=PB[ii*3+1]; Pd_001[2]=PB[ii*3+2]; double Zta=Zta_in[ii]; double pp=pp_in[ii]; float K2_p=K2_p_in[ii]; double aPin1=1/(2*Zta); for(unsigned int j=tId_x;j<primit_ket_end-primit_ket_start;j+=tdis){ unsigned int jj=primit_ket_start+j; unsigned int id_ket=tex1Dfetch(tex_id_ket,jj); double P_max=0.0; for(int p_j=0;p_j<6;p_j++){ for(int p_i=0;p_i<6;p_i++){ Pmtrx[p_i*6+p_j]=Pmtrx_in[(id_ket+p_j)*mtrx_len+(id_bra+p_i)]; double temp_P=fabsf(Pmtrx[p_i*6+p_j]); if(temp_P>P_max) P_max=temp_P; } } float K2_q=tex1Dfetch(tex_K2_q,jj); if(fabsf(K2_p*K2_q)<1.0E-14){ break; } if(fabsf(P_max*K2_p*K2_q)<1.0E-14) continue; int2 temp_int2; temp_int2=tex1Dfetch(tex_Eta,jj); double Eta=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_pq,jj); double pq=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_Q,jj*3+0); double QX=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_Q,jj*3+1); double QY=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_Q,jj*3+2); double QZ=__hiloint2double(temp_int2.y,temp_int2.x); double Qd_010[3]; temp_int2=tex1Dfetch(tex_QC,jj*3+0); Qd_010[0]=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_QC,jj*3+1); Qd_010[1]=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_QC,jj*3+2); Qd_010[2]=__hiloint2double(temp_int2.y,temp_int2.x); double Qd_001[3]; temp_int2=tex1Dfetch(tex_QD,jj*3+0); Qd_001[0]=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_QD,jj*3+1); Qd_001[1]=__hiloint2double(temp_int2.y,temp_int2.x); temp_int2=tex1Dfetch(tex_QD,jj*3+2); Qd_001[2]=__hiloint2double(temp_int2.y,temp_int2.x); double alphaT=rsqrt(Eta+Zta); double lmd=2*P25*pp*pq*alphaT; alphaT=Eta*Zta*alphaT*alphaT; double TX=PX-QX; double TY=PY-QY; double TZ=PZ-QZ; double T=alphaT*(TX*TX+TY*TY+TZ*TZ); double R_000[9]; Ft_fs_8(8,T,R_000); R_000[0]*=lmd; R_000[1]*=-2*alphaT*lmd; R_000[2]*=4*alphaT*alphaT*lmd; R_000[3]*=-8*alphaT*alphaT*alphaT*lmd; R_000[4]*=16*alphaT*alphaT*alphaT*alphaT*lmd; R_000[5]*=-32*alphaT*alphaT*alphaT*alphaT*alphaT*lmd; R_000[6]*=64*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*lmd; R_000[7]*=-128*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*lmd; R_000[8]*=256*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*alphaT*lmd; double aQin1=1/(2*Eta); double R_100[8]; double R_200[7]; double R_300[6]; double R_400[5]; double R_500[4]; double R_600[3]; double R_700[2]; double R_800[1]; double R_010[8]; double R_110[7]; double R_210[6]; double R_310[5]; double R_410[4]; double R_510[3]; double R_610[2]; double R_710[1]; double R_020[7]; double R_120[6]; double R_220[5]; double R_320[4]; double R_420[3]; double R_520[2]; double R_620[1]; double R_030[6]; double R_130[5]; double R_230[4]; double R_330[3]; double R_430[2]; double R_530[1]; double R_040[5]; double R_140[4]; double R_240[3]; double R_340[2]; double R_440[1]; double R_050[4]; double R_150[3]; double R_250[2]; double R_350[1]; double R_060[3]; double R_160[2]; double R_260[1]; double R_070[2]; double R_170[1]; double R_080[1]; double R_001[8]; double R_101[7]; double R_201[6]; double R_301[5]; double R_401[4]; double R_501[3]; double R_601[2]; double R_701[1]; double R_011[7]; double R_111[6]; double R_211[5]; double R_311[4]; double R_411[3]; double R_511[2]; double R_611[1]; double R_021[6]; double R_121[5]; double R_221[4]; double R_321[3]; double R_421[2]; double R_521[1]; double R_031[5]; double R_131[4]; double R_231[3]; double R_331[2]; double R_431[1]; double R_041[4]; double R_141[3]; double R_241[2]; double R_341[1]; double R_051[3]; double R_151[2]; double R_251[1]; double R_061[2]; double R_161[1]; double R_071[1]; double R_002[7]; double R_102[6]; double R_202[5]; double R_302[4]; double R_402[3]; double R_502[2]; double R_602[1]; double R_012[6]; double R_112[5]; double R_212[4]; double R_312[3]; double R_412[2]; double R_512[1]; double R_022[5]; double R_122[4]; double R_222[3]; double R_322[2]; double R_422[1]; double R_032[4]; double R_132[3]; double R_232[2]; double R_332[1]; double R_042[3]; double R_142[2]; double R_242[1]; double R_052[2]; double R_152[1]; double R_062[1]; double R_003[6]; double R_103[5]; double R_203[4]; double R_303[3]; double R_403[2]; double R_503[1]; double R_013[5]; double R_113[4]; double R_213[3]; double R_313[2]; double R_413[1]; double R_023[4]; double R_123[3]; double R_223[2]; double R_323[1]; double R_033[3]; double R_133[2]; double R_233[1]; double R_043[2]; double R_143[1]; double R_053[1]; double R_004[5]; double R_104[4]; double R_204[3]; double R_304[2]; double R_404[1]; double R_014[4]; double R_114[3]; double R_214[2]; double R_314[1]; double R_024[3]; double R_124[2]; double R_224[1]; double R_034[2]; double R_134[1]; double R_044[1]; double R_005[4]; double R_105[3]; double R_205[2]; double R_305[1]; double R_015[3]; double R_115[2]; double R_215[1]; double R_025[2]; double R_125[1]; double R_035[1]; double R_006[3]; double R_106[2]; double R_206[1]; double R_016[2]; double R_116[1]; double R_026[1]; double R_007[2]; double R_107[1]; double R_017[1]; double R_008[1]; for(int i=0;i<8;i++){ R_100[i]=TX*R_000[i+1]; } for(int i=0;i<8;i++){ R_010[i]=TY*R_000[i+1]; } for(int i=0;i<8;i++){ R_001[i]=TZ*R_000[i+1]; } for(int i=0;i<7;i++){ R_200[i]=TX*R_100[i+1]+R_000[i+1]; } for(int i=0;i<7;i++){ R_110[i]=TX*R_010[i+1]; } for(int i=0;i<7;i++){ R_020[i]=TY*R_010[i+1]+R_000[i+1]; } for(int i=0;i<7;i++){ R_101[i]=TX*R_001[i+1]; } for(int i=0;i<7;i++){ R_011[i]=TY*R_001[i+1]; } for(int i=0;i<7;i++){ R_002[i]=TZ*R_001[i+1]+R_000[i+1]; } for(int i=0;i<6;i++){ R_300[i]=TX*R_200[i+1]+2*R_100[i+1]; } for(int i=0;i<6;i++){ R_210[i]=TY*R_200[i+1]; } for(int i=0;i<6;i++){ R_120[i]=TX*R_020[i+1]; } for(int i=0;i<6;i++){ R_030[i]=TY*R_020[i+1]+2*R_010[i+1]; } for(int i=0;i<6;i++){ R_201[i]=TZ*R_200[i+1]; } for(int i=0;i<6;i++){ R_111[i]=TX*R_011[i+1]; } for(int i=0;i<6;i++){ R_021[i]=TZ*R_020[i+1]; } for(int i=0;i<6;i++){ R_102[i]=TX*R_002[i+1]; } for(int i=0;i<6;i++){ R_012[i]=TY*R_002[i+1]; } for(int i=0;i<6;i++){ R_003[i]=TZ*R_002[i+1]+2*R_001[i+1]; } for(int i=0;i<5;i++){ R_400[i]=TX*R_300[i+1]+3*R_200[i+1]; } for(int i=0;i<5;i++){ R_310[i]=TY*R_300[i+1]; } for(int i=0;i<5;i++){ R_220[i]=TX*R_120[i+1]+R_020[i+1]; } for(int i=0;i<5;i++){ R_130[i]=TX*R_030[i+1]; } for(int i=0;i<5;i++){ R_040[i]=TY*R_030[i+1]+3*R_020[i+1]; } for(int i=0;i<5;i++){ R_301[i]=TZ*R_300[i+1]; } for(int i=0;i<5;i++){ R_211[i]=TY*R_201[i+1]; } for(int i=0;i<5;i++){ R_121[i]=TX*R_021[i+1]; } for(int i=0;i<5;i++){ R_031[i]=TZ*R_030[i+1]; } for(int i=0;i<5;i++){ R_202[i]=TX*R_102[i+1]+R_002[i+1]; } for(int i=0;i<5;i++){ R_112[i]=TX*R_012[i+1]; } for(int i=0;i<5;i++){ R_022[i]=TY*R_012[i+1]+R_002[i+1]; } for(int i=0;i<5;i++){ R_103[i]=TX*R_003[i+1]; } for(int i=0;i<5;i++){ R_013[i]=TY*R_003[i+1]; } for(int i=0;i<5;i++){ R_004[i]=TZ*R_003[i+1]+3*R_002[i+1]; } for(int i=0;i<4;i++){ R_500[i]=TX*R_400[i+1]+4*R_300[i+1]; } for(int i=0;i<4;i++){ R_410[i]=TY*R_400[i+1]; } for(int i=0;i<4;i++){ R_320[i]=TX*R_220[i+1]+2*R_120[i+1]; } for(int i=0;i<4;i++){ R_230[i]=TY*R_220[i+1]+2*R_210[i+1]; } for(int i=0;i<4;i++){ R_140[i]=TX*R_040[i+1]; } for(int i=0;i<4;i++){ R_050[i]=TY*R_040[i+1]+4*R_030[i+1]; } for(int i=0;i<4;i++){ R_401[i]=TZ*R_400[i+1]; } for(int i=0;i<4;i++){ R_311[i]=TY*R_301[i+1]; } for(int i=0;i<4;i++){ R_221[i]=TZ*R_220[i+1]; } for(int i=0;i<4;i++){ R_131[i]=TX*R_031[i+1]; } for(int i=0;i<4;i++){ R_041[i]=TZ*R_040[i+1]; } for(int i=0;i<4;i++){ R_302[i]=TX*R_202[i+1]+2*R_102[i+1]; } for(int i=0;i<4;i++){ R_212[i]=TY*R_202[i+1]; } for(int i=0;i<4;i++){ R_122[i]=TX*R_022[i+1]; } for(int i=0;i<4;i++){ R_032[i]=TY*R_022[i+1]+2*R_012[i+1]; } for(int i=0;i<4;i++){ R_203[i]=TZ*R_202[i+1]+2*R_201[i+1]; } for(int i=0;i<4;i++){ R_113[i]=TX*R_013[i+1]; } for(int i=0;i<4;i++){ R_023[i]=TZ*R_022[i+1]+2*R_021[i+1]; } for(int i=0;i<4;i++){ R_104[i]=TX*R_004[i+1]; } for(int i=0;i<4;i++){ R_014[i]=TY*R_004[i+1]; } for(int i=0;i<4;i++){ R_005[i]=TZ*R_004[i+1]+4*R_003[i+1]; } for(int i=0;i<3;i++){ R_600[i]=TX*R_500[i+1]+5*R_400[i+1]; } for(int i=0;i<3;i++){ R_510[i]=TY*R_500[i+1]; } for(int i=0;i<3;i++){ R_420[i]=TX*R_320[i+1]+3*R_220[i+1]; } for(int i=0;i<3;i++){ R_330[i]=TX*R_230[i+1]+2*R_130[i+1]; } for(int i=0;i<3;i++){ R_240[i]=TY*R_230[i+1]+3*R_220[i+1]; } for(int i=0;i<3;i++){ R_150[i]=TX*R_050[i+1]; } for(int i=0;i<3;i++){ R_060[i]=TY*R_050[i+1]+5*R_040[i+1]; } for(int i=0;i<3;i++){ R_501[i]=TZ*R_500[i+1]; } for(int i=0;i<3;i++){ R_411[i]=TY*R_401[i+1]; } for(int i=0;i<3;i++){ R_321[i]=TZ*R_320[i+1]; } for(int i=0;i<3;i++){ R_231[i]=TZ*R_230[i+1]; } for(int i=0;i<3;i++){ R_141[i]=TX*R_041[i+1]; } for(int i=0;i<3;i++){ R_051[i]=TZ*R_050[i+1]; } for(int i=0;i<3;i++){ R_402[i]=TX*R_302[i+1]+3*R_202[i+1]; } for(int i=0;i<3;i++){ R_312[i]=TY*R_302[i+1]; } for(int i=0;i<3;i++){ R_222[i]=TX*R_122[i+1]+R_022[i+1]; } for(int i=0;i<3;i++){ R_132[i]=TX*R_032[i+1]; } for(int i=0;i<3;i++){ R_042[i]=TY*R_032[i+1]+3*R_022[i+1]; } for(int i=0;i<3;i++){ R_303[i]=TX*R_203[i+1]+2*R_103[i+1]; } for(int i=0;i<3;i++){ R_213[i]=TY*R_203[i+1]; } for(int i=0;i<3;i++){ R_123[i]=TX*R_023[i+1]; } for(int i=0;i<3;i++){ R_033[i]=TY*R_023[i+1]+2*R_013[i+1]; } for(int i=0;i<3;i++){ R_204[i]=TZ*R_203[i+1]+3*R_202[i+1]; } for(int i=0;i<3;i++){ R_114[i]=TX*R_014[i+1]; } for(int i=0;i<3;i++){ R_024[i]=TZ*R_023[i+1]+3*R_022[i+1]; } for(int i=0;i<3;i++){ R_105[i]=TX*R_005[i+1]; } for(int i=0;i<3;i++){ R_015[i]=TY*R_005[i+1]; } for(int i=0;i<3;i++){ R_006[i]=TZ*R_005[i+1]+5*R_004[i+1]; } for(int i=0;i<2;i++){ R_700[i]=TX*R_600[i+1]+6*R_500[i+1]; } for(int i=0;i<2;i++){ R_610[i]=TY*R_600[i+1]; } for(int i=0;i<2;i++){ R_520[i]=TX*R_420[i+1]+4*R_320[i+1]; } for(int i=0;i<2;i++){ R_430[i]=TX*R_330[i+1]+3*R_230[i+1]; } for(int i=0;i<2;i++){ R_340[i]=TY*R_330[i+1]+3*R_320[i+1]; } for(int i=0;i<2;i++){ R_250[i]=TY*R_240[i+1]+4*R_230[i+1]; } for(int i=0;i<2;i++){ R_160[i]=TX*R_060[i+1]; } for(int i=0;i<2;i++){ R_070[i]=TY*R_060[i+1]+6*R_050[i+1]; } for(int i=0;i<2;i++){ R_601[i]=TZ*R_600[i+1]; } for(int i=0;i<2;i++){ R_511[i]=TY*R_501[i+1]; } for(int i=0;i<2;i++){ R_421[i]=TZ*R_420[i+1]; } for(int i=0;i<2;i++){ R_331[i]=TZ*R_330[i+1]; } for(int i=0;i<2;i++){ R_241[i]=TZ*R_240[i+1]; } for(int i=0;i<2;i++){ R_151[i]=TX*R_051[i+1]; } for(int i=0;i<2;i++){ R_061[i]=TZ*R_060[i+1]; } for(int i=0;i<2;i++){ R_502[i]=TX*R_402[i+1]+4*R_302[i+1]; } for(int i=0;i<2;i++){ R_412[i]=TY*R_402[i+1]; } for(int i=0;i<2;i++){ R_322[i]=TX*R_222[i+1]+2*R_122[i+1]; } for(int i=0;i<2;i++){ R_232[i]=TY*R_222[i+1]+2*R_212[i+1]; } for(int i=0;i<2;i++){ R_142[i]=TX*R_042[i+1]; } for(int i=0;i<2;i++){ R_052[i]=TY*R_042[i+1]+4*R_032[i+1]; } for(int i=0;i<2;i++){ R_403[i]=TX*R_303[i+1]+3*R_203[i+1]; } for(int i=0;i<2;i++){ R_313[i]=TY*R_303[i+1]; } for(int i=0;i<2;i++){ R_223[i]=TZ*R_222[i+1]+2*R_221[i+1]; } for(int i=0;i<2;i++){ R_133[i]=TX*R_033[i+1]; } for(int i=0;i<2;i++){ R_043[i]=TY*R_033[i+1]+3*R_023[i+1]; } for(int i=0;i<2;i++){ R_304[i]=TZ*R_303[i+1]+3*R_302[i+1]; } for(int i=0;i<2;i++){ R_214[i]=TY*R_204[i+1]; } for(int i=0;i<2;i++){ R_124[i]=TX*R_024[i+1]; } for(int i=0;i<2;i++){ R_034[i]=TZ*R_033[i+1]+3*R_032[i+1]; } for(int i=0;i<2;i++){ R_205[i]=TZ*R_204[i+1]+4*R_203[i+1]; } for(int i=0;i<2;i++){ R_115[i]=TX*R_015[i+1]; } for(int i=0;i<2;i++){ R_025[i]=TZ*R_024[i+1]+4*R_023[i+1]; } for(int i=0;i<2;i++){ R_106[i]=TX*R_006[i+1]; } for(int i=0;i<2;i++){ R_016[i]=TY*R_006[i+1]; } for(int i=0;i<2;i++){ R_007[i]=TZ*R_006[i+1]+6*R_005[i+1]; } for(int i=0;i<1;i++){ R_800[i]=TX*R_700[i+1]+7*R_600[i+1]; } for(int i=0;i<1;i++){ R_710[i]=TY*R_700[i+1]; } for(int i=0;i<1;i++){ R_620[i]=TX*R_520[i+1]+5*R_420[i+1]; } for(int i=0;i<1;i++){ R_530[i]=TX*R_430[i+1]+4*R_330[i+1]; } for(int i=0;i<1;i++){ R_440[i]=TX*R_340[i+1]+3*R_240[i+1]; } for(int i=0;i<1;i++){ R_350[i]=TY*R_340[i+1]+4*R_330[i+1]; } for(int i=0;i<1;i++){ R_260[i]=TY*R_250[i+1]+5*R_240[i+1]; } for(int i=0;i<1;i++){ R_170[i]=TX*R_070[i+1]; } for(int i=0;i<1;i++){ R_080[i]=TY*R_070[i+1]+7*R_060[i+1]; } for(int i=0;i<1;i++){ R_701[i]=TZ*R_700[i+1]; } for(int i=0;i<1;i++){ R_611[i]=TY*R_601[i+1]; } for(int i=0;i<1;i++){ R_521[i]=TZ*R_520[i+1]; } for(int i=0;i<1;i++){ R_431[i]=TZ*R_430[i+1]; } for(int i=0;i<1;i++){ R_341[i]=TZ*R_340[i+1]; } for(int i=0;i<1;i++){ R_251[i]=TZ*R_250[i+1]; } for(int i=0;i<1;i++){ R_161[i]=TX*R_061[i+1]; } for(int i=0;i<1;i++){ R_071[i]=TZ*R_070[i+1]; } for(int i=0;i<1;i++){ R_602[i]=TX*R_502[i+1]+5*R_402[i+1]; } for(int i=0;i<1;i++){ R_512[i]=TY*R_502[i+1]; } for(int i=0;i<1;i++){ R_422[i]=TX*R_322[i+1]+3*R_222[i+1]; } for(int i=0;i<1;i++){ R_332[i]=TX*R_232[i+1]+2*R_132[i+1]; } for(int i=0;i<1;i++){ R_242[i]=TY*R_232[i+1]+3*R_222[i+1]; } for(int i=0;i<1;i++){ R_152[i]=TX*R_052[i+1]; } for(int i=0;i<1;i++){ R_062[i]=TY*R_052[i+1]+5*R_042[i+1]; } for(int i=0;i<1;i++){ R_503[i]=TX*R_403[i+1]+4*R_303[i+1]; } for(int i=0;i<1;i++){ R_413[i]=TY*R_403[i+1]; } for(int i=0;i<1;i++){ R_323[i]=TX*R_223[i+1]+2*R_123[i+1]; } for(int i=0;i<1;i++){ R_233[i]=TY*R_223[i+1]+2*R_213[i+1]; } for(int i=0;i<1;i++){ R_143[i]=TX*R_043[i+1]; } for(int i=0;i<1;i++){ R_053[i]=TY*R_043[i+1]+4*R_033[i+1]; } for(int i=0;i<1;i++){ R_404[i]=TX*R_304[i+1]+3*R_204[i+1]; } for(int i=0;i<1;i++){ R_314[i]=TY*R_304[i+1]; } for(int i=0;i<1;i++){ R_224[i]=TZ*R_223[i+1]+3*R_222[i+1]; } for(int i=0;i<1;i++){ R_134[i]=TX*R_034[i+1]; } for(int i=0;i<1;i++){ R_044[i]=TY*R_034[i+1]+3*R_024[i+1]; } for(int i=0;i<1;i++){ R_305[i]=TZ*R_304[i+1]+4*R_303[i+1]; } for(int i=0;i<1;i++){ R_215[i]=TY*R_205[i+1]; } for(int i=0;i<1;i++){ R_125[i]=TX*R_025[i+1]; } for(int i=0;i<1;i++){ R_035[i]=TZ*R_034[i+1]+4*R_033[i+1]; } for(int i=0;i<1;i++){ R_206[i]=TZ*R_205[i+1]+5*R_204[i+1]; } for(int i=0;i<1;i++){ R_116[i]=TX*R_016[i+1]; } for(int i=0;i<1;i++){ R_026[i]=TZ*R_025[i+1]+5*R_024[i+1]; } for(int i=0;i<1;i++){ R_107[i]=TX*R_007[i+1]; } for(int i=0;i<1;i++){ R_017[i]=TY*R_007[i+1]; } for(int i=0;i<1;i++){ R_008[i]=TZ*R_007[i+1]+7*R_006[i+1]; } double Qd_101[3]; double Qd_002[3]; double Qd_102[3]; double Qd_202[3]; double Qd_110[3]; double Qd_011[3]; double Qd_111[3]; double Qd_211[3]; double Qd_012[3]; double Qd_112[3]; double Qd_212[3]; double Qd_312[3]; double Qd_020[3]; double Qd_120[3]; double Qd_220[3]; double Qd_021[3]; double Qd_121[3]; double Qd_221[3]; double Qd_321[3]; double Qd_022[3]; double Qd_122[3]; double Qd_222[3]; double Qd_322[3]; double Qd_422[3]; for(int i=0;i<3;i++){ Qd_101[i]=aQin1; } for(int i=0;i<3;i++){ Qd_002[i]=Qd_101[i]+Qd_001[i]*Qd_001[i]; } for(int i=0;i<3;i++){ Qd_102[i]=Qd_001[i]*Qd_101[i]+aQin1*Qd_001[i]; } for(int i=0;i<3;i++){ Qd_202[i]=aQin1*Qd_101[i]; } for(int i=0;i<3;i++){ Qd_110[i]=aQin1; } for(int i=0;i<3;i++){ Qd_011[i]=Qd_101[i]+Qd_010[i]*Qd_001[i]; } for(int i=0;i<3;i++){ Qd_111[i]=Qd_010[i]*Qd_101[i]+aQin1*Qd_001[i]; } for(int i=0;i<3;i++){ Qd_211[i]=aQin1*Qd_101[i]; } for(int i=0;i<3;i++){ Qd_012[i]=Qd_111[i]+Qd_001[i]*Qd_011[i]; } for(int i=0;i<3;i++){ Qd_112[i]=2*Qd_211[i]+Qd_001[i]*Qd_111[i]+aQin1*Qd_011[i]; } for(int i=0;i<3;i++){ Qd_212[i]=Qd_001[i]*Qd_211[i]+aQin1*Qd_111[i]; } for(int i=0;i<3;i++){ Qd_312[i]=aQin1*Qd_211[i]; } for(int i=0;i<3;i++){ Qd_020[i]=Qd_110[i]+Qd_010[i]*Qd_010[i]; } for(int i=0;i<3;i++){ Qd_120[i]=Qd_010[i]*Qd_110[i]+aQin1*Qd_010[i]; } for(int i=0;i<3;i++){ Qd_220[i]=aQin1*Qd_110[i]; } for(int i=0;i<3;i++){ Qd_021[i]=Qd_111[i]+Qd_010[i]*Qd_011[i]; } for(int i=0;i<3;i++){ Qd_121[i]=2*Qd_211[i]+Qd_010[i]*Qd_111[i]+aQin1*Qd_011[i]; } for(int i=0;i<3;i++){ Qd_221[i]=Qd_010[i]*Qd_211[i]+aQin1*Qd_111[i]; } for(int i=0;i<3;i++){ Qd_321[i]=aQin1*Qd_211[i]; } for(int i=0;i<3;i++){ Qd_022[i]=Qd_112[i]+Qd_010[i]*Qd_012[i]; } for(int i=0;i<3;i++){ Qd_122[i]=2*Qd_212[i]+Qd_010[i]*Qd_112[i]+aQin1*Qd_012[i]; } for(int i=0;i<3;i++){ Qd_222[i]=3*Qd_312[i]+Qd_010[i]*Qd_212[i]+aQin1*Qd_112[i]; } for(int i=0;i<3;i++){ Qd_322[i]=Qd_010[i]*Qd_312[i]+aQin1*Qd_212[i]; } for(int i=0;i<3;i++){ Qd_422[i]=aQin1*Qd_312[i]; } double Q_022000000=Qd_022[0]; double Q_122000000=Qd_122[0]; double Q_222000000=Qd_222[0]; double Q_322000000=Qd_322[0]; double Q_422000000=Qd_422[0]; double Q_021001000=Qd_021[0]*Qd_001[1]; double Q_021101000=Qd_021[0]*Qd_101[1]; double Q_121001000=Qd_121[0]*Qd_001[1]; double Q_121101000=Qd_121[0]*Qd_101[1]; double Q_221001000=Qd_221[0]*Qd_001[1]; double Q_221101000=Qd_221[0]*Qd_101[1]; double Q_321001000=Qd_321[0]*Qd_001[1]; double Q_321101000=Qd_321[0]*Qd_101[1]; double Q_020002000=Qd_020[0]*Qd_002[1]; double Q_020102000=Qd_020[0]*Qd_102[1]; double Q_020202000=Qd_020[0]*Qd_202[1]; double Q_120002000=Qd_120[0]*Qd_002[1]; double Q_120102000=Qd_120[0]*Qd_102[1]; double Q_120202000=Qd_120[0]*Qd_202[1]; double Q_220002000=Qd_220[0]*Qd_002[1]; double Q_220102000=Qd_220[0]*Qd_102[1]; double Q_220202000=Qd_220[0]*Qd_202[1]; double Q_021000001=Qd_021[0]*Qd_001[2]; double Q_021000101=Qd_021[0]*Qd_101[2]; double Q_121000001=Qd_121[0]*Qd_001[2]; double Q_121000101=Qd_121[0]*Qd_101[2]; double Q_221000001=Qd_221[0]*Qd_001[2]; double Q_221000101=Qd_221[0]*Qd_101[2]; double Q_321000001=Qd_321[0]*Qd_001[2]; double Q_321000101=Qd_321[0]*Qd_101[2]; double Q_020001001=Qd_020[0]*Qd_001[1]*Qd_001[2]; double Q_020001101=Qd_020[0]*Qd_001[1]*Qd_101[2]; double Q_020101001=Qd_020[0]*Qd_101[1]*Qd_001[2]; double Q_020101101=Qd_020[0]*Qd_101[1]*Qd_101[2]; double Q_120001001=Qd_120[0]*Qd_001[1]*Qd_001[2]; double Q_120001101=Qd_120[0]*Qd_001[1]*Qd_101[2]; double Q_120101001=Qd_120[0]*Qd_101[1]*Qd_001[2]; double Q_120101101=Qd_120[0]*Qd_101[1]*Qd_101[2]; double Q_220001001=Qd_220[0]*Qd_001[1]*Qd_001[2]; double Q_220001101=Qd_220[0]*Qd_001[1]*Qd_101[2]; double Q_220101001=Qd_220[0]*Qd_101[1]*Qd_001[2]; double Q_220101101=Qd_220[0]*Qd_101[1]*Qd_101[2]; double Q_020000002=Qd_020[0]*Qd_002[2]; double Q_020000102=Qd_020[0]*Qd_102[2]; double Q_020000202=Qd_020[0]*Qd_202[2]; double Q_120000002=Qd_120[0]*Qd_002[2]; double Q_120000102=Qd_120[0]*Qd_102[2]; double Q_120000202=Qd_120[0]*Qd_202[2]; double Q_220000002=Qd_220[0]*Qd_002[2]; double Q_220000102=Qd_220[0]*Qd_102[2]; double Q_220000202=Qd_220[0]*Qd_202[2]; double Q_012010000=Qd_012[0]*Qd_010[1]; double Q_012110000=Qd_012[0]*Qd_110[1]; double Q_112010000=Qd_112[0]*Qd_010[1]; double Q_112110000=Qd_112[0]*Qd_110[1]; double Q_212010000=Qd_212[0]*Qd_010[1]; double Q_212110000=Qd_212[0]*Qd_110[1]; double Q_312010000=Qd_312[0]*Qd_010[1]; double Q_312110000=Qd_312[0]*Qd_110[1]; double Q_011011000=Qd_011[0]*Qd_011[1]; double Q_011111000=Qd_011[0]*Qd_111[1]; double Q_011211000=Qd_011[0]*Qd_211[1]; double Q_111011000=Qd_111[0]*Qd_011[1]; double Q_111111000=Qd_111[0]*Qd_111[1]; double Q_111211000=Qd_111[0]*Qd_211[1]; double Q_211011000=Qd_211[0]*Qd_011[1]; double Q_211111000=Qd_211[0]*Qd_111[1]; double Q_211211000=Qd_211[0]*Qd_211[1]; double Q_010012000=Qd_010[0]*Qd_012[1]; double Q_010112000=Qd_010[0]*Qd_112[1]; double Q_010212000=Qd_010[0]*Qd_212[1]; double Q_010312000=Qd_010[0]*Qd_312[1]; double Q_110012000=Qd_110[0]*Qd_012[1]; double Q_110112000=Qd_110[0]*Qd_112[1]; double Q_110212000=Qd_110[0]*Qd_212[1]; double Q_110312000=Qd_110[0]*Qd_312[1]; double Q_011010001=Qd_011[0]*Qd_010[1]*Qd_001[2]; double Q_011010101=Qd_011[0]*Qd_010[1]*Qd_101[2]; double Q_011110001=Qd_011[0]*Qd_110[1]*Qd_001[2]; double Q_011110101=Qd_011[0]*Qd_110[1]*Qd_101[2]; double Q_111010001=Qd_111[0]*Qd_010[1]*Qd_001[2]; double Q_111010101=Qd_111[0]*Qd_010[1]*Qd_101[2]; double Q_111110001=Qd_111[0]*Qd_110[1]*Qd_001[2]; double Q_111110101=Qd_111[0]*Qd_110[1]*Qd_101[2]; double Q_211010001=Qd_211[0]*Qd_010[1]*Qd_001[2]; double Q_211010101=Qd_211[0]*Qd_010[1]*Qd_101[2]; double Q_211110001=Qd_211[0]*Qd_110[1]*Qd_001[2]; double Q_211110101=Qd_211[0]*Qd_110[1]*Qd_101[2]; double Q_010011001=Qd_010[0]*Qd_011[1]*Qd_001[2]; double Q_010011101=Qd_010[0]*Qd_011[1]*Qd_101[2]; double Q_010111001=Qd_010[0]*Qd_111[1]*Qd_001[2]; double Q_010111101=Qd_010[0]*Qd_111[1]*Qd_101[2]; double Q_010211001=Qd_010[0]*Qd_211[1]*Qd_001[2]; double Q_010211101=Qd_010[0]*Qd_211[1]*Qd_101[2]; double Q_110011001=Qd_110[0]*Qd_011[1]*Qd_001[2]; double Q_110011101=Qd_110[0]*Qd_011[1]*Qd_101[2]; double Q_110111001=Qd_110[0]*Qd_111[1]*Qd_001[2]; double Q_110111101=Qd_110[0]*Qd_111[1]*Qd_101[2]; double Q_110211001=Qd_110[0]*Qd_211[1]*Qd_001[2]; double Q_110211101=Qd_110[0]*Qd_211[1]*Qd_101[2]; double Q_010010002=Qd_010[0]*Qd_010[1]*Qd_002[2]; double Q_010010102=Qd_010[0]*Qd_010[1]*Qd_102[2]; double Q_010010202=Qd_010[0]*Qd_010[1]*Qd_202[2]; double Q_010110002=Qd_010[0]*Qd_110[1]*Qd_002[2]; double Q_010110102=Qd_010[0]*Qd_110[1]*Qd_102[2]; double Q_010110202=Qd_010[0]*Qd_110[1]*Qd_202[2]; double Q_110010002=Qd_110[0]*Qd_010[1]*Qd_002[2]; double Q_110010102=Qd_110[0]*Qd_010[1]*Qd_102[2]; double Q_110010202=Qd_110[0]*Qd_010[1]*Qd_202[2]; double Q_110110002=Qd_110[0]*Qd_110[1]*Qd_002[2]; double Q_110110102=Qd_110[0]*Qd_110[1]*Qd_102[2]; double Q_110110202=Qd_110[0]*Qd_110[1]*Qd_202[2]; double Q_002020000=Qd_002[0]*Qd_020[1]; double Q_002120000=Qd_002[0]*Qd_120[1]; double Q_002220000=Qd_002[0]*Qd_220[1]; double Q_102020000=Qd_102[0]*Qd_020[1]; double Q_102120000=Qd_102[0]*Qd_120[1]; double Q_102220000=Qd_102[0]*Qd_220[1]; double Q_202020000=Qd_202[0]*Qd_020[1]; double Q_202120000=Qd_202[0]*Qd_120[1]; double Q_202220000=Qd_202[0]*Qd_220[1]; double Q_001021000=Qd_001[0]*Qd_021[1]; double Q_001121000=Qd_001[0]*Qd_121[1]; double Q_001221000=Qd_001[0]*Qd_221[1]; double Q_001321000=Qd_001[0]*Qd_321[1]; double Q_101021000=Qd_101[0]*Qd_021[1]; double Q_101121000=Qd_101[0]*Qd_121[1]; double Q_101221000=Qd_101[0]*Qd_221[1]; double Q_101321000=Qd_101[0]*Qd_321[1]; double Q_000022000=Qd_022[1]; double Q_000122000=Qd_122[1]; double Q_000222000=Qd_222[1]; double Q_000322000=Qd_322[1]; double Q_000422000=Qd_422[1]; double Q_001020001=Qd_001[0]*Qd_020[1]*Qd_001[2]; double Q_001020101=Qd_001[0]*Qd_020[1]*Qd_101[2]; double Q_001120001=Qd_001[0]*Qd_120[1]*Qd_001[2]; double Q_001120101=Qd_001[0]*Qd_120[1]*Qd_101[2]; double Q_001220001=Qd_001[0]*Qd_220[1]*Qd_001[2]; double Q_001220101=Qd_001[0]*Qd_220[1]*Qd_101[2]; double Q_101020001=Qd_101[0]*Qd_020[1]*Qd_001[2]; double Q_101020101=Qd_101[0]*Qd_020[1]*Qd_101[2]; double Q_101120001=Qd_101[0]*Qd_120[1]*Qd_001[2]; double Q_101120101=Qd_101[0]*Qd_120[1]*Qd_101[2]; double Q_101220001=Qd_101[0]*Qd_220[1]*Qd_001[2]; double Q_101220101=Qd_101[0]*Qd_220[1]*Qd_101[2]; double Q_000021001=Qd_021[1]*Qd_001[2]; double Q_000021101=Qd_021[1]*Qd_101[2]; double Q_000121001=Qd_121[1]*Qd_001[2]; double Q_000121101=Qd_121[1]*Qd_101[2]; double Q_000221001=Qd_221[1]*Qd_001[2]; double Q_000221101=Qd_221[1]*Qd_101[2]; double Q_000321001=Qd_321[1]*Qd_001[2]; double Q_000321101=Qd_321[1]*Qd_101[2]; double Q_000020002=Qd_020[1]*Qd_002[2]; double Q_000020102=Qd_020[1]*Qd_102[2]; double Q_000020202=Qd_020[1]*Qd_202[2]; double Q_000120002=Qd_120[1]*Qd_002[2]; double Q_000120102=Qd_120[1]*Qd_102[2]; double Q_000120202=Qd_120[1]*Qd_202[2]; double Q_000220002=Qd_220[1]*Qd_002[2]; double Q_000220102=Qd_220[1]*Qd_102[2]; double Q_000220202=Qd_220[1]*Qd_202[2]; double Q_012000010=Qd_012[0]*Qd_010[2]; double Q_012000110=Qd_012[0]*Qd_110[2]; double Q_112000010=Qd_112[0]*Qd_010[2]; double Q_112000110=Qd_112[0]*Qd_110[2]; double Q_212000010=Qd_212[0]*Qd_010[2]; double Q_212000110=Qd_212[0]*Qd_110[2]; double Q_312000010=Qd_312[0]*Qd_010[2]; double Q_312000110=Qd_312[0]*Qd_110[2]; double Q_011001010=Qd_011[0]*Qd_001[1]*Qd_010[2]; double Q_011001110=Qd_011[0]*Qd_001[1]*Qd_110[2]; double Q_011101010=Qd_011[0]*Qd_101[1]*Qd_010[2]; double Q_011101110=Qd_011[0]*Qd_101[1]*Qd_110[2]; double Q_111001010=Qd_111[0]*Qd_001[1]*Qd_010[2]; double Q_111001110=Qd_111[0]*Qd_001[1]*Qd_110[2]; double Q_111101010=Qd_111[0]*Qd_101[1]*Qd_010[2]; double Q_111101110=Qd_111[0]*Qd_101[1]*Qd_110[2]; double Q_211001010=Qd_211[0]*Qd_001[1]*Qd_010[2]; double Q_211001110=Qd_211[0]*Qd_001[1]*Qd_110[2]; double Q_211101010=Qd_211[0]*Qd_101[1]*Qd_010[2]; double Q_211101110=Qd_211[0]*Qd_101[1]*Qd_110[2]; double Q_010002010=Qd_010[0]*Qd_002[1]*Qd_010[2]; double Q_010002110=Qd_010[0]*Qd_002[1]*Qd_110[2]; double Q_010102010=Qd_010[0]*Qd_102[1]*Qd_010[2]; double Q_010102110=Qd_010[0]*Qd_102[1]*Qd_110[2]; double Q_010202010=Qd_010[0]*Qd_202[1]*Qd_010[2]; double Q_010202110=Qd_010[0]*Qd_202[1]*Qd_110[2]; double Q_110002010=Qd_110[0]*Qd_002[1]*Qd_010[2]; double Q_110002110=Qd_110[0]*Qd_002[1]*Qd_110[2]; double Q_110102010=Qd_110[0]*Qd_102[1]*Qd_010[2]; double Q_110102110=Qd_110[0]*Qd_102[1]*Qd_110[2]; double Q_110202010=Qd_110[0]*Qd_202[1]*Qd_010[2]; double Q_110202110=Qd_110[0]*Qd_202[1]*Qd_110[2]; double Q_011000011=Qd_011[0]*Qd_011[2]; double Q_011000111=Qd_011[0]*Qd_111[2]; double Q_011000211=Qd_011[0]*Qd_211[2]; double Q_111000011=Qd_111[0]*Qd_011[2]; double Q_111000111=Qd_111[0]*Qd_111[2]; double Q_111000211=Qd_111[0]*Qd_211[2]; double Q_211000011=Qd_211[0]*Qd_011[2]; double Q_211000111=Qd_211[0]*Qd_111[2]; double Q_211000211=Qd_211[0]*Qd_211[2]; double Q_010001011=Qd_010[0]*Qd_001[1]*Qd_011[2]; double Q_010001111=Qd_010[0]*Qd_001[1]*Qd_111[2]; double Q_010001211=Qd_010[0]*Qd_001[1]*Qd_211[2]; double Q_010101011=Qd_010[0]*Qd_101[1]*Qd_011[2]; double Q_010101111=Qd_010[0]*Qd_101[1]*Qd_111[2]; double Q_010101211=Qd_010[0]*Qd_101[1]*Qd_211[2]; double Q_110001011=Qd_110[0]*Qd_001[1]*Qd_011[2]; double Q_110001111=Qd_110[0]*Qd_001[1]*Qd_111[2]; double Q_110001211=Qd_110[0]*Qd_001[1]*Qd_211[2]; double Q_110101011=Qd_110[0]*Qd_101[1]*Qd_011[2]; double Q_110101111=Qd_110[0]*Qd_101[1]*Qd_111[2]; double Q_110101211=Qd_110[0]*Qd_101[1]*Qd_211[2]; double Q_010000012=Qd_010[0]*Qd_012[2]; double Q_010000112=Qd_010[0]*Qd_112[2]; double Q_010000212=Qd_010[0]*Qd_212[2]; double Q_010000312=Qd_010[0]*Qd_312[2]; double Q_110000012=Qd_110[0]*Qd_012[2]; double Q_110000112=Qd_110[0]*Qd_112[2]; double Q_110000212=Qd_110[0]*Qd_212[2]; double Q_110000312=Qd_110[0]*Qd_312[2]; double Q_002010010=Qd_002[0]*Qd_010[1]*Qd_010[2]; double Q_002010110=Qd_002[0]*Qd_010[1]*Qd_110[2]; double Q_002110010=Qd_002[0]*Qd_110[1]*Qd_010[2]; double Q_002110110=Qd_002[0]*Qd_110[1]*Qd_110[2]; double Q_102010010=Qd_102[0]*Qd_010[1]*Qd_010[2]; double Q_102010110=Qd_102[0]*Qd_010[1]*Qd_110[2]; double Q_102110010=Qd_102[0]*Qd_110[1]*Qd_010[2]; double Q_102110110=Qd_102[0]*Qd_110[1]*Qd_110[2]; double Q_202010010=Qd_202[0]*Qd_010[1]*Qd_010[2]; double Q_202010110=Qd_202[0]*Qd_010[1]*Qd_110[2]; double Q_202110010=Qd_202[0]*Qd_110[1]*Qd_010[2]; double Q_202110110=Qd_202[0]*Qd_110[1]*Qd_110[2]; double Q_001011010=Qd_001[0]*Qd_011[1]*Qd_010[2]; double Q_001011110=Qd_001[0]*Qd_011[1]*Qd_110[2]; double Q_001111010=Qd_001[0]*Qd_111[1]*Qd_010[2]; double Q_001111110=Qd_001[0]*Qd_111[1]*Qd_110[2]; double Q_001211010=Qd_001[0]*Qd_211[1]*Qd_010[2]; double Q_001211110=Qd_001[0]*Qd_211[1]*Qd_110[2]; double Q_101011010=Qd_101[0]*Qd_011[1]*Qd_010[2]; double Q_101011110=Qd_101[0]*Qd_011[1]*Qd_110[2]; double Q_101111010=Qd_101[0]*Qd_111[1]*Qd_010[2]; double Q_101111110=Qd_101[0]*Qd_111[1]*Qd_110[2]; double Q_101211010=Qd_101[0]*Qd_211[1]*Qd_010[2]; double Q_101211110=Qd_101[0]*Qd_211[1]*Qd_110[2]; double Q_000012010=Qd_012[1]*Qd_010[2]; double Q_000012110=Qd_012[1]*Qd_110[2]; double Q_000112010=Qd_112[1]*Qd_010[2]; double Q_000112110=Qd_112[1]*Qd_110[2]; double Q_000212010=Qd_212[1]*Qd_010[2]; double Q_000212110=Qd_212[1]*Qd_110[2]; double Q_000312010=Qd_312[1]*Qd_010[2]; double Q_000312110=Qd_312[1]*Qd_110[2]; double Q_001010011=Qd_001[0]*Qd_010[1]*Qd_011[2]; double Q_001010111=Qd_001[0]*Qd_010[1]*Qd_111[2]; double Q_001010211=Qd_001[0]*Qd_010[1]*Qd_211[2]; double Q_001110011=Qd_001[0]*Qd_110[1]*Qd_011[2]; double Q_001110111=Qd_001[0]*Qd_110[1]*Qd_111[2]; double Q_001110211=Qd_001[0]*Qd_110[1]*Qd_211[2]; double Q_101010011=Qd_101[0]*Qd_010[1]*Qd_011[2]; double Q_101010111=Qd_101[0]*Qd_010[1]*Qd_111[2]; double Q_101010211=Qd_101[0]*Qd_010[1]*Qd_211[2]; double Q_101110011=Qd_101[0]*Qd_110[1]*Qd_011[2]; double Q_101110111=Qd_101[0]*Qd_110[1]*Qd_111[2]; double Q_101110211=Qd_101[0]*Qd_110[1]*Qd_211[2]; double Q_000011011=Qd_011[1]*Qd_011[2]; double Q_000011111=Qd_011[1]*Qd_111[2]; double Q_000011211=Qd_011[1]*Qd_211[2]; double Q_000111011=Qd_111[1]*Qd_011[2]; double Q_000111111=Qd_111[1]*Qd_111[2]; double Q_000111211=Qd_111[1]*Qd_211[2]; double Q_000211011=Qd_211[1]*Qd_011[2]; double Q_000211111=Qd_211[1]*Qd_111[2]; double Q_000211211=Qd_211[1]*Qd_211[2]; double Q_000010012=Qd_010[1]*Qd_012[2]; double Q_000010112=Qd_010[1]*Qd_112[2]; double Q_000010212=Qd_010[1]*Qd_212[2]; double Q_000010312=Qd_010[1]*Qd_312[2]; double Q_000110012=Qd_110[1]*Qd_012[2]; double Q_000110112=Qd_110[1]*Qd_112[2]; double Q_000110212=Qd_110[1]*Qd_212[2]; double Q_000110312=Qd_110[1]*Qd_312[2]; double Q_002000020=Qd_002[0]*Qd_020[2]; double Q_002000120=Qd_002[0]*Qd_120[2]; double Q_002000220=Qd_002[0]*Qd_220[2]; double Q_102000020=Qd_102[0]*Qd_020[2]; double Q_102000120=Qd_102[0]*Qd_120[2]; double Q_102000220=Qd_102[0]*Qd_220[2]; double Q_202000020=Qd_202[0]*Qd_020[2]; double Q_202000120=Qd_202[0]*Qd_120[2]; double Q_202000220=Qd_202[0]*Qd_220[2]; double Q_001001020=Qd_001[0]*Qd_001[1]*Qd_020[2]; double Q_001001120=Qd_001[0]*Qd_001[1]*Qd_120[2]; double Q_001001220=Qd_001[0]*Qd_001[1]*Qd_220[2]; double Q_001101020=Qd_001[0]*Qd_101[1]*Qd_020[2]; double Q_001101120=Qd_001[0]*Qd_101[1]*Qd_120[2]; double Q_001101220=Qd_001[0]*Qd_101[1]*Qd_220[2]; double Q_101001020=Qd_101[0]*Qd_001[1]*Qd_020[2]; double Q_101001120=Qd_101[0]*Qd_001[1]*Qd_120[2]; double Q_101001220=Qd_101[0]*Qd_001[1]*Qd_220[2]; double Q_101101020=Qd_101[0]*Qd_101[1]*Qd_020[2]; double Q_101101120=Qd_101[0]*Qd_101[1]*Qd_120[2]; double Q_101101220=Qd_101[0]*Qd_101[1]*Qd_220[2]; double Q_000002020=Qd_002[1]*Qd_020[2]; double Q_000002120=Qd_002[1]*Qd_120[2]; double Q_000002220=Qd_002[1]*Qd_220[2]; double Q_000102020=Qd_102[1]*Qd_020[2]; double Q_000102120=Qd_102[1]*Qd_120[2]; double Q_000102220=Qd_102[1]*Qd_220[2]; double Q_000202020=Qd_202[1]*Qd_020[2]; double Q_000202120=Qd_202[1]*Qd_120[2]; double Q_000202220=Qd_202[1]*Qd_220[2]; double Q_001000021=Qd_001[0]*Qd_021[2]; double Q_001000121=Qd_001[0]*Qd_121[2]; double Q_001000221=Qd_001[0]*Qd_221[2]; double Q_001000321=Qd_001[0]*Qd_321[2]; double Q_101000021=Qd_101[0]*Qd_021[2]; double Q_101000121=Qd_101[0]*Qd_121[2]; double Q_101000221=Qd_101[0]*Qd_221[2]; double Q_101000321=Qd_101[0]*Qd_321[2]; double Q_000001021=Qd_001[1]*Qd_021[2]; double Q_000001121=Qd_001[1]*Qd_121[2]; double Q_000001221=Qd_001[1]*Qd_221[2]; double Q_000001321=Qd_001[1]*Qd_321[2]; double Q_000101021=Qd_101[1]*Qd_021[2]; double Q_000101121=Qd_101[1]*Qd_121[2]; double Q_000101221=Qd_101[1]*Qd_221[2]; double Q_000101321=Qd_101[1]*Qd_321[2]; double Q_000000022=Qd_022[2]; double Q_000000122=Qd_122[2]; double Q_000000222=Qd_222[2]; double Q_000000322=Qd_322[2]; double Q_000000422=Qd_422[2]; double QR_022000000000=Q_022000000*R_000[0]+-1*Q_122000000*R_100[0]+Q_222000000*R_200[0]+-1*Q_322000000*R_300[0]+Q_422000000*R_400[0]; double QR_021001000000=Q_021001000*R_000[0]+-1*Q_021101000*R_010[0]+-1*Q_121001000*R_100[0]+Q_121101000*R_110[0]+Q_221001000*R_200[0]+-1*Q_221101000*R_210[0]+-1*Q_321001000*R_300[0]+Q_321101000*R_310[0]; double QR_020002000000=Q_020002000*R_000[0]+-1*Q_020102000*R_010[0]+Q_020202000*R_020[0]+-1*Q_120002000*R_100[0]+Q_120102000*R_110[0]+-1*Q_120202000*R_120[0]+Q_220002000*R_200[0]+-1*Q_220102000*R_210[0]+Q_220202000*R_220[0]; double QR_021000001000=Q_021000001*R_000[0]+-1*Q_021000101*R_001[0]+-1*Q_121000001*R_100[0]+Q_121000101*R_101[0]+Q_221000001*R_200[0]+-1*Q_221000101*R_201[0]+-1*Q_321000001*R_300[0]+Q_321000101*R_301[0]; double QR_020001001000=Q_020001001*R_000[0]+-1*Q_020001101*R_001[0]+-1*Q_020101001*R_010[0]+Q_020101101*R_011[0]+-1*Q_120001001*R_100[0]+Q_120001101*R_101[0]+Q_120101001*R_110[0]+-1*Q_120101101*R_111[0]+Q_220001001*R_200[0]+-1*Q_220001101*R_201[0]+-1*Q_220101001*R_210[0]+Q_220101101*R_211[0]; double QR_020000002000=Q_020000002*R_000[0]+-1*Q_020000102*R_001[0]+Q_020000202*R_002[0]+-1*Q_120000002*R_100[0]+Q_120000102*R_101[0]+-1*Q_120000202*R_102[0]+Q_220000002*R_200[0]+-1*Q_220000102*R_201[0]+Q_220000202*R_202[0]; double QR_012010000000=Q_012010000*R_000[0]+-1*Q_012110000*R_010[0]+-1*Q_112010000*R_100[0]+Q_112110000*R_110[0]+Q_212010000*R_200[0]+-1*Q_212110000*R_210[0]+-1*Q_312010000*R_300[0]+Q_312110000*R_310[0]; double QR_011011000000=Q_011011000*R_000[0]+-1*Q_011111000*R_010[0]+Q_011211000*R_020[0]+-1*Q_111011000*R_100[0]+Q_111111000*R_110[0]+-1*Q_111211000*R_120[0]+Q_211011000*R_200[0]+-1*Q_211111000*R_210[0]+Q_211211000*R_220[0]; double QR_010012000000=Q_010012000*R_000[0]+-1*Q_010112000*R_010[0]+Q_010212000*R_020[0]+-1*Q_010312000*R_030[0]+-1*Q_110012000*R_100[0]+Q_110112000*R_110[0]+-1*Q_110212000*R_120[0]+Q_110312000*R_130[0]; double QR_011010001000=Q_011010001*R_000[0]+-1*Q_011010101*R_001[0]+-1*Q_011110001*R_010[0]+Q_011110101*R_011[0]+-1*Q_111010001*R_100[0]+Q_111010101*R_101[0]+Q_111110001*R_110[0]+-1*Q_111110101*R_111[0]+Q_211010001*R_200[0]+-1*Q_211010101*R_201[0]+-1*Q_211110001*R_210[0]+Q_211110101*R_211[0]; double QR_010011001000=Q_010011001*R_000[0]+-1*Q_010011101*R_001[0]+-1*Q_010111001*R_010[0]+Q_010111101*R_011[0]+Q_010211001*R_020[0]+-1*Q_010211101*R_021[0]+-1*Q_110011001*R_100[0]+Q_110011101*R_101[0]+Q_110111001*R_110[0]+-1*Q_110111101*R_111[0]+-1*Q_110211001*R_120[0]+Q_110211101*R_121[0]; double QR_010010002000=Q_010010002*R_000[0]+-1*Q_010010102*R_001[0]+Q_010010202*R_002[0]+-1*Q_010110002*R_010[0]+Q_010110102*R_011[0]+-1*Q_010110202*R_012[0]+-1*Q_110010002*R_100[0]+Q_110010102*R_101[0]+-1*Q_110010202*R_102[0]+Q_110110002*R_110[0]+-1*Q_110110102*R_111[0]+Q_110110202*R_112[0]; double QR_002020000000=Q_002020000*R_000[0]+-1*Q_002120000*R_010[0]+Q_002220000*R_020[0]+-1*Q_102020000*R_100[0]+Q_102120000*R_110[0]+-1*Q_102220000*R_120[0]+Q_202020000*R_200[0]+-1*Q_202120000*R_210[0]+Q_202220000*R_220[0]; double QR_001021000000=Q_001021000*R_000[0]+-1*Q_001121000*R_010[0]+Q_001221000*R_020[0]+-1*Q_001321000*R_030[0]+-1*Q_101021000*R_100[0]+Q_101121000*R_110[0]+-1*Q_101221000*R_120[0]+Q_101321000*R_130[0]; double QR_000022000000=Q_000022000*R_000[0]+-1*Q_000122000*R_010[0]+Q_000222000*R_020[0]+-1*Q_000322000*R_030[0]+Q_000422000*R_040[0]; double QR_001020001000=Q_001020001*R_000[0]+-1*Q_001020101*R_001[0]+-1*Q_001120001*R_010[0]+Q_001120101*R_011[0]+Q_001220001*R_020[0]+-1*Q_001220101*R_021[0]+-1*Q_101020001*R_100[0]+Q_101020101*R_101[0]+Q_101120001*R_110[0]+-1*Q_101120101*R_111[0]+-1*Q_101220001*R_120[0]+Q_101220101*R_121[0]; double QR_000021001000=Q_000021001*R_000[0]+-1*Q_000021101*R_001[0]+-1*Q_000121001*R_010[0]+Q_000121101*R_011[0]+Q_000221001*R_020[0]+-1*Q_000221101*R_021[0]+-1*Q_000321001*R_030[0]+Q_000321101*R_031[0]; double QR_000020002000=Q_000020002*R_000[0]+-1*Q_000020102*R_001[0]+Q_000020202*R_002[0]+-1*Q_000120002*R_010[0]+Q_000120102*R_011[0]+-1*Q_000120202*R_012[0]+Q_000220002*R_020[0]+-1*Q_000220102*R_021[0]+Q_000220202*R_022[0]; double QR_012000010000=Q_012000010*R_000[0]+-1*Q_012000110*R_001[0]+-1*Q_112000010*R_100[0]+Q_112000110*R_101[0]+Q_212000010*R_200[0]+-1*Q_212000110*R_201[0]+-1*Q_312000010*R_300[0]+Q_312000110*R_301[0]; double QR_011001010000=Q_011001010*R_000[0]+-1*Q_011001110*R_001[0]+-1*Q_011101010*R_010[0]+Q_011101110*R_011[0]+-1*Q_111001010*R_100[0]+Q_111001110*R_101[0]+Q_111101010*R_110[0]+-1*Q_111101110*R_111[0]+Q_211001010*R_200[0]+-1*Q_211001110*R_201[0]+-1*Q_211101010*R_210[0]+Q_211101110*R_211[0]; double QR_010002010000=Q_010002010*R_000[0]+-1*Q_010002110*R_001[0]+-1*Q_010102010*R_010[0]+Q_010102110*R_011[0]+Q_010202010*R_020[0]+-1*Q_010202110*R_021[0]+-1*Q_110002010*R_100[0]+Q_110002110*R_101[0]+Q_110102010*R_110[0]+-1*Q_110102110*R_111[0]+-1*Q_110202010*R_120[0]+Q_110202110*R_121[0]; double QR_011000011000=Q_011000011*R_000[0]+-1*Q_011000111*R_001[0]+Q_011000211*R_002[0]+-1*Q_111000011*R_100[0]+Q_111000111*R_101[0]+-1*Q_111000211*R_102[0]+Q_211000011*R_200[0]+-1*Q_211000111*R_201[0]+Q_211000211*R_202[0]; double QR_010001011000=Q_010001011*R_000[0]+-1*Q_010001111*R_001[0]+Q_010001211*R_002[0]+-1*Q_010101011*R_010[0]+Q_010101111*R_011[0]+-1*Q_010101211*R_012[0]+-1*Q_110001011*R_100[0]+Q_110001111*R_101[0]+-1*Q_110001211*R_102[0]+Q_110101011*R_110[0]+-1*Q_110101111*R_111[0]+Q_110101211*R_112[0]; double QR_010000012000=Q_010000012*R_000[0]+-1*Q_010000112*R_001[0]+Q_010000212*R_002[0]+-1*Q_010000312*R_003[0]+-1*Q_110000012*R_100[0]+Q_110000112*R_101[0]+-1*Q_110000212*R_102[0]+Q_110000312*R_103[0]; double QR_002010010000=Q_002010010*R_000[0]+-1*Q_002010110*R_001[0]+-1*Q_002110010*R_010[0]+Q_002110110*R_011[0]+-1*Q_102010010*R_100[0]+Q_102010110*R_101[0]+Q_102110010*R_110[0]+-1*Q_102110110*R_111[0]+Q_202010010*R_200[0]+-1*Q_202010110*R_201[0]+-1*Q_202110010*R_210[0]+Q_202110110*R_211[0]; double QR_001011010000=Q_001011010*R_000[0]+-1*Q_001011110*R_001[0]+-1*Q_001111010*R_010[0]+Q_001111110*R_011[0]+Q_001211010*R_020[0]+-1*Q_001211110*R_021[0]+-1*Q_101011010*R_100[0]+Q_101011110*R_101[0]+Q_101111010*R_110[0]+-1*Q_101111110*R_111[0]+-1*Q_101211010*R_120[0]+Q_101211110*R_121[0]; double QR_000012010000=Q_000012010*R_000[0]+-1*Q_000012110*R_001[0]+-1*Q_000112010*R_010[0]+Q_000112110*R_011[0]+Q_000212010*R_020[0]+-1*Q_000212110*R_021[0]+-1*Q_000312010*R_030[0]+Q_000312110*R_031[0]; double QR_001010011000=Q_001010011*R_000[0]+-1*Q_001010111*R_001[0]+Q_001010211*R_002[0]+-1*Q_001110011*R_010[0]+Q_001110111*R_011[0]+-1*Q_001110211*R_012[0]+-1*Q_101010011*R_100[0]+Q_101010111*R_101[0]+-1*Q_101010211*R_102[0]+Q_101110011*R_110[0]+-1*Q_101110111*R_111[0]+Q_101110211*R_112[0]; double QR_000011011000=Q_000011011*R_000[0]+-1*Q_000011111*R_001[0]+Q_000011211*R_002[0]+-1*Q_000111011*R_010[0]+Q_000111111*R_011[0]+-1*Q_000111211*R_012[0]+Q_000211011*R_020[0]+-1*Q_000211111*R_021[0]+Q_000211211*R_022[0]; double QR_000010012000=Q_000010012*R_000[0]+-1*Q_000010112*R_001[0]+Q_000010212*R_002[0]+-1*Q_000010312*R_003[0]+-1*Q_000110012*R_010[0]+Q_000110112*R_011[0]+-1*Q_000110212*R_012[0]+Q_000110312*R_013[0]; double QR_002000020000=Q_002000020*R_000[0]+-1*Q_002000120*R_001[0]+Q_002000220*R_002[0]+-1*Q_102000020*R_100[0]+Q_102000120*R_101[0]+-1*Q_102000220*R_102[0]+Q_202000020*R_200[0]+-1*Q_202000120*R_201[0]+Q_202000220*R_202[0]; double QR_001001020000=Q_001001020*R_000[0]+-1*Q_001001120*R_001[0]+Q_001001220*R_002[0]+-1*Q_001101020*R_010[0]+Q_001101120*R_011[0]+-1*Q_001101220*R_012[0]+-1*Q_101001020*R_100[0]+Q_101001120*R_101[0]+-1*Q_101001220*R_102[0]+Q_101101020*R_110[0]+-1*Q_101101120*R_111[0]+Q_101101220*R_112[0]; double QR_000002020000=Q_000002020*R_000[0]+-1*Q_000002120*R_001[0]+Q_000002220*R_002[0]+-1*Q_000102020*R_010[0]+Q_000102120*R_011[0]+-1*Q_000102220*R_012[0]+Q_000202020*R_020[0]+-1*Q_000202120*R_021[0]+Q_000202220*R_022[0]; double QR_001000021000=Q_001000021*R_000[0]+-1*Q_001000121*R_001[0]+Q_001000221*R_002[0]+-1*Q_001000321*R_003[0]+-1*Q_101000021*R_100[0]+Q_101000121*R_101[0]+-1*Q_101000221*R_102[0]+Q_101000321*R_103[0]; double QR_000001021000=Q_000001021*R_000[0]+-1*Q_000001121*R_001[0]+Q_000001221*R_002[0]+-1*Q_000001321*R_003[0]+-1*Q_000101021*R_010[0]+Q_000101121*R_011[0]+-1*Q_000101221*R_012[0]+Q_000101321*R_013[0]; double QR_000000022000=Q_000000022*R_000[0]+-1*Q_000000122*R_001[0]+Q_000000222*R_002[0]+-1*Q_000000322*R_003[0]+Q_000000422*R_004[0]; double QR_022000000001=Q_022000000*R_001[0]+-1*Q_122000000*R_101[0]+Q_222000000*R_201[0]+-1*Q_322000000*R_301[0]+Q_422000000*R_401[0]; double QR_021001000001=Q_021001000*R_001[0]+-1*Q_021101000*R_011[0]+-1*Q_121001000*R_101[0]+Q_121101000*R_111[0]+Q_221001000*R_201[0]+-1*Q_221101000*R_211[0]+-1*Q_321001000*R_301[0]+Q_321101000*R_311[0]; double QR_020002000001=Q_020002000*R_001[0]+-1*Q_020102000*R_011[0]+Q_020202000*R_021[0]+-1*Q_120002000*R_101[0]+Q_120102000*R_111[0]+-1*Q_120202000*R_121[0]+Q_220002000*R_201[0]+-1*Q_220102000*R_211[0]+Q_220202000*R_221[0]; double QR_021000001001=Q_021000001*R_001[0]+-1*Q_021000101*R_002[0]+-1*Q_121000001*R_101[0]+Q_121000101*R_102[0]+Q_221000001*R_201[0]+-1*Q_221000101*R_202[0]+-1*Q_321000001*R_301[0]+Q_321000101*R_302[0]; double QR_020001001001=Q_020001001*R_001[0]+-1*Q_020001101*R_002[0]+-1*Q_020101001*R_011[0]+Q_020101101*R_012[0]+-1*Q_120001001*R_101[0]+Q_120001101*R_102[0]+Q_120101001*R_111[0]+-1*Q_120101101*R_112[0]+Q_220001001*R_201[0]+-1*Q_220001101*R_202[0]+-1*Q_220101001*R_211[0]+Q_220101101*R_212[0]; double QR_020000002001=Q_020000002*R_001[0]+-1*Q_020000102*R_002[0]+Q_020000202*R_003[0]+-1*Q_120000002*R_101[0]+Q_120000102*R_102[0]+-1*Q_120000202*R_103[0]+Q_220000002*R_201[0]+-1*Q_220000102*R_202[0]+Q_220000202*R_203[0]; double QR_012010000001=Q_012010000*R_001[0]+-1*Q_012110000*R_011[0]+-1*Q_112010000*R_101[0]+Q_112110000*R_111[0]+Q_212010000*R_201[0]+-1*Q_212110000*R_211[0]+-1*Q_312010000*R_301[0]+Q_312110000*R_311[0]; double QR_011011000001=Q_011011000*R_001[0]+-1*Q_011111000*R_011[0]+Q_011211000*R_021[0]+-1*Q_111011000*R_101[0]+Q_111111000*R_111[0]+-1*Q_111211000*R_121[0]+Q_211011000*R_201[0]+-1*Q_211111000*R_211[0]+Q_211211000*R_221[0]; double QR_010012000001=Q_010012000*R_001[0]+-1*Q_010112000*R_011[0]+Q_010212000*R_021[0]+-1*Q_010312000*R_031[0]+-1*Q_110012000*R_101[0]+Q_110112000*R_111[0]+-1*Q_110212000*R_121[0]+Q_110312000*R_131[0]; double QR_011010001001=Q_011010001*R_001[0]+-1*Q_011010101*R_002[0]+-1*Q_011110001*R_011[0]+Q_011110101*R_012[0]+-1*Q_111010001*R_101[0]+Q_111010101*R_102[0]+Q_111110001*R_111[0]+-1*Q_111110101*R_112[0]+Q_211010001*R_201[0]+-1*Q_211010101*R_202[0]+-1*Q_211110001*R_211[0]+Q_211110101*R_212[0]; double QR_010011001001=Q_010011001*R_001[0]+-1*Q_010011101*R_002[0]+-1*Q_010111001*R_011[0]+Q_010111101*R_012[0]+Q_010211001*R_021[0]+-1*Q_010211101*R_022[0]+-1*Q_110011001*R_101[0]+Q_110011101*R_102[0]+Q_110111001*R_111[0]+-1*Q_110111101*R_112[0]+-1*Q_110211001*R_121[0]+Q_110211101*R_122[0]; double QR_010010002001=Q_010010002*R_001[0]+-1*Q_010010102*R_002[0]+Q_010010202*R_003[0]+-1*Q_010110002*R_011[0]+Q_010110102*R_012[0]+-1*Q_010110202*R_013[0]+-1*Q_110010002*R_101[0]+Q_110010102*R_102[0]+-1*Q_110010202*R_103[0]+Q_110110002*R_111[0]+-1*Q_110110102*R_112[0]+Q_110110202*R_113[0]; double QR_002020000001=Q_002020000*R_001[0]+-1*Q_002120000*R_011[0]+Q_002220000*R_021[0]+-1*Q_102020000*R_101[0]+Q_102120000*R_111[0]+-1*Q_102220000*R_121[0]+Q_202020000*R_201[0]+-1*Q_202120000*R_211[0]+Q_202220000*R_221[0]; double QR_001021000001=Q_001021000*R_001[0]+-1*Q_001121000*R_011[0]+Q_001221000*R_021[0]+-1*Q_001321000*R_031[0]+-1*Q_101021000*R_101[0]+Q_101121000*R_111[0]+-1*Q_101221000*R_121[0]+Q_101321000*R_131[0]; double QR_000022000001=Q_000022000*R_001[0]+-1*Q_000122000*R_011[0]+Q_000222000*R_021[0]+-1*Q_000322000*R_031[0]+Q_000422000*R_041[0]; double QR_001020001001=Q_001020001*R_001[0]+-1*Q_001020101*R_002[0]+-1*Q_001120001*R_011[0]+Q_001120101*R_012[0]+Q_001220001*R_021[0]+-1*Q_001220101*R_022[0]+-1*Q_101020001*R_101[0]+Q_101020101*R_102[0]+Q_101120001*R_111[0]+-1*Q_101120101*R_112[0]+-1*Q_101220001*R_121[0]+Q_101220101*R_122[0]; double QR_000021001001=Q_000021001*R_001[0]+-1*Q_000021101*R_002[0]+-1*Q_000121001*R_011[0]+Q_000121101*R_012[0]+Q_000221001*R_021[0]+-1*Q_000221101*R_022[0]+-1*Q_000321001*R_031[0]+Q_000321101*R_032[0]; double QR_000020002001=Q_000020002*R_001[0]+-1*Q_000020102*R_002[0]+Q_000020202*R_003[0]+-1*Q_000120002*R_011[0]+Q_000120102*R_012[0]+-1*Q_000120202*R_013[0]+Q_000220002*R_021[0]+-1*Q_000220102*R_022[0]+Q_000220202*R_023[0]; double QR_012000010001=Q_012000010*R_001[0]+-1*Q_012000110*R_002[0]+-1*Q_112000010*R_101[0]+Q_112000110*R_102[0]+Q_212000010*R_201[0]+-1*Q_212000110*R_202[0]+-1*Q_312000010*R_301[0]+Q_312000110*R_302[0]; double QR_011001010001=Q_011001010*R_001[0]+-1*Q_011001110*R_002[0]+-1*Q_011101010*R_011[0]+Q_011101110*R_012[0]+-1*Q_111001010*R_101[0]+Q_111001110*R_102[0]+Q_111101010*R_111[0]+-1*Q_111101110*R_112[0]+Q_211001010*R_201[0]+-1*Q_211001110*R_202[0]+-1*Q_211101010*R_211[0]+Q_211101110*R_212[0]; double QR_010002010001=Q_010002010*R_001[0]+-1*Q_010002110*R_002[0]+-1*Q_010102010*R_011[0]+Q_010102110*R_012[0]+Q_010202010*R_021[0]+-1*Q_010202110*R_022[0]+-1*Q_110002010*R_101[0]+Q_110002110*R_102[0]+Q_110102010*R_111[0]+-1*Q_110102110*R_112[0]+-1*Q_110202010*R_121[0]+Q_110202110*R_122[0]; double QR_011000011001=Q_011000011*R_001[0]+-1*Q_011000111*R_002[0]+Q_011000211*R_003[0]+-1*Q_111000011*R_101[0]+Q_111000111*R_102[0]+-1*Q_111000211*R_103[0]+Q_211000011*R_201[0]+-1*Q_211000111*R_202[0]+Q_211000211*R_203[0]; double QR_010001011001=Q_010001011*R_001[0]+-1*Q_010001111*R_002[0]+Q_010001211*R_003[0]+-1*Q_010101011*R_011[0]+Q_010101111*R_012[0]+-1*Q_010101211*R_013[0]+-1*Q_110001011*R_101[0]+Q_110001111*R_102[0]+-1*Q_110001211*R_103[0]+Q_110101011*R_111[0]+-1*Q_110101111*R_112[0]+Q_110101211*R_113[0]; double QR_010000012001=Q_010000012*R_001[0]+-1*Q_010000112*R_002[0]+Q_010000212*R_003[0]+-1*Q_010000312*R_004[0]+-1*Q_110000012*R_101[0]+Q_110000112*R_102[0]+-1*Q_110000212*R_103[0]+Q_110000312*R_104[0]; double QR_002010010001=Q_002010010*R_001[0]+-1*Q_002010110*R_002[0]+-1*Q_002110010*R_011[0]+Q_002110110*R_012[0]+-1*Q_102010010*R_101[0]+Q_102010110*R_102[0]+Q_102110010*R_111[0]+-1*Q_102110110*R_112[0]+Q_202010010*R_201[0]+-1*Q_202010110*R_202[0]+-1*Q_202110010*R_211[0]+Q_202110110*R_212[0]; double QR_001011010001=Q_001011010*R_001[0]+-1*Q_001011110*R_002[0]+-1*Q_001111010*R_011[0]+Q_001111110*R_012[0]+Q_001211010*R_021[0]+-1*Q_001211110*R_022[0]+-1*Q_101011010*R_101[0]+Q_101011110*R_102[0]+Q_101111010*R_111[0]+-1*Q_101111110*R_112[0]+-1*Q_101211010*R_121[0]+Q_101211110*R_122[0]; double QR_000012010001=Q_000012010*R_001[0]+-1*Q_000012110*R_002[0]+-1*Q_000112010*R_011[0]+Q_000112110*R_012[0]+Q_000212010*R_021[0]+-1*Q_000212110*R_022[0]+-1*Q_000312010*R_031[0]+Q_000312110*R_032[0]; double QR_001010011001=Q_001010011*R_001[0]+-1*Q_001010111*R_002[0]+Q_001010211*R_003[0]+-1*Q_001110011*R_011[0]+Q_001110111*R_012[0]+-1*Q_001110211*R_013[0]+-1*Q_101010011*R_101[0]+Q_101010111*R_102[0]+-1*Q_101010211*R_103[0]+Q_101110011*R_111[0]+-1*Q_101110111*R_112[0]+Q_101110211*R_113[0]; double QR_000011011001=Q_000011011*R_001[0]+-1*Q_000011111*R_002[0]+Q_000011211*R_003[0]+-1*Q_000111011*R_011[0]+Q_000111111*R_012[0]+-1*Q_000111211*R_013[0]+Q_000211011*R_021[0]+-1*Q_000211111*R_022[0]+Q_000211211*R_023[0]; double QR_000010012001=Q_000010012*R_001[0]+-1*Q_000010112*R_002[0]+Q_000010212*R_003[0]+-1*Q_000010312*R_004[0]+-1*Q_000110012*R_011[0]+Q_000110112*R_012[0]+-1*Q_000110212*R_013[0]+Q_000110312*R_014[0]; double QR_002000020001=Q_002000020*R_001[0]+-1*Q_002000120*R_002[0]+Q_002000220*R_003[0]+-1*Q_102000020*R_101[0]+Q_102000120*R_102[0]+-1*Q_102000220*R_103[0]+Q_202000020*R_201[0]+-1*Q_202000120*R_202[0]+Q_202000220*R_203[0]; double QR_001001020001=Q_001001020*R_001[0]+-1*Q_001001120*R_002[0]+Q_001001220*R_003[0]+-1*Q_001101020*R_011[0]+Q_001101120*R_012[0]+-1*Q_001101220*R_013[0]+-1*Q_101001020*R_101[0]+Q_101001120*R_102[0]+-1*Q_101001220*R_103[0]+Q_101101020*R_111[0]+-1*Q_101101120*R_112[0]+Q_101101220*R_113[0]; double QR_000002020001=Q_000002020*R_001[0]+-1*Q_000002120*R_002[0]+Q_000002220*R_003[0]+-1*Q_000102020*R_011[0]+Q_000102120*R_012[0]+-1*Q_000102220*R_013[0]+Q_000202020*R_021[0]+-1*Q_000202120*R_022[0]+Q_000202220*R_023[0]; double QR_001000021001=Q_001000021*R_001[0]+-1*Q_001000121*R_002[0]+Q_001000221*R_003[0]+-1*Q_001000321*R_004[0]+-1*Q_101000021*R_101[0]+Q_101000121*R_102[0]+-1*Q_101000221*R_103[0]+Q_101000321*R_104[0]; double QR_000001021001=Q_000001021*R_001[0]+-1*Q_000001121*R_002[0]+Q_000001221*R_003[0]+-1*Q_000001321*R_004[0]+-1*Q_000101021*R_011[0]+Q_000101121*R_012[0]+-1*Q_000101221*R_013[0]+Q_000101321*R_014[0]; double QR_000000022001=Q_000000022*R_001[0]+-1*Q_000000122*R_002[0]+Q_000000222*R_003[0]+-1*Q_000000322*R_004[0]+Q_000000422*R_005[0]; double QR_022000000010=Q_022000000*R_010[0]+-1*Q_122000000*R_110[0]+Q_222000000*R_210[0]+-1*Q_322000000*R_310[0]+Q_422000000*R_410[0]; double QR_021001000010=Q_021001000*R_010[0]+-1*Q_021101000*R_020[0]+-1*Q_121001000*R_110[0]+Q_121101000*R_120[0]+Q_221001000*R_210[0]+-1*Q_221101000*R_220[0]+-1*Q_321001000*R_310[0]+Q_321101000*R_320[0]; double QR_020002000010=Q_020002000*R_010[0]+-1*Q_020102000*R_020[0]+Q_020202000*R_030[0]+-1*Q_120002000*R_110[0]+Q_120102000*R_120[0]+-1*Q_120202000*R_130[0]+Q_220002000*R_210[0]+-1*Q_220102000*R_220[0]+Q_220202000*R_230[0]; double QR_021000001010=Q_021000001*R_010[0]+-1*Q_021000101*R_011[0]+-1*Q_121000001*R_110[0]+Q_121000101*R_111[0]+Q_221000001*R_210[0]+-1*Q_221000101*R_211[0]+-1*Q_321000001*R_310[0]+Q_321000101*R_311[0]; double QR_020001001010=Q_020001001*R_010[0]+-1*Q_020001101*R_011[0]+-1*Q_020101001*R_020[0]+Q_020101101*R_021[0]+-1*Q_120001001*R_110[0]+Q_120001101*R_111[0]+Q_120101001*R_120[0]+-1*Q_120101101*R_121[0]+Q_220001001*R_210[0]+-1*Q_220001101*R_211[0]+-1*Q_220101001*R_220[0]+Q_220101101*R_221[0]; double QR_020000002010=Q_020000002*R_010[0]+-1*Q_020000102*R_011[0]+Q_020000202*R_012[0]+-1*Q_120000002*R_110[0]+Q_120000102*R_111[0]+-1*Q_120000202*R_112[0]+Q_220000002*R_210[0]+-1*Q_220000102*R_211[0]+Q_220000202*R_212[0]; double QR_012010000010=Q_012010000*R_010[0]+-1*Q_012110000*R_020[0]+-1*Q_112010000*R_110[0]+Q_112110000*R_120[0]+Q_212010000*R_210[0]+-1*Q_212110000*R_220[0]+-1*Q_312010000*R_310[0]+Q_312110000*R_320[0]; double QR_011011000010=Q_011011000*R_010[0]+-1*Q_011111000*R_020[0]+Q_011211000*R_030[0]+-1*Q_111011000*R_110[0]+Q_111111000*R_120[0]+-1*Q_111211000*R_130[0]+Q_211011000*R_210[0]+-1*Q_211111000*R_220[0]+Q_211211000*R_230[0]; double QR_010012000010=Q_010012000*R_010[0]+-1*Q_010112000*R_020[0]+Q_010212000*R_030[0]+-1*Q_010312000*R_040[0]+-1*Q_110012000*R_110[0]+Q_110112000*R_120[0]+-1*Q_110212000*R_130[0]+Q_110312000*R_140[0]; double QR_011010001010=Q_011010001*R_010[0]+-1*Q_011010101*R_011[0]+-1*Q_011110001*R_020[0]+Q_011110101*R_021[0]+-1*Q_111010001*R_110[0]+Q_111010101*R_111[0]+Q_111110001*R_120[0]+-1*Q_111110101*R_121[0]+Q_211010001*R_210[0]+-1*Q_211010101*R_211[0]+-1*Q_211110001*R_220[0]+Q_211110101*R_221[0]; double QR_010011001010=Q_010011001*R_010[0]+-1*Q_010011101*R_011[0]+-1*Q_010111001*R_020[0]+Q_010111101*R_021[0]+Q_010211001*R_030[0]+-1*Q_010211101*R_031[0]+-1*Q_110011001*R_110[0]+Q_110011101*R_111[0]+Q_110111001*R_120[0]+-1*Q_110111101*R_121[0]+-1*Q_110211001*R_130[0]+Q_110211101*R_131[0]; double QR_010010002010=Q_010010002*R_010[0]+-1*Q_010010102*R_011[0]+Q_010010202*R_012[0]+-1*Q_010110002*R_020[0]+Q_010110102*R_021[0]+-1*Q_010110202*R_022[0]+-1*Q_110010002*R_110[0]+Q_110010102*R_111[0]+-1*Q_110010202*R_112[0]+Q_110110002*R_120[0]+-1*Q_110110102*R_121[0]+Q_110110202*R_122[0]; double QR_002020000010=Q_002020000*R_010[0]+-1*Q_002120000*R_020[0]+Q_002220000*R_030[0]+-1*Q_102020000*R_110[0]+Q_102120000*R_120[0]+-1*Q_102220000*R_130[0]+Q_202020000*R_210[0]+-1*Q_202120000*R_220[0]+Q_202220000*R_230[0]; double QR_001021000010=Q_001021000*R_010[0]+-1*Q_001121000*R_020[0]+Q_001221000*R_030[0]+-1*Q_001321000*R_040[0]+-1*Q_101021000*R_110[0]+Q_101121000*R_120[0]+-1*Q_101221000*R_130[0]+Q_101321000*R_140[0]; double QR_000022000010=Q_000022000*R_010[0]+-1*Q_000122000*R_020[0]+Q_000222000*R_030[0]+-1*Q_000322000*R_040[0]+Q_000422000*R_050[0]; double QR_001020001010=Q_001020001*R_010[0]+-1*Q_001020101*R_011[0]+-1*Q_001120001*R_020[0]+Q_001120101*R_021[0]+Q_001220001*R_030[0]+-1*Q_001220101*R_031[0]+-1*Q_101020001*R_110[0]+Q_101020101*R_111[0]+Q_101120001*R_120[0]+-1*Q_101120101*R_121[0]+-1*Q_101220001*R_130[0]+Q_101220101*R_131[0]; double QR_000021001010=Q_000021001*R_010[0]+-1*Q_000021101*R_011[0]+-1*Q_000121001*R_020[0]+Q_000121101*R_021[0]+Q_000221001*R_030[0]+-1*Q_000221101*R_031[0]+-1*Q_000321001*R_040[0]+Q_000321101*R_041[0]; double QR_000020002010=Q_000020002*R_010[0]+-1*Q_000020102*R_011[0]+Q_000020202*R_012[0]+-1*Q_000120002*R_020[0]+Q_000120102*R_021[0]+-1*Q_000120202*R_022[0]+Q_000220002*R_030[0]+-1*Q_000220102*R_031[0]+Q_000220202*R_032[0]; double QR_012000010010=Q_012000010*R_010[0]+-1*Q_012000110*R_011[0]+-1*Q_112000010*R_110[0]+Q_112000110*R_111[0]+Q_212000010*R_210[0]+-1*Q_212000110*R_211[0]+-1*Q_312000010*R_310[0]+Q_312000110*R_311[0]; double QR_011001010010=Q_011001010*R_010[0]+-1*Q_011001110*R_011[0]+-1*Q_011101010*R_020[0]+Q_011101110*R_021[0]+-1*Q_111001010*R_110[0]+Q_111001110*R_111[0]+Q_111101010*R_120[0]+-1*Q_111101110*R_121[0]+Q_211001010*R_210[0]+-1*Q_211001110*R_211[0]+-1*Q_211101010*R_220[0]+Q_211101110*R_221[0]; double QR_010002010010=Q_010002010*R_010[0]+-1*Q_010002110*R_011[0]+-1*Q_010102010*R_020[0]+Q_010102110*R_021[0]+Q_010202010*R_030[0]+-1*Q_010202110*R_031[0]+-1*Q_110002010*R_110[0]+Q_110002110*R_111[0]+Q_110102010*R_120[0]+-1*Q_110102110*R_121[0]+-1*Q_110202010*R_130[0]+Q_110202110*R_131[0]; double QR_011000011010=Q_011000011*R_010[0]+-1*Q_011000111*R_011[0]+Q_011000211*R_012[0]+-1*Q_111000011*R_110[0]+Q_111000111*R_111[0]+-1*Q_111000211*R_112[0]+Q_211000011*R_210[0]+-1*Q_211000111*R_211[0]+Q_211000211*R_212[0]; double QR_010001011010=Q_010001011*R_010[0]+-1*Q_010001111*R_011[0]+Q_010001211*R_012[0]+-1*Q_010101011*R_020[0]+Q_010101111*R_021[0]+-1*Q_010101211*R_022[0]+-1*Q_110001011*R_110[0]+Q_110001111*R_111[0]+-1*Q_110001211*R_112[0]+Q_110101011*R_120[0]+-1*Q_110101111*R_121[0]+Q_110101211*R_122[0]; double QR_010000012010=Q_010000012*R_010[0]+-1*Q_010000112*R_011[0]+Q_010000212*R_012[0]+-1*Q_010000312*R_013[0]+-1*Q_110000012*R_110[0]+Q_110000112*R_111[0]+-1*Q_110000212*R_112[0]+Q_110000312*R_113[0]; double QR_002010010010=Q_002010010*R_010[0]+-1*Q_002010110*R_011[0]+-1*Q_002110010*R_020[0]+Q_002110110*R_021[0]+-1*Q_102010010*R_110[0]+Q_102010110*R_111[0]+Q_102110010*R_120[0]+-1*Q_102110110*R_121[0]+Q_202010010*R_210[0]+-1*Q_202010110*R_211[0]+-1*Q_202110010*R_220[0]+Q_202110110*R_221[0]; double QR_001011010010=Q_001011010*R_010[0]+-1*Q_001011110*R_011[0]+-1*Q_001111010*R_020[0]+Q_001111110*R_021[0]+Q_001211010*R_030[0]+-1*Q_001211110*R_031[0]+-1*Q_101011010*R_110[0]+Q_101011110*R_111[0]+Q_101111010*R_120[0]+-1*Q_101111110*R_121[0]+-1*Q_101211010*R_130[0]+Q_101211110*R_131[0]; double QR_000012010010=Q_000012010*R_010[0]+-1*Q_000012110*R_011[0]+-1*Q_000112010*R_020[0]+Q_000112110*R_021[0]+Q_000212010*R_030[0]+-1*Q_000212110*R_031[0]+-1*Q_000312010*R_040[0]+Q_000312110*R_041[0]; double QR_001010011010=Q_001010011*R_010[0]+-1*Q_001010111*R_011[0]+Q_001010211*R_012[0]+-1*Q_001110011*R_020[0]+Q_001110111*R_021[0]+-1*Q_001110211*R_022[0]+-1*Q_101010011*R_110[0]+Q_101010111*R_111[0]+-1*Q_101010211*R_112[0]+Q_101110011*R_120[0]+-1*Q_101110111*R_121[0]+Q_101110211*R_122[0]; double QR_000011011010=Q_000011011*R_010[0]+-1*Q_000011111*R_011[0]+Q_000011211*R_012[0]+-1*Q_000111011*R_020[0]+Q_000111111*R_021[0]+-1*Q_000111211*R_022[0]+Q_000211011*R_030[0]+-1*Q_000211111*R_031[0]+Q_000211211*R_032[0]; double QR_000010012010=Q_000010012*R_010[0]+-1*Q_000010112*R_011[0]+Q_000010212*R_012[0]+-1*Q_000010312*R_013[0]+-1*Q_000110012*R_020[0]+Q_000110112*R_021[0]+-1*Q_000110212*R_022[0]+Q_000110312*R_023[0]; double QR_002000020010=Q_002000020*R_010[0]+-1*Q_002000120*R_011[0]+Q_002000220*R_012[0]+-1*Q_102000020*R_110[0]+Q_102000120*R_111[0]+-1*Q_102000220*R_112[0]+Q_202000020*R_210[0]+-1*Q_202000120*R_211[0]+Q_202000220*R_212[0]; double QR_001001020010=Q_001001020*R_010[0]+-1*Q_001001120*R_011[0]+Q_001001220*R_012[0]+-1*Q_001101020*R_020[0]+Q_001101120*R_021[0]+-1*Q_001101220*R_022[0]+-1*Q_101001020*R_110[0]+Q_101001120*R_111[0]+-1*Q_101001220*R_112[0]+Q_101101020*R_120[0]+-1*Q_101101120*R_121[0]+Q_101101220*R_122[0]; double QR_000002020010=Q_000002020*R_010[0]+-1*Q_000002120*R_011[0]+Q_000002220*R_012[0]+-1*Q_000102020*R_020[0]+Q_000102120*R_021[0]+-1*Q_000102220*R_022[0]+Q_000202020*R_030[0]+-1*Q_000202120*R_031[0]+Q_000202220*R_032[0]; double QR_001000021010=Q_001000021*R_010[0]+-1*Q_001000121*R_011[0]+Q_001000221*R_012[0]+-1*Q_001000321*R_013[0]+-1*Q_101000021*R_110[0]+Q_101000121*R_111[0]+-1*Q_101000221*R_112[0]+Q_101000321*R_113[0]; double QR_000001021010=Q_000001021*R_010[0]+-1*Q_000001121*R_011[0]+Q_000001221*R_012[0]+-1*Q_000001321*R_013[0]+-1*Q_000101021*R_020[0]+Q_000101121*R_021[0]+-1*Q_000101221*R_022[0]+Q_000101321*R_023[0]; double QR_000000022010=Q_000000022*R_010[0]+-1*Q_000000122*R_011[0]+Q_000000222*R_012[0]+-1*Q_000000322*R_013[0]+Q_000000422*R_014[0]; double QR_022000000100=Q_022000000*R_100[0]+-1*Q_122000000*R_200[0]+Q_222000000*R_300[0]+-1*Q_322000000*R_400[0]+Q_422000000*R_500[0]; double QR_021001000100=Q_021001000*R_100[0]+-1*Q_021101000*R_110[0]+-1*Q_121001000*R_200[0]+Q_121101000*R_210[0]+Q_221001000*R_300[0]+-1*Q_221101000*R_310[0]+-1*Q_321001000*R_400[0]+Q_321101000*R_410[0]; double QR_020002000100=Q_020002000*R_100[0]+-1*Q_020102000*R_110[0]+Q_020202000*R_120[0]+-1*Q_120002000*R_200[0]+Q_120102000*R_210[0]+-1*Q_120202000*R_220[0]+Q_220002000*R_300[0]+-1*Q_220102000*R_310[0]+Q_220202000*R_320[0]; double QR_021000001100=Q_021000001*R_100[0]+-1*Q_021000101*R_101[0]+-1*Q_121000001*R_200[0]+Q_121000101*R_201[0]+Q_221000001*R_300[0]+-1*Q_221000101*R_301[0]+-1*Q_321000001*R_400[0]+Q_321000101*R_401[0]; double QR_020001001100=Q_020001001*R_100[0]+-1*Q_020001101*R_101[0]+-1*Q_020101001*R_110[0]+Q_020101101*R_111[0]+-1*Q_120001001*R_200[0]+Q_120001101*R_201[0]+Q_120101001*R_210[0]+-1*Q_120101101*R_211[0]+Q_220001001*R_300[0]+-1*Q_220001101*R_301[0]+-1*Q_220101001*R_310[0]+Q_220101101*R_311[0]; double QR_020000002100=Q_020000002*R_100[0]+-1*Q_020000102*R_101[0]+Q_020000202*R_102[0]+-1*Q_120000002*R_200[0]+Q_120000102*R_201[0]+-1*Q_120000202*R_202[0]+Q_220000002*R_300[0]+-1*Q_220000102*R_301[0]+Q_220000202*R_302[0]; double QR_012010000100=Q_012010000*R_100[0]+-1*Q_012110000*R_110[0]+-1*Q_112010000*R_200[0]+Q_112110000*R_210[0]+Q_212010000*R_300[0]+-1*Q_212110000*R_310[0]+-1*Q_312010000*R_400[0]+Q_312110000*R_410[0]; double QR_011011000100=Q_011011000*R_100[0]+-1*Q_011111000*R_110[0]+Q_011211000*R_120[0]+-1*Q_111011000*R_200[0]+Q_111111000*R_210[0]+-1*Q_111211000*R_220[0]+Q_211011000*R_300[0]+-1*Q_211111000*R_310[0]+Q_211211000*R_320[0]; double QR_010012000100=Q_010012000*R_100[0]+-1*Q_010112000*R_110[0]+Q_010212000*R_120[0]+-1*Q_010312000*R_130[0]+-1*Q_110012000*R_200[0]+Q_110112000*R_210[0]+-1*Q_110212000*R_220[0]+Q_110312000*R_230[0]; double QR_011010001100=Q_011010001*R_100[0]+-1*Q_011010101*R_101[0]+-1*Q_011110001*R_110[0]+Q_011110101*R_111[0]+-1*Q_111010001*R_200[0]+Q_111010101*R_201[0]+Q_111110001*R_210[0]+-1*Q_111110101*R_211[0]+Q_211010001*R_300[0]+-1*Q_211010101*R_301[0]+-1*Q_211110001*R_310[0]+Q_211110101*R_311[0]; double QR_010011001100=Q_010011001*R_100[0]+-1*Q_010011101*R_101[0]+-1*Q_010111001*R_110[0]+Q_010111101*R_111[0]+Q_010211001*R_120[0]+-1*Q_010211101*R_121[0]+-1*Q_110011001*R_200[0]+Q_110011101*R_201[0]+Q_110111001*R_210[0]+-1*Q_110111101*R_211[0]+-1*Q_110211001*R_220[0]+Q_110211101*R_221[0]; double QR_010010002100=Q_010010002*R_100[0]+-1*Q_010010102*R_101[0]+Q_010010202*R_102[0]+-1*Q_010110002*R_110[0]+Q_010110102*R_111[0]+-1*Q_010110202*R_112[0]+-1*Q_110010002*R_200[0]+Q_110010102*R_201[0]+-1*Q_110010202*R_202[0]+Q_110110002*R_210[0]+-1*Q_110110102*R_211[0]+Q_110110202*R_212[0]; double QR_002020000100=Q_002020000*R_100[0]+-1*Q_002120000*R_110[0]+Q_002220000*R_120[0]+-1*Q_102020000*R_200[0]+Q_102120000*R_210[0]+-1*Q_102220000*R_220[0]+Q_202020000*R_300[0]+-1*Q_202120000*R_310[0]+Q_202220000*R_320[0]; double QR_001021000100=Q_001021000*R_100[0]+-1*Q_001121000*R_110[0]+Q_001221000*R_120[0]+-1*Q_001321000*R_130[0]+-1*Q_101021000*R_200[0]+Q_101121000*R_210[0]+-1*Q_101221000*R_220[0]+Q_101321000*R_230[0]; double QR_000022000100=Q_000022000*R_100[0]+-1*Q_000122000*R_110[0]+Q_000222000*R_120[0]+-1*Q_000322000*R_130[0]+Q_000422000*R_140[0]; double QR_001020001100=Q_001020001*R_100[0]+-1*Q_001020101*R_101[0]+-1*Q_001120001*R_110[0]+Q_001120101*R_111[0]+Q_001220001*R_120[0]+-1*Q_001220101*R_121[0]+-1*Q_101020001*R_200[0]+Q_101020101*R_201[0]+Q_101120001*R_210[0]+-1*Q_101120101*R_211[0]+-1*Q_101220001*R_220[0]+Q_101220101*R_221[0]; double QR_000021001100=Q_000021001*R_100[0]+-1*Q_000021101*R_101[0]+-1*Q_000121001*R_110[0]+Q_000121101*R_111[0]+Q_000221001*R_120[0]+-1*Q_000221101*R_121[0]+-1*Q_000321001*R_130[0]+Q_000321101*R_131[0]; double QR_000020002100=Q_000020002*R_100[0]+-1*Q_000020102*R_101[0]+Q_000020202*R_102[0]+-1*Q_000120002*R_110[0]+Q_000120102*R_111[0]+-1*Q_000120202*R_112[0]+Q_000220002*R_120[0]+-1*Q_000220102*R_121[0]+Q_000220202*R_122[0]; double QR_012000010100=Q_012000010*R_100[0]+-1*Q_012000110*R_101[0]+-1*Q_112000010*R_200[0]+Q_112000110*R_201[0]+Q_212000010*R_300[0]+-1*Q_212000110*R_301[0]+-1*Q_312000010*R_400[0]+Q_312000110*R_401[0]; double QR_011001010100=Q_011001010*R_100[0]+-1*Q_011001110*R_101[0]+-1*Q_011101010*R_110[0]+Q_011101110*R_111[0]+-1*Q_111001010*R_200[0]+Q_111001110*R_201[0]+Q_111101010*R_210[0]+-1*Q_111101110*R_211[0]+Q_211001010*R_300[0]+-1*Q_211001110*R_301[0]+-1*Q_211101010*R_310[0]+Q_211101110*R_311[0]; double QR_010002010100=Q_010002010*R_100[0]+-1*Q_010002110*R_101[0]+-1*Q_010102010*R_110[0]+Q_010102110*R_111[0]+Q_010202010*R_120[0]+-1*Q_010202110*R_121[0]+-1*Q_110002010*R_200[0]+Q_110002110*R_201[0]+Q_110102010*R_210[0]+-1*Q_110102110*R_211[0]+-1*Q_110202010*R_220[0]+Q_110202110*R_221[0]; double QR_011000011100=Q_011000011*R_100[0]+-1*Q_011000111*R_101[0]+Q_011000211*R_102[0]+-1*Q_111000011*R_200[0]+Q_111000111*R_201[0]+-1*Q_111000211*R_202[0]+Q_211000011*R_300[0]+-1*Q_211000111*R_301[0]+Q_211000211*R_302[0]; double QR_010001011100=Q_010001011*R_100[0]+-1*Q_010001111*R_101[0]+Q_010001211*R_102[0]+-1*Q_010101011*R_110[0]+Q_010101111*R_111[0]+-1*Q_010101211*R_112[0]+-1*Q_110001011*R_200[0]+Q_110001111*R_201[0]+-1*Q_110001211*R_202[0]+Q_110101011*R_210[0]+-1*Q_110101111*R_211[0]+Q_110101211*R_212[0]; double QR_010000012100=Q_010000012*R_100[0]+-1*Q_010000112*R_101[0]+Q_010000212*R_102[0]+-1*Q_010000312*R_103[0]+-1*Q_110000012*R_200[0]+Q_110000112*R_201[0]+-1*Q_110000212*R_202[0]+Q_110000312*R_203[0]; double QR_002010010100=Q_002010010*R_100[0]+-1*Q_002010110*R_101[0]+-1*Q_002110010*R_110[0]+Q_002110110*R_111[0]+-1*Q_102010010*R_200[0]+Q_102010110*R_201[0]+Q_102110010*R_210[0]+-1*Q_102110110*R_211[0]+Q_202010010*R_300[0]+-1*Q_202010110*R_301[0]+-1*Q_202110010*R_310[0]+Q_202110110*R_311[0]; double QR_001011010100=Q_001011010*R_100[0]+-1*Q_001011110*R_101[0]+-1*Q_001111010*R_110[0]+Q_001111110*R_111[0]+Q_001211010*R_120[0]+-1*Q_001211110*R_121[0]+-1*Q_101011010*R_200[0]+Q_101011110*R_201[0]+Q_101111010*R_210[0]+-1*Q_101111110*R_211[0]+-1*Q_101211010*R_220[0]+Q_101211110*R_221[0]; double QR_000012010100=Q_000012010*R_100[0]+-1*Q_000012110*R_101[0]+-1*Q_000112010*R_110[0]+Q_000112110*R_111[0]+Q_000212010*R_120[0]+-1*Q_000212110*R_121[0]+-1*Q_000312010*R_130[0]+Q_000312110*R_131[0]; double QR_001010011100=Q_001010011*R_100[0]+-1*Q_001010111*R_101[0]+Q_001010211*R_102[0]+-1*Q_001110011*R_110[0]+Q_001110111*R_111[0]+-1*Q_001110211*R_112[0]+-1*Q_101010011*R_200[0]+Q_101010111*R_201[0]+-1*Q_101010211*R_202[0]+Q_101110011*R_210[0]+-1*Q_101110111*R_211[0]+Q_101110211*R_212[0]; double QR_000011011100=Q_000011011*R_100[0]+-1*Q_000011111*R_101[0]+Q_000011211*R_102[0]+-1*Q_000111011*R_110[0]+Q_000111111*R_111[0]+-1*Q_000111211*R_112[0]+Q_000211011*R_120[0]+-1*Q_000211111*R_121[0]+Q_000211211*R_122[0]; double QR_000010012100=Q_000010012*R_100[0]+-1*Q_000010112*R_101[0]+Q_000010212*R_102[0]+-1*Q_000010312*R_103[0]+-1*Q_000110012*R_110[0]+Q_000110112*R_111[0]+-1*Q_000110212*R_112[0]+Q_000110312*R_113[0]; double QR_002000020100=Q_002000020*R_100[0]+-1*Q_002000120*R_101[0]+Q_002000220*R_102[0]+-1*Q_102000020*R_200[0]+Q_102000120*R_201[0]+-1*Q_102000220*R_202[0]+Q_202000020*R_300[0]+-1*Q_202000120*R_301[0]+Q_202000220*R_302[0]; double QR_001001020100=Q_001001020*R_100[0]+-1*Q_001001120*R_101[0]+Q_001001220*R_102[0]+-1*Q_001101020*R_110[0]+Q_001101120*R_111[0]+-1*Q_001101220*R_112[0]+-1*Q_101001020*R_200[0]+Q_101001120*R_201[0]+-1*Q_101001220*R_202[0]+Q_101101020*R_210[0]+-1*Q_101101120*R_211[0]+Q_101101220*R_212[0]; double QR_000002020100=Q_000002020*R_100[0]+-1*Q_000002120*R_101[0]+Q_000002220*R_102[0]+-1*Q_000102020*R_110[0]+Q_000102120*R_111[0]+-1*Q_000102220*R_112[0]+Q_000202020*R_120[0]+-1*Q_000202120*R_121[0]+Q_000202220*R_122[0]; double QR_001000021100=Q_001000021*R_100[0]+-1*Q_001000121*R_101[0]+Q_001000221*R_102[0]+-1*Q_001000321*R_103[0]+-1*Q_101000021*R_200[0]+Q_101000121*R_201[0]+-1*Q_101000221*R_202[0]+Q_101000321*R_203[0]; double QR_000001021100=Q_000001021*R_100[0]+-1*Q_000001121*R_101[0]+Q_000001221*R_102[0]+-1*Q_000001321*R_103[0]+-1*Q_000101021*R_110[0]+Q_000101121*R_111[0]+-1*Q_000101221*R_112[0]+Q_000101321*R_113[0]; double QR_000000022100=Q_000000022*R_100[0]+-1*Q_000000122*R_101[0]+Q_000000222*R_102[0]+-1*Q_000000322*R_103[0]+Q_000000422*R_104[0]; double QR_022000000002=Q_022000000*R_002[0]+-1*Q_122000000*R_102[0]+Q_222000000*R_202[0]+-1*Q_322000000*R_302[0]+Q_422000000*R_402[0]; double QR_021001000002=Q_021001000*R_002[0]+-1*Q_021101000*R_012[0]+-1*Q_121001000*R_102[0]+Q_121101000*R_112[0]+Q_221001000*R_202[0]+-1*Q_221101000*R_212[0]+-1*Q_321001000*R_302[0]+Q_321101000*R_312[0]; double QR_020002000002=Q_020002000*R_002[0]+-1*Q_020102000*R_012[0]+Q_020202000*R_022[0]+-1*Q_120002000*R_102[0]+Q_120102000*R_112[0]+-1*Q_120202000*R_122[0]+Q_220002000*R_202[0]+-1*Q_220102000*R_212[0]+Q_220202000*R_222[0]; double QR_021000001002=Q_021000001*R_002[0]+-1*Q_021000101*R_003[0]+-1*Q_121000001*R_102[0]+Q_121000101*R_103[0]+Q_221000001*R_202[0]+-1*Q_221000101*R_203[0]+-1*Q_321000001*R_302[0]+Q_321000101*R_303[0]; double QR_020001001002=Q_020001001*R_002[0]+-1*Q_020001101*R_003[0]+-1*Q_020101001*R_012[0]+Q_020101101*R_013[0]+-1*Q_120001001*R_102[0]+Q_120001101*R_103[0]+Q_120101001*R_112[0]+-1*Q_120101101*R_113[0]+Q_220001001*R_202[0]+-1*Q_220001101*R_203[0]+-1*Q_220101001*R_212[0]+Q_220101101*R_213[0]; double QR_020000002002=Q_020000002*R_002[0]+-1*Q_020000102*R_003[0]+Q_020000202*R_004[0]+-1*Q_120000002*R_102[0]+Q_120000102*R_103[0]+-1*Q_120000202*R_104[0]+Q_220000002*R_202[0]+-1*Q_220000102*R_203[0]+Q_220000202*R_204[0]; double QR_012010000002=Q_012010000*R_002[0]+-1*Q_012110000*R_012[0]+-1*Q_112010000*R_102[0]+Q_112110000*R_112[0]+Q_212010000*R_202[0]+-1*Q_212110000*R_212[0]+-1*Q_312010000*R_302[0]+Q_312110000*R_312[0]; double QR_011011000002=Q_011011000*R_002[0]+-1*Q_011111000*R_012[0]+Q_011211000*R_022[0]+-1*Q_111011000*R_102[0]+Q_111111000*R_112[0]+-1*Q_111211000*R_122[0]+Q_211011000*R_202[0]+-1*Q_211111000*R_212[0]+Q_211211000*R_222[0]; double QR_010012000002=Q_010012000*R_002[0]+-1*Q_010112000*R_012[0]+Q_010212000*R_022[0]+-1*Q_010312000*R_032[0]+-1*Q_110012000*R_102[0]+Q_110112000*R_112[0]+-1*Q_110212000*R_122[0]+Q_110312000*R_132[0]; double QR_011010001002=Q_011010001*R_002[0]+-1*Q_011010101*R_003[0]+-1*Q_011110001*R_012[0]+Q_011110101*R_013[0]+-1*Q_111010001*R_102[0]+Q_111010101*R_103[0]+Q_111110001*R_112[0]+-1*Q_111110101*R_113[0]+Q_211010001*R_202[0]+-1*Q_211010101*R_203[0]+-1*Q_211110001*R_212[0]+Q_211110101*R_213[0]; double QR_010011001002=Q_010011001*R_002[0]+-1*Q_010011101*R_003[0]+-1*Q_010111001*R_012[0]+Q_010111101*R_013[0]+Q_010211001*R_022[0]+-1*Q_010211101*R_023[0]+-1*Q_110011001*R_102[0]+Q_110011101*R_103[0]+Q_110111001*R_112[0]+-1*Q_110111101*R_113[0]+-1*Q_110211001*R_122[0]+Q_110211101*R_123[0]; double QR_010010002002=Q_010010002*R_002[0]+-1*Q_010010102*R_003[0]+Q_010010202*R_004[0]+-1*Q_010110002*R_012[0]+Q_010110102*R_013[0]+-1*Q_010110202*R_014[0]+-1*Q_110010002*R_102[0]+Q_110010102*R_103[0]+-1*Q_110010202*R_104[0]+Q_110110002*R_112[0]+-1*Q_110110102*R_113[0]+Q_110110202*R_114[0]; double QR_002020000002=Q_002020000*R_002[0]+-1*Q_002120000*R_012[0]+Q_002220000*R_022[0]+-1*Q_102020000*R_102[0]+Q_102120000*R_112[0]+-1*Q_102220000*R_122[0]+Q_202020000*R_202[0]+-1*Q_202120000*R_212[0]+Q_202220000*R_222[0]; double QR_001021000002=Q_001021000*R_002[0]+-1*Q_001121000*R_012[0]+Q_001221000*R_022[0]+-1*Q_001321000*R_032[0]+-1*Q_101021000*R_102[0]+Q_101121000*R_112[0]+-1*Q_101221000*R_122[0]+Q_101321000*R_132[0]; double QR_000022000002=Q_000022000*R_002[0]+-1*Q_000122000*R_012[0]+Q_000222000*R_022[0]+-1*Q_000322000*R_032[0]+Q_000422000*R_042[0]; double QR_001020001002=Q_001020001*R_002[0]+-1*Q_001020101*R_003[0]+-1*Q_001120001*R_012[0]+Q_001120101*R_013[0]+Q_001220001*R_022[0]+-1*Q_001220101*R_023[0]+-1*Q_101020001*R_102[0]+Q_101020101*R_103[0]+Q_101120001*R_112[0]+-1*Q_101120101*R_113[0]+-1*Q_101220001*R_122[0]+Q_101220101*R_123[0]; double QR_000021001002=Q_000021001*R_002[0]+-1*Q_000021101*R_003[0]+-1*Q_000121001*R_012[0]+Q_000121101*R_013[0]+Q_000221001*R_022[0]+-1*Q_000221101*R_023[0]+-1*Q_000321001*R_032[0]+Q_000321101*R_033[0]; double QR_000020002002=Q_000020002*R_002[0]+-1*Q_000020102*R_003[0]+Q_000020202*R_004[0]+-1*Q_000120002*R_012[0]+Q_000120102*R_013[0]+-1*Q_000120202*R_014[0]+Q_000220002*R_022[0]+-1*Q_000220102*R_023[0]+Q_000220202*R_024[0]; double QR_012000010002=Q_012000010*R_002[0]+-1*Q_012000110*R_003[0]+-1*Q_112000010*R_102[0]+Q_112000110*R_103[0]+Q_212000010*R_202[0]+-1*Q_212000110*R_203[0]+-1*Q_312000010*R_302[0]+Q_312000110*R_303[0]; double QR_011001010002=Q_011001010*R_002[0]+-1*Q_011001110*R_003[0]+-1*Q_011101010*R_012[0]+Q_011101110*R_013[0]+-1*Q_111001010*R_102[0]+Q_111001110*R_103[0]+Q_111101010*R_112[0]+-1*Q_111101110*R_113[0]+Q_211001010*R_202[0]+-1*Q_211001110*R_203[0]+-1*Q_211101010*R_212[0]+Q_211101110*R_213[0]; double QR_010002010002=Q_010002010*R_002[0]+-1*Q_010002110*R_003[0]+-1*Q_010102010*R_012[0]+Q_010102110*R_013[0]+Q_010202010*R_022[0]+-1*Q_010202110*R_023[0]+-1*Q_110002010*R_102[0]+Q_110002110*R_103[0]+Q_110102010*R_112[0]+-1*Q_110102110*R_113[0]+-1*Q_110202010*R_122[0]+Q_110202110*R_123[0]; double QR_011000011002=Q_011000011*R_002[0]+-1*Q_011000111*R_003[0]+Q_011000211*R_004[0]+-1*Q_111000011*R_102[0]+Q_111000111*R_103[0]+-1*Q_111000211*R_104[0]+Q_211000011*R_202[0]+-1*Q_211000111*R_203[0]+Q_211000211*R_204[0]; double QR_010001011002=Q_010001011*R_002[0]+-1*Q_010001111*R_003[0]+Q_010001211*R_004[0]+-1*Q_010101011*R_012[0]+Q_010101111*R_013[0]+-1*Q_010101211*R_014[0]+-1*Q_110001011*R_102[0]+Q_110001111*R_103[0]+-1*Q_110001211*R_104[0]+Q_110101011*R_112[0]+-1*Q_110101111*R_113[0]+Q_110101211*R_114[0]; double QR_010000012002=Q_010000012*R_002[0]+-1*Q_010000112*R_003[0]+Q_010000212*R_004[0]+-1*Q_010000312*R_005[0]+-1*Q_110000012*R_102[0]+Q_110000112*R_103[0]+-1*Q_110000212*R_104[0]+Q_110000312*R_105[0]; double QR_002010010002=Q_002010010*R_002[0]+-1*Q_002010110*R_003[0]+-1*Q_002110010*R_012[0]+Q_002110110*R_013[0]+-1*Q_102010010*R_102[0]+Q_102010110*R_103[0]+Q_102110010*R_112[0]+-1*Q_102110110*R_113[0]+Q_202010010*R_202[0]+-1*Q_202010110*R_203[0]+-1*Q_202110010*R_212[0]+Q_202110110*R_213[0]; double QR_001011010002=Q_001011010*R_002[0]+-1*Q_001011110*R_003[0]+-1*Q_001111010*R_012[0]+Q_001111110*R_013[0]+Q_001211010*R_022[0]+-1*Q_001211110*R_023[0]+-1*Q_101011010*R_102[0]+Q_101011110*R_103[0]+Q_101111010*R_112[0]+-1*Q_101111110*R_113[0]+-1*Q_101211010*R_122[0]+Q_101211110*R_123[0]; double QR_000012010002=Q_000012010*R_002[0]+-1*Q_000012110*R_003[0]+-1*Q_000112010*R_012[0]+Q_000112110*R_013[0]+Q_000212010*R_022[0]+-1*Q_000212110*R_023[0]+-1*Q_000312010*R_032[0]+Q_000312110*R_033[0]; double QR_001010011002=Q_001010011*R_002[0]+-1*Q_001010111*R_003[0]+Q_001010211*R_004[0]+-1*Q_001110011*R_012[0]+Q_001110111*R_013[0]+-1*Q_001110211*R_014[0]+-1*Q_101010011*R_102[0]+Q_101010111*R_103[0]+-1*Q_101010211*R_104[0]+Q_101110011*R_112[0]+-1*Q_101110111*R_113[0]+Q_101110211*R_114[0]; double QR_000011011002=Q_000011011*R_002[0]+-1*Q_000011111*R_003[0]+Q_000011211*R_004[0]+-1*Q_000111011*R_012[0]+Q_000111111*R_013[0]+-1*Q_000111211*R_014[0]+Q_000211011*R_022[0]+-1*Q_000211111*R_023[0]+Q_000211211*R_024[0]; double QR_000010012002=Q_000010012*R_002[0]+-1*Q_000010112*R_003[0]+Q_000010212*R_004[0]+-1*Q_000010312*R_005[0]+-1*Q_000110012*R_012[0]+Q_000110112*R_013[0]+-1*Q_000110212*R_014[0]+Q_000110312*R_015[0]; double QR_002000020002=Q_002000020*R_002[0]+-1*Q_002000120*R_003[0]+Q_002000220*R_004[0]+-1*Q_102000020*R_102[0]+Q_102000120*R_103[0]+-1*Q_102000220*R_104[0]+Q_202000020*R_202[0]+-1*Q_202000120*R_203[0]+Q_202000220*R_204[0]; double QR_001001020002=Q_001001020*R_002[0]+-1*Q_001001120*R_003[0]+Q_001001220*R_004[0]+-1*Q_001101020*R_012[0]+Q_001101120*R_013[0]+-1*Q_001101220*R_014[0]+-1*Q_101001020*R_102[0]+Q_101001120*R_103[0]+-1*Q_101001220*R_104[0]+Q_101101020*R_112[0]+-1*Q_101101120*R_113[0]+Q_101101220*R_114[0]; double QR_000002020002=Q_000002020*R_002[0]+-1*Q_000002120*R_003[0]+Q_000002220*R_004[0]+-1*Q_000102020*R_012[0]+Q_000102120*R_013[0]+-1*Q_000102220*R_014[0]+Q_000202020*R_022[0]+-1*Q_000202120*R_023[0]+Q_000202220*R_024[0]; double QR_001000021002=Q_001000021*R_002[0]+-1*Q_001000121*R_003[0]+Q_001000221*R_004[0]+-1*Q_001000321*R_005[0]+-1*Q_101000021*R_102[0]+Q_101000121*R_103[0]+-1*Q_101000221*R_104[0]+Q_101000321*R_105[0]; double QR_000001021002=Q_000001021*R_002[0]+-1*Q_000001121*R_003[0]+Q_000001221*R_004[0]+-1*Q_000001321*R_005[0]+-1*Q_000101021*R_012[0]+Q_000101121*R_013[0]+-1*Q_000101221*R_014[0]+Q_000101321*R_015[0]; double QR_000000022002=Q_000000022*R_002[0]+-1*Q_000000122*R_003[0]+Q_000000222*R_004[0]+-1*Q_000000322*R_005[0]+Q_000000422*R_006[0]; double QR_022000000011=Q_022000000*R_011[0]+-1*Q_122000000*R_111[0]+Q_222000000*R_211[0]+-1*Q_322000000*R_311[0]+Q_422000000*R_411[0]; double QR_021001000011=Q_021001000*R_011[0]+-1*Q_021101000*R_021[0]+-1*Q_121001000*R_111[0]+Q_121101000*R_121[0]+Q_221001000*R_211[0]+-1*Q_221101000*R_221[0]+-1*Q_321001000*R_311[0]+Q_321101000*R_321[0]; double QR_020002000011=Q_020002000*R_011[0]+-1*Q_020102000*R_021[0]+Q_020202000*R_031[0]+-1*Q_120002000*R_111[0]+Q_120102000*R_121[0]+-1*Q_120202000*R_131[0]+Q_220002000*R_211[0]+-1*Q_220102000*R_221[0]+Q_220202000*R_231[0]; double QR_021000001011=Q_021000001*R_011[0]+-1*Q_021000101*R_012[0]+-1*Q_121000001*R_111[0]+Q_121000101*R_112[0]+Q_221000001*R_211[0]+-1*Q_221000101*R_212[0]+-1*Q_321000001*R_311[0]+Q_321000101*R_312[0]; double QR_020001001011=Q_020001001*R_011[0]+-1*Q_020001101*R_012[0]+-1*Q_020101001*R_021[0]+Q_020101101*R_022[0]+-1*Q_120001001*R_111[0]+Q_120001101*R_112[0]+Q_120101001*R_121[0]+-1*Q_120101101*R_122[0]+Q_220001001*R_211[0]+-1*Q_220001101*R_212[0]+-1*Q_220101001*R_221[0]+Q_220101101*R_222[0]; double QR_020000002011=Q_020000002*R_011[0]+-1*Q_020000102*R_012[0]+Q_020000202*R_013[0]+-1*Q_120000002*R_111[0]+Q_120000102*R_112[0]+-1*Q_120000202*R_113[0]+Q_220000002*R_211[0]+-1*Q_220000102*R_212[0]+Q_220000202*R_213[0]; double QR_012010000011=Q_012010000*R_011[0]+-1*Q_012110000*R_021[0]+-1*Q_112010000*R_111[0]+Q_112110000*R_121[0]+Q_212010000*R_211[0]+-1*Q_212110000*R_221[0]+-1*Q_312010000*R_311[0]+Q_312110000*R_321[0]; double QR_011011000011=Q_011011000*R_011[0]+-1*Q_011111000*R_021[0]+Q_011211000*R_031[0]+-1*Q_111011000*R_111[0]+Q_111111000*R_121[0]+-1*Q_111211000*R_131[0]+Q_211011000*R_211[0]+-1*Q_211111000*R_221[0]+Q_211211000*R_231[0]; double QR_010012000011=Q_010012000*R_011[0]+-1*Q_010112000*R_021[0]+Q_010212000*R_031[0]+-1*Q_010312000*R_041[0]+-1*Q_110012000*R_111[0]+Q_110112000*R_121[0]+-1*Q_110212000*R_131[0]+Q_110312000*R_141[0]; double QR_011010001011=Q_011010001*R_011[0]+-1*Q_011010101*R_012[0]+-1*Q_011110001*R_021[0]+Q_011110101*R_022[0]+-1*Q_111010001*R_111[0]+Q_111010101*R_112[0]+Q_111110001*R_121[0]+-1*Q_111110101*R_122[0]+Q_211010001*R_211[0]+-1*Q_211010101*R_212[0]+-1*Q_211110001*R_221[0]+Q_211110101*R_222[0]; double QR_010011001011=Q_010011001*R_011[0]+-1*Q_010011101*R_012[0]+-1*Q_010111001*R_021[0]+Q_010111101*R_022[0]+Q_010211001*R_031[0]+-1*Q_010211101*R_032[0]+-1*Q_110011001*R_111[0]+Q_110011101*R_112[0]+Q_110111001*R_121[0]+-1*Q_110111101*R_122[0]+-1*Q_110211001*R_131[0]+Q_110211101*R_132[0]; double QR_010010002011=Q_010010002*R_011[0]+-1*Q_010010102*R_012[0]+Q_010010202*R_013[0]+-1*Q_010110002*R_021[0]+Q_010110102*R_022[0]+-1*Q_010110202*R_023[0]+-1*Q_110010002*R_111[0]+Q_110010102*R_112[0]+-1*Q_110010202*R_113[0]+Q_110110002*R_121[0]+-1*Q_110110102*R_122[0]+Q_110110202*R_123[0]; double QR_002020000011=Q_002020000*R_011[0]+-1*Q_002120000*R_021[0]+Q_002220000*R_031[0]+-1*Q_102020000*R_111[0]+Q_102120000*R_121[0]+-1*Q_102220000*R_131[0]+Q_202020000*R_211[0]+-1*Q_202120000*R_221[0]+Q_202220000*R_231[0]; double QR_001021000011=Q_001021000*R_011[0]+-1*Q_001121000*R_021[0]+Q_001221000*R_031[0]+-1*Q_001321000*R_041[0]+-1*Q_101021000*R_111[0]+Q_101121000*R_121[0]+-1*Q_101221000*R_131[0]+Q_101321000*R_141[0]; double QR_000022000011=Q_000022000*R_011[0]+-1*Q_000122000*R_021[0]+Q_000222000*R_031[0]+-1*Q_000322000*R_041[0]+Q_000422000*R_051[0]; double QR_001020001011=Q_001020001*R_011[0]+-1*Q_001020101*R_012[0]+-1*Q_001120001*R_021[0]+Q_001120101*R_022[0]+Q_001220001*R_031[0]+-1*Q_001220101*R_032[0]+-1*Q_101020001*R_111[0]+Q_101020101*R_112[0]+Q_101120001*R_121[0]+-1*Q_101120101*R_122[0]+-1*Q_101220001*R_131[0]+Q_101220101*R_132[0]; double QR_000021001011=Q_000021001*R_011[0]+-1*Q_000021101*R_012[0]+-1*Q_000121001*R_021[0]+Q_000121101*R_022[0]+Q_000221001*R_031[0]+-1*Q_000221101*R_032[0]+-1*Q_000321001*R_041[0]+Q_000321101*R_042[0]; double QR_000020002011=Q_000020002*R_011[0]+-1*Q_000020102*R_012[0]+Q_000020202*R_013[0]+-1*Q_000120002*R_021[0]+Q_000120102*R_022[0]+-1*Q_000120202*R_023[0]+Q_000220002*R_031[0]+-1*Q_000220102*R_032[0]+Q_000220202*R_033[0]; double QR_012000010011=Q_012000010*R_011[0]+-1*Q_012000110*R_012[0]+-1*Q_112000010*R_111[0]+Q_112000110*R_112[0]+Q_212000010*R_211[0]+-1*Q_212000110*R_212[0]+-1*Q_312000010*R_311[0]+Q_312000110*R_312[0]; double QR_011001010011=Q_011001010*R_011[0]+-1*Q_011001110*R_012[0]+-1*Q_011101010*R_021[0]+Q_011101110*R_022[0]+-1*Q_111001010*R_111[0]+Q_111001110*R_112[0]+Q_111101010*R_121[0]+-1*Q_111101110*R_122[0]+Q_211001010*R_211[0]+-1*Q_211001110*R_212[0]+-1*Q_211101010*R_221[0]+Q_211101110*R_222[0]; double QR_010002010011=Q_010002010*R_011[0]+-1*Q_010002110*R_012[0]+-1*Q_010102010*R_021[0]+Q_010102110*R_022[0]+Q_010202010*R_031[0]+-1*Q_010202110*R_032[0]+-1*Q_110002010*R_111[0]+Q_110002110*R_112[0]+Q_110102010*R_121[0]+-1*Q_110102110*R_122[0]+-1*Q_110202010*R_131[0]+Q_110202110*R_132[0]; double QR_011000011011=Q_011000011*R_011[0]+-1*Q_011000111*R_012[0]+Q_011000211*R_013[0]+-1*Q_111000011*R_111[0]+Q_111000111*R_112[0]+-1*Q_111000211*R_113[0]+Q_211000011*R_211[0]+-1*Q_211000111*R_212[0]+Q_211000211*R_213[0]; double QR_010001011011=Q_010001011*R_011[0]+-1*Q_010001111*R_012[0]+Q_010001211*R_013[0]+-1*Q_010101011*R_021[0]+Q_010101111*R_022[0]+-1*Q_010101211*R_023[0]+-1*Q_110001011*R_111[0]+Q_110001111*R_112[0]+-1*Q_110001211*R_113[0]+Q_110101011*R_121[0]+-1*Q_110101111*R_122[0]+Q_110101211*R_123[0]; double QR_010000012011=Q_010000012*R_011[0]+-1*Q_010000112*R_012[0]+Q_010000212*R_013[0]+-1*Q_010000312*R_014[0]+-1*Q_110000012*R_111[0]+Q_110000112*R_112[0]+-1*Q_110000212*R_113[0]+Q_110000312*R_114[0]; double QR_002010010011=Q_002010010*R_011[0]+-1*Q_002010110*R_012[0]+-1*Q_002110010*R_021[0]+Q_002110110*R_022[0]+-1*Q_102010010*R_111[0]+Q_102010110*R_112[0]+Q_102110010*R_121[0]+-1*Q_102110110*R_122[0]+Q_202010010*R_211[0]+-1*Q_202010110*R_212[0]+-1*Q_202110010*R_221[0]+Q_202110110*R_222[0]; double QR_001011010011=Q_001011010*R_011[0]+-1*Q_001011110*R_012[0]+-1*Q_001111010*R_021[0]+Q_001111110*R_022[0]+Q_001211010*R_031[0]+-1*Q_001211110*R_032[0]+-1*Q_101011010*R_111[0]+Q_101011110*R_112[0]+Q_101111010*R_121[0]+-1*Q_101111110*R_122[0]+-1*Q_101211010*R_131[0]+Q_101211110*R_132[0]; double QR_000012010011=Q_000012010*R_011[0]+-1*Q_000012110*R_012[0]+-1*Q_000112010*R_021[0]+Q_000112110*R_022[0]+Q_000212010*R_031[0]+-1*Q_000212110*R_032[0]+-1*Q_000312010*R_041[0]+Q_000312110*R_042[0]; double QR_001010011011=Q_001010011*R_011[0]+-1*Q_001010111*R_012[0]+Q_001010211*R_013[0]+-1*Q_001110011*R_021[0]+Q_001110111*R_022[0]+-1*Q_001110211*R_023[0]+-1*Q_101010011*R_111[0]+Q_101010111*R_112[0]+-1*Q_101010211*R_113[0]+Q_101110011*R_121[0]+-1*Q_101110111*R_122[0]+Q_101110211*R_123[0]; double QR_000011011011=Q_000011011*R_011[0]+-1*Q_000011111*R_012[0]+Q_000011211*R_013[0]+-1*Q_000111011*R_021[0]+Q_000111111*R_022[0]+-1*Q_000111211*R_023[0]+Q_000211011*R_031[0]+-1*Q_000211111*R_032[0]+Q_000211211*R_033[0]; double QR_000010012011=Q_000010012*R_011[0]+-1*Q_000010112*R_012[0]+Q_000010212*R_013[0]+-1*Q_000010312*R_014[0]+-1*Q_000110012*R_021[0]+Q_000110112*R_022[0]+-1*Q_000110212*R_023[0]+Q_000110312*R_024[0]; double QR_002000020011=Q_002000020*R_011[0]+-1*Q_002000120*R_012[0]+Q_002000220*R_013[0]+-1*Q_102000020*R_111[0]+Q_102000120*R_112[0]+-1*Q_102000220*R_113[0]+Q_202000020*R_211[0]+-1*Q_202000120*R_212[0]+Q_202000220*R_213[0]; double QR_001001020011=Q_001001020*R_011[0]+-1*Q_001001120*R_012[0]+Q_001001220*R_013[0]+-1*Q_001101020*R_021[0]+Q_001101120*R_022[0]+-1*Q_001101220*R_023[0]+-1*Q_101001020*R_111[0]+Q_101001120*R_112[0]+-1*Q_101001220*R_113[0]+Q_101101020*R_121[0]+-1*Q_101101120*R_122[0]+Q_101101220*R_123[0]; double QR_000002020011=Q_000002020*R_011[0]+-1*Q_000002120*R_012[0]+Q_000002220*R_013[0]+-1*Q_000102020*R_021[0]+Q_000102120*R_022[0]+-1*Q_000102220*R_023[0]+Q_000202020*R_031[0]+-1*Q_000202120*R_032[0]+Q_000202220*R_033[0]; double QR_001000021011=Q_001000021*R_011[0]+-1*Q_001000121*R_012[0]+Q_001000221*R_013[0]+-1*Q_001000321*R_014[0]+-1*Q_101000021*R_111[0]+Q_101000121*R_112[0]+-1*Q_101000221*R_113[0]+Q_101000321*R_114[0]; double QR_000001021011=Q_000001021*R_011[0]+-1*Q_000001121*R_012[0]+Q_000001221*R_013[0]+-1*Q_000001321*R_014[0]+-1*Q_000101021*R_021[0]+Q_000101121*R_022[0]+-1*Q_000101221*R_023[0]+Q_000101321*R_024[0]; double QR_000000022011=Q_000000022*R_011[0]+-1*Q_000000122*R_012[0]+Q_000000222*R_013[0]+-1*Q_000000322*R_014[0]+Q_000000422*R_015[0]; double QR_022000000020=Q_022000000*R_020[0]+-1*Q_122000000*R_120[0]+Q_222000000*R_220[0]+-1*Q_322000000*R_320[0]+Q_422000000*R_420[0]; double QR_021001000020=Q_021001000*R_020[0]+-1*Q_021101000*R_030[0]+-1*Q_121001000*R_120[0]+Q_121101000*R_130[0]+Q_221001000*R_220[0]+-1*Q_221101000*R_230[0]+-1*Q_321001000*R_320[0]+Q_321101000*R_330[0]; double QR_020002000020=Q_020002000*R_020[0]+-1*Q_020102000*R_030[0]+Q_020202000*R_040[0]+-1*Q_120002000*R_120[0]+Q_120102000*R_130[0]+-1*Q_120202000*R_140[0]+Q_220002000*R_220[0]+-1*Q_220102000*R_230[0]+Q_220202000*R_240[0]; double QR_021000001020=Q_021000001*R_020[0]+-1*Q_021000101*R_021[0]+-1*Q_121000001*R_120[0]+Q_121000101*R_121[0]+Q_221000001*R_220[0]+-1*Q_221000101*R_221[0]+-1*Q_321000001*R_320[0]+Q_321000101*R_321[0]; double QR_020001001020=Q_020001001*R_020[0]+-1*Q_020001101*R_021[0]+-1*Q_020101001*R_030[0]+Q_020101101*R_031[0]+-1*Q_120001001*R_120[0]+Q_120001101*R_121[0]+Q_120101001*R_130[0]+-1*Q_120101101*R_131[0]+Q_220001001*R_220[0]+-1*Q_220001101*R_221[0]+-1*Q_220101001*R_230[0]+Q_220101101*R_231[0]; double QR_020000002020=Q_020000002*R_020[0]+-1*Q_020000102*R_021[0]+Q_020000202*R_022[0]+-1*Q_120000002*R_120[0]+Q_120000102*R_121[0]+-1*Q_120000202*R_122[0]+Q_220000002*R_220[0]+-1*Q_220000102*R_221[0]+Q_220000202*R_222[0]; double QR_012010000020=Q_012010000*R_020[0]+-1*Q_012110000*R_030[0]+-1*Q_112010000*R_120[0]+Q_112110000*R_130[0]+Q_212010000*R_220[0]+-1*Q_212110000*R_230[0]+-1*Q_312010000*R_320[0]+Q_312110000*R_330[0]; double QR_011011000020=Q_011011000*R_020[0]+-1*Q_011111000*R_030[0]+Q_011211000*R_040[0]+-1*Q_111011000*R_120[0]+Q_111111000*R_130[0]+-1*Q_111211000*R_140[0]+Q_211011000*R_220[0]+-1*Q_211111000*R_230[0]+Q_211211000*R_240[0]; double QR_010012000020=Q_010012000*R_020[0]+-1*Q_010112000*R_030[0]+Q_010212000*R_040[0]+-1*Q_010312000*R_050[0]+-1*Q_110012000*R_120[0]+Q_110112000*R_130[0]+-1*Q_110212000*R_140[0]+Q_110312000*R_150[0]; double QR_011010001020=Q_011010001*R_020[0]+-1*Q_011010101*R_021[0]+-1*Q_011110001*R_030[0]+Q_011110101*R_031[0]+-1*Q_111010001*R_120[0]+Q_111010101*R_121[0]+Q_111110001*R_130[0]+-1*Q_111110101*R_131[0]+Q_211010001*R_220[0]+-1*Q_211010101*R_221[0]+-1*Q_211110001*R_230[0]+Q_211110101*R_231[0]; double QR_010011001020=Q_010011001*R_020[0]+-1*Q_010011101*R_021[0]+-1*Q_010111001*R_030[0]+Q_010111101*R_031[0]+Q_010211001*R_040[0]+-1*Q_010211101*R_041[0]+-1*Q_110011001*R_120[0]+Q_110011101*R_121[0]+Q_110111001*R_130[0]+-1*Q_110111101*R_131[0]+-1*Q_110211001*R_140[0]+Q_110211101*R_141[0]; double QR_010010002020=Q_010010002*R_020[0]+-1*Q_010010102*R_021[0]+Q_010010202*R_022[0]+-1*Q_010110002*R_030[0]+Q_010110102*R_031[0]+-1*Q_010110202*R_032[0]+-1*Q_110010002*R_120[0]+Q_110010102*R_121[0]+-1*Q_110010202*R_122[0]+Q_110110002*R_130[0]+-1*Q_110110102*R_131[0]+Q_110110202*R_132[0]; double QR_002020000020=Q_002020000*R_020[0]+-1*Q_002120000*R_030[0]+Q_002220000*R_040[0]+-1*Q_102020000*R_120[0]+Q_102120000*R_130[0]+-1*Q_102220000*R_140[0]+Q_202020000*R_220[0]+-1*Q_202120000*R_230[0]+Q_202220000*R_240[0]; double QR_001021000020=Q_001021000*R_020[0]+-1*Q_001121000*R_030[0]+Q_001221000*R_040[0]+-1*Q_001321000*R_050[0]+-1*Q_101021000*R_120[0]+Q_101121000*R_130[0]+-1*Q_101221000*R_140[0]+Q_101321000*R_150[0]; double QR_000022000020=Q_000022000*R_020[0]+-1*Q_000122000*R_030[0]+Q_000222000*R_040[0]+-1*Q_000322000*R_050[0]+Q_000422000*R_060[0]; double QR_001020001020=Q_001020001*R_020[0]+-1*Q_001020101*R_021[0]+-1*Q_001120001*R_030[0]+Q_001120101*R_031[0]+Q_001220001*R_040[0]+-1*Q_001220101*R_041[0]+-1*Q_101020001*R_120[0]+Q_101020101*R_121[0]+Q_101120001*R_130[0]+-1*Q_101120101*R_131[0]+-1*Q_101220001*R_140[0]+Q_101220101*R_141[0]; double QR_000021001020=Q_000021001*R_020[0]+-1*Q_000021101*R_021[0]+-1*Q_000121001*R_030[0]+Q_000121101*R_031[0]+Q_000221001*R_040[0]+-1*Q_000221101*R_041[0]+-1*Q_000321001*R_050[0]+Q_000321101*R_051[0]; double QR_000020002020=Q_000020002*R_020[0]+-1*Q_000020102*R_021[0]+Q_000020202*R_022[0]+-1*Q_000120002*R_030[0]+Q_000120102*R_031[0]+-1*Q_000120202*R_032[0]+Q_000220002*R_040[0]+-1*Q_000220102*R_041[0]+Q_000220202*R_042[0]; double QR_012000010020=Q_012000010*R_020[0]+-1*Q_012000110*R_021[0]+-1*Q_112000010*R_120[0]+Q_112000110*R_121[0]+Q_212000010*R_220[0]+-1*Q_212000110*R_221[0]+-1*Q_312000010*R_320[0]+Q_312000110*R_321[0]; double QR_011001010020=Q_011001010*R_020[0]+-1*Q_011001110*R_021[0]+-1*Q_011101010*R_030[0]+Q_011101110*R_031[0]+-1*Q_111001010*R_120[0]+Q_111001110*R_121[0]+Q_111101010*R_130[0]+-1*Q_111101110*R_131[0]+Q_211001010*R_220[0]+-1*Q_211001110*R_221[0]+-1*Q_211101010*R_230[0]+Q_211101110*R_231[0]; double QR_010002010020=Q_010002010*R_020[0]+-1*Q_010002110*R_021[0]+-1*Q_010102010*R_030[0]+Q_010102110*R_031[0]+Q_010202010*R_040[0]+-1*Q_010202110*R_041[0]+-1*Q_110002010*R_120[0]+Q_110002110*R_121[0]+Q_110102010*R_130[0]+-1*Q_110102110*R_131[0]+-1*Q_110202010*R_140[0]+Q_110202110*R_141[0]; double QR_011000011020=Q_011000011*R_020[0]+-1*Q_011000111*R_021[0]+Q_011000211*R_022[0]+-1*Q_111000011*R_120[0]+Q_111000111*R_121[0]+-1*Q_111000211*R_122[0]+Q_211000011*R_220[0]+-1*Q_211000111*R_221[0]+Q_211000211*R_222[0]; double QR_010001011020=Q_010001011*R_020[0]+-1*Q_010001111*R_021[0]+Q_010001211*R_022[0]+-1*Q_010101011*R_030[0]+Q_010101111*R_031[0]+-1*Q_010101211*R_032[0]+-1*Q_110001011*R_120[0]+Q_110001111*R_121[0]+-1*Q_110001211*R_122[0]+Q_110101011*R_130[0]+-1*Q_110101111*R_131[0]+Q_110101211*R_132[0]; double QR_010000012020=Q_010000012*R_020[0]+-1*Q_010000112*R_021[0]+Q_010000212*R_022[0]+-1*Q_010000312*R_023[0]+-1*Q_110000012*R_120[0]+Q_110000112*R_121[0]+-1*Q_110000212*R_122[0]+Q_110000312*R_123[0]; double QR_002010010020=Q_002010010*R_020[0]+-1*Q_002010110*R_021[0]+-1*Q_002110010*R_030[0]+Q_002110110*R_031[0]+-1*Q_102010010*R_120[0]+Q_102010110*R_121[0]+Q_102110010*R_130[0]+-1*Q_102110110*R_131[0]+Q_202010010*R_220[0]+-1*Q_202010110*R_221[0]+-1*Q_202110010*R_230[0]+Q_202110110*R_231[0]; double QR_001011010020=Q_001011010*R_020[0]+-1*Q_001011110*R_021[0]+-1*Q_001111010*R_030[0]+Q_001111110*R_031[0]+Q_001211010*R_040[0]+-1*Q_001211110*R_041[0]+-1*Q_101011010*R_120[0]+Q_101011110*R_121[0]+Q_101111010*R_130[0]+-1*Q_101111110*R_131[0]+-1*Q_101211010*R_140[0]+Q_101211110*R_141[0]; double QR_000012010020=Q_000012010*R_020[0]+-1*Q_000012110*R_021[0]+-1*Q_000112010*R_030[0]+Q_000112110*R_031[0]+Q_000212010*R_040[0]+-1*Q_000212110*R_041[0]+-1*Q_000312010*R_050[0]+Q_000312110*R_051[0]; double QR_001010011020=Q_001010011*R_020[0]+-1*Q_001010111*R_021[0]+Q_001010211*R_022[0]+-1*Q_001110011*R_030[0]+Q_001110111*R_031[0]+-1*Q_001110211*R_032[0]+-1*Q_101010011*R_120[0]+Q_101010111*R_121[0]+-1*Q_101010211*R_122[0]+Q_101110011*R_130[0]+-1*Q_101110111*R_131[0]+Q_101110211*R_132[0]; double QR_000011011020=Q_000011011*R_020[0]+-1*Q_000011111*R_021[0]+Q_000011211*R_022[0]+-1*Q_000111011*R_030[0]+Q_000111111*R_031[0]+-1*Q_000111211*R_032[0]+Q_000211011*R_040[0]+-1*Q_000211111*R_041[0]+Q_000211211*R_042[0]; double QR_000010012020=Q_000010012*R_020[0]+-1*Q_000010112*R_021[0]+Q_000010212*R_022[0]+-1*Q_000010312*R_023[0]+-1*Q_000110012*R_030[0]+Q_000110112*R_031[0]+-1*Q_000110212*R_032[0]+Q_000110312*R_033[0]; double QR_002000020020=Q_002000020*R_020[0]+-1*Q_002000120*R_021[0]+Q_002000220*R_022[0]+-1*Q_102000020*R_120[0]+Q_102000120*R_121[0]+-1*Q_102000220*R_122[0]+Q_202000020*R_220[0]+-1*Q_202000120*R_221[0]+Q_202000220*R_222[0]; double QR_001001020020=Q_001001020*R_020[0]+-1*Q_001001120*R_021[0]+Q_001001220*R_022[0]+-1*Q_001101020*R_030[0]+Q_001101120*R_031[0]+-1*Q_001101220*R_032[0]+-1*Q_101001020*R_120[0]+Q_101001120*R_121[0]+-1*Q_101001220*R_122[0]+Q_101101020*R_130[0]+-1*Q_101101120*R_131[0]+Q_101101220*R_132[0]; double QR_000002020020=Q_000002020*R_020[0]+-1*Q_000002120*R_021[0]+Q_000002220*R_022[0]+-1*Q_000102020*R_030[0]+Q_000102120*R_031[0]+-1*Q_000102220*R_032[0]+Q_000202020*R_040[0]+-1*Q_000202120*R_041[0]+Q_000202220*R_042[0]; double QR_001000021020=Q_001000021*R_020[0]+-1*Q_001000121*R_021[0]+Q_001000221*R_022[0]+-1*Q_001000321*R_023[0]+-1*Q_101000021*R_120[0]+Q_101000121*R_121[0]+-1*Q_101000221*R_122[0]+Q_101000321*R_123[0]; double QR_000001021020=Q_000001021*R_020[0]+-1*Q_000001121*R_021[0]+Q_000001221*R_022[0]+-1*Q_000001321*R_023[0]+-1*Q_000101021*R_030[0]+Q_000101121*R_031[0]+-1*Q_000101221*R_032[0]+Q_000101321*R_033[0]; double QR_000000022020=Q_000000022*R_020[0]+-1*Q_000000122*R_021[0]+Q_000000222*R_022[0]+-1*Q_000000322*R_023[0]+Q_000000422*R_024[0]; double QR_022000000101=Q_022000000*R_101[0]+-1*Q_122000000*R_201[0]+Q_222000000*R_301[0]+-1*Q_322000000*R_401[0]+Q_422000000*R_501[0]; double QR_021001000101=Q_021001000*R_101[0]+-1*Q_021101000*R_111[0]+-1*Q_121001000*R_201[0]+Q_121101000*R_211[0]+Q_221001000*R_301[0]+-1*Q_221101000*R_311[0]+-1*Q_321001000*R_401[0]+Q_321101000*R_411[0]; double QR_020002000101=Q_020002000*R_101[0]+-1*Q_020102000*R_111[0]+Q_020202000*R_121[0]+-1*Q_120002000*R_201[0]+Q_120102000*R_211[0]+-1*Q_120202000*R_221[0]+Q_220002000*R_301[0]+-1*Q_220102000*R_311[0]+Q_220202000*R_321[0]; double QR_021000001101=Q_021000001*R_101[0]+-1*Q_021000101*R_102[0]+-1*Q_121000001*R_201[0]+Q_121000101*R_202[0]+Q_221000001*R_301[0]+-1*Q_221000101*R_302[0]+-1*Q_321000001*R_401[0]+Q_321000101*R_402[0]; double QR_020001001101=Q_020001001*R_101[0]+-1*Q_020001101*R_102[0]+-1*Q_020101001*R_111[0]+Q_020101101*R_112[0]+-1*Q_120001001*R_201[0]+Q_120001101*R_202[0]+Q_120101001*R_211[0]+-1*Q_120101101*R_212[0]+Q_220001001*R_301[0]+-1*Q_220001101*R_302[0]+-1*Q_220101001*R_311[0]+Q_220101101*R_312[0]; double QR_020000002101=Q_020000002*R_101[0]+-1*Q_020000102*R_102[0]+Q_020000202*R_103[0]+-1*Q_120000002*R_201[0]+Q_120000102*R_202[0]+-1*Q_120000202*R_203[0]+Q_220000002*R_301[0]+-1*Q_220000102*R_302[0]+Q_220000202*R_303[0]; double QR_012010000101=Q_012010000*R_101[0]+-1*Q_012110000*R_111[0]+-1*Q_112010000*R_201[0]+Q_112110000*R_211[0]+Q_212010000*R_301[0]+-1*Q_212110000*R_311[0]+-1*Q_312010000*R_401[0]+Q_312110000*R_411[0]; double QR_011011000101=Q_011011000*R_101[0]+-1*Q_011111000*R_111[0]+Q_011211000*R_121[0]+-1*Q_111011000*R_201[0]+Q_111111000*R_211[0]+-1*Q_111211000*R_221[0]+Q_211011000*R_301[0]+-1*Q_211111000*R_311[0]+Q_211211000*R_321[0]; double QR_010012000101=Q_010012000*R_101[0]+-1*Q_010112000*R_111[0]+Q_010212000*R_121[0]+-1*Q_010312000*R_131[0]+-1*Q_110012000*R_201[0]+Q_110112000*R_211[0]+-1*Q_110212000*R_221[0]+Q_110312000*R_231[0]; double QR_011010001101=Q_011010001*R_101[0]+-1*Q_011010101*R_102[0]+-1*Q_011110001*R_111[0]+Q_011110101*R_112[0]+-1*Q_111010001*R_201[0]+Q_111010101*R_202[0]+Q_111110001*R_211[0]+-1*Q_111110101*R_212[0]+Q_211010001*R_301[0]+-1*Q_211010101*R_302[0]+-1*Q_211110001*R_311[0]+Q_211110101*R_312[0]; double QR_010011001101=Q_010011001*R_101[0]+-1*Q_010011101*R_102[0]+-1*Q_010111001*R_111[0]+Q_010111101*R_112[0]+Q_010211001*R_121[0]+-1*Q_010211101*R_122[0]+-1*Q_110011001*R_201[0]+Q_110011101*R_202[0]+Q_110111001*R_211[0]+-1*Q_110111101*R_212[0]+-1*Q_110211001*R_221[0]+Q_110211101*R_222[0]; double QR_010010002101=Q_010010002*R_101[0]+-1*Q_010010102*R_102[0]+Q_010010202*R_103[0]+-1*Q_010110002*R_111[0]+Q_010110102*R_112[0]+-1*Q_010110202*R_113[0]+-1*Q_110010002*R_201[0]+Q_110010102*R_202[0]+-1*Q_110010202*R_203[0]+Q_110110002*R_211[0]+-1*Q_110110102*R_212[0]+Q_110110202*R_213[0]; double QR_002020000101=Q_002020000*R_101[0]+-1*Q_002120000*R_111[0]+Q_002220000*R_121[0]+-1*Q_102020000*R_201[0]+Q_102120000*R_211[0]+-1*Q_102220000*R_221[0]+Q_202020000*R_301[0]+-1*Q_202120000*R_311[0]+Q_202220000*R_321[0]; double QR_001021000101=Q_001021000*R_101[0]+-1*Q_001121000*R_111[0]+Q_001221000*R_121[0]+-1*Q_001321000*R_131[0]+-1*Q_101021000*R_201[0]+Q_101121000*R_211[0]+-1*Q_101221000*R_221[0]+Q_101321000*R_231[0]; double QR_000022000101=Q_000022000*R_101[0]+-1*Q_000122000*R_111[0]+Q_000222000*R_121[0]+-1*Q_000322000*R_131[0]+Q_000422000*R_141[0]; double QR_001020001101=Q_001020001*R_101[0]+-1*Q_001020101*R_102[0]+-1*Q_001120001*R_111[0]+Q_001120101*R_112[0]+Q_001220001*R_121[0]+-1*Q_001220101*R_122[0]+-1*Q_101020001*R_201[0]+Q_101020101*R_202[0]+Q_101120001*R_211[0]+-1*Q_101120101*R_212[0]+-1*Q_101220001*R_221[0]+Q_101220101*R_222[0]; double QR_000021001101=Q_000021001*R_101[0]+-1*Q_000021101*R_102[0]+-1*Q_000121001*R_111[0]+Q_000121101*R_112[0]+Q_000221001*R_121[0]+-1*Q_000221101*R_122[0]+-1*Q_000321001*R_131[0]+Q_000321101*R_132[0]; double QR_000020002101=Q_000020002*R_101[0]+-1*Q_000020102*R_102[0]+Q_000020202*R_103[0]+-1*Q_000120002*R_111[0]+Q_000120102*R_112[0]+-1*Q_000120202*R_113[0]+Q_000220002*R_121[0]+-1*Q_000220102*R_122[0]+Q_000220202*R_123[0]; double QR_012000010101=Q_012000010*R_101[0]+-1*Q_012000110*R_102[0]+-1*Q_112000010*R_201[0]+Q_112000110*R_202[0]+Q_212000010*R_301[0]+-1*Q_212000110*R_302[0]+-1*Q_312000010*R_401[0]+Q_312000110*R_402[0]; double QR_011001010101=Q_011001010*R_101[0]+-1*Q_011001110*R_102[0]+-1*Q_011101010*R_111[0]+Q_011101110*R_112[0]+-1*Q_111001010*R_201[0]+Q_111001110*R_202[0]+Q_111101010*R_211[0]+-1*Q_111101110*R_212[0]+Q_211001010*R_301[0]+-1*Q_211001110*R_302[0]+-1*Q_211101010*R_311[0]+Q_211101110*R_312[0]; double QR_010002010101=Q_010002010*R_101[0]+-1*Q_010002110*R_102[0]+-1*Q_010102010*R_111[0]+Q_010102110*R_112[0]+Q_010202010*R_121[0]+-1*Q_010202110*R_122[0]+-1*Q_110002010*R_201[0]+Q_110002110*R_202[0]+Q_110102010*R_211[0]+-1*Q_110102110*R_212[0]+-1*Q_110202010*R_221[0]+Q_110202110*R_222[0]; double QR_011000011101=Q_011000011*R_101[0]+-1*Q_011000111*R_102[0]+Q_011000211*R_103[0]+-1*Q_111000011*R_201[0]+Q_111000111*R_202[0]+-1*Q_111000211*R_203[0]+Q_211000011*R_301[0]+-1*Q_211000111*R_302[0]+Q_211000211*R_303[0]; double QR_010001011101=Q_010001011*R_101[0]+-1*Q_010001111*R_102[0]+Q_010001211*R_103[0]+-1*Q_010101011*R_111[0]+Q_010101111*R_112[0]+-1*Q_010101211*R_113[0]+-1*Q_110001011*R_201[0]+Q_110001111*R_202[0]+-1*Q_110001211*R_203[0]+Q_110101011*R_211[0]+-1*Q_110101111*R_212[0]+Q_110101211*R_213[0]; double QR_010000012101=Q_010000012*R_101[0]+-1*Q_010000112*R_102[0]+Q_010000212*R_103[0]+-1*Q_010000312*R_104[0]+-1*Q_110000012*R_201[0]+Q_110000112*R_202[0]+-1*Q_110000212*R_203[0]+Q_110000312*R_204[0]; double QR_002010010101=Q_002010010*R_101[0]+-1*Q_002010110*R_102[0]+-1*Q_002110010*R_111[0]+Q_002110110*R_112[0]+-1*Q_102010010*R_201[0]+Q_102010110*R_202[0]+Q_102110010*R_211[0]+-1*Q_102110110*R_212[0]+Q_202010010*R_301[0]+-1*Q_202010110*R_302[0]+-1*Q_202110010*R_311[0]+Q_202110110*R_312[0]; double QR_001011010101=Q_001011010*R_101[0]+-1*Q_001011110*R_102[0]+-1*Q_001111010*R_111[0]+Q_001111110*R_112[0]+Q_001211010*R_121[0]+-1*Q_001211110*R_122[0]+-1*Q_101011010*R_201[0]+Q_101011110*R_202[0]+Q_101111010*R_211[0]+-1*Q_101111110*R_212[0]+-1*Q_101211010*R_221[0]+Q_101211110*R_222[0]; double QR_000012010101=Q_000012010*R_101[0]+-1*Q_000012110*R_102[0]+-1*Q_000112010*R_111[0]+Q_000112110*R_112[0]+Q_000212010*R_121[0]+-1*Q_000212110*R_122[0]+-1*Q_000312010*R_131[0]+Q_000312110*R_132[0]; double QR_001010011101=Q_001010011*R_101[0]+-1*Q_001010111*R_102[0]+Q_001010211*R_103[0]+-1*Q_001110011*R_111[0]+Q_001110111*R_112[0]+-1*Q_001110211*R_113[0]+-1*Q_101010011*R_201[0]+Q_101010111*R_202[0]+-1*Q_101010211*R_203[0]+Q_101110011*R_211[0]+-1*Q_101110111*R_212[0]+Q_101110211*R_213[0]; double QR_000011011101=Q_000011011*R_101[0]+-1*Q_000011111*R_102[0]+Q_000011211*R_103[0]+-1*Q_000111011*R_111[0]+Q_000111111*R_112[0]+-1*Q_000111211*R_113[0]+Q_000211011*R_121[0]+-1*Q_000211111*R_122[0]+Q_000211211*R_123[0]; double QR_000010012101=Q_000010012*R_101[0]+-1*Q_000010112*R_102[0]+Q_000010212*R_103[0]+-1*Q_000010312*R_104[0]+-1*Q_000110012*R_111[0]+Q_000110112*R_112[0]+-1*Q_000110212*R_113[0]+Q_000110312*R_114[0]; double QR_002000020101=Q_002000020*R_101[0]+-1*Q_002000120*R_102[0]+Q_002000220*R_103[0]+-1*Q_102000020*R_201[0]+Q_102000120*R_202[0]+-1*Q_102000220*R_203[0]+Q_202000020*R_301[0]+-1*Q_202000120*R_302[0]+Q_202000220*R_303[0]; double QR_001001020101=Q_001001020*R_101[0]+-1*Q_001001120*R_102[0]+Q_001001220*R_103[0]+-1*Q_001101020*R_111[0]+Q_001101120*R_112[0]+-1*Q_001101220*R_113[0]+-1*Q_101001020*R_201[0]+Q_101001120*R_202[0]+-1*Q_101001220*R_203[0]+Q_101101020*R_211[0]+-1*Q_101101120*R_212[0]+Q_101101220*R_213[0]; double QR_000002020101=Q_000002020*R_101[0]+-1*Q_000002120*R_102[0]+Q_000002220*R_103[0]+-1*Q_000102020*R_111[0]+Q_000102120*R_112[0]+-1*Q_000102220*R_113[0]+Q_000202020*R_121[0]+-1*Q_000202120*R_122[0]+Q_000202220*R_123[0]; double QR_001000021101=Q_001000021*R_101[0]+-1*Q_001000121*R_102[0]+Q_001000221*R_103[0]+-1*Q_001000321*R_104[0]+-1*Q_101000021*R_201[0]+Q_101000121*R_202[0]+-1*Q_101000221*R_203[0]+Q_101000321*R_204[0]; double QR_000001021101=Q_000001021*R_101[0]+-1*Q_000001121*R_102[0]+Q_000001221*R_103[0]+-1*Q_000001321*R_104[0]+-1*Q_000101021*R_111[0]+Q_000101121*R_112[0]+-1*Q_000101221*R_113[0]+Q_000101321*R_114[0]; double QR_000000022101=Q_000000022*R_101[0]+-1*Q_000000122*R_102[0]+Q_000000222*R_103[0]+-1*Q_000000322*R_104[0]+Q_000000422*R_105[0]; double QR_022000000110=Q_022000000*R_110[0]+-1*Q_122000000*R_210[0]+Q_222000000*R_310[0]+-1*Q_322000000*R_410[0]+Q_422000000*R_510[0]; double QR_021001000110=Q_021001000*R_110[0]+-1*Q_021101000*R_120[0]+-1*Q_121001000*R_210[0]+Q_121101000*R_220[0]+Q_221001000*R_310[0]+-1*Q_221101000*R_320[0]+-1*Q_321001000*R_410[0]+Q_321101000*R_420[0]; double QR_020002000110=Q_020002000*R_110[0]+-1*Q_020102000*R_120[0]+Q_020202000*R_130[0]+-1*Q_120002000*R_210[0]+Q_120102000*R_220[0]+-1*Q_120202000*R_230[0]+Q_220002000*R_310[0]+-1*Q_220102000*R_320[0]+Q_220202000*R_330[0]; double QR_021000001110=Q_021000001*R_110[0]+-1*Q_021000101*R_111[0]+-1*Q_121000001*R_210[0]+Q_121000101*R_211[0]+Q_221000001*R_310[0]+-1*Q_221000101*R_311[0]+-1*Q_321000001*R_410[0]+Q_321000101*R_411[0]; double QR_020001001110=Q_020001001*R_110[0]+-1*Q_020001101*R_111[0]+-1*Q_020101001*R_120[0]+Q_020101101*R_121[0]+-1*Q_120001001*R_210[0]+Q_120001101*R_211[0]+Q_120101001*R_220[0]+-1*Q_120101101*R_221[0]+Q_220001001*R_310[0]+-1*Q_220001101*R_311[0]+-1*Q_220101001*R_320[0]+Q_220101101*R_321[0]; double QR_020000002110=Q_020000002*R_110[0]+-1*Q_020000102*R_111[0]+Q_020000202*R_112[0]+-1*Q_120000002*R_210[0]+Q_120000102*R_211[0]+-1*Q_120000202*R_212[0]+Q_220000002*R_310[0]+-1*Q_220000102*R_311[0]+Q_220000202*R_312[0]; double QR_012010000110=Q_012010000*R_110[0]+-1*Q_012110000*R_120[0]+-1*Q_112010000*R_210[0]+Q_112110000*R_220[0]+Q_212010000*R_310[0]+-1*Q_212110000*R_320[0]+-1*Q_312010000*R_410[0]+Q_312110000*R_420[0]; double QR_011011000110=Q_011011000*R_110[0]+-1*Q_011111000*R_120[0]+Q_011211000*R_130[0]+-1*Q_111011000*R_210[0]+Q_111111000*R_220[0]+-1*Q_111211000*R_230[0]+Q_211011000*R_310[0]+-1*Q_211111000*R_320[0]+Q_211211000*R_330[0]; double QR_010012000110=Q_010012000*R_110[0]+-1*Q_010112000*R_120[0]+Q_010212000*R_130[0]+-1*Q_010312000*R_140[0]+-1*Q_110012000*R_210[0]+Q_110112000*R_220[0]+-1*Q_110212000*R_230[0]+Q_110312000*R_240[0]; double QR_011010001110=Q_011010001*R_110[0]+-1*Q_011010101*R_111[0]+-1*Q_011110001*R_120[0]+Q_011110101*R_121[0]+-1*Q_111010001*R_210[0]+Q_111010101*R_211[0]+Q_111110001*R_220[0]+-1*Q_111110101*R_221[0]+Q_211010001*R_310[0]+-1*Q_211010101*R_311[0]+-1*Q_211110001*R_320[0]+Q_211110101*R_321[0]; double QR_010011001110=Q_010011001*R_110[0]+-1*Q_010011101*R_111[0]+-1*Q_010111001*R_120[0]+Q_010111101*R_121[0]+Q_010211001*R_130[0]+-1*Q_010211101*R_131[0]+-1*Q_110011001*R_210[0]+Q_110011101*R_211[0]+Q_110111001*R_220[0]+-1*Q_110111101*R_221[0]+-1*Q_110211001*R_230[0]+Q_110211101*R_231[0]; double QR_010010002110=Q_010010002*R_110[0]+-1*Q_010010102*R_111[0]+Q_010010202*R_112[0]+-1*Q_010110002*R_120[0]+Q_010110102*R_121[0]+-1*Q_010110202*R_122[0]+-1*Q_110010002*R_210[0]+Q_110010102*R_211[0]+-1*Q_110010202*R_212[0]+Q_110110002*R_220[0]+-1*Q_110110102*R_221[0]+Q_110110202*R_222[0]; double QR_002020000110=Q_002020000*R_110[0]+-1*Q_002120000*R_120[0]+Q_002220000*R_130[0]+-1*Q_102020000*R_210[0]+Q_102120000*R_220[0]+-1*Q_102220000*R_230[0]+Q_202020000*R_310[0]+-1*Q_202120000*R_320[0]+Q_202220000*R_330[0]; double QR_001021000110=Q_001021000*R_110[0]+-1*Q_001121000*R_120[0]+Q_001221000*R_130[0]+-1*Q_001321000*R_140[0]+-1*Q_101021000*R_210[0]+Q_101121000*R_220[0]+-1*Q_101221000*R_230[0]+Q_101321000*R_240[0]; double QR_000022000110=Q_000022000*R_110[0]+-1*Q_000122000*R_120[0]+Q_000222000*R_130[0]+-1*Q_000322000*R_140[0]+Q_000422000*R_150[0]; double QR_001020001110=Q_001020001*R_110[0]+-1*Q_001020101*R_111[0]+-1*Q_001120001*R_120[0]+Q_001120101*R_121[0]+Q_001220001*R_130[0]+-1*Q_001220101*R_131[0]+-1*Q_101020001*R_210[0]+Q_101020101*R_211[0]+Q_101120001*R_220[0]+-1*Q_101120101*R_221[0]+-1*Q_101220001*R_230[0]+Q_101220101*R_231[0]; double QR_000021001110=Q_000021001*R_110[0]+-1*Q_000021101*R_111[0]+-1*Q_000121001*R_120[0]+Q_000121101*R_121[0]+Q_000221001*R_130[0]+-1*Q_000221101*R_131[0]+-1*Q_000321001*R_140[0]+Q_000321101*R_141[0]; double QR_000020002110=Q_000020002*R_110[0]+-1*Q_000020102*R_111[0]+Q_000020202*R_112[0]+-1*Q_000120002*R_120[0]+Q_000120102*R_121[0]+-1*Q_000120202*R_122[0]+Q_000220002*R_130[0]+-1*Q_000220102*R_131[0]+Q_000220202*R_132[0]; double QR_012000010110=Q_012000010*R_110[0]+-1*Q_012000110*R_111[0]+-1*Q_112000010*R_210[0]+Q_112000110*R_211[0]+Q_212000010*R_310[0]+-1*Q_212000110*R_311[0]+-1*Q_312000010*R_410[0]+Q_312000110*R_411[0]; double QR_011001010110=Q_011001010*R_110[0]+-1*Q_011001110*R_111[0]+-1*Q_011101010*R_120[0]+Q_011101110*R_121[0]+-1*Q_111001010*R_210[0]+Q_111001110*R_211[0]+Q_111101010*R_220[0]+-1*Q_111101110*R_221[0]+Q_211001010*R_310[0]+-1*Q_211001110*R_311[0]+-1*Q_211101010*R_320[0]+Q_211101110*R_321[0]; double QR_010002010110=Q_010002010*R_110[0]+-1*Q_010002110*R_111[0]+-1*Q_010102010*R_120[0]+Q_010102110*R_121[0]+Q_010202010*R_130[0]+-1*Q_010202110*R_131[0]+-1*Q_110002010*R_210[0]+Q_110002110*R_211[0]+Q_110102010*R_220[0]+-1*Q_110102110*R_221[0]+-1*Q_110202010*R_230[0]+Q_110202110*R_231[0]; double QR_011000011110=Q_011000011*R_110[0]+-1*Q_011000111*R_111[0]+Q_011000211*R_112[0]+-1*Q_111000011*R_210[0]+Q_111000111*R_211[0]+-1*Q_111000211*R_212[0]+Q_211000011*R_310[0]+-1*Q_211000111*R_311[0]+Q_211000211*R_312[0]; double QR_010001011110=Q_010001011*R_110[0]+-1*Q_010001111*R_111[0]+Q_010001211*R_112[0]+-1*Q_010101011*R_120[0]+Q_010101111*R_121[0]+-1*Q_010101211*R_122[0]+-1*Q_110001011*R_210[0]+Q_110001111*R_211[0]+-1*Q_110001211*R_212[0]+Q_110101011*R_220[0]+-1*Q_110101111*R_221[0]+Q_110101211*R_222[0]; double QR_010000012110=Q_010000012*R_110[0]+-1*Q_010000112*R_111[0]+Q_010000212*R_112[0]+-1*Q_010000312*R_113[0]+-1*Q_110000012*R_210[0]+Q_110000112*R_211[0]+-1*Q_110000212*R_212[0]+Q_110000312*R_213[0]; double QR_002010010110=Q_002010010*R_110[0]+-1*Q_002010110*R_111[0]+-1*Q_002110010*R_120[0]+Q_002110110*R_121[0]+-1*Q_102010010*R_210[0]+Q_102010110*R_211[0]+Q_102110010*R_220[0]+-1*Q_102110110*R_221[0]+Q_202010010*R_310[0]+-1*Q_202010110*R_311[0]+-1*Q_202110010*R_320[0]+Q_202110110*R_321[0]; double QR_001011010110=Q_001011010*R_110[0]+-1*Q_001011110*R_111[0]+-1*Q_001111010*R_120[0]+Q_001111110*R_121[0]+Q_001211010*R_130[0]+-1*Q_001211110*R_131[0]+-1*Q_101011010*R_210[0]+Q_101011110*R_211[0]+Q_101111010*R_220[0]+-1*Q_101111110*R_221[0]+-1*Q_101211010*R_230[0]+Q_101211110*R_231[0]; double QR_000012010110=Q_000012010*R_110[0]+-1*Q_000012110*R_111[0]+-1*Q_000112010*R_120[0]+Q_000112110*R_121[0]+Q_000212010*R_130[0]+-1*Q_000212110*R_131[0]+-1*Q_000312010*R_140[0]+Q_000312110*R_141[0]; double QR_001010011110=Q_001010011*R_110[0]+-1*Q_001010111*R_111[0]+Q_001010211*R_112[0]+-1*Q_001110011*R_120[0]+Q_001110111*R_121[0]+-1*Q_001110211*R_122[0]+-1*Q_101010011*R_210[0]+Q_101010111*R_211[0]+-1*Q_101010211*R_212[0]+Q_101110011*R_220[0]+-1*Q_101110111*R_221[0]+Q_101110211*R_222[0]; double QR_000011011110=Q_000011011*R_110[0]+-1*Q_000011111*R_111[0]+Q_000011211*R_112[0]+-1*Q_000111011*R_120[0]+Q_000111111*R_121[0]+-1*Q_000111211*R_122[0]+Q_000211011*R_130[0]+-1*Q_000211111*R_131[0]+Q_000211211*R_132[0]; double QR_000010012110=Q_000010012*R_110[0]+-1*Q_000010112*R_111[0]+Q_000010212*R_112[0]+-1*Q_000010312*R_113[0]+-1*Q_000110012*R_120[0]+Q_000110112*R_121[0]+-1*Q_000110212*R_122[0]+Q_000110312*R_123[0]; double QR_002000020110=Q_002000020*R_110[0]+-1*Q_002000120*R_111[0]+Q_002000220*R_112[0]+-1*Q_102000020*R_210[0]+Q_102000120*R_211[0]+-1*Q_102000220*R_212[0]+Q_202000020*R_310[0]+-1*Q_202000120*R_311[0]+Q_202000220*R_312[0]; double QR_001001020110=Q_001001020*R_110[0]+-1*Q_001001120*R_111[0]+Q_001001220*R_112[0]+-1*Q_001101020*R_120[0]+Q_001101120*R_121[0]+-1*Q_001101220*R_122[0]+-1*Q_101001020*R_210[0]+Q_101001120*R_211[0]+-1*Q_101001220*R_212[0]+Q_101101020*R_220[0]+-1*Q_101101120*R_221[0]+Q_101101220*R_222[0]; double QR_000002020110=Q_000002020*R_110[0]+-1*Q_000002120*R_111[0]+Q_000002220*R_112[0]+-1*Q_000102020*R_120[0]+Q_000102120*R_121[0]+-1*Q_000102220*R_122[0]+Q_000202020*R_130[0]+-1*Q_000202120*R_131[0]+Q_000202220*R_132[0]; double QR_001000021110=Q_001000021*R_110[0]+-1*Q_001000121*R_111[0]+Q_001000221*R_112[0]+-1*Q_001000321*R_113[0]+-1*Q_101000021*R_210[0]+Q_101000121*R_211[0]+-1*Q_101000221*R_212[0]+Q_101000321*R_213[0]; double QR_000001021110=Q_000001021*R_110[0]+-1*Q_000001121*R_111[0]+Q_000001221*R_112[0]+-1*Q_000001321*R_113[0]+-1*Q_000101021*R_120[0]+Q_000101121*R_121[0]+-1*Q_000101221*R_122[0]+Q_000101321*R_123[0]; double QR_000000022110=Q_000000022*R_110[0]+-1*Q_000000122*R_111[0]+Q_000000222*R_112[0]+-1*Q_000000322*R_113[0]+Q_000000422*R_114[0]; double QR_022000000200=Q_022000000*R_200[0]+-1*Q_122000000*R_300[0]+Q_222000000*R_400[0]+-1*Q_322000000*R_500[0]+Q_422000000*R_600[0]; double QR_021001000200=Q_021001000*R_200[0]+-1*Q_021101000*R_210[0]+-1*Q_121001000*R_300[0]+Q_121101000*R_310[0]+Q_221001000*R_400[0]+-1*Q_221101000*R_410[0]+-1*Q_321001000*R_500[0]+Q_321101000*R_510[0]; double QR_020002000200=Q_020002000*R_200[0]+-1*Q_020102000*R_210[0]+Q_020202000*R_220[0]+-1*Q_120002000*R_300[0]+Q_120102000*R_310[0]+-1*Q_120202000*R_320[0]+Q_220002000*R_400[0]+-1*Q_220102000*R_410[0]+Q_220202000*R_420[0]; double QR_021000001200=Q_021000001*R_200[0]+-1*Q_021000101*R_201[0]+-1*Q_121000001*R_300[0]+Q_121000101*R_301[0]+Q_221000001*R_400[0]+-1*Q_221000101*R_401[0]+-1*Q_321000001*R_500[0]+Q_321000101*R_501[0]; double QR_020001001200=Q_020001001*R_200[0]+-1*Q_020001101*R_201[0]+-1*Q_020101001*R_210[0]+Q_020101101*R_211[0]+-1*Q_120001001*R_300[0]+Q_120001101*R_301[0]+Q_120101001*R_310[0]+-1*Q_120101101*R_311[0]+Q_220001001*R_400[0]+-1*Q_220001101*R_401[0]+-1*Q_220101001*R_410[0]+Q_220101101*R_411[0]; double QR_020000002200=Q_020000002*R_200[0]+-1*Q_020000102*R_201[0]+Q_020000202*R_202[0]+-1*Q_120000002*R_300[0]+Q_120000102*R_301[0]+-1*Q_120000202*R_302[0]+Q_220000002*R_400[0]+-1*Q_220000102*R_401[0]+Q_220000202*R_402[0]; double QR_012010000200=Q_012010000*R_200[0]+-1*Q_012110000*R_210[0]+-1*Q_112010000*R_300[0]+Q_112110000*R_310[0]+Q_212010000*R_400[0]+-1*Q_212110000*R_410[0]+-1*Q_312010000*R_500[0]+Q_312110000*R_510[0]; double QR_011011000200=Q_011011000*R_200[0]+-1*Q_011111000*R_210[0]+Q_011211000*R_220[0]+-1*Q_111011000*R_300[0]+Q_111111000*R_310[0]+-1*Q_111211000*R_320[0]+Q_211011000*R_400[0]+-1*Q_211111000*R_410[0]+Q_211211000*R_420[0]; double QR_010012000200=Q_010012000*R_200[0]+-1*Q_010112000*R_210[0]+Q_010212000*R_220[0]+-1*Q_010312000*R_230[0]+-1*Q_110012000*R_300[0]+Q_110112000*R_310[0]+-1*Q_110212000*R_320[0]+Q_110312000*R_330[0]; double QR_011010001200=Q_011010001*R_200[0]+-1*Q_011010101*R_201[0]+-1*Q_011110001*R_210[0]+Q_011110101*R_211[0]+-1*Q_111010001*R_300[0]+Q_111010101*R_301[0]+Q_111110001*R_310[0]+-1*Q_111110101*R_311[0]+Q_211010001*R_400[0]+-1*Q_211010101*R_401[0]+-1*Q_211110001*R_410[0]+Q_211110101*R_411[0]; double QR_010011001200=Q_010011001*R_200[0]+-1*Q_010011101*R_201[0]+-1*Q_010111001*R_210[0]+Q_010111101*R_211[0]+Q_010211001*R_220[0]+-1*Q_010211101*R_221[0]+-1*Q_110011001*R_300[0]+Q_110011101*R_301[0]+Q_110111001*R_310[0]+-1*Q_110111101*R_311[0]+-1*Q_110211001*R_320[0]+Q_110211101*R_321[0]; double QR_010010002200=Q_010010002*R_200[0]+-1*Q_010010102*R_201[0]+Q_010010202*R_202[0]+-1*Q_010110002*R_210[0]+Q_010110102*R_211[0]+-1*Q_010110202*R_212[0]+-1*Q_110010002*R_300[0]+Q_110010102*R_301[0]+-1*Q_110010202*R_302[0]+Q_110110002*R_310[0]+-1*Q_110110102*R_311[0]+Q_110110202*R_312[0]; double QR_002020000200=Q_002020000*R_200[0]+-1*Q_002120000*R_210[0]+Q_002220000*R_220[0]+-1*Q_102020000*R_300[0]+Q_102120000*R_310[0]+-1*Q_102220000*R_320[0]+Q_202020000*R_400[0]+-1*Q_202120000*R_410[0]+Q_202220000*R_420[0]; double QR_001021000200=Q_001021000*R_200[0]+-1*Q_001121000*R_210[0]+Q_001221000*R_220[0]+-1*Q_001321000*R_230[0]+-1*Q_101021000*R_300[0]+Q_101121000*R_310[0]+-1*Q_101221000*R_320[0]+Q_101321000*R_330[0]; double QR_000022000200=Q_000022000*R_200[0]+-1*Q_000122000*R_210[0]+Q_000222000*R_220[0]+-1*Q_000322000*R_230[0]+Q_000422000*R_240[0]; double QR_001020001200=Q_001020001*R_200[0]+-1*Q_001020101*R_201[0]+-1*Q_001120001*R_210[0]+Q_001120101*R_211[0]+Q_001220001*R_220[0]+-1*Q_001220101*R_221[0]+-1*Q_101020001*R_300[0]+Q_101020101*R_301[0]+Q_101120001*R_310[0]+-1*Q_101120101*R_311[0]+-1*Q_101220001*R_320[0]+Q_101220101*R_321[0]; double QR_000021001200=Q_000021001*R_200[0]+-1*Q_000021101*R_201[0]+-1*Q_000121001*R_210[0]+Q_000121101*R_211[0]+Q_000221001*R_220[0]+-1*Q_000221101*R_221[0]+-1*Q_000321001*R_230[0]+Q_000321101*R_231[0]; double QR_000020002200=Q_000020002*R_200[0]+-1*Q_000020102*R_201[0]+Q_000020202*R_202[0]+-1*Q_000120002*R_210[0]+Q_000120102*R_211[0]+-1*Q_000120202*R_212[0]+Q_000220002*R_220[0]+-1*Q_000220102*R_221[0]+Q_000220202*R_222[0]; double QR_012000010200=Q_012000010*R_200[0]+-1*Q_012000110*R_201[0]+-1*Q_112000010*R_300[0]+Q_112000110*R_301[0]+Q_212000010*R_400[0]+-1*Q_212000110*R_401[0]+-1*Q_312000010*R_500[0]+Q_312000110*R_501[0]; double QR_011001010200=Q_011001010*R_200[0]+-1*Q_011001110*R_201[0]+-1*Q_011101010*R_210[0]+Q_011101110*R_211[0]+-1*Q_111001010*R_300[0]+Q_111001110*R_301[0]+Q_111101010*R_310[0]+-1*Q_111101110*R_311[0]+Q_211001010*R_400[0]+-1*Q_211001110*R_401[0]+-1*Q_211101010*R_410[0]+Q_211101110*R_411[0]; double QR_010002010200=Q_010002010*R_200[0]+-1*Q_010002110*R_201[0]+-1*Q_010102010*R_210[0]+Q_010102110*R_211[0]+Q_010202010*R_220[0]+-1*Q_010202110*R_221[0]+-1*Q_110002010*R_300[0]+Q_110002110*R_301[0]+Q_110102010*R_310[0]+-1*Q_110102110*R_311[0]+-1*Q_110202010*R_320[0]+Q_110202110*R_321[0]; double QR_011000011200=Q_011000011*R_200[0]+-1*Q_011000111*R_201[0]+Q_011000211*R_202[0]+-1*Q_111000011*R_300[0]+Q_111000111*R_301[0]+-1*Q_111000211*R_302[0]+Q_211000011*R_400[0]+-1*Q_211000111*R_401[0]+Q_211000211*R_402[0]; double QR_010001011200=Q_010001011*R_200[0]+-1*Q_010001111*R_201[0]+Q_010001211*R_202[0]+-1*Q_010101011*R_210[0]+Q_010101111*R_211[0]+-1*Q_010101211*R_212[0]+-1*Q_110001011*R_300[0]+Q_110001111*R_301[0]+-1*Q_110001211*R_302[0]+Q_110101011*R_310[0]+-1*Q_110101111*R_311[0]+Q_110101211*R_312[0]; double QR_010000012200=Q_010000012*R_200[0]+-1*Q_010000112*R_201[0]+Q_010000212*R_202[0]+-1*Q_010000312*R_203[0]+-1*Q_110000012*R_300[0]+Q_110000112*R_301[0]+-1*Q_110000212*R_302[0]+Q_110000312*R_303[0]; double QR_002010010200=Q_002010010*R_200[0]+-1*Q_002010110*R_201[0]+-1*Q_002110010*R_210[0]+Q_002110110*R_211[0]+-1*Q_102010010*R_300[0]+Q_102010110*R_301[0]+Q_102110010*R_310[0]+-1*Q_102110110*R_311[0]+Q_202010010*R_400[0]+-1*Q_202010110*R_401[0]+-1*Q_202110010*R_410[0]+Q_202110110*R_411[0]; double QR_001011010200=Q_001011010*R_200[0]+-1*Q_001011110*R_201[0]+-1*Q_001111010*R_210[0]+Q_001111110*R_211[0]+Q_001211010*R_220[0]+-1*Q_001211110*R_221[0]+-1*Q_101011010*R_300[0]+Q_101011110*R_301[0]+Q_101111010*R_310[0]+-1*Q_101111110*R_311[0]+-1*Q_101211010*R_320[0]+Q_101211110*R_321[0]; double QR_000012010200=Q_000012010*R_200[0]+-1*Q_000012110*R_201[0]+-1*Q_000112010*R_210[0]+Q_000112110*R_211[0]+Q_000212010*R_220[0]+-1*Q_000212110*R_221[0]+-1*Q_000312010*R_230[0]+Q_000312110*R_231[0]; double QR_001010011200=Q_001010011*R_200[0]+-1*Q_001010111*R_201[0]+Q_001010211*R_202[0]+-1*Q_001110011*R_210[0]+Q_001110111*R_211[0]+-1*Q_001110211*R_212[0]+-1*Q_101010011*R_300[0]+Q_101010111*R_301[0]+-1*Q_101010211*R_302[0]+Q_101110011*R_310[0]+-1*Q_101110111*R_311[0]+Q_101110211*R_312[0]; double QR_000011011200=Q_000011011*R_200[0]+-1*Q_000011111*R_201[0]+Q_000011211*R_202[0]+-1*Q_000111011*R_210[0]+Q_000111111*R_211[0]+-1*Q_000111211*R_212[0]+Q_000211011*R_220[0]+-1*Q_000211111*R_221[0]+Q_000211211*R_222[0]; double QR_000010012200=Q_000010012*R_200[0]+-1*Q_000010112*R_201[0]+Q_000010212*R_202[0]+-1*Q_000010312*R_203[0]+-1*Q_000110012*R_210[0]+Q_000110112*R_211[0]+-1*Q_000110212*R_212[0]+Q_000110312*R_213[0]; double QR_002000020200=Q_002000020*R_200[0]+-1*Q_002000120*R_201[0]+Q_002000220*R_202[0]+-1*Q_102000020*R_300[0]+Q_102000120*R_301[0]+-1*Q_102000220*R_302[0]+Q_202000020*R_400[0]+-1*Q_202000120*R_401[0]+Q_202000220*R_402[0]; double QR_001001020200=Q_001001020*R_200[0]+-1*Q_001001120*R_201[0]+Q_001001220*R_202[0]+-1*Q_001101020*R_210[0]+Q_001101120*R_211[0]+-1*Q_001101220*R_212[0]+-1*Q_101001020*R_300[0]+Q_101001120*R_301[0]+-1*Q_101001220*R_302[0]+Q_101101020*R_310[0]+-1*Q_101101120*R_311[0]+Q_101101220*R_312[0]; double QR_000002020200=Q_000002020*R_200[0]+-1*Q_000002120*R_201[0]+Q_000002220*R_202[0]+-1*Q_000102020*R_210[0]+Q_000102120*R_211[0]+-1*Q_000102220*R_212[0]+Q_000202020*R_220[0]+-1*Q_000202120*R_221[0]+Q_000202220*R_222[0]; double QR_001000021200=Q_001000021*R_200[0]+-1*Q_001000121*R_201[0]+Q_001000221*R_202[0]+-1*Q_001000321*R_203[0]+-1*Q_101000021*R_300[0]+Q_101000121*R_301[0]+-1*Q_101000221*R_302[0]+Q_101000321*R_303[0]; double QR_000001021200=Q_000001021*R_200[0]+-1*Q_000001121*R_201[0]+Q_000001221*R_202[0]+-1*Q_000001321*R_203[0]+-1*Q_000101021*R_210[0]+Q_000101121*R_211[0]+-1*Q_000101221*R_212[0]+Q_000101321*R_213[0]; double QR_000000022200=Q_000000022*R_200[0]+-1*Q_000000122*R_201[0]+Q_000000222*R_202[0]+-1*Q_000000322*R_203[0]+Q_000000422*R_204[0]; double QR_022000000003=Q_022000000*R_003[0]+-1*Q_122000000*R_103[0]+Q_222000000*R_203[0]+-1*Q_322000000*R_303[0]+Q_422000000*R_403[0]; double QR_021001000003=Q_021001000*R_003[0]+-1*Q_021101000*R_013[0]+-1*Q_121001000*R_103[0]+Q_121101000*R_113[0]+Q_221001000*R_203[0]+-1*Q_221101000*R_213[0]+-1*Q_321001000*R_303[0]+Q_321101000*R_313[0]; double QR_020002000003=Q_020002000*R_003[0]+-1*Q_020102000*R_013[0]+Q_020202000*R_023[0]+-1*Q_120002000*R_103[0]+Q_120102000*R_113[0]+-1*Q_120202000*R_123[0]+Q_220002000*R_203[0]+-1*Q_220102000*R_213[0]+Q_220202000*R_223[0]; double QR_021000001003=Q_021000001*R_003[0]+-1*Q_021000101*R_004[0]+-1*Q_121000001*R_103[0]+Q_121000101*R_104[0]+Q_221000001*R_203[0]+-1*Q_221000101*R_204[0]+-1*Q_321000001*R_303[0]+Q_321000101*R_304[0]; double QR_020001001003=Q_020001001*R_003[0]+-1*Q_020001101*R_004[0]+-1*Q_020101001*R_013[0]+Q_020101101*R_014[0]+-1*Q_120001001*R_103[0]+Q_120001101*R_104[0]+Q_120101001*R_113[0]+-1*Q_120101101*R_114[0]+Q_220001001*R_203[0]+-1*Q_220001101*R_204[0]+-1*Q_220101001*R_213[0]+Q_220101101*R_214[0]; double QR_020000002003=Q_020000002*R_003[0]+-1*Q_020000102*R_004[0]+Q_020000202*R_005[0]+-1*Q_120000002*R_103[0]+Q_120000102*R_104[0]+-1*Q_120000202*R_105[0]+Q_220000002*R_203[0]+-1*Q_220000102*R_204[0]+Q_220000202*R_205[0]; double QR_012010000003=Q_012010000*R_003[0]+-1*Q_012110000*R_013[0]+-1*Q_112010000*R_103[0]+Q_112110000*R_113[0]+Q_212010000*R_203[0]+-1*Q_212110000*R_213[0]+-1*Q_312010000*R_303[0]+Q_312110000*R_313[0]; double QR_011011000003=Q_011011000*R_003[0]+-1*Q_011111000*R_013[0]+Q_011211000*R_023[0]+-1*Q_111011000*R_103[0]+Q_111111000*R_113[0]+-1*Q_111211000*R_123[0]+Q_211011000*R_203[0]+-1*Q_211111000*R_213[0]+Q_211211000*R_223[0]; double QR_010012000003=Q_010012000*R_003[0]+-1*Q_010112000*R_013[0]+Q_010212000*R_023[0]+-1*Q_010312000*R_033[0]+-1*Q_110012000*R_103[0]+Q_110112000*R_113[0]+-1*Q_110212000*R_123[0]+Q_110312000*R_133[0]; double QR_011010001003=Q_011010001*R_003[0]+-1*Q_011010101*R_004[0]+-1*Q_011110001*R_013[0]+Q_011110101*R_014[0]+-1*Q_111010001*R_103[0]+Q_111010101*R_104[0]+Q_111110001*R_113[0]+-1*Q_111110101*R_114[0]+Q_211010001*R_203[0]+-1*Q_211010101*R_204[0]+-1*Q_211110001*R_213[0]+Q_211110101*R_214[0]; double QR_010011001003=Q_010011001*R_003[0]+-1*Q_010011101*R_004[0]+-1*Q_010111001*R_013[0]+Q_010111101*R_014[0]+Q_010211001*R_023[0]+-1*Q_010211101*R_024[0]+-1*Q_110011001*R_103[0]+Q_110011101*R_104[0]+Q_110111001*R_113[0]+-1*Q_110111101*R_114[0]+-1*Q_110211001*R_123[0]+Q_110211101*R_124[0]; double QR_010010002003=Q_010010002*R_003[0]+-1*Q_010010102*R_004[0]+Q_010010202*R_005[0]+-1*Q_010110002*R_013[0]+Q_010110102*R_014[0]+-1*Q_010110202*R_015[0]+-1*Q_110010002*R_103[0]+Q_110010102*R_104[0]+-1*Q_110010202*R_105[0]+Q_110110002*R_113[0]+-1*Q_110110102*R_114[0]+Q_110110202*R_115[0]; double QR_002020000003=Q_002020000*R_003[0]+-1*Q_002120000*R_013[0]+Q_002220000*R_023[0]+-1*Q_102020000*R_103[0]+Q_102120000*R_113[0]+-1*Q_102220000*R_123[0]+Q_202020000*R_203[0]+-1*Q_202120000*R_213[0]+Q_202220000*R_223[0]; double QR_001021000003=Q_001021000*R_003[0]+-1*Q_001121000*R_013[0]+Q_001221000*R_023[0]+-1*Q_001321000*R_033[0]+-1*Q_101021000*R_103[0]+Q_101121000*R_113[0]+-1*Q_101221000*R_123[0]+Q_101321000*R_133[0]; double QR_000022000003=Q_000022000*R_003[0]+-1*Q_000122000*R_013[0]+Q_000222000*R_023[0]+-1*Q_000322000*R_033[0]+Q_000422000*R_043[0]; double QR_001020001003=Q_001020001*R_003[0]+-1*Q_001020101*R_004[0]+-1*Q_001120001*R_013[0]+Q_001120101*R_014[0]+Q_001220001*R_023[0]+-1*Q_001220101*R_024[0]+-1*Q_101020001*R_103[0]+Q_101020101*R_104[0]+Q_101120001*R_113[0]+-1*Q_101120101*R_114[0]+-1*Q_101220001*R_123[0]+Q_101220101*R_124[0]; double QR_000021001003=Q_000021001*R_003[0]+-1*Q_000021101*R_004[0]+-1*Q_000121001*R_013[0]+Q_000121101*R_014[0]+Q_000221001*R_023[0]+-1*Q_000221101*R_024[0]+-1*Q_000321001*R_033[0]+Q_000321101*R_034[0]; double QR_000020002003=Q_000020002*R_003[0]+-1*Q_000020102*R_004[0]+Q_000020202*R_005[0]+-1*Q_000120002*R_013[0]+Q_000120102*R_014[0]+-1*Q_000120202*R_015[0]+Q_000220002*R_023[0]+-1*Q_000220102*R_024[0]+Q_000220202*R_025[0]; double QR_012000010003=Q_012000010*R_003[0]+-1*Q_012000110*R_004[0]+-1*Q_112000010*R_103[0]+Q_112000110*R_104[0]+Q_212000010*R_203[0]+-1*Q_212000110*R_204[0]+-1*Q_312000010*R_303[0]+Q_312000110*R_304[0]; double QR_011001010003=Q_011001010*R_003[0]+-1*Q_011001110*R_004[0]+-1*Q_011101010*R_013[0]+Q_011101110*R_014[0]+-1*Q_111001010*R_103[0]+Q_111001110*R_104[0]+Q_111101010*R_113[0]+-1*Q_111101110*R_114[0]+Q_211001010*R_203[0]+-1*Q_211001110*R_204[0]+-1*Q_211101010*R_213[0]+Q_211101110*R_214[0]; double QR_010002010003=Q_010002010*R_003[0]+-1*Q_010002110*R_004[0]+-1*Q_010102010*R_013[0]+Q_010102110*R_014[0]+Q_010202010*R_023[0]+-1*Q_010202110*R_024[0]+-1*Q_110002010*R_103[0]+Q_110002110*R_104[0]+Q_110102010*R_113[0]+-1*Q_110102110*R_114[0]+-1*Q_110202010*R_123[0]+Q_110202110*R_124[0]; double QR_011000011003=Q_011000011*R_003[0]+-1*Q_011000111*R_004[0]+Q_011000211*R_005[0]+-1*Q_111000011*R_103[0]+Q_111000111*R_104[0]+-1*Q_111000211*R_105[0]+Q_211000011*R_203[0]+-1*Q_211000111*R_204[0]+Q_211000211*R_205[0]; double QR_010001011003=Q_010001011*R_003[0]+-1*Q_010001111*R_004[0]+Q_010001211*R_005[0]+-1*Q_010101011*R_013[0]+Q_010101111*R_014[0]+-1*Q_010101211*R_015[0]+-1*Q_110001011*R_103[0]+Q_110001111*R_104[0]+-1*Q_110001211*R_105[0]+Q_110101011*R_113[0]+-1*Q_110101111*R_114[0]+Q_110101211*R_115[0]; double QR_010000012003=Q_010000012*R_003[0]+-1*Q_010000112*R_004[0]+Q_010000212*R_005[0]+-1*Q_010000312*R_006[0]+-1*Q_110000012*R_103[0]+Q_110000112*R_104[0]+-1*Q_110000212*R_105[0]+Q_110000312*R_106[0]; double QR_002010010003=Q_002010010*R_003[0]+-1*Q_002010110*R_004[0]+-1*Q_002110010*R_013[0]+Q_002110110*R_014[0]+-1*Q_102010010*R_103[0]+Q_102010110*R_104[0]+Q_102110010*R_113[0]+-1*Q_102110110*R_114[0]+Q_202010010*R_203[0]+-1*Q_202010110*R_204[0]+-1*Q_202110010*R_213[0]+Q_202110110*R_214[0]; double QR_001011010003=Q_001011010*R_003[0]+-1*Q_001011110*R_004[0]+-1*Q_001111010*R_013[0]+Q_001111110*R_014[0]+Q_001211010*R_023[0]+-1*Q_001211110*R_024[0]+-1*Q_101011010*R_103[0]+Q_101011110*R_104[0]+Q_101111010*R_113[0]+-1*Q_101111110*R_114[0]+-1*Q_101211010*R_123[0]+Q_101211110*R_124[0]; double QR_000012010003=Q_000012010*R_003[0]+-1*Q_000012110*R_004[0]+-1*Q_000112010*R_013[0]+Q_000112110*R_014[0]+Q_000212010*R_023[0]+-1*Q_000212110*R_024[0]+-1*Q_000312010*R_033[0]+Q_000312110*R_034[0]; double QR_001010011003=Q_001010011*R_003[0]+-1*Q_001010111*R_004[0]+Q_001010211*R_005[0]+-1*Q_001110011*R_013[0]+Q_001110111*R_014[0]+-1*Q_001110211*R_015[0]+-1*Q_101010011*R_103[0]+Q_101010111*R_104[0]+-1*Q_101010211*R_105[0]+Q_101110011*R_113[0]+-1*Q_101110111*R_114[0]+Q_101110211*R_115[0]; double QR_000011011003=Q_000011011*R_003[0]+-1*Q_000011111*R_004[0]+Q_000011211*R_005[0]+-1*Q_000111011*R_013[0]+Q_000111111*R_014[0]+-1*Q_000111211*R_015[0]+Q_000211011*R_023[0]+-1*Q_000211111*R_024[0]+Q_000211211*R_025[0]; double QR_000010012003=Q_000010012*R_003[0]+-1*Q_000010112*R_004[0]+Q_000010212*R_005[0]+-1*Q_000010312*R_006[0]+-1*Q_000110012*R_013[0]+Q_000110112*R_014[0]+-1*Q_000110212*R_015[0]+Q_000110312*R_016[0]; double QR_002000020003=Q_002000020*R_003[0]+-1*Q_002000120*R_004[0]+Q_002000220*R_005[0]+-1*Q_102000020*R_103[0]+Q_102000120*R_104[0]+-1*Q_102000220*R_105[0]+Q_202000020*R_203[0]+-1*Q_202000120*R_204[0]+Q_202000220*R_205[0]; double QR_001001020003=Q_001001020*R_003[0]+-1*Q_001001120*R_004[0]+Q_001001220*R_005[0]+-1*Q_001101020*R_013[0]+Q_001101120*R_014[0]+-1*Q_001101220*R_015[0]+-1*Q_101001020*R_103[0]+Q_101001120*R_104[0]+-1*Q_101001220*R_105[0]+Q_101101020*R_113[0]+-1*Q_101101120*R_114[0]+Q_101101220*R_115[0]; double QR_000002020003=Q_000002020*R_003[0]+-1*Q_000002120*R_004[0]+Q_000002220*R_005[0]+-1*Q_000102020*R_013[0]+Q_000102120*R_014[0]+-1*Q_000102220*R_015[0]+Q_000202020*R_023[0]+-1*Q_000202120*R_024[0]+Q_000202220*R_025[0]; double QR_001000021003=Q_001000021*R_003[0]+-1*Q_001000121*R_004[0]+Q_001000221*R_005[0]+-1*Q_001000321*R_006[0]+-1*Q_101000021*R_103[0]+Q_101000121*R_104[0]+-1*Q_101000221*R_105[0]+Q_101000321*R_106[0]; double QR_000001021003=Q_000001021*R_003[0]+-1*Q_000001121*R_004[0]+Q_000001221*R_005[0]+-1*Q_000001321*R_006[0]+-1*Q_000101021*R_013[0]+Q_000101121*R_014[0]+-1*Q_000101221*R_015[0]+Q_000101321*R_016[0]; double QR_000000022003=Q_000000022*R_003[0]+-1*Q_000000122*R_004[0]+Q_000000222*R_005[0]+-1*Q_000000322*R_006[0]+Q_000000422*R_007[0]; double QR_022000000012=Q_022000000*R_012[0]+-1*Q_122000000*R_112[0]+Q_222000000*R_212[0]+-1*Q_322000000*R_312[0]+Q_422000000*R_412[0]; double QR_021001000012=Q_021001000*R_012[0]+-1*Q_021101000*R_022[0]+-1*Q_121001000*R_112[0]+Q_121101000*R_122[0]+Q_221001000*R_212[0]+-1*Q_221101000*R_222[0]+-1*Q_321001000*R_312[0]+Q_321101000*R_322[0]; double QR_020002000012=Q_020002000*R_012[0]+-1*Q_020102000*R_022[0]+Q_020202000*R_032[0]+-1*Q_120002000*R_112[0]+Q_120102000*R_122[0]+-1*Q_120202000*R_132[0]+Q_220002000*R_212[0]+-1*Q_220102000*R_222[0]+Q_220202000*R_232[0]; double QR_021000001012=Q_021000001*R_012[0]+-1*Q_021000101*R_013[0]+-1*Q_121000001*R_112[0]+Q_121000101*R_113[0]+Q_221000001*R_212[0]+-1*Q_221000101*R_213[0]+-1*Q_321000001*R_312[0]+Q_321000101*R_313[0]; double QR_020001001012=Q_020001001*R_012[0]+-1*Q_020001101*R_013[0]+-1*Q_020101001*R_022[0]+Q_020101101*R_023[0]+-1*Q_120001001*R_112[0]+Q_120001101*R_113[0]+Q_120101001*R_122[0]+-1*Q_120101101*R_123[0]+Q_220001001*R_212[0]+-1*Q_220001101*R_213[0]+-1*Q_220101001*R_222[0]+Q_220101101*R_223[0]; double QR_020000002012=Q_020000002*R_012[0]+-1*Q_020000102*R_013[0]+Q_020000202*R_014[0]+-1*Q_120000002*R_112[0]+Q_120000102*R_113[0]+-1*Q_120000202*R_114[0]+Q_220000002*R_212[0]+-1*Q_220000102*R_213[0]+Q_220000202*R_214[0]; double QR_012010000012=Q_012010000*R_012[0]+-1*Q_012110000*R_022[0]+-1*Q_112010000*R_112[0]+Q_112110000*R_122[0]+Q_212010000*R_212[0]+-1*Q_212110000*R_222[0]+-1*Q_312010000*R_312[0]+Q_312110000*R_322[0]; double QR_011011000012=Q_011011000*R_012[0]+-1*Q_011111000*R_022[0]+Q_011211000*R_032[0]+-1*Q_111011000*R_112[0]+Q_111111000*R_122[0]+-1*Q_111211000*R_132[0]+Q_211011000*R_212[0]+-1*Q_211111000*R_222[0]+Q_211211000*R_232[0]; double QR_010012000012=Q_010012000*R_012[0]+-1*Q_010112000*R_022[0]+Q_010212000*R_032[0]+-1*Q_010312000*R_042[0]+-1*Q_110012000*R_112[0]+Q_110112000*R_122[0]+-1*Q_110212000*R_132[0]+Q_110312000*R_142[0]; double QR_011010001012=Q_011010001*R_012[0]+-1*Q_011010101*R_013[0]+-1*Q_011110001*R_022[0]+Q_011110101*R_023[0]+-1*Q_111010001*R_112[0]+Q_111010101*R_113[0]+Q_111110001*R_122[0]+-1*Q_111110101*R_123[0]+Q_211010001*R_212[0]+-1*Q_211010101*R_213[0]+-1*Q_211110001*R_222[0]+Q_211110101*R_223[0]; double QR_010011001012=Q_010011001*R_012[0]+-1*Q_010011101*R_013[0]+-1*Q_010111001*R_022[0]+Q_010111101*R_023[0]+Q_010211001*R_032[0]+-1*Q_010211101*R_033[0]+-1*Q_110011001*R_112[0]+Q_110011101*R_113[0]+Q_110111001*R_122[0]+-1*Q_110111101*R_123[0]+-1*Q_110211001*R_132[0]+Q_110211101*R_133[0]; double QR_010010002012=Q_010010002*R_012[0]+-1*Q_010010102*R_013[0]+Q_010010202*R_014[0]+-1*Q_010110002*R_022[0]+Q_010110102*R_023[0]+-1*Q_010110202*R_024[0]+-1*Q_110010002*R_112[0]+Q_110010102*R_113[0]+-1*Q_110010202*R_114[0]+Q_110110002*R_122[0]+-1*Q_110110102*R_123[0]+Q_110110202*R_124[0]; double QR_002020000012=Q_002020000*R_012[0]+-1*Q_002120000*R_022[0]+Q_002220000*R_032[0]+-1*Q_102020000*R_112[0]+Q_102120000*R_122[0]+-1*Q_102220000*R_132[0]+Q_202020000*R_212[0]+-1*Q_202120000*R_222[0]+Q_202220000*R_232[0]; double QR_001021000012=Q_001021000*R_012[0]+-1*Q_001121000*R_022[0]+Q_001221000*R_032[0]+-1*Q_001321000*R_042[0]+-1*Q_101021000*R_112[0]+Q_101121000*R_122[0]+-1*Q_101221000*R_132[0]+Q_101321000*R_142[0]; double QR_000022000012=Q_000022000*R_012[0]+-1*Q_000122000*R_022[0]+Q_000222000*R_032[0]+-1*Q_000322000*R_042[0]+Q_000422000*R_052[0]; double QR_001020001012=Q_001020001*R_012[0]+-1*Q_001020101*R_013[0]+-1*Q_001120001*R_022[0]+Q_001120101*R_023[0]+Q_001220001*R_032[0]+-1*Q_001220101*R_033[0]+-1*Q_101020001*R_112[0]+Q_101020101*R_113[0]+Q_101120001*R_122[0]+-1*Q_101120101*R_123[0]+-1*Q_101220001*R_132[0]+Q_101220101*R_133[0]; double QR_000021001012=Q_000021001*R_012[0]+-1*Q_000021101*R_013[0]+-1*Q_000121001*R_022[0]+Q_000121101*R_023[0]+Q_000221001*R_032[0]+-1*Q_000221101*R_033[0]+-1*Q_000321001*R_042[0]+Q_000321101*R_043[0]; double QR_000020002012=Q_000020002*R_012[0]+-1*Q_000020102*R_013[0]+Q_000020202*R_014[0]+-1*Q_000120002*R_022[0]+Q_000120102*R_023[0]+-1*Q_000120202*R_024[0]+Q_000220002*R_032[0]+-1*Q_000220102*R_033[0]+Q_000220202*R_034[0]; double QR_012000010012=Q_012000010*R_012[0]+-1*Q_012000110*R_013[0]+-1*Q_112000010*R_112[0]+Q_112000110*R_113[0]+Q_212000010*R_212[0]+-1*Q_212000110*R_213[0]+-1*Q_312000010*R_312[0]+Q_312000110*R_313[0]; double QR_011001010012=Q_011001010*R_012[0]+-1*Q_011001110*R_013[0]+-1*Q_011101010*R_022[0]+Q_011101110*R_023[0]+-1*Q_111001010*R_112[0]+Q_111001110*R_113[0]+Q_111101010*R_122[0]+-1*Q_111101110*R_123[0]+Q_211001010*R_212[0]+-1*Q_211001110*R_213[0]+-1*Q_211101010*R_222[0]+Q_211101110*R_223[0]; double QR_010002010012=Q_010002010*R_012[0]+-1*Q_010002110*R_013[0]+-1*Q_010102010*R_022[0]+Q_010102110*R_023[0]+Q_010202010*R_032[0]+-1*Q_010202110*R_033[0]+-1*Q_110002010*R_112[0]+Q_110002110*R_113[0]+Q_110102010*R_122[0]+-1*Q_110102110*R_123[0]+-1*Q_110202010*R_132[0]+Q_110202110*R_133[0]; double QR_011000011012=Q_011000011*R_012[0]+-1*Q_011000111*R_013[0]+Q_011000211*R_014[0]+-1*Q_111000011*R_112[0]+Q_111000111*R_113[0]+-1*Q_111000211*R_114[0]+Q_211000011*R_212[0]+-1*Q_211000111*R_213[0]+Q_211000211*R_214[0]; double QR_010001011012=Q_010001011*R_012[0]+-1*Q_010001111*R_013[0]+Q_010001211*R_014[0]+-1*Q_010101011*R_022[0]+Q_010101111*R_023[0]+-1*Q_010101211*R_024[0]+-1*Q_110001011*R_112[0]+Q_110001111*R_113[0]+-1*Q_110001211*R_114[0]+Q_110101011*R_122[0]+-1*Q_110101111*R_123[0]+Q_110101211*R_124[0]; double QR_010000012012=Q_010000012*R_012[0]+-1*Q_010000112*R_013[0]+Q_010000212*R_014[0]+-1*Q_010000312*R_015[0]+-1*Q_110000012*R_112[0]+Q_110000112*R_113[0]+-1*Q_110000212*R_114[0]+Q_110000312*R_115[0]; double QR_002010010012=Q_002010010*R_012[0]+-1*Q_002010110*R_013[0]+-1*Q_002110010*R_022[0]+Q_002110110*R_023[0]+-1*Q_102010010*R_112[0]+Q_102010110*R_113[0]+Q_102110010*R_122[0]+-1*Q_102110110*R_123[0]+Q_202010010*R_212[0]+-1*Q_202010110*R_213[0]+-1*Q_202110010*R_222[0]+Q_202110110*R_223[0]; double QR_001011010012=Q_001011010*R_012[0]+-1*Q_001011110*R_013[0]+-1*Q_001111010*R_022[0]+Q_001111110*R_023[0]+Q_001211010*R_032[0]+-1*Q_001211110*R_033[0]+-1*Q_101011010*R_112[0]+Q_101011110*R_113[0]+Q_101111010*R_122[0]+-1*Q_101111110*R_123[0]+-1*Q_101211010*R_132[0]+Q_101211110*R_133[0]; double QR_000012010012=Q_000012010*R_012[0]+-1*Q_000012110*R_013[0]+-1*Q_000112010*R_022[0]+Q_000112110*R_023[0]+Q_000212010*R_032[0]+-1*Q_000212110*R_033[0]+-1*Q_000312010*R_042[0]+Q_000312110*R_043[0]; double QR_001010011012=Q_001010011*R_012[0]+-1*Q_001010111*R_013[0]+Q_001010211*R_014[0]+-1*Q_001110011*R_022[0]+Q_001110111*R_023[0]+-1*Q_001110211*R_024[0]+-1*Q_101010011*R_112[0]+Q_101010111*R_113[0]+-1*Q_101010211*R_114[0]+Q_101110011*R_122[0]+-1*Q_101110111*R_123[0]+Q_101110211*R_124[0]; double QR_000011011012=Q_000011011*R_012[0]+-1*Q_000011111*R_013[0]+Q_000011211*R_014[0]+-1*Q_000111011*R_022[0]+Q_000111111*R_023[0]+-1*Q_000111211*R_024[0]+Q_000211011*R_032[0]+-1*Q_000211111*R_033[0]+Q_000211211*R_034[0]; double QR_000010012012=Q_000010012*R_012[0]+-1*Q_000010112*R_013[0]+Q_000010212*R_014[0]+-1*Q_000010312*R_015[0]+-1*Q_000110012*R_022[0]+Q_000110112*R_023[0]+-1*Q_000110212*R_024[0]+Q_000110312*R_025[0]; double QR_002000020012=Q_002000020*R_012[0]+-1*Q_002000120*R_013[0]+Q_002000220*R_014[0]+-1*Q_102000020*R_112[0]+Q_102000120*R_113[0]+-1*Q_102000220*R_114[0]+Q_202000020*R_212[0]+-1*Q_202000120*R_213[0]+Q_202000220*R_214[0]; double QR_001001020012=Q_001001020*R_012[0]+-1*Q_001001120*R_013[0]+Q_001001220*R_014[0]+-1*Q_001101020*R_022[0]+Q_001101120*R_023[0]+-1*Q_001101220*R_024[0]+-1*Q_101001020*R_112[0]+Q_101001120*R_113[0]+-1*Q_101001220*R_114[0]+Q_101101020*R_122[0]+-1*Q_101101120*R_123[0]+Q_101101220*R_124[0]; double QR_000002020012=Q_000002020*R_012[0]+-1*Q_000002120*R_013[0]+Q_000002220*R_014[0]+-1*Q_000102020*R_022[0]+Q_000102120*R_023[0]+-1*Q_000102220*R_024[0]+Q_000202020*R_032[0]+-1*Q_000202120*R_033[0]+Q_000202220*R_034[0]; double QR_001000021012=Q_001000021*R_012[0]+-1*Q_001000121*R_013[0]+Q_001000221*R_014[0]+-1*Q_001000321*R_015[0]+-1*Q_101000021*R_112[0]+Q_101000121*R_113[0]+-1*Q_101000221*R_114[0]+Q_101000321*R_115[0]; double QR_000001021012=Q_000001021*R_012[0]+-1*Q_000001121*R_013[0]+Q_000001221*R_014[0]+-1*Q_000001321*R_015[0]+-1*Q_000101021*R_022[0]+Q_000101121*R_023[0]+-1*Q_000101221*R_024[0]+Q_000101321*R_025[0]; double QR_000000022012=Q_000000022*R_012[0]+-1*Q_000000122*R_013[0]+Q_000000222*R_014[0]+-1*Q_000000322*R_015[0]+Q_000000422*R_016[0]; double QR_022000000021=Q_022000000*R_021[0]+-1*Q_122000000*R_121[0]+Q_222000000*R_221[0]+-1*Q_322000000*R_321[0]+Q_422000000*R_421[0]; double QR_021001000021=Q_021001000*R_021[0]+-1*Q_021101000*R_031[0]+-1*Q_121001000*R_121[0]+Q_121101000*R_131[0]+Q_221001000*R_221[0]+-1*Q_221101000*R_231[0]+-1*Q_321001000*R_321[0]+Q_321101000*R_331[0]; double QR_020002000021=Q_020002000*R_021[0]+-1*Q_020102000*R_031[0]+Q_020202000*R_041[0]+-1*Q_120002000*R_121[0]+Q_120102000*R_131[0]+-1*Q_120202000*R_141[0]+Q_220002000*R_221[0]+-1*Q_220102000*R_231[0]+Q_220202000*R_241[0]; double QR_021000001021=Q_021000001*R_021[0]+-1*Q_021000101*R_022[0]+-1*Q_121000001*R_121[0]+Q_121000101*R_122[0]+Q_221000001*R_221[0]+-1*Q_221000101*R_222[0]+-1*Q_321000001*R_321[0]+Q_321000101*R_322[0]; double QR_020001001021=Q_020001001*R_021[0]+-1*Q_020001101*R_022[0]+-1*Q_020101001*R_031[0]+Q_020101101*R_032[0]+-1*Q_120001001*R_121[0]+Q_120001101*R_122[0]+Q_120101001*R_131[0]+-1*Q_120101101*R_132[0]+Q_220001001*R_221[0]+-1*Q_220001101*R_222[0]+-1*Q_220101001*R_231[0]+Q_220101101*R_232[0]; double QR_020000002021=Q_020000002*R_021[0]+-1*Q_020000102*R_022[0]+Q_020000202*R_023[0]+-1*Q_120000002*R_121[0]+Q_120000102*R_122[0]+-1*Q_120000202*R_123[0]+Q_220000002*R_221[0]+-1*Q_220000102*R_222[0]+Q_220000202*R_223[0]; double QR_012010000021=Q_012010000*R_021[0]+-1*Q_012110000*R_031[0]+-1*Q_112010000*R_121[0]+Q_112110000*R_131[0]+Q_212010000*R_221[0]+-1*Q_212110000*R_231[0]+-1*Q_312010000*R_321[0]+Q_312110000*R_331[0]; double QR_011011000021=Q_011011000*R_021[0]+-1*Q_011111000*R_031[0]+Q_011211000*R_041[0]+-1*Q_111011000*R_121[0]+Q_111111000*R_131[0]+-1*Q_111211000*R_141[0]+Q_211011000*R_221[0]+-1*Q_211111000*R_231[0]+Q_211211000*R_241[0]; double QR_010012000021=Q_010012000*R_021[0]+-1*Q_010112000*R_031[0]+Q_010212000*R_041[0]+-1*Q_010312000*R_051[0]+-1*Q_110012000*R_121[0]+Q_110112000*R_131[0]+-1*Q_110212000*R_141[0]+Q_110312000*R_151[0]; double QR_011010001021=Q_011010001*R_021[0]+-1*Q_011010101*R_022[0]+-1*Q_011110001*R_031[0]+Q_011110101*R_032[0]+-1*Q_111010001*R_121[0]+Q_111010101*R_122[0]+Q_111110001*R_131[0]+-1*Q_111110101*R_132[0]+Q_211010001*R_221[0]+-1*Q_211010101*R_222[0]+-1*Q_211110001*R_231[0]+Q_211110101*R_232[0]; double QR_010011001021=Q_010011001*R_021[0]+-1*Q_010011101*R_022[0]+-1*Q_010111001*R_031[0]+Q_010111101*R_032[0]+Q_010211001*R_041[0]+-1*Q_010211101*R_042[0]+-1*Q_110011001*R_121[0]+Q_110011101*R_122[0]+Q_110111001*R_131[0]+-1*Q_110111101*R_132[0]+-1*Q_110211001*R_141[0]+Q_110211101*R_142[0]; double QR_010010002021=Q_010010002*R_021[0]+-1*Q_010010102*R_022[0]+Q_010010202*R_023[0]+-1*Q_010110002*R_031[0]+Q_010110102*R_032[0]+-1*Q_010110202*R_033[0]+-1*Q_110010002*R_121[0]+Q_110010102*R_122[0]+-1*Q_110010202*R_123[0]+Q_110110002*R_131[0]+-1*Q_110110102*R_132[0]+Q_110110202*R_133[0]; double QR_002020000021=Q_002020000*R_021[0]+-1*Q_002120000*R_031[0]+Q_002220000*R_041[0]+-1*Q_102020000*R_121[0]+Q_102120000*R_131[0]+-1*Q_102220000*R_141[0]+Q_202020000*R_221[0]+-1*Q_202120000*R_231[0]+Q_202220000*R_241[0]; double QR_001021000021=Q_001021000*R_021[0]+-1*Q_001121000*R_031[0]+Q_001221000*R_041[0]+-1*Q_001321000*R_051[0]+-1*Q_101021000*R_121[0]+Q_101121000*R_131[0]+-1*Q_101221000*R_141[0]+Q_101321000*R_151[0]; double QR_000022000021=Q_000022000*R_021[0]+-1*Q_000122000*R_031[0]+Q_000222000*R_041[0]+-1*Q_000322000*R_051[0]+Q_000422000*R_061[0]; double QR_001020001021=Q_001020001*R_021[0]+-1*Q_001020101*R_022[0]+-1*Q_001120001*R_031[0]+Q_001120101*R_032[0]+Q_001220001*R_041[0]+-1*Q_001220101*R_042[0]+-1*Q_101020001*R_121[0]+Q_101020101*R_122[0]+Q_101120001*R_131[0]+-1*Q_101120101*R_132[0]+-1*Q_101220001*R_141[0]+Q_101220101*R_142[0]; double QR_000021001021=Q_000021001*R_021[0]+-1*Q_000021101*R_022[0]+-1*Q_000121001*R_031[0]+Q_000121101*R_032[0]+Q_000221001*R_041[0]+-1*Q_000221101*R_042[0]+-1*Q_000321001*R_051[0]+Q_000321101*R_052[0]; double QR_000020002021=Q_000020002*R_021[0]+-1*Q_000020102*R_022[0]+Q_000020202*R_023[0]+-1*Q_000120002*R_031[0]+Q_000120102*R_032[0]+-1*Q_000120202*R_033[0]+Q_000220002*R_041[0]+-1*Q_000220102*R_042[0]+Q_000220202*R_043[0]; double QR_012000010021=Q_012000010*R_021[0]+-1*Q_012000110*R_022[0]+-1*Q_112000010*R_121[0]+Q_112000110*R_122[0]+Q_212000010*R_221[0]+-1*Q_212000110*R_222[0]+-1*Q_312000010*R_321[0]+Q_312000110*R_322[0]; double QR_011001010021=Q_011001010*R_021[0]+-1*Q_011001110*R_022[0]+-1*Q_011101010*R_031[0]+Q_011101110*R_032[0]+-1*Q_111001010*R_121[0]+Q_111001110*R_122[0]+Q_111101010*R_131[0]+-1*Q_111101110*R_132[0]+Q_211001010*R_221[0]+-1*Q_211001110*R_222[0]+-1*Q_211101010*R_231[0]+Q_211101110*R_232[0]; double QR_010002010021=Q_010002010*R_021[0]+-1*Q_010002110*R_022[0]+-1*Q_010102010*R_031[0]+Q_010102110*R_032[0]+Q_010202010*R_041[0]+-1*Q_010202110*R_042[0]+-1*Q_110002010*R_121[0]+Q_110002110*R_122[0]+Q_110102010*R_131[0]+-1*Q_110102110*R_132[0]+-1*Q_110202010*R_141[0]+Q_110202110*R_142[0]; double QR_011000011021=Q_011000011*R_021[0]+-1*Q_011000111*R_022[0]+Q_011000211*R_023[0]+-1*Q_111000011*R_121[0]+Q_111000111*R_122[0]+-1*Q_111000211*R_123[0]+Q_211000011*R_221[0]+-1*Q_211000111*R_222[0]+Q_211000211*R_223[0]; double QR_010001011021=Q_010001011*R_021[0]+-1*Q_010001111*R_022[0]+Q_010001211*R_023[0]+-1*Q_010101011*R_031[0]+Q_010101111*R_032[0]+-1*Q_010101211*R_033[0]+-1*Q_110001011*R_121[0]+Q_110001111*R_122[0]+-1*Q_110001211*R_123[0]+Q_110101011*R_131[0]+-1*Q_110101111*R_132[0]+Q_110101211*R_133[0]; double QR_010000012021=Q_010000012*R_021[0]+-1*Q_010000112*R_022[0]+Q_010000212*R_023[0]+-1*Q_010000312*R_024[0]+-1*Q_110000012*R_121[0]+Q_110000112*R_122[0]+-1*Q_110000212*R_123[0]+Q_110000312*R_124[0]; double QR_002010010021=Q_002010010*R_021[0]+-1*Q_002010110*R_022[0]+-1*Q_002110010*R_031[0]+Q_002110110*R_032[0]+-1*Q_102010010*R_121[0]+Q_102010110*R_122[0]+Q_102110010*R_131[0]+-1*Q_102110110*R_132[0]+Q_202010010*R_221[0]+-1*Q_202010110*R_222[0]+-1*Q_202110010*R_231[0]+Q_202110110*R_232[0]; double QR_001011010021=Q_001011010*R_021[0]+-1*Q_001011110*R_022[0]+-1*Q_001111010*R_031[0]+Q_001111110*R_032[0]+Q_001211010*R_041[0]+-1*Q_001211110*R_042[0]+-1*Q_101011010*R_121[0]+Q_101011110*R_122[0]+Q_101111010*R_131[0]+-1*Q_101111110*R_132[0]+-1*Q_101211010*R_141[0]+Q_101211110*R_142[0]; double QR_000012010021=Q_000012010*R_021[0]+-1*Q_000012110*R_022[0]+-1*Q_000112010*R_031[0]+Q_000112110*R_032[0]+Q_000212010*R_041[0]+-1*Q_000212110*R_042[0]+-1*Q_000312010*R_051[0]+Q_000312110*R_052[0]; double QR_001010011021=Q_001010011*R_021[0]+-1*Q_001010111*R_022[0]+Q_001010211*R_023[0]+-1*Q_001110011*R_031[0]+Q_001110111*R_032[0]+-1*Q_001110211*R_033[0]+-1*Q_101010011*R_121[0]+Q_101010111*R_122[0]+-1*Q_101010211*R_123[0]+Q_101110011*R_131[0]+-1*Q_101110111*R_132[0]+Q_101110211*R_133[0]; double QR_000011011021=Q_000011011*R_021[0]+-1*Q_000011111*R_022[0]+Q_000011211*R_023[0]+-1*Q_000111011*R_031[0]+Q_000111111*R_032[0]+-1*Q_000111211*R_033[0]+Q_000211011*R_041[0]+-1*Q_000211111*R_042[0]+Q_000211211*R_043[0]; double QR_000010012021=Q_000010012*R_021[0]+-1*Q_000010112*R_022[0]+Q_000010212*R_023[0]+-1*Q_000010312*R_024[0]+-1*Q_000110012*R_031[0]+Q_000110112*R_032[0]+-1*Q_000110212*R_033[0]+Q_000110312*R_034[0]; double QR_002000020021=Q_002000020*R_021[0]+-1*Q_002000120*R_022[0]+Q_002000220*R_023[0]+-1*Q_102000020*R_121[0]+Q_102000120*R_122[0]+-1*Q_102000220*R_123[0]+Q_202000020*R_221[0]+-1*Q_202000120*R_222[0]+Q_202000220*R_223[0]; double QR_001001020021=Q_001001020*R_021[0]+-1*Q_001001120*R_022[0]+Q_001001220*R_023[0]+-1*Q_001101020*R_031[0]+Q_001101120*R_032[0]+-1*Q_001101220*R_033[0]+-1*Q_101001020*R_121[0]+Q_101001120*R_122[0]+-1*Q_101001220*R_123[0]+Q_101101020*R_131[0]+-1*Q_101101120*R_132[0]+Q_101101220*R_133[0]; double QR_000002020021=Q_000002020*R_021[0]+-1*Q_000002120*R_022[0]+Q_000002220*R_023[0]+-1*Q_000102020*R_031[0]+Q_000102120*R_032[0]+-1*Q_000102220*R_033[0]+Q_000202020*R_041[0]+-1*Q_000202120*R_042[0]+Q_000202220*R_043[0]; double QR_001000021021=Q_001000021*R_021[0]+-1*Q_001000121*R_022[0]+Q_001000221*R_023[0]+-1*Q_001000321*R_024[0]+-1*Q_101000021*R_121[0]+Q_101000121*R_122[0]+-1*Q_101000221*R_123[0]+Q_101000321*R_124[0]; double QR_000001021021=Q_000001021*R_021[0]+-1*Q_000001121*R_022[0]+Q_000001221*R_023[0]+-1*Q_000001321*R_024[0]+-1*Q_000101021*R_031[0]+Q_000101121*R_032[0]+-1*Q_000101221*R_033[0]+Q_000101321*R_034[0]; double QR_000000022021=Q_000000022*R_021[0]+-1*Q_000000122*R_022[0]+Q_000000222*R_023[0]+-1*Q_000000322*R_024[0]+Q_000000422*R_025[0]; double QR_022000000030=Q_022000000*R_030[0]+-1*Q_122000000*R_130[0]+Q_222000000*R_230[0]+-1*Q_322000000*R_330[0]+Q_422000000*R_430[0]; double QR_021001000030=Q_021001000*R_030[0]+-1*Q_021101000*R_040[0]+-1*Q_121001000*R_130[0]+Q_121101000*R_140[0]+Q_221001000*R_230[0]+-1*Q_221101000*R_240[0]+-1*Q_321001000*R_330[0]+Q_321101000*R_340[0]; double QR_020002000030=Q_020002000*R_030[0]+-1*Q_020102000*R_040[0]+Q_020202000*R_050[0]+-1*Q_120002000*R_130[0]+Q_120102000*R_140[0]+-1*Q_120202000*R_150[0]+Q_220002000*R_230[0]+-1*Q_220102000*R_240[0]+Q_220202000*R_250[0]; double QR_021000001030=Q_021000001*R_030[0]+-1*Q_021000101*R_031[0]+-1*Q_121000001*R_130[0]+Q_121000101*R_131[0]+Q_221000001*R_230[0]+-1*Q_221000101*R_231[0]+-1*Q_321000001*R_330[0]+Q_321000101*R_331[0]; double QR_020001001030=Q_020001001*R_030[0]+-1*Q_020001101*R_031[0]+-1*Q_020101001*R_040[0]+Q_020101101*R_041[0]+-1*Q_120001001*R_130[0]+Q_120001101*R_131[0]+Q_120101001*R_140[0]+-1*Q_120101101*R_141[0]+Q_220001001*R_230[0]+-1*Q_220001101*R_231[0]+-1*Q_220101001*R_240[0]+Q_220101101*R_241[0]; double QR_020000002030=Q_020000002*R_030[0]+-1*Q_020000102*R_031[0]+Q_020000202*R_032[0]+-1*Q_120000002*R_130[0]+Q_120000102*R_131[0]+-1*Q_120000202*R_132[0]+Q_220000002*R_230[0]+-1*Q_220000102*R_231[0]+Q_220000202*R_232[0]; double QR_012010000030=Q_012010000*R_030[0]+-1*Q_012110000*R_040[0]+-1*Q_112010000*R_130[0]+Q_112110000*R_140[0]+Q_212010000*R_230[0]+-1*Q_212110000*R_240[0]+-1*Q_312010000*R_330[0]+Q_312110000*R_340[0]; double QR_011011000030=Q_011011000*R_030[0]+-1*Q_011111000*R_040[0]+Q_011211000*R_050[0]+-1*Q_111011000*R_130[0]+Q_111111000*R_140[0]+-1*Q_111211000*R_150[0]+Q_211011000*R_230[0]+-1*Q_211111000*R_240[0]+Q_211211000*R_250[0]; double QR_010012000030=Q_010012000*R_030[0]+-1*Q_010112000*R_040[0]+Q_010212000*R_050[0]+-1*Q_010312000*R_060[0]+-1*Q_110012000*R_130[0]+Q_110112000*R_140[0]+-1*Q_110212000*R_150[0]+Q_110312000*R_160[0]; double QR_011010001030=Q_011010001*R_030[0]+-1*Q_011010101*R_031[0]+-1*Q_011110001*R_040[0]+Q_011110101*R_041[0]+-1*Q_111010001*R_130[0]+Q_111010101*R_131[0]+Q_111110001*R_140[0]+-1*Q_111110101*R_141[0]+Q_211010001*R_230[0]+-1*Q_211010101*R_231[0]+-1*Q_211110001*R_240[0]+Q_211110101*R_241[0]; double QR_010011001030=Q_010011001*R_030[0]+-1*Q_010011101*R_031[0]+-1*Q_010111001*R_040[0]+Q_010111101*R_041[0]+Q_010211001*R_050[0]+-1*Q_010211101*R_051[0]+-1*Q_110011001*R_130[0]+Q_110011101*R_131[0]+Q_110111001*R_140[0]+-1*Q_110111101*R_141[0]+-1*Q_110211001*R_150[0]+Q_110211101*R_151[0]; double QR_010010002030=Q_010010002*R_030[0]+-1*Q_010010102*R_031[0]+Q_010010202*R_032[0]+-1*Q_010110002*R_040[0]+Q_010110102*R_041[0]+-1*Q_010110202*R_042[0]+-1*Q_110010002*R_130[0]+Q_110010102*R_131[0]+-1*Q_110010202*R_132[0]+Q_110110002*R_140[0]+-1*Q_110110102*R_141[0]+Q_110110202*R_142[0]; double QR_002020000030=Q_002020000*R_030[0]+-1*Q_002120000*R_040[0]+Q_002220000*R_050[0]+-1*Q_102020000*R_130[0]+Q_102120000*R_140[0]+-1*Q_102220000*R_150[0]+Q_202020000*R_230[0]+-1*Q_202120000*R_240[0]+Q_202220000*R_250[0]; double QR_001021000030=Q_001021000*R_030[0]+-1*Q_001121000*R_040[0]+Q_001221000*R_050[0]+-1*Q_001321000*R_060[0]+-1*Q_101021000*R_130[0]+Q_101121000*R_140[0]+-1*Q_101221000*R_150[0]+Q_101321000*R_160[0]; double QR_000022000030=Q_000022000*R_030[0]+-1*Q_000122000*R_040[0]+Q_000222000*R_050[0]+-1*Q_000322000*R_060[0]+Q_000422000*R_070[0]; double QR_001020001030=Q_001020001*R_030[0]+-1*Q_001020101*R_031[0]+-1*Q_001120001*R_040[0]+Q_001120101*R_041[0]+Q_001220001*R_050[0]+-1*Q_001220101*R_051[0]+-1*Q_101020001*R_130[0]+Q_101020101*R_131[0]+Q_101120001*R_140[0]+-1*Q_101120101*R_141[0]+-1*Q_101220001*R_150[0]+Q_101220101*R_151[0]; double QR_000021001030=Q_000021001*R_030[0]+-1*Q_000021101*R_031[0]+-1*Q_000121001*R_040[0]+Q_000121101*R_041[0]+Q_000221001*R_050[0]+-1*Q_000221101*R_051[0]+-1*Q_000321001*R_060[0]+Q_000321101*R_061[0]; double QR_000020002030=Q_000020002*R_030[0]+-1*Q_000020102*R_031[0]+Q_000020202*R_032[0]+-1*Q_000120002*R_040[0]+Q_000120102*R_041[0]+-1*Q_000120202*R_042[0]+Q_000220002*R_050[0]+-1*Q_000220102*R_051[0]+Q_000220202*R_052[0]; double QR_012000010030=Q_012000010*R_030[0]+-1*Q_012000110*R_031[0]+-1*Q_112000010*R_130[0]+Q_112000110*R_131[0]+Q_212000010*R_230[0]+-1*Q_212000110*R_231[0]+-1*Q_312000010*R_330[0]+Q_312000110*R_331[0]; double QR_011001010030=Q_011001010*R_030[0]+-1*Q_011001110*R_031[0]+-1*Q_011101010*R_040[0]+Q_011101110*R_041[0]+-1*Q_111001010*R_130[0]+Q_111001110*R_131[0]+Q_111101010*R_140[0]+-1*Q_111101110*R_141[0]+Q_211001010*R_230[0]+-1*Q_211001110*R_231[0]+-1*Q_211101010*R_240[0]+Q_211101110*R_241[0]; double QR_010002010030=Q_010002010*R_030[0]+-1*Q_010002110*R_031[0]+-1*Q_010102010*R_040[0]+Q_010102110*R_041[0]+Q_010202010*R_050[0]+-1*Q_010202110*R_051[0]+-1*Q_110002010*R_130[0]+Q_110002110*R_131[0]+Q_110102010*R_140[0]+-1*Q_110102110*R_141[0]+-1*Q_110202010*R_150[0]+Q_110202110*R_151[0]; double QR_011000011030=Q_011000011*R_030[0]+-1*Q_011000111*R_031[0]+Q_011000211*R_032[0]+-1*Q_111000011*R_130[0]+Q_111000111*R_131[0]+-1*Q_111000211*R_132[0]+Q_211000011*R_230[0]+-1*Q_211000111*R_231[0]+Q_211000211*R_232[0]; double QR_010001011030=Q_010001011*R_030[0]+-1*Q_010001111*R_031[0]+Q_010001211*R_032[0]+-1*Q_010101011*R_040[0]+Q_010101111*R_041[0]+-1*Q_010101211*R_042[0]+-1*Q_110001011*R_130[0]+Q_110001111*R_131[0]+-1*Q_110001211*R_132[0]+Q_110101011*R_140[0]+-1*Q_110101111*R_141[0]+Q_110101211*R_142[0]; double QR_010000012030=Q_010000012*R_030[0]+-1*Q_010000112*R_031[0]+Q_010000212*R_032[0]+-1*Q_010000312*R_033[0]+-1*Q_110000012*R_130[0]+Q_110000112*R_131[0]+-1*Q_110000212*R_132[0]+Q_110000312*R_133[0]; double QR_002010010030=Q_002010010*R_030[0]+-1*Q_002010110*R_031[0]+-1*Q_002110010*R_040[0]+Q_002110110*R_041[0]+-1*Q_102010010*R_130[0]+Q_102010110*R_131[0]+Q_102110010*R_140[0]+-1*Q_102110110*R_141[0]+Q_202010010*R_230[0]+-1*Q_202010110*R_231[0]+-1*Q_202110010*R_240[0]+Q_202110110*R_241[0]; double QR_001011010030=Q_001011010*R_030[0]+-1*Q_001011110*R_031[0]+-1*Q_001111010*R_040[0]+Q_001111110*R_041[0]+Q_001211010*R_050[0]+-1*Q_001211110*R_051[0]+-1*Q_101011010*R_130[0]+Q_101011110*R_131[0]+Q_101111010*R_140[0]+-1*Q_101111110*R_141[0]+-1*Q_101211010*R_150[0]+Q_101211110*R_151[0]; double QR_000012010030=Q_000012010*R_030[0]+-1*Q_000012110*R_031[0]+-1*Q_000112010*R_040[0]+Q_000112110*R_041[0]+Q_000212010*R_050[0]+-1*Q_000212110*R_051[0]+-1*Q_000312010*R_060[0]+Q_000312110*R_061[0]; double QR_001010011030=Q_001010011*R_030[0]+-1*Q_001010111*R_031[0]+Q_001010211*R_032[0]+-1*Q_001110011*R_040[0]+Q_001110111*R_041[0]+-1*Q_001110211*R_042[0]+-1*Q_101010011*R_130[0]+Q_101010111*R_131[0]+-1*Q_101010211*R_132[0]+Q_101110011*R_140[0]+-1*Q_101110111*R_141[0]+Q_101110211*R_142[0]; double QR_000011011030=Q_000011011*R_030[0]+-1*Q_000011111*R_031[0]+Q_000011211*R_032[0]+-1*Q_000111011*R_040[0]+Q_000111111*R_041[0]+-1*Q_000111211*R_042[0]+Q_000211011*R_050[0]+-1*Q_000211111*R_051[0]+Q_000211211*R_052[0]; double QR_000010012030=Q_000010012*R_030[0]+-1*Q_000010112*R_031[0]+Q_000010212*R_032[0]+-1*Q_000010312*R_033[0]+-1*Q_000110012*R_040[0]+Q_000110112*R_041[0]+-1*Q_000110212*R_042[0]+Q_000110312*R_043[0]; double QR_002000020030=Q_002000020*R_030[0]+-1*Q_002000120*R_031[0]+Q_002000220*R_032[0]+-1*Q_102000020*R_130[0]+Q_102000120*R_131[0]+-1*Q_102000220*R_132[0]+Q_202000020*R_230[0]+-1*Q_202000120*R_231[0]+Q_202000220*R_232[0]; double QR_001001020030=Q_001001020*R_030[0]+-1*Q_001001120*R_031[0]+Q_001001220*R_032[0]+-1*Q_001101020*R_040[0]+Q_001101120*R_041[0]+-1*Q_001101220*R_042[0]+-1*Q_101001020*R_130[0]+Q_101001120*R_131[0]+-1*Q_101001220*R_132[0]+Q_101101020*R_140[0]+-1*Q_101101120*R_141[0]+Q_101101220*R_142[0]; double QR_000002020030=Q_000002020*R_030[0]+-1*Q_000002120*R_031[0]+Q_000002220*R_032[0]+-1*Q_000102020*R_040[0]+Q_000102120*R_041[0]+-1*Q_000102220*R_042[0]+Q_000202020*R_050[0]+-1*Q_000202120*R_051[0]+Q_000202220*R_052[0]; double QR_001000021030=Q_001000021*R_030[0]+-1*Q_001000121*R_031[0]+Q_001000221*R_032[0]+-1*Q_001000321*R_033[0]+-1*Q_101000021*R_130[0]+Q_101000121*R_131[0]+-1*Q_101000221*R_132[0]+Q_101000321*R_133[0]; double QR_000001021030=Q_000001021*R_030[0]+-1*Q_000001121*R_031[0]+Q_000001221*R_032[0]+-1*Q_000001321*R_033[0]+-1*Q_000101021*R_040[0]+Q_000101121*R_041[0]+-1*Q_000101221*R_042[0]+Q_000101321*R_043[0]; double QR_000000022030=Q_000000022*R_030[0]+-1*Q_000000122*R_031[0]+Q_000000222*R_032[0]+-1*Q_000000322*R_033[0]+Q_000000422*R_034[0]; double QR_022000000102=Q_022000000*R_102[0]+-1*Q_122000000*R_202[0]+Q_222000000*R_302[0]+-1*Q_322000000*R_402[0]+Q_422000000*R_502[0]; double QR_021001000102=Q_021001000*R_102[0]+-1*Q_021101000*R_112[0]+-1*Q_121001000*R_202[0]+Q_121101000*R_212[0]+Q_221001000*R_302[0]+-1*Q_221101000*R_312[0]+-1*Q_321001000*R_402[0]+Q_321101000*R_412[0]; double QR_020002000102=Q_020002000*R_102[0]+-1*Q_020102000*R_112[0]+Q_020202000*R_122[0]+-1*Q_120002000*R_202[0]+Q_120102000*R_212[0]+-1*Q_120202000*R_222[0]+Q_220002000*R_302[0]+-1*Q_220102000*R_312[0]+Q_220202000*R_322[0]; double QR_021000001102=Q_021000001*R_102[0]+-1*Q_021000101*R_103[0]+-1*Q_121000001*R_202[0]+Q_121000101*R_203[0]+Q_221000001*R_302[0]+-1*Q_221000101*R_303[0]+-1*Q_321000001*R_402[0]+Q_321000101*R_403[0]; double QR_020001001102=Q_020001001*R_102[0]+-1*Q_020001101*R_103[0]+-1*Q_020101001*R_112[0]+Q_020101101*R_113[0]+-1*Q_120001001*R_202[0]+Q_120001101*R_203[0]+Q_120101001*R_212[0]+-1*Q_120101101*R_213[0]+Q_220001001*R_302[0]+-1*Q_220001101*R_303[0]+-1*Q_220101001*R_312[0]+Q_220101101*R_313[0]; double QR_020000002102=Q_020000002*R_102[0]+-1*Q_020000102*R_103[0]+Q_020000202*R_104[0]+-1*Q_120000002*R_202[0]+Q_120000102*R_203[0]+-1*Q_120000202*R_204[0]+Q_220000002*R_302[0]+-1*Q_220000102*R_303[0]+Q_220000202*R_304[0]; double QR_012010000102=Q_012010000*R_102[0]+-1*Q_012110000*R_112[0]+-1*Q_112010000*R_202[0]+Q_112110000*R_212[0]+Q_212010000*R_302[0]+-1*Q_212110000*R_312[0]+-1*Q_312010000*R_402[0]+Q_312110000*R_412[0]; double QR_011011000102=Q_011011000*R_102[0]+-1*Q_011111000*R_112[0]+Q_011211000*R_122[0]+-1*Q_111011000*R_202[0]+Q_111111000*R_212[0]+-1*Q_111211000*R_222[0]+Q_211011000*R_302[0]+-1*Q_211111000*R_312[0]+Q_211211000*R_322[0]; double QR_010012000102=Q_010012000*R_102[0]+-1*Q_010112000*R_112[0]+Q_010212000*R_122[0]+-1*Q_010312000*R_132[0]+-1*Q_110012000*R_202[0]+Q_110112000*R_212[0]+-1*Q_110212000*R_222[0]+Q_110312000*R_232[0]; double QR_011010001102=Q_011010001*R_102[0]+-1*Q_011010101*R_103[0]+-1*Q_011110001*R_112[0]+Q_011110101*R_113[0]+-1*Q_111010001*R_202[0]+Q_111010101*R_203[0]+Q_111110001*R_212[0]+-1*Q_111110101*R_213[0]+Q_211010001*R_302[0]+-1*Q_211010101*R_303[0]+-1*Q_211110001*R_312[0]+Q_211110101*R_313[0]; double QR_010011001102=Q_010011001*R_102[0]+-1*Q_010011101*R_103[0]+-1*Q_010111001*R_112[0]+Q_010111101*R_113[0]+Q_010211001*R_122[0]+-1*Q_010211101*R_123[0]+-1*Q_110011001*R_202[0]+Q_110011101*R_203[0]+Q_110111001*R_212[0]+-1*Q_110111101*R_213[0]+-1*Q_110211001*R_222[0]+Q_110211101*R_223[0]; double QR_010010002102=Q_010010002*R_102[0]+-1*Q_010010102*R_103[0]+Q_010010202*R_104[0]+-1*Q_010110002*R_112[0]+Q_010110102*R_113[0]+-1*Q_010110202*R_114[0]+-1*Q_110010002*R_202[0]+Q_110010102*R_203[0]+-1*Q_110010202*R_204[0]+Q_110110002*R_212[0]+-1*Q_110110102*R_213[0]+Q_110110202*R_214[0]; double QR_002020000102=Q_002020000*R_102[0]+-1*Q_002120000*R_112[0]+Q_002220000*R_122[0]+-1*Q_102020000*R_202[0]+Q_102120000*R_212[0]+-1*Q_102220000*R_222[0]+Q_202020000*R_302[0]+-1*Q_202120000*R_312[0]+Q_202220000*R_322[0]; double QR_001021000102=Q_001021000*R_102[0]+-1*Q_001121000*R_112[0]+Q_001221000*R_122[0]+-1*Q_001321000*R_132[0]+-1*Q_101021000*R_202[0]+Q_101121000*R_212[0]+-1*Q_101221000*R_222[0]+Q_101321000*R_232[0]; double QR_000022000102=Q_000022000*R_102[0]+-1*Q_000122000*R_112[0]+Q_000222000*R_122[0]+-1*Q_000322000*R_132[0]+Q_000422000*R_142[0]; double QR_001020001102=Q_001020001*R_102[0]+-1*Q_001020101*R_103[0]+-1*Q_001120001*R_112[0]+Q_001120101*R_113[0]+Q_001220001*R_122[0]+-1*Q_001220101*R_123[0]+-1*Q_101020001*R_202[0]+Q_101020101*R_203[0]+Q_101120001*R_212[0]+-1*Q_101120101*R_213[0]+-1*Q_101220001*R_222[0]+Q_101220101*R_223[0]; double QR_000021001102=Q_000021001*R_102[0]+-1*Q_000021101*R_103[0]+-1*Q_000121001*R_112[0]+Q_000121101*R_113[0]+Q_000221001*R_122[0]+-1*Q_000221101*R_123[0]+-1*Q_000321001*R_132[0]+Q_000321101*R_133[0]; double QR_000020002102=Q_000020002*R_102[0]+-1*Q_000020102*R_103[0]+Q_000020202*R_104[0]+-1*Q_000120002*R_112[0]+Q_000120102*R_113[0]+-1*Q_000120202*R_114[0]+Q_000220002*R_122[0]+-1*Q_000220102*R_123[0]+Q_000220202*R_124[0]; double QR_012000010102=Q_012000010*R_102[0]+-1*Q_012000110*R_103[0]+-1*Q_112000010*R_202[0]+Q_112000110*R_203[0]+Q_212000010*R_302[0]+-1*Q_212000110*R_303[0]+-1*Q_312000010*R_402[0]+Q_312000110*R_403[0]; double QR_011001010102=Q_011001010*R_102[0]+-1*Q_011001110*R_103[0]+-1*Q_011101010*R_112[0]+Q_011101110*R_113[0]+-1*Q_111001010*R_202[0]+Q_111001110*R_203[0]+Q_111101010*R_212[0]+-1*Q_111101110*R_213[0]+Q_211001010*R_302[0]+-1*Q_211001110*R_303[0]+-1*Q_211101010*R_312[0]+Q_211101110*R_313[0]; double QR_010002010102=Q_010002010*R_102[0]+-1*Q_010002110*R_103[0]+-1*Q_010102010*R_112[0]+Q_010102110*R_113[0]+Q_010202010*R_122[0]+-1*Q_010202110*R_123[0]+-1*Q_110002010*R_202[0]+Q_110002110*R_203[0]+Q_110102010*R_212[0]+-1*Q_110102110*R_213[0]+-1*Q_110202010*R_222[0]+Q_110202110*R_223[0]; double QR_011000011102=Q_011000011*R_102[0]+-1*Q_011000111*R_103[0]+Q_011000211*R_104[0]+-1*Q_111000011*R_202[0]+Q_111000111*R_203[0]+-1*Q_111000211*R_204[0]+Q_211000011*R_302[0]+-1*Q_211000111*R_303[0]+Q_211000211*R_304[0]; double QR_010001011102=Q_010001011*R_102[0]+-1*Q_010001111*R_103[0]+Q_010001211*R_104[0]+-1*Q_010101011*R_112[0]+Q_010101111*R_113[0]+-1*Q_010101211*R_114[0]+-1*Q_110001011*R_202[0]+Q_110001111*R_203[0]+-1*Q_110001211*R_204[0]+Q_110101011*R_212[0]+-1*Q_110101111*R_213[0]+Q_110101211*R_214[0]; double QR_010000012102=Q_010000012*R_102[0]+-1*Q_010000112*R_103[0]+Q_010000212*R_104[0]+-1*Q_010000312*R_105[0]+-1*Q_110000012*R_202[0]+Q_110000112*R_203[0]+-1*Q_110000212*R_204[0]+Q_110000312*R_205[0]; double QR_002010010102=Q_002010010*R_102[0]+-1*Q_002010110*R_103[0]+-1*Q_002110010*R_112[0]+Q_002110110*R_113[0]+-1*Q_102010010*R_202[0]+Q_102010110*R_203[0]+Q_102110010*R_212[0]+-1*Q_102110110*R_213[0]+Q_202010010*R_302[0]+-1*Q_202010110*R_303[0]+-1*Q_202110010*R_312[0]+Q_202110110*R_313[0]; double QR_001011010102=Q_001011010*R_102[0]+-1*Q_001011110*R_103[0]+-1*Q_001111010*R_112[0]+Q_001111110*R_113[0]+Q_001211010*R_122[0]+-1*Q_001211110*R_123[0]+-1*Q_101011010*R_202[0]+Q_101011110*R_203[0]+Q_101111010*R_212[0]+-1*Q_101111110*R_213[0]+-1*Q_101211010*R_222[0]+Q_101211110*R_223[0]; double QR_000012010102=Q_000012010*R_102[0]+-1*Q_000012110*R_103[0]+-1*Q_000112010*R_112[0]+Q_000112110*R_113[0]+Q_000212010*R_122[0]+-1*Q_000212110*R_123[0]+-1*Q_000312010*R_132[0]+Q_000312110*R_133[0]; double QR_001010011102=Q_001010011*R_102[0]+-1*Q_001010111*R_103[0]+Q_001010211*R_104[0]+-1*Q_001110011*R_112[0]+Q_001110111*R_113[0]+-1*Q_001110211*R_114[0]+-1*Q_101010011*R_202[0]+Q_101010111*R_203[0]+-1*Q_101010211*R_204[0]+Q_101110011*R_212[0]+-1*Q_101110111*R_213[0]+Q_101110211*R_214[0]; double QR_000011011102=Q_000011011*R_102[0]+-1*Q_000011111*R_103[0]+Q_000011211*R_104[0]+-1*Q_000111011*R_112[0]+Q_000111111*R_113[0]+-1*Q_000111211*R_114[0]+Q_000211011*R_122[0]+-1*Q_000211111*R_123[0]+Q_000211211*R_124[0]; double QR_000010012102=Q_000010012*R_102[0]+-1*Q_000010112*R_103[0]+Q_000010212*R_104[0]+-1*Q_000010312*R_105[0]+-1*Q_000110012*R_112[0]+Q_000110112*R_113[0]+-1*Q_000110212*R_114[0]+Q_000110312*R_115[0]; double QR_002000020102=Q_002000020*R_102[0]+-1*Q_002000120*R_103[0]+Q_002000220*R_104[0]+-1*Q_102000020*R_202[0]+Q_102000120*R_203[0]+-1*Q_102000220*R_204[0]+Q_202000020*R_302[0]+-1*Q_202000120*R_303[0]+Q_202000220*R_304[0]; double QR_001001020102=Q_001001020*R_102[0]+-1*Q_001001120*R_103[0]+Q_001001220*R_104[0]+-1*Q_001101020*R_112[0]+Q_001101120*R_113[0]+-1*Q_001101220*R_114[0]+-1*Q_101001020*R_202[0]+Q_101001120*R_203[0]+-1*Q_101001220*R_204[0]+Q_101101020*R_212[0]+-1*Q_101101120*R_213[0]+Q_101101220*R_214[0]; double QR_000002020102=Q_000002020*R_102[0]+-1*Q_000002120*R_103[0]+Q_000002220*R_104[0]+-1*Q_000102020*R_112[0]+Q_000102120*R_113[0]+-1*Q_000102220*R_114[0]+Q_000202020*R_122[0]+-1*Q_000202120*R_123[0]+Q_000202220*R_124[0]; double QR_001000021102=Q_001000021*R_102[0]+-1*Q_001000121*R_103[0]+Q_001000221*R_104[0]+-1*Q_001000321*R_105[0]+-1*Q_101000021*R_202[0]+Q_101000121*R_203[0]+-1*Q_101000221*R_204[0]+Q_101000321*R_205[0]; double QR_000001021102=Q_000001021*R_102[0]+-1*Q_000001121*R_103[0]+Q_000001221*R_104[0]+-1*Q_000001321*R_105[0]+-1*Q_000101021*R_112[0]+Q_000101121*R_113[0]+-1*Q_000101221*R_114[0]+Q_000101321*R_115[0]; double QR_000000022102=Q_000000022*R_102[0]+-1*Q_000000122*R_103[0]+Q_000000222*R_104[0]+-1*Q_000000322*R_105[0]+Q_000000422*R_106[0]; double QR_022000000111=Q_022000000*R_111[0]+-1*Q_122000000*R_211[0]+Q_222000000*R_311[0]+-1*Q_322000000*R_411[0]+Q_422000000*R_511[0]; double QR_021001000111=Q_021001000*R_111[0]+-1*Q_021101000*R_121[0]+-1*Q_121001000*R_211[0]+Q_121101000*R_221[0]+Q_221001000*R_311[0]+-1*Q_221101000*R_321[0]+-1*Q_321001000*R_411[0]+Q_321101000*R_421[0]; double QR_020002000111=Q_020002000*R_111[0]+-1*Q_020102000*R_121[0]+Q_020202000*R_131[0]+-1*Q_120002000*R_211[0]+Q_120102000*R_221[0]+-1*Q_120202000*R_231[0]+Q_220002000*R_311[0]+-1*Q_220102000*R_321[0]+Q_220202000*R_331[0]; double QR_021000001111=Q_021000001*R_111[0]+-1*Q_021000101*R_112[0]+-1*Q_121000001*R_211[0]+Q_121000101*R_212[0]+Q_221000001*R_311[0]+-1*Q_221000101*R_312[0]+-1*Q_321000001*R_411[0]+Q_321000101*R_412[0]; double QR_020001001111=Q_020001001*R_111[0]+-1*Q_020001101*R_112[0]+-1*Q_020101001*R_121[0]+Q_020101101*R_122[0]+-1*Q_120001001*R_211[0]+Q_120001101*R_212[0]+Q_120101001*R_221[0]+-1*Q_120101101*R_222[0]+Q_220001001*R_311[0]+-1*Q_220001101*R_312[0]+-1*Q_220101001*R_321[0]+Q_220101101*R_322[0]; double QR_020000002111=Q_020000002*R_111[0]+-1*Q_020000102*R_112[0]+Q_020000202*R_113[0]+-1*Q_120000002*R_211[0]+Q_120000102*R_212[0]+-1*Q_120000202*R_213[0]+Q_220000002*R_311[0]+-1*Q_220000102*R_312[0]+Q_220000202*R_313[0]; double QR_012010000111=Q_012010000*R_111[0]+-1*Q_012110000*R_121[0]+-1*Q_112010000*R_211[0]+Q_112110000*R_221[0]+Q_212010000*R_311[0]+-1*Q_212110000*R_321[0]+-1*Q_312010000*R_411[0]+Q_312110000*R_421[0]; double QR_011011000111=Q_011011000*R_111[0]+-1*Q_011111000*R_121[0]+Q_011211000*R_131[0]+-1*Q_111011000*R_211[0]+Q_111111000*R_221[0]+-1*Q_111211000*R_231[0]+Q_211011000*R_311[0]+-1*Q_211111000*R_321[0]+Q_211211000*R_331[0]; double QR_010012000111=Q_010012000*R_111[0]+-1*Q_010112000*R_121[0]+Q_010212000*R_131[0]+-1*Q_010312000*R_141[0]+-1*Q_110012000*R_211[0]+Q_110112000*R_221[0]+-1*Q_110212000*R_231[0]+Q_110312000*R_241[0]; double QR_011010001111=Q_011010001*R_111[0]+-1*Q_011010101*R_112[0]+-1*Q_011110001*R_121[0]+Q_011110101*R_122[0]+-1*Q_111010001*R_211[0]+Q_111010101*R_212[0]+Q_111110001*R_221[0]+-1*Q_111110101*R_222[0]+Q_211010001*R_311[0]+-1*Q_211010101*R_312[0]+-1*Q_211110001*R_321[0]+Q_211110101*R_322[0]; double QR_010011001111=Q_010011001*R_111[0]+-1*Q_010011101*R_112[0]+-1*Q_010111001*R_121[0]+Q_010111101*R_122[0]+Q_010211001*R_131[0]+-1*Q_010211101*R_132[0]+-1*Q_110011001*R_211[0]+Q_110011101*R_212[0]+Q_110111001*R_221[0]+-1*Q_110111101*R_222[0]+-1*Q_110211001*R_231[0]+Q_110211101*R_232[0]; double QR_010010002111=Q_010010002*R_111[0]+-1*Q_010010102*R_112[0]+Q_010010202*R_113[0]+-1*Q_010110002*R_121[0]+Q_010110102*R_122[0]+-1*Q_010110202*R_123[0]+-1*Q_110010002*R_211[0]+Q_110010102*R_212[0]+-1*Q_110010202*R_213[0]+Q_110110002*R_221[0]+-1*Q_110110102*R_222[0]+Q_110110202*R_223[0]; double QR_002020000111=Q_002020000*R_111[0]+-1*Q_002120000*R_121[0]+Q_002220000*R_131[0]+-1*Q_102020000*R_211[0]+Q_102120000*R_221[0]+-1*Q_102220000*R_231[0]+Q_202020000*R_311[0]+-1*Q_202120000*R_321[0]+Q_202220000*R_331[0]; double QR_001021000111=Q_001021000*R_111[0]+-1*Q_001121000*R_121[0]+Q_001221000*R_131[0]+-1*Q_001321000*R_141[0]+-1*Q_101021000*R_211[0]+Q_101121000*R_221[0]+-1*Q_101221000*R_231[0]+Q_101321000*R_241[0]; double QR_000022000111=Q_000022000*R_111[0]+-1*Q_000122000*R_121[0]+Q_000222000*R_131[0]+-1*Q_000322000*R_141[0]+Q_000422000*R_151[0]; double QR_001020001111=Q_001020001*R_111[0]+-1*Q_001020101*R_112[0]+-1*Q_001120001*R_121[0]+Q_001120101*R_122[0]+Q_001220001*R_131[0]+-1*Q_001220101*R_132[0]+-1*Q_101020001*R_211[0]+Q_101020101*R_212[0]+Q_101120001*R_221[0]+-1*Q_101120101*R_222[0]+-1*Q_101220001*R_231[0]+Q_101220101*R_232[0]; double QR_000021001111=Q_000021001*R_111[0]+-1*Q_000021101*R_112[0]+-1*Q_000121001*R_121[0]+Q_000121101*R_122[0]+Q_000221001*R_131[0]+-1*Q_000221101*R_132[0]+-1*Q_000321001*R_141[0]+Q_000321101*R_142[0]; double QR_000020002111=Q_000020002*R_111[0]+-1*Q_000020102*R_112[0]+Q_000020202*R_113[0]+-1*Q_000120002*R_121[0]+Q_000120102*R_122[0]+-1*Q_000120202*R_123[0]+Q_000220002*R_131[0]+-1*Q_000220102*R_132[0]+Q_000220202*R_133[0]; double QR_012000010111=Q_012000010*R_111[0]+-1*Q_012000110*R_112[0]+-1*Q_112000010*R_211[0]+Q_112000110*R_212[0]+Q_212000010*R_311[0]+-1*Q_212000110*R_312[0]+-1*Q_312000010*R_411[0]+Q_312000110*R_412[0]; double QR_011001010111=Q_011001010*R_111[0]+-1*Q_011001110*R_112[0]+-1*Q_011101010*R_121[0]+Q_011101110*R_122[0]+-1*Q_111001010*R_211[0]+Q_111001110*R_212[0]+Q_111101010*R_221[0]+-1*Q_111101110*R_222[0]+Q_211001010*R_311[0]+-1*Q_211001110*R_312[0]+-1*Q_211101010*R_321[0]+Q_211101110*R_322[0]; double QR_010002010111=Q_010002010*R_111[0]+-1*Q_010002110*R_112[0]+-1*Q_010102010*R_121[0]+Q_010102110*R_122[0]+Q_010202010*R_131[0]+-1*Q_010202110*R_132[0]+-1*Q_110002010*R_211[0]+Q_110002110*R_212[0]+Q_110102010*R_221[0]+-1*Q_110102110*R_222[0]+-1*Q_110202010*R_231[0]+Q_110202110*R_232[0]; double QR_011000011111=Q_011000011*R_111[0]+-1*Q_011000111*R_112[0]+Q_011000211*R_113[0]+-1*Q_111000011*R_211[0]+Q_111000111*R_212[0]+-1*Q_111000211*R_213[0]+Q_211000011*R_311[0]+-1*Q_211000111*R_312[0]+Q_211000211*R_313[0]; double QR_010001011111=Q_010001011*R_111[0]+-1*Q_010001111*R_112[0]+Q_010001211*R_113[0]+-1*Q_010101011*R_121[0]+Q_010101111*R_122[0]+-1*Q_010101211*R_123[0]+-1*Q_110001011*R_211[0]+Q_110001111*R_212[0]+-1*Q_110001211*R_213[0]+Q_110101011*R_221[0]+-1*Q_110101111*R_222[0]+Q_110101211*R_223[0]; double QR_010000012111=Q_010000012*R_111[0]+-1*Q_010000112*R_112[0]+Q_010000212*R_113[0]+-1*Q_010000312*R_114[0]+-1*Q_110000012*R_211[0]+Q_110000112*R_212[0]+-1*Q_110000212*R_213[0]+Q_110000312*R_214[0]; double QR_002010010111=Q_002010010*R_111[0]+-1*Q_002010110*R_112[0]+-1*Q_002110010*R_121[0]+Q_002110110*R_122[0]+-1*Q_102010010*R_211[0]+Q_102010110*R_212[0]+Q_102110010*R_221[0]+-1*Q_102110110*R_222[0]+Q_202010010*R_311[0]+-1*Q_202010110*R_312[0]+-1*Q_202110010*R_321[0]+Q_202110110*R_322[0]; double QR_001011010111=Q_001011010*R_111[0]+-1*Q_001011110*R_112[0]+-1*Q_001111010*R_121[0]+Q_001111110*R_122[0]+Q_001211010*R_131[0]+-1*Q_001211110*R_132[0]+-1*Q_101011010*R_211[0]+Q_101011110*R_212[0]+Q_101111010*R_221[0]+-1*Q_101111110*R_222[0]+-1*Q_101211010*R_231[0]+Q_101211110*R_232[0]; double QR_000012010111=Q_000012010*R_111[0]+-1*Q_000012110*R_112[0]+-1*Q_000112010*R_121[0]+Q_000112110*R_122[0]+Q_000212010*R_131[0]+-1*Q_000212110*R_132[0]+-1*Q_000312010*R_141[0]+Q_000312110*R_142[0]; double QR_001010011111=Q_001010011*R_111[0]+-1*Q_001010111*R_112[0]+Q_001010211*R_113[0]+-1*Q_001110011*R_121[0]+Q_001110111*R_122[0]+-1*Q_001110211*R_123[0]+-1*Q_101010011*R_211[0]+Q_101010111*R_212[0]+-1*Q_101010211*R_213[0]+Q_101110011*R_221[0]+-1*Q_101110111*R_222[0]+Q_101110211*R_223[0]; double QR_000011011111=Q_000011011*R_111[0]+-1*Q_000011111*R_112[0]+Q_000011211*R_113[0]+-1*Q_000111011*R_121[0]+Q_000111111*R_122[0]+-1*Q_000111211*R_123[0]+Q_000211011*R_131[0]+-1*Q_000211111*R_132[0]+Q_000211211*R_133[0]; double QR_000010012111=Q_000010012*R_111[0]+-1*Q_000010112*R_112[0]+Q_000010212*R_113[0]+-1*Q_000010312*R_114[0]+-1*Q_000110012*R_121[0]+Q_000110112*R_122[0]+-1*Q_000110212*R_123[0]+Q_000110312*R_124[0]; double QR_002000020111=Q_002000020*R_111[0]+-1*Q_002000120*R_112[0]+Q_002000220*R_113[0]+-1*Q_102000020*R_211[0]+Q_102000120*R_212[0]+-1*Q_102000220*R_213[0]+Q_202000020*R_311[0]+-1*Q_202000120*R_312[0]+Q_202000220*R_313[0]; double QR_001001020111=Q_001001020*R_111[0]+-1*Q_001001120*R_112[0]+Q_001001220*R_113[0]+-1*Q_001101020*R_121[0]+Q_001101120*R_122[0]+-1*Q_001101220*R_123[0]+-1*Q_101001020*R_211[0]+Q_101001120*R_212[0]+-1*Q_101001220*R_213[0]+Q_101101020*R_221[0]+-1*Q_101101120*R_222[0]+Q_101101220*R_223[0]; double QR_000002020111=Q_000002020*R_111[0]+-1*Q_000002120*R_112[0]+Q_000002220*R_113[0]+-1*Q_000102020*R_121[0]+Q_000102120*R_122[0]+-1*Q_000102220*R_123[0]+Q_000202020*R_131[0]+-1*Q_000202120*R_132[0]+Q_000202220*R_133[0]; double QR_001000021111=Q_001000021*R_111[0]+-1*Q_001000121*R_112[0]+Q_001000221*R_113[0]+-1*Q_001000321*R_114[0]+-1*Q_101000021*R_211[0]+Q_101000121*R_212[0]+-1*Q_101000221*R_213[0]+Q_101000321*R_214[0]; double QR_000001021111=Q_000001021*R_111[0]+-1*Q_000001121*R_112[0]+Q_000001221*R_113[0]+-1*Q_000001321*R_114[0]+-1*Q_000101021*R_121[0]+Q_000101121*R_122[0]+-1*Q_000101221*R_123[0]+Q_000101321*R_124[0]; double QR_000000022111=Q_000000022*R_111[0]+-1*Q_000000122*R_112[0]+Q_000000222*R_113[0]+-1*Q_000000322*R_114[0]+Q_000000422*R_115[0]; double QR_022000000120=Q_022000000*R_120[0]+-1*Q_122000000*R_220[0]+Q_222000000*R_320[0]+-1*Q_322000000*R_420[0]+Q_422000000*R_520[0]; double QR_021001000120=Q_021001000*R_120[0]+-1*Q_021101000*R_130[0]+-1*Q_121001000*R_220[0]+Q_121101000*R_230[0]+Q_221001000*R_320[0]+-1*Q_221101000*R_330[0]+-1*Q_321001000*R_420[0]+Q_321101000*R_430[0]; double QR_020002000120=Q_020002000*R_120[0]+-1*Q_020102000*R_130[0]+Q_020202000*R_140[0]+-1*Q_120002000*R_220[0]+Q_120102000*R_230[0]+-1*Q_120202000*R_240[0]+Q_220002000*R_320[0]+-1*Q_220102000*R_330[0]+Q_220202000*R_340[0]; double QR_021000001120=Q_021000001*R_120[0]+-1*Q_021000101*R_121[0]+-1*Q_121000001*R_220[0]+Q_121000101*R_221[0]+Q_221000001*R_320[0]+-1*Q_221000101*R_321[0]+-1*Q_321000001*R_420[0]+Q_321000101*R_421[0]; double QR_020001001120=Q_020001001*R_120[0]+-1*Q_020001101*R_121[0]+-1*Q_020101001*R_130[0]+Q_020101101*R_131[0]+-1*Q_120001001*R_220[0]+Q_120001101*R_221[0]+Q_120101001*R_230[0]+-1*Q_120101101*R_231[0]+Q_220001001*R_320[0]+-1*Q_220001101*R_321[0]+-1*Q_220101001*R_330[0]+Q_220101101*R_331[0]; double QR_020000002120=Q_020000002*R_120[0]+-1*Q_020000102*R_121[0]+Q_020000202*R_122[0]+-1*Q_120000002*R_220[0]+Q_120000102*R_221[0]+-1*Q_120000202*R_222[0]+Q_220000002*R_320[0]+-1*Q_220000102*R_321[0]+Q_220000202*R_322[0]; double QR_012010000120=Q_012010000*R_120[0]+-1*Q_012110000*R_130[0]+-1*Q_112010000*R_220[0]+Q_112110000*R_230[0]+Q_212010000*R_320[0]+-1*Q_212110000*R_330[0]+-1*Q_312010000*R_420[0]+Q_312110000*R_430[0]; double QR_011011000120=Q_011011000*R_120[0]+-1*Q_011111000*R_130[0]+Q_011211000*R_140[0]+-1*Q_111011000*R_220[0]+Q_111111000*R_230[0]+-1*Q_111211000*R_240[0]+Q_211011000*R_320[0]+-1*Q_211111000*R_330[0]+Q_211211000*R_340[0]; double QR_010012000120=Q_010012000*R_120[0]+-1*Q_010112000*R_130[0]+Q_010212000*R_140[0]+-1*Q_010312000*R_150[0]+-1*Q_110012000*R_220[0]+Q_110112000*R_230[0]+-1*Q_110212000*R_240[0]+Q_110312000*R_250[0]; double QR_011010001120=Q_011010001*R_120[0]+-1*Q_011010101*R_121[0]+-1*Q_011110001*R_130[0]+Q_011110101*R_131[0]+-1*Q_111010001*R_220[0]+Q_111010101*R_221[0]+Q_111110001*R_230[0]+-1*Q_111110101*R_231[0]+Q_211010001*R_320[0]+-1*Q_211010101*R_321[0]+-1*Q_211110001*R_330[0]+Q_211110101*R_331[0]; double QR_010011001120=Q_010011001*R_120[0]+-1*Q_010011101*R_121[0]+-1*Q_010111001*R_130[0]+Q_010111101*R_131[0]+Q_010211001*R_140[0]+-1*Q_010211101*R_141[0]+-1*Q_110011001*R_220[0]+Q_110011101*R_221[0]+Q_110111001*R_230[0]+-1*Q_110111101*R_231[0]+-1*Q_110211001*R_240[0]+Q_110211101*R_241[0]; double QR_010010002120=Q_010010002*R_120[0]+-1*Q_010010102*R_121[0]+Q_010010202*R_122[0]+-1*Q_010110002*R_130[0]+Q_010110102*R_131[0]+-1*Q_010110202*R_132[0]+-1*Q_110010002*R_220[0]+Q_110010102*R_221[0]+-1*Q_110010202*R_222[0]+Q_110110002*R_230[0]+-1*Q_110110102*R_231[0]+Q_110110202*R_232[0]; double QR_002020000120=Q_002020000*R_120[0]+-1*Q_002120000*R_130[0]+Q_002220000*R_140[0]+-1*Q_102020000*R_220[0]+Q_102120000*R_230[0]+-1*Q_102220000*R_240[0]+Q_202020000*R_320[0]+-1*Q_202120000*R_330[0]+Q_202220000*R_340[0]; double QR_001021000120=Q_001021000*R_120[0]+-1*Q_001121000*R_130[0]+Q_001221000*R_140[0]+-1*Q_001321000*R_150[0]+-1*Q_101021000*R_220[0]+Q_101121000*R_230[0]+-1*Q_101221000*R_240[0]+Q_101321000*R_250[0]; double QR_000022000120=Q_000022000*R_120[0]+-1*Q_000122000*R_130[0]+Q_000222000*R_140[0]+-1*Q_000322000*R_150[0]+Q_000422000*R_160[0]; double QR_001020001120=Q_001020001*R_120[0]+-1*Q_001020101*R_121[0]+-1*Q_001120001*R_130[0]+Q_001120101*R_131[0]+Q_001220001*R_140[0]+-1*Q_001220101*R_141[0]+-1*Q_101020001*R_220[0]+Q_101020101*R_221[0]+Q_101120001*R_230[0]+-1*Q_101120101*R_231[0]+-1*Q_101220001*R_240[0]+Q_101220101*R_241[0]; double QR_000021001120=Q_000021001*R_120[0]+-1*Q_000021101*R_121[0]+-1*Q_000121001*R_130[0]+Q_000121101*R_131[0]+Q_000221001*R_140[0]+-1*Q_000221101*R_141[0]+-1*Q_000321001*R_150[0]+Q_000321101*R_151[0]; double QR_000020002120=Q_000020002*R_120[0]+-1*Q_000020102*R_121[0]+Q_000020202*R_122[0]+-1*Q_000120002*R_130[0]+Q_000120102*R_131[0]+-1*Q_000120202*R_132[0]+Q_000220002*R_140[0]+-1*Q_000220102*R_141[0]+Q_000220202*R_142[0]; double QR_012000010120=Q_012000010*R_120[0]+-1*Q_012000110*R_121[0]+-1*Q_112000010*R_220[0]+Q_112000110*R_221[0]+Q_212000010*R_320[0]+-1*Q_212000110*R_321[0]+-1*Q_312000010*R_420[0]+Q_312000110*R_421[0]; double QR_011001010120=Q_011001010*R_120[0]+-1*Q_011001110*R_121[0]+-1*Q_011101010*R_130[0]+Q_011101110*R_131[0]+-1*Q_111001010*R_220[0]+Q_111001110*R_221[0]+Q_111101010*R_230[0]+-1*Q_111101110*R_231[0]+Q_211001010*R_320[0]+-1*Q_211001110*R_321[0]+-1*Q_211101010*R_330[0]+Q_211101110*R_331[0]; double QR_010002010120=Q_010002010*R_120[0]+-1*Q_010002110*R_121[0]+-1*Q_010102010*R_130[0]+Q_010102110*R_131[0]+Q_010202010*R_140[0]+-1*Q_010202110*R_141[0]+-1*Q_110002010*R_220[0]+Q_110002110*R_221[0]+Q_110102010*R_230[0]+-1*Q_110102110*R_231[0]+-1*Q_110202010*R_240[0]+Q_110202110*R_241[0]; double QR_011000011120=Q_011000011*R_120[0]+-1*Q_011000111*R_121[0]+Q_011000211*R_122[0]+-1*Q_111000011*R_220[0]+Q_111000111*R_221[0]+-1*Q_111000211*R_222[0]+Q_211000011*R_320[0]+-1*Q_211000111*R_321[0]+Q_211000211*R_322[0]; double QR_010001011120=Q_010001011*R_120[0]+-1*Q_010001111*R_121[0]+Q_010001211*R_122[0]+-1*Q_010101011*R_130[0]+Q_010101111*R_131[0]+-1*Q_010101211*R_132[0]+-1*Q_110001011*R_220[0]+Q_110001111*R_221[0]+-1*Q_110001211*R_222[0]+Q_110101011*R_230[0]+-1*Q_110101111*R_231[0]+Q_110101211*R_232[0]; double QR_010000012120=Q_010000012*R_120[0]+-1*Q_010000112*R_121[0]+Q_010000212*R_122[0]+-1*Q_010000312*R_123[0]+-1*Q_110000012*R_220[0]+Q_110000112*R_221[0]+-1*Q_110000212*R_222[0]+Q_110000312*R_223[0]; double QR_002010010120=Q_002010010*R_120[0]+-1*Q_002010110*R_121[0]+-1*Q_002110010*R_130[0]+Q_002110110*R_131[0]+-1*Q_102010010*R_220[0]+Q_102010110*R_221[0]+Q_102110010*R_230[0]+-1*Q_102110110*R_231[0]+Q_202010010*R_320[0]+-1*Q_202010110*R_321[0]+-1*Q_202110010*R_330[0]+Q_202110110*R_331[0]; double QR_001011010120=Q_001011010*R_120[0]+-1*Q_001011110*R_121[0]+-1*Q_001111010*R_130[0]+Q_001111110*R_131[0]+Q_001211010*R_140[0]+-1*Q_001211110*R_141[0]+-1*Q_101011010*R_220[0]+Q_101011110*R_221[0]+Q_101111010*R_230[0]+-1*Q_101111110*R_231[0]+-1*Q_101211010*R_240[0]+Q_101211110*R_241[0]; double QR_000012010120=Q_000012010*R_120[0]+-1*Q_000012110*R_121[0]+-1*Q_000112010*R_130[0]+Q_000112110*R_131[0]+Q_000212010*R_140[0]+-1*Q_000212110*R_141[0]+-1*Q_000312010*R_150[0]+Q_000312110*R_151[0]; double QR_001010011120=Q_001010011*R_120[0]+-1*Q_001010111*R_121[0]+Q_001010211*R_122[0]+-1*Q_001110011*R_130[0]+Q_001110111*R_131[0]+-1*Q_001110211*R_132[0]+-1*Q_101010011*R_220[0]+Q_101010111*R_221[0]+-1*Q_101010211*R_222[0]+Q_101110011*R_230[0]+-1*Q_101110111*R_231[0]+Q_101110211*R_232[0]; double QR_000011011120=Q_000011011*R_120[0]+-1*Q_000011111*R_121[0]+Q_000011211*R_122[0]+-1*Q_000111011*R_130[0]+Q_000111111*R_131[0]+-1*Q_000111211*R_132[0]+Q_000211011*R_140[0]+-1*Q_000211111*R_141[0]+Q_000211211*R_142[0]; double QR_000010012120=Q_000010012*R_120[0]+-1*Q_000010112*R_121[0]+Q_000010212*R_122[0]+-1*Q_000010312*R_123[0]+-1*Q_000110012*R_130[0]+Q_000110112*R_131[0]+-1*Q_000110212*R_132[0]+Q_000110312*R_133[0]; double QR_002000020120=Q_002000020*R_120[0]+-1*Q_002000120*R_121[0]+Q_002000220*R_122[0]+-1*Q_102000020*R_220[0]+Q_102000120*R_221[0]+-1*Q_102000220*R_222[0]+Q_202000020*R_320[0]+-1*Q_202000120*R_321[0]+Q_202000220*R_322[0]; double QR_001001020120=Q_001001020*R_120[0]+-1*Q_001001120*R_121[0]+Q_001001220*R_122[0]+-1*Q_001101020*R_130[0]+Q_001101120*R_131[0]+-1*Q_001101220*R_132[0]+-1*Q_101001020*R_220[0]+Q_101001120*R_221[0]+-1*Q_101001220*R_222[0]+Q_101101020*R_230[0]+-1*Q_101101120*R_231[0]+Q_101101220*R_232[0]; double QR_000002020120=Q_000002020*R_120[0]+-1*Q_000002120*R_121[0]+Q_000002220*R_122[0]+-1*Q_000102020*R_130[0]+Q_000102120*R_131[0]+-1*Q_000102220*R_132[0]+Q_000202020*R_140[0]+-1*Q_000202120*R_141[0]+Q_000202220*R_142[0]; double QR_001000021120=Q_001000021*R_120[0]+-1*Q_001000121*R_121[0]+Q_001000221*R_122[0]+-1*Q_001000321*R_123[0]+-1*Q_101000021*R_220[0]+Q_101000121*R_221[0]+-1*Q_101000221*R_222[0]+Q_101000321*R_223[0]; double QR_000001021120=Q_000001021*R_120[0]+-1*Q_000001121*R_121[0]+Q_000001221*R_122[0]+-1*Q_000001321*R_123[0]+-1*Q_000101021*R_130[0]+Q_000101121*R_131[0]+-1*Q_000101221*R_132[0]+Q_000101321*R_133[0]; double QR_000000022120=Q_000000022*R_120[0]+-1*Q_000000122*R_121[0]+Q_000000222*R_122[0]+-1*Q_000000322*R_123[0]+Q_000000422*R_124[0]; double QR_022000000201=Q_022000000*R_201[0]+-1*Q_122000000*R_301[0]+Q_222000000*R_401[0]+-1*Q_322000000*R_501[0]+Q_422000000*R_601[0]; double QR_021001000201=Q_021001000*R_201[0]+-1*Q_021101000*R_211[0]+-1*Q_121001000*R_301[0]+Q_121101000*R_311[0]+Q_221001000*R_401[0]+-1*Q_221101000*R_411[0]+-1*Q_321001000*R_501[0]+Q_321101000*R_511[0]; double QR_020002000201=Q_020002000*R_201[0]+-1*Q_020102000*R_211[0]+Q_020202000*R_221[0]+-1*Q_120002000*R_301[0]+Q_120102000*R_311[0]+-1*Q_120202000*R_321[0]+Q_220002000*R_401[0]+-1*Q_220102000*R_411[0]+Q_220202000*R_421[0]; double QR_021000001201=Q_021000001*R_201[0]+-1*Q_021000101*R_202[0]+-1*Q_121000001*R_301[0]+Q_121000101*R_302[0]+Q_221000001*R_401[0]+-1*Q_221000101*R_402[0]+-1*Q_321000001*R_501[0]+Q_321000101*R_502[0]; double QR_020001001201=Q_020001001*R_201[0]+-1*Q_020001101*R_202[0]+-1*Q_020101001*R_211[0]+Q_020101101*R_212[0]+-1*Q_120001001*R_301[0]+Q_120001101*R_302[0]+Q_120101001*R_311[0]+-1*Q_120101101*R_312[0]+Q_220001001*R_401[0]+-1*Q_220001101*R_402[0]+-1*Q_220101001*R_411[0]+Q_220101101*R_412[0]; double QR_020000002201=Q_020000002*R_201[0]+-1*Q_020000102*R_202[0]+Q_020000202*R_203[0]+-1*Q_120000002*R_301[0]+Q_120000102*R_302[0]+-1*Q_120000202*R_303[0]+Q_220000002*R_401[0]+-1*Q_220000102*R_402[0]+Q_220000202*R_403[0]; double QR_012010000201=Q_012010000*R_201[0]+-1*Q_012110000*R_211[0]+-1*Q_112010000*R_301[0]+Q_112110000*R_311[0]+Q_212010000*R_401[0]+-1*Q_212110000*R_411[0]+-1*Q_312010000*R_501[0]+Q_312110000*R_511[0]; double QR_011011000201=Q_011011000*R_201[0]+-1*Q_011111000*R_211[0]+Q_011211000*R_221[0]+-1*Q_111011000*R_301[0]+Q_111111000*R_311[0]+-1*Q_111211000*R_321[0]+Q_211011000*R_401[0]+-1*Q_211111000*R_411[0]+Q_211211000*R_421[0]; double QR_010012000201=Q_010012000*R_201[0]+-1*Q_010112000*R_211[0]+Q_010212000*R_221[0]+-1*Q_010312000*R_231[0]+-1*Q_110012000*R_301[0]+Q_110112000*R_311[0]+-1*Q_110212000*R_321[0]+Q_110312000*R_331[0]; double QR_011010001201=Q_011010001*R_201[0]+-1*Q_011010101*R_202[0]+-1*Q_011110001*R_211[0]+Q_011110101*R_212[0]+-1*Q_111010001*R_301[0]+Q_111010101*R_302[0]+Q_111110001*R_311[0]+-1*Q_111110101*R_312[0]+Q_211010001*R_401[0]+-1*Q_211010101*R_402[0]+-1*Q_211110001*R_411[0]+Q_211110101*R_412[0]; double QR_010011001201=Q_010011001*R_201[0]+-1*Q_010011101*R_202[0]+-1*Q_010111001*R_211[0]+Q_010111101*R_212[0]+Q_010211001*R_221[0]+-1*Q_010211101*R_222[0]+-1*Q_110011001*R_301[0]+Q_110011101*R_302[0]+Q_110111001*R_311[0]+-1*Q_110111101*R_312[0]+-1*Q_110211001*R_321[0]+Q_110211101*R_322[0]; double QR_010010002201=Q_010010002*R_201[0]+-1*Q_010010102*R_202[0]+Q_010010202*R_203[0]+-1*Q_010110002*R_211[0]+Q_010110102*R_212[0]+-1*Q_010110202*R_213[0]+-1*Q_110010002*R_301[0]+Q_110010102*R_302[0]+-1*Q_110010202*R_303[0]+Q_110110002*R_311[0]+-1*Q_110110102*R_312[0]+Q_110110202*R_313[0]; double QR_002020000201=Q_002020000*R_201[0]+-1*Q_002120000*R_211[0]+Q_002220000*R_221[0]+-1*Q_102020000*R_301[0]+Q_102120000*R_311[0]+-1*Q_102220000*R_321[0]+Q_202020000*R_401[0]+-1*Q_202120000*R_411[0]+Q_202220000*R_421[0]; double QR_001021000201=Q_001021000*R_201[0]+-1*Q_001121000*R_211[0]+Q_001221000*R_221[0]+-1*Q_001321000*R_231[0]+-1*Q_101021000*R_301[0]+Q_101121000*R_311[0]+-1*Q_101221000*R_321[0]+Q_101321000*R_331[0]; double QR_000022000201=Q_000022000*R_201[0]+-1*Q_000122000*R_211[0]+Q_000222000*R_221[0]+-1*Q_000322000*R_231[0]+Q_000422000*R_241[0]; double QR_001020001201=Q_001020001*R_201[0]+-1*Q_001020101*R_202[0]+-1*Q_001120001*R_211[0]+Q_001120101*R_212[0]+Q_001220001*R_221[0]+-1*Q_001220101*R_222[0]+-1*Q_101020001*R_301[0]+Q_101020101*R_302[0]+Q_101120001*R_311[0]+-1*Q_101120101*R_312[0]+-1*Q_101220001*R_321[0]+Q_101220101*R_322[0]; double QR_000021001201=Q_000021001*R_201[0]+-1*Q_000021101*R_202[0]+-1*Q_000121001*R_211[0]+Q_000121101*R_212[0]+Q_000221001*R_221[0]+-1*Q_000221101*R_222[0]+-1*Q_000321001*R_231[0]+Q_000321101*R_232[0]; double QR_000020002201=Q_000020002*R_201[0]+-1*Q_000020102*R_202[0]+Q_000020202*R_203[0]+-1*Q_000120002*R_211[0]+Q_000120102*R_212[0]+-1*Q_000120202*R_213[0]+Q_000220002*R_221[0]+-1*Q_000220102*R_222[0]+Q_000220202*R_223[0]; double QR_012000010201=Q_012000010*R_201[0]+-1*Q_012000110*R_202[0]+-1*Q_112000010*R_301[0]+Q_112000110*R_302[0]+Q_212000010*R_401[0]+-1*Q_212000110*R_402[0]+-1*Q_312000010*R_501[0]+Q_312000110*R_502[0]; double QR_011001010201=Q_011001010*R_201[0]+-1*Q_011001110*R_202[0]+-1*Q_011101010*R_211[0]+Q_011101110*R_212[0]+-1*Q_111001010*R_301[0]+Q_111001110*R_302[0]+Q_111101010*R_311[0]+-1*Q_111101110*R_312[0]+Q_211001010*R_401[0]+-1*Q_211001110*R_402[0]+-1*Q_211101010*R_411[0]+Q_211101110*R_412[0]; double QR_010002010201=Q_010002010*R_201[0]+-1*Q_010002110*R_202[0]+-1*Q_010102010*R_211[0]+Q_010102110*R_212[0]+Q_010202010*R_221[0]+-1*Q_010202110*R_222[0]+-1*Q_110002010*R_301[0]+Q_110002110*R_302[0]+Q_110102010*R_311[0]+-1*Q_110102110*R_312[0]+-1*Q_110202010*R_321[0]+Q_110202110*R_322[0]; double QR_011000011201=Q_011000011*R_201[0]+-1*Q_011000111*R_202[0]+Q_011000211*R_203[0]+-1*Q_111000011*R_301[0]+Q_111000111*R_302[0]+-1*Q_111000211*R_303[0]+Q_211000011*R_401[0]+-1*Q_211000111*R_402[0]+Q_211000211*R_403[0]; double QR_010001011201=Q_010001011*R_201[0]+-1*Q_010001111*R_202[0]+Q_010001211*R_203[0]+-1*Q_010101011*R_211[0]+Q_010101111*R_212[0]+-1*Q_010101211*R_213[0]+-1*Q_110001011*R_301[0]+Q_110001111*R_302[0]+-1*Q_110001211*R_303[0]+Q_110101011*R_311[0]+-1*Q_110101111*R_312[0]+Q_110101211*R_313[0]; double QR_010000012201=Q_010000012*R_201[0]+-1*Q_010000112*R_202[0]+Q_010000212*R_203[0]+-1*Q_010000312*R_204[0]+-1*Q_110000012*R_301[0]+Q_110000112*R_302[0]+-1*Q_110000212*R_303[0]+Q_110000312*R_304[0]; double QR_002010010201=Q_002010010*R_201[0]+-1*Q_002010110*R_202[0]+-1*Q_002110010*R_211[0]+Q_002110110*R_212[0]+-1*Q_102010010*R_301[0]+Q_102010110*R_302[0]+Q_102110010*R_311[0]+-1*Q_102110110*R_312[0]+Q_202010010*R_401[0]+-1*Q_202010110*R_402[0]+-1*Q_202110010*R_411[0]+Q_202110110*R_412[0]; double QR_001011010201=Q_001011010*R_201[0]+-1*Q_001011110*R_202[0]+-1*Q_001111010*R_211[0]+Q_001111110*R_212[0]+Q_001211010*R_221[0]+-1*Q_001211110*R_222[0]+-1*Q_101011010*R_301[0]+Q_101011110*R_302[0]+Q_101111010*R_311[0]+-1*Q_101111110*R_312[0]+-1*Q_101211010*R_321[0]+Q_101211110*R_322[0]; double QR_000012010201=Q_000012010*R_201[0]+-1*Q_000012110*R_202[0]+-1*Q_000112010*R_211[0]+Q_000112110*R_212[0]+Q_000212010*R_221[0]+-1*Q_000212110*R_222[0]+-1*Q_000312010*R_231[0]+Q_000312110*R_232[0]; double QR_001010011201=Q_001010011*R_201[0]+-1*Q_001010111*R_202[0]+Q_001010211*R_203[0]+-1*Q_001110011*R_211[0]+Q_001110111*R_212[0]+-1*Q_001110211*R_213[0]+-1*Q_101010011*R_301[0]+Q_101010111*R_302[0]+-1*Q_101010211*R_303[0]+Q_101110011*R_311[0]+-1*Q_101110111*R_312[0]+Q_101110211*R_313[0]; double QR_000011011201=Q_000011011*R_201[0]+-1*Q_000011111*R_202[0]+Q_000011211*R_203[0]+-1*Q_000111011*R_211[0]+Q_000111111*R_212[0]+-1*Q_000111211*R_213[0]+Q_000211011*R_221[0]+-1*Q_000211111*R_222[0]+Q_000211211*R_223[0]; double QR_000010012201=Q_000010012*R_201[0]+-1*Q_000010112*R_202[0]+Q_000010212*R_203[0]+-1*Q_000010312*R_204[0]+-1*Q_000110012*R_211[0]+Q_000110112*R_212[0]+-1*Q_000110212*R_213[0]+Q_000110312*R_214[0]; double QR_002000020201=Q_002000020*R_201[0]+-1*Q_002000120*R_202[0]+Q_002000220*R_203[0]+-1*Q_102000020*R_301[0]+Q_102000120*R_302[0]+-1*Q_102000220*R_303[0]+Q_202000020*R_401[0]+-1*Q_202000120*R_402[0]+Q_202000220*R_403[0]; double QR_001001020201=Q_001001020*R_201[0]+-1*Q_001001120*R_202[0]+Q_001001220*R_203[0]+-1*Q_001101020*R_211[0]+Q_001101120*R_212[0]+-1*Q_001101220*R_213[0]+-1*Q_101001020*R_301[0]+Q_101001120*R_302[0]+-1*Q_101001220*R_303[0]+Q_101101020*R_311[0]+-1*Q_101101120*R_312[0]+Q_101101220*R_313[0]; double QR_000002020201=Q_000002020*R_201[0]+-1*Q_000002120*R_202[0]+Q_000002220*R_203[0]+-1*Q_000102020*R_211[0]+Q_000102120*R_212[0]+-1*Q_000102220*R_213[0]+Q_000202020*R_221[0]+-1*Q_000202120*R_222[0]+Q_000202220*R_223[0]; double QR_001000021201=Q_001000021*R_201[0]+-1*Q_001000121*R_202[0]+Q_001000221*R_203[0]+-1*Q_001000321*R_204[0]+-1*Q_101000021*R_301[0]+Q_101000121*R_302[0]+-1*Q_101000221*R_303[0]+Q_101000321*R_304[0]; double QR_000001021201=Q_000001021*R_201[0]+-1*Q_000001121*R_202[0]+Q_000001221*R_203[0]+-1*Q_000001321*R_204[0]+-1*Q_000101021*R_211[0]+Q_000101121*R_212[0]+-1*Q_000101221*R_213[0]+Q_000101321*R_214[0]; double QR_000000022201=Q_000000022*R_201[0]+-1*Q_000000122*R_202[0]+Q_000000222*R_203[0]+-1*Q_000000322*R_204[0]+Q_000000422*R_205[0]; double QR_022000000210=Q_022000000*R_210[0]+-1*Q_122000000*R_310[0]+Q_222000000*R_410[0]+-1*Q_322000000*R_510[0]+Q_422000000*R_610[0]; double QR_021001000210=Q_021001000*R_210[0]+-1*Q_021101000*R_220[0]+-1*Q_121001000*R_310[0]+Q_121101000*R_320[0]+Q_221001000*R_410[0]+-1*Q_221101000*R_420[0]+-1*Q_321001000*R_510[0]+Q_321101000*R_520[0]; double QR_020002000210=Q_020002000*R_210[0]+-1*Q_020102000*R_220[0]+Q_020202000*R_230[0]+-1*Q_120002000*R_310[0]+Q_120102000*R_320[0]+-1*Q_120202000*R_330[0]+Q_220002000*R_410[0]+-1*Q_220102000*R_420[0]+Q_220202000*R_430[0]; double QR_021000001210=Q_021000001*R_210[0]+-1*Q_021000101*R_211[0]+-1*Q_121000001*R_310[0]+Q_121000101*R_311[0]+Q_221000001*R_410[0]+-1*Q_221000101*R_411[0]+-1*Q_321000001*R_510[0]+Q_321000101*R_511[0]; double QR_020001001210=Q_020001001*R_210[0]+-1*Q_020001101*R_211[0]+-1*Q_020101001*R_220[0]+Q_020101101*R_221[0]+-1*Q_120001001*R_310[0]+Q_120001101*R_311[0]+Q_120101001*R_320[0]+-1*Q_120101101*R_321[0]+Q_220001001*R_410[0]+-1*Q_220001101*R_411[0]+-1*Q_220101001*R_420[0]+Q_220101101*R_421[0]; double QR_020000002210=Q_020000002*R_210[0]+-1*Q_020000102*R_211[0]+Q_020000202*R_212[0]+-1*Q_120000002*R_310[0]+Q_120000102*R_311[0]+-1*Q_120000202*R_312[0]+Q_220000002*R_410[0]+-1*Q_220000102*R_411[0]+Q_220000202*R_412[0]; double QR_012010000210=Q_012010000*R_210[0]+-1*Q_012110000*R_220[0]+-1*Q_112010000*R_310[0]+Q_112110000*R_320[0]+Q_212010000*R_410[0]+-1*Q_212110000*R_420[0]+-1*Q_312010000*R_510[0]+Q_312110000*R_520[0]; double QR_011011000210=Q_011011000*R_210[0]+-1*Q_011111000*R_220[0]+Q_011211000*R_230[0]+-1*Q_111011000*R_310[0]+Q_111111000*R_320[0]+-1*Q_111211000*R_330[0]+Q_211011000*R_410[0]+-1*Q_211111000*R_420[0]+Q_211211000*R_430[0]; double QR_010012000210=Q_010012000*R_210[0]+-1*Q_010112000*R_220[0]+Q_010212000*R_230[0]+-1*Q_010312000*R_240[0]+-1*Q_110012000*R_310[0]+Q_110112000*R_320[0]+-1*Q_110212000*R_330[0]+Q_110312000*R_340[0]; double QR_011010001210=Q_011010001*R_210[0]+-1*Q_011010101*R_211[0]+-1*Q_011110001*R_220[0]+Q_011110101*R_221[0]+-1*Q_111010001*R_310[0]+Q_111010101*R_311[0]+Q_111110001*R_320[0]+-1*Q_111110101*R_321[0]+Q_211010001*R_410[0]+-1*Q_211010101*R_411[0]+-1*Q_211110001*R_420[0]+Q_211110101*R_421[0]; double QR_010011001210=Q_010011001*R_210[0]+-1*Q_010011101*R_211[0]+-1*Q_010111001*R_220[0]+Q_010111101*R_221[0]+Q_010211001*R_230[0]+-1*Q_010211101*R_231[0]+-1*Q_110011001*R_310[0]+Q_110011101*R_311[0]+Q_110111001*R_320[0]+-1*Q_110111101*R_321[0]+-1*Q_110211001*R_330[0]+Q_110211101*R_331[0]; double QR_010010002210=Q_010010002*R_210[0]+-1*Q_010010102*R_211[0]+Q_010010202*R_212[0]+-1*Q_010110002*R_220[0]+Q_010110102*R_221[0]+-1*Q_010110202*R_222[0]+-1*Q_110010002*R_310[0]+Q_110010102*R_311[0]+-1*Q_110010202*R_312[0]+Q_110110002*R_320[0]+-1*Q_110110102*R_321[0]+Q_110110202*R_322[0]; double QR_002020000210=Q_002020000*R_210[0]+-1*Q_002120000*R_220[0]+Q_002220000*R_230[0]+-1*Q_102020000*R_310[0]+Q_102120000*R_320[0]+-1*Q_102220000*R_330[0]+Q_202020000*R_410[0]+-1*Q_202120000*R_420[0]+Q_202220000*R_430[0]; double QR_001021000210=Q_001021000*R_210[0]+-1*Q_001121000*R_220[0]+Q_001221000*R_230[0]+-1*Q_001321000*R_240[0]+-1*Q_101021000*R_310[0]+Q_101121000*R_320[0]+-1*Q_101221000*R_330[0]+Q_101321000*R_340[0]; double QR_000022000210=Q_000022000*R_210[0]+-1*Q_000122000*R_220[0]+Q_000222000*R_230[0]+-1*Q_000322000*R_240[0]+Q_000422000*R_250[0]; double QR_001020001210=Q_001020001*R_210[0]+-1*Q_001020101*R_211[0]+-1*Q_001120001*R_220[0]+Q_001120101*R_221[0]+Q_001220001*R_230[0]+-1*Q_001220101*R_231[0]+-1*Q_101020001*R_310[0]+Q_101020101*R_311[0]+Q_101120001*R_320[0]+-1*Q_101120101*R_321[0]+-1*Q_101220001*R_330[0]+Q_101220101*R_331[0]; double QR_000021001210=Q_000021001*R_210[0]+-1*Q_000021101*R_211[0]+-1*Q_000121001*R_220[0]+Q_000121101*R_221[0]+Q_000221001*R_230[0]+-1*Q_000221101*R_231[0]+-1*Q_000321001*R_240[0]+Q_000321101*R_241[0]; double QR_000020002210=Q_000020002*R_210[0]+-1*Q_000020102*R_211[0]+Q_000020202*R_212[0]+-1*Q_000120002*R_220[0]+Q_000120102*R_221[0]+-1*Q_000120202*R_222[0]+Q_000220002*R_230[0]+-1*Q_000220102*R_231[0]+Q_000220202*R_232[0]; double QR_012000010210=Q_012000010*R_210[0]+-1*Q_012000110*R_211[0]+-1*Q_112000010*R_310[0]+Q_112000110*R_311[0]+Q_212000010*R_410[0]+-1*Q_212000110*R_411[0]+-1*Q_312000010*R_510[0]+Q_312000110*R_511[0]; double QR_011001010210=Q_011001010*R_210[0]+-1*Q_011001110*R_211[0]+-1*Q_011101010*R_220[0]+Q_011101110*R_221[0]+-1*Q_111001010*R_310[0]+Q_111001110*R_311[0]+Q_111101010*R_320[0]+-1*Q_111101110*R_321[0]+Q_211001010*R_410[0]+-1*Q_211001110*R_411[0]+-1*Q_211101010*R_420[0]+Q_211101110*R_421[0]; double QR_010002010210=Q_010002010*R_210[0]+-1*Q_010002110*R_211[0]+-1*Q_010102010*R_220[0]+Q_010102110*R_221[0]+Q_010202010*R_230[0]+-1*Q_010202110*R_231[0]+-1*Q_110002010*R_310[0]+Q_110002110*R_311[0]+Q_110102010*R_320[0]+-1*Q_110102110*R_321[0]+-1*Q_110202010*R_330[0]+Q_110202110*R_331[0]; double QR_011000011210=Q_011000011*R_210[0]+-1*Q_011000111*R_211[0]+Q_011000211*R_212[0]+-1*Q_111000011*R_310[0]+Q_111000111*R_311[0]+-1*Q_111000211*R_312[0]+Q_211000011*R_410[0]+-1*Q_211000111*R_411[0]+Q_211000211*R_412[0]; double QR_010001011210=Q_010001011*R_210[0]+-1*Q_010001111*R_211[0]+Q_010001211*R_212[0]+-1*Q_010101011*R_220[0]+Q_010101111*R_221[0]+-1*Q_010101211*R_222[0]+-1*Q_110001011*R_310[0]+Q_110001111*R_311[0]+-1*Q_110001211*R_312[0]+Q_110101011*R_320[0]+-1*Q_110101111*R_321[0]+Q_110101211*R_322[0]; double QR_010000012210=Q_010000012*R_210[0]+-1*Q_010000112*R_211[0]+Q_010000212*R_212[0]+-1*Q_010000312*R_213[0]+-1*Q_110000012*R_310[0]+Q_110000112*R_311[0]+-1*Q_110000212*R_312[0]+Q_110000312*R_313[0]; double QR_002010010210=Q_002010010*R_210[0]+-1*Q_002010110*R_211[0]+-1*Q_002110010*R_220[0]+Q_002110110*R_221[0]+-1*Q_102010010*R_310[0]+Q_102010110*R_311[0]+Q_102110010*R_320[0]+-1*Q_102110110*R_321[0]+Q_202010010*R_410[0]+-1*Q_202010110*R_411[0]+-1*Q_202110010*R_420[0]+Q_202110110*R_421[0]; double QR_001011010210=Q_001011010*R_210[0]+-1*Q_001011110*R_211[0]+-1*Q_001111010*R_220[0]+Q_001111110*R_221[0]+Q_001211010*R_230[0]+-1*Q_001211110*R_231[0]+-1*Q_101011010*R_310[0]+Q_101011110*R_311[0]+Q_101111010*R_320[0]+-1*Q_101111110*R_321[0]+-1*Q_101211010*R_330[0]+Q_101211110*R_331[0]; double QR_000012010210=Q_000012010*R_210[0]+-1*Q_000012110*R_211[0]+-1*Q_000112010*R_220[0]+Q_000112110*R_221[0]+Q_000212010*R_230[0]+-1*Q_000212110*R_231[0]+-1*Q_000312010*R_240[0]+Q_000312110*R_241[0]; double QR_001010011210=Q_001010011*R_210[0]+-1*Q_001010111*R_211[0]+Q_001010211*R_212[0]+-1*Q_001110011*R_220[0]+Q_001110111*R_221[0]+-1*Q_001110211*R_222[0]+-1*Q_101010011*R_310[0]+Q_101010111*R_311[0]+-1*Q_101010211*R_312[0]+Q_101110011*R_320[0]+-1*Q_101110111*R_321[0]+Q_101110211*R_322[0]; double QR_000011011210=Q_000011011*R_210[0]+-1*Q_000011111*R_211[0]+Q_000011211*R_212[0]+-1*Q_000111011*R_220[0]+Q_000111111*R_221[0]+-1*Q_000111211*R_222[0]+Q_000211011*R_230[0]+-1*Q_000211111*R_231[0]+Q_000211211*R_232[0]; double QR_000010012210=Q_000010012*R_210[0]+-1*Q_000010112*R_211[0]+Q_000010212*R_212[0]+-1*Q_000010312*R_213[0]+-1*Q_000110012*R_220[0]+Q_000110112*R_221[0]+-1*Q_000110212*R_222[0]+Q_000110312*R_223[0]; double QR_002000020210=Q_002000020*R_210[0]+-1*Q_002000120*R_211[0]+Q_002000220*R_212[0]+-1*Q_102000020*R_310[0]+Q_102000120*R_311[0]+-1*Q_102000220*R_312[0]+Q_202000020*R_410[0]+-1*Q_202000120*R_411[0]+Q_202000220*R_412[0]; double QR_001001020210=Q_001001020*R_210[0]+-1*Q_001001120*R_211[0]+Q_001001220*R_212[0]+-1*Q_001101020*R_220[0]+Q_001101120*R_221[0]+-1*Q_001101220*R_222[0]+-1*Q_101001020*R_310[0]+Q_101001120*R_311[0]+-1*Q_101001220*R_312[0]+Q_101101020*R_320[0]+-1*Q_101101120*R_321[0]+Q_101101220*R_322[0]; double QR_000002020210=Q_000002020*R_210[0]+-1*Q_000002120*R_211[0]+Q_000002220*R_212[0]+-1*Q_000102020*R_220[0]+Q_000102120*R_221[0]+-1*Q_000102220*R_222[0]+Q_000202020*R_230[0]+-1*Q_000202120*R_231[0]+Q_000202220*R_232[0]; double QR_001000021210=Q_001000021*R_210[0]+-1*Q_001000121*R_211[0]+Q_001000221*R_212[0]+-1*Q_001000321*R_213[0]+-1*Q_101000021*R_310[0]+Q_101000121*R_311[0]+-1*Q_101000221*R_312[0]+Q_101000321*R_313[0]; double QR_000001021210=Q_000001021*R_210[0]+-1*Q_000001121*R_211[0]+Q_000001221*R_212[0]+-1*Q_000001321*R_213[0]+-1*Q_000101021*R_220[0]+Q_000101121*R_221[0]+-1*Q_000101221*R_222[0]+Q_000101321*R_223[0]; double QR_000000022210=Q_000000022*R_210[0]+-1*Q_000000122*R_211[0]+Q_000000222*R_212[0]+-1*Q_000000322*R_213[0]+Q_000000422*R_214[0]; double QR_022000000300=Q_022000000*R_300[0]+-1*Q_122000000*R_400[0]+Q_222000000*R_500[0]+-1*Q_322000000*R_600[0]+Q_422000000*R_700[0]; double QR_021001000300=Q_021001000*R_300[0]+-1*Q_021101000*R_310[0]+-1*Q_121001000*R_400[0]+Q_121101000*R_410[0]+Q_221001000*R_500[0]+-1*Q_221101000*R_510[0]+-1*Q_321001000*R_600[0]+Q_321101000*R_610[0]; double QR_020002000300=Q_020002000*R_300[0]+-1*Q_020102000*R_310[0]+Q_020202000*R_320[0]+-1*Q_120002000*R_400[0]+Q_120102000*R_410[0]+-1*Q_120202000*R_420[0]+Q_220002000*R_500[0]+-1*Q_220102000*R_510[0]+Q_220202000*R_520[0]; double QR_021000001300=Q_021000001*R_300[0]+-1*Q_021000101*R_301[0]+-1*Q_121000001*R_400[0]+Q_121000101*R_401[0]+Q_221000001*R_500[0]+-1*Q_221000101*R_501[0]+-1*Q_321000001*R_600[0]+Q_321000101*R_601[0]; double QR_020001001300=Q_020001001*R_300[0]+-1*Q_020001101*R_301[0]+-1*Q_020101001*R_310[0]+Q_020101101*R_311[0]+-1*Q_120001001*R_400[0]+Q_120001101*R_401[0]+Q_120101001*R_410[0]+-1*Q_120101101*R_411[0]+Q_220001001*R_500[0]+-1*Q_220001101*R_501[0]+-1*Q_220101001*R_510[0]+Q_220101101*R_511[0]; double QR_020000002300=Q_020000002*R_300[0]+-1*Q_020000102*R_301[0]+Q_020000202*R_302[0]+-1*Q_120000002*R_400[0]+Q_120000102*R_401[0]+-1*Q_120000202*R_402[0]+Q_220000002*R_500[0]+-1*Q_220000102*R_501[0]+Q_220000202*R_502[0]; double QR_012010000300=Q_012010000*R_300[0]+-1*Q_012110000*R_310[0]+-1*Q_112010000*R_400[0]+Q_112110000*R_410[0]+Q_212010000*R_500[0]+-1*Q_212110000*R_510[0]+-1*Q_312010000*R_600[0]+Q_312110000*R_610[0]; double QR_011011000300=Q_011011000*R_300[0]+-1*Q_011111000*R_310[0]+Q_011211000*R_320[0]+-1*Q_111011000*R_400[0]+Q_111111000*R_410[0]+-1*Q_111211000*R_420[0]+Q_211011000*R_500[0]+-1*Q_211111000*R_510[0]+Q_211211000*R_520[0]; double QR_010012000300=Q_010012000*R_300[0]+-1*Q_010112000*R_310[0]+Q_010212000*R_320[0]+-1*Q_010312000*R_330[0]+-1*Q_110012000*R_400[0]+Q_110112000*R_410[0]+-1*Q_110212000*R_420[0]+Q_110312000*R_430[0]; double QR_011010001300=Q_011010001*R_300[0]+-1*Q_011010101*R_301[0]+-1*Q_011110001*R_310[0]+Q_011110101*R_311[0]+-1*Q_111010001*R_400[0]+Q_111010101*R_401[0]+Q_111110001*R_410[0]+-1*Q_111110101*R_411[0]+Q_211010001*R_500[0]+-1*Q_211010101*R_501[0]+-1*Q_211110001*R_510[0]+Q_211110101*R_511[0]; double QR_010011001300=Q_010011001*R_300[0]+-1*Q_010011101*R_301[0]+-1*Q_010111001*R_310[0]+Q_010111101*R_311[0]+Q_010211001*R_320[0]+-1*Q_010211101*R_321[0]+-1*Q_110011001*R_400[0]+Q_110011101*R_401[0]+Q_110111001*R_410[0]+-1*Q_110111101*R_411[0]+-1*Q_110211001*R_420[0]+Q_110211101*R_421[0]; double QR_010010002300=Q_010010002*R_300[0]+-1*Q_010010102*R_301[0]+Q_010010202*R_302[0]+-1*Q_010110002*R_310[0]+Q_010110102*R_311[0]+-1*Q_010110202*R_312[0]+-1*Q_110010002*R_400[0]+Q_110010102*R_401[0]+-1*Q_110010202*R_402[0]+Q_110110002*R_410[0]+-1*Q_110110102*R_411[0]+Q_110110202*R_412[0]; double QR_002020000300=Q_002020000*R_300[0]+-1*Q_002120000*R_310[0]+Q_002220000*R_320[0]+-1*Q_102020000*R_400[0]+Q_102120000*R_410[0]+-1*Q_102220000*R_420[0]+Q_202020000*R_500[0]+-1*Q_202120000*R_510[0]+Q_202220000*R_520[0]; double QR_001021000300=Q_001021000*R_300[0]+-1*Q_001121000*R_310[0]+Q_001221000*R_320[0]+-1*Q_001321000*R_330[0]+-1*Q_101021000*R_400[0]+Q_101121000*R_410[0]+-1*Q_101221000*R_420[0]+Q_101321000*R_430[0]; double QR_000022000300=Q_000022000*R_300[0]+-1*Q_000122000*R_310[0]+Q_000222000*R_320[0]+-1*Q_000322000*R_330[0]+Q_000422000*R_340[0]; double QR_001020001300=Q_001020001*R_300[0]+-1*Q_001020101*R_301[0]+-1*Q_001120001*R_310[0]+Q_001120101*R_311[0]+Q_001220001*R_320[0]+-1*Q_001220101*R_321[0]+-1*Q_101020001*R_400[0]+Q_101020101*R_401[0]+Q_101120001*R_410[0]+-1*Q_101120101*R_411[0]+-1*Q_101220001*R_420[0]+Q_101220101*R_421[0]; double QR_000021001300=Q_000021001*R_300[0]+-1*Q_000021101*R_301[0]+-1*Q_000121001*R_310[0]+Q_000121101*R_311[0]+Q_000221001*R_320[0]+-1*Q_000221101*R_321[0]+-1*Q_000321001*R_330[0]+Q_000321101*R_331[0]; double QR_000020002300=Q_000020002*R_300[0]+-1*Q_000020102*R_301[0]+Q_000020202*R_302[0]+-1*Q_000120002*R_310[0]+Q_000120102*R_311[0]+-1*Q_000120202*R_312[0]+Q_000220002*R_320[0]+-1*Q_000220102*R_321[0]+Q_000220202*R_322[0]; double QR_012000010300=Q_012000010*R_300[0]+-1*Q_012000110*R_301[0]+-1*Q_112000010*R_400[0]+Q_112000110*R_401[0]+Q_212000010*R_500[0]+-1*Q_212000110*R_501[0]+-1*Q_312000010*R_600[0]+Q_312000110*R_601[0]; double QR_011001010300=Q_011001010*R_300[0]+-1*Q_011001110*R_301[0]+-1*Q_011101010*R_310[0]+Q_011101110*R_311[0]+-1*Q_111001010*R_400[0]+Q_111001110*R_401[0]+Q_111101010*R_410[0]+-1*Q_111101110*R_411[0]+Q_211001010*R_500[0]+-1*Q_211001110*R_501[0]+-1*Q_211101010*R_510[0]+Q_211101110*R_511[0]; double QR_010002010300=Q_010002010*R_300[0]+-1*Q_010002110*R_301[0]+-1*Q_010102010*R_310[0]+Q_010102110*R_311[0]+Q_010202010*R_320[0]+-1*Q_010202110*R_321[0]+-1*Q_110002010*R_400[0]+Q_110002110*R_401[0]+Q_110102010*R_410[0]+-1*Q_110102110*R_411[0]+-1*Q_110202010*R_420[0]+Q_110202110*R_421[0]; double QR_011000011300=Q_011000011*R_300[0]+-1*Q_011000111*R_301[0]+Q_011000211*R_302[0]+-1*Q_111000011*R_400[0]+Q_111000111*R_401[0]+-1*Q_111000211*R_402[0]+Q_211000011*R_500[0]+-1*Q_211000111*R_501[0]+Q_211000211*R_502[0]; double QR_010001011300=Q_010001011*R_300[0]+-1*Q_010001111*R_301[0]+Q_010001211*R_302[0]+-1*Q_010101011*R_310[0]+Q_010101111*R_311[0]+-1*Q_010101211*R_312[0]+-1*Q_110001011*R_400[0]+Q_110001111*R_401[0]+-1*Q_110001211*R_402[0]+Q_110101011*R_410[0]+-1*Q_110101111*R_411[0]+Q_110101211*R_412[0]; double QR_010000012300=Q_010000012*R_300[0]+-1*Q_010000112*R_301[0]+Q_010000212*R_302[0]+-1*Q_010000312*R_303[0]+-1*Q_110000012*R_400[0]+Q_110000112*R_401[0]+-1*Q_110000212*R_402[0]+Q_110000312*R_403[0]; double QR_002010010300=Q_002010010*R_300[0]+-1*Q_002010110*R_301[0]+-1*Q_002110010*R_310[0]+Q_002110110*R_311[0]+-1*Q_102010010*R_400[0]+Q_102010110*R_401[0]+Q_102110010*R_410[0]+-1*Q_102110110*R_411[0]+Q_202010010*R_500[0]+-1*Q_202010110*R_501[0]+-1*Q_202110010*R_510[0]+Q_202110110*R_511[0]; double QR_001011010300=Q_001011010*R_300[0]+-1*Q_001011110*R_301[0]+-1*Q_001111010*R_310[0]+Q_001111110*R_311[0]+Q_001211010*R_320[0]+-1*Q_001211110*R_321[0]+-1*Q_101011010*R_400[0]+Q_101011110*R_401[0]+Q_101111010*R_410[0]+-1*Q_101111110*R_411[0]+-1*Q_101211010*R_420[0]+Q_101211110*R_421[0]; double QR_000012010300=Q_000012010*R_300[0]+-1*Q_000012110*R_301[0]+-1*Q_000112010*R_310[0]+Q_000112110*R_311[0]+Q_000212010*R_320[0]+-1*Q_000212110*R_321[0]+-1*Q_000312010*R_330[0]+Q_000312110*R_331[0]; double QR_001010011300=Q_001010011*R_300[0]+-1*Q_001010111*R_301[0]+Q_001010211*R_302[0]+-1*Q_001110011*R_310[0]+Q_001110111*R_311[0]+-1*Q_001110211*R_312[0]+-1*Q_101010011*R_400[0]+Q_101010111*R_401[0]+-1*Q_101010211*R_402[0]+Q_101110011*R_410[0]+-1*Q_101110111*R_411[0]+Q_101110211*R_412[0]; double QR_000011011300=Q_000011011*R_300[0]+-1*Q_000011111*R_301[0]+Q_000011211*R_302[0]+-1*Q_000111011*R_310[0]+Q_000111111*R_311[0]+-1*Q_000111211*R_312[0]+Q_000211011*R_320[0]+-1*Q_000211111*R_321[0]+Q_000211211*R_322[0]; double QR_000010012300=Q_000010012*R_300[0]+-1*Q_000010112*R_301[0]+Q_000010212*R_302[0]+-1*Q_000010312*R_303[0]+-1*Q_000110012*R_310[0]+Q_000110112*R_311[0]+-1*Q_000110212*R_312[0]+Q_000110312*R_313[0]; double QR_002000020300=Q_002000020*R_300[0]+-1*Q_002000120*R_301[0]+Q_002000220*R_302[0]+-1*Q_102000020*R_400[0]+Q_102000120*R_401[0]+-1*Q_102000220*R_402[0]+Q_202000020*R_500[0]+-1*Q_202000120*R_501[0]+Q_202000220*R_502[0]; double QR_001001020300=Q_001001020*R_300[0]+-1*Q_001001120*R_301[0]+Q_001001220*R_302[0]+-1*Q_001101020*R_310[0]+Q_001101120*R_311[0]+-1*Q_001101220*R_312[0]+-1*Q_101001020*R_400[0]+Q_101001120*R_401[0]+-1*Q_101001220*R_402[0]+Q_101101020*R_410[0]+-1*Q_101101120*R_411[0]+Q_101101220*R_412[0]; double QR_000002020300=Q_000002020*R_300[0]+-1*Q_000002120*R_301[0]+Q_000002220*R_302[0]+-1*Q_000102020*R_310[0]+Q_000102120*R_311[0]+-1*Q_000102220*R_312[0]+Q_000202020*R_320[0]+-1*Q_000202120*R_321[0]+Q_000202220*R_322[0]; double QR_001000021300=Q_001000021*R_300[0]+-1*Q_001000121*R_301[0]+Q_001000221*R_302[0]+-1*Q_001000321*R_303[0]+-1*Q_101000021*R_400[0]+Q_101000121*R_401[0]+-1*Q_101000221*R_402[0]+Q_101000321*R_403[0]; double QR_000001021300=Q_000001021*R_300[0]+-1*Q_000001121*R_301[0]+Q_000001221*R_302[0]+-1*Q_000001321*R_303[0]+-1*Q_000101021*R_310[0]+Q_000101121*R_311[0]+-1*Q_000101221*R_312[0]+Q_000101321*R_313[0]; double QR_000000022300=Q_000000022*R_300[0]+-1*Q_000000122*R_301[0]+Q_000000222*R_302[0]+-1*Q_000000322*R_303[0]+Q_000000422*R_304[0]; double QR_022000000004=Q_022000000*R_004[0]+-1*Q_122000000*R_104[0]+Q_222000000*R_204[0]+-1*Q_322000000*R_304[0]+Q_422000000*R_404[0]; double QR_021001000004=Q_021001000*R_004[0]+-1*Q_021101000*R_014[0]+-1*Q_121001000*R_104[0]+Q_121101000*R_114[0]+Q_221001000*R_204[0]+-1*Q_221101000*R_214[0]+-1*Q_321001000*R_304[0]+Q_321101000*R_314[0]; double QR_020002000004=Q_020002000*R_004[0]+-1*Q_020102000*R_014[0]+Q_020202000*R_024[0]+-1*Q_120002000*R_104[0]+Q_120102000*R_114[0]+-1*Q_120202000*R_124[0]+Q_220002000*R_204[0]+-1*Q_220102000*R_214[0]+Q_220202000*R_224[0]; double QR_021000001004=Q_021000001*R_004[0]+-1*Q_021000101*R_005[0]+-1*Q_121000001*R_104[0]+Q_121000101*R_105[0]+Q_221000001*R_204[0]+-1*Q_221000101*R_205[0]+-1*Q_321000001*R_304[0]+Q_321000101*R_305[0]; double QR_020001001004=Q_020001001*R_004[0]+-1*Q_020001101*R_005[0]+-1*Q_020101001*R_014[0]+Q_020101101*R_015[0]+-1*Q_120001001*R_104[0]+Q_120001101*R_105[0]+Q_120101001*R_114[0]+-1*Q_120101101*R_115[0]+Q_220001001*R_204[0]+-1*Q_220001101*R_205[0]+-1*Q_220101001*R_214[0]+Q_220101101*R_215[0]; double QR_020000002004=Q_020000002*R_004[0]+-1*Q_020000102*R_005[0]+Q_020000202*R_006[0]+-1*Q_120000002*R_104[0]+Q_120000102*R_105[0]+-1*Q_120000202*R_106[0]+Q_220000002*R_204[0]+-1*Q_220000102*R_205[0]+Q_220000202*R_206[0]; double QR_012010000004=Q_012010000*R_004[0]+-1*Q_012110000*R_014[0]+-1*Q_112010000*R_104[0]+Q_112110000*R_114[0]+Q_212010000*R_204[0]+-1*Q_212110000*R_214[0]+-1*Q_312010000*R_304[0]+Q_312110000*R_314[0]; double QR_011011000004=Q_011011000*R_004[0]+-1*Q_011111000*R_014[0]+Q_011211000*R_024[0]+-1*Q_111011000*R_104[0]+Q_111111000*R_114[0]+-1*Q_111211000*R_124[0]+Q_211011000*R_204[0]+-1*Q_211111000*R_214[0]+Q_211211000*R_224[0]; double QR_010012000004=Q_010012000*R_004[0]+-1*Q_010112000*R_014[0]+Q_010212000*R_024[0]+-1*Q_010312000*R_034[0]+-1*Q_110012000*R_104[0]+Q_110112000*R_114[0]+-1*Q_110212000*R_124[0]+Q_110312000*R_134[0]; double QR_011010001004=Q_011010001*R_004[0]+-1*Q_011010101*R_005[0]+-1*Q_011110001*R_014[0]+Q_011110101*R_015[0]+-1*Q_111010001*R_104[0]+Q_111010101*R_105[0]+Q_111110001*R_114[0]+-1*Q_111110101*R_115[0]+Q_211010001*R_204[0]+-1*Q_211010101*R_205[0]+-1*Q_211110001*R_214[0]+Q_211110101*R_215[0]; double QR_010011001004=Q_010011001*R_004[0]+-1*Q_010011101*R_005[0]+-1*Q_010111001*R_014[0]+Q_010111101*R_015[0]+Q_010211001*R_024[0]+-1*Q_010211101*R_025[0]+-1*Q_110011001*R_104[0]+Q_110011101*R_105[0]+Q_110111001*R_114[0]+-1*Q_110111101*R_115[0]+-1*Q_110211001*R_124[0]+Q_110211101*R_125[0]; double QR_010010002004=Q_010010002*R_004[0]+-1*Q_010010102*R_005[0]+Q_010010202*R_006[0]+-1*Q_010110002*R_014[0]+Q_010110102*R_015[0]+-1*Q_010110202*R_016[0]+-1*Q_110010002*R_104[0]+Q_110010102*R_105[0]+-1*Q_110010202*R_106[0]+Q_110110002*R_114[0]+-1*Q_110110102*R_115[0]+Q_110110202*R_116[0]; double QR_002020000004=Q_002020000*R_004[0]+-1*Q_002120000*R_014[0]+Q_002220000*R_024[0]+-1*Q_102020000*R_104[0]+Q_102120000*R_114[0]+-1*Q_102220000*R_124[0]+Q_202020000*R_204[0]+-1*Q_202120000*R_214[0]+Q_202220000*R_224[0]; double QR_001021000004=Q_001021000*R_004[0]+-1*Q_001121000*R_014[0]+Q_001221000*R_024[0]+-1*Q_001321000*R_034[0]+-1*Q_101021000*R_104[0]+Q_101121000*R_114[0]+-1*Q_101221000*R_124[0]+Q_101321000*R_134[0]; double QR_000022000004=Q_000022000*R_004[0]+-1*Q_000122000*R_014[0]+Q_000222000*R_024[0]+-1*Q_000322000*R_034[0]+Q_000422000*R_044[0]; double QR_001020001004=Q_001020001*R_004[0]+-1*Q_001020101*R_005[0]+-1*Q_001120001*R_014[0]+Q_001120101*R_015[0]+Q_001220001*R_024[0]+-1*Q_001220101*R_025[0]+-1*Q_101020001*R_104[0]+Q_101020101*R_105[0]+Q_101120001*R_114[0]+-1*Q_101120101*R_115[0]+-1*Q_101220001*R_124[0]+Q_101220101*R_125[0]; double QR_000021001004=Q_000021001*R_004[0]+-1*Q_000021101*R_005[0]+-1*Q_000121001*R_014[0]+Q_000121101*R_015[0]+Q_000221001*R_024[0]+-1*Q_000221101*R_025[0]+-1*Q_000321001*R_034[0]+Q_000321101*R_035[0]; double QR_000020002004=Q_000020002*R_004[0]+-1*Q_000020102*R_005[0]+Q_000020202*R_006[0]+-1*Q_000120002*R_014[0]+Q_000120102*R_015[0]+-1*Q_000120202*R_016[0]+Q_000220002*R_024[0]+-1*Q_000220102*R_025[0]+Q_000220202*R_026[0]; double QR_012000010004=Q_012000010*R_004[0]+-1*Q_012000110*R_005[0]+-1*Q_112000010*R_104[0]+Q_112000110*R_105[0]+Q_212000010*R_204[0]+-1*Q_212000110*R_205[0]+-1*Q_312000010*R_304[0]+Q_312000110*R_305[0]; double QR_011001010004=Q_011001010*R_004[0]+-1*Q_011001110*R_005[0]+-1*Q_011101010*R_014[0]+Q_011101110*R_015[0]+-1*Q_111001010*R_104[0]+Q_111001110*R_105[0]+Q_111101010*R_114[0]+-1*Q_111101110*R_115[0]+Q_211001010*R_204[0]+-1*Q_211001110*R_205[0]+-1*Q_211101010*R_214[0]+Q_211101110*R_215[0]; double QR_010002010004=Q_010002010*R_004[0]+-1*Q_010002110*R_005[0]+-1*Q_010102010*R_014[0]+Q_010102110*R_015[0]+Q_010202010*R_024[0]+-1*Q_010202110*R_025[0]+-1*Q_110002010*R_104[0]+Q_110002110*R_105[0]+Q_110102010*R_114[0]+-1*Q_110102110*R_115[0]+-1*Q_110202010*R_124[0]+Q_110202110*R_125[0]; double QR_011000011004=Q_011000011*R_004[0]+-1*Q_011000111*R_005[0]+Q_011000211*R_006[0]+-1*Q_111000011*R_104[0]+Q_111000111*R_105[0]+-1*Q_111000211*R_106[0]+Q_211000011*R_204[0]+-1*Q_211000111*R_205[0]+Q_211000211*R_206[0]; double QR_010001011004=Q_010001011*R_004[0]+-1*Q_010001111*R_005[0]+Q_010001211*R_006[0]+-1*Q_010101011*R_014[0]+Q_010101111*R_015[0]+-1*Q_010101211*R_016[0]+-1*Q_110001011*R_104[0]+Q_110001111*R_105[0]+-1*Q_110001211*R_106[0]+Q_110101011*R_114[0]+-1*Q_110101111*R_115[0]+Q_110101211*R_116[0]; double QR_010000012004=Q_010000012*R_004[0]+-1*Q_010000112*R_005[0]+Q_010000212*R_006[0]+-1*Q_010000312*R_007[0]+-1*Q_110000012*R_104[0]+Q_110000112*R_105[0]+-1*Q_110000212*R_106[0]+Q_110000312*R_107[0]; double QR_002010010004=Q_002010010*R_004[0]+-1*Q_002010110*R_005[0]+-1*Q_002110010*R_014[0]+Q_002110110*R_015[0]+-1*Q_102010010*R_104[0]+Q_102010110*R_105[0]+Q_102110010*R_114[0]+-1*Q_102110110*R_115[0]+Q_202010010*R_204[0]+-1*Q_202010110*R_205[0]+-1*Q_202110010*R_214[0]+Q_202110110*R_215[0]; double QR_001011010004=Q_001011010*R_004[0]+-1*Q_001011110*R_005[0]+-1*Q_001111010*R_014[0]+Q_001111110*R_015[0]+Q_001211010*R_024[0]+-1*Q_001211110*R_025[0]+-1*Q_101011010*R_104[0]+Q_101011110*R_105[0]+Q_101111010*R_114[0]+-1*Q_101111110*R_115[0]+-1*Q_101211010*R_124[0]+Q_101211110*R_125[0]; double QR_000012010004=Q_000012010*R_004[0]+-1*Q_000012110*R_005[0]+-1*Q_000112010*R_014[0]+Q_000112110*R_015[0]+Q_000212010*R_024[0]+-1*Q_000212110*R_025[0]+-1*Q_000312010*R_034[0]+Q_000312110*R_035[0]; double QR_001010011004=Q_001010011*R_004[0]+-1*Q_001010111*R_005[0]+Q_001010211*R_006[0]+-1*Q_001110011*R_014[0]+Q_001110111*R_015[0]+-1*Q_001110211*R_016[0]+-1*Q_101010011*R_104[0]+Q_101010111*R_105[0]+-1*Q_101010211*R_106[0]+Q_101110011*R_114[0]+-1*Q_101110111*R_115[0]+Q_101110211*R_116[0]; double QR_000011011004=Q_000011011*R_004[0]+-1*Q_000011111*R_005[0]+Q_000011211*R_006[0]+-1*Q_000111011*R_014[0]+Q_000111111*R_015[0]+-1*Q_000111211*R_016[0]+Q_000211011*R_024[0]+-1*Q_000211111*R_025[0]+Q_000211211*R_026[0]; double QR_000010012004=Q_000010012*R_004[0]+-1*Q_000010112*R_005[0]+Q_000010212*R_006[0]+-1*Q_000010312*R_007[0]+-1*Q_000110012*R_014[0]+Q_000110112*R_015[0]+-1*Q_000110212*R_016[0]+Q_000110312*R_017[0]; double QR_002000020004=Q_002000020*R_004[0]+-1*Q_002000120*R_005[0]+Q_002000220*R_006[0]+-1*Q_102000020*R_104[0]+Q_102000120*R_105[0]+-1*Q_102000220*R_106[0]+Q_202000020*R_204[0]+-1*Q_202000120*R_205[0]+Q_202000220*R_206[0]; double QR_001001020004=Q_001001020*R_004[0]+-1*Q_001001120*R_005[0]+Q_001001220*R_006[0]+-1*Q_001101020*R_014[0]+Q_001101120*R_015[0]+-1*Q_001101220*R_016[0]+-1*Q_101001020*R_104[0]+Q_101001120*R_105[0]+-1*Q_101001220*R_106[0]+Q_101101020*R_114[0]+-1*Q_101101120*R_115[0]+Q_101101220*R_116[0]; double QR_000002020004=Q_000002020*R_004[0]+-1*Q_000002120*R_005[0]+Q_000002220*R_006[0]+-1*Q_000102020*R_014[0]+Q_000102120*R_015[0]+-1*Q_000102220*R_016[0]+Q_000202020*R_024[0]+-1*Q_000202120*R_025[0]+Q_000202220*R_026[0]; double QR_001000021004=Q_001000021*R_004[0]+-1*Q_001000121*R_005[0]+Q_001000221*R_006[0]+-1*Q_001000321*R_007[0]+-1*Q_101000021*R_104[0]+Q_101000121*R_105[0]+-1*Q_101000221*R_106[0]+Q_101000321*R_107[0]; double QR_000001021004=Q_000001021*R_004[0]+-1*Q_000001121*R_005[0]+Q_000001221*R_006[0]+-1*Q_000001321*R_007[0]+-1*Q_000101021*R_014[0]+Q_000101121*R_015[0]+-1*Q_000101221*R_016[0]+Q_000101321*R_017[0]; double QR_000000022004=Q_000000022*R_004[0]+-1*Q_000000122*R_005[0]+Q_000000222*R_006[0]+-1*Q_000000322*R_007[0]+Q_000000422*R_008[0]; double QR_022000000013=Q_022000000*R_013[0]+-1*Q_122000000*R_113[0]+Q_222000000*R_213[0]+-1*Q_322000000*R_313[0]+Q_422000000*R_413[0]; double QR_021001000013=Q_021001000*R_013[0]+-1*Q_021101000*R_023[0]+-1*Q_121001000*R_113[0]+Q_121101000*R_123[0]+Q_221001000*R_213[0]+-1*Q_221101000*R_223[0]+-1*Q_321001000*R_313[0]+Q_321101000*R_323[0]; double QR_020002000013=Q_020002000*R_013[0]+-1*Q_020102000*R_023[0]+Q_020202000*R_033[0]+-1*Q_120002000*R_113[0]+Q_120102000*R_123[0]+-1*Q_120202000*R_133[0]+Q_220002000*R_213[0]+-1*Q_220102000*R_223[0]+Q_220202000*R_233[0]; double QR_021000001013=Q_021000001*R_013[0]+-1*Q_021000101*R_014[0]+-1*Q_121000001*R_113[0]+Q_121000101*R_114[0]+Q_221000001*R_213[0]+-1*Q_221000101*R_214[0]+-1*Q_321000001*R_313[0]+Q_321000101*R_314[0]; double QR_020001001013=Q_020001001*R_013[0]+-1*Q_020001101*R_014[0]+-1*Q_020101001*R_023[0]+Q_020101101*R_024[0]+-1*Q_120001001*R_113[0]+Q_120001101*R_114[0]+Q_120101001*R_123[0]+-1*Q_120101101*R_124[0]+Q_220001001*R_213[0]+-1*Q_220001101*R_214[0]+-1*Q_220101001*R_223[0]+Q_220101101*R_224[0]; double QR_020000002013=Q_020000002*R_013[0]+-1*Q_020000102*R_014[0]+Q_020000202*R_015[0]+-1*Q_120000002*R_113[0]+Q_120000102*R_114[0]+-1*Q_120000202*R_115[0]+Q_220000002*R_213[0]+-1*Q_220000102*R_214[0]+Q_220000202*R_215[0]; double QR_012010000013=Q_012010000*R_013[0]+-1*Q_012110000*R_023[0]+-1*Q_112010000*R_113[0]+Q_112110000*R_123[0]+Q_212010000*R_213[0]+-1*Q_212110000*R_223[0]+-1*Q_312010000*R_313[0]+Q_312110000*R_323[0]; double QR_011011000013=Q_011011000*R_013[0]+-1*Q_011111000*R_023[0]+Q_011211000*R_033[0]+-1*Q_111011000*R_113[0]+Q_111111000*R_123[0]+-1*Q_111211000*R_133[0]+Q_211011000*R_213[0]+-1*Q_211111000*R_223[0]+Q_211211000*R_233[0]; double QR_010012000013=Q_010012000*R_013[0]+-1*Q_010112000*R_023[0]+Q_010212000*R_033[0]+-1*Q_010312000*R_043[0]+-1*Q_110012000*R_113[0]+Q_110112000*R_123[0]+-1*Q_110212000*R_133[0]+Q_110312000*R_143[0]; double QR_011010001013=Q_011010001*R_013[0]+-1*Q_011010101*R_014[0]+-1*Q_011110001*R_023[0]+Q_011110101*R_024[0]+-1*Q_111010001*R_113[0]+Q_111010101*R_114[0]+Q_111110001*R_123[0]+-1*Q_111110101*R_124[0]+Q_211010001*R_213[0]+-1*Q_211010101*R_214[0]+-1*Q_211110001*R_223[0]+Q_211110101*R_224[0]; double QR_010011001013=Q_010011001*R_013[0]+-1*Q_010011101*R_014[0]+-1*Q_010111001*R_023[0]+Q_010111101*R_024[0]+Q_010211001*R_033[0]+-1*Q_010211101*R_034[0]+-1*Q_110011001*R_113[0]+Q_110011101*R_114[0]+Q_110111001*R_123[0]+-1*Q_110111101*R_124[0]+-1*Q_110211001*R_133[0]+Q_110211101*R_134[0]; double QR_010010002013=Q_010010002*R_013[0]+-1*Q_010010102*R_014[0]+Q_010010202*R_015[0]+-1*Q_010110002*R_023[0]+Q_010110102*R_024[0]+-1*Q_010110202*R_025[0]+-1*Q_110010002*R_113[0]+Q_110010102*R_114[0]+-1*Q_110010202*R_115[0]+Q_110110002*R_123[0]+-1*Q_110110102*R_124[0]+Q_110110202*R_125[0]; double QR_002020000013=Q_002020000*R_013[0]+-1*Q_002120000*R_023[0]+Q_002220000*R_033[0]+-1*Q_102020000*R_113[0]+Q_102120000*R_123[0]+-1*Q_102220000*R_133[0]+Q_202020000*R_213[0]+-1*Q_202120000*R_223[0]+Q_202220000*R_233[0]; double QR_001021000013=Q_001021000*R_013[0]+-1*Q_001121000*R_023[0]+Q_001221000*R_033[0]+-1*Q_001321000*R_043[0]+-1*Q_101021000*R_113[0]+Q_101121000*R_123[0]+-1*Q_101221000*R_133[0]+Q_101321000*R_143[0]; double QR_000022000013=Q_000022000*R_013[0]+-1*Q_000122000*R_023[0]+Q_000222000*R_033[0]+-1*Q_000322000*R_043[0]+Q_000422000*R_053[0]; double QR_001020001013=Q_001020001*R_013[0]+-1*Q_001020101*R_014[0]+-1*Q_001120001*R_023[0]+Q_001120101*R_024[0]+Q_001220001*R_033[0]+-1*Q_001220101*R_034[0]+-1*Q_101020001*R_113[0]+Q_101020101*R_114[0]+Q_101120001*R_123[0]+-1*Q_101120101*R_124[0]+-1*Q_101220001*R_133[0]+Q_101220101*R_134[0]; double QR_000021001013=Q_000021001*R_013[0]+-1*Q_000021101*R_014[0]+-1*Q_000121001*R_023[0]+Q_000121101*R_024[0]+Q_000221001*R_033[0]+-1*Q_000221101*R_034[0]+-1*Q_000321001*R_043[0]+Q_000321101*R_044[0]; double QR_000020002013=Q_000020002*R_013[0]+-1*Q_000020102*R_014[0]+Q_000020202*R_015[0]+-1*Q_000120002*R_023[0]+Q_000120102*R_024[0]+-1*Q_000120202*R_025[0]+Q_000220002*R_033[0]+-1*Q_000220102*R_034[0]+Q_000220202*R_035[0]; double QR_012000010013=Q_012000010*R_013[0]+-1*Q_012000110*R_014[0]+-1*Q_112000010*R_113[0]+Q_112000110*R_114[0]+Q_212000010*R_213[0]+-1*Q_212000110*R_214[0]+-1*Q_312000010*R_313[0]+Q_312000110*R_314[0]; double QR_011001010013=Q_011001010*R_013[0]+-1*Q_011001110*R_014[0]+-1*Q_011101010*R_023[0]+Q_011101110*R_024[0]+-1*Q_111001010*R_113[0]+Q_111001110*R_114[0]+Q_111101010*R_123[0]+-1*Q_111101110*R_124[0]+Q_211001010*R_213[0]+-1*Q_211001110*R_214[0]+-1*Q_211101010*R_223[0]+Q_211101110*R_224[0]; double QR_010002010013=Q_010002010*R_013[0]+-1*Q_010002110*R_014[0]+-1*Q_010102010*R_023[0]+Q_010102110*R_024[0]+Q_010202010*R_033[0]+-1*Q_010202110*R_034[0]+-1*Q_110002010*R_113[0]+Q_110002110*R_114[0]+Q_110102010*R_123[0]+-1*Q_110102110*R_124[0]+-1*Q_110202010*R_133[0]+Q_110202110*R_134[0]; double QR_011000011013=Q_011000011*R_013[0]+-1*Q_011000111*R_014[0]+Q_011000211*R_015[0]+-1*Q_111000011*R_113[0]+Q_111000111*R_114[0]+-1*Q_111000211*R_115[0]+Q_211000011*R_213[0]+-1*Q_211000111*R_214[0]+Q_211000211*R_215[0]; double QR_010001011013=Q_010001011*R_013[0]+-1*Q_010001111*R_014[0]+Q_010001211*R_015[0]+-1*Q_010101011*R_023[0]+Q_010101111*R_024[0]+-1*Q_010101211*R_025[0]+-1*Q_110001011*R_113[0]+Q_110001111*R_114[0]+-1*Q_110001211*R_115[0]+Q_110101011*R_123[0]+-1*Q_110101111*R_124[0]+Q_110101211*R_125[0]; double QR_010000012013=Q_010000012*R_013[0]+-1*Q_010000112*R_014[0]+Q_010000212*R_015[0]+-1*Q_010000312*R_016[0]+-1*Q_110000012*R_113[0]+Q_110000112*R_114[0]+-1*Q_110000212*R_115[0]+Q_110000312*R_116[0]; double QR_002010010013=Q_002010010*R_013[0]+-1*Q_002010110*R_014[0]+-1*Q_002110010*R_023[0]+Q_002110110*R_024[0]+-1*Q_102010010*R_113[0]+Q_102010110*R_114[0]+Q_102110010*R_123[0]+-1*Q_102110110*R_124[0]+Q_202010010*R_213[0]+-1*Q_202010110*R_214[0]+-1*Q_202110010*R_223[0]+Q_202110110*R_224[0]; double QR_001011010013=Q_001011010*R_013[0]+-1*Q_001011110*R_014[0]+-1*Q_001111010*R_023[0]+Q_001111110*R_024[0]+Q_001211010*R_033[0]+-1*Q_001211110*R_034[0]+-1*Q_101011010*R_113[0]+Q_101011110*R_114[0]+Q_101111010*R_123[0]+-1*Q_101111110*R_124[0]+-1*Q_101211010*R_133[0]+Q_101211110*R_134[0]; double QR_000012010013=Q_000012010*R_013[0]+-1*Q_000012110*R_014[0]+-1*Q_000112010*R_023[0]+Q_000112110*R_024[0]+Q_000212010*R_033[0]+-1*Q_000212110*R_034[0]+-1*Q_000312010*R_043[0]+Q_000312110*R_044[0]; double QR_001010011013=Q_001010011*R_013[0]+-1*Q_001010111*R_014[0]+Q_001010211*R_015[0]+-1*Q_001110011*R_023[0]+Q_001110111*R_024[0]+-1*Q_001110211*R_025[0]+-1*Q_101010011*R_113[0]+Q_101010111*R_114[0]+-1*Q_101010211*R_115[0]+Q_101110011*R_123[0]+-1*Q_101110111*R_124[0]+Q_101110211*R_125[0]; double QR_000011011013=Q_000011011*R_013[0]+-1*Q_000011111*R_014[0]+Q_000011211*R_015[0]+-1*Q_000111011*R_023[0]+Q_000111111*R_024[0]+-1*Q_000111211*R_025[0]+Q_000211011*R_033[0]+-1*Q_000211111*R_034[0]+Q_000211211*R_035[0]; double QR_000010012013=Q_000010012*R_013[0]+-1*Q_000010112*R_014[0]+Q_000010212*R_015[0]+-1*Q_000010312*R_016[0]+-1*Q_000110012*R_023[0]+Q_000110112*R_024[0]+-1*Q_000110212*R_025[0]+Q_000110312*R_026[0]; double QR_002000020013=Q_002000020*R_013[0]+-1*Q_002000120*R_014[0]+Q_002000220*R_015[0]+-1*Q_102000020*R_113[0]+Q_102000120*R_114[0]+-1*Q_102000220*R_115[0]+Q_202000020*R_213[0]+-1*Q_202000120*R_214[0]+Q_202000220*R_215[0]; double QR_001001020013=Q_001001020*R_013[0]+-1*Q_001001120*R_014[0]+Q_001001220*R_015[0]+-1*Q_001101020*R_023[0]+Q_001101120*R_024[0]+-1*Q_001101220*R_025[0]+-1*Q_101001020*R_113[0]+Q_101001120*R_114[0]+-1*Q_101001220*R_115[0]+Q_101101020*R_123[0]+-1*Q_101101120*R_124[0]+Q_101101220*R_125[0]; double QR_000002020013=Q_000002020*R_013[0]+-1*Q_000002120*R_014[0]+Q_000002220*R_015[0]+-1*Q_000102020*R_023[0]+Q_000102120*R_024[0]+-1*Q_000102220*R_025[0]+Q_000202020*R_033[0]+-1*Q_000202120*R_034[0]+Q_000202220*R_035[0]; double QR_001000021013=Q_001000021*R_013[0]+-1*Q_001000121*R_014[0]+Q_001000221*R_015[0]+-1*Q_001000321*R_016[0]+-1*Q_101000021*R_113[0]+Q_101000121*R_114[0]+-1*Q_101000221*R_115[0]+Q_101000321*R_116[0]; double QR_000001021013=Q_000001021*R_013[0]+-1*Q_000001121*R_014[0]+Q_000001221*R_015[0]+-1*Q_000001321*R_016[0]+-1*Q_000101021*R_023[0]+Q_000101121*R_024[0]+-1*Q_000101221*R_025[0]+Q_000101321*R_026[0]; double QR_000000022013=Q_000000022*R_013[0]+-1*Q_000000122*R_014[0]+Q_000000222*R_015[0]+-1*Q_000000322*R_016[0]+Q_000000422*R_017[0]; double QR_022000000022=Q_022000000*R_022[0]+-1*Q_122000000*R_122[0]+Q_222000000*R_222[0]+-1*Q_322000000*R_322[0]+Q_422000000*R_422[0]; double QR_021001000022=Q_021001000*R_022[0]+-1*Q_021101000*R_032[0]+-1*Q_121001000*R_122[0]+Q_121101000*R_132[0]+Q_221001000*R_222[0]+-1*Q_221101000*R_232[0]+-1*Q_321001000*R_322[0]+Q_321101000*R_332[0]; double QR_020002000022=Q_020002000*R_022[0]+-1*Q_020102000*R_032[0]+Q_020202000*R_042[0]+-1*Q_120002000*R_122[0]+Q_120102000*R_132[0]+-1*Q_120202000*R_142[0]+Q_220002000*R_222[0]+-1*Q_220102000*R_232[0]+Q_220202000*R_242[0]; double QR_021000001022=Q_021000001*R_022[0]+-1*Q_021000101*R_023[0]+-1*Q_121000001*R_122[0]+Q_121000101*R_123[0]+Q_221000001*R_222[0]+-1*Q_221000101*R_223[0]+-1*Q_321000001*R_322[0]+Q_321000101*R_323[0]; double QR_020001001022=Q_020001001*R_022[0]+-1*Q_020001101*R_023[0]+-1*Q_020101001*R_032[0]+Q_020101101*R_033[0]+-1*Q_120001001*R_122[0]+Q_120001101*R_123[0]+Q_120101001*R_132[0]+-1*Q_120101101*R_133[0]+Q_220001001*R_222[0]+-1*Q_220001101*R_223[0]+-1*Q_220101001*R_232[0]+Q_220101101*R_233[0]; double QR_020000002022=Q_020000002*R_022[0]+-1*Q_020000102*R_023[0]+Q_020000202*R_024[0]+-1*Q_120000002*R_122[0]+Q_120000102*R_123[0]+-1*Q_120000202*R_124[0]+Q_220000002*R_222[0]+-1*Q_220000102*R_223[0]+Q_220000202*R_224[0]; double QR_012010000022=Q_012010000*R_022[0]+-1*Q_012110000*R_032[0]+-1*Q_112010000*R_122[0]+Q_112110000*R_132[0]+Q_212010000*R_222[0]+-1*Q_212110000*R_232[0]+-1*Q_312010000*R_322[0]+Q_312110000*R_332[0]; double QR_011011000022=Q_011011000*R_022[0]+-1*Q_011111000*R_032[0]+Q_011211000*R_042[0]+-1*Q_111011000*R_122[0]+Q_111111000*R_132[0]+-1*Q_111211000*R_142[0]+Q_211011000*R_222[0]+-1*Q_211111000*R_232[0]+Q_211211000*R_242[0]; double QR_010012000022=Q_010012000*R_022[0]+-1*Q_010112000*R_032[0]+Q_010212000*R_042[0]+-1*Q_010312000*R_052[0]+-1*Q_110012000*R_122[0]+Q_110112000*R_132[0]+-1*Q_110212000*R_142[0]+Q_110312000*R_152[0]; double QR_011010001022=Q_011010001*R_022[0]+-1*Q_011010101*R_023[0]+-1*Q_011110001*R_032[0]+Q_011110101*R_033[0]+-1*Q_111010001*R_122[0]+Q_111010101*R_123[0]+Q_111110001*R_132[0]+-1*Q_111110101*R_133[0]+Q_211010001*R_222[0]+-1*Q_211010101*R_223[0]+-1*Q_211110001*R_232[0]+Q_211110101*R_233[0]; double QR_010011001022=Q_010011001*R_022[0]+-1*Q_010011101*R_023[0]+-1*Q_010111001*R_032[0]+Q_010111101*R_033[0]+Q_010211001*R_042[0]+-1*Q_010211101*R_043[0]+-1*Q_110011001*R_122[0]+Q_110011101*R_123[0]+Q_110111001*R_132[0]+-1*Q_110111101*R_133[0]+-1*Q_110211001*R_142[0]+Q_110211101*R_143[0]; double QR_010010002022=Q_010010002*R_022[0]+-1*Q_010010102*R_023[0]+Q_010010202*R_024[0]+-1*Q_010110002*R_032[0]+Q_010110102*R_033[0]+-1*Q_010110202*R_034[0]+-1*Q_110010002*R_122[0]+Q_110010102*R_123[0]+-1*Q_110010202*R_124[0]+Q_110110002*R_132[0]+-1*Q_110110102*R_133[0]+Q_110110202*R_134[0]; double QR_002020000022=Q_002020000*R_022[0]+-1*Q_002120000*R_032[0]+Q_002220000*R_042[0]+-1*Q_102020000*R_122[0]+Q_102120000*R_132[0]+-1*Q_102220000*R_142[0]+Q_202020000*R_222[0]+-1*Q_202120000*R_232[0]+Q_202220000*R_242[0]; double QR_001021000022=Q_001021000*R_022[0]+-1*Q_001121000*R_032[0]+Q_001221000*R_042[0]+-1*Q_001321000*R_052[0]+-1*Q_101021000*R_122[0]+Q_101121000*R_132[0]+-1*Q_101221000*R_142[0]+Q_101321000*R_152[0]; double QR_000022000022=Q_000022000*R_022[0]+-1*Q_000122000*R_032[0]+Q_000222000*R_042[0]+-1*Q_000322000*R_052[0]+Q_000422000*R_062[0]; double QR_001020001022=Q_001020001*R_022[0]+-1*Q_001020101*R_023[0]+-1*Q_001120001*R_032[0]+Q_001120101*R_033[0]+Q_001220001*R_042[0]+-1*Q_001220101*R_043[0]+-1*Q_101020001*R_122[0]+Q_101020101*R_123[0]+Q_101120001*R_132[0]+-1*Q_101120101*R_133[0]+-1*Q_101220001*R_142[0]+Q_101220101*R_143[0]; double QR_000021001022=Q_000021001*R_022[0]+-1*Q_000021101*R_023[0]+-1*Q_000121001*R_032[0]+Q_000121101*R_033[0]+Q_000221001*R_042[0]+-1*Q_000221101*R_043[0]+-1*Q_000321001*R_052[0]+Q_000321101*R_053[0]; double QR_000020002022=Q_000020002*R_022[0]+-1*Q_000020102*R_023[0]+Q_000020202*R_024[0]+-1*Q_000120002*R_032[0]+Q_000120102*R_033[0]+-1*Q_000120202*R_034[0]+Q_000220002*R_042[0]+-1*Q_000220102*R_043[0]+Q_000220202*R_044[0]; double QR_012000010022=Q_012000010*R_022[0]+-1*Q_012000110*R_023[0]+-1*Q_112000010*R_122[0]+Q_112000110*R_123[0]+Q_212000010*R_222[0]+-1*Q_212000110*R_223[0]+-1*Q_312000010*R_322[0]+Q_312000110*R_323[0]; double QR_011001010022=Q_011001010*R_022[0]+-1*Q_011001110*R_023[0]+-1*Q_011101010*R_032[0]+Q_011101110*R_033[0]+-1*Q_111001010*R_122[0]+Q_111001110*R_123[0]+Q_111101010*R_132[0]+-1*Q_111101110*R_133[0]+Q_211001010*R_222[0]+-1*Q_211001110*R_223[0]+-1*Q_211101010*R_232[0]+Q_211101110*R_233[0]; double QR_010002010022=Q_010002010*R_022[0]+-1*Q_010002110*R_023[0]+-1*Q_010102010*R_032[0]+Q_010102110*R_033[0]+Q_010202010*R_042[0]+-1*Q_010202110*R_043[0]+-1*Q_110002010*R_122[0]+Q_110002110*R_123[0]+Q_110102010*R_132[0]+-1*Q_110102110*R_133[0]+-1*Q_110202010*R_142[0]+Q_110202110*R_143[0]; double QR_011000011022=Q_011000011*R_022[0]+-1*Q_011000111*R_023[0]+Q_011000211*R_024[0]+-1*Q_111000011*R_122[0]+Q_111000111*R_123[0]+-1*Q_111000211*R_124[0]+Q_211000011*R_222[0]+-1*Q_211000111*R_223[0]+Q_211000211*R_224[0]; double QR_010001011022=Q_010001011*R_022[0]+-1*Q_010001111*R_023[0]+Q_010001211*R_024[0]+-1*Q_010101011*R_032[0]+Q_010101111*R_033[0]+-1*Q_010101211*R_034[0]+-1*Q_110001011*R_122[0]+Q_110001111*R_123[0]+-1*Q_110001211*R_124[0]+Q_110101011*R_132[0]+-1*Q_110101111*R_133[0]+Q_110101211*R_134[0]; double QR_010000012022=Q_010000012*R_022[0]+-1*Q_010000112*R_023[0]+Q_010000212*R_024[0]+-1*Q_010000312*R_025[0]+-1*Q_110000012*R_122[0]+Q_110000112*R_123[0]+-1*Q_110000212*R_124[0]+Q_110000312*R_125[0]; double QR_002010010022=Q_002010010*R_022[0]+-1*Q_002010110*R_023[0]+-1*Q_002110010*R_032[0]+Q_002110110*R_033[0]+-1*Q_102010010*R_122[0]+Q_102010110*R_123[0]+Q_102110010*R_132[0]+-1*Q_102110110*R_133[0]+Q_202010010*R_222[0]+-1*Q_202010110*R_223[0]+-1*Q_202110010*R_232[0]+Q_202110110*R_233[0]; double QR_001011010022=Q_001011010*R_022[0]+-1*Q_001011110*R_023[0]+-1*Q_001111010*R_032[0]+Q_001111110*R_033[0]+Q_001211010*R_042[0]+-1*Q_001211110*R_043[0]+-1*Q_101011010*R_122[0]+Q_101011110*R_123[0]+Q_101111010*R_132[0]+-1*Q_101111110*R_133[0]+-1*Q_101211010*R_142[0]+Q_101211110*R_143[0]; double QR_000012010022=Q_000012010*R_022[0]+-1*Q_000012110*R_023[0]+-1*Q_000112010*R_032[0]+Q_000112110*R_033[0]+Q_000212010*R_042[0]+-1*Q_000212110*R_043[0]+-1*Q_000312010*R_052[0]+Q_000312110*R_053[0]; double QR_001010011022=Q_001010011*R_022[0]+-1*Q_001010111*R_023[0]+Q_001010211*R_024[0]+-1*Q_001110011*R_032[0]+Q_001110111*R_033[0]+-1*Q_001110211*R_034[0]+-1*Q_101010011*R_122[0]+Q_101010111*R_123[0]+-1*Q_101010211*R_124[0]+Q_101110011*R_132[0]+-1*Q_101110111*R_133[0]+Q_101110211*R_134[0]; double QR_000011011022=Q_000011011*R_022[0]+-1*Q_000011111*R_023[0]+Q_000011211*R_024[0]+-1*Q_000111011*R_032[0]+Q_000111111*R_033[0]+-1*Q_000111211*R_034[0]+Q_000211011*R_042[0]+-1*Q_000211111*R_043[0]+Q_000211211*R_044[0]; double QR_000010012022=Q_000010012*R_022[0]+-1*Q_000010112*R_023[0]+Q_000010212*R_024[0]+-1*Q_000010312*R_025[0]+-1*Q_000110012*R_032[0]+Q_000110112*R_033[0]+-1*Q_000110212*R_034[0]+Q_000110312*R_035[0]; double QR_002000020022=Q_002000020*R_022[0]+-1*Q_002000120*R_023[0]+Q_002000220*R_024[0]+-1*Q_102000020*R_122[0]+Q_102000120*R_123[0]+-1*Q_102000220*R_124[0]+Q_202000020*R_222[0]+-1*Q_202000120*R_223[0]+Q_202000220*R_224[0]; double QR_001001020022=Q_001001020*R_022[0]+-1*Q_001001120*R_023[0]+Q_001001220*R_024[0]+-1*Q_001101020*R_032[0]+Q_001101120*R_033[0]+-1*Q_001101220*R_034[0]+-1*Q_101001020*R_122[0]+Q_101001120*R_123[0]+-1*Q_101001220*R_124[0]+Q_101101020*R_132[0]+-1*Q_101101120*R_133[0]+Q_101101220*R_134[0]; double QR_000002020022=Q_000002020*R_022[0]+-1*Q_000002120*R_023[0]+Q_000002220*R_024[0]+-1*Q_000102020*R_032[0]+Q_000102120*R_033[0]+-1*Q_000102220*R_034[0]+Q_000202020*R_042[0]+-1*Q_000202120*R_043[0]+Q_000202220*R_044[0]; double QR_001000021022=Q_001000021*R_022[0]+-1*Q_001000121*R_023[0]+Q_001000221*R_024[0]+-1*Q_001000321*R_025[0]+-1*Q_101000021*R_122[0]+Q_101000121*R_123[0]+-1*Q_101000221*R_124[0]+Q_101000321*R_125[0]; double QR_000001021022=Q_000001021*R_022[0]+-1*Q_000001121*R_023[0]+Q_000001221*R_024[0]+-1*Q_000001321*R_025[0]+-1*Q_000101021*R_032[0]+Q_000101121*R_033[0]+-1*Q_000101221*R_034[0]+Q_000101321*R_035[0]; double QR_000000022022=Q_000000022*R_022[0]+-1*Q_000000122*R_023[0]+Q_000000222*R_024[0]+-1*Q_000000322*R_025[0]+Q_000000422*R_026[0]; double QR_022000000031=Q_022000000*R_031[0]+-1*Q_122000000*R_131[0]+Q_222000000*R_231[0]+-1*Q_322000000*R_331[0]+Q_422000000*R_431[0]; double QR_021001000031=Q_021001000*R_031[0]+-1*Q_021101000*R_041[0]+-1*Q_121001000*R_131[0]+Q_121101000*R_141[0]+Q_221001000*R_231[0]+-1*Q_221101000*R_241[0]+-1*Q_321001000*R_331[0]+Q_321101000*R_341[0]; double QR_020002000031=Q_020002000*R_031[0]+-1*Q_020102000*R_041[0]+Q_020202000*R_051[0]+-1*Q_120002000*R_131[0]+Q_120102000*R_141[0]+-1*Q_120202000*R_151[0]+Q_220002000*R_231[0]+-1*Q_220102000*R_241[0]+Q_220202000*R_251[0]; double QR_021000001031=Q_021000001*R_031[0]+-1*Q_021000101*R_032[0]+-1*Q_121000001*R_131[0]+Q_121000101*R_132[0]+Q_221000001*R_231[0]+-1*Q_221000101*R_232[0]+-1*Q_321000001*R_331[0]+Q_321000101*R_332[0]; double QR_020001001031=Q_020001001*R_031[0]+-1*Q_020001101*R_032[0]+-1*Q_020101001*R_041[0]+Q_020101101*R_042[0]+-1*Q_120001001*R_131[0]+Q_120001101*R_132[0]+Q_120101001*R_141[0]+-1*Q_120101101*R_142[0]+Q_220001001*R_231[0]+-1*Q_220001101*R_232[0]+-1*Q_220101001*R_241[0]+Q_220101101*R_242[0]; double QR_020000002031=Q_020000002*R_031[0]+-1*Q_020000102*R_032[0]+Q_020000202*R_033[0]+-1*Q_120000002*R_131[0]+Q_120000102*R_132[0]+-1*Q_120000202*R_133[0]+Q_220000002*R_231[0]+-1*Q_220000102*R_232[0]+Q_220000202*R_233[0]; double QR_012010000031=Q_012010000*R_031[0]+-1*Q_012110000*R_041[0]+-1*Q_112010000*R_131[0]+Q_112110000*R_141[0]+Q_212010000*R_231[0]+-1*Q_212110000*R_241[0]+-1*Q_312010000*R_331[0]+Q_312110000*R_341[0]; double QR_011011000031=Q_011011000*R_031[0]+-1*Q_011111000*R_041[0]+Q_011211000*R_051[0]+-1*Q_111011000*R_131[0]+Q_111111000*R_141[0]+-1*Q_111211000*R_151[0]+Q_211011000*R_231[0]+-1*Q_211111000*R_241[0]+Q_211211000*R_251[0]; double QR_010012000031=Q_010012000*R_031[0]+-1*Q_010112000*R_041[0]+Q_010212000*R_051[0]+-1*Q_010312000*R_061[0]+-1*Q_110012000*R_131[0]+Q_110112000*R_141[0]+-1*Q_110212000*R_151[0]+Q_110312000*R_161[0]; double QR_011010001031=Q_011010001*R_031[0]+-1*Q_011010101*R_032[0]+-1*Q_011110001*R_041[0]+Q_011110101*R_042[0]+-1*Q_111010001*R_131[0]+Q_111010101*R_132[0]+Q_111110001*R_141[0]+-1*Q_111110101*R_142[0]+Q_211010001*R_231[0]+-1*Q_211010101*R_232[0]+-1*Q_211110001*R_241[0]+Q_211110101*R_242[0]; double QR_010011001031=Q_010011001*R_031[0]+-1*Q_010011101*R_032[0]+-1*Q_010111001*R_041[0]+Q_010111101*R_042[0]+Q_010211001*R_051[0]+-1*Q_010211101*R_052[0]+-1*Q_110011001*R_131[0]+Q_110011101*R_132[0]+Q_110111001*R_141[0]+-1*Q_110111101*R_142[0]+-1*Q_110211001*R_151[0]+Q_110211101*R_152[0]; double QR_010010002031=Q_010010002*R_031[0]+-1*Q_010010102*R_032[0]+Q_010010202*R_033[0]+-1*Q_010110002*R_041[0]+Q_010110102*R_042[0]+-1*Q_010110202*R_043[0]+-1*Q_110010002*R_131[0]+Q_110010102*R_132[0]+-1*Q_110010202*R_133[0]+Q_110110002*R_141[0]+-1*Q_110110102*R_142[0]+Q_110110202*R_143[0]; double QR_002020000031=Q_002020000*R_031[0]+-1*Q_002120000*R_041[0]+Q_002220000*R_051[0]+-1*Q_102020000*R_131[0]+Q_102120000*R_141[0]+-1*Q_102220000*R_151[0]+Q_202020000*R_231[0]+-1*Q_202120000*R_241[0]+Q_202220000*R_251[0]; double QR_001021000031=Q_001021000*R_031[0]+-1*Q_001121000*R_041[0]+Q_001221000*R_051[0]+-1*Q_001321000*R_061[0]+-1*Q_101021000*R_131[0]+Q_101121000*R_141[0]+-1*Q_101221000*R_151[0]+Q_101321000*R_161[0]; double QR_000022000031=Q_000022000*R_031[0]+-1*Q_000122000*R_041[0]+Q_000222000*R_051[0]+-1*Q_000322000*R_061[0]+Q_000422000*R_071[0]; double QR_001020001031=Q_001020001*R_031[0]+-1*Q_001020101*R_032[0]+-1*Q_001120001*R_041[0]+Q_001120101*R_042[0]+Q_001220001*R_051[0]+-1*Q_001220101*R_052[0]+-1*Q_101020001*R_131[0]+Q_101020101*R_132[0]+Q_101120001*R_141[0]+-1*Q_101120101*R_142[0]+-1*Q_101220001*R_151[0]+Q_101220101*R_152[0]; double QR_000021001031=Q_000021001*R_031[0]+-1*Q_000021101*R_032[0]+-1*Q_000121001*R_041[0]+Q_000121101*R_042[0]+Q_000221001*R_051[0]+-1*Q_000221101*R_052[0]+-1*Q_000321001*R_061[0]+Q_000321101*R_062[0]; double QR_000020002031=Q_000020002*R_031[0]+-1*Q_000020102*R_032[0]+Q_000020202*R_033[0]+-1*Q_000120002*R_041[0]+Q_000120102*R_042[0]+-1*Q_000120202*R_043[0]+Q_000220002*R_051[0]+-1*Q_000220102*R_052[0]+Q_000220202*R_053[0]; double QR_012000010031=Q_012000010*R_031[0]+-1*Q_012000110*R_032[0]+-1*Q_112000010*R_131[0]+Q_112000110*R_132[0]+Q_212000010*R_231[0]+-1*Q_212000110*R_232[0]+-1*Q_312000010*R_331[0]+Q_312000110*R_332[0]; double QR_011001010031=Q_011001010*R_031[0]+-1*Q_011001110*R_032[0]+-1*Q_011101010*R_041[0]+Q_011101110*R_042[0]+-1*Q_111001010*R_131[0]+Q_111001110*R_132[0]+Q_111101010*R_141[0]+-1*Q_111101110*R_142[0]+Q_211001010*R_231[0]+-1*Q_211001110*R_232[0]+-1*Q_211101010*R_241[0]+Q_211101110*R_242[0]; double QR_010002010031=Q_010002010*R_031[0]+-1*Q_010002110*R_032[0]+-1*Q_010102010*R_041[0]+Q_010102110*R_042[0]+Q_010202010*R_051[0]+-1*Q_010202110*R_052[0]+-1*Q_110002010*R_131[0]+Q_110002110*R_132[0]+Q_110102010*R_141[0]+-1*Q_110102110*R_142[0]+-1*Q_110202010*R_151[0]+Q_110202110*R_152[0]; double QR_011000011031=Q_011000011*R_031[0]+-1*Q_011000111*R_032[0]+Q_011000211*R_033[0]+-1*Q_111000011*R_131[0]+Q_111000111*R_132[0]+-1*Q_111000211*R_133[0]+Q_211000011*R_231[0]+-1*Q_211000111*R_232[0]+Q_211000211*R_233[0]; double QR_010001011031=Q_010001011*R_031[0]+-1*Q_010001111*R_032[0]+Q_010001211*R_033[0]+-1*Q_010101011*R_041[0]+Q_010101111*R_042[0]+-1*Q_010101211*R_043[0]+-1*Q_110001011*R_131[0]+Q_110001111*R_132[0]+-1*Q_110001211*R_133[0]+Q_110101011*R_141[0]+-1*Q_110101111*R_142[0]+Q_110101211*R_143[0]; double QR_010000012031=Q_010000012*R_031[0]+-1*Q_010000112*R_032[0]+Q_010000212*R_033[0]+-1*Q_010000312*R_034[0]+-1*Q_110000012*R_131[0]+Q_110000112*R_132[0]+-1*Q_110000212*R_133[0]+Q_110000312*R_134[0]; double QR_002010010031=Q_002010010*R_031[0]+-1*Q_002010110*R_032[0]+-1*Q_002110010*R_041[0]+Q_002110110*R_042[0]+-1*Q_102010010*R_131[0]+Q_102010110*R_132[0]+Q_102110010*R_141[0]+-1*Q_102110110*R_142[0]+Q_202010010*R_231[0]+-1*Q_202010110*R_232[0]+-1*Q_202110010*R_241[0]+Q_202110110*R_242[0]; double QR_001011010031=Q_001011010*R_031[0]+-1*Q_001011110*R_032[0]+-1*Q_001111010*R_041[0]+Q_001111110*R_042[0]+Q_001211010*R_051[0]+-1*Q_001211110*R_052[0]+-1*Q_101011010*R_131[0]+Q_101011110*R_132[0]+Q_101111010*R_141[0]+-1*Q_101111110*R_142[0]+-1*Q_101211010*R_151[0]+Q_101211110*R_152[0]; double QR_000012010031=Q_000012010*R_031[0]+-1*Q_000012110*R_032[0]+-1*Q_000112010*R_041[0]+Q_000112110*R_042[0]+Q_000212010*R_051[0]+-1*Q_000212110*R_052[0]+-1*Q_000312010*R_061[0]+Q_000312110*R_062[0]; double QR_001010011031=Q_001010011*R_031[0]+-1*Q_001010111*R_032[0]+Q_001010211*R_033[0]+-1*Q_001110011*R_041[0]+Q_001110111*R_042[0]+-1*Q_001110211*R_043[0]+-1*Q_101010011*R_131[0]+Q_101010111*R_132[0]+-1*Q_101010211*R_133[0]+Q_101110011*R_141[0]+-1*Q_101110111*R_142[0]+Q_101110211*R_143[0]; double QR_000011011031=Q_000011011*R_031[0]+-1*Q_000011111*R_032[0]+Q_000011211*R_033[0]+-1*Q_000111011*R_041[0]+Q_000111111*R_042[0]+-1*Q_000111211*R_043[0]+Q_000211011*R_051[0]+-1*Q_000211111*R_052[0]+Q_000211211*R_053[0]; double QR_000010012031=Q_000010012*R_031[0]+-1*Q_000010112*R_032[0]+Q_000010212*R_033[0]+-1*Q_000010312*R_034[0]+-1*Q_000110012*R_041[0]+Q_000110112*R_042[0]+-1*Q_000110212*R_043[0]+Q_000110312*R_044[0]; double QR_002000020031=Q_002000020*R_031[0]+-1*Q_002000120*R_032[0]+Q_002000220*R_033[0]+-1*Q_102000020*R_131[0]+Q_102000120*R_132[0]+-1*Q_102000220*R_133[0]+Q_202000020*R_231[0]+-1*Q_202000120*R_232[0]+Q_202000220*R_233[0]; double QR_001001020031=Q_001001020*R_031[0]+-1*Q_001001120*R_032[0]+Q_001001220*R_033[0]+-1*Q_001101020*R_041[0]+Q_001101120*R_042[0]+-1*Q_001101220*R_043[0]+-1*Q_101001020*R_131[0]+Q_101001120*R_132[0]+-1*Q_101001220*R_133[0]+Q_101101020*R_141[0]+-1*Q_101101120*R_142[0]+Q_101101220*R_143[0]; double QR_000002020031=Q_000002020*R_031[0]+-1*Q_000002120*R_032[0]+Q_000002220*R_033[0]+-1*Q_000102020*R_041[0]+Q_000102120*R_042[0]+-1*Q_000102220*R_043[0]+Q_000202020*R_051[0]+-1*Q_000202120*R_052[0]+Q_000202220*R_053[0]; double QR_001000021031=Q_001000021*R_031[0]+-1*Q_001000121*R_032[0]+Q_001000221*R_033[0]+-1*Q_001000321*R_034[0]+-1*Q_101000021*R_131[0]+Q_101000121*R_132[0]+-1*Q_101000221*R_133[0]+Q_101000321*R_134[0]; double QR_000001021031=Q_000001021*R_031[0]+-1*Q_000001121*R_032[0]+Q_000001221*R_033[0]+-1*Q_000001321*R_034[0]+-1*Q_000101021*R_041[0]+Q_000101121*R_042[0]+-1*Q_000101221*R_043[0]+Q_000101321*R_044[0]; double QR_000000022031=Q_000000022*R_031[0]+-1*Q_000000122*R_032[0]+Q_000000222*R_033[0]+-1*Q_000000322*R_034[0]+Q_000000422*R_035[0]; double QR_022000000040=Q_022000000*R_040[0]+-1*Q_122000000*R_140[0]+Q_222000000*R_240[0]+-1*Q_322000000*R_340[0]+Q_422000000*R_440[0]; double QR_021001000040=Q_021001000*R_040[0]+-1*Q_021101000*R_050[0]+-1*Q_121001000*R_140[0]+Q_121101000*R_150[0]+Q_221001000*R_240[0]+-1*Q_221101000*R_250[0]+-1*Q_321001000*R_340[0]+Q_321101000*R_350[0]; double QR_020002000040=Q_020002000*R_040[0]+-1*Q_020102000*R_050[0]+Q_020202000*R_060[0]+-1*Q_120002000*R_140[0]+Q_120102000*R_150[0]+-1*Q_120202000*R_160[0]+Q_220002000*R_240[0]+-1*Q_220102000*R_250[0]+Q_220202000*R_260[0]; double QR_021000001040=Q_021000001*R_040[0]+-1*Q_021000101*R_041[0]+-1*Q_121000001*R_140[0]+Q_121000101*R_141[0]+Q_221000001*R_240[0]+-1*Q_221000101*R_241[0]+-1*Q_321000001*R_340[0]+Q_321000101*R_341[0]; double QR_020001001040=Q_020001001*R_040[0]+-1*Q_020001101*R_041[0]+-1*Q_020101001*R_050[0]+Q_020101101*R_051[0]+-1*Q_120001001*R_140[0]+Q_120001101*R_141[0]+Q_120101001*R_150[0]+-1*Q_120101101*R_151[0]+Q_220001001*R_240[0]+-1*Q_220001101*R_241[0]+-1*Q_220101001*R_250[0]+Q_220101101*R_251[0]; double QR_020000002040=Q_020000002*R_040[0]+-1*Q_020000102*R_041[0]+Q_020000202*R_042[0]+-1*Q_120000002*R_140[0]+Q_120000102*R_141[0]+-1*Q_120000202*R_142[0]+Q_220000002*R_240[0]+-1*Q_220000102*R_241[0]+Q_220000202*R_242[0]; double QR_012010000040=Q_012010000*R_040[0]+-1*Q_012110000*R_050[0]+-1*Q_112010000*R_140[0]+Q_112110000*R_150[0]+Q_212010000*R_240[0]+-1*Q_212110000*R_250[0]+-1*Q_312010000*R_340[0]+Q_312110000*R_350[0]; double QR_011011000040=Q_011011000*R_040[0]+-1*Q_011111000*R_050[0]+Q_011211000*R_060[0]+-1*Q_111011000*R_140[0]+Q_111111000*R_150[0]+-1*Q_111211000*R_160[0]+Q_211011000*R_240[0]+-1*Q_211111000*R_250[0]+Q_211211000*R_260[0]; double QR_010012000040=Q_010012000*R_040[0]+-1*Q_010112000*R_050[0]+Q_010212000*R_060[0]+-1*Q_010312000*R_070[0]+-1*Q_110012000*R_140[0]+Q_110112000*R_150[0]+-1*Q_110212000*R_160[0]+Q_110312000*R_170[0]; double QR_011010001040=Q_011010001*R_040[0]+-1*Q_011010101*R_041[0]+-1*Q_011110001*R_050[0]+Q_011110101*R_051[0]+-1*Q_111010001*R_140[0]+Q_111010101*R_141[0]+Q_111110001*R_150[0]+-1*Q_111110101*R_151[0]+Q_211010001*R_240[0]+-1*Q_211010101*R_241[0]+-1*Q_211110001*R_250[0]+Q_211110101*R_251[0]; double QR_010011001040=Q_010011001*R_040[0]+-1*Q_010011101*R_041[0]+-1*Q_010111001*R_050[0]+Q_010111101*R_051[0]+Q_010211001*R_060[0]+-1*Q_010211101*R_061[0]+-1*Q_110011001*R_140[0]+Q_110011101*R_141[0]+Q_110111001*R_150[0]+-1*Q_110111101*R_151[0]+-1*Q_110211001*R_160[0]+Q_110211101*R_161[0]; double QR_010010002040=Q_010010002*R_040[0]+-1*Q_010010102*R_041[0]+Q_010010202*R_042[0]+-1*Q_010110002*R_050[0]+Q_010110102*R_051[0]+-1*Q_010110202*R_052[0]+-1*Q_110010002*R_140[0]+Q_110010102*R_141[0]+-1*Q_110010202*R_142[0]+Q_110110002*R_150[0]+-1*Q_110110102*R_151[0]+Q_110110202*R_152[0]; double QR_002020000040=Q_002020000*R_040[0]+-1*Q_002120000*R_050[0]+Q_002220000*R_060[0]+-1*Q_102020000*R_140[0]+Q_102120000*R_150[0]+-1*Q_102220000*R_160[0]+Q_202020000*R_240[0]+-1*Q_202120000*R_250[0]+Q_202220000*R_260[0]; double QR_001021000040=Q_001021000*R_040[0]+-1*Q_001121000*R_050[0]+Q_001221000*R_060[0]+-1*Q_001321000*R_070[0]+-1*Q_101021000*R_140[0]+Q_101121000*R_150[0]+-1*Q_101221000*R_160[0]+Q_101321000*R_170[0]; double QR_000022000040=Q_000022000*R_040[0]+-1*Q_000122000*R_050[0]+Q_000222000*R_060[0]+-1*Q_000322000*R_070[0]+Q_000422000*R_080[0]; double QR_001020001040=Q_001020001*R_040[0]+-1*Q_001020101*R_041[0]+-1*Q_001120001*R_050[0]+Q_001120101*R_051[0]+Q_001220001*R_060[0]+-1*Q_001220101*R_061[0]+-1*Q_101020001*R_140[0]+Q_101020101*R_141[0]+Q_101120001*R_150[0]+-1*Q_101120101*R_151[0]+-1*Q_101220001*R_160[0]+Q_101220101*R_161[0]; double QR_000021001040=Q_000021001*R_040[0]+-1*Q_000021101*R_041[0]+-1*Q_000121001*R_050[0]+Q_000121101*R_051[0]+Q_000221001*R_060[0]+-1*Q_000221101*R_061[0]+-1*Q_000321001*R_070[0]+Q_000321101*R_071[0]; double QR_000020002040=Q_000020002*R_040[0]+-1*Q_000020102*R_041[0]+Q_000020202*R_042[0]+-1*Q_000120002*R_050[0]+Q_000120102*R_051[0]+-1*Q_000120202*R_052[0]+Q_000220002*R_060[0]+-1*Q_000220102*R_061[0]+Q_000220202*R_062[0]; double QR_012000010040=Q_012000010*R_040[0]+-1*Q_012000110*R_041[0]+-1*Q_112000010*R_140[0]+Q_112000110*R_141[0]+Q_212000010*R_240[0]+-1*Q_212000110*R_241[0]+-1*Q_312000010*R_340[0]+Q_312000110*R_341[0]; double QR_011001010040=Q_011001010*R_040[0]+-1*Q_011001110*R_041[0]+-1*Q_011101010*R_050[0]+Q_011101110*R_051[0]+-1*Q_111001010*R_140[0]+Q_111001110*R_141[0]+Q_111101010*R_150[0]+-1*Q_111101110*R_151[0]+Q_211001010*R_240[0]+-1*Q_211001110*R_241[0]+-1*Q_211101010*R_250[0]+Q_211101110*R_251[0]; double QR_010002010040=Q_010002010*R_040[0]+-1*Q_010002110*R_041[0]+-1*Q_010102010*R_050[0]+Q_010102110*R_051[0]+Q_010202010*R_060[0]+-1*Q_010202110*R_061[0]+-1*Q_110002010*R_140[0]+Q_110002110*R_141[0]+Q_110102010*R_150[0]+-1*Q_110102110*R_151[0]+-1*Q_110202010*R_160[0]+Q_110202110*R_161[0]; double QR_011000011040=Q_011000011*R_040[0]+-1*Q_011000111*R_041[0]+Q_011000211*R_042[0]+-1*Q_111000011*R_140[0]+Q_111000111*R_141[0]+-1*Q_111000211*R_142[0]+Q_211000011*R_240[0]+-1*Q_211000111*R_241[0]+Q_211000211*R_242[0]; double QR_010001011040=Q_010001011*R_040[0]+-1*Q_010001111*R_041[0]+Q_010001211*R_042[0]+-1*Q_010101011*R_050[0]+Q_010101111*R_051[0]+-1*Q_010101211*R_052[0]+-1*Q_110001011*R_140[0]+Q_110001111*R_141[0]+-1*Q_110001211*R_142[0]+Q_110101011*R_150[0]+-1*Q_110101111*R_151[0]+Q_110101211*R_152[0]; double QR_010000012040=Q_010000012*R_040[0]+-1*Q_010000112*R_041[0]+Q_010000212*R_042[0]+-1*Q_010000312*R_043[0]+-1*Q_110000012*R_140[0]+Q_110000112*R_141[0]+-1*Q_110000212*R_142[0]+Q_110000312*R_143[0]; double QR_002010010040=Q_002010010*R_040[0]+-1*Q_002010110*R_041[0]+-1*Q_002110010*R_050[0]+Q_002110110*R_051[0]+-1*Q_102010010*R_140[0]+Q_102010110*R_141[0]+Q_102110010*R_150[0]+-1*Q_102110110*R_151[0]+Q_202010010*R_240[0]+-1*Q_202010110*R_241[0]+-1*Q_202110010*R_250[0]+Q_202110110*R_251[0]; double QR_001011010040=Q_001011010*R_040[0]+-1*Q_001011110*R_041[0]+-1*Q_001111010*R_050[0]+Q_001111110*R_051[0]+Q_001211010*R_060[0]+-1*Q_001211110*R_061[0]+-1*Q_101011010*R_140[0]+Q_101011110*R_141[0]+Q_101111010*R_150[0]+-1*Q_101111110*R_151[0]+-1*Q_101211010*R_160[0]+Q_101211110*R_161[0]; double QR_000012010040=Q_000012010*R_040[0]+-1*Q_000012110*R_041[0]+-1*Q_000112010*R_050[0]+Q_000112110*R_051[0]+Q_000212010*R_060[0]+-1*Q_000212110*R_061[0]+-1*Q_000312010*R_070[0]+Q_000312110*R_071[0]; double QR_001010011040=Q_001010011*R_040[0]+-1*Q_001010111*R_041[0]+Q_001010211*R_042[0]+-1*Q_001110011*R_050[0]+Q_001110111*R_051[0]+-1*Q_001110211*R_052[0]+-1*Q_101010011*R_140[0]+Q_101010111*R_141[0]+-1*Q_101010211*R_142[0]+Q_101110011*R_150[0]+-1*Q_101110111*R_151[0]+Q_101110211*R_152[0]; double QR_000011011040=Q_000011011*R_040[0]+-1*Q_000011111*R_041[0]+Q_000011211*R_042[0]+-1*Q_000111011*R_050[0]+Q_000111111*R_051[0]+-1*Q_000111211*R_052[0]+Q_000211011*R_060[0]+-1*Q_000211111*R_061[0]+Q_000211211*R_062[0]; double QR_000010012040=Q_000010012*R_040[0]+-1*Q_000010112*R_041[0]+Q_000010212*R_042[0]+-1*Q_000010312*R_043[0]+-1*Q_000110012*R_050[0]+Q_000110112*R_051[0]+-1*Q_000110212*R_052[0]+Q_000110312*R_053[0]; double QR_002000020040=Q_002000020*R_040[0]+-1*Q_002000120*R_041[0]+Q_002000220*R_042[0]+-1*Q_102000020*R_140[0]+Q_102000120*R_141[0]+-1*Q_102000220*R_142[0]+Q_202000020*R_240[0]+-1*Q_202000120*R_241[0]+Q_202000220*R_242[0]; double QR_001001020040=Q_001001020*R_040[0]+-1*Q_001001120*R_041[0]+Q_001001220*R_042[0]+-1*Q_001101020*R_050[0]+Q_001101120*R_051[0]+-1*Q_001101220*R_052[0]+-1*Q_101001020*R_140[0]+Q_101001120*R_141[0]+-1*Q_101001220*R_142[0]+Q_101101020*R_150[0]+-1*Q_101101120*R_151[0]+Q_101101220*R_152[0]; double QR_000002020040=Q_000002020*R_040[0]+-1*Q_000002120*R_041[0]+Q_000002220*R_042[0]+-1*Q_000102020*R_050[0]+Q_000102120*R_051[0]+-1*Q_000102220*R_052[0]+Q_000202020*R_060[0]+-1*Q_000202120*R_061[0]+Q_000202220*R_062[0]; double QR_001000021040=Q_001000021*R_040[0]+-1*Q_001000121*R_041[0]+Q_001000221*R_042[0]+-1*Q_001000321*R_043[0]+-1*Q_101000021*R_140[0]+Q_101000121*R_141[0]+-1*Q_101000221*R_142[0]+Q_101000321*R_143[0]; double QR_000001021040=Q_000001021*R_040[0]+-1*Q_000001121*R_041[0]+Q_000001221*R_042[0]+-1*Q_000001321*R_043[0]+-1*Q_000101021*R_050[0]+Q_000101121*R_051[0]+-1*Q_000101221*R_052[0]+Q_000101321*R_053[0]; double QR_000000022040=Q_000000022*R_040[0]+-1*Q_000000122*R_041[0]+Q_000000222*R_042[0]+-1*Q_000000322*R_043[0]+Q_000000422*R_044[0]; double QR_022000000103=Q_022000000*R_103[0]+-1*Q_122000000*R_203[0]+Q_222000000*R_303[0]+-1*Q_322000000*R_403[0]+Q_422000000*R_503[0]; double QR_021001000103=Q_021001000*R_103[0]+-1*Q_021101000*R_113[0]+-1*Q_121001000*R_203[0]+Q_121101000*R_213[0]+Q_221001000*R_303[0]+-1*Q_221101000*R_313[0]+-1*Q_321001000*R_403[0]+Q_321101000*R_413[0]; double QR_020002000103=Q_020002000*R_103[0]+-1*Q_020102000*R_113[0]+Q_020202000*R_123[0]+-1*Q_120002000*R_203[0]+Q_120102000*R_213[0]+-1*Q_120202000*R_223[0]+Q_220002000*R_303[0]+-1*Q_220102000*R_313[0]+Q_220202000*R_323[0]; double QR_021000001103=Q_021000001*R_103[0]+-1*Q_021000101*R_104[0]+-1*Q_121000001*R_203[0]+Q_121000101*R_204[0]+Q_221000001*R_303[0]+-1*Q_221000101*R_304[0]+-1*Q_321000001*R_403[0]+Q_321000101*R_404[0]; double QR_020001001103=Q_020001001*R_103[0]+-1*Q_020001101*R_104[0]+-1*Q_020101001*R_113[0]+Q_020101101*R_114[0]+-1*Q_120001001*R_203[0]+Q_120001101*R_204[0]+Q_120101001*R_213[0]+-1*Q_120101101*R_214[0]+Q_220001001*R_303[0]+-1*Q_220001101*R_304[0]+-1*Q_220101001*R_313[0]+Q_220101101*R_314[0]; double QR_020000002103=Q_020000002*R_103[0]+-1*Q_020000102*R_104[0]+Q_020000202*R_105[0]+-1*Q_120000002*R_203[0]+Q_120000102*R_204[0]+-1*Q_120000202*R_205[0]+Q_220000002*R_303[0]+-1*Q_220000102*R_304[0]+Q_220000202*R_305[0]; double QR_012010000103=Q_012010000*R_103[0]+-1*Q_012110000*R_113[0]+-1*Q_112010000*R_203[0]+Q_112110000*R_213[0]+Q_212010000*R_303[0]+-1*Q_212110000*R_313[0]+-1*Q_312010000*R_403[0]+Q_312110000*R_413[0]; double QR_011011000103=Q_011011000*R_103[0]+-1*Q_011111000*R_113[0]+Q_011211000*R_123[0]+-1*Q_111011000*R_203[0]+Q_111111000*R_213[0]+-1*Q_111211000*R_223[0]+Q_211011000*R_303[0]+-1*Q_211111000*R_313[0]+Q_211211000*R_323[0]; double QR_010012000103=Q_010012000*R_103[0]+-1*Q_010112000*R_113[0]+Q_010212000*R_123[0]+-1*Q_010312000*R_133[0]+-1*Q_110012000*R_203[0]+Q_110112000*R_213[0]+-1*Q_110212000*R_223[0]+Q_110312000*R_233[0]; double QR_011010001103=Q_011010001*R_103[0]+-1*Q_011010101*R_104[0]+-1*Q_011110001*R_113[0]+Q_011110101*R_114[0]+-1*Q_111010001*R_203[0]+Q_111010101*R_204[0]+Q_111110001*R_213[0]+-1*Q_111110101*R_214[0]+Q_211010001*R_303[0]+-1*Q_211010101*R_304[0]+-1*Q_211110001*R_313[0]+Q_211110101*R_314[0]; double QR_010011001103=Q_010011001*R_103[0]+-1*Q_010011101*R_104[0]+-1*Q_010111001*R_113[0]+Q_010111101*R_114[0]+Q_010211001*R_123[0]+-1*Q_010211101*R_124[0]+-1*Q_110011001*R_203[0]+Q_110011101*R_204[0]+Q_110111001*R_213[0]+-1*Q_110111101*R_214[0]+-1*Q_110211001*R_223[0]+Q_110211101*R_224[0]; double QR_010010002103=Q_010010002*R_103[0]+-1*Q_010010102*R_104[0]+Q_010010202*R_105[0]+-1*Q_010110002*R_113[0]+Q_010110102*R_114[0]+-1*Q_010110202*R_115[0]+-1*Q_110010002*R_203[0]+Q_110010102*R_204[0]+-1*Q_110010202*R_205[0]+Q_110110002*R_213[0]+-1*Q_110110102*R_214[0]+Q_110110202*R_215[0]; double QR_002020000103=Q_002020000*R_103[0]+-1*Q_002120000*R_113[0]+Q_002220000*R_123[0]+-1*Q_102020000*R_203[0]+Q_102120000*R_213[0]+-1*Q_102220000*R_223[0]+Q_202020000*R_303[0]+-1*Q_202120000*R_313[0]+Q_202220000*R_323[0]; double QR_001021000103=Q_001021000*R_103[0]+-1*Q_001121000*R_113[0]+Q_001221000*R_123[0]+-1*Q_001321000*R_133[0]+-1*Q_101021000*R_203[0]+Q_101121000*R_213[0]+-1*Q_101221000*R_223[0]+Q_101321000*R_233[0]; double QR_000022000103=Q_000022000*R_103[0]+-1*Q_000122000*R_113[0]+Q_000222000*R_123[0]+-1*Q_000322000*R_133[0]+Q_000422000*R_143[0]; double QR_001020001103=Q_001020001*R_103[0]+-1*Q_001020101*R_104[0]+-1*Q_001120001*R_113[0]+Q_001120101*R_114[0]+Q_001220001*R_123[0]+-1*Q_001220101*R_124[0]+-1*Q_101020001*R_203[0]+Q_101020101*R_204[0]+Q_101120001*R_213[0]+-1*Q_101120101*R_214[0]+-1*Q_101220001*R_223[0]+Q_101220101*R_224[0]; double QR_000021001103=Q_000021001*R_103[0]+-1*Q_000021101*R_104[0]+-1*Q_000121001*R_113[0]+Q_000121101*R_114[0]+Q_000221001*R_123[0]+-1*Q_000221101*R_124[0]+-1*Q_000321001*R_133[0]+Q_000321101*R_134[0]; double QR_000020002103=Q_000020002*R_103[0]+-1*Q_000020102*R_104[0]+Q_000020202*R_105[0]+-1*Q_000120002*R_113[0]+Q_000120102*R_114[0]+-1*Q_000120202*R_115[0]+Q_000220002*R_123[0]+-1*Q_000220102*R_124[0]+Q_000220202*R_125[0]; double QR_012000010103=Q_012000010*R_103[0]+-1*Q_012000110*R_104[0]+-1*Q_112000010*R_203[0]+Q_112000110*R_204[0]+Q_212000010*R_303[0]+-1*Q_212000110*R_304[0]+-1*Q_312000010*R_403[0]+Q_312000110*R_404[0]; double QR_011001010103=Q_011001010*R_103[0]+-1*Q_011001110*R_104[0]+-1*Q_011101010*R_113[0]+Q_011101110*R_114[0]+-1*Q_111001010*R_203[0]+Q_111001110*R_204[0]+Q_111101010*R_213[0]+-1*Q_111101110*R_214[0]+Q_211001010*R_303[0]+-1*Q_211001110*R_304[0]+-1*Q_211101010*R_313[0]+Q_211101110*R_314[0]; double QR_010002010103=Q_010002010*R_103[0]+-1*Q_010002110*R_104[0]+-1*Q_010102010*R_113[0]+Q_010102110*R_114[0]+Q_010202010*R_123[0]+-1*Q_010202110*R_124[0]+-1*Q_110002010*R_203[0]+Q_110002110*R_204[0]+Q_110102010*R_213[0]+-1*Q_110102110*R_214[0]+-1*Q_110202010*R_223[0]+Q_110202110*R_224[0]; double QR_011000011103=Q_011000011*R_103[0]+-1*Q_011000111*R_104[0]+Q_011000211*R_105[0]+-1*Q_111000011*R_203[0]+Q_111000111*R_204[0]+-1*Q_111000211*R_205[0]+Q_211000011*R_303[0]+-1*Q_211000111*R_304[0]+Q_211000211*R_305[0]; double QR_010001011103=Q_010001011*R_103[0]+-1*Q_010001111*R_104[0]+Q_010001211*R_105[0]+-1*Q_010101011*R_113[0]+Q_010101111*R_114[0]+-1*Q_010101211*R_115[0]+-1*Q_110001011*R_203[0]+Q_110001111*R_204[0]+-1*Q_110001211*R_205[0]+Q_110101011*R_213[0]+-1*Q_110101111*R_214[0]+Q_110101211*R_215[0]; double QR_010000012103=Q_010000012*R_103[0]+-1*Q_010000112*R_104[0]+Q_010000212*R_105[0]+-1*Q_010000312*R_106[0]+-1*Q_110000012*R_203[0]+Q_110000112*R_204[0]+-1*Q_110000212*R_205[0]+Q_110000312*R_206[0]; double QR_002010010103=Q_002010010*R_103[0]+-1*Q_002010110*R_104[0]+-1*Q_002110010*R_113[0]+Q_002110110*R_114[0]+-1*Q_102010010*R_203[0]+Q_102010110*R_204[0]+Q_102110010*R_213[0]+-1*Q_102110110*R_214[0]+Q_202010010*R_303[0]+-1*Q_202010110*R_304[0]+-1*Q_202110010*R_313[0]+Q_202110110*R_314[0]; double QR_001011010103=Q_001011010*R_103[0]+-1*Q_001011110*R_104[0]+-1*Q_001111010*R_113[0]+Q_001111110*R_114[0]+Q_001211010*R_123[0]+-1*Q_001211110*R_124[0]+-1*Q_101011010*R_203[0]+Q_101011110*R_204[0]+Q_101111010*R_213[0]+-1*Q_101111110*R_214[0]+-1*Q_101211010*R_223[0]+Q_101211110*R_224[0]; double QR_000012010103=Q_000012010*R_103[0]+-1*Q_000012110*R_104[0]+-1*Q_000112010*R_113[0]+Q_000112110*R_114[0]+Q_000212010*R_123[0]+-1*Q_000212110*R_124[0]+-1*Q_000312010*R_133[0]+Q_000312110*R_134[0]; double QR_001010011103=Q_001010011*R_103[0]+-1*Q_001010111*R_104[0]+Q_001010211*R_105[0]+-1*Q_001110011*R_113[0]+Q_001110111*R_114[0]+-1*Q_001110211*R_115[0]+-1*Q_101010011*R_203[0]+Q_101010111*R_204[0]+-1*Q_101010211*R_205[0]+Q_101110011*R_213[0]+-1*Q_101110111*R_214[0]+Q_101110211*R_215[0]; double QR_000011011103=Q_000011011*R_103[0]+-1*Q_000011111*R_104[0]+Q_000011211*R_105[0]+-1*Q_000111011*R_113[0]+Q_000111111*R_114[0]+-1*Q_000111211*R_115[0]+Q_000211011*R_123[0]+-1*Q_000211111*R_124[0]+Q_000211211*R_125[0]; double QR_000010012103=Q_000010012*R_103[0]+-1*Q_000010112*R_104[0]+Q_000010212*R_105[0]+-1*Q_000010312*R_106[0]+-1*Q_000110012*R_113[0]+Q_000110112*R_114[0]+-1*Q_000110212*R_115[0]+Q_000110312*R_116[0]; double QR_002000020103=Q_002000020*R_103[0]+-1*Q_002000120*R_104[0]+Q_002000220*R_105[0]+-1*Q_102000020*R_203[0]+Q_102000120*R_204[0]+-1*Q_102000220*R_205[0]+Q_202000020*R_303[0]+-1*Q_202000120*R_304[0]+Q_202000220*R_305[0]; double QR_001001020103=Q_001001020*R_103[0]+-1*Q_001001120*R_104[0]+Q_001001220*R_105[0]+-1*Q_001101020*R_113[0]+Q_001101120*R_114[0]+-1*Q_001101220*R_115[0]+-1*Q_101001020*R_203[0]+Q_101001120*R_204[0]+-1*Q_101001220*R_205[0]+Q_101101020*R_213[0]+-1*Q_101101120*R_214[0]+Q_101101220*R_215[0]; double QR_000002020103=Q_000002020*R_103[0]+-1*Q_000002120*R_104[0]+Q_000002220*R_105[0]+-1*Q_000102020*R_113[0]+Q_000102120*R_114[0]+-1*Q_000102220*R_115[0]+Q_000202020*R_123[0]+-1*Q_000202120*R_124[0]+Q_000202220*R_125[0]; double QR_001000021103=Q_001000021*R_103[0]+-1*Q_001000121*R_104[0]+Q_001000221*R_105[0]+-1*Q_001000321*R_106[0]+-1*Q_101000021*R_203[0]+Q_101000121*R_204[0]+-1*Q_101000221*R_205[0]+Q_101000321*R_206[0]; double QR_000001021103=Q_000001021*R_103[0]+-1*Q_000001121*R_104[0]+Q_000001221*R_105[0]+-1*Q_000001321*R_106[0]+-1*Q_000101021*R_113[0]+Q_000101121*R_114[0]+-1*Q_000101221*R_115[0]+Q_000101321*R_116[0]; double QR_000000022103=Q_000000022*R_103[0]+-1*Q_000000122*R_104[0]+Q_000000222*R_105[0]+-1*Q_000000322*R_106[0]+Q_000000422*R_107[0]; double QR_022000000112=Q_022000000*R_112[0]+-1*Q_122000000*R_212[0]+Q_222000000*R_312[0]+-1*Q_322000000*R_412[0]+Q_422000000*R_512[0]; double QR_021001000112=Q_021001000*R_112[0]+-1*Q_021101000*R_122[0]+-1*Q_121001000*R_212[0]+Q_121101000*R_222[0]+Q_221001000*R_312[0]+-1*Q_221101000*R_322[0]+-1*Q_321001000*R_412[0]+Q_321101000*R_422[0]; double QR_020002000112=Q_020002000*R_112[0]+-1*Q_020102000*R_122[0]+Q_020202000*R_132[0]+-1*Q_120002000*R_212[0]+Q_120102000*R_222[0]+-1*Q_120202000*R_232[0]+Q_220002000*R_312[0]+-1*Q_220102000*R_322[0]+Q_220202000*R_332[0]; double QR_021000001112=Q_021000001*R_112[0]+-1*Q_021000101*R_113[0]+-1*Q_121000001*R_212[0]+Q_121000101*R_213[0]+Q_221000001*R_312[0]+-1*Q_221000101*R_313[0]+-1*Q_321000001*R_412[0]+Q_321000101*R_413[0]; double QR_020001001112=Q_020001001*R_112[0]+-1*Q_020001101*R_113[0]+-1*Q_020101001*R_122[0]+Q_020101101*R_123[0]+-1*Q_120001001*R_212[0]+Q_120001101*R_213[0]+Q_120101001*R_222[0]+-1*Q_120101101*R_223[0]+Q_220001001*R_312[0]+-1*Q_220001101*R_313[0]+-1*Q_220101001*R_322[0]+Q_220101101*R_323[0]; double QR_020000002112=Q_020000002*R_112[0]+-1*Q_020000102*R_113[0]+Q_020000202*R_114[0]+-1*Q_120000002*R_212[0]+Q_120000102*R_213[0]+-1*Q_120000202*R_214[0]+Q_220000002*R_312[0]+-1*Q_220000102*R_313[0]+Q_220000202*R_314[0]; double QR_012010000112=Q_012010000*R_112[0]+-1*Q_012110000*R_122[0]+-1*Q_112010000*R_212[0]+Q_112110000*R_222[0]+Q_212010000*R_312[0]+-1*Q_212110000*R_322[0]+-1*Q_312010000*R_412[0]+Q_312110000*R_422[0]; double QR_011011000112=Q_011011000*R_112[0]+-1*Q_011111000*R_122[0]+Q_011211000*R_132[0]+-1*Q_111011000*R_212[0]+Q_111111000*R_222[0]+-1*Q_111211000*R_232[0]+Q_211011000*R_312[0]+-1*Q_211111000*R_322[0]+Q_211211000*R_332[0]; double QR_010012000112=Q_010012000*R_112[0]+-1*Q_010112000*R_122[0]+Q_010212000*R_132[0]+-1*Q_010312000*R_142[0]+-1*Q_110012000*R_212[0]+Q_110112000*R_222[0]+-1*Q_110212000*R_232[0]+Q_110312000*R_242[0]; double QR_011010001112=Q_011010001*R_112[0]+-1*Q_011010101*R_113[0]+-1*Q_011110001*R_122[0]+Q_011110101*R_123[0]+-1*Q_111010001*R_212[0]+Q_111010101*R_213[0]+Q_111110001*R_222[0]+-1*Q_111110101*R_223[0]+Q_211010001*R_312[0]+-1*Q_211010101*R_313[0]+-1*Q_211110001*R_322[0]+Q_211110101*R_323[0]; double QR_010011001112=Q_010011001*R_112[0]+-1*Q_010011101*R_113[0]+-1*Q_010111001*R_122[0]+Q_010111101*R_123[0]+Q_010211001*R_132[0]+-1*Q_010211101*R_133[0]+-1*Q_110011001*R_212[0]+Q_110011101*R_213[0]+Q_110111001*R_222[0]+-1*Q_110111101*R_223[0]+-1*Q_110211001*R_232[0]+Q_110211101*R_233[0]; double QR_010010002112=Q_010010002*R_112[0]+-1*Q_010010102*R_113[0]+Q_010010202*R_114[0]+-1*Q_010110002*R_122[0]+Q_010110102*R_123[0]+-1*Q_010110202*R_124[0]+-1*Q_110010002*R_212[0]+Q_110010102*R_213[0]+-1*Q_110010202*R_214[0]+Q_110110002*R_222[0]+-1*Q_110110102*R_223[0]+Q_110110202*R_224[0]; double QR_002020000112=Q_002020000*R_112[0]+-1*Q_002120000*R_122[0]+Q_002220000*R_132[0]+-1*Q_102020000*R_212[0]+Q_102120000*R_222[0]+-1*Q_102220000*R_232[0]+Q_202020000*R_312[0]+-1*Q_202120000*R_322[0]+Q_202220000*R_332[0]; double QR_001021000112=Q_001021000*R_112[0]+-1*Q_001121000*R_122[0]+Q_001221000*R_132[0]+-1*Q_001321000*R_142[0]+-1*Q_101021000*R_212[0]+Q_101121000*R_222[0]+-1*Q_101221000*R_232[0]+Q_101321000*R_242[0]; double QR_000022000112=Q_000022000*R_112[0]+-1*Q_000122000*R_122[0]+Q_000222000*R_132[0]+-1*Q_000322000*R_142[0]+Q_000422000*R_152[0]; double QR_001020001112=Q_001020001*R_112[0]+-1*Q_001020101*R_113[0]+-1*Q_001120001*R_122[0]+Q_001120101*R_123[0]+Q_001220001*R_132[0]+-1*Q_001220101*R_133[0]+-1*Q_101020001*R_212[0]+Q_101020101*R_213[0]+Q_101120001*R_222[0]+-1*Q_101120101*R_223[0]+-1*Q_101220001*R_232[0]+Q_101220101*R_233[0]; double QR_000021001112=Q_000021001*R_112[0]+-1*Q_000021101*R_113[0]+-1*Q_000121001*R_122[0]+Q_000121101*R_123[0]+Q_000221001*R_132[0]+-1*Q_000221101*R_133[0]+-1*Q_000321001*R_142[0]+Q_000321101*R_143[0]; double QR_000020002112=Q_000020002*R_112[0]+-1*Q_000020102*R_113[0]+Q_000020202*R_114[0]+-1*Q_000120002*R_122[0]+Q_000120102*R_123[0]+-1*Q_000120202*R_124[0]+Q_000220002*R_132[0]+-1*Q_000220102*R_133[0]+Q_000220202*R_134[0]; double QR_012000010112=Q_012000010*R_112[0]+-1*Q_012000110*R_113[0]+-1*Q_112000010*R_212[0]+Q_112000110*R_213[0]+Q_212000010*R_312[0]+-1*Q_212000110*R_313[0]+-1*Q_312000010*R_412[0]+Q_312000110*R_413[0]; double QR_011001010112=Q_011001010*R_112[0]+-1*Q_011001110*R_113[0]+-1*Q_011101010*R_122[0]+Q_011101110*R_123[0]+-1*Q_111001010*R_212[0]+Q_111001110*R_213[0]+Q_111101010*R_222[0]+-1*Q_111101110*R_223[0]+Q_211001010*R_312[0]+-1*Q_211001110*R_313[0]+-1*Q_211101010*R_322[0]+Q_211101110*R_323[0]; double QR_010002010112=Q_010002010*R_112[0]+-1*Q_010002110*R_113[0]+-1*Q_010102010*R_122[0]+Q_010102110*R_123[0]+Q_010202010*R_132[0]+-1*Q_010202110*R_133[0]+-1*Q_110002010*R_212[0]+Q_110002110*R_213[0]+Q_110102010*R_222[0]+-1*Q_110102110*R_223[0]+-1*Q_110202010*R_232[0]+Q_110202110*R_233[0]; double QR_011000011112=Q_011000011*R_112[0]+-1*Q_011000111*R_113[0]+Q_011000211*R_114[0]+-1*Q_111000011*R_212[0]+Q_111000111*R_213[0]+-1*Q_111000211*R_214[0]+Q_211000011*R_312[0]+-1*Q_211000111*R_313[0]+Q_211000211*R_314[0]; double QR_010001011112=Q_010001011*R_112[0]+-1*Q_010001111*R_113[0]+Q_010001211*R_114[0]+-1*Q_010101011*R_122[0]+Q_010101111*R_123[0]+-1*Q_010101211*R_124[0]+-1*Q_110001011*R_212[0]+Q_110001111*R_213[0]+-1*Q_110001211*R_214[0]+Q_110101011*R_222[0]+-1*Q_110101111*R_223[0]+Q_110101211*R_224[0]; double QR_010000012112=Q_010000012*R_112[0]+-1*Q_010000112*R_113[0]+Q_010000212*R_114[0]+-1*Q_010000312*R_115[0]+-1*Q_110000012*R_212[0]+Q_110000112*R_213[0]+-1*Q_110000212*R_214[0]+Q_110000312*R_215[0]; double QR_002010010112=Q_002010010*R_112[0]+-1*Q_002010110*R_113[0]+-1*Q_002110010*R_122[0]+Q_002110110*R_123[0]+-1*Q_102010010*R_212[0]+Q_102010110*R_213[0]+Q_102110010*R_222[0]+-1*Q_102110110*R_223[0]+Q_202010010*R_312[0]+-1*Q_202010110*R_313[0]+-1*Q_202110010*R_322[0]+Q_202110110*R_323[0]; double QR_001011010112=Q_001011010*R_112[0]+-1*Q_001011110*R_113[0]+-1*Q_001111010*R_122[0]+Q_001111110*R_123[0]+Q_001211010*R_132[0]+-1*Q_001211110*R_133[0]+-1*Q_101011010*R_212[0]+Q_101011110*R_213[0]+Q_101111010*R_222[0]+-1*Q_101111110*R_223[0]+-1*Q_101211010*R_232[0]+Q_101211110*R_233[0]; double QR_000012010112=Q_000012010*R_112[0]+-1*Q_000012110*R_113[0]+-1*Q_000112010*R_122[0]+Q_000112110*R_123[0]+Q_000212010*R_132[0]+-1*Q_000212110*R_133[0]+-1*Q_000312010*R_142[0]+Q_000312110*R_143[0]; double QR_001010011112=Q_001010011*R_112[0]+-1*Q_001010111*R_113[0]+Q_001010211*R_114[0]+-1*Q_001110011*R_122[0]+Q_001110111*R_123[0]+-1*Q_001110211*R_124[0]+-1*Q_101010011*R_212[0]+Q_101010111*R_213[0]+-1*Q_101010211*R_214[0]+Q_101110011*R_222[0]+-1*Q_101110111*R_223[0]+Q_101110211*R_224[0]; double QR_000011011112=Q_000011011*R_112[0]+-1*Q_000011111*R_113[0]+Q_000011211*R_114[0]+-1*Q_000111011*R_122[0]+Q_000111111*R_123[0]+-1*Q_000111211*R_124[0]+Q_000211011*R_132[0]+-1*Q_000211111*R_133[0]+Q_000211211*R_134[0]; double QR_000010012112=Q_000010012*R_112[0]+-1*Q_000010112*R_113[0]+Q_000010212*R_114[0]+-1*Q_000010312*R_115[0]+-1*Q_000110012*R_122[0]+Q_000110112*R_123[0]+-1*Q_000110212*R_124[0]+Q_000110312*R_125[0]; double QR_002000020112=Q_002000020*R_112[0]+-1*Q_002000120*R_113[0]+Q_002000220*R_114[0]+-1*Q_102000020*R_212[0]+Q_102000120*R_213[0]+-1*Q_102000220*R_214[0]+Q_202000020*R_312[0]+-1*Q_202000120*R_313[0]+Q_202000220*R_314[0]; double QR_001001020112=Q_001001020*R_112[0]+-1*Q_001001120*R_113[0]+Q_001001220*R_114[0]+-1*Q_001101020*R_122[0]+Q_001101120*R_123[0]+-1*Q_001101220*R_124[0]+-1*Q_101001020*R_212[0]+Q_101001120*R_213[0]+-1*Q_101001220*R_214[0]+Q_101101020*R_222[0]+-1*Q_101101120*R_223[0]+Q_101101220*R_224[0]; double QR_000002020112=Q_000002020*R_112[0]+-1*Q_000002120*R_113[0]+Q_000002220*R_114[0]+-1*Q_000102020*R_122[0]+Q_000102120*R_123[0]+-1*Q_000102220*R_124[0]+Q_000202020*R_132[0]+-1*Q_000202120*R_133[0]+Q_000202220*R_134[0]; double QR_001000021112=Q_001000021*R_112[0]+-1*Q_001000121*R_113[0]+Q_001000221*R_114[0]+-1*Q_001000321*R_115[0]+-1*Q_101000021*R_212[0]+Q_101000121*R_213[0]+-1*Q_101000221*R_214[0]+Q_101000321*R_215[0]; double QR_000001021112=Q_000001021*R_112[0]+-1*Q_000001121*R_113[0]+Q_000001221*R_114[0]+-1*Q_000001321*R_115[0]+-1*Q_000101021*R_122[0]+Q_000101121*R_123[0]+-1*Q_000101221*R_124[0]+Q_000101321*R_125[0]; double QR_000000022112=Q_000000022*R_112[0]+-1*Q_000000122*R_113[0]+Q_000000222*R_114[0]+-1*Q_000000322*R_115[0]+Q_000000422*R_116[0]; double QR_022000000121=Q_022000000*R_121[0]+-1*Q_122000000*R_221[0]+Q_222000000*R_321[0]+-1*Q_322000000*R_421[0]+Q_422000000*R_521[0]; double QR_021001000121=Q_021001000*R_121[0]+-1*Q_021101000*R_131[0]+-1*Q_121001000*R_221[0]+Q_121101000*R_231[0]+Q_221001000*R_321[0]+-1*Q_221101000*R_331[0]+-1*Q_321001000*R_421[0]+Q_321101000*R_431[0]; double QR_020002000121=Q_020002000*R_121[0]+-1*Q_020102000*R_131[0]+Q_020202000*R_141[0]+-1*Q_120002000*R_221[0]+Q_120102000*R_231[0]+-1*Q_120202000*R_241[0]+Q_220002000*R_321[0]+-1*Q_220102000*R_331[0]+Q_220202000*R_341[0]; double QR_021000001121=Q_021000001*R_121[0]+-1*Q_021000101*R_122[0]+-1*Q_121000001*R_221[0]+Q_121000101*R_222[0]+Q_221000001*R_321[0]+-1*Q_221000101*R_322[0]+-1*Q_321000001*R_421[0]+Q_321000101*R_422[0]; double QR_020001001121=Q_020001001*R_121[0]+-1*Q_020001101*R_122[0]+-1*Q_020101001*R_131[0]+Q_020101101*R_132[0]+-1*Q_120001001*R_221[0]+Q_120001101*R_222[0]+Q_120101001*R_231[0]+-1*Q_120101101*R_232[0]+Q_220001001*R_321[0]+-1*Q_220001101*R_322[0]+-1*Q_220101001*R_331[0]+Q_220101101*R_332[0]; double QR_020000002121=Q_020000002*R_121[0]+-1*Q_020000102*R_122[0]+Q_020000202*R_123[0]+-1*Q_120000002*R_221[0]+Q_120000102*R_222[0]+-1*Q_120000202*R_223[0]+Q_220000002*R_321[0]+-1*Q_220000102*R_322[0]+Q_220000202*R_323[0]; double QR_012010000121=Q_012010000*R_121[0]+-1*Q_012110000*R_131[0]+-1*Q_112010000*R_221[0]+Q_112110000*R_231[0]+Q_212010000*R_321[0]+-1*Q_212110000*R_331[0]+-1*Q_312010000*R_421[0]+Q_312110000*R_431[0]; double QR_011011000121=Q_011011000*R_121[0]+-1*Q_011111000*R_131[0]+Q_011211000*R_141[0]+-1*Q_111011000*R_221[0]+Q_111111000*R_231[0]+-1*Q_111211000*R_241[0]+Q_211011000*R_321[0]+-1*Q_211111000*R_331[0]+Q_211211000*R_341[0]; double QR_010012000121=Q_010012000*R_121[0]+-1*Q_010112000*R_131[0]+Q_010212000*R_141[0]+-1*Q_010312000*R_151[0]+-1*Q_110012000*R_221[0]+Q_110112000*R_231[0]+-1*Q_110212000*R_241[0]+Q_110312000*R_251[0]; double QR_011010001121=Q_011010001*R_121[0]+-1*Q_011010101*R_122[0]+-1*Q_011110001*R_131[0]+Q_011110101*R_132[0]+-1*Q_111010001*R_221[0]+Q_111010101*R_222[0]+Q_111110001*R_231[0]+-1*Q_111110101*R_232[0]+Q_211010001*R_321[0]+-1*Q_211010101*R_322[0]+-1*Q_211110001*R_331[0]+Q_211110101*R_332[0]; double QR_010011001121=Q_010011001*R_121[0]+-1*Q_010011101*R_122[0]+-1*Q_010111001*R_131[0]+Q_010111101*R_132[0]+Q_010211001*R_141[0]+-1*Q_010211101*R_142[0]+-1*Q_110011001*R_221[0]+Q_110011101*R_222[0]+Q_110111001*R_231[0]+-1*Q_110111101*R_232[0]+-1*Q_110211001*R_241[0]+Q_110211101*R_242[0]; double QR_010010002121=Q_010010002*R_121[0]+-1*Q_010010102*R_122[0]+Q_010010202*R_123[0]+-1*Q_010110002*R_131[0]+Q_010110102*R_132[0]+-1*Q_010110202*R_133[0]+-1*Q_110010002*R_221[0]+Q_110010102*R_222[0]+-1*Q_110010202*R_223[0]+Q_110110002*R_231[0]+-1*Q_110110102*R_232[0]+Q_110110202*R_233[0]; double QR_002020000121=Q_002020000*R_121[0]+-1*Q_002120000*R_131[0]+Q_002220000*R_141[0]+-1*Q_102020000*R_221[0]+Q_102120000*R_231[0]+-1*Q_102220000*R_241[0]+Q_202020000*R_321[0]+-1*Q_202120000*R_331[0]+Q_202220000*R_341[0]; double QR_001021000121=Q_001021000*R_121[0]+-1*Q_001121000*R_131[0]+Q_001221000*R_141[0]+-1*Q_001321000*R_151[0]+-1*Q_101021000*R_221[0]+Q_101121000*R_231[0]+-1*Q_101221000*R_241[0]+Q_101321000*R_251[0]; double QR_000022000121=Q_000022000*R_121[0]+-1*Q_000122000*R_131[0]+Q_000222000*R_141[0]+-1*Q_000322000*R_151[0]+Q_000422000*R_161[0]; double QR_001020001121=Q_001020001*R_121[0]+-1*Q_001020101*R_122[0]+-1*Q_001120001*R_131[0]+Q_001120101*R_132[0]+Q_001220001*R_141[0]+-1*Q_001220101*R_142[0]+-1*Q_101020001*R_221[0]+Q_101020101*R_222[0]+Q_101120001*R_231[0]+-1*Q_101120101*R_232[0]+-1*Q_101220001*R_241[0]+Q_101220101*R_242[0]; double QR_000021001121=Q_000021001*R_121[0]+-1*Q_000021101*R_122[0]+-1*Q_000121001*R_131[0]+Q_000121101*R_132[0]+Q_000221001*R_141[0]+-1*Q_000221101*R_142[0]+-1*Q_000321001*R_151[0]+Q_000321101*R_152[0]; double QR_000020002121=Q_000020002*R_121[0]+-1*Q_000020102*R_122[0]+Q_000020202*R_123[0]+-1*Q_000120002*R_131[0]+Q_000120102*R_132[0]+-1*Q_000120202*R_133[0]+Q_000220002*R_141[0]+-1*Q_000220102*R_142[0]+Q_000220202*R_143[0]; double QR_012000010121=Q_012000010*R_121[0]+-1*Q_012000110*R_122[0]+-1*Q_112000010*R_221[0]+Q_112000110*R_222[0]+Q_212000010*R_321[0]+-1*Q_212000110*R_322[0]+-1*Q_312000010*R_421[0]+Q_312000110*R_422[0]; double QR_011001010121=Q_011001010*R_121[0]+-1*Q_011001110*R_122[0]+-1*Q_011101010*R_131[0]+Q_011101110*R_132[0]+-1*Q_111001010*R_221[0]+Q_111001110*R_222[0]+Q_111101010*R_231[0]+-1*Q_111101110*R_232[0]+Q_211001010*R_321[0]+-1*Q_211001110*R_322[0]+-1*Q_211101010*R_331[0]+Q_211101110*R_332[0]; double QR_010002010121=Q_010002010*R_121[0]+-1*Q_010002110*R_122[0]+-1*Q_010102010*R_131[0]+Q_010102110*R_132[0]+Q_010202010*R_141[0]+-1*Q_010202110*R_142[0]+-1*Q_110002010*R_221[0]+Q_110002110*R_222[0]+Q_110102010*R_231[0]+-1*Q_110102110*R_232[0]+-1*Q_110202010*R_241[0]+Q_110202110*R_242[0]; double QR_011000011121=Q_011000011*R_121[0]+-1*Q_011000111*R_122[0]+Q_011000211*R_123[0]+-1*Q_111000011*R_221[0]+Q_111000111*R_222[0]+-1*Q_111000211*R_223[0]+Q_211000011*R_321[0]+-1*Q_211000111*R_322[0]+Q_211000211*R_323[0]; double QR_010001011121=Q_010001011*R_121[0]+-1*Q_010001111*R_122[0]+Q_010001211*R_123[0]+-1*Q_010101011*R_131[0]+Q_010101111*R_132[0]+-1*Q_010101211*R_133[0]+-1*Q_110001011*R_221[0]+Q_110001111*R_222[0]+-1*Q_110001211*R_223[0]+Q_110101011*R_231[0]+-1*Q_110101111*R_232[0]+Q_110101211*R_233[0]; double QR_010000012121=Q_010000012*R_121[0]+-1*Q_010000112*R_122[0]+Q_010000212*R_123[0]+-1*Q_010000312*R_124[0]+-1*Q_110000012*R_221[0]+Q_110000112*R_222[0]+-1*Q_110000212*R_223[0]+Q_110000312*R_224[0]; double QR_002010010121=Q_002010010*R_121[0]+-1*Q_002010110*R_122[0]+-1*Q_002110010*R_131[0]+Q_002110110*R_132[0]+-1*Q_102010010*R_221[0]+Q_102010110*R_222[0]+Q_102110010*R_231[0]+-1*Q_102110110*R_232[0]+Q_202010010*R_321[0]+-1*Q_202010110*R_322[0]+-1*Q_202110010*R_331[0]+Q_202110110*R_332[0]; double QR_001011010121=Q_001011010*R_121[0]+-1*Q_001011110*R_122[0]+-1*Q_001111010*R_131[0]+Q_001111110*R_132[0]+Q_001211010*R_141[0]+-1*Q_001211110*R_142[0]+-1*Q_101011010*R_221[0]+Q_101011110*R_222[0]+Q_101111010*R_231[0]+-1*Q_101111110*R_232[0]+-1*Q_101211010*R_241[0]+Q_101211110*R_242[0]; double QR_000012010121=Q_000012010*R_121[0]+-1*Q_000012110*R_122[0]+-1*Q_000112010*R_131[0]+Q_000112110*R_132[0]+Q_000212010*R_141[0]+-1*Q_000212110*R_142[0]+-1*Q_000312010*R_151[0]+Q_000312110*R_152[0]; double QR_001010011121=Q_001010011*R_121[0]+-1*Q_001010111*R_122[0]+Q_001010211*R_123[0]+-1*Q_001110011*R_131[0]+Q_001110111*R_132[0]+-1*Q_001110211*R_133[0]+-1*Q_101010011*R_221[0]+Q_101010111*R_222[0]+-1*Q_101010211*R_223[0]+Q_101110011*R_231[0]+-1*Q_101110111*R_232[0]+Q_101110211*R_233[0]; double QR_000011011121=Q_000011011*R_121[0]+-1*Q_000011111*R_122[0]+Q_000011211*R_123[0]+-1*Q_000111011*R_131[0]+Q_000111111*R_132[0]+-1*Q_000111211*R_133[0]+Q_000211011*R_141[0]+-1*Q_000211111*R_142[0]+Q_000211211*R_143[0]; double QR_000010012121=Q_000010012*R_121[0]+-1*Q_000010112*R_122[0]+Q_000010212*R_123[0]+-1*Q_000010312*R_124[0]+-1*Q_000110012*R_131[0]+Q_000110112*R_132[0]+-1*Q_000110212*R_133[0]+Q_000110312*R_134[0]; double QR_002000020121=Q_002000020*R_121[0]+-1*Q_002000120*R_122[0]+Q_002000220*R_123[0]+-1*Q_102000020*R_221[0]+Q_102000120*R_222[0]+-1*Q_102000220*R_223[0]+Q_202000020*R_321[0]+-1*Q_202000120*R_322[0]+Q_202000220*R_323[0]; double QR_001001020121=Q_001001020*R_121[0]+-1*Q_001001120*R_122[0]+Q_001001220*R_123[0]+-1*Q_001101020*R_131[0]+Q_001101120*R_132[0]+-1*Q_001101220*R_133[0]+-1*Q_101001020*R_221[0]+Q_101001120*R_222[0]+-1*Q_101001220*R_223[0]+Q_101101020*R_231[0]+-1*Q_101101120*R_232[0]+Q_101101220*R_233[0]; double QR_000002020121=Q_000002020*R_121[0]+-1*Q_000002120*R_122[0]+Q_000002220*R_123[0]+-1*Q_000102020*R_131[0]+Q_000102120*R_132[0]+-1*Q_000102220*R_133[0]+Q_000202020*R_141[0]+-1*Q_000202120*R_142[0]+Q_000202220*R_143[0]; double QR_001000021121=Q_001000021*R_121[0]+-1*Q_001000121*R_122[0]+Q_001000221*R_123[0]+-1*Q_001000321*R_124[0]+-1*Q_101000021*R_221[0]+Q_101000121*R_222[0]+-1*Q_101000221*R_223[0]+Q_101000321*R_224[0]; double QR_000001021121=Q_000001021*R_121[0]+-1*Q_000001121*R_122[0]+Q_000001221*R_123[0]+-1*Q_000001321*R_124[0]+-1*Q_000101021*R_131[0]+Q_000101121*R_132[0]+-1*Q_000101221*R_133[0]+Q_000101321*R_134[0]; double QR_000000022121=Q_000000022*R_121[0]+-1*Q_000000122*R_122[0]+Q_000000222*R_123[0]+-1*Q_000000322*R_124[0]+Q_000000422*R_125[0]; double QR_022000000130=Q_022000000*R_130[0]+-1*Q_122000000*R_230[0]+Q_222000000*R_330[0]+-1*Q_322000000*R_430[0]+Q_422000000*R_530[0]; double QR_021001000130=Q_021001000*R_130[0]+-1*Q_021101000*R_140[0]+-1*Q_121001000*R_230[0]+Q_121101000*R_240[0]+Q_221001000*R_330[0]+-1*Q_221101000*R_340[0]+-1*Q_321001000*R_430[0]+Q_321101000*R_440[0]; double QR_020002000130=Q_020002000*R_130[0]+-1*Q_020102000*R_140[0]+Q_020202000*R_150[0]+-1*Q_120002000*R_230[0]+Q_120102000*R_240[0]+-1*Q_120202000*R_250[0]+Q_220002000*R_330[0]+-1*Q_220102000*R_340[0]+Q_220202000*R_350[0]; double QR_021000001130=Q_021000001*R_130[0]+-1*Q_021000101*R_131[0]+-1*Q_121000001*R_230[0]+Q_121000101*R_231[0]+Q_221000001*R_330[0]+-1*Q_221000101*R_331[0]+-1*Q_321000001*R_430[0]+Q_321000101*R_431[0]; double QR_020001001130=Q_020001001*R_130[0]+-1*Q_020001101*R_131[0]+-1*Q_020101001*R_140[0]+Q_020101101*R_141[0]+-1*Q_120001001*R_230[0]+Q_120001101*R_231[0]+Q_120101001*R_240[0]+-1*Q_120101101*R_241[0]+Q_220001001*R_330[0]+-1*Q_220001101*R_331[0]+-1*Q_220101001*R_340[0]+Q_220101101*R_341[0]; double QR_020000002130=Q_020000002*R_130[0]+-1*Q_020000102*R_131[0]+Q_020000202*R_132[0]+-1*Q_120000002*R_230[0]+Q_120000102*R_231[0]+-1*Q_120000202*R_232[0]+Q_220000002*R_330[0]+-1*Q_220000102*R_331[0]+Q_220000202*R_332[0]; double QR_012010000130=Q_012010000*R_130[0]+-1*Q_012110000*R_140[0]+-1*Q_112010000*R_230[0]+Q_112110000*R_240[0]+Q_212010000*R_330[0]+-1*Q_212110000*R_340[0]+-1*Q_312010000*R_430[0]+Q_312110000*R_440[0]; double QR_011011000130=Q_011011000*R_130[0]+-1*Q_011111000*R_140[0]+Q_011211000*R_150[0]+-1*Q_111011000*R_230[0]+Q_111111000*R_240[0]+-1*Q_111211000*R_250[0]+Q_211011000*R_330[0]+-1*Q_211111000*R_340[0]+Q_211211000*R_350[0]; double QR_010012000130=Q_010012000*R_130[0]+-1*Q_010112000*R_140[0]+Q_010212000*R_150[0]+-1*Q_010312000*R_160[0]+-1*Q_110012000*R_230[0]+Q_110112000*R_240[0]+-1*Q_110212000*R_250[0]+Q_110312000*R_260[0]; double QR_011010001130=Q_011010001*R_130[0]+-1*Q_011010101*R_131[0]+-1*Q_011110001*R_140[0]+Q_011110101*R_141[0]+-1*Q_111010001*R_230[0]+Q_111010101*R_231[0]+Q_111110001*R_240[0]+-1*Q_111110101*R_241[0]+Q_211010001*R_330[0]+-1*Q_211010101*R_331[0]+-1*Q_211110001*R_340[0]+Q_211110101*R_341[0]; double QR_010011001130=Q_010011001*R_130[0]+-1*Q_010011101*R_131[0]+-1*Q_010111001*R_140[0]+Q_010111101*R_141[0]+Q_010211001*R_150[0]+-1*Q_010211101*R_151[0]+-1*Q_110011001*R_230[0]+Q_110011101*R_231[0]+Q_110111001*R_240[0]+-1*Q_110111101*R_241[0]+-1*Q_110211001*R_250[0]+Q_110211101*R_251[0]; double QR_010010002130=Q_010010002*R_130[0]+-1*Q_010010102*R_131[0]+Q_010010202*R_132[0]+-1*Q_010110002*R_140[0]+Q_010110102*R_141[0]+-1*Q_010110202*R_142[0]+-1*Q_110010002*R_230[0]+Q_110010102*R_231[0]+-1*Q_110010202*R_232[0]+Q_110110002*R_240[0]+-1*Q_110110102*R_241[0]+Q_110110202*R_242[0]; double QR_002020000130=Q_002020000*R_130[0]+-1*Q_002120000*R_140[0]+Q_002220000*R_150[0]+-1*Q_102020000*R_230[0]+Q_102120000*R_240[0]+-1*Q_102220000*R_250[0]+Q_202020000*R_330[0]+-1*Q_202120000*R_340[0]+Q_202220000*R_350[0]; double QR_001021000130=Q_001021000*R_130[0]+-1*Q_001121000*R_140[0]+Q_001221000*R_150[0]+-1*Q_001321000*R_160[0]+-1*Q_101021000*R_230[0]+Q_101121000*R_240[0]+-1*Q_101221000*R_250[0]+Q_101321000*R_260[0]; double QR_000022000130=Q_000022000*R_130[0]+-1*Q_000122000*R_140[0]+Q_000222000*R_150[0]+-1*Q_000322000*R_160[0]+Q_000422000*R_170[0]; double QR_001020001130=Q_001020001*R_130[0]+-1*Q_001020101*R_131[0]+-1*Q_001120001*R_140[0]+Q_001120101*R_141[0]+Q_001220001*R_150[0]+-1*Q_001220101*R_151[0]+-1*Q_101020001*R_230[0]+Q_101020101*R_231[0]+Q_101120001*R_240[0]+-1*Q_101120101*R_241[0]+-1*Q_101220001*R_250[0]+Q_101220101*R_251[0]; double QR_000021001130=Q_000021001*R_130[0]+-1*Q_000021101*R_131[0]+-1*Q_000121001*R_140[0]+Q_000121101*R_141[0]+Q_000221001*R_150[0]+-1*Q_000221101*R_151[0]+-1*Q_000321001*R_160[0]+Q_000321101*R_161[0]; double QR_000020002130=Q_000020002*R_130[0]+-1*Q_000020102*R_131[0]+Q_000020202*R_132[0]+-1*Q_000120002*R_140[0]+Q_000120102*R_141[0]+-1*Q_000120202*R_142[0]+Q_000220002*R_150[0]+-1*Q_000220102*R_151[0]+Q_000220202*R_152[0]; double QR_012000010130=Q_012000010*R_130[0]+-1*Q_012000110*R_131[0]+-1*Q_112000010*R_230[0]+Q_112000110*R_231[0]+Q_212000010*R_330[0]+-1*Q_212000110*R_331[0]+-1*Q_312000010*R_430[0]+Q_312000110*R_431[0]; double QR_011001010130=Q_011001010*R_130[0]+-1*Q_011001110*R_131[0]+-1*Q_011101010*R_140[0]+Q_011101110*R_141[0]+-1*Q_111001010*R_230[0]+Q_111001110*R_231[0]+Q_111101010*R_240[0]+-1*Q_111101110*R_241[0]+Q_211001010*R_330[0]+-1*Q_211001110*R_331[0]+-1*Q_211101010*R_340[0]+Q_211101110*R_341[0]; double QR_010002010130=Q_010002010*R_130[0]+-1*Q_010002110*R_131[0]+-1*Q_010102010*R_140[0]+Q_010102110*R_141[0]+Q_010202010*R_150[0]+-1*Q_010202110*R_151[0]+-1*Q_110002010*R_230[0]+Q_110002110*R_231[0]+Q_110102010*R_240[0]+-1*Q_110102110*R_241[0]+-1*Q_110202010*R_250[0]+Q_110202110*R_251[0]; double QR_011000011130=Q_011000011*R_130[0]+-1*Q_011000111*R_131[0]+Q_011000211*R_132[0]+-1*Q_111000011*R_230[0]+Q_111000111*R_231[0]+-1*Q_111000211*R_232[0]+Q_211000011*R_330[0]+-1*Q_211000111*R_331[0]+Q_211000211*R_332[0]; double QR_010001011130=Q_010001011*R_130[0]+-1*Q_010001111*R_131[0]+Q_010001211*R_132[0]+-1*Q_010101011*R_140[0]+Q_010101111*R_141[0]+-1*Q_010101211*R_142[0]+-1*Q_110001011*R_230[0]+Q_110001111*R_231[0]+-1*Q_110001211*R_232[0]+Q_110101011*R_240[0]+-1*Q_110101111*R_241[0]+Q_110101211*R_242[0]; double QR_010000012130=Q_010000012*R_130[0]+-1*Q_010000112*R_131[0]+Q_010000212*R_132[0]+-1*Q_010000312*R_133[0]+-1*Q_110000012*R_230[0]+Q_110000112*R_231[0]+-1*Q_110000212*R_232[0]+Q_110000312*R_233[0]; double QR_002010010130=Q_002010010*R_130[0]+-1*Q_002010110*R_131[0]+-1*Q_002110010*R_140[0]+Q_002110110*R_141[0]+-1*Q_102010010*R_230[0]+Q_102010110*R_231[0]+Q_102110010*R_240[0]+-1*Q_102110110*R_241[0]+Q_202010010*R_330[0]+-1*Q_202010110*R_331[0]+-1*Q_202110010*R_340[0]+Q_202110110*R_341[0]; double QR_001011010130=Q_001011010*R_130[0]+-1*Q_001011110*R_131[0]+-1*Q_001111010*R_140[0]+Q_001111110*R_141[0]+Q_001211010*R_150[0]+-1*Q_001211110*R_151[0]+-1*Q_101011010*R_230[0]+Q_101011110*R_231[0]+Q_101111010*R_240[0]+-1*Q_101111110*R_241[0]+-1*Q_101211010*R_250[0]+Q_101211110*R_251[0]; double QR_000012010130=Q_000012010*R_130[0]+-1*Q_000012110*R_131[0]+-1*Q_000112010*R_140[0]+Q_000112110*R_141[0]+Q_000212010*R_150[0]+-1*Q_000212110*R_151[0]+-1*Q_000312010*R_160[0]+Q_000312110*R_161[0]; double QR_001010011130=Q_001010011*R_130[0]+-1*Q_001010111*R_131[0]+Q_001010211*R_132[0]+-1*Q_001110011*R_140[0]+Q_001110111*R_141[0]+-1*Q_001110211*R_142[0]+-1*Q_101010011*R_230[0]+Q_101010111*R_231[0]+-1*Q_101010211*R_232[0]+Q_101110011*R_240[0]+-1*Q_101110111*R_241[0]+Q_101110211*R_242[0]; double QR_000011011130=Q_000011011*R_130[0]+-1*Q_000011111*R_131[0]+Q_000011211*R_132[0]+-1*Q_000111011*R_140[0]+Q_000111111*R_141[0]+-1*Q_000111211*R_142[0]+Q_000211011*R_150[0]+-1*Q_000211111*R_151[0]+Q_000211211*R_152[0]; double QR_000010012130=Q_000010012*R_130[0]+-1*Q_000010112*R_131[0]+Q_000010212*R_132[0]+-1*Q_000010312*R_133[0]+-1*Q_000110012*R_140[0]+Q_000110112*R_141[0]+-1*Q_000110212*R_142[0]+Q_000110312*R_143[0]; double QR_002000020130=Q_002000020*R_130[0]+-1*Q_002000120*R_131[0]+Q_002000220*R_132[0]+-1*Q_102000020*R_230[0]+Q_102000120*R_231[0]+-1*Q_102000220*R_232[0]+Q_202000020*R_330[0]+-1*Q_202000120*R_331[0]+Q_202000220*R_332[0]; double QR_001001020130=Q_001001020*R_130[0]+-1*Q_001001120*R_131[0]+Q_001001220*R_132[0]+-1*Q_001101020*R_140[0]+Q_001101120*R_141[0]+-1*Q_001101220*R_142[0]+-1*Q_101001020*R_230[0]+Q_101001120*R_231[0]+-1*Q_101001220*R_232[0]+Q_101101020*R_240[0]+-1*Q_101101120*R_241[0]+Q_101101220*R_242[0]; double QR_000002020130=Q_000002020*R_130[0]+-1*Q_000002120*R_131[0]+Q_000002220*R_132[0]+-1*Q_000102020*R_140[0]+Q_000102120*R_141[0]+-1*Q_000102220*R_142[0]+Q_000202020*R_150[0]+-1*Q_000202120*R_151[0]+Q_000202220*R_152[0]; double QR_001000021130=Q_001000021*R_130[0]+-1*Q_001000121*R_131[0]+Q_001000221*R_132[0]+-1*Q_001000321*R_133[0]+-1*Q_101000021*R_230[0]+Q_101000121*R_231[0]+-1*Q_101000221*R_232[0]+Q_101000321*R_233[0]; double QR_000001021130=Q_000001021*R_130[0]+-1*Q_000001121*R_131[0]+Q_000001221*R_132[0]+-1*Q_000001321*R_133[0]+-1*Q_000101021*R_140[0]+Q_000101121*R_141[0]+-1*Q_000101221*R_142[0]+Q_000101321*R_143[0]; double QR_000000022130=Q_000000022*R_130[0]+-1*Q_000000122*R_131[0]+Q_000000222*R_132[0]+-1*Q_000000322*R_133[0]+Q_000000422*R_134[0]; double QR_022000000202=Q_022000000*R_202[0]+-1*Q_122000000*R_302[0]+Q_222000000*R_402[0]+-1*Q_322000000*R_502[0]+Q_422000000*R_602[0]; double QR_021001000202=Q_021001000*R_202[0]+-1*Q_021101000*R_212[0]+-1*Q_121001000*R_302[0]+Q_121101000*R_312[0]+Q_221001000*R_402[0]+-1*Q_221101000*R_412[0]+-1*Q_321001000*R_502[0]+Q_321101000*R_512[0]; double QR_020002000202=Q_020002000*R_202[0]+-1*Q_020102000*R_212[0]+Q_020202000*R_222[0]+-1*Q_120002000*R_302[0]+Q_120102000*R_312[0]+-1*Q_120202000*R_322[0]+Q_220002000*R_402[0]+-1*Q_220102000*R_412[0]+Q_220202000*R_422[0]; double QR_021000001202=Q_021000001*R_202[0]+-1*Q_021000101*R_203[0]+-1*Q_121000001*R_302[0]+Q_121000101*R_303[0]+Q_221000001*R_402[0]+-1*Q_221000101*R_403[0]+-1*Q_321000001*R_502[0]+Q_321000101*R_503[0]; double QR_020001001202=Q_020001001*R_202[0]+-1*Q_020001101*R_203[0]+-1*Q_020101001*R_212[0]+Q_020101101*R_213[0]+-1*Q_120001001*R_302[0]+Q_120001101*R_303[0]+Q_120101001*R_312[0]+-1*Q_120101101*R_313[0]+Q_220001001*R_402[0]+-1*Q_220001101*R_403[0]+-1*Q_220101001*R_412[0]+Q_220101101*R_413[0]; double QR_020000002202=Q_020000002*R_202[0]+-1*Q_020000102*R_203[0]+Q_020000202*R_204[0]+-1*Q_120000002*R_302[0]+Q_120000102*R_303[0]+-1*Q_120000202*R_304[0]+Q_220000002*R_402[0]+-1*Q_220000102*R_403[0]+Q_220000202*R_404[0]; double QR_012010000202=Q_012010000*R_202[0]+-1*Q_012110000*R_212[0]+-1*Q_112010000*R_302[0]+Q_112110000*R_312[0]+Q_212010000*R_402[0]+-1*Q_212110000*R_412[0]+-1*Q_312010000*R_502[0]+Q_312110000*R_512[0]; double QR_011011000202=Q_011011000*R_202[0]+-1*Q_011111000*R_212[0]+Q_011211000*R_222[0]+-1*Q_111011000*R_302[0]+Q_111111000*R_312[0]+-1*Q_111211000*R_322[0]+Q_211011000*R_402[0]+-1*Q_211111000*R_412[0]+Q_211211000*R_422[0]; double QR_010012000202=Q_010012000*R_202[0]+-1*Q_010112000*R_212[0]+Q_010212000*R_222[0]+-1*Q_010312000*R_232[0]+-1*Q_110012000*R_302[0]+Q_110112000*R_312[0]+-1*Q_110212000*R_322[0]+Q_110312000*R_332[0]; double QR_011010001202=Q_011010001*R_202[0]+-1*Q_011010101*R_203[0]+-1*Q_011110001*R_212[0]+Q_011110101*R_213[0]+-1*Q_111010001*R_302[0]+Q_111010101*R_303[0]+Q_111110001*R_312[0]+-1*Q_111110101*R_313[0]+Q_211010001*R_402[0]+-1*Q_211010101*R_403[0]+-1*Q_211110001*R_412[0]+Q_211110101*R_413[0]; double QR_010011001202=Q_010011001*R_202[0]+-1*Q_010011101*R_203[0]+-1*Q_010111001*R_212[0]+Q_010111101*R_213[0]+Q_010211001*R_222[0]+-1*Q_010211101*R_223[0]+-1*Q_110011001*R_302[0]+Q_110011101*R_303[0]+Q_110111001*R_312[0]+-1*Q_110111101*R_313[0]+-1*Q_110211001*R_322[0]+Q_110211101*R_323[0]; double QR_010010002202=Q_010010002*R_202[0]+-1*Q_010010102*R_203[0]+Q_010010202*R_204[0]+-1*Q_010110002*R_212[0]+Q_010110102*R_213[0]+-1*Q_010110202*R_214[0]+-1*Q_110010002*R_302[0]+Q_110010102*R_303[0]+-1*Q_110010202*R_304[0]+Q_110110002*R_312[0]+-1*Q_110110102*R_313[0]+Q_110110202*R_314[0]; double QR_002020000202=Q_002020000*R_202[0]+-1*Q_002120000*R_212[0]+Q_002220000*R_222[0]+-1*Q_102020000*R_302[0]+Q_102120000*R_312[0]+-1*Q_102220000*R_322[0]+Q_202020000*R_402[0]+-1*Q_202120000*R_412[0]+Q_202220000*R_422[0]; double QR_001021000202=Q_001021000*R_202[0]+-1*Q_001121000*R_212[0]+Q_001221000*R_222[0]+-1*Q_001321000*R_232[0]+-1*Q_101021000*R_302[0]+Q_101121000*R_312[0]+-1*Q_101221000*R_322[0]+Q_101321000*R_332[0]; double QR_000022000202=Q_000022000*R_202[0]+-1*Q_000122000*R_212[0]+Q_000222000*R_222[0]+-1*Q_000322000*R_232[0]+Q_000422000*R_242[0]; double QR_001020001202=Q_001020001*R_202[0]+-1*Q_001020101*R_203[0]+-1*Q_001120001*R_212[0]+Q_001120101*R_213[0]+Q_001220001*R_222[0]+-1*Q_001220101*R_223[0]+-1*Q_101020001*R_302[0]+Q_101020101*R_303[0]+Q_101120001*R_312[0]+-1*Q_101120101*R_313[0]+-1*Q_101220001*R_322[0]+Q_101220101*R_323[0]; double QR_000021001202=Q_000021001*R_202[0]+-1*Q_000021101*R_203[0]+-1*Q_000121001*R_212[0]+Q_000121101*R_213[0]+Q_000221001*R_222[0]+-1*Q_000221101*R_223[0]+-1*Q_000321001*R_232[0]+Q_000321101*R_233[0]; double QR_000020002202=Q_000020002*R_202[0]+-1*Q_000020102*R_203[0]+Q_000020202*R_204[0]+-1*Q_000120002*R_212[0]+Q_000120102*R_213[0]+-1*Q_000120202*R_214[0]+Q_000220002*R_222[0]+-1*Q_000220102*R_223[0]+Q_000220202*R_224[0]; double QR_012000010202=Q_012000010*R_202[0]+-1*Q_012000110*R_203[0]+-1*Q_112000010*R_302[0]+Q_112000110*R_303[0]+Q_212000010*R_402[0]+-1*Q_212000110*R_403[0]+-1*Q_312000010*R_502[0]+Q_312000110*R_503[0]; double QR_011001010202=Q_011001010*R_202[0]+-1*Q_011001110*R_203[0]+-1*Q_011101010*R_212[0]+Q_011101110*R_213[0]+-1*Q_111001010*R_302[0]+Q_111001110*R_303[0]+Q_111101010*R_312[0]+-1*Q_111101110*R_313[0]+Q_211001010*R_402[0]+-1*Q_211001110*R_403[0]+-1*Q_211101010*R_412[0]+Q_211101110*R_413[0]; double QR_010002010202=Q_010002010*R_202[0]+-1*Q_010002110*R_203[0]+-1*Q_010102010*R_212[0]+Q_010102110*R_213[0]+Q_010202010*R_222[0]+-1*Q_010202110*R_223[0]+-1*Q_110002010*R_302[0]+Q_110002110*R_303[0]+Q_110102010*R_312[0]+-1*Q_110102110*R_313[0]+-1*Q_110202010*R_322[0]+Q_110202110*R_323[0]; double QR_011000011202=Q_011000011*R_202[0]+-1*Q_011000111*R_203[0]+Q_011000211*R_204[0]+-1*Q_111000011*R_302[0]+Q_111000111*R_303[0]+-1*Q_111000211*R_304[0]+Q_211000011*R_402[0]+-1*Q_211000111*R_403[0]+Q_211000211*R_404[0]; double QR_010001011202=Q_010001011*R_202[0]+-1*Q_010001111*R_203[0]+Q_010001211*R_204[0]+-1*Q_010101011*R_212[0]+Q_010101111*R_213[0]+-1*Q_010101211*R_214[0]+-1*Q_110001011*R_302[0]+Q_110001111*R_303[0]+-1*Q_110001211*R_304[0]+Q_110101011*R_312[0]+-1*Q_110101111*R_313[0]+Q_110101211*R_314[0]; double QR_010000012202=Q_010000012*R_202[0]+-1*Q_010000112*R_203[0]+Q_010000212*R_204[0]+-1*Q_010000312*R_205[0]+-1*Q_110000012*R_302[0]+Q_110000112*R_303[0]+-1*Q_110000212*R_304[0]+Q_110000312*R_305[0]; double QR_002010010202=Q_002010010*R_202[0]+-1*Q_002010110*R_203[0]+-1*Q_002110010*R_212[0]+Q_002110110*R_213[0]+-1*Q_102010010*R_302[0]+Q_102010110*R_303[0]+Q_102110010*R_312[0]+-1*Q_102110110*R_313[0]+Q_202010010*R_402[0]+-1*Q_202010110*R_403[0]+-1*Q_202110010*R_412[0]+Q_202110110*R_413[0]; double QR_001011010202=Q_001011010*R_202[0]+-1*Q_001011110*R_203[0]+-1*Q_001111010*R_212[0]+Q_001111110*R_213[0]+Q_001211010*R_222[0]+-1*Q_001211110*R_223[0]+-1*Q_101011010*R_302[0]+Q_101011110*R_303[0]+Q_101111010*R_312[0]+-1*Q_101111110*R_313[0]+-1*Q_101211010*R_322[0]+Q_101211110*R_323[0]; double QR_000012010202=Q_000012010*R_202[0]+-1*Q_000012110*R_203[0]+-1*Q_000112010*R_212[0]+Q_000112110*R_213[0]+Q_000212010*R_222[0]+-1*Q_000212110*R_223[0]+-1*Q_000312010*R_232[0]+Q_000312110*R_233[0]; double QR_001010011202=Q_001010011*R_202[0]+-1*Q_001010111*R_203[0]+Q_001010211*R_204[0]+-1*Q_001110011*R_212[0]+Q_001110111*R_213[0]+-1*Q_001110211*R_214[0]+-1*Q_101010011*R_302[0]+Q_101010111*R_303[0]+-1*Q_101010211*R_304[0]+Q_101110011*R_312[0]+-1*Q_101110111*R_313[0]+Q_101110211*R_314[0]; double QR_000011011202=Q_000011011*R_202[0]+-1*Q_000011111*R_203[0]+Q_000011211*R_204[0]+-1*Q_000111011*R_212[0]+Q_000111111*R_213[0]+-1*Q_000111211*R_214[0]+Q_000211011*R_222[0]+-1*Q_000211111*R_223[0]+Q_000211211*R_224[0]; double QR_000010012202=Q_000010012*R_202[0]+-1*Q_000010112*R_203[0]+Q_000010212*R_204[0]+-1*Q_000010312*R_205[0]+-1*Q_000110012*R_212[0]+Q_000110112*R_213[0]+-1*Q_000110212*R_214[0]+Q_000110312*R_215[0]; double QR_002000020202=Q_002000020*R_202[0]+-1*Q_002000120*R_203[0]+Q_002000220*R_204[0]+-1*Q_102000020*R_302[0]+Q_102000120*R_303[0]+-1*Q_102000220*R_304[0]+Q_202000020*R_402[0]+-1*Q_202000120*R_403[0]+Q_202000220*R_404[0]; double QR_001001020202=Q_001001020*R_202[0]+-1*Q_001001120*R_203[0]+Q_001001220*R_204[0]+-1*Q_001101020*R_212[0]+Q_001101120*R_213[0]+-1*Q_001101220*R_214[0]+-1*Q_101001020*R_302[0]+Q_101001120*R_303[0]+-1*Q_101001220*R_304[0]+Q_101101020*R_312[0]+-1*Q_101101120*R_313[0]+Q_101101220*R_314[0]; double QR_000002020202=Q_000002020*R_202[0]+-1*Q_000002120*R_203[0]+Q_000002220*R_204[0]+-1*Q_000102020*R_212[0]+Q_000102120*R_213[0]+-1*Q_000102220*R_214[0]+Q_000202020*R_222[0]+-1*Q_000202120*R_223[0]+Q_000202220*R_224[0]; double QR_001000021202=Q_001000021*R_202[0]+-1*Q_001000121*R_203[0]+Q_001000221*R_204[0]+-1*Q_001000321*R_205[0]+-1*Q_101000021*R_302[0]+Q_101000121*R_303[0]+-1*Q_101000221*R_304[0]+Q_101000321*R_305[0]; double QR_000001021202=Q_000001021*R_202[0]+-1*Q_000001121*R_203[0]+Q_000001221*R_204[0]+-1*Q_000001321*R_205[0]+-1*Q_000101021*R_212[0]+Q_000101121*R_213[0]+-1*Q_000101221*R_214[0]+Q_000101321*R_215[0]; double QR_000000022202=Q_000000022*R_202[0]+-1*Q_000000122*R_203[0]+Q_000000222*R_204[0]+-1*Q_000000322*R_205[0]+Q_000000422*R_206[0]; double QR_022000000211=Q_022000000*R_211[0]+-1*Q_122000000*R_311[0]+Q_222000000*R_411[0]+-1*Q_322000000*R_511[0]+Q_422000000*R_611[0]; double QR_021001000211=Q_021001000*R_211[0]+-1*Q_021101000*R_221[0]+-1*Q_121001000*R_311[0]+Q_121101000*R_321[0]+Q_221001000*R_411[0]+-1*Q_221101000*R_421[0]+-1*Q_321001000*R_511[0]+Q_321101000*R_521[0]; double QR_020002000211=Q_020002000*R_211[0]+-1*Q_020102000*R_221[0]+Q_020202000*R_231[0]+-1*Q_120002000*R_311[0]+Q_120102000*R_321[0]+-1*Q_120202000*R_331[0]+Q_220002000*R_411[0]+-1*Q_220102000*R_421[0]+Q_220202000*R_431[0]; double QR_021000001211=Q_021000001*R_211[0]+-1*Q_021000101*R_212[0]+-1*Q_121000001*R_311[0]+Q_121000101*R_312[0]+Q_221000001*R_411[0]+-1*Q_221000101*R_412[0]+-1*Q_321000001*R_511[0]+Q_321000101*R_512[0]; double QR_020001001211=Q_020001001*R_211[0]+-1*Q_020001101*R_212[0]+-1*Q_020101001*R_221[0]+Q_020101101*R_222[0]+-1*Q_120001001*R_311[0]+Q_120001101*R_312[0]+Q_120101001*R_321[0]+-1*Q_120101101*R_322[0]+Q_220001001*R_411[0]+-1*Q_220001101*R_412[0]+-1*Q_220101001*R_421[0]+Q_220101101*R_422[0]; double QR_020000002211=Q_020000002*R_211[0]+-1*Q_020000102*R_212[0]+Q_020000202*R_213[0]+-1*Q_120000002*R_311[0]+Q_120000102*R_312[0]+-1*Q_120000202*R_313[0]+Q_220000002*R_411[0]+-1*Q_220000102*R_412[0]+Q_220000202*R_413[0]; double QR_012010000211=Q_012010000*R_211[0]+-1*Q_012110000*R_221[0]+-1*Q_112010000*R_311[0]+Q_112110000*R_321[0]+Q_212010000*R_411[0]+-1*Q_212110000*R_421[0]+-1*Q_312010000*R_511[0]+Q_312110000*R_521[0]; double QR_011011000211=Q_011011000*R_211[0]+-1*Q_011111000*R_221[0]+Q_011211000*R_231[0]+-1*Q_111011000*R_311[0]+Q_111111000*R_321[0]+-1*Q_111211000*R_331[0]+Q_211011000*R_411[0]+-1*Q_211111000*R_421[0]+Q_211211000*R_431[0]; double QR_010012000211=Q_010012000*R_211[0]+-1*Q_010112000*R_221[0]+Q_010212000*R_231[0]+-1*Q_010312000*R_241[0]+-1*Q_110012000*R_311[0]+Q_110112000*R_321[0]+-1*Q_110212000*R_331[0]+Q_110312000*R_341[0]; double QR_011010001211=Q_011010001*R_211[0]+-1*Q_011010101*R_212[0]+-1*Q_011110001*R_221[0]+Q_011110101*R_222[0]+-1*Q_111010001*R_311[0]+Q_111010101*R_312[0]+Q_111110001*R_321[0]+-1*Q_111110101*R_322[0]+Q_211010001*R_411[0]+-1*Q_211010101*R_412[0]+-1*Q_211110001*R_421[0]+Q_211110101*R_422[0]; double QR_010011001211=Q_010011001*R_211[0]+-1*Q_010011101*R_212[0]+-1*Q_010111001*R_221[0]+Q_010111101*R_222[0]+Q_010211001*R_231[0]+-1*Q_010211101*R_232[0]+-1*Q_110011001*R_311[0]+Q_110011101*R_312[0]+Q_110111001*R_321[0]+-1*Q_110111101*R_322[0]+-1*Q_110211001*R_331[0]+Q_110211101*R_332[0]; double QR_010010002211=Q_010010002*R_211[0]+-1*Q_010010102*R_212[0]+Q_010010202*R_213[0]+-1*Q_010110002*R_221[0]+Q_010110102*R_222[0]+-1*Q_010110202*R_223[0]+-1*Q_110010002*R_311[0]+Q_110010102*R_312[0]+-1*Q_110010202*R_313[0]+Q_110110002*R_321[0]+-1*Q_110110102*R_322[0]+Q_110110202*R_323[0]; double QR_002020000211=Q_002020000*R_211[0]+-1*Q_002120000*R_221[0]+Q_002220000*R_231[0]+-1*Q_102020000*R_311[0]+Q_102120000*R_321[0]+-1*Q_102220000*R_331[0]+Q_202020000*R_411[0]+-1*Q_202120000*R_421[0]+Q_202220000*R_431[0]; double QR_001021000211=Q_001021000*R_211[0]+-1*Q_001121000*R_221[0]+Q_001221000*R_231[0]+-1*Q_001321000*R_241[0]+-1*Q_101021000*R_311[0]+Q_101121000*R_321[0]+-1*Q_101221000*R_331[0]+Q_101321000*R_341[0]; double QR_000022000211=Q_000022000*R_211[0]+-1*Q_000122000*R_221[0]+Q_000222000*R_231[0]+-1*Q_000322000*R_241[0]+Q_000422000*R_251[0]; double QR_001020001211=Q_001020001*R_211[0]+-1*Q_001020101*R_212[0]+-1*Q_001120001*R_221[0]+Q_001120101*R_222[0]+Q_001220001*R_231[0]+-1*Q_001220101*R_232[0]+-1*Q_101020001*R_311[0]+Q_101020101*R_312[0]+Q_101120001*R_321[0]+-1*Q_101120101*R_322[0]+-1*Q_101220001*R_331[0]+Q_101220101*R_332[0]; double QR_000021001211=Q_000021001*R_211[0]+-1*Q_000021101*R_212[0]+-1*Q_000121001*R_221[0]+Q_000121101*R_222[0]+Q_000221001*R_231[0]+-1*Q_000221101*R_232[0]+-1*Q_000321001*R_241[0]+Q_000321101*R_242[0]; double QR_000020002211=Q_000020002*R_211[0]+-1*Q_000020102*R_212[0]+Q_000020202*R_213[0]+-1*Q_000120002*R_221[0]+Q_000120102*R_222[0]+-1*Q_000120202*R_223[0]+Q_000220002*R_231[0]+-1*Q_000220102*R_232[0]+Q_000220202*R_233[0]; double QR_012000010211=Q_012000010*R_211[0]+-1*Q_012000110*R_212[0]+-1*Q_112000010*R_311[0]+Q_112000110*R_312[0]+Q_212000010*R_411[0]+-1*Q_212000110*R_412[0]+-1*Q_312000010*R_511[0]+Q_312000110*R_512[0]; double QR_011001010211=Q_011001010*R_211[0]+-1*Q_011001110*R_212[0]+-1*Q_011101010*R_221[0]+Q_011101110*R_222[0]+-1*Q_111001010*R_311[0]+Q_111001110*R_312[0]+Q_111101010*R_321[0]+-1*Q_111101110*R_322[0]+Q_211001010*R_411[0]+-1*Q_211001110*R_412[0]+-1*Q_211101010*R_421[0]+Q_211101110*R_422[0]; double QR_010002010211=Q_010002010*R_211[0]+-1*Q_010002110*R_212[0]+-1*Q_010102010*R_221[0]+Q_010102110*R_222[0]+Q_010202010*R_231[0]+-1*Q_010202110*R_232[0]+-1*Q_110002010*R_311[0]+Q_110002110*R_312[0]+Q_110102010*R_321[0]+-1*Q_110102110*R_322[0]+-1*Q_110202010*R_331[0]+Q_110202110*R_332[0]; double QR_011000011211=Q_011000011*R_211[0]+-1*Q_011000111*R_212[0]+Q_011000211*R_213[0]+-1*Q_111000011*R_311[0]+Q_111000111*R_312[0]+-1*Q_111000211*R_313[0]+Q_211000011*R_411[0]+-1*Q_211000111*R_412[0]+Q_211000211*R_413[0]; double QR_010001011211=Q_010001011*R_211[0]+-1*Q_010001111*R_212[0]+Q_010001211*R_213[0]+-1*Q_010101011*R_221[0]+Q_010101111*R_222[0]+-1*Q_010101211*R_223[0]+-1*Q_110001011*R_311[0]+Q_110001111*R_312[0]+-1*Q_110001211*R_313[0]+Q_110101011*R_321[0]+-1*Q_110101111*R_322[0]+Q_110101211*R_323[0]; double QR_010000012211=Q_010000012*R_211[0]+-1*Q_010000112*R_212[0]+Q_010000212*R_213[0]+-1*Q_010000312*R_214[0]+-1*Q_110000012*R_311[0]+Q_110000112*R_312[0]+-1*Q_110000212*R_313[0]+Q_110000312*R_314[0]; double QR_002010010211=Q_002010010*R_211[0]+-1*Q_002010110*R_212[0]+-1*Q_002110010*R_221[0]+Q_002110110*R_222[0]+-1*Q_102010010*R_311[0]+Q_102010110*R_312[0]+Q_102110010*R_321[0]+-1*Q_102110110*R_322[0]+Q_202010010*R_411[0]+-1*Q_202010110*R_412[0]+-1*Q_202110010*R_421[0]+Q_202110110*R_422[0]; double QR_001011010211=Q_001011010*R_211[0]+-1*Q_001011110*R_212[0]+-1*Q_001111010*R_221[0]+Q_001111110*R_222[0]+Q_001211010*R_231[0]+-1*Q_001211110*R_232[0]+-1*Q_101011010*R_311[0]+Q_101011110*R_312[0]+Q_101111010*R_321[0]+-1*Q_101111110*R_322[0]+-1*Q_101211010*R_331[0]+Q_101211110*R_332[0]; double QR_000012010211=Q_000012010*R_211[0]+-1*Q_000012110*R_212[0]+-1*Q_000112010*R_221[0]+Q_000112110*R_222[0]+Q_000212010*R_231[0]+-1*Q_000212110*R_232[0]+-1*Q_000312010*R_241[0]+Q_000312110*R_242[0]; double QR_001010011211=Q_001010011*R_211[0]+-1*Q_001010111*R_212[0]+Q_001010211*R_213[0]+-1*Q_001110011*R_221[0]+Q_001110111*R_222[0]+-1*Q_001110211*R_223[0]+-1*Q_101010011*R_311[0]+Q_101010111*R_312[0]+-1*Q_101010211*R_313[0]+Q_101110011*R_321[0]+-1*Q_101110111*R_322[0]+Q_101110211*R_323[0]; double QR_000011011211=Q_000011011*R_211[0]+-1*Q_000011111*R_212[0]+Q_000011211*R_213[0]+-1*Q_000111011*R_221[0]+Q_000111111*R_222[0]+-1*Q_000111211*R_223[0]+Q_000211011*R_231[0]+-1*Q_000211111*R_232[0]+Q_000211211*R_233[0]; double QR_000010012211=Q_000010012*R_211[0]+-1*Q_000010112*R_212[0]+Q_000010212*R_213[0]+-1*Q_000010312*R_214[0]+-1*Q_000110012*R_221[0]+Q_000110112*R_222[0]+-1*Q_000110212*R_223[0]+Q_000110312*R_224[0]; double QR_002000020211=Q_002000020*R_211[0]+-1*Q_002000120*R_212[0]+Q_002000220*R_213[0]+-1*Q_102000020*R_311[0]+Q_102000120*R_312[0]+-1*Q_102000220*R_313[0]+Q_202000020*R_411[0]+-1*Q_202000120*R_412[0]+Q_202000220*R_413[0]; double QR_001001020211=Q_001001020*R_211[0]+-1*Q_001001120*R_212[0]+Q_001001220*R_213[0]+-1*Q_001101020*R_221[0]+Q_001101120*R_222[0]+-1*Q_001101220*R_223[0]+-1*Q_101001020*R_311[0]+Q_101001120*R_312[0]+-1*Q_101001220*R_313[0]+Q_101101020*R_321[0]+-1*Q_101101120*R_322[0]+Q_101101220*R_323[0]; double QR_000002020211=Q_000002020*R_211[0]+-1*Q_000002120*R_212[0]+Q_000002220*R_213[0]+-1*Q_000102020*R_221[0]+Q_000102120*R_222[0]+-1*Q_000102220*R_223[0]+Q_000202020*R_231[0]+-1*Q_000202120*R_232[0]+Q_000202220*R_233[0]; double QR_001000021211=Q_001000021*R_211[0]+-1*Q_001000121*R_212[0]+Q_001000221*R_213[0]+-1*Q_001000321*R_214[0]+-1*Q_101000021*R_311[0]+Q_101000121*R_312[0]+-1*Q_101000221*R_313[0]+Q_101000321*R_314[0]; double QR_000001021211=Q_000001021*R_211[0]+-1*Q_000001121*R_212[0]+Q_000001221*R_213[0]+-1*Q_000001321*R_214[0]+-1*Q_000101021*R_221[0]+Q_000101121*R_222[0]+-1*Q_000101221*R_223[0]+Q_000101321*R_224[0]; double QR_000000022211=Q_000000022*R_211[0]+-1*Q_000000122*R_212[0]+Q_000000222*R_213[0]+-1*Q_000000322*R_214[0]+Q_000000422*R_215[0]; double QR_022000000220=Q_022000000*R_220[0]+-1*Q_122000000*R_320[0]+Q_222000000*R_420[0]+-1*Q_322000000*R_520[0]+Q_422000000*R_620[0]; double QR_021001000220=Q_021001000*R_220[0]+-1*Q_021101000*R_230[0]+-1*Q_121001000*R_320[0]+Q_121101000*R_330[0]+Q_221001000*R_420[0]+-1*Q_221101000*R_430[0]+-1*Q_321001000*R_520[0]+Q_321101000*R_530[0]; double QR_020002000220=Q_020002000*R_220[0]+-1*Q_020102000*R_230[0]+Q_020202000*R_240[0]+-1*Q_120002000*R_320[0]+Q_120102000*R_330[0]+-1*Q_120202000*R_340[0]+Q_220002000*R_420[0]+-1*Q_220102000*R_430[0]+Q_220202000*R_440[0]; double QR_021000001220=Q_021000001*R_220[0]+-1*Q_021000101*R_221[0]+-1*Q_121000001*R_320[0]+Q_121000101*R_321[0]+Q_221000001*R_420[0]+-1*Q_221000101*R_421[0]+-1*Q_321000001*R_520[0]+Q_321000101*R_521[0]; double QR_020001001220=Q_020001001*R_220[0]+-1*Q_020001101*R_221[0]+-1*Q_020101001*R_230[0]+Q_020101101*R_231[0]+-1*Q_120001001*R_320[0]+Q_120001101*R_321[0]+Q_120101001*R_330[0]+-1*Q_120101101*R_331[0]+Q_220001001*R_420[0]+-1*Q_220001101*R_421[0]+-1*Q_220101001*R_430[0]+Q_220101101*R_431[0]; double QR_020000002220=Q_020000002*R_220[0]+-1*Q_020000102*R_221[0]+Q_020000202*R_222[0]+-1*Q_120000002*R_320[0]+Q_120000102*R_321[0]+-1*Q_120000202*R_322[0]+Q_220000002*R_420[0]+-1*Q_220000102*R_421[0]+Q_220000202*R_422[0]; double QR_012010000220=Q_012010000*R_220[0]+-1*Q_012110000*R_230[0]+-1*Q_112010000*R_320[0]+Q_112110000*R_330[0]+Q_212010000*R_420[0]+-1*Q_212110000*R_430[0]+-1*Q_312010000*R_520[0]+Q_312110000*R_530[0]; double QR_011011000220=Q_011011000*R_220[0]+-1*Q_011111000*R_230[0]+Q_011211000*R_240[0]+-1*Q_111011000*R_320[0]+Q_111111000*R_330[0]+-1*Q_111211000*R_340[0]+Q_211011000*R_420[0]+-1*Q_211111000*R_430[0]+Q_211211000*R_440[0]; double QR_010012000220=Q_010012000*R_220[0]+-1*Q_010112000*R_230[0]+Q_010212000*R_240[0]+-1*Q_010312000*R_250[0]+-1*Q_110012000*R_320[0]+Q_110112000*R_330[0]+-1*Q_110212000*R_340[0]+Q_110312000*R_350[0]; double QR_011010001220=Q_011010001*R_220[0]+-1*Q_011010101*R_221[0]+-1*Q_011110001*R_230[0]+Q_011110101*R_231[0]+-1*Q_111010001*R_320[0]+Q_111010101*R_321[0]+Q_111110001*R_330[0]+-1*Q_111110101*R_331[0]+Q_211010001*R_420[0]+-1*Q_211010101*R_421[0]+-1*Q_211110001*R_430[0]+Q_211110101*R_431[0]; double QR_010011001220=Q_010011001*R_220[0]+-1*Q_010011101*R_221[0]+-1*Q_010111001*R_230[0]+Q_010111101*R_231[0]+Q_010211001*R_240[0]+-1*Q_010211101*R_241[0]+-1*Q_110011001*R_320[0]+Q_110011101*R_321[0]+Q_110111001*R_330[0]+-1*Q_110111101*R_331[0]+-1*Q_110211001*R_340[0]+Q_110211101*R_341[0]; double QR_010010002220=Q_010010002*R_220[0]+-1*Q_010010102*R_221[0]+Q_010010202*R_222[0]+-1*Q_010110002*R_230[0]+Q_010110102*R_231[0]+-1*Q_010110202*R_232[0]+-1*Q_110010002*R_320[0]+Q_110010102*R_321[0]+-1*Q_110010202*R_322[0]+Q_110110002*R_330[0]+-1*Q_110110102*R_331[0]+Q_110110202*R_332[0]; double QR_002020000220=Q_002020000*R_220[0]+-1*Q_002120000*R_230[0]+Q_002220000*R_240[0]+-1*Q_102020000*R_320[0]+Q_102120000*R_330[0]+-1*Q_102220000*R_340[0]+Q_202020000*R_420[0]+-1*Q_202120000*R_430[0]+Q_202220000*R_440[0]; double QR_001021000220=Q_001021000*R_220[0]+-1*Q_001121000*R_230[0]+Q_001221000*R_240[0]+-1*Q_001321000*R_250[0]+-1*Q_101021000*R_320[0]+Q_101121000*R_330[0]+-1*Q_101221000*R_340[0]+Q_101321000*R_350[0]; double QR_000022000220=Q_000022000*R_220[0]+-1*Q_000122000*R_230[0]+Q_000222000*R_240[0]+-1*Q_000322000*R_250[0]+Q_000422000*R_260[0]; double QR_001020001220=Q_001020001*R_220[0]+-1*Q_001020101*R_221[0]+-1*Q_001120001*R_230[0]+Q_001120101*R_231[0]+Q_001220001*R_240[0]+-1*Q_001220101*R_241[0]+-1*Q_101020001*R_320[0]+Q_101020101*R_321[0]+Q_101120001*R_330[0]+-1*Q_101120101*R_331[0]+-1*Q_101220001*R_340[0]+Q_101220101*R_341[0]; double QR_000021001220=Q_000021001*R_220[0]+-1*Q_000021101*R_221[0]+-1*Q_000121001*R_230[0]+Q_000121101*R_231[0]+Q_000221001*R_240[0]+-1*Q_000221101*R_241[0]+-1*Q_000321001*R_250[0]+Q_000321101*R_251[0]; double QR_000020002220=Q_000020002*R_220[0]+-1*Q_000020102*R_221[0]+Q_000020202*R_222[0]+-1*Q_000120002*R_230[0]+Q_000120102*R_231[0]+-1*Q_000120202*R_232[0]+Q_000220002*R_240[0]+-1*Q_000220102*R_241[0]+Q_000220202*R_242[0]; double QR_012000010220=Q_012000010*R_220[0]+-1*Q_012000110*R_221[0]+-1*Q_112000010*R_320[0]+Q_112000110*R_321[0]+Q_212000010*R_420[0]+-1*Q_212000110*R_421[0]+-1*Q_312000010*R_520[0]+Q_312000110*R_521[0]; double QR_011001010220=Q_011001010*R_220[0]+-1*Q_011001110*R_221[0]+-1*Q_011101010*R_230[0]+Q_011101110*R_231[0]+-1*Q_111001010*R_320[0]+Q_111001110*R_321[0]+Q_111101010*R_330[0]+-1*Q_111101110*R_331[0]+Q_211001010*R_420[0]+-1*Q_211001110*R_421[0]+-1*Q_211101010*R_430[0]+Q_211101110*R_431[0]; double QR_010002010220=Q_010002010*R_220[0]+-1*Q_010002110*R_221[0]+-1*Q_010102010*R_230[0]+Q_010102110*R_231[0]+Q_010202010*R_240[0]+-1*Q_010202110*R_241[0]+-1*Q_110002010*R_320[0]+Q_110002110*R_321[0]+Q_110102010*R_330[0]+-1*Q_110102110*R_331[0]+-1*Q_110202010*R_340[0]+Q_110202110*R_341[0]; double QR_011000011220=Q_011000011*R_220[0]+-1*Q_011000111*R_221[0]+Q_011000211*R_222[0]+-1*Q_111000011*R_320[0]+Q_111000111*R_321[0]+-1*Q_111000211*R_322[0]+Q_211000011*R_420[0]+-1*Q_211000111*R_421[0]+Q_211000211*R_422[0]; double QR_010001011220=Q_010001011*R_220[0]+-1*Q_010001111*R_221[0]+Q_010001211*R_222[0]+-1*Q_010101011*R_230[0]+Q_010101111*R_231[0]+-1*Q_010101211*R_232[0]+-1*Q_110001011*R_320[0]+Q_110001111*R_321[0]+-1*Q_110001211*R_322[0]+Q_110101011*R_330[0]+-1*Q_110101111*R_331[0]+Q_110101211*R_332[0]; double QR_010000012220=Q_010000012*R_220[0]+-1*Q_010000112*R_221[0]+Q_010000212*R_222[0]+-1*Q_010000312*R_223[0]+-1*Q_110000012*R_320[0]+Q_110000112*R_321[0]+-1*Q_110000212*R_322[0]+Q_110000312*R_323[0]; double QR_002010010220=Q_002010010*R_220[0]+-1*Q_002010110*R_221[0]+-1*Q_002110010*R_230[0]+Q_002110110*R_231[0]+-1*Q_102010010*R_320[0]+Q_102010110*R_321[0]+Q_102110010*R_330[0]+-1*Q_102110110*R_331[0]+Q_202010010*R_420[0]+-1*Q_202010110*R_421[0]+-1*Q_202110010*R_430[0]+Q_202110110*R_431[0]; double QR_001011010220=Q_001011010*R_220[0]+-1*Q_001011110*R_221[0]+-1*Q_001111010*R_230[0]+Q_001111110*R_231[0]+Q_001211010*R_240[0]+-1*Q_001211110*R_241[0]+-1*Q_101011010*R_320[0]+Q_101011110*R_321[0]+Q_101111010*R_330[0]+-1*Q_101111110*R_331[0]+-1*Q_101211010*R_340[0]+Q_101211110*R_341[0]; double QR_000012010220=Q_000012010*R_220[0]+-1*Q_000012110*R_221[0]+-1*Q_000112010*R_230[0]+Q_000112110*R_231[0]+Q_000212010*R_240[0]+-1*Q_000212110*R_241[0]+-1*Q_000312010*R_250[0]+Q_000312110*R_251[0]; double QR_001010011220=Q_001010011*R_220[0]+-1*Q_001010111*R_221[0]+Q_001010211*R_222[0]+-1*Q_001110011*R_230[0]+Q_001110111*R_231[0]+-1*Q_001110211*R_232[0]+-1*Q_101010011*R_320[0]+Q_101010111*R_321[0]+-1*Q_101010211*R_322[0]+Q_101110011*R_330[0]+-1*Q_101110111*R_331[0]+Q_101110211*R_332[0]; double QR_000011011220=Q_000011011*R_220[0]+-1*Q_000011111*R_221[0]+Q_000011211*R_222[0]+-1*Q_000111011*R_230[0]+Q_000111111*R_231[0]+-1*Q_000111211*R_232[0]+Q_000211011*R_240[0]+-1*Q_000211111*R_241[0]+Q_000211211*R_242[0]; double QR_000010012220=Q_000010012*R_220[0]+-1*Q_000010112*R_221[0]+Q_000010212*R_222[0]+-1*Q_000010312*R_223[0]+-1*Q_000110012*R_230[0]+Q_000110112*R_231[0]+-1*Q_000110212*R_232[0]+Q_000110312*R_233[0]; double QR_002000020220=Q_002000020*R_220[0]+-1*Q_002000120*R_221[0]+Q_002000220*R_222[0]+-1*Q_102000020*R_320[0]+Q_102000120*R_321[0]+-1*Q_102000220*R_322[0]+Q_202000020*R_420[0]+-1*Q_202000120*R_421[0]+Q_202000220*R_422[0]; double QR_001001020220=Q_001001020*R_220[0]+-1*Q_001001120*R_221[0]+Q_001001220*R_222[0]+-1*Q_001101020*R_230[0]+Q_001101120*R_231[0]+-1*Q_001101220*R_232[0]+-1*Q_101001020*R_320[0]+Q_101001120*R_321[0]+-1*Q_101001220*R_322[0]+Q_101101020*R_330[0]+-1*Q_101101120*R_331[0]+Q_101101220*R_332[0]; double QR_000002020220=Q_000002020*R_220[0]+-1*Q_000002120*R_221[0]+Q_000002220*R_222[0]+-1*Q_000102020*R_230[0]+Q_000102120*R_231[0]+-1*Q_000102220*R_232[0]+Q_000202020*R_240[0]+-1*Q_000202120*R_241[0]+Q_000202220*R_242[0]; double QR_001000021220=Q_001000021*R_220[0]+-1*Q_001000121*R_221[0]+Q_001000221*R_222[0]+-1*Q_001000321*R_223[0]+-1*Q_101000021*R_320[0]+Q_101000121*R_321[0]+-1*Q_101000221*R_322[0]+Q_101000321*R_323[0]; double QR_000001021220=Q_000001021*R_220[0]+-1*Q_000001121*R_221[0]+Q_000001221*R_222[0]+-1*Q_000001321*R_223[0]+-1*Q_000101021*R_230[0]+Q_000101121*R_231[0]+-1*Q_000101221*R_232[0]+Q_000101321*R_233[0]; double QR_000000022220=Q_000000022*R_220[0]+-1*Q_000000122*R_221[0]+Q_000000222*R_222[0]+-1*Q_000000322*R_223[0]+Q_000000422*R_224[0]; double QR_022000000301=Q_022000000*R_301[0]+-1*Q_122000000*R_401[0]+Q_222000000*R_501[0]+-1*Q_322000000*R_601[0]+Q_422000000*R_701[0]; double QR_021001000301=Q_021001000*R_301[0]+-1*Q_021101000*R_311[0]+-1*Q_121001000*R_401[0]+Q_121101000*R_411[0]+Q_221001000*R_501[0]+-1*Q_221101000*R_511[0]+-1*Q_321001000*R_601[0]+Q_321101000*R_611[0]; double QR_020002000301=Q_020002000*R_301[0]+-1*Q_020102000*R_311[0]+Q_020202000*R_321[0]+-1*Q_120002000*R_401[0]+Q_120102000*R_411[0]+-1*Q_120202000*R_421[0]+Q_220002000*R_501[0]+-1*Q_220102000*R_511[0]+Q_220202000*R_521[0]; double QR_021000001301=Q_021000001*R_301[0]+-1*Q_021000101*R_302[0]+-1*Q_121000001*R_401[0]+Q_121000101*R_402[0]+Q_221000001*R_501[0]+-1*Q_221000101*R_502[0]+-1*Q_321000001*R_601[0]+Q_321000101*R_602[0]; double QR_020001001301=Q_020001001*R_301[0]+-1*Q_020001101*R_302[0]+-1*Q_020101001*R_311[0]+Q_020101101*R_312[0]+-1*Q_120001001*R_401[0]+Q_120001101*R_402[0]+Q_120101001*R_411[0]+-1*Q_120101101*R_412[0]+Q_220001001*R_501[0]+-1*Q_220001101*R_502[0]+-1*Q_220101001*R_511[0]+Q_220101101*R_512[0]; double QR_020000002301=Q_020000002*R_301[0]+-1*Q_020000102*R_302[0]+Q_020000202*R_303[0]+-1*Q_120000002*R_401[0]+Q_120000102*R_402[0]+-1*Q_120000202*R_403[0]+Q_220000002*R_501[0]+-1*Q_220000102*R_502[0]+Q_220000202*R_503[0]; double QR_012010000301=Q_012010000*R_301[0]+-1*Q_012110000*R_311[0]+-1*Q_112010000*R_401[0]+Q_112110000*R_411[0]+Q_212010000*R_501[0]+-1*Q_212110000*R_511[0]+-1*Q_312010000*R_601[0]+Q_312110000*R_611[0]; double QR_011011000301=Q_011011000*R_301[0]+-1*Q_011111000*R_311[0]+Q_011211000*R_321[0]+-1*Q_111011000*R_401[0]+Q_111111000*R_411[0]+-1*Q_111211000*R_421[0]+Q_211011000*R_501[0]+-1*Q_211111000*R_511[0]+Q_211211000*R_521[0]; double QR_010012000301=Q_010012000*R_301[0]+-1*Q_010112000*R_311[0]+Q_010212000*R_321[0]+-1*Q_010312000*R_331[0]+-1*Q_110012000*R_401[0]+Q_110112000*R_411[0]+-1*Q_110212000*R_421[0]+Q_110312000*R_431[0]; double QR_011010001301=Q_011010001*R_301[0]+-1*Q_011010101*R_302[0]+-1*Q_011110001*R_311[0]+Q_011110101*R_312[0]+-1*Q_111010001*R_401[0]+Q_111010101*R_402[0]+Q_111110001*R_411[0]+-1*Q_111110101*R_412[0]+Q_211010001*R_501[0]+-1*Q_211010101*R_502[0]+-1*Q_211110001*R_511[0]+Q_211110101*R_512[0]; double QR_010011001301=Q_010011001*R_301[0]+-1*Q_010011101*R_302[0]+-1*Q_010111001*R_311[0]+Q_010111101*R_312[0]+Q_010211001*R_321[0]+-1*Q_010211101*R_322[0]+-1*Q_110011001*R_401[0]+Q_110011101*R_402[0]+Q_110111001*R_411[0]+-1*Q_110111101*R_412[0]+-1*Q_110211001*R_421[0]+Q_110211101*R_422[0]; double QR_010010002301=Q_010010002*R_301[0]+-1*Q_010010102*R_302[0]+Q_010010202*R_303[0]+-1*Q_010110002*R_311[0]+Q_010110102*R_312[0]+-1*Q_010110202*R_313[0]+-1*Q_110010002*R_401[0]+Q_110010102*R_402[0]+-1*Q_110010202*R_403[0]+Q_110110002*R_411[0]+-1*Q_110110102*R_412[0]+Q_110110202*R_413[0]; double QR_002020000301=Q_002020000*R_301[0]+-1*Q_002120000*R_311[0]+Q_002220000*R_321[0]+-1*Q_102020000*R_401[0]+Q_102120000*R_411[0]+-1*Q_102220000*R_421[0]+Q_202020000*R_501[0]+-1*Q_202120000*R_511[0]+Q_202220000*R_521[0]; double QR_001021000301=Q_001021000*R_301[0]+-1*Q_001121000*R_311[0]+Q_001221000*R_321[0]+-1*Q_001321000*R_331[0]+-1*Q_101021000*R_401[0]+Q_101121000*R_411[0]+-1*Q_101221000*R_421[0]+Q_101321000*R_431[0]; double QR_000022000301=Q_000022000*R_301[0]+-1*Q_000122000*R_311[0]+Q_000222000*R_321[0]+-1*Q_000322000*R_331[0]+Q_000422000*R_341[0]; double QR_001020001301=Q_001020001*R_301[0]+-1*Q_001020101*R_302[0]+-1*Q_001120001*R_311[0]+Q_001120101*R_312[0]+Q_001220001*R_321[0]+-1*Q_001220101*R_322[0]+-1*Q_101020001*R_401[0]+Q_101020101*R_402[0]+Q_101120001*R_411[0]+-1*Q_101120101*R_412[0]+-1*Q_101220001*R_421[0]+Q_101220101*R_422[0]; double QR_000021001301=Q_000021001*R_301[0]+-1*Q_000021101*R_302[0]+-1*Q_000121001*R_311[0]+Q_000121101*R_312[0]+Q_000221001*R_321[0]+-1*Q_000221101*R_322[0]+-1*Q_000321001*R_331[0]+Q_000321101*R_332[0]; double QR_000020002301=Q_000020002*R_301[0]+-1*Q_000020102*R_302[0]+Q_000020202*R_303[0]+-1*Q_000120002*R_311[0]+Q_000120102*R_312[0]+-1*Q_000120202*R_313[0]+Q_000220002*R_321[0]+-1*Q_000220102*R_322[0]+Q_000220202*R_323[0]; double QR_012000010301=Q_012000010*R_301[0]+-1*Q_012000110*R_302[0]+-1*Q_112000010*R_401[0]+Q_112000110*R_402[0]+Q_212000010*R_501[0]+-1*Q_212000110*R_502[0]+-1*Q_312000010*R_601[0]+Q_312000110*R_602[0]; double QR_011001010301=Q_011001010*R_301[0]+-1*Q_011001110*R_302[0]+-1*Q_011101010*R_311[0]+Q_011101110*R_312[0]+-1*Q_111001010*R_401[0]+Q_111001110*R_402[0]+Q_111101010*R_411[0]+-1*Q_111101110*R_412[0]+Q_211001010*R_501[0]+-1*Q_211001110*R_502[0]+-1*Q_211101010*R_511[0]+Q_211101110*R_512[0]; double QR_010002010301=Q_010002010*R_301[0]+-1*Q_010002110*R_302[0]+-1*Q_010102010*R_311[0]+Q_010102110*R_312[0]+Q_010202010*R_321[0]+-1*Q_010202110*R_322[0]+-1*Q_110002010*R_401[0]+Q_110002110*R_402[0]+Q_110102010*R_411[0]+-1*Q_110102110*R_412[0]+-1*Q_110202010*R_421[0]+Q_110202110*R_422[0]; double QR_011000011301=Q_011000011*R_301[0]+-1*Q_011000111*R_302[0]+Q_011000211*R_303[0]+-1*Q_111000011*R_401[0]+Q_111000111*R_402[0]+-1*Q_111000211*R_403[0]+Q_211000011*R_501[0]+-1*Q_211000111*R_502[0]+Q_211000211*R_503[0]; double QR_010001011301=Q_010001011*R_301[0]+-1*Q_010001111*R_302[0]+Q_010001211*R_303[0]+-1*Q_010101011*R_311[0]+Q_010101111*R_312[0]+-1*Q_010101211*R_313[0]+-1*Q_110001011*R_401[0]+Q_110001111*R_402[0]+-1*Q_110001211*R_403[0]+Q_110101011*R_411[0]+-1*Q_110101111*R_412[0]+Q_110101211*R_413[0]; double QR_010000012301=Q_010000012*R_301[0]+-1*Q_010000112*R_302[0]+Q_010000212*R_303[0]+-1*Q_010000312*R_304[0]+-1*Q_110000012*R_401[0]+Q_110000112*R_402[0]+-1*Q_110000212*R_403[0]+Q_110000312*R_404[0]; double QR_002010010301=Q_002010010*R_301[0]+-1*Q_002010110*R_302[0]+-1*Q_002110010*R_311[0]+Q_002110110*R_312[0]+-1*Q_102010010*R_401[0]+Q_102010110*R_402[0]+Q_102110010*R_411[0]+-1*Q_102110110*R_412[0]+Q_202010010*R_501[0]+-1*Q_202010110*R_502[0]+-1*Q_202110010*R_511[0]+Q_202110110*R_512[0]; double QR_001011010301=Q_001011010*R_301[0]+-1*Q_001011110*R_302[0]+-1*Q_001111010*R_311[0]+Q_001111110*R_312[0]+Q_001211010*R_321[0]+-1*Q_001211110*R_322[0]+-1*Q_101011010*R_401[0]+Q_101011110*R_402[0]+Q_101111010*R_411[0]+-1*Q_101111110*R_412[0]+-1*Q_101211010*R_421[0]+Q_101211110*R_422[0]; double QR_000012010301=Q_000012010*R_301[0]+-1*Q_000012110*R_302[0]+-1*Q_000112010*R_311[0]+Q_000112110*R_312[0]+Q_000212010*R_321[0]+-1*Q_000212110*R_322[0]+-1*Q_000312010*R_331[0]+Q_000312110*R_332[0]; double QR_001010011301=Q_001010011*R_301[0]+-1*Q_001010111*R_302[0]+Q_001010211*R_303[0]+-1*Q_001110011*R_311[0]+Q_001110111*R_312[0]+-1*Q_001110211*R_313[0]+-1*Q_101010011*R_401[0]+Q_101010111*R_402[0]+-1*Q_101010211*R_403[0]+Q_101110011*R_411[0]+-1*Q_101110111*R_412[0]+Q_101110211*R_413[0]; double QR_000011011301=Q_000011011*R_301[0]+-1*Q_000011111*R_302[0]+Q_000011211*R_303[0]+-1*Q_000111011*R_311[0]+Q_000111111*R_312[0]+-1*Q_000111211*R_313[0]+Q_000211011*R_321[0]+-1*Q_000211111*R_322[0]+Q_000211211*R_323[0]; double QR_000010012301=Q_000010012*R_301[0]+-1*Q_000010112*R_302[0]+Q_000010212*R_303[0]+-1*Q_000010312*R_304[0]+-1*Q_000110012*R_311[0]+Q_000110112*R_312[0]+-1*Q_000110212*R_313[0]+Q_000110312*R_314[0]; double QR_002000020301=Q_002000020*R_301[0]+-1*Q_002000120*R_302[0]+Q_002000220*R_303[0]+-1*Q_102000020*R_401[0]+Q_102000120*R_402[0]+-1*Q_102000220*R_403[0]+Q_202000020*R_501[0]+-1*Q_202000120*R_502[0]+Q_202000220*R_503[0]; double QR_001001020301=Q_001001020*R_301[0]+-1*Q_001001120*R_302[0]+Q_001001220*R_303[0]+-1*Q_001101020*R_311[0]+Q_001101120*R_312[0]+-1*Q_001101220*R_313[0]+-1*Q_101001020*R_401[0]+Q_101001120*R_402[0]+-1*Q_101001220*R_403[0]+Q_101101020*R_411[0]+-1*Q_101101120*R_412[0]+Q_101101220*R_413[0]; double QR_000002020301=Q_000002020*R_301[0]+-1*Q_000002120*R_302[0]+Q_000002220*R_303[0]+-1*Q_000102020*R_311[0]+Q_000102120*R_312[0]+-1*Q_000102220*R_313[0]+Q_000202020*R_321[0]+-1*Q_000202120*R_322[0]+Q_000202220*R_323[0]; double QR_001000021301=Q_001000021*R_301[0]+-1*Q_001000121*R_302[0]+Q_001000221*R_303[0]+-1*Q_001000321*R_304[0]+-1*Q_101000021*R_401[0]+Q_101000121*R_402[0]+-1*Q_101000221*R_403[0]+Q_101000321*R_404[0]; double QR_000001021301=Q_000001021*R_301[0]+-1*Q_000001121*R_302[0]+Q_000001221*R_303[0]+-1*Q_000001321*R_304[0]+-1*Q_000101021*R_311[0]+Q_000101121*R_312[0]+-1*Q_000101221*R_313[0]+Q_000101321*R_314[0]; double QR_000000022301=Q_000000022*R_301[0]+-1*Q_000000122*R_302[0]+Q_000000222*R_303[0]+-1*Q_000000322*R_304[0]+Q_000000422*R_305[0]; double QR_022000000310=Q_022000000*R_310[0]+-1*Q_122000000*R_410[0]+Q_222000000*R_510[0]+-1*Q_322000000*R_610[0]+Q_422000000*R_710[0]; double QR_021001000310=Q_021001000*R_310[0]+-1*Q_021101000*R_320[0]+-1*Q_121001000*R_410[0]+Q_121101000*R_420[0]+Q_221001000*R_510[0]+-1*Q_221101000*R_520[0]+-1*Q_321001000*R_610[0]+Q_321101000*R_620[0]; double QR_020002000310=Q_020002000*R_310[0]+-1*Q_020102000*R_320[0]+Q_020202000*R_330[0]+-1*Q_120002000*R_410[0]+Q_120102000*R_420[0]+-1*Q_120202000*R_430[0]+Q_220002000*R_510[0]+-1*Q_220102000*R_520[0]+Q_220202000*R_530[0]; double QR_021000001310=Q_021000001*R_310[0]+-1*Q_021000101*R_311[0]+-1*Q_121000001*R_410[0]+Q_121000101*R_411[0]+Q_221000001*R_510[0]+-1*Q_221000101*R_511[0]+-1*Q_321000001*R_610[0]+Q_321000101*R_611[0]; double QR_020001001310=Q_020001001*R_310[0]+-1*Q_020001101*R_311[0]+-1*Q_020101001*R_320[0]+Q_020101101*R_321[0]+-1*Q_120001001*R_410[0]+Q_120001101*R_411[0]+Q_120101001*R_420[0]+-1*Q_120101101*R_421[0]+Q_220001001*R_510[0]+-1*Q_220001101*R_511[0]+-1*Q_220101001*R_520[0]+Q_220101101*R_521[0]; double QR_020000002310=Q_020000002*R_310[0]+-1*Q_020000102*R_311[0]+Q_020000202*R_312[0]+-1*Q_120000002*R_410[0]+Q_120000102*R_411[0]+-1*Q_120000202*R_412[0]+Q_220000002*R_510[0]+-1*Q_220000102*R_511[0]+Q_220000202*R_512[0]; double QR_012010000310=Q_012010000*R_310[0]+-1*Q_012110000*R_320[0]+-1*Q_112010000*R_410[0]+Q_112110000*R_420[0]+Q_212010000*R_510[0]+-1*Q_212110000*R_520[0]+-1*Q_312010000*R_610[0]+Q_312110000*R_620[0]; double QR_011011000310=Q_011011000*R_310[0]+-1*Q_011111000*R_320[0]+Q_011211000*R_330[0]+-1*Q_111011000*R_410[0]+Q_111111000*R_420[0]+-1*Q_111211000*R_430[0]+Q_211011000*R_510[0]+-1*Q_211111000*R_520[0]+Q_211211000*R_530[0]; double QR_010012000310=Q_010012000*R_310[0]+-1*Q_010112000*R_320[0]+Q_010212000*R_330[0]+-1*Q_010312000*R_340[0]+-1*Q_110012000*R_410[0]+Q_110112000*R_420[0]+-1*Q_110212000*R_430[0]+Q_110312000*R_440[0]; double QR_011010001310=Q_011010001*R_310[0]+-1*Q_011010101*R_311[0]+-1*Q_011110001*R_320[0]+Q_011110101*R_321[0]+-1*Q_111010001*R_410[0]+Q_111010101*R_411[0]+Q_111110001*R_420[0]+-1*Q_111110101*R_421[0]+Q_211010001*R_510[0]+-1*Q_211010101*R_511[0]+-1*Q_211110001*R_520[0]+Q_211110101*R_521[0]; double QR_010011001310=Q_010011001*R_310[0]+-1*Q_010011101*R_311[0]+-1*Q_010111001*R_320[0]+Q_010111101*R_321[0]+Q_010211001*R_330[0]+-1*Q_010211101*R_331[0]+-1*Q_110011001*R_410[0]+Q_110011101*R_411[0]+Q_110111001*R_420[0]+-1*Q_110111101*R_421[0]+-1*Q_110211001*R_430[0]+Q_110211101*R_431[0]; double QR_010010002310=Q_010010002*R_310[0]+-1*Q_010010102*R_311[0]+Q_010010202*R_312[0]+-1*Q_010110002*R_320[0]+Q_010110102*R_321[0]+-1*Q_010110202*R_322[0]+-1*Q_110010002*R_410[0]+Q_110010102*R_411[0]+-1*Q_110010202*R_412[0]+Q_110110002*R_420[0]+-1*Q_110110102*R_421[0]+Q_110110202*R_422[0]; double QR_002020000310=Q_002020000*R_310[0]+-1*Q_002120000*R_320[0]+Q_002220000*R_330[0]+-1*Q_102020000*R_410[0]+Q_102120000*R_420[0]+-1*Q_102220000*R_430[0]+Q_202020000*R_510[0]+-1*Q_202120000*R_520[0]+Q_202220000*R_530[0]; double QR_001021000310=Q_001021000*R_310[0]+-1*Q_001121000*R_320[0]+Q_001221000*R_330[0]+-1*Q_001321000*R_340[0]+-1*Q_101021000*R_410[0]+Q_101121000*R_420[0]+-1*Q_101221000*R_430[0]+Q_101321000*R_440[0]; double QR_000022000310=Q_000022000*R_310[0]+-1*Q_000122000*R_320[0]+Q_000222000*R_330[0]+-1*Q_000322000*R_340[0]+Q_000422000*R_350[0]; double QR_001020001310=Q_001020001*R_310[0]+-1*Q_001020101*R_311[0]+-1*Q_001120001*R_320[0]+Q_001120101*R_321[0]+Q_001220001*R_330[0]+-1*Q_001220101*R_331[0]+-1*Q_101020001*R_410[0]+Q_101020101*R_411[0]+Q_101120001*R_420[0]+-1*Q_101120101*R_421[0]+-1*Q_101220001*R_430[0]+Q_101220101*R_431[0]; double QR_000021001310=Q_000021001*R_310[0]+-1*Q_000021101*R_311[0]+-1*Q_000121001*R_320[0]+Q_000121101*R_321[0]+Q_000221001*R_330[0]+-1*Q_000221101*R_331[0]+-1*Q_000321001*R_340[0]+Q_000321101*R_341[0]; double QR_000020002310=Q_000020002*R_310[0]+-1*Q_000020102*R_311[0]+Q_000020202*R_312[0]+-1*Q_000120002*R_320[0]+Q_000120102*R_321[0]+-1*Q_000120202*R_322[0]+Q_000220002*R_330[0]+-1*Q_000220102*R_331[0]+Q_000220202*R_332[0]; double QR_012000010310=Q_012000010*R_310[0]+-1*Q_012000110*R_311[0]+-1*Q_112000010*R_410[0]+Q_112000110*R_411[0]+Q_212000010*R_510[0]+-1*Q_212000110*R_511[0]+-1*Q_312000010*R_610[0]+Q_312000110*R_611[0]; double QR_011001010310=Q_011001010*R_310[0]+-1*Q_011001110*R_311[0]+-1*Q_011101010*R_320[0]+Q_011101110*R_321[0]+-1*Q_111001010*R_410[0]+Q_111001110*R_411[0]+Q_111101010*R_420[0]+-1*Q_111101110*R_421[0]+Q_211001010*R_510[0]+-1*Q_211001110*R_511[0]+-1*Q_211101010*R_520[0]+Q_211101110*R_521[0]; double QR_010002010310=Q_010002010*R_310[0]+-1*Q_010002110*R_311[0]+-1*Q_010102010*R_320[0]+Q_010102110*R_321[0]+Q_010202010*R_330[0]+-1*Q_010202110*R_331[0]+-1*Q_110002010*R_410[0]+Q_110002110*R_411[0]+Q_110102010*R_420[0]+-1*Q_110102110*R_421[0]+-1*Q_110202010*R_430[0]+Q_110202110*R_431[0]; double QR_011000011310=Q_011000011*R_310[0]+-1*Q_011000111*R_311[0]+Q_011000211*R_312[0]+-1*Q_111000011*R_410[0]+Q_111000111*R_411[0]+-1*Q_111000211*R_412[0]+Q_211000011*R_510[0]+-1*Q_211000111*R_511[0]+Q_211000211*R_512[0]; double QR_010001011310=Q_010001011*R_310[0]+-1*Q_010001111*R_311[0]+Q_010001211*R_312[0]+-1*Q_010101011*R_320[0]+Q_010101111*R_321[0]+-1*Q_010101211*R_322[0]+-1*Q_110001011*R_410[0]+Q_110001111*R_411[0]+-1*Q_110001211*R_412[0]+Q_110101011*R_420[0]+-1*Q_110101111*R_421[0]+Q_110101211*R_422[0]; double QR_010000012310=Q_010000012*R_310[0]+-1*Q_010000112*R_311[0]+Q_010000212*R_312[0]+-1*Q_010000312*R_313[0]+-1*Q_110000012*R_410[0]+Q_110000112*R_411[0]+-1*Q_110000212*R_412[0]+Q_110000312*R_413[0]; double QR_002010010310=Q_002010010*R_310[0]+-1*Q_002010110*R_311[0]+-1*Q_002110010*R_320[0]+Q_002110110*R_321[0]+-1*Q_102010010*R_410[0]+Q_102010110*R_411[0]+Q_102110010*R_420[0]+-1*Q_102110110*R_421[0]+Q_202010010*R_510[0]+-1*Q_202010110*R_511[0]+-1*Q_202110010*R_520[0]+Q_202110110*R_521[0]; double QR_001011010310=Q_001011010*R_310[0]+-1*Q_001011110*R_311[0]+-1*Q_001111010*R_320[0]+Q_001111110*R_321[0]+Q_001211010*R_330[0]+-1*Q_001211110*R_331[0]+-1*Q_101011010*R_410[0]+Q_101011110*R_411[0]+Q_101111010*R_420[0]+-1*Q_101111110*R_421[0]+-1*Q_101211010*R_430[0]+Q_101211110*R_431[0]; double QR_000012010310=Q_000012010*R_310[0]+-1*Q_000012110*R_311[0]+-1*Q_000112010*R_320[0]+Q_000112110*R_321[0]+Q_000212010*R_330[0]+-1*Q_000212110*R_331[0]+-1*Q_000312010*R_340[0]+Q_000312110*R_341[0]; double QR_001010011310=Q_001010011*R_310[0]+-1*Q_001010111*R_311[0]+Q_001010211*R_312[0]+-1*Q_001110011*R_320[0]+Q_001110111*R_321[0]+-1*Q_001110211*R_322[0]+-1*Q_101010011*R_410[0]+Q_101010111*R_411[0]+-1*Q_101010211*R_412[0]+Q_101110011*R_420[0]+-1*Q_101110111*R_421[0]+Q_101110211*R_422[0]; double QR_000011011310=Q_000011011*R_310[0]+-1*Q_000011111*R_311[0]+Q_000011211*R_312[0]+-1*Q_000111011*R_320[0]+Q_000111111*R_321[0]+-1*Q_000111211*R_322[0]+Q_000211011*R_330[0]+-1*Q_000211111*R_331[0]+Q_000211211*R_332[0]; double QR_000010012310=Q_000010012*R_310[0]+-1*Q_000010112*R_311[0]+Q_000010212*R_312[0]+-1*Q_000010312*R_313[0]+-1*Q_000110012*R_320[0]+Q_000110112*R_321[0]+-1*Q_000110212*R_322[0]+Q_000110312*R_323[0]; double QR_002000020310=Q_002000020*R_310[0]+-1*Q_002000120*R_311[0]+Q_002000220*R_312[0]+-1*Q_102000020*R_410[0]+Q_102000120*R_411[0]+-1*Q_102000220*R_412[0]+Q_202000020*R_510[0]+-1*Q_202000120*R_511[0]+Q_202000220*R_512[0]; double QR_001001020310=Q_001001020*R_310[0]+-1*Q_001001120*R_311[0]+Q_001001220*R_312[0]+-1*Q_001101020*R_320[0]+Q_001101120*R_321[0]+-1*Q_001101220*R_322[0]+-1*Q_101001020*R_410[0]+Q_101001120*R_411[0]+-1*Q_101001220*R_412[0]+Q_101101020*R_420[0]+-1*Q_101101120*R_421[0]+Q_101101220*R_422[0]; double QR_000002020310=Q_000002020*R_310[0]+-1*Q_000002120*R_311[0]+Q_000002220*R_312[0]+-1*Q_000102020*R_320[0]+Q_000102120*R_321[0]+-1*Q_000102220*R_322[0]+Q_000202020*R_330[0]+-1*Q_000202120*R_331[0]+Q_000202220*R_332[0]; double QR_001000021310=Q_001000021*R_310[0]+-1*Q_001000121*R_311[0]+Q_001000221*R_312[0]+-1*Q_001000321*R_313[0]+-1*Q_101000021*R_410[0]+Q_101000121*R_411[0]+-1*Q_101000221*R_412[0]+Q_101000321*R_413[0]; double QR_000001021310=Q_000001021*R_310[0]+-1*Q_000001121*R_311[0]+Q_000001221*R_312[0]+-1*Q_000001321*R_313[0]+-1*Q_000101021*R_320[0]+Q_000101121*R_321[0]+-1*Q_000101221*R_322[0]+Q_000101321*R_323[0]; double QR_000000022310=Q_000000022*R_310[0]+-1*Q_000000122*R_311[0]+Q_000000222*R_312[0]+-1*Q_000000322*R_313[0]+Q_000000422*R_314[0]; double QR_022000000400=Q_022000000*R_400[0]+-1*Q_122000000*R_500[0]+Q_222000000*R_600[0]+-1*Q_322000000*R_700[0]+Q_422000000*R_800[0]; double QR_021001000400=Q_021001000*R_400[0]+-1*Q_021101000*R_410[0]+-1*Q_121001000*R_500[0]+Q_121101000*R_510[0]+Q_221001000*R_600[0]+-1*Q_221101000*R_610[0]+-1*Q_321001000*R_700[0]+Q_321101000*R_710[0]; double QR_020002000400=Q_020002000*R_400[0]+-1*Q_020102000*R_410[0]+Q_020202000*R_420[0]+-1*Q_120002000*R_500[0]+Q_120102000*R_510[0]+-1*Q_120202000*R_520[0]+Q_220002000*R_600[0]+-1*Q_220102000*R_610[0]+Q_220202000*R_620[0]; double QR_021000001400=Q_021000001*R_400[0]+-1*Q_021000101*R_401[0]+-1*Q_121000001*R_500[0]+Q_121000101*R_501[0]+Q_221000001*R_600[0]+-1*Q_221000101*R_601[0]+-1*Q_321000001*R_700[0]+Q_321000101*R_701[0]; double QR_020001001400=Q_020001001*R_400[0]+-1*Q_020001101*R_401[0]+-1*Q_020101001*R_410[0]+Q_020101101*R_411[0]+-1*Q_120001001*R_500[0]+Q_120001101*R_501[0]+Q_120101001*R_510[0]+-1*Q_120101101*R_511[0]+Q_220001001*R_600[0]+-1*Q_220001101*R_601[0]+-1*Q_220101001*R_610[0]+Q_220101101*R_611[0]; double QR_020000002400=Q_020000002*R_400[0]+-1*Q_020000102*R_401[0]+Q_020000202*R_402[0]+-1*Q_120000002*R_500[0]+Q_120000102*R_501[0]+-1*Q_120000202*R_502[0]+Q_220000002*R_600[0]+-1*Q_220000102*R_601[0]+Q_220000202*R_602[0]; double QR_012010000400=Q_012010000*R_400[0]+-1*Q_012110000*R_410[0]+-1*Q_112010000*R_500[0]+Q_112110000*R_510[0]+Q_212010000*R_600[0]+-1*Q_212110000*R_610[0]+-1*Q_312010000*R_700[0]+Q_312110000*R_710[0]; double QR_011011000400=Q_011011000*R_400[0]+-1*Q_011111000*R_410[0]+Q_011211000*R_420[0]+-1*Q_111011000*R_500[0]+Q_111111000*R_510[0]+-1*Q_111211000*R_520[0]+Q_211011000*R_600[0]+-1*Q_211111000*R_610[0]+Q_211211000*R_620[0]; double QR_010012000400=Q_010012000*R_400[0]+-1*Q_010112000*R_410[0]+Q_010212000*R_420[0]+-1*Q_010312000*R_430[0]+-1*Q_110012000*R_500[0]+Q_110112000*R_510[0]+-1*Q_110212000*R_520[0]+Q_110312000*R_530[0]; double QR_011010001400=Q_011010001*R_400[0]+-1*Q_011010101*R_401[0]+-1*Q_011110001*R_410[0]+Q_011110101*R_411[0]+-1*Q_111010001*R_500[0]+Q_111010101*R_501[0]+Q_111110001*R_510[0]+-1*Q_111110101*R_511[0]+Q_211010001*R_600[0]+-1*Q_211010101*R_601[0]+-1*Q_211110001*R_610[0]+Q_211110101*R_611[0]; double QR_010011001400=Q_010011001*R_400[0]+-1*Q_010011101*R_401[0]+-1*Q_010111001*R_410[0]+Q_010111101*R_411[0]+Q_010211001*R_420[0]+-1*Q_010211101*R_421[0]+-1*Q_110011001*R_500[0]+Q_110011101*R_501[0]+Q_110111001*R_510[0]+-1*Q_110111101*R_511[0]+-1*Q_110211001*R_520[0]+Q_110211101*R_521[0]; double QR_010010002400=Q_010010002*R_400[0]+-1*Q_010010102*R_401[0]+Q_010010202*R_402[0]+-1*Q_010110002*R_410[0]+Q_010110102*R_411[0]+-1*Q_010110202*R_412[0]+-1*Q_110010002*R_500[0]+Q_110010102*R_501[0]+-1*Q_110010202*R_502[0]+Q_110110002*R_510[0]+-1*Q_110110102*R_511[0]+Q_110110202*R_512[0]; double QR_002020000400=Q_002020000*R_400[0]+-1*Q_002120000*R_410[0]+Q_002220000*R_420[0]+-1*Q_102020000*R_500[0]+Q_102120000*R_510[0]+-1*Q_102220000*R_520[0]+Q_202020000*R_600[0]+-1*Q_202120000*R_610[0]+Q_202220000*R_620[0]; double QR_001021000400=Q_001021000*R_400[0]+-1*Q_001121000*R_410[0]+Q_001221000*R_420[0]+-1*Q_001321000*R_430[0]+-1*Q_101021000*R_500[0]+Q_101121000*R_510[0]+-1*Q_101221000*R_520[0]+Q_101321000*R_530[0]; double QR_000022000400=Q_000022000*R_400[0]+-1*Q_000122000*R_410[0]+Q_000222000*R_420[0]+-1*Q_000322000*R_430[0]+Q_000422000*R_440[0]; double QR_001020001400=Q_001020001*R_400[0]+-1*Q_001020101*R_401[0]+-1*Q_001120001*R_410[0]+Q_001120101*R_411[0]+Q_001220001*R_420[0]+-1*Q_001220101*R_421[0]+-1*Q_101020001*R_500[0]+Q_101020101*R_501[0]+Q_101120001*R_510[0]+-1*Q_101120101*R_511[0]+-1*Q_101220001*R_520[0]+Q_101220101*R_521[0]; double QR_000021001400=Q_000021001*R_400[0]+-1*Q_000021101*R_401[0]+-1*Q_000121001*R_410[0]+Q_000121101*R_411[0]+Q_000221001*R_420[0]+-1*Q_000221101*R_421[0]+-1*Q_000321001*R_430[0]+Q_000321101*R_431[0]; double QR_000020002400=Q_000020002*R_400[0]+-1*Q_000020102*R_401[0]+Q_000020202*R_402[0]+-1*Q_000120002*R_410[0]+Q_000120102*R_411[0]+-1*Q_000120202*R_412[0]+Q_000220002*R_420[0]+-1*Q_000220102*R_421[0]+Q_000220202*R_422[0]; double QR_012000010400=Q_012000010*R_400[0]+-1*Q_012000110*R_401[0]+-1*Q_112000010*R_500[0]+Q_112000110*R_501[0]+Q_212000010*R_600[0]+-1*Q_212000110*R_601[0]+-1*Q_312000010*R_700[0]+Q_312000110*R_701[0]; double QR_011001010400=Q_011001010*R_400[0]+-1*Q_011001110*R_401[0]+-1*Q_011101010*R_410[0]+Q_011101110*R_411[0]+-1*Q_111001010*R_500[0]+Q_111001110*R_501[0]+Q_111101010*R_510[0]+-1*Q_111101110*R_511[0]+Q_211001010*R_600[0]+-1*Q_211001110*R_601[0]+-1*Q_211101010*R_610[0]+Q_211101110*R_611[0]; double QR_010002010400=Q_010002010*R_400[0]+-1*Q_010002110*R_401[0]+-1*Q_010102010*R_410[0]+Q_010102110*R_411[0]+Q_010202010*R_420[0]+-1*Q_010202110*R_421[0]+-1*Q_110002010*R_500[0]+Q_110002110*R_501[0]+Q_110102010*R_510[0]+-1*Q_110102110*R_511[0]+-1*Q_110202010*R_520[0]+Q_110202110*R_521[0]; double QR_011000011400=Q_011000011*R_400[0]+-1*Q_011000111*R_401[0]+Q_011000211*R_402[0]+-1*Q_111000011*R_500[0]+Q_111000111*R_501[0]+-1*Q_111000211*R_502[0]+Q_211000011*R_600[0]+-1*Q_211000111*R_601[0]+Q_211000211*R_602[0]; double QR_010001011400=Q_010001011*R_400[0]+-1*Q_010001111*R_401[0]+Q_010001211*R_402[0]+-1*Q_010101011*R_410[0]+Q_010101111*R_411[0]+-1*Q_010101211*R_412[0]+-1*Q_110001011*R_500[0]+Q_110001111*R_501[0]+-1*Q_110001211*R_502[0]+Q_110101011*R_510[0]+-1*Q_110101111*R_511[0]+Q_110101211*R_512[0]; double QR_010000012400=Q_010000012*R_400[0]+-1*Q_010000112*R_401[0]+Q_010000212*R_402[0]+-1*Q_010000312*R_403[0]+-1*Q_110000012*R_500[0]+Q_110000112*R_501[0]+-1*Q_110000212*R_502[0]+Q_110000312*R_503[0]; double QR_002010010400=Q_002010010*R_400[0]+-1*Q_002010110*R_401[0]+-1*Q_002110010*R_410[0]+Q_002110110*R_411[0]+-1*Q_102010010*R_500[0]+Q_102010110*R_501[0]+Q_102110010*R_510[0]+-1*Q_102110110*R_511[0]+Q_202010010*R_600[0]+-1*Q_202010110*R_601[0]+-1*Q_202110010*R_610[0]+Q_202110110*R_611[0]; double QR_001011010400=Q_001011010*R_400[0]+-1*Q_001011110*R_401[0]+-1*Q_001111010*R_410[0]+Q_001111110*R_411[0]+Q_001211010*R_420[0]+-1*Q_001211110*R_421[0]+-1*Q_101011010*R_500[0]+Q_101011110*R_501[0]+Q_101111010*R_510[0]+-1*Q_101111110*R_511[0]+-1*Q_101211010*R_520[0]+Q_101211110*R_521[0]; double QR_000012010400=Q_000012010*R_400[0]+-1*Q_000012110*R_401[0]+-1*Q_000112010*R_410[0]+Q_000112110*R_411[0]+Q_000212010*R_420[0]+-1*Q_000212110*R_421[0]+-1*Q_000312010*R_430[0]+Q_000312110*R_431[0]; double QR_001010011400=Q_001010011*R_400[0]+-1*Q_001010111*R_401[0]+Q_001010211*R_402[0]+-1*Q_001110011*R_410[0]+Q_001110111*R_411[0]+-1*Q_001110211*R_412[0]+-1*Q_101010011*R_500[0]+Q_101010111*R_501[0]+-1*Q_101010211*R_502[0]+Q_101110011*R_510[0]+-1*Q_101110111*R_511[0]+Q_101110211*R_512[0]; double QR_000011011400=Q_000011011*R_400[0]+-1*Q_000011111*R_401[0]+Q_000011211*R_402[0]+-1*Q_000111011*R_410[0]+Q_000111111*R_411[0]+-1*Q_000111211*R_412[0]+Q_000211011*R_420[0]+-1*Q_000211111*R_421[0]+Q_000211211*R_422[0]; double QR_000010012400=Q_000010012*R_400[0]+-1*Q_000010112*R_401[0]+Q_000010212*R_402[0]+-1*Q_000010312*R_403[0]+-1*Q_000110012*R_410[0]+Q_000110112*R_411[0]+-1*Q_000110212*R_412[0]+Q_000110312*R_413[0]; double QR_002000020400=Q_002000020*R_400[0]+-1*Q_002000120*R_401[0]+Q_002000220*R_402[0]+-1*Q_102000020*R_500[0]+Q_102000120*R_501[0]+-1*Q_102000220*R_502[0]+Q_202000020*R_600[0]+-1*Q_202000120*R_601[0]+Q_202000220*R_602[0]; double QR_001001020400=Q_001001020*R_400[0]+-1*Q_001001120*R_401[0]+Q_001001220*R_402[0]+-1*Q_001101020*R_410[0]+Q_001101120*R_411[0]+-1*Q_001101220*R_412[0]+-1*Q_101001020*R_500[0]+Q_101001120*R_501[0]+-1*Q_101001220*R_502[0]+Q_101101020*R_510[0]+-1*Q_101101120*R_511[0]+Q_101101220*R_512[0]; double QR_000002020400=Q_000002020*R_400[0]+-1*Q_000002120*R_401[0]+Q_000002220*R_402[0]+-1*Q_000102020*R_410[0]+Q_000102120*R_411[0]+-1*Q_000102220*R_412[0]+Q_000202020*R_420[0]+-1*Q_000202120*R_421[0]+Q_000202220*R_422[0]; double QR_001000021400=Q_001000021*R_400[0]+-1*Q_001000121*R_401[0]+Q_001000221*R_402[0]+-1*Q_001000321*R_403[0]+-1*Q_101000021*R_500[0]+Q_101000121*R_501[0]+-1*Q_101000221*R_502[0]+Q_101000321*R_503[0]; double QR_000001021400=Q_000001021*R_400[0]+-1*Q_000001121*R_401[0]+Q_000001221*R_402[0]+-1*Q_000001321*R_403[0]+-1*Q_000101021*R_410[0]+Q_000101121*R_411[0]+-1*Q_000101221*R_412[0]+Q_000101321*R_413[0]; double QR_000000022400=Q_000000022*R_400[0]+-1*Q_000000122*R_401[0]+Q_000000222*R_402[0]+-1*Q_000000322*R_403[0]+Q_000000422*R_404[0]; double Pd_101[3]; double Pd_002[3]; double Pd_102[3]; double Pd_202[3]; double Pd_110[3]; double Pd_011[3]; double Pd_111[3]; double Pd_211[3]; double Pd_012[3]; double Pd_112[3]; double Pd_212[3]; double Pd_312[3]; double Pd_020[3]; double Pd_120[3]; double Pd_220[3]; double Pd_021[3]; double Pd_121[3]; double Pd_221[3]; double Pd_321[3]; double Pd_022[3]; double Pd_122[3]; double Pd_222[3]; double Pd_322[3]; double Pd_422[3]; for(int i=0;i<3;i++){ Pd_101[i]=aPin1; } for(int i=0;i<3;i++){ Pd_002[i]=Pd_101[i]+Pd_001[i]*Pd_001[i]; } for(int i=0;i<3;i++){ Pd_102[i]=Pd_001[i]*Pd_101[i]+aPin1*Pd_001[i]; } for(int i=0;i<3;i++){ Pd_202[i]=aPin1*Pd_101[i]; } for(int i=0;i<3;i++){ Pd_110[i]=aPin1; } for(int i=0;i<3;i++){ Pd_011[i]=Pd_101[i]+Pd_010[i]*Pd_001[i]; } for(int i=0;i<3;i++){ Pd_111[i]=Pd_010[i]*Pd_101[i]+aPin1*Pd_001[i]; } for(int i=0;i<3;i++){ Pd_211[i]=aPin1*Pd_101[i]; } for(int i=0;i<3;i++){ Pd_012[i]=Pd_111[i]+Pd_001[i]*Pd_011[i]; } for(int i=0;i<3;i++){ Pd_112[i]=2*Pd_211[i]+Pd_001[i]*Pd_111[i]+aPin1*Pd_011[i]; } for(int i=0;i<3;i++){ Pd_212[i]=Pd_001[i]*Pd_211[i]+aPin1*Pd_111[i]; } for(int i=0;i<3;i++){ Pd_312[i]=aPin1*Pd_211[i]; } for(int i=0;i<3;i++){ Pd_020[i]=Pd_110[i]+Pd_010[i]*Pd_010[i]; } for(int i=0;i<3;i++){ Pd_120[i]=Pd_010[i]*Pd_110[i]+aPin1*Pd_010[i]; } for(int i=0;i<3;i++){ Pd_220[i]=aPin1*Pd_110[i]; } for(int i=0;i<3;i++){ Pd_021[i]=Pd_111[i]+Pd_010[i]*Pd_011[i]; } for(int i=0;i<3;i++){ Pd_121[i]=2*Pd_211[i]+Pd_010[i]*Pd_111[i]+aPin1*Pd_011[i]; } for(int i=0;i<3;i++){ Pd_221[i]=Pd_010[i]*Pd_211[i]+aPin1*Pd_111[i]; } for(int i=0;i<3;i++){ Pd_321[i]=aPin1*Pd_211[i]; } for(int i=0;i<3;i++){ Pd_022[i]=Pd_112[i]+Pd_010[i]*Pd_012[i]; } for(int i=0;i<3;i++){ Pd_122[i]=2*Pd_212[i]+Pd_010[i]*Pd_112[i]+aPin1*Pd_012[i]; } for(int i=0;i<3;i++){ Pd_222[i]=3*Pd_312[i]+Pd_010[i]*Pd_212[i]+aPin1*Pd_112[i]; } for(int i=0;i<3;i++){ Pd_322[i]=Pd_010[i]*Pd_312[i]+aPin1*Pd_212[i]; } for(int i=0;i<3;i++){ Pd_422[i]=aPin1*Pd_312[i]; } double P_022000000=Pd_022[0]; double P_122000000=Pd_122[0]; double P_222000000=Pd_222[0]; double P_322000000=Pd_322[0]; double P_422000000=Pd_422[0]; double P_021001000=Pd_021[0]*Pd_001[1]; double P_021101000=Pd_021[0]*Pd_101[1]; double P_121001000=Pd_121[0]*Pd_001[1]; double P_121101000=Pd_121[0]*Pd_101[1]; double P_221001000=Pd_221[0]*Pd_001[1]; double P_221101000=Pd_221[0]*Pd_101[1]; double P_321001000=Pd_321[0]*Pd_001[1]; double P_321101000=Pd_321[0]*Pd_101[1]; double P_020002000=Pd_020[0]*Pd_002[1]; double P_020102000=Pd_020[0]*Pd_102[1]; double P_020202000=Pd_020[0]*Pd_202[1]; double P_120002000=Pd_120[0]*Pd_002[1]; double P_120102000=Pd_120[0]*Pd_102[1]; double P_120202000=Pd_120[0]*Pd_202[1]; double P_220002000=Pd_220[0]*Pd_002[1]; double P_220102000=Pd_220[0]*Pd_102[1]; double P_220202000=Pd_220[0]*Pd_202[1]; double P_021000001=Pd_021[0]*Pd_001[2]; double P_021000101=Pd_021[0]*Pd_101[2]; double P_121000001=Pd_121[0]*Pd_001[2]; double P_121000101=Pd_121[0]*Pd_101[2]; double P_221000001=Pd_221[0]*Pd_001[2]; double P_221000101=Pd_221[0]*Pd_101[2]; double P_321000001=Pd_321[0]*Pd_001[2]; double P_321000101=Pd_321[0]*Pd_101[2]; double P_020001001=Pd_020[0]*Pd_001[1]*Pd_001[2]; double P_020001101=Pd_020[0]*Pd_001[1]*Pd_101[2]; double P_020101001=Pd_020[0]*Pd_101[1]*Pd_001[2]; double P_020101101=Pd_020[0]*Pd_101[1]*Pd_101[2]; double P_120001001=Pd_120[0]*Pd_001[1]*Pd_001[2]; double P_120001101=Pd_120[0]*Pd_001[1]*Pd_101[2]; double P_120101001=Pd_120[0]*Pd_101[1]*Pd_001[2]; double P_120101101=Pd_120[0]*Pd_101[1]*Pd_101[2]; double P_220001001=Pd_220[0]*Pd_001[1]*Pd_001[2]; double P_220001101=Pd_220[0]*Pd_001[1]*Pd_101[2]; double P_220101001=Pd_220[0]*Pd_101[1]*Pd_001[2]; double P_220101101=Pd_220[0]*Pd_101[1]*Pd_101[2]; double P_020000002=Pd_020[0]*Pd_002[2]; double P_020000102=Pd_020[0]*Pd_102[2]; double P_020000202=Pd_020[0]*Pd_202[2]; double P_120000002=Pd_120[0]*Pd_002[2]; double P_120000102=Pd_120[0]*Pd_102[2]; double P_120000202=Pd_120[0]*Pd_202[2]; double P_220000002=Pd_220[0]*Pd_002[2]; double P_220000102=Pd_220[0]*Pd_102[2]; double P_220000202=Pd_220[0]*Pd_202[2]; double P_012010000=Pd_012[0]*Pd_010[1]; double P_012110000=Pd_012[0]*Pd_110[1]; double P_112010000=Pd_112[0]*Pd_010[1]; double P_112110000=Pd_112[0]*Pd_110[1]; double P_212010000=Pd_212[0]*Pd_010[1]; double P_212110000=Pd_212[0]*Pd_110[1]; double P_312010000=Pd_312[0]*Pd_010[1]; double P_312110000=Pd_312[0]*Pd_110[1]; double P_011011000=Pd_011[0]*Pd_011[1]; double P_011111000=Pd_011[0]*Pd_111[1]; double P_011211000=Pd_011[0]*Pd_211[1]; double P_111011000=Pd_111[0]*Pd_011[1]; double P_111111000=Pd_111[0]*Pd_111[1]; double P_111211000=Pd_111[0]*Pd_211[1]; double P_211011000=Pd_211[0]*Pd_011[1]; double P_211111000=Pd_211[0]*Pd_111[1]; double P_211211000=Pd_211[0]*Pd_211[1]; double P_010012000=Pd_010[0]*Pd_012[1]; double P_010112000=Pd_010[0]*Pd_112[1]; double P_010212000=Pd_010[0]*Pd_212[1]; double P_010312000=Pd_010[0]*Pd_312[1]; double P_110012000=Pd_110[0]*Pd_012[1]; double P_110112000=Pd_110[0]*Pd_112[1]; double P_110212000=Pd_110[0]*Pd_212[1]; double P_110312000=Pd_110[0]*Pd_312[1]; double P_011010001=Pd_011[0]*Pd_010[1]*Pd_001[2]; double P_011010101=Pd_011[0]*Pd_010[1]*Pd_101[2]; double P_011110001=Pd_011[0]*Pd_110[1]*Pd_001[2]; double P_011110101=Pd_011[0]*Pd_110[1]*Pd_101[2]; double P_111010001=Pd_111[0]*Pd_010[1]*Pd_001[2]; double P_111010101=Pd_111[0]*Pd_010[1]*Pd_101[2]; double P_111110001=Pd_111[0]*Pd_110[1]*Pd_001[2]; double P_111110101=Pd_111[0]*Pd_110[1]*Pd_101[2]; double P_211010001=Pd_211[0]*Pd_010[1]*Pd_001[2]; double P_211010101=Pd_211[0]*Pd_010[1]*Pd_101[2]; double P_211110001=Pd_211[0]*Pd_110[1]*Pd_001[2]; double P_211110101=Pd_211[0]*Pd_110[1]*Pd_101[2]; double P_010011001=Pd_010[0]*Pd_011[1]*Pd_001[2]; double P_010011101=Pd_010[0]*Pd_011[1]*Pd_101[2]; double P_010111001=Pd_010[0]*Pd_111[1]*Pd_001[2]; double P_010111101=Pd_010[0]*Pd_111[1]*Pd_101[2]; double P_010211001=Pd_010[0]*Pd_211[1]*Pd_001[2]; double P_010211101=Pd_010[0]*Pd_211[1]*Pd_101[2]; double P_110011001=Pd_110[0]*Pd_011[1]*Pd_001[2]; double P_110011101=Pd_110[0]*Pd_011[1]*Pd_101[2]; double P_110111001=Pd_110[0]*Pd_111[1]*Pd_001[2]; double P_110111101=Pd_110[0]*Pd_111[1]*Pd_101[2]; double P_110211001=Pd_110[0]*Pd_211[1]*Pd_001[2]; double P_110211101=Pd_110[0]*Pd_211[1]*Pd_101[2]; double P_010010002=Pd_010[0]*Pd_010[1]*Pd_002[2]; double P_010010102=Pd_010[0]*Pd_010[1]*Pd_102[2]; double P_010010202=Pd_010[0]*Pd_010[1]*Pd_202[2]; double P_010110002=Pd_010[0]*Pd_110[1]*Pd_002[2]; double P_010110102=Pd_010[0]*Pd_110[1]*Pd_102[2]; double P_010110202=Pd_010[0]*Pd_110[1]*Pd_202[2]; double P_110010002=Pd_110[0]*Pd_010[1]*Pd_002[2]; double P_110010102=Pd_110[0]*Pd_010[1]*Pd_102[2]; double P_110010202=Pd_110[0]*Pd_010[1]*Pd_202[2]; double P_110110002=Pd_110[0]*Pd_110[1]*Pd_002[2]; double P_110110102=Pd_110[0]*Pd_110[1]*Pd_102[2]; double P_110110202=Pd_110[0]*Pd_110[1]*Pd_202[2]; double P_002020000=Pd_002[0]*Pd_020[1]; double P_002120000=Pd_002[0]*Pd_120[1]; double P_002220000=Pd_002[0]*Pd_220[1]; double P_102020000=Pd_102[0]*Pd_020[1]; double P_102120000=Pd_102[0]*Pd_120[1]; double P_102220000=Pd_102[0]*Pd_220[1]; double P_202020000=Pd_202[0]*Pd_020[1]; double P_202120000=Pd_202[0]*Pd_120[1]; double P_202220000=Pd_202[0]*Pd_220[1]; double P_001021000=Pd_001[0]*Pd_021[1]; double P_001121000=Pd_001[0]*Pd_121[1]; double P_001221000=Pd_001[0]*Pd_221[1]; double P_001321000=Pd_001[0]*Pd_321[1]; double P_101021000=Pd_101[0]*Pd_021[1]; double P_101121000=Pd_101[0]*Pd_121[1]; double P_101221000=Pd_101[0]*Pd_221[1]; double P_101321000=Pd_101[0]*Pd_321[1]; double P_000022000=Pd_022[1]; double P_000122000=Pd_122[1]; double P_000222000=Pd_222[1]; double P_000322000=Pd_322[1]; double P_000422000=Pd_422[1]; double P_001020001=Pd_001[0]*Pd_020[1]*Pd_001[2]; double P_001020101=Pd_001[0]*Pd_020[1]*Pd_101[2]; double P_001120001=Pd_001[0]*Pd_120[1]*Pd_001[2]; double P_001120101=Pd_001[0]*Pd_120[1]*Pd_101[2]; double P_001220001=Pd_001[0]*Pd_220[1]*Pd_001[2]; double P_001220101=Pd_001[0]*Pd_220[1]*Pd_101[2]; double P_101020001=Pd_101[0]*Pd_020[1]*Pd_001[2]; double P_101020101=Pd_101[0]*Pd_020[1]*Pd_101[2]; double P_101120001=Pd_101[0]*Pd_120[1]*Pd_001[2]; double P_101120101=Pd_101[0]*Pd_120[1]*Pd_101[2]; double P_101220001=Pd_101[0]*Pd_220[1]*Pd_001[2]; double P_101220101=Pd_101[0]*Pd_220[1]*Pd_101[2]; double P_000021001=Pd_021[1]*Pd_001[2]; double P_000021101=Pd_021[1]*Pd_101[2]; double P_000121001=Pd_121[1]*Pd_001[2]; double P_000121101=Pd_121[1]*Pd_101[2]; double P_000221001=Pd_221[1]*Pd_001[2]; double P_000221101=Pd_221[1]*Pd_101[2]; double P_000321001=Pd_321[1]*Pd_001[2]; double P_000321101=Pd_321[1]*Pd_101[2]; double P_000020002=Pd_020[1]*Pd_002[2]; double P_000020102=Pd_020[1]*Pd_102[2]; double P_000020202=Pd_020[1]*Pd_202[2]; double P_000120002=Pd_120[1]*Pd_002[2]; double P_000120102=Pd_120[1]*Pd_102[2]; double P_000120202=Pd_120[1]*Pd_202[2]; double P_000220002=Pd_220[1]*Pd_002[2]; double P_000220102=Pd_220[1]*Pd_102[2]; double P_000220202=Pd_220[1]*Pd_202[2]; double P_012000010=Pd_012[0]*Pd_010[2]; double P_012000110=Pd_012[0]*Pd_110[2]; double P_112000010=Pd_112[0]*Pd_010[2]; double P_112000110=Pd_112[0]*Pd_110[2]; double P_212000010=Pd_212[0]*Pd_010[2]; double P_212000110=Pd_212[0]*Pd_110[2]; double P_312000010=Pd_312[0]*Pd_010[2]; double P_312000110=Pd_312[0]*Pd_110[2]; double P_011001010=Pd_011[0]*Pd_001[1]*Pd_010[2]; double P_011001110=Pd_011[0]*Pd_001[1]*Pd_110[2]; double P_011101010=Pd_011[0]*Pd_101[1]*Pd_010[2]; double P_011101110=Pd_011[0]*Pd_101[1]*Pd_110[2]; double P_111001010=Pd_111[0]*Pd_001[1]*Pd_010[2]; double P_111001110=Pd_111[0]*Pd_001[1]*Pd_110[2]; double P_111101010=Pd_111[0]*Pd_101[1]*Pd_010[2]; double P_111101110=Pd_111[0]*Pd_101[1]*Pd_110[2]; double P_211001010=Pd_211[0]*Pd_001[1]*Pd_010[2]; double P_211001110=Pd_211[0]*Pd_001[1]*Pd_110[2]; double P_211101010=Pd_211[0]*Pd_101[1]*Pd_010[2]; double P_211101110=Pd_211[0]*Pd_101[1]*Pd_110[2]; double P_010002010=Pd_010[0]*Pd_002[1]*Pd_010[2]; double P_010002110=Pd_010[0]*Pd_002[1]*Pd_110[2]; double P_010102010=Pd_010[0]*Pd_102[1]*Pd_010[2]; double P_010102110=Pd_010[0]*Pd_102[1]*Pd_110[2]; double P_010202010=Pd_010[0]*Pd_202[1]*Pd_010[2]; double P_010202110=Pd_010[0]*Pd_202[1]*Pd_110[2]; double P_110002010=Pd_110[0]*Pd_002[1]*Pd_010[2]; double P_110002110=Pd_110[0]*Pd_002[1]*Pd_110[2]; double P_110102010=Pd_110[0]*Pd_102[1]*Pd_010[2]; double P_110102110=Pd_110[0]*Pd_102[1]*Pd_110[2]; double P_110202010=Pd_110[0]*Pd_202[1]*Pd_010[2]; double P_110202110=Pd_110[0]*Pd_202[1]*Pd_110[2]; double P_011000011=Pd_011[0]*Pd_011[2]; double P_011000111=Pd_011[0]*Pd_111[2]; double P_011000211=Pd_011[0]*Pd_211[2]; double P_111000011=Pd_111[0]*Pd_011[2]; double P_111000111=Pd_111[0]*Pd_111[2]; double P_111000211=Pd_111[0]*Pd_211[2]; double P_211000011=Pd_211[0]*Pd_011[2]; double P_211000111=Pd_211[0]*Pd_111[2]; double P_211000211=Pd_211[0]*Pd_211[2]; double P_010001011=Pd_010[0]*Pd_001[1]*Pd_011[2]; double P_010001111=Pd_010[0]*Pd_001[1]*Pd_111[2]; double P_010001211=Pd_010[0]*Pd_001[1]*Pd_211[2]; double P_010101011=Pd_010[0]*Pd_101[1]*Pd_011[2]; double P_010101111=Pd_010[0]*Pd_101[1]*Pd_111[2]; double P_010101211=Pd_010[0]*Pd_101[1]*Pd_211[2]; double P_110001011=Pd_110[0]*Pd_001[1]*Pd_011[2]; double P_110001111=Pd_110[0]*Pd_001[1]*Pd_111[2]; double P_110001211=Pd_110[0]*Pd_001[1]*Pd_211[2]; double P_110101011=Pd_110[0]*Pd_101[1]*Pd_011[2]; double P_110101111=Pd_110[0]*Pd_101[1]*Pd_111[2]; double P_110101211=Pd_110[0]*Pd_101[1]*Pd_211[2]; double P_010000012=Pd_010[0]*Pd_012[2]; double P_010000112=Pd_010[0]*Pd_112[2]; double P_010000212=Pd_010[0]*Pd_212[2]; double P_010000312=Pd_010[0]*Pd_312[2]; double P_110000012=Pd_110[0]*Pd_012[2]; double P_110000112=Pd_110[0]*Pd_112[2]; double P_110000212=Pd_110[0]*Pd_212[2]; double P_110000312=Pd_110[0]*Pd_312[2]; double P_002010010=Pd_002[0]*Pd_010[1]*Pd_010[2]; double P_002010110=Pd_002[0]*Pd_010[1]*Pd_110[2]; double P_002110010=Pd_002[0]*Pd_110[1]*Pd_010[2]; double P_002110110=Pd_002[0]*Pd_110[1]*Pd_110[2]; double P_102010010=Pd_102[0]*Pd_010[1]*Pd_010[2]; double P_102010110=Pd_102[0]*Pd_010[1]*Pd_110[2]; double P_102110010=Pd_102[0]*Pd_110[1]*Pd_010[2]; double P_102110110=Pd_102[0]*Pd_110[1]*Pd_110[2]; double P_202010010=Pd_202[0]*Pd_010[1]*Pd_010[2]; double P_202010110=Pd_202[0]*Pd_010[1]*Pd_110[2]; double P_202110010=Pd_202[0]*Pd_110[1]*Pd_010[2]; double P_202110110=Pd_202[0]*Pd_110[1]*Pd_110[2]; double P_001011010=Pd_001[0]*Pd_011[1]*Pd_010[2]; double P_001011110=Pd_001[0]*Pd_011[1]*Pd_110[2]; double P_001111010=Pd_001[0]*Pd_111[1]*Pd_010[2]; double P_001111110=Pd_001[0]*Pd_111[1]*Pd_110[2]; double P_001211010=Pd_001[0]*Pd_211[1]*Pd_010[2]; double P_001211110=Pd_001[0]*Pd_211[1]*Pd_110[2]; double P_101011010=Pd_101[0]*Pd_011[1]*Pd_010[2]; double P_101011110=Pd_101[0]*Pd_011[1]*Pd_110[2]; double P_101111010=Pd_101[0]*Pd_111[1]*Pd_010[2]; double P_101111110=Pd_101[0]*Pd_111[1]*Pd_110[2]; double P_101211010=Pd_101[0]*Pd_211[1]*Pd_010[2]; double P_101211110=Pd_101[0]*Pd_211[1]*Pd_110[2]; double P_000012010=Pd_012[1]*Pd_010[2]; double P_000012110=Pd_012[1]*Pd_110[2]; double P_000112010=Pd_112[1]*Pd_010[2]; double P_000112110=Pd_112[1]*Pd_110[2]; double P_000212010=Pd_212[1]*Pd_010[2]; double P_000212110=Pd_212[1]*Pd_110[2]; double P_000312010=Pd_312[1]*Pd_010[2]; double P_000312110=Pd_312[1]*Pd_110[2]; double P_001010011=Pd_001[0]*Pd_010[1]*Pd_011[2]; double P_001010111=Pd_001[0]*Pd_010[1]*Pd_111[2]; double P_001010211=Pd_001[0]*Pd_010[1]*Pd_211[2]; double P_001110011=Pd_001[0]*Pd_110[1]*Pd_011[2]; double P_001110111=Pd_001[0]*Pd_110[1]*Pd_111[2]; double P_001110211=Pd_001[0]*Pd_110[1]*Pd_211[2]; double P_101010011=Pd_101[0]*Pd_010[1]*Pd_011[2]; double P_101010111=Pd_101[0]*Pd_010[1]*Pd_111[2]; double P_101010211=Pd_101[0]*Pd_010[1]*Pd_211[2]; double P_101110011=Pd_101[0]*Pd_110[1]*Pd_011[2]; double P_101110111=Pd_101[0]*Pd_110[1]*Pd_111[2]; double P_101110211=Pd_101[0]*Pd_110[1]*Pd_211[2]; double P_000011011=Pd_011[1]*Pd_011[2]; double P_000011111=Pd_011[1]*Pd_111[2]; double P_000011211=Pd_011[1]*Pd_211[2]; double P_000111011=Pd_111[1]*Pd_011[2]; double P_000111111=Pd_111[1]*Pd_111[2]; double P_000111211=Pd_111[1]*Pd_211[2]; double P_000211011=Pd_211[1]*Pd_011[2]; double P_000211111=Pd_211[1]*Pd_111[2]; double P_000211211=Pd_211[1]*Pd_211[2]; double P_000010012=Pd_010[1]*Pd_012[2]; double P_000010112=Pd_010[1]*Pd_112[2]; double P_000010212=Pd_010[1]*Pd_212[2]; double P_000010312=Pd_010[1]*Pd_312[2]; double P_000110012=Pd_110[1]*Pd_012[2]; double P_000110112=Pd_110[1]*Pd_112[2]; double P_000110212=Pd_110[1]*Pd_212[2]; double P_000110312=Pd_110[1]*Pd_312[2]; double P_002000020=Pd_002[0]*Pd_020[2]; double P_002000120=Pd_002[0]*Pd_120[2]; double P_002000220=Pd_002[0]*Pd_220[2]; double P_102000020=Pd_102[0]*Pd_020[2]; double P_102000120=Pd_102[0]*Pd_120[2]; double P_102000220=Pd_102[0]*Pd_220[2]; double P_202000020=Pd_202[0]*Pd_020[2]; double P_202000120=Pd_202[0]*Pd_120[2]; double P_202000220=Pd_202[0]*Pd_220[2]; double P_001001020=Pd_001[0]*Pd_001[1]*Pd_020[2]; double P_001001120=Pd_001[0]*Pd_001[1]*Pd_120[2]; double P_001001220=Pd_001[0]*Pd_001[1]*Pd_220[2]; double P_001101020=Pd_001[0]*Pd_101[1]*Pd_020[2]; double P_001101120=Pd_001[0]*Pd_101[1]*Pd_120[2]; double P_001101220=Pd_001[0]*Pd_101[1]*Pd_220[2]; double P_101001020=Pd_101[0]*Pd_001[1]*Pd_020[2]; double P_101001120=Pd_101[0]*Pd_001[1]*Pd_120[2]; double P_101001220=Pd_101[0]*Pd_001[1]*Pd_220[2]; double P_101101020=Pd_101[0]*Pd_101[1]*Pd_020[2]; double P_101101120=Pd_101[0]*Pd_101[1]*Pd_120[2]; double P_101101220=Pd_101[0]*Pd_101[1]*Pd_220[2]; double P_000002020=Pd_002[1]*Pd_020[2]; double P_000002120=Pd_002[1]*Pd_120[2]; double P_000002220=Pd_002[1]*Pd_220[2]; double P_000102020=Pd_102[1]*Pd_020[2]; double P_000102120=Pd_102[1]*Pd_120[2]; double P_000102220=Pd_102[1]*Pd_220[2]; double P_000202020=Pd_202[1]*Pd_020[2]; double P_000202120=Pd_202[1]*Pd_120[2]; double P_000202220=Pd_202[1]*Pd_220[2]; double P_001000021=Pd_001[0]*Pd_021[2]; double P_001000121=Pd_001[0]*Pd_121[2]; double P_001000221=Pd_001[0]*Pd_221[2]; double P_001000321=Pd_001[0]*Pd_321[2]; double P_101000021=Pd_101[0]*Pd_021[2]; double P_101000121=Pd_101[0]*Pd_121[2]; double P_101000221=Pd_101[0]*Pd_221[2]; double P_101000321=Pd_101[0]*Pd_321[2]; double P_000001021=Pd_001[1]*Pd_021[2]; double P_000001121=Pd_001[1]*Pd_121[2]; double P_000001221=Pd_001[1]*Pd_221[2]; double P_000001321=Pd_001[1]*Pd_321[2]; double P_000101021=Pd_101[1]*Pd_021[2]; double P_000101121=Pd_101[1]*Pd_121[2]; double P_000101221=Pd_101[1]*Pd_221[2]; double P_000101321=Pd_101[1]*Pd_321[2]; double P_000000022=Pd_022[2]; double P_000000122=Pd_122[2]; double P_000000222=Pd_222[2]; double P_000000322=Pd_322[2]; double P_000000422=Pd_422[2]; ans_temp[ans_id*36+0]+=Pmtrx[0]*(P_022000000*QR_022000000000+P_122000000*QR_022000000100+P_222000000*QR_022000000200+P_322000000*QR_022000000300+P_422000000*QR_022000000400); ans_temp[ans_id*36+0]+=Pmtrx[1]*(P_022000000*QR_021001000000+P_122000000*QR_021001000100+P_222000000*QR_021001000200+P_322000000*QR_021001000300+P_422000000*QR_021001000400); ans_temp[ans_id*36+0]+=Pmtrx[2]*(P_022000000*QR_020002000000+P_122000000*QR_020002000100+P_222000000*QR_020002000200+P_322000000*QR_020002000300+P_422000000*QR_020002000400); ans_temp[ans_id*36+0]+=Pmtrx[3]*(P_022000000*QR_021000001000+P_122000000*QR_021000001100+P_222000000*QR_021000001200+P_322000000*QR_021000001300+P_422000000*QR_021000001400); ans_temp[ans_id*36+0]+=Pmtrx[4]*(P_022000000*QR_020001001000+P_122000000*QR_020001001100+P_222000000*QR_020001001200+P_322000000*QR_020001001300+P_422000000*QR_020001001400); ans_temp[ans_id*36+0]+=Pmtrx[5]*(P_022000000*QR_020000002000+P_122000000*QR_020000002100+P_222000000*QR_020000002200+P_322000000*QR_020000002300+P_422000000*QR_020000002400); ans_temp[ans_id*36+1]+=Pmtrx[0]*(P_022000000*QR_012010000000+P_122000000*QR_012010000100+P_222000000*QR_012010000200+P_322000000*QR_012010000300+P_422000000*QR_012010000400); ans_temp[ans_id*36+1]+=Pmtrx[1]*(P_022000000*QR_011011000000+P_122000000*QR_011011000100+P_222000000*QR_011011000200+P_322000000*QR_011011000300+P_422000000*QR_011011000400); ans_temp[ans_id*36+1]+=Pmtrx[2]*(P_022000000*QR_010012000000+P_122000000*QR_010012000100+P_222000000*QR_010012000200+P_322000000*QR_010012000300+P_422000000*QR_010012000400); ans_temp[ans_id*36+1]+=Pmtrx[3]*(P_022000000*QR_011010001000+P_122000000*QR_011010001100+P_222000000*QR_011010001200+P_322000000*QR_011010001300+P_422000000*QR_011010001400); ans_temp[ans_id*36+1]+=Pmtrx[4]*(P_022000000*QR_010011001000+P_122000000*QR_010011001100+P_222000000*QR_010011001200+P_322000000*QR_010011001300+P_422000000*QR_010011001400); ans_temp[ans_id*36+1]+=Pmtrx[5]*(P_022000000*QR_010010002000+P_122000000*QR_010010002100+P_222000000*QR_010010002200+P_322000000*QR_010010002300+P_422000000*QR_010010002400); ans_temp[ans_id*36+2]+=Pmtrx[0]*(P_022000000*QR_002020000000+P_122000000*QR_002020000100+P_222000000*QR_002020000200+P_322000000*QR_002020000300+P_422000000*QR_002020000400); ans_temp[ans_id*36+2]+=Pmtrx[1]*(P_022000000*QR_001021000000+P_122000000*QR_001021000100+P_222000000*QR_001021000200+P_322000000*QR_001021000300+P_422000000*QR_001021000400); ans_temp[ans_id*36+2]+=Pmtrx[2]*(P_022000000*QR_000022000000+P_122000000*QR_000022000100+P_222000000*QR_000022000200+P_322000000*QR_000022000300+P_422000000*QR_000022000400); ans_temp[ans_id*36+2]+=Pmtrx[3]*(P_022000000*QR_001020001000+P_122000000*QR_001020001100+P_222000000*QR_001020001200+P_322000000*QR_001020001300+P_422000000*QR_001020001400); ans_temp[ans_id*36+2]+=Pmtrx[4]*(P_022000000*QR_000021001000+P_122000000*QR_000021001100+P_222000000*QR_000021001200+P_322000000*QR_000021001300+P_422000000*QR_000021001400); ans_temp[ans_id*36+2]+=Pmtrx[5]*(P_022000000*QR_000020002000+P_122000000*QR_000020002100+P_222000000*QR_000020002200+P_322000000*QR_000020002300+P_422000000*QR_000020002400); ans_temp[ans_id*36+3]+=Pmtrx[0]*(P_022000000*QR_012000010000+P_122000000*QR_012000010100+P_222000000*QR_012000010200+P_322000000*QR_012000010300+P_422000000*QR_012000010400); ans_temp[ans_id*36+3]+=Pmtrx[1]*(P_022000000*QR_011001010000+P_122000000*QR_011001010100+P_222000000*QR_011001010200+P_322000000*QR_011001010300+P_422000000*QR_011001010400); ans_temp[ans_id*36+3]+=Pmtrx[2]*(P_022000000*QR_010002010000+P_122000000*QR_010002010100+P_222000000*QR_010002010200+P_322000000*QR_010002010300+P_422000000*QR_010002010400); ans_temp[ans_id*36+3]+=Pmtrx[3]*(P_022000000*QR_011000011000+P_122000000*QR_011000011100+P_222000000*QR_011000011200+P_322000000*QR_011000011300+P_422000000*QR_011000011400); ans_temp[ans_id*36+3]+=Pmtrx[4]*(P_022000000*QR_010001011000+P_122000000*QR_010001011100+P_222000000*QR_010001011200+P_322000000*QR_010001011300+P_422000000*QR_010001011400); ans_temp[ans_id*36+3]+=Pmtrx[5]*(P_022000000*QR_010000012000+P_122000000*QR_010000012100+P_222000000*QR_010000012200+P_322000000*QR_010000012300+P_422000000*QR_010000012400); ans_temp[ans_id*36+4]+=Pmtrx[0]*(P_022000000*QR_002010010000+P_122000000*QR_002010010100+P_222000000*QR_002010010200+P_322000000*QR_002010010300+P_422000000*QR_002010010400); ans_temp[ans_id*36+4]+=Pmtrx[1]*(P_022000000*QR_001011010000+P_122000000*QR_001011010100+P_222000000*QR_001011010200+P_322000000*QR_001011010300+P_422000000*QR_001011010400); ans_temp[ans_id*36+4]+=Pmtrx[2]*(P_022000000*QR_000012010000+P_122000000*QR_000012010100+P_222000000*QR_000012010200+P_322000000*QR_000012010300+P_422000000*QR_000012010400); ans_temp[ans_id*36+4]+=Pmtrx[3]*(P_022000000*QR_001010011000+P_122000000*QR_001010011100+P_222000000*QR_001010011200+P_322000000*QR_001010011300+P_422000000*QR_001010011400); ans_temp[ans_id*36+4]+=Pmtrx[4]*(P_022000000*QR_000011011000+P_122000000*QR_000011011100+P_222000000*QR_000011011200+P_322000000*QR_000011011300+P_422000000*QR_000011011400); ans_temp[ans_id*36+4]+=Pmtrx[5]*(P_022000000*QR_000010012000+P_122000000*QR_000010012100+P_222000000*QR_000010012200+P_322000000*QR_000010012300+P_422000000*QR_000010012400); ans_temp[ans_id*36+5]+=Pmtrx[0]*(P_022000000*QR_002000020000+P_122000000*QR_002000020100+P_222000000*QR_002000020200+P_322000000*QR_002000020300+P_422000000*QR_002000020400); ans_temp[ans_id*36+5]+=Pmtrx[1]*(P_022000000*QR_001001020000+P_122000000*QR_001001020100+P_222000000*QR_001001020200+P_322000000*QR_001001020300+P_422000000*QR_001001020400); ans_temp[ans_id*36+5]+=Pmtrx[2]*(P_022000000*QR_000002020000+P_122000000*QR_000002020100+P_222000000*QR_000002020200+P_322000000*QR_000002020300+P_422000000*QR_000002020400); ans_temp[ans_id*36+5]+=Pmtrx[3]*(P_022000000*QR_001000021000+P_122000000*QR_001000021100+P_222000000*QR_001000021200+P_322000000*QR_001000021300+P_422000000*QR_001000021400); ans_temp[ans_id*36+5]+=Pmtrx[4]*(P_022000000*QR_000001021000+P_122000000*QR_000001021100+P_222000000*QR_000001021200+P_322000000*QR_000001021300+P_422000000*QR_000001021400); ans_temp[ans_id*36+5]+=Pmtrx[5]*(P_022000000*QR_000000022000+P_122000000*QR_000000022100+P_222000000*QR_000000022200+P_322000000*QR_000000022300+P_422000000*QR_000000022400); ans_temp[ans_id*36+0]+=Pmtrx[6]*(P_021001000*QR_022000000000+P_021101000*QR_022000000010+P_121001000*QR_022000000100+P_121101000*QR_022000000110+P_221001000*QR_022000000200+P_221101000*QR_022000000210+P_321001000*QR_022000000300+P_321101000*QR_022000000310); ans_temp[ans_id*36+0]+=Pmtrx[7]*(P_021001000*QR_021001000000+P_021101000*QR_021001000010+P_121001000*QR_021001000100+P_121101000*QR_021001000110+P_221001000*QR_021001000200+P_221101000*QR_021001000210+P_321001000*QR_021001000300+P_321101000*QR_021001000310); ans_temp[ans_id*36+0]+=Pmtrx[8]*(P_021001000*QR_020002000000+P_021101000*QR_020002000010+P_121001000*QR_020002000100+P_121101000*QR_020002000110+P_221001000*QR_020002000200+P_221101000*QR_020002000210+P_321001000*QR_020002000300+P_321101000*QR_020002000310); ans_temp[ans_id*36+0]+=Pmtrx[9]*(P_021001000*QR_021000001000+P_021101000*QR_021000001010+P_121001000*QR_021000001100+P_121101000*QR_021000001110+P_221001000*QR_021000001200+P_221101000*QR_021000001210+P_321001000*QR_021000001300+P_321101000*QR_021000001310); ans_temp[ans_id*36+0]+=Pmtrx[10]*(P_021001000*QR_020001001000+P_021101000*QR_020001001010+P_121001000*QR_020001001100+P_121101000*QR_020001001110+P_221001000*QR_020001001200+P_221101000*QR_020001001210+P_321001000*QR_020001001300+P_321101000*QR_020001001310); ans_temp[ans_id*36+0]+=Pmtrx[11]*(P_021001000*QR_020000002000+P_021101000*QR_020000002010+P_121001000*QR_020000002100+P_121101000*QR_020000002110+P_221001000*QR_020000002200+P_221101000*QR_020000002210+P_321001000*QR_020000002300+P_321101000*QR_020000002310); ans_temp[ans_id*36+1]+=Pmtrx[6]*(P_021001000*QR_012010000000+P_021101000*QR_012010000010+P_121001000*QR_012010000100+P_121101000*QR_012010000110+P_221001000*QR_012010000200+P_221101000*QR_012010000210+P_321001000*QR_012010000300+P_321101000*QR_012010000310); ans_temp[ans_id*36+1]+=Pmtrx[7]*(P_021001000*QR_011011000000+P_021101000*QR_011011000010+P_121001000*QR_011011000100+P_121101000*QR_011011000110+P_221001000*QR_011011000200+P_221101000*QR_011011000210+P_321001000*QR_011011000300+P_321101000*QR_011011000310); ans_temp[ans_id*36+1]+=Pmtrx[8]*(P_021001000*QR_010012000000+P_021101000*QR_010012000010+P_121001000*QR_010012000100+P_121101000*QR_010012000110+P_221001000*QR_010012000200+P_221101000*QR_010012000210+P_321001000*QR_010012000300+P_321101000*QR_010012000310); ans_temp[ans_id*36+1]+=Pmtrx[9]*(P_021001000*QR_011010001000+P_021101000*QR_011010001010+P_121001000*QR_011010001100+P_121101000*QR_011010001110+P_221001000*QR_011010001200+P_221101000*QR_011010001210+P_321001000*QR_011010001300+P_321101000*QR_011010001310); ans_temp[ans_id*36+1]+=Pmtrx[10]*(P_021001000*QR_010011001000+P_021101000*QR_010011001010+P_121001000*QR_010011001100+P_121101000*QR_010011001110+P_221001000*QR_010011001200+P_221101000*QR_010011001210+P_321001000*QR_010011001300+P_321101000*QR_010011001310); ans_temp[ans_id*36+1]+=Pmtrx[11]*(P_021001000*QR_010010002000+P_021101000*QR_010010002010+P_121001000*QR_010010002100+P_121101000*QR_010010002110+P_221001000*QR_010010002200+P_221101000*QR_010010002210+P_321001000*QR_010010002300+P_321101000*QR_010010002310); ans_temp[ans_id*36+2]+=Pmtrx[6]*(P_021001000*QR_002020000000+P_021101000*QR_002020000010+P_121001000*QR_002020000100+P_121101000*QR_002020000110+P_221001000*QR_002020000200+P_221101000*QR_002020000210+P_321001000*QR_002020000300+P_321101000*QR_002020000310); ans_temp[ans_id*36+2]+=Pmtrx[7]*(P_021001000*QR_001021000000+P_021101000*QR_001021000010+P_121001000*QR_001021000100+P_121101000*QR_001021000110+P_221001000*QR_001021000200+P_221101000*QR_001021000210+P_321001000*QR_001021000300+P_321101000*QR_001021000310); ans_temp[ans_id*36+2]+=Pmtrx[8]*(P_021001000*QR_000022000000+P_021101000*QR_000022000010+P_121001000*QR_000022000100+P_121101000*QR_000022000110+P_221001000*QR_000022000200+P_221101000*QR_000022000210+P_321001000*QR_000022000300+P_321101000*QR_000022000310); ans_temp[ans_id*36+2]+=Pmtrx[9]*(P_021001000*QR_001020001000+P_021101000*QR_001020001010+P_121001000*QR_001020001100+P_121101000*QR_001020001110+P_221001000*QR_001020001200+P_221101000*QR_001020001210+P_321001000*QR_001020001300+P_321101000*QR_001020001310); ans_temp[ans_id*36+2]+=Pmtrx[10]*(P_021001000*QR_000021001000+P_021101000*QR_000021001010+P_121001000*QR_000021001100+P_121101000*QR_000021001110+P_221001000*QR_000021001200+P_221101000*QR_000021001210+P_321001000*QR_000021001300+P_321101000*QR_000021001310); ans_temp[ans_id*36+2]+=Pmtrx[11]*(P_021001000*QR_000020002000+P_021101000*QR_000020002010+P_121001000*QR_000020002100+P_121101000*QR_000020002110+P_221001000*QR_000020002200+P_221101000*QR_000020002210+P_321001000*QR_000020002300+P_321101000*QR_000020002310); ans_temp[ans_id*36+3]+=Pmtrx[6]*(P_021001000*QR_012000010000+P_021101000*QR_012000010010+P_121001000*QR_012000010100+P_121101000*QR_012000010110+P_221001000*QR_012000010200+P_221101000*QR_012000010210+P_321001000*QR_012000010300+P_321101000*QR_012000010310); ans_temp[ans_id*36+3]+=Pmtrx[7]*(P_021001000*QR_011001010000+P_021101000*QR_011001010010+P_121001000*QR_011001010100+P_121101000*QR_011001010110+P_221001000*QR_011001010200+P_221101000*QR_011001010210+P_321001000*QR_011001010300+P_321101000*QR_011001010310); ans_temp[ans_id*36+3]+=Pmtrx[8]*(P_021001000*QR_010002010000+P_021101000*QR_010002010010+P_121001000*QR_010002010100+P_121101000*QR_010002010110+P_221001000*QR_010002010200+P_221101000*QR_010002010210+P_321001000*QR_010002010300+P_321101000*QR_010002010310); ans_temp[ans_id*36+3]+=Pmtrx[9]*(P_021001000*QR_011000011000+P_021101000*QR_011000011010+P_121001000*QR_011000011100+P_121101000*QR_011000011110+P_221001000*QR_011000011200+P_221101000*QR_011000011210+P_321001000*QR_011000011300+P_321101000*QR_011000011310); ans_temp[ans_id*36+3]+=Pmtrx[10]*(P_021001000*QR_010001011000+P_021101000*QR_010001011010+P_121001000*QR_010001011100+P_121101000*QR_010001011110+P_221001000*QR_010001011200+P_221101000*QR_010001011210+P_321001000*QR_010001011300+P_321101000*QR_010001011310); ans_temp[ans_id*36+3]+=Pmtrx[11]*(P_021001000*QR_010000012000+P_021101000*QR_010000012010+P_121001000*QR_010000012100+P_121101000*QR_010000012110+P_221001000*QR_010000012200+P_221101000*QR_010000012210+P_321001000*QR_010000012300+P_321101000*QR_010000012310); ans_temp[ans_id*36+4]+=Pmtrx[6]*(P_021001000*QR_002010010000+P_021101000*QR_002010010010+P_121001000*QR_002010010100+P_121101000*QR_002010010110+P_221001000*QR_002010010200+P_221101000*QR_002010010210+P_321001000*QR_002010010300+P_321101000*QR_002010010310); ans_temp[ans_id*36+4]+=Pmtrx[7]*(P_021001000*QR_001011010000+P_021101000*QR_001011010010+P_121001000*QR_001011010100+P_121101000*QR_001011010110+P_221001000*QR_001011010200+P_221101000*QR_001011010210+P_321001000*QR_001011010300+P_321101000*QR_001011010310); ans_temp[ans_id*36+4]+=Pmtrx[8]*(P_021001000*QR_000012010000+P_021101000*QR_000012010010+P_121001000*QR_000012010100+P_121101000*QR_000012010110+P_221001000*QR_000012010200+P_221101000*QR_000012010210+P_321001000*QR_000012010300+P_321101000*QR_000012010310); ans_temp[ans_id*36+4]+=Pmtrx[9]*(P_021001000*QR_001010011000+P_021101000*QR_001010011010+P_121001000*QR_001010011100+P_121101000*QR_001010011110+P_221001000*QR_001010011200+P_221101000*QR_001010011210+P_321001000*QR_001010011300+P_321101000*QR_001010011310); ans_temp[ans_id*36+4]+=Pmtrx[10]*(P_021001000*QR_000011011000+P_021101000*QR_000011011010+P_121001000*QR_000011011100+P_121101000*QR_000011011110+P_221001000*QR_000011011200+P_221101000*QR_000011011210+P_321001000*QR_000011011300+P_321101000*QR_000011011310); ans_temp[ans_id*36+4]+=Pmtrx[11]*(P_021001000*QR_000010012000+P_021101000*QR_000010012010+P_121001000*QR_000010012100+P_121101000*QR_000010012110+P_221001000*QR_000010012200+P_221101000*QR_000010012210+P_321001000*QR_000010012300+P_321101000*QR_000010012310); ans_temp[ans_id*36+5]+=Pmtrx[6]*(P_021001000*QR_002000020000+P_021101000*QR_002000020010+P_121001000*QR_002000020100+P_121101000*QR_002000020110+P_221001000*QR_002000020200+P_221101000*QR_002000020210+P_321001000*QR_002000020300+P_321101000*QR_002000020310); ans_temp[ans_id*36+5]+=Pmtrx[7]*(P_021001000*QR_001001020000+P_021101000*QR_001001020010+P_121001000*QR_001001020100+P_121101000*QR_001001020110+P_221001000*QR_001001020200+P_221101000*QR_001001020210+P_321001000*QR_001001020300+P_321101000*QR_001001020310); ans_temp[ans_id*36+5]+=Pmtrx[8]*(P_021001000*QR_000002020000+P_021101000*QR_000002020010+P_121001000*QR_000002020100+P_121101000*QR_000002020110+P_221001000*QR_000002020200+P_221101000*QR_000002020210+P_321001000*QR_000002020300+P_321101000*QR_000002020310); ans_temp[ans_id*36+5]+=Pmtrx[9]*(P_021001000*QR_001000021000+P_021101000*QR_001000021010+P_121001000*QR_001000021100+P_121101000*QR_001000021110+P_221001000*QR_001000021200+P_221101000*QR_001000021210+P_321001000*QR_001000021300+P_321101000*QR_001000021310); ans_temp[ans_id*36+5]+=Pmtrx[10]*(P_021001000*QR_000001021000+P_021101000*QR_000001021010+P_121001000*QR_000001021100+P_121101000*QR_000001021110+P_221001000*QR_000001021200+P_221101000*QR_000001021210+P_321001000*QR_000001021300+P_321101000*QR_000001021310); ans_temp[ans_id*36+5]+=Pmtrx[11]*(P_021001000*QR_000000022000+P_021101000*QR_000000022010+P_121001000*QR_000000022100+P_121101000*QR_000000022110+P_221001000*QR_000000022200+P_221101000*QR_000000022210+P_321001000*QR_000000022300+P_321101000*QR_000000022310); ans_temp[ans_id*36+0]+=Pmtrx[12]*(P_020002000*QR_022000000000+P_020102000*QR_022000000010+P_020202000*QR_022000000020+P_120002000*QR_022000000100+P_120102000*QR_022000000110+P_120202000*QR_022000000120+P_220002000*QR_022000000200+P_220102000*QR_022000000210+P_220202000*QR_022000000220); ans_temp[ans_id*36+0]+=Pmtrx[13]*(P_020002000*QR_021001000000+P_020102000*QR_021001000010+P_020202000*QR_021001000020+P_120002000*QR_021001000100+P_120102000*QR_021001000110+P_120202000*QR_021001000120+P_220002000*QR_021001000200+P_220102000*QR_021001000210+P_220202000*QR_021001000220); ans_temp[ans_id*36+0]+=Pmtrx[14]*(P_020002000*QR_020002000000+P_020102000*QR_020002000010+P_020202000*QR_020002000020+P_120002000*QR_020002000100+P_120102000*QR_020002000110+P_120202000*QR_020002000120+P_220002000*QR_020002000200+P_220102000*QR_020002000210+P_220202000*QR_020002000220); ans_temp[ans_id*36+0]+=Pmtrx[15]*(P_020002000*QR_021000001000+P_020102000*QR_021000001010+P_020202000*QR_021000001020+P_120002000*QR_021000001100+P_120102000*QR_021000001110+P_120202000*QR_021000001120+P_220002000*QR_021000001200+P_220102000*QR_021000001210+P_220202000*QR_021000001220); ans_temp[ans_id*36+0]+=Pmtrx[16]*(P_020002000*QR_020001001000+P_020102000*QR_020001001010+P_020202000*QR_020001001020+P_120002000*QR_020001001100+P_120102000*QR_020001001110+P_120202000*QR_020001001120+P_220002000*QR_020001001200+P_220102000*QR_020001001210+P_220202000*QR_020001001220); ans_temp[ans_id*36+0]+=Pmtrx[17]*(P_020002000*QR_020000002000+P_020102000*QR_020000002010+P_020202000*QR_020000002020+P_120002000*QR_020000002100+P_120102000*QR_020000002110+P_120202000*QR_020000002120+P_220002000*QR_020000002200+P_220102000*QR_020000002210+P_220202000*QR_020000002220); ans_temp[ans_id*36+1]+=Pmtrx[12]*(P_020002000*QR_012010000000+P_020102000*QR_012010000010+P_020202000*QR_012010000020+P_120002000*QR_012010000100+P_120102000*QR_012010000110+P_120202000*QR_012010000120+P_220002000*QR_012010000200+P_220102000*QR_012010000210+P_220202000*QR_012010000220); ans_temp[ans_id*36+1]+=Pmtrx[13]*(P_020002000*QR_011011000000+P_020102000*QR_011011000010+P_020202000*QR_011011000020+P_120002000*QR_011011000100+P_120102000*QR_011011000110+P_120202000*QR_011011000120+P_220002000*QR_011011000200+P_220102000*QR_011011000210+P_220202000*QR_011011000220); ans_temp[ans_id*36+1]+=Pmtrx[14]*(P_020002000*QR_010012000000+P_020102000*QR_010012000010+P_020202000*QR_010012000020+P_120002000*QR_010012000100+P_120102000*QR_010012000110+P_120202000*QR_010012000120+P_220002000*QR_010012000200+P_220102000*QR_010012000210+P_220202000*QR_010012000220); ans_temp[ans_id*36+1]+=Pmtrx[15]*(P_020002000*QR_011010001000+P_020102000*QR_011010001010+P_020202000*QR_011010001020+P_120002000*QR_011010001100+P_120102000*QR_011010001110+P_120202000*QR_011010001120+P_220002000*QR_011010001200+P_220102000*QR_011010001210+P_220202000*QR_011010001220); ans_temp[ans_id*36+1]+=Pmtrx[16]*(P_020002000*QR_010011001000+P_020102000*QR_010011001010+P_020202000*QR_010011001020+P_120002000*QR_010011001100+P_120102000*QR_010011001110+P_120202000*QR_010011001120+P_220002000*QR_010011001200+P_220102000*QR_010011001210+P_220202000*QR_010011001220); ans_temp[ans_id*36+1]+=Pmtrx[17]*(P_020002000*QR_010010002000+P_020102000*QR_010010002010+P_020202000*QR_010010002020+P_120002000*QR_010010002100+P_120102000*QR_010010002110+P_120202000*QR_010010002120+P_220002000*QR_010010002200+P_220102000*QR_010010002210+P_220202000*QR_010010002220); ans_temp[ans_id*36+2]+=Pmtrx[12]*(P_020002000*QR_002020000000+P_020102000*QR_002020000010+P_020202000*QR_002020000020+P_120002000*QR_002020000100+P_120102000*QR_002020000110+P_120202000*QR_002020000120+P_220002000*QR_002020000200+P_220102000*QR_002020000210+P_220202000*QR_002020000220); ans_temp[ans_id*36+2]+=Pmtrx[13]*(P_020002000*QR_001021000000+P_020102000*QR_001021000010+P_020202000*QR_001021000020+P_120002000*QR_001021000100+P_120102000*QR_001021000110+P_120202000*QR_001021000120+P_220002000*QR_001021000200+P_220102000*QR_001021000210+P_220202000*QR_001021000220); ans_temp[ans_id*36+2]+=Pmtrx[14]*(P_020002000*QR_000022000000+P_020102000*QR_000022000010+P_020202000*QR_000022000020+P_120002000*QR_000022000100+P_120102000*QR_000022000110+P_120202000*QR_000022000120+P_220002000*QR_000022000200+P_220102000*QR_000022000210+P_220202000*QR_000022000220); ans_temp[ans_id*36+2]+=Pmtrx[15]*(P_020002000*QR_001020001000+P_020102000*QR_001020001010+P_020202000*QR_001020001020+P_120002000*QR_001020001100+P_120102000*QR_001020001110+P_120202000*QR_001020001120+P_220002000*QR_001020001200+P_220102000*QR_001020001210+P_220202000*QR_001020001220); ans_temp[ans_id*36+2]+=Pmtrx[16]*(P_020002000*QR_000021001000+P_020102000*QR_000021001010+P_020202000*QR_000021001020+P_120002000*QR_000021001100+P_120102000*QR_000021001110+P_120202000*QR_000021001120+P_220002000*QR_000021001200+P_220102000*QR_000021001210+P_220202000*QR_000021001220); ans_temp[ans_id*36+2]+=Pmtrx[17]*(P_020002000*QR_000020002000+P_020102000*QR_000020002010+P_020202000*QR_000020002020+P_120002000*QR_000020002100+P_120102000*QR_000020002110+P_120202000*QR_000020002120+P_220002000*QR_000020002200+P_220102000*QR_000020002210+P_220202000*QR_000020002220); ans_temp[ans_id*36+3]+=Pmtrx[12]*(P_020002000*QR_012000010000+P_020102000*QR_012000010010+P_020202000*QR_012000010020+P_120002000*QR_012000010100+P_120102000*QR_012000010110+P_120202000*QR_012000010120+P_220002000*QR_012000010200+P_220102000*QR_012000010210+P_220202000*QR_012000010220); ans_temp[ans_id*36+3]+=Pmtrx[13]*(P_020002000*QR_011001010000+P_020102000*QR_011001010010+P_020202000*QR_011001010020+P_120002000*QR_011001010100+P_120102000*QR_011001010110+P_120202000*QR_011001010120+P_220002000*QR_011001010200+P_220102000*QR_011001010210+P_220202000*QR_011001010220); ans_temp[ans_id*36+3]+=Pmtrx[14]*(P_020002000*QR_010002010000+P_020102000*QR_010002010010+P_020202000*QR_010002010020+P_120002000*QR_010002010100+P_120102000*QR_010002010110+P_120202000*QR_010002010120+P_220002000*QR_010002010200+P_220102000*QR_010002010210+P_220202000*QR_010002010220); ans_temp[ans_id*36+3]+=Pmtrx[15]*(P_020002000*QR_011000011000+P_020102000*QR_011000011010+P_020202000*QR_011000011020+P_120002000*QR_011000011100+P_120102000*QR_011000011110+P_120202000*QR_011000011120+P_220002000*QR_011000011200+P_220102000*QR_011000011210+P_220202000*QR_011000011220); ans_temp[ans_id*36+3]+=Pmtrx[16]*(P_020002000*QR_010001011000+P_020102000*QR_010001011010+P_020202000*QR_010001011020+P_120002000*QR_010001011100+P_120102000*QR_010001011110+P_120202000*QR_010001011120+P_220002000*QR_010001011200+P_220102000*QR_010001011210+P_220202000*QR_010001011220); ans_temp[ans_id*36+3]+=Pmtrx[17]*(P_020002000*QR_010000012000+P_020102000*QR_010000012010+P_020202000*QR_010000012020+P_120002000*QR_010000012100+P_120102000*QR_010000012110+P_120202000*QR_010000012120+P_220002000*QR_010000012200+P_220102000*QR_010000012210+P_220202000*QR_010000012220); ans_temp[ans_id*36+4]+=Pmtrx[12]*(P_020002000*QR_002010010000+P_020102000*QR_002010010010+P_020202000*QR_002010010020+P_120002000*QR_002010010100+P_120102000*QR_002010010110+P_120202000*QR_002010010120+P_220002000*QR_002010010200+P_220102000*QR_002010010210+P_220202000*QR_002010010220); ans_temp[ans_id*36+4]+=Pmtrx[13]*(P_020002000*QR_001011010000+P_020102000*QR_001011010010+P_020202000*QR_001011010020+P_120002000*QR_001011010100+P_120102000*QR_001011010110+P_120202000*QR_001011010120+P_220002000*QR_001011010200+P_220102000*QR_001011010210+P_220202000*QR_001011010220); ans_temp[ans_id*36+4]+=Pmtrx[14]*(P_020002000*QR_000012010000+P_020102000*QR_000012010010+P_020202000*QR_000012010020+P_120002000*QR_000012010100+P_120102000*QR_000012010110+P_120202000*QR_000012010120+P_220002000*QR_000012010200+P_220102000*QR_000012010210+P_220202000*QR_000012010220); ans_temp[ans_id*36+4]+=Pmtrx[15]*(P_020002000*QR_001010011000+P_020102000*QR_001010011010+P_020202000*QR_001010011020+P_120002000*QR_001010011100+P_120102000*QR_001010011110+P_120202000*QR_001010011120+P_220002000*QR_001010011200+P_220102000*QR_001010011210+P_220202000*QR_001010011220); ans_temp[ans_id*36+4]+=Pmtrx[16]*(P_020002000*QR_000011011000+P_020102000*QR_000011011010+P_020202000*QR_000011011020+P_120002000*QR_000011011100+P_120102000*QR_000011011110+P_120202000*QR_000011011120+P_220002000*QR_000011011200+P_220102000*QR_000011011210+P_220202000*QR_000011011220); ans_temp[ans_id*36+4]+=Pmtrx[17]*(P_020002000*QR_000010012000+P_020102000*QR_000010012010+P_020202000*QR_000010012020+P_120002000*QR_000010012100+P_120102000*QR_000010012110+P_120202000*QR_000010012120+P_220002000*QR_000010012200+P_220102000*QR_000010012210+P_220202000*QR_000010012220); ans_temp[ans_id*36+5]+=Pmtrx[12]*(P_020002000*QR_002000020000+P_020102000*QR_002000020010+P_020202000*QR_002000020020+P_120002000*QR_002000020100+P_120102000*QR_002000020110+P_120202000*QR_002000020120+P_220002000*QR_002000020200+P_220102000*QR_002000020210+P_220202000*QR_002000020220); ans_temp[ans_id*36+5]+=Pmtrx[13]*(P_020002000*QR_001001020000+P_020102000*QR_001001020010+P_020202000*QR_001001020020+P_120002000*QR_001001020100+P_120102000*QR_001001020110+P_120202000*QR_001001020120+P_220002000*QR_001001020200+P_220102000*QR_001001020210+P_220202000*QR_001001020220); ans_temp[ans_id*36+5]+=Pmtrx[14]*(P_020002000*QR_000002020000+P_020102000*QR_000002020010+P_020202000*QR_000002020020+P_120002000*QR_000002020100+P_120102000*QR_000002020110+P_120202000*QR_000002020120+P_220002000*QR_000002020200+P_220102000*QR_000002020210+P_220202000*QR_000002020220); ans_temp[ans_id*36+5]+=Pmtrx[15]*(P_020002000*QR_001000021000+P_020102000*QR_001000021010+P_020202000*QR_001000021020+P_120002000*QR_001000021100+P_120102000*QR_001000021110+P_120202000*QR_001000021120+P_220002000*QR_001000021200+P_220102000*QR_001000021210+P_220202000*QR_001000021220); ans_temp[ans_id*36+5]+=Pmtrx[16]*(P_020002000*QR_000001021000+P_020102000*QR_000001021010+P_020202000*QR_000001021020+P_120002000*QR_000001021100+P_120102000*QR_000001021110+P_120202000*QR_000001021120+P_220002000*QR_000001021200+P_220102000*QR_000001021210+P_220202000*QR_000001021220); ans_temp[ans_id*36+5]+=Pmtrx[17]*(P_020002000*QR_000000022000+P_020102000*QR_000000022010+P_020202000*QR_000000022020+P_120002000*QR_000000022100+P_120102000*QR_000000022110+P_120202000*QR_000000022120+P_220002000*QR_000000022200+P_220102000*QR_000000022210+P_220202000*QR_000000022220); ans_temp[ans_id*36+0]+=Pmtrx[18]*(P_021000001*QR_022000000000+P_021000101*QR_022000000001+P_121000001*QR_022000000100+P_121000101*QR_022000000101+P_221000001*QR_022000000200+P_221000101*QR_022000000201+P_321000001*QR_022000000300+P_321000101*QR_022000000301); ans_temp[ans_id*36+0]+=Pmtrx[19]*(P_021000001*QR_021001000000+P_021000101*QR_021001000001+P_121000001*QR_021001000100+P_121000101*QR_021001000101+P_221000001*QR_021001000200+P_221000101*QR_021001000201+P_321000001*QR_021001000300+P_321000101*QR_021001000301); ans_temp[ans_id*36+0]+=Pmtrx[20]*(P_021000001*QR_020002000000+P_021000101*QR_020002000001+P_121000001*QR_020002000100+P_121000101*QR_020002000101+P_221000001*QR_020002000200+P_221000101*QR_020002000201+P_321000001*QR_020002000300+P_321000101*QR_020002000301); ans_temp[ans_id*36+0]+=Pmtrx[21]*(P_021000001*QR_021000001000+P_021000101*QR_021000001001+P_121000001*QR_021000001100+P_121000101*QR_021000001101+P_221000001*QR_021000001200+P_221000101*QR_021000001201+P_321000001*QR_021000001300+P_321000101*QR_021000001301); ans_temp[ans_id*36+0]+=Pmtrx[22]*(P_021000001*QR_020001001000+P_021000101*QR_020001001001+P_121000001*QR_020001001100+P_121000101*QR_020001001101+P_221000001*QR_020001001200+P_221000101*QR_020001001201+P_321000001*QR_020001001300+P_321000101*QR_020001001301); ans_temp[ans_id*36+0]+=Pmtrx[23]*(P_021000001*QR_020000002000+P_021000101*QR_020000002001+P_121000001*QR_020000002100+P_121000101*QR_020000002101+P_221000001*QR_020000002200+P_221000101*QR_020000002201+P_321000001*QR_020000002300+P_321000101*QR_020000002301); ans_temp[ans_id*36+1]+=Pmtrx[18]*(P_021000001*QR_012010000000+P_021000101*QR_012010000001+P_121000001*QR_012010000100+P_121000101*QR_012010000101+P_221000001*QR_012010000200+P_221000101*QR_012010000201+P_321000001*QR_012010000300+P_321000101*QR_012010000301); ans_temp[ans_id*36+1]+=Pmtrx[19]*(P_021000001*QR_011011000000+P_021000101*QR_011011000001+P_121000001*QR_011011000100+P_121000101*QR_011011000101+P_221000001*QR_011011000200+P_221000101*QR_011011000201+P_321000001*QR_011011000300+P_321000101*QR_011011000301); ans_temp[ans_id*36+1]+=Pmtrx[20]*(P_021000001*QR_010012000000+P_021000101*QR_010012000001+P_121000001*QR_010012000100+P_121000101*QR_010012000101+P_221000001*QR_010012000200+P_221000101*QR_010012000201+P_321000001*QR_010012000300+P_321000101*QR_010012000301); ans_temp[ans_id*36+1]+=Pmtrx[21]*(P_021000001*QR_011010001000+P_021000101*QR_011010001001+P_121000001*QR_011010001100+P_121000101*QR_011010001101+P_221000001*QR_011010001200+P_221000101*QR_011010001201+P_321000001*QR_011010001300+P_321000101*QR_011010001301); ans_temp[ans_id*36+1]+=Pmtrx[22]*(P_021000001*QR_010011001000+P_021000101*QR_010011001001+P_121000001*QR_010011001100+P_121000101*QR_010011001101+P_221000001*QR_010011001200+P_221000101*QR_010011001201+P_321000001*QR_010011001300+P_321000101*QR_010011001301); ans_temp[ans_id*36+1]+=Pmtrx[23]*(P_021000001*QR_010010002000+P_021000101*QR_010010002001+P_121000001*QR_010010002100+P_121000101*QR_010010002101+P_221000001*QR_010010002200+P_221000101*QR_010010002201+P_321000001*QR_010010002300+P_321000101*QR_010010002301); ans_temp[ans_id*36+2]+=Pmtrx[18]*(P_021000001*QR_002020000000+P_021000101*QR_002020000001+P_121000001*QR_002020000100+P_121000101*QR_002020000101+P_221000001*QR_002020000200+P_221000101*QR_002020000201+P_321000001*QR_002020000300+P_321000101*QR_002020000301); ans_temp[ans_id*36+2]+=Pmtrx[19]*(P_021000001*QR_001021000000+P_021000101*QR_001021000001+P_121000001*QR_001021000100+P_121000101*QR_001021000101+P_221000001*QR_001021000200+P_221000101*QR_001021000201+P_321000001*QR_001021000300+P_321000101*QR_001021000301); ans_temp[ans_id*36+2]+=Pmtrx[20]*(P_021000001*QR_000022000000+P_021000101*QR_000022000001+P_121000001*QR_000022000100+P_121000101*QR_000022000101+P_221000001*QR_000022000200+P_221000101*QR_000022000201+P_321000001*QR_000022000300+P_321000101*QR_000022000301); ans_temp[ans_id*36+2]+=Pmtrx[21]*(P_021000001*QR_001020001000+P_021000101*QR_001020001001+P_121000001*QR_001020001100+P_121000101*QR_001020001101+P_221000001*QR_001020001200+P_221000101*QR_001020001201+P_321000001*QR_001020001300+P_321000101*QR_001020001301); ans_temp[ans_id*36+2]+=Pmtrx[22]*(P_021000001*QR_000021001000+P_021000101*QR_000021001001+P_121000001*QR_000021001100+P_121000101*QR_000021001101+P_221000001*QR_000021001200+P_221000101*QR_000021001201+P_321000001*QR_000021001300+P_321000101*QR_000021001301); ans_temp[ans_id*36+2]+=Pmtrx[23]*(P_021000001*QR_000020002000+P_021000101*QR_000020002001+P_121000001*QR_000020002100+P_121000101*QR_000020002101+P_221000001*QR_000020002200+P_221000101*QR_000020002201+P_321000001*QR_000020002300+P_321000101*QR_000020002301); ans_temp[ans_id*36+3]+=Pmtrx[18]*(P_021000001*QR_012000010000+P_021000101*QR_012000010001+P_121000001*QR_012000010100+P_121000101*QR_012000010101+P_221000001*QR_012000010200+P_221000101*QR_012000010201+P_321000001*QR_012000010300+P_321000101*QR_012000010301); ans_temp[ans_id*36+3]+=Pmtrx[19]*(P_021000001*QR_011001010000+P_021000101*QR_011001010001+P_121000001*QR_011001010100+P_121000101*QR_011001010101+P_221000001*QR_011001010200+P_221000101*QR_011001010201+P_321000001*QR_011001010300+P_321000101*QR_011001010301); ans_temp[ans_id*36+3]+=Pmtrx[20]*(P_021000001*QR_010002010000+P_021000101*QR_010002010001+P_121000001*QR_010002010100+P_121000101*QR_010002010101+P_221000001*QR_010002010200+P_221000101*QR_010002010201+P_321000001*QR_010002010300+P_321000101*QR_010002010301); ans_temp[ans_id*36+3]+=Pmtrx[21]*(P_021000001*QR_011000011000+P_021000101*QR_011000011001+P_121000001*QR_011000011100+P_121000101*QR_011000011101+P_221000001*QR_011000011200+P_221000101*QR_011000011201+P_321000001*QR_011000011300+P_321000101*QR_011000011301); ans_temp[ans_id*36+3]+=Pmtrx[22]*(P_021000001*QR_010001011000+P_021000101*QR_010001011001+P_121000001*QR_010001011100+P_121000101*QR_010001011101+P_221000001*QR_010001011200+P_221000101*QR_010001011201+P_321000001*QR_010001011300+P_321000101*QR_010001011301); ans_temp[ans_id*36+3]+=Pmtrx[23]*(P_021000001*QR_010000012000+P_021000101*QR_010000012001+P_121000001*QR_010000012100+P_121000101*QR_010000012101+P_221000001*QR_010000012200+P_221000101*QR_010000012201+P_321000001*QR_010000012300+P_321000101*QR_010000012301); ans_temp[ans_id*36+4]+=Pmtrx[18]*(P_021000001*QR_002010010000+P_021000101*QR_002010010001+P_121000001*QR_002010010100+P_121000101*QR_002010010101+P_221000001*QR_002010010200+P_221000101*QR_002010010201+P_321000001*QR_002010010300+P_321000101*QR_002010010301); ans_temp[ans_id*36+4]+=Pmtrx[19]*(P_021000001*QR_001011010000+P_021000101*QR_001011010001+P_121000001*QR_001011010100+P_121000101*QR_001011010101+P_221000001*QR_001011010200+P_221000101*QR_001011010201+P_321000001*QR_001011010300+P_321000101*QR_001011010301); ans_temp[ans_id*36+4]+=Pmtrx[20]*(P_021000001*QR_000012010000+P_021000101*QR_000012010001+P_121000001*QR_000012010100+P_121000101*QR_000012010101+P_221000001*QR_000012010200+P_221000101*QR_000012010201+P_321000001*QR_000012010300+P_321000101*QR_000012010301); ans_temp[ans_id*36+4]+=Pmtrx[21]*(P_021000001*QR_001010011000+P_021000101*QR_001010011001+P_121000001*QR_001010011100+P_121000101*QR_001010011101+P_221000001*QR_001010011200+P_221000101*QR_001010011201+P_321000001*QR_001010011300+P_321000101*QR_001010011301); ans_temp[ans_id*36+4]+=Pmtrx[22]*(P_021000001*QR_000011011000+P_021000101*QR_000011011001+P_121000001*QR_000011011100+P_121000101*QR_000011011101+P_221000001*QR_000011011200+P_221000101*QR_000011011201+P_321000001*QR_000011011300+P_321000101*QR_000011011301); ans_temp[ans_id*36+4]+=Pmtrx[23]*(P_021000001*QR_000010012000+P_021000101*QR_000010012001+P_121000001*QR_000010012100+P_121000101*QR_000010012101+P_221000001*QR_000010012200+P_221000101*QR_000010012201+P_321000001*QR_000010012300+P_321000101*QR_000010012301); ans_temp[ans_id*36+5]+=Pmtrx[18]*(P_021000001*QR_002000020000+P_021000101*QR_002000020001+P_121000001*QR_002000020100+P_121000101*QR_002000020101+P_221000001*QR_002000020200+P_221000101*QR_002000020201+P_321000001*QR_002000020300+P_321000101*QR_002000020301); ans_temp[ans_id*36+5]+=Pmtrx[19]*(P_021000001*QR_001001020000+P_021000101*QR_001001020001+P_121000001*QR_001001020100+P_121000101*QR_001001020101+P_221000001*QR_001001020200+P_221000101*QR_001001020201+P_321000001*QR_001001020300+P_321000101*QR_001001020301); ans_temp[ans_id*36+5]+=Pmtrx[20]*(P_021000001*QR_000002020000+P_021000101*QR_000002020001+P_121000001*QR_000002020100+P_121000101*QR_000002020101+P_221000001*QR_000002020200+P_221000101*QR_000002020201+P_321000001*QR_000002020300+P_321000101*QR_000002020301); ans_temp[ans_id*36+5]+=Pmtrx[21]*(P_021000001*QR_001000021000+P_021000101*QR_001000021001+P_121000001*QR_001000021100+P_121000101*QR_001000021101+P_221000001*QR_001000021200+P_221000101*QR_001000021201+P_321000001*QR_001000021300+P_321000101*QR_001000021301); ans_temp[ans_id*36+5]+=Pmtrx[22]*(P_021000001*QR_000001021000+P_021000101*QR_000001021001+P_121000001*QR_000001021100+P_121000101*QR_000001021101+P_221000001*QR_000001021200+P_221000101*QR_000001021201+P_321000001*QR_000001021300+P_321000101*QR_000001021301); ans_temp[ans_id*36+5]+=Pmtrx[23]*(P_021000001*QR_000000022000+P_021000101*QR_000000022001+P_121000001*QR_000000022100+P_121000101*QR_000000022101+P_221000001*QR_000000022200+P_221000101*QR_000000022201+P_321000001*QR_000000022300+P_321000101*QR_000000022301); ans_temp[ans_id*36+0]+=Pmtrx[24]*(P_020001001*QR_022000000000+P_020001101*QR_022000000001+P_020101001*QR_022000000010+P_020101101*QR_022000000011+P_120001001*QR_022000000100+P_120001101*QR_022000000101+P_120101001*QR_022000000110+P_120101101*QR_022000000111+P_220001001*QR_022000000200+P_220001101*QR_022000000201+P_220101001*QR_022000000210+P_220101101*QR_022000000211); ans_temp[ans_id*36+0]+=Pmtrx[25]*(P_020001001*QR_021001000000+P_020001101*QR_021001000001+P_020101001*QR_021001000010+P_020101101*QR_021001000011+P_120001001*QR_021001000100+P_120001101*QR_021001000101+P_120101001*QR_021001000110+P_120101101*QR_021001000111+P_220001001*QR_021001000200+P_220001101*QR_021001000201+P_220101001*QR_021001000210+P_220101101*QR_021001000211); ans_temp[ans_id*36+0]+=Pmtrx[26]*(P_020001001*QR_020002000000+P_020001101*QR_020002000001+P_020101001*QR_020002000010+P_020101101*QR_020002000011+P_120001001*QR_020002000100+P_120001101*QR_020002000101+P_120101001*QR_020002000110+P_120101101*QR_020002000111+P_220001001*QR_020002000200+P_220001101*QR_020002000201+P_220101001*QR_020002000210+P_220101101*QR_020002000211); ans_temp[ans_id*36+0]+=Pmtrx[27]*(P_020001001*QR_021000001000+P_020001101*QR_021000001001+P_020101001*QR_021000001010+P_020101101*QR_021000001011+P_120001001*QR_021000001100+P_120001101*QR_021000001101+P_120101001*QR_021000001110+P_120101101*QR_021000001111+P_220001001*QR_021000001200+P_220001101*QR_021000001201+P_220101001*QR_021000001210+P_220101101*QR_021000001211); ans_temp[ans_id*36+0]+=Pmtrx[28]*(P_020001001*QR_020001001000+P_020001101*QR_020001001001+P_020101001*QR_020001001010+P_020101101*QR_020001001011+P_120001001*QR_020001001100+P_120001101*QR_020001001101+P_120101001*QR_020001001110+P_120101101*QR_020001001111+P_220001001*QR_020001001200+P_220001101*QR_020001001201+P_220101001*QR_020001001210+P_220101101*QR_020001001211); ans_temp[ans_id*36+0]+=Pmtrx[29]*(P_020001001*QR_020000002000+P_020001101*QR_020000002001+P_020101001*QR_020000002010+P_020101101*QR_020000002011+P_120001001*QR_020000002100+P_120001101*QR_020000002101+P_120101001*QR_020000002110+P_120101101*QR_020000002111+P_220001001*QR_020000002200+P_220001101*QR_020000002201+P_220101001*QR_020000002210+P_220101101*QR_020000002211); ans_temp[ans_id*36+1]+=Pmtrx[24]*(P_020001001*QR_012010000000+P_020001101*QR_012010000001+P_020101001*QR_012010000010+P_020101101*QR_012010000011+P_120001001*QR_012010000100+P_120001101*QR_012010000101+P_120101001*QR_012010000110+P_120101101*QR_012010000111+P_220001001*QR_012010000200+P_220001101*QR_012010000201+P_220101001*QR_012010000210+P_220101101*QR_012010000211); ans_temp[ans_id*36+1]+=Pmtrx[25]*(P_020001001*QR_011011000000+P_020001101*QR_011011000001+P_020101001*QR_011011000010+P_020101101*QR_011011000011+P_120001001*QR_011011000100+P_120001101*QR_011011000101+P_120101001*QR_011011000110+P_120101101*QR_011011000111+P_220001001*QR_011011000200+P_220001101*QR_011011000201+P_220101001*QR_011011000210+P_220101101*QR_011011000211); ans_temp[ans_id*36+1]+=Pmtrx[26]*(P_020001001*QR_010012000000+P_020001101*QR_010012000001+P_020101001*QR_010012000010+P_020101101*QR_010012000011+P_120001001*QR_010012000100+P_120001101*QR_010012000101+P_120101001*QR_010012000110+P_120101101*QR_010012000111+P_220001001*QR_010012000200+P_220001101*QR_010012000201+P_220101001*QR_010012000210+P_220101101*QR_010012000211); ans_temp[ans_id*36+1]+=Pmtrx[27]*(P_020001001*QR_011010001000+P_020001101*QR_011010001001+P_020101001*QR_011010001010+P_020101101*QR_011010001011+P_120001001*QR_011010001100+P_120001101*QR_011010001101+P_120101001*QR_011010001110+P_120101101*QR_011010001111+P_220001001*QR_011010001200+P_220001101*QR_011010001201+P_220101001*QR_011010001210+P_220101101*QR_011010001211); ans_temp[ans_id*36+1]+=Pmtrx[28]*(P_020001001*QR_010011001000+P_020001101*QR_010011001001+P_020101001*QR_010011001010+P_020101101*QR_010011001011+P_120001001*QR_010011001100+P_120001101*QR_010011001101+P_120101001*QR_010011001110+P_120101101*QR_010011001111+P_220001001*QR_010011001200+P_220001101*QR_010011001201+P_220101001*QR_010011001210+P_220101101*QR_010011001211); ans_temp[ans_id*36+1]+=Pmtrx[29]*(P_020001001*QR_010010002000+P_020001101*QR_010010002001+P_020101001*QR_010010002010+P_020101101*QR_010010002011+P_120001001*QR_010010002100+P_120001101*QR_010010002101+P_120101001*QR_010010002110+P_120101101*QR_010010002111+P_220001001*QR_010010002200+P_220001101*QR_010010002201+P_220101001*QR_010010002210+P_220101101*QR_010010002211); ans_temp[ans_id*36+2]+=Pmtrx[24]*(P_020001001*QR_002020000000+P_020001101*QR_002020000001+P_020101001*QR_002020000010+P_020101101*QR_002020000011+P_120001001*QR_002020000100+P_120001101*QR_002020000101+P_120101001*QR_002020000110+P_120101101*QR_002020000111+P_220001001*QR_002020000200+P_220001101*QR_002020000201+P_220101001*QR_002020000210+P_220101101*QR_002020000211); ans_temp[ans_id*36+2]+=Pmtrx[25]*(P_020001001*QR_001021000000+P_020001101*QR_001021000001+P_020101001*QR_001021000010+P_020101101*QR_001021000011+P_120001001*QR_001021000100+P_120001101*QR_001021000101+P_120101001*QR_001021000110+P_120101101*QR_001021000111+P_220001001*QR_001021000200+P_220001101*QR_001021000201+P_220101001*QR_001021000210+P_220101101*QR_001021000211); ans_temp[ans_id*36+2]+=Pmtrx[26]*(P_020001001*QR_000022000000+P_020001101*QR_000022000001+P_020101001*QR_000022000010+P_020101101*QR_000022000011+P_120001001*QR_000022000100+P_120001101*QR_000022000101+P_120101001*QR_000022000110+P_120101101*QR_000022000111+P_220001001*QR_000022000200+P_220001101*QR_000022000201+P_220101001*QR_000022000210+P_220101101*QR_000022000211); ans_temp[ans_id*36+2]+=Pmtrx[27]*(P_020001001*QR_001020001000+P_020001101*QR_001020001001+P_020101001*QR_001020001010+P_020101101*QR_001020001011+P_120001001*QR_001020001100+P_120001101*QR_001020001101+P_120101001*QR_001020001110+P_120101101*QR_001020001111+P_220001001*QR_001020001200+P_220001101*QR_001020001201+P_220101001*QR_001020001210+P_220101101*QR_001020001211); ans_temp[ans_id*36+2]+=Pmtrx[28]*(P_020001001*QR_000021001000+P_020001101*QR_000021001001+P_020101001*QR_000021001010+P_020101101*QR_000021001011+P_120001001*QR_000021001100+P_120001101*QR_000021001101+P_120101001*QR_000021001110+P_120101101*QR_000021001111+P_220001001*QR_000021001200+P_220001101*QR_000021001201+P_220101001*QR_000021001210+P_220101101*QR_000021001211); ans_temp[ans_id*36+2]+=Pmtrx[29]*(P_020001001*QR_000020002000+P_020001101*QR_000020002001+P_020101001*QR_000020002010+P_020101101*QR_000020002011+P_120001001*QR_000020002100+P_120001101*QR_000020002101+P_120101001*QR_000020002110+P_120101101*QR_000020002111+P_220001001*QR_000020002200+P_220001101*QR_000020002201+P_220101001*QR_000020002210+P_220101101*QR_000020002211); ans_temp[ans_id*36+3]+=Pmtrx[24]*(P_020001001*QR_012000010000+P_020001101*QR_012000010001+P_020101001*QR_012000010010+P_020101101*QR_012000010011+P_120001001*QR_012000010100+P_120001101*QR_012000010101+P_120101001*QR_012000010110+P_120101101*QR_012000010111+P_220001001*QR_012000010200+P_220001101*QR_012000010201+P_220101001*QR_012000010210+P_220101101*QR_012000010211); ans_temp[ans_id*36+3]+=Pmtrx[25]*(P_020001001*QR_011001010000+P_020001101*QR_011001010001+P_020101001*QR_011001010010+P_020101101*QR_011001010011+P_120001001*QR_011001010100+P_120001101*QR_011001010101+P_120101001*QR_011001010110+P_120101101*QR_011001010111+P_220001001*QR_011001010200+P_220001101*QR_011001010201+P_220101001*QR_011001010210+P_220101101*QR_011001010211); ans_temp[ans_id*36+3]+=Pmtrx[26]*(P_020001001*QR_010002010000+P_020001101*QR_010002010001+P_020101001*QR_010002010010+P_020101101*QR_010002010011+P_120001001*QR_010002010100+P_120001101*QR_010002010101+P_120101001*QR_010002010110+P_120101101*QR_010002010111+P_220001001*QR_010002010200+P_220001101*QR_010002010201+P_220101001*QR_010002010210+P_220101101*QR_010002010211); ans_temp[ans_id*36+3]+=Pmtrx[27]*(P_020001001*QR_011000011000+P_020001101*QR_011000011001+P_020101001*QR_011000011010+P_020101101*QR_011000011011+P_120001001*QR_011000011100+P_120001101*QR_011000011101+P_120101001*QR_011000011110+P_120101101*QR_011000011111+P_220001001*QR_011000011200+P_220001101*QR_011000011201+P_220101001*QR_011000011210+P_220101101*QR_011000011211); ans_temp[ans_id*36+3]+=Pmtrx[28]*(P_020001001*QR_010001011000+P_020001101*QR_010001011001+P_020101001*QR_010001011010+P_020101101*QR_010001011011+P_120001001*QR_010001011100+P_120001101*QR_010001011101+P_120101001*QR_010001011110+P_120101101*QR_010001011111+P_220001001*QR_010001011200+P_220001101*QR_010001011201+P_220101001*QR_010001011210+P_220101101*QR_010001011211); ans_temp[ans_id*36+3]+=Pmtrx[29]*(P_020001001*QR_010000012000+P_020001101*QR_010000012001+P_020101001*QR_010000012010+P_020101101*QR_010000012011+P_120001001*QR_010000012100+P_120001101*QR_010000012101+P_120101001*QR_010000012110+P_120101101*QR_010000012111+P_220001001*QR_010000012200+P_220001101*QR_010000012201+P_220101001*QR_010000012210+P_220101101*QR_010000012211); ans_temp[ans_id*36+4]+=Pmtrx[24]*(P_020001001*QR_002010010000+P_020001101*QR_002010010001+P_020101001*QR_002010010010+P_020101101*QR_002010010011+P_120001001*QR_002010010100+P_120001101*QR_002010010101+P_120101001*QR_002010010110+P_120101101*QR_002010010111+P_220001001*QR_002010010200+P_220001101*QR_002010010201+P_220101001*QR_002010010210+P_220101101*QR_002010010211); ans_temp[ans_id*36+4]+=Pmtrx[25]*(P_020001001*QR_001011010000+P_020001101*QR_001011010001+P_020101001*QR_001011010010+P_020101101*QR_001011010011+P_120001001*QR_001011010100+P_120001101*QR_001011010101+P_120101001*QR_001011010110+P_120101101*QR_001011010111+P_220001001*QR_001011010200+P_220001101*QR_001011010201+P_220101001*QR_001011010210+P_220101101*QR_001011010211); ans_temp[ans_id*36+4]+=Pmtrx[26]*(P_020001001*QR_000012010000+P_020001101*QR_000012010001+P_020101001*QR_000012010010+P_020101101*QR_000012010011+P_120001001*QR_000012010100+P_120001101*QR_000012010101+P_120101001*QR_000012010110+P_120101101*QR_000012010111+P_220001001*QR_000012010200+P_220001101*QR_000012010201+P_220101001*QR_000012010210+P_220101101*QR_000012010211); ans_temp[ans_id*36+4]+=Pmtrx[27]*(P_020001001*QR_001010011000+P_020001101*QR_001010011001+P_020101001*QR_001010011010+P_020101101*QR_001010011011+P_120001001*QR_001010011100+P_120001101*QR_001010011101+P_120101001*QR_001010011110+P_120101101*QR_001010011111+P_220001001*QR_001010011200+P_220001101*QR_001010011201+P_220101001*QR_001010011210+P_220101101*QR_001010011211); ans_temp[ans_id*36+4]+=Pmtrx[28]*(P_020001001*QR_000011011000+P_020001101*QR_000011011001+P_020101001*QR_000011011010+P_020101101*QR_000011011011+P_120001001*QR_000011011100+P_120001101*QR_000011011101+P_120101001*QR_000011011110+P_120101101*QR_000011011111+P_220001001*QR_000011011200+P_220001101*QR_000011011201+P_220101001*QR_000011011210+P_220101101*QR_000011011211); ans_temp[ans_id*36+4]+=Pmtrx[29]*(P_020001001*QR_000010012000+P_020001101*QR_000010012001+P_020101001*QR_000010012010+P_020101101*QR_000010012011+P_120001001*QR_000010012100+P_120001101*QR_000010012101+P_120101001*QR_000010012110+P_120101101*QR_000010012111+P_220001001*QR_000010012200+P_220001101*QR_000010012201+P_220101001*QR_000010012210+P_220101101*QR_000010012211); ans_temp[ans_id*36+5]+=Pmtrx[24]*(P_020001001*QR_002000020000+P_020001101*QR_002000020001+P_020101001*QR_002000020010+P_020101101*QR_002000020011+P_120001001*QR_002000020100+P_120001101*QR_002000020101+P_120101001*QR_002000020110+P_120101101*QR_002000020111+P_220001001*QR_002000020200+P_220001101*QR_002000020201+P_220101001*QR_002000020210+P_220101101*QR_002000020211); ans_temp[ans_id*36+5]+=Pmtrx[25]*(P_020001001*QR_001001020000+P_020001101*QR_001001020001+P_020101001*QR_001001020010+P_020101101*QR_001001020011+P_120001001*QR_001001020100+P_120001101*QR_001001020101+P_120101001*QR_001001020110+P_120101101*QR_001001020111+P_220001001*QR_001001020200+P_220001101*QR_001001020201+P_220101001*QR_001001020210+P_220101101*QR_001001020211); ans_temp[ans_id*36+5]+=Pmtrx[26]*(P_020001001*QR_000002020000+P_020001101*QR_000002020001+P_020101001*QR_000002020010+P_020101101*QR_000002020011+P_120001001*QR_000002020100+P_120001101*QR_000002020101+P_120101001*QR_000002020110+P_120101101*QR_000002020111+P_220001001*QR_000002020200+P_220001101*QR_000002020201+P_220101001*QR_000002020210+P_220101101*QR_000002020211); ans_temp[ans_id*36+5]+=Pmtrx[27]*(P_020001001*QR_001000021000+P_020001101*QR_001000021001+P_020101001*QR_001000021010+P_020101101*QR_001000021011+P_120001001*QR_001000021100+P_120001101*QR_001000021101+P_120101001*QR_001000021110+P_120101101*QR_001000021111+P_220001001*QR_001000021200+P_220001101*QR_001000021201+P_220101001*QR_001000021210+P_220101101*QR_001000021211); ans_temp[ans_id*36+5]+=Pmtrx[28]*(P_020001001*QR_000001021000+P_020001101*QR_000001021001+P_020101001*QR_000001021010+P_020101101*QR_000001021011+P_120001001*QR_000001021100+P_120001101*QR_000001021101+P_120101001*QR_000001021110+P_120101101*QR_000001021111+P_220001001*QR_000001021200+P_220001101*QR_000001021201+P_220101001*QR_000001021210+P_220101101*QR_000001021211); ans_temp[ans_id*36+5]+=Pmtrx[29]*(P_020001001*QR_000000022000+P_020001101*QR_000000022001+P_020101001*QR_000000022010+P_020101101*QR_000000022011+P_120001001*QR_000000022100+P_120001101*QR_000000022101+P_120101001*QR_000000022110+P_120101101*QR_000000022111+P_220001001*QR_000000022200+P_220001101*QR_000000022201+P_220101001*QR_000000022210+P_220101101*QR_000000022211); ans_temp[ans_id*36+0]+=Pmtrx[30]*(P_020000002*QR_022000000000+P_020000102*QR_022000000001+P_020000202*QR_022000000002+P_120000002*QR_022000000100+P_120000102*QR_022000000101+P_120000202*QR_022000000102+P_220000002*QR_022000000200+P_220000102*QR_022000000201+P_220000202*QR_022000000202); ans_temp[ans_id*36+0]+=Pmtrx[31]*(P_020000002*QR_021001000000+P_020000102*QR_021001000001+P_020000202*QR_021001000002+P_120000002*QR_021001000100+P_120000102*QR_021001000101+P_120000202*QR_021001000102+P_220000002*QR_021001000200+P_220000102*QR_021001000201+P_220000202*QR_021001000202); ans_temp[ans_id*36+0]+=Pmtrx[32]*(P_020000002*QR_020002000000+P_020000102*QR_020002000001+P_020000202*QR_020002000002+P_120000002*QR_020002000100+P_120000102*QR_020002000101+P_120000202*QR_020002000102+P_220000002*QR_020002000200+P_220000102*QR_020002000201+P_220000202*QR_020002000202); ans_temp[ans_id*36+0]+=Pmtrx[33]*(P_020000002*QR_021000001000+P_020000102*QR_021000001001+P_020000202*QR_021000001002+P_120000002*QR_021000001100+P_120000102*QR_021000001101+P_120000202*QR_021000001102+P_220000002*QR_021000001200+P_220000102*QR_021000001201+P_220000202*QR_021000001202); ans_temp[ans_id*36+0]+=Pmtrx[34]*(P_020000002*QR_020001001000+P_020000102*QR_020001001001+P_020000202*QR_020001001002+P_120000002*QR_020001001100+P_120000102*QR_020001001101+P_120000202*QR_020001001102+P_220000002*QR_020001001200+P_220000102*QR_020001001201+P_220000202*QR_020001001202); ans_temp[ans_id*36+0]+=Pmtrx[35]*(P_020000002*QR_020000002000+P_020000102*QR_020000002001+P_020000202*QR_020000002002+P_120000002*QR_020000002100+P_120000102*QR_020000002101+P_120000202*QR_020000002102+P_220000002*QR_020000002200+P_220000102*QR_020000002201+P_220000202*QR_020000002202); ans_temp[ans_id*36+1]+=Pmtrx[30]*(P_020000002*QR_012010000000+P_020000102*QR_012010000001+P_020000202*QR_012010000002+P_120000002*QR_012010000100+P_120000102*QR_012010000101+P_120000202*QR_012010000102+P_220000002*QR_012010000200+P_220000102*QR_012010000201+P_220000202*QR_012010000202); ans_temp[ans_id*36+1]+=Pmtrx[31]*(P_020000002*QR_011011000000+P_020000102*QR_011011000001+P_020000202*QR_011011000002+P_120000002*QR_011011000100+P_120000102*QR_011011000101+P_120000202*QR_011011000102+P_220000002*QR_011011000200+P_220000102*QR_011011000201+P_220000202*QR_011011000202); ans_temp[ans_id*36+1]+=Pmtrx[32]*(P_020000002*QR_010012000000+P_020000102*QR_010012000001+P_020000202*QR_010012000002+P_120000002*QR_010012000100+P_120000102*QR_010012000101+P_120000202*QR_010012000102+P_220000002*QR_010012000200+P_220000102*QR_010012000201+P_220000202*QR_010012000202); ans_temp[ans_id*36+1]+=Pmtrx[33]*(P_020000002*QR_011010001000+P_020000102*QR_011010001001+P_020000202*QR_011010001002+P_120000002*QR_011010001100+P_120000102*QR_011010001101+P_120000202*QR_011010001102+P_220000002*QR_011010001200+P_220000102*QR_011010001201+P_220000202*QR_011010001202); ans_temp[ans_id*36+1]+=Pmtrx[34]*(P_020000002*QR_010011001000+P_020000102*QR_010011001001+P_020000202*QR_010011001002+P_120000002*QR_010011001100+P_120000102*QR_010011001101+P_120000202*QR_010011001102+P_220000002*QR_010011001200+P_220000102*QR_010011001201+P_220000202*QR_010011001202); ans_temp[ans_id*36+1]+=Pmtrx[35]*(P_020000002*QR_010010002000+P_020000102*QR_010010002001+P_020000202*QR_010010002002+P_120000002*QR_010010002100+P_120000102*QR_010010002101+P_120000202*QR_010010002102+P_220000002*QR_010010002200+P_220000102*QR_010010002201+P_220000202*QR_010010002202); ans_temp[ans_id*36+2]+=Pmtrx[30]*(P_020000002*QR_002020000000+P_020000102*QR_002020000001+P_020000202*QR_002020000002+P_120000002*QR_002020000100+P_120000102*QR_002020000101+P_120000202*QR_002020000102+P_220000002*QR_002020000200+P_220000102*QR_002020000201+P_220000202*QR_002020000202); ans_temp[ans_id*36+2]+=Pmtrx[31]*(P_020000002*QR_001021000000+P_020000102*QR_001021000001+P_020000202*QR_001021000002+P_120000002*QR_001021000100+P_120000102*QR_001021000101+P_120000202*QR_001021000102+P_220000002*QR_001021000200+P_220000102*QR_001021000201+P_220000202*QR_001021000202); ans_temp[ans_id*36+2]+=Pmtrx[32]*(P_020000002*QR_000022000000+P_020000102*QR_000022000001+P_020000202*QR_000022000002+P_120000002*QR_000022000100+P_120000102*QR_000022000101+P_120000202*QR_000022000102+P_220000002*QR_000022000200+P_220000102*QR_000022000201+P_220000202*QR_000022000202); ans_temp[ans_id*36+2]+=Pmtrx[33]*(P_020000002*QR_001020001000+P_020000102*QR_001020001001+P_020000202*QR_001020001002+P_120000002*QR_001020001100+P_120000102*QR_001020001101+P_120000202*QR_001020001102+P_220000002*QR_001020001200+P_220000102*QR_001020001201+P_220000202*QR_001020001202); ans_temp[ans_id*36+2]+=Pmtrx[34]*(P_020000002*QR_000021001000+P_020000102*QR_000021001001+P_020000202*QR_000021001002+P_120000002*QR_000021001100+P_120000102*QR_000021001101+P_120000202*QR_000021001102+P_220000002*QR_000021001200+P_220000102*QR_000021001201+P_220000202*QR_000021001202); ans_temp[ans_id*36+2]+=Pmtrx[35]*(P_020000002*QR_000020002000+P_020000102*QR_000020002001+P_020000202*QR_000020002002+P_120000002*QR_000020002100+P_120000102*QR_000020002101+P_120000202*QR_000020002102+P_220000002*QR_000020002200+P_220000102*QR_000020002201+P_220000202*QR_000020002202); ans_temp[ans_id*36+3]+=Pmtrx[30]*(P_020000002*QR_012000010000+P_020000102*QR_012000010001+P_020000202*QR_012000010002+P_120000002*QR_012000010100+P_120000102*QR_012000010101+P_120000202*QR_012000010102+P_220000002*QR_012000010200+P_220000102*QR_012000010201+P_220000202*QR_012000010202); ans_temp[ans_id*36+3]+=Pmtrx[31]*(P_020000002*QR_011001010000+P_020000102*QR_011001010001+P_020000202*QR_011001010002+P_120000002*QR_011001010100+P_120000102*QR_011001010101+P_120000202*QR_011001010102+P_220000002*QR_011001010200+P_220000102*QR_011001010201+P_220000202*QR_011001010202); ans_temp[ans_id*36+3]+=Pmtrx[32]*(P_020000002*QR_010002010000+P_020000102*QR_010002010001+P_020000202*QR_010002010002+P_120000002*QR_010002010100+P_120000102*QR_010002010101+P_120000202*QR_010002010102+P_220000002*QR_010002010200+P_220000102*QR_010002010201+P_220000202*QR_010002010202); ans_temp[ans_id*36+3]+=Pmtrx[33]*(P_020000002*QR_011000011000+P_020000102*QR_011000011001+P_020000202*QR_011000011002+P_120000002*QR_011000011100+P_120000102*QR_011000011101+P_120000202*QR_011000011102+P_220000002*QR_011000011200+P_220000102*QR_011000011201+P_220000202*QR_011000011202); ans_temp[ans_id*36+3]+=Pmtrx[34]*(P_020000002*QR_010001011000+P_020000102*QR_010001011001+P_020000202*QR_010001011002+P_120000002*QR_010001011100+P_120000102*QR_010001011101+P_120000202*QR_010001011102+P_220000002*QR_010001011200+P_220000102*QR_010001011201+P_220000202*QR_010001011202); ans_temp[ans_id*36+3]+=Pmtrx[35]*(P_020000002*QR_010000012000+P_020000102*QR_010000012001+P_020000202*QR_010000012002+P_120000002*QR_010000012100+P_120000102*QR_010000012101+P_120000202*QR_010000012102+P_220000002*QR_010000012200+P_220000102*QR_010000012201+P_220000202*QR_010000012202); ans_temp[ans_id*36+4]+=Pmtrx[30]*(P_020000002*QR_002010010000+P_020000102*QR_002010010001+P_020000202*QR_002010010002+P_120000002*QR_002010010100+P_120000102*QR_002010010101+P_120000202*QR_002010010102+P_220000002*QR_002010010200+P_220000102*QR_002010010201+P_220000202*QR_002010010202); ans_temp[ans_id*36+4]+=Pmtrx[31]*(P_020000002*QR_001011010000+P_020000102*QR_001011010001+P_020000202*QR_001011010002+P_120000002*QR_001011010100+P_120000102*QR_001011010101+P_120000202*QR_001011010102+P_220000002*QR_001011010200+P_220000102*QR_001011010201+P_220000202*QR_001011010202); ans_temp[ans_id*36+4]+=Pmtrx[32]*(P_020000002*QR_000012010000+P_020000102*QR_000012010001+P_020000202*QR_000012010002+P_120000002*QR_000012010100+P_120000102*QR_000012010101+P_120000202*QR_000012010102+P_220000002*QR_000012010200+P_220000102*QR_000012010201+P_220000202*QR_000012010202); ans_temp[ans_id*36+4]+=Pmtrx[33]*(P_020000002*QR_001010011000+P_020000102*QR_001010011001+P_020000202*QR_001010011002+P_120000002*QR_001010011100+P_120000102*QR_001010011101+P_120000202*QR_001010011102+P_220000002*QR_001010011200+P_220000102*QR_001010011201+P_220000202*QR_001010011202); ans_temp[ans_id*36+4]+=Pmtrx[34]*(P_020000002*QR_000011011000+P_020000102*QR_000011011001+P_020000202*QR_000011011002+P_120000002*QR_000011011100+P_120000102*QR_000011011101+P_120000202*QR_000011011102+P_220000002*QR_000011011200+P_220000102*QR_000011011201+P_220000202*QR_000011011202); ans_temp[ans_id*36+4]+=Pmtrx[35]*(P_020000002*QR_000010012000+P_020000102*QR_000010012001+P_020000202*QR_000010012002+P_120000002*QR_000010012100+P_120000102*QR_000010012101+P_120000202*QR_000010012102+P_220000002*QR_000010012200+P_220000102*QR_000010012201+P_220000202*QR_000010012202); ans_temp[ans_id*36+5]+=Pmtrx[30]*(P_020000002*QR_002000020000+P_020000102*QR_002000020001+P_020000202*QR_002000020002+P_120000002*QR_002000020100+P_120000102*QR_002000020101+P_120000202*QR_002000020102+P_220000002*QR_002000020200+P_220000102*QR_002000020201+P_220000202*QR_002000020202); ans_temp[ans_id*36+5]+=Pmtrx[31]*(P_020000002*QR_001001020000+P_020000102*QR_001001020001+P_020000202*QR_001001020002+P_120000002*QR_001001020100+P_120000102*QR_001001020101+P_120000202*QR_001001020102+P_220000002*QR_001001020200+P_220000102*QR_001001020201+P_220000202*QR_001001020202); ans_temp[ans_id*36+5]+=Pmtrx[32]*(P_020000002*QR_000002020000+P_020000102*QR_000002020001+P_020000202*QR_000002020002+P_120000002*QR_000002020100+P_120000102*QR_000002020101+P_120000202*QR_000002020102+P_220000002*QR_000002020200+P_220000102*QR_000002020201+P_220000202*QR_000002020202); ans_temp[ans_id*36+5]+=Pmtrx[33]*(P_020000002*QR_001000021000+P_020000102*QR_001000021001+P_020000202*QR_001000021002+P_120000002*QR_001000021100+P_120000102*QR_001000021101+P_120000202*QR_001000021102+P_220000002*QR_001000021200+P_220000102*QR_001000021201+P_220000202*QR_001000021202); ans_temp[ans_id*36+5]+=Pmtrx[34]*(P_020000002*QR_000001021000+P_020000102*QR_000001021001+P_020000202*QR_000001021002+P_120000002*QR_000001021100+P_120000102*QR_000001021101+P_120000202*QR_000001021102+P_220000002*QR_000001021200+P_220000102*QR_000001021201+P_220000202*QR_000001021202); ans_temp[ans_id*36+5]+=Pmtrx[35]*(P_020000002*QR_000000022000+P_020000102*QR_000000022001+P_020000202*QR_000000022002+P_120000002*QR_000000022100+P_120000102*QR_000000022101+P_120000202*QR_000000022102+P_220000002*QR_000000022200+P_220000102*QR_000000022201+P_220000202*QR_000000022202); ans_temp[ans_id*36+6]+=Pmtrx[0]*(P_012010000*QR_022000000000+P_012110000*QR_022000000010+P_112010000*QR_022000000100+P_112110000*QR_022000000110+P_212010000*QR_022000000200+P_212110000*QR_022000000210+P_312010000*QR_022000000300+P_312110000*QR_022000000310); ans_temp[ans_id*36+6]+=Pmtrx[1]*(P_012010000*QR_021001000000+P_012110000*QR_021001000010+P_112010000*QR_021001000100+P_112110000*QR_021001000110+P_212010000*QR_021001000200+P_212110000*QR_021001000210+P_312010000*QR_021001000300+P_312110000*QR_021001000310); ans_temp[ans_id*36+6]+=Pmtrx[2]*(P_012010000*QR_020002000000+P_012110000*QR_020002000010+P_112010000*QR_020002000100+P_112110000*QR_020002000110+P_212010000*QR_020002000200+P_212110000*QR_020002000210+P_312010000*QR_020002000300+P_312110000*QR_020002000310); ans_temp[ans_id*36+6]+=Pmtrx[3]*(P_012010000*QR_021000001000+P_012110000*QR_021000001010+P_112010000*QR_021000001100+P_112110000*QR_021000001110+P_212010000*QR_021000001200+P_212110000*QR_021000001210+P_312010000*QR_021000001300+P_312110000*QR_021000001310); ans_temp[ans_id*36+6]+=Pmtrx[4]*(P_012010000*QR_020001001000+P_012110000*QR_020001001010+P_112010000*QR_020001001100+P_112110000*QR_020001001110+P_212010000*QR_020001001200+P_212110000*QR_020001001210+P_312010000*QR_020001001300+P_312110000*QR_020001001310); ans_temp[ans_id*36+6]+=Pmtrx[5]*(P_012010000*QR_020000002000+P_012110000*QR_020000002010+P_112010000*QR_020000002100+P_112110000*QR_020000002110+P_212010000*QR_020000002200+P_212110000*QR_020000002210+P_312010000*QR_020000002300+P_312110000*QR_020000002310); ans_temp[ans_id*36+7]+=Pmtrx[0]*(P_012010000*QR_012010000000+P_012110000*QR_012010000010+P_112010000*QR_012010000100+P_112110000*QR_012010000110+P_212010000*QR_012010000200+P_212110000*QR_012010000210+P_312010000*QR_012010000300+P_312110000*QR_012010000310); ans_temp[ans_id*36+7]+=Pmtrx[1]*(P_012010000*QR_011011000000+P_012110000*QR_011011000010+P_112010000*QR_011011000100+P_112110000*QR_011011000110+P_212010000*QR_011011000200+P_212110000*QR_011011000210+P_312010000*QR_011011000300+P_312110000*QR_011011000310); ans_temp[ans_id*36+7]+=Pmtrx[2]*(P_012010000*QR_010012000000+P_012110000*QR_010012000010+P_112010000*QR_010012000100+P_112110000*QR_010012000110+P_212010000*QR_010012000200+P_212110000*QR_010012000210+P_312010000*QR_010012000300+P_312110000*QR_010012000310); ans_temp[ans_id*36+7]+=Pmtrx[3]*(P_012010000*QR_011010001000+P_012110000*QR_011010001010+P_112010000*QR_011010001100+P_112110000*QR_011010001110+P_212010000*QR_011010001200+P_212110000*QR_011010001210+P_312010000*QR_011010001300+P_312110000*QR_011010001310); ans_temp[ans_id*36+7]+=Pmtrx[4]*(P_012010000*QR_010011001000+P_012110000*QR_010011001010+P_112010000*QR_010011001100+P_112110000*QR_010011001110+P_212010000*QR_010011001200+P_212110000*QR_010011001210+P_312010000*QR_010011001300+P_312110000*QR_010011001310); ans_temp[ans_id*36+7]+=Pmtrx[5]*(P_012010000*QR_010010002000+P_012110000*QR_010010002010+P_112010000*QR_010010002100+P_112110000*QR_010010002110+P_212010000*QR_010010002200+P_212110000*QR_010010002210+P_312010000*QR_010010002300+P_312110000*QR_010010002310); ans_temp[ans_id*36+8]+=Pmtrx[0]*(P_012010000*QR_002020000000+P_012110000*QR_002020000010+P_112010000*QR_002020000100+P_112110000*QR_002020000110+P_212010000*QR_002020000200+P_212110000*QR_002020000210+P_312010000*QR_002020000300+P_312110000*QR_002020000310); ans_temp[ans_id*36+8]+=Pmtrx[1]*(P_012010000*QR_001021000000+P_012110000*QR_001021000010+P_112010000*QR_001021000100+P_112110000*QR_001021000110+P_212010000*QR_001021000200+P_212110000*QR_001021000210+P_312010000*QR_001021000300+P_312110000*QR_001021000310); ans_temp[ans_id*36+8]+=Pmtrx[2]*(P_012010000*QR_000022000000+P_012110000*QR_000022000010+P_112010000*QR_000022000100+P_112110000*QR_000022000110+P_212010000*QR_000022000200+P_212110000*QR_000022000210+P_312010000*QR_000022000300+P_312110000*QR_000022000310); ans_temp[ans_id*36+8]+=Pmtrx[3]*(P_012010000*QR_001020001000+P_012110000*QR_001020001010+P_112010000*QR_001020001100+P_112110000*QR_001020001110+P_212010000*QR_001020001200+P_212110000*QR_001020001210+P_312010000*QR_001020001300+P_312110000*QR_001020001310); ans_temp[ans_id*36+8]+=Pmtrx[4]*(P_012010000*QR_000021001000+P_012110000*QR_000021001010+P_112010000*QR_000021001100+P_112110000*QR_000021001110+P_212010000*QR_000021001200+P_212110000*QR_000021001210+P_312010000*QR_000021001300+P_312110000*QR_000021001310); ans_temp[ans_id*36+8]+=Pmtrx[5]*(P_012010000*QR_000020002000+P_012110000*QR_000020002010+P_112010000*QR_000020002100+P_112110000*QR_000020002110+P_212010000*QR_000020002200+P_212110000*QR_000020002210+P_312010000*QR_000020002300+P_312110000*QR_000020002310); ans_temp[ans_id*36+9]+=Pmtrx[0]*(P_012010000*QR_012000010000+P_012110000*QR_012000010010+P_112010000*QR_012000010100+P_112110000*QR_012000010110+P_212010000*QR_012000010200+P_212110000*QR_012000010210+P_312010000*QR_012000010300+P_312110000*QR_012000010310); ans_temp[ans_id*36+9]+=Pmtrx[1]*(P_012010000*QR_011001010000+P_012110000*QR_011001010010+P_112010000*QR_011001010100+P_112110000*QR_011001010110+P_212010000*QR_011001010200+P_212110000*QR_011001010210+P_312010000*QR_011001010300+P_312110000*QR_011001010310); ans_temp[ans_id*36+9]+=Pmtrx[2]*(P_012010000*QR_010002010000+P_012110000*QR_010002010010+P_112010000*QR_010002010100+P_112110000*QR_010002010110+P_212010000*QR_010002010200+P_212110000*QR_010002010210+P_312010000*QR_010002010300+P_312110000*QR_010002010310); ans_temp[ans_id*36+9]+=Pmtrx[3]*(P_012010000*QR_011000011000+P_012110000*QR_011000011010+P_112010000*QR_011000011100+P_112110000*QR_011000011110+P_212010000*QR_011000011200+P_212110000*QR_011000011210+P_312010000*QR_011000011300+P_312110000*QR_011000011310); ans_temp[ans_id*36+9]+=Pmtrx[4]*(P_012010000*QR_010001011000+P_012110000*QR_010001011010+P_112010000*QR_010001011100+P_112110000*QR_010001011110+P_212010000*QR_010001011200+P_212110000*QR_010001011210+P_312010000*QR_010001011300+P_312110000*QR_010001011310); ans_temp[ans_id*36+9]+=Pmtrx[5]*(P_012010000*QR_010000012000+P_012110000*QR_010000012010+P_112010000*QR_010000012100+P_112110000*QR_010000012110+P_212010000*QR_010000012200+P_212110000*QR_010000012210+P_312010000*QR_010000012300+P_312110000*QR_010000012310); ans_temp[ans_id*36+10]+=Pmtrx[0]*(P_012010000*QR_002010010000+P_012110000*QR_002010010010+P_112010000*QR_002010010100+P_112110000*QR_002010010110+P_212010000*QR_002010010200+P_212110000*QR_002010010210+P_312010000*QR_002010010300+P_312110000*QR_002010010310); ans_temp[ans_id*36+10]+=Pmtrx[1]*(P_012010000*QR_001011010000+P_012110000*QR_001011010010+P_112010000*QR_001011010100+P_112110000*QR_001011010110+P_212010000*QR_001011010200+P_212110000*QR_001011010210+P_312010000*QR_001011010300+P_312110000*QR_001011010310); ans_temp[ans_id*36+10]+=Pmtrx[2]*(P_012010000*QR_000012010000+P_012110000*QR_000012010010+P_112010000*QR_000012010100+P_112110000*QR_000012010110+P_212010000*QR_000012010200+P_212110000*QR_000012010210+P_312010000*QR_000012010300+P_312110000*QR_000012010310); ans_temp[ans_id*36+10]+=Pmtrx[3]*(P_012010000*QR_001010011000+P_012110000*QR_001010011010+P_112010000*QR_001010011100+P_112110000*QR_001010011110+P_212010000*QR_001010011200+P_212110000*QR_001010011210+P_312010000*QR_001010011300+P_312110000*QR_001010011310); ans_temp[ans_id*36+10]+=Pmtrx[4]*(P_012010000*QR_000011011000+P_012110000*QR_000011011010+P_112010000*QR_000011011100+P_112110000*QR_000011011110+P_212010000*QR_000011011200+P_212110000*QR_000011011210+P_312010000*QR_000011011300+P_312110000*QR_000011011310); ans_temp[ans_id*36+10]+=Pmtrx[5]*(P_012010000*QR_000010012000+P_012110000*QR_000010012010+P_112010000*QR_000010012100+P_112110000*QR_000010012110+P_212010000*QR_000010012200+P_212110000*QR_000010012210+P_312010000*QR_000010012300+P_312110000*QR_000010012310); ans_temp[ans_id*36+11]+=Pmtrx[0]*(P_012010000*QR_002000020000+P_012110000*QR_002000020010+P_112010000*QR_002000020100+P_112110000*QR_002000020110+P_212010000*QR_002000020200+P_212110000*QR_002000020210+P_312010000*QR_002000020300+P_312110000*QR_002000020310); ans_temp[ans_id*36+11]+=Pmtrx[1]*(P_012010000*QR_001001020000+P_012110000*QR_001001020010+P_112010000*QR_001001020100+P_112110000*QR_001001020110+P_212010000*QR_001001020200+P_212110000*QR_001001020210+P_312010000*QR_001001020300+P_312110000*QR_001001020310); ans_temp[ans_id*36+11]+=Pmtrx[2]*(P_012010000*QR_000002020000+P_012110000*QR_000002020010+P_112010000*QR_000002020100+P_112110000*QR_000002020110+P_212010000*QR_000002020200+P_212110000*QR_000002020210+P_312010000*QR_000002020300+P_312110000*QR_000002020310); ans_temp[ans_id*36+11]+=Pmtrx[3]*(P_012010000*QR_001000021000+P_012110000*QR_001000021010+P_112010000*QR_001000021100+P_112110000*QR_001000021110+P_212010000*QR_001000021200+P_212110000*QR_001000021210+P_312010000*QR_001000021300+P_312110000*QR_001000021310); ans_temp[ans_id*36+11]+=Pmtrx[4]*(P_012010000*QR_000001021000+P_012110000*QR_000001021010+P_112010000*QR_000001021100+P_112110000*QR_000001021110+P_212010000*QR_000001021200+P_212110000*QR_000001021210+P_312010000*QR_000001021300+P_312110000*QR_000001021310); ans_temp[ans_id*36+11]+=Pmtrx[5]*(P_012010000*QR_000000022000+P_012110000*QR_000000022010+P_112010000*QR_000000022100+P_112110000*QR_000000022110+P_212010000*QR_000000022200+P_212110000*QR_000000022210+P_312010000*QR_000000022300+P_312110000*QR_000000022310); ans_temp[ans_id*36+6]+=Pmtrx[6]*(P_011011000*QR_022000000000+P_011111000*QR_022000000010+P_011211000*QR_022000000020+P_111011000*QR_022000000100+P_111111000*QR_022000000110+P_111211000*QR_022000000120+P_211011000*QR_022000000200+P_211111000*QR_022000000210+P_211211000*QR_022000000220); ans_temp[ans_id*36+6]+=Pmtrx[7]*(P_011011000*QR_021001000000+P_011111000*QR_021001000010+P_011211000*QR_021001000020+P_111011000*QR_021001000100+P_111111000*QR_021001000110+P_111211000*QR_021001000120+P_211011000*QR_021001000200+P_211111000*QR_021001000210+P_211211000*QR_021001000220); ans_temp[ans_id*36+6]+=Pmtrx[8]*(P_011011000*QR_020002000000+P_011111000*QR_020002000010+P_011211000*QR_020002000020+P_111011000*QR_020002000100+P_111111000*QR_020002000110+P_111211000*QR_020002000120+P_211011000*QR_020002000200+P_211111000*QR_020002000210+P_211211000*QR_020002000220); ans_temp[ans_id*36+6]+=Pmtrx[9]*(P_011011000*QR_021000001000+P_011111000*QR_021000001010+P_011211000*QR_021000001020+P_111011000*QR_021000001100+P_111111000*QR_021000001110+P_111211000*QR_021000001120+P_211011000*QR_021000001200+P_211111000*QR_021000001210+P_211211000*QR_021000001220); ans_temp[ans_id*36+6]+=Pmtrx[10]*(P_011011000*QR_020001001000+P_011111000*QR_020001001010+P_011211000*QR_020001001020+P_111011000*QR_020001001100+P_111111000*QR_020001001110+P_111211000*QR_020001001120+P_211011000*QR_020001001200+P_211111000*QR_020001001210+P_211211000*QR_020001001220); ans_temp[ans_id*36+6]+=Pmtrx[11]*(P_011011000*QR_020000002000+P_011111000*QR_020000002010+P_011211000*QR_020000002020+P_111011000*QR_020000002100+P_111111000*QR_020000002110+P_111211000*QR_020000002120+P_211011000*QR_020000002200+P_211111000*QR_020000002210+P_211211000*QR_020000002220); ans_temp[ans_id*36+7]+=Pmtrx[6]*(P_011011000*QR_012010000000+P_011111000*QR_012010000010+P_011211000*QR_012010000020+P_111011000*QR_012010000100+P_111111000*QR_012010000110+P_111211000*QR_012010000120+P_211011000*QR_012010000200+P_211111000*QR_012010000210+P_211211000*QR_012010000220); ans_temp[ans_id*36+7]+=Pmtrx[7]*(P_011011000*QR_011011000000+P_011111000*QR_011011000010+P_011211000*QR_011011000020+P_111011000*QR_011011000100+P_111111000*QR_011011000110+P_111211000*QR_011011000120+P_211011000*QR_011011000200+P_211111000*QR_011011000210+P_211211000*QR_011011000220); ans_temp[ans_id*36+7]+=Pmtrx[8]*(P_011011000*QR_010012000000+P_011111000*QR_010012000010+P_011211000*QR_010012000020+P_111011000*QR_010012000100+P_111111000*QR_010012000110+P_111211000*QR_010012000120+P_211011000*QR_010012000200+P_211111000*QR_010012000210+P_211211000*QR_010012000220); ans_temp[ans_id*36+7]+=Pmtrx[9]*(P_011011000*QR_011010001000+P_011111000*QR_011010001010+P_011211000*QR_011010001020+P_111011000*QR_011010001100+P_111111000*QR_011010001110+P_111211000*QR_011010001120+P_211011000*QR_011010001200+P_211111000*QR_011010001210+P_211211000*QR_011010001220); ans_temp[ans_id*36+7]+=Pmtrx[10]*(P_011011000*QR_010011001000+P_011111000*QR_010011001010+P_011211000*QR_010011001020+P_111011000*QR_010011001100+P_111111000*QR_010011001110+P_111211000*QR_010011001120+P_211011000*QR_010011001200+P_211111000*QR_010011001210+P_211211000*QR_010011001220); ans_temp[ans_id*36+7]+=Pmtrx[11]*(P_011011000*QR_010010002000+P_011111000*QR_010010002010+P_011211000*QR_010010002020+P_111011000*QR_010010002100+P_111111000*QR_010010002110+P_111211000*QR_010010002120+P_211011000*QR_010010002200+P_211111000*QR_010010002210+P_211211000*QR_010010002220); ans_temp[ans_id*36+8]+=Pmtrx[6]*(P_011011000*QR_002020000000+P_011111000*QR_002020000010+P_011211000*QR_002020000020+P_111011000*QR_002020000100+P_111111000*QR_002020000110+P_111211000*QR_002020000120+P_211011000*QR_002020000200+P_211111000*QR_002020000210+P_211211000*QR_002020000220); ans_temp[ans_id*36+8]+=Pmtrx[7]*(P_011011000*QR_001021000000+P_011111000*QR_001021000010+P_011211000*QR_001021000020+P_111011000*QR_001021000100+P_111111000*QR_001021000110+P_111211000*QR_001021000120+P_211011000*QR_001021000200+P_211111000*QR_001021000210+P_211211000*QR_001021000220); ans_temp[ans_id*36+8]+=Pmtrx[8]*(P_011011000*QR_000022000000+P_011111000*QR_000022000010+P_011211000*QR_000022000020+P_111011000*QR_000022000100+P_111111000*QR_000022000110+P_111211000*QR_000022000120+P_211011000*QR_000022000200+P_211111000*QR_000022000210+P_211211000*QR_000022000220); ans_temp[ans_id*36+8]+=Pmtrx[9]*(P_011011000*QR_001020001000+P_011111000*QR_001020001010+P_011211000*QR_001020001020+P_111011000*QR_001020001100+P_111111000*QR_001020001110+P_111211000*QR_001020001120+P_211011000*QR_001020001200+P_211111000*QR_001020001210+P_211211000*QR_001020001220); ans_temp[ans_id*36+8]+=Pmtrx[10]*(P_011011000*QR_000021001000+P_011111000*QR_000021001010+P_011211000*QR_000021001020+P_111011000*QR_000021001100+P_111111000*QR_000021001110+P_111211000*QR_000021001120+P_211011000*QR_000021001200+P_211111000*QR_000021001210+P_211211000*QR_000021001220); ans_temp[ans_id*36+8]+=Pmtrx[11]*(P_011011000*QR_000020002000+P_011111000*QR_000020002010+P_011211000*QR_000020002020+P_111011000*QR_000020002100+P_111111000*QR_000020002110+P_111211000*QR_000020002120+P_211011000*QR_000020002200+P_211111000*QR_000020002210+P_211211000*QR_000020002220); ans_temp[ans_id*36+9]+=Pmtrx[6]*(P_011011000*QR_012000010000+P_011111000*QR_012000010010+P_011211000*QR_012000010020+P_111011000*QR_012000010100+P_111111000*QR_012000010110+P_111211000*QR_012000010120+P_211011000*QR_012000010200+P_211111000*QR_012000010210+P_211211000*QR_012000010220); ans_temp[ans_id*36+9]+=Pmtrx[7]*(P_011011000*QR_011001010000+P_011111000*QR_011001010010+P_011211000*QR_011001010020+P_111011000*QR_011001010100+P_111111000*QR_011001010110+P_111211000*QR_011001010120+P_211011000*QR_011001010200+P_211111000*QR_011001010210+P_211211000*QR_011001010220); ans_temp[ans_id*36+9]+=Pmtrx[8]*(P_011011000*QR_010002010000+P_011111000*QR_010002010010+P_011211000*QR_010002010020+P_111011000*QR_010002010100+P_111111000*QR_010002010110+P_111211000*QR_010002010120+P_211011000*QR_010002010200+P_211111000*QR_010002010210+P_211211000*QR_010002010220); ans_temp[ans_id*36+9]+=Pmtrx[9]*(P_011011000*QR_011000011000+P_011111000*QR_011000011010+P_011211000*QR_011000011020+P_111011000*QR_011000011100+P_111111000*QR_011000011110+P_111211000*QR_011000011120+P_211011000*QR_011000011200+P_211111000*QR_011000011210+P_211211000*QR_011000011220); ans_temp[ans_id*36+9]+=Pmtrx[10]*(P_011011000*QR_010001011000+P_011111000*QR_010001011010+P_011211000*QR_010001011020+P_111011000*QR_010001011100+P_111111000*QR_010001011110+P_111211000*QR_010001011120+P_211011000*QR_010001011200+P_211111000*QR_010001011210+P_211211000*QR_010001011220); ans_temp[ans_id*36+9]+=Pmtrx[11]*(P_011011000*QR_010000012000+P_011111000*QR_010000012010+P_011211000*QR_010000012020+P_111011000*QR_010000012100+P_111111000*QR_010000012110+P_111211000*QR_010000012120+P_211011000*QR_010000012200+P_211111000*QR_010000012210+P_211211000*QR_010000012220); ans_temp[ans_id*36+10]+=Pmtrx[6]*(P_011011000*QR_002010010000+P_011111000*QR_002010010010+P_011211000*QR_002010010020+P_111011000*QR_002010010100+P_111111000*QR_002010010110+P_111211000*QR_002010010120+P_211011000*QR_002010010200+P_211111000*QR_002010010210+P_211211000*QR_002010010220); ans_temp[ans_id*36+10]+=Pmtrx[7]*(P_011011000*QR_001011010000+P_011111000*QR_001011010010+P_011211000*QR_001011010020+P_111011000*QR_001011010100+P_111111000*QR_001011010110+P_111211000*QR_001011010120+P_211011000*QR_001011010200+P_211111000*QR_001011010210+P_211211000*QR_001011010220); ans_temp[ans_id*36+10]+=Pmtrx[8]*(P_011011000*QR_000012010000+P_011111000*QR_000012010010+P_011211000*QR_000012010020+P_111011000*QR_000012010100+P_111111000*QR_000012010110+P_111211000*QR_000012010120+P_211011000*QR_000012010200+P_211111000*QR_000012010210+P_211211000*QR_000012010220); ans_temp[ans_id*36+10]+=Pmtrx[9]*(P_011011000*QR_001010011000+P_011111000*QR_001010011010+P_011211000*QR_001010011020+P_111011000*QR_001010011100+P_111111000*QR_001010011110+P_111211000*QR_001010011120+P_211011000*QR_001010011200+P_211111000*QR_001010011210+P_211211000*QR_001010011220); ans_temp[ans_id*36+10]+=Pmtrx[10]*(P_011011000*QR_000011011000+P_011111000*QR_000011011010+P_011211000*QR_000011011020+P_111011000*QR_000011011100+P_111111000*QR_000011011110+P_111211000*QR_000011011120+P_211011000*QR_000011011200+P_211111000*QR_000011011210+P_211211000*QR_000011011220); ans_temp[ans_id*36+10]+=Pmtrx[11]*(P_011011000*QR_000010012000+P_011111000*QR_000010012010+P_011211000*QR_000010012020+P_111011000*QR_000010012100+P_111111000*QR_000010012110+P_111211000*QR_000010012120+P_211011000*QR_000010012200+P_211111000*QR_000010012210+P_211211000*QR_000010012220); ans_temp[ans_id*36+11]+=Pmtrx[6]*(P_011011000*QR_002000020000+P_011111000*QR_002000020010+P_011211000*QR_002000020020+P_111011000*QR_002000020100+P_111111000*QR_002000020110+P_111211000*QR_002000020120+P_211011000*QR_002000020200+P_211111000*QR_002000020210+P_211211000*QR_002000020220); ans_temp[ans_id*36+11]+=Pmtrx[7]*(P_011011000*QR_001001020000+P_011111000*QR_001001020010+P_011211000*QR_001001020020+P_111011000*QR_001001020100+P_111111000*QR_001001020110+P_111211000*QR_001001020120+P_211011000*QR_001001020200+P_211111000*QR_001001020210+P_211211000*QR_001001020220); ans_temp[ans_id*36+11]+=Pmtrx[8]*(P_011011000*QR_000002020000+P_011111000*QR_000002020010+P_011211000*QR_000002020020+P_111011000*QR_000002020100+P_111111000*QR_000002020110+P_111211000*QR_000002020120+P_211011000*QR_000002020200+P_211111000*QR_000002020210+P_211211000*QR_000002020220); ans_temp[ans_id*36+11]+=Pmtrx[9]*(P_011011000*QR_001000021000+P_011111000*QR_001000021010+P_011211000*QR_001000021020+P_111011000*QR_001000021100+P_111111000*QR_001000021110+P_111211000*QR_001000021120+P_211011000*QR_001000021200+P_211111000*QR_001000021210+P_211211000*QR_001000021220); ans_temp[ans_id*36+11]+=Pmtrx[10]*(P_011011000*QR_000001021000+P_011111000*QR_000001021010+P_011211000*QR_000001021020+P_111011000*QR_000001021100+P_111111000*QR_000001021110+P_111211000*QR_000001021120+P_211011000*QR_000001021200+P_211111000*QR_000001021210+P_211211000*QR_000001021220); ans_temp[ans_id*36+11]+=Pmtrx[11]*(P_011011000*QR_000000022000+P_011111000*QR_000000022010+P_011211000*QR_000000022020+P_111011000*QR_000000022100+P_111111000*QR_000000022110+P_111211000*QR_000000022120+P_211011000*QR_000000022200+P_211111000*QR_000000022210+P_211211000*QR_000000022220); ans_temp[ans_id*36+6]+=Pmtrx[12]*(P_010012000*QR_022000000000+P_010112000*QR_022000000010+P_010212000*QR_022000000020+P_010312000*QR_022000000030+P_110012000*QR_022000000100+P_110112000*QR_022000000110+P_110212000*QR_022000000120+P_110312000*QR_022000000130); ans_temp[ans_id*36+6]+=Pmtrx[13]*(P_010012000*QR_021001000000+P_010112000*QR_021001000010+P_010212000*QR_021001000020+P_010312000*QR_021001000030+P_110012000*QR_021001000100+P_110112000*QR_021001000110+P_110212000*QR_021001000120+P_110312000*QR_021001000130); ans_temp[ans_id*36+6]+=Pmtrx[14]*(P_010012000*QR_020002000000+P_010112000*QR_020002000010+P_010212000*QR_020002000020+P_010312000*QR_020002000030+P_110012000*QR_020002000100+P_110112000*QR_020002000110+P_110212000*QR_020002000120+P_110312000*QR_020002000130); ans_temp[ans_id*36+6]+=Pmtrx[15]*(P_010012000*QR_021000001000+P_010112000*QR_021000001010+P_010212000*QR_021000001020+P_010312000*QR_021000001030+P_110012000*QR_021000001100+P_110112000*QR_021000001110+P_110212000*QR_021000001120+P_110312000*QR_021000001130); ans_temp[ans_id*36+6]+=Pmtrx[16]*(P_010012000*QR_020001001000+P_010112000*QR_020001001010+P_010212000*QR_020001001020+P_010312000*QR_020001001030+P_110012000*QR_020001001100+P_110112000*QR_020001001110+P_110212000*QR_020001001120+P_110312000*QR_020001001130); ans_temp[ans_id*36+6]+=Pmtrx[17]*(P_010012000*QR_020000002000+P_010112000*QR_020000002010+P_010212000*QR_020000002020+P_010312000*QR_020000002030+P_110012000*QR_020000002100+P_110112000*QR_020000002110+P_110212000*QR_020000002120+P_110312000*QR_020000002130); ans_temp[ans_id*36+7]+=Pmtrx[12]*(P_010012000*QR_012010000000+P_010112000*QR_012010000010+P_010212000*QR_012010000020+P_010312000*QR_012010000030+P_110012000*QR_012010000100+P_110112000*QR_012010000110+P_110212000*QR_012010000120+P_110312000*QR_012010000130); ans_temp[ans_id*36+7]+=Pmtrx[13]*(P_010012000*QR_011011000000+P_010112000*QR_011011000010+P_010212000*QR_011011000020+P_010312000*QR_011011000030+P_110012000*QR_011011000100+P_110112000*QR_011011000110+P_110212000*QR_011011000120+P_110312000*QR_011011000130); ans_temp[ans_id*36+7]+=Pmtrx[14]*(P_010012000*QR_010012000000+P_010112000*QR_010012000010+P_010212000*QR_010012000020+P_010312000*QR_010012000030+P_110012000*QR_010012000100+P_110112000*QR_010012000110+P_110212000*QR_010012000120+P_110312000*QR_010012000130); ans_temp[ans_id*36+7]+=Pmtrx[15]*(P_010012000*QR_011010001000+P_010112000*QR_011010001010+P_010212000*QR_011010001020+P_010312000*QR_011010001030+P_110012000*QR_011010001100+P_110112000*QR_011010001110+P_110212000*QR_011010001120+P_110312000*QR_011010001130); ans_temp[ans_id*36+7]+=Pmtrx[16]*(P_010012000*QR_010011001000+P_010112000*QR_010011001010+P_010212000*QR_010011001020+P_010312000*QR_010011001030+P_110012000*QR_010011001100+P_110112000*QR_010011001110+P_110212000*QR_010011001120+P_110312000*QR_010011001130); ans_temp[ans_id*36+7]+=Pmtrx[17]*(P_010012000*QR_010010002000+P_010112000*QR_010010002010+P_010212000*QR_010010002020+P_010312000*QR_010010002030+P_110012000*QR_010010002100+P_110112000*QR_010010002110+P_110212000*QR_010010002120+P_110312000*QR_010010002130); ans_temp[ans_id*36+8]+=Pmtrx[12]*(P_010012000*QR_002020000000+P_010112000*QR_002020000010+P_010212000*QR_002020000020+P_010312000*QR_002020000030+P_110012000*QR_002020000100+P_110112000*QR_002020000110+P_110212000*QR_002020000120+P_110312000*QR_002020000130); ans_temp[ans_id*36+8]+=Pmtrx[13]*(P_010012000*QR_001021000000+P_010112000*QR_001021000010+P_010212000*QR_001021000020+P_010312000*QR_001021000030+P_110012000*QR_001021000100+P_110112000*QR_001021000110+P_110212000*QR_001021000120+P_110312000*QR_001021000130); ans_temp[ans_id*36+8]+=Pmtrx[14]*(P_010012000*QR_000022000000+P_010112000*QR_000022000010+P_010212000*QR_000022000020+P_010312000*QR_000022000030+P_110012000*QR_000022000100+P_110112000*QR_000022000110+P_110212000*QR_000022000120+P_110312000*QR_000022000130); ans_temp[ans_id*36+8]+=Pmtrx[15]*(P_010012000*QR_001020001000+P_010112000*QR_001020001010+P_010212000*QR_001020001020+P_010312000*QR_001020001030+P_110012000*QR_001020001100+P_110112000*QR_001020001110+P_110212000*QR_001020001120+P_110312000*QR_001020001130); ans_temp[ans_id*36+8]+=Pmtrx[16]*(P_010012000*QR_000021001000+P_010112000*QR_000021001010+P_010212000*QR_000021001020+P_010312000*QR_000021001030+P_110012000*QR_000021001100+P_110112000*QR_000021001110+P_110212000*QR_000021001120+P_110312000*QR_000021001130); ans_temp[ans_id*36+8]+=Pmtrx[17]*(P_010012000*QR_000020002000+P_010112000*QR_000020002010+P_010212000*QR_000020002020+P_010312000*QR_000020002030+P_110012000*QR_000020002100+P_110112000*QR_000020002110+P_110212000*QR_000020002120+P_110312000*QR_000020002130); ans_temp[ans_id*36+9]+=Pmtrx[12]*(P_010012000*QR_012000010000+P_010112000*QR_012000010010+P_010212000*QR_012000010020+P_010312000*QR_012000010030+P_110012000*QR_012000010100+P_110112000*QR_012000010110+P_110212000*QR_012000010120+P_110312000*QR_012000010130); ans_temp[ans_id*36+9]+=Pmtrx[13]*(P_010012000*QR_011001010000+P_010112000*QR_011001010010+P_010212000*QR_011001010020+P_010312000*QR_011001010030+P_110012000*QR_011001010100+P_110112000*QR_011001010110+P_110212000*QR_011001010120+P_110312000*QR_011001010130); ans_temp[ans_id*36+9]+=Pmtrx[14]*(P_010012000*QR_010002010000+P_010112000*QR_010002010010+P_010212000*QR_010002010020+P_010312000*QR_010002010030+P_110012000*QR_010002010100+P_110112000*QR_010002010110+P_110212000*QR_010002010120+P_110312000*QR_010002010130); ans_temp[ans_id*36+9]+=Pmtrx[15]*(P_010012000*QR_011000011000+P_010112000*QR_011000011010+P_010212000*QR_011000011020+P_010312000*QR_011000011030+P_110012000*QR_011000011100+P_110112000*QR_011000011110+P_110212000*QR_011000011120+P_110312000*QR_011000011130); ans_temp[ans_id*36+9]+=Pmtrx[16]*(P_010012000*QR_010001011000+P_010112000*QR_010001011010+P_010212000*QR_010001011020+P_010312000*QR_010001011030+P_110012000*QR_010001011100+P_110112000*QR_010001011110+P_110212000*QR_010001011120+P_110312000*QR_010001011130); ans_temp[ans_id*36+9]+=Pmtrx[17]*(P_010012000*QR_010000012000+P_010112000*QR_010000012010+P_010212000*QR_010000012020+P_010312000*QR_010000012030+P_110012000*QR_010000012100+P_110112000*QR_010000012110+P_110212000*QR_010000012120+P_110312000*QR_010000012130); ans_temp[ans_id*36+10]+=Pmtrx[12]*(P_010012000*QR_002010010000+P_010112000*QR_002010010010+P_010212000*QR_002010010020+P_010312000*QR_002010010030+P_110012000*QR_002010010100+P_110112000*QR_002010010110+P_110212000*QR_002010010120+P_110312000*QR_002010010130); ans_temp[ans_id*36+10]+=Pmtrx[13]*(P_010012000*QR_001011010000+P_010112000*QR_001011010010+P_010212000*QR_001011010020+P_010312000*QR_001011010030+P_110012000*QR_001011010100+P_110112000*QR_001011010110+P_110212000*QR_001011010120+P_110312000*QR_001011010130); ans_temp[ans_id*36+10]+=Pmtrx[14]*(P_010012000*QR_000012010000+P_010112000*QR_000012010010+P_010212000*QR_000012010020+P_010312000*QR_000012010030+P_110012000*QR_000012010100+P_110112000*QR_000012010110+P_110212000*QR_000012010120+P_110312000*QR_000012010130); ans_temp[ans_id*36+10]+=Pmtrx[15]*(P_010012000*QR_001010011000+P_010112000*QR_001010011010+P_010212000*QR_001010011020+P_010312000*QR_001010011030+P_110012000*QR_001010011100+P_110112000*QR_001010011110+P_110212000*QR_001010011120+P_110312000*QR_001010011130); ans_temp[ans_id*36+10]+=Pmtrx[16]*(P_010012000*QR_000011011000+P_010112000*QR_000011011010+P_010212000*QR_000011011020+P_010312000*QR_000011011030+P_110012000*QR_000011011100+P_110112000*QR_000011011110+P_110212000*QR_000011011120+P_110312000*QR_000011011130); ans_temp[ans_id*36+10]+=Pmtrx[17]*(P_010012000*QR_000010012000+P_010112000*QR_000010012010+P_010212000*QR_000010012020+P_010312000*QR_000010012030+P_110012000*QR_000010012100+P_110112000*QR_000010012110+P_110212000*QR_000010012120+P_110312000*QR_000010012130); ans_temp[ans_id*36+11]+=Pmtrx[12]*(P_010012000*QR_002000020000+P_010112000*QR_002000020010+P_010212000*QR_002000020020+P_010312000*QR_002000020030+P_110012000*QR_002000020100+P_110112000*QR_002000020110+P_110212000*QR_002000020120+P_110312000*QR_002000020130); ans_temp[ans_id*36+11]+=Pmtrx[13]*(P_010012000*QR_001001020000+P_010112000*QR_001001020010+P_010212000*QR_001001020020+P_010312000*QR_001001020030+P_110012000*QR_001001020100+P_110112000*QR_001001020110+P_110212000*QR_001001020120+P_110312000*QR_001001020130); ans_temp[ans_id*36+11]+=Pmtrx[14]*(P_010012000*QR_000002020000+P_010112000*QR_000002020010+P_010212000*QR_000002020020+P_010312000*QR_000002020030+P_110012000*QR_000002020100+P_110112000*QR_000002020110+P_110212000*QR_000002020120+P_110312000*QR_000002020130); ans_temp[ans_id*36+11]+=Pmtrx[15]*(P_010012000*QR_001000021000+P_010112000*QR_001000021010+P_010212000*QR_001000021020+P_010312000*QR_001000021030+P_110012000*QR_001000021100+P_110112000*QR_001000021110+P_110212000*QR_001000021120+P_110312000*QR_001000021130); ans_temp[ans_id*36+11]+=Pmtrx[16]*(P_010012000*QR_000001021000+P_010112000*QR_000001021010+P_010212000*QR_000001021020+P_010312000*QR_000001021030+P_110012000*QR_000001021100+P_110112000*QR_000001021110+P_110212000*QR_000001021120+P_110312000*QR_000001021130); ans_temp[ans_id*36+11]+=Pmtrx[17]*(P_010012000*QR_000000022000+P_010112000*QR_000000022010+P_010212000*QR_000000022020+P_010312000*QR_000000022030+P_110012000*QR_000000022100+P_110112000*QR_000000022110+P_110212000*QR_000000022120+P_110312000*QR_000000022130); ans_temp[ans_id*36+6]+=Pmtrx[18]*(P_011010001*QR_022000000000+P_011010101*QR_022000000001+P_011110001*QR_022000000010+P_011110101*QR_022000000011+P_111010001*QR_022000000100+P_111010101*QR_022000000101+P_111110001*QR_022000000110+P_111110101*QR_022000000111+P_211010001*QR_022000000200+P_211010101*QR_022000000201+P_211110001*QR_022000000210+P_211110101*QR_022000000211); ans_temp[ans_id*36+6]+=Pmtrx[19]*(P_011010001*QR_021001000000+P_011010101*QR_021001000001+P_011110001*QR_021001000010+P_011110101*QR_021001000011+P_111010001*QR_021001000100+P_111010101*QR_021001000101+P_111110001*QR_021001000110+P_111110101*QR_021001000111+P_211010001*QR_021001000200+P_211010101*QR_021001000201+P_211110001*QR_021001000210+P_211110101*QR_021001000211); ans_temp[ans_id*36+6]+=Pmtrx[20]*(P_011010001*QR_020002000000+P_011010101*QR_020002000001+P_011110001*QR_020002000010+P_011110101*QR_020002000011+P_111010001*QR_020002000100+P_111010101*QR_020002000101+P_111110001*QR_020002000110+P_111110101*QR_020002000111+P_211010001*QR_020002000200+P_211010101*QR_020002000201+P_211110001*QR_020002000210+P_211110101*QR_020002000211); ans_temp[ans_id*36+6]+=Pmtrx[21]*(P_011010001*QR_021000001000+P_011010101*QR_021000001001+P_011110001*QR_021000001010+P_011110101*QR_021000001011+P_111010001*QR_021000001100+P_111010101*QR_021000001101+P_111110001*QR_021000001110+P_111110101*QR_021000001111+P_211010001*QR_021000001200+P_211010101*QR_021000001201+P_211110001*QR_021000001210+P_211110101*QR_021000001211); ans_temp[ans_id*36+6]+=Pmtrx[22]*(P_011010001*QR_020001001000+P_011010101*QR_020001001001+P_011110001*QR_020001001010+P_011110101*QR_020001001011+P_111010001*QR_020001001100+P_111010101*QR_020001001101+P_111110001*QR_020001001110+P_111110101*QR_020001001111+P_211010001*QR_020001001200+P_211010101*QR_020001001201+P_211110001*QR_020001001210+P_211110101*QR_020001001211); ans_temp[ans_id*36+6]+=Pmtrx[23]*(P_011010001*QR_020000002000+P_011010101*QR_020000002001+P_011110001*QR_020000002010+P_011110101*QR_020000002011+P_111010001*QR_020000002100+P_111010101*QR_020000002101+P_111110001*QR_020000002110+P_111110101*QR_020000002111+P_211010001*QR_020000002200+P_211010101*QR_020000002201+P_211110001*QR_020000002210+P_211110101*QR_020000002211); ans_temp[ans_id*36+7]+=Pmtrx[18]*(P_011010001*QR_012010000000+P_011010101*QR_012010000001+P_011110001*QR_012010000010+P_011110101*QR_012010000011+P_111010001*QR_012010000100+P_111010101*QR_012010000101+P_111110001*QR_012010000110+P_111110101*QR_012010000111+P_211010001*QR_012010000200+P_211010101*QR_012010000201+P_211110001*QR_012010000210+P_211110101*QR_012010000211); ans_temp[ans_id*36+7]+=Pmtrx[19]*(P_011010001*QR_011011000000+P_011010101*QR_011011000001+P_011110001*QR_011011000010+P_011110101*QR_011011000011+P_111010001*QR_011011000100+P_111010101*QR_011011000101+P_111110001*QR_011011000110+P_111110101*QR_011011000111+P_211010001*QR_011011000200+P_211010101*QR_011011000201+P_211110001*QR_011011000210+P_211110101*QR_011011000211); ans_temp[ans_id*36+7]+=Pmtrx[20]*(P_011010001*QR_010012000000+P_011010101*QR_010012000001+P_011110001*QR_010012000010+P_011110101*QR_010012000011+P_111010001*QR_010012000100+P_111010101*QR_010012000101+P_111110001*QR_010012000110+P_111110101*QR_010012000111+P_211010001*QR_010012000200+P_211010101*QR_010012000201+P_211110001*QR_010012000210+P_211110101*QR_010012000211); ans_temp[ans_id*36+7]+=Pmtrx[21]*(P_011010001*QR_011010001000+P_011010101*QR_011010001001+P_011110001*QR_011010001010+P_011110101*QR_011010001011+P_111010001*QR_011010001100+P_111010101*QR_011010001101+P_111110001*QR_011010001110+P_111110101*QR_011010001111+P_211010001*QR_011010001200+P_211010101*QR_011010001201+P_211110001*QR_011010001210+P_211110101*QR_011010001211); ans_temp[ans_id*36+7]+=Pmtrx[22]*(P_011010001*QR_010011001000+P_011010101*QR_010011001001+P_011110001*QR_010011001010+P_011110101*QR_010011001011+P_111010001*QR_010011001100+P_111010101*QR_010011001101+P_111110001*QR_010011001110+P_111110101*QR_010011001111+P_211010001*QR_010011001200+P_211010101*QR_010011001201+P_211110001*QR_010011001210+P_211110101*QR_010011001211); ans_temp[ans_id*36+7]+=Pmtrx[23]*(P_011010001*QR_010010002000+P_011010101*QR_010010002001+P_011110001*QR_010010002010+P_011110101*QR_010010002011+P_111010001*QR_010010002100+P_111010101*QR_010010002101+P_111110001*QR_010010002110+P_111110101*QR_010010002111+P_211010001*QR_010010002200+P_211010101*QR_010010002201+P_211110001*QR_010010002210+P_211110101*QR_010010002211); ans_temp[ans_id*36+8]+=Pmtrx[18]*(P_011010001*QR_002020000000+P_011010101*QR_002020000001+P_011110001*QR_002020000010+P_011110101*QR_002020000011+P_111010001*QR_002020000100+P_111010101*QR_002020000101+P_111110001*QR_002020000110+P_111110101*QR_002020000111+P_211010001*QR_002020000200+P_211010101*QR_002020000201+P_211110001*QR_002020000210+P_211110101*QR_002020000211); ans_temp[ans_id*36+8]+=Pmtrx[19]*(P_011010001*QR_001021000000+P_011010101*QR_001021000001+P_011110001*QR_001021000010+P_011110101*QR_001021000011+P_111010001*QR_001021000100+P_111010101*QR_001021000101+P_111110001*QR_001021000110+P_111110101*QR_001021000111+P_211010001*QR_001021000200+P_211010101*QR_001021000201+P_211110001*QR_001021000210+P_211110101*QR_001021000211); ans_temp[ans_id*36+8]+=Pmtrx[20]*(P_011010001*QR_000022000000+P_011010101*QR_000022000001+P_011110001*QR_000022000010+P_011110101*QR_000022000011+P_111010001*QR_000022000100+P_111010101*QR_000022000101+P_111110001*QR_000022000110+P_111110101*QR_000022000111+P_211010001*QR_000022000200+P_211010101*QR_000022000201+P_211110001*QR_000022000210+P_211110101*QR_000022000211); ans_temp[ans_id*36+8]+=Pmtrx[21]*(P_011010001*QR_001020001000+P_011010101*QR_001020001001+P_011110001*QR_001020001010+P_011110101*QR_001020001011+P_111010001*QR_001020001100+P_111010101*QR_001020001101+P_111110001*QR_001020001110+P_111110101*QR_001020001111+P_211010001*QR_001020001200+P_211010101*QR_001020001201+P_211110001*QR_001020001210+P_211110101*QR_001020001211); ans_temp[ans_id*36+8]+=Pmtrx[22]*(P_011010001*QR_000021001000+P_011010101*QR_000021001001+P_011110001*QR_000021001010+P_011110101*QR_000021001011+P_111010001*QR_000021001100+P_111010101*QR_000021001101+P_111110001*QR_000021001110+P_111110101*QR_000021001111+P_211010001*QR_000021001200+P_211010101*QR_000021001201+P_211110001*QR_000021001210+P_211110101*QR_000021001211); ans_temp[ans_id*36+8]+=Pmtrx[23]*(P_011010001*QR_000020002000+P_011010101*QR_000020002001+P_011110001*QR_000020002010+P_011110101*QR_000020002011+P_111010001*QR_000020002100+P_111010101*QR_000020002101+P_111110001*QR_000020002110+P_111110101*QR_000020002111+P_211010001*QR_000020002200+P_211010101*QR_000020002201+P_211110001*QR_000020002210+P_211110101*QR_000020002211); ans_temp[ans_id*36+9]+=Pmtrx[18]*(P_011010001*QR_012000010000+P_011010101*QR_012000010001+P_011110001*QR_012000010010+P_011110101*QR_012000010011+P_111010001*QR_012000010100+P_111010101*QR_012000010101+P_111110001*QR_012000010110+P_111110101*QR_012000010111+P_211010001*QR_012000010200+P_211010101*QR_012000010201+P_211110001*QR_012000010210+P_211110101*QR_012000010211); ans_temp[ans_id*36+9]+=Pmtrx[19]*(P_011010001*QR_011001010000+P_011010101*QR_011001010001+P_011110001*QR_011001010010+P_011110101*QR_011001010011+P_111010001*QR_011001010100+P_111010101*QR_011001010101+P_111110001*QR_011001010110+P_111110101*QR_011001010111+P_211010001*QR_011001010200+P_211010101*QR_011001010201+P_211110001*QR_011001010210+P_211110101*QR_011001010211); ans_temp[ans_id*36+9]+=Pmtrx[20]*(P_011010001*QR_010002010000+P_011010101*QR_010002010001+P_011110001*QR_010002010010+P_011110101*QR_010002010011+P_111010001*QR_010002010100+P_111010101*QR_010002010101+P_111110001*QR_010002010110+P_111110101*QR_010002010111+P_211010001*QR_010002010200+P_211010101*QR_010002010201+P_211110001*QR_010002010210+P_211110101*QR_010002010211); ans_temp[ans_id*36+9]+=Pmtrx[21]*(P_011010001*QR_011000011000+P_011010101*QR_011000011001+P_011110001*QR_011000011010+P_011110101*QR_011000011011+P_111010001*QR_011000011100+P_111010101*QR_011000011101+P_111110001*QR_011000011110+P_111110101*QR_011000011111+P_211010001*QR_011000011200+P_211010101*QR_011000011201+P_211110001*QR_011000011210+P_211110101*QR_011000011211); ans_temp[ans_id*36+9]+=Pmtrx[22]*(P_011010001*QR_010001011000+P_011010101*QR_010001011001+P_011110001*QR_010001011010+P_011110101*QR_010001011011+P_111010001*QR_010001011100+P_111010101*QR_010001011101+P_111110001*QR_010001011110+P_111110101*QR_010001011111+P_211010001*QR_010001011200+P_211010101*QR_010001011201+P_211110001*QR_010001011210+P_211110101*QR_010001011211); ans_temp[ans_id*36+9]+=Pmtrx[23]*(P_011010001*QR_010000012000+P_011010101*QR_010000012001+P_011110001*QR_010000012010+P_011110101*QR_010000012011+P_111010001*QR_010000012100+P_111010101*QR_010000012101+P_111110001*QR_010000012110+P_111110101*QR_010000012111+P_211010001*QR_010000012200+P_211010101*QR_010000012201+P_211110001*QR_010000012210+P_211110101*QR_010000012211); ans_temp[ans_id*36+10]+=Pmtrx[18]*(P_011010001*QR_002010010000+P_011010101*QR_002010010001+P_011110001*QR_002010010010+P_011110101*QR_002010010011+P_111010001*QR_002010010100+P_111010101*QR_002010010101+P_111110001*QR_002010010110+P_111110101*QR_002010010111+P_211010001*QR_002010010200+P_211010101*QR_002010010201+P_211110001*QR_002010010210+P_211110101*QR_002010010211); ans_temp[ans_id*36+10]+=Pmtrx[19]*(P_011010001*QR_001011010000+P_011010101*QR_001011010001+P_011110001*QR_001011010010+P_011110101*QR_001011010011+P_111010001*QR_001011010100+P_111010101*QR_001011010101+P_111110001*QR_001011010110+P_111110101*QR_001011010111+P_211010001*QR_001011010200+P_211010101*QR_001011010201+P_211110001*QR_001011010210+P_211110101*QR_001011010211); ans_temp[ans_id*36+10]+=Pmtrx[20]*(P_011010001*QR_000012010000+P_011010101*QR_000012010001+P_011110001*QR_000012010010+P_011110101*QR_000012010011+P_111010001*QR_000012010100+P_111010101*QR_000012010101+P_111110001*QR_000012010110+P_111110101*QR_000012010111+P_211010001*QR_000012010200+P_211010101*QR_000012010201+P_211110001*QR_000012010210+P_211110101*QR_000012010211); ans_temp[ans_id*36+10]+=Pmtrx[21]*(P_011010001*QR_001010011000+P_011010101*QR_001010011001+P_011110001*QR_001010011010+P_011110101*QR_001010011011+P_111010001*QR_001010011100+P_111010101*QR_001010011101+P_111110001*QR_001010011110+P_111110101*QR_001010011111+P_211010001*QR_001010011200+P_211010101*QR_001010011201+P_211110001*QR_001010011210+P_211110101*QR_001010011211); ans_temp[ans_id*36+10]+=Pmtrx[22]*(P_011010001*QR_000011011000+P_011010101*QR_000011011001+P_011110001*QR_000011011010+P_011110101*QR_000011011011+P_111010001*QR_000011011100+P_111010101*QR_000011011101+P_111110001*QR_000011011110+P_111110101*QR_000011011111+P_211010001*QR_000011011200+P_211010101*QR_000011011201+P_211110001*QR_000011011210+P_211110101*QR_000011011211); ans_temp[ans_id*36+10]+=Pmtrx[23]*(P_011010001*QR_000010012000+P_011010101*QR_000010012001+P_011110001*QR_000010012010+P_011110101*QR_000010012011+P_111010001*QR_000010012100+P_111010101*QR_000010012101+P_111110001*QR_000010012110+P_111110101*QR_000010012111+P_211010001*QR_000010012200+P_211010101*QR_000010012201+P_211110001*QR_000010012210+P_211110101*QR_000010012211); ans_temp[ans_id*36+11]+=Pmtrx[18]*(P_011010001*QR_002000020000+P_011010101*QR_002000020001+P_011110001*QR_002000020010+P_011110101*QR_002000020011+P_111010001*QR_002000020100+P_111010101*QR_002000020101+P_111110001*QR_002000020110+P_111110101*QR_002000020111+P_211010001*QR_002000020200+P_211010101*QR_002000020201+P_211110001*QR_002000020210+P_211110101*QR_002000020211); ans_temp[ans_id*36+11]+=Pmtrx[19]*(P_011010001*QR_001001020000+P_011010101*QR_001001020001+P_011110001*QR_001001020010+P_011110101*QR_001001020011+P_111010001*QR_001001020100+P_111010101*QR_001001020101+P_111110001*QR_001001020110+P_111110101*QR_001001020111+P_211010001*QR_001001020200+P_211010101*QR_001001020201+P_211110001*QR_001001020210+P_211110101*QR_001001020211); ans_temp[ans_id*36+11]+=Pmtrx[20]*(P_011010001*QR_000002020000+P_011010101*QR_000002020001+P_011110001*QR_000002020010+P_011110101*QR_000002020011+P_111010001*QR_000002020100+P_111010101*QR_000002020101+P_111110001*QR_000002020110+P_111110101*QR_000002020111+P_211010001*QR_000002020200+P_211010101*QR_000002020201+P_211110001*QR_000002020210+P_211110101*QR_000002020211); ans_temp[ans_id*36+11]+=Pmtrx[21]*(P_011010001*QR_001000021000+P_011010101*QR_001000021001+P_011110001*QR_001000021010+P_011110101*QR_001000021011+P_111010001*QR_001000021100+P_111010101*QR_001000021101+P_111110001*QR_001000021110+P_111110101*QR_001000021111+P_211010001*QR_001000021200+P_211010101*QR_001000021201+P_211110001*QR_001000021210+P_211110101*QR_001000021211); ans_temp[ans_id*36+11]+=Pmtrx[22]*(P_011010001*QR_000001021000+P_011010101*QR_000001021001+P_011110001*QR_000001021010+P_011110101*QR_000001021011+P_111010001*QR_000001021100+P_111010101*QR_000001021101+P_111110001*QR_000001021110+P_111110101*QR_000001021111+P_211010001*QR_000001021200+P_211010101*QR_000001021201+P_211110001*QR_000001021210+P_211110101*QR_000001021211); ans_temp[ans_id*36+11]+=Pmtrx[23]*(P_011010001*QR_000000022000+P_011010101*QR_000000022001+P_011110001*QR_000000022010+P_011110101*QR_000000022011+P_111010001*QR_000000022100+P_111010101*QR_000000022101+P_111110001*QR_000000022110+P_111110101*QR_000000022111+P_211010001*QR_000000022200+P_211010101*QR_000000022201+P_211110001*QR_000000022210+P_211110101*QR_000000022211); ans_temp[ans_id*36+6]+=Pmtrx[24]*(P_010011001*QR_022000000000+P_010011101*QR_022000000001+P_010111001*QR_022000000010+P_010111101*QR_022000000011+P_010211001*QR_022000000020+P_010211101*QR_022000000021+P_110011001*QR_022000000100+P_110011101*QR_022000000101+P_110111001*QR_022000000110+P_110111101*QR_022000000111+P_110211001*QR_022000000120+P_110211101*QR_022000000121); ans_temp[ans_id*36+6]+=Pmtrx[25]*(P_010011001*QR_021001000000+P_010011101*QR_021001000001+P_010111001*QR_021001000010+P_010111101*QR_021001000011+P_010211001*QR_021001000020+P_010211101*QR_021001000021+P_110011001*QR_021001000100+P_110011101*QR_021001000101+P_110111001*QR_021001000110+P_110111101*QR_021001000111+P_110211001*QR_021001000120+P_110211101*QR_021001000121); ans_temp[ans_id*36+6]+=Pmtrx[26]*(P_010011001*QR_020002000000+P_010011101*QR_020002000001+P_010111001*QR_020002000010+P_010111101*QR_020002000011+P_010211001*QR_020002000020+P_010211101*QR_020002000021+P_110011001*QR_020002000100+P_110011101*QR_020002000101+P_110111001*QR_020002000110+P_110111101*QR_020002000111+P_110211001*QR_020002000120+P_110211101*QR_020002000121); ans_temp[ans_id*36+6]+=Pmtrx[27]*(P_010011001*QR_021000001000+P_010011101*QR_021000001001+P_010111001*QR_021000001010+P_010111101*QR_021000001011+P_010211001*QR_021000001020+P_010211101*QR_021000001021+P_110011001*QR_021000001100+P_110011101*QR_021000001101+P_110111001*QR_021000001110+P_110111101*QR_021000001111+P_110211001*QR_021000001120+P_110211101*QR_021000001121); ans_temp[ans_id*36+6]+=Pmtrx[28]*(P_010011001*QR_020001001000+P_010011101*QR_020001001001+P_010111001*QR_020001001010+P_010111101*QR_020001001011+P_010211001*QR_020001001020+P_010211101*QR_020001001021+P_110011001*QR_020001001100+P_110011101*QR_020001001101+P_110111001*QR_020001001110+P_110111101*QR_020001001111+P_110211001*QR_020001001120+P_110211101*QR_020001001121); ans_temp[ans_id*36+6]+=Pmtrx[29]*(P_010011001*QR_020000002000+P_010011101*QR_020000002001+P_010111001*QR_020000002010+P_010111101*QR_020000002011+P_010211001*QR_020000002020+P_010211101*QR_020000002021+P_110011001*QR_020000002100+P_110011101*QR_020000002101+P_110111001*QR_020000002110+P_110111101*QR_020000002111+P_110211001*QR_020000002120+P_110211101*QR_020000002121); ans_temp[ans_id*36+7]+=Pmtrx[24]*(P_010011001*QR_012010000000+P_010011101*QR_012010000001+P_010111001*QR_012010000010+P_010111101*QR_012010000011+P_010211001*QR_012010000020+P_010211101*QR_012010000021+P_110011001*QR_012010000100+P_110011101*QR_012010000101+P_110111001*QR_012010000110+P_110111101*QR_012010000111+P_110211001*QR_012010000120+P_110211101*QR_012010000121); ans_temp[ans_id*36+7]+=Pmtrx[25]*(P_010011001*QR_011011000000+P_010011101*QR_011011000001+P_010111001*QR_011011000010+P_010111101*QR_011011000011+P_010211001*QR_011011000020+P_010211101*QR_011011000021+P_110011001*QR_011011000100+P_110011101*QR_011011000101+P_110111001*QR_011011000110+P_110111101*QR_011011000111+P_110211001*QR_011011000120+P_110211101*QR_011011000121); ans_temp[ans_id*36+7]+=Pmtrx[26]*(P_010011001*QR_010012000000+P_010011101*QR_010012000001+P_010111001*QR_010012000010+P_010111101*QR_010012000011+P_010211001*QR_010012000020+P_010211101*QR_010012000021+P_110011001*QR_010012000100+P_110011101*QR_010012000101+P_110111001*QR_010012000110+P_110111101*QR_010012000111+P_110211001*QR_010012000120+P_110211101*QR_010012000121); ans_temp[ans_id*36+7]+=Pmtrx[27]*(P_010011001*QR_011010001000+P_010011101*QR_011010001001+P_010111001*QR_011010001010+P_010111101*QR_011010001011+P_010211001*QR_011010001020+P_010211101*QR_011010001021+P_110011001*QR_011010001100+P_110011101*QR_011010001101+P_110111001*QR_011010001110+P_110111101*QR_011010001111+P_110211001*QR_011010001120+P_110211101*QR_011010001121); ans_temp[ans_id*36+7]+=Pmtrx[28]*(P_010011001*QR_010011001000+P_010011101*QR_010011001001+P_010111001*QR_010011001010+P_010111101*QR_010011001011+P_010211001*QR_010011001020+P_010211101*QR_010011001021+P_110011001*QR_010011001100+P_110011101*QR_010011001101+P_110111001*QR_010011001110+P_110111101*QR_010011001111+P_110211001*QR_010011001120+P_110211101*QR_010011001121); ans_temp[ans_id*36+7]+=Pmtrx[29]*(P_010011001*QR_010010002000+P_010011101*QR_010010002001+P_010111001*QR_010010002010+P_010111101*QR_010010002011+P_010211001*QR_010010002020+P_010211101*QR_010010002021+P_110011001*QR_010010002100+P_110011101*QR_010010002101+P_110111001*QR_010010002110+P_110111101*QR_010010002111+P_110211001*QR_010010002120+P_110211101*QR_010010002121); ans_temp[ans_id*36+8]+=Pmtrx[24]*(P_010011001*QR_002020000000+P_010011101*QR_002020000001+P_010111001*QR_002020000010+P_010111101*QR_002020000011+P_010211001*QR_002020000020+P_010211101*QR_002020000021+P_110011001*QR_002020000100+P_110011101*QR_002020000101+P_110111001*QR_002020000110+P_110111101*QR_002020000111+P_110211001*QR_002020000120+P_110211101*QR_002020000121); ans_temp[ans_id*36+8]+=Pmtrx[25]*(P_010011001*QR_001021000000+P_010011101*QR_001021000001+P_010111001*QR_001021000010+P_010111101*QR_001021000011+P_010211001*QR_001021000020+P_010211101*QR_001021000021+P_110011001*QR_001021000100+P_110011101*QR_001021000101+P_110111001*QR_001021000110+P_110111101*QR_001021000111+P_110211001*QR_001021000120+P_110211101*QR_001021000121); ans_temp[ans_id*36+8]+=Pmtrx[26]*(P_010011001*QR_000022000000+P_010011101*QR_000022000001+P_010111001*QR_000022000010+P_010111101*QR_000022000011+P_010211001*QR_000022000020+P_010211101*QR_000022000021+P_110011001*QR_000022000100+P_110011101*QR_000022000101+P_110111001*QR_000022000110+P_110111101*QR_000022000111+P_110211001*QR_000022000120+P_110211101*QR_000022000121); ans_temp[ans_id*36+8]+=Pmtrx[27]*(P_010011001*QR_001020001000+P_010011101*QR_001020001001+P_010111001*QR_001020001010+P_010111101*QR_001020001011+P_010211001*QR_001020001020+P_010211101*QR_001020001021+P_110011001*QR_001020001100+P_110011101*QR_001020001101+P_110111001*QR_001020001110+P_110111101*QR_001020001111+P_110211001*QR_001020001120+P_110211101*QR_001020001121); ans_temp[ans_id*36+8]+=Pmtrx[28]*(P_010011001*QR_000021001000+P_010011101*QR_000021001001+P_010111001*QR_000021001010+P_010111101*QR_000021001011+P_010211001*QR_000021001020+P_010211101*QR_000021001021+P_110011001*QR_000021001100+P_110011101*QR_000021001101+P_110111001*QR_000021001110+P_110111101*QR_000021001111+P_110211001*QR_000021001120+P_110211101*QR_000021001121); ans_temp[ans_id*36+8]+=Pmtrx[29]*(P_010011001*QR_000020002000+P_010011101*QR_000020002001+P_010111001*QR_000020002010+P_010111101*QR_000020002011+P_010211001*QR_000020002020+P_010211101*QR_000020002021+P_110011001*QR_000020002100+P_110011101*QR_000020002101+P_110111001*QR_000020002110+P_110111101*QR_000020002111+P_110211001*QR_000020002120+P_110211101*QR_000020002121); ans_temp[ans_id*36+9]+=Pmtrx[24]*(P_010011001*QR_012000010000+P_010011101*QR_012000010001+P_010111001*QR_012000010010+P_010111101*QR_012000010011+P_010211001*QR_012000010020+P_010211101*QR_012000010021+P_110011001*QR_012000010100+P_110011101*QR_012000010101+P_110111001*QR_012000010110+P_110111101*QR_012000010111+P_110211001*QR_012000010120+P_110211101*QR_012000010121); ans_temp[ans_id*36+9]+=Pmtrx[25]*(P_010011001*QR_011001010000+P_010011101*QR_011001010001+P_010111001*QR_011001010010+P_010111101*QR_011001010011+P_010211001*QR_011001010020+P_010211101*QR_011001010021+P_110011001*QR_011001010100+P_110011101*QR_011001010101+P_110111001*QR_011001010110+P_110111101*QR_011001010111+P_110211001*QR_011001010120+P_110211101*QR_011001010121); ans_temp[ans_id*36+9]+=Pmtrx[26]*(P_010011001*QR_010002010000+P_010011101*QR_010002010001+P_010111001*QR_010002010010+P_010111101*QR_010002010011+P_010211001*QR_010002010020+P_010211101*QR_010002010021+P_110011001*QR_010002010100+P_110011101*QR_010002010101+P_110111001*QR_010002010110+P_110111101*QR_010002010111+P_110211001*QR_010002010120+P_110211101*QR_010002010121); ans_temp[ans_id*36+9]+=Pmtrx[27]*(P_010011001*QR_011000011000+P_010011101*QR_011000011001+P_010111001*QR_011000011010+P_010111101*QR_011000011011+P_010211001*QR_011000011020+P_010211101*QR_011000011021+P_110011001*QR_011000011100+P_110011101*QR_011000011101+P_110111001*QR_011000011110+P_110111101*QR_011000011111+P_110211001*QR_011000011120+P_110211101*QR_011000011121); ans_temp[ans_id*36+9]+=Pmtrx[28]*(P_010011001*QR_010001011000+P_010011101*QR_010001011001+P_010111001*QR_010001011010+P_010111101*QR_010001011011+P_010211001*QR_010001011020+P_010211101*QR_010001011021+P_110011001*QR_010001011100+P_110011101*QR_010001011101+P_110111001*QR_010001011110+P_110111101*QR_010001011111+P_110211001*QR_010001011120+P_110211101*QR_010001011121); ans_temp[ans_id*36+9]+=Pmtrx[29]*(P_010011001*QR_010000012000+P_010011101*QR_010000012001+P_010111001*QR_010000012010+P_010111101*QR_010000012011+P_010211001*QR_010000012020+P_010211101*QR_010000012021+P_110011001*QR_010000012100+P_110011101*QR_010000012101+P_110111001*QR_010000012110+P_110111101*QR_010000012111+P_110211001*QR_010000012120+P_110211101*QR_010000012121); ans_temp[ans_id*36+10]+=Pmtrx[24]*(P_010011001*QR_002010010000+P_010011101*QR_002010010001+P_010111001*QR_002010010010+P_010111101*QR_002010010011+P_010211001*QR_002010010020+P_010211101*QR_002010010021+P_110011001*QR_002010010100+P_110011101*QR_002010010101+P_110111001*QR_002010010110+P_110111101*QR_002010010111+P_110211001*QR_002010010120+P_110211101*QR_002010010121); ans_temp[ans_id*36+10]+=Pmtrx[25]*(P_010011001*QR_001011010000+P_010011101*QR_001011010001+P_010111001*QR_001011010010+P_010111101*QR_001011010011+P_010211001*QR_001011010020+P_010211101*QR_001011010021+P_110011001*QR_001011010100+P_110011101*QR_001011010101+P_110111001*QR_001011010110+P_110111101*QR_001011010111+P_110211001*QR_001011010120+P_110211101*QR_001011010121); ans_temp[ans_id*36+10]+=Pmtrx[26]*(P_010011001*QR_000012010000+P_010011101*QR_000012010001+P_010111001*QR_000012010010+P_010111101*QR_000012010011+P_010211001*QR_000012010020+P_010211101*QR_000012010021+P_110011001*QR_000012010100+P_110011101*QR_000012010101+P_110111001*QR_000012010110+P_110111101*QR_000012010111+P_110211001*QR_000012010120+P_110211101*QR_000012010121); ans_temp[ans_id*36+10]+=Pmtrx[27]*(P_010011001*QR_001010011000+P_010011101*QR_001010011001+P_010111001*QR_001010011010+P_010111101*QR_001010011011+P_010211001*QR_001010011020+P_010211101*QR_001010011021+P_110011001*QR_001010011100+P_110011101*QR_001010011101+P_110111001*QR_001010011110+P_110111101*QR_001010011111+P_110211001*QR_001010011120+P_110211101*QR_001010011121); ans_temp[ans_id*36+10]+=Pmtrx[28]*(P_010011001*QR_000011011000+P_010011101*QR_000011011001+P_010111001*QR_000011011010+P_010111101*QR_000011011011+P_010211001*QR_000011011020+P_010211101*QR_000011011021+P_110011001*QR_000011011100+P_110011101*QR_000011011101+P_110111001*QR_000011011110+P_110111101*QR_000011011111+P_110211001*QR_000011011120+P_110211101*QR_000011011121); ans_temp[ans_id*36+10]+=Pmtrx[29]*(P_010011001*QR_000010012000+P_010011101*QR_000010012001+P_010111001*QR_000010012010+P_010111101*QR_000010012011+P_010211001*QR_000010012020+P_010211101*QR_000010012021+P_110011001*QR_000010012100+P_110011101*QR_000010012101+P_110111001*QR_000010012110+P_110111101*QR_000010012111+P_110211001*QR_000010012120+P_110211101*QR_000010012121); ans_temp[ans_id*36+11]+=Pmtrx[24]*(P_010011001*QR_002000020000+P_010011101*QR_002000020001+P_010111001*QR_002000020010+P_010111101*QR_002000020011+P_010211001*QR_002000020020+P_010211101*QR_002000020021+P_110011001*QR_002000020100+P_110011101*QR_002000020101+P_110111001*QR_002000020110+P_110111101*QR_002000020111+P_110211001*QR_002000020120+P_110211101*QR_002000020121); ans_temp[ans_id*36+11]+=Pmtrx[25]*(P_010011001*QR_001001020000+P_010011101*QR_001001020001+P_010111001*QR_001001020010+P_010111101*QR_001001020011+P_010211001*QR_001001020020+P_010211101*QR_001001020021+P_110011001*QR_001001020100+P_110011101*QR_001001020101+P_110111001*QR_001001020110+P_110111101*QR_001001020111+P_110211001*QR_001001020120+P_110211101*QR_001001020121); ans_temp[ans_id*36+11]+=Pmtrx[26]*(P_010011001*QR_000002020000+P_010011101*QR_000002020001+P_010111001*QR_000002020010+P_010111101*QR_000002020011+P_010211001*QR_000002020020+P_010211101*QR_000002020021+P_110011001*QR_000002020100+P_110011101*QR_000002020101+P_110111001*QR_000002020110+P_110111101*QR_000002020111+P_110211001*QR_000002020120+P_110211101*QR_000002020121); ans_temp[ans_id*36+11]+=Pmtrx[27]*(P_010011001*QR_001000021000+P_010011101*QR_001000021001+P_010111001*QR_001000021010+P_010111101*QR_001000021011+P_010211001*QR_001000021020+P_010211101*QR_001000021021+P_110011001*QR_001000021100+P_110011101*QR_001000021101+P_110111001*QR_001000021110+P_110111101*QR_001000021111+P_110211001*QR_001000021120+P_110211101*QR_001000021121); ans_temp[ans_id*36+11]+=Pmtrx[28]*(P_010011001*QR_000001021000+P_010011101*QR_000001021001+P_010111001*QR_000001021010+P_010111101*QR_000001021011+P_010211001*QR_000001021020+P_010211101*QR_000001021021+P_110011001*QR_000001021100+P_110011101*QR_000001021101+P_110111001*QR_000001021110+P_110111101*QR_000001021111+P_110211001*QR_000001021120+P_110211101*QR_000001021121); ans_temp[ans_id*36+11]+=Pmtrx[29]*(P_010011001*QR_000000022000+P_010011101*QR_000000022001+P_010111001*QR_000000022010+P_010111101*QR_000000022011+P_010211001*QR_000000022020+P_010211101*QR_000000022021+P_110011001*QR_000000022100+P_110011101*QR_000000022101+P_110111001*QR_000000022110+P_110111101*QR_000000022111+P_110211001*QR_000000022120+P_110211101*QR_000000022121); ans_temp[ans_id*36+6]+=Pmtrx[30]*(P_010010002*QR_022000000000+P_010010102*QR_022000000001+P_010010202*QR_022000000002+P_010110002*QR_022000000010+P_010110102*QR_022000000011+P_010110202*QR_022000000012+P_110010002*QR_022000000100+P_110010102*QR_022000000101+P_110010202*QR_022000000102+P_110110002*QR_022000000110+P_110110102*QR_022000000111+P_110110202*QR_022000000112); ans_temp[ans_id*36+6]+=Pmtrx[31]*(P_010010002*QR_021001000000+P_010010102*QR_021001000001+P_010010202*QR_021001000002+P_010110002*QR_021001000010+P_010110102*QR_021001000011+P_010110202*QR_021001000012+P_110010002*QR_021001000100+P_110010102*QR_021001000101+P_110010202*QR_021001000102+P_110110002*QR_021001000110+P_110110102*QR_021001000111+P_110110202*QR_021001000112); ans_temp[ans_id*36+6]+=Pmtrx[32]*(P_010010002*QR_020002000000+P_010010102*QR_020002000001+P_010010202*QR_020002000002+P_010110002*QR_020002000010+P_010110102*QR_020002000011+P_010110202*QR_020002000012+P_110010002*QR_020002000100+P_110010102*QR_020002000101+P_110010202*QR_020002000102+P_110110002*QR_020002000110+P_110110102*QR_020002000111+P_110110202*QR_020002000112); ans_temp[ans_id*36+6]+=Pmtrx[33]*(P_010010002*QR_021000001000+P_010010102*QR_021000001001+P_010010202*QR_021000001002+P_010110002*QR_021000001010+P_010110102*QR_021000001011+P_010110202*QR_021000001012+P_110010002*QR_021000001100+P_110010102*QR_021000001101+P_110010202*QR_021000001102+P_110110002*QR_021000001110+P_110110102*QR_021000001111+P_110110202*QR_021000001112); ans_temp[ans_id*36+6]+=Pmtrx[34]*(P_010010002*QR_020001001000+P_010010102*QR_020001001001+P_010010202*QR_020001001002+P_010110002*QR_020001001010+P_010110102*QR_020001001011+P_010110202*QR_020001001012+P_110010002*QR_020001001100+P_110010102*QR_020001001101+P_110010202*QR_020001001102+P_110110002*QR_020001001110+P_110110102*QR_020001001111+P_110110202*QR_020001001112); ans_temp[ans_id*36+6]+=Pmtrx[35]*(P_010010002*QR_020000002000+P_010010102*QR_020000002001+P_010010202*QR_020000002002+P_010110002*QR_020000002010+P_010110102*QR_020000002011+P_010110202*QR_020000002012+P_110010002*QR_020000002100+P_110010102*QR_020000002101+P_110010202*QR_020000002102+P_110110002*QR_020000002110+P_110110102*QR_020000002111+P_110110202*QR_020000002112); ans_temp[ans_id*36+7]+=Pmtrx[30]*(P_010010002*QR_012010000000+P_010010102*QR_012010000001+P_010010202*QR_012010000002+P_010110002*QR_012010000010+P_010110102*QR_012010000011+P_010110202*QR_012010000012+P_110010002*QR_012010000100+P_110010102*QR_012010000101+P_110010202*QR_012010000102+P_110110002*QR_012010000110+P_110110102*QR_012010000111+P_110110202*QR_012010000112); ans_temp[ans_id*36+7]+=Pmtrx[31]*(P_010010002*QR_011011000000+P_010010102*QR_011011000001+P_010010202*QR_011011000002+P_010110002*QR_011011000010+P_010110102*QR_011011000011+P_010110202*QR_011011000012+P_110010002*QR_011011000100+P_110010102*QR_011011000101+P_110010202*QR_011011000102+P_110110002*QR_011011000110+P_110110102*QR_011011000111+P_110110202*QR_011011000112); ans_temp[ans_id*36+7]+=Pmtrx[32]*(P_010010002*QR_010012000000+P_010010102*QR_010012000001+P_010010202*QR_010012000002+P_010110002*QR_010012000010+P_010110102*QR_010012000011+P_010110202*QR_010012000012+P_110010002*QR_010012000100+P_110010102*QR_010012000101+P_110010202*QR_010012000102+P_110110002*QR_010012000110+P_110110102*QR_010012000111+P_110110202*QR_010012000112); ans_temp[ans_id*36+7]+=Pmtrx[33]*(P_010010002*QR_011010001000+P_010010102*QR_011010001001+P_010010202*QR_011010001002+P_010110002*QR_011010001010+P_010110102*QR_011010001011+P_010110202*QR_011010001012+P_110010002*QR_011010001100+P_110010102*QR_011010001101+P_110010202*QR_011010001102+P_110110002*QR_011010001110+P_110110102*QR_011010001111+P_110110202*QR_011010001112); ans_temp[ans_id*36+7]+=Pmtrx[34]*(P_010010002*QR_010011001000+P_010010102*QR_010011001001+P_010010202*QR_010011001002+P_010110002*QR_010011001010+P_010110102*QR_010011001011+P_010110202*QR_010011001012+P_110010002*QR_010011001100+P_110010102*QR_010011001101+P_110010202*QR_010011001102+P_110110002*QR_010011001110+P_110110102*QR_010011001111+P_110110202*QR_010011001112); ans_temp[ans_id*36+7]+=Pmtrx[35]*(P_010010002*QR_010010002000+P_010010102*QR_010010002001+P_010010202*QR_010010002002+P_010110002*QR_010010002010+P_010110102*QR_010010002011+P_010110202*QR_010010002012+P_110010002*QR_010010002100+P_110010102*QR_010010002101+P_110010202*QR_010010002102+P_110110002*QR_010010002110+P_110110102*QR_010010002111+P_110110202*QR_010010002112); ans_temp[ans_id*36+8]+=Pmtrx[30]*(P_010010002*QR_002020000000+P_010010102*QR_002020000001+P_010010202*QR_002020000002+P_010110002*QR_002020000010+P_010110102*QR_002020000011+P_010110202*QR_002020000012+P_110010002*QR_002020000100+P_110010102*QR_002020000101+P_110010202*QR_002020000102+P_110110002*QR_002020000110+P_110110102*QR_002020000111+P_110110202*QR_002020000112); ans_temp[ans_id*36+8]+=Pmtrx[31]*(P_010010002*QR_001021000000+P_010010102*QR_001021000001+P_010010202*QR_001021000002+P_010110002*QR_001021000010+P_010110102*QR_001021000011+P_010110202*QR_001021000012+P_110010002*QR_001021000100+P_110010102*QR_001021000101+P_110010202*QR_001021000102+P_110110002*QR_001021000110+P_110110102*QR_001021000111+P_110110202*QR_001021000112); ans_temp[ans_id*36+8]+=Pmtrx[32]*(P_010010002*QR_000022000000+P_010010102*QR_000022000001+P_010010202*QR_000022000002+P_010110002*QR_000022000010+P_010110102*QR_000022000011+P_010110202*QR_000022000012+P_110010002*QR_000022000100+P_110010102*QR_000022000101+P_110010202*QR_000022000102+P_110110002*QR_000022000110+P_110110102*QR_000022000111+P_110110202*QR_000022000112); ans_temp[ans_id*36+8]+=Pmtrx[33]*(P_010010002*QR_001020001000+P_010010102*QR_001020001001+P_010010202*QR_001020001002+P_010110002*QR_001020001010+P_010110102*QR_001020001011+P_010110202*QR_001020001012+P_110010002*QR_001020001100+P_110010102*QR_001020001101+P_110010202*QR_001020001102+P_110110002*QR_001020001110+P_110110102*QR_001020001111+P_110110202*QR_001020001112); ans_temp[ans_id*36+8]+=Pmtrx[34]*(P_010010002*QR_000021001000+P_010010102*QR_000021001001+P_010010202*QR_000021001002+P_010110002*QR_000021001010+P_010110102*QR_000021001011+P_010110202*QR_000021001012+P_110010002*QR_000021001100+P_110010102*QR_000021001101+P_110010202*QR_000021001102+P_110110002*QR_000021001110+P_110110102*QR_000021001111+P_110110202*QR_000021001112); ans_temp[ans_id*36+8]+=Pmtrx[35]*(P_010010002*QR_000020002000+P_010010102*QR_000020002001+P_010010202*QR_000020002002+P_010110002*QR_000020002010+P_010110102*QR_000020002011+P_010110202*QR_000020002012+P_110010002*QR_000020002100+P_110010102*QR_000020002101+P_110010202*QR_000020002102+P_110110002*QR_000020002110+P_110110102*QR_000020002111+P_110110202*QR_000020002112); ans_temp[ans_id*36+9]+=Pmtrx[30]*(P_010010002*QR_012000010000+P_010010102*QR_012000010001+P_010010202*QR_012000010002+P_010110002*QR_012000010010+P_010110102*QR_012000010011+P_010110202*QR_012000010012+P_110010002*QR_012000010100+P_110010102*QR_012000010101+P_110010202*QR_012000010102+P_110110002*QR_012000010110+P_110110102*QR_012000010111+P_110110202*QR_012000010112); ans_temp[ans_id*36+9]+=Pmtrx[31]*(P_010010002*QR_011001010000+P_010010102*QR_011001010001+P_010010202*QR_011001010002+P_010110002*QR_011001010010+P_010110102*QR_011001010011+P_010110202*QR_011001010012+P_110010002*QR_011001010100+P_110010102*QR_011001010101+P_110010202*QR_011001010102+P_110110002*QR_011001010110+P_110110102*QR_011001010111+P_110110202*QR_011001010112); ans_temp[ans_id*36+9]+=Pmtrx[32]*(P_010010002*QR_010002010000+P_010010102*QR_010002010001+P_010010202*QR_010002010002+P_010110002*QR_010002010010+P_010110102*QR_010002010011+P_010110202*QR_010002010012+P_110010002*QR_010002010100+P_110010102*QR_010002010101+P_110010202*QR_010002010102+P_110110002*QR_010002010110+P_110110102*QR_010002010111+P_110110202*QR_010002010112); ans_temp[ans_id*36+9]+=Pmtrx[33]*(P_010010002*QR_011000011000+P_010010102*QR_011000011001+P_010010202*QR_011000011002+P_010110002*QR_011000011010+P_010110102*QR_011000011011+P_010110202*QR_011000011012+P_110010002*QR_011000011100+P_110010102*QR_011000011101+P_110010202*QR_011000011102+P_110110002*QR_011000011110+P_110110102*QR_011000011111+P_110110202*QR_011000011112); ans_temp[ans_id*36+9]+=Pmtrx[34]*(P_010010002*QR_010001011000+P_010010102*QR_010001011001+P_010010202*QR_010001011002+P_010110002*QR_010001011010+P_010110102*QR_010001011011+P_010110202*QR_010001011012+P_110010002*QR_010001011100+P_110010102*QR_010001011101+P_110010202*QR_010001011102+P_110110002*QR_010001011110+P_110110102*QR_010001011111+P_110110202*QR_010001011112); ans_temp[ans_id*36+9]+=Pmtrx[35]*(P_010010002*QR_010000012000+P_010010102*QR_010000012001+P_010010202*QR_010000012002+P_010110002*QR_010000012010+P_010110102*QR_010000012011+P_010110202*QR_010000012012+P_110010002*QR_010000012100+P_110010102*QR_010000012101+P_110010202*QR_010000012102+P_110110002*QR_010000012110+P_110110102*QR_010000012111+P_110110202*QR_010000012112); ans_temp[ans_id*36+10]+=Pmtrx[30]*(P_010010002*QR_002010010000+P_010010102*QR_002010010001+P_010010202*QR_002010010002+P_010110002*QR_002010010010+P_010110102*QR_002010010011+P_010110202*QR_002010010012+P_110010002*QR_002010010100+P_110010102*QR_002010010101+P_110010202*QR_002010010102+P_110110002*QR_002010010110+P_110110102*QR_002010010111+P_110110202*QR_002010010112); ans_temp[ans_id*36+10]+=Pmtrx[31]*(P_010010002*QR_001011010000+P_010010102*QR_001011010001+P_010010202*QR_001011010002+P_010110002*QR_001011010010+P_010110102*QR_001011010011+P_010110202*QR_001011010012+P_110010002*QR_001011010100+P_110010102*QR_001011010101+P_110010202*QR_001011010102+P_110110002*QR_001011010110+P_110110102*QR_001011010111+P_110110202*QR_001011010112); ans_temp[ans_id*36+10]+=Pmtrx[32]*(P_010010002*QR_000012010000+P_010010102*QR_000012010001+P_010010202*QR_000012010002+P_010110002*QR_000012010010+P_010110102*QR_000012010011+P_010110202*QR_000012010012+P_110010002*QR_000012010100+P_110010102*QR_000012010101+P_110010202*QR_000012010102+P_110110002*QR_000012010110+P_110110102*QR_000012010111+P_110110202*QR_000012010112); ans_temp[ans_id*36+10]+=Pmtrx[33]*(P_010010002*QR_001010011000+P_010010102*QR_001010011001+P_010010202*QR_001010011002+P_010110002*QR_001010011010+P_010110102*QR_001010011011+P_010110202*QR_001010011012+P_110010002*QR_001010011100+P_110010102*QR_001010011101+P_110010202*QR_001010011102+P_110110002*QR_001010011110+P_110110102*QR_001010011111+P_110110202*QR_001010011112); ans_temp[ans_id*36+10]+=Pmtrx[34]*(P_010010002*QR_000011011000+P_010010102*QR_000011011001+P_010010202*QR_000011011002+P_010110002*QR_000011011010+P_010110102*QR_000011011011+P_010110202*QR_000011011012+P_110010002*QR_000011011100+P_110010102*QR_000011011101+P_110010202*QR_000011011102+P_110110002*QR_000011011110+P_110110102*QR_000011011111+P_110110202*QR_000011011112); ans_temp[ans_id*36+10]+=Pmtrx[35]*(P_010010002*QR_000010012000+P_010010102*QR_000010012001+P_010010202*QR_000010012002+P_010110002*QR_000010012010+P_010110102*QR_000010012011+P_010110202*QR_000010012012+P_110010002*QR_000010012100+P_110010102*QR_000010012101+P_110010202*QR_000010012102+P_110110002*QR_000010012110+P_110110102*QR_000010012111+P_110110202*QR_000010012112); ans_temp[ans_id*36+11]+=Pmtrx[30]*(P_010010002*QR_002000020000+P_010010102*QR_002000020001+P_010010202*QR_002000020002+P_010110002*QR_002000020010+P_010110102*QR_002000020011+P_010110202*QR_002000020012+P_110010002*QR_002000020100+P_110010102*QR_002000020101+P_110010202*QR_002000020102+P_110110002*QR_002000020110+P_110110102*QR_002000020111+P_110110202*QR_002000020112); ans_temp[ans_id*36+11]+=Pmtrx[31]*(P_010010002*QR_001001020000+P_010010102*QR_001001020001+P_010010202*QR_001001020002+P_010110002*QR_001001020010+P_010110102*QR_001001020011+P_010110202*QR_001001020012+P_110010002*QR_001001020100+P_110010102*QR_001001020101+P_110010202*QR_001001020102+P_110110002*QR_001001020110+P_110110102*QR_001001020111+P_110110202*QR_001001020112); ans_temp[ans_id*36+11]+=Pmtrx[32]*(P_010010002*QR_000002020000+P_010010102*QR_000002020001+P_010010202*QR_000002020002+P_010110002*QR_000002020010+P_010110102*QR_000002020011+P_010110202*QR_000002020012+P_110010002*QR_000002020100+P_110010102*QR_000002020101+P_110010202*QR_000002020102+P_110110002*QR_000002020110+P_110110102*QR_000002020111+P_110110202*QR_000002020112); ans_temp[ans_id*36+11]+=Pmtrx[33]*(P_010010002*QR_001000021000+P_010010102*QR_001000021001+P_010010202*QR_001000021002+P_010110002*QR_001000021010+P_010110102*QR_001000021011+P_010110202*QR_001000021012+P_110010002*QR_001000021100+P_110010102*QR_001000021101+P_110010202*QR_001000021102+P_110110002*QR_001000021110+P_110110102*QR_001000021111+P_110110202*QR_001000021112); ans_temp[ans_id*36+11]+=Pmtrx[34]*(P_010010002*QR_000001021000+P_010010102*QR_000001021001+P_010010202*QR_000001021002+P_010110002*QR_000001021010+P_010110102*QR_000001021011+P_010110202*QR_000001021012+P_110010002*QR_000001021100+P_110010102*QR_000001021101+P_110010202*QR_000001021102+P_110110002*QR_000001021110+P_110110102*QR_000001021111+P_110110202*QR_000001021112); ans_temp[ans_id*36+11]+=Pmtrx[35]*(P_010010002*QR_000000022000+P_010010102*QR_000000022001+P_010010202*QR_000000022002+P_010110002*QR_000000022010+P_010110102*QR_000000022011+P_010110202*QR_000000022012+P_110010002*QR_000000022100+P_110010102*QR_000000022101+P_110010202*QR_000000022102+P_110110002*QR_000000022110+P_110110102*QR_000000022111+P_110110202*QR_000000022112); ans_temp[ans_id*36+12]+=Pmtrx[0]*(P_002020000*QR_022000000000+P_002120000*QR_022000000010+P_002220000*QR_022000000020+P_102020000*QR_022000000100+P_102120000*QR_022000000110+P_102220000*QR_022000000120+P_202020000*QR_022000000200+P_202120000*QR_022000000210+P_202220000*QR_022000000220); ans_temp[ans_id*36+12]+=Pmtrx[1]*(P_002020000*QR_021001000000+P_002120000*QR_021001000010+P_002220000*QR_021001000020+P_102020000*QR_021001000100+P_102120000*QR_021001000110+P_102220000*QR_021001000120+P_202020000*QR_021001000200+P_202120000*QR_021001000210+P_202220000*QR_021001000220); ans_temp[ans_id*36+12]+=Pmtrx[2]*(P_002020000*QR_020002000000+P_002120000*QR_020002000010+P_002220000*QR_020002000020+P_102020000*QR_020002000100+P_102120000*QR_020002000110+P_102220000*QR_020002000120+P_202020000*QR_020002000200+P_202120000*QR_020002000210+P_202220000*QR_020002000220); ans_temp[ans_id*36+12]+=Pmtrx[3]*(P_002020000*QR_021000001000+P_002120000*QR_021000001010+P_002220000*QR_021000001020+P_102020000*QR_021000001100+P_102120000*QR_021000001110+P_102220000*QR_021000001120+P_202020000*QR_021000001200+P_202120000*QR_021000001210+P_202220000*QR_021000001220); ans_temp[ans_id*36+12]+=Pmtrx[4]*(P_002020000*QR_020001001000+P_002120000*QR_020001001010+P_002220000*QR_020001001020+P_102020000*QR_020001001100+P_102120000*QR_020001001110+P_102220000*QR_020001001120+P_202020000*QR_020001001200+P_202120000*QR_020001001210+P_202220000*QR_020001001220); ans_temp[ans_id*36+12]+=Pmtrx[5]*(P_002020000*QR_020000002000+P_002120000*QR_020000002010+P_002220000*QR_020000002020+P_102020000*QR_020000002100+P_102120000*QR_020000002110+P_102220000*QR_020000002120+P_202020000*QR_020000002200+P_202120000*QR_020000002210+P_202220000*QR_020000002220); ans_temp[ans_id*36+13]+=Pmtrx[0]*(P_002020000*QR_012010000000+P_002120000*QR_012010000010+P_002220000*QR_012010000020+P_102020000*QR_012010000100+P_102120000*QR_012010000110+P_102220000*QR_012010000120+P_202020000*QR_012010000200+P_202120000*QR_012010000210+P_202220000*QR_012010000220); ans_temp[ans_id*36+13]+=Pmtrx[1]*(P_002020000*QR_011011000000+P_002120000*QR_011011000010+P_002220000*QR_011011000020+P_102020000*QR_011011000100+P_102120000*QR_011011000110+P_102220000*QR_011011000120+P_202020000*QR_011011000200+P_202120000*QR_011011000210+P_202220000*QR_011011000220); ans_temp[ans_id*36+13]+=Pmtrx[2]*(P_002020000*QR_010012000000+P_002120000*QR_010012000010+P_002220000*QR_010012000020+P_102020000*QR_010012000100+P_102120000*QR_010012000110+P_102220000*QR_010012000120+P_202020000*QR_010012000200+P_202120000*QR_010012000210+P_202220000*QR_010012000220); ans_temp[ans_id*36+13]+=Pmtrx[3]*(P_002020000*QR_011010001000+P_002120000*QR_011010001010+P_002220000*QR_011010001020+P_102020000*QR_011010001100+P_102120000*QR_011010001110+P_102220000*QR_011010001120+P_202020000*QR_011010001200+P_202120000*QR_011010001210+P_202220000*QR_011010001220); ans_temp[ans_id*36+13]+=Pmtrx[4]*(P_002020000*QR_010011001000+P_002120000*QR_010011001010+P_002220000*QR_010011001020+P_102020000*QR_010011001100+P_102120000*QR_010011001110+P_102220000*QR_010011001120+P_202020000*QR_010011001200+P_202120000*QR_010011001210+P_202220000*QR_010011001220); ans_temp[ans_id*36+13]+=Pmtrx[5]*(P_002020000*QR_010010002000+P_002120000*QR_010010002010+P_002220000*QR_010010002020+P_102020000*QR_010010002100+P_102120000*QR_010010002110+P_102220000*QR_010010002120+P_202020000*QR_010010002200+P_202120000*QR_010010002210+P_202220000*QR_010010002220); ans_temp[ans_id*36+14]+=Pmtrx[0]*(P_002020000*QR_002020000000+P_002120000*QR_002020000010+P_002220000*QR_002020000020+P_102020000*QR_002020000100+P_102120000*QR_002020000110+P_102220000*QR_002020000120+P_202020000*QR_002020000200+P_202120000*QR_002020000210+P_202220000*QR_002020000220); ans_temp[ans_id*36+14]+=Pmtrx[1]*(P_002020000*QR_001021000000+P_002120000*QR_001021000010+P_002220000*QR_001021000020+P_102020000*QR_001021000100+P_102120000*QR_001021000110+P_102220000*QR_001021000120+P_202020000*QR_001021000200+P_202120000*QR_001021000210+P_202220000*QR_001021000220); ans_temp[ans_id*36+14]+=Pmtrx[2]*(P_002020000*QR_000022000000+P_002120000*QR_000022000010+P_002220000*QR_000022000020+P_102020000*QR_000022000100+P_102120000*QR_000022000110+P_102220000*QR_000022000120+P_202020000*QR_000022000200+P_202120000*QR_000022000210+P_202220000*QR_000022000220); ans_temp[ans_id*36+14]+=Pmtrx[3]*(P_002020000*QR_001020001000+P_002120000*QR_001020001010+P_002220000*QR_001020001020+P_102020000*QR_001020001100+P_102120000*QR_001020001110+P_102220000*QR_001020001120+P_202020000*QR_001020001200+P_202120000*QR_001020001210+P_202220000*QR_001020001220); ans_temp[ans_id*36+14]+=Pmtrx[4]*(P_002020000*QR_000021001000+P_002120000*QR_000021001010+P_002220000*QR_000021001020+P_102020000*QR_000021001100+P_102120000*QR_000021001110+P_102220000*QR_000021001120+P_202020000*QR_000021001200+P_202120000*QR_000021001210+P_202220000*QR_000021001220); ans_temp[ans_id*36+14]+=Pmtrx[5]*(P_002020000*QR_000020002000+P_002120000*QR_000020002010+P_002220000*QR_000020002020+P_102020000*QR_000020002100+P_102120000*QR_000020002110+P_102220000*QR_000020002120+P_202020000*QR_000020002200+P_202120000*QR_000020002210+P_202220000*QR_000020002220); ans_temp[ans_id*36+15]+=Pmtrx[0]*(P_002020000*QR_012000010000+P_002120000*QR_012000010010+P_002220000*QR_012000010020+P_102020000*QR_012000010100+P_102120000*QR_012000010110+P_102220000*QR_012000010120+P_202020000*QR_012000010200+P_202120000*QR_012000010210+P_202220000*QR_012000010220); ans_temp[ans_id*36+15]+=Pmtrx[1]*(P_002020000*QR_011001010000+P_002120000*QR_011001010010+P_002220000*QR_011001010020+P_102020000*QR_011001010100+P_102120000*QR_011001010110+P_102220000*QR_011001010120+P_202020000*QR_011001010200+P_202120000*QR_011001010210+P_202220000*QR_011001010220); ans_temp[ans_id*36+15]+=Pmtrx[2]*(P_002020000*QR_010002010000+P_002120000*QR_010002010010+P_002220000*QR_010002010020+P_102020000*QR_010002010100+P_102120000*QR_010002010110+P_102220000*QR_010002010120+P_202020000*QR_010002010200+P_202120000*QR_010002010210+P_202220000*QR_010002010220); ans_temp[ans_id*36+15]+=Pmtrx[3]*(P_002020000*QR_011000011000+P_002120000*QR_011000011010+P_002220000*QR_011000011020+P_102020000*QR_011000011100+P_102120000*QR_011000011110+P_102220000*QR_011000011120+P_202020000*QR_011000011200+P_202120000*QR_011000011210+P_202220000*QR_011000011220); ans_temp[ans_id*36+15]+=Pmtrx[4]*(P_002020000*QR_010001011000+P_002120000*QR_010001011010+P_002220000*QR_010001011020+P_102020000*QR_010001011100+P_102120000*QR_010001011110+P_102220000*QR_010001011120+P_202020000*QR_010001011200+P_202120000*QR_010001011210+P_202220000*QR_010001011220); ans_temp[ans_id*36+15]+=Pmtrx[5]*(P_002020000*QR_010000012000+P_002120000*QR_010000012010+P_002220000*QR_010000012020+P_102020000*QR_010000012100+P_102120000*QR_010000012110+P_102220000*QR_010000012120+P_202020000*QR_010000012200+P_202120000*QR_010000012210+P_202220000*QR_010000012220); ans_temp[ans_id*36+16]+=Pmtrx[0]*(P_002020000*QR_002010010000+P_002120000*QR_002010010010+P_002220000*QR_002010010020+P_102020000*QR_002010010100+P_102120000*QR_002010010110+P_102220000*QR_002010010120+P_202020000*QR_002010010200+P_202120000*QR_002010010210+P_202220000*QR_002010010220); ans_temp[ans_id*36+16]+=Pmtrx[1]*(P_002020000*QR_001011010000+P_002120000*QR_001011010010+P_002220000*QR_001011010020+P_102020000*QR_001011010100+P_102120000*QR_001011010110+P_102220000*QR_001011010120+P_202020000*QR_001011010200+P_202120000*QR_001011010210+P_202220000*QR_001011010220); ans_temp[ans_id*36+16]+=Pmtrx[2]*(P_002020000*QR_000012010000+P_002120000*QR_000012010010+P_002220000*QR_000012010020+P_102020000*QR_000012010100+P_102120000*QR_000012010110+P_102220000*QR_000012010120+P_202020000*QR_000012010200+P_202120000*QR_000012010210+P_202220000*QR_000012010220); ans_temp[ans_id*36+16]+=Pmtrx[3]*(P_002020000*QR_001010011000+P_002120000*QR_001010011010+P_002220000*QR_001010011020+P_102020000*QR_001010011100+P_102120000*QR_001010011110+P_102220000*QR_001010011120+P_202020000*QR_001010011200+P_202120000*QR_001010011210+P_202220000*QR_001010011220); ans_temp[ans_id*36+16]+=Pmtrx[4]*(P_002020000*QR_000011011000+P_002120000*QR_000011011010+P_002220000*QR_000011011020+P_102020000*QR_000011011100+P_102120000*QR_000011011110+P_102220000*QR_000011011120+P_202020000*QR_000011011200+P_202120000*QR_000011011210+P_202220000*QR_000011011220); ans_temp[ans_id*36+16]+=Pmtrx[5]*(P_002020000*QR_000010012000+P_002120000*QR_000010012010+P_002220000*QR_000010012020+P_102020000*QR_000010012100+P_102120000*QR_000010012110+P_102220000*QR_000010012120+P_202020000*QR_000010012200+P_202120000*QR_000010012210+P_202220000*QR_000010012220); ans_temp[ans_id*36+17]+=Pmtrx[0]*(P_002020000*QR_002000020000+P_002120000*QR_002000020010+P_002220000*QR_002000020020+P_102020000*QR_002000020100+P_102120000*QR_002000020110+P_102220000*QR_002000020120+P_202020000*QR_002000020200+P_202120000*QR_002000020210+P_202220000*QR_002000020220); ans_temp[ans_id*36+17]+=Pmtrx[1]*(P_002020000*QR_001001020000+P_002120000*QR_001001020010+P_002220000*QR_001001020020+P_102020000*QR_001001020100+P_102120000*QR_001001020110+P_102220000*QR_001001020120+P_202020000*QR_001001020200+P_202120000*QR_001001020210+P_202220000*QR_001001020220); ans_temp[ans_id*36+17]+=Pmtrx[2]*(P_002020000*QR_000002020000+P_002120000*QR_000002020010+P_002220000*QR_000002020020+P_102020000*QR_000002020100+P_102120000*QR_000002020110+P_102220000*QR_000002020120+P_202020000*QR_000002020200+P_202120000*QR_000002020210+P_202220000*QR_000002020220); ans_temp[ans_id*36+17]+=Pmtrx[3]*(P_002020000*QR_001000021000+P_002120000*QR_001000021010+P_002220000*QR_001000021020+P_102020000*QR_001000021100+P_102120000*QR_001000021110+P_102220000*QR_001000021120+P_202020000*QR_001000021200+P_202120000*QR_001000021210+P_202220000*QR_001000021220); ans_temp[ans_id*36+17]+=Pmtrx[4]*(P_002020000*QR_000001021000+P_002120000*QR_000001021010+P_002220000*QR_000001021020+P_102020000*QR_000001021100+P_102120000*QR_000001021110+P_102220000*QR_000001021120+P_202020000*QR_000001021200+P_202120000*QR_000001021210+P_202220000*QR_000001021220); ans_temp[ans_id*36+17]+=Pmtrx[5]*(P_002020000*QR_000000022000+P_002120000*QR_000000022010+P_002220000*QR_000000022020+P_102020000*QR_000000022100+P_102120000*QR_000000022110+P_102220000*QR_000000022120+P_202020000*QR_000000022200+P_202120000*QR_000000022210+P_202220000*QR_000000022220); ans_temp[ans_id*36+12]+=Pmtrx[6]*(P_001021000*QR_022000000000+P_001121000*QR_022000000010+P_001221000*QR_022000000020+P_001321000*QR_022000000030+P_101021000*QR_022000000100+P_101121000*QR_022000000110+P_101221000*QR_022000000120+P_101321000*QR_022000000130); ans_temp[ans_id*36+12]+=Pmtrx[7]*(P_001021000*QR_021001000000+P_001121000*QR_021001000010+P_001221000*QR_021001000020+P_001321000*QR_021001000030+P_101021000*QR_021001000100+P_101121000*QR_021001000110+P_101221000*QR_021001000120+P_101321000*QR_021001000130); ans_temp[ans_id*36+12]+=Pmtrx[8]*(P_001021000*QR_020002000000+P_001121000*QR_020002000010+P_001221000*QR_020002000020+P_001321000*QR_020002000030+P_101021000*QR_020002000100+P_101121000*QR_020002000110+P_101221000*QR_020002000120+P_101321000*QR_020002000130); ans_temp[ans_id*36+12]+=Pmtrx[9]*(P_001021000*QR_021000001000+P_001121000*QR_021000001010+P_001221000*QR_021000001020+P_001321000*QR_021000001030+P_101021000*QR_021000001100+P_101121000*QR_021000001110+P_101221000*QR_021000001120+P_101321000*QR_021000001130); ans_temp[ans_id*36+12]+=Pmtrx[10]*(P_001021000*QR_020001001000+P_001121000*QR_020001001010+P_001221000*QR_020001001020+P_001321000*QR_020001001030+P_101021000*QR_020001001100+P_101121000*QR_020001001110+P_101221000*QR_020001001120+P_101321000*QR_020001001130); ans_temp[ans_id*36+12]+=Pmtrx[11]*(P_001021000*QR_020000002000+P_001121000*QR_020000002010+P_001221000*QR_020000002020+P_001321000*QR_020000002030+P_101021000*QR_020000002100+P_101121000*QR_020000002110+P_101221000*QR_020000002120+P_101321000*QR_020000002130); ans_temp[ans_id*36+13]+=Pmtrx[6]*(P_001021000*QR_012010000000+P_001121000*QR_012010000010+P_001221000*QR_012010000020+P_001321000*QR_012010000030+P_101021000*QR_012010000100+P_101121000*QR_012010000110+P_101221000*QR_012010000120+P_101321000*QR_012010000130); ans_temp[ans_id*36+13]+=Pmtrx[7]*(P_001021000*QR_011011000000+P_001121000*QR_011011000010+P_001221000*QR_011011000020+P_001321000*QR_011011000030+P_101021000*QR_011011000100+P_101121000*QR_011011000110+P_101221000*QR_011011000120+P_101321000*QR_011011000130); ans_temp[ans_id*36+13]+=Pmtrx[8]*(P_001021000*QR_010012000000+P_001121000*QR_010012000010+P_001221000*QR_010012000020+P_001321000*QR_010012000030+P_101021000*QR_010012000100+P_101121000*QR_010012000110+P_101221000*QR_010012000120+P_101321000*QR_010012000130); ans_temp[ans_id*36+13]+=Pmtrx[9]*(P_001021000*QR_011010001000+P_001121000*QR_011010001010+P_001221000*QR_011010001020+P_001321000*QR_011010001030+P_101021000*QR_011010001100+P_101121000*QR_011010001110+P_101221000*QR_011010001120+P_101321000*QR_011010001130); ans_temp[ans_id*36+13]+=Pmtrx[10]*(P_001021000*QR_010011001000+P_001121000*QR_010011001010+P_001221000*QR_010011001020+P_001321000*QR_010011001030+P_101021000*QR_010011001100+P_101121000*QR_010011001110+P_101221000*QR_010011001120+P_101321000*QR_010011001130); ans_temp[ans_id*36+13]+=Pmtrx[11]*(P_001021000*QR_010010002000+P_001121000*QR_010010002010+P_001221000*QR_010010002020+P_001321000*QR_010010002030+P_101021000*QR_010010002100+P_101121000*QR_010010002110+P_101221000*QR_010010002120+P_101321000*QR_010010002130); ans_temp[ans_id*36+14]+=Pmtrx[6]*(P_001021000*QR_002020000000+P_001121000*QR_002020000010+P_001221000*QR_002020000020+P_001321000*QR_002020000030+P_101021000*QR_002020000100+P_101121000*QR_002020000110+P_101221000*QR_002020000120+P_101321000*QR_002020000130); ans_temp[ans_id*36+14]+=Pmtrx[7]*(P_001021000*QR_001021000000+P_001121000*QR_001021000010+P_001221000*QR_001021000020+P_001321000*QR_001021000030+P_101021000*QR_001021000100+P_101121000*QR_001021000110+P_101221000*QR_001021000120+P_101321000*QR_001021000130); ans_temp[ans_id*36+14]+=Pmtrx[8]*(P_001021000*QR_000022000000+P_001121000*QR_000022000010+P_001221000*QR_000022000020+P_001321000*QR_000022000030+P_101021000*QR_000022000100+P_101121000*QR_000022000110+P_101221000*QR_000022000120+P_101321000*QR_000022000130); ans_temp[ans_id*36+14]+=Pmtrx[9]*(P_001021000*QR_001020001000+P_001121000*QR_001020001010+P_001221000*QR_001020001020+P_001321000*QR_001020001030+P_101021000*QR_001020001100+P_101121000*QR_001020001110+P_101221000*QR_001020001120+P_101321000*QR_001020001130); ans_temp[ans_id*36+14]+=Pmtrx[10]*(P_001021000*QR_000021001000+P_001121000*QR_000021001010+P_001221000*QR_000021001020+P_001321000*QR_000021001030+P_101021000*QR_000021001100+P_101121000*QR_000021001110+P_101221000*QR_000021001120+P_101321000*QR_000021001130); ans_temp[ans_id*36+14]+=Pmtrx[11]*(P_001021000*QR_000020002000+P_001121000*QR_000020002010+P_001221000*QR_000020002020+P_001321000*QR_000020002030+P_101021000*QR_000020002100+P_101121000*QR_000020002110+P_101221000*QR_000020002120+P_101321000*QR_000020002130); ans_temp[ans_id*36+15]+=Pmtrx[6]*(P_001021000*QR_012000010000+P_001121000*QR_012000010010+P_001221000*QR_012000010020+P_001321000*QR_012000010030+P_101021000*QR_012000010100+P_101121000*QR_012000010110+P_101221000*QR_012000010120+P_101321000*QR_012000010130); ans_temp[ans_id*36+15]+=Pmtrx[7]*(P_001021000*QR_011001010000+P_001121000*QR_011001010010+P_001221000*QR_011001010020+P_001321000*QR_011001010030+P_101021000*QR_011001010100+P_101121000*QR_011001010110+P_101221000*QR_011001010120+P_101321000*QR_011001010130); ans_temp[ans_id*36+15]+=Pmtrx[8]*(P_001021000*QR_010002010000+P_001121000*QR_010002010010+P_001221000*QR_010002010020+P_001321000*QR_010002010030+P_101021000*QR_010002010100+P_101121000*QR_010002010110+P_101221000*QR_010002010120+P_101321000*QR_010002010130); ans_temp[ans_id*36+15]+=Pmtrx[9]*(P_001021000*QR_011000011000+P_001121000*QR_011000011010+P_001221000*QR_011000011020+P_001321000*QR_011000011030+P_101021000*QR_011000011100+P_101121000*QR_011000011110+P_101221000*QR_011000011120+P_101321000*QR_011000011130); ans_temp[ans_id*36+15]+=Pmtrx[10]*(P_001021000*QR_010001011000+P_001121000*QR_010001011010+P_001221000*QR_010001011020+P_001321000*QR_010001011030+P_101021000*QR_010001011100+P_101121000*QR_010001011110+P_101221000*QR_010001011120+P_101321000*QR_010001011130); ans_temp[ans_id*36+15]+=Pmtrx[11]*(P_001021000*QR_010000012000+P_001121000*QR_010000012010+P_001221000*QR_010000012020+P_001321000*QR_010000012030+P_101021000*QR_010000012100+P_101121000*QR_010000012110+P_101221000*QR_010000012120+P_101321000*QR_010000012130); ans_temp[ans_id*36+16]+=Pmtrx[6]*(P_001021000*QR_002010010000+P_001121000*QR_002010010010+P_001221000*QR_002010010020+P_001321000*QR_002010010030+P_101021000*QR_002010010100+P_101121000*QR_002010010110+P_101221000*QR_002010010120+P_101321000*QR_002010010130); ans_temp[ans_id*36+16]+=Pmtrx[7]*(P_001021000*QR_001011010000+P_001121000*QR_001011010010+P_001221000*QR_001011010020+P_001321000*QR_001011010030+P_101021000*QR_001011010100+P_101121000*QR_001011010110+P_101221000*QR_001011010120+P_101321000*QR_001011010130); ans_temp[ans_id*36+16]+=Pmtrx[8]*(P_001021000*QR_000012010000+P_001121000*QR_000012010010+P_001221000*QR_000012010020+P_001321000*QR_000012010030+P_101021000*QR_000012010100+P_101121000*QR_000012010110+P_101221000*QR_000012010120+P_101321000*QR_000012010130); ans_temp[ans_id*36+16]+=Pmtrx[9]*(P_001021000*QR_001010011000+P_001121000*QR_001010011010+P_001221000*QR_001010011020+P_001321000*QR_001010011030+P_101021000*QR_001010011100+P_101121000*QR_001010011110+P_101221000*QR_001010011120+P_101321000*QR_001010011130); ans_temp[ans_id*36+16]+=Pmtrx[10]*(P_001021000*QR_000011011000+P_001121000*QR_000011011010+P_001221000*QR_000011011020+P_001321000*QR_000011011030+P_101021000*QR_000011011100+P_101121000*QR_000011011110+P_101221000*QR_000011011120+P_101321000*QR_000011011130); ans_temp[ans_id*36+16]+=Pmtrx[11]*(P_001021000*QR_000010012000+P_001121000*QR_000010012010+P_001221000*QR_000010012020+P_001321000*QR_000010012030+P_101021000*QR_000010012100+P_101121000*QR_000010012110+P_101221000*QR_000010012120+P_101321000*QR_000010012130); ans_temp[ans_id*36+17]+=Pmtrx[6]*(P_001021000*QR_002000020000+P_001121000*QR_002000020010+P_001221000*QR_002000020020+P_001321000*QR_002000020030+P_101021000*QR_002000020100+P_101121000*QR_002000020110+P_101221000*QR_002000020120+P_101321000*QR_002000020130); ans_temp[ans_id*36+17]+=Pmtrx[7]*(P_001021000*QR_001001020000+P_001121000*QR_001001020010+P_001221000*QR_001001020020+P_001321000*QR_001001020030+P_101021000*QR_001001020100+P_101121000*QR_001001020110+P_101221000*QR_001001020120+P_101321000*QR_001001020130); ans_temp[ans_id*36+17]+=Pmtrx[8]*(P_001021000*QR_000002020000+P_001121000*QR_000002020010+P_001221000*QR_000002020020+P_001321000*QR_000002020030+P_101021000*QR_000002020100+P_101121000*QR_000002020110+P_101221000*QR_000002020120+P_101321000*QR_000002020130); ans_temp[ans_id*36+17]+=Pmtrx[9]*(P_001021000*QR_001000021000+P_001121000*QR_001000021010+P_001221000*QR_001000021020+P_001321000*QR_001000021030+P_101021000*QR_001000021100+P_101121000*QR_001000021110+P_101221000*QR_001000021120+P_101321000*QR_001000021130); ans_temp[ans_id*36+17]+=Pmtrx[10]*(P_001021000*QR_000001021000+P_001121000*QR_000001021010+P_001221000*QR_000001021020+P_001321000*QR_000001021030+P_101021000*QR_000001021100+P_101121000*QR_000001021110+P_101221000*QR_000001021120+P_101321000*QR_000001021130); ans_temp[ans_id*36+17]+=Pmtrx[11]*(P_001021000*QR_000000022000+P_001121000*QR_000000022010+P_001221000*QR_000000022020+P_001321000*QR_000000022030+P_101021000*QR_000000022100+P_101121000*QR_000000022110+P_101221000*QR_000000022120+P_101321000*QR_000000022130); ans_temp[ans_id*36+12]+=Pmtrx[12]*(P_000022000*QR_022000000000+P_000122000*QR_022000000010+P_000222000*QR_022000000020+P_000322000*QR_022000000030+P_000422000*QR_022000000040); ans_temp[ans_id*36+12]+=Pmtrx[13]*(P_000022000*QR_021001000000+P_000122000*QR_021001000010+P_000222000*QR_021001000020+P_000322000*QR_021001000030+P_000422000*QR_021001000040); ans_temp[ans_id*36+12]+=Pmtrx[14]*(P_000022000*QR_020002000000+P_000122000*QR_020002000010+P_000222000*QR_020002000020+P_000322000*QR_020002000030+P_000422000*QR_020002000040); ans_temp[ans_id*36+12]+=Pmtrx[15]*(P_000022000*QR_021000001000+P_000122000*QR_021000001010+P_000222000*QR_021000001020+P_000322000*QR_021000001030+P_000422000*QR_021000001040); ans_temp[ans_id*36+12]+=Pmtrx[16]*(P_000022000*QR_020001001000+P_000122000*QR_020001001010+P_000222000*QR_020001001020+P_000322000*QR_020001001030+P_000422000*QR_020001001040); ans_temp[ans_id*36+12]+=Pmtrx[17]*(P_000022000*QR_020000002000+P_000122000*QR_020000002010+P_000222000*QR_020000002020+P_000322000*QR_020000002030+P_000422000*QR_020000002040); ans_temp[ans_id*36+13]+=Pmtrx[12]*(P_000022000*QR_012010000000+P_000122000*QR_012010000010+P_000222000*QR_012010000020+P_000322000*QR_012010000030+P_000422000*QR_012010000040); ans_temp[ans_id*36+13]+=Pmtrx[13]*(P_000022000*QR_011011000000+P_000122000*QR_011011000010+P_000222000*QR_011011000020+P_000322000*QR_011011000030+P_000422000*QR_011011000040); ans_temp[ans_id*36+13]+=Pmtrx[14]*(P_000022000*QR_010012000000+P_000122000*QR_010012000010+P_000222000*QR_010012000020+P_000322000*QR_010012000030+P_000422000*QR_010012000040); ans_temp[ans_id*36+13]+=Pmtrx[15]*(P_000022000*QR_011010001000+P_000122000*QR_011010001010+P_000222000*QR_011010001020+P_000322000*QR_011010001030+P_000422000*QR_011010001040); ans_temp[ans_id*36+13]+=Pmtrx[16]*(P_000022000*QR_010011001000+P_000122000*QR_010011001010+P_000222000*QR_010011001020+P_000322000*QR_010011001030+P_000422000*QR_010011001040); ans_temp[ans_id*36+13]+=Pmtrx[17]*(P_000022000*QR_010010002000+P_000122000*QR_010010002010+P_000222000*QR_010010002020+P_000322000*QR_010010002030+P_000422000*QR_010010002040); ans_temp[ans_id*36+14]+=Pmtrx[12]*(P_000022000*QR_002020000000+P_000122000*QR_002020000010+P_000222000*QR_002020000020+P_000322000*QR_002020000030+P_000422000*QR_002020000040); ans_temp[ans_id*36+14]+=Pmtrx[13]*(P_000022000*QR_001021000000+P_000122000*QR_001021000010+P_000222000*QR_001021000020+P_000322000*QR_001021000030+P_000422000*QR_001021000040); ans_temp[ans_id*36+14]+=Pmtrx[14]*(P_000022000*QR_000022000000+P_000122000*QR_000022000010+P_000222000*QR_000022000020+P_000322000*QR_000022000030+P_000422000*QR_000022000040); ans_temp[ans_id*36+14]+=Pmtrx[15]*(P_000022000*QR_001020001000+P_000122000*QR_001020001010+P_000222000*QR_001020001020+P_000322000*QR_001020001030+P_000422000*QR_001020001040); ans_temp[ans_id*36+14]+=Pmtrx[16]*(P_000022000*QR_000021001000+P_000122000*QR_000021001010+P_000222000*QR_000021001020+P_000322000*QR_000021001030+P_000422000*QR_000021001040); ans_temp[ans_id*36+14]+=Pmtrx[17]*(P_000022000*QR_000020002000+P_000122000*QR_000020002010+P_000222000*QR_000020002020+P_000322000*QR_000020002030+P_000422000*QR_000020002040); ans_temp[ans_id*36+15]+=Pmtrx[12]*(P_000022000*QR_012000010000+P_000122000*QR_012000010010+P_000222000*QR_012000010020+P_000322000*QR_012000010030+P_000422000*QR_012000010040); ans_temp[ans_id*36+15]+=Pmtrx[13]*(P_000022000*QR_011001010000+P_000122000*QR_011001010010+P_000222000*QR_011001010020+P_000322000*QR_011001010030+P_000422000*QR_011001010040); ans_temp[ans_id*36+15]+=Pmtrx[14]*(P_000022000*QR_010002010000+P_000122000*QR_010002010010+P_000222000*QR_010002010020+P_000322000*QR_010002010030+P_000422000*QR_010002010040); ans_temp[ans_id*36+15]+=Pmtrx[15]*(P_000022000*QR_011000011000+P_000122000*QR_011000011010+P_000222000*QR_011000011020+P_000322000*QR_011000011030+P_000422000*QR_011000011040); ans_temp[ans_id*36+15]+=Pmtrx[16]*(P_000022000*QR_010001011000+P_000122000*QR_010001011010+P_000222000*QR_010001011020+P_000322000*QR_010001011030+P_000422000*QR_010001011040); ans_temp[ans_id*36+15]+=Pmtrx[17]*(P_000022000*QR_010000012000+P_000122000*QR_010000012010+P_000222000*QR_010000012020+P_000322000*QR_010000012030+P_000422000*QR_010000012040); ans_temp[ans_id*36+16]+=Pmtrx[12]*(P_000022000*QR_002010010000+P_000122000*QR_002010010010+P_000222000*QR_002010010020+P_000322000*QR_002010010030+P_000422000*QR_002010010040); ans_temp[ans_id*36+16]+=Pmtrx[13]*(P_000022000*QR_001011010000+P_000122000*QR_001011010010+P_000222000*QR_001011010020+P_000322000*QR_001011010030+P_000422000*QR_001011010040); ans_temp[ans_id*36+16]+=Pmtrx[14]*(P_000022000*QR_000012010000+P_000122000*QR_000012010010+P_000222000*QR_000012010020+P_000322000*QR_000012010030+P_000422000*QR_000012010040); ans_temp[ans_id*36+16]+=Pmtrx[15]*(P_000022000*QR_001010011000+P_000122000*QR_001010011010+P_000222000*QR_001010011020+P_000322000*QR_001010011030+P_000422000*QR_001010011040); ans_temp[ans_id*36+16]+=Pmtrx[16]*(P_000022000*QR_000011011000+P_000122000*QR_000011011010+P_000222000*QR_000011011020+P_000322000*QR_000011011030+P_000422000*QR_000011011040); ans_temp[ans_id*36+16]+=Pmtrx[17]*(P_000022000*QR_000010012000+P_000122000*QR_000010012010+P_000222000*QR_000010012020+P_000322000*QR_000010012030+P_000422000*QR_000010012040); ans_temp[ans_id*36+17]+=Pmtrx[12]*(P_000022000*QR_002000020000+P_000122000*QR_002000020010+P_000222000*QR_002000020020+P_000322000*QR_002000020030+P_000422000*QR_002000020040); ans_temp[ans_id*36+17]+=Pmtrx[13]*(P_000022000*QR_001001020000+P_000122000*QR_001001020010+P_000222000*QR_001001020020+P_000322000*QR_001001020030+P_000422000*QR_001001020040); ans_temp[ans_id*36+17]+=Pmtrx[14]*(P_000022000*QR_000002020000+P_000122000*QR_000002020010+P_000222000*QR_000002020020+P_000322000*QR_000002020030+P_000422000*QR_000002020040); ans_temp[ans_id*36+17]+=Pmtrx[15]*(P_000022000*QR_001000021000+P_000122000*QR_001000021010+P_000222000*QR_001000021020+P_000322000*QR_001000021030+P_000422000*QR_001000021040); ans_temp[ans_id*36+17]+=Pmtrx[16]*(P_000022000*QR_000001021000+P_000122000*QR_000001021010+P_000222000*QR_000001021020+P_000322000*QR_000001021030+P_000422000*QR_000001021040); ans_temp[ans_id*36+17]+=Pmtrx[17]*(P_000022000*QR_000000022000+P_000122000*QR_000000022010+P_000222000*QR_000000022020+P_000322000*QR_000000022030+P_000422000*QR_000000022040); ans_temp[ans_id*36+12]+=Pmtrx[18]*(P_001020001*QR_022000000000+P_001020101*QR_022000000001+P_001120001*QR_022000000010+P_001120101*QR_022000000011+P_001220001*QR_022000000020+P_001220101*QR_022000000021+P_101020001*QR_022000000100+P_101020101*QR_022000000101+P_101120001*QR_022000000110+P_101120101*QR_022000000111+P_101220001*QR_022000000120+P_101220101*QR_022000000121); ans_temp[ans_id*36+12]+=Pmtrx[19]*(P_001020001*QR_021001000000+P_001020101*QR_021001000001+P_001120001*QR_021001000010+P_001120101*QR_021001000011+P_001220001*QR_021001000020+P_001220101*QR_021001000021+P_101020001*QR_021001000100+P_101020101*QR_021001000101+P_101120001*QR_021001000110+P_101120101*QR_021001000111+P_101220001*QR_021001000120+P_101220101*QR_021001000121); ans_temp[ans_id*36+12]+=Pmtrx[20]*(P_001020001*QR_020002000000+P_001020101*QR_020002000001+P_001120001*QR_020002000010+P_001120101*QR_020002000011+P_001220001*QR_020002000020+P_001220101*QR_020002000021+P_101020001*QR_020002000100+P_101020101*QR_020002000101+P_101120001*QR_020002000110+P_101120101*QR_020002000111+P_101220001*QR_020002000120+P_101220101*QR_020002000121); ans_temp[ans_id*36+12]+=Pmtrx[21]*(P_001020001*QR_021000001000+P_001020101*QR_021000001001+P_001120001*QR_021000001010+P_001120101*QR_021000001011+P_001220001*QR_021000001020+P_001220101*QR_021000001021+P_101020001*QR_021000001100+P_101020101*QR_021000001101+P_101120001*QR_021000001110+P_101120101*QR_021000001111+P_101220001*QR_021000001120+P_101220101*QR_021000001121); ans_temp[ans_id*36+12]+=Pmtrx[22]*(P_001020001*QR_020001001000+P_001020101*QR_020001001001+P_001120001*QR_020001001010+P_001120101*QR_020001001011+P_001220001*QR_020001001020+P_001220101*QR_020001001021+P_101020001*QR_020001001100+P_101020101*QR_020001001101+P_101120001*QR_020001001110+P_101120101*QR_020001001111+P_101220001*QR_020001001120+P_101220101*QR_020001001121); ans_temp[ans_id*36+12]+=Pmtrx[23]*(P_001020001*QR_020000002000+P_001020101*QR_020000002001+P_001120001*QR_020000002010+P_001120101*QR_020000002011+P_001220001*QR_020000002020+P_001220101*QR_020000002021+P_101020001*QR_020000002100+P_101020101*QR_020000002101+P_101120001*QR_020000002110+P_101120101*QR_020000002111+P_101220001*QR_020000002120+P_101220101*QR_020000002121); ans_temp[ans_id*36+13]+=Pmtrx[18]*(P_001020001*QR_012010000000+P_001020101*QR_012010000001+P_001120001*QR_012010000010+P_001120101*QR_012010000011+P_001220001*QR_012010000020+P_001220101*QR_012010000021+P_101020001*QR_012010000100+P_101020101*QR_012010000101+P_101120001*QR_012010000110+P_101120101*QR_012010000111+P_101220001*QR_012010000120+P_101220101*QR_012010000121); ans_temp[ans_id*36+13]+=Pmtrx[19]*(P_001020001*QR_011011000000+P_001020101*QR_011011000001+P_001120001*QR_011011000010+P_001120101*QR_011011000011+P_001220001*QR_011011000020+P_001220101*QR_011011000021+P_101020001*QR_011011000100+P_101020101*QR_011011000101+P_101120001*QR_011011000110+P_101120101*QR_011011000111+P_101220001*QR_011011000120+P_101220101*QR_011011000121); ans_temp[ans_id*36+13]+=Pmtrx[20]*(P_001020001*QR_010012000000+P_001020101*QR_010012000001+P_001120001*QR_010012000010+P_001120101*QR_010012000011+P_001220001*QR_010012000020+P_001220101*QR_010012000021+P_101020001*QR_010012000100+P_101020101*QR_010012000101+P_101120001*QR_010012000110+P_101120101*QR_010012000111+P_101220001*QR_010012000120+P_101220101*QR_010012000121); ans_temp[ans_id*36+13]+=Pmtrx[21]*(P_001020001*QR_011010001000+P_001020101*QR_011010001001+P_001120001*QR_011010001010+P_001120101*QR_011010001011+P_001220001*QR_011010001020+P_001220101*QR_011010001021+P_101020001*QR_011010001100+P_101020101*QR_011010001101+P_101120001*QR_011010001110+P_101120101*QR_011010001111+P_101220001*QR_011010001120+P_101220101*QR_011010001121); ans_temp[ans_id*36+13]+=Pmtrx[22]*(P_001020001*QR_010011001000+P_001020101*QR_010011001001+P_001120001*QR_010011001010+P_001120101*QR_010011001011+P_001220001*QR_010011001020+P_001220101*QR_010011001021+P_101020001*QR_010011001100+P_101020101*QR_010011001101+P_101120001*QR_010011001110+P_101120101*QR_010011001111+P_101220001*QR_010011001120+P_101220101*QR_010011001121); ans_temp[ans_id*36+13]+=Pmtrx[23]*(P_001020001*QR_010010002000+P_001020101*QR_010010002001+P_001120001*QR_010010002010+P_001120101*QR_010010002011+P_001220001*QR_010010002020+P_001220101*QR_010010002021+P_101020001*QR_010010002100+P_101020101*QR_010010002101+P_101120001*QR_010010002110+P_101120101*QR_010010002111+P_101220001*QR_010010002120+P_101220101*QR_010010002121); ans_temp[ans_id*36+14]+=Pmtrx[18]*(P_001020001*QR_002020000000+P_001020101*QR_002020000001+P_001120001*QR_002020000010+P_001120101*QR_002020000011+P_001220001*QR_002020000020+P_001220101*QR_002020000021+P_101020001*QR_002020000100+P_101020101*QR_002020000101+P_101120001*QR_002020000110+P_101120101*QR_002020000111+P_101220001*QR_002020000120+P_101220101*QR_002020000121); ans_temp[ans_id*36+14]+=Pmtrx[19]*(P_001020001*QR_001021000000+P_001020101*QR_001021000001+P_001120001*QR_001021000010+P_001120101*QR_001021000011+P_001220001*QR_001021000020+P_001220101*QR_001021000021+P_101020001*QR_001021000100+P_101020101*QR_001021000101+P_101120001*QR_001021000110+P_101120101*QR_001021000111+P_101220001*QR_001021000120+P_101220101*QR_001021000121); ans_temp[ans_id*36+14]+=Pmtrx[20]*(P_001020001*QR_000022000000+P_001020101*QR_000022000001+P_001120001*QR_000022000010+P_001120101*QR_000022000011+P_001220001*QR_000022000020+P_001220101*QR_000022000021+P_101020001*QR_000022000100+P_101020101*QR_000022000101+P_101120001*QR_000022000110+P_101120101*QR_000022000111+P_101220001*QR_000022000120+P_101220101*QR_000022000121); ans_temp[ans_id*36+14]+=Pmtrx[21]*(P_001020001*QR_001020001000+P_001020101*QR_001020001001+P_001120001*QR_001020001010+P_001120101*QR_001020001011+P_001220001*QR_001020001020+P_001220101*QR_001020001021+P_101020001*QR_001020001100+P_101020101*QR_001020001101+P_101120001*QR_001020001110+P_101120101*QR_001020001111+P_101220001*QR_001020001120+P_101220101*QR_001020001121); ans_temp[ans_id*36+14]+=Pmtrx[22]*(P_001020001*QR_000021001000+P_001020101*QR_000021001001+P_001120001*QR_000021001010+P_001120101*QR_000021001011+P_001220001*QR_000021001020+P_001220101*QR_000021001021+P_101020001*QR_000021001100+P_101020101*QR_000021001101+P_101120001*QR_000021001110+P_101120101*QR_000021001111+P_101220001*QR_000021001120+P_101220101*QR_000021001121); ans_temp[ans_id*36+14]+=Pmtrx[23]*(P_001020001*QR_000020002000+P_001020101*QR_000020002001+P_001120001*QR_000020002010+P_001120101*QR_000020002011+P_001220001*QR_000020002020+P_001220101*QR_000020002021+P_101020001*QR_000020002100+P_101020101*QR_000020002101+P_101120001*QR_000020002110+P_101120101*QR_000020002111+P_101220001*QR_000020002120+P_101220101*QR_000020002121); ans_temp[ans_id*36+15]+=Pmtrx[18]*(P_001020001*QR_012000010000+P_001020101*QR_012000010001+P_001120001*QR_012000010010+P_001120101*QR_012000010011+P_001220001*QR_012000010020+P_001220101*QR_012000010021+P_101020001*QR_012000010100+P_101020101*QR_012000010101+P_101120001*QR_012000010110+P_101120101*QR_012000010111+P_101220001*QR_012000010120+P_101220101*QR_012000010121); ans_temp[ans_id*36+15]+=Pmtrx[19]*(P_001020001*QR_011001010000+P_001020101*QR_011001010001+P_001120001*QR_011001010010+P_001120101*QR_011001010011+P_001220001*QR_011001010020+P_001220101*QR_011001010021+P_101020001*QR_011001010100+P_101020101*QR_011001010101+P_101120001*QR_011001010110+P_101120101*QR_011001010111+P_101220001*QR_011001010120+P_101220101*QR_011001010121); ans_temp[ans_id*36+15]+=Pmtrx[20]*(P_001020001*QR_010002010000+P_001020101*QR_010002010001+P_001120001*QR_010002010010+P_001120101*QR_010002010011+P_001220001*QR_010002010020+P_001220101*QR_010002010021+P_101020001*QR_010002010100+P_101020101*QR_010002010101+P_101120001*QR_010002010110+P_101120101*QR_010002010111+P_101220001*QR_010002010120+P_101220101*QR_010002010121); ans_temp[ans_id*36+15]+=Pmtrx[21]*(P_001020001*QR_011000011000+P_001020101*QR_011000011001+P_001120001*QR_011000011010+P_001120101*QR_011000011011+P_001220001*QR_011000011020+P_001220101*QR_011000011021+P_101020001*QR_011000011100+P_101020101*QR_011000011101+P_101120001*QR_011000011110+P_101120101*QR_011000011111+P_101220001*QR_011000011120+P_101220101*QR_011000011121); ans_temp[ans_id*36+15]+=Pmtrx[22]*(P_001020001*QR_010001011000+P_001020101*QR_010001011001+P_001120001*QR_010001011010+P_001120101*QR_010001011011+P_001220001*QR_010001011020+P_001220101*QR_010001011021+P_101020001*QR_010001011100+P_101020101*QR_010001011101+P_101120001*QR_010001011110+P_101120101*QR_010001011111+P_101220001*QR_010001011120+P_101220101*QR_010001011121); ans_temp[ans_id*36+15]+=Pmtrx[23]*(P_001020001*QR_010000012000+P_001020101*QR_010000012001+P_001120001*QR_010000012010+P_001120101*QR_010000012011+P_001220001*QR_010000012020+P_001220101*QR_010000012021+P_101020001*QR_010000012100+P_101020101*QR_010000012101+P_101120001*QR_010000012110+P_101120101*QR_010000012111+P_101220001*QR_010000012120+P_101220101*QR_010000012121); ans_temp[ans_id*36+16]+=Pmtrx[18]*(P_001020001*QR_002010010000+P_001020101*QR_002010010001+P_001120001*QR_002010010010+P_001120101*QR_002010010011+P_001220001*QR_002010010020+P_001220101*QR_002010010021+P_101020001*QR_002010010100+P_101020101*QR_002010010101+P_101120001*QR_002010010110+P_101120101*QR_002010010111+P_101220001*QR_002010010120+P_101220101*QR_002010010121); ans_temp[ans_id*36+16]+=Pmtrx[19]*(P_001020001*QR_001011010000+P_001020101*QR_001011010001+P_001120001*QR_001011010010+P_001120101*QR_001011010011+P_001220001*QR_001011010020+P_001220101*QR_001011010021+P_101020001*QR_001011010100+P_101020101*QR_001011010101+P_101120001*QR_001011010110+P_101120101*QR_001011010111+P_101220001*QR_001011010120+P_101220101*QR_001011010121); ans_temp[ans_id*36+16]+=Pmtrx[20]*(P_001020001*QR_000012010000+P_001020101*QR_000012010001+P_001120001*QR_000012010010+P_001120101*QR_000012010011+P_001220001*QR_000012010020+P_001220101*QR_000012010021+P_101020001*QR_000012010100+P_101020101*QR_000012010101+P_101120001*QR_000012010110+P_101120101*QR_000012010111+P_101220001*QR_000012010120+P_101220101*QR_000012010121); ans_temp[ans_id*36+16]+=Pmtrx[21]*(P_001020001*QR_001010011000+P_001020101*QR_001010011001+P_001120001*QR_001010011010+P_001120101*QR_001010011011+P_001220001*QR_001010011020+P_001220101*QR_001010011021+P_101020001*QR_001010011100+P_101020101*QR_001010011101+P_101120001*QR_001010011110+P_101120101*QR_001010011111+P_101220001*QR_001010011120+P_101220101*QR_001010011121); ans_temp[ans_id*36+16]+=Pmtrx[22]*(P_001020001*QR_000011011000+P_001020101*QR_000011011001+P_001120001*QR_000011011010+P_001120101*QR_000011011011+P_001220001*QR_000011011020+P_001220101*QR_000011011021+P_101020001*QR_000011011100+P_101020101*QR_000011011101+P_101120001*QR_000011011110+P_101120101*QR_000011011111+P_101220001*QR_000011011120+P_101220101*QR_000011011121); ans_temp[ans_id*36+16]+=Pmtrx[23]*(P_001020001*QR_000010012000+P_001020101*QR_000010012001+P_001120001*QR_000010012010+P_001120101*QR_000010012011+P_001220001*QR_000010012020+P_001220101*QR_000010012021+P_101020001*QR_000010012100+P_101020101*QR_000010012101+P_101120001*QR_000010012110+P_101120101*QR_000010012111+P_101220001*QR_000010012120+P_101220101*QR_000010012121); ans_temp[ans_id*36+17]+=Pmtrx[18]*(P_001020001*QR_002000020000+P_001020101*QR_002000020001+P_001120001*QR_002000020010+P_001120101*QR_002000020011+P_001220001*QR_002000020020+P_001220101*QR_002000020021+P_101020001*QR_002000020100+P_101020101*QR_002000020101+P_101120001*QR_002000020110+P_101120101*QR_002000020111+P_101220001*QR_002000020120+P_101220101*QR_002000020121); ans_temp[ans_id*36+17]+=Pmtrx[19]*(P_001020001*QR_001001020000+P_001020101*QR_001001020001+P_001120001*QR_001001020010+P_001120101*QR_001001020011+P_001220001*QR_001001020020+P_001220101*QR_001001020021+P_101020001*QR_001001020100+P_101020101*QR_001001020101+P_101120001*QR_001001020110+P_101120101*QR_001001020111+P_101220001*QR_001001020120+P_101220101*QR_001001020121); ans_temp[ans_id*36+17]+=Pmtrx[20]*(P_001020001*QR_000002020000+P_001020101*QR_000002020001+P_001120001*QR_000002020010+P_001120101*QR_000002020011+P_001220001*QR_000002020020+P_001220101*QR_000002020021+P_101020001*QR_000002020100+P_101020101*QR_000002020101+P_101120001*QR_000002020110+P_101120101*QR_000002020111+P_101220001*QR_000002020120+P_101220101*QR_000002020121); ans_temp[ans_id*36+17]+=Pmtrx[21]*(P_001020001*QR_001000021000+P_001020101*QR_001000021001+P_001120001*QR_001000021010+P_001120101*QR_001000021011+P_001220001*QR_001000021020+P_001220101*QR_001000021021+P_101020001*QR_001000021100+P_101020101*QR_001000021101+P_101120001*QR_001000021110+P_101120101*QR_001000021111+P_101220001*QR_001000021120+P_101220101*QR_001000021121); ans_temp[ans_id*36+17]+=Pmtrx[22]*(P_001020001*QR_000001021000+P_001020101*QR_000001021001+P_001120001*QR_000001021010+P_001120101*QR_000001021011+P_001220001*QR_000001021020+P_001220101*QR_000001021021+P_101020001*QR_000001021100+P_101020101*QR_000001021101+P_101120001*QR_000001021110+P_101120101*QR_000001021111+P_101220001*QR_000001021120+P_101220101*QR_000001021121); ans_temp[ans_id*36+17]+=Pmtrx[23]*(P_001020001*QR_000000022000+P_001020101*QR_000000022001+P_001120001*QR_000000022010+P_001120101*QR_000000022011+P_001220001*QR_000000022020+P_001220101*QR_000000022021+P_101020001*QR_000000022100+P_101020101*QR_000000022101+P_101120001*QR_000000022110+P_101120101*QR_000000022111+P_101220001*QR_000000022120+P_101220101*QR_000000022121); ans_temp[ans_id*36+12]+=Pmtrx[24]*(P_000021001*QR_022000000000+P_000021101*QR_022000000001+P_000121001*QR_022000000010+P_000121101*QR_022000000011+P_000221001*QR_022000000020+P_000221101*QR_022000000021+P_000321001*QR_022000000030+P_000321101*QR_022000000031); ans_temp[ans_id*36+12]+=Pmtrx[25]*(P_000021001*QR_021001000000+P_000021101*QR_021001000001+P_000121001*QR_021001000010+P_000121101*QR_021001000011+P_000221001*QR_021001000020+P_000221101*QR_021001000021+P_000321001*QR_021001000030+P_000321101*QR_021001000031); ans_temp[ans_id*36+12]+=Pmtrx[26]*(P_000021001*QR_020002000000+P_000021101*QR_020002000001+P_000121001*QR_020002000010+P_000121101*QR_020002000011+P_000221001*QR_020002000020+P_000221101*QR_020002000021+P_000321001*QR_020002000030+P_000321101*QR_020002000031); ans_temp[ans_id*36+12]+=Pmtrx[27]*(P_000021001*QR_021000001000+P_000021101*QR_021000001001+P_000121001*QR_021000001010+P_000121101*QR_021000001011+P_000221001*QR_021000001020+P_000221101*QR_021000001021+P_000321001*QR_021000001030+P_000321101*QR_021000001031); ans_temp[ans_id*36+12]+=Pmtrx[28]*(P_000021001*QR_020001001000+P_000021101*QR_020001001001+P_000121001*QR_020001001010+P_000121101*QR_020001001011+P_000221001*QR_020001001020+P_000221101*QR_020001001021+P_000321001*QR_020001001030+P_000321101*QR_020001001031); ans_temp[ans_id*36+12]+=Pmtrx[29]*(P_000021001*QR_020000002000+P_000021101*QR_020000002001+P_000121001*QR_020000002010+P_000121101*QR_020000002011+P_000221001*QR_020000002020+P_000221101*QR_020000002021+P_000321001*QR_020000002030+P_000321101*QR_020000002031); ans_temp[ans_id*36+13]+=Pmtrx[24]*(P_000021001*QR_012010000000+P_000021101*QR_012010000001+P_000121001*QR_012010000010+P_000121101*QR_012010000011+P_000221001*QR_012010000020+P_000221101*QR_012010000021+P_000321001*QR_012010000030+P_000321101*QR_012010000031); ans_temp[ans_id*36+13]+=Pmtrx[25]*(P_000021001*QR_011011000000+P_000021101*QR_011011000001+P_000121001*QR_011011000010+P_000121101*QR_011011000011+P_000221001*QR_011011000020+P_000221101*QR_011011000021+P_000321001*QR_011011000030+P_000321101*QR_011011000031); ans_temp[ans_id*36+13]+=Pmtrx[26]*(P_000021001*QR_010012000000+P_000021101*QR_010012000001+P_000121001*QR_010012000010+P_000121101*QR_010012000011+P_000221001*QR_010012000020+P_000221101*QR_010012000021+P_000321001*QR_010012000030+P_000321101*QR_010012000031); ans_temp[ans_id*36+13]+=Pmtrx[27]*(P_000021001*QR_011010001000+P_000021101*QR_011010001001+P_000121001*QR_011010001010+P_000121101*QR_011010001011+P_000221001*QR_011010001020+P_000221101*QR_011010001021+P_000321001*QR_011010001030+P_000321101*QR_011010001031); ans_temp[ans_id*36+13]+=Pmtrx[28]*(P_000021001*QR_010011001000+P_000021101*QR_010011001001+P_000121001*QR_010011001010+P_000121101*QR_010011001011+P_000221001*QR_010011001020+P_000221101*QR_010011001021+P_000321001*QR_010011001030+P_000321101*QR_010011001031); ans_temp[ans_id*36+13]+=Pmtrx[29]*(P_000021001*QR_010010002000+P_000021101*QR_010010002001+P_000121001*QR_010010002010+P_000121101*QR_010010002011+P_000221001*QR_010010002020+P_000221101*QR_010010002021+P_000321001*QR_010010002030+P_000321101*QR_010010002031); ans_temp[ans_id*36+14]+=Pmtrx[24]*(P_000021001*QR_002020000000+P_000021101*QR_002020000001+P_000121001*QR_002020000010+P_000121101*QR_002020000011+P_000221001*QR_002020000020+P_000221101*QR_002020000021+P_000321001*QR_002020000030+P_000321101*QR_002020000031); ans_temp[ans_id*36+14]+=Pmtrx[25]*(P_000021001*QR_001021000000+P_000021101*QR_001021000001+P_000121001*QR_001021000010+P_000121101*QR_001021000011+P_000221001*QR_001021000020+P_000221101*QR_001021000021+P_000321001*QR_001021000030+P_000321101*QR_001021000031); ans_temp[ans_id*36+14]+=Pmtrx[26]*(P_000021001*QR_000022000000+P_000021101*QR_000022000001+P_000121001*QR_000022000010+P_000121101*QR_000022000011+P_000221001*QR_000022000020+P_000221101*QR_000022000021+P_000321001*QR_000022000030+P_000321101*QR_000022000031); ans_temp[ans_id*36+14]+=Pmtrx[27]*(P_000021001*QR_001020001000+P_000021101*QR_001020001001+P_000121001*QR_001020001010+P_000121101*QR_001020001011+P_000221001*QR_001020001020+P_000221101*QR_001020001021+P_000321001*QR_001020001030+P_000321101*QR_001020001031); ans_temp[ans_id*36+14]+=Pmtrx[28]*(P_000021001*QR_000021001000+P_000021101*QR_000021001001+P_000121001*QR_000021001010+P_000121101*QR_000021001011+P_000221001*QR_000021001020+P_000221101*QR_000021001021+P_000321001*QR_000021001030+P_000321101*QR_000021001031); ans_temp[ans_id*36+14]+=Pmtrx[29]*(P_000021001*QR_000020002000+P_000021101*QR_000020002001+P_000121001*QR_000020002010+P_000121101*QR_000020002011+P_000221001*QR_000020002020+P_000221101*QR_000020002021+P_000321001*QR_000020002030+P_000321101*QR_000020002031); ans_temp[ans_id*36+15]+=Pmtrx[24]*(P_000021001*QR_012000010000+P_000021101*QR_012000010001+P_000121001*QR_012000010010+P_000121101*QR_012000010011+P_000221001*QR_012000010020+P_000221101*QR_012000010021+P_000321001*QR_012000010030+P_000321101*QR_012000010031); ans_temp[ans_id*36+15]+=Pmtrx[25]*(P_000021001*QR_011001010000+P_000021101*QR_011001010001+P_000121001*QR_011001010010+P_000121101*QR_011001010011+P_000221001*QR_011001010020+P_000221101*QR_011001010021+P_000321001*QR_011001010030+P_000321101*QR_011001010031); ans_temp[ans_id*36+15]+=Pmtrx[26]*(P_000021001*QR_010002010000+P_000021101*QR_010002010001+P_000121001*QR_010002010010+P_000121101*QR_010002010011+P_000221001*QR_010002010020+P_000221101*QR_010002010021+P_000321001*QR_010002010030+P_000321101*QR_010002010031); ans_temp[ans_id*36+15]+=Pmtrx[27]*(P_000021001*QR_011000011000+P_000021101*QR_011000011001+P_000121001*QR_011000011010+P_000121101*QR_011000011011+P_000221001*QR_011000011020+P_000221101*QR_011000011021+P_000321001*QR_011000011030+P_000321101*QR_011000011031); ans_temp[ans_id*36+15]+=Pmtrx[28]*(P_000021001*QR_010001011000+P_000021101*QR_010001011001+P_000121001*QR_010001011010+P_000121101*QR_010001011011+P_000221001*QR_010001011020+P_000221101*QR_010001011021+P_000321001*QR_010001011030+P_000321101*QR_010001011031); ans_temp[ans_id*36+15]+=Pmtrx[29]*(P_000021001*QR_010000012000+P_000021101*QR_010000012001+P_000121001*QR_010000012010+P_000121101*QR_010000012011+P_000221001*QR_010000012020+P_000221101*QR_010000012021+P_000321001*QR_010000012030+P_000321101*QR_010000012031); ans_temp[ans_id*36+16]+=Pmtrx[24]*(P_000021001*QR_002010010000+P_000021101*QR_002010010001+P_000121001*QR_002010010010+P_000121101*QR_002010010011+P_000221001*QR_002010010020+P_000221101*QR_002010010021+P_000321001*QR_002010010030+P_000321101*QR_002010010031); ans_temp[ans_id*36+16]+=Pmtrx[25]*(P_000021001*QR_001011010000+P_000021101*QR_001011010001+P_000121001*QR_001011010010+P_000121101*QR_001011010011+P_000221001*QR_001011010020+P_000221101*QR_001011010021+P_000321001*QR_001011010030+P_000321101*QR_001011010031); ans_temp[ans_id*36+16]+=Pmtrx[26]*(P_000021001*QR_000012010000+P_000021101*QR_000012010001+P_000121001*QR_000012010010+P_000121101*QR_000012010011+P_000221001*QR_000012010020+P_000221101*QR_000012010021+P_000321001*QR_000012010030+P_000321101*QR_000012010031); ans_temp[ans_id*36+16]+=Pmtrx[27]*(P_000021001*QR_001010011000+P_000021101*QR_001010011001+P_000121001*QR_001010011010+P_000121101*QR_001010011011+P_000221001*QR_001010011020+P_000221101*QR_001010011021+P_000321001*QR_001010011030+P_000321101*QR_001010011031); ans_temp[ans_id*36+16]+=Pmtrx[28]*(P_000021001*QR_000011011000+P_000021101*QR_000011011001+P_000121001*QR_000011011010+P_000121101*QR_000011011011+P_000221001*QR_000011011020+P_000221101*QR_000011011021+P_000321001*QR_000011011030+P_000321101*QR_000011011031); ans_temp[ans_id*36+16]+=Pmtrx[29]*(P_000021001*QR_000010012000+P_000021101*QR_000010012001+P_000121001*QR_000010012010+P_000121101*QR_000010012011+P_000221001*QR_000010012020+P_000221101*QR_000010012021+P_000321001*QR_000010012030+P_000321101*QR_000010012031); ans_temp[ans_id*36+17]+=Pmtrx[24]*(P_000021001*QR_002000020000+P_000021101*QR_002000020001+P_000121001*QR_002000020010+P_000121101*QR_002000020011+P_000221001*QR_002000020020+P_000221101*QR_002000020021+P_000321001*QR_002000020030+P_000321101*QR_002000020031); ans_temp[ans_id*36+17]+=Pmtrx[25]*(P_000021001*QR_001001020000+P_000021101*QR_001001020001+P_000121001*QR_001001020010+P_000121101*QR_001001020011+P_000221001*QR_001001020020+P_000221101*QR_001001020021+P_000321001*QR_001001020030+P_000321101*QR_001001020031); ans_temp[ans_id*36+17]+=Pmtrx[26]*(P_000021001*QR_000002020000+P_000021101*QR_000002020001+P_000121001*QR_000002020010+P_000121101*QR_000002020011+P_000221001*QR_000002020020+P_000221101*QR_000002020021+P_000321001*QR_000002020030+P_000321101*QR_000002020031); ans_temp[ans_id*36+17]+=Pmtrx[27]*(P_000021001*QR_001000021000+P_000021101*QR_001000021001+P_000121001*QR_001000021010+P_000121101*QR_001000021011+P_000221001*QR_001000021020+P_000221101*QR_001000021021+P_000321001*QR_001000021030+P_000321101*QR_001000021031); ans_temp[ans_id*36+17]+=Pmtrx[28]*(P_000021001*QR_000001021000+P_000021101*QR_000001021001+P_000121001*QR_000001021010+P_000121101*QR_000001021011+P_000221001*QR_000001021020+P_000221101*QR_000001021021+P_000321001*QR_000001021030+P_000321101*QR_000001021031); ans_temp[ans_id*36+17]+=Pmtrx[29]*(P_000021001*QR_000000022000+P_000021101*QR_000000022001+P_000121001*QR_000000022010+P_000121101*QR_000000022011+P_000221001*QR_000000022020+P_000221101*QR_000000022021+P_000321001*QR_000000022030+P_000321101*QR_000000022031); ans_temp[ans_id*36+12]+=Pmtrx[30]*(P_000020002*QR_022000000000+P_000020102*QR_022000000001+P_000020202*QR_022000000002+P_000120002*QR_022000000010+P_000120102*QR_022000000011+P_000120202*QR_022000000012+P_000220002*QR_022000000020+P_000220102*QR_022000000021+P_000220202*QR_022000000022); ans_temp[ans_id*36+12]+=Pmtrx[31]*(P_000020002*QR_021001000000+P_000020102*QR_021001000001+P_000020202*QR_021001000002+P_000120002*QR_021001000010+P_000120102*QR_021001000011+P_000120202*QR_021001000012+P_000220002*QR_021001000020+P_000220102*QR_021001000021+P_000220202*QR_021001000022); ans_temp[ans_id*36+12]+=Pmtrx[32]*(P_000020002*QR_020002000000+P_000020102*QR_020002000001+P_000020202*QR_020002000002+P_000120002*QR_020002000010+P_000120102*QR_020002000011+P_000120202*QR_020002000012+P_000220002*QR_020002000020+P_000220102*QR_020002000021+P_000220202*QR_020002000022); ans_temp[ans_id*36+12]+=Pmtrx[33]*(P_000020002*QR_021000001000+P_000020102*QR_021000001001+P_000020202*QR_021000001002+P_000120002*QR_021000001010+P_000120102*QR_021000001011+P_000120202*QR_021000001012+P_000220002*QR_021000001020+P_000220102*QR_021000001021+P_000220202*QR_021000001022); ans_temp[ans_id*36+12]+=Pmtrx[34]*(P_000020002*QR_020001001000+P_000020102*QR_020001001001+P_000020202*QR_020001001002+P_000120002*QR_020001001010+P_000120102*QR_020001001011+P_000120202*QR_020001001012+P_000220002*QR_020001001020+P_000220102*QR_020001001021+P_000220202*QR_020001001022); ans_temp[ans_id*36+12]+=Pmtrx[35]*(P_000020002*QR_020000002000+P_000020102*QR_020000002001+P_000020202*QR_020000002002+P_000120002*QR_020000002010+P_000120102*QR_020000002011+P_000120202*QR_020000002012+P_000220002*QR_020000002020+P_000220102*QR_020000002021+P_000220202*QR_020000002022); ans_temp[ans_id*36+13]+=Pmtrx[30]*(P_000020002*QR_012010000000+P_000020102*QR_012010000001+P_000020202*QR_012010000002+P_000120002*QR_012010000010+P_000120102*QR_012010000011+P_000120202*QR_012010000012+P_000220002*QR_012010000020+P_000220102*QR_012010000021+P_000220202*QR_012010000022); ans_temp[ans_id*36+13]+=Pmtrx[31]*(P_000020002*QR_011011000000+P_000020102*QR_011011000001+P_000020202*QR_011011000002+P_000120002*QR_011011000010+P_000120102*QR_011011000011+P_000120202*QR_011011000012+P_000220002*QR_011011000020+P_000220102*QR_011011000021+P_000220202*QR_011011000022); ans_temp[ans_id*36+13]+=Pmtrx[32]*(P_000020002*QR_010012000000+P_000020102*QR_010012000001+P_000020202*QR_010012000002+P_000120002*QR_010012000010+P_000120102*QR_010012000011+P_000120202*QR_010012000012+P_000220002*QR_010012000020+P_000220102*QR_010012000021+P_000220202*QR_010012000022); ans_temp[ans_id*36+13]+=Pmtrx[33]*(P_000020002*QR_011010001000+P_000020102*QR_011010001001+P_000020202*QR_011010001002+P_000120002*QR_011010001010+P_000120102*QR_011010001011+P_000120202*QR_011010001012+P_000220002*QR_011010001020+P_000220102*QR_011010001021+P_000220202*QR_011010001022); ans_temp[ans_id*36+13]+=Pmtrx[34]*(P_000020002*QR_010011001000+P_000020102*QR_010011001001+P_000020202*QR_010011001002+P_000120002*QR_010011001010+P_000120102*QR_010011001011+P_000120202*QR_010011001012+P_000220002*QR_010011001020+P_000220102*QR_010011001021+P_000220202*QR_010011001022); ans_temp[ans_id*36+13]+=Pmtrx[35]*(P_000020002*QR_010010002000+P_000020102*QR_010010002001+P_000020202*QR_010010002002+P_000120002*QR_010010002010+P_000120102*QR_010010002011+P_000120202*QR_010010002012+P_000220002*QR_010010002020+P_000220102*QR_010010002021+P_000220202*QR_010010002022); ans_temp[ans_id*36+14]+=Pmtrx[30]*(P_000020002*QR_002020000000+P_000020102*QR_002020000001+P_000020202*QR_002020000002+P_000120002*QR_002020000010+P_000120102*QR_002020000011+P_000120202*QR_002020000012+P_000220002*QR_002020000020+P_000220102*QR_002020000021+P_000220202*QR_002020000022); ans_temp[ans_id*36+14]+=Pmtrx[31]*(P_000020002*QR_001021000000+P_000020102*QR_001021000001+P_000020202*QR_001021000002+P_000120002*QR_001021000010+P_000120102*QR_001021000011+P_000120202*QR_001021000012+P_000220002*QR_001021000020+P_000220102*QR_001021000021+P_000220202*QR_001021000022); ans_temp[ans_id*36+14]+=Pmtrx[32]*(P_000020002*QR_000022000000+P_000020102*QR_000022000001+P_000020202*QR_000022000002+P_000120002*QR_000022000010+P_000120102*QR_000022000011+P_000120202*QR_000022000012+P_000220002*QR_000022000020+P_000220102*QR_000022000021+P_000220202*QR_000022000022); ans_temp[ans_id*36+14]+=Pmtrx[33]*(P_000020002*QR_001020001000+P_000020102*QR_001020001001+P_000020202*QR_001020001002+P_000120002*QR_001020001010+P_000120102*QR_001020001011+P_000120202*QR_001020001012+P_000220002*QR_001020001020+P_000220102*QR_001020001021+P_000220202*QR_001020001022); ans_temp[ans_id*36+14]+=Pmtrx[34]*(P_000020002*QR_000021001000+P_000020102*QR_000021001001+P_000020202*QR_000021001002+P_000120002*QR_000021001010+P_000120102*QR_000021001011+P_000120202*QR_000021001012+P_000220002*QR_000021001020+P_000220102*QR_000021001021+P_000220202*QR_000021001022); ans_temp[ans_id*36+14]+=Pmtrx[35]*(P_000020002*QR_000020002000+P_000020102*QR_000020002001+P_000020202*QR_000020002002+P_000120002*QR_000020002010+P_000120102*QR_000020002011+P_000120202*QR_000020002012+P_000220002*QR_000020002020+P_000220102*QR_000020002021+P_000220202*QR_000020002022); ans_temp[ans_id*36+15]+=Pmtrx[30]*(P_000020002*QR_012000010000+P_000020102*QR_012000010001+P_000020202*QR_012000010002+P_000120002*QR_012000010010+P_000120102*QR_012000010011+P_000120202*QR_012000010012+P_000220002*QR_012000010020+P_000220102*QR_012000010021+P_000220202*QR_012000010022); ans_temp[ans_id*36+15]+=Pmtrx[31]*(P_000020002*QR_011001010000+P_000020102*QR_011001010001+P_000020202*QR_011001010002+P_000120002*QR_011001010010+P_000120102*QR_011001010011+P_000120202*QR_011001010012+P_000220002*QR_011001010020+P_000220102*QR_011001010021+P_000220202*QR_011001010022); ans_temp[ans_id*36+15]+=Pmtrx[32]*(P_000020002*QR_010002010000+P_000020102*QR_010002010001+P_000020202*QR_010002010002+P_000120002*QR_010002010010+P_000120102*QR_010002010011+P_000120202*QR_010002010012+P_000220002*QR_010002010020+P_000220102*QR_010002010021+P_000220202*QR_010002010022); ans_temp[ans_id*36+15]+=Pmtrx[33]*(P_000020002*QR_011000011000+P_000020102*QR_011000011001+P_000020202*QR_011000011002+P_000120002*QR_011000011010+P_000120102*QR_011000011011+P_000120202*QR_011000011012+P_000220002*QR_011000011020+P_000220102*QR_011000011021+P_000220202*QR_011000011022); ans_temp[ans_id*36+15]+=Pmtrx[34]*(P_000020002*QR_010001011000+P_000020102*QR_010001011001+P_000020202*QR_010001011002+P_000120002*QR_010001011010+P_000120102*QR_010001011011+P_000120202*QR_010001011012+P_000220002*QR_010001011020+P_000220102*QR_010001011021+P_000220202*QR_010001011022); ans_temp[ans_id*36+15]+=Pmtrx[35]*(P_000020002*QR_010000012000+P_000020102*QR_010000012001+P_000020202*QR_010000012002+P_000120002*QR_010000012010+P_000120102*QR_010000012011+P_000120202*QR_010000012012+P_000220002*QR_010000012020+P_000220102*QR_010000012021+P_000220202*QR_010000012022); ans_temp[ans_id*36+16]+=Pmtrx[30]*(P_000020002*QR_002010010000+P_000020102*QR_002010010001+P_000020202*QR_002010010002+P_000120002*QR_002010010010+P_000120102*QR_002010010011+P_000120202*QR_002010010012+P_000220002*QR_002010010020+P_000220102*QR_002010010021+P_000220202*QR_002010010022); ans_temp[ans_id*36+16]+=Pmtrx[31]*(P_000020002*QR_001011010000+P_000020102*QR_001011010001+P_000020202*QR_001011010002+P_000120002*QR_001011010010+P_000120102*QR_001011010011+P_000120202*QR_001011010012+P_000220002*QR_001011010020+P_000220102*QR_001011010021+P_000220202*QR_001011010022); ans_temp[ans_id*36+16]+=Pmtrx[32]*(P_000020002*QR_000012010000+P_000020102*QR_000012010001+P_000020202*QR_000012010002+P_000120002*QR_000012010010+P_000120102*QR_000012010011+P_000120202*QR_000012010012+P_000220002*QR_000012010020+P_000220102*QR_000012010021+P_000220202*QR_000012010022); ans_temp[ans_id*36+16]+=Pmtrx[33]*(P_000020002*QR_001010011000+P_000020102*QR_001010011001+P_000020202*QR_001010011002+P_000120002*QR_001010011010+P_000120102*QR_001010011011+P_000120202*QR_001010011012+P_000220002*QR_001010011020+P_000220102*QR_001010011021+P_000220202*QR_001010011022); ans_temp[ans_id*36+16]+=Pmtrx[34]*(P_000020002*QR_000011011000+P_000020102*QR_000011011001+P_000020202*QR_000011011002+P_000120002*QR_000011011010+P_000120102*QR_000011011011+P_000120202*QR_000011011012+P_000220002*QR_000011011020+P_000220102*QR_000011011021+P_000220202*QR_000011011022); ans_temp[ans_id*36+16]+=Pmtrx[35]*(P_000020002*QR_000010012000+P_000020102*QR_000010012001+P_000020202*QR_000010012002+P_000120002*QR_000010012010+P_000120102*QR_000010012011+P_000120202*QR_000010012012+P_000220002*QR_000010012020+P_000220102*QR_000010012021+P_000220202*QR_000010012022); ans_temp[ans_id*36+17]+=Pmtrx[30]*(P_000020002*QR_002000020000+P_000020102*QR_002000020001+P_000020202*QR_002000020002+P_000120002*QR_002000020010+P_000120102*QR_002000020011+P_000120202*QR_002000020012+P_000220002*QR_002000020020+P_000220102*QR_002000020021+P_000220202*QR_002000020022); ans_temp[ans_id*36+17]+=Pmtrx[31]*(P_000020002*QR_001001020000+P_000020102*QR_001001020001+P_000020202*QR_001001020002+P_000120002*QR_001001020010+P_000120102*QR_001001020011+P_000120202*QR_001001020012+P_000220002*QR_001001020020+P_000220102*QR_001001020021+P_000220202*QR_001001020022); ans_temp[ans_id*36+17]+=Pmtrx[32]*(P_000020002*QR_000002020000+P_000020102*QR_000002020001+P_000020202*QR_000002020002+P_000120002*QR_000002020010+P_000120102*QR_000002020011+P_000120202*QR_000002020012+P_000220002*QR_000002020020+P_000220102*QR_000002020021+P_000220202*QR_000002020022); ans_temp[ans_id*36+17]+=Pmtrx[33]*(P_000020002*QR_001000021000+P_000020102*QR_001000021001+P_000020202*QR_001000021002+P_000120002*QR_001000021010+P_000120102*QR_001000021011+P_000120202*QR_001000021012+P_000220002*QR_001000021020+P_000220102*QR_001000021021+P_000220202*QR_001000021022); ans_temp[ans_id*36+17]+=Pmtrx[34]*(P_000020002*QR_000001021000+P_000020102*QR_000001021001+P_000020202*QR_000001021002+P_000120002*QR_000001021010+P_000120102*QR_000001021011+P_000120202*QR_000001021012+P_000220002*QR_000001021020+P_000220102*QR_000001021021+P_000220202*QR_000001021022); ans_temp[ans_id*36+17]+=Pmtrx[35]*(P_000020002*QR_000000022000+P_000020102*QR_000000022001+P_000020202*QR_000000022002+P_000120002*QR_000000022010+P_000120102*QR_000000022011+P_000120202*QR_000000022012+P_000220002*QR_000000022020+P_000220102*QR_000000022021+P_000220202*QR_000000022022); ans_temp[ans_id*36+18]+=Pmtrx[0]*(P_012000010*QR_022000000000+P_012000110*QR_022000000001+P_112000010*QR_022000000100+P_112000110*QR_022000000101+P_212000010*QR_022000000200+P_212000110*QR_022000000201+P_312000010*QR_022000000300+P_312000110*QR_022000000301); ans_temp[ans_id*36+18]+=Pmtrx[1]*(P_012000010*QR_021001000000+P_012000110*QR_021001000001+P_112000010*QR_021001000100+P_112000110*QR_021001000101+P_212000010*QR_021001000200+P_212000110*QR_021001000201+P_312000010*QR_021001000300+P_312000110*QR_021001000301); ans_temp[ans_id*36+18]+=Pmtrx[2]*(P_012000010*QR_020002000000+P_012000110*QR_020002000001+P_112000010*QR_020002000100+P_112000110*QR_020002000101+P_212000010*QR_020002000200+P_212000110*QR_020002000201+P_312000010*QR_020002000300+P_312000110*QR_020002000301); ans_temp[ans_id*36+18]+=Pmtrx[3]*(P_012000010*QR_021000001000+P_012000110*QR_021000001001+P_112000010*QR_021000001100+P_112000110*QR_021000001101+P_212000010*QR_021000001200+P_212000110*QR_021000001201+P_312000010*QR_021000001300+P_312000110*QR_021000001301); ans_temp[ans_id*36+18]+=Pmtrx[4]*(P_012000010*QR_020001001000+P_012000110*QR_020001001001+P_112000010*QR_020001001100+P_112000110*QR_020001001101+P_212000010*QR_020001001200+P_212000110*QR_020001001201+P_312000010*QR_020001001300+P_312000110*QR_020001001301); ans_temp[ans_id*36+18]+=Pmtrx[5]*(P_012000010*QR_020000002000+P_012000110*QR_020000002001+P_112000010*QR_020000002100+P_112000110*QR_020000002101+P_212000010*QR_020000002200+P_212000110*QR_020000002201+P_312000010*QR_020000002300+P_312000110*QR_020000002301); ans_temp[ans_id*36+19]+=Pmtrx[0]*(P_012000010*QR_012010000000+P_012000110*QR_012010000001+P_112000010*QR_012010000100+P_112000110*QR_012010000101+P_212000010*QR_012010000200+P_212000110*QR_012010000201+P_312000010*QR_012010000300+P_312000110*QR_012010000301); ans_temp[ans_id*36+19]+=Pmtrx[1]*(P_012000010*QR_011011000000+P_012000110*QR_011011000001+P_112000010*QR_011011000100+P_112000110*QR_011011000101+P_212000010*QR_011011000200+P_212000110*QR_011011000201+P_312000010*QR_011011000300+P_312000110*QR_011011000301); ans_temp[ans_id*36+19]+=Pmtrx[2]*(P_012000010*QR_010012000000+P_012000110*QR_010012000001+P_112000010*QR_010012000100+P_112000110*QR_010012000101+P_212000010*QR_010012000200+P_212000110*QR_010012000201+P_312000010*QR_010012000300+P_312000110*QR_010012000301); ans_temp[ans_id*36+19]+=Pmtrx[3]*(P_012000010*QR_011010001000+P_012000110*QR_011010001001+P_112000010*QR_011010001100+P_112000110*QR_011010001101+P_212000010*QR_011010001200+P_212000110*QR_011010001201+P_312000010*QR_011010001300+P_312000110*QR_011010001301); ans_temp[ans_id*36+19]+=Pmtrx[4]*(P_012000010*QR_010011001000+P_012000110*QR_010011001001+P_112000010*QR_010011001100+P_112000110*QR_010011001101+P_212000010*QR_010011001200+P_212000110*QR_010011001201+P_312000010*QR_010011001300+P_312000110*QR_010011001301); ans_temp[ans_id*36+19]+=Pmtrx[5]*(P_012000010*QR_010010002000+P_012000110*QR_010010002001+P_112000010*QR_010010002100+P_112000110*QR_010010002101+P_212000010*QR_010010002200+P_212000110*QR_010010002201+P_312000010*QR_010010002300+P_312000110*QR_010010002301); ans_temp[ans_id*36+20]+=Pmtrx[0]*(P_012000010*QR_002020000000+P_012000110*QR_002020000001+P_112000010*QR_002020000100+P_112000110*QR_002020000101+P_212000010*QR_002020000200+P_212000110*QR_002020000201+P_312000010*QR_002020000300+P_312000110*QR_002020000301); ans_temp[ans_id*36+20]+=Pmtrx[1]*(P_012000010*QR_001021000000+P_012000110*QR_001021000001+P_112000010*QR_001021000100+P_112000110*QR_001021000101+P_212000010*QR_001021000200+P_212000110*QR_001021000201+P_312000010*QR_001021000300+P_312000110*QR_001021000301); ans_temp[ans_id*36+20]+=Pmtrx[2]*(P_012000010*QR_000022000000+P_012000110*QR_000022000001+P_112000010*QR_000022000100+P_112000110*QR_000022000101+P_212000010*QR_000022000200+P_212000110*QR_000022000201+P_312000010*QR_000022000300+P_312000110*QR_000022000301); ans_temp[ans_id*36+20]+=Pmtrx[3]*(P_012000010*QR_001020001000+P_012000110*QR_001020001001+P_112000010*QR_001020001100+P_112000110*QR_001020001101+P_212000010*QR_001020001200+P_212000110*QR_001020001201+P_312000010*QR_001020001300+P_312000110*QR_001020001301); ans_temp[ans_id*36+20]+=Pmtrx[4]*(P_012000010*QR_000021001000+P_012000110*QR_000021001001+P_112000010*QR_000021001100+P_112000110*QR_000021001101+P_212000010*QR_000021001200+P_212000110*QR_000021001201+P_312000010*QR_000021001300+P_312000110*QR_000021001301); ans_temp[ans_id*36+20]+=Pmtrx[5]*(P_012000010*QR_000020002000+P_012000110*QR_000020002001+P_112000010*QR_000020002100+P_112000110*QR_000020002101+P_212000010*QR_000020002200+P_212000110*QR_000020002201+P_312000010*QR_000020002300+P_312000110*QR_000020002301); ans_temp[ans_id*36+21]+=Pmtrx[0]*(P_012000010*QR_012000010000+P_012000110*QR_012000010001+P_112000010*QR_012000010100+P_112000110*QR_012000010101+P_212000010*QR_012000010200+P_212000110*QR_012000010201+P_312000010*QR_012000010300+P_312000110*QR_012000010301); ans_temp[ans_id*36+21]+=Pmtrx[1]*(P_012000010*QR_011001010000+P_012000110*QR_011001010001+P_112000010*QR_011001010100+P_112000110*QR_011001010101+P_212000010*QR_011001010200+P_212000110*QR_011001010201+P_312000010*QR_011001010300+P_312000110*QR_011001010301); ans_temp[ans_id*36+21]+=Pmtrx[2]*(P_012000010*QR_010002010000+P_012000110*QR_010002010001+P_112000010*QR_010002010100+P_112000110*QR_010002010101+P_212000010*QR_010002010200+P_212000110*QR_010002010201+P_312000010*QR_010002010300+P_312000110*QR_010002010301); ans_temp[ans_id*36+21]+=Pmtrx[3]*(P_012000010*QR_011000011000+P_012000110*QR_011000011001+P_112000010*QR_011000011100+P_112000110*QR_011000011101+P_212000010*QR_011000011200+P_212000110*QR_011000011201+P_312000010*QR_011000011300+P_312000110*QR_011000011301); ans_temp[ans_id*36+21]+=Pmtrx[4]*(P_012000010*QR_010001011000+P_012000110*QR_010001011001+P_112000010*QR_010001011100+P_112000110*QR_010001011101+P_212000010*QR_010001011200+P_212000110*QR_010001011201+P_312000010*QR_010001011300+P_312000110*QR_010001011301); ans_temp[ans_id*36+21]+=Pmtrx[5]*(P_012000010*QR_010000012000+P_012000110*QR_010000012001+P_112000010*QR_010000012100+P_112000110*QR_010000012101+P_212000010*QR_010000012200+P_212000110*QR_010000012201+P_312000010*QR_010000012300+P_312000110*QR_010000012301); ans_temp[ans_id*36+22]+=Pmtrx[0]*(P_012000010*QR_002010010000+P_012000110*QR_002010010001+P_112000010*QR_002010010100+P_112000110*QR_002010010101+P_212000010*QR_002010010200+P_212000110*QR_002010010201+P_312000010*QR_002010010300+P_312000110*QR_002010010301); ans_temp[ans_id*36+22]+=Pmtrx[1]*(P_012000010*QR_001011010000+P_012000110*QR_001011010001+P_112000010*QR_001011010100+P_112000110*QR_001011010101+P_212000010*QR_001011010200+P_212000110*QR_001011010201+P_312000010*QR_001011010300+P_312000110*QR_001011010301); ans_temp[ans_id*36+22]+=Pmtrx[2]*(P_012000010*QR_000012010000+P_012000110*QR_000012010001+P_112000010*QR_000012010100+P_112000110*QR_000012010101+P_212000010*QR_000012010200+P_212000110*QR_000012010201+P_312000010*QR_000012010300+P_312000110*QR_000012010301); ans_temp[ans_id*36+22]+=Pmtrx[3]*(P_012000010*QR_001010011000+P_012000110*QR_001010011001+P_112000010*QR_001010011100+P_112000110*QR_001010011101+P_212000010*QR_001010011200+P_212000110*QR_001010011201+P_312000010*QR_001010011300+P_312000110*QR_001010011301); ans_temp[ans_id*36+22]+=Pmtrx[4]*(P_012000010*QR_000011011000+P_012000110*QR_000011011001+P_112000010*QR_000011011100+P_112000110*QR_000011011101+P_212000010*QR_000011011200+P_212000110*QR_000011011201+P_312000010*QR_000011011300+P_312000110*QR_000011011301); ans_temp[ans_id*36+22]+=Pmtrx[5]*(P_012000010*QR_000010012000+P_012000110*QR_000010012001+P_112000010*QR_000010012100+P_112000110*QR_000010012101+P_212000010*QR_000010012200+P_212000110*QR_000010012201+P_312000010*QR_000010012300+P_312000110*QR_000010012301); ans_temp[ans_id*36+23]+=Pmtrx[0]*(P_012000010*QR_002000020000+P_012000110*QR_002000020001+P_112000010*QR_002000020100+P_112000110*QR_002000020101+P_212000010*QR_002000020200+P_212000110*QR_002000020201+P_312000010*QR_002000020300+P_312000110*QR_002000020301); ans_temp[ans_id*36+23]+=Pmtrx[1]*(P_012000010*QR_001001020000+P_012000110*QR_001001020001+P_112000010*QR_001001020100+P_112000110*QR_001001020101+P_212000010*QR_001001020200+P_212000110*QR_001001020201+P_312000010*QR_001001020300+P_312000110*QR_001001020301); ans_temp[ans_id*36+23]+=Pmtrx[2]*(P_012000010*QR_000002020000+P_012000110*QR_000002020001+P_112000010*QR_000002020100+P_112000110*QR_000002020101+P_212000010*QR_000002020200+P_212000110*QR_000002020201+P_312000010*QR_000002020300+P_312000110*QR_000002020301); ans_temp[ans_id*36+23]+=Pmtrx[3]*(P_012000010*QR_001000021000+P_012000110*QR_001000021001+P_112000010*QR_001000021100+P_112000110*QR_001000021101+P_212000010*QR_001000021200+P_212000110*QR_001000021201+P_312000010*QR_001000021300+P_312000110*QR_001000021301); ans_temp[ans_id*36+23]+=Pmtrx[4]*(P_012000010*QR_000001021000+P_012000110*QR_000001021001+P_112000010*QR_000001021100+P_112000110*QR_000001021101+P_212000010*QR_000001021200+P_212000110*QR_000001021201+P_312000010*QR_000001021300+P_312000110*QR_000001021301); ans_temp[ans_id*36+23]+=Pmtrx[5]*(P_012000010*QR_000000022000+P_012000110*QR_000000022001+P_112000010*QR_000000022100+P_112000110*QR_000000022101+P_212000010*QR_000000022200+P_212000110*QR_000000022201+P_312000010*QR_000000022300+P_312000110*QR_000000022301); ans_temp[ans_id*36+18]+=Pmtrx[6]*(P_011001010*QR_022000000000+P_011001110*QR_022000000001+P_011101010*QR_022000000010+P_011101110*QR_022000000011+P_111001010*QR_022000000100+P_111001110*QR_022000000101+P_111101010*QR_022000000110+P_111101110*QR_022000000111+P_211001010*QR_022000000200+P_211001110*QR_022000000201+P_211101010*QR_022000000210+P_211101110*QR_022000000211); ans_temp[ans_id*36+18]+=Pmtrx[7]*(P_011001010*QR_021001000000+P_011001110*QR_021001000001+P_011101010*QR_021001000010+P_011101110*QR_021001000011+P_111001010*QR_021001000100+P_111001110*QR_021001000101+P_111101010*QR_021001000110+P_111101110*QR_021001000111+P_211001010*QR_021001000200+P_211001110*QR_021001000201+P_211101010*QR_021001000210+P_211101110*QR_021001000211); ans_temp[ans_id*36+18]+=Pmtrx[8]*(P_011001010*QR_020002000000+P_011001110*QR_020002000001+P_011101010*QR_020002000010+P_011101110*QR_020002000011+P_111001010*QR_020002000100+P_111001110*QR_020002000101+P_111101010*QR_020002000110+P_111101110*QR_020002000111+P_211001010*QR_020002000200+P_211001110*QR_020002000201+P_211101010*QR_020002000210+P_211101110*QR_020002000211); ans_temp[ans_id*36+18]+=Pmtrx[9]*(P_011001010*QR_021000001000+P_011001110*QR_021000001001+P_011101010*QR_021000001010+P_011101110*QR_021000001011+P_111001010*QR_021000001100+P_111001110*QR_021000001101+P_111101010*QR_021000001110+P_111101110*QR_021000001111+P_211001010*QR_021000001200+P_211001110*QR_021000001201+P_211101010*QR_021000001210+P_211101110*QR_021000001211); ans_temp[ans_id*36+18]+=Pmtrx[10]*(P_011001010*QR_020001001000+P_011001110*QR_020001001001+P_011101010*QR_020001001010+P_011101110*QR_020001001011+P_111001010*QR_020001001100+P_111001110*QR_020001001101+P_111101010*QR_020001001110+P_111101110*QR_020001001111+P_211001010*QR_020001001200+P_211001110*QR_020001001201+P_211101010*QR_020001001210+P_211101110*QR_020001001211); ans_temp[ans_id*36+18]+=Pmtrx[11]*(P_011001010*QR_020000002000+P_011001110*QR_020000002001+P_011101010*QR_020000002010+P_011101110*QR_020000002011+P_111001010*QR_020000002100+P_111001110*QR_020000002101+P_111101010*QR_020000002110+P_111101110*QR_020000002111+P_211001010*QR_020000002200+P_211001110*QR_020000002201+P_211101010*QR_020000002210+P_211101110*QR_020000002211); ans_temp[ans_id*36+19]+=Pmtrx[6]*(P_011001010*QR_012010000000+P_011001110*QR_012010000001+P_011101010*QR_012010000010+P_011101110*QR_012010000011+P_111001010*QR_012010000100+P_111001110*QR_012010000101+P_111101010*QR_012010000110+P_111101110*QR_012010000111+P_211001010*QR_012010000200+P_211001110*QR_012010000201+P_211101010*QR_012010000210+P_211101110*QR_012010000211); ans_temp[ans_id*36+19]+=Pmtrx[7]*(P_011001010*QR_011011000000+P_011001110*QR_011011000001+P_011101010*QR_011011000010+P_011101110*QR_011011000011+P_111001010*QR_011011000100+P_111001110*QR_011011000101+P_111101010*QR_011011000110+P_111101110*QR_011011000111+P_211001010*QR_011011000200+P_211001110*QR_011011000201+P_211101010*QR_011011000210+P_211101110*QR_011011000211); ans_temp[ans_id*36+19]+=Pmtrx[8]*(P_011001010*QR_010012000000+P_011001110*QR_010012000001+P_011101010*QR_010012000010+P_011101110*QR_010012000011+P_111001010*QR_010012000100+P_111001110*QR_010012000101+P_111101010*QR_010012000110+P_111101110*QR_010012000111+P_211001010*QR_010012000200+P_211001110*QR_010012000201+P_211101010*QR_010012000210+P_211101110*QR_010012000211); ans_temp[ans_id*36+19]+=Pmtrx[9]*(P_011001010*QR_011010001000+P_011001110*QR_011010001001+P_011101010*QR_011010001010+P_011101110*QR_011010001011+P_111001010*QR_011010001100+P_111001110*QR_011010001101+P_111101010*QR_011010001110+P_111101110*QR_011010001111+P_211001010*QR_011010001200+P_211001110*QR_011010001201+P_211101010*QR_011010001210+P_211101110*QR_011010001211); ans_temp[ans_id*36+19]+=Pmtrx[10]*(P_011001010*QR_010011001000+P_011001110*QR_010011001001+P_011101010*QR_010011001010+P_011101110*QR_010011001011+P_111001010*QR_010011001100+P_111001110*QR_010011001101+P_111101010*QR_010011001110+P_111101110*QR_010011001111+P_211001010*QR_010011001200+P_211001110*QR_010011001201+P_211101010*QR_010011001210+P_211101110*QR_010011001211); ans_temp[ans_id*36+19]+=Pmtrx[11]*(P_011001010*QR_010010002000+P_011001110*QR_010010002001+P_011101010*QR_010010002010+P_011101110*QR_010010002011+P_111001010*QR_010010002100+P_111001110*QR_010010002101+P_111101010*QR_010010002110+P_111101110*QR_010010002111+P_211001010*QR_010010002200+P_211001110*QR_010010002201+P_211101010*QR_010010002210+P_211101110*QR_010010002211); ans_temp[ans_id*36+20]+=Pmtrx[6]*(P_011001010*QR_002020000000+P_011001110*QR_002020000001+P_011101010*QR_002020000010+P_011101110*QR_002020000011+P_111001010*QR_002020000100+P_111001110*QR_002020000101+P_111101010*QR_002020000110+P_111101110*QR_002020000111+P_211001010*QR_002020000200+P_211001110*QR_002020000201+P_211101010*QR_002020000210+P_211101110*QR_002020000211); ans_temp[ans_id*36+20]+=Pmtrx[7]*(P_011001010*QR_001021000000+P_011001110*QR_001021000001+P_011101010*QR_001021000010+P_011101110*QR_001021000011+P_111001010*QR_001021000100+P_111001110*QR_001021000101+P_111101010*QR_001021000110+P_111101110*QR_001021000111+P_211001010*QR_001021000200+P_211001110*QR_001021000201+P_211101010*QR_001021000210+P_211101110*QR_001021000211); ans_temp[ans_id*36+20]+=Pmtrx[8]*(P_011001010*QR_000022000000+P_011001110*QR_000022000001+P_011101010*QR_000022000010+P_011101110*QR_000022000011+P_111001010*QR_000022000100+P_111001110*QR_000022000101+P_111101010*QR_000022000110+P_111101110*QR_000022000111+P_211001010*QR_000022000200+P_211001110*QR_000022000201+P_211101010*QR_000022000210+P_211101110*QR_000022000211); ans_temp[ans_id*36+20]+=Pmtrx[9]*(P_011001010*QR_001020001000+P_011001110*QR_001020001001+P_011101010*QR_001020001010+P_011101110*QR_001020001011+P_111001010*QR_001020001100+P_111001110*QR_001020001101+P_111101010*QR_001020001110+P_111101110*QR_001020001111+P_211001010*QR_001020001200+P_211001110*QR_001020001201+P_211101010*QR_001020001210+P_211101110*QR_001020001211); ans_temp[ans_id*36+20]+=Pmtrx[10]*(P_011001010*QR_000021001000+P_011001110*QR_000021001001+P_011101010*QR_000021001010+P_011101110*QR_000021001011+P_111001010*QR_000021001100+P_111001110*QR_000021001101+P_111101010*QR_000021001110+P_111101110*QR_000021001111+P_211001010*QR_000021001200+P_211001110*QR_000021001201+P_211101010*QR_000021001210+P_211101110*QR_000021001211); ans_temp[ans_id*36+20]+=Pmtrx[11]*(P_011001010*QR_000020002000+P_011001110*QR_000020002001+P_011101010*QR_000020002010+P_011101110*QR_000020002011+P_111001010*QR_000020002100+P_111001110*QR_000020002101+P_111101010*QR_000020002110+P_111101110*QR_000020002111+P_211001010*QR_000020002200+P_211001110*QR_000020002201+P_211101010*QR_000020002210+P_211101110*QR_000020002211); ans_temp[ans_id*36+21]+=Pmtrx[6]*(P_011001010*QR_012000010000+P_011001110*QR_012000010001+P_011101010*QR_012000010010+P_011101110*QR_012000010011+P_111001010*QR_012000010100+P_111001110*QR_012000010101+P_111101010*QR_012000010110+P_111101110*QR_012000010111+P_211001010*QR_012000010200+P_211001110*QR_012000010201+P_211101010*QR_012000010210+P_211101110*QR_012000010211); ans_temp[ans_id*36+21]+=Pmtrx[7]*(P_011001010*QR_011001010000+P_011001110*QR_011001010001+P_011101010*QR_011001010010+P_011101110*QR_011001010011+P_111001010*QR_011001010100+P_111001110*QR_011001010101+P_111101010*QR_011001010110+P_111101110*QR_011001010111+P_211001010*QR_011001010200+P_211001110*QR_011001010201+P_211101010*QR_011001010210+P_211101110*QR_011001010211); ans_temp[ans_id*36+21]+=Pmtrx[8]*(P_011001010*QR_010002010000+P_011001110*QR_010002010001+P_011101010*QR_010002010010+P_011101110*QR_010002010011+P_111001010*QR_010002010100+P_111001110*QR_010002010101+P_111101010*QR_010002010110+P_111101110*QR_010002010111+P_211001010*QR_010002010200+P_211001110*QR_010002010201+P_211101010*QR_010002010210+P_211101110*QR_010002010211); ans_temp[ans_id*36+21]+=Pmtrx[9]*(P_011001010*QR_011000011000+P_011001110*QR_011000011001+P_011101010*QR_011000011010+P_011101110*QR_011000011011+P_111001010*QR_011000011100+P_111001110*QR_011000011101+P_111101010*QR_011000011110+P_111101110*QR_011000011111+P_211001010*QR_011000011200+P_211001110*QR_011000011201+P_211101010*QR_011000011210+P_211101110*QR_011000011211); ans_temp[ans_id*36+21]+=Pmtrx[10]*(P_011001010*QR_010001011000+P_011001110*QR_010001011001+P_011101010*QR_010001011010+P_011101110*QR_010001011011+P_111001010*QR_010001011100+P_111001110*QR_010001011101+P_111101010*QR_010001011110+P_111101110*QR_010001011111+P_211001010*QR_010001011200+P_211001110*QR_010001011201+P_211101010*QR_010001011210+P_211101110*QR_010001011211); ans_temp[ans_id*36+21]+=Pmtrx[11]*(P_011001010*QR_010000012000+P_011001110*QR_010000012001+P_011101010*QR_010000012010+P_011101110*QR_010000012011+P_111001010*QR_010000012100+P_111001110*QR_010000012101+P_111101010*QR_010000012110+P_111101110*QR_010000012111+P_211001010*QR_010000012200+P_211001110*QR_010000012201+P_211101010*QR_010000012210+P_211101110*QR_010000012211); ans_temp[ans_id*36+22]+=Pmtrx[6]*(P_011001010*QR_002010010000+P_011001110*QR_002010010001+P_011101010*QR_002010010010+P_011101110*QR_002010010011+P_111001010*QR_002010010100+P_111001110*QR_002010010101+P_111101010*QR_002010010110+P_111101110*QR_002010010111+P_211001010*QR_002010010200+P_211001110*QR_002010010201+P_211101010*QR_002010010210+P_211101110*QR_002010010211); ans_temp[ans_id*36+22]+=Pmtrx[7]*(P_011001010*QR_001011010000+P_011001110*QR_001011010001+P_011101010*QR_001011010010+P_011101110*QR_001011010011+P_111001010*QR_001011010100+P_111001110*QR_001011010101+P_111101010*QR_001011010110+P_111101110*QR_001011010111+P_211001010*QR_001011010200+P_211001110*QR_001011010201+P_211101010*QR_001011010210+P_211101110*QR_001011010211); ans_temp[ans_id*36+22]+=Pmtrx[8]*(P_011001010*QR_000012010000+P_011001110*QR_000012010001+P_011101010*QR_000012010010+P_011101110*QR_000012010011+P_111001010*QR_000012010100+P_111001110*QR_000012010101+P_111101010*QR_000012010110+P_111101110*QR_000012010111+P_211001010*QR_000012010200+P_211001110*QR_000012010201+P_211101010*QR_000012010210+P_211101110*QR_000012010211); ans_temp[ans_id*36+22]+=Pmtrx[9]*(P_011001010*QR_001010011000+P_011001110*QR_001010011001+P_011101010*QR_001010011010+P_011101110*QR_001010011011+P_111001010*QR_001010011100+P_111001110*QR_001010011101+P_111101010*QR_001010011110+P_111101110*QR_001010011111+P_211001010*QR_001010011200+P_211001110*QR_001010011201+P_211101010*QR_001010011210+P_211101110*QR_001010011211); ans_temp[ans_id*36+22]+=Pmtrx[10]*(P_011001010*QR_000011011000+P_011001110*QR_000011011001+P_011101010*QR_000011011010+P_011101110*QR_000011011011+P_111001010*QR_000011011100+P_111001110*QR_000011011101+P_111101010*QR_000011011110+P_111101110*QR_000011011111+P_211001010*QR_000011011200+P_211001110*QR_000011011201+P_211101010*QR_000011011210+P_211101110*QR_000011011211); ans_temp[ans_id*36+22]+=Pmtrx[11]*(P_011001010*QR_000010012000+P_011001110*QR_000010012001+P_011101010*QR_000010012010+P_011101110*QR_000010012011+P_111001010*QR_000010012100+P_111001110*QR_000010012101+P_111101010*QR_000010012110+P_111101110*QR_000010012111+P_211001010*QR_000010012200+P_211001110*QR_000010012201+P_211101010*QR_000010012210+P_211101110*QR_000010012211); ans_temp[ans_id*36+23]+=Pmtrx[6]*(P_011001010*QR_002000020000+P_011001110*QR_002000020001+P_011101010*QR_002000020010+P_011101110*QR_002000020011+P_111001010*QR_002000020100+P_111001110*QR_002000020101+P_111101010*QR_002000020110+P_111101110*QR_002000020111+P_211001010*QR_002000020200+P_211001110*QR_002000020201+P_211101010*QR_002000020210+P_211101110*QR_002000020211); ans_temp[ans_id*36+23]+=Pmtrx[7]*(P_011001010*QR_001001020000+P_011001110*QR_001001020001+P_011101010*QR_001001020010+P_011101110*QR_001001020011+P_111001010*QR_001001020100+P_111001110*QR_001001020101+P_111101010*QR_001001020110+P_111101110*QR_001001020111+P_211001010*QR_001001020200+P_211001110*QR_001001020201+P_211101010*QR_001001020210+P_211101110*QR_001001020211); ans_temp[ans_id*36+23]+=Pmtrx[8]*(P_011001010*QR_000002020000+P_011001110*QR_000002020001+P_011101010*QR_000002020010+P_011101110*QR_000002020011+P_111001010*QR_000002020100+P_111001110*QR_000002020101+P_111101010*QR_000002020110+P_111101110*QR_000002020111+P_211001010*QR_000002020200+P_211001110*QR_000002020201+P_211101010*QR_000002020210+P_211101110*QR_000002020211); ans_temp[ans_id*36+23]+=Pmtrx[9]*(P_011001010*QR_001000021000+P_011001110*QR_001000021001+P_011101010*QR_001000021010+P_011101110*QR_001000021011+P_111001010*QR_001000021100+P_111001110*QR_001000021101+P_111101010*QR_001000021110+P_111101110*QR_001000021111+P_211001010*QR_001000021200+P_211001110*QR_001000021201+P_211101010*QR_001000021210+P_211101110*QR_001000021211); ans_temp[ans_id*36+23]+=Pmtrx[10]*(P_011001010*QR_000001021000+P_011001110*QR_000001021001+P_011101010*QR_000001021010+P_011101110*QR_000001021011+P_111001010*QR_000001021100+P_111001110*QR_000001021101+P_111101010*QR_000001021110+P_111101110*QR_000001021111+P_211001010*QR_000001021200+P_211001110*QR_000001021201+P_211101010*QR_000001021210+P_211101110*QR_000001021211); ans_temp[ans_id*36+23]+=Pmtrx[11]*(P_011001010*QR_000000022000+P_011001110*QR_000000022001+P_011101010*QR_000000022010+P_011101110*QR_000000022011+P_111001010*QR_000000022100+P_111001110*QR_000000022101+P_111101010*QR_000000022110+P_111101110*QR_000000022111+P_211001010*QR_000000022200+P_211001110*QR_000000022201+P_211101010*QR_000000022210+P_211101110*QR_000000022211); ans_temp[ans_id*36+18]+=Pmtrx[12]*(P_010002010*QR_022000000000+P_010002110*QR_022000000001+P_010102010*QR_022000000010+P_010102110*QR_022000000011+P_010202010*QR_022000000020+P_010202110*QR_022000000021+P_110002010*QR_022000000100+P_110002110*QR_022000000101+P_110102010*QR_022000000110+P_110102110*QR_022000000111+P_110202010*QR_022000000120+P_110202110*QR_022000000121); ans_temp[ans_id*36+18]+=Pmtrx[13]*(P_010002010*QR_021001000000+P_010002110*QR_021001000001+P_010102010*QR_021001000010+P_010102110*QR_021001000011+P_010202010*QR_021001000020+P_010202110*QR_021001000021+P_110002010*QR_021001000100+P_110002110*QR_021001000101+P_110102010*QR_021001000110+P_110102110*QR_021001000111+P_110202010*QR_021001000120+P_110202110*QR_021001000121); ans_temp[ans_id*36+18]+=Pmtrx[14]*(P_010002010*QR_020002000000+P_010002110*QR_020002000001+P_010102010*QR_020002000010+P_010102110*QR_020002000011+P_010202010*QR_020002000020+P_010202110*QR_020002000021+P_110002010*QR_020002000100+P_110002110*QR_020002000101+P_110102010*QR_020002000110+P_110102110*QR_020002000111+P_110202010*QR_020002000120+P_110202110*QR_020002000121); ans_temp[ans_id*36+18]+=Pmtrx[15]*(P_010002010*QR_021000001000+P_010002110*QR_021000001001+P_010102010*QR_021000001010+P_010102110*QR_021000001011+P_010202010*QR_021000001020+P_010202110*QR_021000001021+P_110002010*QR_021000001100+P_110002110*QR_021000001101+P_110102010*QR_021000001110+P_110102110*QR_021000001111+P_110202010*QR_021000001120+P_110202110*QR_021000001121); ans_temp[ans_id*36+18]+=Pmtrx[16]*(P_010002010*QR_020001001000+P_010002110*QR_020001001001+P_010102010*QR_020001001010+P_010102110*QR_020001001011+P_010202010*QR_020001001020+P_010202110*QR_020001001021+P_110002010*QR_020001001100+P_110002110*QR_020001001101+P_110102010*QR_020001001110+P_110102110*QR_020001001111+P_110202010*QR_020001001120+P_110202110*QR_020001001121); ans_temp[ans_id*36+18]+=Pmtrx[17]*(P_010002010*QR_020000002000+P_010002110*QR_020000002001+P_010102010*QR_020000002010+P_010102110*QR_020000002011+P_010202010*QR_020000002020+P_010202110*QR_020000002021+P_110002010*QR_020000002100+P_110002110*QR_020000002101+P_110102010*QR_020000002110+P_110102110*QR_020000002111+P_110202010*QR_020000002120+P_110202110*QR_020000002121); ans_temp[ans_id*36+19]+=Pmtrx[12]*(P_010002010*QR_012010000000+P_010002110*QR_012010000001+P_010102010*QR_012010000010+P_010102110*QR_012010000011+P_010202010*QR_012010000020+P_010202110*QR_012010000021+P_110002010*QR_012010000100+P_110002110*QR_012010000101+P_110102010*QR_012010000110+P_110102110*QR_012010000111+P_110202010*QR_012010000120+P_110202110*QR_012010000121); ans_temp[ans_id*36+19]+=Pmtrx[13]*(P_010002010*QR_011011000000+P_010002110*QR_011011000001+P_010102010*QR_011011000010+P_010102110*QR_011011000011+P_010202010*QR_011011000020+P_010202110*QR_011011000021+P_110002010*QR_011011000100+P_110002110*QR_011011000101+P_110102010*QR_011011000110+P_110102110*QR_011011000111+P_110202010*QR_011011000120+P_110202110*QR_011011000121); ans_temp[ans_id*36+19]+=Pmtrx[14]*(P_010002010*QR_010012000000+P_010002110*QR_010012000001+P_010102010*QR_010012000010+P_010102110*QR_010012000011+P_010202010*QR_010012000020+P_010202110*QR_010012000021+P_110002010*QR_010012000100+P_110002110*QR_010012000101+P_110102010*QR_010012000110+P_110102110*QR_010012000111+P_110202010*QR_010012000120+P_110202110*QR_010012000121); ans_temp[ans_id*36+19]+=Pmtrx[15]*(P_010002010*QR_011010001000+P_010002110*QR_011010001001+P_010102010*QR_011010001010+P_010102110*QR_011010001011+P_010202010*QR_011010001020+P_010202110*QR_011010001021+P_110002010*QR_011010001100+P_110002110*QR_011010001101+P_110102010*QR_011010001110+P_110102110*QR_011010001111+P_110202010*QR_011010001120+P_110202110*QR_011010001121); ans_temp[ans_id*36+19]+=Pmtrx[16]*(P_010002010*QR_010011001000+P_010002110*QR_010011001001+P_010102010*QR_010011001010+P_010102110*QR_010011001011+P_010202010*QR_010011001020+P_010202110*QR_010011001021+P_110002010*QR_010011001100+P_110002110*QR_010011001101+P_110102010*QR_010011001110+P_110102110*QR_010011001111+P_110202010*QR_010011001120+P_110202110*QR_010011001121); ans_temp[ans_id*36+19]+=Pmtrx[17]*(P_010002010*QR_010010002000+P_010002110*QR_010010002001+P_010102010*QR_010010002010+P_010102110*QR_010010002011+P_010202010*QR_010010002020+P_010202110*QR_010010002021+P_110002010*QR_010010002100+P_110002110*QR_010010002101+P_110102010*QR_010010002110+P_110102110*QR_010010002111+P_110202010*QR_010010002120+P_110202110*QR_010010002121); ans_temp[ans_id*36+20]+=Pmtrx[12]*(P_010002010*QR_002020000000+P_010002110*QR_002020000001+P_010102010*QR_002020000010+P_010102110*QR_002020000011+P_010202010*QR_002020000020+P_010202110*QR_002020000021+P_110002010*QR_002020000100+P_110002110*QR_002020000101+P_110102010*QR_002020000110+P_110102110*QR_002020000111+P_110202010*QR_002020000120+P_110202110*QR_002020000121); ans_temp[ans_id*36+20]+=Pmtrx[13]*(P_010002010*QR_001021000000+P_010002110*QR_001021000001+P_010102010*QR_001021000010+P_010102110*QR_001021000011+P_010202010*QR_001021000020+P_010202110*QR_001021000021+P_110002010*QR_001021000100+P_110002110*QR_001021000101+P_110102010*QR_001021000110+P_110102110*QR_001021000111+P_110202010*QR_001021000120+P_110202110*QR_001021000121); ans_temp[ans_id*36+20]+=Pmtrx[14]*(P_010002010*QR_000022000000+P_010002110*QR_000022000001+P_010102010*QR_000022000010+P_010102110*QR_000022000011+P_010202010*QR_000022000020+P_010202110*QR_000022000021+P_110002010*QR_000022000100+P_110002110*QR_000022000101+P_110102010*QR_000022000110+P_110102110*QR_000022000111+P_110202010*QR_000022000120+P_110202110*QR_000022000121); ans_temp[ans_id*36+20]+=Pmtrx[15]*(P_010002010*QR_001020001000+P_010002110*QR_001020001001+P_010102010*QR_001020001010+P_010102110*QR_001020001011+P_010202010*QR_001020001020+P_010202110*QR_001020001021+P_110002010*QR_001020001100+P_110002110*QR_001020001101+P_110102010*QR_001020001110+P_110102110*QR_001020001111+P_110202010*QR_001020001120+P_110202110*QR_001020001121); ans_temp[ans_id*36+20]+=Pmtrx[16]*(P_010002010*QR_000021001000+P_010002110*QR_000021001001+P_010102010*QR_000021001010+P_010102110*QR_000021001011+P_010202010*QR_000021001020+P_010202110*QR_000021001021+P_110002010*QR_000021001100+P_110002110*QR_000021001101+P_110102010*QR_000021001110+P_110102110*QR_000021001111+P_110202010*QR_000021001120+P_110202110*QR_000021001121); ans_temp[ans_id*36+20]+=Pmtrx[17]*(P_010002010*QR_000020002000+P_010002110*QR_000020002001+P_010102010*QR_000020002010+P_010102110*QR_000020002011+P_010202010*QR_000020002020+P_010202110*QR_000020002021+P_110002010*QR_000020002100+P_110002110*QR_000020002101+P_110102010*QR_000020002110+P_110102110*QR_000020002111+P_110202010*QR_000020002120+P_110202110*QR_000020002121); ans_temp[ans_id*36+21]+=Pmtrx[12]*(P_010002010*QR_012000010000+P_010002110*QR_012000010001+P_010102010*QR_012000010010+P_010102110*QR_012000010011+P_010202010*QR_012000010020+P_010202110*QR_012000010021+P_110002010*QR_012000010100+P_110002110*QR_012000010101+P_110102010*QR_012000010110+P_110102110*QR_012000010111+P_110202010*QR_012000010120+P_110202110*QR_012000010121); ans_temp[ans_id*36+21]+=Pmtrx[13]*(P_010002010*QR_011001010000+P_010002110*QR_011001010001+P_010102010*QR_011001010010+P_010102110*QR_011001010011+P_010202010*QR_011001010020+P_010202110*QR_011001010021+P_110002010*QR_011001010100+P_110002110*QR_011001010101+P_110102010*QR_011001010110+P_110102110*QR_011001010111+P_110202010*QR_011001010120+P_110202110*QR_011001010121); ans_temp[ans_id*36+21]+=Pmtrx[14]*(P_010002010*QR_010002010000+P_010002110*QR_010002010001+P_010102010*QR_010002010010+P_010102110*QR_010002010011+P_010202010*QR_010002010020+P_010202110*QR_010002010021+P_110002010*QR_010002010100+P_110002110*QR_010002010101+P_110102010*QR_010002010110+P_110102110*QR_010002010111+P_110202010*QR_010002010120+P_110202110*QR_010002010121); ans_temp[ans_id*36+21]+=Pmtrx[15]*(P_010002010*QR_011000011000+P_010002110*QR_011000011001+P_010102010*QR_011000011010+P_010102110*QR_011000011011+P_010202010*QR_011000011020+P_010202110*QR_011000011021+P_110002010*QR_011000011100+P_110002110*QR_011000011101+P_110102010*QR_011000011110+P_110102110*QR_011000011111+P_110202010*QR_011000011120+P_110202110*QR_011000011121); ans_temp[ans_id*36+21]+=Pmtrx[16]*(P_010002010*QR_010001011000+P_010002110*QR_010001011001+P_010102010*QR_010001011010+P_010102110*QR_010001011011+P_010202010*QR_010001011020+P_010202110*QR_010001011021+P_110002010*QR_010001011100+P_110002110*QR_010001011101+P_110102010*QR_010001011110+P_110102110*QR_010001011111+P_110202010*QR_010001011120+P_110202110*QR_010001011121); ans_temp[ans_id*36+21]+=Pmtrx[17]*(P_010002010*QR_010000012000+P_010002110*QR_010000012001+P_010102010*QR_010000012010+P_010102110*QR_010000012011+P_010202010*QR_010000012020+P_010202110*QR_010000012021+P_110002010*QR_010000012100+P_110002110*QR_010000012101+P_110102010*QR_010000012110+P_110102110*QR_010000012111+P_110202010*QR_010000012120+P_110202110*QR_010000012121); ans_temp[ans_id*36+22]+=Pmtrx[12]*(P_010002010*QR_002010010000+P_010002110*QR_002010010001+P_010102010*QR_002010010010+P_010102110*QR_002010010011+P_010202010*QR_002010010020+P_010202110*QR_002010010021+P_110002010*QR_002010010100+P_110002110*QR_002010010101+P_110102010*QR_002010010110+P_110102110*QR_002010010111+P_110202010*QR_002010010120+P_110202110*QR_002010010121); ans_temp[ans_id*36+22]+=Pmtrx[13]*(P_010002010*QR_001011010000+P_010002110*QR_001011010001+P_010102010*QR_001011010010+P_010102110*QR_001011010011+P_010202010*QR_001011010020+P_010202110*QR_001011010021+P_110002010*QR_001011010100+P_110002110*QR_001011010101+P_110102010*QR_001011010110+P_110102110*QR_001011010111+P_110202010*QR_001011010120+P_110202110*QR_001011010121); ans_temp[ans_id*36+22]+=Pmtrx[14]*(P_010002010*QR_000012010000+P_010002110*QR_000012010001+P_010102010*QR_000012010010+P_010102110*QR_000012010011+P_010202010*QR_000012010020+P_010202110*QR_000012010021+P_110002010*QR_000012010100+P_110002110*QR_000012010101+P_110102010*QR_000012010110+P_110102110*QR_000012010111+P_110202010*QR_000012010120+P_110202110*QR_000012010121); ans_temp[ans_id*36+22]+=Pmtrx[15]*(P_010002010*QR_001010011000+P_010002110*QR_001010011001+P_010102010*QR_001010011010+P_010102110*QR_001010011011+P_010202010*QR_001010011020+P_010202110*QR_001010011021+P_110002010*QR_001010011100+P_110002110*QR_001010011101+P_110102010*QR_001010011110+P_110102110*QR_001010011111+P_110202010*QR_001010011120+P_110202110*QR_001010011121); ans_temp[ans_id*36+22]+=Pmtrx[16]*(P_010002010*QR_000011011000+P_010002110*QR_000011011001+P_010102010*QR_000011011010+P_010102110*QR_000011011011+P_010202010*QR_000011011020+P_010202110*QR_000011011021+P_110002010*QR_000011011100+P_110002110*QR_000011011101+P_110102010*QR_000011011110+P_110102110*QR_000011011111+P_110202010*QR_000011011120+P_110202110*QR_000011011121); ans_temp[ans_id*36+22]+=Pmtrx[17]*(P_010002010*QR_000010012000+P_010002110*QR_000010012001+P_010102010*QR_000010012010+P_010102110*QR_000010012011+P_010202010*QR_000010012020+P_010202110*QR_000010012021+P_110002010*QR_000010012100+P_110002110*QR_000010012101+P_110102010*QR_000010012110+P_110102110*QR_000010012111+P_110202010*QR_000010012120+P_110202110*QR_000010012121); ans_temp[ans_id*36+23]+=Pmtrx[12]*(P_010002010*QR_002000020000+P_010002110*QR_002000020001+P_010102010*QR_002000020010+P_010102110*QR_002000020011+P_010202010*QR_002000020020+P_010202110*QR_002000020021+P_110002010*QR_002000020100+P_110002110*QR_002000020101+P_110102010*QR_002000020110+P_110102110*QR_002000020111+P_110202010*QR_002000020120+P_110202110*QR_002000020121); ans_temp[ans_id*36+23]+=Pmtrx[13]*(P_010002010*QR_001001020000+P_010002110*QR_001001020001+P_010102010*QR_001001020010+P_010102110*QR_001001020011+P_010202010*QR_001001020020+P_010202110*QR_001001020021+P_110002010*QR_001001020100+P_110002110*QR_001001020101+P_110102010*QR_001001020110+P_110102110*QR_001001020111+P_110202010*QR_001001020120+P_110202110*QR_001001020121); ans_temp[ans_id*36+23]+=Pmtrx[14]*(P_010002010*QR_000002020000+P_010002110*QR_000002020001+P_010102010*QR_000002020010+P_010102110*QR_000002020011+P_010202010*QR_000002020020+P_010202110*QR_000002020021+P_110002010*QR_000002020100+P_110002110*QR_000002020101+P_110102010*QR_000002020110+P_110102110*QR_000002020111+P_110202010*QR_000002020120+P_110202110*QR_000002020121); ans_temp[ans_id*36+23]+=Pmtrx[15]*(P_010002010*QR_001000021000+P_010002110*QR_001000021001+P_010102010*QR_001000021010+P_010102110*QR_001000021011+P_010202010*QR_001000021020+P_010202110*QR_001000021021+P_110002010*QR_001000021100+P_110002110*QR_001000021101+P_110102010*QR_001000021110+P_110102110*QR_001000021111+P_110202010*QR_001000021120+P_110202110*QR_001000021121); ans_temp[ans_id*36+23]+=Pmtrx[16]*(P_010002010*QR_000001021000+P_010002110*QR_000001021001+P_010102010*QR_000001021010+P_010102110*QR_000001021011+P_010202010*QR_000001021020+P_010202110*QR_000001021021+P_110002010*QR_000001021100+P_110002110*QR_000001021101+P_110102010*QR_000001021110+P_110102110*QR_000001021111+P_110202010*QR_000001021120+P_110202110*QR_000001021121); ans_temp[ans_id*36+23]+=Pmtrx[17]*(P_010002010*QR_000000022000+P_010002110*QR_000000022001+P_010102010*QR_000000022010+P_010102110*QR_000000022011+P_010202010*QR_000000022020+P_010202110*QR_000000022021+P_110002010*QR_000000022100+P_110002110*QR_000000022101+P_110102010*QR_000000022110+P_110102110*QR_000000022111+P_110202010*QR_000000022120+P_110202110*QR_000000022121); ans_temp[ans_id*36+18]+=Pmtrx[18]*(P_011000011*QR_022000000000+P_011000111*QR_022000000001+P_011000211*QR_022000000002+P_111000011*QR_022000000100+P_111000111*QR_022000000101+P_111000211*QR_022000000102+P_211000011*QR_022000000200+P_211000111*QR_022000000201+P_211000211*QR_022000000202); ans_temp[ans_id*36+18]+=Pmtrx[19]*(P_011000011*QR_021001000000+P_011000111*QR_021001000001+P_011000211*QR_021001000002+P_111000011*QR_021001000100+P_111000111*QR_021001000101+P_111000211*QR_021001000102+P_211000011*QR_021001000200+P_211000111*QR_021001000201+P_211000211*QR_021001000202); ans_temp[ans_id*36+18]+=Pmtrx[20]*(P_011000011*QR_020002000000+P_011000111*QR_020002000001+P_011000211*QR_020002000002+P_111000011*QR_020002000100+P_111000111*QR_020002000101+P_111000211*QR_020002000102+P_211000011*QR_020002000200+P_211000111*QR_020002000201+P_211000211*QR_020002000202); ans_temp[ans_id*36+18]+=Pmtrx[21]*(P_011000011*QR_021000001000+P_011000111*QR_021000001001+P_011000211*QR_021000001002+P_111000011*QR_021000001100+P_111000111*QR_021000001101+P_111000211*QR_021000001102+P_211000011*QR_021000001200+P_211000111*QR_021000001201+P_211000211*QR_021000001202); ans_temp[ans_id*36+18]+=Pmtrx[22]*(P_011000011*QR_020001001000+P_011000111*QR_020001001001+P_011000211*QR_020001001002+P_111000011*QR_020001001100+P_111000111*QR_020001001101+P_111000211*QR_020001001102+P_211000011*QR_020001001200+P_211000111*QR_020001001201+P_211000211*QR_020001001202); ans_temp[ans_id*36+18]+=Pmtrx[23]*(P_011000011*QR_020000002000+P_011000111*QR_020000002001+P_011000211*QR_020000002002+P_111000011*QR_020000002100+P_111000111*QR_020000002101+P_111000211*QR_020000002102+P_211000011*QR_020000002200+P_211000111*QR_020000002201+P_211000211*QR_020000002202); ans_temp[ans_id*36+19]+=Pmtrx[18]*(P_011000011*QR_012010000000+P_011000111*QR_012010000001+P_011000211*QR_012010000002+P_111000011*QR_012010000100+P_111000111*QR_012010000101+P_111000211*QR_012010000102+P_211000011*QR_012010000200+P_211000111*QR_012010000201+P_211000211*QR_012010000202); ans_temp[ans_id*36+19]+=Pmtrx[19]*(P_011000011*QR_011011000000+P_011000111*QR_011011000001+P_011000211*QR_011011000002+P_111000011*QR_011011000100+P_111000111*QR_011011000101+P_111000211*QR_011011000102+P_211000011*QR_011011000200+P_211000111*QR_011011000201+P_211000211*QR_011011000202); ans_temp[ans_id*36+19]+=Pmtrx[20]*(P_011000011*QR_010012000000+P_011000111*QR_010012000001+P_011000211*QR_010012000002+P_111000011*QR_010012000100+P_111000111*QR_010012000101+P_111000211*QR_010012000102+P_211000011*QR_010012000200+P_211000111*QR_010012000201+P_211000211*QR_010012000202); ans_temp[ans_id*36+19]+=Pmtrx[21]*(P_011000011*QR_011010001000+P_011000111*QR_011010001001+P_011000211*QR_011010001002+P_111000011*QR_011010001100+P_111000111*QR_011010001101+P_111000211*QR_011010001102+P_211000011*QR_011010001200+P_211000111*QR_011010001201+P_211000211*QR_011010001202); ans_temp[ans_id*36+19]+=Pmtrx[22]*(P_011000011*QR_010011001000+P_011000111*QR_010011001001+P_011000211*QR_010011001002+P_111000011*QR_010011001100+P_111000111*QR_010011001101+P_111000211*QR_010011001102+P_211000011*QR_010011001200+P_211000111*QR_010011001201+P_211000211*QR_010011001202); ans_temp[ans_id*36+19]+=Pmtrx[23]*(P_011000011*QR_010010002000+P_011000111*QR_010010002001+P_011000211*QR_010010002002+P_111000011*QR_010010002100+P_111000111*QR_010010002101+P_111000211*QR_010010002102+P_211000011*QR_010010002200+P_211000111*QR_010010002201+P_211000211*QR_010010002202); ans_temp[ans_id*36+20]+=Pmtrx[18]*(P_011000011*QR_002020000000+P_011000111*QR_002020000001+P_011000211*QR_002020000002+P_111000011*QR_002020000100+P_111000111*QR_002020000101+P_111000211*QR_002020000102+P_211000011*QR_002020000200+P_211000111*QR_002020000201+P_211000211*QR_002020000202); ans_temp[ans_id*36+20]+=Pmtrx[19]*(P_011000011*QR_001021000000+P_011000111*QR_001021000001+P_011000211*QR_001021000002+P_111000011*QR_001021000100+P_111000111*QR_001021000101+P_111000211*QR_001021000102+P_211000011*QR_001021000200+P_211000111*QR_001021000201+P_211000211*QR_001021000202); ans_temp[ans_id*36+20]+=Pmtrx[20]*(P_011000011*QR_000022000000+P_011000111*QR_000022000001+P_011000211*QR_000022000002+P_111000011*QR_000022000100+P_111000111*QR_000022000101+P_111000211*QR_000022000102+P_211000011*QR_000022000200+P_211000111*QR_000022000201+P_211000211*QR_000022000202); ans_temp[ans_id*36+20]+=Pmtrx[21]*(P_011000011*QR_001020001000+P_011000111*QR_001020001001+P_011000211*QR_001020001002+P_111000011*QR_001020001100+P_111000111*QR_001020001101+P_111000211*QR_001020001102+P_211000011*QR_001020001200+P_211000111*QR_001020001201+P_211000211*QR_001020001202); ans_temp[ans_id*36+20]+=Pmtrx[22]*(P_011000011*QR_000021001000+P_011000111*QR_000021001001+P_011000211*QR_000021001002+P_111000011*QR_000021001100+P_111000111*QR_000021001101+P_111000211*QR_000021001102+P_211000011*QR_000021001200+P_211000111*QR_000021001201+P_211000211*QR_000021001202); ans_temp[ans_id*36+20]+=Pmtrx[23]*(P_011000011*QR_000020002000+P_011000111*QR_000020002001+P_011000211*QR_000020002002+P_111000011*QR_000020002100+P_111000111*QR_000020002101+P_111000211*QR_000020002102+P_211000011*QR_000020002200+P_211000111*QR_000020002201+P_211000211*QR_000020002202); ans_temp[ans_id*36+21]+=Pmtrx[18]*(P_011000011*QR_012000010000+P_011000111*QR_012000010001+P_011000211*QR_012000010002+P_111000011*QR_012000010100+P_111000111*QR_012000010101+P_111000211*QR_012000010102+P_211000011*QR_012000010200+P_211000111*QR_012000010201+P_211000211*QR_012000010202); ans_temp[ans_id*36+21]+=Pmtrx[19]*(P_011000011*QR_011001010000+P_011000111*QR_011001010001+P_011000211*QR_011001010002+P_111000011*QR_011001010100+P_111000111*QR_011001010101+P_111000211*QR_011001010102+P_211000011*QR_011001010200+P_211000111*QR_011001010201+P_211000211*QR_011001010202); ans_temp[ans_id*36+21]+=Pmtrx[20]*(P_011000011*QR_010002010000+P_011000111*QR_010002010001+P_011000211*QR_010002010002+P_111000011*QR_010002010100+P_111000111*QR_010002010101+P_111000211*QR_010002010102+P_211000011*QR_010002010200+P_211000111*QR_010002010201+P_211000211*QR_010002010202); ans_temp[ans_id*36+21]+=Pmtrx[21]*(P_011000011*QR_011000011000+P_011000111*QR_011000011001+P_011000211*QR_011000011002+P_111000011*QR_011000011100+P_111000111*QR_011000011101+P_111000211*QR_011000011102+P_211000011*QR_011000011200+P_211000111*QR_011000011201+P_211000211*QR_011000011202); ans_temp[ans_id*36+21]+=Pmtrx[22]*(P_011000011*QR_010001011000+P_011000111*QR_010001011001+P_011000211*QR_010001011002+P_111000011*QR_010001011100+P_111000111*QR_010001011101+P_111000211*QR_010001011102+P_211000011*QR_010001011200+P_211000111*QR_010001011201+P_211000211*QR_010001011202); ans_temp[ans_id*36+21]+=Pmtrx[23]*(P_011000011*QR_010000012000+P_011000111*QR_010000012001+P_011000211*QR_010000012002+P_111000011*QR_010000012100+P_111000111*QR_010000012101+P_111000211*QR_010000012102+P_211000011*QR_010000012200+P_211000111*QR_010000012201+P_211000211*QR_010000012202); ans_temp[ans_id*36+22]+=Pmtrx[18]*(P_011000011*QR_002010010000+P_011000111*QR_002010010001+P_011000211*QR_002010010002+P_111000011*QR_002010010100+P_111000111*QR_002010010101+P_111000211*QR_002010010102+P_211000011*QR_002010010200+P_211000111*QR_002010010201+P_211000211*QR_002010010202); ans_temp[ans_id*36+22]+=Pmtrx[19]*(P_011000011*QR_001011010000+P_011000111*QR_001011010001+P_011000211*QR_001011010002+P_111000011*QR_001011010100+P_111000111*QR_001011010101+P_111000211*QR_001011010102+P_211000011*QR_001011010200+P_211000111*QR_001011010201+P_211000211*QR_001011010202); ans_temp[ans_id*36+22]+=Pmtrx[20]*(P_011000011*QR_000012010000+P_011000111*QR_000012010001+P_011000211*QR_000012010002+P_111000011*QR_000012010100+P_111000111*QR_000012010101+P_111000211*QR_000012010102+P_211000011*QR_000012010200+P_211000111*QR_000012010201+P_211000211*QR_000012010202); ans_temp[ans_id*36+22]+=Pmtrx[21]*(P_011000011*QR_001010011000+P_011000111*QR_001010011001+P_011000211*QR_001010011002+P_111000011*QR_001010011100+P_111000111*QR_001010011101+P_111000211*QR_001010011102+P_211000011*QR_001010011200+P_211000111*QR_001010011201+P_211000211*QR_001010011202); ans_temp[ans_id*36+22]+=Pmtrx[22]*(P_011000011*QR_000011011000+P_011000111*QR_000011011001+P_011000211*QR_000011011002+P_111000011*QR_000011011100+P_111000111*QR_000011011101+P_111000211*QR_000011011102+P_211000011*QR_000011011200+P_211000111*QR_000011011201+P_211000211*QR_000011011202); ans_temp[ans_id*36+22]+=Pmtrx[23]*(P_011000011*QR_000010012000+P_011000111*QR_000010012001+P_011000211*QR_000010012002+P_111000011*QR_000010012100+P_111000111*QR_000010012101+P_111000211*QR_000010012102+P_211000011*QR_000010012200+P_211000111*QR_000010012201+P_211000211*QR_000010012202); ans_temp[ans_id*36+23]+=Pmtrx[18]*(P_011000011*QR_002000020000+P_011000111*QR_002000020001+P_011000211*QR_002000020002+P_111000011*QR_002000020100+P_111000111*QR_002000020101+P_111000211*QR_002000020102+P_211000011*QR_002000020200+P_211000111*QR_002000020201+P_211000211*QR_002000020202); ans_temp[ans_id*36+23]+=Pmtrx[19]*(P_011000011*QR_001001020000+P_011000111*QR_001001020001+P_011000211*QR_001001020002+P_111000011*QR_001001020100+P_111000111*QR_001001020101+P_111000211*QR_001001020102+P_211000011*QR_001001020200+P_211000111*QR_001001020201+P_211000211*QR_001001020202); ans_temp[ans_id*36+23]+=Pmtrx[20]*(P_011000011*QR_000002020000+P_011000111*QR_000002020001+P_011000211*QR_000002020002+P_111000011*QR_000002020100+P_111000111*QR_000002020101+P_111000211*QR_000002020102+P_211000011*QR_000002020200+P_211000111*QR_000002020201+P_211000211*QR_000002020202); ans_temp[ans_id*36+23]+=Pmtrx[21]*(P_011000011*QR_001000021000+P_011000111*QR_001000021001+P_011000211*QR_001000021002+P_111000011*QR_001000021100+P_111000111*QR_001000021101+P_111000211*QR_001000021102+P_211000011*QR_001000021200+P_211000111*QR_001000021201+P_211000211*QR_001000021202); ans_temp[ans_id*36+23]+=Pmtrx[22]*(P_011000011*QR_000001021000+P_011000111*QR_000001021001+P_011000211*QR_000001021002+P_111000011*QR_000001021100+P_111000111*QR_000001021101+P_111000211*QR_000001021102+P_211000011*QR_000001021200+P_211000111*QR_000001021201+P_211000211*QR_000001021202); ans_temp[ans_id*36+23]+=Pmtrx[23]*(P_011000011*QR_000000022000+P_011000111*QR_000000022001+P_011000211*QR_000000022002+P_111000011*QR_000000022100+P_111000111*QR_000000022101+P_111000211*QR_000000022102+P_211000011*QR_000000022200+P_211000111*QR_000000022201+P_211000211*QR_000000022202); ans_temp[ans_id*36+18]+=Pmtrx[24]*(P_010001011*QR_022000000000+P_010001111*QR_022000000001+P_010001211*QR_022000000002+P_010101011*QR_022000000010+P_010101111*QR_022000000011+P_010101211*QR_022000000012+P_110001011*QR_022000000100+P_110001111*QR_022000000101+P_110001211*QR_022000000102+P_110101011*QR_022000000110+P_110101111*QR_022000000111+P_110101211*QR_022000000112); ans_temp[ans_id*36+18]+=Pmtrx[25]*(P_010001011*QR_021001000000+P_010001111*QR_021001000001+P_010001211*QR_021001000002+P_010101011*QR_021001000010+P_010101111*QR_021001000011+P_010101211*QR_021001000012+P_110001011*QR_021001000100+P_110001111*QR_021001000101+P_110001211*QR_021001000102+P_110101011*QR_021001000110+P_110101111*QR_021001000111+P_110101211*QR_021001000112); ans_temp[ans_id*36+18]+=Pmtrx[26]*(P_010001011*QR_020002000000+P_010001111*QR_020002000001+P_010001211*QR_020002000002+P_010101011*QR_020002000010+P_010101111*QR_020002000011+P_010101211*QR_020002000012+P_110001011*QR_020002000100+P_110001111*QR_020002000101+P_110001211*QR_020002000102+P_110101011*QR_020002000110+P_110101111*QR_020002000111+P_110101211*QR_020002000112); ans_temp[ans_id*36+18]+=Pmtrx[27]*(P_010001011*QR_021000001000+P_010001111*QR_021000001001+P_010001211*QR_021000001002+P_010101011*QR_021000001010+P_010101111*QR_021000001011+P_010101211*QR_021000001012+P_110001011*QR_021000001100+P_110001111*QR_021000001101+P_110001211*QR_021000001102+P_110101011*QR_021000001110+P_110101111*QR_021000001111+P_110101211*QR_021000001112); ans_temp[ans_id*36+18]+=Pmtrx[28]*(P_010001011*QR_020001001000+P_010001111*QR_020001001001+P_010001211*QR_020001001002+P_010101011*QR_020001001010+P_010101111*QR_020001001011+P_010101211*QR_020001001012+P_110001011*QR_020001001100+P_110001111*QR_020001001101+P_110001211*QR_020001001102+P_110101011*QR_020001001110+P_110101111*QR_020001001111+P_110101211*QR_020001001112); ans_temp[ans_id*36+18]+=Pmtrx[29]*(P_010001011*QR_020000002000+P_010001111*QR_020000002001+P_010001211*QR_020000002002+P_010101011*QR_020000002010+P_010101111*QR_020000002011+P_010101211*QR_020000002012+P_110001011*QR_020000002100+P_110001111*QR_020000002101+P_110001211*QR_020000002102+P_110101011*QR_020000002110+P_110101111*QR_020000002111+P_110101211*QR_020000002112); ans_temp[ans_id*36+19]+=Pmtrx[24]*(P_010001011*QR_012010000000+P_010001111*QR_012010000001+P_010001211*QR_012010000002+P_010101011*QR_012010000010+P_010101111*QR_012010000011+P_010101211*QR_012010000012+P_110001011*QR_012010000100+P_110001111*QR_012010000101+P_110001211*QR_012010000102+P_110101011*QR_012010000110+P_110101111*QR_012010000111+P_110101211*QR_012010000112); ans_temp[ans_id*36+19]+=Pmtrx[25]*(P_010001011*QR_011011000000+P_010001111*QR_011011000001+P_010001211*QR_011011000002+P_010101011*QR_011011000010+P_010101111*QR_011011000011+P_010101211*QR_011011000012+P_110001011*QR_011011000100+P_110001111*QR_011011000101+P_110001211*QR_011011000102+P_110101011*QR_011011000110+P_110101111*QR_011011000111+P_110101211*QR_011011000112); ans_temp[ans_id*36+19]+=Pmtrx[26]*(P_010001011*QR_010012000000+P_010001111*QR_010012000001+P_010001211*QR_010012000002+P_010101011*QR_010012000010+P_010101111*QR_010012000011+P_010101211*QR_010012000012+P_110001011*QR_010012000100+P_110001111*QR_010012000101+P_110001211*QR_010012000102+P_110101011*QR_010012000110+P_110101111*QR_010012000111+P_110101211*QR_010012000112); ans_temp[ans_id*36+19]+=Pmtrx[27]*(P_010001011*QR_011010001000+P_010001111*QR_011010001001+P_010001211*QR_011010001002+P_010101011*QR_011010001010+P_010101111*QR_011010001011+P_010101211*QR_011010001012+P_110001011*QR_011010001100+P_110001111*QR_011010001101+P_110001211*QR_011010001102+P_110101011*QR_011010001110+P_110101111*QR_011010001111+P_110101211*QR_011010001112); ans_temp[ans_id*36+19]+=Pmtrx[28]*(P_010001011*QR_010011001000+P_010001111*QR_010011001001+P_010001211*QR_010011001002+P_010101011*QR_010011001010+P_010101111*QR_010011001011+P_010101211*QR_010011001012+P_110001011*QR_010011001100+P_110001111*QR_010011001101+P_110001211*QR_010011001102+P_110101011*QR_010011001110+P_110101111*QR_010011001111+P_110101211*QR_010011001112); ans_temp[ans_id*36+19]+=Pmtrx[29]*(P_010001011*QR_010010002000+P_010001111*QR_010010002001+P_010001211*QR_010010002002+P_010101011*QR_010010002010+P_010101111*QR_010010002011+P_010101211*QR_010010002012+P_110001011*QR_010010002100+P_110001111*QR_010010002101+P_110001211*QR_010010002102+P_110101011*QR_010010002110+P_110101111*QR_010010002111+P_110101211*QR_010010002112); ans_temp[ans_id*36+20]+=Pmtrx[24]*(P_010001011*QR_002020000000+P_010001111*QR_002020000001+P_010001211*QR_002020000002+P_010101011*QR_002020000010+P_010101111*QR_002020000011+P_010101211*QR_002020000012+P_110001011*QR_002020000100+P_110001111*QR_002020000101+P_110001211*QR_002020000102+P_110101011*QR_002020000110+P_110101111*QR_002020000111+P_110101211*QR_002020000112); ans_temp[ans_id*36+20]+=Pmtrx[25]*(P_010001011*QR_001021000000+P_010001111*QR_001021000001+P_010001211*QR_001021000002+P_010101011*QR_001021000010+P_010101111*QR_001021000011+P_010101211*QR_001021000012+P_110001011*QR_001021000100+P_110001111*QR_001021000101+P_110001211*QR_001021000102+P_110101011*QR_001021000110+P_110101111*QR_001021000111+P_110101211*QR_001021000112); ans_temp[ans_id*36+20]+=Pmtrx[26]*(P_010001011*QR_000022000000+P_010001111*QR_000022000001+P_010001211*QR_000022000002+P_010101011*QR_000022000010+P_010101111*QR_000022000011+P_010101211*QR_000022000012+P_110001011*QR_000022000100+P_110001111*QR_000022000101+P_110001211*QR_000022000102+P_110101011*QR_000022000110+P_110101111*QR_000022000111+P_110101211*QR_000022000112); ans_temp[ans_id*36+20]+=Pmtrx[27]*(P_010001011*QR_001020001000+P_010001111*QR_001020001001+P_010001211*QR_001020001002+P_010101011*QR_001020001010+P_010101111*QR_001020001011+P_010101211*QR_001020001012+P_110001011*QR_001020001100+P_110001111*QR_001020001101+P_110001211*QR_001020001102+P_110101011*QR_001020001110+P_110101111*QR_001020001111+P_110101211*QR_001020001112); ans_temp[ans_id*36+20]+=Pmtrx[28]*(P_010001011*QR_000021001000+P_010001111*QR_000021001001+P_010001211*QR_000021001002+P_010101011*QR_000021001010+P_010101111*QR_000021001011+P_010101211*QR_000021001012+P_110001011*QR_000021001100+P_110001111*QR_000021001101+P_110001211*QR_000021001102+P_110101011*QR_000021001110+P_110101111*QR_000021001111+P_110101211*QR_000021001112); ans_temp[ans_id*36+20]+=Pmtrx[29]*(P_010001011*QR_000020002000+P_010001111*QR_000020002001+P_010001211*QR_000020002002+P_010101011*QR_000020002010+P_010101111*QR_000020002011+P_010101211*QR_000020002012+P_110001011*QR_000020002100+P_110001111*QR_000020002101+P_110001211*QR_000020002102+P_110101011*QR_000020002110+P_110101111*QR_000020002111+P_110101211*QR_000020002112); ans_temp[ans_id*36+21]+=Pmtrx[24]*(P_010001011*QR_012000010000+P_010001111*QR_012000010001+P_010001211*QR_012000010002+P_010101011*QR_012000010010+P_010101111*QR_012000010011+P_010101211*QR_012000010012+P_110001011*QR_012000010100+P_110001111*QR_012000010101+P_110001211*QR_012000010102+P_110101011*QR_012000010110+P_110101111*QR_012000010111+P_110101211*QR_012000010112); ans_temp[ans_id*36+21]+=Pmtrx[25]*(P_010001011*QR_011001010000+P_010001111*QR_011001010001+P_010001211*QR_011001010002+P_010101011*QR_011001010010+P_010101111*QR_011001010011+P_010101211*QR_011001010012+P_110001011*QR_011001010100+P_110001111*QR_011001010101+P_110001211*QR_011001010102+P_110101011*QR_011001010110+P_110101111*QR_011001010111+P_110101211*QR_011001010112); ans_temp[ans_id*36+21]+=Pmtrx[26]*(P_010001011*QR_010002010000+P_010001111*QR_010002010001+P_010001211*QR_010002010002+P_010101011*QR_010002010010+P_010101111*QR_010002010011+P_010101211*QR_010002010012+P_110001011*QR_010002010100+P_110001111*QR_010002010101+P_110001211*QR_010002010102+P_110101011*QR_010002010110+P_110101111*QR_010002010111+P_110101211*QR_010002010112); ans_temp[ans_id*36+21]+=Pmtrx[27]*(P_010001011*QR_011000011000+P_010001111*QR_011000011001+P_010001211*QR_011000011002+P_010101011*QR_011000011010+P_010101111*QR_011000011011+P_010101211*QR_011000011012+P_110001011*QR_011000011100+P_110001111*QR_011000011101+P_110001211*QR_011000011102+P_110101011*QR_011000011110+P_110101111*QR_011000011111+P_110101211*QR_011000011112); ans_temp[ans_id*36+21]+=Pmtrx[28]*(P_010001011*QR_010001011000+P_010001111*QR_010001011001+P_010001211*QR_010001011002+P_010101011*QR_010001011010+P_010101111*QR_010001011011+P_010101211*QR_010001011012+P_110001011*QR_010001011100+P_110001111*QR_010001011101+P_110001211*QR_010001011102+P_110101011*QR_010001011110+P_110101111*QR_010001011111+P_110101211*QR_010001011112); ans_temp[ans_id*36+21]+=Pmtrx[29]*(P_010001011*QR_010000012000+P_010001111*QR_010000012001+P_010001211*QR_010000012002+P_010101011*QR_010000012010+P_010101111*QR_010000012011+P_010101211*QR_010000012012+P_110001011*QR_010000012100+P_110001111*QR_010000012101+P_110001211*QR_010000012102+P_110101011*QR_010000012110+P_110101111*QR_010000012111+P_110101211*QR_010000012112); ans_temp[ans_id*36+22]+=Pmtrx[24]*(P_010001011*QR_002010010000+P_010001111*QR_002010010001+P_010001211*QR_002010010002+P_010101011*QR_002010010010+P_010101111*QR_002010010011+P_010101211*QR_002010010012+P_110001011*QR_002010010100+P_110001111*QR_002010010101+P_110001211*QR_002010010102+P_110101011*QR_002010010110+P_110101111*QR_002010010111+P_110101211*QR_002010010112); ans_temp[ans_id*36+22]+=Pmtrx[25]*(P_010001011*QR_001011010000+P_010001111*QR_001011010001+P_010001211*QR_001011010002+P_010101011*QR_001011010010+P_010101111*QR_001011010011+P_010101211*QR_001011010012+P_110001011*QR_001011010100+P_110001111*QR_001011010101+P_110001211*QR_001011010102+P_110101011*QR_001011010110+P_110101111*QR_001011010111+P_110101211*QR_001011010112); ans_temp[ans_id*36+22]+=Pmtrx[26]*(P_010001011*QR_000012010000+P_010001111*QR_000012010001+P_010001211*QR_000012010002+P_010101011*QR_000012010010+P_010101111*QR_000012010011+P_010101211*QR_000012010012+P_110001011*QR_000012010100+P_110001111*QR_000012010101+P_110001211*QR_000012010102+P_110101011*QR_000012010110+P_110101111*QR_000012010111+P_110101211*QR_000012010112); ans_temp[ans_id*36+22]+=Pmtrx[27]*(P_010001011*QR_001010011000+P_010001111*QR_001010011001+P_010001211*QR_001010011002+P_010101011*QR_001010011010+P_010101111*QR_001010011011+P_010101211*QR_001010011012+P_110001011*QR_001010011100+P_110001111*QR_001010011101+P_110001211*QR_001010011102+P_110101011*QR_001010011110+P_110101111*QR_001010011111+P_110101211*QR_001010011112); ans_temp[ans_id*36+22]+=Pmtrx[28]*(P_010001011*QR_000011011000+P_010001111*QR_000011011001+P_010001211*QR_000011011002+P_010101011*QR_000011011010+P_010101111*QR_000011011011+P_010101211*QR_000011011012+P_110001011*QR_000011011100+P_110001111*QR_000011011101+P_110001211*QR_000011011102+P_110101011*QR_000011011110+P_110101111*QR_000011011111+P_110101211*QR_000011011112); ans_temp[ans_id*36+22]+=Pmtrx[29]*(P_010001011*QR_000010012000+P_010001111*QR_000010012001+P_010001211*QR_000010012002+P_010101011*QR_000010012010+P_010101111*QR_000010012011+P_010101211*QR_000010012012+P_110001011*QR_000010012100+P_110001111*QR_000010012101+P_110001211*QR_000010012102+P_110101011*QR_000010012110+P_110101111*QR_000010012111+P_110101211*QR_000010012112); ans_temp[ans_id*36+23]+=Pmtrx[24]*(P_010001011*QR_002000020000+P_010001111*QR_002000020001+P_010001211*QR_002000020002+P_010101011*QR_002000020010+P_010101111*QR_002000020011+P_010101211*QR_002000020012+P_110001011*QR_002000020100+P_110001111*QR_002000020101+P_110001211*QR_002000020102+P_110101011*QR_002000020110+P_110101111*QR_002000020111+P_110101211*QR_002000020112); ans_temp[ans_id*36+23]+=Pmtrx[25]*(P_010001011*QR_001001020000+P_010001111*QR_001001020001+P_010001211*QR_001001020002+P_010101011*QR_001001020010+P_010101111*QR_001001020011+P_010101211*QR_001001020012+P_110001011*QR_001001020100+P_110001111*QR_001001020101+P_110001211*QR_001001020102+P_110101011*QR_001001020110+P_110101111*QR_001001020111+P_110101211*QR_001001020112); ans_temp[ans_id*36+23]+=Pmtrx[26]*(P_010001011*QR_000002020000+P_010001111*QR_000002020001+P_010001211*QR_000002020002+P_010101011*QR_000002020010+P_010101111*QR_000002020011+P_010101211*QR_000002020012+P_110001011*QR_000002020100+P_110001111*QR_000002020101+P_110001211*QR_000002020102+P_110101011*QR_000002020110+P_110101111*QR_000002020111+P_110101211*QR_000002020112); ans_temp[ans_id*36+23]+=Pmtrx[27]*(P_010001011*QR_001000021000+P_010001111*QR_001000021001+P_010001211*QR_001000021002+P_010101011*QR_001000021010+P_010101111*QR_001000021011+P_010101211*QR_001000021012+P_110001011*QR_001000021100+P_110001111*QR_001000021101+P_110001211*QR_001000021102+P_110101011*QR_001000021110+P_110101111*QR_001000021111+P_110101211*QR_001000021112); ans_temp[ans_id*36+23]+=Pmtrx[28]*(P_010001011*QR_000001021000+P_010001111*QR_000001021001+P_010001211*QR_000001021002+P_010101011*QR_000001021010+P_010101111*QR_000001021011+P_010101211*QR_000001021012+P_110001011*QR_000001021100+P_110001111*QR_000001021101+P_110001211*QR_000001021102+P_110101011*QR_000001021110+P_110101111*QR_000001021111+P_110101211*QR_000001021112); ans_temp[ans_id*36+23]+=Pmtrx[29]*(P_010001011*QR_000000022000+P_010001111*QR_000000022001+P_010001211*QR_000000022002+P_010101011*QR_000000022010+P_010101111*QR_000000022011+P_010101211*QR_000000022012+P_110001011*QR_000000022100+P_110001111*QR_000000022101+P_110001211*QR_000000022102+P_110101011*QR_000000022110+P_110101111*QR_000000022111+P_110101211*QR_000000022112); ans_temp[ans_id*36+18]+=Pmtrx[30]*(P_010000012*QR_022000000000+P_010000112*QR_022000000001+P_010000212*QR_022000000002+P_010000312*QR_022000000003+P_110000012*QR_022000000100+P_110000112*QR_022000000101+P_110000212*QR_022000000102+P_110000312*QR_022000000103); ans_temp[ans_id*36+18]+=Pmtrx[31]*(P_010000012*QR_021001000000+P_010000112*QR_021001000001+P_010000212*QR_021001000002+P_010000312*QR_021001000003+P_110000012*QR_021001000100+P_110000112*QR_021001000101+P_110000212*QR_021001000102+P_110000312*QR_021001000103); ans_temp[ans_id*36+18]+=Pmtrx[32]*(P_010000012*QR_020002000000+P_010000112*QR_020002000001+P_010000212*QR_020002000002+P_010000312*QR_020002000003+P_110000012*QR_020002000100+P_110000112*QR_020002000101+P_110000212*QR_020002000102+P_110000312*QR_020002000103); ans_temp[ans_id*36+18]+=Pmtrx[33]*(P_010000012*QR_021000001000+P_010000112*QR_021000001001+P_010000212*QR_021000001002+P_010000312*QR_021000001003+P_110000012*QR_021000001100+P_110000112*QR_021000001101+P_110000212*QR_021000001102+P_110000312*QR_021000001103); ans_temp[ans_id*36+18]+=Pmtrx[34]*(P_010000012*QR_020001001000+P_010000112*QR_020001001001+P_010000212*QR_020001001002+P_010000312*QR_020001001003+P_110000012*QR_020001001100+P_110000112*QR_020001001101+P_110000212*QR_020001001102+P_110000312*QR_020001001103); ans_temp[ans_id*36+18]+=Pmtrx[35]*(P_010000012*QR_020000002000+P_010000112*QR_020000002001+P_010000212*QR_020000002002+P_010000312*QR_020000002003+P_110000012*QR_020000002100+P_110000112*QR_020000002101+P_110000212*QR_020000002102+P_110000312*QR_020000002103); ans_temp[ans_id*36+19]+=Pmtrx[30]*(P_010000012*QR_012010000000+P_010000112*QR_012010000001+P_010000212*QR_012010000002+P_010000312*QR_012010000003+P_110000012*QR_012010000100+P_110000112*QR_012010000101+P_110000212*QR_012010000102+P_110000312*QR_012010000103); ans_temp[ans_id*36+19]+=Pmtrx[31]*(P_010000012*QR_011011000000+P_010000112*QR_011011000001+P_010000212*QR_011011000002+P_010000312*QR_011011000003+P_110000012*QR_011011000100+P_110000112*QR_011011000101+P_110000212*QR_011011000102+P_110000312*QR_011011000103); ans_temp[ans_id*36+19]+=Pmtrx[32]*(P_010000012*QR_010012000000+P_010000112*QR_010012000001+P_010000212*QR_010012000002+P_010000312*QR_010012000003+P_110000012*QR_010012000100+P_110000112*QR_010012000101+P_110000212*QR_010012000102+P_110000312*QR_010012000103); ans_temp[ans_id*36+19]+=Pmtrx[33]*(P_010000012*QR_011010001000+P_010000112*QR_011010001001+P_010000212*QR_011010001002+P_010000312*QR_011010001003+P_110000012*QR_011010001100+P_110000112*QR_011010001101+P_110000212*QR_011010001102+P_110000312*QR_011010001103); ans_temp[ans_id*36+19]+=Pmtrx[34]*(P_010000012*QR_010011001000+P_010000112*QR_010011001001+P_010000212*QR_010011001002+P_010000312*QR_010011001003+P_110000012*QR_010011001100+P_110000112*QR_010011001101+P_110000212*QR_010011001102+P_110000312*QR_010011001103); ans_temp[ans_id*36+19]+=Pmtrx[35]*(P_010000012*QR_010010002000+P_010000112*QR_010010002001+P_010000212*QR_010010002002+P_010000312*QR_010010002003+P_110000012*QR_010010002100+P_110000112*QR_010010002101+P_110000212*QR_010010002102+P_110000312*QR_010010002103); ans_temp[ans_id*36+20]+=Pmtrx[30]*(P_010000012*QR_002020000000+P_010000112*QR_002020000001+P_010000212*QR_002020000002+P_010000312*QR_002020000003+P_110000012*QR_002020000100+P_110000112*QR_002020000101+P_110000212*QR_002020000102+P_110000312*QR_002020000103); ans_temp[ans_id*36+20]+=Pmtrx[31]*(P_010000012*QR_001021000000+P_010000112*QR_001021000001+P_010000212*QR_001021000002+P_010000312*QR_001021000003+P_110000012*QR_001021000100+P_110000112*QR_001021000101+P_110000212*QR_001021000102+P_110000312*QR_001021000103); ans_temp[ans_id*36+20]+=Pmtrx[32]*(P_010000012*QR_000022000000+P_010000112*QR_000022000001+P_010000212*QR_000022000002+P_010000312*QR_000022000003+P_110000012*QR_000022000100+P_110000112*QR_000022000101+P_110000212*QR_000022000102+P_110000312*QR_000022000103); ans_temp[ans_id*36+20]+=Pmtrx[33]*(P_010000012*QR_001020001000+P_010000112*QR_001020001001+P_010000212*QR_001020001002+P_010000312*QR_001020001003+P_110000012*QR_001020001100+P_110000112*QR_001020001101+P_110000212*QR_001020001102+P_110000312*QR_001020001103); ans_temp[ans_id*36+20]+=Pmtrx[34]*(P_010000012*QR_000021001000+P_010000112*QR_000021001001+P_010000212*QR_000021001002+P_010000312*QR_000021001003+P_110000012*QR_000021001100+P_110000112*QR_000021001101+P_110000212*QR_000021001102+P_110000312*QR_000021001103); ans_temp[ans_id*36+20]+=Pmtrx[35]*(P_010000012*QR_000020002000+P_010000112*QR_000020002001+P_010000212*QR_000020002002+P_010000312*QR_000020002003+P_110000012*QR_000020002100+P_110000112*QR_000020002101+P_110000212*QR_000020002102+P_110000312*QR_000020002103); ans_temp[ans_id*36+21]+=Pmtrx[30]*(P_010000012*QR_012000010000+P_010000112*QR_012000010001+P_010000212*QR_012000010002+P_010000312*QR_012000010003+P_110000012*QR_012000010100+P_110000112*QR_012000010101+P_110000212*QR_012000010102+P_110000312*QR_012000010103); ans_temp[ans_id*36+21]+=Pmtrx[31]*(P_010000012*QR_011001010000+P_010000112*QR_011001010001+P_010000212*QR_011001010002+P_010000312*QR_011001010003+P_110000012*QR_011001010100+P_110000112*QR_011001010101+P_110000212*QR_011001010102+P_110000312*QR_011001010103); ans_temp[ans_id*36+21]+=Pmtrx[32]*(P_010000012*QR_010002010000+P_010000112*QR_010002010001+P_010000212*QR_010002010002+P_010000312*QR_010002010003+P_110000012*QR_010002010100+P_110000112*QR_010002010101+P_110000212*QR_010002010102+P_110000312*QR_010002010103); ans_temp[ans_id*36+21]+=Pmtrx[33]*(P_010000012*QR_011000011000+P_010000112*QR_011000011001+P_010000212*QR_011000011002+P_010000312*QR_011000011003+P_110000012*QR_011000011100+P_110000112*QR_011000011101+P_110000212*QR_011000011102+P_110000312*QR_011000011103); ans_temp[ans_id*36+21]+=Pmtrx[34]*(P_010000012*QR_010001011000+P_010000112*QR_010001011001+P_010000212*QR_010001011002+P_010000312*QR_010001011003+P_110000012*QR_010001011100+P_110000112*QR_010001011101+P_110000212*QR_010001011102+P_110000312*QR_010001011103); ans_temp[ans_id*36+21]+=Pmtrx[35]*(P_010000012*QR_010000012000+P_010000112*QR_010000012001+P_010000212*QR_010000012002+P_010000312*QR_010000012003+P_110000012*QR_010000012100+P_110000112*QR_010000012101+P_110000212*QR_010000012102+P_110000312*QR_010000012103); ans_temp[ans_id*36+22]+=Pmtrx[30]*(P_010000012*QR_002010010000+P_010000112*QR_002010010001+P_010000212*QR_002010010002+P_010000312*QR_002010010003+P_110000012*QR_002010010100+P_110000112*QR_002010010101+P_110000212*QR_002010010102+P_110000312*QR_002010010103); ans_temp[ans_id*36+22]+=Pmtrx[31]*(P_010000012*QR_001011010000+P_010000112*QR_001011010001+P_010000212*QR_001011010002+P_010000312*QR_001011010003+P_110000012*QR_001011010100+P_110000112*QR_001011010101+P_110000212*QR_001011010102+P_110000312*QR_001011010103); ans_temp[ans_id*36+22]+=Pmtrx[32]*(P_010000012*QR_000012010000+P_010000112*QR_000012010001+P_010000212*QR_000012010002+P_010000312*QR_000012010003+P_110000012*QR_000012010100+P_110000112*QR_000012010101+P_110000212*QR_000012010102+P_110000312*QR_000012010103); ans_temp[ans_id*36+22]+=Pmtrx[33]*(P_010000012*QR_001010011000+P_010000112*QR_001010011001+P_010000212*QR_001010011002+P_010000312*QR_001010011003+P_110000012*QR_001010011100+P_110000112*QR_001010011101+P_110000212*QR_001010011102+P_110000312*QR_001010011103); ans_temp[ans_id*36+22]+=Pmtrx[34]*(P_010000012*QR_000011011000+P_010000112*QR_000011011001+P_010000212*QR_000011011002+P_010000312*QR_000011011003+P_110000012*QR_000011011100+P_110000112*QR_000011011101+P_110000212*QR_000011011102+P_110000312*QR_000011011103); ans_temp[ans_id*36+22]+=Pmtrx[35]*(P_010000012*QR_000010012000+P_010000112*QR_000010012001+P_010000212*QR_000010012002+P_010000312*QR_000010012003+P_110000012*QR_000010012100+P_110000112*QR_000010012101+P_110000212*QR_000010012102+P_110000312*QR_000010012103); ans_temp[ans_id*36+23]+=Pmtrx[30]*(P_010000012*QR_002000020000+P_010000112*QR_002000020001+P_010000212*QR_002000020002+P_010000312*QR_002000020003+P_110000012*QR_002000020100+P_110000112*QR_002000020101+P_110000212*QR_002000020102+P_110000312*QR_002000020103); ans_temp[ans_id*36+23]+=Pmtrx[31]*(P_010000012*QR_001001020000+P_010000112*QR_001001020001+P_010000212*QR_001001020002+P_010000312*QR_001001020003+P_110000012*QR_001001020100+P_110000112*QR_001001020101+P_110000212*QR_001001020102+P_110000312*QR_001001020103); ans_temp[ans_id*36+23]+=Pmtrx[32]*(P_010000012*QR_000002020000+P_010000112*QR_000002020001+P_010000212*QR_000002020002+P_010000312*QR_000002020003+P_110000012*QR_000002020100+P_110000112*QR_000002020101+P_110000212*QR_000002020102+P_110000312*QR_000002020103); ans_temp[ans_id*36+23]+=Pmtrx[33]*(P_010000012*QR_001000021000+P_010000112*QR_001000021001+P_010000212*QR_001000021002+P_010000312*QR_001000021003+P_110000012*QR_001000021100+P_110000112*QR_001000021101+P_110000212*QR_001000021102+P_110000312*QR_001000021103); ans_temp[ans_id*36+23]+=Pmtrx[34]*(P_010000012*QR_000001021000+P_010000112*QR_000001021001+P_010000212*QR_000001021002+P_010000312*QR_000001021003+P_110000012*QR_000001021100+P_110000112*QR_000001021101+P_110000212*QR_000001021102+P_110000312*QR_000001021103); ans_temp[ans_id*36+23]+=Pmtrx[35]*(P_010000012*QR_000000022000+P_010000112*QR_000000022001+P_010000212*QR_000000022002+P_010000312*QR_000000022003+P_110000012*QR_000000022100+P_110000112*QR_000000022101+P_110000212*QR_000000022102+P_110000312*QR_000000022103); ans_temp[ans_id*36+24]+=Pmtrx[0]*(P_002010010*QR_022000000000+P_002010110*QR_022000000001+P_002110010*QR_022000000010+P_002110110*QR_022000000011+P_102010010*QR_022000000100+P_102010110*QR_022000000101+P_102110010*QR_022000000110+P_102110110*QR_022000000111+P_202010010*QR_022000000200+P_202010110*QR_022000000201+P_202110010*QR_022000000210+P_202110110*QR_022000000211); ans_temp[ans_id*36+24]+=Pmtrx[1]*(P_002010010*QR_021001000000+P_002010110*QR_021001000001+P_002110010*QR_021001000010+P_002110110*QR_021001000011+P_102010010*QR_021001000100+P_102010110*QR_021001000101+P_102110010*QR_021001000110+P_102110110*QR_021001000111+P_202010010*QR_021001000200+P_202010110*QR_021001000201+P_202110010*QR_021001000210+P_202110110*QR_021001000211); ans_temp[ans_id*36+24]+=Pmtrx[2]*(P_002010010*QR_020002000000+P_002010110*QR_020002000001+P_002110010*QR_020002000010+P_002110110*QR_020002000011+P_102010010*QR_020002000100+P_102010110*QR_020002000101+P_102110010*QR_020002000110+P_102110110*QR_020002000111+P_202010010*QR_020002000200+P_202010110*QR_020002000201+P_202110010*QR_020002000210+P_202110110*QR_020002000211); ans_temp[ans_id*36+24]+=Pmtrx[3]*(P_002010010*QR_021000001000+P_002010110*QR_021000001001+P_002110010*QR_021000001010+P_002110110*QR_021000001011+P_102010010*QR_021000001100+P_102010110*QR_021000001101+P_102110010*QR_021000001110+P_102110110*QR_021000001111+P_202010010*QR_021000001200+P_202010110*QR_021000001201+P_202110010*QR_021000001210+P_202110110*QR_021000001211); ans_temp[ans_id*36+24]+=Pmtrx[4]*(P_002010010*QR_020001001000+P_002010110*QR_020001001001+P_002110010*QR_020001001010+P_002110110*QR_020001001011+P_102010010*QR_020001001100+P_102010110*QR_020001001101+P_102110010*QR_020001001110+P_102110110*QR_020001001111+P_202010010*QR_020001001200+P_202010110*QR_020001001201+P_202110010*QR_020001001210+P_202110110*QR_020001001211); ans_temp[ans_id*36+24]+=Pmtrx[5]*(P_002010010*QR_020000002000+P_002010110*QR_020000002001+P_002110010*QR_020000002010+P_002110110*QR_020000002011+P_102010010*QR_020000002100+P_102010110*QR_020000002101+P_102110010*QR_020000002110+P_102110110*QR_020000002111+P_202010010*QR_020000002200+P_202010110*QR_020000002201+P_202110010*QR_020000002210+P_202110110*QR_020000002211); ans_temp[ans_id*36+25]+=Pmtrx[0]*(P_002010010*QR_012010000000+P_002010110*QR_012010000001+P_002110010*QR_012010000010+P_002110110*QR_012010000011+P_102010010*QR_012010000100+P_102010110*QR_012010000101+P_102110010*QR_012010000110+P_102110110*QR_012010000111+P_202010010*QR_012010000200+P_202010110*QR_012010000201+P_202110010*QR_012010000210+P_202110110*QR_012010000211); ans_temp[ans_id*36+25]+=Pmtrx[1]*(P_002010010*QR_011011000000+P_002010110*QR_011011000001+P_002110010*QR_011011000010+P_002110110*QR_011011000011+P_102010010*QR_011011000100+P_102010110*QR_011011000101+P_102110010*QR_011011000110+P_102110110*QR_011011000111+P_202010010*QR_011011000200+P_202010110*QR_011011000201+P_202110010*QR_011011000210+P_202110110*QR_011011000211); ans_temp[ans_id*36+25]+=Pmtrx[2]*(P_002010010*QR_010012000000+P_002010110*QR_010012000001+P_002110010*QR_010012000010+P_002110110*QR_010012000011+P_102010010*QR_010012000100+P_102010110*QR_010012000101+P_102110010*QR_010012000110+P_102110110*QR_010012000111+P_202010010*QR_010012000200+P_202010110*QR_010012000201+P_202110010*QR_010012000210+P_202110110*QR_010012000211); ans_temp[ans_id*36+25]+=Pmtrx[3]*(P_002010010*QR_011010001000+P_002010110*QR_011010001001+P_002110010*QR_011010001010+P_002110110*QR_011010001011+P_102010010*QR_011010001100+P_102010110*QR_011010001101+P_102110010*QR_011010001110+P_102110110*QR_011010001111+P_202010010*QR_011010001200+P_202010110*QR_011010001201+P_202110010*QR_011010001210+P_202110110*QR_011010001211); ans_temp[ans_id*36+25]+=Pmtrx[4]*(P_002010010*QR_010011001000+P_002010110*QR_010011001001+P_002110010*QR_010011001010+P_002110110*QR_010011001011+P_102010010*QR_010011001100+P_102010110*QR_010011001101+P_102110010*QR_010011001110+P_102110110*QR_010011001111+P_202010010*QR_010011001200+P_202010110*QR_010011001201+P_202110010*QR_010011001210+P_202110110*QR_010011001211); ans_temp[ans_id*36+25]+=Pmtrx[5]*(P_002010010*QR_010010002000+P_002010110*QR_010010002001+P_002110010*QR_010010002010+P_002110110*QR_010010002011+P_102010010*QR_010010002100+P_102010110*QR_010010002101+P_102110010*QR_010010002110+P_102110110*QR_010010002111+P_202010010*QR_010010002200+P_202010110*QR_010010002201+P_202110010*QR_010010002210+P_202110110*QR_010010002211); ans_temp[ans_id*36+26]+=Pmtrx[0]*(P_002010010*QR_002020000000+P_002010110*QR_002020000001+P_002110010*QR_002020000010+P_002110110*QR_002020000011+P_102010010*QR_002020000100+P_102010110*QR_002020000101+P_102110010*QR_002020000110+P_102110110*QR_002020000111+P_202010010*QR_002020000200+P_202010110*QR_002020000201+P_202110010*QR_002020000210+P_202110110*QR_002020000211); ans_temp[ans_id*36+26]+=Pmtrx[1]*(P_002010010*QR_001021000000+P_002010110*QR_001021000001+P_002110010*QR_001021000010+P_002110110*QR_001021000011+P_102010010*QR_001021000100+P_102010110*QR_001021000101+P_102110010*QR_001021000110+P_102110110*QR_001021000111+P_202010010*QR_001021000200+P_202010110*QR_001021000201+P_202110010*QR_001021000210+P_202110110*QR_001021000211); ans_temp[ans_id*36+26]+=Pmtrx[2]*(P_002010010*QR_000022000000+P_002010110*QR_000022000001+P_002110010*QR_000022000010+P_002110110*QR_000022000011+P_102010010*QR_000022000100+P_102010110*QR_000022000101+P_102110010*QR_000022000110+P_102110110*QR_000022000111+P_202010010*QR_000022000200+P_202010110*QR_000022000201+P_202110010*QR_000022000210+P_202110110*QR_000022000211); ans_temp[ans_id*36+26]+=Pmtrx[3]*(P_002010010*QR_001020001000+P_002010110*QR_001020001001+P_002110010*QR_001020001010+P_002110110*QR_001020001011+P_102010010*QR_001020001100+P_102010110*QR_001020001101+P_102110010*QR_001020001110+P_102110110*QR_001020001111+P_202010010*QR_001020001200+P_202010110*QR_001020001201+P_202110010*QR_001020001210+P_202110110*QR_001020001211); ans_temp[ans_id*36+26]+=Pmtrx[4]*(P_002010010*QR_000021001000+P_002010110*QR_000021001001+P_002110010*QR_000021001010+P_002110110*QR_000021001011+P_102010010*QR_000021001100+P_102010110*QR_000021001101+P_102110010*QR_000021001110+P_102110110*QR_000021001111+P_202010010*QR_000021001200+P_202010110*QR_000021001201+P_202110010*QR_000021001210+P_202110110*QR_000021001211); ans_temp[ans_id*36+26]+=Pmtrx[5]*(P_002010010*QR_000020002000+P_002010110*QR_000020002001+P_002110010*QR_000020002010+P_002110110*QR_000020002011+P_102010010*QR_000020002100+P_102010110*QR_000020002101+P_102110010*QR_000020002110+P_102110110*QR_000020002111+P_202010010*QR_000020002200+P_202010110*QR_000020002201+P_202110010*QR_000020002210+P_202110110*QR_000020002211); ans_temp[ans_id*36+27]+=Pmtrx[0]*(P_002010010*QR_012000010000+P_002010110*QR_012000010001+P_002110010*QR_012000010010+P_002110110*QR_012000010011+P_102010010*QR_012000010100+P_102010110*QR_012000010101+P_102110010*QR_012000010110+P_102110110*QR_012000010111+P_202010010*QR_012000010200+P_202010110*QR_012000010201+P_202110010*QR_012000010210+P_202110110*QR_012000010211); ans_temp[ans_id*36+27]+=Pmtrx[1]*(P_002010010*QR_011001010000+P_002010110*QR_011001010001+P_002110010*QR_011001010010+P_002110110*QR_011001010011+P_102010010*QR_011001010100+P_102010110*QR_011001010101+P_102110010*QR_011001010110+P_102110110*QR_011001010111+P_202010010*QR_011001010200+P_202010110*QR_011001010201+P_202110010*QR_011001010210+P_202110110*QR_011001010211); ans_temp[ans_id*36+27]+=Pmtrx[2]*(P_002010010*QR_010002010000+P_002010110*QR_010002010001+P_002110010*QR_010002010010+P_002110110*QR_010002010011+P_102010010*QR_010002010100+P_102010110*QR_010002010101+P_102110010*QR_010002010110+P_102110110*QR_010002010111+P_202010010*QR_010002010200+P_202010110*QR_010002010201+P_202110010*QR_010002010210+P_202110110*QR_010002010211); ans_temp[ans_id*36+27]+=Pmtrx[3]*(P_002010010*QR_011000011000+P_002010110*QR_011000011001+P_002110010*QR_011000011010+P_002110110*QR_011000011011+P_102010010*QR_011000011100+P_102010110*QR_011000011101+P_102110010*QR_011000011110+P_102110110*QR_011000011111+P_202010010*QR_011000011200+P_202010110*QR_011000011201+P_202110010*QR_011000011210+P_202110110*QR_011000011211); ans_temp[ans_id*36+27]+=Pmtrx[4]*(P_002010010*QR_010001011000+P_002010110*QR_010001011001+P_002110010*QR_010001011010+P_002110110*QR_010001011011+P_102010010*QR_010001011100+P_102010110*QR_010001011101+P_102110010*QR_010001011110+P_102110110*QR_010001011111+P_202010010*QR_010001011200+P_202010110*QR_010001011201+P_202110010*QR_010001011210+P_202110110*QR_010001011211); ans_temp[ans_id*36+27]+=Pmtrx[5]*(P_002010010*QR_010000012000+P_002010110*QR_010000012001+P_002110010*QR_010000012010+P_002110110*QR_010000012011+P_102010010*QR_010000012100+P_102010110*QR_010000012101+P_102110010*QR_010000012110+P_102110110*QR_010000012111+P_202010010*QR_010000012200+P_202010110*QR_010000012201+P_202110010*QR_010000012210+P_202110110*QR_010000012211); ans_temp[ans_id*36+28]+=Pmtrx[0]*(P_002010010*QR_002010010000+P_002010110*QR_002010010001+P_002110010*QR_002010010010+P_002110110*QR_002010010011+P_102010010*QR_002010010100+P_102010110*QR_002010010101+P_102110010*QR_002010010110+P_102110110*QR_002010010111+P_202010010*QR_002010010200+P_202010110*QR_002010010201+P_202110010*QR_002010010210+P_202110110*QR_002010010211); ans_temp[ans_id*36+28]+=Pmtrx[1]*(P_002010010*QR_001011010000+P_002010110*QR_001011010001+P_002110010*QR_001011010010+P_002110110*QR_001011010011+P_102010010*QR_001011010100+P_102010110*QR_001011010101+P_102110010*QR_001011010110+P_102110110*QR_001011010111+P_202010010*QR_001011010200+P_202010110*QR_001011010201+P_202110010*QR_001011010210+P_202110110*QR_001011010211); ans_temp[ans_id*36+28]+=Pmtrx[2]*(P_002010010*QR_000012010000+P_002010110*QR_000012010001+P_002110010*QR_000012010010+P_002110110*QR_000012010011+P_102010010*QR_000012010100+P_102010110*QR_000012010101+P_102110010*QR_000012010110+P_102110110*QR_000012010111+P_202010010*QR_000012010200+P_202010110*QR_000012010201+P_202110010*QR_000012010210+P_202110110*QR_000012010211); ans_temp[ans_id*36+28]+=Pmtrx[3]*(P_002010010*QR_001010011000+P_002010110*QR_001010011001+P_002110010*QR_001010011010+P_002110110*QR_001010011011+P_102010010*QR_001010011100+P_102010110*QR_001010011101+P_102110010*QR_001010011110+P_102110110*QR_001010011111+P_202010010*QR_001010011200+P_202010110*QR_001010011201+P_202110010*QR_001010011210+P_202110110*QR_001010011211); ans_temp[ans_id*36+28]+=Pmtrx[4]*(P_002010010*QR_000011011000+P_002010110*QR_000011011001+P_002110010*QR_000011011010+P_002110110*QR_000011011011+P_102010010*QR_000011011100+P_102010110*QR_000011011101+P_102110010*QR_000011011110+P_102110110*QR_000011011111+P_202010010*QR_000011011200+P_202010110*QR_000011011201+P_202110010*QR_000011011210+P_202110110*QR_000011011211); ans_temp[ans_id*36+28]+=Pmtrx[5]*(P_002010010*QR_000010012000+P_002010110*QR_000010012001+P_002110010*QR_000010012010+P_002110110*QR_000010012011+P_102010010*QR_000010012100+P_102010110*QR_000010012101+P_102110010*QR_000010012110+P_102110110*QR_000010012111+P_202010010*QR_000010012200+P_202010110*QR_000010012201+P_202110010*QR_000010012210+P_202110110*QR_000010012211); ans_temp[ans_id*36+29]+=Pmtrx[0]*(P_002010010*QR_002000020000+P_002010110*QR_002000020001+P_002110010*QR_002000020010+P_002110110*QR_002000020011+P_102010010*QR_002000020100+P_102010110*QR_002000020101+P_102110010*QR_002000020110+P_102110110*QR_002000020111+P_202010010*QR_002000020200+P_202010110*QR_002000020201+P_202110010*QR_002000020210+P_202110110*QR_002000020211); ans_temp[ans_id*36+29]+=Pmtrx[1]*(P_002010010*QR_001001020000+P_002010110*QR_001001020001+P_002110010*QR_001001020010+P_002110110*QR_001001020011+P_102010010*QR_001001020100+P_102010110*QR_001001020101+P_102110010*QR_001001020110+P_102110110*QR_001001020111+P_202010010*QR_001001020200+P_202010110*QR_001001020201+P_202110010*QR_001001020210+P_202110110*QR_001001020211); ans_temp[ans_id*36+29]+=Pmtrx[2]*(P_002010010*QR_000002020000+P_002010110*QR_000002020001+P_002110010*QR_000002020010+P_002110110*QR_000002020011+P_102010010*QR_000002020100+P_102010110*QR_000002020101+P_102110010*QR_000002020110+P_102110110*QR_000002020111+P_202010010*QR_000002020200+P_202010110*QR_000002020201+P_202110010*QR_000002020210+P_202110110*QR_000002020211); ans_temp[ans_id*36+29]+=Pmtrx[3]*(P_002010010*QR_001000021000+P_002010110*QR_001000021001+P_002110010*QR_001000021010+P_002110110*QR_001000021011+P_102010010*QR_001000021100+P_102010110*QR_001000021101+P_102110010*QR_001000021110+P_102110110*QR_001000021111+P_202010010*QR_001000021200+P_202010110*QR_001000021201+P_202110010*QR_001000021210+P_202110110*QR_001000021211); ans_temp[ans_id*36+29]+=Pmtrx[4]*(P_002010010*QR_000001021000+P_002010110*QR_000001021001+P_002110010*QR_000001021010+P_002110110*QR_000001021011+P_102010010*QR_000001021100+P_102010110*QR_000001021101+P_102110010*QR_000001021110+P_102110110*QR_000001021111+P_202010010*QR_000001021200+P_202010110*QR_000001021201+P_202110010*QR_000001021210+P_202110110*QR_000001021211); ans_temp[ans_id*36+29]+=Pmtrx[5]*(P_002010010*QR_000000022000+P_002010110*QR_000000022001+P_002110010*QR_000000022010+P_002110110*QR_000000022011+P_102010010*QR_000000022100+P_102010110*QR_000000022101+P_102110010*QR_000000022110+P_102110110*QR_000000022111+P_202010010*QR_000000022200+P_202010110*QR_000000022201+P_202110010*QR_000000022210+P_202110110*QR_000000022211); ans_temp[ans_id*36+24]+=Pmtrx[6]*(P_001011010*QR_022000000000+P_001011110*QR_022000000001+P_001111010*QR_022000000010+P_001111110*QR_022000000011+P_001211010*QR_022000000020+P_001211110*QR_022000000021+P_101011010*QR_022000000100+P_101011110*QR_022000000101+P_101111010*QR_022000000110+P_101111110*QR_022000000111+P_101211010*QR_022000000120+P_101211110*QR_022000000121); ans_temp[ans_id*36+24]+=Pmtrx[7]*(P_001011010*QR_021001000000+P_001011110*QR_021001000001+P_001111010*QR_021001000010+P_001111110*QR_021001000011+P_001211010*QR_021001000020+P_001211110*QR_021001000021+P_101011010*QR_021001000100+P_101011110*QR_021001000101+P_101111010*QR_021001000110+P_101111110*QR_021001000111+P_101211010*QR_021001000120+P_101211110*QR_021001000121); ans_temp[ans_id*36+24]+=Pmtrx[8]*(P_001011010*QR_020002000000+P_001011110*QR_020002000001+P_001111010*QR_020002000010+P_001111110*QR_020002000011+P_001211010*QR_020002000020+P_001211110*QR_020002000021+P_101011010*QR_020002000100+P_101011110*QR_020002000101+P_101111010*QR_020002000110+P_101111110*QR_020002000111+P_101211010*QR_020002000120+P_101211110*QR_020002000121); ans_temp[ans_id*36+24]+=Pmtrx[9]*(P_001011010*QR_021000001000+P_001011110*QR_021000001001+P_001111010*QR_021000001010+P_001111110*QR_021000001011+P_001211010*QR_021000001020+P_001211110*QR_021000001021+P_101011010*QR_021000001100+P_101011110*QR_021000001101+P_101111010*QR_021000001110+P_101111110*QR_021000001111+P_101211010*QR_021000001120+P_101211110*QR_021000001121); ans_temp[ans_id*36+24]+=Pmtrx[10]*(P_001011010*QR_020001001000+P_001011110*QR_020001001001+P_001111010*QR_020001001010+P_001111110*QR_020001001011+P_001211010*QR_020001001020+P_001211110*QR_020001001021+P_101011010*QR_020001001100+P_101011110*QR_020001001101+P_101111010*QR_020001001110+P_101111110*QR_020001001111+P_101211010*QR_020001001120+P_101211110*QR_020001001121); ans_temp[ans_id*36+24]+=Pmtrx[11]*(P_001011010*QR_020000002000+P_001011110*QR_020000002001+P_001111010*QR_020000002010+P_001111110*QR_020000002011+P_001211010*QR_020000002020+P_001211110*QR_020000002021+P_101011010*QR_020000002100+P_101011110*QR_020000002101+P_101111010*QR_020000002110+P_101111110*QR_020000002111+P_101211010*QR_020000002120+P_101211110*QR_020000002121); ans_temp[ans_id*36+25]+=Pmtrx[6]*(P_001011010*QR_012010000000+P_001011110*QR_012010000001+P_001111010*QR_012010000010+P_001111110*QR_012010000011+P_001211010*QR_012010000020+P_001211110*QR_012010000021+P_101011010*QR_012010000100+P_101011110*QR_012010000101+P_101111010*QR_012010000110+P_101111110*QR_012010000111+P_101211010*QR_012010000120+P_101211110*QR_012010000121); ans_temp[ans_id*36+25]+=Pmtrx[7]*(P_001011010*QR_011011000000+P_001011110*QR_011011000001+P_001111010*QR_011011000010+P_001111110*QR_011011000011+P_001211010*QR_011011000020+P_001211110*QR_011011000021+P_101011010*QR_011011000100+P_101011110*QR_011011000101+P_101111010*QR_011011000110+P_101111110*QR_011011000111+P_101211010*QR_011011000120+P_101211110*QR_011011000121); ans_temp[ans_id*36+25]+=Pmtrx[8]*(P_001011010*QR_010012000000+P_001011110*QR_010012000001+P_001111010*QR_010012000010+P_001111110*QR_010012000011+P_001211010*QR_010012000020+P_001211110*QR_010012000021+P_101011010*QR_010012000100+P_101011110*QR_010012000101+P_101111010*QR_010012000110+P_101111110*QR_010012000111+P_101211010*QR_010012000120+P_101211110*QR_010012000121); ans_temp[ans_id*36+25]+=Pmtrx[9]*(P_001011010*QR_011010001000+P_001011110*QR_011010001001+P_001111010*QR_011010001010+P_001111110*QR_011010001011+P_001211010*QR_011010001020+P_001211110*QR_011010001021+P_101011010*QR_011010001100+P_101011110*QR_011010001101+P_101111010*QR_011010001110+P_101111110*QR_011010001111+P_101211010*QR_011010001120+P_101211110*QR_011010001121); ans_temp[ans_id*36+25]+=Pmtrx[10]*(P_001011010*QR_010011001000+P_001011110*QR_010011001001+P_001111010*QR_010011001010+P_001111110*QR_010011001011+P_001211010*QR_010011001020+P_001211110*QR_010011001021+P_101011010*QR_010011001100+P_101011110*QR_010011001101+P_101111010*QR_010011001110+P_101111110*QR_010011001111+P_101211010*QR_010011001120+P_101211110*QR_010011001121); ans_temp[ans_id*36+25]+=Pmtrx[11]*(P_001011010*QR_010010002000+P_001011110*QR_010010002001+P_001111010*QR_010010002010+P_001111110*QR_010010002011+P_001211010*QR_010010002020+P_001211110*QR_010010002021+P_101011010*QR_010010002100+P_101011110*QR_010010002101+P_101111010*QR_010010002110+P_101111110*QR_010010002111+P_101211010*QR_010010002120+P_101211110*QR_010010002121); ans_temp[ans_id*36+26]+=Pmtrx[6]*(P_001011010*QR_002020000000+P_001011110*QR_002020000001+P_001111010*QR_002020000010+P_001111110*QR_002020000011+P_001211010*QR_002020000020+P_001211110*QR_002020000021+P_101011010*QR_002020000100+P_101011110*QR_002020000101+P_101111010*QR_002020000110+P_101111110*QR_002020000111+P_101211010*QR_002020000120+P_101211110*QR_002020000121); ans_temp[ans_id*36+26]+=Pmtrx[7]*(P_001011010*QR_001021000000+P_001011110*QR_001021000001+P_001111010*QR_001021000010+P_001111110*QR_001021000011+P_001211010*QR_001021000020+P_001211110*QR_001021000021+P_101011010*QR_001021000100+P_101011110*QR_001021000101+P_101111010*QR_001021000110+P_101111110*QR_001021000111+P_101211010*QR_001021000120+P_101211110*QR_001021000121); ans_temp[ans_id*36+26]+=Pmtrx[8]*(P_001011010*QR_000022000000+P_001011110*QR_000022000001+P_001111010*QR_000022000010+P_001111110*QR_000022000011+P_001211010*QR_000022000020+P_001211110*QR_000022000021+P_101011010*QR_000022000100+P_101011110*QR_000022000101+P_101111010*QR_000022000110+P_101111110*QR_000022000111+P_101211010*QR_000022000120+P_101211110*QR_000022000121); ans_temp[ans_id*36+26]+=Pmtrx[9]*(P_001011010*QR_001020001000+P_001011110*QR_001020001001+P_001111010*QR_001020001010+P_001111110*QR_001020001011+P_001211010*QR_001020001020+P_001211110*QR_001020001021+P_101011010*QR_001020001100+P_101011110*QR_001020001101+P_101111010*QR_001020001110+P_101111110*QR_001020001111+P_101211010*QR_001020001120+P_101211110*QR_001020001121); ans_temp[ans_id*36+26]+=Pmtrx[10]*(P_001011010*QR_000021001000+P_001011110*QR_000021001001+P_001111010*QR_000021001010+P_001111110*QR_000021001011+P_001211010*QR_000021001020+P_001211110*QR_000021001021+P_101011010*QR_000021001100+P_101011110*QR_000021001101+P_101111010*QR_000021001110+P_101111110*QR_000021001111+P_101211010*QR_000021001120+P_101211110*QR_000021001121); ans_temp[ans_id*36+26]+=Pmtrx[11]*(P_001011010*QR_000020002000+P_001011110*QR_000020002001+P_001111010*QR_000020002010+P_001111110*QR_000020002011+P_001211010*QR_000020002020+P_001211110*QR_000020002021+P_101011010*QR_000020002100+P_101011110*QR_000020002101+P_101111010*QR_000020002110+P_101111110*QR_000020002111+P_101211010*QR_000020002120+P_101211110*QR_000020002121); ans_temp[ans_id*36+27]+=Pmtrx[6]*(P_001011010*QR_012000010000+P_001011110*QR_012000010001+P_001111010*QR_012000010010+P_001111110*QR_012000010011+P_001211010*QR_012000010020+P_001211110*QR_012000010021+P_101011010*QR_012000010100+P_101011110*QR_012000010101+P_101111010*QR_012000010110+P_101111110*QR_012000010111+P_101211010*QR_012000010120+P_101211110*QR_012000010121); ans_temp[ans_id*36+27]+=Pmtrx[7]*(P_001011010*QR_011001010000+P_001011110*QR_011001010001+P_001111010*QR_011001010010+P_001111110*QR_011001010011+P_001211010*QR_011001010020+P_001211110*QR_011001010021+P_101011010*QR_011001010100+P_101011110*QR_011001010101+P_101111010*QR_011001010110+P_101111110*QR_011001010111+P_101211010*QR_011001010120+P_101211110*QR_011001010121); ans_temp[ans_id*36+27]+=Pmtrx[8]*(P_001011010*QR_010002010000+P_001011110*QR_010002010001+P_001111010*QR_010002010010+P_001111110*QR_010002010011+P_001211010*QR_010002010020+P_001211110*QR_010002010021+P_101011010*QR_010002010100+P_101011110*QR_010002010101+P_101111010*QR_010002010110+P_101111110*QR_010002010111+P_101211010*QR_010002010120+P_101211110*QR_010002010121); ans_temp[ans_id*36+27]+=Pmtrx[9]*(P_001011010*QR_011000011000+P_001011110*QR_011000011001+P_001111010*QR_011000011010+P_001111110*QR_011000011011+P_001211010*QR_011000011020+P_001211110*QR_011000011021+P_101011010*QR_011000011100+P_101011110*QR_011000011101+P_101111010*QR_011000011110+P_101111110*QR_011000011111+P_101211010*QR_011000011120+P_101211110*QR_011000011121); ans_temp[ans_id*36+27]+=Pmtrx[10]*(P_001011010*QR_010001011000+P_001011110*QR_010001011001+P_001111010*QR_010001011010+P_001111110*QR_010001011011+P_001211010*QR_010001011020+P_001211110*QR_010001011021+P_101011010*QR_010001011100+P_101011110*QR_010001011101+P_101111010*QR_010001011110+P_101111110*QR_010001011111+P_101211010*QR_010001011120+P_101211110*QR_010001011121); ans_temp[ans_id*36+27]+=Pmtrx[11]*(P_001011010*QR_010000012000+P_001011110*QR_010000012001+P_001111010*QR_010000012010+P_001111110*QR_010000012011+P_001211010*QR_010000012020+P_001211110*QR_010000012021+P_101011010*QR_010000012100+P_101011110*QR_010000012101+P_101111010*QR_010000012110+P_101111110*QR_010000012111+P_101211010*QR_010000012120+P_101211110*QR_010000012121); ans_temp[ans_id*36+28]+=Pmtrx[6]*(P_001011010*QR_002010010000+P_001011110*QR_002010010001+P_001111010*QR_002010010010+P_001111110*QR_002010010011+P_001211010*QR_002010010020+P_001211110*QR_002010010021+P_101011010*QR_002010010100+P_101011110*QR_002010010101+P_101111010*QR_002010010110+P_101111110*QR_002010010111+P_101211010*QR_002010010120+P_101211110*QR_002010010121); ans_temp[ans_id*36+28]+=Pmtrx[7]*(P_001011010*QR_001011010000+P_001011110*QR_001011010001+P_001111010*QR_001011010010+P_001111110*QR_001011010011+P_001211010*QR_001011010020+P_001211110*QR_001011010021+P_101011010*QR_001011010100+P_101011110*QR_001011010101+P_101111010*QR_001011010110+P_101111110*QR_001011010111+P_101211010*QR_001011010120+P_101211110*QR_001011010121); ans_temp[ans_id*36+28]+=Pmtrx[8]*(P_001011010*QR_000012010000+P_001011110*QR_000012010001+P_001111010*QR_000012010010+P_001111110*QR_000012010011+P_001211010*QR_000012010020+P_001211110*QR_000012010021+P_101011010*QR_000012010100+P_101011110*QR_000012010101+P_101111010*QR_000012010110+P_101111110*QR_000012010111+P_101211010*QR_000012010120+P_101211110*QR_000012010121); ans_temp[ans_id*36+28]+=Pmtrx[9]*(P_001011010*QR_001010011000+P_001011110*QR_001010011001+P_001111010*QR_001010011010+P_001111110*QR_001010011011+P_001211010*QR_001010011020+P_001211110*QR_001010011021+P_101011010*QR_001010011100+P_101011110*QR_001010011101+P_101111010*QR_001010011110+P_101111110*QR_001010011111+P_101211010*QR_001010011120+P_101211110*QR_001010011121); ans_temp[ans_id*36+28]+=Pmtrx[10]*(P_001011010*QR_000011011000+P_001011110*QR_000011011001+P_001111010*QR_000011011010+P_001111110*QR_000011011011+P_001211010*QR_000011011020+P_001211110*QR_000011011021+P_101011010*QR_000011011100+P_101011110*QR_000011011101+P_101111010*QR_000011011110+P_101111110*QR_000011011111+P_101211010*QR_000011011120+P_101211110*QR_000011011121); ans_temp[ans_id*36+28]+=Pmtrx[11]*(P_001011010*QR_000010012000+P_001011110*QR_000010012001+P_001111010*QR_000010012010+P_001111110*QR_000010012011+P_001211010*QR_000010012020+P_001211110*QR_000010012021+P_101011010*QR_000010012100+P_101011110*QR_000010012101+P_101111010*QR_000010012110+P_101111110*QR_000010012111+P_101211010*QR_000010012120+P_101211110*QR_000010012121); ans_temp[ans_id*36+29]+=Pmtrx[6]*(P_001011010*QR_002000020000+P_001011110*QR_002000020001+P_001111010*QR_002000020010+P_001111110*QR_002000020011+P_001211010*QR_002000020020+P_001211110*QR_002000020021+P_101011010*QR_002000020100+P_101011110*QR_002000020101+P_101111010*QR_002000020110+P_101111110*QR_002000020111+P_101211010*QR_002000020120+P_101211110*QR_002000020121); ans_temp[ans_id*36+29]+=Pmtrx[7]*(P_001011010*QR_001001020000+P_001011110*QR_001001020001+P_001111010*QR_001001020010+P_001111110*QR_001001020011+P_001211010*QR_001001020020+P_001211110*QR_001001020021+P_101011010*QR_001001020100+P_101011110*QR_001001020101+P_101111010*QR_001001020110+P_101111110*QR_001001020111+P_101211010*QR_001001020120+P_101211110*QR_001001020121); ans_temp[ans_id*36+29]+=Pmtrx[8]*(P_001011010*QR_000002020000+P_001011110*QR_000002020001+P_001111010*QR_000002020010+P_001111110*QR_000002020011+P_001211010*QR_000002020020+P_001211110*QR_000002020021+P_101011010*QR_000002020100+P_101011110*QR_000002020101+P_101111010*QR_000002020110+P_101111110*QR_000002020111+P_101211010*QR_000002020120+P_101211110*QR_000002020121); ans_temp[ans_id*36+29]+=Pmtrx[9]*(P_001011010*QR_001000021000+P_001011110*QR_001000021001+P_001111010*QR_001000021010+P_001111110*QR_001000021011+P_001211010*QR_001000021020+P_001211110*QR_001000021021+P_101011010*QR_001000021100+P_101011110*QR_001000021101+P_101111010*QR_001000021110+P_101111110*QR_001000021111+P_101211010*QR_001000021120+P_101211110*QR_001000021121); ans_temp[ans_id*36+29]+=Pmtrx[10]*(P_001011010*QR_000001021000+P_001011110*QR_000001021001+P_001111010*QR_000001021010+P_001111110*QR_000001021011+P_001211010*QR_000001021020+P_001211110*QR_000001021021+P_101011010*QR_000001021100+P_101011110*QR_000001021101+P_101111010*QR_000001021110+P_101111110*QR_000001021111+P_101211010*QR_000001021120+P_101211110*QR_000001021121); ans_temp[ans_id*36+29]+=Pmtrx[11]*(P_001011010*QR_000000022000+P_001011110*QR_000000022001+P_001111010*QR_000000022010+P_001111110*QR_000000022011+P_001211010*QR_000000022020+P_001211110*QR_000000022021+P_101011010*QR_000000022100+P_101011110*QR_000000022101+P_101111010*QR_000000022110+P_101111110*QR_000000022111+P_101211010*QR_000000022120+P_101211110*QR_000000022121); ans_temp[ans_id*36+24]+=Pmtrx[12]*(P_000012010*QR_022000000000+P_000012110*QR_022000000001+P_000112010*QR_022000000010+P_000112110*QR_022000000011+P_000212010*QR_022000000020+P_000212110*QR_022000000021+P_000312010*QR_022000000030+P_000312110*QR_022000000031); ans_temp[ans_id*36+24]+=Pmtrx[13]*(P_000012010*QR_021001000000+P_000012110*QR_021001000001+P_000112010*QR_021001000010+P_000112110*QR_021001000011+P_000212010*QR_021001000020+P_000212110*QR_021001000021+P_000312010*QR_021001000030+P_000312110*QR_021001000031); ans_temp[ans_id*36+24]+=Pmtrx[14]*(P_000012010*QR_020002000000+P_000012110*QR_020002000001+P_000112010*QR_020002000010+P_000112110*QR_020002000011+P_000212010*QR_020002000020+P_000212110*QR_020002000021+P_000312010*QR_020002000030+P_000312110*QR_020002000031); ans_temp[ans_id*36+24]+=Pmtrx[15]*(P_000012010*QR_021000001000+P_000012110*QR_021000001001+P_000112010*QR_021000001010+P_000112110*QR_021000001011+P_000212010*QR_021000001020+P_000212110*QR_021000001021+P_000312010*QR_021000001030+P_000312110*QR_021000001031); ans_temp[ans_id*36+24]+=Pmtrx[16]*(P_000012010*QR_020001001000+P_000012110*QR_020001001001+P_000112010*QR_020001001010+P_000112110*QR_020001001011+P_000212010*QR_020001001020+P_000212110*QR_020001001021+P_000312010*QR_020001001030+P_000312110*QR_020001001031); ans_temp[ans_id*36+24]+=Pmtrx[17]*(P_000012010*QR_020000002000+P_000012110*QR_020000002001+P_000112010*QR_020000002010+P_000112110*QR_020000002011+P_000212010*QR_020000002020+P_000212110*QR_020000002021+P_000312010*QR_020000002030+P_000312110*QR_020000002031); ans_temp[ans_id*36+25]+=Pmtrx[12]*(P_000012010*QR_012010000000+P_000012110*QR_012010000001+P_000112010*QR_012010000010+P_000112110*QR_012010000011+P_000212010*QR_012010000020+P_000212110*QR_012010000021+P_000312010*QR_012010000030+P_000312110*QR_012010000031); ans_temp[ans_id*36+25]+=Pmtrx[13]*(P_000012010*QR_011011000000+P_000012110*QR_011011000001+P_000112010*QR_011011000010+P_000112110*QR_011011000011+P_000212010*QR_011011000020+P_000212110*QR_011011000021+P_000312010*QR_011011000030+P_000312110*QR_011011000031); ans_temp[ans_id*36+25]+=Pmtrx[14]*(P_000012010*QR_010012000000+P_000012110*QR_010012000001+P_000112010*QR_010012000010+P_000112110*QR_010012000011+P_000212010*QR_010012000020+P_000212110*QR_010012000021+P_000312010*QR_010012000030+P_000312110*QR_010012000031); ans_temp[ans_id*36+25]+=Pmtrx[15]*(P_000012010*QR_011010001000+P_000012110*QR_011010001001+P_000112010*QR_011010001010+P_000112110*QR_011010001011+P_000212010*QR_011010001020+P_000212110*QR_011010001021+P_000312010*QR_011010001030+P_000312110*QR_011010001031); ans_temp[ans_id*36+25]+=Pmtrx[16]*(P_000012010*QR_010011001000+P_000012110*QR_010011001001+P_000112010*QR_010011001010+P_000112110*QR_010011001011+P_000212010*QR_010011001020+P_000212110*QR_010011001021+P_000312010*QR_010011001030+P_000312110*QR_010011001031); ans_temp[ans_id*36+25]+=Pmtrx[17]*(P_000012010*QR_010010002000+P_000012110*QR_010010002001+P_000112010*QR_010010002010+P_000112110*QR_010010002011+P_000212010*QR_010010002020+P_000212110*QR_010010002021+P_000312010*QR_010010002030+P_000312110*QR_010010002031); ans_temp[ans_id*36+26]+=Pmtrx[12]*(P_000012010*QR_002020000000+P_000012110*QR_002020000001+P_000112010*QR_002020000010+P_000112110*QR_002020000011+P_000212010*QR_002020000020+P_000212110*QR_002020000021+P_000312010*QR_002020000030+P_000312110*QR_002020000031); ans_temp[ans_id*36+26]+=Pmtrx[13]*(P_000012010*QR_001021000000+P_000012110*QR_001021000001+P_000112010*QR_001021000010+P_000112110*QR_001021000011+P_000212010*QR_001021000020+P_000212110*QR_001021000021+P_000312010*QR_001021000030+P_000312110*QR_001021000031); ans_temp[ans_id*36+26]+=Pmtrx[14]*(P_000012010*QR_000022000000+P_000012110*QR_000022000001+P_000112010*QR_000022000010+P_000112110*QR_000022000011+P_000212010*QR_000022000020+P_000212110*QR_000022000021+P_000312010*QR_000022000030+P_000312110*QR_000022000031); ans_temp[ans_id*36+26]+=Pmtrx[15]*(P_000012010*QR_001020001000+P_000012110*QR_001020001001+P_000112010*QR_001020001010+P_000112110*QR_001020001011+P_000212010*QR_001020001020+P_000212110*QR_001020001021+P_000312010*QR_001020001030+P_000312110*QR_001020001031); ans_temp[ans_id*36+26]+=Pmtrx[16]*(P_000012010*QR_000021001000+P_000012110*QR_000021001001+P_000112010*QR_000021001010+P_000112110*QR_000021001011+P_000212010*QR_000021001020+P_000212110*QR_000021001021+P_000312010*QR_000021001030+P_000312110*QR_000021001031); ans_temp[ans_id*36+26]+=Pmtrx[17]*(P_000012010*QR_000020002000+P_000012110*QR_000020002001+P_000112010*QR_000020002010+P_000112110*QR_000020002011+P_000212010*QR_000020002020+P_000212110*QR_000020002021+P_000312010*QR_000020002030+P_000312110*QR_000020002031); ans_temp[ans_id*36+27]+=Pmtrx[12]*(P_000012010*QR_012000010000+P_000012110*QR_012000010001+P_000112010*QR_012000010010+P_000112110*QR_012000010011+P_000212010*QR_012000010020+P_000212110*QR_012000010021+P_000312010*QR_012000010030+P_000312110*QR_012000010031); ans_temp[ans_id*36+27]+=Pmtrx[13]*(P_000012010*QR_011001010000+P_000012110*QR_011001010001+P_000112010*QR_011001010010+P_000112110*QR_011001010011+P_000212010*QR_011001010020+P_000212110*QR_011001010021+P_000312010*QR_011001010030+P_000312110*QR_011001010031); ans_temp[ans_id*36+27]+=Pmtrx[14]*(P_000012010*QR_010002010000+P_000012110*QR_010002010001+P_000112010*QR_010002010010+P_000112110*QR_010002010011+P_000212010*QR_010002010020+P_000212110*QR_010002010021+P_000312010*QR_010002010030+P_000312110*QR_010002010031); ans_temp[ans_id*36+27]+=Pmtrx[15]*(P_000012010*QR_011000011000+P_000012110*QR_011000011001+P_000112010*QR_011000011010+P_000112110*QR_011000011011+P_000212010*QR_011000011020+P_000212110*QR_011000011021+P_000312010*QR_011000011030+P_000312110*QR_011000011031); ans_temp[ans_id*36+27]+=Pmtrx[16]*(P_000012010*QR_010001011000+P_000012110*QR_010001011001+P_000112010*QR_010001011010+P_000112110*QR_010001011011+P_000212010*QR_010001011020+P_000212110*QR_010001011021+P_000312010*QR_010001011030+P_000312110*QR_010001011031); ans_temp[ans_id*36+27]+=Pmtrx[17]*(P_000012010*QR_010000012000+P_000012110*QR_010000012001+P_000112010*QR_010000012010+P_000112110*QR_010000012011+P_000212010*QR_010000012020+P_000212110*QR_010000012021+P_000312010*QR_010000012030+P_000312110*QR_010000012031); ans_temp[ans_id*36+28]+=Pmtrx[12]*(P_000012010*QR_002010010000+P_000012110*QR_002010010001+P_000112010*QR_002010010010+P_000112110*QR_002010010011+P_000212010*QR_002010010020+P_000212110*QR_002010010021+P_000312010*QR_002010010030+P_000312110*QR_002010010031); ans_temp[ans_id*36+28]+=Pmtrx[13]*(P_000012010*QR_001011010000+P_000012110*QR_001011010001+P_000112010*QR_001011010010+P_000112110*QR_001011010011+P_000212010*QR_001011010020+P_000212110*QR_001011010021+P_000312010*QR_001011010030+P_000312110*QR_001011010031); ans_temp[ans_id*36+28]+=Pmtrx[14]*(P_000012010*QR_000012010000+P_000012110*QR_000012010001+P_000112010*QR_000012010010+P_000112110*QR_000012010011+P_000212010*QR_000012010020+P_000212110*QR_000012010021+P_000312010*QR_000012010030+P_000312110*QR_000012010031); ans_temp[ans_id*36+28]+=Pmtrx[15]*(P_000012010*QR_001010011000+P_000012110*QR_001010011001+P_000112010*QR_001010011010+P_000112110*QR_001010011011+P_000212010*QR_001010011020+P_000212110*QR_001010011021+P_000312010*QR_001010011030+P_000312110*QR_001010011031); ans_temp[ans_id*36+28]+=Pmtrx[16]*(P_000012010*QR_000011011000+P_000012110*QR_000011011001+P_000112010*QR_000011011010+P_000112110*QR_000011011011+P_000212010*QR_000011011020+P_000212110*QR_000011011021+P_000312010*QR_000011011030+P_000312110*QR_000011011031); ans_temp[ans_id*36+28]+=Pmtrx[17]*(P_000012010*QR_000010012000+P_000012110*QR_000010012001+P_000112010*QR_000010012010+P_000112110*QR_000010012011+P_000212010*QR_000010012020+P_000212110*QR_000010012021+P_000312010*QR_000010012030+P_000312110*QR_000010012031); ans_temp[ans_id*36+29]+=Pmtrx[12]*(P_000012010*QR_002000020000+P_000012110*QR_002000020001+P_000112010*QR_002000020010+P_000112110*QR_002000020011+P_000212010*QR_002000020020+P_000212110*QR_002000020021+P_000312010*QR_002000020030+P_000312110*QR_002000020031); ans_temp[ans_id*36+29]+=Pmtrx[13]*(P_000012010*QR_001001020000+P_000012110*QR_001001020001+P_000112010*QR_001001020010+P_000112110*QR_001001020011+P_000212010*QR_001001020020+P_000212110*QR_001001020021+P_000312010*QR_001001020030+P_000312110*QR_001001020031); ans_temp[ans_id*36+29]+=Pmtrx[14]*(P_000012010*QR_000002020000+P_000012110*QR_000002020001+P_000112010*QR_000002020010+P_000112110*QR_000002020011+P_000212010*QR_000002020020+P_000212110*QR_000002020021+P_000312010*QR_000002020030+P_000312110*QR_000002020031); ans_temp[ans_id*36+29]+=Pmtrx[15]*(P_000012010*QR_001000021000+P_000012110*QR_001000021001+P_000112010*QR_001000021010+P_000112110*QR_001000021011+P_000212010*QR_001000021020+P_000212110*QR_001000021021+P_000312010*QR_001000021030+P_000312110*QR_001000021031); ans_temp[ans_id*36+29]+=Pmtrx[16]*(P_000012010*QR_000001021000+P_000012110*QR_000001021001+P_000112010*QR_000001021010+P_000112110*QR_000001021011+P_000212010*QR_000001021020+P_000212110*QR_000001021021+P_000312010*QR_000001021030+P_000312110*QR_000001021031); ans_temp[ans_id*36+29]+=Pmtrx[17]*(P_000012010*QR_000000022000+P_000012110*QR_000000022001+P_000112010*QR_000000022010+P_000112110*QR_000000022011+P_000212010*QR_000000022020+P_000212110*QR_000000022021+P_000312010*QR_000000022030+P_000312110*QR_000000022031); ans_temp[ans_id*36+24]+=Pmtrx[18]*(P_001010011*QR_022000000000+P_001010111*QR_022000000001+P_001010211*QR_022000000002+P_001110011*QR_022000000010+P_001110111*QR_022000000011+P_001110211*QR_022000000012+P_101010011*QR_022000000100+P_101010111*QR_022000000101+P_101010211*QR_022000000102+P_101110011*QR_022000000110+P_101110111*QR_022000000111+P_101110211*QR_022000000112); ans_temp[ans_id*36+24]+=Pmtrx[19]*(P_001010011*QR_021001000000+P_001010111*QR_021001000001+P_001010211*QR_021001000002+P_001110011*QR_021001000010+P_001110111*QR_021001000011+P_001110211*QR_021001000012+P_101010011*QR_021001000100+P_101010111*QR_021001000101+P_101010211*QR_021001000102+P_101110011*QR_021001000110+P_101110111*QR_021001000111+P_101110211*QR_021001000112); ans_temp[ans_id*36+24]+=Pmtrx[20]*(P_001010011*QR_020002000000+P_001010111*QR_020002000001+P_001010211*QR_020002000002+P_001110011*QR_020002000010+P_001110111*QR_020002000011+P_001110211*QR_020002000012+P_101010011*QR_020002000100+P_101010111*QR_020002000101+P_101010211*QR_020002000102+P_101110011*QR_020002000110+P_101110111*QR_020002000111+P_101110211*QR_020002000112); ans_temp[ans_id*36+24]+=Pmtrx[21]*(P_001010011*QR_021000001000+P_001010111*QR_021000001001+P_001010211*QR_021000001002+P_001110011*QR_021000001010+P_001110111*QR_021000001011+P_001110211*QR_021000001012+P_101010011*QR_021000001100+P_101010111*QR_021000001101+P_101010211*QR_021000001102+P_101110011*QR_021000001110+P_101110111*QR_021000001111+P_101110211*QR_021000001112); ans_temp[ans_id*36+24]+=Pmtrx[22]*(P_001010011*QR_020001001000+P_001010111*QR_020001001001+P_001010211*QR_020001001002+P_001110011*QR_020001001010+P_001110111*QR_020001001011+P_001110211*QR_020001001012+P_101010011*QR_020001001100+P_101010111*QR_020001001101+P_101010211*QR_020001001102+P_101110011*QR_020001001110+P_101110111*QR_020001001111+P_101110211*QR_020001001112); ans_temp[ans_id*36+24]+=Pmtrx[23]*(P_001010011*QR_020000002000+P_001010111*QR_020000002001+P_001010211*QR_020000002002+P_001110011*QR_020000002010+P_001110111*QR_020000002011+P_001110211*QR_020000002012+P_101010011*QR_020000002100+P_101010111*QR_020000002101+P_101010211*QR_020000002102+P_101110011*QR_020000002110+P_101110111*QR_020000002111+P_101110211*QR_020000002112); ans_temp[ans_id*36+25]+=Pmtrx[18]*(P_001010011*QR_012010000000+P_001010111*QR_012010000001+P_001010211*QR_012010000002+P_001110011*QR_012010000010+P_001110111*QR_012010000011+P_001110211*QR_012010000012+P_101010011*QR_012010000100+P_101010111*QR_012010000101+P_101010211*QR_012010000102+P_101110011*QR_012010000110+P_101110111*QR_012010000111+P_101110211*QR_012010000112); ans_temp[ans_id*36+25]+=Pmtrx[19]*(P_001010011*QR_011011000000+P_001010111*QR_011011000001+P_001010211*QR_011011000002+P_001110011*QR_011011000010+P_001110111*QR_011011000011+P_001110211*QR_011011000012+P_101010011*QR_011011000100+P_101010111*QR_011011000101+P_101010211*QR_011011000102+P_101110011*QR_011011000110+P_101110111*QR_011011000111+P_101110211*QR_011011000112); ans_temp[ans_id*36+25]+=Pmtrx[20]*(P_001010011*QR_010012000000+P_001010111*QR_010012000001+P_001010211*QR_010012000002+P_001110011*QR_010012000010+P_001110111*QR_010012000011+P_001110211*QR_010012000012+P_101010011*QR_010012000100+P_101010111*QR_010012000101+P_101010211*QR_010012000102+P_101110011*QR_010012000110+P_101110111*QR_010012000111+P_101110211*QR_010012000112); ans_temp[ans_id*36+25]+=Pmtrx[21]*(P_001010011*QR_011010001000+P_001010111*QR_011010001001+P_001010211*QR_011010001002+P_001110011*QR_011010001010+P_001110111*QR_011010001011+P_001110211*QR_011010001012+P_101010011*QR_011010001100+P_101010111*QR_011010001101+P_101010211*QR_011010001102+P_101110011*QR_011010001110+P_101110111*QR_011010001111+P_101110211*QR_011010001112); ans_temp[ans_id*36+25]+=Pmtrx[22]*(P_001010011*QR_010011001000+P_001010111*QR_010011001001+P_001010211*QR_010011001002+P_001110011*QR_010011001010+P_001110111*QR_010011001011+P_001110211*QR_010011001012+P_101010011*QR_010011001100+P_101010111*QR_010011001101+P_101010211*QR_010011001102+P_101110011*QR_010011001110+P_101110111*QR_010011001111+P_101110211*QR_010011001112); ans_temp[ans_id*36+25]+=Pmtrx[23]*(P_001010011*QR_010010002000+P_001010111*QR_010010002001+P_001010211*QR_010010002002+P_001110011*QR_010010002010+P_001110111*QR_010010002011+P_001110211*QR_010010002012+P_101010011*QR_010010002100+P_101010111*QR_010010002101+P_101010211*QR_010010002102+P_101110011*QR_010010002110+P_101110111*QR_010010002111+P_101110211*QR_010010002112); ans_temp[ans_id*36+26]+=Pmtrx[18]*(P_001010011*QR_002020000000+P_001010111*QR_002020000001+P_001010211*QR_002020000002+P_001110011*QR_002020000010+P_001110111*QR_002020000011+P_001110211*QR_002020000012+P_101010011*QR_002020000100+P_101010111*QR_002020000101+P_101010211*QR_002020000102+P_101110011*QR_002020000110+P_101110111*QR_002020000111+P_101110211*QR_002020000112); ans_temp[ans_id*36+26]+=Pmtrx[19]*(P_001010011*QR_001021000000+P_001010111*QR_001021000001+P_001010211*QR_001021000002+P_001110011*QR_001021000010+P_001110111*QR_001021000011+P_001110211*QR_001021000012+P_101010011*QR_001021000100+P_101010111*QR_001021000101+P_101010211*QR_001021000102+P_101110011*QR_001021000110+P_101110111*QR_001021000111+P_101110211*QR_001021000112); ans_temp[ans_id*36+26]+=Pmtrx[20]*(P_001010011*QR_000022000000+P_001010111*QR_000022000001+P_001010211*QR_000022000002+P_001110011*QR_000022000010+P_001110111*QR_000022000011+P_001110211*QR_000022000012+P_101010011*QR_000022000100+P_101010111*QR_000022000101+P_101010211*QR_000022000102+P_101110011*QR_000022000110+P_101110111*QR_000022000111+P_101110211*QR_000022000112); ans_temp[ans_id*36+26]+=Pmtrx[21]*(P_001010011*QR_001020001000+P_001010111*QR_001020001001+P_001010211*QR_001020001002+P_001110011*QR_001020001010+P_001110111*QR_001020001011+P_001110211*QR_001020001012+P_101010011*QR_001020001100+P_101010111*QR_001020001101+P_101010211*QR_001020001102+P_101110011*QR_001020001110+P_101110111*QR_001020001111+P_101110211*QR_001020001112); ans_temp[ans_id*36+26]+=Pmtrx[22]*(P_001010011*QR_000021001000+P_001010111*QR_000021001001+P_001010211*QR_000021001002+P_001110011*QR_000021001010+P_001110111*QR_000021001011+P_001110211*QR_000021001012+P_101010011*QR_000021001100+P_101010111*QR_000021001101+P_101010211*QR_000021001102+P_101110011*QR_000021001110+P_101110111*QR_000021001111+P_101110211*QR_000021001112); ans_temp[ans_id*36+26]+=Pmtrx[23]*(P_001010011*QR_000020002000+P_001010111*QR_000020002001+P_001010211*QR_000020002002+P_001110011*QR_000020002010+P_001110111*QR_000020002011+P_001110211*QR_000020002012+P_101010011*QR_000020002100+P_101010111*QR_000020002101+P_101010211*QR_000020002102+P_101110011*QR_000020002110+P_101110111*QR_000020002111+P_101110211*QR_000020002112); ans_temp[ans_id*36+27]+=Pmtrx[18]*(P_001010011*QR_012000010000+P_001010111*QR_012000010001+P_001010211*QR_012000010002+P_001110011*QR_012000010010+P_001110111*QR_012000010011+P_001110211*QR_012000010012+P_101010011*QR_012000010100+P_101010111*QR_012000010101+P_101010211*QR_012000010102+P_101110011*QR_012000010110+P_101110111*QR_012000010111+P_101110211*QR_012000010112); ans_temp[ans_id*36+27]+=Pmtrx[19]*(P_001010011*QR_011001010000+P_001010111*QR_011001010001+P_001010211*QR_011001010002+P_001110011*QR_011001010010+P_001110111*QR_011001010011+P_001110211*QR_011001010012+P_101010011*QR_011001010100+P_101010111*QR_011001010101+P_101010211*QR_011001010102+P_101110011*QR_011001010110+P_101110111*QR_011001010111+P_101110211*QR_011001010112); ans_temp[ans_id*36+27]+=Pmtrx[20]*(P_001010011*QR_010002010000+P_001010111*QR_010002010001+P_001010211*QR_010002010002+P_001110011*QR_010002010010+P_001110111*QR_010002010011+P_001110211*QR_010002010012+P_101010011*QR_010002010100+P_101010111*QR_010002010101+P_101010211*QR_010002010102+P_101110011*QR_010002010110+P_101110111*QR_010002010111+P_101110211*QR_010002010112); ans_temp[ans_id*36+27]+=Pmtrx[21]*(P_001010011*QR_011000011000+P_001010111*QR_011000011001+P_001010211*QR_011000011002+P_001110011*QR_011000011010+P_001110111*QR_011000011011+P_001110211*QR_011000011012+P_101010011*QR_011000011100+P_101010111*QR_011000011101+P_101010211*QR_011000011102+P_101110011*QR_011000011110+P_101110111*QR_011000011111+P_101110211*QR_011000011112); ans_temp[ans_id*36+27]+=Pmtrx[22]*(P_001010011*QR_010001011000+P_001010111*QR_010001011001+P_001010211*QR_010001011002+P_001110011*QR_010001011010+P_001110111*QR_010001011011+P_001110211*QR_010001011012+P_101010011*QR_010001011100+P_101010111*QR_010001011101+P_101010211*QR_010001011102+P_101110011*QR_010001011110+P_101110111*QR_010001011111+P_101110211*QR_010001011112); ans_temp[ans_id*36+27]+=Pmtrx[23]*(P_001010011*QR_010000012000+P_001010111*QR_010000012001+P_001010211*QR_010000012002+P_001110011*QR_010000012010+P_001110111*QR_010000012011+P_001110211*QR_010000012012+P_101010011*QR_010000012100+P_101010111*QR_010000012101+P_101010211*QR_010000012102+P_101110011*QR_010000012110+P_101110111*QR_010000012111+P_101110211*QR_010000012112); ans_temp[ans_id*36+28]+=Pmtrx[18]*(P_001010011*QR_002010010000+P_001010111*QR_002010010001+P_001010211*QR_002010010002+P_001110011*QR_002010010010+P_001110111*QR_002010010011+P_001110211*QR_002010010012+P_101010011*QR_002010010100+P_101010111*QR_002010010101+P_101010211*QR_002010010102+P_101110011*QR_002010010110+P_101110111*QR_002010010111+P_101110211*QR_002010010112); ans_temp[ans_id*36+28]+=Pmtrx[19]*(P_001010011*QR_001011010000+P_001010111*QR_001011010001+P_001010211*QR_001011010002+P_001110011*QR_001011010010+P_001110111*QR_001011010011+P_001110211*QR_001011010012+P_101010011*QR_001011010100+P_101010111*QR_001011010101+P_101010211*QR_001011010102+P_101110011*QR_001011010110+P_101110111*QR_001011010111+P_101110211*QR_001011010112); ans_temp[ans_id*36+28]+=Pmtrx[20]*(P_001010011*QR_000012010000+P_001010111*QR_000012010001+P_001010211*QR_000012010002+P_001110011*QR_000012010010+P_001110111*QR_000012010011+P_001110211*QR_000012010012+P_101010011*QR_000012010100+P_101010111*QR_000012010101+P_101010211*QR_000012010102+P_101110011*QR_000012010110+P_101110111*QR_000012010111+P_101110211*QR_000012010112); ans_temp[ans_id*36+28]+=Pmtrx[21]*(P_001010011*QR_001010011000+P_001010111*QR_001010011001+P_001010211*QR_001010011002+P_001110011*QR_001010011010+P_001110111*QR_001010011011+P_001110211*QR_001010011012+P_101010011*QR_001010011100+P_101010111*QR_001010011101+P_101010211*QR_001010011102+P_101110011*QR_001010011110+P_101110111*QR_001010011111+P_101110211*QR_001010011112); ans_temp[ans_id*36+28]+=Pmtrx[22]*(P_001010011*QR_000011011000+P_001010111*QR_000011011001+P_001010211*QR_000011011002+P_001110011*QR_000011011010+P_001110111*QR_000011011011+P_001110211*QR_000011011012+P_101010011*QR_000011011100+P_101010111*QR_000011011101+P_101010211*QR_000011011102+P_101110011*QR_000011011110+P_101110111*QR_000011011111+P_101110211*QR_000011011112); ans_temp[ans_id*36+28]+=Pmtrx[23]*(P_001010011*QR_000010012000+P_001010111*QR_000010012001+P_001010211*QR_000010012002+P_001110011*QR_000010012010+P_001110111*QR_000010012011+P_001110211*QR_000010012012+P_101010011*QR_000010012100+P_101010111*QR_000010012101+P_101010211*QR_000010012102+P_101110011*QR_000010012110+P_101110111*QR_000010012111+P_101110211*QR_000010012112); ans_temp[ans_id*36+29]+=Pmtrx[18]*(P_001010011*QR_002000020000+P_001010111*QR_002000020001+P_001010211*QR_002000020002+P_001110011*QR_002000020010+P_001110111*QR_002000020011+P_001110211*QR_002000020012+P_101010011*QR_002000020100+P_101010111*QR_002000020101+P_101010211*QR_002000020102+P_101110011*QR_002000020110+P_101110111*QR_002000020111+P_101110211*QR_002000020112); ans_temp[ans_id*36+29]+=Pmtrx[19]*(P_001010011*QR_001001020000+P_001010111*QR_001001020001+P_001010211*QR_001001020002+P_001110011*QR_001001020010+P_001110111*QR_001001020011+P_001110211*QR_001001020012+P_101010011*QR_001001020100+P_101010111*QR_001001020101+P_101010211*QR_001001020102+P_101110011*QR_001001020110+P_101110111*QR_001001020111+P_101110211*QR_001001020112); ans_temp[ans_id*36+29]+=Pmtrx[20]*(P_001010011*QR_000002020000+P_001010111*QR_000002020001+P_001010211*QR_000002020002+P_001110011*QR_000002020010+P_001110111*QR_000002020011+P_001110211*QR_000002020012+P_101010011*QR_000002020100+P_101010111*QR_000002020101+P_101010211*QR_000002020102+P_101110011*QR_000002020110+P_101110111*QR_000002020111+P_101110211*QR_000002020112); ans_temp[ans_id*36+29]+=Pmtrx[21]*(P_001010011*QR_001000021000+P_001010111*QR_001000021001+P_001010211*QR_001000021002+P_001110011*QR_001000021010+P_001110111*QR_001000021011+P_001110211*QR_001000021012+P_101010011*QR_001000021100+P_101010111*QR_001000021101+P_101010211*QR_001000021102+P_101110011*QR_001000021110+P_101110111*QR_001000021111+P_101110211*QR_001000021112); ans_temp[ans_id*36+29]+=Pmtrx[22]*(P_001010011*QR_000001021000+P_001010111*QR_000001021001+P_001010211*QR_000001021002+P_001110011*QR_000001021010+P_001110111*QR_000001021011+P_001110211*QR_000001021012+P_101010011*QR_000001021100+P_101010111*QR_000001021101+P_101010211*QR_000001021102+P_101110011*QR_000001021110+P_101110111*QR_000001021111+P_101110211*QR_000001021112); ans_temp[ans_id*36+29]+=Pmtrx[23]*(P_001010011*QR_000000022000+P_001010111*QR_000000022001+P_001010211*QR_000000022002+P_001110011*QR_000000022010+P_001110111*QR_000000022011+P_001110211*QR_000000022012+P_101010011*QR_000000022100+P_101010111*QR_000000022101+P_101010211*QR_000000022102+P_101110011*QR_000000022110+P_101110111*QR_000000022111+P_101110211*QR_000000022112); ans_temp[ans_id*36+24]+=Pmtrx[24]*(P_000011011*QR_022000000000+P_000011111*QR_022000000001+P_000011211*QR_022000000002+P_000111011*QR_022000000010+P_000111111*QR_022000000011+P_000111211*QR_022000000012+P_000211011*QR_022000000020+P_000211111*QR_022000000021+P_000211211*QR_022000000022); ans_temp[ans_id*36+24]+=Pmtrx[25]*(P_000011011*QR_021001000000+P_000011111*QR_021001000001+P_000011211*QR_021001000002+P_000111011*QR_021001000010+P_000111111*QR_021001000011+P_000111211*QR_021001000012+P_000211011*QR_021001000020+P_000211111*QR_021001000021+P_000211211*QR_021001000022); ans_temp[ans_id*36+24]+=Pmtrx[26]*(P_000011011*QR_020002000000+P_000011111*QR_020002000001+P_000011211*QR_020002000002+P_000111011*QR_020002000010+P_000111111*QR_020002000011+P_000111211*QR_020002000012+P_000211011*QR_020002000020+P_000211111*QR_020002000021+P_000211211*QR_020002000022); ans_temp[ans_id*36+24]+=Pmtrx[27]*(P_000011011*QR_021000001000+P_000011111*QR_021000001001+P_000011211*QR_021000001002+P_000111011*QR_021000001010+P_000111111*QR_021000001011+P_000111211*QR_021000001012+P_000211011*QR_021000001020+P_000211111*QR_021000001021+P_000211211*QR_021000001022); ans_temp[ans_id*36+24]+=Pmtrx[28]*(P_000011011*QR_020001001000+P_000011111*QR_020001001001+P_000011211*QR_020001001002+P_000111011*QR_020001001010+P_000111111*QR_020001001011+P_000111211*QR_020001001012+P_000211011*QR_020001001020+P_000211111*QR_020001001021+P_000211211*QR_020001001022); ans_temp[ans_id*36+24]+=Pmtrx[29]*(P_000011011*QR_020000002000+P_000011111*QR_020000002001+P_000011211*QR_020000002002+P_000111011*QR_020000002010+P_000111111*QR_020000002011+P_000111211*QR_020000002012+P_000211011*QR_020000002020+P_000211111*QR_020000002021+P_000211211*QR_020000002022); ans_temp[ans_id*36+25]+=Pmtrx[24]*(P_000011011*QR_012010000000+P_000011111*QR_012010000001+P_000011211*QR_012010000002+P_000111011*QR_012010000010+P_000111111*QR_012010000011+P_000111211*QR_012010000012+P_000211011*QR_012010000020+P_000211111*QR_012010000021+P_000211211*QR_012010000022); ans_temp[ans_id*36+25]+=Pmtrx[25]*(P_000011011*QR_011011000000+P_000011111*QR_011011000001+P_000011211*QR_011011000002+P_000111011*QR_011011000010+P_000111111*QR_011011000011+P_000111211*QR_011011000012+P_000211011*QR_011011000020+P_000211111*QR_011011000021+P_000211211*QR_011011000022); ans_temp[ans_id*36+25]+=Pmtrx[26]*(P_000011011*QR_010012000000+P_000011111*QR_010012000001+P_000011211*QR_010012000002+P_000111011*QR_010012000010+P_000111111*QR_010012000011+P_000111211*QR_010012000012+P_000211011*QR_010012000020+P_000211111*QR_010012000021+P_000211211*QR_010012000022); ans_temp[ans_id*36+25]+=Pmtrx[27]*(P_000011011*QR_011010001000+P_000011111*QR_011010001001+P_000011211*QR_011010001002+P_000111011*QR_011010001010+P_000111111*QR_011010001011+P_000111211*QR_011010001012+P_000211011*QR_011010001020+P_000211111*QR_011010001021+P_000211211*QR_011010001022); ans_temp[ans_id*36+25]+=Pmtrx[28]*(P_000011011*QR_010011001000+P_000011111*QR_010011001001+P_000011211*QR_010011001002+P_000111011*QR_010011001010+P_000111111*QR_010011001011+P_000111211*QR_010011001012+P_000211011*QR_010011001020+P_000211111*QR_010011001021+P_000211211*QR_010011001022); ans_temp[ans_id*36+25]+=Pmtrx[29]*(P_000011011*QR_010010002000+P_000011111*QR_010010002001+P_000011211*QR_010010002002+P_000111011*QR_010010002010+P_000111111*QR_010010002011+P_000111211*QR_010010002012+P_000211011*QR_010010002020+P_000211111*QR_010010002021+P_000211211*QR_010010002022); ans_temp[ans_id*36+26]+=Pmtrx[24]*(P_000011011*QR_002020000000+P_000011111*QR_002020000001+P_000011211*QR_002020000002+P_000111011*QR_002020000010+P_000111111*QR_002020000011+P_000111211*QR_002020000012+P_000211011*QR_002020000020+P_000211111*QR_002020000021+P_000211211*QR_002020000022); ans_temp[ans_id*36+26]+=Pmtrx[25]*(P_000011011*QR_001021000000+P_000011111*QR_001021000001+P_000011211*QR_001021000002+P_000111011*QR_001021000010+P_000111111*QR_001021000011+P_000111211*QR_001021000012+P_000211011*QR_001021000020+P_000211111*QR_001021000021+P_000211211*QR_001021000022); ans_temp[ans_id*36+26]+=Pmtrx[26]*(P_000011011*QR_000022000000+P_000011111*QR_000022000001+P_000011211*QR_000022000002+P_000111011*QR_000022000010+P_000111111*QR_000022000011+P_000111211*QR_000022000012+P_000211011*QR_000022000020+P_000211111*QR_000022000021+P_000211211*QR_000022000022); ans_temp[ans_id*36+26]+=Pmtrx[27]*(P_000011011*QR_001020001000+P_000011111*QR_001020001001+P_000011211*QR_001020001002+P_000111011*QR_001020001010+P_000111111*QR_001020001011+P_000111211*QR_001020001012+P_000211011*QR_001020001020+P_000211111*QR_001020001021+P_000211211*QR_001020001022); ans_temp[ans_id*36+26]+=Pmtrx[28]*(P_000011011*QR_000021001000+P_000011111*QR_000021001001+P_000011211*QR_000021001002+P_000111011*QR_000021001010+P_000111111*QR_000021001011+P_000111211*QR_000021001012+P_000211011*QR_000021001020+P_000211111*QR_000021001021+P_000211211*QR_000021001022); ans_temp[ans_id*36+26]+=Pmtrx[29]*(P_000011011*QR_000020002000+P_000011111*QR_000020002001+P_000011211*QR_000020002002+P_000111011*QR_000020002010+P_000111111*QR_000020002011+P_000111211*QR_000020002012+P_000211011*QR_000020002020+P_000211111*QR_000020002021+P_000211211*QR_000020002022); ans_temp[ans_id*36+27]+=Pmtrx[24]*(P_000011011*QR_012000010000+P_000011111*QR_012000010001+P_000011211*QR_012000010002+P_000111011*QR_012000010010+P_000111111*QR_012000010011+P_000111211*QR_012000010012+P_000211011*QR_012000010020+P_000211111*QR_012000010021+P_000211211*QR_012000010022); ans_temp[ans_id*36+27]+=Pmtrx[25]*(P_000011011*QR_011001010000+P_000011111*QR_011001010001+P_000011211*QR_011001010002+P_000111011*QR_011001010010+P_000111111*QR_011001010011+P_000111211*QR_011001010012+P_000211011*QR_011001010020+P_000211111*QR_011001010021+P_000211211*QR_011001010022); ans_temp[ans_id*36+27]+=Pmtrx[26]*(P_000011011*QR_010002010000+P_000011111*QR_010002010001+P_000011211*QR_010002010002+P_000111011*QR_010002010010+P_000111111*QR_010002010011+P_000111211*QR_010002010012+P_000211011*QR_010002010020+P_000211111*QR_010002010021+P_000211211*QR_010002010022); ans_temp[ans_id*36+27]+=Pmtrx[27]*(P_000011011*QR_011000011000+P_000011111*QR_011000011001+P_000011211*QR_011000011002+P_000111011*QR_011000011010+P_000111111*QR_011000011011+P_000111211*QR_011000011012+P_000211011*QR_011000011020+P_000211111*QR_011000011021+P_000211211*QR_011000011022); ans_temp[ans_id*36+27]+=Pmtrx[28]*(P_000011011*QR_010001011000+P_000011111*QR_010001011001+P_000011211*QR_010001011002+P_000111011*QR_010001011010+P_000111111*QR_010001011011+P_000111211*QR_010001011012+P_000211011*QR_010001011020+P_000211111*QR_010001011021+P_000211211*QR_010001011022); ans_temp[ans_id*36+27]+=Pmtrx[29]*(P_000011011*QR_010000012000+P_000011111*QR_010000012001+P_000011211*QR_010000012002+P_000111011*QR_010000012010+P_000111111*QR_010000012011+P_000111211*QR_010000012012+P_000211011*QR_010000012020+P_000211111*QR_010000012021+P_000211211*QR_010000012022); ans_temp[ans_id*36+28]+=Pmtrx[24]*(P_000011011*QR_002010010000+P_000011111*QR_002010010001+P_000011211*QR_002010010002+P_000111011*QR_002010010010+P_000111111*QR_002010010011+P_000111211*QR_002010010012+P_000211011*QR_002010010020+P_000211111*QR_002010010021+P_000211211*QR_002010010022); ans_temp[ans_id*36+28]+=Pmtrx[25]*(P_000011011*QR_001011010000+P_000011111*QR_001011010001+P_000011211*QR_001011010002+P_000111011*QR_001011010010+P_000111111*QR_001011010011+P_000111211*QR_001011010012+P_000211011*QR_001011010020+P_000211111*QR_001011010021+P_000211211*QR_001011010022); ans_temp[ans_id*36+28]+=Pmtrx[26]*(P_000011011*QR_000012010000+P_000011111*QR_000012010001+P_000011211*QR_000012010002+P_000111011*QR_000012010010+P_000111111*QR_000012010011+P_000111211*QR_000012010012+P_000211011*QR_000012010020+P_000211111*QR_000012010021+P_000211211*QR_000012010022); ans_temp[ans_id*36+28]+=Pmtrx[27]*(P_000011011*QR_001010011000+P_000011111*QR_001010011001+P_000011211*QR_001010011002+P_000111011*QR_001010011010+P_000111111*QR_001010011011+P_000111211*QR_001010011012+P_000211011*QR_001010011020+P_000211111*QR_001010011021+P_000211211*QR_001010011022); ans_temp[ans_id*36+28]+=Pmtrx[28]*(P_000011011*QR_000011011000+P_000011111*QR_000011011001+P_000011211*QR_000011011002+P_000111011*QR_000011011010+P_000111111*QR_000011011011+P_000111211*QR_000011011012+P_000211011*QR_000011011020+P_000211111*QR_000011011021+P_000211211*QR_000011011022); ans_temp[ans_id*36+28]+=Pmtrx[29]*(P_000011011*QR_000010012000+P_000011111*QR_000010012001+P_000011211*QR_000010012002+P_000111011*QR_000010012010+P_000111111*QR_000010012011+P_000111211*QR_000010012012+P_000211011*QR_000010012020+P_000211111*QR_000010012021+P_000211211*QR_000010012022); ans_temp[ans_id*36+29]+=Pmtrx[24]*(P_000011011*QR_002000020000+P_000011111*QR_002000020001+P_000011211*QR_002000020002+P_000111011*QR_002000020010+P_000111111*QR_002000020011+P_000111211*QR_002000020012+P_000211011*QR_002000020020+P_000211111*QR_002000020021+P_000211211*QR_002000020022); ans_temp[ans_id*36+29]+=Pmtrx[25]*(P_000011011*QR_001001020000+P_000011111*QR_001001020001+P_000011211*QR_001001020002+P_000111011*QR_001001020010+P_000111111*QR_001001020011+P_000111211*QR_001001020012+P_000211011*QR_001001020020+P_000211111*QR_001001020021+P_000211211*QR_001001020022); ans_temp[ans_id*36+29]+=Pmtrx[26]*(P_000011011*QR_000002020000+P_000011111*QR_000002020001+P_000011211*QR_000002020002+P_000111011*QR_000002020010+P_000111111*QR_000002020011+P_000111211*QR_000002020012+P_000211011*QR_000002020020+P_000211111*QR_000002020021+P_000211211*QR_000002020022); ans_temp[ans_id*36+29]+=Pmtrx[27]*(P_000011011*QR_001000021000+P_000011111*QR_001000021001+P_000011211*QR_001000021002+P_000111011*QR_001000021010+P_000111111*QR_001000021011+P_000111211*QR_001000021012+P_000211011*QR_001000021020+P_000211111*QR_001000021021+P_000211211*QR_001000021022); ans_temp[ans_id*36+29]+=Pmtrx[28]*(P_000011011*QR_000001021000+P_000011111*QR_000001021001+P_000011211*QR_000001021002+P_000111011*QR_000001021010+P_000111111*QR_000001021011+P_000111211*QR_000001021012+P_000211011*QR_000001021020+P_000211111*QR_000001021021+P_000211211*QR_000001021022); ans_temp[ans_id*36+29]+=Pmtrx[29]*(P_000011011*QR_000000022000+P_000011111*QR_000000022001+P_000011211*QR_000000022002+P_000111011*QR_000000022010+P_000111111*QR_000000022011+P_000111211*QR_000000022012+P_000211011*QR_000000022020+P_000211111*QR_000000022021+P_000211211*QR_000000022022); ans_temp[ans_id*36+24]+=Pmtrx[30]*(P_000010012*QR_022000000000+P_000010112*QR_022000000001+P_000010212*QR_022000000002+P_000010312*QR_022000000003+P_000110012*QR_022000000010+P_000110112*QR_022000000011+P_000110212*QR_022000000012+P_000110312*QR_022000000013); ans_temp[ans_id*36+24]+=Pmtrx[31]*(P_000010012*QR_021001000000+P_000010112*QR_021001000001+P_000010212*QR_021001000002+P_000010312*QR_021001000003+P_000110012*QR_021001000010+P_000110112*QR_021001000011+P_000110212*QR_021001000012+P_000110312*QR_021001000013); ans_temp[ans_id*36+24]+=Pmtrx[32]*(P_000010012*QR_020002000000+P_000010112*QR_020002000001+P_000010212*QR_020002000002+P_000010312*QR_020002000003+P_000110012*QR_020002000010+P_000110112*QR_020002000011+P_000110212*QR_020002000012+P_000110312*QR_020002000013); ans_temp[ans_id*36+24]+=Pmtrx[33]*(P_000010012*QR_021000001000+P_000010112*QR_021000001001+P_000010212*QR_021000001002+P_000010312*QR_021000001003+P_000110012*QR_021000001010+P_000110112*QR_021000001011+P_000110212*QR_021000001012+P_000110312*QR_021000001013); ans_temp[ans_id*36+24]+=Pmtrx[34]*(P_000010012*QR_020001001000+P_000010112*QR_020001001001+P_000010212*QR_020001001002+P_000010312*QR_020001001003+P_000110012*QR_020001001010+P_000110112*QR_020001001011+P_000110212*QR_020001001012+P_000110312*QR_020001001013); ans_temp[ans_id*36+24]+=Pmtrx[35]*(P_000010012*QR_020000002000+P_000010112*QR_020000002001+P_000010212*QR_020000002002+P_000010312*QR_020000002003+P_000110012*QR_020000002010+P_000110112*QR_020000002011+P_000110212*QR_020000002012+P_000110312*QR_020000002013); ans_temp[ans_id*36+25]+=Pmtrx[30]*(P_000010012*QR_012010000000+P_000010112*QR_012010000001+P_000010212*QR_012010000002+P_000010312*QR_012010000003+P_000110012*QR_012010000010+P_000110112*QR_012010000011+P_000110212*QR_012010000012+P_000110312*QR_012010000013); ans_temp[ans_id*36+25]+=Pmtrx[31]*(P_000010012*QR_011011000000+P_000010112*QR_011011000001+P_000010212*QR_011011000002+P_000010312*QR_011011000003+P_000110012*QR_011011000010+P_000110112*QR_011011000011+P_000110212*QR_011011000012+P_000110312*QR_011011000013); ans_temp[ans_id*36+25]+=Pmtrx[32]*(P_000010012*QR_010012000000+P_000010112*QR_010012000001+P_000010212*QR_010012000002+P_000010312*QR_010012000003+P_000110012*QR_010012000010+P_000110112*QR_010012000011+P_000110212*QR_010012000012+P_000110312*QR_010012000013); ans_temp[ans_id*36+25]+=Pmtrx[33]*(P_000010012*QR_011010001000+P_000010112*QR_011010001001+P_000010212*QR_011010001002+P_000010312*QR_011010001003+P_000110012*QR_011010001010+P_000110112*QR_011010001011+P_000110212*QR_011010001012+P_000110312*QR_011010001013); ans_temp[ans_id*36+25]+=Pmtrx[34]*(P_000010012*QR_010011001000+P_000010112*QR_010011001001+P_000010212*QR_010011001002+P_000010312*QR_010011001003+P_000110012*QR_010011001010+P_000110112*QR_010011001011+P_000110212*QR_010011001012+P_000110312*QR_010011001013); ans_temp[ans_id*36+25]+=Pmtrx[35]*(P_000010012*QR_010010002000+P_000010112*QR_010010002001+P_000010212*QR_010010002002+P_000010312*QR_010010002003+P_000110012*QR_010010002010+P_000110112*QR_010010002011+P_000110212*QR_010010002012+P_000110312*QR_010010002013); ans_temp[ans_id*36+26]+=Pmtrx[30]*(P_000010012*QR_002020000000+P_000010112*QR_002020000001+P_000010212*QR_002020000002+P_000010312*QR_002020000003+P_000110012*QR_002020000010+P_000110112*QR_002020000011+P_000110212*QR_002020000012+P_000110312*QR_002020000013); ans_temp[ans_id*36+26]+=Pmtrx[31]*(P_000010012*QR_001021000000+P_000010112*QR_001021000001+P_000010212*QR_001021000002+P_000010312*QR_001021000003+P_000110012*QR_001021000010+P_000110112*QR_001021000011+P_000110212*QR_001021000012+P_000110312*QR_001021000013); ans_temp[ans_id*36+26]+=Pmtrx[32]*(P_000010012*QR_000022000000+P_000010112*QR_000022000001+P_000010212*QR_000022000002+P_000010312*QR_000022000003+P_000110012*QR_000022000010+P_000110112*QR_000022000011+P_000110212*QR_000022000012+P_000110312*QR_000022000013); ans_temp[ans_id*36+26]+=Pmtrx[33]*(P_000010012*QR_001020001000+P_000010112*QR_001020001001+P_000010212*QR_001020001002+P_000010312*QR_001020001003+P_000110012*QR_001020001010+P_000110112*QR_001020001011+P_000110212*QR_001020001012+P_000110312*QR_001020001013); ans_temp[ans_id*36+26]+=Pmtrx[34]*(P_000010012*QR_000021001000+P_000010112*QR_000021001001+P_000010212*QR_000021001002+P_000010312*QR_000021001003+P_000110012*QR_000021001010+P_000110112*QR_000021001011+P_000110212*QR_000021001012+P_000110312*QR_000021001013); ans_temp[ans_id*36+26]+=Pmtrx[35]*(P_000010012*QR_000020002000+P_000010112*QR_000020002001+P_000010212*QR_000020002002+P_000010312*QR_000020002003+P_000110012*QR_000020002010+P_000110112*QR_000020002011+P_000110212*QR_000020002012+P_000110312*QR_000020002013); ans_temp[ans_id*36+27]+=Pmtrx[30]*(P_000010012*QR_012000010000+P_000010112*QR_012000010001+P_000010212*QR_012000010002+P_000010312*QR_012000010003+P_000110012*QR_012000010010+P_000110112*QR_012000010011+P_000110212*QR_012000010012+P_000110312*QR_012000010013); ans_temp[ans_id*36+27]+=Pmtrx[31]*(P_000010012*QR_011001010000+P_000010112*QR_011001010001+P_000010212*QR_011001010002+P_000010312*QR_011001010003+P_000110012*QR_011001010010+P_000110112*QR_011001010011+P_000110212*QR_011001010012+P_000110312*QR_011001010013); ans_temp[ans_id*36+27]+=Pmtrx[32]*(P_000010012*QR_010002010000+P_000010112*QR_010002010001+P_000010212*QR_010002010002+P_000010312*QR_010002010003+P_000110012*QR_010002010010+P_000110112*QR_010002010011+P_000110212*QR_010002010012+P_000110312*QR_010002010013); ans_temp[ans_id*36+27]+=Pmtrx[33]*(P_000010012*QR_011000011000+P_000010112*QR_011000011001+P_000010212*QR_011000011002+P_000010312*QR_011000011003+P_000110012*QR_011000011010+P_000110112*QR_011000011011+P_000110212*QR_011000011012+P_000110312*QR_011000011013); ans_temp[ans_id*36+27]+=Pmtrx[34]*(P_000010012*QR_010001011000+P_000010112*QR_010001011001+P_000010212*QR_010001011002+P_000010312*QR_010001011003+P_000110012*QR_010001011010+P_000110112*QR_010001011011+P_000110212*QR_010001011012+P_000110312*QR_010001011013); ans_temp[ans_id*36+27]+=Pmtrx[35]*(P_000010012*QR_010000012000+P_000010112*QR_010000012001+P_000010212*QR_010000012002+P_000010312*QR_010000012003+P_000110012*QR_010000012010+P_000110112*QR_010000012011+P_000110212*QR_010000012012+P_000110312*QR_010000012013); ans_temp[ans_id*36+28]+=Pmtrx[30]*(P_000010012*QR_002010010000+P_000010112*QR_002010010001+P_000010212*QR_002010010002+P_000010312*QR_002010010003+P_000110012*QR_002010010010+P_000110112*QR_002010010011+P_000110212*QR_002010010012+P_000110312*QR_002010010013); ans_temp[ans_id*36+28]+=Pmtrx[31]*(P_000010012*QR_001011010000+P_000010112*QR_001011010001+P_000010212*QR_001011010002+P_000010312*QR_001011010003+P_000110012*QR_001011010010+P_000110112*QR_001011010011+P_000110212*QR_001011010012+P_000110312*QR_001011010013); ans_temp[ans_id*36+28]+=Pmtrx[32]*(P_000010012*QR_000012010000+P_000010112*QR_000012010001+P_000010212*QR_000012010002+P_000010312*QR_000012010003+P_000110012*QR_000012010010+P_000110112*QR_000012010011+P_000110212*QR_000012010012+P_000110312*QR_000012010013); ans_temp[ans_id*36+28]+=Pmtrx[33]*(P_000010012*QR_001010011000+P_000010112*QR_001010011001+P_000010212*QR_001010011002+P_000010312*QR_001010011003+P_000110012*QR_001010011010+P_000110112*QR_001010011011+P_000110212*QR_001010011012+P_000110312*QR_001010011013); ans_temp[ans_id*36+28]+=Pmtrx[34]*(P_000010012*QR_000011011000+P_000010112*QR_000011011001+P_000010212*QR_000011011002+P_000010312*QR_000011011003+P_000110012*QR_000011011010+P_000110112*QR_000011011011+P_000110212*QR_000011011012+P_000110312*QR_000011011013); ans_temp[ans_id*36+28]+=Pmtrx[35]*(P_000010012*QR_000010012000+P_000010112*QR_000010012001+P_000010212*QR_000010012002+P_000010312*QR_000010012003+P_000110012*QR_000010012010+P_000110112*QR_000010012011+P_000110212*QR_000010012012+P_000110312*QR_000010012013); ans_temp[ans_id*36+29]+=Pmtrx[30]*(P_000010012*QR_002000020000+P_000010112*QR_002000020001+P_000010212*QR_002000020002+P_000010312*QR_002000020003+P_000110012*QR_002000020010+P_000110112*QR_002000020011+P_000110212*QR_002000020012+P_000110312*QR_002000020013); ans_temp[ans_id*36+29]+=Pmtrx[31]*(P_000010012*QR_001001020000+P_000010112*QR_001001020001+P_000010212*QR_001001020002+P_000010312*QR_001001020003+P_000110012*QR_001001020010+P_000110112*QR_001001020011+P_000110212*QR_001001020012+P_000110312*QR_001001020013); ans_temp[ans_id*36+29]+=Pmtrx[32]*(P_000010012*QR_000002020000+P_000010112*QR_000002020001+P_000010212*QR_000002020002+P_000010312*QR_000002020003+P_000110012*QR_000002020010+P_000110112*QR_000002020011+P_000110212*QR_000002020012+P_000110312*QR_000002020013); ans_temp[ans_id*36+29]+=Pmtrx[33]*(P_000010012*QR_001000021000+P_000010112*QR_001000021001+P_000010212*QR_001000021002+P_000010312*QR_001000021003+P_000110012*QR_001000021010+P_000110112*QR_001000021011+P_000110212*QR_001000021012+P_000110312*QR_001000021013); ans_temp[ans_id*36+29]+=Pmtrx[34]*(P_000010012*QR_000001021000+P_000010112*QR_000001021001+P_000010212*QR_000001021002+P_000010312*QR_000001021003+P_000110012*QR_000001021010+P_000110112*QR_000001021011+P_000110212*QR_000001021012+P_000110312*QR_000001021013); ans_temp[ans_id*36+29]+=Pmtrx[35]*(P_000010012*QR_000000022000+P_000010112*QR_000000022001+P_000010212*QR_000000022002+P_000010312*QR_000000022003+P_000110012*QR_000000022010+P_000110112*QR_000000022011+P_000110212*QR_000000022012+P_000110312*QR_000000022013); ans_temp[ans_id*36+30]+=Pmtrx[0]*(P_002000020*QR_022000000000+P_002000120*QR_022000000001+P_002000220*QR_022000000002+P_102000020*QR_022000000100+P_102000120*QR_022000000101+P_102000220*QR_022000000102+P_202000020*QR_022000000200+P_202000120*QR_022000000201+P_202000220*QR_022000000202); ans_temp[ans_id*36+30]+=Pmtrx[1]*(P_002000020*QR_021001000000+P_002000120*QR_021001000001+P_002000220*QR_021001000002+P_102000020*QR_021001000100+P_102000120*QR_021001000101+P_102000220*QR_021001000102+P_202000020*QR_021001000200+P_202000120*QR_021001000201+P_202000220*QR_021001000202); ans_temp[ans_id*36+30]+=Pmtrx[2]*(P_002000020*QR_020002000000+P_002000120*QR_020002000001+P_002000220*QR_020002000002+P_102000020*QR_020002000100+P_102000120*QR_020002000101+P_102000220*QR_020002000102+P_202000020*QR_020002000200+P_202000120*QR_020002000201+P_202000220*QR_020002000202); ans_temp[ans_id*36+30]+=Pmtrx[3]*(P_002000020*QR_021000001000+P_002000120*QR_021000001001+P_002000220*QR_021000001002+P_102000020*QR_021000001100+P_102000120*QR_021000001101+P_102000220*QR_021000001102+P_202000020*QR_021000001200+P_202000120*QR_021000001201+P_202000220*QR_021000001202); ans_temp[ans_id*36+30]+=Pmtrx[4]*(P_002000020*QR_020001001000+P_002000120*QR_020001001001+P_002000220*QR_020001001002+P_102000020*QR_020001001100+P_102000120*QR_020001001101+P_102000220*QR_020001001102+P_202000020*QR_020001001200+P_202000120*QR_020001001201+P_202000220*QR_020001001202); ans_temp[ans_id*36+30]+=Pmtrx[5]*(P_002000020*QR_020000002000+P_002000120*QR_020000002001+P_002000220*QR_020000002002+P_102000020*QR_020000002100+P_102000120*QR_020000002101+P_102000220*QR_020000002102+P_202000020*QR_020000002200+P_202000120*QR_020000002201+P_202000220*QR_020000002202); ans_temp[ans_id*36+31]+=Pmtrx[0]*(P_002000020*QR_012010000000+P_002000120*QR_012010000001+P_002000220*QR_012010000002+P_102000020*QR_012010000100+P_102000120*QR_012010000101+P_102000220*QR_012010000102+P_202000020*QR_012010000200+P_202000120*QR_012010000201+P_202000220*QR_012010000202); ans_temp[ans_id*36+31]+=Pmtrx[1]*(P_002000020*QR_011011000000+P_002000120*QR_011011000001+P_002000220*QR_011011000002+P_102000020*QR_011011000100+P_102000120*QR_011011000101+P_102000220*QR_011011000102+P_202000020*QR_011011000200+P_202000120*QR_011011000201+P_202000220*QR_011011000202); ans_temp[ans_id*36+31]+=Pmtrx[2]*(P_002000020*QR_010012000000+P_002000120*QR_010012000001+P_002000220*QR_010012000002+P_102000020*QR_010012000100+P_102000120*QR_010012000101+P_102000220*QR_010012000102+P_202000020*QR_010012000200+P_202000120*QR_010012000201+P_202000220*QR_010012000202); ans_temp[ans_id*36+31]+=Pmtrx[3]*(P_002000020*QR_011010001000+P_002000120*QR_011010001001+P_002000220*QR_011010001002+P_102000020*QR_011010001100+P_102000120*QR_011010001101+P_102000220*QR_011010001102+P_202000020*QR_011010001200+P_202000120*QR_011010001201+P_202000220*QR_011010001202); ans_temp[ans_id*36+31]+=Pmtrx[4]*(P_002000020*QR_010011001000+P_002000120*QR_010011001001+P_002000220*QR_010011001002+P_102000020*QR_010011001100+P_102000120*QR_010011001101+P_102000220*QR_010011001102+P_202000020*QR_010011001200+P_202000120*QR_010011001201+P_202000220*QR_010011001202); ans_temp[ans_id*36+31]+=Pmtrx[5]*(P_002000020*QR_010010002000+P_002000120*QR_010010002001+P_002000220*QR_010010002002+P_102000020*QR_010010002100+P_102000120*QR_010010002101+P_102000220*QR_010010002102+P_202000020*QR_010010002200+P_202000120*QR_010010002201+P_202000220*QR_010010002202); ans_temp[ans_id*36+32]+=Pmtrx[0]*(P_002000020*QR_002020000000+P_002000120*QR_002020000001+P_002000220*QR_002020000002+P_102000020*QR_002020000100+P_102000120*QR_002020000101+P_102000220*QR_002020000102+P_202000020*QR_002020000200+P_202000120*QR_002020000201+P_202000220*QR_002020000202); ans_temp[ans_id*36+32]+=Pmtrx[1]*(P_002000020*QR_001021000000+P_002000120*QR_001021000001+P_002000220*QR_001021000002+P_102000020*QR_001021000100+P_102000120*QR_001021000101+P_102000220*QR_001021000102+P_202000020*QR_001021000200+P_202000120*QR_001021000201+P_202000220*QR_001021000202); ans_temp[ans_id*36+32]+=Pmtrx[2]*(P_002000020*QR_000022000000+P_002000120*QR_000022000001+P_002000220*QR_000022000002+P_102000020*QR_000022000100+P_102000120*QR_000022000101+P_102000220*QR_000022000102+P_202000020*QR_000022000200+P_202000120*QR_000022000201+P_202000220*QR_000022000202); ans_temp[ans_id*36+32]+=Pmtrx[3]*(P_002000020*QR_001020001000+P_002000120*QR_001020001001+P_002000220*QR_001020001002+P_102000020*QR_001020001100+P_102000120*QR_001020001101+P_102000220*QR_001020001102+P_202000020*QR_001020001200+P_202000120*QR_001020001201+P_202000220*QR_001020001202); ans_temp[ans_id*36+32]+=Pmtrx[4]*(P_002000020*QR_000021001000+P_002000120*QR_000021001001+P_002000220*QR_000021001002+P_102000020*QR_000021001100+P_102000120*QR_000021001101+P_102000220*QR_000021001102+P_202000020*QR_000021001200+P_202000120*QR_000021001201+P_202000220*QR_000021001202); ans_temp[ans_id*36+32]+=Pmtrx[5]*(P_002000020*QR_000020002000+P_002000120*QR_000020002001+P_002000220*QR_000020002002+P_102000020*QR_000020002100+P_102000120*QR_000020002101+P_102000220*QR_000020002102+P_202000020*QR_000020002200+P_202000120*QR_000020002201+P_202000220*QR_000020002202); ans_temp[ans_id*36+33]+=Pmtrx[0]*(P_002000020*QR_012000010000+P_002000120*QR_012000010001+P_002000220*QR_012000010002+P_102000020*QR_012000010100+P_102000120*QR_012000010101+P_102000220*QR_012000010102+P_202000020*QR_012000010200+P_202000120*QR_012000010201+P_202000220*QR_012000010202); ans_temp[ans_id*36+33]+=Pmtrx[1]*(P_002000020*QR_011001010000+P_002000120*QR_011001010001+P_002000220*QR_011001010002+P_102000020*QR_011001010100+P_102000120*QR_011001010101+P_102000220*QR_011001010102+P_202000020*QR_011001010200+P_202000120*QR_011001010201+P_202000220*QR_011001010202); ans_temp[ans_id*36+33]+=Pmtrx[2]*(P_002000020*QR_010002010000+P_002000120*QR_010002010001+P_002000220*QR_010002010002+P_102000020*QR_010002010100+P_102000120*QR_010002010101+P_102000220*QR_010002010102+P_202000020*QR_010002010200+P_202000120*QR_010002010201+P_202000220*QR_010002010202); ans_temp[ans_id*36+33]+=Pmtrx[3]*(P_002000020*QR_011000011000+P_002000120*QR_011000011001+P_002000220*QR_011000011002+P_102000020*QR_011000011100+P_102000120*QR_011000011101+P_102000220*QR_011000011102+P_202000020*QR_011000011200+P_202000120*QR_011000011201+P_202000220*QR_011000011202); ans_temp[ans_id*36+33]+=Pmtrx[4]*(P_002000020*QR_010001011000+P_002000120*QR_010001011001+P_002000220*QR_010001011002+P_102000020*QR_010001011100+P_102000120*QR_010001011101+P_102000220*QR_010001011102+P_202000020*QR_010001011200+P_202000120*QR_010001011201+P_202000220*QR_010001011202); ans_temp[ans_id*36+33]+=Pmtrx[5]*(P_002000020*QR_010000012000+P_002000120*QR_010000012001+P_002000220*QR_010000012002+P_102000020*QR_010000012100+P_102000120*QR_010000012101+P_102000220*QR_010000012102+P_202000020*QR_010000012200+P_202000120*QR_010000012201+P_202000220*QR_010000012202); ans_temp[ans_id*36+34]+=Pmtrx[0]*(P_002000020*QR_002010010000+P_002000120*QR_002010010001+P_002000220*QR_002010010002+P_102000020*QR_002010010100+P_102000120*QR_002010010101+P_102000220*QR_002010010102+P_202000020*QR_002010010200+P_202000120*QR_002010010201+P_202000220*QR_002010010202); ans_temp[ans_id*36+34]+=Pmtrx[1]*(P_002000020*QR_001011010000+P_002000120*QR_001011010001+P_002000220*QR_001011010002+P_102000020*QR_001011010100+P_102000120*QR_001011010101+P_102000220*QR_001011010102+P_202000020*QR_001011010200+P_202000120*QR_001011010201+P_202000220*QR_001011010202); ans_temp[ans_id*36+34]+=Pmtrx[2]*(P_002000020*QR_000012010000+P_002000120*QR_000012010001+P_002000220*QR_000012010002+P_102000020*QR_000012010100+P_102000120*QR_000012010101+P_102000220*QR_000012010102+P_202000020*QR_000012010200+P_202000120*QR_000012010201+P_202000220*QR_000012010202); ans_temp[ans_id*36+34]+=Pmtrx[3]*(P_002000020*QR_001010011000+P_002000120*QR_001010011001+P_002000220*QR_001010011002+P_102000020*QR_001010011100+P_102000120*QR_001010011101+P_102000220*QR_001010011102+P_202000020*QR_001010011200+P_202000120*QR_001010011201+P_202000220*QR_001010011202); ans_temp[ans_id*36+34]+=Pmtrx[4]*(P_002000020*QR_000011011000+P_002000120*QR_000011011001+P_002000220*QR_000011011002+P_102000020*QR_000011011100+P_102000120*QR_000011011101+P_102000220*QR_000011011102+P_202000020*QR_000011011200+P_202000120*QR_000011011201+P_202000220*QR_000011011202); ans_temp[ans_id*36+34]+=Pmtrx[5]*(P_002000020*QR_000010012000+P_002000120*QR_000010012001+P_002000220*QR_000010012002+P_102000020*QR_000010012100+P_102000120*QR_000010012101+P_102000220*QR_000010012102+P_202000020*QR_000010012200+P_202000120*QR_000010012201+P_202000220*QR_000010012202); ans_temp[ans_id*36+35]+=Pmtrx[0]*(P_002000020*QR_002000020000+P_002000120*QR_002000020001+P_002000220*QR_002000020002+P_102000020*QR_002000020100+P_102000120*QR_002000020101+P_102000220*QR_002000020102+P_202000020*QR_002000020200+P_202000120*QR_002000020201+P_202000220*QR_002000020202); ans_temp[ans_id*36+35]+=Pmtrx[1]*(P_002000020*QR_001001020000+P_002000120*QR_001001020001+P_002000220*QR_001001020002+P_102000020*QR_001001020100+P_102000120*QR_001001020101+P_102000220*QR_001001020102+P_202000020*QR_001001020200+P_202000120*QR_001001020201+P_202000220*QR_001001020202); ans_temp[ans_id*36+35]+=Pmtrx[2]*(P_002000020*QR_000002020000+P_002000120*QR_000002020001+P_002000220*QR_000002020002+P_102000020*QR_000002020100+P_102000120*QR_000002020101+P_102000220*QR_000002020102+P_202000020*QR_000002020200+P_202000120*QR_000002020201+P_202000220*QR_000002020202); ans_temp[ans_id*36+35]+=Pmtrx[3]*(P_002000020*QR_001000021000+P_002000120*QR_001000021001+P_002000220*QR_001000021002+P_102000020*QR_001000021100+P_102000120*QR_001000021101+P_102000220*QR_001000021102+P_202000020*QR_001000021200+P_202000120*QR_001000021201+P_202000220*QR_001000021202); ans_temp[ans_id*36+35]+=Pmtrx[4]*(P_002000020*QR_000001021000+P_002000120*QR_000001021001+P_002000220*QR_000001021002+P_102000020*QR_000001021100+P_102000120*QR_000001021101+P_102000220*QR_000001021102+P_202000020*QR_000001021200+P_202000120*QR_000001021201+P_202000220*QR_000001021202); ans_temp[ans_id*36+35]+=Pmtrx[5]*(P_002000020*QR_000000022000+P_002000120*QR_000000022001+P_002000220*QR_000000022002+P_102000020*QR_000000022100+P_102000120*QR_000000022101+P_102000220*QR_000000022102+P_202000020*QR_000000022200+P_202000120*QR_000000022201+P_202000220*QR_000000022202); ans_temp[ans_id*36+30]+=Pmtrx[6]*(P_001001020*QR_022000000000+P_001001120*QR_022000000001+P_001001220*QR_022000000002+P_001101020*QR_022000000010+P_001101120*QR_022000000011+P_001101220*QR_022000000012+P_101001020*QR_022000000100+P_101001120*QR_022000000101+P_101001220*QR_022000000102+P_101101020*QR_022000000110+P_101101120*QR_022000000111+P_101101220*QR_022000000112); ans_temp[ans_id*36+30]+=Pmtrx[7]*(P_001001020*QR_021001000000+P_001001120*QR_021001000001+P_001001220*QR_021001000002+P_001101020*QR_021001000010+P_001101120*QR_021001000011+P_001101220*QR_021001000012+P_101001020*QR_021001000100+P_101001120*QR_021001000101+P_101001220*QR_021001000102+P_101101020*QR_021001000110+P_101101120*QR_021001000111+P_101101220*QR_021001000112); ans_temp[ans_id*36+30]+=Pmtrx[8]*(P_001001020*QR_020002000000+P_001001120*QR_020002000001+P_001001220*QR_020002000002+P_001101020*QR_020002000010+P_001101120*QR_020002000011+P_001101220*QR_020002000012+P_101001020*QR_020002000100+P_101001120*QR_020002000101+P_101001220*QR_020002000102+P_101101020*QR_020002000110+P_101101120*QR_020002000111+P_101101220*QR_020002000112); ans_temp[ans_id*36+30]+=Pmtrx[9]*(P_001001020*QR_021000001000+P_001001120*QR_021000001001+P_001001220*QR_021000001002+P_001101020*QR_021000001010+P_001101120*QR_021000001011+P_001101220*QR_021000001012+P_101001020*QR_021000001100+P_101001120*QR_021000001101+P_101001220*QR_021000001102+P_101101020*QR_021000001110+P_101101120*QR_021000001111+P_101101220*QR_021000001112); ans_temp[ans_id*36+30]+=Pmtrx[10]*(P_001001020*QR_020001001000+P_001001120*QR_020001001001+P_001001220*QR_020001001002+P_001101020*QR_020001001010+P_001101120*QR_020001001011+P_001101220*QR_020001001012+P_101001020*QR_020001001100+P_101001120*QR_020001001101+P_101001220*QR_020001001102+P_101101020*QR_020001001110+P_101101120*QR_020001001111+P_101101220*QR_020001001112); ans_temp[ans_id*36+30]+=Pmtrx[11]*(P_001001020*QR_020000002000+P_001001120*QR_020000002001+P_001001220*QR_020000002002+P_001101020*QR_020000002010+P_001101120*QR_020000002011+P_001101220*QR_020000002012+P_101001020*QR_020000002100+P_101001120*QR_020000002101+P_101001220*QR_020000002102+P_101101020*QR_020000002110+P_101101120*QR_020000002111+P_101101220*QR_020000002112); ans_temp[ans_id*36+31]+=Pmtrx[6]*(P_001001020*QR_012010000000+P_001001120*QR_012010000001+P_001001220*QR_012010000002+P_001101020*QR_012010000010+P_001101120*QR_012010000011+P_001101220*QR_012010000012+P_101001020*QR_012010000100+P_101001120*QR_012010000101+P_101001220*QR_012010000102+P_101101020*QR_012010000110+P_101101120*QR_012010000111+P_101101220*QR_012010000112); ans_temp[ans_id*36+31]+=Pmtrx[7]*(P_001001020*QR_011011000000+P_001001120*QR_011011000001+P_001001220*QR_011011000002+P_001101020*QR_011011000010+P_001101120*QR_011011000011+P_001101220*QR_011011000012+P_101001020*QR_011011000100+P_101001120*QR_011011000101+P_101001220*QR_011011000102+P_101101020*QR_011011000110+P_101101120*QR_011011000111+P_101101220*QR_011011000112); ans_temp[ans_id*36+31]+=Pmtrx[8]*(P_001001020*QR_010012000000+P_001001120*QR_010012000001+P_001001220*QR_010012000002+P_001101020*QR_010012000010+P_001101120*QR_010012000011+P_001101220*QR_010012000012+P_101001020*QR_010012000100+P_101001120*QR_010012000101+P_101001220*QR_010012000102+P_101101020*QR_010012000110+P_101101120*QR_010012000111+P_101101220*QR_010012000112); ans_temp[ans_id*36+31]+=Pmtrx[9]*(P_001001020*QR_011010001000+P_001001120*QR_011010001001+P_001001220*QR_011010001002+P_001101020*QR_011010001010+P_001101120*QR_011010001011+P_001101220*QR_011010001012+P_101001020*QR_011010001100+P_101001120*QR_011010001101+P_101001220*QR_011010001102+P_101101020*QR_011010001110+P_101101120*QR_011010001111+P_101101220*QR_011010001112); ans_temp[ans_id*36+31]+=Pmtrx[10]*(P_001001020*QR_010011001000+P_001001120*QR_010011001001+P_001001220*QR_010011001002+P_001101020*QR_010011001010+P_001101120*QR_010011001011+P_001101220*QR_010011001012+P_101001020*QR_010011001100+P_101001120*QR_010011001101+P_101001220*QR_010011001102+P_101101020*QR_010011001110+P_101101120*QR_010011001111+P_101101220*QR_010011001112); ans_temp[ans_id*36+31]+=Pmtrx[11]*(P_001001020*QR_010010002000+P_001001120*QR_010010002001+P_001001220*QR_010010002002+P_001101020*QR_010010002010+P_001101120*QR_010010002011+P_001101220*QR_010010002012+P_101001020*QR_010010002100+P_101001120*QR_010010002101+P_101001220*QR_010010002102+P_101101020*QR_010010002110+P_101101120*QR_010010002111+P_101101220*QR_010010002112); ans_temp[ans_id*36+32]+=Pmtrx[6]*(P_001001020*QR_002020000000+P_001001120*QR_002020000001+P_001001220*QR_002020000002+P_001101020*QR_002020000010+P_001101120*QR_002020000011+P_001101220*QR_002020000012+P_101001020*QR_002020000100+P_101001120*QR_002020000101+P_101001220*QR_002020000102+P_101101020*QR_002020000110+P_101101120*QR_002020000111+P_101101220*QR_002020000112); ans_temp[ans_id*36+32]+=Pmtrx[7]*(P_001001020*QR_001021000000+P_001001120*QR_001021000001+P_001001220*QR_001021000002+P_001101020*QR_001021000010+P_001101120*QR_001021000011+P_001101220*QR_001021000012+P_101001020*QR_001021000100+P_101001120*QR_001021000101+P_101001220*QR_001021000102+P_101101020*QR_001021000110+P_101101120*QR_001021000111+P_101101220*QR_001021000112); ans_temp[ans_id*36+32]+=Pmtrx[8]*(P_001001020*QR_000022000000+P_001001120*QR_000022000001+P_001001220*QR_000022000002+P_001101020*QR_000022000010+P_001101120*QR_000022000011+P_001101220*QR_000022000012+P_101001020*QR_000022000100+P_101001120*QR_000022000101+P_101001220*QR_000022000102+P_101101020*QR_000022000110+P_101101120*QR_000022000111+P_101101220*QR_000022000112); ans_temp[ans_id*36+32]+=Pmtrx[9]*(P_001001020*QR_001020001000+P_001001120*QR_001020001001+P_001001220*QR_001020001002+P_001101020*QR_001020001010+P_001101120*QR_001020001011+P_001101220*QR_001020001012+P_101001020*QR_001020001100+P_101001120*QR_001020001101+P_101001220*QR_001020001102+P_101101020*QR_001020001110+P_101101120*QR_001020001111+P_101101220*QR_001020001112); ans_temp[ans_id*36+32]+=Pmtrx[10]*(P_001001020*QR_000021001000+P_001001120*QR_000021001001+P_001001220*QR_000021001002+P_001101020*QR_000021001010+P_001101120*QR_000021001011+P_001101220*QR_000021001012+P_101001020*QR_000021001100+P_101001120*QR_000021001101+P_101001220*QR_000021001102+P_101101020*QR_000021001110+P_101101120*QR_000021001111+P_101101220*QR_000021001112); ans_temp[ans_id*36+32]+=Pmtrx[11]*(P_001001020*QR_000020002000+P_001001120*QR_000020002001+P_001001220*QR_000020002002+P_001101020*QR_000020002010+P_001101120*QR_000020002011+P_001101220*QR_000020002012+P_101001020*QR_000020002100+P_101001120*QR_000020002101+P_101001220*QR_000020002102+P_101101020*QR_000020002110+P_101101120*QR_000020002111+P_101101220*QR_000020002112); ans_temp[ans_id*36+33]+=Pmtrx[6]*(P_001001020*QR_012000010000+P_001001120*QR_012000010001+P_001001220*QR_012000010002+P_001101020*QR_012000010010+P_001101120*QR_012000010011+P_001101220*QR_012000010012+P_101001020*QR_012000010100+P_101001120*QR_012000010101+P_101001220*QR_012000010102+P_101101020*QR_012000010110+P_101101120*QR_012000010111+P_101101220*QR_012000010112); ans_temp[ans_id*36+33]+=Pmtrx[7]*(P_001001020*QR_011001010000+P_001001120*QR_011001010001+P_001001220*QR_011001010002+P_001101020*QR_011001010010+P_001101120*QR_011001010011+P_001101220*QR_011001010012+P_101001020*QR_011001010100+P_101001120*QR_011001010101+P_101001220*QR_011001010102+P_101101020*QR_011001010110+P_101101120*QR_011001010111+P_101101220*QR_011001010112); ans_temp[ans_id*36+33]+=Pmtrx[8]*(P_001001020*QR_010002010000+P_001001120*QR_010002010001+P_001001220*QR_010002010002+P_001101020*QR_010002010010+P_001101120*QR_010002010011+P_001101220*QR_010002010012+P_101001020*QR_010002010100+P_101001120*QR_010002010101+P_101001220*QR_010002010102+P_101101020*QR_010002010110+P_101101120*QR_010002010111+P_101101220*QR_010002010112); ans_temp[ans_id*36+33]+=Pmtrx[9]*(P_001001020*QR_011000011000+P_001001120*QR_011000011001+P_001001220*QR_011000011002+P_001101020*QR_011000011010+P_001101120*QR_011000011011+P_001101220*QR_011000011012+P_101001020*QR_011000011100+P_101001120*QR_011000011101+P_101001220*QR_011000011102+P_101101020*QR_011000011110+P_101101120*QR_011000011111+P_101101220*QR_011000011112); ans_temp[ans_id*36+33]+=Pmtrx[10]*(P_001001020*QR_010001011000+P_001001120*QR_010001011001+P_001001220*QR_010001011002+P_001101020*QR_010001011010+P_001101120*QR_010001011011+P_001101220*QR_010001011012+P_101001020*QR_010001011100+P_101001120*QR_010001011101+P_101001220*QR_010001011102+P_101101020*QR_010001011110+P_101101120*QR_010001011111+P_101101220*QR_010001011112); ans_temp[ans_id*36+33]+=Pmtrx[11]*(P_001001020*QR_010000012000+P_001001120*QR_010000012001+P_001001220*QR_010000012002+P_001101020*QR_010000012010+P_001101120*QR_010000012011+P_001101220*QR_010000012012+P_101001020*QR_010000012100+P_101001120*QR_010000012101+P_101001220*QR_010000012102+P_101101020*QR_010000012110+P_101101120*QR_010000012111+P_101101220*QR_010000012112); ans_temp[ans_id*36+34]+=Pmtrx[6]*(P_001001020*QR_002010010000+P_001001120*QR_002010010001+P_001001220*QR_002010010002+P_001101020*QR_002010010010+P_001101120*QR_002010010011+P_001101220*QR_002010010012+P_101001020*QR_002010010100+P_101001120*QR_002010010101+P_101001220*QR_002010010102+P_101101020*QR_002010010110+P_101101120*QR_002010010111+P_101101220*QR_002010010112); ans_temp[ans_id*36+34]+=Pmtrx[7]*(P_001001020*QR_001011010000+P_001001120*QR_001011010001+P_001001220*QR_001011010002+P_001101020*QR_001011010010+P_001101120*QR_001011010011+P_001101220*QR_001011010012+P_101001020*QR_001011010100+P_101001120*QR_001011010101+P_101001220*QR_001011010102+P_101101020*QR_001011010110+P_101101120*QR_001011010111+P_101101220*QR_001011010112); ans_temp[ans_id*36+34]+=Pmtrx[8]*(P_001001020*QR_000012010000+P_001001120*QR_000012010001+P_001001220*QR_000012010002+P_001101020*QR_000012010010+P_001101120*QR_000012010011+P_001101220*QR_000012010012+P_101001020*QR_000012010100+P_101001120*QR_000012010101+P_101001220*QR_000012010102+P_101101020*QR_000012010110+P_101101120*QR_000012010111+P_101101220*QR_000012010112); ans_temp[ans_id*36+34]+=Pmtrx[9]*(P_001001020*QR_001010011000+P_001001120*QR_001010011001+P_001001220*QR_001010011002+P_001101020*QR_001010011010+P_001101120*QR_001010011011+P_001101220*QR_001010011012+P_101001020*QR_001010011100+P_101001120*QR_001010011101+P_101001220*QR_001010011102+P_101101020*QR_001010011110+P_101101120*QR_001010011111+P_101101220*QR_001010011112); ans_temp[ans_id*36+34]+=Pmtrx[10]*(P_001001020*QR_000011011000+P_001001120*QR_000011011001+P_001001220*QR_000011011002+P_001101020*QR_000011011010+P_001101120*QR_000011011011+P_001101220*QR_000011011012+P_101001020*QR_000011011100+P_101001120*QR_000011011101+P_101001220*QR_000011011102+P_101101020*QR_000011011110+P_101101120*QR_000011011111+P_101101220*QR_000011011112); ans_temp[ans_id*36+34]+=Pmtrx[11]*(P_001001020*QR_000010012000+P_001001120*QR_000010012001+P_001001220*QR_000010012002+P_001101020*QR_000010012010+P_001101120*QR_000010012011+P_001101220*QR_000010012012+P_101001020*QR_000010012100+P_101001120*QR_000010012101+P_101001220*QR_000010012102+P_101101020*QR_000010012110+P_101101120*QR_000010012111+P_101101220*QR_000010012112); ans_temp[ans_id*36+35]+=Pmtrx[6]*(P_001001020*QR_002000020000+P_001001120*QR_002000020001+P_001001220*QR_002000020002+P_001101020*QR_002000020010+P_001101120*QR_002000020011+P_001101220*QR_002000020012+P_101001020*QR_002000020100+P_101001120*QR_002000020101+P_101001220*QR_002000020102+P_101101020*QR_002000020110+P_101101120*QR_002000020111+P_101101220*QR_002000020112); ans_temp[ans_id*36+35]+=Pmtrx[7]*(P_001001020*QR_001001020000+P_001001120*QR_001001020001+P_001001220*QR_001001020002+P_001101020*QR_001001020010+P_001101120*QR_001001020011+P_001101220*QR_001001020012+P_101001020*QR_001001020100+P_101001120*QR_001001020101+P_101001220*QR_001001020102+P_101101020*QR_001001020110+P_101101120*QR_001001020111+P_101101220*QR_001001020112); ans_temp[ans_id*36+35]+=Pmtrx[8]*(P_001001020*QR_000002020000+P_001001120*QR_000002020001+P_001001220*QR_000002020002+P_001101020*QR_000002020010+P_001101120*QR_000002020011+P_001101220*QR_000002020012+P_101001020*QR_000002020100+P_101001120*QR_000002020101+P_101001220*QR_000002020102+P_101101020*QR_000002020110+P_101101120*QR_000002020111+P_101101220*QR_000002020112); ans_temp[ans_id*36+35]+=Pmtrx[9]*(P_001001020*QR_001000021000+P_001001120*QR_001000021001+P_001001220*QR_001000021002+P_001101020*QR_001000021010+P_001101120*QR_001000021011+P_001101220*QR_001000021012+P_101001020*QR_001000021100+P_101001120*QR_001000021101+P_101001220*QR_001000021102+P_101101020*QR_001000021110+P_101101120*QR_001000021111+P_101101220*QR_001000021112); ans_temp[ans_id*36+35]+=Pmtrx[10]*(P_001001020*QR_000001021000+P_001001120*QR_000001021001+P_001001220*QR_000001021002+P_001101020*QR_000001021010+P_001101120*QR_000001021011+P_001101220*QR_000001021012+P_101001020*QR_000001021100+P_101001120*QR_000001021101+P_101001220*QR_000001021102+P_101101020*QR_000001021110+P_101101120*QR_000001021111+P_101101220*QR_000001021112); ans_temp[ans_id*36+35]+=Pmtrx[11]*(P_001001020*QR_000000022000+P_001001120*QR_000000022001+P_001001220*QR_000000022002+P_001101020*QR_000000022010+P_001101120*QR_000000022011+P_001101220*QR_000000022012+P_101001020*QR_000000022100+P_101001120*QR_000000022101+P_101001220*QR_000000022102+P_101101020*QR_000000022110+P_101101120*QR_000000022111+P_101101220*QR_000000022112); ans_temp[ans_id*36+30]+=Pmtrx[12]*(P_000002020*QR_022000000000+P_000002120*QR_022000000001+P_000002220*QR_022000000002+P_000102020*QR_022000000010+P_000102120*QR_022000000011+P_000102220*QR_022000000012+P_000202020*QR_022000000020+P_000202120*QR_022000000021+P_000202220*QR_022000000022); ans_temp[ans_id*36+30]+=Pmtrx[13]*(P_000002020*QR_021001000000+P_000002120*QR_021001000001+P_000002220*QR_021001000002+P_000102020*QR_021001000010+P_000102120*QR_021001000011+P_000102220*QR_021001000012+P_000202020*QR_021001000020+P_000202120*QR_021001000021+P_000202220*QR_021001000022); ans_temp[ans_id*36+30]+=Pmtrx[14]*(P_000002020*QR_020002000000+P_000002120*QR_020002000001+P_000002220*QR_020002000002+P_000102020*QR_020002000010+P_000102120*QR_020002000011+P_000102220*QR_020002000012+P_000202020*QR_020002000020+P_000202120*QR_020002000021+P_000202220*QR_020002000022); ans_temp[ans_id*36+30]+=Pmtrx[15]*(P_000002020*QR_021000001000+P_000002120*QR_021000001001+P_000002220*QR_021000001002+P_000102020*QR_021000001010+P_000102120*QR_021000001011+P_000102220*QR_021000001012+P_000202020*QR_021000001020+P_000202120*QR_021000001021+P_000202220*QR_021000001022); ans_temp[ans_id*36+30]+=Pmtrx[16]*(P_000002020*QR_020001001000+P_000002120*QR_020001001001+P_000002220*QR_020001001002+P_000102020*QR_020001001010+P_000102120*QR_020001001011+P_000102220*QR_020001001012+P_000202020*QR_020001001020+P_000202120*QR_020001001021+P_000202220*QR_020001001022); ans_temp[ans_id*36+30]+=Pmtrx[17]*(P_000002020*QR_020000002000+P_000002120*QR_020000002001+P_000002220*QR_020000002002+P_000102020*QR_020000002010+P_000102120*QR_020000002011+P_000102220*QR_020000002012+P_000202020*QR_020000002020+P_000202120*QR_020000002021+P_000202220*QR_020000002022); ans_temp[ans_id*36+31]+=Pmtrx[12]*(P_000002020*QR_012010000000+P_000002120*QR_012010000001+P_000002220*QR_012010000002+P_000102020*QR_012010000010+P_000102120*QR_012010000011+P_000102220*QR_012010000012+P_000202020*QR_012010000020+P_000202120*QR_012010000021+P_000202220*QR_012010000022); ans_temp[ans_id*36+31]+=Pmtrx[13]*(P_000002020*QR_011011000000+P_000002120*QR_011011000001+P_000002220*QR_011011000002+P_000102020*QR_011011000010+P_000102120*QR_011011000011+P_000102220*QR_011011000012+P_000202020*QR_011011000020+P_000202120*QR_011011000021+P_000202220*QR_011011000022); ans_temp[ans_id*36+31]+=Pmtrx[14]*(P_000002020*QR_010012000000+P_000002120*QR_010012000001+P_000002220*QR_010012000002+P_000102020*QR_010012000010+P_000102120*QR_010012000011+P_000102220*QR_010012000012+P_000202020*QR_010012000020+P_000202120*QR_010012000021+P_000202220*QR_010012000022); ans_temp[ans_id*36+31]+=Pmtrx[15]*(P_000002020*QR_011010001000+P_000002120*QR_011010001001+P_000002220*QR_011010001002+P_000102020*QR_011010001010+P_000102120*QR_011010001011+P_000102220*QR_011010001012+P_000202020*QR_011010001020+P_000202120*QR_011010001021+P_000202220*QR_011010001022); ans_temp[ans_id*36+31]+=Pmtrx[16]*(P_000002020*QR_010011001000+P_000002120*QR_010011001001+P_000002220*QR_010011001002+P_000102020*QR_010011001010+P_000102120*QR_010011001011+P_000102220*QR_010011001012+P_000202020*QR_010011001020+P_000202120*QR_010011001021+P_000202220*QR_010011001022); ans_temp[ans_id*36+31]+=Pmtrx[17]*(P_000002020*QR_010010002000+P_000002120*QR_010010002001+P_000002220*QR_010010002002+P_000102020*QR_010010002010+P_000102120*QR_010010002011+P_000102220*QR_010010002012+P_000202020*QR_010010002020+P_000202120*QR_010010002021+P_000202220*QR_010010002022); ans_temp[ans_id*36+32]+=Pmtrx[12]*(P_000002020*QR_002020000000+P_000002120*QR_002020000001+P_000002220*QR_002020000002+P_000102020*QR_002020000010+P_000102120*QR_002020000011+P_000102220*QR_002020000012+P_000202020*QR_002020000020+P_000202120*QR_002020000021+P_000202220*QR_002020000022); ans_temp[ans_id*36+32]+=Pmtrx[13]*(P_000002020*QR_001021000000+P_000002120*QR_001021000001+P_000002220*QR_001021000002+P_000102020*QR_001021000010+P_000102120*QR_001021000011+P_000102220*QR_001021000012+P_000202020*QR_001021000020+P_000202120*QR_001021000021+P_000202220*QR_001021000022); ans_temp[ans_id*36+32]+=Pmtrx[14]*(P_000002020*QR_000022000000+P_000002120*QR_000022000001+P_000002220*QR_000022000002+P_000102020*QR_000022000010+P_000102120*QR_000022000011+P_000102220*QR_000022000012+P_000202020*QR_000022000020+P_000202120*QR_000022000021+P_000202220*QR_000022000022); ans_temp[ans_id*36+32]+=Pmtrx[15]*(P_000002020*QR_001020001000+P_000002120*QR_001020001001+P_000002220*QR_001020001002+P_000102020*QR_001020001010+P_000102120*QR_001020001011+P_000102220*QR_001020001012+P_000202020*QR_001020001020+P_000202120*QR_001020001021+P_000202220*QR_001020001022); ans_temp[ans_id*36+32]+=Pmtrx[16]*(P_000002020*QR_000021001000+P_000002120*QR_000021001001+P_000002220*QR_000021001002+P_000102020*QR_000021001010+P_000102120*QR_000021001011+P_000102220*QR_000021001012+P_000202020*QR_000021001020+P_000202120*QR_000021001021+P_000202220*QR_000021001022); ans_temp[ans_id*36+32]+=Pmtrx[17]*(P_000002020*QR_000020002000+P_000002120*QR_000020002001+P_000002220*QR_000020002002+P_000102020*QR_000020002010+P_000102120*QR_000020002011+P_000102220*QR_000020002012+P_000202020*QR_000020002020+P_000202120*QR_000020002021+P_000202220*QR_000020002022); ans_temp[ans_id*36+33]+=Pmtrx[12]*(P_000002020*QR_012000010000+P_000002120*QR_012000010001+P_000002220*QR_012000010002+P_000102020*QR_012000010010+P_000102120*QR_012000010011+P_000102220*QR_012000010012+P_000202020*QR_012000010020+P_000202120*QR_012000010021+P_000202220*QR_012000010022); ans_temp[ans_id*36+33]+=Pmtrx[13]*(P_000002020*QR_011001010000+P_000002120*QR_011001010001+P_000002220*QR_011001010002+P_000102020*QR_011001010010+P_000102120*QR_011001010011+P_000102220*QR_011001010012+P_000202020*QR_011001010020+P_000202120*QR_011001010021+P_000202220*QR_011001010022); ans_temp[ans_id*36+33]+=Pmtrx[14]*(P_000002020*QR_010002010000+P_000002120*QR_010002010001+P_000002220*QR_010002010002+P_000102020*QR_010002010010+P_000102120*QR_010002010011+P_000102220*QR_010002010012+P_000202020*QR_010002010020+P_000202120*QR_010002010021+P_000202220*QR_010002010022); ans_temp[ans_id*36+33]+=Pmtrx[15]*(P_000002020*QR_011000011000+P_000002120*QR_011000011001+P_000002220*QR_011000011002+P_000102020*QR_011000011010+P_000102120*QR_011000011011+P_000102220*QR_011000011012+P_000202020*QR_011000011020+P_000202120*QR_011000011021+P_000202220*QR_011000011022); ans_temp[ans_id*36+33]+=Pmtrx[16]*(P_000002020*QR_010001011000+P_000002120*QR_010001011001+P_000002220*QR_010001011002+P_000102020*QR_010001011010+P_000102120*QR_010001011011+P_000102220*QR_010001011012+P_000202020*QR_010001011020+P_000202120*QR_010001011021+P_000202220*QR_010001011022); ans_temp[ans_id*36+33]+=Pmtrx[17]*(P_000002020*QR_010000012000+P_000002120*QR_010000012001+P_000002220*QR_010000012002+P_000102020*QR_010000012010+P_000102120*QR_010000012011+P_000102220*QR_010000012012+P_000202020*QR_010000012020+P_000202120*QR_010000012021+P_000202220*QR_010000012022); ans_temp[ans_id*36+34]+=Pmtrx[12]*(P_000002020*QR_002010010000+P_000002120*QR_002010010001+P_000002220*QR_002010010002+P_000102020*QR_002010010010+P_000102120*QR_002010010011+P_000102220*QR_002010010012+P_000202020*QR_002010010020+P_000202120*QR_002010010021+P_000202220*QR_002010010022); ans_temp[ans_id*36+34]+=Pmtrx[13]*(P_000002020*QR_001011010000+P_000002120*QR_001011010001+P_000002220*QR_001011010002+P_000102020*QR_001011010010+P_000102120*QR_001011010011+P_000102220*QR_001011010012+P_000202020*QR_001011010020+P_000202120*QR_001011010021+P_000202220*QR_001011010022); ans_temp[ans_id*36+34]+=Pmtrx[14]*(P_000002020*QR_000012010000+P_000002120*QR_000012010001+P_000002220*QR_000012010002+P_000102020*QR_000012010010+P_000102120*QR_000012010011+P_000102220*QR_000012010012+P_000202020*QR_000012010020+P_000202120*QR_000012010021+P_000202220*QR_000012010022); ans_temp[ans_id*36+34]+=Pmtrx[15]*(P_000002020*QR_001010011000+P_000002120*QR_001010011001+P_000002220*QR_001010011002+P_000102020*QR_001010011010+P_000102120*QR_001010011011+P_000102220*QR_001010011012+P_000202020*QR_001010011020+P_000202120*QR_001010011021+P_000202220*QR_001010011022); ans_temp[ans_id*36+34]+=Pmtrx[16]*(P_000002020*QR_000011011000+P_000002120*QR_000011011001+P_000002220*QR_000011011002+P_000102020*QR_000011011010+P_000102120*QR_000011011011+P_000102220*QR_000011011012+P_000202020*QR_000011011020+P_000202120*QR_000011011021+P_000202220*QR_000011011022); ans_temp[ans_id*36+34]+=Pmtrx[17]*(P_000002020*QR_000010012000+P_000002120*QR_000010012001+P_000002220*QR_000010012002+P_000102020*QR_000010012010+P_000102120*QR_000010012011+P_000102220*QR_000010012012+P_000202020*QR_000010012020+P_000202120*QR_000010012021+P_000202220*QR_000010012022); ans_temp[ans_id*36+35]+=Pmtrx[12]*(P_000002020*QR_002000020000+P_000002120*QR_002000020001+P_000002220*QR_002000020002+P_000102020*QR_002000020010+P_000102120*QR_002000020011+P_000102220*QR_002000020012+P_000202020*QR_002000020020+P_000202120*QR_002000020021+P_000202220*QR_002000020022); ans_temp[ans_id*36+35]+=Pmtrx[13]*(P_000002020*QR_001001020000+P_000002120*QR_001001020001+P_000002220*QR_001001020002+P_000102020*QR_001001020010+P_000102120*QR_001001020011+P_000102220*QR_001001020012+P_000202020*QR_001001020020+P_000202120*QR_001001020021+P_000202220*QR_001001020022); ans_temp[ans_id*36+35]+=Pmtrx[14]*(P_000002020*QR_000002020000+P_000002120*QR_000002020001+P_000002220*QR_000002020002+P_000102020*QR_000002020010+P_000102120*QR_000002020011+P_000102220*QR_000002020012+P_000202020*QR_000002020020+P_000202120*QR_000002020021+P_000202220*QR_000002020022); ans_temp[ans_id*36+35]+=Pmtrx[15]*(P_000002020*QR_001000021000+P_000002120*QR_001000021001+P_000002220*QR_001000021002+P_000102020*QR_001000021010+P_000102120*QR_001000021011+P_000102220*QR_001000021012+P_000202020*QR_001000021020+P_000202120*QR_001000021021+P_000202220*QR_001000021022); ans_temp[ans_id*36+35]+=Pmtrx[16]*(P_000002020*QR_000001021000+P_000002120*QR_000001021001+P_000002220*QR_000001021002+P_000102020*QR_000001021010+P_000102120*QR_000001021011+P_000102220*QR_000001021012+P_000202020*QR_000001021020+P_000202120*QR_000001021021+P_000202220*QR_000001021022); ans_temp[ans_id*36+35]+=Pmtrx[17]*(P_000002020*QR_000000022000+P_000002120*QR_000000022001+P_000002220*QR_000000022002+P_000102020*QR_000000022010+P_000102120*QR_000000022011+P_000102220*QR_000000022012+P_000202020*QR_000000022020+P_000202120*QR_000000022021+P_000202220*QR_000000022022); ans_temp[ans_id*36+30]+=Pmtrx[18]*(P_001000021*QR_022000000000+P_001000121*QR_022000000001+P_001000221*QR_022000000002+P_001000321*QR_022000000003+P_101000021*QR_022000000100+P_101000121*QR_022000000101+P_101000221*QR_022000000102+P_101000321*QR_022000000103); ans_temp[ans_id*36+30]+=Pmtrx[19]*(P_001000021*QR_021001000000+P_001000121*QR_021001000001+P_001000221*QR_021001000002+P_001000321*QR_021001000003+P_101000021*QR_021001000100+P_101000121*QR_021001000101+P_101000221*QR_021001000102+P_101000321*QR_021001000103); ans_temp[ans_id*36+30]+=Pmtrx[20]*(P_001000021*QR_020002000000+P_001000121*QR_020002000001+P_001000221*QR_020002000002+P_001000321*QR_020002000003+P_101000021*QR_020002000100+P_101000121*QR_020002000101+P_101000221*QR_020002000102+P_101000321*QR_020002000103); ans_temp[ans_id*36+30]+=Pmtrx[21]*(P_001000021*QR_021000001000+P_001000121*QR_021000001001+P_001000221*QR_021000001002+P_001000321*QR_021000001003+P_101000021*QR_021000001100+P_101000121*QR_021000001101+P_101000221*QR_021000001102+P_101000321*QR_021000001103); ans_temp[ans_id*36+30]+=Pmtrx[22]*(P_001000021*QR_020001001000+P_001000121*QR_020001001001+P_001000221*QR_020001001002+P_001000321*QR_020001001003+P_101000021*QR_020001001100+P_101000121*QR_020001001101+P_101000221*QR_020001001102+P_101000321*QR_020001001103); ans_temp[ans_id*36+30]+=Pmtrx[23]*(P_001000021*QR_020000002000+P_001000121*QR_020000002001+P_001000221*QR_020000002002+P_001000321*QR_020000002003+P_101000021*QR_020000002100+P_101000121*QR_020000002101+P_101000221*QR_020000002102+P_101000321*QR_020000002103); ans_temp[ans_id*36+31]+=Pmtrx[18]*(P_001000021*QR_012010000000+P_001000121*QR_012010000001+P_001000221*QR_012010000002+P_001000321*QR_012010000003+P_101000021*QR_012010000100+P_101000121*QR_012010000101+P_101000221*QR_012010000102+P_101000321*QR_012010000103); ans_temp[ans_id*36+31]+=Pmtrx[19]*(P_001000021*QR_011011000000+P_001000121*QR_011011000001+P_001000221*QR_011011000002+P_001000321*QR_011011000003+P_101000021*QR_011011000100+P_101000121*QR_011011000101+P_101000221*QR_011011000102+P_101000321*QR_011011000103); ans_temp[ans_id*36+31]+=Pmtrx[20]*(P_001000021*QR_010012000000+P_001000121*QR_010012000001+P_001000221*QR_010012000002+P_001000321*QR_010012000003+P_101000021*QR_010012000100+P_101000121*QR_010012000101+P_101000221*QR_010012000102+P_101000321*QR_010012000103); ans_temp[ans_id*36+31]+=Pmtrx[21]*(P_001000021*QR_011010001000+P_001000121*QR_011010001001+P_001000221*QR_011010001002+P_001000321*QR_011010001003+P_101000021*QR_011010001100+P_101000121*QR_011010001101+P_101000221*QR_011010001102+P_101000321*QR_011010001103); ans_temp[ans_id*36+31]+=Pmtrx[22]*(P_001000021*QR_010011001000+P_001000121*QR_010011001001+P_001000221*QR_010011001002+P_001000321*QR_010011001003+P_101000021*QR_010011001100+P_101000121*QR_010011001101+P_101000221*QR_010011001102+P_101000321*QR_010011001103); ans_temp[ans_id*36+31]+=Pmtrx[23]*(P_001000021*QR_010010002000+P_001000121*QR_010010002001+P_001000221*QR_010010002002+P_001000321*QR_010010002003+P_101000021*QR_010010002100+P_101000121*QR_010010002101+P_101000221*QR_010010002102+P_101000321*QR_010010002103); ans_temp[ans_id*36+32]+=Pmtrx[18]*(P_001000021*QR_002020000000+P_001000121*QR_002020000001+P_001000221*QR_002020000002+P_001000321*QR_002020000003+P_101000021*QR_002020000100+P_101000121*QR_002020000101+P_101000221*QR_002020000102+P_101000321*QR_002020000103); ans_temp[ans_id*36+32]+=Pmtrx[19]*(P_001000021*QR_001021000000+P_001000121*QR_001021000001+P_001000221*QR_001021000002+P_001000321*QR_001021000003+P_101000021*QR_001021000100+P_101000121*QR_001021000101+P_101000221*QR_001021000102+P_101000321*QR_001021000103); ans_temp[ans_id*36+32]+=Pmtrx[20]*(P_001000021*QR_000022000000+P_001000121*QR_000022000001+P_001000221*QR_000022000002+P_001000321*QR_000022000003+P_101000021*QR_000022000100+P_101000121*QR_000022000101+P_101000221*QR_000022000102+P_101000321*QR_000022000103); ans_temp[ans_id*36+32]+=Pmtrx[21]*(P_001000021*QR_001020001000+P_001000121*QR_001020001001+P_001000221*QR_001020001002+P_001000321*QR_001020001003+P_101000021*QR_001020001100+P_101000121*QR_001020001101+P_101000221*QR_001020001102+P_101000321*QR_001020001103); ans_temp[ans_id*36+32]+=Pmtrx[22]*(P_001000021*QR_000021001000+P_001000121*QR_000021001001+P_001000221*QR_000021001002+P_001000321*QR_000021001003+P_101000021*QR_000021001100+P_101000121*QR_000021001101+P_101000221*QR_000021001102+P_101000321*QR_000021001103); ans_temp[ans_id*36+32]+=Pmtrx[23]*(P_001000021*QR_000020002000+P_001000121*QR_000020002001+P_001000221*QR_000020002002+P_001000321*QR_000020002003+P_101000021*QR_000020002100+P_101000121*QR_000020002101+P_101000221*QR_000020002102+P_101000321*QR_000020002103); ans_temp[ans_id*36+33]+=Pmtrx[18]*(P_001000021*QR_012000010000+P_001000121*QR_012000010001+P_001000221*QR_012000010002+P_001000321*QR_012000010003+P_101000021*QR_012000010100+P_101000121*QR_012000010101+P_101000221*QR_012000010102+P_101000321*QR_012000010103); ans_temp[ans_id*36+33]+=Pmtrx[19]*(P_001000021*QR_011001010000+P_001000121*QR_011001010001+P_001000221*QR_011001010002+P_001000321*QR_011001010003+P_101000021*QR_011001010100+P_101000121*QR_011001010101+P_101000221*QR_011001010102+P_101000321*QR_011001010103); ans_temp[ans_id*36+33]+=Pmtrx[20]*(P_001000021*QR_010002010000+P_001000121*QR_010002010001+P_001000221*QR_010002010002+P_001000321*QR_010002010003+P_101000021*QR_010002010100+P_101000121*QR_010002010101+P_101000221*QR_010002010102+P_101000321*QR_010002010103); ans_temp[ans_id*36+33]+=Pmtrx[21]*(P_001000021*QR_011000011000+P_001000121*QR_011000011001+P_001000221*QR_011000011002+P_001000321*QR_011000011003+P_101000021*QR_011000011100+P_101000121*QR_011000011101+P_101000221*QR_011000011102+P_101000321*QR_011000011103); ans_temp[ans_id*36+33]+=Pmtrx[22]*(P_001000021*QR_010001011000+P_001000121*QR_010001011001+P_001000221*QR_010001011002+P_001000321*QR_010001011003+P_101000021*QR_010001011100+P_101000121*QR_010001011101+P_101000221*QR_010001011102+P_101000321*QR_010001011103); ans_temp[ans_id*36+33]+=Pmtrx[23]*(P_001000021*QR_010000012000+P_001000121*QR_010000012001+P_001000221*QR_010000012002+P_001000321*QR_010000012003+P_101000021*QR_010000012100+P_101000121*QR_010000012101+P_101000221*QR_010000012102+P_101000321*QR_010000012103); ans_temp[ans_id*36+34]+=Pmtrx[18]*(P_001000021*QR_002010010000+P_001000121*QR_002010010001+P_001000221*QR_002010010002+P_001000321*QR_002010010003+P_101000021*QR_002010010100+P_101000121*QR_002010010101+P_101000221*QR_002010010102+P_101000321*QR_002010010103); ans_temp[ans_id*36+34]+=Pmtrx[19]*(P_001000021*QR_001011010000+P_001000121*QR_001011010001+P_001000221*QR_001011010002+P_001000321*QR_001011010003+P_101000021*QR_001011010100+P_101000121*QR_001011010101+P_101000221*QR_001011010102+P_101000321*QR_001011010103); ans_temp[ans_id*36+34]+=Pmtrx[20]*(P_001000021*QR_000012010000+P_001000121*QR_000012010001+P_001000221*QR_000012010002+P_001000321*QR_000012010003+P_101000021*QR_000012010100+P_101000121*QR_000012010101+P_101000221*QR_000012010102+P_101000321*QR_000012010103); ans_temp[ans_id*36+34]+=Pmtrx[21]*(P_001000021*QR_001010011000+P_001000121*QR_001010011001+P_001000221*QR_001010011002+P_001000321*QR_001010011003+P_101000021*QR_001010011100+P_101000121*QR_001010011101+P_101000221*QR_001010011102+P_101000321*QR_001010011103); ans_temp[ans_id*36+34]+=Pmtrx[22]*(P_001000021*QR_000011011000+P_001000121*QR_000011011001+P_001000221*QR_000011011002+P_001000321*QR_000011011003+P_101000021*QR_000011011100+P_101000121*QR_000011011101+P_101000221*QR_000011011102+P_101000321*QR_000011011103); ans_temp[ans_id*36+34]+=Pmtrx[23]*(P_001000021*QR_000010012000+P_001000121*QR_000010012001+P_001000221*QR_000010012002+P_001000321*QR_000010012003+P_101000021*QR_000010012100+P_101000121*QR_000010012101+P_101000221*QR_000010012102+P_101000321*QR_000010012103); ans_temp[ans_id*36+35]+=Pmtrx[18]*(P_001000021*QR_002000020000+P_001000121*QR_002000020001+P_001000221*QR_002000020002+P_001000321*QR_002000020003+P_101000021*QR_002000020100+P_101000121*QR_002000020101+P_101000221*QR_002000020102+P_101000321*QR_002000020103); ans_temp[ans_id*36+35]+=Pmtrx[19]*(P_001000021*QR_001001020000+P_001000121*QR_001001020001+P_001000221*QR_001001020002+P_001000321*QR_001001020003+P_101000021*QR_001001020100+P_101000121*QR_001001020101+P_101000221*QR_001001020102+P_101000321*QR_001001020103); ans_temp[ans_id*36+35]+=Pmtrx[20]*(P_001000021*QR_000002020000+P_001000121*QR_000002020001+P_001000221*QR_000002020002+P_001000321*QR_000002020003+P_101000021*QR_000002020100+P_101000121*QR_000002020101+P_101000221*QR_000002020102+P_101000321*QR_000002020103); ans_temp[ans_id*36+35]+=Pmtrx[21]*(P_001000021*QR_001000021000+P_001000121*QR_001000021001+P_001000221*QR_001000021002+P_001000321*QR_001000021003+P_101000021*QR_001000021100+P_101000121*QR_001000021101+P_101000221*QR_001000021102+P_101000321*QR_001000021103); ans_temp[ans_id*36+35]+=Pmtrx[22]*(P_001000021*QR_000001021000+P_001000121*QR_000001021001+P_001000221*QR_000001021002+P_001000321*QR_000001021003+P_101000021*QR_000001021100+P_101000121*QR_000001021101+P_101000221*QR_000001021102+P_101000321*QR_000001021103); ans_temp[ans_id*36+35]+=Pmtrx[23]*(P_001000021*QR_000000022000+P_001000121*QR_000000022001+P_001000221*QR_000000022002+P_001000321*QR_000000022003+P_101000021*QR_000000022100+P_101000121*QR_000000022101+P_101000221*QR_000000022102+P_101000321*QR_000000022103); ans_temp[ans_id*36+30]+=Pmtrx[24]*(P_000001021*QR_022000000000+P_000001121*QR_022000000001+P_000001221*QR_022000000002+P_000001321*QR_022000000003+P_000101021*QR_022000000010+P_000101121*QR_022000000011+P_000101221*QR_022000000012+P_000101321*QR_022000000013); ans_temp[ans_id*36+30]+=Pmtrx[25]*(P_000001021*QR_021001000000+P_000001121*QR_021001000001+P_000001221*QR_021001000002+P_000001321*QR_021001000003+P_000101021*QR_021001000010+P_000101121*QR_021001000011+P_000101221*QR_021001000012+P_000101321*QR_021001000013); ans_temp[ans_id*36+30]+=Pmtrx[26]*(P_000001021*QR_020002000000+P_000001121*QR_020002000001+P_000001221*QR_020002000002+P_000001321*QR_020002000003+P_000101021*QR_020002000010+P_000101121*QR_020002000011+P_000101221*QR_020002000012+P_000101321*QR_020002000013); ans_temp[ans_id*36+30]+=Pmtrx[27]*(P_000001021*QR_021000001000+P_000001121*QR_021000001001+P_000001221*QR_021000001002+P_000001321*QR_021000001003+P_000101021*QR_021000001010+P_000101121*QR_021000001011+P_000101221*QR_021000001012+P_000101321*QR_021000001013); ans_temp[ans_id*36+30]+=Pmtrx[28]*(P_000001021*QR_020001001000+P_000001121*QR_020001001001+P_000001221*QR_020001001002+P_000001321*QR_020001001003+P_000101021*QR_020001001010+P_000101121*QR_020001001011+P_000101221*QR_020001001012+P_000101321*QR_020001001013); ans_temp[ans_id*36+30]+=Pmtrx[29]*(P_000001021*QR_020000002000+P_000001121*QR_020000002001+P_000001221*QR_020000002002+P_000001321*QR_020000002003+P_000101021*QR_020000002010+P_000101121*QR_020000002011+P_000101221*QR_020000002012+P_000101321*QR_020000002013); ans_temp[ans_id*36+31]+=Pmtrx[24]*(P_000001021*QR_012010000000+P_000001121*QR_012010000001+P_000001221*QR_012010000002+P_000001321*QR_012010000003+P_000101021*QR_012010000010+P_000101121*QR_012010000011+P_000101221*QR_012010000012+P_000101321*QR_012010000013); ans_temp[ans_id*36+31]+=Pmtrx[25]*(P_000001021*QR_011011000000+P_000001121*QR_011011000001+P_000001221*QR_011011000002+P_000001321*QR_011011000003+P_000101021*QR_011011000010+P_000101121*QR_011011000011+P_000101221*QR_011011000012+P_000101321*QR_011011000013); ans_temp[ans_id*36+31]+=Pmtrx[26]*(P_000001021*QR_010012000000+P_000001121*QR_010012000001+P_000001221*QR_010012000002+P_000001321*QR_010012000003+P_000101021*QR_010012000010+P_000101121*QR_010012000011+P_000101221*QR_010012000012+P_000101321*QR_010012000013); ans_temp[ans_id*36+31]+=Pmtrx[27]*(P_000001021*QR_011010001000+P_000001121*QR_011010001001+P_000001221*QR_011010001002+P_000001321*QR_011010001003+P_000101021*QR_011010001010+P_000101121*QR_011010001011+P_000101221*QR_011010001012+P_000101321*QR_011010001013); ans_temp[ans_id*36+31]+=Pmtrx[28]*(P_000001021*QR_010011001000+P_000001121*QR_010011001001+P_000001221*QR_010011001002+P_000001321*QR_010011001003+P_000101021*QR_010011001010+P_000101121*QR_010011001011+P_000101221*QR_010011001012+P_000101321*QR_010011001013); ans_temp[ans_id*36+31]+=Pmtrx[29]*(P_000001021*QR_010010002000+P_000001121*QR_010010002001+P_000001221*QR_010010002002+P_000001321*QR_010010002003+P_000101021*QR_010010002010+P_000101121*QR_010010002011+P_000101221*QR_010010002012+P_000101321*QR_010010002013); ans_temp[ans_id*36+32]+=Pmtrx[24]*(P_000001021*QR_002020000000+P_000001121*QR_002020000001+P_000001221*QR_002020000002+P_000001321*QR_002020000003+P_000101021*QR_002020000010+P_000101121*QR_002020000011+P_000101221*QR_002020000012+P_000101321*QR_002020000013); ans_temp[ans_id*36+32]+=Pmtrx[25]*(P_000001021*QR_001021000000+P_000001121*QR_001021000001+P_000001221*QR_001021000002+P_000001321*QR_001021000003+P_000101021*QR_001021000010+P_000101121*QR_001021000011+P_000101221*QR_001021000012+P_000101321*QR_001021000013); ans_temp[ans_id*36+32]+=Pmtrx[26]*(P_000001021*QR_000022000000+P_000001121*QR_000022000001+P_000001221*QR_000022000002+P_000001321*QR_000022000003+P_000101021*QR_000022000010+P_000101121*QR_000022000011+P_000101221*QR_000022000012+P_000101321*QR_000022000013); ans_temp[ans_id*36+32]+=Pmtrx[27]*(P_000001021*QR_001020001000+P_000001121*QR_001020001001+P_000001221*QR_001020001002+P_000001321*QR_001020001003+P_000101021*QR_001020001010+P_000101121*QR_001020001011+P_000101221*QR_001020001012+P_000101321*QR_001020001013); ans_temp[ans_id*36+32]+=Pmtrx[28]*(P_000001021*QR_000021001000+P_000001121*QR_000021001001+P_000001221*QR_000021001002+P_000001321*QR_000021001003+P_000101021*QR_000021001010+P_000101121*QR_000021001011+P_000101221*QR_000021001012+P_000101321*QR_000021001013); ans_temp[ans_id*36+32]+=Pmtrx[29]*(P_000001021*QR_000020002000+P_000001121*QR_000020002001+P_000001221*QR_000020002002+P_000001321*QR_000020002003+P_000101021*QR_000020002010+P_000101121*QR_000020002011+P_000101221*QR_000020002012+P_000101321*QR_000020002013); ans_temp[ans_id*36+33]+=Pmtrx[24]*(P_000001021*QR_012000010000+P_000001121*QR_012000010001+P_000001221*QR_012000010002+P_000001321*QR_012000010003+P_000101021*QR_012000010010+P_000101121*QR_012000010011+P_000101221*QR_012000010012+P_000101321*QR_012000010013); ans_temp[ans_id*36+33]+=Pmtrx[25]*(P_000001021*QR_011001010000+P_000001121*QR_011001010001+P_000001221*QR_011001010002+P_000001321*QR_011001010003+P_000101021*QR_011001010010+P_000101121*QR_011001010011+P_000101221*QR_011001010012+P_000101321*QR_011001010013); ans_temp[ans_id*36+33]+=Pmtrx[26]*(P_000001021*QR_010002010000+P_000001121*QR_010002010001+P_000001221*QR_010002010002+P_000001321*QR_010002010003+P_000101021*QR_010002010010+P_000101121*QR_010002010011+P_000101221*QR_010002010012+P_000101321*QR_010002010013); ans_temp[ans_id*36+33]+=Pmtrx[27]*(P_000001021*QR_011000011000+P_000001121*QR_011000011001+P_000001221*QR_011000011002+P_000001321*QR_011000011003+P_000101021*QR_011000011010+P_000101121*QR_011000011011+P_000101221*QR_011000011012+P_000101321*QR_011000011013); ans_temp[ans_id*36+33]+=Pmtrx[28]*(P_000001021*QR_010001011000+P_000001121*QR_010001011001+P_000001221*QR_010001011002+P_000001321*QR_010001011003+P_000101021*QR_010001011010+P_000101121*QR_010001011011+P_000101221*QR_010001011012+P_000101321*QR_010001011013); ans_temp[ans_id*36+33]+=Pmtrx[29]*(P_000001021*QR_010000012000+P_000001121*QR_010000012001+P_000001221*QR_010000012002+P_000001321*QR_010000012003+P_000101021*QR_010000012010+P_000101121*QR_010000012011+P_000101221*QR_010000012012+P_000101321*QR_010000012013); ans_temp[ans_id*36+34]+=Pmtrx[24]*(P_000001021*QR_002010010000+P_000001121*QR_002010010001+P_000001221*QR_002010010002+P_000001321*QR_002010010003+P_000101021*QR_002010010010+P_000101121*QR_002010010011+P_000101221*QR_002010010012+P_000101321*QR_002010010013); ans_temp[ans_id*36+34]+=Pmtrx[25]*(P_000001021*QR_001011010000+P_000001121*QR_001011010001+P_000001221*QR_001011010002+P_000001321*QR_001011010003+P_000101021*QR_001011010010+P_000101121*QR_001011010011+P_000101221*QR_001011010012+P_000101321*QR_001011010013); ans_temp[ans_id*36+34]+=Pmtrx[26]*(P_000001021*QR_000012010000+P_000001121*QR_000012010001+P_000001221*QR_000012010002+P_000001321*QR_000012010003+P_000101021*QR_000012010010+P_000101121*QR_000012010011+P_000101221*QR_000012010012+P_000101321*QR_000012010013); ans_temp[ans_id*36+34]+=Pmtrx[27]*(P_000001021*QR_001010011000+P_000001121*QR_001010011001+P_000001221*QR_001010011002+P_000001321*QR_001010011003+P_000101021*QR_001010011010+P_000101121*QR_001010011011+P_000101221*QR_001010011012+P_000101321*QR_001010011013); ans_temp[ans_id*36+34]+=Pmtrx[28]*(P_000001021*QR_000011011000+P_000001121*QR_000011011001+P_000001221*QR_000011011002+P_000001321*QR_000011011003+P_000101021*QR_000011011010+P_000101121*QR_000011011011+P_000101221*QR_000011011012+P_000101321*QR_000011011013); ans_temp[ans_id*36+34]+=Pmtrx[29]*(P_000001021*QR_000010012000+P_000001121*QR_000010012001+P_000001221*QR_000010012002+P_000001321*QR_000010012003+P_000101021*QR_000010012010+P_000101121*QR_000010012011+P_000101221*QR_000010012012+P_000101321*QR_000010012013); ans_temp[ans_id*36+35]+=Pmtrx[24]*(P_000001021*QR_002000020000+P_000001121*QR_002000020001+P_000001221*QR_002000020002+P_000001321*QR_002000020003+P_000101021*QR_002000020010+P_000101121*QR_002000020011+P_000101221*QR_002000020012+P_000101321*QR_002000020013); ans_temp[ans_id*36+35]+=Pmtrx[25]*(P_000001021*QR_001001020000+P_000001121*QR_001001020001+P_000001221*QR_001001020002+P_000001321*QR_001001020003+P_000101021*QR_001001020010+P_000101121*QR_001001020011+P_000101221*QR_001001020012+P_000101321*QR_001001020013); ans_temp[ans_id*36+35]+=Pmtrx[26]*(P_000001021*QR_000002020000+P_000001121*QR_000002020001+P_000001221*QR_000002020002+P_000001321*QR_000002020003+P_000101021*QR_000002020010+P_000101121*QR_000002020011+P_000101221*QR_000002020012+P_000101321*QR_000002020013); ans_temp[ans_id*36+35]+=Pmtrx[27]*(P_000001021*QR_001000021000+P_000001121*QR_001000021001+P_000001221*QR_001000021002+P_000001321*QR_001000021003+P_000101021*QR_001000021010+P_000101121*QR_001000021011+P_000101221*QR_001000021012+P_000101321*QR_001000021013); ans_temp[ans_id*36+35]+=Pmtrx[28]*(P_000001021*QR_000001021000+P_000001121*QR_000001021001+P_000001221*QR_000001021002+P_000001321*QR_000001021003+P_000101021*QR_000001021010+P_000101121*QR_000001021011+P_000101221*QR_000001021012+P_000101321*QR_000001021013); ans_temp[ans_id*36+35]+=Pmtrx[29]*(P_000001021*QR_000000022000+P_000001121*QR_000000022001+P_000001221*QR_000000022002+P_000001321*QR_000000022003+P_000101021*QR_000000022010+P_000101121*QR_000000022011+P_000101221*QR_000000022012+P_000101321*QR_000000022013); ans_temp[ans_id*36+30]+=Pmtrx[30]*(P_000000022*QR_022000000000+P_000000122*QR_022000000001+P_000000222*QR_022000000002+P_000000322*QR_022000000003+P_000000422*QR_022000000004); ans_temp[ans_id*36+30]+=Pmtrx[31]*(P_000000022*QR_021001000000+P_000000122*QR_021001000001+P_000000222*QR_021001000002+P_000000322*QR_021001000003+P_000000422*QR_021001000004); ans_temp[ans_id*36+30]+=Pmtrx[32]*(P_000000022*QR_020002000000+P_000000122*QR_020002000001+P_000000222*QR_020002000002+P_000000322*QR_020002000003+P_000000422*QR_020002000004); ans_temp[ans_id*36+30]+=Pmtrx[33]*(P_000000022*QR_021000001000+P_000000122*QR_021000001001+P_000000222*QR_021000001002+P_000000322*QR_021000001003+P_000000422*QR_021000001004); ans_temp[ans_id*36+30]+=Pmtrx[34]*(P_000000022*QR_020001001000+P_000000122*QR_020001001001+P_000000222*QR_020001001002+P_000000322*QR_020001001003+P_000000422*QR_020001001004); ans_temp[ans_id*36+30]+=Pmtrx[35]*(P_000000022*QR_020000002000+P_000000122*QR_020000002001+P_000000222*QR_020000002002+P_000000322*QR_020000002003+P_000000422*QR_020000002004); ans_temp[ans_id*36+31]+=Pmtrx[30]*(P_000000022*QR_012010000000+P_000000122*QR_012010000001+P_000000222*QR_012010000002+P_000000322*QR_012010000003+P_000000422*QR_012010000004); ans_temp[ans_id*36+31]+=Pmtrx[31]*(P_000000022*QR_011011000000+P_000000122*QR_011011000001+P_000000222*QR_011011000002+P_000000322*QR_011011000003+P_000000422*QR_011011000004); ans_temp[ans_id*36+31]+=Pmtrx[32]*(P_000000022*QR_010012000000+P_000000122*QR_010012000001+P_000000222*QR_010012000002+P_000000322*QR_010012000003+P_000000422*QR_010012000004); ans_temp[ans_id*36+31]+=Pmtrx[33]*(P_000000022*QR_011010001000+P_000000122*QR_011010001001+P_000000222*QR_011010001002+P_000000322*QR_011010001003+P_000000422*QR_011010001004); ans_temp[ans_id*36+31]+=Pmtrx[34]*(P_000000022*QR_010011001000+P_000000122*QR_010011001001+P_000000222*QR_010011001002+P_000000322*QR_010011001003+P_000000422*QR_010011001004); ans_temp[ans_id*36+31]+=Pmtrx[35]*(P_000000022*QR_010010002000+P_000000122*QR_010010002001+P_000000222*QR_010010002002+P_000000322*QR_010010002003+P_000000422*QR_010010002004); ans_temp[ans_id*36+32]+=Pmtrx[30]*(P_000000022*QR_002020000000+P_000000122*QR_002020000001+P_000000222*QR_002020000002+P_000000322*QR_002020000003+P_000000422*QR_002020000004); ans_temp[ans_id*36+32]+=Pmtrx[31]*(P_000000022*QR_001021000000+P_000000122*QR_001021000001+P_000000222*QR_001021000002+P_000000322*QR_001021000003+P_000000422*QR_001021000004); ans_temp[ans_id*36+32]+=Pmtrx[32]*(P_000000022*QR_000022000000+P_000000122*QR_000022000001+P_000000222*QR_000022000002+P_000000322*QR_000022000003+P_000000422*QR_000022000004); ans_temp[ans_id*36+32]+=Pmtrx[33]*(P_000000022*QR_001020001000+P_000000122*QR_001020001001+P_000000222*QR_001020001002+P_000000322*QR_001020001003+P_000000422*QR_001020001004); ans_temp[ans_id*36+32]+=Pmtrx[34]*(P_000000022*QR_000021001000+P_000000122*QR_000021001001+P_000000222*QR_000021001002+P_000000322*QR_000021001003+P_000000422*QR_000021001004); ans_temp[ans_id*36+32]+=Pmtrx[35]*(P_000000022*QR_000020002000+P_000000122*QR_000020002001+P_000000222*QR_000020002002+P_000000322*QR_000020002003+P_000000422*QR_000020002004); ans_temp[ans_id*36+33]+=Pmtrx[30]*(P_000000022*QR_012000010000+P_000000122*QR_012000010001+P_000000222*QR_012000010002+P_000000322*QR_012000010003+P_000000422*QR_012000010004); ans_temp[ans_id*36+33]+=Pmtrx[31]*(P_000000022*QR_011001010000+P_000000122*QR_011001010001+P_000000222*QR_011001010002+P_000000322*QR_011001010003+P_000000422*QR_011001010004); ans_temp[ans_id*36+33]+=Pmtrx[32]*(P_000000022*QR_010002010000+P_000000122*QR_010002010001+P_000000222*QR_010002010002+P_000000322*QR_010002010003+P_000000422*QR_010002010004); ans_temp[ans_id*36+33]+=Pmtrx[33]*(P_000000022*QR_011000011000+P_000000122*QR_011000011001+P_000000222*QR_011000011002+P_000000322*QR_011000011003+P_000000422*QR_011000011004); ans_temp[ans_id*36+33]+=Pmtrx[34]*(P_000000022*QR_010001011000+P_000000122*QR_010001011001+P_000000222*QR_010001011002+P_000000322*QR_010001011003+P_000000422*QR_010001011004); ans_temp[ans_id*36+33]+=Pmtrx[35]*(P_000000022*QR_010000012000+P_000000122*QR_010000012001+P_000000222*QR_010000012002+P_000000322*QR_010000012003+P_000000422*QR_010000012004); ans_temp[ans_id*36+34]+=Pmtrx[30]*(P_000000022*QR_002010010000+P_000000122*QR_002010010001+P_000000222*QR_002010010002+P_000000322*QR_002010010003+P_000000422*QR_002010010004); ans_temp[ans_id*36+34]+=Pmtrx[31]*(P_000000022*QR_001011010000+P_000000122*QR_001011010001+P_000000222*QR_001011010002+P_000000322*QR_001011010003+P_000000422*QR_001011010004); ans_temp[ans_id*36+34]+=Pmtrx[32]*(P_000000022*QR_000012010000+P_000000122*QR_000012010001+P_000000222*QR_000012010002+P_000000322*QR_000012010003+P_000000422*QR_000012010004); ans_temp[ans_id*36+34]+=Pmtrx[33]*(P_000000022*QR_001010011000+P_000000122*QR_001010011001+P_000000222*QR_001010011002+P_000000322*QR_001010011003+P_000000422*QR_001010011004); ans_temp[ans_id*36+34]+=Pmtrx[34]*(P_000000022*QR_000011011000+P_000000122*QR_000011011001+P_000000222*QR_000011011002+P_000000322*QR_000011011003+P_000000422*QR_000011011004); ans_temp[ans_id*36+34]+=Pmtrx[35]*(P_000000022*QR_000010012000+P_000000122*QR_000010012001+P_000000222*QR_000010012002+P_000000322*QR_000010012003+P_000000422*QR_000010012004); ans_temp[ans_id*36+35]+=Pmtrx[30]*(P_000000022*QR_002000020000+P_000000122*QR_002000020001+P_000000222*QR_002000020002+P_000000322*QR_002000020003+P_000000422*QR_002000020004); ans_temp[ans_id*36+35]+=Pmtrx[31]*(P_000000022*QR_001001020000+P_000000122*QR_001001020001+P_000000222*QR_001001020002+P_000000322*QR_001001020003+P_000000422*QR_001001020004); ans_temp[ans_id*36+35]+=Pmtrx[32]*(P_000000022*QR_000002020000+P_000000122*QR_000002020001+P_000000222*QR_000002020002+P_000000322*QR_000002020003+P_000000422*QR_000002020004); ans_temp[ans_id*36+35]+=Pmtrx[33]*(P_000000022*QR_001000021000+P_000000122*QR_001000021001+P_000000222*QR_001000021002+P_000000322*QR_001000021003+P_000000422*QR_001000021004); ans_temp[ans_id*36+35]+=Pmtrx[34]*(P_000000022*QR_000001021000+P_000000122*QR_000001021001+P_000000222*QR_000001021002+P_000000322*QR_000001021003+P_000000422*QR_000001021004); ans_temp[ans_id*36+35]+=Pmtrx[35]*(P_000000022*QR_000000022000+P_000000122*QR_000000022001+P_000000222*QR_000000022002+P_000000322*QR_000000022003+P_000000422*QR_000000022004); } } __syncthreads(); int num_thread=NTHREAD/2; while (num_thread!=0){ __syncthreads(); if(tId_x<num_thread){ for(int ians=0;ians<36;ians++){ ans_temp[tId_x*36+ians]+=ans_temp[(tId_x+num_thread)*36+ians]; } } num_thread/=2; } if(tId_x==0){ for(int ians=0;ians<36;ians++){ ans[(i_contrc_bra*contrc_ket_num+j_contrc_ket)*36+ians]=ans_temp[(tId_x)*36+ians]; } } } } }
671b4bfc57d9bfab4970df275e60ed4168e01354.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" /** * @file spmm.cu * @author Muhammad Osama ([email protected]) * @brief Sparse matrix-matrix multiplication * @version 0.1 * @date 2022-01-20 * * @copyright Copyright (c) 2022 * */ #include <chrono> #include <iomanip> #include <iostream> #include <thrust/device_vector.h> #include <thrust/host_vector.h> #include <gunrock/formats/formats.hxx> #include <gunrock/io/matrix_market.hxx> #include <gunrock/algorithms/generate/random.hxx> #include <gunrock/util/print.hxx> #include <gunrock/util/timer.hxx> #include <gunrock/util/compare.hxx> #include <gunrock/util/load_store.hxx> using namespace gunrock; enum access_mode_t { row_major, col_major }; template <typename type_t, access_mode_t mode = row_major> struct matrix_t { __host__ __device__ constexpr matrix_t() : height(0), width(0), data(nullptr) {} __host__ __device__ constexpr matrix_t(std::size_t _height, std::size_t _width, type_t* _data) : height(_height), width(_width), data(_data) {} __host__ __device__ constexpr matrix_t(const matrix_t& other) : height(other.height), width(other.width), data(other.data) {} __host__ __device__ __forceinline__ constexpr std::size_t size() const noexcept { return height * width; } __host__ __device__ __forceinline__ constexpr type_t& operator()( std::size_t row, std::size_t col) noexcept { // return data[mode == row_major ? row * width + col : row + col * height]; return data[row * width + col]; } __host__ __device__ __forceinline__ constexpr const type_t& operator()( std::size_t row, std::size_t col) const noexcept { return data[row * width + col]; } void print() { thrust::device_vector<type_t> d_data(data, data + size()); thrust::host_vector<type_t> h_data = d_data; std::cout << "Matrix: " << height << " x " << width << std::endl; std::cout << "==========================" << std::endl; for (std::size_t row = 0; row < height; ++row) { for (std::size_t col = 0; col < width; ++col) { std::cout << h_data[row * width + col] << "\t"; } std::cout << std::endl; } std::cout << "==========================" << std::endl; } std::size_t height; std::size_t width; type_t* data; }; template <typename type_t, typename offset_t, typename index_t> void cpu_spmm(std::size_t const m, std::size_t const n, std::size_t const nnz, const offset_t* offsets, const index_t* indices, const type_t* values, matrix_t<type_t> const B, matrix_t<type_t> C) { for (index_t row = 0; row < m; ++row) { for (index_t col = 0; col < n; ++col) { type_t sum = 0.0f; for (auto nz = offsets[row]; nz < offsets[row + 1]; ++nz) { sum += values[nz] * B(indices[nz], col); } C(row, col) = sum; } } } template <std::size_t ATOM_X = 1, std::size_t ATOM_Y = 1, std::size_t TILE_X = 16, std::size_t TILE_Y = 16, typename type_t, typename offset_t, typename index_t> __global__ void spmm(std::size_t nnz, offset_t* offsets, index_t* indices, type_t* values, matrix_t<type_t> const B, matrix_t<type_t> C) { // constexpr std::size_t ATOM_SIZE = ATOM_X * ATOM_Y; constexpr std::size_t TILE_SIZE = TILE_X * TILE_Y; __shared__ offset_t sh_offsets[TILE_SIZE + 1]; // For all rows of sparse-matrix A. for (index_t row = threadIdx.x + (blockIdx.x * blockDim.x); row < C.height; row += blockDim.x * gridDim.x) { // Load the row offsets of A into shared memory. sh_offsets[threadIdx.x] = offsets[row]; if (threadIdx.x == (blockDim.x - 1) || row == (C.height - 1)) { sh_offsets[threadIdx.x + 1] = offsets[row + 1]; } __syncthreads(); offset_t offset = sh_offsets[threadIdx.x]; offset_t end = sh_offsets[threadIdx.x + 1]; // For all columns of sparse-matrix B. for (index_t col = 0; col < C.width; ++col) { type_t sum = 0.0f; for (offset_t nz = offset; nz < end; ++nz) { index_t k = thread::load(&indices[nz]); type_t val = thread::load(&values[nz]); type_t b_val = B(k, col); sum += val * b_val; } thread::store(&C(row, col), sum); } } } int main(int argc, char** argv) { using type_t = float; using vertex_t = int; using edge_t = int; using weight_t = type_t; using namespace gunrock; using namespace memory; using namespace format; std::string filename = argv[1]; io::matrix_market_t<vertex_t, edge_t, weight_t> mm; csr_t<memory_space_t::device, vertex_t, edge_t, weight_t> A; A.from_coo(mm.load(filename)); std::size_t m = A.number_of_rows; std::size_t k = A.number_of_columns; std::size_t n = 4; std::size_t nnz = A.number_of_nonzeros; thrust::device_vector<type_t> B_vec(k * n); thrust::device_vector<type_t> C_vec(m * n); generate::random::uniform_distribution(B_vec, 1.0f, 2.0f); matrix_t<type_t> B(k, n, B_vec.data().get()); matrix_t<type_t> C(m, n, C_vec.data().get()); constexpr std::size_t BLK_X = 16; constexpr std::size_t BLK_Y = 16; constexpr std::size_t num_threads = BLK_X * BLK_Y; std::size_t num_blocks = (m + num_threads - 1) / num_threads; util::timer_t timer; timer.start(); hipLaunchKernelGGL(( spmm), dim3(num_blocks), dim3(num_threads), 0, 0, nnz, A.row_offsets.data().get(), A.column_indices.data().get(), A.nonzero_values.data().get(), B, C); hipDeviceSynchronize(); auto gpu_elapsed = timer.end(); std::cout << "GPU Elapsed (ms): " << gpu_elapsed << std::endl; csr_t<memory_space_t::host, vertex_t, edge_t, weight_t> A_host(A); thrust::host_vector<type_t> B_host_vec = B_vec; thrust::host_vector<type_t> C_host_vec(m * n); matrix_t<type_t> B_host(k, n, B_host_vec.data()); matrix_t<type_t> C_host(m, n, C_host_vec.data()); auto start = std::chrono::high_resolution_clock::now(); cpu_spmm(m, n, nnz, // Sizes A_host.row_offsets.data(), // A offsets A_host.column_indices.data(), // A indices A_host.nonzero_values.data(), // A non-zero values B_host, // B tensor C_host // C tensor ); auto end = std::chrono::high_resolution_clock::now(); auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(end - start) .count(); std::cout << "CPU Elapsed (ms): " << (float)(elapsed / 1000) << std::endl; int n_errors = util::compare( C_vec.data().get(), C_host_vec.data(), m * n, [](const weight_t a, const weight_t b) { return std::abs(a - b) > 1e-6; }, true); std::cout << "Number of errors: " << n_errors << std::endl; }
671b4bfc57d9bfab4970df275e60ed4168e01354.cu
/** * @file spmm.cu * @author Muhammad Osama ([email protected]) * @brief Sparse matrix-matrix multiplication * @version 0.1 * @date 2022-01-20 * * @copyright Copyright (c) 2022 * */ #include <chrono> #include <iomanip> #include <iostream> #include <thrust/device_vector.h> #include <thrust/host_vector.h> #include <gunrock/formats/formats.hxx> #include <gunrock/io/matrix_market.hxx> #include <gunrock/algorithms/generate/random.hxx> #include <gunrock/util/print.hxx> #include <gunrock/util/timer.hxx> #include <gunrock/util/compare.hxx> #include <gunrock/util/load_store.hxx> using namespace gunrock; enum access_mode_t { row_major, col_major }; template <typename type_t, access_mode_t mode = row_major> struct matrix_t { __host__ __device__ constexpr matrix_t() : height(0), width(0), data(nullptr) {} __host__ __device__ constexpr matrix_t(std::size_t _height, std::size_t _width, type_t* _data) : height(_height), width(_width), data(_data) {} __host__ __device__ constexpr matrix_t(const matrix_t& other) : height(other.height), width(other.width), data(other.data) {} __host__ __device__ __forceinline__ constexpr std::size_t size() const noexcept { return height * width; } __host__ __device__ __forceinline__ constexpr type_t& operator()( std::size_t row, std::size_t col) noexcept { // return data[mode == row_major ? row * width + col : row + col * height]; return data[row * width + col]; } __host__ __device__ __forceinline__ constexpr const type_t& operator()( std::size_t row, std::size_t col) const noexcept { return data[row * width + col]; } void print() { thrust::device_vector<type_t> d_data(data, data + size()); thrust::host_vector<type_t> h_data = d_data; std::cout << "Matrix: " << height << " x " << width << std::endl; std::cout << "==========================" << std::endl; for (std::size_t row = 0; row < height; ++row) { for (std::size_t col = 0; col < width; ++col) { std::cout << h_data[row * width + col] << "\t"; } std::cout << std::endl; } std::cout << "==========================" << std::endl; } std::size_t height; std::size_t width; type_t* data; }; template <typename type_t, typename offset_t, typename index_t> void cpu_spmm(std::size_t const m, std::size_t const n, std::size_t const nnz, const offset_t* offsets, const index_t* indices, const type_t* values, matrix_t<type_t> const B, matrix_t<type_t> C) { for (index_t row = 0; row < m; ++row) { for (index_t col = 0; col < n; ++col) { type_t sum = 0.0f; for (auto nz = offsets[row]; nz < offsets[row + 1]; ++nz) { sum += values[nz] * B(indices[nz], col); } C(row, col) = sum; } } } template <std::size_t ATOM_X = 1, std::size_t ATOM_Y = 1, std::size_t TILE_X = 16, std::size_t TILE_Y = 16, typename type_t, typename offset_t, typename index_t> __global__ void spmm(std::size_t nnz, offset_t* offsets, index_t* indices, type_t* values, matrix_t<type_t> const B, matrix_t<type_t> C) { // constexpr std::size_t ATOM_SIZE = ATOM_X * ATOM_Y; constexpr std::size_t TILE_SIZE = TILE_X * TILE_Y; __shared__ offset_t sh_offsets[TILE_SIZE + 1]; // For all rows of sparse-matrix A. for (index_t row = threadIdx.x + (blockIdx.x * blockDim.x); row < C.height; row += blockDim.x * gridDim.x) { // Load the row offsets of A into shared memory. sh_offsets[threadIdx.x] = offsets[row]; if (threadIdx.x == (blockDim.x - 1) || row == (C.height - 1)) { sh_offsets[threadIdx.x + 1] = offsets[row + 1]; } __syncthreads(); offset_t offset = sh_offsets[threadIdx.x]; offset_t end = sh_offsets[threadIdx.x + 1]; // For all columns of sparse-matrix B. for (index_t col = 0; col < C.width; ++col) { type_t sum = 0.0f; for (offset_t nz = offset; nz < end; ++nz) { index_t k = thread::load(&indices[nz]); type_t val = thread::load(&values[nz]); type_t b_val = B(k, col); sum += val * b_val; } thread::store(&C(row, col), sum); } } } int main(int argc, char** argv) { using type_t = float; using vertex_t = int; using edge_t = int; using weight_t = type_t; using namespace gunrock; using namespace memory; using namespace format; std::string filename = argv[1]; io::matrix_market_t<vertex_t, edge_t, weight_t> mm; csr_t<memory_space_t::device, vertex_t, edge_t, weight_t> A; A.from_coo(mm.load(filename)); std::size_t m = A.number_of_rows; std::size_t k = A.number_of_columns; std::size_t n = 4; std::size_t nnz = A.number_of_nonzeros; thrust::device_vector<type_t> B_vec(k * n); thrust::device_vector<type_t> C_vec(m * n); generate::random::uniform_distribution(B_vec, 1.0f, 2.0f); matrix_t<type_t> B(k, n, B_vec.data().get()); matrix_t<type_t> C(m, n, C_vec.data().get()); constexpr std::size_t BLK_X = 16; constexpr std::size_t BLK_Y = 16; constexpr std::size_t num_threads = BLK_X * BLK_Y; std::size_t num_blocks = (m + num_threads - 1) / num_threads; util::timer_t timer; timer.start(); spmm<<<num_blocks, num_threads>>>(nnz, A.row_offsets.data().get(), A.column_indices.data().get(), A.nonzero_values.data().get(), B, C); cudaDeviceSynchronize(); auto gpu_elapsed = timer.end(); std::cout << "GPU Elapsed (ms): " << gpu_elapsed << std::endl; csr_t<memory_space_t::host, vertex_t, edge_t, weight_t> A_host(A); thrust::host_vector<type_t> B_host_vec = B_vec; thrust::host_vector<type_t> C_host_vec(m * n); matrix_t<type_t> B_host(k, n, B_host_vec.data()); matrix_t<type_t> C_host(m, n, C_host_vec.data()); auto start = std::chrono::high_resolution_clock::now(); cpu_spmm(m, n, nnz, // Sizes A_host.row_offsets.data(), // A offsets A_host.column_indices.data(), // A indices A_host.nonzero_values.data(), // A non-zero values B_host, // B tensor C_host // C tensor ); auto end = std::chrono::high_resolution_clock::now(); auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(end - start) .count(); std::cout << "CPU Elapsed (ms): " << (float)(elapsed / 1000) << std::endl; int n_errors = util::compare( C_vec.data().get(), C_host_vec.data(), m * n, [](const weight_t a, const weight_t b) { return std::abs(a - b) > 1e-6; }, true); std::cout << "Number of errors: " << n_errors << std::endl; }
2199bdcf13e436fa94e889417d51918cde40e718.hip
// !!! This is a file automatically generated by hipify!!! #include <pybind11/numpy.h> #include <pybind11/pybind11.h> #include "../model/decoder.h" #include "../model/encoder.h" #include "../proto/transformer_weight.h" #include "../tools/util.h" #ifdef FP16_MODE const lightseq::cuda::OperationType transformer_optytpe = lightseq::cuda::OperationType::FP16; #else const lightseq::cuda::OperationType transformer_optytpe = lightseq::cuda::OperationType::FP32; #endif namespace py = pybind11; namespace lightseq { namespace cuda { class Transformer { private: typedef lightseq::cuda::OperationTypeTraits<transformer_optytpe> optraits; lightseq::cuda::Encoder<transformer_optytpe> *encoder_; lightseq::cuda::Decoder<transformer_optytpe> *decoder_; optraits::DataType *d_encoder_output_; int *d_input_; int *d_output_; int *d_padding_mask_; int _max_batch_size; hipStream_t stream_; hipblasHandle_t hd_; lightseq::cuda::TransformerWeight<transformer_optytpe> tw_; std::set<std::string> available_sampling_methods = {"beam_search", "topk", "topp", "topk_greedy"}; public: Transformer(const std::string weight_path, const int max_batch_size) : stream_(nullptr), hd_(nullptr), decoder_(nullptr) { /* ---step1. init environment--- */ _max_batch_size = max_batch_size; hipError_t cuerr = hipSetDevice(0); if (cuerr != hipSuccess) { throw std::runtime_error(hipGetErrorString(cuerr)); } cuerr = hipStreamCreate(&stream_); if (cuerr != hipSuccess) { throw std::runtime_error(hipGetErrorString(cuerr)); } hipblasStatus_t cublaserr = hipblasCreate(&hd_); if (cublaserr != HIPBLAS_STATUS_SUCCESS) { throw std::runtime_error("Failed to creat cublas handle "); } cublaserr = hipblasSetStream(hd_, stream_); if (cublaserr != HIPBLAS_STATUS_SUCCESS) { throw std::runtime_error("Failed to set stream for cublas handle"); } /* ---step2. load model weights into GPU memory--- */ // saved in custom proto file std::string model_weights_path = weight_path; std::string res = tw_.initializing(model_weights_path); if (!res.empty()) { throw std::runtime_error(res); } if (tw_._sampling_method == "topk" || tw_._sampling_method == "topp") { tw_._beam_size = 1; } tw_.print_model_config(); /* step3. instantiate encoder and decoder, init the gpu memory buffer. using thrust vector to avoid manage gpu memory by hand */ // register device memory for inputs and outputs lightseq::cuda::CHECK_GPU_ERROR( hipMalloc(&d_input_, _max_batch_size * tw_._max_step * sizeof(int))); lightseq::cuda::CHECK_GPU_ERROR(hipMalloc( &d_padding_mask_, _max_batch_size * tw_._max_step * sizeof(int))); lightseq::cuda::CHECK_GPU_ERROR(hipMalloc( &d_encoder_output_, _max_batch_size * tw_._max_step * tw_._hidden_size * sizeof(optraits::DataType))); lightseq::cuda::CHECK_GPU_ERROR(hipMalloc( &d_output_, _max_batch_size * tw_._beam_size * tw_._max_step * sizeof(int))); encoder_ = new lightseq::cuda::Encoder<transformer_optytpe>( max_batch_size, d_input_, d_padding_mask_, d_encoder_output_, tw_, stream_, hd_); res = encoder_->check(); if (!res.empty()) { throw std::runtime_error(res); } decoder_ = new lightseq::cuda::Decoder<transformer_optytpe>( _max_batch_size, d_padding_mask_, d_encoder_output_, d_output_, tw_, stream_, hd_, true); res = decoder_->check(); if (!res.empty()) { throw std::runtime_error(res); } long buf_bytesize = ::max(encoder_->compute_buffer_bytesize(), decoder_->compute_buffer_bytesize()); std::cout << "transformer buf_bytesize: " << buf_bytesize << std::endl; void *d_buf_; // encoder and decoder use the same buffer to save gpu memory useage lightseq::cuda::CHECK_GPU_ERROR( hipMalloc((void **)&d_buf_, (size_t)buf_bytesize)); encoder_->init_buffer(d_buf_); decoder_->init_buffer(d_buf_); cuerr = hipStreamSynchronize(stream_); if (cuerr != hipSuccess) { std::cout << "Failed to init GPU for transformer" << std::endl; std::runtime_error(std::string(hipGetErrorString(cuerr))); } } std::tuple<py::array_t<int>, py::array_t<float>> infer( py::array_t<int, py::array::c_style | py::array::forcecast> input_seq, bool multiple_output = false, std::string sampling_method = "", int beam_size = -1, float length_penalty = -1, float topp = -1, float topk = -1, float diverse_lambda = -1) { if (available_sampling_methods.find(sampling_method) != available_sampling_methods.end()) { tw_._sampling_method = sampling_method; } if (sampling_method == "topk" || sampling_method == "topp") { multiple_output = false; } if (sampling_method == "topk_greedy") { multiple_output = true; } decoder_->_output_topk = multiple_output; auto input_seq_out = input_seq.mutable_unchecked<2>(); const int *input_seq_data = input_seq_out.data(0, 0); int batch_size = input_seq_out.shape(0); int batch_seq_len = input_seq_out.shape(1); if (batch_size > _max_batch_size) { throw std::runtime_error( "batch size of input greater than max_batch_size"); } if (batch_seq_len > tw_._max_step) { throw std::runtime_error("seq len of input greater than max_step"); } lightseq::cuda::CHECK_GPU_ERROR(hipMemcpyAsync( d_input_, input_seq_data, sizeof(int) * input_seq_out.size(), hipMemcpyHostToDevice, stream_)); encoder_->run_one_infer(batch_size, batch_seq_len); decoder_->run_one_infer(batch_size, batch_seq_len); int tokens_size = decoder_->_cur_step + 1; beam_size = tw_._beam_size; int output_k = multiple_output ? beam_size : 1; auto tokens = py::array_t<int>({batch_size, output_k, tokens_size}); int *tokens_data = tokens.mutable_data(0, 0); lightseq::cuda::CHECK_GPU_ERROR(hipMemcpy(tokens_data, d_output_, sizeof(int) * tokens.size(), hipMemcpyDeviceToHost)); auto scores = py::array_t<float>({batch_size, output_k}); float *scores_data = scores.mutable_data(0, 0); lightseq::cuda::CHECK_GPU_ERROR( hipMemcpy(scores_data, decoder_->_p_d_alive_seq_score, sizeof(float) * scores.size(), hipMemcpyDeviceToHost)); return std::make_tuple(tokens, scores); } }; } // namespace cuda } // namespace lightseq
2199bdcf13e436fa94e889417d51918cde40e718.cu
#include <pybind11/numpy.h> #include <pybind11/pybind11.h> #include "../model/decoder.h" #include "../model/encoder.h" #include "../proto/transformer_weight.h" #include "../tools/util.h" #ifdef FP16_MODE const lightseq::cuda::OperationType transformer_optytpe = lightseq::cuda::OperationType::FP16; #else const lightseq::cuda::OperationType transformer_optytpe = lightseq::cuda::OperationType::FP32; #endif namespace py = pybind11; namespace lightseq { namespace cuda { class Transformer { private: typedef lightseq::cuda::OperationTypeTraits<transformer_optytpe> optraits; lightseq::cuda::Encoder<transformer_optytpe> *encoder_; lightseq::cuda::Decoder<transformer_optytpe> *decoder_; optraits::DataType *d_encoder_output_; int *d_input_; int *d_output_; int *d_padding_mask_; int _max_batch_size; cudaStream_t stream_; cublasHandle_t hd_; lightseq::cuda::TransformerWeight<transformer_optytpe> tw_; std::set<std::string> available_sampling_methods = {"beam_search", "topk", "topp", "topk_greedy"}; public: Transformer(const std::string weight_path, const int max_batch_size) : stream_(nullptr), hd_(nullptr), decoder_(nullptr) { /* ---step1. init environment--- */ _max_batch_size = max_batch_size; cudaError_t cuerr = cudaSetDevice(0); if (cuerr != cudaSuccess) { throw std::runtime_error(cudaGetErrorString(cuerr)); } cuerr = cudaStreamCreate(&stream_); if (cuerr != cudaSuccess) { throw std::runtime_error(cudaGetErrorString(cuerr)); } cublasStatus_t cublaserr = cublasCreate(&hd_); if (cublaserr != CUBLAS_STATUS_SUCCESS) { throw std::runtime_error("Failed to creat cublas handle "); } cublaserr = cublasSetStream(hd_, stream_); if (cublaserr != CUBLAS_STATUS_SUCCESS) { throw std::runtime_error("Failed to set stream for cublas handle"); } /* ---step2. load model weights into GPU memory--- */ // saved in custom proto file std::string model_weights_path = weight_path; std::string res = tw_.initializing(model_weights_path); if (!res.empty()) { throw std::runtime_error(res); } if (tw_._sampling_method == "topk" || tw_._sampling_method == "topp") { tw_._beam_size = 1; } tw_.print_model_config(); /* step3. instantiate encoder and decoder, init the gpu memory buffer. using thrust vector to avoid manage gpu memory by hand */ // register device memory for inputs and outputs lightseq::cuda::CHECK_GPU_ERROR( cudaMalloc(&d_input_, _max_batch_size * tw_._max_step * sizeof(int))); lightseq::cuda::CHECK_GPU_ERROR(cudaMalloc( &d_padding_mask_, _max_batch_size * tw_._max_step * sizeof(int))); lightseq::cuda::CHECK_GPU_ERROR(cudaMalloc( &d_encoder_output_, _max_batch_size * tw_._max_step * tw_._hidden_size * sizeof(optraits::DataType))); lightseq::cuda::CHECK_GPU_ERROR(cudaMalloc( &d_output_, _max_batch_size * tw_._beam_size * tw_._max_step * sizeof(int))); encoder_ = new lightseq::cuda::Encoder<transformer_optytpe>( max_batch_size, d_input_, d_padding_mask_, d_encoder_output_, tw_, stream_, hd_); res = encoder_->check(); if (!res.empty()) { throw std::runtime_error(res); } decoder_ = new lightseq::cuda::Decoder<transformer_optytpe>( _max_batch_size, d_padding_mask_, d_encoder_output_, d_output_, tw_, stream_, hd_, true); res = decoder_->check(); if (!res.empty()) { throw std::runtime_error(res); } long buf_bytesize = std::max(encoder_->compute_buffer_bytesize(), decoder_->compute_buffer_bytesize()); std::cout << "transformer buf_bytesize: " << buf_bytesize << std::endl; void *d_buf_; // encoder and decoder use the same buffer to save gpu memory useage lightseq::cuda::CHECK_GPU_ERROR( cudaMalloc((void **)&d_buf_, (size_t)buf_bytesize)); encoder_->init_buffer(d_buf_); decoder_->init_buffer(d_buf_); cuerr = cudaStreamSynchronize(stream_); if (cuerr != cudaSuccess) { std::cout << "Failed to init GPU for transformer" << std::endl; std::runtime_error(std::string(cudaGetErrorString(cuerr))); } } std::tuple<py::array_t<int>, py::array_t<float>> infer( py::array_t<int, py::array::c_style | py::array::forcecast> input_seq, bool multiple_output = false, std::string sampling_method = "", int beam_size = -1, float length_penalty = -1, float topp = -1, float topk = -1, float diverse_lambda = -1) { if (available_sampling_methods.find(sampling_method) != available_sampling_methods.end()) { tw_._sampling_method = sampling_method; } if (sampling_method == "topk" || sampling_method == "topp") { multiple_output = false; } if (sampling_method == "topk_greedy") { multiple_output = true; } decoder_->_output_topk = multiple_output; auto input_seq_out = input_seq.mutable_unchecked<2>(); const int *input_seq_data = input_seq_out.data(0, 0); int batch_size = input_seq_out.shape(0); int batch_seq_len = input_seq_out.shape(1); if (batch_size > _max_batch_size) { throw std::runtime_error( "batch size of input greater than max_batch_size"); } if (batch_seq_len > tw_._max_step) { throw std::runtime_error("seq len of input greater than max_step"); } lightseq::cuda::CHECK_GPU_ERROR(cudaMemcpyAsync( d_input_, input_seq_data, sizeof(int) * input_seq_out.size(), cudaMemcpyHostToDevice, stream_)); encoder_->run_one_infer(batch_size, batch_seq_len); decoder_->run_one_infer(batch_size, batch_seq_len); int tokens_size = decoder_->_cur_step + 1; beam_size = tw_._beam_size; int output_k = multiple_output ? beam_size : 1; auto tokens = py::array_t<int>({batch_size, output_k, tokens_size}); int *tokens_data = tokens.mutable_data(0, 0); lightseq::cuda::CHECK_GPU_ERROR(cudaMemcpy(tokens_data, d_output_, sizeof(int) * tokens.size(), cudaMemcpyDeviceToHost)); auto scores = py::array_t<float>({batch_size, output_k}); float *scores_data = scores.mutable_data(0, 0); lightseq::cuda::CHECK_GPU_ERROR( cudaMemcpy(scores_data, decoder_->_p_d_alive_seq_score, sizeof(float) * scores.size(), cudaMemcpyDeviceToHost)); return std::make_tuple(tokens, scores); } }; } // namespace cuda } // namespace lightseq
9008b5b45742761763ab8c88fd56d4313d8fe57f.hip
// !!! This is a file automatically generated by hipify!!! /***** Copyright (C) 2016 Pierre Karpman, INRIA France/Nanyang Technological University Singapore (-2016), CWI (2016/2017), L'Universite Grenoble Alpes (2017-) (C) 2016 Thomas Peyrin, Nanyang Technological University Singapore (C) 2016 Marc Stevens, Centrum Wiskunde & Informatica (CWI), Amsterdam. This file is part of sha1_gpu_nearcollisionattacks source-code and released under the MIT License *****/ /************ TODO TODO **********\ \************ TODO TODO *********/ //// main prepocessor flags // enables managed cyclic buffers and CPU verification of GPU results //#define DEBUG1 // disabling temporary buffer will force writes to directly go to main buffer #define DISABLE_TMP_BUF // enable performance counters //#define USE_PERF_COUNTERS // PERFORMANCE COUNTERS ARE NOW WORKING PROPERLY AND HAVE VERY SMALL OVERHEAD #ifndef DEBUG1 #define BLOCKS 26 #define THREADS_PER_BLOCK 512 #define DEBUG_BREAK #else #define BLOCKS 2 #define THREADS_PER_BLOCK 512 #define DEBUG_BREAK break; #endif #include "main.hpp" #include "neutral_bits_packing.hpp" #include "sha1detail.hpp" #include <cuda_cyclicbuffer.hpp> #include <timer.hpp> #include <hip/hip_runtime.h> #include <hip/hip_runtime.h> #include <map> #include <iostream> #include <fstream> #include <iomanip> #include <stdexcept> using namespace hashclash; using namespace std; #define CUDA_ASSERT(s) { hipError_t err = s; if (err != hipSuccess) { throw std::runtime_error("CUDA command returned: " + string(hipGetErrorString(err)) + "!"); } } // set other defines based on main preprocessor flags #ifdef DEBUG1 #ifndef USE_MANAGED #define USE_MANAGED #endif #define VERIFY_GPU_RESULTS #endif // DEBUG1 #ifdef USE_MANAGED #define MANAGED __managed__ #else #define MANAGED #endif // DEFINE CYCLIC BUFFER TYPES // MASK VERSION // template<size_t N> struct cyclic_buffer_control_mask_t; // template<size_t N> struct cyclic_buffer_control_mask_readlock_t; // template<size_t N, typename val_t = uint32_t, size_t val_cnt = 1, typename control_type = cyclic_buffer_control_mask_t<N> > struct cyclic_buffer_mask_t; // CAS VERSION // template<size_t N> struct cyclic_buffer_control_cas_t; // template<size_t N, typename val_t = uint32_t, size_t val_cnt = 1, typename control_type = cyclic_buffer_control_cas_t<N> > struct cyclic_buffer_cas_t; // definition of cyclic buffer for 2^16 22-word elems: basesol: Q12,..,Q17,m5,...,m20 [uses CAS, as it's only written by the host] typedef cyclic_buffer_cas_t< BASESOLCOUNT, uint32_t, 22, cyclic_buffer_control_cas_t< BASESOLCOUNT > > buffer_basesol_t; typedef buffer_basesol_t::control_t control_basesol_t; // definition of cyclic buffer for 2^20 2-word elems typedef cyclic_buffer_mask_t< (1<<20), uint32_t, 2, cyclic_buffer_control_mask_t< (1<<20) >, 1 > buffer_20_2_t; // used for block-specific buffers: fencetype = block-wide typedef buffer_20_2_t::control_t control_20_2_t; typedef cyclic_buffer_cas_t< (1<<20), uint32_t, 2, cyclic_buffer_control_cas_t< (1<<20) >, 2 > gl_buffer_20_2_t; // used for global buffers: fencetype = gpu-wide typedef gl_buffer_20_2_t::control_t gl_control_20_2_t; // definition of cyclic buffer for 2^20 11-word elems: extbasesol: q15, q16, q17, m14, m15, m16, m17, m18, m19, m20, base_idx typedef cyclic_buffer_mask_t< (1<<20), uint32_t, 11, cyclic_buffer_control_mask_t< (1<<20) >, 1 > buffer_extbasesol20_t; // used for block-specific buffers: fencetype = block-wide typedef buffer_extbasesol20_t::control_t control_extbasesol20_t; // Marc: let's try steps 28-30 with 3 conditions total together and output extbasesol20+m17+m18+m19+booms typedef cyclic_buffer_mask_t< (1 << 20), uint32_t, 3, cyclic_buffer_control_mask_t< (1 << 20) >, 1 > buffer_30_3_t; // used for block-specific buffers: fencetype = block-wide typedef buffer_30_3_t::control_t control_30_3_t; // definition of cyclic buffer for 2^10 21-word elems: sol: Q36,..,Q40,m24,...,m39 // definition of cyclic buffer for 2^10 21-word elems: sol: Q56,..,Q60,m44,...,m59 typedef cyclic_buffer_cas_t< (1<<10), uint32_t, 21, cyclic_buffer_control_cas_t< (1<<10) >, 2 > buffer_sol_t; typedef buffer_sol_t::control_t control_sol_t; // WARP-SPECIFIC TEMPORARY BUFFER (2x 32 2-word elems) // Usage: (all warp-wide calls) // WARP_TMP_BUF.reset() // called once on kernel entrance // WARP_TMP_BUF.write1(bool,val1,buf,ctrl) // write 1-word elem to tmp buf, flush to mainbuf when one half of 32 is full // WARP_TMP_BUF.write2(bool,val1,val2,buf,ctrl) // write 2-word elem to tmp buf, flush to mainbuf when one half of 32 is full // WARP_TMP_BUF.flush1(buf,ctrl) // call once on function exit to move remaining 1-word elems to mainbuf // WARP_TMP_BUF.flush2(buf,ctrl) // call once on function exit to move remaining 2-word elems to mainbuf // #ifdef DISABLE_TMP_BUF class dummy_tmp_buf { public: inline __device__ void reset() {} template<typename buffer_t, typename control_t> inline __device__ void flush1(buffer_t& buf, control_t& ctrl) {} template<typename buffer_t, typename control_t> inline __device__ void flush2(buffer_t& buf, control_t& ctrl) {} template<typename buffer_t, typename control_t> inline __device__ void write1(bool dowrite, uint32_t val1, buffer_t& buf, control_t& ctrl) { buf.write(ctrl, dowrite, val1); } template<typename buffer_t, typename control_t> inline __device__ void write2(bool dowrite, uint32_t val1, uint32_t val2, buffer_t& buf, control_t& ctrl) { buf.write(ctrl, dowrite, val1, val2); } }; __shared__ dummy_tmp_buf dummytmpbuf; #define WARP_TMP_BUF dummytmpbuf #else __shared__ warp_tmp_buf_t warp_tmp_buf[THREADS_PER_BLOCK/32]; #define WARP_TMP_BUF warp_tmp_buf[threadIdx.x/32] #endif #define MANAGED2 __managed__ //#define MANAGED2 MANAGED // FIXME OLD /*** Main buffers declaration ***/ MANAGED __device__ buffer_basesol_t base_solutions_buf; __managed__ __device__ control_basesol_t base_solutions_ctl; // always managed to detect when it's empty #define BASESOLBUF base_solutions_buf #define BASESOLCTL base_solutions_ctl MANAGED __device__ gl_buffer_20_2_t q18_solutions_buf; __managed__ __device__ gl_control_20_2_t q18_solutions_ctl; #define Q18SOLBUF q18_solutions_buf #define Q18SOLCTL q18_solutions_ctl MANAGED __device__ gl_buffer_20_2_t q19_solutions_buf; __managed__ __device__ gl_control_20_2_t q19_solutions_ctl; #define Q19SOLBUF q19_solutions_buf #define Q19SOLCTL q19_solutions_ctl MANAGED __device__ buffer_extbasesol20_t q20_solutions_buf[BLOCKS]; __shared__ control_extbasesol20_t q20_solutions_ctl; MANAGED2 __device__ control_extbasesol20_t q20_solutions_ctl_bu [BLOCKS]; #define Q20SOLBUF q20_solutions_buf [blockIdx.x] #define Q20SOLCTL q20_solutions_ctl MANAGED __device__ buffer_20_2_t q21_solutions_buf[BLOCKS]; __shared__ control_20_2_t q21_solutions_ctl; MANAGED2 __device__ control_20_2_t q21_solutions_ctl_bu [BLOCKS]; #define Q21SOLBUF q21_solutions_buf [blockIdx.x] #define Q21SOLCTL q21_solutions_ctl MANAGED __device__ buffer_20_2_t q22_solutions_buf[BLOCKS]; __shared__ control_20_2_t q22_solutions_ctl; MANAGED2 __device__ control_20_2_t q22_solutions_ctl_bu [BLOCKS]; #define Q22SOLBUF q22_solutions_buf [blockIdx.x] #define Q22SOLCTL q22_solutions_ctl MANAGED __device__ buffer_20_2_t q23_solutions_buf [BLOCKS]; __shared__ control_20_2_t q23_solutions_ctl; MANAGED2 __device__ control_20_2_t q23_solutions_ctl_bu [BLOCKS]; #define Q23SOLBUF q23_solutions_buf [blockIdx.x] #define Q23SOLCTL q23_solutions_ctl MANAGED __device__ buffer_20_2_t q26_solutions_buf [BLOCKS]; __shared__ control_20_2_t q26_solutions_ctl; MANAGED2 __device__ control_20_2_t q26_solutions_ctl_bu [BLOCKS]; #define Q26SOLBUF q26_solutions_buf [blockIdx.x] #define Q26SOLCTL q26_solutions_ctl MANAGED __device__ buffer_30_3_t q28_solutions_buf[BLOCKS]; __shared__ control_30_3_t q28_solutions_ctl; MANAGED2 __device__ control_30_3_t q28_solutions_ctl_bu [BLOCKS]; #define Q28SOLBUF q28_solutions_buf [blockIdx.x] #define Q28SOLCTL q28_solutions_ctl MANAGED __device__ buffer_30_3_t q30_solutions_buf[BLOCKS]; __shared__ control_30_3_t q30_solutions_ctl; MANAGED2 __device__ control_30_3_t q30_solutions_ctl_bu [BLOCKS]; #define Q30SOLBUF q30_solutions_buf [blockIdx.x] #define Q30SOLCTL q30_solutions_ctl MANAGED __device__ buffer_sol_t q40_solutions_buf[BLOCKS]; __shared__ control_sol_t q40_solutions_ctl; MANAGED2 __device__ control_sol_t q40_solutions_ctl_bu [BLOCKS]; #define Q40SOLBUF q40_solutions_buf [blockIdx.x] #define Q40SOLCTL q40_solutions_ctl __managed__ __device__ buffer_sol_t collision_candidates_buf; __managed__ __device__ control_sol_t collision_candidates_ctl; #define COLLCANDIDATEBUF collision_candidates_buf #define COLLCANDIDATECTL collision_candidates_ctl /*** performance measure stuff ***/ #ifdef USE_PERF_COUNTERS __managed__ uint64_t main_performance_counter[BLOCKS][80]; __shared__ uint32_t tmp_performance_counter[80]; __device__ inline void performance_reset() { for (unsigned b = 0; b < BLOCKS; ++b) { for (unsigned i = 0; i < 80; ++i) { main_performance_counter[b][i] = 0; } } } __device__ inline void performance_backup() { if (threadIdx.x == 0) { for (unsigned i = 0; i < 80; ++i) { main_performance_counter[blockIdx.x][i] += tmp_performance_counter[i]; } } } __device__ inline void performance_restore() { if (threadIdx.x == 0) { for (unsigned i = 0; i < 80; ++i) { //main_performance_counter[blockIdx.x][i] // = tmp_performance_counter[i] = 0; } } } __device__ inline void performance_start_counter(unsigned i) { if ((threadIdx.x&31)==0) atomicAdd(&tmp_performance_counter[i], (uint32_t)(uint64_t(0)-clock64())); } __device__ inline void performance_stop_counter(unsigned i) { if ((threadIdx.x&31)==0) atomicAdd(&tmp_performance_counter[i], uint32_t(clock64())); } #define PERF_START_COUNTER(i) performance_start_counter(i); #define PERF_STOP_COUNTER(i) performance_stop_counter(i); void show_performance_counters() { uint64_t total = 0; for (unsigned b = 0; b < BLOCKS; ++b) { for (unsigned i = 0; i < 80; ++i) { total += main_performance_counter[b][i]; } } for (unsigned i = 0; i < 80; ++i) { uint64_t stepi = 0; for (unsigned b = 0; b < BLOCKS; ++b) { stepi += main_performance_counter[b][i]; } if (stepi > 0) { cout << "Perf.counter " << i << "\t : " << setprecision(4) << (100.0*double(stepi)/double(total)) << " \t " << stepi << endl; } } } #else #define PERF_START_COUNTER(i) #define PERF_STOP_COUNTER(i) #endif // USE_PERF_COUNTERS /*** Bit condition masks for steps Q-4 to Q80, stored on the device in constant memory ***/ // QOFF: value for Q_t is at index QOFF+t in tables below #define QOFF 4 namespace host { #include "tables.hpp" } namespace dev { #define TABLE_PREFIX __constant__ #include "tables.hpp" } /* *** SHA1 FUNCTIONS ********************************** */ __host__ __device__ inline uint32_t sha1_round1(const uint32_t a, const uint32_t b, const uint32_t c, const uint32_t d, const uint32_t e, const uint32_t m) { // a = rotate_left (a, 5); // c = rotate_left(c, 30); // d = rotate_left(d, 30); // e = rotate_left(e, 30); return rotate_left(a,5) + sha1_f1(b, rotate_left(c,30), rotate_left(d,30)) + rotate_left(e,30) + m + 0x5A827999; } __host__ __device__ inline uint32_t sha1_round2(const uint32_t a, const uint32_t b, const uint32_t c, const uint32_t d, const uint32_t e, const uint32_t m) //__host__ __device__ inline uint32_t sha1_round2(uint32_t a, uint32_t b, uint32_t c, uint32_t d, uint32_t e, uint32_t m) { // a = rotate_left (a, 5); // c = rotate_left(c, 30); // d = rotate_left(d, 30); // e = rotate_left(e, 30); // return a + sha1_f2(b, c, d) + e + m + 0x6ED9EBA1; return rotate_left(a,5) + sha1_f2(b, rotate_left(c,30), rotate_left(d,30)) + rotate_left(e,30) + m + 0x6ED9EBA1; } __host__ __device__ inline uint32_t sha1_round3(const uint32_t a, const uint32_t b, const uint32_t c, const uint32_t d, const uint32_t e, const uint32_t m) { // a = rotate_left (a, 5); // c = rotate_left(c, 30); // d = rotate_left(d, 30); // e = rotate_left(e, 30); return rotate_left(a,5) + sha1_f3(b, rotate_left(c,30), rotate_left(d,30)) + rotate_left(e,30) + m + 0x8F1BBCDC; // return a + sha1_f3(b, c, d) + e + m + 0x8F1BBCDC; } __host__ __device__ inline uint32_t sha1_mess(uint32_t m_3, uint32_t m_8, uint32_t m_14, uint32_t m_16) { return rotate_left(m_3 ^ m_8 ^ m_14 ^ m_16, 1); } #define NEXT_NB(a,mask) { (a) -= 1; (a) &= mask;} __device__ void stepQ18(uint32_t base_idx) { PERF_START_COUNTER(18); using namespace dev; /// fetch the base solution uint32_t q12 = BASESOLBUF.get<0>(base_idx); uint32_t q13 = BASESOLBUF.get<1>(base_idx); uint32_t q14 = BASESOLBUF.get<2>(base_idx); uint32_t q15 = BASESOLBUF.get<3>(base_idx); uint32_t q16 = BASESOLBUF.get<4>(base_idx); uint32_t q17 = BASESOLBUF.get<5>(base_idx); uint32_t m14 = BASESOLBUF.get<15>(base_idx); uint32_t m15 = BASESOLBUF.get<16>(base_idx); uint32_t m16 = BASESOLBUF.get<17>(base_idx); uint32_t m17 = BASESOLBUF.get<18>(base_idx); uint32_t oldq16 = q16; uint32_t w14_q18_nb = 0; for (unsigned l = 0; l < (1<<4); ++l) { NEXT_NB(w14_q18_nb, W14NBQ18M); m14 &= ~W14NBQ18M; m14 |= w14_q18_nb; q15 += w14_q18_nb; q16 += rotate_left(w14_q18_nb, 5); uint32_t w15_q18_nb = 0; for (unsigned k = 0; k < (1<<4); ++k) { NEXT_NB(w15_q18_nb, W15NBQ18M); m15 &= ~W15NBQ18M; m15 |= w15_q18_nb; q16 += w15_q18_nb; bool valid_sol = (0 == ((oldq16 ^ q16) & Qcondmask[QOFF + 16])); uint32_t newq17 = sha1_round1(q16, q15, q14, q13, q12, m16); valid_sol &= 0 == ((newq17 ^ q17) & Qcondmask[QOFF + 17]); uint32_t newq18 = sha1_round1(newq17, q16, q15, q14, q13, m17); uint32_t q18nessies = Qset1mask[QOFF + 18] ^ (Qprevmask[QOFF + 18] & newq17) // ^ (Qprevrmask [QOFF + 18] & rotate_left(newq17, 30)) // ^ (Qprev2rmask[QOFF + 18] & rotate_left(newq16, 30)) ; valid_sol &= 0 == ((newq18 ^ q18nessies) & Qcondmask[QOFF + 18]); uint32_t sol_val_0 = pack_q18q20_sol0(base_idx, m14, m15); uint32_t sol_val_1 = pack_q18q20_sol1(base_idx, m14, m15); WARP_TMP_BUF.write2(valid_sol, sol_val_0, sol_val_1, Q18SOLBUF, Q18SOLCTL); q16 -= w15_q18_nb; } q16 -= rotate_left(w14_q18_nb, 5); q15 -= w14_q18_nb; } WARP_TMP_BUF.flush2(Q18SOLBUF, Q18SOLCTL); PERF_STOP_COUNTER(18); } __device__ void stepQ19(uint32_t thread_rd_idx) { PERF_START_COUNTER(19); using namespace dev; uint32_t q18_sol0 = Q18SOLBUF.get<0>(thread_rd_idx); uint32_t q18_sol1 = Q18SOLBUF.get<1>(thread_rd_idx); uint32_t base_idx = unpack_idx(q18_sol0, q18_sol1); uint32_t w14_sol_nb = unpack_w14_nbs(q18_sol0, q18_sol1); uint32_t w15_sol_nb = unpack_w15_nbs(q18_sol0, q18_sol1); /// fetch the base solution and update it to the Q18 solution using the above neutral bits uint32_t q12 = BASESOLBUF.get<0>(base_idx); uint32_t q13 = BASESOLBUF.get<1>(base_idx); uint32_t q14 = BASESOLBUF.get<2>(base_idx); uint32_t q15 = BASESOLBUF.get<3>(base_idx); uint32_t q16 = BASESOLBUF.get<4>(base_idx); uint32_t m14 = BASESOLBUF.get<15>(base_idx); uint32_t m15 = BASESOLBUF.get<16>(base_idx); uint32_t m16 = BASESOLBUF.get<17>(base_idx); uint32_t m17 = BASESOLBUF.get<18>(base_idx); uint32_t m18 = BASESOLBUF.get<19>(base_idx); m14 |= w14_sol_nb; m15 |= w15_sol_nb; q15 += w14_sol_nb; q16 += w15_sol_nb + rotate_left(w14_sol_nb, 5); uint32_t oldq17 = sha1_round1(q16, q15, q14, q13, q12, m16); uint32_t oldq18 = sha1_round1(oldq17, q16, q15, q14, q13, m17); q16 -= rotate_left(q15, 5); uint32_t w14_q19_nb = 0; for (unsigned j = 0; j < (1<<2); ++j) { NEXT_NB(w14_q19_nb, W14NBQ19M); // start to recompute the previous state m14 &= ~W14NBQ19M; m14 |= w14_q19_nb; q15 += w14_q19_nb; q16 += rotate_left(q15, 5); uint32_t w15_q19_nb = 0; for (unsigned i = 0; i < (1<<5); ++i) { NEXT_NB(w15_q19_nb, W15NBQ19M); m15 &= ~W15NBQ19M; m15 |= w15_q19_nb; q16 += w15_q19_nb; uint32_t w16_q19_nb = 0; for (unsigned l = 0; l < (1<<5); ++l) { NEXT_NB(w16_q19_nb, W16NBQ19M); m16 &= ~W16NBQ19M; m16 |= w16_q19_nb; uint32_t q17 = sha1_round1(q16, q15, q14, q13, q12, m16); uint32_t q18 = sha1_round1(q17, q16, q15, q14, q13, m17); uint32_t q19 = sha1_round1(q18, q17, q16, q15, q14, m18); bool valid_sol = (0 == ((oldq17 ^ q17) & Qcondmask[QOFF + 17])); valid_sol &= 0 == ((oldq18 ^ q18) & Qcondmask[QOFF+18]); uint32_t q19nessies = Qset1mask[QOFF + 19] ^ (Qprevmask [QOFF + 19] & q18) ^ (Qprevrmask [QOFF + 19] & rotate_left(q18, 30)) ^ (Qprev2rmask[QOFF + 19] & rotate_left(q17, 30)) ; valid_sol &= 0 == ((q19 ^ q19nessies) & Qcondmask[QOFF + 19]); uint32_t sol_val_0 = pack_q18q20_sol0(base_idx, m14, m15, m16); uint32_t sol_val_1 = pack_q18q20_sol1(base_idx, m14, m15, m16); WARP_TMP_BUF.write2(valid_sol, sol_val_0, sol_val_1, Q19SOLBUF, Q19SOLCTL); } q16 -= w15_q19_nb; } q16 -= rotate_left(q15, 5); q15 -= w14_q19_nb; } WARP_TMP_BUF.flush2(Q19SOLBUF, Q19SOLCTL); PERF_STOP_COUNTER(19); } __device__ void stepQ20(uint32_t thread_rd_idx) { PERF_START_COUNTER(20); using namespace dev; uint32_t q19_sol0 = Q19SOLBUF.get<0>(thread_rd_idx); uint32_t q19_sol1 = Q19SOLBUF.get<1>(thread_rd_idx); uint32_t base_idx = unpack_idx(q19_sol0, q19_sol1); uint32_t w14_sol_nb = unpack_w14_nbs(q19_sol0, q19_sol1); uint32_t w15_sol_nb = unpack_w15_nbs(q19_sol0, q19_sol1); uint32_t w16_sol_nb = unpack_w16_nbs(q19_sol0, q19_sol1); /// fetch the base solution and update it to the Q18 solution using the above neutral bits uint32_t q12 = BASESOLBUF.get<0>(base_idx); uint32_t q13 = BASESOLBUF.get<1>(base_idx); uint32_t q14 = BASESOLBUF.get<2>(base_idx); uint32_t q15 = BASESOLBUF.get<3>(base_idx); uint32_t q16 = BASESOLBUF.get<4>(base_idx); uint32_t m14 = BASESOLBUF.get<15>(base_idx); uint32_t m15 = BASESOLBUF.get<16>(base_idx); uint32_t m16 = BASESOLBUF.get<17>(base_idx); uint32_t m17 = BASESOLBUF.get<18>(base_idx); uint32_t m18 = BASESOLBUF.get<19>(base_idx); uint32_t m19 = BASESOLBUF.get<20>(base_idx); uint32_t m20 = BASESOLBUF.get<21>(base_idx); m14 |= w14_sol_nb; m15 |= w15_sol_nb; m16 |= w16_sol_nb; q15 += w14_sol_nb; q16 += w15_sol_nb + rotate_left(w14_sol_nb, 5); uint32_t oldq17 = sha1_round1(q16, q15, q14, q13, q12, m16); uint32_t oldq18 = sha1_round1(oldq17, q16, q15, q14, q13, m17); uint32_t oldq19 = sha1_round1(oldq18, oldq17, q16, q15, q14, m18); q16 -= m15; uint32_t w15_q20_nb = 0; for (unsigned i = 0; i < (1<<2); ++i) { NEXT_NB(w15_q20_nb, W15NBQ20M); m15 &= ~W15NBQ20M; m15 |= w15_q20_nb; q16 += m15; uint32_t w16_q20_nb = 0; for (unsigned l = 0; l < (1<<4); ++l) { NEXT_NB(w16_q20_nb, W16NBQ20M); m16 &= ~W16NBQ20M; m16 |= w16_q20_nb; uint32_t q17 = sha1_round1(q16, q15, q14, q13, q12, m16); uint32_t w17_q20_nb = 0; for (unsigned m = 0; m < (1<<6); ++m) { NEXT_NB(w17_q20_nb, W17NBQ20M); m17 &= ~W17NBQ20M; m17 |= w17_q20_nb; //w18[5]: W15[4] uint32_t m18fb = (((m15 >> 4)) & 1) << 5; //w19[13]: W15[15] W15[16] W17[14] W17[16] W17[19] uint32_t m19fb = ((0 ^ (m15 >> 15) ^ (m15 >> 16) ^ (m17 >> 14) ^ (m17 >> 16) ^ (m17 >> 19)) & 1) << 13; //w19[15] : W14[10] W15[12] W15[13] W16[13] W16[14] W16[15] W17[11] W17[13] W17[16] W17[18] W18[12] W19[10] m19fb ^= ((0 ^ (m14 >> 10) ^ (m15 >> 12) ^ (m15 >> 13) ^ (m16 >> 13) ^ (m16 >> 14) ^ (m16 >> 15) ^ (m17 >> 11) ^ (m17 >> 13) ^ (m17 >> 16) ^ (m17 >> 18) ^ (m18 >> 12) ^ (m19 >> 10)) & 1) << 15; //w19[16] : W17[17] W17[19] m19fb ^= ((0 ^ (m17 >> 17) ^ (m17 >> 19)) & 1) << 16; //w19[17] : W16[16] W17[18] W17[19] W18[15] m19fb ^= ((0 ^ (m16 >> 16) ^ (m17 >> 18) ^ (m17 >> 19) ^ (m18 >> 15)) & 1) << 17; //w19[18] : W17[19] m19fb ^= ((0 ^ (m17 >> 19)) & 1) << 18; //w20[0] : W16[16] W17[19] W18[15] uint32_t m20fb = 0; m20fb ^= ((0 ^ (m16 >> 16) ^ (m17 >> 19) ^ (m18 >> 15)) & 1) << 0; //w20[14] : W15[14] W15[16] W17[18] W17[19] m20fb ^= ((0 ^ (m15 >> 14) ^ (m15 >> 16) ^ (m17 >> 18) ^ (m17 >> 19)) & 1) << 14; //w20[16] : W15[16] m20fb ^= ((0 ^ (m15 >> 16)) & 1) << 16; //w20[17] : W15[16] W16[13] W16[15] W17[16] W18[12] m20fb ^= ((0 ^ (m15 >> 16) ^ (m16 >> 13) ^ (m16 >> 15) ^ (m17 >> 16) ^ (m18 >> 12)) & 1) << 17; m18 ^= m18fb; m19 ^= m19fb; m20 ^= m20fb; uint32_t q18 = sha1_round1(q17, q16, q15, q14, q13, m17); uint32_t q19 = sha1_round1(q18, q17, q16, q15, q14, m18); uint32_t q20 = sha1_round1(q19, q18, q17, q16, q15, m19); bool valid_sol = (0 == ((oldq17 ^ q17) & Qcondmask[QOFF + 17])); valid_sol &= 0 == ((oldq18 ^ q18) & Qcondmask[QOFF+18]); valid_sol &= 0 == ((oldq19 ^ q19) & Qcondmask[QOFF+19]); uint32_t q20nessies = Qset1mask[QOFF + 20] ^ (Qprevmask [QOFF + 20] & q19) ^ (Qprevrmask [QOFF + 20] & rotate_left(q19, 30)) ^ (Qprev2rmask[QOFF + 20] & rotate_left(q18, 30)) ; valid_sol &= 0 == ((q20 ^ q20nessies) & Qcondmask[QOFF + 20]); Q20SOLBUF.write(Q20SOLCTL, valid_sol, q15, q16, q17, m14, m15, m16, m17, m18, m19, m20, base_idx); m18 ^= m18fb; m19 ^= m19fb; m20 ^= m20fb; } } q16 -= m15; } PERF_STOP_COUNTER(20); } __device__ void stepQ21(uint32_t thread_rd_idx) { PERF_START_COUNTER(21); using namespace dev; const uint32_t basesolidx = Q20SOLBUF.get<10>(thread_rd_idx); uint32_t q13 = BASESOLBUF.get<1>(basesolidx); uint32_t q14 = BASESOLBUF.get<2>(basesolidx); uint32_t q15 = Q20SOLBUF.get<0>(thread_rd_idx); uint32_t q16 = Q20SOLBUF.get<1>(thread_rd_idx); uint32_t q17 = Q20SOLBUF.get<2>(thread_rd_idx); uint32_t m17 = Q20SOLBUF.get<6>(thread_rd_idx); uint32_t m18 = Q20SOLBUF.get<7>(thread_rd_idx); uint32_t m19 = Q20SOLBUF.get<8>(thread_rd_idx); uint32_t m20 = Q20SOLBUF.get<9>(thread_rd_idx); uint32_t q18 = sha1_round1(q17, q16, q15, q14, q13, m17); uint32_t oldq19 = sha1_round1(q18, q17, q16, q15, q14, m18); uint32_t oldq20 = sha1_round1(oldq19, q18, q17, q16, q15, m19); q18 -= m17; uint32_t w17_q21_nb = 0; for (unsigned k = 0; k < (1<<4); ++k) { NEXT_NB(w17_q21_nb, W17NBQ21M); m17 &= ~W17NBQ21M; m17 |= w17_q21_nb; q18 += m17; uint32_t w18_q21_nb = 0; for (unsigned l = 0; l < (1<<1); ++l) { NEXT_NB(w18_q21_nb, W18NBQ21M); m18 &= ~W18NBQ21M; m18 |= w18_q21_nb; uint32_t m19fb = (((m17<<4)^(m17<<2))&(1<<15)) ^ ((m18<<2)&(1<<17)); uint32_t m20fb = (m18>>15)&(1<<0); m19 ^= m19fb; m20 ^= m20fb; uint32_t q19 = sha1_round1(q18, q17, q16, q15, q14, m18); uint32_t q20 = sha1_round1(q19, q18, q17, q16, q15, m19); uint32_t q21 = sha1_round2(q20, q19, q18, q17, q16, m20); const uint32_t q21nessies = Qset1mask[QOFF+21] // ^ (Qprevmask [QOFF + 21] & q20) ^ (Qprevrmask [QOFF + 21] & rotate_left(q20, 30)) // ^ (Qprev2rmask [QOFF + 21] & rotate_left(q19, 30)) ; bool valid_sol = 0 == ((q21 ^ q21nessies) & Qcondmask[QOFF + 21]); valid_sol &= 0 == ((oldq20 ^ q20) & Qcondmask[QOFF+20]); valid_sol &= 0 == ((oldq19 ^ q19) & Qcondmask[QOFF+19]); uint32_t sol_val_0 = pack_q21q25_sol0(thread_rd_idx, m17, m18, m19, m20); uint32_t sol_val_1 = pack_q21q25_sol1(thread_rd_idx, m17, m18, m19, m20); WARP_TMP_BUF.write2(valid_sol, sol_val_0, sol_val_1, Q21SOLBUF, Q21SOLCTL); m19 ^= m19fb; m20 ^= m20fb; } q18 -= m17; } PERF_STOP_COUNTER(21); } __device__ void stepQ22(uint32_t thread_rd_idx) { PERF_START_COUNTER(22); using namespace dev; uint32_t q21_sol0 = Q21SOLBUF.get<0>(thread_rd_idx); uint32_t q21_sol1 = Q21SOLBUF.get<1>(thread_rd_idx); const uint32_t extsolidx = unpack_idx(q21_sol0,q21_sol1); const uint32_t basesolidx = Q20SOLBUF.get<10>(extsolidx); uint32_t q13 = BASESOLBUF.get<1>(basesolidx); uint32_t q14 = BASESOLBUF.get<2>(basesolidx); uint32_t q15 = Q20SOLBUF.get<0>(extsolidx); uint32_t q16 = Q20SOLBUF.get<1>(extsolidx); uint32_t q17 = Q20SOLBUF.get<2>(extsolidx); uint32_t m13 = BASESOLBUF.get<14>(basesolidx); uint32_t m7 = BASESOLBUF.get<8>(basesolidx); uint32_t m5 = BASESOLBUF.get<6>(basesolidx); uint32_t m17 = Q20SOLBUF.get<6>(extsolidx); uint32_t m18 = Q20SOLBUF.get<7>(extsolidx); uint32_t m19 = Q20SOLBUF.get<8>(extsolidx); uint32_t m20 = Q20SOLBUF.get<9>(extsolidx); m17 ^= unpack_w17ext_nbs(q21_sol0,q21_sol1); m18 ^= unpack_w18_nbs(q21_sol0,q21_sol1); m19 &= ~W19NBPACKM; m19 ^= unpack_w19_nbs_fb(q21_sol0,q21_sol1); m20 &= ~W20NBPACKM; m20 ^= unpack_w20_nbs_fb(q21_sol0,q21_sol1); uint32_t q18 = sha1_round1(q17, q16, q15, q14, q13, m17); uint32_t q19 = sha1_round1(q18, q17, q16, q15, q14, m18); uint32_t oldq20 = sha1_round1(q19, q18, q17, q16, q15, m19); // uint32_t oldq21 = sha1_round2(oldq20, q19, q18, q17, q16, m20); q19 -= m18; uint32_t m21precomp = m13 ^ m7 ^ m5; uint32_t q20precomp = sha1_round1(0, q18, q17, q16, q15, 0); uint32_t w18_q22_nb = 0; for (unsigned k = 0; k < (1<<6); k++) { NEXT_NB(w18_q22_nb, W18NBQ22M); m18 &= ~W18NBQ22M; m18 |= w18_q22_nb; q19 += m18; uint32_t m21 = rotate_left(m18 ^ m21precomp,1); uint32_t m19fb = ((m18<<3) /*^(m19<<5)*/) & (1<<15); uint32_t m20fb = (m18<<5) & (1<<17); m19 ^= m19fb; m20 ^= m20fb; uint32_t w19_q22_nb = 0; for (unsigned l = 0; l < (1<<2); l++) { NEXT_NB(w19_q22_nb, W19NBQ22M); m19 &= ~W19NBQ22M; m19 |= w19_q22_nb; m19 ^= (m19<<5) & (1<<15); uint32_t q20 = q20precomp + rotate_left(q19,5) + m19; //sha1_round1(q19, q18, q17, q16, q15, m19); uint32_t q21 = sha1_round2(q20, q19, q18, q17, q16, m20); uint32_t q22 = sha1_round2(q21, q20, q19, q18, q17, m21); bool valid_sol = 0 == ((oldq20 ^ q20) & Qcondmask[QOFF+20]); const uint32_t q21nessies = Qset1mask[QOFF+21] // ^ (Qprevmask [QOFF + 21] & newq20) ^ (Qprevrmask [QOFF + 21] & rotate_left(q20, 30)) // ^ (Qprev2rmask [QOFF + 21] & rotate_left(q19, 30)) ; valid_sol &= 0 == ((q21 ^ q21nessies) & Qcondmask[QOFF + 21]); const uint32_t q22nessies = Qset1mask[QOFF+22] ^ (Qprevmask [QOFF + 22] & q21) // ^ (Qprevrmask [QOFF + 22] & rotate_left(q21, 30)) ^ (Qprev2rmask [QOFF + 22] & rotate_left(q20, 30)) ; valid_sol &= 0 == ((q22 ^ q22nessies) & Qcondmask[QOFF + 22]); uint32_t sol_val_0 = pack_q21q25_sol0(extsolidx, m17, m18, m19, m20); uint32_t sol_val_1 = pack_q21q25_sol1(extsolidx, m17, m18, m19, m20); WARP_TMP_BUF.write2(valid_sol, sol_val_0, sol_val_1, Q22SOLBUF, Q22SOLCTL); m19 ^= (m19<<5) & (1<<15); } m19 ^= m19fb; m20 ^= m20fb; q19 -= m18; } PERF_STOP_COUNTER(22); } __device__ void stepQ23(uint32_t thread_rd_idx) { PERF_START_COUNTER(23); using namespace dev; uint32_t q22_sol0 = Q22SOLBUF.get<0>(thread_rd_idx); uint32_t q22_sol1 = Q22SOLBUF.get<1>(thread_rd_idx); const uint32_t extsolidx = unpack_idx(q22_sol0,q22_sol1); const uint32_t basesolidx = Q20SOLBUF.get<10>(extsolidx); uint32_t q13 = BASESOLBUF.get<1>(basesolidx); uint32_t q14 = BASESOLBUF.get<2>(basesolidx); uint32_t q15 = Q20SOLBUF.get<0>(extsolidx); uint32_t q16 = Q20SOLBUF.get<1>(extsolidx); uint32_t q17 = Q20SOLBUF.get<2>(extsolidx); uint32_t m5 = BASESOLBUF.get<6>(basesolidx); uint32_t m6 = BASESOLBUF.get<7>(basesolidx); uint32_t m7 = BASESOLBUF.get<8>(basesolidx); uint32_t m8 = BASESOLBUF.get<9>(basesolidx); uint32_t m13 = BASESOLBUF.get<14>(basesolidx); uint32_t m14 = Q20SOLBUF.get<3>(extsolidx); uint32_t m17 = Q20SOLBUF.get<6>(extsolidx); uint32_t m18 = Q20SOLBUF.get<7>(extsolidx); uint32_t m19 = Q20SOLBUF.get<8>(extsolidx); uint32_t m20 = Q20SOLBUF.get<9>(extsolidx); m17 ^= unpack_w17ext_nbs(q22_sol0,q22_sol1); m18 ^= unpack_w18_nbs(q22_sol0,q22_sol1); m19 &= ~W19NBPACKM; m19 ^= unpack_w19_nbs_fb(q22_sol0,q22_sol1); m20 &= ~W20NBPACKM; m20 ^= unpack_w20_nbs_fb(q22_sol0,q22_sol1); uint32_t q18 = sha1_round1(q17, q16, q15, q14, q13, m17); uint32_t q19 = sha1_round1(q18, q17, q16, q15, q14, m18); uint32_t oldq20 = sha1_round1(q19, q18, q17, q16, q15, m19); q19 -= m18; uint32_t m21precomp = m13 ^ m7 ^ m5; uint32_t m22precomp = m14 ^ m8 ^ m6; uint32_t q20precomp = sha1_round1(0, q18, q17, q16, q15, 0); uint32_t w18_q23_nb = 0; for (unsigned k = 0; k < (1<<4); k++) { NEXT_NB(w18_q23_nb, W18NBQ23M); m18 &= ~W18NBQ23M; m18 |= w18_q23_nb; q19 += m18; uint32_t m21 = rotate_left(m18 ^ m21precomp,1); uint32_t w19_q23_nb = 0; for (unsigned l = 0; l < (1<<3); l++) { NEXT_NB(w19_q23_nb, W19NBQ23M); m19 &= ~W19NBQ23M; m19 |= w19_q23_nb; uint32_t m22 = rotate_left(m19 ^ m22precomp,1); uint32_t q20 = q20precomp + rotate_left(q19,5) + m19; //sha1_round1(q19, q18, q17, q16, q15, m19); uint32_t w20_q23_nb = 0; for (unsigned m = 0; m < (1<<1); m++) { NEXT_NB(w20_q23_nb, W20NBQ23M); m20 &= ~W20NBQ23M; m20 |= w20_q23_nb; uint32_t q21 = sha1_round2(q20, q19, q18, q17, q16, m20); uint32_t q22 = sha1_round2(q21, q20, q19, q18, q17, m21); uint32_t q23 = sha1_round2(q22, q21, q20, q19, q18, m22); bool valid_sol = 0 == ((oldq20 ^ q20) & Qcondmask[QOFF+20]); const uint32_t q21nessies = Qset1mask[QOFF+21] // ^ (Qprevmask [QOFF + 21] & newq20) ^ (Qprevrmask [QOFF + 21] & rotate_left(q20, 30)) // ^ (Qprev2rmask [QOFF + 21] & rotate_left(q19, 30)) ; valid_sol &= 0 == ((q21 ^ q21nessies) & Qcondmask[QOFF + 21]); const uint32_t q22nessies = Qset1mask[QOFF+22] ^ (Qprevmask [QOFF + 22] & q21) // ^ (Qprevrmask [QOFF + 22] & rotate_left(q21, 30)) ^ (Qprev2rmask [QOFF + 22] & rotate_left(q20, 30)) ; valid_sol &= 0 == ((q22 ^ q22nessies) & Qcondmask[QOFF + 22]); const uint32_t q23nessies = Qset1mask[QOFF+23] // ^ (Qprevmask [QOFF + 23] & q22) ^ (Qprevrmask [QOFF + 23] & rotate_left(q22, 30)) // ^ (Qprev2rmask [QOFF + 23] & rotate_left(q21, 30)) ; valid_sol &= 0 == ((q23 ^ q23nessies) & Qcondmask[QOFF + 23]); uint32_t sol_val_0 = pack_q21q25_sol0(extsolidx, m17, m18, m19, m20); uint32_t sol_val_1 = pack_q21q25_sol1(extsolidx, m17, m18, m19, m20); WARP_TMP_BUF.write2(valid_sol, sol_val_0, sol_val_1, Q23SOLBUF, Q23SOLCTL); } } q19 -= m18; } PERF_STOP_COUNTER(23); } __device__ void stepQ2456(uint32_t thread_rd_idx) { PERF_START_COUNTER(24); using namespace dev; uint32_t q23_sol0 = Q23SOLBUF.get<0>(thread_rd_idx); uint32_t q23_sol1 = Q23SOLBUF.get<1>(thread_rd_idx); const uint32_t extsolidx = unpack_idx(q23_sol0,q23_sol1); const uint32_t basesolidx = Q20SOLBUF.get<10>(extsolidx); uint32_t q13 = BASESOLBUF.get<1>(basesolidx); uint32_t q14 = BASESOLBUF.get<2>(basesolidx); uint32_t q15 = Q20SOLBUF.get<0>(extsolidx); uint32_t q16 = Q20SOLBUF.get<1>(extsolidx); uint32_t q17 = Q20SOLBUF.get<2>(extsolidx); uint32_t m5 = BASESOLBUF.get<6>(basesolidx); uint32_t m6 = BASESOLBUF.get<7>(basesolidx); uint32_t m7 = BASESOLBUF.get<8>(basesolidx); uint32_t m8 = BASESOLBUF.get<9>(basesolidx); uint32_t m9 = BASESOLBUF.get<10>(basesolidx); uint32_t m10 = BASESOLBUF.get<11>(basesolidx); uint32_t m11 = BASESOLBUF.get<12>(basesolidx); uint32_t m13 = BASESOLBUF.get<14>(basesolidx); uint32_t m14 = Q20SOLBUF.get<3>(extsolidx); uint32_t m15 = Q20SOLBUF.get<4>(extsolidx); uint32_t m16 = Q20SOLBUF.get<5>(extsolidx); uint32_t m17 = Q20SOLBUF.get<6>(extsolidx); uint32_t m18 = Q20SOLBUF.get<7>(extsolidx); uint32_t m19 = Q20SOLBUF.get<8>(extsolidx); uint32_t m20 = Q20SOLBUF.get<9>(extsolidx); m17 ^= unpack_w17ext_nbs(q23_sol0,q23_sol1); m18 ^= unpack_w18_nbs(q23_sol0,q23_sol1); m19 &= ~W19NBPACKM; m19 ^= unpack_w19_nbs_fb(q23_sol0,q23_sol1); m20 &= ~W20NBPACKM; m20 ^= unpack_w20_nbs_fb(q23_sol0,q23_sol1); uint32_t m21 = rotate_left(m18 ^ m13 ^ m7 ^ m5,1); uint32_t m24 = rotate_left(m21 ^ m16 ^ m10 ^ m8,1); uint32_t q18 = sha1_round1(q17, q16, q15, q14, q13, m17); uint32_t q19 = sha1_round1(q18, q17, q16, q15, q14, m18); uint32_t q20 = sha1_round1(q19, q18, q17, q16, q15, 0); uint32_t q21precomp = sha1_round2(0, q19, q18, q17, q16, 0); uint32_t m22precomp = m14 ^ m8 ^ m6; uint32_t m23precomp = m15 ^ m9 ^ m7; uint32_t m25precomp = m17 ^ m11 ^ m9; uint32_t w19_q24_nb = 0; for (unsigned l = 0; l < (1<<3); l++) { NEXT_NB(w19_q24_nb, W19NBQ24M); m19 &= ~W19NBQ24M; m19 |= w19_q24_nb; q20 += m19; uint32_t m22 = rotate_left(m19 ^ m22precomp,1); uint32_t m25 = rotate_left(m22 ^ m25precomp,1); uint32_t w20_q24_nb = 0; #define W20NBQ2425M (W20NBQ24M|W20NBQ25M) for (unsigned m = 0; m < (1<<4); m++) { NEXT_NB(w20_q24_nb, W20NBQ2425M); m20 &= ~W20NBQ2425M; m20 |= w20_q24_nb; uint32_t m23 = rotate_left(m20 ^ m23precomp,1); uint32_t q21 = q21precomp + rotate_left(q20,5) + m20; uint32_t q22 = sha1_round2(q21, q20, q19, q18, q17, m21); uint32_t q23 = sha1_round2(q22, q21, q20, q19, q18, m22); uint32_t q24 = sha1_round2(q23, q22, q21, q20, q19, m23); const uint32_t q22nessies = Qset1mask[QOFF+22] ^ (Qprevmask [QOFF + 22] & q21) // ^ (Qprevrmask [QOFF + 22] & rotate_left(q21, 30)) ^ (Qprev2rmask [QOFF + 22] & rotate_left(q20, 30)) ; bool valid_sol = 0 == ((q22 ^ q22nessies) & Qcondmask[QOFF + 22]); const uint32_t q23nessies = Qset1mask[QOFF+23] // ^ (Qprevmask [QOFF + 23] & q22) ^ (Qprevrmask [QOFF + 23] & rotate_left(q22, 30)) // ^ (Qprev2rmask [QOFF + 23] & rotate_left(q21, 30)) ; valid_sol &= 0 == ((q23 ^ q23nessies) & Qcondmask[QOFF + 23]); const uint32_t q24nessies = Qset1mask[QOFF+24] // ^ (Qprevmask [QOFF + 24] & q23) ^ (Qprevrmask [QOFF + 24] & rotate_left(q23, 30)) ^ (Qprev2rmask [QOFF + 24] & rotate_left(q22, 30)) ; valid_sol &= 0 == ((q24 ^ q24nessies) & Qcondmask[QOFF + 24]); uint32_t q25 = sha1_round2(q24, q23, q22, q21, q20, m24); const uint32_t q25nessies = Qset1mask[QOFF+25] // ^ (Qprevmask [QOFF + 25] & q24) ^ (Qprevrmask [QOFF + 25] & rotate_left(q24, 30)) // ^ (Qprev2rmask [QOFF + 25] & rotate_left(q23, 30)) ; valid_sol &= 0 == ((q25 ^ q25nessies) & Qcondmask[QOFF + 25]); // if (valid_sol) // { uint32_t q26 = sha1_round2(q25, q24, q23, q22, q21, m25); const uint32_t q26nessies = Qset1mask[QOFF+26] // ^ (Qprevmask [QOFF + 26] & q25) // ^ (Qprevrmask [QOFF + 26] & rotate_left(q25, 30)) ^ (Qprev2rmask [QOFF + 26] & rotate_left(q24, 30)) ; valid_sol &= 0 == ((q26 ^ q26nessies) & Qcondmask[QOFF + 26]); // } uint32_t sol_val_0 = pack_q21q25_sol0(extsolidx, m17, m18, m19, m20); uint32_t sol_val_1 = pack_q21q25_sol1(extsolidx, m17, m18, m19, m20); WARP_TMP_BUF.write2(valid_sol, sol_val_0, sol_val_1, Q26SOLBUF, Q26SOLCTL); } q20 -= m19; } PERF_STOP_COUNTER(24); } __device__ void stepQ2728(uint32_t thread_rd_idx) { PERF_START_COUNTER(27); using namespace dev; const uint32_t q26_sol0 = Q26SOLBUF.get<0>(thread_rd_idx); const uint32_t q26_sol1 = Q26SOLBUF.get<1>(thread_rd_idx); const uint32_t extsolidx = unpack_idx(q26_sol0,q26_sol1); const uint32_t basesolidx = Q20SOLBUF.get<10>(extsolidx); uint32_t m17 = Q20SOLBUF.get<6>(extsolidx); uint32_t m18 = Q20SOLBUF.get<7>(extsolidx); uint32_t m19 = Q20SOLBUF.get<8>(extsolidx); uint32_t m20 = Q20SOLBUF.get<9>(extsolidx); m17 ^= unpack_w17ext_nbs(q26_sol0,q26_sol1); m18 ^= unpack_w18_nbs(q26_sol0,q26_sol1); m19 &= ~W19NBPACKM; m19 ^= unpack_w19_nbs_fb(q26_sol0,q26_sol1); m20 &= ~W20NBPACKM; m20 ^= unpack_w20_nbs_fb(q26_sol0,q26_sol1); const uint32_t m5 = BASESOLBUF.get<6>(basesolidx); const uint32_t m7 = BASESOLBUF.get<8>(basesolidx); const uint32_t m13 = BASESOLBUF.get<14>(basesolidx); const uint32_t m21 = rotate_left(m18 ^ m13 ^ m7 ^ m5,1); uint32_t q19, q20, q21, q22, q23; { uint32_t q13 = BASESOLBUF.get<1>(basesolidx); uint32_t q14 = BASESOLBUF.get<2>(basesolidx); uint32_t q15 = Q20SOLBUF.get<0>(extsolidx); uint32_t q16 = Q20SOLBUF.get<1>(extsolidx); uint32_t q17 = Q20SOLBUF.get<2>(extsolidx); uint32_t q18 = sha1_round1(q17, q16, q15, q14, q13, m17); q19 = sha1_round1(q18, q17, q16, q15, q14, m18); q20 = sha1_round1(q19, q18, q17, q16, q15, m19); q21 = sha1_round2(q20, q19, q18, q17, q16, m20); q22 = sha1_round2(q21, q20, q19, q18, q17, m21); q23 = sha1_round2(q22, q21, q20, q19, q18, 0); } // booms change: m10, m11, m12, m14, m15, m16 => m22 (m14), m23 (m15), m24 (m10,m16), m25(m11), m26(m10,m12),m27(m11),m28(m12,m14),m29(m15) // m5 const uint32_t m6 = BASESOLBUF.get<7>(basesolidx); // m7 const uint32_t m8 = BASESOLBUF.get<9>(basesolidx); const uint32_t m9 = BASESOLBUF.get<10>(basesolidx); uint32_t m10 = BASESOLBUF.get<11>(basesolidx); uint32_t m11 = BASESOLBUF.get<12>(basesolidx); uint32_t m12 = BASESOLBUF.get<13>(basesolidx); // m13 uint32_t m14 = Q20SOLBUF.get<3>(extsolidx); uint32_t m15 = Q20SOLBUF.get<4>(extsolidx); uint32_t m16 = Q20SOLBUF.get<5>(extsolidx); uint32_t m22precomp = m19 ^ 0 ^ m8 ^ m6; uint32_t m23precomp = m20 ^ 0 ^ m9 ^ m7; uint32_t m24precomp = m21 ^ m16 ^ 0 ^ m8; uint32_t m25precomp = m17 ^ m9; uint32_t m26precomp = m18 ^ m12; uint32_t m27precomp = m19 ^ m13; uint32_t q24precomp = sha1_round2(0, q22, q21, q20, q19, 0); uint32_t q11_bo = 0; for (unsigned m = 0; m < (1<<2); ++m) { NEXT_NB(q11_bo, Q11BOOMS); m10 ^= q11_bo; m11 ^= q11_bo<<5; m14 ^= (q11_bo>>2)&(1<<6); m15 ^= q11_bo>>2; uint32_t m22 = rotate_left(m14 ^ m22precomp,1); q23 += m22; uint32_t m23 = rotate_left(m15 ^ m23precomp,1); uint32_t q24 = q24precomp + rotate_left(q23,5) + m23; //sha1_round2(q23, q22, q21, q20, q19, m23); uint32_t m24 = rotate_left(m10 ^ m24precomp,1); uint32_t q25 = sha1_round2(q24, q23, q22, q21, q20, m24); uint32_t m25 = rotate_left(m22 ^ m11 ^ m25precomp,1); uint32_t q26 = sha1_round2(q25, q24, q23, q22, q21, m25); uint32_t m26 = rotate_left(m23 ^ m26precomp ^ m10,1); uint32_t q27 = sha1_round2(q26, q25, q24, q23, q22, m26); uint32_t m27 = rotate_left(m24 ^ m27precomp ^ m11,1); uint32_t q28 = sha1_round2(q27, q26, q25, q24, q23, m27); // const uint32_t q25nessies = Qset1mask[QOFF+25] // ^ (Qprevmask [QOFF + 25] & q24) // ^ (Qprevrmask [QOFF + 25] & rotate_left(q24,30)) // ^ (Qprev2rmask [QOFF + 25] & rotate_left(q23, 30)) ; // bool valid_sol = 0 == ((q25 ^ q25nessies) & Qcondmask[QOFF + 25]); const uint32_t q26nessies = Qset1mask[QOFF+26] // ^ (Qprevmask [QOFF + 26] & q25) // ^ (Qprevrmask [QOFF + 26] & rotate_left(q25, 30)) ^ (Qprev2rmask [QOFF + 26] & rotate_left(q24,30)) ; bool valid_sol = 0 == ((q26 ^ q26nessies) & Qcondmask[QOFF + 26]); const uint32_t q27nessies = Qset1mask[QOFF+27] // ^ (Qprevmask [QOFF + 27] & q26) ^ (Qprevrmask [QOFF + 27] & rotate_left(q26,30)) // ^ (Qprev2rmask [QOFF + 27] & rotate_left(q25, 30)) ; valid_sol &= 0 == ((q27 ^ q27nessies) & Qcondmask[QOFF + 27]); const uint32_t q28nessies = // Qset1mask[QOFF+28] // ^ (Qprevmask [QOFF + 28] & q27) // ^ (Qprevrmask [QOFF + 28] & rotate_left(q27, 30)) /*^*/ (Qprev2rmask [QOFF + 28] & rotate_left(q26,30)) ; valid_sol &= 0 == ((q28 ^ q28nessies) & Qcondmask[QOFF + 28]); Q28SOLBUF.write(Q28SOLCTL, valid_sol, q26_sol0, q26_sol1, q11_bo); q23 -= m22; m10 ^= q11_bo; m11 ^= q11_bo<<5; m14 ^= (q11_bo>>2)&(1<<6); m15 ^= q11_bo>>2; } PERF_STOP_COUNTER(27); } __device__ void stepQ2930(uint32_t thread_rd_idx) { PERF_START_COUNTER(29); using namespace dev; const uint32_t q28_sol0 = Q28SOLBUF.get<0>(thread_rd_idx); const uint32_t q28_sol1 = Q28SOLBUF.get<1>(thread_rd_idx); const uint32_t q28_sol2 = Q28SOLBUF.get<2>(thread_rd_idx); const uint32_t extsolidx = unpack_idx(q28_sol0,q28_sol1); const uint32_t basesolidx = Q20SOLBUF.get<10>(extsolidx); uint32_t m17 = Q20SOLBUF.get<6>(extsolidx); uint32_t m18 = Q20SOLBUF.get<7>(extsolidx); uint32_t m19 = Q20SOLBUF.get<8>(extsolidx); uint32_t m20 = Q20SOLBUF.get<9>(extsolidx); m17 ^= unpack_w17ext_nbs(q28_sol0,q28_sol1); m18 ^= unpack_w18_nbs(q28_sol0,q28_sol1); m19 &= ~W19NBPACKM; m19 ^= unpack_w19_nbs_fb(q28_sol0,q28_sol1); m20 &= ~W20NBPACKM; m20 ^= unpack_w20_nbs_fb(q28_sol0,q28_sol1); const uint32_t m5 = BASESOLBUF.get<6>(basesolidx); const uint32_t m7 = BASESOLBUF.get<8>(basesolidx); const uint32_t m13 = BASESOLBUF.get<14>(basesolidx); const uint32_t m21 = rotate_left(m18 ^ m13 ^ m7 ^ m5,1); uint32_t q19, q20, q21, q22, q23; { uint32_t q13 = BASESOLBUF.get<1>(basesolidx); uint32_t q14 = BASESOLBUF.get<2>(basesolidx); uint32_t q15 = Q20SOLBUF.get<0>(extsolidx); uint32_t q16 = Q20SOLBUF.get<1>(extsolidx); uint32_t q17 = Q20SOLBUF.get<2>(extsolidx); uint32_t q18 = sha1_round1(q17, q16, q15, q14, q13, m17); q19 = sha1_round1(q18, q17, q16, q15, q14, m18); q20 = sha1_round1(q19, q18, q17, q16, q15, m19); q21 = sha1_round2(q20, q19, q18, q17, q16, m20); q22 = sha1_round2(q21, q20, q19, q18, q17, m21); q23 = sha1_round2(q22, q21, q20, q19, q18, 0); } // booms change: m10, m11, m12, m14, m15, m16 => m22 (m14), m23 (m15), m24 (m10,m16), m25(m11), m26(m10,m12),m27(m11),m28(m12,m14),m29(m15) // m5 const uint32_t m6 = BASESOLBUF.get<7>(basesolidx); // m7 const uint32_t m8 = BASESOLBUF.get<9>(basesolidx); const uint32_t m9 = BASESOLBUF.get<10>(basesolidx); uint32_t m10 = BASESOLBUF.get<11>(basesolidx); uint32_t m11 = BASESOLBUF.get<12>(basesolidx); uint32_t m12 = BASESOLBUF.get<13>(basesolidx); // m13 uint32_t m14 = Q20SOLBUF.get<3>(extsolidx); uint32_t m15 = Q20SOLBUF.get<4>(extsolidx); uint32_t m16 = Q20SOLBUF.get<5>(extsolidx); m10 ^= q28_sol2; m11 ^= q28_sol2<<5; m14 ^= (q28_sol2>>2)&(1<<6); m15 ^= q28_sol2>>2; uint32_t m22 = rotate_left(m19 ^ m14 ^ m8 ^ m6,1); q23 += m22; uint32_t m23 = rotate_left(m20 ^ m15 ^ m9 ^ m7,1); uint32_t q24 = sha1_round2(q23, q22, q21, q20, q19, m23); uint32_t q25 = sha1_round2(q24, q23, q22, q21, q20, 0); uint32_t q26precomp = sha1_round2(0, q24, q23, q22, q21, 0); uint32_t m24precomp = m21 ^ m10 ^ m8; uint32_t m25precomp = m22 ^ m17 ^ m9; uint32_t m26precomp = m23 ^ m18 ^ m10; uint32_t m27precomp = m19 ^ m13; uint32_t m29precomp = m21 ^ m15 ^ m13; uint32_t q12_bo = 0; for (unsigned m = 0; m < (1<<2); ++m) { NEXT_NB(q12_bo, Q12BOOMS); m11 ^= q12_bo; m12 ^= q12_bo<<5; m16 ^= q12_bo>>2; uint32_t m24 = rotate_left(m16 ^ m24precomp,1); q25 += m24; uint32_t m25 = rotate_left(m11 ^ m25precomp,1); uint32_t q26 = q26precomp + rotate_left(q25,5) + m25; // uint32_t q26 = sha1_round2(q25, q24, q23, q22, q21, m25); uint32_t m26 = rotate_left(m12 ^ m26precomp,1); uint32_t q27 = sha1_round2(q26, q25, q24, q23, q22, m26); uint32_t m27 = rotate_left(m24 ^ m11 ^ m27precomp,1); uint32_t q28 = sha1_round2(q27, q26, q25, q24, q23, m27); uint32_t m28 = rotate_left(m25 ^ m20 ^ m14 ^ m12,1); uint32_t q29 = sha1_round2(q28, q27, q26, q25, q24, m28); uint32_t m29 = rotate_left(m26 ^ m29precomp,1); uint32_t q30 = sha1_round2(q29, q28, q27, q26, q25, m29); // const uint32_t q25nessies = Qset1mask[QOFF+25] // ^ (Qprevmask [QOFF + 25] & q24) // ^ (Qprevrmask [QOFF + 25] & rotate_left(q24,30)) // ^ (Qprev2rmask [QOFF + 25] & rotate_left(q23, 30)) // ; // bool valid_sol = 0 == ((q25 ^ q25nessies) & Qcondmask[QOFF + 25]); // const uint32_t q26nessies = Qset1mask[QOFF+26] // ^ (Qprevmask [QOFF + 26] & q25) // ^ (Qprevrmask [QOFF + 26] & rotate_left(q25, 30)) // ^ (Qprev2rmask [QOFF + 26] & rotate_left(q24,30)) // ; // valid_sol &= 0 == ((q26 ^ q26nessies) & Qcondmask[QOFF + 26]); const uint32_t q27nessies = Qset1mask[QOFF+27] // ^ (Qprevmask [QOFF + 27] & q26) ^ (Qprevrmask [QOFF + 27] & rotate_left(q26,30)) // ^ (Qprev2rmask [QOFF + 27] & rotate_left(q25, 30)) ; bool valid_sol = 0 == ((q27 ^ q27nessies) & Qcondmask[QOFF + 27]); const uint32_t q28nessies = // Qset1mask[QOFF+28] // ^ (Qprevmask [QOFF + 28] & q27) // ^ (Qprevrmask [QOFF + 28] & rotate_left(q27, 30)) /*^*/ (Qprev2rmask [QOFF + 28] & rotate_left(q26,30)) ; valid_sol &= 0 == ((q28 ^ q28nessies) & Qcondmask[QOFF + 28]); valid_sol &= 0 == ((q29 ^ Qset1mask[QOFF+29]) & Qcondmask[QOFF + 29]); valid_sol &= 0 == ((q30 ^ Qset1mask[QOFF+30]) & Qcondmask[QOFF + 30]); uint32_t sol2 = (q28_sol2 ^ (q12_bo<<16)); Q30SOLBUF.write(Q30SOLCTL, valid_sol, q28_sol0, q28_sol1, sol2); q25 -= m24; m11 ^= q12_bo; m12 ^= q12_bo<<5; m16 ^= q12_bo>>2; } PERF_STOP_COUNTER(29); } __device__ void stepQ3140(uint32_t thread_rd_idx) { PERF_START_COUNTER(31); using namespace dev; const uint32_t q30_sol0 = Q30SOLBUF.get<0>(thread_rd_idx); const uint32_t q30_sol1 = Q30SOLBUF.get<1>(thread_rd_idx); const uint32_t q30_sol2 = Q30SOLBUF.get<2>(thread_rd_idx); const uint32_t extsolidx = unpack_idx(q30_sol0,q30_sol1); const uint32_t basesolidx = Q20SOLBUF.get<10>(extsolidx); uint32_t m17 = Q20SOLBUF.get<6>(extsolidx); uint32_t m18 = Q20SOLBUF.get<7>(extsolidx); uint32_t m19 = Q20SOLBUF.get<8>(extsolidx); uint32_t m20 = Q20SOLBUF.get<9>(extsolidx); m17 ^= unpack_w17ext_nbs(q30_sol0,q30_sol1); m18 ^= unpack_w18_nbs(q30_sol0,q30_sol1); m19 &= ~W19NBPACKM; m19 ^= unpack_w19_nbs_fb(q30_sol0,q30_sol1); m20 &= ~W20NBPACKM; m20 ^= unpack_w20_nbs_fb(q30_sol0,q30_sol1); const uint32_t m5 = BASESOLBUF.get<6>(basesolidx); const uint32_t m7 = BASESOLBUF.get<8>(basesolidx); const uint32_t m13 = BASESOLBUF.get<14>(basesolidx); const uint32_t m21 = rotate_left(m18 ^ m13 ^ m7 ^ m5,1); uint32_t q19, q20, q21, q22, q23; { uint32_t q13 = BASESOLBUF.get<1>(basesolidx); uint32_t q14 = BASESOLBUF.get<2>(basesolidx); uint32_t q15 = Q20SOLBUF.get<0>(extsolidx); uint32_t q16 = Q20SOLBUF.get<1>(extsolidx); uint32_t q17 = Q20SOLBUF.get<2>(extsolidx); uint32_t q18 = sha1_round1(q17, q16, q15, q14, q13, m17); q19 = sha1_round1(q18, q17, q16, q15, q14, m18); q20 = sha1_round1(q19, q18, q17, q16, q15, m19); q21 = sha1_round2(q20, q19, q18, q17, q16, m20); q22 = sha1_round2(q21, q20, q19, q18, q17, m21); q23 = sha1_round2(q22, q21, q20, q19, q18, 0); } // booms change: m10, m11, m12, m14, m15, m16 => m22 (m14), m23 (m15), m24 (m10,m16), m25(m11), m26(m10,m12),m27(m11),m28(m12,m14),m29(m15) // m5 const uint32_t m6 = BASESOLBUF.get<7>(basesolidx); // m7 const uint32_t m8 = BASESOLBUF.get<9>(basesolidx); const uint32_t m9 = BASESOLBUF.get<10>(basesolidx); uint32_t m10 = BASESOLBUF.get<11>(basesolidx); uint32_t m11 = BASESOLBUF.get<12>(basesolidx); uint32_t m12 = BASESOLBUF.get<13>(basesolidx); // m13 uint32_t m14 = Q20SOLBUF.get<3>(extsolidx); uint32_t m15 = Q20SOLBUF.get<4>(extsolidx); uint32_t m16 = Q20SOLBUF.get<5>(extsolidx); { const uint32_t q11boom = q30_sol2 & Q11BOOMS; const uint32_t q12boom = (q30_sol2>>16) & Q12BOOMS; m10 ^= q11boom; m11 ^= q11boom<<5; m14 ^= (q11boom>>2)&(1<<6); m15 ^= q11boom>>2; m11 ^= q12boom; m12 ^= q12boom<<5; m16 ^= q12boom>>2; } uint32_t m22 = rotate_left(m19 ^ m14 ^ m8 ^ m6,1); q23 += m22; const uint32_t m23 = rotate_left(m20 ^ m15 ^ m9 ^ m7, 1); const uint32_t m24 = rotate_left(m21 ^ m16 ^ m10 ^ m8, 1); const uint32_t m25 = rotate_left(m22 ^ m17 ^ m11 ^ m9, 1); const uint32_t m26 = rotate_left(m23 ^ m18 ^ m12 ^ m10, 1); const uint32_t m27 = rotate_left(m24 ^ m19 ^ m13 ^ m11, 1); const uint32_t m28 = rotate_left(m25 ^ m20 ^ m14 ^ m12, 1); const uint32_t m29 = rotate_left(m26 ^ m21 ^ m15 ^ m13, 1); const uint32_t q24 = rotate_left(q23,5) + sha1_f2(q22,rotate_left(q21,30),rotate_left(q20,30)) + rotate_left(q19,30) + 0x6ED9EBA1 + m23; const uint32_t q25 = rotate_left(q24,5) + sha1_f2(q23,rotate_left(q22,30),rotate_left(q21,30)) + rotate_left(q20,30) + 0x6ED9EBA1 + m24; uint32_t q26 = rotate_left(q25,5) + sha1_f2(q24,rotate_left(q23,30),rotate_left(q22,30)) + rotate_left(q21,30) + 0x6ED9EBA1 + m25; uint32_t q27 = rotate_left(q26,5) + sha1_f2(q25,rotate_left(q24,30),rotate_left(q23,30)) + rotate_left(q22,30) + 0x6ED9EBA1 + m26; uint32_t q28 = rotate_left(q27,5) + sha1_f2(q26,rotate_left(q25,30),rotate_left(q24,30)) + rotate_left(q23,30) + 0x6ED9EBA1 + m27; uint32_t q29 = rotate_left(q28,5) + sha1_f2(q27,rotate_left(q26,30),rotate_left(q25,30)) + rotate_left(q24,30) + 0x6ED9EBA1 + m28; uint32_t q30 = rotate_left(q29,5) + sha1_f2(q28,rotate_left(q27,30),rotate_left(q26,30)) + rotate_left(q25,30) + 0x6ED9EBA1 + m29; const uint32_t m30 = rotate_left(m27 ^ m22 ^ m16 ^ m14, 1); const uint32_t m31 = rotate_left(m28 ^ m23 ^ m17 ^ m15, 1); const uint32_t m32 = rotate_left(m29 ^ m24 ^ m18 ^ m16, 1); const uint32_t m33 = rotate_left(m30 ^ m25 ^ m19 ^ m17, 1); const uint32_t m34 = rotate_left(m31 ^ m26 ^ m20 ^ m18, 1); const uint32_t m35 = rotate_left(m32 ^ m27 ^ m21 ^ m19, 1); const uint32_t m36 = rotate_left(m33 ^ m28 ^ m22 ^ m20, 1); const uint32_t m37 = rotate_left(m34 ^ m29 ^ m23 ^ m21, 1); const uint32_t m38 = rotate_left(m35 ^ m30 ^ m24 ^ m22, 1); const uint32_t m39 = rotate_left(m36 ^ m31 ^ m25 ^ m23, 1); uint32_t q36,q37,q38,q39,q40; { const uint32_t q31 = rotate_left(q30,5) + sha1_f2(q29,rotate_left(q28,30),rotate_left(q27,30)) + rotate_left(q26,30) + 0x6ED9EBA1 + m30; const uint32_t q32 = rotate_left(q31,5) + sha1_f2(q30,rotate_left(q29,30),rotate_left(q28,30)) + rotate_left(q27,30) + 0x6ED9EBA1 + m31; const uint32_t q33 = rotate_left(q32,5) + sha1_f2(q31,rotate_left(q30,30),rotate_left(q29,30)) + rotate_left(q28,30) + 0x6ED9EBA1 + m32; const uint32_t q34 = rotate_left(q33,5) + sha1_f2(q32,rotate_left(q31,30),rotate_left(q30,30)) + rotate_left(q29,30) + 0x6ED9EBA1 + m33; const uint32_t q35 = rotate_left(q34,5) + sha1_f2(q33,rotate_left(q32,30),rotate_left(q31,30)) + rotate_left(q30,30) + 0x6ED9EBA1 + m34; q36 = rotate_left(q35,5) + sha1_f2(q34,rotate_left(q33,30),rotate_left(q32,30)) + rotate_left(q31,30) + 0x6ED9EBA1 + m35; q37 = rotate_left(q36,5) + sha1_f2(q35,rotate_left(q34,30),rotate_left(q33,30)) + rotate_left(q32,30) + 0x6ED9EBA1 + m36; q38 = rotate_left(q37,5) + sha1_f2(q36,rotate_left(q35,30),rotate_left(q34,30)) + rotate_left(q33,30) + 0x6ED9EBA1 + m37; q39 = rotate_left(q38,5) + sha1_f2(q37,rotate_left(q36,30),rotate_left(q35,30)) + rotate_left(q34,30) + 0x6ED9EBA1 + m38; q40 = rotate_left(q39,5) + sha1_f2(q38,rotate_left(q37,30),rotate_left(q36,30)) + rotate_left(q35,30) + 0x6ED9EBA1 + m39; } q26 += dQ[QOFF+26]; q27 += dQ[QOFF+27]; q28 += dQ[QOFF+28]; q29 += dQ[QOFF+29]; q30 += dQ[QOFF+30]; uint32_t q36b,q37b,q38b,q39b,q40b; { const uint32_t q31 = rotate_left(q30,5) + sha1_f2(q29,rotate_left(q28,30),rotate_left(q27,30)) + rotate_left(q26,30) + 0x6ED9EBA1 + (m30^DV_DW[30]); const uint32_t q32 = rotate_left(q31,5) + sha1_f2(q30,rotate_left(q29,30),rotate_left(q28,30)) + rotate_left(q27,30) + 0x6ED9EBA1 + (m31^DV_DW[31]); const uint32_t q33 = rotate_left(q32,5) + sha1_f2(q31,rotate_left(q30,30),rotate_left(q29,30)) + rotate_left(q28,30) + 0x6ED9EBA1 + (m32^DV_DW[32]); const uint32_t q34 = rotate_left(q33,5) + sha1_f2(q32,rotate_left(q31,30),rotate_left(q30,30)) + rotate_left(q29,30) + 0x6ED9EBA1 + (m33^DV_DW[33]); const uint32_t q35 = rotate_left(q34,5) + sha1_f2(q33,rotate_left(q32,30),rotate_left(q31,30)) + rotate_left(q30,30) + 0x6ED9EBA1 + (m34^DV_DW[34]); q36b = rotate_left(q35,5) + sha1_f2(q34,rotate_left(q33,30),rotate_left(q32,30)) + rotate_left(q31,30) + 0x6ED9EBA1 + (m35^DV_DW[35]); q37b = rotate_left(q36b,5) + sha1_f2(q35,rotate_left(q34,30),rotate_left(q33,30)) + rotate_left(q32,30) + 0x6ED9EBA1 + (m36^DV_DW[36]); q38b = rotate_left(q37b,5) + sha1_f2(q36b,rotate_left(q35,30),rotate_left(q34,30)) + rotate_left(q33,30) + 0x6ED9EBA1 + (m37^DV_DW[37]); q39b = rotate_left(q38b,5) + sha1_f2(q37b,rotate_left(q36b,30),rotate_left(q35,30)) + rotate_left(q34,30) + 0x6ED9EBA1 + (m38^DV_DW[38]); q40b = rotate_left(q39b,5) + sha1_f2(q38b,rotate_left(q37b,30),rotate_left(q36b,30)) + rotate_left(q35,30) + 0x6ED9EBA1 + (m39^DV_DW[39]); } bool valid_sol = 0 == ( (q36^q36b) | (q37^q37b) | (q38^q38b) | (q39^q39b) | (q40^q40b) ); Q40SOLBUF.write(Q40SOLCTL, valid_sol, q36, q37, q38, q39, q40, m24,m25,m26,m27,m28,m29,m30,m31,m32,m33,m34,m35,m36,m37,m38,m39); PERF_STOP_COUNTER(31); } __device__ void step_extend_Q60(uint32_t thread_rd_idx) { PERF_START_COUNTER(60); using namespace dev; uint32_t e = Q40SOLBUF.get<0>(thread_rd_idx); // q36 uint32_t d = Q40SOLBUF.get<1>(thread_rd_idx); // q37 uint32_t c = Q40SOLBUF.get<2>(thread_rd_idx); // q38 uint32_t b = Q40SOLBUF.get<3>(thread_rd_idx); // q39 uint32_t a = Q40SOLBUF.get<4>(thread_rd_idx); // q40 uint32_t E = e; uint32_t D = d; uint32_t C = c; uint32_t B = b; uint32_t A = a; uint32_t m40, m41, m42, m43, m44, m45, m46, m47; uint32_t m48, m49, m50, m51, m52, m53, m54, m55; uint32_t m56, m57, m58, m59; { uint32_t m24 = Q40SOLBUF.get<5>(thread_rd_idx); uint32_t m25 = Q40SOLBUF.get<6>(thread_rd_idx); uint32_t m26 = Q40SOLBUF.get<7>(thread_rd_idx); uint32_t m27 = Q40SOLBUF.get<8>(thread_rd_idx); uint32_t m28 = Q40SOLBUF.get<9>(thread_rd_idx); uint32_t m29 = Q40SOLBUF.get<10>(thread_rd_idx); uint32_t m30 = Q40SOLBUF.get<11>(thread_rd_idx); uint32_t m31 = Q40SOLBUF.get<12>(thread_rd_idx); uint32_t m32 = Q40SOLBUF.get<13>(thread_rd_idx); uint32_t m33 = Q40SOLBUF.get<14>(thread_rd_idx); uint32_t m34 = Q40SOLBUF.get<15>(thread_rd_idx); uint32_t m35 = Q40SOLBUF.get<16>(thread_rd_idx); uint32_t m36 = Q40SOLBUF.get<17>(thread_rd_idx); uint32_t m37 = Q40SOLBUF.get<18>(thread_rd_idx); uint32_t m38 = Q40SOLBUF.get<19>(thread_rd_idx); uint32_t m39 = Q40SOLBUF.get<20>(thread_rd_idx); m40 = sha1_mess(m37, m32, m26, m24); m41 = sha1_mess(m38, m33, m27, m25); m42 = sha1_mess(m39, m34, m28, m26); m43 = sha1_mess(m40, m35, m29, m27); m44 = sha1_mess(m41, m36, m30, m28); m45 = sha1_mess(m42, m37, m31, m29); m46 = sha1_mess(m43, m38, m32, m30); m47 = sha1_mess(m44, m39, m33, m31); m48 = sha1_mess(m45, m40, m34, m32); m49 = sha1_mess(m46, m41, m35, m33); m50 = sha1_mess(m47, m42, m36, m34); m51 = sha1_mess(m48, m43, m37, m35); m52 = sha1_mess(m49, m44, m38, m36); m53 = sha1_mess(m50, m45, m39, m37); m54 = sha1_mess(m51, m46, m40, m38); m55 = sha1_mess(m52, m47, m41, m39); m56 = sha1_mess(m53, m48, m42, m40); m57 = sha1_mess(m54, m49, m43, m41); m58 = sha1_mess(m55, m50, m44, m42); m59 = sha1_mess(m56, m51, m45, m43); } e = sha1_round3(a, b, c, d, e, m40); d = sha1_round3(e, a, b, c, d, m41); c = sha1_round3(d, e, a, b, c, m42); b = sha1_round3(c, d, e, a, b, m43); a = sha1_round3(b, c, d, e, a, m44); e = sha1_round3(a, b, c, d, e, m45); d = sha1_round3(e, a, b, c, d, m46); c = sha1_round3(d, e, a, b, c, m47); b = sha1_round3(c, d, e, a, b, m48); a = sha1_round3(b, c, d, e, a, m49); e = sha1_round3(a, b, c, d, e, m50); d = sha1_round3(e, a, b, c, d, m51); c = sha1_round3(d, e, a, b, c, m52); b = sha1_round3(c, d, e, a, b, m53); a = sha1_round3(b, c, d, e, a, m54); e = sha1_round3(a, b, c, d, e, m55); d = sha1_round3(e, a, b, c, d, m56); c = sha1_round3(d, e, a, b, c, m57); b = sha1_round3(c, d, e, a, b, m58); a = sha1_round3(b, c, d, e, a, m59); m40 ^= DV_DW[40]; m41 ^= DV_DW[41]; m42 ^= DV_DW[42]; m43 ^= DV_DW[43]; m44 ^= DV_DW[44]; m45 ^= DV_DW[45]; m46 ^= DV_DW[46]; m47 ^= DV_DW[47]; m48 ^= DV_DW[48]; m49 ^= DV_DW[49]; m50 ^= DV_DW[50]; m51 ^= DV_DW[51]; m52 ^= DV_DW[52]; m53 ^= DV_DW[53]; m54 ^= DV_DW[54]; m55 ^= DV_DW[55]; m56 ^= DV_DW[56]; m57 ^= DV_DW[57]; m58 ^= DV_DW[58]; m59 ^= DV_DW[59]; E = sha1_round3(A, B, C, D, E, m40); D = sha1_round3(E, A, B, C, D, m41); C = sha1_round3(D, E, A, B, C, m42); B = sha1_round3(C, D, E, A, B, m43); A = sha1_round3(B, C, D, E, A, m44); E = sha1_round3(A, B, C, D, E, m45); D = sha1_round3(E, A, B, C, D, m46); C = sha1_round3(D, E, A, B, C, m47); B = sha1_round3(C, D, E, A, B, m48); A = sha1_round3(B, C, D, E, A, m49); E = sha1_round3(A, B, C, D, E, m50); D = sha1_round3(E, A, B, C, D, m51); C = sha1_round3(D, E, A, B, C, m52); B = sha1_round3(C, D, E, A, B, m53); A = sha1_round3(B, C, D, E, A, m54); E = sha1_round3(A, B, C, D, E, m55); D = sha1_round3(E, A, B, C, D, m56); C = sha1_round3(D, E, A, B, C, m57); B = sha1_round3(C, D, E, A, B, m58); A = sha1_round3(B, C, D, E, A, m59); // bool good60 = (e == E); // good60 = (d == D) && good60; // good60 = (c == C) && good60; // good60 = (b == B) && good60; // good60 = (a == A) && good60; bool good60 = 0 == ((e^E)|(d^D)|(c^C)|(b^B)|(a^A)); // sol: Q56,..,Q60,m44,...,m59 COLLCANDIDATEBUF.write(COLLCANDIDATECTL, good60, e, d, c, b, a, m44, m45, m46, m47, m48, m49, m50, m51, m52, m53, m54, m55, m56, m57, m58, m59); PERF_STOP_COUNTER(60); } // BACKUP CONTROLS ONLY IF THEY ARE IN SHARED (AND THUS BLOCK-SPECIFIC) __device__ void backup_controls() { __syncthreads(); if (threadIdx.x == 0) { // q18_solutions_ctl_bu[blockIdx.x] = Q18SOLCTL; // q19_solutions_ctl_bu[blockIdx.x] = Q19SOLCTL; q20_solutions_ctl_bu[blockIdx.x] = Q20SOLCTL; q21_solutions_ctl_bu[blockIdx.x] = Q21SOLCTL; q22_solutions_ctl_bu[blockIdx.x] = Q22SOLCTL; q23_solutions_ctl_bu[blockIdx.x] = Q23SOLCTL; q26_solutions_ctl_bu[blockIdx.x] = Q26SOLCTL; q28_solutions_ctl_bu[blockIdx.x] = Q28SOLCTL; q30_solutions_ctl_bu[blockIdx.x] = Q30SOLCTL; q40_solutions_ctl_bu[blockIdx.x] = Q40SOLCTL; #ifdef USE_PERF_COUNTERS performance_backup(); #endif } __syncthreads(); } __device__ void restore_controls() { __syncthreads(); if (threadIdx.x == 0) { // Q18SOLCTL = q18_solutions_ctl_bu[blockIdx.x]; // Q19SOLCTL = q19_solutions_ctl_bu[blockIdx.x]; Q20SOLCTL = q20_solutions_ctl_bu[blockIdx.x]; Q21SOLCTL = q21_solutions_ctl_bu[blockIdx.x]; Q22SOLCTL = q22_solutions_ctl_bu[blockIdx.x]; Q23SOLCTL = q23_solutions_ctl_bu[blockIdx.x]; Q26SOLCTL = q26_solutions_ctl_bu[blockIdx.x]; Q28SOLCTL = q28_solutions_ctl_bu[blockIdx.x]; Q30SOLCTL = q30_solutions_ctl_bu[blockIdx.x]; Q40SOLCTL = q40_solutions_ctl_bu[blockIdx.x]; #ifdef USE_PERF_COUNTERS performance_restore(); #endif } __syncthreads(); } __global__ void reset_buffers() { // restore_controls(); // unnecessary BASESOLBUF.reset(BASESOLCTL); Q18SOLBUF.reset(Q18SOLCTL); Q19SOLBUF.reset(Q19SOLCTL); Q20SOLBUF.reset(Q20SOLCTL); Q21SOLBUF.reset(Q21SOLCTL); Q22SOLBUF.reset(Q22SOLCTL); Q23SOLBUF.reset(Q23SOLCTL); Q26SOLBUF.reset(Q26SOLCTL); Q28SOLBUF.reset(Q28SOLCTL); Q30SOLBUF.reset(Q30SOLCTL); Q40SOLBUF.reset(Q40SOLCTL); COLLCANDIDATEBUF.reset(COLLCANDIDATECTL); #ifdef USE_PERF_COUNTERS performance_reset(); #endif backup_controls(); } __global__ void cuda_attack() { restore_controls(); __shared__ uint32_t stepQ18done; __shared__ uint64_t startclock; if (threadIdx.x==0) { stepQ18done = 0; startclock = clock64(); } #define USE_CLOCK_LOOP #ifdef USE_CLOCK_LOOP do { // crashes when adding this loop ?!?!?!?! causes memory access error ?!?!? // for (unsigned lloop = 0; lloop < 16; ++lloop) { #else for (unsigned lloop = 0; lloop < (1<<18); ++lloop) { { #endif #if 1 { uint32_t thidx = Q40SOLBUF.getreadidx(Q40SOLCTL); if (thidx != 0xFFFFFFFF) { step_extend_Q60(thidx); DEBUG_BREAK; continue; } } #endif #if 1 { uint32_t thidx = Q30SOLBUF.getreadidx(Q30SOLCTL); if (thidx != 0xFFFFFFFF) { stepQ3140(thidx); DEBUG_BREAK; continue; } } #endif #if 1 { uint32_t thidx = Q28SOLBUF.getreadidx(Q28SOLCTL); if (thidx != 0xFFFFFFFF) { stepQ2930(thidx); DEBUG_BREAK; continue; } } #endif #if 1 { uint32_t thidx = Q26SOLBUF.getreadidx(Q26SOLCTL); if (thidx != 0xFFFFFFFF) { stepQ2728(thidx); DEBUG_BREAK; continue; } } #endif #if 1 { uint32_t thidx = Q23SOLBUF.getreadidx(Q23SOLCTL); if (thidx != 0xFFFFFFFF) { stepQ2456(thidx); DEBUG_BREAK; continue; } } #endif #if 1 { uint32_t thidx = Q22SOLBUF.getreadidx(Q22SOLCTL); if (thidx != 0xFFFFFFFF) { stepQ23(thidx); DEBUG_BREAK; continue; } } #endif #if 1 { uint32_t thidx = Q21SOLBUF.getreadidx(Q21SOLCTL); if (thidx != 0xFFFFFFFF) { stepQ22(thidx); DEBUG_BREAK; continue; } } #endif #if 1 { uint32_t thidx = Q20SOLBUF.getreadidx(Q20SOLCTL); if (thidx != 0xFFFFFFFF) { stepQ21(thidx); DEBUG_BREAK; continue; } } #endif #if 1 { uint32_t thidx = Q19SOLBUF.getreadidx(Q19SOLCTL); if (thidx != 0xFFFFFFFF) { stepQ20(thidx); DEBUG_BREAK; continue; } } #endif #if 1 { uint32_t thidx = Q18SOLBUF.getreadidx(Q18SOLCTL); if (thidx != 0xFFFFFFFF) { stepQ19(thidx); DEBUG_BREAK; continue; } } #endif #if 1 // only let warp 0 of each block grab a basesol once per kernel run if (stepQ18done == 0 && (threadIdx.x>>5)==0) { uint32_t thidx = BASESOLBUF.getreadidx(BASESOLCTL); if (thidx != 0xFFFFFFFF) { if (threadIdx.x == 0) stepQ18done = 1; stepQ18(thidx); // break; DEBUG_BREAK; continue; } } #endif } } #ifdef USE_CLOCK_LOOP #ifdef USE_PERF_COUNTERS while ((clock64()-startclock) < (uint64_t(1)<<32)); #else while ((clock64()-startclock) < (uint64_t(1)<<34)); #endif #endif backup_controls(); } void verify_step_computations(int cuda_blocks); bool verify(basesol_t basesol); void print_attack_info(); void save_q60solutions() { if (outputfile.empty()) { outputfile = "q60sols.txt"; // return; } static size_t oldsize = 0; q60sol_t sol; vector<q60sol_t> q60sols; for (size_t i = 0; i < COLLCANDIDATECTL.write_idx; ++i) { sol.Q[0] = COLLCANDIDATEBUF.get<0>(i); sol.Q[1] = COLLCANDIDATEBUF.get<1>(i); sol.Q[2] = COLLCANDIDATEBUF.get<2>(i); sol.Q[3] = COLLCANDIDATEBUF.get<3>(i); sol.Q[4] = COLLCANDIDATEBUF.get<4>(i); sol.m[0] = COLLCANDIDATEBUF.get<5>(i); sol.m[1] = COLLCANDIDATEBUF.get<6>(i); sol.m[2] = COLLCANDIDATEBUF.get<7>(i); sol.m[3] = COLLCANDIDATEBUF.get<8>(i); sol.m[4] = COLLCANDIDATEBUF.get<9>(i); sol.m[5] = COLLCANDIDATEBUF.get<10>(i); sol.m[6] = COLLCANDIDATEBUF.get<11>(i); sol.m[7] = COLLCANDIDATEBUF.get<12>(i); sol.m[8] = COLLCANDIDATEBUF.get<13>(i); sol.m[9] = COLLCANDIDATEBUF.get<14>(i); sol.m[10] = COLLCANDIDATEBUF.get<15>(i); sol.m[11] = COLLCANDIDATEBUF.get<16>(i); sol.m[12] = COLLCANDIDATEBUF.get<17>(i); sol.m[13] = COLLCANDIDATEBUF.get<18>(i); sol.m[14] = COLLCANDIDATEBUF.get<19>(i); sol.m[15] = COLLCANDIDATEBUF.get<20>(i); q60sols.push_back(sol); } if (oldsize != q60sols.size()) { oldsize = q60sols.size(); cout << "Writing " << q60sols.size() << " Q60-solutions to '" << outputfile << "'..." << endl; ofstream ofs(outputfile.c_str()); if (!ofs) { cout << "Error opening '" << outputfile << ".tmp'!" << endl; return; } for (size_t i = 0; i < q60sols.size(); ++i) { ofs << encode_q60sol(q60sols[i]) << endl; } } } buffer_basesol_t basesol_buf_host; control_basesol_t basesol_ctl_host; bool compiled_with_cuda() { return true; } void cuda_main(std::vector<basesol_t>& basesols) { unsigned flags; switch (cuda_scheduler) { case 0: default: flags = hipDeviceScheduleAuto; break; case 1: flags = hipDeviceScheduleSpin; break; case 2: flags = hipDeviceScheduleYield; break; case 3: flags = hipDeviceScheduleBlockingSync; break; } cout << "Using device " << cuda_device << ": " << flush; CUDA_ASSERT( hipSetDeviceFlags(flags) ); CUDA_ASSERT( hipSetDevice(cuda_device) ); hipDeviceProp_t prop; CUDA_ASSERT( hipGetDeviceProperties(&prop, cuda_device) ); cout << prop.name << " (PCI " << hex << setw(2) << setfill('0') << prop.pciBusID << ":" << hex << setw(2) << setfill('0') << prop.pciDeviceID << "." << hex << prop.pciDomainID << dec << ")" << endl; if (cuda_threads_per_block == -1) { cuda_threads_per_block = prop.maxThreadsPerBlock; } if (THREADS_PER_BLOCK < cuda_threads_per_block) { cuda_threads_per_block = THREADS_PER_BLOCK; } if (prop.regsPerBlock/64 < cuda_threads_per_block) { cuda_threads_per_block = prop.regsPerBlock/64; } if (cuda_blocks == -1) { cuda_blocks = prop.multiProcessorCount * (prop.maxThreadsPerMultiProcessor / prop.maxThreadsPerBlock); } if (BLOCKS < cuda_blocks) { cuda_blocks = BLOCKS; } cout << "Using " << cuda_blocks << " blocks x " << cuda_threads_per_block << " threads/block." << endl; cout << "Resetting buffers..." << flush; hipLaunchKernelGGL(( reset_buffers), dim3(cuda_blocks),dim3(32), 0, 0, ); CUDA_ASSERT( hipDeviceSynchronize() ); cout << "done." << endl; #if 1 cout << "Filtering base solutions" << endl; cout << "In : " << basesols.size() << endl; for (size_t i = 0; i < basesols.size(); ) { if (verify(basesols[i])) { ++i; } else { swap(basesols[i], basesols.back()); basesols.pop_back(); } } cout << "Out: " << basesols.size() << endl; if (basesols.size() == 0) { return; } #endif cout << "Initializing base solution buffer" << endl; size_t basesolcnt = basesols.size(); if (basesol_buf_host.size < basesolcnt) { basesolcnt = basesol_buf_host.size; } for (size_t i = 0; i < basesolcnt; ++i) { // Q12,..,Q17,m4,...,m19 basesol_buf_host.write(basesol_ctl_host, true , basesols[i].Q[ 0], basesols[i].Q[ 1], basesols[i].Q[ 2], basesols[i].Q[ 3], basesols[i].Q[ 4], basesols[i].Q[ 5] , basesols[i].m[ 0], basesols[i].m[ 1], basesols[i].m[ 2], basesols[i].m[ 3] , basesols[i].m[ 4], basesols[i].m[ 5], basesols[i].m[ 6], basesols[i].m[ 7] , basesols[i].m[ 8], basesols[i].m[ 9], basesols[i].m[10], basesols[i].m[11] , basesols[i].m[12], basesols[i].m[13], basesols[i].m[14], basesols[i].m[15] ); } #ifdef USE_MANAGED cout << "Moving " << basesolcnt << " base solutions to GPU MANAGED..." << flush; // directly copy to variable in HOST memory base_solutions_buf = basesol_buf_host; base_solutions_ctl = basesol_ctl_host; #else cout << "Moving " << basesolcnt << " base solutions to GPU GLOBAL..." << flush; // directly copy to variable in GPU GLOBAL memory CUDA_ASSERT( hipMemcpyToSymbol(base_solutions_buf, &basesol_buf_host, sizeof(basesol_buf_host) ) ); CUDA_ASSERT( hipMemcpyToSymbol(base_solutions_ctl, &basesol_ctl_host, sizeof(basesol_ctl_host) ) ); CUDA_ASSERT( hipDeviceSynchronize() ); #endif cout << "done." << endl; // use auto for same type deduction, same type is necessary for proper wrap-around behaviour uint32_t q18oldbufsize; uint32_t q19oldbufsize; uint32_t q20oldbufsize[BLOCKS]; uint32_t q21oldbufsize[BLOCKS]; uint32_t q22oldbufsize[BLOCKS]; uint32_t q23oldbufsize[BLOCKS]; uint32_t q26oldbufsize[BLOCKS]; uint32_t q28oldbufsize[BLOCKS]; uint32_t q30oldbufsize[BLOCKS]; uint32_t q40oldbufsize[BLOCKS]; q18oldbufsize = q18_solutions_ctl.write_idx; q19oldbufsize = q19_solutions_ctl.write_idx; for (unsigned bl = 0; bl < cuda_blocks; ++bl) { q20oldbufsize[bl] = q20_solutions_ctl_bu[bl].write_idx; q21oldbufsize[bl] = q21_solutions_ctl_bu[bl].write_idx; q22oldbufsize[bl] = q22_solutions_ctl_bu[bl].write_idx; q23oldbufsize[bl] = q23_solutions_ctl_bu[bl].write_idx; q26oldbufsize[bl] = q26_solutions_ctl_bu[bl].write_idx; q28oldbufsize[bl] = q28_solutions_ctl_bu[bl].write_idx; q30oldbufsize[bl] = q30_solutions_ctl_bu[bl].write_idx; q40oldbufsize[bl] = q40_solutions_ctl_bu[bl].write_idx; } uint64_t q18sols = 0, q19sols = 0, q20sols = 0, q21sols = 0, q22sols = 0, q23sols = 0, q26sols = 0, q28sols = 0, q30sols = 0, q40sols = 0, q60sols = 0; cout << "Starting CUDA kernel" << flush; timer::timer cuda_total_time; while (true) { cout << "." << flush; timer::timer cuda_time; hipLaunchKernelGGL(( cuda_attack), dim3(cuda_blocks),dim3(cuda_threads_per_block), 0, 0, ); CUDA_ASSERT( hipDeviceSynchronize() ); cout << "CUDA running time: " << cuda_time.time() << endl; #ifdef VERIFY_GPU_RESULTS verify_step_computations(cuda_blocks); #endif uint64_t basesolsleft = uint32_t(base_solutions_ctl.write_idx - base_solutions_ctl.read_idx); uint64_t gl_workleft_base = uint32_t(basesolsleft)>>5; uint64_t gl_workleft_q18 = ((q18_solutions_ctl.write_idx - q18_solutions_ctl.read_idx) % q18_solutions_ctl.size) >>5; uint64_t gl_workleft_q19 = ((q19_solutions_ctl.write_idx - q19_solutions_ctl.read_idx) % q19_solutions_ctl.size) >>5; uint64_t gl_workleft = gl_workleft_base + gl_workleft_q18 + gl_workleft_q19; q18sols += q18_solutions_ctl.write_idx - q18oldbufsize; q19sols += q19_solutions_ctl.write_idx - q19oldbufsize; q18oldbufsize = q18_solutions_ctl.write_idx; q19oldbufsize = q19_solutions_ctl.write_idx; uint64_t workleft = gl_workleft; for (unsigned bl = 0; bl < cuda_blocks; ++bl) { workleft += (q20_solutions_ctl_bu[bl].write_idx - q20_solutions_ctl_bu[bl].read_idx)>>5; workleft += (q21_solutions_ctl_bu[bl].write_idx - q21_solutions_ctl_bu[bl].read_idx)>>5; workleft += (q22_solutions_ctl_bu[bl].write_idx - q22_solutions_ctl_bu[bl].read_idx)>>5; workleft += (q23_solutions_ctl_bu[bl].write_idx - q23_solutions_ctl_bu[bl].read_idx)>>5; workleft += (q26_solutions_ctl_bu[bl].write_idx - q26_solutions_ctl_bu[bl].read_idx)>>5; workleft += (q28_solutions_ctl_bu[bl].write_idx - q28_solutions_ctl_bu[bl].read_idx)>>5; workleft += (q30_solutions_ctl_bu[bl].write_idx - q30_solutions_ctl_bu[bl].read_idx)>>5; workleft += (q40_solutions_ctl_bu[bl].write_idx - q40_solutions_ctl_bu[bl].read_idx)>>5; q20sols += q20_solutions_ctl_bu[bl].write_idx - q20oldbufsize[bl]; q21sols += q21_solutions_ctl_bu[bl].write_idx - q21oldbufsize[bl]; q22sols += q22_solutions_ctl_bu[bl].write_idx - q22oldbufsize[bl]; q23sols += q23_solutions_ctl_bu[bl].write_idx - q23oldbufsize[bl]; q26sols += q26_solutions_ctl_bu[bl].write_idx - q26oldbufsize[bl]; q28sols += q28_solutions_ctl_bu[bl].write_idx - q28oldbufsize[bl]; q30sols += q30_solutions_ctl_bu[bl].write_idx - q30oldbufsize[bl]; q40sols += q40_solutions_ctl_bu[bl].write_idx - q40oldbufsize[bl]; q20oldbufsize[bl] = q20_solutions_ctl_bu[bl].write_idx; q21oldbufsize[bl] = q21_solutions_ctl_bu[bl].write_idx; q22oldbufsize[bl] = q22_solutions_ctl_bu[bl].write_idx; q23oldbufsize[bl] = q23_solutions_ctl_bu[bl].write_idx; q26oldbufsize[bl] = q26_solutions_ctl_bu[bl].write_idx; q28oldbufsize[bl] = q28_solutions_ctl_bu[bl].write_idx; q30oldbufsize[bl] = q30_solutions_ctl_bu[bl].write_idx; q40oldbufsize[bl] = q40_solutions_ctl_bu[bl].write_idx; } q60sols = collision_candidates_ctl.write_idx; cout << "Q18 sols:\t" << q18sols << "\t" << (double(q18sols)/cuda_total_time.time()) << "#/s" << endl; cout << "Q19 sols:\t" << q19sols << "\t" << (double(q19sols)/cuda_total_time.time()) << "#/s" << endl; cout << "Q20 sols:\t" << q20sols << "\t" << (double(q20sols)/cuda_total_time.time()) << "#/s" << endl; cout << "Q21 sols:\t" << q21sols << "\t" << (double(q21sols)/cuda_total_time.time()) << "#/s" << endl; cout << "Q22 sols:\t" << q22sols << "\t" << (double(q22sols)/cuda_total_time.time()) << "#/s" << endl; cout << "Q23 sols:\t" << q23sols << "\t" << (double(q23sols)/cuda_total_time.time()) << "#/s" << endl; cout << "Q26 sols:\t" << q26sols << "\t" << (double(q26sols)/cuda_total_time.time()) << "#/s" << endl; cout << "Q28 sols:\t" << q28sols << "\t" << (double(q28sols)/cuda_total_time.time()) << "#/s" << endl; cout << "Q30 sols:\t" << q30sols << "\t" << (double(q30sols)/cuda_total_time.time()) << "#/s" << endl; cout << "Q40 sols:\t" << q40sols << "\t" << (double(q40sols)/cuda_total_time.time()) << "#/s" << endl; cout << "Q60 sols:\t" << q60sols << "\t" << (double(q60sols)/cuda_total_time.time()) << "#/s" << endl; save_q60solutions(); #ifdef USE_PERF_COUNTERS show_performance_counters(); #endif // exit if base solutions have been exhausted // !! NOTE THAT THERE MAY STILL BE SOME OTHER WORK LEFT !! cout << "Basesolutions left: " << basesolsleft << "\t" << (double(base_solutions_ctl.read_idx)/cuda_total_time.time()) << "#/s" << endl; cout << "Global work left: B:" << gl_workleft_base << " Q18:" << gl_workleft_q18 << " Q19:" << gl_workleft_q19 << endl; if (gl_workleft == 0) { cout << "Exhausted work!" << endl; break; } // boost::this_thread::sleep_for( boost::chrono::seconds(1) ); } } #ifdef VERIFY_GPU_RESULTS #define VERIFY_ERROR(s) { cout << "Err @ block=" << block << " bufidx=" << read_idx << " baseidx=" << base_idx << " : " << s << endl; ok = false; } uint32_t isQokay(int t, uint32_t Q[]) { using namespace host; uint32_t Qval = Qset1mask[QOFF+t] ^ (Qnextmask[QOFF+t] & Q[QOFF+t+1]) ^ (Qprevmask[QOFF+t] & Q[QOFF+t-1]) ^ (Qprevrmask[QOFF+t] & rotate_left(Q[QOFF+t-1],30)) ^ (Qprev2rmask[QOFF+t] & rotate_left(Q[QOFF+t-2],30)) ; return ( (Q[QOFF+t] ^ Qval) & Qcondmask[QOFF+t] ); } vector<uint32_t>& operator^=(vector<uint32_t>& l, const vector<uint32_t>& r) { if (l.size() != r.size()) throw std::runtime_error("vector<uint32_t>::operator^=(): unequal sizes!"); for (unsigned i = 0; i < l.size(); ++i) l[i] ^= r[i]; return l; } void print_convert_msgbitrel(const uint32_t rel[17], int oldmainblockoffset, int newmainblockoffset) { vector<uint32_t> bitrel(81, 0); for (int t = oldmainblockoffset; t < oldmainblockoffset + 16; ++t) bitrel[t] = rel[t - oldmainblockoffset]; bitrel[80] = rel[16]; map< vector<uint32_t>, vector<uint32_t> > bit_exp; for (unsigned t = 0; t < 16; ++t) for (unsigned b = 0; b < 32; ++b) { vector<uint32_t> l(16, 0), r(80, 0); l[t] |= 1 << b; sha1_me_generalised(&r[0], &l[0], newmainblockoffset); bit_exp[l] = r; } map< pair<unsigned, unsigned>, vector<uint32_t> > bit80_vec16; for (unsigned t = 0; t < 80; ++t) for (unsigned b = 0; b < 32; ++b) { vector<uint32_t> r(16, 0); for (map<vector<uint32_t>,vector<uint32_t> >::const_iterator it = bit_exp.begin(); it != bit_exp.end(); ++it) if (it->second[t] & (1 << b)) r ^= it->first; bit80_vec16[make_pair(t, b)] = r; } vector<uint32_t> newrel(16); for (unsigned t = 0; t < 80; ++t) for (unsigned b = 0; b < 32; ++b) if (bitrel[t] & (1 << b)) newrel ^= bit80_vec16[make_pair(t, b)]; newrel.resize(17); newrel[16] = (bitrel[80] == 0) ? 0 : 1; for (unsigned t = newmainblockoffset; t < newmainblockoffset + 16; ++t) for (unsigned b = 0; b < 32; ++b) if (newrel[t - newmainblockoffset] & (1 << b)) cout << " ^ W" << t << "[" << b << "]"; cout << " = " << (newrel[16] & 1) << endl; } bool verify_Q18_Q19(int block, size_t read_idx, int lastQ, uint32_t w0, uint32_t w1) { bool ok = true; using namespace host; uint32_t m[80]; uint32_t Q[85]; size_t base_idx = unpack_idx(w0,w1); Q[QOFF+12] = base_solutions_buf.get<0>(base_idx); Q[QOFF+13] = base_solutions_buf.get<1>(base_idx); Q[QOFF+14] = base_solutions_buf.get<2>(base_idx); Q[QOFF+15] = base_solutions_buf.get<3>(base_idx); Q[QOFF+16] = base_solutions_buf.get<4>(base_idx); Q[QOFF+17] = base_solutions_buf.get<5>(base_idx); m[ 5] = base_solutions_buf.get< 6>(base_idx); m[ 6] = base_solutions_buf.get< 7>(base_idx); m[ 7] = base_solutions_buf.get< 8>(base_idx); m[ 8] = base_solutions_buf.get< 9>(base_idx); m[ 9] = base_solutions_buf.get<10>(base_idx); m[10] = base_solutions_buf.get<11>(base_idx); m[11] = base_solutions_buf.get<12>(base_idx); m[12] = base_solutions_buf.get<13>(base_idx); m[13] = base_solutions_buf.get<14>(base_idx); m[14] = base_solutions_buf.get<15>(base_idx); m[15] = base_solutions_buf.get<16>(base_idx); m[16] = base_solutions_buf.get<17>(base_idx); m[17] = base_solutions_buf.get<18>(base_idx); m[18] = base_solutions_buf.get<19>(base_idx); m[19] = base_solutions_buf.get<20>(base_idx); m[20] = base_solutions_buf.get<21>(base_idx); uint32_t m14nb = unpack_w14_nbs(w0, w1); uint32_t m15nb = unpack_w15_nbs(w0, w1); uint32_t m16nb = unpack_w16_nbs(w0, w1); uint32_t m17nb = unpack_w17base_nbs(w0, w1); if (m14nb & ~W14NBALLM) VERIFY_ERROR("m14nb bad"); if (m15nb & ~W15NBALLM) VERIFY_ERROR("m15nb bad"); if (m16nb & ~W16NBALLM) VERIFY_ERROR("m16nb bad"); if (m17nb & ~W17NBBASM) VERIFY_ERROR("m17nb bad"); m[14] |= m14nb; m[15] |= m15nb; m[16] |= m16nb; m[17] |= m17nb; uint32_t* main_m1 = m; //w18[5]: W15[4] main_m1[18] ^= ((0 ^ (main_m1[15] >> 4)) & 1) << 5; //w19[13]: W15[15] W15[16] W17[14] W17[16] W17[19] main_m1[19] ^= ((0 ^ (main_m1[15] >> 15) ^ (main_m1[15] >> 16) ^ (main_m1[17] >> 14) ^ (main_m1[17] >> 16) ^ (main_m1[17] >> 19)) & 1) << 13; //w19[15] : W14[10] W15[12] W15[13] W16[13] W16[14] W16[15] W17[11] W17[13] W17[16] W17[18] W18[12] W19[10] main_m1[19] ^= ((0 ^ (main_m1[14] >> 10) ^ (main_m1[15] >> 12) ^ (main_m1[15] >> 13) ^ (main_m1[16] >> 13) ^ (main_m1[16] >> 14) ^ (main_m1[16] >> 15) ^ (main_m1[17] >> 11) ^ (main_m1[17] >> 13) ^ (main_m1[17] >> 16) ^ (main_m1[17] >> 18) ^ (main_m1[18] >> 12) ^ (main_m1[19] >> 10)) & 1) << 15; //w19[16] : W17[17] W17[19] main_m1[19] ^= ((0 ^ (main_m1[17] >> 17) ^ (main_m1[17] >> 19)) & 1) << 16; //w19[17] : W16[16] W17[18] W17[19] W18[15] main_m1[19] ^= ((0 ^ (main_m1[16] >> 16) ^ (main_m1[17] >> 18) ^ (main_m1[17] >> 19) ^ (main_m1[18] >> 15)) & 1) << 17; //w19[18] : W17[19] main_m1[19] ^= ((0 ^ (main_m1[17] >> 19)) & 1) << 18; //w20[0] : W16[16] W17[19] W18[15] main_m1[20] ^= ((0 ^ (main_m1[16] >> 16) ^ (main_m1[17] >> 19) ^ (main_m1[18] >> 15)) & 1) << 0; //w20[14] : W15[14] W15[16] W17[18] W17[19] main_m1[20] ^= ((0 ^ (main_m1[15] >> 14) ^ (main_m1[15] >> 16) ^ (main_m1[17] >> 18) ^ (main_m1[17] >> 19)) & 1) << 14; //w20[16] : W15[16] main_m1[20] ^= ((0 ^ (main_m1[15] >> 16)) & 1) << 16; //w20[17] : W15[16] W16[13] W16[15] W17[16] W18[12] main_m1[20] ^= ((0 ^ (main_m1[15] >> 16) ^ (main_m1[16] >> 13) ^ (main_m1[16] >> 15) ^ (main_m1[17] >> 16) ^ (main_m1[18] >> 12)) & 1) << 17; Q[QOFF + 16] -= rotate_left(Q[QOFF + 15], 5); Q[QOFF + 15] += m14nb; Q[QOFF + 16] += rotate_left(Q[QOFF + 15], 5); Q[QOFF + 16] += m15nb; for (int t = 16; t < lastQ; ++t) { sha1_step(t, Q, m); } for (int t = 14; t <= lastQ; ++t) { uint32_t okm = isQokay(t,Q); if (okm != 0) { VERIFY_ERROR("Q" << t << " bad !" << hex << okm << dec); ok = false; } } return ok; } bool verify_Q20(int block, size_t read_idx) { bool ok = true; using namespace host; const int lastQ = 20; uint32_t m[80]; uint32_t Q[85]; // extsol: q15, q16, q17, m14, m15, m16, m17, m18, m19, m20, base_idx size_t base_idx = q20_solutions_buf[block].get<10>(read_idx); Q[QOFF + 12] = base_solutions_buf.get<0>(base_idx); Q[QOFF + 13] = base_solutions_buf.get<1>(base_idx); Q[QOFF + 14] = base_solutions_buf.get<2>(base_idx); Q[QOFF + 15] = q20_solutions_buf[block].get<0>(read_idx); Q[QOFF + 16] = q20_solutions_buf[block].get<1>(read_idx); Q[QOFF + 17] = q20_solutions_buf[block].get<2>(read_idx); m[ 5] = base_solutions_buf.get< 6>(base_idx); m[ 6] = base_solutions_buf.get< 7>(base_idx); m[ 7] = base_solutions_buf.get< 8>(base_idx); m[ 8] = base_solutions_buf.get< 9>(base_idx); m[ 9] = base_solutions_buf.get<10>(base_idx); m[10] = base_solutions_buf.get<11>(base_idx); m[11] = base_solutions_buf.get<12>(base_idx); m[12] = base_solutions_buf.get<13>(base_idx); m[13] = base_solutions_buf.get<14>(base_idx); m[14] = q20_solutions_buf[block].get<3>(read_idx); m[15] = q20_solutions_buf[block].get<4>(read_idx); m[16] = q20_solutions_buf[block].get<5>(read_idx); m[17] = q20_solutions_buf[block].get<6>(read_idx); m[18] = q20_solutions_buf[block].get<7>(read_idx); m[19] = q20_solutions_buf[block].get<8>(read_idx); m[20] = q20_solutions_buf[block].get<9>(read_idx); sha1_me_generalised(m, 5); // compute previous steps for (int t = 16; t >= 0; --t) sha1_step_bw(t, Q, m); for (int t = 17; t < lastQ; ++t) sha1_step(t, Q, m); // verify stateconditions Q-2,...,Q20 for (int t = -4+2; t <= lastQ; ++t) { uint32_t okm = isQokay(t, Q); if (okm != 0) { VERIFY_ERROR("Q" << t << " bad !" << hex << okm << dec); ok = false; } } // verify msgbitrelations // [1200] verify message bitrelations for (unsigned r = 0; r < msgbitrels16_size; ++r) { uint32_t w = msgbitrels16[r][16]; for (unsigned t = mainblockoffset; t < mainblockoffset + 16; ++t) { w ^= m[t] & msgbitrels16[r][t - mainblockoffset]; } if (0 != (hashclash::hw(w) & 1)) { std::cerr << "bitrelation " << r << " is not satisfied!" << std::endl; print_convert_msgbitrel(msgbitrels16[r], 1, 5); return false; } } return ok; } bool verify_Q21_Q26(int block, size_t read_idx, int lastQ, uint32_t w0, uint32_t w1) { bool ok = true; using namespace host; uint32_t m[80]; uint32_t Q[85]; size_t ext_idx = unpack_idx(w0,w1); size_t base_idx = q20_solutions_buf[block].get<10>(ext_idx); Q[QOFF + 12] = base_solutions_buf.get<0>(base_idx); Q[QOFF + 13] = base_solutions_buf.get<1>(base_idx); Q[QOFF + 14] = base_solutions_buf.get<2>(base_idx); Q[QOFF + 15] = q20_solutions_buf[block].get<0>(ext_idx); Q[QOFF + 16] = q20_solutions_buf[block].get<1>(ext_idx); Q[QOFF + 17] = q20_solutions_buf[block].get<2>(ext_idx); m[ 5] = base_solutions_buf.get< 6>(base_idx); m[ 6] = base_solutions_buf.get< 7>(base_idx); m[ 7] = base_solutions_buf.get< 8>(base_idx); m[ 8] = base_solutions_buf.get< 9>(base_idx); m[ 9] = base_solutions_buf.get<10>(base_idx); m[10] = base_solutions_buf.get<11>(base_idx); m[11] = base_solutions_buf.get<12>(base_idx); m[12] = base_solutions_buf.get<13>(base_idx); m[13] = base_solutions_buf.get<14>(base_idx); m[14] = q20_solutions_buf[block].get<3>(ext_idx); m[15] = q20_solutions_buf[block].get<4>(ext_idx); m[16] = q20_solutions_buf[block].get<5>(ext_idx); m[17] = q20_solutions_buf[block].get<6>(ext_idx); m[18] = q20_solutions_buf[block].get<7>(ext_idx); m[19] = q20_solutions_buf[block].get<8>(ext_idx); m[20] = q20_solutions_buf[block].get<9>(ext_idx); m[17] ^= unpack_w17ext_nbs(w0,w1); m[18] ^= unpack_w18_nbs(w0,w1); m[19] &= ~W19NBPACKM; m[19] ^= unpack_w19_nbs_fb(w0,w1); m[20] &= ~W20NBPACKM; m[20] ^= unpack_w20_nbs_fb(w0,w1); sha1_me_generalised(m, 5); for (int t = 17; t < lastQ; ++t) { sha1_step(t, Q, m); } for (int t = 14; t <= lastQ; ++t) { uint32_t okm = isQokay(t,Q); if (okm != 0) { VERIFY_ERROR("Q" << t << " bad !" << hex << okm << dec); ok = false; } } // verify msgbitrelations // [1200] verify message bitrelations for (unsigned r = 0; r < msgbitrels16_size; ++r) { uint32_t w = msgbitrels16[r][16]; for (unsigned t = mainblockoffset; t < mainblockoffset + 16; ++t) { w ^= m[t] & msgbitrels16[r][t - mainblockoffset]; } if (0 != (hc::hw(w) & 1)) { std::cout << "bitrelation " << r << " is not satisfied!" << std::endl; print_convert_msgbitrel(msgbitrels16[r], 1, 4); return false; } } return ok; } bool verify_Q27_Q30(int block, size_t read_idx, int lastQ, uint32_t w0, uint32_t w1, uint32_t q112boom) { bool ok = true; using namespace host; uint32_t m[80]; uint32_t Q[85]; size_t ext_idx = unpack_idx(w0,w1); size_t base_idx = q20_solutions_buf[block].get<10>(ext_idx); Q[QOFF + 12] = base_solutions_buf.get<0>(base_idx); Q[QOFF + 13] = base_solutions_buf.get<1>(base_idx); Q[QOFF + 14] = base_solutions_buf.get<2>(base_idx); Q[QOFF + 15] = q20_solutions_buf[block].get<0>(ext_idx); Q[QOFF + 16] = q20_solutions_buf[block].get<1>(ext_idx); Q[QOFF + 17] = q20_solutions_buf[block].get<2>(ext_idx); m[ 5] = base_solutions_buf.get< 6>(base_idx); m[ 6] = base_solutions_buf.get< 7>(base_idx); m[ 7] = base_solutions_buf.get< 8>(base_idx); m[ 8] = base_solutions_buf.get< 9>(base_idx); m[ 9] = base_solutions_buf.get<10>(base_idx); m[10] = base_solutions_buf.get<11>(base_idx); m[11] = base_solutions_buf.get<12>(base_idx); m[12] = base_solutions_buf.get<13>(base_idx); m[13] = base_solutions_buf.get<14>(base_idx); m[14] = q20_solutions_buf[block].get<3>(ext_idx); m[15] = q20_solutions_buf[block].get<4>(ext_idx); m[16] = q20_solutions_buf[block].get<5>(ext_idx); m[17] = q20_solutions_buf[block].get<6>(ext_idx); m[18] = q20_solutions_buf[block].get<7>(ext_idx); m[19] = q20_solutions_buf[block].get<8>(ext_idx); m[20] = q20_solutions_buf[block].get<9>(ext_idx); m[17] ^= unpack_w17ext_nbs(w0,w1); m[18] ^= unpack_w18_nbs(w0,w1); m[19] &= ~W19NBPACKM; m[19] ^= unpack_w19_nbs_fb(w0,w1); m[20] &= ~W20NBPACKM; m[20] ^= unpack_w20_nbs_fb(w0,w1); uint32_t q11boom = q112boom & Q11BOOMS; uint32_t q12boom = (q112boom>>16) & Q12BOOMS; m[10] ^= q11boom; m[11] ^= q11boom<<5; m[14] ^= (q11boom>>2)&(1<<6); m[15] ^= q11boom>>2; m[11] ^= q12boom; m[12] ^= q12boom<<5; m[16] ^= q12boom>>2; sha1_me_generalised(m, 5); for (int t = 17; t < lastQ; ++t) { sha1_step(t, Q, m); } for (int t = 14; t <= lastQ; ++t) { uint32_t okm = isQokay(t,Q); if (okm != 0) { VERIFY_ERROR("Q" << t << " bad !" << hex << okm << dec); ok = false; } } // verify msgbitrelations // [1200] verify message bitrelations for (unsigned r = 0; r < msgbitrels16_size; ++r) { uint32_t w = msgbitrels16[r][16]; for (unsigned t = mainblockoffset; t < mainblockoffset + 16; ++t) { w ^= m[t] & msgbitrels16[r][t - mainblockoffset]; } if (0 != (hc::hw(w) & 1)) { std::cout << "bitrelation " << r << " is not satisfied!" << std::endl; print_convert_msgbitrel(msgbitrels16[r], 1, 4); return false; } } return ok; } void verify_step_computations(int cuda_blocks) { for (unsigned block = 0; block < cuda_blocks; ++block) { cout << "======== Verifying block " << block << endl; /* cout << "Base solutions left: " << (base_solutions_ctl.write_idx - base_solutions_ctl.read_idx) << setfill(' ') << endl; size_t q18checked = 0, q18ok = 0; uint32_t q18count = q18_solutions_ctl_bu[block].write_idx - q18_solutions_ctl_bu[block].read_idx; cout << q18_solutions_ctl_bu[block].read_idx << " " << q18_solutions_ctl_bu[block].write_idx << " " << q18count << endl; for (uint32_t i = q18_solutions_ctl_bu[block].read_idx; i != q18_solutions_ctl_bu[block].write_idx; ++i) { uint32_t w0 = q18_solutions_buf[block].get<0>(i); uint32_t w1 = q18_solutions_buf[block].get<1>(i); if (verify_Q18_Q19(block, i, 18, w0, w1)) ++q18ok; ++q18checked; if (i - q18_solutions_ctl_bu[block].read_idx > q18_solutions_ctl_bu[block].size) break; } cout << "Verified " << setw(10) << q18checked << " out of " << setw(10) << q18count << " Q18 solutions: " << q18ok << " OK" << endl; size_t q19checked = 0, q19ok = 0; uint32_t q19count = q19_solutions_ctl_bu[block].write_idx - q19_solutions_ctl_bu[block].read_idx; for (uint32_t i = q19_solutions_ctl_bu[block].read_idx; i != q19_solutions_ctl_bu[block].write_idx; ++i) { uint32_t w0 = q19_solutions_buf[block].get<0>(i); uint32_t w1 = q19_solutions_buf[block].get<1>(i); if (verify_Q18_Q19(block, i, 19, w0, w1)) ++q19ok; ++q19checked; if (i - q19_solutions_ctl_bu[block].read_idx > q19_solutions_ctl_bu[block].size) break; } cout << "Verified " << setw(10) << q19checked << " out of " << setw(10) << q19count << " Q19 solutions: " << q19ok << " OK" << endl; */ size_t q20checked = 0, q20ok = 0; uint32_t q20count = q20_solutions_ctl_bu[block].write_idx - q20_solutions_ctl_bu[block].read_idx; for (uint32_t i = q20_solutions_ctl_bu[block].read_idx; i != q20_solutions_ctl_bu[block].write_idx; ++i) { if (verify_Q20(block, i)) ++q20ok; ++q20checked; if (i - q20_solutions_ctl_bu[block].read_idx > q20_solutions_ctl_bu[block].size) break; } cout << "Verified " << setw(10) << q20checked << " out of " << setw(10) << q20count << " Q20 solutions: " << q20ok << " OK" << endl; size_t q21checked = 0, q21ok = 0; uint32_t q21count = q21_solutions_ctl_bu[block].write_idx - q21_solutions_ctl_bu[block].read_idx; for (uint32_t i = q21_solutions_ctl_bu[block].read_idx; i != q21_solutions_ctl_bu[block].write_idx; ++i) { uint32_t w0 = q21_solutions_buf[block].get<0>(i); uint32_t w1 = q21_solutions_buf[block].get<1>(i); if (verify_Q21_Q26(block, i, 21, w0, w1)) ++q21ok; ++q21checked; if (i - q21_solutions_ctl_bu[block].read_idx > q21_solutions_ctl_bu[block].size) break; } cout << "Verified " << setw(10) << q21checked << " out of " << setw(10) << q21count << " Q21 solutions: " << q21ok << " OK" << endl; size_t q22checked = 0, q22ok = 0; uint32_t q22count = q22_solutions_ctl_bu[block].write_idx - q22_solutions_ctl_bu[block].read_idx; for (uint32_t i = q22_solutions_ctl_bu[block].read_idx; i != q22_solutions_ctl_bu[block].write_idx; ++i) { uint32_t w0 = q22_solutions_buf[block].get<0>(i); uint32_t w1 = q22_solutions_buf[block].get<1>(i); if (verify_Q21_Q26(block, i, 22, w0, w1)) ++q22ok; ++q22checked; if (i - q22_solutions_ctl_bu[block].read_idx > q22_solutions_ctl_bu[block].size) break; } cout << "Verified " << setw(10) << q22checked << " out of " << setw(10) << q22count << " Q22 solutions: " << q22ok << " OK" << endl; size_t q23checked = 0, q23ok = 0; uint32_t q23count = q23_solutions_ctl_bu[block].write_idx - q23_solutions_ctl_bu[block].read_idx; for (uint32_t i = q23_solutions_ctl_bu[block].read_idx; i != q23_solutions_ctl_bu[block].write_idx; ++i) { uint32_t w0 = q23_solutions_buf[block].get<0>(i); uint32_t w1 = q23_solutions_buf[block].get<1>(i); if (verify_Q21_Q26(block, i, 23, w0, w1)) ++q23ok; ++q23checked; if (i - q23_solutions_ctl_bu[block].read_idx > q23_solutions_ctl_bu[block].size) break; } cout << "Verified " << setw(10) << q23checked << " out of " << setw(10) << q23count << " Q23 solutions: " << q23ok << " OK" << endl; size_t q26checked = 0, q26ok = 0; uint32_t q26count = q26_solutions_ctl_bu[block].write_idx - q26_solutions_ctl_bu[block].read_idx; for (uint32_t i = q26_solutions_ctl_bu[block].read_idx; i != q26_solutions_ctl_bu[block].write_idx; ++i) { uint32_t w0 = q26_solutions_buf[block].get<0>(i); uint32_t w1 = q26_solutions_buf[block].get<1>(i); if (verify_Q21_Q26(block, i, 26, w0, w1)) ++q26ok; ++q26checked; if (i - q26_solutions_ctl_bu[block].read_idx > q26_solutions_ctl_bu[block].size) break; } cout << "Verified " << setw(10) << q26checked << " out of " << setw(10) << q26count << " Q26 solutions: " << q26ok << " OK" << endl; size_t q28checked = 0, q28ok = 0; uint32_t q28count = q28_solutions_ctl_bu[block].write_idx - q28_solutions_ctl_bu[block].read_idx; for (uint32_t i = q28_solutions_ctl_bu[block].read_idx; i != q28_solutions_ctl_bu[block].write_idx; ++i) { uint32_t w0 = q28_solutions_buf[block].get<0>(i); uint32_t w1 = q28_solutions_buf[block].get<1>(i); uint32_t w2 = q28_solutions_buf[block].get<2>(i); if (verify_Q27_Q30(block, i, 28, w0, w1, w2)) ++q28ok; ++q28checked; if (i - q28_solutions_ctl_bu[block].read_idx > q28_solutions_ctl_bu[block].size) break; } cout << "Verified " << setw(10) << q28checked << " out of " << setw(10) << q28count << " Q28 solutions: " << q28ok << " OK" << endl; size_t q30checked = 0, q30ok = 0; uint32_t q30count = q30_solutions_ctl_bu[block].write_idx - q30_solutions_ctl_bu[block].read_idx; for (uint32_t i = q30_solutions_ctl_bu[block].read_idx; i != q30_solutions_ctl_bu[block].write_idx; ++i) { uint32_t w0 = q30_solutions_buf[block].get<0>(i); uint32_t w1 = q30_solutions_buf[block].get<1>(i); uint32_t w2 = q30_solutions_buf[block].get<2>(i); if (verify_Q27_Q30(block, i, 30, w0, w1, w2)) ++q30ok; ++q30checked; if (i - q30_solutions_ctl_bu[block].read_idx > q30_solutions_ctl_bu[block].size) break; } cout << "Verified " << setw(10) << q30checked << " out of " << setw(10) << q30count << " Q30 solutions: " << q30ok << " OK" << endl; } } #endif // VERIFY_GPU_RESULTS
9008b5b45742761763ab8c88fd56d4313d8fe57f.cu
/***** Copyright (C) 2016 Pierre Karpman, INRIA France/Nanyang Technological University Singapore (-2016), CWI (2016/2017), L'Universite Grenoble Alpes (2017-) (C) 2016 Thomas Peyrin, Nanyang Technological University Singapore (C) 2016 Marc Stevens, Centrum Wiskunde & Informatica (CWI), Amsterdam. This file is part of sha1_gpu_nearcollisionattacks source-code and released under the MIT License *****/ /************ TODO TODO **********\ \************ TODO TODO *********/ //// main prepocessor flags // enables managed cyclic buffers and CPU verification of GPU results //#define DEBUG1 // disabling temporary buffer will force writes to directly go to main buffer #define DISABLE_TMP_BUF // enable performance counters //#define USE_PERF_COUNTERS // PERFORMANCE COUNTERS ARE NOW WORKING PROPERLY AND HAVE VERY SMALL OVERHEAD #ifndef DEBUG1 #define BLOCKS 26 #define THREADS_PER_BLOCK 512 #define DEBUG_BREAK #else #define BLOCKS 2 #define THREADS_PER_BLOCK 512 #define DEBUG_BREAK break; #endif #include "main.hpp" #include "neutral_bits_packing.hpp" #include "sha1detail.hpp" #include <cuda_cyclicbuffer.hpp> #include <timer.hpp> #include <cuda.h> #include <cuda_runtime.h> #include <map> #include <iostream> #include <fstream> #include <iomanip> #include <stdexcept> using namespace hashclash; using namespace std; #define CUDA_ASSERT(s) { cudaError_t err = s; if (err != cudaSuccess) { throw std::runtime_error("CUDA command returned: " + string(cudaGetErrorString(err)) + "!"); } } // set other defines based on main preprocessor flags #ifdef DEBUG1 #ifndef USE_MANAGED #define USE_MANAGED #endif #define VERIFY_GPU_RESULTS #endif // DEBUG1 #ifdef USE_MANAGED #define MANAGED __managed__ #else #define MANAGED #endif // DEFINE CYCLIC BUFFER TYPES // MASK VERSION // template<size_t N> struct cyclic_buffer_control_mask_t; // template<size_t N> struct cyclic_buffer_control_mask_readlock_t; // template<size_t N, typename val_t = uint32_t, size_t val_cnt = 1, typename control_type = cyclic_buffer_control_mask_t<N> > struct cyclic_buffer_mask_t; // CAS VERSION // template<size_t N> struct cyclic_buffer_control_cas_t; // template<size_t N, typename val_t = uint32_t, size_t val_cnt = 1, typename control_type = cyclic_buffer_control_cas_t<N> > struct cyclic_buffer_cas_t; // definition of cyclic buffer for 2^16 22-word elems: basesol: Q12,..,Q17,m5,...,m20 [uses CAS, as it's only written by the host] typedef cyclic_buffer_cas_t< BASESOLCOUNT, uint32_t, 22, cyclic_buffer_control_cas_t< BASESOLCOUNT > > buffer_basesol_t; typedef buffer_basesol_t::control_t control_basesol_t; // definition of cyclic buffer for 2^20 2-word elems typedef cyclic_buffer_mask_t< (1<<20), uint32_t, 2, cyclic_buffer_control_mask_t< (1<<20) >, 1 > buffer_20_2_t; // used for block-specific buffers: fencetype = block-wide typedef buffer_20_2_t::control_t control_20_2_t; typedef cyclic_buffer_cas_t< (1<<20), uint32_t, 2, cyclic_buffer_control_cas_t< (1<<20) >, 2 > gl_buffer_20_2_t; // used for global buffers: fencetype = gpu-wide typedef gl_buffer_20_2_t::control_t gl_control_20_2_t; // definition of cyclic buffer for 2^20 11-word elems: extbasesol: q15, q16, q17, m14, m15, m16, m17, m18, m19, m20, base_idx typedef cyclic_buffer_mask_t< (1<<20), uint32_t, 11, cyclic_buffer_control_mask_t< (1<<20) >, 1 > buffer_extbasesol20_t; // used for block-specific buffers: fencetype = block-wide typedef buffer_extbasesol20_t::control_t control_extbasesol20_t; // Marc: let's try steps 28-30 with 3 conditions total together and output extbasesol20+m17+m18+m19+booms typedef cyclic_buffer_mask_t< (1 << 20), uint32_t, 3, cyclic_buffer_control_mask_t< (1 << 20) >, 1 > buffer_30_3_t; // used for block-specific buffers: fencetype = block-wide typedef buffer_30_3_t::control_t control_30_3_t; // definition of cyclic buffer for 2^10 21-word elems: sol: Q36,..,Q40,m24,...,m39 // definition of cyclic buffer for 2^10 21-word elems: sol: Q56,..,Q60,m44,...,m59 typedef cyclic_buffer_cas_t< (1<<10), uint32_t, 21, cyclic_buffer_control_cas_t< (1<<10) >, 2 > buffer_sol_t; typedef buffer_sol_t::control_t control_sol_t; // WARP-SPECIFIC TEMPORARY BUFFER (2x 32 2-word elems) // Usage: (all warp-wide calls) // WARP_TMP_BUF.reset() // called once on kernel entrance // WARP_TMP_BUF.write1(bool,val1,buf,ctrl) // write 1-word elem to tmp buf, flush to mainbuf when one half of 32 is full // WARP_TMP_BUF.write2(bool,val1,val2,buf,ctrl) // write 2-word elem to tmp buf, flush to mainbuf when one half of 32 is full // WARP_TMP_BUF.flush1(buf,ctrl) // call once on function exit to move remaining 1-word elems to mainbuf // WARP_TMP_BUF.flush2(buf,ctrl) // call once on function exit to move remaining 2-word elems to mainbuf // #ifdef DISABLE_TMP_BUF class dummy_tmp_buf { public: inline __device__ void reset() {} template<typename buffer_t, typename control_t> inline __device__ void flush1(buffer_t& buf, control_t& ctrl) {} template<typename buffer_t, typename control_t> inline __device__ void flush2(buffer_t& buf, control_t& ctrl) {} template<typename buffer_t, typename control_t> inline __device__ void write1(bool dowrite, uint32_t val1, buffer_t& buf, control_t& ctrl) { buf.write(ctrl, dowrite, val1); } template<typename buffer_t, typename control_t> inline __device__ void write2(bool dowrite, uint32_t val1, uint32_t val2, buffer_t& buf, control_t& ctrl) { buf.write(ctrl, dowrite, val1, val2); } }; __shared__ dummy_tmp_buf dummytmpbuf; #define WARP_TMP_BUF dummytmpbuf #else __shared__ warp_tmp_buf_t warp_tmp_buf[THREADS_PER_BLOCK/32]; #define WARP_TMP_BUF warp_tmp_buf[threadIdx.x/32] #endif #define MANAGED2 __managed__ //#define MANAGED2 MANAGED // FIXME OLD /*** Main buffers declaration ***/ MANAGED __device__ buffer_basesol_t base_solutions_buf; __managed__ __device__ control_basesol_t base_solutions_ctl; // always managed to detect when it's empty #define BASESOLBUF base_solutions_buf #define BASESOLCTL base_solutions_ctl MANAGED __device__ gl_buffer_20_2_t q18_solutions_buf; __managed__ __device__ gl_control_20_2_t q18_solutions_ctl; #define Q18SOLBUF q18_solutions_buf #define Q18SOLCTL q18_solutions_ctl MANAGED __device__ gl_buffer_20_2_t q19_solutions_buf; __managed__ __device__ gl_control_20_2_t q19_solutions_ctl; #define Q19SOLBUF q19_solutions_buf #define Q19SOLCTL q19_solutions_ctl MANAGED __device__ buffer_extbasesol20_t q20_solutions_buf[BLOCKS]; __shared__ control_extbasesol20_t q20_solutions_ctl; MANAGED2 __device__ control_extbasesol20_t q20_solutions_ctl_bu [BLOCKS]; #define Q20SOLBUF q20_solutions_buf [blockIdx.x] #define Q20SOLCTL q20_solutions_ctl MANAGED __device__ buffer_20_2_t q21_solutions_buf[BLOCKS]; __shared__ control_20_2_t q21_solutions_ctl; MANAGED2 __device__ control_20_2_t q21_solutions_ctl_bu [BLOCKS]; #define Q21SOLBUF q21_solutions_buf [blockIdx.x] #define Q21SOLCTL q21_solutions_ctl MANAGED __device__ buffer_20_2_t q22_solutions_buf[BLOCKS]; __shared__ control_20_2_t q22_solutions_ctl; MANAGED2 __device__ control_20_2_t q22_solutions_ctl_bu [BLOCKS]; #define Q22SOLBUF q22_solutions_buf [blockIdx.x] #define Q22SOLCTL q22_solutions_ctl MANAGED __device__ buffer_20_2_t q23_solutions_buf [BLOCKS]; __shared__ control_20_2_t q23_solutions_ctl; MANAGED2 __device__ control_20_2_t q23_solutions_ctl_bu [BLOCKS]; #define Q23SOLBUF q23_solutions_buf [blockIdx.x] #define Q23SOLCTL q23_solutions_ctl MANAGED __device__ buffer_20_2_t q26_solutions_buf [BLOCKS]; __shared__ control_20_2_t q26_solutions_ctl; MANAGED2 __device__ control_20_2_t q26_solutions_ctl_bu [BLOCKS]; #define Q26SOLBUF q26_solutions_buf [blockIdx.x] #define Q26SOLCTL q26_solutions_ctl MANAGED __device__ buffer_30_3_t q28_solutions_buf[BLOCKS]; __shared__ control_30_3_t q28_solutions_ctl; MANAGED2 __device__ control_30_3_t q28_solutions_ctl_bu [BLOCKS]; #define Q28SOLBUF q28_solutions_buf [blockIdx.x] #define Q28SOLCTL q28_solutions_ctl MANAGED __device__ buffer_30_3_t q30_solutions_buf[BLOCKS]; __shared__ control_30_3_t q30_solutions_ctl; MANAGED2 __device__ control_30_3_t q30_solutions_ctl_bu [BLOCKS]; #define Q30SOLBUF q30_solutions_buf [blockIdx.x] #define Q30SOLCTL q30_solutions_ctl MANAGED __device__ buffer_sol_t q40_solutions_buf[BLOCKS]; __shared__ control_sol_t q40_solutions_ctl; MANAGED2 __device__ control_sol_t q40_solutions_ctl_bu [BLOCKS]; #define Q40SOLBUF q40_solutions_buf [blockIdx.x] #define Q40SOLCTL q40_solutions_ctl __managed__ __device__ buffer_sol_t collision_candidates_buf; __managed__ __device__ control_sol_t collision_candidates_ctl; #define COLLCANDIDATEBUF collision_candidates_buf #define COLLCANDIDATECTL collision_candidates_ctl /*** performance measure stuff ***/ #ifdef USE_PERF_COUNTERS __managed__ uint64_t main_performance_counter[BLOCKS][80]; __shared__ uint32_t tmp_performance_counter[80]; __device__ inline void performance_reset() { for (unsigned b = 0; b < BLOCKS; ++b) { for (unsigned i = 0; i < 80; ++i) { main_performance_counter[b][i] = 0; } } } __device__ inline void performance_backup() { if (threadIdx.x == 0) { for (unsigned i = 0; i < 80; ++i) { main_performance_counter[blockIdx.x][i] += tmp_performance_counter[i]; } } } __device__ inline void performance_restore() { if (threadIdx.x == 0) { for (unsigned i = 0; i < 80; ++i) { //main_performance_counter[blockIdx.x][i] // = tmp_performance_counter[i] = 0; } } } __device__ inline void performance_start_counter(unsigned i) { if ((threadIdx.x&31)==0) atomicAdd(&tmp_performance_counter[i], (uint32_t)(uint64_t(0)-clock64())); } __device__ inline void performance_stop_counter(unsigned i) { if ((threadIdx.x&31)==0) atomicAdd(&tmp_performance_counter[i], uint32_t(clock64())); } #define PERF_START_COUNTER(i) performance_start_counter(i); #define PERF_STOP_COUNTER(i) performance_stop_counter(i); void show_performance_counters() { uint64_t total = 0; for (unsigned b = 0; b < BLOCKS; ++b) { for (unsigned i = 0; i < 80; ++i) { total += main_performance_counter[b][i]; } } for (unsigned i = 0; i < 80; ++i) { uint64_t stepi = 0; for (unsigned b = 0; b < BLOCKS; ++b) { stepi += main_performance_counter[b][i]; } if (stepi > 0) { cout << "Perf.counter " << i << "\t : " << setprecision(4) << (100.0*double(stepi)/double(total)) << " \t " << stepi << endl; } } } #else #define PERF_START_COUNTER(i) #define PERF_STOP_COUNTER(i) #endif // USE_PERF_COUNTERS /*** Bit condition masks for steps Q-4 to Q80, stored on the device in constant memory ***/ // QOFF: value for Q_t is at index QOFF+t in tables below #define QOFF 4 namespace host { #include "tables.hpp" } namespace dev { #define TABLE_PREFIX __constant__ #include "tables.hpp" } /* *** SHA1 FUNCTIONS ********************************** */ __host__ __device__ inline uint32_t sha1_round1(const uint32_t a, const uint32_t b, const uint32_t c, const uint32_t d, const uint32_t e, const uint32_t m) { // a = rotate_left (a, 5); // c = rotate_left(c, 30); // d = rotate_left(d, 30); // e = rotate_left(e, 30); return rotate_left(a,5) + sha1_f1(b, rotate_left(c,30), rotate_left(d,30)) + rotate_left(e,30) + m + 0x5A827999; } __host__ __device__ inline uint32_t sha1_round2(const uint32_t a, const uint32_t b, const uint32_t c, const uint32_t d, const uint32_t e, const uint32_t m) //__host__ __device__ inline uint32_t sha1_round2(uint32_t a, uint32_t b, uint32_t c, uint32_t d, uint32_t e, uint32_t m) { // a = rotate_left (a, 5); // c = rotate_left(c, 30); // d = rotate_left(d, 30); // e = rotate_left(e, 30); // return a + sha1_f2(b, c, d) + e + m + 0x6ED9EBA1; return rotate_left(a,5) + sha1_f2(b, rotate_left(c,30), rotate_left(d,30)) + rotate_left(e,30) + m + 0x6ED9EBA1; } __host__ __device__ inline uint32_t sha1_round3(const uint32_t a, const uint32_t b, const uint32_t c, const uint32_t d, const uint32_t e, const uint32_t m) { // a = rotate_left (a, 5); // c = rotate_left(c, 30); // d = rotate_left(d, 30); // e = rotate_left(e, 30); return rotate_left(a,5) + sha1_f3(b, rotate_left(c,30), rotate_left(d,30)) + rotate_left(e,30) + m + 0x8F1BBCDC; // return a + sha1_f3(b, c, d) + e + m + 0x8F1BBCDC; } __host__ __device__ inline uint32_t sha1_mess(uint32_t m_3, uint32_t m_8, uint32_t m_14, uint32_t m_16) { return rotate_left(m_3 ^ m_8 ^ m_14 ^ m_16, 1); } #define NEXT_NB(a,mask) { (a) -= 1; (a) &= mask;} __device__ void stepQ18(uint32_t base_idx) { PERF_START_COUNTER(18); using namespace dev; /// fetch the base solution uint32_t q12 = BASESOLBUF.get<0>(base_idx); uint32_t q13 = BASESOLBUF.get<1>(base_idx); uint32_t q14 = BASESOLBUF.get<2>(base_idx); uint32_t q15 = BASESOLBUF.get<3>(base_idx); uint32_t q16 = BASESOLBUF.get<4>(base_idx); uint32_t q17 = BASESOLBUF.get<5>(base_idx); uint32_t m14 = BASESOLBUF.get<15>(base_idx); uint32_t m15 = BASESOLBUF.get<16>(base_idx); uint32_t m16 = BASESOLBUF.get<17>(base_idx); uint32_t m17 = BASESOLBUF.get<18>(base_idx); uint32_t oldq16 = q16; uint32_t w14_q18_nb = 0; for (unsigned l = 0; l < (1<<4); ++l) { NEXT_NB(w14_q18_nb, W14NBQ18M); m14 &= ~W14NBQ18M; m14 |= w14_q18_nb; q15 += w14_q18_nb; q16 += rotate_left(w14_q18_nb, 5); uint32_t w15_q18_nb = 0; for (unsigned k = 0; k < (1<<4); ++k) { NEXT_NB(w15_q18_nb, W15NBQ18M); m15 &= ~W15NBQ18M; m15 |= w15_q18_nb; q16 += w15_q18_nb; bool valid_sol = (0 == ((oldq16 ^ q16) & Qcondmask[QOFF + 16])); uint32_t newq17 = sha1_round1(q16, q15, q14, q13, q12, m16); valid_sol &= 0 == ((newq17 ^ q17) & Qcondmask[QOFF + 17]); uint32_t newq18 = sha1_round1(newq17, q16, q15, q14, q13, m17); uint32_t q18nessies = Qset1mask[QOFF + 18] ^ (Qprevmask[QOFF + 18] & newq17) // ^ (Qprevrmask [QOFF + 18] & rotate_left(newq17, 30)) // ^ (Qprev2rmask[QOFF + 18] & rotate_left(newq16, 30)) ; valid_sol &= 0 == ((newq18 ^ q18nessies) & Qcondmask[QOFF + 18]); uint32_t sol_val_0 = pack_q18q20_sol0(base_idx, m14, m15); uint32_t sol_val_1 = pack_q18q20_sol1(base_idx, m14, m15); WARP_TMP_BUF.write2(valid_sol, sol_val_0, sol_val_1, Q18SOLBUF, Q18SOLCTL); q16 -= w15_q18_nb; } q16 -= rotate_left(w14_q18_nb, 5); q15 -= w14_q18_nb; } WARP_TMP_BUF.flush2(Q18SOLBUF, Q18SOLCTL); PERF_STOP_COUNTER(18); } __device__ void stepQ19(uint32_t thread_rd_idx) { PERF_START_COUNTER(19); using namespace dev; uint32_t q18_sol0 = Q18SOLBUF.get<0>(thread_rd_idx); uint32_t q18_sol1 = Q18SOLBUF.get<1>(thread_rd_idx); uint32_t base_idx = unpack_idx(q18_sol0, q18_sol1); uint32_t w14_sol_nb = unpack_w14_nbs(q18_sol0, q18_sol1); uint32_t w15_sol_nb = unpack_w15_nbs(q18_sol0, q18_sol1); /// fetch the base solution and update it to the Q18 solution using the above neutral bits uint32_t q12 = BASESOLBUF.get<0>(base_idx); uint32_t q13 = BASESOLBUF.get<1>(base_idx); uint32_t q14 = BASESOLBUF.get<2>(base_idx); uint32_t q15 = BASESOLBUF.get<3>(base_idx); uint32_t q16 = BASESOLBUF.get<4>(base_idx); uint32_t m14 = BASESOLBUF.get<15>(base_idx); uint32_t m15 = BASESOLBUF.get<16>(base_idx); uint32_t m16 = BASESOLBUF.get<17>(base_idx); uint32_t m17 = BASESOLBUF.get<18>(base_idx); uint32_t m18 = BASESOLBUF.get<19>(base_idx); m14 |= w14_sol_nb; m15 |= w15_sol_nb; q15 += w14_sol_nb; q16 += w15_sol_nb + rotate_left(w14_sol_nb, 5); uint32_t oldq17 = sha1_round1(q16, q15, q14, q13, q12, m16); uint32_t oldq18 = sha1_round1(oldq17, q16, q15, q14, q13, m17); q16 -= rotate_left(q15, 5); uint32_t w14_q19_nb = 0; for (unsigned j = 0; j < (1<<2); ++j) { NEXT_NB(w14_q19_nb, W14NBQ19M); // start to recompute the previous state m14 &= ~W14NBQ19M; m14 |= w14_q19_nb; q15 += w14_q19_nb; q16 += rotate_left(q15, 5); uint32_t w15_q19_nb = 0; for (unsigned i = 0; i < (1<<5); ++i) { NEXT_NB(w15_q19_nb, W15NBQ19M); m15 &= ~W15NBQ19M; m15 |= w15_q19_nb; q16 += w15_q19_nb; uint32_t w16_q19_nb = 0; for (unsigned l = 0; l < (1<<5); ++l) { NEXT_NB(w16_q19_nb, W16NBQ19M); m16 &= ~W16NBQ19M; m16 |= w16_q19_nb; uint32_t q17 = sha1_round1(q16, q15, q14, q13, q12, m16); uint32_t q18 = sha1_round1(q17, q16, q15, q14, q13, m17); uint32_t q19 = sha1_round1(q18, q17, q16, q15, q14, m18); bool valid_sol = (0 == ((oldq17 ^ q17) & Qcondmask[QOFF + 17])); valid_sol &= 0 == ((oldq18 ^ q18) & Qcondmask[QOFF+18]); uint32_t q19nessies = Qset1mask[QOFF + 19] ^ (Qprevmask [QOFF + 19] & q18) ^ (Qprevrmask [QOFF + 19] & rotate_left(q18, 30)) ^ (Qprev2rmask[QOFF + 19] & rotate_left(q17, 30)) ; valid_sol &= 0 == ((q19 ^ q19nessies) & Qcondmask[QOFF + 19]); uint32_t sol_val_0 = pack_q18q20_sol0(base_idx, m14, m15, m16); uint32_t sol_val_1 = pack_q18q20_sol1(base_idx, m14, m15, m16); WARP_TMP_BUF.write2(valid_sol, sol_val_0, sol_val_1, Q19SOLBUF, Q19SOLCTL); } q16 -= w15_q19_nb; } q16 -= rotate_left(q15, 5); q15 -= w14_q19_nb; } WARP_TMP_BUF.flush2(Q19SOLBUF, Q19SOLCTL); PERF_STOP_COUNTER(19); } __device__ void stepQ20(uint32_t thread_rd_idx) { PERF_START_COUNTER(20); using namespace dev; uint32_t q19_sol0 = Q19SOLBUF.get<0>(thread_rd_idx); uint32_t q19_sol1 = Q19SOLBUF.get<1>(thread_rd_idx); uint32_t base_idx = unpack_idx(q19_sol0, q19_sol1); uint32_t w14_sol_nb = unpack_w14_nbs(q19_sol0, q19_sol1); uint32_t w15_sol_nb = unpack_w15_nbs(q19_sol0, q19_sol1); uint32_t w16_sol_nb = unpack_w16_nbs(q19_sol0, q19_sol1); /// fetch the base solution and update it to the Q18 solution using the above neutral bits uint32_t q12 = BASESOLBUF.get<0>(base_idx); uint32_t q13 = BASESOLBUF.get<1>(base_idx); uint32_t q14 = BASESOLBUF.get<2>(base_idx); uint32_t q15 = BASESOLBUF.get<3>(base_idx); uint32_t q16 = BASESOLBUF.get<4>(base_idx); uint32_t m14 = BASESOLBUF.get<15>(base_idx); uint32_t m15 = BASESOLBUF.get<16>(base_idx); uint32_t m16 = BASESOLBUF.get<17>(base_idx); uint32_t m17 = BASESOLBUF.get<18>(base_idx); uint32_t m18 = BASESOLBUF.get<19>(base_idx); uint32_t m19 = BASESOLBUF.get<20>(base_idx); uint32_t m20 = BASESOLBUF.get<21>(base_idx); m14 |= w14_sol_nb; m15 |= w15_sol_nb; m16 |= w16_sol_nb; q15 += w14_sol_nb; q16 += w15_sol_nb + rotate_left(w14_sol_nb, 5); uint32_t oldq17 = sha1_round1(q16, q15, q14, q13, q12, m16); uint32_t oldq18 = sha1_round1(oldq17, q16, q15, q14, q13, m17); uint32_t oldq19 = sha1_round1(oldq18, oldq17, q16, q15, q14, m18); q16 -= m15; uint32_t w15_q20_nb = 0; for (unsigned i = 0; i < (1<<2); ++i) { NEXT_NB(w15_q20_nb, W15NBQ20M); m15 &= ~W15NBQ20M; m15 |= w15_q20_nb; q16 += m15; uint32_t w16_q20_nb = 0; for (unsigned l = 0; l < (1<<4); ++l) { NEXT_NB(w16_q20_nb, W16NBQ20M); m16 &= ~W16NBQ20M; m16 |= w16_q20_nb; uint32_t q17 = sha1_round1(q16, q15, q14, q13, q12, m16); uint32_t w17_q20_nb = 0; for (unsigned m = 0; m < (1<<6); ++m) { NEXT_NB(w17_q20_nb, W17NBQ20M); m17 &= ~W17NBQ20M; m17 |= w17_q20_nb; //w18[5]: W15[4] uint32_t m18fb = (((m15 >> 4)) & 1) << 5; //w19[13]: W15[15] W15[16] W17[14] W17[16] W17[19] uint32_t m19fb = ((0 ^ (m15 >> 15) ^ (m15 >> 16) ^ (m17 >> 14) ^ (m17 >> 16) ^ (m17 >> 19)) & 1) << 13; //w19[15] : W14[10] W15[12] W15[13] W16[13] W16[14] W16[15] W17[11] W17[13] W17[16] W17[18] W18[12] W19[10] m19fb ^= ((0 ^ (m14 >> 10) ^ (m15 >> 12) ^ (m15 >> 13) ^ (m16 >> 13) ^ (m16 >> 14) ^ (m16 >> 15) ^ (m17 >> 11) ^ (m17 >> 13) ^ (m17 >> 16) ^ (m17 >> 18) ^ (m18 >> 12) ^ (m19 >> 10)) & 1) << 15; //w19[16] : W17[17] W17[19] m19fb ^= ((0 ^ (m17 >> 17) ^ (m17 >> 19)) & 1) << 16; //w19[17] : W16[16] W17[18] W17[19] W18[15] m19fb ^= ((0 ^ (m16 >> 16) ^ (m17 >> 18) ^ (m17 >> 19) ^ (m18 >> 15)) & 1) << 17; //w19[18] : W17[19] m19fb ^= ((0 ^ (m17 >> 19)) & 1) << 18; //w20[0] : W16[16] W17[19] W18[15] uint32_t m20fb = 0; m20fb ^= ((0 ^ (m16 >> 16) ^ (m17 >> 19) ^ (m18 >> 15)) & 1) << 0; //w20[14] : W15[14] W15[16] W17[18] W17[19] m20fb ^= ((0 ^ (m15 >> 14) ^ (m15 >> 16) ^ (m17 >> 18) ^ (m17 >> 19)) & 1) << 14; //w20[16] : W15[16] m20fb ^= ((0 ^ (m15 >> 16)) & 1) << 16; //w20[17] : W15[16] W16[13] W16[15] W17[16] W18[12] m20fb ^= ((0 ^ (m15 >> 16) ^ (m16 >> 13) ^ (m16 >> 15) ^ (m17 >> 16) ^ (m18 >> 12)) & 1) << 17; m18 ^= m18fb; m19 ^= m19fb; m20 ^= m20fb; uint32_t q18 = sha1_round1(q17, q16, q15, q14, q13, m17); uint32_t q19 = sha1_round1(q18, q17, q16, q15, q14, m18); uint32_t q20 = sha1_round1(q19, q18, q17, q16, q15, m19); bool valid_sol = (0 == ((oldq17 ^ q17) & Qcondmask[QOFF + 17])); valid_sol &= 0 == ((oldq18 ^ q18) & Qcondmask[QOFF+18]); valid_sol &= 0 == ((oldq19 ^ q19) & Qcondmask[QOFF+19]); uint32_t q20nessies = Qset1mask[QOFF + 20] ^ (Qprevmask [QOFF + 20] & q19) ^ (Qprevrmask [QOFF + 20] & rotate_left(q19, 30)) ^ (Qprev2rmask[QOFF + 20] & rotate_left(q18, 30)) ; valid_sol &= 0 == ((q20 ^ q20nessies) & Qcondmask[QOFF + 20]); Q20SOLBUF.write(Q20SOLCTL, valid_sol, q15, q16, q17, m14, m15, m16, m17, m18, m19, m20, base_idx); m18 ^= m18fb; m19 ^= m19fb; m20 ^= m20fb; } } q16 -= m15; } PERF_STOP_COUNTER(20); } __device__ void stepQ21(uint32_t thread_rd_idx) { PERF_START_COUNTER(21); using namespace dev; const uint32_t basesolidx = Q20SOLBUF.get<10>(thread_rd_idx); uint32_t q13 = BASESOLBUF.get<1>(basesolidx); uint32_t q14 = BASESOLBUF.get<2>(basesolidx); uint32_t q15 = Q20SOLBUF.get<0>(thread_rd_idx); uint32_t q16 = Q20SOLBUF.get<1>(thread_rd_idx); uint32_t q17 = Q20SOLBUF.get<2>(thread_rd_idx); uint32_t m17 = Q20SOLBUF.get<6>(thread_rd_idx); uint32_t m18 = Q20SOLBUF.get<7>(thread_rd_idx); uint32_t m19 = Q20SOLBUF.get<8>(thread_rd_idx); uint32_t m20 = Q20SOLBUF.get<9>(thread_rd_idx); uint32_t q18 = sha1_round1(q17, q16, q15, q14, q13, m17); uint32_t oldq19 = sha1_round1(q18, q17, q16, q15, q14, m18); uint32_t oldq20 = sha1_round1(oldq19, q18, q17, q16, q15, m19); q18 -= m17; uint32_t w17_q21_nb = 0; for (unsigned k = 0; k < (1<<4); ++k) { NEXT_NB(w17_q21_nb, W17NBQ21M); m17 &= ~W17NBQ21M; m17 |= w17_q21_nb; q18 += m17; uint32_t w18_q21_nb = 0; for (unsigned l = 0; l < (1<<1); ++l) { NEXT_NB(w18_q21_nb, W18NBQ21M); m18 &= ~W18NBQ21M; m18 |= w18_q21_nb; uint32_t m19fb = (((m17<<4)^(m17<<2))&(1<<15)) ^ ((m18<<2)&(1<<17)); uint32_t m20fb = (m18>>15)&(1<<0); m19 ^= m19fb; m20 ^= m20fb; uint32_t q19 = sha1_round1(q18, q17, q16, q15, q14, m18); uint32_t q20 = sha1_round1(q19, q18, q17, q16, q15, m19); uint32_t q21 = sha1_round2(q20, q19, q18, q17, q16, m20); const uint32_t q21nessies = Qset1mask[QOFF+21] // ^ (Qprevmask [QOFF + 21] & q20) ^ (Qprevrmask [QOFF + 21] & rotate_left(q20, 30)) // ^ (Qprev2rmask [QOFF + 21] & rotate_left(q19, 30)) ; bool valid_sol = 0 == ((q21 ^ q21nessies) & Qcondmask[QOFF + 21]); valid_sol &= 0 == ((oldq20 ^ q20) & Qcondmask[QOFF+20]); valid_sol &= 0 == ((oldq19 ^ q19) & Qcondmask[QOFF+19]); uint32_t sol_val_0 = pack_q21q25_sol0(thread_rd_idx, m17, m18, m19, m20); uint32_t sol_val_1 = pack_q21q25_sol1(thread_rd_idx, m17, m18, m19, m20); WARP_TMP_BUF.write2(valid_sol, sol_val_0, sol_val_1, Q21SOLBUF, Q21SOLCTL); m19 ^= m19fb; m20 ^= m20fb; } q18 -= m17; } PERF_STOP_COUNTER(21); } __device__ void stepQ22(uint32_t thread_rd_idx) { PERF_START_COUNTER(22); using namespace dev; uint32_t q21_sol0 = Q21SOLBUF.get<0>(thread_rd_idx); uint32_t q21_sol1 = Q21SOLBUF.get<1>(thread_rd_idx); const uint32_t extsolidx = unpack_idx(q21_sol0,q21_sol1); const uint32_t basesolidx = Q20SOLBUF.get<10>(extsolidx); uint32_t q13 = BASESOLBUF.get<1>(basesolidx); uint32_t q14 = BASESOLBUF.get<2>(basesolidx); uint32_t q15 = Q20SOLBUF.get<0>(extsolidx); uint32_t q16 = Q20SOLBUF.get<1>(extsolidx); uint32_t q17 = Q20SOLBUF.get<2>(extsolidx); uint32_t m13 = BASESOLBUF.get<14>(basesolidx); uint32_t m7 = BASESOLBUF.get<8>(basesolidx); uint32_t m5 = BASESOLBUF.get<6>(basesolidx); uint32_t m17 = Q20SOLBUF.get<6>(extsolidx); uint32_t m18 = Q20SOLBUF.get<7>(extsolidx); uint32_t m19 = Q20SOLBUF.get<8>(extsolidx); uint32_t m20 = Q20SOLBUF.get<9>(extsolidx); m17 ^= unpack_w17ext_nbs(q21_sol0,q21_sol1); m18 ^= unpack_w18_nbs(q21_sol0,q21_sol1); m19 &= ~W19NBPACKM; m19 ^= unpack_w19_nbs_fb(q21_sol0,q21_sol1); m20 &= ~W20NBPACKM; m20 ^= unpack_w20_nbs_fb(q21_sol0,q21_sol1); uint32_t q18 = sha1_round1(q17, q16, q15, q14, q13, m17); uint32_t q19 = sha1_round1(q18, q17, q16, q15, q14, m18); uint32_t oldq20 = sha1_round1(q19, q18, q17, q16, q15, m19); // uint32_t oldq21 = sha1_round2(oldq20, q19, q18, q17, q16, m20); q19 -= m18; uint32_t m21precomp = m13 ^ m7 ^ m5; uint32_t q20precomp = sha1_round1(0, q18, q17, q16, q15, 0); uint32_t w18_q22_nb = 0; for (unsigned k = 0; k < (1<<6); k++) { NEXT_NB(w18_q22_nb, W18NBQ22M); m18 &= ~W18NBQ22M; m18 |= w18_q22_nb; q19 += m18; uint32_t m21 = rotate_left(m18 ^ m21precomp,1); uint32_t m19fb = ((m18<<3) /*^(m19<<5)*/) & (1<<15); uint32_t m20fb = (m18<<5) & (1<<17); m19 ^= m19fb; m20 ^= m20fb; uint32_t w19_q22_nb = 0; for (unsigned l = 0; l < (1<<2); l++) { NEXT_NB(w19_q22_nb, W19NBQ22M); m19 &= ~W19NBQ22M; m19 |= w19_q22_nb; m19 ^= (m19<<5) & (1<<15); uint32_t q20 = q20precomp + rotate_left(q19,5) + m19; //sha1_round1(q19, q18, q17, q16, q15, m19); uint32_t q21 = sha1_round2(q20, q19, q18, q17, q16, m20); uint32_t q22 = sha1_round2(q21, q20, q19, q18, q17, m21); bool valid_sol = 0 == ((oldq20 ^ q20) & Qcondmask[QOFF+20]); const uint32_t q21nessies = Qset1mask[QOFF+21] // ^ (Qprevmask [QOFF + 21] & newq20) ^ (Qprevrmask [QOFF + 21] & rotate_left(q20, 30)) // ^ (Qprev2rmask [QOFF + 21] & rotate_left(q19, 30)) ; valid_sol &= 0 == ((q21 ^ q21nessies) & Qcondmask[QOFF + 21]); const uint32_t q22nessies = Qset1mask[QOFF+22] ^ (Qprevmask [QOFF + 22] & q21) // ^ (Qprevrmask [QOFF + 22] & rotate_left(q21, 30)) ^ (Qprev2rmask [QOFF + 22] & rotate_left(q20, 30)) ; valid_sol &= 0 == ((q22 ^ q22nessies) & Qcondmask[QOFF + 22]); uint32_t sol_val_0 = pack_q21q25_sol0(extsolidx, m17, m18, m19, m20); uint32_t sol_val_1 = pack_q21q25_sol1(extsolidx, m17, m18, m19, m20); WARP_TMP_BUF.write2(valid_sol, sol_val_0, sol_val_1, Q22SOLBUF, Q22SOLCTL); m19 ^= (m19<<5) & (1<<15); } m19 ^= m19fb; m20 ^= m20fb; q19 -= m18; } PERF_STOP_COUNTER(22); } __device__ void stepQ23(uint32_t thread_rd_idx) { PERF_START_COUNTER(23); using namespace dev; uint32_t q22_sol0 = Q22SOLBUF.get<0>(thread_rd_idx); uint32_t q22_sol1 = Q22SOLBUF.get<1>(thread_rd_idx); const uint32_t extsolidx = unpack_idx(q22_sol0,q22_sol1); const uint32_t basesolidx = Q20SOLBUF.get<10>(extsolidx); uint32_t q13 = BASESOLBUF.get<1>(basesolidx); uint32_t q14 = BASESOLBUF.get<2>(basesolidx); uint32_t q15 = Q20SOLBUF.get<0>(extsolidx); uint32_t q16 = Q20SOLBUF.get<1>(extsolidx); uint32_t q17 = Q20SOLBUF.get<2>(extsolidx); uint32_t m5 = BASESOLBUF.get<6>(basesolidx); uint32_t m6 = BASESOLBUF.get<7>(basesolidx); uint32_t m7 = BASESOLBUF.get<8>(basesolidx); uint32_t m8 = BASESOLBUF.get<9>(basesolidx); uint32_t m13 = BASESOLBUF.get<14>(basesolidx); uint32_t m14 = Q20SOLBUF.get<3>(extsolidx); uint32_t m17 = Q20SOLBUF.get<6>(extsolidx); uint32_t m18 = Q20SOLBUF.get<7>(extsolidx); uint32_t m19 = Q20SOLBUF.get<8>(extsolidx); uint32_t m20 = Q20SOLBUF.get<9>(extsolidx); m17 ^= unpack_w17ext_nbs(q22_sol0,q22_sol1); m18 ^= unpack_w18_nbs(q22_sol0,q22_sol1); m19 &= ~W19NBPACKM; m19 ^= unpack_w19_nbs_fb(q22_sol0,q22_sol1); m20 &= ~W20NBPACKM; m20 ^= unpack_w20_nbs_fb(q22_sol0,q22_sol1); uint32_t q18 = sha1_round1(q17, q16, q15, q14, q13, m17); uint32_t q19 = sha1_round1(q18, q17, q16, q15, q14, m18); uint32_t oldq20 = sha1_round1(q19, q18, q17, q16, q15, m19); q19 -= m18; uint32_t m21precomp = m13 ^ m7 ^ m5; uint32_t m22precomp = m14 ^ m8 ^ m6; uint32_t q20precomp = sha1_round1(0, q18, q17, q16, q15, 0); uint32_t w18_q23_nb = 0; for (unsigned k = 0; k < (1<<4); k++) { NEXT_NB(w18_q23_nb, W18NBQ23M); m18 &= ~W18NBQ23M; m18 |= w18_q23_nb; q19 += m18; uint32_t m21 = rotate_left(m18 ^ m21precomp,1); uint32_t w19_q23_nb = 0; for (unsigned l = 0; l < (1<<3); l++) { NEXT_NB(w19_q23_nb, W19NBQ23M); m19 &= ~W19NBQ23M; m19 |= w19_q23_nb; uint32_t m22 = rotate_left(m19 ^ m22precomp,1); uint32_t q20 = q20precomp + rotate_left(q19,5) + m19; //sha1_round1(q19, q18, q17, q16, q15, m19); uint32_t w20_q23_nb = 0; for (unsigned m = 0; m < (1<<1); m++) { NEXT_NB(w20_q23_nb, W20NBQ23M); m20 &= ~W20NBQ23M; m20 |= w20_q23_nb; uint32_t q21 = sha1_round2(q20, q19, q18, q17, q16, m20); uint32_t q22 = sha1_round2(q21, q20, q19, q18, q17, m21); uint32_t q23 = sha1_round2(q22, q21, q20, q19, q18, m22); bool valid_sol = 0 == ((oldq20 ^ q20) & Qcondmask[QOFF+20]); const uint32_t q21nessies = Qset1mask[QOFF+21] // ^ (Qprevmask [QOFF + 21] & newq20) ^ (Qprevrmask [QOFF + 21] & rotate_left(q20, 30)) // ^ (Qprev2rmask [QOFF + 21] & rotate_left(q19, 30)) ; valid_sol &= 0 == ((q21 ^ q21nessies) & Qcondmask[QOFF + 21]); const uint32_t q22nessies = Qset1mask[QOFF+22] ^ (Qprevmask [QOFF + 22] & q21) // ^ (Qprevrmask [QOFF + 22] & rotate_left(q21, 30)) ^ (Qprev2rmask [QOFF + 22] & rotate_left(q20, 30)) ; valid_sol &= 0 == ((q22 ^ q22nessies) & Qcondmask[QOFF + 22]); const uint32_t q23nessies = Qset1mask[QOFF+23] // ^ (Qprevmask [QOFF + 23] & q22) ^ (Qprevrmask [QOFF + 23] & rotate_left(q22, 30)) // ^ (Qprev2rmask [QOFF + 23] & rotate_left(q21, 30)) ; valid_sol &= 0 == ((q23 ^ q23nessies) & Qcondmask[QOFF + 23]); uint32_t sol_val_0 = pack_q21q25_sol0(extsolidx, m17, m18, m19, m20); uint32_t sol_val_1 = pack_q21q25_sol1(extsolidx, m17, m18, m19, m20); WARP_TMP_BUF.write2(valid_sol, sol_val_0, sol_val_1, Q23SOLBUF, Q23SOLCTL); } } q19 -= m18; } PERF_STOP_COUNTER(23); } __device__ void stepQ2456(uint32_t thread_rd_idx) { PERF_START_COUNTER(24); using namespace dev; uint32_t q23_sol0 = Q23SOLBUF.get<0>(thread_rd_idx); uint32_t q23_sol1 = Q23SOLBUF.get<1>(thread_rd_idx); const uint32_t extsolidx = unpack_idx(q23_sol0,q23_sol1); const uint32_t basesolidx = Q20SOLBUF.get<10>(extsolidx); uint32_t q13 = BASESOLBUF.get<1>(basesolidx); uint32_t q14 = BASESOLBUF.get<2>(basesolidx); uint32_t q15 = Q20SOLBUF.get<0>(extsolidx); uint32_t q16 = Q20SOLBUF.get<1>(extsolidx); uint32_t q17 = Q20SOLBUF.get<2>(extsolidx); uint32_t m5 = BASESOLBUF.get<6>(basesolidx); uint32_t m6 = BASESOLBUF.get<7>(basesolidx); uint32_t m7 = BASESOLBUF.get<8>(basesolidx); uint32_t m8 = BASESOLBUF.get<9>(basesolidx); uint32_t m9 = BASESOLBUF.get<10>(basesolidx); uint32_t m10 = BASESOLBUF.get<11>(basesolidx); uint32_t m11 = BASESOLBUF.get<12>(basesolidx); uint32_t m13 = BASESOLBUF.get<14>(basesolidx); uint32_t m14 = Q20SOLBUF.get<3>(extsolidx); uint32_t m15 = Q20SOLBUF.get<4>(extsolidx); uint32_t m16 = Q20SOLBUF.get<5>(extsolidx); uint32_t m17 = Q20SOLBUF.get<6>(extsolidx); uint32_t m18 = Q20SOLBUF.get<7>(extsolidx); uint32_t m19 = Q20SOLBUF.get<8>(extsolidx); uint32_t m20 = Q20SOLBUF.get<9>(extsolidx); m17 ^= unpack_w17ext_nbs(q23_sol0,q23_sol1); m18 ^= unpack_w18_nbs(q23_sol0,q23_sol1); m19 &= ~W19NBPACKM; m19 ^= unpack_w19_nbs_fb(q23_sol0,q23_sol1); m20 &= ~W20NBPACKM; m20 ^= unpack_w20_nbs_fb(q23_sol0,q23_sol1); uint32_t m21 = rotate_left(m18 ^ m13 ^ m7 ^ m5,1); uint32_t m24 = rotate_left(m21 ^ m16 ^ m10 ^ m8,1); uint32_t q18 = sha1_round1(q17, q16, q15, q14, q13, m17); uint32_t q19 = sha1_round1(q18, q17, q16, q15, q14, m18); uint32_t q20 = sha1_round1(q19, q18, q17, q16, q15, 0); uint32_t q21precomp = sha1_round2(0, q19, q18, q17, q16, 0); uint32_t m22precomp = m14 ^ m8 ^ m6; uint32_t m23precomp = m15 ^ m9 ^ m7; uint32_t m25precomp = m17 ^ m11 ^ m9; uint32_t w19_q24_nb = 0; for (unsigned l = 0; l < (1<<3); l++) { NEXT_NB(w19_q24_nb, W19NBQ24M); m19 &= ~W19NBQ24M; m19 |= w19_q24_nb; q20 += m19; uint32_t m22 = rotate_left(m19 ^ m22precomp,1); uint32_t m25 = rotate_left(m22 ^ m25precomp,1); uint32_t w20_q24_nb = 0; #define W20NBQ2425M (W20NBQ24M|W20NBQ25M) for (unsigned m = 0; m < (1<<4); m++) { NEXT_NB(w20_q24_nb, W20NBQ2425M); m20 &= ~W20NBQ2425M; m20 |= w20_q24_nb; uint32_t m23 = rotate_left(m20 ^ m23precomp,1); uint32_t q21 = q21precomp + rotate_left(q20,5) + m20; uint32_t q22 = sha1_round2(q21, q20, q19, q18, q17, m21); uint32_t q23 = sha1_round2(q22, q21, q20, q19, q18, m22); uint32_t q24 = sha1_round2(q23, q22, q21, q20, q19, m23); const uint32_t q22nessies = Qset1mask[QOFF+22] ^ (Qprevmask [QOFF + 22] & q21) // ^ (Qprevrmask [QOFF + 22] & rotate_left(q21, 30)) ^ (Qprev2rmask [QOFF + 22] & rotate_left(q20, 30)) ; bool valid_sol = 0 == ((q22 ^ q22nessies) & Qcondmask[QOFF + 22]); const uint32_t q23nessies = Qset1mask[QOFF+23] // ^ (Qprevmask [QOFF + 23] & q22) ^ (Qprevrmask [QOFF + 23] & rotate_left(q22, 30)) // ^ (Qprev2rmask [QOFF + 23] & rotate_left(q21, 30)) ; valid_sol &= 0 == ((q23 ^ q23nessies) & Qcondmask[QOFF + 23]); const uint32_t q24nessies = Qset1mask[QOFF+24] // ^ (Qprevmask [QOFF + 24] & q23) ^ (Qprevrmask [QOFF + 24] & rotate_left(q23, 30)) ^ (Qprev2rmask [QOFF + 24] & rotate_left(q22, 30)) ; valid_sol &= 0 == ((q24 ^ q24nessies) & Qcondmask[QOFF + 24]); uint32_t q25 = sha1_round2(q24, q23, q22, q21, q20, m24); const uint32_t q25nessies = Qset1mask[QOFF+25] // ^ (Qprevmask [QOFF + 25] & q24) ^ (Qprevrmask [QOFF + 25] & rotate_left(q24, 30)) // ^ (Qprev2rmask [QOFF + 25] & rotate_left(q23, 30)) ; valid_sol &= 0 == ((q25 ^ q25nessies) & Qcondmask[QOFF + 25]); // if (valid_sol) // { uint32_t q26 = sha1_round2(q25, q24, q23, q22, q21, m25); const uint32_t q26nessies = Qset1mask[QOFF+26] // ^ (Qprevmask [QOFF + 26] & q25) // ^ (Qprevrmask [QOFF + 26] & rotate_left(q25, 30)) ^ (Qprev2rmask [QOFF + 26] & rotate_left(q24, 30)) ; valid_sol &= 0 == ((q26 ^ q26nessies) & Qcondmask[QOFF + 26]); // } uint32_t sol_val_0 = pack_q21q25_sol0(extsolidx, m17, m18, m19, m20); uint32_t sol_val_1 = pack_q21q25_sol1(extsolidx, m17, m18, m19, m20); WARP_TMP_BUF.write2(valid_sol, sol_val_0, sol_val_1, Q26SOLBUF, Q26SOLCTL); } q20 -= m19; } PERF_STOP_COUNTER(24); } __device__ void stepQ2728(uint32_t thread_rd_idx) { PERF_START_COUNTER(27); using namespace dev; const uint32_t q26_sol0 = Q26SOLBUF.get<0>(thread_rd_idx); const uint32_t q26_sol1 = Q26SOLBUF.get<1>(thread_rd_idx); const uint32_t extsolidx = unpack_idx(q26_sol0,q26_sol1); const uint32_t basesolidx = Q20SOLBUF.get<10>(extsolidx); uint32_t m17 = Q20SOLBUF.get<6>(extsolidx); uint32_t m18 = Q20SOLBUF.get<7>(extsolidx); uint32_t m19 = Q20SOLBUF.get<8>(extsolidx); uint32_t m20 = Q20SOLBUF.get<9>(extsolidx); m17 ^= unpack_w17ext_nbs(q26_sol0,q26_sol1); m18 ^= unpack_w18_nbs(q26_sol0,q26_sol1); m19 &= ~W19NBPACKM; m19 ^= unpack_w19_nbs_fb(q26_sol0,q26_sol1); m20 &= ~W20NBPACKM; m20 ^= unpack_w20_nbs_fb(q26_sol0,q26_sol1); const uint32_t m5 = BASESOLBUF.get<6>(basesolidx); const uint32_t m7 = BASESOLBUF.get<8>(basesolidx); const uint32_t m13 = BASESOLBUF.get<14>(basesolidx); const uint32_t m21 = rotate_left(m18 ^ m13 ^ m7 ^ m5,1); uint32_t q19, q20, q21, q22, q23; { uint32_t q13 = BASESOLBUF.get<1>(basesolidx); uint32_t q14 = BASESOLBUF.get<2>(basesolidx); uint32_t q15 = Q20SOLBUF.get<0>(extsolidx); uint32_t q16 = Q20SOLBUF.get<1>(extsolidx); uint32_t q17 = Q20SOLBUF.get<2>(extsolidx); uint32_t q18 = sha1_round1(q17, q16, q15, q14, q13, m17); q19 = sha1_round1(q18, q17, q16, q15, q14, m18); q20 = sha1_round1(q19, q18, q17, q16, q15, m19); q21 = sha1_round2(q20, q19, q18, q17, q16, m20); q22 = sha1_round2(q21, q20, q19, q18, q17, m21); q23 = sha1_round2(q22, q21, q20, q19, q18, 0); } // booms change: m10, m11, m12, m14, m15, m16 => m22 (m14), m23 (m15), m24 (m10,m16), m25(m11), m26(m10,m12),m27(m11),m28(m12,m14),m29(m15) // m5 const uint32_t m6 = BASESOLBUF.get<7>(basesolidx); // m7 const uint32_t m8 = BASESOLBUF.get<9>(basesolidx); const uint32_t m9 = BASESOLBUF.get<10>(basesolidx); uint32_t m10 = BASESOLBUF.get<11>(basesolidx); uint32_t m11 = BASESOLBUF.get<12>(basesolidx); uint32_t m12 = BASESOLBUF.get<13>(basesolidx); // m13 uint32_t m14 = Q20SOLBUF.get<3>(extsolidx); uint32_t m15 = Q20SOLBUF.get<4>(extsolidx); uint32_t m16 = Q20SOLBUF.get<5>(extsolidx); uint32_t m22precomp = m19 ^ 0 ^ m8 ^ m6; uint32_t m23precomp = m20 ^ 0 ^ m9 ^ m7; uint32_t m24precomp = m21 ^ m16 ^ 0 ^ m8; uint32_t m25precomp = m17 ^ m9; uint32_t m26precomp = m18 ^ m12; uint32_t m27precomp = m19 ^ m13; uint32_t q24precomp = sha1_round2(0, q22, q21, q20, q19, 0); uint32_t q11_bo = 0; for (unsigned m = 0; m < (1<<2); ++m) { NEXT_NB(q11_bo, Q11BOOMS); m10 ^= q11_bo; m11 ^= q11_bo<<5; m14 ^= (q11_bo>>2)&(1<<6); m15 ^= q11_bo>>2; uint32_t m22 = rotate_left(m14 ^ m22precomp,1); q23 += m22; uint32_t m23 = rotate_left(m15 ^ m23precomp,1); uint32_t q24 = q24precomp + rotate_left(q23,5) + m23; //sha1_round2(q23, q22, q21, q20, q19, m23); uint32_t m24 = rotate_left(m10 ^ m24precomp,1); uint32_t q25 = sha1_round2(q24, q23, q22, q21, q20, m24); uint32_t m25 = rotate_left(m22 ^ m11 ^ m25precomp,1); uint32_t q26 = sha1_round2(q25, q24, q23, q22, q21, m25); uint32_t m26 = rotate_left(m23 ^ m26precomp ^ m10,1); uint32_t q27 = sha1_round2(q26, q25, q24, q23, q22, m26); uint32_t m27 = rotate_left(m24 ^ m27precomp ^ m11,1); uint32_t q28 = sha1_round2(q27, q26, q25, q24, q23, m27); // const uint32_t q25nessies = Qset1mask[QOFF+25] // ^ (Qprevmask [QOFF + 25] & q24) // ^ (Qprevrmask [QOFF + 25] & rotate_left(q24,30)) // ^ (Qprev2rmask [QOFF + 25] & rotate_left(q23, 30)) ; // bool valid_sol = 0 == ((q25 ^ q25nessies) & Qcondmask[QOFF + 25]); const uint32_t q26nessies = Qset1mask[QOFF+26] // ^ (Qprevmask [QOFF + 26] & q25) // ^ (Qprevrmask [QOFF + 26] & rotate_left(q25, 30)) ^ (Qprev2rmask [QOFF + 26] & rotate_left(q24,30)) ; bool valid_sol = 0 == ((q26 ^ q26nessies) & Qcondmask[QOFF + 26]); const uint32_t q27nessies = Qset1mask[QOFF+27] // ^ (Qprevmask [QOFF + 27] & q26) ^ (Qprevrmask [QOFF + 27] & rotate_left(q26,30)) // ^ (Qprev2rmask [QOFF + 27] & rotate_left(q25, 30)) ; valid_sol &= 0 == ((q27 ^ q27nessies) & Qcondmask[QOFF + 27]); const uint32_t q28nessies = // Qset1mask[QOFF+28] // ^ (Qprevmask [QOFF + 28] & q27) // ^ (Qprevrmask [QOFF + 28] & rotate_left(q27, 30)) /*^*/ (Qprev2rmask [QOFF + 28] & rotate_left(q26,30)) ; valid_sol &= 0 == ((q28 ^ q28nessies) & Qcondmask[QOFF + 28]); Q28SOLBUF.write(Q28SOLCTL, valid_sol, q26_sol0, q26_sol1, q11_bo); q23 -= m22; m10 ^= q11_bo; m11 ^= q11_bo<<5; m14 ^= (q11_bo>>2)&(1<<6); m15 ^= q11_bo>>2; } PERF_STOP_COUNTER(27); } __device__ void stepQ2930(uint32_t thread_rd_idx) { PERF_START_COUNTER(29); using namespace dev; const uint32_t q28_sol0 = Q28SOLBUF.get<0>(thread_rd_idx); const uint32_t q28_sol1 = Q28SOLBUF.get<1>(thread_rd_idx); const uint32_t q28_sol2 = Q28SOLBUF.get<2>(thread_rd_idx); const uint32_t extsolidx = unpack_idx(q28_sol0,q28_sol1); const uint32_t basesolidx = Q20SOLBUF.get<10>(extsolidx); uint32_t m17 = Q20SOLBUF.get<6>(extsolidx); uint32_t m18 = Q20SOLBUF.get<7>(extsolidx); uint32_t m19 = Q20SOLBUF.get<8>(extsolidx); uint32_t m20 = Q20SOLBUF.get<9>(extsolidx); m17 ^= unpack_w17ext_nbs(q28_sol0,q28_sol1); m18 ^= unpack_w18_nbs(q28_sol0,q28_sol1); m19 &= ~W19NBPACKM; m19 ^= unpack_w19_nbs_fb(q28_sol0,q28_sol1); m20 &= ~W20NBPACKM; m20 ^= unpack_w20_nbs_fb(q28_sol0,q28_sol1); const uint32_t m5 = BASESOLBUF.get<6>(basesolidx); const uint32_t m7 = BASESOLBUF.get<8>(basesolidx); const uint32_t m13 = BASESOLBUF.get<14>(basesolidx); const uint32_t m21 = rotate_left(m18 ^ m13 ^ m7 ^ m5,1); uint32_t q19, q20, q21, q22, q23; { uint32_t q13 = BASESOLBUF.get<1>(basesolidx); uint32_t q14 = BASESOLBUF.get<2>(basesolidx); uint32_t q15 = Q20SOLBUF.get<0>(extsolidx); uint32_t q16 = Q20SOLBUF.get<1>(extsolidx); uint32_t q17 = Q20SOLBUF.get<2>(extsolidx); uint32_t q18 = sha1_round1(q17, q16, q15, q14, q13, m17); q19 = sha1_round1(q18, q17, q16, q15, q14, m18); q20 = sha1_round1(q19, q18, q17, q16, q15, m19); q21 = sha1_round2(q20, q19, q18, q17, q16, m20); q22 = sha1_round2(q21, q20, q19, q18, q17, m21); q23 = sha1_round2(q22, q21, q20, q19, q18, 0); } // booms change: m10, m11, m12, m14, m15, m16 => m22 (m14), m23 (m15), m24 (m10,m16), m25(m11), m26(m10,m12),m27(m11),m28(m12,m14),m29(m15) // m5 const uint32_t m6 = BASESOLBUF.get<7>(basesolidx); // m7 const uint32_t m8 = BASESOLBUF.get<9>(basesolidx); const uint32_t m9 = BASESOLBUF.get<10>(basesolidx); uint32_t m10 = BASESOLBUF.get<11>(basesolidx); uint32_t m11 = BASESOLBUF.get<12>(basesolidx); uint32_t m12 = BASESOLBUF.get<13>(basesolidx); // m13 uint32_t m14 = Q20SOLBUF.get<3>(extsolidx); uint32_t m15 = Q20SOLBUF.get<4>(extsolidx); uint32_t m16 = Q20SOLBUF.get<5>(extsolidx); m10 ^= q28_sol2; m11 ^= q28_sol2<<5; m14 ^= (q28_sol2>>2)&(1<<6); m15 ^= q28_sol2>>2; uint32_t m22 = rotate_left(m19 ^ m14 ^ m8 ^ m6,1); q23 += m22; uint32_t m23 = rotate_left(m20 ^ m15 ^ m9 ^ m7,1); uint32_t q24 = sha1_round2(q23, q22, q21, q20, q19, m23); uint32_t q25 = sha1_round2(q24, q23, q22, q21, q20, 0); uint32_t q26precomp = sha1_round2(0, q24, q23, q22, q21, 0); uint32_t m24precomp = m21 ^ m10 ^ m8; uint32_t m25precomp = m22 ^ m17 ^ m9; uint32_t m26precomp = m23 ^ m18 ^ m10; uint32_t m27precomp = m19 ^ m13; uint32_t m29precomp = m21 ^ m15 ^ m13; uint32_t q12_bo = 0; for (unsigned m = 0; m < (1<<2); ++m) { NEXT_NB(q12_bo, Q12BOOMS); m11 ^= q12_bo; m12 ^= q12_bo<<5; m16 ^= q12_bo>>2; uint32_t m24 = rotate_left(m16 ^ m24precomp,1); q25 += m24; uint32_t m25 = rotate_left(m11 ^ m25precomp,1); uint32_t q26 = q26precomp + rotate_left(q25,5) + m25; // uint32_t q26 = sha1_round2(q25, q24, q23, q22, q21, m25); uint32_t m26 = rotate_left(m12 ^ m26precomp,1); uint32_t q27 = sha1_round2(q26, q25, q24, q23, q22, m26); uint32_t m27 = rotate_left(m24 ^ m11 ^ m27precomp,1); uint32_t q28 = sha1_round2(q27, q26, q25, q24, q23, m27); uint32_t m28 = rotate_left(m25 ^ m20 ^ m14 ^ m12,1); uint32_t q29 = sha1_round2(q28, q27, q26, q25, q24, m28); uint32_t m29 = rotate_left(m26 ^ m29precomp,1); uint32_t q30 = sha1_round2(q29, q28, q27, q26, q25, m29); // const uint32_t q25nessies = Qset1mask[QOFF+25] // ^ (Qprevmask [QOFF + 25] & q24) // ^ (Qprevrmask [QOFF + 25] & rotate_left(q24,30)) // ^ (Qprev2rmask [QOFF + 25] & rotate_left(q23, 30)) // ; // bool valid_sol = 0 == ((q25 ^ q25nessies) & Qcondmask[QOFF + 25]); // const uint32_t q26nessies = Qset1mask[QOFF+26] // ^ (Qprevmask [QOFF + 26] & q25) // ^ (Qprevrmask [QOFF + 26] & rotate_left(q25, 30)) // ^ (Qprev2rmask [QOFF + 26] & rotate_left(q24,30)) // ; // valid_sol &= 0 == ((q26 ^ q26nessies) & Qcondmask[QOFF + 26]); const uint32_t q27nessies = Qset1mask[QOFF+27] // ^ (Qprevmask [QOFF + 27] & q26) ^ (Qprevrmask [QOFF + 27] & rotate_left(q26,30)) // ^ (Qprev2rmask [QOFF + 27] & rotate_left(q25, 30)) ; bool valid_sol = 0 == ((q27 ^ q27nessies) & Qcondmask[QOFF + 27]); const uint32_t q28nessies = // Qset1mask[QOFF+28] // ^ (Qprevmask [QOFF + 28] & q27) // ^ (Qprevrmask [QOFF + 28] & rotate_left(q27, 30)) /*^*/ (Qprev2rmask [QOFF + 28] & rotate_left(q26,30)) ; valid_sol &= 0 == ((q28 ^ q28nessies) & Qcondmask[QOFF + 28]); valid_sol &= 0 == ((q29 ^ Qset1mask[QOFF+29]) & Qcondmask[QOFF + 29]); valid_sol &= 0 == ((q30 ^ Qset1mask[QOFF+30]) & Qcondmask[QOFF + 30]); uint32_t sol2 = (q28_sol2 ^ (q12_bo<<16)); Q30SOLBUF.write(Q30SOLCTL, valid_sol, q28_sol0, q28_sol1, sol2); q25 -= m24; m11 ^= q12_bo; m12 ^= q12_bo<<5; m16 ^= q12_bo>>2; } PERF_STOP_COUNTER(29); } __device__ void stepQ3140(uint32_t thread_rd_idx) { PERF_START_COUNTER(31); using namespace dev; const uint32_t q30_sol0 = Q30SOLBUF.get<0>(thread_rd_idx); const uint32_t q30_sol1 = Q30SOLBUF.get<1>(thread_rd_idx); const uint32_t q30_sol2 = Q30SOLBUF.get<2>(thread_rd_idx); const uint32_t extsolidx = unpack_idx(q30_sol0,q30_sol1); const uint32_t basesolidx = Q20SOLBUF.get<10>(extsolidx); uint32_t m17 = Q20SOLBUF.get<6>(extsolidx); uint32_t m18 = Q20SOLBUF.get<7>(extsolidx); uint32_t m19 = Q20SOLBUF.get<8>(extsolidx); uint32_t m20 = Q20SOLBUF.get<9>(extsolidx); m17 ^= unpack_w17ext_nbs(q30_sol0,q30_sol1); m18 ^= unpack_w18_nbs(q30_sol0,q30_sol1); m19 &= ~W19NBPACKM; m19 ^= unpack_w19_nbs_fb(q30_sol0,q30_sol1); m20 &= ~W20NBPACKM; m20 ^= unpack_w20_nbs_fb(q30_sol0,q30_sol1); const uint32_t m5 = BASESOLBUF.get<6>(basesolidx); const uint32_t m7 = BASESOLBUF.get<8>(basesolidx); const uint32_t m13 = BASESOLBUF.get<14>(basesolidx); const uint32_t m21 = rotate_left(m18 ^ m13 ^ m7 ^ m5,1); uint32_t q19, q20, q21, q22, q23; { uint32_t q13 = BASESOLBUF.get<1>(basesolidx); uint32_t q14 = BASESOLBUF.get<2>(basesolidx); uint32_t q15 = Q20SOLBUF.get<0>(extsolidx); uint32_t q16 = Q20SOLBUF.get<1>(extsolidx); uint32_t q17 = Q20SOLBUF.get<2>(extsolidx); uint32_t q18 = sha1_round1(q17, q16, q15, q14, q13, m17); q19 = sha1_round1(q18, q17, q16, q15, q14, m18); q20 = sha1_round1(q19, q18, q17, q16, q15, m19); q21 = sha1_round2(q20, q19, q18, q17, q16, m20); q22 = sha1_round2(q21, q20, q19, q18, q17, m21); q23 = sha1_round2(q22, q21, q20, q19, q18, 0); } // booms change: m10, m11, m12, m14, m15, m16 => m22 (m14), m23 (m15), m24 (m10,m16), m25(m11), m26(m10,m12),m27(m11),m28(m12,m14),m29(m15) // m5 const uint32_t m6 = BASESOLBUF.get<7>(basesolidx); // m7 const uint32_t m8 = BASESOLBUF.get<9>(basesolidx); const uint32_t m9 = BASESOLBUF.get<10>(basesolidx); uint32_t m10 = BASESOLBUF.get<11>(basesolidx); uint32_t m11 = BASESOLBUF.get<12>(basesolidx); uint32_t m12 = BASESOLBUF.get<13>(basesolidx); // m13 uint32_t m14 = Q20SOLBUF.get<3>(extsolidx); uint32_t m15 = Q20SOLBUF.get<4>(extsolidx); uint32_t m16 = Q20SOLBUF.get<5>(extsolidx); { const uint32_t q11boom = q30_sol2 & Q11BOOMS; const uint32_t q12boom = (q30_sol2>>16) & Q12BOOMS; m10 ^= q11boom; m11 ^= q11boom<<5; m14 ^= (q11boom>>2)&(1<<6); m15 ^= q11boom>>2; m11 ^= q12boom; m12 ^= q12boom<<5; m16 ^= q12boom>>2; } uint32_t m22 = rotate_left(m19 ^ m14 ^ m8 ^ m6,1); q23 += m22; const uint32_t m23 = rotate_left(m20 ^ m15 ^ m9 ^ m7, 1); const uint32_t m24 = rotate_left(m21 ^ m16 ^ m10 ^ m8, 1); const uint32_t m25 = rotate_left(m22 ^ m17 ^ m11 ^ m9, 1); const uint32_t m26 = rotate_left(m23 ^ m18 ^ m12 ^ m10, 1); const uint32_t m27 = rotate_left(m24 ^ m19 ^ m13 ^ m11, 1); const uint32_t m28 = rotate_left(m25 ^ m20 ^ m14 ^ m12, 1); const uint32_t m29 = rotate_left(m26 ^ m21 ^ m15 ^ m13, 1); const uint32_t q24 = rotate_left(q23,5) + sha1_f2(q22,rotate_left(q21,30),rotate_left(q20,30)) + rotate_left(q19,30) + 0x6ED9EBA1 + m23; const uint32_t q25 = rotate_left(q24,5) + sha1_f2(q23,rotate_left(q22,30),rotate_left(q21,30)) + rotate_left(q20,30) + 0x6ED9EBA1 + m24; uint32_t q26 = rotate_left(q25,5) + sha1_f2(q24,rotate_left(q23,30),rotate_left(q22,30)) + rotate_left(q21,30) + 0x6ED9EBA1 + m25; uint32_t q27 = rotate_left(q26,5) + sha1_f2(q25,rotate_left(q24,30),rotate_left(q23,30)) + rotate_left(q22,30) + 0x6ED9EBA1 + m26; uint32_t q28 = rotate_left(q27,5) + sha1_f2(q26,rotate_left(q25,30),rotate_left(q24,30)) + rotate_left(q23,30) + 0x6ED9EBA1 + m27; uint32_t q29 = rotate_left(q28,5) + sha1_f2(q27,rotate_left(q26,30),rotate_left(q25,30)) + rotate_left(q24,30) + 0x6ED9EBA1 + m28; uint32_t q30 = rotate_left(q29,5) + sha1_f2(q28,rotate_left(q27,30),rotate_left(q26,30)) + rotate_left(q25,30) + 0x6ED9EBA1 + m29; const uint32_t m30 = rotate_left(m27 ^ m22 ^ m16 ^ m14, 1); const uint32_t m31 = rotate_left(m28 ^ m23 ^ m17 ^ m15, 1); const uint32_t m32 = rotate_left(m29 ^ m24 ^ m18 ^ m16, 1); const uint32_t m33 = rotate_left(m30 ^ m25 ^ m19 ^ m17, 1); const uint32_t m34 = rotate_left(m31 ^ m26 ^ m20 ^ m18, 1); const uint32_t m35 = rotate_left(m32 ^ m27 ^ m21 ^ m19, 1); const uint32_t m36 = rotate_left(m33 ^ m28 ^ m22 ^ m20, 1); const uint32_t m37 = rotate_left(m34 ^ m29 ^ m23 ^ m21, 1); const uint32_t m38 = rotate_left(m35 ^ m30 ^ m24 ^ m22, 1); const uint32_t m39 = rotate_left(m36 ^ m31 ^ m25 ^ m23, 1); uint32_t q36,q37,q38,q39,q40; { const uint32_t q31 = rotate_left(q30,5) + sha1_f2(q29,rotate_left(q28,30),rotate_left(q27,30)) + rotate_left(q26,30) + 0x6ED9EBA1 + m30; const uint32_t q32 = rotate_left(q31,5) + sha1_f2(q30,rotate_left(q29,30),rotate_left(q28,30)) + rotate_left(q27,30) + 0x6ED9EBA1 + m31; const uint32_t q33 = rotate_left(q32,5) + sha1_f2(q31,rotate_left(q30,30),rotate_left(q29,30)) + rotate_left(q28,30) + 0x6ED9EBA1 + m32; const uint32_t q34 = rotate_left(q33,5) + sha1_f2(q32,rotate_left(q31,30),rotate_left(q30,30)) + rotate_left(q29,30) + 0x6ED9EBA1 + m33; const uint32_t q35 = rotate_left(q34,5) + sha1_f2(q33,rotate_left(q32,30),rotate_left(q31,30)) + rotate_left(q30,30) + 0x6ED9EBA1 + m34; q36 = rotate_left(q35,5) + sha1_f2(q34,rotate_left(q33,30),rotate_left(q32,30)) + rotate_left(q31,30) + 0x6ED9EBA1 + m35; q37 = rotate_left(q36,5) + sha1_f2(q35,rotate_left(q34,30),rotate_left(q33,30)) + rotate_left(q32,30) + 0x6ED9EBA1 + m36; q38 = rotate_left(q37,5) + sha1_f2(q36,rotate_left(q35,30),rotate_left(q34,30)) + rotate_left(q33,30) + 0x6ED9EBA1 + m37; q39 = rotate_left(q38,5) + sha1_f2(q37,rotate_left(q36,30),rotate_left(q35,30)) + rotate_left(q34,30) + 0x6ED9EBA1 + m38; q40 = rotate_left(q39,5) + sha1_f2(q38,rotate_left(q37,30),rotate_left(q36,30)) + rotate_left(q35,30) + 0x6ED9EBA1 + m39; } q26 += dQ[QOFF+26]; q27 += dQ[QOFF+27]; q28 += dQ[QOFF+28]; q29 += dQ[QOFF+29]; q30 += dQ[QOFF+30]; uint32_t q36b,q37b,q38b,q39b,q40b; { const uint32_t q31 = rotate_left(q30,5) + sha1_f2(q29,rotate_left(q28,30),rotate_left(q27,30)) + rotate_left(q26,30) + 0x6ED9EBA1 + (m30^DV_DW[30]); const uint32_t q32 = rotate_left(q31,5) + sha1_f2(q30,rotate_left(q29,30),rotate_left(q28,30)) + rotate_left(q27,30) + 0x6ED9EBA1 + (m31^DV_DW[31]); const uint32_t q33 = rotate_left(q32,5) + sha1_f2(q31,rotate_left(q30,30),rotate_left(q29,30)) + rotate_left(q28,30) + 0x6ED9EBA1 + (m32^DV_DW[32]); const uint32_t q34 = rotate_left(q33,5) + sha1_f2(q32,rotate_left(q31,30),rotate_left(q30,30)) + rotate_left(q29,30) + 0x6ED9EBA1 + (m33^DV_DW[33]); const uint32_t q35 = rotate_left(q34,5) + sha1_f2(q33,rotate_left(q32,30),rotate_left(q31,30)) + rotate_left(q30,30) + 0x6ED9EBA1 + (m34^DV_DW[34]); q36b = rotate_left(q35,5) + sha1_f2(q34,rotate_left(q33,30),rotate_left(q32,30)) + rotate_left(q31,30) + 0x6ED9EBA1 + (m35^DV_DW[35]); q37b = rotate_left(q36b,5) + sha1_f2(q35,rotate_left(q34,30),rotate_left(q33,30)) + rotate_left(q32,30) + 0x6ED9EBA1 + (m36^DV_DW[36]); q38b = rotate_left(q37b,5) + sha1_f2(q36b,rotate_left(q35,30),rotate_left(q34,30)) + rotate_left(q33,30) + 0x6ED9EBA1 + (m37^DV_DW[37]); q39b = rotate_left(q38b,5) + sha1_f2(q37b,rotate_left(q36b,30),rotate_left(q35,30)) + rotate_left(q34,30) + 0x6ED9EBA1 + (m38^DV_DW[38]); q40b = rotate_left(q39b,5) + sha1_f2(q38b,rotate_left(q37b,30),rotate_left(q36b,30)) + rotate_left(q35,30) + 0x6ED9EBA1 + (m39^DV_DW[39]); } bool valid_sol = 0 == ( (q36^q36b) | (q37^q37b) | (q38^q38b) | (q39^q39b) | (q40^q40b) ); Q40SOLBUF.write(Q40SOLCTL, valid_sol, q36, q37, q38, q39, q40, m24,m25,m26,m27,m28,m29,m30,m31,m32,m33,m34,m35,m36,m37,m38,m39); PERF_STOP_COUNTER(31); } __device__ void step_extend_Q60(uint32_t thread_rd_idx) { PERF_START_COUNTER(60); using namespace dev; uint32_t e = Q40SOLBUF.get<0>(thread_rd_idx); // q36 uint32_t d = Q40SOLBUF.get<1>(thread_rd_idx); // q37 uint32_t c = Q40SOLBUF.get<2>(thread_rd_idx); // q38 uint32_t b = Q40SOLBUF.get<3>(thread_rd_idx); // q39 uint32_t a = Q40SOLBUF.get<4>(thread_rd_idx); // q40 uint32_t E = e; uint32_t D = d; uint32_t C = c; uint32_t B = b; uint32_t A = a; uint32_t m40, m41, m42, m43, m44, m45, m46, m47; uint32_t m48, m49, m50, m51, m52, m53, m54, m55; uint32_t m56, m57, m58, m59; { uint32_t m24 = Q40SOLBUF.get<5>(thread_rd_idx); uint32_t m25 = Q40SOLBUF.get<6>(thread_rd_idx); uint32_t m26 = Q40SOLBUF.get<7>(thread_rd_idx); uint32_t m27 = Q40SOLBUF.get<8>(thread_rd_idx); uint32_t m28 = Q40SOLBUF.get<9>(thread_rd_idx); uint32_t m29 = Q40SOLBUF.get<10>(thread_rd_idx); uint32_t m30 = Q40SOLBUF.get<11>(thread_rd_idx); uint32_t m31 = Q40SOLBUF.get<12>(thread_rd_idx); uint32_t m32 = Q40SOLBUF.get<13>(thread_rd_idx); uint32_t m33 = Q40SOLBUF.get<14>(thread_rd_idx); uint32_t m34 = Q40SOLBUF.get<15>(thread_rd_idx); uint32_t m35 = Q40SOLBUF.get<16>(thread_rd_idx); uint32_t m36 = Q40SOLBUF.get<17>(thread_rd_idx); uint32_t m37 = Q40SOLBUF.get<18>(thread_rd_idx); uint32_t m38 = Q40SOLBUF.get<19>(thread_rd_idx); uint32_t m39 = Q40SOLBUF.get<20>(thread_rd_idx); m40 = sha1_mess(m37, m32, m26, m24); m41 = sha1_mess(m38, m33, m27, m25); m42 = sha1_mess(m39, m34, m28, m26); m43 = sha1_mess(m40, m35, m29, m27); m44 = sha1_mess(m41, m36, m30, m28); m45 = sha1_mess(m42, m37, m31, m29); m46 = sha1_mess(m43, m38, m32, m30); m47 = sha1_mess(m44, m39, m33, m31); m48 = sha1_mess(m45, m40, m34, m32); m49 = sha1_mess(m46, m41, m35, m33); m50 = sha1_mess(m47, m42, m36, m34); m51 = sha1_mess(m48, m43, m37, m35); m52 = sha1_mess(m49, m44, m38, m36); m53 = sha1_mess(m50, m45, m39, m37); m54 = sha1_mess(m51, m46, m40, m38); m55 = sha1_mess(m52, m47, m41, m39); m56 = sha1_mess(m53, m48, m42, m40); m57 = sha1_mess(m54, m49, m43, m41); m58 = sha1_mess(m55, m50, m44, m42); m59 = sha1_mess(m56, m51, m45, m43); } e = sha1_round3(a, b, c, d, e, m40); d = sha1_round3(e, a, b, c, d, m41); c = sha1_round3(d, e, a, b, c, m42); b = sha1_round3(c, d, e, a, b, m43); a = sha1_round3(b, c, d, e, a, m44); e = sha1_round3(a, b, c, d, e, m45); d = sha1_round3(e, a, b, c, d, m46); c = sha1_round3(d, e, a, b, c, m47); b = sha1_round3(c, d, e, a, b, m48); a = sha1_round3(b, c, d, e, a, m49); e = sha1_round3(a, b, c, d, e, m50); d = sha1_round3(e, a, b, c, d, m51); c = sha1_round3(d, e, a, b, c, m52); b = sha1_round3(c, d, e, a, b, m53); a = sha1_round3(b, c, d, e, a, m54); e = sha1_round3(a, b, c, d, e, m55); d = sha1_round3(e, a, b, c, d, m56); c = sha1_round3(d, e, a, b, c, m57); b = sha1_round3(c, d, e, a, b, m58); a = sha1_round3(b, c, d, e, a, m59); m40 ^= DV_DW[40]; m41 ^= DV_DW[41]; m42 ^= DV_DW[42]; m43 ^= DV_DW[43]; m44 ^= DV_DW[44]; m45 ^= DV_DW[45]; m46 ^= DV_DW[46]; m47 ^= DV_DW[47]; m48 ^= DV_DW[48]; m49 ^= DV_DW[49]; m50 ^= DV_DW[50]; m51 ^= DV_DW[51]; m52 ^= DV_DW[52]; m53 ^= DV_DW[53]; m54 ^= DV_DW[54]; m55 ^= DV_DW[55]; m56 ^= DV_DW[56]; m57 ^= DV_DW[57]; m58 ^= DV_DW[58]; m59 ^= DV_DW[59]; E = sha1_round3(A, B, C, D, E, m40); D = sha1_round3(E, A, B, C, D, m41); C = sha1_round3(D, E, A, B, C, m42); B = sha1_round3(C, D, E, A, B, m43); A = sha1_round3(B, C, D, E, A, m44); E = sha1_round3(A, B, C, D, E, m45); D = sha1_round3(E, A, B, C, D, m46); C = sha1_round3(D, E, A, B, C, m47); B = sha1_round3(C, D, E, A, B, m48); A = sha1_round3(B, C, D, E, A, m49); E = sha1_round3(A, B, C, D, E, m50); D = sha1_round3(E, A, B, C, D, m51); C = sha1_round3(D, E, A, B, C, m52); B = sha1_round3(C, D, E, A, B, m53); A = sha1_round3(B, C, D, E, A, m54); E = sha1_round3(A, B, C, D, E, m55); D = sha1_round3(E, A, B, C, D, m56); C = sha1_round3(D, E, A, B, C, m57); B = sha1_round3(C, D, E, A, B, m58); A = sha1_round3(B, C, D, E, A, m59); // bool good60 = (e == E); // good60 = (d == D) && good60; // good60 = (c == C) && good60; // good60 = (b == B) && good60; // good60 = (a == A) && good60; bool good60 = 0 == ((e^E)|(d^D)|(c^C)|(b^B)|(a^A)); // sol: Q56,..,Q60,m44,...,m59 COLLCANDIDATEBUF.write(COLLCANDIDATECTL, good60, e, d, c, b, a, m44, m45, m46, m47, m48, m49, m50, m51, m52, m53, m54, m55, m56, m57, m58, m59); PERF_STOP_COUNTER(60); } // BACKUP CONTROLS ONLY IF THEY ARE IN SHARED (AND THUS BLOCK-SPECIFIC) __device__ void backup_controls() { __syncthreads(); if (threadIdx.x == 0) { // q18_solutions_ctl_bu[blockIdx.x] = Q18SOLCTL; // q19_solutions_ctl_bu[blockIdx.x] = Q19SOLCTL; q20_solutions_ctl_bu[blockIdx.x] = Q20SOLCTL; q21_solutions_ctl_bu[blockIdx.x] = Q21SOLCTL; q22_solutions_ctl_bu[blockIdx.x] = Q22SOLCTL; q23_solutions_ctl_bu[blockIdx.x] = Q23SOLCTL; q26_solutions_ctl_bu[blockIdx.x] = Q26SOLCTL; q28_solutions_ctl_bu[blockIdx.x] = Q28SOLCTL; q30_solutions_ctl_bu[blockIdx.x] = Q30SOLCTL; q40_solutions_ctl_bu[blockIdx.x] = Q40SOLCTL; #ifdef USE_PERF_COUNTERS performance_backup(); #endif } __syncthreads(); } __device__ void restore_controls() { __syncthreads(); if (threadIdx.x == 0) { // Q18SOLCTL = q18_solutions_ctl_bu[blockIdx.x]; // Q19SOLCTL = q19_solutions_ctl_bu[blockIdx.x]; Q20SOLCTL = q20_solutions_ctl_bu[blockIdx.x]; Q21SOLCTL = q21_solutions_ctl_bu[blockIdx.x]; Q22SOLCTL = q22_solutions_ctl_bu[blockIdx.x]; Q23SOLCTL = q23_solutions_ctl_bu[blockIdx.x]; Q26SOLCTL = q26_solutions_ctl_bu[blockIdx.x]; Q28SOLCTL = q28_solutions_ctl_bu[blockIdx.x]; Q30SOLCTL = q30_solutions_ctl_bu[blockIdx.x]; Q40SOLCTL = q40_solutions_ctl_bu[blockIdx.x]; #ifdef USE_PERF_COUNTERS performance_restore(); #endif } __syncthreads(); } __global__ void reset_buffers() { // restore_controls(); // unnecessary BASESOLBUF.reset(BASESOLCTL); Q18SOLBUF.reset(Q18SOLCTL); Q19SOLBUF.reset(Q19SOLCTL); Q20SOLBUF.reset(Q20SOLCTL); Q21SOLBUF.reset(Q21SOLCTL); Q22SOLBUF.reset(Q22SOLCTL); Q23SOLBUF.reset(Q23SOLCTL); Q26SOLBUF.reset(Q26SOLCTL); Q28SOLBUF.reset(Q28SOLCTL); Q30SOLBUF.reset(Q30SOLCTL); Q40SOLBUF.reset(Q40SOLCTL); COLLCANDIDATEBUF.reset(COLLCANDIDATECTL); #ifdef USE_PERF_COUNTERS performance_reset(); #endif backup_controls(); } __global__ void cuda_attack() { restore_controls(); __shared__ uint32_t stepQ18done; __shared__ uint64_t startclock; if (threadIdx.x==0) { stepQ18done = 0; startclock = clock64(); } #define USE_CLOCK_LOOP #ifdef USE_CLOCK_LOOP do { // crashes when adding this loop ?!?!?!?! causes memory access error ?!?!? // for (unsigned lloop = 0; lloop < 16; ++lloop) { #else for (unsigned lloop = 0; lloop < (1<<18); ++lloop) { { #endif #if 1 { uint32_t thidx = Q40SOLBUF.getreadidx(Q40SOLCTL); if (thidx != 0xFFFFFFFF) { step_extend_Q60(thidx); DEBUG_BREAK; continue; } } #endif #if 1 { uint32_t thidx = Q30SOLBUF.getreadidx(Q30SOLCTL); if (thidx != 0xFFFFFFFF) { stepQ3140(thidx); DEBUG_BREAK; continue; } } #endif #if 1 { uint32_t thidx = Q28SOLBUF.getreadidx(Q28SOLCTL); if (thidx != 0xFFFFFFFF) { stepQ2930(thidx); DEBUG_BREAK; continue; } } #endif #if 1 { uint32_t thidx = Q26SOLBUF.getreadidx(Q26SOLCTL); if (thidx != 0xFFFFFFFF) { stepQ2728(thidx); DEBUG_BREAK; continue; } } #endif #if 1 { uint32_t thidx = Q23SOLBUF.getreadidx(Q23SOLCTL); if (thidx != 0xFFFFFFFF) { stepQ2456(thidx); DEBUG_BREAK; continue; } } #endif #if 1 { uint32_t thidx = Q22SOLBUF.getreadidx(Q22SOLCTL); if (thidx != 0xFFFFFFFF) { stepQ23(thidx); DEBUG_BREAK; continue; } } #endif #if 1 { uint32_t thidx = Q21SOLBUF.getreadidx(Q21SOLCTL); if (thidx != 0xFFFFFFFF) { stepQ22(thidx); DEBUG_BREAK; continue; } } #endif #if 1 { uint32_t thidx = Q20SOLBUF.getreadidx(Q20SOLCTL); if (thidx != 0xFFFFFFFF) { stepQ21(thidx); DEBUG_BREAK; continue; } } #endif #if 1 { uint32_t thidx = Q19SOLBUF.getreadidx(Q19SOLCTL); if (thidx != 0xFFFFFFFF) { stepQ20(thidx); DEBUG_BREAK; continue; } } #endif #if 1 { uint32_t thidx = Q18SOLBUF.getreadidx(Q18SOLCTL); if (thidx != 0xFFFFFFFF) { stepQ19(thidx); DEBUG_BREAK; continue; } } #endif #if 1 // only let warp 0 of each block grab a basesol once per kernel run if (stepQ18done == 0 && (threadIdx.x>>5)==0) { uint32_t thidx = BASESOLBUF.getreadidx(BASESOLCTL); if (thidx != 0xFFFFFFFF) { if (threadIdx.x == 0) stepQ18done = 1; stepQ18(thidx); // break; DEBUG_BREAK; continue; } } #endif } } #ifdef USE_CLOCK_LOOP #ifdef USE_PERF_COUNTERS while ((clock64()-startclock) < (uint64_t(1)<<32)); #else while ((clock64()-startclock) < (uint64_t(1)<<34)); #endif #endif backup_controls(); } void verify_step_computations(int cuda_blocks); bool verify(basesol_t basesol); void print_attack_info(); void save_q60solutions() { if (outputfile.empty()) { outputfile = "q60sols.txt"; // return; } static size_t oldsize = 0; q60sol_t sol; vector<q60sol_t> q60sols; for (size_t i = 0; i < COLLCANDIDATECTL.write_idx; ++i) { sol.Q[0] = COLLCANDIDATEBUF.get<0>(i); sol.Q[1] = COLLCANDIDATEBUF.get<1>(i); sol.Q[2] = COLLCANDIDATEBUF.get<2>(i); sol.Q[3] = COLLCANDIDATEBUF.get<3>(i); sol.Q[4] = COLLCANDIDATEBUF.get<4>(i); sol.m[0] = COLLCANDIDATEBUF.get<5>(i); sol.m[1] = COLLCANDIDATEBUF.get<6>(i); sol.m[2] = COLLCANDIDATEBUF.get<7>(i); sol.m[3] = COLLCANDIDATEBUF.get<8>(i); sol.m[4] = COLLCANDIDATEBUF.get<9>(i); sol.m[5] = COLLCANDIDATEBUF.get<10>(i); sol.m[6] = COLLCANDIDATEBUF.get<11>(i); sol.m[7] = COLLCANDIDATEBUF.get<12>(i); sol.m[8] = COLLCANDIDATEBUF.get<13>(i); sol.m[9] = COLLCANDIDATEBUF.get<14>(i); sol.m[10] = COLLCANDIDATEBUF.get<15>(i); sol.m[11] = COLLCANDIDATEBUF.get<16>(i); sol.m[12] = COLLCANDIDATEBUF.get<17>(i); sol.m[13] = COLLCANDIDATEBUF.get<18>(i); sol.m[14] = COLLCANDIDATEBUF.get<19>(i); sol.m[15] = COLLCANDIDATEBUF.get<20>(i); q60sols.push_back(sol); } if (oldsize != q60sols.size()) { oldsize = q60sols.size(); cout << "Writing " << q60sols.size() << " Q60-solutions to '" << outputfile << "'..." << endl; ofstream ofs(outputfile.c_str()); if (!ofs) { cout << "Error opening '" << outputfile << ".tmp'!" << endl; return; } for (size_t i = 0; i < q60sols.size(); ++i) { ofs << encode_q60sol(q60sols[i]) << endl; } } } buffer_basesol_t basesol_buf_host; control_basesol_t basesol_ctl_host; bool compiled_with_cuda() { return true; } void cuda_main(std::vector<basesol_t>& basesols) { unsigned flags; switch (cuda_scheduler) { case 0: default: flags = cudaDeviceScheduleAuto; break; case 1: flags = cudaDeviceScheduleSpin; break; case 2: flags = cudaDeviceScheduleYield; break; case 3: flags = cudaDeviceScheduleBlockingSync; break; } cout << "Using device " << cuda_device << ": " << flush; CUDA_ASSERT( cudaSetDeviceFlags(flags) ); CUDA_ASSERT( cudaSetDevice(cuda_device) ); cudaDeviceProp prop; CUDA_ASSERT( cudaGetDeviceProperties(&prop, cuda_device) ); cout << prop.name << " (PCI " << hex << setw(2) << setfill('0') << prop.pciBusID << ":" << hex << setw(2) << setfill('0') << prop.pciDeviceID << "." << hex << prop.pciDomainID << dec << ")" << endl; if (cuda_threads_per_block == -1) { cuda_threads_per_block = prop.maxThreadsPerBlock; } if (THREADS_PER_BLOCK < cuda_threads_per_block) { cuda_threads_per_block = THREADS_PER_BLOCK; } if (prop.regsPerBlock/64 < cuda_threads_per_block) { cuda_threads_per_block = prop.regsPerBlock/64; } if (cuda_blocks == -1) { cuda_blocks = prop.multiProcessorCount * (prop.maxThreadsPerMultiProcessor / prop.maxThreadsPerBlock); } if (BLOCKS < cuda_blocks) { cuda_blocks = BLOCKS; } cout << "Using " << cuda_blocks << " blocks x " << cuda_threads_per_block << " threads/block." << endl; cout << "Resetting buffers..." << flush; reset_buffers<<<cuda_blocks,32>>>(); CUDA_ASSERT( cudaDeviceSynchronize() ); cout << "done." << endl; #if 1 cout << "Filtering base solutions" << endl; cout << "In : " << basesols.size() << endl; for (size_t i = 0; i < basesols.size(); ) { if (verify(basesols[i])) { ++i; } else { swap(basesols[i], basesols.back()); basesols.pop_back(); } } cout << "Out: " << basesols.size() << endl; if (basesols.size() == 0) { return; } #endif cout << "Initializing base solution buffer" << endl; size_t basesolcnt = basesols.size(); if (basesol_buf_host.size < basesolcnt) { basesolcnt = basesol_buf_host.size; } for (size_t i = 0; i < basesolcnt; ++i) { // Q12,..,Q17,m4,...,m19 basesol_buf_host.write(basesol_ctl_host, true , basesols[i].Q[ 0], basesols[i].Q[ 1], basesols[i].Q[ 2], basesols[i].Q[ 3], basesols[i].Q[ 4], basesols[i].Q[ 5] , basesols[i].m[ 0], basesols[i].m[ 1], basesols[i].m[ 2], basesols[i].m[ 3] , basesols[i].m[ 4], basesols[i].m[ 5], basesols[i].m[ 6], basesols[i].m[ 7] , basesols[i].m[ 8], basesols[i].m[ 9], basesols[i].m[10], basesols[i].m[11] , basesols[i].m[12], basesols[i].m[13], basesols[i].m[14], basesols[i].m[15] ); } #ifdef USE_MANAGED cout << "Moving " << basesolcnt << " base solutions to GPU MANAGED..." << flush; // directly copy to variable in HOST memory base_solutions_buf = basesol_buf_host; base_solutions_ctl = basesol_ctl_host; #else cout << "Moving " << basesolcnt << " base solutions to GPU GLOBAL..." << flush; // directly copy to variable in GPU GLOBAL memory CUDA_ASSERT( cudaMemcpyToSymbol(base_solutions_buf, &basesol_buf_host, sizeof(basesol_buf_host) ) ); CUDA_ASSERT( cudaMemcpyToSymbol(base_solutions_ctl, &basesol_ctl_host, sizeof(basesol_ctl_host) ) ); CUDA_ASSERT( cudaDeviceSynchronize() ); #endif cout << "done." << endl; // use auto for same type deduction, same type is necessary for proper wrap-around behaviour uint32_t q18oldbufsize; uint32_t q19oldbufsize; uint32_t q20oldbufsize[BLOCKS]; uint32_t q21oldbufsize[BLOCKS]; uint32_t q22oldbufsize[BLOCKS]; uint32_t q23oldbufsize[BLOCKS]; uint32_t q26oldbufsize[BLOCKS]; uint32_t q28oldbufsize[BLOCKS]; uint32_t q30oldbufsize[BLOCKS]; uint32_t q40oldbufsize[BLOCKS]; q18oldbufsize = q18_solutions_ctl.write_idx; q19oldbufsize = q19_solutions_ctl.write_idx; for (unsigned bl = 0; bl < cuda_blocks; ++bl) { q20oldbufsize[bl] = q20_solutions_ctl_bu[bl].write_idx; q21oldbufsize[bl] = q21_solutions_ctl_bu[bl].write_idx; q22oldbufsize[bl] = q22_solutions_ctl_bu[bl].write_idx; q23oldbufsize[bl] = q23_solutions_ctl_bu[bl].write_idx; q26oldbufsize[bl] = q26_solutions_ctl_bu[bl].write_idx; q28oldbufsize[bl] = q28_solutions_ctl_bu[bl].write_idx; q30oldbufsize[bl] = q30_solutions_ctl_bu[bl].write_idx; q40oldbufsize[bl] = q40_solutions_ctl_bu[bl].write_idx; } uint64_t q18sols = 0, q19sols = 0, q20sols = 0, q21sols = 0, q22sols = 0, q23sols = 0, q26sols = 0, q28sols = 0, q30sols = 0, q40sols = 0, q60sols = 0; cout << "Starting CUDA kernel" << flush; timer::timer cuda_total_time; while (true) { cout << "." << flush; timer::timer cuda_time; cuda_attack<<<cuda_blocks,cuda_threads_per_block>>>(); CUDA_ASSERT( cudaDeviceSynchronize() ); cout << "CUDA running time: " << cuda_time.time() << endl; #ifdef VERIFY_GPU_RESULTS verify_step_computations(cuda_blocks); #endif uint64_t basesolsleft = uint32_t(base_solutions_ctl.write_idx - base_solutions_ctl.read_idx); uint64_t gl_workleft_base = uint32_t(basesolsleft)>>5; uint64_t gl_workleft_q18 = ((q18_solutions_ctl.write_idx - q18_solutions_ctl.read_idx) % q18_solutions_ctl.size) >>5; uint64_t gl_workleft_q19 = ((q19_solutions_ctl.write_idx - q19_solutions_ctl.read_idx) % q19_solutions_ctl.size) >>5; uint64_t gl_workleft = gl_workleft_base + gl_workleft_q18 + gl_workleft_q19; q18sols += q18_solutions_ctl.write_idx - q18oldbufsize; q19sols += q19_solutions_ctl.write_idx - q19oldbufsize; q18oldbufsize = q18_solutions_ctl.write_idx; q19oldbufsize = q19_solutions_ctl.write_idx; uint64_t workleft = gl_workleft; for (unsigned bl = 0; bl < cuda_blocks; ++bl) { workleft += (q20_solutions_ctl_bu[bl].write_idx - q20_solutions_ctl_bu[bl].read_idx)>>5; workleft += (q21_solutions_ctl_bu[bl].write_idx - q21_solutions_ctl_bu[bl].read_idx)>>5; workleft += (q22_solutions_ctl_bu[bl].write_idx - q22_solutions_ctl_bu[bl].read_idx)>>5; workleft += (q23_solutions_ctl_bu[bl].write_idx - q23_solutions_ctl_bu[bl].read_idx)>>5; workleft += (q26_solutions_ctl_bu[bl].write_idx - q26_solutions_ctl_bu[bl].read_idx)>>5; workleft += (q28_solutions_ctl_bu[bl].write_idx - q28_solutions_ctl_bu[bl].read_idx)>>5; workleft += (q30_solutions_ctl_bu[bl].write_idx - q30_solutions_ctl_bu[bl].read_idx)>>5; workleft += (q40_solutions_ctl_bu[bl].write_idx - q40_solutions_ctl_bu[bl].read_idx)>>5; q20sols += q20_solutions_ctl_bu[bl].write_idx - q20oldbufsize[bl]; q21sols += q21_solutions_ctl_bu[bl].write_idx - q21oldbufsize[bl]; q22sols += q22_solutions_ctl_bu[bl].write_idx - q22oldbufsize[bl]; q23sols += q23_solutions_ctl_bu[bl].write_idx - q23oldbufsize[bl]; q26sols += q26_solutions_ctl_bu[bl].write_idx - q26oldbufsize[bl]; q28sols += q28_solutions_ctl_bu[bl].write_idx - q28oldbufsize[bl]; q30sols += q30_solutions_ctl_bu[bl].write_idx - q30oldbufsize[bl]; q40sols += q40_solutions_ctl_bu[bl].write_idx - q40oldbufsize[bl]; q20oldbufsize[bl] = q20_solutions_ctl_bu[bl].write_idx; q21oldbufsize[bl] = q21_solutions_ctl_bu[bl].write_idx; q22oldbufsize[bl] = q22_solutions_ctl_bu[bl].write_idx; q23oldbufsize[bl] = q23_solutions_ctl_bu[bl].write_idx; q26oldbufsize[bl] = q26_solutions_ctl_bu[bl].write_idx; q28oldbufsize[bl] = q28_solutions_ctl_bu[bl].write_idx; q30oldbufsize[bl] = q30_solutions_ctl_bu[bl].write_idx; q40oldbufsize[bl] = q40_solutions_ctl_bu[bl].write_idx; } q60sols = collision_candidates_ctl.write_idx; cout << "Q18 sols:\t" << q18sols << "\t" << (double(q18sols)/cuda_total_time.time()) << "#/s" << endl; cout << "Q19 sols:\t" << q19sols << "\t" << (double(q19sols)/cuda_total_time.time()) << "#/s" << endl; cout << "Q20 sols:\t" << q20sols << "\t" << (double(q20sols)/cuda_total_time.time()) << "#/s" << endl; cout << "Q21 sols:\t" << q21sols << "\t" << (double(q21sols)/cuda_total_time.time()) << "#/s" << endl; cout << "Q22 sols:\t" << q22sols << "\t" << (double(q22sols)/cuda_total_time.time()) << "#/s" << endl; cout << "Q23 sols:\t" << q23sols << "\t" << (double(q23sols)/cuda_total_time.time()) << "#/s" << endl; cout << "Q26 sols:\t" << q26sols << "\t" << (double(q26sols)/cuda_total_time.time()) << "#/s" << endl; cout << "Q28 sols:\t" << q28sols << "\t" << (double(q28sols)/cuda_total_time.time()) << "#/s" << endl; cout << "Q30 sols:\t" << q30sols << "\t" << (double(q30sols)/cuda_total_time.time()) << "#/s" << endl; cout << "Q40 sols:\t" << q40sols << "\t" << (double(q40sols)/cuda_total_time.time()) << "#/s" << endl; cout << "Q60 sols:\t" << q60sols << "\t" << (double(q60sols)/cuda_total_time.time()) << "#/s" << endl; save_q60solutions(); #ifdef USE_PERF_COUNTERS show_performance_counters(); #endif // exit if base solutions have been exhausted // !! NOTE THAT THERE MAY STILL BE SOME OTHER WORK LEFT !! cout << "Basesolutions left: " << basesolsleft << "\t" << (double(base_solutions_ctl.read_idx)/cuda_total_time.time()) << "#/s" << endl; cout << "Global work left: B:" << gl_workleft_base << " Q18:" << gl_workleft_q18 << " Q19:" << gl_workleft_q19 << endl; if (gl_workleft == 0) { cout << "Exhausted work!" << endl; break; } // boost::this_thread::sleep_for( boost::chrono::seconds(1) ); } } #ifdef VERIFY_GPU_RESULTS #define VERIFY_ERROR(s) { cout << "Err @ block=" << block << " bufidx=" << read_idx << " baseidx=" << base_idx << " : " << s << endl; ok = false; } uint32_t isQokay(int t, uint32_t Q[]) { using namespace host; uint32_t Qval = Qset1mask[QOFF+t] ^ (Qnextmask[QOFF+t] & Q[QOFF+t+1]) ^ (Qprevmask[QOFF+t] & Q[QOFF+t-1]) ^ (Qprevrmask[QOFF+t] & rotate_left(Q[QOFF+t-1],30)) ^ (Qprev2rmask[QOFF+t] & rotate_left(Q[QOFF+t-2],30)) ; return ( (Q[QOFF+t] ^ Qval) & Qcondmask[QOFF+t] ); } vector<uint32_t>& operator^=(vector<uint32_t>& l, const vector<uint32_t>& r) { if (l.size() != r.size()) throw std::runtime_error("vector<uint32_t>::operator^=(): unequal sizes!"); for (unsigned i = 0; i < l.size(); ++i) l[i] ^= r[i]; return l; } void print_convert_msgbitrel(const uint32_t rel[17], int oldmainblockoffset, int newmainblockoffset) { vector<uint32_t> bitrel(81, 0); for (int t = oldmainblockoffset; t < oldmainblockoffset + 16; ++t) bitrel[t] = rel[t - oldmainblockoffset]; bitrel[80] = rel[16]; map< vector<uint32_t>, vector<uint32_t> > bit_exp; for (unsigned t = 0; t < 16; ++t) for (unsigned b = 0; b < 32; ++b) { vector<uint32_t> l(16, 0), r(80, 0); l[t] |= 1 << b; sha1_me_generalised(&r[0], &l[0], newmainblockoffset); bit_exp[l] = r; } map< pair<unsigned, unsigned>, vector<uint32_t> > bit80_vec16; for (unsigned t = 0; t < 80; ++t) for (unsigned b = 0; b < 32; ++b) { vector<uint32_t> r(16, 0); for (map<vector<uint32_t>,vector<uint32_t> >::const_iterator it = bit_exp.begin(); it != bit_exp.end(); ++it) if (it->second[t] & (1 << b)) r ^= it->first; bit80_vec16[make_pair(t, b)] = r; } vector<uint32_t> newrel(16); for (unsigned t = 0; t < 80; ++t) for (unsigned b = 0; b < 32; ++b) if (bitrel[t] & (1 << b)) newrel ^= bit80_vec16[make_pair(t, b)]; newrel.resize(17); newrel[16] = (bitrel[80] == 0) ? 0 : 1; for (unsigned t = newmainblockoffset; t < newmainblockoffset + 16; ++t) for (unsigned b = 0; b < 32; ++b) if (newrel[t - newmainblockoffset] & (1 << b)) cout << " ^ W" << t << "[" << b << "]"; cout << " = " << (newrel[16] & 1) << endl; } bool verify_Q18_Q19(int block, size_t read_idx, int lastQ, uint32_t w0, uint32_t w1) { bool ok = true; using namespace host; uint32_t m[80]; uint32_t Q[85]; size_t base_idx = unpack_idx(w0,w1); Q[QOFF+12] = base_solutions_buf.get<0>(base_idx); Q[QOFF+13] = base_solutions_buf.get<1>(base_idx); Q[QOFF+14] = base_solutions_buf.get<2>(base_idx); Q[QOFF+15] = base_solutions_buf.get<3>(base_idx); Q[QOFF+16] = base_solutions_buf.get<4>(base_idx); Q[QOFF+17] = base_solutions_buf.get<5>(base_idx); m[ 5] = base_solutions_buf.get< 6>(base_idx); m[ 6] = base_solutions_buf.get< 7>(base_idx); m[ 7] = base_solutions_buf.get< 8>(base_idx); m[ 8] = base_solutions_buf.get< 9>(base_idx); m[ 9] = base_solutions_buf.get<10>(base_idx); m[10] = base_solutions_buf.get<11>(base_idx); m[11] = base_solutions_buf.get<12>(base_idx); m[12] = base_solutions_buf.get<13>(base_idx); m[13] = base_solutions_buf.get<14>(base_idx); m[14] = base_solutions_buf.get<15>(base_idx); m[15] = base_solutions_buf.get<16>(base_idx); m[16] = base_solutions_buf.get<17>(base_idx); m[17] = base_solutions_buf.get<18>(base_idx); m[18] = base_solutions_buf.get<19>(base_idx); m[19] = base_solutions_buf.get<20>(base_idx); m[20] = base_solutions_buf.get<21>(base_idx); uint32_t m14nb = unpack_w14_nbs(w0, w1); uint32_t m15nb = unpack_w15_nbs(w0, w1); uint32_t m16nb = unpack_w16_nbs(w0, w1); uint32_t m17nb = unpack_w17base_nbs(w0, w1); if (m14nb & ~W14NBALLM) VERIFY_ERROR("m14nb bad"); if (m15nb & ~W15NBALLM) VERIFY_ERROR("m15nb bad"); if (m16nb & ~W16NBALLM) VERIFY_ERROR("m16nb bad"); if (m17nb & ~W17NBBASM) VERIFY_ERROR("m17nb bad"); m[14] |= m14nb; m[15] |= m15nb; m[16] |= m16nb; m[17] |= m17nb; uint32_t* main_m1 = m; //w18[5]: W15[4] main_m1[18] ^= ((0 ^ (main_m1[15] >> 4)) & 1) << 5; //w19[13]: W15[15] W15[16] W17[14] W17[16] W17[19] main_m1[19] ^= ((0 ^ (main_m1[15] >> 15) ^ (main_m1[15] >> 16) ^ (main_m1[17] >> 14) ^ (main_m1[17] >> 16) ^ (main_m1[17] >> 19)) & 1) << 13; //w19[15] : W14[10] W15[12] W15[13] W16[13] W16[14] W16[15] W17[11] W17[13] W17[16] W17[18] W18[12] W19[10] main_m1[19] ^= ((0 ^ (main_m1[14] >> 10) ^ (main_m1[15] >> 12) ^ (main_m1[15] >> 13) ^ (main_m1[16] >> 13) ^ (main_m1[16] >> 14) ^ (main_m1[16] >> 15) ^ (main_m1[17] >> 11) ^ (main_m1[17] >> 13) ^ (main_m1[17] >> 16) ^ (main_m1[17] >> 18) ^ (main_m1[18] >> 12) ^ (main_m1[19] >> 10)) & 1) << 15; //w19[16] : W17[17] W17[19] main_m1[19] ^= ((0 ^ (main_m1[17] >> 17) ^ (main_m1[17] >> 19)) & 1) << 16; //w19[17] : W16[16] W17[18] W17[19] W18[15] main_m1[19] ^= ((0 ^ (main_m1[16] >> 16) ^ (main_m1[17] >> 18) ^ (main_m1[17] >> 19) ^ (main_m1[18] >> 15)) & 1) << 17; //w19[18] : W17[19] main_m1[19] ^= ((0 ^ (main_m1[17] >> 19)) & 1) << 18; //w20[0] : W16[16] W17[19] W18[15] main_m1[20] ^= ((0 ^ (main_m1[16] >> 16) ^ (main_m1[17] >> 19) ^ (main_m1[18] >> 15)) & 1) << 0; //w20[14] : W15[14] W15[16] W17[18] W17[19] main_m1[20] ^= ((0 ^ (main_m1[15] >> 14) ^ (main_m1[15] >> 16) ^ (main_m1[17] >> 18) ^ (main_m1[17] >> 19)) & 1) << 14; //w20[16] : W15[16] main_m1[20] ^= ((0 ^ (main_m1[15] >> 16)) & 1) << 16; //w20[17] : W15[16] W16[13] W16[15] W17[16] W18[12] main_m1[20] ^= ((0 ^ (main_m1[15] >> 16) ^ (main_m1[16] >> 13) ^ (main_m1[16] >> 15) ^ (main_m1[17] >> 16) ^ (main_m1[18] >> 12)) & 1) << 17; Q[QOFF + 16] -= rotate_left(Q[QOFF + 15], 5); Q[QOFF + 15] += m14nb; Q[QOFF + 16] += rotate_left(Q[QOFF + 15], 5); Q[QOFF + 16] += m15nb; for (int t = 16; t < lastQ; ++t) { sha1_step(t, Q, m); } for (int t = 14; t <= lastQ; ++t) { uint32_t okm = isQokay(t,Q); if (okm != 0) { VERIFY_ERROR("Q" << t << " bad !" << hex << okm << dec); ok = false; } } return ok; } bool verify_Q20(int block, size_t read_idx) { bool ok = true; using namespace host; const int lastQ = 20; uint32_t m[80]; uint32_t Q[85]; // extsol: q15, q16, q17, m14, m15, m16, m17, m18, m19, m20, base_idx size_t base_idx = q20_solutions_buf[block].get<10>(read_idx); Q[QOFF + 12] = base_solutions_buf.get<0>(base_idx); Q[QOFF + 13] = base_solutions_buf.get<1>(base_idx); Q[QOFF + 14] = base_solutions_buf.get<2>(base_idx); Q[QOFF + 15] = q20_solutions_buf[block].get<0>(read_idx); Q[QOFF + 16] = q20_solutions_buf[block].get<1>(read_idx); Q[QOFF + 17] = q20_solutions_buf[block].get<2>(read_idx); m[ 5] = base_solutions_buf.get< 6>(base_idx); m[ 6] = base_solutions_buf.get< 7>(base_idx); m[ 7] = base_solutions_buf.get< 8>(base_idx); m[ 8] = base_solutions_buf.get< 9>(base_idx); m[ 9] = base_solutions_buf.get<10>(base_idx); m[10] = base_solutions_buf.get<11>(base_idx); m[11] = base_solutions_buf.get<12>(base_idx); m[12] = base_solutions_buf.get<13>(base_idx); m[13] = base_solutions_buf.get<14>(base_idx); m[14] = q20_solutions_buf[block].get<3>(read_idx); m[15] = q20_solutions_buf[block].get<4>(read_idx); m[16] = q20_solutions_buf[block].get<5>(read_idx); m[17] = q20_solutions_buf[block].get<6>(read_idx); m[18] = q20_solutions_buf[block].get<7>(read_idx); m[19] = q20_solutions_buf[block].get<8>(read_idx); m[20] = q20_solutions_buf[block].get<9>(read_idx); sha1_me_generalised(m, 5); // compute previous steps for (int t = 16; t >= 0; --t) sha1_step_bw(t, Q, m); for (int t = 17; t < lastQ; ++t) sha1_step(t, Q, m); // verify stateconditions Q-2,...,Q20 for (int t = -4+2; t <= lastQ; ++t) { uint32_t okm = isQokay(t, Q); if (okm != 0) { VERIFY_ERROR("Q" << t << " bad !" << hex << okm << dec); ok = false; } } // verify msgbitrelations // [1200] verify message bitrelations for (unsigned r = 0; r < msgbitrels16_size; ++r) { uint32_t w = msgbitrels16[r][16]; for (unsigned t = mainblockoffset; t < mainblockoffset + 16; ++t) { w ^= m[t] & msgbitrels16[r][t - mainblockoffset]; } if (0 != (hashclash::hw(w) & 1)) { std::cerr << "bitrelation " << r << " is not satisfied!" << std::endl; print_convert_msgbitrel(msgbitrels16[r], 1, 5); return false; } } return ok; } bool verify_Q21_Q26(int block, size_t read_idx, int lastQ, uint32_t w0, uint32_t w1) { bool ok = true; using namespace host; uint32_t m[80]; uint32_t Q[85]; size_t ext_idx = unpack_idx(w0,w1); size_t base_idx = q20_solutions_buf[block].get<10>(ext_idx); Q[QOFF + 12] = base_solutions_buf.get<0>(base_idx); Q[QOFF + 13] = base_solutions_buf.get<1>(base_idx); Q[QOFF + 14] = base_solutions_buf.get<2>(base_idx); Q[QOFF + 15] = q20_solutions_buf[block].get<0>(ext_idx); Q[QOFF + 16] = q20_solutions_buf[block].get<1>(ext_idx); Q[QOFF + 17] = q20_solutions_buf[block].get<2>(ext_idx); m[ 5] = base_solutions_buf.get< 6>(base_idx); m[ 6] = base_solutions_buf.get< 7>(base_idx); m[ 7] = base_solutions_buf.get< 8>(base_idx); m[ 8] = base_solutions_buf.get< 9>(base_idx); m[ 9] = base_solutions_buf.get<10>(base_idx); m[10] = base_solutions_buf.get<11>(base_idx); m[11] = base_solutions_buf.get<12>(base_idx); m[12] = base_solutions_buf.get<13>(base_idx); m[13] = base_solutions_buf.get<14>(base_idx); m[14] = q20_solutions_buf[block].get<3>(ext_idx); m[15] = q20_solutions_buf[block].get<4>(ext_idx); m[16] = q20_solutions_buf[block].get<5>(ext_idx); m[17] = q20_solutions_buf[block].get<6>(ext_idx); m[18] = q20_solutions_buf[block].get<7>(ext_idx); m[19] = q20_solutions_buf[block].get<8>(ext_idx); m[20] = q20_solutions_buf[block].get<9>(ext_idx); m[17] ^= unpack_w17ext_nbs(w0,w1); m[18] ^= unpack_w18_nbs(w0,w1); m[19] &= ~W19NBPACKM; m[19] ^= unpack_w19_nbs_fb(w0,w1); m[20] &= ~W20NBPACKM; m[20] ^= unpack_w20_nbs_fb(w0,w1); sha1_me_generalised(m, 5); for (int t = 17; t < lastQ; ++t) { sha1_step(t, Q, m); } for (int t = 14; t <= lastQ; ++t) { uint32_t okm = isQokay(t,Q); if (okm != 0) { VERIFY_ERROR("Q" << t << " bad !" << hex << okm << dec); ok = false; } } // verify msgbitrelations // [1200] verify message bitrelations for (unsigned r = 0; r < msgbitrels16_size; ++r) { uint32_t w = msgbitrels16[r][16]; for (unsigned t = mainblockoffset; t < mainblockoffset + 16; ++t) { w ^= m[t] & msgbitrels16[r][t - mainblockoffset]; } if (0 != (hc::hw(w) & 1)) { std::cout << "bitrelation " << r << " is not satisfied!" << std::endl; print_convert_msgbitrel(msgbitrels16[r], 1, 4); return false; } } return ok; } bool verify_Q27_Q30(int block, size_t read_idx, int lastQ, uint32_t w0, uint32_t w1, uint32_t q112boom) { bool ok = true; using namespace host; uint32_t m[80]; uint32_t Q[85]; size_t ext_idx = unpack_idx(w0,w1); size_t base_idx = q20_solutions_buf[block].get<10>(ext_idx); Q[QOFF + 12] = base_solutions_buf.get<0>(base_idx); Q[QOFF + 13] = base_solutions_buf.get<1>(base_idx); Q[QOFF + 14] = base_solutions_buf.get<2>(base_idx); Q[QOFF + 15] = q20_solutions_buf[block].get<0>(ext_idx); Q[QOFF + 16] = q20_solutions_buf[block].get<1>(ext_idx); Q[QOFF + 17] = q20_solutions_buf[block].get<2>(ext_idx); m[ 5] = base_solutions_buf.get< 6>(base_idx); m[ 6] = base_solutions_buf.get< 7>(base_idx); m[ 7] = base_solutions_buf.get< 8>(base_idx); m[ 8] = base_solutions_buf.get< 9>(base_idx); m[ 9] = base_solutions_buf.get<10>(base_idx); m[10] = base_solutions_buf.get<11>(base_idx); m[11] = base_solutions_buf.get<12>(base_idx); m[12] = base_solutions_buf.get<13>(base_idx); m[13] = base_solutions_buf.get<14>(base_idx); m[14] = q20_solutions_buf[block].get<3>(ext_idx); m[15] = q20_solutions_buf[block].get<4>(ext_idx); m[16] = q20_solutions_buf[block].get<5>(ext_idx); m[17] = q20_solutions_buf[block].get<6>(ext_idx); m[18] = q20_solutions_buf[block].get<7>(ext_idx); m[19] = q20_solutions_buf[block].get<8>(ext_idx); m[20] = q20_solutions_buf[block].get<9>(ext_idx); m[17] ^= unpack_w17ext_nbs(w0,w1); m[18] ^= unpack_w18_nbs(w0,w1); m[19] &= ~W19NBPACKM; m[19] ^= unpack_w19_nbs_fb(w0,w1); m[20] &= ~W20NBPACKM; m[20] ^= unpack_w20_nbs_fb(w0,w1); uint32_t q11boom = q112boom & Q11BOOMS; uint32_t q12boom = (q112boom>>16) & Q12BOOMS; m[10] ^= q11boom; m[11] ^= q11boom<<5; m[14] ^= (q11boom>>2)&(1<<6); m[15] ^= q11boom>>2; m[11] ^= q12boom; m[12] ^= q12boom<<5; m[16] ^= q12boom>>2; sha1_me_generalised(m, 5); for (int t = 17; t < lastQ; ++t) { sha1_step(t, Q, m); } for (int t = 14; t <= lastQ; ++t) { uint32_t okm = isQokay(t,Q); if (okm != 0) { VERIFY_ERROR("Q" << t << " bad !" << hex << okm << dec); ok = false; } } // verify msgbitrelations // [1200] verify message bitrelations for (unsigned r = 0; r < msgbitrels16_size; ++r) { uint32_t w = msgbitrels16[r][16]; for (unsigned t = mainblockoffset; t < mainblockoffset + 16; ++t) { w ^= m[t] & msgbitrels16[r][t - mainblockoffset]; } if (0 != (hc::hw(w) & 1)) { std::cout << "bitrelation " << r << " is not satisfied!" << std::endl; print_convert_msgbitrel(msgbitrels16[r], 1, 4); return false; } } return ok; } void verify_step_computations(int cuda_blocks) { for (unsigned block = 0; block < cuda_blocks; ++block) { cout << "======== Verifying block " << block << endl; /* cout << "Base solutions left: " << (base_solutions_ctl.write_idx - base_solutions_ctl.read_idx) << setfill(' ') << endl; size_t q18checked = 0, q18ok = 0; uint32_t q18count = q18_solutions_ctl_bu[block].write_idx - q18_solutions_ctl_bu[block].read_idx; cout << q18_solutions_ctl_bu[block].read_idx << " " << q18_solutions_ctl_bu[block].write_idx << " " << q18count << endl; for (uint32_t i = q18_solutions_ctl_bu[block].read_idx; i != q18_solutions_ctl_bu[block].write_idx; ++i) { uint32_t w0 = q18_solutions_buf[block].get<0>(i); uint32_t w1 = q18_solutions_buf[block].get<1>(i); if (verify_Q18_Q19(block, i, 18, w0, w1)) ++q18ok; ++q18checked; if (i - q18_solutions_ctl_bu[block].read_idx > q18_solutions_ctl_bu[block].size) break; } cout << "Verified " << setw(10) << q18checked << " out of " << setw(10) << q18count << " Q18 solutions: " << q18ok << " OK" << endl; size_t q19checked = 0, q19ok = 0; uint32_t q19count = q19_solutions_ctl_bu[block].write_idx - q19_solutions_ctl_bu[block].read_idx; for (uint32_t i = q19_solutions_ctl_bu[block].read_idx; i != q19_solutions_ctl_bu[block].write_idx; ++i) { uint32_t w0 = q19_solutions_buf[block].get<0>(i); uint32_t w1 = q19_solutions_buf[block].get<1>(i); if (verify_Q18_Q19(block, i, 19, w0, w1)) ++q19ok; ++q19checked; if (i - q19_solutions_ctl_bu[block].read_idx > q19_solutions_ctl_bu[block].size) break; } cout << "Verified " << setw(10) << q19checked << " out of " << setw(10) << q19count << " Q19 solutions: " << q19ok << " OK" << endl; */ size_t q20checked = 0, q20ok = 0; uint32_t q20count = q20_solutions_ctl_bu[block].write_idx - q20_solutions_ctl_bu[block].read_idx; for (uint32_t i = q20_solutions_ctl_bu[block].read_idx; i != q20_solutions_ctl_bu[block].write_idx; ++i) { if (verify_Q20(block, i)) ++q20ok; ++q20checked; if (i - q20_solutions_ctl_bu[block].read_idx > q20_solutions_ctl_bu[block].size) break; } cout << "Verified " << setw(10) << q20checked << " out of " << setw(10) << q20count << " Q20 solutions: " << q20ok << " OK" << endl; size_t q21checked = 0, q21ok = 0; uint32_t q21count = q21_solutions_ctl_bu[block].write_idx - q21_solutions_ctl_bu[block].read_idx; for (uint32_t i = q21_solutions_ctl_bu[block].read_idx; i != q21_solutions_ctl_bu[block].write_idx; ++i) { uint32_t w0 = q21_solutions_buf[block].get<0>(i); uint32_t w1 = q21_solutions_buf[block].get<1>(i); if (verify_Q21_Q26(block, i, 21, w0, w1)) ++q21ok; ++q21checked; if (i - q21_solutions_ctl_bu[block].read_idx > q21_solutions_ctl_bu[block].size) break; } cout << "Verified " << setw(10) << q21checked << " out of " << setw(10) << q21count << " Q21 solutions: " << q21ok << " OK" << endl; size_t q22checked = 0, q22ok = 0; uint32_t q22count = q22_solutions_ctl_bu[block].write_idx - q22_solutions_ctl_bu[block].read_idx; for (uint32_t i = q22_solutions_ctl_bu[block].read_idx; i != q22_solutions_ctl_bu[block].write_idx; ++i) { uint32_t w0 = q22_solutions_buf[block].get<0>(i); uint32_t w1 = q22_solutions_buf[block].get<1>(i); if (verify_Q21_Q26(block, i, 22, w0, w1)) ++q22ok; ++q22checked; if (i - q22_solutions_ctl_bu[block].read_idx > q22_solutions_ctl_bu[block].size) break; } cout << "Verified " << setw(10) << q22checked << " out of " << setw(10) << q22count << " Q22 solutions: " << q22ok << " OK" << endl; size_t q23checked = 0, q23ok = 0; uint32_t q23count = q23_solutions_ctl_bu[block].write_idx - q23_solutions_ctl_bu[block].read_idx; for (uint32_t i = q23_solutions_ctl_bu[block].read_idx; i != q23_solutions_ctl_bu[block].write_idx; ++i) { uint32_t w0 = q23_solutions_buf[block].get<0>(i); uint32_t w1 = q23_solutions_buf[block].get<1>(i); if (verify_Q21_Q26(block, i, 23, w0, w1)) ++q23ok; ++q23checked; if (i - q23_solutions_ctl_bu[block].read_idx > q23_solutions_ctl_bu[block].size) break; } cout << "Verified " << setw(10) << q23checked << " out of " << setw(10) << q23count << " Q23 solutions: " << q23ok << " OK" << endl; size_t q26checked = 0, q26ok = 0; uint32_t q26count = q26_solutions_ctl_bu[block].write_idx - q26_solutions_ctl_bu[block].read_idx; for (uint32_t i = q26_solutions_ctl_bu[block].read_idx; i != q26_solutions_ctl_bu[block].write_idx; ++i) { uint32_t w0 = q26_solutions_buf[block].get<0>(i); uint32_t w1 = q26_solutions_buf[block].get<1>(i); if (verify_Q21_Q26(block, i, 26, w0, w1)) ++q26ok; ++q26checked; if (i - q26_solutions_ctl_bu[block].read_idx > q26_solutions_ctl_bu[block].size) break; } cout << "Verified " << setw(10) << q26checked << " out of " << setw(10) << q26count << " Q26 solutions: " << q26ok << " OK" << endl; size_t q28checked = 0, q28ok = 0; uint32_t q28count = q28_solutions_ctl_bu[block].write_idx - q28_solutions_ctl_bu[block].read_idx; for (uint32_t i = q28_solutions_ctl_bu[block].read_idx; i != q28_solutions_ctl_bu[block].write_idx; ++i) { uint32_t w0 = q28_solutions_buf[block].get<0>(i); uint32_t w1 = q28_solutions_buf[block].get<1>(i); uint32_t w2 = q28_solutions_buf[block].get<2>(i); if (verify_Q27_Q30(block, i, 28, w0, w1, w2)) ++q28ok; ++q28checked; if (i - q28_solutions_ctl_bu[block].read_idx > q28_solutions_ctl_bu[block].size) break; } cout << "Verified " << setw(10) << q28checked << " out of " << setw(10) << q28count << " Q28 solutions: " << q28ok << " OK" << endl; size_t q30checked = 0, q30ok = 0; uint32_t q30count = q30_solutions_ctl_bu[block].write_idx - q30_solutions_ctl_bu[block].read_idx; for (uint32_t i = q30_solutions_ctl_bu[block].read_idx; i != q30_solutions_ctl_bu[block].write_idx; ++i) { uint32_t w0 = q30_solutions_buf[block].get<0>(i); uint32_t w1 = q30_solutions_buf[block].get<1>(i); uint32_t w2 = q30_solutions_buf[block].get<2>(i); if (verify_Q27_Q30(block, i, 30, w0, w1, w2)) ++q30ok; ++q30checked; if (i - q30_solutions_ctl_bu[block].read_idx > q30_solutions_ctl_bu[block].size) break; } cout << "Verified " << setw(10) << q30checked << " out of " << setw(10) << q30count << " Q30 solutions: " << q30ok << " OK" << endl; } } #endif // VERIFY_GPU_RESULTS
86b7939e728dc4bd11f26bfa079c4600e78d920c.hip
// !!! This is a file automatically generated by hipify!!! #include "morphology2d.cuh" #include <hip/hip_runtime_api.h> #include <stdio.h> #include <vector> #include <nppdefs.h> #include <npp.h> #include <nppi.h> /** cuda error checking helper methods for data copy between host and device and device and host and kernel error check. */ #define CUDA_ERROR_CHECK #define CudaSafeCall( err ) __cudaSafeCall( err, __FILE__, __LINE__ ) #define CudaCheckError() __cudaCheckError( __FILE__, __LINE__ ) inline void __cudaSafeCall( hipError_t err, const char *file, const int line ) { #ifdef CUDA_ERROR_CHECK if ( hipSuccess != err ) { fprintf( stderr, "cudaSafeCall() failed at %s:%i : %s\n", file, line, hipGetErrorString( err ) ); exit( -1 ); } #endif return; } inline void __cudaCheckError( const char *file, const int line ) { #ifdef CUDA_ERROR_CHECK hipError_t err = hipGetLastError(); if ( hipSuccess != err ) { fprintf( stderr, "cudaCheckError() failed at %s:%i : %s\n", file, line, hipGetErrorString( err ) ); exit( -1 ); } err = hipDeviceSynchronize(); if( hipSuccess != err ) { fprintf( stderr, "cudaCheckError() with sync failed at %s:%i : %s\n", file, line, hipGetErrorString( err ) ); exit( -1 ); } #endif return; } /** allocates memory in device and copies data from host memory to padded device memory. */ __host__ void ConvertHostToDevice(uint8_t *inHostSrc, uint32_t inSrcWidth, uint32_t inSrcHeight, uint8_t *&outDeviceDst, size_t &outDstStep) { CudaSafeCall(hipMallocPitch(&outDeviceDst, &outDstStep, inSrcWidth * sizeof(uint8_t), inSrcHeight)); CudaSafeCall(hipMemcpy2D(outDeviceDst, outDstStep, inHostSrc, inSrcWidth * sizeof(uint8_t), inSrcWidth * sizeof(uint8_t), inSrcHeight, hipMemcpyHostToDevice)); } /** allocates memory in device and copies data from host memory to padded device memory. */ __host__ void ConvertHostToDevice(uint8_t *inHostSrc, uint32_t inSrcSize, uint8_t *&outDeviceDst) { CudaSafeCall(hipMalloc(&outDeviceDst, inSrcSize * sizeof(uint8_t))); CudaSafeCall(hipMemcpy(outDeviceDst, inHostSrc, inSrcSize * sizeof(uint8_t), hipMemcpyHostToDevice)); } /** allocates memory in host and copies data from device memory to host memory. */ __host__ void ConvertDeviceToHost(uint8_t *inDeviceSrc, size_t inSrcStep, uint32_t inSrcWidth, uint32_t inSrcHeight, uint8_t *&outHostDst) { outHostDst = (uint8_t*)malloc(inSrcWidth * inSrcHeight); CudaSafeCall(hipMemcpy2D(outHostDst, inSrcWidth * sizeof(uint8_t), inDeviceSrc, inSrcStep, inSrcWidth * sizeof(uint8_t), inSrcHeight, hipMemcpyDeviceToHost)); } /** calculates center of kernel */ __host__ void KernelCenter(NppiSize inKernelSize, NppiPoint &outCenter) { outCenter.x = inKernelSize.width / 2; outCenter.y = inKernelSize.height / 2; } /** calculates radius of kernel */ __host__ void KernelRadius(NppiSize inKernelSize, NppiSize &outRadius) { outRadius.width = (inKernelSize.width - 1) / 2; outRadius.height = (inKernelSize.height - 1) / 2; } /** adds border to border image */ __host__ void AddConstBorderToImage(uint8_t *inDeviceSrc, size_t inSrcstep, NppiSize inSrcSize, NppiSize inPadRadius, uint8_t inPadValue, uint8_t *&outDeviceDst, size_t &outDstStep, NppiSize &outDstSize) { // calculates new size uint32_t width = inSrcSize.width + 2 * inPadRadius.width; uint32_t height = inSrcSize.height + 2 * inPadRadius.height; outDstSize.width = width; outDstSize.height = height; // allocates memory for output CudaSafeCall(hipMallocPitch(&outDeviceDst, &outDstStep, width * sizeof(uint8_t), height)); // adds paddibng to Src nppiCopyConstBorder_8u_C1R(inDeviceSrc, inSrcstep, inSrcSize, outDeviceDst, outDstStep, outDstSize, inPadRadius.height, inPadRadius.width, inPadValue); } /** erosion of 2d image with cons */ void Erode(uint8_t *inSrc, uint32_t inSrcWidth, uint32_t inSrcHeight, uint8_t* inKernel, uint8_t inKernelWidth, uint8_t inKernelHeight, uint8_t *&outDst) { const uint8_t foregroundValue = 1; // copies src to device memory size_t deviceSrcStep; uint8_t* deviceSrc; ConvertHostToDevice(inSrc, inSrcWidth, inSrcHeight, deviceSrc, deviceSrcStep); NppiSize srcSize = {inSrcWidth, inSrcHeight}; // copies kernel to device memory uint8_t* deviceKernel; uint32_t kernelTotalPixels = inKernelWidth * inKernelHeight; ConvertHostToDevice(inKernel, kernelTotalPixels, deviceKernel); NppiSize kernelSize = {inKernelWidth, inKernelHeight}; // adds padding to src for border control NppiSize kernelRadius; KernelRadius(kernelSize, kernelRadius); size_t paddedDeviceSrcStep; uint8_t* paddedDeviceSrc; NppiSize paddedDeviceSrcSize; AddConstBorderToImage(deviceSrc, deviceSrcStep, srcSize, kernelRadius, foregroundValue, paddedDeviceSrc, paddedDeviceSrcStep, paddedDeviceSrcSize); paddedDeviceSrc = paddedDeviceSrc + kernelRadius.height * paddedDeviceSrcStep + kernelRadius.width * sizeof(uint8_t); // allocates memory for output size_t deviceDstStep; uint8_t *deviceDst; CudaSafeCall(hipMallocPitch(&deviceDst, &deviceDstStep, inSrcWidth * sizeof(uint8_t), inSrcHeight)); NppiPoint kernelCenter; KernelCenter(kernelSize, kernelCenter); nppiErode_8u_C1R(paddedDeviceSrc, paddedDeviceSrcStep, deviceDst, deviceDstStep, srcSize, deviceKernel, kernelSize, kernelCenter); CudaCheckError(); ConvertDeviceToHost(deviceDst, deviceDstStep, inSrcWidth, inSrcHeight, outDst); hipFree(deviceDst); hipFree(deviceKernel); } /** 2d erosion of built in npp erode with border control */ void ErodeWithBorderControl(uint8_t *inSrc, uint32_t inSrcWidth, uint32_t inSrcHeight, uint8_t* inKernel, uint8_t inKernelWidth, uint8_t inKernelHeight, uint8_t *&outDst) { // copies src to device memory size_t deviceSrcStep; uint8_t* deviceSrc; ConvertHostToDevice(inSrc, inSrcWidth, inSrcHeight, deviceSrc, deviceSrcStep); NppiSize srcSize = {inSrcWidth, inSrcHeight}; // copies kernel to device memory uint8_t* deviceKernel; uint32_t kernelPixelCount = inKernelWidth * inKernelHeight; ConvertHostToDevice(inKernel, kernelPixelCount, deviceKernel); NppiSize kernelSize = {inKernelWidth, inKernelHeight}; // allocates memory for output size_t deviceDstStep; uint8_t *deviceDst; CudaSafeCall(hipMallocPitch(&deviceDst, &deviceDstStep, inSrcWidth * sizeof(uint8_t), inSrcHeight)); NppiPoint kernelCenter; KernelCenter(kernelSize, kernelCenter); NppiPoint offset = {0, 0}; // erosion nppiErodeBorder_8u_C1R(deviceSrc, deviceSrcStep, srcSize, offset, deviceDst, deviceDstStep, srcSize, deviceKernel, kernelSize, kernelCenter, NPP_BORDER_REPLICATE); CudaCheckError(); ConvertDeviceToHost(deviceDst, deviceDstStep, inSrcWidth, inSrcHeight, outDst); hipFree(deviceDst); hipFree(deviceKernel); } // // __device__ int GetGlobal3dThreadIdx() { // int blockId = blockIdx.x + blockIdx.y * gridDim.x + gridDim.x * gridDim.y * blockIdx.z; // int threadId = blockId * (blockDim.x * blockDim.y * blockDim.z) + (threadIdx.z * (blockDim.x * blockDim.y)) + (threadIdx.y * blockDim.x) + threadIdx.x; // return threadId; // } // // // __device__ bool Erode(int inOrigx, int inOrigy, int inOrigz, // hipPitchedPtr inImg, int inPaddingx, int inPaddingy, int inPaddingz, // hipPitchedPtr inGpuStructElem, int inStructElemRadiusx, int inStructElemRadiusy, int inStructElemRadiusz, // int *inGpuStructElemForegroundDataPosx, int *inGpuStructElemForegroundDataPosy, int *inGpuStructElemForegroundDataPosz, int kernelDimSize) { // // int x = inOrigx + inPaddingx - inStructElemRadiusx; // int y = inOrigy + inPaddingy - inStructElemRadiusy; // int z = inOrigz + inPaddingz - inStructElemRadiusz; // // for (int i = 0; i < kernelDimSize; ++i) { // // // gets kernel pixel // int kx = *(inGpuStructElemForegroundDataPosx + i); // int ky = *(inGpuStructElemForegroundDataPosy + i); // int kz = *(inGpuStructElemForegroundDataPosz + i); // unsigned char kernelPixel = getPixel(inGpuStructElem, kx, ky, kz); // // // gets image pixel // int imx = x + kx; // int imy = y + ky; // int imz = z + kz; // unsigned char imagePixel = getPixel(inImg, imx, imy, imz); // // if (!(kernelPixel && imagePixel)) { // return true; // } // } // return false;and // } // // // __global__ void ImgErosion(hipPitchedPtr inGpuOrigImg, int *inGpuOrigImgForegoundDataPosx, int *inGpuOrigImgForegoundDataPosy, int *inGpuOrigImgForegoundDataPosz, int inImgDimSize, // hipPitchedPtr inPaddedImg, int inPaddingx, int inPaddingy, int inPaddingz, // hipPitchedPtr inGpuStructElem, int inStructElemRadiusx, int inStructElemRadiusy, int inStructElemRadiusz, // int *inGpuStructElemForegroundDataPosx, int *inGpuStructElemForegroundDataPosy, int *inGpuStructElemForegroundDataPosz, int kernelDimSize) { // // int threadId = GetGlobal3dThreadIdx(); // if(threadId < inImgDimSize) { // int x = *(inGpuOrigImgForegoundDataPosx + threadId); // int y = *(inGpuOrigImgForegoundDataPosy + threadId); // int z = *(inGpuOrigImgForegoundDataPosz + threadId); // int isEroded = Erode(x, y, z, inPaddedImg, inPaddingx, inPaddingy, inPaddingz, // inGpuStructElem, inStructElemRadiusx, inStructElemRadiusy, inStructElemRadiusz, // inGpuStructElemForegroundDataPosx, inGpuStructElemForegroundDataPosy, inGpuStructElemForegroundDataPosz, kernelDimSize); // if (isEroded) { // char* devPtr = (char*)inGpuOrigImg.ptr; // size_t pitch = inGpuOrigImg.pitch; // size_t slicePitch = pitch * inGpuOrigImg.ysize; // char* slice = devPtr + z * slicePitch; // unsigned char* row = (unsigned char*)(slice + y * pitch); // row[x] = 0; // } // } // } // __host__ void CopyFromDevice3dToHostMemory(hipPitchedPtr inData, int x, int y, int z, unsigned char *&outData) { // hipExtent extent = make_hipExtent(x * sizeof(unsigned char), y, z); // hipMemcpy3DParms cpyParam = {0}; // cpyParam.srcPtr = inData; // cpyParam.dstPtr = make_hipPitchedPtr( (void*)outData, x * sizeof(unsigned char), y, z); // cpyParam.extent = extent; // cpyParam.kind = hipMemcpyDeviceToHost; // hipMemcpy3D(&cpyParam); } __host__ void CopyFromHostToDevice3dMemory(unsigned char *inData, int x, int y, int z, hipPitchedPtr &outData) { // hipExtent extent = make_hipExtent(x * sizeof(unsigned char), y, z); // hipMalloc3D(&outData, extent); // hipMemcpy3DParms copyParam = {0}; // copyParam.srcPtr = make_hipPitchedPtr( (void*)inData, x * sizeof(unsigned char), y, z ); // copyParam.srcPtr = make_hipPitchedPtr( (void*)inData, x * sizeof(unsigned char), y, z); // copyParam.dstPtr = outData; // copyParam.extent = extent; // copyParam.kind = hipMemcpyHostToDevice; // hipMemcpy3D(&copyParam); } // __device__ unsigned char getPixel(hipPitchedPtr inImg, int x, int y, int z) { // // char* devPtr = (char*)inImg.ptr; // // size_t pitch = inImg.pitch; // // size_t slicePitch = pitch * inImg.ysize; // // char* slice = devPtr + z * slicePitch; // // unsigned char* row = (unsigned char*)(slice + y * pitch); // // return row[x]; // } __global__ void FindBorders(hipPitchedPtr inImgData, int dimX, int dimY, int dimZ, hipPitchedPtr inKernelData, int radiusX, int radiusY, int radiusZ) { // int threadX = blockIdx.x * blockDim.x + threadIdx.x; // int threadY = blockIdx.y * blockDim.y + threadIdx.y; // int threadZ = blockIdx.z * blockDim.z + threadIdx.z; // // if (0 < threadX && dimX > threadX && 0 < threadY && dimY > threadY && 0 < threadZ && dimZ > threadZ) { // unsigned char imgPixel = getPixel(inImgData, threadX, threadY, threadZ); // if (imgPixel == 0) { // int startX = threadX - radiusX; // int startY = threadY - radiusY; // int startZ = threadZ - radiusZ; // // for (int i = startX; i < threadX + 2 * radiusX; ++i) { // for (int j = startY; j < threadY + 2 * radiusY; ++j) { // for (int k = startZ; k < threadZ + 2 * radiusZ; ++k) { // unsigned char compPixel = getPixel(inImgData, k, j, i); // // finds border pixels by comparing if adjacent pixel is foreground // if(compPixel == 1) { // char* devPtr = (char*)inImgData.ptr; // size_t pitch = inImgData.pitch; // size_t slicePitch = pitch * inImgData.ysize; // char* slice = devPtr + threadZ * slicePitch; // unsigned char* row = (unsigned char*)(slice + threadY * pitch); // row[threadX] = 2; // break; // } // } // } // } // } // } } void PaintObjectAndVolImgBorderKernel(unsigned char *inImgData, int inImgDataDims[3], unsigned char *inKernelData, int inKernelRadius[3], unsigned char *&outImgData) { // hipPitchedPtr gpuImgData; // CopyFromHostToDevice3dMemory(inImgData, inImgDataDims[0], inImgDataDims[1], inImgDataDims[2], gpuImgData); // // hipPitchedPtr gpuKernelData; // CopyFromHostToDevice3dMemory(inKernelData, inKernelRadius[0], inKernelRadius[1], inKernelRadius[2], gpuKernelData); // // FindBorders(hipPitchedPtr inImgData, int dimX, int dimY, int dimZ, // // hipPitchedPtr inKernelData, // // int radiusX, int radiusY, int radiusZ) // int tpb0 = (inImgDataDims[0] + 8) / 8 + 1; // int tpb1 = (inImgDataDims[1] + 8) / 8 + 1; // int tpb2 = (inImgDataDims[2] + 8) / 8 + 1; // // dim3 blocks_per_grid(tpb0, tpb1, tpb2); // dim3 threads_per_block(8, 8, 8); // FindBorders<<<blocks_per_grid, threads_per_block>>>(gpuImgData, inImgDataDims[0], inImgDataDims[1], inImgDataDims[2], gpuKernelData, inKernelRadius[0], inKernelRadius[1], inKernelRadius[2]); // CudaCheckError(); // outImgData = (unsigned char*)malloc(inImgDataDims[0] * inImgDataDims[1] * inImgDataDims[2] * sizeof(unsigned char)); // CopyFromDevice3dToHostMemory(gpuImgData, inImgDataDims[0], inImgDataDims[1], inImgDataDims[2], outImgData); // CudaCheckError(); // hipFree(gpuImgData.ptr); // hipFree(gpuKernelData.ptr); } __host__ void GetKernelForegroundIndex(unsigned char* inData, int inDimensions[3], std::vector<int> &x, std::vector<int> &y, std::vector<int> &z) { // int totalSize = inDimensions[0] * inDimensions[1] * inDimensions[2]; // x.reserve(totalSize); // y.reserve(totalSize); // z.reserve(totalSize); // // for (int iz = 0; iz < inDimensions[2]; ++iz) { // for (int iy = 0; iy < inDimensions[1]; ++iy) { // for (int ix = 0; ix < inDimensions[0]; ++ix) { // unsigned char pixel = *(inData + (iz *( inDimensions[0] * inDimensions[1] ) + (iy * inDimensions[0]) + ix)); // if (pixel == 1) { // x.push_back(ix); // y.push_back(iy); // z.push_back(iz); // } // } // } // } } __host__ void CopyFromHostToDeviceMemory(int *inData, int size, int *&outData) { // hipMalloc(&outData, size * sizeof(int)); // hipMemcpy(outData, inData, size * sizeof(int), hipMemcpyHostToDevice); } // // std::vector<int> kernelPosX, kernelPosY, kernelPosZ; // GetKernelForegroundIndex(inKernelData, kernelDims, kernelPosX, kernelPosY, kernelPosZ); // int dimSize = kernelPosX.size(); // printf("%d \n", dimSize); // int *gpuKernelPosX; // CopyFromHostToDeviceMemory(&kernelPosX[0], dimSize, gpuKernelPosX); // int *gpuKernelPosY; // CopyFromHostToDeviceMemory(&kernelPosY[0], dimSize, gpuKernelPosY); // int *gpuKernelPosZ; // CopyFromHostToDeviceMemory(&kernelPosZ[0], dimSize, gpuKernelPosZ); // // int tpb0 = (inImgDataDims[0] + 8) / 8 + 1; // int tpb1 = (inImgDataDims[1] + 8) / 8 + 1; // int tpb2 = (inImgDataDims[2] + 8) / 8 + 1; // // dim3 blocks_per_grid(tpb0, tpb1, tpb2); // dim3 threads_per_block(8, 8, 8); // PaintObject<<<blocks_per_grid, threads_per_block>>>(gpuImgData, inImgDataDims[0], inImgDataDims[1], inImgDataDims[2], kernelDims[0], // kernelDims[1], kernelDims[2], gpuKernelPosX, gpuKernelPosY, gpuKernelPosZ, dimSize, gpuOutImgData); // CudaCheckError(); // outImgData = (unsigned char*)malloc(inImgDataDims[0] * inImgDataDims[1] * inImgDataDims[2] * sizeof(unsigned char)); // CopyFromDevice3dToHostMemory(gpuOutImgData, inImgDataDims[0], inImgDataDims[1], inImgDataDims[2], outImgData); // CudaCheckError(); // // hipFree(gpuImgData.ptr); // hipFree(gpuOutImgData.ptr); // hipFree(gpuKernelPosX); // hipFree(gpuKernelPosY); // hipFree(gpuKernelPosZ); // hipProfilerStop(); //} // // // void Erode(unsigned char *inOrigImg, int inOrigImgDims[3], unsigned char *inStructElem, int inStructElemDims[3], unsigned char *&outErodedImg) { // // // // // // // std::vector<int> origImgForegoundDataPosx; // // std::vector<int> origImgForegoundDataPosy; // // std::vector<int> origImgForegoundDataPosz; // // GetForegroundData(inOrigImg, inOrigImgDims, origImgForegoundDataPosx, origImgForegoundDataPosy, origImgForegoundDataPosz); // // int imgDimSize = origImgForegoundDataPosx.size(); // // // // // moves original image pos data to gpu // // int* gpuOrigImgForegoundDataPosx; // // CopyFromHostToDeviceMemory(&origImgForegoundDataPosx[0], origImgForegoundDataPosx.size(), gpuOrigImgForegoundDataPosx); // // int* gpuOrigImgForegoundDataPosy; // // CopyFromHostToDeviceMemory(&origImgForegoundDataPosy[0], origImgForegoundDataPosy.size(), gpuOrigImgForegoundDataPosy); // // int* gpuOrigImgForegoundDataPosz; // // CopyFromHostToDeviceMemory(&origImgForegoundDataPosz[0], origImgForegoundDataPosz.size(), gpuOrigImgForegoundDataPosz); // // // // // gets foreground pixel pos from kernel // // std::vector<int> structElemForegroundDataPosx; // // std::vector<int> structElemForegroundDataPosy; // // std::vector<int> structElemForegroundDataPosz; // // GetForegroundData(inStructElem, inStructElemDims, structElemForegroundDataPosx, structElemForegroundDataPosy, structElemForegroundDataPosz); // // int kernelDimSize = structElemForegroundDataPosx.size(); // // // // // moves structuring element pos data to gpu // // // // // moves data to gpu // // hipPitchedPtr gpuOrigImg; // // CopyFromHostToDevice3dMemory(inOrigImg, inOrigImgDims[0], inOrigImgDims[1], inOrigImgDims[2], gpuOrigImg); // // hipPitchedPtr gpuPaddedImg; // // CopyFromHostToDevice3dMemory(inPaddedImg, inPaddedImgDims[0], inPaddedImgDims[1], inPaddedImgDims[2], gpuPaddedImg); // // hipPitchedPtr gpuStructElem; // // CopyFromHostToDevice3dMemory(inStructElem, inStructElemDims[0], inStructElemDims[1], inStructElemDims[2], gpuStructElem); // // // // // calculates difference of padded img and original image // // int padding[3]; // // for (auto i = 0; i < 3; ++i) { // // padding[i] = (inPaddedImgDims[i] - inOrigImgDims[i]) / 2; // // } // // // // // calculates kernel radius // // int kernelRadius[3]; // // for (auto i = 0; i < 3; ++i) { // // kernelRadius[i] = (inStructElemDims[i] - 1) / 2; // // } // // printf("%d", origImgForegoundDataPosz.size()); // // int s = ::ceil((double)imgDimSize / 512); // // ImgErosion<<<dim3(s, 1, 1), dim3(8, 8, 8)>>>(gpuOrigImg, gpuOrigImgForegoundDataPosx, gpuOrigImgForegoundDataPosy, gpuOrigImgForegoundDataPosz, imgDimSize, // // gpuPaddedImg, padding[0], padding[1], padding[2], // // gpuStructElem, kernelRadius[0], kernelRadius[1], kernelRadius[2], // // gpuStructElemForegroundDataPosx, gpuStructElemForegroundDataPosy, gpuStructElemForegroundDataPosz, // // kernelDimSize); // // CudaCheckError(); // // outErodedImg = (unsigned cha hipDeviceSynchronize();r*)malloc(inOrigImgDims[0] * inOrigImgDims[1] * inOrigImgDims[2] * sizeof(unsigned char)); // // CopyFromDevice3dToHostMemory(gpuOrigImg, inOrigImgDims[0], inOrigImgDims[1], inOrigImgDims[2], outErodedImg); // // // // hipFree(gpuOrigImg.ptr); // // hipFree(gpuPaddedImg.ptr); // // hipFree(gpuStructElem.ptr); // // hipFree(gpuStructElem.ptr); // // hipFree(gpuOrigImgForegoundDataPosx); // // hipFree(gpuOrigImgForegoundDataPosy); // // hipFree(gpuOrigImgForegoundDataPosz); // // hipFree(gpuStructElemForegroundDataPosx); // // hipFree(gpuStructElemForegroundDataPosy); // // hipFree(gpuStructElemForegroundDataPosz); // // }// int* gpuStructElemForegroundDataPosx; // // CopyFromHostToDeviceMemory(&structElemForegroundDataPosx[0], structElemForegroundDataPosx.size(), gpuStructElemForegroundDataPosx); // // int* gpuStructElemForegroundDataPosy; // // CopyFromHostToDeviceMemory(&structElemForegroundDataPosy[0], structElemForegroundDataPosy.size(), gpuStructElemForegroundDataPosy); // // int* gpuStructElemForegroundDataPosz; // // CopyFromHostToDeviceMemory(&structElemForegroundDataPosz[0], structElemForegroundDataPosz.size(), gpuStructElemForegroundDataPosz); // // // // // moves data to gpu // // hipPitchedPtr gpuOrigImg; // // CopyFromHostToDevice3dMemory(inOrigImg, inOrigImgDims[0], inOrigImgDims[1], inOrigImgDims[2], gpuOrigImg); // // hipPitchedPtr gpuPaddedImg; // // CopyFromHostToDevice3dMemory(inPaddedImg, inPaddedImgDims[0], inPaddedImgDims[1], inPaddedImgDims[2], gpuPaddedImg); // // hipPitchedPtr gpuStructElem; // // CopyFromHostToDevice3dMemory(inStructElem, inStructElemDims[0], inStructElemDims[1], inStructElemDims[2], gpuStructElem); // // // // // calculates difference of padded img and original image // // int padding[3]; // // for (auto i = 0; i < 3; ++i) { // // padding[i] = (inPaddedImgDims[i] - inOrigImgDims[i]) / 2; // // } // // // // // calculates kernel radius // // int kernelRadius[3]; // // for (auto i = 0; i < 3; ++i) { // // kernelRadius[i] = (inStructElemDims[i] - 1) / 2; // // } // // printf("%d", origImgForegoundDataPosz.size()); // // int s = ::ceil((double)imgDimSize / 512); // // ImgErosion<<<dim3(s, 1, 1), dim3(8, 8, 8)>>>(gpuOrigImg, gpuOrigImgForegoundDataPosx, gpuOrigImgForegoundDataPosy, gpuOrigImgForegoundDataPosz, imgDimSize, // // gpuPaddedImg, padding[0], padding[1], padding[2], // // gpuStructElem, kernelRadius[0], kernelRadius[1], kernelRadius[2], // // gpuStructElemForegroundDataPosx, gpuStructElemForegroundDataPosy, gpuStructElemForegroundDataPosz, // // kernelDimSize); // // CudaCheckError(); // // outErodedImg = (unsigned char*)malloc(inOrigImgDims[0] * inOrigImgDims[1] * inOrigImgDims[2] * sizeof(unsigned char)); // // CopyFromDevice3dToHostMemory(gpuOrigImg, inOrigImgDims[0], inOrigImgDims[1], inOrigImgDims[2], outErodedImg); // // // // hipFree(gpuOrigImg.ptr); // // hipFree(gpuPaddedImg.ptr); // // hipFree(gpuStructElem.ptr); // // hipFree(gpuStructElem.ptr); // // hipFree(gpuOrigImgForegoundDataPosx); // // hipFree(gpuOrigImgForegoundDataPosy); // // hipFree(gpuOrigImgForegoundDataPosz); // // hipFree(gpuStructElemForegroundDataPosx); // // hipFree(gpuStructElemForegroundDataPosy); // // hipFree(gpuStructElemForegroundDataPosz); // // }
86b7939e728dc4bd11f26bfa079c4600e78d920c.cu
#include "morphology2d.cuh" #include <cuda_profiler_api.h> #include <stdio.h> #include <vector> #include <nppdefs.h> #include <npp.h> #include <nppi.h> /** cuda error checking helper methods for data copy between host and device and device and host and kernel error check. */ #define CUDA_ERROR_CHECK #define CudaSafeCall( err ) __cudaSafeCall( err, __FILE__, __LINE__ ) #define CudaCheckError() __cudaCheckError( __FILE__, __LINE__ ) inline void __cudaSafeCall( cudaError err, const char *file, const int line ) { #ifdef CUDA_ERROR_CHECK if ( cudaSuccess != err ) { fprintf( stderr, "cudaSafeCall() failed at %s:%i : %s\n", file, line, cudaGetErrorString( err ) ); exit( -1 ); } #endif return; } inline void __cudaCheckError( const char *file, const int line ) { #ifdef CUDA_ERROR_CHECK cudaError err = cudaGetLastError(); if ( cudaSuccess != err ) { fprintf( stderr, "cudaCheckError() failed at %s:%i : %s\n", file, line, cudaGetErrorString( err ) ); exit( -1 ); } err = cudaDeviceSynchronize(); if( cudaSuccess != err ) { fprintf( stderr, "cudaCheckError() with sync failed at %s:%i : %s\n", file, line, cudaGetErrorString( err ) ); exit( -1 ); } #endif return; } /** allocates memory in device and copies data from host memory to padded device memory. */ __host__ void ConvertHostToDevice(uint8_t *inHostSrc, uint32_t inSrcWidth, uint32_t inSrcHeight, uint8_t *&outDeviceDst, size_t &outDstStep) { CudaSafeCall(cudaMallocPitch(&outDeviceDst, &outDstStep, inSrcWidth * sizeof(uint8_t), inSrcHeight)); CudaSafeCall(cudaMemcpy2D(outDeviceDst, outDstStep, inHostSrc, inSrcWidth * sizeof(uint8_t), inSrcWidth * sizeof(uint8_t), inSrcHeight, cudaMemcpyHostToDevice)); } /** allocates memory in device and copies data from host memory to padded device memory. */ __host__ void ConvertHostToDevice(uint8_t *inHostSrc, uint32_t inSrcSize, uint8_t *&outDeviceDst) { CudaSafeCall(cudaMalloc(&outDeviceDst, inSrcSize * sizeof(uint8_t))); CudaSafeCall(cudaMemcpy(outDeviceDst, inHostSrc, inSrcSize * sizeof(uint8_t), cudaMemcpyHostToDevice)); } /** allocates memory in host and copies data from device memory to host memory. */ __host__ void ConvertDeviceToHost(uint8_t *inDeviceSrc, size_t inSrcStep, uint32_t inSrcWidth, uint32_t inSrcHeight, uint8_t *&outHostDst) { outHostDst = (uint8_t*)malloc(inSrcWidth * inSrcHeight); CudaSafeCall(cudaMemcpy2D(outHostDst, inSrcWidth * sizeof(uint8_t), inDeviceSrc, inSrcStep, inSrcWidth * sizeof(uint8_t), inSrcHeight, cudaMemcpyDeviceToHost)); } /** calculates center of kernel */ __host__ void KernelCenter(NppiSize inKernelSize, NppiPoint &outCenter) { outCenter.x = inKernelSize.width / 2; outCenter.y = inKernelSize.height / 2; } /** calculates radius of kernel */ __host__ void KernelRadius(NppiSize inKernelSize, NppiSize &outRadius) { outRadius.width = (inKernelSize.width - 1) / 2; outRadius.height = (inKernelSize.height - 1) / 2; } /** adds border to border image */ __host__ void AddConstBorderToImage(uint8_t *inDeviceSrc, size_t inSrcstep, NppiSize inSrcSize, NppiSize inPadRadius, uint8_t inPadValue, uint8_t *&outDeviceDst, size_t &outDstStep, NppiSize &outDstSize) { // calculates new size uint32_t width = inSrcSize.width + 2 * inPadRadius.width; uint32_t height = inSrcSize.height + 2 * inPadRadius.height; outDstSize.width = width; outDstSize.height = height; // allocates memory for output CudaSafeCall(cudaMallocPitch(&outDeviceDst, &outDstStep, width * sizeof(uint8_t), height)); // adds paddibng to Src nppiCopyConstBorder_8u_C1R(inDeviceSrc, inSrcstep, inSrcSize, outDeviceDst, outDstStep, outDstSize, inPadRadius.height, inPadRadius.width, inPadValue); } /** erosion of 2d image with cons */ void Erode(uint8_t *inSrc, uint32_t inSrcWidth, uint32_t inSrcHeight, uint8_t* inKernel, uint8_t inKernelWidth, uint8_t inKernelHeight, uint8_t *&outDst) { const uint8_t foregroundValue = 1; // copies src to device memory size_t deviceSrcStep; uint8_t* deviceSrc; ConvertHostToDevice(inSrc, inSrcWidth, inSrcHeight, deviceSrc, deviceSrcStep); NppiSize srcSize = {inSrcWidth, inSrcHeight}; // copies kernel to device memory uint8_t* deviceKernel; uint32_t kernelTotalPixels = inKernelWidth * inKernelHeight; ConvertHostToDevice(inKernel, kernelTotalPixels, deviceKernel); NppiSize kernelSize = {inKernelWidth, inKernelHeight}; // adds padding to src for border control NppiSize kernelRadius; KernelRadius(kernelSize, kernelRadius); size_t paddedDeviceSrcStep; uint8_t* paddedDeviceSrc; NppiSize paddedDeviceSrcSize; AddConstBorderToImage(deviceSrc, deviceSrcStep, srcSize, kernelRadius, foregroundValue, paddedDeviceSrc, paddedDeviceSrcStep, paddedDeviceSrcSize); paddedDeviceSrc = paddedDeviceSrc + kernelRadius.height * paddedDeviceSrcStep + kernelRadius.width * sizeof(uint8_t); // allocates memory for output size_t deviceDstStep; uint8_t *deviceDst; CudaSafeCall(cudaMallocPitch(&deviceDst, &deviceDstStep, inSrcWidth * sizeof(uint8_t), inSrcHeight)); NppiPoint kernelCenter; KernelCenter(kernelSize, kernelCenter); nppiErode_8u_C1R(paddedDeviceSrc, paddedDeviceSrcStep, deviceDst, deviceDstStep, srcSize, deviceKernel, kernelSize, kernelCenter); CudaCheckError(); ConvertDeviceToHost(deviceDst, deviceDstStep, inSrcWidth, inSrcHeight, outDst); cudaFree(deviceDst); cudaFree(deviceKernel); } /** 2d erosion of built in npp erode with border control */ void ErodeWithBorderControl(uint8_t *inSrc, uint32_t inSrcWidth, uint32_t inSrcHeight, uint8_t* inKernel, uint8_t inKernelWidth, uint8_t inKernelHeight, uint8_t *&outDst) { // copies src to device memory size_t deviceSrcStep; uint8_t* deviceSrc; ConvertHostToDevice(inSrc, inSrcWidth, inSrcHeight, deviceSrc, deviceSrcStep); NppiSize srcSize = {inSrcWidth, inSrcHeight}; // copies kernel to device memory uint8_t* deviceKernel; uint32_t kernelPixelCount = inKernelWidth * inKernelHeight; ConvertHostToDevice(inKernel, kernelPixelCount, deviceKernel); NppiSize kernelSize = {inKernelWidth, inKernelHeight}; // allocates memory for output size_t deviceDstStep; uint8_t *deviceDst; CudaSafeCall(cudaMallocPitch(&deviceDst, &deviceDstStep, inSrcWidth * sizeof(uint8_t), inSrcHeight)); NppiPoint kernelCenter; KernelCenter(kernelSize, kernelCenter); NppiPoint offset = {0, 0}; // erosion nppiErodeBorder_8u_C1R(deviceSrc, deviceSrcStep, srcSize, offset, deviceDst, deviceDstStep, srcSize, deviceKernel, kernelSize, kernelCenter, NPP_BORDER_REPLICATE); CudaCheckError(); ConvertDeviceToHost(deviceDst, deviceDstStep, inSrcWidth, inSrcHeight, outDst); cudaFree(deviceDst); cudaFree(deviceKernel); } // // __device__ int GetGlobal3dThreadIdx() { // int blockId = blockIdx.x + blockIdx.y * gridDim.x + gridDim.x * gridDim.y * blockIdx.z; // int threadId = blockId * (blockDim.x * blockDim.y * blockDim.z) + (threadIdx.z * (blockDim.x * blockDim.y)) + (threadIdx.y * blockDim.x) + threadIdx.x; // return threadId; // } // // // __device__ bool Erode(int inOrigx, int inOrigy, int inOrigz, // cudaPitchedPtr inImg, int inPaddingx, int inPaddingy, int inPaddingz, // cudaPitchedPtr inGpuStructElem, int inStructElemRadiusx, int inStructElemRadiusy, int inStructElemRadiusz, // int *inGpuStructElemForegroundDataPosx, int *inGpuStructElemForegroundDataPosy, int *inGpuStructElemForegroundDataPosz, int kernelDimSize) { // // int x = inOrigx + inPaddingx - inStructElemRadiusx; // int y = inOrigy + inPaddingy - inStructElemRadiusy; // int z = inOrigz + inPaddingz - inStructElemRadiusz; // // for (int i = 0; i < kernelDimSize; ++i) { // // // gets kernel pixel // int kx = *(inGpuStructElemForegroundDataPosx + i); // int ky = *(inGpuStructElemForegroundDataPosy + i); // int kz = *(inGpuStructElemForegroundDataPosz + i); // unsigned char kernelPixel = getPixel(inGpuStructElem, kx, ky, kz); // // // gets image pixel // int imx = x + kx; // int imy = y + ky; // int imz = z + kz; // unsigned char imagePixel = getPixel(inImg, imx, imy, imz); // // if (!(kernelPixel && imagePixel)) { // return true; // } // } // return false;and // } // // // __global__ void ImgErosion(cudaPitchedPtr inGpuOrigImg, int *inGpuOrigImgForegoundDataPosx, int *inGpuOrigImgForegoundDataPosy, int *inGpuOrigImgForegoundDataPosz, int inImgDimSize, // cudaPitchedPtr inPaddedImg, int inPaddingx, int inPaddingy, int inPaddingz, // cudaPitchedPtr inGpuStructElem, int inStructElemRadiusx, int inStructElemRadiusy, int inStructElemRadiusz, // int *inGpuStructElemForegroundDataPosx, int *inGpuStructElemForegroundDataPosy, int *inGpuStructElemForegroundDataPosz, int kernelDimSize) { // // int threadId = GetGlobal3dThreadIdx(); // if(threadId < inImgDimSize) { // int x = *(inGpuOrigImgForegoundDataPosx + threadId); // int y = *(inGpuOrigImgForegoundDataPosy + threadId); // int z = *(inGpuOrigImgForegoundDataPosz + threadId); // int isEroded = Erode(x, y, z, inPaddedImg, inPaddingx, inPaddingy, inPaddingz, // inGpuStructElem, inStructElemRadiusx, inStructElemRadiusy, inStructElemRadiusz, // inGpuStructElemForegroundDataPosx, inGpuStructElemForegroundDataPosy, inGpuStructElemForegroundDataPosz, kernelDimSize); // if (isEroded) { // char* devPtr = (char*)inGpuOrigImg.ptr; // size_t pitch = inGpuOrigImg.pitch; // size_t slicePitch = pitch * inGpuOrigImg.ysize; // char* slice = devPtr + z * slicePitch; // unsigned char* row = (unsigned char*)(slice + y * pitch); // row[x] = 0; // } // } // } // __host__ void CopyFromDevice3dToHostMemory(cudaPitchedPtr inData, int x, int y, int z, unsigned char *&outData) { // cudaExtent extent = make_cudaExtent(x * sizeof(unsigned char), y, z); // cudaMemcpy3DParms cpyParam = {0}; // cpyParam.srcPtr = inData; // cpyParam.dstPtr = make_cudaPitchedPtr( (void*)outData, x * sizeof(unsigned char), y, z); // cpyParam.extent = extent; // cpyParam.kind = cudaMemcpyDeviceToHost; // cudaMemcpy3D(&cpyParam); } __host__ void CopyFromHostToDevice3dMemory(unsigned char *inData, int x, int y, int z, cudaPitchedPtr &outData) { // cudaExtent extent = make_cudaExtent(x * sizeof(unsigned char), y, z); // cudaMalloc3D(&outData, extent); // cudaMemcpy3DParms copyParam = {0}; // copyParam.srcPtr = make_cudaPitchedPtr( (void*)inData, x * sizeof(unsigned char), y, z ); // copyParam.srcPtr = make_cudaPitchedPtr( (void*)inData, x * sizeof(unsigned char), y, z); // copyParam.dstPtr = outData; // copyParam.extent = extent; // copyParam.kind = cudaMemcpyHostToDevice; // cudaMemcpy3D(&copyParam); } // __device__ unsigned char getPixel(cudaPitchedPtr inImg, int x, int y, int z) { // // char* devPtr = (char*)inImg.ptr; // // size_t pitch = inImg.pitch; // // size_t slicePitch = pitch * inImg.ysize; // // char* slice = devPtr + z * slicePitch; // // unsigned char* row = (unsigned char*)(slice + y * pitch); // // return row[x]; // } __global__ void FindBorders(cudaPitchedPtr inImgData, int dimX, int dimY, int dimZ, cudaPitchedPtr inKernelData, int radiusX, int radiusY, int radiusZ) { // int threadX = blockIdx.x * blockDim.x + threadIdx.x; // int threadY = blockIdx.y * blockDim.y + threadIdx.y; // int threadZ = blockIdx.z * blockDim.z + threadIdx.z; // // if (0 < threadX && dimX > threadX && 0 < threadY && dimY > threadY && 0 < threadZ && dimZ > threadZ) { // unsigned char imgPixel = getPixel(inImgData, threadX, threadY, threadZ); // if (imgPixel == 0) { // int startX = threadX - radiusX; // int startY = threadY - radiusY; // int startZ = threadZ - radiusZ; // // for (int i = startX; i < threadX + 2 * radiusX; ++i) { // for (int j = startY; j < threadY + 2 * radiusY; ++j) { // for (int k = startZ; k < threadZ + 2 * radiusZ; ++k) { // unsigned char compPixel = getPixel(inImgData, k, j, i); // // finds border pixels by comparing if adjacent pixel is foreground // if(compPixel == 1) { // char* devPtr = (char*)inImgData.ptr; // size_t pitch = inImgData.pitch; // size_t slicePitch = pitch * inImgData.ysize; // char* slice = devPtr + threadZ * slicePitch; // unsigned char* row = (unsigned char*)(slice + threadY * pitch); // row[threadX] = 2; // break; // } // } // } // } // } // } } void PaintObjectAndVolImgBorderKernel(unsigned char *inImgData, int inImgDataDims[3], unsigned char *inKernelData, int inKernelRadius[3], unsigned char *&outImgData) { // cudaPitchedPtr gpuImgData; // CopyFromHostToDevice3dMemory(inImgData, inImgDataDims[0], inImgDataDims[1], inImgDataDims[2], gpuImgData); // // cudaPitchedPtr gpuKernelData; // CopyFromHostToDevice3dMemory(inKernelData, inKernelRadius[0], inKernelRadius[1], inKernelRadius[2], gpuKernelData); // // FindBorders(cudaPitchedPtr inImgData, int dimX, int dimY, int dimZ, // // cudaPitchedPtr inKernelData, // // int radiusX, int radiusY, int radiusZ) // int tpb0 = (inImgDataDims[0] + 8) / 8 + 1; // int tpb1 = (inImgDataDims[1] + 8) / 8 + 1; // int tpb2 = (inImgDataDims[2] + 8) / 8 + 1; // // dim3 blocks_per_grid(tpb0, tpb1, tpb2); // dim3 threads_per_block(8, 8, 8); // FindBorders<<<blocks_per_grid, threads_per_block>>>(gpuImgData, inImgDataDims[0], inImgDataDims[1], inImgDataDims[2], gpuKernelData, inKernelRadius[0], inKernelRadius[1], inKernelRadius[2]); // CudaCheckError(); // outImgData = (unsigned char*)malloc(inImgDataDims[0] * inImgDataDims[1] * inImgDataDims[2] * sizeof(unsigned char)); // CopyFromDevice3dToHostMemory(gpuImgData, inImgDataDims[0], inImgDataDims[1], inImgDataDims[2], outImgData); // CudaCheckError(); // cudaFree(gpuImgData.ptr); // cudaFree(gpuKernelData.ptr); } __host__ void GetKernelForegroundIndex(unsigned char* inData, int inDimensions[3], std::vector<int> &x, std::vector<int> &y, std::vector<int> &z) { // int totalSize = inDimensions[0] * inDimensions[1] * inDimensions[2]; // x.reserve(totalSize); // y.reserve(totalSize); // z.reserve(totalSize); // // for (int iz = 0; iz < inDimensions[2]; ++iz) { // for (int iy = 0; iy < inDimensions[1]; ++iy) { // for (int ix = 0; ix < inDimensions[0]; ++ix) { // unsigned char pixel = *(inData + (iz *( inDimensions[0] * inDimensions[1] ) + (iy * inDimensions[0]) + ix)); // if (pixel == 1) { // x.push_back(ix); // y.push_back(iy); // z.push_back(iz); // } // } // } // } } __host__ void CopyFromHostToDeviceMemory(int *inData, int size, int *&outData) { // cudaMalloc(&outData, size * sizeof(int)); // cudaMemcpy(outData, inData, size * sizeof(int), cudaMemcpyHostToDevice); } // // std::vector<int> kernelPosX, kernelPosY, kernelPosZ; // GetKernelForegroundIndex(inKernelData, kernelDims, kernelPosX, kernelPosY, kernelPosZ); // int dimSize = kernelPosX.size(); // printf("%d \n", dimSize); // int *gpuKernelPosX; // CopyFromHostToDeviceMemory(&kernelPosX[0], dimSize, gpuKernelPosX); // int *gpuKernelPosY; // CopyFromHostToDeviceMemory(&kernelPosY[0], dimSize, gpuKernelPosY); // int *gpuKernelPosZ; // CopyFromHostToDeviceMemory(&kernelPosZ[0], dimSize, gpuKernelPosZ); // // int tpb0 = (inImgDataDims[0] + 8) / 8 + 1; // int tpb1 = (inImgDataDims[1] + 8) / 8 + 1; // int tpb2 = (inImgDataDims[2] + 8) / 8 + 1; // // dim3 blocks_per_grid(tpb0, tpb1, tpb2); // dim3 threads_per_block(8, 8, 8); // PaintObject<<<blocks_per_grid, threads_per_block>>>(gpuImgData, inImgDataDims[0], inImgDataDims[1], inImgDataDims[2], kernelDims[0], // kernelDims[1], kernelDims[2], gpuKernelPosX, gpuKernelPosY, gpuKernelPosZ, dimSize, gpuOutImgData); // CudaCheckError(); // outImgData = (unsigned char*)malloc(inImgDataDims[0] * inImgDataDims[1] * inImgDataDims[2] * sizeof(unsigned char)); // CopyFromDevice3dToHostMemory(gpuOutImgData, inImgDataDims[0], inImgDataDims[1], inImgDataDims[2], outImgData); // CudaCheckError(); // // cudaFree(gpuImgData.ptr); // cudaFree(gpuOutImgData.ptr); // cudaFree(gpuKernelPosX); // cudaFree(gpuKernelPosY); // cudaFree(gpuKernelPosZ); // cudaProfilerStop(); //} // // // void Erode(unsigned char *inOrigImg, int inOrigImgDims[3], unsigned char *inStructElem, int inStructElemDims[3], unsigned char *&outErodedImg) { // // // // // // // std::vector<int> origImgForegoundDataPosx; // // std::vector<int> origImgForegoundDataPosy; // // std::vector<int> origImgForegoundDataPosz; // // GetForegroundData(inOrigImg, inOrigImgDims, origImgForegoundDataPosx, origImgForegoundDataPosy, origImgForegoundDataPosz); // // int imgDimSize = origImgForegoundDataPosx.size(); // // // // // moves original image pos data to gpu // // int* gpuOrigImgForegoundDataPosx; // // CopyFromHostToDeviceMemory(&origImgForegoundDataPosx[0], origImgForegoundDataPosx.size(), gpuOrigImgForegoundDataPosx); // // int* gpuOrigImgForegoundDataPosy; // // CopyFromHostToDeviceMemory(&origImgForegoundDataPosy[0], origImgForegoundDataPosy.size(), gpuOrigImgForegoundDataPosy); // // int* gpuOrigImgForegoundDataPosz; // // CopyFromHostToDeviceMemory(&origImgForegoundDataPosz[0], origImgForegoundDataPosz.size(), gpuOrigImgForegoundDataPosz); // // // // // gets foreground pixel pos from kernel // // std::vector<int> structElemForegroundDataPosx; // // std::vector<int> structElemForegroundDataPosy; // // std::vector<int> structElemForegroundDataPosz; // // GetForegroundData(inStructElem, inStructElemDims, structElemForegroundDataPosx, structElemForegroundDataPosy, structElemForegroundDataPosz); // // int kernelDimSize = structElemForegroundDataPosx.size(); // // // // // moves structuring element pos data to gpu // // // // // moves data to gpu // // cudaPitchedPtr gpuOrigImg; // // CopyFromHostToDevice3dMemory(inOrigImg, inOrigImgDims[0], inOrigImgDims[1], inOrigImgDims[2], gpuOrigImg); // // cudaPitchedPtr gpuPaddedImg; // // CopyFromHostToDevice3dMemory(inPaddedImg, inPaddedImgDims[0], inPaddedImgDims[1], inPaddedImgDims[2], gpuPaddedImg); // // cudaPitchedPtr gpuStructElem; // // CopyFromHostToDevice3dMemory(inStructElem, inStructElemDims[0], inStructElemDims[1], inStructElemDims[2], gpuStructElem); // // // // // calculates difference of padded img and original image // // int padding[3]; // // for (auto i = 0; i < 3; ++i) { // // padding[i] = (inPaddedImgDims[i] - inOrigImgDims[i]) / 2; // // } // // // // // calculates kernel radius // // int kernelRadius[3]; // // for (auto i = 0; i < 3; ++i) { // // kernelRadius[i] = (inStructElemDims[i] - 1) / 2; // // } // // printf("%d", origImgForegoundDataPosz.size()); // // int s = std::ceil((double)imgDimSize / 512); // // ImgErosion<<<dim3(s, 1, 1), dim3(8, 8, 8)>>>(gpuOrigImg, gpuOrigImgForegoundDataPosx, gpuOrigImgForegoundDataPosy, gpuOrigImgForegoundDataPosz, imgDimSize, // // gpuPaddedImg, padding[0], padding[1], padding[2], // // gpuStructElem, kernelRadius[0], kernelRadius[1], kernelRadius[2], // // gpuStructElemForegroundDataPosx, gpuStructElemForegroundDataPosy, gpuStructElemForegroundDataPosz, // // kernelDimSize); // // CudaCheckError(); // // outErodedImg = (unsigned cha cudaThreadSynchronize();r*)malloc(inOrigImgDims[0] * inOrigImgDims[1] * inOrigImgDims[2] * sizeof(unsigned char)); // // CopyFromDevice3dToHostMemory(gpuOrigImg, inOrigImgDims[0], inOrigImgDims[1], inOrigImgDims[2], outErodedImg); // // // // cudaFree(gpuOrigImg.ptr); // // cudaFree(gpuPaddedImg.ptr); // // cudaFree(gpuStructElem.ptr); // // cudaFree(gpuStructElem.ptr); // // cudaFree(gpuOrigImgForegoundDataPosx); // // cudaFree(gpuOrigImgForegoundDataPosy); // // cudaFree(gpuOrigImgForegoundDataPosz); // // cudaFree(gpuStructElemForegroundDataPosx); // // cudaFree(gpuStructElemForegroundDataPosy); // // cudaFree(gpuStructElemForegroundDataPosz); // // }// int* gpuStructElemForegroundDataPosx; // // CopyFromHostToDeviceMemory(&structElemForegroundDataPosx[0], structElemForegroundDataPosx.size(), gpuStructElemForegroundDataPosx); // // int* gpuStructElemForegroundDataPosy; // // CopyFromHostToDeviceMemory(&structElemForegroundDataPosy[0], structElemForegroundDataPosy.size(), gpuStructElemForegroundDataPosy); // // int* gpuStructElemForegroundDataPosz; // // CopyFromHostToDeviceMemory(&structElemForegroundDataPosz[0], structElemForegroundDataPosz.size(), gpuStructElemForegroundDataPosz); // // // // // moves data to gpu // // cudaPitchedPtr gpuOrigImg; // // CopyFromHostToDevice3dMemory(inOrigImg, inOrigImgDims[0], inOrigImgDims[1], inOrigImgDims[2], gpuOrigImg); // // cudaPitchedPtr gpuPaddedImg; // // CopyFromHostToDevice3dMemory(inPaddedImg, inPaddedImgDims[0], inPaddedImgDims[1], inPaddedImgDims[2], gpuPaddedImg); // // cudaPitchedPtr gpuStructElem; // // CopyFromHostToDevice3dMemory(inStructElem, inStructElemDims[0], inStructElemDims[1], inStructElemDims[2], gpuStructElem); // // // // // calculates difference of padded img and original image // // int padding[3]; // // for (auto i = 0; i < 3; ++i) { // // padding[i] = (inPaddedImgDims[i] - inOrigImgDims[i]) / 2; // // } // // // // // calculates kernel radius // // int kernelRadius[3]; // // for (auto i = 0; i < 3; ++i) { // // kernelRadius[i] = (inStructElemDims[i] - 1) / 2; // // } // // printf("%d", origImgForegoundDataPosz.size()); // // int s = std::ceil((double)imgDimSize / 512); // // ImgErosion<<<dim3(s, 1, 1), dim3(8, 8, 8)>>>(gpuOrigImg, gpuOrigImgForegoundDataPosx, gpuOrigImgForegoundDataPosy, gpuOrigImgForegoundDataPosz, imgDimSize, // // gpuPaddedImg, padding[0], padding[1], padding[2], // // gpuStructElem, kernelRadius[0], kernelRadius[1], kernelRadius[2], // // gpuStructElemForegroundDataPosx, gpuStructElemForegroundDataPosy, gpuStructElemForegroundDataPosz, // // kernelDimSize); // // CudaCheckError(); // // outErodedImg = (unsigned char*)malloc(inOrigImgDims[0] * inOrigImgDims[1] * inOrigImgDims[2] * sizeof(unsigned char)); // // CopyFromDevice3dToHostMemory(gpuOrigImg, inOrigImgDims[0], inOrigImgDims[1], inOrigImgDims[2], outErodedImg); // // // // cudaFree(gpuOrigImg.ptr); // // cudaFree(gpuPaddedImg.ptr); // // cudaFree(gpuStructElem.ptr); // // cudaFree(gpuStructElem.ptr); // // cudaFree(gpuOrigImgForegoundDataPosx); // // cudaFree(gpuOrigImgForegoundDataPosy); // // cudaFree(gpuOrigImgForegoundDataPosz); // // cudaFree(gpuStructElemForegroundDataPosx); // // cudaFree(gpuStructElemForegroundDataPosy); // // cudaFree(gpuStructElemForegroundDataPosz); // // }
4f8f207ecabded998a79c8d457ca5bd1360ddf34.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include "DeviceFunctions.cuh" #include "stdio.h" __global__ void SequenceArrayDevice(uint* __restrict__ InputArray, const uint size) { uint i = threadIdx.x + blockIdx.x * blockDim.x; while (i < size) { InputArray[i] = i; i += blockDim.x * gridDim.x; } } __global__ void DefaultValueArrayDevice(uint* __restrict__ InputArray, const uint value, const uint size) { uint i = threadIdx.x + blockIdx.x * blockDim.x; while (i < size) { InputArray[i] = value; i += blockDim.x * gridDim.x; } } __global__ void Permutation(const DeviceAABB* __restrict__ Input, DeviceAABB* __restrict__ Output, const uint* __restrict__ permutationIndexes, const uint size) { uint i = threadIdx.x + blockIdx.x * blockDim.x; while (i < size) { Output[i] = Input[permutationIndexes[i]]; i += blockDim.x * gridDim.x; } } namespace CUDALBVH { void AABBPermuntation(DeviceAABB*& inputAABBs, uint*& permutationIDs, uint size) { DeviceAABB* orderedAABBs; hipMalloc(&orderedAABBs, sizeof(DeviceAABB) * size); int blockSize = 0; // The launch configurator returned block size int gridSize = 0; // The actual grid size needed, based on input size GetMaximumOccupancyForFunction(gridSize, blockSize, size, Permutation); Permutation << <gridSize, blockSize >> > (inputAABBs, orderedAABBs, permutationIDs, size); hipFree(inputAABBs); inputAABBs = orderedAABBs; } void AABBPermuntation(DeviceAABB*& inputAABBs, DeviceAABB*& outputAABBs, uint*& permutationIDs, uint size) { int blockSize = 0; // The launch configurator returned block size int gridSize = 0; // The actual grid size needed, based on input size GetMaximumOccupancyForFunction(gridSize, blockSize, size, Permutation); Permutation << <gridSize, blockSize >> > (inputAABBs, outputAABBs, permutationIDs, size); } void SequenceArray(uint*& input, uint size) { int blockSize = 0; // The launch configurator returned block size int gridSize = 0; // The actual grid size needed, based on input size GetMaximumOccupancyForFunction(gridSize, blockSize, size, SequenceArrayDevice); // Initialize an array with a sequence representing the id of the each of the input DeviceAABB SequenceArrayDevice << <gridSize, blockSize >> > (input, size); } void DefaultValueArray(uint*& input, uint value, uint size) { int blockSize = 0; // The launch configurator returned block size int gridSize = 0; // The actual grid size needed, based on input size GetMaximumOccupancyForFunction(gridSize, blockSize, size, DefaultValueArrayDevice); // Initialize an array with a sequence representing the id of the each of the input DeviceAABB DefaultValueArrayDevice << <gridSize, blockSize >> > (input, value, size); } hipError_t checkCuda(hipError_t result) { #if defined(DEBUG) || defined(_DEBUG) if (result != hipSuccess) { fprintf(stderr, "CUDA Runtime Error: %sn", hipGetErrorString(result)); } #endif return result; } }
4f8f207ecabded998a79c8d457ca5bd1360ddf34.cu
#include "DeviceFunctions.cuh" #include "stdio.h" __global__ void SequenceArrayDevice(uint* __restrict__ InputArray, const uint size) { uint i = threadIdx.x + blockIdx.x * blockDim.x; while (i < size) { InputArray[i] = i; i += blockDim.x * gridDim.x; } } __global__ void DefaultValueArrayDevice(uint* __restrict__ InputArray, const uint value, const uint size) { uint i = threadIdx.x + blockIdx.x * blockDim.x; while (i < size) { InputArray[i] = value; i += blockDim.x * gridDim.x; } } __global__ void Permutation(const DeviceAABB* __restrict__ Input, DeviceAABB* __restrict__ Output, const uint* __restrict__ permutationIndexes, const uint size) { uint i = threadIdx.x + blockIdx.x * blockDim.x; while (i < size) { Output[i] = Input[permutationIndexes[i]]; i += blockDim.x * gridDim.x; } } namespace CUDALBVH { void AABBPermuntation(DeviceAABB*& inputAABBs, uint*& permutationIDs, uint size) { DeviceAABB* orderedAABBs; cudaMalloc(&orderedAABBs, sizeof(DeviceAABB) * size); int blockSize = 0; // The launch configurator returned block size int gridSize = 0; // The actual grid size needed, based on input size GetMaximumOccupancyForFunction(gridSize, blockSize, size, Permutation); Permutation << <gridSize, blockSize >> > (inputAABBs, orderedAABBs, permutationIDs, size); cudaFree(inputAABBs); inputAABBs = orderedAABBs; } void AABBPermuntation(DeviceAABB*& inputAABBs, DeviceAABB*& outputAABBs, uint*& permutationIDs, uint size) { int blockSize = 0; // The launch configurator returned block size int gridSize = 0; // The actual grid size needed, based on input size GetMaximumOccupancyForFunction(gridSize, blockSize, size, Permutation); Permutation << <gridSize, blockSize >> > (inputAABBs, outputAABBs, permutationIDs, size); } void SequenceArray(uint*& input, uint size) { int blockSize = 0; // The launch configurator returned block size int gridSize = 0; // The actual grid size needed, based on input size GetMaximumOccupancyForFunction(gridSize, blockSize, size, SequenceArrayDevice); // Initialize an array with a sequence representing the id of the each of the input DeviceAABB SequenceArrayDevice << <gridSize, blockSize >> > (input, size); } void DefaultValueArray(uint*& input, uint value, uint size) { int blockSize = 0; // The launch configurator returned block size int gridSize = 0; // The actual grid size needed, based on input size GetMaximumOccupancyForFunction(gridSize, blockSize, size, DefaultValueArrayDevice); // Initialize an array with a sequence representing the id of the each of the input DeviceAABB DefaultValueArrayDevice << <gridSize, blockSize >> > (input, value, size); } cudaError_t checkCuda(cudaError_t result) { #if defined(DEBUG) || defined(_DEBUG) if (result != cudaSuccess) { fprintf(stderr, "CUDA Runtime Error: %sn", cudaGetErrorString(result)); } #endif return result; } }
a055e05c0d8c70c03c63dca0be66efc7faaf2af0.hip
// !!! This is a file automatically generated by hipify!!! //#include "Timer.cuh" /*#if __cplusplus > 199711L || __GXX_EXPERIMENTAL_CXX0X__ template<> void Timer<HOST>::start() { startTime = std::chrono::system_clock::now(); } template<> void Timer<HOST>::stop() { endTime = std::chrono::system_clock::now(); } template<> float Timer<HOST>::duration() { return std::chrono::duration_cast<std::chrono::microseconds>(endTime - startTime).count() * 1000; } #else*/ template<> inline void Timer<HOST>::start() { gettimeofday(&startTime, NULL); } template<> inline void Timer<HOST>::stop() { gettimeofday(&endTime, NULL); } template<> inline float Timer<HOST>::duration() { int secs(endTime.tv_sec - startTime.tv_sec); int usecs(endTime.tv_usec - startTime.tv_usec); if(usecs < 0) { --secs; usecs += 1000000; } return (secs * 1000 + usecs / 1000.0); //return static_cast<int>(secs * 1000 + usecs / 1000.0 + 0.5); } //#endif template<> inline void Timer<HOST>::getTime(std::string str) { /*Timer<HOST>::stop(); std::cout << Color::FG_L_BLUE << std::setw(W) << str << '\t' << std::fixed << std::setprecision(P) << duration() << " ms" << Color::FG_DEFAULT << std::endl;*/ } template<> inline Timer<HOST>::Timer(int _P, int _W) : P(_P), W(_W) { //Timer<HOST>::start(); } #if defined(__NVCC__) template<> void Timer<DEVICE>::start() { hipEventRecord(startTimeCuda, 0); } template<> void Timer<DEVICE>::stop() { hipEventRecord(stopTimeCuda, 0); hipEventSynchronize(stopTimeCuda); } template<> float Timer<DEVICE>::duration() { float time; hipEventElapsedTime(&time, startTimeCuda, stopTimeCuda); return time; } template<> void Timer<DEVICE>::getTime(std::string str) { Timer<DEVICE>::stop(); std::cout << Color::FG_L_RED << std::setw(W) << str << '\t' << std::fixed << std::setprecision(P) << duration() << " ms" << Color::FG_DEFAULT << std::endl; } template<> void Timer<DEVICE>::getTime(std::string str, const char *file, const int line) { Timer<DEVICE>::getTime(str); hipDeviceSynchronize(); cudaUtil::__getLastCudaError(str.c_str(), file, line); } template<> Timer<DEVICE>::Timer(int _P, int _W) : P(_P), W(_W) { hipEventCreate(&startTimeCuda); hipEventCreate(&stopTimeCuda); //Timer<DEVICE>::start(); } //--------------------------------------------------------------------------------- /* template<> void Timer<DEVICE_H>::start() { gettimeofday(&startTime, NULL); } template<> void Timer<DEVICE_H>::stop() { hipDeviceSynchronize(); gettimeofday(&endTime, NULL); } template<> float Timer<DEVICE_H>::duration() { int secs(endTime.tv_sec - startTime.tv_sec); int usecs(endTime.tv_usec - startTime.tv_usec); if(usecs < 0) { --secs; usecs += 1000000; } return (secs * 1000 + usecs / 1000.0); //return static_cast<int>(secs * 1000 + usecs / 1000.0 + 0.5); } template<> void Timer<DEVICE_H>::getTime(std::string str) { Timer<DEVICE_H>::stop(); std::cout << std::setw(W) << str << '\t' << std::fixed << std::setprecision(P) << duration() << " ms\n"; } template<> Timer<DEVICE_H>::Timer(int _P, int _W) : P(_P), W(_W) { Timer<DEVICE_H>::start(); } template<> void Timer<DEVICE_H>::getTime(std::string str, const char *file, const int line) { Timer<DEVICE_H>::getTime(str); hipDeviceSynchronize(); fUtil::__getLastCudaError(str.c_str(), file, line); }*/ #endif
a055e05c0d8c70c03c63dca0be66efc7faaf2af0.cu
//#include "Timer.cuh" /*#if __cplusplus > 199711L || __GXX_EXPERIMENTAL_CXX0X__ template<> void Timer<HOST>::start() { startTime = std::chrono::system_clock::now(); } template<> void Timer<HOST>::stop() { endTime = std::chrono::system_clock::now(); } template<> float Timer<HOST>::duration() { return std::chrono::duration_cast<std::chrono::microseconds>(endTime - startTime).count() * 1000; } #else*/ template<> inline void Timer<HOST>::start() { gettimeofday(&startTime, NULL); } template<> inline void Timer<HOST>::stop() { gettimeofday(&endTime, NULL); } template<> inline float Timer<HOST>::duration() { int secs(endTime.tv_sec - startTime.tv_sec); int usecs(endTime.tv_usec - startTime.tv_usec); if(usecs < 0) { --secs; usecs += 1000000; } return (secs * 1000 + usecs / 1000.0); //return static_cast<int>(secs * 1000 + usecs / 1000.0 + 0.5); } //#endif template<> inline void Timer<HOST>::getTime(std::string str) { /*Timer<HOST>::stop(); std::cout << Color::FG_L_BLUE << std::setw(W) << str << '\t' << std::fixed << std::setprecision(P) << duration() << " ms" << Color::FG_DEFAULT << std::endl;*/ } template<> inline Timer<HOST>::Timer(int _P, int _W) : P(_P), W(_W) { //Timer<HOST>::start(); } #if defined(__NVCC__) template<> void Timer<DEVICE>::start() { cudaEventRecord(startTimeCuda, 0); } template<> void Timer<DEVICE>::stop() { cudaEventRecord(stopTimeCuda, 0); cudaEventSynchronize(stopTimeCuda); } template<> float Timer<DEVICE>::duration() { float time; cudaEventElapsedTime(&time, startTimeCuda, stopTimeCuda); return time; } template<> void Timer<DEVICE>::getTime(std::string str) { Timer<DEVICE>::stop(); std::cout << Color::FG_L_RED << std::setw(W) << str << '\t' << std::fixed << std::setprecision(P) << duration() << " ms" << Color::FG_DEFAULT << std::endl; } template<> void Timer<DEVICE>::getTime(std::string str, const char *file, const int line) { Timer<DEVICE>::getTime(str); cudaDeviceSynchronize(); cudaUtil::__getLastCudaError(str.c_str(), file, line); } template<> Timer<DEVICE>::Timer(int _P, int _W) : P(_P), W(_W) { cudaEventCreate(&startTimeCuda); cudaEventCreate(&stopTimeCuda); //Timer<DEVICE>::start(); } //--------------------------------------------------------------------------------- /* template<> void Timer<DEVICE_H>::start() { gettimeofday(&startTime, NULL); } template<> void Timer<DEVICE_H>::stop() { cudaDeviceSynchronize(); gettimeofday(&endTime, NULL); } template<> float Timer<DEVICE_H>::duration() { int secs(endTime.tv_sec - startTime.tv_sec); int usecs(endTime.tv_usec - startTime.tv_usec); if(usecs < 0) { --secs; usecs += 1000000; } return (secs * 1000 + usecs / 1000.0); //return static_cast<int>(secs * 1000 + usecs / 1000.0 + 0.5); } template<> void Timer<DEVICE_H>::getTime(std::string str) { Timer<DEVICE_H>::stop(); std::cout << std::setw(W) << str << '\t' << std::fixed << std::setprecision(P) << duration() << " ms\n"; } template<> Timer<DEVICE_H>::Timer(int _P, int _W) : P(_P), W(_W) { Timer<DEVICE_H>::start(); } template<> void Timer<DEVICE_H>::getTime(std::string str, const char *file, const int line) { Timer<DEVICE_H>::getTime(str); cudaDeviceSynchronize(); fUtil::__getLastCudaError(str.c_str(), file, line); }*/ #endif
c1aa5ed489844a4a1908b435908dfd7e33c9ba67.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" // // Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // #include <optix.h> #include <cuda/GeometryData.h> #include <cuda/LocalGeometry.h> #include <cuda/curve.h> #include <cuda/helpers.h> #include <cuda/whitted_cuda.h> #include <sutil/vec_math.h> // Get curve hit-point in world coordinates. static __forceinline__ __device__ float3 getHitPoint() { const float t = optixGetRayTmax(); const float3 rayOrigin = optixGetWorldRayOrigin(); const float3 rayDirection = optixGetWorldRayDirection(); return rayOrigin + t * rayDirection; } // Compute surface normal of quadratic pimitive in world space. static __forceinline__ __device__ float3 normalLinear( const int primitiveIndex ) { const OptixTraversableHandle gas = optixGetGASTraversableHandle(); const unsigned int gasSbtIndex = optixGetSbtGASIndex(); float4 controlPoints[2]; optixGetLinearCurveVertexData( gas, primitiveIndex, gasSbtIndex, 0.0f, controlPoints ); LinearBSplineSegment interpolator( controlPoints ); float3 hitPoint = getHitPoint(); // interpolators work in object space hitPoint = optixTransformPointFromWorldToObjectSpace( hitPoint ); const float3 normal = surfaceNormal( interpolator, optixGetCurveParameter(), hitPoint ); return optixTransformNormalFromObjectToWorldSpace( normal ); } // Compute surface normal of quadratic pimitive in world space. static __forceinline__ __device__ float3 normalQuadratic( const int primitiveIndex ) { const OptixTraversableHandle gas = optixGetGASTraversableHandle(); const unsigned int gasSbtIndex = optixGetSbtGASIndex(); float4 controlPoints[3]; optixGetQuadraticBSplineVertexData( gas, primitiveIndex, gasSbtIndex, 0.0f, controlPoints ); QuadraticBSplineSegment interpolator( controlPoints ); float3 hitPoint = getHitPoint(); // interpolators work in object space hitPoint = optixTransformPointFromWorldToObjectSpace( hitPoint ); const float3 normal = surfaceNormal( interpolator, optixGetCurveParameter(), hitPoint ); return optixTransformNormalFromObjectToWorldSpace( normal ); } // Compute surface normal of cubic pimitive in world space. static __forceinline__ __device__ float3 normalCubic( const int primitiveIndex ) { const OptixTraversableHandle gas = optixGetGASTraversableHandle(); const unsigned int gasSbtIndex = optixGetSbtGASIndex(); float4 controlPoints[4]; optixGetCubicBSplineVertexData( gas, primitiveIndex, gasSbtIndex, 0.0f, controlPoints ); CubicBSplineSegment interpolator( controlPoints ); float3 hitPoint = getHitPoint(); // interpolators work in object space hitPoint = optixTransformPointFromWorldToObjectSpace( hitPoint ); const float3 normal = surfaceNormal( interpolator, optixGetCurveParameter(), hitPoint ); return optixTransformNormalFromObjectToWorldSpace( normal ); } static __forceinline__ __device__ float3 shade( const whitted::HitGroupData* hitGroupData, const float3 hitPoint, const float3 normal, const float3 base_color ) { // // Retrieve material data // float metallic = hitGroupData->material_data.pbr.metallic; float roughness = hitGroupData->material_data.pbr.roughness; // // Convert to material params // const float F0 = 0.04f; const float3 diff_color = base_color * ( 1.0f - F0 ) * ( 1.0f - metallic ); const float3 spec_color = lerp( make_float3( F0 ), base_color, metallic ); const float alpha = roughness * roughness; float3 result = make_float3( 0.0f ); for( int i = 0; i < whitted::params.lights.count; ++i ) { Light light = whitted::params.lights[i]; if( light.type == Light::Type::POINT ) { const float L_dist = length( light.point.position - hitPoint ); const float3 L = ( light.point.position - hitPoint ) / L_dist; const float3 V = -normalize( optixGetWorldRayDirection() ); const float3 H = normalize( L + V ); const float N_dot_L = dot( normal, L ); const float N_dot_V = dot( normal, V ); const float N_dot_H = dot( normal, H ); const float V_dot_H = dot( V, H ); if( N_dot_L > 0.0f && N_dot_V > 0.0f ) { const float tmin = 0.001f; // TODO const float tmax = L_dist - 0.001f; // TODO const bool occluded = whitted::traceOcclusion( whitted::params.handle, hitPoint, L, tmin, tmax ); if( !occluded ) { const float3 F = whitted::schlick( spec_color, V_dot_H ); const float G_vis = whitted::vis( N_dot_L, N_dot_V, alpha ); const float D = whitted::ggxNormal( N_dot_H, alpha ); const float3 diff = ( 1.0f - F ) * diff_color / M_PIf; const float3 spec = F * G_vis * D; result += light.point.color * light.point.intensity * N_dot_L * ( diff + spec ); } } } } return result; } // Get u-parameter for full strand. // // Parameters: // geo - the GeometricData from the SBT. // primitiveIndex - the primitive index // static __forceinline__ __device__ float getStrandU( const GeometryData& geo, const int primitiveIndex ) { float segmentU = optixGetCurveParameter(); float2 strandInfo = geo.curves.strand_u[primitiveIndex]; // strandInfo.x ~ strand u at segment start // strandInfo.y ~ scale factor (i.e. 1/numberOfSegments) return strandInfo.x + segmentU * strandInfo.y; } // Compute normal // static __forceinline__ __device__ float3 computeNormal( OptixPrimitiveType type, const int primitiveIndex ) { switch( type ) { case OPTIX_PRIMITIVE_TYPE_ROUND_LINEAR: return normalLinear( primitiveIndex ); break; case OPTIX_PRIMITIVE_TYPE_ROUND_QUADRATIC_BSPLINE: return normalQuadratic( primitiveIndex ); break; case OPTIX_PRIMITIVE_TYPE_ROUND_CUBIC_BSPLINE: return normalCubic( primitiveIndex ); break; } return make_float3(0.0f); } extern "C" __global__ void __closesthit__curve_strand_u() { const unsigned int primitiveIndex = optixGetPrimitiveIndex(); const whitted::HitGroupData* hitGroupData = reinterpret_cast<whitted::HitGroupData*>( optixGetSbtDataPointer() ); const GeometryData& geometryData = reinterpret_cast<const GeometryData&>( hitGroupData->geometry_data ); const float3 normal = computeNormal( optixGetPrimitiveType(), primitiveIndex ); const float3 colors[2] = {make_float3( 1, 0, 0 ), make_float3( 0, 1, 0 )}; const float u = getStrandU( geometryData, primitiveIndex ); const float3 base_color = colors[0] * u + colors[1] * ( 1 - u ); const float3 hitPoint = getHitPoint(); const float3 result = shade( hitGroupData, hitPoint, normal, base_color ); whitted::setPayloadResult( result ); } extern "C" __global__ void __closesthit__curve_segment_u() { const unsigned int primitiveIndex = optixGetPrimitiveIndex(); const whitted::HitGroupData* hitGroupData = reinterpret_cast<whitted::HitGroupData*>( optixGetSbtDataPointer() ); const float3 normal = computeNormal( optixGetPrimitiveType(), primitiveIndex ); const float3 colors[3] = {make_float3( 1, 0, 0 ), make_float3( 0, 1, 0 ), make_float3( 0, 0, 1 ) }; const float u = optixGetCurveParameter(); float3 base_color; if( u == 0.0f || u == 1.0f ) // on end-cap base_color = colors[2]; else base_color = colors[0] * u + colors[1] * ( 1 - u ); const float3 hitPoint = getHitPoint(); const float3 result = shade( hitGroupData, hitPoint, normal, base_color ); whitted::setPayloadResult( result ); } extern "C" __global__ void __closesthit__curve_strand_idx() { unsigned int primitiveIndex = optixGetPrimitiveIndex(); const whitted::HitGroupData* hitGroupData = reinterpret_cast<whitted::HitGroupData*>( optixGetSbtDataPointer() ); const GeometryData& geometryData = reinterpret_cast<const GeometryData&>( hitGroupData->geometry_data ); float3 normal = computeNormal( optixGetPrimitiveType(), primitiveIndex ); float3 colors[6] = {make_float3( 1, 0, 0 ), make_float3( 0, 1, 0 ), make_float3( 0, 0, 1 ), make_float3( 1, 1, 0 ), make_float3( 1, 0, 1 ), make_float3( 0, 1, 1 )}; unsigned int strandIndex = geometryData.curves.strand_i[primitiveIndex]; uint2 strandInfo = geometryData.curves.strand_info[strandIndex]; float u = ( primitiveIndex - strandInfo.x ) / (float)strandInfo.y; float3 base_color = colors[0] * u + colors[strandIndex % 5 + 1] * ( 1.0f - u ); float3 hitPoint = getHitPoint(); float3 result = shade( hitGroupData, hitPoint, normal, base_color ); whitted::setPayloadResult( result ); }
c1aa5ed489844a4a1908b435908dfd7e33c9ba67.cu
// // Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // #include <optix.h> #include <cuda/GeometryData.h> #include <cuda/LocalGeometry.h> #include <cuda/curve.h> #include <cuda/helpers.h> #include <cuda/whitted_cuda.h> #include <sutil/vec_math.h> // Get curve hit-point in world coordinates. static __forceinline__ __device__ float3 getHitPoint() { const float t = optixGetRayTmax(); const float3 rayOrigin = optixGetWorldRayOrigin(); const float3 rayDirection = optixGetWorldRayDirection(); return rayOrigin + t * rayDirection; } // Compute surface normal of quadratic pimitive in world space. static __forceinline__ __device__ float3 normalLinear( const int primitiveIndex ) { const OptixTraversableHandle gas = optixGetGASTraversableHandle(); const unsigned int gasSbtIndex = optixGetSbtGASIndex(); float4 controlPoints[2]; optixGetLinearCurveVertexData( gas, primitiveIndex, gasSbtIndex, 0.0f, controlPoints ); LinearBSplineSegment interpolator( controlPoints ); float3 hitPoint = getHitPoint(); // interpolators work in object space hitPoint = optixTransformPointFromWorldToObjectSpace( hitPoint ); const float3 normal = surfaceNormal( interpolator, optixGetCurveParameter(), hitPoint ); return optixTransformNormalFromObjectToWorldSpace( normal ); } // Compute surface normal of quadratic pimitive in world space. static __forceinline__ __device__ float3 normalQuadratic( const int primitiveIndex ) { const OptixTraversableHandle gas = optixGetGASTraversableHandle(); const unsigned int gasSbtIndex = optixGetSbtGASIndex(); float4 controlPoints[3]; optixGetQuadraticBSplineVertexData( gas, primitiveIndex, gasSbtIndex, 0.0f, controlPoints ); QuadraticBSplineSegment interpolator( controlPoints ); float3 hitPoint = getHitPoint(); // interpolators work in object space hitPoint = optixTransformPointFromWorldToObjectSpace( hitPoint ); const float3 normal = surfaceNormal( interpolator, optixGetCurveParameter(), hitPoint ); return optixTransformNormalFromObjectToWorldSpace( normal ); } // Compute surface normal of cubic pimitive in world space. static __forceinline__ __device__ float3 normalCubic( const int primitiveIndex ) { const OptixTraversableHandle gas = optixGetGASTraversableHandle(); const unsigned int gasSbtIndex = optixGetSbtGASIndex(); float4 controlPoints[4]; optixGetCubicBSplineVertexData( gas, primitiveIndex, gasSbtIndex, 0.0f, controlPoints ); CubicBSplineSegment interpolator( controlPoints ); float3 hitPoint = getHitPoint(); // interpolators work in object space hitPoint = optixTransformPointFromWorldToObjectSpace( hitPoint ); const float3 normal = surfaceNormal( interpolator, optixGetCurveParameter(), hitPoint ); return optixTransformNormalFromObjectToWorldSpace( normal ); } static __forceinline__ __device__ float3 shade( const whitted::HitGroupData* hitGroupData, const float3 hitPoint, const float3 normal, const float3 base_color ) { // // Retrieve material data // float metallic = hitGroupData->material_data.pbr.metallic; float roughness = hitGroupData->material_data.pbr.roughness; // // Convert to material params // const float F0 = 0.04f; const float3 diff_color = base_color * ( 1.0f - F0 ) * ( 1.0f - metallic ); const float3 spec_color = lerp( make_float3( F0 ), base_color, metallic ); const float alpha = roughness * roughness; float3 result = make_float3( 0.0f ); for( int i = 0; i < whitted::params.lights.count; ++i ) { Light light = whitted::params.lights[i]; if( light.type == Light::Type::POINT ) { const float L_dist = length( light.point.position - hitPoint ); const float3 L = ( light.point.position - hitPoint ) / L_dist; const float3 V = -normalize( optixGetWorldRayDirection() ); const float3 H = normalize( L + V ); const float N_dot_L = dot( normal, L ); const float N_dot_V = dot( normal, V ); const float N_dot_H = dot( normal, H ); const float V_dot_H = dot( V, H ); if( N_dot_L > 0.0f && N_dot_V > 0.0f ) { const float tmin = 0.001f; // TODO const float tmax = L_dist - 0.001f; // TODO const bool occluded = whitted::traceOcclusion( whitted::params.handle, hitPoint, L, tmin, tmax ); if( !occluded ) { const float3 F = whitted::schlick( spec_color, V_dot_H ); const float G_vis = whitted::vis( N_dot_L, N_dot_V, alpha ); const float D = whitted::ggxNormal( N_dot_H, alpha ); const float3 diff = ( 1.0f - F ) * diff_color / M_PIf; const float3 spec = F * G_vis * D; result += light.point.color * light.point.intensity * N_dot_L * ( diff + spec ); } } } } return result; } // Get u-parameter for full strand. // // Parameters: // geo - the GeometricData from the SBT. // primitiveIndex - the primitive index // static __forceinline__ __device__ float getStrandU( const GeometryData& geo, const int primitiveIndex ) { float segmentU = optixGetCurveParameter(); float2 strandInfo = geo.curves.strand_u[primitiveIndex]; // strandInfo.x ~ strand u at segment start // strandInfo.y ~ scale factor (i.e. 1/numberOfSegments) return strandInfo.x + segmentU * strandInfo.y; } // Compute normal // static __forceinline__ __device__ float3 computeNormal( OptixPrimitiveType type, const int primitiveIndex ) { switch( type ) { case OPTIX_PRIMITIVE_TYPE_ROUND_LINEAR: return normalLinear( primitiveIndex ); break; case OPTIX_PRIMITIVE_TYPE_ROUND_QUADRATIC_BSPLINE: return normalQuadratic( primitiveIndex ); break; case OPTIX_PRIMITIVE_TYPE_ROUND_CUBIC_BSPLINE: return normalCubic( primitiveIndex ); break; } return make_float3(0.0f); } extern "C" __global__ void __closesthit__curve_strand_u() { const unsigned int primitiveIndex = optixGetPrimitiveIndex(); const whitted::HitGroupData* hitGroupData = reinterpret_cast<whitted::HitGroupData*>( optixGetSbtDataPointer() ); const GeometryData& geometryData = reinterpret_cast<const GeometryData&>( hitGroupData->geometry_data ); const float3 normal = computeNormal( optixGetPrimitiveType(), primitiveIndex ); const float3 colors[2] = {make_float3( 1, 0, 0 ), make_float3( 0, 1, 0 )}; const float u = getStrandU( geometryData, primitiveIndex ); const float3 base_color = colors[0] * u + colors[1] * ( 1 - u ); const float3 hitPoint = getHitPoint(); const float3 result = shade( hitGroupData, hitPoint, normal, base_color ); whitted::setPayloadResult( result ); } extern "C" __global__ void __closesthit__curve_segment_u() { const unsigned int primitiveIndex = optixGetPrimitiveIndex(); const whitted::HitGroupData* hitGroupData = reinterpret_cast<whitted::HitGroupData*>( optixGetSbtDataPointer() ); const float3 normal = computeNormal( optixGetPrimitiveType(), primitiveIndex ); const float3 colors[3] = {make_float3( 1, 0, 0 ), make_float3( 0, 1, 0 ), make_float3( 0, 0, 1 ) }; const float u = optixGetCurveParameter(); float3 base_color; if( u == 0.0f || u == 1.0f ) // on end-cap base_color = colors[2]; else base_color = colors[0] * u + colors[1] * ( 1 - u ); const float3 hitPoint = getHitPoint(); const float3 result = shade( hitGroupData, hitPoint, normal, base_color ); whitted::setPayloadResult( result ); } extern "C" __global__ void __closesthit__curve_strand_idx() { unsigned int primitiveIndex = optixGetPrimitiveIndex(); const whitted::HitGroupData* hitGroupData = reinterpret_cast<whitted::HitGroupData*>( optixGetSbtDataPointer() ); const GeometryData& geometryData = reinterpret_cast<const GeometryData&>( hitGroupData->geometry_data ); float3 normal = computeNormal( optixGetPrimitiveType(), primitiveIndex ); float3 colors[6] = {make_float3( 1, 0, 0 ), make_float3( 0, 1, 0 ), make_float3( 0, 0, 1 ), make_float3( 1, 1, 0 ), make_float3( 1, 0, 1 ), make_float3( 0, 1, 1 )}; unsigned int strandIndex = geometryData.curves.strand_i[primitiveIndex]; uint2 strandInfo = geometryData.curves.strand_info[strandIndex]; float u = ( primitiveIndex - strandInfo.x ) / (float)strandInfo.y; float3 base_color = colors[0] * u + colors[strandIndex % 5 + 1] * ( 1.0f - u ); float3 hitPoint = getHitPoint(); float3 result = shade( hitGroupData, hitPoint, normal, base_color ); whitted::setPayloadResult( result ); }
57c6373cdf16e72735b3cd4971c751695d8de1c3.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" /* * Simulacion simplificada de bombardeo de particulas de alta energia * * Computacion Paralela (Grado en Informatica) * 2017/2018 * * (c) 2018 Arturo Gonzalez Escribano */ #include<stdio.h> #include<stdlib.h> #include<math.h> #include<cuda.h> #include"cputils.h" #include"kernel.cu" #define PI 3.14159f #define HILOS 128 /* Estructura para almacenar los datos de una tormenta de particulas */ typedef struct { int size; int *posval; } Storm; /* FUNCIONES AUXILIARES: No se utilizan dentro de la medida de tiempo, dejar como estan */ /* Funcion de DEBUG: Imprimir el estado de la capa */ void debug_print(int layer_size, float *layer, int *posiciones, float *maximos, int num_storms ) { int i,k; if ( layer_size <= 35 ) { /* Recorrer capa */ for( k=0; k<layer_size; k++ ) { /* Escribir valor del punto */ printf("%10.4f |", layer[k] ); /* Calcular el numero de caracteres normalizado con el maximo a 60 */ int ticks = (int)( 60 * layer[k] / maximos[num_storms-1] ); /* Escribir todos los caracteres menos el ultimo */ for (i=0; i<ticks-1; i++ ) printf("o"); /* Para maximos locales escribir ultimo caracter especial */ if ( k>0 && k<layer_size-1 && layer[k] > layer[k-1] && layer[k] > layer[k+1] ) printf("x"); else printf("o"); /* Si el punto es uno de los maximos especiales, annadir marca */ for (i=0; i<num_storms; i++) if ( posiciones[i] == k ) printf(" M%d", i ); /* Fin de linea */ printf("\n"); } } } /* * Funcion: Lectura de fichero con datos de tormenta de particulas */ Storm read_storm_file( char *fname ) { FILE *fstorm = cp_abrir_fichero( fname ); if ( fstorm == NULL ) { fprintf(stderr,"Error: Opening storm file %s\n", fname ); exit( EXIT_FAILURE ); } Storm storm; int ok = fscanf(fstorm, "%d", &(storm.size) ); if ( ok != 1 ) { fprintf(stderr,"Error: Reading size of storm file %s\n", fname ); exit( EXIT_FAILURE ); } storm.posval = (int *)malloc( sizeof(int) * storm.size * 2 ); if ( storm.posval == NULL ) { fprintf(stderr,"Error: Allocating memory for storm file %s, with size %d\n", fname, storm.size ); exit( EXIT_FAILURE ); } int elem; for ( elem=0; elem<storm.size; elem++ ) { ok = fscanf(fstorm, "%d %d\n", &(storm.posval[elem*2]), &(storm.posval[elem*2+1]) ); if ( ok != 2 ) { fprintf(stderr,"Error: Reading element %d in storm file %s\n", elem, fname ); exit( EXIT_FAILURE ); } } fclose( fstorm ); return storm; } /* * PROGRAMA PRINCIPAL */ int main(int argc, char *argv[]) { int i,j,k; /* 1.1. Leer argumentos */ if (argc<3) { fprintf(stderr,"Usage: %s <size> <storm_1_file> [ <storm_i_file> ] ... \n", argv[0] ); exit( EXIT_FAILURE ); } int layer_size = atoi( argv[1] ); int num_storms = argc-2; Storm storms[ num_storms ]; /* 1.2. Leer datos de storms */ for( i=2; i<argc; i++ ) storms[i-2] = read_storm_file( argv[i] ); /* 1.3. Inicializar maximos a cero */ float maximos[ num_storms ]; int posiciones[ num_storms ]; for (i=0; i<num_storms; i++) { maximos[i] = 0.0f; posiciones[i] = 0; } /* 2. Inicia medida de tiempo */ hipSetDevice(0); hipDeviceSynchronize(); double ttotal = cp_Wtime(); /* COMIENZO: No optimizar/paralelizar el main por encima de este punto */ float *layer; hipMalloc(&layer, sizeof(float)*layer_size); float *layer_copy; hipMalloc(&layer_copy, sizeof(float)*layer_size); if ( layer == NULL || layer_copy == NULL ) { fprintf(stderr,"Error: Allocating the layer memory\n"); exit( EXIT_FAILURE ); } for( k=0; k<layer_size; k++ ) layer[k] = 0.0f; for( k=0; k<layer_size; k++ ) layer_copy[k] = 0.0f; hipError_t err; float *d_layer; float *d_layerCopy; float *h_max; int *h_pos; hipMalloc(&h_max, sizeof(float)*layer_size); hipMalloc(&h_pos, sizeof(float)*layer_size); err = hipMalloc((void**) &d_layer,layer_size*sizeof(float)); if (err != hipSuccess) printf("CUDA-ERROR 1: %s\n", hipGetErrorString(err)); err = hipMalloc((void**) &d_layerCopy,layer_size*sizeof(float)); if (err != hipSuccess) printf("CUDA-ERROR 2: %s\n", hipGetErrorString(err)); err = hipMemcpy(d_layer, layer, layer_size * sizeof(float), hipMemcpyHostToDevice ); if (err != hipSuccess) printf("CUDA-ERROR 4: %s\n", hipGetErrorString(err)); err = hipMemcpy(d_layerCopy, layer_copy, layer_size * sizeof(float), hipMemcpyHostToDevice ); if (err != hipSuccess) printf("CUDA-ERROR 5: %s\n", hipGetErrorString(err)); float p; int BLOQUES = (1+(layer_size-1)/HILOS); if (BLOQUES<1) BLOQUES=1; for( i=0; i<num_storms; i++) { for (p=0; p<((layer_size));p++){ h_pos[p]=p; } err = hipMemcpy(d_layerCopy, h_pos, ((layer_size))* sizeof(float), hipMemcpyHostToDevice ); if (err != hipSuccess) printf("CUDA-ERROR 6: %s\n", hipGetErrorString(err)); for( j=0; j<storms[i].size; j++ ) { float energia = (float)storms[i].posval[j*2+1] / 1000; int posicion = storms[i].posval[j*2]; hipLaunchKernelGGL(( gpu_Actualizar), dim3(BLOQUES), dim3(HILOS), 0, 0, d_layer, posicion, energia,layer_size); } hipLaunchKernelGGL(( gpu_Copiar), dim3(BLOQUES), dim3(HILOS), 0, 0, d_layer, d_layerCopy,layer_size); hipLaunchKernelGGL(( gpu_Relajacion), dim3(BLOQUES), dim3(HILOS), 0, 0, d_layer, d_layerCopy, layer_size); hipLaunchKernelGGL(( gpu_Copiar), dim3(BLOQUES), dim3(HILOS), 0, 0, d_layer, d_layerCopy, layer_size); // TENEMOS LOS DATOS EN D_LAYER Y EN D_LAYERCOPY // HACEMOS LA COPIA EN LAYER err = hipMemcpy(layer, d_layer, sizeof(float)*layer_size, hipMemcpyDeviceToHost ); if (err != hipSuccess) printf("CUDA-ERROR 8: %s\n", hipGetErrorString(err)); // Usamos D_LAYERCOPY como POSICIONES // Metemos los condidatos en D_LAYER hipLaunchKernelGGL(( gpu_obtenCandidatos), dim3(BLOQUES), dim3(HILOS), 0, 0, d_layerCopy, d_layer, layer_size); for (int redSize = layer_size; redSize>=1; redSize /= 2) { // Usamos LayerCopy como Posiciones hipLaunchKernelGGL(( gpu_reduceMaximo), dim3(BLOQUES), dim3(HILOS), 0, 0, d_layer, d_layerCopy, redSize); } err = hipMemcpy(h_pos, d_layerCopy, sizeof(float)*((layer_size)), hipMemcpyDeviceToHost ); if (err != hipSuccess) printf("CUDA-ERROR 8: %s\n", hipGetErrorString(err)); err = hipMemcpy(h_max, d_layer, sizeof(float)*layer_size, hipMemcpyDeviceToHost ); if (err != hipSuccess) printf("CUDA-ERROR 8: %s\n", hipGetErrorString(err)); maximos[i] = h_max[0]; posiciones[i] = h_pos[0]; err = hipMemcpy(d_layer, layer, sizeof(float)*layer_size, hipMemcpyHostToDevice ); if (err != hipSuccess) printf("CUDA-ERROR 8: %s\n", hipGetErrorString(err)); } //Liberamos memoria err = hipFree(d_layer); if (err != hipSuccess) printf("CUDA-ERROR 9: %s\n",hipGetErrorString(err)); err = hipFree(d_layerCopy); if (err != hipSuccess) printf("CUDA-ERROR 10: %s\n", hipGetErrorString(err)); /* FINAL: No optimizar/paralelizar por debajo de este punto */ /* 6. Final de medida de tiempo */ ttotal = cp_Wtime() - ttotal; /* 7. DEBUG: Dibujar resultado (Solo para capas con hasta 35 puntos) */ #ifdef DEBUG debug_print( layer_size, layer, posiciones, maximos, num_storms ); #endif /* 8. Salida de resultados para tablon */ printf("\n"); /* 8.1. Tiempo total de la computacion */ printf("Time: %lf\n", ttotal ); /* 8.2. Escribir los maximos */ printf("Result:"); for (i=0; i<num_storms; i++) printf(" %d %f", posiciones[i], maximos[i] ); printf("\n"); /* 9. Liberar recursos */ for( i=0; i<argc-2; i++ ) free( storms[i].posval ); /* 10. Final correcto */ return 0; }
57c6373cdf16e72735b3cd4971c751695d8de1c3.cu
/* * Simulacion simplificada de bombardeo de particulas de alta energia * * Computacion Paralela (Grado en Informatica) * 2017/2018 * * (c) 2018 Arturo Gonzalez Escribano */ #include<stdio.h> #include<stdlib.h> #include<math.h> #include<cuda.h> #include"cputils.h" #include"kernel.cu" #define PI 3.14159f #define HILOS 128 /* Estructura para almacenar los datos de una tormenta de particulas */ typedef struct { int size; int *posval; } Storm; /* FUNCIONES AUXILIARES: No se utilizan dentro de la medida de tiempo, dejar como estan */ /* Funcion de DEBUG: Imprimir el estado de la capa */ void debug_print(int layer_size, float *layer, int *posiciones, float *maximos, int num_storms ) { int i,k; if ( layer_size <= 35 ) { /* Recorrer capa */ for( k=0; k<layer_size; k++ ) { /* Escribir valor del punto */ printf("%10.4f |", layer[k] ); /* Calcular el numero de caracteres normalizado con el maximo a 60 */ int ticks = (int)( 60 * layer[k] / maximos[num_storms-1] ); /* Escribir todos los caracteres menos el ultimo */ for (i=0; i<ticks-1; i++ ) printf("o"); /* Para maximos locales escribir ultimo caracter especial */ if ( k>0 && k<layer_size-1 && layer[k] > layer[k-1] && layer[k] > layer[k+1] ) printf("x"); else printf("o"); /* Si el punto es uno de los maximos especiales, annadir marca */ for (i=0; i<num_storms; i++) if ( posiciones[i] == k ) printf(" M%d", i ); /* Fin de linea */ printf("\n"); } } } /* * Funcion: Lectura de fichero con datos de tormenta de particulas */ Storm read_storm_file( char *fname ) { FILE *fstorm = cp_abrir_fichero( fname ); if ( fstorm == NULL ) { fprintf(stderr,"Error: Opening storm file %s\n", fname ); exit( EXIT_FAILURE ); } Storm storm; int ok = fscanf(fstorm, "%d", &(storm.size) ); if ( ok != 1 ) { fprintf(stderr,"Error: Reading size of storm file %s\n", fname ); exit( EXIT_FAILURE ); } storm.posval = (int *)malloc( sizeof(int) * storm.size * 2 ); if ( storm.posval == NULL ) { fprintf(stderr,"Error: Allocating memory for storm file %s, with size %d\n", fname, storm.size ); exit( EXIT_FAILURE ); } int elem; for ( elem=0; elem<storm.size; elem++ ) { ok = fscanf(fstorm, "%d %d\n", &(storm.posval[elem*2]), &(storm.posval[elem*2+1]) ); if ( ok != 2 ) { fprintf(stderr,"Error: Reading element %d in storm file %s\n", elem, fname ); exit( EXIT_FAILURE ); } } fclose( fstorm ); return storm; } /* * PROGRAMA PRINCIPAL */ int main(int argc, char *argv[]) { int i,j,k; /* 1.1. Leer argumentos */ if (argc<3) { fprintf(stderr,"Usage: %s <size> <storm_1_file> [ <storm_i_file> ] ... \n", argv[0] ); exit( EXIT_FAILURE ); } int layer_size = atoi( argv[1] ); int num_storms = argc-2; Storm storms[ num_storms ]; /* 1.2. Leer datos de storms */ for( i=2; i<argc; i++ ) storms[i-2] = read_storm_file( argv[i] ); /* 1.3. Inicializar maximos a cero */ float maximos[ num_storms ]; int posiciones[ num_storms ]; for (i=0; i<num_storms; i++) { maximos[i] = 0.0f; posiciones[i] = 0; } /* 2. Inicia medida de tiempo */ cudaSetDevice(0); cudaDeviceSynchronize(); double ttotal = cp_Wtime(); /* COMIENZO: No optimizar/paralelizar el main por encima de este punto */ float *layer; cudaMalloc(&layer, sizeof(float)*layer_size); float *layer_copy; cudaMalloc(&layer_copy, sizeof(float)*layer_size); if ( layer == NULL || layer_copy == NULL ) { fprintf(stderr,"Error: Allocating the layer memory\n"); exit( EXIT_FAILURE ); } for( k=0; k<layer_size; k++ ) layer[k] = 0.0f; for( k=0; k<layer_size; k++ ) layer_copy[k] = 0.0f; cudaError_t err; float *d_layer; float *d_layerCopy; float *h_max; int *h_pos; cudaMalloc(&h_max, sizeof(float)*layer_size); cudaMalloc(&h_pos, sizeof(float)*layer_size); err = cudaMalloc((void**) &d_layer,layer_size*sizeof(float)); if (err != cudaSuccess) printf("CUDA-ERROR 1: %s\n", cudaGetErrorString(err)); err = cudaMalloc((void**) &d_layerCopy,layer_size*sizeof(float)); if (err != cudaSuccess) printf("CUDA-ERROR 2: %s\n", cudaGetErrorString(err)); err = cudaMemcpy(d_layer, layer, layer_size * sizeof(float), cudaMemcpyHostToDevice ); if (err != cudaSuccess) printf("CUDA-ERROR 4: %s\n", cudaGetErrorString(err)); err = cudaMemcpy(d_layerCopy, layer_copy, layer_size * sizeof(float), cudaMemcpyHostToDevice ); if (err != cudaSuccess) printf("CUDA-ERROR 5: %s\n", cudaGetErrorString(err)); float p; int BLOQUES = (1+(layer_size-1)/HILOS); if (BLOQUES<1) BLOQUES=1; for( i=0; i<num_storms; i++) { for (p=0; p<((layer_size));p++){ h_pos[p]=p; } err = cudaMemcpy(d_layerCopy, h_pos, ((layer_size))* sizeof(float), cudaMemcpyHostToDevice ); if (err != cudaSuccess) printf("CUDA-ERROR 6: %s\n", cudaGetErrorString(err)); for( j=0; j<storms[i].size; j++ ) { float energia = (float)storms[i].posval[j*2+1] / 1000; int posicion = storms[i].posval[j*2]; gpu_Actualizar<<<BLOQUES, HILOS>>>(d_layer, posicion, energia,layer_size); } gpu_Copiar<<<BLOQUES, HILOS>>>(d_layer, d_layerCopy,layer_size); gpu_Relajacion<<<BLOQUES, HILOS>>>(d_layer, d_layerCopy, layer_size); gpu_Copiar<<<BLOQUES, HILOS>>>(d_layer, d_layerCopy, layer_size); // TENEMOS LOS DATOS EN D_LAYER Y EN D_LAYERCOPY // HACEMOS LA COPIA EN LAYER err = cudaMemcpy(layer, d_layer, sizeof(float)*layer_size, cudaMemcpyDeviceToHost ); if (err != cudaSuccess) printf("CUDA-ERROR 8: %s\n", cudaGetErrorString(err)); // Usamos D_LAYERCOPY como POSICIONES // Metemos los condidatos en D_LAYER gpu_obtenCandidatos<<<BLOQUES, HILOS>>>(d_layerCopy, d_layer, layer_size); for (int redSize = layer_size; redSize>=1; redSize /= 2) { // Usamos LayerCopy como Posiciones gpu_reduceMaximo<<<BLOQUES, HILOS>>> (d_layer, d_layerCopy, redSize); } err = cudaMemcpy(h_pos, d_layerCopy, sizeof(float)*((layer_size)), cudaMemcpyDeviceToHost ); if (err != cudaSuccess) printf("CUDA-ERROR 8: %s\n", cudaGetErrorString(err)); err = cudaMemcpy(h_max, d_layer, sizeof(float)*layer_size, cudaMemcpyDeviceToHost ); if (err != cudaSuccess) printf("CUDA-ERROR 8: %s\n", cudaGetErrorString(err)); maximos[i] = h_max[0]; posiciones[i] = h_pos[0]; err = cudaMemcpy(d_layer, layer, sizeof(float)*layer_size, cudaMemcpyHostToDevice ); if (err != cudaSuccess) printf("CUDA-ERROR 8: %s\n", cudaGetErrorString(err)); } //Liberamos memoria err = cudaFree(d_layer); if (err != cudaSuccess) printf("CUDA-ERROR 9: %s\n",cudaGetErrorString(err)); err = cudaFree(d_layerCopy); if (err != cudaSuccess) printf("CUDA-ERROR 10: %s\n", cudaGetErrorString(err)); /* FINAL: No optimizar/paralelizar por debajo de este punto */ /* 6. Final de medida de tiempo */ ttotal = cp_Wtime() - ttotal; /* 7. DEBUG: Dibujar resultado (Solo para capas con hasta 35 puntos) */ #ifdef DEBUG debug_print( layer_size, layer, posiciones, maximos, num_storms ); #endif /* 8. Salida de resultados para tablon */ printf("\n"); /* 8.1. Tiempo total de la computacion */ printf("Time: %lf\n", ttotal ); /* 8.2. Escribir los maximos */ printf("Result:"); for (i=0; i<num_storms; i++) printf(" %d %f", posiciones[i], maximos[i] ); printf("\n"); /* 9. Liberar recursos */ for( i=0; i<argc-2; i++ ) free( storms[i].posval ); /* 10. Final correcto */ return 0; }
ad99b821355ac1244b6d99ac2e46ba6cf111471e.hip
// !!! This is a file automatically generated by hipify!!! /* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <cctype> #include <algorithm> #include <functional> #include <numeric> #include "cm.h" #include "atof.h" #include "compress.cu" #include "sorts.hip" #include "filter.h" #include "callbacks.h" #ifdef _WIN64 #define atoll(S) _atoi64(S) #include <windows.h> #else #include <unistd.h> #endif using namespace std; size_t total_count = 0, total_max; clock_t tot; unsigned int total_segments = 0; unsigned int process_count; size_t alloced_sz = 0; bool fact_file_loaded = 1; bool verbose; bool interactive, ssd, delta, star; void* d_v = nullptr; void* s_v = nullptr; queue<string> op_sort; queue<string> op_presort; queue<string> op_type; bool op_case = 0; queue<string> op_value; queue<int_type> op_nums; queue<float_type> op_nums_f; queue<string> col_aliases; map<string, map<string, col_data> > data_dict; unordered_map<string, unordered_map<unsigned long long int, size_t> > char_hash; map<string, char*> index_buffers; map<string, char*> buffers; map<string, size_t> buffer_sizes; size_t total_buffer_size; queue<string> buffer_names; void* alloced_tmp; bool alloced_switch = 0; map<string,CudaSet*> varNames; // STL map to manage CudaSet variables struct is_match { __host__ __device__ bool operator()(unsigned int x) { return x != 4294967295; } }; struct f_equal_to { __host__ __device__ bool operator()(const float_type x, const float_type y) { return (((x-y) < EPSILON) && ((x-y) > -EPSILON)); } }; struct f_less { __host__ __device__ bool operator()(const float_type x, const float_type y) { return ((y-x) > EPSILON); } }; struct f_greater { __host__ __device__ bool operator()(const float_type x, const float_type y) { return ((x-y) > EPSILON); } }; struct f_greater_equal_to { __host__ __device__ bool operator()(const float_type x, const float_type y) { return (((x-y) > EPSILON) || (((x-y) < EPSILON) && ((x-y) > -EPSILON))); } }; struct f_less_equal { __host__ __device__ bool operator()(const float_type x, const float_type y) { return (((y-x) > EPSILON) || (((x-y) < EPSILON) && ((x-y) > -EPSILON))); } }; struct f_not_equal_to { __host__ __device__ bool operator()(const float_type x, const float_type y) { return ((x-y) > EPSILON) || ((x-y) < -EPSILON); } }; struct long_to_float_type { __host__ __device__ float_type operator()(const int_type x) { return (float_type)x; } }; struct to_zero { __host__ __device__ bool operator()(const int_type x) { if(x == -1) return 0; else return 1; } }; struct div_long_to_float_type { __host__ __device__ float_type operator()(const int_type x, const float_type y) { return (float_type)x/y; } }; char *mystrtok(char **m,char *s,const char c) { char *p=s?s:*m; if( !*p ) return 0; *m=strchr(p,c); if( *m ) *(*m)++=0; else *m=p+strlen(p); return p; } void allocColumns(CudaSet* a, queue<string> fields); void copyColumns(CudaSet* a, queue<string> fields, unsigned int segment, size_t& count, bool rsz, bool flt); void mygather(unsigned int tindex, unsigned int idx, CudaSet* a, CudaSet* t, size_t count, size_t g_size); void mycopy(unsigned int tindex, unsigned int idx, CudaSet* a, CudaSet* t, size_t count, size_t g_size); void write_compressed_char(string file_name, unsigned int index, size_t mCount); size_t getFreeMem(); char zone_map_check(queue<string> op_type, queue<string> op_value, queue<int_type> op_nums,queue<float_type> op_nums_f, CudaSet* a, unsigned int segment); size_t getTotalSystemMemory(); void process_error(int severity, string err); CudaSet::CudaSet(queue<string> &nameRef, queue<string> &typeRef, queue<int> &sizeRef, queue<int> &colsRef, size_t Recs, queue<string> &references, queue<string> &references_names) : mColumnCount(0), mRecCount(0) { initialize(nameRef, typeRef, sizeRef, colsRef, Recs, references, references_names); keep = false; source = 1; text_source = 1; grp = nullptr; fil_f = nullptr; fil_s = nullptr; }; CudaSet::CudaSet(queue<string> &nameRef, queue<string> &typeRef, queue<int> &sizeRef, queue<int> &colsRef, size_t Recs, string file_name, unsigned int max) : mColumnCount(0), mRecCount(0) { maxRecs = max; initialize(nameRef, typeRef, sizeRef, colsRef, Recs, file_name); keep = false; source = 1; text_source = 0; grp = nullptr; fil_f = nullptr; fil_s = nullptr; }; CudaSet::CudaSet(const size_t RecordCount, const unsigned int ColumnCount) { initialize(RecordCount, ColumnCount); keep = false; source = 0; text_source = 0; grp = nullptr; fil_f = nullptr; fil_s = nullptr; }; CudaSet::CudaSet(queue<string> op_sel, const queue<string> op_sel_as) { initialize(op_sel, op_sel_as); keep = false; source = 0; text_source = 0; grp = nullptr; fil_f = nullptr; fil_s = nullptr; }; CudaSet::CudaSet(CudaSet* a, CudaSet* b, queue<string> op_sel, queue<string> op_sel_as) { initialize(a,b, op_sel, op_sel_as); keep = false; source = 0; text_source = 0; grp = nullptr; fil_f = nullptr; fil_s = nullptr; }; CudaSet::~CudaSet() { free(); }; void CudaSet::allocColumnOnDevice(string colname, size_t RecordCount) { if (type[colname] != 1 ) { d_columns_int[colname].resize(RecordCount); } else d_columns_float[colname].resize(RecordCount); }; void CudaSet::resize_join(size_t addRecs) { mRecCount = mRecCount + addRecs; for(unsigned int i=0; i < columnNames.size(); i++) { if(type[columnNames[i]] != 1) { h_columns_int[columnNames[i]].resize(mRecCount); } else h_columns_float[columnNames[i]].resize(mRecCount); }; }; void CudaSet::resize(size_t addRecs) { mRecCount = mRecCount + addRecs; for(unsigned int i=0; i < columnNames.size(); i++) { if(type[columnNames[i]] != 1) { h_columns_int[columnNames[i]].resize(mRecCount); } else { h_columns_float[columnNames[i]].resize(mRecCount); } }; }; void CudaSet::deAllocColumnOnDevice(string colname) { if (type[colname] != 1 && !d_columns_int.empty()) { if(d_columns_int[colname].size() > 0) { d_columns_int[colname].resize(0); d_columns_int[colname].shrink_to_fit(); }; } else if (type[colname] == 1 && !d_columns_float.empty()) { if (d_columns_float[colname].size() > 0) { d_columns_float[colname].resize(0); d_columns_float[colname].shrink_to_fit(); }; }; }; void CudaSet::allocOnDevice(size_t RecordCount) { for(unsigned int i=0; i < columnNames.size(); i++) allocColumnOnDevice(columnNames[i], RecordCount); }; void CudaSet::deAllocOnDevice() { for(unsigned int i=0; i < columnNames.size(); i++) deAllocColumnOnDevice(columnNames[i]); for (auto it=d_columns_int.begin(); it != d_columns_int.end(); ++it ) { if(it->second.size() > 0) { it->second.resize(0); it->second.shrink_to_fit(); }; }; for (auto it=d_columns_float.begin(); it != d_columns_float.end(); ++it ) { if(it->second.size() > 0) { it->second.resize(0); it->second.shrink_to_fit(); }; }; if(grp) { hipFree(grp); grp = nullptr; }; if(filtered) { // free the sources if(varNames.find(source_name) != varNames.end()) { varNames[source_name]->deAllocOnDevice(); }; }; }; void CudaSet::resizeDeviceColumn(size_t RecCount, string colname) { if (type[colname] != 1) { d_columns_int[colname].resize(RecCount); } else d_columns_float[colname].resize(RecCount); }; void CudaSet::resizeDevice(size_t RecCount) { for(unsigned int i=0; i < columnNames.size(); i++) { resizeDeviceColumn(RecCount, columnNames[i]); }; }; bool CudaSet::onDevice(string colname) { if (type[colname] != 1) { if (!d_columns_int.empty() && d_columns_int[colname].size()) return 1; } else if (!d_columns_float.empty() && d_columns_float[colname].size()) return 1; return 0; } CudaSet* CudaSet::copyDeviceStruct() { CudaSet* a = new CudaSet(mRecCount, mColumnCount); a->not_compressed = not_compressed; a->segCount = segCount; a->maxRecs = maxRecs; a->ref_joins = ref_joins; a->ref_sets = ref_sets; a->ref_cols = ref_cols; a->columnNames = columnNames; a->cols = cols; a->type = type; a->char_size = char_size; a->decimal = decimal; for(unsigned int i=0; i < columnNames.size(); i++) { if(a->type[columnNames[i]] == 0) { a->d_columns_int[columnNames[i]] = thrust::device_vector<int_type>(); a->h_columns_int[columnNames[i]] = thrust::host_vector<int_type, uninitialized_host_allocator<int_type> >(); } else if(a->type[columnNames[i]] == 1) { a->d_columns_float[columnNames[i]] = thrust::device_vector<float_type>(); a->h_columns_float[columnNames[i]] = thrust::host_vector<float_type, uninitialized_host_allocator<float_type> >(); } else { a->h_columns_char[columnNames[i]] = nullptr; a->d_columns_char[columnNames[i]] = nullptr; }; }; a->load_file_name = load_file_name; a->mRecCount = 0; return a; } int_type CudaSet::readSsdSegmentsFromFile(unsigned int segNum, string colname, size_t offset, thrust::host_vector<unsigned int>& prm_vh, CudaSet* dest) { string f1 = load_file_name + "." + colname + "." + to_string(segNum); FILE* f = fopen(f1.c_str(), "rb" ); if(!f) { cout << "Error opening " << f1 << " file " << endl; exit(0); }; unsigned int cnt, bits; int_type lower_val; unsigned short int val_s_r[4096/2]; char val_c_r[4096]; unsigned int val_i_r[4096/4]; unsigned long long int val_l_r[4096/8]; unsigned int idx; bool idx_set = 0; fread(&cnt, 4, 1, f); fread(&lower_val, 8, 1, f); fseek(f, cnt - (8+4) + 32, SEEK_CUR); fread(&bits, 4, 1, f); //cout << "lower_val bits " << lower_val << " " << bits << endl; if(type[colname] == 0) { //cout << "lower_val bits " << lower_val << " " << bits << endl; for(unsigned int i = 0; i < prm_vh.size(); i++) { if(!idx_set || prm_vh[i] >= idx + 4096/(bits/8)) { fseek(f, 24 + prm_vh[i]*(bits/8), SEEK_SET); idx = prm_vh[i]; idx_set = 1; if(bits == 8) { fread(&val_c_r[0], 4096, 1, f); dest->h_columns_int[colname][i + offset] = val_c_r[0]; } else if(bits == 16) { fread(&val_s_r, 4096, 1, f); dest->h_columns_int[colname][i + offset] = val_s_r[0]; } if(bits == 32) { fread(&val_i_r, 4096, 1, f); dest->h_columns_int[colname][i + offset] = val_i_r[0]; } if(bits == 84) { fread(&val_l_r, 4096, 1, f); dest->h_columns_int[colname][i + offset] = val_l_r[0]; } } else { if(bits == 8) { dest->h_columns_int[colname][i + offset] = val_c_r[prm_vh[i]-idx]; } else if(bits == 16) { dest->h_columns_int[colname][i + offset] = val_s_r[prm_vh[i]-idx]; } if(bits == 32) { dest->h_columns_int[colname][i + offset] = val_i_r[prm_vh[i]-idx]; } if(bits == 84) { dest->h_columns_int[colname][i + offset] = val_l_r[prm_vh[i]-idx]; } }; }; } else if(type[colname] == 1) { for(unsigned int i = 0; i < prm_vh.size(); i++) { if(!idx_set || prm_vh[i] >= idx + 4096/(bits/8)) { fseek(f, 24 + prm_vh[i]*(bits/8), SEEK_SET); idx = prm_vh[i]; idx_set = 1; fread(val_c_r, 4096, 1, f); memcpy(&dest->h_columns_float[colname][i + offset], &val_c_r[0], bits/8); } else { memcpy(&dest->h_columns_float[colname][i + offset], &val_c_r[(prm_vh[i]-idx)*(bits/8)], bits/8); }; }; } else { //no strings in fact tables }; fclose(f); return lower_val; } int_type CudaSet::readSsdSegmentsFromFileR(unsigned int segNum, string colname, thrust::host_vector<unsigned int>& prm_vh, thrust::host_vector<unsigned int>& dest) { string f1 = load_file_name + "." + colname + "." + to_string(segNum); FILE* f = fopen(f1.c_str(), "rb" ); if(!f) { cout << "Error opening " << f1 << " file " << endl; exit(0); }; unsigned int cnt, bits; int_type lower_val; fread(&cnt, 4, 1, f); fread(&lower_val, 8, 1, f); fseek(f, cnt - (8+4) + 32, SEEK_CUR); fread(&bits, 4, 1, f); unsigned short int val_s_r[4096/2]; char val_c_r[4096]; unsigned int val_i_r[4096/4]; unsigned long long int val_l_r[4096/8]; unsigned int idx; bool idx_set = 0; for(unsigned int i = 0; i < prm_vh.size(); i++) { if(!idx_set || prm_vh[i] >= idx + 4096/(bits/8)) { fseek(f, 24 + prm_vh[i]*(bits/8), SEEK_SET); idx = prm_vh[i]; idx_set = 1; if(bits == 8) { fread(val_c_r, 4096, 1, f); dest[i] = val_c_r[0]; } else if(bits == 16) { fread(val_s_r, 4096, 1, f); dest[i] = val_s_r[0]; } if(bits == 32) { fread(val_i_r, 4096, 1, f); dest[i] = val_i_r[0]; } if(bits == 84) { fread(val_l_r, 4096, 1, f); dest[i] = val_l_r[0]; } } else { if(bits == 8) { dest[i] = val_c_r[prm_vh[i]-idx]; } else if(bits == 16) { dest[i] = val_s_r[prm_vh[i]-idx]; } if(bits == 32) { dest[i] = val_i_r[prm_vh[i]-idx]; } if(bits == 84) { dest[i] = val_l_r[prm_vh[i]-idx]; } }; }; fclose(f); return lower_val; } std::clock_t tot_disk; void CudaSet::readSegmentsFromFile(unsigned int segNum, string colname, size_t offset) { string f1 = load_file_name + "." + colname + "." + to_string(segNum); if(type[colname] == 2) f1 = f1 + ".idx"; std::clock_t start1 = std::clock(); if(interactive) { //check if data are in buffers if(buffers.find(f1) == buffers.end()) { // add data to buffers FILE* f = fopen(f1.c_str(), "rb" ); if(!f) { process_error(3, "Error opening " + string(f1) +" file " ); }; fseek(f, 0, SEEK_END); long fileSize = ftell(f); while(total_buffer_size + fileSize > getTotalSystemMemory() && !buffer_names.empty()) { //free some buffers //delete [] buffers[buffer_names.front()]; hipHostFree(buffers[buffer_names.front()]); total_buffer_size = total_buffer_size - buffer_sizes[buffer_names.front()]; buffer_sizes.erase(buffer_names.front()); buffers.erase(buffer_names.front()); buffer_names.pop(); }; fseek(f, 0, SEEK_SET); char* buff; hipHostMalloc((void**) &buff, fileSize,hipHostMallocDefault); fread(buff, fileSize, 1, f); fclose(f); buffers[f1] = buff; buffer_sizes[f1] = fileSize; buffer_names.push(f1); total_buffer_size = total_buffer_size + fileSize; buffer_names.push(f1); cout << "added buffer " << f1 << " " << fileSize << endl; }; // get data from buffers if(type[colname] != 1) { unsigned int cnt = ((unsigned int*)buffers[f1])[0]; if(cnt > h_columns_int[colname].size()/8 + 10) h_columns_int[colname].resize(cnt/8 + 10); } else { unsigned int cnt = ((unsigned int*)buffers[f1])[0]; if(cnt > h_columns_float[colname].size()/8 + 10) h_columns_float[colname].resize(cnt/8 + 10); } } else { FILE* f = fopen(f1.c_str(), "rb" ); if(!f) { cout << "Error opening " << f1 << " file " << endl; exit(0); }; if(type[colname] != 1) { if(1 > h_columns_int[colname].size()) h_columns_int[colname].resize(1); fread(h_columns_int[colname].data(), 4, 1, f); unsigned int cnt = ((unsigned int*)(h_columns_int[colname].data()))[0]; if(cnt/8+10 > h_columns_int[colname].size()) h_columns_int[colname].resize(cnt + 10); size_t rr = fread((unsigned int*)(h_columns_int[colname].data()) + 1, 1, cnt+52, f); if(rr != cnt+52) { char buf[1024]; sprintf(buf, "Couldn't read %d bytes from %s ,read only", cnt+52, f1.c_str()); process_error(3, string(buf)); }; } else { if(1 > h_columns_float[colname].size()) h_columns_float[colname].resize(1); fread(h_columns_float[colname].data(), 4, 1, f); unsigned int cnt = ((unsigned int*)(h_columns_float[colname].data()))[0]; if(cnt/8+10 > h_columns_float[colname].size()) h_columns_float[colname].resize(cnt + 10); size_t rr = fread((unsigned int*)(h_columns_float[colname].data()) + 1, 1, cnt+52, f); if(rr != cnt+52) { char buf[1024]; sprintf(buf, "Couldn't read %d bytes from %s ,read only", cnt+52, f1.c_str()); process_error(3, string(buf)); }; } fclose(f); }; tot_disk = tot_disk + (std::clock() - start1); }; void CudaSet::CopyColumnToGpu(string colname, unsigned int segment, size_t offset) { if(not_compressed) { // calculate how many records we need to copy if(segment < segCount-1) { mRecCount = maxRecs; } else { mRecCount = hostRecCount - maxRecs*(segCount-1); }; if(type[colname] != 1) { if(!alloced_switch) thrust::copy(h_columns_int[colname].begin() + maxRecs*segment, h_columns_int[colname].begin() + maxRecs*segment + mRecCount, d_columns_int[colname].begin() + offset); else { thrust::device_ptr<int_type> d_col((int_type*)alloced_tmp); thrust::copy(h_columns_int[colname].begin() + maxRecs*segment, h_columns_int[colname].begin() + maxRecs*segment + mRecCount, d_col); }; } else { if(!alloced_switch) { thrust::copy(h_columns_float[colname].begin() + maxRecs*segment, h_columns_float[colname].begin() + maxRecs*segment + mRecCount, d_columns_float[colname].begin() + offset); } else { thrust::device_ptr<float_type> d_col((float_type*)alloced_tmp); thrust::copy(h_columns_float[colname].begin() + maxRecs*segment, h_columns_float[colname].begin() + maxRecs*segment + mRecCount, d_col); }; } } else { readSegmentsFromFile(segment,colname, offset); if(!d_v) CUDA_SAFE_CALL(hipMalloc((void **) &d_v, 12)); if(!s_v) CUDA_SAFE_CALL(hipMalloc((void **) &s_v, 8)); string f1; if(type[colname] == 2) { f1 = load_file_name + "." + colname + "." + to_string(segment) + ".idx"; } else { f1 = load_file_name + "." + colname + "." + to_string(segment); }; if(type[colname] != 1) { if(!alloced_switch) { if(buffers.find(f1) == buffers.end()) { mRecCount = pfor_decompress(thrust::raw_pointer_cast(d_columns_int[colname].data() + offset), h_columns_int[colname].data(), d_v, s_v); } else { mRecCount = pfor_decompress(thrust::raw_pointer_cast(d_columns_int[colname].data() + offset), buffers[f1], d_v, s_v); }; } else { if(buffers.find(f1) == buffers.end()) { mRecCount = pfor_decompress(alloced_tmp, h_columns_int[colname].data(), d_v, s_v); } else { mRecCount = pfor_decompress(alloced_tmp, buffers[f1], d_v, s_v); }; }; } else { if(decimal[colname]) { if(!alloced_switch) { if(buffers.find(f1) == buffers.end()) { mRecCount = pfor_decompress( thrust::raw_pointer_cast(d_columns_float[colname].data() + offset) , h_columns_float[colname].data(), d_v, s_v); } else { mRecCount = pfor_decompress( thrust::raw_pointer_cast(d_columns_float[colname].data() + offset) , buffers[f1], d_v, s_v); }; thrust::device_ptr<long long int> d_col_int((long long int*)thrust::raw_pointer_cast(d_columns_float[colname].data() + offset)); thrust::transform(d_col_int,d_col_int+mRecCount,d_columns_float[colname].begin(), long_to_float()); } else { if(buffers.find(f1) == buffers.end()) { mRecCount = pfor_decompress(alloced_tmp, h_columns_float[colname].data(), d_v, s_v); } else { mRecCount = pfor_decompress(alloced_tmp, buffers[f1], d_v, s_v); }; thrust::device_ptr<long long int> d_col_int((long long int*)alloced_tmp); thrust::device_ptr<float_type> d_col_float((float_type*)alloced_tmp); thrust::transform(d_col_int,d_col_int+mRecCount, d_col_float, long_to_float()); //for(int i = 0; i < mRecCount;i++) //cout << "DECOMP " << (float_type)(d_col_int[i]) << " " << d_col_float[i] << endl; }; } //else // uncompressed float // will have to fix it later so uncompressed data will be written by segments too } }; } void CudaSet::CopyColumnToGpu(string colname) // copy all segments { if(not_compressed) { if(type[colname] != 1) thrust::copy(h_columns_int[colname].begin(), h_columns_int[colname].begin() + mRecCount, d_columns_int[colname].begin()); else thrust::copy(h_columns_float[colname].begin(), h_columns_float[colname].begin() + mRecCount, d_columns_float[colname].begin()); } else { if(!d_v) CUDA_SAFE_CALL(hipMalloc((void **) &d_v, 12)); if(!s_v) CUDA_SAFE_CALL(hipMalloc((void **) &s_v, 8)); size_t cnt = 0; string f1; for(unsigned int i = 0; i < segCount; i++) { readSegmentsFromFile(i,colname, cnt); if(type[colname] == 2) { f1 = load_file_name + "." + colname + "." + to_string(i) + ".idx"; } else { f1 = load_file_name + "." + colname + "." + to_string(i); }; if(type[colname] == 0) { if(buffers.find(f1) == buffers.end()) { mRecCount = pfor_decompress(thrust::raw_pointer_cast(d_columns_int[colname].data() + cnt), h_columns_int[colname].data(), d_v, s_v); } else { mRecCount = pfor_decompress(thrust::raw_pointer_cast(d_columns_int[colname].data() + cnt), buffers[f1], d_v, s_v); }; } else if(type[colname] == 1) { if(decimal[colname]) { if(buffers.find(f1) == buffers.end()) { mRecCount = pfor_decompress( thrust::raw_pointer_cast(d_columns_float[colname].data() + cnt) , h_columns_float[colname].data(), d_v, s_v); } else { mRecCount = pfor_decompress( thrust::raw_pointer_cast(d_columns_float[colname].data() + cnt) , buffers[f1], d_v, s_v); }; thrust::device_ptr<long long int> d_col_int((long long int*)thrust::raw_pointer_cast(d_columns_float[colname].data() + cnt)); thrust::transform(d_col_int,d_col_int+mRecCount,d_columns_float[colname].begin() + cnt, long_to_float()); } // else uncompressed float // will have to fix it later so uncompressed data will be written by segments too }; cnt = cnt + mRecCount; //totalRecs = totals + mRecCount; }; mRecCount = cnt; }; } void CudaSet::CopyColumnToHost(string colname, size_t offset, size_t RecCount) { if(type[colname] != 1) { //cout << "copied " << colname << " " << RecCount << endl; thrust::copy(d_columns_int[colname].begin(), d_columns_int[colname].begin() + RecCount, h_columns_int[colname].begin() + offset); //cout << "to " << colname << " " << h_columns_int[colname][0] << " " << h_columns_int[colname][1] << endl; //cout << "to " << colname << " " << d_columns_int[colname][0] << " " << d_columns_int[colname][1] << endl; } else thrust::copy(d_columns_float[colname].begin(), d_columns_float[colname].begin() + RecCount, h_columns_float[colname].begin() + offset); } void CudaSet::CopyColumnToHost(string colname) { CopyColumnToHost(colname, 0, mRecCount); } void CudaSet::CopyToHost(size_t offset, size_t count) { for(unsigned int i = 0; i < columnNames.size(); i++) { CopyColumnToHost(columnNames[i], offset, count); }; } float_type* CudaSet::get_float_type_by_name(string name) { return thrust::raw_pointer_cast(d_columns_float[name].data()); } int_type* CudaSet::get_int_by_name(string name) { return thrust::raw_pointer_cast(d_columns_int[name].data()); } float_type* CudaSet::get_host_float_by_name(string name) { return thrust::raw_pointer_cast(h_columns_float[name].data()); } int_type* CudaSet::get_host_int_by_name(string name) { return thrust::raw_pointer_cast(h_columns_int[name].data()); } void CudaSet::GroupBy(stack<string> columnRef) { if(grp) hipFree(grp); CUDA_SAFE_CALL(hipMalloc((void **) &grp, mRecCount * sizeof(bool))); thrust::device_ptr<bool> d_grp(grp); thrust::sequence(d_grp, d_grp+mRecCount, 0, 0); thrust::device_ptr<bool> d_group = thrust::device_malloc<bool>(mRecCount); d_group[mRecCount-1] = 1; for(int i = 0; i < columnRef.size(); columnRef.pop()) { columnGroups.push(columnRef.top()); // save for future references if (type[columnRef.top()] != 1) { // int_type thrust::transform(d_columns_int[columnRef.top()].begin(), d_columns_int[columnRef.top()].begin() + mRecCount - 1, d_columns_int[columnRef.top()].begin()+1, d_group, thrust::not_equal_to<int_type>()); } else { // float_type thrust::transform(d_columns_float[columnRef.top()].begin(), d_columns_float[columnRef.top()].begin() + mRecCount - 1, d_columns_float[columnRef.top()].begin()+1, d_group, f_not_equal_to()); }; thrust::transform(d_group, d_group+mRecCount, d_grp, d_grp, thrust::logical_or<bool>()); }; thrust::device_free(d_group); grp_count = thrust::count(d_grp, d_grp+mRecCount,1); }; void CudaSet::addDeviceColumn(int_type* col, string colname, size_t recCount) { if (std::find(columnNames.begin(), columnNames.end(), colname) == columnNames.end()) { columnNames.push_back(colname); type[colname] = 0; d_columns_int[colname] = thrust::device_vector<int_type>(recCount); h_columns_int[colname] = thrust::host_vector<int_type, uninitialized_host_allocator<int_type> >(recCount); } else { // already exists, my need to resize it if(d_columns_int[colname].size() < recCount) { d_columns_int[colname].resize(recCount); }; if(h_columns_int[colname].size() < recCount) { h_columns_int[colname].resize(recCount); }; }; // copy data to d columns thrust::device_ptr<int_type> d_col((int_type*)col); thrust::copy(d_col, d_col+recCount, d_columns_int[colname].begin()); //cout << "added " << colname << " " << d_columns_int[colname][0] << " " << d_columns_int[colname][1] << " " << recCount << endl; thrust::copy(d_columns_int[colname].begin(), d_columns_int[colname].begin()+recCount, h_columns_int[colname].begin()); //for(int i = 0; i < recCount; i++) { //h_columns_int[colname][i] = d_columns_int[colname][i]; // cout << "set " << " " << h_columns_int[colname][i] << " to " << d_columns_int[colname][i] << endl; //}; //cout << "added host " << colname << " " << h_columns_int[colname][0] << " " << h_columns_int[colname][1] << endl; //thrust::host_vector<int_type> test(recCount); //thrust::copy(d_columns_int[colname].begin(), d_columns_int[colname].begin()+recCount, test.begin()); //cout << "added test " << test[0] << " " << test[1] << endl; }; void CudaSet::addDeviceColumn(float_type* col, string colname, size_t recCount, bool is_decimal) { if (std::find(columnNames.begin(), columnNames.end(), colname) == columnNames.end()) { columnNames.push_back(colname); type[colname] = 1; d_columns_float[colname] = thrust::device_vector<float_type>(recCount); h_columns_float[colname] = thrust::host_vector<float_type, uninitialized_host_allocator<float_type> >(recCount); } else { // already exists, my need to resize it if(d_columns_float[colname].size() < recCount) d_columns_float[colname].resize(recCount); if(h_columns_float[colname].size() < recCount) h_columns_float[colname].resize(recCount); }; decimal[colname] = is_decimal; thrust::device_ptr<float_type> d_col((float_type*)col); thrust::copy(d_col, d_col+recCount, d_columns_float[colname].begin()); }; void CudaSet::compress(string file_name, size_t offset, unsigned int check_type, unsigned int check_val, size_t mCount) { string str(file_name); thrust::device_vector<unsigned int> permutation; void* d; CUDA_SAFE_CALL(hipMalloc((void **) &d, mCount*float_size)); total_count = total_count + mCount; if (mCount > total_max && op_sort.empty()) { total_max = mCount; }; if(!op_sort.empty()) { //sort the segment //copy the key columns to device queue<string> sf(op_sort); permutation.resize(mRecCount); thrust::sequence(permutation.begin(), permutation.begin() + mRecCount,0,1); unsigned int* raw_ptr = thrust::raw_pointer_cast(permutation.data()); void* temp; CUDA_SAFE_CALL(hipMalloc((void **) &temp, mRecCount*max_char(this, sf))); string sort_type = "ASC"; while(!sf.empty()) { if(type[sf.front()] != 2) { allocColumnOnDevice(sf.front(), maxRecs); CopyColumnToGpu(sf.front()); }; if (type[sf.front()] == 0) update_permutation(d_columns_int[sf.front()], raw_ptr, mRecCount, sort_type, (int_type*)temp); else if (type[sf.front()] == 1) update_permutation(d_columns_float[sf.front()], raw_ptr, mRecCount, sort_type, (float_type*)temp); else { thrust::host_vector<unsigned int> permutation_h = permutation; update_permutation_char_host(h_columns_char[sf.front()], permutation_h.data(), mRecCount, sort_type, (char*)temp, char_size[sf.front()]); }; if(type[sf.front()] != 2) deAllocColumnOnDevice(sf.front()); sf.pop(); }; hipFree(temp); }; // here we need to check for partitions and if partition_count > 0 -> create partitions if(mCount < partition_count || partition_count == 0) partition_count = 1; unsigned int partition_recs = mCount/partition_count; if(!op_sort.empty()) { if(total_max < partition_recs) total_max = partition_recs; }; total_segments++; unsigned int old_segments = total_segments; size_t new_offset; for(unsigned int i = 0; i < columnNames.size(); i++) { string colname = columnNames[i]; str = file_name + "." + colname; curr_file = str; str += "." + to_string(total_segments-1); new_offset = 0; if(!op_sort.empty() && type[colname] != 2) { allocColumnOnDevice(colname, maxRecs); CopyColumnToGpu(colname); }; if(type[colname] == 0) { thrust::device_ptr<int_type> d_col((int_type*)d); if(!op_sort.empty()) { thrust::gather(permutation.begin(), permutation.end(), d_columns_int[colname].begin(), d_col); for(unsigned int p = 0; p < partition_count; p++) { str = file_name + "." + colname; curr_file = str; str += "." + to_string(total_segments-1); if (p < partition_count - 1) { pfor_compress( (int_type*)d + new_offset, partition_recs*int_size, str, h_columns_int[colname], 0); } else { pfor_compress( (int_type*)d + new_offset, (mCount - partition_recs*p)*int_size, str, h_columns_int[colname], 0); }; new_offset = new_offset + partition_recs; total_segments++; }; } else { thrust::copy(h_columns_int[colname].begin() + offset, h_columns_int[colname].begin() + offset + mCount, d_col); pfor_compress( d, mCount*int_size, str, h_columns_int[colname], 0); }; } else if(type[colname] == 1) { if(decimal[colname]) { thrust::device_ptr<float_type> d_col((float_type*)d); if(!op_sort.empty()) { thrust::gather(permutation.begin(), permutation.end(), d_columns_float[colname].begin(), d_col); thrust::device_ptr<long long int> d_col_dec((long long int*)d); thrust::transform(d_col,d_col+mCount,d_col_dec, float_to_long()); for(unsigned int p = 0; p < partition_count; p++) { str = file_name + "." + colname; curr_file = str; str += "." + to_string(total_segments-1); if (p < partition_count - 1) pfor_compress( (int_type*)d + new_offset, partition_recs*float_size, str, h_columns_float[colname], 1); else pfor_compress( (int_type*)d + new_offset, (mCount - partition_recs*p)*float_size, str, h_columns_float[colname], 1); new_offset = new_offset + partition_recs; total_segments++; }; } else { thrust::copy(h_columns_float[colname].begin() + offset, h_columns_float[colname].begin() + offset + mCount, d_col); thrust::device_ptr<long long int> d_col_dec((long long int*)d); thrust::transform(d_col,d_col+mCount,d_col_dec, float_to_long()); pfor_compress( d, mCount*float_size, str, h_columns_float[colname], 1); }; } else { // do not compress -- float thrust::device_ptr<float_type> d_col((float_type*)d); if(!op_sort.empty()) { thrust::gather(permutation.begin(), permutation.end(), d_columns_float[colname].begin(), d_col); thrust::copy(d_col, d_col+mRecCount, h_columns_float[colname].begin()); for(unsigned int p = 0; p < partition_count; p++) { str = file_name + "." + colname; curr_file = str; str += "." + to_string(total_segments-1); unsigned int curr_cnt; if (p < partition_count - 1) curr_cnt = partition_recs; else curr_cnt = mCount - partition_recs*p; fstream binary_file(str.c_str(),ios::out|ios::binary|fstream::app); binary_file.write((char *)&curr_cnt, 4); binary_file.write((char *)(h_columns_float[colname].data() + new_offset),curr_cnt*float_size); new_offset = new_offset + partition_recs; unsigned int comp_type = 3; binary_file.write((char *)&comp_type, 4); binary_file.close(); }; } else { fstream binary_file(str.c_str(),ios::out|ios::binary|fstream::app); binary_file.write((char *)&mCount, 4); binary_file.write((char *)(h_columns_float[colname].data() + offset),mCount*float_size); unsigned int comp_type = 3; binary_file.write((char *)&comp_type, 4); binary_file.close(); }; }; } else { //char if(!op_sort.empty()) { unsigned int* h_permutation = new unsigned int[mRecCount]; thrust::copy(permutation.begin(), permutation.end(), h_permutation); char* t = new char[char_size[colname]*mRecCount]; apply_permutation_char_host(h_columns_char[colname], h_permutation, mRecCount, t, char_size[colname]); delete [] h_permutation; thrust::copy(t, t+ char_size[colname]*mRecCount, h_columns_char[colname]); delete [] t; for(unsigned int p = 0; p < partition_count; p++) { str = file_name + "." + colname; curr_file = str; str += "." + to_string(total_segments-1); if (p < partition_count - 1) compress_char(str, colname, partition_recs, new_offset, total_segments-1); else compress_char(str, colname, mCount - partition_recs*p, new_offset, total_segments-1); new_offset = new_offset + partition_recs; total_segments++; }; } else { compress_char(str, colname, mCount, offset, total_segments-1); }; }; if(type[colname] != 2) deAllocColumnOnDevice(colname); if((check_type == 1 && fact_file_loaded) || (check_type == 1 && check_val == 0)) { if(!op_sort.empty()) writeHeader(file_name, colname, total_segments-1); else { writeHeader(file_name, colname, total_segments); }; }; total_segments = old_segments; }; hipFree(d); if(!op_sort.empty()) { total_segments = (old_segments-1)+partition_count; }; permutation.resize(0); permutation.shrink_to_fit(); } void CudaSet::writeHeader(string file_name, string colname, unsigned int tot_segs) { string str = file_name + "." + colname; string ff = str; str += ".header"; fstream binary_file(str.c_str(),ios::out|ios::binary|ios::trunc); binary_file.write((char *)&total_count, 8); binary_file.write((char *)&tot_segs, 4); binary_file.write((char *)&total_max, 4); binary_file.write((char *)&cnt_counts[ff], 4); binary_file.close(); }; void CudaSet::reWriteHeader(string file_name, string colname, unsigned int tot_segs, size_t newRecs, size_t maxRecs1) { string str = file_name + "." + colname; string ff = str; str += ".header"; fstream binary_file(str.c_str(),ios::out|ios::binary|ios::trunc); binary_file.write((char *)&newRecs, 8); binary_file.write((char *)&tot_segs, 4); binary_file.write((char *)&maxRecs1, 4); binary_file.close(); }; void CudaSet::writeSortHeader(string file_name) { string str(file_name); unsigned int idx; if(!op_sort.empty()) { str += ".sort"; fstream binary_file(str.c_str(),ios::out|ios::binary|ios::trunc); idx = (unsigned int)op_sort.size(); binary_file.write((char *)&idx, 4); queue<string> os(op_sort); while(!os.empty()) { //idx = cols[columnNames[os.front()]]; if(verbose) cout << "sorted on " << idx << endl; idx = os.front().size(); binary_file.write((char *)&idx, 4); binary_file.write(os.front().data(), idx); os.pop(); }; binary_file.close(); } else { str += ".sort"; remove(str.c_str()); }; if(!op_presort.empty()) { str += ".presort"; fstream binary_file(str.c_str(),ios::out|ios::binary|ios::trunc); idx = (unsigned int)op_presort.size(); binary_file.write((char *)&idx, 4); queue<string> os(op_presort); while(!os.empty()) { //idx = cols[columnNames[os.front()]]; idx = os.front().size(); binary_file.write((char *)&idx, 4); binary_file.write(os.front().data(), idx); os.pop(); }; binary_file.close(); } else { str += ".presort"; remove(str.c_str()); }; } using namespace mgpu; void CudaSet::Display(unsigned int limit, bool binary, bool term) { #define MAXCOLS 128 #define MAXFIELDSIZE 1400 //-- This should/will be converted to an array holding pointers of malloced sized structures-- char bigbuf[MAXCOLS * MAXFIELDSIZE]; memset(bigbuf, 0, MAXCOLS * MAXFIELDSIZE); char *fields[MAXCOLS]; const char *dcolumns[MAXCOLS]; size_t mCount; // num records in play bool print_all = 0; string ss; int rows = 0; if(limit != 0 && limit < mRecCount) mCount = limit; else { mCount = mRecCount; print_all = 1; }; cout << "mRecCount=" << mRecCount << " mcount = " << mCount << " term " << term << " limit=" << limit << " print_all=" << print_all << endl; unsigned int cc =0; unordered_map<string, FILE*> file_map; unordered_map<string, unsigned int> len_map; for(unsigned int i = 0; i < columnNames.size(); i++) { fields[cc] = &(bigbuf[cc*MAXFIELDSIZE]); // a hack to avoid malloc overheads - refine later dcolumns[cc++] = columnNames[i].c_str(); if(string_map.find(columnNames[i]) != string_map.end()) { auto s = string_map[columnNames[i]]; auto pos = s.find_first_of("."); auto len = data_dict[s.substr(0, pos)][s.substr(pos+1)].col_length; FILE *f; f = fopen(string_map[columnNames[i]].c_str(), "rb"); file_map[string_map[columnNames[i]]] = f; len_map[string_map[columnNames[i]]] = len; }; }; // The goal here is to loop fast and avoid any double handling of outgoing data - pointers are good. if(not_compressed && prm_d.size() == 0) { for(unsigned int i=0; i < mCount; i++) { // for each record for(unsigned int j=0; j < columnNames.size(); j++) { // for each col if (type[columnNames[j]] != 1) { if(string_map.find(columnNames[j]) == string_map.end()) sprintf(fields[j], "%lld", (h_columns_int[columnNames[j]])[i] ); else { fseek(file_map[string_map[columnNames[j]]], h_columns_int[columnNames[j]][i] * len_map[string_map[columnNames[j]]], SEEK_SET); fread(fields[j], 1, len_map[string_map[columnNames[j]]], file_map[string_map[columnNames[j]]]); fields[j][len_map[string_map[columnNames[j]]]] ='\0'; // zero terminate string }; } else sprintf(fields[j], "%.2f", (h_columns_float[columnNames[j]])[i] ); }; row_cb(mColumnCount, (char **)fields, (char **)dcolumns); rows++; }; } else { queue<string> op_vx; for(unsigned int i = 0; i < columnNames.size(); i++) op_vx.push(columnNames[i]); if(prm_d.size() || source) { allocColumns(this, op_vx); }; unsigned int curr_seg = 0; size_t cnt = 0; size_t curr_count, sum_printed = 0; resize(maxRecs); while(sum_printed < mCount || print_all) { if(prm_d.size() || source) { // if host arrays are empty copyColumns(this, op_vx, curr_seg, cnt); size_t olRecs = mRecCount; mRecCount = olRecs; CopyToHost(0,mRecCount); if(sum_printed + mRecCount <= mCount || print_all) curr_count = mRecCount; else curr_count = mCount - sum_printed; } else curr_count = mCount; sum_printed = sum_printed + mRecCount; for(unsigned int i=0; i < curr_count; i++) { for(unsigned int j=0; j < columnNames.size(); j++) { if (type[columnNames[j]] != 1) { if(string_map.find(columnNames[j]) == string_map.end()) sprintf(fields[j], "%lld", (h_columns_int[columnNames[j]])[i] ); else { fseek(file_map[string_map[columnNames[j]]], h_columns_int[columnNames[j]][i] * len_map[string_map[columnNames[j]]], SEEK_SET); fread(fields[j], 1, len_map[string_map[columnNames[j]]], file_map[string_map[columnNames[j]]]); fields[j][len_map[string_map[columnNames[j]]]] ='\0'; // zero terminate string }; } else sprintf(fields[j], "%.2f", (h_columns_float[columnNames[j]])[i] ); }; row_cb(mColumnCount, (char **)fields, (char**)dcolumns); rows++; }; curr_seg++; if(curr_seg == segCount) print_all = 0; }; }; // end else for(auto it = file_map.begin(); it != file_map.end(); it++) fclose(it->second); } void CudaSet::Store(const string file_name, const char* sep, const unsigned int limit, const bool binary, const bool term) { if (mRecCount == 0 && binary == 1 && !term) { // write tails for(unsigned int j=0; j < columnNames.size(); j++) { writeHeader(file_name, columnNames[j], total_segments); }; return; }; size_t mCount; bool print_all = 0; if(limit != 0 && limit < mRecCount) mCount = limit; else { mCount = mRecCount; print_all = 1; }; //cout << "mCount " << mCount << " " << mRecCount << endl; if(binary == 0) { unordered_map<string, FILE*> file_map; unordered_map<string, unsigned int> len_map; string bf; unsigned int max_len = 0; for(unsigned int j=0; j < columnNames.size(); j++) { if(string_map.find(columnNames[j]) != string_map.end()) { auto s = string_map[columnNames[j]]; auto pos = s.find_first_of("."); auto len = data_dict[s.substr(0, pos)][s.substr(pos+1)].col_length; if(len > max_len) max_len = len; FILE *f; f = fopen(string_map[columnNames[j]].c_str(), "rb"); file_map[string_map[columnNames[j]]] = f; len_map[string_map[columnNames[j]]] = len; }; }; bf.reserve(max_len); FILE *file_pr; if(!term) { file_pr = fopen(file_name.c_str(), "w"); if (!file_pr) cout << "Could not open file " << file_name << endl; } else file_pr = stdout; if(not_compressed && prm_d.size() == 0) { for(unsigned int i=0; i < mCount; i++) { for(unsigned int j=0; j < columnNames.size(); j++) { if (type[columnNames[j]] != 1 ) { if(string_map.find(columnNames[j]) == string_map.end()) { fprintf(file_pr, "%lld", (h_columns_int[columnNames[j]])[i]); } else { //fprintf(file_pr, "%.*s", string_hash[columnNames[j]][h_columns_int[columnNames[j]][i]].size(), string_hash[columnNames[j]][h_columns_int[columnNames[j]][i]].c_str()); fseek(file_map[string_map[columnNames[j]]], h_columns_int[columnNames[j]][i] * len_map[string_map[columnNames[j]]], SEEK_SET); fread(&bf[0], 1, len_map[string_map[columnNames[j]]], file_map[string_map[columnNames[j]]]); fprintf(file_pr, "%.*s", len_map[string_map[columnNames[j]]], bf.c_str()); }; fputs(sep, file_pr); } else { fprintf(file_pr, "%.2f", (h_columns_float[columnNames[j]])[i]); fputs(sep, file_pr); } }; if (i != mCount -1 ) fputs("\n",file_pr); }; if(!term) fclose(file_pr); } else { queue<string> op_vx; string ss; for(unsigned int j=0; j < columnNames.size(); j++) op_vx.push(columnNames[j]); if(prm_d.size() || source) { allocColumns(this, op_vx); }; unsigned int curr_seg = 0; size_t cnt = 0; size_t curr_count, sum_printed = 0; mRecCount = 0; resize(maxRecs); while(sum_printed < mCount || print_all) { if(prm_d.size() || source) { copyColumns(this, op_vx, curr_seg, cnt); if(curr_seg == 0) { if(limit != 0 && limit < mRecCount) { mCount = limit; print_all = 0; } else { mCount = mRecCount; print_all = 1; }; }; // if host arrays are empty size_t olRecs = mRecCount; mRecCount = olRecs; CopyToHost(0,mRecCount); //cout << "start " << sum_printed << " " << mRecCount << " " << mCount << endl; if(sum_printed + mRecCount <= mCount || print_all) { curr_count = mRecCount; } else { curr_count = mCount - sum_printed; }; } else { curr_count = mCount; }; sum_printed = sum_printed + mRecCount; //cout << "sum printed " << sum_printed << " " << curr_count << " " << curr_seg << endl; for(unsigned int i=0; i < curr_count; i++) { for(unsigned int j=0; j < columnNames.size(); j++) { if (type[columnNames[j]] != 1) { if(string_map.find(columnNames[j]) == string_map.end()) { fprintf(file_pr, "%lld", (h_columns_int[columnNames[j]])[i]); } else { fseek(file_map[string_map[columnNames[j]]], h_columns_int[columnNames[j]][i] * len_map[string_map[columnNames[j]]], SEEK_SET); fread(&bf[0], 1, len_map[string_map[columnNames[j]]], file_map[string_map[columnNames[j]]]); fprintf(file_pr, "%.*s", len_map[string_map[columnNames[j]]], bf.c_str()); }; fputs(sep, file_pr); } else { fprintf(file_pr, "%.2f", (h_columns_float[columnNames[j]])[i]); fputs(sep, file_pr); }; }; if (i != mCount -1 && (curr_seg != segCount || i < curr_count)) fputs("\n",file_pr); }; curr_seg++; if(curr_seg == segCount) print_all = 0; }; if(!term) { fclose(file_pr); }; }; for(auto it = file_map.begin(); it != file_map.end(); it++) fclose(it->second); } else { //lets update the data dictionary for(unsigned int j=0; j < columnNames.size(); j++) { if(decimal[columnNames[j]] == 1) data_dict[file_name][columnNames[j]].col_type = 3; else data_dict[file_name][columnNames[j]].col_type = type[columnNames[j]]; if(type[columnNames[j]] != 2) data_dict[file_name][columnNames[j]].col_length = 0; else data_dict[file_name][columnNames[j]].col_length = char_size[columnNames[j]]; }; save_dict = 1; if(text_source) { //writing a binary file using a text file as a source // time to perform join checks on REFERENCES dataset segments //for(unsigned int i = 0; i< mColumnCount; i++) { for(unsigned int i=0; i < columnNames.size(); i++) { if(ref_sets.find(columnNames[i]) != ref_sets.end()) { string f1 = file_name + "." + columnNames[i] + ".refs"; fstream f_file; if(total_segments == 0) { f_file.open(f1.c_str(), ios::out|ios::trunc|ios::binary); unsigned int len = ref_sets[columnNames[i]].size(); f_file.write((char *)&len, 4); f_file.write(ref_sets[columnNames[i]].c_str(), len); len = ref_cols[columnNames[i]].size(); f_file.write((char *)&len, 4); f_file.write(ref_cols[columnNames[i]].c_str(), len); } else { f_file.open(f1.c_str(), ios::out|ios::app|ios::binary); }; f1 = ref_sets[columnNames[i]] + "." + ref_cols[columnNames[i]] + ".header"; FILE* ff = fopen(f1.c_str(), "rb"); if(!ff) { process_error(3, "Couldn't open file " + string(f1)); }; unsigned int ref_segCount, ref_maxRecs; fread((char *)&ref_segCount, 4, 1, ff); fread((char *)&ref_segCount, 4, 1, ff); fread((char *)&ref_segCount, 4, 1, ff); fread((char *)&ref_maxRecs, 4, 1, ff); fclose(ff); //cout << "CALC " << i << " " << columnNames[i] << " " << ref_sets[columnNames[i]] << " " << ref_cols[columnNames[i]] << " " << ref_segCount << " " << ref_maxRecs << endl; CudaSet* a = new CudaSet(maxRecs, 1); //a->h_columns_int[ref_cols[columnNames[i]]] = thrust::host_vector<int_type, pinned_allocator<int_type> >(); a->h_columns_int[ref_cols[columnNames[i]]] = thrust::host_vector<int_type>(); a->d_columns_int[ref_cols[columnNames[i]]] = thrust::device_vector<int_type>(ref_maxRecs); a->type[ref_cols[columnNames[i]]] = 0; a->not_compressed = 0; a->load_file_name = ref_sets[columnNames[i]]; a->cols[1] = ref_cols[columnNames[i]]; a->columnNames.push_back(ref_cols[columnNames[i]]); MGPU_MEM(int) aIndicesDevice, bIndicesDevice; size_t res_count; if(!onDevice(columnNames[i])) { allocColumnOnDevice(columnNames[i], maxRecs); }; CopyColumnToGpu(columnNames[i]); thrust::sort(d_columns_int[columnNames[i]].begin(), d_columns_int[columnNames[i]].begin() + mRecCount); f_file.write((char *)&total_segments, 4); f_file.write((char *)&ref_segCount, 4); for(unsigned int z = 0; z < ref_segCount; z++) { a->CopyColumnToGpu(ref_cols[columnNames[i]], z, 0); thrust::sort(a->d_columns_int[ref_cols[columnNames[i]]].begin(), a->d_columns_int[ref_cols[columnNames[i]]].begin() + a->mRecCount); // check if there is a join result //cout << "join " << mRecCount << " " << a->mRecCount << " " << getFreeMem() << endl; //cout << d_columns_int[columnNames[i]][0] << " " << d_columns_int[columnNames[i]][mRecCount-1] << " " << a->d_columns_int[ref_cols[columnNames[i]]][a->mRecCount-1] << " " << a->d_columns_int[ref_cols[columnNames[i]]][0] << endl; if(d_columns_int[columnNames[i]][0] > a->d_columns_int[ref_cols[columnNames[i]]][a->mRecCount-1] || d_columns_int[columnNames[i]][mRecCount-1] < a->d_columns_int[ref_cols[columnNames[i]]][0]) { res_count = 0; } else { res_count = RelationalJoin<MgpuJoinKindInner>(thrust::raw_pointer_cast(d_columns_int[columnNames[i]].data()), mRecCount, thrust::raw_pointer_cast(a->d_columns_int[ref_cols[columnNames[i]]].data()), a->mRecCount, &aIndicesDevice, &bIndicesDevice, mgpu::less<int_type>(), *context); }; cout << "RES " << i << " " << total_segments << ":" << z << " " << res_count << endl; f_file.write((char *)&z, 4); f_file.write((char *)&res_count, 8); }; f_file.close(); a->deAllocColumnOnDevice(ref_cols[columnNames[i]]); a->free(); }; }; compress(file_name, 0, 1, 0, mCount); for(unsigned int i = 0; i< columnNames.size(); i++) if(type[columnNames[i]] == 2) deAllocColumnOnDevice(columnNames[i]); } else { //writing a binary file using a binary file as a source fact_file_loaded = 1; size_t offset = 0; if(!not_compressed) { // records are compressed, for example after filter op. //decompress to host queue<string> op_vx; for(unsigned int i = 0; i< columnNames.size(); i++) { op_vx.push(columnNames[i]); }; allocColumns(this, op_vx); size_t oldCnt = mRecCount; mRecCount = 0; resize(oldCnt); mRecCount = oldCnt; for(unsigned int i = 0; i < segCount; i++) { size_t cnt = 0; copyColumns(this, op_vx, i, cnt); CopyToHost(0, mRecCount); offset = offset + mRecCount; compress(file_name, 0, 0, i - (segCount-1), mRecCount); }; } else { // now we have decompressed records on the host //call setSegments and compress columns in every segment segCount = (mRecCount/process_count + 1); offset = 0; for(unsigned int z = 0; z < segCount; z++) { if(z < segCount-1) { if(mRecCount < process_count) { mCount = mRecCount; } else { mCount = process_count; } } else { mCount = mRecCount - (segCount-1)*process_count; }; compress(file_name, offset, 0, z - (segCount-1), mCount); offset = offset + mCount; }; }; }; }; } void CudaSet::compress_char(const string file_name, const string colname, const size_t mCount, const size_t offset, const unsigned int segment) { unsigned int len = char_size[colname]; unsigned long long int string_hash; string h_name, i_name, file_no_seg = file_name.substr(0, file_name.find_last_of(".")); i_name = file_no_seg + "." + to_string(segment) + ".idx"; h_name = file_no_seg + "." + to_string(segment) + ".hash"; fstream b_file_str, loc_hashes; fstream binary_file_h(h_name.c_str(),ios::out|ios::binary|ios::trunc); binary_file_h.write((char *)&mCount, 4); if(segment == 0) { b_file_str.open(file_no_seg.c_str(),ios::out|ios::binary|ios::trunc); } else { b_file_str.open(file_no_seg.c_str(),ios::out|ios::binary|ios::app); }; if(h_columns_int.find(colname) == h_columns_int.end()) h_columns_int[colname] = thrust::host_vector<int_type >(mCount); if(d_columns_int.find(colname) == d_columns_int.end()) d_columns_int[colname] = thrust::device_vector<int_type >(mCount); for (unsigned int i = 0 ; i < mCount; i++) { string_hash = MurmurHash64A(h_columns_char[colname] + (i+offset)*len, len, hash_seed)/2; binary_file_h.write((char *)&string_hash, 8); if(char_hash[colname].find(string_hash) == char_hash[colname].end()) { auto cnt = char_hash[colname].size(); char_hash[colname][string_hash] = cnt; b_file_str.write((char *)h_columns_char[colname] + (i+offset)*len, len); h_columns_int[colname][i] = cnt; } else { h_columns_int[colname][i] = char_hash[colname][string_hash]; }; }; thrust::device_vector<int_type> d_col(mCount); thrust::copy(h_columns_int[colname].begin(), h_columns_int[colname].begin() + mCount, d_col.begin()); pfor_compress(thrust::raw_pointer_cast(d_col.data()), mCount*int_size, i_name, h_columns_int[colname], 0); binary_file_h.close(); b_file_str.close(); }; void CudaSet::compress_int(const string file_name, const string colname, const size_t mCount) { std::vector<unsigned int> dict_val; unsigned int bits_encoded; set<int_type> dict_s; map<int_type, unsigned int> d_ordered; for (unsigned int i = 0 ; i < mCount; i++) { int_type f = h_columns_int[colname][i]; dict_s.insert(f); }; unsigned int i = 0; for (auto it = dict_s.begin(); it != dict_s.end(); it++) { d_ordered[*it] = i++; }; for (unsigned int i = 0 ; i < mCount; i++) { int_type f = h_columns_int[colname][i]; dict_val.push_back(d_ordered[f]); }; bits_encoded = (unsigned int)ceil(log2(double(d_ordered.size()+1))); //cout << "bits " << bits_encoded << endl; unsigned int sz = (unsigned int)d_ordered.size(); // write to a file fstream binary_file(file_name.c_str(),ios::out|ios::binary|ios::trunc); binary_file.write((char *)&sz, 4); for (auto it = d_ordered.begin(); it != d_ordered.end(); it++) { binary_file.write((char*)(&(it->first)), int_size); }; unsigned int fit_count = 64/bits_encoded; unsigned long long int val = 0; binary_file.write((char *)&fit_count, 4); binary_file.write((char *)&bits_encoded, 4); unsigned int curr_cnt = 1; unsigned int vals_count = (unsigned int)dict_val.size()/fit_count; if(!vals_count || dict_val.size()%fit_count) vals_count++; binary_file.write((char *)&vals_count, 4); unsigned int real_count = (unsigned int)dict_val.size(); binary_file.write((char *)&real_count, 4); for(unsigned int i = 0; i < dict_val.size(); i++) { val = val | dict_val[i]; if(curr_cnt < fit_count) val = val << bits_encoded; if( (curr_cnt == fit_count) || (i == (dict_val.size() - 1)) ) { if (curr_cnt < fit_count) { val = val << ((fit_count-curr_cnt)-1)*bits_encoded; }; curr_cnt = 1; binary_file.write((char *)&val, int_size); val = 0; } else curr_cnt = curr_cnt + 1; }; binary_file.close(); }; bool CudaSet::LoadBigFile(FILE* file_p) { char line[2000]; unsigned int current_column, count = 0; string colname; char *p,*t; const char* sep = separator.c_str(); unsigned int maxx = cols.rbegin()->first; //clear the varchars //for(auto it=columnNames.begin(); it!=columnNames.end();it++) { for(unsigned int i = 0; i < mColumnCount; i++) { if(type[columnNames[i]] == 2) { if(!h_columns_char[columnNames[i]]) h_columns_char[columnNames[i]] = new char[maxRecs*char_size[columnNames[i]]]; memset(h_columns_char[columnNames[i]], 0, maxRecs*char_size[columnNames[i]]); }; }; while (count < process_count && fgets(line, 2000, file_p)) { strtok(line, "\n"); current_column = 0; for(t=mystrtok(&p,line,*sep); t && current_column < maxx; t=mystrtok(&p,0,*sep)) { current_column++; if(cols.find(current_column) == cols.end()) { continue; }; if (type[cols[current_column]] == 0) { if (strchr(t,'-') && t[0] != '-') { // handling possible dates strncpy(t+4,t+5,2); strncpy(t+6,t+8,2); t[8] = '\0'; (h_columns_int[cols[current_column]])[count] = atoll(t); } else if (strchr(t,'/')) { // 4/30/2014 string s(t); size_t pos1 = s.find_first_of("/",0); size_t pos2 = s.find_first_of("/",pos1+1); string month = s.substr(0,pos1); if(month.length() == 1) month = "0" + month; string day = s.substr(pos1+1,pos2-pos1-1); if(day.length() == 1) day = "0" + day; string s2 = s.substr(pos2+1, string::npos) + month + day; (h_columns_int[cols[current_column]])[count] = atoll(s2.c_str()); } else { (h_columns_int[cols[current_column]])[count] = atoll(t); }; } else if (type[cols[current_column]] == 1) { (h_columns_float[cols[current_column]])[count] = atoff(t); } else {//char strcpy(h_columns_char[cols[current_column]] + count*char_size[cols[current_column]], t); } }; count++; }; mRecCount = count; if(count < process_count) { fclose(file_p); return 1; } else return 0; }; void CudaSet::free() { for(unsigned int i = 0; i < columnNames.size(); i++ ) { if(type[columnNames[i]] == 0 ) { h_columns_int[columnNames[i]].resize(0); h_columns_int[columnNames[i]].shrink_to_fit(); } else { h_columns_float[columnNames[i]].resize(0); h_columns_float[columnNames[i]].shrink_to_fit(); }; }; prm_d.resize(0); prm_d.shrink_to_fit(); deAllocOnDevice(); }; bool* CudaSet::logical_and(bool* column1, bool* column2) { thrust::device_ptr<bool> dev_ptr1(column1); thrust::device_ptr<bool> dev_ptr2(column2); thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, dev_ptr1, thrust::logical_and<bool>()); thrust::device_free(dev_ptr2); return column1; } bool* CudaSet::logical_or(bool* column1, bool* column2) { thrust::device_ptr<bool> dev_ptr1(column1); thrust::device_ptr<bool> dev_ptr2(column2); thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, dev_ptr1, thrust::logical_or<bool>()); thrust::device_free(dev_ptr2); return column1; } bool* CudaSet::compare(int_type s, int_type d, int_type op_type) { bool res; if (op_type == 2) // > if(d>s) res = 1; else res = 0; else if (op_type == 1) // < if(d<s) res = 1; else res = 0; else if (op_type == 6) // >= if(d>=s) res = 1; else res = 0; else if (op_type == 5) // <= if(d<=s) res = 1; else res = 0; else if (op_type == 4)// = if(d==s) res = 1; else res = 0; else // != if(d!=s) res = 1; else res = 0; thrust::device_ptr<bool> p = thrust::device_malloc<bool>(mRecCount); thrust::sequence(p, p+mRecCount,res,(bool)0); return thrust::raw_pointer_cast(p); }; bool* CudaSet::compare(float_type s, float_type d, int_type op_type) { bool res; if (op_type == 2) // > if ((d-s) > EPSILON) res = 1; else res = 0; else if (op_type == 1) // < if ((s-d) > EPSILON) res = 1; else res = 0; else if (op_type == 6) // >= if (((d-s) > EPSILON) || (((d-s) < EPSILON) && ((d-s) > -EPSILON))) res = 1; else res = 0; else if (op_type == 5) // <= if (((s-d) > EPSILON) || (((d-s) < EPSILON) && ((d-s) > -EPSILON))) res = 1; else res = 0; else if (op_type == 4)// = if (((d-s) < EPSILON) && ((d-s) > -EPSILON)) res = 1; else res = 0; else // != if (!(((d-s) < EPSILON) && ((d-s) > -EPSILON))) res = 1; else res = 0; thrust::device_ptr<bool> p = thrust::device_malloc<bool>(mRecCount); thrust::sequence(p, p+mRecCount,res,(bool)0); return thrust::raw_pointer_cast(p); } bool* CudaSet::compare(int_type* column1, int_type d, int_type op_type) { thrust::device_ptr<bool> temp = thrust::device_malloc<bool>(mRecCount); thrust::device_ptr<int_type> dev_ptr(column1); if (op_type == 2) // > thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), temp, thrust::greater<int_type>()); else if (op_type == 1) // < thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), temp, thrust::less<int_type>()); else if (op_type == 6) // >= thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), temp, thrust::greater_equal<int_type>()); else if (op_type == 5) // <= thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), temp, thrust::less_equal<int_type>()); else if (op_type == 4)// = thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), temp, thrust::equal_to<int_type>()); else // != thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), temp, thrust::not_equal_to<int_type>()); return thrust::raw_pointer_cast(temp); } bool* CudaSet::compare(float_type* column1, float_type d, int_type op_type) { thrust::device_ptr<bool> res = thrust::device_malloc<bool>(mRecCount); thrust::device_ptr<float_type> dev_ptr(column1); if (op_type == 2) // > thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), res, f_greater()); else if (op_type == 1) // < thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), res, f_less()); else if (op_type == 6) // >= thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), res, f_greater_equal_to()); else if (op_type == 5) // <= thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), res, f_less_equal()); else if (op_type == 4)// = thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), res, f_equal_to()); else // != thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), res, f_not_equal_to()); return thrust::raw_pointer_cast(res); } bool* CudaSet::compare(int_type* column1, int_type* column2, int_type op_type) { thrust::device_ptr<int_type> dev_ptr1(column1); thrust::device_ptr<int_type> dev_ptr2(column2); thrust::device_ptr<bool> temp = thrust::device_malloc<bool>(mRecCount); if (op_type == 2) // > thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::greater<int_type>()); else if (op_type == 1) // < thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::less<int_type>()); else if (op_type == 6) // >= thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::greater_equal<int_type>()); else if (op_type == 5) // <= thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::less_equal<int_type>()); else if (op_type == 4)// = thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::equal_to<int_type>()); else // != thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::not_equal_to<int_type>()); return thrust::raw_pointer_cast(temp); } bool* CudaSet::compare(float_type* column1, float_type* column2, int_type op_type) { thrust::device_ptr<float_type> dev_ptr1(column1); thrust::device_ptr<float_type> dev_ptr2(column2); thrust::device_ptr<bool> temp = thrust::device_malloc<bool>(mRecCount); if (op_type == 2) // > thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_greater()); else if (op_type == 1) // < thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_less()); else if (op_type == 6) // >= thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_greater_equal_to()); else if (op_type == 5) // <= thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_less_equal()); else if (op_type == 4)// = thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_equal_to()); else // != thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_not_equal_to()); return thrust::raw_pointer_cast(temp); } bool* CudaSet::compare(float_type* column1, int_type* column2, int_type op_type) { thrust::device_ptr<float_type> dev_ptr1(column1); thrust::device_ptr<int_type> dev_ptr(column2); thrust::device_ptr<float_type> dev_ptr2 = thrust::device_malloc<float_type>(mRecCount); thrust::device_ptr<bool> temp = thrust::device_malloc<bool>(mRecCount); thrust::transform(dev_ptr, dev_ptr + mRecCount, dev_ptr2, long_to_float_type()); if (op_type == 2) // > thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_greater()); else if (op_type == 1) // < thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_less()); else if (op_type == 6) // >= thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_greater_equal_to()); else if (op_type == 5) // <= thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_less_equal()); else if (op_type == 4)// = thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_equal_to()); else // != thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_not_equal_to()); thrust::device_free(dev_ptr2); return thrust::raw_pointer_cast(temp); } float_type* CudaSet::op(int_type* column1, float_type* column2, string op_type, int reverse) { thrust::device_ptr<float_type> temp = thrust::device_malloc<float_type>(mRecCount); thrust::device_ptr<int_type> dev_ptr(column1); thrust::transform(dev_ptr, dev_ptr + mRecCount, temp, long_to_float_type()); // in-place transformation thrust::device_ptr<float_type> dev_ptr1(column2); if(reverse == 0) { if (op_type.compare("MUL") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::multiplies<float_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::plus<float_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::minus<float_type>()); else thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::divides<float_type>()); } else { if (op_type.compare("MUL") == 0) thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::multiplies<float_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::plus<float_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::minus<float_type>()); else thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::divides<float_type>()); }; return thrust::raw_pointer_cast(temp); } int_type* CudaSet::op(int_type* column1, int_type* column2, string op_type, int reverse) { thrust::device_ptr<int_type> temp = thrust::device_malloc<int_type>(mRecCount); thrust::device_ptr<int_type> dev_ptr1(column1); thrust::device_ptr<int_type> dev_ptr2(column2); if(reverse == 0) { if (op_type.compare("MUL") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::multiplies<int_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::plus<int_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::minus<int_type>()); else thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::divides<int_type>()); } else { if (op_type.compare("MUL") == 0) thrust::transform(dev_ptr2, dev_ptr2+mRecCount, dev_ptr1, temp, thrust::multiplies<int_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(dev_ptr2, dev_ptr2+mRecCount, dev_ptr1, temp, thrust::plus<int_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(dev_ptr2, dev_ptr2+mRecCount, dev_ptr1, temp, thrust::minus<int_type>()); else thrust::transform(dev_ptr2, dev_ptr2+mRecCount, dev_ptr1, temp, thrust::divides<int_type>()); } return thrust::raw_pointer_cast(temp); } float_type* CudaSet::op(float_type* column1, float_type* column2, string op_type, int reverse) { thrust::device_ptr<float_type> temp = thrust::device_malloc<float_type>(mRecCount); thrust::device_ptr<float_type> dev_ptr1(column1); thrust::device_ptr<float_type> dev_ptr2(column2); if(reverse == 0) { if (op_type.compare("MUL") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::multiplies<float_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::plus<float_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::minus<float_type>()); else thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::divides<float_type>()); } else { if (op_type.compare("MUL") == 0) thrust::transform(dev_ptr2, dev_ptr2+mRecCount, dev_ptr1, temp, thrust::multiplies<float_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(dev_ptr2, dev_ptr2+mRecCount, dev_ptr1, temp, thrust::plus<float_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(dev_ptr2, dev_ptr2+mRecCount, dev_ptr1, temp, thrust::minus<float_type>()); else thrust::transform(dev_ptr2, dev_ptr2+mRecCount, dev_ptr1, temp, thrust::divides<float_type>()); }; return thrust::raw_pointer_cast(temp); } int_type* CudaSet::op(int_type* column1, int_type d, string op_type, int reverse) { thrust::device_ptr<int_type> temp = thrust::device_malloc<int_type>(mRecCount); thrust::fill(temp, temp+mRecCount, d); thrust::device_ptr<int_type> dev_ptr1(column1); if(reverse == 0) { if (op_type.compare("MUL") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::multiplies<int_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::plus<int_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::minus<int_type>()); else thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::divides<int_type>()); } else { if (op_type.compare("MUL") == 0) thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::multiplies<int_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::plus<int_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::minus<int_type>()); else thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::divides<int_type>()); }; return thrust::raw_pointer_cast(temp); } float_type* CudaSet::op(int_type* column1, float_type d, string op_type, int reverse) { thrust::device_ptr<float_type> temp = thrust::device_malloc<float_type>(mRecCount); thrust::fill(temp, temp+mRecCount, d); thrust::device_ptr<int_type> dev_ptr(column1); thrust::device_ptr<float_type> dev_ptr1 = thrust::device_malloc<float_type>(mRecCount); thrust::transform(dev_ptr, dev_ptr + mRecCount, dev_ptr1, long_to_float_type()); if(reverse == 0) { if (op_type.compare("MUL") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::multiplies<float_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::plus<float_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::minus<float_type>()); else thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::divides<float_type>()); } else { if (op_type.compare("MUL") == 0) thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::multiplies<float_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::plus<float_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::minus<float_type>()); else thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::divides<float_type>()); }; thrust::device_free(dev_ptr1); return thrust::raw_pointer_cast(temp); } float_type* CudaSet::op(float_type* column1, float_type d, string op_type,int reverse) { thrust::device_ptr<float_type> temp = thrust::device_malloc<float_type>(mRecCount); thrust::device_ptr<float_type> dev_ptr1(column1); if(reverse == 0) { if (op_type.compare("MUL") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, thrust::make_constant_iterator(d), temp, thrust::multiplies<float_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, thrust::make_constant_iterator(d), temp, thrust::plus<float_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, thrust::make_constant_iterator(d), temp, thrust::minus<float_type>()); else thrust::transform(dev_ptr1, dev_ptr1+mRecCount, thrust::make_constant_iterator(d), temp, thrust::divides<float_type>()); } else { if (op_type.compare("MUL") == 0) thrust::transform(thrust::make_constant_iterator(d), thrust::make_constant_iterator(d)+mRecCount, dev_ptr1, temp, thrust::multiplies<float_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(thrust::make_constant_iterator(d), thrust::make_constant_iterator(d)+mRecCount, dev_ptr1, temp, thrust::plus<float_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(thrust::make_constant_iterator(d), thrust::make_constant_iterator(d)+mRecCount, dev_ptr1, temp, thrust::minus<float_type>()); else thrust::transform(thrust::make_constant_iterator(d), thrust::make_constant_iterator(d)+mRecCount, dev_ptr1, temp, thrust::divides<float_type>()); }; return thrust::raw_pointer_cast(temp); } char CudaSet::loadIndex(const string index_name, const unsigned int segment) { FILE* f; unsigned int bits_encoded, fit_count, vals_count, sz, real_count; void* d_str; string f1 = index_name + "." + to_string(segment); char res; if(interactive) { if(index_buffers.find(f1) == index_buffers.end()) { f = fopen (f1.c_str(), "rb" ); fseek(f, 0, SEEK_END); long fileSize = ftell(f); char* buff; hipHostMalloc(&buff, fileSize, hipHostMallocDefault); fseek(f, 0, SEEK_SET); fread(buff, fileSize, 1, f); fclose(f); index_buffers[f1] = buff; }; sz = ((unsigned int*)index_buffers[f1])[0]; idx_dictionary_int[index_name].clear(); for(unsigned int i = 0; i < sz; i++) { idx_dictionary_int[index_name][((int_type*)(index_buffers[f1]+4+8*i))[0]] = i; }; vals_count = ((unsigned int*)(index_buffers[f1]+4 +8*sz))[2]; real_count = ((unsigned int*)(index_buffers[f1]+4 +8*sz))[3]; mRecCount = real_count; res = (index_buffers[f1]+4 +8*sz + (vals_count+2)*int_size)[0]; hipMalloc((void **) &d_str, (vals_count+2)*int_size); hipMemcpy( d_str, (void *) &((index_buffers[f1]+4 +8*sz)[0]), (vals_count+2)*int_size, hipMemcpyHostToDevice); if(idx_vals.count(index_name)) hipFree(idx_vals[index_name]); idx_vals[index_name] = (unsigned long long int*)d_str; } else { f = fopen (f1.c_str(), "rb" ); fread(&sz, 4, 1, f); int_type* d_array = new int_type[sz]; idx_dictionary_int[index_name].clear(); fread((void*)d_array, sz*int_size, 1, f); for(unsigned int i = 0; i < sz; i++) { idx_dictionary_int[index_name][d_array[i]] = i; //cout << index_name << " " << d_array[i] << " " << i << endl; }; delete [] d_array; fread(&fit_count, 4, 1, f); fread(&bits_encoded, 4, 1, f); fread(&vals_count, 4, 1, f); fread(&real_count, 4, 1, f); mRecCount = real_count; unsigned long long int* int_array = new unsigned long long int[vals_count+2]; fseek ( f , -16 , SEEK_CUR ); fread((void*)int_array, 1, vals_count*8 + 16, f); fread(&res, 1, 1, f); fclose(f); void* d_str; hipMalloc((void **) &d_str, (vals_count+2)*int_size); hipMemcpy( d_str, (void *) int_array, (vals_count+2)*int_size, hipMemcpyHostToDevice); if(idx_vals.count(index_name)) hipFree(idx_vals[index_name]); idx_vals[index_name] = (unsigned long long int*)d_str; } return res; } void CudaSet::initialize(queue<string> &nameRef, queue<string> &typeRef, queue<int> &sizeRef, queue<int> &colsRef, size_t Recs, string file_name) // compressed data for DIM tables { mColumnCount = (unsigned int)nameRef.size(); FILE* f; string f1; unsigned int cnt; char buffer[4000]; string str; not_compressed = 0; mRecCount = Recs; hostRecCount = Recs; totalRecs = Recs; load_file_name = file_name; f1 = file_name + ".sort"; f = fopen (f1.c_str() , "rb" ); if(f) { unsigned int sz, idx; fread((char *)&sz, 4, 1, f); for(unsigned int j = 0; j < sz; j++) { fread((char *)&idx, 4, 1, f); fread(buffer, idx, 1, f); str.assign(buffer, idx); sorted_fields.push(str); if(verbose) cout << "segment sorted on " << str << endl; }; fclose(f); }; f1 = file_name + ".presort"; f = fopen (f1.c_str() , "rb" ); if(f) { unsigned int sz, idx; fread((char *)&sz, 4, 1, f); for(unsigned int j = 0; j < sz; j++) { fread((char *)&idx, 4, 1, f); fread(buffer, idx, 1, f); str.assign(buffer, idx); presorted_fields.push(str); if(verbose) cout << "presorted on " << str << endl; }; fclose(f); }; tmp_table = 0; filtered = 0; for(unsigned int i=0; i < mColumnCount; i++) { //f1 = file_name + "." + nameRef.front() + ".0"; //f = fopen (f1.c_str() , "rb" ); //fread((char *)&bytes, 4, 1, f); //need to read metadata such as type and length //fclose(f); columnNames.push_back(nameRef.front()); cols[colsRef.front()] = nameRef.front(); if (((typeRef.front()).compare("decimal") == 0) || ((typeRef.front()).compare("int") == 0)) { f1 = file_name + "." + nameRef.front() + ".0"; f = fopen (f1.c_str() , "rb" ); if(!f) { cout << "Couldn't find field " << nameRef.front() << endl; exit(0); }; for(unsigned int j = 0; j < 6; j++) fread((char *)&cnt, 4, 1, f); fclose(f); compTypes[nameRef.front()] = cnt; }; //check the references f1 = file_name + "." + nameRef.front() + ".refs"; f = fopen (f1.c_str() , "rb" ); if(f) { unsigned int len; fread(&len, 4, 1, f); char* array = new char[len+1]; memset(array, 0, len+1); fread((void*)array, len, 1, f); string s(array); ref_sets[nameRef.front()] = s; delete [] array; unsigned int segs, seg_num, curr_seg; size_t res_count; fread(&len, 4, 1, f); char* array1 = new char[len+1]; memset(array1, 0, len+1); fread((void*)array1, len, 1, f); string s1(array1); ref_cols[nameRef.front()] = s1; delete [] array1; unsigned int bytes_read = fread((void*)&curr_seg, 4, 1, f); while(bytes_read == 1) { fread((void*)&segs, 4, 1, f); //ref seg count //cout << "for " << i << " read " << array << " and " << z << " " << segs << endl; for(unsigned int j = 0; j < segs; j++) { fread((void*)&seg_num, 4, 1, f); fread((void*)&res_count, 8, 1, f); //cout << "curr_seg " << curr_seg << " " << seg_num << " " << res_count << endl; if(res_count) ref_joins[columnNames[i]][curr_seg].insert(seg_num); else ref_joins[columnNames[i]][curr_seg].insert(std::numeric_limits<unsigned int>::max()); }; bytes_read = fread((void*)&curr_seg, 4, 1, f); }; fclose(f); }; if ((typeRef.front()).compare("int") == 0) { type[nameRef.front()] = 0; decimal[nameRef.front()] = 0; h_columns_int[nameRef.front()] = thrust::host_vector<int_type, pinned_allocator<int_type> >(); //h_columns_int[nameRef.front()] = thrust::host_vector<int_type >(); d_columns_int[nameRef.front()] = thrust::device_vector<int_type>(); } else if ((typeRef.front()).compare("float") == 0) { type[nameRef.front()] = 1; decimal[nameRef.front()] = 0; h_columns_float[nameRef.front()] = thrust::host_vector<float_type, pinned_allocator<float_type> >(); //h_columns_float[nameRef.front()] = thrust::host_vector<float_type>(); d_columns_float[nameRef.front()] = thrust::device_vector<float_type >(); } else if ((typeRef.front()).compare("decimal") == 0) { type[nameRef.front()] = 1; decimal[nameRef.front()] = 1; h_columns_float[nameRef.front()] = thrust::host_vector<float_type, pinned_allocator<float_type> >(); //h_columns_float[nameRef.front()] = thrust::host_vector<float_type>(); d_columns_float[nameRef.front()] = thrust::device_vector<float_type>(); } else { type[nameRef.front()] = 2; decimal[nameRef.front()] = 0; h_columns_char[nameRef.front()] = nullptr; d_columns_char[nameRef.front()] = nullptr; char_size[nameRef.front()] = sizeRef.front(); string_map[nameRef.front()] = file_name + "." + nameRef.front(); }; nameRef.pop(); typeRef.pop(); sizeRef.pop(); colsRef.pop(); }; }; void CudaSet::initialize(queue<string> &nameRef, queue<string> &typeRef, queue<int> &sizeRef, queue<int> &colsRef, size_t Recs, queue<string> &references, queue<string> &references_names) { mColumnCount = (unsigned int)nameRef.size(); tmp_table = 0; filtered = 0; mRecCount = Recs; hostRecCount = Recs; segCount = 1; for(unsigned int i=0; i < mColumnCount; i++) { columnNames.push_back(nameRef.front()); cols[colsRef.front()] = nameRef.front(); if ((typeRef.front()).compare("int") == 0) { type[nameRef.front()] = 0; decimal[nameRef.front()] = 0; h_columns_int[nameRef.front()] = thrust::host_vector<int_type, pinned_allocator<int_type> >(); //h_columns_int[nameRef.front()] = thrust::host_vector<int_type>(); d_columns_int[nameRef.front()] = thrust::device_vector<int_type>(); } else if ((typeRef.front()).compare("float") == 0) { type[nameRef.front()] = 1; decimal[nameRef.front()] = 0; h_columns_float[nameRef.front()] = thrust::host_vector<float_type, pinned_allocator<float_type> >(); //h_columns_float[nameRef.front()] = thrust::host_vector<float_type>(); d_columns_float[nameRef.front()] = thrust::device_vector<float_type>(); } else if ((typeRef.front()).compare("decimal") == 0) { type[nameRef.front()] = 1; decimal[nameRef.front()] = 1; h_columns_float[nameRef.front()] = thrust::host_vector<float_type, pinned_allocator<float_type> >(); //h_columns_float[nameRef.front()] = thrust::host_vector<float_type>(); d_columns_float[nameRef.front()] = thrust::device_vector<float_type>(); } else { type[nameRef.front()] = 2; decimal[nameRef.front()] = 0; h_columns_char[nameRef.front()] = nullptr; d_columns_char[nameRef.front()] = nullptr; char_size[nameRef.front()] = sizeRef.front(); }; if(!references.front().empty()) { ref_sets[nameRef.front()] = references.front(); ref_cols[nameRef.front()] = references_names.front(); }; nameRef.pop(); typeRef.pop(); sizeRef.pop(); colsRef.pop(); references.pop(); references_names.pop(); }; }; void CudaSet::initialize(const size_t RecordCount, const unsigned int ColumnCount) { mRecCount = RecordCount; hostRecCount = RecordCount; mColumnCount = ColumnCount; filtered = 0; }; void CudaSet::initialize(queue<string> op_sel, const queue<string> op_sel_as) { mRecCount = 0; mColumnCount = (unsigned int)op_sel.size(); segCount = 1; not_compressed = 1; filtered = 0; col_aliases = op_sel_as; unsigned int i = 0; CudaSet *a; while(!op_sel.empty()) { for(auto it = varNames.begin(); it != varNames.end(); it++) { a = it->second; if(std::find(a->columnNames.begin(), a->columnNames.end(), op_sel.front()) != a->columnNames.end()) break; }; type[op_sel.front()] = a->type[op_sel.front()]; cols[i] = op_sel.front(); decimal[op_sel.front()] = a->decimal[op_sel.front()]; columnNames.push_back(op_sel.front()); if (a->type[op_sel.front()] == 0) { d_columns_int[op_sel.front()] = thrust::device_vector<int_type>(); //h_columns_int[op_sel.front()] = thrust::host_vector<int_type, pinned_allocator<int_type> >(); h_columns_int[op_sel.front()] = thrust::host_vector<int_type>(); } else if (a->type[op_sel.front()] == 1) { d_columns_float[op_sel.front()] = thrust::device_vector<float_type>(); //h_columns_float[op_sel.front()] = thrust::host_vector<float_type, pinned_allocator<float_type> >(); h_columns_float[op_sel.front()] = thrust::host_vector<float_type>(); } else { h_columns_char[op_sel.front()] = nullptr; d_columns_char[op_sel.front()] = nullptr; char_size[op_sel.front()] = a->char_size[op_sel.front()]; }; i++; op_sel.pop(); }; } void CudaSet::initialize(CudaSet* a, CudaSet* b, queue<string> op_sel, queue<string> op_sel_as) { mRecCount = 0; mColumnCount = 0; queue<string> q_cnt(op_sel); unsigned int i = 0; set<string> field_names; while(!q_cnt.empty()) { if( std::find(a->columnNames.begin(), a->columnNames.end(), q_cnt.front()) != a->columnNames.end() || std::find(b->columnNames.begin(), b->columnNames.end(), q_cnt.front()) != b->columnNames.end()) { field_names.insert(q_cnt.front()); }; q_cnt.pop(); } mColumnCount = (unsigned int)field_names.size(); maxRecs = b->maxRecs; segCount = 1; filtered = 0; not_compressed = 1; col_aliases = op_sel_as; i = 0; while(!op_sel.empty()) { if(std::find(columnNames.begin(), columnNames.end(), op_sel.front()) == columnNames.end()) { if(std::find(a->columnNames.begin(), a->columnNames.end(), op_sel.front()) != a->columnNames.end()) { cols[i] = op_sel.front(); decimal[op_sel.front()] = a->decimal[op_sel.front()]; columnNames.push_back(op_sel.front()); type[op_sel.front()] = a->type[op_sel.front()]; if (a->type[op_sel.front()] == 0) { d_columns_int[op_sel.front()] = thrust::device_vector<int_type>(); h_columns_int[op_sel.front()] = thrust::host_vector<int_type, pinned_allocator<int_type> >(); //h_columns_int[op_sel.front()] = thrust::host_vector<int_type>(); if(a->string_map.find(op_sel.front()) != a->string_map.end()) { string_map[op_sel.front()] = a->string_map[op_sel.front()]; //cout << "SETTING J " << op_sel.front() << " " << a->string_map[op_sel.front()] << endl; }; } else if (a->type[op_sel.front()] == 1) { d_columns_float[op_sel.front()] = thrust::device_vector<float_type>(); h_columns_float[op_sel.front()] = thrust::host_vector<float_type, pinned_allocator<float_type> >(); //h_columns_float[op_sel.front()] = thrust::host_vector<float_type>(); } else { h_columns_char[op_sel.front()] = nullptr; d_columns_char[op_sel.front()] = nullptr; char_size[op_sel.front()] = a->char_size[op_sel.front()]; string_map[op_sel.front()] = a->string_map[op_sel.front()]; //cout << "SETTING J " << op_sel.front() << " " << a->string_map[op_sel.front()] << endl; }; i++; } else if(std::find(b->columnNames.begin(), b->columnNames.end(), op_sel.front()) != b->columnNames.end()) { columnNames.push_back(op_sel.front()); cols[i] = op_sel.front(); decimal[op_sel.front()] = b->decimal[op_sel.front()]; type[op_sel.front()] = b->type[op_sel.front()]; if (b->type[op_sel.front()] == 0) { d_columns_int[op_sel.front()] = thrust::device_vector<int_type>(); h_columns_int[op_sel.front()] = thrust::host_vector<int_type, pinned_allocator<int_type> >(); //h_columns_int[op_sel.front()] = thrust::host_vector<int_type>(); if(b->string_map.find(op_sel.front()) != b->string_map.end()) { string_map[op_sel.front()] = b->string_map[op_sel.front()]; //cout << "SETTING J " << op_sel.front() << " " << b->string_map[op_sel.front()] << endl; }; } else if (b->type[op_sel.front()] == 1) { d_columns_float[op_sel.front()] = thrust::device_vector<float_type>(); h_columns_float[op_sel.front()] = thrust::host_vector<float_type, pinned_allocator<float_type> >(); //h_columns_float[op_sel.front()] = thrust::host_vector<float_type>(); } else { h_columns_char[op_sel.front()] = nullptr; d_columns_char[op_sel.front()] = nullptr; char_size[op_sel.front()] = b->char_size[op_sel.front()]; string_map[op_sel.front()] = b->string_map[op_sel.front()]; //cout << "SETTING J " << op_sel.front() << " " << b->string_map[op_sel.front()] << endl; }; i++; } } op_sel.pop(); }; }; int_type reverse_op(int_type op_type) { if (op_type == 2) // > return 5; else if (op_type == 1) // < return 6; else if (op_type == 6) // >= return 1; else if (op_type == 5) // <= return 2; else return op_type; } size_t getFreeMem() { size_t available, total; hipMemGetInfo(&available, &total); return available; } ; void allocColumns(CudaSet* a, queue<string> fields) { if(a->filtered) { CudaSet* t; if(a->filtered) t = varNames[a->source_name]; else t = a; if(int_size*t->maxRecs > alloced_sz) { if(alloced_sz) { hipFree(alloced_tmp); }; hipMalloc((void **) &alloced_tmp, int_size*t->maxRecs); alloced_sz = int_size*t->maxRecs; } } else { while(!fields.empty()) { if(var_exists(a, fields.front()) && !a->onDevice(fields.front())) { a->allocColumnOnDevice(fields.front(), a->maxRecs); } fields.pop(); }; }; } void gatherColumns(CudaSet* a, CudaSet* t, string field, unsigned int segment, size_t& count) { if(!a->onDevice(field)) { a->allocColumnOnDevice(field, a->maxRecs); }; if(a->prm_index == 'R') { mygather(field, a, t, count, a->mRecCount); } else { mycopy(field, a, t, count, t->mRecCount); a->mRecCount = t->mRecCount; }; } size_t getSegmentRecCount(CudaSet* a, unsigned int segment) { if (segment == a->segCount-1) { return a->hostRecCount - a->maxRecs*segment; } else return a->maxRecs; } void copyColumns(CudaSet* a, queue<string> fields, unsigned int segment, size_t& count, bool rsz, bool flt) { set<string> uniques; if(a->filtered) { //filter the segment if(flt) { filter_op(a->fil_s, a->fil_f, segment); }; if(rsz && a->mRecCount) { queue<string> fields1(fields); while(!fields1.empty()) { a->resizeDeviceColumn(a->devRecCount + a->mRecCount, fields1.front()); fields1.pop(); }; a->devRecCount = a->devRecCount + a->mRecCount; }; }; while(!fields.empty()) { if (uniques.count(fields.front()) == 0 && var_exists(a, fields.front())) { if(a->filtered) { if(a->mRecCount) { CudaSet *t = varNames[a->source_name]; alloced_switch = 1; t->CopyColumnToGpu(fields.front(), segment); thrust::device_ptr<int_type> d_col((int_type*)alloced_tmp); gatherColumns(a, t, fields.front(), segment, count); alloced_switch = 0; if(t->orig_segs.size() >= segment+1) { a->orig_segs.resize(segment+1); a->orig_segs.resize(segment+1); a->orig_segs[segment] = t->orig_segs[segment]; }; }; } else { if(a->mRecCount) { a->CopyColumnToGpu(fields.front(), segment, count); }; }; uniques.insert(fields.front()); }; fields.pop(); }; } void setPrm(CudaSet* a, CudaSet* b, char val, unsigned int segment) { b->prm_index = val; if (val == 'A') { b->mRecCount = getSegmentRecCount(a,segment); } else if (val == 'N') { b->mRecCount = 0; } } void mygather(string colname, CudaSet* a, CudaSet* t, size_t offset, size_t g_size) { if(t->type[colname] != 1 ) { if(!alloced_switch) { thrust::gather(a->prm_d.begin(), a->prm_d.begin() + g_size, t->d_columns_int[colname].begin(), a->d_columns_int[colname].begin() + offset); } else { thrust::device_ptr<int_type> d_col((int_type*)alloced_tmp); thrust::gather(a->prm_d.begin(), a->prm_d.begin() + g_size, d_col, a->d_columns_int[colname].begin() + offset); }; } else { if(!alloced_switch) { thrust::gather(a->prm_d.begin(), a->prm_d.begin() + g_size, t->d_columns_float[colname].begin(), a->d_columns_float[colname].begin() + offset); } else { thrust::device_ptr<float_type> d_col((float_type*)alloced_tmp); thrust::gather(a->prm_d.begin(), a->prm_d.begin() + g_size, d_col, a->d_columns_float[colname].begin() + offset); }; } }; void mycopy(string colname, CudaSet* a, CudaSet* t, size_t offset, size_t g_size) { if(t->type[colname] != 1) { if(!alloced_switch) { thrust::copy(t->d_columns_int[colname].begin(), t->d_columns_int[colname].begin() + g_size, a->d_columns_int[colname].begin() + offset); } else { thrust::device_ptr<int_type> d_col((int_type*)alloced_tmp); thrust::copy(d_col, d_col + g_size, a->d_columns_int[colname].begin() + offset); }; } else { if(!alloced_switch) { thrust::copy(t->d_columns_float[colname].begin(), t->d_columns_float[colname].begin() + g_size, a->d_columns_float[colname].begin() + offset); } else { thrust::device_ptr<float_type> d_col((float_type*)alloced_tmp); thrust::copy(d_col, d_col + g_size, a->d_columns_float[colname].begin() + offset); }; }; }; size_t load_queue(queue<string> c1, CudaSet* right, string f2, size_t &rcount, unsigned int start_segment, unsigned int end_segment, bool rsz, bool flt) { queue<string> cc; while(!c1.empty()) { if(std::find(right->columnNames.begin(), right->columnNames.end(), c1.front()) != right->columnNames.end()) { if(f2 != c1.front() ) { cc.push(c1.front()); }; }; c1.pop(); }; if(std::find(right->columnNames.begin(), right->columnNames.end(), f2) != right->columnNames.end()) { cc.push(f2); }; if(right->filtered) { allocColumns(right, cc); }; rcount = right->maxRecs; queue<string> ct(cc); while(!ct.empty()) { if(right->filtered && rsz) { right->mRecCount = 0; } else { right->allocColumnOnDevice(ct.front(), rcount); }; ct.pop(); }; size_t cnt_r = 0; right->devRecCount = 0; for(unsigned int i = start_segment; i < end_segment; i++) { if(!right->filtered) copyColumns(right, cc, i, cnt_r, rsz, 0); else copyColumns(right, cc, i, cnt_r, rsz, flt); cnt_r = cnt_r + right->mRecCount; }; right->mRecCount = cnt_r; return cnt_r; } size_t max_char(CudaSet* a) { size_t max_char1 = 8; for(unsigned int i = 0; i < a->columnNames.size(); i++) { if(a->type[a->columnNames[i]] == 2) { if (a->char_size[a->columnNames[i]] > max_char1) max_char1 = a->char_size[a->columnNames[i]]; } else if(a->type[a->columnNames[i]] == 0 && a->string_map.find(a->columnNames[i]) != a->string_map.end()) { auto s = a->string_map[a->columnNames[i]]; auto pos = s.find_first_of("."); auto len = data_dict[s.substr(0, pos)][s.substr(pos+1)].col_length; if (len > max_char1) max_char1 = len; }; }; return max_char1; }; size_t max_char(CudaSet* a, queue<string> field_names) { size_t max_char = 8; while (!field_names.empty()) { if (a->type[field_names.front()] == 2) { if (a->char_size[field_names.front()] > max_char) max_char = a->char_size[field_names.front()]; }; field_names.pop(); }; return max_char; }; void setSegments(CudaSet* a, queue<string> cols) { size_t mem_available = getFreeMem(); size_t tot_sz = 0; while(!cols.empty()) { if(a->type[cols.front()] != 2) tot_sz = tot_sz + int_size; else tot_sz = tot_sz + a->char_size[cols.front()]; cols.pop(); }; if(a->mRecCount*tot_sz > mem_available/3) { //default is 3 a->segCount = (a->mRecCount*tot_sz)/(mem_available/5) + 1; a->maxRecs = (a->mRecCount/a->segCount)+1; }; }; void update_permutation_char_host(char* key, unsigned int* permutation, size_t RecCount, string SortType, char* tmp, unsigned int len) { str_gather_host(permutation, RecCount, (void*)key, (void*)tmp, len); if (SortType.compare("DESC") == 0 ) str_sort_host(tmp, RecCount, permutation, 1, len); else str_sort_host(tmp, RecCount, permutation, 0, len); } void apply_permutation_char(char* key, unsigned int* permutation, size_t RecCount, char* tmp, unsigned int len) { // copy keys to temporary vector hipMemcpy( (void*)tmp, (void*) key, RecCount*len, hipMemcpyDeviceToDevice); // permute the keys str_gather((void*)permutation, RecCount, (void*)tmp, (void*)key, len); } void apply_permutation_char_host(char* key, unsigned int* permutation, size_t RecCount, char* res, unsigned int len) { str_gather_host(permutation, RecCount, (void*)key, (void*)res, len); } void filter_op(const char *s, const char *f, unsigned int segment) { CudaSet *a, *b; a = varNames.find(f)->second; a->name = f; std::clock_t start1 = std::clock(); if(a->mRecCount == 0 && !a->filtered) { b = new CudaSet(0,1); } else { if(verbose) cout << "FILTER " << s << " " << f << " " << getFreeMem() << '\xd'; b = varNames[s]; b->name = s; b->string_map = a->string_map; size_t cnt = 0; allocColumns(a, b->fil_value); if (b->prm_d.size() == 0) b->prm_d.resize(a->maxRecs); //cout << endl << "MAP CHECK start " << segment << endl; char map_check = zone_map_check(b->fil_type,b->fil_value,b->fil_nums, b->fil_nums_f, a, segment); //cout << endl << "MAP CHECK segment " << segment << " " << map_check << endl; if(map_check == 'R') { copyColumns(a, b->fil_value, segment, cnt); bool* res = filter(b->fil_type,b->fil_value,b->fil_nums, b->fil_nums_f, a, segment); thrust::device_ptr<bool> bp((bool*)res); b->prm_index = 'R'; b->mRecCount = thrust::count(bp, bp + (unsigned int)a->mRecCount, 1); thrust::copy_if(thrust::make_counting_iterator((unsigned int)0), thrust::make_counting_iterator((unsigned int)a->mRecCount), bp, b->prm_d.begin(), thrust::identity<bool>()); hipFree(res); } else { setPrm(a,b,map_check,segment); }; if(segment == a->segCount-1) a->deAllocOnDevice(); } if(verbose) cout << endl << "filter res " << b->mRecCount << endl; //std::cout<< "filter time " << ( ( std::clock() - start1 ) / (double)CLOCKS_PER_SEC ) << " " << getFreeMem() << '\n'; } size_t load_right(CudaSet* right, string colname, string f2, queue<string> op_g, queue<string> op_sel, queue<string> op_alt, bool decimal_join, size_t& rcount, unsigned int start_seg, unsigned int end_seg, bool rsz) { size_t cnt_r = 0; //if join is on strings then add integer columns to left and right tables and modify colInd1 and colInd2 // need to allocate all right columns if(right->not_compressed) { queue<string> op_alt1; op_alt1.push(f2); cnt_r = load_queue(op_alt1, right, "", rcount, start_seg, end_seg, rsz, 1); } else { cnt_r = load_queue(op_alt, right, f2, rcount, start_seg, end_seg, rsz, 1); }; /* if (right->type[colname] == 2) { str_join = 1; right->d_columns_int[f2] = thrust::device_vector<int_type>(); for(unsigned int i = start_seg; i < end_seg; i++) { right->add_hashed_strings(f2, i); }; cnt_r = right->d_columns_int[f2].size(); }; */ if(right->not_compressed) { queue<string> op_alt1; while(!op_alt.empty()) { if(f2.compare(op_alt.front())) { if (std::find(right->columnNames.begin(), right->columnNames.end(), op_alt.front()) != right->columnNames.end()) { op_alt1.push(op_alt.front()); }; }; op_alt.pop(); }; if(!op_alt1.empty()) cnt_r = load_queue(op_alt1, right, "", rcount, start_seg, end_seg, 0, 0); }; return cnt_r; }; void insert_records(const char* f, const char* s) { char buf[4096]; size_t size, maxRecs, cnt = 0; string str_s, str_d; if(varNames.find(s) == varNames.end()) { process_error(3, "couldn't find " + string(s) ); }; CudaSet *a; a = varNames.find(s)->second; a->name = s; if(varNames.find(f) == varNames.end()) { process_error(3, "couldn't find " + string(f) ); }; CudaSet *b; b = varNames.find(f)->second; b->name = f; // if both source and destination are on disk cout << "SOURCES " << a->source << ":" << b->source << endl; if(a->source && b->source) { for(unsigned int i = 0; i < a->segCount; i++) { for(unsigned int z = 0; z < a->columnNames.size(); z++) { if(a->type[a->columnNames[z]] != 2) { str_s = a->load_file_name + "." + a->columnNames[z] + "." + to_string(i); str_d = b->load_file_name + "." + a->columnNames[z] + "." + to_string(b->segCount + i); cout << str_s << " " << str_d << endl; FILE* source = fopen(str_s.c_str(), "rb"); FILE* dest = fopen(str_d.c_str(), "wb"); while (size = fread(buf, 1, BUFSIZ, source)) { fwrite(buf, 1, size, dest); } fclose(source); fclose(dest); } else { //merge strings //read b's strings str_s = b->load_file_name + "." + b->columnNames[z]; FILE* dest = fopen(str_s.c_str(), "rb"); auto len = b->char_size[b->columnNames[z]]; map<string, unsigned long long int> map_d; buf[len] = 0; unsigned long long cnt = 0; while (fread(buf, len, 1, dest)) { map_d[buf] = cnt; cnt++; }; fclose(dest); unsigned long long int cct = cnt; str_s = a->load_file_name + "." + a->columnNames[z] + "." + to_string(i) + ".hash"; str_d = b->load_file_name + "." + b->columnNames[z] + "." + to_string(b->segCount + i) + ".hash"; FILE* source = fopen(str_s.c_str(), "rb"); dest = fopen(str_d.c_str(), "wb"); while (size = fread(buf, 1, BUFSIZ, source)) { fwrite(buf, 1, size, dest); } fclose(source); fclose(dest); str_s = a->load_file_name + "." + a->columnNames[z]; source = fopen(str_s.c_str(), "rb"); map<unsigned long long int, string> map_s; buf[len] = 0; cnt = 0; while (fread(buf, len, 1, source)) { map_s[cnt] = buf; cnt++; }; fclose(source); queue<string> op_vx; op_vx.push(a->columnNames[z]); allocColumns(a, op_vx); a->resize(a->maxRecs); a->CopyColumnToGpu(a->columnNames[z], z, 0); a->CopyColumnToHost(a->columnNames[z]); str_d = b->load_file_name + "." + b->columnNames[z]; fstream f_file; f_file.open(str_d.c_str(), ios::out|ios::app|ios::binary); for(auto j = 0; j < a->mRecCount; j++) { auto ss = map_s[a->h_columns_int[a->columnNames[z]][j]]; if(map_d.find(ss) == map_d.end()) { //add f_file.write((char *)ss.c_str(), len); a->h_columns_int[a->columnNames[z]][j] = cct; cct++; } else { a->h_columns_int[a->columnNames[z]][j] = map_d[ss]; }; }; f_file.close(); thrust::device_vector<int_type> d_col(a->mRecCount); thrust::copy(a->h_columns_int[a->columnNames[z]].begin(), a->h_columns_int[a->columnNames[z]].begin() + a->mRecCount, d_col.begin()); auto i_name = b->load_file_name + "." + b->columnNames[z] + "." + to_string(b->segCount + i) + ".idx"; pfor_compress(thrust::raw_pointer_cast(d_col.data()), a->mRecCount*int_size, i_name, a->h_columns_int[a->columnNames[z]], 0); }; }; }; if(a->maxRecs > b->maxRecs) maxRecs = a->maxRecs; else maxRecs = b->maxRecs; for(unsigned int i = 0; i < b->columnNames.size(); i++) { b->reWriteHeader(b->load_file_name, b->columnNames[i], a->segCount + b->segCount, a->totalRecs + b->totalRecs, maxRecs); }; } else if(!a->source && !b->source) { //if both source and destination are in memory size_t oldCount = b->mRecCount; b->resize(a->mRecCount); for(unsigned int z = 0; z< b->mColumnCount; z++) { if(b->type[a->columnNames[z]] == 0) { thrust::copy(a->h_columns_int[a->columnNames[z]].begin(), a->h_columns_int[a->columnNames[z]].begin() + a->mRecCount, b->h_columns_int[b->columnNames[z]].begin() + oldCount); } else if(b->type[a->columnNames[z]] == 1) { thrust::copy(a->h_columns_float[a->columnNames[z]].begin(), a->h_columns_float[a->columnNames[z]].begin() + a->mRecCount, b->h_columns_float[b->columnNames[z]].begin() + oldCount); } else { hipMemcpy(b->h_columns_char[b->columnNames[z]] + b->char_size[b->columnNames[z]]*oldCount, a->h_columns_char[a->columnNames[z]], a->char_size[a->columnNames[z]]*a->mRecCount, hipMemcpyHostToHost); }; }; } else if(!a->source && b->source) { total_segments = b->segCount; total_count = b->mRecCount; total_max = b->maxRecs;; queue<string> op_vx; for(unsigned int i=0; i < a->columnNames.size(); i++) op_vx.push(a->columnNames[i]); allocColumns(a, op_vx); a->resize(a->maxRecs); for(unsigned int i = 0; i < a->segCount; i++) { if (a->filtered) { copyColumns(a, op_vx, i, cnt); a->CopyToHost(0, a->mRecCount); }; a->compress(b->load_file_name, 0, 1, i - (a->segCount-1), a->mRecCount); }; for(unsigned int i = 0; i < b->columnNames.size(); i++) { b->writeHeader(b->load_file_name, b->columnNames[i], total_segments); }; }; }; void delete_records(const char* f) { CudaSet *a; a = varNames.find(f)->second; a->name = f; size_t totalRemoved = 0; size_t maxRecs = 0; if(!a->keep) { // temporary variable process_error(2, "Delete operator is only applicable to disk based sets\nfor deleting records from derived sets please use filter operator "); } else { // read matching segments, delete, compress and write on a disk replacing the original segments string str, str_old; queue<string> op_vx; size_t cnt; for ( auto it=data_dict[a->load_file_name].begin() ; it != data_dict[a->load_file_name].end(); ++it ) { op_vx.push((*it).first); if (std::find(a->columnNames.begin(), a->columnNames.end(), (*it).first) == a->columnNames.end()) { if ((*it).second.col_type == 0) { a->type[(*it).first] = 0; a->decimal[(*it).first] = 0; //a->h_columns_int[(*it).first] = thrust::host_vector<int_type, pinned_allocator<int_type> >(); a->h_columns_int[(*it).first] = thrust::host_vector<int_type>(); a->d_columns_int[(*it).first] = thrust::device_vector<int_type>(); } else if((*it).second.col_type == 1) { a->type[(*it).first] = 1; a->decimal[(*it).first] = 0; //a->h_columns_float[(*it).first] = thrust::host_vector<float_type, pinned_allocator<float_type> >(); a->h_columns_float[(*it).first] = thrust::host_vector<float_type>(); a->d_columns_float[(*it).first] = thrust::device_vector<float_type>(); } else if ((*it).second.col_type == 3) { a->type[(*it).first] = 1; a->decimal[(*it).first] = 1; //a->h_columns_float[(*it).first] = thrust::host_vector<float_type, pinned_allocator<float_type> >(); a->h_columns_float[(*it).first] = thrust::host_vector<float_type>(); a->d_columns_float[(*it).first] = thrust::device_vector<float_type>(); } else { a->type[(*it).first] = 2; a->decimal[(*it).first] = 0; a->h_columns_char[(*it).first] = nullptr; a->d_columns_char[(*it).first] = nullptr; a->char_size[(*it).first] = (*it).second.col_length; }; a->columnNames.push_back((*it).first); } }; allocColumns(a, op_vx); a->resize(a->maxRecs); a->prm_d.resize(a->maxRecs); size_t cc = a->mRecCount; size_t tmp; void* d; CUDA_SAFE_CALL(hipMalloc((void **) &d, a->maxRecs*float_size)); unsigned int new_seg_count = 0; char map_check; for(unsigned int i = 0; i < a->segCount; i++) { map_check = zone_map_check(op_type,op_value,op_nums, op_nums_f, a, i); if(verbose) cout << "MAP CHECK segment " << i << " " << map_check << endl; if(map_check != 'N') { cnt = 0; copyColumns(a, op_vx, i, cnt); tmp = a->mRecCount; if(a->mRecCount) { bool* res = filter(op_type,op_value,op_nums, op_nums_f, a, i); thrust::device_ptr<bool> bp((bool*)res); thrust::copy_if(thrust::make_counting_iterator((unsigned int)0), thrust::make_counting_iterator((unsigned int)a->mRecCount), bp, a->prm_d.begin(), not_identity<bool>()); a->mRecCount = thrust::count(bp, bp + (unsigned int)a->mRecCount, 0); hipFree(res); // cout << "Remained recs count " << a->mRecCount << endl; if(a->mRecCount > maxRecs) maxRecs = a->mRecCount; if (a->mRecCount) { totalRemoved = totalRemoved + (tmp - a->mRecCount); if (a->mRecCount == tmp) { //none deleted if(new_seg_count != i) { for (auto it=data_dict[a->load_file_name].begin() ; it != data_dict[a->load_file_name].end(); ++it ) { auto colname = (*it).first; str_old = a->load_file_name + "." + colname + "." + to_string(i); str = a->load_file_name + "." + colname + "." + to_string(new_seg_count); remove(str.c_str()); rename(str_old.c_str(), str.c_str()); }; }; new_seg_count++; } else { //some deleted //cout << "writing segment " << new_seg_count << endl; map<string, col_data> s = data_dict[a->load_file_name]; for ( map<string, col_data>::iterator it=s.begin() ; it != s.end(); ++it ) { string colname = (*it).first; str = a->load_file_name + "." + colname + "." + to_string(new_seg_count); if(a->type[colname] == 0) { thrust::device_ptr<int_type> d_col((int_type*)d); thrust::gather(a->prm_d.begin(), a->prm_d.begin() + a->mRecCount, a->d_columns_int[colname].begin(), d_col); pfor_compress( d, a->mRecCount*int_size, str, a->h_columns_int[colname], 0); } else if(a->type[colname] == 1) { thrust::device_ptr<float_type> d_col((float_type*)d); if(a->decimal[colname]) { thrust::gather(a->prm_d.begin(), a->prm_d.begin() + a->mRecCount, a->d_columns_float[colname].begin(), d_col); thrust::device_ptr<long long int> d_col_dec((long long int*)d); thrust::transform(d_col,d_col+a->mRecCount, d_col_dec, float_to_long()); pfor_compress( d, a->mRecCount*float_size, str, a->h_columns_float[colname], 1); } else { thrust::gather(a->prm_d.begin(), a->prm_d.begin() + a->mRecCount, a->d_columns_float[colname].begin(), d_col); thrust::copy(d_col, d_col + a->mRecCount, a->h_columns_float[colname].begin()); fstream binary_file(str.c_str(),ios::out|ios::binary); binary_file.write((char *)&a->mRecCount, 4); binary_file.write((char *)(a->h_columns_float[colname].data()),a->mRecCount*float_size); unsigned int comp_type = 3; binary_file.write((char *)&comp_type, 4); binary_file.close(); }; } else { thrust::device_ptr<int_type> d_col((int_type*)d); thrust::gather(a->prm_d.begin(), a->prm_d.begin() + a->mRecCount, a->d_columns_int[colname].begin(), d_col); pfor_compress( d, a->mRecCount*int_size, str + ".hash", a->h_columns_int[colname], 0); }; }; new_seg_count++; }; } else { totalRemoved = totalRemoved + tmp; }; } } else { if(new_seg_count != i) { for(unsigned int z = 0; z < a->columnNames.size(); z++) { str_old = a->load_file_name + "." + a->columnNames[z] + "." + to_string(i); str = a->load_file_name + "." + a->columnNames[z] + "." + to_string(new_seg_count); remove(str.c_str()); rename(str_old.c_str(), str.c_str()); }; }; new_seg_count++; maxRecs = a->maxRecs; }; }; if (new_seg_count < a->segCount) { for(unsigned int i = new_seg_count; i < a->segCount; i++) { //cout << "delete segment " << i << endl; for(unsigned int z = 0; z < a->columnNames.size(); z++) { str = a->load_file_name + "." + a->columnNames[z]; str += "." + to_string(i); remove(str.c_str()); }; }; }; for(unsigned int i = new_seg_count; i < a->segCount; i++) { a->reWriteHeader(a->load_file_name, a->columnNames[i], new_seg_count, a->totalRecs-totalRemoved, maxRecs); }; a->mRecCount = cc; a->prm_d.resize(0); a->segCount = new_seg_count; a->deAllocOnDevice(); hipFree(d); }; }; void save_col_data(map<string, map<string, col_data> >& data_dict, string file_name) { size_t str_len; fstream binary_file(file_name.c_str(),ios::out|ios::binary|ios::trunc); size_t len = data_dict.size(); binary_file.write((char *)&len, 8); for (auto it=data_dict.begin() ; it != data_dict.end(); ++it ) { str_len = (*it).first.size(); binary_file.write((char *)&str_len, 8); binary_file.write((char *)(*it).first.data(), str_len); map<string, col_data> s = (*it).second; size_t len1 = s.size(); binary_file.write((char *)&len1, 8); for (auto sit=s.begin() ; sit != s.end(); ++sit ) { str_len = (*sit).first.size(); binary_file.write((char *)&str_len, 8); binary_file.write((char *)(*sit).first.data(), str_len); binary_file.write((char *)&(*sit).second.col_type, 4); binary_file.write((char *)&(*sit).second.col_length, 4); }; }; binary_file.close(); } void load_col_data(map<string, map<string, col_data> >& data_dict, string file_name) { size_t str_len, recs, len1; string str1, str2; char buffer[4000]; unsigned int col_type, col_length; fstream binary_file; binary_file.open(file_name.c_str(),ios::in|ios::binary); if(binary_file.is_open()) { binary_file.read((char*)&recs, 8); for(unsigned int i = 0; i < recs; i++) { binary_file.read((char*)&str_len, 8); binary_file.read(buffer, str_len); str1.assign(buffer, str_len); binary_file.read((char*)&len1, 8); for(unsigned int j = 0; j < len1; j++) { binary_file.read((char*)&str_len, 8); binary_file.read(buffer, str_len); str2.assign(buffer, str_len); binary_file.read((char*)&col_type, 4); binary_file.read((char*)&col_length, 4); data_dict[str1][str2].col_type = col_type; data_dict[str1][str2].col_length = col_length; //cout << "data DICT " << str1 << " " << str2 << " " << col_type << " " << col_length << endl; }; }; binary_file.close(); } else { cout << "Couldn't open data dictionary" << endl; }; } bool var_exists(CudaSet* a, string name) { if(std::find(a->columnNames.begin(), a->columnNames.end(), name) != a->columnNames.end()) return 1; else return 0; } int file_exist (const char *filename) { std::ifstream infile(filename); return infile.good(); } bool check_bitmap_file_exist(CudaSet* left, CudaSet* right) { queue<string> cols(right->fil_value); bool bitmaps_exist = 1; if(cols.size() == 0) { bitmaps_exist = 0; }; while(cols.size() ) { if (std::find(right->columnNames.begin(), right->columnNames.end(), cols.front()) != right->columnNames.end()) { string fname = left->load_file_name + "." + right->load_file_name + "." + cols.front() + ".0"; if( !file_exist(fname.c_str())) { bitmaps_exist = 0; }; }; cols.pop(); }; return bitmaps_exist; } bool check_bitmaps_exist(CudaSet* left, CudaSet* right) { //check if there are join bitmap indexes queue<string> cols(right->fil_value); bool bitmaps_exist = 1; if(cols.size() == 0) { bitmaps_exist = 1; return 1; }; while(cols.size() ) { if (std::find(right->columnNames.begin(), right->columnNames.end(), cols.front()) != right->columnNames.end()) { string fname = left->load_file_name + "." + right->load_file_name + "." + cols.front() + ".0"; if( !file_exist(fname.c_str())) { bitmaps_exist = 0; }; }; cols.pop(); }; if(bitmaps_exist) { while(!right->fil_nums.empty() ) { left->fil_nums.push(right->fil_nums.front()); right->fil_nums.pop(); }; while(!right->fil_nums_f.empty() ) { left->fil_nums_f.push(right->fil_nums_f.front()); right->fil_nums_f.pop(); }; while(!right->fil_value.empty() ) { if (std::find(right->columnNames.begin(), right->columnNames.end(), right->fil_value.front()) != right->columnNames.end()) { string fname = left->load_file_name + "." + right->load_file_name + "." + right->fil_value.front(); left->fil_value.push(fname); } else left->fil_value.push(right->fil_value.front()); right->fil_value.pop(); }; bool add_and = 1; if(left->fil_type.empty()) add_and = 0; while(!right->fil_type.empty() ) { left->fil_type.push(right->fil_type.front()); right->fil_type.pop(); }; if(add_and) { left->fil_type.push("AND"); }; return 1; } else { return 0; }; } void check_sort(const string str, const char* rtable, const char* rid) { CudaSet* right = varNames.find(rtable)->second; fstream binary_file(str.c_str(),ios::out|ios::binary|ios::app); binary_file.write((char *)&right->sort_check, 1); binary_file.close(); } void update_char_permutation(CudaSet* a, string colname, unsigned int* raw_ptr, string ord, void* temp, bool host) { unordered_map<string, unordered_map<unsigned long long int, string> > string_hash; auto s = a->string_map[colname]; auto pos = s.find_first_of("."); auto len = data_dict[s.substr(0, pos)][s.substr(pos+1)].col_length; a->h_columns_char[colname] = new char[a->mRecCount*len]; memset(a->h_columns_char[colname], 0, a->mRecCount*len); thrust::device_ptr<unsigned int> perm(raw_ptr); thrust::device_ptr<int_type> temp_int((int_type*)temp); thrust::gather(perm, perm+a->mRecCount, a->d_columns_int[colname].begin(), temp_int); thrust::copy(temp_int, temp_int+a->mRecCount, a->h_columns_int[colname].begin()); FILE *f; f = fopen(a->string_map[colname].c_str(), "rb"); for(int z = 0 ; z < a->mRecCount; z++) { fseek(f, a->h_columns_int[colname][z] * len, SEEK_SET); fread(a->h_columns_char[colname] + z*len, 1, len, f); }; fclose(f); if(!host) { void *d; hipMalloc((void **) &d, a->mRecCount*len); a->d_columns_char[colname] = (char*)d; hipMemcpy(a->d_columns_char[colname], a->h_columns_char[colname], len*a->mRecCount, hipMemcpyHostToDevice); if (ord.compare("DESC") == 0 ) str_sort(a->d_columns_char[colname], a->mRecCount, raw_ptr, 1, len); else str_sort(a->d_columns_char[colname], a->mRecCount, raw_ptr, 0, len); hipFree(d); } else { if (ord.compare("DESC") == 0 ) str_sort_host(a->h_columns_char[colname], a->mRecCount, raw_ptr, 1, len); else str_sort_host(a->h_columns_char[colname], a->mRecCount, raw_ptr, 0, len); }; } #ifdef _WIN64 size_t getTotalSystemMemory() { MEMORYSTATUSEX status; status.dwLength = sizeof(status); GlobalMemoryStatusEx(&status); return status.ullTotalPhys; } #else size_t getTotalSystemMemory() { long pages = sysconf(_SC_PHYS_PAGES); long page_size = sysconf(_SC_PAGE_SIZE); return pages * page_size; } #endif
ad99b821355ac1244b6d99ac2e46ba6cf111471e.cu
/* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <cctype> #include <algorithm> #include <functional> #include <numeric> #include "cm.h" #include "atof.h" #include "compress.cu" #include "sorts.cu" #include "filter.h" #include "callbacks.h" #ifdef _WIN64 #define atoll(S) _atoi64(S) #include <windows.h> #else #include <unistd.h> #endif using namespace std; size_t total_count = 0, total_max; clock_t tot; unsigned int total_segments = 0; unsigned int process_count; size_t alloced_sz = 0; bool fact_file_loaded = 1; bool verbose; bool interactive, ssd, delta, star; void* d_v = nullptr; void* s_v = nullptr; queue<string> op_sort; queue<string> op_presort; queue<string> op_type; bool op_case = 0; queue<string> op_value; queue<int_type> op_nums; queue<float_type> op_nums_f; queue<string> col_aliases; map<string, map<string, col_data> > data_dict; unordered_map<string, unordered_map<unsigned long long int, size_t> > char_hash; map<string, char*> index_buffers; map<string, char*> buffers; map<string, size_t> buffer_sizes; size_t total_buffer_size; queue<string> buffer_names; void* alloced_tmp; bool alloced_switch = 0; map<string,CudaSet*> varNames; // STL map to manage CudaSet variables struct is_match { __host__ __device__ bool operator()(unsigned int x) { return x != 4294967295; } }; struct f_equal_to { __host__ __device__ bool operator()(const float_type x, const float_type y) { return (((x-y) < EPSILON) && ((x-y) > -EPSILON)); } }; struct f_less { __host__ __device__ bool operator()(const float_type x, const float_type y) { return ((y-x) > EPSILON); } }; struct f_greater { __host__ __device__ bool operator()(const float_type x, const float_type y) { return ((x-y) > EPSILON); } }; struct f_greater_equal_to { __host__ __device__ bool operator()(const float_type x, const float_type y) { return (((x-y) > EPSILON) || (((x-y) < EPSILON) && ((x-y) > -EPSILON))); } }; struct f_less_equal { __host__ __device__ bool operator()(const float_type x, const float_type y) { return (((y-x) > EPSILON) || (((x-y) < EPSILON) && ((x-y) > -EPSILON))); } }; struct f_not_equal_to { __host__ __device__ bool operator()(const float_type x, const float_type y) { return ((x-y) > EPSILON) || ((x-y) < -EPSILON); } }; struct long_to_float_type { __host__ __device__ float_type operator()(const int_type x) { return (float_type)x; } }; struct to_zero { __host__ __device__ bool operator()(const int_type x) { if(x == -1) return 0; else return 1; } }; struct div_long_to_float_type { __host__ __device__ float_type operator()(const int_type x, const float_type y) { return (float_type)x/y; } }; char *mystrtok(char **m,char *s,const char c) { char *p=s?s:*m; if( !*p ) return 0; *m=strchr(p,c); if( *m ) *(*m)++=0; else *m=p+strlen(p); return p; } void allocColumns(CudaSet* a, queue<string> fields); void copyColumns(CudaSet* a, queue<string> fields, unsigned int segment, size_t& count, bool rsz, bool flt); void mygather(unsigned int tindex, unsigned int idx, CudaSet* a, CudaSet* t, size_t count, size_t g_size); void mycopy(unsigned int tindex, unsigned int idx, CudaSet* a, CudaSet* t, size_t count, size_t g_size); void write_compressed_char(string file_name, unsigned int index, size_t mCount); size_t getFreeMem(); char zone_map_check(queue<string> op_type, queue<string> op_value, queue<int_type> op_nums,queue<float_type> op_nums_f, CudaSet* a, unsigned int segment); size_t getTotalSystemMemory(); void process_error(int severity, string err); CudaSet::CudaSet(queue<string> &nameRef, queue<string> &typeRef, queue<int> &sizeRef, queue<int> &colsRef, size_t Recs, queue<string> &references, queue<string> &references_names) : mColumnCount(0), mRecCount(0) { initialize(nameRef, typeRef, sizeRef, colsRef, Recs, references, references_names); keep = false; source = 1; text_source = 1; grp = nullptr; fil_f = nullptr; fil_s = nullptr; }; CudaSet::CudaSet(queue<string> &nameRef, queue<string> &typeRef, queue<int> &sizeRef, queue<int> &colsRef, size_t Recs, string file_name, unsigned int max) : mColumnCount(0), mRecCount(0) { maxRecs = max; initialize(nameRef, typeRef, sizeRef, colsRef, Recs, file_name); keep = false; source = 1; text_source = 0; grp = nullptr; fil_f = nullptr; fil_s = nullptr; }; CudaSet::CudaSet(const size_t RecordCount, const unsigned int ColumnCount) { initialize(RecordCount, ColumnCount); keep = false; source = 0; text_source = 0; grp = nullptr; fil_f = nullptr; fil_s = nullptr; }; CudaSet::CudaSet(queue<string> op_sel, const queue<string> op_sel_as) { initialize(op_sel, op_sel_as); keep = false; source = 0; text_source = 0; grp = nullptr; fil_f = nullptr; fil_s = nullptr; }; CudaSet::CudaSet(CudaSet* a, CudaSet* b, queue<string> op_sel, queue<string> op_sel_as) { initialize(a,b, op_sel, op_sel_as); keep = false; source = 0; text_source = 0; grp = nullptr; fil_f = nullptr; fil_s = nullptr; }; CudaSet::~CudaSet() { free(); }; void CudaSet::allocColumnOnDevice(string colname, size_t RecordCount) { if (type[colname] != 1 ) { d_columns_int[colname].resize(RecordCount); } else d_columns_float[colname].resize(RecordCount); }; void CudaSet::resize_join(size_t addRecs) { mRecCount = mRecCount + addRecs; for(unsigned int i=0; i < columnNames.size(); i++) { if(type[columnNames[i]] != 1) { h_columns_int[columnNames[i]].resize(mRecCount); } else h_columns_float[columnNames[i]].resize(mRecCount); }; }; void CudaSet::resize(size_t addRecs) { mRecCount = mRecCount + addRecs; for(unsigned int i=0; i < columnNames.size(); i++) { if(type[columnNames[i]] != 1) { h_columns_int[columnNames[i]].resize(mRecCount); } else { h_columns_float[columnNames[i]].resize(mRecCount); } }; }; void CudaSet::deAllocColumnOnDevice(string colname) { if (type[colname] != 1 && !d_columns_int.empty()) { if(d_columns_int[colname].size() > 0) { d_columns_int[colname].resize(0); d_columns_int[colname].shrink_to_fit(); }; } else if (type[colname] == 1 && !d_columns_float.empty()) { if (d_columns_float[colname].size() > 0) { d_columns_float[colname].resize(0); d_columns_float[colname].shrink_to_fit(); }; }; }; void CudaSet::allocOnDevice(size_t RecordCount) { for(unsigned int i=0; i < columnNames.size(); i++) allocColumnOnDevice(columnNames[i], RecordCount); }; void CudaSet::deAllocOnDevice() { for(unsigned int i=0; i < columnNames.size(); i++) deAllocColumnOnDevice(columnNames[i]); for (auto it=d_columns_int.begin(); it != d_columns_int.end(); ++it ) { if(it->second.size() > 0) { it->second.resize(0); it->second.shrink_to_fit(); }; }; for (auto it=d_columns_float.begin(); it != d_columns_float.end(); ++it ) { if(it->second.size() > 0) { it->second.resize(0); it->second.shrink_to_fit(); }; }; if(grp) { cudaFree(grp); grp = nullptr; }; if(filtered) { // free the sources if(varNames.find(source_name) != varNames.end()) { varNames[source_name]->deAllocOnDevice(); }; }; }; void CudaSet::resizeDeviceColumn(size_t RecCount, string colname) { if (type[colname] != 1) { d_columns_int[colname].resize(RecCount); } else d_columns_float[colname].resize(RecCount); }; void CudaSet::resizeDevice(size_t RecCount) { for(unsigned int i=0; i < columnNames.size(); i++) { resizeDeviceColumn(RecCount, columnNames[i]); }; }; bool CudaSet::onDevice(string colname) { if (type[colname] != 1) { if (!d_columns_int.empty() && d_columns_int[colname].size()) return 1; } else if (!d_columns_float.empty() && d_columns_float[colname].size()) return 1; return 0; } CudaSet* CudaSet::copyDeviceStruct() { CudaSet* a = new CudaSet(mRecCount, mColumnCount); a->not_compressed = not_compressed; a->segCount = segCount; a->maxRecs = maxRecs; a->ref_joins = ref_joins; a->ref_sets = ref_sets; a->ref_cols = ref_cols; a->columnNames = columnNames; a->cols = cols; a->type = type; a->char_size = char_size; a->decimal = decimal; for(unsigned int i=0; i < columnNames.size(); i++) { if(a->type[columnNames[i]] == 0) { a->d_columns_int[columnNames[i]] = thrust::device_vector<int_type>(); a->h_columns_int[columnNames[i]] = thrust::host_vector<int_type, uninitialized_host_allocator<int_type> >(); } else if(a->type[columnNames[i]] == 1) { a->d_columns_float[columnNames[i]] = thrust::device_vector<float_type>(); a->h_columns_float[columnNames[i]] = thrust::host_vector<float_type, uninitialized_host_allocator<float_type> >(); } else { a->h_columns_char[columnNames[i]] = nullptr; a->d_columns_char[columnNames[i]] = nullptr; }; }; a->load_file_name = load_file_name; a->mRecCount = 0; return a; } int_type CudaSet::readSsdSegmentsFromFile(unsigned int segNum, string colname, size_t offset, thrust::host_vector<unsigned int>& prm_vh, CudaSet* dest) { string f1 = load_file_name + "." + colname + "." + to_string(segNum); FILE* f = fopen(f1.c_str(), "rb" ); if(!f) { cout << "Error opening " << f1 << " file " << endl; exit(0); }; unsigned int cnt, bits; int_type lower_val; unsigned short int val_s_r[4096/2]; char val_c_r[4096]; unsigned int val_i_r[4096/4]; unsigned long long int val_l_r[4096/8]; unsigned int idx; bool idx_set = 0; fread(&cnt, 4, 1, f); fread(&lower_val, 8, 1, f); fseek(f, cnt - (8+4) + 32, SEEK_CUR); fread(&bits, 4, 1, f); //cout << "lower_val bits " << lower_val << " " << bits << endl; if(type[colname] == 0) { //cout << "lower_val bits " << lower_val << " " << bits << endl; for(unsigned int i = 0; i < prm_vh.size(); i++) { if(!idx_set || prm_vh[i] >= idx + 4096/(bits/8)) { fseek(f, 24 + prm_vh[i]*(bits/8), SEEK_SET); idx = prm_vh[i]; idx_set = 1; if(bits == 8) { fread(&val_c_r[0], 4096, 1, f); dest->h_columns_int[colname][i + offset] = val_c_r[0]; } else if(bits == 16) { fread(&val_s_r, 4096, 1, f); dest->h_columns_int[colname][i + offset] = val_s_r[0]; } if(bits == 32) { fread(&val_i_r, 4096, 1, f); dest->h_columns_int[colname][i + offset] = val_i_r[0]; } if(bits == 84) { fread(&val_l_r, 4096, 1, f); dest->h_columns_int[colname][i + offset] = val_l_r[0]; } } else { if(bits == 8) { dest->h_columns_int[colname][i + offset] = val_c_r[prm_vh[i]-idx]; } else if(bits == 16) { dest->h_columns_int[colname][i + offset] = val_s_r[prm_vh[i]-idx]; } if(bits == 32) { dest->h_columns_int[colname][i + offset] = val_i_r[prm_vh[i]-idx]; } if(bits == 84) { dest->h_columns_int[colname][i + offset] = val_l_r[prm_vh[i]-idx]; } }; }; } else if(type[colname] == 1) { for(unsigned int i = 0; i < prm_vh.size(); i++) { if(!idx_set || prm_vh[i] >= idx + 4096/(bits/8)) { fseek(f, 24 + prm_vh[i]*(bits/8), SEEK_SET); idx = prm_vh[i]; idx_set = 1; fread(val_c_r, 4096, 1, f); memcpy(&dest->h_columns_float[colname][i + offset], &val_c_r[0], bits/8); } else { memcpy(&dest->h_columns_float[colname][i + offset], &val_c_r[(prm_vh[i]-idx)*(bits/8)], bits/8); }; }; } else { //no strings in fact tables }; fclose(f); return lower_val; } int_type CudaSet::readSsdSegmentsFromFileR(unsigned int segNum, string colname, thrust::host_vector<unsigned int>& prm_vh, thrust::host_vector<unsigned int>& dest) { string f1 = load_file_name + "." + colname + "." + to_string(segNum); FILE* f = fopen(f1.c_str(), "rb" ); if(!f) { cout << "Error opening " << f1 << " file " << endl; exit(0); }; unsigned int cnt, bits; int_type lower_val; fread(&cnt, 4, 1, f); fread(&lower_val, 8, 1, f); fseek(f, cnt - (8+4) + 32, SEEK_CUR); fread(&bits, 4, 1, f); unsigned short int val_s_r[4096/2]; char val_c_r[4096]; unsigned int val_i_r[4096/4]; unsigned long long int val_l_r[4096/8]; unsigned int idx; bool idx_set = 0; for(unsigned int i = 0; i < prm_vh.size(); i++) { if(!idx_set || prm_vh[i] >= idx + 4096/(bits/8)) { fseek(f, 24 + prm_vh[i]*(bits/8), SEEK_SET); idx = prm_vh[i]; idx_set = 1; if(bits == 8) { fread(val_c_r, 4096, 1, f); dest[i] = val_c_r[0]; } else if(bits == 16) { fread(val_s_r, 4096, 1, f); dest[i] = val_s_r[0]; } if(bits == 32) { fread(val_i_r, 4096, 1, f); dest[i] = val_i_r[0]; } if(bits == 84) { fread(val_l_r, 4096, 1, f); dest[i] = val_l_r[0]; } } else { if(bits == 8) { dest[i] = val_c_r[prm_vh[i]-idx]; } else if(bits == 16) { dest[i] = val_s_r[prm_vh[i]-idx]; } if(bits == 32) { dest[i] = val_i_r[prm_vh[i]-idx]; } if(bits == 84) { dest[i] = val_l_r[prm_vh[i]-idx]; } }; }; fclose(f); return lower_val; } std::clock_t tot_disk; void CudaSet::readSegmentsFromFile(unsigned int segNum, string colname, size_t offset) { string f1 = load_file_name + "." + colname + "." + to_string(segNum); if(type[colname] == 2) f1 = f1 + ".idx"; std::clock_t start1 = std::clock(); if(interactive) { //check if data are in buffers if(buffers.find(f1) == buffers.end()) { // add data to buffers FILE* f = fopen(f1.c_str(), "rb" ); if(!f) { process_error(3, "Error opening " + string(f1) +" file " ); }; fseek(f, 0, SEEK_END); long fileSize = ftell(f); while(total_buffer_size + fileSize > getTotalSystemMemory() && !buffer_names.empty()) { //free some buffers //delete [] buffers[buffer_names.front()]; cudaFreeHost(buffers[buffer_names.front()]); total_buffer_size = total_buffer_size - buffer_sizes[buffer_names.front()]; buffer_sizes.erase(buffer_names.front()); buffers.erase(buffer_names.front()); buffer_names.pop(); }; fseek(f, 0, SEEK_SET); char* buff; cudaHostAlloc((void**) &buff, fileSize,cudaHostAllocDefault); fread(buff, fileSize, 1, f); fclose(f); buffers[f1] = buff; buffer_sizes[f1] = fileSize; buffer_names.push(f1); total_buffer_size = total_buffer_size + fileSize; buffer_names.push(f1); cout << "added buffer " << f1 << " " << fileSize << endl; }; // get data from buffers if(type[colname] != 1) { unsigned int cnt = ((unsigned int*)buffers[f1])[0]; if(cnt > h_columns_int[colname].size()/8 + 10) h_columns_int[colname].resize(cnt/8 + 10); } else { unsigned int cnt = ((unsigned int*)buffers[f1])[0]; if(cnt > h_columns_float[colname].size()/8 + 10) h_columns_float[colname].resize(cnt/8 + 10); } } else { FILE* f = fopen(f1.c_str(), "rb" ); if(!f) { cout << "Error opening " << f1 << " file " << endl; exit(0); }; if(type[colname] != 1) { if(1 > h_columns_int[colname].size()) h_columns_int[colname].resize(1); fread(h_columns_int[colname].data(), 4, 1, f); unsigned int cnt = ((unsigned int*)(h_columns_int[colname].data()))[0]; if(cnt/8+10 > h_columns_int[colname].size()) h_columns_int[colname].resize(cnt + 10); size_t rr = fread((unsigned int*)(h_columns_int[colname].data()) + 1, 1, cnt+52, f); if(rr != cnt+52) { char buf[1024]; sprintf(buf, "Couldn't read %d bytes from %s ,read only", cnt+52, f1.c_str()); process_error(3, string(buf)); }; } else { if(1 > h_columns_float[colname].size()) h_columns_float[colname].resize(1); fread(h_columns_float[colname].data(), 4, 1, f); unsigned int cnt = ((unsigned int*)(h_columns_float[colname].data()))[0]; if(cnt/8+10 > h_columns_float[colname].size()) h_columns_float[colname].resize(cnt + 10); size_t rr = fread((unsigned int*)(h_columns_float[colname].data()) + 1, 1, cnt+52, f); if(rr != cnt+52) { char buf[1024]; sprintf(buf, "Couldn't read %d bytes from %s ,read only", cnt+52, f1.c_str()); process_error(3, string(buf)); }; } fclose(f); }; tot_disk = tot_disk + (std::clock() - start1); }; void CudaSet::CopyColumnToGpu(string colname, unsigned int segment, size_t offset) { if(not_compressed) { // calculate how many records we need to copy if(segment < segCount-1) { mRecCount = maxRecs; } else { mRecCount = hostRecCount - maxRecs*(segCount-1); }; if(type[colname] != 1) { if(!alloced_switch) thrust::copy(h_columns_int[colname].begin() + maxRecs*segment, h_columns_int[colname].begin() + maxRecs*segment + mRecCount, d_columns_int[colname].begin() + offset); else { thrust::device_ptr<int_type> d_col((int_type*)alloced_tmp); thrust::copy(h_columns_int[colname].begin() + maxRecs*segment, h_columns_int[colname].begin() + maxRecs*segment + mRecCount, d_col); }; } else { if(!alloced_switch) { thrust::copy(h_columns_float[colname].begin() + maxRecs*segment, h_columns_float[colname].begin() + maxRecs*segment + mRecCount, d_columns_float[colname].begin() + offset); } else { thrust::device_ptr<float_type> d_col((float_type*)alloced_tmp); thrust::copy(h_columns_float[colname].begin() + maxRecs*segment, h_columns_float[colname].begin() + maxRecs*segment + mRecCount, d_col); }; } } else { readSegmentsFromFile(segment,colname, offset); if(!d_v) CUDA_SAFE_CALL(cudaMalloc((void **) &d_v, 12)); if(!s_v) CUDA_SAFE_CALL(cudaMalloc((void **) &s_v, 8)); string f1; if(type[colname] == 2) { f1 = load_file_name + "." + colname + "." + to_string(segment) + ".idx"; } else { f1 = load_file_name + "." + colname + "." + to_string(segment); }; if(type[colname] != 1) { if(!alloced_switch) { if(buffers.find(f1) == buffers.end()) { mRecCount = pfor_decompress(thrust::raw_pointer_cast(d_columns_int[colname].data() + offset), h_columns_int[colname].data(), d_v, s_v); } else { mRecCount = pfor_decompress(thrust::raw_pointer_cast(d_columns_int[colname].data() + offset), buffers[f1], d_v, s_v); }; } else { if(buffers.find(f1) == buffers.end()) { mRecCount = pfor_decompress(alloced_tmp, h_columns_int[colname].data(), d_v, s_v); } else { mRecCount = pfor_decompress(alloced_tmp, buffers[f1], d_v, s_v); }; }; } else { if(decimal[colname]) { if(!alloced_switch) { if(buffers.find(f1) == buffers.end()) { mRecCount = pfor_decompress( thrust::raw_pointer_cast(d_columns_float[colname].data() + offset) , h_columns_float[colname].data(), d_v, s_v); } else { mRecCount = pfor_decompress( thrust::raw_pointer_cast(d_columns_float[colname].data() + offset) , buffers[f1], d_v, s_v); }; thrust::device_ptr<long long int> d_col_int((long long int*)thrust::raw_pointer_cast(d_columns_float[colname].data() + offset)); thrust::transform(d_col_int,d_col_int+mRecCount,d_columns_float[colname].begin(), long_to_float()); } else { if(buffers.find(f1) == buffers.end()) { mRecCount = pfor_decompress(alloced_tmp, h_columns_float[colname].data(), d_v, s_v); } else { mRecCount = pfor_decompress(alloced_tmp, buffers[f1], d_v, s_v); }; thrust::device_ptr<long long int> d_col_int((long long int*)alloced_tmp); thrust::device_ptr<float_type> d_col_float((float_type*)alloced_tmp); thrust::transform(d_col_int,d_col_int+mRecCount, d_col_float, long_to_float()); //for(int i = 0; i < mRecCount;i++) //cout << "DECOMP " << (float_type)(d_col_int[i]) << " " << d_col_float[i] << endl; }; } //else // uncompressed float // will have to fix it later so uncompressed data will be written by segments too } }; } void CudaSet::CopyColumnToGpu(string colname) // copy all segments { if(not_compressed) { if(type[colname] != 1) thrust::copy(h_columns_int[colname].begin(), h_columns_int[colname].begin() + mRecCount, d_columns_int[colname].begin()); else thrust::copy(h_columns_float[colname].begin(), h_columns_float[colname].begin() + mRecCount, d_columns_float[colname].begin()); } else { if(!d_v) CUDA_SAFE_CALL(cudaMalloc((void **) &d_v, 12)); if(!s_v) CUDA_SAFE_CALL(cudaMalloc((void **) &s_v, 8)); size_t cnt = 0; string f1; for(unsigned int i = 0; i < segCount; i++) { readSegmentsFromFile(i,colname, cnt); if(type[colname] == 2) { f1 = load_file_name + "." + colname + "." + to_string(i) + ".idx"; } else { f1 = load_file_name + "." + colname + "." + to_string(i); }; if(type[colname] == 0) { if(buffers.find(f1) == buffers.end()) { mRecCount = pfor_decompress(thrust::raw_pointer_cast(d_columns_int[colname].data() + cnt), h_columns_int[colname].data(), d_v, s_v); } else { mRecCount = pfor_decompress(thrust::raw_pointer_cast(d_columns_int[colname].data() + cnt), buffers[f1], d_v, s_v); }; } else if(type[colname] == 1) { if(decimal[colname]) { if(buffers.find(f1) == buffers.end()) { mRecCount = pfor_decompress( thrust::raw_pointer_cast(d_columns_float[colname].data() + cnt) , h_columns_float[colname].data(), d_v, s_v); } else { mRecCount = pfor_decompress( thrust::raw_pointer_cast(d_columns_float[colname].data() + cnt) , buffers[f1], d_v, s_v); }; thrust::device_ptr<long long int> d_col_int((long long int*)thrust::raw_pointer_cast(d_columns_float[colname].data() + cnt)); thrust::transform(d_col_int,d_col_int+mRecCount,d_columns_float[colname].begin() + cnt, long_to_float()); } // else uncompressed float // will have to fix it later so uncompressed data will be written by segments too }; cnt = cnt + mRecCount; //totalRecs = totals + mRecCount; }; mRecCount = cnt; }; } void CudaSet::CopyColumnToHost(string colname, size_t offset, size_t RecCount) { if(type[colname] != 1) { //cout << "copied " << colname << " " << RecCount << endl; thrust::copy(d_columns_int[colname].begin(), d_columns_int[colname].begin() + RecCount, h_columns_int[colname].begin() + offset); //cout << "to " << colname << " " << h_columns_int[colname][0] << " " << h_columns_int[colname][1] << endl; //cout << "to " << colname << " " << d_columns_int[colname][0] << " " << d_columns_int[colname][1] << endl; } else thrust::copy(d_columns_float[colname].begin(), d_columns_float[colname].begin() + RecCount, h_columns_float[colname].begin() + offset); } void CudaSet::CopyColumnToHost(string colname) { CopyColumnToHost(colname, 0, mRecCount); } void CudaSet::CopyToHost(size_t offset, size_t count) { for(unsigned int i = 0; i < columnNames.size(); i++) { CopyColumnToHost(columnNames[i], offset, count); }; } float_type* CudaSet::get_float_type_by_name(string name) { return thrust::raw_pointer_cast(d_columns_float[name].data()); } int_type* CudaSet::get_int_by_name(string name) { return thrust::raw_pointer_cast(d_columns_int[name].data()); } float_type* CudaSet::get_host_float_by_name(string name) { return thrust::raw_pointer_cast(h_columns_float[name].data()); } int_type* CudaSet::get_host_int_by_name(string name) { return thrust::raw_pointer_cast(h_columns_int[name].data()); } void CudaSet::GroupBy(stack<string> columnRef) { if(grp) cudaFree(grp); CUDA_SAFE_CALL(cudaMalloc((void **) &grp, mRecCount * sizeof(bool))); thrust::device_ptr<bool> d_grp(grp); thrust::sequence(d_grp, d_grp+mRecCount, 0, 0); thrust::device_ptr<bool> d_group = thrust::device_malloc<bool>(mRecCount); d_group[mRecCount-1] = 1; for(int i = 0; i < columnRef.size(); columnRef.pop()) { columnGroups.push(columnRef.top()); // save for future references if (type[columnRef.top()] != 1) { // int_type thrust::transform(d_columns_int[columnRef.top()].begin(), d_columns_int[columnRef.top()].begin() + mRecCount - 1, d_columns_int[columnRef.top()].begin()+1, d_group, thrust::not_equal_to<int_type>()); } else { // float_type thrust::transform(d_columns_float[columnRef.top()].begin(), d_columns_float[columnRef.top()].begin() + mRecCount - 1, d_columns_float[columnRef.top()].begin()+1, d_group, f_not_equal_to()); }; thrust::transform(d_group, d_group+mRecCount, d_grp, d_grp, thrust::logical_or<bool>()); }; thrust::device_free(d_group); grp_count = thrust::count(d_grp, d_grp+mRecCount,1); }; void CudaSet::addDeviceColumn(int_type* col, string colname, size_t recCount) { if (std::find(columnNames.begin(), columnNames.end(), colname) == columnNames.end()) { columnNames.push_back(colname); type[colname] = 0; d_columns_int[colname] = thrust::device_vector<int_type>(recCount); h_columns_int[colname] = thrust::host_vector<int_type, uninitialized_host_allocator<int_type> >(recCount); } else { // already exists, my need to resize it if(d_columns_int[colname].size() < recCount) { d_columns_int[colname].resize(recCount); }; if(h_columns_int[colname].size() < recCount) { h_columns_int[colname].resize(recCount); }; }; // copy data to d columns thrust::device_ptr<int_type> d_col((int_type*)col); thrust::copy(d_col, d_col+recCount, d_columns_int[colname].begin()); //cout << "added " << colname << " " << d_columns_int[colname][0] << " " << d_columns_int[colname][1] << " " << recCount << endl; thrust::copy(d_columns_int[colname].begin(), d_columns_int[colname].begin()+recCount, h_columns_int[colname].begin()); //for(int i = 0; i < recCount; i++) { //h_columns_int[colname][i] = d_columns_int[colname][i]; // cout << "set " << " " << h_columns_int[colname][i] << " to " << d_columns_int[colname][i] << endl; //}; //cout << "added host " << colname << " " << h_columns_int[colname][0] << " " << h_columns_int[colname][1] << endl; //thrust::host_vector<int_type> test(recCount); //thrust::copy(d_columns_int[colname].begin(), d_columns_int[colname].begin()+recCount, test.begin()); //cout << "added test " << test[0] << " " << test[1] << endl; }; void CudaSet::addDeviceColumn(float_type* col, string colname, size_t recCount, bool is_decimal) { if (std::find(columnNames.begin(), columnNames.end(), colname) == columnNames.end()) { columnNames.push_back(colname); type[colname] = 1; d_columns_float[colname] = thrust::device_vector<float_type>(recCount); h_columns_float[colname] = thrust::host_vector<float_type, uninitialized_host_allocator<float_type> >(recCount); } else { // already exists, my need to resize it if(d_columns_float[colname].size() < recCount) d_columns_float[colname].resize(recCount); if(h_columns_float[colname].size() < recCount) h_columns_float[colname].resize(recCount); }; decimal[colname] = is_decimal; thrust::device_ptr<float_type> d_col((float_type*)col); thrust::copy(d_col, d_col+recCount, d_columns_float[colname].begin()); }; void CudaSet::compress(string file_name, size_t offset, unsigned int check_type, unsigned int check_val, size_t mCount) { string str(file_name); thrust::device_vector<unsigned int> permutation; void* d; CUDA_SAFE_CALL(cudaMalloc((void **) &d, mCount*float_size)); total_count = total_count + mCount; if (mCount > total_max && op_sort.empty()) { total_max = mCount; }; if(!op_sort.empty()) { //sort the segment //copy the key columns to device queue<string> sf(op_sort); permutation.resize(mRecCount); thrust::sequence(permutation.begin(), permutation.begin() + mRecCount,0,1); unsigned int* raw_ptr = thrust::raw_pointer_cast(permutation.data()); void* temp; CUDA_SAFE_CALL(cudaMalloc((void **) &temp, mRecCount*max_char(this, sf))); string sort_type = "ASC"; while(!sf.empty()) { if(type[sf.front()] != 2) { allocColumnOnDevice(sf.front(), maxRecs); CopyColumnToGpu(sf.front()); }; if (type[sf.front()] == 0) update_permutation(d_columns_int[sf.front()], raw_ptr, mRecCount, sort_type, (int_type*)temp); else if (type[sf.front()] == 1) update_permutation(d_columns_float[sf.front()], raw_ptr, mRecCount, sort_type, (float_type*)temp); else { thrust::host_vector<unsigned int> permutation_h = permutation; update_permutation_char_host(h_columns_char[sf.front()], permutation_h.data(), mRecCount, sort_type, (char*)temp, char_size[sf.front()]); }; if(type[sf.front()] != 2) deAllocColumnOnDevice(sf.front()); sf.pop(); }; cudaFree(temp); }; // here we need to check for partitions and if partition_count > 0 -> create partitions if(mCount < partition_count || partition_count == 0) partition_count = 1; unsigned int partition_recs = mCount/partition_count; if(!op_sort.empty()) { if(total_max < partition_recs) total_max = partition_recs; }; total_segments++; unsigned int old_segments = total_segments; size_t new_offset; for(unsigned int i = 0; i < columnNames.size(); i++) { string colname = columnNames[i]; str = file_name + "." + colname; curr_file = str; str += "." + to_string(total_segments-1); new_offset = 0; if(!op_sort.empty() && type[colname] != 2) { allocColumnOnDevice(colname, maxRecs); CopyColumnToGpu(colname); }; if(type[colname] == 0) { thrust::device_ptr<int_type> d_col((int_type*)d); if(!op_sort.empty()) { thrust::gather(permutation.begin(), permutation.end(), d_columns_int[colname].begin(), d_col); for(unsigned int p = 0; p < partition_count; p++) { str = file_name + "." + colname; curr_file = str; str += "." + to_string(total_segments-1); if (p < partition_count - 1) { pfor_compress( (int_type*)d + new_offset, partition_recs*int_size, str, h_columns_int[colname], 0); } else { pfor_compress( (int_type*)d + new_offset, (mCount - partition_recs*p)*int_size, str, h_columns_int[colname], 0); }; new_offset = new_offset + partition_recs; total_segments++; }; } else { thrust::copy(h_columns_int[colname].begin() + offset, h_columns_int[colname].begin() + offset + mCount, d_col); pfor_compress( d, mCount*int_size, str, h_columns_int[colname], 0); }; } else if(type[colname] == 1) { if(decimal[colname]) { thrust::device_ptr<float_type> d_col((float_type*)d); if(!op_sort.empty()) { thrust::gather(permutation.begin(), permutation.end(), d_columns_float[colname].begin(), d_col); thrust::device_ptr<long long int> d_col_dec((long long int*)d); thrust::transform(d_col,d_col+mCount,d_col_dec, float_to_long()); for(unsigned int p = 0; p < partition_count; p++) { str = file_name + "." + colname; curr_file = str; str += "." + to_string(total_segments-1); if (p < partition_count - 1) pfor_compress( (int_type*)d + new_offset, partition_recs*float_size, str, h_columns_float[colname], 1); else pfor_compress( (int_type*)d + new_offset, (mCount - partition_recs*p)*float_size, str, h_columns_float[colname], 1); new_offset = new_offset + partition_recs; total_segments++; }; } else { thrust::copy(h_columns_float[colname].begin() + offset, h_columns_float[colname].begin() + offset + mCount, d_col); thrust::device_ptr<long long int> d_col_dec((long long int*)d); thrust::transform(d_col,d_col+mCount,d_col_dec, float_to_long()); pfor_compress( d, mCount*float_size, str, h_columns_float[colname], 1); }; } else { // do not compress -- float thrust::device_ptr<float_type> d_col((float_type*)d); if(!op_sort.empty()) { thrust::gather(permutation.begin(), permutation.end(), d_columns_float[colname].begin(), d_col); thrust::copy(d_col, d_col+mRecCount, h_columns_float[colname].begin()); for(unsigned int p = 0; p < partition_count; p++) { str = file_name + "." + colname; curr_file = str; str += "." + to_string(total_segments-1); unsigned int curr_cnt; if (p < partition_count - 1) curr_cnt = partition_recs; else curr_cnt = mCount - partition_recs*p; fstream binary_file(str.c_str(),ios::out|ios::binary|fstream::app); binary_file.write((char *)&curr_cnt, 4); binary_file.write((char *)(h_columns_float[colname].data() + new_offset),curr_cnt*float_size); new_offset = new_offset + partition_recs; unsigned int comp_type = 3; binary_file.write((char *)&comp_type, 4); binary_file.close(); }; } else { fstream binary_file(str.c_str(),ios::out|ios::binary|fstream::app); binary_file.write((char *)&mCount, 4); binary_file.write((char *)(h_columns_float[colname].data() + offset),mCount*float_size); unsigned int comp_type = 3; binary_file.write((char *)&comp_type, 4); binary_file.close(); }; }; } else { //char if(!op_sort.empty()) { unsigned int* h_permutation = new unsigned int[mRecCount]; thrust::copy(permutation.begin(), permutation.end(), h_permutation); char* t = new char[char_size[colname]*mRecCount]; apply_permutation_char_host(h_columns_char[colname], h_permutation, mRecCount, t, char_size[colname]); delete [] h_permutation; thrust::copy(t, t+ char_size[colname]*mRecCount, h_columns_char[colname]); delete [] t; for(unsigned int p = 0; p < partition_count; p++) { str = file_name + "." + colname; curr_file = str; str += "." + to_string(total_segments-1); if (p < partition_count - 1) compress_char(str, colname, partition_recs, new_offset, total_segments-1); else compress_char(str, colname, mCount - partition_recs*p, new_offset, total_segments-1); new_offset = new_offset + partition_recs; total_segments++; }; } else { compress_char(str, colname, mCount, offset, total_segments-1); }; }; if(type[colname] != 2) deAllocColumnOnDevice(colname); if((check_type == 1 && fact_file_loaded) || (check_type == 1 && check_val == 0)) { if(!op_sort.empty()) writeHeader(file_name, colname, total_segments-1); else { writeHeader(file_name, colname, total_segments); }; }; total_segments = old_segments; }; cudaFree(d); if(!op_sort.empty()) { total_segments = (old_segments-1)+partition_count; }; permutation.resize(0); permutation.shrink_to_fit(); } void CudaSet::writeHeader(string file_name, string colname, unsigned int tot_segs) { string str = file_name + "." + colname; string ff = str; str += ".header"; fstream binary_file(str.c_str(),ios::out|ios::binary|ios::trunc); binary_file.write((char *)&total_count, 8); binary_file.write((char *)&tot_segs, 4); binary_file.write((char *)&total_max, 4); binary_file.write((char *)&cnt_counts[ff], 4); binary_file.close(); }; void CudaSet::reWriteHeader(string file_name, string colname, unsigned int tot_segs, size_t newRecs, size_t maxRecs1) { string str = file_name + "." + colname; string ff = str; str += ".header"; fstream binary_file(str.c_str(),ios::out|ios::binary|ios::trunc); binary_file.write((char *)&newRecs, 8); binary_file.write((char *)&tot_segs, 4); binary_file.write((char *)&maxRecs1, 4); binary_file.close(); }; void CudaSet::writeSortHeader(string file_name) { string str(file_name); unsigned int idx; if(!op_sort.empty()) { str += ".sort"; fstream binary_file(str.c_str(),ios::out|ios::binary|ios::trunc); idx = (unsigned int)op_sort.size(); binary_file.write((char *)&idx, 4); queue<string> os(op_sort); while(!os.empty()) { //idx = cols[columnNames[os.front()]]; if(verbose) cout << "sorted on " << idx << endl; idx = os.front().size(); binary_file.write((char *)&idx, 4); binary_file.write(os.front().data(), idx); os.pop(); }; binary_file.close(); } else { str += ".sort"; remove(str.c_str()); }; if(!op_presort.empty()) { str += ".presort"; fstream binary_file(str.c_str(),ios::out|ios::binary|ios::trunc); idx = (unsigned int)op_presort.size(); binary_file.write((char *)&idx, 4); queue<string> os(op_presort); while(!os.empty()) { //idx = cols[columnNames[os.front()]]; idx = os.front().size(); binary_file.write((char *)&idx, 4); binary_file.write(os.front().data(), idx); os.pop(); }; binary_file.close(); } else { str += ".presort"; remove(str.c_str()); }; } using namespace mgpu; void CudaSet::Display(unsigned int limit, bool binary, bool term) { #define MAXCOLS 128 #define MAXFIELDSIZE 1400 //-- This should/will be converted to an array holding pointers of malloced sized structures-- char bigbuf[MAXCOLS * MAXFIELDSIZE]; memset(bigbuf, 0, MAXCOLS * MAXFIELDSIZE); char *fields[MAXCOLS]; const char *dcolumns[MAXCOLS]; size_t mCount; // num records in play bool print_all = 0; string ss; int rows = 0; if(limit != 0 && limit < mRecCount) mCount = limit; else { mCount = mRecCount; print_all = 1; }; cout << "mRecCount=" << mRecCount << " mcount = " << mCount << " term " << term << " limit=" << limit << " print_all=" << print_all << endl; unsigned int cc =0; unordered_map<string, FILE*> file_map; unordered_map<string, unsigned int> len_map; for(unsigned int i = 0; i < columnNames.size(); i++) { fields[cc] = &(bigbuf[cc*MAXFIELDSIZE]); // a hack to avoid malloc overheads - refine later dcolumns[cc++] = columnNames[i].c_str(); if(string_map.find(columnNames[i]) != string_map.end()) { auto s = string_map[columnNames[i]]; auto pos = s.find_first_of("."); auto len = data_dict[s.substr(0, pos)][s.substr(pos+1)].col_length; FILE *f; f = fopen(string_map[columnNames[i]].c_str(), "rb"); file_map[string_map[columnNames[i]]] = f; len_map[string_map[columnNames[i]]] = len; }; }; // The goal here is to loop fast and avoid any double handling of outgoing data - pointers are good. if(not_compressed && prm_d.size() == 0) { for(unsigned int i=0; i < mCount; i++) { // for each record for(unsigned int j=0; j < columnNames.size(); j++) { // for each col if (type[columnNames[j]] != 1) { if(string_map.find(columnNames[j]) == string_map.end()) sprintf(fields[j], "%lld", (h_columns_int[columnNames[j]])[i] ); else { fseek(file_map[string_map[columnNames[j]]], h_columns_int[columnNames[j]][i] * len_map[string_map[columnNames[j]]], SEEK_SET); fread(fields[j], 1, len_map[string_map[columnNames[j]]], file_map[string_map[columnNames[j]]]); fields[j][len_map[string_map[columnNames[j]]]] ='\0'; // zero terminate string }; } else sprintf(fields[j], "%.2f", (h_columns_float[columnNames[j]])[i] ); }; row_cb(mColumnCount, (char **)fields, (char **)dcolumns); rows++; }; } else { queue<string> op_vx; for(unsigned int i = 0; i < columnNames.size(); i++) op_vx.push(columnNames[i]); if(prm_d.size() || source) { allocColumns(this, op_vx); }; unsigned int curr_seg = 0; size_t cnt = 0; size_t curr_count, sum_printed = 0; resize(maxRecs); while(sum_printed < mCount || print_all) { if(prm_d.size() || source) { // if host arrays are empty copyColumns(this, op_vx, curr_seg, cnt); size_t olRecs = mRecCount; mRecCount = olRecs; CopyToHost(0,mRecCount); if(sum_printed + mRecCount <= mCount || print_all) curr_count = mRecCount; else curr_count = mCount - sum_printed; } else curr_count = mCount; sum_printed = sum_printed + mRecCount; for(unsigned int i=0; i < curr_count; i++) { for(unsigned int j=0; j < columnNames.size(); j++) { if (type[columnNames[j]] != 1) { if(string_map.find(columnNames[j]) == string_map.end()) sprintf(fields[j], "%lld", (h_columns_int[columnNames[j]])[i] ); else { fseek(file_map[string_map[columnNames[j]]], h_columns_int[columnNames[j]][i] * len_map[string_map[columnNames[j]]], SEEK_SET); fread(fields[j], 1, len_map[string_map[columnNames[j]]], file_map[string_map[columnNames[j]]]); fields[j][len_map[string_map[columnNames[j]]]] ='\0'; // zero terminate string }; } else sprintf(fields[j], "%.2f", (h_columns_float[columnNames[j]])[i] ); }; row_cb(mColumnCount, (char **)fields, (char**)dcolumns); rows++; }; curr_seg++; if(curr_seg == segCount) print_all = 0; }; }; // end else for(auto it = file_map.begin(); it != file_map.end(); it++) fclose(it->second); } void CudaSet::Store(const string file_name, const char* sep, const unsigned int limit, const bool binary, const bool term) { if (mRecCount == 0 && binary == 1 && !term) { // write tails for(unsigned int j=0; j < columnNames.size(); j++) { writeHeader(file_name, columnNames[j], total_segments); }; return; }; size_t mCount; bool print_all = 0; if(limit != 0 && limit < mRecCount) mCount = limit; else { mCount = mRecCount; print_all = 1; }; //cout << "mCount " << mCount << " " << mRecCount << endl; if(binary == 0) { unordered_map<string, FILE*> file_map; unordered_map<string, unsigned int> len_map; string bf; unsigned int max_len = 0; for(unsigned int j=0; j < columnNames.size(); j++) { if(string_map.find(columnNames[j]) != string_map.end()) { auto s = string_map[columnNames[j]]; auto pos = s.find_first_of("."); auto len = data_dict[s.substr(0, pos)][s.substr(pos+1)].col_length; if(len > max_len) max_len = len; FILE *f; f = fopen(string_map[columnNames[j]].c_str(), "rb"); file_map[string_map[columnNames[j]]] = f; len_map[string_map[columnNames[j]]] = len; }; }; bf.reserve(max_len); FILE *file_pr; if(!term) { file_pr = fopen(file_name.c_str(), "w"); if (!file_pr) cout << "Could not open file " << file_name << endl; } else file_pr = stdout; if(not_compressed && prm_d.size() == 0) { for(unsigned int i=0; i < mCount; i++) { for(unsigned int j=0; j < columnNames.size(); j++) { if (type[columnNames[j]] != 1 ) { if(string_map.find(columnNames[j]) == string_map.end()) { fprintf(file_pr, "%lld", (h_columns_int[columnNames[j]])[i]); } else { //fprintf(file_pr, "%.*s", string_hash[columnNames[j]][h_columns_int[columnNames[j]][i]].size(), string_hash[columnNames[j]][h_columns_int[columnNames[j]][i]].c_str()); fseek(file_map[string_map[columnNames[j]]], h_columns_int[columnNames[j]][i] * len_map[string_map[columnNames[j]]], SEEK_SET); fread(&bf[0], 1, len_map[string_map[columnNames[j]]], file_map[string_map[columnNames[j]]]); fprintf(file_pr, "%.*s", len_map[string_map[columnNames[j]]], bf.c_str()); }; fputs(sep, file_pr); } else { fprintf(file_pr, "%.2f", (h_columns_float[columnNames[j]])[i]); fputs(sep, file_pr); } }; if (i != mCount -1 ) fputs("\n",file_pr); }; if(!term) fclose(file_pr); } else { queue<string> op_vx; string ss; for(unsigned int j=0; j < columnNames.size(); j++) op_vx.push(columnNames[j]); if(prm_d.size() || source) { allocColumns(this, op_vx); }; unsigned int curr_seg = 0; size_t cnt = 0; size_t curr_count, sum_printed = 0; mRecCount = 0; resize(maxRecs); while(sum_printed < mCount || print_all) { if(prm_d.size() || source) { copyColumns(this, op_vx, curr_seg, cnt); if(curr_seg == 0) { if(limit != 0 && limit < mRecCount) { mCount = limit; print_all = 0; } else { mCount = mRecCount; print_all = 1; }; }; // if host arrays are empty size_t olRecs = mRecCount; mRecCount = olRecs; CopyToHost(0,mRecCount); //cout << "start " << sum_printed << " " << mRecCount << " " << mCount << endl; if(sum_printed + mRecCount <= mCount || print_all) { curr_count = mRecCount; } else { curr_count = mCount - sum_printed; }; } else { curr_count = mCount; }; sum_printed = sum_printed + mRecCount; //cout << "sum printed " << sum_printed << " " << curr_count << " " << curr_seg << endl; for(unsigned int i=0; i < curr_count; i++) { for(unsigned int j=0; j < columnNames.size(); j++) { if (type[columnNames[j]] != 1) { if(string_map.find(columnNames[j]) == string_map.end()) { fprintf(file_pr, "%lld", (h_columns_int[columnNames[j]])[i]); } else { fseek(file_map[string_map[columnNames[j]]], h_columns_int[columnNames[j]][i] * len_map[string_map[columnNames[j]]], SEEK_SET); fread(&bf[0], 1, len_map[string_map[columnNames[j]]], file_map[string_map[columnNames[j]]]); fprintf(file_pr, "%.*s", len_map[string_map[columnNames[j]]], bf.c_str()); }; fputs(sep, file_pr); } else { fprintf(file_pr, "%.2f", (h_columns_float[columnNames[j]])[i]); fputs(sep, file_pr); }; }; if (i != mCount -1 && (curr_seg != segCount || i < curr_count)) fputs("\n",file_pr); }; curr_seg++; if(curr_seg == segCount) print_all = 0; }; if(!term) { fclose(file_pr); }; }; for(auto it = file_map.begin(); it != file_map.end(); it++) fclose(it->second); } else { //lets update the data dictionary for(unsigned int j=0; j < columnNames.size(); j++) { if(decimal[columnNames[j]] == 1) data_dict[file_name][columnNames[j]].col_type = 3; else data_dict[file_name][columnNames[j]].col_type = type[columnNames[j]]; if(type[columnNames[j]] != 2) data_dict[file_name][columnNames[j]].col_length = 0; else data_dict[file_name][columnNames[j]].col_length = char_size[columnNames[j]]; }; save_dict = 1; if(text_source) { //writing a binary file using a text file as a source // time to perform join checks on REFERENCES dataset segments //for(unsigned int i = 0; i< mColumnCount; i++) { for(unsigned int i=0; i < columnNames.size(); i++) { if(ref_sets.find(columnNames[i]) != ref_sets.end()) { string f1 = file_name + "." + columnNames[i] + ".refs"; fstream f_file; if(total_segments == 0) { f_file.open(f1.c_str(), ios::out|ios::trunc|ios::binary); unsigned int len = ref_sets[columnNames[i]].size(); f_file.write((char *)&len, 4); f_file.write(ref_sets[columnNames[i]].c_str(), len); len = ref_cols[columnNames[i]].size(); f_file.write((char *)&len, 4); f_file.write(ref_cols[columnNames[i]].c_str(), len); } else { f_file.open(f1.c_str(), ios::out|ios::app|ios::binary); }; f1 = ref_sets[columnNames[i]] + "." + ref_cols[columnNames[i]] + ".header"; FILE* ff = fopen(f1.c_str(), "rb"); if(!ff) { process_error(3, "Couldn't open file " + string(f1)); }; unsigned int ref_segCount, ref_maxRecs; fread((char *)&ref_segCount, 4, 1, ff); fread((char *)&ref_segCount, 4, 1, ff); fread((char *)&ref_segCount, 4, 1, ff); fread((char *)&ref_maxRecs, 4, 1, ff); fclose(ff); //cout << "CALC " << i << " " << columnNames[i] << " " << ref_sets[columnNames[i]] << " " << ref_cols[columnNames[i]] << " " << ref_segCount << " " << ref_maxRecs << endl; CudaSet* a = new CudaSet(maxRecs, 1); //a->h_columns_int[ref_cols[columnNames[i]]] = thrust::host_vector<int_type, pinned_allocator<int_type> >(); a->h_columns_int[ref_cols[columnNames[i]]] = thrust::host_vector<int_type>(); a->d_columns_int[ref_cols[columnNames[i]]] = thrust::device_vector<int_type>(ref_maxRecs); a->type[ref_cols[columnNames[i]]] = 0; a->not_compressed = 0; a->load_file_name = ref_sets[columnNames[i]]; a->cols[1] = ref_cols[columnNames[i]]; a->columnNames.push_back(ref_cols[columnNames[i]]); MGPU_MEM(int) aIndicesDevice, bIndicesDevice; size_t res_count; if(!onDevice(columnNames[i])) { allocColumnOnDevice(columnNames[i], maxRecs); }; CopyColumnToGpu(columnNames[i]); thrust::sort(d_columns_int[columnNames[i]].begin(), d_columns_int[columnNames[i]].begin() + mRecCount); f_file.write((char *)&total_segments, 4); f_file.write((char *)&ref_segCount, 4); for(unsigned int z = 0; z < ref_segCount; z++) { a->CopyColumnToGpu(ref_cols[columnNames[i]], z, 0); thrust::sort(a->d_columns_int[ref_cols[columnNames[i]]].begin(), a->d_columns_int[ref_cols[columnNames[i]]].begin() + a->mRecCount); // check if there is a join result //cout << "join " << mRecCount << " " << a->mRecCount << " " << getFreeMem() << endl; //cout << d_columns_int[columnNames[i]][0] << " " << d_columns_int[columnNames[i]][mRecCount-1] << " " << a->d_columns_int[ref_cols[columnNames[i]]][a->mRecCount-1] << " " << a->d_columns_int[ref_cols[columnNames[i]]][0] << endl; if(d_columns_int[columnNames[i]][0] > a->d_columns_int[ref_cols[columnNames[i]]][a->mRecCount-1] || d_columns_int[columnNames[i]][mRecCount-1] < a->d_columns_int[ref_cols[columnNames[i]]][0]) { res_count = 0; } else { res_count = RelationalJoin<MgpuJoinKindInner>(thrust::raw_pointer_cast(d_columns_int[columnNames[i]].data()), mRecCount, thrust::raw_pointer_cast(a->d_columns_int[ref_cols[columnNames[i]]].data()), a->mRecCount, &aIndicesDevice, &bIndicesDevice, mgpu::less<int_type>(), *context); }; cout << "RES " << i << " " << total_segments << ":" << z << " " << res_count << endl; f_file.write((char *)&z, 4); f_file.write((char *)&res_count, 8); }; f_file.close(); a->deAllocColumnOnDevice(ref_cols[columnNames[i]]); a->free(); }; }; compress(file_name, 0, 1, 0, mCount); for(unsigned int i = 0; i< columnNames.size(); i++) if(type[columnNames[i]] == 2) deAllocColumnOnDevice(columnNames[i]); } else { //writing a binary file using a binary file as a source fact_file_loaded = 1; size_t offset = 0; if(!not_compressed) { // records are compressed, for example after filter op. //decompress to host queue<string> op_vx; for(unsigned int i = 0; i< columnNames.size(); i++) { op_vx.push(columnNames[i]); }; allocColumns(this, op_vx); size_t oldCnt = mRecCount; mRecCount = 0; resize(oldCnt); mRecCount = oldCnt; for(unsigned int i = 0; i < segCount; i++) { size_t cnt = 0; copyColumns(this, op_vx, i, cnt); CopyToHost(0, mRecCount); offset = offset + mRecCount; compress(file_name, 0, 0, i - (segCount-1), mRecCount); }; } else { // now we have decompressed records on the host //call setSegments and compress columns in every segment segCount = (mRecCount/process_count + 1); offset = 0; for(unsigned int z = 0; z < segCount; z++) { if(z < segCount-1) { if(mRecCount < process_count) { mCount = mRecCount; } else { mCount = process_count; } } else { mCount = mRecCount - (segCount-1)*process_count; }; compress(file_name, offset, 0, z - (segCount-1), mCount); offset = offset + mCount; }; }; }; }; } void CudaSet::compress_char(const string file_name, const string colname, const size_t mCount, const size_t offset, const unsigned int segment) { unsigned int len = char_size[colname]; unsigned long long int string_hash; string h_name, i_name, file_no_seg = file_name.substr(0, file_name.find_last_of(".")); i_name = file_no_seg + "." + to_string(segment) + ".idx"; h_name = file_no_seg + "." + to_string(segment) + ".hash"; fstream b_file_str, loc_hashes; fstream binary_file_h(h_name.c_str(),ios::out|ios::binary|ios::trunc); binary_file_h.write((char *)&mCount, 4); if(segment == 0) { b_file_str.open(file_no_seg.c_str(),ios::out|ios::binary|ios::trunc); } else { b_file_str.open(file_no_seg.c_str(),ios::out|ios::binary|ios::app); }; if(h_columns_int.find(colname) == h_columns_int.end()) h_columns_int[colname] = thrust::host_vector<int_type >(mCount); if(d_columns_int.find(colname) == d_columns_int.end()) d_columns_int[colname] = thrust::device_vector<int_type >(mCount); for (unsigned int i = 0 ; i < mCount; i++) { string_hash = MurmurHash64A(h_columns_char[colname] + (i+offset)*len, len, hash_seed)/2; binary_file_h.write((char *)&string_hash, 8); if(char_hash[colname].find(string_hash) == char_hash[colname].end()) { auto cnt = char_hash[colname].size(); char_hash[colname][string_hash] = cnt; b_file_str.write((char *)h_columns_char[colname] + (i+offset)*len, len); h_columns_int[colname][i] = cnt; } else { h_columns_int[colname][i] = char_hash[colname][string_hash]; }; }; thrust::device_vector<int_type> d_col(mCount); thrust::copy(h_columns_int[colname].begin(), h_columns_int[colname].begin() + mCount, d_col.begin()); pfor_compress(thrust::raw_pointer_cast(d_col.data()), mCount*int_size, i_name, h_columns_int[colname], 0); binary_file_h.close(); b_file_str.close(); }; void CudaSet::compress_int(const string file_name, const string colname, const size_t mCount) { std::vector<unsigned int> dict_val; unsigned int bits_encoded; set<int_type> dict_s; map<int_type, unsigned int> d_ordered; for (unsigned int i = 0 ; i < mCount; i++) { int_type f = h_columns_int[colname][i]; dict_s.insert(f); }; unsigned int i = 0; for (auto it = dict_s.begin(); it != dict_s.end(); it++) { d_ordered[*it] = i++; }; for (unsigned int i = 0 ; i < mCount; i++) { int_type f = h_columns_int[colname][i]; dict_val.push_back(d_ordered[f]); }; bits_encoded = (unsigned int)ceil(log2(double(d_ordered.size()+1))); //cout << "bits " << bits_encoded << endl; unsigned int sz = (unsigned int)d_ordered.size(); // write to a file fstream binary_file(file_name.c_str(),ios::out|ios::binary|ios::trunc); binary_file.write((char *)&sz, 4); for (auto it = d_ordered.begin(); it != d_ordered.end(); it++) { binary_file.write((char*)(&(it->first)), int_size); }; unsigned int fit_count = 64/bits_encoded; unsigned long long int val = 0; binary_file.write((char *)&fit_count, 4); binary_file.write((char *)&bits_encoded, 4); unsigned int curr_cnt = 1; unsigned int vals_count = (unsigned int)dict_val.size()/fit_count; if(!vals_count || dict_val.size()%fit_count) vals_count++; binary_file.write((char *)&vals_count, 4); unsigned int real_count = (unsigned int)dict_val.size(); binary_file.write((char *)&real_count, 4); for(unsigned int i = 0; i < dict_val.size(); i++) { val = val | dict_val[i]; if(curr_cnt < fit_count) val = val << bits_encoded; if( (curr_cnt == fit_count) || (i == (dict_val.size() - 1)) ) { if (curr_cnt < fit_count) { val = val << ((fit_count-curr_cnt)-1)*bits_encoded; }; curr_cnt = 1; binary_file.write((char *)&val, int_size); val = 0; } else curr_cnt = curr_cnt + 1; }; binary_file.close(); }; bool CudaSet::LoadBigFile(FILE* file_p) { char line[2000]; unsigned int current_column, count = 0; string colname; char *p,*t; const char* sep = separator.c_str(); unsigned int maxx = cols.rbegin()->first; //clear the varchars //for(auto it=columnNames.begin(); it!=columnNames.end();it++) { for(unsigned int i = 0; i < mColumnCount; i++) { if(type[columnNames[i]] == 2) { if(!h_columns_char[columnNames[i]]) h_columns_char[columnNames[i]] = new char[maxRecs*char_size[columnNames[i]]]; memset(h_columns_char[columnNames[i]], 0, maxRecs*char_size[columnNames[i]]); }; }; while (count < process_count && fgets(line, 2000, file_p)) { strtok(line, "\n"); current_column = 0; for(t=mystrtok(&p,line,*sep); t && current_column < maxx; t=mystrtok(&p,0,*sep)) { current_column++; if(cols.find(current_column) == cols.end()) { continue; }; if (type[cols[current_column]] == 0) { if (strchr(t,'-') && t[0] != '-') { // handling possible dates strncpy(t+4,t+5,2); strncpy(t+6,t+8,2); t[8] = '\0'; (h_columns_int[cols[current_column]])[count] = atoll(t); } else if (strchr(t,'/')) { // 4/30/2014 string s(t); size_t pos1 = s.find_first_of("/",0); size_t pos2 = s.find_first_of("/",pos1+1); string month = s.substr(0,pos1); if(month.length() == 1) month = "0" + month; string day = s.substr(pos1+1,pos2-pos1-1); if(day.length() == 1) day = "0" + day; string s2 = s.substr(pos2+1, string::npos) + month + day; (h_columns_int[cols[current_column]])[count] = atoll(s2.c_str()); } else { (h_columns_int[cols[current_column]])[count] = atoll(t); }; } else if (type[cols[current_column]] == 1) { (h_columns_float[cols[current_column]])[count] = atoff(t); } else {//char strcpy(h_columns_char[cols[current_column]] + count*char_size[cols[current_column]], t); } }; count++; }; mRecCount = count; if(count < process_count) { fclose(file_p); return 1; } else return 0; }; void CudaSet::free() { for(unsigned int i = 0; i < columnNames.size(); i++ ) { if(type[columnNames[i]] == 0 ) { h_columns_int[columnNames[i]].resize(0); h_columns_int[columnNames[i]].shrink_to_fit(); } else { h_columns_float[columnNames[i]].resize(0); h_columns_float[columnNames[i]].shrink_to_fit(); }; }; prm_d.resize(0); prm_d.shrink_to_fit(); deAllocOnDevice(); }; bool* CudaSet::logical_and(bool* column1, bool* column2) { thrust::device_ptr<bool> dev_ptr1(column1); thrust::device_ptr<bool> dev_ptr2(column2); thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, dev_ptr1, thrust::logical_and<bool>()); thrust::device_free(dev_ptr2); return column1; } bool* CudaSet::logical_or(bool* column1, bool* column2) { thrust::device_ptr<bool> dev_ptr1(column1); thrust::device_ptr<bool> dev_ptr2(column2); thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, dev_ptr1, thrust::logical_or<bool>()); thrust::device_free(dev_ptr2); return column1; } bool* CudaSet::compare(int_type s, int_type d, int_type op_type) { bool res; if (op_type == 2) // > if(d>s) res = 1; else res = 0; else if (op_type == 1) // < if(d<s) res = 1; else res = 0; else if (op_type == 6) // >= if(d>=s) res = 1; else res = 0; else if (op_type == 5) // <= if(d<=s) res = 1; else res = 0; else if (op_type == 4)// = if(d==s) res = 1; else res = 0; else // != if(d!=s) res = 1; else res = 0; thrust::device_ptr<bool> p = thrust::device_malloc<bool>(mRecCount); thrust::sequence(p, p+mRecCount,res,(bool)0); return thrust::raw_pointer_cast(p); }; bool* CudaSet::compare(float_type s, float_type d, int_type op_type) { bool res; if (op_type == 2) // > if ((d-s) > EPSILON) res = 1; else res = 0; else if (op_type == 1) // < if ((s-d) > EPSILON) res = 1; else res = 0; else if (op_type == 6) // >= if (((d-s) > EPSILON) || (((d-s) < EPSILON) && ((d-s) > -EPSILON))) res = 1; else res = 0; else if (op_type == 5) // <= if (((s-d) > EPSILON) || (((d-s) < EPSILON) && ((d-s) > -EPSILON))) res = 1; else res = 0; else if (op_type == 4)// = if (((d-s) < EPSILON) && ((d-s) > -EPSILON)) res = 1; else res = 0; else // != if (!(((d-s) < EPSILON) && ((d-s) > -EPSILON))) res = 1; else res = 0; thrust::device_ptr<bool> p = thrust::device_malloc<bool>(mRecCount); thrust::sequence(p, p+mRecCount,res,(bool)0); return thrust::raw_pointer_cast(p); } bool* CudaSet::compare(int_type* column1, int_type d, int_type op_type) { thrust::device_ptr<bool> temp = thrust::device_malloc<bool>(mRecCount); thrust::device_ptr<int_type> dev_ptr(column1); if (op_type == 2) // > thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), temp, thrust::greater<int_type>()); else if (op_type == 1) // < thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), temp, thrust::less<int_type>()); else if (op_type == 6) // >= thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), temp, thrust::greater_equal<int_type>()); else if (op_type == 5) // <= thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), temp, thrust::less_equal<int_type>()); else if (op_type == 4)// = thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), temp, thrust::equal_to<int_type>()); else // != thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), temp, thrust::not_equal_to<int_type>()); return thrust::raw_pointer_cast(temp); } bool* CudaSet::compare(float_type* column1, float_type d, int_type op_type) { thrust::device_ptr<bool> res = thrust::device_malloc<bool>(mRecCount); thrust::device_ptr<float_type> dev_ptr(column1); if (op_type == 2) // > thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), res, f_greater()); else if (op_type == 1) // < thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), res, f_less()); else if (op_type == 6) // >= thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), res, f_greater_equal_to()); else if (op_type == 5) // <= thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), res, f_less_equal()); else if (op_type == 4)// = thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), res, f_equal_to()); else // != thrust::transform(dev_ptr, dev_ptr+mRecCount, thrust::make_constant_iterator(d), res, f_not_equal_to()); return thrust::raw_pointer_cast(res); } bool* CudaSet::compare(int_type* column1, int_type* column2, int_type op_type) { thrust::device_ptr<int_type> dev_ptr1(column1); thrust::device_ptr<int_type> dev_ptr2(column2); thrust::device_ptr<bool> temp = thrust::device_malloc<bool>(mRecCount); if (op_type == 2) // > thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::greater<int_type>()); else if (op_type == 1) // < thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::less<int_type>()); else if (op_type == 6) // >= thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::greater_equal<int_type>()); else if (op_type == 5) // <= thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::less_equal<int_type>()); else if (op_type == 4)// = thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::equal_to<int_type>()); else // != thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::not_equal_to<int_type>()); return thrust::raw_pointer_cast(temp); } bool* CudaSet::compare(float_type* column1, float_type* column2, int_type op_type) { thrust::device_ptr<float_type> dev_ptr1(column1); thrust::device_ptr<float_type> dev_ptr2(column2); thrust::device_ptr<bool> temp = thrust::device_malloc<bool>(mRecCount); if (op_type == 2) // > thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_greater()); else if (op_type == 1) // < thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_less()); else if (op_type == 6) // >= thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_greater_equal_to()); else if (op_type == 5) // <= thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_less_equal()); else if (op_type == 4)// = thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_equal_to()); else // != thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_not_equal_to()); return thrust::raw_pointer_cast(temp); } bool* CudaSet::compare(float_type* column1, int_type* column2, int_type op_type) { thrust::device_ptr<float_type> dev_ptr1(column1); thrust::device_ptr<int_type> dev_ptr(column2); thrust::device_ptr<float_type> dev_ptr2 = thrust::device_malloc<float_type>(mRecCount); thrust::device_ptr<bool> temp = thrust::device_malloc<bool>(mRecCount); thrust::transform(dev_ptr, dev_ptr + mRecCount, dev_ptr2, long_to_float_type()); if (op_type == 2) // > thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_greater()); else if (op_type == 1) // < thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_less()); else if (op_type == 6) // >= thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_greater_equal_to()); else if (op_type == 5) // <= thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_less_equal()); else if (op_type == 4)// = thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_equal_to()); else // != thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, f_not_equal_to()); thrust::device_free(dev_ptr2); return thrust::raw_pointer_cast(temp); } float_type* CudaSet::op(int_type* column1, float_type* column2, string op_type, int reverse) { thrust::device_ptr<float_type> temp = thrust::device_malloc<float_type>(mRecCount); thrust::device_ptr<int_type> dev_ptr(column1); thrust::transform(dev_ptr, dev_ptr + mRecCount, temp, long_to_float_type()); // in-place transformation thrust::device_ptr<float_type> dev_ptr1(column2); if(reverse == 0) { if (op_type.compare("MUL") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::multiplies<float_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::plus<float_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::minus<float_type>()); else thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::divides<float_type>()); } else { if (op_type.compare("MUL") == 0) thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::multiplies<float_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::plus<float_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::minus<float_type>()); else thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::divides<float_type>()); }; return thrust::raw_pointer_cast(temp); } int_type* CudaSet::op(int_type* column1, int_type* column2, string op_type, int reverse) { thrust::device_ptr<int_type> temp = thrust::device_malloc<int_type>(mRecCount); thrust::device_ptr<int_type> dev_ptr1(column1); thrust::device_ptr<int_type> dev_ptr2(column2); if(reverse == 0) { if (op_type.compare("MUL") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::multiplies<int_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::plus<int_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::minus<int_type>()); else thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::divides<int_type>()); } else { if (op_type.compare("MUL") == 0) thrust::transform(dev_ptr2, dev_ptr2+mRecCount, dev_ptr1, temp, thrust::multiplies<int_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(dev_ptr2, dev_ptr2+mRecCount, dev_ptr1, temp, thrust::plus<int_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(dev_ptr2, dev_ptr2+mRecCount, dev_ptr1, temp, thrust::minus<int_type>()); else thrust::transform(dev_ptr2, dev_ptr2+mRecCount, dev_ptr1, temp, thrust::divides<int_type>()); } return thrust::raw_pointer_cast(temp); } float_type* CudaSet::op(float_type* column1, float_type* column2, string op_type, int reverse) { thrust::device_ptr<float_type> temp = thrust::device_malloc<float_type>(mRecCount); thrust::device_ptr<float_type> dev_ptr1(column1); thrust::device_ptr<float_type> dev_ptr2(column2); if(reverse == 0) { if (op_type.compare("MUL") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::multiplies<float_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::plus<float_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::minus<float_type>()); else thrust::transform(dev_ptr1, dev_ptr1+mRecCount, dev_ptr2, temp, thrust::divides<float_type>()); } else { if (op_type.compare("MUL") == 0) thrust::transform(dev_ptr2, dev_ptr2+mRecCount, dev_ptr1, temp, thrust::multiplies<float_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(dev_ptr2, dev_ptr2+mRecCount, dev_ptr1, temp, thrust::plus<float_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(dev_ptr2, dev_ptr2+mRecCount, dev_ptr1, temp, thrust::minus<float_type>()); else thrust::transform(dev_ptr2, dev_ptr2+mRecCount, dev_ptr1, temp, thrust::divides<float_type>()); }; return thrust::raw_pointer_cast(temp); } int_type* CudaSet::op(int_type* column1, int_type d, string op_type, int reverse) { thrust::device_ptr<int_type> temp = thrust::device_malloc<int_type>(mRecCount); thrust::fill(temp, temp+mRecCount, d); thrust::device_ptr<int_type> dev_ptr1(column1); if(reverse == 0) { if (op_type.compare("MUL") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::multiplies<int_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::plus<int_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::minus<int_type>()); else thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::divides<int_type>()); } else { if (op_type.compare("MUL") == 0) thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::multiplies<int_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::plus<int_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::minus<int_type>()); else thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::divides<int_type>()); }; return thrust::raw_pointer_cast(temp); } float_type* CudaSet::op(int_type* column1, float_type d, string op_type, int reverse) { thrust::device_ptr<float_type> temp = thrust::device_malloc<float_type>(mRecCount); thrust::fill(temp, temp+mRecCount, d); thrust::device_ptr<int_type> dev_ptr(column1); thrust::device_ptr<float_type> dev_ptr1 = thrust::device_malloc<float_type>(mRecCount); thrust::transform(dev_ptr, dev_ptr + mRecCount, dev_ptr1, long_to_float_type()); if(reverse == 0) { if (op_type.compare("MUL") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::multiplies<float_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::plus<float_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::minus<float_type>()); else thrust::transform(dev_ptr1, dev_ptr1+mRecCount, temp, temp, thrust::divides<float_type>()); } else { if (op_type.compare("MUL") == 0) thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::multiplies<float_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::plus<float_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::minus<float_type>()); else thrust::transform(temp, temp+mRecCount, dev_ptr1, temp, thrust::divides<float_type>()); }; thrust::device_free(dev_ptr1); return thrust::raw_pointer_cast(temp); } float_type* CudaSet::op(float_type* column1, float_type d, string op_type,int reverse) { thrust::device_ptr<float_type> temp = thrust::device_malloc<float_type>(mRecCount); thrust::device_ptr<float_type> dev_ptr1(column1); if(reverse == 0) { if (op_type.compare("MUL") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, thrust::make_constant_iterator(d), temp, thrust::multiplies<float_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, thrust::make_constant_iterator(d), temp, thrust::plus<float_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(dev_ptr1, dev_ptr1+mRecCount, thrust::make_constant_iterator(d), temp, thrust::minus<float_type>()); else thrust::transform(dev_ptr1, dev_ptr1+mRecCount, thrust::make_constant_iterator(d), temp, thrust::divides<float_type>()); } else { if (op_type.compare("MUL") == 0) thrust::transform(thrust::make_constant_iterator(d), thrust::make_constant_iterator(d)+mRecCount, dev_ptr1, temp, thrust::multiplies<float_type>()); else if (op_type.compare("ADD") == 0) thrust::transform(thrust::make_constant_iterator(d), thrust::make_constant_iterator(d)+mRecCount, dev_ptr1, temp, thrust::plus<float_type>()); else if (op_type.compare("MINUS") == 0) thrust::transform(thrust::make_constant_iterator(d), thrust::make_constant_iterator(d)+mRecCount, dev_ptr1, temp, thrust::minus<float_type>()); else thrust::transform(thrust::make_constant_iterator(d), thrust::make_constant_iterator(d)+mRecCount, dev_ptr1, temp, thrust::divides<float_type>()); }; return thrust::raw_pointer_cast(temp); } char CudaSet::loadIndex(const string index_name, const unsigned int segment) { FILE* f; unsigned int bits_encoded, fit_count, vals_count, sz, real_count; void* d_str; string f1 = index_name + "." + to_string(segment); char res; if(interactive) { if(index_buffers.find(f1) == index_buffers.end()) { f = fopen (f1.c_str(), "rb" ); fseek(f, 0, SEEK_END); long fileSize = ftell(f); char* buff; cudaHostAlloc(&buff, fileSize, cudaHostAllocDefault); fseek(f, 0, SEEK_SET); fread(buff, fileSize, 1, f); fclose(f); index_buffers[f1] = buff; }; sz = ((unsigned int*)index_buffers[f1])[0]; idx_dictionary_int[index_name].clear(); for(unsigned int i = 0; i < sz; i++) { idx_dictionary_int[index_name][((int_type*)(index_buffers[f1]+4+8*i))[0]] = i; }; vals_count = ((unsigned int*)(index_buffers[f1]+4 +8*sz))[2]; real_count = ((unsigned int*)(index_buffers[f1]+4 +8*sz))[3]; mRecCount = real_count; res = (index_buffers[f1]+4 +8*sz + (vals_count+2)*int_size)[0]; cudaMalloc((void **) &d_str, (vals_count+2)*int_size); cudaMemcpy( d_str, (void *) &((index_buffers[f1]+4 +8*sz)[0]), (vals_count+2)*int_size, cudaMemcpyHostToDevice); if(idx_vals.count(index_name)) cudaFree(idx_vals[index_name]); idx_vals[index_name] = (unsigned long long int*)d_str; } else { f = fopen (f1.c_str(), "rb" ); fread(&sz, 4, 1, f); int_type* d_array = new int_type[sz]; idx_dictionary_int[index_name].clear(); fread((void*)d_array, sz*int_size, 1, f); for(unsigned int i = 0; i < sz; i++) { idx_dictionary_int[index_name][d_array[i]] = i; //cout << index_name << " " << d_array[i] << " " << i << endl; }; delete [] d_array; fread(&fit_count, 4, 1, f); fread(&bits_encoded, 4, 1, f); fread(&vals_count, 4, 1, f); fread(&real_count, 4, 1, f); mRecCount = real_count; unsigned long long int* int_array = new unsigned long long int[vals_count+2]; fseek ( f , -16 , SEEK_CUR ); fread((void*)int_array, 1, vals_count*8 + 16, f); fread(&res, 1, 1, f); fclose(f); void* d_str; cudaMalloc((void **) &d_str, (vals_count+2)*int_size); cudaMemcpy( d_str, (void *) int_array, (vals_count+2)*int_size, cudaMemcpyHostToDevice); if(idx_vals.count(index_name)) cudaFree(idx_vals[index_name]); idx_vals[index_name] = (unsigned long long int*)d_str; } return res; } void CudaSet::initialize(queue<string> &nameRef, queue<string> &typeRef, queue<int> &sizeRef, queue<int> &colsRef, size_t Recs, string file_name) // compressed data for DIM tables { mColumnCount = (unsigned int)nameRef.size(); FILE* f; string f1; unsigned int cnt; char buffer[4000]; string str; not_compressed = 0; mRecCount = Recs; hostRecCount = Recs; totalRecs = Recs; load_file_name = file_name; f1 = file_name + ".sort"; f = fopen (f1.c_str() , "rb" ); if(f) { unsigned int sz, idx; fread((char *)&sz, 4, 1, f); for(unsigned int j = 0; j < sz; j++) { fread((char *)&idx, 4, 1, f); fread(buffer, idx, 1, f); str.assign(buffer, idx); sorted_fields.push(str); if(verbose) cout << "segment sorted on " << str << endl; }; fclose(f); }; f1 = file_name + ".presort"; f = fopen (f1.c_str() , "rb" ); if(f) { unsigned int sz, idx; fread((char *)&sz, 4, 1, f); for(unsigned int j = 0; j < sz; j++) { fread((char *)&idx, 4, 1, f); fread(buffer, idx, 1, f); str.assign(buffer, idx); presorted_fields.push(str); if(verbose) cout << "presorted on " << str << endl; }; fclose(f); }; tmp_table = 0; filtered = 0; for(unsigned int i=0; i < mColumnCount; i++) { //f1 = file_name + "." + nameRef.front() + ".0"; //f = fopen (f1.c_str() , "rb" ); //fread((char *)&bytes, 4, 1, f); //need to read metadata such as type and length //fclose(f); columnNames.push_back(nameRef.front()); cols[colsRef.front()] = nameRef.front(); if (((typeRef.front()).compare("decimal") == 0) || ((typeRef.front()).compare("int") == 0)) { f1 = file_name + "." + nameRef.front() + ".0"; f = fopen (f1.c_str() , "rb" ); if(!f) { cout << "Couldn't find field " << nameRef.front() << endl; exit(0); }; for(unsigned int j = 0; j < 6; j++) fread((char *)&cnt, 4, 1, f); fclose(f); compTypes[nameRef.front()] = cnt; }; //check the references f1 = file_name + "." + nameRef.front() + ".refs"; f = fopen (f1.c_str() , "rb" ); if(f) { unsigned int len; fread(&len, 4, 1, f); char* array = new char[len+1]; memset(array, 0, len+1); fread((void*)array, len, 1, f); string s(array); ref_sets[nameRef.front()] = s; delete [] array; unsigned int segs, seg_num, curr_seg; size_t res_count; fread(&len, 4, 1, f); char* array1 = new char[len+1]; memset(array1, 0, len+1); fread((void*)array1, len, 1, f); string s1(array1); ref_cols[nameRef.front()] = s1; delete [] array1; unsigned int bytes_read = fread((void*)&curr_seg, 4, 1, f); while(bytes_read == 1) { fread((void*)&segs, 4, 1, f); //ref seg count //cout << "for " << i << " read " << array << " and " << z << " " << segs << endl; for(unsigned int j = 0; j < segs; j++) { fread((void*)&seg_num, 4, 1, f); fread((void*)&res_count, 8, 1, f); //cout << "curr_seg " << curr_seg << " " << seg_num << " " << res_count << endl; if(res_count) ref_joins[columnNames[i]][curr_seg].insert(seg_num); else ref_joins[columnNames[i]][curr_seg].insert(std::numeric_limits<unsigned int>::max()); }; bytes_read = fread((void*)&curr_seg, 4, 1, f); }; fclose(f); }; if ((typeRef.front()).compare("int") == 0) { type[nameRef.front()] = 0; decimal[nameRef.front()] = 0; h_columns_int[nameRef.front()] = thrust::host_vector<int_type, pinned_allocator<int_type> >(); //h_columns_int[nameRef.front()] = thrust::host_vector<int_type >(); d_columns_int[nameRef.front()] = thrust::device_vector<int_type>(); } else if ((typeRef.front()).compare("float") == 0) { type[nameRef.front()] = 1; decimal[nameRef.front()] = 0; h_columns_float[nameRef.front()] = thrust::host_vector<float_type, pinned_allocator<float_type> >(); //h_columns_float[nameRef.front()] = thrust::host_vector<float_type>(); d_columns_float[nameRef.front()] = thrust::device_vector<float_type >(); } else if ((typeRef.front()).compare("decimal") == 0) { type[nameRef.front()] = 1; decimal[nameRef.front()] = 1; h_columns_float[nameRef.front()] = thrust::host_vector<float_type, pinned_allocator<float_type> >(); //h_columns_float[nameRef.front()] = thrust::host_vector<float_type>(); d_columns_float[nameRef.front()] = thrust::device_vector<float_type>(); } else { type[nameRef.front()] = 2; decimal[nameRef.front()] = 0; h_columns_char[nameRef.front()] = nullptr; d_columns_char[nameRef.front()] = nullptr; char_size[nameRef.front()] = sizeRef.front(); string_map[nameRef.front()] = file_name + "." + nameRef.front(); }; nameRef.pop(); typeRef.pop(); sizeRef.pop(); colsRef.pop(); }; }; void CudaSet::initialize(queue<string> &nameRef, queue<string> &typeRef, queue<int> &sizeRef, queue<int> &colsRef, size_t Recs, queue<string> &references, queue<string> &references_names) { mColumnCount = (unsigned int)nameRef.size(); tmp_table = 0; filtered = 0; mRecCount = Recs; hostRecCount = Recs; segCount = 1; for(unsigned int i=0; i < mColumnCount; i++) { columnNames.push_back(nameRef.front()); cols[colsRef.front()] = nameRef.front(); if ((typeRef.front()).compare("int") == 0) { type[nameRef.front()] = 0; decimal[nameRef.front()] = 0; h_columns_int[nameRef.front()] = thrust::host_vector<int_type, pinned_allocator<int_type> >(); //h_columns_int[nameRef.front()] = thrust::host_vector<int_type>(); d_columns_int[nameRef.front()] = thrust::device_vector<int_type>(); } else if ((typeRef.front()).compare("float") == 0) { type[nameRef.front()] = 1; decimal[nameRef.front()] = 0; h_columns_float[nameRef.front()] = thrust::host_vector<float_type, pinned_allocator<float_type> >(); //h_columns_float[nameRef.front()] = thrust::host_vector<float_type>(); d_columns_float[nameRef.front()] = thrust::device_vector<float_type>(); } else if ((typeRef.front()).compare("decimal") == 0) { type[nameRef.front()] = 1; decimal[nameRef.front()] = 1; h_columns_float[nameRef.front()] = thrust::host_vector<float_type, pinned_allocator<float_type> >(); //h_columns_float[nameRef.front()] = thrust::host_vector<float_type>(); d_columns_float[nameRef.front()] = thrust::device_vector<float_type>(); } else { type[nameRef.front()] = 2; decimal[nameRef.front()] = 0; h_columns_char[nameRef.front()] = nullptr; d_columns_char[nameRef.front()] = nullptr; char_size[nameRef.front()] = sizeRef.front(); }; if(!references.front().empty()) { ref_sets[nameRef.front()] = references.front(); ref_cols[nameRef.front()] = references_names.front(); }; nameRef.pop(); typeRef.pop(); sizeRef.pop(); colsRef.pop(); references.pop(); references_names.pop(); }; }; void CudaSet::initialize(const size_t RecordCount, const unsigned int ColumnCount) { mRecCount = RecordCount; hostRecCount = RecordCount; mColumnCount = ColumnCount; filtered = 0; }; void CudaSet::initialize(queue<string> op_sel, const queue<string> op_sel_as) { mRecCount = 0; mColumnCount = (unsigned int)op_sel.size(); segCount = 1; not_compressed = 1; filtered = 0; col_aliases = op_sel_as; unsigned int i = 0; CudaSet *a; while(!op_sel.empty()) { for(auto it = varNames.begin(); it != varNames.end(); it++) { a = it->second; if(std::find(a->columnNames.begin(), a->columnNames.end(), op_sel.front()) != a->columnNames.end()) break; }; type[op_sel.front()] = a->type[op_sel.front()]; cols[i] = op_sel.front(); decimal[op_sel.front()] = a->decimal[op_sel.front()]; columnNames.push_back(op_sel.front()); if (a->type[op_sel.front()] == 0) { d_columns_int[op_sel.front()] = thrust::device_vector<int_type>(); //h_columns_int[op_sel.front()] = thrust::host_vector<int_type, pinned_allocator<int_type> >(); h_columns_int[op_sel.front()] = thrust::host_vector<int_type>(); } else if (a->type[op_sel.front()] == 1) { d_columns_float[op_sel.front()] = thrust::device_vector<float_type>(); //h_columns_float[op_sel.front()] = thrust::host_vector<float_type, pinned_allocator<float_type> >(); h_columns_float[op_sel.front()] = thrust::host_vector<float_type>(); } else { h_columns_char[op_sel.front()] = nullptr; d_columns_char[op_sel.front()] = nullptr; char_size[op_sel.front()] = a->char_size[op_sel.front()]; }; i++; op_sel.pop(); }; } void CudaSet::initialize(CudaSet* a, CudaSet* b, queue<string> op_sel, queue<string> op_sel_as) { mRecCount = 0; mColumnCount = 0; queue<string> q_cnt(op_sel); unsigned int i = 0; set<string> field_names; while(!q_cnt.empty()) { if( std::find(a->columnNames.begin(), a->columnNames.end(), q_cnt.front()) != a->columnNames.end() || std::find(b->columnNames.begin(), b->columnNames.end(), q_cnt.front()) != b->columnNames.end()) { field_names.insert(q_cnt.front()); }; q_cnt.pop(); } mColumnCount = (unsigned int)field_names.size(); maxRecs = b->maxRecs; segCount = 1; filtered = 0; not_compressed = 1; col_aliases = op_sel_as; i = 0; while(!op_sel.empty()) { if(std::find(columnNames.begin(), columnNames.end(), op_sel.front()) == columnNames.end()) { if(std::find(a->columnNames.begin(), a->columnNames.end(), op_sel.front()) != a->columnNames.end()) { cols[i] = op_sel.front(); decimal[op_sel.front()] = a->decimal[op_sel.front()]; columnNames.push_back(op_sel.front()); type[op_sel.front()] = a->type[op_sel.front()]; if (a->type[op_sel.front()] == 0) { d_columns_int[op_sel.front()] = thrust::device_vector<int_type>(); h_columns_int[op_sel.front()] = thrust::host_vector<int_type, pinned_allocator<int_type> >(); //h_columns_int[op_sel.front()] = thrust::host_vector<int_type>(); if(a->string_map.find(op_sel.front()) != a->string_map.end()) { string_map[op_sel.front()] = a->string_map[op_sel.front()]; //cout << "SETTING J " << op_sel.front() << " " << a->string_map[op_sel.front()] << endl; }; } else if (a->type[op_sel.front()] == 1) { d_columns_float[op_sel.front()] = thrust::device_vector<float_type>(); h_columns_float[op_sel.front()] = thrust::host_vector<float_type, pinned_allocator<float_type> >(); //h_columns_float[op_sel.front()] = thrust::host_vector<float_type>(); } else { h_columns_char[op_sel.front()] = nullptr; d_columns_char[op_sel.front()] = nullptr; char_size[op_sel.front()] = a->char_size[op_sel.front()]; string_map[op_sel.front()] = a->string_map[op_sel.front()]; //cout << "SETTING J " << op_sel.front() << " " << a->string_map[op_sel.front()] << endl; }; i++; } else if(std::find(b->columnNames.begin(), b->columnNames.end(), op_sel.front()) != b->columnNames.end()) { columnNames.push_back(op_sel.front()); cols[i] = op_sel.front(); decimal[op_sel.front()] = b->decimal[op_sel.front()]; type[op_sel.front()] = b->type[op_sel.front()]; if (b->type[op_sel.front()] == 0) { d_columns_int[op_sel.front()] = thrust::device_vector<int_type>(); h_columns_int[op_sel.front()] = thrust::host_vector<int_type, pinned_allocator<int_type> >(); //h_columns_int[op_sel.front()] = thrust::host_vector<int_type>(); if(b->string_map.find(op_sel.front()) != b->string_map.end()) { string_map[op_sel.front()] = b->string_map[op_sel.front()]; //cout << "SETTING J " << op_sel.front() << " " << b->string_map[op_sel.front()] << endl; }; } else if (b->type[op_sel.front()] == 1) { d_columns_float[op_sel.front()] = thrust::device_vector<float_type>(); h_columns_float[op_sel.front()] = thrust::host_vector<float_type, pinned_allocator<float_type> >(); //h_columns_float[op_sel.front()] = thrust::host_vector<float_type>(); } else { h_columns_char[op_sel.front()] = nullptr; d_columns_char[op_sel.front()] = nullptr; char_size[op_sel.front()] = b->char_size[op_sel.front()]; string_map[op_sel.front()] = b->string_map[op_sel.front()]; //cout << "SETTING J " << op_sel.front() << " " << b->string_map[op_sel.front()] << endl; }; i++; } } op_sel.pop(); }; }; int_type reverse_op(int_type op_type) { if (op_type == 2) // > return 5; else if (op_type == 1) // < return 6; else if (op_type == 6) // >= return 1; else if (op_type == 5) // <= return 2; else return op_type; } size_t getFreeMem() { size_t available, total; cudaMemGetInfo(&available, &total); return available; } ; void allocColumns(CudaSet* a, queue<string> fields) { if(a->filtered) { CudaSet* t; if(a->filtered) t = varNames[a->source_name]; else t = a; if(int_size*t->maxRecs > alloced_sz) { if(alloced_sz) { cudaFree(alloced_tmp); }; cudaMalloc((void **) &alloced_tmp, int_size*t->maxRecs); alloced_sz = int_size*t->maxRecs; } } else { while(!fields.empty()) { if(var_exists(a, fields.front()) && !a->onDevice(fields.front())) { a->allocColumnOnDevice(fields.front(), a->maxRecs); } fields.pop(); }; }; } void gatherColumns(CudaSet* a, CudaSet* t, string field, unsigned int segment, size_t& count) { if(!a->onDevice(field)) { a->allocColumnOnDevice(field, a->maxRecs); }; if(a->prm_index == 'R') { mygather(field, a, t, count, a->mRecCount); } else { mycopy(field, a, t, count, t->mRecCount); a->mRecCount = t->mRecCount; }; } size_t getSegmentRecCount(CudaSet* a, unsigned int segment) { if (segment == a->segCount-1) { return a->hostRecCount - a->maxRecs*segment; } else return a->maxRecs; } void copyColumns(CudaSet* a, queue<string> fields, unsigned int segment, size_t& count, bool rsz, bool flt) { set<string> uniques; if(a->filtered) { //filter the segment if(flt) { filter_op(a->fil_s, a->fil_f, segment); }; if(rsz && a->mRecCount) { queue<string> fields1(fields); while(!fields1.empty()) { a->resizeDeviceColumn(a->devRecCount + a->mRecCount, fields1.front()); fields1.pop(); }; a->devRecCount = a->devRecCount + a->mRecCount; }; }; while(!fields.empty()) { if (uniques.count(fields.front()) == 0 && var_exists(a, fields.front())) { if(a->filtered) { if(a->mRecCount) { CudaSet *t = varNames[a->source_name]; alloced_switch = 1; t->CopyColumnToGpu(fields.front(), segment); thrust::device_ptr<int_type> d_col((int_type*)alloced_tmp); gatherColumns(a, t, fields.front(), segment, count); alloced_switch = 0; if(t->orig_segs.size() >= segment+1) { a->orig_segs.resize(segment+1); a->orig_segs.resize(segment+1); a->orig_segs[segment] = t->orig_segs[segment]; }; }; } else { if(a->mRecCount) { a->CopyColumnToGpu(fields.front(), segment, count); }; }; uniques.insert(fields.front()); }; fields.pop(); }; } void setPrm(CudaSet* a, CudaSet* b, char val, unsigned int segment) { b->prm_index = val; if (val == 'A') { b->mRecCount = getSegmentRecCount(a,segment); } else if (val == 'N') { b->mRecCount = 0; } } void mygather(string colname, CudaSet* a, CudaSet* t, size_t offset, size_t g_size) { if(t->type[colname] != 1 ) { if(!alloced_switch) { thrust::gather(a->prm_d.begin(), a->prm_d.begin() + g_size, t->d_columns_int[colname].begin(), a->d_columns_int[colname].begin() + offset); } else { thrust::device_ptr<int_type> d_col((int_type*)alloced_tmp); thrust::gather(a->prm_d.begin(), a->prm_d.begin() + g_size, d_col, a->d_columns_int[colname].begin() + offset); }; } else { if(!alloced_switch) { thrust::gather(a->prm_d.begin(), a->prm_d.begin() + g_size, t->d_columns_float[colname].begin(), a->d_columns_float[colname].begin() + offset); } else { thrust::device_ptr<float_type> d_col((float_type*)alloced_tmp); thrust::gather(a->prm_d.begin(), a->prm_d.begin() + g_size, d_col, a->d_columns_float[colname].begin() + offset); }; } }; void mycopy(string colname, CudaSet* a, CudaSet* t, size_t offset, size_t g_size) { if(t->type[colname] != 1) { if(!alloced_switch) { thrust::copy(t->d_columns_int[colname].begin(), t->d_columns_int[colname].begin() + g_size, a->d_columns_int[colname].begin() + offset); } else { thrust::device_ptr<int_type> d_col((int_type*)alloced_tmp); thrust::copy(d_col, d_col + g_size, a->d_columns_int[colname].begin() + offset); }; } else { if(!alloced_switch) { thrust::copy(t->d_columns_float[colname].begin(), t->d_columns_float[colname].begin() + g_size, a->d_columns_float[colname].begin() + offset); } else { thrust::device_ptr<float_type> d_col((float_type*)alloced_tmp); thrust::copy(d_col, d_col + g_size, a->d_columns_float[colname].begin() + offset); }; }; }; size_t load_queue(queue<string> c1, CudaSet* right, string f2, size_t &rcount, unsigned int start_segment, unsigned int end_segment, bool rsz, bool flt) { queue<string> cc; while(!c1.empty()) { if(std::find(right->columnNames.begin(), right->columnNames.end(), c1.front()) != right->columnNames.end()) { if(f2 != c1.front() ) { cc.push(c1.front()); }; }; c1.pop(); }; if(std::find(right->columnNames.begin(), right->columnNames.end(), f2) != right->columnNames.end()) { cc.push(f2); }; if(right->filtered) { allocColumns(right, cc); }; rcount = right->maxRecs; queue<string> ct(cc); while(!ct.empty()) { if(right->filtered && rsz) { right->mRecCount = 0; } else { right->allocColumnOnDevice(ct.front(), rcount); }; ct.pop(); }; size_t cnt_r = 0; right->devRecCount = 0; for(unsigned int i = start_segment; i < end_segment; i++) { if(!right->filtered) copyColumns(right, cc, i, cnt_r, rsz, 0); else copyColumns(right, cc, i, cnt_r, rsz, flt); cnt_r = cnt_r + right->mRecCount; }; right->mRecCount = cnt_r; return cnt_r; } size_t max_char(CudaSet* a) { size_t max_char1 = 8; for(unsigned int i = 0; i < a->columnNames.size(); i++) { if(a->type[a->columnNames[i]] == 2) { if (a->char_size[a->columnNames[i]] > max_char1) max_char1 = a->char_size[a->columnNames[i]]; } else if(a->type[a->columnNames[i]] == 0 && a->string_map.find(a->columnNames[i]) != a->string_map.end()) { auto s = a->string_map[a->columnNames[i]]; auto pos = s.find_first_of("."); auto len = data_dict[s.substr(0, pos)][s.substr(pos+1)].col_length; if (len > max_char1) max_char1 = len; }; }; return max_char1; }; size_t max_char(CudaSet* a, queue<string> field_names) { size_t max_char = 8; while (!field_names.empty()) { if (a->type[field_names.front()] == 2) { if (a->char_size[field_names.front()] > max_char) max_char = a->char_size[field_names.front()]; }; field_names.pop(); }; return max_char; }; void setSegments(CudaSet* a, queue<string> cols) { size_t mem_available = getFreeMem(); size_t tot_sz = 0; while(!cols.empty()) { if(a->type[cols.front()] != 2) tot_sz = tot_sz + int_size; else tot_sz = tot_sz + a->char_size[cols.front()]; cols.pop(); }; if(a->mRecCount*tot_sz > mem_available/3) { //default is 3 a->segCount = (a->mRecCount*tot_sz)/(mem_available/5) + 1; a->maxRecs = (a->mRecCount/a->segCount)+1; }; }; void update_permutation_char_host(char* key, unsigned int* permutation, size_t RecCount, string SortType, char* tmp, unsigned int len) { str_gather_host(permutation, RecCount, (void*)key, (void*)tmp, len); if (SortType.compare("DESC") == 0 ) str_sort_host(tmp, RecCount, permutation, 1, len); else str_sort_host(tmp, RecCount, permutation, 0, len); } void apply_permutation_char(char* key, unsigned int* permutation, size_t RecCount, char* tmp, unsigned int len) { // copy keys to temporary vector cudaMemcpy( (void*)tmp, (void*) key, RecCount*len, cudaMemcpyDeviceToDevice); // permute the keys str_gather((void*)permutation, RecCount, (void*)tmp, (void*)key, len); } void apply_permutation_char_host(char* key, unsigned int* permutation, size_t RecCount, char* res, unsigned int len) { str_gather_host(permutation, RecCount, (void*)key, (void*)res, len); } void filter_op(const char *s, const char *f, unsigned int segment) { CudaSet *a, *b; a = varNames.find(f)->second; a->name = f; std::clock_t start1 = std::clock(); if(a->mRecCount == 0 && !a->filtered) { b = new CudaSet(0,1); } else { if(verbose) cout << "FILTER " << s << " " << f << " " << getFreeMem() << '\xd'; b = varNames[s]; b->name = s; b->string_map = a->string_map; size_t cnt = 0; allocColumns(a, b->fil_value); if (b->prm_d.size() == 0) b->prm_d.resize(a->maxRecs); //cout << endl << "MAP CHECK start " << segment << endl; char map_check = zone_map_check(b->fil_type,b->fil_value,b->fil_nums, b->fil_nums_f, a, segment); //cout << endl << "MAP CHECK segment " << segment << " " << map_check << endl; if(map_check == 'R') { copyColumns(a, b->fil_value, segment, cnt); bool* res = filter(b->fil_type,b->fil_value,b->fil_nums, b->fil_nums_f, a, segment); thrust::device_ptr<bool> bp((bool*)res); b->prm_index = 'R'; b->mRecCount = thrust::count(bp, bp + (unsigned int)a->mRecCount, 1); thrust::copy_if(thrust::make_counting_iterator((unsigned int)0), thrust::make_counting_iterator((unsigned int)a->mRecCount), bp, b->prm_d.begin(), thrust::identity<bool>()); cudaFree(res); } else { setPrm(a,b,map_check,segment); }; if(segment == a->segCount-1) a->deAllocOnDevice(); } if(verbose) cout << endl << "filter res " << b->mRecCount << endl; //std::cout<< "filter time " << ( ( std::clock() - start1 ) / (double)CLOCKS_PER_SEC ) << " " << getFreeMem() << '\n'; } size_t load_right(CudaSet* right, string colname, string f2, queue<string> op_g, queue<string> op_sel, queue<string> op_alt, bool decimal_join, size_t& rcount, unsigned int start_seg, unsigned int end_seg, bool rsz) { size_t cnt_r = 0; //if join is on strings then add integer columns to left and right tables and modify colInd1 and colInd2 // need to allocate all right columns if(right->not_compressed) { queue<string> op_alt1; op_alt1.push(f2); cnt_r = load_queue(op_alt1, right, "", rcount, start_seg, end_seg, rsz, 1); } else { cnt_r = load_queue(op_alt, right, f2, rcount, start_seg, end_seg, rsz, 1); }; /* if (right->type[colname] == 2) { str_join = 1; right->d_columns_int[f2] = thrust::device_vector<int_type>(); for(unsigned int i = start_seg; i < end_seg; i++) { right->add_hashed_strings(f2, i); }; cnt_r = right->d_columns_int[f2].size(); }; */ if(right->not_compressed) { queue<string> op_alt1; while(!op_alt.empty()) { if(f2.compare(op_alt.front())) { if (std::find(right->columnNames.begin(), right->columnNames.end(), op_alt.front()) != right->columnNames.end()) { op_alt1.push(op_alt.front()); }; }; op_alt.pop(); }; if(!op_alt1.empty()) cnt_r = load_queue(op_alt1, right, "", rcount, start_seg, end_seg, 0, 0); }; return cnt_r; }; void insert_records(const char* f, const char* s) { char buf[4096]; size_t size, maxRecs, cnt = 0; string str_s, str_d; if(varNames.find(s) == varNames.end()) { process_error(3, "couldn't find " + string(s) ); }; CudaSet *a; a = varNames.find(s)->second; a->name = s; if(varNames.find(f) == varNames.end()) { process_error(3, "couldn't find " + string(f) ); }; CudaSet *b; b = varNames.find(f)->second; b->name = f; // if both source and destination are on disk cout << "SOURCES " << a->source << ":" << b->source << endl; if(a->source && b->source) { for(unsigned int i = 0; i < a->segCount; i++) { for(unsigned int z = 0; z < a->columnNames.size(); z++) { if(a->type[a->columnNames[z]] != 2) { str_s = a->load_file_name + "." + a->columnNames[z] + "." + to_string(i); str_d = b->load_file_name + "." + a->columnNames[z] + "." + to_string(b->segCount + i); cout << str_s << " " << str_d << endl; FILE* source = fopen(str_s.c_str(), "rb"); FILE* dest = fopen(str_d.c_str(), "wb"); while (size = fread(buf, 1, BUFSIZ, source)) { fwrite(buf, 1, size, dest); } fclose(source); fclose(dest); } else { //merge strings //read b's strings str_s = b->load_file_name + "." + b->columnNames[z]; FILE* dest = fopen(str_s.c_str(), "rb"); auto len = b->char_size[b->columnNames[z]]; map<string, unsigned long long int> map_d; buf[len] = 0; unsigned long long cnt = 0; while (fread(buf, len, 1, dest)) { map_d[buf] = cnt; cnt++; }; fclose(dest); unsigned long long int cct = cnt; str_s = a->load_file_name + "." + a->columnNames[z] + "." + to_string(i) + ".hash"; str_d = b->load_file_name + "." + b->columnNames[z] + "." + to_string(b->segCount + i) + ".hash"; FILE* source = fopen(str_s.c_str(), "rb"); dest = fopen(str_d.c_str(), "wb"); while (size = fread(buf, 1, BUFSIZ, source)) { fwrite(buf, 1, size, dest); } fclose(source); fclose(dest); str_s = a->load_file_name + "." + a->columnNames[z]; source = fopen(str_s.c_str(), "rb"); map<unsigned long long int, string> map_s; buf[len] = 0; cnt = 0; while (fread(buf, len, 1, source)) { map_s[cnt] = buf; cnt++; }; fclose(source); queue<string> op_vx; op_vx.push(a->columnNames[z]); allocColumns(a, op_vx); a->resize(a->maxRecs); a->CopyColumnToGpu(a->columnNames[z], z, 0); a->CopyColumnToHost(a->columnNames[z]); str_d = b->load_file_name + "." + b->columnNames[z]; fstream f_file; f_file.open(str_d.c_str(), ios::out|ios::app|ios::binary); for(auto j = 0; j < a->mRecCount; j++) { auto ss = map_s[a->h_columns_int[a->columnNames[z]][j]]; if(map_d.find(ss) == map_d.end()) { //add f_file.write((char *)ss.c_str(), len); a->h_columns_int[a->columnNames[z]][j] = cct; cct++; } else { a->h_columns_int[a->columnNames[z]][j] = map_d[ss]; }; }; f_file.close(); thrust::device_vector<int_type> d_col(a->mRecCount); thrust::copy(a->h_columns_int[a->columnNames[z]].begin(), a->h_columns_int[a->columnNames[z]].begin() + a->mRecCount, d_col.begin()); auto i_name = b->load_file_name + "." + b->columnNames[z] + "." + to_string(b->segCount + i) + ".idx"; pfor_compress(thrust::raw_pointer_cast(d_col.data()), a->mRecCount*int_size, i_name, a->h_columns_int[a->columnNames[z]], 0); }; }; }; if(a->maxRecs > b->maxRecs) maxRecs = a->maxRecs; else maxRecs = b->maxRecs; for(unsigned int i = 0; i < b->columnNames.size(); i++) { b->reWriteHeader(b->load_file_name, b->columnNames[i], a->segCount + b->segCount, a->totalRecs + b->totalRecs, maxRecs); }; } else if(!a->source && !b->source) { //if both source and destination are in memory size_t oldCount = b->mRecCount; b->resize(a->mRecCount); for(unsigned int z = 0; z< b->mColumnCount; z++) { if(b->type[a->columnNames[z]] == 0) { thrust::copy(a->h_columns_int[a->columnNames[z]].begin(), a->h_columns_int[a->columnNames[z]].begin() + a->mRecCount, b->h_columns_int[b->columnNames[z]].begin() + oldCount); } else if(b->type[a->columnNames[z]] == 1) { thrust::copy(a->h_columns_float[a->columnNames[z]].begin(), a->h_columns_float[a->columnNames[z]].begin() + a->mRecCount, b->h_columns_float[b->columnNames[z]].begin() + oldCount); } else { cudaMemcpy(b->h_columns_char[b->columnNames[z]] + b->char_size[b->columnNames[z]]*oldCount, a->h_columns_char[a->columnNames[z]], a->char_size[a->columnNames[z]]*a->mRecCount, cudaMemcpyHostToHost); }; }; } else if(!a->source && b->source) { total_segments = b->segCount; total_count = b->mRecCount; total_max = b->maxRecs;; queue<string> op_vx; for(unsigned int i=0; i < a->columnNames.size(); i++) op_vx.push(a->columnNames[i]); allocColumns(a, op_vx); a->resize(a->maxRecs); for(unsigned int i = 0; i < a->segCount; i++) { if (a->filtered) { copyColumns(a, op_vx, i, cnt); a->CopyToHost(0, a->mRecCount); }; a->compress(b->load_file_name, 0, 1, i - (a->segCount-1), a->mRecCount); }; for(unsigned int i = 0; i < b->columnNames.size(); i++) { b->writeHeader(b->load_file_name, b->columnNames[i], total_segments); }; }; }; void delete_records(const char* f) { CudaSet *a; a = varNames.find(f)->second; a->name = f; size_t totalRemoved = 0; size_t maxRecs = 0; if(!a->keep) { // temporary variable process_error(2, "Delete operator is only applicable to disk based sets\nfor deleting records from derived sets please use filter operator "); } else { // read matching segments, delete, compress and write on a disk replacing the original segments string str, str_old; queue<string> op_vx; size_t cnt; for ( auto it=data_dict[a->load_file_name].begin() ; it != data_dict[a->load_file_name].end(); ++it ) { op_vx.push((*it).first); if (std::find(a->columnNames.begin(), a->columnNames.end(), (*it).first) == a->columnNames.end()) { if ((*it).second.col_type == 0) { a->type[(*it).first] = 0; a->decimal[(*it).first] = 0; //a->h_columns_int[(*it).first] = thrust::host_vector<int_type, pinned_allocator<int_type> >(); a->h_columns_int[(*it).first] = thrust::host_vector<int_type>(); a->d_columns_int[(*it).first] = thrust::device_vector<int_type>(); } else if((*it).second.col_type == 1) { a->type[(*it).first] = 1; a->decimal[(*it).first] = 0; //a->h_columns_float[(*it).first] = thrust::host_vector<float_type, pinned_allocator<float_type> >(); a->h_columns_float[(*it).first] = thrust::host_vector<float_type>(); a->d_columns_float[(*it).first] = thrust::device_vector<float_type>(); } else if ((*it).second.col_type == 3) { a->type[(*it).first] = 1; a->decimal[(*it).first] = 1; //a->h_columns_float[(*it).first] = thrust::host_vector<float_type, pinned_allocator<float_type> >(); a->h_columns_float[(*it).first] = thrust::host_vector<float_type>(); a->d_columns_float[(*it).first] = thrust::device_vector<float_type>(); } else { a->type[(*it).first] = 2; a->decimal[(*it).first] = 0; a->h_columns_char[(*it).first] = nullptr; a->d_columns_char[(*it).first] = nullptr; a->char_size[(*it).first] = (*it).second.col_length; }; a->columnNames.push_back((*it).first); } }; allocColumns(a, op_vx); a->resize(a->maxRecs); a->prm_d.resize(a->maxRecs); size_t cc = a->mRecCount; size_t tmp; void* d; CUDA_SAFE_CALL(cudaMalloc((void **) &d, a->maxRecs*float_size)); unsigned int new_seg_count = 0; char map_check; for(unsigned int i = 0; i < a->segCount; i++) { map_check = zone_map_check(op_type,op_value,op_nums, op_nums_f, a, i); if(verbose) cout << "MAP CHECK segment " << i << " " << map_check << endl; if(map_check != 'N') { cnt = 0; copyColumns(a, op_vx, i, cnt); tmp = a->mRecCount; if(a->mRecCount) { bool* res = filter(op_type,op_value,op_nums, op_nums_f, a, i); thrust::device_ptr<bool> bp((bool*)res); thrust::copy_if(thrust::make_counting_iterator((unsigned int)0), thrust::make_counting_iterator((unsigned int)a->mRecCount), bp, a->prm_d.begin(), not_identity<bool>()); a->mRecCount = thrust::count(bp, bp + (unsigned int)a->mRecCount, 0); cudaFree(res); // cout << "Remained recs count " << a->mRecCount << endl; if(a->mRecCount > maxRecs) maxRecs = a->mRecCount; if (a->mRecCount) { totalRemoved = totalRemoved + (tmp - a->mRecCount); if (a->mRecCount == tmp) { //none deleted if(new_seg_count != i) { for (auto it=data_dict[a->load_file_name].begin() ; it != data_dict[a->load_file_name].end(); ++it ) { auto colname = (*it).first; str_old = a->load_file_name + "." + colname + "." + to_string(i); str = a->load_file_name + "." + colname + "." + to_string(new_seg_count); remove(str.c_str()); rename(str_old.c_str(), str.c_str()); }; }; new_seg_count++; } else { //some deleted //cout << "writing segment " << new_seg_count << endl; map<string, col_data> s = data_dict[a->load_file_name]; for ( map<string, col_data>::iterator it=s.begin() ; it != s.end(); ++it ) { string colname = (*it).first; str = a->load_file_name + "." + colname + "." + to_string(new_seg_count); if(a->type[colname] == 0) { thrust::device_ptr<int_type> d_col((int_type*)d); thrust::gather(a->prm_d.begin(), a->prm_d.begin() + a->mRecCount, a->d_columns_int[colname].begin(), d_col); pfor_compress( d, a->mRecCount*int_size, str, a->h_columns_int[colname], 0); } else if(a->type[colname] == 1) { thrust::device_ptr<float_type> d_col((float_type*)d); if(a->decimal[colname]) { thrust::gather(a->prm_d.begin(), a->prm_d.begin() + a->mRecCount, a->d_columns_float[colname].begin(), d_col); thrust::device_ptr<long long int> d_col_dec((long long int*)d); thrust::transform(d_col,d_col+a->mRecCount, d_col_dec, float_to_long()); pfor_compress( d, a->mRecCount*float_size, str, a->h_columns_float[colname], 1); } else { thrust::gather(a->prm_d.begin(), a->prm_d.begin() + a->mRecCount, a->d_columns_float[colname].begin(), d_col); thrust::copy(d_col, d_col + a->mRecCount, a->h_columns_float[colname].begin()); fstream binary_file(str.c_str(),ios::out|ios::binary); binary_file.write((char *)&a->mRecCount, 4); binary_file.write((char *)(a->h_columns_float[colname].data()),a->mRecCount*float_size); unsigned int comp_type = 3; binary_file.write((char *)&comp_type, 4); binary_file.close(); }; } else { thrust::device_ptr<int_type> d_col((int_type*)d); thrust::gather(a->prm_d.begin(), a->prm_d.begin() + a->mRecCount, a->d_columns_int[colname].begin(), d_col); pfor_compress( d, a->mRecCount*int_size, str + ".hash", a->h_columns_int[colname], 0); }; }; new_seg_count++; }; } else { totalRemoved = totalRemoved + tmp; }; } } else { if(new_seg_count != i) { for(unsigned int z = 0; z < a->columnNames.size(); z++) { str_old = a->load_file_name + "." + a->columnNames[z] + "." + to_string(i); str = a->load_file_name + "." + a->columnNames[z] + "." + to_string(new_seg_count); remove(str.c_str()); rename(str_old.c_str(), str.c_str()); }; }; new_seg_count++; maxRecs = a->maxRecs; }; }; if (new_seg_count < a->segCount) { for(unsigned int i = new_seg_count; i < a->segCount; i++) { //cout << "delete segment " << i << endl; for(unsigned int z = 0; z < a->columnNames.size(); z++) { str = a->load_file_name + "." + a->columnNames[z]; str += "." + to_string(i); remove(str.c_str()); }; }; }; for(unsigned int i = new_seg_count; i < a->segCount; i++) { a->reWriteHeader(a->load_file_name, a->columnNames[i], new_seg_count, a->totalRecs-totalRemoved, maxRecs); }; a->mRecCount = cc; a->prm_d.resize(0); a->segCount = new_seg_count; a->deAllocOnDevice(); cudaFree(d); }; }; void save_col_data(map<string, map<string, col_data> >& data_dict, string file_name) { size_t str_len; fstream binary_file(file_name.c_str(),ios::out|ios::binary|ios::trunc); size_t len = data_dict.size(); binary_file.write((char *)&len, 8); for (auto it=data_dict.begin() ; it != data_dict.end(); ++it ) { str_len = (*it).first.size(); binary_file.write((char *)&str_len, 8); binary_file.write((char *)(*it).first.data(), str_len); map<string, col_data> s = (*it).second; size_t len1 = s.size(); binary_file.write((char *)&len1, 8); for (auto sit=s.begin() ; sit != s.end(); ++sit ) { str_len = (*sit).first.size(); binary_file.write((char *)&str_len, 8); binary_file.write((char *)(*sit).first.data(), str_len); binary_file.write((char *)&(*sit).second.col_type, 4); binary_file.write((char *)&(*sit).second.col_length, 4); }; }; binary_file.close(); } void load_col_data(map<string, map<string, col_data> >& data_dict, string file_name) { size_t str_len, recs, len1; string str1, str2; char buffer[4000]; unsigned int col_type, col_length; fstream binary_file; binary_file.open(file_name.c_str(),ios::in|ios::binary); if(binary_file.is_open()) { binary_file.read((char*)&recs, 8); for(unsigned int i = 0; i < recs; i++) { binary_file.read((char*)&str_len, 8); binary_file.read(buffer, str_len); str1.assign(buffer, str_len); binary_file.read((char*)&len1, 8); for(unsigned int j = 0; j < len1; j++) { binary_file.read((char*)&str_len, 8); binary_file.read(buffer, str_len); str2.assign(buffer, str_len); binary_file.read((char*)&col_type, 4); binary_file.read((char*)&col_length, 4); data_dict[str1][str2].col_type = col_type; data_dict[str1][str2].col_length = col_length; //cout << "data DICT " << str1 << " " << str2 << " " << col_type << " " << col_length << endl; }; }; binary_file.close(); } else { cout << "Couldn't open data dictionary" << endl; }; } bool var_exists(CudaSet* a, string name) { if(std::find(a->columnNames.begin(), a->columnNames.end(), name) != a->columnNames.end()) return 1; else return 0; } int file_exist (const char *filename) { std::ifstream infile(filename); return infile.good(); } bool check_bitmap_file_exist(CudaSet* left, CudaSet* right) { queue<string> cols(right->fil_value); bool bitmaps_exist = 1; if(cols.size() == 0) { bitmaps_exist = 0; }; while(cols.size() ) { if (std::find(right->columnNames.begin(), right->columnNames.end(), cols.front()) != right->columnNames.end()) { string fname = left->load_file_name + "." + right->load_file_name + "." + cols.front() + ".0"; if( !file_exist(fname.c_str())) { bitmaps_exist = 0; }; }; cols.pop(); }; return bitmaps_exist; } bool check_bitmaps_exist(CudaSet* left, CudaSet* right) { //check if there are join bitmap indexes queue<string> cols(right->fil_value); bool bitmaps_exist = 1; if(cols.size() == 0) { bitmaps_exist = 1; return 1; }; while(cols.size() ) { if (std::find(right->columnNames.begin(), right->columnNames.end(), cols.front()) != right->columnNames.end()) { string fname = left->load_file_name + "." + right->load_file_name + "." + cols.front() + ".0"; if( !file_exist(fname.c_str())) { bitmaps_exist = 0; }; }; cols.pop(); }; if(bitmaps_exist) { while(!right->fil_nums.empty() ) { left->fil_nums.push(right->fil_nums.front()); right->fil_nums.pop(); }; while(!right->fil_nums_f.empty() ) { left->fil_nums_f.push(right->fil_nums_f.front()); right->fil_nums_f.pop(); }; while(!right->fil_value.empty() ) { if (std::find(right->columnNames.begin(), right->columnNames.end(), right->fil_value.front()) != right->columnNames.end()) { string fname = left->load_file_name + "." + right->load_file_name + "." + right->fil_value.front(); left->fil_value.push(fname); } else left->fil_value.push(right->fil_value.front()); right->fil_value.pop(); }; bool add_and = 1; if(left->fil_type.empty()) add_and = 0; while(!right->fil_type.empty() ) { left->fil_type.push(right->fil_type.front()); right->fil_type.pop(); }; if(add_and) { left->fil_type.push("AND"); }; return 1; } else { return 0; }; } void check_sort(const string str, const char* rtable, const char* rid) { CudaSet* right = varNames.find(rtable)->second; fstream binary_file(str.c_str(),ios::out|ios::binary|ios::app); binary_file.write((char *)&right->sort_check, 1); binary_file.close(); } void update_char_permutation(CudaSet* a, string colname, unsigned int* raw_ptr, string ord, void* temp, bool host) { unordered_map<string, unordered_map<unsigned long long int, string> > string_hash; auto s = a->string_map[colname]; auto pos = s.find_first_of("."); auto len = data_dict[s.substr(0, pos)][s.substr(pos+1)].col_length; a->h_columns_char[colname] = new char[a->mRecCount*len]; memset(a->h_columns_char[colname], 0, a->mRecCount*len); thrust::device_ptr<unsigned int> perm(raw_ptr); thrust::device_ptr<int_type> temp_int((int_type*)temp); thrust::gather(perm, perm+a->mRecCount, a->d_columns_int[colname].begin(), temp_int); thrust::copy(temp_int, temp_int+a->mRecCount, a->h_columns_int[colname].begin()); FILE *f; f = fopen(a->string_map[colname].c_str(), "rb"); for(int z = 0 ; z < a->mRecCount; z++) { fseek(f, a->h_columns_int[colname][z] * len, SEEK_SET); fread(a->h_columns_char[colname] + z*len, 1, len, f); }; fclose(f); if(!host) { void *d; cudaMalloc((void **) &d, a->mRecCount*len); a->d_columns_char[colname] = (char*)d; cudaMemcpy(a->d_columns_char[colname], a->h_columns_char[colname], len*a->mRecCount, cudaMemcpyHostToDevice); if (ord.compare("DESC") == 0 ) str_sort(a->d_columns_char[colname], a->mRecCount, raw_ptr, 1, len); else str_sort(a->d_columns_char[colname], a->mRecCount, raw_ptr, 0, len); cudaFree(d); } else { if (ord.compare("DESC") == 0 ) str_sort_host(a->h_columns_char[colname], a->mRecCount, raw_ptr, 1, len); else str_sort_host(a->h_columns_char[colname], a->mRecCount, raw_ptr, 0, len); }; } #ifdef _WIN64 size_t getTotalSystemMemory() { MEMORYSTATUSEX status; status.dwLength = sizeof(status); GlobalMemoryStatusEx(&status); return status.ullTotalPhys; } #else size_t getTotalSystemMemory() { long pages = sysconf(_SC_PHYS_PAGES); long page_size = sysconf(_SC_PAGE_SIZE); return pages * page_size; } #endif
3eb1e78e3b8c0c8e72f855a77ef4fddbb1f95acd.hip
// !!! This is a file automatically generated by hipify!!! #include <hiprand/hiprand.h> #include <thrust/device_vector.h> #include <thrust/count.h> #include <math.h> #include <stdio.h> #define N (1 << 20) int main(void) { hiprandGenerator_t gen; hiprandCreateGenerator(&gen, HIPRAND_RNG_PSEUDO_DEFAULT); hiprandSetPseudoRandomGeneratorSeed(gen, 42ULL); thrust::device_vector<float> dvec_x(N); thrust::device_vector<float> dvec_y(N); float *ptr_x = thrust::raw_pointer_cast(&dvec_x[0]); float *ptr_y = thrust::raw_pointer_cast(&dvec_y[0]); hiprandGenerateUniform(gen, ptr_x, N); hiprandGenerateUniform(gen, ptr_y, N); hiprandDestroyGenerator(gen); int insideCount = thrust::count_if(thrust::make_zip_iterator(thrust::make_tuple( dvec_x.begin(), dvec_y.begin())), thrust::make_zip_iterator( thrust::make_tuple(dvec_x.end(), dvec_y.end())), []__device__(const thrust::tuple<float, float> &el) { return (pow(thrust::get<0>(el), 2) + pow(thrust::get<1>(el), 2)) < 1.f; }); printf("pi = %f\n", insideCount*4.f/N); return 0; }
3eb1e78e3b8c0c8e72f855a77ef4fddbb1f95acd.cu
#include <curand.h> #include <thrust/device_vector.h> #include <thrust/count.h> #include <math.h> #include <stdio.h> #define N (1 << 20) int main(void) { curandGenerator_t gen; curandCreateGenerator(&gen, CURAND_RNG_PSEUDO_DEFAULT); curandSetPseudoRandomGeneratorSeed(gen, 42ULL); thrust::device_vector<float> dvec_x(N); thrust::device_vector<float> dvec_y(N); float *ptr_x = thrust::raw_pointer_cast(&dvec_x[0]); float *ptr_y = thrust::raw_pointer_cast(&dvec_y[0]); curandGenerateUniform(gen, ptr_x, N); curandGenerateUniform(gen, ptr_y, N); curandDestroyGenerator(gen); int insideCount = thrust::count_if(thrust::make_zip_iterator(thrust::make_tuple( dvec_x.begin(), dvec_y.begin())), thrust::make_zip_iterator( thrust::make_tuple(dvec_x.end(), dvec_y.end())), []__device__(const thrust::tuple<float, float> &el) { return (pow(thrust::get<0>(el), 2) + pow(thrust::get<1>(el), 2)) < 1.f; }); printf("pi = %f\n", insideCount*4.f/N); return 0; }
f8318fd46da5020bba558df9b6cf68ccb2c199e9.hip
// !!! This is a file automatically generated by hipify!!! #include "GFilter.h" #include <cassert> #include <hip/hip_runtime.h> #include <hip/hip_runtime.h> // declare texture memory reference texture<float, hipTextureType2D, hipReadModeElementType> texA, texB; __constant__ float d_eps; // declare constant memory #define BLOCK_SIZE 32 // TODO : change this macro define to kernel parameter to decide the size of shared memory in boxfilter_kernel #define BOXWIDTH 17 // R : row, C : col, N : colNums #define INDX(R, C, N) ((R) * (N) + (C)) /* #define FILTER 0 #define FILTER_WIDTH 5 #define FILTER_RAD (FILTER_WIDTH / 2) #define BLOCKSIZE 32 #define INNER_TILE_WIDTH (BLOCKSIZE - FILTER_RAD * 2) #define INDX(row, col, wid) (((row) * (wid)) + (col)) __global__ void boxfilter_kernel(const float * const inputChannel, float *const outputChannel, int wid, int hei, const float * __restrict__ const filter) { // shared memory data (+1 to avoid bank conflict __shared__ float sh_matrix[BLOCKSIZE+1][BLOCKSIZE]; int tx = threadIdx.x; int ty = threadIdx.y; int bx = blockIdx.x; int by = blockIdx.y; int tileX = bx * INNER_TILE_WIDTH + tx; // cols int tileY = by * INNER_TILE_WIDTH + ty; // rows // if tileX_image < 0, then it must be outside of the image int tileX_image = tileX - FILTER_RAD; int tileY_image = tileY - FILTER_RAD; // fill shared memory if((tileX_image >= 0) && (tileX_image < wid) && (tileY_image >= 0) && (tileY_image < hei)) sh_matrix[ty][tx] = inputChannel[INDX(tileY_image, tileX_image, wid)]; else sh_matrix[ty][tx] = 0; __syncthreads(); // Do convolution (only in the inner tile of block) float res = 0.0f; if(tx < INNER_TILE_WIDTH && ty < INNER_TILE_WIDTH) { for(int fr = 0; fr < FILTER_WIDTH; ++fr) for(int fc = 0; fc < FILTER_WIDTH; ++fc) res += sh_matrix[fr + ty][fc + tx] * filter[INDX(fr, fc, FILTER_WIDTH)]; if(tileX < wid && tileY < hei) outputChannel[INDX(tileY_image, tileX_image, wid)] = res; } } */ // calculate the variance of varI based on texture memory // out : corrIp and convIp, __global__ void variance_kernel(float *out, float *lhs, int wid, int hei) { int idx = threadIdx.x + blockDim.x * blockIdx.x; int idy = threadIdx.y + blockDim.y * blockIdx.y; if(idx >= wid || idy >= hei) return ; float val = 0.f; val = tex2D(texA, idy, idx); val *= val; val = lhs[INDX(idy, idx, wid)] - val; out[INDX(idy, idx, wid)] = val; } __global__ void covariance_kernel(float *out, float *lhs, int wid, int hei) { int idx = threadIdx.x + blockDim.x * blockIdx.x; int idy = threadIdx.y + blockDim.y * blockIdx.y; if(idx >= wid || idy >= hei) return ; float val = 0.0f; val = tex2D(texA, idy, idx); val *= tex2D(texB, idy, idx); out[INDX(idy, idx, wid)] = lhs[INDX(idy, idx, wid)] - val; } // input 3 variables : meanP, meanI and "a", the former two are stored in texture now __global__ void calcuB_kernel(float *out, float *in, int wid, int hei) { int idx = threadIdx.x + blockDim.x * blockIdx.x; int idy = threadIdx.y + blockDim.y * blockIdx.y; if(idx >= wid || idy >= hei) return ; float val; val = in[INDX(idy, idx, wid)]; val *= tex2D(texA, idy, idx); val = tex2D(texB, idy, idx) - val; out[INDX(idy, idx, wid)] = val; } __device__ int clamp(int a, int b, int c) { int temp = a > b ? a : b; return (temp < c ? temp : c); } // boxfilter based on share memory __global__ void boxfilter_kernel(float * const d_in, float * const d_out, int wid, int hei, const float * __restrict__ filter, const int filterWidth) { const unsigned int x0 = threadIdx.x; const unsigned int y0 = threadIdx.y; const int tx = x0 + blockIdx.x * blockDim.x; const int ty = y0 + blockIdx.y * blockDim.y; if(tx >= wid || ty >= hei) return ; const int filterRadius = filterWidth / 2; float value = 0.f; __shared__ float shMat[BLOCK_SIZE + BOXWIDTH - 1][BLOCK_SIZE + BOXWIDTH - 1]; int fx, fy; // case 1 : upper left fx = tx - filterRadius; // col fy = ty - filterRadius; // row fx = clamp(fx, 0, wid); fy = clamp(fy, 0, hei); shMat[x0][y0] = d_in[INDX(fy, fx, wid)]; // case 2 : upper right fx = tx + filterRadius; fy = ty - filterRadius; fx = clamp(fx, 0, wid); fy = clamp(fy, 0, hei); shMat[x0 + filterWidth - 1][y0] = d_in[INDX(fy, fx, wid)]; // case 3 : lower left fx = tx - filterRadius; fy = ty + filterRadius; fx = clamp(fx, 0, wid); fy = clamp(fy, 0, hei); shMat[x0][y0 + filterWidth - 1] = d_in[INDX(fy, fx, wid)]; // case 4 : lower right fx = fx + filterRadius; fy = fy + filterRadius; fx = clamp(fx, 0, wid); fy = clamp(fy, 0, hei); shMat[x0+filterWidth - 1][y0 + filterWidth - 1] = d_in[INDX(fy, fx, wid)]; __syncthreads(); for(int i = 0; i < filterWidth; ++i) for (int j = 0; j < filterWidth; ++j) { value += filter[INDX(j, i, filterWidth)] * shMat[x0+i][y0+j]; } d_out[INDX(ty, tx, wid)] = value; } // calculate the image I based on texture memory __global__ void boxfilterTI_kernel(float *out, int wid, int hei, const size_t pitch, const int fWid, const int fHei) { int idx = threadIdx.x + blockDim.x * blockIdx.x; int idy = threadIdx.y + blockDim.y * blockIdx.y; float outputVal = 0.0f; if(idx < wid && idy < hei) { for(int i = -fWid; i <= fWid; ++i) { for(int j = -fHei; j <= fHei; ++j) outputVal += tex2D(texA, idy + j, idx + i); } outputVal /= ((2 * fWid + 1) * (2 * fHei + 1)); int offset = idy * pitch / sizeof(float) + idx; out[offset] = outputVal; } } __global__ void boxfilterTP_kernel(float *out, int wid, int hei, const size_t pitch, const int fWid, const int fHei) { int idx = threadIdx.x + blockDim.x * blockIdx.x; int idy = threadIdx.y + blockDim.y * blockIdx.y; float outputVal = 0.0f; if(idx < wid && idy < hei) { for(int i = -fWid; i <= fWid; ++i) { for(int j = -fHei; j <= fHei; ++j) outputVal += tex2D(texB, idy + j, idx + i); } outputVal /= ((2 * fWid + 1) * (2 * fHei + 1)); int offset = idy * pitch / sizeof(float) + idx; out[offset] = outputVal; } } __global__ void elemwisemult_kernel(float *out, size_t pitch, const int wid, const int hei) { int idx = threadIdx.x + blockDim.x * blockIdx.x; int idy = threadIdx.y + blockDim.y * blockIdx.y; int offset = idy * pitch / sizeof(float) + idx; float res = 0.f; if(idx < wid && idy < hei) { res = tex2D(texA, idy, idx) * tex2D(texB, idy, idx); } out[offset] = res; } /* __global__ void elemwisemult_kernel(float *out, float *inA, float *inB, size_t pitch, const int wid, const int hei) { extern __shared__ float A[]; extern __shared__ float B[]; int idx = threadIdx.x + blockDim.x * blockIdx.x; int idy = threadIdx.y + blockDim.y * blockIdx.y; //int index = idy * blockDim.x * gridDim.x + idx; int offset = idy * pitch / sizeof(float) + idx; int sharedIdx = threadIdx.y * blockDim.x + threadIdx.x; if(idx < wid && idy < hei) { A[sharedIdx] = inA[offset]; B[sharedIdx] = inB[offset]; //A[threadIdx.x][threadIdx.y] = inA[index]; //B[threadIdx.x][threadIdx.y] = inB[index]; __syncthreads(); out[offset] = A[sharedIdx] * B[sharedIdx]; } } */ __global__ void elemwisemultSame_kernel(float *out, const size_t pitch, const int wid, const int hei) { int idx = threadIdx.x + blockDim.x * blockIdx.x; int idy = threadIdx.y + blockDim.y * blockIdx.y; float outputVal = 0.0f; if(idx < wid && idy < hei) { outputVal = tex2D(texA, idy, idx); outputVal *= outputVal; } int offset = idy * pitch / sizeof(float) + idx; out[offset] = outputVal; } /* // dir means the operation : 0 for add, 1 for subtraction __global__ void elewiseAdd_kernel(float *lhs, float *rhs, int dir, int wid, int hei) { int idx = threadIdx.x + blockDim.x * blockIdx.x; int idy = threadIdx.y + blockDim.y * blockIdx.y; int index = idy * wid + idx; if(idx < wid && idy < hei) { if(dir == 0) // for operation + lhs[index] += rhs[index]; else if(dir == 1) // for operation - lhs[index] -= rhs[index]; else lhs[index] = lhs[index]; } } */ // the img I is binded to texA, so the source operators are in1, in2 only // in1 : meanA, in2 : meanB __global__ void finnalCal_kernel(float * const out, const float * const in1, const float * const in2, int wid, int hei) { int idx = threadIdx.x + blockDim.x * blockIdx.x; int idy = threadIdx.y + blockDim.y * blockIdx.y; if(idx >= wid || idy >= hei) return ; float val = 0.f; val = in1[INDX(idy, idx, wid)] * tex2D(texA, idy, idx); val += in2[INDX(idy, idx, wid)]; out[INDX(idy, idx, wid)] = val; } __global__ void elewiseDiv_kernel(float *lhs, float *rhs, int wid, int hei) { int idx = threadIdx.x + blockDim.x * blockIdx.x; int idy = threadIdx.y + blockDim.y * blockIdx.y; //int index = idy * wid + idx; if(idx < wid && idy < hei) { lhs[INDX(idy, idx, wid)] /= rhs[INDX(idy, idx, wid)] + d_eps; } } // allocate page-locked memory on host hipHostMalloc, use hipHostFree to free them void GFilter::prepareMem(float *dataInI, float *dataInP) { } void GFilter::createfilter() { //const int filterSize = (2 * rad + 1) * (2 * rad + 1); filter = new float [FILTERSIZE]; for(int i = 0; i < FILTERSIZE; ++i) filter[i] = 1.0 / FILTERSIZE; } /* void GFilter::boxfilter(float *d_in, float *d_out, int rad, const float * const __restrict__ filter) { dim3 threadPerBlock(BLOCKSIZE, BLOCKSIZE); dim3 blockPerGrid((width + threadPerBlock.x - 1) / BLOCKSIZE, (height + threadPerBlock.y - 1) / BLOCKSIZE); } */ void GFilter::guidedfilter() { // copy data from host to device // allocate pitch memory on device use hipMallocPitch size_t pitch = 0; hipError_t cudaState = hipSuccess; cudaState = hipMallocPitch((void **)&d_imgI, &pitch, width, height); // pitch' unit is bytes ! assert(cudaState == hipSuccess); cudaState = hipMallocPitch((void **)&d_imgP, &pitch, width, height); assert(cudaState == hipSuccess); // allocate temp data on device use hipMalloc cudaState = hipMalloc((void **)&d_meanI, sizeof(float) * width * height); assert(cudaState == hipSuccess); cudaState = hipMalloc((void **)&d_meanP, sizeof(float) * width * height); assert(cudaState == hipSuccess); cudaState = hipMalloc((void **)&d_tempA, sizeof(float) * width * height); assert(cudaState == hipSuccess); cudaState = hipMalloc((void **)&d_tempB, sizeof(float) * width * height); assert(cudaState == hipSuccess); // copy data from host to device use hipMemcpy2D // the dst pitch and src pitch all are in bytes cudaState = hipMemcpy2D(d_imgI, pitch, h_imgI, sizeof(float) * width, sizeof(float) * width, height, hipMemcpyHostToDevice); assert(cudaState == hipSuccess); cudaState = hipMemcpy2D(d_imgP, pitch, h_imgP, sizeof(float) * width, sizeof(float) * width, height, hipMemcpyHostToDevice); assert(cudaState == hipSuccess); // prepare the texture memory hipChannelFormatDesc channelDesc = hipCreateChannelDesc<float>(); texA.addressMode[0] = texA.addressMode[1] = hipAddressModeBorder; // bind the 2D Pitch memory to 2D texture memory cudaState = hipBindTexture2D(NULL, texA, d_imgI, channelDesc, width, height, pitch); assert(cudaState == hipSuccess); cudaState = hipBindTexture2D(NULL, texB, d_imgP, channelDesc, width, height, pitch); assert(cudaState == hipSuccess); /* // prepare the filter on device constant memory by using hipMemcpyToSymbol createfilter(); cudaState = hipMemcpyToSymbol(d_); */ createfilter(); cudaState = hipMalloc((void **)&d_filter, FILTERSIZE * sizeof(float)); assert(cudaState == hipSuccess); cudaState = hipMemcpy(d_filter, filter, FILTERSIZE * sizeof(float), hipMemcpyHostToDevice); assert(cudaState == hipSuccess); // prepare the kernel launching parameters dim3 threadPerBlock(BLOCK_SIZE, BLOCK_SIZE); dim3 blockPerGrid; blockPerGrid.x = (width + threadPerBlock.x - 1) / threadPerBlock.x; blockPerGrid.y = (height + threadPerBlock.y - 1) / threadPerBlock.y; // launch boxfilter kernel with stream technology hipStream_t st[4]; // create stream use hipStreamCreate for(int i = 0; i < 4; ++i) { cudaState = hipStreamCreate(&st[i]); assert(cudaState == hipSuccess); } hipLaunchKernelGGL(( boxfilterTI_kernel), dim3(blockPerGrid), dim3(threadPerBlock), 0, st[0], d_meanI, width, height, pitch, rad, rad); hipLaunchKernelGGL(( boxfilterTP_kernel), dim3(blockPerGrid), dim3(threadPerBlock), 0, st[1], d_meanP, width, height, pitch, rad, rad); hipLaunchKernelGGL(( elemwisemultSame_kernel), dim3(blockPerGrid), dim3(threadPerBlock), 0, st[2], d_tempA, pitch, width, height); hipLaunchKernelGGL(( elemwisemult_kernel), dim3(blockPerGrid), dim3(threadPerBlock), 0, st[3], d_tempB, pitch, width, height); // synchronize all above streams use cudaDeviceSyncthronize() cudaState = hipDeviceSynchronize(); assert(cudaState == hipSuccess); // calculate the corrI and corrIp hipLaunchKernelGGL(( boxfilter_kernel), dim3(blockPerGrid), dim3(threadPerBlock), 0, 0, d_tempA, d_tempA, width, height, d_filter, FILTERWIDTH); hipLaunchKernelGGL(( boxfilter_kernel), dim3(blockPerGrid), dim3(threadPerBlock), 0, 0, d_tempB, d_tempB, width, height, d_filter, FILTERWIDTH); // change the texA to d_meanI // Unbind the texA from origin d_imgI cudaState = hipUnbindTexture(texA); assert(cudaState == hipSuccess); // rebind the texA to d_meanI // the pitch of d_meanI is width * sizeof(float) cudaState = hipBindTexture2D(NULL, texA, d_meanI, channelDesc, width, height, width * sizeof(float)); assert(cudaState == hipSuccess); // calculation the variance of I: varI hipLaunchKernelGGL(( variance_kernel), dim3(blockPerGrid), dim3(threadPerBlock), 0, 0, d_tempA, d_tempA, width, height); // rebind the texB to d_meanP // unbind the texB from d_imgP; cudaState = hipUnbindTexture(texB); assert(cudaState == hipSuccess); // bind the texB to d_meanp cudaState = hipBindTexture2D(NULL, texB, d_meanP, channelDesc, width, height, sizeof(float) * width); assert(cudaState == hipSuccess); // calculate the covariance of I and P based on global memory hipLaunchKernelGGL(( covariance_kernel), dim3(blockPerGrid), dim3(threadPerBlock), 0, 0, d_tempB, d_tempB, width, height); // calculate the a & b // calculate the "a" and store it in d_tempB // copy eps to device constant memory which is d_eps cudaState = hipMemcpyToSymbol(d_eps, &eps, sizeof(float), NULL, hipMemcpyDefault); assert(cudaState == hipSuccess); // launch the kernel function hipLaunchKernelGGL(( elewiseDiv_kernel), dim3(blockPerGrid), dim3(threadPerBlock), 0, 0, d_tempB, d_tempA, width, height); /* // rebind texB to above "a" cudaState = hipUnbindTexture(texB); assert(cudaState == hipSuccess); // bind the texB to "a" which is in d_tempB cudaState = hipBindTexture2D(NULL, texB, d_tempB, channelDesc, sizeof(float) * width); assert(cudaState == hipSuccess); */ // calculate the "b" and store it in tempA // launch the the kernel function hipLaunchKernelGGL(( calcuB_kernel), dim3(blockPerGrid), dim3(threadPerBlock), 0, 0, d_tempA, d_tempB, width, height); // calculate the boxfilter of "a" & "b" // calculate meanA based on d_tempB hipLaunchKernelGGL(( boxfilter_kernel), dim3(blockPerGrid), dim3(threadPerBlock), 0, 0, d_tempB, d_tempB, width, height, d_filter, FILTERWIDTH); // calculate meaB based on d_tempA hipLaunchKernelGGL(( boxfilter_kernel), dim3(blockPerGrid), dim3(threadPerBlock), 0, 0, d_tempA, d_tempA, width, height, d_filter, FILTERWIDTH); // calculate the finnal output: guided filtering result Res = new float [width * height]; // rebind the texA to d_imgI // unbind the texA from d_meanI cudaState = hipUnbindTexture(texA); assert(cudaState == hipSuccess); // rebind the texA to d_imgI cudaState = hipBindTexture2D(NULL, texA, d_imgI, width, height, pitch); assert(cudaState == hipSuccess); hipLaunchKernelGGL(( finnalCal_kernel), dim3(blockPerGrid), dim3(threadPerBlock), 0, 0, d_meanI, d_tempB, d_tempA, width, height); // Finnal step : copy data from device back to host cudaState = hipMemcpy(Res, d_meanI, sizeof(float) * width * height, hipMemcpyHostToDevice); assert(cudaState == hipSuccess); // Unbind all textures cudaState = hipUnbindTexture(texB); assert(cudaState == hipSuccess); cudaState = hipUnbindTexture(texA); assert(cudaState == hipSuccess); // destory streams use cudaStreamDestory for(int i = 0; i < 4; i++) { cudaState = hipStreamDestroy(st[i]); assert(cudaState == hipSuccess); } if(d_imgI) hipFree(d_imgI); if(d_imgP) hipFree(d_imgP); if(d_tempA) hipFree(d_tempA); if(d_tempB) hipFree(d_tempB); if(d_meanI) hipFree(d_meanI); if(d_meanP) hipFree(d_meanP); if(d_filter) hipFree(d_filter); } GFilter::~GFilter() { /* if(d_imgI) hipFree(d_imgI); if(d_imgP) hipFree(d_imgP); if(d_tempA) hipFree(d_tempA); if(d_tempB) hipFree(d_tempB); if(d_meanI) hipFree(d_meanI); if(d_meanP) hipFree(d_meanP); if(d_filter) hipFree(d_filter); if(filter) delete [] filter; if(Res) delete [] Res; */ }
f8318fd46da5020bba558df9b6cf68ccb2c199e9.cu
#include "GFilter.h" #include <cassert> #include <cuda.h> #include <cuda_runtime.h> // declare texture memory reference texture<float, cudaTextureType2D, cudaReadModeElementType> texA, texB; __constant__ float d_eps; // declare constant memory #define BLOCK_SIZE 32 // TODO : change this macro define to kernel parameter to decide the size of shared memory in boxfilter_kernel #define BOXWIDTH 17 // R : row, C : col, N : colNums #define INDX(R, C, N) ((R) * (N) + (C)) /* #define FILTER 0 #define FILTER_WIDTH 5 #define FILTER_RAD (FILTER_WIDTH / 2) #define BLOCKSIZE 32 #define INNER_TILE_WIDTH (BLOCKSIZE - FILTER_RAD * 2) #define INDX(row, col, wid) (((row) * (wid)) + (col)) __global__ void boxfilter_kernel(const float * const inputChannel, float *const outputChannel, int wid, int hei, const float * __restrict__ const filter) { // shared memory data (+1 to avoid bank conflict __shared__ float sh_matrix[BLOCKSIZE+1][BLOCKSIZE]; int tx = threadIdx.x; int ty = threadIdx.y; int bx = blockIdx.x; int by = blockIdx.y; int tileX = bx * INNER_TILE_WIDTH + tx; // cols int tileY = by * INNER_TILE_WIDTH + ty; // rows // if tileX_image < 0, then it must be outside of the image int tileX_image = tileX - FILTER_RAD; int tileY_image = tileY - FILTER_RAD; // fill shared memory if((tileX_image >= 0) && (tileX_image < wid) && (tileY_image >= 0) && (tileY_image < hei)) sh_matrix[ty][tx] = inputChannel[INDX(tileY_image, tileX_image, wid)]; else sh_matrix[ty][tx] = 0; __syncthreads(); // Do convolution (only in the inner tile of block) float res = 0.0f; if(tx < INNER_TILE_WIDTH && ty < INNER_TILE_WIDTH) { for(int fr = 0; fr < FILTER_WIDTH; ++fr) for(int fc = 0; fc < FILTER_WIDTH; ++fc) res += sh_matrix[fr + ty][fc + tx] * filter[INDX(fr, fc, FILTER_WIDTH)]; if(tileX < wid && tileY < hei) outputChannel[INDX(tileY_image, tileX_image, wid)] = res; } } */ // calculate the variance of varI based on texture memory // out : corrIp and convIp, __global__ void variance_kernel(float *out, float *lhs, int wid, int hei) { int idx = threadIdx.x + blockDim.x * blockIdx.x; int idy = threadIdx.y + blockDim.y * blockIdx.y; if(idx >= wid || idy >= hei) return ; float val = 0.f; val = tex2D(texA, idy, idx); val *= val; val = lhs[INDX(idy, idx, wid)] - val; out[INDX(idy, idx, wid)] = val; } __global__ void covariance_kernel(float *out, float *lhs, int wid, int hei) { int idx = threadIdx.x + blockDim.x * blockIdx.x; int idy = threadIdx.y + blockDim.y * blockIdx.y; if(idx >= wid || idy >= hei) return ; float val = 0.0f; val = tex2D(texA, idy, idx); val *= tex2D(texB, idy, idx); out[INDX(idy, idx, wid)] = lhs[INDX(idy, idx, wid)] - val; } // input 3 variables : meanP, meanI and "a", the former two are stored in texture now __global__ void calcuB_kernel(float *out, float *in, int wid, int hei) { int idx = threadIdx.x + blockDim.x * blockIdx.x; int idy = threadIdx.y + blockDim.y * blockIdx.y; if(idx >= wid || idy >= hei) return ; float val; val = in[INDX(idy, idx, wid)]; val *= tex2D(texA, idy, idx); val = tex2D(texB, idy, idx) - val; out[INDX(idy, idx, wid)] = val; } __device__ int clamp(int a, int b, int c) { int temp = a > b ? a : b; return (temp < c ? temp : c); } // boxfilter based on share memory __global__ void boxfilter_kernel(float * const d_in, float * const d_out, int wid, int hei, const float * __restrict__ filter, const int filterWidth) { const unsigned int x0 = threadIdx.x; const unsigned int y0 = threadIdx.y; const int tx = x0 + blockIdx.x * blockDim.x; const int ty = y0 + blockIdx.y * blockDim.y; if(tx >= wid || ty >= hei) return ; const int filterRadius = filterWidth / 2; float value = 0.f; __shared__ float shMat[BLOCK_SIZE + BOXWIDTH - 1][BLOCK_SIZE + BOXWIDTH - 1]; int fx, fy; // case 1 : upper left fx = tx - filterRadius; // col fy = ty - filterRadius; // row fx = clamp(fx, 0, wid); fy = clamp(fy, 0, hei); shMat[x0][y0] = d_in[INDX(fy, fx, wid)]; // case 2 : upper right fx = tx + filterRadius; fy = ty - filterRadius; fx = clamp(fx, 0, wid); fy = clamp(fy, 0, hei); shMat[x0 + filterWidth - 1][y0] = d_in[INDX(fy, fx, wid)]; // case 3 : lower left fx = tx - filterRadius; fy = ty + filterRadius; fx = clamp(fx, 0, wid); fy = clamp(fy, 0, hei); shMat[x0][y0 + filterWidth - 1] = d_in[INDX(fy, fx, wid)]; // case 4 : lower right fx = fx + filterRadius; fy = fy + filterRadius; fx = clamp(fx, 0, wid); fy = clamp(fy, 0, hei); shMat[x0+filterWidth - 1][y0 + filterWidth - 1] = d_in[INDX(fy, fx, wid)]; __syncthreads(); for(int i = 0; i < filterWidth; ++i) for (int j = 0; j < filterWidth; ++j) { value += filter[INDX(j, i, filterWidth)] * shMat[x0+i][y0+j]; } d_out[INDX(ty, tx, wid)] = value; } // calculate the image I based on texture memory __global__ void boxfilterTI_kernel(float *out, int wid, int hei, const size_t pitch, const int fWid, const int fHei) { int idx = threadIdx.x + blockDim.x * blockIdx.x; int idy = threadIdx.y + blockDim.y * blockIdx.y; float outputVal = 0.0f; if(idx < wid && idy < hei) { for(int i = -fWid; i <= fWid; ++i) { for(int j = -fHei; j <= fHei; ++j) outputVal += tex2D(texA, idy + j, idx + i); } outputVal /= ((2 * fWid + 1) * (2 * fHei + 1)); int offset = idy * pitch / sizeof(float) + idx; out[offset] = outputVal; } } __global__ void boxfilterTP_kernel(float *out, int wid, int hei, const size_t pitch, const int fWid, const int fHei) { int idx = threadIdx.x + blockDim.x * blockIdx.x; int idy = threadIdx.y + blockDim.y * blockIdx.y; float outputVal = 0.0f; if(idx < wid && idy < hei) { for(int i = -fWid; i <= fWid; ++i) { for(int j = -fHei; j <= fHei; ++j) outputVal += tex2D(texB, idy + j, idx + i); } outputVal /= ((2 * fWid + 1) * (2 * fHei + 1)); int offset = idy * pitch / sizeof(float) + idx; out[offset] = outputVal; } } __global__ void elemwisemult_kernel(float *out, size_t pitch, const int wid, const int hei) { int idx = threadIdx.x + blockDim.x * blockIdx.x; int idy = threadIdx.y + blockDim.y * blockIdx.y; int offset = idy * pitch / sizeof(float) + idx; float res = 0.f; if(idx < wid && idy < hei) { res = tex2D(texA, idy, idx) * tex2D(texB, idy, idx); } out[offset] = res; } /* __global__ void elemwisemult_kernel(float *out, float *inA, float *inB, size_t pitch, const int wid, const int hei) { extern __shared__ float A[]; extern __shared__ float B[]; int idx = threadIdx.x + blockDim.x * blockIdx.x; int idy = threadIdx.y + blockDim.y * blockIdx.y; //int index = idy * blockDim.x * gridDim.x + idx; int offset = idy * pitch / sizeof(float) + idx; int sharedIdx = threadIdx.y * blockDim.x + threadIdx.x; if(idx < wid && idy < hei) { A[sharedIdx] = inA[offset]; B[sharedIdx] = inB[offset]; //A[threadIdx.x][threadIdx.y] = inA[index]; //B[threadIdx.x][threadIdx.y] = inB[index]; __syncthreads(); out[offset] = A[sharedIdx] * B[sharedIdx]; } } */ __global__ void elemwisemultSame_kernel(float *out, const size_t pitch, const int wid, const int hei) { int idx = threadIdx.x + blockDim.x * blockIdx.x; int idy = threadIdx.y + blockDim.y * blockIdx.y; float outputVal = 0.0f; if(idx < wid && idy < hei) { outputVal = tex2D(texA, idy, idx); outputVal *= outputVal; } int offset = idy * pitch / sizeof(float) + idx; out[offset] = outputVal; } /* // dir means the operation : 0 for add, 1 for subtraction __global__ void elewiseAdd_kernel(float *lhs, float *rhs, int dir, int wid, int hei) { int idx = threadIdx.x + blockDim.x * blockIdx.x; int idy = threadIdx.y + blockDim.y * blockIdx.y; int index = idy * wid + idx; if(idx < wid && idy < hei) { if(dir == 0) // for operation + lhs[index] += rhs[index]; else if(dir == 1) // for operation - lhs[index] -= rhs[index]; else lhs[index] = lhs[index]; } } */ // the img I is binded to texA, so the source operators are in1, in2 only // in1 : meanA, in2 : meanB __global__ void finnalCal_kernel(float * const out, const float * const in1, const float * const in2, int wid, int hei) { int idx = threadIdx.x + blockDim.x * blockIdx.x; int idy = threadIdx.y + blockDim.y * blockIdx.y; if(idx >= wid || idy >= hei) return ; float val = 0.f; val = in1[INDX(idy, idx, wid)] * tex2D(texA, idy, idx); val += in2[INDX(idy, idx, wid)]; out[INDX(idy, idx, wid)] = val; } __global__ void elewiseDiv_kernel(float *lhs, float *rhs, int wid, int hei) { int idx = threadIdx.x + blockDim.x * blockIdx.x; int idy = threadIdx.y + blockDim.y * blockIdx.y; //int index = idy * wid + idx; if(idx < wid && idy < hei) { lhs[INDX(idy, idx, wid)] /= rhs[INDX(idy, idx, wid)] + d_eps; } } // allocate page-locked memory on host cudaHostAlloc, use cudaFreeHost to free them void GFilter::prepareMem(float *dataInI, float *dataInP) { } void GFilter::createfilter() { //const int filterSize = (2 * rad + 1) * (2 * rad + 1); filter = new float [FILTERSIZE]; for(int i = 0; i < FILTERSIZE; ++i) filter[i] = 1.0 / FILTERSIZE; } /* void GFilter::boxfilter(float *d_in, float *d_out, int rad, const float * const __restrict__ filter) { dim3 threadPerBlock(BLOCKSIZE, BLOCKSIZE); dim3 blockPerGrid((width + threadPerBlock.x - 1) / BLOCKSIZE, (height + threadPerBlock.y - 1) / BLOCKSIZE); } */ void GFilter::guidedfilter() { // copy data from host to device // allocate pitch memory on device use cudaMallocPitch size_t pitch = 0; cudaError_t cudaState = cudaSuccess; cudaState = cudaMallocPitch((void **)&d_imgI, &pitch, width, height); // pitch' unit is bytes ! assert(cudaState == cudaSuccess); cudaState = cudaMallocPitch((void **)&d_imgP, &pitch, width, height); assert(cudaState == cudaSuccess); // allocate temp data on device use cudaMalloc cudaState = cudaMalloc((void **)&d_meanI, sizeof(float) * width * height); assert(cudaState == cudaSuccess); cudaState = cudaMalloc((void **)&d_meanP, sizeof(float) * width * height); assert(cudaState == cudaSuccess); cudaState = cudaMalloc((void **)&d_tempA, sizeof(float) * width * height); assert(cudaState == cudaSuccess); cudaState = cudaMalloc((void **)&d_tempB, sizeof(float) * width * height); assert(cudaState == cudaSuccess); // copy data from host to device use cudaMemcpy2D // the dst pitch and src pitch all are in bytes cudaState = cudaMemcpy2D(d_imgI, pitch, h_imgI, sizeof(float) * width, sizeof(float) * width, height, cudaMemcpyHostToDevice); assert(cudaState == cudaSuccess); cudaState = cudaMemcpy2D(d_imgP, pitch, h_imgP, sizeof(float) * width, sizeof(float) * width, height, cudaMemcpyHostToDevice); assert(cudaState == cudaSuccess); // prepare the texture memory cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc<float>(); texA.addressMode[0] = texA.addressMode[1] = cudaAddressModeBorder; // bind the 2D Pitch memory to 2D texture memory cudaState = cudaBindTexture2D(NULL, texA, d_imgI, channelDesc, width, height, pitch); assert(cudaState == cudaSuccess); cudaState = cudaBindTexture2D(NULL, texB, d_imgP, channelDesc, width, height, pitch); assert(cudaState == cudaSuccess); /* // prepare the filter on device constant memory by using cudaMemcpyToSymbol createfilter(); cudaState = cudaMemcpyToSymbol(d_); */ createfilter(); cudaState = cudaMalloc((void **)&d_filter, FILTERSIZE * sizeof(float)); assert(cudaState == cudaSuccess); cudaState = cudaMemcpy(d_filter, filter, FILTERSIZE * sizeof(float), cudaMemcpyHostToDevice); assert(cudaState == cudaSuccess); // prepare the kernel launching parameters dim3 threadPerBlock(BLOCK_SIZE, BLOCK_SIZE); dim3 blockPerGrid; blockPerGrid.x = (width + threadPerBlock.x - 1) / threadPerBlock.x; blockPerGrid.y = (height + threadPerBlock.y - 1) / threadPerBlock.y; // launch boxfilter kernel with stream technology cudaStream_t st[4]; // create stream use cudaStreamCreate for(int i = 0; i < 4; ++i) { cudaState = cudaStreamCreate(&st[i]); assert(cudaState == cudaSuccess); } boxfilterTI_kernel<<<blockPerGrid, threadPerBlock, 0, st[0]>>>(d_meanI, width, height, pitch, rad, rad); boxfilterTP_kernel<<<blockPerGrid, threadPerBlock, 0, st[1]>>>(d_meanP, width, height, pitch, rad, rad); elemwisemultSame_kernel<<<blockPerGrid, threadPerBlock, 0, st[2]>>>(d_tempA, pitch, width, height); elemwisemult_kernel<<<blockPerGrid, threadPerBlock, 0, st[3]>>>(d_tempB, pitch, width, height); // synchronize all above streams use cudaDeviceSyncthronize() cudaState = cudaDeviceSynchronize(); assert(cudaState == cudaSuccess); // calculate the corrI and corrIp boxfilter_kernel<<<blockPerGrid, threadPerBlock>>>(d_tempA, d_tempA, width, height, d_filter, FILTERWIDTH); boxfilter_kernel<<<blockPerGrid, threadPerBlock>>>(d_tempB, d_tempB, width, height, d_filter, FILTERWIDTH); // change the texA to d_meanI // Unbind the texA from origin d_imgI cudaState = cudaUnbindTexture(texA); assert(cudaState == cudaSuccess); // rebind the texA to d_meanI // the pitch of d_meanI is width * sizeof(float) cudaState = cudaBindTexture2D(NULL, texA, d_meanI, channelDesc, width, height, width * sizeof(float)); assert(cudaState == cudaSuccess); // calculation the variance of I: varI variance_kernel<<<blockPerGrid, threadPerBlock>>>(d_tempA, d_tempA, width, height); // rebind the texB to d_meanP // unbind the texB from d_imgP; cudaState = cudaUnbindTexture(texB); assert(cudaState == cudaSuccess); // bind the texB to d_meanp cudaState = cudaBindTexture2D(NULL, texB, d_meanP, channelDesc, width, height, sizeof(float) * width); assert(cudaState == cudaSuccess); // calculate the covariance of I and P based on global memory covariance_kernel<<<blockPerGrid, threadPerBlock>>>(d_tempB, d_tempB, width, height); // calculate the a & b // calculate the "a" and store it in d_tempB // copy eps to device constant memory which is d_eps cudaState = cudaMemcpyToSymbol(d_eps, &eps, sizeof(float), NULL, cudaMemcpyDefault); assert(cudaState == cudaSuccess); // launch the kernel function elewiseDiv_kernel<<<blockPerGrid, threadPerBlock>>>(d_tempB, d_tempA, width, height); /* // rebind texB to above "a" cudaState = cudaUnbindTexture(texB); assert(cudaState == cudaSuccess); // bind the texB to "a" which is in d_tempB cudaState = cudaBindTexture2D(NULL, texB, d_tempB, channelDesc, sizeof(float) * width); assert(cudaState == cudaSuccess); */ // calculate the "b" and store it in tempA // launch the the kernel function calcuB_kernel<<<blockPerGrid, threadPerBlock>>>(d_tempA, d_tempB, width, height); // calculate the boxfilter of "a" & "b" // calculate meanA based on d_tempB boxfilter_kernel<<<blockPerGrid, threadPerBlock>>>(d_tempB, d_tempB, width, height, d_filter, FILTERWIDTH); // calculate meaB based on d_tempA boxfilter_kernel<<<blockPerGrid, threadPerBlock>>>(d_tempA, d_tempA, width, height, d_filter, FILTERWIDTH); // calculate the finnal output: guided filtering result Res = new float [width * height]; // rebind the texA to d_imgI // unbind the texA from d_meanI cudaState = cudaUnbindTexture(texA); assert(cudaState == cudaSuccess); // rebind the texA to d_imgI cudaState = cudaBindTexture2D(NULL, texA, d_imgI, width, height, pitch); assert(cudaState == cudaSuccess); finnalCal_kernel<<<blockPerGrid, threadPerBlock>>>(d_meanI, d_tempB, d_tempA, width, height); // Finnal step : copy data from device back to host cudaState = cudaMemcpy(Res, d_meanI, sizeof(float) * width * height, cudaMemcpyHostToDevice); assert(cudaState == cudaSuccess); // Unbind all textures cudaState = cudaUnbindTexture(texB); assert(cudaState == cudaSuccess); cudaState = cudaUnbindTexture(texA); assert(cudaState == cudaSuccess); // destory streams use cudaStreamDestory for(int i = 0; i < 4; i++) { cudaState = cudaStreamDestroy(st[i]); assert(cudaState == cudaSuccess); } if(d_imgI) cudaFree(d_imgI); if(d_imgP) cudaFree(d_imgP); if(d_tempA) cudaFree(d_tempA); if(d_tempB) cudaFree(d_tempB); if(d_meanI) cudaFree(d_meanI); if(d_meanP) cudaFree(d_meanP); if(d_filter) cudaFree(d_filter); } GFilter::~GFilter() { /* if(d_imgI) cudaFree(d_imgI); if(d_imgP) cudaFree(d_imgP); if(d_tempA) cudaFree(d_tempA); if(d_tempB) cudaFree(d_tempB); if(d_meanI) cudaFree(d_meanI); if(d_meanP) cudaFree(d_meanP); if(d_filter) cudaFree(d_filter); if(filter) delete [] filter; if(Res) delete [] Res; */ }
cfbd3d6e67334572fde5ca7054e5d01e5229e228.hip
// !!! This is a file automatically generated by hipify!!! #include "cuda_error_hadling.h" #include "bfs_gpu.cuh" #include <limits> #include <iostream> #include <hip/hip_runtime.h> #include <stdio.h> #include <stdlib.h> #include <getopt.h> #include <hip/hip_runtime.h> #include <sys/time.h> #include <math.h> #include <assert.h> #include <float.h> #include "const.h" using namespace std; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // init levels ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void __global__ init_kernel(int *_levels, int _vertices_count, int _source_vertex) { register const int idx = (blockIdx.x * blockDim.x + threadIdx.x) + blockIdx.y * blockDim.x * gridDim.x; // if (idx < _vertices_count) _levels[idx] = UNVISITED_VERTEX; _levels[_source_vertex] = 1; // - "" } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // main computational algorithm ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void __global__ bfs_kernel(int *_levels, long long *_outgoing_ptrs, int *_outgoing_ids, int _vertices_count, long long _edges_count, int *_changes, int _current_level) { register const int src_id = blockIdx.x * blockDim.x + threadIdx.x; if (src_id < _vertices_count) // { if(_levels[src_id] == _current_level) // ( ) { const long long edge_start = _outgoing_ptrs[src_id]; // const int connections_count = _outgoing_ptrs[src_id + 1] - _outgoing_ptrs[src_id]; // for(int edge_pos = 0; edge_pos < connections_count; edge_pos++) // : { int dst_id = _outgoing_ids[edge_start + edge_pos]; // ID if (_levels[dst_id] == UNVISITED_VERTEX) // - { _levels[dst_id] = _current_level + 1; // _changes[0] = 1; } } } } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // single GPU implememntation ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void gpu_bfs_wrapper(long long *_outgoing_ptrs, int *_outgoing_ids, int _vertices_count, long long _edges_count, int _source_vertex, int *_levels) { dim3 init_threads(1024); dim3 init_blocks((_vertices_count - 1) / init_threads.x + 1); // call init kernel hipLaunchKernelGGL(( SAFE_KERNEL_CALL((init_kernel) , dim3(init_blocks), dim3(init_threads) , 0, 0, _levels, _vertices_count, _source_vertex))); // device variable to stop iterations, for each source vertex int *changes; SAFE_CALL(hipMallocManaged((void**)&changes, sizeof(int))); // set grid size dim3 compute_threads(1024); dim3 compute_blocks((_vertices_count - 1) / compute_threads.x + 1); int current_level = 1; // compute shortest paths do { changes[0] = 0; hipLaunchKernelGGL(( SAFE_KERNEL_CALL((bfs_kernel) , dim3(compute_blocks), dim3(compute_threads) , 0, 0, _levels, _outgoing_ptrs, _outgoing_ids, _vertices_count, _edges_count, changes, current_level))); current_level++; } while(changes[0] > 0); SAFE_CALL(hipFree(changes)); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
cfbd3d6e67334572fde5ca7054e5d01e5229e228.cu
#include "cuda_error_hadling.h" #include "bfs_gpu.cuh" #include <limits> #include <iostream> #include <cuda_runtime.h> #include <stdio.h> #include <stdlib.h> #include <getopt.h> #include <cuda.h> #include <sys/time.h> #include <math.h> #include <assert.h> #include <float.h> #include "const.h" using namespace std; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // init levels ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void __global__ init_kernel(int *_levels, int _vertices_count, int _source_vertex) { register const int idx = (blockIdx.x * blockDim.x + threadIdx.x) + blockIdx.y * blockDim.x * gridDim.x; // все вершины кроме источника еще не посещены if (idx < _vertices_count) _levels[idx] = UNVISITED_VERTEX; _levels[_source_vertex] = 1; // вершина-источник помещается на первый "уровень" } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // main computational algorithm ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void __global__ bfs_kernel(int *_levels, long long *_outgoing_ptrs, int *_outgoing_ids, int _vertices_count, long long _edges_count, int *_changes, int _current_level) { register const int src_id = blockIdx.x * blockDim.x + threadIdx.x; if (src_id < _vertices_count) // для всех графовых вершин выполнить следующее { if(_levels[src_id] == _current_level) // если графовая вершина принадлежит текущему (ранее посещенному уровню) { const long long edge_start = _outgoing_ptrs[src_id]; // получаем положение первого ребра вершины const int connections_count = _outgoing_ptrs[src_id + 1] - _outgoing_ptrs[src_id]; // получаем число смежных ребер вершины for(int edge_pos = 0; edge_pos < connections_count; edge_pos++) // для каждого смежного ребра делаем: { int dst_id = _outgoing_ids[edge_start + edge_pos]; // загружаем ID напарвляющей вершины ребра if (_levels[dst_id] == UNVISITED_VERTEX) // если направляющая вершина - не посещенная { _levels[dst_id] = _current_level + 1; // то помечаем её следующим уровнем _changes[0] = 1; } } } } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // single GPU implememntation ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void gpu_bfs_wrapper(long long *_outgoing_ptrs, int *_outgoing_ids, int _vertices_count, long long _edges_count, int _source_vertex, int *_levels) { dim3 init_threads(1024); dim3 init_blocks((_vertices_count - 1) / init_threads.x + 1); // call init kernel SAFE_KERNEL_CALL((init_kernel <<< init_blocks, init_threads >>> (_levels, _vertices_count, _source_vertex))); // device variable to stop iterations, for each source vertex int *changes; SAFE_CALL(cudaMallocManaged((void**)&changes, sizeof(int))); // set grid size dim3 compute_threads(1024); dim3 compute_blocks((_vertices_count - 1) / compute_threads.x + 1); int current_level = 1; // compute shortest paths do { changes[0] = 0; SAFE_KERNEL_CALL((bfs_kernel <<< compute_blocks, compute_threads >>> (_levels, _outgoing_ptrs, _outgoing_ids, _vertices_count, _edges_count, changes, current_level))); current_level++; } while(changes[0] > 0); SAFE_CALL(cudaFree(changes)); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
91f47f23ca657af3f6eb6c8dd6a9fb61d9fe3bc5.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" /****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ /* * Copyright 2018-2019 Autoware Foundation. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <algorithm> // headers in local files #include "modules/perception/lidar/lib/detection/lidar_point_pillars/anchor_mask_cuda.h" #include "modules/perception/lidar/lib/detection/lidar_point_pillars/common.h" namespace apollo { namespace perception { namespace lidar { // modified prefix sum code from // https://www.mimuw.edu.pl/~ps209291/kgkp/slides/scan.pdf __global__ void scan_x(int* g_odata, int* g_idata, int n) { extern __shared__ int temp[]; // allocated on invocation int thid = threadIdx.x; int bid = blockIdx.x; int bdim = blockDim.x; int offset = 1; temp[2 * thid] = g_idata[bid * bdim * 2 + 2 * thid]; // load input into shared memory temp[2 * thid + 1] = g_idata[bid * bdim * 2 + 2 * thid + 1]; for (int d = n >> 1; d > 0; d >>= 1) { // build sum in place up the tree __syncthreads(); if (thid < d) { int ai = offset * (2 * thid + 1) - 1; int bi = offset * (2 * thid + 2) - 1; temp[bi] += temp[ai]; } offset *= 2; } if (thid == 0) { temp[n - 1] = 0; } // clear the last element for (int d = 1; d < n; d *= 2) { // traverse down tree & build scan offset >>= 1; __syncthreads(); if (thid < d) { int ai = offset * (2 * thid + 1) - 1; int bi = offset * (2 * thid + 2) - 1; int t = temp[ai]; temp[ai] = temp[bi]; temp[bi] += t; } } __syncthreads(); g_odata[bid * bdim * 2 + 2 * thid] = temp[2 * thid + 1]; // write results to device memory int second_ind = 2 * thid + 2; if (second_ind == bdim * 2) { g_odata[bid * bdim * 2 + 2 * thid + 1] = temp[2 * thid + 1] + g_idata[bid * bdim * 2 + 2 * thid + 1]; } else { g_odata[bid * bdim * 2 + 2 * thid + 1] = temp[2 * thid + 2]; } } // modified prefix sum code from // https://www.mimuw.edu.pl/~ps209291/kgkp/slides/scan.pdf __global__ void scan_y(int* g_odata, int* g_idata, int n) { extern __shared__ int temp[]; // allocated on invocation int thid = threadIdx.x; int bid = blockIdx.x; int bdim = blockDim.x; int gdim = gridDim.x; int offset = 1; temp[2 * thid] = g_idata[bid + 2 * thid * gdim]; // load input into shared memory temp[2 * thid + 1] = g_idata[bid + 2 * thid * gdim + gdim]; for (int d = n >> 1; d > 0; d >>= 1) { // build sum in place up the tree __syncthreads(); if (thid < d) { int ai = offset * (2 * thid + 1) - 1; int bi = offset * (2 * thid + 2) - 1; temp[bi] += temp[ai]; } offset *= 2; } if (thid == 0) { temp[n - 1] = 0; } // clear the last element for (int d = 1; d < n; d *= 2) { // traverse down tree & build scan offset >>= 1; __syncthreads(); if (thid < d) { int ai = offset * (2 * thid + 1) - 1; int bi = offset * (2 * thid + 2) - 1; int t = temp[ai]; temp[ai] = temp[bi]; temp[bi] += t; } } __syncthreads(); g_odata[bid + 2 * thid * gdim] = temp[2 * thid + 1]; // write results to device memory int second_ind = 2 * thid + 2; if (second_ind == bdim * 2) { g_odata[bid + 2 * thid * gdim + gdim] = temp[2 * thid + 1] + g_idata[bid + 2 * thid * gdim + gdim]; } else { g_odata[bid + 2 * thid * gdim + gdim] = temp[2 * thid + 2]; } } __global__ void make_anchor_mask_kernel( const float* dev_box_anchors_min_x, const float* dev_box_anchors_min_y, const float* dev_box_anchors_max_x, const float* dev_box_anchors_max_y, int* dev_sparse_pillar_map, int* dev_anchor_mask, const float MIN_X_RANGE, const float MIN_Y_RANGE, const float PILLAR_X_SIZE, const float PILLAR_Y_SIZE, const int GRID_X_SIZE, const int GRID_Y_SIZE, const int NUM_INDS_FOR_SCAN) { int tid = threadIdx.x + blockIdx.x * blockDim.x; int anchor_coor[NUM_2D_BOX_CORNERS_MACRO] = {0}; const int GRID_X_SIZE_1 = GRID_X_SIZE - 1; // grid_x_size - 1 const int GRID_Y_SIZE_1 = GRID_Y_SIZE - 1; // grid_y_size - 1 anchor_coor[0] = floor((dev_box_anchors_min_x[tid] - MIN_X_RANGE) / PILLAR_X_SIZE); anchor_coor[1] = floor((dev_box_anchors_min_y[tid] - MIN_Y_RANGE) / PILLAR_Y_SIZE); anchor_coor[2] = floor((dev_box_anchors_max_x[tid] - MIN_X_RANGE) / PILLAR_X_SIZE); anchor_coor[3] = floor((dev_box_anchors_max_y[tid] - MIN_Y_RANGE) / PILLAR_Y_SIZE); anchor_coor[0] = max(anchor_coor[0], 0); anchor_coor[1] = max(anchor_coor[1], 0); anchor_coor[2] = min(anchor_coor[2], GRID_X_SIZE_1); anchor_coor[3] = min(anchor_coor[3], GRID_Y_SIZE_1); int right_top = dev_sparse_pillar_map[anchor_coor[3] * NUM_INDS_FOR_SCAN + anchor_coor[2]]; int left_bottom = dev_sparse_pillar_map[anchor_coor[1] * NUM_INDS_FOR_SCAN + anchor_coor[0]]; int left_top = dev_sparse_pillar_map[anchor_coor[3] * NUM_INDS_FOR_SCAN + anchor_coor[0]]; int right_bottom = dev_sparse_pillar_map[anchor_coor[1] * NUM_INDS_FOR_SCAN + anchor_coor[2]]; int area = right_top - left_top - right_bottom + left_bottom; if (area > 1) { dev_anchor_mask[tid] = 1; } else { dev_anchor_mask[tid] = 0; } } AnchorMaskCuda::AnchorMaskCuda( const int NUM_INDS_FOR_SCAN, const int NUM_ANCHOR_X_INDS, const int NUM_ANCHOR_Y_INDS, const int NUM_ANCHOR_R_INDS, const float MIN_X_RANGE, const float MIN_Y_RANGE, const float PILLAR_X_SIZE, const float PILLAR_Y_SIZE, const int GRID_X_SIZE, const int GRID_Y_SIZE) : NUM_INDS_FOR_SCAN_(NUM_INDS_FOR_SCAN), NUM_ANCHOR_X_INDS_(NUM_ANCHOR_X_INDS), NUM_ANCHOR_Y_INDS_(NUM_ANCHOR_Y_INDS), NUM_ANCHOR_R_INDS_(NUM_ANCHOR_R_INDS), MIN_X_RANGE_(MIN_X_RANGE), MIN_Y_RANGE_(MIN_Y_RANGE), PILLAR_X_SIZE_(PILLAR_X_SIZE), PILLAR_Y_SIZE_(PILLAR_Y_SIZE), GRID_X_SIZE_(GRID_X_SIZE), GRID_Y_SIZE_(GRID_Y_SIZE) {} void AnchorMaskCuda::doAnchorMaskCuda( int* dev_sparse_pillar_map, int* dev_cumsum_along_x, int* dev_cumsum_along_y, const float* dev_box_anchors_min_x, const float* dev_box_anchors_min_y, const float* dev_box_anchors_max_x, const float* dev_box_anchors_max_y, int* dev_anchor_mask) { hipLaunchKernelGGL(( scan_x), dim3(NUM_INDS_FOR_SCAN_), dim3(NUM_INDS_FOR_SCAN_ / 2), NUM_INDS_FOR_SCAN_ * sizeof(int), 0, dev_cumsum_along_x, dev_sparse_pillar_map, NUM_INDS_FOR_SCAN_); hipLaunchKernelGGL(( scan_y), dim3(NUM_INDS_FOR_SCAN_), dim3(NUM_INDS_FOR_SCAN_ / 2), NUM_INDS_FOR_SCAN_ * sizeof(int), 0, dev_cumsum_along_y, dev_cumsum_along_x, NUM_INDS_FOR_SCAN_); GPU_CHECK(hipMemcpy(dev_sparse_pillar_map, dev_cumsum_along_y, NUM_INDS_FOR_SCAN_ * NUM_INDS_FOR_SCAN_ * sizeof(int), hipMemcpyDeviceToDevice)); hipLaunchKernelGGL(( make_anchor_mask_kernel), dim3(NUM_ANCHOR_X_INDS_ * NUM_ANCHOR_R_INDS_), dim3(NUM_ANCHOR_Y_INDS_), 0, 0, dev_box_anchors_min_x, dev_box_anchors_min_y, dev_box_anchors_max_x, dev_box_anchors_max_y, dev_sparse_pillar_map, dev_anchor_mask, MIN_X_RANGE_, MIN_Y_RANGE_, PILLAR_X_SIZE_, PILLAR_Y_SIZE_, GRID_X_SIZE_, GRID_Y_SIZE_, NUM_INDS_FOR_SCAN_); } } // namespace lidar } // namespace perception } // namespace apollo
91f47f23ca657af3f6eb6c8dd6a9fb61d9fe3bc5.cu
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ /* * Copyright 2018-2019 Autoware Foundation. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <algorithm> // headers in local files #include "modules/perception/lidar/lib/detection/lidar_point_pillars/anchor_mask_cuda.h" #include "modules/perception/lidar/lib/detection/lidar_point_pillars/common.h" namespace apollo { namespace perception { namespace lidar { // modified prefix sum code from // https://www.mimuw.edu.pl/~ps209291/kgkp/slides/scan.pdf __global__ void scan_x(int* g_odata, int* g_idata, int n) { extern __shared__ int temp[]; // allocated on invocation int thid = threadIdx.x; int bid = blockIdx.x; int bdim = blockDim.x; int offset = 1; temp[2 * thid] = g_idata[bid * bdim * 2 + 2 * thid]; // load input into shared memory temp[2 * thid + 1] = g_idata[bid * bdim * 2 + 2 * thid + 1]; for (int d = n >> 1; d > 0; d >>= 1) { // build sum in place up the tree __syncthreads(); if (thid < d) { int ai = offset * (2 * thid + 1) - 1; int bi = offset * (2 * thid + 2) - 1; temp[bi] += temp[ai]; } offset *= 2; } if (thid == 0) { temp[n - 1] = 0; } // clear the last element for (int d = 1; d < n; d *= 2) { // traverse down tree & build scan offset >>= 1; __syncthreads(); if (thid < d) { int ai = offset * (2 * thid + 1) - 1; int bi = offset * (2 * thid + 2) - 1; int t = temp[ai]; temp[ai] = temp[bi]; temp[bi] += t; } } __syncthreads(); g_odata[bid * bdim * 2 + 2 * thid] = temp[2 * thid + 1]; // write results to device memory int second_ind = 2 * thid + 2; if (second_ind == bdim * 2) { g_odata[bid * bdim * 2 + 2 * thid + 1] = temp[2 * thid + 1] + g_idata[bid * bdim * 2 + 2 * thid + 1]; } else { g_odata[bid * bdim * 2 + 2 * thid + 1] = temp[2 * thid + 2]; } } // modified prefix sum code from // https://www.mimuw.edu.pl/~ps209291/kgkp/slides/scan.pdf __global__ void scan_y(int* g_odata, int* g_idata, int n) { extern __shared__ int temp[]; // allocated on invocation int thid = threadIdx.x; int bid = blockIdx.x; int bdim = blockDim.x; int gdim = gridDim.x; int offset = 1; temp[2 * thid] = g_idata[bid + 2 * thid * gdim]; // load input into shared memory temp[2 * thid + 1] = g_idata[bid + 2 * thid * gdim + gdim]; for (int d = n >> 1; d > 0; d >>= 1) { // build sum in place up the tree __syncthreads(); if (thid < d) { int ai = offset * (2 * thid + 1) - 1; int bi = offset * (2 * thid + 2) - 1; temp[bi] += temp[ai]; } offset *= 2; } if (thid == 0) { temp[n - 1] = 0; } // clear the last element for (int d = 1; d < n; d *= 2) { // traverse down tree & build scan offset >>= 1; __syncthreads(); if (thid < d) { int ai = offset * (2 * thid + 1) - 1; int bi = offset * (2 * thid + 2) - 1; int t = temp[ai]; temp[ai] = temp[bi]; temp[bi] += t; } } __syncthreads(); g_odata[bid + 2 * thid * gdim] = temp[2 * thid + 1]; // write results to device memory int second_ind = 2 * thid + 2; if (second_ind == bdim * 2) { g_odata[bid + 2 * thid * gdim + gdim] = temp[2 * thid + 1] + g_idata[bid + 2 * thid * gdim + gdim]; } else { g_odata[bid + 2 * thid * gdim + gdim] = temp[2 * thid + 2]; } } __global__ void make_anchor_mask_kernel( const float* dev_box_anchors_min_x, const float* dev_box_anchors_min_y, const float* dev_box_anchors_max_x, const float* dev_box_anchors_max_y, int* dev_sparse_pillar_map, int* dev_anchor_mask, const float MIN_X_RANGE, const float MIN_Y_RANGE, const float PILLAR_X_SIZE, const float PILLAR_Y_SIZE, const int GRID_X_SIZE, const int GRID_Y_SIZE, const int NUM_INDS_FOR_SCAN) { int tid = threadIdx.x + blockIdx.x * blockDim.x; int anchor_coor[NUM_2D_BOX_CORNERS_MACRO] = {0}; const int GRID_X_SIZE_1 = GRID_X_SIZE - 1; // grid_x_size - 1 const int GRID_Y_SIZE_1 = GRID_Y_SIZE - 1; // grid_y_size - 1 anchor_coor[0] = floor((dev_box_anchors_min_x[tid] - MIN_X_RANGE) / PILLAR_X_SIZE); anchor_coor[1] = floor((dev_box_anchors_min_y[tid] - MIN_Y_RANGE) / PILLAR_Y_SIZE); anchor_coor[2] = floor((dev_box_anchors_max_x[tid] - MIN_X_RANGE) / PILLAR_X_SIZE); anchor_coor[3] = floor((dev_box_anchors_max_y[tid] - MIN_Y_RANGE) / PILLAR_Y_SIZE); anchor_coor[0] = max(anchor_coor[0], 0); anchor_coor[1] = max(anchor_coor[1], 0); anchor_coor[2] = min(anchor_coor[2], GRID_X_SIZE_1); anchor_coor[3] = min(anchor_coor[3], GRID_Y_SIZE_1); int right_top = dev_sparse_pillar_map[anchor_coor[3] * NUM_INDS_FOR_SCAN + anchor_coor[2]]; int left_bottom = dev_sparse_pillar_map[anchor_coor[1] * NUM_INDS_FOR_SCAN + anchor_coor[0]]; int left_top = dev_sparse_pillar_map[anchor_coor[3] * NUM_INDS_FOR_SCAN + anchor_coor[0]]; int right_bottom = dev_sparse_pillar_map[anchor_coor[1] * NUM_INDS_FOR_SCAN + anchor_coor[2]]; int area = right_top - left_top - right_bottom + left_bottom; if (area > 1) { dev_anchor_mask[tid] = 1; } else { dev_anchor_mask[tid] = 0; } } AnchorMaskCuda::AnchorMaskCuda( const int NUM_INDS_FOR_SCAN, const int NUM_ANCHOR_X_INDS, const int NUM_ANCHOR_Y_INDS, const int NUM_ANCHOR_R_INDS, const float MIN_X_RANGE, const float MIN_Y_RANGE, const float PILLAR_X_SIZE, const float PILLAR_Y_SIZE, const int GRID_X_SIZE, const int GRID_Y_SIZE) : NUM_INDS_FOR_SCAN_(NUM_INDS_FOR_SCAN), NUM_ANCHOR_X_INDS_(NUM_ANCHOR_X_INDS), NUM_ANCHOR_Y_INDS_(NUM_ANCHOR_Y_INDS), NUM_ANCHOR_R_INDS_(NUM_ANCHOR_R_INDS), MIN_X_RANGE_(MIN_X_RANGE), MIN_Y_RANGE_(MIN_Y_RANGE), PILLAR_X_SIZE_(PILLAR_X_SIZE), PILLAR_Y_SIZE_(PILLAR_Y_SIZE), GRID_X_SIZE_(GRID_X_SIZE), GRID_Y_SIZE_(GRID_Y_SIZE) {} void AnchorMaskCuda::doAnchorMaskCuda( int* dev_sparse_pillar_map, int* dev_cumsum_along_x, int* dev_cumsum_along_y, const float* dev_box_anchors_min_x, const float* dev_box_anchors_min_y, const float* dev_box_anchors_max_x, const float* dev_box_anchors_max_y, int* dev_anchor_mask) { scan_x<<<NUM_INDS_FOR_SCAN_, NUM_INDS_FOR_SCAN_ / 2, NUM_INDS_FOR_SCAN_ * sizeof(int)>>>( dev_cumsum_along_x, dev_sparse_pillar_map, NUM_INDS_FOR_SCAN_); scan_y<<<NUM_INDS_FOR_SCAN_, NUM_INDS_FOR_SCAN_ / 2, NUM_INDS_FOR_SCAN_ * sizeof(int)>>>( dev_cumsum_along_y, dev_cumsum_along_x, NUM_INDS_FOR_SCAN_); GPU_CHECK(cudaMemcpy(dev_sparse_pillar_map, dev_cumsum_along_y, NUM_INDS_FOR_SCAN_ * NUM_INDS_FOR_SCAN_ * sizeof(int), cudaMemcpyDeviceToDevice)); make_anchor_mask_kernel<<<NUM_ANCHOR_X_INDS_ * NUM_ANCHOR_R_INDS_, NUM_ANCHOR_Y_INDS_>>>( dev_box_anchors_min_x, dev_box_anchors_min_y, dev_box_anchors_max_x, dev_box_anchors_max_y, dev_sparse_pillar_map, dev_anchor_mask, MIN_X_RANGE_, MIN_Y_RANGE_, PILLAR_X_SIZE_, PILLAR_Y_SIZE_, GRID_X_SIZE_, GRID_Y_SIZE_, NUM_INDS_FOR_SCAN_); } } // namespace lidar } // namespace perception } // namespace apollo
cee519450c6b9c0edcb2fa42c7e8021cebc2ee40.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" /* -- MAGMA (version 1.4.1) -- Univ. of Tennessee, Knoxville Univ. of California, Berkeley Univ. of Colorado, Denver December 2013 @precisions normal z -> s d c @author Stan Tomov */ #include "common_magma.h" #define PRECISION_z #include "commonblas.h" __global__ void ztranspose_32( magmaDoubleComplex *B, int ldb, const magmaDoubleComplex *A, int lda ) { __shared__ magmaDoubleComplex a[32][ZSIZE_1SHARED+1]; int inx = threadIdx.x; int iny = threadIdx.y; int ibx = blockIdx.x*32; int iby = blockIdx.y*32; A += ibx + inx + __mul24( iby + iny, lda ); B += iby + inx + __mul24( ibx + iny, ldb ); a[iny+0][inx] = A[0*lda]; a[iny+8][inx] = A[8*lda]; a[iny+16][inx] = A[16*lda]; a[iny+24][inx] = A[24*lda]; __syncthreads(); #if defined(PRECISION_s) || defined(PRECISION_d) || defined(PRECISION_c) B[0*ldb] = a[inx][iny+0]; B[8*ldb] = a[inx][iny+8]; B[16*ldb] = a[inx][iny+16]; B[24*ldb] = a[inx][iny+24]; #else /* defined(PRECISION_z) */ B[0*ldb] = a[inx][iny+0]; B[8*ldb] = a[inx][iny+8]; B[0*ldb+16] = a[inx+16][iny+0]; B[8*ldb+16] = a[inx+16][iny+8]; __syncthreads(); A += ZSIZE_1SHARED; B += __mul24( 16, ldb); a[iny+0][inx] = A[0*lda]; a[iny+8][inx] = A[8*lda]; a[iny+16][inx] = A[16*lda]; a[iny+24][inx] = A[24*lda]; __syncthreads(); B[0*ldb] = a[inx][iny+0]; B[8*ldb] = a[inx][iny+8]; B[0*ldb+16] = a[inx+16][iny+0]; B[8*ldb+16] = a[inx+16][iny+8]; #endif } // // m, n - dimensions in the source matrix // This version works when m and n are divisible by 32. // extern "C" void magmablas_ztranspose(magmaDoubleComplex *odata, magma_int_t ldo, const magmaDoubleComplex *idata, magma_int_t ldi, magma_int_t m, magma_int_t n ) { //assert( (m%32) == 0 && (n%32) == 0, "misaligned transpose" ); dim3 threads( ZSIZE_1SHARED, 8, 1 ); dim3 grid( m/32, n/32, 1 ); hipLaunchKernelGGL(( ztranspose_32), dim3(grid), dim3(threads), 0, magma_stream , odata, ldo, idata, ldi ); }
cee519450c6b9c0edcb2fa42c7e8021cebc2ee40.cu
/* -- MAGMA (version 1.4.1) -- Univ. of Tennessee, Knoxville Univ. of California, Berkeley Univ. of Colorado, Denver December 2013 @precisions normal z -> s d c @author Stan Tomov */ #include "common_magma.h" #define PRECISION_z #include "commonblas.h" __global__ void ztranspose_32( magmaDoubleComplex *B, int ldb, const magmaDoubleComplex *A, int lda ) { __shared__ magmaDoubleComplex a[32][ZSIZE_1SHARED+1]; int inx = threadIdx.x; int iny = threadIdx.y; int ibx = blockIdx.x*32; int iby = blockIdx.y*32; A += ibx + inx + __mul24( iby + iny, lda ); B += iby + inx + __mul24( ibx + iny, ldb ); a[iny+0][inx] = A[0*lda]; a[iny+8][inx] = A[8*lda]; a[iny+16][inx] = A[16*lda]; a[iny+24][inx] = A[24*lda]; __syncthreads(); #if defined(PRECISION_s) || defined(PRECISION_d) || defined(PRECISION_c) B[0*ldb] = a[inx][iny+0]; B[8*ldb] = a[inx][iny+8]; B[16*ldb] = a[inx][iny+16]; B[24*ldb] = a[inx][iny+24]; #else /* defined(PRECISION_z) */ B[0*ldb] = a[inx][iny+0]; B[8*ldb] = a[inx][iny+8]; B[0*ldb+16] = a[inx+16][iny+0]; B[8*ldb+16] = a[inx+16][iny+8]; __syncthreads(); A += ZSIZE_1SHARED; B += __mul24( 16, ldb); a[iny+0][inx] = A[0*lda]; a[iny+8][inx] = A[8*lda]; a[iny+16][inx] = A[16*lda]; a[iny+24][inx] = A[24*lda]; __syncthreads(); B[0*ldb] = a[inx][iny+0]; B[8*ldb] = a[inx][iny+8]; B[0*ldb+16] = a[inx+16][iny+0]; B[8*ldb+16] = a[inx+16][iny+8]; #endif } // // m, n - dimensions in the source matrix // This version works when m and n are divisible by 32. // extern "C" void magmablas_ztranspose(magmaDoubleComplex *odata, magma_int_t ldo, const magmaDoubleComplex *idata, magma_int_t ldi, magma_int_t m, magma_int_t n ) { //assert( (m%32) == 0 && (n%32) == 0, "misaligned transpose" ); dim3 threads( ZSIZE_1SHARED, 8, 1 ); dim3 grid( m/32, n/32, 1 ); ztranspose_32<<< grid, threads, 0, magma_stream >>>( odata, ldo, idata, ldi ); }
9872915ba106f7435979ef314c164fa4953253d5.hip
// !!! This is a file automatically generated by hipify!!! #define GLM_FORCE_CUDA #include <stdio.h> #include <hip/hip_runtime.h> #include <cmath> #include <glm/glm.hpp> #include "utilityCore.hpp" #include "kernel.h" #define checkCUDAErrorWithLine(msg) checkCUDAError(msg, __LINE__) /** * Check for CUDA errors; print and exit if there was a problem. */ void checkCUDAError(const char *msg, int line = -1) { hipError_t err = hipGetLastError(); if (hipSuccess != err) { if (line >= 0) { fprintf(stderr, "Line %d: ", line); } fprintf(stderr, "Cuda error: %s: %s.\n", msg, hipGetErrorString(err)); exit(EXIT_FAILURE); } } /***************** * Configuration * *****************/ /*! Block size used for CUDA kernel launch. */ #define blockSize 128 /*! Mass of one "planet." */ #define planetMass 3e8f /*! Mass of the "star" at the center. */ #define starMass 5e10f /*! Size of the starting area in simulation space. */ const float scene_scale = 1e2; /*********************************************** * Kernel state (pointers are device pointers) * ***********************************************/ int numObjects; dim3 threadsPerBlock(blockSize); glm::vec3 *dev_pos; glm::vec3 *dev_vel; glm::vec3 *dev_acc; /****************** * initSimulation * ******************/ __host__ __device__ unsigned int hash(unsigned int a) { a = (a + 0x7ed55d16) + (a << 12); a = (a ^ 0xc761c23c) ^ (a >> 19); a = (a + 0x165667b1) + (a << 5); a = (a + 0xd3a2646c) ^ (a << 9); a = (a + 0xfd7046c5) + (a << 3); a = (a ^ 0xb55a4f09) ^ (a >> 16); return a; } /** * Function for generating a random vec3. */ __host__ __device__ glm::vec3 generateRandomVec3(float time, int index) { thrust::default_random_engine rng(hash((int)(index * time))); thrust::uniform_real_distribution<float> unitDistrib(-1, 1); return glm::vec3((float)unitDistrib(rng), (float)unitDistrib(rng), (float)unitDistrib(rng)); } /** * CUDA kernel for generating planets with a specified mass randomly around the star. */ __global__ void kernGenerateRandomPosArray(int time, int N, glm::vec3 * arr, float scale, float mass) { int index = (blockIdx.x * blockDim.x) + threadIdx.x; if (index < N) { glm::vec3 rand = generateRandomVec3(time, index); arr[index].x = scale * rand.x; arr[index].y = scale * rand.y; arr[index].z = 0.1 * scale * sqrt(rand.x * rand.x + rand.y * rand.y) * rand.z; } } /** * CUDA kernel for generating velocities in a vortex around the origin. * This is just to make for an interesting-looking scene. */ __global__ void kernGenerateCircularVelArray(int time, int N, glm::vec3 * arr, glm::vec3 * pos) { int index = (blockIdx.x * blockDim.x) + threadIdx.x; if (index < N) { glm::vec3 R = glm::vec3(pos[index].x, pos[index].y, pos[index].z); float r = glm::length(R) + EPSILON; float s = sqrt(G * starMass / r); glm::vec3 D = glm::normalize(glm::cross(R / r, glm::vec3(0, 0, 1))); arr[index].x = s * D.x; arr[index].y = s * D.y; arr[index].z = s * D.z; } } /** * Initialize memory, update some globals */ void Nbody::initSimulation(int N) { numObjects = N; dim3 fullBlocksPerGrid((N + blockSize - 1) / blockSize); hipMalloc((void**)&dev_pos, N * sizeof(glm::vec3)); checkCUDAErrorWithLine("hipMalloc dev_pos failed!"); hipMalloc((void**)&dev_vel, N * sizeof(glm::vec3)); checkCUDAErrorWithLine("hipMalloc dev_vel failed!"); hipMalloc((void**)&dev_acc, N * sizeof(glm::vec3)); checkCUDAErrorWithLine("hipMalloc dev_acc failed!"); hipLaunchKernelGGL(( kernGenerateRandomPosArray), dim3(fullBlocksPerGrid), dim3(blockSize), 0, 0, 1, numObjects, dev_pos, scene_scale, planetMass); checkCUDAErrorWithLine("kernGenerateRandomPosArray failed!"); hipLaunchKernelGGL(( kernGenerateCircularVelArray), dim3(fullBlocksPerGrid), dim3(blockSize), 0, 0, 2, numObjects, dev_vel, dev_pos); checkCUDAErrorWithLine("kernGenerateCircularVelArray failed!"); hipDeviceSynchronize(); } /****************** * copyPlanetsToVBO * ******************/ /** * Copy the planet positions into the VBO so that they can be drawn by OpenGL. */ __global__ void kernCopyPlanetsToVBO(int N, glm::vec3 *pos, float *vbo, float s_scale) { int index = threadIdx.x + (blockIdx.x * blockDim.x); float c_scale = -1.0f / s_scale; if (index < N) { vbo[4 * index + 0] = pos[index].x * c_scale; vbo[4 * index + 1] = pos[index].y * c_scale; vbo[4 * index + 2] = pos[index].z * c_scale; vbo[4 * index + 3] = 1; } } /** * Wrapper for call to the kernCopyPlanetsToVBO CUDA kernel. */ void Nbody::copyPlanetsToVBO(float *vbodptr) { dim3 fullBlocksPerGrid((int)ceil(float(numObjects) / float(blockSize))); hipLaunchKernelGGL(( kernCopyPlanetsToVBO), dim3(fullBlocksPerGrid), dim3(blockSize), 0, 0, numObjects, dev_pos, vbodptr, scene_scale); checkCUDAErrorWithLine("copyPlanetsToVBO failed!"); hipDeviceSynchronize(); } /****************** * stepSimulation * ******************/ /** * Compute the acceleration on the body with index `iSelf` due to the `N` * bodies in the array `pos`. */ __device__ glm::vec3 accelerate(int N, int iSelf, const glm::vec3 *pos) { // TODO: Compute the acceleration on `my_pos` due to: // * The star at the origin (with mass `starMass`) // * All of the *other* planets (with mass `planetMass`) // Return the sum of all of these contributions. const glm::vec3 my_pos = pos[iSelf]; glm::vec3 acc(0, 0, 0); for (int i = 0; i < N; i++) if (i != iSelf){ glm::vec3 dp = pos[i] - my_pos; float rad = 1.0 / (glm::length(dp) + EPSILON); acc += planetMass * G * rad * rad * rad * dp; } float rad = 1.0 / (glm::length(my_pos) + EPSILON); acc -= starMass * G * rad * rad * rad * my_pos; // HINT: You may want to write a helper function that will compute the acceleration at // a single point due to a single other mass. Be careful that you protect against // division by very small numbers. // HINT: Use Newtonian gravitational acceleration: // G M // g = ----- // r^2 // where: // * G is the universal gravitational constant (already defined for you) // * M is the mass of the other object // * r is the distance between this object and the other object return acc; } /** * For each of the `N` bodies, update its acceleration. * Compute the total instantaneous acceleration using `accelerate`, then store that into `acc`. */ __global__ void kernUpdateAcc(int N, float dt, const glm::vec3 *pos, glm::vec3 *acc) { // TODO: implement kernUpdateAcc. // This function body runs once on each CUDA thread. // To avoid race conditions, each instance should only write ONE value to `acc`! unsigned int idx = blockIdx.x*blockDim.x + threadIdx.x; if (idx < N) acc[idx] = accelerate(N, idx, pos); } /** * For each of the `N` bodies, update its velocity, then update its position, using a * simple Euler integration scheme. Acceleration must be updated before calling this kernel. */ __global__ void kernUpdateVelPos(int N, float dt, glm::vec3 *pos, glm::vec3 *vel, const glm::vec3 *acc) { // TODO: implement kernUpdateVelPos. unsigned int idx = blockIdx.x*blockDim.x + threadIdx.x; if (idx < N){ vel[idx] += acc[idx] * dt; pos[idx] += vel[idx] * dt; } } /** * Step the entire N-body simulation by `dt` seconds. */ void Nbody::stepSimulation(float dt) { // TODO: Using the CUDA kernels you wrote above, write a function that // calls the kernels to perform a full simulation step. dim3 fullBlocksPerGrid((int)ceil(float(numObjects) / float(blockSize))); kernUpdateAcc << <fullBlocksPerGrid, threadsPerBlock >> >(numObjects, dt, dev_pos, dev_acc); kernUpdateVelPos << <fullBlocksPerGrid, threadsPerBlock >> >(numObjects, dt, dev_pos, dev_vel, dev_acc); } void Nbody::endSimulation() { hipFree(dev_acc); hipFree(dev_vel); hipFree(dev_pos); }
9872915ba106f7435979ef314c164fa4953253d5.cu
#define GLM_FORCE_CUDA #include <stdio.h> #include <cuda.h> #include <cmath> #include <glm/glm.hpp> #include "utilityCore.hpp" #include "kernel.h" #define checkCUDAErrorWithLine(msg) checkCUDAError(msg, __LINE__) /** * Check for CUDA errors; print and exit if there was a problem. */ void checkCUDAError(const char *msg, int line = -1) { cudaError_t err = cudaGetLastError(); if (cudaSuccess != err) { if (line >= 0) { fprintf(stderr, "Line %d: ", line); } fprintf(stderr, "Cuda error: %s: %s.\n", msg, cudaGetErrorString(err)); exit(EXIT_FAILURE); } } /***************** * Configuration * *****************/ /*! Block size used for CUDA kernel launch. */ #define blockSize 128 /*! Mass of one "planet." */ #define planetMass 3e8f /*! Mass of the "star" at the center. */ #define starMass 5e10f /*! Size of the starting area in simulation space. */ const float scene_scale = 1e2; /*********************************************** * Kernel state (pointers are device pointers) * ***********************************************/ int numObjects; dim3 threadsPerBlock(blockSize); glm::vec3 *dev_pos; glm::vec3 *dev_vel; glm::vec3 *dev_acc; /****************** * initSimulation * ******************/ __host__ __device__ unsigned int hash(unsigned int a) { a = (a + 0x7ed55d16) + (a << 12); a = (a ^ 0xc761c23c) ^ (a >> 19); a = (a + 0x165667b1) + (a << 5); a = (a + 0xd3a2646c) ^ (a << 9); a = (a + 0xfd7046c5) + (a << 3); a = (a ^ 0xb55a4f09) ^ (a >> 16); return a; } /** * Function for generating a random vec3. */ __host__ __device__ glm::vec3 generateRandomVec3(float time, int index) { thrust::default_random_engine rng(hash((int)(index * time))); thrust::uniform_real_distribution<float> unitDistrib(-1, 1); return glm::vec3((float)unitDistrib(rng), (float)unitDistrib(rng), (float)unitDistrib(rng)); } /** * CUDA kernel for generating planets with a specified mass randomly around the star. */ __global__ void kernGenerateRandomPosArray(int time, int N, glm::vec3 * arr, float scale, float mass) { int index = (blockIdx.x * blockDim.x) + threadIdx.x; if (index < N) { glm::vec3 rand = generateRandomVec3(time, index); arr[index].x = scale * rand.x; arr[index].y = scale * rand.y; arr[index].z = 0.1 * scale * sqrt(rand.x * rand.x + rand.y * rand.y) * rand.z; } } /** * CUDA kernel for generating velocities in a vortex around the origin. * This is just to make for an interesting-looking scene. */ __global__ void kernGenerateCircularVelArray(int time, int N, glm::vec3 * arr, glm::vec3 * pos) { int index = (blockIdx.x * blockDim.x) + threadIdx.x; if (index < N) { glm::vec3 R = glm::vec3(pos[index].x, pos[index].y, pos[index].z); float r = glm::length(R) + EPSILON; float s = sqrt(G * starMass / r); glm::vec3 D = glm::normalize(glm::cross(R / r, glm::vec3(0, 0, 1))); arr[index].x = s * D.x; arr[index].y = s * D.y; arr[index].z = s * D.z; } } /** * Initialize memory, update some globals */ void Nbody::initSimulation(int N) { numObjects = N; dim3 fullBlocksPerGrid((N + blockSize - 1) / blockSize); cudaMalloc((void**)&dev_pos, N * sizeof(glm::vec3)); checkCUDAErrorWithLine("cudaMalloc dev_pos failed!"); cudaMalloc((void**)&dev_vel, N * sizeof(glm::vec3)); checkCUDAErrorWithLine("cudaMalloc dev_vel failed!"); cudaMalloc((void**)&dev_acc, N * sizeof(glm::vec3)); checkCUDAErrorWithLine("cudaMalloc dev_acc failed!"); kernGenerateRandomPosArray<<<fullBlocksPerGrid, blockSize>>>(1, numObjects, dev_pos, scene_scale, planetMass); checkCUDAErrorWithLine("kernGenerateRandomPosArray failed!"); kernGenerateCircularVelArray<<<fullBlocksPerGrid, blockSize>>>(2, numObjects, dev_vel, dev_pos); checkCUDAErrorWithLine("kernGenerateCircularVelArray failed!"); cudaThreadSynchronize(); } /****************** * copyPlanetsToVBO * ******************/ /** * Copy the planet positions into the VBO so that they can be drawn by OpenGL. */ __global__ void kernCopyPlanetsToVBO(int N, glm::vec3 *pos, float *vbo, float s_scale) { int index = threadIdx.x + (blockIdx.x * blockDim.x); float c_scale = -1.0f / s_scale; if (index < N) { vbo[4 * index + 0] = pos[index].x * c_scale; vbo[4 * index + 1] = pos[index].y * c_scale; vbo[4 * index + 2] = pos[index].z * c_scale; vbo[4 * index + 3] = 1; } } /** * Wrapper for call to the kernCopyPlanetsToVBO CUDA kernel. */ void Nbody::copyPlanetsToVBO(float *vbodptr) { dim3 fullBlocksPerGrid((int)ceil(float(numObjects) / float(blockSize))); kernCopyPlanetsToVBO<<<fullBlocksPerGrid, blockSize>>>(numObjects, dev_pos, vbodptr, scene_scale); checkCUDAErrorWithLine("copyPlanetsToVBO failed!"); cudaThreadSynchronize(); } /****************** * stepSimulation * ******************/ /** * Compute the acceleration on the body with index `iSelf` due to the `N` * bodies in the array `pos`. */ __device__ glm::vec3 accelerate(int N, int iSelf, const glm::vec3 *pos) { // TODO: Compute the acceleration on `my_pos` due to: // * The star at the origin (with mass `starMass`) // * All of the *other* planets (with mass `planetMass`) // Return the sum of all of these contributions. const glm::vec3 my_pos = pos[iSelf]; glm::vec3 acc(0, 0, 0); for (int i = 0; i < N; i++) if (i != iSelf){ glm::vec3 dp = pos[i] - my_pos; float rad = 1.0 / (glm::length(dp) + EPSILON); acc += planetMass * G * rad * rad * rad * dp; } float rad = 1.0 / (glm::length(my_pos) + EPSILON); acc -= starMass * G * rad * rad * rad * my_pos; // HINT: You may want to write a helper function that will compute the acceleration at // a single point due to a single other mass. Be careful that you protect against // division by very small numbers. // HINT: Use Newtonian gravitational acceleration: // G M // g = ----- // r^2 // where: // * G is the universal gravitational constant (already defined for you) // * M is the mass of the other object // * r is the distance between this object and the other object return acc; } /** * For each of the `N` bodies, update its acceleration. * Compute the total instantaneous acceleration using `accelerate`, then store that into `acc`. */ __global__ void kernUpdateAcc(int N, float dt, const glm::vec3 *pos, glm::vec3 *acc) { // TODO: implement kernUpdateAcc. // This function body runs once on each CUDA thread. // To avoid race conditions, each instance should only write ONE value to `acc`! unsigned int idx = blockIdx.x*blockDim.x + threadIdx.x; if (idx < N) acc[idx] = accelerate(N, idx, pos); } /** * For each of the `N` bodies, update its velocity, then update its position, using a * simple Euler integration scheme. Acceleration must be updated before calling this kernel. */ __global__ void kernUpdateVelPos(int N, float dt, glm::vec3 *pos, glm::vec3 *vel, const glm::vec3 *acc) { // TODO: implement kernUpdateVelPos. unsigned int idx = blockIdx.x*blockDim.x + threadIdx.x; if (idx < N){ vel[idx] += acc[idx] * dt; pos[idx] += vel[idx] * dt; } } /** * Step the entire N-body simulation by `dt` seconds. */ void Nbody::stepSimulation(float dt) { // TODO: Using the CUDA kernels you wrote above, write a function that // calls the kernels to perform a full simulation step. dim3 fullBlocksPerGrid((int)ceil(float(numObjects) / float(blockSize))); kernUpdateAcc << <fullBlocksPerGrid, threadsPerBlock >> >(numObjects, dt, dev_pos, dev_acc); kernUpdateVelPos << <fullBlocksPerGrid, threadsPerBlock >> >(numObjects, dt, dev_pos, dev_vel, dev_acc); } void Nbody::endSimulation() { cudaFree(dev_acc); cudaFree(dev_vel); cudaFree(dev_pos); }
75be3a1121697cb51fe60fb4be1a1296f1f490c8.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" // Copyright (c) 2017 Sony Corporation. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include <nbla/cuda/array/cuda_array.hpp> #include <nbla/cuda/common.hpp> #include <nbla/cuda/function/prelu.hpp> #include <nbla/cuda/math.hpp> #include <nbla/cuda/utils/block_reduce.cuh> #include <nbla/singleton_manager.hpp> namespace nbla { template <typename T> __global__ void forward_prelu_kernel(const int size, const T *x, const T *w, T *y) { NBLA_CUDA_KERNEL_LOOP(s, size) { y[s] = (x[s] >= 0) ? x[s] : x[s] * (*w); } } template <typename T> __global__ void forward_prelu_kernel_c(const int size, const int base_shape, const int base_stride, const T *x, const T *w, T *y) { NBLA_CUDA_KERNEL_LOOP(s, size) { const int iw = int(s / base_stride) % base_shape; y[s] = (x[s] >= 0) ? x[s] : x[s] * w[iw]; } } template <typename T, bool accum = true> __global__ void backward_prelu_kernel_input(const int size, const T *dy, const T *x, const T *w, T *dx) { NBLA_CUDA_KERNEL_LOOP(s, size) { dx[s] = (accum ? dx[s] : 0) + ((x[s] >= 0) ? dy[s] : dy[s] * (*w)); } } template <typename T, bool accum = true> __global__ void backward_prelu_kernel_input_c(const int size, const int base_shape, const int base_stride, const T *dy, const T *x, const T *w, T *dx) { NBLA_CUDA_KERNEL_LOOP(s, size) { const int iw = int(s / base_stride) % base_shape; dx[s] = (accum ? dx[s] : 0) + ((x[s] >= 0) ? dy[s] : dy[s] * w[iw]); } } template <typename T> __global__ void backward_prelu_kernel_weights_temp(const int insize, const int outsize, const T *dy, const T *x, T *buff) { NBLA_CUDA_KERNEL_LOOP(s, insize) { buff[s] = dy[s] * x[s] * (x[s] < 0); for (int i = 1; i < outsize; ++i) { buff[s] += dy[s + i * insize] * x[s + i * insize] * (x[s + i * insize] < 0); } } } template <typename T, bool accum> __global__ void kernel_reduce_per_block(const int N, const T *x, T *buff) { T thread_data = 0; NBLA_CUDA_KERNEL_LOOP(i, N) { thread_data += x[i]; } thread_data = blockReduceSum(thread_data); if (threadIdx.x == 0) { buff[blockIdx.x] = (accum ? buff[blockIdx.x] : 0) + thread_data; } } template <typename T> void PReLUCuda<T>::setup_impl(const Variables &inputs, const Variables &outputs) { PReLU<T>::setup_impl(inputs, outputs); } template <typename T> void PReLUCuda<T>::forward_impl(const Variables &inputs, const Variables &outputs) { cuda_set_device(std::stoi(this->ctx_.device_id)); const T *x = inputs[0]->get_data_pointer<T>(this->ctx_); const T *w = inputs[1]->get_data_pointer<T>(this->ctx_); T *y = outputs[0]->cast_data_and_get_pointer<T>(this->ctx_); const int size = inputs[0]->size(); if (inputs[1]->size() == 1) { NBLA_CUDA_LAUNCH_KERNEL_SIMPLE(forward_prelu_kernel, size, x, w, y); return; } NBLA_CUDA_LAUNCH_KERNEL_SIMPLE(forward_prelu_kernel_c, size, this->base_shape_, this->base_stride_, x, w, y); } template <typename T> void PReLUCuda<T>::backward_impl(const Variables &inputs, const Variables &outputs, const vector<bool> &propagate_down, const vector<bool> &accum) { if (!(propagate_down[0] || propagate_down[1])) { return; } cuda_set_device(std::stoi(this->ctx_.device_id)); const T *x = inputs[0]->get_data_pointer<T>(this->ctx_); const T *dy = outputs[0]->get_grad_pointer<T>(this->ctx_); const int size = inputs[0]->size(); if (propagate_down[0]) { const T *w = inputs[1]->get_data_pointer<T>(this->ctx_); T *dx = inputs[0]->cast_grad_and_get_pointer<T>(this->ctx_); if (inputs[1]->size() == 1) { if (accum[0]) { NBLA_CUDA_LAUNCH_KERNEL_SIMPLE((backward_prelu_kernel_input<T, true>), size, dy, x, w, dx); } else { NBLA_CUDA_LAUNCH_KERNEL_SIMPLE((backward_prelu_kernel_input<T, false>), size, dy, x, w, dx); } } else { if (accum[0]) { NBLA_CUDA_LAUNCH_KERNEL_SIMPLE((backward_prelu_kernel_input_c<T, true>), size, this->base_shape_, this->base_stride_, dy, x, w, dx); } else { NBLA_CUDA_LAUNCH_KERNEL_SIMPLE( (backward_prelu_kernel_input_c<T, false>), size, this->base_shape_, this->base_stride_, dy, x, w, dx); } } } if (propagate_down[1]) { T *dw = inputs[1]->cast_grad_and_get_pointer<T>(this->ctx_); const int insize = inputs[0]->size(this->base_axis_); const int outsize = size / insize; const int channels = inputs[1]->size(); // Weight backward consists of two step. // 1) Element-wise backward operation (sample dimensions are reduced). // 2) Reduction to weight vector (or scalar) by using well-tuned cublas // function. shared_ptr<CudaCachedArray> arr_buff( new CudaCachedArray(insize, get_dtype<T>(), this->ctx_)); T *buff = arr_buff->pointer<T>(); NBLA_CUDA_LAUNCH_KERNEL_SIMPLE(backward_prelu_kernel_weights_temp, insize, outsize, dy, x, buff); if (channels == 1) { shared_ptr<CudaCachedArray> arr_buff2; T *buff2 = buff; int blocks = insize; if (insize >= 1024) { blocks = min(NBLA_CUDA_GET_BLOCKS(insize), /*max blocks*/ 1024); arr_buff2 = make_shared<CudaCachedArray>(blocks, get_dtype<T>(), this->ctx_); buff2 = arr_buff2->pointer<T>(); hipLaunchKernelGGL(( kernel_reduce_per_block<T, false>), dim3(blocks), dim3(NBLA_CUDA_NUM_THREADS), 0, 0, insize, buff, buff2); } if (accum[1]) { hipLaunchKernelGGL(( kernel_reduce_per_block<T, true>), dim3(1), dim3(1024), 0, 0, blocks, buff, dw); } else { hipLaunchKernelGGL(( kernel_reduce_per_block<T, false>), dim3(1), dim3(1024), 0, 0, blocks, buff, dw); } } else { const int spatial_size = insize / channels; const T *ones = static_cast<const T *>(SingletonManager::get<NNabla>()->ones( spatial_size, get_dtype<T>(), this->ctx_)); cuda_gemv(this->device_, dw, buff, spatial_size, channels, true, ones, spatial_size, (T)1, (T)(accum[1] ? 1 : 0)); } } } // template instantiation template class PReLUCuda<float>; }
75be3a1121697cb51fe60fb4be1a1296f1f490c8.cu
// Copyright (c) 2017 Sony Corporation. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include <nbla/cuda/array/cuda_array.hpp> #include <nbla/cuda/common.hpp> #include <nbla/cuda/function/prelu.hpp> #include <nbla/cuda/math.hpp> #include <nbla/cuda/utils/block_reduce.cuh> #include <nbla/singleton_manager.hpp> namespace nbla { template <typename T> __global__ void forward_prelu_kernel(const int size, const T *x, const T *w, T *y) { NBLA_CUDA_KERNEL_LOOP(s, size) { y[s] = (x[s] >= 0) ? x[s] : x[s] * (*w); } } template <typename T> __global__ void forward_prelu_kernel_c(const int size, const int base_shape, const int base_stride, const T *x, const T *w, T *y) { NBLA_CUDA_KERNEL_LOOP(s, size) { const int iw = int(s / base_stride) % base_shape; y[s] = (x[s] >= 0) ? x[s] : x[s] * w[iw]; } } template <typename T, bool accum = true> __global__ void backward_prelu_kernel_input(const int size, const T *dy, const T *x, const T *w, T *dx) { NBLA_CUDA_KERNEL_LOOP(s, size) { dx[s] = (accum ? dx[s] : 0) + ((x[s] >= 0) ? dy[s] : dy[s] * (*w)); } } template <typename T, bool accum = true> __global__ void backward_prelu_kernel_input_c(const int size, const int base_shape, const int base_stride, const T *dy, const T *x, const T *w, T *dx) { NBLA_CUDA_KERNEL_LOOP(s, size) { const int iw = int(s / base_stride) % base_shape; dx[s] = (accum ? dx[s] : 0) + ((x[s] >= 0) ? dy[s] : dy[s] * w[iw]); } } template <typename T> __global__ void backward_prelu_kernel_weights_temp(const int insize, const int outsize, const T *dy, const T *x, T *buff) { NBLA_CUDA_KERNEL_LOOP(s, insize) { buff[s] = dy[s] * x[s] * (x[s] < 0); for (int i = 1; i < outsize; ++i) { buff[s] += dy[s + i * insize] * x[s + i * insize] * (x[s + i * insize] < 0); } } } template <typename T, bool accum> __global__ void kernel_reduce_per_block(const int N, const T *x, T *buff) { T thread_data = 0; NBLA_CUDA_KERNEL_LOOP(i, N) { thread_data += x[i]; } thread_data = blockReduceSum(thread_data); if (threadIdx.x == 0) { buff[blockIdx.x] = (accum ? buff[blockIdx.x] : 0) + thread_data; } } template <typename T> void PReLUCuda<T>::setup_impl(const Variables &inputs, const Variables &outputs) { PReLU<T>::setup_impl(inputs, outputs); } template <typename T> void PReLUCuda<T>::forward_impl(const Variables &inputs, const Variables &outputs) { cuda_set_device(std::stoi(this->ctx_.device_id)); const T *x = inputs[0]->get_data_pointer<T>(this->ctx_); const T *w = inputs[1]->get_data_pointer<T>(this->ctx_); T *y = outputs[0]->cast_data_and_get_pointer<T>(this->ctx_); const int size = inputs[0]->size(); if (inputs[1]->size() == 1) { NBLA_CUDA_LAUNCH_KERNEL_SIMPLE(forward_prelu_kernel, size, x, w, y); return; } NBLA_CUDA_LAUNCH_KERNEL_SIMPLE(forward_prelu_kernel_c, size, this->base_shape_, this->base_stride_, x, w, y); } template <typename T> void PReLUCuda<T>::backward_impl(const Variables &inputs, const Variables &outputs, const vector<bool> &propagate_down, const vector<bool> &accum) { if (!(propagate_down[0] || propagate_down[1])) { return; } cuda_set_device(std::stoi(this->ctx_.device_id)); const T *x = inputs[0]->get_data_pointer<T>(this->ctx_); const T *dy = outputs[0]->get_grad_pointer<T>(this->ctx_); const int size = inputs[0]->size(); if (propagate_down[0]) { const T *w = inputs[1]->get_data_pointer<T>(this->ctx_); T *dx = inputs[0]->cast_grad_and_get_pointer<T>(this->ctx_); if (inputs[1]->size() == 1) { if (accum[0]) { NBLA_CUDA_LAUNCH_KERNEL_SIMPLE((backward_prelu_kernel_input<T, true>), size, dy, x, w, dx); } else { NBLA_CUDA_LAUNCH_KERNEL_SIMPLE((backward_prelu_kernel_input<T, false>), size, dy, x, w, dx); } } else { if (accum[0]) { NBLA_CUDA_LAUNCH_KERNEL_SIMPLE((backward_prelu_kernel_input_c<T, true>), size, this->base_shape_, this->base_stride_, dy, x, w, dx); } else { NBLA_CUDA_LAUNCH_KERNEL_SIMPLE( (backward_prelu_kernel_input_c<T, false>), size, this->base_shape_, this->base_stride_, dy, x, w, dx); } } } if (propagate_down[1]) { T *dw = inputs[1]->cast_grad_and_get_pointer<T>(this->ctx_); const int insize = inputs[0]->size(this->base_axis_); const int outsize = size / insize; const int channels = inputs[1]->size(); // Weight backward consists of two step. // 1) Element-wise backward operation (sample dimensions are reduced). // 2) Reduction to weight vector (or scalar) by using well-tuned cublas // function. shared_ptr<CudaCachedArray> arr_buff( new CudaCachedArray(insize, get_dtype<T>(), this->ctx_)); T *buff = arr_buff->pointer<T>(); NBLA_CUDA_LAUNCH_KERNEL_SIMPLE(backward_prelu_kernel_weights_temp, insize, outsize, dy, x, buff); if (channels == 1) { shared_ptr<CudaCachedArray> arr_buff2; T *buff2 = buff; int blocks = insize; if (insize >= 1024) { blocks = min(NBLA_CUDA_GET_BLOCKS(insize), /*max blocks*/ 1024); arr_buff2 = make_shared<CudaCachedArray>(blocks, get_dtype<T>(), this->ctx_); buff2 = arr_buff2->pointer<T>(); kernel_reduce_per_block<T, false><<<blocks, NBLA_CUDA_NUM_THREADS>>>( insize, buff, buff2); } if (accum[1]) { kernel_reduce_per_block<T, true><<<1, 1024>>>(blocks, buff, dw); } else { kernel_reduce_per_block<T, false><<<1, 1024>>>(blocks, buff, dw); } } else { const int spatial_size = insize / channels; const T *ones = static_cast<const T *>(SingletonManager::get<NNabla>()->ones( spatial_size, get_dtype<T>(), this->ctx_)); cuda_gemv(this->device_, dw, buff, spatial_size, channels, true, ones, spatial_size, (T)1, (T)(accum[1] ? 1 : 0)); } } } // template instantiation template class PReLUCuda<float>; }
f6d34c1add23b535361ba6ebf458f8dbbb110dcb.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include <stdio.h> #include <helper_cuda.h> __global__ void hello(); int main(int argc, char const *argv[]) { hipLaunchKernelGGL(( hello), dim3(100), dim3(100), 0, 0, ); // checkCudaErrors(hipDeviceSynchronize()); hipDeviceSynchronize(); return 0; } __global__ void hello() { if (blockIdx.x*blockDim.x+threadIdx.x == 100) { int* a = (int*) 0x10000; *a = 0; } printf("Hello! I'm thread %d out of %d in block %d. My global thread is " "%d out of %d.\n", threadIdx.x, blockDim.x, blockIdx.x, blockIdx.x*blockDim.x+threadIdx.x, gridDim.x*blockDim.x); }
f6d34c1add23b535361ba6ebf458f8dbbb110dcb.cu
#include <stdio.h> #include <helper_cuda.h> __global__ void hello(); int main(int argc, char const *argv[]) { hello<<<100, 100>>>(); // checkCudaErrors(cudaDeviceSynchronize()); cudaDeviceSynchronize(); return 0; } __global__ void hello() { if (blockIdx.x*blockDim.x+threadIdx.x == 100) { int* a = (int*) 0x10000; *a = 0; } printf("Hello! I'm thread %d out of %d in block %d. My global thread is " "%d out of %d.\n", threadIdx.x, blockDim.x, blockIdx.x, blockIdx.x*blockDim.x+threadIdx.x, gridDim.x*blockDim.x); }
55de1c15691c7b79fc2ba5574ee5eb53df82230c.hip
// !!! This is a file automatically generated by hipify!!! #include "caffe/layers/base_data_layer.hpp" #include "caffe/layers/suncg_data_layer.hpp" #include "caffe/util/rng.hpp" #include "suncg_fusion.hpp" #include "suncg_util.hpp" #include <vector> #include <utility> DEFINE_bool(shuran_chatter, false, "If you are Shuran and want chatter, turn this on."); namespace caffe{ template<typename Dtype> SuncgDataLayer<Dtype>::~SuncgDataLayer<Dtype>() { this->StopInternalThread(); } template<typename Dtype> void SuncgDataLayer<Dtype>::DataLayerSetUp(const vector<Blob<Dtype> *> &bottom, const vector<Blob<Dtype> *> &top) { LOG(INFO) << "Read SUNCG parameters"; const SuncgDataParameter& data_param = this->layer_param_.suncg_data_param(); for (int i = 0; i < data_param.file_data_size(); ++i) { file_data.push_back(data_param.file_data(i)); } file_list = data_param.file_list(); vox_unit = data_param.vox_unit(); vox_margin = data_param.vox_margin(); add_height = data_param.with_height(); for (int i = 0; i < data_param.seg_class_map_size(); ++i) { segmentation_class_map.push_back(data_param.seg_class_map(i)); } num_segmentation_class = *std::max_element(segmentation_class_map.begin(), segmentation_class_map.end()) + 1; LOG(INFO) << "num_segmentation_class: " << num_segmentation_class; for (int i = 0; i < data_param.seg_class_weight_size(); ++i) { segmentation_class_weight.push_back(data_param.seg_class_weight(i)); } for (int i = 0; i < data_param.occ_class_weight_size(); ++i) { occupancy_class_weight.push_back(data_param.occ_class_weight(i)); } shuffle_data = data_param.shuffle(); occ_emptyonly = data_param.occ_empty_only(); data_num_channel = add_height ? 2 : 1; surf_only = data_param.surf_only(); CHECK_EQ(data_param.vox_size_size(), 3); CHECK_EQ(data_param.crop_size_size(), 3); for (int i = 0; i < data_param.vox_size_size(); ++i) { data_full_vox_size.push_back(data_param.vox_size(i)); } for (int i = 0; i < data_param.crop_size_size(); ++i) { data_crop_vox_size.push_back(data_param.crop_size(i));; } for (int i = 0; i < data_param.label_size_size(); ++i) { label_vox_size.push_back(data_param.label_size(i)); } sample_neg_obj_ratio = data_param.neg_obj_sample_ratio(); batch_size = data_param.batch_size(); offset_value = 0; epoch_prefetch = 0; counter = 0; // List all files in data folder and shuffle them if necessary GetFiles(file_data, data_filenames, "camera_list_train.list", "0000.png"); if (shuffle_data) { const unsigned int rng_seed = caffe_rng_rand(); rng_.reset(new Caffe::RNG(rng_seed)); Shuffle(); } LOG(INFO) << "Read camera information"; // Copy camera information to GPU cam_info[0] = Dtype(frame_width); cam_info[1] = Dtype(frame_height); for (int i = 0; i < 9; ++i) cam_info[i + 2] = cam_K[i]; for (int i = 0; i < 16; ++i) cam_info[i + 11] = 0.0f; CUDA_CHECK(hipMalloc(&cam_info_GPU, 27 * sizeof(Dtype))); LOG(INFO) << "Set voxel volume parameters and copy them to GPU"; vox_info[0] = vox_unit; vox_info[1] = vox_margin; for (int i = 0; i < 3; ++i) vox_info[i + 2] = Dtype(data_crop_vox_size[i]); CUDA_CHECK(hipMalloc(&vox_info_GPU, 8 * sizeof(Dtype))); LOG(INFO) << "Allocating data"; LOG(INFO) << "data_num_channel: " << data_num_channel; // GPU malloc depth data CUDA_CHECK(hipMalloc(&depth_data_GPU, frame_height * frame_width * sizeof(Dtype))); // GPU malloc voxel volume weights CUDA_CHECK(hipMalloc(&vox_weight_GPU, data_crop_vox_size[0] * data_crop_vox_size[1] * data_crop_vox_size[2] * sizeof(Dtype))); size_t memoryBytes = 0; // std::cout << (train_me ? "* " : " "); // std::cout << name << std::endl; // Determine if data should be cropped is_cropping_data = data_crop_vox_size[0] < data_full_vox_size[0] || data_crop_vox_size[1] < data_full_vox_size[1] || data_crop_vox_size[2] < data_full_vox_size[2]; int num_crop_voxels = data_crop_vox_size[0] * data_crop_vox_size[1] * data_crop_vox_size[2]; int num_full_voxels = data_full_vox_size[0] * data_full_vox_size[1] * data_full_vox_size[2]; if (is_cropping_data) { CUDA_CHECK(hipMalloc(&vox_data_GPU, batch_size * data_num_channel * num_crop_voxels * sizeof(Dtype))); memoryBytes += batch_size * data_num_channel * num_crop_voxels * sizeof(Dtype); } else { CUDA_CHECK(hipMalloc(&vox_data_GPU, batch_size * data_num_channel * num_full_voxels * sizeof(Dtype))); memoryBytes += batch_size * data_num_channel * num_full_voxels * sizeof(Dtype); } int num_label_voxels = label_vox_size[0] * label_vox_size[1] * label_vox_size[2]; CUDA_CHECK(hipMalloc(&occupancy_label_GPU, batch_size * num_label_voxels * sizeof(Dtype))); CUDA_CHECK(hipMalloc(&occupancy_weight_GPU, batch_size * 2 * num_label_voxels * sizeof(Dtype))); memoryBytes += batch_size * 3 * num_label_voxels * sizeof(Dtype); CUDA_CHECK(hipMalloc(&segmentation_label_GPU, batch_size * num_label_voxels * sizeof(Dtype))); CUDA_CHECK(hipMalloc(&segmentation_weight_GPU, batch_size * num_segmentation_class * num_label_voxels * sizeof(Dtype))); CUDA_CHECK(hipMalloc(&segmentation_surf_weight_GPU, batch_size * num_segmentation_class * num_label_voxels * sizeof(Dtype))); memoryBytes += batch_size * (num_segmentation_class + 1) * num_label_voxels * sizeof(Dtype); LOG(INFO) << "Resize tops"; // out[0]->need_diff = false; std::vector<int> data_dim; data_dim.resize(5); data_dim[0] = batch_size; data_dim[1] = data_num_channel; if (is_cropping_data) { data_dim[2] = data_crop_vox_size[0]; data_dim[3] = data_crop_vox_size[1]; data_dim[4] = data_crop_vox_size[2]; } else { data_dim[2] = data_full_vox_size[0]; data_dim[3] = data_full_vox_size[1]; data_dim[4] = data_full_vox_size[2]; } top[0]->Reshape(data_dim); for (int i = 0; i < this->PREFETCH_COUNT; ++i) { this->prefetch_[i].Resize(5); this->prefetch_[i].mutable_blob(0)->Reshape(data_dim); } data_dim[1] = 1; data_dim[2] = label_vox_size[0]; data_dim[3] = label_vox_size[1]; data_dim[4] = label_vox_size[2]; for (int i = 1; i < top.size(); ++i) { top[i]->Reshape(data_dim); for (int j = 0; j < this->PREFETCH_COUNT; ++j) { this->prefetch_[j].mutable_blob(i)->Reshape(data_dim); } } // if (top.size() > 5) { // data_dim[2] = 480; // data_dim[3] = 640; // data_dim[4] = 1; // top[5]->Reshape(data_dim); // for (int j = 0; j < this->PREFETCH_COUNT; ++j) { // this->prefetch_[j].mutable_blob(5)->Reshape(data_dim); // } // } // // out[0]->receptive_field.resize(data_dim.size() - 2); fill_n(out[0]->receptive_field.begin(), data_dim.size() - 2, 1); // out[0]->receptive_gap.resize(data_dim.size() - 2); fill_n(out[0]->receptive_gap.begin(), data_dim.size() - 2, 1); // out[0]->receptive_offset.resize(data_dim.size() - 2); fill_n(out[0]->receptive_offset.begin(), data_dim.size() - 2, 0); // memoryBytes += out[0]->Malloc(data_dim); // // // Occupancy label // out[1]->need_diff = false; // data_dim[1] = 1; // data_dim[2] = label_vox_size[0]; // data_dim[3] = label_vox_size[1]; // data_dim[4] = label_vox_size[2]; // memoryBytes += out[1]->Malloc(data_dim); // // // Occupancy weight // out[2]->need_diff = false; // data_dim[1] = 2; // memoryBytes += out[2]->Malloc(data_dim); // // // Segmentation label // out[3]->need_diff = false; // data_dim[1] = 1; // memoryBytes += out[3]->Malloc(data_dim); // // // Segmentation weight // out[4]->need_diff = false; // data_dim[1] = num_segmentation_class; // memoryBytes += out[4]->Malloc(data_dim); // // // Segmentation surface weight // out[5]->need_diff = false; // memoryBytes += out[5]->Malloc(data_dim); // // // prefetch(); // lock = std::async(std::launch::async, &SUNCGDataLayer::prefetch, this); // return memoryBytes; } template<typename Dtype> void SuncgDataLayer<Dtype>::load_batch(Batch<Dtype> *batch) { // LOG(INFO) << "Loading " << batch; const SuncgDataParameter& data_param = this->layer_param_.suncg_data_param(); Blob<Dtype> *tsdf = nullptr, *occ_label = nullptr, *occ_weight = nullptr; if (batch->size() > 3) { occ_label = batch->mutable_blob(3); occ_weight = batch->mutable_blob(4); } // if (data_param.data_type() == SuncgDataParameter_DATA_TSDF) { // tsdf = batch->mutable_blob(0); // } else if(data_param.data_type() == SuncgDataParameter_DATA_OCCUPANCY) { // occ_label = batch->mutable_blob(0); // } tsdf = batch->mutable_blob(0); Blob<Dtype> *seg_label = batch->mutable_blob(1); Blob<Dtype> *seg_weight = batch->mutable_blob(2); for (size_t batch_idx = 0; batch_idx < batch_size; ++batch_idx) { // Get random image bool is_valid_image = false; std::string depth_path = ""; while (!is_valid_image) { depth_path = data_filenames[counter]; is_valid_image = FileExists(depth_path.substr(0, depth_path.length() - 3) + "bin") && FileExists(depth_path); // increase counter counter++; if (counter >= data_filenames.size()) { counter = 0; ++epoch_prefetch; if (shuffle_data) Shuffle(); } } // Get depth image and copy to GPU Dtype *depth_data = new Dtype[frame_height * frame_width]; ReadDepthImage(depth_path, depth_data, frame_width, frame_height); // LOG(INFO) << "Depth data: " << depth_data[frame_width * frame_height / 2]; CUDA_CHECK(hipMemcpy(depth_data_GPU, depth_data, frame_height * frame_width * sizeof(Dtype), hipMemcpyHostToDevice)); // Get voxel origin (in world coordinates), camera pose, and voxel labels Dtype vox_origin[3]; Dtype cam_pose[16]; int num_crop_voxels = data_crop_vox_size[0] * data_crop_vox_size[1] * data_crop_vox_size[2]; int num_full_voxels = data_full_vox_size[0] * data_full_vox_size[1] * data_full_vox_size[2]; Dtype *occupancy_label_full = new Dtype[num_full_voxels]; Dtype *segmentation_label_full = new Dtype[num_full_voxels]; ReadVoxLabel(depth_path.substr(0, depth_path.length() - 3) + "bin", vox_origin, cam_pose, occupancy_label_full, segmentation_class_map, segmentation_label_full); // Find cropping origin int crop_origin[3] = { 0, 0, 0 }; if (is_cropping_data) { bool crop_vox_found = false; int max_iter = 100; int sample_iter = 0; // Crop a random box out of the full volume while (!crop_vox_found && sample_iter < max_iter) { // Compute random cropping origin crop_origin[0] = 0.0f; crop_origin[1] = 0.0f; crop_origin[2] = 0.0f; if (data_full_vox_size[0] - data_crop_vox_size[0] > 0) crop_origin[0] = (int)::floor(GenRandFloat(0.0f, (float)( data_full_vox_size[0] - data_crop_vox_size[0]))); if (data_full_vox_size[1] - data_crop_vox_size[1] > 0) crop_origin[1] = (int)::floor(GenRandFloat(0.0f, (float)( data_full_vox_size[1] - data_crop_vox_size[1]))); if (data_full_vox_size[2] - data_crop_vox_size[2] > 0) crop_origin[2] = (int)::floor(GenRandFloat(0.0f, (float)( data_full_vox_size[2] - data_crop_vox_size[2]))); sample_iter++; // Check cropped box is non-empty and contains object classes other than only floor, wall, ceiling int num_non_empty_voxels = 0; int num_object_voxels = 0; for (int x = crop_origin[0]; x < crop_origin[0] + data_crop_vox_size[0]; ++x) for (int y = crop_origin[1]; y < crop_origin[1] + data_crop_vox_size[1]; ++y) for (int z = crop_origin[2]; z < crop_origin[2] + data_crop_vox_size[2]; ++z) { int full_voxel_idx = z * data_full_vox_size[0] * data_full_vox_size[1] + y * data_full_vox_size[0] + x; if (segmentation_label_full[full_voxel_idx] > 0 & segmentation_label_full[full_voxel_idx] < 255) num_non_empty_voxels++; if (segmentation_label_full[full_voxel_idx] > 3) num_object_voxels++; } if (num_non_empty_voxels < data_crop_vox_size[0] * data_crop_vox_size[0] || num_object_voxels < data_crop_vox_size[0]) continue; crop_vox_found = true; } } if (FLAGS_shuran_chatter) { LOG(INFO) << depth_path << " " << crop_origin[0] << " " << crop_origin[1] << " " << crop_origin[2]; } // Update voxel parameters with new voxel origin (+ cropping origin) in world coordinates vox_info[5] = vox_origin[0] + (float)(crop_origin[2]) * vox_unit; vox_info[6] = vox_origin[1] + (float)(crop_origin[0]) * vox_unit; vox_info[7] = vox_origin[2] + (float)(crop_origin[1]) * vox_unit; // Update camera information with new camera pose for (int i = 0; i < 16; ++i) cam_info[i + 11] = cam_pose[i]; // Update camera information and voxel parameters in GPU CUDA_CHECK(hipMemcpy(cam_info_GPU, cam_info, 27 * sizeof(Dtype), hipMemcpyHostToDevice)); CUDA_CHECK(hipMemcpy(vox_info_GPU, vox_info, 8 * sizeof(Dtype), hipMemcpyHostToDevice)); // Get voxel volume Dtype *tmp_tsdf_data_GPU = vox_data_GPU + batch_idx * num_crop_voxels; GPU_set_value(num_crop_voxels, tmp_tsdf_data_GPU, Dtype(1.0)); Dtype *tmp_vox_height_GPU = NULL; if (add_height) { tmp_vox_height_GPU = vox_data_GPU + batch_idx * data_num_channel * num_crop_voxels + num_crop_voxels; GPU_set_zeros(num_crop_voxels, tmp_vox_height_GPU); } // Reset voxel weights in GPU Dtype *vox_weight_CPU = new Dtype[num_crop_voxels]; memset(vox_weight_CPU, 0, num_crop_voxels * sizeof(Dtype)); CUDA_CHECK(hipMemcpy(vox_weight_GPU, vox_weight_CPU, num_crop_voxels * sizeof(Dtype), hipMemcpyHostToDevice)); // Retreive cropped labels Dtype *occupancy_label_crop = new Dtype[num_crop_voxels]; Dtype *segmentation_label_crop = new Dtype[num_crop_voxels]; for (int x = 0; x < data_crop_vox_size[0]; ++x) for (int y = 0; y < data_crop_vox_size[1]; ++y) for (int z = 0; z < data_crop_vox_size[2]; ++z) { int crop_voxel_idx = z * data_crop_vox_size[0] * data_crop_vox_size[1] + y * data_crop_vox_size[0] + x; int full_voxel_idx = (z + crop_origin[2]) * data_full_vox_size[0] * data_full_vox_size[1] + (y + crop_origin[1]) * data_full_vox_size[0] + (x + crop_origin[0]); occupancy_label_crop[crop_voxel_idx] = occupancy_label_full[full_voxel_idx]; segmentation_label_crop[crop_voxel_idx] = segmentation_label_full[full_voxel_idx]; } // Fuse frame into voxel volume if (data_param.data_type() == SuncgDataParameter_DATA_OCCUPANCY){ Dtype * occupancy_label_crop_GPU; hipMalloc(&occupancy_label_crop_GPU, num_crop_voxels* sizeof(Dtype)); hipMemcpy(occupancy_label_crop_GPU, occupancy_label_crop, num_crop_voxels * sizeof(Dtype), hipMemcpyHostToDevice); int THREADS_NUM = 1024; int BLOCK_NUM = int((num_crop_voxels + size_t(THREADS_NUM) - 1) / THREADS_NUM); CompleteTSDF << < BLOCK_NUM, THREADS_NUM >> >(vox_info_GPU, occupancy_label_crop_GPU, tmp_tsdf_data_GPU); hipFree(occupancy_label_crop_GPU); CUDA_CHECK(hipGetLastError()); } else{ if (data_param.with_projection_tsdf()){ int num_blocks = data_crop_vox_size[2]; int num_threads = data_crop_vox_size[1]; GPU_set_zeros(num_crop_voxels, vox_weight_GPU); Integrate << < data_crop_vox_size[2], data_crop_vox_size[1] >> > (cam_info_GPU, vox_info_GPU, depth_data_GPU, tmp_tsdf_data_GPU, vox_weight_GPU, tmp_vox_height_GPU); CUDA_CHECK(hipGetLastError()); } else{ ComputeTSDF(cam_info, vox_info, cam_info_GPU, vox_info_GPU, depth_data_GPU, tmp_tsdf_data_GPU, tmp_vox_height_GPU); CUDA_CHECK(hipGetLastError()); } } // Copy voxel volume back to CPU Dtype *vox_tsdf = new Dtype[num_crop_voxels]; CUDA_CHECK(hipMemcpy(vox_tsdf, tmp_tsdf_data_GPU, num_crop_voxels * sizeof(Dtype), hipMemcpyDeviceToHost)); if (tsdf != nullptr) { memcpy(tsdf->mutable_cpu_data() + num_crop_voxels * batch_idx * data_num_channel, vox_tsdf, num_crop_voxels * sizeof(Dtype)); } //adding height to floor if (add_height){ hipMemcpy(tsdf->mutable_cpu_data() + num_crop_voxels * batch_idx * data_num_channel + num_crop_voxels, tmp_vox_height_GPU, num_crop_voxels * sizeof(Dtype), hipMemcpyDeviceToHost); } // Downsample label with scale int num_label_voxels = label_vox_size[0] * label_vox_size[1] * label_vox_size[2]; int label_downscale = (data_crop_vox_size[0] / label_vox_size[0]); Dtype *occupancy_label_downscale = new Dtype[num_label_voxels]; Dtype *segmentation_label_downscale = new Dtype[num_label_voxels]; Dtype *tsdf_data_downscale = new Dtype[num_label_voxels]; if (label_downscale > 1){ DownsampleLabel(data_crop_vox_size, label_vox_size, label_downscale, occupancy_label_crop, occupancy_label_downscale, segmentation_label_crop, segmentation_label_downscale, vox_tsdf, tsdf_data_downscale); } else{ if (FLAGS_shuran_chatter) { LOG(INFO) << "label_downscale: " << label_downscale; } memcpy(occupancy_label_downscale, occupancy_label_crop, num_label_voxels * sizeof(Dtype)); memcpy(segmentation_label_downscale, segmentation_label_crop, num_label_voxels * sizeof(Dtype)); memcpy(tsdf_data_downscale, vox_tsdf, num_label_voxels * sizeof(Dtype)); } // Copy labels to GPU // CUDA_CHECK( // hipMemcpy(occupancy_label_GPU + batch_idx * num_label_voxels, // occupancy_label_downscale, // num_label_voxels * sizeof(Dtype), // hipMemcpyHostToDevice)); // CUDA_CHECK( // hipMemcpy(segmentation_label_GPU + batch_idx * num_label_voxels, // segmentation_label_downscale, // num_label_voxels * sizeof(Dtype), // hipMemcpyHostToDevice)); if (occ_label != nullptr) { memcpy(occ_label->mutable_cpu_data() + batch_idx * num_label_voxels, occupancy_label_downscale, num_label_voxels * sizeof(Dtype)); } memcpy(seg_label->mutable_cpu_data() + batch_idx * num_label_voxels, segmentation_label_downscale, num_label_voxels * sizeof(Dtype)); // Find number of occupied voxels // Save voxel indices of background // Set label weights of occupied voxels as 1 int num_occ_voxels = 0; std::vector<int> bg_voxel_idx; Dtype *occupancy_weight = new Dtype[num_label_voxels]; Dtype *segmentation_weight = new Dtype[num_label_voxels]; //Dtype *segmentation_surf_weight = new Dtype[num_label_voxels]; memset(occupancy_weight, 0, num_label_voxels * sizeof(Dtype)); memset(segmentation_weight, 0, num_label_voxels * sizeof(Dtype)); //memset(segmentation_surf_weight, 0, num_label_voxels * sizeof(Dtype)); for (int i = 0; i < num_label_voxels; ++i) { if (Dtype(occupancy_label_downscale[i]) > 0) { if (tsdf_data_downscale[i] < -0.5) { // forground voxels in unobserved region num_occ_voxels++; occupancy_weight[i] = Dtype(occupancy_class_weight[1]); } } else { if (tsdf_data_downscale[i] < -0.5) { bg_voxel_idx.push_back(i); // background voxels in unobserved regoin } } if (Dtype(segmentation_label_downscale[i]) > 0 && Dtype(segmentation_label_downscale[i]) < 255) { // foreground voxels within room if (surf_only){ if (abs(tsdf_data_downscale[i]) < 0.5){ segmentation_weight[i] = Dtype(segmentation_class_weight[(int)segmentation_label_downscale[i]]); } } else{ segmentation_weight[i] = Dtype(segmentation_class_weight[(int)segmentation_label_downscale[i]]); } // if (abs(tsdf_data_downscale[i]) < 0.5) { // segmentation_surf_weight[i] = Dtype( // segmentation_class_weight[(int) (segmentation_label_downscale[i])]); // } } } // Raise the weight for a few indices of background voxels std::random_device tmp_rand_rd; std::mt19937 tmp_rand_mt(tmp_rand_rd()); int segnegcout = 0; int segnegtotal = floor(sample_neg_obj_ratio * (float)num_occ_voxels); if (bg_voxel_idx.size() > 0) { std::uniform_real_distribution<double> tmp_rand_dist( 0, (float)(bg_voxel_idx.size()) - 0.0001); for (int i = 0; i < num_occ_voxels; ++i) { int rand_idx = (int)(::floor(tmp_rand_dist(tmp_rand_mt))); occupancy_weight[bg_voxel_idx[rand_idx]] = Dtype( occupancy_class_weight[0]); if (segnegcout < segnegtotal && Dtype(segmentation_label_downscale[bg_voxel_idx[rand_idx]]) < 255) { // background voxels within room segmentation_weight[bg_voxel_idx[rand_idx]] = Dtype( segmentation_class_weight[0]); segnegcout++; } } } if (occ_weight != nullptr) { memcpy(occ_weight->mutable_cpu_data() + batch_idx * num_label_voxels, occupancy_weight, num_label_voxels * sizeof(Dtype)); } memcpy(seg_weight->mutable_cpu_data() + batch_idx * num_label_voxels, segmentation_weight, num_label_voxels * sizeof(Dtype)); // // Visualize //SaveVox2Ply("vis_tsdf_" + std::to_string(batch_idx) + ".ply", data_crop_vox_size, vox_tsdf); // "vis_tsdf_" + data_filenames[counter] + ".ply" // if (add_height) { // Dtype * vox_height = new Dtype[num_crop_voxels]; // CUDA_CHECK(hipMemcpy(vox_height, tmp_vox_height_GPU, num_crop_voxels * sizeof(Dtype), hipMemcpyDeviceToHost)); // SaveVoxHeight2Ply("vis_height_" + std::to_string(batch_idx) + ".ply", data_crop_vox_size, vox_height); // delete [] vox_height; // } // SaveVox2Ply("vis_tsdf_" + std::to_string(batch_idx) + ".ply", label_vox_size, tsdf_data_downscale); // SaveVoxLabel2Ply("vis_occ_label_" + std::to_string(batch_idx) + ".ply", label_vox_size, label_downscale, occupancy_label_downscale); // SaveVoxLabel2Ply("vis_seg_label_" + std::to_string(batch_idx) + ".ply", label_vox_size, label_downscale, segmentation_label_downscale); // SaveVoxWeight2Ply("vis_occ_weight_" + std::to_string(batch_idx) + ".ply", label_vox_size, label_downscale, occupancy_weight); // SaveVoxWeight2Ply("vis_seg_weight_" + std::to_string(batch_idx) + ".ply", label_vox_size, label_downscale, segmentation_weight); // SaveVoxWeight2Ply("vis_seg_surf_weight_" + std::to_string(batch_idx) + ".ply", label_vox_size, label_downscale, segmentation_surf_weight); if (data_param.tsdf_type() > 0) { // transfrom TSDF if necsessary int THREADS_NUM = 1024; int BLOCK_NUM = int((num_crop_voxels + size_t(THREADS_NUM) - 1) / THREADS_NUM); tsdfTransform << < BLOCK_NUM, THREADS_NUM >> > (vox_info_GPU, tmp_tsdf_data_GPU, data_param.tsdf_type()); CUDA_CHECK(hipMemcpy(tsdf->mutable_cpu_data() + num_crop_voxels * batch_idx, tmp_tsdf_data_GPU, num_crop_voxels * sizeof(Dtype), hipMemcpyDeviceToHost)); } // // Free memory delete[] depth_data; delete[] vox_tsdf; delete[] vox_weight_CPU; delete[] tsdf_data_downscale; delete[] occupancy_label_full; delete[] occupancy_label_crop; delete[] occupancy_label_downscale; delete[] occupancy_weight; delete[] segmentation_label_full; delete[] segmentation_label_crop; delete[] segmentation_label_downscale; delete[] segmentation_weight; //delete[] segmentation_surf_weight; } } template<typename Dtype> int SuncgDataLayer<Dtype>::numofitems() { return data_filenames.size(); }; template<typename Dtype> void SuncgDataLayer<Dtype>::Shuffle() { //std::shuffle(sceneMetaList.begin(),sceneMetaList.end(), rng ); caffe::rng_t *rng = static_cast<caffe::rng_t *>(rng_->generator()); shuffle(data_filenames.begin(), data_filenames.end(), rng); return; }; template SuncgDataLayer<float>::~SuncgDataLayer(); template void SuncgDataLayer<float>::DataLayerSetUp(const vector<Blob<float>*>& bottom, const vector<Blob<float>*>& top); template void SuncgDataLayer<float>::load_batch(Batch<float>* batch); template SuncgDataLayer<double>::~SuncgDataLayer(); template void SuncgDataLayer<double>::DataLayerSetUp(const vector<Blob<double>*>& bottom, const vector<Blob<double>*>& top); template void SuncgDataLayer<double>::load_batch(Batch<double>* batch); }
55de1c15691c7b79fc2ba5574ee5eb53df82230c.cu
#include "caffe/layers/base_data_layer.hpp" #include "caffe/layers/suncg_data_layer.hpp" #include "caffe/util/rng.hpp" #include "suncg_fusion.hpp" #include "suncg_util.hpp" #include <vector> #include <utility> DEFINE_bool(shuran_chatter, false, "If you are Shuran and want chatter, turn this on."); namespace caffe{ template<typename Dtype> SuncgDataLayer<Dtype>::~SuncgDataLayer<Dtype>() { this->StopInternalThread(); } template<typename Dtype> void SuncgDataLayer<Dtype>::DataLayerSetUp(const vector<Blob<Dtype> *> &bottom, const vector<Blob<Dtype> *> &top) { LOG(INFO) << "Read SUNCG parameters"; const SuncgDataParameter& data_param = this->layer_param_.suncg_data_param(); for (int i = 0; i < data_param.file_data_size(); ++i) { file_data.push_back(data_param.file_data(i)); } file_list = data_param.file_list(); vox_unit = data_param.vox_unit(); vox_margin = data_param.vox_margin(); add_height = data_param.with_height(); for (int i = 0; i < data_param.seg_class_map_size(); ++i) { segmentation_class_map.push_back(data_param.seg_class_map(i)); } num_segmentation_class = *std::max_element(segmentation_class_map.begin(), segmentation_class_map.end()) + 1; LOG(INFO) << "num_segmentation_class: " << num_segmentation_class; for (int i = 0; i < data_param.seg_class_weight_size(); ++i) { segmentation_class_weight.push_back(data_param.seg_class_weight(i)); } for (int i = 0; i < data_param.occ_class_weight_size(); ++i) { occupancy_class_weight.push_back(data_param.occ_class_weight(i)); } shuffle_data = data_param.shuffle(); occ_emptyonly = data_param.occ_empty_only(); data_num_channel = add_height ? 2 : 1; surf_only = data_param.surf_only(); CHECK_EQ(data_param.vox_size_size(), 3); CHECK_EQ(data_param.crop_size_size(), 3); for (int i = 0; i < data_param.vox_size_size(); ++i) { data_full_vox_size.push_back(data_param.vox_size(i)); } for (int i = 0; i < data_param.crop_size_size(); ++i) { data_crop_vox_size.push_back(data_param.crop_size(i));; } for (int i = 0; i < data_param.label_size_size(); ++i) { label_vox_size.push_back(data_param.label_size(i)); } sample_neg_obj_ratio = data_param.neg_obj_sample_ratio(); batch_size = data_param.batch_size(); offset_value = 0; epoch_prefetch = 0; counter = 0; // List all files in data folder and shuffle them if necessary GetFiles(file_data, data_filenames, "camera_list_train.list", "0000.png"); if (shuffle_data) { const unsigned int rng_seed = caffe_rng_rand(); rng_.reset(new Caffe::RNG(rng_seed)); Shuffle(); } LOG(INFO) << "Read camera information"; // Copy camera information to GPU cam_info[0] = Dtype(frame_width); cam_info[1] = Dtype(frame_height); for (int i = 0; i < 9; ++i) cam_info[i + 2] = cam_K[i]; for (int i = 0; i < 16; ++i) cam_info[i + 11] = 0.0f; CUDA_CHECK(cudaMalloc(&cam_info_GPU, 27 * sizeof(Dtype))); LOG(INFO) << "Set voxel volume parameters and copy them to GPU"; vox_info[0] = vox_unit; vox_info[1] = vox_margin; for (int i = 0; i < 3; ++i) vox_info[i + 2] = Dtype(data_crop_vox_size[i]); CUDA_CHECK(cudaMalloc(&vox_info_GPU, 8 * sizeof(Dtype))); LOG(INFO) << "Allocating data"; LOG(INFO) << "data_num_channel: " << data_num_channel; // GPU malloc depth data CUDA_CHECK(cudaMalloc(&depth_data_GPU, frame_height * frame_width * sizeof(Dtype))); // GPU malloc voxel volume weights CUDA_CHECK(cudaMalloc(&vox_weight_GPU, data_crop_vox_size[0] * data_crop_vox_size[1] * data_crop_vox_size[2] * sizeof(Dtype))); size_t memoryBytes = 0; // std::cout << (train_me ? "* " : " "); // std::cout << name << std::endl; // Determine if data should be cropped is_cropping_data = data_crop_vox_size[0] < data_full_vox_size[0] || data_crop_vox_size[1] < data_full_vox_size[1] || data_crop_vox_size[2] < data_full_vox_size[2]; int num_crop_voxels = data_crop_vox_size[0] * data_crop_vox_size[1] * data_crop_vox_size[2]; int num_full_voxels = data_full_vox_size[0] * data_full_vox_size[1] * data_full_vox_size[2]; if (is_cropping_data) { CUDA_CHECK(cudaMalloc(&vox_data_GPU, batch_size * data_num_channel * num_crop_voxels * sizeof(Dtype))); memoryBytes += batch_size * data_num_channel * num_crop_voxels * sizeof(Dtype); } else { CUDA_CHECK(cudaMalloc(&vox_data_GPU, batch_size * data_num_channel * num_full_voxels * sizeof(Dtype))); memoryBytes += batch_size * data_num_channel * num_full_voxels * sizeof(Dtype); } int num_label_voxels = label_vox_size[0] * label_vox_size[1] * label_vox_size[2]; CUDA_CHECK(cudaMalloc(&occupancy_label_GPU, batch_size * num_label_voxels * sizeof(Dtype))); CUDA_CHECK(cudaMalloc(&occupancy_weight_GPU, batch_size * 2 * num_label_voxels * sizeof(Dtype))); memoryBytes += batch_size * 3 * num_label_voxels * sizeof(Dtype); CUDA_CHECK(cudaMalloc(&segmentation_label_GPU, batch_size * num_label_voxels * sizeof(Dtype))); CUDA_CHECK(cudaMalloc(&segmentation_weight_GPU, batch_size * num_segmentation_class * num_label_voxels * sizeof(Dtype))); CUDA_CHECK(cudaMalloc(&segmentation_surf_weight_GPU, batch_size * num_segmentation_class * num_label_voxels * sizeof(Dtype))); memoryBytes += batch_size * (num_segmentation_class + 1) * num_label_voxels * sizeof(Dtype); LOG(INFO) << "Resize tops"; // out[0]->need_diff = false; std::vector<int> data_dim; data_dim.resize(5); data_dim[0] = batch_size; data_dim[1] = data_num_channel; if (is_cropping_data) { data_dim[2] = data_crop_vox_size[0]; data_dim[3] = data_crop_vox_size[1]; data_dim[4] = data_crop_vox_size[2]; } else { data_dim[2] = data_full_vox_size[0]; data_dim[3] = data_full_vox_size[1]; data_dim[4] = data_full_vox_size[2]; } top[0]->Reshape(data_dim); for (int i = 0; i < this->PREFETCH_COUNT; ++i) { this->prefetch_[i].Resize(5); this->prefetch_[i].mutable_blob(0)->Reshape(data_dim); } data_dim[1] = 1; data_dim[2] = label_vox_size[0]; data_dim[3] = label_vox_size[1]; data_dim[4] = label_vox_size[2]; for (int i = 1; i < top.size(); ++i) { top[i]->Reshape(data_dim); for (int j = 0; j < this->PREFETCH_COUNT; ++j) { this->prefetch_[j].mutable_blob(i)->Reshape(data_dim); } } // if (top.size() > 5) { // data_dim[2] = 480; // data_dim[3] = 640; // data_dim[4] = 1; // top[5]->Reshape(data_dim); // for (int j = 0; j < this->PREFETCH_COUNT; ++j) { // this->prefetch_[j].mutable_blob(5)->Reshape(data_dim); // } // } // // out[0]->receptive_field.resize(data_dim.size() - 2); fill_n(out[0]->receptive_field.begin(), data_dim.size() - 2, 1); // out[0]->receptive_gap.resize(data_dim.size() - 2); fill_n(out[0]->receptive_gap.begin(), data_dim.size() - 2, 1); // out[0]->receptive_offset.resize(data_dim.size() - 2); fill_n(out[0]->receptive_offset.begin(), data_dim.size() - 2, 0); // memoryBytes += out[0]->Malloc(data_dim); // // // Occupancy label // out[1]->need_diff = false; // data_dim[1] = 1; // data_dim[2] = label_vox_size[0]; // data_dim[3] = label_vox_size[1]; // data_dim[4] = label_vox_size[2]; // memoryBytes += out[1]->Malloc(data_dim); // // // Occupancy weight // out[2]->need_diff = false; // data_dim[1] = 2; // memoryBytes += out[2]->Malloc(data_dim); // // // Segmentation label // out[3]->need_diff = false; // data_dim[1] = 1; // memoryBytes += out[3]->Malloc(data_dim); // // // Segmentation weight // out[4]->need_diff = false; // data_dim[1] = num_segmentation_class; // memoryBytes += out[4]->Malloc(data_dim); // // // Segmentation surface weight // out[5]->need_diff = false; // memoryBytes += out[5]->Malloc(data_dim); // // // prefetch(); // lock = std::async(std::launch::async, &SUNCGDataLayer::prefetch, this); // return memoryBytes; } template<typename Dtype> void SuncgDataLayer<Dtype>::load_batch(Batch<Dtype> *batch) { // LOG(INFO) << "Loading " << batch; const SuncgDataParameter& data_param = this->layer_param_.suncg_data_param(); Blob<Dtype> *tsdf = nullptr, *occ_label = nullptr, *occ_weight = nullptr; if (batch->size() > 3) { occ_label = batch->mutable_blob(3); occ_weight = batch->mutable_blob(4); } // if (data_param.data_type() == SuncgDataParameter_DATA_TSDF) { // tsdf = batch->mutable_blob(0); // } else if(data_param.data_type() == SuncgDataParameter_DATA_OCCUPANCY) { // occ_label = batch->mutable_blob(0); // } tsdf = batch->mutable_blob(0); Blob<Dtype> *seg_label = batch->mutable_blob(1); Blob<Dtype> *seg_weight = batch->mutable_blob(2); for (size_t batch_idx = 0; batch_idx < batch_size; ++batch_idx) { // Get random image bool is_valid_image = false; std::string depth_path = ""; while (!is_valid_image) { depth_path = data_filenames[counter]; is_valid_image = FileExists(depth_path.substr(0, depth_path.length() - 3) + "bin") && FileExists(depth_path); // increase counter counter++; if (counter >= data_filenames.size()) { counter = 0; ++epoch_prefetch; if (shuffle_data) Shuffle(); } } // Get depth image and copy to GPU Dtype *depth_data = new Dtype[frame_height * frame_width]; ReadDepthImage(depth_path, depth_data, frame_width, frame_height); // LOG(INFO) << "Depth data: " << depth_data[frame_width * frame_height / 2]; CUDA_CHECK(cudaMemcpy(depth_data_GPU, depth_data, frame_height * frame_width * sizeof(Dtype), cudaMemcpyHostToDevice)); // Get voxel origin (in world coordinates), camera pose, and voxel labels Dtype vox_origin[3]; Dtype cam_pose[16]; int num_crop_voxels = data_crop_vox_size[0] * data_crop_vox_size[1] * data_crop_vox_size[2]; int num_full_voxels = data_full_vox_size[0] * data_full_vox_size[1] * data_full_vox_size[2]; Dtype *occupancy_label_full = new Dtype[num_full_voxels]; Dtype *segmentation_label_full = new Dtype[num_full_voxels]; ReadVoxLabel(depth_path.substr(0, depth_path.length() - 3) + "bin", vox_origin, cam_pose, occupancy_label_full, segmentation_class_map, segmentation_label_full); // Find cropping origin int crop_origin[3] = { 0, 0, 0 }; if (is_cropping_data) { bool crop_vox_found = false; int max_iter = 100; int sample_iter = 0; // Crop a random box out of the full volume while (!crop_vox_found && sample_iter < max_iter) { // Compute random cropping origin crop_origin[0] = 0.0f; crop_origin[1] = 0.0f; crop_origin[2] = 0.0f; if (data_full_vox_size[0] - data_crop_vox_size[0] > 0) crop_origin[0] = (int)std::floor(GenRandFloat(0.0f, (float)( data_full_vox_size[0] - data_crop_vox_size[0]))); if (data_full_vox_size[1] - data_crop_vox_size[1] > 0) crop_origin[1] = (int)std::floor(GenRandFloat(0.0f, (float)( data_full_vox_size[1] - data_crop_vox_size[1]))); if (data_full_vox_size[2] - data_crop_vox_size[2] > 0) crop_origin[2] = (int)std::floor(GenRandFloat(0.0f, (float)( data_full_vox_size[2] - data_crop_vox_size[2]))); sample_iter++; // Check cropped box is non-empty and contains object classes other than only floor, wall, ceiling int num_non_empty_voxels = 0; int num_object_voxels = 0; for (int x = crop_origin[0]; x < crop_origin[0] + data_crop_vox_size[0]; ++x) for (int y = crop_origin[1]; y < crop_origin[1] + data_crop_vox_size[1]; ++y) for (int z = crop_origin[2]; z < crop_origin[2] + data_crop_vox_size[2]; ++z) { int full_voxel_idx = z * data_full_vox_size[0] * data_full_vox_size[1] + y * data_full_vox_size[0] + x; if (segmentation_label_full[full_voxel_idx] > 0 & segmentation_label_full[full_voxel_idx] < 255) num_non_empty_voxels++; if (segmentation_label_full[full_voxel_idx] > 3) num_object_voxels++; } if (num_non_empty_voxels < data_crop_vox_size[0] * data_crop_vox_size[0] || num_object_voxels < data_crop_vox_size[0]) continue; crop_vox_found = true; } } if (FLAGS_shuran_chatter) { LOG(INFO) << depth_path << " " << crop_origin[0] << " " << crop_origin[1] << " " << crop_origin[2]; } // Update voxel parameters with new voxel origin (+ cropping origin) in world coordinates vox_info[5] = vox_origin[0] + (float)(crop_origin[2]) * vox_unit; vox_info[6] = vox_origin[1] + (float)(crop_origin[0]) * vox_unit; vox_info[7] = vox_origin[2] + (float)(crop_origin[1]) * vox_unit; // Update camera information with new camera pose for (int i = 0; i < 16; ++i) cam_info[i + 11] = cam_pose[i]; // Update camera information and voxel parameters in GPU CUDA_CHECK(cudaMemcpy(cam_info_GPU, cam_info, 27 * sizeof(Dtype), cudaMemcpyHostToDevice)); CUDA_CHECK(cudaMemcpy(vox_info_GPU, vox_info, 8 * sizeof(Dtype), cudaMemcpyHostToDevice)); // Get voxel volume Dtype *tmp_tsdf_data_GPU = vox_data_GPU + batch_idx * num_crop_voxels; GPU_set_value(num_crop_voxels, tmp_tsdf_data_GPU, Dtype(1.0)); Dtype *tmp_vox_height_GPU = NULL; if (add_height) { tmp_vox_height_GPU = vox_data_GPU + batch_idx * data_num_channel * num_crop_voxels + num_crop_voxels; GPU_set_zeros(num_crop_voxels, tmp_vox_height_GPU); } // Reset voxel weights in GPU Dtype *vox_weight_CPU = new Dtype[num_crop_voxels]; memset(vox_weight_CPU, 0, num_crop_voxels * sizeof(Dtype)); CUDA_CHECK(cudaMemcpy(vox_weight_GPU, vox_weight_CPU, num_crop_voxels * sizeof(Dtype), cudaMemcpyHostToDevice)); // Retreive cropped labels Dtype *occupancy_label_crop = new Dtype[num_crop_voxels]; Dtype *segmentation_label_crop = new Dtype[num_crop_voxels]; for (int x = 0; x < data_crop_vox_size[0]; ++x) for (int y = 0; y < data_crop_vox_size[1]; ++y) for (int z = 0; z < data_crop_vox_size[2]; ++z) { int crop_voxel_idx = z * data_crop_vox_size[0] * data_crop_vox_size[1] + y * data_crop_vox_size[0] + x; int full_voxel_idx = (z + crop_origin[2]) * data_full_vox_size[0] * data_full_vox_size[1] + (y + crop_origin[1]) * data_full_vox_size[0] + (x + crop_origin[0]); occupancy_label_crop[crop_voxel_idx] = occupancy_label_full[full_voxel_idx]; segmentation_label_crop[crop_voxel_idx] = segmentation_label_full[full_voxel_idx]; } // Fuse frame into voxel volume if (data_param.data_type() == SuncgDataParameter_DATA_OCCUPANCY){ Dtype * occupancy_label_crop_GPU; cudaMalloc(&occupancy_label_crop_GPU, num_crop_voxels* sizeof(Dtype)); cudaMemcpy(occupancy_label_crop_GPU, occupancy_label_crop, num_crop_voxels * sizeof(Dtype), cudaMemcpyHostToDevice); int THREADS_NUM = 1024; int BLOCK_NUM = int((num_crop_voxels + size_t(THREADS_NUM) - 1) / THREADS_NUM); CompleteTSDF << < BLOCK_NUM, THREADS_NUM >> >(vox_info_GPU, occupancy_label_crop_GPU, tmp_tsdf_data_GPU); cudaFree(occupancy_label_crop_GPU); CUDA_CHECK(cudaGetLastError()); } else{ if (data_param.with_projection_tsdf()){ int num_blocks = data_crop_vox_size[2]; int num_threads = data_crop_vox_size[1]; GPU_set_zeros(num_crop_voxels, vox_weight_GPU); Integrate << < data_crop_vox_size[2], data_crop_vox_size[1] >> > (cam_info_GPU, vox_info_GPU, depth_data_GPU, tmp_tsdf_data_GPU, vox_weight_GPU, tmp_vox_height_GPU); CUDA_CHECK(cudaGetLastError()); } else{ ComputeTSDF(cam_info, vox_info, cam_info_GPU, vox_info_GPU, depth_data_GPU, tmp_tsdf_data_GPU, tmp_vox_height_GPU); CUDA_CHECK(cudaGetLastError()); } } // Copy voxel volume back to CPU Dtype *vox_tsdf = new Dtype[num_crop_voxels]; CUDA_CHECK(cudaMemcpy(vox_tsdf, tmp_tsdf_data_GPU, num_crop_voxels * sizeof(Dtype), cudaMemcpyDeviceToHost)); if (tsdf != nullptr) { memcpy(tsdf->mutable_cpu_data() + num_crop_voxels * batch_idx * data_num_channel, vox_tsdf, num_crop_voxels * sizeof(Dtype)); } //adding height to floor if (add_height){ cudaMemcpy(tsdf->mutable_cpu_data() + num_crop_voxels * batch_idx * data_num_channel + num_crop_voxels, tmp_vox_height_GPU, num_crop_voxels * sizeof(Dtype), cudaMemcpyDeviceToHost); } // Downsample label with scale int num_label_voxels = label_vox_size[0] * label_vox_size[1] * label_vox_size[2]; int label_downscale = (data_crop_vox_size[0] / label_vox_size[0]); Dtype *occupancy_label_downscale = new Dtype[num_label_voxels]; Dtype *segmentation_label_downscale = new Dtype[num_label_voxels]; Dtype *tsdf_data_downscale = new Dtype[num_label_voxels]; if (label_downscale > 1){ DownsampleLabel(data_crop_vox_size, label_vox_size, label_downscale, occupancy_label_crop, occupancy_label_downscale, segmentation_label_crop, segmentation_label_downscale, vox_tsdf, tsdf_data_downscale); } else{ if (FLAGS_shuran_chatter) { LOG(INFO) << "label_downscale: " << label_downscale; } memcpy(occupancy_label_downscale, occupancy_label_crop, num_label_voxels * sizeof(Dtype)); memcpy(segmentation_label_downscale, segmentation_label_crop, num_label_voxels * sizeof(Dtype)); memcpy(tsdf_data_downscale, vox_tsdf, num_label_voxels * sizeof(Dtype)); } // Copy labels to GPU // CUDA_CHECK( // cudaMemcpy(occupancy_label_GPU + batch_idx * num_label_voxels, // occupancy_label_downscale, // num_label_voxels * sizeof(Dtype), // cudaMemcpyHostToDevice)); // CUDA_CHECK( // cudaMemcpy(segmentation_label_GPU + batch_idx * num_label_voxels, // segmentation_label_downscale, // num_label_voxels * sizeof(Dtype), // cudaMemcpyHostToDevice)); if (occ_label != nullptr) { memcpy(occ_label->mutable_cpu_data() + batch_idx * num_label_voxels, occupancy_label_downscale, num_label_voxels * sizeof(Dtype)); } memcpy(seg_label->mutable_cpu_data() + batch_idx * num_label_voxels, segmentation_label_downscale, num_label_voxels * sizeof(Dtype)); // Find number of occupied voxels // Save voxel indices of background // Set label weights of occupied voxels as 1 int num_occ_voxels = 0; std::vector<int> bg_voxel_idx; Dtype *occupancy_weight = new Dtype[num_label_voxels]; Dtype *segmentation_weight = new Dtype[num_label_voxels]; //Dtype *segmentation_surf_weight = new Dtype[num_label_voxels]; memset(occupancy_weight, 0, num_label_voxels * sizeof(Dtype)); memset(segmentation_weight, 0, num_label_voxels * sizeof(Dtype)); //memset(segmentation_surf_weight, 0, num_label_voxels * sizeof(Dtype)); for (int i = 0; i < num_label_voxels; ++i) { if (Dtype(occupancy_label_downscale[i]) > 0) { if (tsdf_data_downscale[i] < -0.5) { // forground voxels in unobserved region num_occ_voxels++; occupancy_weight[i] = Dtype(occupancy_class_weight[1]); } } else { if (tsdf_data_downscale[i] < -0.5) { bg_voxel_idx.push_back(i); // background voxels in unobserved regoin } } if (Dtype(segmentation_label_downscale[i]) > 0 && Dtype(segmentation_label_downscale[i]) < 255) { // foreground voxels within room if (surf_only){ if (abs(tsdf_data_downscale[i]) < 0.5){ segmentation_weight[i] = Dtype(segmentation_class_weight[(int)segmentation_label_downscale[i]]); } } else{ segmentation_weight[i] = Dtype(segmentation_class_weight[(int)segmentation_label_downscale[i]]); } // if (abs(tsdf_data_downscale[i]) < 0.5) { // segmentation_surf_weight[i] = Dtype( // segmentation_class_weight[(int) (segmentation_label_downscale[i])]); // } } } // Raise the weight for a few indices of background voxels std::random_device tmp_rand_rd; std::mt19937 tmp_rand_mt(tmp_rand_rd()); int segnegcout = 0; int segnegtotal = floor(sample_neg_obj_ratio * (float)num_occ_voxels); if (bg_voxel_idx.size() > 0) { std::uniform_real_distribution<double> tmp_rand_dist( 0, (float)(bg_voxel_idx.size()) - 0.0001); for (int i = 0; i < num_occ_voxels; ++i) { int rand_idx = (int)(std::floor(tmp_rand_dist(tmp_rand_mt))); occupancy_weight[bg_voxel_idx[rand_idx]] = Dtype( occupancy_class_weight[0]); if (segnegcout < segnegtotal && Dtype(segmentation_label_downscale[bg_voxel_idx[rand_idx]]) < 255) { // background voxels within room segmentation_weight[bg_voxel_idx[rand_idx]] = Dtype( segmentation_class_weight[0]); segnegcout++; } } } if (occ_weight != nullptr) { memcpy(occ_weight->mutable_cpu_data() + batch_idx * num_label_voxels, occupancy_weight, num_label_voxels * sizeof(Dtype)); } memcpy(seg_weight->mutable_cpu_data() + batch_idx * num_label_voxels, segmentation_weight, num_label_voxels * sizeof(Dtype)); // // Visualize //SaveVox2Ply("vis_tsdf_" + std::to_string(batch_idx) + ".ply", data_crop_vox_size, vox_tsdf); // "vis_tsdf_" + data_filenames[counter] + ".ply" // if (add_height) { // Dtype * vox_height = new Dtype[num_crop_voxels]; // CUDA_CHECK(cudaMemcpy(vox_height, tmp_vox_height_GPU, num_crop_voxels * sizeof(Dtype), cudaMemcpyDeviceToHost)); // SaveVoxHeight2Ply("vis_height_" + std::to_string(batch_idx) + ".ply", data_crop_vox_size, vox_height); // delete [] vox_height; // } // SaveVox2Ply("vis_tsdf_" + std::to_string(batch_idx) + ".ply", label_vox_size, tsdf_data_downscale); // SaveVoxLabel2Ply("vis_occ_label_" + std::to_string(batch_idx) + ".ply", label_vox_size, label_downscale, occupancy_label_downscale); // SaveVoxLabel2Ply("vis_seg_label_" + std::to_string(batch_idx) + ".ply", label_vox_size, label_downscale, segmentation_label_downscale); // SaveVoxWeight2Ply("vis_occ_weight_" + std::to_string(batch_idx) + ".ply", label_vox_size, label_downscale, occupancy_weight); // SaveVoxWeight2Ply("vis_seg_weight_" + std::to_string(batch_idx) + ".ply", label_vox_size, label_downscale, segmentation_weight); // SaveVoxWeight2Ply("vis_seg_surf_weight_" + std::to_string(batch_idx) + ".ply", label_vox_size, label_downscale, segmentation_surf_weight); if (data_param.tsdf_type() > 0) { // transfrom TSDF if necsessary int THREADS_NUM = 1024; int BLOCK_NUM = int((num_crop_voxels + size_t(THREADS_NUM) - 1) / THREADS_NUM); tsdfTransform << < BLOCK_NUM, THREADS_NUM >> > (vox_info_GPU, tmp_tsdf_data_GPU, data_param.tsdf_type()); CUDA_CHECK(cudaMemcpy(tsdf->mutable_cpu_data() + num_crop_voxels * batch_idx, tmp_tsdf_data_GPU, num_crop_voxels * sizeof(Dtype), cudaMemcpyDeviceToHost)); } // // Free memory delete[] depth_data; delete[] vox_tsdf; delete[] vox_weight_CPU; delete[] tsdf_data_downscale; delete[] occupancy_label_full; delete[] occupancy_label_crop; delete[] occupancy_label_downscale; delete[] occupancy_weight; delete[] segmentation_label_full; delete[] segmentation_label_crop; delete[] segmentation_label_downscale; delete[] segmentation_weight; //delete[] segmentation_surf_weight; } } template<typename Dtype> int SuncgDataLayer<Dtype>::numofitems() { return data_filenames.size(); }; template<typename Dtype> void SuncgDataLayer<Dtype>::Shuffle() { //std::shuffle(sceneMetaList.begin(),sceneMetaList.end(), rng ); caffe::rng_t *rng = static_cast<caffe::rng_t *>(rng_->generator()); shuffle(data_filenames.begin(), data_filenames.end(), rng); return; }; template SuncgDataLayer<float>::~SuncgDataLayer(); template void SuncgDataLayer<float>::DataLayerSetUp(const vector<Blob<float>*>& bottom, const vector<Blob<float>*>& top); template void SuncgDataLayer<float>::load_batch(Batch<float>* batch); template SuncgDataLayer<double>::~SuncgDataLayer(); template void SuncgDataLayer<double>::DataLayerSetUp(const vector<Blob<double>*>& bottom, const vector<Blob<double>*>& top); template void SuncgDataLayer<double>::load_batch(Batch<double>* batch); }
b5a939ebc9bf7210af8c17c83dee707bbe7bac85.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include "device_launch_parameters.h" #include "hip/device_functions.h" #include <stdio.h> #include <stdlib.h> static void HandleError(hipError_t err, const char *file, int line) { if (err != hipSuccess) { printf("%s in %s at line %d\n", hipGetErrorString(err), file, line); exit(EXIT_FAILURE); } } #define HANDLE_ERROR(err) (HandleError(err, __FILE__, __LINE__)) #define imin(a,b) (a<b?a:b) const int N = 33 * 1024; const int threadsPerBlock = 256; const int blocksPerGrid = imin(32, (N + threadsPerBlock - 1) / threadsPerBlock); __global__ void dot_kernel(float* a, float* b, float* c) { __shared__ float cache[threadsPerBlock]; int tid = threadIdx.x + blockDim.x * blockIdx.x; int cacheIndex = threadIdx.x; float temp = 0; while (tid < N) { temp += a[tid] * b[tid]; //tid += threadsPerBlock*blocksPerGrid; tid += blockDim.x * gridDim.x; } cache[cacheIndex] = temp; __syncthreads(); int i = blockDim.x / 2; while (i > 0) { if (cacheIndex < i) cache[cacheIndex] = cache[cacheIndex] + cache[cacheIndex + i]; __syncthreads(); i /= 2; } // chache[0]block // global memory0 if (cacheIndex == 0) { c[blockIdx.x] = cache[0]; } } int main() { float *h_a, *h_b, c, *h_partial_c; float *d_a, *d_b, *d_partial_c; h_a = (float*)malloc(N * sizeof(float)); h_b = (float*)malloc(N * sizeof(float)); h_partial_c = (float*)malloc(blocksPerGrid * sizeof(float)); HANDLE_ERROR(hipMalloc((void**)&d_a, N * sizeof(float))); HANDLE_ERROR(hipMalloc((void**)&d_b, N * sizeof(float))); HANDLE_ERROR(hipMalloc((void**)&d_partial_c, blocksPerGrid * sizeof(float))); // fill in data for (int i = 0; i < N; i++) { h_a[i] = i; h_b[i] = i * 2; } HANDLE_ERROR(hipMemcpy(d_a, h_a, N * sizeof(float), hipMemcpyHostToDevice)); HANDLE_ERROR(hipMemcpy(d_b, h_b, N * sizeof(float), hipMemcpyHostToDevice)); // launch kernel dot_kernel << <threadsPerBlock, blocksPerGrid >> > (d_a, d_b, d_partial_c); HANDLE_ERROR(hipMemcpy(h_partial_c, d_partial_c, blocksPerGrid * sizeof(float), hipMemcpyDeviceToHost)); c = 0; for (int i = 0; i < blocksPerGrid; i++) { c += h_partial_c[i]; } hipFree(d_a); hipFree(d_b); hipFree(d_partial_c); free(h_a); free(h_b); free(h_partial_c); printf("Square Sum:%f\n", c); }
b5a939ebc9bf7210af8c17c83dee707bbe7bac85.cu
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include "device_functions.h" #include <stdio.h> #include <stdlib.h> static void HandleError(cudaError_t err, const char *file, int line) { if (err != cudaSuccess) { printf("%s in %s at line %d\n", cudaGetErrorString(err), file, line); exit(EXIT_FAILURE); } } #define HANDLE_ERROR(err) (HandleError(err, __FILE__, __LINE__)) #define imin(a,b) (a<b?a:b) const int N = 33 * 1024; const int threadsPerBlock = 256; const int blocksPerGrid = imin(32, (N + threadsPerBlock - 1) / threadsPerBlock); __global__ void dot_kernel(float* a, float* b, float* c) { __shared__ float cache[threadsPerBlock]; int tid = threadIdx.x + blockDim.x * blockIdx.x; int cacheIndex = threadIdx.x; float temp = 0; while (tid < N) { temp += a[tid] * b[tid]; //tid += threadsPerBlock*blocksPerGrid; tid += blockDim.x * gridDim.x; } cache[cacheIndex] = temp; __syncthreads(); int i = blockDim.x / 2; while (i > 0) { if (cacheIndex < i) cache[cacheIndex] = cache[cacheIndex] + cache[cacheIndex + i]; __syncthreads(); i /= 2; } // 经过上面的同步之后,chache[0]就是我们想要的改block的和 // 把这个值存在global memory里,只需要一个线程来做这件事,这里选0线程 if (cacheIndex == 0) { c[blockIdx.x] = cache[0]; } } int main() { float *h_a, *h_b, c, *h_partial_c; float *d_a, *d_b, *d_partial_c; h_a = (float*)malloc(N * sizeof(float)); h_b = (float*)malloc(N * sizeof(float)); h_partial_c = (float*)malloc(blocksPerGrid * sizeof(float)); HANDLE_ERROR(cudaMalloc((void**)&d_a, N * sizeof(float))); HANDLE_ERROR(cudaMalloc((void**)&d_b, N * sizeof(float))); HANDLE_ERROR(cudaMalloc((void**)&d_partial_c, blocksPerGrid * sizeof(float))); // fill in data for (int i = 0; i < N; i++) { h_a[i] = i; h_b[i] = i * 2; } HANDLE_ERROR(cudaMemcpy(d_a, h_a, N * sizeof(float), cudaMemcpyHostToDevice)); HANDLE_ERROR(cudaMemcpy(d_b, h_b, N * sizeof(float), cudaMemcpyHostToDevice)); // launch kernel dot_kernel << <threadsPerBlock, blocksPerGrid >> > (d_a, d_b, d_partial_c); HANDLE_ERROR(cudaMemcpy(h_partial_c, d_partial_c, blocksPerGrid * sizeof(float), cudaMemcpyDeviceToHost)); c = 0; for (int i = 0; i < blocksPerGrid; i++) { c += h_partial_c[i]; } cudaFree(d_a); cudaFree(d_b); cudaFree(d_partial_c); free(h_a); free(h_b); free(h_partial_c); printf("Square Sum:%f\n", c); }
bc90bb7e039fadc91401a6461dabda0f1d378ab3.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" /* Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include <algorithm> #include "paddle/fluid/operators/gather.cu.h" #include "paddle/fluid/operators/math/math_function.h" #include "paddle/fluid/operators/math/segment_pooling.h" #include "paddle/fluid/platform/device/gpu/gpu_launch_config.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h" namespace paddle { namespace operators { using Tensor = framework::Tensor; template <typename T, typename Index, int DimTileSize> __global__ void SegmentSumIdsKernel(const Index* segment_ids, T* summed_ids, const Index input_length_size, const Index total_stripe_count) { CUDA_KERNEL_LOOP(stripe_index, total_stripe_count) { const Index segment_offset = stripe_index; const Index dim_index_base = stripe_index * Index(DimTileSize); const Index actual_height = min(Index(DimTileSize), input_length_size - dim_index_base); Index first_segment_id = segment_ids[dim_index_base]; Index last_segment_id = -1; if (dim_index_base > 0) { last_segment_id = segment_ids[dim_index_base - 1]; } T sum = T(0); for (Index j = 0; j < actual_height; j++) { Index current_segment_id = segment_ids[dim_index_base + j]; PADDLE_ENFORCE(current_segment_id >= last_segment_id, "the segment ids should be sorted, but got " "segment_ids[%d]:%d > segment_ids[%d]:%d.", dim_index_base + j - 1, dim_index_base + j, last_segment_id, current_segment_id); if (current_segment_id > last_segment_id) { for (Index interval_id = last_segment_id + 1; interval_id < current_segment_id; ++interval_id) { *(summed_ids + interval_id) = 0; } if (j > 0) { if (last_segment_id == first_segment_id) { platform::CudaAtomicAdd(summed_ids + last_segment_id, sum); } else { *(summed_ids + last_segment_id) = sum; } sum = T(0); } } sum += T(1); last_segment_id = current_segment_id; } platform::CudaAtomicAdd(summed_ids + last_segment_id, sum); } } template <typename T, typename Index, int DimTileSize> __global__ void SegmentMeanKernel(const Index* segment_ids, const T* input, T* output, T* summed_ids, const Index input_length_size, const Index inner_dim_size, const Index output_length_size, const Index total_stripe_count) { CUDA_KERNEL_LOOP(stripe_index, total_stripe_count) { const Index segment_offset = stripe_index % inner_dim_size; const Index dim_index_base = stripe_index / inner_dim_size * Index(DimTileSize); const Index actual_height = min(Index(DimTileSize), input_length_size - dim_index_base); Index first_segment_id = segment_ids[dim_index_base]; Index last_segment_id = -1; if (dim_index_base > 0) { last_segment_id = segment_ids[dim_index_base - 1]; } T sum = T(0); for (Index j = 0; j < actual_height; j++) { Index current_segment_id = segment_ids[dim_index_base + j]; if (current_segment_id > last_segment_id) { // reset the interval value which do not have corresponding ids. for (Index interval_id = last_segment_id + 1; interval_id < current_segment_id; ++interval_id) { *(output + interval_id * inner_dim_size + segment_offset) = T(0); } if (j > 0) { Index output_index = last_segment_id * inner_dim_size + segment_offset; if (last_segment_id == first_segment_id) { platform::CudaAtomicAdd(output + output_index, sum / *(summed_ids + last_segment_id)); } else { *(output + output_index) = sum / *(summed_ids + last_segment_id); } sum = T(0); } } sum += input[(dim_index_base + j) * inner_dim_size + segment_offset]; last_segment_id = current_segment_id; } Index output_index = last_segment_id * inner_dim_size + segment_offset; platform::CudaAtomicAdd(output + output_index, sum / *(summed_ids + last_segment_id)); } } template <typename T, typename Index, typename Helper, typename Pool> __global__ void __launch_bounds__(1024, 1) SegmentOpsKernel(const Index* segment_ids, const T* input, T* output, Helper h, Pool pool) { CUDA_KERNEL_LOOP(stripe_index, h.total_stripe_count) { Index segment_offset, dim_index_base, actual_height; Index inner_dim_size = h.inner_dim_size; h.calculate(stripe_index, &segment_offset, &dim_index_base, &actual_height); T minmax = pool.initial(); Index first_segment_id = segment_ids[dim_index_base]; // -1 is for the start value when interval_id = 0 Index last_segment_id = -1; if (dim_index_base > 0) { last_segment_id = segment_ids[dim_index_base - 1]; } for (Index j = 0; j < actual_height; j++) { Index current_segment_id = segment_ids[dim_index_base + j]; // ensure the segment_ids is sorted. PADDLE_ENFORCE(current_segment_id >= last_segment_id, "The segment ids should be sorted, but got " "segment_ids[%d]:%d > segment_ids[%d]:%d.", dim_index_base + j - 1, dim_index_base + j, last_segment_id, current_segment_id); if (current_segment_id > last_segment_id) { // reset the interval value which do not have corresponding ids. for (Index interval_id = last_segment_id + 1; interval_id < current_segment_id; ++interval_id) { *(output + interval_id * inner_dim_size + segment_offset) = T(0); } // don't update result when j=0 if (j > 0) { const Index output_index = last_segment_id * inner_dim_size + segment_offset; if (last_segment_id == first_segment_id) { pool.atomic(output + output_index, minmax); } else { *(output + output_index) = minmax; } minmax = pool.initial(); } } pool.compute( input[(dim_index_base + j) * inner_dim_size + segment_offset], &minmax); last_segment_id = current_segment_id; } const Index output_index = last_segment_id * inner_dim_size + segment_offset; pool.atomic(output + output_index, minmax); } } template <typename T, typename Index, typename Helper> __global__ void SegmentIndexGradKernel(const Index* segment_ids, const T* input, const T* output, const T* out_grad, T* in_grad, Helper h) { CUDA_KERNEL_LOOP(stripe_index, h.total_stripe_count) { Index segment_offset, dim_index_base, actual_height; h.calculate(stripe_index, &segment_offset, &dim_index_base, &actual_height); for (Index j = 0; j < actual_height; j++) { Index current_segment_id = segment_ids[dim_index_base + j]; Index input_index = (dim_index_base + j) * h.inner_dim_size + segment_offset; Index output_index = current_segment_id * h.inner_dim_size + segment_offset; if (input[input_index] == output[output_index]) { in_grad[input_index] = out_grad[output_index]; } } } } template <class T> class MaxPool { public: DEVICE inline T initial() { return static_cast<T>(-FLT_MAX); } DEVICE inline void compute(const T& x, T* y) { *y = *y > x ? *y : x; } DEVICE inline T atomic(T* address, const T val) { return platform::CudaAtomicMax(address, val); } }; template <class T> class MinPool { public: DEVICE inline T initial() { return static_cast<T>(FLT_MAX); } DEVICE inline void compute(const T& x, T* y) { *y = *y < x ? *y : x; } DEVICE inline T atomic(T* address, const T val) { return platform::CudaAtomicMin(address, val); } }; template <class T> class SumPool { public: DEVICE inline T initial() { return static_cast<T>(0); } DEVICE inline void compute(const T& x, T* y) { *y = *y + x; } DEVICE inline T atomic(T* address, const T val) { return platform::CudaAtomicAdd(address, val); } }; template <class T> class ArrangeHelper { public: const T input_total_size; const T input_length_size; const T output_length_size; T inner_dim_size; T total_stripe_count; const T DimTileSize = 8; ArrangeHelper(T a, T b, T c) : input_total_size(a), input_length_size(b), output_length_size(c) { T input_outer_dim_num_stripe = (input_length_size + DimTileSize - 1) / DimTileSize; inner_dim_size = input_total_size / input_length_size; total_stripe_count = inner_dim_size * input_outer_dim_num_stripe; } DEVICE inline void calculate(T stripe_index, T* segment_offset, T* dim_index_base, T* actual_height) { *segment_offset = stripe_index % inner_dim_size; *dim_index_base = stripe_index / inner_dim_size * DimTileSize; *actual_height = min(DimTileSize, input_length_size - *dim_index_base); } }; template <typename T, typename Index> void SegmentPoolCUDAGradFunctor(const platform::CUDADeviceContext& ctx, const framework::Tensor& input, const framework::Tensor& segment_ids, const framework::Tensor& output, const framework::Tensor& out_grad, framework::Tensor* in_grad, const std::string pooltype = "SUM") { auto h = ArrangeHelper<Index>(input.numel(), segment_ids.dims()[0], output.dims()[0]); auto config = platform::GetGpuLaunchConfig1D(ctx, h.total_stripe_count); if (pooltype == "MAX" || pooltype == "MIN") { hipLaunchKernelGGL(( SegmentIndexGradKernel<T, Index, ArrangeHelper<Index>>), dim3(config.block_per_grid.x), dim3(config.thread_per_block.x), 0, ctx.stream(), segment_ids.data<Index>(), input.data<T>(), output.data<T>(), out_grad.data<T>(), in_grad->data<T>(), h); } else { PADDLE_THROW(platform::errors::InvalidArgument( "Unsupported segment pooling grad operation, Only MAX, MIN " "available, but got %s.", pooltype)); } } template <typename T> __global__ void SimpleDiv(T* x, const T* y, const int len, const int dim) { for (int i = blockIdx.x; i < len; i += gridDim.x) { __shared__ T y_i; auto base = i * dim; if (threadIdx.x == 0) { y_i = y[i]; } __syncthreads(); for (int j = threadIdx.x; j < dim; j += blockDim.x) { x[base + j] /= y_i; } } } template <typename T, typename IndexT> class SegmentPoolFunctor<platform::CUDADeviceContext, T, IndexT> { public: void operator()(const platform::CUDADeviceContext& ctx, const framework::Tensor& input, const framework::Tensor& segment_ids, framework::Tensor* output, framework::Tensor* summed_ids = nullptr, const std::string pooltype = "SUM") { if (pooltype == "MEAN") { // Sum the segment id num first T DimTileSize = 8; auto input_length_size = segment_ids.numel(); auto total_stripe_count = (input_length_size + DimTileSize - 1) / DimTileSize; auto config = platform::GetGpuLaunchConfig1D(ctx, total_stripe_count); hipLaunchKernelGGL(( SegmentSumIdsKernel< T, IndexT, IndexT(8)>), dim3(config.block_per_grid.x), dim3(config.thread_per_block.x), 0, ctx.stream(), segment_ids.data<IndexT>(), summed_ids->data<T>(), input_length_size, total_stripe_count); } auto h = ArrangeHelper<IndexT>(input.numel(), segment_ids.dims()[0], output->dims()[0]); auto config = platform::GetGpuLaunchConfig1D(ctx, h.total_stripe_count); if (pooltype == "MEAN") { hipLaunchKernelGGL(( SegmentMeanKernel< T, IndexT, IndexT(8)>), dim3(config.block_per_grid.x), dim3(config.thread_per_block.x), 0, ctx.stream(), segment_ids.data<IndexT>(), input.data<T>(), output->data<T>(), summed_ids->data<T>(), h.input_length_size, h.inner_dim_size, h.output_length_size, h.total_stripe_count); } else if (pooltype == "SUM") { SumPool<T> pool; hipLaunchKernelGGL(( SegmentOpsKernel< T, IndexT, ArrangeHelper<IndexT>, SumPool<T>>), dim3(config.block_per_grid.x), dim3(config.thread_per_block.x), 0, ctx.stream(), segment_ids.data<IndexT>(), input.data<T>(), output->data<T>(), h, pool); } else if (pooltype == "MAX") { MaxPool<T> pool; hipLaunchKernelGGL(( SegmentOpsKernel< T, IndexT, ArrangeHelper<IndexT>, MaxPool<T>>), dim3(config.block_per_grid.x), dim3(config.thread_per_block.x), 0, ctx.stream(), segment_ids.data<IndexT>(), input.data<T>(), output->data<T>(), h, pool); } else if (pooltype == "MIN") { MinPool<T> pool; hipLaunchKernelGGL(( SegmentOpsKernel< T, IndexT, ArrangeHelper<IndexT>, MinPool<T>>), dim3(config.block_per_grid.x), dim3(config.thread_per_block.x), 0, ctx.stream(), segment_ids.data<IndexT>(), input.data<T>(), output->data<T>(), h, pool); } else { PADDLE_THROW(platform::errors::InvalidArgument( "Unsupported segment pooling operation, Only MEAN, SUM, MAX, MIN " "available, but got %s.", pooltype)); } } }; template <typename T, typename IndexT> class SegmentPoolGradFunctor<platform::CUDADeviceContext, T, IndexT> { public: void operator()(const platform::CUDADeviceContext& context, const framework::Tensor& input, const framework::Tensor& output, const framework::Tensor& out_grad, const framework::Tensor& segments, framework::Tensor* in_grad, const framework::Tensor* summed_ids = nullptr, const std::string pooltype = "SUM") { if (pooltype == "MAX" || pooltype == "MIN") { SegmentPoolCUDAGradFunctor<T, IndexT>(context, input, segments, output, out_grad, in_grad, pooltype); } else if (pooltype == "MEAN") { framework::Tensor mean_grad; mean_grad.mutable_data<T>(input.dims(), context.GetPlace()); framework::TensorCopy(out_grad, context.GetPlace(), context, &mean_grad); int len = output.dims()[0]; int dim = output.numel() / len; auto config = platform::GetGpuLaunchConfig1D(context, len); hipLaunchKernelGGL(( SimpleDiv<T>), dim3(config.block_per_grid.x), dim3(config.thread_per_block.x), 0, context.stream(), mean_grad.data<T>(), summed_ids->data<T>(), len, dim); GPUGather<T, IndexT>(context, mean_grad, segments, in_grad); } else if (pooltype == "SUM") { GPUGather<T, IndexT>(context, out_grad, segments, in_grad); } else { PADDLE_THROW(platform::errors::InvalidArgument( "Unsupported segment pooling operation, Only MEAN, SUM, MAX, MIN " "available, but got %s.", pooltype)); } } }; using CUDA = paddle::platform::CUDADeviceContext; template class SegmentPoolFunctor<CUDA, float, int>; template class SegmentPoolFunctor<CUDA, float, int64_t>; template class SegmentPoolFunctor<CUDA, double, int>; template class SegmentPoolFunctor<CUDA, double, int64_t>; template class SegmentPoolGradFunctor<CUDA, float, int>; template class SegmentPoolGradFunctor<CUDA, float, int64_t>; template class SegmentPoolGradFunctor<CUDA, double, int>; template class SegmentPoolGradFunctor<CUDA, double, int64_t>; } // namespace operators } // namespace paddle
bc90bb7e039fadc91401a6461dabda0f1d378ab3.cu
/* Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include <algorithm> #include "paddle/fluid/operators/gather.cu.h" #include "paddle/fluid/operators/math/math_function.h" #include "paddle/fluid/operators/math/segment_pooling.h" #include "paddle/fluid/platform/device/gpu/gpu_launch_config.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h" namespace paddle { namespace operators { using Tensor = framework::Tensor; template <typename T, typename Index, int DimTileSize> __global__ void SegmentSumIdsKernel(const Index* segment_ids, T* summed_ids, const Index input_length_size, const Index total_stripe_count) { CUDA_KERNEL_LOOP(stripe_index, total_stripe_count) { const Index segment_offset = stripe_index; const Index dim_index_base = stripe_index * Index(DimTileSize); const Index actual_height = min(Index(DimTileSize), input_length_size - dim_index_base); Index first_segment_id = segment_ids[dim_index_base]; Index last_segment_id = -1; if (dim_index_base > 0) { last_segment_id = segment_ids[dim_index_base - 1]; } T sum = T(0); for (Index j = 0; j < actual_height; j++) { Index current_segment_id = segment_ids[dim_index_base + j]; PADDLE_ENFORCE(current_segment_id >= last_segment_id, "the segment ids should be sorted, but got " "segment_ids[%d]:%d > segment_ids[%d]:%d.", dim_index_base + j - 1, dim_index_base + j, last_segment_id, current_segment_id); if (current_segment_id > last_segment_id) { for (Index interval_id = last_segment_id + 1; interval_id < current_segment_id; ++interval_id) { *(summed_ids + interval_id) = 0; } if (j > 0) { if (last_segment_id == first_segment_id) { platform::CudaAtomicAdd(summed_ids + last_segment_id, sum); } else { *(summed_ids + last_segment_id) = sum; } sum = T(0); } } sum += T(1); last_segment_id = current_segment_id; } platform::CudaAtomicAdd(summed_ids + last_segment_id, sum); } } template <typename T, typename Index, int DimTileSize> __global__ void SegmentMeanKernel(const Index* segment_ids, const T* input, T* output, T* summed_ids, const Index input_length_size, const Index inner_dim_size, const Index output_length_size, const Index total_stripe_count) { CUDA_KERNEL_LOOP(stripe_index, total_stripe_count) { const Index segment_offset = stripe_index % inner_dim_size; const Index dim_index_base = stripe_index / inner_dim_size * Index(DimTileSize); const Index actual_height = min(Index(DimTileSize), input_length_size - dim_index_base); Index first_segment_id = segment_ids[dim_index_base]; Index last_segment_id = -1; if (dim_index_base > 0) { last_segment_id = segment_ids[dim_index_base - 1]; } T sum = T(0); for (Index j = 0; j < actual_height; j++) { Index current_segment_id = segment_ids[dim_index_base + j]; if (current_segment_id > last_segment_id) { // reset the interval value which do not have corresponding ids. for (Index interval_id = last_segment_id + 1; interval_id < current_segment_id; ++interval_id) { *(output + interval_id * inner_dim_size + segment_offset) = T(0); } if (j > 0) { Index output_index = last_segment_id * inner_dim_size + segment_offset; if (last_segment_id == first_segment_id) { platform::CudaAtomicAdd(output + output_index, sum / *(summed_ids + last_segment_id)); } else { *(output + output_index) = sum / *(summed_ids + last_segment_id); } sum = T(0); } } sum += input[(dim_index_base + j) * inner_dim_size + segment_offset]; last_segment_id = current_segment_id; } Index output_index = last_segment_id * inner_dim_size + segment_offset; platform::CudaAtomicAdd(output + output_index, sum / *(summed_ids + last_segment_id)); } } template <typename T, typename Index, typename Helper, typename Pool> __global__ void __launch_bounds__(1024, 1) SegmentOpsKernel(const Index* segment_ids, const T* input, T* output, Helper h, Pool pool) { CUDA_KERNEL_LOOP(stripe_index, h.total_stripe_count) { Index segment_offset, dim_index_base, actual_height; Index inner_dim_size = h.inner_dim_size; h.calculate(stripe_index, &segment_offset, &dim_index_base, &actual_height); T minmax = pool.initial(); Index first_segment_id = segment_ids[dim_index_base]; // -1 is for the start value when interval_id = 0 Index last_segment_id = -1; if (dim_index_base > 0) { last_segment_id = segment_ids[dim_index_base - 1]; } for (Index j = 0; j < actual_height; j++) { Index current_segment_id = segment_ids[dim_index_base + j]; // ensure the segment_ids is sorted. PADDLE_ENFORCE(current_segment_id >= last_segment_id, "The segment ids should be sorted, but got " "segment_ids[%d]:%d > segment_ids[%d]:%d.", dim_index_base + j - 1, dim_index_base + j, last_segment_id, current_segment_id); if (current_segment_id > last_segment_id) { // reset the interval value which do not have corresponding ids. for (Index interval_id = last_segment_id + 1; interval_id < current_segment_id; ++interval_id) { *(output + interval_id * inner_dim_size + segment_offset) = T(0); } // don't update result when j=0 if (j > 0) { const Index output_index = last_segment_id * inner_dim_size + segment_offset; if (last_segment_id == first_segment_id) { pool.atomic(output + output_index, minmax); } else { *(output + output_index) = minmax; } minmax = pool.initial(); } } pool.compute( input[(dim_index_base + j) * inner_dim_size + segment_offset], &minmax); last_segment_id = current_segment_id; } const Index output_index = last_segment_id * inner_dim_size + segment_offset; pool.atomic(output + output_index, minmax); } } template <typename T, typename Index, typename Helper> __global__ void SegmentIndexGradKernel(const Index* segment_ids, const T* input, const T* output, const T* out_grad, T* in_grad, Helper h) { CUDA_KERNEL_LOOP(stripe_index, h.total_stripe_count) { Index segment_offset, dim_index_base, actual_height; h.calculate(stripe_index, &segment_offset, &dim_index_base, &actual_height); for (Index j = 0; j < actual_height; j++) { Index current_segment_id = segment_ids[dim_index_base + j]; Index input_index = (dim_index_base + j) * h.inner_dim_size + segment_offset; Index output_index = current_segment_id * h.inner_dim_size + segment_offset; if (input[input_index] == output[output_index]) { in_grad[input_index] = out_grad[output_index]; } } } } template <class T> class MaxPool { public: DEVICE inline T initial() { return static_cast<T>(-FLT_MAX); } DEVICE inline void compute(const T& x, T* y) { *y = *y > x ? *y : x; } DEVICE inline T atomic(T* address, const T val) { return platform::CudaAtomicMax(address, val); } }; template <class T> class MinPool { public: DEVICE inline T initial() { return static_cast<T>(FLT_MAX); } DEVICE inline void compute(const T& x, T* y) { *y = *y < x ? *y : x; } DEVICE inline T atomic(T* address, const T val) { return platform::CudaAtomicMin(address, val); } }; template <class T> class SumPool { public: DEVICE inline T initial() { return static_cast<T>(0); } DEVICE inline void compute(const T& x, T* y) { *y = *y + x; } DEVICE inline T atomic(T* address, const T val) { return platform::CudaAtomicAdd(address, val); } }; template <class T> class ArrangeHelper { public: const T input_total_size; const T input_length_size; const T output_length_size; T inner_dim_size; T total_stripe_count; const T DimTileSize = 8; ArrangeHelper(T a, T b, T c) : input_total_size(a), input_length_size(b), output_length_size(c) { T input_outer_dim_num_stripe = (input_length_size + DimTileSize - 1) / DimTileSize; inner_dim_size = input_total_size / input_length_size; total_stripe_count = inner_dim_size * input_outer_dim_num_stripe; } DEVICE inline void calculate(T stripe_index, T* segment_offset, T* dim_index_base, T* actual_height) { *segment_offset = stripe_index % inner_dim_size; *dim_index_base = stripe_index / inner_dim_size * DimTileSize; *actual_height = min(DimTileSize, input_length_size - *dim_index_base); } }; template <typename T, typename Index> void SegmentPoolCUDAGradFunctor(const platform::CUDADeviceContext& ctx, const framework::Tensor& input, const framework::Tensor& segment_ids, const framework::Tensor& output, const framework::Tensor& out_grad, framework::Tensor* in_grad, const std::string pooltype = "SUM") { auto h = ArrangeHelper<Index>(input.numel(), segment_ids.dims()[0], output.dims()[0]); auto config = platform::GetGpuLaunchConfig1D(ctx, h.total_stripe_count); if (pooltype == "MAX" || pooltype == "MIN") { SegmentIndexGradKernel<T, Index, ArrangeHelper<Index>><<< config.block_per_grid.x, config.thread_per_block.x, 0, ctx.stream()>>>( segment_ids.data<Index>(), input.data<T>(), output.data<T>(), out_grad.data<T>(), in_grad->data<T>(), h); } else { PADDLE_THROW(platform::errors::InvalidArgument( "Unsupported segment pooling grad operation, Only MAX, MIN " "available, but got %s.", pooltype)); } } template <typename T> __global__ void SimpleDiv(T* x, const T* y, const int len, const int dim) { for (int i = blockIdx.x; i < len; i += gridDim.x) { __shared__ T y_i; auto base = i * dim; if (threadIdx.x == 0) { y_i = y[i]; } __syncthreads(); for (int j = threadIdx.x; j < dim; j += blockDim.x) { x[base + j] /= y_i; } } } template <typename T, typename IndexT> class SegmentPoolFunctor<platform::CUDADeviceContext, T, IndexT> { public: void operator()(const platform::CUDADeviceContext& ctx, const framework::Tensor& input, const framework::Tensor& segment_ids, framework::Tensor* output, framework::Tensor* summed_ids = nullptr, const std::string pooltype = "SUM") { if (pooltype == "MEAN") { // Sum the segment id num first T DimTileSize = 8; auto input_length_size = segment_ids.numel(); auto total_stripe_count = (input_length_size + DimTileSize - 1) / DimTileSize; auto config = platform::GetGpuLaunchConfig1D(ctx, total_stripe_count); SegmentSumIdsKernel< T, IndexT, IndexT(8)><<<config.block_per_grid.x, config.thread_per_block.x, 0, ctx.stream()>>>( segment_ids.data<IndexT>(), summed_ids->data<T>(), input_length_size, total_stripe_count); } auto h = ArrangeHelper<IndexT>(input.numel(), segment_ids.dims()[0], output->dims()[0]); auto config = platform::GetGpuLaunchConfig1D(ctx, h.total_stripe_count); if (pooltype == "MEAN") { SegmentMeanKernel< T, IndexT, IndexT(8)><<<config.block_per_grid.x, config.thread_per_block.x, 0, ctx.stream()>>>( segment_ids.data<IndexT>(), input.data<T>(), output->data<T>(), summed_ids->data<T>(), h.input_length_size, h.inner_dim_size, h.output_length_size, h.total_stripe_count); } else if (pooltype == "SUM") { SumPool<T> pool; SegmentOpsKernel< T, IndexT, ArrangeHelper<IndexT>, SumPool<T>><<<config.block_per_grid.x, config.thread_per_block.x, 0, ctx.stream()>>>(segment_ids.data<IndexT>(), input.data<T>(), output->data<T>(), h, pool); } else if (pooltype == "MAX") { MaxPool<T> pool; SegmentOpsKernel< T, IndexT, ArrangeHelper<IndexT>, MaxPool<T>><<<config.block_per_grid.x, config.thread_per_block.x, 0, ctx.stream()>>>(segment_ids.data<IndexT>(), input.data<T>(), output->data<T>(), h, pool); } else if (pooltype == "MIN") { MinPool<T> pool; SegmentOpsKernel< T, IndexT, ArrangeHelper<IndexT>, MinPool<T>><<<config.block_per_grid.x, config.thread_per_block.x, 0, ctx.stream()>>>(segment_ids.data<IndexT>(), input.data<T>(), output->data<T>(), h, pool); } else { PADDLE_THROW(platform::errors::InvalidArgument( "Unsupported segment pooling operation, Only MEAN, SUM, MAX, MIN " "available, but got %s.", pooltype)); } } }; template <typename T, typename IndexT> class SegmentPoolGradFunctor<platform::CUDADeviceContext, T, IndexT> { public: void operator()(const platform::CUDADeviceContext& context, const framework::Tensor& input, const framework::Tensor& output, const framework::Tensor& out_grad, const framework::Tensor& segments, framework::Tensor* in_grad, const framework::Tensor* summed_ids = nullptr, const std::string pooltype = "SUM") { if (pooltype == "MAX" || pooltype == "MIN") { SegmentPoolCUDAGradFunctor<T, IndexT>(context, input, segments, output, out_grad, in_grad, pooltype); } else if (pooltype == "MEAN") { framework::Tensor mean_grad; mean_grad.mutable_data<T>(input.dims(), context.GetPlace()); framework::TensorCopy(out_grad, context.GetPlace(), context, &mean_grad); int len = output.dims()[0]; int dim = output.numel() / len; auto config = platform::GetGpuLaunchConfig1D(context, len); SimpleDiv<T><<<config.block_per_grid.x, config.thread_per_block.x, 0, context.stream()>>>(mean_grad.data<T>(), summed_ids->data<T>(), len, dim); GPUGather<T, IndexT>(context, mean_grad, segments, in_grad); } else if (pooltype == "SUM") { GPUGather<T, IndexT>(context, out_grad, segments, in_grad); } else { PADDLE_THROW(platform::errors::InvalidArgument( "Unsupported segment pooling operation, Only MEAN, SUM, MAX, MIN " "available, but got %s.", pooltype)); } } }; using CUDA = paddle::platform::CUDADeviceContext; template class SegmentPoolFunctor<CUDA, float, int>; template class SegmentPoolFunctor<CUDA, float, int64_t>; template class SegmentPoolFunctor<CUDA, double, int>; template class SegmentPoolFunctor<CUDA, double, int64_t>; template class SegmentPoolGradFunctor<CUDA, float, int>; template class SegmentPoolGradFunctor<CUDA, float, int64_t>; template class SegmentPoolGradFunctor<CUDA, double, int>; template class SegmentPoolGradFunctor<CUDA, double, int64_t>; } // namespace operators } // namespace paddle
10f9af54de14578664a8842516d4f75d7259c9cb.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include "g_de.cuh" /* * Device code */ //Kernel to initialize particles //Uses cuRAND to generate pseudorandom numbers on the GPU //<<<max_particles, dims>>> __global__ void Initialize(unsigned long long seed, float *d_pos, hiprandState_t *d_states, float const *d_xmin, float const *d_xmax) { int index = blockDim.x * blockIdx.x + threadIdx.x; //Adjust d_pos d_pos[index] = d_xmin[threadIdx.x] + (d_xmax[threadIdx.x] - d_xmin[threadIdx.x]) * d_pos[index]; //if (threadIdx.x == 9) //printf("%.2f\n", d_pos[index]); //Initializing up cuRAND //Each thread gets a different seed, different sequence number and no offset //hiprand_init(index, index, 0, &d_states[index]); //Each thread gets one seed every run, but different sequence //number; the seed is also different in different run if (index < max_particles) hiprand_init(seed, index, 0, &d_states[index]); } /* Calculate the fitness function for each particle */ __global__ void FitnessCalculate(float *d_pos, float *fitness, float const *d_inVector, float const *d_zern, const int dims, const int pixel_num) { int index = blockDim.x * blockIdx.x + threadIdx.x; //particle index float tp_fitness = 0.0f; /* index: particle index d_zern: pixel_num * dims [store in this way (pixel1, pixel2, pixel3, ..., pixel_pixel_num)_dim1, (pixel1, pixel2, pixel3, ..., pixel_pixel_num)_dim2, ...] d_inVector: [store in this way (pixel1, pixel2, pixel3, ..., pixel_pixel_num)_image1, (pixel1, pixel2, pixel3, ..., pixel_pixel_num)_image2] d_pos: [store in this way (dim1, dim2, dim3, ...)_particle1, (dim1, dim2, dim3, ...)_particle2, ...] */ float phi; float delta; float tp1, tp2; for (int i = 0; i < pixel_num; ++i) { phi = 0.0f; delta = d_pos[index * dims + dims - 1]; for (int j = 0; j < dims - 1; ++j) { phi += d_zern[j * pixel_num + i] * d_pos[index * dims + j]; } //tp_fitness += abs(cos(phi) - d_inVector[i]) + abs(cos(phi + delta) - d_inVector[pixel_num + i]); tp1 = cos(phi) - d_inVector[i]; tp2 = cos(phi + delta) - d_inVector[pixel_num + i]; tp_fitness += tp1 * tp1 + tp2 * tp2; } fitness[index] = tp_fitness; //printf("index: %d, fitness: %.2f\n", index, fitness[index]); /*Test if (index == 0) { float tp_result = 0.0f; //float tp_pos[] = { 0.4820f, -0.2068f, 1.1224f, -0.0914f, 0.0067f, -9.5738f, -0.0742f, 0.0980f, 0.0987f, -0.0152f, 0.0301f }; float tp_pos[] = { 0.479791f, -0.174059f, 1.09441f, 0.0210509f, 0.0434665f, - 9.51595f, - 0.0642395f, 0.0921565f, 0.0961314f, 0.0441319f, 0.0345671f }; for (int i = 0; i < pixel_num; ++i) { phi = 0.0f; delta = tp_pos[dims - 1]; for (int j = 0; j < dims - 1; ++j) { phi += d_zern[j * pixel_num + i] * tp_pos[j]; } //tp_result += abs(cos(phi) - d_inVector[i]) + abs(cos(phi + delta) - d_inVector[pixel_num + i]); tp_result += (cos(phi) - d_inVector[i]) * (cos(phi) - d_inVector[i]) + (cos(phi + delta) - d_inVector[pixel_num + i]) * (cos(phi + delta) - d_inVector[pixel_num + i]); } printf("%f", tp_result); } */ } /* Kernel to obtain the min fitness and corresponding index in each block; the min of each block are placed at the first blockIdx.x positions. ( 1. << <max_particles / 32, 32 >> > 2. << < 1, max_particles / 32 >> >) */ __global__ void ReduceFitnessMin(float *d_fitness, int *d_best_fitness_index, const int step) { int index = blockDim.x * blockIdx.x + threadIdx.x; int tx = threadIdx.x; //Declare shared memory for staging the reduce phase __shared__ float stage[512]; //max particles number: 512 * 32 __shared__ int best[512]; //Copy PBestY to shared memory if (step == 1) { best[tx] = index; } else { best[tx] = d_best_fitness_index[index]; } stage[tx] = d_fitness[index]; __syncthreads(); //Perform the actual reduce for (unsigned int s = blockDim.x / 2; s > 0; s >>= 1) { if (tx < s) { if (stage[tx] > stage[tx + s]) { stage[tx] = stage[tx + s]; best[tx] = best[tx + s]; } } __syncthreads(); } //Copy results back into global memory if (tx == 0) { d_fitness[blockIdx.x] = stage[0]; d_best_fitness_index[blockIdx.x] = best[0]; } } /* Kernel to generate the random integers in the DE */ __device__ int RandomInteger(hiprandState_t *state, const int min_rand_int, const int max_rand_int) { float rand_f = hiprand_uniform(state); rand_f *= (max_rand_int - min_rand_int + 0.999999); rand_f += min_rand_int; return (int)truncf(rand_f); } /* Calculate fitness for a single trail */ __device__ void TrailFitnessCalculate(float *d_trail, float *fitness_trail, float const *d_inVector, float const *d_zern, const int dims, const int pixel_num) { float tp_fitness = 0.0f; float phi; float delta; float tp1, tp2; for (int i = 0; i < pixel_num; ++i) { phi = 0.0f; delta = d_trail[dims - 1]; for (int j = 0; j < dims - 1; ++j) { phi += d_zern[j * pixel_num + i] * d_trail[j]; } //tp_fitness += abs(cos(phi) - d_inVector[i]) + abs(cos(phi + delta) - d_inVector[pixel_num + i]); tp1 = cos(phi) - d_inVector[i]; tp2 = cos(phi + delta) - d_inVector[pixel_num + i]; tp_fitness += tp1 * tp1 + tp2 * tp2; } *fitness_trail = tp_fitness; } /* d_zern: pixel_num * dims [store in this way (pixel1, pixel2, pixel3, ..., pixel_pixel_num)_dim1, (pixel1, pixel2, pixel3, ..., pixel_pixel_num)_dim2, ...)] */ //<<<max_particles/32, 32>>> __global__ void Iterate(float *d_pos, hiprandState_t *d_states, float *d_fitness, float *d_trails, float *d_trail_fitness, float const *d_inVector, float const *d_zern, float const *d_xmin, float const *d_xmax, const int dims, const int pixel_num) { //parameters int index = blockDim.x * blockIdx.x + threadIdx.x; //particle index hiprandState_t &local_state = d_states[index]; const float difference_factor = 0.6f; const float crossover_rate = 0.5f; float F = difference_factor * hiprand_uniform(&local_state); //Choose 3 distinct particles (!= index) (range: [0, max_particles-1] int r0, r1, r2; r0 = RandomInteger(&local_state, 0, max_particles - 1); r1 = RandomInteger(&local_state, 0, max_particles - 1); r2 = RandomInteger(&local_state, 0, max_particles - 1); while (r0 == index || r1 == index || r2 == index || r0 == r1 || r0 == r2 || r1 == r2) { r0 = RandomInteger(&local_state, 0, max_particles - 1); r1 = RandomInteger(&local_state, 0, max_particles - 1); r2 = RandomInteger(&local_state, 0, max_particles - 1); } //Mutation and crossover loops for (int k = 0; k < dims; ++k) { d_trails[index * dims + k] = d_pos[index * dims + k]; } int j = RandomInteger(&local_state, 0, dims - 1); for (int k = 0; k < dims; ++k) { if (hiprand_uniform(&local_state) <= crossover_rate || k == j) { d_trails[index * dims + k] = d_pos[r0 * dims + k] + F * (d_pos[r1 * dims + k] - d_pos[r2 * dims + k]); //if (blockIdx.x == 0 && threadIdx.x == 0) { //printf("k = %d, j = %d\n", k, j); //} if (d_trails[index * dims + k] > d_xmax[k] || d_trails[index * dims + k] < d_xmin[k]) //re-initialization d_trails[index * dims + k] = d_xmin[k] + hiprand_uniform(&local_state) * (d_xmax[k] - d_xmin[k]); } } //Fitness calculation of the trail and update d_pos if trail is better float fitness_trail; TrailFitnessCalculate(&(d_trails[index * dims]), &fitness_trail, d_inVector, d_zern, dims, pixel_num); //bool accepted_flag = false; if (fitness_trail <= d_fitness[index]) { //trail accepted //accepted_flag = true; d_trail_fitness[index] = fitness_trail; d_fitness[index] = fitness_trail; } else d_trail_fitness[index] = inf; //printf("accepted? %d, %d, d_fitness[%d] = %.2f, d_trail_fitness[%d] = %.2f\n", accepted_flag, d_fitness[index] == d_trail_fitness[index],index, d_fitness[index], index, d_trail_fitness[index]); ////Set the current state of the PRNG //d_states[index] = local_state; } __global__ void PosUpdate(float *d_pos, const float *d_trails, const float *d_trail_fitness, const float *d_xmax, const float *d_xmin, const int dims) { int index = blockIdx.x * blockDim.x + threadIdx.x; if (d_trail_fitness[index] < inf) { for (int k = 0; k < dims; ++k) { d_pos[index * dims + k] = d_trails[index * dims + k]; //Ensure position values are within range if (d_pos[index * dims + k] > d_xmax[k]) d_pos[index * dims + k] = d_xmax[k]; if (d_pos[index * dims + k] < d_xmin[k]) d_pos[index * dims + k] = d_xmin[k]; } } } void DE(const float * const in_vector, const float * const xmin, const float * const xmax, const float * const zern, const float &crossover_rate, const float &difference_factor, const int pixel_num, const int dims, float *g_best, float *g_best_pos, bool iter_option, float &time_use, std::vector<float> &fit_rec, std::vector<float> &iter_rec) { //GPU memory allocation float const *d_inVector; float const *d_zern; float const *d_xmin; float const *d_xmax; hipMalloc((void**)&d_inVector, 2 * pixel_num * sizeof(float)); hipMemcpy((void*)d_inVector, (void*)in_vector, 2 * pixel_num * sizeof(float), hipMemcpyHostToDevice); hipMalloc((void**)&d_zern, (dims - 1) * pixel_num * sizeof(float)); hipMemcpy((void*)d_zern, (void*)zern, (dims - 1) * pixel_num * sizeof(float), hipMemcpyHostToDevice); hipMalloc((void**)&d_xmin, dims * sizeof(float)); hipMemcpy((void*)d_xmin, (void*)xmin, dims * sizeof(float), hipMemcpyHostToDevice); hipMalloc((void**)&d_xmax, dims * sizeof(float)); hipMemcpy((void*)d_xmax, (void*)xmax, dims * sizeof(float), hipMemcpyHostToDevice); float *d_pos; hiprandState_t *d_states; float *d_fitness; int *d_best_fitness_index; hipMalloc((void**)&d_pos, max_particles * dims * sizeof(float)); //hipMalloc((void**)&d_states, max_particles * dims * sizeof(hiprandState_t)); hipMalloc((void**)&d_states, max_particles * sizeof(hiprandState_t)); hipMalloc((void**)&d_fitness, max_particles * sizeof(float)); hipMalloc((void**)&d_best_fitness_index, max_particles * sizeof(int)); //Initialize d_pos and d_states hiprandGenerator_t gen; hiprandCreateGenerator(&gen, HIPRAND_RNG_PSEUDO_DEFAULT); hiprandSetPseudoRandomGeneratorSeed(gen, time(NULL)); hiprandGenerateUniform(gen, d_pos, max_particles * dims); hiprandDestroyGenerator(gen); //Adjust the d_pos //Generate the different seeds every time std::random_device rd; std::mt19937_64 eng(rd()); std::uniform_int_distribution<unsigned long long> distr; unsigned long long seed = distr(eng); Initialize << <max_particles, dims >> > (seed, d_pos, d_states, d_xmin, d_xmax); //Initialize d_fitness, g_best, g_best_pos FitnessCalculate << <max_particles / 32, 32 >> > (d_pos, d_fitness, d_inVector, d_zern, dims, pixel_num); // Calculate the fitness for each particle float *tp_d_fitness; hipMalloc((void**)&tp_d_fitness, max_particles * sizeof(float)); hipMemcpy(tp_d_fitness, d_fitness, max_particles * sizeof(float), hipMemcpyDeviceToDevice); ReduceFitnessMin << <max_particles / 32, 32 >> > (tp_d_fitness, d_best_fitness_index, 1); ReduceFitnessMin << <1, max_particles / 32 >> > (tp_d_fitness, d_best_fitness_index, 2); int g_best_index; hipMemcpy(g_best, tp_d_fitness, sizeof(float), hipMemcpyDeviceToHost); hipMemcpy(&g_best_index, d_best_fitness_index, sizeof(int), hipMemcpyDeviceToHost); hipMemcpy(g_best_pos, &(d_pos[g_best_index * dims]), dims * sizeof(float), hipMemcpyDeviceToHost); hipFree((void *) tp_d_fitness); hipFree((void *) d_best_fitness_index); //Iteration float *best_with_change = new float[1000]; //record the g_best change int count_best_with_change = 0; const int NE = 10; //Termination criteria const float TOLFUN = 0.001f; //Tolerance of the fitness change std::chrono::duration<double> elapsed_seconds_from_start; float *trail_fitness = new float[max_particles]; float *d_trail_fitness; float *d_trails; hipMalloc((void**)&d_trail_fitness, max_particles * sizeof(float)); hipMalloc((void**)&d_trails, dims * max_particles * sizeof(float)); auto t_start = std::chrono::system_clock::now();//variables for time record for (int i = 0; i < max_iters; ++i) { //i //auto t_start_i = std::chrono::system_clock::now(); //DE for each particles to obtain the trail and //d_trail_fitness, which records the fitness of the trail of each particles (= inf //if the trail is not accepted); it is then used for updating the best and best_pos. //printf("i = %d\n", i); Iterate << <max_particles / 32, 32 >> > (d_pos, d_states, d_fitness, d_trails, d_trail_fitness, d_inVector, d_zern, d_xmin, d_xmax, dims, pixel_num); //Kernel for updating the d_pos according to the d_trail_fitness (<inf means accepted) PosUpdate << <max_particles / 32, 32 >> > (d_pos, d_trails, d_trail_fitness, d_xmax, d_xmin, dims); // Wait for GPU to finish before accessing on host hipDeviceSynchronize(); hipMemcpy(trail_fitness, d_trail_fitness, max_particles * sizeof(float), hipMemcpyDeviceToHost); //update g_best and g_best_pos by comparing each accepted trail (<= inf) int tp_min_index; bool updated_flag = false; //flag shows whether the g_best is updated by the accepted trails for (int index = 0; index < max_particles; ++index) { if (trail_fitness[index] <= *g_best && trail_fitness[index] < inf) { *g_best = trail_fitness[index]; best_with_change[count_best_with_change++] = trail_fitness[index]; tp_min_index = index; updated_flag = true; fit_rec.push_back(*g_best); iter_rec.push_back(i); printf("Changed best: %.3f, index: %d, iter: %d\n", *g_best, count_best_with_change - 1, i); } } if (updated_flag) hipMemcpy(g_best_pos, &(d_pos[tp_min_index * dims]), dims * sizeof(float), hipMemcpyDeviceToHost); //auto t_end_i = std::chrono::system_clock::now(); //elapsed_seconds_from_start = t_end_i - t_start; //elapsed_seconds_from_start_i = t_end_i - t_start_i; //std::cout << "###########" << std::endl << "Iteration number: " << i << //", time for the iteration (s): " << elapsed_seconds_from_start_i.count() //<< ", time since beginning of iteration (s): " //<< elapsed_seconds_from_start.count() << std::endl << "###########" << std::endl; //Check the termination criterion if ( (!iter_option) && count_best_with_change > NE && abs(best_with_change[count_best_with_change - 1] - best_with_change[count_best_with_change - 1 - NE]) < TOLFUN) { break; } } hipDeviceSynchronize(); auto t_end_i = std::chrono::system_clock::now(); elapsed_seconds_from_start = t_end_i - t_start; std::cout << "*******" << std::endl << "Time for the iteration(s): " << elapsed_seconds_from_start.count() << std::endl << "********" << std::endl; time_use = elapsed_seconds_from_start.count(); //Clean hipFree((void *) d_inVector); hipFree((void *) d_zern); hipFree((void *) d_xmin); hipFree((void *) d_xmax); hipFree((void *) d_pos); hipFree((void *) d_states); hipFree((void *) d_fitness); delete[] best_with_change; delete[] trail_fitness; hipFree((void *) d_trail_fitness); hipFree((void *)d_trails); }
10f9af54de14578664a8842516d4f75d7259c9cb.cu
#include "g_de.cuh" /* * Device code */ //Kernel to initialize particles //Uses cuRAND to generate pseudorandom numbers on the GPU //<<<max_particles, dims>>> __global__ void Initialize(unsigned long long seed, float *d_pos, curandState *d_states, float const *d_xmin, float const *d_xmax) { int index = blockDim.x * blockIdx.x + threadIdx.x; //Adjust d_pos d_pos[index] = d_xmin[threadIdx.x] + (d_xmax[threadIdx.x] - d_xmin[threadIdx.x]) * d_pos[index]; //if (threadIdx.x == 9) //printf("%.2f\n", d_pos[index]); //Initializing up cuRAND //Each thread gets a different seed, different sequence number and no offset //curand_init(index, index, 0, &d_states[index]); //Each thread gets one seed every run, but different sequence //number; the seed is also different in different run if (index < max_particles) curand_init(seed, index, 0, &d_states[index]); } /* Calculate the fitness function for each particle */ __global__ void FitnessCalculate(float *d_pos, float *fitness, float const *d_inVector, float const *d_zern, const int dims, const int pixel_num) { int index = blockDim.x * blockIdx.x + threadIdx.x; //particle index float tp_fitness = 0.0f; /* index: particle index d_zern: pixel_num * dims [store in this way (pixel1, pixel2, pixel3, ..., pixel_pixel_num)_dim1, (pixel1, pixel2, pixel3, ..., pixel_pixel_num)_dim2, ...] d_inVector: [store in this way (pixel1, pixel2, pixel3, ..., pixel_pixel_num)_image1, (pixel1, pixel2, pixel3, ..., pixel_pixel_num)_image2] d_pos: [store in this way (dim1, dim2, dim3, ...)_particle1, (dim1, dim2, dim3, ...)_particle2, ...] */ float phi; float delta; float tp1, tp2; for (int i = 0; i < pixel_num; ++i) { phi = 0.0f; delta = d_pos[index * dims + dims - 1]; for (int j = 0; j < dims - 1; ++j) { phi += d_zern[j * pixel_num + i] * d_pos[index * dims + j]; } //tp_fitness += abs(cos(phi) - d_inVector[i]) + abs(cos(phi + delta) - d_inVector[pixel_num + i]); tp1 = cos(phi) - d_inVector[i]; tp2 = cos(phi + delta) - d_inVector[pixel_num + i]; tp_fitness += tp1 * tp1 + tp2 * tp2; } fitness[index] = tp_fitness; //printf("index: %d, fitness: %.2f\n", index, fitness[index]); /*Test if (index == 0) { float tp_result = 0.0f; //float tp_pos[] = { 0.4820f, -0.2068f, 1.1224f, -0.0914f, 0.0067f, -9.5738f, -0.0742f, 0.0980f, 0.0987f, -0.0152f, 0.0301f }; float tp_pos[] = { 0.479791f, -0.174059f, 1.09441f, 0.0210509f, 0.0434665f, - 9.51595f, - 0.0642395f, 0.0921565f, 0.0961314f, 0.0441319f, 0.0345671f }; for (int i = 0; i < pixel_num; ++i) { phi = 0.0f; delta = tp_pos[dims - 1]; for (int j = 0; j < dims - 1; ++j) { phi += d_zern[j * pixel_num + i] * tp_pos[j]; } //tp_result += abs(cos(phi) - d_inVector[i]) + abs(cos(phi + delta) - d_inVector[pixel_num + i]); tp_result += (cos(phi) - d_inVector[i]) * (cos(phi) - d_inVector[i]) + (cos(phi + delta) - d_inVector[pixel_num + i]) * (cos(phi + delta) - d_inVector[pixel_num + i]); } printf("%f", tp_result); } */ } /* Kernel to obtain the min fitness and corresponding index in each block; the min of each block are placed at the first blockIdx.x positions. ( 1. << <max_particles / 32, 32 >> > 2. << < 1, max_particles / 32 >> >) */ __global__ void ReduceFitnessMin(float *d_fitness, int *d_best_fitness_index, const int step) { int index = blockDim.x * blockIdx.x + threadIdx.x; int tx = threadIdx.x; //Declare shared memory for staging the reduce phase __shared__ float stage[512]; //max particles number: 512 * 32 __shared__ int best[512]; //Copy PBestY to shared memory if (step == 1) { best[tx] = index; } else { best[tx] = d_best_fitness_index[index]; } stage[tx] = d_fitness[index]; __syncthreads(); //Perform the actual reduce for (unsigned int s = blockDim.x / 2; s > 0; s >>= 1) { if (tx < s) { if (stage[tx] > stage[tx + s]) { stage[tx] = stage[tx + s]; best[tx] = best[tx + s]; } } __syncthreads(); } //Copy results back into global memory if (tx == 0) { d_fitness[blockIdx.x] = stage[0]; d_best_fitness_index[blockIdx.x] = best[0]; } } /* Kernel to generate the random integers in the DE */ __device__ int RandomInteger(curandState *state, const int min_rand_int, const int max_rand_int) { float rand_f = curand_uniform(state); rand_f *= (max_rand_int - min_rand_int + 0.999999); rand_f += min_rand_int; return (int)truncf(rand_f); } /* Calculate fitness for a single trail */ __device__ void TrailFitnessCalculate(float *d_trail, float *fitness_trail, float const *d_inVector, float const *d_zern, const int dims, const int pixel_num) { float tp_fitness = 0.0f; float phi; float delta; float tp1, tp2; for (int i = 0; i < pixel_num; ++i) { phi = 0.0f; delta = d_trail[dims - 1]; for (int j = 0; j < dims - 1; ++j) { phi += d_zern[j * pixel_num + i] * d_trail[j]; } //tp_fitness += abs(cos(phi) - d_inVector[i]) + abs(cos(phi + delta) - d_inVector[pixel_num + i]); tp1 = cos(phi) - d_inVector[i]; tp2 = cos(phi + delta) - d_inVector[pixel_num + i]; tp_fitness += tp1 * tp1 + tp2 * tp2; } *fitness_trail = tp_fitness; } /* d_zern: pixel_num * dims [store in this way (pixel1, pixel2, pixel3, ..., pixel_pixel_num)_dim1, (pixel1, pixel2, pixel3, ..., pixel_pixel_num)_dim2, ...)] */ //<<<max_particles/32, 32>>> __global__ void Iterate(float *d_pos, curandState *d_states, float *d_fitness, float *d_trails, float *d_trail_fitness, float const *d_inVector, float const *d_zern, float const *d_xmin, float const *d_xmax, const int dims, const int pixel_num) { //parameters int index = blockDim.x * blockIdx.x + threadIdx.x; //particle index curandState &local_state = d_states[index]; const float difference_factor = 0.6f; const float crossover_rate = 0.5f; float F = difference_factor * curand_uniform(&local_state); //Choose 3 distinct particles (!= index) (range: [0, max_particles-1] int r0, r1, r2; r0 = RandomInteger(&local_state, 0, max_particles - 1); r1 = RandomInteger(&local_state, 0, max_particles - 1); r2 = RandomInteger(&local_state, 0, max_particles - 1); while (r0 == index || r1 == index || r2 == index || r0 == r1 || r0 == r2 || r1 == r2) { r0 = RandomInteger(&local_state, 0, max_particles - 1); r1 = RandomInteger(&local_state, 0, max_particles - 1); r2 = RandomInteger(&local_state, 0, max_particles - 1); } //Mutation and crossover loops for (int k = 0; k < dims; ++k) { d_trails[index * dims + k] = d_pos[index * dims + k]; } int j = RandomInteger(&local_state, 0, dims - 1); for (int k = 0; k < dims; ++k) { if (curand_uniform(&local_state) <= crossover_rate || k == j) { d_trails[index * dims + k] = d_pos[r0 * dims + k] + F * (d_pos[r1 * dims + k] - d_pos[r2 * dims + k]); //if (blockIdx.x == 0 && threadIdx.x == 0) { //printf("k = %d, j = %d\n", k, j); //} if (d_trails[index * dims + k] > d_xmax[k] || d_trails[index * dims + k] < d_xmin[k]) //re-initialization d_trails[index * dims + k] = d_xmin[k] + curand_uniform(&local_state) * (d_xmax[k] - d_xmin[k]); } } //Fitness calculation of the trail and update d_pos if trail is better float fitness_trail; TrailFitnessCalculate(&(d_trails[index * dims]), &fitness_trail, d_inVector, d_zern, dims, pixel_num); //bool accepted_flag = false; if (fitness_trail <= d_fitness[index]) { //trail accepted //accepted_flag = true; d_trail_fitness[index] = fitness_trail; d_fitness[index] = fitness_trail; } else d_trail_fitness[index] = inf; //printf("accepted? %d, %d, d_fitness[%d] = %.2f, d_trail_fitness[%d] = %.2f\n", accepted_flag, d_fitness[index] == d_trail_fitness[index],index, d_fitness[index], index, d_trail_fitness[index]); ////Set the current state of the PRNG //d_states[index] = local_state; } __global__ void PosUpdate(float *d_pos, const float *d_trails, const float *d_trail_fitness, const float *d_xmax, const float *d_xmin, const int dims) { int index = blockIdx.x * blockDim.x + threadIdx.x; if (d_trail_fitness[index] < inf) { for (int k = 0; k < dims; ++k) { d_pos[index * dims + k] = d_trails[index * dims + k]; //Ensure position values are within range if (d_pos[index * dims + k] > d_xmax[k]) d_pos[index * dims + k] = d_xmax[k]; if (d_pos[index * dims + k] < d_xmin[k]) d_pos[index * dims + k] = d_xmin[k]; } } } void DE(const float * const in_vector, const float * const xmin, const float * const xmax, const float * const zern, const float &crossover_rate, const float &difference_factor, const int pixel_num, const int dims, float *g_best, float *g_best_pos, bool iter_option, float &time_use, std::vector<float> &fit_rec, std::vector<float> &iter_rec) { //GPU memory allocation float const *d_inVector; float const *d_zern; float const *d_xmin; float const *d_xmax; cudaMalloc((void**)&d_inVector, 2 * pixel_num * sizeof(float)); cudaMemcpy((void*)d_inVector, (void*)in_vector, 2 * pixel_num * sizeof(float), cudaMemcpyHostToDevice); cudaMalloc((void**)&d_zern, (dims - 1) * pixel_num * sizeof(float)); cudaMemcpy((void*)d_zern, (void*)zern, (dims - 1) * pixel_num * sizeof(float), cudaMemcpyHostToDevice); cudaMalloc((void**)&d_xmin, dims * sizeof(float)); cudaMemcpy((void*)d_xmin, (void*)xmin, dims * sizeof(float), cudaMemcpyHostToDevice); cudaMalloc((void**)&d_xmax, dims * sizeof(float)); cudaMemcpy((void*)d_xmax, (void*)xmax, dims * sizeof(float), cudaMemcpyHostToDevice); float *d_pos; curandState *d_states; float *d_fitness; int *d_best_fitness_index; cudaMalloc((void**)&d_pos, max_particles * dims * sizeof(float)); //cudaMalloc((void**)&d_states, max_particles * dims * sizeof(curandState)); cudaMalloc((void**)&d_states, max_particles * sizeof(curandState)); cudaMalloc((void**)&d_fitness, max_particles * sizeof(float)); cudaMalloc((void**)&d_best_fitness_index, max_particles * sizeof(int)); //Initialize d_pos and d_states curandGenerator_t gen; curandCreateGenerator(&gen, CURAND_RNG_PSEUDO_DEFAULT); curandSetPseudoRandomGeneratorSeed(gen, time(NULL)); curandGenerateUniform(gen, d_pos, max_particles * dims); curandDestroyGenerator(gen); //Adjust the d_pos //Generate the different seeds every time std::random_device rd; std::mt19937_64 eng(rd()); std::uniform_int_distribution<unsigned long long> distr; unsigned long long seed = distr(eng); Initialize << <max_particles, dims >> > (seed, d_pos, d_states, d_xmin, d_xmax); //Initialize d_fitness, g_best, g_best_pos FitnessCalculate << <max_particles / 32, 32 >> > (d_pos, d_fitness, d_inVector, d_zern, dims, pixel_num); // Calculate the fitness for each particle float *tp_d_fitness; cudaMalloc((void**)&tp_d_fitness, max_particles * sizeof(float)); cudaMemcpy(tp_d_fitness, d_fitness, max_particles * sizeof(float), cudaMemcpyDeviceToDevice); ReduceFitnessMin << <max_particles / 32, 32 >> > (tp_d_fitness, d_best_fitness_index, 1); ReduceFitnessMin << <1, max_particles / 32 >> > (tp_d_fitness, d_best_fitness_index, 2); int g_best_index; cudaMemcpy(g_best, tp_d_fitness, sizeof(float), cudaMemcpyDeviceToHost); cudaMemcpy(&g_best_index, d_best_fitness_index, sizeof(int), cudaMemcpyDeviceToHost); cudaMemcpy(g_best_pos, &(d_pos[g_best_index * dims]), dims * sizeof(float), cudaMemcpyDeviceToHost); cudaFree((void *) tp_d_fitness); cudaFree((void *) d_best_fitness_index); //Iteration float *best_with_change = new float[1000]; //record the g_best change int count_best_with_change = 0; const int NE = 10; //Termination criteria const float TOLFUN = 0.001f; //Tolerance of the fitness change std::chrono::duration<double> elapsed_seconds_from_start; float *trail_fitness = new float[max_particles]; float *d_trail_fitness; float *d_trails; cudaMalloc((void**)&d_trail_fitness, max_particles * sizeof(float)); cudaMalloc((void**)&d_trails, dims * max_particles * sizeof(float)); auto t_start = std::chrono::system_clock::now();//variables for time record for (int i = 0; i < max_iters; ++i) { //i //auto t_start_i = std::chrono::system_clock::now(); //DE for each particles to obtain the trail and //d_trail_fitness, which records the fitness of the trail of each particles (= inf //if the trail is not accepted); it is then used for updating the best and best_pos. //printf("i = %d\n", i); Iterate << <max_particles / 32, 32 >> > (d_pos, d_states, d_fitness, d_trails, d_trail_fitness, d_inVector, d_zern, d_xmin, d_xmax, dims, pixel_num); //Kernel for updating the d_pos according to the d_trail_fitness (<inf means accepted) PosUpdate << <max_particles / 32, 32 >> > (d_pos, d_trails, d_trail_fitness, d_xmax, d_xmin, dims); // Wait for GPU to finish before accessing on host cudaDeviceSynchronize(); cudaMemcpy(trail_fitness, d_trail_fitness, max_particles * sizeof(float), cudaMemcpyDeviceToHost); //update g_best and g_best_pos by comparing each accepted trail (<= inf) int tp_min_index; bool updated_flag = false; //flag shows whether the g_best is updated by the accepted trails for (int index = 0; index < max_particles; ++index) { if (trail_fitness[index] <= *g_best && trail_fitness[index] < inf) { *g_best = trail_fitness[index]; best_with_change[count_best_with_change++] = trail_fitness[index]; tp_min_index = index; updated_flag = true; fit_rec.push_back(*g_best); iter_rec.push_back(i); printf("Changed best: %.3f, index: %d, iter: %d\n", *g_best, count_best_with_change - 1, i); } } if (updated_flag) cudaMemcpy(g_best_pos, &(d_pos[tp_min_index * dims]), dims * sizeof(float), cudaMemcpyDeviceToHost); //auto t_end_i = std::chrono::system_clock::now(); //elapsed_seconds_from_start = t_end_i - t_start; //elapsed_seconds_from_start_i = t_end_i - t_start_i; //std::cout << "###########" << std::endl << "Iteration number: " << i << //", time for the iteration (s): " << elapsed_seconds_from_start_i.count() //<< ", time since beginning of iteration (s): " //<< elapsed_seconds_from_start.count() << std::endl << "###########" << std::endl; //Check the termination criterion if ( (!iter_option) && count_best_with_change > NE && abs(best_with_change[count_best_with_change - 1] - best_with_change[count_best_with_change - 1 - NE]) < TOLFUN) { break; } } cudaDeviceSynchronize(); auto t_end_i = std::chrono::system_clock::now(); elapsed_seconds_from_start = t_end_i - t_start; std::cout << "*******" << std::endl << "Time for the iteration(s): " << elapsed_seconds_from_start.count() << std::endl << "********" << std::endl; time_use = elapsed_seconds_from_start.count(); //Clean cudaFree((void *) d_inVector); cudaFree((void *) d_zern); cudaFree((void *) d_xmin); cudaFree((void *) d_xmax); cudaFree((void *) d_pos); cudaFree((void *) d_states); cudaFree((void *) d_fitness); delete[] best_with_change; delete[] trail_fitness; cudaFree((void *) d_trail_fitness); cudaFree((void *)d_trails); }
bc2ebb93d6988b22a5d723cd3da7878427286fd1.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include <stdio.h> __global__ void kernel( void ) { } int main( void ) { hipLaunchKernelGGL(( kernel), dim3(1),dim3(1), 0, 0, ); printf( "Hello, World!\n" ); return 0; }
bc2ebb93d6988b22a5d723cd3da7878427286fd1.cu
#include <stdio.h> __global__ void kernel( void ) { } int main( void ) { kernel<<<1,1>>>(); printf( "Hello, World!\n" ); return 0; }
bab2640445a9f09620b33adce6519b44fe291d05.hip
// !!! This is a file automatically generated by hipify!!! #include <math.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <hip/hip_runtime.h> #include <cusparse_v2.h> #include "rocblas.h" #include <hiprand/hiprand.h> #include <helper_functions.h> #include <helper_cuda.h> #include "mex.h" #include "kcDefs.h" //see for info on anything starting with KC_ #include "kcArrayFunctions.h" //poison log likelihood for one observation __device__ KC_FP_TYPE lh(KC_FP_TYPE y, KC_FP_TYPE x, KC_FP_TYPE g, KC_FP_TYPE dt, KC_FP_TYPE sh, KC_FP_TYPE bias, KC_FP_TYPE log_power) { KC_FP_TYPE logex = (g*x>100)?(g*x):KC_MIN(log1p(KC_EXP(x*g)),KC_MAXN); KC_FP_TYPE r = (KC_MIN(KC_POW(logex*1.0000000,log_power),KC_MAXN)+bias)*KC_EXP(sh); return y*(KC_LOG(r)+KC_LOG(dt)) - dt*r - KC_GAMMALN(y+1.0); } //sums up log likelihood of each trial given model parameters __global__ void kcSumGBfinal(const KC_FP_TYPE * log_p_tr, KC_FP_TYPE * log_p, const int NT) { int idx = blockDim.x * blockIdx.x + threadIdx.x; if(idx < 1) { log_p[0] = 0; for(int ii = 0; ii < NT; ii++) { log_p[0] += log_p_tr[ii]; } } } //averages log likelihood of each simulated path // (one thread for each trial) __global__ void kcSumGBlogpTr(const KC_FP_TYPE * log_p, KC_FP_TYPE * log_p_tr, const int NT, const int nSims) { int idx = blockIdx.x*blockDim.x+threadIdx.x; if(idx < NT) { log_p_tr[idx] = 0; KC_FP_TYPE trSum = 0; KC_FP_TYPE log_x = 0; log_p_tr[idx] = KC_SQRT(-1.0); //computes log( 1/nSims * \sum exp( log p(y | sim paths)) ) for a single trial // does the sum in a slightly more numerical stable way than just blindly exponentiating all the log likleihoods for(int ii = 0; ii < nSims && isnan(log_p_tr[idx]);ii++) { trSum = 1 ; log_x = log_p[ii*NT+idx]; for(int kk = 0; kk < ii; kk++) { trSum += KC_EXP(log_p[kk*NT+idx] - log_x); } for(int kk = ii+1; kk < nSims; kk++) { trSum += KC_EXP(log_p[kk*NT+idx] - log_x); } if(trSum > 1e-25 && !isnan(trSum) && !isinf(trSum)) { log_p_tr[idx] = log_x-KC_LOG((double)nSims)+KC_LOG(trSum); break; } } } } //simulates a ramping (diffusion-to-bound) path for each trial and computes likelihood __global__ void kcSimGBPaths(const KC_FP_TYPE * y, const int * trIdx, const int * betaIdx, KC_FP_TYPE * xx, const KC_FP_TYPE * b,const KC_FP_TYPE w2,const KC_FP_TYPE l_0, const KC_FP_TYPE g, const KC_FP_TYPE dt, KC_FP_TYPE * log_p, const int NT, const int TT, const int sim, KC_FP_TYPE * spe, KC_FP_TYPE bias, KC_FP_TYPE log_power) { int idx = blockIdx.x*blockDim.x+threadIdx.x; if(idx < NT ) { int trNum = idx; int T1 = trIdx[trNum]; //xx contains zero mean Gaussian noise of variance \omega^2 xx[T1] += l_0; //xx[T1] now contains initial point for simulated diffusion trajectory for this trial int currIdx = sim*(NT)+idx; log_p[currIdx] = lh(y[T1],xx[T1],g,dt,spe[T1],bias,log_power); for(int ii = T1+1; ii < trIdx[trNum+1];ii++) { //progates particle forward in time xx[ii] = (xx[ii-1] >= 1.0)?1.0:KC_MIN(xx[ii] + xx[ii-1]+b[betaIdx[ii]],1.0); //log likelihood of single observation (bin) y[ii] given diffusion path is at x[ii] log_p[currIdx] += lh(y[ii],xx[ii],g,dt,spe[ii],bias,log_power); } } } //Estimates the log probability of a set of spike trains under the ramping model given a set of fixed parameters // This estimation is made by Monte Carlo simulations from the model to integrate out latent variable //args // 0 = y (observations) // 1 = trIdx (array that accesses the beta value used at each timepoint, y being indexed at 0. Includes final value that should be length of y) // 2 = betaIdxVector (array that gives coherence used at each bins of y. i.e., accesses the beta value used at each timepoint. values begin at 0 instead of 1 to be consistent with C, unlike MATLAB) // 3 = spike history effect (same size as y) // 4 = beta values // 5 = w (variance of diffusion process) // 6 = l_0 (starting lambda value) // 7 = g (absorbing boundary effective height) // 8 = dt (bin size in seconds) // 9 = number of samples to use to estimate log probability of observations (I recommend using at least 1000) // 10 = bias // 11 = power //outputs (left-hand side) // 0 = log p(y|\theta) // 1 = log p(y|\theta) for each individual trial void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { hipError_t ce; //load up trial data unsigned int TT = kcGetArrayNumEl(prhs[0]); KC_FP_TYPE * y = kcGetArrayData(prhs[0]); int * trIdx = kcGetArrayDataInt(prhs[1]); unsigned int NT = kcGetArrayNumEl(prhs[1])-1; int * betaIdx = kcGetArrayDataInt(prhs[2],TT); // load spike history effect KC_FP_TYPE * spe = kcGetArrayData(prhs[3]); //how many simulations to use to estimate log p(y|\theta) int trialsToSim = (int)mxGetScalar(prhs[9]); //load up parameters to simulate model if(mxGetClassID(prhs[4]) != KC_FP_TYPE_MATLAB) { mexErrMsgTxt("Beta input wrong floating point type (kcSimGaussianBound)!"); } KC_FP_TYPE * b = (KC_FP_TYPE *)mxGetPr(prhs[4]); int numBetas = mxGetNumberOfElements(prhs[4]); KC_FP_TYPE * b_gpu; ce = hipMalloc((void**)&b_gpu,sizeof(KC_FP_TYPE)*numBetas); if(ce != hipSuccess) { mexPrintf("Error allocating space for betas on device - first allocation in function (kcSimGaussianBound) "); mexPrintf(hipGetErrorString(ce)); mexPrintf(" (%d)\n", (int)ce); } checkCudaErrors(hipMemcpy(b_gpu,b,sizeof(KC_FP_TYPE)*numBetas,hipMemcpyHostToDevice)); KC_FP_TYPE w = mxGetScalar(prhs[5]); KC_FP_TYPE l_0 = mxGetScalar(prhs[6]); KC_FP_TYPE g = mxGetScalar(prhs[7]); KC_FP_TYPE dt = mxGetScalar(prhs[8]); KC_FP_TYPE bias = mxGetScalar(prhs[10]); KC_FP_TYPE log_power = mxGetScalar(prhs[11]); //setup CUDA variables + random number generator int randSize = TT + (((TT)%2==0)?0:1); KC_FP_TYPE * xx; checkCudaErrors(hipMalloc((void**)&xx,randSize*sizeof(KC_FP_TYPE))); hiprandGenerator_t curandGen = 0; hiprandStatus_t hiprandStatus_t; hiprandStatus_t = hiprandCreateGenerator(&curandGen, HIPRAND_RNG_PSEUDO_DEFAULT); if(hiprandStatus_t != HIPRAND_STATUS_SUCCESS ) { mexPrintf("CURAND-1 error %d\n",(int)hiprandStatus_t); mexErrMsgTxt("CUDA errors"); } struct timeval now; gettimeofday(&now,NULL); unsigned long long mySeed = (unsigned long long)now.tv_usec+(unsigned long long)(1e7*(unsigned long long)now.tv_sec); hiprandStatus_t = hiprandSetPseudoRandomGeneratorSeed(curandGen, mySeed); if(hiprandStatus_t != HIPRAND_STATUS_SUCCESS ) { mexPrintf("CURAND-2 error %d\n",(int)hiprandStatus_t); mexErrMsgTxt("CUDA errors"); } int blockSize = 2; int nBlocks = NT/blockSize + ((NT%blockSize==0)?0:1); int blockSizeT = 2; int nBlocksT = NT/blockSizeT + ((NT%blockSizeT==0)?0:1); //allocates sspace on GPU for simulating the likelihood KC_FP_TYPE * log_p; //KC_FP_TYPE * log_p_2; KC_FP_TYPE * log_p_tr; KC_FP_TYPE * sum_log_p; checkCudaErrors(hipMalloc((void**)&log_p,sizeof(KC_FP_TYPE)*NT*trialsToSim)); //checkCudaErrors(hipMalloc((void**)&log_p_2,sizeof(KC_FP_TYPE)*NT*trialsToSim)); checkCudaErrors(hipMalloc((void**)&log_p_tr,sizeof(KC_FP_TYPE)*NT)); checkCudaErrors(hipMalloc((void**)&sum_log_p,sizeof(KC_FP_TYPE)*1)); // generate AR1 noise for(int kk = 0; kk < trialsToSim; kk++) { //generates zero mean Gaussian noise with correct variance hiprandStatus_t = KC_RANDOM_NORMAL_FUNCTION(curandGen,xx,randSize,0,KC_SQRT(w)); if(hiprandStatus_t != HIPRAND_STATUS_SUCCESS ) { mexPrintf("CURAND gen error %d\n",(int)hiprandStatus_t); mexErrMsgTxt("CUDA errors"); } //checkCudaErrors(hipDeviceSynchronize()); //calculate path + logP hipLaunchKernelGGL(( kcSimGBPaths), dim3(nBlocks),dim3(blockSize), 0, 0, y,trIdx,betaIdx,xx,b_gpu,w,l_0,g,dt,log_p,NT,TT,kk,spe,bias,log_power); ce = hipDeviceSynchronize(); if(ce != hipSuccess) { mexPrintf("Error in simulating of kcSimGaussianBound.cu "); mexPrintf(hipGetErrorString(ce)); mexPrintf(" (%d)\n", (int)ce); mexErrMsgTxt("CUDA errors"); } } // log_p_2 = log_p; //average likelihood of each sampled path to get log p(y|\theta) for each trial hipLaunchKernelGGL(( kcSumGBlogpTr), dim3(nBlocksT),dim3(blockSizeT), 0, 0, log_p,log_p_tr,NT,trialsToSim); checkCudaErrors(hipDeviceSynchronize()); //sums up log likelihood of each trial hipLaunchKernelGGL(( kcSumGBfinal), dim3(1),dim3(1), 0, 0, log_p_tr,sum_log_p,NT); checkCudaErrors(hipDeviceSynchronize()); //copy back to host if(nlhs > 0) { plhs[0] = mxCreateNumericMatrix(1,1,KC_FP_TYPE_MATLAB,mxREAL); checkCudaErrors(hipMemcpy((KC_FP_TYPE *)mxGetPr(plhs[0]),sum_log_p,1*sizeof(KC_FP_TYPE),hipMemcpyDeviceToHost)); } if(nlhs > 1) { plhs[1] = mxCreateNumericMatrix(NT,1,KC_FP_TYPE_MATLAB,mxREAL); checkCudaErrors(hipMemcpy((KC_FP_TYPE *)mxGetPr(plhs[1]),log_p_tr,NT*sizeof(KC_FP_TYPE),hipMemcpyDeviceToHost)); } //free up CUDA variables checkCudaErrors(hiprandDestroyGenerator(curandGen)); checkCudaErrors(hipFree(xx)); checkCudaErrors(hipFree(b_gpu)); checkCudaErrors(hipFree(log_p)); checkCudaErrors(hipFree(log_p_tr)); checkCudaErrors(hipFree(sum_log_p)); }
bab2640445a9f09620b33adce6519b44fe291d05.cu
#include <math.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <cuda_runtime.h> #include <cusparse_v2.h> #include "cublas_v2.h" #include <curand.h> #include <helper_functions.h> #include <helper_cuda.h> #include "mex.h" #include "kcDefs.h" //see for info on anything starting with KC_ #include "kcArrayFunctions.h" //poison log likelihood for one observation __device__ KC_FP_TYPE lh(KC_FP_TYPE y, KC_FP_TYPE x, KC_FP_TYPE g, KC_FP_TYPE dt, KC_FP_TYPE sh, KC_FP_TYPE bias, KC_FP_TYPE log_power) { KC_FP_TYPE logex = (g*x>100)?(g*x):KC_MIN(log1p(KC_EXP(x*g)),KC_MAXN); KC_FP_TYPE r = (KC_MIN(KC_POW(logex*1.0000000,log_power),KC_MAXN)+bias)*KC_EXP(sh); return y*(KC_LOG(r)+KC_LOG(dt)) - dt*r - KC_GAMMALN(y+1.0); } //sums up log likelihood of each trial given model parameters __global__ void kcSumGBfinal(const KC_FP_TYPE * log_p_tr, KC_FP_TYPE * log_p, const int NT) { int idx = blockDim.x * blockIdx.x + threadIdx.x; if(idx < 1) { log_p[0] = 0; for(int ii = 0; ii < NT; ii++) { log_p[0] += log_p_tr[ii]; } } } //averages log likelihood of each simulated path // (one thread for each trial) __global__ void kcSumGBlogpTr(const KC_FP_TYPE * log_p, KC_FP_TYPE * log_p_tr, const int NT, const int nSims) { int idx = blockIdx.x*blockDim.x+threadIdx.x; if(idx < NT) { log_p_tr[idx] = 0; KC_FP_TYPE trSum = 0; KC_FP_TYPE log_x = 0; log_p_tr[idx] = KC_SQRT(-1.0); //computes log( 1/nSims * \sum exp( log p(y | sim paths)) ) for a single trial // does the sum in a slightly more numerical stable way than just blindly exponentiating all the log likleihoods for(int ii = 0; ii < nSims && isnan(log_p_tr[idx]);ii++) { trSum = 1 ; log_x = log_p[ii*NT+idx]; for(int kk = 0; kk < ii; kk++) { trSum += KC_EXP(log_p[kk*NT+idx] - log_x); } for(int kk = ii+1; kk < nSims; kk++) { trSum += KC_EXP(log_p[kk*NT+idx] - log_x); } if(trSum > 1e-25 && !isnan(trSum) && !isinf(trSum)) { log_p_tr[idx] = log_x-KC_LOG((double)nSims)+KC_LOG(trSum); break; } } } } //simulates a ramping (diffusion-to-bound) path for each trial and computes likelihood __global__ void kcSimGBPaths(const KC_FP_TYPE * y, const int * trIdx, const int * betaIdx, KC_FP_TYPE * xx, const KC_FP_TYPE * b,const KC_FP_TYPE w2,const KC_FP_TYPE l_0, const KC_FP_TYPE g, const KC_FP_TYPE dt, KC_FP_TYPE * log_p, const int NT, const int TT, const int sim, KC_FP_TYPE * spe, KC_FP_TYPE bias, KC_FP_TYPE log_power) { int idx = blockIdx.x*blockDim.x+threadIdx.x; if(idx < NT ) { int trNum = idx; int T1 = trIdx[trNum]; //xx contains zero mean Gaussian noise of variance \omega^2 xx[T1] += l_0; //xx[T1] now contains initial point for simulated diffusion trajectory for this trial int currIdx = sim*(NT)+idx; log_p[currIdx] = lh(y[T1],xx[T1],g,dt,spe[T1],bias,log_power); for(int ii = T1+1; ii < trIdx[trNum+1];ii++) { //progates particle forward in time xx[ii] = (xx[ii-1] >= 1.0)?1.0:KC_MIN(xx[ii] + xx[ii-1]+b[betaIdx[ii]],1.0); //log likelihood of single observation (bin) y[ii] given diffusion path is at x[ii] log_p[currIdx] += lh(y[ii],xx[ii],g,dt,spe[ii],bias,log_power); } } } //Estimates the log probability of a set of spike trains under the ramping model given a set of fixed parameters // This estimation is made by Monte Carlo simulations from the model to integrate out latent variable //args // 0 = y (observations) // 1 = trIdx (array that accesses the beta value used at each timepoint, y being indexed at 0. Includes final value that should be length of y) // 2 = betaIdxVector (array that gives coherence used at each bins of y. i.e., accesses the beta value used at each timepoint. values begin at 0 instead of 1 to be consistent with C, unlike MATLAB) // 3 = spike history effect (same size as y) // 4 = beta values // 5 = w (variance of diffusion process) // 6 = l_0 (starting lambda value) // 7 = g (absorbing boundary effective height) // 8 = dt (bin size in seconds) // 9 = number of samples to use to estimate log probability of observations (I recommend using at least 1000) // 10 = bias // 11 = power //outputs (left-hand side) // 0 = log p(y|\theta) // 1 = log p(y|\theta) for each individual trial void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { cudaError_t ce; //load up trial data unsigned int TT = kcGetArrayNumEl(prhs[0]); KC_FP_TYPE * y = kcGetArrayData(prhs[0]); int * trIdx = kcGetArrayDataInt(prhs[1]); unsigned int NT = kcGetArrayNumEl(prhs[1])-1; int * betaIdx = kcGetArrayDataInt(prhs[2],TT); // load spike history effect KC_FP_TYPE * spe = kcGetArrayData(prhs[3]); //how many simulations to use to estimate log p(y|\theta) int trialsToSim = (int)mxGetScalar(prhs[9]); //load up parameters to simulate model if(mxGetClassID(prhs[4]) != KC_FP_TYPE_MATLAB) { mexErrMsgTxt("Beta input wrong floating point type (kcSimGaussianBound)!"); } KC_FP_TYPE * b = (KC_FP_TYPE *)mxGetPr(prhs[4]); int numBetas = mxGetNumberOfElements(prhs[4]); KC_FP_TYPE * b_gpu; ce = cudaMalloc((void**)&b_gpu,sizeof(KC_FP_TYPE)*numBetas); if(ce != cudaSuccess) { mexPrintf("Error allocating space for betas on device - first allocation in function (kcSimGaussianBound) "); mexPrintf(cudaGetErrorString(ce)); mexPrintf(" (%d)\n", (int)ce); } checkCudaErrors(cudaMemcpy(b_gpu,b,sizeof(KC_FP_TYPE)*numBetas,cudaMemcpyHostToDevice)); KC_FP_TYPE w = mxGetScalar(prhs[5]); KC_FP_TYPE l_0 = mxGetScalar(prhs[6]); KC_FP_TYPE g = mxGetScalar(prhs[7]); KC_FP_TYPE dt = mxGetScalar(prhs[8]); KC_FP_TYPE bias = mxGetScalar(prhs[10]); KC_FP_TYPE log_power = mxGetScalar(prhs[11]); //setup CUDA variables + random number generator int randSize = TT + (((TT)%2==0)?0:1); KC_FP_TYPE * xx; checkCudaErrors(cudaMalloc((void**)&xx,randSize*sizeof(KC_FP_TYPE))); curandGenerator_t curandGen = 0; curandStatus_t curandStatus; curandStatus = curandCreateGenerator(&curandGen, CURAND_RNG_PSEUDO_DEFAULT); if(curandStatus != CURAND_STATUS_SUCCESS ) { mexPrintf("CURAND-1 error %d\n",(int)curandStatus); mexErrMsgTxt("CUDA errors"); } struct timeval now; gettimeofday(&now,NULL); unsigned long long mySeed = (unsigned long long)now.tv_usec+(unsigned long long)(1e7*(unsigned long long)now.tv_sec); curandStatus = curandSetPseudoRandomGeneratorSeed(curandGen, mySeed); if(curandStatus != CURAND_STATUS_SUCCESS ) { mexPrintf("CURAND-2 error %d\n",(int)curandStatus); mexErrMsgTxt("CUDA errors"); } int blockSize = 2; int nBlocks = NT/blockSize + ((NT%blockSize==0)?0:1); int blockSizeT = 2; int nBlocksT = NT/blockSizeT + ((NT%blockSizeT==0)?0:1); //allocates sspace on GPU for simulating the likelihood KC_FP_TYPE * log_p; //KC_FP_TYPE * log_p_2; KC_FP_TYPE * log_p_tr; KC_FP_TYPE * sum_log_p; checkCudaErrors(cudaMalloc((void**)&log_p,sizeof(KC_FP_TYPE)*NT*trialsToSim)); //checkCudaErrors(cudaMalloc((void**)&log_p_2,sizeof(KC_FP_TYPE)*NT*trialsToSim)); checkCudaErrors(cudaMalloc((void**)&log_p_tr,sizeof(KC_FP_TYPE)*NT)); checkCudaErrors(cudaMalloc((void**)&sum_log_p,sizeof(KC_FP_TYPE)*1)); // generate AR1 noise for(int kk = 0; kk < trialsToSim; kk++) { //generates zero mean Gaussian noise with correct variance curandStatus = KC_RANDOM_NORMAL_FUNCTION(curandGen,xx,randSize,0,KC_SQRT(w)); if(curandStatus != CURAND_STATUS_SUCCESS ) { mexPrintf("CURAND gen error %d\n",(int)curandStatus); mexErrMsgTxt("CUDA errors"); } //checkCudaErrors(cudaDeviceSynchronize()); //calculate path + logP kcSimGBPaths<<<nBlocks,blockSize>>>(y,trIdx,betaIdx,xx,b_gpu,w,l_0,g,dt,log_p,NT,TT,kk,spe,bias,log_power); ce = cudaDeviceSynchronize(); if(ce != cudaSuccess) { mexPrintf("Error in simulating of kcSimGaussianBound.cu "); mexPrintf(cudaGetErrorString(ce)); mexPrintf(" (%d)\n", (int)ce); mexErrMsgTxt("CUDA errors"); } } // log_p_2 = log_p; //average likelihood of each sampled path to get log p(y|\theta) for each trial kcSumGBlogpTr<<<nBlocksT,blockSizeT>>>(log_p,log_p_tr,NT,trialsToSim); checkCudaErrors(cudaDeviceSynchronize()); //sums up log likelihood of each trial kcSumGBfinal<<<1,1>>>(log_p_tr,sum_log_p,NT); checkCudaErrors(cudaDeviceSynchronize()); //copy back to host if(nlhs > 0) { plhs[0] = mxCreateNumericMatrix(1,1,KC_FP_TYPE_MATLAB,mxREAL); checkCudaErrors(cudaMemcpy((KC_FP_TYPE *)mxGetPr(plhs[0]),sum_log_p,1*sizeof(KC_FP_TYPE),cudaMemcpyDeviceToHost)); } if(nlhs > 1) { plhs[1] = mxCreateNumericMatrix(NT,1,KC_FP_TYPE_MATLAB,mxREAL); checkCudaErrors(cudaMemcpy((KC_FP_TYPE *)mxGetPr(plhs[1]),log_p_tr,NT*sizeof(KC_FP_TYPE),cudaMemcpyDeviceToHost)); } //free up CUDA variables checkCudaErrors(curandDestroyGenerator(curandGen)); checkCudaErrors(cudaFree(xx)); checkCudaErrors(cudaFree(b_gpu)); checkCudaErrors(cudaFree(log_p)); checkCudaErrors(cudaFree(log_p_tr)); checkCudaErrors(cudaFree(sum_log_p)); }
b56e68f12b2b34828a7d850e3b9412626c21d18b.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" /* * Copyright (c) 2019-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "csv_common.h" #include "csv_gpu.h" #include "datetime.cuh" #include <io/utilities/block_utils.cuh> #include <io/utilities/parsing_utils.cuh> #include <cudf/detail/utilities/vector_factories.hpp> #include <cudf/fixed_point/fixed_point.hpp> #include <cudf/lists/list_view.cuh> #include <cudf/null_mask.hpp> #include <cudf/strings/string_view.cuh> #include <cudf/structs/struct_view.hpp> #include <cudf/utilities/bit.hpp> #include <cudf/utilities/error.hpp> #include <cudf/utilities/span.hpp> #include <cudf/utilities/traits.hpp> #include <cudf/utilities/type_dispatcher.hpp> #include <io/utilities/trie.cuh> #include <rmm/cuda_stream_view.hpp> #include <rmm/exec_policy.hpp> #include <thrust/detail/copy.h> #include <thrust/transform.h> #include <type_traits> using namespace ::cudf::io; using cudf::device_span; namespace cudf { namespace io { namespace csv { namespace gpu { /// Block dimension for dtype detection and conversion kernels constexpr uint32_t csvparse_block_dim = 128; /* * @brief Returns true is the input character is a valid digit. * Supports both decimal and hexadecimal digits (uppercase and lowercase). * * @param c Character to check * @param is_hex Whether to check as a hexadecimal * * @return `true` if it is digit-like, `false` otherwise */ __device__ __inline__ bool is_digit(char c, bool is_hex = false) { if (c >= '0' && c <= '9') return true; if (is_hex) { if (c >= 'A' && c <= 'F') return true; if (c >= 'a' && c <= 'f') return true; } return false; } /* * @brief Checks whether the given character counters indicate a potentially * valid date and/or time field. * * For performance and simplicity, we detect only the most common date * formats. Example formats that are detectable: * * `2001/02/30` * `2001-02-30 00:00:00` * `2/30/2001 T04:05:60.7` * `2 / 1 / 2011` * `02/January` * * @param len Number of non special-symbol or numeric characters * @param decimal_count Number of '.' characters * @param colon_count Number of ':' characters * @param dash_count Number of '-' characters * @param slash_count Number of '/' characters * * @return `true` if it is date-like, `false` otherwise */ __device__ __inline__ bool is_datetime( long len, long decimal_count, long colon_count, long dash_count, long slash_count) { // Must not exceed count of longest month (September) plus `T` time indicator if (len > 10) { return false; } // Must not exceed more than one decimals or more than two time separators if (decimal_count > 1 || colon_count > 2) { return false; } // Must have one or two '-' or '/' but not both as date separators if ((dash_count > 0 && dash_count < 3 && slash_count == 0) || (dash_count == 0 && slash_count > 0 && slash_count < 3)) { return true; } return false; } /* * @brief Returns true if the counters indicate a potentially valid float. * False positives are possible because positions are not taken into account. * For example, field "e.123-" would match the pattern. * * @param len Number of non special-symbol or numeric characters * @param digit_count Number of digits characters * @param decimal_count Number of '.' characters * @param dash_count Number of '-' characters * @param exponent_count Number of 'e or E' characters * * @return `true` if it is floating point-like, `false` otherwise */ __device__ __inline__ bool is_floatingpoint( long len, long digit_count, long decimal_count, long dash_count, long exponent_count) { // Can't have more than one exponent and one decimal point if (decimal_count > 1) return false; if (exponent_count > 1) return false; // Without the exponent or a decimal point, this is an integer, not a float if (decimal_count == 0 && exponent_count == 0) return false; // Can only have one '-' per component if (dash_count > 1 + exponent_count) return false; // If anything other than these characters is present, it's not a float if (digit_count + decimal_count + dash_count + exponent_count != len) { return false; } // Needs at least 1 digit, 2 if exponent is present if (digit_count < 1 + exponent_count) return false; return true; } /* * @brief CUDA kernel that parses and converts CSV data into cuDF column data. * * Data is processed in one row/record at a time, so the number of total * threads (tid) is equal to the number of rows. * * @param opts A set of parsing options * @param csv_text The entire CSV data to read * @param column_flags Per-column parsing behavior flags * @param row_offsets The start the CSV data of interest * @param d_columnData The count for each column data type */ __global__ void __launch_bounds__(csvparse_block_dim) data_type_detection(parse_options_view const opts, device_span<char const> csv_text, device_span<column_parse::flags const> const column_flags, device_span<uint64_t const> const row_offsets, device_span<column_type_histogram> d_columnData) { auto const raw_csv = csv_text.data(); // ThreadIds range per block, so also need the blockId // This is entry into the fields; threadId is an element within `num_records` long const rec_id = threadIdx.x + (blockDim.x * blockIdx.x); long const rec_id_next = rec_id + 1; // we can have more threads than data, make sure we are not past the end of // the data if (rec_id_next >= row_offsets.size()) { return; } auto field_start = raw_csv + row_offsets[rec_id]; auto const row_end = raw_csv + row_offsets[rec_id_next]; auto next_field = field_start; int col = 0; int actual_col = 0; // Going through all the columns of a given record while (col < column_flags.size() && field_start <= row_end) { auto next_delimiter = cudf::io::gpu::seek_field_end(field_start, row_end, opts); // Checking if this is a column that the user wants --- user can filter columns if (column_flags[col] & column_parse::enabled) { // points to last character in the field auto const field_len = static_cast<size_t>(next_delimiter - field_start); if (serialized_trie_contains(opts.trie_na, {field_start, field_len})) { atomicAdd(&d_columnData[actual_col].null_count, 1); } else if (serialized_trie_contains(opts.trie_true, {field_start, field_len}) || serialized_trie_contains(opts.trie_false, {field_start, field_len})) { atomicAdd(&d_columnData[actual_col].bool_count, 1); } else if (cudf::io::is_infinity(field_start, next_delimiter)) { atomicAdd(&d_columnData[actual_col].float_count, 1); } else { long countNumber = 0; long countDecimal = 0; long countSlash = 0; long countDash = 0; long countPlus = 0; long countColon = 0; long countString = 0; long countExponent = 0; // Modify field_start & end to ignore whitespace and quotechars // This could possibly result in additional empty fields auto const trimmed_field_range = trim_whitespaces_quotes(field_start, next_delimiter); auto const trimmed_field_len = trimmed_field_range.second - trimmed_field_range.first; for (auto cur = trimmed_field_range.first; cur < trimmed_field_range.second; ++cur) { if (is_digit(*cur)) { countNumber++; continue; } // Looking for unique characters that will help identify column types. switch (*cur) { case '.': countDecimal++; break; case '-': countDash++; break; case '+': countPlus++; break; case '/': countSlash++; break; case ':': countColon++; break; case 'e': case 'E': if (cur > trimmed_field_range.first && cur < trimmed_field_range.second - 1) countExponent++; break; default: countString++; break; } } // Integers have to have the length of the string // Off by one if they start with a minus sign auto const int_req_number_cnt = trimmed_field_len - ((*trimmed_field_range.first == '-' || *trimmed_field_range.first == '+') && trimmed_field_len > 1); if (column_flags[col] & column_parse::as_datetime) { // PANDAS uses `object` dtype if the date is unparseable if (is_datetime(countString, countDecimal, countColon, countDash, countSlash)) { atomicAdd(&d_columnData[actual_col].datetime_count, 1); } else { atomicAdd(&d_columnData[actual_col].string_count, 1); } } else if (countNumber == int_req_number_cnt) { auto const is_negative = (*trimmed_field_range.first == '-'); auto const data_begin = trimmed_field_range.first + (is_negative || (*trimmed_field_range.first == '+')); cudf::size_type *ptr = cudf::io::gpu::infer_integral_field_counter( data_begin, data_begin + countNumber, is_negative, d_columnData[actual_col]); atomicAdd(ptr, 1); } else if (is_floatingpoint(trimmed_field_len, countNumber, countDecimal, countDash + countPlus, countExponent)) { atomicAdd(&d_columnData[actual_col].float_count, 1); } else { atomicAdd(&d_columnData[actual_col].string_count, 1); } } actual_col++; } next_field = next_delimiter + 1; field_start = next_field; col++; } } template <typename T, int base> __inline__ __device__ T decode_value(char const *begin, char const *end, parse_options_view const &opts) { return cudf::io::parse_numeric<T, base>(begin, end, opts); } template <typename T> __inline__ __device__ T decode_value(char const *begin, char const *end, parse_options_view const &opts) { return cudf::io::parse_numeric<T>(begin, end, opts); } template <> __inline__ __device__ cudf::timestamp_D decode_value(char const *begin, char const *end, parse_options_view const &opts) { return timestamp_D{cudf::duration_D{to_date(begin, end, opts.dayfirst)}}; } template <> __inline__ __device__ cudf::timestamp_s decode_value(char const *begin, char const *end, parse_options_view const &opts) { auto milli = to_date_time(begin, end, opts.dayfirst); if (milli == -1) { return timestamp_s{cudf::duration_s{to_non_negative_integer<int64_t>(begin, end)}}; } else { return timestamp_s{cudf::duration_s{milli / 1000}}; } } template <> __inline__ __device__ cudf::timestamp_ms decode_value(char const *begin, char const *end, parse_options_view const &opts) { auto milli = to_date_time(begin, end, opts.dayfirst); if (milli == -1) { return timestamp_ms{cudf::duration_ms{to_non_negative_integer<int64_t>(begin, end)}}; } else { return timestamp_ms{cudf::duration_ms{milli}}; } } template <> __inline__ __device__ cudf::timestamp_us decode_value(char const *begin, char const *end, parse_options_view const &opts) { auto milli = to_date_time(begin, end, opts.dayfirst); if (milli == -1) { return timestamp_us{cudf::duration_us{to_non_negative_integer<int64_t>(begin, end)}}; } else { return timestamp_us{cudf::duration_us{milli * 1000}}; } } template <> __inline__ __device__ cudf::timestamp_ns decode_value(char const *begin, char const *end, parse_options_view const &opts) { auto milli = to_date_time(begin, end, opts.dayfirst); if (milli == -1) { return timestamp_ns{cudf::duration_ns{to_non_negative_integer<int64_t>(begin, end)}}; } else { return timestamp_ns{cudf::duration_ns{milli * 1000000}}; } } #ifndef DURATION_DECODE_VALUE #define DURATION_DECODE_VALUE(Type) \ template <> \ __inline__ __device__ Type decode_value( \ const char *begin, const char *end, parse_options_view const &opts) \ { \ return Type{to_time_delta<Type>(begin, end)}; \ } #endif DURATION_DECODE_VALUE(duration_D) DURATION_DECODE_VALUE(duration_s) DURATION_DECODE_VALUE(duration_ms) DURATION_DECODE_VALUE(duration_us) DURATION_DECODE_VALUE(duration_ns) // The purpose of this is merely to allow compilation ONLY // TODO : make this work for csv template <> __inline__ __device__ cudf::string_view decode_value(char const *begin, char const *end, parse_options_view const &opts) { return cudf::string_view{}; } // The purpose of this is merely to allow compilation ONLY template <> __inline__ __device__ cudf::dictionary32 decode_value(char const *begin, char const *end, parse_options_view const &opts) { return cudf::dictionary32{}; } // The purpose of this is merely to allow compilation ONLY // TODO : make this work for csv template <> __inline__ __device__ cudf::list_view decode_value(char const *begin, char const *end, parse_options_view const &opts) { return cudf::list_view{}; } // The purpose of this is merely to allow compilation ONLY // TODO : make this work for csv template <> __inline__ __device__ numeric::decimal32 decode_value(char const *begin, char const *end, parse_options_view const &opts) { return numeric::decimal32{}; } // The purpose of this is merely to allow compilation ONLY // TODO : make this work for csv template <> __inline__ __device__ numeric::decimal64 decode_value(char const *begin, char const *end, parse_options_view const &opts) { return numeric::decimal64{}; } // The purpose of this is merely to allow compilation ONLY // TODO : make this work for csv template <> __inline__ __device__ cudf::struct_view decode_value(char const *begin, char const *end, parse_options_view const &opts) { return cudf::struct_view{}; } /** * @brief Functor for converting CSV raw data to typed value. */ struct decode_op { /** * @brief Dispatch for numeric types whose values can be convertible to * 0 or 1 to represent boolean false/true, based upon checking against a * true/false values list. * * @return bool Whether the parsed value is valid. */ template <typename T, typename std::enable_if_t<std::is_integral<T>::value and !std::is_same<T, bool>::value> * = nullptr> __host__ __device__ __forceinline__ bool operator()(void *out_buffer, size_t row, char const *begin, char const *end, parse_options_view const &opts, column_parse::flags flags) { static_cast<T *>(out_buffer)[row] = [&flags, &opts, begin, end]() -> T { // Check for user-specified true/false values auto const field_len = static_cast<size_t>(end - begin); if (serialized_trie_contains(opts.trie_true, {begin, field_len})) { return 1; } if (serialized_trie_contains(opts.trie_false, {begin, field_len})) { return 0; } return flags & column_parse::as_hexadecimal ? decode_value<T, 16>(begin, end, opts) : decode_value<T>(begin, end, opts); }(); return true; } /** * @brief Dispatch for boolean type types. */ template <typename T, typename std::enable_if_t<std::is_same<T, bool>::value> * = nullptr> __host__ __device__ __forceinline__ bool operator()(void *out_buffer, size_t row, char const *begin, char const *end, parse_options_view const &opts, column_parse::flags flags) { static_cast<T *>(out_buffer)[row] = [&opts, begin, end]() { // Check for user-specified true/false values auto const field_len = static_cast<size_t>(end - begin); if (serialized_trie_contains(opts.trie_true, {begin, field_len})) { return true; } if (serialized_trie_contains(opts.trie_false, {begin, field_len})) { return false; } return decode_value<T>(begin, end, opts); }(); return true; } /** * @brief Dispatch for floating points, which are set to NaN if the input * is not valid. In such case, the validity mask is set to zero too. */ template <typename T, typename std::enable_if_t<std::is_floating_point<T>::value> * = nullptr> __host__ __device__ __forceinline__ bool operator()(void *out_buffer, size_t row, char const *begin, char const *end, parse_options_view const &opts, column_parse::flags flags) { T const value = decode_value<T>(begin, end, opts); static_cast<T *>(out_buffer)[row] = value; return !std::isnan(value); } /** * @brief Dispatch for all other types. */ template <typename T, typename std::enable_if_t<!std::is_integral<T>::value and !std::is_floating_point<T>::value> * = nullptr> __host__ __device__ __forceinline__ bool operator()(void *out_buffer, size_t row, char const *begin, char const *end, parse_options_view const &opts, column_parse::flags flags) { static_cast<T *>(out_buffer)[row] = decode_value<T>(begin, end, opts); return true; } }; /** * @brief CUDA kernel that parses and converts CSV data into cuDF column data. * * Data is processed one record at a time * * @param[in] raw_csv The entire CSV data to read * @param[in] opts A set of parsing options * @param[in] num_records The number of lines/rows of CSV data * @param[in] num_columns The number of columns of CSV data * @param[in] column_flags Per-column parsing behavior flags * @param[in] recStart The start the CSV data of interest * @param[in] dtype The data type of the column * @param[out] data The output column data * @param[out] valid The bitmaps indicating whether column fields are valid * @param[out] num_valid The numbers of valid fields in columns */ __global__ void __launch_bounds__(csvparse_block_dim) convert_csv_to_cudf(cudf::io::parse_options_view options, device_span<char const> data, device_span<column_parse::flags const> column_flags, device_span<uint64_t const> row_offsets, device_span<cudf::data_type const> dtypes, device_span<void *const> columns, device_span<cudf::bitmask_type *const> valids) { auto const raw_csv = data.data(); // thread IDs range per block, so also need the block id. // this is entry into the field array - tid is an elements within the num_entries array long const rec_id = threadIdx.x + (blockDim.x * blockIdx.x); long const rec_id_next = rec_id + 1; // we can have more threads than data, make sure we are not past the end of // the data if (rec_id_next >= row_offsets.size()) return; auto field_start = raw_csv + row_offsets[rec_id]; auto const row_end = raw_csv + row_offsets[rec_id_next]; auto next_field = field_start; int col = 0; int actual_col = 0; while (col < column_flags.size() && field_start <= row_end) { auto next_delimiter = cudf::io::gpu::seek_field_end(next_field, row_end, options); if (column_flags[col] & column_parse::enabled) { // check if the entire field is a NaN string - consistent with pandas auto const is_valid = !serialized_trie_contains( options.trie_na, {field_start, static_cast<size_t>(next_delimiter - field_start)}); // Modify field_start & end to ignore whitespace and quotechars auto field_end = next_delimiter; if (is_valid && dtypes[actual_col].id() != cudf::type_id::STRING) { auto const trimmed_field = trim_whitespaces_quotes(field_start, field_end, options.quotechar); field_start = trimmed_field.first; field_end = trimmed_field.second; } if (is_valid) { // Type dispatcher does not handle STRING if (dtypes[actual_col].id() == cudf::type_id::STRING) { auto end = next_delimiter; if (options.keepquotes == false) { if ((*field_start == options.quotechar) && (*(end - 1) == options.quotechar)) { ++field_start; --end; } } auto str_list = static_cast<std::pair<const char *, size_t> *>(columns[actual_col]); str_list[rec_id].first = field_start; str_list[rec_id].second = end - field_start; } else { if (cudf::type_dispatcher(dtypes[actual_col], decode_op{}, columns[actual_col], rec_id, field_start, field_end, options, column_flags[col])) { // set the valid bitmap - all bits were set to 0 to start set_bit(valids[actual_col], rec_id); } } } else if (dtypes[actual_col].id() == cudf::type_id::STRING) { auto str_list = static_cast<std::pair<const char *, size_t> *>(columns[actual_col]); str_list[rec_id].first = nullptr; str_list[rec_id].second = 0; } ++actual_col; } next_field = next_delimiter + 1; field_start = next_field; ++col; } } /* * @brief Merge two packed row contexts (each corresponding to a block of characters) * and return the packed row context corresponding to the merged character block */ inline __device__ packed_rowctx_t merge_row_contexts(packed_rowctx_t first_ctx, packed_rowctx_t second_ctx) { uint32_t id0 = get_row_context(first_ctx, ROW_CTX_NONE) & 3; uint32_t id1 = get_row_context(first_ctx, ROW_CTX_QUOTE) & 3; uint32_t id2 = get_row_context(first_ctx, ROW_CTX_COMMENT) & 3; return (first_ctx & ~pack_row_contexts(3, 3, 3)) + pack_row_contexts(get_row_context(second_ctx, id0), get_row_context(second_ctx, id1), get_row_context(second_ctx, id2)); } /* * @brief Per-character context: * 1-bit count (0 or 1) per context in the lower 4 bits * 2-bit output context id per input context in bits 8..15 */ constexpr __device__ uint32_t make_char_context(uint32_t id0, uint32_t id1, uint32_t id2 = ROW_CTX_COMMENT, uint32_t c0 = 0, uint32_t c1 = 0, uint32_t c2 = 0) { return (id0 << 8) | (id1 << 10) | (id2 << 12) | (ROW_CTX_EOF << 14) | (c0) | (c1 << 1) | (c2 << 2); } /* * @brief Merge a 1-character context to keep track of bitmasks where new rows occur * Merges a single-character "block" row context at position pos with the current * block's row context (the current block contains 32-pos characters) * * @param ctx Current block context and new rows bitmaps * @param char_ctx state transitions associated with new character * @param pos Position within the current 32-character block * * NOTE: This is probably the most performance-critical piece of the row gathering kernel. * The char_ctx value should be created via make_char_context, and its value should * have been evaluated at compile-time. */ inline __device__ void merge_char_context(uint4 &ctx, uint32_t char_ctx, uint32_t pos) { uint32_t id0 = (ctx.w >> 0) & 3; uint32_t id1 = (ctx.w >> 2) & 3; uint32_t id2 = (ctx.w >> 4) & 3; // Set the newrow bit in the bitmap at the corresponding position ctx.x |= ((char_ctx >> id0) & 1) << pos; ctx.y |= ((char_ctx >> id1) & 1) << pos; ctx.z |= ((char_ctx >> id2) & 1) << pos; // Update the output context ids ctx.w = ((char_ctx >> (8 + id0 * 2)) & 0x03) | ((char_ctx >> (6 + id1 * 2)) & 0x0c) | ((char_ctx >> (4 + id2 * 2)) & 0x30) | (ROW_CTX_EOF << 6); } /* * Convert the context-with-row-bitmaps version to a packed row context */ inline __device__ packed_rowctx_t pack_rowmaps(uint4 ctx_map) { return pack_row_contexts(make_row_context(__popc(ctx_map.x), (ctx_map.w >> 0) & 3), make_row_context(__popc(ctx_map.y), (ctx_map.w >> 2) & 3), make_row_context(__popc(ctx_map.z), (ctx_map.w >> 4) & 3)); } /* * Selects the row bitmap corresponding to the given parser state */ inline __device__ uint32_t select_rowmap(uint4 ctx_map, uint32_t ctxid) { return (ctxid == ROW_CTX_NONE) ? ctx_map.x : (ctxid == ROW_CTX_QUOTE) ? ctx_map.y : (ctxid == ROW_CTX_COMMENT) ? ctx_map.z : 0; } /** * @brief Single pair-wise 512-wide row context merge transform * * Merge row context blocks and record the merge operation in a context * tree so that the transform is reversible. * The tree is organized such that the left and right children of node n * are located at indices n*2 and n*2+1, the root node starting at index 1 * * @tparam lanemask mask to specify source of packed row context * @tparam tmask mask to specify principle thread for merging row context * @tparam base start location for writing into packed row context tree * @tparam level_scale level of the node in the tree * @param ctxtree[out] packed row context tree * @param ctxb[in] packed row context for the current character block * @param t thread id (leaf node id) */ template <uint32_t lanemask, uint32_t tmask, uint32_t base, uint32_t level_scale> inline __device__ void ctx_merge(uint64_t *ctxtree, packed_rowctx_t *ctxb, uint32_t t) { uint64_t tmp = shuffle_xor(*ctxb, lanemask); if (!(t & tmask)) { *ctxb = merge_row_contexts(*ctxb, tmp); ctxtree[base + (t >> level_scale)] = *ctxb; } } /** * @brief Single 512-wide row context inverse merge transform * * Walks the context tree starting from a root node * * @tparam rmask Mask to specify which threads write input row context * @param[in] base Start read location of the merge transform tree * @param[in] ctxtree Merge transform tree * @param[in] ctx Input context * @param[in] brow4 output row in block *4 * @param[in] t thread id (leaf node id) */ template <uint32_t rmask> inline __device__ void ctx_unmerge( uint32_t base, uint64_t *ctxtree, uint32_t *ctx, uint32_t *brow4, uint32_t t) { rowctx32_t ctxb_left, ctxb_right, ctxb_sum; ctxb_sum = get_row_context(ctxtree[base], *ctx); ctxb_left = get_row_context(ctxtree[(base)*2 + 0], *ctx); ctxb_right = get_row_context(ctxtree[(base)*2 + 1], ctxb_left & 3); if (t & (rmask)) { *brow4 += (ctxb_sum & ~3) - (ctxb_right & ~3); *ctx = ctxb_left & 3; } } /* * @brief 512-wide row context merge transform * * Repeatedly merge row context blocks, keeping track of each merge operation * in a context tree so that the transform is reversible * The tree is organized such that the left and right children of node n * are located at indices n*2 and n*2+1, the root node starting at index 1 * * Each node contains the counts and output contexts corresponding to the * possible input contexts. * Each parent node's count is obtained by adding the corresponding counts * from the left child node with the right child node's count selected from * the left child node's output context: * parent.count[k] = left.count[k] + right.count[left.outctx[k]] * parent.outctx[k] = right.outctx[left.outctx[k]] * * @param ctxtree[out] packed row context tree * @param ctxb[in] packed row context for the current character block * @param t thread id (leaf node id) */ static inline __device__ void rowctx_merge_transform(uint64_t ctxtree[1024], packed_rowctx_t ctxb, uint32_t t) { ctxtree[512 + t] = ctxb; ctx_merge<1, 0x1, 256, 1>(ctxtree, &ctxb, t); ctx_merge<2, 0x3, 128, 2>(ctxtree, &ctxb, t); ctx_merge<4, 0x7, 64, 3>(ctxtree, &ctxb, t); ctx_merge<8, 0xf, 32, 4>(ctxtree, &ctxb, t); __syncthreads(); if (t < 32) { ctxb = ctxtree[32 + t]; ctx_merge<1, 0x1, 16, 1>(ctxtree, &ctxb, t); ctx_merge<2, 0x3, 8, 2>(ctxtree, &ctxb, t); ctx_merge<4, 0x7, 4, 3>(ctxtree, &ctxb, t); ctx_merge<8, 0xf, 2, 4>(ctxtree, &ctxb, t); // Final stage uint64_t tmp = shuffle_xor(ctxb, 16); if (t == 0) { ctxtree[1] = merge_row_contexts(ctxb, tmp); } } } /* * @brief 512-wide row context inverse merge transform * * Walks the context tree starting from the root node (index 1) using * the starting context in node index 0. * The return value is the starting row and input context for the given leaf node * * @param[in] ctxtree Merge transform tree * @param[in] t thread id (leaf node id) * * @return Final row context and count (row_position*4 + context_id format) */ static inline __device__ rowctx32_t rowctx_inverse_merge_transform(uint64_t ctxtree[1024], uint32_t t) { uint32_t ctx = ctxtree[0] & 3; // Starting input context rowctx32_t brow4 = 0; // output row in block *4 ctx_unmerge<256>(1, ctxtree, &ctx, &brow4, t); ctx_unmerge<128>(2 + (t >> 8), ctxtree, &ctx, &brow4, t); ctx_unmerge<64>(4 + (t >> 7), ctxtree, &ctx, &brow4, t); ctx_unmerge<32>(8 + (t >> 6), ctxtree, &ctx, &brow4, t); ctx_unmerge<16>(16 + (t >> 5), ctxtree, &ctx, &brow4, t); ctx_unmerge<8>(32 + (t >> 4), ctxtree, &ctx, &brow4, t); ctx_unmerge<4>(64 + (t >> 3), ctxtree, &ctx, &brow4, t); ctx_unmerge<2>(128 + (t >> 2), ctxtree, &ctx, &brow4, t); ctx_unmerge<1>(256 + (t >> 1), ctxtree, &ctx, &brow4, t); return brow4 + ctx; } /** * @brief Gather row offsets from CSV character data split into 16KB chunks * * This is done in two phases: the first phase returns the possible row counts * per 16K character block for each possible parsing context at the start of the block, * along with the resulting parsing context at the end of the block. * The caller can then compute the actual parsing context at the beginning of each * individual block and total row count. * The second phase outputs the location of each row in the block, using the parsing * context and initial row counter accumulated from the results of the previous phase. * Row parsing context will be updated after phase 2 such that the value contains * the number of rows starting at byte_range_end or beyond. * * @param row_ctx Row parsing context (output of phase 1 or input to phase 2) * @param offsets_out Row offsets (nullptr for phase1, non-null indicates phase 2) * @param data Base pointer of character data (all row offsets are relative to this) * @param chunk_size Total number of characters to parse * @param parse_pos Current parsing position in the file * @param start_offset Position of the start of the character buffer in the file * @param data_size CSV file size * @param byte_range_start Ignore rows starting before this position in the file * @param byte_range_end In phase 2, store the number of rows beyond range in row_ctx * @param skip_rows Number of rows to skip (ignored in phase 1) * @param terminator Line terminator character * @param delimiter Column delimiter character * @param quotechar Quote character * @param escapechar Delimiter escape character * @param commentchar Comment line character (skip rows starting with this character) */ __global__ void __launch_bounds__(rowofs_block_dim) gather_row_offsets_gpu(uint64_t *row_ctx, device_span<uint64_t> offsets_out, device_span<char const> const data, size_t chunk_size, size_t parse_pos, size_t start_offset, size_t data_size, size_t byte_range_start, size_t byte_range_end, size_t skip_rows, int terminator, int delimiter, int quotechar, int escapechar, int commentchar) { auto start = data.begin(); using block_reduce = typename hipcub::BlockReduce<uint32_t, rowofs_block_dim>; __shared__ union { typename block_reduce::TempStorage bk_storage; __align__(8) uint64_t ctxtree[rowofs_block_dim * 2]; } temp_storage; const char *end = start + (min(parse_pos + chunk_size, data_size) - start_offset); uint32_t t = threadIdx.x; size_t block_pos = (parse_pos - start_offset) + blockIdx.x * static_cast<size_t>(rowofs_block_bytes) + t * 32; const char *cur = start + block_pos; // Initial state is neutral context (no state transitions), zero rows uint4 ctx_map = { .x = 0, .y = 0, .z = 0, .w = (ROW_CTX_NONE << 0) | (ROW_CTX_QUOTE << 2) | (ROW_CTX_COMMENT << 4) | (ROW_CTX_EOF << 6)}; int c, c_prev = (cur > start && cur <= end) ? cur[-1] : terminator; // Loop through all 32 bytes and keep a bitmask of row starts for each possible input context for (uint32_t pos = 0; pos < 32; pos++, cur++, c_prev = c) { uint32_t ctx; if (cur < end) { c = cur[0]; if (c_prev == terminator) { if (c == commentchar) { // Start of a new comment row ctx = make_char_context(ROW_CTX_COMMENT, ROW_CTX_QUOTE, ROW_CTX_COMMENT, 1, 0, 1); } else if (c == quotechar) { // Quoted string on newrow, or quoted string ending in terminator ctx = make_char_context(ROW_CTX_QUOTE, ROW_CTX_NONE, ROW_CTX_QUOTE, 1, 0, 1); } else { // Start of a new row unless within a quote ctx = make_char_context(ROW_CTX_NONE, ROW_CTX_QUOTE, ROW_CTX_NONE, 1, 0, 1); } } else if (c == quotechar) { if (c_prev == delimiter || c_prev == quotechar) { // Quoted string after delimiter, quoted string ending in delimiter, or double-quote ctx = make_char_context(ROW_CTX_QUOTE, ROW_CTX_NONE); } else { // Closing or ignored quote ctx = make_char_context(ROW_CTX_NONE, ROW_CTX_NONE); } } else { // Neutral character ctx = make_char_context(ROW_CTX_NONE, ROW_CTX_QUOTE); } } else { const char *data_end = start + data_size - start_offset; if (cur <= end && cur == data_end) { // Add a newline at data end (need the extra row offset to infer length of previous row) ctx = make_char_context(ROW_CTX_EOF, ROW_CTX_EOF, ROW_CTX_EOF, 1, 1, 1); } else { // Pass-through context (beyond chunk_size or data_end) ctx = make_char_context(ROW_CTX_NONE, ROW_CTX_QUOTE, ROW_CTX_COMMENT); } } // Merge with current context, keeping track of where new rows occur merge_char_context(ctx_map, ctx, pos); } // Eliminate rows that start before byte_range_start if (start_offset + block_pos < byte_range_start) { uint32_t dist_minus1 = min(byte_range_start - (start_offset + block_pos) - 1, UINT64_C(31)); uint32_t mask = 0xfffffffe << dist_minus1; ctx_map.x &= mask; ctx_map.y &= mask; ctx_map.z &= mask; } // Convert the long-form {rowmap,outctx}[inctx] version into packed version // {rowcount,ouctx}[inctx], then merge the row contexts of the 32-character blocks into // a single 16K-character block context rowctx_merge_transform(temp_storage.ctxtree, pack_rowmaps(ctx_map), t); // If this is the second phase, get the block's initial parser state and row counter if (offsets_out.data()) { if (t == 0) { temp_storage.ctxtree[0] = row_ctx[blockIdx.x]; } __syncthreads(); // Walk back the transform tree with the known initial parser state rowctx32_t ctx = rowctx_inverse_merge_transform(temp_storage.ctxtree, t); uint64_t row = (temp_storage.ctxtree[0] >> 2) + (ctx >> 2); uint32_t rows_out_of_range = 0; uint32_t rowmap = select_rowmap(ctx_map, ctx & 3); // Output row positions while (rowmap != 0) { uint32_t pos = __ffs(rowmap); block_pos += pos; if (row >= skip_rows && row - skip_rows < offsets_out.size()) { // Output byte offsets are relative to the base of the input buffer offsets_out[row - skip_rows] = block_pos - 1; rows_out_of_range += (start_offset + block_pos - 1 >= byte_range_end); } row++; rowmap >>= pos; } __syncthreads(); // Return the number of rows out of range rows_out_of_range = block_reduce(temp_storage.bk_storage).Sum(rows_out_of_range); if (t == 0) { row_ctx[blockIdx.x] = rows_out_of_range; } } else { // Just store the row counts and output contexts if (t == 0) { row_ctx[blockIdx.x] = temp_storage.ctxtree[1]; } } } size_t __host__ count_blank_rows(const cudf::io::parse_options_view &opts, device_span<char const> data, device_span<uint64_t const> row_offsets, rmm::cuda_stream_view stream) { const auto newline = opts.skipblanklines ? opts.terminator : opts.comment; const auto comment = opts.comment != '\0' ? opts.comment : newline; const auto carriage = (opts.skipblanklines && opts.terminator == '\n') ? '\r' : comment; return thrust::count_if( rmm::exec_policy(stream), row_offsets.begin(), row_offsets.end(), [data = data, newline, comment, carriage] __device__(const uint64_t pos) { return ((pos != data.size()) && (data[pos] == newline || data[pos] == comment || data[pos] == carriage)); }); } device_span<uint64_t> __host__ remove_blank_rows(cudf::io::parse_options_view const &options, device_span<char const> data, device_span<uint64_t> row_offsets, rmm::cuda_stream_view stream) { size_t d_size = data.size(); const auto newline = options.skipblanklines ? options.terminator : options.comment; const auto comment = options.comment != '\0' ? options.comment : newline; const auto carriage = (options.skipblanklines && options.terminator == '\n') ? '\r' : comment; auto new_end = thrust::remove_if( rmm::exec_policy(stream), row_offsets.begin(), row_offsets.end(), [data = data, d_size, newline, comment, carriage] __device__(const uint64_t pos) { return ((pos != d_size) && (data[pos] == newline || data[pos] == comment || data[pos] == carriage)); }); return row_offsets.subspan(0, new_end - row_offsets.begin()); } std::vector<column_type_histogram> detect_column_types( cudf::io::parse_options_view const &options, device_span<char const> const data, device_span<column_parse::flags const> const column_flags, device_span<uint64_t const> const row_starts, size_t const num_active_columns, rmm::cuda_stream_view stream) { // Calculate actual block count to use based on records count const int block_size = csvparse_block_dim; const int grid_size = (row_starts.size() + block_size - 1) / block_size; auto d_stats = detail::make_zeroed_device_uvector_async<column_type_histogram>(num_active_columns, stream); hipLaunchKernelGGL(( data_type_detection), dim3(grid_size), dim3(block_size), 0, stream.value(), options, data, column_flags, row_starts, d_stats); return detail::make_std_vector_sync(d_stats, stream); } void __host__ decode_row_column_data(cudf::io::parse_options_view const &options, device_span<char const> data, device_span<column_parse::flags const> column_flags, device_span<uint64_t const> row_offsets, device_span<cudf::data_type const> dtypes, device_span<void *const> columns, device_span<cudf::bitmask_type *const> valids, rmm::cuda_stream_view stream) { // Calculate actual block count to use based on records count auto const block_size = csvparse_block_dim; auto const num_rows = row_offsets.size() - 1; auto const grid_size = (num_rows + block_size - 1) / block_size; hipLaunchKernelGGL(( convert_csv_to_cudf), dim3(grid_size), dim3(block_size), 0, stream.value(), options, data, column_flags, row_offsets, dtypes, columns, valids); } uint32_t __host__ gather_row_offsets(const parse_options_view &options, uint64_t *row_ctx, device_span<uint64_t> const offsets_out, device_span<char const> const data, size_t chunk_size, size_t parse_pos, size_t start_offset, size_t data_size, size_t byte_range_start, size_t byte_range_end, size_t skip_rows, rmm::cuda_stream_view stream) { uint32_t dim_grid = 1 + (chunk_size / rowofs_block_bytes); hipLaunchKernelGGL(( gather_row_offsets_gpu), dim3(dim_grid), dim3(rowofs_block_dim), 0, stream.value(), row_ctx, offsets_out, data, chunk_size, parse_pos, start_offset, data_size, byte_range_start, byte_range_end, skip_rows, options.terminator, options.delimiter, (options.quotechar) ? options.quotechar : 0x100, /*(options.escapechar) ? options.escapechar :*/ 0x100, (options.comment) ? options.comment : 0x100); return dim_grid; } } // namespace gpu } // namespace csv } // namespace io } // namespace cudf
b56e68f12b2b34828a7d850e3b9412626c21d18b.cu
/* * Copyright (c) 2019-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "csv_common.h" #include "csv_gpu.h" #include "datetime.cuh" #include <io/utilities/block_utils.cuh> #include <io/utilities/parsing_utils.cuh> #include <cudf/detail/utilities/vector_factories.hpp> #include <cudf/fixed_point/fixed_point.hpp> #include <cudf/lists/list_view.cuh> #include <cudf/null_mask.hpp> #include <cudf/strings/string_view.cuh> #include <cudf/structs/struct_view.hpp> #include <cudf/utilities/bit.hpp> #include <cudf/utilities/error.hpp> #include <cudf/utilities/span.hpp> #include <cudf/utilities/traits.hpp> #include <cudf/utilities/type_dispatcher.hpp> #include <io/utilities/trie.cuh> #include <rmm/cuda_stream_view.hpp> #include <rmm/exec_policy.hpp> #include <thrust/detail/copy.h> #include <thrust/transform.h> #include <type_traits> using namespace ::cudf::io; using cudf::device_span; namespace cudf { namespace io { namespace csv { namespace gpu { /// Block dimension for dtype detection and conversion kernels constexpr uint32_t csvparse_block_dim = 128; /* * @brief Returns true is the input character is a valid digit. * Supports both decimal and hexadecimal digits (uppercase and lowercase). * * @param c Character to check * @param is_hex Whether to check as a hexadecimal * * @return `true` if it is digit-like, `false` otherwise */ __device__ __inline__ bool is_digit(char c, bool is_hex = false) { if (c >= '0' && c <= '9') return true; if (is_hex) { if (c >= 'A' && c <= 'F') return true; if (c >= 'a' && c <= 'f') return true; } return false; } /* * @brief Checks whether the given character counters indicate a potentially * valid date and/or time field. * * For performance and simplicity, we detect only the most common date * formats. Example formats that are detectable: * * `2001/02/30` * `2001-02-30 00:00:00` * `2/30/2001 T04:05:60.7` * `2 / 1 / 2011` * `02/January` * * @param len Number of non special-symbol or numeric characters * @param decimal_count Number of '.' characters * @param colon_count Number of ':' characters * @param dash_count Number of '-' characters * @param slash_count Number of '/' characters * * @return `true` if it is date-like, `false` otherwise */ __device__ __inline__ bool is_datetime( long len, long decimal_count, long colon_count, long dash_count, long slash_count) { // Must not exceed count of longest month (September) plus `T` time indicator if (len > 10) { return false; } // Must not exceed more than one decimals or more than two time separators if (decimal_count > 1 || colon_count > 2) { return false; } // Must have one or two '-' or '/' but not both as date separators if ((dash_count > 0 && dash_count < 3 && slash_count == 0) || (dash_count == 0 && slash_count > 0 && slash_count < 3)) { return true; } return false; } /* * @brief Returns true if the counters indicate a potentially valid float. * False positives are possible because positions are not taken into account. * For example, field "e.123-" would match the pattern. * * @param len Number of non special-symbol or numeric characters * @param digit_count Number of digits characters * @param decimal_count Number of '.' characters * @param dash_count Number of '-' characters * @param exponent_count Number of 'e or E' characters * * @return `true` if it is floating point-like, `false` otherwise */ __device__ __inline__ bool is_floatingpoint( long len, long digit_count, long decimal_count, long dash_count, long exponent_count) { // Can't have more than one exponent and one decimal point if (decimal_count > 1) return false; if (exponent_count > 1) return false; // Without the exponent or a decimal point, this is an integer, not a float if (decimal_count == 0 && exponent_count == 0) return false; // Can only have one '-' per component if (dash_count > 1 + exponent_count) return false; // If anything other than these characters is present, it's not a float if (digit_count + decimal_count + dash_count + exponent_count != len) { return false; } // Needs at least 1 digit, 2 if exponent is present if (digit_count < 1 + exponent_count) return false; return true; } /* * @brief CUDA kernel that parses and converts CSV data into cuDF column data. * * Data is processed in one row/record at a time, so the number of total * threads (tid) is equal to the number of rows. * * @param opts A set of parsing options * @param csv_text The entire CSV data to read * @param column_flags Per-column parsing behavior flags * @param row_offsets The start the CSV data of interest * @param d_columnData The count for each column data type */ __global__ void __launch_bounds__(csvparse_block_dim) data_type_detection(parse_options_view const opts, device_span<char const> csv_text, device_span<column_parse::flags const> const column_flags, device_span<uint64_t const> const row_offsets, device_span<column_type_histogram> d_columnData) { auto const raw_csv = csv_text.data(); // ThreadIds range per block, so also need the blockId // This is entry into the fields; threadId is an element within `num_records` long const rec_id = threadIdx.x + (blockDim.x * blockIdx.x); long const rec_id_next = rec_id + 1; // we can have more threads than data, make sure we are not past the end of // the data if (rec_id_next >= row_offsets.size()) { return; } auto field_start = raw_csv + row_offsets[rec_id]; auto const row_end = raw_csv + row_offsets[rec_id_next]; auto next_field = field_start; int col = 0; int actual_col = 0; // Going through all the columns of a given record while (col < column_flags.size() && field_start <= row_end) { auto next_delimiter = cudf::io::gpu::seek_field_end(field_start, row_end, opts); // Checking if this is a column that the user wants --- user can filter columns if (column_flags[col] & column_parse::enabled) { // points to last character in the field auto const field_len = static_cast<size_t>(next_delimiter - field_start); if (serialized_trie_contains(opts.trie_na, {field_start, field_len})) { atomicAdd(&d_columnData[actual_col].null_count, 1); } else if (serialized_trie_contains(opts.trie_true, {field_start, field_len}) || serialized_trie_contains(opts.trie_false, {field_start, field_len})) { atomicAdd(&d_columnData[actual_col].bool_count, 1); } else if (cudf::io::is_infinity(field_start, next_delimiter)) { atomicAdd(&d_columnData[actual_col].float_count, 1); } else { long countNumber = 0; long countDecimal = 0; long countSlash = 0; long countDash = 0; long countPlus = 0; long countColon = 0; long countString = 0; long countExponent = 0; // Modify field_start & end to ignore whitespace and quotechars // This could possibly result in additional empty fields auto const trimmed_field_range = trim_whitespaces_quotes(field_start, next_delimiter); auto const trimmed_field_len = trimmed_field_range.second - trimmed_field_range.first; for (auto cur = trimmed_field_range.first; cur < trimmed_field_range.second; ++cur) { if (is_digit(*cur)) { countNumber++; continue; } // Looking for unique characters that will help identify column types. switch (*cur) { case '.': countDecimal++; break; case '-': countDash++; break; case '+': countPlus++; break; case '/': countSlash++; break; case ':': countColon++; break; case 'e': case 'E': if (cur > trimmed_field_range.first && cur < trimmed_field_range.second - 1) countExponent++; break; default: countString++; break; } } // Integers have to have the length of the string // Off by one if they start with a minus sign auto const int_req_number_cnt = trimmed_field_len - ((*trimmed_field_range.first == '-' || *trimmed_field_range.first == '+') && trimmed_field_len > 1); if (column_flags[col] & column_parse::as_datetime) { // PANDAS uses `object` dtype if the date is unparseable if (is_datetime(countString, countDecimal, countColon, countDash, countSlash)) { atomicAdd(&d_columnData[actual_col].datetime_count, 1); } else { atomicAdd(&d_columnData[actual_col].string_count, 1); } } else if (countNumber == int_req_number_cnt) { auto const is_negative = (*trimmed_field_range.first == '-'); auto const data_begin = trimmed_field_range.first + (is_negative || (*trimmed_field_range.first == '+')); cudf::size_type *ptr = cudf::io::gpu::infer_integral_field_counter( data_begin, data_begin + countNumber, is_negative, d_columnData[actual_col]); atomicAdd(ptr, 1); } else if (is_floatingpoint(trimmed_field_len, countNumber, countDecimal, countDash + countPlus, countExponent)) { atomicAdd(&d_columnData[actual_col].float_count, 1); } else { atomicAdd(&d_columnData[actual_col].string_count, 1); } } actual_col++; } next_field = next_delimiter + 1; field_start = next_field; col++; } } template <typename T, int base> __inline__ __device__ T decode_value(char const *begin, char const *end, parse_options_view const &opts) { return cudf::io::parse_numeric<T, base>(begin, end, opts); } template <typename T> __inline__ __device__ T decode_value(char const *begin, char const *end, parse_options_view const &opts) { return cudf::io::parse_numeric<T>(begin, end, opts); } template <> __inline__ __device__ cudf::timestamp_D decode_value(char const *begin, char const *end, parse_options_view const &opts) { return timestamp_D{cudf::duration_D{to_date(begin, end, opts.dayfirst)}}; } template <> __inline__ __device__ cudf::timestamp_s decode_value(char const *begin, char const *end, parse_options_view const &opts) { auto milli = to_date_time(begin, end, opts.dayfirst); if (milli == -1) { return timestamp_s{cudf::duration_s{to_non_negative_integer<int64_t>(begin, end)}}; } else { return timestamp_s{cudf::duration_s{milli / 1000}}; } } template <> __inline__ __device__ cudf::timestamp_ms decode_value(char const *begin, char const *end, parse_options_view const &opts) { auto milli = to_date_time(begin, end, opts.dayfirst); if (milli == -1) { return timestamp_ms{cudf::duration_ms{to_non_negative_integer<int64_t>(begin, end)}}; } else { return timestamp_ms{cudf::duration_ms{milli}}; } } template <> __inline__ __device__ cudf::timestamp_us decode_value(char const *begin, char const *end, parse_options_view const &opts) { auto milli = to_date_time(begin, end, opts.dayfirst); if (milli == -1) { return timestamp_us{cudf::duration_us{to_non_negative_integer<int64_t>(begin, end)}}; } else { return timestamp_us{cudf::duration_us{milli * 1000}}; } } template <> __inline__ __device__ cudf::timestamp_ns decode_value(char const *begin, char const *end, parse_options_view const &opts) { auto milli = to_date_time(begin, end, opts.dayfirst); if (milli == -1) { return timestamp_ns{cudf::duration_ns{to_non_negative_integer<int64_t>(begin, end)}}; } else { return timestamp_ns{cudf::duration_ns{milli * 1000000}}; } } #ifndef DURATION_DECODE_VALUE #define DURATION_DECODE_VALUE(Type) \ template <> \ __inline__ __device__ Type decode_value( \ const char *begin, const char *end, parse_options_view const &opts) \ { \ return Type{to_time_delta<Type>(begin, end)}; \ } #endif DURATION_DECODE_VALUE(duration_D) DURATION_DECODE_VALUE(duration_s) DURATION_DECODE_VALUE(duration_ms) DURATION_DECODE_VALUE(duration_us) DURATION_DECODE_VALUE(duration_ns) // The purpose of this is merely to allow compilation ONLY // TODO : make this work for csv template <> __inline__ __device__ cudf::string_view decode_value(char const *begin, char const *end, parse_options_view const &opts) { return cudf::string_view{}; } // The purpose of this is merely to allow compilation ONLY template <> __inline__ __device__ cudf::dictionary32 decode_value(char const *begin, char const *end, parse_options_view const &opts) { return cudf::dictionary32{}; } // The purpose of this is merely to allow compilation ONLY // TODO : make this work for csv template <> __inline__ __device__ cudf::list_view decode_value(char const *begin, char const *end, parse_options_view const &opts) { return cudf::list_view{}; } // The purpose of this is merely to allow compilation ONLY // TODO : make this work for csv template <> __inline__ __device__ numeric::decimal32 decode_value(char const *begin, char const *end, parse_options_view const &opts) { return numeric::decimal32{}; } // The purpose of this is merely to allow compilation ONLY // TODO : make this work for csv template <> __inline__ __device__ numeric::decimal64 decode_value(char const *begin, char const *end, parse_options_view const &opts) { return numeric::decimal64{}; } // The purpose of this is merely to allow compilation ONLY // TODO : make this work for csv template <> __inline__ __device__ cudf::struct_view decode_value(char const *begin, char const *end, parse_options_view const &opts) { return cudf::struct_view{}; } /** * @brief Functor for converting CSV raw data to typed value. */ struct decode_op { /** * @brief Dispatch for numeric types whose values can be convertible to * 0 or 1 to represent boolean false/true, based upon checking against a * true/false values list. * * @return bool Whether the parsed value is valid. */ template <typename T, typename std::enable_if_t<std::is_integral<T>::value and !std::is_same<T, bool>::value> * = nullptr> __host__ __device__ __forceinline__ bool operator()(void *out_buffer, size_t row, char const *begin, char const *end, parse_options_view const &opts, column_parse::flags flags) { static_cast<T *>(out_buffer)[row] = [&flags, &opts, begin, end]() -> T { // Check for user-specified true/false values auto const field_len = static_cast<size_t>(end - begin); if (serialized_trie_contains(opts.trie_true, {begin, field_len})) { return 1; } if (serialized_trie_contains(opts.trie_false, {begin, field_len})) { return 0; } return flags & column_parse::as_hexadecimal ? decode_value<T, 16>(begin, end, opts) : decode_value<T>(begin, end, opts); }(); return true; } /** * @brief Dispatch for boolean type types. */ template <typename T, typename std::enable_if_t<std::is_same<T, bool>::value> * = nullptr> __host__ __device__ __forceinline__ bool operator()(void *out_buffer, size_t row, char const *begin, char const *end, parse_options_view const &opts, column_parse::flags flags) { static_cast<T *>(out_buffer)[row] = [&opts, begin, end]() { // Check for user-specified true/false values auto const field_len = static_cast<size_t>(end - begin); if (serialized_trie_contains(opts.trie_true, {begin, field_len})) { return true; } if (serialized_trie_contains(opts.trie_false, {begin, field_len})) { return false; } return decode_value<T>(begin, end, opts); }(); return true; } /** * @brief Dispatch for floating points, which are set to NaN if the input * is not valid. In such case, the validity mask is set to zero too. */ template <typename T, typename std::enable_if_t<std::is_floating_point<T>::value> * = nullptr> __host__ __device__ __forceinline__ bool operator()(void *out_buffer, size_t row, char const *begin, char const *end, parse_options_view const &opts, column_parse::flags flags) { T const value = decode_value<T>(begin, end, opts); static_cast<T *>(out_buffer)[row] = value; return !std::isnan(value); } /** * @brief Dispatch for all other types. */ template <typename T, typename std::enable_if_t<!std::is_integral<T>::value and !std::is_floating_point<T>::value> * = nullptr> __host__ __device__ __forceinline__ bool operator()(void *out_buffer, size_t row, char const *begin, char const *end, parse_options_view const &opts, column_parse::flags flags) { static_cast<T *>(out_buffer)[row] = decode_value<T>(begin, end, opts); return true; } }; /** * @brief CUDA kernel that parses and converts CSV data into cuDF column data. * * Data is processed one record at a time * * @param[in] raw_csv The entire CSV data to read * @param[in] opts A set of parsing options * @param[in] num_records The number of lines/rows of CSV data * @param[in] num_columns The number of columns of CSV data * @param[in] column_flags Per-column parsing behavior flags * @param[in] recStart The start the CSV data of interest * @param[in] dtype The data type of the column * @param[out] data The output column data * @param[out] valid The bitmaps indicating whether column fields are valid * @param[out] num_valid The numbers of valid fields in columns */ __global__ void __launch_bounds__(csvparse_block_dim) convert_csv_to_cudf(cudf::io::parse_options_view options, device_span<char const> data, device_span<column_parse::flags const> column_flags, device_span<uint64_t const> row_offsets, device_span<cudf::data_type const> dtypes, device_span<void *const> columns, device_span<cudf::bitmask_type *const> valids) { auto const raw_csv = data.data(); // thread IDs range per block, so also need the block id. // this is entry into the field array - tid is an elements within the num_entries array long const rec_id = threadIdx.x + (blockDim.x * blockIdx.x); long const rec_id_next = rec_id + 1; // we can have more threads than data, make sure we are not past the end of // the data if (rec_id_next >= row_offsets.size()) return; auto field_start = raw_csv + row_offsets[rec_id]; auto const row_end = raw_csv + row_offsets[rec_id_next]; auto next_field = field_start; int col = 0; int actual_col = 0; while (col < column_flags.size() && field_start <= row_end) { auto next_delimiter = cudf::io::gpu::seek_field_end(next_field, row_end, options); if (column_flags[col] & column_parse::enabled) { // check if the entire field is a NaN string - consistent with pandas auto const is_valid = !serialized_trie_contains( options.trie_na, {field_start, static_cast<size_t>(next_delimiter - field_start)}); // Modify field_start & end to ignore whitespace and quotechars auto field_end = next_delimiter; if (is_valid && dtypes[actual_col].id() != cudf::type_id::STRING) { auto const trimmed_field = trim_whitespaces_quotes(field_start, field_end, options.quotechar); field_start = trimmed_field.first; field_end = trimmed_field.second; } if (is_valid) { // Type dispatcher does not handle STRING if (dtypes[actual_col].id() == cudf::type_id::STRING) { auto end = next_delimiter; if (options.keepquotes == false) { if ((*field_start == options.quotechar) && (*(end - 1) == options.quotechar)) { ++field_start; --end; } } auto str_list = static_cast<std::pair<const char *, size_t> *>(columns[actual_col]); str_list[rec_id].first = field_start; str_list[rec_id].second = end - field_start; } else { if (cudf::type_dispatcher(dtypes[actual_col], decode_op{}, columns[actual_col], rec_id, field_start, field_end, options, column_flags[col])) { // set the valid bitmap - all bits were set to 0 to start set_bit(valids[actual_col], rec_id); } } } else if (dtypes[actual_col].id() == cudf::type_id::STRING) { auto str_list = static_cast<std::pair<const char *, size_t> *>(columns[actual_col]); str_list[rec_id].first = nullptr; str_list[rec_id].second = 0; } ++actual_col; } next_field = next_delimiter + 1; field_start = next_field; ++col; } } /* * @brief Merge two packed row contexts (each corresponding to a block of characters) * and return the packed row context corresponding to the merged character block */ inline __device__ packed_rowctx_t merge_row_contexts(packed_rowctx_t first_ctx, packed_rowctx_t second_ctx) { uint32_t id0 = get_row_context(first_ctx, ROW_CTX_NONE) & 3; uint32_t id1 = get_row_context(first_ctx, ROW_CTX_QUOTE) & 3; uint32_t id2 = get_row_context(first_ctx, ROW_CTX_COMMENT) & 3; return (first_ctx & ~pack_row_contexts(3, 3, 3)) + pack_row_contexts(get_row_context(second_ctx, id0), get_row_context(second_ctx, id1), get_row_context(second_ctx, id2)); } /* * @brief Per-character context: * 1-bit count (0 or 1) per context in the lower 4 bits * 2-bit output context id per input context in bits 8..15 */ constexpr __device__ uint32_t make_char_context(uint32_t id0, uint32_t id1, uint32_t id2 = ROW_CTX_COMMENT, uint32_t c0 = 0, uint32_t c1 = 0, uint32_t c2 = 0) { return (id0 << 8) | (id1 << 10) | (id2 << 12) | (ROW_CTX_EOF << 14) | (c0) | (c1 << 1) | (c2 << 2); } /* * @brief Merge a 1-character context to keep track of bitmasks where new rows occur * Merges a single-character "block" row context at position pos with the current * block's row context (the current block contains 32-pos characters) * * @param ctx Current block context and new rows bitmaps * @param char_ctx state transitions associated with new character * @param pos Position within the current 32-character block * * NOTE: This is probably the most performance-critical piece of the row gathering kernel. * The char_ctx value should be created via make_char_context, and its value should * have been evaluated at compile-time. */ inline __device__ void merge_char_context(uint4 &ctx, uint32_t char_ctx, uint32_t pos) { uint32_t id0 = (ctx.w >> 0) & 3; uint32_t id1 = (ctx.w >> 2) & 3; uint32_t id2 = (ctx.w >> 4) & 3; // Set the newrow bit in the bitmap at the corresponding position ctx.x |= ((char_ctx >> id0) & 1) << pos; ctx.y |= ((char_ctx >> id1) & 1) << pos; ctx.z |= ((char_ctx >> id2) & 1) << pos; // Update the output context ids ctx.w = ((char_ctx >> (8 + id0 * 2)) & 0x03) | ((char_ctx >> (6 + id1 * 2)) & 0x0c) | ((char_ctx >> (4 + id2 * 2)) & 0x30) | (ROW_CTX_EOF << 6); } /* * Convert the context-with-row-bitmaps version to a packed row context */ inline __device__ packed_rowctx_t pack_rowmaps(uint4 ctx_map) { return pack_row_contexts(make_row_context(__popc(ctx_map.x), (ctx_map.w >> 0) & 3), make_row_context(__popc(ctx_map.y), (ctx_map.w >> 2) & 3), make_row_context(__popc(ctx_map.z), (ctx_map.w >> 4) & 3)); } /* * Selects the row bitmap corresponding to the given parser state */ inline __device__ uint32_t select_rowmap(uint4 ctx_map, uint32_t ctxid) { return (ctxid == ROW_CTX_NONE) ? ctx_map.x : (ctxid == ROW_CTX_QUOTE) ? ctx_map.y : (ctxid == ROW_CTX_COMMENT) ? ctx_map.z : 0; } /** * @brief Single pair-wise 512-wide row context merge transform * * Merge row context blocks and record the merge operation in a context * tree so that the transform is reversible. * The tree is organized such that the left and right children of node n * are located at indices n*2 and n*2+1, the root node starting at index 1 * * @tparam lanemask mask to specify source of packed row context * @tparam tmask mask to specify principle thread for merging row context * @tparam base start location for writing into packed row context tree * @tparam level_scale level of the node in the tree * @param ctxtree[out] packed row context tree * @param ctxb[in] packed row context for the current character block * @param t thread id (leaf node id) */ template <uint32_t lanemask, uint32_t tmask, uint32_t base, uint32_t level_scale> inline __device__ void ctx_merge(uint64_t *ctxtree, packed_rowctx_t *ctxb, uint32_t t) { uint64_t tmp = shuffle_xor(*ctxb, lanemask); if (!(t & tmask)) { *ctxb = merge_row_contexts(*ctxb, tmp); ctxtree[base + (t >> level_scale)] = *ctxb; } } /** * @brief Single 512-wide row context inverse merge transform * * Walks the context tree starting from a root node * * @tparam rmask Mask to specify which threads write input row context * @param[in] base Start read location of the merge transform tree * @param[in] ctxtree Merge transform tree * @param[in] ctx Input context * @param[in] brow4 output row in block *4 * @param[in] t thread id (leaf node id) */ template <uint32_t rmask> inline __device__ void ctx_unmerge( uint32_t base, uint64_t *ctxtree, uint32_t *ctx, uint32_t *brow4, uint32_t t) { rowctx32_t ctxb_left, ctxb_right, ctxb_sum; ctxb_sum = get_row_context(ctxtree[base], *ctx); ctxb_left = get_row_context(ctxtree[(base)*2 + 0], *ctx); ctxb_right = get_row_context(ctxtree[(base)*2 + 1], ctxb_left & 3); if (t & (rmask)) { *brow4 += (ctxb_sum & ~3) - (ctxb_right & ~3); *ctx = ctxb_left & 3; } } /* * @brief 512-wide row context merge transform * * Repeatedly merge row context blocks, keeping track of each merge operation * in a context tree so that the transform is reversible * The tree is organized such that the left and right children of node n * are located at indices n*2 and n*2+1, the root node starting at index 1 * * Each node contains the counts and output contexts corresponding to the * possible input contexts. * Each parent node's count is obtained by adding the corresponding counts * from the left child node with the right child node's count selected from * the left child node's output context: * parent.count[k] = left.count[k] + right.count[left.outctx[k]] * parent.outctx[k] = right.outctx[left.outctx[k]] * * @param ctxtree[out] packed row context tree * @param ctxb[in] packed row context for the current character block * @param t thread id (leaf node id) */ static inline __device__ void rowctx_merge_transform(uint64_t ctxtree[1024], packed_rowctx_t ctxb, uint32_t t) { ctxtree[512 + t] = ctxb; ctx_merge<1, 0x1, 256, 1>(ctxtree, &ctxb, t); ctx_merge<2, 0x3, 128, 2>(ctxtree, &ctxb, t); ctx_merge<4, 0x7, 64, 3>(ctxtree, &ctxb, t); ctx_merge<8, 0xf, 32, 4>(ctxtree, &ctxb, t); __syncthreads(); if (t < 32) { ctxb = ctxtree[32 + t]; ctx_merge<1, 0x1, 16, 1>(ctxtree, &ctxb, t); ctx_merge<2, 0x3, 8, 2>(ctxtree, &ctxb, t); ctx_merge<4, 0x7, 4, 3>(ctxtree, &ctxb, t); ctx_merge<8, 0xf, 2, 4>(ctxtree, &ctxb, t); // Final stage uint64_t tmp = shuffle_xor(ctxb, 16); if (t == 0) { ctxtree[1] = merge_row_contexts(ctxb, tmp); } } } /* * @brief 512-wide row context inverse merge transform * * Walks the context tree starting from the root node (index 1) using * the starting context in node index 0. * The return value is the starting row and input context for the given leaf node * * @param[in] ctxtree Merge transform tree * @param[in] t thread id (leaf node id) * * @return Final row context and count (row_position*4 + context_id format) */ static inline __device__ rowctx32_t rowctx_inverse_merge_transform(uint64_t ctxtree[1024], uint32_t t) { uint32_t ctx = ctxtree[0] & 3; // Starting input context rowctx32_t brow4 = 0; // output row in block *4 ctx_unmerge<256>(1, ctxtree, &ctx, &brow4, t); ctx_unmerge<128>(2 + (t >> 8), ctxtree, &ctx, &brow4, t); ctx_unmerge<64>(4 + (t >> 7), ctxtree, &ctx, &brow4, t); ctx_unmerge<32>(8 + (t >> 6), ctxtree, &ctx, &brow4, t); ctx_unmerge<16>(16 + (t >> 5), ctxtree, &ctx, &brow4, t); ctx_unmerge<8>(32 + (t >> 4), ctxtree, &ctx, &brow4, t); ctx_unmerge<4>(64 + (t >> 3), ctxtree, &ctx, &brow4, t); ctx_unmerge<2>(128 + (t >> 2), ctxtree, &ctx, &brow4, t); ctx_unmerge<1>(256 + (t >> 1), ctxtree, &ctx, &brow4, t); return brow4 + ctx; } /** * @brief Gather row offsets from CSV character data split into 16KB chunks * * This is done in two phases: the first phase returns the possible row counts * per 16K character block for each possible parsing context at the start of the block, * along with the resulting parsing context at the end of the block. * The caller can then compute the actual parsing context at the beginning of each * individual block and total row count. * The second phase outputs the location of each row in the block, using the parsing * context and initial row counter accumulated from the results of the previous phase. * Row parsing context will be updated after phase 2 such that the value contains * the number of rows starting at byte_range_end or beyond. * * @param row_ctx Row parsing context (output of phase 1 or input to phase 2) * @param offsets_out Row offsets (nullptr for phase1, non-null indicates phase 2) * @param data Base pointer of character data (all row offsets are relative to this) * @param chunk_size Total number of characters to parse * @param parse_pos Current parsing position in the file * @param start_offset Position of the start of the character buffer in the file * @param data_size CSV file size * @param byte_range_start Ignore rows starting before this position in the file * @param byte_range_end In phase 2, store the number of rows beyond range in row_ctx * @param skip_rows Number of rows to skip (ignored in phase 1) * @param terminator Line terminator character * @param delimiter Column delimiter character * @param quotechar Quote character * @param escapechar Delimiter escape character * @param commentchar Comment line character (skip rows starting with this character) */ __global__ void __launch_bounds__(rowofs_block_dim) gather_row_offsets_gpu(uint64_t *row_ctx, device_span<uint64_t> offsets_out, device_span<char const> const data, size_t chunk_size, size_t parse_pos, size_t start_offset, size_t data_size, size_t byte_range_start, size_t byte_range_end, size_t skip_rows, int terminator, int delimiter, int quotechar, int escapechar, int commentchar) { auto start = data.begin(); using block_reduce = typename cub::BlockReduce<uint32_t, rowofs_block_dim>; __shared__ union { typename block_reduce::TempStorage bk_storage; __align__(8) uint64_t ctxtree[rowofs_block_dim * 2]; } temp_storage; const char *end = start + (min(parse_pos + chunk_size, data_size) - start_offset); uint32_t t = threadIdx.x; size_t block_pos = (parse_pos - start_offset) + blockIdx.x * static_cast<size_t>(rowofs_block_bytes) + t * 32; const char *cur = start + block_pos; // Initial state is neutral context (no state transitions), zero rows uint4 ctx_map = { .x = 0, .y = 0, .z = 0, .w = (ROW_CTX_NONE << 0) | (ROW_CTX_QUOTE << 2) | (ROW_CTX_COMMENT << 4) | (ROW_CTX_EOF << 6)}; int c, c_prev = (cur > start && cur <= end) ? cur[-1] : terminator; // Loop through all 32 bytes and keep a bitmask of row starts for each possible input context for (uint32_t pos = 0; pos < 32; pos++, cur++, c_prev = c) { uint32_t ctx; if (cur < end) { c = cur[0]; if (c_prev == terminator) { if (c == commentchar) { // Start of a new comment row ctx = make_char_context(ROW_CTX_COMMENT, ROW_CTX_QUOTE, ROW_CTX_COMMENT, 1, 0, 1); } else if (c == quotechar) { // Quoted string on newrow, or quoted string ending in terminator ctx = make_char_context(ROW_CTX_QUOTE, ROW_CTX_NONE, ROW_CTX_QUOTE, 1, 0, 1); } else { // Start of a new row unless within a quote ctx = make_char_context(ROW_CTX_NONE, ROW_CTX_QUOTE, ROW_CTX_NONE, 1, 0, 1); } } else if (c == quotechar) { if (c_prev == delimiter || c_prev == quotechar) { // Quoted string after delimiter, quoted string ending in delimiter, or double-quote ctx = make_char_context(ROW_CTX_QUOTE, ROW_CTX_NONE); } else { // Closing or ignored quote ctx = make_char_context(ROW_CTX_NONE, ROW_CTX_NONE); } } else { // Neutral character ctx = make_char_context(ROW_CTX_NONE, ROW_CTX_QUOTE); } } else { const char *data_end = start + data_size - start_offset; if (cur <= end && cur == data_end) { // Add a newline at data end (need the extra row offset to infer length of previous row) ctx = make_char_context(ROW_CTX_EOF, ROW_CTX_EOF, ROW_CTX_EOF, 1, 1, 1); } else { // Pass-through context (beyond chunk_size or data_end) ctx = make_char_context(ROW_CTX_NONE, ROW_CTX_QUOTE, ROW_CTX_COMMENT); } } // Merge with current context, keeping track of where new rows occur merge_char_context(ctx_map, ctx, pos); } // Eliminate rows that start before byte_range_start if (start_offset + block_pos < byte_range_start) { uint32_t dist_minus1 = min(byte_range_start - (start_offset + block_pos) - 1, UINT64_C(31)); uint32_t mask = 0xfffffffe << dist_minus1; ctx_map.x &= mask; ctx_map.y &= mask; ctx_map.z &= mask; } // Convert the long-form {rowmap,outctx}[inctx] version into packed version // {rowcount,ouctx}[inctx], then merge the row contexts of the 32-character blocks into // a single 16K-character block context rowctx_merge_transform(temp_storage.ctxtree, pack_rowmaps(ctx_map), t); // If this is the second phase, get the block's initial parser state and row counter if (offsets_out.data()) { if (t == 0) { temp_storage.ctxtree[0] = row_ctx[blockIdx.x]; } __syncthreads(); // Walk back the transform tree with the known initial parser state rowctx32_t ctx = rowctx_inverse_merge_transform(temp_storage.ctxtree, t); uint64_t row = (temp_storage.ctxtree[0] >> 2) + (ctx >> 2); uint32_t rows_out_of_range = 0; uint32_t rowmap = select_rowmap(ctx_map, ctx & 3); // Output row positions while (rowmap != 0) { uint32_t pos = __ffs(rowmap); block_pos += pos; if (row >= skip_rows && row - skip_rows < offsets_out.size()) { // Output byte offsets are relative to the base of the input buffer offsets_out[row - skip_rows] = block_pos - 1; rows_out_of_range += (start_offset + block_pos - 1 >= byte_range_end); } row++; rowmap >>= pos; } __syncthreads(); // Return the number of rows out of range rows_out_of_range = block_reduce(temp_storage.bk_storage).Sum(rows_out_of_range); if (t == 0) { row_ctx[blockIdx.x] = rows_out_of_range; } } else { // Just store the row counts and output contexts if (t == 0) { row_ctx[blockIdx.x] = temp_storage.ctxtree[1]; } } } size_t __host__ count_blank_rows(const cudf::io::parse_options_view &opts, device_span<char const> data, device_span<uint64_t const> row_offsets, rmm::cuda_stream_view stream) { const auto newline = opts.skipblanklines ? opts.terminator : opts.comment; const auto comment = opts.comment != '\0' ? opts.comment : newline; const auto carriage = (opts.skipblanklines && opts.terminator == '\n') ? '\r' : comment; return thrust::count_if( rmm::exec_policy(stream), row_offsets.begin(), row_offsets.end(), [data = data, newline, comment, carriage] __device__(const uint64_t pos) { return ((pos != data.size()) && (data[pos] == newline || data[pos] == comment || data[pos] == carriage)); }); } device_span<uint64_t> __host__ remove_blank_rows(cudf::io::parse_options_view const &options, device_span<char const> data, device_span<uint64_t> row_offsets, rmm::cuda_stream_view stream) { size_t d_size = data.size(); const auto newline = options.skipblanklines ? options.terminator : options.comment; const auto comment = options.comment != '\0' ? options.comment : newline; const auto carriage = (options.skipblanklines && options.terminator == '\n') ? '\r' : comment; auto new_end = thrust::remove_if( rmm::exec_policy(stream), row_offsets.begin(), row_offsets.end(), [data = data, d_size, newline, comment, carriage] __device__(const uint64_t pos) { return ((pos != d_size) && (data[pos] == newline || data[pos] == comment || data[pos] == carriage)); }); return row_offsets.subspan(0, new_end - row_offsets.begin()); } std::vector<column_type_histogram> detect_column_types( cudf::io::parse_options_view const &options, device_span<char const> const data, device_span<column_parse::flags const> const column_flags, device_span<uint64_t const> const row_starts, size_t const num_active_columns, rmm::cuda_stream_view stream) { // Calculate actual block count to use based on records count const int block_size = csvparse_block_dim; const int grid_size = (row_starts.size() + block_size - 1) / block_size; auto d_stats = detail::make_zeroed_device_uvector_async<column_type_histogram>(num_active_columns, stream); data_type_detection<<<grid_size, block_size, 0, stream.value()>>>( options, data, column_flags, row_starts, d_stats); return detail::make_std_vector_sync(d_stats, stream); } void __host__ decode_row_column_data(cudf::io::parse_options_view const &options, device_span<char const> data, device_span<column_parse::flags const> column_flags, device_span<uint64_t const> row_offsets, device_span<cudf::data_type const> dtypes, device_span<void *const> columns, device_span<cudf::bitmask_type *const> valids, rmm::cuda_stream_view stream) { // Calculate actual block count to use based on records count auto const block_size = csvparse_block_dim; auto const num_rows = row_offsets.size() - 1; auto const grid_size = (num_rows + block_size - 1) / block_size; convert_csv_to_cudf<<<grid_size, block_size, 0, stream.value()>>>( options, data, column_flags, row_offsets, dtypes, columns, valids); } uint32_t __host__ gather_row_offsets(const parse_options_view &options, uint64_t *row_ctx, device_span<uint64_t> const offsets_out, device_span<char const> const data, size_t chunk_size, size_t parse_pos, size_t start_offset, size_t data_size, size_t byte_range_start, size_t byte_range_end, size_t skip_rows, rmm::cuda_stream_view stream) { uint32_t dim_grid = 1 + (chunk_size / rowofs_block_bytes); gather_row_offsets_gpu<<<dim_grid, rowofs_block_dim, 0, stream.value()>>>( row_ctx, offsets_out, data, chunk_size, parse_pos, start_offset, data_size, byte_range_start, byte_range_end, skip_rows, options.terminator, options.delimiter, (options.quotechar) ? options.quotechar : 0x100, /*(options.escapechar) ? options.escapechar :*/ 0x100, (options.comment) ? options.comment : 0x100); return dim_grid; } } // namespace gpu } // namespace csv } // namespace io } // namespace cudf
e2af4929a62f8493749c87d8fb168b7aae78ad0f.hip
// !!! This is a file automatically generated by hipify!!! // mpi_main.cu: test driver. #include "HZ.hpp" #include "HZ_L.hpp" #include "HZ_L3.hpp" #include "my_utils.hpp" #include "cuda_memory_helper.hpp" int main(int argc, char *argv[]) { if (9 != argc) { (void)snprintf(err_msg, err_msg_size, "%s SNP0 SNP1 SNP2 ALG MF MG N FN", *argv); DIE(err_msg); } const char *const ca_exe = argv[0]; const char *const ca_snp0 = argv[1]; const char *const ca_snp1 = argv[2]; const char *const ca_snp2 = argv[3]; const char *const ca_alg = argv[4]; const char *const ca_mF = argv[5]; const char *const ca_mG = argv[6]; const char *const ca_n = argv[7]; const char *const ca_fn = argv[8]; const unsigned routine = static_cast<unsigned>(atou(ca_alg)); const size_t mF = atou(ca_mF); const size_t mG = atou(ca_mG); const size_t n = atou(ca_n); if (n > mF) { DIE("N > MF"); } if (n > mG) { DIE("N > MG"); } const unsigned snp0 = static_cast<unsigned>(atou(ca_snp0)); if ((snp0 != STRAT_CYCWOR) && (snp0 != STRAT_MMSTEP)) { DIE("SNP0 \\notin { 2, 4 }"); } const unsigned snp1 = static_cast<unsigned>(atou(ca_snp1)); if ((snp1 != STRAT_CYCWOR) && (snp1 != STRAT_MMSTEP)) { DIE("SNP1 \\notin { 2, 4 }"); } const unsigned snp2 = static_cast<unsigned>(atou(ca_snp2)); if ((snp2 != (STRAT_CYCWOR + 1u)) && (snp2 != (STRAT_MMSTEP + 1u))) { DIE("SNP2 \\notin { 3, 5 }"); } if (!*ca_fn) { DIE("invalid argument FN"); } if (init_MPI(&argc, &argv)) { (void)snprintf(err_msg, err_msg_size, "%s[%d] init_MPI failed\n", ca_exe, mpi_rank); DIE(err_msg); } if (!mpi_cuda_aware) { DIE("MPI is not CUDA aware"); } const size_t gpu = static_cast<size_t>(mpi_rank); const size_t gpus = static_cast<size_t>(mpi_size); if (gpus < 2u) { DIE("MPI_COMM_WORLD size < 2"); } const size_t n2 = (gpus << 1u); if (n < n2) { DIE("N < n2"); } const int dev = assign_dev2host(); if (dev < 0) { DIE("assign_dev2host failed"); } if (MPI_Barrier(MPI_COMM_WORLD)) { DIE("MPI_Barrier1"); } const int dcc = configureGPU(dev); (void)fprintf(stderr, "[%u] device(%d) has CC(%d)\n", gpu, dev, dcc); (void)fflush(stderr); size_t mF_ = 0u, mG_ = 0u, n_ = 0u; border_sizes(gpus, mF, mG, n, mF_, mG_, n_); const size_t n_gpu = n_ / gpus; const size_t n_col = (n_gpu >> 1u); const size_t n0 = (HZ_L1_NCOLB << 1u); const size_t n1 = n_gpu / HZ_L1_NCOLB; if (n_gpu % HZ_L1_NCOLB) { DIE("n_gpu % 16 != 0"); } init_strats(snp0, n0, snp1, n1, snp2, n2); const size_t p = static_cast<size_t>(strat2[0u][gpu][0u][0u]); const size_t q = static_cast<size_t>(strat2[0u][gpu][0u][1u]); size_t ldhF = mF_, ldhG = mG_, ldhV = n_; const size_t p_ = p * n_col; const size_t n_p = ((p_ >= n) ? static_cast<size_t>(0u) : (((p_ + n_col) > n) ? (n - p_) : n_col)); const MPI_Offset opF = static_cast<MPI_Offset>((p_ * mF) #ifdef USE_COMPLEX * 2u #endif /* USE_COMPLEX */ ); const MPI_Offset opG = static_cast<MPI_Offset>((p_ * mG) #ifdef USE_COMPLEX * 2u #endif /* USE_COMPLEX */ ); const MPI_Offset opV = static_cast<MPI_Offset>((p_ * n) #ifdef USE_COMPLEX * 2u #endif /* USE_COMPLEX */ ); const MPI_Offset opS = static_cast<MPI_Offset>(p_); const size_t q_ = q * n_col; const size_t n_q = ((q_ >= n) ? static_cast<size_t>(0u) : (((q_ + n_col) > n) ? (n - q_) : n_col)); const MPI_Offset oqF = static_cast<MPI_Offset>((q_ * mF) #ifdef USE_COMPLEX * 2u #endif /* USE_COMPLEX */ ); const MPI_Offset oqG = static_cast<MPI_Offset>((q_ * mG) #ifdef USE_COMPLEX * 2u #endif /* USE_COMPLEX */ ); const MPI_Offset oqV = static_cast<MPI_Offset>((q_ * n) #ifdef USE_COMPLEX * 2u #endif /* USE_COMPLEX */ ); const MPI_Offset oqS = static_cast<MPI_Offset>(q_); char *const fn = static_cast<char*>(calloc(strlen(ca_fn) + 4u, sizeof(char))); SYSP_CALL(fn); #ifdef USE_COMPLEX double *const buf = static_cast<double*>(calloc((((mF >= mG) ? mF : mG) * 2u), sizeof(double))); SYSP_CALL(buf); #endif /* USE_COMPLEX */ MPI_File fh = MPI_FILE_NULL; size_t ldA = static_cast<size_t>(0u); ldA = ldhF; #ifdef USE_COMPLEX cuD *const hFD = allocHostMtx<cuD>(ldA, mF_, n_gpu, true); SYSP_CALL(hFD); cuJ *const hFJ = allocHostMtx<cuJ>(ldA, mF_, n_gpu, true); SYSP_CALL(hFJ); #else /* !USE_COMPLEX */ double *const hF = allocHostMtx<double>(ldA, mF_, n_gpu, true); SYSP_CALL(hF); #endif /* ?USE_COMPLEX */ ldhF = ldA; if (MPI_File_open(MPI_COMM_WORLD, strcat(strcpy(fn, ca_fn), ".Y"), MPI_MODE_RDONLY, MPI_INFO_NULL, &fh)) { DIE("MPI_File_open(Y)"); } if (MPI_File_set_view(fh, 0, MPI_DOUBLE, MPI_DOUBLE, "native", MPI_INFO_NULL)) { DIE("MPI_File_set_view(Y)"); } #ifdef USE_COMPLEX for (size_t j = 0u; j < n_p; ++j) { if (MPI_File_read_at(fh, (opF + j * mF * 2u), buf, (mF * 2u), MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_read_at(Y)p"); } const size_t o = (ldA * j); cuD *const cD = (hFD + o); cuJ *const cJ = (hFJ + o); for (size_t i = 0u; i < mF; ++i) { const size_t i2 = (i * 2u); cD[i] = static_cast<cuD>(buf[i2]); cJ[i] = static_cast<cuJ>(buf[i2 + 1u]); } } for (size_t j = 0u; j < n_q; ++j) { if (MPI_File_read_at(fh, (oqF + j * mF * 2u), buf, (mF * 2u), MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_read_at(Y)q"); } const size_t o = (ldA * (n_col + j)); cuD *const cD = (hFD + o); cuJ *const cJ = (hFJ + o); for (size_t i = 0u; i < mF; ++i) { const size_t i2 = (i * 2u); cD[i] = static_cast<cuD>(buf[i2]); cJ[i] = static_cast<cuJ>(buf[i2 + 1u]); } } #else /* !USE_COMPLEX */ for (size_t j = 0u; j < n_p; ++j) { if (MPI_File_read_at(fh, (opF + j * mF), (hF + ldA * j), mF, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_read_at(Y)p"); } } for (size_t j = 0u; j < n_q; ++j) { if (MPI_File_read_at(fh, (oqF + j * mF), (hF + ldA * (n_col + j)), mF, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_read_at(Y)q"); } } #endif /* ?USE_COMPLEX */ if (MPI_File_close(&fh)) { DIE("MPI_File_close(Y)"); } if ((p_ + n_col) > n) { if (p_ >= n) { const size_t o = (p_ - n); #ifdef USE_COMPLEX SYSI_CALL(bdinit((mF + o), (o + 1u), hFD, ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit((mF + o), (o + 1u), hF, ldA)); #endif /* ?USE_COMPLEX */ } else { const size_t f = (n - p_); #ifdef USE_COMPLEX SYSI_CALL(bdinit(mF, (n_col - f), (hFD + ldA * f), ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit(mF, (n_col - f), (hF + ldA * f), ldA)); #endif /* ?USE_COMPLEX */ } } if ((q_ + n_col) > n) { if (q_ >= n) { const size_t o = (q_ - n); #ifdef USE_COMPLEX SYSI_CALL(bdinit((mF + o), (o + 1u), (hFD + ldA * n_col), ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit((mF + o), (o + 1u), (hF + ldA * n_col), ldA)); #endif /* ?USE_COMPLEX */ } else { const size_t f = (n - p_); #ifdef USE_COMPLEX SYSI_CALL(bdinit(mF, (n_col - f), (hFD + ldA * (n_col + f)), ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit(mF, (n_col - f), (hF + ldA * (n_col + f)), ldA)); #endif /* ?USE_COMPLEX */ } } ldA = ldhG; #ifdef USE_COMPLEX cuD *const hGD = allocHostMtx<cuD>(ldA, mG_, n_gpu, true); SYSP_CALL(hGD); cuJ *const hGJ = allocHostMtx<cuJ>(ldA, mG_, n_gpu, true); SYSP_CALL(hGJ); #else /* !USE_COMPLEX */ double *const hG = allocHostMtx<double>(ldA, mG_, n_gpu, true); SYSP_CALL(hG); #endif /* ?USE_COMPLEX */ ldhG = ldA; if (MPI_File_open(MPI_COMM_WORLD, strcat(strcpy(fn, ca_fn), ".W"), MPI_MODE_RDONLY, MPI_INFO_NULL, &fh)) { DIE("MPI_File_open(W)"); } if (MPI_File_set_view(fh, 0, MPI_DOUBLE, MPI_DOUBLE, "native", MPI_INFO_NULL)) { DIE("MPI_File_set_view(W)"); } #ifdef USE_COMPLEX for (size_t j = 0u; j < n_p; ++j) { if (MPI_File_read_at(fh, (opG + j * mG * 2u), buf, (mG * 2u), MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_read_at(W)p"); } const size_t o = (ldA * j); cuD *const cD = (hGD + o); cuJ *const cJ = (hGJ + o); for (size_t i = 0u; i < mG; ++i) { const size_t i2 = (i * 2u); cD[i] = static_cast<cuD>(buf[i2]); cJ[i] = static_cast<cuJ>(buf[i2 + 1u]); } } for (size_t j = 0u; j < n_q; ++j) { if (MPI_File_read_at(fh, (oqG + j * mG * 2u), buf, (mG * 2u), MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_read_at(W)q"); } const size_t o = (ldA * (n_col + j)); cuD *const cD = (hGD + o); cuJ *const cJ = (hGJ + o); for (size_t i = 0u; i < mG; ++i) { const size_t i2 = (i * 2u); cD[i] = static_cast<cuD>(buf[i2]); cJ[i] = static_cast<cuJ>(buf[i2 + 1u]); } } #else /* !USE_COMPLEX */ for (size_t j = 0u; j < n_p; ++j) { if (MPI_File_read_at(fh, (opG + j * mG), (hG + ldA * j), mG, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_read_at(W)p"); } } for (size_t j = 0u; j < n_q; ++j) { if (MPI_File_read_at(fh, (oqG + j * mG), (hG + ldA * (n_col + j)), mG, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_read_at(W)q"); } } #endif /* ?USE_COMPLEX */ if (MPI_File_close(&fh)) { DIE("MPI_File_close(W)"); } if ((p_ + n_col) > n) { if (p_ >= n) { const size_t o = (p_ - n); #ifdef USE_COMPLEX SYSI_CALL(bdinit((mG + o), (o + 1u), hGD, ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit((mG + o), (o + 1u), hG, ldA)); #endif /* ?USE_COMPLEX */ } else { const size_t f = (n - p_); #ifdef USE_COMPLEX SYSI_CALL(bdinit(mG, (n_col - f), (hGD + ldA * f), ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit(mG, (n_col - f), (hG + ldA * f), ldA)); #endif /* ?USE_COMPLEX */ } } if ((q_ + n_col) > n) { if (q_ >= n) { const size_t o = (q_ - n); #ifdef USE_COMPLEX SYSI_CALL(bdinit((mG + o), (o + 1u), (hGD + ldA * n_col), ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit((mG + o), (o + 1u), (hG + ldA * n_col), ldA)); #endif /* ?USE_COMPLEX */ } else { const size_t f = (n - p_); #ifdef USE_COMPLEX SYSI_CALL(bdinit(mG, (n_col - f), (hGD + ldA * (n_col + f)), ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit(mG, (n_col - f), (hG + ldA * (n_col + f)), ldA)); #endif /* ?USE_COMPLEX */ } } ldA = ldhV; #ifdef USE_COMPLEX cuD *const hVD = allocHostMtx<cuD>(ldA, n_, n_gpu, true); SYSP_CALL(hVD); cuJ *const hVJ = allocHostMtx<cuJ>(ldA, n_, n_gpu, true); SYSP_CALL(hVJ); #else /* !USE_COMPLEX */ double *const hV = allocHostMtx<double>(ldA, n_, n_gpu, true); SYSP_CALL(hV); #endif /* ?USE_COMPLEX */ ldhV = ldA; if ((p_ + n_col) > n) { if (p_ >= n) { const size_t o = (p_ - n); #ifdef USE_COMPLEX SYSI_CALL(bdinit((n + o), (o + 1u), hVD, ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit((n + o), (o + 1u), hV, ldA)); #endif /* ?USE_COMPLEX */ } else { const size_t f = (n - p_); #ifdef USE_COMPLEX SYSI_CALL(bdinit(n, (n_col - f), (hVD + ldA * f), ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit(n, (n_col - f), (hV + ldA * f), ldA)); #endif /* ?USE_COMPLEX */ } } if ((q_ + n_col) > n) { if (q_ >= n) { const size_t o = (q_ - n); #ifdef USE_COMPLEX SYSI_CALL(bdinit((n + o), (o + 1u), (hVD + ldA * n_col), ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit((n + o), (o + 1u), (hV + ldA * n_col), ldA)); #endif /* ?USE_COMPLEX */ } else { const size_t f = (n - p_); #ifdef USE_COMPLEX SYSI_CALL(bdinit(n, (n_col - f), (hVD + ldA * (n_col + f)), ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit(n, (n_col - f), (hV + ldA * (n_col + f)), ldA)); #endif /* ?USE_COMPLEX */ } } double *const hS = allocHostVec<double>(n_gpu); SYSP_CALL(hS); double *const hH = allocHostVec<double>(n_gpu); SYSP_CALL(hH); double *const hK = allocHostVec<double>(n_gpu); SYSP_CALL(hK); unsigned glbSwp = 0u; unsigned long long glb_s = 0ull, glb_b = 0ull; double timing = -0.0; if (MPI_Barrier(MPI_COMM_WORLD)) { DIE("MPI_Barrier2"); } #ifdef USE_COMPLEX const int ret = HZ_L3(routine, gpu, gpus, mF_, mG_, n_, n_gpu, n_col, hFD, hFJ, ldhF, hGD, hGJ, ldhG, hVD, hVJ, ldhV, hS, hH, hK, glbSwp, glb_s, glb_b, timing); #else /* !USE_COMPLEX */ const int ret = HZ_L3(routine, gpu, gpus, mF_, mG_, n_, n_gpu, n_col, hF, ldhF, hG, ldhG, hV, ldhV, hS, hH, hK, glbSwp, glb_s, glb_b, timing); #endif /* ?USE_COMPLEX */ if (ret) { (void)snprintf(err_msg, err_msg_size, "%s: error %d", ca_exe, ret); DIE(err_msg); } else if (!gpu) { (void)fprintf(stdout, "GLB_ROT_S(%15llu), GLB_ROT_B(%15llu)\n", glb_s, glb_b); (void)fprintf(stdout, "%#16.6f s %2u sweeps\n", timing, glbSwp); (void)fflush(stdout); } if (MPI_File_open(MPI_COMM_WORLD, strcat(strcpy(fn, ca_fn), ".YU"), (MPI_MODE_WRONLY | MPI_MODE_CREATE), MPI_INFO_NULL, &fh)) { DIE("MPI_File_open(YU)"); } if (MPI_File_set_size(fh, (mF * n * sizeof(double) #ifdef USE_COMPLEX * 2u #endif /* USE_COMPLEX */ ))) { DIE("MPI_File_set_size(YU)"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(YU)"); } if (MPI_File_set_view(fh, 0, MPI_DOUBLE, MPI_DOUBLE, "native", MPI_INFO_NULL)) { DIE("MPI_File_set_view(YU)"); } #ifdef USE_COMPLEX for (size_t j = 0u; j < n_p; ++j) { const size_t o = (ldhF * j); const cuD *const cD = (hFD + o); const cuJ *const cJ = (hFJ + o); for (size_t i = 0u; i < mF; ++i) { const size_t i2 = (i * 2u); buf[i2] = static_cast<double>(cD[i]); buf[i2 + 1u] = static_cast<double>(cJ[i]); } if (MPI_File_write_at(fh, (opF + j * mF * 2u), buf, (mF * 2u), MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(YU)p"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(YU)p"); } for (size_t j = 0u; j < n_q; ++j) { const size_t o = (ldhF * (n_col + j)); const cuD *const cD = (hFD + o); const cuJ *const cJ = (hFJ + o); for (size_t i = 0u; i < mF; ++i) { const size_t i2 = (i * 2u); buf[i2] = static_cast<double>(cD[i]); buf[i2 + 1u] = static_cast<double>(cJ[i]); } if (MPI_File_write_at(fh, (oqF + j * mF * 2u), buf, (mF * 2u), MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(YU)q"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(YU)q"); } #else /* !USE_COMPLEX */ for (size_t j = 0u; j < n_p; ++j) { if (MPI_File_write_at(fh, (opF + j * mF), (hF + ldhF * j), mF, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(YU)p"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(YU)p"); } for (size_t j = 0u; j < n_q; ++j) { if (MPI_File_write_at(fh, (oqF + j * mF), (hF + ldhF * (n_col + j)), mF, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(YU)q"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(YU)q"); } #endif /* ?USE_COMPLEX */ if (MPI_File_close(&fh)) { DIE("MPI_File_close(YU)"); } if (MPI_File_open(MPI_COMM_WORLD, strcat(strcpy(fn, ca_fn), ".WV"), (MPI_MODE_WRONLY | MPI_MODE_CREATE), MPI_INFO_NULL, &fh)) { DIE("MPI_File_open(WV)"); } if (MPI_File_set_size(fh, (mG * n * sizeof(double) #ifdef USE_COMPLEX * 2u #endif /* USE_COMPLEX */ ))) { DIE("MPI_File_set_size(WV)"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(WV)"); } if (MPI_File_set_view(fh, 0, MPI_DOUBLE, MPI_DOUBLE, "native", MPI_INFO_NULL)) { DIE("MPI_File_set_view(WV)"); } #ifdef USE_COMPLEX for (size_t j = 0u; j < n_p; ++j) { const size_t o = (ldhG * j); const cuD *const cD = (hGD + o); const cuJ *const cJ = (hGJ + o); for (size_t i = 0u; i < mG; ++i) { const size_t i2 = (i * 2u); buf[i2] = static_cast<double>(cD[i]); buf[i2 + 1u] = static_cast<double>(cJ[i]); } if (MPI_File_write_at(fh, (opG + j * mG * 2u), buf, (mG * 2u), MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(WV)p"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(WV)p"); } for (size_t j = 0u; j < n_q; ++j) { const size_t o = (ldhG * (n_col + j)); const cuD *const cD = (hGD + o); const cuJ *const cJ = (hGJ + o); for (size_t i = 0u; i < mG; ++i) { const size_t i2 = (i * 2u); buf[i2] = static_cast<double>(cD[i]); buf[i2 + 1u] = static_cast<double>(cJ[i]); } if (MPI_File_write_at(fh, (oqG + j * mG * 2u), buf, (mG * 2u), MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(WV)q"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(WV)q"); } #else /* !USE_COMPLEX */ for (size_t j = 0u; j < n_p; ++j) { if (MPI_File_write_at(fh, (opG + j * mG), (hG + ldhG * j), mG, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(WV)p"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(WV)p"); } for (size_t j = 0u; j < n_q; ++j) { if (MPI_File_write_at(fh, (oqG + j * mG), (hG + ldhG * (n_col + j)), mG, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(WV)q"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(WV)q"); } #endif /* ?USE_COMPLEX */ if (MPI_File_close(&fh)) { DIE("MPI_File_close(WV)"); } if (MPI_File_open(MPI_COMM_WORLD, strcat(strcpy(fn, ca_fn), ".Z"), (MPI_MODE_WRONLY | MPI_MODE_CREATE), MPI_INFO_NULL, &fh)) { DIE("MPI_File_open(Z)"); } if (MPI_File_set_size(fh, (n * n * sizeof(double) #ifdef USE_COMPLEX * 2u #endif /* USE_COMPLEX */ ))) { DIE("MPI_File_set_size(Z)"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(Z)"); } if (MPI_File_set_view(fh, 0, MPI_DOUBLE, MPI_DOUBLE, "native", MPI_INFO_NULL)) { DIE("MPI_File_set_view(Z)"); } #ifdef USE_COMPLEX for (size_t j = 0u; j < n_p; ++j) { const size_t o = (ldhV * j); const cuD *const cD = (hVD + o); const cuJ *const cJ = (hVJ + o); for (size_t i = 0u; i < n; ++i) { const size_t i2 = (i * 2u); buf[i2] = static_cast<double>(cD[i]); buf[i2 + 1u] = static_cast<double>(cJ[i]); } if (MPI_File_write_at(fh, (opV + j * n * 2u), buf, (n * 2u), MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(Z)p"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(Z)p"); } for (size_t j = 0u; j < n_q; ++j) { const size_t o = (ldhV * (n_col + j)); const cuD *const cD = (hVD + o); const cuJ *const cJ = (hVJ + o); for (size_t i = 0u; i < n; ++i) { const size_t i2 = (i * 2u); buf[i2] = static_cast<double>(cD[i]); buf[i2 + 1u] = static_cast<double>(cJ[i]); } if (MPI_File_write_at(fh, (oqV + j * n * 2u), buf, (n * 2u), MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(Z)q"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(Z)q"); } #else /* !USE_COMPLEX */ for (size_t j = 0u; j < n_p; ++j) { if (MPI_File_write_at(fh, (opV + j * n), (hV + ldhV * j), n, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(Z)p"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(Z)p"); } for (size_t j = 0u; j < n_q; ++j) { if (MPI_File_write_at(fh, (oqV + j * n), (hV + ldhV * (n_col + j)), n, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(Z)q"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(Z)q"); } #endif /* ?USE_COMPLEX */ if (MPI_File_close(&fh)) { DIE("MPI_File_close(Z)"); } if (MPI_File_open(MPI_COMM_WORLD, strcat(strcpy(fn, ca_fn), ".SS"), (MPI_MODE_WRONLY | MPI_MODE_CREATE), MPI_INFO_NULL, &fh)) { DIE("MPI_File_open(SS)"); } if (MPI_File_set_size(fh, (n * sizeof(double)))) { DIE("MPI_File_set_size(SS)"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(SS)"); } if (MPI_File_set_view(fh, 0, MPI_DOUBLE, MPI_DOUBLE, "native", MPI_INFO_NULL)) { DIE("MPI_File_set_view(SS)"); } if (MPI_File_write_at(fh, opS, hS, n_p, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(SS)p"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(SS)p"); } if (MPI_File_write_at(fh, oqS, (hS + n_col), n_q, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(SS)q"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(SS)q"); } if (MPI_File_close(&fh)) { DIE("MPI_File_close(SS)"); } if (MPI_File_open(MPI_COMM_WORLD, strcat(strcpy(fn, ca_fn), ".SY"), (MPI_MODE_WRONLY | MPI_MODE_CREATE), MPI_INFO_NULL, &fh)) { DIE("MPI_File_open(SY)"); } if (MPI_File_set_size(fh, (n * sizeof(double)))) { DIE("MPI_File_set_size(SY)"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(SY)"); } if (MPI_File_set_view(fh, 0, MPI_DOUBLE, MPI_DOUBLE, "native", MPI_INFO_NULL)) { DIE("MPI_File_set_view(SY)"); } if (MPI_File_write_at(fh, opS, hH, n_p, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(SY)p"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(SY)p"); } if (MPI_File_write_at(fh, oqS, (hH + n_col), n_q, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(SY)q"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(SY)q"); } if (MPI_File_close(&fh)) { DIE("MPI_File_close(SY)"); } if (MPI_File_open(MPI_COMM_WORLD, strcat(strcpy(fn, ca_fn), ".SW"), (MPI_MODE_WRONLY | MPI_MODE_CREATE), MPI_INFO_NULL, &fh)) { DIE("MPI_File_open(SW)"); } if (MPI_File_set_size(fh, (n * sizeof(double)))) { DIE("MPI_File_set_size(SW)"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(SW)"); } if (MPI_File_set_view(fh, 0, MPI_DOUBLE, MPI_DOUBLE, "native", MPI_INFO_NULL)) { DIE("MPI_File_set_view(SW)"); } if (MPI_File_write_at(fh, opS, hK, n_p, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(SW)p"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(SW)p"); } if (MPI_File_write_at(fh, oqS, (hK + n_col), n_q, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(SW)q"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(SW)q"); } if (MPI_File_close(&fh)) { DIE("MPI_File_close(SW)"); } if (hK) CUDA_CALL(hipHostFree(hK)); if (hH) CUDA_CALL(hipHostFree(hH)); if (hS) CUDA_CALL(hipHostFree(hS)); #ifdef USE_COMPLEX if (hVJ) CUDA_CALL(hipHostFree(hVJ)); if (hVD) CUDA_CALL(hipHostFree(hVD)); if (hGJ) CUDA_CALL(hipHostFree(hGJ)); if (hGD) CUDA_CALL(hipHostFree(hGD)); if (hFJ) CUDA_CALL(hipHostFree(hFJ)); if (hFD) CUDA_CALL(hipHostFree(hFD)); #else /* !USE_COMPLEX */ if (hV) CUDA_CALL(hipHostFree(hV)); if (hG) CUDA_CALL(hipHostFree(hG)); if (hF) CUDA_CALL(hipHostFree(hF)); #endif /* ?USE_COMPLEX */ #ifdef USE_COMPLEX free(buf); #endif /* USE_COMPLEX */ free(fn); free_strats(); CUDA_CALL(hipDeviceSynchronize()); #if (defined(PROFILE) && (PROFILE != 0)) CUDA_CALL(hipDeviceReset()); #endif /* ?PROFILE */ return fini_MPI(); }
e2af4929a62f8493749c87d8fb168b7aae78ad0f.cu
// mpi_main.cu: test driver. #include "HZ.hpp" #include "HZ_L.hpp" #include "HZ_L3.hpp" #include "my_utils.hpp" #include "cuda_memory_helper.hpp" int main(int argc, char *argv[]) { if (9 != argc) { (void)snprintf(err_msg, err_msg_size, "%s SNP0 SNP1 SNP2 ALG MF MG N FN", *argv); DIE(err_msg); } const char *const ca_exe = argv[0]; const char *const ca_snp0 = argv[1]; const char *const ca_snp1 = argv[2]; const char *const ca_snp2 = argv[3]; const char *const ca_alg = argv[4]; const char *const ca_mF = argv[5]; const char *const ca_mG = argv[6]; const char *const ca_n = argv[7]; const char *const ca_fn = argv[8]; const unsigned routine = static_cast<unsigned>(atou(ca_alg)); const size_t mF = atou(ca_mF); const size_t mG = atou(ca_mG); const size_t n = atou(ca_n); if (n > mF) { DIE("N > MF"); } if (n > mG) { DIE("N > MG"); } const unsigned snp0 = static_cast<unsigned>(atou(ca_snp0)); if ((snp0 != STRAT_CYCWOR) && (snp0 != STRAT_MMSTEP)) { DIE("SNP0 \\notin { 2, 4 }"); } const unsigned snp1 = static_cast<unsigned>(atou(ca_snp1)); if ((snp1 != STRAT_CYCWOR) && (snp1 != STRAT_MMSTEP)) { DIE("SNP1 \\notin { 2, 4 }"); } const unsigned snp2 = static_cast<unsigned>(atou(ca_snp2)); if ((snp2 != (STRAT_CYCWOR + 1u)) && (snp2 != (STRAT_MMSTEP + 1u))) { DIE("SNP2 \\notin { 3, 5 }"); } if (!*ca_fn) { DIE("invalid argument FN"); } if (init_MPI(&argc, &argv)) { (void)snprintf(err_msg, err_msg_size, "%s[%d] init_MPI failed\n", ca_exe, mpi_rank); DIE(err_msg); } if (!mpi_cuda_aware) { DIE("MPI is not CUDA aware"); } const size_t gpu = static_cast<size_t>(mpi_rank); const size_t gpus = static_cast<size_t>(mpi_size); if (gpus < 2u) { DIE("MPI_COMM_WORLD size < 2"); } const size_t n2 = (gpus << 1u); if (n < n2) { DIE("N < n2"); } const int dev = assign_dev2host(); if (dev < 0) { DIE("assign_dev2host failed"); } if (MPI_Barrier(MPI_COMM_WORLD)) { DIE("MPI_Barrier1"); } const int dcc = configureGPU(dev); (void)fprintf(stderr, "[%u] device(%d) has CC(%d)\n", gpu, dev, dcc); (void)fflush(stderr); size_t mF_ = 0u, mG_ = 0u, n_ = 0u; border_sizes(gpus, mF, mG, n, mF_, mG_, n_); const size_t n_gpu = n_ / gpus; const size_t n_col = (n_gpu >> 1u); const size_t n0 = (HZ_L1_NCOLB << 1u); const size_t n1 = n_gpu / HZ_L1_NCOLB; if (n_gpu % HZ_L1_NCOLB) { DIE("n_gpu % 16 != 0"); } init_strats(snp0, n0, snp1, n1, snp2, n2); const size_t p = static_cast<size_t>(strat2[0u][gpu][0u][0u]); const size_t q = static_cast<size_t>(strat2[0u][gpu][0u][1u]); size_t ldhF = mF_, ldhG = mG_, ldhV = n_; const size_t p_ = p * n_col; const size_t n_p = ((p_ >= n) ? static_cast<size_t>(0u) : (((p_ + n_col) > n) ? (n - p_) : n_col)); const MPI_Offset opF = static_cast<MPI_Offset>((p_ * mF) #ifdef USE_COMPLEX * 2u #endif /* USE_COMPLEX */ ); const MPI_Offset opG = static_cast<MPI_Offset>((p_ * mG) #ifdef USE_COMPLEX * 2u #endif /* USE_COMPLEX */ ); const MPI_Offset opV = static_cast<MPI_Offset>((p_ * n) #ifdef USE_COMPLEX * 2u #endif /* USE_COMPLEX */ ); const MPI_Offset opS = static_cast<MPI_Offset>(p_); const size_t q_ = q * n_col; const size_t n_q = ((q_ >= n) ? static_cast<size_t>(0u) : (((q_ + n_col) > n) ? (n - q_) : n_col)); const MPI_Offset oqF = static_cast<MPI_Offset>((q_ * mF) #ifdef USE_COMPLEX * 2u #endif /* USE_COMPLEX */ ); const MPI_Offset oqG = static_cast<MPI_Offset>((q_ * mG) #ifdef USE_COMPLEX * 2u #endif /* USE_COMPLEX */ ); const MPI_Offset oqV = static_cast<MPI_Offset>((q_ * n) #ifdef USE_COMPLEX * 2u #endif /* USE_COMPLEX */ ); const MPI_Offset oqS = static_cast<MPI_Offset>(q_); char *const fn = static_cast<char*>(calloc(strlen(ca_fn) + 4u, sizeof(char))); SYSP_CALL(fn); #ifdef USE_COMPLEX double *const buf = static_cast<double*>(calloc((((mF >= mG) ? mF : mG) * 2u), sizeof(double))); SYSP_CALL(buf); #endif /* USE_COMPLEX */ MPI_File fh = MPI_FILE_NULL; size_t ldA = static_cast<size_t>(0u); ldA = ldhF; #ifdef USE_COMPLEX cuD *const hFD = allocHostMtx<cuD>(ldA, mF_, n_gpu, true); SYSP_CALL(hFD); cuJ *const hFJ = allocHostMtx<cuJ>(ldA, mF_, n_gpu, true); SYSP_CALL(hFJ); #else /* !USE_COMPLEX */ double *const hF = allocHostMtx<double>(ldA, mF_, n_gpu, true); SYSP_CALL(hF); #endif /* ?USE_COMPLEX */ ldhF = ldA; if (MPI_File_open(MPI_COMM_WORLD, strcat(strcpy(fn, ca_fn), ".Y"), MPI_MODE_RDONLY, MPI_INFO_NULL, &fh)) { DIE("MPI_File_open(Y)"); } if (MPI_File_set_view(fh, 0, MPI_DOUBLE, MPI_DOUBLE, "native", MPI_INFO_NULL)) { DIE("MPI_File_set_view(Y)"); } #ifdef USE_COMPLEX for (size_t j = 0u; j < n_p; ++j) { if (MPI_File_read_at(fh, (opF + j * mF * 2u), buf, (mF * 2u), MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_read_at(Y)p"); } const size_t o = (ldA * j); cuD *const cD = (hFD + o); cuJ *const cJ = (hFJ + o); for (size_t i = 0u; i < mF; ++i) { const size_t i2 = (i * 2u); cD[i] = static_cast<cuD>(buf[i2]); cJ[i] = static_cast<cuJ>(buf[i2 + 1u]); } } for (size_t j = 0u; j < n_q; ++j) { if (MPI_File_read_at(fh, (oqF + j * mF * 2u), buf, (mF * 2u), MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_read_at(Y)q"); } const size_t o = (ldA * (n_col + j)); cuD *const cD = (hFD + o); cuJ *const cJ = (hFJ + o); for (size_t i = 0u; i < mF; ++i) { const size_t i2 = (i * 2u); cD[i] = static_cast<cuD>(buf[i2]); cJ[i] = static_cast<cuJ>(buf[i2 + 1u]); } } #else /* !USE_COMPLEX */ for (size_t j = 0u; j < n_p; ++j) { if (MPI_File_read_at(fh, (opF + j * mF), (hF + ldA * j), mF, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_read_at(Y)p"); } } for (size_t j = 0u; j < n_q; ++j) { if (MPI_File_read_at(fh, (oqF + j * mF), (hF + ldA * (n_col + j)), mF, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_read_at(Y)q"); } } #endif /* ?USE_COMPLEX */ if (MPI_File_close(&fh)) { DIE("MPI_File_close(Y)"); } if ((p_ + n_col) > n) { if (p_ >= n) { const size_t o = (p_ - n); #ifdef USE_COMPLEX SYSI_CALL(bdinit((mF + o), (o + 1u), hFD, ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit((mF + o), (o + 1u), hF, ldA)); #endif /* ?USE_COMPLEX */ } else { const size_t f = (n - p_); #ifdef USE_COMPLEX SYSI_CALL(bdinit(mF, (n_col - f), (hFD + ldA * f), ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit(mF, (n_col - f), (hF + ldA * f), ldA)); #endif /* ?USE_COMPLEX */ } } if ((q_ + n_col) > n) { if (q_ >= n) { const size_t o = (q_ - n); #ifdef USE_COMPLEX SYSI_CALL(bdinit((mF + o), (o + 1u), (hFD + ldA * n_col), ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit((mF + o), (o + 1u), (hF + ldA * n_col), ldA)); #endif /* ?USE_COMPLEX */ } else { const size_t f = (n - p_); #ifdef USE_COMPLEX SYSI_CALL(bdinit(mF, (n_col - f), (hFD + ldA * (n_col + f)), ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit(mF, (n_col - f), (hF + ldA * (n_col + f)), ldA)); #endif /* ?USE_COMPLEX */ } } ldA = ldhG; #ifdef USE_COMPLEX cuD *const hGD = allocHostMtx<cuD>(ldA, mG_, n_gpu, true); SYSP_CALL(hGD); cuJ *const hGJ = allocHostMtx<cuJ>(ldA, mG_, n_gpu, true); SYSP_CALL(hGJ); #else /* !USE_COMPLEX */ double *const hG = allocHostMtx<double>(ldA, mG_, n_gpu, true); SYSP_CALL(hG); #endif /* ?USE_COMPLEX */ ldhG = ldA; if (MPI_File_open(MPI_COMM_WORLD, strcat(strcpy(fn, ca_fn), ".W"), MPI_MODE_RDONLY, MPI_INFO_NULL, &fh)) { DIE("MPI_File_open(W)"); } if (MPI_File_set_view(fh, 0, MPI_DOUBLE, MPI_DOUBLE, "native", MPI_INFO_NULL)) { DIE("MPI_File_set_view(W)"); } #ifdef USE_COMPLEX for (size_t j = 0u; j < n_p; ++j) { if (MPI_File_read_at(fh, (opG + j * mG * 2u), buf, (mG * 2u), MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_read_at(W)p"); } const size_t o = (ldA * j); cuD *const cD = (hGD + o); cuJ *const cJ = (hGJ + o); for (size_t i = 0u; i < mG; ++i) { const size_t i2 = (i * 2u); cD[i] = static_cast<cuD>(buf[i2]); cJ[i] = static_cast<cuJ>(buf[i2 + 1u]); } } for (size_t j = 0u; j < n_q; ++j) { if (MPI_File_read_at(fh, (oqG + j * mG * 2u), buf, (mG * 2u), MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_read_at(W)q"); } const size_t o = (ldA * (n_col + j)); cuD *const cD = (hGD + o); cuJ *const cJ = (hGJ + o); for (size_t i = 0u; i < mG; ++i) { const size_t i2 = (i * 2u); cD[i] = static_cast<cuD>(buf[i2]); cJ[i] = static_cast<cuJ>(buf[i2 + 1u]); } } #else /* !USE_COMPLEX */ for (size_t j = 0u; j < n_p; ++j) { if (MPI_File_read_at(fh, (opG + j * mG), (hG + ldA * j), mG, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_read_at(W)p"); } } for (size_t j = 0u; j < n_q; ++j) { if (MPI_File_read_at(fh, (oqG + j * mG), (hG + ldA * (n_col + j)), mG, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_read_at(W)q"); } } #endif /* ?USE_COMPLEX */ if (MPI_File_close(&fh)) { DIE("MPI_File_close(W)"); } if ((p_ + n_col) > n) { if (p_ >= n) { const size_t o = (p_ - n); #ifdef USE_COMPLEX SYSI_CALL(bdinit((mG + o), (o + 1u), hGD, ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit((mG + o), (o + 1u), hG, ldA)); #endif /* ?USE_COMPLEX */ } else { const size_t f = (n - p_); #ifdef USE_COMPLEX SYSI_CALL(bdinit(mG, (n_col - f), (hGD + ldA * f), ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit(mG, (n_col - f), (hG + ldA * f), ldA)); #endif /* ?USE_COMPLEX */ } } if ((q_ + n_col) > n) { if (q_ >= n) { const size_t o = (q_ - n); #ifdef USE_COMPLEX SYSI_CALL(bdinit((mG + o), (o + 1u), (hGD + ldA * n_col), ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit((mG + o), (o + 1u), (hG + ldA * n_col), ldA)); #endif /* ?USE_COMPLEX */ } else { const size_t f = (n - p_); #ifdef USE_COMPLEX SYSI_CALL(bdinit(mG, (n_col - f), (hGD + ldA * (n_col + f)), ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit(mG, (n_col - f), (hG + ldA * (n_col + f)), ldA)); #endif /* ?USE_COMPLEX */ } } ldA = ldhV; #ifdef USE_COMPLEX cuD *const hVD = allocHostMtx<cuD>(ldA, n_, n_gpu, true); SYSP_CALL(hVD); cuJ *const hVJ = allocHostMtx<cuJ>(ldA, n_, n_gpu, true); SYSP_CALL(hVJ); #else /* !USE_COMPLEX */ double *const hV = allocHostMtx<double>(ldA, n_, n_gpu, true); SYSP_CALL(hV); #endif /* ?USE_COMPLEX */ ldhV = ldA; if ((p_ + n_col) > n) { if (p_ >= n) { const size_t o = (p_ - n); #ifdef USE_COMPLEX SYSI_CALL(bdinit((n + o), (o + 1u), hVD, ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit((n + o), (o + 1u), hV, ldA)); #endif /* ?USE_COMPLEX */ } else { const size_t f = (n - p_); #ifdef USE_COMPLEX SYSI_CALL(bdinit(n, (n_col - f), (hVD + ldA * f), ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit(n, (n_col - f), (hV + ldA * f), ldA)); #endif /* ?USE_COMPLEX */ } } if ((q_ + n_col) > n) { if (q_ >= n) { const size_t o = (q_ - n); #ifdef USE_COMPLEX SYSI_CALL(bdinit((n + o), (o + 1u), (hVD + ldA * n_col), ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit((n + o), (o + 1u), (hV + ldA * n_col), ldA)); #endif /* ?USE_COMPLEX */ } else { const size_t f = (n - p_); #ifdef USE_COMPLEX SYSI_CALL(bdinit(n, (n_col - f), (hVD + ldA * (n_col + f)), ldA)); #else /* !USE_COMPLEX */ SYSI_CALL(bdinit(n, (n_col - f), (hV + ldA * (n_col + f)), ldA)); #endif /* ?USE_COMPLEX */ } } double *const hS = allocHostVec<double>(n_gpu); SYSP_CALL(hS); double *const hH = allocHostVec<double>(n_gpu); SYSP_CALL(hH); double *const hK = allocHostVec<double>(n_gpu); SYSP_CALL(hK); unsigned glbSwp = 0u; unsigned long long glb_s = 0ull, glb_b = 0ull; double timing = -0.0; if (MPI_Barrier(MPI_COMM_WORLD)) { DIE("MPI_Barrier2"); } #ifdef USE_COMPLEX const int ret = HZ_L3(routine, gpu, gpus, mF_, mG_, n_, n_gpu, n_col, hFD, hFJ, ldhF, hGD, hGJ, ldhG, hVD, hVJ, ldhV, hS, hH, hK, glbSwp, glb_s, glb_b, timing); #else /* !USE_COMPLEX */ const int ret = HZ_L3(routine, gpu, gpus, mF_, mG_, n_, n_gpu, n_col, hF, ldhF, hG, ldhG, hV, ldhV, hS, hH, hK, glbSwp, glb_s, glb_b, timing); #endif /* ?USE_COMPLEX */ if (ret) { (void)snprintf(err_msg, err_msg_size, "%s: error %d", ca_exe, ret); DIE(err_msg); } else if (!gpu) { (void)fprintf(stdout, "GLB_ROT_S(%15llu), GLB_ROT_B(%15llu)\n", glb_s, glb_b); (void)fprintf(stdout, "%#16.6f s %2u sweeps\n", timing, glbSwp); (void)fflush(stdout); } if (MPI_File_open(MPI_COMM_WORLD, strcat(strcpy(fn, ca_fn), ".YU"), (MPI_MODE_WRONLY | MPI_MODE_CREATE), MPI_INFO_NULL, &fh)) { DIE("MPI_File_open(YU)"); } if (MPI_File_set_size(fh, (mF * n * sizeof(double) #ifdef USE_COMPLEX * 2u #endif /* USE_COMPLEX */ ))) { DIE("MPI_File_set_size(YU)"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(YU)"); } if (MPI_File_set_view(fh, 0, MPI_DOUBLE, MPI_DOUBLE, "native", MPI_INFO_NULL)) { DIE("MPI_File_set_view(YU)"); } #ifdef USE_COMPLEX for (size_t j = 0u; j < n_p; ++j) { const size_t o = (ldhF * j); const cuD *const cD = (hFD + o); const cuJ *const cJ = (hFJ + o); for (size_t i = 0u; i < mF; ++i) { const size_t i2 = (i * 2u); buf[i2] = static_cast<double>(cD[i]); buf[i2 + 1u] = static_cast<double>(cJ[i]); } if (MPI_File_write_at(fh, (opF + j * mF * 2u), buf, (mF * 2u), MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(YU)p"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(YU)p"); } for (size_t j = 0u; j < n_q; ++j) { const size_t o = (ldhF * (n_col + j)); const cuD *const cD = (hFD + o); const cuJ *const cJ = (hFJ + o); for (size_t i = 0u; i < mF; ++i) { const size_t i2 = (i * 2u); buf[i2] = static_cast<double>(cD[i]); buf[i2 + 1u] = static_cast<double>(cJ[i]); } if (MPI_File_write_at(fh, (oqF + j * mF * 2u), buf, (mF * 2u), MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(YU)q"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(YU)q"); } #else /* !USE_COMPLEX */ for (size_t j = 0u; j < n_p; ++j) { if (MPI_File_write_at(fh, (opF + j * mF), (hF + ldhF * j), mF, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(YU)p"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(YU)p"); } for (size_t j = 0u; j < n_q; ++j) { if (MPI_File_write_at(fh, (oqF + j * mF), (hF + ldhF * (n_col + j)), mF, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(YU)q"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(YU)q"); } #endif /* ?USE_COMPLEX */ if (MPI_File_close(&fh)) { DIE("MPI_File_close(YU)"); } if (MPI_File_open(MPI_COMM_WORLD, strcat(strcpy(fn, ca_fn), ".WV"), (MPI_MODE_WRONLY | MPI_MODE_CREATE), MPI_INFO_NULL, &fh)) { DIE("MPI_File_open(WV)"); } if (MPI_File_set_size(fh, (mG * n * sizeof(double) #ifdef USE_COMPLEX * 2u #endif /* USE_COMPLEX */ ))) { DIE("MPI_File_set_size(WV)"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(WV)"); } if (MPI_File_set_view(fh, 0, MPI_DOUBLE, MPI_DOUBLE, "native", MPI_INFO_NULL)) { DIE("MPI_File_set_view(WV)"); } #ifdef USE_COMPLEX for (size_t j = 0u; j < n_p; ++j) { const size_t o = (ldhG * j); const cuD *const cD = (hGD + o); const cuJ *const cJ = (hGJ + o); for (size_t i = 0u; i < mG; ++i) { const size_t i2 = (i * 2u); buf[i2] = static_cast<double>(cD[i]); buf[i2 + 1u] = static_cast<double>(cJ[i]); } if (MPI_File_write_at(fh, (opG + j * mG * 2u), buf, (mG * 2u), MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(WV)p"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(WV)p"); } for (size_t j = 0u; j < n_q; ++j) { const size_t o = (ldhG * (n_col + j)); const cuD *const cD = (hGD + o); const cuJ *const cJ = (hGJ + o); for (size_t i = 0u; i < mG; ++i) { const size_t i2 = (i * 2u); buf[i2] = static_cast<double>(cD[i]); buf[i2 + 1u] = static_cast<double>(cJ[i]); } if (MPI_File_write_at(fh, (oqG + j * mG * 2u), buf, (mG * 2u), MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(WV)q"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(WV)q"); } #else /* !USE_COMPLEX */ for (size_t j = 0u; j < n_p; ++j) { if (MPI_File_write_at(fh, (opG + j * mG), (hG + ldhG * j), mG, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(WV)p"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(WV)p"); } for (size_t j = 0u; j < n_q; ++j) { if (MPI_File_write_at(fh, (oqG + j * mG), (hG + ldhG * (n_col + j)), mG, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(WV)q"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(WV)q"); } #endif /* ?USE_COMPLEX */ if (MPI_File_close(&fh)) { DIE("MPI_File_close(WV)"); } if (MPI_File_open(MPI_COMM_WORLD, strcat(strcpy(fn, ca_fn), ".Z"), (MPI_MODE_WRONLY | MPI_MODE_CREATE), MPI_INFO_NULL, &fh)) { DIE("MPI_File_open(Z)"); } if (MPI_File_set_size(fh, (n * n * sizeof(double) #ifdef USE_COMPLEX * 2u #endif /* USE_COMPLEX */ ))) { DIE("MPI_File_set_size(Z)"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(Z)"); } if (MPI_File_set_view(fh, 0, MPI_DOUBLE, MPI_DOUBLE, "native", MPI_INFO_NULL)) { DIE("MPI_File_set_view(Z)"); } #ifdef USE_COMPLEX for (size_t j = 0u; j < n_p; ++j) { const size_t o = (ldhV * j); const cuD *const cD = (hVD + o); const cuJ *const cJ = (hVJ + o); for (size_t i = 0u; i < n; ++i) { const size_t i2 = (i * 2u); buf[i2] = static_cast<double>(cD[i]); buf[i2 + 1u] = static_cast<double>(cJ[i]); } if (MPI_File_write_at(fh, (opV + j * n * 2u), buf, (n * 2u), MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(Z)p"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(Z)p"); } for (size_t j = 0u; j < n_q; ++j) { const size_t o = (ldhV * (n_col + j)); const cuD *const cD = (hVD + o); const cuJ *const cJ = (hVJ + o); for (size_t i = 0u; i < n; ++i) { const size_t i2 = (i * 2u); buf[i2] = static_cast<double>(cD[i]); buf[i2 + 1u] = static_cast<double>(cJ[i]); } if (MPI_File_write_at(fh, (oqV + j * n * 2u), buf, (n * 2u), MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(Z)q"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(Z)q"); } #else /* !USE_COMPLEX */ for (size_t j = 0u; j < n_p; ++j) { if (MPI_File_write_at(fh, (opV + j * n), (hV + ldhV * j), n, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(Z)p"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(Z)p"); } for (size_t j = 0u; j < n_q; ++j) { if (MPI_File_write_at(fh, (oqV + j * n), (hV + ldhV * (n_col + j)), n, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(Z)q"); } } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(Z)q"); } #endif /* ?USE_COMPLEX */ if (MPI_File_close(&fh)) { DIE("MPI_File_close(Z)"); } if (MPI_File_open(MPI_COMM_WORLD, strcat(strcpy(fn, ca_fn), ".SS"), (MPI_MODE_WRONLY | MPI_MODE_CREATE), MPI_INFO_NULL, &fh)) { DIE("MPI_File_open(SS)"); } if (MPI_File_set_size(fh, (n * sizeof(double)))) { DIE("MPI_File_set_size(SS)"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(SS)"); } if (MPI_File_set_view(fh, 0, MPI_DOUBLE, MPI_DOUBLE, "native", MPI_INFO_NULL)) { DIE("MPI_File_set_view(SS)"); } if (MPI_File_write_at(fh, opS, hS, n_p, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(SS)p"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(SS)p"); } if (MPI_File_write_at(fh, oqS, (hS + n_col), n_q, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(SS)q"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(SS)q"); } if (MPI_File_close(&fh)) { DIE("MPI_File_close(SS)"); } if (MPI_File_open(MPI_COMM_WORLD, strcat(strcpy(fn, ca_fn), ".SY"), (MPI_MODE_WRONLY | MPI_MODE_CREATE), MPI_INFO_NULL, &fh)) { DIE("MPI_File_open(SY)"); } if (MPI_File_set_size(fh, (n * sizeof(double)))) { DIE("MPI_File_set_size(SY)"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(SY)"); } if (MPI_File_set_view(fh, 0, MPI_DOUBLE, MPI_DOUBLE, "native", MPI_INFO_NULL)) { DIE("MPI_File_set_view(SY)"); } if (MPI_File_write_at(fh, opS, hH, n_p, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(SY)p"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(SY)p"); } if (MPI_File_write_at(fh, oqS, (hH + n_col), n_q, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(SY)q"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(SY)q"); } if (MPI_File_close(&fh)) { DIE("MPI_File_close(SY)"); } if (MPI_File_open(MPI_COMM_WORLD, strcat(strcpy(fn, ca_fn), ".SW"), (MPI_MODE_WRONLY | MPI_MODE_CREATE), MPI_INFO_NULL, &fh)) { DIE("MPI_File_open(SW)"); } if (MPI_File_set_size(fh, (n * sizeof(double)))) { DIE("MPI_File_set_size(SW)"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(SW)"); } if (MPI_File_set_view(fh, 0, MPI_DOUBLE, MPI_DOUBLE, "native", MPI_INFO_NULL)) { DIE("MPI_File_set_view(SW)"); } if (MPI_File_write_at(fh, opS, hK, n_p, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(SW)p"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(SW)p"); } if (MPI_File_write_at(fh, oqS, (hK + n_col), n_q, MPI_DOUBLE, MPI_STATUS_IGNORE)) { DIE("MPI_File_write_at(SW)q"); } if (MPI_File_sync(fh)) { DIE("MPI_File_sync(SW)q"); } if (MPI_File_close(&fh)) { DIE("MPI_File_close(SW)"); } if (hK) CUDA_CALL(cudaFreeHost(hK)); if (hH) CUDA_CALL(cudaFreeHost(hH)); if (hS) CUDA_CALL(cudaFreeHost(hS)); #ifdef USE_COMPLEX if (hVJ) CUDA_CALL(cudaFreeHost(hVJ)); if (hVD) CUDA_CALL(cudaFreeHost(hVD)); if (hGJ) CUDA_CALL(cudaFreeHost(hGJ)); if (hGD) CUDA_CALL(cudaFreeHost(hGD)); if (hFJ) CUDA_CALL(cudaFreeHost(hFJ)); if (hFD) CUDA_CALL(cudaFreeHost(hFD)); #else /* !USE_COMPLEX */ if (hV) CUDA_CALL(cudaFreeHost(hV)); if (hG) CUDA_CALL(cudaFreeHost(hG)); if (hF) CUDA_CALL(cudaFreeHost(hF)); #endif /* ?USE_COMPLEX */ #ifdef USE_COMPLEX free(buf); #endif /* USE_COMPLEX */ free(fn); free_strats(); CUDA_CALL(cudaDeviceSynchronize()); #if (defined(PROFILE) && (PROFILE != 0)) CUDA_CALL(cudaDeviceReset()); #endif /* ?PROFILE */ return fini_MPI(); }
507a109ad5a32ced14446c80d73a5a884679aa27.hip
// !!! This is a file automatically generated by hipify!!! #include <hip/hip_runtime.h> #include <stdio.h> #include <stdlib.h> __global__ void mandelKernel() { // To avoid error caused by the floating number, use the following pseudo code // // float x = lowerX + thisX * stepX; // float y = lowerY + thisY * stepY; } // Host front-end function that allocates the memory and launches the GPU kernel void hostFE (float upperX, float upperY, float lowerX, float lowerY, int* img, int resX, int resY, int maxIterations) { float stepX = (upperX - lowerX) / resX; float stepY = (upperY - lowerY) / resY; }
507a109ad5a32ced14446c80d73a5a884679aa27.cu
#include <cuda.h> #include <stdio.h> #include <stdlib.h> __global__ void mandelKernel() { // To avoid error caused by the floating number, use the following pseudo code // // float x = lowerX + thisX * stepX; // float y = lowerY + thisY * stepY; } // Host front-end function that allocates the memory and launches the GPU kernel void hostFE (float upperX, float upperY, float lowerX, float lowerY, int* img, int resX, int resY, int maxIterations) { float stepX = (upperX - lowerX) / resX; float stepY = (upperY - lowerY) / resY; }
7901dd33b2874b37bd00c72bb49396ccc8956d0d.hip
// !!! This is a file automatically generated by hipify!!! /************************************************** # Copyright (C) 2014 Raptis Dimos <[email protected]> # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # **************************************************/ /* * gpu_util.cu -- GPU utility functions * Copyright (C) 2010-2013, Computing Systems Laboratory (CSLab) */ #include <hip/hip_runtime.h> #include "gpu_util.h" /* Initialize the CUDA runtime */ void gpu_init() { hipFree(0); } void *gpu_alloc(size_t count) { void *ret; if (hipMalloc(&ret, count) != hipSuccess) { ret = NULL; } return ret; } void gpu_free(void *gpuptr) { hipFree(gpuptr); } int copy_to_gpu(const void *host, void *gpu, size_t count) { if (hipMemcpy(gpu, host, count, hipMemcpyHostToDevice) != hipSuccess) return -1; return 0; } int copy_from_gpu(void *host, const void *gpu, size_t count) { if (hipMemcpy(host, gpu, count, hipMemcpyDeviceToHost) != hipSuccess) return -1; return 0; } const char *gpu_get_errmsg(hipError_t err) { return hipGetErrorString(err); } const char *gpu_get_last_errmsg() { return gpu_get_errmsg(hipGetLastError()); }
7901dd33b2874b37bd00c72bb49396ccc8956d0d.cu
/************************************************** # Copyright (C) 2014 Raptis Dimos <[email protected]> # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # **************************************************/ /* * gpu_util.cu -- GPU utility functions * Copyright (C) 2010-2013, Computing Systems Laboratory (CSLab) */ #include <cuda.h> #include "gpu_util.h" /* Initialize the CUDA runtime */ void gpu_init() { cudaFree(0); } void *gpu_alloc(size_t count) { void *ret; if (cudaMalloc(&ret, count) != cudaSuccess) { ret = NULL; } return ret; } void gpu_free(void *gpuptr) { cudaFree(gpuptr); } int copy_to_gpu(const void *host, void *gpu, size_t count) { if (cudaMemcpy(gpu, host, count, cudaMemcpyHostToDevice) != cudaSuccess) return -1; return 0; } int copy_from_gpu(void *host, const void *gpu, size_t count) { if (cudaMemcpy(host, gpu, count, cudaMemcpyDeviceToHost) != cudaSuccess) return -1; return 0; } const char *gpu_get_errmsg(cudaError_t err) { return cudaGetErrorString(err); } const char *gpu_get_last_errmsg() { return gpu_get_errmsg(cudaGetLastError()); }
3bbc156e8a5df64078c0b21b371fc05b5a3b0907.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" /* Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include <paddle/fluid/platform/device_context.h> #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/memory/malloc.h" #include "paddle/fluid/operators/partial_concat_op.h" #include "paddle/fluid/platform/float16.h" namespace plat = paddle::platform; namespace paddle { namespace operators { #define CEIL_DIV(x, y) (((x) + (y)-1) / (y)) using LoDTensor = framework::LoDTensor; using Tensor = phi::DenseTensor; template <class T> __global__ void ConcatPartialCUDAKernel(T **in, T *out, int64_t all_length, int64_t in_batch_len, int64_t start_index, int64_t out_batch_len, int64_t part_length) { int id = blockIdx.x * blockDim.x + threadIdx.x; while (id < all_length) { int64_t bs_id = id / out_batch_len; int64_t bs_index = id % out_batch_len; int64_t var_id = bs_index / part_length; int64_t part_index = bs_index % part_length; int64_t in_id = start_index + part_index; const T *tmp = in[var_id]; out[id] = tmp[bs_id * in_batch_len + in_id]; id += blockDim.x * gridDim.x; } } template <class T> __global__ void ConcatPartialGradCUDAKernel(T **in, const T *out, int64_t all_length, int64_t in_batch_len, int64_t start_index, int64_t out_batch_len, int64_t part_length) { int id = blockIdx.x * blockDim.x + threadIdx.x; while (id < all_length) { int64_t bs_id = id / out_batch_len; int64_t bs_index = id % out_batch_len; int64_t var_id = bs_index / part_length; int64_t part_index = bs_index % part_length; int64_t in_id = start_index + part_index; T *tmp = in[var_id]; tmp[bs_id * in_batch_len + in_id] = out[id]; id += blockDim.x * gridDim.x; } } template <typename T> class PartialConcatOpCUDAKernel : public framework::OpKernel<T> { public: void Compute(const framework::ExecutionContext &ctx) const override { auto in_vars = ctx.MultiInput<phi::DenseTensor>("X"); Tensor *out = ctx.Output<phi::DenseTensor>("Out"); PADDLE_ENFORCE_EQ(in_vars[0] != nullptr, true, platform::errors::InvalidArgument( "The input of partial concat should not be null.")); auto input_dim = in_vars[0]->dims(); PADDLE_ENFORCE_EQ(input_dim.size(), 2, platform::errors::InvalidArgument( "Only supports 2-D array with batch size in the 1st " "dimension and data in the 2nd.")); auto in_size = input_dim[1]; // may be negative auto start_index = ctx.Attr<int>("start_index"); start_index = ComputeStartIndex(start_index, in_size); auto partial_len = ctx.Attr<int>("length"); if (partial_len < 0) { partial_len = in_size - start_index; } int in_num = in_vars.size(); int batch_size = input_dim[0]; int out_batch_len = partial_len * in_num; int all_length = batch_size * out_batch_len; constexpr size_t theory_sm_threads = 1024; auto &dev_ctx = ctx.template device_context<phi::GPUContext>(); auto stream = dev_ctx.stream(); auto max_threads = dev_ctx.GetMaxPhysicalThreadCount(); auto sm_count = max_threads / theory_sm_threads; size_t tile_size = 0; int grids; int blocks; auto ComputeKernelParameter = [&](size_t length) { if (length >= max_threads) tile_size = 1024; else if (length < max_threads && length > sm_count * 128) tile_size = 512; else if (length <= sm_count * 128) tile_size = 256; grids = CEIL_DIV(length, tile_size); blocks = tile_size; }; auto place = ctx.GetPlace(); T *out_data = out->mutable_data<T>(place); std::vector<const T *> in_data; for (int i = 0; i < in_num; ++i) in_data.emplace_back(in_vars[i]->data<T>()); auto tmp_in_array = memory::Alloc( dev_ctx.GetPlace(), in_data.size() * sizeof(T *), phi::Stream(reinterpret_cast<phi::StreamId>(dev_ctx.stream()))); memory::Copy(dev_ctx.GetPlace(), tmp_in_array->ptr(), platform::CPUPlace(), reinterpret_cast<void *>(in_data.data()), in_data.size() * sizeof(T *), dev_ctx.stream()); T **in_array_data = reinterpret_cast<T **>(tmp_in_array->ptr()); ComputeKernelParameter(all_length); hipLaunchKernelGGL(( ConcatPartialCUDAKernel<T>), dim3(grids), dim3(blocks), 0, stream, in_array_data, out->data<T>(), all_length, in_size, start_index, out_batch_len, partial_len); } }; template <typename T> class PartialConcatGradOpCUDAKernel : public framework::OpKernel<T> { public: void Compute(const framework::ExecutionContext &ctx) const override { auto *out_grad = ctx.Input<phi::DenseTensor>(framework::GradVarName("Out")); auto ins = ctx.MultiInput<LoDTensor>("X"); auto outs = ctx.MultiOutput<LoDTensor>(framework::GradVarName("X")); PADDLE_ENFORCE_EQ(ins[0] != nullptr, true, platform::errors::InvalidArgument( "The input of partial concat should not be null.")); // all parameters auto batch_size = ins[0]->dims()[0]; auto in_size = ins[0]->dims()[1]; // may be negative auto start_index = ctx.Attr<int>("start_index"); start_index = ComputeStartIndex(start_index, in_size); auto partial_len = ctx.Attr<int>("length"); if (partial_len < 0) partial_len = in_size - start_index; auto in_num = ins.size(); auto grad_batch_len = partial_len * in_num; auto all_length = grad_batch_len * batch_size; // initialize auto &place = *ctx.template device_context<phi::GPUContext>().eigen_device(); for (size_t i = 0; i < outs.size(); ++i) { outs[i]->mutable_data<T>(ctx.GetPlace()); auto dxt = framework::EigenVector<T>::Flatten(*outs[i]); dxt.device(place) = dxt.constant(static_cast<T>(0)); } constexpr size_t theory_sm_threads = 1024; auto &dev_ctx = ctx.template device_context<phi::GPUContext>(); auto stream = dev_ctx.stream(); auto max_threads = dev_ctx.GetMaxPhysicalThreadCount(); auto sm_count = max_threads / theory_sm_threads; size_t tile_size = 0; int grids; int blocks; auto ComputeKernelParameter = [&](size_t length) { if (length >= max_threads) tile_size = 1024; else if (length < max_threads && length > sm_count * 128) tile_size = 512; else if (length <= sm_count * 128) tile_size = 256; grids = CEIL_DIV(length, tile_size); blocks = tile_size; }; std::vector<const T *> out_data; for (size_t i = 0; i < in_num; ++i) { out_data.emplace_back(outs[i]->data<T>()); } auto tmp_out_array = memory::Alloc( dev_ctx.GetPlace(), out_data.size() * sizeof(T *), phi::Stream(reinterpret_cast<phi::StreamId>(dev_ctx.stream()))); memory::Copy(dev_ctx.GetPlace(), tmp_out_array->ptr(), platform::CPUPlace(), reinterpret_cast<void *>(out_data.data()), out_data.size() * sizeof(T *), dev_ctx.stream()); T **out_grad_data = reinterpret_cast<T **>(tmp_out_array->ptr()); ComputeKernelParameter(all_length); hipLaunchKernelGGL(( ConcatPartialGradCUDAKernel<T>) , dim3(grids), dim3(blocks), 0, stream, out_grad_data, out_grad->data<T>(), all_length, in_size, start_index, grad_batch_len, partial_len); } }; } // namespace operators } // namespace paddle namespace ops = paddle::operators; REGISTER_OP_CUDA_KERNEL(partial_concat, ops::PartialConcatOpCUDAKernel<float>, ops::PartialConcatOpCUDAKernel<double>, ops::PartialConcatOpCUDAKernel<int>, ops::PartialConcatOpCUDAKernel<int64_t>, ops::PartialConcatOpCUDAKernel<plat::float16>); REGISTER_OP_CUDA_KERNEL(partial_concat_grad, ops::PartialConcatGradOpCUDAKernel<float>, ops::PartialConcatGradOpCUDAKernel<double>, ops::PartialConcatGradOpCUDAKernel<int>, ops::PartialConcatGradOpCUDAKernel<int64_t>, ops::PartialConcatGradOpCUDAKernel<plat::float16>);
3bbc156e8a5df64078c0b21b371fc05b5a3b0907.cu
/* Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include <paddle/fluid/platform/device_context.h> #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/memory/malloc.h" #include "paddle/fluid/operators/partial_concat_op.h" #include "paddle/fluid/platform/float16.h" namespace plat = paddle::platform; namespace paddle { namespace operators { #define CEIL_DIV(x, y) (((x) + (y)-1) / (y)) using LoDTensor = framework::LoDTensor; using Tensor = phi::DenseTensor; template <class T> __global__ void ConcatPartialCUDAKernel(T **in, T *out, int64_t all_length, int64_t in_batch_len, int64_t start_index, int64_t out_batch_len, int64_t part_length) { int id = blockIdx.x * blockDim.x + threadIdx.x; while (id < all_length) { int64_t bs_id = id / out_batch_len; int64_t bs_index = id % out_batch_len; int64_t var_id = bs_index / part_length; int64_t part_index = bs_index % part_length; int64_t in_id = start_index + part_index; const T *tmp = in[var_id]; out[id] = tmp[bs_id * in_batch_len + in_id]; id += blockDim.x * gridDim.x; } } template <class T> __global__ void ConcatPartialGradCUDAKernel(T **in, const T *out, int64_t all_length, int64_t in_batch_len, int64_t start_index, int64_t out_batch_len, int64_t part_length) { int id = blockIdx.x * blockDim.x + threadIdx.x; while (id < all_length) { int64_t bs_id = id / out_batch_len; int64_t bs_index = id % out_batch_len; int64_t var_id = bs_index / part_length; int64_t part_index = bs_index % part_length; int64_t in_id = start_index + part_index; T *tmp = in[var_id]; tmp[bs_id * in_batch_len + in_id] = out[id]; id += blockDim.x * gridDim.x; } } template <typename T> class PartialConcatOpCUDAKernel : public framework::OpKernel<T> { public: void Compute(const framework::ExecutionContext &ctx) const override { auto in_vars = ctx.MultiInput<phi::DenseTensor>("X"); Tensor *out = ctx.Output<phi::DenseTensor>("Out"); PADDLE_ENFORCE_EQ(in_vars[0] != nullptr, true, platform::errors::InvalidArgument( "The input of partial concat should not be null.")); auto input_dim = in_vars[0]->dims(); PADDLE_ENFORCE_EQ(input_dim.size(), 2, platform::errors::InvalidArgument( "Only supports 2-D array with batch size in the 1st " "dimension and data in the 2nd.")); auto in_size = input_dim[1]; // may be negative auto start_index = ctx.Attr<int>("start_index"); start_index = ComputeStartIndex(start_index, in_size); auto partial_len = ctx.Attr<int>("length"); if (partial_len < 0) { partial_len = in_size - start_index; } int in_num = in_vars.size(); int batch_size = input_dim[0]; int out_batch_len = partial_len * in_num; int all_length = batch_size * out_batch_len; constexpr size_t theory_sm_threads = 1024; auto &dev_ctx = ctx.template device_context<phi::GPUContext>(); auto stream = dev_ctx.stream(); auto max_threads = dev_ctx.GetMaxPhysicalThreadCount(); auto sm_count = max_threads / theory_sm_threads; size_t tile_size = 0; int grids; int blocks; auto ComputeKernelParameter = [&](size_t length) { if (length >= max_threads) tile_size = 1024; else if (length < max_threads && length > sm_count * 128) tile_size = 512; else if (length <= sm_count * 128) tile_size = 256; grids = CEIL_DIV(length, tile_size); blocks = tile_size; }; auto place = ctx.GetPlace(); T *out_data = out->mutable_data<T>(place); std::vector<const T *> in_data; for (int i = 0; i < in_num; ++i) in_data.emplace_back(in_vars[i]->data<T>()); auto tmp_in_array = memory::Alloc( dev_ctx.GetPlace(), in_data.size() * sizeof(T *), phi::Stream(reinterpret_cast<phi::StreamId>(dev_ctx.stream()))); memory::Copy(dev_ctx.GetPlace(), tmp_in_array->ptr(), platform::CPUPlace(), reinterpret_cast<void *>(in_data.data()), in_data.size() * sizeof(T *), dev_ctx.stream()); T **in_array_data = reinterpret_cast<T **>(tmp_in_array->ptr()); ComputeKernelParameter(all_length); ConcatPartialCUDAKernel<T><<<grids, blocks, 0, stream>>>(in_array_data, out->data<T>(), all_length, in_size, start_index, out_batch_len, partial_len); } }; template <typename T> class PartialConcatGradOpCUDAKernel : public framework::OpKernel<T> { public: void Compute(const framework::ExecutionContext &ctx) const override { auto *out_grad = ctx.Input<phi::DenseTensor>(framework::GradVarName("Out")); auto ins = ctx.MultiInput<LoDTensor>("X"); auto outs = ctx.MultiOutput<LoDTensor>(framework::GradVarName("X")); PADDLE_ENFORCE_EQ(ins[0] != nullptr, true, platform::errors::InvalidArgument( "The input of partial concat should not be null.")); // all parameters auto batch_size = ins[0]->dims()[0]; auto in_size = ins[0]->dims()[1]; // may be negative auto start_index = ctx.Attr<int>("start_index"); start_index = ComputeStartIndex(start_index, in_size); auto partial_len = ctx.Attr<int>("length"); if (partial_len < 0) partial_len = in_size - start_index; auto in_num = ins.size(); auto grad_batch_len = partial_len * in_num; auto all_length = grad_batch_len * batch_size; // initialize auto &place = *ctx.template device_context<phi::GPUContext>().eigen_device(); for (size_t i = 0; i < outs.size(); ++i) { outs[i]->mutable_data<T>(ctx.GetPlace()); auto dxt = framework::EigenVector<T>::Flatten(*outs[i]); dxt.device(place) = dxt.constant(static_cast<T>(0)); } constexpr size_t theory_sm_threads = 1024; auto &dev_ctx = ctx.template device_context<phi::GPUContext>(); auto stream = dev_ctx.stream(); auto max_threads = dev_ctx.GetMaxPhysicalThreadCount(); auto sm_count = max_threads / theory_sm_threads; size_t tile_size = 0; int grids; int blocks; auto ComputeKernelParameter = [&](size_t length) { if (length >= max_threads) tile_size = 1024; else if (length < max_threads && length > sm_count * 128) tile_size = 512; else if (length <= sm_count * 128) tile_size = 256; grids = CEIL_DIV(length, tile_size); blocks = tile_size; }; std::vector<const T *> out_data; for (size_t i = 0; i < in_num; ++i) { out_data.emplace_back(outs[i]->data<T>()); } auto tmp_out_array = memory::Alloc( dev_ctx.GetPlace(), out_data.size() * sizeof(T *), phi::Stream(reinterpret_cast<phi::StreamId>(dev_ctx.stream()))); memory::Copy(dev_ctx.GetPlace(), tmp_out_array->ptr(), platform::CPUPlace(), reinterpret_cast<void *>(out_data.data()), out_data.size() * sizeof(T *), dev_ctx.stream()); T **out_grad_data = reinterpret_cast<T **>(tmp_out_array->ptr()); ComputeKernelParameter(all_length); ConcatPartialGradCUDAKernel<T> <<<grids, blocks, 0, stream>>>(out_grad_data, out_grad->data<T>(), all_length, in_size, start_index, grad_batch_len, partial_len); } }; } // namespace operators } // namespace paddle namespace ops = paddle::operators; REGISTER_OP_CUDA_KERNEL(partial_concat, ops::PartialConcatOpCUDAKernel<float>, ops::PartialConcatOpCUDAKernel<double>, ops::PartialConcatOpCUDAKernel<int>, ops::PartialConcatOpCUDAKernel<int64_t>, ops::PartialConcatOpCUDAKernel<plat::float16>); REGISTER_OP_CUDA_KERNEL(partial_concat_grad, ops::PartialConcatGradOpCUDAKernel<float>, ops::PartialConcatGradOpCUDAKernel<double>, ops::PartialConcatGradOpCUDAKernel<int>, ops::PartialConcatGradOpCUDAKernel<int64_t>, ops::PartialConcatGradOpCUDAKernel<plat::float16>);
1d96912ff057ff426b5b45cda85e818f1c54cd59.hip
// !!! This is a file automatically generated by hipify!!! /* * Copyright (c) 2019-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <cudf/column/column_device_view.cuh> #include <cudf/column/column_factories.hpp> #include <cudf/copying.hpp> #include <cudf/detail/get_value.cuh> #include <cudf/detail/indexalator.cuh> #include <cudf/detail/iterator.cuh> #include <cudf/detail/null_mask.hpp> #include <cudf/detail/nvtx/ranges.hpp> #include <cudf/scalar/scalar_device_view.cuh> #include <cudf/strings/detail/strings_children.cuh> #include <cudf/strings/string_view.cuh> #include <cudf/strings/strings_column_view.hpp> #include <cudf/strings/substring.hpp> #include <cudf/utilities/default_stream.hpp> #include <rmm/cuda_stream_view.hpp> #include <thrust/for_each.h> #include <thrust/iterator/counting_iterator.h> namespace cudf { namespace strings { namespace detail { namespace { /** * @brief Function logic for the substring API. * * This will perform a substring operation on each string * using the provided start, stop, and step parameters. */ struct substring_fn { column_device_view const d_column; numeric_scalar_device_view<size_type> const d_start; numeric_scalar_device_view<size_type> const d_stop; numeric_scalar_device_view<size_type> const d_step; int32_t* d_offsets{}; char* d_chars{}; __device__ void operator()(size_type idx) { if (d_column.is_null(idx)) { if (!d_chars) d_offsets[idx] = 0; return; } auto const d_str = d_column.template element<string_view>(idx); auto const length = d_str.length(); if (length == 0) { if (!d_chars) d_offsets[idx] = 0; return; } size_type const step = d_step.is_valid() ? d_step.value() : 1; auto const begin = [&] { // always inclusive // when invalid, default depends on step if (!d_start.is_valid()) return (step > 0) ? d_str.begin() : (d_str.end() - 1); // normal positive position logic auto start = d_start.value(); if (start >= 0) { if (start < length) return d_str.begin() + start; return d_str.end() + (step < 0 ? -1 : 0); } // handle negative position here auto adjust = length + start; if (adjust >= 0) return d_str.begin() + adjust; return d_str.begin() + (step < 0 ? -1 : 0); }(); auto const end = [&] { // always exclusive // when invalid, default depends on step if (!d_stop.is_valid()) return step > 0 ? d_str.end() : (d_str.begin() - 1); // normal positive position logic auto stop = d_stop.value(); if (stop >= 0) return (stop < length) ? (d_str.begin() + stop) : d_str.end(); // handle negative position here auto adjust = length + stop; return d_str.begin() + (adjust >= 0 ? adjust : -1); }(); size_type bytes = 0; char* d_buffer = d_chars ? d_chars + d_offsets[idx] : nullptr; auto itr = begin; while (step > 0 ? itr < end : end < itr) { bytes += bytes_in_char_utf8(*itr); if (d_buffer) d_buffer += from_char_utf8(*itr, d_buffer); itr += step; } if (!d_chars) d_offsets[idx] = bytes; } }; } // namespace // std::unique_ptr<column> slice_strings(strings_column_view const& strings, numeric_scalar<size_type> const& start, numeric_scalar<size_type> const& stop, numeric_scalar<size_type> const& step, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { if (strings.is_empty()) return make_empty_column(type_id::STRING); if (step.is_valid(stream)) CUDF_EXPECTS(step.value(stream) != 0, "Step parameter must not be 0"); auto const d_column = column_device_view::create(strings.parent(), stream); auto const d_start = get_scalar_device_view(const_cast<numeric_scalar<size_type>&>(start)); auto const d_stop = get_scalar_device_view(const_cast<numeric_scalar<size_type>&>(stop)); auto const d_step = get_scalar_device_view(const_cast<numeric_scalar<size_type>&>(step)); auto children = make_strings_children( substring_fn{*d_column, d_start, d_stop, d_step}, strings.size(), stream, mr); return make_strings_column(strings.size(), std::move(children.first), std::move(children.second), strings.null_count(), cudf::detail::copy_bitmask(strings.parent(), stream, mr)); } } // namespace detail // external API std::unique_ptr<column> slice_strings(strings_column_view const& strings, numeric_scalar<size_type> const& start, numeric_scalar<size_type> const& stop, numeric_scalar<size_type> const& step, rmm::mr::device_memory_resource* mr) { CUDF_FUNC_RANGE(); return detail::slice_strings(strings, start, stop, step, cudf::get_default_stream(), mr); } namespace detail { namespace { /** * @brief Function logic for substring_from API. * * This both calculates the output size and executes the substring. */ struct substring_from_fn { column_device_view const d_column; cudf::detail::input_indexalator const starts; cudf::detail::input_indexalator const stops; int32_t* d_offsets{}; char* d_chars{}; __device__ void operator()(size_type idx) { if (d_column.is_null(idx)) { if (!d_chars) d_offsets[idx] = 0; return; } auto const d_str = d_column.template element<string_view>(idx); auto const length = d_str.length(); auto const start = ::max(starts[idx], 0); if (start >= length) { if (!d_chars) d_offsets[idx] = 0; return; } auto const stop = stops[idx]; auto const end = (((stop < 0) || (stop > length)) ? length : stop); auto const d_substr = d_str.substr(start, end - start); if (d_chars) memcpy(d_chars + d_offsets[idx], d_substr.data(), d_substr.size_bytes()); else d_offsets[idx] = d_substr.size_bytes(); } }; /** * @brief Common utility function for the slice_strings APIs. * * It wraps calling the functors appropriately to build the output strings column. * * The input iterators may have unique position values per string in `d_column`. * * @param d_column Input strings column to substring. * @param null_count Number of nulls for the output column. * @param starts Start positions index iterator. * @param stops Stop positions index iterator. * @param stream CUDA stream used for device memory operations and kernel launches. * @param mr Device memory resource used to allocate the returned column's device memory. */ std::unique_ptr<column> compute_substrings_from_fn(column_device_view const& d_column, size_type null_count, cudf::detail::input_indexalator starts, cudf::detail::input_indexalator stops, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { auto strings_count = d_column.size(); // Copy the null mask rmm::device_buffer null_mask = !d_column.nullable() ? rmm::device_buffer{0, stream, mr} : rmm::device_buffer( d_column.null_mask(), cudf::bitmask_allocation_size_bytes(strings_count), stream, mr); auto children = make_strings_children(substring_from_fn{d_column, starts, stops}, strings_count, stream, mr); return make_strings_column(strings_count, std::move(children.first), std::move(children.second), null_count, std::move(null_mask)); } /** * @brief Compute slice indices for each string. * * When slice_strings is invoked with a delimiter string and a delimiter count, we need to * compute the start and end indices of the substring. This function accomplishes that. */ template <typename DelimiterItrT> void compute_substring_indices(column_device_view const& d_column, DelimiterItrT const delim_itr, size_type delimiter_count, size_type* start_char_pos, size_type* end_char_pos, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource*) { auto strings_count = d_column.size(); thrust::for_each_n( rmm::exec_policy(stream), thrust::make_counting_iterator<size_type>(0), strings_count, [delim_itr, delimiter_count, start_char_pos, end_char_pos, d_column] __device__(size_type idx) { auto const& delim_val_pair = delim_itr[idx]; auto const& delim_val = delim_val_pair.first; // Don't use it yet // If the column value for this row is null, result is null. // If the delimiter count is 0, result is empty string. // If the global delimiter or the row specific delimiter is invalid or if it is empty, row // value is empty. if (d_column.is_null(idx) || !delim_val_pair.second || delim_val.empty()) return; auto const& col_val = d_column.element<string_view>(idx); // If the column value for the row is empty, the row value is empty. if (!col_val.empty()) { auto const col_val_len = col_val.length(); auto const delimiter_len = delim_val.length(); auto nsearches = (delimiter_count < 0) ? -delimiter_count : delimiter_count; bool const left_to_right = (delimiter_count > 0); size_type start_pos = start_char_pos[idx]; size_type end_pos = col_val_len; size_type char_pos = -1; end_char_pos[idx] = col_val_len; for (auto i = 0; i < nsearches; ++i) { char_pos = left_to_right ? col_val.find(delim_val, start_pos) : col_val.rfind(delim_val, 0, end_pos); if (char_pos == string_view::npos) return; if (left_to_right) start_pos = char_pos + delimiter_len; else end_pos = char_pos; } if (left_to_right) end_char_pos[idx] = char_pos; else start_char_pos[idx] = end_pos + delimiter_len; } }); } } // namespace // std::unique_ptr<column> slice_strings(strings_column_view const& strings, column_view const& starts_column, column_view const& stops_column, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { size_type strings_count = strings.size(); if (strings_count == 0) return make_empty_column(type_id::STRING); CUDF_EXPECTS(starts_column.size() == strings_count, "Parameter starts must have the same number of rows as strings."); CUDF_EXPECTS(stops_column.size() == strings_count, "Parameter stops must have the same number of rows as strings."); CUDF_EXPECTS(starts_column.type() == stops_column.type(), "Parameters starts and stops must be of the same type."); CUDF_EXPECTS(starts_column.null_count() == 0, "Parameter starts must not contain nulls."); CUDF_EXPECTS(stops_column.null_count() == 0, "Parameter stops must not contain nulls."); CUDF_EXPECTS(starts_column.type().id() != data_type{type_id::BOOL8}.id(), "Positions values must not be bool type."); CUDF_EXPECTS(is_fixed_width(starts_column.type()), "Positions values must be fixed width type."); auto strings_column = column_device_view::create(strings.parent(), stream); auto starts_iter = cudf::detail::indexalator_factory::make_input_iterator(starts_column); auto stops_iter = cudf::detail::indexalator_factory::make_input_iterator(stops_column); return compute_substrings_from_fn( *strings_column, strings.null_count(), starts_iter, stops_iter, stream, mr); } template <typename DelimiterItrT> std::unique_ptr<column> slice_strings(strings_column_view const& strings, DelimiterItrT const delimiter_itr, size_type count, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { auto strings_count = strings.size(); // If there aren't any rows, return an empty strings column if (strings_count == 0) return empty_like(strings.parent()); // Compute the substring indices first auto start_chars_pos_vec = make_column_from_scalar(numeric_scalar<size_type>(0, true, stream), strings_count, stream, rmm::mr::get_current_device_resource()); auto stop_chars_pos_vec = make_column_from_scalar(numeric_scalar<size_type>(0, true, stream), strings_count, stream, rmm::mr::get_current_device_resource()); auto start_char_pos = start_chars_pos_vec->mutable_view().data<size_type>(); auto end_char_pos = stop_chars_pos_vec->mutable_view().data<size_type>(); auto strings_column = column_device_view::create(strings.parent(), stream); auto d_column = *strings_column; // If delimiter count is 0, the output column will contain empty strings if (count != 0) { // Compute the substring indices first compute_substring_indices( d_column, delimiter_itr, count, start_char_pos, end_char_pos, stream, mr); } // Extract the substrings using the indices next auto starts_iter = cudf::detail::indexalator_factory::make_input_iterator(start_chars_pos_vec->view()); auto stops_iter = cudf::detail::indexalator_factory::make_input_iterator(stop_chars_pos_vec->view()); return compute_substrings_from_fn( d_column, strings.null_count(), starts_iter, stops_iter, stream, mr); } std::unique_ptr<column> slice_strings(strings_column_view const& strings, strings_column_view const& delimiters, size_type count, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { CUDF_EXPECTS(strings.size() == delimiters.size(), "Strings and delimiters column sizes do not match"); auto delimiters_dev_view_ptr = cudf::column_device_view::create(delimiters.parent(), stream); auto delimiters_dev_view = *delimiters_dev_view_ptr; return (delimiters_dev_view.nullable()) ? detail::slice_strings( strings, cudf::detail::make_pair_iterator<string_view, true>(delimiters_dev_view), count, stream, mr) : detail::slice_strings( strings, cudf::detail::make_pair_iterator<string_view, false>(delimiters_dev_view), count, stream, mr); } } // namespace detail // external API std::unique_ptr<column> slice_strings(strings_column_view const& strings, column_view const& starts_column, column_view const& stops_column, rmm::mr::device_memory_resource* mr) { CUDF_FUNC_RANGE(); return detail::slice_strings( strings, starts_column, stops_column, cudf::get_default_stream(), mr); } std::unique_ptr<column> slice_strings(strings_column_view const& strings, string_scalar const& delimiter, size_type count, rmm::mr::device_memory_resource* mr) { CUDF_FUNC_RANGE(); return detail::slice_strings(strings, cudf::detail::make_pair_iterator<string_view>(delimiter), count, cudf::get_default_stream(), mr); } std::unique_ptr<column> slice_strings(strings_column_view const& strings, strings_column_view const& delimiters, size_type count, rmm::mr::device_memory_resource* mr) { CUDF_FUNC_RANGE(); return detail::slice_strings(strings, delimiters, count, cudf::get_default_stream(), mr); } } // namespace strings } // namespace cudf
1d96912ff057ff426b5b45cda85e818f1c54cd59.cu
/* * Copyright (c) 2019-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <cudf/column/column_device_view.cuh> #include <cudf/column/column_factories.hpp> #include <cudf/copying.hpp> #include <cudf/detail/get_value.cuh> #include <cudf/detail/indexalator.cuh> #include <cudf/detail/iterator.cuh> #include <cudf/detail/null_mask.hpp> #include <cudf/detail/nvtx/ranges.hpp> #include <cudf/scalar/scalar_device_view.cuh> #include <cudf/strings/detail/strings_children.cuh> #include <cudf/strings/string_view.cuh> #include <cudf/strings/strings_column_view.hpp> #include <cudf/strings/substring.hpp> #include <cudf/utilities/default_stream.hpp> #include <rmm/cuda_stream_view.hpp> #include <thrust/for_each.h> #include <thrust/iterator/counting_iterator.h> namespace cudf { namespace strings { namespace detail { namespace { /** * @brief Function logic for the substring API. * * This will perform a substring operation on each string * using the provided start, stop, and step parameters. */ struct substring_fn { column_device_view const d_column; numeric_scalar_device_view<size_type> const d_start; numeric_scalar_device_view<size_type> const d_stop; numeric_scalar_device_view<size_type> const d_step; int32_t* d_offsets{}; char* d_chars{}; __device__ void operator()(size_type idx) { if (d_column.is_null(idx)) { if (!d_chars) d_offsets[idx] = 0; return; } auto const d_str = d_column.template element<string_view>(idx); auto const length = d_str.length(); if (length == 0) { if (!d_chars) d_offsets[idx] = 0; return; } size_type const step = d_step.is_valid() ? d_step.value() : 1; auto const begin = [&] { // always inclusive // when invalid, default depends on step if (!d_start.is_valid()) return (step > 0) ? d_str.begin() : (d_str.end() - 1); // normal positive position logic auto start = d_start.value(); if (start >= 0) { if (start < length) return d_str.begin() + start; return d_str.end() + (step < 0 ? -1 : 0); } // handle negative position here auto adjust = length + start; if (adjust >= 0) return d_str.begin() + adjust; return d_str.begin() + (step < 0 ? -1 : 0); }(); auto const end = [&] { // always exclusive // when invalid, default depends on step if (!d_stop.is_valid()) return step > 0 ? d_str.end() : (d_str.begin() - 1); // normal positive position logic auto stop = d_stop.value(); if (stop >= 0) return (stop < length) ? (d_str.begin() + stop) : d_str.end(); // handle negative position here auto adjust = length + stop; return d_str.begin() + (adjust >= 0 ? adjust : -1); }(); size_type bytes = 0; char* d_buffer = d_chars ? d_chars + d_offsets[idx] : nullptr; auto itr = begin; while (step > 0 ? itr < end : end < itr) { bytes += bytes_in_char_utf8(*itr); if (d_buffer) d_buffer += from_char_utf8(*itr, d_buffer); itr += step; } if (!d_chars) d_offsets[idx] = bytes; } }; } // namespace // std::unique_ptr<column> slice_strings(strings_column_view const& strings, numeric_scalar<size_type> const& start, numeric_scalar<size_type> const& stop, numeric_scalar<size_type> const& step, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { if (strings.is_empty()) return make_empty_column(type_id::STRING); if (step.is_valid(stream)) CUDF_EXPECTS(step.value(stream) != 0, "Step parameter must not be 0"); auto const d_column = column_device_view::create(strings.parent(), stream); auto const d_start = get_scalar_device_view(const_cast<numeric_scalar<size_type>&>(start)); auto const d_stop = get_scalar_device_view(const_cast<numeric_scalar<size_type>&>(stop)); auto const d_step = get_scalar_device_view(const_cast<numeric_scalar<size_type>&>(step)); auto children = make_strings_children( substring_fn{*d_column, d_start, d_stop, d_step}, strings.size(), stream, mr); return make_strings_column(strings.size(), std::move(children.first), std::move(children.second), strings.null_count(), cudf::detail::copy_bitmask(strings.parent(), stream, mr)); } } // namespace detail // external API std::unique_ptr<column> slice_strings(strings_column_view const& strings, numeric_scalar<size_type> const& start, numeric_scalar<size_type> const& stop, numeric_scalar<size_type> const& step, rmm::mr::device_memory_resource* mr) { CUDF_FUNC_RANGE(); return detail::slice_strings(strings, start, stop, step, cudf::get_default_stream(), mr); } namespace detail { namespace { /** * @brief Function logic for substring_from API. * * This both calculates the output size and executes the substring. */ struct substring_from_fn { column_device_view const d_column; cudf::detail::input_indexalator const starts; cudf::detail::input_indexalator const stops; int32_t* d_offsets{}; char* d_chars{}; __device__ void operator()(size_type idx) { if (d_column.is_null(idx)) { if (!d_chars) d_offsets[idx] = 0; return; } auto const d_str = d_column.template element<string_view>(idx); auto const length = d_str.length(); auto const start = std::max(starts[idx], 0); if (start >= length) { if (!d_chars) d_offsets[idx] = 0; return; } auto const stop = stops[idx]; auto const end = (((stop < 0) || (stop > length)) ? length : stop); auto const d_substr = d_str.substr(start, end - start); if (d_chars) memcpy(d_chars + d_offsets[idx], d_substr.data(), d_substr.size_bytes()); else d_offsets[idx] = d_substr.size_bytes(); } }; /** * @brief Common utility function for the slice_strings APIs. * * It wraps calling the functors appropriately to build the output strings column. * * The input iterators may have unique position values per string in `d_column`. * * @param d_column Input strings column to substring. * @param null_count Number of nulls for the output column. * @param starts Start positions index iterator. * @param stops Stop positions index iterator. * @param stream CUDA stream used for device memory operations and kernel launches. * @param mr Device memory resource used to allocate the returned column's device memory. */ std::unique_ptr<column> compute_substrings_from_fn(column_device_view const& d_column, size_type null_count, cudf::detail::input_indexalator starts, cudf::detail::input_indexalator stops, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { auto strings_count = d_column.size(); // Copy the null mask rmm::device_buffer null_mask = !d_column.nullable() ? rmm::device_buffer{0, stream, mr} : rmm::device_buffer( d_column.null_mask(), cudf::bitmask_allocation_size_bytes(strings_count), stream, mr); auto children = make_strings_children(substring_from_fn{d_column, starts, stops}, strings_count, stream, mr); return make_strings_column(strings_count, std::move(children.first), std::move(children.second), null_count, std::move(null_mask)); } /** * @brief Compute slice indices for each string. * * When slice_strings is invoked with a delimiter string and a delimiter count, we need to * compute the start and end indices of the substring. This function accomplishes that. */ template <typename DelimiterItrT> void compute_substring_indices(column_device_view const& d_column, DelimiterItrT const delim_itr, size_type delimiter_count, size_type* start_char_pos, size_type* end_char_pos, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource*) { auto strings_count = d_column.size(); thrust::for_each_n( rmm::exec_policy(stream), thrust::make_counting_iterator<size_type>(0), strings_count, [delim_itr, delimiter_count, start_char_pos, end_char_pos, d_column] __device__(size_type idx) { auto const& delim_val_pair = delim_itr[idx]; auto const& delim_val = delim_val_pair.first; // Don't use it yet // If the column value for this row is null, result is null. // If the delimiter count is 0, result is empty string. // If the global delimiter or the row specific delimiter is invalid or if it is empty, row // value is empty. if (d_column.is_null(idx) || !delim_val_pair.second || delim_val.empty()) return; auto const& col_val = d_column.element<string_view>(idx); // If the column value for the row is empty, the row value is empty. if (!col_val.empty()) { auto const col_val_len = col_val.length(); auto const delimiter_len = delim_val.length(); auto nsearches = (delimiter_count < 0) ? -delimiter_count : delimiter_count; bool const left_to_right = (delimiter_count > 0); size_type start_pos = start_char_pos[idx]; size_type end_pos = col_val_len; size_type char_pos = -1; end_char_pos[idx] = col_val_len; for (auto i = 0; i < nsearches; ++i) { char_pos = left_to_right ? col_val.find(delim_val, start_pos) : col_val.rfind(delim_val, 0, end_pos); if (char_pos == string_view::npos) return; if (left_to_right) start_pos = char_pos + delimiter_len; else end_pos = char_pos; } if (left_to_right) end_char_pos[idx] = char_pos; else start_char_pos[idx] = end_pos + delimiter_len; } }); } } // namespace // std::unique_ptr<column> slice_strings(strings_column_view const& strings, column_view const& starts_column, column_view const& stops_column, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { size_type strings_count = strings.size(); if (strings_count == 0) return make_empty_column(type_id::STRING); CUDF_EXPECTS(starts_column.size() == strings_count, "Parameter starts must have the same number of rows as strings."); CUDF_EXPECTS(stops_column.size() == strings_count, "Parameter stops must have the same number of rows as strings."); CUDF_EXPECTS(starts_column.type() == stops_column.type(), "Parameters starts and stops must be of the same type."); CUDF_EXPECTS(starts_column.null_count() == 0, "Parameter starts must not contain nulls."); CUDF_EXPECTS(stops_column.null_count() == 0, "Parameter stops must not contain nulls."); CUDF_EXPECTS(starts_column.type().id() != data_type{type_id::BOOL8}.id(), "Positions values must not be bool type."); CUDF_EXPECTS(is_fixed_width(starts_column.type()), "Positions values must be fixed width type."); auto strings_column = column_device_view::create(strings.parent(), stream); auto starts_iter = cudf::detail::indexalator_factory::make_input_iterator(starts_column); auto stops_iter = cudf::detail::indexalator_factory::make_input_iterator(stops_column); return compute_substrings_from_fn( *strings_column, strings.null_count(), starts_iter, stops_iter, stream, mr); } template <typename DelimiterItrT> std::unique_ptr<column> slice_strings(strings_column_view const& strings, DelimiterItrT const delimiter_itr, size_type count, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { auto strings_count = strings.size(); // If there aren't any rows, return an empty strings column if (strings_count == 0) return empty_like(strings.parent()); // Compute the substring indices first auto start_chars_pos_vec = make_column_from_scalar(numeric_scalar<size_type>(0, true, stream), strings_count, stream, rmm::mr::get_current_device_resource()); auto stop_chars_pos_vec = make_column_from_scalar(numeric_scalar<size_type>(0, true, stream), strings_count, stream, rmm::mr::get_current_device_resource()); auto start_char_pos = start_chars_pos_vec->mutable_view().data<size_type>(); auto end_char_pos = stop_chars_pos_vec->mutable_view().data<size_type>(); auto strings_column = column_device_view::create(strings.parent(), stream); auto d_column = *strings_column; // If delimiter count is 0, the output column will contain empty strings if (count != 0) { // Compute the substring indices first compute_substring_indices( d_column, delimiter_itr, count, start_char_pos, end_char_pos, stream, mr); } // Extract the substrings using the indices next auto starts_iter = cudf::detail::indexalator_factory::make_input_iterator(start_chars_pos_vec->view()); auto stops_iter = cudf::detail::indexalator_factory::make_input_iterator(stop_chars_pos_vec->view()); return compute_substrings_from_fn( d_column, strings.null_count(), starts_iter, stops_iter, stream, mr); } std::unique_ptr<column> slice_strings(strings_column_view const& strings, strings_column_view const& delimiters, size_type count, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { CUDF_EXPECTS(strings.size() == delimiters.size(), "Strings and delimiters column sizes do not match"); auto delimiters_dev_view_ptr = cudf::column_device_view::create(delimiters.parent(), stream); auto delimiters_dev_view = *delimiters_dev_view_ptr; return (delimiters_dev_view.nullable()) ? detail::slice_strings( strings, cudf::detail::make_pair_iterator<string_view, true>(delimiters_dev_view), count, stream, mr) : detail::slice_strings( strings, cudf::detail::make_pair_iterator<string_view, false>(delimiters_dev_view), count, stream, mr); } } // namespace detail // external API std::unique_ptr<column> slice_strings(strings_column_view const& strings, column_view const& starts_column, column_view const& stops_column, rmm::mr::device_memory_resource* mr) { CUDF_FUNC_RANGE(); return detail::slice_strings( strings, starts_column, stops_column, cudf::get_default_stream(), mr); } std::unique_ptr<column> slice_strings(strings_column_view const& strings, string_scalar const& delimiter, size_type count, rmm::mr::device_memory_resource* mr) { CUDF_FUNC_RANGE(); return detail::slice_strings(strings, cudf::detail::make_pair_iterator<string_view>(delimiter), count, cudf::get_default_stream(), mr); } std::unique_ptr<column> slice_strings(strings_column_view const& strings, strings_column_view const& delimiters, size_type count, rmm::mr::device_memory_resource* mr) { CUDF_FUNC_RANGE(); return detail::slice_strings(strings, delimiters, count, cudf::get_default_stream(), mr); } } // namespace strings } // namespace cudf
08013bf1ddc4a06d53a6cbba38e0779ec51b6932.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include "THHUNN.h" #include "THHDeviceTensor.cuh" #include "THHDeviceTensorUtils.cuh" #include "THHDeviceUtils.cuh" #include "THHReduceApplyUtils.cuh" #include "utils.h" #include "common.h" __global__ void SpatialMirrorHorizontal_updateOutput( THCDeviceTensor<float, 4> input, THCDeviceTensor<float, 4> output) { int outputPointId = threadIdx.x + blockIdx.x * blockDim.x; int plane = blockIdx.y; int batch = blockIdx.z; if (outputPointId >= output.getSize(2) * output.getSize(3)) { return; } int outputPointX = outputPointId % output.getSize(3); int outputPointY = outputPointId / output.getSize(3); int inputPointX = output.getSize(3) - outputPointX - 1; int inputPointY = outputPointY; float valueToCopy = input[batch][plane][inputPointY][inputPointX]; output[batch][plane][outputPointY][outputPointX] = valueToCopy; } static int extracunn_SpatialMirrorHorizontal_updateOutput(lua_State *L) { THCState *state = getCutorchState(L); THCudaTensor *input = (THCudaTensor*)luaT_checkudata(L, 2, "torch.CudaTensor"); THCudaTensor *output = (THCudaTensor*)luaT_getfieldcheckudata(L, 1, "output", "torch.CudaTensor"); int planeDim = 0; int dimh = 1; int dimw = 2; int numBatch = 1; int numInputDims = THCudaTensor_nDimension(state, input); THArgCheck(numInputDims == 3 || numInputDims == 4, 2, "input must be 3 or 4-dimensional"); if (numInputDims == 4) { numBatch = THCudaTensor_size(state, input, 0); planeDim++; dimh++; dimw++; } int numPlanes = THCudaTensor_size(state, input, planeDim); int inputH = THCudaTensor_size(state, input, dimh); int inputW = THCudaTensor_size(state, input, dimw); int outputH = inputH; int outputW = inputW; THCDeviceTensor<float, 4> devInput; THCDeviceTensor<float, 4> devOutput; if (numInputDims == 3) { THCudaTensor_resize3d(state, output, numPlanes, outputH, outputW); devInput = toDeviceTensor<float, 3>(state, input).upcastOuter<4>(); devOutput = toDeviceTensor<float, 3>(state, output).upcastOuter<4>(); } else { THCudaTensor_resize4d(state, output, numBatch, numPlanes, outputH, outputW); devInput = toDeviceTensor<float, 4>(state, input); devOutput = toDeviceTensor<float, 4>(state, output); } int outputPlaneSize = devOutput.getSize(2) * devOutput.getSize(3); dim3 gridSize(THCCeilDiv(outputPlaneSize, 256), devOutput.getSize(1), devOutput.getSize(0)); dim3 blockSize(outputPlaneSize > 256 ? 256 : outputPlaneSize); hipLaunchKernelGGL(( SpatialMirrorHorizontal_updateOutput), dim3(gridSize), dim3(blockSize), 0, THCState_getCurrentStream(state), devInput, devOutput); return 1; } __global__ void SpatialMirrorHorizontal_updateGradInput( THCDeviceTensor<float, 4> gradInput, THCDeviceTensor<float, 4> gradOutput) { int outputPointId = threadIdx.x + blockIdx.x * blockDim.x; int plane = blockIdx.y; int batch = blockIdx.z; if (outputPointId >= gradOutput.getSize(2) * gradOutput.getSize(3)) { return; } int outputPointX = outputPointId % gradOutput.getSize(3); int outputPointY = outputPointId / gradOutput.getSize(3); int inputPointX = gradOutput.getSize(3) - outputPointX - 1; int inputPointY = outputPointY; float valueToCopy = gradOutput[batch][plane][outputPointY][outputPointX]; //atomicAdd(&gradInput[batch][plane][inputPointY][inputPointX], valueToCopy); gradInput[batch][plane][inputPointY][inputPointX] = valueToCopy; } static int extracunn_SpatialMirrorHorizontal_updateGradInput(lua_State *L) { THCState *state = getCutorchState(L); // Inputs THCudaTensor *input = (THCudaTensor *)luaT_checkudata(L, 2, "torch.CudaTensor"); THCudaTensor *gradOutput = (THCudaTensor *)luaT_checkudata(L, 3, "torch.CudaTensor"); THCudaTensor *gradInput = (THCudaTensor *)luaT_getfieldcheckudata(L, 1, "gradInput", "torch.CudaTensor"); int planeDim = 0; int dimh = 1; int dimw = 2; int numInputDims = THCudaTensor_nDimension(state, input); if (numInputDims == 4) { planeDim++; dimh++; dimw++; } THCudaTensor_resizeAs(state, gradInput, input); THCudaTensor_zero(state, gradInput); THCDeviceTensor<float, 4> devGradInput; THCDeviceTensor<float, 4> devGradOutput; if (numInputDims == 3) { devGradInput = toDeviceTensor<float, 3>(state, gradInput).upcastOuter<4>(); devGradOutput = toDeviceTensor<float, 3>(state, gradOutput).upcastOuter<4>(); } else { devGradInput = toDeviceTensor<float, 4>(state, gradInput); devGradOutput = toDeviceTensor<float, 4>(state, gradOutput); } int outputPlaneSize = devGradOutput.getSize(2) * devGradOutput.getSize(3); dim3 gridSize(THCCeilDiv(outputPlaneSize, 256), devGradOutput.getSize(1), devGradOutput.getSize(0)); dim3 blockSize(outputPlaneSize > 256 ? 256 : outputPlaneSize); hipLaunchKernelGGL(( SpatialMirrorHorizontal_updateGradInput), dim3(gridSize), dim3(blockSize), 0, THCState_getCurrentStream(state), devGradInput, devGradOutput); return 1; } static const struct luaL_Reg extracunn_SpatialMirrorHorizontal__ [] = { {"SpatialMirrorHorizontal_updateOutput", extracunn_SpatialMirrorHorizontal_updateOutput}, {"SpatialMirrorHorizontal_updateGradInput", extracunn_SpatialMirrorHorizontal_updateGradInput}, {NULL, NULL} }; void extracunn_SpatialMirrorHorizontal_init(lua_State *L) { luaT_pushmetatable(L, "torch.CudaTensor"); luaT_registeratname(L, extracunn_SpatialMirrorHorizontal__, "nn"); lua_pop(L,1); }
08013bf1ddc4a06d53a6cbba38e0779ec51b6932.cu
#include "THCUNN.h" #include "THCDeviceTensor.cuh" #include "THCDeviceTensorUtils.cuh" #include "THCDeviceUtils.cuh" #include "THCReduceApplyUtils.cuh" #include "utils.h" #include "common.h" __global__ void SpatialMirrorHorizontal_updateOutput( THCDeviceTensor<float, 4> input, THCDeviceTensor<float, 4> output) { int outputPointId = threadIdx.x + blockIdx.x * blockDim.x; int plane = blockIdx.y; int batch = blockIdx.z; if (outputPointId >= output.getSize(2) * output.getSize(3)) { return; } int outputPointX = outputPointId % output.getSize(3); int outputPointY = outputPointId / output.getSize(3); int inputPointX = output.getSize(3) - outputPointX - 1; int inputPointY = outputPointY; float valueToCopy = input[batch][plane][inputPointY][inputPointX]; output[batch][plane][outputPointY][outputPointX] = valueToCopy; } static int extracunn_SpatialMirrorHorizontal_updateOutput(lua_State *L) { THCState *state = getCutorchState(L); THCudaTensor *input = (THCudaTensor*)luaT_checkudata(L, 2, "torch.CudaTensor"); THCudaTensor *output = (THCudaTensor*)luaT_getfieldcheckudata(L, 1, "output", "torch.CudaTensor"); int planeDim = 0; int dimh = 1; int dimw = 2; int numBatch = 1; int numInputDims = THCudaTensor_nDimension(state, input); THArgCheck(numInputDims == 3 || numInputDims == 4, 2, "input must be 3 or 4-dimensional"); if (numInputDims == 4) { numBatch = THCudaTensor_size(state, input, 0); planeDim++; dimh++; dimw++; } int numPlanes = THCudaTensor_size(state, input, planeDim); int inputH = THCudaTensor_size(state, input, dimh); int inputW = THCudaTensor_size(state, input, dimw); int outputH = inputH; int outputW = inputW; THCDeviceTensor<float, 4> devInput; THCDeviceTensor<float, 4> devOutput; if (numInputDims == 3) { THCudaTensor_resize3d(state, output, numPlanes, outputH, outputW); devInput = toDeviceTensor<float, 3>(state, input).upcastOuter<4>(); devOutput = toDeviceTensor<float, 3>(state, output).upcastOuter<4>(); } else { THCudaTensor_resize4d(state, output, numBatch, numPlanes, outputH, outputW); devInput = toDeviceTensor<float, 4>(state, input); devOutput = toDeviceTensor<float, 4>(state, output); } int outputPlaneSize = devOutput.getSize(2) * devOutput.getSize(3); dim3 gridSize(THCCeilDiv(outputPlaneSize, 256), devOutput.getSize(1), devOutput.getSize(0)); dim3 blockSize(outputPlaneSize > 256 ? 256 : outputPlaneSize); SpatialMirrorHorizontal_updateOutput<<<gridSize, blockSize, 0, THCState_getCurrentStream(state)>>>( devInput, devOutput); return 1; } __global__ void SpatialMirrorHorizontal_updateGradInput( THCDeviceTensor<float, 4> gradInput, THCDeviceTensor<float, 4> gradOutput) { int outputPointId = threadIdx.x + blockIdx.x * blockDim.x; int plane = blockIdx.y; int batch = blockIdx.z; if (outputPointId >= gradOutput.getSize(2) * gradOutput.getSize(3)) { return; } int outputPointX = outputPointId % gradOutput.getSize(3); int outputPointY = outputPointId / gradOutput.getSize(3); int inputPointX = gradOutput.getSize(3) - outputPointX - 1; int inputPointY = outputPointY; float valueToCopy = gradOutput[batch][plane][outputPointY][outputPointX]; //atomicAdd(&gradInput[batch][plane][inputPointY][inputPointX], valueToCopy); gradInput[batch][plane][inputPointY][inputPointX] = valueToCopy; } static int extracunn_SpatialMirrorHorizontal_updateGradInput(lua_State *L) { THCState *state = getCutorchState(L); // Inputs THCudaTensor *input = (THCudaTensor *)luaT_checkudata(L, 2, "torch.CudaTensor"); THCudaTensor *gradOutput = (THCudaTensor *)luaT_checkudata(L, 3, "torch.CudaTensor"); THCudaTensor *gradInput = (THCudaTensor *)luaT_getfieldcheckudata(L, 1, "gradInput", "torch.CudaTensor"); int planeDim = 0; int dimh = 1; int dimw = 2; int numInputDims = THCudaTensor_nDimension(state, input); if (numInputDims == 4) { planeDim++; dimh++; dimw++; } THCudaTensor_resizeAs(state, gradInput, input); THCudaTensor_zero(state, gradInput); THCDeviceTensor<float, 4> devGradInput; THCDeviceTensor<float, 4> devGradOutput; if (numInputDims == 3) { devGradInput = toDeviceTensor<float, 3>(state, gradInput).upcastOuter<4>(); devGradOutput = toDeviceTensor<float, 3>(state, gradOutput).upcastOuter<4>(); } else { devGradInput = toDeviceTensor<float, 4>(state, gradInput); devGradOutput = toDeviceTensor<float, 4>(state, gradOutput); } int outputPlaneSize = devGradOutput.getSize(2) * devGradOutput.getSize(3); dim3 gridSize(THCCeilDiv(outputPlaneSize, 256), devGradOutput.getSize(1), devGradOutput.getSize(0)); dim3 blockSize(outputPlaneSize > 256 ? 256 : outputPlaneSize); SpatialMirrorHorizontal_updateGradInput<<<gridSize, blockSize, 0, THCState_getCurrentStream(state)>>>( devGradInput, devGradOutput); return 1; } static const struct luaL_Reg extracunn_SpatialMirrorHorizontal__ [] = { {"SpatialMirrorHorizontal_updateOutput", extracunn_SpatialMirrorHorizontal_updateOutput}, {"SpatialMirrorHorizontal_updateGradInput", extracunn_SpatialMirrorHorizontal_updateGradInput}, {NULL, NULL} }; void extracunn_SpatialMirrorHorizontal_init(lua_State *L) { luaT_pushmetatable(L, "torch.CudaTensor"); luaT_registeratname(L, extracunn_SpatialMirrorHorizontal__, "nn"); lua_pop(L,1); }
275fda539c88d2ed62ced054f4f86622efbf816b.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include "includes.h" __global__ void fast_variance_kernel(float *x, float *mean, int batch, int filters, int spatial, float *variance) { const int threads = BLOCK; __shared__ float local[threads]; int id = threadIdx.x; local[id] = 0; int filter = blockIdx.x; int i, j; for(j = 0; j < batch; ++j){ for(i = 0; i < spatial; i += threads){ int index = j*spatial*filters + filter*spatial + i + id; local[id] += (i+id < spatial) ? pow((x[index] - mean[filter]), 2) : 0; } } __syncthreads(); if(id == 0){ variance[filter] = 0; for(i = 0; i < threads; ++i){ variance[filter] += local[i]; } variance[filter] /= (spatial * batch - 1); } }
275fda539c88d2ed62ced054f4f86622efbf816b.cu
#include "includes.h" __global__ void fast_variance_kernel(float *x, float *mean, int batch, int filters, int spatial, float *variance) { const int threads = BLOCK; __shared__ float local[threads]; int id = threadIdx.x; local[id] = 0; int filter = blockIdx.x; int i, j; for(j = 0; j < batch; ++j){ for(i = 0; i < spatial; i += threads){ int index = j*spatial*filters + filter*spatial + i + id; local[id] += (i+id < spatial) ? pow((x[index] - mean[filter]), 2) : 0; } } __syncthreads(); if(id == 0){ variance[filter] = 0; for(i = 0; i < threads; ++i){ variance[filter] += local[i]; } variance[filter] /= (spatial * batch - 1); } }
67669f62f9b8b539cf023da076a829db5bdb346a.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include <stdlib.h> #include <stdio.h> #include <string.h> #include "timer.h" #include "cuda_utils.h" #include <thrust/sort.h> typedef float dtype; #define N_ (8 * 8 * 8) #define MAX_THREADS 256 #define MAX_BLOCKS 64 #define MIN(x,y) ((x < y) ? x : y) float *d_attr_values, *d_output; int * d_target_values; float * data_temp; // NVIDIA's // Selection sort used when depth gets too big or the number of elements drops // below a threshold. __device__ float selection_sort( float * data_mat, int left, int right ) { float max = 0; float min = 100000; for(int i = left; i<right; i++) { if(data_mat[i]>max) max = data_mat[i]; if(data_mat[i]<min) min = data_mat[i]; } return (max+min)/2; } __global__ void kernel5(float * attrValues, int *targetValues, float *g_odata, unsigned int numSamples, unsigned int numClasses, int numAttributes) { /* Shared variable within each block */ __shared__ float scratch[MAX_THREADS]; __shared__ float sum[MAX_THREADS]; /* Finding block id */ unsigned int bid = gridDim.x * blockIdx.y + blockIdx.x; /* Number of threads within each block */ unsigned int numberThreads = blockDim.x; /* Attributes per block */ unsigned int blockOffset = bid*numSamples; if(threadIdx.x==0 && bid<numAttributes) { /* Initialize Shared Memory */ for(int k = 0; k<3*numClasses; k++) { scratch[k] = 0; } for(int k = 0; k<MAX_THREADS ; k++) { sum[k] = 0; } //Memory to store threshold scratch[3*numClasses] = 0; } __syncthreads (); /* Reduction */ unsigned int offset = blockOffset+threadIdx.x; while(offset < blockOffset+numSamples && bid<numAttributes) { sum[threadIdx.x] += attrValues[offset]; offset += numberThreads; } __syncthreads (); /* Find global max and min */ if(threadIdx.x==0 && bid<numAttributes){ float global_sum = 0; for(unsigned int m = 0; m<MAX_THREADS; m++) global_sum += sum[m]; scratch[3*numClasses] = global_sum/numSamples; } __syncthreads (); offset = blockOffset+threadIdx.x; while(offset < blockOffset+numSamples && bid<numAttributes) { int temp = (int)targetValues[offset-blockOffset]; atomicAdd(scratch+temp, 1); float thresh = scratch[3*numClasses]; if(attrValues[offset] <= thresh) atomicAdd(scratch+numClasses+temp, 1); else atomicAdd(scratch+numClasses+numClasses+temp, 1); offset += numberThreads; } __syncthreads (); if(threadIdx.x==0 && bid<numAttributes) { float entropy = 0; float entropy_l = 0; float entropy_r = 0; float proportion = 0; float proportion_l = 0; float proportion_r = 0; int numSamples_l = 0; for(int m = numClasses; m<2*numClasses; m++) numSamples_l += scratch[m]; int numSamples_r = 0; for(int m = 2*numClasses; m<3*numClasses; m++) numSamples_r += scratch[m]; for(int m=0; m<numClasses; m++){ proportion = scratch[m]/numSamples; proportion_l = scratch[numClasses+m]/numSamples_l; proportion_r = scratch[2*numClasses+m]/numSamples_r; if(proportion!=0) entropy += (-1)*proportion*log2f(proportion); if(proportion_l!=0) entropy_l += (-1)*proportion_l*log2f(proportion_l); if(proportion_r!=0) entropy_r += (-1)*proportion_r*log2f(proportion_r); } g_odata[2*bid] = entropy - ((numSamples_l/numSamples)*entropy_l + (numSamples_r/numSamples)*entropy_r); g_odata[2*bid+1] = scratch[3*numClasses]; } __syncthreads (); } void gpuHandler(float * samplesData, int * targetVals, int numSamples, int numAttrs, int numClasses, int * remAttributes, int & maxAttr, float & maxThreshold) { int numRequiredAttrs = 0; for(int i = 0; i<numAttrs; i++) if(remAttributes[i]==0) numRequiredAttrs++; // float * data_temp = (float *) malloc (numSamples * numRequiredAttrs * sizeof(float)); int offset = 0; for(int i = 0; i< numAttrs; i++) { if(remAttributes[i]!=0) continue; for(int j = 0; j<numSamples; j++) { data_temp[offset] = samplesData[j*numAttrs+i]; offset++; } } // float *d_output, *d_temp_attr; // int *d_target_values; /* allocate memory */ //CUDA_CHECK_ERROR (hipMalloc (&d_attr_values,numRequiredAttrs * numSamples * sizeof (float))); //CUDA_CHECK_ERROR (hipMalloc (&d_temp_attr, numRequiredAttrs * numSamples * sizeof (float))); //CUDA_CHECK_ERROR (hipMalloc (&d_target_values, numSamples * sizeof (int))); //CUDA_CHECK_ERROR (hipMalloc (&d_output, numRequiredAttrs * 2 * sizeof (float))); // CUDA_CHECK_ERROR (hipMemcpy (d_attr_values, data_temp, numRequiredAttrs*numSamples * sizeof (float), hipMemcpyHostToDevice)); // CUDA_CHECK_ERROR (hipMemcpy (d_temp_attr, data_temp, numRequiredAttrs*numSamples * sizeof (float), hipMemcpyHostToDevice)); CUDA_CHECK_ERROR (hipMemcpy (d_target_values, targetVals, numSamples * sizeof (int), hipMemcpyHostToDevice)); /* GPU kernel */ dim3 gb(MAX_BLOCKS, 1, 1); dim3 tb(MAX_THREADS, 1, 1); /* warm up */ // hipLaunchKernelGGL(( kernel5) , dim3(gb), dim3(tb), 0, 0, d_attr_values, d_temp_attr, d_target_values, d_output, numSamples, numClasses, 1); // hipDeviceSynchronize (); /* execute kernel */ unsigned int attrPerBlock = MAX_BLOCKS; float * h_ans = (float *) malloc (2*numRequiredAttrs*sizeof(float)); for(int iter = 0; iter < numRequiredAttrs; iter=iter+MAX_BLOCKS) { if(numRequiredAttrs - iter < MAX_BLOCKS) attrPerBlock = numRequiredAttrs - iter; // Copying max 64 attr data into CUDA CUDA_CHECK_ERROR (hipMemcpy (d_attr_values, data_temp+iter*numSamples, attrPerBlock*numSamples * sizeof (float), hipMemcpyHostToDevice)); hipLaunchKernelGGL(( kernel5) , dim3(gb), dim3(tb), 0, 0, d_attr_values, d_target_values, d_output, numSamples, numClasses, numRequiredAttrs); hipDeviceSynchronize (); /* copy result back from GPU */ CUDA_CHECK_ERROR (hipMemcpy (h_ans+iter*2, d_output, 2*attrPerBlock*sizeof (dtype), hipMemcpyDeviceToHost)); } #if 0 hipLaunchKernelGGL(( kernel5) , dim3(gb), dim3(tb), 0, 0, d_attr_values, d_target_values, d_output, numSamples, numClasses, numRequiredAttrs); hipDeviceSynchronize (); /* copy result back from GPU */ float * h_ans = (float *) malloc (2*numRequiredAttrs*sizeof(float)); CUDA_CHECK_ERROR (hipMemcpy (h_ans, d_output, 2*numRequiredAttrs*sizeof (dtype), hipMemcpyDeviceToHost)); #endif //printf("\nFinal Answer:- \n"); //for(int k = 0; k<2*numRequiredAttrs; k++) // printf(" %f ", h_ans[k]); int maxInd = -1; float max = 0; maxThreshold = -1; for(int j = 0; j<numRequiredAttrs; j++) if(h_ans[2*j]>max) { max = h_ans[2*j]; maxInd = j; maxThreshold = h_ans[2*j+1]; } if(maxInd == -1) { maxAttr = -1; maxThreshold = -1; free(h_ans); return; } maxAttr = -1; int temp = -1; for(int j = 0; j < numAttrs; j++){ if(remAttributes[j] == 0) { temp++; if(maxInd == temp) { maxAttr = j; free(h_ans); return; } } } } //device void alloc_cuda1D_float(int numSamples, int numAttrs) { CUDA_CHECK_ERROR (hipMalloc (&d_attr_values, MAX_BLOCKS * numSamples * sizeof (float))); CUDA_CHECK_ERROR (hipMalloc (&d_target_values, numSamples * sizeof (int))); CUDA_CHECK_ERROR (hipMalloc (&d_output, MAX_BLOCKS * 2 * sizeof (float))); data_temp = (float *) malloc (numSamples * numAttrs * sizeof(float)); }
67669f62f9b8b539cf023da076a829db5bdb346a.cu
#include <stdlib.h> #include <stdio.h> #include <string.h> #include "timer.h" #include "cuda_utils.h" #include <thrust/sort.h> typedef float dtype; #define N_ (8 * 8 * 8) #define MAX_THREADS 256 #define MAX_BLOCKS 64 #define MIN(x,y) ((x < y) ? x : y) float *d_attr_values, *d_output; int * d_target_values; float * data_temp; // NVIDIA's // Selection sort used when depth gets too big or the number of elements drops // below a threshold. __device__ float selection_sort( float * data_mat, int left, int right ) { float max = 0; float min = 100000; for(int i = left; i<right; i++) { if(data_mat[i]>max) max = data_mat[i]; if(data_mat[i]<min) min = data_mat[i]; } return (max+min)/2; } __global__ void kernel5(float * attrValues, int *targetValues, float *g_odata, unsigned int numSamples, unsigned int numClasses, int numAttributes) { /* Shared variable within each block */ __shared__ float scratch[MAX_THREADS]; __shared__ float sum[MAX_THREADS]; /* Finding block id */ unsigned int bid = gridDim.x * blockIdx.y + blockIdx.x; /* Number of threads within each block */ unsigned int numberThreads = blockDim.x; /* Attributes per block */ unsigned int blockOffset = bid*numSamples; if(threadIdx.x==0 && bid<numAttributes) { /* Initialize Shared Memory */ for(int k = 0; k<3*numClasses; k++) { scratch[k] = 0; } for(int k = 0; k<MAX_THREADS ; k++) { sum[k] = 0; } //Memory to store threshold scratch[3*numClasses] = 0; } __syncthreads (); /* Reduction */ unsigned int offset = blockOffset+threadIdx.x; while(offset < blockOffset+numSamples && bid<numAttributes) { sum[threadIdx.x] += attrValues[offset]; offset += numberThreads; } __syncthreads (); /* Find global max and min */ if(threadIdx.x==0 && bid<numAttributes){ float global_sum = 0; for(unsigned int m = 0; m<MAX_THREADS; m++) global_sum += sum[m]; scratch[3*numClasses] = global_sum/numSamples; } __syncthreads (); offset = blockOffset+threadIdx.x; while(offset < blockOffset+numSamples && bid<numAttributes) { int temp = (int)targetValues[offset-blockOffset]; atomicAdd(scratch+temp, 1); float thresh = scratch[3*numClasses]; if(attrValues[offset] <= thresh) atomicAdd(scratch+numClasses+temp, 1); else atomicAdd(scratch+numClasses+numClasses+temp, 1); offset += numberThreads; } __syncthreads (); if(threadIdx.x==0 && bid<numAttributes) { float entropy = 0; float entropy_l = 0; float entropy_r = 0; float proportion = 0; float proportion_l = 0; float proportion_r = 0; int numSamples_l = 0; for(int m = numClasses; m<2*numClasses; m++) numSamples_l += scratch[m]; int numSamples_r = 0; for(int m = 2*numClasses; m<3*numClasses; m++) numSamples_r += scratch[m]; for(int m=0; m<numClasses; m++){ proportion = scratch[m]/numSamples; proportion_l = scratch[numClasses+m]/numSamples_l; proportion_r = scratch[2*numClasses+m]/numSamples_r; if(proportion!=0) entropy += (-1)*proportion*log2f(proportion); if(proportion_l!=0) entropy_l += (-1)*proportion_l*log2f(proportion_l); if(proportion_r!=0) entropy_r += (-1)*proportion_r*log2f(proportion_r); } g_odata[2*bid] = entropy - ((numSamples_l/numSamples)*entropy_l + (numSamples_r/numSamples)*entropy_r); g_odata[2*bid+1] = scratch[3*numClasses]; } __syncthreads (); } void gpuHandler(float * samplesData, int * targetVals, int numSamples, int numAttrs, int numClasses, int * remAttributes, int & maxAttr, float & maxThreshold) { int numRequiredAttrs = 0; for(int i = 0; i<numAttrs; i++) if(remAttributes[i]==0) numRequiredAttrs++; // float * data_temp = (float *) malloc (numSamples * numRequiredAttrs * sizeof(float)); int offset = 0; for(int i = 0; i< numAttrs; i++) { if(remAttributes[i]!=0) continue; for(int j = 0; j<numSamples; j++) { data_temp[offset] = samplesData[j*numAttrs+i]; offset++; } } // float *d_output, *d_temp_attr; // int *d_target_values; /* allocate memory */ //CUDA_CHECK_ERROR (cudaMalloc (&d_attr_values,numRequiredAttrs * numSamples * sizeof (float))); //CUDA_CHECK_ERROR (cudaMalloc (&d_temp_attr, numRequiredAttrs * numSamples * sizeof (float))); //CUDA_CHECK_ERROR (cudaMalloc (&d_target_values, numSamples * sizeof (int))); //CUDA_CHECK_ERROR (cudaMalloc (&d_output, numRequiredAttrs * 2 * sizeof (float))); // CUDA_CHECK_ERROR (cudaMemcpy (d_attr_values, data_temp, numRequiredAttrs*numSamples * sizeof (float), cudaMemcpyHostToDevice)); // CUDA_CHECK_ERROR (cudaMemcpy (d_temp_attr, data_temp, numRequiredAttrs*numSamples * sizeof (float), cudaMemcpyHostToDevice)); CUDA_CHECK_ERROR (cudaMemcpy (d_target_values, targetVals, numSamples * sizeof (int), cudaMemcpyHostToDevice)); /* GPU kernel */ dim3 gb(MAX_BLOCKS, 1, 1); dim3 tb(MAX_THREADS, 1, 1); /* warm up */ // kernel5 <<<gb, tb>>> (d_attr_values, d_temp_attr, d_target_values, d_output, numSamples, numClasses, 1); // cudaThreadSynchronize (); /* execute kernel */ unsigned int attrPerBlock = MAX_BLOCKS; float * h_ans = (float *) malloc (2*numRequiredAttrs*sizeof(float)); for(int iter = 0; iter < numRequiredAttrs; iter=iter+MAX_BLOCKS) { if(numRequiredAttrs - iter < MAX_BLOCKS) attrPerBlock = numRequiredAttrs - iter; // Copying max 64 attr data into CUDA CUDA_CHECK_ERROR (cudaMemcpy (d_attr_values, data_temp+iter*numSamples, attrPerBlock*numSamples * sizeof (float), cudaMemcpyHostToDevice)); kernel5 <<<gb, tb>>> (d_attr_values, d_target_values, d_output, numSamples, numClasses, numRequiredAttrs); cudaThreadSynchronize (); /* copy result back from GPU */ CUDA_CHECK_ERROR (cudaMemcpy (h_ans+iter*2, d_output, 2*attrPerBlock*sizeof (dtype), cudaMemcpyDeviceToHost)); } #if 0 kernel5 <<<gb, tb>>> (d_attr_values, d_target_values, d_output, numSamples, numClasses, numRequiredAttrs); cudaThreadSynchronize (); /* copy result back from GPU */ float * h_ans = (float *) malloc (2*numRequiredAttrs*sizeof(float)); CUDA_CHECK_ERROR (cudaMemcpy (h_ans, d_output, 2*numRequiredAttrs*sizeof (dtype), cudaMemcpyDeviceToHost)); #endif //printf("\nFinal Answer:- \n"); //for(int k = 0; k<2*numRequiredAttrs; k++) // printf(" %f ", h_ans[k]); int maxInd = -1; float max = 0; maxThreshold = -1; for(int j = 0; j<numRequiredAttrs; j++) if(h_ans[2*j]>max) { max = h_ans[2*j]; maxInd = j; maxThreshold = h_ans[2*j+1]; } if(maxInd == -1) { maxAttr = -1; maxThreshold = -1; free(h_ans); return; } maxAttr = -1; int temp = -1; for(int j = 0; j < numAttrs; j++){ if(remAttributes[j] == 0) { temp++; if(maxInd == temp) { maxAttr = j; free(h_ans); return; } } } } //device void alloc_cuda1D_float(int numSamples, int numAttrs) { CUDA_CHECK_ERROR (cudaMalloc (&d_attr_values, MAX_BLOCKS * numSamples * sizeof (float))); CUDA_CHECK_ERROR (cudaMalloc (&d_target_values, numSamples * sizeof (int))); CUDA_CHECK_ERROR (cudaMalloc (&d_output, MAX_BLOCKS * 2 * sizeof (float))); data_temp = (float *) malloc (numSamples * numAttrs * sizeof(float)); }
3a9509c2385071239363e109107ff2b5fb4c3803.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include<stdio.h> __global__ void farthestPointSampling(int batchSize, int nPoints, int outNPoints, const float * dataset, float * temp, int * indexs, float * outPoints){ if(outNPoints <= 0) return; int tid = threadIdx.x; __shared__ float outcomeDist[1024]; __shared__ int outcomeIndex[1024]; for(int i = blockIdx.x; i < batchSize; i += gridDim.x){ int addPointIndex = 0; if(tid == 0){ indexs[i * outNPoints] = addPointIndex; outPoints[(i * outNPoints) * 3] = dataset[(i * nPoints + addPointIndex) * 3]; outPoints[(i * outNPoints) * 3 + 1] = dataset[(i * nPoints + addPointIndex) * 3 + 1]; outPoints[(i * outNPoints) * 3 + 2] = dataset[(i * nPoints + addPointIndex) * 3 + 2]; } //Initialize a temporary collection used to store the intermediate //value of the distance between points for(int k = tid; k < nPoints; k += blockDim.x){ temp[i * nPoints + k] = 1e38; } __syncthreads(); //compute the longest distance for each turn for(int s = 1; s < outNPoints; s++){ float bestDist = -1; int bestIndex = 0; float x, y, z, x_, y_, z_, dist; x = dataset[i * nPoints * 3 + addPointIndex * 3]; y = dataset[i * nPoints * 3 + addPointIndex * 3 + 1]; z = dataset[i * nPoints * 3 + addPointIndex * 3 + 2]; for (int d = tid; d < nPoints; d += blockDim.x){ float priorDist = temp[i * nPoints + d]; x_ = dataset[i * nPoints * 3 + d * 3]; y_ = dataset[i * nPoints * 3 + d * 3 + 1]; z_ = dataset[i * nPoints * 3 + d * 3 + 2]; dist = (x_ - x) * (x_ - x) + (y_ - y) * (y_ - y) + (z_ - z) * (z_ - z); dist = min(dist, priorDist); //update the temporary collection if(dist != priorDist) temp[i * nPoints + d] = dist; //set the longest distance value if(dist > bestDist){ bestDist = dist; bestIndex = d; } } outcomeDist[tid] = bestDist; outcomeIndex[tid] = bestIndex; // printf("finish one turn %d, bestDist: %f, bestIndex: %d\n", threadIdx.x, bestDist, bestIndex); __syncthreads(); //merge outputs from all thread for(int stride = blockDim.x / 2; stride > 0; stride /=2 ){ if(tid < stride){ if(outcomeDist[tid] < outcomeDist[tid + stride]){ outcomeDist[tid] = outcomeDist[tid + stride]; outcomeIndex[tid] = outcomeIndex[tid + stride]; } } __syncthreads(); } addPointIndex = outcomeIndex[0]; if(tid == 0){ indexs[i * outNPoints + s] = addPointIndex; outPoints[(i * outNPoints + s) * 3] = dataset[i * nPoints * 3 + addPointIndex * 3]; outPoints[(i * outNPoints + s) * 3 + 1] = dataset[i * nPoints * 3 + addPointIndex * 3 + 1]; outPoints[(i * outNPoints + s) * 3 + 2] = dataset[i * nPoints * 3 + addPointIndex * 3 + 2]; } } } } void farthestPointSamplingLauncher(int batchSize, int nPoints, int outNPoints, const float * dataset, float * temp, int * indexs, float * outPoints){ int inputSize = sizeof(float) * batchSize * nPoints * 3; int outputSize = sizeof(float) * outNPoints * batchSize; float * datasetCuda; float * tempCuda; int * indexsCuda; // float * outPointsCuda; hipMalloc((void**)&datasetCuda, inputSize); hipMalloc((void**)&tempCuda, sizeof(float) * batchSize * nPoints); hipMalloc((void**)&indexsCuda, outputSize); // hipMalloc((void**)&outPointsCuda, outputSize * 3); hipMemcpy(datasetCuda, dataset, inputSize, hipMemcpyHostToDevice); hipMemcpy(tempCuda, temp, sizeof(float) * batchSize * nPoints, hipMemcpyHostToDevice); dim3 grid(min(batchSize, 32)); dim3 block(min(nPoints, 1024)); hipLaunchKernelGGL(( farthestPointSampling), dim3(grid), dim3(block), 0, 0, batchSize, nPoints, outNPoints, datasetCuda, tempCuda, indexsCuda, outPoints); //farthestPointSampling<<<grid, block>>>(batchSize, nPoints, outNPoints, dataset, temp, indexs); // hipMemcpy(outPoints, outPointsCuda, outputSize * 3, hipMemcpyDeviceToHost); hipMemcpy(indexs, indexsCuda, outputSize, hipMemcpyDeviceToHost); hipFree(datasetCuda); hipFree(tempCuda); hipFree(indexsCuda); } __global__ void farthestGrad(int batchSize, int nPoints, int outNPoints, const int * pointsIndexs, const float * pointsGrad, float * backGrad){ for(int i = blockIdx.x; i < batchSize; i += gridDim.x) for(int j = threadIdx.x; j < nPoints; j += blockDim.x) backGrad[(i * nPoints + j) * 3] = 0; for(int i = blockIdx.x; i < batchSize; i += gridDim.x){ for(int j = threadIdx.x; j < outNPoints; j += blockDim.x){ int index = pointsIndexs[i * outNPoints + j]; atomicAdd(&backGrad[(i * nPoints + index) * 3], pointsGrad[(i * outNPoints + j) * 3]); atomicAdd(&backGrad[(i * nPoints + index) * 3 + 1], pointsGrad[(i * outNPoints + j) * 3 + 1]); atomicAdd(&backGrad[(i * nPoints + index) * 3 + 2], pointsGrad[(i * outNPoints + j) * 3 + 2]); } } } void farthestPointSampleGrad(int batchSize, int nPoints, int outNPoints, const int * pointsIndexs, const float * pointsGrad, float * backGrad){ dim3 grid(min(batchSize, 32)); dim3 block(min(outNPoints, 1024)); hipLaunchKernelGGL(( farthestGrad), dim3(grid), dim3(block), 0, 0, batchSize, nPoints, outNPoints, pointsIndexs, pointsGrad, backGrad); }
3a9509c2385071239363e109107ff2b5fb4c3803.cu
#include<stdio.h> __global__ void farthestPointSampling(int batchSize, int nPoints, int outNPoints, const float * dataset, float * temp, int * indexs, float * outPoints){ if(outNPoints <= 0) return; int tid = threadIdx.x; __shared__ float outcomeDist[1024]; __shared__ int outcomeIndex[1024]; for(int i = blockIdx.x; i < batchSize; i += gridDim.x){ int addPointIndex = 0; if(tid == 0){ indexs[i * outNPoints] = addPointIndex; outPoints[(i * outNPoints) * 3] = dataset[(i * nPoints + addPointIndex) * 3]; outPoints[(i * outNPoints) * 3 + 1] = dataset[(i * nPoints + addPointIndex) * 3 + 1]; outPoints[(i * outNPoints) * 3 + 2] = dataset[(i * nPoints + addPointIndex) * 3 + 2]; } //Initialize a temporary collection used to store the intermediate //value of the distance between points for(int k = tid; k < nPoints; k += blockDim.x){ temp[i * nPoints + k] = 1e38; } __syncthreads(); //compute the longest distance for each turn for(int s = 1; s < outNPoints; s++){ float bestDist = -1; int bestIndex = 0; float x, y, z, x_, y_, z_, dist; x = dataset[i * nPoints * 3 + addPointIndex * 3]; y = dataset[i * nPoints * 3 + addPointIndex * 3 + 1]; z = dataset[i * nPoints * 3 + addPointIndex * 3 + 2]; for (int d = tid; d < nPoints; d += blockDim.x){ float priorDist = temp[i * nPoints + d]; x_ = dataset[i * nPoints * 3 + d * 3]; y_ = dataset[i * nPoints * 3 + d * 3 + 1]; z_ = dataset[i * nPoints * 3 + d * 3 + 2]; dist = (x_ - x) * (x_ - x) + (y_ - y) * (y_ - y) + (z_ - z) * (z_ - z); dist = min(dist, priorDist); //update the temporary collection if(dist != priorDist) temp[i * nPoints + d] = dist; //set the longest distance value if(dist > bestDist){ bestDist = dist; bestIndex = d; } } outcomeDist[tid] = bestDist; outcomeIndex[tid] = bestIndex; // printf("finish one turn %d, bestDist: %f, bestIndex: %d\n", threadIdx.x, bestDist, bestIndex); __syncthreads(); //merge outputs from all thread for(int stride = blockDim.x / 2; stride > 0; stride /=2 ){ if(tid < stride){ if(outcomeDist[tid] < outcomeDist[tid + stride]){ outcomeDist[tid] = outcomeDist[tid + stride]; outcomeIndex[tid] = outcomeIndex[tid + stride]; } } __syncthreads(); } addPointIndex = outcomeIndex[0]; if(tid == 0){ indexs[i * outNPoints + s] = addPointIndex; outPoints[(i * outNPoints + s) * 3] = dataset[i * nPoints * 3 + addPointIndex * 3]; outPoints[(i * outNPoints + s) * 3 + 1] = dataset[i * nPoints * 3 + addPointIndex * 3 + 1]; outPoints[(i * outNPoints + s) * 3 + 2] = dataset[i * nPoints * 3 + addPointIndex * 3 + 2]; } } } } void farthestPointSamplingLauncher(int batchSize, int nPoints, int outNPoints, const float * dataset, float * temp, int * indexs, float * outPoints){ int inputSize = sizeof(float) * batchSize * nPoints * 3; int outputSize = sizeof(float) * outNPoints * batchSize; float * datasetCuda; float * tempCuda; int * indexsCuda; // float * outPointsCuda; cudaMalloc((void**)&datasetCuda, inputSize); cudaMalloc((void**)&tempCuda, sizeof(float) * batchSize * nPoints); cudaMalloc((void**)&indexsCuda, outputSize); // cudaMalloc((void**)&outPointsCuda, outputSize * 3); cudaMemcpy(datasetCuda, dataset, inputSize, cudaMemcpyHostToDevice); cudaMemcpy(tempCuda, temp, sizeof(float) * batchSize * nPoints, cudaMemcpyHostToDevice); dim3 grid(min(batchSize, 32)); dim3 block(min(nPoints, 1024)); farthestPointSampling<<<grid, block>>>(batchSize, nPoints, outNPoints, datasetCuda, tempCuda, indexsCuda, outPoints); //farthestPointSampling<<<grid, block>>>(batchSize, nPoints, outNPoints, dataset, temp, indexs); // cudaMemcpy(outPoints, outPointsCuda, outputSize * 3, cudaMemcpyDeviceToHost); cudaMemcpy(indexs, indexsCuda, outputSize, cudaMemcpyDeviceToHost); cudaFree(datasetCuda); cudaFree(tempCuda); cudaFree(indexsCuda); } __global__ void farthestGrad(int batchSize, int nPoints, int outNPoints, const int * pointsIndexs, const float * pointsGrad, float * backGrad){ for(int i = blockIdx.x; i < batchSize; i += gridDim.x) for(int j = threadIdx.x; j < nPoints; j += blockDim.x) backGrad[(i * nPoints + j) * 3] = 0; for(int i = blockIdx.x; i < batchSize; i += gridDim.x){ for(int j = threadIdx.x; j < outNPoints; j += blockDim.x){ int index = pointsIndexs[i * outNPoints + j]; atomicAdd(&backGrad[(i * nPoints + index) * 3], pointsGrad[(i * outNPoints + j) * 3]); atomicAdd(&backGrad[(i * nPoints + index) * 3 + 1], pointsGrad[(i * outNPoints + j) * 3 + 1]); atomicAdd(&backGrad[(i * nPoints + index) * 3 + 2], pointsGrad[(i * outNPoints + j) * 3 + 2]); } } } void farthestPointSampleGrad(int batchSize, int nPoints, int outNPoints, const int * pointsIndexs, const float * pointsGrad, float * backGrad){ dim3 grid(min(batchSize, 32)); dim3 block(min(outNPoints, 1024)); farthestGrad<<<grid, block>>>(batchSize, nPoints, outNPoints, pointsIndexs, pointsGrad, backGrad); }
9bd8cf19e0488a9bd264d71337a4d75772facac9.hip
// !!! This is a file automatically generated by hipify!!! /*! * Copyright (c) 2020 by Contributors * \file array/cuda/spmm.cu * \brief SPMM C APIs and definitions. */ #include <dgl/array.h> #include "./spmm.cuh" #include "./ge_spmm.cuh" #include "functor.cuh" #include "../../runtime/cuda/cuda_common.h" namespace dgl { using namespace cuda; namespace aten { namespace { /*! \brief Fill the vector started from ptr of size length with val */ template <typename DType> void _Fill(DType* ptr, size_t length, DType val) { auto* thr_entry = runtime::CUDAThreadEntry::ThreadLocal(); int nt = FindNumThreads(length); int nb = (length + nt - 1) / nt; // on x-axis, no need to worry about upperbound. CUDA_KERNEL_CALL(cuda::_FillKernel, nb, nt, 0, thr_entry->stream, ptr, length, val); } } // namespace namespace cusparse { #if CUDART_VERSION < 11000 template <typename DType> hipsparseStatus_t Xcsrmm2(hipsparseHandle_t handle, hipsparseOperation_t transA, hipsparseOperation_t transB, int m, int n, int k, int nnz, const DType* alpha, const hipsparseMatDescr_t descrA, const DType* csrValA, const int* csrRowPtrA, const int* csrColIndA, const DType* B, int ldb, const DType* beta, DType* C, int ldc) { LOG(INFO) << "Not supported dtype"; return HIPSPARSE_STATUS_EXECUTION_FAILED; } template <> hipsparseStatus_t Xcsrmm2<float>(hipsparseHandle_t handle, hipsparseOperation_t transA, hipsparseOperation_t transB, int m, int n, int k, int nnz, const float* alpha, const hipsparseMatDescr_t descrA, const float* csrValA, const int* csrRowPtrA, const int* csrColIndA, const float* B, int ldb, const float* beta, float* C, int ldc) { return hipsparseScsrmm2(handle, transA, transB, m, n, k, nnz, alpha, descrA, csrValA, csrRowPtrA, csrColIndA, B, ldb, beta, C, ldc); } template <> hipsparseStatus_t Xcsrmm2<double>(hipsparseHandle_t handle, hipsparseOperation_t transA, hipsparseOperation_t transB, int m, int n, int k, int nnz, const double* alpha, const hipsparseMatDescr_t descrA, const double* csrValA, const int* csrRowPtrA, const int* csrColIndA, const double* B, int ldb, const double* beta, double* C, int ldc) { return hipsparseDcsrmm2(handle, transA, transB, m, n, k, nnz, alpha, descrA, csrValA, csrRowPtrA, csrColIndA, B, ldb, beta, C, ldc); } #endif template <typename DType> hipblasStatus_t Xgeam(hipblasHandle_t handle, hipblasOperation_t transa, hipblasOperation_t transb, int m, int n, const DType* alpha, const DType* A, int lda, const DType* beta, const DType* B, int ldb, DType* C, int ldc) { LOG(INFO) << "Not supported dtype"; return HIPBLAS_STATUS_EXECUTION_FAILED; } template <> hipblasStatus_t Xgeam<float>(hipblasHandle_t handle, hipblasOperation_t transa, hipblasOperation_t transb, int m, int n, const float* alpha, const float* A, int lda, const float* beta, const float* B, int ldb, float* C, int ldc) { return hipblasSgeam(handle, transa, transb, m, n, alpha, A, lda, beta, B, ldb, C, ldc); } template <> hipblasStatus_t Xgeam<double>(hipblasHandle_t handle, hipblasOperation_t transa, hipblasOperation_t transb, int m, int n, const double* alpha, const double* A, int lda, const double* beta, const double* B, int ldb, double* C, int ldc) { return hipblasDgeam(handle, transa, transb, m, n, alpha, A, lda, beta, B, ldb, C, ldc); } /*! Cusparse implementation of SpMM on Csr format. */ template <typename DType> void CusparseCsrmm2( const DLContext& ctx, const CSRMatrix& csr, const DType* B_data, const DType* A_data, DType* C_data, int x_length) { // We use csrmm2 to perform following operation: // C = A x B, where A is a sparse matrix in csr format, B is the dense matrix for node // feature tensor. However, since cusparse only supports column-major, while our tensor // is stored in row-major, the actual computation is: // C = trans(A x trans(B)). // Currently, we use cublasXgeam to implement transposition and allocate intermediate // workspace memory for this. const int m = csr.num_rows; const int n = x_length; const int k = csr.num_cols; const int nnz = csr.indices->shape[0]; const DType alpha = 1.0; const DType beta = 0.0; // device auto device = runtime::DeviceAPI::Get(ctx); auto* thr_entry = runtime::CUDAThreadEntry::ThreadLocal(); // allocate cusparse handle if needed if (!thr_entry->cusparse_handle) { CUSPARSE_CALL(hipsparseCreate(&(thr_entry->cusparse_handle))); } CUSPARSE_CALL(hipsparseSetStream(thr_entry->cusparse_handle, thr_entry->stream)); // all one data array DType* valptr = nullptr; if (!A_data) { valptr = static_cast<DType*>(device->AllocWorkspace(ctx, nnz * sizeof(DType))); _Fill(valptr, nnz, static_cast<DType>(1.)); } #if CUDART_VERSION >= 11000 hipsparseSpMatDescr_t matA; hipsparseDnMatDescr_t matB, matC; constexpr auto cuda_dtype = std::is_same<DType, float>::value ? HIP_R_32F: HIP_R_64F; CUSPARSE_CALL(hipsparseCreateCsr(&matA, m, k, nnz, static_cast<int32_t*>(csr.indptr->data), static_cast<int32_t*>(csr.indices->data), const_cast<DType*>(valptr? valptr : A_data), HIPSPARSE_INDEX_32I, HIPSPARSE_INDEX_32I, HIPSPARSE_INDEX_BASE_ZERO, cuda_dtype)); CUSPARSE_CALL(hipsparseCreateDnMat(&matB, k, n, n, const_cast<DType*>(B_data), cuda_dtype, HIPSPARSE_ORDER_ROW)); CUSPARSE_CALL(hipsparseCreateDnMat(&matC, m, n, n, C_data, cuda_dtype, HIPSPARSE_ORDER_ROW)); auto transA = HIPSPARSE_OPERATION_NON_TRANSPOSE; auto transB = HIPSPARSE_OPERATION_NON_TRANSPOSE; size_t workspace_size; CUSPARSE_CALL(hipsparseSpMM_bufferSize( thr_entry->cusparse_handle, transA, transB, &alpha, matA, matB, &beta, matC, cuda_dtype, CUSPARSE_SPMM_CSR_ALG2, &workspace_size)); void* workspace = device->AllocWorkspace(ctx, workspace_size); CUSPARSE_CALL(hipsparseSpMM( thr_entry->cusparse_handle, transA, transB, &alpha, matA, matB, &beta, matC, cuda_dtype, CUSPARSE_SPMM_CSR_ALG2, workspace)); device->FreeWorkspace(ctx, workspace); CUSPARSE_CALL(hipsparseDestroySpMat(matA)); CUSPARSE_CALL(hipsparseDestroyDnMat(matB)); CUSPARSE_CALL(hipsparseDestroyDnMat(matC)); #else // allocate matrix for temporary transposed output DType* trans_out = static_cast<DType*>(device->AllocWorkspace(ctx, m * n * sizeof(DType))); hipsparseMatDescr_t descr; CUSPARSE_CALL(hipsparseCreateMatDescr(&descr)); CUSPARSE_CALL(hipsparseSetMatType(descr, HIPSPARSE_MATRIX_TYPE_GENERAL)); CUSPARSE_CALL(hipsparseSetMatIndexBase(descr, HIPSPARSE_INDEX_BASE_ZERO)); CUSPARSE_CALL(Xcsrmm2<DType>( thr_entry->cusparse_handle, HIPSPARSE_OPERATION_NON_TRANSPOSE, HIPSPARSE_OPERATION_TRANSPOSE, m, n, k, nnz, &alpha, descr, (valptr)? valptr : A_data, static_cast<int32_t*>(csr.indptr->data), static_cast<int32_t*>(csr.indices->data), B_data, n, &beta, trans_out, m)); CUSPARSE_CALL(hipsparseDestroyMatDescr(descr)); // transpose the output matrix if (!thr_entry->cublas_handle) CUBLAS_CALL(hipblasCreate(&(thr_entry->cublas_handle))); CUBLAS_CALL(hipblasSetStream(thr_entry->cublas_handle, thr_entry->stream)); CUBLAS_CALL(Xgeam<DType>( thr_entry->cublas_handle, HIPBLAS_OP_T, HIPBLAS_OP_N, n, m, &alpha, trans_out, m, &beta, nullptr, n, C_data, n)); device->FreeWorkspace(ctx, trans_out); #endif if (valptr) device->FreeWorkspace(ctx, valptr); } } // namespace cusparse #define SWITCH_OP(op, Op, ...) \ do { \ if ((op) == "add") { \ typedef cuda::binary::Add<DType> Op; \ { __VA_ARGS__ } \ } else if ((op) == "sub") { \ typedef cuda::binary::Sub<DType> Op; \ { __VA_ARGS__ } \ } else if ((op) == "mul") { \ typedef cuda::binary::Mul<DType> Op; \ { __VA_ARGS__ } \ } else if ((op) == "div") { \ typedef cuda::binary::Div<DType> Op; \ { __VA_ARGS__ } \ } else if ((op) == "copy_lhs") { \ typedef cuda::binary::CopyLhs<DType> Op; \ { __VA_ARGS__ } \ } else if ((op) == "copy_rhs") { \ typedef cuda::binary::CopyRhs<DType> Op; \ { __VA_ARGS__ } \ } else { \ LOG(FATAL) << "Unsupported SpMM binary operator: " << op; \ } \ } while (0) /*! * \brief CUDA implementation of g-SpMM on Csr format. * \note use cusparse if the reduce operator is `sum` and there is * no broadcast, use dgl's kernel in other cases. */ template <int XPU, typename IdType, typename DType> void SpMMCsr(const std::string& op, const std::string& reduce, const BcastOff& bcast, const CSRMatrix& csr, NDArray ufeat, NDArray efeat, NDArray out, std::vector<NDArray> out_aux) { int64_t feat_len = bcast.out_len; bool is_scalar_efeat = efeat.NumElements() == csr.indices->shape[0]; bool use_efeat = op != "copy_lhs"; if (reduce == "sum") { if (sizeof(IdType) == 4 && op == "copy_lhs") { // cusparse int64_t x_length = 1; for (int i = 1; i < ufeat->ndim; ++i) x_length *= ufeat->shape[i]; cusparse::CusparseCsrmm2<DType>( ufeat->ctx, csr, static_cast<DType*>(ufeat->data), nullptr, static_cast<DType*>(out->data), x_length); } else if (sizeof(IdType) == 4 && op == "mul" && is_scalar_efeat) { // cusparse int64_t x_length = 1; for (int i = 1; i < ufeat->ndim; ++i) x_length *= ufeat->shape[i]; if (!IsNullArray(csr.data)) efeat = IndexSelect(efeat, csr.data); cusparse::CusparseCsrmm2<DType>( ufeat->ctx, csr, static_cast<DType*>(ufeat->data), static_cast<DType*>(efeat->data), static_cast<DType*>(out->data), x_length); } else { // general kernel SWITCH_OP(op, Op, { cuda::SpMMCsr<IdType, DType, Op, cuda::reduce::Sum<IdType, DType> >( bcast, csr, ufeat, efeat, out, NullArray(), NullArray()); }); } } else if (reduce == "max") { SWITCH_OP(op, Op, { cuda::SpMMCsr<IdType, DType, Op, cuda::reduce::Max<IdType, DType> >( bcast, csr, ufeat, efeat, out, out_aux[0], out_aux[1]); }); } else if (reduce == "min") { SWITCH_OP(op, Op, { cuda::SpMMCsr<IdType, DType, Op, cuda::reduce::Min<IdType, DType> >( bcast, csr, ufeat, efeat, out, out_aux[0], out_aux[1]); }); } else { LOG(FATAL) << "Not implemented"; } } /*! * \brief CUDA implementation of g-SpMM on Coo format. */ template <int XPU, typename IdType, typename DType> void SpMMCoo(const std::string& op, const std::string& reduce, const BcastOff& bcast, const COOMatrix& coo, NDArray ufeat, NDArray efeat, NDArray out, std::vector<NDArray> out_aux) { if (reduce == "sum") { SWITCH_OP(op, Op, { cuda::SpMMCoo<IdType, DType, Op, cuda::reduce::Sum<IdType, DType, true> > ( bcast, coo, ufeat, efeat, out, NullArray(), NullArray()); }); } else if (reduce == "max") { SWITCH_OP(op, Op, { cuda::SpMMCoo<IdType, DType, Op, cuda::reduce::Max<IdType, DType, true> > ( bcast, coo, ufeat, efeat, out, out_aux[0], out_aux[1]); }); } else if (reduce == "min") { SWITCH_OP(op, Op, { cuda::SpMMCoo<IdType, DType, Op, cuda::reduce::Min<IdType, DType, true> > ( bcast, coo, ufeat, efeat, out, out_aux[0], out_aux[1]); }); } else { LOG(FATAL) << "Not implemented"; } } template void SpMMCsr<kDLGPU, int32_t, float>( const std::string& op, const std::string& reduce, const BcastOff& bcast, const CSRMatrix& csr, NDArray ufeat, NDArray efeat, NDArray out, std::vector<NDArray> out_aux); template void SpMMCsr<kDLGPU, int64_t, float>( const std::string& op, const std::string& reduce, const BcastOff& bcast, const CSRMatrix& csr, NDArray ufeat, NDArray efeat, NDArray out, std::vector<NDArray> out_aux); template void SpMMCsr<kDLGPU, int32_t, double>( const std::string& op, const std::string& reduce, const BcastOff& bcast, const CSRMatrix& csr, NDArray ufeat, NDArray efeat, NDArray out, std::vector<NDArray> out_aux); template void SpMMCsr<kDLGPU, int64_t, double>( const std::string& op, const std::string& reduce, const BcastOff& bcast, const CSRMatrix& csr, NDArray ufeat, NDArray efeat, NDArray out, std::vector<NDArray> out_aux); template void SpMMCoo<kDLGPU, int32_t, float>( const std::string& op, const std::string& reduce, const BcastOff& bcast, const COOMatrix& coo, NDArray ufeat, NDArray efeat, NDArray out, std::vector<NDArray> out_aux); template void SpMMCoo<kDLGPU, int64_t, float>( const std::string& op, const std::string& reduce, const BcastOff& bcast, const COOMatrix& coo, NDArray ufeat, NDArray efeat, NDArray out, std::vector<NDArray> out_aux); template void SpMMCoo<kDLGPU, int32_t, double>( const std::string& op, const std::string& reduce, const BcastOff& bcast, const COOMatrix& coo, NDArray ufeat, NDArray efeat, NDArray out, std::vector<NDArray> out_aux); template void SpMMCoo<kDLGPU, int64_t, double>( const std::string& op, const std::string& reduce, const BcastOff& bcast, const COOMatrix& coo, NDArray ufeat, NDArray efeat, NDArray out, std::vector<NDArray> out_aux); } // namespace aten } // namespace dgl
9bd8cf19e0488a9bd264d71337a4d75772facac9.cu
/*! * Copyright (c) 2020 by Contributors * \file array/cuda/spmm.cu * \brief SPMM C APIs and definitions. */ #include <dgl/array.h> #include "./spmm.cuh" #include "./ge_spmm.cuh" #include "./functor.cuh" #include "../../runtime/cuda/cuda_common.h" namespace dgl { using namespace cuda; namespace aten { namespace { /*! \brief Fill the vector started from ptr of size length with val */ template <typename DType> void _Fill(DType* ptr, size_t length, DType val) { auto* thr_entry = runtime::CUDAThreadEntry::ThreadLocal(); int nt = FindNumThreads(length); int nb = (length + nt - 1) / nt; // on x-axis, no need to worry about upperbound. CUDA_KERNEL_CALL(cuda::_FillKernel, nb, nt, 0, thr_entry->stream, ptr, length, val); } } // namespace namespace cusparse { #if CUDART_VERSION < 11000 template <typename DType> cusparseStatus_t Xcsrmm2(cusparseHandle_t handle, cusparseOperation_t transA, cusparseOperation_t transB, int m, int n, int k, int nnz, const DType* alpha, const cusparseMatDescr_t descrA, const DType* csrValA, const int* csrRowPtrA, const int* csrColIndA, const DType* B, int ldb, const DType* beta, DType* C, int ldc) { LOG(INFO) << "Not supported dtype"; return CUSPARSE_STATUS_EXECUTION_FAILED; } template <> cusparseStatus_t Xcsrmm2<float>(cusparseHandle_t handle, cusparseOperation_t transA, cusparseOperation_t transB, int m, int n, int k, int nnz, const float* alpha, const cusparseMatDescr_t descrA, const float* csrValA, const int* csrRowPtrA, const int* csrColIndA, const float* B, int ldb, const float* beta, float* C, int ldc) { return cusparseScsrmm2(handle, transA, transB, m, n, k, nnz, alpha, descrA, csrValA, csrRowPtrA, csrColIndA, B, ldb, beta, C, ldc); } template <> cusparseStatus_t Xcsrmm2<double>(cusparseHandle_t handle, cusparseOperation_t transA, cusparseOperation_t transB, int m, int n, int k, int nnz, const double* alpha, const cusparseMatDescr_t descrA, const double* csrValA, const int* csrRowPtrA, const int* csrColIndA, const double* B, int ldb, const double* beta, double* C, int ldc) { return cusparseDcsrmm2(handle, transA, transB, m, n, k, nnz, alpha, descrA, csrValA, csrRowPtrA, csrColIndA, B, ldb, beta, C, ldc); } #endif template <typename DType> cublasStatus_t Xgeam(cublasHandle_t handle, cublasOperation_t transa, cublasOperation_t transb, int m, int n, const DType* alpha, const DType* A, int lda, const DType* beta, const DType* B, int ldb, DType* C, int ldc) { LOG(INFO) << "Not supported dtype"; return CUBLAS_STATUS_EXECUTION_FAILED; } template <> cublasStatus_t Xgeam<float>(cublasHandle_t handle, cublasOperation_t transa, cublasOperation_t transb, int m, int n, const float* alpha, const float* A, int lda, const float* beta, const float* B, int ldb, float* C, int ldc) { return cublasSgeam(handle, transa, transb, m, n, alpha, A, lda, beta, B, ldb, C, ldc); } template <> cublasStatus_t Xgeam<double>(cublasHandle_t handle, cublasOperation_t transa, cublasOperation_t transb, int m, int n, const double* alpha, const double* A, int lda, const double* beta, const double* B, int ldb, double* C, int ldc) { return cublasDgeam(handle, transa, transb, m, n, alpha, A, lda, beta, B, ldb, C, ldc); } /*! Cusparse implementation of SpMM on Csr format. */ template <typename DType> void CusparseCsrmm2( const DLContext& ctx, const CSRMatrix& csr, const DType* B_data, const DType* A_data, DType* C_data, int x_length) { // We use csrmm2 to perform following operation: // C = A x B, where A is a sparse matrix in csr format, B is the dense matrix for node // feature tensor. However, since cusparse only supports column-major, while our tensor // is stored in row-major, the actual computation is: // C = trans(A x trans(B)). // Currently, we use cublasXgeam to implement transposition and allocate intermediate // workspace memory for this. const int m = csr.num_rows; const int n = x_length; const int k = csr.num_cols; const int nnz = csr.indices->shape[0]; const DType alpha = 1.0; const DType beta = 0.0; // device auto device = runtime::DeviceAPI::Get(ctx); auto* thr_entry = runtime::CUDAThreadEntry::ThreadLocal(); // allocate cusparse handle if needed if (!thr_entry->cusparse_handle) { CUSPARSE_CALL(cusparseCreate(&(thr_entry->cusparse_handle))); } CUSPARSE_CALL(cusparseSetStream(thr_entry->cusparse_handle, thr_entry->stream)); // all one data array DType* valptr = nullptr; if (!A_data) { valptr = static_cast<DType*>(device->AllocWorkspace(ctx, nnz * sizeof(DType))); _Fill(valptr, nnz, static_cast<DType>(1.)); } #if CUDART_VERSION >= 11000 cusparseSpMatDescr_t matA; cusparseDnMatDescr_t matB, matC; constexpr auto cuda_dtype = std::is_same<DType, float>::value ? CUDA_R_32F: CUDA_R_64F; CUSPARSE_CALL(cusparseCreateCsr(&matA, m, k, nnz, static_cast<int32_t*>(csr.indptr->data), static_cast<int32_t*>(csr.indices->data), const_cast<DType*>(valptr? valptr : A_data), CUSPARSE_INDEX_32I, CUSPARSE_INDEX_32I, CUSPARSE_INDEX_BASE_ZERO, cuda_dtype)); CUSPARSE_CALL(cusparseCreateDnMat(&matB, k, n, n, const_cast<DType*>(B_data), cuda_dtype, CUSPARSE_ORDER_ROW)); CUSPARSE_CALL(cusparseCreateDnMat(&matC, m, n, n, C_data, cuda_dtype, CUSPARSE_ORDER_ROW)); auto transA = CUSPARSE_OPERATION_NON_TRANSPOSE; auto transB = CUSPARSE_OPERATION_NON_TRANSPOSE; size_t workspace_size; CUSPARSE_CALL(cusparseSpMM_bufferSize( thr_entry->cusparse_handle, transA, transB, &alpha, matA, matB, &beta, matC, cuda_dtype, CUSPARSE_SPMM_CSR_ALG2, &workspace_size)); void* workspace = device->AllocWorkspace(ctx, workspace_size); CUSPARSE_CALL(cusparseSpMM( thr_entry->cusparse_handle, transA, transB, &alpha, matA, matB, &beta, matC, cuda_dtype, CUSPARSE_SPMM_CSR_ALG2, workspace)); device->FreeWorkspace(ctx, workspace); CUSPARSE_CALL(cusparseDestroySpMat(matA)); CUSPARSE_CALL(cusparseDestroyDnMat(matB)); CUSPARSE_CALL(cusparseDestroyDnMat(matC)); #else // allocate matrix for temporary transposed output DType* trans_out = static_cast<DType*>(device->AllocWorkspace(ctx, m * n * sizeof(DType))); cusparseMatDescr_t descr; CUSPARSE_CALL(cusparseCreateMatDescr(&descr)); CUSPARSE_CALL(cusparseSetMatType(descr, CUSPARSE_MATRIX_TYPE_GENERAL)); CUSPARSE_CALL(cusparseSetMatIndexBase(descr, CUSPARSE_INDEX_BASE_ZERO)); CUSPARSE_CALL(Xcsrmm2<DType>( thr_entry->cusparse_handle, CUSPARSE_OPERATION_NON_TRANSPOSE, CUSPARSE_OPERATION_TRANSPOSE, m, n, k, nnz, &alpha, descr, (valptr)? valptr : A_data, static_cast<int32_t*>(csr.indptr->data), static_cast<int32_t*>(csr.indices->data), B_data, n, &beta, trans_out, m)); CUSPARSE_CALL(cusparseDestroyMatDescr(descr)); // transpose the output matrix if (!thr_entry->cublas_handle) CUBLAS_CALL(cublasCreate(&(thr_entry->cublas_handle))); CUBLAS_CALL(cublasSetStream(thr_entry->cublas_handle, thr_entry->stream)); CUBLAS_CALL(Xgeam<DType>( thr_entry->cublas_handle, CUBLAS_OP_T, CUBLAS_OP_N, n, m, &alpha, trans_out, m, &beta, nullptr, n, C_data, n)); device->FreeWorkspace(ctx, trans_out); #endif if (valptr) device->FreeWorkspace(ctx, valptr); } } // namespace cusparse #define SWITCH_OP(op, Op, ...) \ do { \ if ((op) == "add") { \ typedef cuda::binary::Add<DType> Op; \ { __VA_ARGS__ } \ } else if ((op) == "sub") { \ typedef cuda::binary::Sub<DType> Op; \ { __VA_ARGS__ } \ } else if ((op) == "mul") { \ typedef cuda::binary::Mul<DType> Op; \ { __VA_ARGS__ } \ } else if ((op) == "div") { \ typedef cuda::binary::Div<DType> Op; \ { __VA_ARGS__ } \ } else if ((op) == "copy_lhs") { \ typedef cuda::binary::CopyLhs<DType> Op; \ { __VA_ARGS__ } \ } else if ((op) == "copy_rhs") { \ typedef cuda::binary::CopyRhs<DType> Op; \ { __VA_ARGS__ } \ } else { \ LOG(FATAL) << "Unsupported SpMM binary operator: " << op; \ } \ } while (0) /*! * \brief CUDA implementation of g-SpMM on Csr format. * \note use cusparse if the reduce operator is `sum` and there is * no broadcast, use dgl's kernel in other cases. */ template <int XPU, typename IdType, typename DType> void SpMMCsr(const std::string& op, const std::string& reduce, const BcastOff& bcast, const CSRMatrix& csr, NDArray ufeat, NDArray efeat, NDArray out, std::vector<NDArray> out_aux) { int64_t feat_len = bcast.out_len; bool is_scalar_efeat = efeat.NumElements() == csr.indices->shape[0]; bool use_efeat = op != "copy_lhs"; if (reduce == "sum") { if (sizeof(IdType) == 4 && op == "copy_lhs") { // cusparse int64_t x_length = 1; for (int i = 1; i < ufeat->ndim; ++i) x_length *= ufeat->shape[i]; cusparse::CusparseCsrmm2<DType>( ufeat->ctx, csr, static_cast<DType*>(ufeat->data), nullptr, static_cast<DType*>(out->data), x_length); } else if (sizeof(IdType) == 4 && op == "mul" && is_scalar_efeat) { // cusparse int64_t x_length = 1; for (int i = 1; i < ufeat->ndim; ++i) x_length *= ufeat->shape[i]; if (!IsNullArray(csr.data)) efeat = IndexSelect(efeat, csr.data); cusparse::CusparseCsrmm2<DType>( ufeat->ctx, csr, static_cast<DType*>(ufeat->data), static_cast<DType*>(efeat->data), static_cast<DType*>(out->data), x_length); } else { // general kernel SWITCH_OP(op, Op, { cuda::SpMMCsr<IdType, DType, Op, cuda::reduce::Sum<IdType, DType> >( bcast, csr, ufeat, efeat, out, NullArray(), NullArray()); }); } } else if (reduce == "max") { SWITCH_OP(op, Op, { cuda::SpMMCsr<IdType, DType, Op, cuda::reduce::Max<IdType, DType> >( bcast, csr, ufeat, efeat, out, out_aux[0], out_aux[1]); }); } else if (reduce == "min") { SWITCH_OP(op, Op, { cuda::SpMMCsr<IdType, DType, Op, cuda::reduce::Min<IdType, DType> >( bcast, csr, ufeat, efeat, out, out_aux[0], out_aux[1]); }); } else { LOG(FATAL) << "Not implemented"; } } /*! * \brief CUDA implementation of g-SpMM on Coo format. */ template <int XPU, typename IdType, typename DType> void SpMMCoo(const std::string& op, const std::string& reduce, const BcastOff& bcast, const COOMatrix& coo, NDArray ufeat, NDArray efeat, NDArray out, std::vector<NDArray> out_aux) { if (reduce == "sum") { SWITCH_OP(op, Op, { cuda::SpMMCoo<IdType, DType, Op, cuda::reduce::Sum<IdType, DType, true> > ( bcast, coo, ufeat, efeat, out, NullArray(), NullArray()); }); } else if (reduce == "max") { SWITCH_OP(op, Op, { cuda::SpMMCoo<IdType, DType, Op, cuda::reduce::Max<IdType, DType, true> > ( bcast, coo, ufeat, efeat, out, out_aux[0], out_aux[1]); }); } else if (reduce == "min") { SWITCH_OP(op, Op, { cuda::SpMMCoo<IdType, DType, Op, cuda::reduce::Min<IdType, DType, true> > ( bcast, coo, ufeat, efeat, out, out_aux[0], out_aux[1]); }); } else { LOG(FATAL) << "Not implemented"; } } template void SpMMCsr<kDLGPU, int32_t, float>( const std::string& op, const std::string& reduce, const BcastOff& bcast, const CSRMatrix& csr, NDArray ufeat, NDArray efeat, NDArray out, std::vector<NDArray> out_aux); template void SpMMCsr<kDLGPU, int64_t, float>( const std::string& op, const std::string& reduce, const BcastOff& bcast, const CSRMatrix& csr, NDArray ufeat, NDArray efeat, NDArray out, std::vector<NDArray> out_aux); template void SpMMCsr<kDLGPU, int32_t, double>( const std::string& op, const std::string& reduce, const BcastOff& bcast, const CSRMatrix& csr, NDArray ufeat, NDArray efeat, NDArray out, std::vector<NDArray> out_aux); template void SpMMCsr<kDLGPU, int64_t, double>( const std::string& op, const std::string& reduce, const BcastOff& bcast, const CSRMatrix& csr, NDArray ufeat, NDArray efeat, NDArray out, std::vector<NDArray> out_aux); template void SpMMCoo<kDLGPU, int32_t, float>( const std::string& op, const std::string& reduce, const BcastOff& bcast, const COOMatrix& coo, NDArray ufeat, NDArray efeat, NDArray out, std::vector<NDArray> out_aux); template void SpMMCoo<kDLGPU, int64_t, float>( const std::string& op, const std::string& reduce, const BcastOff& bcast, const COOMatrix& coo, NDArray ufeat, NDArray efeat, NDArray out, std::vector<NDArray> out_aux); template void SpMMCoo<kDLGPU, int32_t, double>( const std::string& op, const std::string& reduce, const BcastOff& bcast, const COOMatrix& coo, NDArray ufeat, NDArray efeat, NDArray out, std::vector<NDArray> out_aux); template void SpMMCoo<kDLGPU, int64_t, double>( const std::string& op, const std::string& reduce, const BcastOff& bcast, const COOMatrix& coo, NDArray ufeat, NDArray efeat, NDArray out, std::vector<NDArray> out_aux); } // namespace aten } // namespace dgl
d59e0a2e6f18197e97096ec3283f843045029e4a.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include "../common.h" #define DIM 128 __global__ void reduceGmem(int *g_idata, int *g_odata, unsigned int n) { unsigned int tid = threadIdx.x; unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x; int *idata = g_idata + blockIdx.x * blockDim.x; if (idx >= n) return; if (blockDim.x >= 1024 && tid < 512) idata[tid] += idata[tid + 512]; __syncthreads(); if (blockDim.x >= 512 && tid < 256) idata[tid] += idata[tid + 256]; __syncthreads(); if (blockDim.x >= 256 && tid < 128) idata[tid] += idata[tid + 128]; __syncthreads(); if (blockDim.x >=128 && tid < 64) idata[tid] += idata[tid + 64]; __syncthreads(); if (tid < 32) { volatile int *vmem = idata; vmem[tid] += vmem[tid + 32]; vmem[tid] += vmem[tid + 16]; vmem[tid] += vmem[tid + 8]; vmem[tid] += vmem[tid + 4]; vmem[tid] += vmem[tid + 2]; vmem[tid] += vmem[tid + 1]; } if (tid == 0) g_odata[blockIdx.x] = idata[0]; } __global__ void reduceSmem(int *g_idata, int *g_odata, unsigned int n) { __shared__ int smem[DIM]; unsigned int tid = threadIdx.x; unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x; if (idx > n) return; int *idata = g_idata + blockIdx.x * blockDim.x; smem[tid] = idata[tid]; __syncthreads(); if (blockDim.x >= 1024 && tid < 512) smem[tid] += smem[tid+512]; __syncthreads(); if (blockDim.x >= 512 && tid < 256) smem[tid] += smem[tid+256]; __syncthreads(); if (blockDim.x >= 256 && tid < 128) smem[tid] += smem[tid+128]; __syncthreads(); if (blockDim.x >= 128 && tid < 64) smem[tid] += smem[tid+64]; __syncthreads(); if (tid < 32) { volatile int *vsmem = smem; vsmem[tid] += vsmem[tid + 32]; vsmem[tid] += vsmem[tid + 16]; vsmem[tid] += vsmem[tid + 8]; vsmem[tid] += vsmem[tid + 4]; vsmem[tid] += vsmem[tid + 2]; vsmem[tid] += vsmem[tid + 1]; } if (tid == 0) g_odata[blockIdx.x] = smem[0]; } __global__ void reduceSmemUnroll(int *g_idata, int *g_odata, unsigned int n) { __shared__ int smem[DIM]; unsigned int tid = threadIdx.x; unsigned int idx = blockIdx.x * blockDim.x * 4 + threadIdx.x; int tmpSum = 0; if (idx + 3 * blockDim.x <= n) { int a1 = g_idata[idx]; int a2 = g_idata[idx + blockDim.x]; int a3 = g_idata[idx + 2 * blockDim.x]; int a4 = g_idata[idx + 3 * blockDim.x]; tmpSum = a1 + a2 + a3 + a4; } smem[tid] = tmpSum; __syncthreads(); if (blockDim.x >= 1024 && tid < 512) smem[tid] += smem[tid+512]; __syncthreads(); if (blockDim.x >= 512 && tid < 256) smem[tid] += smem[tid+256]; __syncthreads(); if (blockDim.x >= 256 && tid < 128) smem[tid] += smem[tid+128]; __syncthreads(); if (blockDim.x >= 128 && tid < 64) smem[tid] += smem[tid+64]; __syncthreads(); if (tid < 32) { volatile int *vsmem = smem; vsmem[tid] += vsmem[tid + 32]; vsmem[tid] += vsmem[tid + 16]; vsmem[tid] += vsmem[tid + 8]; vsmem[tid] += vsmem[tid + 4]; vsmem[tid] += vsmem[tid + 2]; vsmem[tid] += vsmem[tid + 1]; } if (tid == 0) g_odata[blockIdx.x] = smem[0]; } __global__ void reduceSmemUnrollDyn(int *g_idata, int *g_odata, unsigned int n) { extern __shared__ int smem[]; unsigned int tid = threadIdx.x; unsigned int idx = blockIdx.x * blockDim.x * 4 + threadIdx.x; int tmpSum = 0; if (idx + 3 * blockDim.x <= n) { int a1 = g_idata[idx]; int a2 = g_idata[idx + blockDim.x]; int a3 = g_idata[idx + 2 * blockDim.x]; int a4 = g_idata[idx + 3 * blockDim.x]; tmpSum = a1 + a2 + a3 + a4; } smem[tid] = tmpSum; __syncthreads(); if (blockDim.x >= 1024 && tid < 512) smem[tid] += smem[tid+512]; __syncthreads(); if (blockDim.x >= 512 && tid < 256) smem[tid] += smem[tid+256]; __syncthreads(); if (blockDim.x >= 256 && tid < 128) smem[tid] += smem[tid+128]; __syncthreads(); if (blockDim.x >= 128 && tid < 64) smem[tid] += smem[tid+64]; __syncthreads(); if (tid < 32) { volatile int *vsmem = smem; vsmem[tid] += vsmem[tid + 32]; vsmem[tid] += vsmem[tid + 16]; vsmem[tid] += vsmem[tid + 8]; vsmem[tid] += vsmem[tid + 4]; vsmem[tid] += vsmem[tid + 2]; vsmem[tid] += vsmem[tid + 1]; } if (tid == 0) g_odata[blockIdx.x] = smem[0]; } int recursiveReduce(int *data, int const size) { if (size == 1) return data[0]; int const stride = size / 2; for (int i = 0; i < stride; i++) { data[i] += data[i+stride]; } return recursiveReduce(data, stride); } int main(int argc, char** argv) { int dev = 0; hipDeviceProp_t deviceProp; hipGetDeviceProperties(&deviceProp, dev); printf("%s starting reduction at ", argv[0]); printf("device %d: %s ", dev, deviceProp.name); hipSetDevice(dev); int size = 1 << 20; printf(" with array size %d ", size); int blocksize = DIM; if (argc > 1) { blocksize = atoi(argv[1]); } dim3 block(blocksize, 1); dim3 grid((size + block.x - 1) / block.x); printf("grid %d block %d\n", grid.x, block.x); size_t bytes = size * sizeof(int); int *h_idata = (int*)malloc(bytes); int *h_odata = (int*)malloc(grid.x * sizeof(int)); int *tmp = (int*)malloc(bytes); for (int i = 0; i < size; i++) { srand((unsigned)time(NULL)); h_idata[i] = (int)(rand() % 0xFF); //h_idata[i] = 2; } memcpy(tmp, h_idata, bytes); double iStart, iElaps; int gpu_sum = 0; int *d_idata = NULL; int *d_odata = NULL; CHECK(hipMalloc(&d_idata, bytes)); CHECK(hipMalloc(&d_odata, grid.x * sizeof(int))); iStart = cpuSecond(); int cpu_sum = recursiveReduce(tmp, size); iElaps = cpuSecond() - iStart; printf("cpu reduce elapsed: %f s, cpu_sum: %d\n", iElaps, cpu_sum); CHECK(hipMemcpy(d_idata, h_idata, bytes, hipMemcpyHostToDevice)); iStart = cpuSecond(); hipLaunchKernelGGL(( reduceGmem), dim3(grid), dim3(block), 0, 0, d_idata, d_odata, size); hipDeviceSynchronize(); iElaps = cpuSecond() - iStart; CHECK(hipMemcpy(h_odata, d_odata, grid.x * sizeof(int), hipMemcpyDeviceToHost)); for (int i=0; i<grid.x; i++) { gpu_sum += h_odata[i]; } printf("gpu reduce Gmem elapsed: %f s, gpu_sum: %d\n", iElaps, gpu_sum); CHECK(hipMemcpy(d_idata, h_idata, bytes, hipMemcpyHostToDevice)); iStart = cpuSecond(); hipLaunchKernelGGL(( reduceSmem), dim3(grid), dim3(block), 0, 0, d_idata, d_odata, size); hipDeviceSynchronize(); iElaps = cpuSecond() - iStart; CHECK(hipMemcpy(h_odata, d_odata, grid.x * sizeof(int), hipMemcpyDeviceToHost)); gpu_sum = 0; for (int i=0; i<grid.x; i++) { gpu_sum += h_odata[i]; } printf("gpu reduce Smem elapsed: %f s, gpu_sum: %d\n", iElaps, gpu_sum); CHECK(hipMemcpy(d_idata, h_idata, bytes, hipMemcpyHostToDevice)); iStart = cpuSecond(); hipLaunchKernelGGL(( reduceSmemUnroll), dim3(grid.x / 4), dim3(block), 0, 0, d_idata, d_odata, size); hipDeviceSynchronize(); iElaps = cpuSecond() - iStart; CHECK(hipMemcpy(h_odata, d_odata, grid.x * sizeof(int), hipMemcpyDeviceToHost)); gpu_sum = 0; for (int i=0; i<grid.x; i++) { gpu_sum += h_odata[i]; } printf("gpu reduce Smem Unroll elapsed: %f s, gpu_sum: %d\n", iElaps, gpu_sum); CHECK(hipMemcpy(d_idata, h_idata, bytes, hipMemcpyHostToDevice)); iStart = cpuSecond(); hipLaunchKernelGGL(( reduceSmemUnrollDyn), dim3(grid.x / 4), dim3(block), DIM * sizeof(int), 0, d_idata, d_odata, size); hipDeviceSynchronize(); iElaps = cpuSecond() - iStart; CHECK(hipMemcpy(h_odata, d_odata, grid.x * sizeof(int), hipMemcpyDeviceToHost)); gpu_sum = 0; for (int i=0; i<grid.x; i++) { gpu_sum += h_odata[i]; } printf("gpu reduce Smem Unroll Dynamic elapsed: %f s, gpu_sum: %d\n", iElaps, gpu_sum); }
d59e0a2e6f18197e97096ec3283f843045029e4a.cu
#include "../common.h" #define DIM 128 __global__ void reduceGmem(int *g_idata, int *g_odata, unsigned int n) { unsigned int tid = threadIdx.x; unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x; int *idata = g_idata + blockIdx.x * blockDim.x; if (idx >= n) return; if (blockDim.x >= 1024 && tid < 512) idata[tid] += idata[tid + 512]; __syncthreads(); if (blockDim.x >= 512 && tid < 256) idata[tid] += idata[tid + 256]; __syncthreads(); if (blockDim.x >= 256 && tid < 128) idata[tid] += idata[tid + 128]; __syncthreads(); if (blockDim.x >=128 && tid < 64) idata[tid] += idata[tid + 64]; __syncthreads(); if (tid < 32) { volatile int *vmem = idata; vmem[tid] += vmem[tid + 32]; vmem[tid] += vmem[tid + 16]; vmem[tid] += vmem[tid + 8]; vmem[tid] += vmem[tid + 4]; vmem[tid] += vmem[tid + 2]; vmem[tid] += vmem[tid + 1]; } if (tid == 0) g_odata[blockIdx.x] = idata[0]; } __global__ void reduceSmem(int *g_idata, int *g_odata, unsigned int n) { __shared__ int smem[DIM]; unsigned int tid = threadIdx.x; unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x; if (idx > n) return; int *idata = g_idata + blockIdx.x * blockDim.x; smem[tid] = idata[tid]; __syncthreads(); if (blockDim.x >= 1024 && tid < 512) smem[tid] += smem[tid+512]; __syncthreads(); if (blockDim.x >= 512 && tid < 256) smem[tid] += smem[tid+256]; __syncthreads(); if (blockDim.x >= 256 && tid < 128) smem[tid] += smem[tid+128]; __syncthreads(); if (blockDim.x >= 128 && tid < 64) smem[tid] += smem[tid+64]; __syncthreads(); if (tid < 32) { volatile int *vsmem = smem; vsmem[tid] += vsmem[tid + 32]; vsmem[tid] += vsmem[tid + 16]; vsmem[tid] += vsmem[tid + 8]; vsmem[tid] += vsmem[tid + 4]; vsmem[tid] += vsmem[tid + 2]; vsmem[tid] += vsmem[tid + 1]; } if (tid == 0) g_odata[blockIdx.x] = smem[0]; } __global__ void reduceSmemUnroll(int *g_idata, int *g_odata, unsigned int n) { __shared__ int smem[DIM]; unsigned int tid = threadIdx.x; unsigned int idx = blockIdx.x * blockDim.x * 4 + threadIdx.x; int tmpSum = 0; if (idx + 3 * blockDim.x <= n) { int a1 = g_idata[idx]; int a2 = g_idata[idx + blockDim.x]; int a3 = g_idata[idx + 2 * blockDim.x]; int a4 = g_idata[idx + 3 * blockDim.x]; tmpSum = a1 + a2 + a3 + a4; } smem[tid] = tmpSum; __syncthreads(); if (blockDim.x >= 1024 && tid < 512) smem[tid] += smem[tid+512]; __syncthreads(); if (blockDim.x >= 512 && tid < 256) smem[tid] += smem[tid+256]; __syncthreads(); if (blockDim.x >= 256 && tid < 128) smem[tid] += smem[tid+128]; __syncthreads(); if (blockDim.x >= 128 && tid < 64) smem[tid] += smem[tid+64]; __syncthreads(); if (tid < 32) { volatile int *vsmem = smem; vsmem[tid] += vsmem[tid + 32]; vsmem[tid] += vsmem[tid + 16]; vsmem[tid] += vsmem[tid + 8]; vsmem[tid] += vsmem[tid + 4]; vsmem[tid] += vsmem[tid + 2]; vsmem[tid] += vsmem[tid + 1]; } if (tid == 0) g_odata[blockIdx.x] = smem[0]; } __global__ void reduceSmemUnrollDyn(int *g_idata, int *g_odata, unsigned int n) { extern __shared__ int smem[]; unsigned int tid = threadIdx.x; unsigned int idx = blockIdx.x * blockDim.x * 4 + threadIdx.x; int tmpSum = 0; if (idx + 3 * blockDim.x <= n) { int a1 = g_idata[idx]; int a2 = g_idata[idx + blockDim.x]; int a3 = g_idata[idx + 2 * blockDim.x]; int a4 = g_idata[idx + 3 * blockDim.x]; tmpSum = a1 + a2 + a3 + a4; } smem[tid] = tmpSum; __syncthreads(); if (blockDim.x >= 1024 && tid < 512) smem[tid] += smem[tid+512]; __syncthreads(); if (blockDim.x >= 512 && tid < 256) smem[tid] += smem[tid+256]; __syncthreads(); if (blockDim.x >= 256 && tid < 128) smem[tid] += smem[tid+128]; __syncthreads(); if (blockDim.x >= 128 && tid < 64) smem[tid] += smem[tid+64]; __syncthreads(); if (tid < 32) { volatile int *vsmem = smem; vsmem[tid] += vsmem[tid + 32]; vsmem[tid] += vsmem[tid + 16]; vsmem[tid] += vsmem[tid + 8]; vsmem[tid] += vsmem[tid + 4]; vsmem[tid] += vsmem[tid + 2]; vsmem[tid] += vsmem[tid + 1]; } if (tid == 0) g_odata[blockIdx.x] = smem[0]; } int recursiveReduce(int *data, int const size) { if (size == 1) return data[0]; int const stride = size / 2; for (int i = 0; i < stride; i++) { data[i] += data[i+stride]; } return recursiveReduce(data, stride); } int main(int argc, char** argv) { int dev = 0; cudaDeviceProp deviceProp; cudaGetDeviceProperties(&deviceProp, dev); printf("%s starting reduction at ", argv[0]); printf("device %d: %s ", dev, deviceProp.name); cudaSetDevice(dev); int size = 1 << 20; printf(" with array size %d ", size); int blocksize = DIM; if (argc > 1) { blocksize = atoi(argv[1]); } dim3 block(blocksize, 1); dim3 grid((size + block.x - 1) / block.x); printf("grid %d block %d\n", grid.x, block.x); size_t bytes = size * sizeof(int); int *h_idata = (int*)malloc(bytes); int *h_odata = (int*)malloc(grid.x * sizeof(int)); int *tmp = (int*)malloc(bytes); for (int i = 0; i < size; i++) { srand((unsigned)time(NULL)); h_idata[i] = (int)(rand() % 0xFF); //h_idata[i] = 2; } memcpy(tmp, h_idata, bytes); double iStart, iElaps; int gpu_sum = 0; int *d_idata = NULL; int *d_odata = NULL; CHECK(cudaMalloc(&d_idata, bytes)); CHECK(cudaMalloc(&d_odata, grid.x * sizeof(int))); iStart = cpuSecond(); int cpu_sum = recursiveReduce(tmp, size); iElaps = cpuSecond() - iStart; printf("cpu reduce elapsed: %f s, cpu_sum: %d\n", iElaps, cpu_sum); CHECK(cudaMemcpy(d_idata, h_idata, bytes, cudaMemcpyHostToDevice)); iStart = cpuSecond(); reduceGmem<<<grid, block>>>(d_idata, d_odata, size); cudaDeviceSynchronize(); iElaps = cpuSecond() - iStart; CHECK(cudaMemcpy(h_odata, d_odata, grid.x * sizeof(int), cudaMemcpyDeviceToHost)); for (int i=0; i<grid.x; i++) { gpu_sum += h_odata[i]; } printf("gpu reduce Gmem elapsed: %f s, gpu_sum: %d\n", iElaps, gpu_sum); CHECK(cudaMemcpy(d_idata, h_idata, bytes, cudaMemcpyHostToDevice)); iStart = cpuSecond(); reduceSmem<<<grid, block>>>(d_idata, d_odata, size); cudaDeviceSynchronize(); iElaps = cpuSecond() - iStart; CHECK(cudaMemcpy(h_odata, d_odata, grid.x * sizeof(int), cudaMemcpyDeviceToHost)); gpu_sum = 0; for (int i=0; i<grid.x; i++) { gpu_sum += h_odata[i]; } printf("gpu reduce Smem elapsed: %f s, gpu_sum: %d\n", iElaps, gpu_sum); CHECK(cudaMemcpy(d_idata, h_idata, bytes, cudaMemcpyHostToDevice)); iStart = cpuSecond(); reduceSmemUnroll<<<grid.x / 4, block>>>(d_idata, d_odata, size); cudaDeviceSynchronize(); iElaps = cpuSecond() - iStart; CHECK(cudaMemcpy(h_odata, d_odata, grid.x * sizeof(int), cudaMemcpyDeviceToHost)); gpu_sum = 0; for (int i=0; i<grid.x; i++) { gpu_sum += h_odata[i]; } printf("gpu reduce Smem Unroll elapsed: %f s, gpu_sum: %d\n", iElaps, gpu_sum); CHECK(cudaMemcpy(d_idata, h_idata, bytes, cudaMemcpyHostToDevice)); iStart = cpuSecond(); reduceSmemUnrollDyn<<<grid.x / 4, block, DIM * sizeof(int)>>>(d_idata, d_odata, size); cudaDeviceSynchronize(); iElaps = cpuSecond() - iStart; CHECK(cudaMemcpy(h_odata, d_odata, grid.x * sizeof(int), cudaMemcpyDeviceToHost)); gpu_sum = 0; for (int i=0; i<grid.x; i++) { gpu_sum += h_odata[i]; } printf("gpu reduce Smem Unroll Dynamic elapsed: %f s, gpu_sum: %d\n", iElaps, gpu_sum); }
16f0c357b629a303956b24f307052dd11c46371c.hip
// !!! This is a file automatically generated by hipify!!! #include <stdio.h> #include <iostream> #include <hip/hip_runtime_api.h> //#include <cutil.h> #include <hip/hip_runtime.h> #include <string> #define GPUJOULE_DIR "" #define SHARED_MEM_ELEMENTS 1024 #define GLOBAL_MEM_ELEMENTS 195840 int num_blocks; int num_threads_per_block; int num_iterations; int divergence; float* h_A; float* h_B; float* h_C; float* h_res; float* d_A; float* d_B; float* d_C; float* d_res; __global__ void init_memory (unsigned long long ** my_ptr_array, unsigned long long * my_array, int stride, int num_blocks_k, int num_threads_per_block_k) { int block_id; int warp_id; int i; int index; int tid = blockDim.x * blockIdx.x + threadIdx.x; void **ptr_array = (void **)my_ptr_array; unsigned long long *array = (unsigned long long *)my_array; if (tid == 0) { // int elements_per_block = GLOBAL_MEM_ELEMENTS / num_blocks_k; int num_warps_per_block = num_threads_per_block_k / 32; // int elements_per_warp = elements_per_block / num_warps_per_block; int elements_per_warp = GLOBAL_MEM_ELEMENTS / num_warps_per_block; // for (block_id = 0; block_id < num_blocks_k; block_id++) { for (warp_id = 0; warp_id < num_warps_per_block; warp_id++) { for (i = 0; i < elements_per_warp; i++) { // index = (block_id * elements_per_block) + (warp_id * elements_per_warp); index = (warp_id * elements_per_warp); ptr_array[index + i] = (void*)&array[(index + ((i + 48) % elements_per_warp))]; } } // } /* for (i = 0; i < GLOBAL_MEM_ELEMENTS; i++) { ptr_array[i] = (void*)&array[(i + 32)%GLOBAL_MEM_ELEMENTS]; } */ for (i = 0; i < GLOBAL_MEM_ELEMENTS; i++) { //array[i] = (unsigned long long)ptr_array[(i+stride)%GLOBAL_MEM_ELEMENTS]; array[i] = (unsigned long long)ptr_array[i]; } } __syncthreads(); } __global__ void shared_latency (unsigned long long ** my_ptr_array, unsigned long long * my_array, int array_length, int iterations, unsigned long long * duration, int stride, int divergence, int num_blocks_k, int num_threads_per_block_k) { // unsigned long long int start_time, end_time; unsigned long long int sum_time = 0; int i, k; int tid = blockDim.x * blockIdx.x + threadIdx.x; int block_id = blockIdx.x; int warp_id = threadIdx.x / 32; int warp_thread_id = threadIdx.x % 32; // int elements_per_block = GLOBAL_MEM_ELEMENTS / num_blocks_k; int num_warps_per_block = num_threads_per_block_k / 32; // int elements_per_warp = elements_per_block / num_warps_per_block; int elements_per_warp = GLOBAL_MEM_ELEMENTS / num_warps_per_block; // int index1 = (block_id * elements_per_block) + (warp_id * elements_per_warp) + warp_thread_id; int index1 = (warp_id * elements_per_warp) + warp_thread_id; void **ptr_array = (void **)my_ptr_array; unsigned long long int *array = (unsigned long long int *)my_array; void **tmp_ptr; //tmp_ptr = (void *)sdata; //tmp_ptr = (void **)(&(ptr_array[(threadIdx.x * stride)%GLOBAL_MEM_ELEMENTS])); //tmp_ptr = (void **)(&(ptr_array[(tid * stride)%GLOBAL_MEM_ELEMENTS])); //tmp_ptr = (void **)(&(ptr_array[index1])); tmp_ptr = (void **)(&(array[index1])); double f1, f2, f3; f1 = 1.1; f2 = 2.5; if (warp_thread_id < divergence) { /* __asm volatile ( ".reg .f32 %r14;\n\t" "mov.f32 %r14, 2.2;\n\t" ); */ for (int l = 0; l < iterations; l++) { tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); } } // __syncthreads(); // if ((blockDim.x * blockIdx.x + threadIdx.x) == 0) duration[tid] = (unsigned long long)(*tmp_ptr) + (f1 * tid); // __syncthreads(); } void usage() { std::cout << "Usage ./binary <num_blocks> <num_threads_per_block> <iterations>" "threads active per warp" << std::endl; } void parametric_measure_shared(int N, int iterations, int stride) { hipProfilerStop(); int i; unsigned long long int * h_a; unsigned long long int * d_a; unsigned long long ** h_ptr_a; unsigned long long ** d_ptr_a; unsigned long long * duration; unsigned long long * latency; hipError_t error_id; /* allocate array on CPU */ h_a = (unsigned long long *)malloc(sizeof(unsigned long long int) * N); h_ptr_a = (unsigned long long **)malloc(sizeof(unsigned long long int*)*N); latency = (unsigned long long *)malloc(sizeof(unsigned long long) * num_threads_per_block * num_blocks); /* initialize array elements on CPU */ for (i = 0; i < N; i++) { h_ptr_a[i] = (unsigned long long *)&h_a[i]; } for (i = 0; i < N; i++) { h_a[i] = (unsigned long long)h_ptr_a[(i + 1 + stride) % N]; } /* allocate arrays on GPU */ hipMalloc ((void **) &d_a, sizeof(unsigned long long int) * N ); hipMalloc ((void **) &d_ptr_a, sizeof(unsigned long long int*) * N ); hipMalloc ((void **) &duration, sizeof(unsigned long long) * num_threads_per_block * num_blocks); hipDeviceSynchronize (); error_id = hipGetLastError(); if (error_id != hipSuccess) { printf("Error 1 is %s\n", hipGetErrorString(error_id)); } /* copy array elements from CPU to GPU */ hipMemcpy((void *)d_a, (void *)h_a, sizeof(unsigned long long int) * N, hipMemcpyHostToDevice); hipMemcpy((void *)d_ptr_a, (void *)h_ptr_a, sizeof(unsigned long long int *) * N, hipMemcpyHostToDevice); hipMemcpy((void *)duration, (void *)latency, sizeof(unsigned long long) * num_threads_per_block * num_blocks, hipMemcpyHostToDevice); hipDeviceSynchronize (); error_id = hipGetLastError(); if (error_id != hipSuccess) { printf("Error 2 is %s\n", hipGetErrorString(error_id)); } hipLaunchKernelGGL(( init_memory) , dim3(1), dim3(1), 0, 0, d_ptr_a, d_a, stride, num_blocks, num_threads_per_block); hipDeviceSynchronize(); /* launch kernel*/ //dim3 Db = dim3(13); //dim3 Dg = dim3(768,1,1); //printf("Launch kernel with parameters: %d, N: %d, stride: %d\n", iterations, N, stride); // int sharedMemSize = sizeof(unsigned long long int) * N ; hipEvent_t start, stop; float time; hipEventCreate(&start); hipEventCreate(&stop); std::string cmd = "GPUJOULE_DIR/nvml/example/power_monitor 5 > GPUJOULE_DIR/energy_model_ubench/energy_model_data/data_movement_energy/l2_cache/fadd_l2d_50_50_64p_asm_power.txt &"; std::system(cmd.c_str()); std::system("sleep 5"); hipEventRecord(start, 0); hipProfilerStart(); hipFuncSetCacheConfig(shared_latency, hipFuncCachePreferL1); //shared_latency <<<Dg, Db, sharedMemSize>>>(d_a, N, iterations, duration); //shared_latency <<<num_blocks, num_threads_per_block, sharedMemSize>>>(d_a, N, num_iterations, duration, stride, divergence); hipLaunchKernelGGL(( shared_latency) , dim3(num_blocks), dim3(num_threads_per_block), 0, 0, d_ptr_a, d_a, N, num_iterations, duration, stride, divergence, num_blocks, num_threads_per_block); hipDeviceSynchronize(); ///hipDeviceSynchronize (); hipProfilerStop(); hipEventRecord(stop, 0); hipEventSynchronize(stop); hipEventElapsedTime(&time, start, stop); std::system("killall power_monitor"); error_id = hipGetLastError(); if (error_id != hipSuccess) { printf("Error 3 is %s\n", hipGetErrorString(error_id)); } /* copy results from GPU to CPU */ hipMemcpy((void *)h_a, (void *)d_a, sizeof(unsigned long long int) * N, hipMemcpyDeviceToHost); hipMemcpy((void *)latency, (void *)duration, sizeof(unsigned long long) * num_threads_per_block * num_blocks, hipMemcpyDeviceToHost); hipDeviceSynchronize (); /* print results*/ unsigned long long max_dur = latency[0]; unsigned long long min_dur = latency[0]; unsigned long long avg_lat = latency[0]; for (int i = 1; i < num_threads_per_block * num_blocks; i++) { avg_lat += latency[i]; if (latency[i] > max_dur) { max_dur = latency[i]; } else if (latency[i] < min_dur) { min_dur = latency[i]; } } // printf(" %d, %f, %f, %f, %f\n",stride,(double)(avg_lat/(num_threads_per_block * num_blocks * 256.0 *num_iterations)), (double)(min_dur/(256.0 * num_iterations)), (double)(max_dur/(256.0 * num_iterations)), time); printf("%f\n", time); /* free memory on GPU */ hipFree(d_a); hipFree(d_ptr_a); hipFree(duration); hipDeviceSynchronize (); /*free memory on CPU */ free(h_a); free(h_ptr_a); free(latency); } int main(int argc, char **argv) { int N; if (argc != 6) { usage(); exit(1); } num_blocks = atoi(argv[1]); num_threads_per_block = atoi(argv[2]); num_iterations = atoi(argv[3]); divergence = atoi(argv[4]); int stride = atoi(argv[5]); N = GLOBAL_MEM_ELEMENTS; parametric_measure_shared(N, 10, stride); return 0; }
16f0c357b629a303956b24f307052dd11c46371c.cu
#include <stdio.h> #include <iostream> #include <cuda_profiler_api.h> //#include <cutil.h> #include <cuda_runtime.h> #include <string> #define GPUJOULE_DIR "" #define SHARED_MEM_ELEMENTS 1024 #define GLOBAL_MEM_ELEMENTS 195840 int num_blocks; int num_threads_per_block; int num_iterations; int divergence; float* h_A; float* h_B; float* h_C; float* h_res; float* d_A; float* d_B; float* d_C; float* d_res; __global__ void init_memory (unsigned long long ** my_ptr_array, unsigned long long * my_array, int stride, int num_blocks_k, int num_threads_per_block_k) { int block_id; int warp_id; int i; int index; int tid = blockDim.x * blockIdx.x + threadIdx.x; void **ptr_array = (void **)my_ptr_array; unsigned long long *array = (unsigned long long *)my_array; if (tid == 0) { // int elements_per_block = GLOBAL_MEM_ELEMENTS / num_blocks_k; int num_warps_per_block = num_threads_per_block_k / 32; // int elements_per_warp = elements_per_block / num_warps_per_block; int elements_per_warp = GLOBAL_MEM_ELEMENTS / num_warps_per_block; // for (block_id = 0; block_id < num_blocks_k; block_id++) { for (warp_id = 0; warp_id < num_warps_per_block; warp_id++) { for (i = 0; i < elements_per_warp; i++) { // index = (block_id * elements_per_block) + (warp_id * elements_per_warp); index = (warp_id * elements_per_warp); ptr_array[index + i] = (void*)&array[(index + ((i + 48) % elements_per_warp))]; } } // } /* for (i = 0; i < GLOBAL_MEM_ELEMENTS; i++) { ptr_array[i] = (void*)&array[(i + 32)%GLOBAL_MEM_ELEMENTS]; } */ for (i = 0; i < GLOBAL_MEM_ELEMENTS; i++) { //array[i] = (unsigned long long)ptr_array[(i+stride)%GLOBAL_MEM_ELEMENTS]; array[i] = (unsigned long long)ptr_array[i]; } } __syncthreads(); } __global__ void shared_latency (unsigned long long ** my_ptr_array, unsigned long long * my_array, int array_length, int iterations, unsigned long long * duration, int stride, int divergence, int num_blocks_k, int num_threads_per_block_k) { // unsigned long long int start_time, end_time; unsigned long long int sum_time = 0; int i, k; int tid = blockDim.x * blockIdx.x + threadIdx.x; int block_id = blockIdx.x; int warp_id = threadIdx.x / 32; int warp_thread_id = threadIdx.x % 32; // int elements_per_block = GLOBAL_MEM_ELEMENTS / num_blocks_k; int num_warps_per_block = num_threads_per_block_k / 32; // int elements_per_warp = elements_per_block / num_warps_per_block; int elements_per_warp = GLOBAL_MEM_ELEMENTS / num_warps_per_block; // int index1 = (block_id * elements_per_block) + (warp_id * elements_per_warp) + warp_thread_id; int index1 = (warp_id * elements_per_warp) + warp_thread_id; void **ptr_array = (void **)my_ptr_array; unsigned long long int *array = (unsigned long long int *)my_array; void **tmp_ptr; //tmp_ptr = (void *)sdata; //tmp_ptr = (void **)(&(ptr_array[(threadIdx.x * stride)%GLOBAL_MEM_ELEMENTS])); //tmp_ptr = (void **)(&(ptr_array[(tid * stride)%GLOBAL_MEM_ELEMENTS])); //tmp_ptr = (void **)(&(ptr_array[index1])); tmp_ptr = (void **)(&(array[index1])); double f1, f2, f3; f1 = 1.1; f2 = 2.5; if (warp_thread_id < divergence) { /* __asm volatile ( ".reg .f32 %r14;\n\t" "mov.f32 %r14, 2.2;\n\t" ); */ for (int l = 0; l < iterations; l++) { tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); tmp_ptr = (void**)(*tmp_ptr); f1 = f1 + (unsigned long long)(*tmp_ptr); } } // __syncthreads(); // if ((blockDim.x * blockIdx.x + threadIdx.x) == 0) duration[tid] = (unsigned long long)(*tmp_ptr) + (f1 * tid); // __syncthreads(); } void usage() { std::cout << "Usage ./binary <num_blocks> <num_threads_per_block> <iterations>" "threads active per warp" << std::endl; } void parametric_measure_shared(int N, int iterations, int stride) { cudaProfilerStop(); int i; unsigned long long int * h_a; unsigned long long int * d_a; unsigned long long ** h_ptr_a; unsigned long long ** d_ptr_a; unsigned long long * duration; unsigned long long * latency; cudaError_t error_id; /* allocate array on CPU */ h_a = (unsigned long long *)malloc(sizeof(unsigned long long int) * N); h_ptr_a = (unsigned long long **)malloc(sizeof(unsigned long long int*)*N); latency = (unsigned long long *)malloc(sizeof(unsigned long long) * num_threads_per_block * num_blocks); /* initialize array elements on CPU */ for (i = 0; i < N; i++) { h_ptr_a[i] = (unsigned long long *)&h_a[i]; } for (i = 0; i < N; i++) { h_a[i] = (unsigned long long)h_ptr_a[(i + 1 + stride) % N]; } /* allocate arrays on GPU */ cudaMalloc ((void **) &d_a, sizeof(unsigned long long int) * N ); cudaMalloc ((void **) &d_ptr_a, sizeof(unsigned long long int*) * N ); cudaMalloc ((void **) &duration, sizeof(unsigned long long) * num_threads_per_block * num_blocks); cudaThreadSynchronize (); error_id = cudaGetLastError(); if (error_id != cudaSuccess) { printf("Error 1 is %s\n", cudaGetErrorString(error_id)); } /* copy array elements from CPU to GPU */ cudaMemcpy((void *)d_a, (void *)h_a, sizeof(unsigned long long int) * N, cudaMemcpyHostToDevice); cudaMemcpy((void *)d_ptr_a, (void *)h_ptr_a, sizeof(unsigned long long int *) * N, cudaMemcpyHostToDevice); cudaMemcpy((void *)duration, (void *)latency, sizeof(unsigned long long) * num_threads_per_block * num_blocks, cudaMemcpyHostToDevice); cudaThreadSynchronize (); error_id = cudaGetLastError(); if (error_id != cudaSuccess) { printf("Error 2 is %s\n", cudaGetErrorString(error_id)); } init_memory <<<1, 1>>>(d_ptr_a, d_a, stride, num_blocks, num_threads_per_block); cudaDeviceSynchronize(); /* launch kernel*/ //dim3 Db = dim3(13); //dim3 Dg = dim3(768,1,1); //printf("Launch kernel with parameters: %d, N: %d, stride: %d\n", iterations, N, stride); // int sharedMemSize = sizeof(unsigned long long int) * N ; cudaEvent_t start, stop; float time; cudaEventCreate(&start); cudaEventCreate(&stop); std::string cmd = "GPUJOULE_DIR/nvml/example/power_monitor 5 > GPUJOULE_DIR/energy_model_ubench/energy_model_data/data_movement_energy/l2_cache/fadd_l2d_50_50_64p_asm_power.txt &"; std::system(cmd.c_str()); std::system("sleep 5"); cudaEventRecord(start, 0); cudaProfilerStart(); cudaFuncSetCacheConfig(shared_latency, cudaFuncCachePreferL1); //shared_latency <<<Dg, Db, sharedMemSize>>>(d_a, N, iterations, duration); //shared_latency <<<num_blocks, num_threads_per_block, sharedMemSize>>>(d_a, N, num_iterations, duration, stride, divergence); shared_latency <<<num_blocks, num_threads_per_block>>>(d_ptr_a, d_a, N, num_iterations, duration, stride, divergence, num_blocks, num_threads_per_block); cudaDeviceSynchronize(); ///cudaThreadSynchronize (); cudaProfilerStop(); cudaEventRecord(stop, 0); cudaEventSynchronize(stop); cudaEventElapsedTime(&time, start, stop); std::system("killall power_monitor"); error_id = cudaGetLastError(); if (error_id != cudaSuccess) { printf("Error 3 is %s\n", cudaGetErrorString(error_id)); } /* copy results from GPU to CPU */ cudaMemcpy((void *)h_a, (void *)d_a, sizeof(unsigned long long int) * N, cudaMemcpyDeviceToHost); cudaMemcpy((void *)latency, (void *)duration, sizeof(unsigned long long) * num_threads_per_block * num_blocks, cudaMemcpyDeviceToHost); cudaThreadSynchronize (); /* print results*/ unsigned long long max_dur = latency[0]; unsigned long long min_dur = latency[0]; unsigned long long avg_lat = latency[0]; for (int i = 1; i < num_threads_per_block * num_blocks; i++) { avg_lat += latency[i]; if (latency[i] > max_dur) { max_dur = latency[i]; } else if (latency[i] < min_dur) { min_dur = latency[i]; } } // printf(" %d, %f, %f, %f, %f\n",stride,(double)(avg_lat/(num_threads_per_block * num_blocks * 256.0 *num_iterations)), (double)(min_dur/(256.0 * num_iterations)), (double)(max_dur/(256.0 * num_iterations)), time); printf("%f\n", time); /* free memory on GPU */ cudaFree(d_a); cudaFree(d_ptr_a); cudaFree(duration); cudaThreadSynchronize (); /*free memory on CPU */ free(h_a); free(h_ptr_a); free(latency); } int main(int argc, char **argv) { int N; if (argc != 6) { usage(); exit(1); } num_blocks = atoi(argv[1]); num_threads_per_block = atoi(argv[2]); num_iterations = atoi(argv[3]); divergence = atoi(argv[4]); int stride = atoi(argv[5]); N = GLOBAL_MEM_ELEMENTS; parametric_measure_shared(N, 10, stride); return 0; }
98c18459e10924dfc44c1e00e7b93740fd010121.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include "kernel_functions_cuda.h" #include <cstddef> /////////////////////////////////////////////////////////////// /// Implements the 'inner product' operation of Douglas Theobald QCP superposition method (see : http://theobald.brandeis.edu/qcp/ /// and "Rapid calculation of RMSDs using a quaternion-based characteristic polynomial." Acta Crystallogr A 61(4):478-480 /// for more info ). /// /// \param A [In/Out] A 3x3 matrix ( blank space for a real explanation of this parameter) /// \param first_conformation_coords [In] Array containing the coordinates of the reference conformation. /// \param second_conformation_coords [In] Array containing the coordinates of the conformation to be measured. /// \param number_of_atoms [In] Number of atoms of both conformations (must be the same, of course). /// /// \return The E0 parameter (upper bound for max Eigenvalue). /////////////////////////////////////////////////////////////// __device__ floating_point_type innerProduct(floating_point_type* A, floating_point_type* first_conformation_coords, floating_point_type* second_conformation_coords, const int number_of_atoms){ floating_point_type x1, x2, y1, y2, z1, z2; floating_point_type G1 = 0.0f, G2 = 0.0f; A[0] = A[1] = A[2] = A[3] = A[4] = A[5] = A[6] = A[7] = A[8] = 0.0f; int total_number_of_coordinates = 3* number_of_atoms; for (int i = 0; i < total_number_of_coordinates; i+=3){ x1 = first_conformation_coords[i]; y1 = first_conformation_coords[i+1]; z1 = first_conformation_coords[i+2]; x2 = second_conformation_coords[i]; y2 = second_conformation_coords[i+1]; z2 = second_conformation_coords[i+2]; G1 += x1 * x1 + y1 * y1 + z1 * z1; G2 += x2 * x2 + y2 * y2 + z2 * z2; A[0] += (x1 * x2); A[1] += (x1 * y2); A[2] += (x1 * z2); A[3] += (y1 * x2); A[4] += (y1 * y2); A[5] += (y1 * z2); A[6] += (z1 * x2); A[7] += (z1 * y2); A[8] += (z1 * z2); } return (G1 + G2) * 0.5; } /////////////////////////////////////////////////////////////// /// This function ports the second part of Douglas Theobald QCP superposition method (see 'innerProduct'). /// /// \param A [In] A 3x3 matrix (more ?). /// \param E0 [In] Upper bound for the maximum eigenvalue (?). /// \param number_of_atoms [In] Number of atoms of conformations used to get A and E0. /// /// \return The actual rmsd between both conformations. /////////////////////////////////////////////////////////////// __device__ floating_point_type calcRMSDForTwoConformationsWithTheobaldMethod( floating_point_type *A, const floating_point_type E0, const int number_of_atoms, floating_point_type * rot_matrix){ floating_point_type Sxx, Sxy, Sxz, Syx, Syy, Syz, Szx, Szy, Szz; floating_point_type Szz2, Syy2, Sxx2, Sxy2, Syz2, Sxz2, Syx2, Szy2, Szx2, SyzSzymSyySzz2, Sxx2Syy2Szz2Syz2Szy2, Sxy2Sxz2Syx2Szx2, SxzpSzx, SyzpSzy, SxypSyx, SyzmSzy, SxzmSzx, SxymSyx, SxxpSyy, SxxmSyy; floating_point_type C[4]; floating_point_type mxEigenV; floating_point_type b, a, delta, x2; floating_point_type oldg = 0.0f; floating_point_type evalprec = 1e-11f; Sxx = A[0]; Sxy = A[1]; Sxz = A[2]; Syx = A[3]; Syy = A[4]; Syz = A[5]; Szx = A[6]; Szy = A[7]; Szz = A[8]; Sxx2 = Sxx * Sxx; Syy2 = Syy * Syy; Szz2 = Szz * Szz; Sxy2 = Sxy * Sxy; Syz2 = Syz * Syz; Sxz2 = Sxz * Sxz; Syx2 = Syx * Syx; Szy2 = Szy * Szy; Szx2 = Szx * Szx; SyzSzymSyySzz2 = 2.0f*(Syz*Szy - Syy*Szz); Sxx2Syy2Szz2Syz2Szy2 = Syy2 + Szz2 - Sxx2 + Syz2 + Szy2; C[2] = -2.0f * (Sxx2 + Syy2 + Szz2 + Sxy2 + Syx2 + Sxz2 + Szx2 + Syz2 + Szy2); C[1] = 8.0f * (Sxx*Syz*Szy + Syy*Szx*Sxz + Szz*Sxy*Syx - Sxx*Syy*Szz - Syz*Szx*Sxy - Szy*Syx*Sxz); SxzpSzx = Sxz + Szx; SyzpSzy = Syz + Szy; SxypSyx = Sxy + Syx; SyzmSzy = Syz - Szy; SxzmSzx = Sxz - Szx; SxymSyx = Sxy - Syx; SxxpSyy = Sxx + Syy; SxxmSyy = Sxx - Syy; Sxy2Sxz2Syx2Szx2 = Sxy2 + Sxz2 - Syx2 - Szx2; C[0] = Sxy2Sxz2Syx2Szx2 * Sxy2Sxz2Syx2Szx2 + (Sxx2Syy2Szz2Syz2Szy2 + SyzSzymSyySzz2) * (Sxx2Syy2Szz2Syz2Szy2 - SyzSzymSyySzz2) + (-(SxzpSzx)*(SyzmSzy)+(SxymSyx)*(SxxmSyy-Szz)) * (-(SxzmSzx)*(SyzpSzy)+(SxymSyx)*(SxxmSyy+Szz)) + (-(SxzpSzx)*(SyzpSzy)-(SxypSyx)*(SxxpSyy-Szz)) * (-(SxzmSzx)*(SyzmSzy)-(SxypSyx)*(SxxpSyy+Szz)) + (+(SxypSyx)*(SyzpSzy)+(SxzpSzx)*(SxxmSyy+Szz)) * (-(SxymSyx)*(SyzmSzy)+(SxzpSzx)*(SxxpSyy+Szz)) + (+(SxypSyx)*(SyzmSzy)+(SxzmSzx)*(SxxmSyy-Szz)) * (-(SxymSyx)*(SyzpSzy)+(SxzmSzx)*(SxxpSyy-Szz)); mxEigenV = E0; for (int i = 0; i < 50; ++i){ oldg = mxEigenV; x2 = mxEigenV*mxEigenV; b = (x2 + C[2])*mxEigenV; a = b + C[1]; delta = ((a*mxEigenV + C[0])/(2.0f*x2*mxEigenV + b + a)); mxEigenV -= delta; if (fabs(mxEigenV - oldg) < fabs(evalprec*mxEigenV)) break; } if (rot_matrix != NULL ){ double a11, a12, a13, a14, a21, a22, a23, a24, a31, a32, a33, a34, a41, a42, a43, a44; double a3344_4334, a3244_4234, a3243_4233, a3143_4133, a3144_4134, a3142_4132; double q1, q2, q3, q4, normq; double evecprec = 1e-6; double a2, x2, y2, z2; double xy, az, zx, ay, yz, ax; a11 = SxxpSyy + Szz - mxEigenV; a12 = SyzmSzy; a13 = -SxzmSzx; a14 = SxymSyx; a21 = SyzmSzy; a22 = SxxmSyy - Szz-mxEigenV; a23 = SxypSyx; a24= SxzpSzx; a31 = a13; a32 = a23; a33 = Syy-Sxx-Szz - mxEigenV; a34 = SyzpSzy; a41 = a14; a42 = a24; a43 = a34; a44 = Szz - SxxpSyy - mxEigenV; a3344_4334 = a33 * a44 - a43 * a34; a3244_4234 = a32 * a44-a42*a34; a3243_4233 = a32 * a43 - a42 * a33; a3143_4133 = a31 * a43-a41*a33; a3144_4134 = a31 * a44 - a41 * a34; a3142_4132 = a31 * a42-a41*a32; q1 = a22*a3344_4334-a23*a3244_4234+a24*a3243_4233; q2 = -a21*a3344_4334+a23*a3144_4134-a24*a3143_4133; q3 = a21*a3244_4234-a22*a3144_4134+a24*a3142_4132; q4 = -a21*a3243_4233+a22*a3143_4133-a23*a3142_4132; double qsqr = q1 * q1 + q2 * q2 + q3 * q3 + q4 * q4; if (qsqr < evecprec) { q1 = a12*a3344_4334 - a13*a3244_4234 + a14*a3243_4233; q2 = -a11*a3344_4334 + a13*a3144_4134 - a14*a3143_4133; q3 = a11*a3244_4234 - a12*a3144_4134 + a14*a3142_4132; q4 = -a11*a3243_4233 + a12*a3143_4133 - a13*a3142_4132; qsqr = q1*q1 + q2 *q2 + q3*q3+q4*q4; if (qsqr < evecprec) { double a1324_1423 = a13 * a24 - a14 * a23, a1224_1422 = a12 * a24 - a14 * a22; double a1223_1322 = a12 * a23 - a13 * a22, a1124_1421 = a11 * a24 - a14 * a21; double a1123_1321 = a11 * a23 - a13 * a21, a1122_1221 = a11 * a22 - a12 * a21; q1 = a42 * a1324_1423 - a43 * a1224_1422 + a44 * a1223_1322; q2 = -a41 * a1324_1423 + a43 * a1124_1421 - a44 * a1123_1321; q3 = a41 * a1224_1422 - a42 * a1124_1421 + a44 * a1122_1221; q4 = -a41 * a1223_1322 + a42 * a1123_1321 - a43 * a1122_1221; qsqr = q1*q1 + q2 *q2 + q3*q3+q4*q4; if (qsqr < evecprec) { q1 = a32 * a1324_1423 - a33 * a1224_1422 + a34 * a1223_1322; q2 = -a31 * a1324_1423 + a33 * a1124_1421 - a34 * a1123_1321; q3 = a31 * a1224_1422 - a32 * a1124_1421 + a34 * a1122_1221; q4 = -a31 * a1223_1322 + a32 * a1123_1321 - a33 * a1122_1221; qsqr = q1*q1 + q2 *q2 + q3*q3 + q4*q4; } } } normq = sqrt(qsqr); q1 /= normq; q2 /= normq; q3 /= normq; q4 /= normq; a2 = q1 * q1; x2 = q2 * q2; y2 = q3 * q3; z2 = q4 * q4; xy = q2 * q3; az = q1 * q4; zx = q4 * q2; ay = q1 * q3; yz = q3 * q4; ax = q1 * q2; rot_matrix[0] = a2 + x2 - y2 - z2; rot_matrix[1] = 2 * (xy + az); rot_matrix[2] = 2 * (zx - ay); rot_matrix[3] = 2 * (xy - az); rot_matrix[4] = a2 - x2 + y2 - z2; rot_matrix[5] = 2 * (yz + ax); rot_matrix[6] = 2 * (zx + ay); rot_matrix[7] = 2 * (yz - ax); rot_matrix[8] = a2 - x2 - y2 + z2; } return sqrt(fabs(2.0f * (E0 - mxEigenV)/number_of_atoms)); } /////////////////////////////////////////////////////////////// /// Wrapping function for Douglas Theobald QCP superposition method to calculate the RMSD for two conformations. /// /// \param first_conformation_coords [In] Array containing the coordinates of the reference conformation. /// \param second_conformation_coords [In] Array containing the coordinates of the conformation to be measured. /// \param number_of_atoms [In] Number of atoms of both conformations (must be the same, of course). /// \return The actual rmsd between both conformations. /////////////////////////////////////////////////////////////// __device__ floating_point_type calcRMSDOfTwoConformations( floating_point_type* first_conformation_coords, floating_point_type* second_conformation_coords, const int number_of_atoms, floating_point_type* rot_matrix){ floating_point_type A[9]; floating_point_type E0 = innerProduct(A, first_conformation_coords, second_conformation_coords, number_of_atoms); return calcRMSDForTwoConformationsWithTheobaldMethod( A, E0, number_of_atoms, rot_matrix); } __device__ void rotate3D( unsigned int number_of_atoms, floating_point_type * const coords, floating_point_type* u){ // We go through all selected atoms for(unsigned int i=0; i<number_of_atoms; ++i){ int offset = i*3; floating_point_type x_tmp_0,x_tmp_1,x_tmp_2; x_tmp_0 = coords[offset]; x_tmp_1 = coords[offset+1]; x_tmp_2 = coords[offset+2]; // An rotate each of them coords[offset] = u[0] * x_tmp_0 + u[1] * x_tmp_1 + u[2] * x_tmp_2; coords[offset+1] = u[3] * x_tmp_0 + u[4] * x_tmp_1 + u[5] * x_tmp_2; coords[offset+2] = u[6] * x_tmp_0 + u[7] * x_tmp_1 + u[8] * x_tmp_2; } } __device__ floating_point_type calcRMS( floating_point_type* x, floating_point_type* y, unsigned int num_atoms){ double sum_res = 0.0; for(unsigned int i=0; i<num_atoms*3; ++i){ sum_res += (x[i] - y[i]) * (x[i] - y[i]); } return sqrt(sum_res/num_atoms); } /////////////////////////////////////////////////////////////// /// Given a trajectory with N conformations stored in 'all_coordinates', it calculates the rmsd between the conformation /// with 'i' = 'base_conformation_id' and the conformations in the range [j+1,M). In this case it tries to do each of the /// single rmsd measures in one thread. /// /// \param all_coordinates [In] The array storing all coordinates for all conformations in order: /// (conf0_atom_0_x,conf0_atom_0_y,conf0_atom_0_z,conf0_atom_1_x,conf0_atom_1_y ... confN-1_atom_N_z) /// \param base_conformation_id [In] The reference conformation id ('i' in the above explanation). /// \param other_conformations_starting_id [In] The value of j in the above explanation. /// \param number_of_conformations [In] Number of conformations stored in the coordinates array. /// \param number_of_atoms [In] Number of atoms of any of the conformations. /// \param rmsd [In] Array where the rmsds are stored (rmsd[j] is the rmsd between conformation 'i' and /// conformation 'j'). /////////////////////////////////////////////////////////////// __global__ void calcRMSDOfOneVsFollowing( floating_point_type* first_conformation_coords, const int base_conformation_id, floating_point_type* all_coordinates, const int number_of_conformations, const int atoms_per_conformation, const int coordinates_per_conformation, floating_point_type* rmsd){ int second_conformation_id = base_conformation_id + 1 + (blockDim.x*blockIdx.x + threadIdx.x); while(second_conformation_id < number_of_conformations){ floating_point_type* second_conformation_coords = &(all_coordinates[second_conformation_id*coordinates_per_conformation]); rmsd[second_conformation_id-(base_conformation_id+1)] = calcRMSDOfTwoConformations( first_conformation_coords, second_conformation_coords, atoms_per_conformation); second_conformation_id += blockDim.x*gridDim.x; } } __global__ void calcRMSDOfOneVsFollowingWithRotation( floating_point_type* first_conformation_coords, const int base_conformation_id, floating_point_type* all_coordinates, const int number_of_conformations, const int atoms_per_conformation, const int coordinates_per_conformation, floating_point_type* rmsd){ int second_conformation_id = base_conformation_id + 1 + (blockDim.x*blockIdx.x + threadIdx.x); while(second_conformation_id < number_of_conformations){ floating_point_type* second_conformation_coords = &(all_coordinates[second_conformation_id*coordinates_per_conformation]); floating_point_type rot_matrix[9]; rmsd[second_conformation_id-(base_conformation_id+1)] = calcRMSDOfTwoConformations( first_conformation_coords, second_conformation_coords, atoms_per_conformation, rot_matrix); rotate3D( atoms_per_conformation, second_conformation_coords, rot_matrix); second_conformation_id += blockDim.x*gridDim.x; } } __global__ void calcRMSDOfOneVsFollowingFitDiffersCalc( floating_point_type* fitReference, floating_point_type* calcReference, int reference_conformation_number, floating_point_type* rmsd, int numberOfConformations, int coordinatesPerConformation, int atomsPerConformation, floating_point_type *allCoordinates, int coordinatesPerRMSDConformation, int atomsPerRMSDConformation, floating_point_type *allRMSDCoordinates){ int second_conformation_id = reference_conformation_number + 1 + (blockDim.x*blockIdx.x + threadIdx.x); while(second_conformation_id < numberOfConformations){ floating_point_type rot_matrix[9]; floating_point_type* second_conformation_coords = &(allCoordinates[second_conformation_id*coordinatesPerConformation]); floating_point_type* second_calc_conformation_coords = &(allRMSDCoordinates[second_conformation_id*coordinatesPerRMSDConformation]); calcRMSDOfTwoConformations( fitReference, second_conformation_coords, atomsPerConformation, rot_matrix); rotate3D( atomsPerConformation, second_conformation_coords, rot_matrix); rotate3D( atomsPerRMSDConformation, second_calc_conformation_coords, rot_matrix); rmsd[second_conformation_id-(reference_conformation_number+1)] = calcRMS( calcReference, second_calc_conformation_coords, atomsPerRMSDConformation); second_conformation_id += blockDim.x*gridDim.x; } }
98c18459e10924dfc44c1e00e7b93740fd010121.cu
#include "kernel_functions_cuda.h" #include <cstddef> /////////////////////////////////////////////////////////////// /// Implements the 'inner product' operation of Douglas Theobald QCP superposition method (see : http://theobald.brandeis.edu/qcp/ /// and "Rapid calculation of RMSDs using a quaternion-based characteristic polynomial." Acta Crystallogr A 61(4):478-480 /// for more info ). /// /// \param A [In/Out] A 3x3 matrix ( blank space for a real explanation of this parameter) /// \param first_conformation_coords [In] Array containing the coordinates of the reference conformation. /// \param second_conformation_coords [In] Array containing the coordinates of the conformation to be measured. /// \param number_of_atoms [In] Number of atoms of both conformations (must be the same, of course). /// /// \return The E0 parameter (upper bound for max Eigenvalue). /////////////////////////////////////////////////////////////// __device__ floating_point_type innerProduct(floating_point_type* A, floating_point_type* first_conformation_coords, floating_point_type* second_conformation_coords, const int number_of_atoms){ floating_point_type x1, x2, y1, y2, z1, z2; floating_point_type G1 = 0.0f, G2 = 0.0f; A[0] = A[1] = A[2] = A[3] = A[4] = A[5] = A[6] = A[7] = A[8] = 0.0f; int total_number_of_coordinates = 3* number_of_atoms; for (int i = 0; i < total_number_of_coordinates; i+=3){ x1 = first_conformation_coords[i]; y1 = first_conformation_coords[i+1]; z1 = first_conformation_coords[i+2]; x2 = second_conformation_coords[i]; y2 = second_conformation_coords[i+1]; z2 = second_conformation_coords[i+2]; G1 += x1 * x1 + y1 * y1 + z1 * z1; G2 += x2 * x2 + y2 * y2 + z2 * z2; A[0] += (x1 * x2); A[1] += (x1 * y2); A[2] += (x1 * z2); A[3] += (y1 * x2); A[4] += (y1 * y2); A[5] += (y1 * z2); A[6] += (z1 * x2); A[7] += (z1 * y2); A[8] += (z1 * z2); } return (G1 + G2) * 0.5; } /////////////////////////////////////////////////////////////// /// This function ports the second part of Douglas Theobald QCP superposition method (see 'innerProduct'). /// /// \param A [In] A 3x3 matrix (more ?). /// \param E0 [In] Upper bound for the maximum eigenvalue (?). /// \param number_of_atoms [In] Number of atoms of conformations used to get A and E0. /// /// \return The actual rmsd between both conformations. /////////////////////////////////////////////////////////////// __device__ floating_point_type calcRMSDForTwoConformationsWithTheobaldMethod( floating_point_type *A, const floating_point_type E0, const int number_of_atoms, floating_point_type * rot_matrix){ floating_point_type Sxx, Sxy, Sxz, Syx, Syy, Syz, Szx, Szy, Szz; floating_point_type Szz2, Syy2, Sxx2, Sxy2, Syz2, Sxz2, Syx2, Szy2, Szx2, SyzSzymSyySzz2, Sxx2Syy2Szz2Syz2Szy2, Sxy2Sxz2Syx2Szx2, SxzpSzx, SyzpSzy, SxypSyx, SyzmSzy, SxzmSzx, SxymSyx, SxxpSyy, SxxmSyy; floating_point_type C[4]; floating_point_type mxEigenV; floating_point_type b, a, delta, x2; floating_point_type oldg = 0.0f; floating_point_type evalprec = 1e-11f; Sxx = A[0]; Sxy = A[1]; Sxz = A[2]; Syx = A[3]; Syy = A[4]; Syz = A[5]; Szx = A[6]; Szy = A[7]; Szz = A[8]; Sxx2 = Sxx * Sxx; Syy2 = Syy * Syy; Szz2 = Szz * Szz; Sxy2 = Sxy * Sxy; Syz2 = Syz * Syz; Sxz2 = Sxz * Sxz; Syx2 = Syx * Syx; Szy2 = Szy * Szy; Szx2 = Szx * Szx; SyzSzymSyySzz2 = 2.0f*(Syz*Szy - Syy*Szz); Sxx2Syy2Szz2Syz2Szy2 = Syy2 + Szz2 - Sxx2 + Syz2 + Szy2; C[2] = -2.0f * (Sxx2 + Syy2 + Szz2 + Sxy2 + Syx2 + Sxz2 + Szx2 + Syz2 + Szy2); C[1] = 8.0f * (Sxx*Syz*Szy + Syy*Szx*Sxz + Szz*Sxy*Syx - Sxx*Syy*Szz - Syz*Szx*Sxy - Szy*Syx*Sxz); SxzpSzx = Sxz + Szx; SyzpSzy = Syz + Szy; SxypSyx = Sxy + Syx; SyzmSzy = Syz - Szy; SxzmSzx = Sxz - Szx; SxymSyx = Sxy - Syx; SxxpSyy = Sxx + Syy; SxxmSyy = Sxx - Syy; Sxy2Sxz2Syx2Szx2 = Sxy2 + Sxz2 - Syx2 - Szx2; C[0] = Sxy2Sxz2Syx2Szx2 * Sxy2Sxz2Syx2Szx2 + (Sxx2Syy2Szz2Syz2Szy2 + SyzSzymSyySzz2) * (Sxx2Syy2Szz2Syz2Szy2 - SyzSzymSyySzz2) + (-(SxzpSzx)*(SyzmSzy)+(SxymSyx)*(SxxmSyy-Szz)) * (-(SxzmSzx)*(SyzpSzy)+(SxymSyx)*(SxxmSyy+Szz)) + (-(SxzpSzx)*(SyzpSzy)-(SxypSyx)*(SxxpSyy-Szz)) * (-(SxzmSzx)*(SyzmSzy)-(SxypSyx)*(SxxpSyy+Szz)) + (+(SxypSyx)*(SyzpSzy)+(SxzpSzx)*(SxxmSyy+Szz)) * (-(SxymSyx)*(SyzmSzy)+(SxzpSzx)*(SxxpSyy+Szz)) + (+(SxypSyx)*(SyzmSzy)+(SxzmSzx)*(SxxmSyy-Szz)) * (-(SxymSyx)*(SyzpSzy)+(SxzmSzx)*(SxxpSyy-Szz)); mxEigenV = E0; for (int i = 0; i < 50; ++i){ oldg = mxEigenV; x2 = mxEigenV*mxEigenV; b = (x2 + C[2])*mxEigenV; a = b + C[1]; delta = ((a*mxEigenV + C[0])/(2.0f*x2*mxEigenV + b + a)); mxEigenV -= delta; if (fabs(mxEigenV - oldg) < fabs(evalprec*mxEigenV)) break; } if (rot_matrix != NULL ){ double a11, a12, a13, a14, a21, a22, a23, a24, a31, a32, a33, a34, a41, a42, a43, a44; double a3344_4334, a3244_4234, a3243_4233, a3143_4133, a3144_4134, a3142_4132; double q1, q2, q3, q4, normq; double evecprec = 1e-6; double a2, x2, y2, z2; double xy, az, zx, ay, yz, ax; a11 = SxxpSyy + Szz - mxEigenV; a12 = SyzmSzy; a13 = -SxzmSzx; a14 = SxymSyx; a21 = SyzmSzy; a22 = SxxmSyy - Szz-mxEigenV; a23 = SxypSyx; a24= SxzpSzx; a31 = a13; a32 = a23; a33 = Syy-Sxx-Szz - mxEigenV; a34 = SyzpSzy; a41 = a14; a42 = a24; a43 = a34; a44 = Szz - SxxpSyy - mxEigenV; a3344_4334 = a33 * a44 - a43 * a34; a3244_4234 = a32 * a44-a42*a34; a3243_4233 = a32 * a43 - a42 * a33; a3143_4133 = a31 * a43-a41*a33; a3144_4134 = a31 * a44 - a41 * a34; a3142_4132 = a31 * a42-a41*a32; q1 = a22*a3344_4334-a23*a3244_4234+a24*a3243_4233; q2 = -a21*a3344_4334+a23*a3144_4134-a24*a3143_4133; q3 = a21*a3244_4234-a22*a3144_4134+a24*a3142_4132; q4 = -a21*a3243_4233+a22*a3143_4133-a23*a3142_4132; double qsqr = q1 * q1 + q2 * q2 + q3 * q3 + q4 * q4; if (qsqr < evecprec) { q1 = a12*a3344_4334 - a13*a3244_4234 + a14*a3243_4233; q2 = -a11*a3344_4334 + a13*a3144_4134 - a14*a3143_4133; q3 = a11*a3244_4234 - a12*a3144_4134 + a14*a3142_4132; q4 = -a11*a3243_4233 + a12*a3143_4133 - a13*a3142_4132; qsqr = q1*q1 + q2 *q2 + q3*q3+q4*q4; if (qsqr < evecprec) { double a1324_1423 = a13 * a24 - a14 * a23, a1224_1422 = a12 * a24 - a14 * a22; double a1223_1322 = a12 * a23 - a13 * a22, a1124_1421 = a11 * a24 - a14 * a21; double a1123_1321 = a11 * a23 - a13 * a21, a1122_1221 = a11 * a22 - a12 * a21; q1 = a42 * a1324_1423 - a43 * a1224_1422 + a44 * a1223_1322; q2 = -a41 * a1324_1423 + a43 * a1124_1421 - a44 * a1123_1321; q3 = a41 * a1224_1422 - a42 * a1124_1421 + a44 * a1122_1221; q4 = -a41 * a1223_1322 + a42 * a1123_1321 - a43 * a1122_1221; qsqr = q1*q1 + q2 *q2 + q3*q3+q4*q4; if (qsqr < evecprec) { q1 = a32 * a1324_1423 - a33 * a1224_1422 + a34 * a1223_1322; q2 = -a31 * a1324_1423 + a33 * a1124_1421 - a34 * a1123_1321; q3 = a31 * a1224_1422 - a32 * a1124_1421 + a34 * a1122_1221; q4 = -a31 * a1223_1322 + a32 * a1123_1321 - a33 * a1122_1221; qsqr = q1*q1 + q2 *q2 + q3*q3 + q4*q4; } } } normq = sqrt(qsqr); q1 /= normq; q2 /= normq; q3 /= normq; q4 /= normq; a2 = q1 * q1; x2 = q2 * q2; y2 = q3 * q3; z2 = q4 * q4; xy = q2 * q3; az = q1 * q4; zx = q4 * q2; ay = q1 * q3; yz = q3 * q4; ax = q1 * q2; rot_matrix[0] = a2 + x2 - y2 - z2; rot_matrix[1] = 2 * (xy + az); rot_matrix[2] = 2 * (zx - ay); rot_matrix[3] = 2 * (xy - az); rot_matrix[4] = a2 - x2 + y2 - z2; rot_matrix[5] = 2 * (yz + ax); rot_matrix[6] = 2 * (zx + ay); rot_matrix[7] = 2 * (yz - ax); rot_matrix[8] = a2 - x2 - y2 + z2; } return sqrt(fabs(2.0f * (E0 - mxEigenV)/number_of_atoms)); } /////////////////////////////////////////////////////////////// /// Wrapping function for Douglas Theobald QCP superposition method to calculate the RMSD for two conformations. /// /// \param first_conformation_coords [In] Array containing the coordinates of the reference conformation. /// \param second_conformation_coords [In] Array containing the coordinates of the conformation to be measured. /// \param number_of_atoms [In] Number of atoms of both conformations (must be the same, of course). /// \return The actual rmsd between both conformations. /////////////////////////////////////////////////////////////// __device__ floating_point_type calcRMSDOfTwoConformations( floating_point_type* first_conformation_coords, floating_point_type* second_conformation_coords, const int number_of_atoms, floating_point_type* rot_matrix){ floating_point_type A[9]; floating_point_type E0 = innerProduct(A, first_conformation_coords, second_conformation_coords, number_of_atoms); return calcRMSDForTwoConformationsWithTheobaldMethod( A, E0, number_of_atoms, rot_matrix); } __device__ void rotate3D( unsigned int number_of_atoms, floating_point_type * const coords, floating_point_type* u){ // We go through all selected atoms for(unsigned int i=0; i<number_of_atoms; ++i){ int offset = i*3; floating_point_type x_tmp_0,x_tmp_1,x_tmp_2; x_tmp_0 = coords[offset]; x_tmp_1 = coords[offset+1]; x_tmp_2 = coords[offset+2]; // An rotate each of them coords[offset] = u[0] * x_tmp_0 + u[1] * x_tmp_1 + u[2] * x_tmp_2; coords[offset+1] = u[3] * x_tmp_0 + u[4] * x_tmp_1 + u[5] * x_tmp_2; coords[offset+2] = u[6] * x_tmp_0 + u[7] * x_tmp_1 + u[8] * x_tmp_2; } } __device__ floating_point_type calcRMS( floating_point_type* x, floating_point_type* y, unsigned int num_atoms){ double sum_res = 0.0; for(unsigned int i=0; i<num_atoms*3; ++i){ sum_res += (x[i] - y[i]) * (x[i] - y[i]); } return sqrt(sum_res/num_atoms); } /////////////////////////////////////////////////////////////// /// Given a trajectory with N conformations stored in 'all_coordinates', it calculates the rmsd between the conformation /// with 'i' = 'base_conformation_id' and the conformations in the range [j+1,M). In this case it tries to do each of the /// single rmsd measures in one thread. /// /// \param all_coordinates [In] The array storing all coordinates for all conformations in order: /// (conf0_atom_0_x,conf0_atom_0_y,conf0_atom_0_z,conf0_atom_1_x,conf0_atom_1_y ... confN-1_atom_N_z) /// \param base_conformation_id [In] The reference conformation id ('i' in the above explanation). /// \param other_conformations_starting_id [In] The value of j in the above explanation. /// \param number_of_conformations [In] Number of conformations stored in the coordinates array. /// \param number_of_atoms [In] Number of atoms of any of the conformations. /// \param rmsd [In] Array where the rmsds are stored (rmsd[j] is the rmsd between conformation 'i' and /// conformation 'j'). /////////////////////////////////////////////////////////////// __global__ void calcRMSDOfOneVsFollowing( floating_point_type* first_conformation_coords, const int base_conformation_id, floating_point_type* all_coordinates, const int number_of_conformations, const int atoms_per_conformation, const int coordinates_per_conformation, floating_point_type* rmsd){ int second_conformation_id = base_conformation_id + 1 + (blockDim.x*blockIdx.x + threadIdx.x); while(second_conformation_id < number_of_conformations){ floating_point_type* second_conformation_coords = &(all_coordinates[second_conformation_id*coordinates_per_conformation]); rmsd[second_conformation_id-(base_conformation_id+1)] = calcRMSDOfTwoConformations( first_conformation_coords, second_conformation_coords, atoms_per_conformation); second_conformation_id += blockDim.x*gridDim.x; } } __global__ void calcRMSDOfOneVsFollowingWithRotation( floating_point_type* first_conformation_coords, const int base_conformation_id, floating_point_type* all_coordinates, const int number_of_conformations, const int atoms_per_conformation, const int coordinates_per_conformation, floating_point_type* rmsd){ int second_conformation_id = base_conformation_id + 1 + (blockDim.x*blockIdx.x + threadIdx.x); while(second_conformation_id < number_of_conformations){ floating_point_type* second_conformation_coords = &(all_coordinates[second_conformation_id*coordinates_per_conformation]); floating_point_type rot_matrix[9]; rmsd[second_conformation_id-(base_conformation_id+1)] = calcRMSDOfTwoConformations( first_conformation_coords, second_conformation_coords, atoms_per_conformation, rot_matrix); rotate3D( atoms_per_conformation, second_conformation_coords, rot_matrix); second_conformation_id += blockDim.x*gridDim.x; } } __global__ void calcRMSDOfOneVsFollowingFitDiffersCalc( floating_point_type* fitReference, floating_point_type* calcReference, int reference_conformation_number, floating_point_type* rmsd, int numberOfConformations, int coordinatesPerConformation, int atomsPerConformation, floating_point_type *allCoordinates, int coordinatesPerRMSDConformation, int atomsPerRMSDConformation, floating_point_type *allRMSDCoordinates){ int second_conformation_id = reference_conformation_number + 1 + (blockDim.x*blockIdx.x + threadIdx.x); while(second_conformation_id < numberOfConformations){ floating_point_type rot_matrix[9]; floating_point_type* second_conformation_coords = &(allCoordinates[second_conformation_id*coordinatesPerConformation]); floating_point_type* second_calc_conformation_coords = &(allRMSDCoordinates[second_conformation_id*coordinatesPerRMSDConformation]); calcRMSDOfTwoConformations( fitReference, second_conformation_coords, atomsPerConformation, rot_matrix); rotate3D( atomsPerConformation, second_conformation_coords, rot_matrix); rotate3D( atomsPerRMSDConformation, second_calc_conformation_coords, rot_matrix); rmsd[second_conformation_id-(reference_conformation_number+1)] = calcRMS( calcReference, second_calc_conformation_coords, atomsPerRMSDConformation); second_conformation_id += blockDim.x*gridDim.x; } }
23fd08656340841dcdb975d7a6e98585cd40030c.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" /** * Gruppe: 122 * Konstantin Muller (2327697) * Robin Ferrari (2585277) * Vladislav Lasmann (2593078) */ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #include <time.h> #include <sys/time.h> #include "timing.h" #define BLOCK_SIZE 16 #define HEADER_SIZE 122 typedef unsigned char BYTE; //#define CUDA_ERROR_CHECK #define CudaSafeCall( err ) __cudaSafeCall( err, __FILE__, __LINE__ ) #define CudaCheckError() __cudaCheckError( __FILE__, __LINE__ ) void showGPUMem(); inline void __cudaSafeCall( hipError_t err, const char *file, const int line ) { #ifdef CUDA_ERROR_CHECK if ( hipSuccess != err ) { fprintf( stderr, "cudaSafeCall() failed at %s:%i : %s\n", file, line, hipGetErrorString( err ) ); exit( -1 ); } #endif return; } inline void __cudaCheckError( const char *file, const int line ) { #ifdef CUDA_ERROR_CHECK hipError_t err = hipGetLastError(); if ( hipSuccess != err ) { fprintf( stderr, "cudaCheckError() failed at %s:%i : %s\n", file, line, hipGetErrorString( err ) ); showGPUMem(); exit( -1 ); } // More careful checking. However, this will affect performance. // Comment away if needed. /* err = hipDeviceSynchronize(); if( hipSuccess != err ) { fprintf( stderr, "cudaCheckError() with sync failed at %s:%i : %s\n", file, line, hipGetErrorString( err ) ); exit( -1 ); }*/ #endif return; } void showGPUMem(){ // show memory usage of GPU size_t free_byte ; size_t total_byte ; hipError_t cuda_status = hipMemGetInfo( &free_byte, &total_byte ) ; if ( hipSuccess != cuda_status ){ printf("Error: hipMemGetInfo fails, %s \n", hipGetErrorString(cuda_status) ); exit(1); } double free_db = (double)free_byte ; double total_db = (double)total_byte ; double used_db = total_db - free_db ; printf("GPU memory usage: used = %f MB, free = %f MB, total = %f MB\n", used_db/1024.0/1024.0, free_db/1024.0/1024.0, total_db/1024.0/1024.0); } /********* BMP Image functions **************/ typedef struct { int width; int height; float *data; } BMPImage; BYTE bmp_info[HEADER_SIZE]; // Reference header /** * Reads a BMP 24bpp file and returns a BMPImage structure. * Thanks to https://stackoverflow.com/a/9296467 */ BMPImage readBMP(char *filename) { BMPImage bitmap = { 0 }; int size = 0; BYTE *data = NULL; FILE *file = fopen(filename, "rb"); // Read the header (expected BGR - 24bpp) fread(bmp_info, sizeof(BYTE), HEADER_SIZE, file); // Get the image width / height from the header bitmap.width = *((int *)&bmp_info[18]); bitmap.height = *((int *)&bmp_info[22]); size = *((int *)&bmp_info[34]); // Read the image data data = (BYTE *)malloc(sizeof(BYTE) * size); fread(data, sizeof(BYTE), size, file); // Convert the pixel values to float bitmap.data = (float *)malloc(sizeof(float) * size); for (int i = 0; i < size; i++) { bitmap.data[i] = (float)data[i]; } fclose(file); free(data); return bitmap; } /** * Writes a BMP file in grayscale given its image data and a filename. */ void writeBMPGrayscale(int width, int height, float *image, char *filename) { FILE *file = NULL; file = fopen(filename, "wb"); // Write the reference header fwrite(bmp_info, sizeof(BYTE), HEADER_SIZE, file); // Unwrap the 8-bit grayscale into a 24bpp (for simplicity) for (int h = 0; h < height; h++) { int row = h * width; for (int w = 0; w < width; w++) { BYTE pixel = (BYTE)((image[row + w] > 255.0f) ? 255.0f : (image[row + w] < 0.0f) ? 0.0f : image[row + w]); // Repeat the same pixel value for BGR fputc(pixel, file); fputc(pixel, file); fputc(pixel, file); } } fclose(file); } /** * Releases a given BMPImage. */ void freeBMP(BMPImage bitmap) { free(bitmap.data); } /*********** Gray Scale Filter *********/ /** * Converts a given 24bpp image into 8bpp grayscale using the CPU. */ void grayscale(int width, int height, float *image, float *image_out) { for (int h = 0; h < height; h++) { int offset_out = h * width; // 1 color per pixel int offset = offset_out * 3; // 3 colors per pixel for (int w = 0; w < width; w++) { float *pixel = &image[offset + w * 3]; // Convert to grayscale following the "luminance" model image_out[offset_out + w] = pixel[0] * 0.0722f + // B pixel[1] * 0.7152f + // G pixel[2] * 0.2126f; // R } } } /** * Converts a given 24bpp image into 8bpp grayscale using the GPU. */ __global__ void cuda_grayscale(int width, int height, float *image, float *image_out) { // calculate the global indices int absX = blockIdx.x * blockDim.x + threadIdx.x; int absY = blockIdx.y * blockDim.y + threadIdx.y; // calculate the offset in the memories int offset_out = absY * width + absX; // 1 color per pixel int offset_in = offset_out * 3; // 3 color per pixel // Grayscaling from 3 colors per pixel to 1 color per pixel image_out[offset_out] = 0.0722f * image[ offset_in] + // B 0.7152f * image[ offset_in + 1] + // G 0.2126f * image[ offset_in + 2]; // R } /****************Convolution Filters*****/ /** * Applies a 3x3 convolution matrix to a pixel using the CPU. */ float applyFilter(float *image, int stride, float *matrix, int filter_dim) { float pixel = 0.0f; for (int h = 0; h < filter_dim; h++) { int offset = h * stride; int offset_kernel = h * filter_dim; for (int w = 0; w < filter_dim; w++) { pixel += image[offset + w] * matrix[offset_kernel + w]; } } return pixel; } /** * Task 5 * Applies a 3x3 convolution matrix to a pixel using the GPU. */ __device__ float cuda_applyFilter(float *image, int stride, float *matrix, int filter_dim) { float pixel = 0.0f; for (int h = 0; h < filter_dim; h++) { int offset = h * stride; int offset_kernel = h * filter_dim; for (int w = 0; w < filter_dim; w++) { pixel += image[offset + w] * matrix[offset_kernel + w]; } } return pixel; } /** * Applies a Gaussian 3x3 filter to a given image using the CPU. */ void gaussian(int width, int height, float *image, float *image_out) { float gaussian[9] = { 1.0f / 16.0f, 2.0f / 16.0f, 1.0f / 16.0f, 2.0f / 16.0f, 4.0f / 16.0f, 2.0f / 16.0f, 1.0f / 16.0f, 2.0f / 16.0f, 1.0f / 16.0f }; for (int h = 0; h < (height - 2); h++) { int offset_t = h * width; int offset = (h + 1) * width; for (int w = 0; w < (width - 2); w++) { image_out[offset + (w + 1)] = applyFilter(&image[offset_t + w], width, gaussian, 3); } } } /** * Task 6 * Applies a Gaussian 3x3 filter to a given image using the GPU. */ __global__ void cuda_gaussian(int width, int height, float *image, float *image_out) { //(9 pt): implement gaussian filter kernel float gaussian[9] = { 1.0f / 16.0f, 2.0f / 16.0f, 1.0f / 16.0f, 2.0f / 16.0f, 4.0f / 16.0f, 2.0f / 16.0f, 1.0f / 16.0f, 2.0f / 16.0f, 1.0f / 16.0f }; // calculate the global indices int absX = blockIdx.x * blockDim.x + threadIdx.x; int absY = blockIdx.y * blockDim.y + threadIdx.y; // calculate the offset in the memory int offset_t = absY * width; int offset = (absY + 1) * width; if( absY < (height - 2) && absX < (width - 2) ){ image_out[offset + (absX + 1)] = cuda_applyFilter(&image[offset_t + absX], width, gaussian, 3); } } /** * Calculates the gradient of an image using a Sobel filter on the CPU. */ void sobel(int width, int height, float *image, float *image_out) { float sobel_x[9] = {1.0f, 0.0f, -1.0f, 2.0f, 0.0f, -2.0f, 1.0f, 0.0f, -1.0f }; float sobel_y[9] = {1.0f, 2.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, -2.0f, -1.0f }; for (int h = 0; h < (height - 2); h++) { int offset_t = h * width; int offset = (h + 1) * width; for (int w = 0; w < (width - 2); w++) { float gx = applyFilter(&image[offset_t + w], width, sobel_x, 3); float gy = applyFilter(&image[offset_t + w], width, sobel_y, 3); image_out[offset + (w + 1)] = sqrtf(gx * gx + gy * gy); } } } /** * Task 7 * Calculates the gradient of an image using a Sobel filter on the GPU. */ __global__ void cuda_sobel(int width, int height, float *image, float *image_out) { //TODO (9 pt): implement sobel filter kernel float sobel_x[9] = {1.0f, 0.0f, -1.0f, 2.0f, 0.0f, -2.0f, 1.0f, 0.0f, -1.0f }; float sobel_y[9] = {1.0f, 2.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, -2.0f, -1.0f }; // calculate the global indices int absX = blockIdx.x * blockDim.x + threadIdx.x; int absY = blockIdx.y * blockDim.y + threadIdx.y; // calculate the offset in the memory int offset_t = absY * width; int offset = (absY + 1) * width; if( absY < (height - 2) && absX < (width - 2) ){ float gx = cuda_applyFilter(&image[offset_t + absX], width, sobel_x, 3); float gy = cuda_applyFilter(&image[offset_t + absX], width, sobel_y, 3); image_out[offset + (absX + 1)] = sqrtf(gx * gx + gy * gy); } } int main(int argc, char *argv[]) { //check for arguments if(argc != 2){ puts("Usage: sol input_file\n"); exit(0); } BMPImage bitmap = { 0 }; float *d_bitmap = { 0 }; float *image_out[2] = { 0 }; float *d_image_out[2] = { 0 }; int image_size = 0; double t[2] = { 0 }; //dim3 grid(1); dim3 block(BLOCK_SIZE, BLOCK_SIZE); char path[255]; init_clock_time(); // Read the input image and update the grid dimension bitmap = readBMP(argv[1]); image_size = bitmap.width * bitmap.height; /* Task 1: Calculate the grid dimensions-size */ dim3 grid( ceil((double) bitmap.width / (double) BLOCK_SIZE), ceil( (double) bitmap.height / (double) BLOCK_SIZE) ); printf("Image read (width=%d height=%d).\n", bitmap.width, bitmap.height); // Allocate the intermediate image buffers for each step for (int i = 0; i < 2; i++) { image_out[i] = (float *)calloc(image_size, sizeof(float)); // Task2: //(2 pt): allocate memory on the device //(2 pt): intialize allocated memory on device to zero hipMalloc((void**) &d_image_out[i], image_size * sizeof(float) ); hipMemcpy( (void*) d_image_out[i], image_out[i], image_size * sizeof(float), hipMemcpyHostToDevice ); } //Task3: copy input image to device //(2 pt): Allocate memory on device for input image //(2 pt): Copy input image into the device memory hipMalloc( (void**) &d_bitmap, 3 * image_size * sizeof(float) ); hipMemcpy( (void*) d_bitmap, bitmap.data, 3 * image_size * sizeof(float), hipMemcpyHostToDevice ); t[0] = get_clock_time(); // Covert input image to grayscale grayscale(bitmap.width, bitmap.height, bitmap.data, image_out[0]); //serial version //Task4: (2 pt): Launch cuda_grayscale() //cuda_grayscale<<<grid, block>>>(bitmap.width, bitmap.height, d_bitmap, d_image_out[0]); t[1] = get_clock_time(); //(2 pt): transfer image from device to the main memory for saving onto the disk //hipMemcpy( image_out[0], d_image_out[0], image_size * sizeof(float), hipMemcpyDeviceToHost ); sprintf(path, "images/grayscale.bmp"); writeBMPGrayscale(bitmap.width, bitmap.height, image_out[0], path); //write output file printf("Time taken for grayscaling: %8.5f ms\n",t[1] - t[0]); // Apply a 3x3 Gaussian filter t[0] = get_clock_time(); // Launch the CPU version gaussian(bitmap.width, bitmap.height, image_out[0], image_out[1]); // Launch the GPU version // (2 pt): Launch cuda_gaussian(); //cuda_gaussian<<<grid, block>>>(bitmap.width, bitmap.height, d_image_out[0], d_image_out[1]); t[1] = get_clock_time(); //(2 pt): transfer image from device to the main memory for saving onto the disk //hipMemcpy( image_out[1], d_image_out[1], image_size * sizeof(float), hipMemcpyDeviceToHost); // Store the result image with the Gaussian filter applied sprintf(path, "images/gaussian.bmp"); writeBMPGrayscale(bitmap.width, bitmap.height, image_out[1], path); //write output file printf("Time taken for Gaussian filtering: %8.5f ms\n",t[1] - t[0]); // Apply a Sobel filter t[0] = get_clock_time(); // Launch the CPU version sobel(bitmap.width, bitmap.height, image_out[1], image_out[0]); // Launch the GPU version // (2 pt): Launch cuda_sobel(); //cuda_sobel<<<grid, block>>>(bitmap.width, bitmap.height, d_image_out[1], d_image_out[0]); t[1] = get_clock_time(); //(2 pt): transfer image from device to the main memory for saving onto the disk //hipMemcpy( image_out[0], d_image_out[0], image_size * sizeof(float), hipMemcpyDeviceToHost); // Store the final result image with the Sobel filter applied sprintf(path, "images/sobel.bmp"); writeBMPGrayscale(bitmap.width, bitmap.height, image_out[0], path); //write output file printf("Time taken for Sobel filtering: %8.5f ms\n",t[1] - t[0]); // Task 9 // Release the allocated memory for (int i = 0; i < 2; i++) { free(image_out[i]); hipFree(d_image_out[i]); } freeBMP(bitmap); hipFree(d_bitmap); // Got any errors? printf("%s\n", hipGetErrorString(hipGetLastError())); return 0; }
23fd08656340841dcdb975d7a6e98585cd40030c.cu
/** * Gruppe: 122 * Konstantin Müller (2327697) * Robin Ferrari (2585277) * Vladislav Lasmann (2593078) */ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #include <time.h> #include <sys/time.h> #include "timing.h" #define BLOCK_SIZE 16 #define HEADER_SIZE 122 typedef unsigned char BYTE; //#define CUDA_ERROR_CHECK #define CudaSafeCall( err ) __cudaSafeCall( err, __FILE__, __LINE__ ) #define CudaCheckError() __cudaCheckError( __FILE__, __LINE__ ) void showGPUMem(); inline void __cudaSafeCall( cudaError err, const char *file, const int line ) { #ifdef CUDA_ERROR_CHECK if ( cudaSuccess != err ) { fprintf( stderr, "cudaSafeCall() failed at %s:%i : %s\n", file, line, cudaGetErrorString( err ) ); exit( -1 ); } #endif return; } inline void __cudaCheckError( const char *file, const int line ) { #ifdef CUDA_ERROR_CHECK cudaError err = cudaGetLastError(); if ( cudaSuccess != err ) { fprintf( stderr, "cudaCheckError() failed at %s:%i : %s\n", file, line, cudaGetErrorString( err ) ); showGPUMem(); exit( -1 ); } // More careful checking. However, this will affect performance. // Comment away if needed. /* err = cudaDeviceSynchronize(); if( cudaSuccess != err ) { fprintf( stderr, "cudaCheckError() with sync failed at %s:%i : %s\n", file, line, cudaGetErrorString( err ) ); exit( -1 ); }*/ #endif return; } void showGPUMem(){ // show memory usage of GPU size_t free_byte ; size_t total_byte ; cudaError_t cuda_status = cudaMemGetInfo( &free_byte, &total_byte ) ; if ( cudaSuccess != cuda_status ){ printf("Error: cudaMemGetInfo fails, %s \n", cudaGetErrorString(cuda_status) ); exit(1); } double free_db = (double)free_byte ; double total_db = (double)total_byte ; double used_db = total_db - free_db ; printf("GPU memory usage: used = %f MB, free = %f MB, total = %f MB\n", used_db/1024.0/1024.0, free_db/1024.0/1024.0, total_db/1024.0/1024.0); } /********* BMP Image functions **************/ typedef struct { int width; int height; float *data; } BMPImage; BYTE bmp_info[HEADER_SIZE]; // Reference header /** * Reads a BMP 24bpp file and returns a BMPImage structure. * Thanks to https://stackoverflow.com/a/9296467 */ BMPImage readBMP(char *filename) { BMPImage bitmap = { 0 }; int size = 0; BYTE *data = NULL; FILE *file = fopen(filename, "rb"); // Read the header (expected BGR - 24bpp) fread(bmp_info, sizeof(BYTE), HEADER_SIZE, file); // Get the image width / height from the header bitmap.width = *((int *)&bmp_info[18]); bitmap.height = *((int *)&bmp_info[22]); size = *((int *)&bmp_info[34]); // Read the image data data = (BYTE *)malloc(sizeof(BYTE) * size); fread(data, sizeof(BYTE), size, file); // Convert the pixel values to float bitmap.data = (float *)malloc(sizeof(float) * size); for (int i = 0; i < size; i++) { bitmap.data[i] = (float)data[i]; } fclose(file); free(data); return bitmap; } /** * Writes a BMP file in grayscale given its image data and a filename. */ void writeBMPGrayscale(int width, int height, float *image, char *filename) { FILE *file = NULL; file = fopen(filename, "wb"); // Write the reference header fwrite(bmp_info, sizeof(BYTE), HEADER_SIZE, file); // Unwrap the 8-bit grayscale into a 24bpp (for simplicity) for (int h = 0; h < height; h++) { int row = h * width; for (int w = 0; w < width; w++) { BYTE pixel = (BYTE)((image[row + w] > 255.0f) ? 255.0f : (image[row + w] < 0.0f) ? 0.0f : image[row + w]); // Repeat the same pixel value for BGR fputc(pixel, file); fputc(pixel, file); fputc(pixel, file); } } fclose(file); } /** * Releases a given BMPImage. */ void freeBMP(BMPImage bitmap) { free(bitmap.data); } /*********** Gray Scale Filter *********/ /** * Converts a given 24bpp image into 8bpp grayscale using the CPU. */ void grayscale(int width, int height, float *image, float *image_out) { for (int h = 0; h < height; h++) { int offset_out = h * width; // 1 color per pixel int offset = offset_out * 3; // 3 colors per pixel for (int w = 0; w < width; w++) { float *pixel = &image[offset + w * 3]; // Convert to grayscale following the "luminance" model image_out[offset_out + w] = pixel[0] * 0.0722f + // B pixel[1] * 0.7152f + // G pixel[2] * 0.2126f; // R } } } /** * Converts a given 24bpp image into 8bpp grayscale using the GPU. */ __global__ void cuda_grayscale(int width, int height, float *image, float *image_out) { // calculate the global indices int absX = blockIdx.x * blockDim.x + threadIdx.x; int absY = blockIdx.y * blockDim.y + threadIdx.y; // calculate the offset in the memories int offset_out = absY * width + absX; // 1 color per pixel int offset_in = offset_out * 3; // 3 color per pixel // Grayscaling from 3 colors per pixel to 1 color per pixel image_out[offset_out] = 0.0722f * image[ offset_in] + // B 0.7152f * image[ offset_in + 1] + // G 0.2126f * image[ offset_in + 2]; // R } /****************Convolution Filters*****/ /** * Applies a 3x3 convolution matrix to a pixel using the CPU. */ float applyFilter(float *image, int stride, float *matrix, int filter_dim) { float pixel = 0.0f; for (int h = 0; h < filter_dim; h++) { int offset = h * stride; int offset_kernel = h * filter_dim; for (int w = 0; w < filter_dim; w++) { pixel += image[offset + w] * matrix[offset_kernel + w]; } } return pixel; } /** * Task 5 * Applies a 3x3 convolution matrix to a pixel using the GPU. */ __device__ float cuda_applyFilter(float *image, int stride, float *matrix, int filter_dim) { float pixel = 0.0f; for (int h = 0; h < filter_dim; h++) { int offset = h * stride; int offset_kernel = h * filter_dim; for (int w = 0; w < filter_dim; w++) { pixel += image[offset + w] * matrix[offset_kernel + w]; } } return pixel; } /** * Applies a Gaussian 3x3 filter to a given image using the CPU. */ void gaussian(int width, int height, float *image, float *image_out) { float gaussian[9] = { 1.0f / 16.0f, 2.0f / 16.0f, 1.0f / 16.0f, 2.0f / 16.0f, 4.0f / 16.0f, 2.0f / 16.0f, 1.0f / 16.0f, 2.0f / 16.0f, 1.0f / 16.0f }; for (int h = 0; h < (height - 2); h++) { int offset_t = h * width; int offset = (h + 1) * width; for (int w = 0; w < (width - 2); w++) { image_out[offset + (w + 1)] = applyFilter(&image[offset_t + w], width, gaussian, 3); } } } /** * Task 6 * Applies a Gaussian 3x3 filter to a given image using the GPU. */ __global__ void cuda_gaussian(int width, int height, float *image, float *image_out) { //(9 pt): implement gaussian filter kernel float gaussian[9] = { 1.0f / 16.0f, 2.0f / 16.0f, 1.0f / 16.0f, 2.0f / 16.0f, 4.0f / 16.0f, 2.0f / 16.0f, 1.0f / 16.0f, 2.0f / 16.0f, 1.0f / 16.0f }; // calculate the global indices int absX = blockIdx.x * blockDim.x + threadIdx.x; int absY = blockIdx.y * blockDim.y + threadIdx.y; // calculate the offset in the memory int offset_t = absY * width; int offset = (absY + 1) * width; if( absY < (height - 2) && absX < (width - 2) ){ image_out[offset + (absX + 1)] = cuda_applyFilter(&image[offset_t + absX], width, gaussian, 3); } } /** * Calculates the gradient of an image using a Sobel filter on the CPU. */ void sobel(int width, int height, float *image, float *image_out) { float sobel_x[9] = {1.0f, 0.0f, -1.0f, 2.0f, 0.0f, -2.0f, 1.0f, 0.0f, -1.0f }; float sobel_y[9] = {1.0f, 2.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, -2.0f, -1.0f }; for (int h = 0; h < (height - 2); h++) { int offset_t = h * width; int offset = (h + 1) * width; for (int w = 0; w < (width - 2); w++) { float gx = applyFilter(&image[offset_t + w], width, sobel_x, 3); float gy = applyFilter(&image[offset_t + w], width, sobel_y, 3); image_out[offset + (w + 1)] = sqrtf(gx * gx + gy * gy); } } } /** * Task 7 * Calculates the gradient of an image using a Sobel filter on the GPU. */ __global__ void cuda_sobel(int width, int height, float *image, float *image_out) { //TODO (9 pt): implement sobel filter kernel float sobel_x[9] = {1.0f, 0.0f, -1.0f, 2.0f, 0.0f, -2.0f, 1.0f, 0.0f, -1.0f }; float sobel_y[9] = {1.0f, 2.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, -2.0f, -1.0f }; // calculate the global indices int absX = blockIdx.x * blockDim.x + threadIdx.x; int absY = blockIdx.y * blockDim.y + threadIdx.y; // calculate the offset in the memory int offset_t = absY * width; int offset = (absY + 1) * width; if( absY < (height - 2) && absX < (width - 2) ){ float gx = cuda_applyFilter(&image[offset_t + absX], width, sobel_x, 3); float gy = cuda_applyFilter(&image[offset_t + absX], width, sobel_y, 3); image_out[offset + (absX + 1)] = sqrtf(gx * gx + gy * gy); } } int main(int argc, char *argv[]) { //check for arguments if(argc != 2){ puts("Usage: sol input_file\n"); exit(0); } BMPImage bitmap = { 0 }; float *d_bitmap = { 0 }; float *image_out[2] = { 0 }; float *d_image_out[2] = { 0 }; int image_size = 0; double t[2] = { 0 }; //dim3 grid(1); dim3 block(BLOCK_SIZE, BLOCK_SIZE); char path[255]; init_clock_time(); // Read the input image and update the grid dimension bitmap = readBMP(argv[1]); image_size = bitmap.width * bitmap.height; /* Task 1: Calculate the grid dimensions-size */ dim3 grid( ceil((double) bitmap.width / (double) BLOCK_SIZE), ceil( (double) bitmap.height / (double) BLOCK_SIZE) ); printf("Image read (width=%d height=%d).\n", bitmap.width, bitmap.height); // Allocate the intermediate image buffers for each step for (int i = 0; i < 2; i++) { image_out[i] = (float *)calloc(image_size, sizeof(float)); // Task2: //(2 pt): allocate memory on the device //(2 pt): intialize allocated memory on device to zero cudaMalloc((void**) &d_image_out[i], image_size * sizeof(float) ); cudaMemcpy( (void*) d_image_out[i], image_out[i], image_size * sizeof(float), cudaMemcpyHostToDevice ); } //Task3: copy input image to device //(2 pt): Allocate memory on device for input image //(2 pt): Copy input image into the device memory cudaMalloc( (void**) &d_bitmap, 3 * image_size * sizeof(float) ); cudaMemcpy( (void*) d_bitmap, bitmap.data, 3 * image_size * sizeof(float), cudaMemcpyHostToDevice ); t[0] = get_clock_time(); // Covert input image to grayscale grayscale(bitmap.width, bitmap.height, bitmap.data, image_out[0]); //serial version //Task4: (2 pt): Launch cuda_grayscale() //cuda_grayscale<<<grid, block>>>(bitmap.width, bitmap.height, d_bitmap, d_image_out[0]); t[1] = get_clock_time(); //(2 pt): transfer image from device to the main memory for saving onto the disk //cudaMemcpy( image_out[0], d_image_out[0], image_size * sizeof(float), cudaMemcpyDeviceToHost ); sprintf(path, "images/grayscale.bmp"); writeBMPGrayscale(bitmap.width, bitmap.height, image_out[0], path); //write output file printf("Time taken for grayscaling: %8.5f ms\n",t[1] - t[0]); // Apply a 3x3 Gaussian filter t[0] = get_clock_time(); // Launch the CPU version gaussian(bitmap.width, bitmap.height, image_out[0], image_out[1]); // Launch the GPU version // (2 pt): Launch cuda_gaussian(); //cuda_gaussian<<<grid, block>>>(bitmap.width, bitmap.height, d_image_out[0], d_image_out[1]); t[1] = get_clock_time(); //(2 pt): transfer image from device to the main memory for saving onto the disk //cudaMemcpy( image_out[1], d_image_out[1], image_size * sizeof(float), cudaMemcpyDeviceToHost); // Store the result image with the Gaussian filter applied sprintf(path, "images/gaussian.bmp"); writeBMPGrayscale(bitmap.width, bitmap.height, image_out[1], path); //write output file printf("Time taken for Gaussian filtering: %8.5f ms\n",t[1] - t[0]); // Apply a Sobel filter t[0] = get_clock_time(); // Launch the CPU version sobel(bitmap.width, bitmap.height, image_out[1], image_out[0]); // Launch the GPU version // (2 pt): Launch cuda_sobel(); //cuda_sobel<<<grid, block>>>(bitmap.width, bitmap.height, d_image_out[1], d_image_out[0]); t[1] = get_clock_time(); //(2 pt): transfer image from device to the main memory for saving onto the disk //cudaMemcpy( image_out[0], d_image_out[0], image_size * sizeof(float), cudaMemcpyDeviceToHost); // Store the final result image with the Sobel filter applied sprintf(path, "images/sobel.bmp"); writeBMPGrayscale(bitmap.width, bitmap.height, image_out[0], path); //write output file printf("Time taken for Sobel filtering: %8.5f ms\n",t[1] - t[0]); // Task 9 // Release the allocated memory for (int i = 0; i < 2; i++) { free(image_out[i]); cudaFree(d_image_out[i]); } freeBMP(bitmap); cudaFree(d_bitmap); // Got any errors? printf("%s\n", cudaGetErrorString(cudaGetLastError())); return 0; }
9bf49f488d669218aaf3a0cb44c1020a9588779f.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include <opencv2/opencv.hpp> #include <vector> __global__ void emboss ( unsigned char * data, unsigned char * out, std::size_t cols, std::size_t rows) { auto op1 = blockIdx.x * (blockDim.x) + threadIdx.x; auto op2 = blockIdx.y * (blockDim.y) + threadIdx.y; if ( op1 > 0 && op1 < (cols - 1) && op2 > 0 && op2 < (rows - 1)) { for (auto c = 0; c < 3; ++c){ auto op3 = data[((op2 - 1) * cols + op1 - 1) * 3 + c] * -18 + data[((op2 - 1) * cols + op1 + 1) * 3 + c] * 0 + data[( op2 * cols + op1 - 1) * 3 + c] * -9 + data[( op2 * cols + op1 + 1) * 3 + c] * 9 + data[((op2 + 1) * cols + op1 - 1) * 3 + c] * 0 + data[((op2 + 1) * cols + op1 + 1) * 3 + c] * 18 + data[(( op2 - 1) * cols + op1) * 3 + c] * -9 + 9 * data[( op2 * cols + op1) * 3 + c] + data[(( op2 + 1) * cols + op1) * 3 + c] * 9; out[(op2 * cols + op1) * 3 + c] = (op3 / 9); } } } int main() { cv::Mat img_in = cv::imread("in.jpg", cv::IMREAD_UNCHANGED ); auto rgb = img_in.data; auto rows = img_in.rows; auto cols = img_in.cols; std::vector< unsigned char > g( 3 * rows * cols ); cv::Mat img_out( rows, cols, CV_8UC3, g.data() ); unsigned char * rgb_d; unsigned char * out; std::size_t size = 3 * img_in.cols * img_in.rows; hipMalloc( &rgb_d, 3 * rows * cols); hipMalloc( &out, 3 * rows * cols ); hipStream_t streams[ 2 ]; hipStreamCreate( &streams[ 0 ] ); hipStreamCreate( &streams[ 1 ] ); hipMemcpyAsync( rgb_d, rgb, size/2, hipMemcpyHostToDevice, streams[ 0 ] ); hipMemcpyAsync( rgb_d+size/2, rgb+size/2, size/2, hipMemcpyHostToDevice, streams[ 1 ] ); dim3 dim1( 32, 32 ); dim3 dim2( 3 * (( cols ) / ((dim1.x - 2) + 1) ), (( rows ) / ((dim1.y - 2) + 1) )); hipEvent_t start, stop; hipEventCreate( &start ); hipEventCreate( &stop ); hipEventRecord( start ); hipLaunchKernelGGL(( emboss), dim3(dim2), dim3(dim1), 0, streams[ 0 ] , rgb_d, out, cols, rows / 2 + 2); hipLaunchKernelGGL(( emboss), dim3(dim2), dim3(dim1), 0, streams[ 1 ] , rgb_d+size/2, out+size/2, cols, rows / 2); hipMemcpyAsync( g.data(), out, size/2, hipMemcpyDeviceToHost, streams[ 0 ] ); hipMemcpyAsync( g.data()+size/2, out+size/2, size/2, hipMemcpyDeviceToHost, streams[ 1 ] ); hipDeviceSynchronize(); hipStreamDestroy(streams[0]); hipStreamDestroy(streams[1]); auto hipError_t = hipGetLastError(); if (hipError_t != hipSuccess){ std::cout << hipGetErrorName(hipError_t) << std::endl; std::cout << hipGetErrorString(hipError_t) << std::endl; } else { std::cout << "No Errors!" << std::endl; } hipEventRecord( stop ); hipEventSynchronize( stop ); float duration = 0.0f; hipEventElapsedTime( &duration, start, stop ); std::cout << "Total: " << duration << "ms\n"; cv::imwrite( "EmbossStreamOutput.jpg", img_out ); hipFree( rgb_d); hipFree ( out); return 0; }
9bf49f488d669218aaf3a0cb44c1020a9588779f.cu
#include <opencv2/opencv.hpp> #include <vector> __global__ void emboss ( unsigned char * data, unsigned char * out, std::size_t cols, std::size_t rows) { auto op1 = blockIdx.x * (blockDim.x) + threadIdx.x; auto op2 = blockIdx.y * (blockDim.y) + threadIdx.y; if ( op1 > 0 && op1 < (cols - 1) && op2 > 0 && op2 < (rows - 1)) { for (auto c = 0; c < 3; ++c){ auto op3 = data[((op2 - 1) * cols + op1 - 1) * 3 + c] * -18 + data[((op2 - 1) * cols + op1 + 1) * 3 + c] * 0 + data[( op2 * cols + op1 - 1) * 3 + c] * -9 + data[( op2 * cols + op1 + 1) * 3 + c] * 9 + data[((op2 + 1) * cols + op1 - 1) * 3 + c] * 0 + data[((op2 + 1) * cols + op1 + 1) * 3 + c] * 18 + data[(( op2 - 1) * cols + op1) * 3 + c] * -9 + 9 * data[( op2 * cols + op1) * 3 + c] + data[(( op2 + 1) * cols + op1) * 3 + c] * 9; out[(op2 * cols + op1) * 3 + c] = (op3 / 9); } } } int main() { cv::Mat img_in = cv::imread("in.jpg", cv::IMREAD_UNCHANGED ); auto rgb = img_in.data; auto rows = img_in.rows; auto cols = img_in.cols; std::vector< unsigned char > g( 3 * rows * cols ); cv::Mat img_out( rows, cols, CV_8UC3, g.data() ); unsigned char * rgb_d; unsigned char * out; std::size_t size = 3 * img_in.cols * img_in.rows; cudaMalloc( &rgb_d, 3 * rows * cols); cudaMalloc( &out, 3 * rows * cols ); cudaStream_t streams[ 2 ]; cudaStreamCreate( &streams[ 0 ] ); cudaStreamCreate( &streams[ 1 ] ); cudaMemcpyAsync( rgb_d, rgb, size/2, cudaMemcpyHostToDevice, streams[ 0 ] ); cudaMemcpyAsync( rgb_d+size/2, rgb+size/2, size/2, cudaMemcpyHostToDevice, streams[ 1 ] ); dim3 dim1( 32, 32 ); dim3 dim2( 3 * (( cols ) / ((dim1.x - 2) + 1) ), (( rows ) / ((dim1.y - 2) + 1) )); cudaEvent_t start, stop; cudaEventCreate( &start ); cudaEventCreate( &stop ); cudaEventRecord( start ); emboss<<< dim2, dim1, 0, streams[ 0 ] >>>( rgb_d, out, cols, rows / 2 + 2); emboss<<< dim2, dim1, 0, streams[ 1 ] >>>( rgb_d+size/2, out+size/2, cols, rows / 2); cudaMemcpyAsync( g.data(), out, size/2, cudaMemcpyDeviceToHost, streams[ 0 ] ); cudaMemcpyAsync( g.data()+size/2, out+size/2, size/2, cudaMemcpyDeviceToHost, streams[ 1 ] ); cudaDeviceSynchronize(); cudaStreamDestroy(streams[0]); cudaStreamDestroy(streams[1]); auto cudaError = cudaGetLastError(); if (cudaError != cudaSuccess){ std::cout << cudaGetErrorName(cudaError) << std::endl; std::cout << cudaGetErrorString(cudaError) << std::endl; } else { std::cout << "No Errors!" << std::endl; } cudaEventRecord( stop ); cudaEventSynchronize( stop ); float duration = 0.0f; cudaEventElapsedTime( &duration, start, stop ); std::cout << "Total: " << duration << "ms\n"; cv::imwrite( "EmbossStreamOutput.jpg", img_out ); cudaFree( rgb_d); cudaFree ( out); return 0; }
d1f7ffa3e49241f6e87637bba5a21d1e9fe97046.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include "reduce_hip.cuh" __global__ void reduce(int *a, int *partial_sum, int N) { size_t tid = threadIdx.x; size_t gid = threadIdx.x + blockIdx.x * blockDim.x; for (size_t s = N / 2; s > 0; s >>= 1) { if (tid < s) { a[gid] += a[gid + s]; } __syncthreads(); } if (tid == 0) partial_sum[blockIdx.x] = a[blockIdx.x * blockDim.x]; }
d1f7ffa3e49241f6e87637bba5a21d1e9fe97046.cu
#include "reduce.cuh" __global__ void reduce(int *a, int *partial_sum, int N) { size_t tid = threadIdx.x; size_t gid = threadIdx.x + blockIdx.x * blockDim.x; for (size_t s = N / 2; s > 0; s >>= 1) { if (tid < s) { a[gid] += a[gid + s]; } __syncthreads(); } if (tid == 0) partial_sum[blockIdx.x] = a[blockIdx.x * blockDim.x]; }
da6cbe444a44ddd5d0d78abed40bbf35738d5800.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include "includes.h" __global__ void kLog(float* mat, float* target, unsigned int len, float tiny) { const unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x; const unsigned int numThreads = blockDim.x * gridDim.x; for (unsigned int i = idx; i < len; i += numThreads) target[i] = __logf(mat[i] + tiny); }
da6cbe444a44ddd5d0d78abed40bbf35738d5800.cu
#include "includes.h" __global__ void kLog(float* mat, float* target, unsigned int len, float tiny) { const unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x; const unsigned int numThreads = blockDim.x * gridDim.x; for (unsigned int i = idx; i < len; i += numThreads) target[i] = __logf(mat[i] + tiny); }
86e4ccff76d0add0153a252b8404828417d9eea4.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" /* * File: kernels.cu * Contiene i kernel da eseguire sul device e alcune macro * Autori: Claudio Scandura, Giuseppe Quartarone */ /* Macro per la gestione degli errori */ #define safe_call(x) \ if( (x) != hipSuccess ) { fprintf(stderr,"ERRORE CUDA: %s\n", hipGetErrorString(hipGetLastError())); return -1; } #define ec_null(x) \ if ( (x) == NULL ) { perror("ERRORE"); return -1; } #define ec_rv(N)\ if ((int)N) { errno=N; perror("Errore"); exit(errno); } #define TABLE_BAR "\t\t\t\t|++++++++++|++++++++++++++|++++++++++++++++|++++++++++++|+++++++++++++++++|\n" #define THREAD_FIR 512 /* Numero di thread in un blocco per FIR (no change) */ #define THREAD_SCALAR 256 /* Numero di thread in un blocco per prodotto scalare (no change)*/ #ifndef TAPS /* Calcola il prodotto scalare di n coppie di vettori <V,W>. Ogni blocco di thread elabora un prodotto scalare; i thread in un blocco lavorano su fette di elementi della coppia <V,W> a: puntatore a memoria globale del device; contiene V0,...,Vn allocati in modo contiguo b: come a, ma contiene i vettori W0,...,W1 res: zona di memoria globale dove scrivere i risultati vectors: il numero dei vettori elems: lunghezza dei vettori */ __global__ void ScalarProduct(float *a, float* b, float* res, int vectors, int elems){ /* memoria shared per scrivere i risultati dei singoli thread */ __shared__ float th_r[THREAD_SCALAR]; /* memoria shared per scrivere i risultati parziali delle singole fette*/ __shared__ float sl_r[THREAD_SCALAR]; int slices=elems/THREAD_SCALAR; /* le fette sono piu` di una quando gli elementi sono piu dei thread nel blocco NB: slices non deve superare il numero dei thread in un blocco */ const int tId = threadIdx.x; /* scorre i vettori in a e b */ for(int vec_id = blockIdx.x; vec_id < vectors; vec_id += gridDim.x){ int base = elems * vec_id; /* scandisce le fette dei due vettori */ for(int slice = 0; slice < slices; slice++, base += blockDim.x){ th_r[tId] = a[base + tId] * b[base + tId]; __syncthreads(); /* calcola il risultato finale della fetta */ for( int step = blockDim.x /2; step > 0; step /= 2){ if( tId < step ) th_r[tId] += th_r[step + tId]; __syncthreads(); } /* il primo thread del blocco scrive il risultato parziale della fetta */ if ( tId == 0) sl_r[slice] = th_r[0]; } /* somma i risultati delle fette */ for(int step = slices/2; step > 0; step /=2){ if( tId < step ) sl_r[tId] += sl_r[step + tId]; __syncthreads(); } /* il risultato finale viene scritto in memoria globale */ if( tId == 0 ) res[vec_id] = sl_r[0]; } } /* Funzione analoga a quella sopra, calcola la norma 2 di n vettori, non occorre quindi avere i vettori W */ __global__ void norma2(float *a, float* res, int vectors, int elems){ __shared__ float th_r[THREAD_SCALAR]; __shared__ float sl_r[THREAD_SCALAR]; int slices=elems/THREAD_SCALAR; const int tId = threadIdx.x; /* identificatore thread nel blocco */ for(int vec_id = blockIdx.x; vec_id < vectors; vec_id += gridDim.x){ int base = elems * vec_id; for(int slice = 0; slice < slices; slice++, base += blockDim.x){ th_r[tId] = a[base + tId] * a[base + tId]; __syncthreads(); for( int step = blockDim.x /2; step > 0; step /= 2){ if( tId < step ) th_r[tId] += th_r[step + tId]; __syncthreads(); } if ( tId == 0) sl_r[slice] = th_r[0]; } for(int step = slices/2; step > 0; step /=2){ if( tId < step ) sl_r[tId] += sl_r[step + tId]; __syncthreads(); } if( tId == 0 ) res[vec_id] = sqrtf(sl_r[0]); } } #else #ifdef __SYM__ /* Tramite le direttive di compilazione si alloca meno memoria in caso di FIR simmetrico */ __device__ __constant__ float d_coeffs[TAPS/2]; #else __device__ __constant__ float d_coeffs[TAPS]; #endif /* Texture reference alla delay line per velocizzare l' accesso in memoria globale */ texture<float, 1, hipReadModeElementType> texRef1; /* Calcolo FIR A blocchi di thread corrispondono blocchi della delay line, ogni thread quindi calcola il risultato di una singola posizione del vettore dei risultati. Si usa la tecnica del buffer circolare per implementare la convoluzione res: la delay line size: la dimensione di res */ __global__ void fir(float* res, int size){ const int tId = threadIdx.x; /* identificatore del thread nel blocco */ register float t_res; /* registro per l'accumulo del risultato del thread */ /* scorre i blocchi della delay line */ for(int b_id = blockIdx.x; b_id < size/THREAD_FIR ; b_id += gridDim.x){ t_res=0.0; /* ricava la posizione di res sul quale calcolare la convoluzione */ int element = THREAD_FIR * b_id +tId, count=element; for (int k=0; k<TAPS; k++) { /* preleva la posizione di res dalla memoria texture (cached) */ t_res+=d_coeffs[k]*tex1Dfetch(texRef1, count--); if (count<0) count=size-1; } res[element]=t_res; } } /* Come fir() con la differenza che si assume di avere un vettore dei coefficienti simmetrico */ __global__ void fir_sym(float* res, int size){ const int tId = threadIdx.x; register float t_res; for(int b_id = blockIdx.x; b_id < size/THREAD_FIR ; b_id += gridDim.x){ t_res=0.0; int element = THREAD_FIR * b_id +tId, count=element, sym_ind; /* calcola l'indirizzo simmetrico di res[count] relativamente alla lunghezza di input response */ if (count-TAPS+1<0) sym_ind=size+(count - TAPS+1); else sym_ind=count-TAPS+1; for (int k=0; k<TAPS/2; k++) { /* essendo count e sym_ind generalmente non contigui questi due prelievi sono la causa della lentezza di questo kernel rispetto a fir() poiche` generano texture miss */ t_res+=d_coeffs[k]*(tex1Dfetch(texRef1, count--)+tex1Dfetch(texRef1, sym_ind++)); if (count<0) count=size-1; if (sym_ind>=size) sym_ind=0; } res[element]=t_res; } } #endif /* Funzione per l'inizializzazione casuale di vettori */ static void init(float *v, int size, float seed) { int k; srand(time(NULL)); for (k=0; k<size; k++) v[k]=random()*seed; }
86e4ccff76d0add0153a252b8404828417d9eea4.cu
/* * File: kernels.cu * Contiene i kernel da eseguire sul device e alcune macro * Autori: Claudio Scandura, Giuseppe Quartarone */ /* Macro per la gestione degli errori */ #define safe_call(x) \ if( (x) != cudaSuccess ) { fprintf(stderr,"ERRORE CUDA: %s\n", cudaGetErrorString(cudaGetLastError())); return -1; } #define ec_null(x) \ if ( (x) == NULL ) { perror("ERRORE"); return -1; } #define ec_rv(N)\ if ((int)N) { errno=N; perror("Errore"); exit(errno); } #define TABLE_BAR "\t\t\t\t|++++++++++|++++++++++++++|++++++++++++++++|++++++++++++|+++++++++++++++++|\n" #define THREAD_FIR 512 /* Numero di thread in un blocco per FIR (no change) */ #define THREAD_SCALAR 256 /* Numero di thread in un blocco per prodotto scalare (no change)*/ #ifndef TAPS /* Calcola il prodotto scalare di n coppie di vettori <V,W>. Ogni blocco di thread elabora un prodotto scalare; i thread in un blocco lavorano su fette di elementi della coppia <V,W> a: puntatore a memoria globale del device; contiene V0,...,Vn allocati in modo contiguo b: come a, ma contiene i vettori W0,...,W1 res: zona di memoria globale dove scrivere i risultati vectors: il numero dei vettori elems: lunghezza dei vettori */ __global__ void ScalarProduct(float *a, float* b, float* res, int vectors, int elems){ /* memoria shared per scrivere i risultati dei singoli thread */ __shared__ float th_r[THREAD_SCALAR]; /* memoria shared per scrivere i risultati parziali delle singole fette*/ __shared__ float sl_r[THREAD_SCALAR]; int slices=elems/THREAD_SCALAR; /* le fette sono piu` di una quando gli elementi sono piu dei thread nel blocco NB: slices non deve superare il numero dei thread in un blocco */ const int tId = threadIdx.x; /* scorre i vettori in a e b */ for(int vec_id = blockIdx.x; vec_id < vectors; vec_id += gridDim.x){ int base = elems * vec_id; /* scandisce le fette dei due vettori */ for(int slice = 0; slice < slices; slice++, base += blockDim.x){ th_r[tId] = a[base + tId] * b[base + tId]; __syncthreads(); /* calcola il risultato finale della fetta */ for( int step = blockDim.x /2; step > 0; step /= 2){ if( tId < step ) th_r[tId] += th_r[step + tId]; __syncthreads(); } /* il primo thread del blocco scrive il risultato parziale della fetta */ if ( tId == 0) sl_r[slice] = th_r[0]; } /* somma i risultati delle fette */ for(int step = slices/2; step > 0; step /=2){ if( tId < step ) sl_r[tId] += sl_r[step + tId]; __syncthreads(); } /* il risultato finale viene scritto in memoria globale */ if( tId == 0 ) res[vec_id] = sl_r[0]; } } /* Funzione analoga a quella sopra, calcola la norma 2 di n vettori, non occorre quindi avere i vettori W */ __global__ void norma2(float *a, float* res, int vectors, int elems){ __shared__ float th_r[THREAD_SCALAR]; __shared__ float sl_r[THREAD_SCALAR]; int slices=elems/THREAD_SCALAR; const int tId = threadIdx.x; /* identificatore thread nel blocco */ for(int vec_id = blockIdx.x; vec_id < vectors; vec_id += gridDim.x){ int base = elems * vec_id; for(int slice = 0; slice < slices; slice++, base += blockDim.x){ th_r[tId] = a[base + tId] * a[base + tId]; __syncthreads(); for( int step = blockDim.x /2; step > 0; step /= 2){ if( tId < step ) th_r[tId] += th_r[step + tId]; __syncthreads(); } if ( tId == 0) sl_r[slice] = th_r[0]; } for(int step = slices/2; step > 0; step /=2){ if( tId < step ) sl_r[tId] += sl_r[step + tId]; __syncthreads(); } if( tId == 0 ) res[vec_id] = sqrtf(sl_r[0]); } } #else #ifdef __SYM__ /* Tramite le direttive di compilazione si alloca meno memoria in caso di FIR simmetrico */ __device__ __constant__ float d_coeffs[TAPS/2]; #else __device__ __constant__ float d_coeffs[TAPS]; #endif /* Texture reference alla delay line per velocizzare l' accesso in memoria globale */ texture<float, 1, cudaReadModeElementType> texRef1; /* Calcolo FIR A blocchi di thread corrispondono blocchi della delay line, ogni thread quindi calcola il risultato di una singola posizione del vettore dei risultati. Si usa la tecnica del buffer circolare per implementare la convoluzione res: la delay line size: la dimensione di res */ __global__ void fir(float* res, int size){ const int tId = threadIdx.x; /* identificatore del thread nel blocco */ register float t_res; /* registro per l'accumulo del risultato del thread */ /* scorre i blocchi della delay line */ for(int b_id = blockIdx.x; b_id < size/THREAD_FIR ; b_id += gridDim.x){ t_res=0.0; /* ricava la posizione di res sul quale calcolare la convoluzione */ int element = THREAD_FIR * b_id +tId, count=element; for (int k=0; k<TAPS; k++) { /* preleva la posizione di res dalla memoria texture (cached) */ t_res+=d_coeffs[k]*tex1Dfetch(texRef1, count--); if (count<0) count=size-1; } res[element]=t_res; } } /* Come fir() con la differenza che si assume di avere un vettore dei coefficienti simmetrico */ __global__ void fir_sym(float* res, int size){ const int tId = threadIdx.x; register float t_res; for(int b_id = blockIdx.x; b_id < size/THREAD_FIR ; b_id += gridDim.x){ t_res=0.0; int element = THREAD_FIR * b_id +tId, count=element, sym_ind; /* calcola l'indirizzo simmetrico di res[count] relativamente alla lunghezza di input response */ if (count-TAPS+1<0) sym_ind=size+(count - TAPS+1); else sym_ind=count-TAPS+1; for (int k=0; k<TAPS/2; k++) { /* essendo count e sym_ind generalmente non contigui questi due prelievi sono la causa della lentezza di questo kernel rispetto a fir() poiche` generano texture miss */ t_res+=d_coeffs[k]*(tex1Dfetch(texRef1, count--)+tex1Dfetch(texRef1, sym_ind++)); if (count<0) count=size-1; if (sym_ind>=size) sym_ind=0; } res[element]=t_res; } } #endif /* Funzione per l'inizializzazione casuale di vettori */ static void init(float *v, int size, float seed) { int k; srand(time(NULL)); for (k=0; k<size; k++) v[k]=random()*seed; }
29fc2e46b1a0edbe8cf8428aca749cadf740ed84.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" // ------------------------------------------------------------------ // Faster R-CNN // Copyright (c) 2015 Microsoft // Licensed under The MIT License [see fast-rcnn/LICENSE for details] // Written by Shaoqing Ren // ------------------------------------------------------------------ #include "gpu_nms.hpp" #include <vector> #include <iostream> #define CUDA_CHECK(condition) \ /* Code block avoids redefinition of hipError_t error */ \ do { \ hipError_t error = condition; \ if (error != hipSuccess) { \ std::cout << hipGetErrorString(error) << std::endl; \ } \ } while (0) #define DIVUP(m,n) ((m) / (n) + ((m) % (n) > 0)) int const threadsPerBlock = sizeof(unsigned long long) * 8; __device__ inline float devIoU(float const * const a, float const * const b) { float left = max(a[0], b[0]), right = min(a[2], b[2]); float top = max(a[1], b[1]), bottom = min(a[3], b[3]); float width = max(right - left + 1, 0.f), height = max(bottom - top + 1, 0.f); float interS = width * height; float Sa = (a[2] - a[0] + 1) * (a[3] - a[1] + 1); float Sb = (b[2] - b[0] + 1) * (b[3] - b[1] + 1); return interS / (Sa + Sb - interS); } __global__ void nms_kernel(const int n_boxes, const float nms_overlap_thresh, const float *dev_boxes, unsigned long long *dev_mask) { const int row_start = blockIdx.y; const int col_start = blockIdx.x; // if (row_start > col_start) return; const int row_size = min(n_boxes - row_start * threadsPerBlock, threadsPerBlock); const int col_size = min(n_boxes - col_start * threadsPerBlock, threadsPerBlock); __shared__ float block_boxes[threadsPerBlock * 5]; if (threadIdx.x < col_size) { block_boxes[threadIdx.x * 5 + 0] = dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 0]; block_boxes[threadIdx.x * 5 + 1] = dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 1]; block_boxes[threadIdx.x * 5 + 2] = dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 2]; block_boxes[threadIdx.x * 5 + 3] = dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 3]; block_boxes[threadIdx.x * 5 + 4] = dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 4]; } __syncthreads(); if (threadIdx.x < row_size) { const int cur_box_idx = threadsPerBlock * row_start + threadIdx.x; const float *cur_box = dev_boxes + cur_box_idx * 5; int i = 0; unsigned long long t = 0; int start = 0; if (row_start == col_start) { start = threadIdx.x + 1; } for (i = start; i < col_size; i++) { if (devIoU(cur_box, block_boxes + i * 5) > nms_overlap_thresh) { t |= 1ULL << i; } } const int col_blocks = DIVUP(n_boxes, threadsPerBlock); dev_mask[cur_box_idx * col_blocks + col_start] = t; } } void _set_device(int device_id) { int current_device; CUDA_CHECK(hipGetDevice(&current_device)); if (current_device == device_id) { return; } // The call to hipSetDevice must come before any calls to Get, which // may perform initialization using the GPU. CUDA_CHECK(hipSetDevice(device_id)); } void _nms(int* keep_out, int* num_out, const float* boxes_host, int boxes_num, int boxes_dim, float nms_overlap_thresh, int device_id) { _set_device(device_id); float* boxes_dev = NULL; unsigned long long* mask_dev = NULL; const int col_blocks = DIVUP(boxes_num, threadsPerBlock); CUDA_CHECK(hipMalloc(&boxes_dev, boxes_num * boxes_dim * sizeof(float))); CUDA_CHECK(hipMemcpy(boxes_dev, boxes_host, boxes_num * boxes_dim * sizeof(float), hipMemcpyHostToDevice)); CUDA_CHECK(hipMalloc(&mask_dev, boxes_num * col_blocks * sizeof(unsigned long long))); dim3 blocks(DIVUP(boxes_num, threadsPerBlock), DIVUP(boxes_num, threadsPerBlock)); dim3 threads(threadsPerBlock); hipLaunchKernelGGL(( nms_kernel), dim3(blocks), dim3(threads), 0, 0, boxes_num, nms_overlap_thresh, boxes_dev, mask_dev); std::vector<unsigned long long> mask_host(boxes_num * col_blocks); CUDA_CHECK(hipMemcpy(&mask_host[0], mask_dev, sizeof(unsigned long long) * boxes_num * col_blocks, hipMemcpyDeviceToHost)); std::vector<unsigned long long> remv(col_blocks); memset(&remv[0], 0, sizeof(unsigned long long) * col_blocks); int num_to_keep = 0; for (int i = 0; i < boxes_num; i++) { int nblock = i / threadsPerBlock; int inblock = i % threadsPerBlock; if (!(remv[nblock] & (1ULL << inblock))) { keep_out[num_to_keep++] = i; unsigned long long *p = &mask_host[0] + i * col_blocks; for (int j = nblock; j < col_blocks; j++) { remv[j] |= p[j]; } } } *num_out = num_to_keep; CUDA_CHECK(hipFree(boxes_dev)); CUDA_CHECK(hipFree(mask_dev)); }
29fc2e46b1a0edbe8cf8428aca749cadf740ed84.cu
// ------------------------------------------------------------------ // Faster R-CNN // Copyright (c) 2015 Microsoft // Licensed under The MIT License [see fast-rcnn/LICENSE for details] // Written by Shaoqing Ren // ------------------------------------------------------------------ #include "gpu_nms.hpp" #include <vector> #include <iostream> #define CUDA_CHECK(condition) \ /* Code block avoids redefinition of cudaError_t error */ \ do { \ cudaError_t error = condition; \ if (error != cudaSuccess) { \ std::cout << cudaGetErrorString(error) << std::endl; \ } \ } while (0) #define DIVUP(m,n) ((m) / (n) + ((m) % (n) > 0)) int const threadsPerBlock = sizeof(unsigned long long) * 8; __device__ inline float devIoU(float const * const a, float const * const b) { float left = max(a[0], b[0]), right = min(a[2], b[2]); float top = max(a[1], b[1]), bottom = min(a[3], b[3]); float width = max(right - left + 1, 0.f), height = max(bottom - top + 1, 0.f); float interS = width * height; float Sa = (a[2] - a[0] + 1) * (a[3] - a[1] + 1); float Sb = (b[2] - b[0] + 1) * (b[3] - b[1] + 1); return interS / (Sa + Sb - interS); } __global__ void nms_kernel(const int n_boxes, const float nms_overlap_thresh, const float *dev_boxes, unsigned long long *dev_mask) { const int row_start = blockIdx.y; const int col_start = blockIdx.x; // if (row_start > col_start) return; const int row_size = min(n_boxes - row_start * threadsPerBlock, threadsPerBlock); const int col_size = min(n_boxes - col_start * threadsPerBlock, threadsPerBlock); __shared__ float block_boxes[threadsPerBlock * 5]; if (threadIdx.x < col_size) { block_boxes[threadIdx.x * 5 + 0] = dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 0]; block_boxes[threadIdx.x * 5 + 1] = dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 1]; block_boxes[threadIdx.x * 5 + 2] = dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 2]; block_boxes[threadIdx.x * 5 + 3] = dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 3]; block_boxes[threadIdx.x * 5 + 4] = dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 4]; } __syncthreads(); if (threadIdx.x < row_size) { const int cur_box_idx = threadsPerBlock * row_start + threadIdx.x; const float *cur_box = dev_boxes + cur_box_idx * 5; int i = 0; unsigned long long t = 0; int start = 0; if (row_start == col_start) { start = threadIdx.x + 1; } for (i = start; i < col_size; i++) { if (devIoU(cur_box, block_boxes + i * 5) > nms_overlap_thresh) { t |= 1ULL << i; } } const int col_blocks = DIVUP(n_boxes, threadsPerBlock); dev_mask[cur_box_idx * col_blocks + col_start] = t; } } void _set_device(int device_id) { int current_device; CUDA_CHECK(cudaGetDevice(&current_device)); if (current_device == device_id) { return; } // The call to cudaSetDevice must come before any calls to Get, which // may perform initialization using the GPU. CUDA_CHECK(cudaSetDevice(device_id)); } void _nms(int* keep_out, int* num_out, const float* boxes_host, int boxes_num, int boxes_dim, float nms_overlap_thresh, int device_id) { _set_device(device_id); float* boxes_dev = NULL; unsigned long long* mask_dev = NULL; const int col_blocks = DIVUP(boxes_num, threadsPerBlock); CUDA_CHECK(cudaMalloc(&boxes_dev, boxes_num * boxes_dim * sizeof(float))); CUDA_CHECK(cudaMemcpy(boxes_dev, boxes_host, boxes_num * boxes_dim * sizeof(float), cudaMemcpyHostToDevice)); CUDA_CHECK(cudaMalloc(&mask_dev, boxes_num * col_blocks * sizeof(unsigned long long))); dim3 blocks(DIVUP(boxes_num, threadsPerBlock), DIVUP(boxes_num, threadsPerBlock)); dim3 threads(threadsPerBlock); nms_kernel<<<blocks, threads>>>(boxes_num, nms_overlap_thresh, boxes_dev, mask_dev); std::vector<unsigned long long> mask_host(boxes_num * col_blocks); CUDA_CHECK(cudaMemcpy(&mask_host[0], mask_dev, sizeof(unsigned long long) * boxes_num * col_blocks, cudaMemcpyDeviceToHost)); std::vector<unsigned long long> remv(col_blocks); memset(&remv[0], 0, sizeof(unsigned long long) * col_blocks); int num_to_keep = 0; for (int i = 0; i < boxes_num; i++) { int nblock = i / threadsPerBlock; int inblock = i % threadsPerBlock; if (!(remv[nblock] & (1ULL << inblock))) { keep_out[num_to_keep++] = i; unsigned long long *p = &mask_host[0] + i * col_blocks; for (int j = nblock; j < col_blocks; j++) { remv[j] |= p[j]; } } } *num_out = num_to_keep; CUDA_CHECK(cudaFree(boxes_dev)); CUDA_CHECK(cudaFree(mask_dev)); }
087cb71580a83e2231d37d86be2b2d5b99965c9d.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include "FFT_stockham.cuh" #define S_NUM 1 void ExeFft(int N1, int N2,float2* h_dataI, float2* h_dataO, int k) { float2 *d_dataI; float2 *d_dataO; float2 *round_one; float2 *round_two; float2 *h_dataO_temp; round_one = (float2 *)malloc(N1*N2*sizeof(float2)); round_two = (float2 *)malloc(N2*N1*sizeof(float2)); float2 *d_round_one; float2 *d_round_two; CUDA_SAFE_CALL(hipMalloc((void**)&d_round_one, N1*S_NUM*sizeof(float2))); CUDA_SAFE_CALL(hipMalloc((void**)&d_dataO, N1*S_NUM*sizeof(float2))); unsigned int timer = 0; cutCreateTimer(&timer); cutStartTimer(timer); hipStream_t* cudastream; Transform(h_dataI, round_one, N2, N1); cudastream = new hipStream_t[S_NUM]; for (int i=0;i<N2;i++) { CUDA_SAFE_CALL(hipStreamCreate(cudastream+i%S_NUM)); CUDA_SAFE_CALL(hipMemcpyAsync(d_round_one + (i%S_NUM)*N1, round_one + i*N1, N1*sizeof(float2), hipMemcpyHostToDevice, cudastream[i%S_NUM])); DoFft(N1, 1, d_round_one + (i%S_NUM)*N1, d_dataO + (i%S_NUM)*N1 , k, cudastream[i%S_NUM]); CUDA_SAFE_CALL(hipMemcpyAsync(round_one + i*N1, d_dataO + (i%S_NUM)*N1, sizeof(float2)*N1, hipMemcpyDeviceToHost, cudastream[i%S_NUM])); } hipDeviceSynchronize(); delete[] cudastream; CUDA_SAFE_CALL(hipFree(d_round_one)); CUDA_SAFE_CALL(hipMalloc((void**)&d_round_two, N2*S_NUM*sizeof(float2))); CUDA_SAFE_CALL(hipFree(d_dataO)); CUDA_SAFE_CALL(hipMalloc((void**)&d_dataO, N2*S_NUM*sizeof(float2))); clock_t start_t, end_t; start_t = clock(); Transform(round_one, round_two, N1, N2); whirl_factor(round_two, round_two, N1, N2); end_t = clock(); cout << "\tsh time:\t" << end_t-start_t << "\t" << N1 << "\t" << N2<< endl; h_dataO_temp = round_one; cudastream = new hipStream_t[S_NUM]; for (int i=0;i<N1;i++) { CUDA_SAFE_CALL(hipStreamCreate(cudastream+i%S_NUM)); CUDA_SAFE_CALL(hipMemcpyAsync(d_round_two+ (i%S_NUM)*N2, round_two + i*N2, N2*sizeof(float2), hipMemcpyHostToDevice, cudastream[i%S_NUM])); DoFft(N2, 1, d_round_two + (i%S_NUM)*N2, d_dataO + (i%S_NUM)*N2, k, cudastream[i%S_NUM]); CUDA_SAFE_CALL(hipMemcpyAsync(h_dataO_temp + i*N2, d_dataO + (i%S_NUM)*N2, N2*sizeof(float2), hipMemcpyDeviceToHost, cudastream[i%S_NUM])); } hipDeviceSynchronize();// cutStopTimer(timer); float t = cutGetTimerValue(timer); cutDeleteTimer(timer); cout << "sh time:\t" << t << "\t" << N1 << "\t" << N2<< endl; for (int i=0;i<N1;i++) { for (int j=0;j<N2;j++) { h_dataO[j*N1+i] = h_dataO_temp[i*N2+j]; } } delete[] cudastream; delete[] round_one; delete[] round_two; CUDA_SAFE_CALL(hipFree(d_round_two)); } void DoFft(int N, int cN,float2* dataI, float2* dataO, int k, hipStream_t cudastream) { int R = 2; int T = (N/R<THREAD_X)? N/R:THREAD_X; int BX = ((N-1)/(R*T) + 1<65536)? ((N-1)/(R*T) + 1):65536; int BY = cN*(-1)*(k - 1)*M_FACTOR/2;// if (BY==0) { BY = cN; } dim3 dimgrid(BX,BY,1); dim3 dimblock(T,1,1); float2* temp = dataO; float2* dataIn=dataI; for (int Ns=1; Ns<N; Ns*=R) { hipLaunchKernelGGL(( GPU_FFT_stockham), dim3(dimgrid), dim3(dimblock), 0, cudastream, N, R, Ns, dataIn, temp, k); hipDeviceSynchronize(); float2 *change; change = temp; temp = dataIn; dataIn = change; } if (dataIn != dataO) { hipMemcpyAsync(dataO,dataIn,sizeof(float2)*N*BY, hipMemcpyDeviceToDevice, cudastream); } } void Transform(float2* dataIn, float2* dataOut, int N1, int N2) //float2* d_dataIn, float2* d_dataOut, int N1, int N2 { //FermiCUDA //Whitepaper //NVIDIAs Next Generation // CUDATM Compute Architecture: // FermiTM //dim3 threads(16,16,1); //dim3 blocks(1,1,1); //blocks.x = (N1+threads.x-1)/threads.x; //blocks.y = (N2+threads.y-1)/threads.y; //Trans<<<blocks, threads>>>(d_dataIn, d_dataOut, N1, N2); int idin; int idout; for (int i=0;i<N1;i++) { for (int j=0;j<N2;j++) { idin = j*N1+i; idout = i*N2+j; dataOut[idout].x = dataIn[idin].x; dataOut[idout].y = dataIn[idin].y; } } return ; } void whirl_factor(float2* dataI, float2 *dataO, int N1, int N2) { //A4(k,j) = cos(2*pi*(k-1)*(j-1)/(n1*n2))-(-1)^0.5*sin(2*pi*(k-1)*(j-1)/(n1*n2)); //dim3 blocks; //dim3 threads; int index; float id_x; float id_y; for (int i=0;i<N1;i++) { for (int j=0;j<N2;j++) { id_x = i; id_y = j; index = id_x * N2 + id_y; float2 w; float an = 2.0*M_PI*(id_x)*(id_y)/(N1*N2); w.x = cos(an); w.y = -sin(an); dataO[index] = h_multi(w, dataI[index]); } } } __global__ void GPU_FFT_stockham(int N, int R, int Ns,float2* dataI, float2* dataO ,int k) { int b, T, t; b = blockIdx.x; T = blockDim.x; t = threadIdx.x; int j = (blockIdx.x)*T + t; if (j< N/R) { FftIteration(j, N, R, Ns, dataI+blockIdx.y*N, dataO+blockIdx.y*N, k); } } __device__ void FftIteration(int j, int N, int R, int Ns, float2* data0, float2* data1, int k) { float2 v[2]; //float2 v[4]; //float2 v[8]; //float2 v[16]; int b = blockIdx.x; int t = threadIdx.x; int T = blockDim.x; int idxS = j; float angle = (-2) * M_PI * (j%Ns) / (Ns*R); for (int r= 0;r<R;r++) { v[r].x = data0[idxS + r*N/R].x; v[r].y = k*data0[idxS + r*N/R].y; float2 temp; temp = v[r]; v[r].x = temp.x*__cosf(angle*r) - temp.y*__sinf(angle*r); v[r].y = temp.y*__cosf(angle*r) + temp.x*__sinf(angle*r); } FFT_2(v); //FFT_4(v); //FFT_8(v); //FFT_16(v); int idxD; idxD = expand(j, Ns, R); for (int r=0;r<R;r++) { data1[idxD+r*Ns].x = v[r].x; data1[idxD+r*Ns].y = k*v[r].y; } /*idxD = (t/Ns)*R + (t%Ns); exchange(v, R, 1, idxD, Ns, j, T); idxD = b * T * R + t; for (int r=0;r<R;r++) { data1[idxD+r*T] = v[r]; }*/ return ; } __device__ void FFT_2(float2* v) { float2 v0; v0.x = v[0].x; v0.y = v[0].y; v[0].x = v0.x + v[1].x; v[0].y = v0.y + v[1].y; v[1].x = v0.x - v[1].x; v[1].y = v0.y - v[1].y; } __device__ int expand(int idxL, int N1,int N2) { return ((idxL/N1)*N1*N2 + (idxL%N1)); } __device__ float2 multi(float2 a, float2 b) { float2 c; c.x = a.x*b.x - a.y*b.y; c.y = a.x*b.y + a.y*b.x; return c; } //__device__ void FFT(float2* v) //{ // float2 v0[16], v1[16]; // for (int i=0;i<16;i++) // { // v0[i] = v[i]; // } // // for (int n=0;n<16;n++) // { // v[n].x = 0; // v[n].y = 0; // for (int k=0;k<R;k++) // { // v1[k].x = __cosf(k*n*M_PI/8); // v1[k].y = -1*__sinf(k*n*M_PI/8); // // v[n].x += multi(v0[k], v1[k]).x; // v[n].y += multi(v0[k], v1[k]).y; // // } // } // return ; //} __global__ void Trans(float2* d_dataIn, float2* d_dataOut, int N1, int N2) { //int tidx = threadIdx.x; //int tidy = threadIdx.y; //int bidx = blockIdx.x; //int bidy = blockIdx.y; //int index = (bidy*gridDim.x + bidx)*(blockDim.x*blockDim.y) + tidy*blockDim.x + tidx; //int id_x,id_y; //id_x = index%N1; //id_y = index/N1; //int total = gridDim.x*gridDim.y*(blockDim.x*blockDim.y); //while((tidx+(blockDim.x*bidx))<N1&&(tidy+(blockDim.y*bidy))<N2&&(id_x<id_y)) //{ // float2 tempx; // float2 tempy; // tempx.x = d_dataIn[id_x + id_y*N1].x; // tempx.y = d_dataIn[id_x + id_y*N1].y; // tempy.x = d_dataIn[id_y + id_x*N1].x; // tempy.y = d_dataIn[id_y + id_x*N1].y; // d_dataOut[id_x].x = tempy.x; // d_dataOut[id_x].y = tempy.y; // d_dataOut[id_y].x = tempx.x; // d_dataOut[id_y].y = tempx.y; // index += total; // id_x = index%N1; // id_y = index/N1; //} } __global__ void whirl(float2* d_dataI, float2 *d_dataO, int N1, int N2) { int tidx = threadIdx.x; int tidy = threadIdx.y; int bidx = blockIdx.x; int bidy = blockIdx.y; int index = (bidy*gridDim.x + bidx)*(blockDim.x*blockDim.y) + tidy*blockDim.x + tidx; int id_x,id_y; id_x = index%N1; id_y = index/N1; int total = gridDim.x*gridDim.y*(blockDim.x*blockDim.y); while((tidx+(blockDim.x*bidx))<N1&&(tidy+(blockDim.y*bidy))<N2&&(id_x<id_y)) { //A4(k,j) = cos(2*pi*(k-1)*(j-1)/(n1*n2))-(-1)^0.5*sin(2*pi*(k-1)*(j-1)/(n1*n2)); float2 w; w.x = __cosf(2*M_PI*(id_x)*(id_y)/(N1*N2)); w.y = -__sinf(2*M_PI*(id_x)*(id_y)/(N1*N2)); d_dataO[index].x = multi(w, d_dataI[index]).x; d_dataO[index].y = multi(w, d_dataI[index]).y; index += total; id_x = index%N1; id_y = index/N1; } } float2 h_multi(float2 a, float2 b) { float2 c; c.x = a.x*b.x - a.y*b.y; c.y = a.x*b.y + a.y*b.x; return c; }
087cb71580a83e2231d37d86be2b2d5b99965c9d.cu
#include "FFT_stockham.cuh" #define S_NUM 1 void ExeFft(int N1, int N2,float2* h_dataI, float2* h_dataO, int k) { float2 *d_dataI; float2 *d_dataO; float2 *round_one; float2 *round_two; float2 *h_dataO_temp; round_one = (float2 *)malloc(N1*N2*sizeof(float2)); round_two = (float2 *)malloc(N2*N1*sizeof(float2)); float2 *d_round_one; float2 *d_round_two; CUDA_SAFE_CALL(cudaMalloc((void**)&d_round_one, N1*S_NUM*sizeof(float2))); CUDA_SAFE_CALL(cudaMalloc((void**)&d_dataO, N1*S_NUM*sizeof(float2))); unsigned int timer = 0; cutCreateTimer(&timer); cutStartTimer(timer); cudaStream_t* cudastream; Transform(h_dataI, round_one, N2, N1); cudastream = new cudaStream_t[S_NUM]; for (int i=0;i<N2;i++) { CUDA_SAFE_CALL(cudaStreamCreate(cudastream+i%S_NUM)); CUDA_SAFE_CALL(cudaMemcpyAsync(d_round_one + (i%S_NUM)*N1, round_one + i*N1, N1*sizeof(float2), cudaMemcpyHostToDevice, cudastream[i%S_NUM])); DoFft(N1, 1, d_round_one + (i%S_NUM)*N1, d_dataO + (i%S_NUM)*N1 , k, cudastream[i%S_NUM]); CUDA_SAFE_CALL(cudaMemcpyAsync(round_one + i*N1, d_dataO + (i%S_NUM)*N1, sizeof(float2)*N1, cudaMemcpyDeviceToHost, cudastream[i%S_NUM])); } cudaThreadSynchronize(); delete[] cudastream; CUDA_SAFE_CALL(cudaFree(d_round_one)); CUDA_SAFE_CALL(cudaMalloc((void**)&d_round_two, N2*S_NUM*sizeof(float2))); CUDA_SAFE_CALL(cudaFree(d_dataO)); CUDA_SAFE_CALL(cudaMalloc((void**)&d_dataO, N2*S_NUM*sizeof(float2))); clock_t start_t, end_t; start_t = clock(); Transform(round_one, round_two, N1, N2); whirl_factor(round_two, round_two, N1, N2); end_t = clock(); cout << "\tsh time:\t" << end_t-start_t << "\t" << N1 << "\t" << N2<< endl; h_dataO_temp = round_one; cudastream = new cudaStream_t[S_NUM]; for (int i=0;i<N1;i++) { CUDA_SAFE_CALL(cudaStreamCreate(cudastream+i%S_NUM)); CUDA_SAFE_CALL(cudaMemcpyAsync(d_round_two+ (i%S_NUM)*N2, round_two + i*N2, N2*sizeof(float2), cudaMemcpyHostToDevice, cudastream[i%S_NUM])); DoFft(N2, 1, d_round_two + (i%S_NUM)*N2, d_dataO + (i%S_NUM)*N2, k, cudastream[i%S_NUM]); CUDA_SAFE_CALL(cudaMemcpyAsync(h_dataO_temp + i*N2, d_dataO + (i%S_NUM)*N2, N2*sizeof(float2), cudaMemcpyDeviceToHost, cudastream[i%S_NUM])); } cudaThreadSynchronize();//同步操作,保证操作的一致性 cutStopTimer(timer); float t = cutGetTimerValue(timer); cutDeleteTimer(timer); cout << "sh time:\t" << t << "\t" << N1 << "\t" << N2<< endl; for (int i=0;i<N1;i++) { for (int j=0;j<N2;j++) { h_dataO[j*N1+i] = h_dataO_temp[i*N2+j]; } } delete[] cudastream; delete[] round_one; delete[] round_two; CUDA_SAFE_CALL(cudaFree(d_round_two)); } void DoFft(int N, int cN,float2* dataI, float2* dataO, int k, cudaStream_t cudastream) { int R = 2; int T = (N/R<THREAD_X)? N/R:THREAD_X; int BX = ((N-1)/(R*T) + 1<65536)? ((N-1)/(R*T) + 1):65536; int BY = cN*(-1)*(k - 1)*M_FACTOR/2;//为了小波变换的变通道数 表达式 if (BY==0) { BY = cN; } dim3 dimgrid(BX,BY,1); dim3 dimblock(T,1,1); float2* temp = dataO; float2* dataIn=dataI; for (int Ns=1; Ns<N; Ns*=R) { GPU_FFT_stockham<<<dimgrid, dimblock, 0, cudastream>>>(N, R, Ns, dataIn, temp, k); cudaThreadSynchronize(); float2 *change; change = temp; temp = dataIn; dataIn = change; } if (dataIn != dataO) { cudaMemcpyAsync(dataO,dataIn,sizeof(float2)*N*BY, cudaMemcpyDeviceToDevice, cudastream); } } void Transform(float2* dataIn, float2* dataOut, int N1, int N2) //float2* d_dataIn, float2* d_dataOut, int N1, int N2 { //Fermi架构CUDA编程与优化 //Whitepaper //NVIDIA’s Next Generation // CUDATM Compute Architecture: // FermiTM //dim3 threads(16,16,1); //dim3 blocks(1,1,1); //blocks.x = (N1+threads.x-1)/threads.x; //blocks.y = (N2+threads.y-1)/threads.y; //Trans<<<blocks, threads>>>(d_dataIn, d_dataOut, N1, N2); int idin; int idout; for (int i=0;i<N1;i++) { for (int j=0;j<N2;j++) { idin = j*N1+i; idout = i*N2+j; dataOut[idout].x = dataIn[idin].x; dataOut[idout].y = dataIn[idin].y; } } return ; } void whirl_factor(float2* dataI, float2 *dataO, int N1, int N2) { //A4(k,j) = cos(2*pi*(k-1)*(j-1)/(n1*n2))-(-1)^0.5*sin(2*pi*(k-1)*(j-1)/(n1*n2)); //dim3 blocks; //dim3 threads; int index; float id_x; float id_y; for (int i=0;i<N1;i++) { for (int j=0;j<N2;j++) { id_x = i; id_y = j; index = id_x * N2 + id_y; float2 w; float an = 2.0*M_PI*(id_x)*(id_y)/(N1*N2); w.x = cos(an); w.y = -sin(an); dataO[index] = h_multi(w, dataI[index]); } } } __global__ void GPU_FFT_stockham(int N, int R, int Ns,float2* dataI, float2* dataO ,int k) { int b, T, t; b = blockIdx.x; T = blockDim.x; t = threadIdx.x; int j = (blockIdx.x)*T + t; if (j< N/R) { FftIteration(j, N, R, Ns, dataI+blockIdx.y*N, dataO+blockIdx.y*N, k); } } __device__ void FftIteration(int j, int N, int R, int Ns, float2* data0, float2* data1, int k) { float2 v[2]; //float2 v[4]; //float2 v[8]; //float2 v[16]; int b = blockIdx.x; int t = threadIdx.x; int T = blockDim.x; int idxS = j; float angle = (-2) * M_PI * (j%Ns) / (Ns*R); for (int r= 0;r<R;r++) { v[r].x = data0[idxS + r*N/R].x; v[r].y = k*data0[idxS + r*N/R].y; float2 temp; temp = v[r]; v[r].x = temp.x*__cosf(angle*r) - temp.y*__sinf(angle*r); v[r].y = temp.y*__cosf(angle*r) + temp.x*__sinf(angle*r); } FFT_2(v); //FFT_4(v); //FFT_8(v); //FFT_16(v); int idxD; idxD = expand(j, Ns, R); for (int r=0;r<R;r++) { data1[idxD+r*Ns].x = v[r].x; data1[idxD+r*Ns].y = k*v[r].y; } /*idxD = (t/Ns)*R + (t%Ns); exchange(v, R, 1, idxD, Ns, j, T); idxD = b * T * R + t; for (int r=0;r<R;r++) { data1[idxD+r*T] = v[r]; }*/ return ; } __device__ void FFT_2(float2* v) { float2 v0; v0.x = v[0].x; v0.y = v[0].y; v[0].x = v0.x + v[1].x; v[0].y = v0.y + v[1].y; v[1].x = v0.x - v[1].x; v[1].y = v0.y - v[1].y; } __device__ int expand(int idxL, int N1,int N2) { return ((idxL/N1)*N1*N2 + (idxL%N1)); } __device__ float2 multi(float2 a, float2 b) { float2 c; c.x = a.x*b.x - a.y*b.y; c.y = a.x*b.y + a.y*b.x; return c; } //__device__ void FFT(float2* v) //{ // float2 v0[16], v1[16]; // for (int i=0;i<16;i++) // { // v0[i] = v[i]; // } // // for (int n=0;n<16;n++) // { // v[n].x = 0; // v[n].y = 0; // for (int k=0;k<R;k++) // { // v1[k].x = __cosf(k*n*M_PI/8); // v1[k].y = -1*__sinf(k*n*M_PI/8); // // v[n].x += multi(v0[k], v1[k]).x; // v[n].y += multi(v0[k], v1[k]).y; // // } // } // return ; //} __global__ void Trans(float2* d_dataIn, float2* d_dataOut, int N1, int N2) { //int tidx = threadIdx.x; //int tidy = threadIdx.y; //int bidx = blockIdx.x; //int bidy = blockIdx.y; //int index = (bidy*gridDim.x + bidx)*(blockDim.x*blockDim.y) + tidy*blockDim.x + tidx; //int id_x,id_y; //id_x = index%N1; //id_y = index/N1; //int total = gridDim.x*gridDim.y*(blockDim.x*blockDim.y); //while((tidx+(blockDim.x*bidx))<N1&&(tidy+(blockDim.y*bidy))<N2&&(id_x<id_y)) //{ // float2 tempx; // float2 tempy; // tempx.x = d_dataIn[id_x + id_y*N1].x; // tempx.y = d_dataIn[id_x + id_y*N1].y; // tempy.x = d_dataIn[id_y + id_x*N1].x; // tempy.y = d_dataIn[id_y + id_x*N1].y; // d_dataOut[id_x].x = tempy.x; // d_dataOut[id_x].y = tempy.y; // d_dataOut[id_y].x = tempx.x; // d_dataOut[id_y].y = tempx.y; // index += total; // id_x = index%N1; // id_y = index/N1; //} } __global__ void whirl(float2* d_dataI, float2 *d_dataO, int N1, int N2) { int tidx = threadIdx.x; int tidy = threadIdx.y; int bidx = blockIdx.x; int bidy = blockIdx.y; int index = (bidy*gridDim.x + bidx)*(blockDim.x*blockDim.y) + tidy*blockDim.x + tidx; int id_x,id_y; id_x = index%N1; id_y = index/N1; int total = gridDim.x*gridDim.y*(blockDim.x*blockDim.y); while((tidx+(blockDim.x*bidx))<N1&&(tidy+(blockDim.y*bidy))<N2&&(id_x<id_y)) { //A4(k,j) = cos(2*pi*(k-1)*(j-1)/(n1*n2))-(-1)^0.5*sin(2*pi*(k-1)*(j-1)/(n1*n2)); float2 w; w.x = __cosf(2*M_PI*(id_x)*(id_y)/(N1*N2)); w.y = -__sinf(2*M_PI*(id_x)*(id_y)/(N1*N2)); d_dataO[index].x = multi(w, d_dataI[index]).x; d_dataO[index].y = multi(w, d_dataI[index]).y; index += total; id_x = index%N1; id_y = index/N1; } } float2 h_multi(float2 a, float2 b) { float2 c; c.x = a.x*b.x - a.y*b.y; c.y = a.x*b.y + a.y*b.x; return c; }
089960e16484dbd01583c70820e55841ccb5fd44.hip
// !!! This is a file automatically generated by hipify!!! #include <iostream> #include <string> #include <stdio.h> #include "../utils.hpp" size_t numRows(); //return # of rows in the image size_t numCols(); //return # of cols in the image void preProcess(uchar4 **h_inputImageRGBA, uchar4 **h_outputImageRGBA, uchar4 **d_inputImageRGBA, uchar4 **d_outputImageRGBA, unsigned char **d_redBlurred, unsigned char **d_greenBlurred, unsigned char **d_blueBlurred, const std::string& filename); void postProcess(const std::string& output_file); void your_gaussian_blur(const uchar4 * const h_inputImageRGBA, uchar4 * const d_inputImageRGBA, uchar4* const d_outputImageRGBA, const size_t numRows, const size_t numCols, unsigned char *d_redBlurred, unsigned char *d_greenBlurred, unsigned char *d_blueBlurred, const int filterWidth); void allocateMemoryAndCopyToGPU(const size_t numRowsImage, const size_t numColsImage, const float* const h_filter, const size_t filterWidth); void cleanup(); //include the definitions of the above functions for this homework #include "HW2.cu" int main(int argc, char **argv) { uchar4 *h_inputImageRGBA, *d_inputImageRGBA; uchar4 *h_outputImageRGBA, *d_outputImageRGBA; unsigned char *d_redBlurred, *d_greenBlurred, *d_blueBlurred; float *h_filter; int filterWidth; std::string input_file; std::string output_file; if (argc == 3) { input_file = std::string(argv[1]); output_file = std::string(argv[2]); } else { std::cerr << "Usage: ./hw input_file output_file" << std::endl; exit(1); } //load the image and give us our input and output pointers preProcess(&h_inputImageRGBA, &h_outputImageRGBA, &d_inputImageRGBA, &d_outputImageRGBA, &d_redBlurred, &d_greenBlurred, &d_blueBlurred, &h_filter, &filterWidth, input_file); allocateMemoryAndCopyToGPU(numRows(), numCols(), h_filter, filterWidth); //call the students' code std::cout << "preprocess, allocation ok\n"; your_gaussian_blur(h_inputImageRGBA, d_inputImageRGBA, d_outputImageRGBA, numRows(), numCols(), d_redBlurred, d_greenBlurred, d_blueBlurred, filterWidth); std::cout << "gaussian blur ok\n"; hipDeviceSynchronize(); checkCudaErrors(hipGetLastError()); cleanup(); //check results and output the blurred image postProcess(output_file); std::cout << "postprocess and cleanup ok\n"; checkCudaErrors(hipFree(d_redBlurred)); checkCudaErrors(hipFree(d_greenBlurred)); checkCudaErrors(hipFree(d_blueBlurred)); std::cout << "Done!"; return 0; }
089960e16484dbd01583c70820e55841ccb5fd44.cu
#include <iostream> #include <string> #include <stdio.h> #include "../utils.hpp" size_t numRows(); //return # of rows in the image size_t numCols(); //return # of cols in the image void preProcess(uchar4 **h_inputImageRGBA, uchar4 **h_outputImageRGBA, uchar4 **d_inputImageRGBA, uchar4 **d_outputImageRGBA, unsigned char **d_redBlurred, unsigned char **d_greenBlurred, unsigned char **d_blueBlurred, const std::string& filename); void postProcess(const std::string& output_file); void your_gaussian_blur(const uchar4 * const h_inputImageRGBA, uchar4 * const d_inputImageRGBA, uchar4* const d_outputImageRGBA, const size_t numRows, const size_t numCols, unsigned char *d_redBlurred, unsigned char *d_greenBlurred, unsigned char *d_blueBlurred, const int filterWidth); void allocateMemoryAndCopyToGPU(const size_t numRowsImage, const size_t numColsImage, const float* const h_filter, const size_t filterWidth); void cleanup(); //include the definitions of the above functions for this homework #include "HW2.cu" int main(int argc, char **argv) { uchar4 *h_inputImageRGBA, *d_inputImageRGBA; uchar4 *h_outputImageRGBA, *d_outputImageRGBA; unsigned char *d_redBlurred, *d_greenBlurred, *d_blueBlurred; float *h_filter; int filterWidth; std::string input_file; std::string output_file; if (argc == 3) { input_file = std::string(argv[1]); output_file = std::string(argv[2]); } else { std::cerr << "Usage: ./hw input_file output_file" << std::endl; exit(1); } //load the image and give us our input and output pointers preProcess(&h_inputImageRGBA, &h_outputImageRGBA, &d_inputImageRGBA, &d_outputImageRGBA, &d_redBlurred, &d_greenBlurred, &d_blueBlurred, &h_filter, &filterWidth, input_file); allocateMemoryAndCopyToGPU(numRows(), numCols(), h_filter, filterWidth); //call the students' code std::cout << "preprocess, allocation ok\n"; your_gaussian_blur(h_inputImageRGBA, d_inputImageRGBA, d_outputImageRGBA, numRows(), numCols(), d_redBlurred, d_greenBlurred, d_blueBlurred, filterWidth); std::cout << "gaussian blur ok\n"; cudaDeviceSynchronize(); checkCudaErrors(cudaGetLastError()); cleanup(); //check results and output the blurred image postProcess(output_file); std::cout << "postprocess and cleanup ok\n"; checkCudaErrors(cudaFree(d_redBlurred)); checkCudaErrors(cudaFree(d_greenBlurred)); checkCudaErrors(cudaFree(d_blueBlurred)); std::cout << "Done!"; return 0; }
505ac7ebdbb1eaa6110123bd69dd551a7c23ae91.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include "includes.h" void printUsage(char* appName); int parseArgs(char** argv,int* pSize,int *print,int argc); uint64_t getTime(); __global__ void prime(int *a, int count) { int tid = blockIdx.x * blockDim.x + threadIdx.x; //Handle the data at the index if(tid > count) return; int can = a[tid]; int counter=3; //int flag=0; //float limit = sqrtf((float)can); float limit = sqrtf(can); limit = limit+1; // if even -- get out if(can%2==0) { a[tid] = 1; } else { for(;counter<=limit;counter+=2) { if(can%counter==0) { a[tid]=1; // set as prime break; } } } }
505ac7ebdbb1eaa6110123bd69dd551a7c23ae91.cu
#include "includes.h" void printUsage(char* appName); int parseArgs(char** argv,int* pSize,int *print,int argc); uint64_t getTime(); __global__ void prime(int *a, int count) { int tid = blockIdx.x * blockDim.x + threadIdx.x; //Handle the data at the index if(tid > count) return; int can = a[tid]; int counter=3; //int flag=0; //float limit = sqrtf((float)can); float limit = sqrtf(can); limit = limit+1; // if even -- get out if(can%2==0) { a[tid] = 1; } else { for(;counter<=limit;counter+=2) { if(can%counter==0) { a[tid]=1; // set as prime break; } } } }
90b964eb779654c82df0204d2bf382f74f792d62.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include "stdio.h" #define N 512 __global__ void dot(int *a, int *b, int *c){ __shared__ int temp[N]; temp[threadIdx.x] = a[threadIdx.x] * b[threadIdx.x]; //each thread computes a pairwise product // temp varible will be store in register of GPU // wait for each threads finished the treatmnt for its computation __syncthreads(); //Thread 0 sums the pairwise products // Only the threads 0 in each block can acces to the shared memory if ( 0 == threadIdx.x) { int sum = 0; for( int i =0; i < N ; i++) sum +=temp[i]; *c = sum; } } int main( void ){ int *a,*b,*c; // host copies of a, b and c int *dev_a,*dev_b, *dev_c; // device copies of a, b and c int size = N * sizeof(int); // we need space for an integer //allocate device copies of a, b , c hipMalloc((void**) &dev_a, size); hipMalloc((void**) &dev_b, size); hipMalloc((void**) &dev_c, sizeof(int)); a = (int*)malloc(size); b = (int*)malloc(size); c = (int*)malloc(sizeof(int)); for (int i= 0; i<N ; i++){ a[i]=i; b[i]=i*2; } //copy inputs to device (GPU) hipMemcpy(dev_a, a, size , hipMemcpyHostToDevice); hipMemcpy(dev_b, b, size, hipMemcpyHostToDevice); // launch add() kernel on GPU, passing parameters hipLaunchKernelGGL(( dot), dim3(1) , dim3(N) , 0, 0, dev_a,dev_b,dev_c); //copy device result back to host copy of c hipMemcpy(c, dev_c, sizeof(int), hipMemcpyDeviceToHost); printf("The sum is : %d\n", *c); free(a); free(b); free(c); hipFree(dev_a); hipFree(dev_b); hipFree(dev_c); return 0; }
90b964eb779654c82df0204d2bf382f74f792d62.cu
#include "stdio.h" #define N 512 __global__ void dot(int *a, int *b, int *c){ __shared__ int temp[N]; temp[threadIdx.x] = a[threadIdx.x] * b[threadIdx.x]; //each thread computes a pairwise product // temp varible will be store in register of GPU // wait for each threads finished the treatmnt for its computation __syncthreads(); //Thread 0 sums the pairwise products // Only the threads 0 in each block can acces to the shared memory if ( 0 == threadIdx.x) { int sum = 0; for( int i =0; i < N ; i++) sum +=temp[i]; *c = sum; } } int main( void ){ int *a,*b,*c; // host copies of a, b and c int *dev_a,*dev_b, *dev_c; // device copies of a, b and c int size = N * sizeof(int); // we need space for an integer //allocate device copies of a, b , c cudaMalloc((void**) &dev_a, size); cudaMalloc((void**) &dev_b, size); cudaMalloc((void**) &dev_c, sizeof(int)); a = (int*)malloc(size); b = (int*)malloc(size); c = (int*)malloc(sizeof(int)); for (int i= 0; i<N ; i++){ a[i]=i; b[i]=i*2; } //copy inputs to device (GPU) cudaMemcpy(dev_a, a, size , cudaMemcpyHostToDevice); cudaMemcpy(dev_b, b, size, cudaMemcpyHostToDevice); // launch add() kernel on GPU, passing parameters dot<<<1 , N >>> (dev_a,dev_b,dev_c); //copy device result back to host copy of c cudaMemcpy(c, dev_c, sizeof(int), cudaMemcpyDeviceToHost); printf("The sum is : %d\n", *c); free(a); free(b); free(c); cudaFree(dev_a); cudaFree(dev_b); cudaFree(dev_c); return 0; }
29aa997c8aeea85c760f17a8176931c4a8acbece.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" /* Copyright (c) 2013-2014, Gregory P. Meyer University of Illinois Board of Trustees All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder(s) nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <dip/common/error.h> #include <dip/common/macros.h> #include <dip/common/types.h> #include <dip/surface/voxel.h> #define BLOCK_WIDTH 16 namespace dip { __constant__ float T[4][4]; __device__ bool interpolate(int volume_size, float volume_dimension, float voxel_dimension, float min_weight, const Voxel *volume, Vertex center, float vx, float vy, float vz, float &tsdf) { // Convert Vertex Position to Grid Position float gx, gy, gz; gx = (vx + (volume_dimension / 2.0f) - center.x) / voxel_dimension; gy = (vy + (volume_dimension / 2.0f) - center.y) / voxel_dimension; gz = (vz + (volume_dimension / 2.0f) - center.z) / voxel_dimension; float gx0, gy0, gz0; float gx1, gy1, gz1; gx0 = floor(gx); gx1 = gx0 + 1.0f; gy0 = floor(gy); gy1 = gy0 + 1.0f; gz0 = floor(gz); gz1 = gz0 + 1.0f; int i; float f000, f001, f010, f011, f100, f101, f110, f111; float w000, w001, w010, w011, w100, w101, w110, w111; i = (int)gx0 + (int)gy0 * volume_size + (int)gz0 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f000 = UNCOMPRESS_VALUE(volume[i]); w000 = UNCOMPRESS_WEIGHT(volume[i]); } else { f000 = 0.0f; w000 = 0.0f; } i = (int)gx0 + (int)gy0 * volume_size + (int)gz1 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f001 = UNCOMPRESS_VALUE(volume[i]); w001 = UNCOMPRESS_WEIGHT(volume[i]); } else { f001 = 0.0f; w001 = 0.0f; } i = (int)gx0 + (int)gy1 * volume_size + (int)gz0 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f010 = UNCOMPRESS_VALUE(volume[i]); w010 = UNCOMPRESS_WEIGHT(volume[i]); } else { f010 = 0.0f; w010 = 0.0f; } i = (int)gx0 + (int)gy1 * volume_size + (int)gz1 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f011 = UNCOMPRESS_VALUE(volume[i]); w011 = UNCOMPRESS_WEIGHT(volume[i]); } else { f011 = 0.0f; w011 = 0.0f; } i = (int)gx1 + (int)gy0 * volume_size + (int)gz0 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f100 = UNCOMPRESS_VALUE(volume[i]); w100 = UNCOMPRESS_WEIGHT(volume[i]); } else { f100 = 0.0f; w100 = 0.0f; } i = (int)gx1 + (int)gy0 * volume_size + (int)gz1 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f101 = UNCOMPRESS_VALUE(volume[i]); w101 = UNCOMPRESS_WEIGHT(volume[i]); } else { f101 = 0.0f; w101 = 0.0f; } i = (int)gx1 + (int)gy1 * volume_size + (int)gz0 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f110 = UNCOMPRESS_VALUE(volume[i]); w110 = UNCOMPRESS_WEIGHT(volume[i]); } else { f110 = 0.0f; w110 = 0.0f; } i = (int)gx1 + (int)gy1 * volume_size + (int)gz1 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f111 = UNCOMPRESS_VALUE(volume[i]); w111 = UNCOMPRESS_WEIGHT(volume[i]); } else { f111 = 0.0f; w111 = 0.0f; } if((w000 <= min_weight) || (w001 <= min_weight) || (w010 <= min_weight) || (w011 <= min_weight) || (w100 <= min_weight) || (w101 <= min_weight) || (w110 <= min_weight) || (w111 <= min_weight)) { return false; } float u, v, w; u = (gx - gx0); v = (gy - gy0); w = (gz - gz0); tsdf = (1 - u) * (1 - v) * (1 - w) * f000 + (1 - u) * (1 - v) * ( w) * f001 + (1 - u) * ( v) * (1 - w) * f010 + (1 - u) * ( v) * ( w) * f011 + ( u) * (1 - v) * (1 - w) * f100 + ( u) * (1 - v) * ( w) * f101 + ( u) * ( v) * (1 - w) * f110 + ( u) * ( v) * ( w) * f111; return true; } __device__ bool surface_normal(int volume_size, float volume_dimension, float voxel_dimension, float min_weight, const Voxel *volume, Vertex center, float vx, float vy, float vz, float &nx, float &ny, float &nz) { // Convert Vertex Position to Grid Position float gx, gy, gz; gx = (vx + (volume_dimension / 2.0f) - center.x) / voxel_dimension; gy = (vy + (volume_dimension / 2.0f) - center.y) / voxel_dimension; gz = (vz + (volume_dimension / 2.0f) - center.z) / voxel_dimension; float gx0, gy0, gz0; float gx1, gy1, gz1; gx0 = floor(gx); gx1 = gx0 + 1.0f; gy0 = floor(gy); gy1 = gy0 + 1.0f; gz0 = floor(gz); gz1 = gz0 + 1.0f; int i; float f000, f001, f010, f011, f100, f101, f110, f111; float w000, w001, w010, w011, w100, w101, w110, w111; i = (int)gx0 + (int)gy0 * volume_size + (int)gz0 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f000 = UNCOMPRESS_VALUE(volume[i]); w000 = UNCOMPRESS_WEIGHT(volume[i]); } else { f000 = 0.0f; w000 = 0.0f; } i = (int)gx0 + (int)gy0 * volume_size + (int)gz1 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f001 = UNCOMPRESS_VALUE(volume[i]); w001 = UNCOMPRESS_WEIGHT(volume[i]); } else { f001 = 0.0f; w001 = 0.0f; } i = (int)gx0 + (int)gy1 * volume_size + (int)gz0 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f010 = UNCOMPRESS_VALUE(volume[i]); w010 = UNCOMPRESS_WEIGHT(volume[i]); } else { f010 = 0.0f; w010 = 0.0f; } i = (int)gx0 + (int)gy1 * volume_size + (int)gz1 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f011 = UNCOMPRESS_VALUE(volume[i]); w011 = UNCOMPRESS_WEIGHT(volume[i]); } else { f011 = 0.0f; w011 = 0.0f; } i = (int)gx1 + (int)gy0 * volume_size + (int)gz0 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f100 = UNCOMPRESS_VALUE(volume[i]); w100 = UNCOMPRESS_WEIGHT(volume[i]); } else { f100 = 0.0f; w100 = 0.0f; } i = (int)gx1 + (int)gy0 * volume_size + (int)gz1 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f101 = UNCOMPRESS_VALUE(volume[i]); w101 = UNCOMPRESS_WEIGHT(volume[i]); } else { f101 = 0.0f; w101 = 0.0f; } i = (int)gx1 + (int)gy1 * volume_size + (int)gz0 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f110 = UNCOMPRESS_VALUE(volume[i]); w110 = UNCOMPRESS_WEIGHT(volume[i]); } else { f110 = 0.0f; w110 = 0.0f; } i = (int)gx1 + (int)gy1 * volume_size + (int)gz1 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f111 = UNCOMPRESS_VALUE(volume[i]); w111 = UNCOMPRESS_WEIGHT(volume[i]); } else { f111 = 0.0f; w111 = 0.0f; } if((w000 <= min_weight) || (w001 <= min_weight) || (w010 <= min_weight) || (w011 <= min_weight) || (w100 <= min_weight) || (w101 <= min_weight) || (w110 <= min_weight) || (w111 <= min_weight)) { return false; } float u, v, w; u = (gx - gx0); v = (gy - gy0); w = (gz - gz0); nx = (1 - v) * (1 - w) * f000 + (1 - v) * ( w) * f001 + ( v) * (1 - w) * f010 + ( v) * ( w) * f011 + -(1 - v) * (1 - w) * f100 + -(1 - v) * ( w) * f101 + -( v) * (1 - w) * f110 + -( v) * ( w) * f111; ny = (1 - u) * (1 - w) * f000 + (1 - u) * ( w) * f001 + -(1 - u) * (1 - w) * f010 + -(1 - u) * ( w) * f011 + ( u) * (1 - w) * f100 + ( u) * ( w) * f101 + -( u) * (1 - w) * f110 + -( u) * ( w) * f111; nz = (1 - u) * (1 - v) * f000 + -(1 - u) * (1 - v) * f001 + (1 - u) * ( v) * f010 + -(1 - u) * ( v) * f011 + ( u) * (1 - v) * f100 + -( u) * (1 - v) * f101 + ( u) * ( v) * f110 + -( u) * ( v) * f111; return true; } __global__ void RayCaster(float max_distance, float max_truncation, int volume_size, float volume_dimension, float voxel_dimension, float min_weight, int width, int height, float fx, float fy, float cx, float cy, Vertex center, const Voxel *volume, Vertices model_vertices, Normals model_normals, Color *normal_map) { // Get Block and Thread Id int bx = blockIdx.x; int by = blockIdx.y; int tx = threadIdx.x; int ty = threadIdx.y; // Calculate Row & Column int x = tx + bx * BLOCK_WIDTH; int y = ty + by * BLOCK_WIDTH; int i = x + y * width; if ((x < width) && (y < height)) { // Initialize Normal Map Color normal_color; normal_color.r = normal_color.g = normal_color.b = 0; // Initialize Model Vertex and Normal Vertex model_vertex; Vector model_normal; model_vertex.x = model_vertex.y = model_vertex.z = 0.0f; model_normal.x = model_normal.y = model_normal.z = 0.0f; // Ray Starting Position Vertex ray_start; ray_start.x = T[0][3]; ray_start.y = T[1][3]; ray_start.z = T[2][3]; // Ray Direction Vector ray_direction, ray_temp; ray_temp.x = (x - cx) / fx; ray_temp.y = (y - cy) / fy; ray_temp.z = 1.0f; ray_direction.x = T[0][0] * ray_temp.x + T[0][1] * ray_temp.y + T[0][2] * ray_temp.z; ray_direction.y = T[1][0] * ray_temp.x + T[1][1] * ray_temp.y + T[1][2] * ray_temp.z; ray_direction.z = T[2][0] * ray_temp.x + T[2][1] * ray_temp.y + T[2][2] * ray_temp.z; // Normalize Ray Direction float ray_inorm = rsqrt(ray_direction.x * ray_direction.x + ray_direction.y * ray_direction.y + ray_direction.z * ray_direction.z); ray_direction.x *= ray_inorm; ray_direction.y *= ray_inorm; ray_direction.z *= ray_inorm; // Ray Casting float time = 0.0f, time_last = 0.0f; float tsdf, tsdf_last = 0.0f; while (time < max_distance) { // Determine Vertex Position Vertex vertex_position; vertex_position.x = ray_start.x + ray_direction.x * time; vertex_position.y = ray_start.y + ray_direction.y * time; vertex_position.z = ray_start.z + ray_direction.z * time; // Determine Grid Position Vertex grid_position; grid_position.x = (vertex_position.x + (volume_dimension / 2.0f) - center.x) / voxel_dimension; grid_position.y = (vertex_position.y + (volume_dimension / 2.0f) - center.y) / voxel_dimension; grid_position.z = (vertex_position.z + (volume_dimension / 2.0f) - center.z) / voxel_dimension; if ((grid_position.x) < 1 || (grid_position.x >= volume_size - 1)) { time_last = time; time += max_truncation; continue; } if ((grid_position.y) < 1 || (grid_position.y >= volume_size - 1)) { time_last = time; time += max_truncation; continue; } if ((grid_position.z) < 1 || (grid_position.z >= volume_size - 1)) { time_last = time; time += max_truncation; continue; } if (!interpolate(volume_size, volume_dimension, voxel_dimension, min_weight, volume, center, vertex_position.x, vertex_position.y, vertex_position.z, tsdf)) { time_last = time; time += max_truncation; continue; } if (tsdf_last < 0.0f && tsdf >= 0.0f) break; if (tsdf_last > 0.0f && tsdf <= 0.0f) { // Determine Time float t = time_last -(((time - time_last) * tsdf_last) / (tsdf - tsdf_last)); // Determine Position model_vertex.x = ray_start.x + ray_direction.x * t; model_vertex.y = ray_start.y + ray_direction.y * t; model_vertex.z = ray_start.z + ray_direction.z * t; // Determine Normal if (surface_normal(volume_size, volume_dimension, voxel_dimension, min_weight, volume, center, model_vertex.x, model_vertex.y, model_vertex.z, model_normal.x, model_normal.y, model_normal.z)) { // Normalize float inorm = rsqrt(model_normal.x * model_normal.x + model_normal.y * model_normal.y + model_normal.z * model_normal.z); if (isfinite(inorm)) { model_normal.x *= inorm; model_normal.y *= inorm; model_normal.z *= inorm; normal_color.r = ((model_normal.x + 1.0f) / 2.0f) * 255.0f; normal_color.g = ((model_normal.y + 1.0f) / 2.0f) * 255.0f; normal_color.b = ((model_normal.z + 1.0f) / 2.0f) * 255.0f; } } break; } tsdf_last = tsdf; time_last = time; if (ABS(tsdf) < 1.0f) time += voxel_dimension; else time += max_truncation; } model_vertices.x[i] = model_vertex.x; model_vertices.y[i] = model_vertex.y; model_vertices.z[i] = model_vertex.z; model_normals.x[i] = model_normal.x; model_normals.y[i] = model_normal.y; model_normals.z[i] = model_normal.z; if (normal_map != NULL) normal_map[i] = normal_color; } } void RayCastingKernel(float max_distance, float max_truncation, int volume_size, float volume_dimension, float voxel_dimension, float min_weight, int width, int height, float fx, float fy, float cx, float cy, Vertex center, float *transformation, const Voxel *volume, Vertices model_vertices, Normals model_normals, Color *normal_map) { // Copy Transforms to Constant Memory CUDA_ERROR_CHECK(hipMemcpyToSymbol(T, transformation, sizeof(float) * 16)); // Launch Ray Casting Kernel int grid_width = (width + (BLOCK_WIDTH - 1)) / BLOCK_WIDTH; int grid_height = (height + (BLOCK_WIDTH - 1)) / BLOCK_WIDTH; dim3 grid_dim(grid_width, grid_height, 1); dim3 block_dim(BLOCK_WIDTH, BLOCK_WIDTH, 1); hipLaunchKernelGGL(( RayCaster), dim3(grid_dim), dim3(block_dim), 0, 0, max_distance, max_truncation, volume_size, volume_dimension, voxel_dimension, min_weight, width, height, fx, fy, cx, cy, center, volume, model_vertices, model_normals, normal_map); CUDA_ERROR_CHECK(hipDeviceSynchronize()); } } // namespace dip
29aa997c8aeea85c760f17a8176931c4a8acbece.cu
/* Copyright (c) 2013-2014, Gregory P. Meyer University of Illinois Board of Trustees All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder(s) nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <dip/common/error.h> #include <dip/common/macros.h> #include <dip/common/types.h> #include <dip/surface/voxel.h> #define BLOCK_WIDTH 16 namespace dip { __constant__ float T[4][4]; __device__ bool interpolate(int volume_size, float volume_dimension, float voxel_dimension, float min_weight, const Voxel *volume, Vertex center, float vx, float vy, float vz, float &tsdf) { // Convert Vertex Position to Grid Position float gx, gy, gz; gx = (vx + (volume_dimension / 2.0f) - center.x) / voxel_dimension; gy = (vy + (volume_dimension / 2.0f) - center.y) / voxel_dimension; gz = (vz + (volume_dimension / 2.0f) - center.z) / voxel_dimension; float gx0, gy0, gz0; float gx1, gy1, gz1; gx0 = floor(gx); gx1 = gx0 + 1.0f; gy0 = floor(gy); gy1 = gy0 + 1.0f; gz0 = floor(gz); gz1 = gz0 + 1.0f; int i; float f000, f001, f010, f011, f100, f101, f110, f111; float w000, w001, w010, w011, w100, w101, w110, w111; i = (int)gx0 + (int)gy0 * volume_size + (int)gz0 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f000 = UNCOMPRESS_VALUE(volume[i]); w000 = UNCOMPRESS_WEIGHT(volume[i]); } else { f000 = 0.0f; w000 = 0.0f; } i = (int)gx0 + (int)gy0 * volume_size + (int)gz1 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f001 = UNCOMPRESS_VALUE(volume[i]); w001 = UNCOMPRESS_WEIGHT(volume[i]); } else { f001 = 0.0f; w001 = 0.0f; } i = (int)gx0 + (int)gy1 * volume_size + (int)gz0 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f010 = UNCOMPRESS_VALUE(volume[i]); w010 = UNCOMPRESS_WEIGHT(volume[i]); } else { f010 = 0.0f; w010 = 0.0f; } i = (int)gx0 + (int)gy1 * volume_size + (int)gz1 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f011 = UNCOMPRESS_VALUE(volume[i]); w011 = UNCOMPRESS_WEIGHT(volume[i]); } else { f011 = 0.0f; w011 = 0.0f; } i = (int)gx1 + (int)gy0 * volume_size + (int)gz0 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f100 = UNCOMPRESS_VALUE(volume[i]); w100 = UNCOMPRESS_WEIGHT(volume[i]); } else { f100 = 0.0f; w100 = 0.0f; } i = (int)gx1 + (int)gy0 * volume_size + (int)gz1 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f101 = UNCOMPRESS_VALUE(volume[i]); w101 = UNCOMPRESS_WEIGHT(volume[i]); } else { f101 = 0.0f; w101 = 0.0f; } i = (int)gx1 + (int)gy1 * volume_size + (int)gz0 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f110 = UNCOMPRESS_VALUE(volume[i]); w110 = UNCOMPRESS_WEIGHT(volume[i]); } else { f110 = 0.0f; w110 = 0.0f; } i = (int)gx1 + (int)gy1 * volume_size + (int)gz1 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f111 = UNCOMPRESS_VALUE(volume[i]); w111 = UNCOMPRESS_WEIGHT(volume[i]); } else { f111 = 0.0f; w111 = 0.0f; } if((w000 <= min_weight) || (w001 <= min_weight) || (w010 <= min_weight) || (w011 <= min_weight) || (w100 <= min_weight) || (w101 <= min_weight) || (w110 <= min_weight) || (w111 <= min_weight)) { return false; } float u, v, w; u = (gx - gx0); v = (gy - gy0); w = (gz - gz0); tsdf = (1 - u) * (1 - v) * (1 - w) * f000 + (1 - u) * (1 - v) * ( w) * f001 + (1 - u) * ( v) * (1 - w) * f010 + (1 - u) * ( v) * ( w) * f011 + ( u) * (1 - v) * (1 - w) * f100 + ( u) * (1 - v) * ( w) * f101 + ( u) * ( v) * (1 - w) * f110 + ( u) * ( v) * ( w) * f111; return true; } __device__ bool surface_normal(int volume_size, float volume_dimension, float voxel_dimension, float min_weight, const Voxel *volume, Vertex center, float vx, float vy, float vz, float &nx, float &ny, float &nz) { // Convert Vertex Position to Grid Position float gx, gy, gz; gx = (vx + (volume_dimension / 2.0f) - center.x) / voxel_dimension; gy = (vy + (volume_dimension / 2.0f) - center.y) / voxel_dimension; gz = (vz + (volume_dimension / 2.0f) - center.z) / voxel_dimension; float gx0, gy0, gz0; float gx1, gy1, gz1; gx0 = floor(gx); gx1 = gx0 + 1.0f; gy0 = floor(gy); gy1 = gy0 + 1.0f; gz0 = floor(gz); gz1 = gz0 + 1.0f; int i; float f000, f001, f010, f011, f100, f101, f110, f111; float w000, w001, w010, w011, w100, w101, w110, w111; i = (int)gx0 + (int)gy0 * volume_size + (int)gz0 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f000 = UNCOMPRESS_VALUE(volume[i]); w000 = UNCOMPRESS_WEIGHT(volume[i]); } else { f000 = 0.0f; w000 = 0.0f; } i = (int)gx0 + (int)gy0 * volume_size + (int)gz1 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f001 = UNCOMPRESS_VALUE(volume[i]); w001 = UNCOMPRESS_WEIGHT(volume[i]); } else { f001 = 0.0f; w001 = 0.0f; } i = (int)gx0 + (int)gy1 * volume_size + (int)gz0 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f010 = UNCOMPRESS_VALUE(volume[i]); w010 = UNCOMPRESS_WEIGHT(volume[i]); } else { f010 = 0.0f; w010 = 0.0f; } i = (int)gx0 + (int)gy1 * volume_size + (int)gz1 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f011 = UNCOMPRESS_VALUE(volume[i]); w011 = UNCOMPRESS_WEIGHT(volume[i]); } else { f011 = 0.0f; w011 = 0.0f; } i = (int)gx1 + (int)gy0 * volume_size + (int)gz0 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f100 = UNCOMPRESS_VALUE(volume[i]); w100 = UNCOMPRESS_WEIGHT(volume[i]); } else { f100 = 0.0f; w100 = 0.0f; } i = (int)gx1 + (int)gy0 * volume_size + (int)gz1 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f101 = UNCOMPRESS_VALUE(volume[i]); w101 = UNCOMPRESS_WEIGHT(volume[i]); } else { f101 = 0.0f; w101 = 0.0f; } i = (int)gx1 + (int)gy1 * volume_size + (int)gz0 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f110 = UNCOMPRESS_VALUE(volume[i]); w110 = UNCOMPRESS_WEIGHT(volume[i]); } else { f110 = 0.0f; w110 = 0.0f; } i = (int)gx1 + (int)gy1 * volume_size + (int)gz1 * volume_size * volume_size; if (i > 0 && i < volume_size * volume_size * volume_size) { f111 = UNCOMPRESS_VALUE(volume[i]); w111 = UNCOMPRESS_WEIGHT(volume[i]); } else { f111 = 0.0f; w111 = 0.0f; } if((w000 <= min_weight) || (w001 <= min_weight) || (w010 <= min_weight) || (w011 <= min_weight) || (w100 <= min_weight) || (w101 <= min_weight) || (w110 <= min_weight) || (w111 <= min_weight)) { return false; } float u, v, w; u = (gx - gx0); v = (gy - gy0); w = (gz - gz0); nx = (1 - v) * (1 - w) * f000 + (1 - v) * ( w) * f001 + ( v) * (1 - w) * f010 + ( v) * ( w) * f011 + -(1 - v) * (1 - w) * f100 + -(1 - v) * ( w) * f101 + -( v) * (1 - w) * f110 + -( v) * ( w) * f111; ny = (1 - u) * (1 - w) * f000 + (1 - u) * ( w) * f001 + -(1 - u) * (1 - w) * f010 + -(1 - u) * ( w) * f011 + ( u) * (1 - w) * f100 + ( u) * ( w) * f101 + -( u) * (1 - w) * f110 + -( u) * ( w) * f111; nz = (1 - u) * (1 - v) * f000 + -(1 - u) * (1 - v) * f001 + (1 - u) * ( v) * f010 + -(1 - u) * ( v) * f011 + ( u) * (1 - v) * f100 + -( u) * (1 - v) * f101 + ( u) * ( v) * f110 + -( u) * ( v) * f111; return true; } __global__ void RayCaster(float max_distance, float max_truncation, int volume_size, float volume_dimension, float voxel_dimension, float min_weight, int width, int height, float fx, float fy, float cx, float cy, Vertex center, const Voxel *volume, Vertices model_vertices, Normals model_normals, Color *normal_map) { // Get Block and Thread Id int bx = blockIdx.x; int by = blockIdx.y; int tx = threadIdx.x; int ty = threadIdx.y; // Calculate Row & Column int x = tx + bx * BLOCK_WIDTH; int y = ty + by * BLOCK_WIDTH; int i = x + y * width; if ((x < width) && (y < height)) { // Initialize Normal Map Color normal_color; normal_color.r = normal_color.g = normal_color.b = 0; // Initialize Model Vertex and Normal Vertex model_vertex; Vector model_normal; model_vertex.x = model_vertex.y = model_vertex.z = 0.0f; model_normal.x = model_normal.y = model_normal.z = 0.0f; // Ray Starting Position Vertex ray_start; ray_start.x = T[0][3]; ray_start.y = T[1][3]; ray_start.z = T[2][3]; // Ray Direction Vector ray_direction, ray_temp; ray_temp.x = (x - cx) / fx; ray_temp.y = (y - cy) / fy; ray_temp.z = 1.0f; ray_direction.x = T[0][0] * ray_temp.x + T[0][1] * ray_temp.y + T[0][2] * ray_temp.z; ray_direction.y = T[1][0] * ray_temp.x + T[1][1] * ray_temp.y + T[1][2] * ray_temp.z; ray_direction.z = T[2][0] * ray_temp.x + T[2][1] * ray_temp.y + T[2][2] * ray_temp.z; // Normalize Ray Direction float ray_inorm = rsqrt(ray_direction.x * ray_direction.x + ray_direction.y * ray_direction.y + ray_direction.z * ray_direction.z); ray_direction.x *= ray_inorm; ray_direction.y *= ray_inorm; ray_direction.z *= ray_inorm; // Ray Casting float time = 0.0f, time_last = 0.0f; float tsdf, tsdf_last = 0.0f; while (time < max_distance) { // Determine Vertex Position Vertex vertex_position; vertex_position.x = ray_start.x + ray_direction.x * time; vertex_position.y = ray_start.y + ray_direction.y * time; vertex_position.z = ray_start.z + ray_direction.z * time; // Determine Grid Position Vertex grid_position; grid_position.x = (vertex_position.x + (volume_dimension / 2.0f) - center.x) / voxel_dimension; grid_position.y = (vertex_position.y + (volume_dimension / 2.0f) - center.y) / voxel_dimension; grid_position.z = (vertex_position.z + (volume_dimension / 2.0f) - center.z) / voxel_dimension; if ((grid_position.x) < 1 || (grid_position.x >= volume_size - 1)) { time_last = time; time += max_truncation; continue; } if ((grid_position.y) < 1 || (grid_position.y >= volume_size - 1)) { time_last = time; time += max_truncation; continue; } if ((grid_position.z) < 1 || (grid_position.z >= volume_size - 1)) { time_last = time; time += max_truncation; continue; } if (!interpolate(volume_size, volume_dimension, voxel_dimension, min_weight, volume, center, vertex_position.x, vertex_position.y, vertex_position.z, tsdf)) { time_last = time; time += max_truncation; continue; } if (tsdf_last < 0.0f && tsdf >= 0.0f) break; if (tsdf_last > 0.0f && tsdf <= 0.0f) { // Determine Time float t = time_last -(((time - time_last) * tsdf_last) / (tsdf - tsdf_last)); // Determine Position model_vertex.x = ray_start.x + ray_direction.x * t; model_vertex.y = ray_start.y + ray_direction.y * t; model_vertex.z = ray_start.z + ray_direction.z * t; // Determine Normal if (surface_normal(volume_size, volume_dimension, voxel_dimension, min_weight, volume, center, model_vertex.x, model_vertex.y, model_vertex.z, model_normal.x, model_normal.y, model_normal.z)) { // Normalize float inorm = rsqrt(model_normal.x * model_normal.x + model_normal.y * model_normal.y + model_normal.z * model_normal.z); if (isfinite(inorm)) { model_normal.x *= inorm; model_normal.y *= inorm; model_normal.z *= inorm; normal_color.r = ((model_normal.x + 1.0f) / 2.0f) * 255.0f; normal_color.g = ((model_normal.y + 1.0f) / 2.0f) * 255.0f; normal_color.b = ((model_normal.z + 1.0f) / 2.0f) * 255.0f; } } break; } tsdf_last = tsdf; time_last = time; if (ABS(tsdf) < 1.0f) time += voxel_dimension; else time += max_truncation; } model_vertices.x[i] = model_vertex.x; model_vertices.y[i] = model_vertex.y; model_vertices.z[i] = model_vertex.z; model_normals.x[i] = model_normal.x; model_normals.y[i] = model_normal.y; model_normals.z[i] = model_normal.z; if (normal_map != NULL) normal_map[i] = normal_color; } } void RayCastingKernel(float max_distance, float max_truncation, int volume_size, float volume_dimension, float voxel_dimension, float min_weight, int width, int height, float fx, float fy, float cx, float cy, Vertex center, float *transformation, const Voxel *volume, Vertices model_vertices, Normals model_normals, Color *normal_map) { // Copy Transforms to Constant Memory CUDA_ERROR_CHECK(cudaMemcpyToSymbol(T, transformation, sizeof(float) * 16)); // Launch Ray Casting Kernel int grid_width = (width + (BLOCK_WIDTH - 1)) / BLOCK_WIDTH; int grid_height = (height + (BLOCK_WIDTH - 1)) / BLOCK_WIDTH; dim3 grid_dim(grid_width, grid_height, 1); dim3 block_dim(BLOCK_WIDTH, BLOCK_WIDTH, 1); RayCaster<<<grid_dim, block_dim>>>(max_distance, max_truncation, volume_size, volume_dimension, voxel_dimension, min_weight, width, height, fx, fy, cx, cy, center, volume, model_vertices, model_normals, normal_map); CUDA_ERROR_CHECK(cudaDeviceSynchronize()); } } // namespace dip
6ee4e7f815d1d4be8262f079d75fadb1e3d5db48.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" /* * Copyright (c) 2018 Preferred Networks, Inc. All rights reserved. */ #include <hip/hip_fp16.h> namespace chainer_trt { namespace plugin { template <typename T> __global__ void slice_kernel(const T *src_gpu, T *dest_gpu, int *mapping_gpu, int n_src, int n_dst) { const int dst_idx = blockIdx.x * blockDim.x + threadIdx.x; if(n_dst <= dst_idx) return; const int src_idx = mapping_gpu[dst_idx]; dest_gpu[blockIdx.y * n_dst + dst_idx] = src_gpu[blockIdx.y * n_src + src_idx]; // blockIdx.y is batch idx } template <typename T> void apply_slice(const T *src_gpu, T *dest_gpu, int *mapping_gpu, int n_src, int n_dst, int batch_size, hipStream_t stream) { const int block_size = 1024; const int grid_size = (int)::ceil(1.0 * n_dst / block_size); dim3 grid(grid_size, batch_size); hipLaunchKernelGGL(( slice_kernel<T>), dim3(grid), dim3(block_size), 0, stream, src_gpu, dest_gpu, mapping_gpu, n_src, n_dst); } template void apply_slice(const float *, float *, int *, int, int, int, hipStream_t); template void apply_slice(const __half *, __half *, int *, int, int, int, hipStream_t); } }
6ee4e7f815d1d4be8262f079d75fadb1e3d5db48.cu
/* * Copyright (c) 2018 Preferred Networks, Inc. All rights reserved. */ #include <cuda_fp16.h> namespace chainer_trt { namespace plugin { template <typename T> __global__ void slice_kernel(const T *src_gpu, T *dest_gpu, int *mapping_gpu, int n_src, int n_dst) { const int dst_idx = blockIdx.x * blockDim.x + threadIdx.x; if(n_dst <= dst_idx) return; const int src_idx = mapping_gpu[dst_idx]; dest_gpu[blockIdx.y * n_dst + dst_idx] = src_gpu[blockIdx.y * n_src + src_idx]; // blockIdx.y is batch idx } template <typename T> void apply_slice(const T *src_gpu, T *dest_gpu, int *mapping_gpu, int n_src, int n_dst, int batch_size, cudaStream_t stream) { const int block_size = 1024; const int grid_size = (int)std::ceil(1.0 * n_dst / block_size); dim3 grid(grid_size, batch_size); slice_kernel<T><<<grid, block_size, 0, stream>>>( src_gpu, dest_gpu, mapping_gpu, n_src, n_dst); } template void apply_slice(const float *, float *, int *, int, int, int, cudaStream_t); template void apply_slice(const __half *, __half *, int *, int, int, int, cudaStream_t); } }
29e500872da5894b48839b4f917a1fe9803f9c3e.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include "includes.h" __global__ void lots_of_float_compute(float *inputs, int N, size_t niters, float *outputs) { size_t tid = blockIdx.x * blockDim.x + threadIdx.x; size_t nthreads = gridDim.x * blockDim.x; for (; tid < N; tid += nthreads) { size_t iter; float val = inputs[tid]; for (iter = 0; iter < niters; iter++) { val = (val + 5.0f) - 101.0f; val = (val / 3.0f) + 102.0f; val = (val + 1.07f) - 103.0f; val = (val / 1.037f) + 104.0f; val = (val + 3.00f) - 105.0f; val = (val / 0.22f) + 106.0f; } outputs[tid] = val; } }
29e500872da5894b48839b4f917a1fe9803f9c3e.cu
#include "includes.h" __global__ void lots_of_float_compute(float *inputs, int N, size_t niters, float *outputs) { size_t tid = blockIdx.x * blockDim.x + threadIdx.x; size_t nthreads = gridDim.x * blockDim.x; for (; tid < N; tid += nthreads) { size_t iter; float val = inputs[tid]; for (iter = 0; iter < niters; iter++) { val = (val + 5.0f) - 101.0f; val = (val / 3.0f) + 102.0f; val = (val + 1.07f) - 103.0f; val = (val / 1.037f) + 104.0f; val = (val + 3.00f) - 105.0f; val = (val / 0.22f) + 106.0f; } outputs[tid] = val; } }
64080d6c247cac0766ba74cd880be0da8fc1219e.hip
// !!! This is a file automatically generated by hipify!!! /** * @file rasterize.cu * @brief CUDA-accelerated rasterization pipeline. * @authors Skeleton code: Yining Karl Li, Kai Ninomiya, Shuai Shao (Shrek) * @date 2012-2016 * @copyright University of Pennsylvania & STUDENT */ #include <cmath> #include <cstdio> #include <hip/hip_runtime.h> #include <hip/hip_runtime.h> #include <thrust/random.h> #include <util/checkCUDAError.h> #include <util/tiny_gltf_loader.h> #include "rasterizeTools.h" #include "rasterize.h" #include <glm/gtc/quaternion.hpp> #include <glm/gtc/matrix_transform.hpp> #include <thrust/execution_policy.h> #include <thrust/partition.h> #include <chrono> #define POINTS 0 #define WIREFRAME 0 #define DEBUG_DEPTH 0 #define DEBUG_NORMALS 0 #define TEXTURE 1 #define TEXTURE_PERSP_CORRECT 1 #define TEXTURE_BILINEAR_FILT 1 #define BLUR 0 #define BLUR_SHARED 0 #define SSAO 0 // SCREEN SPACE AMBIENT OCCLUSION : WORK UNDER PROGRESS #define BBOX_OPTIMIZATIONS 1 #define BACK_FACE_CULLING 0 #define BACK_FACE_CULLING_WITHOUT_COMPACTION 0 #define SSAA 2 // SUPERSAMPLE ANTIALIASING // 1 (min value : no AA), 2, 4, ... namespace { typedef unsigned short VertexIndex; typedef glm::vec3 VertexAttributePosition; typedef glm::vec3 VertexAttributeNormal; typedef glm::vec2 VertexAttributeTexcoord; typedef unsigned char TextureData; typedef unsigned char BufferByte; enum PrimitiveType { Point = 1, Line = 2, Triangle = 3 }; struct VertexOut { glm::vec4 pos; // TODO: add new attributes to your VertexOut // The attributes listed below might be useful, // but always feel free to modify on your own glm::vec3 eyePos; // eye space position used for shading glm::vec3 eyeNor; // eye space normal used for shading, cuz normal will go wrong after perspective transformation //glm::vec3 col; glm::vec2 texcoord0; TextureData* dev_diffuseTex = NULL; int texWidth, texHeight; // ... }; struct Primitive { PrimitiveType primitiveType = Triangle; // C++ 11 init VertexOut v[3]; bool back = false; // used for back face culling }; struct Fragment { glm::vec3 color; // TODO: add new attributes to your Fragment // The attributes listed below might be useful, // but always feel free to modify on your own glm::vec3 eyePos; // eye space position used for shading glm::vec3 eyeNor; VertexAttributeTexcoord texcoord0; TextureData* dev_diffuseTex = NULL; int texWidth, texHeight; // ... }; struct PrimitiveDevBufPointers { int primitiveMode; //from tinygltfloader macro PrimitiveType primitiveType; int numPrimitives; int numIndices; int numVertices; // Vertex In, const after loaded VertexIndex* dev_indices; VertexAttributePosition* dev_position; VertexAttributeNormal* dev_normal; VertexAttributeTexcoord* dev_texcoord0; // Materials, add more attributes when needed TextureData* dev_diffuseTex; int diffuseTexWidth; int diffuseTexHeight; // TextureData* dev_specularTex; // TextureData* dev_normalTex; // ... // Vertex Out, vertex used for rasterization, this is changing every frame VertexOut* dev_verticesOut; // TODO: add more attributes when needed }; } static std::map<std::string, std::vector<PrimitiveDevBufPointers>> mesh2PrimitivesMap; static int width = 0; static int height = 0; static int totalNumPrimitivesCompact = 0; // updated after compaction by culling static int totalNumPrimitives = 0; static Primitive *dev_primitives = NULL; static Fragment *dev_fragmentBuffer = NULL; static glm::vec3 *dev_framebuffer = NULL; static int * dev_depth = NULL; // you might need this buffer when doing depth test static int * dev_mutex = NULL; static glm::vec3 *dev_postBuffer1 = NULL; static glm::vec3 *dev_postBuffer2 = NULL; static Primitive *dev_primitives_compact = NULL; // gaussian kernel // source: http://www.sunsetlakesoftware.com/2013/10/21/optimizing-gaussian-blurs-mobile-gpu // source: http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/ __constant__ float mat[5] = { 0.2270270270, 0.1945945946, 0.1216216216, 0.0540540541, 0.0162162162 }; __constant__ float light[3] = {100.f, 100.f, 100.f}; /** * Called once at the beginning of the program to allocate memory. */ void rasterizeInit(int w, int h) { width = w * SSAA; height = h * SSAA; hipFree(dev_fragmentBuffer); hipMalloc(&dev_fragmentBuffer, width * height * sizeof(Fragment)); hipMemset(dev_fragmentBuffer, 0, width * height * sizeof(Fragment)); hipFree(dev_framebuffer); hipMalloc(&dev_framebuffer, width * height * sizeof(glm::vec3)); hipMemset(dev_framebuffer, 0, width * height * sizeof(glm::vec3)); hipMalloc(&dev_postBuffer1, width * height * sizeof(glm::vec3)); hipMemset(dev_postBuffer1, 0, width * height * sizeof(glm::vec3)); hipMalloc(&dev_postBuffer2, width * height * sizeof(glm::vec3)); hipMemset(dev_postBuffer2, 0, width * height * sizeof(glm::vec3)); hipFree(dev_depth); hipMalloc(&dev_depth, width * height * sizeof(int)); hipFree(dev_mutex); hipMalloc(&dev_mutex, width * height * sizeof(int)); checkCUDAError("rasterizeInit"); } __global__ void initDepth(int w, int h, int *depth) { int x = (blockIdx.x * blockDim.x) + threadIdx.x; int y = (blockIdx.y * blockDim.y) + threadIdx.y; if (x < w && y < h) { int index = x + (y * w); depth[index] = INT_MAX; } } /** * Kernel that writes the image to the OpenGL PBO directly. */ __global__ void sendImageToPBO(uchar4 *pbo, int w, int h, glm::vec3 *image) { int x = (blockIdx.x * blockDim.x) + threadIdx.x; int y = (blockIdx.y * blockDim.y) + threadIdx.y; int width = w / SSAA; int height = h / SSAA; int index = x + (y * width); if (x < width && y < height) { glm::vec3 color; for (int i = 0; i < SSAA; i++) { for (int j = 0; j < SSAA; j++) { int ind = (x *SSAA) + i + (y * SSAA + j) * w; color.x += glm::clamp(image[ind].x, 0.0f, 1.0f) * 255.0; color.y += glm::clamp(image[ind].y, 0.0f, 1.0f) * 255.0; color.z += glm::clamp(image[ind].z, 0.0f, 1.0f) * 255.0; } } color /= (SSAA*SSAA); // Each thread writes one pixel location in the texture (textel) pbo[index].w = 0; pbo[index].x = color.x; pbo[index].y = color.y; pbo[index].z = color.z; } } /** * Returns texture color for a fragment */ __device__ glm::vec3 getColor(Fragment &fragment, glm::vec2 uv) { // the color is stored in a 1D array of floats.. // convert to 1D index // scale by 3 int index = ((int)uv.x + (int)uv.y * fragment.texWidth) * 3; glm::vec3 col(fragment.dev_diffuseTex[index], fragment.dev_diffuseTex[index + 1], fragment.dev_diffuseTex[index + 2]); return col / 255.f; // map colors to 0-1 range.. } /** * Returns Bilinear Filtered texture color for a fragment * Reference: https://en.wikipedia.org/wiki/Bilinear_filtering */ __device__ glm::vec3 getBilinearFilteredColor(Fragment &fragment, glm::vec2 uv) { // get 4 valid indices.. int intX0 = uv.x; int intY0 = uv.y; int intX1 = glm::clamp(intX0 + 1, 0, fragment.texWidth - 1); int intY1 = glm::clamp(intY0 + 1, 0, fragment.texHeight - 1); // get colors at 4 texels.. glm::vec3 col00 = getColor(fragment, glm::vec2(intX0, intY0)); glm::vec3 col01 = getColor(fragment, glm::vec2(intX0, intY1)); glm::vec3 col10 = getColor(fragment, glm::vec2(intX1, intY0)); glm::vec3 col11 = getColor(fragment, glm::vec2(intX1, intY1)); // lerp based on fractional parts.. float fracX = uv.x - intX0; float fracY = uv.y - intY0; glm::vec3 col0001 = glm::mix(col00, col01, fracY); glm::vec3 col1011 = glm::mix(col10, col11, fracY); return glm::mix(col0001, col1011, fracX); } /** * Writes fragment colors to the framebuffer */ __global__ void render(int w, int h, Fragment *fragmentBuffer, glm::vec3 *framebuffer) { int x = (blockIdx.x * blockDim.x) + threadIdx.x; int y = (blockIdx.y * blockDim.y) + threadIdx.y; if (x < w && y < h) { int index = x + (y * w); glm::vec3 &outPix = framebuffer[index]; Fragment &frag = fragmentBuffer[index]; if (frag.color == glm::vec3()) { outPix *= 0.f; return; } #if POINTS || WIREFRAME outPix = frag.color; #elif DEBUG_DEPTH outPix = frag.color; // maybe scale this to look better??? #elif DEBUG_NORMALS outPix = frag.color; #elif TEXTURE if (frag.dev_diffuseTex != NULL) { #if TEXTURE_BILINEAR_FILT glm::vec2 uv(frag.texcoord0.x * frag.texWidth, frag.texcoord0.y * frag.texHeight); outPix = getBilinearFilteredColor(frag, uv); #else glm::vec2 uv(frag.texcoord0.x * frag.texWidth, frag.texcoord0.y * frag.texHeight); outPix = getColor(frag, uv); #endif // LAMBERT SHADING: glm::vec3 lightDir = glm::normalize(frag.eyePos - glm::vec3(1.f)); outPix *= glm::max(fabs(glm::dot(lightDir, frag.eyeNor)), 0.2f); } else { outPix = glm::vec3(); // reset color.. } #else // LAMBERT SHADING: glm::vec3 lightDir = frag.eyePos - glm::vec3(light[0], light[1], light[2]); lightDir = glm::normalize(lightDir); float dot = glm::dot(-lightDir, frag.eyeNor); if (dot <= 0.1f) { dot = 0.1f; } glm::vec3 col = frag.color * dot; outPix = col; #endif } } // Screen space ambient occlusion // https://www.gamedev.net/articles/programming/graphics/a-simple-and-practical-approach-to-ssao-r2753/ __global__ void shaderSSAO(int w, int h, Fragment *fragmentBuffer) { int x = (blockIdx.x * blockDim.x) + threadIdx.x; int y = (blockIdx.y * blockDim.y) + threadIdx.y; if (x < w && y < h) { int index = x + (y * w); Fragment &frag = fragmentBuffer[index]; float ao = 0.f; for (int i = -2; i < 3; i++) { for (int j = -2; j < 3; j++) { int xi = x + i; int yi = y + i; if (xi > 0 && yi > 0 && xi < w && yi < h && i != 0 && j != 0) { int idxi = xi + (yi * w); Fragment &fragi = fragmentBuffer[idxi]; glm::vec3 N = fragi.eyeNor; glm::vec3 V = fragi.eyePos - frag.eyePos; float d = glm::length(V); ao += glm::max(0.f, glm::dot(N, glm::normalize(V))) * (1.f / (1.f + d)); } } } frag.color = ao * glm::vec3(1.f); } } /** * Post Processing Shader * operates on framebuffer * uses the __constant__ gaussian kernel defined above.. */ __global__ void postProcess(bool dirX, int w, int h, glm::vec3 *frameBuffer, int* depthBuffer, glm::vec3 *postBuffer) { int x = dirX ? threadIdx.x : blockIdx.x; int y = dirX ? blockIdx.x : threadIdx.x; int index = x + (y * w); if (x < w && y < h) { glm::vec3 col = mat[0] * frameBuffer[index]; if (dirX) { for (int i = 1; i < 5; i++) { if (x + i < w) { col += mat[i] * frameBuffer[(x + i) + y * w]; } if (x - i >= 0) { col += mat[i] * frameBuffer[(x - i) + y * w]; } } } else { for (int i = 1; i < 5; i++) { if (y + i < h) { col += mat[i] * frameBuffer[x + (y + i) * w]; } if (y - i >= 0) { col += mat[i] * frameBuffer[x + (y - i) * w]; } } } postBuffer[index] = col; } else { postBuffer[index] = frameBuffer[index]; } } __global__ void postProcessShared(bool dirX, int w, int h, glm::vec3 *frameBuffer, int* depthBuffer, glm::vec3 *postBuffer) { int x = dirX ? threadIdx.x : blockIdx.x; int y = dirX ? blockIdx.x : threadIdx.x; int index = x + (y * w); if (x >= w || y >= h) { return; } // https://devblogs.nvidia.com/parallelforall/using-shared-memory-cuda-cc/ extern __shared__ glm::vec3 sm[]; if (dirX) { sm[x] = frameBuffer[index]; } else { sm[y] = frameBuffer[index]; } __syncthreads(); int depth = depthBuffer[index]; glm::vec3 col; if (dirX) { col = mat[0] * sm[x]; for (int i = 1; i < 5; i++) { if (x + i < w) { if (abs(depthBuffer[(x + i) + y * w] - depth) < 10000) { col += mat[i] * sm[x + i]; } } if (x - i >= 0) { if (abs(depthBuffer[(x - i) + y * w] - depth) < 10000) { col += mat[i] * sm[x - i]; } } } } else { col = mat[0] * sm[y]; for (int i = 1; i < 5; i++) { if (y + i < h) { if (abs(depthBuffer[x + (y + i) * w] - depth) < 10000) { col += mat[i] * sm[y + i]; } } if (y - i >= 0) { if (abs(depthBuffer[x + (y - i) * w] - depth) < 10000) { col += mat[i] * sm[y - i]; } } } } postBuffer[index] = col; } /** * Blend kernel for DOF * reference: https://mynameismjp.wordpress.com/the-museum/samples-tutorials-tools/depth-of-field-sample/ */ __global__ void postBlend(int w, int h, glm::vec3 *frameBuffer, int *depthBuffer, glm::vec3 *postBuffer) { int x = (blockIdx.x * blockDim.x) + threadIdx.x; int y = (blockIdx.y * blockDim.y) + threadIdx.y; int index = x + (y * w); if (x < w && y < h && frameBuffer[index]!=glm::vec3()) { float z = depthBuffer[index] * .0001f; //z = z < 0.3 ? fabs(z - 0.3) * 2.f : fabs(z - 0.3) * 2.f; //postBuffer[index] *= z; //postBuffer[index] += (1 - z) * frameBuffer[index]; z = fabs(z - 0.5) * 2.f; postBuffer[index] *= z; postBuffer[index] += (1 - z) * frameBuffer[index]; } } /** * kern function with support for stride to sometimes replace hipMemcpy * One thread is responsible for copying one component */ __global__ void _deviceBufferCopy(int N, BufferByte* dev_dst, const BufferByte* dev_src, int n, int byteStride, int byteOffset, int componentTypeByteSize) { // Attribute (vec3 position) // component (3 * float) // byte (4 * byte) // id of component int i = (blockIdx.x * blockDim.x) + threadIdx.x; if (i < N) { int count = i / n; int offset = i - count * n; // which component of the attribute for (int j = 0; j < componentTypeByteSize; j++) { dev_dst[count * componentTypeByteSize * n + offset * componentTypeByteSize + j] = dev_src[byteOffset + count * (byteStride == 0 ? componentTypeByteSize * n : byteStride) + offset * componentTypeByteSize + j]; } } } __global__ void _nodeMatrixTransform( int numVertices, VertexAttributePosition* position, VertexAttributeNormal* normal, glm::mat4 MV, glm::mat3 MV_normal) { // vertex id int vid = (blockIdx.x * blockDim.x) + threadIdx.x; if (vid < numVertices) { position[vid] = glm::vec3(MV * glm::vec4(position[vid], 1.0f)); normal[vid] = glm::normalize(MV_normal * normal[vid]); } } glm::mat4 getMatrixFromNodeMatrixVector(const tinygltf::Node & n) { glm::mat4 curMatrix(1.0); const std::vector<double> &m = n.matrix; if (m.size() > 0) { // matrix, copy it for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { curMatrix[i][j] = (float)m.at(4 * i + j); } } } else { // no matrix, use rotation, scale, translation if (n.translation.size() > 0) { curMatrix[3][0] = n.translation[0]; curMatrix[3][1] = n.translation[1]; curMatrix[3][2] = n.translation[2]; } if (n.rotation.size() > 0) { glm::mat4 R; glm::quat q; q[0] = n.rotation[0]; q[1] = n.rotation[1]; q[2] = n.rotation[2]; R = glm::mat4_cast(q); curMatrix = curMatrix * R; } if (n.scale.size() > 0) { curMatrix = curMatrix * glm::scale(glm::vec3(n.scale[0], n.scale[1], n.scale[2])); } } return curMatrix; } void traverseNode ( std::map<std::string, glm::mat4> & n2m, const tinygltf::Scene & scene, const std::string & nodeString, const glm::mat4 & parentMatrix ) { const tinygltf::Node & n = scene.nodes.at(nodeString); glm::mat4 M = parentMatrix * getMatrixFromNodeMatrixVector(n); n2m.insert(std::pair<std::string, glm::mat4>(nodeString, M)); auto it = n.children.begin(); auto itEnd = n.children.end(); for (; it != itEnd; ++it) { traverseNode(n2m, scene, *it, M); } } void rasterizeSetBuffers(const tinygltf::Scene & scene) { totalNumPrimitives = 0; std::map<std::string, BufferByte*> bufferViewDevPointers; // 1. copy all `bufferViews` to device memory { std::map<std::string, tinygltf::BufferView>::const_iterator it( scene.bufferViews.begin()); std::map<std::string, tinygltf::BufferView>::const_iterator itEnd( scene.bufferViews.end()); for (; it != itEnd; it++) { const std::string key = it->first; const tinygltf::BufferView &bufferView = it->second; if (bufferView.target == 0) { continue; // Unsupported bufferView. } const tinygltf::Buffer &buffer = scene.buffers.at(bufferView.buffer); BufferByte* dev_bufferView; hipMalloc(&dev_bufferView, bufferView.byteLength); hipMemcpy(dev_bufferView, &buffer.data.front() + bufferView.byteOffset, bufferView.byteLength, hipMemcpyHostToDevice); checkCUDAError("Set BufferView Device Mem"); bufferViewDevPointers.insert(std::make_pair(key, dev_bufferView)); } } // 2. for each mesh: // for each primitive: // build device buffer of indices, materail, and each attributes // and store these pointers in a map { std::map<std::string, glm::mat4> nodeString2Matrix; auto rootNodeNamesList = scene.scenes.at(scene.defaultScene); { auto it = rootNodeNamesList.begin(); auto itEnd = rootNodeNamesList.end(); for (; it != itEnd; ++it) { traverseNode(nodeString2Matrix, scene, *it, glm::mat4(1.0f)); } } // parse through node to access mesh auto itNode = nodeString2Matrix.begin(); auto itEndNode = nodeString2Matrix.end(); for (; itNode != itEndNode; ++itNode) { const tinygltf::Node & N = scene.nodes.at(itNode->first); const glm::mat4 & matrix = itNode->second; const glm::mat3 & matrixNormal = glm::transpose(glm::inverse(glm::mat3(matrix))); auto itMeshName = N.meshes.begin(); auto itEndMeshName = N.meshes.end(); for (; itMeshName != itEndMeshName; ++itMeshName) { const tinygltf::Mesh & mesh = scene.meshes.at(*itMeshName); auto res = mesh2PrimitivesMap.insert(std::pair<std::string, std::vector<PrimitiveDevBufPointers>>(mesh.name, std::vector<PrimitiveDevBufPointers>())); std::vector<PrimitiveDevBufPointers> & primitiveVector = (res.first)->second; // for each primitive for (size_t i = 0; i < mesh.primitives.size(); i++) { const tinygltf::Primitive &primitive = mesh.primitives[i]; if (primitive.indices.empty()) return; // TODO: add new attributes for your PrimitiveDevBufPointers when you add new attributes VertexIndex* dev_indices = NULL; VertexAttributePosition* dev_position = NULL; VertexAttributeNormal* dev_normal = NULL; VertexAttributeTexcoord* dev_texcoord0 = NULL; // ----------Indices------------- const tinygltf::Accessor &indexAccessor = scene.accessors.at(primitive.indices); const tinygltf::BufferView &bufferView = scene.bufferViews.at(indexAccessor.bufferView); BufferByte* dev_bufferView = bufferViewDevPointers.at(indexAccessor.bufferView); // assume type is SCALAR for indices int n = 1; int numIndices = indexAccessor.count; int componentTypeByteSize = sizeof(VertexIndex); int byteLength = numIndices * n * componentTypeByteSize; dim3 numThreadsPerBlock(128); dim3 numBlocks((numIndices + numThreadsPerBlock.x - 1) / numThreadsPerBlock.x); hipMalloc(&dev_indices, byteLength); _deviceBufferCopy << <numBlocks, numThreadsPerBlock >> > ( numIndices, (BufferByte*)dev_indices, dev_bufferView, n, indexAccessor.byteStride, indexAccessor.byteOffset, componentTypeByteSize); checkCUDAError("Set Index Buffer"); // ---------Primitive Info------- // Warning: LINE_STRIP is not supported in tinygltfloader int numPrimitives; PrimitiveType primitiveType; switch (primitive.mode) { case TINYGLTF_MODE_TRIANGLES: primitiveType = PrimitiveType::Triangle; numPrimitives = numIndices / 3; break; case TINYGLTF_MODE_TRIANGLE_STRIP: primitiveType = PrimitiveType::Triangle; numPrimitives = numIndices - 2; break; case TINYGLTF_MODE_TRIANGLE_FAN: primitiveType = PrimitiveType::Triangle; numPrimitives = numIndices - 2; break; case TINYGLTF_MODE_LINE: primitiveType = PrimitiveType::Line; numPrimitives = numIndices / 2; break; case TINYGLTF_MODE_LINE_LOOP: primitiveType = PrimitiveType::Line; numPrimitives = numIndices + 1; break; case TINYGLTF_MODE_POINTS: primitiveType = PrimitiveType::Point; numPrimitives = numIndices; break; default: // output error break; }; // ----------Attributes------------- auto it(primitive.attributes.begin()); auto itEnd(primitive.attributes.end()); int numVertices = 0; // for each attribute for (; it != itEnd; it++) { const tinygltf::Accessor &accessor = scene.accessors.at(it->second); const tinygltf::BufferView &bufferView = scene.bufferViews.at(accessor.bufferView); int n = 1; if (accessor.type == TINYGLTF_TYPE_SCALAR) { n = 1; } else if (accessor.type == TINYGLTF_TYPE_VEC2) { n = 2; } else if (accessor.type == TINYGLTF_TYPE_VEC3) { n = 3; } else if (accessor.type == TINYGLTF_TYPE_VEC4) { n = 4; } BufferByte * dev_bufferView = bufferViewDevPointers.at(accessor.bufferView); BufferByte ** dev_attribute = NULL; numVertices = accessor.count; int componentTypeByteSize; // Note: since the type of our attribute array (dev_position) is static (float32) // We assume the glTF model attribute type are 5126(FLOAT) here if (it->first.compare("POSITION") == 0) { componentTypeByteSize = sizeof(VertexAttributePosition) / n; dev_attribute = (BufferByte**)&dev_position; } else if (it->first.compare("NORMAL") == 0) { componentTypeByteSize = sizeof(VertexAttributeNormal) / n; dev_attribute = (BufferByte**)&dev_normal; } else if (it->first.compare("TEXCOORD_0") == 0) { componentTypeByteSize = sizeof(VertexAttributeTexcoord) / n; dev_attribute = (BufferByte**)&dev_texcoord0; } std::cout << accessor.bufferView << " - " << it->second << " - " << it->first << '\n'; dim3 numThreadsPerBlock(128); dim3 numBlocks((n * numVertices + numThreadsPerBlock.x - 1) / numThreadsPerBlock.x); int byteLength = numVertices * n * componentTypeByteSize; hipMalloc(dev_attribute, byteLength); _deviceBufferCopy << <numBlocks, numThreadsPerBlock >> > ( n * numVertices, *dev_attribute, dev_bufferView, n, accessor.byteStride, accessor.byteOffset, componentTypeByteSize); std::string msg = "Set Attribute Buffer: " + it->first; checkCUDAError(msg.c_str()); } // malloc for VertexOut VertexOut* dev_vertexOut; hipMalloc(&dev_vertexOut, numVertices * sizeof(VertexOut)); checkCUDAError("Malloc VertexOut Buffer"); // ----------Materials------------- // You can only worry about this part once you started to // implement textures for your rasterizer TextureData* dev_diffuseTex = NULL; int diffuseTexWidth = 0; int diffuseTexHeight = 0; if (!primitive.material.empty()) { const tinygltf::Material &mat = scene.materials.at(primitive.material); printf("material.name = %s\n", mat.name.c_str()); if (mat.values.find("diffuse") != mat.values.end()) { std::string diffuseTexName = mat.values.at("diffuse").string_value; if (scene.textures.find(diffuseTexName) != scene.textures.end()) { const tinygltf::Texture &tex = scene.textures.at(diffuseTexName); if (scene.images.find(tex.source) != scene.images.end()) { const tinygltf::Image &image = scene.images.at(tex.source); size_t s = image.image.size() * sizeof(TextureData); hipMalloc(&dev_diffuseTex, s); hipMemcpy(dev_diffuseTex, &image.image.at(0), s, hipMemcpyHostToDevice); diffuseTexWidth = image.width; diffuseTexHeight = image.height; checkCUDAError("Set Texture Image data"); } } } // TODO: write your code for other materails // You may have to take a look at tinygltfloader // You can also use the above code loading diffuse material as a start point } // ---------Node hierarchy transform-------- hipDeviceSynchronize(); dim3 numBlocksNodeTransform((numVertices + numThreadsPerBlock.x - 1) / numThreadsPerBlock.x); _nodeMatrixTransform << <numBlocksNodeTransform, numThreadsPerBlock >> > ( numVertices, dev_position, dev_normal, matrix, matrixNormal); checkCUDAError("Node hierarchy transformation"); // at the end of the for loop of primitive // push dev pointers to map primitiveVector.push_back(PrimitiveDevBufPointers{ primitive.mode, primitiveType, numPrimitives, numIndices, numVertices, dev_indices, dev_position, dev_normal, dev_texcoord0, dev_diffuseTex, diffuseTexWidth, diffuseTexHeight, dev_vertexOut //VertexOut }); totalNumPrimitives += numPrimitives; } // for each primitive } // for each mesh } // for each node } // 3. Malloc for dev_primitives { hipMalloc(&dev_primitives, totalNumPrimitives * sizeof(Primitive)); #if BACK_FACE_CULLING hipMalloc(&dev_primitives_compact, totalNumPrimitives * sizeof(Primitive)); #endif } // Finally, hipFree raw dev_bufferViews { std::map<std::string, BufferByte*>::const_iterator it(bufferViewDevPointers.begin()); std::map<std::string, BufferByte*>::const_iterator itEnd(bufferViewDevPointers.end()); //bufferViewDevPointers for (; it != itEnd; it++) { hipFree(it->second); } checkCUDAError("Free BufferView Device Mem"); } } __global__ void _vertexTransformAndAssembly( int numVertices, PrimitiveDevBufPointers primitive, glm::mat4 MVP, glm::mat4 MV, glm::mat3 MV_normal, int width, int height) { // vertex id int vid = (blockIdx.x * blockDim.x) + threadIdx.x; if (vid < numVertices) { // TODO: Apply vertex transformation here // Multiply the MVP matrix for each vertex position, this will transform everything into clipping space // Then divide the pos by its w element to transform into NDC space // Finally transform x and y to viewport space VertexOut &outVert = primitive.dev_verticesOut[vid]; glm::vec4 inPos(primitive.dev_position[vid], 1.f); glm::vec4 outPos; outPos = MVP * inPos; // transform outPos /= outPos.w; // rehomogenize outVert.pos.x = (1.f - outPos.x) * width * 0.5f; outVert.pos.y = (1.f - outPos.y) * height * 0.5f; outVert.pos.z = -outPos.z; outVert.eyePos = glm::vec3(MV * inPos); outVert.eyeNor = glm::normalize(MV_normal * primitive.dev_normal[vid]); #if TEXTURE outVert.texcoord0 = primitive.dev_texcoord0[vid]; outVert.dev_diffuseTex = primitive.dev_diffuseTex; outVert.texWidth = primitive.diffuseTexWidth; outVert.texHeight = primitive.diffuseTexHeight; #endif // TODO: Apply vertex assembly here // Assemble all attribute arraies into the primitive array } } static int curPrimitiveBeginId = 0; __global__ void _primitiveAssembly(int numIndices, int curPrimitiveBeginId, Primitive* dev_primitives, PrimitiveDevBufPointers primitive) { // index id int iid = (blockIdx.x * blockDim.x) + threadIdx.x; if (iid < numIndices) { // TODO: uncomment the following code for a start // This is primitive assembly for triangles int pid; // id for cur primitives vector if (primitive.primitiveMode == TINYGLTF_MODE_TRIANGLES) { pid = iid / (int)primitive.primitiveType; VertexOut &vout = primitive.dev_verticesOut[primitive.dev_indices[iid]]; dev_primitives[pid + curPrimitiveBeginId].v[iid % (int)primitive.primitiveType] = vout; #if BACK_FACE_CULLING if (glm::dot(vout.eyeNor, glm::vec3(0.f, 0.f, 1.f)) < 0.f) { dev_primitives[pid + curPrimitiveBeginId].back = true; } else { dev_primitives[pid + curPrimitiveBeginId].back = false; } #endif } // TODO: other primitive types (point, line) // point, line handled in rasterization.. } } /** * Creates a line from two points (A and B) using Digital Differential Analyzer (DDA) Algorithm * * Reference: http://www.geeksforgeeks.org/dda-line-generation-algorithm-computer-graphics/ */ __device__ void drawLine(glm::vec3 A, glm::vec3 B, Fragment *fragBuf, int width) { float dx = B.x - A.x; float dy = B.y - A.y; float steps = fabs(dx) > fabs(dy) ? dx : dy; dx /= fabs(steps); dy /= fabs(steps); float x = A.x, y = A.y; for (int i = 0; i < steps; i++) { int index = (int)x + (int)y * width; fragBuf[index].color = glm::vec3(0.98); x += dx; y += dy; } } __global__ void _rasterizeTriangles(int numTris, Primitive *dev_primitives, Fragment *fragBuf, int *depthBuf, int *mutex, int width, int height) { // index id int tid = (blockIdx.x * blockDim.x) + threadIdx.x; if (tid < numTris) { Primitive &prim = dev_primitives[tid]; glm::vec3 tri[3] = { glm::vec3(prim.v[0].pos), glm::vec3(prim.v[1].pos), glm::vec3(prim.v[2].pos) }; #if BACK_FACE_CULLING_WITHOUT_COMPACTION if (glm::dot(prim.v[0].eyeNor, glm::vec3(0.f, 0.f, 1.f)) < 0.f) { return; } #endif #if POINTS for (int i = 0; i < 3; i++) { int x = tri[i].x; int y = tri[i].y; int index = x + (y * width); #if DEBUG_DEPTH fragBuf[index].color = glm::abs(glm::vec3(1.f + tri[i].z)); #elif DEBUG_NORMALS fragBuf[index].color = prim.v[i].eyeNor; #else fragBuf[index].color = glm::vec3(0.98); #endif } #elif WIREFRAME drawLine(tri[0], tri[1], fragBuf, width); drawLine(tri[1], tri[2], fragBuf, width); drawLine(tri[2], tri[0], fragBuf, width); #else AABB bbox = getAABBForTriangle(tri); #if BBOX_OPTIMIZATIONS // return when the entire bbox is outside screen.. if (bbox.min.x > width || bbox.max.x<0 || bbox.min.y>height || bbox.max.y < 0) { return; } // clip bounding boxes to the screen size.. // won't cause much divergence as most of the threads // in a warp would fall in the same category most of the time.. if (bbox.min.x < 0) { bbox.min.x = 0.f; } if (bbox.min.y < 0) { bbox.min.y = 0.f; } if (bbox.max.x > width) { bbox.min.x = width; } if (bbox.max.y > height) { bbox.min.x = height; } #endif for (int y = bbox.min.y; y <= bbox.max.y; y++) { for (int x = bbox.min.x; x <= bbox.max.x; x++) { glm::vec2 point(x, y); glm::vec3 baryCoord = calculateBarycentricCoordinate(tri, point); if (!isBarycentricCoordInBounds(baryCoord)) { continue; } int baryZ = getZAtCoordinate(baryCoord, tri) * 10000; int index = x + (y * width); glm::vec3 eyePosition = prim.v[0].eyePos * baryCoord.x + prim.v[1].eyePos * baryCoord.y + prim.v[2].eyePos * baryCoord.z; bool isSet; do { isSet = (atomicCAS(&mutex[index], 0, 1) == 0); if (isSet) { if (depthBuf[index] > baryZ) { depthBuf[index] = baryZ; fragBuf[index].eyePos = eyePosition; fragBuf[index].eyeNor = prim.v[0].eyeNor * baryCoord.x + prim.v[1].eyeNor * baryCoord.y + prim.v[2].eyeNor * baryCoord.z; #if DEBUG_DEPTH fragBuf[index].color = glm::abs(glm::vec3(1.f - baryZ / 10000.f)); #elif DEBUG_NORMALS fragBuf[index].color = fragBuf[index].eyeNor; #elif TEXTURE #if TEXTURE_PERSP_CORRECT float z0 = prim.v[0].eyePos.z, z1 = prim.v[1].eyePos.z, z2 = prim.v[2].eyePos.z; float z = baryCoord.x / z0 + baryCoord.y / z1 + baryCoord.z / z2; fragBuf[index].texcoord0 = (prim.v[0].texcoord0 / z0 * baryCoord.x + prim.v[1].texcoord0 / z1 * baryCoord.y + prim.v[2].texcoord0 / z2 * baryCoord.z) / z; #else fragBuf[index].texcoord0 = prim.v[0].texcoord0 * baryCoord.x + prim.v[1].texcoord0 * baryCoord.y + prim.v[2].texcoord0 * baryCoord.z; #endif fragBuf[index].dev_diffuseTex = prim.v[0].dev_diffuseTex; fragBuf[index].texWidth = prim.v[0].texWidth; fragBuf[index].texHeight = prim.v[0].texHeight; fragBuf[index].color = glm::vec3(0.98); #else // lambert fragBuf[index].color = glm::vec3(0.98); #endif } mutex[index] = 0; } } while (!isSet); } } #endif } } /** * predicate struct for thrust::copy_if */ struct isNotBack { __host__ __device__ bool operator()(const Primitive &prim) { return !prim.back; } }; /** * Perform rasterization. */ void rasterize(uchar4 *pbo, const glm::mat4 & MVP, const glm::mat4 & MV, const glm::mat3 MV_normal) { int sideLength2d = 8; dim3 blockSize2d(sideLength2d, sideLength2d); dim3 blockCount2d((width - 1) / blockSize2d.x + 1, (height - 1) / blockSize2d.y + 1); // Execute your rasterization pipeline here // (See README for rasterization pipeline outline.) // Vertex Process & primitive assembly { curPrimitiveBeginId = 0; dim3 numThreadsPerBlock(128); auto it = mesh2PrimitivesMap.begin(); auto itEnd = mesh2PrimitivesMap.end(); for (; it != itEnd; ++it) { auto p = (it->second).begin(); // each primitive auto pEnd = (it->second).end(); for (; p != pEnd; ++p) { dim3 numBlocksForVertices((p->numVertices + numThreadsPerBlock.x - 1) / numThreadsPerBlock.x); dim3 numBlocksForIndices((p->numIndices + numThreadsPerBlock.x - 1) / numThreadsPerBlock.x); hipLaunchKernelGGL(( _vertexTransformAndAssembly) , dim3(numBlocksForVertices), dim3(numThreadsPerBlock), 0, 0, p->numVertices, *p, MVP, MV, MV_normal, width, height); checkCUDAError("Vertex Processing"); hipDeviceSynchronize(); hipLaunchKernelGGL(( _primitiveAssembly) , dim3(numBlocksForIndices), dim3(numThreadsPerBlock), 0, 0, p->numIndices, curPrimitiveBeginId, dev_primitives, *p); checkCUDAError("Primitive Assembly"); curPrimitiveBeginId += p->numPrimitives; } } checkCUDAError("Vertex Processing and Primitive Assembly"); } hipMemset(dev_fragmentBuffer, 0, width * height * sizeof(Fragment)); hipMemset(dev_mutex, 0, width * height * sizeof(int)); initDepth << <blockCount2d, blockSize2d >> > (width, height, dev_depth); #if BACK_FACE_CULLING hipMemset(dev_primitives_compact, 0, totalNumPrimitives * sizeof(Primitive)); Primitive* end = thrust::copy_if(thrust::device, dev_primitives, dev_primitives + totalNumPrimitives, dev_primitives_compact, isNotBack()); checkCUDAError("Back face culling: thrust::partition"); totalNumPrimitivesCompact = end - dev_primitives_compact; //// TODO: rasterize dim3 numThreadsPerBlock(128); dim3 numBlocksPerTriangle((totalNumPrimitivesCompact + numThreadsPerBlock.x - 1) / numThreadsPerBlock.x); _rasterizeTriangles << <numBlocksPerTriangle, numThreadsPerBlock >> > (totalNumPrimitivesCompact, dev_primitives_compact, dev_fragmentBuffer, dev_depth, dev_mutex, width, height); checkCUDAError("rasterize triangles"); #else //// TODO: rasterize dim3 numThreadsPerBlock(128); dim3 numBlocksPerTriangle((totalNumPrimitives + numThreadsPerBlock.x - 1) / numThreadsPerBlock.x); hipLaunchKernelGGL(( _rasterizeTriangles) , dim3(numBlocksPerTriangle), dim3(numThreadsPerBlock), 0, 0, totalNumPrimitives, dev_primitives, dev_fragmentBuffer, dev_depth, dev_mutex, width, height); checkCUDAError("rasterize triangles"); #endif #if SSAO // SSAO shaderSSAO << <blockCount2d, blockSize2d >> > (width, height, dev_fragmentBuffer); checkCUDAError("SSAO"); #endif // Copy fragmentbuffer colors into framebuffer [frame buffer is sent for post processing] hipLaunchKernelGGL(( render) , dim3(blockCount2d), dim3(blockSize2d), 0, 0, width, height, dev_fragmentBuffer, dev_framebuffer); checkCUDAError("fragment shader"); #if BLUR #if BLUR_SHARED // Doing seperate blur in X and then in Y to make things faster.. // Using 2 postbuffers to avoid over-writing and collision between threads while doing blurring in Y dir.. // blur in x dir dim3 threadsX(width), blocksX(height), threadsY(height), blocksY(width); bool dirX = true; hipLaunchKernelGGL(( postProcessShared) , dim3(blocksX), dim3(threadsX), width * sizeof(glm::vec3), 0, dirX, width, height, dev_framebuffer, dev_depth, dev_postBuffer1); checkCUDAError("post shader X"); // blur in y dir dirX = false; hipLaunchKernelGGL(( postProcessShared) , dim3(blocksY), dim3(threadsY), height * sizeof(glm::vec3), 0, dirX, width, height, dev_postBuffer1, dev_depth, dev_postBuffer2); checkCUDAError("post shader Y"); // 2nd pass for more blurring.. dirX = true; hipLaunchKernelGGL(( postProcessShared) , dim3(blocksX), dim3(threadsX), width * sizeof(glm::vec3), 0, dirX, width, height, dev_postBuffer2, dev_depth, dev_postBuffer1); checkCUDAError("post shader X"); // blur in y dir dirX = false; hipLaunchKernelGGL(( postProcessShared) , dim3(blocksY), dim3(threadsY), height * sizeof(glm::vec3), 0, dirX, width, height, dev_postBuffer1, dev_depth, dev_postBuffer2); checkCUDAError("post shader Y"); #else // This version doesn't use shared memory. It is implemented only for the sake of comparison // blur in x dir dim3 threadsX(width), threadsY(height), blocksX(height), blocksY(width); bool dirX = true; hipLaunchKernelGGL(( postProcess) , dim3(blocksX), dim3(threadsX), 0, 0, dirX, width, height, dev_framebuffer, dev_depth, dev_postBuffer1); checkCUDAError("post shader X"); // blur in y dir dirX = false; hipLaunchKernelGGL(( postProcess) , dim3(blocksY), dim3(threadsY), 0, 0, dirX, width, height, dev_postBuffer1, dev_depth, dev_postBuffer2); checkCUDAError("post shader Y"); #endif // blend for DOF hipLaunchKernelGGL(( postBlend) , dim3(blockCount2d), dim3(blockSize2d), 0, 0, width, height, dev_framebuffer, dev_depth, dev_postBuffer2); checkCUDAError("copy post render result to pbo"); // Copy framebuffer into OpenGL buffer for OpenGL previewing hipLaunchKernelGGL(( sendImageToPBO) , dim3(blockCount2d), dim3(blockSize2d), 0, 0, pbo, width, height, dev_postBuffer2); checkCUDAError("copy post render result to pbo"); #else blockSize2d = dim3(sideLength2d, sideLength2d); blockCount2d = dim3((width/SSAA - 1) / blockSize2d.x + 1, (height/SSAA - 1) / blockSize2d.y + 1); // Copy framebuffer into OpenGL buffer for OpenGL previewing hipLaunchKernelGGL(( sendImageToPBO) , dim3(blockCount2d), dim3(blockSize2d), 0, 0, pbo, width, height, dev_framebuffer); checkCUDAError("copy render result to pbo"); #endif } /** * Called once at the end of the program to free CUDA memory. */ void rasterizeFree() { // deconstruct primitives attribute/indices device buffer auto it(mesh2PrimitivesMap.begin()); auto itEnd(mesh2PrimitivesMap.end()); for (; it != itEnd; ++it) { for (auto p = it->second.begin(); p != it->second.end(); ++p) { hipFree(p->dev_indices); hipFree(p->dev_position); hipFree(p->dev_normal); hipFree(p->dev_texcoord0); hipFree(p->dev_diffuseTex); hipFree(p->dev_verticesOut); //TODO: release other attributes and materials } } //////////// hipFree(dev_primitives); dev_primitives = NULL; hipFree(dev_fragmentBuffer); dev_fragmentBuffer = NULL; hipFree(dev_framebuffer); dev_framebuffer = NULL; hipFree(dev_postBuffer1); dev_postBuffer1 = NULL; hipFree(dev_postBuffer2); dev_postBuffer2 = NULL; hipFree(dev_depth); dev_depth = NULL; hipFree(dev_mutex); dev_mutex = NULL; hipFree(dev_primitives_compact); dev_primitives = NULL; checkCUDAError("rasterize Free"); }
64080d6c247cac0766ba74cd880be0da8fc1219e.cu
/** * @file rasterize.cu * @brief CUDA-accelerated rasterization pipeline. * @authors Skeleton code: Yining Karl Li, Kai Ninomiya, Shuai Shao (Shrek) * @date 2012-2016 * @copyright University of Pennsylvania & STUDENT */ #include <cmath> #include <cstdio> #include <cuda.h> #include <cuda_runtime.h> #include <thrust/random.h> #include <util/checkCUDAError.h> #include <util/tiny_gltf_loader.h> #include "rasterizeTools.h" #include "rasterize.h" #include <glm/gtc/quaternion.hpp> #include <glm/gtc/matrix_transform.hpp> #include <thrust/execution_policy.h> #include <thrust/partition.h> #include <chrono> #define POINTS 0 #define WIREFRAME 0 #define DEBUG_DEPTH 0 #define DEBUG_NORMALS 0 #define TEXTURE 1 #define TEXTURE_PERSP_CORRECT 1 #define TEXTURE_BILINEAR_FILT 1 #define BLUR 0 #define BLUR_SHARED 0 #define SSAO 0 // SCREEN SPACE AMBIENT OCCLUSION : WORK UNDER PROGRESS #define BBOX_OPTIMIZATIONS 1 #define BACK_FACE_CULLING 0 #define BACK_FACE_CULLING_WITHOUT_COMPACTION 0 #define SSAA 2 // SUPERSAMPLE ANTIALIASING // 1 (min value : no AA), 2, 4, ... namespace { typedef unsigned short VertexIndex; typedef glm::vec3 VertexAttributePosition; typedef glm::vec3 VertexAttributeNormal; typedef glm::vec2 VertexAttributeTexcoord; typedef unsigned char TextureData; typedef unsigned char BufferByte; enum PrimitiveType { Point = 1, Line = 2, Triangle = 3 }; struct VertexOut { glm::vec4 pos; // TODO: add new attributes to your VertexOut // The attributes listed below might be useful, // but always feel free to modify on your own glm::vec3 eyePos; // eye space position used for shading glm::vec3 eyeNor; // eye space normal used for shading, cuz normal will go wrong after perspective transformation //glm::vec3 col; glm::vec2 texcoord0; TextureData* dev_diffuseTex = NULL; int texWidth, texHeight; // ... }; struct Primitive { PrimitiveType primitiveType = Triangle; // C++ 11 init VertexOut v[3]; bool back = false; // used for back face culling }; struct Fragment { glm::vec3 color; // TODO: add new attributes to your Fragment // The attributes listed below might be useful, // but always feel free to modify on your own glm::vec3 eyePos; // eye space position used for shading glm::vec3 eyeNor; VertexAttributeTexcoord texcoord0; TextureData* dev_diffuseTex = NULL; int texWidth, texHeight; // ... }; struct PrimitiveDevBufPointers { int primitiveMode; //from tinygltfloader macro PrimitiveType primitiveType; int numPrimitives; int numIndices; int numVertices; // Vertex In, const after loaded VertexIndex* dev_indices; VertexAttributePosition* dev_position; VertexAttributeNormal* dev_normal; VertexAttributeTexcoord* dev_texcoord0; // Materials, add more attributes when needed TextureData* dev_diffuseTex; int diffuseTexWidth; int diffuseTexHeight; // TextureData* dev_specularTex; // TextureData* dev_normalTex; // ... // Vertex Out, vertex used for rasterization, this is changing every frame VertexOut* dev_verticesOut; // TODO: add more attributes when needed }; } static std::map<std::string, std::vector<PrimitiveDevBufPointers>> mesh2PrimitivesMap; static int width = 0; static int height = 0; static int totalNumPrimitivesCompact = 0; // updated after compaction by culling static int totalNumPrimitives = 0; static Primitive *dev_primitives = NULL; static Fragment *dev_fragmentBuffer = NULL; static glm::vec3 *dev_framebuffer = NULL; static int * dev_depth = NULL; // you might need this buffer when doing depth test static int * dev_mutex = NULL; static glm::vec3 *dev_postBuffer1 = NULL; static glm::vec3 *dev_postBuffer2 = NULL; static Primitive *dev_primitives_compact = NULL; // gaussian kernel // source: http://www.sunsetlakesoftware.com/2013/10/21/optimizing-gaussian-blurs-mobile-gpu // source: http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/ __constant__ float mat[5] = { 0.2270270270, 0.1945945946, 0.1216216216, 0.0540540541, 0.0162162162 }; __constant__ float light[3] = {100.f, 100.f, 100.f}; /** * Called once at the beginning of the program to allocate memory. */ void rasterizeInit(int w, int h) { width = w * SSAA; height = h * SSAA; cudaFree(dev_fragmentBuffer); cudaMalloc(&dev_fragmentBuffer, width * height * sizeof(Fragment)); cudaMemset(dev_fragmentBuffer, 0, width * height * sizeof(Fragment)); cudaFree(dev_framebuffer); cudaMalloc(&dev_framebuffer, width * height * sizeof(glm::vec3)); cudaMemset(dev_framebuffer, 0, width * height * sizeof(glm::vec3)); cudaMalloc(&dev_postBuffer1, width * height * sizeof(glm::vec3)); cudaMemset(dev_postBuffer1, 0, width * height * sizeof(glm::vec3)); cudaMalloc(&dev_postBuffer2, width * height * sizeof(glm::vec3)); cudaMemset(dev_postBuffer2, 0, width * height * sizeof(glm::vec3)); cudaFree(dev_depth); cudaMalloc(&dev_depth, width * height * sizeof(int)); cudaFree(dev_mutex); cudaMalloc(&dev_mutex, width * height * sizeof(int)); checkCUDAError("rasterizeInit"); } __global__ void initDepth(int w, int h, int *depth) { int x = (blockIdx.x * blockDim.x) + threadIdx.x; int y = (blockIdx.y * blockDim.y) + threadIdx.y; if (x < w && y < h) { int index = x + (y * w); depth[index] = INT_MAX; } } /** * Kernel that writes the image to the OpenGL PBO directly. */ __global__ void sendImageToPBO(uchar4 *pbo, int w, int h, glm::vec3 *image) { int x = (blockIdx.x * blockDim.x) + threadIdx.x; int y = (blockIdx.y * blockDim.y) + threadIdx.y; int width = w / SSAA; int height = h / SSAA; int index = x + (y * width); if (x < width && y < height) { glm::vec3 color; for (int i = 0; i < SSAA; i++) { for (int j = 0; j < SSAA; j++) { int ind = (x *SSAA) + i + (y * SSAA + j) * w; color.x += glm::clamp(image[ind].x, 0.0f, 1.0f) * 255.0; color.y += glm::clamp(image[ind].y, 0.0f, 1.0f) * 255.0; color.z += glm::clamp(image[ind].z, 0.0f, 1.0f) * 255.0; } } color /= (SSAA*SSAA); // Each thread writes one pixel location in the texture (textel) pbo[index].w = 0; pbo[index].x = color.x; pbo[index].y = color.y; pbo[index].z = color.z; } } /** * Returns texture color for a fragment */ __device__ glm::vec3 getColor(Fragment &fragment, glm::vec2 uv) { // the color is stored in a 1D array of floats.. // convert to 1D index // scale by 3 int index = ((int)uv.x + (int)uv.y * fragment.texWidth) * 3; glm::vec3 col(fragment.dev_diffuseTex[index], fragment.dev_diffuseTex[index + 1], fragment.dev_diffuseTex[index + 2]); return col / 255.f; // map colors to 0-1 range.. } /** * Returns Bilinear Filtered texture color for a fragment * Reference: https://en.wikipedia.org/wiki/Bilinear_filtering */ __device__ glm::vec3 getBilinearFilteredColor(Fragment &fragment, glm::vec2 uv) { // get 4 valid indices.. int intX0 = uv.x; int intY0 = uv.y; int intX1 = glm::clamp(intX0 + 1, 0, fragment.texWidth - 1); int intY1 = glm::clamp(intY0 + 1, 0, fragment.texHeight - 1); // get colors at 4 texels.. glm::vec3 col00 = getColor(fragment, glm::vec2(intX0, intY0)); glm::vec3 col01 = getColor(fragment, glm::vec2(intX0, intY1)); glm::vec3 col10 = getColor(fragment, glm::vec2(intX1, intY0)); glm::vec3 col11 = getColor(fragment, glm::vec2(intX1, intY1)); // lerp based on fractional parts.. float fracX = uv.x - intX0; float fracY = uv.y - intY0; glm::vec3 col0001 = glm::mix(col00, col01, fracY); glm::vec3 col1011 = glm::mix(col10, col11, fracY); return glm::mix(col0001, col1011, fracX); } /** * Writes fragment colors to the framebuffer */ __global__ void render(int w, int h, Fragment *fragmentBuffer, glm::vec3 *framebuffer) { int x = (blockIdx.x * blockDim.x) + threadIdx.x; int y = (blockIdx.y * blockDim.y) + threadIdx.y; if (x < w && y < h) { int index = x + (y * w); glm::vec3 &outPix = framebuffer[index]; Fragment &frag = fragmentBuffer[index]; if (frag.color == glm::vec3()) { outPix *= 0.f; return; } #if POINTS || WIREFRAME outPix = frag.color; #elif DEBUG_DEPTH outPix = frag.color; // maybe scale this to look better??? #elif DEBUG_NORMALS outPix = frag.color; #elif TEXTURE if (frag.dev_diffuseTex != NULL) { #if TEXTURE_BILINEAR_FILT glm::vec2 uv(frag.texcoord0.x * frag.texWidth, frag.texcoord0.y * frag.texHeight); outPix = getBilinearFilteredColor(frag, uv); #else glm::vec2 uv(frag.texcoord0.x * frag.texWidth, frag.texcoord0.y * frag.texHeight); outPix = getColor(frag, uv); #endif // LAMBERT SHADING: glm::vec3 lightDir = glm::normalize(frag.eyePos - glm::vec3(1.f)); outPix *= glm::max(fabs(glm::dot(lightDir, frag.eyeNor)), 0.2f); } else { outPix = glm::vec3(); // reset color.. } #else // LAMBERT SHADING: glm::vec3 lightDir = frag.eyePos - glm::vec3(light[0], light[1], light[2]); lightDir = glm::normalize(lightDir); float dot = glm::dot(-lightDir, frag.eyeNor); if (dot <= 0.1f) { dot = 0.1f; } glm::vec3 col = frag.color * dot; outPix = col; #endif } } // Screen space ambient occlusion // https://www.gamedev.net/articles/programming/graphics/a-simple-and-practical-approach-to-ssao-r2753/ __global__ void shaderSSAO(int w, int h, Fragment *fragmentBuffer) { int x = (blockIdx.x * blockDim.x) + threadIdx.x; int y = (blockIdx.y * blockDim.y) + threadIdx.y; if (x < w && y < h) { int index = x + (y * w); Fragment &frag = fragmentBuffer[index]; float ao = 0.f; for (int i = -2; i < 3; i++) { for (int j = -2; j < 3; j++) { int xi = x + i; int yi = y + i; if (xi > 0 && yi > 0 && xi < w && yi < h && i != 0 && j != 0) { int idxi = xi + (yi * w); Fragment &fragi = fragmentBuffer[idxi]; glm::vec3 N = fragi.eyeNor; glm::vec3 V = fragi.eyePos - frag.eyePos; float d = glm::length(V); ao += glm::max(0.f, glm::dot(N, glm::normalize(V))) * (1.f / (1.f + d)); } } } frag.color = ao * glm::vec3(1.f); } } /** * Post Processing Shader * operates on framebuffer * uses the __constant__ gaussian kernel defined above.. */ __global__ void postProcess(bool dirX, int w, int h, glm::vec3 *frameBuffer, int* depthBuffer, glm::vec3 *postBuffer) { int x = dirX ? threadIdx.x : blockIdx.x; int y = dirX ? blockIdx.x : threadIdx.x; int index = x + (y * w); if (x < w && y < h) { glm::vec3 col = mat[0] * frameBuffer[index]; if (dirX) { for (int i = 1; i < 5; i++) { if (x + i < w) { col += mat[i] * frameBuffer[(x + i) + y * w]; } if (x - i >= 0) { col += mat[i] * frameBuffer[(x - i) + y * w]; } } } else { for (int i = 1; i < 5; i++) { if (y + i < h) { col += mat[i] * frameBuffer[x + (y + i) * w]; } if (y - i >= 0) { col += mat[i] * frameBuffer[x + (y - i) * w]; } } } postBuffer[index] = col; } else { postBuffer[index] = frameBuffer[index]; } } __global__ void postProcessShared(bool dirX, int w, int h, glm::vec3 *frameBuffer, int* depthBuffer, glm::vec3 *postBuffer) { int x = dirX ? threadIdx.x : blockIdx.x; int y = dirX ? blockIdx.x : threadIdx.x; int index = x + (y * w); if (x >= w || y >= h) { return; } // https://devblogs.nvidia.com/parallelforall/using-shared-memory-cuda-cc/ extern __shared__ glm::vec3 sm[]; if (dirX) { sm[x] = frameBuffer[index]; } else { sm[y] = frameBuffer[index]; } __syncthreads(); int depth = depthBuffer[index]; glm::vec3 col; if (dirX) { col = mat[0] * sm[x]; for (int i = 1; i < 5; i++) { if (x + i < w) { if (abs(depthBuffer[(x + i) + y * w] - depth) < 10000) { col += mat[i] * sm[x + i]; } } if (x - i >= 0) { if (abs(depthBuffer[(x - i) + y * w] - depth) < 10000) { col += mat[i] * sm[x - i]; } } } } else { col = mat[0] * sm[y]; for (int i = 1; i < 5; i++) { if (y + i < h) { if (abs(depthBuffer[x + (y + i) * w] - depth) < 10000) { col += mat[i] * sm[y + i]; } } if (y - i >= 0) { if (abs(depthBuffer[x + (y - i) * w] - depth) < 10000) { col += mat[i] * sm[y - i]; } } } } postBuffer[index] = col; } /** * Blend kernel for DOF * reference: https://mynameismjp.wordpress.com/the-museum/samples-tutorials-tools/depth-of-field-sample/ */ __global__ void postBlend(int w, int h, glm::vec3 *frameBuffer, int *depthBuffer, glm::vec3 *postBuffer) { int x = (blockIdx.x * blockDim.x) + threadIdx.x; int y = (blockIdx.y * blockDim.y) + threadIdx.y; int index = x + (y * w); if (x < w && y < h && frameBuffer[index]!=glm::vec3()) { float z = depthBuffer[index] * .0001f; //z = z < 0.3 ? fabs(z - 0.3) * 2.f : fabs(z - 0.3) * 2.f; //postBuffer[index] *= z; //postBuffer[index] += (1 - z) * frameBuffer[index]; z = fabs(z - 0.5) * 2.f; postBuffer[index] *= z; postBuffer[index] += (1 - z) * frameBuffer[index]; } } /** * kern function with support for stride to sometimes replace cudaMemcpy * One thread is responsible for copying one component */ __global__ void _deviceBufferCopy(int N, BufferByte* dev_dst, const BufferByte* dev_src, int n, int byteStride, int byteOffset, int componentTypeByteSize) { // Attribute (vec3 position) // component (3 * float) // byte (4 * byte) // id of component int i = (blockIdx.x * blockDim.x) + threadIdx.x; if (i < N) { int count = i / n; int offset = i - count * n; // which component of the attribute for (int j = 0; j < componentTypeByteSize; j++) { dev_dst[count * componentTypeByteSize * n + offset * componentTypeByteSize + j] = dev_src[byteOffset + count * (byteStride == 0 ? componentTypeByteSize * n : byteStride) + offset * componentTypeByteSize + j]; } } } __global__ void _nodeMatrixTransform( int numVertices, VertexAttributePosition* position, VertexAttributeNormal* normal, glm::mat4 MV, glm::mat3 MV_normal) { // vertex id int vid = (blockIdx.x * blockDim.x) + threadIdx.x; if (vid < numVertices) { position[vid] = glm::vec3(MV * glm::vec4(position[vid], 1.0f)); normal[vid] = glm::normalize(MV_normal * normal[vid]); } } glm::mat4 getMatrixFromNodeMatrixVector(const tinygltf::Node & n) { glm::mat4 curMatrix(1.0); const std::vector<double> &m = n.matrix; if (m.size() > 0) { // matrix, copy it for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { curMatrix[i][j] = (float)m.at(4 * i + j); } } } else { // no matrix, use rotation, scale, translation if (n.translation.size() > 0) { curMatrix[3][0] = n.translation[0]; curMatrix[3][1] = n.translation[1]; curMatrix[3][2] = n.translation[2]; } if (n.rotation.size() > 0) { glm::mat4 R; glm::quat q; q[0] = n.rotation[0]; q[1] = n.rotation[1]; q[2] = n.rotation[2]; R = glm::mat4_cast(q); curMatrix = curMatrix * R; } if (n.scale.size() > 0) { curMatrix = curMatrix * glm::scale(glm::vec3(n.scale[0], n.scale[1], n.scale[2])); } } return curMatrix; } void traverseNode ( std::map<std::string, glm::mat4> & n2m, const tinygltf::Scene & scene, const std::string & nodeString, const glm::mat4 & parentMatrix ) { const tinygltf::Node & n = scene.nodes.at(nodeString); glm::mat4 M = parentMatrix * getMatrixFromNodeMatrixVector(n); n2m.insert(std::pair<std::string, glm::mat4>(nodeString, M)); auto it = n.children.begin(); auto itEnd = n.children.end(); for (; it != itEnd; ++it) { traverseNode(n2m, scene, *it, M); } } void rasterizeSetBuffers(const tinygltf::Scene & scene) { totalNumPrimitives = 0; std::map<std::string, BufferByte*> bufferViewDevPointers; // 1. copy all `bufferViews` to device memory { std::map<std::string, tinygltf::BufferView>::const_iterator it( scene.bufferViews.begin()); std::map<std::string, tinygltf::BufferView>::const_iterator itEnd( scene.bufferViews.end()); for (; it != itEnd; it++) { const std::string key = it->first; const tinygltf::BufferView &bufferView = it->second; if (bufferView.target == 0) { continue; // Unsupported bufferView. } const tinygltf::Buffer &buffer = scene.buffers.at(bufferView.buffer); BufferByte* dev_bufferView; cudaMalloc(&dev_bufferView, bufferView.byteLength); cudaMemcpy(dev_bufferView, &buffer.data.front() + bufferView.byteOffset, bufferView.byteLength, cudaMemcpyHostToDevice); checkCUDAError("Set BufferView Device Mem"); bufferViewDevPointers.insert(std::make_pair(key, dev_bufferView)); } } // 2. for each mesh: // for each primitive: // build device buffer of indices, materail, and each attributes // and store these pointers in a map { std::map<std::string, glm::mat4> nodeString2Matrix; auto rootNodeNamesList = scene.scenes.at(scene.defaultScene); { auto it = rootNodeNamesList.begin(); auto itEnd = rootNodeNamesList.end(); for (; it != itEnd; ++it) { traverseNode(nodeString2Matrix, scene, *it, glm::mat4(1.0f)); } } // parse through node to access mesh auto itNode = nodeString2Matrix.begin(); auto itEndNode = nodeString2Matrix.end(); for (; itNode != itEndNode; ++itNode) { const tinygltf::Node & N = scene.nodes.at(itNode->first); const glm::mat4 & matrix = itNode->second; const glm::mat3 & matrixNormal = glm::transpose(glm::inverse(glm::mat3(matrix))); auto itMeshName = N.meshes.begin(); auto itEndMeshName = N.meshes.end(); for (; itMeshName != itEndMeshName; ++itMeshName) { const tinygltf::Mesh & mesh = scene.meshes.at(*itMeshName); auto res = mesh2PrimitivesMap.insert(std::pair<std::string, std::vector<PrimitiveDevBufPointers>>(mesh.name, std::vector<PrimitiveDevBufPointers>())); std::vector<PrimitiveDevBufPointers> & primitiveVector = (res.first)->second; // for each primitive for (size_t i = 0; i < mesh.primitives.size(); i++) { const tinygltf::Primitive &primitive = mesh.primitives[i]; if (primitive.indices.empty()) return; // TODO: add new attributes for your PrimitiveDevBufPointers when you add new attributes VertexIndex* dev_indices = NULL; VertexAttributePosition* dev_position = NULL; VertexAttributeNormal* dev_normal = NULL; VertexAttributeTexcoord* dev_texcoord0 = NULL; // ----------Indices------------- const tinygltf::Accessor &indexAccessor = scene.accessors.at(primitive.indices); const tinygltf::BufferView &bufferView = scene.bufferViews.at(indexAccessor.bufferView); BufferByte* dev_bufferView = bufferViewDevPointers.at(indexAccessor.bufferView); // assume type is SCALAR for indices int n = 1; int numIndices = indexAccessor.count; int componentTypeByteSize = sizeof(VertexIndex); int byteLength = numIndices * n * componentTypeByteSize; dim3 numThreadsPerBlock(128); dim3 numBlocks((numIndices + numThreadsPerBlock.x - 1) / numThreadsPerBlock.x); cudaMalloc(&dev_indices, byteLength); _deviceBufferCopy << <numBlocks, numThreadsPerBlock >> > ( numIndices, (BufferByte*)dev_indices, dev_bufferView, n, indexAccessor.byteStride, indexAccessor.byteOffset, componentTypeByteSize); checkCUDAError("Set Index Buffer"); // ---------Primitive Info------- // Warning: LINE_STRIP is not supported in tinygltfloader int numPrimitives; PrimitiveType primitiveType; switch (primitive.mode) { case TINYGLTF_MODE_TRIANGLES: primitiveType = PrimitiveType::Triangle; numPrimitives = numIndices / 3; break; case TINYGLTF_MODE_TRIANGLE_STRIP: primitiveType = PrimitiveType::Triangle; numPrimitives = numIndices - 2; break; case TINYGLTF_MODE_TRIANGLE_FAN: primitiveType = PrimitiveType::Triangle; numPrimitives = numIndices - 2; break; case TINYGLTF_MODE_LINE: primitiveType = PrimitiveType::Line; numPrimitives = numIndices / 2; break; case TINYGLTF_MODE_LINE_LOOP: primitiveType = PrimitiveType::Line; numPrimitives = numIndices + 1; break; case TINYGLTF_MODE_POINTS: primitiveType = PrimitiveType::Point; numPrimitives = numIndices; break; default: // output error break; }; // ----------Attributes------------- auto it(primitive.attributes.begin()); auto itEnd(primitive.attributes.end()); int numVertices = 0; // for each attribute for (; it != itEnd; it++) { const tinygltf::Accessor &accessor = scene.accessors.at(it->second); const tinygltf::BufferView &bufferView = scene.bufferViews.at(accessor.bufferView); int n = 1; if (accessor.type == TINYGLTF_TYPE_SCALAR) { n = 1; } else if (accessor.type == TINYGLTF_TYPE_VEC2) { n = 2; } else if (accessor.type == TINYGLTF_TYPE_VEC3) { n = 3; } else if (accessor.type == TINYGLTF_TYPE_VEC4) { n = 4; } BufferByte * dev_bufferView = bufferViewDevPointers.at(accessor.bufferView); BufferByte ** dev_attribute = NULL; numVertices = accessor.count; int componentTypeByteSize; // Note: since the type of our attribute array (dev_position) is static (float32) // We assume the glTF model attribute type are 5126(FLOAT) here if (it->first.compare("POSITION") == 0) { componentTypeByteSize = sizeof(VertexAttributePosition) / n; dev_attribute = (BufferByte**)&dev_position; } else if (it->first.compare("NORMAL") == 0) { componentTypeByteSize = sizeof(VertexAttributeNormal) / n; dev_attribute = (BufferByte**)&dev_normal; } else if (it->first.compare("TEXCOORD_0") == 0) { componentTypeByteSize = sizeof(VertexAttributeTexcoord) / n; dev_attribute = (BufferByte**)&dev_texcoord0; } std::cout << accessor.bufferView << " - " << it->second << " - " << it->first << '\n'; dim3 numThreadsPerBlock(128); dim3 numBlocks((n * numVertices + numThreadsPerBlock.x - 1) / numThreadsPerBlock.x); int byteLength = numVertices * n * componentTypeByteSize; cudaMalloc(dev_attribute, byteLength); _deviceBufferCopy << <numBlocks, numThreadsPerBlock >> > ( n * numVertices, *dev_attribute, dev_bufferView, n, accessor.byteStride, accessor.byteOffset, componentTypeByteSize); std::string msg = "Set Attribute Buffer: " + it->first; checkCUDAError(msg.c_str()); } // malloc for VertexOut VertexOut* dev_vertexOut; cudaMalloc(&dev_vertexOut, numVertices * sizeof(VertexOut)); checkCUDAError("Malloc VertexOut Buffer"); // ----------Materials------------- // You can only worry about this part once you started to // implement textures for your rasterizer TextureData* dev_diffuseTex = NULL; int diffuseTexWidth = 0; int diffuseTexHeight = 0; if (!primitive.material.empty()) { const tinygltf::Material &mat = scene.materials.at(primitive.material); printf("material.name = %s\n", mat.name.c_str()); if (mat.values.find("diffuse") != mat.values.end()) { std::string diffuseTexName = mat.values.at("diffuse").string_value; if (scene.textures.find(diffuseTexName) != scene.textures.end()) { const tinygltf::Texture &tex = scene.textures.at(diffuseTexName); if (scene.images.find(tex.source) != scene.images.end()) { const tinygltf::Image &image = scene.images.at(tex.source); size_t s = image.image.size() * sizeof(TextureData); cudaMalloc(&dev_diffuseTex, s); cudaMemcpy(dev_diffuseTex, &image.image.at(0), s, cudaMemcpyHostToDevice); diffuseTexWidth = image.width; diffuseTexHeight = image.height; checkCUDAError("Set Texture Image data"); } } } // TODO: write your code for other materails // You may have to take a look at tinygltfloader // You can also use the above code loading diffuse material as a start point } // ---------Node hierarchy transform-------- cudaDeviceSynchronize(); dim3 numBlocksNodeTransform((numVertices + numThreadsPerBlock.x - 1) / numThreadsPerBlock.x); _nodeMatrixTransform << <numBlocksNodeTransform, numThreadsPerBlock >> > ( numVertices, dev_position, dev_normal, matrix, matrixNormal); checkCUDAError("Node hierarchy transformation"); // at the end of the for loop of primitive // push dev pointers to map primitiveVector.push_back(PrimitiveDevBufPointers{ primitive.mode, primitiveType, numPrimitives, numIndices, numVertices, dev_indices, dev_position, dev_normal, dev_texcoord0, dev_diffuseTex, diffuseTexWidth, diffuseTexHeight, dev_vertexOut //VertexOut }); totalNumPrimitives += numPrimitives; } // for each primitive } // for each mesh } // for each node } // 3. Malloc for dev_primitives { cudaMalloc(&dev_primitives, totalNumPrimitives * sizeof(Primitive)); #if BACK_FACE_CULLING cudaMalloc(&dev_primitives_compact, totalNumPrimitives * sizeof(Primitive)); #endif } // Finally, cudaFree raw dev_bufferViews { std::map<std::string, BufferByte*>::const_iterator it(bufferViewDevPointers.begin()); std::map<std::string, BufferByte*>::const_iterator itEnd(bufferViewDevPointers.end()); //bufferViewDevPointers for (; it != itEnd; it++) { cudaFree(it->second); } checkCUDAError("Free BufferView Device Mem"); } } __global__ void _vertexTransformAndAssembly( int numVertices, PrimitiveDevBufPointers primitive, glm::mat4 MVP, glm::mat4 MV, glm::mat3 MV_normal, int width, int height) { // vertex id int vid = (blockIdx.x * blockDim.x) + threadIdx.x; if (vid < numVertices) { // TODO: Apply vertex transformation here // Multiply the MVP matrix for each vertex position, this will transform everything into clipping space // Then divide the pos by its w element to transform into NDC space // Finally transform x and y to viewport space VertexOut &outVert = primitive.dev_verticesOut[vid]; glm::vec4 inPos(primitive.dev_position[vid], 1.f); glm::vec4 outPos; outPos = MVP * inPos; // transform outPos /= outPos.w; // rehomogenize outVert.pos.x = (1.f - outPos.x) * width * 0.5f; outVert.pos.y = (1.f - outPos.y) * height * 0.5f; outVert.pos.z = -outPos.z; outVert.eyePos = glm::vec3(MV * inPos); outVert.eyeNor = glm::normalize(MV_normal * primitive.dev_normal[vid]); #if TEXTURE outVert.texcoord0 = primitive.dev_texcoord0[vid]; outVert.dev_diffuseTex = primitive.dev_diffuseTex; outVert.texWidth = primitive.diffuseTexWidth; outVert.texHeight = primitive.diffuseTexHeight; #endif // TODO: Apply vertex assembly here // Assemble all attribute arraies into the primitive array } } static int curPrimitiveBeginId = 0; __global__ void _primitiveAssembly(int numIndices, int curPrimitiveBeginId, Primitive* dev_primitives, PrimitiveDevBufPointers primitive) { // index id int iid = (blockIdx.x * blockDim.x) + threadIdx.x; if (iid < numIndices) { // TODO: uncomment the following code for a start // This is primitive assembly for triangles int pid; // id for cur primitives vector if (primitive.primitiveMode == TINYGLTF_MODE_TRIANGLES) { pid = iid / (int)primitive.primitiveType; VertexOut &vout = primitive.dev_verticesOut[primitive.dev_indices[iid]]; dev_primitives[pid + curPrimitiveBeginId].v[iid % (int)primitive.primitiveType] = vout; #if BACK_FACE_CULLING if (glm::dot(vout.eyeNor, glm::vec3(0.f, 0.f, 1.f)) < 0.f) { dev_primitives[pid + curPrimitiveBeginId].back = true; } else { dev_primitives[pid + curPrimitiveBeginId].back = false; } #endif } // TODO: other primitive types (point, line) // point, line handled in rasterization.. } } /** * Creates a line from two points (A and B) using Digital Differential Analyzer (DDA) Algorithm * * Reference: http://www.geeksforgeeks.org/dda-line-generation-algorithm-computer-graphics/ */ __device__ void drawLine(glm::vec3 A, glm::vec3 B, Fragment *fragBuf, int width) { float dx = B.x - A.x; float dy = B.y - A.y; float steps = fabs(dx) > fabs(dy) ? dx : dy; dx /= fabs(steps); dy /= fabs(steps); float x = A.x, y = A.y; for (int i = 0; i < steps; i++) { int index = (int)x + (int)y * width; fragBuf[index].color = glm::vec3(0.98); x += dx; y += dy; } } __global__ void _rasterizeTriangles(int numTris, Primitive *dev_primitives, Fragment *fragBuf, int *depthBuf, int *mutex, int width, int height) { // index id int tid = (blockIdx.x * blockDim.x) + threadIdx.x; if (tid < numTris) { Primitive &prim = dev_primitives[tid]; glm::vec3 tri[3] = { glm::vec3(prim.v[0].pos), glm::vec3(prim.v[1].pos), glm::vec3(prim.v[2].pos) }; #if BACK_FACE_CULLING_WITHOUT_COMPACTION if (glm::dot(prim.v[0].eyeNor, glm::vec3(0.f, 0.f, 1.f)) < 0.f) { return; } #endif #if POINTS for (int i = 0; i < 3; i++) { int x = tri[i].x; int y = tri[i].y; int index = x + (y * width); #if DEBUG_DEPTH fragBuf[index].color = glm::abs(glm::vec3(1.f + tri[i].z)); #elif DEBUG_NORMALS fragBuf[index].color = prim.v[i].eyeNor; #else fragBuf[index].color = glm::vec3(0.98); #endif } #elif WIREFRAME drawLine(tri[0], tri[1], fragBuf, width); drawLine(tri[1], tri[2], fragBuf, width); drawLine(tri[2], tri[0], fragBuf, width); #else AABB bbox = getAABBForTriangle(tri); #if BBOX_OPTIMIZATIONS // return when the entire bbox is outside screen.. if (bbox.min.x > width || bbox.max.x<0 || bbox.min.y>height || bbox.max.y < 0) { return; } // clip bounding boxes to the screen size.. // won't cause much divergence as most of the threads // in a warp would fall in the same category most of the time.. if (bbox.min.x < 0) { bbox.min.x = 0.f; } if (bbox.min.y < 0) { bbox.min.y = 0.f; } if (bbox.max.x > width) { bbox.min.x = width; } if (bbox.max.y > height) { bbox.min.x = height; } #endif for (int y = bbox.min.y; y <= bbox.max.y; y++) { for (int x = bbox.min.x; x <= bbox.max.x; x++) { glm::vec2 point(x, y); glm::vec3 baryCoord = calculateBarycentricCoordinate(tri, point); if (!isBarycentricCoordInBounds(baryCoord)) { continue; } int baryZ = getZAtCoordinate(baryCoord, tri) * 10000; int index = x + (y * width); glm::vec3 eyePosition = prim.v[0].eyePos * baryCoord.x + prim.v[1].eyePos * baryCoord.y + prim.v[2].eyePos * baryCoord.z; bool isSet; do { isSet = (atomicCAS(&mutex[index], 0, 1) == 0); if (isSet) { if (depthBuf[index] > baryZ) { depthBuf[index] = baryZ; fragBuf[index].eyePos = eyePosition; fragBuf[index].eyeNor = prim.v[0].eyeNor * baryCoord.x + prim.v[1].eyeNor * baryCoord.y + prim.v[2].eyeNor * baryCoord.z; #if DEBUG_DEPTH fragBuf[index].color = glm::abs(glm::vec3(1.f - baryZ / 10000.f)); #elif DEBUG_NORMALS fragBuf[index].color = fragBuf[index].eyeNor; #elif TEXTURE #if TEXTURE_PERSP_CORRECT float z0 = prim.v[0].eyePos.z, z1 = prim.v[1].eyePos.z, z2 = prim.v[2].eyePos.z; float z = baryCoord.x / z0 + baryCoord.y / z1 + baryCoord.z / z2; fragBuf[index].texcoord0 = (prim.v[0].texcoord0 / z0 * baryCoord.x + prim.v[1].texcoord0 / z1 * baryCoord.y + prim.v[2].texcoord0 / z2 * baryCoord.z) / z; #else fragBuf[index].texcoord0 = prim.v[0].texcoord0 * baryCoord.x + prim.v[1].texcoord0 * baryCoord.y + prim.v[2].texcoord0 * baryCoord.z; #endif fragBuf[index].dev_diffuseTex = prim.v[0].dev_diffuseTex; fragBuf[index].texWidth = prim.v[0].texWidth; fragBuf[index].texHeight = prim.v[0].texHeight; fragBuf[index].color = glm::vec3(0.98); #else // lambert fragBuf[index].color = glm::vec3(0.98); #endif } mutex[index] = 0; } } while (!isSet); } } #endif } } /** * predicate struct for thrust::copy_if */ struct isNotBack { __host__ __device__ bool operator()(const Primitive &prim) { return !prim.back; } }; /** * Perform rasterization. */ void rasterize(uchar4 *pbo, const glm::mat4 & MVP, const glm::mat4 & MV, const glm::mat3 MV_normal) { int sideLength2d = 8; dim3 blockSize2d(sideLength2d, sideLength2d); dim3 blockCount2d((width - 1) / blockSize2d.x + 1, (height - 1) / blockSize2d.y + 1); // Execute your rasterization pipeline here // (See README for rasterization pipeline outline.) // Vertex Process & primitive assembly { curPrimitiveBeginId = 0; dim3 numThreadsPerBlock(128); auto it = mesh2PrimitivesMap.begin(); auto itEnd = mesh2PrimitivesMap.end(); for (; it != itEnd; ++it) { auto p = (it->second).begin(); // each primitive auto pEnd = (it->second).end(); for (; p != pEnd; ++p) { dim3 numBlocksForVertices((p->numVertices + numThreadsPerBlock.x - 1) / numThreadsPerBlock.x); dim3 numBlocksForIndices((p->numIndices + numThreadsPerBlock.x - 1) / numThreadsPerBlock.x); _vertexTransformAndAssembly <<<numBlocksForVertices, numThreadsPerBlock>>> (p->numVertices, *p, MVP, MV, MV_normal, width, height); checkCUDAError("Vertex Processing"); cudaDeviceSynchronize(); _primitiveAssembly <<<numBlocksForIndices, numThreadsPerBlock>>> (p->numIndices, curPrimitiveBeginId, dev_primitives, *p); checkCUDAError("Primitive Assembly"); curPrimitiveBeginId += p->numPrimitives; } } checkCUDAError("Vertex Processing and Primitive Assembly"); } cudaMemset(dev_fragmentBuffer, 0, width * height * sizeof(Fragment)); cudaMemset(dev_mutex, 0, width * height * sizeof(int)); initDepth << <blockCount2d, blockSize2d >> > (width, height, dev_depth); #if BACK_FACE_CULLING cudaMemset(dev_primitives_compact, 0, totalNumPrimitives * sizeof(Primitive)); Primitive* end = thrust::copy_if(thrust::device, dev_primitives, dev_primitives + totalNumPrimitives, dev_primitives_compact, isNotBack()); checkCUDAError("Back face culling: thrust::partition"); totalNumPrimitivesCompact = end - dev_primitives_compact; //// TODO: rasterize dim3 numThreadsPerBlock(128); dim3 numBlocksPerTriangle((totalNumPrimitivesCompact + numThreadsPerBlock.x - 1) / numThreadsPerBlock.x); _rasterizeTriangles << <numBlocksPerTriangle, numThreadsPerBlock >> > (totalNumPrimitivesCompact, dev_primitives_compact, dev_fragmentBuffer, dev_depth, dev_mutex, width, height); checkCUDAError("rasterize triangles"); #else //// TODO: rasterize dim3 numThreadsPerBlock(128); dim3 numBlocksPerTriangle((totalNumPrimitives + numThreadsPerBlock.x - 1) / numThreadsPerBlock.x); _rasterizeTriangles <<<numBlocksPerTriangle, numThreadsPerBlock>>> (totalNumPrimitives, dev_primitives, dev_fragmentBuffer, dev_depth, dev_mutex, width, height); checkCUDAError("rasterize triangles"); #endif #if SSAO // SSAO shaderSSAO << <blockCount2d, blockSize2d >> > (width, height, dev_fragmentBuffer); checkCUDAError("SSAO"); #endif // Copy fragmentbuffer colors into framebuffer [frame buffer is sent for post processing] render <<<blockCount2d, blockSize2d>>> (width, height, dev_fragmentBuffer, dev_framebuffer); checkCUDAError("fragment shader"); #if BLUR #if BLUR_SHARED // Doing seperate blur in X and then in Y to make things faster.. // Using 2 postbuffers to avoid over-writing and collision between threads while doing blurring in Y dir.. // blur in x dir dim3 threadsX(width), blocksX(height), threadsY(height), blocksY(width); bool dirX = true; postProcessShared <<<blocksX, threadsX, width * sizeof(glm::vec3)>>> (dirX, width, height, dev_framebuffer, dev_depth, dev_postBuffer1); checkCUDAError("post shader X"); // blur in y dir dirX = false; postProcessShared <<<blocksY, threadsY, height * sizeof(glm::vec3)>>> (dirX, width, height, dev_postBuffer1, dev_depth, dev_postBuffer2); checkCUDAError("post shader Y"); // 2nd pass for more blurring.. dirX = true; postProcessShared <<<blocksX, threadsX, width * sizeof(glm::vec3)>>> (dirX, width, height, dev_postBuffer2, dev_depth, dev_postBuffer1); checkCUDAError("post shader X"); // blur in y dir dirX = false; postProcessShared <<<blocksY, threadsY, height * sizeof(glm::vec3)>>> (dirX, width, height, dev_postBuffer1, dev_depth, dev_postBuffer2); checkCUDAError("post shader Y"); #else // This version doesn't use shared memory. It is implemented only for the sake of comparison // blur in x dir dim3 threadsX(width), threadsY(height), blocksX(height), blocksY(width); bool dirX = true; postProcess <<<blocksX, threadsX>>> (dirX, width, height, dev_framebuffer, dev_depth, dev_postBuffer1); checkCUDAError("post shader X"); // blur in y dir dirX = false; postProcess <<<blocksY, threadsY>>> (dirX, width, height, dev_postBuffer1, dev_depth, dev_postBuffer2); checkCUDAError("post shader Y"); #endif // blend for DOF postBlend <<<blockCount2d, blockSize2d>>> (width, height, dev_framebuffer, dev_depth, dev_postBuffer2); checkCUDAError("copy post render result to pbo"); // Copy framebuffer into OpenGL buffer for OpenGL previewing sendImageToPBO <<<blockCount2d, blockSize2d>>> (pbo, width, height, dev_postBuffer2); checkCUDAError("copy post render result to pbo"); #else blockSize2d = dim3(sideLength2d, sideLength2d); blockCount2d = dim3((width/SSAA - 1) / blockSize2d.x + 1, (height/SSAA - 1) / blockSize2d.y + 1); // Copy framebuffer into OpenGL buffer for OpenGL previewing sendImageToPBO <<<blockCount2d, blockSize2d>>> (pbo, width, height, dev_framebuffer); checkCUDAError("copy render result to pbo"); #endif } /** * Called once at the end of the program to free CUDA memory. */ void rasterizeFree() { // deconstruct primitives attribute/indices device buffer auto it(mesh2PrimitivesMap.begin()); auto itEnd(mesh2PrimitivesMap.end()); for (; it != itEnd; ++it) { for (auto p = it->second.begin(); p != it->second.end(); ++p) { cudaFree(p->dev_indices); cudaFree(p->dev_position); cudaFree(p->dev_normal); cudaFree(p->dev_texcoord0); cudaFree(p->dev_diffuseTex); cudaFree(p->dev_verticesOut); //TODO: release other attributes and materials } } //////////// cudaFree(dev_primitives); dev_primitives = NULL; cudaFree(dev_fragmentBuffer); dev_fragmentBuffer = NULL; cudaFree(dev_framebuffer); dev_framebuffer = NULL; cudaFree(dev_postBuffer1); dev_postBuffer1 = NULL; cudaFree(dev_postBuffer2); dev_postBuffer2 = NULL; cudaFree(dev_depth); dev_depth = NULL; cudaFree(dev_mutex); dev_mutex = NULL; cudaFree(dev_primitives_compact); dev_primitives = NULL; checkCUDAError("rasterize Free"); }
baa160fd7f9ed9e03f532ddf8270632cd8274e46.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" /* * * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. * * * * See COPYRIGHT for license information * */ #include "nvshmem.h" #include "nvshmem_internal.h" template <nvshmemi_op_t desc, int is_nbi> __global__ void nvshmemi_proxy_rma_entrypoint(void *rptr, void *lptr, rma_bytesdesc_t bytesdesc, int pe); template <> __global__ void nvshmemi_proxy_rma_entrypoint<NVSHMEMI_OP_PUT, 1>(void *rptr, void *lptr, rma_bytesdesc_t bytesdesc, int pe) { nvshmemi_proxy_rma_nbi<NVSHMEMI_OP_PUT>((void *)rptr, (void *)lptr, bytesdesc.nelems * bytesdesc.elembytes, pe); } template <> __global__ void nvshmemi_proxy_rma_entrypoint<NVSHMEMI_OP_GET, 1>(void *rptr, void *lptr, rma_bytesdesc_t bytesdesc, int pe) { nvshmemi_proxy_rma_nbi<NVSHMEMI_OP_GET>((void *)rptr, (void *)lptr, bytesdesc.nelems * bytesdesc.elembytes, pe); } template <> __global__ void nvshmemi_proxy_rma_entrypoint<NVSHMEMI_OP_PUT, 0>(void *rptr, void *lptr, rma_bytesdesc_t bytesdesc, int pe) { nvshmemi_proxy_rma_nbi<NVSHMEMI_OP_PUT>((void *)rptr, (void *)lptr, bytesdesc.nelems * bytesdesc.elembytes, pe); nvshmemi_proxy_quiet(); } template <> __global__ void nvshmemi_proxy_rma_entrypoint<NVSHMEMI_OP_GET, 0>(void *rptr, void *lptr, rma_bytesdesc_t bytesdesc, int pe) { nvshmemi_proxy_rma_nbi<NVSHMEMI_OP_GET>((void *)rptr, (void *)lptr, bytesdesc.nelems * bytesdesc.elembytes, pe); nvshmemi_proxy_quiet(); } template <nvshmemi_op_t desc, int is_nbi> int nvshmemi_proxy_rma_launcher(void *args[], hipStream_t cstrm); typedef void (*rma)(void *, void *, rma_bytesdesc_t, int); template <> int nvshmemi_proxy_rma_launcher<NVSHMEMI_OP_PUT, 1>(void *args[], hipStream_t cstrm) { rma put_nbi = nvshmemi_proxy_rma_entrypoint<NVSHMEMI_OP_PUT, 1>; return cudaLaunchKernel((const void *)put_nbi, 1, 1, args, 0, cstrm); } template <> int nvshmemi_proxy_rma_launcher<NVSHMEMI_OP_GET, 1>(void *args[], hipStream_t cstrm) { rma get_nbi = nvshmemi_proxy_rma_entrypoint<NVSHMEMI_OP_GET, 1>; return cudaLaunchKernel((const void *)get_nbi, 1, 1, args, 0, cstrm); } template <> int nvshmemi_proxy_rma_launcher<NVSHMEMI_OP_PUT, 0>(void *args[], hipStream_t cstrm) { rma put = nvshmemi_proxy_rma_entrypoint<NVSHMEMI_OP_PUT, 0>; return cudaLaunchKernel((const void *)put, 1, 1, args, 0, cstrm); } template <> int nvshmemi_proxy_rma_launcher<NVSHMEMI_OP_GET, 0>(void *args[], hipStream_t cstrm) { rma get = nvshmemi_proxy_rma_entrypoint<NVSHMEMI_OP_GET, 0>; return cudaLaunchKernel((const void *)get, 1, 1, args, 0, cstrm); }
baa160fd7f9ed9e03f532ddf8270632cd8274e46.cu
/* * * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. * * * * See COPYRIGHT for license information * */ #include "nvshmem.h" #include "nvshmem_internal.h" template <nvshmemi_op_t desc, int is_nbi> __global__ void nvshmemi_proxy_rma_entrypoint(void *rptr, void *lptr, rma_bytesdesc_t bytesdesc, int pe); template <> __global__ void nvshmemi_proxy_rma_entrypoint<NVSHMEMI_OP_PUT, 1>(void *rptr, void *lptr, rma_bytesdesc_t bytesdesc, int pe) { nvshmemi_proxy_rma_nbi<NVSHMEMI_OP_PUT>((void *)rptr, (void *)lptr, bytesdesc.nelems * bytesdesc.elembytes, pe); } template <> __global__ void nvshmemi_proxy_rma_entrypoint<NVSHMEMI_OP_GET, 1>(void *rptr, void *lptr, rma_bytesdesc_t bytesdesc, int pe) { nvshmemi_proxy_rma_nbi<NVSHMEMI_OP_GET>((void *)rptr, (void *)lptr, bytesdesc.nelems * bytesdesc.elembytes, pe); } template <> __global__ void nvshmemi_proxy_rma_entrypoint<NVSHMEMI_OP_PUT, 0>(void *rptr, void *lptr, rma_bytesdesc_t bytesdesc, int pe) { nvshmemi_proxy_rma_nbi<NVSHMEMI_OP_PUT>((void *)rptr, (void *)lptr, bytesdesc.nelems * bytesdesc.elembytes, pe); nvshmemi_proxy_quiet(); } template <> __global__ void nvshmemi_proxy_rma_entrypoint<NVSHMEMI_OP_GET, 0>(void *rptr, void *lptr, rma_bytesdesc_t bytesdesc, int pe) { nvshmemi_proxy_rma_nbi<NVSHMEMI_OP_GET>((void *)rptr, (void *)lptr, bytesdesc.nelems * bytesdesc.elembytes, pe); nvshmemi_proxy_quiet(); } template <nvshmemi_op_t desc, int is_nbi> int nvshmemi_proxy_rma_launcher(void *args[], cudaStream_t cstrm); typedef void (*rma)(void *, void *, rma_bytesdesc_t, int); template <> int nvshmemi_proxy_rma_launcher<NVSHMEMI_OP_PUT, 1>(void *args[], cudaStream_t cstrm) { rma put_nbi = nvshmemi_proxy_rma_entrypoint<NVSHMEMI_OP_PUT, 1>; return cudaLaunchKernel((const void *)put_nbi, 1, 1, args, 0, cstrm); } template <> int nvshmemi_proxy_rma_launcher<NVSHMEMI_OP_GET, 1>(void *args[], cudaStream_t cstrm) { rma get_nbi = nvshmemi_proxy_rma_entrypoint<NVSHMEMI_OP_GET, 1>; return cudaLaunchKernel((const void *)get_nbi, 1, 1, args, 0, cstrm); } template <> int nvshmemi_proxy_rma_launcher<NVSHMEMI_OP_PUT, 0>(void *args[], cudaStream_t cstrm) { rma put = nvshmemi_proxy_rma_entrypoint<NVSHMEMI_OP_PUT, 0>; return cudaLaunchKernel((const void *)put, 1, 1, args, 0, cstrm); } template <> int nvshmemi_proxy_rma_launcher<NVSHMEMI_OP_GET, 0>(void *args[], cudaStream_t cstrm) { rma get = nvshmemi_proxy_rma_entrypoint<NVSHMEMI_OP_GET, 0>; return cudaLaunchKernel((const void *)get, 1, 1, args, 0, cstrm); }
74eb677de466898debcd640aff8265509afa9fe6.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include "cudaconv2.cuh" #include "filter_acts/filter_act_templates.cuh" #include "nvmatrix.cuh" #include "src/cuda/utils.cuh" namespace megdnn { namespace cuda { __device__ __forceinline__ void filterActs_YxX_color_preload_ty_4_tx_32_f_16_cc_3_setImgCoords( int fPidx, int imgLoadModPosY, int imgLoadModPosX, int imgSizeX, int filterSize, int& iPidx) { int x = imgLoadModPosX + (fPidx) % filterSize; int y = imgLoadModPosY + (fPidx) / filterSize; iPidx = y >= 0 && y < imgSizeX && x >= 0 && x < imgSizeX ? y * imgSizeX + x : -1; } #define FA_COLOR3_IMPRELOAD(c, i) \ imPreload[c][i] = \ iPidxNext < 0 || (checkImgBounds && myImgIdx + i * B_X >= numImages) \ ? 0 \ : mm[c * imgPixels * imgStride + i * B_X]; #define FA_COLOR3_IMPRELOAD_TX(c, i) \ imPreload[c][i] = \ iPidxNext < 0 || (checkImgBounds && myImgIdx + i * B_X >= numImages) \ ? 0 \ : tex1Dfetch<float>( \ images, \ imagesOffset2 + c * imgPixels * imgStride + i * B_X); /* * images: (numImgColors, imgSizeY, imgSizeX, numImages) with stride given * filters: (numFilterColors, filterPixels, numFilters) if conv * (numModules, numFilterColors, filterPixels, numFilters) otherwise * * targets: (numFilters, numModulesY, numModulesX, numImages) * */ template < int B_Y, int B_X, int imgsPerThread, int filtersPerThread, int numColors, int pixelCache, bool scale, bool checkImgBounds> //__launch_bounds__(128,3) __global__ void filterActs_YxX_color_preload_ty_4_tx_32_i_4_f_16_px_4_cc_3_tex( hipTextureObject_t images, hipTextureObject_t filters, float* targets, const int numImages, const int numFilters, const int imgSizeY, const int imgSizeX, const int filterSize, const int paddingStart, const int moduleStride, const int numModulesY, const int numModulesX, const int imgStride, const float scaleTargets, const float scaleOutputs, const bool conv /*, const bool noloads*/) { __shared__ float shFilters [numColors][pixelCache] [B_Y * filtersPerThread]; // pre-load 1 pixel from B_Y*filtersPerThread filters __shared__ float shImages[numColors][pixelCache] [B_X * imgsPerThread]; // pre-load 1 pixel from B_X*imgsPerThread images fill_shared_mem<float>((float*)shFilters, sizeof(shFilters) / sizeof(float), 0); fill_shared_mem<float>((float*)shImages, sizeof(shImages) / sizeof(float), 0); __syncthreads(); const int imgPixels = imgSizeY * imgSizeX; const int filterPixels = filterSize * filterSize; const int blocksPerModule = numFilters / (B_Y * filtersPerThread); const int moduleIdx = blockIdx.y / blocksPerModule; const int blockFilterIdx = filtersPerThread * B_Y * (blockIdx.y % blocksPerModule); const int numModules = numModulesX * numModulesY; // Another fun insanity: the % B_X makes things faster, even thought threadIdx.x is // in the range 0..31. It appears that this allows the compiler to optimize? const int tx = threadIdx.x % B_X; const int ty = threadIdx.y % B_Y; const int tidx = ty * B_X + threadIdx.x; const int imgLoadModPosY = paddingStart + (moduleIdx / numModulesX) * moduleStride; const int imgLoadModPosX = paddingStart + (moduleIdx % numModulesX) * moduleStride; const int shFilterLoadY = tidx / (B_Y * filtersPerThread); const int shFilterLoadX = tidx % (B_Y * filtersPerThread); const int myImgIdx = blockIdx.x * B_X * imgsPerThread + threadIdx.x; // images += myImgIdx; // filters += blockFilterIdx // + shFilterLoadY * numFilters + shFilterLoadX; // if (!conv) { // NOTE: UNTESTED! // filters += moduleIdx * numColors * filterPixels * numFilters; // } const int imagesOffset = myImgIdx; const int filtersOffset = blockFilterIdx + shFilterLoadY * numFilters + shFilterLoadX + (conv ? 0 : moduleIdx * numColors * filterPixels * numFilters); targets += moduleIdx * numImages + (blockFilterIdx + threadIdx.y * filtersPerThread) * numImages * numModules + myImgIdx; float prod[imgsPerThread][filtersPerThread]; #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { prod[i][f] = 0; } } int iPidxNext; float imPreload[numColors][imgsPerThread]; float fPreload[numColors][pixelCache * filtersPerThread / B_X]; #pragma unroll for (int c = 0; c < numColors; ++c) { #pragma unroll for (int p = 0; p < pixelCache; p += B_X / filtersPerThread) { if (p + shFilterLoadY < filterPixels) { fPreload[c][p * filtersPerThread / B_X] = tex1Dfetch<float>( filters, filtersOffset + p * numFilters + c * numFilters * filterPixels); } else { fPreload[c][p * filtersPerThread / B_X] = 0; } } } filterActs_YxX_color_preload_ty_4_tx_32_f_16_cc_3_setImgCoords( ty, imgLoadModPosY, imgLoadModPosX, imgSizeX, filterSize, iPidxNext); #pragma unroll for (int c = 0; c < numColors; ++c) { #pragma unroll for (int i = 0; i < imgsPerThread; i++) { if (iPidxNext >= 0 && (!checkImgBounds || myImgIdx + i * B_X < numImages)) { imPreload[c][i] = tex1Dfetch<float>( images, imagesOffset + (c * imgPixels + iPidxNext) * imgStride + i * B_X); } else { imPreload[c][i] = 0; } } } for (int p = 0; p < filterPixels; p += pixelCache) { #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int c = 0; c < numColors; ++c) { // NOTE: bank conflicts here! shImages[c][ty][tx * imgsPerThread + i] = imPreload[c][i]; } } const int fPidxNext = p + pixelCache >= filterPixels ? 0 : p + pixelCache; filterActs_YxX_color_preload_ty_4_tx_32_f_16_cc_3_setImgCoords( fPidxNext + ty, imgLoadModPosY, imgLoadModPosX, imgSizeX, filterSize, iPidxNext); // const float* ff = &filters[numFilters * fPidxNext]; // const float* mm = &images[imgStride * iPidxNext]; const int filtersOffset2 = filtersOffset + numFilters * fPidxNext; const int imagesOffset2 = imagesOffset + imgStride * iPidxNext; FA_COLOR3_IMPRELOAD_TX(0, 0); FA_COLOR3_IMPRELOAD_TX(0, 1); FA_COLOR3_IMPRELOAD_TX(0, 2); FA_COLOR3_IMPRELOAD_TX(0, 3); #pragma unroll for (int c = 0; c < numColors; ++c) { #pragma unroll for (int pp = 0; pp < pixelCache; pp += B_X / filtersPerThread) { shFilters[c][pp + shFilterLoadY][shFilterLoadX] = fPreload[c][pp * filtersPerThread / B_X]; } } __syncthreads(); FA_COLOR3_IMPRELOAD_TX(1, 0); FA_COLOR3_IMPRELOAD_TX(1, 1); FA_COLOR3_IMPRELOAD_TX(1, 2); FA_COLOR3_IMPRELOAD_TX(1, 3); FA_COLOR3_IMPRELOAD_TX(2, 0); FA_COLOR3_IMPRELOAD_TX(2, 1); FA_COLOR3_IMPRELOAD_TX(2, 2); FA_COLOR3_IMPRELOAD_TX(2, 3); #pragma unroll for (int c = 0; c < numColors; c++) { #pragma unroll for (int pp = 0; pp < pixelCache * filtersPerThread / B_X; pp++) { fPreload[c][pp] = fPidxNext + pp * (B_X / filtersPerThread) + shFilterLoadY >= filterPixels ? 0 : tex1Dfetch<float>( filters, filtersOffset2 + c * numFilters * filterPixels + pp * (B_X / filtersPerThread) * numFilters); } } #pragma unroll for (int pp = 0; pp < pixelCache; pp++) { #pragma unroll for (int c = 0; c < numColors; c++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { #pragma unroll for (int i = 0; i < imgsPerThread; i++) { prod[i][f] += shImages[c][pp][tx * imgsPerThread + i] * shFilters[c][pp][ty * filtersPerThread + f]; } } } } __syncthreads(); } if (scale) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { #pragma unroll for (int i = 0; i < imgsPerThread; i++) { if (!checkImgBounds || myImgIdx + i * B_X < numImages) { targets[i * B_X + f * numImages * numModules] = scaleTargets * targets[i * B_X + f * numImages * numModules] + scaleOutputs * prod[i][f]; } } } } else { // Note: reversing order of these loops saves 2 registers, but costs time #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { if (!checkImgBounds || myImgIdx + i * B_X < numImages) { targets[i * B_X + f * numImages * numModules] = scaleOutputs * prod[i][f]; } } } } } /* * images: (numImgColors, imgSizeY, imgSizeX, numImages) with stride given * filters: (numFilterColors, filterPixels, numFilters) if conv * (numModules, numFilterColors, filterPixels, numFilters) otherwise * * targets: (numFilters, numModulesY, numModulesX, numImages) * * This won't be pretty. */ template < int B_Y, int B_X, int imgsPerThread, int filtersPerThread, int numColors, int pixelCache, bool scale, bool checkImgBounds> __global__ void filterActs_YxX_color_preload_ty_4_tx_32_i_4_f_12_px_4_cc_3_tex( hipTextureObject_t images, hipTextureObject_t filters, float* targets, const int numImages, const int numFilters, const int imgSizeY, const int imgSizeX, const int filterSize, const int paddingStart, const int moduleStride, const int numModulesY, const int numModulesX, const int imgStride, const float scaleTargets, const float scaleOutputs, const bool conv /*, const bool noloads*/) { __shared__ float shFilters [numColors][pixelCache] [B_Y * filtersPerThread]; // pre-load 1 pixel from B_Y*filtersPerThread filters __shared__ float shImages[numColors][pixelCache] [B_X * imgsPerThread]; // pre-load 1 pixel from B_X*imgsPerThread images fill_shared_mem<float>((float*)shFilters, sizeof(shFilters) / sizeof(float), 0); fill_shared_mem<float>((float*)shImages, sizeof(shImages) / sizeof(float), 0); __syncthreads(); const int imgPixels = imgSizeY * imgSizeX; const int filterPixels = filterSize * filterSize; const int blocksPerModule = numFilters / (B_Y * filtersPerThread); const int moduleIdx = blockIdx.y / blocksPerModule; const int blockFilterIdx = filtersPerThread * B_Y * (blockIdx.y % blocksPerModule); const int numModules = numModulesX * numModulesY; // Another fun insanity: the % B_X makes things faster, even though threadIdx.x is // in the range 0..31. It appears that this allows the compiler to optimize? const int tx = threadIdx.x % B_X; const int ty = threadIdx.y % B_Y; const int tidx = ty * B_X + threadIdx.x; const int warp = tidx / 32; const int imgLoadModPosY = paddingStart + (moduleIdx / numModulesX) * moduleStride; const int imgLoadModPosX = paddingStart + (moduleIdx % numModulesX) * moduleStride; const int shFilterLoadY = tidx / (B_Y * filtersPerThread); const int shFilterLoadX = tidx % (B_Y * filtersPerThread); const int myImgIdx = blockIdx.x * B_X * imgsPerThread + threadIdx.x; // images += myImgIdx; // filters += blockFilterIdx // + shFilterLoadY * numFilters + shFilterLoadX; // if (!conv) { // NOTE: UNTESTED! // filters += moduleIdx * numColors * filterPixels * numFilters; // } const int imagesOffset = myImgIdx; const int filtersOffset = blockFilterIdx + shFilterLoadY * numFilters + shFilterLoadX + (conv ? 0 : moduleIdx * numColors * filterPixels * numFilters); targets += moduleIdx * numImages + (blockFilterIdx + threadIdx.y * filtersPerThread) * numImages * numModules + myImgIdx; float prod[imgsPerThread][filtersPerThread]; #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { prod[i][f] = 0; } } int iPidxNext; float imPreload[numColors][imgsPerThread]; float fPreload[numColors][DIVUP(pixelCache * filtersPerThread, B_X)]; if (warp < 3) { #pragma unroll for (int c = 0; c < numColors; ++c) { #pragma unroll for (int p = 0; p < pixelCache; p += 2) { if (p + shFilterLoadY < filterPixels) { fPreload[c][p / 2] = tex1Dfetch<float>( filters, filtersOffset + p * numFilters + c * numFilters * filterPixels); } else { fPreload[c][p / 2] = 0; } } } } filterActs_YxX_color_preload_ty_4_tx_32_f_16_cc_3_setImgCoords( ty, imgLoadModPosY, imgLoadModPosX, imgSizeX, filterSize, iPidxNext); #pragma unroll for (int c = 0; c < numColors; ++c) { #pragma unroll for (int i = 0; i < imgsPerThread; i++) { if (iPidxNext >= 0 && (!checkImgBounds || myImgIdx + i * B_X < numImages)) { imPreload[c][i] = tex1Dfetch<float>( images, imagesOffset + (c * imgPixels + iPidxNext) * imgStride + i * B_X); } else { imPreload[c][i] = 0; } } } for (int p = 0; p < filterPixels; p += pixelCache) { const int fPidxNext = p + pixelCache >= filterPixels ? 0 : p + pixelCache; filterActs_YxX_color_preload_ty_4_tx_32_f_16_cc_3_setImgCoords( fPidxNext + ty, imgLoadModPosY, imgLoadModPosX, imgSizeX, filterSize, iPidxNext); #pragma unroll for (int c = 0; c < numColors; ++c) { #pragma unroll for (int i = 0; i < imgsPerThread; i++) { // NOTE: bank conflicts here! shImages[c][ty][tx * imgsPerThread + i] = imPreload[c][i]; } } if (warp < 3) { #pragma unroll for (int c = 0; c < numColors; ++c) { #pragma unroll for (int pp = 0; pp < pixelCache; pp += 2) { shFilters[c][pp + shFilterLoadY][shFilterLoadX] = fPreload[c][pp / 2]; } } } __syncthreads(); // const float* ff = &filters[numFilters * fPidxNext]; // const float* mm = &images[imgStride * iPidxNext]; const int filtersOffset2 = filtersOffset + numFilters * fPidxNext; const int imagesOffset2 = imagesOffset + imgStride * iPidxNext; #pragma unroll for (int i = 0; i < imgsPerThread; ++i) { #pragma unroll for (int c = 0; c < numColors; c++) { FA_COLOR3_IMPRELOAD_TX(c, i); } } #pragma unroll for (int c = 0; c < numColors; c++) { #pragma unroll for (int pp = 0; pp < 2; pp++) { fPreload[c][pp] = warp >= 3 || fPidxNext + pp * 2 + shFilterLoadY >= filterPixels ? 0 : tex1Dfetch<float>( filters, filtersOffset2 + c * numFilters * filterPixels + pp * 2 * numFilters); } #pragma unroll for (int pp = 0; pp < pixelCache; pp++) { #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { prod[i][f] += shImages[c][pp][tx * imgsPerThread + i] * shFilters[c][pp][ty * filtersPerThread + f]; } } } } __syncthreads(); } if (scale) { #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { if (!checkImgBounds || myImgIdx + i * B_X < numImages) { targets[i * B_X + f * numImages * numModules] = scaleTargets * targets[i * B_X + f * numImages * numModules] + scaleOutputs * prod[i][f]; } } } } else { // Note: reversing order of these loops costs 2 registers, but saves time #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { if (!checkImgBounds || myImgIdx + i * B_X < numImages) { targets[i * B_X + f * numImages * numModules] = scaleOutputs * prod[i][f]; } } } } } /* * images: (numImgColors, imgSizeY, imgSizeX, numImages) with stride given * filters: (numFilterColors, filterPixels, numFilters) if conv * (numModules, numFilterColors, filterPixels, numFilters) otherwise * * targets: (numFilters, numModulesY, numModulesX, numImages) * * Note: in git there's a 1.5% faster version of this which sues 167 registers instead * of 154... it's basically the same thing, but it doesn't do the next-pixel * computation. It just avoids pre-loading when it rolls over to the next pixel. */ template < int B_Y, int B_X, int imgsPerThread, int filtersPerThread, int colorCache, bool scale, bool checkImgBounds> __global__ void filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4( float* images, float* filters, float* targets, const int numImages, const int numFilters, const int imgSizeY, const int imgSizeX, const int filterSize, const int paddingStart, const int moduleStride, const int numModulesY, const int numModulesX, const int imgStride, const int numImgColors, const int numGroups, const float scaleTargets, const float scaleOutputs, const bool conv /*, const bool noloads*/) { __shared__ float shFilters [colorCache] [B_Y * filtersPerThread]; // pre-load 1 pixel from B_Y*filtersPerThread filters __shared__ float shImages[colorCache] [B_X * imgsPerThread]; // pre-load 1 pixel from B_X*imgsPerThread images fill_shared_mem<float>((float*)shFilters, sizeof(shFilters) / sizeof(float), 0); fill_shared_mem<float>((float*)shImages, sizeof(shImages) / sizeof(float), 0); __syncthreads(); const int imgPixels = imgSizeY * imgSizeX; const int filterPixels = filterSize * filterSize; const int numFilterColors = numImgColors / numGroups; const int blocksPerModule = numFilters / (B_Y * filtersPerThread); const int moduleIdx = blockIdx.y / blocksPerModule; const int blockFilterIdx = filtersPerThread * B_Y * (blockIdx.y % blocksPerModule); const int numFiltersPerGroup = numFilters / numGroups; const int blockGroupIdx = blockFilterIdx / numFiltersPerGroup; const int numModules = numModulesX * numModulesY; const int blockColorIdx = numFilterColors * blockGroupIdx; // Another fun insanity: the % B_X makes things faster, even thought threadIdx.x is // in the range 0..31. It appears that this allows the compiler to optimize? const int tx = threadIdx.x % B_X; const int ty = threadIdx.y % B_Y; const int tidx = ty * B_X + threadIdx.x; const int imgLoadModPosY = paddingStart + (moduleIdx / numModulesX) * moduleStride; const int imgLoadModPosX = paddingStart + (moduleIdx % numModulesX) * moduleStride; const int shFilterLoadY = tidx / (B_Y * filtersPerThread); const int shFilterLoadX = tidx % (B_Y * filtersPerThread); const int myImgIdx = blockIdx.x * B_X * imgsPerThread + threadIdx.x; images += (blockColorIdx + threadIdx.y) * imgPixels * imgStride + myImgIdx; filters += blockFilterIdx + shFilterLoadY * numFilters * filterPixels + shFilterLoadX; if (!conv) { filters += moduleIdx * numFilterColors * filterPixels * numFilters; } targets += moduleIdx * numImages + (blockFilterIdx + threadIdx.y * filtersPerThread) * numImages * numModules + myImgIdx; float prod[imgsPerThread][filtersPerThread]; // float fCache[filtersPerThread]; #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { prod[i][f] = 0; } } // NOTE: these max/min functions increase register usage as compared to my macros const int imgStartX = max(0, imgLoadModPosX); const int imgStartY = max(0, imgLoadModPosY); const int imgEndX = min(imgLoadModPosX + filterSize, imgSizeX); const int imgEndY = min(imgLoadModPosY + filterSize, imgSizeY); // __shared__ int imgPos[] int fPidx, iPidx; float imPreload[imgsPerThread]; float fPreload[colorCache * filtersPerThread / B_X]; // float fCache[filtersPerThread]; filterActs_YxX_sparse2_preload_ty_4_tx_32_f_16_c_4_setPixelCoords( filterSize, imgSizeX, imgLoadModPosY, imgLoadModPosX, imgStartY, imgStartX, fPidx, iPidx); #pragma unroll for (int i = 0; i < imgsPerThread; i++) { if (!checkImgBounds || myImgIdx + i * B_X < numImages) { imPreload[i] = images[imgStride * iPidx + i * B_X]; } else { imPreload[i] = 0; } } if (/*B_X % filtersPerThread == 0 ||*/ shFilterLoadY < B_X / filtersPerThread) { // This if statement reduces reg usage.. #pragma unroll for (int c = 0; c < colorCache; c += B_X / filtersPerThread) { fPreload[c * filtersPerThread / B_X] = filters[(c * filterPixels + fPidx) * numFilters]; } } for (int imgY = imgStartY; imgY < imgEndY; ++imgY) { // const int filterPxY = imgY - imgLoadModPosY; for (int imgX = imgStartX; imgX < imgEndX; ++imgX) { // const int filterPxX = imgX - imgLoadModPosX; // const int p = filterPxY * filterSize + filterPxX; // const int pixIdx = imgY * imgSizeX + imgX;// Pixel index in // img setPixelCoords(filterSize, imgSizeX, imgLoadModPosY, // imgLoadModPosX, imgY, imgX, &p, &pixIdx); float* m = // &images[imgStride * pixIdx]; const bool lastPixel = imgY == imgEndY - 1 && imgX == imgEndX - 1; int imgYNext = imgY; int imgXNext = imgX; int fPidxNext, iPidxNext; if (!lastPixel) { imgYNext = imgY + (imgX + 1 == imgEndX); imgXNext = imgX + 1 == imgEndX ? imgStartX : imgX + 1; } filterActs_YxX_sparse2_preload_ty_4_tx_32_f_16_c_4_setPixelCoords( filterSize, imgSizeX, imgLoadModPosY, imgLoadModPosX, imgYNext, imgXNext, fPidxNext, iPidxNext); for (int oc = 0; oc < numFilterColors; oc += colorCache) { // oc stands for outer color (loop) const float* ff = &filters [numFilters * ((oc + colorCache) * filterPixels + fPidx)]; const float* mm = &images[imgStride * ((oc + colorCache) * imgPixels + iPidx)]; if (oc == numFilterColors - colorCache) { ff = &filters[fPidxNext * numFilters]; mm = &images[iPidxNext * imgStride]; fPidx = fPidxNext; iPidx = iPidxNext; } #pragma unroll for (int c = 0; c < colorCache; c += B_X / filtersPerThread) { shFilters[c + shFilterLoadY][shFilterLoadX] = fPreload[c * filtersPerThread / B_X]; } #pragma unroll for (int i = 0; i < imgsPerThread; i++) { // NOTE: bank conflicts here! shImages[ty][tx * imgsPerThread + i] = imPreload[i]; } imPreload[0] = (checkImgBounds && myImgIdx + 0 * B_X >= numImages) ? 0 : mm[0 * B_X]; imPreload[1] = (checkImgBounds && myImgIdx + 1 * B_X >= numImages) ? 0 : mm[1 * B_X]; imPreload[2] = (checkImgBounds && myImgIdx + 2 * B_X >= numImages) ? 0 : mm[2 * B_X]; __syncthreads(); #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { prod[i][f] += shImages[0][threadIdx.x * imgsPerThread + i] * shFilters[0][threadIdx.y * filtersPerThread + f]; } } fPreload[0] = ff[0]; #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { prod[i][f] += shImages[1][threadIdx.x * imgsPerThread + i] * shFilters[1][threadIdx.y * filtersPerThread + f]; } } fPreload[1] = ff[(B_X / filtersPerThread * filterPixels) * numFilters]; #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { prod[i][f] += shImages[2][threadIdx.x * imgsPerThread + i] * shFilters[2][threadIdx.y * filtersPerThread + f]; } } imPreload[3] = (checkImgBounds && myImgIdx + 3 * B_X >= numImages) ? 0 : mm[3 * B_X]; #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { prod[i][f] += shImages[3][threadIdx.x * imgsPerThread + i] * shFilters[3][threadIdx.y * filtersPerThread + f]; } } __syncthreads(); } } } if (scale) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { #pragma unroll for (int i = 0; i < imgsPerThread; i++) { if (!checkImgBounds || myImgIdx + i * B_X < numImages) { targets[i * B_X + f * numImages * numModules] = scaleTargets * targets[i * B_X + f * numImages * numModules] + scaleOutputs * prod[i][f]; } } } } else { // Note: reversing order of these loops saves 2 registers, but costs time #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { if (!checkImgBounds || myImgIdx + i * B_X < numImages) { targets[i * B_X + f * numImages * numModules] = scaleOutputs * prod[i][f]; } } } } } /* * images: (numImgColors, imgSizeY, imgSizeX, numImages) with stride given * filters: (numFilterColors, filterPixels, numFilters) if conv * (numModules, numFilterColors, filterPixels, numFilters) otherwise * * targets: (numFilters, numModules, numImages) * * Note: all of these convolution routines are optimized for the case when * the number of images (i.e. the minibatch size) is a multiple of 128. * Other batch sizes will work, but but I made no attempt whatsoever * to make them work fast. */ void _filterActs( hipStream_t stream, NVMatrix& images, NVMatrix& filters, NVMatrix& targets, int imgSizeY, int numModulesY, int numModulesX, int paddingStart, int moduleStride, int numImgColors, int numGroups, float scaleTargets, float scaleOutput, bool conv) { int numFilterColors = numImgColors / numGroups; int numFilters = filters.getNumCols(); int numModules = numModulesY * numModulesX; int numImages = images.getNumCols(); int imgPixels = images.getNumRows() / numImgColors; int imgSizeX = imgPixels / imgSizeY; int filterModuleMult = conv ? 1 : numModules; megdnn_assert_internal( numGroups > 1 || (numImgColors > 0 && (numImgColors <= 3 || numImgColors % 4 == 0))); megdnn_assert_internal(numGroups == 1 || numFilterColors % 4 == 0); // megdnn_assert_internal(numFilters % (16 * numGroups) == 0); megdnn_assert_internal(numImgColors % numGroups == 0); bool previous_limit = (numFilters % (16 * numGroups)) == 0; // images.printShape("images"); // printf("rows: %d, pixels: %d, colors: %d\n", images.getNumRows(), imgPixels, // numImgColors); images.printShape("images"); megdnn_assert_internal(images.getNumRows() == imgPixels * numImgColors); megdnn_assert_internal(imgSizeY * imgSizeX == imgPixels); int numFiltersPerGroup = numFilters / numGroups; int imgStride = images.getStride(); // images does not need to be a contiguous matrix int filterPixels = filters.getNumRows() / (filterModuleMult * numFilterColors); int filterSize = int(sqrt(filterPixels)); megdnn_assert_internal(filterSize * filterSize == filterPixels); megdnn_assert_internal( filters.getNumRows() == filterModuleMult * numFilterColors * filterPixels); // These routines don't handle the case when only part of the image is visited in // the convolution megdnn_assert_internal(paddingStart <= 0); megdnn_assert_internal( paddingStart + (numModulesX - 1) * moduleStride + filterSize >= imgSizeX); megdnn_assert_internal( paddingStart + (numModulesY - 1) * moduleStride + filterSize >= imgSizeY); megdnn_assert_internal(moduleStride <= filterSize); megdnn_assert_internal(!images.isTrans()); megdnn_assert_internal(!filters.isTrans()); megdnn_assert_internal(!targets.isTrans()); megdnn_assert_internal(filters.isContiguous()); megdnn_assert_internal(targets.isContiguous()); int imgsPerThread = numImages % 128 == 0 ? 4 : numImages % 64 == 0 ? 2 : 1; int filtersPerThread, threadsY = 4; if (numImgColors <= 3) { // Special kernels written for colors = 3, filters = 64 and colors = 3, filters // = 48 cases. The remaining cases use the old routines. // TODO: Modernize the remaining cases if you care about them. filtersPerThread = numFiltersPerGroup % 64 == 0 ? 16 : numFiltersPerGroup % 48 == 0 ? 12 : numFiltersPerGroup % 32 == 0 ? 8 : 4; } else { filtersPerThread = numFiltersPerGroup % 64 == 0 ? 16 : numFiltersPerGroup % 32 == 0 ? 8 : 4; threadsY = numFiltersPerGroup % 128 == 0 && numFilterColors % 8 == 0 && imgsPerThread != 4 ? 8 : 4; } int threadsX = 32; dim3 threads(threadsX, threadsY); dim3 blocks = dim3(DIVUP(numImages, threads.x * imgsPerThread), numModules * DIVUP(numFilters, (threads.y * filtersPerThread))); bool checkImgBounds = numImages % (threads.x * imgsPerThread) != 0; bool scale = scaleTargets != 0; if (scaleTargets == 0) { targets.resize(numFilters * numModules, numImages); } else { megdnn_assert_internal(targets.getNumRows() == numFilters * numModules); megdnn_assert_internal(targets.getNumCols() == numImages); } // Auto-generated calling code... // NOTE: The calling code is set up such that if checkImgBounds is true, then // imgsPerThread = 1. In principle it doesn't have to be this way, and you may want // to optimize for that case. if (scale == false) { if (checkImgBounds == false) { if (numFilterColors % 8 == 0) { if (numImages % 128 == 0) { if (numFiltersPerGroup % 128 == 0) { if (previous_limit) { if (images.getNumDataBytes() < TEXTURE_SIZE_MAX) { hipFuncSetCacheConfig( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4_tex< 4, 32, 4, 16, 4, false, false>, hipFuncCachePreferL1); hipLaunchKernelGGL(( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4_tex< 4, 32, 4, 16, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getTextureObject(), filters.getTextureObject(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else { hipFuncSetCacheConfig( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4< 4, 32, 4, 16, 4, false, false>, hipFuncCachePreferL1); hipLaunchKernelGGL(( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4< 4, 32, 4, 16, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else { hipFuncSetCacheConfig( filterActs_YxX_sparse2< 4, 32, 4, 16, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 4, 16, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numFiltersPerGroup % 64 == 0) { if (previous_limit) { if (images.getNumDataBytes() < TEXTURE_SIZE_MAX) { hipFuncSetCacheConfig( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4_tex< 4, 32, 4, 16, 4, false, false>, hipFuncCachePreferL1); hipLaunchKernelGGL(( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4_tex< 4, 32, 4, 16, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getTextureObject(), filters.getTextureObject(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else { hipFuncSetCacheConfig( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4< 4, 32, 4, 16, 4, false, false>, hipFuncCachePreferL1); hipLaunchKernelGGL(( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4< 4, 32, 4, 16, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else { hipFuncSetCacheConfig( filterActs_YxX_sparse2< 4, 32, 4, 16, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 4, 16, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 8, 8, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 4, 8, 8, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 4, 8, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 4, 4, 8, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numImages % 64 == 0) { if (numFiltersPerGroup % 128 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<8, 32, 2, 16, 8, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<8, 32, 2, 16, 8, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 16, 8, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 2, 16, 8, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 8, 8, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 2, 8, 8, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 4, 8, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 2, 4, 8, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numImages % 32 == 0) { if (numFiltersPerGroup % 128 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<8, 32, 1, 16, 8, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<8, 32, 1, 16, 8, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 8, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 16, 8, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 8, 8, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 8, 8, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 4, 8, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 4, 8, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors % 4 == 0) { if (numImages % 128 == 0) { if (numFiltersPerGroup % 128 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 16, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 4, 16, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 16, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 4, 16, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 8, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 4, 8, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 4, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 4, 4, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numImages % 64 == 0) { if (numFiltersPerGroup % 128 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 16, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 2, 16, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 16, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 2, 16, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 8, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 2, 8, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 4, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 2, 4, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numImages % 32 == 0) { if (numFiltersPerGroup % 128 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 16, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 16, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 8, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 8, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 4, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 4, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 3) { if (numImages % 128 == 0) { if (numFiltersPerGroup % 64 == 0) { if (previous_limit) { hipFuncSetCacheConfig( filterActs_YxX_color_preload_ty_4_tx_32_i_4_f_16_px_4_cc_3_tex< 4, 32, 4, 16, 3, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color_preload_ty_4_tx_32_i_4_f_16_px_4_cc_3_tex< 4, 32, 4, 16, 3, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getTextureObject(), filters.getTextureObject(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else { hipFuncSetCacheConfig( filterActs_YxX_color< 4, 32, 4, 16, 3, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 16, 3, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numFiltersPerGroup % 48 == 0) { if (previous_limit) { hipFuncSetCacheConfig( filterActs_YxX_color_preload_ty_4_tx_32_i_4_f_12_px_4_cc_3_tex< 4, 32, 4, 12, 3, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color_preload_ty_4_tx_32_i_4_f_12_px_4_cc_3_tex< 4, 32, 4, 12, 3, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getTextureObject(), filters.getTextureObject(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else { hipFuncSetCacheConfig( filterActs_YxX_color< 4, 32, 4, 12, 3, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 12, 3, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 8, 3, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 8, 3, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 4, 3, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 4, 3, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 64 == 0) { if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 16, 3, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 16, 3, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 12, 3, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 12, 3, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 8, 3, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 8, 3, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 4, 3, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 4, 3, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 32 == 0) { if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 3, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 16, 3, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 3, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 12, 3, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 3, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 8, 3, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 3, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 4, 3, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 2) { if (numImages % 128 == 0) { if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 16, 2, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 16, 2, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 12, 2, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 12, 2, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 8, 2, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 8, 2, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 4, 2, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 4, 2, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 64 == 0) { if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 16, 2, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 16, 2, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 12, 2, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 12, 2, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 8, 2, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 8, 2, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 4, 2, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 4, 2, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 32 == 0) { if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 2, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 16, 2, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 2, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 12, 2, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 2, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 8, 2, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 2, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 4, 2, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 1) { if (numImages % 128 == 0) { if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 16, 1, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 16, 1, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 12, 1, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 12, 1, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 8, 1, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 8, 1, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 4, 1, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 4, 1, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 64 == 0) { if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 16, 1, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 16, 1, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 12, 1, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 12, 1, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 8, 1, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 8, 1, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 4, 1, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 4, 1, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 32 == 0) { if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 1, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 16, 1, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 1, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 12, 1, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 1, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 8, 1, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 1, 4, false, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 4, 1, 4, false, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } } else if (checkImgBounds == true) { if (numFilterColors % 8 == 0) { if (numImages % 1 == 0) { if (numFiltersPerGroup % 128 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<8, 32, 1, 16, 8, false, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<8, 32, 1, 16, 8, false, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 8, false, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 16, 8, false, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 8, 8, false, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 8, 8, false, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 4, 8, false, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 4, 8, false, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors % 4 == 0) { if (numImages % 1 == 0) { if (numFiltersPerGroup % 128 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 4, false, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 16, 4, false, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 4, false, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 16, 4, false, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 8, 4, false, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 8, 4, false, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 4, 4, false, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 4, 4, false, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 3) { if (numImages % 1 == 0) { if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 3, 4, false, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 16, 3, 4, false, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 3, 4, false, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 12, 3, 4, false, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 3, 4, false, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 8, 3, 4, false, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 3, 4, false, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 4, 3, 4, false, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 2) { if (numImages % 1 == 0) { if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 2, 4, false, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 16, 2, 4, false, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 2, 4, false, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 12, 2, 4, false, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 2, 4, false, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 8, 2, 4, false, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 2, 4, false, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 4, 2, 4, false, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 1) { if (numImages % 1 == 0) { if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 1, 4, false, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 16, 1, 4, false, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 1, 4, false, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 12, 1, 4, false, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 1, 4, false, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 8, 1, 4, false, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 1, 4, false, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 4, 1, 4, false, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } } } else if (scale == true) { if (checkImgBounds == false) { if (numFilterColors % 8 == 0) { if (numImages % 128 == 0) { if (numFiltersPerGroup % 128 == 0) { if (previous_limit) { if (images.getNumDataBytes() < TEXTURE_SIZE_MAX) { hipFuncSetCacheConfig( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4_tex< 4, 32, 4, 16, 4, true, false>, hipFuncCachePreferL1); hipLaunchKernelGGL(( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4_tex< 4, 32, 4, 16, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getTextureObject(), filters.getTextureObject(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else { hipFuncSetCacheConfig( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4< 4, 32, 4, 16, 4, true, false>, hipFuncCachePreferL1); hipLaunchKernelGGL(( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4< 4, 32, 4, 16, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else { hipFuncSetCacheConfig( filterActs_YxX_sparse2< 4, 32, 4, 16, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 4, 16, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numFiltersPerGroup % 64 == 0) { if (previous_limit) { if (images.getNumDataBytes() < TEXTURE_SIZE_MAX) { hipFuncSetCacheConfig( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4_tex< 4, 32, 4, 16, 4, true, false>, hipFuncCachePreferL1); hipLaunchKernelGGL(( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4_tex< 4, 32, 4, 16, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getTextureObject(), filters.getTextureObject(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else { hipFuncSetCacheConfig( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4< 4, 32, 4, 16, 4, true, false>, hipFuncCachePreferL1); hipLaunchKernelGGL(( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4< 4, 32, 4, 16, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else { hipFuncSetCacheConfig( filterActs_YxX_sparse2< 4, 32, 4, 16, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 4, 16, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 8, 8, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 4, 8, 8, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 4, 8, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 4, 4, 8, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numImages % 64 == 0) { if (numFiltersPerGroup % 128 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<8, 32, 2, 16, 8, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<8, 32, 2, 16, 8, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 16, 8, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 2, 16, 8, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 8, 8, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 2, 8, 8, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 4, 8, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 2, 4, 8, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numImages % 32 == 0) { if (numFiltersPerGroup % 128 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<8, 32, 1, 16, 8, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<8, 32, 1, 16, 8, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 8, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 16, 8, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 8, 8, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 8, 8, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 4, 8, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 4, 8, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors % 4 == 0) { if (numImages % 128 == 0) { if (numFiltersPerGroup % 128 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 16, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 4, 16, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 16, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 4, 16, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 8, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 4, 8, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 4, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 4, 4, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numImages % 64 == 0) { if (numFiltersPerGroup % 128 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 16, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 2, 16, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 16, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 2, 16, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 8, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 2, 8, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 4, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 2, 4, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numImages % 32 == 0) { if (numFiltersPerGroup % 128 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 16, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 16, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 8, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 8, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 4, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 4, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 3) { if (numImages % 128 == 0) { if (numFiltersPerGroup % 64 == 0) { if (previous_limit) { hipFuncSetCacheConfig( filterActs_YxX_color_preload_ty_4_tx_32_i_4_f_16_px_4_cc_3_tex< 4, 32, 4, 16, 3, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color_preload_ty_4_tx_32_i_4_f_16_px_4_cc_3_tex< 4, 32, 4, 16, 3, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getTextureObject(), filters.getTextureObject(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else { hipFuncSetCacheConfig( filterActs_YxX_color< 4, 32, 4, 16, 3, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 16, 3, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numFiltersPerGroup % 48 == 0) { if (previous_limit) { hipFuncSetCacheConfig( filterActs_YxX_color_preload_ty_4_tx_32_i_4_f_12_px_4_cc_3_tex< 4, 32, 4, 12, 3, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color_preload_ty_4_tx_32_i_4_f_12_px_4_cc_3_tex< 4, 32, 4, 12, 3, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getTextureObject(), filters.getTextureObject(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else { hipFuncSetCacheConfig( filterActs_YxX_color< 4, 32, 4, 12, 3, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 12, 3, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 8, 3, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 8, 3, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 4, 3, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 4, 3, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 64 == 0) { if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 16, 3, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 16, 3, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 12, 3, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 12, 3, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 8, 3, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 8, 3, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 4, 3, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 4, 3, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 32 == 0) { if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 3, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 16, 3, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 3, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 12, 3, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 3, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 8, 3, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 3, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 4, 3, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 2) { if (numImages % 128 == 0) { if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 16, 2, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 16, 2, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 12, 2, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 12, 2, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 8, 2, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 8, 2, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 4, 2, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 4, 2, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 64 == 0) { if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 16, 2, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 16, 2, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 12, 2, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 12, 2, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 8, 2, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 8, 2, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 4, 2, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 4, 2, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 32 == 0) { if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 2, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 16, 2, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 2, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 12, 2, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 2, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 8, 2, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 2, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 4, 2, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 1) { if (numImages % 128 == 0) { if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 16, 1, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 16, 1, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 12, 1, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 12, 1, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 8, 1, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 8, 1, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 4, 1, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 4, 4, 1, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 64 == 0) { if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 16, 1, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 16, 1, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 12, 1, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 12, 1, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 8, 1, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 8, 1, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 4, 1, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 2, 4, 1, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 32 == 0) { if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 1, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 16, 1, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 1, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 12, 1, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 1, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 8, 1, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 1, 4, true, false>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 4, 1, 4, true, false>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } } else if (checkImgBounds == true) { if (numFilterColors % 8 == 0) { if (numImages % 1 == 0) { if (numFiltersPerGroup % 128 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<8, 32, 1, 16, 8, true, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<8, 32, 1, 16, 8, true, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 8, true, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 16, 8, true, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 8, 8, true, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 8, 8, true, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 4, 8, true, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 4, 8, true, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors % 4 == 0) { if (numImages % 1 == 0) { if (numFiltersPerGroup % 128 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 4, true, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 16, 4, true, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 4, true, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 16, 4, true, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 8, 4, true, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 8, 4, true, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 4, 4, true, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_sparse2<4, 32, 1, 4, 4, true, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 3) { if (numImages % 1 == 0) { if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 3, 4, true, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 16, 3, 4, true, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 3, 4, true, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 12, 3, 4, true, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 3, 4, true, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 8, 3, 4, true, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 3, 4, true, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 4, 3, 4, true, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 2) { if (numImages % 1 == 0) { if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 2, 4, true, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 16, 2, 4, true, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 2, 4, true, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 12, 2, 4, true, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 2, 4, true, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 8, 2, 4, true, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 2, 4, true, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 4, 2, 4, true, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 1) { if (numImages % 1 == 0) { if (numFiltersPerGroup % 64 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 1, 4, true, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 16, 1, 4, true, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 1, 4, true, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 12, 1, 4, true, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 1, 4, true, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 8, 1, 4, true, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { hipFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 1, 4, true, true>, hipFuncCachePreferShared); hipLaunchKernelGGL(( filterActs_YxX_color<4, 32, 1, 4, 1, 4, true, true>) , dim3(blocks), dim3(threads), 0, stream, images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } } } getLastCudaError("filterActs: kernel execution failed"); } void convFilterActs( hipStream_t stream, NVMatrix& images, NVMatrix& filters, NVMatrix& targets, int imgSizeY, int numModulesY, int numModulesX, int paddingStart, int moduleStride, int numImgColors, int numGroups) { convFilterActs( stream, images, filters, targets, imgSizeY, numModulesY, numModulesX, paddingStart, moduleStride, numImgColors, numGroups, 0, 1); } void convFilterActs( hipStream_t stream, NVMatrix& images, NVMatrix& filters, NVMatrix& targets, int imgSizeY, int numModulesY, int numModulesX, int paddingStart, int moduleStride, int numImgColors, int numGroups, float scaleTargets, float scaleOutput) { _filterActs( stream, images, filters, targets, imgSizeY, numModulesY, numModulesX, paddingStart, moduleStride, numImgColors, numGroups, scaleTargets, scaleOutput, true); } void localFilterActs( hipStream_t stream, NVMatrix& images, NVMatrix& filters, NVMatrix& targets, int imgSizeY, int numModulesY, int numModulesX, int paddingStart, int moduleStride, int numImgColors, int numGroups) { localFilterActs( stream, images, filters, targets, imgSizeY, numModulesY, numModulesX, paddingStart, moduleStride, numImgColors, numGroups, 0, 1); } void localFilterActs( hipStream_t stream, NVMatrix& images, NVMatrix& filters, NVMatrix& targets, int imgSizeY, int numModulesY, int numModulesX, int paddingStart, int moduleStride, int numImgColors, int numGroups, float scaleTargets, float scaleOutput) { _filterActs( stream, images, filters, targets, imgSizeY, numModulesY, numModulesX, paddingStart, moduleStride, numImgColors, numGroups, scaleTargets, scaleOutput, false); } } // namespace cuda } // namespace megdnn
74eb677de466898debcd640aff8265509afa9fe6.cu
#include "cudaconv2.cuh" #include "filter_acts/filter_act_templates.cuh" #include "nvmatrix.cuh" #include "src/cuda/utils.cuh" namespace megdnn { namespace cuda { __device__ __forceinline__ void filterActs_YxX_color_preload_ty_4_tx_32_f_16_cc_3_setImgCoords( int fPidx, int imgLoadModPosY, int imgLoadModPosX, int imgSizeX, int filterSize, int& iPidx) { int x = imgLoadModPosX + (fPidx) % filterSize; int y = imgLoadModPosY + (fPidx) / filterSize; iPidx = y >= 0 && y < imgSizeX && x >= 0 && x < imgSizeX ? y * imgSizeX + x : -1; } #define FA_COLOR3_IMPRELOAD(c, i) \ imPreload[c][i] = \ iPidxNext < 0 || (checkImgBounds && myImgIdx + i * B_X >= numImages) \ ? 0 \ : mm[c * imgPixels * imgStride + i * B_X]; #define FA_COLOR3_IMPRELOAD_TX(c, i) \ imPreload[c][i] = \ iPidxNext < 0 || (checkImgBounds && myImgIdx + i * B_X >= numImages) \ ? 0 \ : tex1Dfetch<float>( \ images, \ imagesOffset2 + c * imgPixels * imgStride + i * B_X); /* * images: (numImgColors, imgSizeY, imgSizeX, numImages) with stride given * filters: (numFilterColors, filterPixels, numFilters) if conv * (numModules, numFilterColors, filterPixels, numFilters) otherwise * * targets: (numFilters, numModulesY, numModulesX, numImages) * */ template < int B_Y, int B_X, int imgsPerThread, int filtersPerThread, int numColors, int pixelCache, bool scale, bool checkImgBounds> //__launch_bounds__(128,3) __global__ void filterActs_YxX_color_preload_ty_4_tx_32_i_4_f_16_px_4_cc_3_tex( cudaTextureObject_t images, cudaTextureObject_t filters, float* targets, const int numImages, const int numFilters, const int imgSizeY, const int imgSizeX, const int filterSize, const int paddingStart, const int moduleStride, const int numModulesY, const int numModulesX, const int imgStride, const float scaleTargets, const float scaleOutputs, const bool conv /*, const bool noloads*/) { __shared__ float shFilters [numColors][pixelCache] [B_Y * filtersPerThread]; // pre-load 1 pixel from B_Y*filtersPerThread filters __shared__ float shImages[numColors][pixelCache] [B_X * imgsPerThread]; // pre-load 1 pixel from B_X*imgsPerThread images fill_shared_mem<float>((float*)shFilters, sizeof(shFilters) / sizeof(float), 0); fill_shared_mem<float>((float*)shImages, sizeof(shImages) / sizeof(float), 0); __syncthreads(); const int imgPixels = imgSizeY * imgSizeX; const int filterPixels = filterSize * filterSize; const int blocksPerModule = numFilters / (B_Y * filtersPerThread); const int moduleIdx = blockIdx.y / blocksPerModule; const int blockFilterIdx = filtersPerThread * B_Y * (blockIdx.y % blocksPerModule); const int numModules = numModulesX * numModulesY; // Another fun insanity: the % B_X makes things faster, even thought threadIdx.x is // in the range 0..31. It appears that this allows the compiler to optimize? const int tx = threadIdx.x % B_X; const int ty = threadIdx.y % B_Y; const int tidx = ty * B_X + threadIdx.x; const int imgLoadModPosY = paddingStart + (moduleIdx / numModulesX) * moduleStride; const int imgLoadModPosX = paddingStart + (moduleIdx % numModulesX) * moduleStride; const int shFilterLoadY = tidx / (B_Y * filtersPerThread); const int shFilterLoadX = tidx % (B_Y * filtersPerThread); const int myImgIdx = blockIdx.x * B_X * imgsPerThread + threadIdx.x; // images += myImgIdx; // filters += blockFilterIdx // + shFilterLoadY * numFilters + shFilterLoadX; // if (!conv) { // NOTE: UNTESTED! // filters += moduleIdx * numColors * filterPixels * numFilters; // } const int imagesOffset = myImgIdx; const int filtersOffset = blockFilterIdx + shFilterLoadY * numFilters + shFilterLoadX + (conv ? 0 : moduleIdx * numColors * filterPixels * numFilters); targets += moduleIdx * numImages + (blockFilterIdx + threadIdx.y * filtersPerThread) * numImages * numModules + myImgIdx; float prod[imgsPerThread][filtersPerThread]; #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { prod[i][f] = 0; } } int iPidxNext; float imPreload[numColors][imgsPerThread]; float fPreload[numColors][pixelCache * filtersPerThread / B_X]; #pragma unroll for (int c = 0; c < numColors; ++c) { #pragma unroll for (int p = 0; p < pixelCache; p += B_X / filtersPerThread) { if (p + shFilterLoadY < filterPixels) { fPreload[c][p * filtersPerThread / B_X] = tex1Dfetch<float>( filters, filtersOffset + p * numFilters + c * numFilters * filterPixels); } else { fPreload[c][p * filtersPerThread / B_X] = 0; } } } filterActs_YxX_color_preload_ty_4_tx_32_f_16_cc_3_setImgCoords( ty, imgLoadModPosY, imgLoadModPosX, imgSizeX, filterSize, iPidxNext); #pragma unroll for (int c = 0; c < numColors; ++c) { #pragma unroll for (int i = 0; i < imgsPerThread; i++) { if (iPidxNext >= 0 && (!checkImgBounds || myImgIdx + i * B_X < numImages)) { imPreload[c][i] = tex1Dfetch<float>( images, imagesOffset + (c * imgPixels + iPidxNext) * imgStride + i * B_X); } else { imPreload[c][i] = 0; } } } for (int p = 0; p < filterPixels; p += pixelCache) { #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int c = 0; c < numColors; ++c) { // NOTE: bank conflicts here! shImages[c][ty][tx * imgsPerThread + i] = imPreload[c][i]; } } const int fPidxNext = p + pixelCache >= filterPixels ? 0 : p + pixelCache; filterActs_YxX_color_preload_ty_4_tx_32_f_16_cc_3_setImgCoords( fPidxNext + ty, imgLoadModPosY, imgLoadModPosX, imgSizeX, filterSize, iPidxNext); // const float* ff = &filters[numFilters * fPidxNext]; // const float* mm = &images[imgStride * iPidxNext]; const int filtersOffset2 = filtersOffset + numFilters * fPidxNext; const int imagesOffset2 = imagesOffset + imgStride * iPidxNext; FA_COLOR3_IMPRELOAD_TX(0, 0); FA_COLOR3_IMPRELOAD_TX(0, 1); FA_COLOR3_IMPRELOAD_TX(0, 2); FA_COLOR3_IMPRELOAD_TX(0, 3); #pragma unroll for (int c = 0; c < numColors; ++c) { #pragma unroll for (int pp = 0; pp < pixelCache; pp += B_X / filtersPerThread) { shFilters[c][pp + shFilterLoadY][shFilterLoadX] = fPreload[c][pp * filtersPerThread / B_X]; } } __syncthreads(); FA_COLOR3_IMPRELOAD_TX(1, 0); FA_COLOR3_IMPRELOAD_TX(1, 1); FA_COLOR3_IMPRELOAD_TX(1, 2); FA_COLOR3_IMPRELOAD_TX(1, 3); FA_COLOR3_IMPRELOAD_TX(2, 0); FA_COLOR3_IMPRELOAD_TX(2, 1); FA_COLOR3_IMPRELOAD_TX(2, 2); FA_COLOR3_IMPRELOAD_TX(2, 3); #pragma unroll for (int c = 0; c < numColors; c++) { #pragma unroll for (int pp = 0; pp < pixelCache * filtersPerThread / B_X; pp++) { fPreload[c][pp] = fPidxNext + pp * (B_X / filtersPerThread) + shFilterLoadY >= filterPixels ? 0 : tex1Dfetch<float>( filters, filtersOffset2 + c * numFilters * filterPixels + pp * (B_X / filtersPerThread) * numFilters); } } #pragma unroll for (int pp = 0; pp < pixelCache; pp++) { #pragma unroll for (int c = 0; c < numColors; c++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { #pragma unroll for (int i = 0; i < imgsPerThread; i++) { prod[i][f] += shImages[c][pp][tx * imgsPerThread + i] * shFilters[c][pp][ty * filtersPerThread + f]; } } } } __syncthreads(); } if (scale) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { #pragma unroll for (int i = 0; i < imgsPerThread; i++) { if (!checkImgBounds || myImgIdx + i * B_X < numImages) { targets[i * B_X + f * numImages * numModules] = scaleTargets * targets[i * B_X + f * numImages * numModules] + scaleOutputs * prod[i][f]; } } } } else { // Note: reversing order of these loops saves 2 registers, but costs time #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { if (!checkImgBounds || myImgIdx + i * B_X < numImages) { targets[i * B_X + f * numImages * numModules] = scaleOutputs * prod[i][f]; } } } } } /* * images: (numImgColors, imgSizeY, imgSizeX, numImages) with stride given * filters: (numFilterColors, filterPixels, numFilters) if conv * (numModules, numFilterColors, filterPixels, numFilters) otherwise * * targets: (numFilters, numModulesY, numModulesX, numImages) * * This won't be pretty. */ template < int B_Y, int B_X, int imgsPerThread, int filtersPerThread, int numColors, int pixelCache, bool scale, bool checkImgBounds> __global__ void filterActs_YxX_color_preload_ty_4_tx_32_i_4_f_12_px_4_cc_3_tex( cudaTextureObject_t images, cudaTextureObject_t filters, float* targets, const int numImages, const int numFilters, const int imgSizeY, const int imgSizeX, const int filterSize, const int paddingStart, const int moduleStride, const int numModulesY, const int numModulesX, const int imgStride, const float scaleTargets, const float scaleOutputs, const bool conv /*, const bool noloads*/) { __shared__ float shFilters [numColors][pixelCache] [B_Y * filtersPerThread]; // pre-load 1 pixel from B_Y*filtersPerThread filters __shared__ float shImages[numColors][pixelCache] [B_X * imgsPerThread]; // pre-load 1 pixel from B_X*imgsPerThread images fill_shared_mem<float>((float*)shFilters, sizeof(shFilters) / sizeof(float), 0); fill_shared_mem<float>((float*)shImages, sizeof(shImages) / sizeof(float), 0); __syncthreads(); const int imgPixels = imgSizeY * imgSizeX; const int filterPixels = filterSize * filterSize; const int blocksPerModule = numFilters / (B_Y * filtersPerThread); const int moduleIdx = blockIdx.y / blocksPerModule; const int blockFilterIdx = filtersPerThread * B_Y * (blockIdx.y % blocksPerModule); const int numModules = numModulesX * numModulesY; // Another fun insanity: the % B_X makes things faster, even though threadIdx.x is // in the range 0..31. It appears that this allows the compiler to optimize? const int tx = threadIdx.x % B_X; const int ty = threadIdx.y % B_Y; const int tidx = ty * B_X + threadIdx.x; const int warp = tidx / 32; const int imgLoadModPosY = paddingStart + (moduleIdx / numModulesX) * moduleStride; const int imgLoadModPosX = paddingStart + (moduleIdx % numModulesX) * moduleStride; const int shFilterLoadY = tidx / (B_Y * filtersPerThread); const int shFilterLoadX = tidx % (B_Y * filtersPerThread); const int myImgIdx = blockIdx.x * B_X * imgsPerThread + threadIdx.x; // images += myImgIdx; // filters += blockFilterIdx // + shFilterLoadY * numFilters + shFilterLoadX; // if (!conv) { // NOTE: UNTESTED! // filters += moduleIdx * numColors * filterPixels * numFilters; // } const int imagesOffset = myImgIdx; const int filtersOffset = blockFilterIdx + shFilterLoadY * numFilters + shFilterLoadX + (conv ? 0 : moduleIdx * numColors * filterPixels * numFilters); targets += moduleIdx * numImages + (blockFilterIdx + threadIdx.y * filtersPerThread) * numImages * numModules + myImgIdx; float prod[imgsPerThread][filtersPerThread]; #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { prod[i][f] = 0; } } int iPidxNext; float imPreload[numColors][imgsPerThread]; float fPreload[numColors][DIVUP(pixelCache * filtersPerThread, B_X)]; if (warp < 3) { #pragma unroll for (int c = 0; c < numColors; ++c) { #pragma unroll for (int p = 0; p < pixelCache; p += 2) { if (p + shFilterLoadY < filterPixels) { fPreload[c][p / 2] = tex1Dfetch<float>( filters, filtersOffset + p * numFilters + c * numFilters * filterPixels); } else { fPreload[c][p / 2] = 0; } } } } filterActs_YxX_color_preload_ty_4_tx_32_f_16_cc_3_setImgCoords( ty, imgLoadModPosY, imgLoadModPosX, imgSizeX, filterSize, iPidxNext); #pragma unroll for (int c = 0; c < numColors; ++c) { #pragma unroll for (int i = 0; i < imgsPerThread; i++) { if (iPidxNext >= 0 && (!checkImgBounds || myImgIdx + i * B_X < numImages)) { imPreload[c][i] = tex1Dfetch<float>( images, imagesOffset + (c * imgPixels + iPidxNext) * imgStride + i * B_X); } else { imPreload[c][i] = 0; } } } for (int p = 0; p < filterPixels; p += pixelCache) { const int fPidxNext = p + pixelCache >= filterPixels ? 0 : p + pixelCache; filterActs_YxX_color_preload_ty_4_tx_32_f_16_cc_3_setImgCoords( fPidxNext + ty, imgLoadModPosY, imgLoadModPosX, imgSizeX, filterSize, iPidxNext); #pragma unroll for (int c = 0; c < numColors; ++c) { #pragma unroll for (int i = 0; i < imgsPerThread; i++) { // NOTE: bank conflicts here! shImages[c][ty][tx * imgsPerThread + i] = imPreload[c][i]; } } if (warp < 3) { #pragma unroll for (int c = 0; c < numColors; ++c) { #pragma unroll for (int pp = 0; pp < pixelCache; pp += 2) { shFilters[c][pp + shFilterLoadY][shFilterLoadX] = fPreload[c][pp / 2]; } } } __syncthreads(); // const float* ff = &filters[numFilters * fPidxNext]; // const float* mm = &images[imgStride * iPidxNext]; const int filtersOffset2 = filtersOffset + numFilters * fPidxNext; const int imagesOffset2 = imagesOffset + imgStride * iPidxNext; #pragma unroll for (int i = 0; i < imgsPerThread; ++i) { #pragma unroll for (int c = 0; c < numColors; c++) { FA_COLOR3_IMPRELOAD_TX(c, i); } } #pragma unroll for (int c = 0; c < numColors; c++) { #pragma unroll for (int pp = 0; pp < 2; pp++) { fPreload[c][pp] = warp >= 3 || fPidxNext + pp * 2 + shFilterLoadY >= filterPixels ? 0 : tex1Dfetch<float>( filters, filtersOffset2 + c * numFilters * filterPixels + pp * 2 * numFilters); } #pragma unroll for (int pp = 0; pp < pixelCache; pp++) { #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { prod[i][f] += shImages[c][pp][tx * imgsPerThread + i] * shFilters[c][pp][ty * filtersPerThread + f]; } } } } __syncthreads(); } if (scale) { #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { if (!checkImgBounds || myImgIdx + i * B_X < numImages) { targets[i * B_X + f * numImages * numModules] = scaleTargets * targets[i * B_X + f * numImages * numModules] + scaleOutputs * prod[i][f]; } } } } else { // Note: reversing order of these loops costs 2 registers, but saves time #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { if (!checkImgBounds || myImgIdx + i * B_X < numImages) { targets[i * B_X + f * numImages * numModules] = scaleOutputs * prod[i][f]; } } } } } /* * images: (numImgColors, imgSizeY, imgSizeX, numImages) with stride given * filters: (numFilterColors, filterPixels, numFilters) if conv * (numModules, numFilterColors, filterPixels, numFilters) otherwise * * targets: (numFilters, numModulesY, numModulesX, numImages) * * Note: in git there's a 1.5% faster version of this which sues 167 registers instead * of 154... it's basically the same thing, but it doesn't do the next-pixel * computation. It just avoids pre-loading when it rolls over to the next pixel. */ template < int B_Y, int B_X, int imgsPerThread, int filtersPerThread, int colorCache, bool scale, bool checkImgBounds> __global__ void filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4( float* images, float* filters, float* targets, const int numImages, const int numFilters, const int imgSizeY, const int imgSizeX, const int filterSize, const int paddingStart, const int moduleStride, const int numModulesY, const int numModulesX, const int imgStride, const int numImgColors, const int numGroups, const float scaleTargets, const float scaleOutputs, const bool conv /*, const bool noloads*/) { __shared__ float shFilters [colorCache] [B_Y * filtersPerThread]; // pre-load 1 pixel from B_Y*filtersPerThread filters __shared__ float shImages[colorCache] [B_X * imgsPerThread]; // pre-load 1 pixel from B_X*imgsPerThread images fill_shared_mem<float>((float*)shFilters, sizeof(shFilters) / sizeof(float), 0); fill_shared_mem<float>((float*)shImages, sizeof(shImages) / sizeof(float), 0); __syncthreads(); const int imgPixels = imgSizeY * imgSizeX; const int filterPixels = filterSize * filterSize; const int numFilterColors = numImgColors / numGroups; const int blocksPerModule = numFilters / (B_Y * filtersPerThread); const int moduleIdx = blockIdx.y / blocksPerModule; const int blockFilterIdx = filtersPerThread * B_Y * (blockIdx.y % blocksPerModule); const int numFiltersPerGroup = numFilters / numGroups; const int blockGroupIdx = blockFilterIdx / numFiltersPerGroup; const int numModules = numModulesX * numModulesY; const int blockColorIdx = numFilterColors * blockGroupIdx; // Another fun insanity: the % B_X makes things faster, even thought threadIdx.x is // in the range 0..31. It appears that this allows the compiler to optimize? const int tx = threadIdx.x % B_X; const int ty = threadIdx.y % B_Y; const int tidx = ty * B_X + threadIdx.x; const int imgLoadModPosY = paddingStart + (moduleIdx / numModulesX) * moduleStride; const int imgLoadModPosX = paddingStart + (moduleIdx % numModulesX) * moduleStride; const int shFilterLoadY = tidx / (B_Y * filtersPerThread); const int shFilterLoadX = tidx % (B_Y * filtersPerThread); const int myImgIdx = blockIdx.x * B_X * imgsPerThread + threadIdx.x; images += (blockColorIdx + threadIdx.y) * imgPixels * imgStride + myImgIdx; filters += blockFilterIdx + shFilterLoadY * numFilters * filterPixels + shFilterLoadX; if (!conv) { filters += moduleIdx * numFilterColors * filterPixels * numFilters; } targets += moduleIdx * numImages + (blockFilterIdx + threadIdx.y * filtersPerThread) * numImages * numModules + myImgIdx; float prod[imgsPerThread][filtersPerThread]; // float fCache[filtersPerThread]; #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { prod[i][f] = 0; } } // NOTE: these max/min functions increase register usage as compared to my macros const int imgStartX = max(0, imgLoadModPosX); const int imgStartY = max(0, imgLoadModPosY); const int imgEndX = min(imgLoadModPosX + filterSize, imgSizeX); const int imgEndY = min(imgLoadModPosY + filterSize, imgSizeY); // __shared__ int imgPos[] int fPidx, iPidx; float imPreload[imgsPerThread]; float fPreload[colorCache * filtersPerThread / B_X]; // float fCache[filtersPerThread]; filterActs_YxX_sparse2_preload_ty_4_tx_32_f_16_c_4_setPixelCoords( filterSize, imgSizeX, imgLoadModPosY, imgLoadModPosX, imgStartY, imgStartX, fPidx, iPidx); #pragma unroll for (int i = 0; i < imgsPerThread; i++) { if (!checkImgBounds || myImgIdx + i * B_X < numImages) { imPreload[i] = images[imgStride * iPidx + i * B_X]; } else { imPreload[i] = 0; } } if (/*B_X % filtersPerThread == 0 ||*/ shFilterLoadY < B_X / filtersPerThread) { // This if statement reduces reg usage.. #pragma unroll for (int c = 0; c < colorCache; c += B_X / filtersPerThread) { fPreload[c * filtersPerThread / B_X] = filters[(c * filterPixels + fPidx) * numFilters]; } } for (int imgY = imgStartY; imgY < imgEndY; ++imgY) { // const int filterPxY = imgY - imgLoadModPosY; for (int imgX = imgStartX; imgX < imgEndX; ++imgX) { // const int filterPxX = imgX - imgLoadModPosX; // const int p = filterPxY * filterSize + filterPxX; // const int pixIdx = imgY * imgSizeX + imgX;// Pixel index in // img setPixelCoords(filterSize, imgSizeX, imgLoadModPosY, // imgLoadModPosX, imgY, imgX, &p, &pixIdx); float* m = // &images[imgStride * pixIdx]; const bool lastPixel = imgY == imgEndY - 1 && imgX == imgEndX - 1; int imgYNext = imgY; int imgXNext = imgX; int fPidxNext, iPidxNext; if (!lastPixel) { imgYNext = imgY + (imgX + 1 == imgEndX); imgXNext = imgX + 1 == imgEndX ? imgStartX : imgX + 1; } filterActs_YxX_sparse2_preload_ty_4_tx_32_f_16_c_4_setPixelCoords( filterSize, imgSizeX, imgLoadModPosY, imgLoadModPosX, imgYNext, imgXNext, fPidxNext, iPidxNext); for (int oc = 0; oc < numFilterColors; oc += colorCache) { // oc stands for outer color (loop) const float* ff = &filters [numFilters * ((oc + colorCache) * filterPixels + fPidx)]; const float* mm = &images[imgStride * ((oc + colorCache) * imgPixels + iPidx)]; if (oc == numFilterColors - colorCache) { ff = &filters[fPidxNext * numFilters]; mm = &images[iPidxNext * imgStride]; fPidx = fPidxNext; iPidx = iPidxNext; } #pragma unroll for (int c = 0; c < colorCache; c += B_X / filtersPerThread) { shFilters[c + shFilterLoadY][shFilterLoadX] = fPreload[c * filtersPerThread / B_X]; } #pragma unroll for (int i = 0; i < imgsPerThread; i++) { // NOTE: bank conflicts here! shImages[ty][tx * imgsPerThread + i] = imPreload[i]; } imPreload[0] = (checkImgBounds && myImgIdx + 0 * B_X >= numImages) ? 0 : mm[0 * B_X]; imPreload[1] = (checkImgBounds && myImgIdx + 1 * B_X >= numImages) ? 0 : mm[1 * B_X]; imPreload[2] = (checkImgBounds && myImgIdx + 2 * B_X >= numImages) ? 0 : mm[2 * B_X]; __syncthreads(); #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { prod[i][f] += shImages[0][threadIdx.x * imgsPerThread + i] * shFilters[0][threadIdx.y * filtersPerThread + f]; } } fPreload[0] = ff[0]; #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { prod[i][f] += shImages[1][threadIdx.x * imgsPerThread + i] * shFilters[1][threadIdx.y * filtersPerThread + f]; } } fPreload[1] = ff[(B_X / filtersPerThread * filterPixels) * numFilters]; #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { prod[i][f] += shImages[2][threadIdx.x * imgsPerThread + i] * shFilters[2][threadIdx.y * filtersPerThread + f]; } } imPreload[3] = (checkImgBounds && myImgIdx + 3 * B_X >= numImages) ? 0 : mm[3 * B_X]; #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { prod[i][f] += shImages[3][threadIdx.x * imgsPerThread + i] * shFilters[3][threadIdx.y * filtersPerThread + f]; } } __syncthreads(); } } } if (scale) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { #pragma unroll for (int i = 0; i < imgsPerThread; i++) { if (!checkImgBounds || myImgIdx + i * B_X < numImages) { targets[i * B_X + f * numImages * numModules] = scaleTargets * targets[i * B_X + f * numImages * numModules] + scaleOutputs * prod[i][f]; } } } } else { // Note: reversing order of these loops saves 2 registers, but costs time #pragma unroll for (int i = 0; i < imgsPerThread; i++) { #pragma unroll for (int f = 0; f < filtersPerThread; f++) { if (!checkImgBounds || myImgIdx + i * B_X < numImages) { targets[i * B_X + f * numImages * numModules] = scaleOutputs * prod[i][f]; } } } } } /* * images: (numImgColors, imgSizeY, imgSizeX, numImages) with stride given * filters: (numFilterColors, filterPixels, numFilters) if conv * (numModules, numFilterColors, filterPixels, numFilters) otherwise * * targets: (numFilters, numModules, numImages) * * Note: all of these convolution routines are optimized for the case when * the number of images (i.e. the minibatch size) is a multiple of 128. * Other batch sizes will work, but but I made no attempt whatsoever * to make them work fast. */ void _filterActs( cudaStream_t stream, NVMatrix& images, NVMatrix& filters, NVMatrix& targets, int imgSizeY, int numModulesY, int numModulesX, int paddingStart, int moduleStride, int numImgColors, int numGroups, float scaleTargets, float scaleOutput, bool conv) { int numFilterColors = numImgColors / numGroups; int numFilters = filters.getNumCols(); int numModules = numModulesY * numModulesX; int numImages = images.getNumCols(); int imgPixels = images.getNumRows() / numImgColors; int imgSizeX = imgPixels / imgSizeY; int filterModuleMult = conv ? 1 : numModules; megdnn_assert_internal( numGroups > 1 || (numImgColors > 0 && (numImgColors <= 3 || numImgColors % 4 == 0))); megdnn_assert_internal(numGroups == 1 || numFilterColors % 4 == 0); // megdnn_assert_internal(numFilters % (16 * numGroups) == 0); megdnn_assert_internal(numImgColors % numGroups == 0); bool previous_limit = (numFilters % (16 * numGroups)) == 0; // images.printShape("images"); // printf("rows: %d, pixels: %d, colors: %d\n", images.getNumRows(), imgPixels, // numImgColors); images.printShape("images"); megdnn_assert_internal(images.getNumRows() == imgPixels * numImgColors); megdnn_assert_internal(imgSizeY * imgSizeX == imgPixels); int numFiltersPerGroup = numFilters / numGroups; int imgStride = images.getStride(); // images does not need to be a contiguous matrix int filterPixels = filters.getNumRows() / (filterModuleMult * numFilterColors); int filterSize = int(sqrt(filterPixels)); megdnn_assert_internal(filterSize * filterSize == filterPixels); megdnn_assert_internal( filters.getNumRows() == filterModuleMult * numFilterColors * filterPixels); // These routines don't handle the case when only part of the image is visited in // the convolution megdnn_assert_internal(paddingStart <= 0); megdnn_assert_internal( paddingStart + (numModulesX - 1) * moduleStride + filterSize >= imgSizeX); megdnn_assert_internal( paddingStart + (numModulesY - 1) * moduleStride + filterSize >= imgSizeY); megdnn_assert_internal(moduleStride <= filterSize); megdnn_assert_internal(!images.isTrans()); megdnn_assert_internal(!filters.isTrans()); megdnn_assert_internal(!targets.isTrans()); megdnn_assert_internal(filters.isContiguous()); megdnn_assert_internal(targets.isContiguous()); int imgsPerThread = numImages % 128 == 0 ? 4 : numImages % 64 == 0 ? 2 : 1; int filtersPerThread, threadsY = 4; if (numImgColors <= 3) { // Special kernels written for colors = 3, filters = 64 and colors = 3, filters // = 48 cases. The remaining cases use the old routines. // TODO: Modernize the remaining cases if you care about them. filtersPerThread = numFiltersPerGroup % 64 == 0 ? 16 : numFiltersPerGroup % 48 == 0 ? 12 : numFiltersPerGroup % 32 == 0 ? 8 : 4; } else { filtersPerThread = numFiltersPerGroup % 64 == 0 ? 16 : numFiltersPerGroup % 32 == 0 ? 8 : 4; threadsY = numFiltersPerGroup % 128 == 0 && numFilterColors % 8 == 0 && imgsPerThread != 4 ? 8 : 4; } int threadsX = 32; dim3 threads(threadsX, threadsY); dim3 blocks = dim3(DIVUP(numImages, threads.x * imgsPerThread), numModules * DIVUP(numFilters, (threads.y * filtersPerThread))); bool checkImgBounds = numImages % (threads.x * imgsPerThread) != 0; bool scale = scaleTargets != 0; if (scaleTargets == 0) { targets.resize(numFilters * numModules, numImages); } else { megdnn_assert_internal(targets.getNumRows() == numFilters * numModules); megdnn_assert_internal(targets.getNumCols() == numImages); } // Auto-generated calling code... // NOTE: The calling code is set up such that if checkImgBounds is true, then // imgsPerThread = 1. In principle it doesn't have to be this way, and you may want // to optimize for that case. if (scale == false) { if (checkImgBounds == false) { if (numFilterColors % 8 == 0) { if (numImages % 128 == 0) { if (numFiltersPerGroup % 128 == 0) { if (previous_limit) { if (images.getNumDataBytes() < TEXTURE_SIZE_MAX) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4_tex< 4, 32, 4, 16, 4, false, false>, cudaFuncCachePreferL1); filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4_tex< 4, 32, 4, 16, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getTextureObject(), filters.getTextureObject(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else { cudaFuncSetCacheConfig( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4< 4, 32, 4, 16, 4, false, false>, cudaFuncCachePreferL1); filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4< 4, 32, 4, 16, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else { cudaFuncSetCacheConfig( filterActs_YxX_sparse2< 4, 32, 4, 16, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 4, 16, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numFiltersPerGroup % 64 == 0) { if (previous_limit) { if (images.getNumDataBytes() < TEXTURE_SIZE_MAX) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4_tex< 4, 32, 4, 16, 4, false, false>, cudaFuncCachePreferL1); filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4_tex< 4, 32, 4, 16, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getTextureObject(), filters.getTextureObject(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else { cudaFuncSetCacheConfig( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4< 4, 32, 4, 16, 4, false, false>, cudaFuncCachePreferL1); filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4< 4, 32, 4, 16, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else { cudaFuncSetCacheConfig( filterActs_YxX_sparse2< 4, 32, 4, 16, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 4, 16, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 8, 8, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 4, 8, 8, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 4, 8, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 4, 4, 8, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numImages % 64 == 0) { if (numFiltersPerGroup % 128 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<8, 32, 2, 16, 8, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<8, 32, 2, 16, 8, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 16, 8, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 2, 16, 8, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 8, 8, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 2, 8, 8, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 4, 8, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 2, 4, 8, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numImages % 32 == 0) { if (numFiltersPerGroup % 128 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<8, 32, 1, 16, 8, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<8, 32, 1, 16, 8, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 8, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 16, 8, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 8, 8, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 8, 8, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 4, 8, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 4, 8, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors % 4 == 0) { if (numImages % 128 == 0) { if (numFiltersPerGroup % 128 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 16, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 4, 16, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 16, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 4, 16, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 8, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 4, 8, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 4, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 4, 4, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numImages % 64 == 0) { if (numFiltersPerGroup % 128 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 16, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 2, 16, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 16, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 2, 16, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 8, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 2, 8, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 4, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 2, 4, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numImages % 32 == 0) { if (numFiltersPerGroup % 128 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 16, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 16, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 8, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 8, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 4, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 4, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 3) { if (numImages % 128 == 0) { if (numFiltersPerGroup % 64 == 0) { if (previous_limit) { cudaFuncSetCacheConfig( filterActs_YxX_color_preload_ty_4_tx_32_i_4_f_16_px_4_cc_3_tex< 4, 32, 4, 16, 3, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color_preload_ty_4_tx_32_i_4_f_16_px_4_cc_3_tex< 4, 32, 4, 16, 3, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getTextureObject(), filters.getTextureObject(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else { cudaFuncSetCacheConfig( filterActs_YxX_color< 4, 32, 4, 16, 3, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 16, 3, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numFiltersPerGroup % 48 == 0) { if (previous_limit) { cudaFuncSetCacheConfig( filterActs_YxX_color_preload_ty_4_tx_32_i_4_f_12_px_4_cc_3_tex< 4, 32, 4, 12, 3, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color_preload_ty_4_tx_32_i_4_f_12_px_4_cc_3_tex< 4, 32, 4, 12, 3, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getTextureObject(), filters.getTextureObject(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else { cudaFuncSetCacheConfig( filterActs_YxX_color< 4, 32, 4, 12, 3, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 12, 3, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 8, 3, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 8, 3, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 4, 3, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 4, 3, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 64 == 0) { if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 16, 3, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 16, 3, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 12, 3, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 12, 3, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 8, 3, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 8, 3, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 4, 3, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 4, 3, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 32 == 0) { if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 3, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 16, 3, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 3, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 12, 3, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 3, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 8, 3, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 3, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 4, 3, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 2) { if (numImages % 128 == 0) { if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 16, 2, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 16, 2, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 12, 2, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 12, 2, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 8, 2, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 8, 2, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 4, 2, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 4, 2, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 64 == 0) { if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 16, 2, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 16, 2, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 12, 2, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 12, 2, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 8, 2, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 8, 2, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 4, 2, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 4, 2, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 32 == 0) { if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 2, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 16, 2, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 2, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 12, 2, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 2, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 8, 2, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 2, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 4, 2, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 1) { if (numImages % 128 == 0) { if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 16, 1, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 16, 1, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 12, 1, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 12, 1, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 8, 1, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 8, 1, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 4, 1, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 4, 1, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 64 == 0) { if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 16, 1, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 16, 1, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 12, 1, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 12, 1, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 8, 1, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 8, 1, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 4, 1, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 4, 1, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 32 == 0) { if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 1, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 16, 1, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 1, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 12, 1, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 1, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 8, 1, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 1, 4, false, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 4, 1, 4, false, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } } else if (checkImgBounds == true) { if (numFilterColors % 8 == 0) { if (numImages % 1 == 0) { if (numFiltersPerGroup % 128 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<8, 32, 1, 16, 8, false, true>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<8, 32, 1, 16, 8, false, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 8, false, true>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 16, 8, false, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 8, 8, false, true>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 8, 8, false, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 4, 8, false, true>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 4, 8, false, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors % 4 == 0) { if (numImages % 1 == 0) { if (numFiltersPerGroup % 128 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 4, false, true>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 16, 4, false, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 4, false, true>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 16, 4, false, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 8, 4, false, true>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 8, 4, false, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 4, 4, false, true>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 4, 4, false, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 3) { if (numImages % 1 == 0) { if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 3, 4, false, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 16, 3, 4, false, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 3, 4, false, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 12, 3, 4, false, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 3, 4, false, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 8, 3, 4, false, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 3, 4, false, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 4, 3, 4, false, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 2) { if (numImages % 1 == 0) { if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 2, 4, false, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 16, 2, 4, false, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 2, 4, false, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 12, 2, 4, false, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 2, 4, false, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 8, 2, 4, false, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 2, 4, false, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 4, 2, 4, false, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 1) { if (numImages % 1 == 0) { if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 1, 4, false, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 16, 1, 4, false, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 1, 4, false, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 12, 1, 4, false, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 1, 4, false, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 8, 1, 4, false, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 1, 4, false, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 4, 1, 4, false, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } } } else if (scale == true) { if (checkImgBounds == false) { if (numFilterColors % 8 == 0) { if (numImages % 128 == 0) { if (numFiltersPerGroup % 128 == 0) { if (previous_limit) { if (images.getNumDataBytes() < TEXTURE_SIZE_MAX) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4_tex< 4, 32, 4, 16, 4, true, false>, cudaFuncCachePreferL1); filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4_tex< 4, 32, 4, 16, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getTextureObject(), filters.getTextureObject(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else { cudaFuncSetCacheConfig( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4< 4, 32, 4, 16, 4, true, false>, cudaFuncCachePreferL1); filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4< 4, 32, 4, 16, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else { cudaFuncSetCacheConfig( filterActs_YxX_sparse2< 4, 32, 4, 16, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 4, 16, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numFiltersPerGroup % 64 == 0) { if (previous_limit) { if (images.getNumDataBytes() < TEXTURE_SIZE_MAX) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4_tex< 4, 32, 4, 16, 4, true, false>, cudaFuncCachePreferL1); filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4_tex< 4, 32, 4, 16, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getTextureObject(), filters.getTextureObject(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else { cudaFuncSetCacheConfig( filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4< 4, 32, 4, 16, 4, true, false>, cudaFuncCachePreferL1); filterActs_YxX_sparse2_preload_ty_4_tx_32_i_4_f_16_c_4< 4, 32, 4, 16, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else { cudaFuncSetCacheConfig( filterActs_YxX_sparse2< 4, 32, 4, 16, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 4, 16, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 8, 8, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 4, 8, 8, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 4, 8, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 4, 4, 8, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numImages % 64 == 0) { if (numFiltersPerGroup % 128 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<8, 32, 2, 16, 8, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<8, 32, 2, 16, 8, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 16, 8, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 2, 16, 8, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 8, 8, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 2, 8, 8, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 4, 8, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 2, 4, 8, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numImages % 32 == 0) { if (numFiltersPerGroup % 128 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<8, 32, 1, 16, 8, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<8, 32, 1, 16, 8, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 8, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 16, 8, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 8, 8, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 8, 8, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 4, 8, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 4, 8, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors % 4 == 0) { if (numImages % 128 == 0) { if (numFiltersPerGroup % 128 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 16, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 4, 16, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 16, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 4, 16, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 8, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 4, 8, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 4, 4, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 4, 4, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numImages % 64 == 0) { if (numFiltersPerGroup % 128 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 16, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 2, 16, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 16, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 2, 16, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 8, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 2, 8, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 2, 4, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 2, 4, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } else if (numImages % 32 == 0) { if (numFiltersPerGroup % 128 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 16, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 16, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 8, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 8, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 4, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 4, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 3) { if (numImages % 128 == 0) { if (numFiltersPerGroup % 64 == 0) { if (previous_limit) { cudaFuncSetCacheConfig( filterActs_YxX_color_preload_ty_4_tx_32_i_4_f_16_px_4_cc_3_tex< 4, 32, 4, 16, 3, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color_preload_ty_4_tx_32_i_4_f_16_px_4_cc_3_tex< 4, 32, 4, 16, 3, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getTextureObject(), filters.getTextureObject(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else { cudaFuncSetCacheConfig( filterActs_YxX_color< 4, 32, 4, 16, 3, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 16, 3, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numFiltersPerGroup % 48 == 0) { if (previous_limit) { cudaFuncSetCacheConfig( filterActs_YxX_color_preload_ty_4_tx_32_i_4_f_12_px_4_cc_3_tex< 4, 32, 4, 12, 3, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color_preload_ty_4_tx_32_i_4_f_12_px_4_cc_3_tex< 4, 32, 4, 12, 3, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getTextureObject(), filters.getTextureObject(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else { cudaFuncSetCacheConfig( filterActs_YxX_color< 4, 32, 4, 12, 3, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 12, 3, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 8, 3, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 8, 3, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 4, 3, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 4, 3, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 64 == 0) { if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 16, 3, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 16, 3, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 12, 3, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 12, 3, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 8, 3, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 8, 3, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 4, 3, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 4, 3, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 32 == 0) { if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 3, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 16, 3, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 3, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 12, 3, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 3, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 8, 3, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 3, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 4, 3, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 2) { if (numImages % 128 == 0) { if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 16, 2, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 16, 2, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 12, 2, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 12, 2, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 8, 2, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 8, 2, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 4, 2, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 4, 2, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 64 == 0) { if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 16, 2, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 16, 2, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 12, 2, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 12, 2, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 8, 2, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 8, 2, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 4, 2, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 4, 2, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 32 == 0) { if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 2, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 16, 2, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 2, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 12, 2, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 2, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 8, 2, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 2, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 4, 2, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 1) { if (numImages % 128 == 0) { if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 16, 1, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 16, 1, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 12, 1, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 12, 1, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 8, 1, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 8, 1, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 4, 4, 1, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 4, 4, 1, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 64 == 0) { if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 16, 1, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 16, 1, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 12, 1, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 12, 1, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 8, 1, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 8, 1, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 2, 4, 1, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 2, 4, 1, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } else if (numImages % 32 == 0) { if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 1, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 16, 1, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 1, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 12, 1, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 1, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 8, 1, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 1, 4, true, false>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 4, 1, 4, true, false> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } } else if (checkImgBounds == true) { if (numFilterColors % 8 == 0) { if (numImages % 1 == 0) { if (numFiltersPerGroup % 128 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<8, 32, 1, 16, 8, true, true>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<8, 32, 1, 16, 8, true, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 8, true, true>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 16, 8, true, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 8, 8, true, true>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 8, 8, true, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 4, 8, true, true>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 4, 8, true, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors % 4 == 0) { if (numImages % 1 == 0) { if (numFiltersPerGroup % 128 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 4, true, true>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 16, 4, true, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 16, 4, true, true>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 16, 4, true, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 8, 4, true, true>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 8, 4, true, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_sparse2<4, 32, 1, 4, 4, true, true>, cudaFuncCachePreferShared); filterActs_YxX_sparse2<4, 32, 1, 4, 4, true, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, numImgColors, numGroups, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 3) { if (numImages % 1 == 0) { if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 3, 4, true, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 16, 3, 4, true, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 3, 4, true, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 12, 3, 4, true, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 3, 4, true, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 8, 3, 4, true, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 3, 4, true, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 4, 3, 4, true, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 2) { if (numImages % 1 == 0) { if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 2, 4, true, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 16, 2, 4, true, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 2, 4, true, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 12, 2, 4, true, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 2, 4, true, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 8, 2, 4, true, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 2, 4, true, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 4, 2, 4, true, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } else if (numFilterColors == 1) { if (numImages % 1 == 0) { if (numFiltersPerGroup % 64 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 16, 1, 4, true, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 16, 1, 4, true, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 48 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 12, 1, 4, true, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 12, 1, 4, true, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 32 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 8, 1, 4, true, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 8, 1, 4, true, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } else if (numFiltersPerGroup % 1 == 0) { cudaFuncSetCacheConfig( filterActs_YxX_color<4, 32, 1, 4, 1, 4, true, true>, cudaFuncCachePreferShared); filterActs_YxX_color<4, 32, 1, 4, 1, 4, true, true> <<<blocks, threads, 0, stream>>>( images.getDevData(), filters.getDevData(), targets.getDevData(), numImages, numFilters, imgSizeY, imgSizeX, filterSize, paddingStart, moduleStride, numModulesY, numModulesX, imgStride, scaleTargets, scaleOutput, conv); } } } } } getLastCudaError("filterActs: kernel execution failed"); } void convFilterActs( cudaStream_t stream, NVMatrix& images, NVMatrix& filters, NVMatrix& targets, int imgSizeY, int numModulesY, int numModulesX, int paddingStart, int moduleStride, int numImgColors, int numGroups) { convFilterActs( stream, images, filters, targets, imgSizeY, numModulesY, numModulesX, paddingStart, moduleStride, numImgColors, numGroups, 0, 1); } void convFilterActs( cudaStream_t stream, NVMatrix& images, NVMatrix& filters, NVMatrix& targets, int imgSizeY, int numModulesY, int numModulesX, int paddingStart, int moduleStride, int numImgColors, int numGroups, float scaleTargets, float scaleOutput) { _filterActs( stream, images, filters, targets, imgSizeY, numModulesY, numModulesX, paddingStart, moduleStride, numImgColors, numGroups, scaleTargets, scaleOutput, true); } void localFilterActs( cudaStream_t stream, NVMatrix& images, NVMatrix& filters, NVMatrix& targets, int imgSizeY, int numModulesY, int numModulesX, int paddingStart, int moduleStride, int numImgColors, int numGroups) { localFilterActs( stream, images, filters, targets, imgSizeY, numModulesY, numModulesX, paddingStart, moduleStride, numImgColors, numGroups, 0, 1); } void localFilterActs( cudaStream_t stream, NVMatrix& images, NVMatrix& filters, NVMatrix& targets, int imgSizeY, int numModulesY, int numModulesX, int paddingStart, int moduleStride, int numImgColors, int numGroups, float scaleTargets, float scaleOutput) { _filterActs( stream, images, filters, targets, imgSizeY, numModulesY, numModulesX, paddingStart, moduleStride, numImgColors, numGroups, scaleTargets, scaleOutput, false); } } // namespace cuda } // namespace megdnn
8a520995e0f91e2463456a4b74173eb75ba68ed7.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" #include "voxelize.cuh" // CUDA Global Memory variables // Debug counters for some sanity checks #ifdef _DEBUG __device__ size_t debug_d_n_voxels_marked = 0; __device__ size_t debug_d_n_triangles = 0; __device__ size_t debug_d_n_voxels_tested = 0; #endif // Possible optimization: buffer bitsets (for now: Disabled because too much overhead) //struct bufferedBitSetter{ // unsigned int* voxel_table; // size_t current_int_location; // unsigned int current_mask; // // __device__ __inline__ bufferedBitSetter(unsigned int* voxel_table, size_t index) : // voxel_table(voxel_table), current_mask(0) { // current_int_location = int(index / 32.0f); // } // // __device__ __inline__ void setBit(size_t index){ // size_t new_int_location = int(index / 32.0f); // if (current_int_location != new_int_location){ // flush(); // current_int_location = new_int_location; // } // unsigned int bit_pos = 31 - (unsigned int)(int(index) % 32); // current_mask = current_mask | (1 << bit_pos); // } // // __device__ __inline__ void flush(){ // if (current_mask != 0){ // atomicOr(&(voxel_table[current_int_location]), current_mask); // } // } //}; // Possible optimization: check bit before you set it - don't need to do atomic operation if it's already set to 1 // For now: overhead, so it seems //__device__ __inline__ bool checkBit(unsigned int* voxel_table, size_t index){ // size_t int_location = index / size_t(32); // unsigned int bit_pos = size_t(31) - (index % size_t(32)); // we count bit positions RtL, but array indices LtR // return ((voxel_table[int_location]) & (1 << bit_pos)); //} // Set a bit in the giant voxel table. This involves doing an atomic operation on a 32-bit word in memory. // Blocking other threads writing to it for a very short time __device__ __inline__ void setBit(unsigned int* voxel_table, size_t index){ size_t int_location = index / size_t(32); unsigned int bit_pos = size_t(31) - (index % size_t(32)); // we count bit positions RtL, but array indices LtR unsigned int mask = 1 << bit_pos; atomicOr(&(voxel_table[int_location]), mask); } // Main triangle voxelization method __global__ void voxelize_triangle(voxinfo info, float* triangle_data, unsigned int* voxel_table, bool morton_order){ size_t thread_id = threadIdx.x + blockIdx.x * blockDim.x; size_t stride = blockDim.x * gridDim.x; // Common variables used in the voxelization process glm::vec3 delta_p(info.unit.x, info.unit.y, info.unit.z); glm::vec3 grid_max(info.gridsize.x - 1, info.gridsize.y - 1, info.gridsize.z - 1); // grid max (grid runs from 0 to gridsize-1) while (thread_id < info.n_triangles){ // every thread works on specific triangles in its stride size_t t = thread_id * 9; // triangle contains 9 vertices // COMPUTE COMMON TRIANGLE PROPERTIES // Move vertices to origin using bbox glm::vec3 v0 = glm::vec3(triangle_data[t], triangle_data[t + 1], triangle_data[t + 2]) - info.bbox.min; glm::vec3 v1 = glm::vec3(triangle_data[t + 3], triangle_data[t + 4], triangle_data[t + 5]) - info.bbox.min; glm::vec3 v2 = glm::vec3(triangle_data[t + 6], triangle_data[t + 7], triangle_data[t + 8]) - info.bbox.min; // Edge vectors glm::vec3 e0 = v1 - v0; glm::vec3 e1 = v2 - v1; glm::vec3 e2 = v0 - v2; // Normal vector pointing up from the triangle glm::vec3 n = glm::normalize(glm::cross(e0, e1)); // COMPUTE TRIANGLE BBOX IN GRID // Triangle bounding box in world coordinates is min(v0,v1,v2) and max(v0,v1,v2) AABox<glm::vec3> t_bbox_world(glm::min(v0, glm::min(v1, v2)), glm::max(v0, glm::max(v1, v2))); // Triangle bounding box in voxel grid coordinates is the world bounding box divided by the grid unit vector AABox<glm::ivec3> t_bbox_grid; t_bbox_grid.min = glm::clamp(t_bbox_world.min / info.unit, glm::vec3(0.0f, 0.0f, 0.0f), grid_max); t_bbox_grid.max = glm::clamp(t_bbox_world.max / info.unit, glm::vec3(0.0f, 0.0f, 0.0f), grid_max); // PREPARE PLANE TEST PROPERTIES glm::vec3 c(0.0f, 0.0f, 0.0f); if (n.x > 0.0f) { c.x = info.unit.x; } if (n.y > 0.0f) { c.y = info.unit.y; } if (n.z > 0.0f) { c.z = info.unit.z; } float d1 = glm::dot(n, (c - v0)); float d2 = glm::dot(n, ((delta_p - c) - v0)); // PREPARE PROJECTION TEST PROPERTIES // XY plane glm::vec2 n_xy_e0(-1.0f*e0.y, e0.x); glm::vec2 n_xy_e1(-1.0f*e1.y, e1.x); glm::vec2 n_xy_e2(-1.0f*e2.y, e2.x); if (n.z < 0.0f) { n_xy_e0 = -n_xy_e0; n_xy_e1 = -n_xy_e1; n_xy_e2 = -n_xy_e2; } float d_xy_e0 = (-1.0f * glm::dot(n_xy_e0, glm::vec2(v0.x, v0.y))) + glm::max(0.0f, info.unit.x*n_xy_e0[0]) + glm::max(0.0f, info.unit.y*n_xy_e0[1]); float d_xy_e1 = (-1.0f * glm::dot(n_xy_e1, glm::vec2(v1.x, v1.y))) + glm::max(0.0f, info.unit.x*n_xy_e1[0]) + glm::max(0.0f, info.unit.y*n_xy_e1[1]); float d_xy_e2 = (-1.0f * glm::dot(n_xy_e2, glm::vec2(v2.x, v2.y))) + glm::max(0.0f, info.unit.x*n_xy_e2[0]) + glm::max(0.0f, info.unit.y*n_xy_e2[1]); // YZ plane glm::vec2 n_yz_e0(-1.0f*e0.z, e0.y); glm::vec2 n_yz_e1(-1.0f*e1.z, e1.y); glm::vec2 n_yz_e2(-1.0f*e2.z, e2.y); if (n.x < 0.0f) { n_yz_e0 = -n_yz_e0; n_yz_e1 = -n_yz_e1; n_yz_e2 = -n_yz_e2; } float d_yz_e0 = (-1.0f * glm::dot(n_yz_e0, glm::vec2(v0.y, v0.z))) + glm::max(0.0f, info.unit.y*n_yz_e0[0]) + glm::max(0.0f, info.unit.z*n_yz_e0[1]); float d_yz_e1 = (-1.0f * glm::dot(n_yz_e1, glm::vec2(v1.y, v1.z))) + glm::max(0.0f, info.unit.y*n_yz_e1[0]) + glm::max(0.0f, info.unit.z*n_yz_e1[1]); float d_yz_e2 = (-1.0f * glm::dot(n_yz_e2, glm::vec2(v2.y, v2.z))) + glm::max(0.0f, info.unit.y*n_yz_e2[0]) + glm::max(0.0f, info.unit.z*n_yz_e2[1]); // ZX plane glm::vec2 n_zx_e0(-1.0f*e0.x, e0.z); glm::vec2 n_zx_e1(-1.0f*e1.x, e1.z); glm::vec2 n_zx_e2(-1.0f*e2.x, e2.z); if (n.y < 0.0f) { n_zx_e0 = -n_zx_e0; n_zx_e1 = -n_zx_e1; n_zx_e2 = -n_zx_e2; } float d_xz_e0 = (-1.0f * glm::dot(n_zx_e0, glm::vec2(v0.z, v0.x))) + glm::max(0.0f, info.unit.x*n_zx_e0[0]) + glm::max(0.0f, info.unit.z*n_zx_e0[1]); float d_xz_e1 = (-1.0f * glm::dot(n_zx_e1, glm::vec2(v1.z, v1.x))) + glm::max(0.0f, info.unit.x*n_zx_e1[0]) + glm::max(0.0f, info.unit.z*n_zx_e1[1]); float d_xz_e2 = (-1.0f * glm::dot(n_zx_e2, glm::vec2(v2.z, v2.x))) + glm::max(0.0f, info.unit.x*n_zx_e2[0]) + glm::max(0.0f, info.unit.z*n_zx_e2[1]); // test possible grid boxes for overlap for (int z = t_bbox_grid.min.z; z <= t_bbox_grid.max.z; z++){ for (int y = t_bbox_grid.min.y; y <= t_bbox_grid.max.y; y++){ for (int x = t_bbox_grid.min.x; x <= t_bbox_grid.max.x; x++){ // size_t location = x + (y*info.gridsize) + (z*info.gridsize*info.gridsize); // if (checkBit(voxel_table, location)){ continue; } #ifdef _DEBUG atomicAdd(&debug_d_n_voxels_tested, 1); #endif // TRIANGLE PLANE THROUGH BOX TEST glm::vec3 p(x*info.unit.x, y*info.unit.y, z*info.unit.z); float nDOTp = glm::dot(n, p); if ((nDOTp + d1) * (nDOTp + d2) > 0.0f) { continue; } // PROJECTION TESTS // XY glm::vec2 p_xy(p.x, p.y); if ((glm::dot(n_xy_e0, p_xy) + d_xy_e0) < 0.0f){ continue; } if ((glm::dot(n_xy_e1, p_xy) + d_xy_e1) < 0.0f){ continue; } if ((glm::dot(n_xy_e2, p_xy) + d_xy_e2) < 0.0f){ continue; } // YZ glm::vec2 p_yz(p.y, p.z); if ((glm::dot(n_yz_e0, p_yz) + d_yz_e0) < 0.0f){ continue; } if ((glm::dot(n_yz_e1, p_yz) + d_yz_e1) < 0.0f){ continue; } if ((glm::dot(n_yz_e2, p_yz) + d_yz_e2) < 0.0f){ continue; } // XZ glm::vec2 p_zx(p.z, p.x); if ((glm::dot(n_zx_e0, p_zx) + d_xz_e0) < 0.0f){ continue; } if ((glm::dot(n_zx_e1, p_zx) + d_xz_e1) < 0.0f){ continue; } if ((glm::dot(n_zx_e2, p_zx) + d_xz_e2) < 0.0f){ continue; } #ifdef _DEBUG atomicAdd(&debug_d_n_voxels_marked, 1); #endif if (morton_order){ size_t location = mortonEncode_LUT(x, y, z); setBit(voxel_table, location); } else { size_t location = static_cast<size_t>(x) + (static_cast<size_t>(y)* static_cast<size_t>(info.gridsize.y)) + (static_cast<size_t>(z)* static_cast<size_t>(info.gridsize.y)* static_cast<size_t>(info.gridsize.z)); setBit(voxel_table, location); } continue; } } } #ifdef _DEBUG atomicAdd(&debug_d_n_triangles, 1); #endif thread_id += stride; } } void voxelize(const voxinfo& v, float* triangle_data, unsigned int* vtable, bool useThrustPath, bool morton_code) { float elapsedTime; // These are only used when we're not using UNIFIED memory unsigned int* dev_vtable; // DEVICE pointer to voxel_data size_t vtable_size; // vtable size // Create timers, set start time hipEvent_t start_vox, stop_vox; checkCudaErrors(hipEventCreate(&start_vox)); checkCudaErrors(hipEventCreate(&stop_vox)); // Copy morton LUT if we're encoding to morton if (morton_code){ checkCudaErrors(hipMemcpyToSymbol(morton256_x, host_morton256_x, 256 * sizeof(uint32_t))); checkCudaErrors(hipMemcpyToSymbol(morton256_y, host_morton256_y, 256 * sizeof(uint32_t))); checkCudaErrors(hipMemcpyToSymbol(morton256_z, host_morton256_z, 256 * sizeof(uint32_t))); } // Estimate best block and grid size using CUDA Occupancy Calculator int blockSize; // The launch configurator returned block size int minGridSize; // The minimum grid size needed to achieve the maximum occupancy for a full device launch int gridSize; // The actual grid size needed, based on input size hipOccupancyMaxPotentialBlockSize(&minGridSize, &blockSize, voxelize_triangle, 0, 0); // Round up according to array size gridSize = (v.n_triangles + blockSize - 1) / blockSize; if (useThrustPath) { // We're not using UNIFIED memory vtable_size = ((size_t)v.gridsize.x * v.gridsize.y * v.gridsize.z) / (size_t) 8.0; fprintf(stdout, "[Voxel Grid] Allocating %llu kB of DEVICE memory for Voxel Grid\n", size_t(vtable_size / 1024.0f)); checkCudaErrors(hipMalloc(&dev_vtable, vtable_size)); checkCudaErrors(hipMemset(dev_vtable, 0, vtable_size)); // Start voxelization checkCudaErrors(hipEventRecord(start_vox, 0)); voxelize_triangle << <gridSize, blockSize >> > (v, triangle_data, dev_vtable, morton_code); } else { // UNIFIED MEMORY checkCudaErrors(hipEventRecord(start_vox, 0)); voxelize_triangle << <gridSize, blockSize >> > (v, triangle_data, vtable, morton_code); } hipDeviceSynchronize(); checkCudaErrors(hipEventRecord(stop_vox, 0)); checkCudaErrors(hipEventSynchronize(stop_vox)); checkCudaErrors(hipEventElapsedTime(&elapsedTime, start_vox, stop_vox)); printf("[Perf] Voxelization GPU time: %.1f ms\n", elapsedTime); // If we're not using UNIFIED memory, copy the voxel table back and free all if (useThrustPath){ fprintf(stdout, "[Voxel Grid] Copying %llu kB to page-locked HOST memory\n", size_t(vtable_size / 1024.0f)); checkCudaErrors(hipMemcpy((void*)vtable, dev_vtable, vtable_size, hipMemcpyDefault)); fprintf(stdout, "[Voxel Grid] Freeing %llu kB of DEVICE memory\n", size_t(vtable_size / 1024.0f)); checkCudaErrors(hipFree(dev_vtable)); } // SANITY CHECKS #ifdef _DEBUG size_t debug_n_triangles, debug_n_voxels_marked, debug_n_voxels_tested; checkCudaErrors(hipMemcpyFromSymbol((void*)&(debug_n_triangles),debug_d_n_triangles, sizeof(debug_d_n_triangles), 0, hipMemcpyDeviceToHost)); checkCudaErrors(hipMemcpyFromSymbol((void*)&(debug_n_voxels_marked), debug_d_n_voxels_marked, sizeof(debug_d_n_voxels_marked), 0, hipMemcpyDeviceToHost)); checkCudaErrors(hipMemcpyFromSymbol((void*) & (debug_n_voxels_tested), debug_d_n_voxels_tested, sizeof(debug_d_n_voxels_tested), 0, hipMemcpyDeviceToHost)); printf("[Debug] Processed %llu triangles on the GPU \n", debug_n_triangles); printf("[Debug] Tested %llu voxels for overlap on GPU \n", debug_n_voxels_tested); printf("[Debug] Marked %llu voxels as filled (includes duplicates!) \n", debug_n_voxels_marked); #endif // Destroy timers checkCudaErrors(hipEventDestroy(start_vox)); checkCudaErrors(hipEventDestroy(stop_vox)); }
8a520995e0f91e2463456a4b74173eb75ba68ed7.cu
#include "voxelize.cuh" // CUDA Global Memory variables // Debug counters for some sanity checks #ifdef _DEBUG __device__ size_t debug_d_n_voxels_marked = 0; __device__ size_t debug_d_n_triangles = 0; __device__ size_t debug_d_n_voxels_tested = 0; #endif // Possible optimization: buffer bitsets (for now: Disabled because too much overhead) //struct bufferedBitSetter{ // unsigned int* voxel_table; // size_t current_int_location; // unsigned int current_mask; // // __device__ __inline__ bufferedBitSetter(unsigned int* voxel_table, size_t index) : // voxel_table(voxel_table), current_mask(0) { // current_int_location = int(index / 32.0f); // } // // __device__ __inline__ void setBit(size_t index){ // size_t new_int_location = int(index / 32.0f); // if (current_int_location != new_int_location){ // flush(); // current_int_location = new_int_location; // } // unsigned int bit_pos = 31 - (unsigned int)(int(index) % 32); // current_mask = current_mask | (1 << bit_pos); // } // // __device__ __inline__ void flush(){ // if (current_mask != 0){ // atomicOr(&(voxel_table[current_int_location]), current_mask); // } // } //}; // Possible optimization: check bit before you set it - don't need to do atomic operation if it's already set to 1 // For now: overhead, so it seems //__device__ __inline__ bool checkBit(unsigned int* voxel_table, size_t index){ // size_t int_location = index / size_t(32); // unsigned int bit_pos = size_t(31) - (index % size_t(32)); // we count bit positions RtL, but array indices LtR // return ((voxel_table[int_location]) & (1 << bit_pos)); //} // Set a bit in the giant voxel table. This involves doing an atomic operation on a 32-bit word in memory. // Blocking other threads writing to it for a very short time __device__ __inline__ void setBit(unsigned int* voxel_table, size_t index){ size_t int_location = index / size_t(32); unsigned int bit_pos = size_t(31) - (index % size_t(32)); // we count bit positions RtL, but array indices LtR unsigned int mask = 1 << bit_pos; atomicOr(&(voxel_table[int_location]), mask); } // Main triangle voxelization method __global__ void voxelize_triangle(voxinfo info, float* triangle_data, unsigned int* voxel_table, bool morton_order){ size_t thread_id = threadIdx.x + blockIdx.x * blockDim.x; size_t stride = blockDim.x * gridDim.x; // Common variables used in the voxelization process glm::vec3 delta_p(info.unit.x, info.unit.y, info.unit.z); glm::vec3 grid_max(info.gridsize.x - 1, info.gridsize.y - 1, info.gridsize.z - 1); // grid max (grid runs from 0 to gridsize-1) while (thread_id < info.n_triangles){ // every thread works on specific triangles in its stride size_t t = thread_id * 9; // triangle contains 9 vertices // COMPUTE COMMON TRIANGLE PROPERTIES // Move vertices to origin using bbox glm::vec3 v0 = glm::vec3(triangle_data[t], triangle_data[t + 1], triangle_data[t + 2]) - info.bbox.min; glm::vec3 v1 = glm::vec3(triangle_data[t + 3], triangle_data[t + 4], triangle_data[t + 5]) - info.bbox.min; glm::vec3 v2 = glm::vec3(triangle_data[t + 6], triangle_data[t + 7], triangle_data[t + 8]) - info.bbox.min; // Edge vectors glm::vec3 e0 = v1 - v0; glm::vec3 e1 = v2 - v1; glm::vec3 e2 = v0 - v2; // Normal vector pointing up from the triangle glm::vec3 n = glm::normalize(glm::cross(e0, e1)); // COMPUTE TRIANGLE BBOX IN GRID // Triangle bounding box in world coordinates is min(v0,v1,v2) and max(v0,v1,v2) AABox<glm::vec3> t_bbox_world(glm::min(v0, glm::min(v1, v2)), glm::max(v0, glm::max(v1, v2))); // Triangle bounding box in voxel grid coordinates is the world bounding box divided by the grid unit vector AABox<glm::ivec3> t_bbox_grid; t_bbox_grid.min = glm::clamp(t_bbox_world.min / info.unit, glm::vec3(0.0f, 0.0f, 0.0f), grid_max); t_bbox_grid.max = glm::clamp(t_bbox_world.max / info.unit, glm::vec3(0.0f, 0.0f, 0.0f), grid_max); // PREPARE PLANE TEST PROPERTIES glm::vec3 c(0.0f, 0.0f, 0.0f); if (n.x > 0.0f) { c.x = info.unit.x; } if (n.y > 0.0f) { c.y = info.unit.y; } if (n.z > 0.0f) { c.z = info.unit.z; } float d1 = glm::dot(n, (c - v0)); float d2 = glm::dot(n, ((delta_p - c) - v0)); // PREPARE PROJECTION TEST PROPERTIES // XY plane glm::vec2 n_xy_e0(-1.0f*e0.y, e0.x); glm::vec2 n_xy_e1(-1.0f*e1.y, e1.x); glm::vec2 n_xy_e2(-1.0f*e2.y, e2.x); if (n.z < 0.0f) { n_xy_e0 = -n_xy_e0; n_xy_e1 = -n_xy_e1; n_xy_e2 = -n_xy_e2; } float d_xy_e0 = (-1.0f * glm::dot(n_xy_e0, glm::vec2(v0.x, v0.y))) + glm::max(0.0f, info.unit.x*n_xy_e0[0]) + glm::max(0.0f, info.unit.y*n_xy_e0[1]); float d_xy_e1 = (-1.0f * glm::dot(n_xy_e1, glm::vec2(v1.x, v1.y))) + glm::max(0.0f, info.unit.x*n_xy_e1[0]) + glm::max(0.0f, info.unit.y*n_xy_e1[1]); float d_xy_e2 = (-1.0f * glm::dot(n_xy_e2, glm::vec2(v2.x, v2.y))) + glm::max(0.0f, info.unit.x*n_xy_e2[0]) + glm::max(0.0f, info.unit.y*n_xy_e2[1]); // YZ plane glm::vec2 n_yz_e0(-1.0f*e0.z, e0.y); glm::vec2 n_yz_e1(-1.0f*e1.z, e1.y); glm::vec2 n_yz_e2(-1.0f*e2.z, e2.y); if (n.x < 0.0f) { n_yz_e0 = -n_yz_e0; n_yz_e1 = -n_yz_e1; n_yz_e2 = -n_yz_e2; } float d_yz_e0 = (-1.0f * glm::dot(n_yz_e0, glm::vec2(v0.y, v0.z))) + glm::max(0.0f, info.unit.y*n_yz_e0[0]) + glm::max(0.0f, info.unit.z*n_yz_e0[1]); float d_yz_e1 = (-1.0f * glm::dot(n_yz_e1, glm::vec2(v1.y, v1.z))) + glm::max(0.0f, info.unit.y*n_yz_e1[0]) + glm::max(0.0f, info.unit.z*n_yz_e1[1]); float d_yz_e2 = (-1.0f * glm::dot(n_yz_e2, glm::vec2(v2.y, v2.z))) + glm::max(0.0f, info.unit.y*n_yz_e2[0]) + glm::max(0.0f, info.unit.z*n_yz_e2[1]); // ZX plane glm::vec2 n_zx_e0(-1.0f*e0.x, e0.z); glm::vec2 n_zx_e1(-1.0f*e1.x, e1.z); glm::vec2 n_zx_e2(-1.0f*e2.x, e2.z); if (n.y < 0.0f) { n_zx_e0 = -n_zx_e0; n_zx_e1 = -n_zx_e1; n_zx_e2 = -n_zx_e2; } float d_xz_e0 = (-1.0f * glm::dot(n_zx_e0, glm::vec2(v0.z, v0.x))) + glm::max(0.0f, info.unit.x*n_zx_e0[0]) + glm::max(0.0f, info.unit.z*n_zx_e0[1]); float d_xz_e1 = (-1.0f * glm::dot(n_zx_e1, glm::vec2(v1.z, v1.x))) + glm::max(0.0f, info.unit.x*n_zx_e1[0]) + glm::max(0.0f, info.unit.z*n_zx_e1[1]); float d_xz_e2 = (-1.0f * glm::dot(n_zx_e2, glm::vec2(v2.z, v2.x))) + glm::max(0.0f, info.unit.x*n_zx_e2[0]) + glm::max(0.0f, info.unit.z*n_zx_e2[1]); // test possible grid boxes for overlap for (int z = t_bbox_grid.min.z; z <= t_bbox_grid.max.z; z++){ for (int y = t_bbox_grid.min.y; y <= t_bbox_grid.max.y; y++){ for (int x = t_bbox_grid.min.x; x <= t_bbox_grid.max.x; x++){ // size_t location = x + (y*info.gridsize) + (z*info.gridsize*info.gridsize); // if (checkBit(voxel_table, location)){ continue; } #ifdef _DEBUG atomicAdd(&debug_d_n_voxels_tested, 1); #endif // TRIANGLE PLANE THROUGH BOX TEST glm::vec3 p(x*info.unit.x, y*info.unit.y, z*info.unit.z); float nDOTp = glm::dot(n, p); if ((nDOTp + d1) * (nDOTp + d2) > 0.0f) { continue; } // PROJECTION TESTS // XY glm::vec2 p_xy(p.x, p.y); if ((glm::dot(n_xy_e0, p_xy) + d_xy_e0) < 0.0f){ continue; } if ((glm::dot(n_xy_e1, p_xy) + d_xy_e1) < 0.0f){ continue; } if ((glm::dot(n_xy_e2, p_xy) + d_xy_e2) < 0.0f){ continue; } // YZ glm::vec2 p_yz(p.y, p.z); if ((glm::dot(n_yz_e0, p_yz) + d_yz_e0) < 0.0f){ continue; } if ((glm::dot(n_yz_e1, p_yz) + d_yz_e1) < 0.0f){ continue; } if ((glm::dot(n_yz_e2, p_yz) + d_yz_e2) < 0.0f){ continue; } // XZ glm::vec2 p_zx(p.z, p.x); if ((glm::dot(n_zx_e0, p_zx) + d_xz_e0) < 0.0f){ continue; } if ((glm::dot(n_zx_e1, p_zx) + d_xz_e1) < 0.0f){ continue; } if ((glm::dot(n_zx_e2, p_zx) + d_xz_e2) < 0.0f){ continue; } #ifdef _DEBUG atomicAdd(&debug_d_n_voxels_marked, 1); #endif if (morton_order){ size_t location = mortonEncode_LUT(x, y, z); setBit(voxel_table, location); } else { size_t location = static_cast<size_t>(x) + (static_cast<size_t>(y)* static_cast<size_t>(info.gridsize.y)) + (static_cast<size_t>(z)* static_cast<size_t>(info.gridsize.y)* static_cast<size_t>(info.gridsize.z)); setBit(voxel_table, location); } continue; } } } #ifdef _DEBUG atomicAdd(&debug_d_n_triangles, 1); #endif thread_id += stride; } } void voxelize(const voxinfo& v, float* triangle_data, unsigned int* vtable, bool useThrustPath, bool morton_code) { float elapsedTime; // These are only used when we're not using UNIFIED memory unsigned int* dev_vtable; // DEVICE pointer to voxel_data size_t vtable_size; // vtable size // Create timers, set start time cudaEvent_t start_vox, stop_vox; checkCudaErrors(cudaEventCreate(&start_vox)); checkCudaErrors(cudaEventCreate(&stop_vox)); // Copy morton LUT if we're encoding to morton if (morton_code){ checkCudaErrors(cudaMemcpyToSymbol(morton256_x, host_morton256_x, 256 * sizeof(uint32_t))); checkCudaErrors(cudaMemcpyToSymbol(morton256_y, host_morton256_y, 256 * sizeof(uint32_t))); checkCudaErrors(cudaMemcpyToSymbol(morton256_z, host_morton256_z, 256 * sizeof(uint32_t))); } // Estimate best block and grid size using CUDA Occupancy Calculator int blockSize; // The launch configurator returned block size int minGridSize; // The minimum grid size needed to achieve the maximum occupancy for a full device launch int gridSize; // The actual grid size needed, based on input size cudaOccupancyMaxPotentialBlockSize(&minGridSize, &blockSize, voxelize_triangle, 0, 0); // Round up according to array size gridSize = (v.n_triangles + blockSize - 1) / blockSize; if (useThrustPath) { // We're not using UNIFIED memory vtable_size = ((size_t)v.gridsize.x * v.gridsize.y * v.gridsize.z) / (size_t) 8.0; fprintf(stdout, "[Voxel Grid] Allocating %llu kB of DEVICE memory for Voxel Grid\n", size_t(vtable_size / 1024.0f)); checkCudaErrors(cudaMalloc(&dev_vtable, vtable_size)); checkCudaErrors(cudaMemset(dev_vtable, 0, vtable_size)); // Start voxelization checkCudaErrors(cudaEventRecord(start_vox, 0)); voxelize_triangle << <gridSize, blockSize >> > (v, triangle_data, dev_vtable, morton_code); } else { // UNIFIED MEMORY checkCudaErrors(cudaEventRecord(start_vox, 0)); voxelize_triangle << <gridSize, blockSize >> > (v, triangle_data, vtable, morton_code); } cudaDeviceSynchronize(); checkCudaErrors(cudaEventRecord(stop_vox, 0)); checkCudaErrors(cudaEventSynchronize(stop_vox)); checkCudaErrors(cudaEventElapsedTime(&elapsedTime, start_vox, stop_vox)); printf("[Perf] Voxelization GPU time: %.1f ms\n", elapsedTime); // If we're not using UNIFIED memory, copy the voxel table back and free all if (useThrustPath){ fprintf(stdout, "[Voxel Grid] Copying %llu kB to page-locked HOST memory\n", size_t(vtable_size / 1024.0f)); checkCudaErrors(cudaMemcpy((void*)vtable, dev_vtable, vtable_size, cudaMemcpyDefault)); fprintf(stdout, "[Voxel Grid] Freeing %llu kB of DEVICE memory\n", size_t(vtable_size / 1024.0f)); checkCudaErrors(cudaFree(dev_vtable)); } // SANITY CHECKS #ifdef _DEBUG size_t debug_n_triangles, debug_n_voxels_marked, debug_n_voxels_tested; checkCudaErrors(cudaMemcpyFromSymbol((void*)&(debug_n_triangles),debug_d_n_triangles, sizeof(debug_d_n_triangles), 0, cudaMemcpyDeviceToHost)); checkCudaErrors(cudaMemcpyFromSymbol((void*)&(debug_n_voxels_marked), debug_d_n_voxels_marked, sizeof(debug_d_n_voxels_marked), 0, cudaMemcpyDeviceToHost)); checkCudaErrors(cudaMemcpyFromSymbol((void*) & (debug_n_voxels_tested), debug_d_n_voxels_tested, sizeof(debug_d_n_voxels_tested), 0, cudaMemcpyDeviceToHost)); printf("[Debug] Processed %llu triangles on the GPU \n", debug_n_triangles); printf("[Debug] Tested %llu voxels for overlap on GPU \n", debug_n_voxels_tested); printf("[Debug] Marked %llu voxels as filled (includes duplicates!) \n", debug_n_voxels_marked); #endif // Destroy timers checkCudaErrors(cudaEventDestroy(start_vox)); checkCudaErrors(cudaEventDestroy(stop_vox)); }
37ca52a6525974f8e5f376391aa4202d04acd555.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" /* * Written by Xueyan Zou @TuSimple Algorithm Intern */ #include "./spatial-propagation-inl.h" #include <assert.h> #include <mshadow/tensor.h> #include <mshadow/cuda/reduce.cuh> #include <algorithm> #include <vector> namespace mshadow { namespace cuda { __device__ void get_gate_idx(int h1, int w1, int h2, int w2, int* out, bool horizontal, bool reverse) { if(horizontal && ! reverse) // left -> right { if(w1>w2) { out[0]=h1; out[1]=w1; } else { out[0]=h2; out[1]=w2; } } if(horizontal && reverse) // right -> left { if(w1<w2) { out[0]=h1; out[1]=w1; } else { out[0]=h2; out[1]=w2; } } if(!horizontal && !reverse) // top -> bottom { if(h1>h2) { out[0]=h1; out[1]=w1; } else { out[0]=h2; out[1]=w2; } } if(!horizontal && reverse) // bottom -> top { if(h1<h2) { out[0]=h1; out[1]=w1; } else { out[0]=h2; out[1]=w2; } } } template <typename Dtype> __device__ void set_gate(Dtype* data, int num, int channels, int height, int width, int n, int c, int h1, int w1, int h2, int w2, Dtype v, bool horizontal, bool reverse) { if(h1<0 || h1 >=height) //redundant return ; //redundant if(w1<0 || w1 >= width) //redundant return ; //redundant if(h2<0 || h2 >=height) //redundant return ; //redundant if(w2<0 || w2 >= width) //redundant return ; //redundant int idx[2]; get_gate_idx(h1, w1, h2, w2, idx, horizontal, reverse); int h = idx[0]; int w = idx[1]; data[n*channels*height*width + c*height*width + h*width + w] = v; } template <typename Dtype> //this function is modified by xueyan __device__ Dtype get_gate(Dtype * data, int num, int channels, int height, int width, int n, int c, int h1, int w1, int h2, int w2, bool horizontal, bool reverse){ //handle index out of range if(h1<0 || h1 >=height) //redundant return 0; //redundant if(w1<0 || w1 >= width) //redundant return 0; //redundant if(h2<0 || h2 >=height) return 0; if(w2<0 || w2 >= width) return 0; int idx[2]; get_gate_idx(h1, w1, h2, w2, idx, horizontal, reverse); int h = idx[0]; int w = idx[1]; return data[n*channels*height*width + c*height*width + h*width + w]; } template <typename Dtype> __device__ void set_data(Dtype * data, int num, int channels,int height, int width,int n,int c,int h,int w, Dtype v) { //modify by xueyan, assert error. if(h<0 || h >=height) assert(0); if(w<0 || w >= width) assert(0); data[n*channels*height*width + c*height*width + h*width + w] = v; } template <typename Dtype> __device__ Dtype get_data(Dtype *data, int num, int channels, int height, int width, int n, int c, int h, int w){ //handle index out of range if(h<0 || h >=height) return 0; if(w<0 || w >= width) return 0; //spatial-propagation-inl.h:82 -> default configuration of dim is (batch, channel, height, width) return data[n*channels*height*width + c*height*width + h*width + w]; } /*LEFT->RIGHT*/ /*h(t) = (1-sum(g_i(t))) * x_i(t) + sum(g_i(t) * h_i(t-1))*/ template <typename Dtype> __global__ void forward_one_col_left_right(const int count, int T, int num, int channels, int height, int width, const Dtype* X, const Dtype* G1, const Dtype* G2, const Dtype* G3, Dtype* H, bool horizontal, bool reverse){ //count -> total number of threads; T -> current_row/current_column; num -> total num batch for(int index = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; index < count; index += blockDim.x * gridDim.x * gridDim.y){ //CUDA kernel loop, index trace the current thread int hc_count = height * channels; //in order to calculate batch size int n,c,h,w; //w->current_col; n->current_batch; c->current_channel; int temp = index; w = T; n = temp / hc_count; temp = temp % hc_count; c = temp / height; temp = temp % height; h = temp; //locate the pixel as (n,c,h,w); Dtype x_data = get_data(X,num,channels,height,width,n,c,h,w); //x //modify logic by xueyan Dtype g_data_1 = get_gate(G1,num,channels,height,width,n,c,h,w,h-1,w-1,horizontal,reverse); //g_1(t) Dtype h_minus1_data_1 = get_data(H,num,channels,height,width,n,c,h-1,w-1); //h_1(t-1) Dtype h1_minus1 = g_data_1 * h_minus1_data_1; //g_1(t)*h_1(t-1) Dtype g_data_2 = get_gate(G2,num,channels,height,width,n,c,h,w,h,w-1,horizontal,reverse); //g_2(t) Dtype h_minus1_data_2 = get_data(H,num,channels,height,width,n,c,h,w-1); //h_2(t-1) Dtype h2_minus1 = g_data_2 * h_minus1_data_2; //g_2(t)*h_2(t-1) Dtype g_data_3 = get_gate(G3,num,channels,height,width,n,c,h,w,h+1,w-1,horizontal,reverse); //g_3(t) Dtype h_minus1_data_3 = get_data(H,num,channels,height,width,n,c,h+1,w-1); //h_3(t-1) Dtype h3_minus1 = g_data_3 * h_minus1_data_3; //g_3(t)*h_3(t-1) Dtype h_hype = h1_minus1 + h2_minus1 + h3_minus1; //sum(g_i(t)*h_i(t-1)) = g_1(t)*h_1(t-1)+g_2(t)*h_2(t-1)+g_3(t)*h_3(t-1) Dtype x_hype = (1 - g_data_1 - g_data_2 - g_data_3) * x_data; //(1-sum(g_i(t))) * x Dtype h_data = x_hype + h_hype; //(1-sum(g_i(t))) * x_i(t) + sum(g_i(t) * h_i(t-1)) set_data(H,num,channels,height,width,n,c,h,w,h_data); //set H data at point x } } /*END h(t) = (1-sum(g_i(t))) * x_i(t) + sum(g_i(t) * h_i(t+1))*/ /*RIGHT->LEFT*/ /*h(t) = (1-sum(g_i(t))) * x_i(t) + sum(g_i(t) * h_i(t+1))*/ template <typename Dtype> __global__ void forward_one_col_right_left(const int count, int T, int num, int channels, int height, int width, const Dtype* X, const Dtype* G1, const Dtype* G2, const Dtype* G3, Dtype* H, bool horizontal, bool reverse){ //count -> total number of threads; T -> current_row/current_column; num -> total num batch for(int index = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; index < count; index += blockDim.x * gridDim.x * gridDim.y){ //CUDA kernel loop, index trace the current thread int hc_count = height * channels; int n,c,h,w; //w->current_col; n->current_batch; c->current_channel; int temp = index; w = T; n = temp / hc_count; temp = temp % hc_count; c = temp / height; temp = temp % height; h = temp; //locate the pixel as (n,c,h,w); Dtype x_data = get_data(X,num,channels,height,width,n,c,h,w); //x //modify logic by xueyan Dtype g_data_1 = get_gate(G1,num,channels,height,width,n,c,h,w,h-1,w+1,horizontal,reverse); //g_1(t) Dtype h_minus1_data_1 = get_data(H,num,channels,height,width,n,c,h-1,w+1); //h_1(t+1) Dtype h1_minus1 = g_data_1 * h_minus1_data_1; //g_1(t)*h_1(t+1) Dtype g_data_2 = get_gate(G2,num,channels,height,width,n,c,h,w,h,w+1,horizontal,reverse); //g_2(t) Dtype h_minus1_data_2 = get_data(H,num,channels,height,width,n,c,h,w+1); //h_2(t+1) Dtype h2_minus1 = g_data_2 * h_minus1_data_2; //g_2(t)*h_2(t+1) Dtype g_data_3 = get_gate(G3,num,channels,height,width,n,c,h,w,h+1,w+1,horizontal,reverse); //g_3(t) Dtype h_minus1_data_3 = get_data(H,num,channels,height,width,n,c,h+1,w+1); //h_3(t+1) Dtype h3_minus1 = g_data_3 * h_minus1_data_3; //g_3(t)*h_3(t+1) Dtype h_hype = h1_minus1 + h2_minus1 + h3_minus1; //sum(g_i(t)*h_i(t+1)) = g_1(t)*h_1(t+1)+g_2(t)*h_2(t+1)+g_3(t)*h_3(t+1) Dtype x_hype = (1 - g_data_1 - g_data_2 - g_data_3) * x_data; //(1-sum(g_i(t))) * x Dtype h_data = x_hype + h_hype; //(1-sum(g_i(t))) * x_i(t) + sum(g_i(t) * h_i(t+1)) set_data(H,num,channels,height,width,n,c,h,w,h_data); //set H data at point x } } /*END h(t) = (1-sum(g_i(t))) * x_i(t) + sum(g_i(t) * h_i(t+1))*/ /*TOP->BOTTOM*/ /*h(t) = (1-sum(g_(t)i)) * x_(t)i + sum(g_(t)i * h_(t-1)i)*/ template <typename Dtype> __global__ void forward_one_row_top_bottom(const int count, int T, int num, int channels, int height, int width, const Dtype* X, const Dtype* G1, const Dtype* G2, const Dtype* G3, Dtype* H, bool horizontal, bool reverse){ //count -> total number of threads; T -> current_row/current_column; num -> total num batch for(int index = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; index < count; index += blockDim.x * gridDim.x * gridDim.y){ //CUDA kernel loop, index trace the current thread int wc_count = width * channels; int n,c,h,w; //w->current_col; n->current_batch; c->current_channel; int temp = index; h = T; n = temp / wc_count; temp = temp % wc_count; c = temp / width; temp = temp % width; w = temp; //locate the pixel as (n,c,h,w); //modify logic by xueyan Dtype x_data = get_data(X,num,channels,height,width,n,c,h,w); //x Dtype g_data_1 = get_gate(G1,num,channels,height,width,n,c,h,w,h-1,w-1,horizontal,reverse); //g_(t)1 Dtype h_minus1_data_1 = get_data(H,num,channels,height,width,n,c,h-1,w-1); //h_(t-1)1 Dtype h1_minus1 = g_data_1 * h_minus1_data_1; //g_(t)1 * h_(t-1)1 Dtype g_data_2 = get_gate(G2,num,channels,height,width,n,c,h,w,h-1,w,horizontal,reverse); //g_(t)2 Dtype h_minus1_data_2 = get_data(H,num,channels,height,width,n,c,h-1,w); //h_(t-1)2 Dtype h2_minus1 = g_data_2 * h_minus1_data_2; //g_(t)2 * h_(t-1)2 Dtype g_data_3 = get_gate(G3,num,channels,height,width,n,c,h,w,h-1,w+1,horizontal,reverse); //g_(t)3 Dtype h_minus1_data_3 = get_data(H,num,channels,height,width,n,c,h-1,w+1); //h_(t-1)3 Dtype h3_minus1 = g_data_3 * h_minus1_data_3; //g_(t)3 * h_(t-1)3 Dtype h_hype = h1_minus1 + h2_minus1 + h3_minus1; //sum(g_(t)i * h_(t-1)i) = g_(t)1*h_(t-1)1+g_(t)2*h_(t-1)2+g_(t)3*h_(t-1)3 Dtype x_hype = (1 - g_data_1 - g_data_2 - g_data_3) * x_data; //(1-sum(g_(t)i)) * x_(t)i Dtype h_data = x_hype + h_hype; //(1-sum(g_(t)i)) * x_(t)i + sum(g_(t)i * h_(t-1)i) set_data(H,num,channels,height,width,n,c,h,w,h_data); } } /*END h(t) = (1-sum(g_(t)i)) * x_(t)i + sum(g_(t)i * h_(t-1)i)*/ /*BOTTOM->TOP*/ /*h(t) = (1-sum(g_(t)i)) * x_(t)i + sum(g_(t)i * h_(t+1)i)*/ template <typename Dtype> __global__ void forward_one_row_bottom_top(const int count, int T, int num, int channels, int height, int width, const Dtype* X, const Dtype* G1, const Dtype* G2, const Dtype* G3, Dtype* H, bool horizontal, bool reverse){ //count -> total number of threads; T -> current_row/current_column; num -> total num batch for(int index = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; index < count; index += blockDim.x * gridDim.x * gridDim.y){ //CUDA kernel loop, index trace the current thread int wc_count = width * channels; int n,c,h,w; //w->current_col; n->current_batch; c->current_channel; int temp = index; h = T; n = temp / wc_count; temp = temp % wc_count; c = temp / width; temp = temp % width; w = temp; //locate the pixel as (n,c,h,w); //modify logic by xueyan Dtype x_data = get_data(X,num,channels,height,width,n,c,h,w); //w Dtype g_data_1 = get_gate(G1,num,channels,height,width,n,c,h,w,h+1,w-1,horizontal,reverse); //g_(t)1 Dtype h_minus1_data_1 = get_data(H,num,channels,height,width,n,c,h+1,w-1); //h_(t+1)1 Dtype h1_minus1 = g_data_1 * h_minus1_data_1; //g_(t)1 * h_(t+1)1 Dtype g_data_2 = get_gate(G2,num,channels,height,width,n,c,h,w,h+1,w,horizontal,reverse); //g_(t)2 Dtype h_minus1_data_2 = get_data(H,num,channels,height,width,n,c,h+1,w); //h_(t+1)2 Dtype h2_minus1 = g_data_2 * h_minus1_data_2; //g_(t)2 * h_(t+1)2 Dtype g_data_3 = get_gate(G3,num,channels,height,width,n,c,h,w,h+1,w+1,horizontal,reverse); //g_(t)3 Dtype h_minus1_data_3 = get_data(H,num,channels,height,width,n,c,h+1,w+1); //h_(t+1)3 Dtype h3_minus1 = g_data_3 * h_minus1_data_3; //g_(t)3 * h_(t+1)3 Dtype h_hype = h1_minus1 + h2_minus1 + h3_minus1; //sum(g_(t)i * h_(t+1)i) = g_(t)1*h_(t+1)1+g_(t)2*h_(t+1)2+g_(t)3*h_(t+1)3 Dtype x_hype = (1 - g_data_1 - g_data_2 - g_data_3) * x_data; //(1-sum(g_(t)i)) * x_(t)i Dtype h_data = x_hype + h_hype; //(1-sum(g_(t)i)) * x_(t)i + sum(g_(t)i * h_(t+1)i) set_data(H,num,channels,height,width,n,c,h,w,h_data); } } /*END h(t) = (1-sum(g_(t)i)) * x_(t)i + sum(g_(t)i * h_(t-1)i)*/ template <typename Dtype> __global__ void backward_one_col_left_right(const int count, int T, int num, int channels, int height, int width, const Dtype* X, const Dtype* G1, const Dtype* G2, const Dtype* G3, const Dtype* H, Dtype* X_diff, Dtype* G1_diff, Dtype* G2_diff, Dtype* G3_diff, Dtype* H_diff, bool horizontal, bool reverse){ for(int index = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; index < count; index += blockDim.x * gridDim.x * gridDim.y){ //CUDA kernel loop, index trace the current thread int hc_count = height * channels; int n,c,h,w; //w->current_col; n->current_batch; c->current_channel; int temp=index; w = T; n = temp / hc_count; temp = temp % hc_count; c = temp / height; temp = temp % height; h = temp; //locate the pixel as (n,c,h,w); Dtype x_data = get_data(X,num,channels,height,width,n,c,h,w); //h(t)_diff = top(t)_diff Dtype h_diff = get_data(H_diff,num,channels,height,width,n,c,h,w); //h(t)_diff += h(t+1)_diff * g(t+1) if t<T Dtype add1_h3_diff = get_data(H_diff,num,channels,height,width,n,c,h-1,w+1); Dtype add1_g3_data = get_gate(G3,num,channels,height,width,n,c,h,w,h-1,w+1,horizontal,reverse); Dtype add1_h2_diff = get_data(H_diff,num,channels,height,width,n,c,h,w+1); Dtype add1_g2_data = get_gate(G2,num,channels,height,width,n,c,h,w,h,w+1,horizontal,reverse); Dtype add1_h1_diff = get_data(H_diff,num,channels,height,width,n,c,h+1,w+1); Dtype add1_g1_data = get_gate(G1,num,channels,height,width,n,c,h,w,h+1,w+1,horizontal,reverse); h_diff = h_diff + add1_h3_diff * add1_g3_data + add1_h2_diff * add1_g2_data + add1_h1_diff * add1_g1_data; //H_diff[n*channels*height*width + c*height*width + h*width + w]=0; set_data(H_diff,num,channels,height,width,n,c,h,w,h_diff); //x(t)_diff=(1-sum(g_date))*h(t)_diff Dtype g1_data = get_gate(G1,num,channels,height,width,n,c,h,w,h-1,w-1,horizontal,reverse); Dtype g2_data = get_gate(G2,num,channels,height,width,n,c,h,w,h,w-1,horizontal,reverse); Dtype g3_data = get_gate(G3,num,channels,height,width,n,c,h,w,h+1,w-1,horizontal,reverse); Dtype x_diff = (1- g1_data -g2_data -g3_data) * h_diff; set_data(X_diff,num,channels,height,width,n,c,h,w,x_diff); // g_diff = h_diff * (h_data(t-1) - x_data) Dtype h1_minus1_data = get_data(H,num,channels,height,width,n,c,h-1,w-1); Dtype g1_diff = h_diff * (h1_minus1_data - x_data); set_gate(G1_diff,num,channels,height,width,n,c,h,w,h-1,w-1,g1_diff,horizontal,reverse); Dtype h2_minus1_data = get_data(H,num,channels,height,width,n,c,h,w-1); Dtype g2_diff = h_diff * (h2_minus1_data - x_data); set_gate(G2_diff,num,channels,height,width,n,c,h,w,h,w-1,g2_diff,horizontal,reverse); Dtype h3_minus1_data = get_data(H,num,channels,height,width,n,c,h+1,w-1); Dtype g3_diff = h_diff * (h3_minus1_data - x_data); set_gate(G3_diff,num,channels,height,width,n,c,h,w,h+1,w-1,g3_diff,horizontal,reverse); } } template <typename Dtype> __global__ void backward_one_col_right_left(const int count, int T, int num,int channels, int height, int width, const Dtype* X, const Dtype* G1, const Dtype* G2, const Dtype* G3, const Dtype* H, Dtype* X_diff, Dtype* G1_diff, Dtype* G2_diff, Dtype* G3_diff, Dtype* H_diff, bool horizontal, bool reverse){ for(int index = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; index < count; index += blockDim.x * gridDim.x * gridDim.y){ //CUDA kernel loop, index trace the current thread int hc_count = height * channels; int n,c,h,w; //w->current_col; n->current_batch; c->current_channel; int temp=index; w = T; n = temp / hc_count; temp = temp % hc_count; c = temp / height; temp = temp % height; h = temp; //locate the pixel as (n,c,h,w); Dtype x_data = get_data(X,num,channels,height,width,n,c,h,w); //h(t)_diff = top(t)_diff Dtype h_diff = get_data(H_diff,num,channels,height,width,n,c,h,w); //h(t)_diff += h(t+1)_diff * g(t+1) if t<T Dtype add1_h3_diff = get_data(H_diff,num,channels,height,width,n,c,h-1,w-1); Dtype add1_g3_data = get_gate(G3,num,channels,height,width,n,c,h,w,h-1,w-1,horizontal,reverse); Dtype add1_h2_diff = get_data(H_diff,num,channels,height,width,n,c,h,w-1); Dtype add1_g2_data = get_gate(G2,num,channels,height,width,n,c,h,w,h,w-1,horizontal,reverse); Dtype add1_h1_diff = get_data(H_diff,num,channels,height,width,n,c,h+1,w-1); Dtype add1_g1_data = get_gate(G1,num,channels,height,width,n,c,h,w,h+1,w-1,horizontal,reverse); h_diff = h_diff + add1_h3_diff * add1_g3_data + add1_h2_diff * add1_g2_data + add1_h1_diff * add1_g1_data; set_data(H_diff,num,channels,height,width,n,c,h,w,h_diff); Dtype g1_data = get_gate(G1,num,channels,height,width,n,c,h,w,h-1,w+1,horizontal,reverse); Dtype g2_data = get_gate(G2,num,channels,height,width,n,c,h,w,h,w+1,horizontal,reverse); Dtype g3_data = get_gate(G3,num,channels,height,width,n,c,h,w,h+1,w+1,horizontal,reverse); Dtype x_diff = (1 - g1_data - g2_data - g3_data) * h_diff; set_data(X_diff,num,channels,height,width,n,c,h,w,x_diff); // g_diff = h_diff * (h_data(t-1) - x_data) Dtype h1_minus1_data = get_data(H,num,channels,height,width,n,c,h-1,w+1); Dtype g1_diff = h_diff * (h1_minus1_data - x_data); set_gate(G1_diff,num,channels,height,width,n,c,h,w,h-1,w+1,g1_diff,horizontal,reverse); Dtype h2_minus1_data = get_data(H,num,channels,height,width,n,c,h,w+1); Dtype g2_diff = h_diff * (h2_minus1_data - x_data); set_gate(G2_diff,num,channels,height,width,n,c,h,w,h,w+1,g2_diff,horizontal,reverse); Dtype h3_minus1_data = get_data(H,num,channels,height,width,n,c,h+1,w+1); Dtype g3_diff = h_diff * (h3_minus1_data - x_data); set_gate(G3_diff,num,channels,height,width,n,c,h,w,h+1,w+1,g3_diff,horizontal,reverse); } } template <typename Dtype> __global__ void backward_one_row_top_bottom(const int count, int T, int num,int channels, int height, int width, const Dtype* X, const Dtype* G1, const Dtype* G2, const Dtype* G3, const Dtype* H, Dtype* X_diff, Dtype* G1_diff, Dtype* G2_diff, Dtype* G3_diff, Dtype* H_diff, bool horizontal, bool reverse){ for(int index = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; index < count; index += blockDim.x * gridDim.x * gridDim.y){ //CUDA kernel loop, index trace the current thread int wc_count = width * channels; int n,c,h,w; //w->current_col; n->current_batch; c->current_channel; int temp=index; h = T; n = temp / wc_count; temp = temp % wc_count; c = temp / width; temp = temp % width; w = temp; //locate the pixel as (n,c,h,w); Dtype x_data = get_data(X,num,channels,height,width,n,c,h,w); Dtype h_diff = get_data(H_diff,num,channels,height,width,n,c,h,w); //h(t)_diff += h(t+1)_diff * g(t+1) if t<T Dtype add1_h3_diff = get_data(H_diff,num,channels,height,width,n,c,h+1,w-1); Dtype add1_g3_data = get_gate(G3,num,channels,height,width,n,c,h,w,h+1,w-1,horizontal,reverse); Dtype add1_h2_diff = get_data(H_diff,num,channels,height,width,n,c,h+1,w); Dtype add1_g2_data = get_gate(G2,num,channels,height,width,n,c,h,w,h+1,w,horizontal,reverse); Dtype add1_h1_diff = get_data(H_diff,num,channels,height,width,n,c,h+1,w+1); Dtype add1_g1_data = get_gate(G1,num,channels,height,width,n,c,h,w,h+1,w+1,horizontal,reverse); h_diff = h_diff + add1_h3_diff * add1_g3_data + add1_h2_diff * add1_g2_data + add1_h1_diff * add1_g1_data; set_data(H_diff,num,channels,height,width,n,c,h,w,h_diff); //x(t)_diff=(1-g(t))*h(t)_diff Dtype g1_data = get_gate(G1,num,channels,height,width,n,c,h,w,h-1,w-1,horizontal,reverse); Dtype g2_data = get_gate(G2,num,channels,height,width,n,c,h,w,h-1,w,horizontal,reverse); Dtype g3_data = get_gate(G3,num,channels,height,width,n,c,h,w,h-1,w+1,horizontal,reverse); Dtype x_diff = (1- g1_data - g2_data - g3_data) * h_diff; set_data(X_diff,num,channels,height,width,n,c,h,w,x_diff); // g_diff = h_diff * (h_data(t-1) - x_data) Dtype h1_minus1_data = get_data(H,num,channels,height,width,n,c,h-1,w-1); Dtype g1_diff = h_diff * (h1_minus1_data - x_data); set_gate(G1_diff,num,channels,height,width,n,c,h,w,h-1,w-1,g1_diff,horizontal,reverse); Dtype h2_minus1_data = get_data(H,num,channels,height,width,n,c,h-1,w); Dtype g2_diff = h_diff * (h2_minus1_data - x_data); set_gate(G2_diff,num,channels,height,width,n,c,h,w,h-1,w,g2_diff,horizontal,reverse); Dtype h3_minus1_data = get_data(H,num,channels,height,width,n,c,h-1,w+1); Dtype g3_diff = h_diff * (h3_minus1_data - x_data); set_gate(G3_diff,num,channels,height,width,n,c,h,w,h-1,w+1,g3_diff,horizontal,reverse); } } template <typename Dtype> __global__ void backward_one_row_bottom_top(const int count, int T, int num, int channels, int height, int width, const Dtype* X, const Dtype* G1, const Dtype* G2, const Dtype* G3, const Dtype* H, Dtype* X_diff, Dtype* G1_diff, Dtype* G2_diff, Dtype* G3_diff, Dtype* H_diff, bool horizontal, bool reverse){ for(int index = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; index < count; index += blockDim.x * gridDim.x * gridDim.y){ //CUDA kernel loop, index trace the current thread int wc_count = width * channels; int n,c,h,w; int temp=index; h = T; n = temp / wc_count; temp = temp % wc_count; c = temp / width; temp = temp % width; w = temp; Dtype x_data = get_data(X,num,channels,height,width,n,c,h,w); //h(t)_diff = top(t)_diff Dtype h_diff = get_data(H_diff,num,channels,height,width,n,c,h,w); //h(t)_diff += h(t+1)_diff * g(t+1) if t<T Dtype add1_h3_diff = get_data(H_diff,num,channels,height,width,n,c,h-1,w-1); Dtype add1_g3_data = get_gate(G3,num,channels,height,width,n,c,h,w,h-1,w-1,horizontal,reverse); Dtype add1_h2_diff = get_data(H_diff,num,channels,height,width,n,c,h-1,w); Dtype add1_g2_data = get_gate(G2,num,channels,height,width,n,c,h,w,h-1,w,horizontal,reverse); Dtype add1_h1_diff = get_data(H_diff,num,channels,height,width,n,c,h-1,w+1); Dtype add1_g1_data = get_gate(G1,num,channels,height,width,n,c,h,w,h-1,w+1,horizontal,reverse); h_diff = h_diff + add1_h3_diff * add1_g3_data + add1_h2_diff * add1_g2_data + add1_h1_diff * add1_g1_data; set_data(H_diff,num,channels,height,width,n,c,h,w,h_diff); //x(t)_diff=(1-g(t))*h(t)_diff Dtype g1_data = get_gate(G1,num,channels,height,width,n,c,h,w,h+1,w-1,horizontal,reverse); Dtype g2_data = get_gate(G2,num,channels,height,width,n,c,h,w,h+1,w,horizontal,reverse); Dtype g3_data = get_gate(G3,num,channels,height,width,n,c,h,w,h+1,w+1,horizontal,reverse); Dtype x_diff = (1- g1_data -g2_data -g3_data) * h_diff; set_data(X_diff,num,channels,height,width,n,c,h,w,x_diff); // g_diff = h_diff * (h_data(t-1) - x_data) Dtype h1_minus1_data = get_data(H,num,channels,height,width,n,c,h+1,w-1); Dtype g1_diff = h_diff * (h1_minus1_data - x_data); set_gate(G1_diff,num,channels,height,width,n,c,h,w,h+1,w-1,g1_diff,horizontal,reverse); //Dtype g2_diff = h_diff * g2_idx * x_data * -1; Dtype h2_minus1_data = get_data(H,num,channels,height,width,n,c,h+1,w); Dtype g2_diff = h_diff * (h2_minus1_data - x_data); set_gate(G2_diff,num,channels,height,width,n,c,h,w,h+1,w,g2_diff,horizontal,reverse); //Dtype g3_diff = h_diff * g3_idx * x_data * -1; Dtype h3_minus1_data = get_data(H,num,channels,height,width,n,c,h+1,w+1); Dtype g3_diff = h_diff * (h3_minus1_data - x_data); set_gate(G3_diff,num,channels,height,width,n,c,h,w,h+1,w+1,g3_diff,horizontal,reverse); } } template<typename Dtype> inline void SPNForward(const Tensor<gpu, 4, Dtype> &data, const Tensor<gpu, 4, Dtype> &g1, const Tensor<gpu, 4, Dtype> &g2, const Tensor<gpu, 4, Dtype> &g3, const Tensor<gpu, 4, Dtype> &out, const bool horizontal_, const bool reverse_){ /*get pointer*/ const Dtype *X = data.dptr_; const Dtype *G1 = g1.dptr_; const Dtype *G2 = g2.dptr_; const Dtype *G3 = g3.dptr_; Dtype *H = out.dptr_; /*END get pointer*/ /*get dimension*/ //data, g1, g2, g3, out, share the same dimension //n_X represent number of X const int n_batch = data.size(0); const int n_channel = data.size(1); const int height = data.size(2); const int width = data.size(3); /*END get dimension*/ /*set cuda system param*/ const int NUM_THREADS_BLOCK = 512; //CUDA: use 512 threads per block const int NUM_BLOCKS_GRID = kMaxGridDim; //CUDA: use largest blocks num per grid /*END set cuda system param*/ /*allocate kernel*/ if(horizontal_ && !reverse_){ // left to right /*logic within this block: *1. calculate total number of execution units that run in parallel *2. calculate block and grid dimension *3. check block/grid dimension, get stream *4. call cuda kernal function*/ const int n_operation_parallel = height * n_channel * n_batch; const int n_blocks_need = ((n_operation_parallel - 1) / NUM_THREADS_BLOCK) + 1; const int n_grids_need = ((n_blocks_need - 1) / NUM_BLOCKS_GRID) + 1; for(int current_col = 0; current_col < width; current_col++){ //iterate through the column dim3 dimGrid(NUM_BLOCKS_GRID, n_grids_need); dim3 dimBlock(NUM_THREADS_BLOCK); CheckLaunchParam(dimGrid, dimBlock, "SPN left->right forward"); //check whether dimGrid or dimBlock is out of range hipStream_t stream = Stream<gpu>::GetStream(out.stream_); //??not sure where to find the definition of stream_ hipLaunchKernelGGL(( forward_one_col_left_right<Dtype>), dim3(dimGrid), dim3(dimBlock), 0, stream, n_operation_parallel, current_col, n_batch, n_channel, height, width, X, G1, G2, G3, H, horizontal_, reverse_); } }else if(horizontal_ && reverse_){ // right to left /*logic same as previous*/ const int n_operation_parallel = height * n_channel * n_batch; //total number of execution units that run in parallel const int n_blocks_need = ((n_operation_parallel - 1) / NUM_THREADS_BLOCK) + 1; const int n_grids_need = ((n_blocks_need - 1) / NUM_BLOCKS_GRID) + 1; for(int current_col = width - 1; current_col >= 0; current_col--){ dim3 dimGrid(NUM_BLOCKS_GRID, n_grids_need); dim3 dimBlock(NUM_THREADS_BLOCK); CheckLaunchParam(dimGrid, dimBlock, "SPN right->left forward"); //check whether dimGrid or dimBlock is out of range hipStream_t stream = Stream<gpu>::GetStream(out.stream_); //??not sure where to find the definition of stream_ hipLaunchKernelGGL(( forward_one_col_right_left<Dtype>), dim3(dimGrid), dim3(dimBlock), 0, stream, n_operation_parallel, current_col, n_batch, n_channel, height, width, X, G1, G2, G3, H, horizontal_, reverse_); } }else if(!horizontal_ && !reverse_){ // top to bottom /*logic same as previous*/ const int n_operation_parallel = width * n_channel * n_batch; //total number of execution units that run in parallel const int n_blocks_need = ((n_operation_parallel - 1) / NUM_THREADS_BLOCK) + 1; const int n_grids_need = ((n_blocks_need - 1) / NUM_BLOCKS_GRID) + 1; for(int current_row = 0; current_row < height; current_row++){ dim3 dimGrid(NUM_BLOCKS_GRID, n_grids_need); dim3 dimBlock(NUM_THREADS_BLOCK); CheckLaunchParam(dimGrid, dimBlock, "SPN top->bottom forward"); //check whether dimGrid or dimBlock is out of range hipStream_t stream = Stream<gpu>::GetStream(out.stream_); //??not sure where to find the definition of stream_ hipLaunchKernelGGL(( forward_one_row_top_bottom<Dtype>), dim3(dimGrid), dim3(dimBlock), 0, stream, n_operation_parallel, current_row, n_batch, n_channel, height, width, X, G1, G2, G3, H, horizontal_, reverse_); } }else{ //bottom to top /*logic same as previous*/ const int n_operation_parallel = width * n_channel * n_batch; //total number of execution units that run in parallel const int n_blocks_need = ((n_operation_parallel - 1) / NUM_THREADS_BLOCK) + 1; const int n_grids_need = ((n_blocks_need - 1) / NUM_BLOCKS_GRID) + 1; for(int current_row = height - 1; current_row >= 0; current_row--){ dim3 dimGrid(NUM_BLOCKS_GRID, n_grids_need); dim3 dimBlock(NUM_THREADS_BLOCK); CheckLaunchParam(dimGrid, dimBlock, "SPN bottom->top forward"); //check whether dimGrid or dimBlock is out of range hipStream_t stream = Stream<gpu>::GetStream(out.stream_); //??not sure where to find the definition of stream_ hipLaunchKernelGGL(( forward_one_row_bottom_top<Dtype>), dim3(dimGrid), dim3(dimBlock), 0, stream, n_operation_parallel, current_row, n_batch, n_channel, height, width, X, G1, G2, G3, H, horizontal_, reverse_); } } /*END allocate kernel*/ }//end SPNForward template<typename Dtype> inline void SPNBackward(const Tensor<gpu, 4, Dtype> &data, const Tensor<gpu, 4, Dtype> &g1, const Tensor<gpu, 4, Dtype> &g2, const Tensor<gpu, 4, Dtype> &g3, const Tensor<gpu, 4, Dtype> &out, const Tensor<gpu, 4, Dtype> &data_diff, const Tensor<gpu, 4, Dtype> &g1_diff, const Tensor<gpu, 4, Dtype> &g2_diff, const Tensor<gpu, 4, Dtype> &g3_diff, const Tensor<gpu, 4, Dtype> &out_diff, const bool horizontal_, const bool reverse_){ /*get pointer*/ const Dtype *X = data.dptr_; const Dtype *G1 = g1.dptr_; const Dtype *G2 = g2.dptr_; const Dtype *G3 = g3.dptr_; const Dtype *H = out.dptr_; Dtype *X_diff = data_diff.dptr_; Dtype *G1_diff = g1_diff.dptr_; Dtype *G2_diff = g2_diff.dptr_; Dtype *G3_diff = g3_diff.dptr_; Dtype *H_diff = out_diff.dptr_; /*END get pointer*/ /*get dimension*/ //data, g1, g2, g3, out, share the same dimension //n_X represent number of X const int n_batch = data.size(0); const int n_channel = data.size(1); const int height = data.size(2); const int width = data.size(3); /*END get dimension*/ /*set cuda system param*/ const int NUM_THREADS_BLOCK = 512; //CUDA: use 512 threads per block const int NUM_BLOCKS_GRID = kMaxGridDim; //CUDA: use largest blocks num per grid /*END set cuda system param*/ /*allocate kernel*/ if(horizontal_ && !reverse_){ // left to right /*logic within this block: *1. calculate total number of execution units that run in parallel *2. calculate block and grid dimension *3. check block/grid dimension, get stream *4. call cuda kernal function*/ const int n_operation_parallel = height * n_channel * n_batch; const int n_blocks_need = ((n_operation_parallel - 1) / NUM_THREADS_BLOCK) + 1; const int n_grids_need = ((n_blocks_need - 1) / NUM_BLOCKS_GRID) + 1; for(int current_col = width - 1; current_col >= 0; current_col--){ //iterate through the column dim3 dimGrid(NUM_BLOCKS_GRID, n_grids_need); dim3 dimBlock(NUM_THREADS_BLOCK); CheckLaunchParam(dimGrid, dimBlock, "SPN left->right backward"); //check whether dimGrid or dimBlock is out of range hipStream_t stream = Stream<gpu>::GetStream(out.stream_); //??not sure where to find the definition of stream_ hipLaunchKernelGGL(( backward_one_col_left_right<Dtype>), dim3(dimGrid), dim3(dimBlock), 0, stream, n_operation_parallel, current_col, n_batch, n_channel, height, width, X, G1, G2, G3, H, X_diff, G1_diff, G2_diff, G3_diff, H_diff, horizontal_, reverse_); } }else if(horizontal_ && reverse_){ // right to left /*logic same as previous*/ const int n_operation_parallel = height * n_channel * n_batch; //total number of execution units that run in parallel const int n_blocks_need = ((n_operation_parallel - 1) / NUM_THREADS_BLOCK) + 1; const int n_grids_need = ((n_blocks_need - 1) / NUM_BLOCKS_GRID) + 1; for(int current_col = 0; current_col < width; current_col++){ dim3 dimGrid(NUM_BLOCKS_GRID, n_grids_need); dim3 dimBlock(NUM_THREADS_BLOCK); CheckLaunchParam(dimGrid, dimBlock, "SPN right->left backward"); //check whether dimGrid or dimBlock is out of range hipStream_t stream = Stream<gpu>::GetStream(out.stream_); //??not sure where to find the definition of stream_ hipLaunchKernelGGL(( backward_one_col_right_left<Dtype>), dim3(dimGrid), dim3(dimBlock), 0, stream, n_operation_parallel, current_col, n_batch, n_channel, height, width, X, G1, G2, G3, H, X_diff, G1_diff, G2_diff, G3_diff, H_diff, horizontal_, reverse_); } }else if(!horizontal_ && !reverse_){ // top to bottom /*logic same as previous*/ const int n_operation_parallel = width * n_channel * n_batch; //total number of execution units that run in parallel const int n_blocks_need = ((n_operation_parallel - 1) / NUM_THREADS_BLOCK) + 1; const int n_grids_need = ((n_blocks_need - 1) / NUM_BLOCKS_GRID) + 1; for(int current_row = height - 1; current_row >= 0; current_row--){ dim3 dimGrid(NUM_BLOCKS_GRID, n_grids_need); dim3 dimBlock(NUM_THREADS_BLOCK); CheckLaunchParam(dimGrid, dimBlock, "SPN top->bottom backward"); //check whether dimGrid or dimBlock is out of range hipStream_t stream = Stream<gpu>::GetStream(out.stream_); //??not sure where to find the definition of stream_ hipLaunchKernelGGL(( backward_one_row_top_bottom<Dtype>), dim3(dimGrid), dim3(dimBlock), 0, stream, n_operation_parallel, current_row, n_batch, n_channel, height, width, X, G1, G2, G3, H, X_diff, G1_diff, G2_diff, G3_diff, H_diff, horizontal_, reverse_); } }else{ //bottom to top /*logic same as previous*/ const int n_operation_parallel = width * n_channel * n_batch; //total number of execution units that run in parallel const int n_blocks_need = ((n_operation_parallel - 1) / NUM_THREADS_BLOCK) + 1; const int n_grids_need = ((n_blocks_need - 1) / NUM_BLOCKS_GRID) + 1; for(int current_row = 0; current_row < width; current_row++){ dim3 dimGrid(NUM_BLOCKS_GRID, n_grids_need); dim3 dimBlock(NUM_THREADS_BLOCK); CheckLaunchParam(dimGrid, dimBlock, "SPN bottom->top backward"); //check whether dimGrid or dimBlock is out of range hipStream_t stream = Stream<gpu>::GetStream(out.stream_); //??not sure where to find the definition of stream_ hipLaunchKernelGGL(( backward_one_row_bottom_top<Dtype>), dim3(dimGrid), dim3(dimBlock), 0, stream, n_operation_parallel, current_row, n_batch, n_channel, height, width, X, G1, G2, G3, H, X_diff, G1_diff, G2_diff, G3_diff, H_diff, horizontal_, reverse_); } } /*END allocate kernel*/ }//end SPNBackward } //namespace cuda template<typename Dtype> inline void SPNForward(const Tensor<gpu, 4, Dtype> &data, const Tensor<gpu, 4, Dtype> &g1, const Tensor<gpu, 4, Dtype> &g2, const Tensor<gpu, 4, Dtype> &g3, const Tensor<gpu, 4, Dtype> &out, const bool horizontal, const bool reverse){ cuda::SPNForward(data, g1, g2, g3, out, horizontal, reverse); } template<typename Dtype> inline void SPNBackward(const Tensor<gpu, 4, Dtype> &data, const Tensor<gpu, 4, Dtype> &g1, const Tensor<gpu, 4, Dtype> &g2, const Tensor<gpu, 4, Dtype> &g3, const Tensor<gpu, 4, Dtype> &out, const Tensor<gpu, 4, Dtype> &data_diff, const Tensor<gpu, 4, Dtype> &g1_diff, const Tensor<gpu, 4, Dtype> &g2_diff, const Tensor<gpu, 4, Dtype> &g3_diff, const Tensor<gpu, 4, Dtype> &out_diff, const bool horizontal, const bool reverse){ cuda::SPNBackward(data, g1, g2, g3, out, data_diff, g1_diff, g2_diff, g3_diff, out_diff, horizontal, reverse); } } //namespace mshadow namespace mxnet { namespace op { template<> Operator* CreateOp<gpu>(SpnParam param, int dtype) { Operator *op = NULL; MSHADOW_REAL_TYPE_SWITCH(dtype, DType, { op = new SpnOp<gpu, DType>(param); }) return op; } } // namespace op } // namespace mxnet
37ca52a6525974f8e5f376391aa4202d04acd555.cu
/* * Written by Xueyan Zou @TuSimple Algorithm Intern */ #include "./spatial-propagation-inl.h" #include <assert.h> #include <mshadow/tensor.h> #include <mshadow/cuda/reduce.cuh> #include <algorithm> #include <vector> namespace mshadow { namespace cuda { __device__ void get_gate_idx(int h1, int w1, int h2, int w2, int* out, bool horizontal, bool reverse) { if(horizontal && ! reverse) // left -> right { if(w1>w2) { out[0]=h1; out[1]=w1; } else { out[0]=h2; out[1]=w2; } } if(horizontal && reverse) // right -> left { if(w1<w2) { out[0]=h1; out[1]=w1; } else { out[0]=h2; out[1]=w2; } } if(!horizontal && !reverse) // top -> bottom { if(h1>h2) { out[0]=h1; out[1]=w1; } else { out[0]=h2; out[1]=w2; } } if(!horizontal && reverse) // bottom -> top { if(h1<h2) { out[0]=h1; out[1]=w1; } else { out[0]=h2; out[1]=w2; } } } template <typename Dtype> __device__ void set_gate(Dtype* data, int num, int channels, int height, int width, int n, int c, int h1, int w1, int h2, int w2, Dtype v, bool horizontal, bool reverse) { if(h1<0 || h1 >=height) //redundant return ; //redundant if(w1<0 || w1 >= width) //redundant return ; //redundant if(h2<0 || h2 >=height) //redundant return ; //redundant if(w2<0 || w2 >= width) //redundant return ; //redundant int idx[2]; get_gate_idx(h1, w1, h2, w2, idx, horizontal, reverse); int h = idx[0]; int w = idx[1]; data[n*channels*height*width + c*height*width + h*width + w] = v; } template <typename Dtype> //this function is modified by xueyan __device__ Dtype get_gate(Dtype * data, int num, int channels, int height, int width, int n, int c, int h1, int w1, int h2, int w2, bool horizontal, bool reverse){ //handle index out of range if(h1<0 || h1 >=height) //redundant return 0; //redundant if(w1<0 || w1 >= width) //redundant return 0; //redundant if(h2<0 || h2 >=height) return 0; if(w2<0 || w2 >= width) return 0; int idx[2]; get_gate_idx(h1, w1, h2, w2, idx, horizontal, reverse); int h = idx[0]; int w = idx[1]; return data[n*channels*height*width + c*height*width + h*width + w]; } template <typename Dtype> __device__ void set_data(Dtype * data, int num, int channels,int height, int width,int n,int c,int h,int w, Dtype v) { //modify by xueyan, assert error. if(h<0 || h >=height) assert(0); if(w<0 || w >= width) assert(0); data[n*channels*height*width + c*height*width + h*width + w] = v; } template <typename Dtype> __device__ Dtype get_data(Dtype *data, int num, int channels, int height, int width, int n, int c, int h, int w){ //handle index out of range if(h<0 || h >=height) return 0; if(w<0 || w >= width) return 0; //spatial-propagation-inl.h:82 -> default configuration of dim is (batch, channel, height, width) return data[n*channels*height*width + c*height*width + h*width + w]; } /*LEFT->RIGHT*/ /*h(t) = (1-sum(g_i(t))) * x_i(t) + sum(g_i(t) * h_i(t-1))*/ template <typename Dtype> __global__ void forward_one_col_left_right(const int count, int T, int num, int channels, int height, int width, const Dtype* X, const Dtype* G1, const Dtype* G2, const Dtype* G3, Dtype* H, bool horizontal, bool reverse){ //count -> total number of threads; T -> current_row/current_column; num -> total num batch for(int index = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; index < count; index += blockDim.x * gridDim.x * gridDim.y){ //CUDA kernel loop, index trace the current thread int hc_count = height * channels; //in order to calculate batch size int n,c,h,w; //w->current_col; n->current_batch; c->current_channel; int temp = index; w = T; n = temp / hc_count; temp = temp % hc_count; c = temp / height; temp = temp % height; h = temp; //locate the pixel as (n,c,h,w); Dtype x_data = get_data(X,num,channels,height,width,n,c,h,w); //x //modify logic by xueyan Dtype g_data_1 = get_gate(G1,num,channels,height,width,n,c,h,w,h-1,w-1,horizontal,reverse); //g_1(t) Dtype h_minus1_data_1 = get_data(H,num,channels,height,width,n,c,h-1,w-1); //h_1(t-1) Dtype h1_minus1 = g_data_1 * h_minus1_data_1; //g_1(t)*h_1(t-1) Dtype g_data_2 = get_gate(G2,num,channels,height,width,n,c,h,w,h,w-1,horizontal,reverse); //g_2(t) Dtype h_minus1_data_2 = get_data(H,num,channels,height,width,n,c,h,w-1); //h_2(t-1) Dtype h2_minus1 = g_data_2 * h_minus1_data_2; //g_2(t)*h_2(t-1) Dtype g_data_3 = get_gate(G3,num,channels,height,width,n,c,h,w,h+1,w-1,horizontal,reverse); //g_3(t) Dtype h_minus1_data_3 = get_data(H,num,channels,height,width,n,c,h+1,w-1); //h_3(t-1) Dtype h3_minus1 = g_data_3 * h_minus1_data_3; //g_3(t)*h_3(t-1) Dtype h_hype = h1_minus1 + h2_minus1 + h3_minus1; //sum(g_i(t)*h_i(t-1)) = g_1(t)*h_1(t-1)+g_2(t)*h_2(t-1)+g_3(t)*h_3(t-1) Dtype x_hype = (1 - g_data_1 - g_data_2 - g_data_3) * x_data; //(1-sum(g_i(t))) * x Dtype h_data = x_hype + h_hype; //(1-sum(g_i(t))) * x_i(t) + sum(g_i(t) * h_i(t-1)) set_data(H,num,channels,height,width,n,c,h,w,h_data); //set H data at point x } } /*END h(t) = (1-sum(g_i(t))) * x_i(t) + sum(g_i(t) * h_i(t+1))*/ /*RIGHT->LEFT*/ /*h(t) = (1-sum(g_i(t))) * x_i(t) + sum(g_i(t) * h_i(t+1))*/ template <typename Dtype> __global__ void forward_one_col_right_left(const int count, int T, int num, int channels, int height, int width, const Dtype* X, const Dtype* G1, const Dtype* G2, const Dtype* G3, Dtype* H, bool horizontal, bool reverse){ //count -> total number of threads; T -> current_row/current_column; num -> total num batch for(int index = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; index < count; index += blockDim.x * gridDim.x * gridDim.y){ //CUDA kernel loop, index trace the current thread int hc_count = height * channels; int n,c,h,w; //w->current_col; n->current_batch; c->current_channel; int temp = index; w = T; n = temp / hc_count; temp = temp % hc_count; c = temp / height; temp = temp % height; h = temp; //locate the pixel as (n,c,h,w); Dtype x_data = get_data(X,num,channels,height,width,n,c,h,w); //x //modify logic by xueyan Dtype g_data_1 = get_gate(G1,num,channels,height,width,n,c,h,w,h-1,w+1,horizontal,reverse); //g_1(t) Dtype h_minus1_data_1 = get_data(H,num,channels,height,width,n,c,h-1,w+1); //h_1(t+1) Dtype h1_minus1 = g_data_1 * h_minus1_data_1; //g_1(t)*h_1(t+1) Dtype g_data_2 = get_gate(G2,num,channels,height,width,n,c,h,w,h,w+1,horizontal,reverse); //g_2(t) Dtype h_minus1_data_2 = get_data(H,num,channels,height,width,n,c,h,w+1); //h_2(t+1) Dtype h2_minus1 = g_data_2 * h_minus1_data_2; //g_2(t)*h_2(t+1) Dtype g_data_3 = get_gate(G3,num,channels,height,width,n,c,h,w,h+1,w+1,horizontal,reverse); //g_3(t) Dtype h_minus1_data_3 = get_data(H,num,channels,height,width,n,c,h+1,w+1); //h_3(t+1) Dtype h3_minus1 = g_data_3 * h_minus1_data_3; //g_3(t)*h_3(t+1) Dtype h_hype = h1_minus1 + h2_minus1 + h3_minus1; //sum(g_i(t)*h_i(t+1)) = g_1(t)*h_1(t+1)+g_2(t)*h_2(t+1)+g_3(t)*h_3(t+1) Dtype x_hype = (1 - g_data_1 - g_data_2 - g_data_3) * x_data; //(1-sum(g_i(t))) * x Dtype h_data = x_hype + h_hype; //(1-sum(g_i(t))) * x_i(t) + sum(g_i(t) * h_i(t+1)) set_data(H,num,channels,height,width,n,c,h,w,h_data); //set H data at point x } } /*END h(t) = (1-sum(g_i(t))) * x_i(t) + sum(g_i(t) * h_i(t+1))*/ /*TOP->BOTTOM*/ /*h(t) = (1-sum(g_(t)i)) * x_(t)i + sum(g_(t)i * h_(t-1)i)*/ template <typename Dtype> __global__ void forward_one_row_top_bottom(const int count, int T, int num, int channels, int height, int width, const Dtype* X, const Dtype* G1, const Dtype* G2, const Dtype* G3, Dtype* H, bool horizontal, bool reverse){ //count -> total number of threads; T -> current_row/current_column; num -> total num batch for(int index = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; index < count; index += blockDim.x * gridDim.x * gridDim.y){ //CUDA kernel loop, index trace the current thread int wc_count = width * channels; int n,c,h,w; //w->current_col; n->current_batch; c->current_channel; int temp = index; h = T; n = temp / wc_count; temp = temp % wc_count; c = temp / width; temp = temp % width; w = temp; //locate the pixel as (n,c,h,w); //modify logic by xueyan Dtype x_data = get_data(X,num,channels,height,width,n,c,h,w); //x Dtype g_data_1 = get_gate(G1,num,channels,height,width,n,c,h,w,h-1,w-1,horizontal,reverse); //g_(t)1 Dtype h_minus1_data_1 = get_data(H,num,channels,height,width,n,c,h-1,w-1); //h_(t-1)1 Dtype h1_minus1 = g_data_1 * h_minus1_data_1; //g_(t)1 * h_(t-1)1 Dtype g_data_2 = get_gate(G2,num,channels,height,width,n,c,h,w,h-1,w,horizontal,reverse); //g_(t)2 Dtype h_minus1_data_2 = get_data(H,num,channels,height,width,n,c,h-1,w); //h_(t-1)2 Dtype h2_minus1 = g_data_2 * h_minus1_data_2; //g_(t)2 * h_(t-1)2 Dtype g_data_3 = get_gate(G3,num,channels,height,width,n,c,h,w,h-1,w+1,horizontal,reverse); //g_(t)3 Dtype h_minus1_data_3 = get_data(H,num,channels,height,width,n,c,h-1,w+1); //h_(t-1)3 Dtype h3_minus1 = g_data_3 * h_minus1_data_3; //g_(t)3 * h_(t-1)3 Dtype h_hype = h1_minus1 + h2_minus1 + h3_minus1; //sum(g_(t)i * h_(t-1)i) = g_(t)1*h_(t-1)1+g_(t)2*h_(t-1)2+g_(t)3*h_(t-1)3 Dtype x_hype = (1 - g_data_1 - g_data_2 - g_data_3) * x_data; //(1-sum(g_(t)i)) * x_(t)i Dtype h_data = x_hype + h_hype; //(1-sum(g_(t)i)) * x_(t)i + sum(g_(t)i * h_(t-1)i) set_data(H,num,channels,height,width,n,c,h,w,h_data); } } /*END h(t) = (1-sum(g_(t)i)) * x_(t)i + sum(g_(t)i * h_(t-1)i)*/ /*BOTTOM->TOP*/ /*h(t) = (1-sum(g_(t)i)) * x_(t)i + sum(g_(t)i * h_(t+1)i)*/ template <typename Dtype> __global__ void forward_one_row_bottom_top(const int count, int T, int num, int channels, int height, int width, const Dtype* X, const Dtype* G1, const Dtype* G2, const Dtype* G3, Dtype* H, bool horizontal, bool reverse){ //count -> total number of threads; T -> current_row/current_column; num -> total num batch for(int index = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; index < count; index += blockDim.x * gridDim.x * gridDim.y){ //CUDA kernel loop, index trace the current thread int wc_count = width * channels; int n,c,h,w; //w->current_col; n->current_batch; c->current_channel; int temp = index; h = T; n = temp / wc_count; temp = temp % wc_count; c = temp / width; temp = temp % width; w = temp; //locate the pixel as (n,c,h,w); //modify logic by xueyan Dtype x_data = get_data(X,num,channels,height,width,n,c,h,w); //w Dtype g_data_1 = get_gate(G1,num,channels,height,width,n,c,h,w,h+1,w-1,horizontal,reverse); //g_(t)1 Dtype h_minus1_data_1 = get_data(H,num,channels,height,width,n,c,h+1,w-1); //h_(t+1)1 Dtype h1_minus1 = g_data_1 * h_minus1_data_1; //g_(t)1 * h_(t+1)1 Dtype g_data_2 = get_gate(G2,num,channels,height,width,n,c,h,w,h+1,w,horizontal,reverse); //g_(t)2 Dtype h_minus1_data_2 = get_data(H,num,channels,height,width,n,c,h+1,w); //h_(t+1)2 Dtype h2_minus1 = g_data_2 * h_minus1_data_2; //g_(t)2 * h_(t+1)2 Dtype g_data_3 = get_gate(G3,num,channels,height,width,n,c,h,w,h+1,w+1,horizontal,reverse); //g_(t)3 Dtype h_minus1_data_3 = get_data(H,num,channels,height,width,n,c,h+1,w+1); //h_(t+1)3 Dtype h3_minus1 = g_data_3 * h_minus1_data_3; //g_(t)3 * h_(t+1)3 Dtype h_hype = h1_minus1 + h2_minus1 + h3_minus1; //sum(g_(t)i * h_(t+1)i) = g_(t)1*h_(t+1)1+g_(t)2*h_(t+1)2+g_(t)3*h_(t+1)3 Dtype x_hype = (1 - g_data_1 - g_data_2 - g_data_3) * x_data; //(1-sum(g_(t)i)) * x_(t)i Dtype h_data = x_hype + h_hype; //(1-sum(g_(t)i)) * x_(t)i + sum(g_(t)i * h_(t+1)i) set_data(H,num,channels,height,width,n,c,h,w,h_data); } } /*END h(t) = (1-sum(g_(t)i)) * x_(t)i + sum(g_(t)i * h_(t-1)i)*/ template <typename Dtype> __global__ void backward_one_col_left_right(const int count, int T, int num, int channels, int height, int width, const Dtype* X, const Dtype* G1, const Dtype* G2, const Dtype* G3, const Dtype* H, Dtype* X_diff, Dtype* G1_diff, Dtype* G2_diff, Dtype* G3_diff, Dtype* H_diff, bool horizontal, bool reverse){ for(int index = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; index < count; index += blockDim.x * gridDim.x * gridDim.y){ //CUDA kernel loop, index trace the current thread int hc_count = height * channels; int n,c,h,w; //w->current_col; n->current_batch; c->current_channel; int temp=index; w = T; n = temp / hc_count; temp = temp % hc_count; c = temp / height; temp = temp % height; h = temp; //locate the pixel as (n,c,h,w); Dtype x_data = get_data(X,num,channels,height,width,n,c,h,w); //h(t)_diff = top(t)_diff Dtype h_diff = get_data(H_diff,num,channels,height,width,n,c,h,w); //h(t)_diff += h(t+1)_diff * g(t+1) if t<T Dtype add1_h3_diff = get_data(H_diff,num,channels,height,width,n,c,h-1,w+1); Dtype add1_g3_data = get_gate(G3,num,channels,height,width,n,c,h,w,h-1,w+1,horizontal,reverse); Dtype add1_h2_diff = get_data(H_diff,num,channels,height,width,n,c,h,w+1); Dtype add1_g2_data = get_gate(G2,num,channels,height,width,n,c,h,w,h,w+1,horizontal,reverse); Dtype add1_h1_diff = get_data(H_diff,num,channels,height,width,n,c,h+1,w+1); Dtype add1_g1_data = get_gate(G1,num,channels,height,width,n,c,h,w,h+1,w+1,horizontal,reverse); h_diff = h_diff + add1_h3_diff * add1_g3_data + add1_h2_diff * add1_g2_data + add1_h1_diff * add1_g1_data; //H_diff[n*channels*height*width + c*height*width + h*width + w]=0; set_data(H_diff,num,channels,height,width,n,c,h,w,h_diff); //x(t)_diff=(1-sum(g_date))*h(t)_diff Dtype g1_data = get_gate(G1,num,channels,height,width,n,c,h,w,h-1,w-1,horizontal,reverse); Dtype g2_data = get_gate(G2,num,channels,height,width,n,c,h,w,h,w-1,horizontal,reverse); Dtype g3_data = get_gate(G3,num,channels,height,width,n,c,h,w,h+1,w-1,horizontal,reverse); Dtype x_diff = (1- g1_data -g2_data -g3_data) * h_diff; set_data(X_diff,num,channels,height,width,n,c,h,w,x_diff); // g_diff = h_diff * (h_data(t-1) - x_data) Dtype h1_minus1_data = get_data(H,num,channels,height,width,n,c,h-1,w-1); Dtype g1_diff = h_diff * (h1_minus1_data - x_data); set_gate(G1_diff,num,channels,height,width,n,c,h,w,h-1,w-1,g1_diff,horizontal,reverse); Dtype h2_minus1_data = get_data(H,num,channels,height,width,n,c,h,w-1); Dtype g2_diff = h_diff * (h2_minus1_data - x_data); set_gate(G2_diff,num,channels,height,width,n,c,h,w,h,w-1,g2_diff,horizontal,reverse); Dtype h3_minus1_data = get_data(H,num,channels,height,width,n,c,h+1,w-1); Dtype g3_diff = h_diff * (h3_minus1_data - x_data); set_gate(G3_diff,num,channels,height,width,n,c,h,w,h+1,w-1,g3_diff,horizontal,reverse); } } template <typename Dtype> __global__ void backward_one_col_right_left(const int count, int T, int num,int channels, int height, int width, const Dtype* X, const Dtype* G1, const Dtype* G2, const Dtype* G3, const Dtype* H, Dtype* X_diff, Dtype* G1_diff, Dtype* G2_diff, Dtype* G3_diff, Dtype* H_diff, bool horizontal, bool reverse){ for(int index = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; index < count; index += blockDim.x * gridDim.x * gridDim.y){ //CUDA kernel loop, index trace the current thread int hc_count = height * channels; int n,c,h,w; //w->current_col; n->current_batch; c->current_channel; int temp=index; w = T; n = temp / hc_count; temp = temp % hc_count; c = temp / height; temp = temp % height; h = temp; //locate the pixel as (n,c,h,w); Dtype x_data = get_data(X,num,channels,height,width,n,c,h,w); //h(t)_diff = top(t)_diff Dtype h_diff = get_data(H_diff,num,channels,height,width,n,c,h,w); //h(t)_diff += h(t+1)_diff * g(t+1) if t<T Dtype add1_h3_diff = get_data(H_diff,num,channels,height,width,n,c,h-1,w-1); Dtype add1_g3_data = get_gate(G3,num,channels,height,width,n,c,h,w,h-1,w-1,horizontal,reverse); Dtype add1_h2_diff = get_data(H_diff,num,channels,height,width,n,c,h,w-1); Dtype add1_g2_data = get_gate(G2,num,channels,height,width,n,c,h,w,h,w-1,horizontal,reverse); Dtype add1_h1_diff = get_data(H_diff,num,channels,height,width,n,c,h+1,w-1); Dtype add1_g1_data = get_gate(G1,num,channels,height,width,n,c,h,w,h+1,w-1,horizontal,reverse); h_diff = h_diff + add1_h3_diff * add1_g3_data + add1_h2_diff * add1_g2_data + add1_h1_diff * add1_g1_data; set_data(H_diff,num,channels,height,width,n,c,h,w,h_diff); Dtype g1_data = get_gate(G1,num,channels,height,width,n,c,h,w,h-1,w+1,horizontal,reverse); Dtype g2_data = get_gate(G2,num,channels,height,width,n,c,h,w,h,w+1,horizontal,reverse); Dtype g3_data = get_gate(G3,num,channels,height,width,n,c,h,w,h+1,w+1,horizontal,reverse); Dtype x_diff = (1 - g1_data - g2_data - g3_data) * h_diff; set_data(X_diff,num,channels,height,width,n,c,h,w,x_diff); // g_diff = h_diff * (h_data(t-1) - x_data) Dtype h1_minus1_data = get_data(H,num,channels,height,width,n,c,h-1,w+1); Dtype g1_diff = h_diff * (h1_minus1_data - x_data); set_gate(G1_diff,num,channels,height,width,n,c,h,w,h-1,w+1,g1_diff,horizontal,reverse); Dtype h2_minus1_data = get_data(H,num,channels,height,width,n,c,h,w+1); Dtype g2_diff = h_diff * (h2_minus1_data - x_data); set_gate(G2_diff,num,channels,height,width,n,c,h,w,h,w+1,g2_diff,horizontal,reverse); Dtype h3_minus1_data = get_data(H,num,channels,height,width,n,c,h+1,w+1); Dtype g3_diff = h_diff * (h3_minus1_data - x_data); set_gate(G3_diff,num,channels,height,width,n,c,h,w,h+1,w+1,g3_diff,horizontal,reverse); } } template <typename Dtype> __global__ void backward_one_row_top_bottom(const int count, int T, int num,int channels, int height, int width, const Dtype* X, const Dtype* G1, const Dtype* G2, const Dtype* G3, const Dtype* H, Dtype* X_diff, Dtype* G1_diff, Dtype* G2_diff, Dtype* G3_diff, Dtype* H_diff, bool horizontal, bool reverse){ for(int index = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; index < count; index += blockDim.x * gridDim.x * gridDim.y){ //CUDA kernel loop, index trace the current thread int wc_count = width * channels; int n,c,h,w; //w->current_col; n->current_batch; c->current_channel; int temp=index; h = T; n = temp / wc_count; temp = temp % wc_count; c = temp / width; temp = temp % width; w = temp; //locate the pixel as (n,c,h,w); Dtype x_data = get_data(X,num,channels,height,width,n,c,h,w); Dtype h_diff = get_data(H_diff,num,channels,height,width,n,c,h,w); //h(t)_diff += h(t+1)_diff * g(t+1) if t<T Dtype add1_h3_diff = get_data(H_diff,num,channels,height,width,n,c,h+1,w-1); Dtype add1_g3_data = get_gate(G3,num,channels,height,width,n,c,h,w,h+1,w-1,horizontal,reverse); Dtype add1_h2_diff = get_data(H_diff,num,channels,height,width,n,c,h+1,w); Dtype add1_g2_data = get_gate(G2,num,channels,height,width,n,c,h,w,h+1,w,horizontal,reverse); Dtype add1_h1_diff = get_data(H_diff,num,channels,height,width,n,c,h+1,w+1); Dtype add1_g1_data = get_gate(G1,num,channels,height,width,n,c,h,w,h+1,w+1,horizontal,reverse); h_diff = h_diff + add1_h3_diff * add1_g3_data + add1_h2_diff * add1_g2_data + add1_h1_diff * add1_g1_data; set_data(H_diff,num,channels,height,width,n,c,h,w,h_diff); //x(t)_diff=(1-g(t))*h(t)_diff Dtype g1_data = get_gate(G1,num,channels,height,width,n,c,h,w,h-1,w-1,horizontal,reverse); Dtype g2_data = get_gate(G2,num,channels,height,width,n,c,h,w,h-1,w,horizontal,reverse); Dtype g3_data = get_gate(G3,num,channels,height,width,n,c,h,w,h-1,w+1,horizontal,reverse); Dtype x_diff = (1- g1_data - g2_data - g3_data) * h_diff; set_data(X_diff,num,channels,height,width,n,c,h,w,x_diff); // g_diff = h_diff * (h_data(t-1) - x_data) Dtype h1_minus1_data = get_data(H,num,channels,height,width,n,c,h-1,w-1); Dtype g1_diff = h_diff * (h1_minus1_data - x_data); set_gate(G1_diff,num,channels,height,width,n,c,h,w,h-1,w-1,g1_diff,horizontal,reverse); Dtype h2_minus1_data = get_data(H,num,channels,height,width,n,c,h-1,w); Dtype g2_diff = h_diff * (h2_minus1_data - x_data); set_gate(G2_diff,num,channels,height,width,n,c,h,w,h-1,w,g2_diff,horizontal,reverse); Dtype h3_minus1_data = get_data(H,num,channels,height,width,n,c,h-1,w+1); Dtype g3_diff = h_diff * (h3_minus1_data - x_data); set_gate(G3_diff,num,channels,height,width,n,c,h,w,h-1,w+1,g3_diff,horizontal,reverse); } } template <typename Dtype> __global__ void backward_one_row_bottom_top(const int count, int T, int num, int channels, int height, int width, const Dtype* X, const Dtype* G1, const Dtype* G2, const Dtype* G3, const Dtype* H, Dtype* X_diff, Dtype* G1_diff, Dtype* G2_diff, Dtype* G3_diff, Dtype* H_diff, bool horizontal, bool reverse){ for(int index = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; index < count; index += blockDim.x * gridDim.x * gridDim.y){ //CUDA kernel loop, index trace the current thread int wc_count = width * channels; int n,c,h,w; int temp=index; h = T; n = temp / wc_count; temp = temp % wc_count; c = temp / width; temp = temp % width; w = temp; Dtype x_data = get_data(X,num,channels,height,width,n,c,h,w); //h(t)_diff = top(t)_diff Dtype h_diff = get_data(H_diff,num,channels,height,width,n,c,h,w); //h(t)_diff += h(t+1)_diff * g(t+1) if t<T Dtype add1_h3_diff = get_data(H_diff,num,channels,height,width,n,c,h-1,w-1); Dtype add1_g3_data = get_gate(G3,num,channels,height,width,n,c,h,w,h-1,w-1,horizontal,reverse); Dtype add1_h2_diff = get_data(H_diff,num,channels,height,width,n,c,h-1,w); Dtype add1_g2_data = get_gate(G2,num,channels,height,width,n,c,h,w,h-1,w,horizontal,reverse); Dtype add1_h1_diff = get_data(H_diff,num,channels,height,width,n,c,h-1,w+1); Dtype add1_g1_data = get_gate(G1,num,channels,height,width,n,c,h,w,h-1,w+1,horizontal,reverse); h_diff = h_diff + add1_h3_diff * add1_g3_data + add1_h2_diff * add1_g2_data + add1_h1_diff * add1_g1_data; set_data(H_diff,num,channels,height,width,n,c,h,w,h_diff); //x(t)_diff=(1-g(t))*h(t)_diff Dtype g1_data = get_gate(G1,num,channels,height,width,n,c,h,w,h+1,w-1,horizontal,reverse); Dtype g2_data = get_gate(G2,num,channels,height,width,n,c,h,w,h+1,w,horizontal,reverse); Dtype g3_data = get_gate(G3,num,channels,height,width,n,c,h,w,h+1,w+1,horizontal,reverse); Dtype x_diff = (1- g1_data -g2_data -g3_data) * h_diff; set_data(X_diff,num,channels,height,width,n,c,h,w,x_diff); // g_diff = h_diff * (h_data(t-1) - x_data) Dtype h1_minus1_data = get_data(H,num,channels,height,width,n,c,h+1,w-1); Dtype g1_diff = h_diff * (h1_minus1_data - x_data); set_gate(G1_diff,num,channels,height,width,n,c,h,w,h+1,w-1,g1_diff,horizontal,reverse); //Dtype g2_diff = h_diff * g2_idx * x_data * -1; Dtype h2_minus1_data = get_data(H,num,channels,height,width,n,c,h+1,w); Dtype g2_diff = h_diff * (h2_minus1_data - x_data); set_gate(G2_diff,num,channels,height,width,n,c,h,w,h+1,w,g2_diff,horizontal,reverse); //Dtype g3_diff = h_diff * g3_idx * x_data * -1; Dtype h3_minus1_data = get_data(H,num,channels,height,width,n,c,h+1,w+1); Dtype g3_diff = h_diff * (h3_minus1_data - x_data); set_gate(G3_diff,num,channels,height,width,n,c,h,w,h+1,w+1,g3_diff,horizontal,reverse); } } template<typename Dtype> inline void SPNForward(const Tensor<gpu, 4, Dtype> &data, const Tensor<gpu, 4, Dtype> &g1, const Tensor<gpu, 4, Dtype> &g2, const Tensor<gpu, 4, Dtype> &g3, const Tensor<gpu, 4, Dtype> &out, const bool horizontal_, const bool reverse_){ /*get pointer*/ const Dtype *X = data.dptr_; const Dtype *G1 = g1.dptr_; const Dtype *G2 = g2.dptr_; const Dtype *G3 = g3.dptr_; Dtype *H = out.dptr_; /*END get pointer*/ /*get dimension*/ //data, g1, g2, g3, out, share the same dimension //n_X represent number of X const int n_batch = data.size(0); const int n_channel = data.size(1); const int height = data.size(2); const int width = data.size(3); /*END get dimension*/ /*set cuda system param*/ const int NUM_THREADS_BLOCK = 512; //CUDA: use 512 threads per block const int NUM_BLOCKS_GRID = kMaxGridDim; //CUDA: use largest blocks num per grid /*END set cuda system param*/ /*allocate kernel*/ if(horizontal_ && !reverse_){ // left to right /*logic within this block: *1. calculate total number of execution units that run in parallel *2. calculate block and grid dimension *3. check block/grid dimension, get stream *4. call cuda kernal function*/ const int n_operation_parallel = height * n_channel * n_batch; const int n_blocks_need = ((n_operation_parallel - 1) / NUM_THREADS_BLOCK) + 1; const int n_grids_need = ((n_blocks_need - 1) / NUM_BLOCKS_GRID) + 1; for(int current_col = 0; current_col < width; current_col++){ //iterate through the column dim3 dimGrid(NUM_BLOCKS_GRID, n_grids_need); dim3 dimBlock(NUM_THREADS_BLOCK); CheckLaunchParam(dimGrid, dimBlock, "SPN left->right forward"); //check whether dimGrid or dimBlock is out of range cudaStream_t stream = Stream<gpu>::GetStream(out.stream_); //??not sure where to find the definition of stream_ forward_one_col_left_right<Dtype><<<dimGrid, dimBlock, 0, stream>>>(n_operation_parallel, current_col, n_batch, n_channel, height, width, X, G1, G2, G3, H, horizontal_, reverse_); } }else if(horizontal_ && reverse_){ // right to left /*logic same as previous*/ const int n_operation_parallel = height * n_channel * n_batch; //total number of execution units that run in parallel const int n_blocks_need = ((n_operation_parallel - 1) / NUM_THREADS_BLOCK) + 1; const int n_grids_need = ((n_blocks_need - 1) / NUM_BLOCKS_GRID) + 1; for(int current_col = width - 1; current_col >= 0; current_col--){ dim3 dimGrid(NUM_BLOCKS_GRID, n_grids_need); dim3 dimBlock(NUM_THREADS_BLOCK); CheckLaunchParam(dimGrid, dimBlock, "SPN right->left forward"); //check whether dimGrid or dimBlock is out of range cudaStream_t stream = Stream<gpu>::GetStream(out.stream_); //??not sure where to find the definition of stream_ forward_one_col_right_left<Dtype><<<dimGrid, dimBlock, 0, stream>>>(n_operation_parallel, current_col, n_batch, n_channel, height, width, X, G1, G2, G3, H, horizontal_, reverse_); } }else if(!horizontal_ && !reverse_){ // top to bottom /*logic same as previous*/ const int n_operation_parallel = width * n_channel * n_batch; //total number of execution units that run in parallel const int n_blocks_need = ((n_operation_parallel - 1) / NUM_THREADS_BLOCK) + 1; const int n_grids_need = ((n_blocks_need - 1) / NUM_BLOCKS_GRID) + 1; for(int current_row = 0; current_row < height; current_row++){ dim3 dimGrid(NUM_BLOCKS_GRID, n_grids_need); dim3 dimBlock(NUM_THREADS_BLOCK); CheckLaunchParam(dimGrid, dimBlock, "SPN top->bottom forward"); //check whether dimGrid or dimBlock is out of range cudaStream_t stream = Stream<gpu>::GetStream(out.stream_); //??not sure where to find the definition of stream_ forward_one_row_top_bottom<Dtype><<<dimGrid, dimBlock, 0, stream>>>(n_operation_parallel, current_row, n_batch, n_channel, height, width, X, G1, G2, G3, H, horizontal_, reverse_); } }else{ //bottom to top /*logic same as previous*/ const int n_operation_parallel = width * n_channel * n_batch; //total number of execution units that run in parallel const int n_blocks_need = ((n_operation_parallel - 1) / NUM_THREADS_BLOCK) + 1; const int n_grids_need = ((n_blocks_need - 1) / NUM_BLOCKS_GRID) + 1; for(int current_row = height - 1; current_row >= 0; current_row--){ dim3 dimGrid(NUM_BLOCKS_GRID, n_grids_need); dim3 dimBlock(NUM_THREADS_BLOCK); CheckLaunchParam(dimGrid, dimBlock, "SPN bottom->top forward"); //check whether dimGrid or dimBlock is out of range cudaStream_t stream = Stream<gpu>::GetStream(out.stream_); //??not sure where to find the definition of stream_ forward_one_row_bottom_top<Dtype><<<dimGrid, dimBlock, 0, stream>>>(n_operation_parallel, current_row, n_batch, n_channel, height, width, X, G1, G2, G3, H, horizontal_, reverse_); } } /*END allocate kernel*/ }//end SPNForward template<typename Dtype> inline void SPNBackward(const Tensor<gpu, 4, Dtype> &data, const Tensor<gpu, 4, Dtype> &g1, const Tensor<gpu, 4, Dtype> &g2, const Tensor<gpu, 4, Dtype> &g3, const Tensor<gpu, 4, Dtype> &out, const Tensor<gpu, 4, Dtype> &data_diff, const Tensor<gpu, 4, Dtype> &g1_diff, const Tensor<gpu, 4, Dtype> &g2_diff, const Tensor<gpu, 4, Dtype> &g3_diff, const Tensor<gpu, 4, Dtype> &out_diff, const bool horizontal_, const bool reverse_){ /*get pointer*/ const Dtype *X = data.dptr_; const Dtype *G1 = g1.dptr_; const Dtype *G2 = g2.dptr_; const Dtype *G3 = g3.dptr_; const Dtype *H = out.dptr_; Dtype *X_diff = data_diff.dptr_; Dtype *G1_diff = g1_diff.dptr_; Dtype *G2_diff = g2_diff.dptr_; Dtype *G3_diff = g3_diff.dptr_; Dtype *H_diff = out_diff.dptr_; /*END get pointer*/ /*get dimension*/ //data, g1, g2, g3, out, share the same dimension //n_X represent number of X const int n_batch = data.size(0); const int n_channel = data.size(1); const int height = data.size(2); const int width = data.size(3); /*END get dimension*/ /*set cuda system param*/ const int NUM_THREADS_BLOCK = 512; //CUDA: use 512 threads per block const int NUM_BLOCKS_GRID = kMaxGridDim; //CUDA: use largest blocks num per grid /*END set cuda system param*/ /*allocate kernel*/ if(horizontal_ && !reverse_){ // left to right /*logic within this block: *1. calculate total number of execution units that run in parallel *2. calculate block and grid dimension *3. check block/grid dimension, get stream *4. call cuda kernal function*/ const int n_operation_parallel = height * n_channel * n_batch; const int n_blocks_need = ((n_operation_parallel - 1) / NUM_THREADS_BLOCK) + 1; const int n_grids_need = ((n_blocks_need - 1) / NUM_BLOCKS_GRID) + 1; for(int current_col = width - 1; current_col >= 0; current_col--){ //iterate through the column dim3 dimGrid(NUM_BLOCKS_GRID, n_grids_need); dim3 dimBlock(NUM_THREADS_BLOCK); CheckLaunchParam(dimGrid, dimBlock, "SPN left->right backward"); //check whether dimGrid or dimBlock is out of range cudaStream_t stream = Stream<gpu>::GetStream(out.stream_); //??not sure where to find the definition of stream_ backward_one_col_left_right<Dtype><<<dimGrid, dimBlock, 0, stream>>>(n_operation_parallel, current_col, n_batch, n_channel, height, width, X, G1, G2, G3, H, X_diff, G1_diff, G2_diff, G3_diff, H_diff, horizontal_, reverse_); } }else if(horizontal_ && reverse_){ // right to left /*logic same as previous*/ const int n_operation_parallel = height * n_channel * n_batch; //total number of execution units that run in parallel const int n_blocks_need = ((n_operation_parallel - 1) / NUM_THREADS_BLOCK) + 1; const int n_grids_need = ((n_blocks_need - 1) / NUM_BLOCKS_GRID) + 1; for(int current_col = 0; current_col < width; current_col++){ dim3 dimGrid(NUM_BLOCKS_GRID, n_grids_need); dim3 dimBlock(NUM_THREADS_BLOCK); CheckLaunchParam(dimGrid, dimBlock, "SPN right->left backward"); //check whether dimGrid or dimBlock is out of range cudaStream_t stream = Stream<gpu>::GetStream(out.stream_); //??not sure where to find the definition of stream_ backward_one_col_right_left<Dtype><<<dimGrid, dimBlock, 0, stream>>>(n_operation_parallel, current_col, n_batch, n_channel, height, width, X, G1, G2, G3, H, X_diff, G1_diff, G2_diff, G3_diff, H_diff, horizontal_, reverse_); } }else if(!horizontal_ && !reverse_){ // top to bottom /*logic same as previous*/ const int n_operation_parallel = width * n_channel * n_batch; //total number of execution units that run in parallel const int n_blocks_need = ((n_operation_parallel - 1) / NUM_THREADS_BLOCK) + 1; const int n_grids_need = ((n_blocks_need - 1) / NUM_BLOCKS_GRID) + 1; for(int current_row = height - 1; current_row >= 0; current_row--){ dim3 dimGrid(NUM_BLOCKS_GRID, n_grids_need); dim3 dimBlock(NUM_THREADS_BLOCK); CheckLaunchParam(dimGrid, dimBlock, "SPN top->bottom backward"); //check whether dimGrid or dimBlock is out of range cudaStream_t stream = Stream<gpu>::GetStream(out.stream_); //??not sure where to find the definition of stream_ backward_one_row_top_bottom<Dtype><<<dimGrid, dimBlock, 0, stream>>>(n_operation_parallel, current_row, n_batch, n_channel, height, width, X, G1, G2, G3, H, X_diff, G1_diff, G2_diff, G3_diff, H_diff, horizontal_, reverse_); } }else{ //bottom to top /*logic same as previous*/ const int n_operation_parallel = width * n_channel * n_batch; //total number of execution units that run in parallel const int n_blocks_need = ((n_operation_parallel - 1) / NUM_THREADS_BLOCK) + 1; const int n_grids_need = ((n_blocks_need - 1) / NUM_BLOCKS_GRID) + 1; for(int current_row = 0; current_row < width; current_row++){ dim3 dimGrid(NUM_BLOCKS_GRID, n_grids_need); dim3 dimBlock(NUM_THREADS_BLOCK); CheckLaunchParam(dimGrid, dimBlock, "SPN bottom->top backward"); //check whether dimGrid or dimBlock is out of range cudaStream_t stream = Stream<gpu>::GetStream(out.stream_); //??not sure where to find the definition of stream_ backward_one_row_bottom_top<Dtype><<<dimGrid, dimBlock, 0, stream>>>(n_operation_parallel, current_row, n_batch, n_channel, height, width, X, G1, G2, G3, H, X_diff, G1_diff, G2_diff, G3_diff, H_diff, horizontal_, reverse_); } } /*END allocate kernel*/ }//end SPNBackward } //namespace cuda template<typename Dtype> inline void SPNForward(const Tensor<gpu, 4, Dtype> &data, const Tensor<gpu, 4, Dtype> &g1, const Tensor<gpu, 4, Dtype> &g2, const Tensor<gpu, 4, Dtype> &g3, const Tensor<gpu, 4, Dtype> &out, const bool horizontal, const bool reverse){ cuda::SPNForward(data, g1, g2, g3, out, horizontal, reverse); } template<typename Dtype> inline void SPNBackward(const Tensor<gpu, 4, Dtype> &data, const Tensor<gpu, 4, Dtype> &g1, const Tensor<gpu, 4, Dtype> &g2, const Tensor<gpu, 4, Dtype> &g3, const Tensor<gpu, 4, Dtype> &out, const Tensor<gpu, 4, Dtype> &data_diff, const Tensor<gpu, 4, Dtype> &g1_diff, const Tensor<gpu, 4, Dtype> &g2_diff, const Tensor<gpu, 4, Dtype> &g3_diff, const Tensor<gpu, 4, Dtype> &out_diff, const bool horizontal, const bool reverse){ cuda::SPNBackward(data, g1, g2, g3, out, data_diff, g1_diff, g2_diff, g3_diff, out_diff, horizontal, reverse); } } //namespace mshadow namespace mxnet { namespace op { template<> Operator* CreateOp<gpu>(SpnParam param, int dtype) { Operator *op = NULL; MSHADOW_REAL_TYPE_SWITCH(dtype, DType, { op = new SpnOp<gpu, DType>(param); }) return op; } } // namespace op } // namespace mxnet
559df37012d117f28e3d20d6c2196e92c7d2e59c.hip
// !!! This is a file automatically generated by hipify!!! #include "op_lib.cu" #import "op_datatypes.cpp" __constant__ float gam; __constant__ float gm1; __constant__ float cfl; __constant__ float eps; __constant__ float mach; __constant__ float alpha; __constant__ myconst air_const; #include "adt_calc_kernel.hip" #include "res_calc_kernel.cu" #include "save_soln_kernel.cu" #include "update_kernel.hip"
559df37012d117f28e3d20d6c2196e92c7d2e59c.cu
#include "op_lib.cu" #import "op_datatypes.cpp" __constant__ float gam; __constant__ float gm1; __constant__ float cfl; __constant__ float eps; __constant__ float mach; __constant__ float alpha; __constant__ myconst air_const; #include "adt_calc_kernel.cu" #include "res_calc_kernel.cu" #include "save_soln_kernel.cu" #include "update_kernel.cu"
cc9a984ce7ac34603881f92f5b80815708a025cb.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" extern "C" { __global__ void add(int *c, const int *a, const int *b) { int i = threadIdx.x; c[i] = a[i] + b[i]; } }
cc9a984ce7ac34603881f92f5b80815708a025cb.cu
extern "C" { __global__ void add(int *c, const int *a, const int *b) { int i = threadIdx.x; c[i] = a[i] + b[i]; } }
b268b17e4eb905922e666a2e8de72c8dfc2d5428.hip
// !!! This is a file automatically generated by hipify!!! #include "hip/hip_runtime.h" /* Copyright 2020 The OneFlow Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "oneflow/core/framework/framework.h" #include "oneflow/core/kernel/new_kernel_util.h" #include "oneflow/core/common/nd_index_offset_helper.h" namespace oneflow { namespace { __device__ int64_t GetNearestInputIndex(const int64_t out_dim_idx, const float scale, const int64_t in_dim_size) { return max(min(static_cast<int64_t>(floorf((static_cast<float>(out_dim_idx) + 0.5f) * scale)), in_dim_size - 1), static_cast<int64_t>(0)); } template<typename T> __global__ void UpsampleNearestForward(const int64_t elem_cnt, const T* in_dptr, NdIndexOffsetHelper<int64_t, 4> in_helper, NdIndexOffsetHelper<int64_t, 4> out_helper, const int64_t in_height, const int64_t in_width, const float scale_h, const float scale_w, T* out_dptr) { CUDA_1D_KERNEL_LOOP(index, elem_cnt) { int64_t n, c, h, w; out_helper.OffsetToNdIndex(index, n, c, h, w); const int64_t in_h = GetNearestInputIndex(h, scale_h, in_height); const int64_t in_w = GetNearestInputIndex(w, scale_w, in_width); out_dptr[index] = in_dptr[in_helper.NdIndexToOffset(n, c, in_h, in_w)]; } } template<typename T> __global__ void UpsampleNearestBackward(const int64_t elem_cnt, const T* dy_dptr, NdIndexOffsetHelper<int64_t, 4> dy_helper, NdIndexOffsetHelper<int64_t, 4> dx_helper, const int64_t dx_height, const int64_t dx_width, const float scale_h, const float scale_w, T* dx_dptr) { CUDA_1D_KERNEL_LOOP(index, elem_cnt) { int64_t n, c, h, w; dy_helper.OffsetToNdIndex(index, n, c, h, w); const int64_t dx_h = GetNearestInputIndex(h, scale_h, dx_height); const int64_t dx_w = GetNearestInputIndex(w, scale_w, dx_width); atomicAdd(dx_dptr + dx_helper.NdIndexToOffset(n, c, dx_h, dx_w), dy_dptr[index]); } } struct BilinearParam { int64_t top_h_index; int64_t bottom_h_index; int64_t left_w_index; int64_t right_w_index; float w_lerp; float h_lerp; }; __device__ void GetBilinearParam(const int64_t index, const int64_t h, const int64_t w, const int64_t in_height, const int64_t in_width, const float scale_h, const float scale_w, BilinearParam* params) { const float in_h = (static_cast<float>(h) + 0.5f) * scale_h - 0.5f; const float in_w = (static_cast<float>(w) + 0.5f) * scale_w - 0.5f; params->top_h_index = in_h > 0.0 ? floorf(in_h) : 0; params->bottom_h_index = (in_h < in_height - 1) ? ceilf(in_h) : in_height - 1; params->h_lerp = in_h - floorf(in_h); params->left_w_index = in_w > 0.0 ? floorf(in_w) : 0; params->right_w_index = (in_w < in_width - 1) ? ceilf(in_w) : in_width - 1; params->w_lerp = in_w - floorf(in_w); } template<typename T> __global__ void UpsampleBilinearForward(const int64_t elem_cnt, const T* in_dptr, NdIndexOffsetHelper<int64_t, 4> in_helper, NdIndexOffsetHelper<int64_t, 4> out_helper, const int64_t in_height, const int64_t in_width, const float scale_h, const float scale_w, T* out_dptr) { CUDA_1D_KERNEL_LOOP(index, elem_cnt) { int64_t n, c, h, w; out_helper.OffsetToNdIndex(index, n, c, h, w); BilinearParam params; GetBilinearParam(index, h, w, in_height, in_width, scale_h, scale_w, &params); const int64_t top_offset = in_helper.NdIndexToOffset(n, c, params.top_h_index, 0); const int64_t bottom_offset = in_helper.NdIndexToOffset(n, c, params.bottom_h_index, 0); const float top_left = in_dptr[top_offset + params.left_w_index]; const float top_right = in_dptr[top_offset + params.right_w_index]; const float bottom_left = in_dptr[bottom_offset + params.left_w_index]; const float bottom_right = in_dptr[bottom_offset + params.right_w_index]; const float top = top_left + (top_right - top_left) * params.w_lerp; const float bottom = bottom_left + (bottom_right - bottom_left) * params.w_lerp; out_dptr[index] = top + (bottom - top) * params.h_lerp; } } template<typename T> __global__ void UpsampleBilinearBackward(const int64_t elem_cnt, const T* dy_dptr, NdIndexOffsetHelper<int64_t, 4> dy_helper, NdIndexOffsetHelper<int64_t, 4> dx_helper, const int64_t dx_height, const int64_t dx_width, const float scale_h, const float scale_w, T* dx_dptr) { CUDA_1D_KERNEL_LOOP(index, elem_cnt) { int64_t n, c, h, w; dy_helper.OffsetToNdIndex(index, n, c, h, w); BilinearParam params; GetBilinearParam(index, h, w, dx_height, dx_width, scale_h, scale_w, &params); const int64_t top_offset = dx_helper.NdIndexToOffset(n, c, params.top_h_index, 0); const int64_t bottom_offset = dx_helper.NdIndexToOffset(n, c, params.bottom_h_index, 0); const T dy = dy_dptr[index]; const float dbottom = params.h_lerp * dy; T* dx_dptr_bottom_offset = dx_dptr + bottom_offset; atomicAdd(dx_dptr_bottom_offset + params.left_w_index, static_cast<T>((1 - params.w_lerp) * dbottom)); atomicAdd(dx_dptr_bottom_offset + params.right_w_index, static_cast<T>(params.w_lerp * dbottom)); const float dtop = dy - dbottom; T* dx_dptr_top_offset = dx_dptr + top_offset; atomicAdd(dx_dptr_top_offset + params.left_w_index, static_cast<T>((1 - params.w_lerp) * dtop)); atomicAdd(dx_dptr_top_offset + params.right_w_index, static_cast<T>(params.w_lerp * dtop)); } } } // namespace template<typename T> class UpsampleNearestGPUKernel final : public user_op::OpKernel { public: UpsampleNearestGPUKernel() = default; ~UpsampleNearestGPUKernel() = default; private: void Compute(user_op::KernelComputeContext* ctx) const override { const user_op::Tensor* x_blob = ctx->Tensor4ArgNameAndIndex("x", 0); user_op::Tensor* y_blob = ctx->Tensor4ArgNameAndIndex("y", 0); const float height_scale = ctx->Attr<float>("height_scale"); const float width_scale = ctx->Attr<float>("width_scale"); const int64_t elem_cnt = y_blob->shape().elem_cnt(); NdIndexOffsetHelper<int64_t, 4> in_helper(x_blob->shape().At(0), x_blob->shape().At(1), x_blob->shape().At(2), x_blob->shape().At(3)); NdIndexOffsetHelper<int64_t, 4> out_helper(y_blob->shape().At(0), y_blob->shape().At(1), y_blob->shape().At(2), y_blob->shape().At(3)); RUN_CUDA_KERNEL((UpsampleNearestForward<T>), ctx->device_ctx(), elem_cnt, elem_cnt, x_blob->dptr<T>(), in_helper, out_helper, x_blob->shape().At(2), x_blob->shape().At(3), 1.f / height_scale, 1.f / width_scale, y_blob->mut_dptr<T>()); } bool AlwaysComputeWhenAllOutputsEmpty() const override { return false; } }; template<typename T> class UpsampleNearestGradGPUKernel final : public user_op::OpKernel { public: UpsampleNearestGradGPUKernel() = default; ~UpsampleNearestGradGPUKernel() = default; private: void Compute(user_op::KernelComputeContext* ctx) const override { user_op::Tensor* dx_blob = ctx->Tensor4ArgNameAndIndex("dx", 0); if (dx_blob == nullptr) { return; } Memset<DeviceType::kGPU>(ctx->device_ctx(), dx_blob->mut_dptr<T>(), 0, dx_blob->shape().elem_cnt() * sizeof(T)); const user_op::Tensor* dy_blob = ctx->Tensor4ArgNameAndIndex("dy", 0); const float height_scale = ctx->Attr<float>("height_scale"); const float width_scale = ctx->Attr<float>("width_scale"); const int64_t elem_cnt = dy_blob->shape().elem_cnt(); NdIndexOffsetHelper<int64_t, 4> dy_helper(dy_blob->shape().At(0), dy_blob->shape().At(1), dy_blob->shape().At(2), dy_blob->shape().At(3)); NdIndexOffsetHelper<int64_t, 4> dx_helper(dx_blob->shape().At(0), dx_blob->shape().At(1), dx_blob->shape().At(2), dx_blob->shape().At(3)); RUN_CUDA_KERNEL((UpsampleNearestBackward<T>), ctx->device_ctx(), elem_cnt, elem_cnt, dy_blob->dptr<T>(), dy_helper, dx_helper, dx_blob->shape().At(2), dx_blob->shape().At(3), 1.f / height_scale, 1.f / width_scale, dx_blob->mut_dptr<T>()); } bool AlwaysComputeWhenAllOutputsEmpty() const override { return false; } }; #define REGISTER_UPSAMPLE_NEAREST_GPU_KERNEL(dtype) \ REGISTER_USER_KERNEL("upsample") \ .SetCreateFn<UpsampleNearestGPUKernel<dtype>>() \ .SetIsMatchedHob( \ (user_op::HobDeviceTag() == "gpu") \ & (user_op::HobDataType("y", 0) == GetDataType<dtype>::value) \ & (user_op::HobAttr<std::string>("interpolation") == std::string("nearest"))); \ REGISTER_USER_KERNEL("upsample_grad") \ .SetCreateFn<UpsampleNearestGradGPUKernel<dtype>>() \ .SetIsMatchedHob( \ (user_op::HobDeviceTag() == "gpu") \ & (user_op::HobDataType("dx", 0) == GetDataType<dtype>::value) \ & (user_op::HobAttr<std::string>("interpolation") == std::string("nearest"))); REGISTER_UPSAMPLE_NEAREST_GPU_KERNEL(float) REGISTER_UPSAMPLE_NEAREST_GPU_KERNEL(double) template<typename T> class UpsampleBilinearGPUKernel final : public user_op::OpKernel { public: UpsampleBilinearGPUKernel() = default; ~UpsampleBilinearGPUKernel() = default; private: void Compute(user_op::KernelComputeContext* ctx) const override { const user_op::Tensor* x_blob = ctx->Tensor4ArgNameAndIndex("x", 0); user_op::Tensor* y_blob = ctx->Tensor4ArgNameAndIndex("y", 0); const float height_scale = ctx->Attr<float>("height_scale"); const float width_scale = ctx->Attr<float>("width_scale"); const int64_t elem_cnt = y_blob->shape().elem_cnt(); NdIndexOffsetHelper<int64_t, 4> in_helper(x_blob->shape().At(0), x_blob->shape().At(1), x_blob->shape().At(2), x_blob->shape().At(3)); NdIndexOffsetHelper<int64_t, 4> out_helper(y_blob->shape().At(0), y_blob->shape().At(1), y_blob->shape().At(2), y_blob->shape().At(3)); RUN_CUDA_KERNEL((UpsampleBilinearForward<T>), ctx->device_ctx(), elem_cnt, elem_cnt, x_blob->dptr<T>(), in_helper, out_helper, x_blob->shape().At(2), x_blob->shape().At(3), 1.f / height_scale, 1.f / width_scale, y_blob->mut_dptr<T>()); } bool AlwaysComputeWhenAllOutputsEmpty() const override { return false; } }; template<typename T> class UpsampleBilinearGradGPUKernel final : public user_op::OpKernel { public: UpsampleBilinearGradGPUKernel() = default; ~UpsampleBilinearGradGPUKernel() = default; private: void Compute(user_op::KernelComputeContext* ctx) const override { user_op::Tensor* dx_blob = ctx->Tensor4ArgNameAndIndex("dx", 0); if (dx_blob == nullptr) { return; } Memset<DeviceType::kGPU>(ctx->device_ctx(), dx_blob->mut_dptr<T>(), 0, dx_blob->shape().elem_cnt() * sizeof(T)); const user_op::Tensor* dy_blob = ctx->Tensor4ArgNameAndIndex("dy", 0); const float height_scale = ctx->Attr<float>("height_scale"); const float width_scale = ctx->Attr<float>("width_scale"); const int64_t elem_cnt = dy_blob->shape().elem_cnt(); NdIndexOffsetHelper<int64_t, 4> dy_helper(dy_blob->shape().At(0), dy_blob->shape().At(1), dy_blob->shape().At(2), dy_blob->shape().At(3)); NdIndexOffsetHelper<int64_t, 4> dx_helper(dx_blob->shape().At(0), dx_blob->shape().At(1), dx_blob->shape().At(2), dx_blob->shape().At(3)); RUN_CUDA_KERNEL((UpsampleBilinearBackward<T>), ctx->device_ctx(), elem_cnt, elem_cnt, dy_blob->dptr<T>(), dy_helper, dx_helper, dx_blob->shape().At(2), dx_blob->shape().At(3), 1.f / height_scale, 1.f / width_scale, dx_blob->mut_dptr<T>()); } bool AlwaysComputeWhenAllOutputsEmpty() const override { return false; } }; #define REGISTER_UPSAMPLE_BILINEAR_GPU_KERNEL(dtype) \ REGISTER_USER_KERNEL("upsample") \ .SetCreateFn<UpsampleBilinearGPUKernel<dtype>>() \ .SetIsMatchedHob( \ (user_op::HobDeviceTag() == "gpu") \ & (user_op::HobDataType("y", 0) == GetDataType<dtype>::value) \ & (user_op::HobAttr<std::string>("interpolation") == std::string("bilinear"))); \ REGISTER_USER_KERNEL("upsample_grad") \ .SetCreateFn<UpsampleBilinearGradGPUKernel<dtype>>() \ .SetIsMatchedHob( \ (user_op::HobDeviceTag() == "gpu") \ & (user_op::HobDataType("dx", 0) == GetDataType<dtype>::value) \ & (user_op::HobAttr<std::string>("interpolation") == std::string("bilinear"))); REGISTER_UPSAMPLE_BILINEAR_GPU_KERNEL(float) REGISTER_UPSAMPLE_BILINEAR_GPU_KERNEL(double) } // namespace oneflow
b268b17e4eb905922e666a2e8de72c8dfc2d5428.cu
/* Copyright 2020 The OneFlow Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "oneflow/core/framework/framework.h" #include "oneflow/core/kernel/new_kernel_util.h" #include "oneflow/core/common/nd_index_offset_helper.h" namespace oneflow { namespace { __device__ int64_t GetNearestInputIndex(const int64_t out_dim_idx, const float scale, const int64_t in_dim_size) { return max(min(static_cast<int64_t>(floorf((static_cast<float>(out_dim_idx) + 0.5f) * scale)), in_dim_size - 1), static_cast<int64_t>(0)); } template<typename T> __global__ void UpsampleNearestForward(const int64_t elem_cnt, const T* in_dptr, NdIndexOffsetHelper<int64_t, 4> in_helper, NdIndexOffsetHelper<int64_t, 4> out_helper, const int64_t in_height, const int64_t in_width, const float scale_h, const float scale_w, T* out_dptr) { CUDA_1D_KERNEL_LOOP(index, elem_cnt) { int64_t n, c, h, w; out_helper.OffsetToNdIndex(index, n, c, h, w); const int64_t in_h = GetNearestInputIndex(h, scale_h, in_height); const int64_t in_w = GetNearestInputIndex(w, scale_w, in_width); out_dptr[index] = in_dptr[in_helper.NdIndexToOffset(n, c, in_h, in_w)]; } } template<typename T> __global__ void UpsampleNearestBackward(const int64_t elem_cnt, const T* dy_dptr, NdIndexOffsetHelper<int64_t, 4> dy_helper, NdIndexOffsetHelper<int64_t, 4> dx_helper, const int64_t dx_height, const int64_t dx_width, const float scale_h, const float scale_w, T* dx_dptr) { CUDA_1D_KERNEL_LOOP(index, elem_cnt) { int64_t n, c, h, w; dy_helper.OffsetToNdIndex(index, n, c, h, w); const int64_t dx_h = GetNearestInputIndex(h, scale_h, dx_height); const int64_t dx_w = GetNearestInputIndex(w, scale_w, dx_width); atomicAdd(dx_dptr + dx_helper.NdIndexToOffset(n, c, dx_h, dx_w), dy_dptr[index]); } } struct BilinearParam { int64_t top_h_index; int64_t bottom_h_index; int64_t left_w_index; int64_t right_w_index; float w_lerp; float h_lerp; }; __device__ void GetBilinearParam(const int64_t index, const int64_t h, const int64_t w, const int64_t in_height, const int64_t in_width, const float scale_h, const float scale_w, BilinearParam* params) { const float in_h = (static_cast<float>(h) + 0.5f) * scale_h - 0.5f; const float in_w = (static_cast<float>(w) + 0.5f) * scale_w - 0.5f; params->top_h_index = in_h > 0.0 ? floorf(in_h) : 0; params->bottom_h_index = (in_h < in_height - 1) ? ceilf(in_h) : in_height - 1; params->h_lerp = in_h - floorf(in_h); params->left_w_index = in_w > 0.0 ? floorf(in_w) : 0; params->right_w_index = (in_w < in_width - 1) ? ceilf(in_w) : in_width - 1; params->w_lerp = in_w - floorf(in_w); } template<typename T> __global__ void UpsampleBilinearForward(const int64_t elem_cnt, const T* in_dptr, NdIndexOffsetHelper<int64_t, 4> in_helper, NdIndexOffsetHelper<int64_t, 4> out_helper, const int64_t in_height, const int64_t in_width, const float scale_h, const float scale_w, T* out_dptr) { CUDA_1D_KERNEL_LOOP(index, elem_cnt) { int64_t n, c, h, w; out_helper.OffsetToNdIndex(index, n, c, h, w); BilinearParam params; GetBilinearParam(index, h, w, in_height, in_width, scale_h, scale_w, &params); const int64_t top_offset = in_helper.NdIndexToOffset(n, c, params.top_h_index, 0); const int64_t bottom_offset = in_helper.NdIndexToOffset(n, c, params.bottom_h_index, 0); const float top_left = in_dptr[top_offset + params.left_w_index]; const float top_right = in_dptr[top_offset + params.right_w_index]; const float bottom_left = in_dptr[bottom_offset + params.left_w_index]; const float bottom_right = in_dptr[bottom_offset + params.right_w_index]; const float top = top_left + (top_right - top_left) * params.w_lerp; const float bottom = bottom_left + (bottom_right - bottom_left) * params.w_lerp; out_dptr[index] = top + (bottom - top) * params.h_lerp; } } template<typename T> __global__ void UpsampleBilinearBackward(const int64_t elem_cnt, const T* dy_dptr, NdIndexOffsetHelper<int64_t, 4> dy_helper, NdIndexOffsetHelper<int64_t, 4> dx_helper, const int64_t dx_height, const int64_t dx_width, const float scale_h, const float scale_w, T* dx_dptr) { CUDA_1D_KERNEL_LOOP(index, elem_cnt) { int64_t n, c, h, w; dy_helper.OffsetToNdIndex(index, n, c, h, w); BilinearParam params; GetBilinearParam(index, h, w, dx_height, dx_width, scale_h, scale_w, &params); const int64_t top_offset = dx_helper.NdIndexToOffset(n, c, params.top_h_index, 0); const int64_t bottom_offset = dx_helper.NdIndexToOffset(n, c, params.bottom_h_index, 0); const T dy = dy_dptr[index]; const float dbottom = params.h_lerp * dy; T* dx_dptr_bottom_offset = dx_dptr + bottom_offset; atomicAdd(dx_dptr_bottom_offset + params.left_w_index, static_cast<T>((1 - params.w_lerp) * dbottom)); atomicAdd(dx_dptr_bottom_offset + params.right_w_index, static_cast<T>(params.w_lerp * dbottom)); const float dtop = dy - dbottom; T* dx_dptr_top_offset = dx_dptr + top_offset; atomicAdd(dx_dptr_top_offset + params.left_w_index, static_cast<T>((1 - params.w_lerp) * dtop)); atomicAdd(dx_dptr_top_offset + params.right_w_index, static_cast<T>(params.w_lerp * dtop)); } } } // namespace template<typename T> class UpsampleNearestGPUKernel final : public user_op::OpKernel { public: UpsampleNearestGPUKernel() = default; ~UpsampleNearestGPUKernel() = default; private: void Compute(user_op::KernelComputeContext* ctx) const override { const user_op::Tensor* x_blob = ctx->Tensor4ArgNameAndIndex("x", 0); user_op::Tensor* y_blob = ctx->Tensor4ArgNameAndIndex("y", 0); const float height_scale = ctx->Attr<float>("height_scale"); const float width_scale = ctx->Attr<float>("width_scale"); const int64_t elem_cnt = y_blob->shape().elem_cnt(); NdIndexOffsetHelper<int64_t, 4> in_helper(x_blob->shape().At(0), x_blob->shape().At(1), x_blob->shape().At(2), x_blob->shape().At(3)); NdIndexOffsetHelper<int64_t, 4> out_helper(y_blob->shape().At(0), y_blob->shape().At(1), y_blob->shape().At(2), y_blob->shape().At(3)); RUN_CUDA_KERNEL((UpsampleNearestForward<T>), ctx->device_ctx(), elem_cnt, elem_cnt, x_blob->dptr<T>(), in_helper, out_helper, x_blob->shape().At(2), x_blob->shape().At(3), 1.f / height_scale, 1.f / width_scale, y_blob->mut_dptr<T>()); } bool AlwaysComputeWhenAllOutputsEmpty() const override { return false; } }; template<typename T> class UpsampleNearestGradGPUKernel final : public user_op::OpKernel { public: UpsampleNearestGradGPUKernel() = default; ~UpsampleNearestGradGPUKernel() = default; private: void Compute(user_op::KernelComputeContext* ctx) const override { user_op::Tensor* dx_blob = ctx->Tensor4ArgNameAndIndex("dx", 0); if (dx_blob == nullptr) { return; } Memset<DeviceType::kGPU>(ctx->device_ctx(), dx_blob->mut_dptr<T>(), 0, dx_blob->shape().elem_cnt() * sizeof(T)); const user_op::Tensor* dy_blob = ctx->Tensor4ArgNameAndIndex("dy", 0); const float height_scale = ctx->Attr<float>("height_scale"); const float width_scale = ctx->Attr<float>("width_scale"); const int64_t elem_cnt = dy_blob->shape().elem_cnt(); NdIndexOffsetHelper<int64_t, 4> dy_helper(dy_blob->shape().At(0), dy_blob->shape().At(1), dy_blob->shape().At(2), dy_blob->shape().At(3)); NdIndexOffsetHelper<int64_t, 4> dx_helper(dx_blob->shape().At(0), dx_blob->shape().At(1), dx_blob->shape().At(2), dx_blob->shape().At(3)); RUN_CUDA_KERNEL((UpsampleNearestBackward<T>), ctx->device_ctx(), elem_cnt, elem_cnt, dy_blob->dptr<T>(), dy_helper, dx_helper, dx_blob->shape().At(2), dx_blob->shape().At(3), 1.f / height_scale, 1.f / width_scale, dx_blob->mut_dptr<T>()); } bool AlwaysComputeWhenAllOutputsEmpty() const override { return false; } }; #define REGISTER_UPSAMPLE_NEAREST_GPU_KERNEL(dtype) \ REGISTER_USER_KERNEL("upsample") \ .SetCreateFn<UpsampleNearestGPUKernel<dtype>>() \ .SetIsMatchedHob( \ (user_op::HobDeviceTag() == "gpu") \ & (user_op::HobDataType("y", 0) == GetDataType<dtype>::value) \ & (user_op::HobAttr<std::string>("interpolation") == std::string("nearest"))); \ REGISTER_USER_KERNEL("upsample_grad") \ .SetCreateFn<UpsampleNearestGradGPUKernel<dtype>>() \ .SetIsMatchedHob( \ (user_op::HobDeviceTag() == "gpu") \ & (user_op::HobDataType("dx", 0) == GetDataType<dtype>::value) \ & (user_op::HobAttr<std::string>("interpolation") == std::string("nearest"))); REGISTER_UPSAMPLE_NEAREST_GPU_KERNEL(float) REGISTER_UPSAMPLE_NEAREST_GPU_KERNEL(double) template<typename T> class UpsampleBilinearGPUKernel final : public user_op::OpKernel { public: UpsampleBilinearGPUKernel() = default; ~UpsampleBilinearGPUKernel() = default; private: void Compute(user_op::KernelComputeContext* ctx) const override { const user_op::Tensor* x_blob = ctx->Tensor4ArgNameAndIndex("x", 0); user_op::Tensor* y_blob = ctx->Tensor4ArgNameAndIndex("y", 0); const float height_scale = ctx->Attr<float>("height_scale"); const float width_scale = ctx->Attr<float>("width_scale"); const int64_t elem_cnt = y_blob->shape().elem_cnt(); NdIndexOffsetHelper<int64_t, 4> in_helper(x_blob->shape().At(0), x_blob->shape().At(1), x_blob->shape().At(2), x_blob->shape().At(3)); NdIndexOffsetHelper<int64_t, 4> out_helper(y_blob->shape().At(0), y_blob->shape().At(1), y_blob->shape().At(2), y_blob->shape().At(3)); RUN_CUDA_KERNEL((UpsampleBilinearForward<T>), ctx->device_ctx(), elem_cnt, elem_cnt, x_blob->dptr<T>(), in_helper, out_helper, x_blob->shape().At(2), x_blob->shape().At(3), 1.f / height_scale, 1.f / width_scale, y_blob->mut_dptr<T>()); } bool AlwaysComputeWhenAllOutputsEmpty() const override { return false; } }; template<typename T> class UpsampleBilinearGradGPUKernel final : public user_op::OpKernel { public: UpsampleBilinearGradGPUKernel() = default; ~UpsampleBilinearGradGPUKernel() = default; private: void Compute(user_op::KernelComputeContext* ctx) const override { user_op::Tensor* dx_blob = ctx->Tensor4ArgNameAndIndex("dx", 0); if (dx_blob == nullptr) { return; } Memset<DeviceType::kGPU>(ctx->device_ctx(), dx_blob->mut_dptr<T>(), 0, dx_blob->shape().elem_cnt() * sizeof(T)); const user_op::Tensor* dy_blob = ctx->Tensor4ArgNameAndIndex("dy", 0); const float height_scale = ctx->Attr<float>("height_scale"); const float width_scale = ctx->Attr<float>("width_scale"); const int64_t elem_cnt = dy_blob->shape().elem_cnt(); NdIndexOffsetHelper<int64_t, 4> dy_helper(dy_blob->shape().At(0), dy_blob->shape().At(1), dy_blob->shape().At(2), dy_blob->shape().At(3)); NdIndexOffsetHelper<int64_t, 4> dx_helper(dx_blob->shape().At(0), dx_blob->shape().At(1), dx_blob->shape().At(2), dx_blob->shape().At(3)); RUN_CUDA_KERNEL((UpsampleBilinearBackward<T>), ctx->device_ctx(), elem_cnt, elem_cnt, dy_blob->dptr<T>(), dy_helper, dx_helper, dx_blob->shape().At(2), dx_blob->shape().At(3), 1.f / height_scale, 1.f / width_scale, dx_blob->mut_dptr<T>()); } bool AlwaysComputeWhenAllOutputsEmpty() const override { return false; } }; #define REGISTER_UPSAMPLE_BILINEAR_GPU_KERNEL(dtype) \ REGISTER_USER_KERNEL("upsample") \ .SetCreateFn<UpsampleBilinearGPUKernel<dtype>>() \ .SetIsMatchedHob( \ (user_op::HobDeviceTag() == "gpu") \ & (user_op::HobDataType("y", 0) == GetDataType<dtype>::value) \ & (user_op::HobAttr<std::string>("interpolation") == std::string("bilinear"))); \ REGISTER_USER_KERNEL("upsample_grad") \ .SetCreateFn<UpsampleBilinearGradGPUKernel<dtype>>() \ .SetIsMatchedHob( \ (user_op::HobDeviceTag() == "gpu") \ & (user_op::HobDataType("dx", 0) == GetDataType<dtype>::value) \ & (user_op::HobAttr<std::string>("interpolation") == std::string("bilinear"))); REGISTER_UPSAMPLE_BILINEAR_GPU_KERNEL(float) REGISTER_UPSAMPLE_BILINEAR_GPU_KERNEL(double) } // namespace oneflow