Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
compiledformula.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2018 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
20
21namespace QuantExt {
22
24 op_ = f.op_;
25 x_ = f.x_;
26 v_ = f.v_;
27 args_ = f.args_;
28 return *this;
29}
30
32 op_ = f.op_;
33 x_ = f.x_;
34 v_ = f.v_;
35 args_.swap(f.args_);
36 return *this;
37}
38
39//
40
42 std::vector<CompiledFormula> newArgs;
43 newArgs.push_back(*this);
44 newArgs.push_back(y);
45 op_ = plus;
46 x_ = Null<Real>();
47 v_ = Null<Size>();
48 args_.swap(newArgs);
49 return *this;
50}
51
53 std::vector<CompiledFormula> newArgs;
54 newArgs.push_back(*this);
55 newArgs.push_back(y);
56 op_ = minus;
57 x_ = Null<Real>();
58 v_ = Null<Size>();
59 args_.swap(newArgs);
60 return *this;
61}
62
64 std::vector<CompiledFormula> newArgs;
65 newArgs.push_back(*this);
66 newArgs.push_back(y);
67 op_ = multiply;
68 x_ = Null<Real>();
69 v_ = Null<Size>();
70 args_.swap(newArgs);
71 return *this;
72}
73
75 std::vector<CompiledFormula> newArgs;
76 newArgs.push_back(*this);
77 newArgs.push_back(y);
78 op_ = divide;
79 x_ = Null<Real>();
80 v_ = Null<Size>();
81 args_.swap(newArgs);
82 return *this;
83}
84
85//
86
89 r.args_ = std::vector<CompiledFormula>(1, *this);
90 r.op_ = negate;
91 r.x_ = Null<Real>();
92 r.v_ = Null<Size>();
93 return r;
94}
95
96//
97
99 x += y;
100 return x;
101}
102
104 x -= y;
105 return x;
106}
107
109 x *= y;
110 return x;
111}
112
114 x /= y;
115 return x;
116}
117
119 std::vector<CompiledFormula> newArgs;
120 newArgs.push_back(x);
121 x.op_ = op;
122 x.x_ = Null<Real>();
123 x.v_ = Null<Size>();
124 x.args_.swap(newArgs);
125 return x;
126}
127
129 std::vector<CompiledFormula> newArgs;
130 newArgs.push_back(x);
131 newArgs.push_back(y);
132 x.op_ = op;
133 x.x_ = Null<Real>();
134 x.v_ = Null<Size>();
135 x.args_.swap(newArgs);
136 return x;
137}
138
139//
140
141// cppcheck-suppress passedByValue
143
144// cppcheck-suppress passedByValue
146
147// cppcheck-suppress passedByValue
149
150// cppcheck-suppress passedByValue
152
153// cppcheck-suppress passedByValue
155
156//
157
158// cppcheck-suppress passedByValue
160
161// cppcheck-suppress passedByValue
163
164// cppcheck-suppress passedByValue
166
167} // namespace QuantExt
helper class representing a formula with variables given by an id v
std::vector< CompiledFormula > args_
CompiledFormula & operator-=(const CompiledFormula &)
CompiledFormula & operator/=(const CompiledFormula &)
CompiledFormula operator-() const
CompiledFormula & operator=(const CompiledFormula &)
CompiledFormula & operator+=(const CompiledFormula &)
CompiledFormula & operator*=(const CompiledFormula &)
compiled formula
BucketedDistribution operator+(const BucketedDistribution &lhs, const BucketedDistribution &rhs)
Sum probabilities in two bucketed distributions with equal buckets.
CompiledFormula exp(CompiledFormula x)
CompiledFormula min(CompiledFormula x, const CompiledFormula &y)
CompiledFormula pow(CompiledFormula x, const CompiledFormula &y)
CompiledFormula geqZero(CompiledFormula x)
CompiledFormula unaryOp(CompiledFormula x, CompiledFormula::Operator op)
CompiledFormula max(CompiledFormula x, const CompiledFormula &y)
CompiledFormula abs(CompiledFormula x)
CompiledFormula log(CompiledFormula x)
CompiledFormula operator-(CompiledFormula x, const CompiledFormula &y)
CompiledFormula operator/(CompiledFormula x, const CompiledFormula &y)
CompiledFormula gtZero(CompiledFormula x)
CompiledFormula binaryOp(CompiledFormula x, const CompiledFormula &y, CompiledFormula::Operator op)
BucketedDistribution operator*(Real factor, const BucketedDistribution &rhs)