default_operations.hpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. /*
  2. [auto_generated]
  3. boost/numeric/odeint/algebra/default_operations.hpp
  4. [begin_description]
  5. Default operations. They work with the default numerical types, like float, double, complex< double> ...
  6. [end_description]
  7. Copyright 2010-2012 Karsten Ahnert
  8. Copyright 2010-2013 Mario Mulansky
  9. Distributed under the Boost Software License, Version 1.0.
  10. (See accompanying file LICENSE_1_0.txt or
  11. copy at http://www.boost.org/LICENSE_1_0.txt)
  12. */
  13. #ifndef BOOST_NUMERIC_ODEINT_ALGEBRA_DEFAULT_OPERATIONS_HPP_INCLUDED
  14. #define BOOST_NUMERIC_ODEINT_ALGEBRA_DEFAULT_OPERATIONS_HPP_INCLUDED
  15. #include <algorithm>
  16. #include <boost/config.hpp>
  17. #include <boost/array.hpp>
  18. #include <boost/numeric/odeint/util/unit_helper.hpp>
  19. namespace boost {
  20. namespace numeric {
  21. namespace odeint {
  22. /*
  23. * Notes:
  24. *
  25. * * the results structs are needed in order to work with fusion_algebra
  26. */
  27. struct default_operations
  28. {
  29. template< class Fac1 = double >
  30. struct scale
  31. {
  32. const Fac1 m_alpha1;
  33. scale( Fac1 alpha1 ) : m_alpha1( alpha1 ) { }
  34. template< class T1 >
  35. void operator()( T1 &t1 ) const
  36. {
  37. t1 *= m_alpha1;
  38. }
  39. typedef void result_type;
  40. };
  41. template< class Fac1 = double >
  42. struct scale_sum1
  43. {
  44. const Fac1 m_alpha1;
  45. scale_sum1( Fac1 alpha1 ) : m_alpha1( alpha1 ) { }
  46. template< class T1 , class T2 >
  47. void operator()( T1 &t1 , const T2 &t2 ) const
  48. {
  49. t1 = m_alpha1 * t2;
  50. }
  51. typedef void result_type;
  52. };
  53. template< class Fac1 = double , class Fac2 = Fac1 >
  54. struct scale_sum2
  55. {
  56. const Fac1 m_alpha1;
  57. const Fac2 m_alpha2;
  58. scale_sum2( Fac1 alpha1 , Fac2 alpha2 ) : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) { }
  59. template< class T1 , class T2 , class T3 >
  60. void operator()( T1 &t1 , const T2 &t2 , const T3 &t3) const
  61. {
  62. t1 = m_alpha1 * t2 + m_alpha2 * t3;
  63. }
  64. typedef void result_type;
  65. };
  66. template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 >
  67. struct scale_sum3
  68. {
  69. const Fac1 m_alpha1;
  70. const Fac2 m_alpha2;
  71. const Fac3 m_alpha3;
  72. scale_sum3( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 )
  73. : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) { }
  74. template< class T1 , class T2 , class T3 , class T4 >
  75. void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 ) const
  76. {
  77. t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4;
  78. }
  79. typedef void result_type;
  80. };
  81. template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 >
  82. struct scale_sum4
  83. {
  84. const Fac1 m_alpha1;
  85. const Fac2 m_alpha2;
  86. const Fac3 m_alpha3;
  87. const Fac4 m_alpha4;
  88. scale_sum4( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 )
  89. : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) { }
  90. template< class T1 , class T2 , class T3 , class T4 , class T5 >
  91. void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5) const
  92. {
  93. t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5;
  94. }
  95. typedef void result_type;
  96. };
  97. template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 >
  98. struct scale_sum5
  99. {
  100. const Fac1 m_alpha1;
  101. const Fac2 m_alpha2;
  102. const Fac3 m_alpha3;
  103. const Fac4 m_alpha4;
  104. const Fac5 m_alpha5;
  105. scale_sum5( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 , Fac5 alpha5 )
  106. : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) { }
  107. template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 >
  108. void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6) const
  109. {
  110. t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6;
  111. }
  112. typedef void result_type;
  113. };
  114. template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 >
  115. struct scale_sum6
  116. {
  117. const Fac1 m_alpha1;
  118. const Fac2 m_alpha2;
  119. const Fac3 m_alpha3;
  120. const Fac4 m_alpha4;
  121. const Fac5 m_alpha5;
  122. const Fac6 m_alpha6;
  123. scale_sum6( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 , Fac5 alpha5 , Fac6 alpha6 )
  124. : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ){ }
  125. template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 >
  126. void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 ,const T7 &t7) const
  127. {
  128. t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7;
  129. }
  130. typedef void result_type;
  131. };
  132. template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 >
  133. struct scale_sum7
  134. {
  135. const Fac1 m_alpha1;
  136. const Fac2 m_alpha2;
  137. const Fac3 m_alpha3;
  138. const Fac4 m_alpha4;
  139. const Fac5 m_alpha5;
  140. const Fac6 m_alpha6;
  141. const Fac7 m_alpha7;
  142. scale_sum7( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 ,
  143. Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 )
  144. : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) { }
  145. template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 >
  146. void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 ) const
  147. {
  148. t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8;
  149. }
  150. typedef void result_type;
  151. };
  152. template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 , class Fac8 = Fac7 >
  153. struct scale_sum8
  154. {
  155. const Fac1 m_alpha1;
  156. const Fac2 m_alpha2;
  157. const Fac3 m_alpha3;
  158. const Fac4 m_alpha4;
  159. const Fac5 m_alpha5;
  160. const Fac6 m_alpha6;
  161. const Fac7 m_alpha7;
  162. const Fac8 m_alpha8;
  163. scale_sum8( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 ,
  164. Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 , Fac8 alpha8 )
  165. : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) , m_alpha8( alpha8 ) { }
  166. template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 >
  167. void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 , const T9 &t9 ) const
  168. {
  169. t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8 + m_alpha8 * t9;
  170. }
  171. typedef void result_type;
  172. };
  173. template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 , class Fac8 = Fac7 , class Fac9 = Fac8 >
  174. struct scale_sum9
  175. {
  176. const Fac1 m_alpha1;
  177. const Fac2 m_alpha2;
  178. const Fac3 m_alpha3;
  179. const Fac4 m_alpha4;
  180. const Fac5 m_alpha5;
  181. const Fac6 m_alpha6;
  182. const Fac7 m_alpha7;
  183. const Fac8 m_alpha8;
  184. const Fac9 m_alpha9;
  185. scale_sum9( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 ,
  186. Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 , Fac8 alpha8 , Fac9 alpha9 )
  187. : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) , m_alpha8( alpha8 ) , m_alpha9( alpha9 ) { }
  188. template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 , class T10 >
  189. void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 , const T9 &t9 , const T10 &t10 ) const
  190. {
  191. t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8 + m_alpha8 * t9 + m_alpha9 * t10;
  192. }
  193. typedef void result_type;
  194. };
  195. template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 , class Fac8 = Fac7 , class Fac9 = Fac8 , class Fac10 = Fac9 >
  196. struct scale_sum10
  197. {
  198. const Fac1 m_alpha1;
  199. const Fac2 m_alpha2;
  200. const Fac3 m_alpha3;
  201. const Fac4 m_alpha4;
  202. const Fac5 m_alpha5;
  203. const Fac6 m_alpha6;
  204. const Fac7 m_alpha7;
  205. const Fac8 m_alpha8;
  206. const Fac9 m_alpha9;
  207. const Fac10 m_alpha10;
  208. scale_sum10( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 ,
  209. Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 , Fac8 alpha8 , Fac9 alpha9 , Fac10 alpha10 )
  210. : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) , m_alpha8( alpha8 ) , m_alpha9( alpha9 ) , m_alpha10( alpha10 ) { }
  211. template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 , class T10 , class T11 >
  212. void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 , const T9 &t9 , const T10 &t10 , const T11 &t11 ) const
  213. {
  214. t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8 + m_alpha8 * t9 + m_alpha9 * t10 + m_alpha10 * t11;
  215. }
  216. typedef void result_type;
  217. };
  218. template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 , class Fac8 = Fac7 , class Fac9 = Fac8 , class Fac10 = Fac9 , class Fac11 = Fac10 >
  219. struct scale_sum11
  220. {
  221. const Fac1 m_alpha1;
  222. const Fac2 m_alpha2;
  223. const Fac3 m_alpha3;
  224. const Fac4 m_alpha4;
  225. const Fac5 m_alpha5;
  226. const Fac6 m_alpha6;
  227. const Fac7 m_alpha7;
  228. const Fac8 m_alpha8;
  229. const Fac9 m_alpha9;
  230. const Fac10 m_alpha10;
  231. const Fac11 m_alpha11;
  232. scale_sum11( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 ,
  233. Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 , Fac8 alpha8 , Fac9 alpha9 ,
  234. Fac10 alpha10 , Fac11 alpha11 )
  235. : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) , m_alpha8( alpha8 ) , m_alpha9( alpha9 ) , m_alpha10( alpha10 ) , m_alpha11( alpha11 ) { }
  236. template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 , class T10 , class T11 , class T12 >
  237. void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 , const T9 &t9 , const T10 &t10 , const T11 &t11 , const T12 &t12 ) const
  238. {
  239. t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8 + m_alpha8 * t9 + m_alpha9 * t10 + m_alpha10 * t11 + m_alpha11 * t12;
  240. }
  241. typedef void result_type;
  242. };
  243. template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 , class Fac8 = Fac7 , class Fac9 = Fac8 , class Fac10 = Fac9 , class Fac11 = Fac10 , class Fac12 = Fac11 >
  244. struct scale_sum12
  245. {
  246. const Fac1 m_alpha1;
  247. const Fac2 m_alpha2;
  248. const Fac3 m_alpha3;
  249. const Fac4 m_alpha4;
  250. const Fac5 m_alpha5;
  251. const Fac6 m_alpha6;
  252. const Fac7 m_alpha7;
  253. const Fac8 m_alpha8;
  254. const Fac9 m_alpha9;
  255. const Fac10 m_alpha10;
  256. const Fac11 m_alpha11;
  257. const Fac12 m_alpha12;
  258. scale_sum12( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 ,
  259. Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 , Fac8 alpha8 , Fac9 alpha9 ,
  260. Fac10 alpha10 , Fac11 alpha11 , Fac12 alpha12 )
  261. : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) , m_alpha8( alpha8 ) , m_alpha9( alpha9 ) , m_alpha10( alpha10 ) , m_alpha11( alpha11 ) , m_alpha12( alpha12 ) { }
  262. template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 , class T10 , class T11 , class T12 , class T13 >
  263. void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 , const T9 &t9 , const T10 &t10 , const T11 &t11 , const T12 &t12 , const T13 &t13 ) const
  264. {
  265. t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8 + m_alpha8 * t9 + m_alpha9 * t10 + m_alpha10 * t11 + m_alpha11 * t12 + m_alpha12 * t13;
  266. }
  267. typedef void result_type;
  268. };
  269. template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 , class Fac8 = Fac7 , class Fac9 = Fac8 , class Fac10 = Fac9 , class Fac11 = Fac10 , class Fac12 = Fac11 , class Fac13 = Fac12 >
  270. struct scale_sum13
  271. {
  272. const Fac1 m_alpha1;
  273. const Fac2 m_alpha2;
  274. const Fac3 m_alpha3;
  275. const Fac4 m_alpha4;
  276. const Fac5 m_alpha5;
  277. const Fac6 m_alpha6;
  278. const Fac7 m_alpha7;
  279. const Fac8 m_alpha8;
  280. const Fac9 m_alpha9;
  281. const Fac10 m_alpha10;
  282. const Fac11 m_alpha11;
  283. const Fac12 m_alpha12;
  284. const Fac13 m_alpha13;
  285. scale_sum13( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 ,
  286. Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 , Fac8 alpha8 , Fac9 alpha9 ,
  287. Fac10 alpha10 , Fac11 alpha11 , Fac12 alpha12 , Fac13 alpha13 )
  288. : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) , m_alpha8( alpha8 ) , m_alpha9( alpha9 ) , m_alpha10( alpha10 ) , m_alpha11( alpha11 ) , m_alpha12( alpha12 ) , m_alpha13( alpha13 ) { }
  289. template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 , class T10 , class T11 , class T12 , class T13 , class T14 >
  290. void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 , const T9 &t9 , const T10 &t10 , const T11 &t11 , const T12 &t12 , const T13 &t13 , const T14 &t14 ) const
  291. {
  292. t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8 + m_alpha8 * t9 + m_alpha9 * t10 + m_alpha10 * t11 + m_alpha11 * t12 + m_alpha12 * t13 + m_alpha13 * t14;
  293. }
  294. typedef void result_type;
  295. };
  296. template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 , class Fac8 = Fac7 , class Fac9 = Fac8 , class Fac10 = Fac9 , class Fac11 = Fac10 , class Fac12 = Fac11 , class Fac13 = Fac12 , class Fac14 = Fac13 >
  297. struct scale_sum14
  298. {
  299. const Fac1 m_alpha1;
  300. const Fac2 m_alpha2;
  301. const Fac3 m_alpha3;
  302. const Fac4 m_alpha4;
  303. const Fac5 m_alpha5;
  304. const Fac6 m_alpha6;
  305. const Fac7 m_alpha7;
  306. const Fac8 m_alpha8;
  307. const Fac9 m_alpha9;
  308. const Fac10 m_alpha10;
  309. const Fac11 m_alpha11;
  310. const Fac12 m_alpha12;
  311. const Fac13 m_alpha13;
  312. const Fac14 m_alpha14;
  313. scale_sum14( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 ,
  314. Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 , Fac8 alpha8 , Fac9 alpha9 ,
  315. Fac10 alpha10 , Fac11 alpha11 , Fac12 alpha12 , Fac13 alpha13 , Fac14 alpha14 )
  316. : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) , m_alpha8( alpha8 ) , m_alpha9( alpha9 ) , m_alpha10( alpha10 ) , m_alpha11( alpha11 ) , m_alpha12( alpha12 ) , m_alpha13( alpha13 ) , m_alpha14( alpha14 ) { }
  317. template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 , class T10 , class T11 , class T12 , class T13 , class T14 , class T15 >
  318. void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 , const T9 &t9 , const T10 &t10 , const T11 &t11 , const T12 &t12 , const T13 &t13 , const T14 &t14 , const T15 &t15 ) const
  319. {
  320. t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8 + m_alpha8 * t9 + m_alpha9 * t10 + m_alpha10 * t11 + m_alpha11 * t12 + m_alpha12 * t13 + m_alpha13 * t14 + m_alpha14 * t15;
  321. }
  322. typedef void result_type;
  323. };
  324. template< class Fac1 = double , class Fac2 = Fac1 >
  325. struct scale_sum_swap2
  326. {
  327. const Fac1 m_alpha1;
  328. const Fac2 m_alpha2;
  329. scale_sum_swap2( Fac1 alpha1 , Fac2 alpha2 ) : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) { }
  330. template< class T1 , class T2 , class T3 >
  331. void operator()( T1 &t1 , T2 &t2 , const T3 &t3) const
  332. {
  333. const T1 tmp( t1 );
  334. t1 = m_alpha1 * t2 + m_alpha2 * t3;
  335. t2 = tmp;
  336. }
  337. typedef void result_type;
  338. };
  339. /*
  340. * for usage in for_each2
  341. *
  342. * Works with boost::units by eliminating the unit
  343. */
  344. template< class Fac1 = double >
  345. struct rel_error
  346. {
  347. const Fac1 m_eps_abs , m_eps_rel , m_a_x , m_a_dxdt;
  348. rel_error( Fac1 eps_abs , Fac1 eps_rel , Fac1 a_x , Fac1 a_dxdt )
  349. : m_eps_abs( eps_abs ) , m_eps_rel( eps_rel ) , m_a_x( a_x ) , m_a_dxdt( a_dxdt ) { }
  350. template< class T1 , class T2 , class T3 >
  351. void operator()( T3 &t3 , const T1 &t1 , const T2 &t2 ) const
  352. {
  353. using std::abs;
  354. set_unit_value( t3 , abs( get_unit_value( t3 ) ) / ( m_eps_abs + m_eps_rel * ( m_a_x * abs( get_unit_value( t1 ) ) + m_a_dxdt * abs( get_unit_value( t2 ) ) ) ) );
  355. }
  356. typedef void result_type;
  357. };
  358. /*
  359. * for usage in for_each3
  360. *
  361. * used in the controller for the rosenbrock4 method
  362. *
  363. * Works with boost::units by eliminating the unit
  364. */
  365. template< class Fac1 = double >
  366. struct default_rel_error
  367. {
  368. const Fac1 m_eps_abs , m_eps_rel ;
  369. default_rel_error( Fac1 eps_abs , Fac1 eps_rel )
  370. : m_eps_abs( eps_abs ) , m_eps_rel( eps_rel ) { }
  371. /*
  372. * xerr = xerr / ( eps_abs + eps_rel * max( x , x_old ) )
  373. */
  374. template< class T1 , class T2 , class T3 >
  375. void operator()( T3 &t3 , const T1 &t1 , const T2 &t2 ) const
  376. {
  377. BOOST_USING_STD_MAX();
  378. using std::abs;
  379. Fac1 x1 = abs( get_unit_value( t1 ) ) , x2 = abs( get_unit_value( t2 ) );
  380. set_unit_value( t3 , abs( get_unit_value( t3 ) ) / ( m_eps_abs + m_eps_rel * max BOOST_PREVENT_MACRO_SUBSTITUTION ( x1 , x2 ) ) );
  381. }
  382. typedef void result_type;
  383. };
  384. /*
  385. * for usage in reduce
  386. */
  387. template< class Value >
  388. struct maximum
  389. {
  390. template< class Fac1 , class Fac2 >
  391. Value operator()( Fac1 t1 , const Fac2 t2 ) const
  392. {
  393. using std::abs;
  394. Value a1 = abs( get_unit_value( t1 ) ) , a2 = abs( get_unit_value( t2 ) );
  395. return ( a1 < a2 ) ? a2 : a1 ;
  396. }
  397. typedef Value result_type;
  398. };
  399. template< class Fac1 = double >
  400. struct rel_error_max
  401. {
  402. const Fac1 m_eps_abs , m_eps_rel;
  403. rel_error_max( Fac1 eps_abs , Fac1 eps_rel )
  404. : m_eps_abs( eps_abs ) , m_eps_rel( eps_rel )
  405. { }
  406. template< class Res , class T1 , class T2 , class T3 >
  407. Res operator()( Res r , const T1 &x_old , const T2 &x , const T3 &x_err )
  408. {
  409. BOOST_USING_STD_MAX();
  410. using std::abs;
  411. Res tmp = abs( get_unit_value( x_err ) ) / ( m_eps_abs + m_eps_rel * max BOOST_PREVENT_MACRO_SUBSTITUTION ( abs( x_old ) , abs( x ) ) );
  412. return max BOOST_PREVENT_MACRO_SUBSTITUTION ( r , tmp );
  413. }
  414. };
  415. template< class Fac1 = double >
  416. struct rel_error_max2
  417. {
  418. const Fac1 m_eps_abs , m_eps_rel , m_a_x , m_a_dxdt;
  419. rel_error_max2( Fac1 eps_abs , Fac1 eps_rel , Fac1 a_x , Fac1 a_dxdt )
  420. : m_eps_abs( eps_abs ) , m_eps_rel( eps_rel ) , m_a_x( a_x ) , m_a_dxdt( a_dxdt )
  421. { }
  422. template< class Res , class T1 , class T2 , class T3 , class T4 >
  423. Res operator()( Res r , const T1 &x_old , const T2 &/*x*/ , const T3 &dxdt_old , const T4 &x_err )
  424. {
  425. BOOST_USING_STD_MAX();
  426. using std::abs;
  427. Res tmp = abs( get_unit_value( x_err ) ) /
  428. ( m_eps_abs + m_eps_rel * ( m_a_x * abs( get_unit_value( x_old ) ) + m_a_dxdt * abs( get_unit_value( dxdt_old ) ) ) );
  429. return max BOOST_PREVENT_MACRO_SUBSTITUTION ( r , tmp );
  430. }
  431. };
  432. template< class Fac1 = double >
  433. struct rel_error_l2
  434. {
  435. const Fac1 m_eps_abs , m_eps_rel;
  436. rel_error_l2( Fac1 eps_abs , Fac1 eps_rel )
  437. : m_eps_abs( eps_abs ) , m_eps_rel( eps_rel )
  438. { }
  439. template< class Res , class T1 , class T2 , class T3 >
  440. Res operator()( Res r , const T1 &x_old , const T2 &x , const T3 &x_err )
  441. {
  442. BOOST_USING_STD_MAX();
  443. using std::abs;
  444. Res tmp = abs( get_unit_value( x_err ) ) / ( m_eps_abs + m_eps_rel * max BOOST_PREVENT_MACRO_SUBSTITUTION ( abs( x_old ) , abs( x ) ) );
  445. return r + tmp * tmp;
  446. }
  447. };
  448. template< class Fac1 = double >
  449. struct rel_error_l2_2
  450. {
  451. const Fac1 m_eps_abs , m_eps_rel , m_a_x , m_a_dxdt;
  452. rel_error_l2_2( Fac1 eps_abs , Fac1 eps_rel , Fac1 a_x , Fac1 a_dxdt )
  453. : m_eps_abs( eps_abs ) , m_eps_rel( eps_rel ) , m_a_x( a_x ) , m_a_dxdt( a_dxdt )
  454. { }
  455. template< class Res , class T1 , class T2 , class T3 , class T4 >
  456. Res operator()( Res r , const T1 &x_old , const T2 &/*x*/ , const T3 &dxdt_old , const T4 &x_err )
  457. {
  458. using std::abs;
  459. Res tmp = abs( get_unit_value( x_err ) ) /
  460. ( m_eps_abs + m_eps_rel * ( m_a_x * abs( get_unit_value( x_old ) ) + m_a_dxdt * abs( get_unit_value( dxdt_old ) ) ) );
  461. return r + tmp * tmp;
  462. }
  463. };
  464. };
  465. } // odeint
  466. } // numeric
  467. } // boost
  468. #endif // BOOST_NUMERIC_ODEINT_ALGEBRA_DEFAULT_OPERATIONS_HPP_INCLUDED