QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
gmres.hpp
Go to the documentation of this file.
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
20/*! \file gmres.hpp
21 \brief generalized minimal residual method
22*/
23
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
34 /*! References:
35 Saad, Yousef. 1996, Iterative methods for sparse linear systems,
36 http://www-users.cs.umn.edu/~saad/books.html
37
38 Dongarra et al. 1994,
39 Templates for the Solution of Linear Systems: Building Blocks
40 for Iterative Methods, 2nd Edition, SIAM, Philadelphia
41 http://www.netlib.org/templates/templates.pdf
42
43 Christian Kanzow
44 Numerik linearer Gleichungssysteme (German)
45 Chapter 6: GMRES und verwandte Verfahren
46 http://bilder.buecher.de/zusatz/12/12950/12950560_lese_1.pdf
47 */
48
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.
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
ext::function< Real(Real)> b
Maps function, bind and cref to either the boost or std implementation.
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