31#include <ql/errors.hpp>
33#include <boost/make_shared.hpp>
34#include <boost/math/special_functions/relative_difference.hpp>
51 for (
const auto&
id :
ids) {
64 const std::vector<QuantLib::Date>&
dates()
const override {
return dates_; }
67 QuantLib::Date
asof()
const override {
return asof_; }
70 Real
getT0(Size i, Size)
const override {
76 void setT0(Real value, Size i, Size)
override {
82 Real
get(Size i, Size j, Size k, Size)
const override {
94 void set(Real value, Size i, Size j, Size k, Size)
override {
96 T castValue =
static_cast<T
>(
value);
97 if (boost::math::epsilon_difference<T>(castValue,
t0Data_[i]) > 42) {
129 void check(QuantLib::Size i, QuantLib::Size j, QuantLib::Size k)
const {
130 QL_REQUIRE(i <
numIds(),
"Out of bounds on ids (i=" << i <<
")");
131 QL_REQUIRE(j <
depth(),
"Out of bounds on depth (j=" << j <<
")");
132 QL_REQUIRE(k <
samples(),
"Out of bounds on samples (k=" << k <<
")");
const std::set< std::string > ids() const
Get a set of all ids in the cube.
NPVSensiCube class stores NPVs resulting from risk factor shifts on an as of date.
QuantLib::Size depth() const override
The depth in the NPVSensiCube is exactly one.
SensiCube stores only npvs not equal to the base npvs.
QuantLib::Size samples() const override
std::set< QuantLib::Size > relevantScenarios() const override
std::vector< std::map< QuantLib::Size, T > > tradeNPVs_
const std::map< std::string, Size > & idsAndIndexes() const override
Get the vector of ids for this cube.
void setT0(Real value, Size i, Size) override
Set a value in the cube.
std::vector< QuantLib::Date > dates_
QuantLib::Size numIds() const override
Return the length of each dimension.
void remove(Size i, Size k) override
Real getT0(Size i, Size) const override
Get a T0 value from the cube.
const std::vector< QuantLib::Date > & dates() const override
Get the vector of dates for this cube.
void remove(Size i) override
void set(Real value, Size i, Size j, Size k, Size) override
Set a value in the cube.
QuantLib::Date asof() const override
Return the asof date (T0 date)
std::map< QuantLib::Size, QuantLib::Real > getTradeNPVs(QuantLib::Size i) const override
void check(QuantLib::Size i, QuantLib::Size j, QuantLib::Size k) const
std::map< std::string, Size > idIdx_
std::set< QuantLib::Size > relevantScenarios_
SensiCube(const std::set< std::string > &ids, const QuantLib::Date &asof, QuantLib::Size samples, const T &t=T())
Real get(Size i, Size j, Size k, Size) const override
Get a value from the cube.
SafeStack< ValueType > value
Size size(const ValueType &v)
An NPV cube for storing NPVs resulting from risk factor shifts.