/// process 64 bytes void MD5::processBlock(const void* data) { // get last hash uint32_t a = m_hash[0]; uint32_t b = m_hash[1]; uint32_t c = m_hash[2]; uint32_t d = m_hash[3]; // data represented as 16x 32-bit words const uint32_t* words = (uint32_t*) data; // computations are little endian, swap data if necessary #if defined(__BYTE_ORDER) && (__BYTE_ORDER != 0) && (__BYTE_ORDER == __BIG_ENDIAN) #define LITTLEENDIAN(x) swap(x) #else #define LITTLEENDIAN(x) (x) #endif // first round uint32_t word0 = LITTLEENDIAN(words[ 0]); a = rotate(a + f1(b,c,d) + word0 + 0xd76aa478, 7) + b; uint32_t word1 = LITTLEENDIAN(words[ 1]); d = rotate(d + f1(a,b,c) + word1 + 0xe8c7b756, 12) + a; uint32_t word2 = LITTLEENDIAN(words[ 2]); c = rotate(c + f1(d,a,b) + word2 + 0x242070db, 17) + d; uint32_t word3 = LITTLEENDIAN(words[ 3]); b = rotate(b + f1(c,d,a) + word3 + 0xc1bdceee, 22) + c; uint32_t word4 = LITTLEENDIAN(words[ 4]); a = rotate(a + f1(b,c,d) + word4 + 0xf57c0faf, 7) + b; uint32_t word5 = LITTLEENDIAN(words[ 5]); d = rotate(d + f1(a,b,c) + word5 + 0x4787c62a, 12) + a; uint32_t word6 = LITTLEENDIAN(words[ 6]); c = rotate(c + f1(d,a,b) + word6 + 0xa8304613, 17) + d; uint32_t word7 = LITTLEENDIAN(words[ 7]); b = rotate(b + f1(c,d,a) + word7 + 0xfd469501, 22) + c; uint32_t word8 = LITTLEENDIAN(words[ 8]); a = rotate(a + f1(b,c,d) + word8 + 0x698098d8, 7) + b; uint32_t word9 = LITTLEENDIAN(words[ 9]); d = rotate(d + f1(a,b,c) + word9 + 0x8b44f7af, 12) + a; uint32_t word10 = LITTLEENDIAN(words[10]); c = rotate(c + f1(d,a,b) + word10 + 0xffff5bb1, 17) + d; uint32_t word11 = LITTLEENDIAN(words[11]); b = rotate(b + f1(c,d,a) + word11 + 0x895cd7be, 22) + c; uint32_t word12 = LITTLEENDIAN(words[12]); a = rotate(a + f1(b,c,d) + word12 + 0x6b901122, 7) + b; uint32_t word13 = LITTLEENDIAN(words[13]); d = rotate(d + f1(a,b,c) + word13 + 0xfd987193, 12) + a; uint32_t word14 = LITTLEENDIAN(words[14]); c = rotate(c + f1(d,a,b) + word14 + 0xa679438e, 17) + d; uint32_t word15 = LITTLEENDIAN(words[15]); b = rotate(b + f1(c,d,a) + word15 + 0x49b40821, 22) + c; // second round a = rotate(a + f2(b,c,d) + word1 + 0xf61e2562, 5) + b; d = rotate(d + f2(a,b,c) + word6 + 0xc040b340, 9) + a; c = rotate(c + f2(d,a,b) + word11 + 0x265e5a51, 14) + d; b = rotate(b + f2(c,d,a) + word0 + 0xe9b6c7aa, 20) + c; a = rotate(a + f2(b,c,d) + word5 + 0xd62f105d, 5) + b; d = rotate(d + f2(a,b,c) + word10 + 0x02441453, 9) + a; c = rotate(c + f2(d,a,b) + word15 + 0xd8a1e681, 14) + d; b = rotate(b + f2(c,d,a) + word4 + 0xe7d3fbc8, 20) + c; a = rotate(a + f2(b,c,d) + word9 + 0x21e1cde6, 5) + b; d = rotate(d + f2(a,b,c) + word14 + 0xc33707d6, 9) + a; c = rotate(c + f2(d,a,b) + word3 + 0xf4d50d87, 14) + d; b = rotate(b + f2(c,d,a) + word8 + 0x455a14ed, 20) + c; a = rotate(a + f2(b,c,d) + word13 + 0xa9e3e905, 5) + b; d = rotate(d + f2(a,b,c) + word2 + 0xfcefa3f8, 9) + a; c = rotate(c + f2(d,a,b) + word7 + 0x676f02d9, 14) + d; b = rotate(b + f2(c,d,a) + word12 + 0x8d2a4c8a, 20) + c; // third round a = rotate(a + f3(b,c,d) + word5 + 0xfffa3942, 4) + b; d = rotate(d + f3(a,b,c) + word8 + 0x8771f681, 11) + a; c = rotate(c + f3(d,a,b) + word11 + 0x6d9d6122, 16) + d; b = rotate(b + f3(c,d,a) + word14 + 0xfde5380c, 23) + c; a = rotate(a + f3(b,c,d) + word1 + 0xa4beea44, 4) + b; d = rotate(d + f3(a,b,c) + word4 + 0x4bdecfa9, 11) + a; c = rotate(c + f3(d,a,b) + word7 + 0xf6bb4b60, 16) + d; b = rotate(b + f3(c,d,a) + word10 + 0xbebfbc70, 23) + c; a = rotate(a + f3(b,c,d) + word13 + 0x289b7ec6, 4) + b; d = rotate(d + f3(a,b,c) + word0 + 0xeaa127fa, 11) + a; c = rotate(c + f3(d,a,b) + word3 + 0xd4ef3085, 16) + d; b = rotate(b + f3(c,d,a) + word6 + 0x04881d05, 23) + c; a = rotate(a + f3(b,c,d) + word9 + 0xd9d4d039, 4) + b; d = rotate(d + f3(a,b,c) + word12 + 0xe6db99e5, 11) + a; c = rotate(c + f3(d,a,b) + word15 + 0x1fa27cf8, 16) + d; b = rotate(b + f3(c,d,a) + word2 + 0xc4ac5665, 23) + c; // fourth round a = rotate(a + f4(b,c,d) + word0 + 0xf4292244, 6) + b; d = rotate(d + f4(a,b,c) + word7 + 0x432aff97, 10) + a; c = rotate(c + f4(d,a,b) + word14 + 0xab9423a7, 15) + d; b = rotate(b + f4(c,d,a) + word5 + 0xfc93a039, 21) + c; a = rotate(a + f4(b,c,d) + word12 + 0x655b59c3, 6) + b; d = rotate(d + f4(a,b,c) + word3 + 0x8f0ccc92, 10) + a; c = rotate(c + f4(d,a,b) + word10 + 0xffeff47d, 15) + d; b = rotate(b + f4(c,d,a) + word1 + 0x85845dd1, 21) + c; a = rotate(a + f4(b,c,d) + word8 + 0x6fa87e4f, 6) + b; d = rotate(d + f4(a,b,c) + word15 + 0xfe2ce6e0, 10) + a; c = rotate(c + f4(d,a,b) + word6 + 0xa3014314, 15) + d; b = rotate(b + f4(c,d,a) + word13 + 0x4e0811a1, 21) + c; a = rotate(a + f4(b,c,d) + word4 + 0xf7537e82, 6) + b; d = rotate(d + f4(a,b,c) + word11 + 0xbd3af235, 10) + a; c = rotate(c + f4(d,a,b) + word2 + 0x2ad7d2bb, 15) + d; b = rotate(b + f4(c,d,a) + word9 + 0xeb86d391, 21) + c; // update hash m_hash[0] += a; m_hash[1] += b; m_hash[2] += c; m_hash[3] += d; }
main() { printf("%d\n",t(f1,t(f1,f2(10)))); printf("%d\n",t(f2,t(f2,f1(10)))); }
__attribute__ ((noinline)) int main1 (void) { int i, j; for (j = 0; j < 8; j++) { for (i = 0; i <= N; i++) { ia[i] = i + 3; ib[i] = i + N + 3; asm (""); } switch (j) { case 0: f1 (); break; case 1: f2 (); break; case 2: f3 (); break; case 3: f4 (); break; case 4: f5 (); break; case 5: f6 (); break; case 6: f7 (); break; case 7: f8 (); break; } for (i = 0; i <= N; i++) { int ea = i + 3; int eb = i + N + 3; switch (j) { case 0: if (i) ea = 1; if (i == 0) eb = 3; else if (i != N) eb = 1; break; case 1: if (i != N) ea = 1; if (i != N) eb = i + 4; break; case 2: if (i) ea = 1; if (i != N) eb = i + 3; break; case 3: if (i != N) ea = 1; if (i < N - 1) eb = 1; else if (i == N - 1) eb = 67; break; case 4: ea = 1 + (i != N); break; case 5: ea = 2 - (i != N); break; case 6: ea = 1 + (i == 0); break; case 7: ea = 2 - (i == 0); break; } if (ia[i] != ea || ib[i] != eb) abort (); } } return 0; }
void sha1_core(const uint32_t M[16], uint32_t hash_value[5]) { uint32_t H0; uint32_t H1; uint32_t H2; uint32_t H3; uint32_t H4; uint32_t W[80]; uint32_t A, B, C, D, E, TEMP; int t; /* copy hash_value into H0, H1, H2, H3, H4 */ H0 = hash_value[0]; H1 = hash_value[1]; H2 = hash_value[2]; H3 = hash_value[3]; H4 = hash_value[4]; /* copy/xor message into array */ W[0] = be32_to_cpu(M[0]); W[1] = be32_to_cpu(M[1]); W[2] = be32_to_cpu(M[2]); W[3] = be32_to_cpu(M[3]); W[4] = be32_to_cpu(M[4]); W[5] = be32_to_cpu(M[5]); W[6] = be32_to_cpu(M[6]); W[7] = be32_to_cpu(M[7]); W[8] = be32_to_cpu(M[8]); W[9] = be32_to_cpu(M[9]); W[10] = be32_to_cpu(M[10]); W[11] = be32_to_cpu(M[11]); W[12] = be32_to_cpu(M[12]); W[13] = be32_to_cpu(M[13]); W[14] = be32_to_cpu(M[14]); W[15] = be32_to_cpu(M[15]); TEMP = W[13] ^ W[8] ^ W[2] ^ W[0]; W[16] = S1(TEMP); TEMP = W[14] ^ W[9] ^ W[3] ^ W[1]; W[17] = S1(TEMP); TEMP = W[15] ^ W[10] ^ W[4] ^ W[2]; W[18] = S1(TEMP); TEMP = W[16] ^ W[11] ^ W[5] ^ W[3]; W[19] = S1(TEMP); TEMP = W[17] ^ W[12] ^ W[6] ^ W[4]; W[20] = S1(TEMP); TEMP = W[18] ^ W[13] ^ W[7] ^ W[5]; W[21] = S1(TEMP); TEMP = W[19] ^ W[14] ^ W[8] ^ W[6]; W[22] = S1(TEMP); TEMP = W[20] ^ W[15] ^ W[9] ^ W[7]; W[23] = S1(TEMP); TEMP = W[21] ^ W[16] ^ W[10] ^ W[8]; W[24] = S1(TEMP); TEMP = W[22] ^ W[17] ^ W[11] ^ W[9]; W[25] = S1(TEMP); TEMP = W[23] ^ W[18] ^ W[12] ^ W[10]; W[26] = S1(TEMP); TEMP = W[24] ^ W[19] ^ W[13] ^ W[11]; W[27] = S1(TEMP); TEMP = W[25] ^ W[20] ^ W[14] ^ W[12]; W[28] = S1(TEMP); TEMP = W[26] ^ W[21] ^ W[15] ^ W[13]; W[29] = S1(TEMP); TEMP = W[27] ^ W[22] ^ W[16] ^ W[14]; W[30] = S1(TEMP); TEMP = W[28] ^ W[23] ^ W[17] ^ W[15]; W[31] = S1(TEMP); /* process the remainder of the array */ for (t=32; t < 80; t++) { TEMP = W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]; W[t] = S1(TEMP); } A = H0; B = H1; C = H2; D = H3; E = H4; for (t=0; t < 20; t++) { TEMP = S5(A) + f0(B,C,D) + E + W[t] + SHA_K0; E = D; D = C; C = S30(B); B = A; A = TEMP; } for ( ; t < 40; t++) { TEMP = S5(A) + f1(B,C,D) + E + W[t] + SHA_K1; E = D; D = C; C = S30(B); B = A; A = TEMP; } for ( ; t < 60; t++) { TEMP = S5(A) + f2(B,C,D) + E + W[t] + SHA_K2; E = D; D = C; C = S30(B); B = A; A = TEMP; } for ( ; t < 80; t++) { TEMP = S5(A) + f3(B,C,D) + E + W[t] + SHA_K3; E = D; D = C; C = S30(B); B = A; A = TEMP; } hash_value[0] = H0 + A; hash_value[1] = H1 + B; hash_value[2] = H2 + C; hash_value[3] = H3 + D; hash_value[4] = H4 + E; return; }
/* Hashes 'data', which should be a pointer to 512 bits of data (sixteen 32 bit ints), into the ongoing 160 bit hash value (five 32 bit ints) 'hash' */ int sha_hash(int *data, int *hash) { int W[80]; unsigned int A=hash[0], B=hash[1], C=hash[2], D=hash[3], E=hash[4]; unsigned int t, x, TEMP; for (t=0; t<16; t++) { #ifndef WORDS_BIGENDIAN W[t]=switch_endianness(data[t]); #else W[t]=data[t]; #endif } /* SHA1 Data expansion */ for (t=16; t<80; t++) { x=W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]; W[t]=rol1(x); } /* SHA1 main loop (t=0 to 79) This is broken down into four subloops in order to use the correct round function and constant */ for (t=0; t<20; t++) { TEMP=rol5(A) + f1(B,C,D) + E + W[t] + K1; E=D; D=C; C=rol30(B); B=A; A=TEMP; } for (; t<40; t++) { TEMP=rol5(A) + f2(B,C,D) + E + W[t] + K2; E=D; D=C; C=rol30(B); B=A; A=TEMP; } for (; t<60; t++) { TEMP=rol5(A) + f3(B,C,D) + E + W[t] + K3; E=D; D=C; C=rol30(B); B=A; A=TEMP; } for (; t<80; t++) { TEMP=rol5(A) + f2(B,C,D) + E + W[t] + K4; E=D; D=C; C=rol30(B); B=A; A=TEMP; } hash[0]+=A; hash[1]+=B; hash[2]+=C; hash[3]+=D; hash[4]+=E; return 0; }
static void f1(int i, int j, int k, int l){ printf("int f1():\n"); printf("globval=%d, autoval=%d, regival=%d, volaval=%d,statval=%d\n", globval, i, j, k, l); f2(); }
//creates a Mesh with the appropriate values and returns its pointer //calculates the rotation Mesh* Surfrev::createMesh() { Mesh* m = new Mesh(); //empty mesh float degrees = 360/slices; float angle = 0; vec3 Y(0,1,0); //inserts all points doing the rotation around the y-axis for(int i=0; i<slices; i++) { for(int j=0; j<points; j++) { vec3 v = rotation3D(Y,angle)*polyline[j]; //cout<<"X = "<<v[0]<<" Y = "<<v[1] <<" Z = "<< v[2]<<endl; m->addVertex(v); } angle += degrees; } for(int i=0; i<(slices*points)-1; i++) { //finds normal for face that is going to be inserted to the mesh if(i<((slices*points)-(points+1))) { int mod = (1+i)%points; if(mod != 0) { /*cout<<"--------\nPoint: "<<i<<endl; cout<<"i+1: "<<i+1<<endl; cout<<"i+1+points: "<<i+1+points<<endl; cout<<"i+points: "<<i+points<<"\n"<<endl; cout<<(mod)<<" = Mod\n\n";*/ } vec4 vert1(m->getVertex(i)[0],m->getVertex(i)[1],m->getVertex(i)[2],1); vec4 vert2(m->getVertex(i+1)[0],m->getVertex(i+1)[1],m->getVertex(i+1)[2],1); vec4 vert3(m->getVertex(i+points+1)[0],m->getVertex(i+points+1)[1],m->getVertex(i+points+1)[2],1); //check for final point that has x = 0: triangle not square if(((i+2)%points) == 0 && m->getVertex(i+1)[0] == 0) { vert3[0] = m->getVertex(i+points)[0]; vert3[1] = m->getVertex(i+points)[1]; vert3[2] = m->getVertex(i+points)[2]; } vec4 n = getNormal(vert1,vert2,vert3); vec3 normal(n[0],n[1],n[2]); if(mod != 0) { /*std::cout<<"Normal x = "<<normal[0]<<std::endl; std::cout<<"Normal y = "<<normal[1]<<std::endl; std::cout<<"Normal z = "<<normal[2]<<std::endl;*/ } m->addNormal(normal); ////creates the faces, normal index is = i, always have 4 vertices for a face vec2 f1((double)i,(double)i); vec2 f2((double)i+1,(double)i); vec2 f3((double)points+i+1,(double)i); vec2 f4((double)points+i,(double)i); std::vector<vec2> face; face.push_back(f2); face.push_back(f1); face.push_back(f4); face.push_back(f3); if(mod != 0) { //cout<<"add face: "<<i<<endl; m->addFace(face); } } //case: do last face else { int mod = (1+i)%points; int k = (points*slices); /*cout<<"Else Point: "<<i<<endl; cout<<"i+1: "<<i+1<<endl; cout<<"i+1+points: "<<i+1+points-k<<endl; cout<<"i+points: "<<i+points-k<<"\n"<<endl; cout<<(mod)<<" = Mod\n\n";*/ vec4 vert1L(m->getVertex(i)[0],m->getVertex(i)[1],m->getVertex(i)[2],1); vec4 vert2L(m->getVertex(i+1)[0],m->getVertex(i+1)[1],m->getVertex(i+1)[2],1); vec4 vert3L(m->getVertex(i+points+1-k)[0],m->getVertex(i+points+1-k)[1],m->getVertex(i+points+1-k)[2],1); if(((i+2)%points) == 0 && m->getVertex(i+1)[0] == 0) { vert3L[0] = m->getVertex(i+points-k)[0]; vert3L[1] = m->getVertex(i+points-k)[1]; vert3L[2] = m->getVertex(i+points-k)[2]; } vec4 nL = getNormal(vert1L,vert2L,vert3L); vec3 normalL(nL[0],nL[1],nL[2]); /*std::cout<<"--------\nNormal x = "<<normal[0]<<std::endl; std::cout<<"Normal y = "<<normal[1]<<std::endl; std::cout<<"Normal z = "<<normal[2]<<std::endl;*/ m->addNormal(normalL); //creates the faces, normal index is = i, always have 4 vertices for a face vec2 f1L((double)i,(double)i); vec2 f2L((double)i+1,(double)i); vec2 f3L((double)points+i+1-k,(double)i); vec2 f4L((double)points+i-k,(double)i); std::vector<vec2> faceL; faceL.push_back(f2L); faceL.push_back(f1L); faceL.push_back(f4L); faceL.push_back(f3L); if(mod != 0) { //cout<<"add face: "<<i<<endl; m->addFace(faceL); } } } //check if there is an opening at the top or bottom to cap or not if(polyline[0][0] != 0) { //cap the bottom /*cout<<"X1 = "<<m->getVertex(0)[0]<<" Y1 = "<<m->getVertex(0)[1]<<" Z1 = "<<m->getVertex(points-1)[2]<<endl; cout<<"X2 = "<<m->getVertex((points))[0]<<" Y2 = "<<m->getVertex((points))[1]<<" Z2 = "<<m->getVertex((points))[2]<<endl; cout<<"X3 = "<<m->getVertex((points*2))[0]<<" Y3 = "<<m->getVertex((points*2))[1]<<" Z3 = "<<m->getVertex((points*2))[2]<<"\n"<<endl;*/ vec4 vert1(m->getVertex(0)[0],m->getVertex(0)[1],m->getVertex(0)[2],1); vec4 vert2(m->getVertex(points)[0],m->getVertex(points)[1],m->getVertex(points)[2],1); vec4 vert3(m->getVertex(points*2)[0],m->getVertex(points*2)[1],m->getVertex(points*2)[2],1); vec4 n = getNormal(vert1,vert2,vert3); vec3 normal(n[0],n[1],n[2]); m->addNormal(normal); std::vector<vec2> face; for(int k=0; k<slices; k++) { vec2 f((double)points*k,(double)m->lastNorm()); face.push_back(f); } m->addFace(face); } if(polyline[points-1][0] != 0) { //cap the top /*cout<<"Top\nX1 = "<<m->getVertex(points-1)[0]<<" Y1 = "<<m->getVertex(points-1)[1]<<" Z1 = "<<m->getVertex(points-1)[2]<<endl; cout<<"X2 = "<<m->getVertex((points*2)-1)[0]<<" Y2 = "<<m->getVertex((points*2)-1)[1]<<" Z2 = "<<m->getVertex((points*2)-1)[2]<<endl; cout<<"X3 = "<<m->getVertex((points*3)-1)[0]<<" Y3 = "<<m->getVertex((points*3)-1)[1]<<" Z3 = "<<m->getVertex((points*3)-1)[2]<<"\n"<<endl;*/ vec4 vert1(m->getVertex(points-1)[0],m->getVertex(points-1)[1],m->getVertex(points-1)[2],1); vec4 vert2(m->getVertex((points*2)-1)[0],m->getVertex((points*2)-1)[1],m->getVertex((points*2)-1)[2],1); vec4 vert3(m->getVertex((points*3)-1)[0],m->getVertex((points*3)-1)[1],m->getVertex((points*3)-1)[2],1); vec4 n = getNormal(vert1,vert2,vert3); n = n * (-1); vec3 normal(n[0],n[1],n[2]); m->addNormal(normal); std::vector<vec2> face; for(int k=1; k<slices+1; k++) { vec2 f((double)(points*k)-1,(double)m->lastNorm()); face.push_back(f); } m->addFace(face); } return m; }
void test13() { f2() ? (void)0 : (void)0; }
void roo_fitWH() { TString poscharge = "Plus"; TString negcharge = "Minus"; std::vector<TString> charge(2); charge.at(0) = poscharge; charge.at(1) = negcharge; TString canvas_name_plus = "muon_MC_WHelicityFramePlots_PlusICVar"; TCanvas *c0 = new TCanvas(canvas_name_plus,"",450,400); TString canvas_name_minus = "muon_MC_WHelicityFramePlots_MinusICVar"; TCanvas *c1 = new TCanvas(canvas_name_minus,"",450,400); // Run both for + and - charges for(unsigned int j=0; j<charge.size(); j++) { // if (j==1) break; // do only + charge fit if (realData) { sfactor=36; } // Nominal values are taken from a fit to the MC W data (scaled to 100pb-1) RooRealVar *fLnom, *fRnom, *f0nom; if (j==0) { fLnom=new RooRealVar("fL_nom","fLnom",0.556); fRnom=new RooRealVar("fR_nom","fRnom",0.234); f0nom=new RooRealVar("f0_nom","f0nom",0.210); } else { fLnom=new RooRealVar("fL_nom","fLnom",0.523); fRnom=new RooRealVar("fR_nom","fRnom",0.265); f0nom=new RooRealVar("f0_nom","f0nom",0.212); } TString Hist1 = "RECO_PolPlots_50toinf/RECO_ICVarPF"+ charge.at(j) + "_LH"; TString Hist2 = "RECO_PolPlots_50toinf/RECO_ICVarPF"+ charge.at(j) + "_RH"; TString Hist3 = "RECO_PolPlots_50toinf/RECO_ICVarPF"+ charge.at(j) + "_LO"; TString Hist_data1 = "RECO_PolPlots_50toinf/RECO_ICVarPF"+ charge.at(j); TH1D *mc1 = (TH1D*)sigfile->Get(Hist1); TH1D *mc2 = (TH1D*)sigfile->Get(Hist2); TH1D *mc3 = (TH1D*)sigfile->Get(Hist3); TH1D *sighist = (TH1D*)sigfile->Get(Hist_data1); // W signal histogram TH1D *bkghist=(TH1D*)bkgfile->Get(Hist_data1); // Bkg histogram TH1D *hdata=(TH1D*)datafile->Get(Hist_data1); // Real data histogram // //we are only fitting for fL and fR // double accFactor1 = refTempHist1->Integral() / mc1->Integral(); // double accFactor2 = refTempHist2->Integral() / mc2->Integral(); // double accFactor3 = refTempHist3->Integral() / mc3->Integral(); // double normFactor = (mc1->Integral() + mc2->Integral() + mc3->Integral()) / (refTempHist1->Integral() + refTempHist2->Integral() + refTempHist3->Integral()); mc1->Rebin(rbin); mc2->Rebin(rbin); mc3->Rebin(rbin); sighist->Rebin(rbin); bkghist->Rebin(rbin); hdata->Rebin(rbin); // Scale to sfactor/pb if MC //if (!realData) { if (toyMC) sfactor=400; sighist->Scale(sfactor); bkghist->Scale(sfactor); // } //datahist->Scale(invWeightW);//to get MC errors - otherwise comment out Double_t nbkg=0; TH1D *datahist; if (realData) { datahist=hdata; } else { datahist=(TH1D*)sighist->Clone(); if (addbkg) {datahist->Add(bkghist); } } if (addbkg) { //nbkg=bkghist->Integral(); nbkg=bkghist->Integral(bkghist->FindBin(xmin+quanta),bkghist->FindBin(xmax-quanta)); } //Double_t istat=datahist->Integral(); //Double_t f_sig=(sighist->Integral())/istat; // signal fraction Double_t istat=datahist->Integral(datahist->FindBin(xmin+quanta),datahist->FindBin(xmax-quanta)); Double_t f_sig=(sighist->Integral(sighist->FindBin(xmin+quanta),sighist->FindBin(xmax-quanta)))/istat; Double_t f_bkg=nbkg/istat; // bkg fraction // Start RooFit session RooRealVar x("x","LP",xmin,xmax); // Import binned Data RooDataHist data1("data1","dataset with WHICVarPlus",x,mc1); RooDataHist data2("data2","dataset with WHICVarPlus",x,mc2); RooDataHist data3("data3","dataset with WHICVarPlus",x,mc3); RooDataHist test("data","dataset with WHICVarPlus",x,datahist); RooDataHist data_bkg("data4","dataset with ICVar",x,bkghist); // Relative fractions - allow them to float to negative values too if needs be // if (fitMode==0) { RooRealVar f1("fL","fL fraction",fLnom->getVal(),0.,1.); RooRealVar f2("fR","fR fraction", fRnom->getVal(),0.,1.); RooFormulaVar f3("f0","1-fL-fR",RooArgList(f1,f2)); if (fitMode) { f1.setVal((fLnom->getVal()-fRnom->getVal())); f1.setRange(-1.,1.); f1.setPlotLabel("f_{L}-f_{R}"); f2.setVal(f0nom->getVal()); f2.setPlotLabel("f_{0}"); } // } else { // RooRealVar f1("fL","fL fraction",(fLnom->getVal()-fRnom->getVal()),-1.,1.); // RooRealVar f2("fR","fR fraction", (fLnom->getVal()+fRnom->getVal()),-1.,1.); // RooFormulaVar f3("f0","1-fL-fR",RooArgList(f1,f2)); // } RooRealVar fsub("fsub","fsub par",(fLnom->getVal()-fRnom->getVal()),-1.,1.); RooRealVar fsum("fsum","fsum par",(fLnom->getVal()+fRnom->getVal()), -1.,1.); // Background template RooHistPdf *bkg = new RooHistPdf("bkg","bkg",x,data_bkg); // Bkg fraction RooRealVar fbkg("f_{bkg}","f_bkg fraction",f_bkg); // Templates RooHistPdf h1("h1","h1",x,data1); // left-handed template histogram RooHistPdf h2("h2","h2",x,data2); // right-handed template histo RooHistPdf h3("h3","h3",x,data3); // longitudinal template histo // Construct model PDF RooAbsPdf *sig, *model; if (charge.at(j) == "Plus") { // plus charge PDFs if (addParameter) { sig = new RooWPlusExtended("sigmodel","model",x,f1,f2,fsub); } else { sig = new RooWPlus("sigmodel","model",x,f1,f2); } } else if (charge.at(j) == "Minus") { // minus charge PDFs if (addParameter) { sig = new RooWMinusExtended("sigmodel","model",x,f1,f2,fsub); } else { sig = new RooWMinus("sigmodel","model",x,f1,f2); } } if (addbkg) { model = new RooAddPdf("model","model",RooArgList(*bkg,*sig),fbkg); } else { model = sig; } // Set the Fit Range x.setRange("fitrange",-0.0,1.3); // Construct likelihood ( + penalty term) RooNLLVar nll("nll","nll",*model,test,Range("fitrange")); RooRealVar pen("pen","penalty term",(0.5*1./(0.01*0.01))); RooFormulaVar nllPen("nllPen","nll+pen*fsub^2",RooArgList(nll,pen,fsub)); // Fitting RooMinuit *m; if (!addParameter) { m = new RooMinuit(nll); } else { m = new RooMinuit(nllPen);} if (!toyMC) { m->migrad(); m->hesse(); } RooFitResult *res1 = m->save(); // Re-diced data // Int_t nevt=static_cast<int>(istat); // RooDataSet *gtest = model->generate(x,nevt); // Fitting // RooFitResult * res1 = model.fitTo(test,Minos(kFALSE), Save()); // res1->Print(); if(makePlots) { // Temp PDF for plotting purposes // RooAddPdf temp("temp","component 1",RooArgList(*h1,*h2,*h3),RooArgList(*f1,*f2)) ; // Plotting gROOT->SetStyle("Plain"); gStyle->SetOptFit(0); gStyle->SetOptTitle(0); gStyle->SetOptStat(0); //gStyle->SetCanvasDefH(600); //Height of canvas //gStyle->SetCanvasDefW(600); //Width of canvas if(charge.at(j) == "Plus") { c0->cd(); //c0->Divide(2,1);c0->cd(1); } if(charge.at(j) == "Minus") { c1->cd(); //c1->Divide(2,1);c1->cd(1); } //RooPlot* frame = new RooPlot(0.0,1.3,0,800); RooPlot* frame = x.frame(); test.plotOn(frame,Name("data")); model->plotOn(frame,Name("model")); // model->paramOn(frame);//, Format("NELU", AutoPrecision(2)), Layout(0.1,0.5,0.9)); // h1.plotOn(frame); // h2.plotOn(frame); // h3.plotOn(frame); // model->plotOn(frame, Components(h1),LineColor(kRed),LineStyle(kDashed)); // temp->plotOn(frame, Components(h2),LineColor(kGreen),LineStyle(kDashed)); // temp->plotOn(frame, Components(h3),LineColor(kYellow),LineStyle(kDashed)); if (addbkg) { // model->plotOn(frame, Components(h1),FillColor(5),DrawOption("F")); //model->plotOn(frame,Components(*bkg),FillColor(5),DrawOption("")); } hdata->GetYaxis()->SetTitle("Events / 0.1"); if(charge.at(j) == "Plus") { hdata->GetXaxis()->SetTitle("#it{L_{P}}(#mu^{+})");} if(charge.at(j) == "Minus") {hdata->GetXaxis()->SetTitle("#it{L_{P}}(#mu^{-})");} hdata->GetXaxis()->SetTitleSize(0.06); hdata->GetXaxis()->SetTitleOffset(1.); hdata->GetYaxis()->SetTitleSize(0.06); hdata->GetYaxis()->SetTitleOffset(1.2); hdata->GetXaxis()->SetLabelSize(0.055); hdata->GetYaxis()->SetLabelSize(0.055); hdata->GetXaxis()->SetRangeUser(0.0,1.29); hdata->GetYaxis()->SetRangeUser(0.0,600); hdata->SetMarkerStyle(20); // mc1->Draw("same"); // Goodness-of-fit Double_t chi2= frame->chiSquare("model","data",3); Double_t nllmin=res1->minNll(); cout << "" << endl; cout << "Printing out the goodness-of-fit measure:" << endl; cout << "chi2 = " << chi2 << "\t" << "min NLL = " << nllmin << endl; res1->Print(); // TCanvas* testt = new TCanvas ("testt","hj"); cout <<"intetral: "<< hdata->Integral()<<endl; hdata->GetXaxis()->SetRangeUser(0.0,1.29); cout << hdata->Integral()<<endl; hdata->Draw(""); // frame->Draw("same"); mc1->GetXaxis()->SetRangeUser(0.0,1.29); float f_l_a = mc1->Integral(); mc2->GetXaxis()->SetRangeUser(0.0,1.29); float f_r_a = mc2->Integral(); mc3->GetXaxis()->SetRangeUser(0.0,1.29); float f_0_a = mc3->Integral(); float allData = hdata->Integral(); float EWKBkg = allData*(f_bkg); float WData = allData*(1-f_bkg); float f_l = 0.5*(1-f2.getVal()+f1.getVal()); float f_r = 0.5*(1-f2.getVal()-f1.getVal()); float f_0 = f2.getVal(); cout << "f_l: "<< f_l<< ",f_r: "<< f_r<< ", f_0: "<< f_0<< " 1= "<< f_l+f_r+f_0<< endl; float allW = f_l*f_l_a+f_r*f_r_a+f_0*f_0_a; //hdata->Draw(""); // bkghist->GetXaxis()->SetRangeUser(0.0,1.3); bkghist->Scale(EWKBkg/bkghist->Integral()); bkghist->Draw("samehist"); bkghist->SetLineColor(kYellow); bkghist->SetFillColor(kYellow); mc1->Scale(f_l*WData/allW); mc2->Scale(f_r*WData/allW); mc3->Scale(f_0*WData/allW); mc1->SetLineColor(kRed); mc2->SetLineColor(kGreen); mc3->SetLineColor(kBlue); mc1->SetLineWidth(3); mc2->SetLineWidth(3); mc3->SetLineWidth(3); mc1->SetLineStyle(2); mc2->SetLineStyle(3); mc3->SetLineStyle(4); mc1->Draw("samehist"); mc2->Draw("samehist"); mc3->Draw("samehist"); TH1D* allHists = (TH1D*)mc1->Clone(); allHists->Add(mc2,1); allHists->Add(mc3,1); allHists->Add(bkghist,1); allHists->SetLineWidth(3); // frame->SetOptFit(0); frame->Draw("same"); // allHists->Draw("same"); TLegend* aleg; //if(charge.at(j) == "Minus") aleg = new TLegend(0.2,0.69,0.6,0.9,""); // if(charge.at(j) == "Plus") //aleg = new TLegend(0.5,0.6,0.7,0.9,"");//new TLegend(0.8,0.69,0.95,0.9,""); aleg = new TLegend(0.2017937,0.7419355,0.4775785,0.9193548,NULL,"brNDC"); aleg->SetNColumns(2); aleg->SetFillColor(0); aleg->SetLineColor(0); aleg->AddEntry(mc1,"f_{L}","lf"); aleg->AddEntry(mc2,"f_{R}","lf"); aleg->AddEntry(mc3,"f_{0}","lf"); aleg->AddEntry(bkghist,"EWK","lf"); TH1* dummyhist = new TH1F("", "", 1, 0, 1); dummyhist->SetLineColor(kBlue); dummyhist->SetLineWidth(3); aleg->AddEntry(dummyhist, "fit result", "lf"); aleg->AddEntry(hdata, "data","P"); aleg->Draw("same"); //TLatex* preliminary; //TLatex* text; //if(false) { //text = new TLatex(0.35,480,"#splitline{f_{L}-f_{R}=0.240#pm0.036(stat.)#pm0.031(syst.)}{f_{0}=0.183#pm0.087(stat.)#pm0.123(syst.)}"); //preliminary = new TLatex(0.35,550,"CMS preliminary: #it{L} = 36pb^{-1}@ 7 TeV"); //} //if(true){ //text = new TLatex(0.05,480,"#splitline{f_{L}-f_{R}=0.310#pm0.036(stat.)#pm0.017(syst.)}{f_{0}=0.171#pm0.085(stat.)#pm0.099(syst.)}"); //preliminary = new TLatex(0.05,550,"#splitline{CMS, #sqrt{s} = 7 TeV,}{#it{L_{int}} = 36 pb^{-1}}");} //preliminary->SetTextSize(0.043); //preliminary->Draw("same"); //text->SetTextSize(0.043); // text->Draw("same"); /* // Draw Minuit contours if(charge.at(j) == "Plus") { c0->cd(2); } else { c1->cd(2); } // RooPlot *rcont=m->contour(f1,f2,1,2); // rcont->Draw(); RooPlot *rcontour=new RooPlot(f1,f2); res1->plotOn(rcontour,f1,f2,"ME123VHB"); rcontour->Draw(); if (fitMode) { rcontour->GetXaxis()->SetTitle("f_{L}-f_{R}"); rcontour->GetYaxis()->SetTitle("f_{0}"); } else { rcontour->GetXaxis()->SetTitle("f_{L}"); rcontour->GetYaxis()->SetTitle("f_{R}"); } */ } TLatex * text = new TLatex(0.7451931,500.8655,"#splitline{CMS, #sqrt{s} = 7 TeV}{L_{ int} = 36 pb^{-1}}"); text->SetTextSize(0.043); text->SetLineWidth(2); text->Draw("same"); const TMatrixDSym& cor = res1->correlationMatrix(); const TMatrixDSym& cov = res1->covarianceMatrix(); //Print correlation, covariance matrix cout << "correlation matrix" << endl; cor.Print(); cout << "covariance matrix" << endl; cov.Print(); cout << f1 << endl; cout << f2 << endl; if (!fitMode) { cout << "f0 = " << f3 << " +/- " << f3.getPropagatedError(*res1) << endl; } } if(makePlots) { c0->Print(canvas_name_plus+".pdf"); c1->Print(canvas_name_minus+".pdf"); } if (toyMC) { // MC STudies Int_t nevt=istat; Int_t nEXP=100; RooMCStudy mgr(*model,*model,x,"","mhrv"); mgr.generateAndFit(nEXP,nevt,kTRUE); TCanvas *cp0 = new TCanvas("c0","",1200,400); cp0->Divide(3,1); cp0->cd(1); RooPlot *p1=mgr.plotParam(f1); p1->Draw(); if (fitMode) p1->SetTitle(";f_{L}-f_{R};number of toys"); cp0->cd(2); RooPlot *p2 = mgr.plotError(f1); p2->Draw(); if (fitMode) p2->SetTitle(";#delta (f_{L}-f_{R});number of toys"); cp0->cd(3); // f1 pull RooPlot* m1pframe = mgr.plotPull(f1,-3.,3.,30,kTRUE); m1pframe->Draw(); if (fitMode) { m1pframe->SetTitle(";f_{L}-f_{R};number of toys"); } TCanvas *cp02 = new TCanvas("c1","",1200,400); cp02->Divide(3,1); cp02->cd(1); RooPlot *p3=mgr.plotParam(f2); p3->Draw(); if (fitMode) p3->SetTitle(";f_{0};number of toys"); cp02->cd(2); RooPlot *p4=mgr.plotError(f2); p4->Draw(); if (fitMode) p4->SetTitle(";#delta f_{0}; number of toys"); cp02->cd(3); // f2 pull RooPlot* m2pframe = mgr.plotPull(f2,-3.,3.,30,kTRUE); m2pframe->Draw(); if (fitMode) { m2pframe->SetTitle(";f_{0};number of toys"); } TCanvas *cnll = new TCanvas("cnll",""); RooPlot* nllframe = mgr.plotNLL(); // nllframe->Draw(); } return; }
int main() { std::cout << "############----EX00----###############" << std::endl; { { FragTrap f1; while (f1.hit_points() > 0) { f1.beRepaired(5); f1.takeDamage(25); f1.meleeAttack("Warior"); f1.rangedAttack("Robot"); f1.vaulthunter_dot_exe("Man"); std::cout << std::endl; std::cout << "Hit Points: " << f1.hit_points() << std::endl; } } std::cout << "_________________" << std::endl; { FragTrap f2("NOOD"); while (f2.hit_points() > 0) { f2.beRepaired(5); f2.takeDamage(35); f2.vaulthunter_dot_exe("Man"); std::cout << std::endl; std::cout << "Hit Points: " << f2.hit_points() << std::endl; } } } std::cout << "############----EX01----###############" << std::endl; { std::cout << "_______FR4G_______" << std::endl; { FragTrap f1; while (f1.hit_points() > 0) { f1.beRepaired(5); f1.takeDamage(25); f1.meleeAttack("Warior"); f1.rangedAttack("Robot"); f1.vaulthunter_dot_exe("Man"); std::cout << std::endl; std::cout << "Hit Points: " << f1.hit_points() << std::endl; } } std::cout << "_______SC4V_______" << std::endl; { ScavTrap s1("BOT"); while (s1.hit_points() > 0) { s1.beRepaired(5); s1.takeDamage(35); s1.challengeNewcomer("Woman"); std::cout << std::endl; std::cout << "Hit Points: " << s1.hit_points() << std::endl; } } } std::cout << "############----EX02----###############" << std::endl; { std::cout << "_______FR4G_______" << std::endl; FragTrap *f1 = new FragTrap("Yana"); while (f1->hit_points() > 0) { f1->beRepaired(5); f1->takeDamage(25); f1->meleeAttack("Warior"); f1->rangedAttack("Robot"); f1->vaulthunter_dot_exe("Man"); std::cout << std::endl; std::cout << "Hit Points: " << f1->hit_points() << std::endl; } delete f1; std::cout << "_______SC4V_______" << std::endl; ScavTrap *s1 = new ScavTrap("Paul"); while (s1->hit_points() > 0) { s1->beRepaired(5); s1->takeDamage(35); s1->challengeNewcomer("Woman"); std::cout << std::endl; std::cout << "Hit Points: " << s1->hit_points() << std::endl; } delete s1; } std::cout << std::endl << "############----EX03----###############" << std::endl << std::endl; { std::cout << "_______FR4G_______" << std::endl; FragTrap *f1 = new FragTrap("Robot"); std::cout << "_______SC4V_______" << std::endl; ScavTrap *s1 = new ScavTrap("Warior"); std::cout << "_______NINJA_______" << std::endl; NinjaTrap *n1 = new NinjaTrap("Boss"); n1->takeDamage(20); n1->beRepaired(10); n1->ninjaShoebox(*n1); n1->ninjaShoebox(*f1); n1->ninjaShoebox(*s1); std::cout << "_______NINJA_______" << std::endl; delete n1; std::cout << "_______SC4V_______" << std::endl; delete s1; std::cout << "_______FR4G_______" << std::endl; delete f1; } std::cout << std::endl << "############----EX04----###############" << std::endl << std::endl; { SuperTrap sc("sysy"); FragTrap lol("lol"); sc.rangedAttack("yany"); sc.meleeAttack("yany"); sc.vaulthunter_dot_exe("popol"); sc.ninjaShoebox(lol); std::cout << std::endl; std::cout << std::endl; std::cout << std::endl; } return 0; }
int run_main (int, ACE_TCHAR *[]) { ACE_START_TEST (ACE_TEXT ("Future_Test")); #if defined (ACE_HAS_THREADS) // @@ Should make these be <auto_ptr>s... Prime_Scheduler *andres, *peter, *helmut, *matias; // Create active objects.. ACE_NEW_RETURN (andres, Prime_Scheduler (ACE_TEXT ("andres")), -1); int result = andres->open (); ACE_ASSERT (result != -1); ACE_NEW_RETURN (peter, Prime_Scheduler (ACE_TEXT ("peter")), -1); result = peter->open (); ACE_ASSERT (result != -1); ACE_NEW_RETURN (helmut, Prime_Scheduler (ACE_TEXT ("helmut")), -1); result = helmut->open (); ACE_ASSERT (result != -1); // Matias passes all asynchronous method calls on to Andres... ACE_NEW_RETURN (matias, Prime_Scheduler (ACE_TEXT ("matias"), andres), -1); result = matias->open (); ACE_ASSERT (result != -1); for (int i = 0; i < n_loops; i++) { { ACE_Future<u_long> fresulta; ACE_Future<u_long> fresultb; ACE_Future<u_long> fresultc; ACE_Future<u_long> fresultd; ACE_Future<u_long> fresulte; ACE_Future<const ACE_TCHAR *> fname; ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) going to do a non-blocking call\n"))); // Spawn off the methods, which run in a separate thread as // active object invocations. fresulta = andres->work (9013); fresultb = peter->work (9013); fresultc = helmut->work (9013); fresultd = matias->work (9013); fname = andres->name (); // See if the result is available... if (fresulta.ready ()) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) wow.. work is ready.....\n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) non-blocking call done... now blocking...\n"))); // Save the result of fresulta. fresulte = fresulta; if (i % 3 == 0) { // Every 3rd time... disconnect the futures... but // "fresulte" should still contain the result... fresulta.cancel (10ul); fresultb.cancel (20ul); fresultc.cancel (30ul); fresultd.cancel (40ul); } u_long resulta = 0, resultb = 0, resultc = 0, resultd = 0, resulte = 0; fresulta.get (resulta); fresultb.get (resultb); fresultc.get (resultc); fresultd.get (resultd); fresulte.get (resulte); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) result a %u\n") ACE_TEXT ("(%t) result b %u\n") ACE_TEXT ("(%t) result c %u\n") ACE_TEXT ("(%t) result d %u\n") ACE_TEXT ("(%t) result e %u\n"), (u_int) resulta, (u_int) resultb, (u_int) resultc, (u_int) resultd, (u_int) resulte)); const ACE_TCHAR *name = 0; fname.get (name); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) name %s\n"), name)); } ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) task_count %d future_count %d ") ACE_TEXT ("capsule_count %d method_request_count %d\n"), task_count.value (), future_count.value (), capsule_count.value (), method_request_count.value ())); } // Close things down. andres->end (); peter->end (); helmut->end (); matias->end (); ACE_Thread_Manager::instance ()->wait (); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) task_count %d future_count %d ") ACE_TEXT ("capsule_count %d method_request_count %d\n"), task_count.value (), future_count.value (), capsule_count.value (), method_request_count.value ())); { // Check if set then get works, older versions of <ACE_Future> // will lock forever (or until the timer expires), will use a // small timer value to avoid blocking the process. ACE_Future<int> f1; f1.set (100); // Note you need to use absolute time, not relative time. ACE_Time_Value timeout (ACE_OS::gettimeofday () + ACE_Time_Value (10)); int value = 0; if (f1.get (value, &timeout) == 0 && value == 100) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Ace_Future<T>::Set followed by Ace_Future<T>::Get works.\n"))); else ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Future<T>::Set followed by Ace_Future<T>::Get does ") ACE_TEXT ("not work, broken Ace_Future<> implementation.\n"))); } { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Checking if Ace_Future<T>::operator= is implemented ") ACE_TEXT ("incorrectly this might crash the program.\n"))); ACE_Future<int> f1; { // To ensure that a rep object is created. ACE_Future<int> f2 (f1); } // Now it is one ACE_Future<int> referencing the rep instance ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("0.\n"))); //Check that self assignment works. f1 = f1; // Is there any repesentation left, and if so what is the ref // count older ACE_Future<> implementations have deleted the rep // instance at this moment // The stuff below might crash the process if the <operator=> // implementation was bad. int value = 0; ACE_Time_Value timeout (ACE_OS::gettimeofday () + ACE_Time_Value (10)); f1.set (100); f1.get (value, &timeout); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("1.\n"))); { // Might delete the same data a couple of times. ACE_Future<int> f2 (f1); f1.set (100); f1.get (value, &timeout); } ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("2.\n"))); { ACE_Future<int> f2 (f1); f1.set (100); f1.get (value, &timeout); } ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("3.\n"))); { ACE_Future<int> f2 (f1); f1.set (100); f1.get (value, &timeout); } ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("4.\n"))); { ACE_Future<int> f2 (f1); f1.set (100); f1.get (value, &timeout); } ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("5.\n"))); { ACE_Future<int> f2 (90); f2.get (value, &timeout); f1.get (value, &timeout); } } ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("No it did not crash the program.\n"))); delete andres; delete peter; delete helmut; delete matias; #else ACE_ERROR ((LM_INFO, ACE_TEXT ("threads not supported on this platform\n"))); #endif /* ACE_HAS_THREADS */ ACE_END_TEST; return 0; }
// { dg-do assemble } // Bug: the temporary from the default parameter to f2 is reused. struct A {}; int f2 (int i, const A& ar = A()); void f (int i, int j = f2(1)); void g () { f (1); } void h () { f (1); }
void bar(void) { f1(ext, loc_small, loc_big[0]); clobber; f2(&ext, &loc_small, &loc_big[0]); }
static void f1(int argc){ if(argc == 1) longjmp(env,1); f2(); }
int main(void) { std::cout << "PART 00" << std::endl; // ------------------- PART 00 ------------------------------ // Bureaucrat b1("b1", 5); Bureaucrat b2("b2", 147); try { Bureaucrat *b3 = new Bureaucrat("b3", 1000); delete b3; } catch (std::exception &e) { std::cout << "Error: " << e.what() << std::endl; } for (int i = 0; i < 8; i++) { try { b1 += 1; b2 -= 1; } catch (std::exception &e) { std::cout << "Error: " << e.what() << std::endl; } std::cout << b1; std::cout << b2; } std::cout << std::endl << "PART 01" << std::endl; // ------------------- PART 01 ------------------------------ // Form f1("f1", 5, 5); Form f2("f2", 100, 100); try { Form *f3 = new Form("f3", 1000, 1000); delete f3; } catch (std::exception &e) { std::cout << "Error: " << e.what() << std::endl; } std::cout << f1; std::cout << f2; try { b1.signForm(f1); } catch (std::exception &e) { std::cout << "Error: " << e.what() << std::endl; } std::cout << f1; try { b2.signForm(f1); } catch (std::exception &e) { std::cout << "Error: " << e.what() << std::endl; } std::cout << f1; try { b1.signForm(f2); } catch (std::exception &e) { std::cout << "Error: " << e.what() << std::endl; } std::cout << f2; try { b2.signForm(f2); } catch (std::exception &e) { std::cout << "Error: " << e.what() << std::endl; } std::cout << f2; try { b2.signForm(f2); } catch (std::exception &e) { std::cout << "Error: " << e.what() << std::endl; } std::cout << f2; return (0); }
main() { float a=0; float b=1; float alpha=0; float h=0.2; float beta=0; float n1; int n; float Z; float z; float x; float y; float Y; float *Y_arr; float *y_arr; float k1,k2,l1,l2,m1,m2,p1,p2; int i; float K1,K2; float final_y; printf("Enter the value of 'a'\n"); scanf("%f",&a); printf("Enter the value of 'b'\n"); scanf("%f",&b); printf("Enter the value of 'h'\n"); scanf("%f",&h); printf("Enter the value of alpha\n"); scanf("%f",&alpha); printf("Enter the value of beta\n"); scanf("%f",&beta); n1=(b-a)/h; n=n1; Z=-1; z=1; //alpha x=a; y=alpha; Y=alpha; Y_arr=(float *) malloc(sizeof(float)*(n+1)); y_arr=(float *) malloc(sizeof(float)*(n+1)); Y_arr[0]=Y; y_arr[0]=y; printf("%d\n",n); for(i=1;i<=n;i++) { k1=h*f1(x,y,z); k2=h*f2(x,y,z); l1=h*f1(x+h/2,y+k1/2,z+k2/2); l2=h*f2(x+h/2,y+k1/2,z+k2/2); m1=h*f1(x+h/2,y+l1/2,z+l2/2); m2=h*f2(x+h/2,y+l1/2,z+l2/2); p1=h*f1(x+h,y+m1,z+m2); p2=h*f2(x+h,y+m1,z+m2); x=x+h; y=y+((k1+2*l1+2*m1+p1)/6); z=z+((k2+2*l2+2*m2+p2)/6); y_arr[i]=y; } x=a; for(i=1;i<=n;i++) { k1=h*f1(x,Y,Z); k2=h*f2(x,Y,Z); l1=h*f1(x+h/2,Y+k1/2,Z+k2/2); l2=h*f2(x+h/2,Y+k1/2,Z+k2/2); m1=h*f1(x+h/2,Y+l1/2,Z+l2/2); m2=h*f2(x+h/2,Y+l1/2,Z+l2/2); p1=h*f1(x+h,Y+m1,Z+m2); p2=h*f2(x+h,Y+m1,Z+m2); x=x+h; Y=Y+((k1+2*l1+2*m1+p1)/6); Z=Z+((k2+2*l2+2*m2+p2)/6); Y_arr[i]=Y; } K1=(beta-y_arr[n])/(Y_arr[n]-y_arr[n]); K2=(Y_arr[n]-beta)/(Y_arr[n]-y_arr[n]); for(i=0;i<=n;i++) { final_y = (K1*Y_arr[i])+ (K2*y_arr[i]); printf("y%d=%f\n",i+1,final_y); } return 0; }
void test_f2() { float &fr = f2(AC().a); }
void t4p::PhpCodeCompletionProviderClass::HandleAutoCompletionPhp(const UnicodeString& code, const UnicodeString& word, pelet::LanguageDiscoveryClass::Syntax syntax, t4p::CodeControlClass* ctrl, wxString& completeStatus) { Lexer.SetVersion(App.PhpModule.Environment.Php.Version); Parser.SetVersion(App.PhpModule.Environment.Php.Version); ScopeFinder.SetVersion(App.PhpModule.Environment.Php.Version); std::vector<wxFileName> sourceDirs = App.Projects.AllEnabledSourceDirectories(); std::vector<wxString> autoCompleteList; std::vector<UnicodeString> variableMatches; int expressionPos = code.length() - 1; UnicodeString lastExpression = Lexer.LastExpression(code); pelet::ScopeClass scope; pelet::VariableClass parsedVariable(scope); pelet::ScopeClass variableScope; t4p::SymbolTableMatchErrorClass error; bool doDuckTyping = ctrl->CodeControlOptions.EnableDynamicAutoCompletion; if (!lastExpression.isEmpty()) { Parser.ParseExpression(lastExpression, parsedVariable); ScopeFinder.GetScopeString(code, expressionPos, variableScope); App.PhpModule.TagCache.ExpressionCompletionMatches(ctrl->GetIdString(), parsedVariable, variableScope, sourceDirs, variableMatches, AutoCompletionResourceMatches, doDuckTyping, error); if (!variableMatches.empty()) { for (size_t i = 0; i < variableMatches.size(); ++i) { wxString postFix = wxString::Format(wxT("?%d"), AUTOCOMP_IMAGE_VARIABLE); autoCompleteList.push_back(t4p::IcuToWx(variableMatches[i]) + postFix); } } else if (parsedVariable.ChainList.size() == 1) { // a bunch of function, define, or class names for (size_t i = 0; i < AutoCompletionResourceMatches.size(); ++i) { t4p::PhpTagClass res = AutoCompletionResourceMatches[i]; wxString postFix; if (t4p::PhpTagClass::DEFINE == res.Type) { postFix = wxString::Format(wxT("?%d"), AUTOCOMP_IMAGE_DEFINE); } else if (t4p::PhpTagClass::FUNCTION == res.Type) { postFix = wxString::Format(wxT("?%d"), AUTOCOMP_IMAGE_FUNCTION); } else if (t4p::PhpTagClass::CLASS == res.Type) { postFix = wxString::Format(wxT("?%d"), AUTOCOMP_IMAGE_CLASS); } autoCompleteList.push_back(t4p::IcuToWx(res.Identifier) + postFix); } // when completing standalone function names, also include keyword matches std::vector<wxString> keywordMatches = CollectNearMatchKeywords(t4p::IcuToWx(parsedVariable.ChainList[0].Name)); for (size_t i = 0; i < keywordMatches.size(); ++i) { wxString postFix = wxString::Format(wxT("?%d"), AUTOCOMP_IMAGE_KEYWORD); autoCompleteList.push_back(keywordMatches[i] + postFix); } } else if (!AutoCompletionResourceMatches.empty()) { // an object / function "chain" for (size_t i = 0; i < AutoCompletionResourceMatches.size(); ++i) { t4p::PhpTagClass res = AutoCompletionResourceMatches[i]; wxString comp = t4p::IcuToWx(res.Identifier); wxString postFix; if (t4p::PhpTagClass::MEMBER == res.Type && res.IsPrivate) { postFix = wxString::Format(wxT("?%d"), AUTOCOMP_IMAGE_PRIVATE_MEMBER); } else if (t4p::PhpTagClass::MEMBER == res.Type && res.IsProtected) { postFix = wxString::Format(wxT("?%d"), AUTOCOMP_IMAGE_PROTECTED_MEMBER); } else if (t4p::PhpTagClass::MEMBER == res.Type) { postFix = wxString::Format(wxT("?%d"), AUTOCOMP_IMAGE_PUBLIC_MEMBER); } else if (t4p::PhpTagClass::METHOD == res.Type && res.IsPrivate) { postFix = wxString::Format(wxT("?%d"), AUTOCOMP_IMAGE_PRIVATE_METHOD); } else if (t4p::PhpTagClass::METHOD == res.Type && res.IsProtected) { postFix = wxString::Format(wxT("?%d"), AUTOCOMP_IMAGE_PROTECTED_METHOD); } else if (t4p::PhpTagClass::METHOD == res.Type) { postFix = wxString::Format(wxT("?%d"), AUTOCOMP_IMAGE_PUBLIC_METHOD); } else if (t4p::PhpTagClass::CLASS_CONSTANT == res.Type) { postFix = wxString::Format(wxT("?%d"), AUTOCOMP_IMAGE_CLASS_CONSTANT); } autoCompleteList.push_back(comp + postFix); } } // auto complete any template variables std::vector<t4p::TemplateFileTagClass> templateFiles = App.PhpModule.CurrentTemplates(); std::vector<t4p::TemplateFileTagClass>::const_iterator templateFile; std::vector<wxString>::const_iterator variable; for (templateFile = templateFiles.begin(); templateFile != templateFiles.end(); ++templateFile) { wxFileName f1(templateFile->FullPath); wxFileName f2(ctrl->GetFileName()); if (f1 == f2) { for (variable = templateFile->Variables.begin(); variable != templateFile->Variables.end(); ++variable) { if (variable->Find(t4p::IcuToWx(lastExpression)) == 0) { wxString postFix = wxString::Format(wxT("?%d"), AUTOCOMP_IMAGE_VARIABLE); autoCompleteList.push_back(*variable + postFix); } } } } // in case of a double quoted string, complete SQL table names too // this is in addition to auto completing any variable names inside the string too if (pelet::LanguageDiscoveryClass::SYNTAX_PHP_DOUBLE_QUOTE_STRING == syntax) { AppendSqlTableNames(word, autoCompleteList); } } if (!autoCompleteList.empty()) { // scintilla needs the keywords sorted. sort(autoCompleteList.begin(), autoCompleteList.end()); wxString list; for (size_t i = 0; i < autoCompleteList.size(); ++i) { list += autoCompleteList[i]; if (i < (autoCompleteList.size() - 1)) { list += (wxChar)ctrl->AutoCompGetSeparator(); } } ctrl->AutoCompSetMaxWidth(0); int currentPos = ctrl->GetCurrentPos(); int startPos = ctrl->WordStartPosition(currentPos, true); int wordLength = currentPos - startPos; ctrl->AutoCompShow(wordLength, list); } else { HandleAutoCompletionPhpStatus(error, lastExpression, parsedVariable, variableScope, completeStatus); } }
// for convenience define f4, which appears frequently in the roots double complex f4(double complex x, double complex z) { return cpow( (f3(x,z) + csqrt( -256.0*f2(x,z)*f2(x,z)*f2(x,z) + f3(x,z)*f3(x,z) )) / 2.0, ONE_THIRD ); }
int main() { f1(0); f2(0); }
void sha1_final(sha1_ctx_t *ctx, uint32_t *output) { uint32_t A, B, C, D, E, TEMP; uint32_t W[80]; int i, t; /* * process the remaining octets_in_buffer, padding and terminating as * necessary */ { int tail = ctx->octets_in_buffer % 4; /* copy/xor message into array */ for (i=0; i < (ctx->octets_in_buffer+3)/4; i++) W[i] = be32_to_cpu(ctx->M[i]); /* set the high bit of the octet immediately following the message */ switch (tail) { case (3): W[i-1] = (be32_to_cpu(ctx->M[i-1]) & 0xffffff00) | 0x80; W[i] = 0x0; break; case (2): W[i-1] = (be32_to_cpu(ctx->M[i-1]) & 0xffff0000) | 0x8000; W[i] = 0x0; break; case (1): W[i-1] = (be32_to_cpu(ctx->M[i-1]) & 0xff000000) | 0x800000; W[i] = 0x0; break; case (0): W[i] = 0x80000000; break; } /* zeroize remaining words */ for (i++ ; i < 15; i++) W[i] = 0x0; /* * if there is room at the end of the word array, then set the * last word to the bit-length of the message; otherwise, set that * word to zero and then we need to do one more run of the * compression algo. */ if (ctx->octets_in_buffer < 56) W[15] = ctx->num_bits_in_msg; else if (ctx->octets_in_buffer < 60) W[15] = 0x0; /* process the word array */ for (t=16; t < 80; t++) { TEMP = W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]; W[t] = S1(TEMP); } A = ctx->H[0]; B = ctx->H[1]; C = ctx->H[2]; D = ctx->H[3]; E = ctx->H[4]; for (t=0; t < 20; t++) { TEMP = S5(A) + f0(B,C,D) + E + W[t] + SHA_K0; E = D; D = C; C = S30(B); B = A; A = TEMP; } for ( ; t < 40; t++) { TEMP = S5(A) + f1(B,C,D) + E + W[t] + SHA_K1; E = D; D = C; C = S30(B); B = A; A = TEMP; } for ( ; t < 60; t++) { TEMP = S5(A) + f2(B,C,D) + E + W[t] + SHA_K2; E = D; D = C; C = S30(B); B = A; A = TEMP; } for ( ; t < 80; t++) { TEMP = S5(A) + f3(B,C,D) + E + W[t] + SHA_K3; E = D; D = C; C = S30(B); B = A; A = TEMP; } ctx->H[0] += A; ctx->H[1] += B; ctx->H[2] += C; ctx->H[3] += D; ctx->H[4] += E; } debug_print(mod_sha1, "(final) running sha1_core()", NULL); if (ctx->octets_in_buffer >= 56) { debug_print(mod_sha1, "(final) running sha1_core() again", NULL); /* we need to do one final run of the compression algo */ /* * set initial part of word array to zeros, and set the * final part to the number of bits in the message */ for (i=0; i < 15; i++) W[i] = 0x0; W[15] = ctx->num_bits_in_msg; /* process the word array */ for (t=16; t < 80; t++) { TEMP = W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]; W[t] = S1(TEMP); } A = ctx->H[0]; B = ctx->H[1]; C = ctx->H[2]; D = ctx->H[3]; E = ctx->H[4]; for (t=0; t < 20; t++) { TEMP = S5(A) + f0(B,C,D) + E + W[t] + SHA_K0; E = D; D = C; C = S30(B); B = A; A = TEMP; } for ( ; t < 40; t++) { TEMP = S5(A) + f1(B,C,D) + E + W[t] + SHA_K1; E = D; D = C; C = S30(B); B = A; A = TEMP; } for ( ; t < 60; t++) { TEMP = S5(A) + f2(B,C,D) + E + W[t] + SHA_K2; E = D; D = C; C = S30(B); B = A; A = TEMP; } for ( ; t < 80; t++) { TEMP = S5(A) + f3(B,C,D) + E + W[t] + SHA_K3; E = D; D = C; C = S30(B); B = A; A = TEMP; } ctx->H[0] += A; ctx->H[1] += B; ctx->H[2] += C; ctx->H[3] += D; ctx->H[4] += E; } /* copy result into output buffer */ output[0] = be32_to_cpu(ctx->H[0]); output[1] = be32_to_cpu(ctx->H[1]); output[2] = be32_to_cpu(ctx->H[2]); output[3] = be32_to_cpu(ctx->H[3]); output[4] = be32_to_cpu(ctx->H[4]); /* indicate that message buffer in context is empty */ ctx->octets_in_buffer = 0; return; }
int main () { int i; check_vect (); for (i = 0; i < N; i++) { switch (i % 9) { case 0: asm (""); a[i] = - i - 1; b[i] = i + 1; break; case 1: a[i] = 0; b[i] = 0; break; case 2: a[i] = i + 1; b[i] = - i - 1; break; case 3: a[i] = i; b[i] = i + 7; break; case 4: a[i] = i; b[i] = i; break; case 5: a[i] = i + 16; b[i] = i + 3; break; case 6: a[i] = - i - 5; b[i] = - i; break; case 7: a[i] = - i; b[i] = - i; break; case 8: a[i] = - i; b[i] = - i - 7; break; } } for (i = 0; i < N; i++) { switch ((i / 9) % 3) { case 0: c[i] = a[i / 9]; d[i] = b[i / 9]; break; case 1: c[i] = a[i / 9 + 3]; d[i] = b[i / 9 + 3]; break; case 2: c[i] = a[i / 9 + 6]; d[i] = b[i / 9 + 6]; break; } } f1 (); for (i = 0; i < N; i++) if (k[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0)) abort (); __builtin_memset (k, 0, sizeof (k)); f2 (); for (i = 0; i < N; i++) if (k[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0)) abort (); __builtin_memset (k, 0, sizeof (k)); f3 (); for (i = 0; i < N; i++) if (k[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0)) abort (); __builtin_memset (k, 0, sizeof (k)); f4 (); for (i = 0; i < N; i++) if (k[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0)) abort (); __builtin_memset (k, 0, sizeof (k)); f5 (k); for (i = 0; i < N; i++) if (k[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0)) abort (); __builtin_memset (k, 0, sizeof (k)); f6 (k); for (i = 0; i < N; i++) if (k[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0)) abort (); __builtin_memset (k, 0, sizeof (k)); f7 (k); for (i = 0; i < N; i++) if (k[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0)) abort (); __builtin_memset (k, 0, sizeof (k)); f8 (k); for (i = 0; i < N; i++) if (k[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0)) abort (); __builtin_memset (k, 0, sizeof (k)); return 0; }
void f1(void) { f2(); return; }
// CHECK: diagnose_before_perform_inferring_CPU.cpp:[[@LINE-2]]:10: error: call from AMP-restricted function to CPU-restricted function // CHECK-NEXT: return f1(); // CHECK-NEXT: ^ int main(void) { f2(); return 0; }
void main (void) { int i; for (i = 0; i < 10; i++) f2 (); }
void VanDerPolOscillator::evalModel( const InArgs& inArgs, const OutArgs& outArgs ) const { // compute f(x) Teuchos::RCP<const Epetra_Vector> x = inArgs.get_x(); Teuchos::RCP<Epetra_Vector> f = outArgs.get_f(); if ( (x != Teuchos::null) && (f != Teuchos::null) ) { evalVField((*x)[0],(*x)[1],(*f)[0],(*f)[1]); } // compute f([x]) Teuchos::RCP<const Teuchos::Polynomial<Epetra_Vector> > x_poly = inArgs.get_x_poly(); Teuchos::RCP<Teuchos::Polynomial<Epetra_Vector> > f_poly = outArgs.get_f_poly(); if ( (x_poly != Teuchos::null) && (f_poly != Teuchos::null) ) { unsigned int d = x_poly->degree(); Sacado::Tay::Taylor<double> x1(d,0.0); Sacado::Tay::Taylor<double> x2(d,0.0); Sacado::Tay::Taylor<double> f1(d,0.0); Sacado::Tay::Taylor<double> f2(d,0.0); for (unsigned int i=0; i<=d; i++) { x1.fastAccessCoeff(i) = (*(x_poly->getCoefficient(i)))[0]; x2.fastAccessCoeff(i) = (*(x_poly->getCoefficient(i)))[1]; } evalVField(x1,x2,f1,f2); for (unsigned int i=0; i<=d; i++) { (*(f_poly->getCoefficient(i)))[0] = f1.coeff(i); (*(f_poly->getCoefficient(i)))[1] = f2.coeff(i); } } // compute W Teuchos::RCP<Epetra_Operator> W = outArgs.get_W(); if (W != Teuchos::null) { const double alpha = inArgs.get_alpha(); const double beta = inArgs.get_beta(); Epetra_CrsMatrix &crsW = Teuchos::dyn_cast<Epetra_CrsMatrix>(*W); const int dim = 2; double values_1[2]; double values_2[2]; int indices[] = {0,1}; Sacado::Fad::DFad<double> x1(dim,0,(*x)[0]); Sacado::Fad::DFad<double> x2(dim,1,(*x)[1]); Sacado::Fad::DFad<double> f1; Sacado::Fad::DFad<double> f2; evalVField(x1,x2,f1,f2); values_1[0] = alpha * f1.fastAccessDx(0) - beta; values_1[1] = alpha * f1.fastAccessDx(1); values_2[0] = alpha * f2.fastAccessDx(0); values_2[0] = alpha * f2.fastAccessDx(1) - beta; crsW.ReplaceGlobalValues(0,dim,values_1,indices); crsW.ReplaceGlobalValues(1,dim,values_2,indices); } }
int f3() { return f2(); }
void f1 (int a){ if (a) f2(a-1);//IF A IS NOT ZERO IT'S TRUE printf ("%d ",a); }
void CLearnWorldServerDlg::SaveData() { CString B; wstring temp; FILE *fStream1; errno_t e = _tfopen_s(&fStream1, _T("Admin.txt"), _T("wt,ccs=UNICODE")); if (e != 0) return ; // failed..CString sRead; CStdioFile f1(fStream1); // open the file from this stream temp = to_wstring(AdminList.size()); f1.WriteString(temp.c_str()); f1.WriteString(L"\n"); for (int i = 0; i < AdminList.size(); i++) { f1.WriteString(AdminList[i]._User + L"\n"); f1.WriteString(AdminList[i]._Pass + L"\n"); f1.WriteString(AdminList[i]._Name + L"\n"); f1.WriteString(to_wstring(AdminList[i]._Db.iDay).c_str()); f1.WriteString(L"\n"); f1.WriteString(to_wstring(AdminList[i]._Db.iMonth).c_str() ); f1.WriteString(L"\n"); f1.WriteString(to_wstring(AdminList[i]._Db.iYear).c_str() ); f1.WriteString(L"\n"); f1.WriteString(AdminList[i]._Gender + L"\n"); f1.WriteString(AdminList[i]._Add + L"\n"); f1.WriteString(AdminList[i]._Phone + L"\n"); } f1.Close(); FILE *fStream2; errno_t e1 = _tfopen_s(&fStream2, _T("User.txt"), _T("wt,ccs=UNICODE")); if (e1 != 0) return; // failed..CString sRead; CStdioFile f2(fStream2); // open the file from this stream temp = to_wstring(UserList.size()); f2.WriteString(temp.c_str()); f2.WriteString(L"\n"); for (int i = 0; i < UserList.size(); i++) { f2.WriteString(UserList[i]._User + L"\n"); f2.WriteString(UserList[i]._Pass + L"\n"); f2.WriteString(UserList[i]._Name + L"\n"); f2.WriteString(to_wstring(UserList[i]._Db.iDay).c_str()); f2.WriteString(L"\n"); f2.WriteString(to_wstring(UserList[i]._Db.iMonth).c_str());; f2.WriteString(L"\n"); f2.WriteString(to_wstring(UserList[i]._Db.iYear).c_str()); f2.WriteString(L"\n"); f2.WriteString(UserList[i]._Gender + L"\n"); f2.WriteString(UserList[i]._Add + L"\n"); f2.WriteString(UserList[i]._Phone + L"\n"); f2.WriteString(UserList[i].Rating + L"\n"); } f2.Close(); FILE *fStream3; errno_t e2 = _tfopen_s(&fStream3, _T("Teacher.txt"), _T("wt,ccs=UNICODE")); if (e2 != 0) return; // failed..CString sRead; CStdioFile f3(fStream3); // open the file from this stream temp = to_wstring(TeacherList.size()); f3.WriteString(temp.c_str()); f3.WriteString(L"\n"); for (int i = 0; i < TeacherList.size(); i++) { f3.WriteString(TeacherList[i]._User + L"\n"); f3.WriteString(TeacherList[i]._Pass + L"\n"); f3.WriteString(TeacherList[i]._Name + L"\n"); f3.WriteString(to_wstring(TeacherList[i]._Db.iDay).c_str()); f3.WriteString(L"\n"); f3.WriteString(to_wstring(TeacherList[i]._Db.iMonth).c_str());; f3.WriteString(L"\n"); f3.WriteString(to_wstring(TeacherList[i]._Db.iYear).c_str()); f3.WriteString(L"\n"); f3.WriteString(TeacherList[i]._Gender + L"\n"); f3.WriteString(TeacherList[i]._Add + L"\n"); f3.WriteString(TeacherList[i]._Phone + L"\n"); f3.WriteString(TeacherList[i].Rating + L"\n"); f3.WriteString(TeacherList[i].NumberOfRating + L"\n"); } f3.Close(); FILE *fStream4; errno_t e3 = _tfopen_s(&fStream4, _T("Deactivated.txt"), _T("wt,ccs=UNICODE")); if (e3 != 0) return; // failed..CString sRead; CStdioFile f4(fStream4); // open the file from this stream temp = to_wstring(DeactivatedAccount.size()); f4.WriteString(temp.c_str()); f4.WriteString(L"\n"); for (int i = 0; i < DeactivatedAccount.size(); i++) { f4.WriteString(DeactivatedAccount[i] + L"\r\n"); } f4.Close(); }
int f1 (int a, int b) { return f2(a) + b; }