Coverage Report

Created: 2025-12-08 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/quantlib/ql/processes/eulerdiscretization.cpp
Line
Count
Source
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
/*
4
 Copyright (C) 2004, 2005 StatPro Italia srl
5
6
 This file is part of QuantLib, a free-software/open-source library
7
 for financial quantitative analysts and developers - http://quantlib.org/
8
9
 QuantLib is free software: you can redistribute it and/or modify it
10
 under the terms of the QuantLib license.  You should have received a
11
 copy of the license along with this program; if not, please email
12
 <quantlib-dev@lists.sf.net>. The license is also available online at
13
 <https://www.quantlib.org/license.shtml>.
14
15
 This program is distributed in the hope that it will be useful, but WITHOUT
16
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17
 FOR A PARTICULAR PURPOSE.  See the license for more details.
18
*/
19
20
#include <ql/processes/eulerdiscretization.hpp>
21
22
namespace QuantLib {
23
24
    Array EulerDiscretization::drift(const StochasticProcess& process,
25
                                     Time t0, const Array& x0,
26
0
                                     Time dt) const {
27
0
        return process.drift(t0, x0)*dt;
28
0
    }
29
30
    Real EulerDiscretization::drift(const StochasticProcess1D& process,
31
0
                                    Time t0, Real x0, Time dt) const {
32
0
        return process.drift(t0, x0)*dt;
33
0
    }
34
35
    Matrix EulerDiscretization::diffusion(const StochasticProcess& process,
36
                                          Time t0,
37
                                          const Array& x0,
38
0
                                          Time dt) const {
39
0
        return process.diffusion(t0, x0) * std::sqrt(dt);
40
0
    }
41
42
    Real EulerDiscretization::diffusion(const StochasticProcess1D& process,
43
0
                                        Time t0, Real x0, Time dt) const {
44
0
        return process.diffusion(t0, x0) * std::sqrt(dt);
45
0
    }
46
47
    Matrix EulerDiscretization::covariance(const StochasticProcess& process,
48
                                           Time t0,
49
                                           const Array& x0,
50
0
                                           Time dt) const {
51
0
        Matrix sigma = process.diffusion(t0, x0);
52
0
        Matrix result = sigma*transpose(sigma)*dt;
53
0
        return result;
54
0
    }
55
56
    Real EulerDiscretization::variance(const StochasticProcess1D& process,
57
0
                                       Time t0, Real x0, Time dt) const {
58
0
        Real sigma = process.diffusion(t0, x0);
59
0
        return sigma*sigma*dt;
60
0
    }
61
62
}
63