mirror of
https://github.com/boostorg/odeint.git
synced 2026-01-19 04:22:12 +00:00
Change eigen algebra to support Eigen>=3.3 (#237)
* Change eigen algebra to support Eigen>=3.3 An internal change in Eigen made odeint incompatible with Eigen versions >=3.3. This commit changes odeint in such a way that it does not rely on the changed behvior, so it is now compatible with old and new Eigen. Fixes #194 * Remove obsolete Eigen fail compile test * Remove compile-fail test for C++98 unwrap_reference
This commit is contained in:
@@ -25,42 +25,36 @@
|
||||
// from odeint
|
||||
// (that is, it lets odeint treat the eigen matrices correctly, knowing
|
||||
// how to add, multiply, compute the norm, etc)
|
||||
|
||||
namespace Eigen {
|
||||
|
||||
|
||||
template<typename D>
|
||||
inline const
|
||||
typename Eigen::CwiseUnaryOp<
|
||||
typename Eigen::internal::scalar_add_op<
|
||||
typename Eigen::internal::traits<D>::Scalar>,
|
||||
const D >
|
||||
typename Eigen::CwiseBinaryOp<
|
||||
internal::scalar_sum_op<typename internal::traits<D>::Scalar>,
|
||||
typename DenseBase<D>::ConstantReturnType,
|
||||
const D>
|
||||
operator+(const typename Eigen::MatrixBase<D> &m,
|
||||
const typename Eigen::internal::traits<D>::Scalar &s) {
|
||||
return Eigen::CwiseUnaryOp<
|
||||
typename Eigen::internal::scalar_add_op<
|
||||
typename Eigen::internal::traits<D>::Scalar>,
|
||||
const D >(m.derived(),Eigen::internal::scalar_add_op<
|
||||
typename Eigen::internal::traits<D>::Scalar>(s));
|
||||
return CwiseBinaryOp<
|
||||
internal::scalar_sum_op<typename internal::traits<D>::Scalar>,
|
||||
typename DenseBase<D>::ConstantReturnType,
|
||||
const D>(DenseBase<D>::Constant(m.rows(), m.cols(), s), m.derived());
|
||||
}
|
||||
|
||||
template<typename D>
|
||||
inline const
|
||||
typename Eigen::CwiseUnaryOp<
|
||||
typename Eigen::internal::scalar_add_op<
|
||||
typename Eigen::internal::traits<D>::Scalar>,
|
||||
const D >
|
||||
typename Eigen::CwiseBinaryOp<
|
||||
internal::scalar_sum_op<typename internal::traits<D>::Scalar>,
|
||||
typename DenseBase<D>::ConstantReturnType,
|
||||
const D>
|
||||
operator+(const typename Eigen::internal::traits<D>::Scalar &s,
|
||||
const typename Eigen::MatrixBase<D> &m) {
|
||||
return Eigen::CwiseUnaryOp<
|
||||
typename Eigen::internal::scalar_add_op<
|
||||
typename Eigen::internal::traits<D>::Scalar>,
|
||||
const D >(m.derived(),Eigen::internal::scalar_add_op<
|
||||
typename Eigen::internal::traits<D>::Scalar>(s));
|
||||
const typename Eigen::MatrixBase<D> &m) {
|
||||
return CwiseBinaryOp<
|
||||
internal::scalar_sum_op<typename internal::traits<D>::Scalar>,
|
||||
typename DenseBase<D>::ConstantReturnType,
|
||||
const D>(DenseBase<D>::Constant(m.rows(), m.cols(), s), m.derived());
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename D1,typename D2>
|
||||
inline const
|
||||
typename Eigen::CwiseBinaryOp<
|
||||
@@ -82,14 +76,9 @@ abs( const Eigen::MatrixBase< D > &m ) {
|
||||
return m.cwiseAbs();
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // end Eigen namespace
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
namespace odeint {
|
||||
|
||||
@@ -84,7 +84,6 @@ test-suite "odeint"
|
||||
[ run integrate_overflow.cpp ]
|
||||
[ compile unwrap_boost_reference.cpp ]
|
||||
[ compile unwrap_reference.cpp : <cxxflags>-std=c++0x : unwrap_reference_C++11 ]
|
||||
[ compile-fail unwrap_reference.cpp : <cxxflags>-std=c++98 : unwrap_reference_C++98 ]
|
||||
[ compile std_array.cpp : <cxxflags>-std=c++0x ]
|
||||
:
|
||||
<testing.launcher>valgrind
|
||||
|
||||
@@ -31,6 +31,5 @@ test-suite "odeint"
|
||||
[ run runge_kutta4.cpp ]
|
||||
[ run runge_kutta_dopri5.cpp ]
|
||||
[ run integrate.cpp ]
|
||||
[ compile-fail fail_integrate.cpp ]
|
||||
: <testing.launcher>valgrind
|
||||
;
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
[auto_generated]
|
||||
fail_integrate.cpp
|
||||
|
||||
[begin_description]
|
||||
tba.
|
||||
[end_description]
|
||||
|
||||
Copyright 2009-2012 Karsten Ahnert
|
||||
Copyright 2009-2012 Mario Mulansky
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or
|
||||
copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(disable:4996)
|
||||
#endif
|
||||
|
||||
#define BOOST_TEST_MODULE odeint_dummy
|
||||
|
||||
#include <boost/numeric/odeint/integrate/integrate.hpp>
|
||||
#include <boost/numeric/odeint/external/eigen/eigen.hpp>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include "dummy_odes.hpp"
|
||||
|
||||
using namespace boost::unit_test;
|
||||
using namespace boost::numeric::odeint;
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE( eigen_fail_integrate )
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test )
|
||||
{
|
||||
typedef Eigen::Matrix< double , 1 , 1 > state_type;
|
||||
state_type x;
|
||||
x[0] = 10.0;
|
||||
double t_start = 0.0 , t_end = 1.0 , dt = 0.1;
|
||||
integrate( constant_system_functor_standard() , x , t_start , t_end , dt );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
Reference in New Issue
Block a user