1[/============================================================================ 2 Boost.odeint 3 4 Copyright 2011 Mario Mulansky 5 Copyright 2012 Karsten Ahnert 6 Copyright 2013 Pascal Germroth 7 8 Use, modification and distribution is subject to the Boost Software License, 9 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 10 http://www.boost.org/LICENSE_1_0.txt) 11=============================================================================/] 12 13 14 15[section State Algebra Operations] 16 17[note The following does not apply to implicit steppers like implicit_euler or Rosenbrock 4 as there the `state_type` can not be changed from `ublas::vector` and no algebra/operations are used.] 18 19[heading Description] 20 21The `State`, `Algebra` and `Operations` together define a concept describing how the mathematical vector operations required for the stepper algorithms are performed. 22The typical vector operation done within steppers is 23 24['*y* = __Sigma __alpha[sub i] [*x[sub i]]]. 25 26The `State` represents the state variable of an ODE, usually denoted with /x/. 27Algorithmically, the state is often realized as a `vector< double >` or `array< double , N >`, however, the genericity of odeint enables you to basically use anything as a state type. 28The algorithmic counterpart of such mathematical expressions is divided into two parts. 29First, the `Algebra` is used to account for the vector character of the equation. 30In the case of a `vector` as state type this means the `Algebra` is responsible for iteration over all vector elements. 31Second, the `Operations` are used to represent the actual operation applied to each of the vector elements. 32So the `Algebra` iterates over all elements of the `State`s and calls an operation taken from the `Operations` for each element. 33This is where `State`, `Algebra` and `Operations` have to work together to make odeint running. 34Please have a look at the `range_algebra` and `default_operations` to see an example how this is implemented. 35 36In the following we describe how `State`, `Algebra` and `Operations` are used together within the stepper implementations. 37 38[section Operations] 39 40[heading Notation] 41 42[variablelist 43 [[`Operations`] [The operations type]] 44 [/[`Time`] [A type representing the time type of steppers]] 45 [[`Value1`, ... , `ValueN`] [Types representing the value or time type of stepper]] 46 [[`Scale`] [Type of the scale operation]] 47 [[`scale`] [Object of type `Scale`]] 48 [[[^ScaleSum['N]]] [Type that represents a general scale_sum operation, [^/N/] should be replaced by a number from 1 to 14.]] 49 [[[^scale_sum['N]]] [Object of type [^ScaleSum['N]], [^/N/] should be replaced by a number from 1 to 14.]] 50 [[`ScaleSumSwap2`] [Type of the scale sum swap operation]] 51 [[`scale_sum_swap2`] [Object of type `ScaleSumSwap2`]] 52 [[`a1, a2, ...`] [Objects of type `Value1`, `Value2`, ...]] 53 [[`y, x1, x2, ...`] [Objects of `State`'s value type]] 54] 55 56[heading Valid Expressions] 57 58[table 59 [[Name] [Expression] [Type] [Semantics]] 60 [[Get scale operation] [`Operations::scale< Value >`] [`Scale`] [Get `Scale` from `Operations`]] 61 [[`Scale` constructor] [`Scale< Value >( a )`] [`Scale`] [Constructs a `Scale` object]] 62 [[`Scale` operation] [`scale( x )`] [`void`] [Calculates `x *= a`]] 63 [[Get general `scale_sum` operation] [[^Operations::scale_sum['N]< Value1 , ... , ValueN >]] [[^ScaleSum['N]]] [Get the [^ScaleSum['N]] type from `Operations`, [^/N/] should be replaced by a number from 1 to 14.]] 64 [[`scale_sum` constructor] [[^ScaleSum['N]< Value1 , ... , ValueN >( a1 , ... , aN )]] [[^ScaleSum['N]]] [Constructs a `scale_sum` object given [^/N/] parameter values with [^/N/] between 1 and 14.]] 65 [[`scale_sum` operation] [[^scale_sum['N]( y , x1 , ... , xN )]] [`void`] [Calculates `y = a1*x1 + a2*x2 + ... + aN*xN`. Note that this is an [^/N/+1]-ary function call.]] 66 [[Get scale sum swap operation] [`Operations::scale_sum_swap2< Value1 , Value2 >`] [`ScaleSumSwap2`] [Get scale sum swap from operations]] 67 [[`ScaleSumSwap2` constructor] [`ScaleSumSwap2< Value1 , Value2 >( a1 , a2 )`] [`ScaleSumSwap2`] [Constructor]] 68 [[`ScaleSumSwap2` operation] [`scale_sum_swap2( x1 , x2 , x3 )`] [`void`] [Calculates `tmp = x1`, `x1 = a1*x2 + a2*x3` and `x2 = tmp`.]] 69] 70 71[endsect] 72 73[section Algebra] 74 75[heading Notation] 76 77[variablelist 78 [[`State`] [The state type]] 79 [[`Algebra`] [The algebra type]] 80 [[[^Operation['N]]] [An [^/N/]-ary operation type, [^/N/] should be a number from 1 to 14.]] 81 [[`algebra`] [Object of type `Algebra`]] 82 [[[^operation['N]]] [Object of type [^Operation['N]]]] 83 [[`y, x1, x2, ...`] [Objects of type `State`]] 84] 85 86 87[heading Valid Expressions] 88 89[table 90 [[Name] [Expression] [Type] [Semantics]] 91 [[Vector Operation with arity 2] [`algebra.for_each2( y , x , operation2 )`] [void] [Calls `operation2( y_i , x_i )` for each element `y_i` of `y` and `x_i` of `x`.]] 92 [[Vector Operation with arity 3] [`algebra.for_each3( y , x1 , x2 , operation3 )`] [void] [Calls `operation3( y_i , x1_i , x2_i )` for each element `y_i` of `y` and `x1_i` of `x1` and `x2_i` of `x2`.]] 93 [[Vector Operation with arity [^/N/]] [[^algebra.for_each['N]( y , x1 , ... , xN , operation['N] )]] [void] [Calls [^operation['N]( y_i , x1_i , ... , xN_i )] for each element `y_i` of `y` and `x1_i` of `x1` and so on. [^/N/] should be replaced by a number between 1 and 14.]] 94] 95 96[endsect] 97 98[section Pre-Defined implementations] 99 100As standard configuration odeint uses the `range_algebra` and `default_operations` which suffices most situations. 101However, a few more possibilities exist either to gain better performance or to ensure interoperability with other libraries. 102In the following we list the existing `Algebra`/`Operations` configurations that can be used in the steppers. 103 104[table 105 [[`State`] [`Algebra`] [`Operations`] [Remarks]] 106 [[Anything supporting __boost_range, like `std::vector`, `std::list`, `boost::array`,... based on a `value_type` that supports operators +,* (typically `double`)] [`range_algebra`] [`default_operations`] [Standard implementation, applicable for most typical situations.]] 107 [[`boost::array` based on a `value_type` that supports operators +,*] [`array_algebra`] [`default_operations`] [Special implementation for boost::array with better performance than `range_algebra`]] 108 [[Anything that defines operators + within itself and * with scalar (Mathematically spoken, anything that is a vector space).] [`vector_space_algebra`] [`default_operations`] [For the use of __controlled_stepper, the template `vector_space_reduce` has to be instantiated.]] 109 [[`thrust::device_vector`, `thrust::host_vector`] [`thrust_algebra`] [`thrust_operations`] [For running odeint on CUDA devices by using __thrust]] 110 [[Any RandomAccessRange] [`openmp_range_algebra`] [`default_operations`] [OpenMP-parallelised range algebra]] 111 [[`openmp_state`] [`openmp_algebra`] [`default_operations`] [OpenMP-parallelised algebra for split data]] 112 [[`boost::array` or anything which allocates the elements in a C-like manner] [`vector_space_algebra`] [`mkl_operations`] [Using the __intel_mkl in odeint for maximum performance. Currently, only the RK4 stepper is supported.]] 113] 114 115[endsect] 116 117[section Example expressions] 118 119[table 120 [[Name] [Expression] [Type] [Semantics]] 121 [[Vector operation] [`algebra.for_each3( y , x1 , x2 , Operations::scale_sum2< Value1 , Value2 >( a1 , a2 ) )`] [void] [Calculates ['*y* = a1 *x1* + a2 *x2*]]] 122] 123 124[endsect] 125 126[endsect]