ParGeMSLR
fgmres.hpp
Go to the documentation of this file.
1 #ifndef PARGEMSLR_FGMRES_H
2 #define PARGEMSLR_FGMRES_H
3 
9 #include "../utils/memory.hpp"
10 #include "../utils/parallel.hpp"
11 #include "../utils/utils.hpp"
12 #include "../vectors/vector.hpp"
13 #include "../vectors/sequential_vector.hpp"
14 #include "../matrices/matrix.hpp"
15 #include "../matrices/matrixops.hpp"
16 #include "../matrices/dense_matrix.hpp"
17 #include "solver.hpp"
18 
19 namespace pargemslr
20 {
21 
27  template <class MatrixType, class VectorType, typename DataType>
28  class FlexGmresClass: public SolverClass<MatrixType, VectorType, DataType>
29  {
30  private:
31 
36  typename std::conditional<PargemslrIsDoublePrecision<DataType>::value,
37  double,
38  float>::type _tol;
39 
44  int _maxits;
45 
50  int _kdim;
51 
56  bool _absolute_tol;
57 
62  typename std::conditional<PargemslrIsDoublePrecision<DataType>::value,
63  double,
64  float>::type _rel_res;
65 
70  int _iter;
71 
76  typename std::conditional<PargemslrIsDoublePrecision<DataType>::value,
78  vector_seq_float>::type _rel_res_vector;
79 
84  int _location;
85 
86  public:
87 
92  FlexGmresClass() : SolverClass<MatrixType, VectorType, DataType>()
93  {
94  this->_solver_type = kSolverFgmres;
95  this->_location = kMemoryHost;
96  this->_kdim = 50;
97  this->_maxits = 200;
98  this->_tol = 1e-08;
99  this->_absolute_tol = false;
100  this->_rel_res = 0.0;
101  this->_iter = 0;
102  }
103 
109  FlexGmresClass(const FlexGmresClass<MatrixType, VectorType, DataType> &solver) : SolverClass<MatrixType, VectorType, DataType>(solver)
110  {
111  this->_location = solver._location;
112  this->_kdim = solver._kdim;
113  this->_maxits = solver._maxits;
114  this->_tol = solver._tol;
115  this->_absolute_tol = solver._absolute_tol;
116  this->_rel_res = solver._rel_res;
117  this->_iter = solver._iter;
118  this->_rel_res_vector = solver._rel_res_vector;
119  }
120 
126  FlexGmresClass(FlexGmresClass<MatrixType, VectorType, DataType> &&solver) : SolverClass<MatrixType, VectorType, DataType>(std::move(solver))
127  {
128  this->_location = solver._location;
129  solver._location = kMemoryHost;
130  this->_kdim = solver._kdim;
131  solver._kdim = 0;
132  this->_maxits = solver._maxits;
133  solver._maxits = 0;
134  this->_tol = solver._tol;
135  solver._tol = 0;
136  this->_absolute_tol = solver._absolute_tol;
137  solver._absolute_tol = false;
138  this->_rel_res = solver._rel_res;
139  solver._rel_res = 0;
140  this->_iter = solver._iter;
141  solver._iter = 0;
142  this->_rel_res_vector = std::move(solver._rel_res_vector);
143  }
144 
152  {
153  this->Clear();
155  this->_location = solver._location;
156  this->_kdim = solver._kdim;
157  this->_maxits = solver._maxits;
158  this->_tol = solver._tol;
159  this->_absolute_tol = solver._absolute_tol;
160  this->_rel_res = solver._rel_res;
161  this->_iter = solver._iter;
162  this->_rel_res_vector = solver._rel_res_vector;
163  return *this;
164  }
165 
173  {
174  this->Clear();
176  this->_location = solver._location;
177  solver._location = kMemoryHost;
178  this->_kdim = solver._kdim;
179  solver._kdim = 0;
180  this->_maxits = solver._maxits;
181  solver._maxits = 0;
182  this->_tol = solver._tol;
183  solver._tol = 0;
184  this->_absolute_tol = solver._absolute_tol;
185  solver._absolute_tol = false;
186  this->_rel_res = solver._rel_res;
187  solver._rel_res = 0;
188  this->_iter = solver._iter;
189  solver._iter = 0;
190  this->_rel_res_vector = std::move(solver._rel_res_vector);
191  return *this;
192  }
193 
199  int Clear()
200  {
201  /* call base clear function */
203 
204  this->_location = kMemoryHost;
205 
206  _rel_res = 0.0;
207  _iter = 0;
208  _rel_res_vector.Clear();
209 
210  return PARGEMSLR_SUCCESS;
211 
212  }
213 
219  {
220  this->Clear();
221  }
222 
230  virtual int Setup( VectorType &x, VectorType &rhs)
231  {
232 
233  if(this->_ready)
234  {
235  /* don't need to setup if already done so */
236  return PARGEMSLR_SUCCESS;
237  }
238 
239  /* for gmres we only need to setup the preconditioner */
240  if(this->_preconditioner)
241  {
242  this->_preconditioner->SetSolveLocation(this->_location);
243  this->_preconditioner->Setup( x, rhs);
244  }
245 
246  this->_solution = &x;
247  this->_right_hand_side = &rhs;
248 
249  this->_solver_precision = x.GetPrecision();
250 
251  this->_ready = true;
252 
253  return PARGEMSLR_SUCCESS;
254  }
255 
263  virtual int Solve( VectorType &x, VectorType &rhs)
264  {
265  if(!(this->_ready))
266  {
267  PARGEMSLR_ERROR("Solve without setup.");
268  return PARGEMSLR_ERROR_FUNCTION_CALL_ERR;
269  }
270 
271  /* define the data type */
272  typedef typename std::conditional<PargemslrIsDoublePrecision<DataType>::value, double, float>::type RealDataType;
273  typedef DataType T;
274 
275  /* Declare variables */
276  int n_local, i, j, k;
277  T one, zero, mone;
278  RealDataType normb, EPSILON, normr, tolr, t, gam;
279  T inormr, hii, hii1;
280 
281 #ifdef PARGEMSLR_TIMING
282  int np, myid;
283  MPI_Comm comm;
284 
285  this->_matrix->GetMpiInfo(np, myid, comm);
286 #endif
287 
288  SequentialVectorClass<T> c, s, rs;
289  VectorType v, z, w;
290  DenseMatrixClass<T> V, Z, H;
291 
292  EPSILON = std::numeric_limits<RealDataType>::epsilon();
293 
294  one = 1.0;
295  zero = 0.0;
296  mone = -1.0;
297 
298  /* get the local length */
299  n_local = x.GetLengthLocal();
300 
301  /* Working matrices to hold the Krylov basis and upper-Hessenberg matrices */
302  V.Setup(n_local, this->_kdim+1, this->_location, true);
303  Z.Setup(n_local, this->_kdim+1, this->_location, true);
304  H.Setup(this->_kdim+1, this->_kdim, kMemoryHost, true);
305 
306  /* Temp vector pointers */
307  this->_matrix->SetupVectorPtrStr(v);
308  this->_matrix->SetupVectorPtrStr(z);
309  this->_matrix->SetupVectorPtrStr(w);
310 
311  /* Working vectors for Givens rotations */
312  c.Setup(this->_kdim, true);
313  s.Setup(this->_kdim, true);
314  rs.Setup(this->_kdim+1, true);
315 
316  /* Exit if RHS is zero */
317  //rhs.NormInf(normb);
318  rhs.Norm2(normb);
319 
320  /* the solution is direct */
321  if (normb < EPSILON)
322  {
323  x.Fill(0.0);
324  this->_rel_res = 0.0;
325  this->_iter = 0;
326  this->_rel_res_vector.Setup(1, true);
327  return PARGEMSLR_SUCCESS;
328  }
329 
330  /* Make b the first vector of the basis (will normalize later) */
331  if(n_local > 0)
332  {
333  v.UpdatePtr( &V(0, 0), V.GetDataLocation());
334  }
335 
336  /* Compute the residual norm v = rhs - A*x */
337  PARGEMSLR_MEMCPY(v.GetData(), rhs.GetData(), n_local, v.GetDataLocation(), rhs.GetDataLocation(), T);
338  PARGEMSLR_TIME_CALL( comm, PARGEMSLR_ITERTIME_AMV, (this->_matrix->MatVec( 'N', mone, x, one, v)));
339 
340  /* Compute the 2-norm of residual */
341  v.Norm2(normr);
342 
343  /* the solution is direct */
344  if (normr < EPSILON)
345  {
346  this->_rel_res = 0.0;
347  this->_iter = 0;
348  this->_rel_res_vector.Setup(1, true);
349  return PARGEMSLR_SUCCESS;
350  }
351 
352  if(this->_absolute_tol)
353  {
354  tolr = this->_tol;
355  }
356  else
357  {
358  tolr = this->_tol*normb;
359  }
360 
361  /* A few variables used to keep track of the loop's state */
362  this->_rel_res_vector.Setup(this->_maxits+1, true);
363  //this->_rel_res_vector[0] = normr;
364  this->_rel_res_vector[0] = normr/normb;
365  this->_iter = 0;
366 
367  if(this->_print_option>0 && parallel_log::_grank == 0)
368  {
369  PargemslrPrintDashLine(pargemslr::pargemslr_global::_dash_line_width);
370  PARGEMSLR_PRINT("Start FlexGMRES(%d)\n",this->_kdim);
371  PARGEMSLR_PRINT("Residual Tol: %e\nMax number of inner iterations: %d\n", tolr, this->_maxits);
372  PargemslrPrintDashLine(pargemslr::pargemslr_global::_dash_line_width);
373  PARGEMSLR_PRINT("Step Residual norm Relative res. Convergence Rate\n");
374  //PARGEMSLR_PRINT("%5d %8e %8e N/A\n", 0, normr, 1.0);
375  PARGEMSLR_PRINT("%5d %8e %8e N/A\n", 0, normr, this->_rel_res_vector[0]);
376  }
377 
378  /* Outer loop */
379  while (this->_iter < this->_maxits)
380  {
381  /* Scale the starting vector */
382  rs[0] = normr;
383  inormr = 1.0/normr;
384 
385  v.Scale(inormr);
386 
387  // Inner loop
388  i = 0;
389 
390  while (i < this->_kdim && this->_iter < this->_maxits)
391  {
392  i++;
393  this->_iter++;
394  if( n_local > 0)
395  {
396  v.UpdatePtr( &V(0, i-1), V.GetDataLocation() );
397  z.UpdatePtr( &Z(0, i-1), Z.GetDataLocation() );
398  w.UpdatePtr( &V(0, i), V.GetDataLocation() );
399  }
400 
401  /* zi = M^{-1} * vi -- apply the preconditioner */
402  if(this->_preconditioner)
403  {
404 #ifdef PARGEMSLR_TIMING
405  PARGEMSLR_TIME_CALL( comm, PARGEMSLR_PRECTIME_PRECOND, (this->_preconditioner->Solve(z, v)));
406  PARGEMSLR_TIME_CALL( comm, PARGEMSLR_ITERTIME_AMV, (this->_matrix->MatVec( 'N', one, z, zero, w)));
407 #else
408  this->_preconditioner->Solve(z, v);
409  this->_matrix->MatVec( 'N', one, z, zero, w);
410 #endif
411  }
412  else
413  {
414  PARGEMSLR_MEMCPY(z.GetData(), v.GetData(), n_local, z.GetDataLocation(), v.GetDataLocation(), T);
415 #ifdef PARGEMSLR_TIMING
416  PARGEMSLR_TIME_CALL( comm, PARGEMSLR_ITERTIME_AMV, (this->_matrix->MatVec( 'N', one, v, zero, w)));
417 #else
418  this->_matrix->MatVec( 'N', one, v, zero, w);
419 #endif
420  }
421 
422  /* Modified Gram-schmidt without re-orth */
423 #ifdef PARGEMSLR_TIMING
424  PARGEMSLR_TIME_CALL( comm, PARGEMSLR_ITERTIME_MGS, (PargemslrMgs( w, V, H, t, i-1, RealDataType(1e-12), RealDataType(-1.0))));
425 #else
426  PargemslrMgs( w, V, H, t, i-1, RealDataType(1e-12), RealDataType(-1.0));
427 #endif
428 
429  if (PargemslrAbs(t) < EPSILON)
430  {
431  if(this->_print_option>0 && parallel_log::_grank == 0)
432  {
433  PARGEMSLR_PRINT("Break down in the current cycle\n");
434  }
435  goto label;
436  }
437  /* Scale w (t=||w|| is already computed in the mgs function) */
438  //scale(w, 1.0 / t);
439 
440  /* Least squares problem of H */
441  for (j = 1; j < i; j++)
442  {
443  hii = H(j-1,i-1);
444  H(j-1,i-1) = PargemslrConj(c[j-1])*hii + s[j-1]*H(j,i-1);
445  H(j,i-1) = -s[j-1]*hii + c[j-1]*H(j,i-1);
446  }
447 
448  hii = H(i-1,i-1);
449  hii1 = H(i,i-1);
450  gam = sqrt(PargemslrAbs(hii)*PargemslrAbs(hii) + PargemslrAbs(hii1)*PargemslrAbs(hii1));
451  if (PargemslrAbs(gam) < EPSILON)
452  {
453  goto label;
454  }
455  c[i-1] = hii / gam;
456  s[i-1] = hii1 / gam;
457  rs[i] = -s[i-1] * rs[i-1];
458  rs[i-1] = PargemslrConj(c[i-1]) * rs[i-1];
459  /* Check residual norm */
460  H(i-1,i-1) = PargemslrConj(c[i-1])*hii + s[i-1]*hii1;
461  normr = PargemslrAbs(rs[i]);
462  //this->_rel_res_vector[this->_iter] = normr;
463  this->_rel_res_vector[this->_iter] = normr/normb;
464  if(this->_print_option>0 && parallel_log::_grank == 0)
465  {
466  //PARGEMSLR_PRINT("%5d %8e %8e %8.6f\n", this->_iter, normr, normr / this->_rel_res_vector[0], normr / this->_rel_res_vector[this->_iter-1]);
467  PARGEMSLR_PRINT("%5d %8e %8e %8.6f\n", this->_iter, normr, this->_rel_res_vector[this->_iter], this->_rel_res_vector[this->_iter] / this->_rel_res_vector[this->_iter-1]);
468  }
469  if (normr <= tolr)
470  {
471  break;
472  }
473  } // End of inner loop
474 
475  /* Print residual norm at the end of each cycle */
476  if (this->_print_option==0 && parallel_log::_grank == 0)
477  {
478  //PARGEMSLR_PRINT("Rel. residual at the end of current cycle (# of steps per cycle: %d): %e \n", this->_kdim, normr / this->_rel_res_vector[0]);
479  PARGEMSLR_PRINT("Rel. residual at the end of current cycle (# of steps per cycle: %d): %e \n", this->_kdim, this->_rel_res_vector[0]);
480  }
481 
482  /* Solve the upper triangular system */
483  rs[i-1] /= H(i-1,i-1);
484  for ( k = i-2; k >= 0; k--)
485  {
486  for ( j = k+1; j < i; j++)
487  {
488  rs[k] -= H(k,j)*rs[j];
489  }
490  rs[k] /= H(k,k);
491  }
492 
493  /* Get current approximate solution */
494  for ( j = 0; j < i; j++)
495  {
496  if(n_local > 0)
497  {
498  z.UpdatePtr( &Z(0, j), Z.GetDataLocation() );
499  }
500  x.Axpy( rs[j], z);
501  }
502 
503  /* Test convergence */
504  if (normr <= tolr)
505  {
506  this->_rel_res = normr;
507  break;
508  }
509 
510  PARGEMSLR_CHKERR(i==0 && this->_iter != this->_maxits);
511 
512  /* Restart */
513 
514  if(n_local)
515  {
516  v.UpdatePtr( &V(0, 0), V.GetDataLocation() );
517  }
518  PARGEMSLR_MEMCPY(v.GetData(), rhs.GetData(), n_local, v.GetDataLocation(), rhs.GetDataLocation(), T);
519 #ifdef PARGEMSLR_TIMING
520  PARGEMSLR_TIME_CALL( comm, PARGEMSLR_ITERTIME_AMV, (this->_matrix->MatVec( 'N', one, x, zero, w)) );
521 #else
522  this->_matrix->MatVec( 'N', one, x, zero, w);
523 #endif
524 
525  v.Axpy(mone, w);
526 
527  /*
528  for ( j = i; j > 0; j--)
529  {
530  rs[j-1] = -s[j-1] * rs[j];
531  rs[j] = c[j-1] * rs[j];
532  }
533 
534  if(i)
535  {
536  if(n_local > 0)
537  {
538  v.UpdatePtr( &V(0, 0), V.GetDataLocation() );
539  v.Scale(rs[0]);
540  for ( j = 1 ; j <= i; j++)
541  {
542  w.UpdatePtr( &V(0, j), V.GetDataLocation() );
543  v.Axpy(rs[j], w);
544  }
545  }
546  }
547  */
548 
549  } // End of outer loop
550 
551  label:
552  //this->_rel_res = normr / this->_rel_res_vector[0];
553  this->_rel_res = normr / normb;
554 
555  this->_rel_res_vector.Resize( this->_iter+1, true, false);
556 
557  /* De-allocate */
558  c.Clear();
559  s.Clear();
560  rs.Clear();
561  V.Clear();
562  Z.Clear();
563  H.Clear();
564  v.Clear();
565  z.Clear();
566  w.Clear();
567 
568  return PARGEMSLR_SUCCESS;
569  }
570 
577  virtual int SetSolveLocation( const int &location)
578  {
579  if(this->_preconditioner)
580  {
581  this->_preconditioner->SetSolveLocation(location);
582  this->_location = location;
583  return PARGEMSLR_SUCCESS;
584  }
585 
586  if(this->_location == location)
587  {
588  return PARGEMSLR_SUCCESS;
589  }
590 
591  this->_location = location;
592 
593  return PARGEMSLR_SUCCESS;
594 
595  }
596 
597  /* ------ SETS and GETS ------ */
598 
606  virtual int SetWithParameterArray(double *params)
607  {
608  this->_tol = params[PARGEMSLR_IO_SOLVER_TOL];
609  this->_maxits = params[PARGEMSLR_IO_SOLVER_MAXITS];
610  this->_kdim = params[PARGEMSLR_IO_SOLVER_KDIM];
611  this->_absolute_tol = params[PARGEMSLR_IO_SOLVER_ATOL] != 0.0;
612  this->_print_option = params[PARGEMSLR_IO_GENERAL_PRINT_LEVEL];
613  return PARGEMSLR_SUCCESS;
614  }
615 
622  template <typename T>
623  int SetTolerance(T tol)
624  {
625  this->_tol = tol;
626  return PARGEMSLR_SUCCESS;
627  }
628 
635  int SetMaxNumberIterations(int maxits)
636  {
637  this->_maxits = maxits;
638  return PARGEMSLR_SUCCESS;
639  }
640 
648  {
649  this->_kdim = kdim;
650  return PARGEMSLR_SUCCESS;
651  }
652 
659  int SetAbsoluteTol(bool option)
660  {
661  this->_absolute_tol = option;
662  return PARGEMSLR_SUCCESS;
663  }
664 
670  typename std::conditional<PargemslrIsDoublePrecision<DataType>::value,
671  double,
672  float>::type GetFinalRelativeResidual() const
673  {
674  return this->_rel_res;
675  }
676 
683  {
684  return this->_iter;
685  }
686 
692  typename std::conditional<PargemslrIsDoublePrecision<DataType>::value,
695  {
696  return this->_rel_res_vector;
697  }
698 
699  };
700 
701  typedef FlexGmresClass<CsrMatrixClass<float>, SequentialVectorClass<float>, float> fgmres_csr_seq_float;
702  typedef FlexGmresClass<CsrMatrixClass<double>, SequentialVectorClass<double>, double> fgmres_csr_seq_double;
703  typedef FlexGmresClass<CsrMatrixClass<complexs>, SequentialVectorClass<complexs>, complexs> fgmres_csr_seq_complexs;
704  typedef FlexGmresClass<CsrMatrixClass<complexd>, SequentialVectorClass<complexd>, complexd> fgmres_csr_seq_complexd;
705  typedef FlexGmresClass<ParallelCsrMatrixClass<float>, ParallelVectorClass<float>, float> fgmres_csr_par_float;
706  typedef FlexGmresClass<ParallelCsrMatrixClass<double>, ParallelVectorClass<double>, double> fgmres_csr_par_double;
707  typedef FlexGmresClass<ParallelCsrMatrixClass<complexs>, ParallelVectorClass<complexs>, complexs> fgmres_csr_par_complexs;
708  typedef FlexGmresClass<ParallelCsrMatrixClass<complexd>, ParallelVectorClass<complexd>, complexd> fgmres_csr_par_complexd;
709 
710 }
711 
712 #endif
pargemslr::SolverClass::_solver_type
SolverTypeEnum _solver_type
The type of the solver.
Definition: solver.hpp:60
pargemslr::SolverClass::_solver_precision
PrecisionEnum _solver_precision
The precision of the solver.
Definition: solver.hpp:54
pargemslr::DenseMatrixClass::Setup
int Setup(int nrows, int ncols)
Free the current matrix, and malloc memory to create a new matrix on the host.
Definition: dense_matrix.cpp:231
pargemslr::SequentialVectorClass::Scale
virtual int Scale(const T &alpha)
Scale the vector by x = alpha*x, where x is this vector.
Definition: sequential_vector.cpp:1037
pargemslr::DenseMatrixClass
Class of dense matrix.
Definition: dense_matrix.hpp:23
pargemslr::FlexGmresClass::Solve
virtual int Solve(VectorType &x, VectorType &rhs)
Solve phase. Call this function after Setup.
Definition: fgmres.hpp:263
pargemslr::FlexGmresClass
The real flexgmres solver class.
Definition: fgmres.hpp:29
pargemslr::FlexGmresClass::GetFinalRelativeResidual
std::conditional< PargemslrIsDoublePrecision< DataType >::value, double, float >::type GetFinalRelativeResidual() const
Get the final relative residual.
Definition: fgmres.hpp:672
pargemslr::FlexGmresClass::~FlexGmresClass
~FlexGmresClass()
The destructor.
Definition: fgmres.hpp:218
pargemslr::FlexGmresClass::Clear
int Clear()
Free function.
Definition: fgmres.hpp:199
pargemslr::FlexGmresClass::SetTolerance
int SetTolerance(T tol)
Set the tolorance for stop the iteration.
Definition: fgmres.hpp:623
pargemslr::SequentialVectorClass
The class of sequential real/complex vector.
Definition: structs.hpp:12
solver.hpp
Virtual class of iterative solvers.
pargemslr::SequentialVectorClass::Setup
int Setup(int length)
Free the current vector, and malloc memory to initilize the vector.
Definition: sequential_vector.cpp:178
pargemslr::SolverClass::_ready
bool _ready
If the solver is ready.
Definition: solver.hpp:108
pargemslr::SolverClass
The base solver class.
Definition: solver.hpp:47
pargemslr::FlexGmresClass::SetKrylovSubspaceDimension
int SetKrylovSubspaceDimension(int kdim)
Set the maximum number of flexible GMRES inner iterations per cycle.
Definition: fgmres.hpp:647
pargemslr::FlexGmresClass::GetNumberIterations
int GetNumberIterations() const
Get the number of iterations.
Definition: fgmres.hpp:682
pargemslr::SolverClass::_print_option
int _print_option
The print option.
Definition: solver.hpp:114
pargemslr::FlexGmresClass::SetWithParameterArray
virtual int SetWithParameterArray(double *params)
Setup with parameter array.
Definition: fgmres.hpp:606
pargemslr::FlexGmresClass::operator=
FlexGmresClass< MatrixType, VectorType, DataType > & operator=(FlexGmresClass< MatrixType, VectorType, DataType > &&solver)
The = operator.
Definition: fgmres.hpp:172
pargemslr::FlexGmresClass::SetMaxNumberIterations
int SetMaxNumberIterations(int maxits)
Set the maximum number of iterations.
Definition: fgmres.hpp:635
pargemslr::DenseMatrixClass::GetDataLocation
virtual int GetDataLocation() const
Get the data location of the matrix.
Definition: dense_matrix.cpp:171
pargemslr::FlexGmresClass::Setup
virtual int Setup(VectorType &x, VectorType &rhs)
Setup the solver phase, include building the preconditioner, call this function before Solve,...
Definition: fgmres.hpp:230
pargemslr::SolverClass::_solution
VectorType * _solution
Pointer to the solution, note that this vector is not going to be freed.
Definition: solver.hpp:96
pargemslr::SolverClass::_matrix
MatrixType * _matrix
The matrix.
Definition: solver.hpp:72
pargemslr::FlexGmresClass::FlexGmresClass
FlexGmresClass(const FlexGmresClass< MatrixType, VectorType, DataType > &solver)
The copy constructor.
Definition: fgmres.hpp:109
pargemslr::FlexGmresClass::SetSolveLocation
virtual int SetSolveLocation(const int &location)
Set the data location that the solver apply to.
Definition: fgmres.hpp:577
pargemslr::FlexGmresClass::SetAbsoluteTol
int SetAbsoluteTol(bool option)
Set if we use absolute threshold ||r|| or ||r||/||b||.
Definition: fgmres.hpp:659
pargemslr::FlexGmresClass::FlexGmresClass
FlexGmresClass(FlexGmresClass< MatrixType, VectorType, DataType > &&solver)
The move constructor.
Definition: fgmres.hpp:126
pargemslr::FlexGmresClass::FlexGmresClass
FlexGmresClass()
The constructor.
Definition: fgmres.hpp:92
pargemslr::FlexGmresClass::operator=
FlexGmresClass< MatrixType, VectorType, DataType > & operator=(const FlexGmresClass< MatrixType, VectorType, DataType > &solver)
The = operator.
Definition: fgmres.hpp:151
pargemslr::SolverClass::_right_hand_side
VectorType * _right_hand_side
Pointer to the right-hand-size, note that this vector is not going to be freed.
Definition: solver.hpp:102
pargemslr::SolverClass::_preconditioner
SolverClass< MatrixType, VectorType, DataType > * _preconditioner
The preconditioner.
Definition: solver.hpp:84
pargemslr::DenseMatrixClass::Clear
virtual int Clear()
Free the current matrix.
Definition: dense_matrix.cpp:122
pargemslr::FlexGmresClass::GetRelativeResidual
std::conditional< PargemslrIsDoublePrecision< DataType >::value, vector_seq_double, vector_seq_float >::type & GetRelativeResidual()
Get the relative residual at each step as a vector.
Definition: fgmres.hpp:694
pargemslr::SequentialVectorClass::Clear
virtual int Clear()
Free the current vector.
Definition: sequential_vector.cpp:431
pargemslr::SolverClass::operator=
SolverClass< MatrixType, VectorType, DataType > & operator=(const SolverClass< MatrixType, VectorType, DataType > &solver)
The = operator of solver class.
Definition: solver.hpp:210
pargemslr::SolverClass::Clear
virtual int Clear()
Free the current solver.
Definition: solver.hpp:264