31 "negative times not allowed");
34 for (
Size i=0; i<=steps; i++)
40 dt_ = std::vector<Time>(steps,
dt);
49 QL_FAIL(
"using inadequate time grid: all nodes "
50 "are later than the required time t = "
51 << std::setprecision(12) <<
t
52 <<
" (earliest node is t1 = "
53 << std::setprecision(12) <<
times_.front() <<
")");
55 QL_FAIL(
"using inadequate time grid: all nodes "
56 "are earlier than the required time t = "
57 << std::setprecision(12) <<
t
58 <<
" (latest node is t1 = "
59 << std::setprecision(12) <<
times_.back() <<
")");
69 QL_FAIL(
"using inadequate time grid: the nodes closest "
70 "to the required time t = "
71 << std::setprecision(12) <<
t
73 << std::setprecision(12) <<
times_[j]
75 << std::setprecision(12) <<
times_[k]);
82 auto result = std::lower_bound(
begin,
end,
t);
83 if (result ==
begin) {
85 }
else if (result ==
end) {
88 Time dt1 = *result -
t;
89 Time dt2 =
t - *(result-1);
93 return (result-
begin)-1;
std::vector< Time > mandatoryTimes_
const_iterator begin() const
std::vector< Time > times_
Size index(Time t) const
returns the index i such that grid[i] = t
Size closestIndex(Time t) const
returns the index i such that grid[i] is closest to t
const_iterator end() const
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
Real Time
continuous quantity with 1-year units
std::size_t Size
size of a container
bool close_enough(const Quantity &m1, const Quantity &m2, Size n)