Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
InMemoryCubeBase< T > Class Template Reference

InMemoryCube stores the cube in memory using nested STL vectors. More...

#include <orea/cube/inmemorycube.hpp>

+ Inheritance diagram for InMemoryCubeBase< T >:
+ Collaboration diagram for InMemoryCubeBase< T >:

Public Member Functions

 InMemoryCubeBase (const Date &asof, const std::set< std::string > &ids, const vector< Date > &dates, Size samples, const T &t=T())
 default ctor More...
 
 InMemoryCubeBase ()
 default constructor More...
 
Size numIds () const override
 Return the length of each dimension. More...
 
Size numDates () const override
 
virtual Size samples () const override
 
const std::map< std::string, Size > & idsAndIndexes () const override
 Return a map of all ids and their position in the cube. More...
 
const std::vector< QuantLib::Date > & dates () const override
 Get the vector of dates for this cube. More...
 
QuantLib::Date asof () const override
 Return the asof date (T0 date) More...
 
- Public Member Functions inherited from NPVCube
 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

void check (Size i, Size j, Size k, Size d) const
 
- Protected Member Functions inherited from NPVCube
virtual Size index (const std::string &id) const
 
virtual Size index (const QuantLib::Date &date) const
 

Protected Attributes

QuantLib::Date asof_
 
vector< QuantLib::Date > dates_
 
Size samples_
 
vector< T > t0Data_
 
vector< vector< vector< T > > > data_
 
std::map< std::string, Size > idIdx_
 

Detailed Description

template<typename T>
class ore::analytics::InMemoryCubeBase< T >

InMemoryCube stores the cube in memory using nested STL vectors.

InMemoryCube stores the cube in memory using nested STL vectors, this class is a template to allow both single and double precision implementations.

The use of nested STL vectors is adds a small memory overhead (~ 1 to 2%)

Definition at line 50 of file inmemorycube.hpp.

Constructor & Destructor Documentation

◆ InMemoryCubeBase() [1/2]

InMemoryCubeBase ( const Date &  asof,
const std::set< std::string > &  ids,
const vector< Date > &  dates,
Size  samples,
const T &  t = T() 
)

default ctor

Definition at line 53 of file inmemorycube.hpp.

55 : asof_(asof), dates_(dates), samples_(samples), t0Data_(ids.size(), t),
56 data_(ids.size(), vector<vector<T>>(dates.size(), vector<T>(samples, t))) {
57 QL_REQUIRE(ids.size() > 0, "InMemoryCube::InMemoryCube no ids specified");
58 QL_REQUIRE(dates.size() > 0, "InMemoryCube::InMemoryCube no dates specified");
59 QL_REQUIRE(samples > 0, "InMemoryCube::InMemoryCube samples must be > 0");
60 size_t pos = 0;
61 for (const auto& id : ids) {
62 idIdx_[id] = pos++;
63 }
64
65 }
vector< vector< vector< T > > > data_
virtual Size samples() const override
const std::vector< QuantLib::Date > & dates() const override
Get the vector of dates for this cube.
QuantLib::Date asof() const override
Return the asof date (T0 date)
std::map< std::string, Size > idIdx_
vector< QuantLib::Date > dates_
const std::set< std::string > ids() const
Get a set of all ids in the cube.
Definition: npvcube.hpp:75
+ Here is the call graph for this function:

◆ InMemoryCubeBase() [2/2]

default constructor

Definition at line 68 of file inmemorycube.hpp.

68{}

Member Function Documentation

◆ numIds()

Size numIds ( ) const
overridevirtual

Return the length of each dimension.

Implements NPVCube.

Definition at line 71 of file inmemorycube.hpp.

71{ return idIdx_.size(); }
+ Here is the caller graph for this function:

◆ numDates()

Size numDates ( ) const
overridevirtual

Implements NPVCube.

Definition at line 72 of file inmemorycube.hpp.

72{ return dates_.size(); }
+ Here is the caller graph for this function:

◆ samples()

virtual Size samples ( ) const
overridevirtual

Implements NPVCube.

Definition at line 73 of file inmemorycube.hpp.

73{ return samples_; }
+ Here is the caller graph for this function:

◆ idsAndIndexes()

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

Return a map of all ids and their position in the cube.

Implements NPVCube.

Definition at line 76 of file inmemorycube.hpp.

76{ return idIdx_; }

◆ dates()

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

Get the vector of dates for this cube.

Implements NPVCube.

Definition at line 78 of file inmemorycube.hpp.

78{ return dates_; }
+ Here is the caller graph for this function:

◆ asof()

QuantLib::Date asof ( ) const
overridevirtual

Return the asof date (T0 date)

Implements NPVCube.

Definition at line 81 of file inmemorycube.hpp.

81{ return asof_; }

◆ check()

void check ( Size  i,
Size  j,
Size  k,
Size  d 
) const
protected

Definition at line 84 of file inmemorycube.hpp.

84 {
85 QL_REQUIRE(i < numIds(), "Out of bounds on ids (i=" << i << ", numIds=" << numIds() << ")");
86 QL_REQUIRE(j < numDates(), "Out of bounds on dates (j=" << j << ", numDates=" << numDates() << ")");
87 QL_REQUIRE(k < samples(), "Out of bounds on samples (k=" << k << ", samples=" << samples() << ")");
88 QL_REQUIRE(d < depth(), "Out of bounds on depth (d=" << d << ", depth=" << depth() << ")");
89 }
Size numDates() const override
Size numIds() const override
Return the length of each dimension.
virtual Size depth() const =0
+ Here is the call graph for this function:

Member Data Documentation

◆ asof_

QuantLib::Date asof_
protected

Definition at line 91 of file inmemorycube.hpp.

◆ dates_

vector<QuantLib::Date> dates_
protected

Definition at line 92 of file inmemorycube.hpp.

◆ samples_

Size samples_
protected

Definition at line 93 of file inmemorycube.hpp.

◆ t0Data_

vector<T> t0Data_
protected

Definition at line 94 of file inmemorycube.hpp.

◆ data_

vector<vector<vector<T> > > data_
protected

Definition at line 95 of file inmemorycube.hpp.

◆ idIdx_

std::map<std::string, Size> idIdx_
protected

Definition at line 97 of file inmemorycube.hpp.