18 #ifndef BUBBLEPROFILER_EIGEN_STATE_UTILS_HPP_INCLUDED 19 #define BUBBLEPROFILER_EIGEN_STATE_UTILS_HPP_INCLUDED 23 #include <boost/version.hpp> 25 #if BOOST_VERSION >= 105600 26 #include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp> 27 #include <boost/numeric/odeint/algebra/vector_space_algebra.hpp> 29 #include <boost/numeric/odeint/algebra/range_algebra.hpp> 30 #include <boost/numeric/odeint/algebra/vector_space_algebra.hpp> 35 template <
typename Derived>
36 typename Eigen::MatrixBase<Derived>::PlainObject
38 const typename Eigen::MatrixBase<Derived>::Scalar& s)
40 return m + s * Eigen::MatrixBase<Derived>::Ones(m.rows(), m.cols());
43 template <
typename Derived>
44 typename Eigen::MatrixBase<Derived>::PlainObject
45 operator+(
const typename Eigen::MatrixBase<Derived>::Scalar& s,
46 const Eigen::MatrixBase<Derived>& m)
48 return m + s * Eigen::MatrixBase<Derived>::Ones(m.rows(), m.cols());
51 template <
typename DerivedA,
typename DerivedB>
52 auto operator/(
const Eigen::MatrixBase<DerivedA>& x1,
53 const Eigen::MatrixBase<DerivedB>& x2)
54 -> decltype(x1.cwiseQuotient(x2))
56 return x1.cwiseQuotient(x2);
59 template <
typename Derived>
60 auto abs(
const Eigen::MatrixBase<Derived>& m)
61 -> decltype(m.cwiseAbs())
68 #if BOOST_VERSION >= 105600 74 template <
typename Scalar,
int Rows,
int Cols,
int Opts,
75 int MaxRows,
int MaxCols>
76 struct vector_space_norm_inf<
77 Eigen::Matrix<Scalar,Rows,Cols,Opts,MaxRows,MaxCols> > {
78 using result_type =
typename Eigen::Matrix<Scalar,Rows,Cols,Opts,
79 MaxRows,MaxCols>::RealScalar;
81 result_type operator()(
const Eigen::Matrix<Scalar,Rows,Cols,
82 Opts,MaxRows,MaxCols>& m)
const {
83 return m.template lpNorm<Eigen::Infinity>();
87 template<
class Derived >
88 struct algebra_dispatcher_sfinae< Derived ,
89 typename boost::enable_if<
90 typename boost::is_base_of<
91 Eigen::MatrixBase< Derived > ,
94 typedef vector_space_algebra algebra_type;
98 template <
class Derived >
99 struct algebra_dispatcher_sfinae< Derived ,
100 typename boost::enable_if<
101 typename boost::is_base_of<
102 Eigen::ArrayBase< Derived > ,
105 typedef vector_space_algebra algebra_type;
114 template <
class State>
115 struct State_algebra_dispatcher {
117 typename boost::numeric::odeint::algebra_dispatcher<State>::algebra_type;
128 template <
class State,
class Enable =
void>
133 template<
class Derived >
135 typename boost::enable_if<
136 typename boost::is_base_of<
137 Eigen::MatrixBase< Derived > ,
144 template <
class Derived >
146 typename boost::enable_if<
147 typename boost::is_base_of<
148 Eigen::ArrayBase< Derived > ,
156 template <
class State>
boost::numeric::odeint::range_algebra algebra_type
Eigen::MatrixBase< Derived >::PlainObject operator+(const Eigen::MatrixBase< Derived > &m, const typename Eigen::MatrixBase< Derived >::Scalar &s)
auto abs(const Eigen::MatrixBase< Derived > &m) -> decltype(m.cwiseAbs())
auto operator/(const Eigen::MatrixBase< DerivedA > &x1, const Eigen::MatrixBase< DerivedB > &x2) -> decltype(x1.cwiseQuotient(x2))
boost::numeric::odeint::vector_space_algebra algebra_type
boost::numeric::odeint::vector_space_algebra algebra_type