]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /* |
2 | [auto_generated] | |
3 | boost/numeric/odeint/external/eigen/eigen_algebra.hpp | |
4 | ||
5 | [begin_description] | |
6 | tba. | |
7 | [end_description] | |
8 | ||
9 | Copyright 2013 Christian Shelton | |
10 | Copyright 2013 Karsten Ahnert | |
11 | ||
12 | Distributed under the Boost Software License, Version 1.0. | |
13 | (See accompanying file LICENSE_1_0.txt or | |
14 | copy at http://www.boost.org/LICENSE_1_0.txt) | |
15 | */ | |
16 | ||
17 | ||
18 | #ifndef BOOST_NUMERIC_ODEINT_EXTERNAL_EIGEN_EIGEN_ALGEBRA_HPP_INCLUDED | |
19 | #define BOOST_NUMERIC_ODEINT_EXTERNAL_EIGEN_EIGEN_ALGEBRA_HPP_INCLUDED | |
20 | ||
21 | #include <Eigen/Dense> | |
22 | #include <boost/numeric/odeint/algebra/vector_space_algebra.hpp> | |
23 | ||
24 | // Necessary routines for Eigen matrices to work with vector_space_algebra | |
25 | // from odeint | |
26 | // (that is, it lets odeint treat the eigen matrices correctly, knowing | |
27 | // how to add, multiply, compute the norm, etc) | |
28 | ||
29 | namespace Eigen { | |
30 | ||
31 | ||
32 | template<typename D> | |
33 | inline const | |
34 | typename Eigen::CwiseUnaryOp< | |
35 | typename Eigen::internal::scalar_add_op< | |
36 | typename Eigen::internal::traits<D>::Scalar>, | |
37 | const D > | |
38 | operator+(const typename Eigen::MatrixBase<D> &m, | |
39 | const typename Eigen::internal::traits<D>::Scalar &s) { | |
40 | return Eigen::CwiseUnaryOp< | |
41 | typename Eigen::internal::scalar_add_op< | |
42 | typename Eigen::internal::traits<D>::Scalar>, | |
43 | const D >(m.derived(),Eigen::internal::scalar_add_op< | |
44 | typename Eigen::internal::traits<D>::Scalar>(s)); | |
45 | } | |
46 | ||
47 | template<typename D> | |
48 | inline const | |
49 | typename Eigen::CwiseUnaryOp< | |
50 | typename Eigen::internal::scalar_add_op< | |
51 | typename Eigen::internal::traits<D>::Scalar>, | |
52 | const D > | |
53 | operator+(const typename Eigen::internal::traits<D>::Scalar &s, | |
54 | const typename Eigen::MatrixBase<D> &m) { | |
55 | return Eigen::CwiseUnaryOp< | |
56 | typename Eigen::internal::scalar_add_op< | |
57 | typename Eigen::internal::traits<D>::Scalar>, | |
58 | const D >(m.derived(),Eigen::internal::scalar_add_op< | |
59 | typename Eigen::internal::traits<D>::Scalar>(s)); | |
60 | } | |
61 | ||
62 | ||
63 | ||
64 | template<typename D1,typename D2> | |
65 | inline const | |
66 | typename Eigen::CwiseBinaryOp< | |
67 | typename Eigen::internal::scalar_quotient_op< | |
68 | typename Eigen::internal::traits<D1>::Scalar>, | |
69 | const D1, const D2> | |
70 | operator/(const Eigen::MatrixBase<D1> &x1, const Eigen::MatrixBase<D2> &x2) { | |
71 | return x1.cwiseQuotient(x2); | |
72 | } | |
73 | ||
74 | ||
75 | template< typename D > | |
76 | inline const | |
77 | typename Eigen::CwiseUnaryOp< | |
78 | typename Eigen::internal::scalar_abs_op< | |
79 | typename Eigen::internal::traits< D >::Scalar > , | |
80 | const D > | |
81 | abs( const Eigen::MatrixBase< D > &m ) { | |
82 | return m.cwiseAbs(); | |
83 | } | |
84 | ||
85 | ||
86 | ||
87 | } // end Eigen namespace | |
88 | ||
89 | ||
90 | ||
91 | ||
92 | ||
93 | namespace boost { | |
94 | namespace numeric { | |
95 | namespace odeint { | |
96 | ||
97 | template<typename B,int S1,int S2,int O, int M1, int M2> | |
98 | struct vector_space_norm_inf< Eigen::Matrix<B,S1,S2,O,M1,M2> > | |
99 | { | |
100 | typedef B result_type; | |
101 | result_type operator()( const Eigen::Matrix<B,S1,S2,O,M1,M2> &m ) const | |
102 | { | |
103 | return m.template lpNorm<Eigen::Infinity>(); | |
104 | } | |
105 | }; | |
106 | ||
107 | } } } // end boost::numeric::odeint namespace | |
108 | ||
109 | #endif // BOOST_NUMERIC_ODEINT_EXTERNAL_EIGEN_EIGEN_ALGEBRA_HPP_INCLUDED |