Go to the documentation of this file.
42 const string& solution,
61 unique_ptr<Fopr> fopr_crs(Fopr::New(
"CRS", matrix));
67 double Stop_cond = 1.0e-28;
68 bool init_guess =
false;
71 params_solver.
set_int(
"maximum_number_of_iteration", Niter);
72 params_solver.
set_int(
"maximum_number_of_restart", Nrestart);
73 params_solver.
set_double(
"convergence_criterion_squared", Stop_cond);
74 params_solver.
set_bool(
"use_initial_guess", init_guess);
76 unique_ptr<Solver>
solver(
new Solver_CG(fopr_crs.get(), params_solver));
80 fopr_crs->set_mode(
"D");
81 fopr_crs->mult_dag(b2, b);
87 fopr_crs->set_mode(
"DdagD");
88 solver->solve(x, b2, Nconv, diff);
89 vout.
general(
vl,
"solver(CG): Nconv = %4d diff = %12.6e\n", Nconv, diff);
93 const double xx = x.
norm2();
108 std::ofstream field_out(filename.c_str());
109 if (!field_out.is_open()) {
110 vout.
crucial(
"Error: Failed to open the text file. %s\n", filename.c_str());
114 vout.
general(
"Writing Field to %s\n", filename.c_str());
116 field_out << f.
nin() << std::endl;
117 field_out << f.
nvol() << std::endl;
118 field_out << f.
nex() << std::endl;
120 field_out.setf(std::ios_base::scientific, std::ios_base::floatfield);
121 field_out.precision(14);
123 for (
int j = 0, n = f.
size(); j < n; ++j) {
124 field_out << f.
cmp(j) << std::endl;
139 std::ifstream field_in(filename.c_str());
140 if (!field_in.is_open()) {
141 vout.
crucial(
"Error: Failed to open the text file. %s\n", filename.c_str());
145 vout.
general(
"Reading Field from %s\n", filename.c_str());
147 int Nin = 0, Nvol = 0, Nex = 0;
152 f.
reset(Nin, Nvol, Nex);
155 for (
int j = 0, n = f.
ntot(); j < n; ++j) {
void set_bool(const string &key, const bool value)
void set(const int jin, const int site, const int jex, double v)
void set_double(const string &key, const double value)
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Test of CRS matrix format.
int solver(const std::string &)
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=Element_type::COMPLEX)
int CRSsolver(const string &solution, const string &matrix, const string &source, double &result)
double cmp(const int jin, const int site, const int jex) const
static Bridge::VerboseLevel Vlevel()
void read_text(Field &f, const string &filename)
void set_int(const string &key, const int value)
void write_text(const Field &f, const string &filename)
void crucial(const char *format,...)
Standard Conjugate Gradient solver algorithm.
Container of Field-type object.
void general(const char *format,...)