int main() { Foo F; Foo *F2 = new Foo(); new Foo(); Foo(); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type 'Foo' is prohibited Foo F3 = Foo(); // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: creating a temporary object of type 'Foo' is prohibited Bar(); NS::Bar(); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type 'NS::Bar' is prohibited int A = func(Foo()); // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: creating a temporary object of type 'Foo' is prohibited Foo F4(0); Foo *F5 = new Foo(0); new Foo(0); Foo(0); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type 'Foo' is prohibited Foo F6 = Foo(0); // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: creating a temporary object of type 'Foo' is prohibited Bar(0); NS::Bar(0); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type 'NS::Bar' is prohibited int B = func(Foo(0)); // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: creating a temporary object of type 'Foo' is prohibited }
int main() { auto a1 = F1(); auto a2 = F2(); auto a3 = F3(); auto a4 = F4(); auto a5 = F5(); return 0; }
seconlevel_f4::seconlevel_f4(QWidget *parent) : QWidget(parent), ui(new Ui::seconlevel_f4) { ui->setupUi(this); group = new GroupDialog(parent); group->hide(); connect(group ,SIGNAL(finished(int)) ,this ,SLOT(f1_Done(int))); autotab = new AutoDialog(parent); autotab->hide(); connect(autotab ,SIGNAL(finished(int)) ,this ,SLOT(f2_Done(int))); jump = new JumpDialog(parent); jump->hide(); connect(jump ,SIGNAL(finished(int)) ,this ,SLOT(f6_Done(int))); connect(ui->pushButton_F1,SIGNAL(clicked()),this ,SLOT(F1())); ui->pushButton_F1->setCheckable(true); connect(ui->pushButton_F2,SIGNAL(clicked()),this ,SLOT(F2())); ui->pushButton_F2->setCheckable(true); connect(ui->pushButton_F3,SIGNAL(clicked()),this ,SLOT(F3())); ui->pushButton_F3->setCheckable(true); connect(ui->pushButton_F4,SIGNAL(clicked()),this ,SLOT(F4())); ui->pushButton_F4->setCheckable(true); connect(ui->pushButton_F5,SIGNAL(clicked()),this ,SLOT(F5())); ui->pushButton_F5->setCheckable(true); connect(ui->pushButton_F6,SIGNAL(clicked()),this ,SLOT(F6())); ui->pushButton_F6->setCheckable(true); connect(ui->pushButton_F7,SIGNAL(clicked()),this ,SLOT(F7())); ui->pushButton_F7->setCheckable(true); connect(this ,SIGNAL(enter(int)),parent ,SLOT(funcbarUpdate(int))); connect(ui->pushButton_F8,SIGNAL(clicked()),this ,SLOT(F8())); /*数据表模式改变信号*/ connect(this ,SIGNAL(stateChange(char)) ,parent ,SLOT(tableStateUpdate(char))); /*段选信号*/ connect(this ,SIGNAL(selectRows(bool)) ,parent ,SLOT(tableSelect(bool))); setFocusPolicy(Qt::NoFocus); }
int g(unsigned char *in,int i,dword *h) { dword h0,h1,h2,h3,h4,a,b,c,d,e,temp; unsigned char *kp; dword w[80]; kp = in; h0 = WORD(kp); kp += 4; h1 = WORD(kp); kp += 4; h2 = WORD(kp); kp += 4; h3 = WORD(kp); kp += 4; h4 = WORD(kp); kp += 4; w[0] = i; for (i=1;i<16;i++) w[i] = 0; for (i=16;i<80;i++) w[i] = w[i-3]^w[i-8]^w[i-14]^w[i-16]; a = h0; b = h1; c = h2; d = h3; e = h4; for(i=0;i<20;i++) { temp = ROT27(a) + F1(b, c, d) + e + w[i] + 0x5a827998; e = d; d = c; c = ROT2(b); b = a; a = temp; } for (i=20;i<40;i++) { temp = ROT27(a) + F2(b, c, d) + e + w[i] + 0x6ef9eba1; e = d; d = c; c = ROT2(b); b = a; a = temp; } for (i=40;i<60;i++) { temp = ROT27(a) + F3(b, c, d) + e + w[i] + 0x7f1cbcdc; e = d; d = c; c = ROT2(b); b = a; a = temp; } for (i=60;i<80;i++) { temp = ROT27(a) + F4(b, c, d) + e + w[i] + 0xaa62d1d6; e = d; d = c; c = ROT2(b); b = a; a = temp; } h[0] = h0+a; h[1] = h1+b; h[2] = h2+c; h[3] = h3+d; h[4] = h4+e; return (ALG_OK); }
/* The RIPEMD160 compression function. Operates on self->buf */ static void ripemd160_compress(hash_state *self) { unsigned w, round; uint32_t T; uint32_t AL, BL, CL, DL, EL; /* left line */ uint32_t AR, BR, CR, DR, ER; /* right line */ uint32_t bufw[16]; for (w=0; w<16; w++) bufw[w] = LOAD_U32_LITTLE(&self->buf[w*4]); /* Load the left and right lines with the initial state */ AL = AR = self->h[0]; BL = BR = self->h[1]; CL = CR = self->h[2]; DL = DR = self->h[3]; EL = ER = self->h[4]; /* Round 1 */ round = 0; for (w = 0; w < 16; w++) { /* left line */ T = ROL(SL[round][w], AL + F1(BL, CL, DL) + bufw[RL[round][w]] + KL[round]) + EL; AL = EL; EL = DL; DL = ROL(10, CL); CL = BL; BL = T; } for (w = 0; w < 16; w++) { /* right line */ T = ROL(SR[round][w], AR + F5(BR, CR, DR) + bufw[RR[round][w]] + KR[round]) + ER; AR = ER; ER = DR; DR = ROL(10, CR); CR = BR; BR = T; } /* Round 2 */ round++; for (w = 0; w < 16; w++) { /* left line */ T = ROL(SL[round][w], AL + F2(BL, CL, DL) + bufw[RL[round][w]] + KL[round]) + EL; AL = EL; EL = DL; DL = ROL(10, CL); CL = BL; BL = T; } for (w = 0; w < 16; w++) { /* right line */ T = ROL(SR[round][w], AR + F4(BR, CR, DR) + bufw[RR[round][w]] + KR[round]) + ER; AR = ER; ER = DR; DR = ROL(10, CR); CR = BR; BR = T; } /* Round 3 */ round++; for (w = 0; w < 16; w++) { /* left line */ T = ROL(SL[round][w], AL + F3(BL, CL, DL) + bufw[RL[round][w]] + KL[round]) + EL; AL = EL; EL = DL; DL = ROL(10, CL); CL = BL; BL = T; } for (w = 0; w < 16; w++) { /* right line */ T = ROL(SR[round][w], AR + F3(BR, CR, DR) + bufw[RR[round][w]] + KR[round]) + ER; AR = ER; ER = DR; DR = ROL(10, CR); CR = BR; BR = T; } /* Round 4 */ round++; for (w = 0; w < 16; w++) { /* left line */ T = ROL(SL[round][w], AL + F4(BL, CL, DL) + bufw[RL[round][w]] + KL[round]) + EL; AL = EL; EL = DL; DL = ROL(10, CL); CL = BL; BL = T; } for (w = 0; w < 16; w++) { /* right line */ T = ROL(SR[round][w], AR + F2(BR, CR, DR) + bufw[RR[round][w]] + KR[round]) + ER; AR = ER; ER = DR; DR = ROL(10, CR); CR = BR; BR = T; } /* Round 5 */ round++; for (w = 0; w < 16; w++) { /* left line */ T = ROL(SL[round][w], AL + F5(BL, CL, DL) + bufw[RL[round][w]] + KL[round]) + EL; AL = EL; EL = DL; DL = ROL(10, CL); CL = BL; BL = T; } for (w = 0; w < 16; w++) { /* right line */ T = ROL(SR[round][w], AR + F1(BR, CR, DR) + bufw[RR[round][w]] + KR[round]) + ER; AR = ER; ER = DR; DR = ROL(10, CR); CR = BR; BR = T; } /* Final mixing stage */ T = self->h[1] + CL + DR; self->h[1] = self->h[2] + DL + ER; self->h[2] = self->h[3] + EL + AR; self->h[3] = self->h[4] + AL + BR; self->h[4] = self->h[0] + BL + CR; self->h[0] = T; /* Clear the buffer and wipe the temporary variables */ T = AL = BL = CL = DL = EL = AR = BR = CR = DR = ER = 0; memset(&self->buf, 0, sizeof(self->buf)); self->bufpos = 0; }
static void sha_transform(SshSHAContext *context, const unsigned char *block) { static SshUInt32 W[80]; SshUInt32 a, b, c, d, e, f; a = context->A; b = context->B; c = context->C; d = context->D; e = context->E; #if 1 /* Unroll as much as one can, removing unneccessary copying etc. What actually happens is that the compiler must interleave all these operations some efficient way. On processors with only few registers it might be better to implement the table generation before actual 'nonlinear' operations. On Intel processors that might be the case, although one never knows without trying. */ #define TABLE_IN(i) \ W[i] = SSH_GET_32BIT(block); block += 4; #define TABLE_MORE(i, t) \ t = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]; \ W[i] = ROLL_1(t); #define NONLINEAR1(F, a, b, c, d, e, f, i) \ TABLE_IN(i); \ f = ROLL_5(a); \ f += F(b, c, d); \ b = ROLL_30(b); \ f += e + W[i]; #define NONLINEAR2(F, a, b, c, d, e, f, i) \ TABLE_MORE(i, f); \ f = ROLL_5(a); \ f += F(b, c, d); \ b = ROLL_30(b); \ f += e + W[i]; NONLINEAR1(F1, a, b, c, d, e, f, 0); NONLINEAR1(F1, f, a, b, c, d, e, 1); NONLINEAR1(F1, e, f, a, b, c, d, 2); NONLINEAR1(F1, d, e, f, a, b, c, 3); NONLINEAR1(F1, c, d, e, f, a, b, 4); NONLINEAR1(F1, b, c, d, e, f, a, 5); NONLINEAR1(F1, a, b, c, d, e, f, 6); NONLINEAR1(F1, f, a, b, c, d, e, 7); NONLINEAR1(F1, e, f, a, b, c, d, 8); NONLINEAR1(F1, d, e, f, a, b, c, 9); NONLINEAR1(F1, c, d, e, f, a, b, 10); NONLINEAR1(F1, b, c, d, e, f, a, 11); NONLINEAR1(F1, a, b, c, d, e, f, 12); NONLINEAR1(F1, f, a, b, c, d, e, 13); NONLINEAR1(F1, e, f, a, b, c, d, 14); NONLINEAR1(F1, d, e, f, a, b, c, 15); NONLINEAR2(F1, c, d, e, f, a, b, 16); NONLINEAR2(F1, b, c, d, e, f, a, 17); NONLINEAR2(F1, a, b, c, d, e, f, 18); NONLINEAR2(F1, f, a, b, c, d, e, 19); NONLINEAR2(F2, e, f, a, b, c, d, 20); NONLINEAR2(F2, d, e, f, a, b, c, 21); NONLINEAR2(F2, c, d, e, f, a, b, 22); NONLINEAR2(F2, b, c, d, e, f, a, 23); NONLINEAR2(F2, a, b, c, d, e, f, 24); NONLINEAR2(F2, f, a, b, c, d, e, 25); NONLINEAR2(F2, e, f, a, b, c, d, 26); NONLINEAR2(F2, d, e, f, a, b, c, 27); NONLINEAR2(F2, c, d, e, f, a, b, 28); NONLINEAR2(F2, b, c, d, e, f, a, 29); NONLINEAR2(F2, a, b, c, d, e, f, 30); NONLINEAR2(F2, f, a, b, c, d, e, 31); NONLINEAR2(F2, e, f, a, b, c, d, 32); NONLINEAR2(F2, d, e, f, a, b, c, 33); NONLINEAR2(F2, c, d, e, f, a, b, 34); NONLINEAR2(F2, b, c, d, e, f, a, 35); NONLINEAR2(F2, a, b, c, d, e, f, 36); NONLINEAR2(F2, f, a, b, c, d, e, 37); NONLINEAR2(F2, e, f, a, b, c, d, 38); NONLINEAR2(F2, d, e, f, a, b, c, 39); NONLINEAR2(F3, c, d, e, f, a, b, 40); NONLINEAR2(F3, b, c, d, e, f, a, 41); NONLINEAR2(F3, a, b, c, d, e, f, 42); NONLINEAR2(F3, f, a, b, c, d, e, 43); NONLINEAR2(F3, e, f, a, b, c, d, 44); NONLINEAR2(F3, d, e, f, a, b, c, 45); NONLINEAR2(F3, c, d, e, f, a, b, 46); NONLINEAR2(F3, b, c, d, e, f, a, 47); NONLINEAR2(F3, a, b, c, d, e, f, 48); NONLINEAR2(F3, f, a, b, c, d, e, 49); NONLINEAR2(F3, e, f, a, b, c, d, 50); NONLINEAR2(F3, d, e, f, a, b, c, 51); NONLINEAR2(F3, c, d, e, f, a, b, 52); NONLINEAR2(F3, b, c, d, e, f, a, 53); NONLINEAR2(F3, a, b, c, d, e, f, 54); NONLINEAR2(F3, f, a, b, c, d, e, 55); NONLINEAR2(F3, e, f, a, b, c, d, 56); NONLINEAR2(F3, d, e, f, a, b, c, 57); NONLINEAR2(F3, c, d, e, f, a, b, 58); NONLINEAR2(F3, b, c, d, e, f, a, 59); NONLINEAR2(F4, a, b, c, d, e, f, 60); NONLINEAR2(F4, f, a, b, c, d, e, 61); NONLINEAR2(F4, e, f, a, b, c, d, 62); NONLINEAR2(F4, d, e, f, a, b, c, 63); NONLINEAR2(F4, c, d, e, f, a, b, 64); NONLINEAR2(F4, b, c, d, e, f, a, 65); NONLINEAR2(F4, a, b, c, d, e, f, 66); NONLINEAR2(F4, f, a, b, c, d, e, 67); NONLINEAR2(F4, e, f, a, b, c, d, 68); NONLINEAR2(F4, d, e, f, a, b, c, 69); NONLINEAR2(F4, c, d, e, f, a, b, 70); NONLINEAR2(F4, b, c, d, e, f, a, 71); NONLINEAR2(F4, a, b, c, d, e, f, 72); NONLINEAR2(F4, f, a, b, c, d, e, 73); NONLINEAR2(F4, e, f, a, b, c, d, 74); NONLINEAR2(F4, d, e, f, a, b, c, 75); NONLINEAR2(F4, c, d, e, f, a, b, 76); NONLINEAR2(F4, b, c, d, e, f, a, 77); NONLINEAR2(F4, a, b, c, d, e, f, 78); NONLINEAR2(F4, f, a, b, c, d, e, 79); /* Remember the correct order of rotated variables. */ context->A += e; context->B += f; context->C += a; context->D += b; context->E += c; #else /* Inefficient version (but actually not that slow, only slightly slower than the above one). */ /* t is not currently defined so you need to define that if want to use these routines. */ for (t = 0; t < 16; t++) { W[t] = SSH_GET_32BIT(block); block += 4; } for (t = 16; t < 80; t++) { f = W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]; W[t] = ROLL_1(f); } for (t = 0; t < 80; t++) { f = ROLL_5(a); if (t < 40) { if (t < 20) f += F1(b, c, d); else f += F2(b, c, d); } else { if (t < 60) f += F3(b, c, d); else f += F4(b, c, d); } f += e + W[t]; f &= 0xFFFFFFFFL; e = d; d = c; c = ROLL_30(b); b = a; a = f; } context->A += a; context->B += b; context->C += c; context->D += d; context->E += e; #endif /* unrolled. */ context->A &= 0xFFFFFFFFL; context->B &= 0xFFFFFFFFL; context->C &= 0xFFFFFFFFL; context->D &= 0xFFFFFFFFL; context->E &= 0xFFFFFFFFL; }
/* * RIPEMD-160 Compression Function */ void RIPEMD_160::compress_n(const uint8_t input[], size_t blocks) { const uint32_t MAGIC2 = 0x5A827999, MAGIC3 = 0x6ED9EBA1, MAGIC4 = 0x8F1BBCDC, MAGIC5 = 0xA953FD4E, MAGIC6 = 0x50A28BE6, MAGIC7 = 0x5C4DD124, MAGIC8 = 0x6D703EF3, MAGIC9 = 0x7A6D76E9; for(size_t i = 0; i != blocks; ++i) { load_le(m_M.data(), input, m_M.size()); uint32_t A1 = m_digest[0], A2 = A1, B1 = m_digest[1], B2 = B1, C1 = m_digest[2], C2 = C1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(A1,B1,C1,D1,E1,m_M[ 8],14,MAGIC5); F1(A2,B2,C2,D2,E2,m_M[14], 5 ); F5(E1,A1,B1,C1,D1,m_M[11],11,MAGIC5); F1(E2,A2,B2,C2,D2,m_M[ 0],15 ); F5(D1,E1,A1,B1,C1,m_M[ 6], 8,MAGIC5); F1(D2,E2,A2,B2,C2,m_M[ 3],13 ); F5(C1,D1,E1,A1,B1,m_M[15], 5,MAGIC5); F1(C2,D2,E2,A2,B2,m_M[ 9],11 ); F5(B1,C1,D1,E1,A1,m_M[13], 6,MAGIC5); F1(B2,C2,D2,E2,A2,m_M[11],11 ); C1 = m_digest[1] + C1 + D2; m_digest[1] = m_digest[2] + D1 + E2; m_digest[2] = m_digest[3] + E1 + A2; m_digest[3] = m_digest[4] + A1 + B2; m_digest[4] = m_digest[0] + B1 + C2; m_digest[0] = C1; input += hash_block_size(); } }
int main() //Declare and initialize Variables inside main function { char fileName[BUFFER_SIZE]; int i,j,rows,cols,user_input=0,Value1=0,loop=1; char ci; //Print out menu while (loop = 1){ // printf("Please select an option:\n"); // printf("1) Read in a picture file and process it.\n"); // printf("2) Read in two picture files and subtract the second picture from the first.\n"); printf("Read in a pic and apply the sobelfunc function to it. Use a grayscale pic saved as a *.pgm in your computer Please enter the number 3 on your keyboard and then hit the enter key \n"); // printf("4) Exit.\n"); scanf("%d", &user_input); //Read in an image and prompt user to enter a value for the image if (user_input == 1){ printf("enter image filename in the format *.pgm: "); scanf("%s", fileName); img = readpic(fileName); printf("Successfully read image file '%s'\n", fileName); printf("Enter a value for the picture: "); scanf("%d", &Value1); system("pause"); F3(img, numRows, numCols, Value1); F4(img, numRows, numCols, Value1); printf("Enter image filename for output: "); scanf("%s", fileName); writeoutpic(fileName,img); free(img); img = NULL; } //Read in two images and subtract the second from the first else if (user_input == 2) { printf("Enter first image filename: "); scanf("%s", fileName); // temppicx = readpic(fileName); printf("Enter second image filename: "); scanf("%s", fileName); // temppicy = readpic(fileName); // sobelout = setImage(); // subtractpixels(sobelout, temppicx, temppicy); printf("Enter image filename for output: "); scanf("%s", fileName); // writeoutpic(fileName,sobelout); free(temppicx); temppicx = NULL; free(temppicy); temppicy = NULL; } //Read in a picture and apply the sobelfunc function to it else if (user_input == 3){ printf("Enter pic filename (*.pgm, example dog.pgm): "); scanf("%s", fileName); img = readpic(fileName); sobelout= setdImage(); candid = setImage(); sobelout= setdImage(); temppicx= setdImage(); temppicy= setdImage(); finaly= setImage(); sobelout2=setImage(); cannyfunc(img,sobelout,temppicx,temppicy,candid,finaly); printf("Enter mag filename for output: "); scanf("%s", fileName); for(i=0;i<numRows;i++) for (j=0;j<numCols;j++) sobelout2[i][j]= (int) sobelout[i][j]; writeoutpic(fileName,sobelout2); printf("Enter peaks filename for output: "); scanf("%s", fileName); writeoutpic(fileName,candid); printf("Enter final filename for output: "); scanf("%s", fileName); writeoutpic(fileName,finaly); free(img); img = NULL; } //Exit the program. else if (user_input == 4) { return(EXIT_SUCCESS); } } }
Vector SchemeRoe(const Cell& Cell1,const Cell& Cell2,const Cell& Cell3,const Cell& Cell4, int AxisNo) { // Local variables Vector V1, V2, V3, V4; // Velocities real rho1, rho2, rho3, rho4; // Densities real p1, p2, p3, p4; // Pressures real rhoE1, rhoE2, rhoE3, rhoE4; // Energies Vector Result(QuantityNb); Vector F1(QuantityNb); // Fluxes Vector F2(QuantityNb); Vector F3(QuantityNb); Vector F4(QuantityNb); Vector Q1, Q2, Q3, Q4; // Conservative quantities Vector FL(QuantityNb),FR(QuantityNb); // Left and right fluxex Vector QL(QuantityNb),QR(QuantityNb); // Left and right conservative quantities real rhoL, rhoR; // Left and right densities real pL, pR; // Left and right pressures real rhoEL, rhoER; // Left and right energies Vector VL(Dimension), VR(Dimension); // Left and right velocities Vector One(QuantityNb); real rho; // central density with Roe's average Vector V(Dimension); // central velocity with Roe's average real H; // central enthalpy with Roe's average real c; // central speed of sound with Roe's average real Roe; // Coefficient for Roe's average Matrix L, R; // left and right eigenmatrix Matrix Lambda(QuantityNb); // diagonal matrix containing the eigenvalues Matrix A; // absolute value of the jacobian matrix Vector Lim; // limiter (Van Leer) int i; // coutner // vector one. for(i=1; i<=QuantityNb; i++ ) One.setValue(i,1.); // --- Get conservative quantities --- Q1 = Cell1.average(); Q2 = Cell2.average(); Q3 = Cell3.average(); Q4 = Cell4.average(); // --- Get primitive variables --- // density rho1 = Cell1.density(); rho2 = Cell2.density(); rho3 = Cell3.density(); rho4 = Cell4.density(); // velocity V1 = Cell1.velocity(); V2 = Cell2.velocity(); V3 = Cell3.velocity(); V4 = Cell4.velocity(); // energy rhoE1 = Cell1.energy(); rhoE2 = Cell2.energy(); rhoE3 = Cell3.energy(); rhoE4 = Cell4.energy(); // pressure p1 = Cell1.pressure(); p2 = Cell2.pressure(); p3 = Cell3.pressure(); p4 = Cell4.pressure(); // --- Compute Euler fluxes --- F1.setValue(1,rho1*V1.value(AxisNo)); F2.setValue(1,rho2*V2.value(AxisNo)); F3.setValue(1,rho3*V3.value(AxisNo)); F4.setValue(1,rho4*V4.value(AxisNo)); for(i=1; i<=Dimension; i++) { F1.setValue(i+1, rho1*V1.value(AxisNo)*V1.value(i) + ((AxisNo == i)? p1 : 0.)); F2.setValue(i+1, rho2*V2.value(AxisNo)*V2.value(i) + ((AxisNo == i)? p2 : 0.)); F3.setValue(i+1, rho3*V3.value(AxisNo)*V3.value(i) + ((AxisNo == i)? p3 : 0.)); F4.setValue(i+1, rho4*V4.value(AxisNo)*V4.value(i) + ((AxisNo == i)? p4 : 0.)); } F1.setValue(QuantityNb,(rhoE1+p1)*V1.value(AxisNo)); F2.setValue(QuantityNb,(rhoE2+p2)*V2.value(AxisNo)); F3.setValue(QuantityNb,(rhoE3+p3)*V3.value(AxisNo)); F4.setValue(QuantityNb,(rhoE4+p4)*V4.value(AxisNo)); // --- Van Leer limiter --- // Left Lim = Limiter(Q3-Q2, Q2-Q1); FL = F2 + 0.5*(Lim|(F2-F1)) + 0.5*((One-Lim)|(F3-F2)); QL = Q2 + 0.5*(Lim|(Q2-Q1)) + 0.5*((One-Lim)|(Q3-Q2)); // Right Lim = Limiter(Q3-Q2, Q4-Q3); FR = F3 - 0.5*(Lim|(F4-F3)) - 0.5*((One-Lim)|(F3-F2)); QR = Q3 - 0.5*(Lim|(Q4-Q3)) - 0.5*((One-Lim)|(Q3-Q2)); /* FL = F2; FR = F3; QL = Q2; QR = Q3; */ // --- Extract left and right primitive variables --- rhoL = QL.value(1); rhoR = QR.value(1); for (i=1; i<= Dimension; i++) { VL.setValue(i,QL.value(i+1)/rhoL); VR.setValue(i,QR.value(i+1)/rhoR); } rhoEL=QL.value(QuantityNb); rhoER=QR.value(QuantityNb); pL = (Gamma-1)*(rhoEL - .5*rhoL*(VL*VL)); pR = (Gamma-1)*(rhoER - .5*rhoR*(VR*VR)); // --- Compute Roe's averages --- Roe = sqrt(rhoR/rhoL); rho = Roe*rhoL; V = 1./(1.+Roe)*( Roe*VR + VL ); H = 1./(1.+Roe)*( Roe*(rhoER+pR)/rhoR + (rhoEL+pL)/rhoL ); c = sqrt ( (Gamma-1)*( H - 0.5*(V*V) ) ); // --- Compute diagonal matrix containing the absolute value of the eigenvalues --- for (i=1;i<=Dimension;i++) Lambda.setValue(i,i, fabs(V.value(AxisNo))); Lambda.setValue(Dimension+1, Dimension+1, fabs(V.value(AxisNo)+c)); Lambda.setValue(Dimension+2, Dimension+2, fabs(V.value(AxisNo)-c)); // --- Set left and right eigenmatrices --- L.setEigenMatrix(true, AxisNo, V, c); R.setEigenMatrix(false, AxisNo, V, c, H); // --- Compute absolute Jacobian matrix --- A = R*Lambda*L; // --- Compute Euler Flux --- Result = 0.5*(FL+FR) - 0.5*(A*(QR-QL)); return Result; }
void coordinate_tunning(int x, int y) { int tune_number; tune_number = 0; if (F1(x,y) > 0) { if (F3(x,y) > 0) { tune_number = 3; } else { if (F4(x,y) < 0) tune_number = 1; else tune_number = 2; } } else { if (F2(x,y) < 0) { if (F3(x,y) > 0) { tune_number = 9; } else { if (F4(x,y) < 0) tune_number = 7; else tune_number = 8; } } else { if (F3(x,y) > 0) tune_number = 6; else { if (F4(x,y) < 0) tune_number = 4; else tune_number = 5; } } } pr_info("%s x : %d, y : %d, tune_number : %d", __func__, x, y, tune_number); memcpy(&DYNAMIC_BROWSER_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&DYNAMIC_GALLERY_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&DYNAMIC_UI_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&DYNAMIC_VIDEO_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&DYNAMIC_VT_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&DYNAMIC_eBOOK_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&STANDARD_BROWSER_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&STANDARD_GALLERY_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&STANDARD_UI_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&STANDARD_VIDEO_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&STANDARD_VT_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&STANDARD_eBOOK_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&AUTO_BROWSER_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&AUTO_CAMERA_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&AUTO_GALLERY_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&AUTO_UI_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&AUTO_VIDEO_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&AUTO_VT_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&CAMERA_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); }
/* * SHA-160 Compression Function */ void SHA_160::compress_n(const byte input[], u32bit blocks) { u32bit A = digest[0], B = digest[1], C = digest[2], D = digest[3], E = digest[4]; for(u32bit i = 0; i != blocks; ++i) { for(u32bit j = 0; j != 16; j += 4) { W[j ] = load_be<u32bit>(input, j); W[j+1] = load_be<u32bit>(input, j+1); W[j+2] = load_be<u32bit>(input, j+2); W[j+3] = load_be<u32bit>(input, j+3); } input += HASH_BLOCK_SIZE; for(u32bit j = 16; j != 80; j += 4) { W[j ] = rotate_left((W[j-3] ^ W[j-8] ^ W[j-14] ^ W[j-16]), 1); W[j+1] = rotate_left((W[j-2] ^ W[j-7] ^ W[j-13] ^ W[j-15]), 1); W[j+2] = rotate_left((W[j-1] ^ W[j-6] ^ W[j-12] ^ W[j-14]), 1); W[j+3] = rotate_left((W[j ] ^ W[j-5] ^ W[j-11] ^ W[j-13]), 1); } F1(A,B,C,D,E,W[ 0]); F1(E,A,B,C,D,W[ 1]); F1(D,E,A,B,C,W[ 2]); F1(C,D,E,A,B,W[ 3]); F1(B,C,D,E,A,W[ 4]); F1(A,B,C,D,E,W[ 5]); F1(E,A,B,C,D,W[ 6]); F1(D,E,A,B,C,W[ 7]); F1(C,D,E,A,B,W[ 8]); F1(B,C,D,E,A,W[ 9]); F1(A,B,C,D,E,W[10]); F1(E,A,B,C,D,W[11]); F1(D,E,A,B,C,W[12]); F1(C,D,E,A,B,W[13]); F1(B,C,D,E,A,W[14]); F1(A,B,C,D,E,W[15]); F1(E,A,B,C,D,W[16]); F1(D,E,A,B,C,W[17]); F1(C,D,E,A,B,W[18]); F1(B,C,D,E,A,W[19]); F2(A,B,C,D,E,W[20]); F2(E,A,B,C,D,W[21]); F2(D,E,A,B,C,W[22]); F2(C,D,E,A,B,W[23]); F2(B,C,D,E,A,W[24]); F2(A,B,C,D,E,W[25]); F2(E,A,B,C,D,W[26]); F2(D,E,A,B,C,W[27]); F2(C,D,E,A,B,W[28]); F2(B,C,D,E,A,W[29]); F2(A,B,C,D,E,W[30]); F2(E,A,B,C,D,W[31]); F2(D,E,A,B,C,W[32]); F2(C,D,E,A,B,W[33]); F2(B,C,D,E,A,W[34]); F2(A,B,C,D,E,W[35]); F2(E,A,B,C,D,W[36]); F2(D,E,A,B,C,W[37]); F2(C,D,E,A,B,W[38]); F2(B,C,D,E,A,W[39]); F3(A,B,C,D,E,W[40]); F3(E,A,B,C,D,W[41]); F3(D,E,A,B,C,W[42]); F3(C,D,E,A,B,W[43]); F3(B,C,D,E,A,W[44]); F3(A,B,C,D,E,W[45]); F3(E,A,B,C,D,W[46]); F3(D,E,A,B,C,W[47]); F3(C,D,E,A,B,W[48]); F3(B,C,D,E,A,W[49]); F3(A,B,C,D,E,W[50]); F3(E,A,B,C,D,W[51]); F3(D,E,A,B,C,W[52]); F3(C,D,E,A,B,W[53]); F3(B,C,D,E,A,W[54]); F3(A,B,C,D,E,W[55]); F3(E,A,B,C,D,W[56]); F3(D,E,A,B,C,W[57]); F3(C,D,E,A,B,W[58]); F3(B,C,D,E,A,W[59]); F4(A,B,C,D,E,W[60]); F4(E,A,B,C,D,W[61]); F4(D,E,A,B,C,W[62]); F4(C,D,E,A,B,W[63]); F4(B,C,D,E,A,W[64]); F4(A,B,C,D,E,W[65]); F4(E,A,B,C,D,W[66]); F4(D,E,A,B,C,W[67]); F4(C,D,E,A,B,W[68]); F4(B,C,D,E,A,W[69]); F4(A,B,C,D,E,W[70]); F4(E,A,B,C,D,W[71]); F4(D,E,A,B,C,W[72]); F4(C,D,E,A,B,W[73]); F4(B,C,D,E,A,W[74]); F4(A,B,C,D,E,W[75]); F4(E,A,B,C,D,W[76]); F4(D,E,A,B,C,W[77]); F4(C,D,E,A,B,W[78]); F4(B,C,D,E,A,W[79]); A = (digest[0] += A); B = (digest[1] += B); C = (digest[2] += C); D = (digest[3] += D); E = (digest[4] += E); } }
void coordinate_tunning(int x, int y) { int tune_number; #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_S6E3HA2_CMD_WQHD_PT_PANEL)|| defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_S6E3HA2_CMD_WQXGA_PT_PANEL) int i, j; #endif tune_number = 0; if (F1(x,y) > 0) { if (F3(x,y) > 0) { tune_number = 3; } else { if (F4(x,y) < 0) tune_number = 1; else tune_number = 2; } } else { if (F2(x,y) < 0) { if (F3(x,y) > 0) { tune_number = 9; } else { if (F4(x,y) < 0) tune_number = 7; else tune_number = 8; } } else { if (F3(x,y) > 0) tune_number = 6; else { if (F4(x,y) < 0) tune_number = 4; else tune_number = 5; } } } pr_info("%s x : %d, y : %d, tune_number : %d", __func__, x, y, tune_number); #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_S6E3HA2_CMD_WQHD_PT_PANEL)|| defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_S6E3HA2_CMD_WQXGA_PT_PANEL) for(i = 0; i < MAX_mDNIe_MODE; i++) { for(j = 0; j < MAX_BACKGROUND_MODE; j++) { if((mdnie_tune_value[i][j][0][1] != NULL) && (i != mDNIe_eBOOK_MODE)) { memcpy(&mdnie_tune_value[i][j][0][1][scr_wr_addr], &coordinate_data[j][tune_number][0], coordinate_data_size); } } } #else memcpy(&DYNAMIC_BROWSER_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&DYNAMIC_GALLERY_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&DYNAMIC_UI_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&DYNAMIC_VIDEO_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&DYNAMIC_VT_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&DYNAMIC_EBOOK_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&STANDARD_BROWSER_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&STANDARD_GALLERY_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&STANDARD_UI_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&STANDARD_VIDEO_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&STANDARD_VT_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&STANDARD_EBOOK_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&AUTO_BROWSER_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&AUTO_CAMERA_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&AUTO_GALLERY_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&AUTO_UI_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&AUTO_VIDEO_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&AUTO_VT_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); memcpy(&CAMERA_2[scr_wr_addr], &coordinate_data[tune_number][0], coordinate_data_size); #endif }
int main () { //===============================================================// //========= PROBLEM SETUP =======================// //===============================================================// int d = 4; int j0 = 2; cout << "Wavelets: d = " << d << ", j0 = " << j0 << endl << endl; /// Basis initialization _Basis basis(d, j0); Basis2D basis2d(basis, basis); /* for (int i = 1; i<= 6; ++i) { DataType u; std::string snapshot; std::string plot; snapshot = "training_data_toy/snap/snap_"; plot = "plot_"; snapshot += std::to_string(i); plot += std::to_string(i); snapshot += ".txt"; std::cout << "Reading snapshot from file " << snapshot << std::endl; std::cout << "Printing plot to file " << plot << std::endl; readCoeffVector2D(u, snapshot.c_str()); precon _p; plot2D(basis2d, u, _p, zero, 0., 1., 0., 1., 1e-02, plot.c_str()); } exit(0); */ /// Initialization of operators DenseVectorT no_singPts; Function<T> zero_Fct(zero_fct,no_singPts); // Bilinear Forms Identity1D IdentityBil(basis); Laplace1D LaplaceBil(basis); RefIdentity1D RefIdentityBil(basis.refinementbasis); RefLaplace1D RefLaplaceBil(basis.refinementbasis); /// Initialization of local operator LOp_Id1D lOp_Id1D (basis, basis, RefIdentityBil, IdentityBil); LOp_Lapl1D lOp_Lapl1D (basis, basis, RefLaplaceBil, LaplaceBil); LOp_Id_Id_2D localIdentityIdentityOp2D (lOp_Id1D, lOp_Id1D); LOp_Id_Lapl_2D localIdentityLaplaceOp2D (lOp_Id1D, lOp_Lapl1D); LOp_Lapl_Id_2D localLaplaceIdentityOp2D (lOp_Lapl1D, lOp_Id1D); localIdentityIdentityOp2D.setJ(9); localIdentityLaplaceOp2D.setJ(9); localLaplaceIdentityOp2D.setJ(9); /// Initialization of preconditioner Prec2D prec(basis2d); NoPrec2D noPrec; /// Initialization of rhs /// Right Hand Side: /// No Singular Supports in both dimensions DenseVectorT sing_support; /// Forcing Functions Function2D<T> F1_Fct(f1, sing_support, sing_support); Function2D<T> F2_Fct(f2, sing_support, sing_support); Function2D<T> F3_Fct(f3, sing_support, sing_support); Function2D<T> F4_Fct(f4, sing_support, sing_support); Function2D<T> F5_Fct(f5, sing_support, sing_support); Function2D<T> F6_Fct(f6, sing_support, sing_support); Function2D<T> F7_Fct(f7, sing_support, sing_support); Function2D<T> F8_Fct(f8, sing_support, sing_support); Function2D<T> F9_Fct(f9, sing_support, sing_support); Function2D<T> F10_Fct(f10, sing_support, sing_support); Function2D<T> F11_Fct(f11, sing_support, sing_support); Function2D<T> F12_Fct(f12, sing_support, sing_support); Function2D<T> F13_Fct(f13, sing_support, sing_support); Function2D<T> F14_Fct(f14, sing_support, sing_support); Function2D<T> F15_Fct(f15, sing_support, sing_support); Function2D<T> F16_Fct(f16, sing_support, sing_support); Function2D<T> F17_Fct(f17, sing_support, sing_support); Function2D<T> F18_Fct(f18, sing_support, sing_support); Function2D<T> F19_Fct(f19, sing_support, sing_support); Function2D<T> F20_Fct(f20, sing_support, sing_support); Function2D<T> F21_Fct(f21, sing_support, sing_support); Function2D<T> F22_Fct(f22, sing_support, sing_support); Function2D<T> F23_Fct(f23, sing_support, sing_support); Function2D<T> F24_Fct(f24, sing_support, sing_support); Function2D<T> F25_Fct(f25, sing_support, sing_support); Function2D<T> F26_Fct(f26, sing_support, sing_support); Function2D<T> F27_Fct(f27, sing_support, sing_support); Function2D<T> F28_Fct(f28, sing_support, sing_support); Function2D<T> F29_Fct(f29, sing_support, sing_support); Function2D<T> F30_Fct(f30, sing_support, sing_support); Function2D<T> F31_Fct(f31, sing_support, sing_support); Function2D<T> F32_Fct(f32, sing_support, sing_support); Function2D<T> F33_Fct(f33, sing_support, sing_support); Function2D<T> F34_Fct(f34, sing_support, sing_support); Function2D<T> F35_Fct(f35, sing_support, sing_support); Function2D<T> F36_Fct(f36, sing_support, sing_support); Function2D<T> F37_Fct(f37, sing_support, sing_support); Function2D<T> F38_Fct(f38, sing_support, sing_support); Function2D<T> F39_Fct(f39, sing_support, sing_support); Function2D<T> F40_Fct(f40, sing_support, sing_support); Function2D<T> F41_Fct(f41, sing_support, sing_support); Function2D<T> F42_Fct(f42, sing_support, sing_support); Function2D<T> F43_Fct(f43, sing_support, sing_support); Function2D<T> F44_Fct(f44, sing_support, sing_support); Function2D<T> F45_Fct(f45, sing_support, sing_support); Function2D<T> F46_Fct(f46, sing_support, sing_support); Function2D<T> F47_Fct(f47, sing_support, sing_support); Function2D<T> F48_Fct(f48, sing_support, sing_support); Function2D<T> F49_Fct(f49, sing_support, sing_support); RhsIntegral2D rhs_1(basis2d, F1_Fct, 100); RhsIntegral2D rhs_2(basis2d, F2_Fct, 100); RhsIntegral2D rhs_3(basis2d, F3_Fct, 100); RhsIntegral2D rhs_4(basis2d, F4_Fct, 100); RhsIntegral2D rhs_5(basis2d, F5_Fct, 100); RhsIntegral2D rhs_6(basis2d, F6_Fct, 100); RhsIntegral2D rhs_7(basis2d, F7_Fct, 100); RhsIntegral2D rhs_8(basis2d, F8_Fct, 100); RhsIntegral2D rhs_9(basis2d, F9_Fct, 100); RhsIntegral2D rhs_10(basis2d, F10_Fct, 100); RhsIntegral2D rhs_11(basis2d, F11_Fct, 100); RhsIntegral2D rhs_12(basis2d, F12_Fct, 100); RhsIntegral2D rhs_13(basis2d, F13_Fct, 100); RhsIntegral2D rhs_14(basis2d, F14_Fct, 100); RhsIntegral2D rhs_15(basis2d, F15_Fct, 100); RhsIntegral2D rhs_16(basis2d, F16_Fct, 100); RhsIntegral2D rhs_17(basis2d, F17_Fct, 100); RhsIntegral2D rhs_18(basis2d, F18_Fct, 100); RhsIntegral2D rhs_19(basis2d, F19_Fct, 100); RhsIntegral2D rhs_20(basis2d, F20_Fct, 100); RhsIntegral2D rhs_21(basis2d, F21_Fct, 100); RhsIntegral2D rhs_22(basis2d, F22_Fct, 100); RhsIntegral2D rhs_23(basis2d, F23_Fct, 100); RhsIntegral2D rhs_24(basis2d, F24_Fct, 100); RhsIntegral2D rhs_25(basis2d, F25_Fct, 100); RhsIntegral2D rhs_26(basis2d, F26_Fct, 100); RhsIntegral2D rhs_27(basis2d, F27_Fct, 100); RhsIntegral2D rhs_28(basis2d, F28_Fct, 100); RhsIntegral2D rhs_29(basis2d, F29_Fct, 100); RhsIntegral2D rhs_30(basis2d, F30_Fct, 100); RhsIntegral2D rhs_31(basis2d, F31_Fct, 100); RhsIntegral2D rhs_32(basis2d, F32_Fct, 100); RhsIntegral2D rhs_33(basis2d, F33_Fct, 100); RhsIntegral2D rhs_34(basis2d, F34_Fct, 100); RhsIntegral2D rhs_35(basis2d, F35_Fct, 100); RhsIntegral2D rhs_36(basis2d, F36_Fct, 100); RhsIntegral2D rhs_37(basis2d, F37_Fct, 100); RhsIntegral2D rhs_38(basis2d, F38_Fct, 100); RhsIntegral2D rhs_39(basis2d, F39_Fct, 100); RhsIntegral2D rhs_40(basis2d, F40_Fct, 100); RhsIntegral2D rhs_41(basis2d, F41_Fct, 100); RhsIntegral2D rhs_42(basis2d, F42_Fct, 100); RhsIntegral2D rhs_43(basis2d, F43_Fct, 100); RhsIntegral2D rhs_44(basis2d, F44_Fct, 100); RhsIntegral2D rhs_45(basis2d, F45_Fct, 100); RhsIntegral2D rhs_46(basis2d, F46_Fct, 100); RhsIntegral2D rhs_47(basis2d, F47_Fct, 100); RhsIntegral2D rhs_48(basis2d, F48_Fct, 100); RhsIntegral2D rhs_49(basis2d, F49_Fct, 100); Rhs F1(rhs_1,noPrec); Rhs F2(rhs_2,noPrec); Rhs F3(rhs_3,noPrec); Rhs F4(rhs_4,noPrec); Rhs F5(rhs_5,noPrec); Rhs F6(rhs_6,noPrec); Rhs F7(rhs_7,noPrec); Rhs F8(rhs_8,noPrec); Rhs F9(rhs_9,noPrec); Rhs F10(rhs_10,noPrec); Rhs F11(rhs_11,noPrec); Rhs F12(rhs_12,noPrec); Rhs F13(rhs_13,noPrec); Rhs F14(rhs_14,noPrec); Rhs F15(rhs_15,noPrec); Rhs F16(rhs_16,noPrec); Rhs F17(rhs_17,noPrec); Rhs F18(rhs_18,noPrec); Rhs F19(rhs_19,noPrec); Rhs F20(rhs_20,noPrec); Rhs F21(rhs_21,noPrec); Rhs F22(rhs_22,noPrec); Rhs F23(rhs_23,noPrec); Rhs F24(rhs_24,noPrec); Rhs F25(rhs_25,noPrec); Rhs F26(rhs_26,noPrec); Rhs F27(rhs_27,noPrec); Rhs F28(rhs_28,noPrec); Rhs F29(rhs_29,noPrec); Rhs F30(rhs_30,noPrec); Rhs F31(rhs_31,noPrec); Rhs F32(rhs_32,noPrec); Rhs F33(rhs_33,noPrec); Rhs F34(rhs_34,noPrec); Rhs F35(rhs_35,noPrec); Rhs F36(rhs_36,noPrec); Rhs F37(rhs_37,noPrec); Rhs F38(rhs_38,noPrec); Rhs F39(rhs_39,noPrec); Rhs F40(rhs_40,noPrec); Rhs F41(rhs_41,noPrec); Rhs F42(rhs_42,noPrec); Rhs F43(rhs_43,noPrec); Rhs F44(rhs_44,noPrec); Rhs F45(rhs_45,noPrec); Rhs F46(rhs_46,noPrec); Rhs F47(rhs_47,noPrec); Rhs F48(rhs_48,noPrec); Rhs F49(rhs_49,noPrec); //===============================================================// //=============== RB SETUP =====================================// //===============================================================// // Affine Decompositions: // Left Hand Side vector<ThetaStructure<ParamType>::ThetaFct> lhs_theta_fcts; lhs_theta_fcts.push_back(no_theta); ThetaStructure<ParamType> lhs_theta(lhs_theta_fcts); vector<AbstractLocalOperator2D<T>* > lhs_ops; lhs_ops.push_back(&localLaplaceIdentityOp2D); lhs_ops.push_back(&localIdentityLaplaceOp2D); Flex_COp_2D A(lhs_ops); vector<Flex_COp_2D*> ops_vec; ops_vec.push_back(&A); Affine_Op_2D affine_lhs(lhs_theta, ops_vec); H1_InnProd_2D innprod(localIdentityIdentityOp2D, localLaplaceIdentityOp2D, localIdentityLaplaceOp2D); // Right Hand Side vector<ThetaStructure<ParamType>::ThetaFct> rhs_theta_fcts; rhs_theta_fcts.push_back(theta_chi_1); rhs_theta_fcts.push_back(theta_chi_2); rhs_theta_fcts.push_back(theta_chi_3); rhs_theta_fcts.push_back(theta_chi_4); rhs_theta_fcts.push_back(theta_chi_5); rhs_theta_fcts.push_back(theta_chi_6); rhs_theta_fcts.push_back(theta_chi_7); rhs_theta_fcts.push_back(theta_chi_8); rhs_theta_fcts.push_back(theta_chi_9); rhs_theta_fcts.push_back(theta_chi_10); rhs_theta_fcts.push_back(theta_chi_11); rhs_theta_fcts.push_back(theta_chi_12); rhs_theta_fcts.push_back(theta_chi_13); rhs_theta_fcts.push_back(theta_chi_14); rhs_theta_fcts.push_back(theta_chi_15); rhs_theta_fcts.push_back(theta_chi_16); rhs_theta_fcts.push_back(theta_chi_17); rhs_theta_fcts.push_back(theta_chi_18); rhs_theta_fcts.push_back(theta_chi_19); rhs_theta_fcts.push_back(theta_chi_20); rhs_theta_fcts.push_back(theta_chi_21); rhs_theta_fcts.push_back(theta_chi_22); rhs_theta_fcts.push_back(theta_chi_23); rhs_theta_fcts.push_back(theta_chi_24); rhs_theta_fcts.push_back(theta_chi_25); rhs_theta_fcts.push_back(theta_chi_26); rhs_theta_fcts.push_back(theta_chi_27); rhs_theta_fcts.push_back(theta_chi_28); rhs_theta_fcts.push_back(theta_chi_29); rhs_theta_fcts.push_back(theta_chi_30); rhs_theta_fcts.push_back(theta_chi_31); rhs_theta_fcts.push_back(theta_chi_32); rhs_theta_fcts.push_back(theta_chi_33); rhs_theta_fcts.push_back(theta_chi_34); rhs_theta_fcts.push_back(theta_chi_35); rhs_theta_fcts.push_back(theta_chi_36); rhs_theta_fcts.push_back(theta_chi_37); rhs_theta_fcts.push_back(theta_chi_38); rhs_theta_fcts.push_back(theta_chi_39); rhs_theta_fcts.push_back(theta_chi_40); rhs_theta_fcts.push_back(theta_chi_41); rhs_theta_fcts.push_back(theta_chi_42); rhs_theta_fcts.push_back(theta_chi_43); rhs_theta_fcts.push_back(theta_chi_44); rhs_theta_fcts.push_back(theta_chi_45); rhs_theta_fcts.push_back(theta_chi_46); rhs_theta_fcts.push_back(theta_chi_47); rhs_theta_fcts.push_back(theta_chi_48); rhs_theta_fcts.push_back(theta_chi_49); ThetaStructure<ParamType> rhs_theta(rhs_theta_fcts); vector<Rhs*> rhs_fcts; rhs_fcts.push_back(&F1); rhs_fcts.push_back(&F2); rhs_fcts.push_back(&F3); rhs_fcts.push_back(&F4); rhs_fcts.push_back(&F5); rhs_fcts.push_back(&F6); rhs_fcts.push_back(&F7); rhs_fcts.push_back(&F8); rhs_fcts.push_back(&F9); rhs_fcts.push_back(&F10); rhs_fcts.push_back(&F11); rhs_fcts.push_back(&F12); rhs_fcts.push_back(&F13); rhs_fcts.push_back(&F14); rhs_fcts.push_back(&F15); rhs_fcts.push_back(&F16); rhs_fcts.push_back(&F17); rhs_fcts.push_back(&F18); rhs_fcts.push_back(&F19); rhs_fcts.push_back(&F20); rhs_fcts.push_back(&F21); rhs_fcts.push_back(&F22); rhs_fcts.push_back(&F23); rhs_fcts.push_back(&F24); rhs_fcts.push_back(&F25); rhs_fcts.push_back(&F26); rhs_fcts.push_back(&F27); rhs_fcts.push_back(&F28); rhs_fcts.push_back(&F29); rhs_fcts.push_back(&F30); rhs_fcts.push_back(&F31); rhs_fcts.push_back(&F32); rhs_fcts.push_back(&F33); rhs_fcts.push_back(&F34); rhs_fcts.push_back(&F35); rhs_fcts.push_back(&F36); rhs_fcts.push_back(&F37); rhs_fcts.push_back(&F38); rhs_fcts.push_back(&F39); rhs_fcts.push_back(&F40); rhs_fcts.push_back(&F41); rhs_fcts.push_back(&F42); rhs_fcts.push_back(&F43); rhs_fcts.push_back(&F44); rhs_fcts.push_back(&F45); rhs_fcts.push_back(&F46); rhs_fcts.push_back(&F47); rhs_fcts.push_back(&F48); rhs_fcts.push_back(&F49); Affine_Rhs_2D affine_rhs(rhs_theta, rhs_fcts); RieszF_Rhs_2D rieszF_rhs(rhs_fcts); RieszA_Rhs_2D rieszA_rhs(ops_vec); // Right Hand Sides for direct Riesz Representor AffineA_Rhs_2D affineA_rhs(lhs_theta, lhs_ops); RieszRes_Rhs_2D rieszRes_rhs(affineA_rhs, affine_rhs); //===============================================================// //=============== AWGM =========================================// //===============================================================// IS_Parameters is_parameters; AWGM_Parameters awgm_truth_parameters, awgm_riesz_f_parameters, awgm_riesz_a_parameters, awgm_riesz_res_parameters; awgm_truth_parameters.max_its = 1e+03; is_parameters.adaptive_tol = true; is_parameters.init_tol = 0.0001; is_parameters.res_reduction = 0.01; //----------- Solver ---------------- // T gamma = 0.2; IndexSet<Index2D> Lambda; getSparseGridIndexSet(basis2d, Lambda, 1, 0, gamma); MT_AWGM_Truth awgm_u(basis2d, affine_lhs, affine_rhs, prec, awgm_truth_parameters, is_parameters); awgm_u.set_sol(dummy); awgm_u.awgm_params.tol = 1e-04; awgm_u.awgm_params.max_basissize = 1e+06; awgm_u.set_initial_indexset(Lambda); MT_AWGM_Riesz_F awgm_rieszF(basis2d, innprod, rieszF_rhs, prec, awgm_riesz_f_parameters, is_parameters); awgm_rieszF.set_sol(dummy); awgm_rieszF.set_initial_indexset(Lambda); awgm_rieszF.awgm_params.tol = 5e-04; awgm_rieszF.awgm_params.info_filename = "stempel_rieszF_conv_info.txt"; MT_AWGM_Riesz_A awgm_rieszA(basis2d, innprod, rieszA_rhs, prec, awgm_riesz_a_parameters, is_parameters); awgm_rieszA.set_sol(dummy); awgm_rieszA.set_initial_indexset(Lambda); awgm_rieszA.awgm_params.tol = 5e-04; awgm_rieszA.awgm_params.info_filename = "stempel_rieszA_conv_info.txt"; MT_AWGM_Riesz_Res awgm_rieszRes(basis2d, innprod, rieszRes_rhs, prec, awgm_riesz_res_parameters, is_parameters); awgm_rieszRes.set_sol(dummy); awgm_rieszRes.set_initial_indexset(Lambda); awgm_rieszRes.awgm_params.tol = 5e-04; awgm_rieszRes.awgm_params.print_info = false; MTTruthSolver rb_truth(awgm_u, awgm_rieszF, awgm_rieszA, &awgm_rieszRes, innprod, affine_lhs, rieszF_rhs); //----------- RB System ---------------- // RB_Model rb_system(lhs_theta, rhs_theta); rb_system.rb_params.ref_param = {{1.}}; rb_system.rb_params.call = call_cg; //----------- RB Base ---------------- // RB_BaseModel rb_base(rb_system, rb_truth, Lambda); ParamType mu_min = {{0}}; ParamType mu_max = {{1}}; rb_base.greedy_params.training_type = weak; rb_base.greedy_params.tol = 1e-05; rb_base.greedy_params.min_param = mu_min; rb_base.greedy_params.max_param = mu_max; rb_base.greedy_params.Nmax = 6; rb_base.greedy_params.nb_training_params = {{nb_stempel}}; rb_base.greedy_params.log_scaling = {{0}}; rb_base.greedy_params.print_file = "toy_greedy_info.txt"; rb_base.greedy_params.trainingdata_folder = "training_data_toy"; rb_base.greedy_params.print_paramset = true; rb_base.greedy_params.erase_snapshot_params = false; rb_base.greedy_params.orthonormalize_bfs = true; rb_base.greedy_params.tighten_tol = true; rb_base.greedy_params.snapshot_tol_red_crit = repeated_param; rb_base.greedy_params.tighten_tol_rieszA = false; rb_base.greedy_params.tighten_tol_rieszF = false; rb_base.greedy_params.tighten_tol_reduction = 0.1, rb_base.greedy_params.update_snapshot = true; rb_base.greedy_params.update_rieszF = false; rb_base.greedy_params.update_rieszA = false; rb_base.greedy_params.test_estimator_equivalence = false; rb_base.greedy_params.write_direct_representors = false; rb_base.greedy_params.riesz_constant_X = 5.6; rb_base.greedy_params.riesz_constant_Y = 2; cout << "Parameters Training: " << std::endl << std::endl; rb_base.greedy_params.print(); rb_system.rb_params.print(); cout << "Parameters Truth Solver: " << std::endl << std::endl; awgm_u.awgm_params.print(); awgm_u.is_params.print(); cout << "Parameters Riesz Solver F : " << std::endl << std::endl; awgm_rieszF.awgm_params.print(); cout << "Parameters Riesz Solver A : " << std::endl << std::endl; awgm_rieszA.awgm_params.print(); cout << "Parameters Riesz Solver Res : " << std::endl << std::endl; awgm_rieszRes.awgm_params.print(); //rb_system.read_rb_data("training_data_toy"); //rb_base.read_basisfunctions("training_data_toy/bf"); /*for (int i=0; i<rb_base.n_bf(); ++i) { std::cout << " i = " << i+1 << std::endl; std::cout << rb_base.rb_basisfunctions[i].size() << std::endl; }*/ //rb_base.read_rieszrepresentors("training_data_toy/representors"); //rb_base.calculate_Riesz_RHS_information(true); //rb_base.calc_rb_data(); //rb_system.write_rb_data("training_data_toy"); rb_base.train_Greedy(); std::cout << "toy_offline exited normally\n"; return 0; }
static void RenderPackedRGB( vout_thread_t *p_vout, picture_t *p_pic ) { int length; length = 2 * p_sys->i_overlap_w2 * p_pic->p->i_pixel_pitch; if (p_sys->b_has_changed) { int i_plane_; int i_col_mod; Denom = F2(length / p_pic->p->i_pixel_pitch); a_2 = p_sys->a_2 * (ACCURACY / 100); a_1 = p_sys->a_1 * 2 * p_sys->i_overlap_w2 * (ACCURACY / 100); a_0 = p_sys->a_0 * Denom * (ACCURACY / 100); for(i_col_mod = 0; i_col_mod < 2; i_col_mod++) for (i_index = 0; i_index < length / p_pic->p->i_pixel_pitch; i_index++) for (i_plane_ = 0; i_plane_ < p_pic->p->i_pixel_pitch; i_plane_++) p_sys->lambda[i_col_mod][i_plane_][i_index] = clip_accuracy(!i_col_mod ? ACCURACY - (F4(a_2, a_1, i_index) + a_0) / Denom : ACCURACY - (F4(a_2, a_1,(length / p_pic->p->i_pixel_pitch) - i_index) + a_0) / Denom); } length = 2 * p_sys->i_overlap_h2; if (p_sys->b_has_changed) { int i_plane_; int i_row_mod; Denom = F2(length); a_2 = p_sys->a_2 * (ACCURACY / 100); a_1 = p_sys->a_1 * length * (ACCURACY / 100); a_0 = p_sys->a_0 * Denom * (ACCURACY / 100); for(i_row_mod = 0; i_row_mod < 2; i_row_mod++) for (i_index = 0; i_index < length; i_index++) for (i_plane_ = 0; i_plane_ < p_pic->p->i_pixel_pitch; i_plane_++) p_sys->lambda2[i_row_mod][i_plane_][i_index] = clip_accuracy(!i_row_mod ? ACCURACY - (F4(a_2, a_1, i_index) + a_0) / Denom : ACCURACY - (F4(a_2, a_1,(length) - i_index) + a_0) / Denom); } }
/* * RIPEMD-128 Compression Function */ void RIPEMD_128::compress_n(const byte input[], u32bit blocks) { for(u32bit i = 0; i != blocks; ++i) { for(u32bit j = 0; j != 16; ++j) M[j] = load_le<u32bit>(input, j); input += HASH_BLOCK_SIZE; u32bit A1 = digest[0], A2 = A1, B1 = digest[1], B2 = B1, C1 = digest[2], C2 = C1, D1 = digest[3], D2 = D1; const u32bit MAGIC2 = 0x5A827999, MAGIC3 = 0x6ED9EBA1, MAGIC4 = 0x8F1BBCDC, MAGIC5 = 0x50A28BE6, MAGIC6 = 0x5C4DD124, MAGIC7 = 0x6D703EF3; F1(A1,B1,C1,D1,M[ 0],11 ); F4(A2,B2,C2,D2,M[ 5], 8,MAGIC5); F1(D1,A1,B1,C1,M[ 1],14 ); F4(D2,A2,B2,C2,M[14], 9,MAGIC5); F1(C1,D1,A1,B1,M[ 2],15 ); F4(C2,D2,A2,B2,M[ 7], 9,MAGIC5); F1(B1,C1,D1,A1,M[ 3],12 ); F4(B2,C2,D2,A2,M[ 0],11,MAGIC5); F1(A1,B1,C1,D1,M[ 4], 5 ); F4(A2,B2,C2,D2,M[ 9],13,MAGIC5); F1(D1,A1,B1,C1,M[ 5], 8 ); F4(D2,A2,B2,C2,M[ 2],15,MAGIC5); F1(C1,D1,A1,B1,M[ 6], 7 ); F4(C2,D2,A2,B2,M[11],15,MAGIC5); F1(B1,C1,D1,A1,M[ 7], 9 ); F4(B2,C2,D2,A2,M[ 4], 5,MAGIC5); F1(A1,B1,C1,D1,M[ 8],11 ); F4(A2,B2,C2,D2,M[13], 7,MAGIC5); F1(D1,A1,B1,C1,M[ 9],13 ); F4(D2,A2,B2,C2,M[ 6], 7,MAGIC5); F1(C1,D1,A1,B1,M[10],14 ); F4(C2,D2,A2,B2,M[15], 8,MAGIC5); F1(B1,C1,D1,A1,M[11],15 ); F4(B2,C2,D2,A2,M[ 8],11,MAGIC5); F1(A1,B1,C1,D1,M[12], 6 ); F4(A2,B2,C2,D2,M[ 1],14,MAGIC5); F1(D1,A1,B1,C1,M[13], 7 ); F4(D2,A2,B2,C2,M[10],14,MAGIC5); F1(C1,D1,A1,B1,M[14], 9 ); F4(C2,D2,A2,B2,M[ 3],12,MAGIC5); F1(B1,C1,D1,A1,M[15], 8 ); F4(B2,C2,D2,A2,M[12], 6,MAGIC5); F2(A1,B1,C1,D1,M[ 7], 7,MAGIC2); F3(A2,B2,C2,D2,M[ 6], 9,MAGIC6); F2(D1,A1,B1,C1,M[ 4], 6,MAGIC2); F3(D2,A2,B2,C2,M[11],13,MAGIC6); F2(C1,D1,A1,B1,M[13], 8,MAGIC2); F3(C2,D2,A2,B2,M[ 3],15,MAGIC6); F2(B1,C1,D1,A1,M[ 1],13,MAGIC2); F3(B2,C2,D2,A2,M[ 7], 7,MAGIC6); F2(A1,B1,C1,D1,M[10],11,MAGIC2); F3(A2,B2,C2,D2,M[ 0],12,MAGIC6); F2(D1,A1,B1,C1,M[ 6], 9,MAGIC2); F3(D2,A2,B2,C2,M[13], 8,MAGIC6); F2(C1,D1,A1,B1,M[15], 7,MAGIC2); F3(C2,D2,A2,B2,M[ 5], 9,MAGIC6); F2(B1,C1,D1,A1,M[ 3],15,MAGIC2); F3(B2,C2,D2,A2,M[10],11,MAGIC6); F2(A1,B1,C1,D1,M[12], 7,MAGIC2); F3(A2,B2,C2,D2,M[14], 7,MAGIC6); F2(D1,A1,B1,C1,M[ 0],12,MAGIC2); F3(D2,A2,B2,C2,M[15], 7,MAGIC6); F2(C1,D1,A1,B1,M[ 9],15,MAGIC2); F3(C2,D2,A2,B2,M[ 8],12,MAGIC6); F2(B1,C1,D1,A1,M[ 5], 9,MAGIC2); F3(B2,C2,D2,A2,M[12], 7,MAGIC6); F2(A1,B1,C1,D1,M[ 2],11,MAGIC2); F3(A2,B2,C2,D2,M[ 4], 6,MAGIC6); F2(D1,A1,B1,C1,M[14], 7,MAGIC2); F3(D2,A2,B2,C2,M[ 9],15,MAGIC6); F2(C1,D1,A1,B1,M[11],13,MAGIC2); F3(C2,D2,A2,B2,M[ 1],13,MAGIC6); F2(B1,C1,D1,A1,M[ 8],12,MAGIC2); F3(B2,C2,D2,A2,M[ 2],11,MAGIC6); F3(A1,B1,C1,D1,M[ 3],11,MAGIC3); F2(A2,B2,C2,D2,M[15], 9,MAGIC7); F3(D1,A1,B1,C1,M[10],13,MAGIC3); F2(D2,A2,B2,C2,M[ 5], 7,MAGIC7); F3(C1,D1,A1,B1,M[14], 6,MAGIC3); F2(C2,D2,A2,B2,M[ 1],15,MAGIC7); F3(B1,C1,D1,A1,M[ 4], 7,MAGIC3); F2(B2,C2,D2,A2,M[ 3],11,MAGIC7); F3(A1,B1,C1,D1,M[ 9],14,MAGIC3); F2(A2,B2,C2,D2,M[ 7], 8,MAGIC7); F3(D1,A1,B1,C1,M[15], 9,MAGIC3); F2(D2,A2,B2,C2,M[14], 6,MAGIC7); F3(C1,D1,A1,B1,M[ 8],13,MAGIC3); F2(C2,D2,A2,B2,M[ 6], 6,MAGIC7); F3(B1,C1,D1,A1,M[ 1],15,MAGIC3); F2(B2,C2,D2,A2,M[ 9],14,MAGIC7); F3(A1,B1,C1,D1,M[ 2],14,MAGIC3); F2(A2,B2,C2,D2,M[11],12,MAGIC7); F3(D1,A1,B1,C1,M[ 7], 8,MAGIC3); F2(D2,A2,B2,C2,M[ 8],13,MAGIC7); F3(C1,D1,A1,B1,M[ 0],13,MAGIC3); F2(C2,D2,A2,B2,M[12], 5,MAGIC7); F3(B1,C1,D1,A1,M[ 6], 6,MAGIC3); F2(B2,C2,D2,A2,M[ 2],14,MAGIC7); F3(A1,B1,C1,D1,M[13], 5,MAGIC3); F2(A2,B2,C2,D2,M[10],13,MAGIC7); F3(D1,A1,B1,C1,M[11],12,MAGIC3); F2(D2,A2,B2,C2,M[ 0],13,MAGIC7); F3(C1,D1,A1,B1,M[ 5], 7,MAGIC3); F2(C2,D2,A2,B2,M[ 4], 7,MAGIC7); F3(B1,C1,D1,A1,M[12], 5,MAGIC3); F2(B2,C2,D2,A2,M[13], 5,MAGIC7); F4(A1,B1,C1,D1,M[ 1],11,MAGIC4); F1(A2,B2,C2,D2,M[ 8],15 ); F4(D1,A1,B1,C1,M[ 9],12,MAGIC4); F1(D2,A2,B2,C2,M[ 6], 5 ); F4(C1,D1,A1,B1,M[11],14,MAGIC4); F1(C2,D2,A2,B2,M[ 4], 8 ); F4(B1,C1,D1,A1,M[10],15,MAGIC4); F1(B2,C2,D2,A2,M[ 1],11 ); F4(A1,B1,C1,D1,M[ 0],14,MAGIC4); F1(A2,B2,C2,D2,M[ 3],14 ); F4(D1,A1,B1,C1,M[ 8],15,MAGIC4); F1(D2,A2,B2,C2,M[11],14 ); F4(C1,D1,A1,B1,M[12], 9,MAGIC4); F1(C2,D2,A2,B2,M[15], 6 ); F4(B1,C1,D1,A1,M[ 4], 8,MAGIC4); F1(B2,C2,D2,A2,M[ 0],14 ); F4(A1,B1,C1,D1,M[13], 9,MAGIC4); F1(A2,B2,C2,D2,M[ 5], 6 ); F4(D1,A1,B1,C1,M[ 3],14,MAGIC4); F1(D2,A2,B2,C2,M[12], 9 ); F4(C1,D1,A1,B1,M[ 7], 5,MAGIC4); F1(C2,D2,A2,B2,M[ 2],12 ); F4(B1,C1,D1,A1,M[15], 6,MAGIC4); F1(B2,C2,D2,A2,M[13], 9 ); F4(A1,B1,C1,D1,M[14], 8,MAGIC4); F1(A2,B2,C2,D2,M[ 9],12 ); F4(D1,A1,B1,C1,M[ 5], 6,MAGIC4); F1(D2,A2,B2,C2,M[ 7], 5 ); F4(C1,D1,A1,B1,M[ 6], 5,MAGIC4); F1(C2,D2,A2,B2,M[10],15 ); F4(B1,C1,D1,A1,M[ 2],12,MAGIC4); F1(B2,C2,D2,A2,M[14], 8 ); D2 = digest[1] + C1 + D2; digest[1] = digest[2] + D1 + A2; digest[2] = digest[3] + A1 + B2; digest[3] = digest[0] + B1 + C2; digest[0] = D2; } }
/* The RIPEMD160 compression function. */ static inline void rmd160_compress(struct rmd160_ctx *ctx, uint32_t *buf) { uint8_t w, round; uint32_t T; uint32_t AL, BL, CL, DL, EL; /* left line */ uint32_t AR, BR, CR, DR, ER; /* right line */ uint32_t X[16]; /* Byte-swap the buffer if we're on a big-endian machine */ cpu_to_le32_array(X, buf, 16); /* Load the left and right lines with the initial state */ AL = AR = ctx->h[0]; BL = BR = ctx->h[1]; CL = CR = ctx->h[2]; DL = DR = ctx->h[3]; EL = ER = ctx->h[4]; /* Round 1 */ round = 0; for (w = 0; w < 16; w++) { /* left line */ T = rol32(AL + F1(BL, CL, DL) + X[RL[round][w]] + KL[round], SL[round][w]) + EL; AL = EL; EL = DL; DL = rol32(CL, 10); CL = BL; BL = T; } for (w = 0; w < 16; w++) { /* right line */ T = rol32(AR + F5(BR, CR, DR) + X[RR[round][w]] + KR[round], SR[round][w]) + ER; AR = ER; ER = DR; DR = rol32(CR, 10); CR = BR; BR = T; } /* Round 2 */ round++; for (w = 0; w < 16; w++) { /* left line */ T = rol32(AL + F2(BL, CL, DL) + X[RL[round][w]] + KL[round], SL[round][w]) + EL; AL = EL; EL = DL; DL = rol32(CL, 10); CL = BL; BL = T; } for (w = 0; w < 16; w++) { /* right line */ T = rol32(AR + F4(BR, CR, DR) + X[RR[round][w]] + KR[round], SR[round][w]) + ER; AR = ER; ER = DR; DR = rol32(CR, 10); CR = BR; BR = T; } /* Round 3 */ round++; for (w = 0; w < 16; w++) { /* left line */ T = rol32(AL + F3(BL, CL, DL) + X[RL[round][w]] + KL[round], SL[round][w]) + EL; AL = EL; EL = DL; DL = rol32(CL, 10); CL = BL; BL = T; } for (w = 0; w < 16; w++) { /* right line */ T = rol32(AR + F3(BR, CR, DR) + X[RR[round][w]] + KR[round], SR[round][w]) + ER; AR = ER; ER = DR; DR = rol32(CR, 10); CR = BR; BR = T; } /* Round 4 */ round++; for (w = 0; w < 16; w++) { /* left line */ T = rol32(AL + F4(BL, CL, DL) + X[RL[round][w]] + KL[round], SL[round][w]) + EL; AL = EL; EL = DL; DL = rol32(CL, 10); CL = BL; BL = T; } for (w = 0; w < 16; w++) { /* right line */ T = rol32(AR + F2(BR, CR, DR) + X[RR[round][w]] + KR[round], SR[round][w]) + ER; AR = ER; ER = DR; DR = rol32(CR, 10); CR = BR; BR = T; } /* Round 5 */ round++; for (w = 0; w < 16; w++) { /* left line */ T = rol32(AL + F5(BL, CL, DL) + X[RL[round][w]] + KL[round], SL[round][w]) + EL; AL = EL; EL = DL; DL = rol32(CL, 10); CL = BL; BL = T; } for (w = 0; w < 16; w++) { /* right line */ T = rol32(AR + F1(BR, CR, DR) + X[RR[round][w]] + KR[round], SR[round][w]) + ER; AR = ER; ER = DR; DR = rol32(CR, 10); CR = BR; BR = T; } /* Final mixing stage */ T = ctx->h[1] + CL + DR; ctx->h[1] = ctx->h[2] + DL + ER; ctx->h[2] = ctx->h[3] + EL + AR; ctx->h[3] = ctx->h[4] + AL + BR; ctx->h[4] = ctx->h[0] + BL + CR; ctx->h[0] = T; }
/* This is a simple example of multi-dimensional integration using a simple (not necessarily optimal) spacing of points. Note that this doesn't perform any error estimation - it only calculates the value for a given grid size. */ double IntegrateExample_dumb( int functionCode, int n, // How many points on each dimension const float *a, // An array of k lower bounds const float *b, // An array of k upper bounds const float *params // Parameters to function ){ int k=-1, total=-1, i0, i1, i2, j; // Accumulate in double, as it avoids floating-point errors when adding large // numbers of values together. Note that using double in a GPU has implications, // as some GPUs cannot do doubles, and on others they are much slower than floats double acc=0; //float *x=NULL; int n0=n, n1=n, n2=n; // By default use n points in each dimension switch(functionCode){ case 0: k=1; break; case 1: k=2; break; case 2: k=3; break; case 3: k=3; break; case 4: k=3; break; case 5: k=3; break; case 6: k=3; break; default: fprintf(stderr, "Invalid function code."); exit(1); } // Collapse any dimensions we don't use if(k<3){ n2=1; } if(k<2){ n1=1; } float* x = new float[k]; // Loop over highest dimension on outside, as it might be collapsed to zero for(i2=0;i2<n2;i2++){ if(k>2){ x[2]=a[2]+(b[2]-a[2]) * (i2+0.5f)/n2; } for(i1=0;i1<n1;i1++){ if(k>1){ x[1]=a[1]+(b[1]-a[1]) * (i1+0.5f)/n1; } // Inner dimension is never collapsed to zero for(i0=0;i0<n0;i0++){ x[0]=a[0]+(b[0]-a[0]) * (i0+0.5f)/n0; // Now call the function. Note that it is rather // inefficient to be choosing the function in the inner loop... // MAKE A FUNCTION POINTER FURTHER UP THEN USE IT!!!! switch(functionCode){ case 0: acc+=F0(x,params); break; case 1: acc+=F1(x,params); break; case 2: acc+=F2(x,params); break; case 3: acc+=F3(x,params); break; case 4: acc+=F4(x,params); break; case 5: acc+=F5(x,params); break; case 6: acc+=F6(x,params); break; } } } } // Do the final normalisation and return the results for(j=0;j<k;j++){ acc=acc*(b[j]-a[j]); } return acc/(n0*n1*n2); }