diff options
author | Thomas Capricelli <orzel@freehackers.org> | 2009-10-13 01:14:19 +0200 |
---|---|---|
committer | Thomas Capricelli <orzel@freehackers.org> | 2009-10-13 01:14:19 +0200 |
commit | 456f7d094db636b2fc0e6eb0a9fdccc304ddd9ce (patch) | |
tree | ae0fb976d104d406aad5cf472010e48d2807a2c7 /unsupported | |
parent | 977ed615a66a7a9d0f0ee59439b2137f000918c2 (diff) | |
parent | e5bf72679c993e302df95aa2947402482aaded71 (diff) |
merge with eigen-tip
Diffstat (limited to 'unsupported')
-rw-r--r-- | unsupported/CMakeLists.txt | 10 | ||||
-rw-r--r-- | unsupported/Eigen/AdolcForward | 4 | ||||
-rw-r--r-- | unsupported/Eigen/AlignedVector3 | 60 | ||||
-rw-r--r-- | unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h | 2 | ||||
-rw-r--r-- | unsupported/test/autodiff.cpp | 26 |
5 files changed, 52 insertions, 50 deletions
diff --git a/unsupported/CMakeLists.txt b/unsupported/CMakeLists.txt index 895fcdbed..7104085a3 100644 --- a/unsupported/CMakeLists.txt +++ b/unsupported/CMakeLists.txt @@ -1,9 +1,3 @@ - add_subdirectory(Eigen) - -add_subdirectory(doc) - -if(EIGEN_BUILD_TESTS) - add_subdirectory(test) -endif(EIGEN_BUILD_TESTS) - +add_subdirectory(doc EXCLUDE_FROM_ALL) +add_subdirectory(test EXCLUDE_FROM_ALL) diff --git a/unsupported/Eigen/AdolcForward b/unsupported/Eigen/AdolcForward index 9a54a3aaa..70aa47815 100644 --- a/unsupported/Eigen/AdolcForward +++ b/unsupported/Eigen/AdolcForward @@ -29,7 +29,7 @@ // // This file provides support for adolc's adouble type in forward mode. // ADOL-C is a C++ automatic differentiation library, -// see http://www.math.tu-dresden.de/~adol-c/ for more information. +// see https://projects.coin-or.org/ADOL-C for more information. // // Note that the maximal number of directions is controlled by // the preprocessor token NUMBER_DIRECTIONS. The default is 2. @@ -63,7 +63,7 @@ namespace Eigen { * \defgroup AdolcForward_Module Adolc forward module * This module provides support for adolc's adouble type in forward mode. * ADOL-C is a C++ automatic differentiation library, - * see http://www.math.tu-dresden.de/~adol-c/ for more information. + * see https://projects.coin-or.org/ADOL-C for more information. * It mainly consists in: * - a struct Eigen::NumTraits<adtl::adouble> specialization * - overloads of ei_* math function for adtl::adouble type. diff --git a/unsupported/Eigen/AlignedVector3 b/unsupported/Eigen/AlignedVector3 index aaec5f98a..f20fad6d1 100644 --- a/unsupported/Eigen/AlignedVector3 +++ b/unsupported/Eigen/AlignedVector3 @@ -63,37 +63,37 @@ template<typename _Scalar> class AlignedVector3 typedef Matrix<_Scalar,4,1> CoeffType; CoeffType m_coeffs; public: - + EIGEN_GENERIC_PUBLIC_INTERFACE(AlignedVector3) using Base::operator*; - + inline int rows() const { return 3; } inline int cols() const { return 1; } - + inline const Scalar& coeff(int row, int col) const { return m_coeffs.coeff(row, col); } - + inline Scalar& coeffRef(int row, int col) { return m_coeffs.coeffRef(row, col); } - + inline const Scalar& coeff(int index) const { return m_coeffs.coeff(index); } inline Scalar& coeffRef(int index) { return m_coeffs.coeffRef(index);} - - + + inline AlignedVector3(const Scalar& x, const Scalar& y, const Scalar& z) : m_coeffs(x, y, z, Scalar(0)) {} - + inline AlignedVector3(const AlignedVector3& other) - : m_coeffs(other.m_coeffs) + : Base(), m_coeffs(other.m_coeffs) {} - + template<typename XprType, int Size=XprType::SizeAtCompileTime> struct generic_assign_selector {}; - + template<typename XprType> struct generic_assign_selector<XprType,4> { inline static void run(AlignedVector3& dest, const XprType& src) @@ -101,7 +101,7 @@ template<typename _Scalar> class AlignedVector3 dest.m_coeffs = src; } }; - + template<typename XprType> struct generic_assign_selector<XprType,3> { inline static void run(AlignedVector3& dest, const XprType& src) @@ -110,44 +110,44 @@ template<typename _Scalar> class AlignedVector3 dest.m_coeffs.w() = Scalar(0); } }; - + template<typename Derived> inline explicit AlignedVector3(const MatrixBase<Derived>& other) { generic_assign_selector<Derived>::run(*this,other.derived()); } - + inline AlignedVector3& operator=(const AlignedVector3& other) { m_coeffs = other.m_coeffs; return *this; } - - + + inline AlignedVector3 operator+(const AlignedVector3& other) const { return AlignedVector3(m_coeffs + other.m_coeffs); } - + inline AlignedVector3& operator+=(const AlignedVector3& other) { m_coeffs += other.m_coeffs; return *this; } - + inline AlignedVector3 operator-(const AlignedVector3& other) const { return AlignedVector3(m_coeffs - other.m_coeffs); } - + inline AlignedVector3 operator-=(const AlignedVector3& other) { m_coeffs -= other.m_coeffs; return *this; } - + inline AlignedVector3 operator*(const Scalar& s) const { return AlignedVector3(m_coeffs * s); } - + inline friend AlignedVector3 operator*(const Scalar& s,const AlignedVector3& vec) { return AlignedVector3(s * vec.m_coeffs); } - + inline AlignedVector3& operator*=(const Scalar& s) { m_coeffs *= s; return *this; } - + inline AlignedVector3 operator/(const Scalar& s) const { return AlignedVector3(m_coeffs / s); } - + inline AlignedVector3& operator/=(const Scalar& s) { m_coeffs /= s; return *this; } - + inline Scalar dot(const AlignedVector3& other) const { ei_assert(m_coeffs.w()==Scalar(0)); @@ -164,29 +164,29 @@ template<typename _Scalar> class AlignedVector3 { return AlignedVector3(m_coeffs / norm()); } - + inline Scalar sum() const { ei_assert(m_coeffs.w()==Scalar(0)); return m_coeffs.sum(); } - + inline Scalar squaredNorm() const { ei_assert(m_coeffs.w()==Scalar(0)); return m_coeffs.squaredNorm(); } - + inline Scalar norm() const { return ei_sqrt(squaredNorm()); } - + inline AlignedVector3 cross(const AlignedVector3& other) const { return AlignedVector3(m_coeffs.cross3(other.m_coeffs)); } - + template<typename Derived> inline bool isApprox(const MatrixBase<Derived>& other, RealScalar eps=precision<Scalar>()) const { diff --git a/unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h b/unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h index 0feb577df..d42197345 100644 --- a/unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h +++ b/unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h @@ -56,7 +56,7 @@ public: typedef Matrix<ActiveScalar, InputsAtCompileTime, 1> ActiveInput; typedef Matrix<ActiveScalar, ValuesAtCompileTime, 1> ActiveValue; - void operator() (const InputType& x, ValueType* v, JacobianType* _jac) const + void operator() (const InputType& x, ValueType* v, JacobianType* _jac=0) const { ei_assert(v!=0); if (!_jac) diff --git a/unsupported/test/autodiff.cpp b/unsupported/test/autodiff.cpp index 43ef1a308..b1164897c 100644 --- a/unsupported/test/autodiff.cpp +++ b/unsupported/test/autodiff.cpp @@ -111,7 +111,7 @@ struct TestFunc1 } }; -template<typename Func> void adolc_forward_jacobian(const Func& f) +template<typename Func> void forward_jacobian(const Func& f) { typename Func::InputType x = Func::InputType::Random(f.inputs()); typename Func::ValueType y(f.values()), yref(f.values()); @@ -134,21 +134,29 @@ template<typename Func> void adolc_forward_jacobian(const Func& f) VERIFY_IS_APPROX(j, jref); } -void test_autodiff() +void test_autodiff_scalar() { std::cerr << foo<float>(1,2) << "\n"; AutoDiffScalar<Vector2f> ax(1,Vector2f::UnitX()); AutoDiffScalar<Vector2f> ay(2,Vector2f::UnitY()); std::cerr << foo<AutoDiffScalar<Vector2f> >(ax,ay).value() << " <> " << foo<AutoDiffScalar<Vector2f> >(ax,ay).derivatives().transpose() << "\n\n"; +} +void test_autodiff_jacobian() +{ for(int i = 0; i < g_repeat; i++) { - CALL_SUBTEST(( adolc_forward_jacobian(TestFunc1<double,2,2>()) )); - CALL_SUBTEST(( adolc_forward_jacobian(TestFunc1<double,2,3>()) )); - CALL_SUBTEST(( adolc_forward_jacobian(TestFunc1<double,3,2>()) )); - CALL_SUBTEST(( adolc_forward_jacobian(TestFunc1<double,3,3>()) )); - CALL_SUBTEST(( adolc_forward_jacobian(TestFunc1<double>(3,3)) )); + CALL_SUBTEST(( forward_jacobian(TestFunc1<double,2,2>()) )); + CALL_SUBTEST(( forward_jacobian(TestFunc1<double,2,3>()) )); + CALL_SUBTEST(( forward_jacobian(TestFunc1<double,3,2>()) )); + CALL_SUBTEST(( forward_jacobian(TestFunc1<double,3,3>()) )); + CALL_SUBTEST(( forward_jacobian(TestFunc1<double>(3,3)) )); } - -// exit(1); } + +void test_autodiff() +{ + test_autodiff_scalar(); + test_autodiff_jacobian(); +} + |