26int get_index_randomvariable_output_size() {
27 static int index = std::ios_base::xalloc();
31int get_index_randomvariable_output_pattern() {
32 static int index = std::ios_base::xalloc();
39 out.iword(get_index_randomvariable_output_size()) =
static_cast<long>(r.
n());
44 out.iword(get_index_randomvariable_output_pattern()) =
static_cast<long>(p.
getPattern());
50const RandomVariable& convertToRandomVariable(
const RandomVariable& c) {
return c; }
51RandomVariable convertToRandomVariable(
const Filter& c) {
return RandomVariable(c); }
53template <
typename C> std::ostream& output(std::ostream& out,
const C& c) {
54 if (!c.initialised()) {
56 }
else if (c.deterministic()) {
57 out << std::boolalpha << c.at(0);
62 long os = out.iword(get_index_randomvariable_output_size());
63 long pt = out.iword(get_index_randomvariable_output_pattern());
67 Size n = std::min<Size>(c.size(), os == 0 ? 10 :
static_cast<Size
>(os));
75 for (Size i = 0; i < n; ++i)
76 out << c.at(i) << (i < n - 1 ?
"," :
"");
82 Size s = std::max<Size>(n / 3, 1);
83 if (c.size() <= 3 * s) {
84 for (Size i = 0; i < c.size(); ++i)
85 out << c.at(i) << (i < c.size() - 1 ?
"," :
"");
87 for (Size i = 0; i < s; ++i)
88 out << c.at(i) <<
",";
90 for (Size i = c.size() / 2 - s / 2; i < c.size() / 2 - s / 2 + s; ++i)
91 out << c.at(i) <<
",";
93 for (Size i = c.size() - s; i < c.size(); ++i)
94 out << c.at(i) << (i < c.size() - 1 ?
"," :
"");
98 out <<
expectation(convertToRandomVariable(c)) << (!c.deterministic() ?
" (avg)" :
"");
100 out <<
"<unknown output pattern>";
112 if (r.
time() != Null<Real>())
113 out <<
" t=" << r.
time();
pattern getPattern() const
std::ostream & operator<<(std::ostream &out, EquityReturnType t)
RandomVariable expectation(const RandomVariable &r)