QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
AdaptiveRungeKutta< T > Class Template Reference

#include <adaptiverungekutta.hpp>

+ Collaboration diagram for AdaptiveRungeKutta< T >:

Public Types

typedef ext::function< std::vector< T >(const Real, const std::vector< T > &)> OdeFct
 
typedef ext::function< T(const Real, const T)> OdeFct1d
 

Public Member Functions

 AdaptiveRungeKutta (const Real eps=1.0e-6, const Real h1=1.0e-4, const Real hmin=0.0)
 
std::vector< Toperator() (const OdeFct &ode, const std::vector< T > &y1, Real x1, Real x2)
 
T operator() (const OdeFct1d &ode, T y1, Real x1, Real x2)
 

Private Member Functions

void rkqs (std::vector< T > &y, const std::vector< T > &dydx, Real &x, Real htry, Real eps, const std::vector< Real > &yScale, Real &hdid, Real &hnext, const OdeFct &derivs)
 
void rkck (const std::vector< T > &y, const std::vector< T > &dydx, Real x, Real h, std::vector< T > &yout, std::vector< T > &yerr, const OdeFct &derivs)
 

Private Attributes

const std::vector< TyStart_
 
const Real eps_
 
const Real h1_
 
const Real hmin_
 
const Real a2 = 0.2
 
const Real a3 = 0.3
 
const Real a4 = 0.6
 
const Real a5 = 1.0
 
const Real a6 = 0.875
 
const Real b21 = 0.2
 
const Real b31
 
const Real b32
 
const Real b41 = 0.3
 
const Real b42 = -0.9
 
const Real b43 = 1.2
 
const Real b51
 
const Real b52 = 2.5
 
const Real b53
 
const Real b54
 
const Real b61
 
const Real b62
 
const Real b63
 
const Real b64
 
const Real b65
 
const Real c1
 
const Real c3
 
const Real c4
 
const Real c6
 
const Real dc1
 
const Real dc3
 
const Real dc4
 
const Real dc5
 
const Real dc6
 
const double ADAPTIVERK_MAXSTP = 10000
 
const double ADAPTIVERK_TINY = 1.0E-30
 
const double ADAPTIVERK_SAFETY = 0.9
 
const double ADAPTIVERK_PGROW = -0.2
 
const double ADAPTIVERK_PSHRINK = -0.25
 
const double ADAPTIVERK_ERRCON = 1.89E-4
 

Detailed Description

template<class T = Real>
class QuantLib::AdaptiveRungeKutta< T >

Definition at line 40 of file adaptiverungekutta.hpp.

Member Typedef Documentation

◆ OdeFct

typedef ext::function<std::vector<T>(const Real, const std::vector<T>&)> OdeFct

Definition at line 42 of file adaptiverungekutta.hpp.

◆ OdeFct1d

typedef ext::function<T(const Real, const T)> OdeFct1d

Definition at line 43 of file adaptiverungekutta.hpp.

Constructor & Destructor Documentation

◆ AdaptiveRungeKutta()

AdaptiveRungeKutta ( const Real  eps = 1.0e-6,
const Real  h1 = 1.0e-4,
const Real  hmin = 0.0 
)

The class is constructed with the following inputs:

  • eps prescribed error for the solution
  • h1 start step size
  • hmin smallest step size allowed

Definition at line 51 of file adaptiverungekutta.hpp.

Member Function Documentation

◆ operator()() [1/2]

std::vector< T > operator() ( const OdeFct ode,
const std::vector< T > &  y1,
Real  x1,
Real  x2 
)

Integrate the ode from \( x1 \) to \( x2 \) with initial value condition \( f(x1)=y1 \).

The ode is given by a function \( F: R \times K^n \rightarrow K^n \) as \( f'(x) = F(x,f(x)) \), $K=R, C$

Definition at line 99 of file adaptiverungekutta.hpp.

◆ operator()() [2/2]

T operator() ( const OdeFct1d ode,
T  y1,
Real  x1,
Real  x2 
)

Definition at line 147 of file adaptiverungekutta.hpp.

◆ rkqs()

void rkqs ( std::vector< T > &  y,
const std::vector< T > &  dydx,
Real x,
Real  htry,
Real  eps,
const std::vector< Real > &  yScale,
Real hdid,
Real hnext,
const OdeFct derivs 
)
private

Definition at line 156 of file adaptiverungekutta.hpp.

◆ rkck()

void rkck ( const std::vector< T > &  y,
const std::vector< T > &  dydx,
Real  x,
Real  h,
std::vector< T > &  yout,
std::vector< T > &  yerr,
const OdeFct derivs 
)
private

Definition at line 207 of file adaptiverungekutta.hpp.

Member Data Documentation

◆ yStart_

const std::vector<T> yStart_
private

Definition at line 86 of file adaptiverungekutta.hpp.

◆ eps_

const Real eps_
private

Definition at line 87 of file adaptiverungekutta.hpp.

◆ h1_

const Real h1_
private

Definition at line 87 of file adaptiverungekutta.hpp.

◆ hmin_

const Real hmin_
private

Definition at line 87 of file adaptiverungekutta.hpp.

◆ a2

const Real a2 = 0.2
private

Definition at line 88 of file adaptiverungekutta.hpp.

◆ a3

const Real a3 = 0.3
private

Definition at line 88 of file adaptiverungekutta.hpp.

◆ a4

const Real a4 = 0.6
private

Definition at line 88 of file adaptiverungekutta.hpp.

◆ a5

const Real a5 = 1.0
private

Definition at line 88 of file adaptiverungekutta.hpp.

◆ a6

const Real a6 = 0.875
private

Definition at line 88 of file adaptiverungekutta.hpp.

◆ b21

const Real b21 = 0.2
private

Definition at line 88 of file adaptiverungekutta.hpp.

◆ b31

const Real b31
private

Definition at line 88 of file adaptiverungekutta.hpp.

◆ b32

const Real b32
private

Definition at line 88 of file adaptiverungekutta.hpp.

◆ b41

const Real b41 = 0.3
private

Definition at line 89 of file adaptiverungekutta.hpp.

◆ b42

const Real b42 = -0.9
private

Definition at line 89 of file adaptiverungekutta.hpp.

◆ b43

const Real b43 = 1.2
private

Definition at line 89 of file adaptiverungekutta.hpp.

◆ b51

const Real b51
private

Definition at line 89 of file adaptiverungekutta.hpp.

◆ b52

const Real b52 = 2.5
private

Definition at line 89 of file adaptiverungekutta.hpp.

◆ b53

const Real b53
private

Definition at line 89 of file adaptiverungekutta.hpp.

◆ b54

const Real b54
private

Definition at line 89 of file adaptiverungekutta.hpp.

◆ b61

const Real b61
private

Definition at line 89 of file adaptiverungekutta.hpp.

◆ b62

const Real b62
private

Definition at line 89 of file adaptiverungekutta.hpp.

◆ b63

const Real b63
private

Definition at line 89 of file adaptiverungekutta.hpp.

◆ b64

const Real b64
private

Definition at line 89 of file adaptiverungekutta.hpp.

◆ b65

const Real b65
private

Definition at line 90 of file adaptiverungekutta.hpp.

◆ c1

const Real c1
private

Definition at line 90 of file adaptiverungekutta.hpp.

◆ c3

const Real c3
private

Definition at line 90 of file adaptiverungekutta.hpp.

◆ c4

const Real c4
private

Definition at line 90 of file adaptiverungekutta.hpp.

◆ c6

const Real c6
private

Definition at line 90 of file adaptiverungekutta.hpp.

◆ dc1

const Real dc1
private

Definition at line 90 of file adaptiverungekutta.hpp.

◆ dc3

const Real dc3
private

Definition at line 90 of file adaptiverungekutta.hpp.

◆ dc4

const Real dc4
private

Definition at line 90 of file adaptiverungekutta.hpp.

◆ dc5

const Real dc5
private

Definition at line 90 of file adaptiverungekutta.hpp.

◆ dc6

const Real dc6
private

Definition at line 90 of file adaptiverungekutta.hpp.

◆ ADAPTIVERK_MAXSTP

const double ADAPTIVERK_MAXSTP = 10000
private

Definition at line 91 of file adaptiverungekutta.hpp.

◆ ADAPTIVERK_TINY

const double ADAPTIVERK_TINY = 1.0E-30
private

Definition at line 91 of file adaptiverungekutta.hpp.

◆ ADAPTIVERK_SAFETY

const double ADAPTIVERK_SAFETY = 0.9
private

Definition at line 91 of file adaptiverungekutta.hpp.

◆ ADAPTIVERK_PGROW

const double ADAPTIVERK_PGROW = -0.2
private

Definition at line 92 of file adaptiverungekutta.hpp.

◆ ADAPTIVERK_PSHRINK

const double ADAPTIVERK_PSHRINK = -0.25
private

Definition at line 92 of file adaptiverungekutta.hpp.

◆ ADAPTIVERK_ERRCON

const double ADAPTIVERK_ERRCON = 1.89E-4
private

Definition at line 93 of file adaptiverungekutta.hpp.