28 const std::vector<Real>& values) {
30 "number of dates differs from number of values");
32 for (
Size i = 0; i < dates.size(); i++)
33 self[dates[i]] = values[i];
37 QL_REQUIRE(!buckets.empty(),
"empty bucket structure");
39 std::vector<Date> sbuckets = buckets;
40 std::sort(sbuckets.begin(), sbuckets.end());
44 for (
auto& sbucket : sbuckets)
45 result[sbucket] = 0.0;
47 for (
auto j : *
this) {
49 Real value = j.second;
52 std::vector<Date>::const_iterator bi =
53 std::lower_bound(sbuckets.begin(), sbuckets.end(), date);
55 if (bi == sbuckets.end())
56 pDate = sbuckets.back();
60 if (bi != sbuckets.begin() && bi != sbuckets.end())
64 result[pDate] += value;
69 result[pDate] += value*(nDays/tDays);
70 result[nDate] += value*(pDays/tDays);
template class providing a null value for a given type.
Distribution over a number of dates.
TimeBasket rebin(const std::vector< Date > &buckets) const
redistribute the entries over the given dates
std::map< Date, Real > super
Classes and functions for error handling.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
std::size_t Size
size of a container
distribution over a number of date ranges