void expM(std::complex<double> U[d3][d3], std::complex<double> A[d3][d3]) { // U = exp(A) // U = 1 + sum_i 1/i! * A^i const int nmax=20; std::complex<double> Atmp1[d3][d3], Atmp2[d3][d3]; for (int i=0; i<d3; i++) { for (int j=0; j<d3; j++) { U[i][j] = 0; } } for (int i=0; i<d3; i++) { U[i][i] = 1; Atmp1[i][i] = 1; } double fact=1; int i=0; for (i=1; i<nmax; i++) { fact *= i; axb(Atmp2,Atmp1,A); aeb(Atmp1,Atmp2); za(Atmp2, 1.0/(double)fact, Atmp2); apb(U,Atmp2); if (IsSmall(Atmp2)) break; } }
void CalcZ(std::complex<double> Z[3][3], ConfigData *W, int x, int mu) { std::complex<double> U[3][3], S[3][3], US[3][3]; W->extract(*U, x, mu); CalcStapleSum(S, W, x, mu); axb(US, U, S); projA(Z,US); za(Z,-1.0,Z); }
void model_parameters::initialization(void) { NAreaAge.initialize(); CatchAreaAge.initialize(); CatchNatAge.initialize(); Nage(1,1) = So*Bo/(1+beta*Bo); for(int i=sage+1 ; i <= nage ; i++) { Nage(1,i) = Nage(1,i-1) * mfexp(-za(i-1)); } VulB(1) = elem_prod(elem_prod(Nage(1),va),wa); SB(1) = elem_prod(Nage(1),fa)*wa/2; tBo = Nage(1)*wa; calcmaxpos(tBo); varPos = maxPos*cvPos; PosX(1) = minPos + (maxPos - minPos) * (0.5+0.5*sin(indmonth(1)*PI/6 - mo*PI/6)); VBarea(1,sarea) = VulB(1)* (cnorm(areas(sarea)+0.5,PosX(1),varPos)); for(int r=sarea+1 ; r <= narea-1 ; r++) { VBarea(1,r) = VulB(1)* (cnorm(areas(r)+0.5,PosX(1),varPos)-cnorm(areas(r)-0.5,PosX(1),varPos)); NAreaAge(1)(r) = elem_prod(Nage(1)(sage,nage),(cnorm(areas(r)+0.5,PosX(1),varPos)-cnorm(areas(r)-0.5,PosX(1),varPos))); } //VBarea(1,narea) = VulB(1)* (1.0-cnorm(areas(narea)-0.5,PosX(1),varPos)); NationVulB(1,1) = sum(VBarea(1)(sarea,sarea+nationareas(1)-1)); NationVulB(1,2) = sum(VBarea(1)(sarea+nationareas(1),narea)); dvar_vector tmp1(sarea,narea); dvar_vector tmp2(sarea,narea); dvar_vector tmp3(sarea,narea); for(int rr= sarea; rr<=narea; rr++) { tmp1(rr)= VBarea(1)(rr)/ (NationVulB(1)(indnatarea(rr)) + 0.0001); tmp2(rr) = tmp1(rr)*TotEffyear(indnatarea(rr))(indyr(1)); Effarea(1)(rr) = tmp2(rr)*TotEffmonth(indnatarea(rr))(indmonth(1)); } for(int a= sage; a<= nage;a++) { dvar_vector propVBarea(sarea,narea); for(int rr =sarea; rr<=narea; rr++) { propVBarea(rr) = (cnorm(areas(rr)+0.5,PosX(1),varPos)-cnorm(areas(rr)-0.5,PosX(1),varPos))(a-sage+1); CatchAreaAge(1)(rr)(a) = q*Effarea(1)(rr)*va(a)/(q*Effarea(1)(rr)*va(a)+m)*(1-mfexp(-(q*Effarea(1)(rr)*va(a)+m)))*NAreaAge(1)(rr)(a); CatchNatAge(1)(indnatarea(rr))(a) += CatchAreaAge(1)(rr)(a); EffNatAge(indnatarea(rr))(1)(sage-2) = 1; EffNatAge(indnatarea(rr))(1)(sage-1) = indnatarea(rr); EffNatAge(indnatarea(rr))(1)(a) += Effarea(1)(rr)*propVBarea(rr); } //cout<<"propVBarea "<<propVBarea<<endl; //cout<<"Effarea(1) "<<Effarea(1)<<endl; Effage(1)(a) = Effarea(1)* propVBarea; } }
int ZipFile::getFileCount() const { int count=0; std::ifstream inp("c:\\test.zip", std::ios::binary); if(!inp) { throw ValueException::FromString("unable to open file"); } typedef Poco::Zip::ZipArchive za_t; za_t za(inp); for (za_t::FileInfos::const_iterator i = za.fileInfoBegin(); i != za.fileInfoEnd(); ++i) { if (!i->second.isDirectory()) ++count; } return count; }
void projA(std::complex<double> A[d3][d3], std::complex<double> U[d3][d3]) { // A = proj(U), where U is projected on a antihermitian traceless matrix A // proj(U) = ( U - U^dag)/2 - i*( U - U^dag)/2 )/3 std::complex<double> Udag[d3][d3], UmUdag[d3][d3]; aeb(Udag,U); adag(Udag); amb(UmUdag, U,Udag); za(UmUdag, 0.5, UmUdag); aeb(A,UmUdag); std::complex<double> trace; trace = UmUdag[0][0] + UmUdag[1][1] + UmUdag[2][2]; for (int i=0; i<d3; i++) { A[i][i] -= trace/(double)3; } }
void SmallFlowStep(ConfigData *config) { // Here we have to implement the RK scheme from 1006.4518 [hep-lat] // Appendix C // W_0 = V_t // W_1 = exp(1/4 Z_0) W_0 // W_2 = exp(8/9 Z_1 - 17/36 Z_0) W_1 // W_t+eps = exp(3/4 Z_2 - 8/9 Z_1 + 17/36 Z_0) W_2 // // Z_i = eps Z(W_i) // // The input configuration 'config' will be overwritten with the // configuration at flow time t'=t+eps. // We allocate a new ConfigData // W_0 = V_t : W0 = config; ConfigData *S0 = new ConfigData(opt.ns, opt.ns, opt.ns, opt.nt, 3); // W_1 = exp(1/4 Z_0) W_0 ConfigData *W1 = new ConfigData(opt.ns, opt.ns, opt.ns, opt.nt, 3); #pragma omp parallel for for (int x=0; x<opt.ns*opt.ns*opt.ns*opt.nt; x++) { std::complex<double> U[3][3], Z0[3][3], A[3][3], expA[3][3], newU[3][3]; for (int mu=0; mu<4; mu++) { // For link U_x,mu CalcZ(Z0, config, x, mu); S0->replace(*Z0, x, mu); // save this into ConfigData for Z0s za(A, 1.0/4.0*opt.eps, Z0); expM(expA, A); config->extract(*U, x, mu); axb(newU, expA, U); #ifdef DEBUG if (testUnitarity(newU) > 1e-5) { std::cout << "WARNING: New link in SmallFlowStep() not unitary anymore!" << std::endl; } #endif W1->replace(*newU, x, mu); } } // W_2 = exp(8/9 Z_1 - 17/36 Z_0) W_1 ConfigData *W2 = new ConfigData(opt.ns, opt.ns, opt.ns, opt.nt, 3); #pragma omp parallel for for (int x=0; x<opt.ns*opt.ns*opt.ns*opt.nt; x++) { std::complex<double> U[3][3], Z0[3][3], Z1[3][3], A[3][3], A2[3][3], expA[3][3], newU[3][3]; for (int mu=0; mu<4; mu++) { // First part with Z0 S0->extract(*Z0, x, mu); // get this from ConfigData for Z0s za(A, -17.0/36.0*opt.eps, Z0); // Add second part with Z1 CalcZ(Z1, W1, x, mu); za(A2, 8.0/9.0*opt.eps, Z1); // Add both parts apb(A,A2); S0->replace(*A, x, mu); // save this into ConfigData S0 (A=-17/36*Z0 + 8/9*Z1) expM(expA, A); W1->extract(*U, x, mu); axb(newU, expA, U); #ifdef DEBUG if (testUnitarity(newU) > 1e-5) { std::cout << "WARNING: New link in SmallFlowStep() not unitary anymore!" << std::endl; } #endif W2->replace(*newU, x, mu); } } delete W1; W1 = 0; // W_t+eps = exp(3/4 Z_2 - 8/9 Z_1 + 17/36 Z_0) W_2 #pragma omp parallel for for (int x=0; x<opt.ns*opt.ns*opt.ns*opt.nt; x++) { std::complex<double> U[3][3], Z0[3][3], Z2[3][3], A[3][3], A2[3][3], expA[3][3], newU[3][3]; for (int mu=0; mu<4; mu++) { // For link U_x,mu // First part with Z0 and Z1 S0->extract(*Z0, x, mu); // load -17/36*Z0 + 8/9*Z1 za(A, -1.0, Z0); // switch the sign // Add third part with Z2 CalcZ(Z2, W2, x, mu); za(A2, 3.0/4.0*opt.eps, Z2); // Add both parts apb(A,A2); expM(expA, A); W2->extract(*U, x, mu); axb(newU, expA, U); #ifdef DEBUG if (testUnitarity(newU) > 1e-5) { std::cout << "WARNING: New link in SmallFlowStep() not unitary anymore!" << std::endl; } #endif config->replace(*newU, x, mu); } } // Cleaning up delete W2; W2 = 0; delete S0; S0 = 0; }