Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
NPVCube Class Referenceabstract

NPV Cube class stores both future and current NPV values. More...

#include <orea/cube/npvcube.hpp>

+ Inheritance diagram for NPVCube:
+ Collaboration diagram for NPVCube:

Public Member Functions

 NPVCube ()
 default ctor More...
 
 NPVCube (NPVCube &)=delete
 Do not allow cube copying. More...
 
NPVCubeoperator= (NPVCube const &)=delete
 
virtual ~NPVCube ()
 dtor More...
 
virtual Size numIds () const =0
 Return the length of each dimension. More...
 
virtual Size numDates () const =0
 
virtual Size samples () const =0
 
virtual Size depth () const =0
 
virtual const std::map< std::string, Size > & idsAndIndexes () const =0
 Get a map of id and their index position in this cube. More...
 
const std::set< std::string > ids () const
 Get a set of all ids in the cube. More...
 
virtual const std::vector< QuantLib::Date > & dates () const =0
 Get the vector of dates for this cube. More...
 
virtual QuantLib::Date asof () const =0
 Return the asof date (T0 date) More...
 
virtual Real getT0 (Size id, Size depth=0) const =0
 Get a T0 value from the cube using index. More...
 
virtual Real getT0 (const std::string &id, Size depth=0) const
 Get a T0 value from the cube using trade id. More...
 
virtual void setT0 (Real value, Size id, Size depth=0)=0
 Set a value in the cube using index. More...
 
virtual void setT0 (Real value, const std::string &id, Size depth=0)
 Set a value in the cube using trade id. More...
 
virtual Real get (Size id, Size date, Size sample, Size depth=0) const =0
 Get a value from the cube using index. More...
 
virtual void set (Real value, Size id, Size date, Size sample, Size depth=0)=0
 Set a value in the cube using index. More...
 
virtual Real get (const std::string &id, const QuantLib::Date &date, Size sample, Size depth=0) const
 Get a value from the cube using trade id and date. More...
 
virtual void set (Real value, const std::string &id, const QuantLib::Date &date, Size sample, Size depth=0)
 Set a value in the cube using trade id and date. More...
 
virtual void remove (Size id)
 
virtual void remove (Size id, Size sample)
 
Size getTradeIndex (const std::string &id) const
 

Protected Member Functions

virtual Size index (const std::string &id) const
 
virtual Size index (const QuantLib::Date &date) const
 

Detailed Description

NPV Cube class stores both future and current NPV values.

The cube class stores future NPV values in a 4-D array.

This abstract base class is just used for the storage of a cube. This class also stores the tradeIds, dates and vector of T0 NPVs

The values in the cube must be set according to the following rules to ensure consistent behavior:

Definition at line 53 of file npvcube.hpp.

Constructor & Destructor Documentation

◆ NPVCube() [1/2]

NPVCube ( )

default ctor

Definition at line 56 of file npvcube.hpp.

56{}

◆ NPVCube() [2/2]

NPVCube ( NPVCube )
delete

Do not allow cube copying.

◆ ~NPVCube()

virtual ~NPVCube ( )
virtual

dtor

Definition at line 63 of file npvcube.hpp.

63{}

Member Function Documentation

◆ operator=()

NPVCube & operator= ( NPVCube const &  )
delete

◆ numIds()

virtual Size numIds ( ) const
pure virtual

◆ numDates()

virtual Size numDates ( ) const
pure virtual

◆ samples()

virtual Size samples ( ) const
pure virtual

◆ depth()

virtual Size depth ( ) const
pure virtual

Implemented in InMemoryCube1< T >, InMemoryCubeN< T >, JaggedCube< T >, JointNPVCube, JointNPVSensiCube, NPVSensiCube, and SparseNpvCube< T >.

+ Here is the caller graph for this function:

◆ idsAndIndexes()

virtual const std::map< std::string, Size > & idsAndIndexes ( ) const
pure virtual

Get a map of id and their index position in this cube.

Implemented in InMemoryCubeBase< T >, InMemoryCubeBase< vector< T > >, JaggedCube< T >, JointNPVCube, JointNPVSensiCube, SensiCube< T >, and SparseNpvCube< T >.

+ Here is the caller graph for this function:

◆ ids()

const std::set< std::string > ids ( ) const

Get a set of all ids in the cube.

Definition at line 75 of file npvcube.hpp.

75 {
76 std::set<std::string> result;
77 for (const auto& [id, pos] : idsAndIndexes()) {
78 result.insert(id);
79 }
80 return result;
81 }
virtual const std::map< std::string, Size > & idsAndIndexes() const =0
Get a map of id and their index position in this cube.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dates()

virtual const std::vector< QuantLib::Date > & dates ( ) const
pure virtual

Get the vector of dates for this cube.

Implemented in InMemoryCubeBase< T >, InMemoryCubeBase< vector< T > >, JaggedCube< T >, JointNPVCube, JointNPVSensiCube, SensiCube< T >, and SparseNpvCube< T >.

+ Here is the caller graph for this function:

◆ asof()

virtual QuantLib::Date asof ( ) const
pure virtual

Return the asof date (T0 date)

Implemented in InMemoryCubeBase< T >, InMemoryCubeBase< vector< T > >, JaggedCube< T >, JointNPVCube, JointNPVSensiCube, SensiCube< T >, and SparseNpvCube< T >.

+ Here is the caller graph for this function:

◆ getT0() [1/2]

virtual Real getT0 ( Size  id,
Size  depth = 0 
) const
pure virtual

Get a T0 value from the cube using index.

Implemented in InMemoryCube1< T >, InMemoryCubeN< T >, JaggedCube< T >, SparseNpvCube< T >, SensiCube< T >, JointNPVCube, and JointNPVSensiCube.

◆ getT0() [2/2]

virtual Real getT0 ( const std::string &  id,
Size  depth = 0 
) const
virtual

Get a T0 value from the cube using trade id.

Definition at line 91 of file npvcube.hpp.

91{ return getT0(index(id), depth); };
virtual Real getT0(Size id, Size depth=0) const =0
Get a T0 value from the cube using index.
virtual Size depth() const =0
virtual Size index(const std::string &id) const
Definition: npvcube.hpp:121
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setT0() [1/2]

virtual void setT0 ( Real  value,
Size  id,
Size  depth = 0 
)
pure virtual

Set a value in the cube using index.

Implemented in InMemoryCube1< T >, InMemoryCubeN< T >, JaggedCube< T >, SparseNpvCube< T >, SensiCube< T >, JointNPVCube, and JointNPVSensiCube.

+ Here is the caller graph for this function:

◆ setT0() [2/2]

virtual void setT0 ( Real  value,
const std::string &  id,
Size  depth = 0 
)
virtual

Set a value in the cube using trade id.

Definition at line 95 of file npvcube.hpp.

95{ setT0(value, index(id), depth); };
virtual void setT0(Real value, Size id, Size depth=0)=0
Set a value in the cube using index.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get() [1/2]

virtual Real get ( Size  id,
Size  date,
Size  sample,
Size  depth = 0 
) const
pure virtual

Get a value from the cube using index.

Implemented in InMemoryCube1< T >, InMemoryCubeN< T >, JaggedCube< T >, SparseNpvCube< T >, SensiCube< T >, JointNPVCube, JointNPVSensiCube, and NPVSensiCube.

+ Here is the caller graph for this function:

◆ set() [1/2]

virtual void set ( Real  value,
Size  id,
Size  date,
Size  sample,
Size  depth = 0 
)
pure virtual

Set a value in the cube using index.

Implemented in InMemoryCube1< T >, InMemoryCubeN< T >, JaggedCube< T >, SparseNpvCube< T >, SensiCube< T >, JointNPVCube, JointNPVSensiCube, and NPVSensiCube.

+ Here is the caller graph for this function:

◆ get() [2/2]

virtual Real get ( const std::string &  id,
const QuantLib::Date &  date,
Size  sample,
Size  depth = 0 
) const
virtual

Get a value from the cube using trade id and date.

Reimplemented in NPVSensiCube.

Definition at line 103 of file npvcube.hpp.

103 {
104 return get(index(id), index(date), sample, depth);
105 };
virtual Real get(Size id, Size date, Size sample, Size depth=0) const =0
Get a value from the cube using index.
+ Here is the call graph for this function:

◆ set() [2/2]

virtual void set ( Real  value,
const std::string &  id,
const QuantLib::Date &  date,
Size  sample,
Size  depth = 0 
)
virtual

Set a value in the cube using trade id and date.

Reimplemented in NPVSensiCube.

Definition at line 107 of file npvcube.hpp.

107 {
108 set(value, index(id), index(date), sample, depth);
109 }
virtual void set(Real value, Size id, Size date, Size sample, Size depth=0)=0
Set a value in the cube using index.
+ Here is the call graph for this function:

◆ remove() [1/2]

void remove ( Size  id)
virtual

remove all values for a given id, i.e. change the state as if setT0() and set() has never been called for the id the default implementation has generelly to be overriden in derived classes depending on how values are stored

Reimplemented in SensiCube< T >, and JointNPVSensiCube.

Definition at line 137 of file npvcube.hpp.

137 {
138 for (Size date = 0; date < this->numDates(); ++date) {
139 for (Size depth = 0; depth < this->depth(); ++depth) {
140 setT0(0.0, id, depth);
141 for (Size sample = 0; sample < this->samples(); ++sample) {
142 set(0.0, id, date, sample, depth);
143 }
144 }
145 }
146}
virtual Size numDates() const =0
virtual Size samples() const =0
+ Here is the call graph for this function:

◆ remove() [2/2]

void remove ( Size  id,
Size  sample 
)
virtual

simliar as above, but remove all values for a given id and scenario and keep T0 values

Reimplemented in SensiCube< T >, and JointNPVSensiCube.

Definition at line 148 of file npvcube.hpp.

148 {
149 for (Size date = 0; date < this->numDates(); ++date) {
150 for (Size depth = 0; depth < this->depth(); ++depth) {
151 set(0.0, id, date, sample, depth);
152 }
153 }
154}
+ Here is the call graph for this function:

◆ getTradeIndex()

Size getTradeIndex ( const std::string &  id) const

Definition at line 118 of file npvcube.hpp.

118{ return index(id); }
+ Here is the call graph for this function:

◆ index() [1/2]

virtual Size index ( const std::string &  id) const
protectedvirtual

Definition at line 121 of file npvcube.hpp.

121 {
122 const auto& it = idsAndIndexes().find(id);
123 QL_REQUIRE(it != idsAndIndexes().end(), "NPVCube can't find an index for id " << id);
124 return it->second;
125 };
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ index() [2/2]

virtual Size index ( const QuantLib::Date &  date) const
protectedvirtual

Definition at line 127 of file npvcube.hpp.

127 {
128 auto it = std::find(dates().begin(), dates().end(), date);
129 QL_REQUIRE(it != dates().end(), "NPVCube can't find an index for date " << date);
130 return std::distance(dates().begin(), it);
131 };
virtual const std::vector< QuantLib::Date > & dates() const =0
Get the vector of dates for this cube.
+ Here is the call graph for this function: