QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
gmres.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2017 Klaus Spanderen
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
24#ifndef quantlib_gmres_hpp
25#define quantlib_gmres_hpp
26
27#include <ql/math/array.hpp>
28#include <ql/functional.hpp>
29
30#include <list>
31
32namespace QuantLib {
33
49 struct GMRESResult {
50 std::list<Real> errors;
52 };
53
54 class GMRES {
55 public:
56 typedef ext::function<Array(const Array&)> MatrixMult;
57
58 GMRES(MatrixMult A, Size maxIter, Real relTol, MatrixMult preConditioner = MatrixMult());
59
60 GMRESResult solve(const Array& b, const Array& x0 = Array()) const;
62 Size restart, const Array& b, const Array& x0 = Array()) const;
63
64 protected:
65 GMRESResult solveImpl(const Array& b, const Array& x0) const;
66
70 };
71
72}
73
74#endif
1-D array used in linear algebra.
Definition: array.hpp:52
GMRESResult solveWithRestart(Size restart, const Array &b, const Array &x0=Array()) const
Definition: gmres.cpp:47
const MatrixMult A_
Definition: gmres.hpp:67
GMRESResult solve(const Array &b, const Array &x0=Array()) const
Definition: gmres.cpp:39
const Real relTol_
Definition: gmres.hpp:69
const MatrixMult M_
Definition: gmres.hpp:67
const Size maxIter_
Definition: gmres.hpp:68
GMRESResult solveImpl(const Array &b, const Array &x0) const
Definition: gmres.cpp:66
ext::function< Array(const Array &)> MatrixMult
Definition: gmres.hpp:56
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35
std::list< Real > errors
Definition: gmres.hpp:50