APFEL 4.8.0
A PDF evolution library in C++
Loading...
Searching...
No Matches
ode.h
Go to the documentation of this file.
1//
2// APFEL++ 2017
3//
4// Author: Valerio Bertone: valerio.bertone@cern.ch
5//
6
7#pragma once
8
9namespace apfel
10{
28
34 template<class U>
35 std::function<U(double const&, U const&, double const&)>
36 rk4(std::function<U(double const& t, U const& Obj)> const& f)
37 {
38 // *INDENT-OFF*
39 return
40 [ f ] (double const& t, U const& y, double const& dt) -> U{ return
41 [t,y,dt,f ] ( U const& dy1 ) -> U{ return
42 [t,y,dt,f,dy1 ] ( U const& dy2 ) -> U{ return
43 [t,y,dt,f,dy1,dy2 ] ( U const& dy3 ) -> U{ return
44 [ f,dy1,dy2,dy3] ( U const& dy4 ) -> U{ return
45 ( dy1 + 2 * dy2 + 2 * dy3 + dy4 ) / 6 ;} (
46 dt * f( t + dt , y + dy3 ) );} (
47 dt * f( t + dt / 2, y + dy2 / 2 ) );} (
48 dt * f( t + dt / 2, y + dy1 / 2 ) );} (
49 dt * f( t , y ) );} ;
50 // *INDENT-ON*
51 }
52
59 template<class U>
60 std::function<U(double const&, U const&, double const&)>
61 rk1(std::function<U(double const& t, U const& Obj)> const& f)
62 {
63 return [f] (double const& t, U const& y, double const& dt) -> U{ return dt * f(t, y); } ;
64 }
66}
Namespace for all APFEL++ functions and classes.
Definition alphaqcd.h:14
std::function< U(double const &, U const &, double const &) rk1)(std::function< U(double const &t, U const &Obj)> const &f)
Template function that implements the first order RK algorithm.
Definition ode.h:61
std::function< U(double const &, U const &, double const &) rk4)(std::function< U(double const &t, U const &Obj)> const &f)
Template function that implements the fourth order RK algorithm.
Definition ode.h:36