|
19 | 19 | #ifndef orea_cube_i |
20 | 20 | #define orea_cube_i |
21 | 21 |
|
| 22 | +%include stl.i |
| 23 | +%include types.i |
| 24 | + |
22 | 25 | %{ |
23 | 26 | using ore::analytics::NPVCube; |
| 27 | +using ore::analytics::JointNPVCube; |
| 28 | +using ore::analytics::InMemoryCubeBase; |
| 29 | +using ore::analytics::InMemoryCubeN; |
24 | 30 | using ore::analytics::AggregationScenarioData; |
25 | 31 | using ore::analytics::AggregationScenarioDataType; |
| 32 | +using ore::analytics::DoublePrecisionInMemoryCubeN; |
26 | 33 | %} |
27 | 34 |
|
28 | 35 | %shared_ptr(NPVCube) |
@@ -81,4 +88,87 @@ public: |
81 | 88 | } |
82 | 89 | }; |
83 | 90 |
|
| 91 | +%shared_ptr(InMemoryCubeN<float>); |
| 92 | +%shared_ptr(InMemoryCubeN<double>); |
| 93 | +template <typename T> class InMemoryCubeN : public InMemoryCubeBase<std::vector<T>> { |
| 94 | +public: |
| 95 | + InMemoryCubeN(const QuantLib::Date& asof, const std::set<std::string>& ids, const std::vector<QuantLib::Date>& dates, QuantLib::Size samples, QuantLib::Size depth, |
| 96 | + const T& t = T()); |
| 97 | + InMemoryCubeN(); |
| 98 | + QuantLib::Size depth() const override; |
| 99 | + virtual QuantLib::Real getT0(QuantLib::Size i, QuantLib::Size d) const override; |
| 100 | + virtual void setT0(QuantLib::Real value, QuantLib::Size i, QuantLib::Size d) override; |
| 101 | + QuantLib::Real get(QuantLib::Size i, QuantLib::Size j, QuantLib::Size k, QuantLib::Size d) const override ; |
| 102 | + void set(QuantLib::Real value, QuantLib::Size i, QuantLib::Size j, QuantLib::Size k, QuantLib::Size d) override; |
| 103 | +}; |
| 104 | + |
| 105 | +//! InMemoryCube of depth N with single precision floating point numbers. |
| 106 | +%template(SinglePrecisionInMemoryCubeN) InMemoryCubeN<float>; |
| 107 | + |
| 108 | +//! InMemoryCube of depth N with double precision floating point numbers. |
| 109 | +%template(DoublePrecisionInMemoryCubeN) InMemoryCubeN<double>; |
| 110 | + |
| 111 | +%shared_ptr(SinglePrecisionInMemoryCubeN); |
| 112 | +%shared_ptr(DoublePrecisionInMemoryCubeN); |
| 113 | + |
| 114 | +%template(DoublePrecisionInMemoryCubeNVector) std::vector< ext::shared_ptr<InMemoryCubeN<double > > >; |
| 115 | + |
| 116 | +%shared_ptr(JointNPVCube) |
| 117 | +class JointNPVCube : public NPVCube { |
| 118 | +public: |
| 119 | + %extend { |
| 120 | + JointNPVCube( |
| 121 | + const ext::shared_ptr<NPVCube>& cube1, const ext::shared_ptr<NPVCube>& cube2, |
| 122 | + const std::set<std::string>& ids = {}, const bool requireUniqueIds = true) { |
| 123 | + return new JointNPVCube(cube1, cube2, ids, requireUniqueIds); |
| 124 | + } |
| 125 | + |
| 126 | + JointNPVCube( |
| 127 | + const std::vector<ext::shared_ptr<NPVCube>>& cubes, const std::set<std::string>& ids = {}, |
| 128 | + const bool requireUniqueIds = true){ |
| 129 | + return new JointNPVCube(cubes, ids, requireUniqueIds); |
| 130 | + } |
| 131 | + |
| 132 | + JointNPVCube( |
| 133 | + const ext::shared_ptr<InMemoryCubeN<double>>& cube1, const ext::shared_ptr<InMemoryCubeN<double>>& cube2, |
| 134 | + const std::set<std::string>& ids = {}, const bool requireUniqueIds = true) { |
| 135 | + return new JointNPVCube(cube1, cube2, ids, requireUniqueIds); |
| 136 | + } |
| 137 | + |
| 138 | + JointNPVCube( |
| 139 | + const std::vector<ext::shared_ptr<InMemoryCubeN<double>>>& cubes, const std::set<std::string>& ids = {}, |
| 140 | + const bool requireUniqueIds = true){ |
| 141 | + std::vector<ext::shared_ptr<NPVCube>> npvCubes(cubes.begin(), cubes.end()); |
| 142 | + return new JointNPVCube(npvCubes, ids, requireUniqueIds); |
| 143 | + } |
| 144 | + |
| 145 | + JointNPVCube( |
| 146 | + const ext::shared_ptr<InMemoryCubeN<float>>& cube1, const ext::shared_ptr<InMemoryCubeN<float>>& cube2, |
| 147 | + const std::set<std::string>& ids = {}, const bool requireUniqueIds = true) { |
| 148 | + return new JointNPVCube(cube1, cube2, ids, requireUniqueIds); |
| 149 | + } |
| 150 | + |
| 151 | + JointNPVCube( |
| 152 | + const std::vector<ext::shared_ptr<InMemoryCubeN<float>>>& cubes, const std::set<std::string>& ids = {}, |
| 153 | + const bool requireUniqueIds = true){ |
| 154 | + std::vector<ext::shared_ptr<NPVCube>> npvCubes(cubes.begin(), cubes.end()); |
| 155 | + return new JointNPVCube(npvCubes, ids, requireUniqueIds); |
| 156 | + } |
| 157 | + } |
| 158 | + QuantLib::Size numIds() const override; |
| 159 | + QuantLib::Size numDates() const override; |
| 160 | + QuantLib::Size samples() const override; |
| 161 | + QuantLib::Size depth() const override; |
| 162 | + |
| 163 | + const std::map<std::string, QuantLib::Size>& idsAndIndexes() const override; |
| 164 | + const std::vector<QuantLib::Date>& dates() const override; |
| 165 | + QuantLib::Date asof() const override; |
| 166 | + |
| 167 | + QuantLib::Real getT0(QuantLib::Size id, QuantLib::Size depth = 0) const override; |
| 168 | + void setT0(QuantLib::Real value, QuantLib::Size id, QuantLib::Size depth = 0) override; |
| 169 | + |
| 170 | + QuantLib::Real get(QuantLib::Size id, QuantLib::Size date, QuantLib::Size sample, QuantLib::Size depth = 0) const override; |
| 171 | + void set(QuantLib::Real value, QuantLib::Size id, QuantLib::Size date, QuantLib::Size sample, QuantLib::Size depth = 0) override; |
| 172 | +}; |
| 173 | + |
84 | 174 | #endif |
0 commit comments