void generate_matrix_123(rokko::distributed_matrix<T>& mat) { for(int local_i=0; local_i<mat.m_local; ++local_i) { for(int local_j=0; local_j<mat.n_local; ++local_j) { int global_i = mat.translate_l2g_row(local_i); int global_j = mat.translate_l2g_col(local_j); mat.set_local(local_i, local_j, mat.m_global * global_j + global_i ); } } }
void function_matrix(rokko::localized_vector<double> const& eigval_tmp, rokko::distributed_matrix<T, MATRIX_MAJOR> const& eigvec, rokko::distributed_matrix<T, MATRIX_MAJOR>& result, rokko::distributed_matrix<T, MATRIX_MAJOR>& tmp) { for (int local_j=0; local_j<eigvec.get_n_local(); ++local_j) { int global_j = eigvec.translate_l2g_col(local_j); double coeff = eigval_tmp(global_j); for (int local_i=0; local_i<eigvec.get_m_local(); ++local_i) { double value = eigvec.get_local(local_i, local_j); tmp.set_local(local_i, local_j, coeff * value); } } product(1, tmp, false, eigvec, true, 0, result); }
void diagonalize_fixedB(rokko::parallel_dense_solver& solver, rokko::distributed_matrix<T, MATRIX_MAJOR>& A, rokko::distributed_matrix<T, MATRIX_MAJOR>& B, rokko::localized_vector<double>& eigval, rokko::distributed_matrix<T, MATRIX_MAJOR>& eigvec, T tol = 0) { rokko::distributed_matrix<double, matrix_major> tmp(A.get_mapping()), Binvroot(A.get_mapping()), mat(A.get_mapping()); rokko::parameters params; int myrank = A.get_myrank(); params.set("routine", ""); solver.diagonalize(B, eigval, eigvec, params); // computation of B^{-1/2} for(int i=0; i<eigval.size(); ++i) eigval(i) = (eigval(i) > tol) ? sqrt(1/eigval(i)) : 0; function_matrix(eigval, eigvec, Binvroot, tmp); // computation of B^{-1/2} A B^{-1/2} product(1, Binvroot, false, A, false, 0, tmp); product(1, tmp, false, Binvroot, false, 0, mat); // diagonalization of B^{-1/2} A B^{-1/2} solver.diagonalize(mat, eigval, tmp, params); // computation of {eigvec of Ax=lambda Bx} = B^{-1/2} {eigvec of B^{-1/2} A B^{-1/2}} product(1, Binvroot, false, tmp, false, 0, eigvec); }