24#ifndef quantlib_finite_difference_model_hpp
25#define quantlib_finite_difference_model_hpp
36 template<
class Evolver>
39 typedef typename Evolver::traits
traits;
42 typedef typename traits::bc_set
bc_set;
47 std::vector<Time> stoppingTimes = std::vector<Time>())
54 std::vector<Time> stoppingTimes = std::vector<Time>())
93 "trying to roll back from " << from <<
" to " << to);
95 Time dt = (from-to)/steps,
t = from;
100 condition->applyTo(a,from);
102 for (
Size i=0; i<steps; ++i,
t -= dt) {
106 Time next = (i < steps -1)?
t-dt : to;
108 if (std::fabs(to-next) < std::sqrt(
QL_EPSILON)) next = to;
132 condition->applyTo(a,next);
142 condition->applyTo(a, next);
boundary conditions for differential operators
Generic finite difference model.
traits::operator_type operator_type
FiniteDifferenceModel(const operator_type &L, const bc_set &bcs, std::vector< Time > stoppingTimes=std::vector< Time >())
std::vector< Time > stoppingTimes_
void rollback(array_type &a, Time from, Time to, Size steps)
void rollbackImpl(array_type &a, Time from, Time to, Size steps, const condition_type *condition)
void rollback(array_type &a, Time from, Time to, Size steps, const condition_type &condition)
traits::condition_type condition_type
traits::array_type array_type
FiniteDifferenceModel(Evolver evolver, std::vector< Time > stoppingTimes=std::vector< Time >())
const Evolver & evolver() const
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Real Time
continuous quantity with 1-year units
QL_INTEGER Integer
integer number
std::size_t Size
size of a container
Differential operator traits.
conditions to be applied at every time step