ROL
ROL_Krylov.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Rapid Optimization Library (ROL) Package
4 //
5 // Copyright 2014 NTESS and the ROL contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef ROL_KRYLOV_H
11 #define ROL_KRYLOV_H
12 
17 #include "ROL_Vector.hpp"
18 #include "ROL_LinearOperator.hpp"
19 #include "ROL_ParameterList.hpp"
20 
21 namespace ROL {
22 
23 template<class Real>
24 class Krylov {
25 
26  Real absTol_; // Absolute residual tolerance
27  Real relTol_; // Relative residual tolerance
28  unsigned maxit_; // Maximum number of iterations
29 
30 public:
31  virtual ~Krylov(void) {}
32 
33  Krylov( Real absTol = 1.e-4, Real relTol = 1.e-2, unsigned maxit = 100 )
34  : absTol_(absTol), relTol_(relTol), maxit_(maxit) {}
35 
36  Krylov( ROL::ParameterList &parlist ) {
37  ROL::ParameterList &krylovList = parlist.sublist("General").sublist("Krylov");
38  absTol_ = krylovList.get("Absolute Tolerance", 1.e-4);
39  relTol_ = krylovList.get("Relative Tolerance", 1.e-2);
40  maxit_ = krylovList.get("Iteration Limit", 100);
41  }
42 
43  // Run Krylov Method
44  virtual Real run( Vector<Real> &x, LinearOperator<Real> &A,
45  const Vector<Real> &b, LinearOperator<Real> &M,
46  int &iter, int &flag ) = 0;
47 
48  void resetAbsoluteTolerance(const Real absTol) {
49  absTol_ = absTol;
50  }
51  void resetRelativeTolerance(const Real relTol) {
52  relTol_ = relTol;
53  }
54  void resetMaximumIteration(const unsigned maxit) {
55  maxit_ = maxit;
56  }
57  Real getAbsoluteTolerance(void) const {
58  return absTol_;
59  }
60  Real getRelativeTolerance(void) const {
61  return relTol_;
62  }
63  unsigned getMaximumIteration(void) const {
64  return maxit_;
65  }
66 };
67 
68 }
69 
70 #endif
Real getRelativeTolerance(void) const
Definition: ROL_Krylov.hpp:60
Real getAbsoluteTolerance(void) const
Definition: ROL_Krylov.hpp:57
unsigned getMaximumIteration(void) const
Definition: ROL_Krylov.hpp:63
void resetRelativeTolerance(const Real relTol)
Definition: ROL_Krylov.hpp:51
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
void resetMaximumIteration(const unsigned maxit)
Definition: ROL_Krylov.hpp:54
Krylov(ROL::ParameterList &parlist)
Definition: ROL_Krylov.hpp:36
virtual Real run(Vector< Real > &x, LinearOperator< Real > &A, const Vector< Real > &b, LinearOperator< Real > &M, int &iter, int &flag)=0
unsigned maxit_
Definition: ROL_Krylov.hpp:28
Provides definitions for Krylov solvers.
Definition: ROL_Krylov.hpp:24
Provides the interface to apply a linear operator.
virtual ~Krylov(void)
Definition: ROL_Krylov.hpp:31
void resetAbsoluteTolerance(const Real absTol)
Definition: ROL_Krylov.hpp:48
Krylov(Real absTol=1.e-4, Real relTol=1.e-2, unsigned maxit=100)
Definition: ROL_Krylov.hpp:33