QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
fdminnervaluecalculator.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) 2008 Andreas Gaida
5 Copyright (C) 2008, 2009 Ralph Schreyer
6 Copyright (C) 2008, 2009 Klaus Spanderen
7
8 This file is part of QuantLib, a free-software/open-source library
9 for financial quantitative analysts and developers - http://quantlib.org/
10
11 QuantLib is free software: you can redistribute it and/or modify it
12 under the terms of the QuantLib license. You should have received a
13 copy of the license along with this program; if not, please email
14 <quantlib-dev@lists.sf.net>. The license is also available online at
15 <http://quantlib.org/license.shtml>.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the license for more details.
20*/
21
22/*! \file fdminnervaluecalculator.hpp
23 \brief layer of abstraction to calculate the inner value
24*/
25
26#ifndef quantlib_fdm_inner_value_calculator_hpp
27#define quantlib_fdm_inner_value_calculator_hpp
28
29#include <ql/types.hpp>
30#include <ql/shared_ptr.hpp>
31#include <ql/functional.hpp>
32#include <vector>
33
34
35namespace QuantLib {
36
37 class Payoff;
38 class BasketPayoff;
39 class FdmMesher;
40 class FdmLinearOpIterator;
41
42
44 public:
45 virtual ~FdmInnerValueCalculator() = default;
46
47 virtual Real innerValue(const FdmLinearOpIterator& iter, Time t) = 0;
48 virtual Real avgInnerValue(const FdmLinearOpIterator& iter, Time t) = 0;
49 };
50
51
53 public:
54 FdmCellAveragingInnerValue(ext::shared_ptr<Payoff> payoff,
55 ext::shared_ptr<FdmMesher> mesher,
56 Size direction,
57 ext::function<Real(Real)> gridMapping = [](Real x){ return x; });
58
59 Real innerValue(const FdmLinearOpIterator& iter, Time) override;
60 Real avgInnerValue(const FdmLinearOpIterator& iter, Time t) override;
61
62 private:
64
65 const ext::shared_ptr<Payoff> payoff_;
66 const ext::shared_ptr<FdmMesher> mesher_;
68 const ext::function<Real(Real)> gridMapping_;
69
70 std::vector<Real> avgInnerValues_;
71 };
72
74 public:
75 FdmLogInnerValue(const ext::shared_ptr<Payoff>& payoff,
76 const ext::shared_ptr<FdmMesher>& mesher,
77 Size direction);
78 };
79
81 public:
82 FdmLogBasketInnerValue(ext::shared_ptr<BasketPayoff> payoff,
83 ext::shared_ptr<FdmMesher> mesher);
84
85 Real innerValue(const FdmLinearOpIterator& iter, Time) override;
86 Real avgInnerValue(const FdmLinearOpIterator& iter, Time) override;
87
88 private:
89 const ext::shared_ptr<BasketPayoff> payoff_;
90 const ext::shared_ptr<FdmMesher> mesher_;
91 };
92
94 public:
95 Real innerValue(const FdmLinearOpIterator&, Time) override { return 0.0; }
96 Real avgInnerValue(const FdmLinearOpIterator&, Time) override { return 0.0; }
97 };
98}
99
100#endif
Real avgInnerValue(const FdmLinearOpIterator &iter, Time t) override
const ext::shared_ptr< FdmMesher > mesher_
Real avgInnerValueCalc(const FdmLinearOpIterator &iter, Time t)
Real innerValue(const FdmLinearOpIterator &iter, Time) override
const ext::function< Real(Real)> gridMapping_
const ext::shared_ptr< Payoff > payoff_
virtual Real avgInnerValue(const FdmLinearOpIterator &iter, Time t)=0
virtual Real innerValue(const FdmLinearOpIterator &iter, Time t)=0
virtual ~FdmInnerValueCalculator()=default
Real avgInnerValue(const FdmLinearOpIterator &iter, Time) override
const ext::shared_ptr< BasketPayoff > payoff_
const ext::shared_ptr< FdmMesher > mesher_
Real innerValue(const FdmLinearOpIterator &iter, Time) override
Real innerValue(const FdmLinearOpIterator &, Time) override
Real avgInnerValue(const FdmLinearOpIterator &, Time) override
const DefaultType & t
Maps function, bind and cref to either the boost or std implementation.
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
ext::shared_ptr< QuantLib::Payoff > payoff
Definition: any.hpp:35
Maps shared_ptr to either the boost or std implementation.
Custom types.