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

#include <orea/cube/jaggedcube.hpp>

+ Collaboration diagram for TradeBlock< T >:

Public Member Functions

 TradeBlock ()
 
 TradeBlock (Size inputDates, Size inputDepth, Size samples)
 
Size index (Size date, Size dep, Size sample) const
 
Size indexT0 (Size dep) const
 
bool isValid (Size date, Size dep, Size sample) const
 
bool isValidT0 (Size dep) const
 
Real getT0 (Size dep) const
 
void setT0 (Real value, Size dep)
 
Real get (Size date, Size sample, Size dep) const
 
void set (Real value, Size date, Size sample, Size dep)
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int)
 

Private Attributes

Size dateLen_
 
Size depth_
 
Size samples_
 
vector< T > data_
 

Friends

class boost::serialization::access
 

Detailed Description

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

Definition at line 43 of file jaggedcube.hpp.

Constructor & Destructor Documentation

◆ TradeBlock() [1/2]

◆ TradeBlock() [2/2]

TradeBlock ( Size  inputDates,
Size  inputDepth,
Size  samples 
)

Definition at line 53 of file jaggedcube.hpp.

54 : dateLen_(inputDates), depth_(inputDepth), samples_(samples) {
55 Size len = (1 + (dateLen_ * samples_)) * depth_;
56 data_ = vector<T>(len, T());
57 }

Member Function Documentation

◆ index()

Size index ( Size  date,
Size  dep,
Size  sample 
) const

Definition at line 59 of file jaggedcube.hpp.

59 {
60 // calculate index of element
61 return depth_ + // T0 block
62 dep + (sample * depth_) + (date * depth_ * samples_);
63 }
+ Here is the caller graph for this function:

◆ indexT0()

Size indexT0 ( Size  dep) const

Definition at line 65 of file jaggedcube.hpp.

65{ return dep; }
+ Here is the caller graph for this function:

◆ isValid()

bool isValid ( Size  date,
Size  dep,
Size  sample 
) const

Definition at line 67 of file jaggedcube.hpp.

67 {
68 // return true if this is valid
69 return date < dateLen_ && sample < samples_ && dep < depth_;
70 }
+ Here is the caller graph for this function:

◆ isValidT0()

bool isValidT0 ( Size  dep) const

Definition at line 72 of file jaggedcube.hpp.

72{ return dep < depth_; }
+ Here is the caller graph for this function:

◆ getT0()

Real getT0 ( Size  dep) const

Definition at line 74 of file jaggedcube.hpp.

74 {
75 if (this->isValidT0(dep)) {
76 return static_cast<Real>(this->data_[indexT0(dep)]);
77 } else {
78 return 0;
79 }
80 }
bool isValidT0(Size dep) const
Definition: jaggedcube.hpp:72
Size indexT0(Size dep) const
Definition: jaggedcube.hpp:65
+ Here is the call graph for this function:

◆ setT0()

void setT0 ( Real  value,
Size  dep 
)

Definition at line 82 of file jaggedcube.hpp.

82 {
83 if (this->isValidT0(dep)) {
84 this->data_[indexT0(dep)] = static_cast<T>(value);
85 } else {
86 QL_REQUIRE(value == 0, "Cannot set nonzero value for T0 dep = " << dep);
87 }
88 }
SafeStack< ValueType > value
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get()

Real get ( Size  date,
Size  sample,
Size  dep 
) const

Definition at line 90 of file jaggedcube.hpp.

90 {
91 // if isValid return the value cast to a Real
92 if (this->isValid(date, dep, sample)) {
93 return static_cast<Real>(this->data_[index(date, dep, sample)]);
94 } else {
95 return 0;
96 }
97 }
Size index(Size date, Size dep, Size sample) const
Definition: jaggedcube.hpp:59
bool isValid(Size date, Size dep, Size sample) const
Definition: jaggedcube.hpp:67
+ Here is the call graph for this function:

◆ set()

void set ( Real  value,
Size  date,
Size  sample,
Size  dep 
)

Definition at line 99 of file jaggedcube.hpp.

99 {
100 // if isValid set in the buffer
101 if (this->isValid(date, dep, sample)) {
102 this->data_[index(date, dep, sample)] = static_cast<T>(value);
103 } else {
104 QL_REQUIRE(value == 0,
105 "Cannot set nonzero value for date: " << date << ", depth: " << dep << ", sample: " << sample);
106 }
107 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize()

void serialize ( Archive &  ar,
const unsigned int   
)
private

Definition at line 111 of file jaggedcube.hpp.

111 {
112 ar& depth_;
113 ar& dateLen_;
114 ar& samples_;
115 ar& data_;
116 }

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 110 of file jaggedcube.hpp.

Member Data Documentation

◆ dateLen_

Size dateLen_
private

Definition at line 45 of file jaggedcube.hpp.

◆ depth_

Size depth_
private

Definition at line 46 of file jaggedcube.hpp.

◆ samples_

Size samples_
private

Definition at line 47 of file jaggedcube.hpp.

◆ data_

vector<T> data_
private

Definition at line 48 of file jaggedcube.hpp.