22#include <ql/functional.hpp>
23#include <ql/math/matrixutilities/bicgstab.hpp>
24#include <ql/math/matrixutilities/gmres.hpp>
25#include <ql/methods/finitedifferences/schemes/impliciteulerscheme.hpp>
34 : dt_(
Null<
Real>()), iterations_(ext::make_shared<
Size>(0U)), relTol_(relTol),
35 map_(
std::move(map)), bcSet_(bcSet), solverType_(solverType) {}
38 return r - (theta*
dt_)*
map_->apply(r);
46 QL_REQUIRE(t-
dt_ > -1e-8,
"a step towards negative time given");
47 map_->setTime(std::max(0.0, t-
dt_), t);
52 if (
map_->size() == 1) {
53 a =
map_->solve_splitting(0, a, -theta*
dt_);
56 auto preconditioner = [&](
const Array& _a){
return map_->preconditioner(_a, -theta*
dt_); };
57 auto applyF = [&](
const Array& _a){
return apply(_a, theta); };
73 (*iterations_) += result.
errors.size();
77 QL_FAIL(
"unknown/illegal solver type");
1-D array used in linear algebra.
BiCGStabResult solve(const Array &b, const Array &x0=Array()) const
void applyAfterSolving(array_type &a) const
void setTime(Time t) const
void applyBeforeSolving(operator_type &op, array_type &a) const
GMRESResult solve(const Array &b, const Array &x0=Array()) const
ext::shared_ptr< Size > iterations_
ImplicitEulerScheme(ext::shared_ptr< FdmLinearOpComposite > map, const bc_set &bcSet=bc_set(), Real relTol=1e-8, SolverType solverType=BiCGstab)
const SolverType solverType_
const BoundaryConditionSchemeHelper bcSet_
const ext::shared_ptr< FdmLinearOpComposite > map_
traits::array_type array_type
Array apply(const Array &r, Real theta) const
Size numberOfIterations() const
void step(array_type &a, Time t)
template class providing a null value for a given type.
Real Time
continuous quantity with 1-year units
std::size_t Size
size of a container