int main(){ int r1,c1,r2,c2,arr1[10][10],arr2[10][10],mult[10][10]; again: printf("enter the row and column for first matrix:\n"); scanf("%d %d", &r1,&c1); printf("enter the row and column for second matrix:\n"); scanf("%d %d", &r2,&c2); if(c1!=r2){ printf("Error! rows or column of first matrix is not equal to row and column of second matrix.Enter Again!\n"); goto again; } matrix_form(arr1,arr2,r1,c1,r2,c2); multiplication(arr1,arr2,r1,c1,r2,c2,mult); display(mult,r1,c2); return 0; }
const iTEBD<Tensor> evolve_itime(iTEBD<Tensor> psi, const Tensor &H12, double dt, tensor::index nsteps, double tolerance, tensor::index max_dim, tensor::index deltan, int method, std::vector<double> *energies, std::vector<double> *entropies) { static const double FR_param[5] = {0.67560359597983, 1.35120719195966, -0.17560359597983, -1.70241438391932}; Tensor eH12[4]; //int method = 2; switch (method) { case 1: /* Second order Trotter expansion */ eH12[1] = linalg::expm((-dt/2) * H12); case 0: /* First order Trotter expansion */ eH12[0] = linalg::expm((-dt) * H12); break; default: /* Fourth order Trotter expansion */ for (int i = 0; i < 4; i++) { eH12[i] = linalg::expm((-dt*FR_param[i]) * H12); } } Tensor Id = Tensor::eye(H12.rows()); double time = 0; psi = psi.canonical_form(); double E = energy(psi, H12), S = psi.entropy(); if (energies) energies->push_back(E); if (entropies) entropies->push_back(S); if (!deltan) { deltan = 1; } std::cout.precision(5); std::cout << nsteps << ", " << dt << " x " << deltan << " = " << dt * deltan << std::endl; std::cout << "t=" << time << ";\tE=" << E << "; dE=" << 0.0 << ";\tS=" << S << "; dS=" << 0.0 << ";\tl=" << std::max(psi.left_dimension(0), psi.right_dimension(0)) << std::endl << "l = " << matrix_form(real(psi.left_vector(0))) << std::endl; for (size_t phases = (nsteps + deltan - 1) / deltan; phases; phases--) { for (size_t i = 0; (i < deltan); i++) { switch (method) { case 0: psi = psi.apply_operator(eH12[0], 0, tolerance, max_dim); psi = psi.apply_operator(eH12[0], 1, tolerance, max_dim); break; case 1: psi = psi.apply_operator(eH12[1], 0, tolerance, max_dim); psi = psi.apply_operator(eH12[0], 1, tolerance, max_dim); psi = psi.apply_operator(eH12[1], 0, tolerance, max_dim); break; default: psi = psi.apply_operator(eH12[0], 0, tolerance, max_dim); psi = psi.apply_operator(eH12[1], 1, tolerance, max_dim); psi = psi.apply_operator(eH12[2], 0, tolerance, max_dim); psi = psi.apply_operator(eH12[3], 1, tolerance, max_dim); psi = psi.apply_operator(eH12[2], 0, tolerance, max_dim); psi = psi.apply_operator(eH12[1], 1, tolerance, max_dim); psi = psi.apply_operator(eH12[0], 0, tolerance, max_dim); } time += dt; } psi = psi.canonical_form(); double newE = energy(psi, H12); double newS = psi.entropy(); if (energies) energies->push_back(newE); if (entropies) entropies->push_back(newS); std::cout << "t=" << time << ";\tE=" << newE << "; dE=" << newE-E << ";\tS=" << newS << "; dS=" << newS-S << ";\tl=" << std::max(psi.left_dimension(0), psi.right_dimension(0)) << std::endl << "l = " << matrix_form(real(psi.left_vector(0))) << std::endl; E = newE; S = newS; } return psi; }
scalar DefaultMatrixFormSurf::value(int n, double *wt, Func<scalar> *u_ext[], Func<double> *u, Func<double> *v, Geom<double> *e, ExtData<scalar> *ext) const { return matrix_form(n, wt, u_ext, u, v, e, ext); }