25#include <ql/math/matrixutilities/expm.hpp>
26#include <ql/math/ode/adaptiverungekutta.hpp>
34 class MatrixVectorProductFct {
36 explicit MatrixVectorProductFct(Matrix m) : m_(
std::move(m)) {}
39 std::vector<Real> operator()(
Real t,
const std::vector<Real>& y) {
41 std::vector<Real> result(m_.rows());
42 for (
Size i=0; i < result.size(); i++) {
43 result[i] = std::inner_product(y.begin(), y.end(),
44 m_.row_begin(i),
Real(0.0));
55 QL_REQUIRE(n == M.
columns(),
"Expm expects a square matrix");
61 for (
Size i=0; i < n; ++i) {
62 std::vector<Real> x0(n, 0.0);
65 const std::vector<Real> r = rk(odeFct, x0, 0.0, t);
ext::function< std::vector< T >(const Real, const std::vector< T > &)> OdeFct
Matrix used in linear algebra.
const_column_iterator column_begin(Size i) const
std::size_t Size
size of a container
Matrix Expm(const Matrix &M, Real t, Real tol)
matrix exponential based on the ordinary differential equations method