QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
parallelevolver.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2005 Joseph Wang
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
32#ifndef quantlib_system_evolver_hpp
33#define quantlib_system_evolver_hpp
34
35#include <ql/methods/finitedifferences/finitedifferencemodel.hpp>
36#include <ql/methods/finitedifferences/stepcondition.hpp>
37#include <ql/numericalmethod.hpp>
38#include <vector>
39
40namespace QuantLib {
41
45 template <typename array_type>
46 class [[deprecated("Use the new finite-differences framework instead")]] StepConditionSet {
47 typedef ext::shared_ptr<StepCondition<array_type> > itemType;
48 std::vector<itemType> stepConditions_;
49 public:
50 void applyTo(std::vector<array_type>& a, Time t) const {
51 //#pragma omp parallel for
52 for (Size i=0; i < stepConditions_.size(); i++) {
53 stepConditions_[i]->applyTo(a[i], t);
54 }
55 }
56 void push_back(const itemType& a) {
57 stepConditions_.push_back(a);
58 }
59 };
60
61 template <typename bc_set>
63 std::vector<bc_set> bcSet_;
64 public:
65 void push_back(const bc_set& a) {
66 bcSet_.push_back(a);
67 }
68 const bc_set& operator[](Size i) const {
69 return bcSet_[i];
70 }
71 };
72
76 template <typename traits>
77 class [[deprecated("Use the new finite-differences framework instead")]] ParallelEvolverTraits {
78 public:
79 typedef std::vector<typename traits::array_type> array_type;
80 typedef std::vector<typename traits::operator_type> operator_type;
81 typedef std::vector<typename traits::bc_type> bc_type;
83 QL_DEPRECATED_DISABLE_WARNING
85 QL_DEPRECATED_ENABLE_WARNING
86 };
87
91 template <class Evolver>
92 class [[deprecated("Use the new finite-differences framework instead")]] ParallelEvolver {
93 public:
94 // typedefs
95 QL_DEPRECATED_DISABLE_WARNING
97 QL_DEPRECATED_ENABLE_WARNING
98 typedef typename traits::operator_type operator_type;
99 typedef typename traits::array_type array_type;
100 typedef typename traits::bc_set bc_set;
101 // constructors
102 ParallelEvolver(const operator_type& L,
103 const bc_set& bcs) {
104 evolvers_.reserve(L.size());
105 for (Size i=0; i < L.size(); i++) {
106 evolvers_.push_back(ext::shared_ptr<Evolver>(new
107 Evolver(L[i], bcs[i])));
108 }
109 }
111 Time t) {
112 //#pragma omp parallel for
113 for (Size i=0; i < evolvers_.size(); i++) {
114 evolvers_[i]->step(a[i], t);
115 }
116 }
117 void setStep(Time dt) {
118 for (Size i=0; i < evolvers_.size(); i++) {
119 evolvers_[i]->setStep(dt);
120 }
121 }
122 private:
123 std::vector<ext::shared_ptr<Evolver> > evolvers_;
124 };
125
126}
127
128
129#endif
std::vector< bc_set > bcSet_
const bc_set & operator[](Size i) const
void push_back(const bc_set &a)
std::vector< ext::shared_ptr< Evolver > > evolvers_
ParallelEvolver(const operator_type &L, const bc_set &bcs)
traits::array_type array_type
QL_DEPRECATED_DISABLE_WARNING typedef ParallelEvolverTraits< typename Evolver::traits > traits
void step(array_type &a, Time t)
QL_DEPRECATED_ENABLE_WARNING typedef traits::operator_type operator_type
QL_DEPRECATED_DISABLE_WARNING typedef StepConditionSet< typename traits::array_type > condition_type
std::vector< typename traits::array_type > array_type
BoundaryConditionSet< typename traits::bc_set > bc_set
std::vector< typename traits::operator_type > operator_type
std::vector< typename traits::bc_type > bc_type
std::vector< itemType > stepConditions_
void push_back(const itemType &a)
ext::shared_ptr< StepCondition< array_type > > itemType
void applyTo(std::vector< array_type > &a, Time t) const
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35