32 std::vector<Time> averageTimes,
35 const ext::shared_ptr<FdmMesher>& mesher,
37 :
x_(mesher->layout()->dim()[equityDirection]),
38 a_(mesher->layout()->dim()[equityDirection == 0 ? 1 : 0]),
39 averageTimes_(
std::move(averageTimes)), pastFixings_(pastFixings),
mesher_(mesher),
40 equityDirection_(equityDirection) {
42 QL_REQUIRE(mesher->layout()->dim().size()==2,
"2D allowed only");
43 QL_REQUIRE(equityDirection == 0 || equityDirection == 1,
44 "equityDirection has to be 0 or 1");
46 const Size xSpacing =
mesher_->layout()->spacing()[equityDirection];
49 x_[i] = std::exp(tmp[i*xSpacing]);
51 const Size averageDirection = equityDirection == 0 ? 1 : 0;
52 const Size aSpacing =
mesher_->layout()->spacing()[averageDirection];
53 tmp =
mesher_->locations(averageDirection);
55 a_[i] = std::exp(tmp[i*aSpacing]);
61 "inconsistent array dimensions");
63 const std::vector<Time>::const_iterator iter
72 const Size aSpacing =
mesher_->layout()->spacing()[averageDirection];
77 Size index = i*xSpacing + j*aSpacing;
78 tmp[j] = aCopy[index];
83 Size index = i*xSpacing + j*aSpacing;
84 a[index] = interp((iT-nTimes)/(
double)(iT)*
a_[j] +
85 nTimes/(
double)(iT)*
x_[i],
true);
1-D array used in linear algebra.
const_iterator end() const
Size size() const
dimension of the array
const_iterator begin() const
const std::vector< Time > averageTimes_
const Size equityDirection_
FdmArithmeticAverageCondition(std::vector< Time > averageTimes, Real, Size pastFixings, const ext::shared_ptr< FdmMesher > &mesher, Size equityDirection)
const ext::shared_ptr< FdmMesher > mesher_
void applyTo(Array &a, Time t) const override
cubic interpolation between discrete points
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
step condition to handle arithmetic average
memory layout of a fdm linear operator
const ext::shared_ptr< FdmMesher > mesher_
Real Time
continuous quantity with 1-year units
std::size_t Size
size of a container