QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
triplebandlinearop.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2008 Andreas Gaida
5 Copyright (C) 2008 Ralph Schreyer
6 Copyright (C) 2008 Klaus Spanderen
7 Copyright (C) 2014 Johannes Göttker-Schnetmann
8
9 This file is part of QuantLib, a free-software/open-source library
10 for financial quantitative analysts and developers - http://quantlib.org/
11
12 QuantLib is free software: you can redistribute it and/or modify it
13 under the terms of the QuantLib license. You should have received a
14 copy of the license along with this program; if not, please email
15 <quantlib-dev@lists.sf.net>. The license is also available online at
16 <http://quantlib.org/license.shtml>.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the license for more details.
21*/
22
27#ifndef quantlib_triple_band_linear_op_hpp
28#define quantlib_triple_band_linear_op_hpp
29
30#include <ql/methods/finitedifferences/operators/fdmlinearop.hpp>
31#include <memory>
32
33namespace QuantLib {
34
35 class FdmMesher;
36
38 public:
39 TripleBandLinearOp(Size direction,
40 const ext::shared_ptr<FdmMesher>& mesher);
41
46 ~TripleBandLinearOp() override = default;
47
48 Array apply(const Array& r) const override;
49 Array solve_splitting(const Array& r, Real a, Real b = 1.0) const;
50
51 TripleBandLinearOp mult(const Array& u) const;
52 // interpret u as the diagonal of a diagonal matrix, multiplied on LHS
53 TripleBandLinearOp multR(const Array& u) const;
54 // interpret u as the diagonal of a diagonal matrix, multiplied on RHS
56 TripleBandLinearOp add(const Array& u) const;
57
58 // some very basic linear algebra routines
59 void axpyb(const Array& a, const TripleBandLinearOp& x,
60 const TripleBandLinearOp& y, const Array& b);
61
62 void swap(TripleBandLinearOp& m) noexcept;
63
64 SparseMatrix toMatrix() const override;
65
66 protected:
67 TripleBandLinearOp() = default;
68
70 std::unique_ptr<Size[]> i0_, i2_;
71 std::unique_ptr<Size[]> reverseIndex_;
72 std::unique_ptr<Real[]> lower_, diag_, upper_;
73
74 ext::shared_ptr<FdmMesher> mesher_;
75 };
76
77
79 swap(m);
80 }
81
83 TripleBandLinearOp tmp(m);
84 swap(tmp);
85 return *this;
86 }
87
89 swap(m);
90 return *this;
91 }
92
93}
94
95#endif
1-D array used in linear algebra.
Definition: array.hpp:52
std::unique_ptr< Real[]> diag_
void swap(TripleBandLinearOp &m) noexcept
std::unique_ptr< Real[]> lower_
std::unique_ptr< Size[]> i0_
SparseMatrix toMatrix() const override
TripleBandLinearOp multR(const Array &u) const
Array solve_splitting(const Array &r, Real a, Real b=1.0) const
std::unique_ptr< Real[]> upper_
~TripleBandLinearOp() override=default
void axpyb(const Array &a, const TripleBandLinearOp &x, const TripleBandLinearOp &y, const Array &b)
TripleBandLinearOp mult(const Array &u) const
TripleBandLinearOp & operator=(const TripleBandLinearOp &m)
Array apply(const Array &r) const override
ext::shared_ptr< FdmMesher > mesher_
std::unique_ptr< Size[]> reverseIndex_
TripleBandLinearOp add(const TripleBandLinearOp &m) const
std::unique_ptr< Size[]> i2_
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
void swap(Array &v, Array &w) noexcept
Definition: array.hpp:903
boost::numeric::ublas::compressed_matrix< Real > SparseMatrix