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

InMemoryCube of variable depth. More...

#include <orea/cube/inmemorycube.hpp>

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

Public Member Functions

 InMemoryCubeN (const Date &asof, const std::set< std::string > &ids, const vector< Date > &dates, Size samples, Size depth, const T &t=T())
 ctor More...
 
 InMemoryCubeN ()
 default More...
 
Size depth () const override
 Depth. More...
 
virtual Real getT0 (Size i, Size d) const override
 Get a T0 value from the cube. More...
 
virtual void setT0 (Real value, Size i, Size d) override
 Set a value in the cube. More...
 
Real get (Size i, Size j, Size k, Size d) const override
 Get a value from the cube. More...
 
void set (Real value, Size i, Size j, Size k, Size d) override
 Set a value in the cube. More...
 
- Public Member Functions inherited from InMemoryCubeBase< vector< T > >
 InMemoryCubeBase (const Date &asof, const std::set< std::string > &ids, const vector< Date > &dates, Size samples, const vector< T > &t=vector< 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
 

Additional Inherited Members

- Protected Member Functions inherited from InMemoryCubeBase< vector< T > >
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 inherited from InMemoryCubeBase< vector< T > >
QuantLib::Date asof_
 
vector< QuantLib::Date > dates_
 
Size samples_
 
vector< vector< T > > t0Data_
 
vector< vector< vector< vector< T > > > > data_
 
std::map< std::string, Size > idIdx_
 

Detailed Description

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

InMemoryCube of variable depth.

This implementation stores a vector an InMemoryCubeBase

Definition at line 145 of file inmemorycube.hpp.

Constructor & Destructor Documentation

◆ InMemoryCubeN() [1/2]

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

ctor

Definition at line 148 of file inmemorycube.hpp.

150 : InMemoryCubeBase<vector<T>>(asof, ids, dates, samples, vector<T>(depth, t)) {}
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)
Size depth() const override
Depth.
const std::set< std::string > ids() const
Get a set of all ids in the cube.
Definition: npvcube.hpp:75

◆ InMemoryCubeN() [2/2]

default

Definition at line 153 of file inmemorycube.hpp.

153{}

Member Function Documentation

◆ depth()

Size depth ( ) const
overridevirtual

Depth.

Implements NPVCube.

Definition at line 156 of file inmemorycube.hpp.

156{ return this->data_[0][0][0].size(); } // we don't want any members in this class
vector< vector< vector< vector< T > > > > data_

◆ getT0()

virtual Real getT0 ( Size  i,
Size  d 
) const
overridevirtual

Get a T0 value from the cube.

Implements NPVCube.

Definition at line 159 of file inmemorycube.hpp.

159 {
160 this->check(i, 0, 0, d);
161 return this->t0Data_[i][d];
162 }

◆ setT0()

virtual void setT0 ( Real  value,
Size  i,
Size  d 
)
overridevirtual

Set a value in the cube.

Implements NPVCube.

Definition at line 165 of file inmemorycube.hpp.

165 {
166 this->check(i, 0, 0, d);
167 this->t0Data_[i][d] = static_cast<T>(value);
168 }
SafeStack< ValueType > value

◆ get()

Real get ( Size  i,
Size  j,
Size  k,
Size  d 
) const
overridevirtual

Get a value from the cube.

Implements NPVCube.

Definition at line 171 of file inmemorycube.hpp.

171 {
172 this->check(i, j, k, d);
173 return this->data_[i][j][k][d];
174 }

◆ set()

void set ( Real  value,
Size  i,
Size  j,
Size  k,
Size  d 
)
overridevirtual

Set a value in the cube.

Implements NPVCube.

Definition at line 177 of file inmemorycube.hpp.

177 {
178 this->check(i, j, k, d);
179 this->data_[i][j][k][d] = static_cast<T>(value);
180 }