23#include <ql/tuple.hpp>
32 QL_REQUIRE(!
scalars.empty() || !
arrays.empty(),
"Context::varSize(): context is empty()");
33 Size res = Null<Size>();
35 if (res != Null<Size>())
36 QL_REQUIRE(
size(v.second) == res,
"Context::varSize(): inconsistent var sizes");
40 for (
auto const& v :
arrays) {
41 for (
auto const& a : v.second) {
42 if (res != Null<Size>())
43 QL_REQUIRE(
size(a) == res,
"Context::varSize(): inconsistent var sizes");
52 constexpr Size wd1 = 30, wd2 = 10;
53 for (
auto const& v : context.
scalars) {
54 out << std::setw(wd1) << std::left << v.first;
55 out <<
"(" << std::setw(wd2) << valueTypeLabels.at(v.second.which()) <<
")";
60 out << std::left << v.second <<
'\n';
62 for (
auto const& v : context.
arrays) {
64 for (
auto const& d : v.second) {
65 out << std::setw(wd1) << std::left << (v.first +
"[" + std::to_string(counter + 1) +
"]");
66 out <<
"(" << std::setw(wd2) << valueTypeLabels.at(d.which()) <<
")";
71 out << std::left << d <<
'\n';
79void resetSize(
ValueType& v,
const Size n) {
82 QuantLib::ext::get<RandomVariable>(v).resetSize(n);
85 QuantLib::ext::get<Filter>(v).resetSize(n);
88 QuantLib::ext::get<EventVec>(v).size = n;
91 QuantLib::ext::get<CurrencyVec>(v).size = n;
94 QuantLib::ext::get<IndexVec>(v).size = n;
97 QuantLib::ext::get<DaycounterVec>(v).size = n;
100 QL_FAIL(
"resetSize(): value type not handled. internal error, contact dev.");
107 ::ore::data::resetSize(v, n);
109 for (
auto& [_, a] :
arrays) {
111 ::ore::data::resetSize(v, n);
script engine context holding variable names and values
std::ostream & operator<<(std::ostream &out, EquityReturnType t)
Size size(const ValueType &v)
boost::variant< RandomVariable, EventVec, CurrencyVec, IndexVec, DaycounterVec, Filter > ValueType
Serializable Credit Default Swap.
std::map< std::string, ValueType > scalars
std::map< std::string, std::vector< ValueType > > arrays
void resetSize(const std::size_t n)
std::set< std::string > constants
string conversion utilities