diff options
author | Benoit Jacob <jacob.benoit.1@gmail.com> | 2010-10-25 10:15:22 -0400 |
---|---|---|
committer | Benoit Jacob <jacob.benoit.1@gmail.com> | 2010-10-25 10:15:22 -0400 |
commit | 4716040703be1ee906439385d20475dcddad5ce3 (patch) | |
tree | 8efd3cf3007d8360e66f38e2d280127cbb70daa6 /unsupported | |
parent | ca85a1f6c5fc33ac382aa2d7ba2da63d55d3223e (diff) |
bug #86 : use internal:: namespace instead of ei_ prefix
Diffstat (limited to 'unsupported')
61 files changed, 828 insertions, 724 deletions
diff --git a/unsupported/Eigen/AdolcForward b/unsupported/Eigen/AdolcForward index 8f1a00d20..1ecf98794 100644 --- a/unsupported/Eigen/AdolcForward +++ b/unsupported/Eigen/AdolcForward @@ -66,7 +66,7 @@ namespace Eigen { * 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. + * - overloads of internal::* math function for adtl::adouble type. * * Note that the maximal number of directions is controlled by * the preprocessor token NUMBER_DIRECTIONS. The default is 2. @@ -80,21 +80,25 @@ namespace Eigen { } // namespace Eigen // the Adolc's type adouble is defined in the adtl namespace -// therefore, the following ei_* functions *must* be defined +// therefore, the following internal::* functions *must* be defined // in the same namespace namespace adtl { - inline const adouble& ei_conj(const adouble& x) { return x; } - inline const adouble& ei_real(const adouble& x) { return x; } - inline adouble ei_imag(const adouble&) { return 0.; } - inline adouble ei_abs(const adouble& x) { return fabs(x); } - inline adouble ei_abs2(const adouble& x) { return x*x; } - inline adouble ei_sqrt(const adouble& x) { return sqrt(x); } - inline adouble ei_exp(const adouble& x) { return exp(x); } - inline adouble ei_log(const adouble& x) { return log(x); } - inline adouble ei_sin(const adouble& x) { return sin(x); } - inline adouble ei_cos(const adouble& x) { return cos(x); } - inline adouble ei_pow(const adouble& x, adouble y) { return pow(x, y); } + namespace internal { + + inline const adouble& internal::conj(const adouble& x) { return x; } + inline const adouble& internal::real(const adouble& x) { return x; } + inline adouble internal::imag(const adouble&) { return 0.; } + inline adouble internal::abs(const adouble& x) { return fabs(x); } + inline adouble internal::abs2(const adouble& x) { return x*x; } + inline adouble internal::sqrt(const adouble& x) { return sqrt(x); } + inline adouble internal::exp(const adouble& x) { return exp(x); } + inline adouble internal::log(const adouble& x) { return log(x); } + inline adouble internal::sin(const adouble& x) { return sin(x); } + inline adouble internal::cos(const adouble& x) { return cos(x); } + inline adouble internal::pow(const adouble& x, adouble y) { return pow(x, y); } + + } } @@ -140,7 +144,7 @@ public: void operator() (const InputType& x, ValueType* v, JacobianType* _jac) const { - ei_assert(v!=0); + eigen_assert(v!=0); if (!_jac) { Functor::operator()(x, v); diff --git a/unsupported/Eigen/AlignedVector3 b/unsupported/Eigen/AlignedVector3 index 7efe4ac21..804142a00 100644 --- a/unsupported/Eigen/AlignedVector3 +++ b/unsupported/Eigen/AlignedVector3 @@ -52,10 +52,12 @@ namespace Eigen { // TODO specialize Cwise template<typename _Scalar> class AlignedVector3; -template<typename _Scalar> struct ei_traits<AlignedVector3<_Scalar> > - : ei_traits<Matrix<_Scalar,3,1,0,4,1> > +namespace internal { +template<typename _Scalar> struct traits<AlignedVector3<_Scalar> > + : traits<Matrix<_Scalar,3,1,0,4,1> > { }; +} template<typename _Scalar> class AlignedVector3 : public MatrixBase<AlignedVector3<_Scalar> > @@ -151,8 +153,8 @@ template<typename _Scalar> class AlignedVector3 inline Scalar dot(const AlignedVector3& other) const { - ei_assert(m_coeffs.w()==Scalar(0)); - ei_assert(other.m_coeffs.w()==Scalar(0)); + eigen_assert(m_coeffs.w()==Scalar(0)); + eigen_assert(other.m_coeffs.w()==Scalar(0)); return m_coeffs.dot(other.m_coeffs); } @@ -168,19 +170,19 @@ template<typename _Scalar> class AlignedVector3 inline Scalar sum() const { - ei_assert(m_coeffs.w()==Scalar(0)); + eigen_assert(m_coeffs.w()==Scalar(0)); return m_coeffs.sum(); } inline Scalar squaredNorm() const { - ei_assert(m_coeffs.w()==Scalar(0)); + eigen_assert(m_coeffs.w()==Scalar(0)); return m_coeffs.squaredNorm(); } inline Scalar norm() const { - return ei_sqrt(squaredNorm()); + return internal::sqrt(squaredNorm()); } inline AlignedVector3 cross(const AlignedVector3& other) const diff --git a/unsupported/Eigen/FFT b/unsupported/Eigen/FFT index a72198ccf..592898078 100644 --- a/unsupported/Eigen/FFT +++ b/unsupported/Eigen/FFT @@ -88,23 +88,23 @@ # include <fftw3.h> namespace Eigen { # include "src/FFT/ei_fftw_impl.h" - //template <typename T> typedef struct ei_fftw_impl default_fft_impl; this does not work - template <typename T> struct default_fft_impl : public ei_fftw_impl<T> {}; + //template <typename T> typedef struct internal::fftw_impl default_fft_impl; this does not work + template <typename T> struct default_fft_impl : public internal::fftw_impl<T> {}; } #elif defined EIGEN_MKL_DEFAULT // TODO // intel Math Kernel Library: fastest, commercial -- may be incompatible with Eigen in GPL form namespace Eigen { # include "src/FFT/ei_imklfft_impl.h" - template <typename T> struct default_fft_impl : public ei_imklfft_impl {}; + template <typename T> struct default_fft_impl : public internal::imklfft_impl {}; } #else -// ei_kissfft_impl: small, free, reasonably efficient default, derived from kissfft +// internal::kissfft_impl: small, free, reasonably efficient default, derived from kissfft // namespace Eigen { # include "src/FFT/ei_kissfft_impl.h" template <typename T> - struct default_fft_impl : public ei_kissfft_impl<T> {}; + struct default_fft_impl : public internal::kissfft_impl<T> {}; } #endif @@ -115,16 +115,18 @@ namespace Eigen { template<typename T_SrcMat,typename T_FftIfc> struct fft_fwd_proxy; template<typename T_SrcMat,typename T_FftIfc> struct fft_inv_proxy; +namespace internal { template<typename T_SrcMat,typename T_FftIfc> -struct ei_traits< fft_fwd_proxy<T_SrcMat,T_FftIfc> > +struct traits< fft_fwd_proxy<T_SrcMat,T_FftIfc> > { typedef typename T_SrcMat::PlainObject ReturnType; }; template<typename T_SrcMat,typename T_FftIfc> -struct ei_traits< fft_inv_proxy<T_SrcMat,T_FftIfc> > +struct traits< fft_inv_proxy<T_SrcMat,T_FftIfc> > { typedef typename T_SrcMat::PlainObject ReturnType; }; +} template<typename T_SrcMat,typename T_FftIfc> struct fft_fwd_proxy @@ -238,7 +240,7 @@ class FFT EIGEN_STATIC_ASSERT_VECTOR_ONLY(InputDerived) EIGEN_STATIC_ASSERT_VECTOR_ONLY(ComplexDerived) EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(ComplexDerived,InputDerived) // size at compile-time - EIGEN_STATIC_ASSERT((ei_is_same_type<dst_type, Complex>::ret), + EIGEN_STATIC_ASSERT((internal::is_same_type<dst_type, Complex>::ret), YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) EIGEN_STATIC_ASSERT(int(InputDerived::Flags)&int(ComplexDerived::Flags)&DirectAccessBit, THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_WITH_DIRECT_MEMORY_ACCESS_SUCH_AS_MAP_OR_PLAIN_MATRICES) @@ -307,7 +309,7 @@ class FFT EIGEN_STATIC_ASSERT_VECTOR_ONLY(OutputDerived) EIGEN_STATIC_ASSERT_VECTOR_ONLY(ComplexDerived) EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(ComplexDerived,OutputDerived) // size at compile-time - EIGEN_STATIC_ASSERT((ei_is_same_type<src_type, Complex>::ret), + EIGEN_STATIC_ASSERT((internal::is_same_type<src_type, Complex>::ret), YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) EIGEN_STATIC_ASSERT(int(OutputDerived::Flags)&int(ComplexDerived::Flags)&DirectAccessBit, THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_WITH_DIRECT_MEMORY_ACCESS_SUCH_AS_MAP_OR_PLAIN_MATRICES) diff --git a/unsupported/Eigen/MPRealSupport b/unsupported/Eigen/MPRealSupport index abc719ba7..0d60cd99a 100644 --- a/unsupported/Eigen/MPRealSupport +++ b/unsupported/Eigen/MPRealSupport @@ -102,7 +102,9 @@ int main() } }; - template<> mpfr::mpreal ei_random<mpfr::mpreal>() + namespace internal { + + template<> mpfr::mpreal random<mpfr::mpreal>() { #if (MPFR_VERSION >= MPFR_VERSION_NUM(3,0,0)) static gmp_randstate_t state; @@ -117,44 +119,50 @@ int main() return mpfr::urandom(state)*2-1; #else - return mpfr::mpreal(ei_random<double>()); + return mpfr::mpreal(random<double>()); #endif } - template<> mpfr::mpreal ei_random<mpfr::mpreal>(const mpfr::mpreal& a, const mpfr::mpreal& b) + template<> mpfr::mpreal random<mpfr::mpreal>(const mpfr::mpreal& a, const mpfr::mpreal& b) { - return a + (b-a) * ei_random<mpfr::mpreal>(); + return a + (b-a) * random<mpfr::mpreal>(); } + + } // end namespace internal } namespace mpfr { - inline const mpreal& ei_conj(const mpreal& x) { return x; } - inline const mpreal& ei_real(const mpreal& x) { return x; } - inline mpreal ei_imag(const mpreal&) { return 0.0; } - inline mpreal ei_abs(const mpreal& x) { return fabs(x); } - inline mpreal ei_abs2(const mpreal& x) { return x*x; } - inline mpreal ei_sqrt(const mpreal& x) { return sqrt(x); } - inline mpreal ei_exp(const mpreal& x) { return exp(x); } - inline mpreal ei_log(const mpreal& x) { return log(x); } - inline mpreal ei_sin(const mpreal& x) { return sin(x); } - inline mpreal ei_cos(const mpreal& x) { return cos(x); } - inline mpreal ei_pow(const mpreal& x, mpreal& y) { return pow(x, y); } - - bool ei_isMuchSmallerThan(const mpreal& a, const mpreal& b, const mpreal& prec) + namespace internal { + + inline const mpreal& conj(const mpreal& x) { return x; } + inline const mpreal& real(const mpreal& x) { return x; } + inline mpreal imag(const mpreal&) { return 0.0; } + inline mpreal abs(const mpreal& x) { return mpfr::fabs(x); } + inline mpreal abs2(const mpreal& x) { return x*x; } + inline mpreal sqrt(const mpreal& x) { return mpfr::sqrt(x); } + inline mpreal exp(const mpreal& x) { return mpfr::exp(x); } + inline mpreal log(const mpreal& x) { return mpfr::log(x); } + inline mpreal sin(const mpreal& x) { return mpfr::sin(x); } + inline mpreal cos(const mpreal& x) { return mpfr::cos(x); } + inline mpreal pow(const mpreal& x, mpreal& y) { return mpfr::pow(x, y); } + + bool isMuchSmallerThan(const mpreal& a, const mpreal& b, const mpreal& prec) { - return ei_abs(a) <= abs(b) * prec; + return mpfr::abs(a) <= mpfr::abs(b) * prec; } - inline bool ei_isApprox(const mpreal& a, const mpreal& b, const mpreal& prec) + inline bool isApprox(const mpreal& a, const mpreal& b, const mpreal& prec) { - return ei_abs(a - b) <= min(abs(a), abs(b)) * prec; + return mpfr::abs(a - b) <= mpfr::min(mpfr::abs(a), mpfr::abs(b)) * prec; } - inline bool ei_isApproxOrLessThan(const mpreal& a, const mpreal& b, const mpreal& prec) + inline bool isApproxOrLessThan(const mpreal& a, const mpreal& b, const mpreal& prec) { - return a <= b || ei_isApprox(a, b, prec); + return a <= b || isApprox(a, b, prec); } + + } // end namespace internal } #endif // EIGEN_MPREALSUPPORT_MODULE_H diff --git a/unsupported/Eigen/MatrixFunctions b/unsupported/Eigen/MatrixFunctions index e0bc4732c..d39c49e53 100644 --- a/unsupported/Eigen/MatrixFunctions +++ b/unsupported/Eigen/MatrixFunctions @@ -176,7 +176,7 @@ Output: \verbinclude MatrixExponential.out Compute a matrix function. \code -const MatrixFunctionReturnValue<Derived> MatrixBase<Derived>::matrixFunction(typename ei_stem_function<typename ei_traits<Derived>::Scalar>::type f) const +const MatrixFunctionReturnValue<Derived> MatrixBase<Derived>::matrixFunction(typename internal::stem_function<typename internal::traits<Derived>::Scalar>::type f) const \endcode \param[in] M argument of matrix function, should be a square matrix. diff --git a/unsupported/Eigen/OpenGLSupport b/unsupported/Eigen/OpenGLSupport index 51d890a19..b967f0d7a 100644 --- a/unsupported/Eigen/OpenGLSupport +++ b/unsupported/Eigen/OpenGLSupport @@ -63,30 +63,30 @@ template< typename XprType, bool IsGLCompatible = bool(XprType::Flags&LinearAccessBit) \ && bool(XprType::Flags&DirectAccessBit) \ && (XprType::IsVectorAtCompileTime || (XprType::Flags&RowMajorBit)==0)> \ -struct EIGEN_CAT(EIGEN_CAT(ei_gl_,FUNC),_impl); \ +struct EIGEN_CAT(EIGEN_CAT(internal::gl_,FUNC),_impl); \ \ template<typename XprType, typename Scalar, int Rows, int Cols> \ -struct EIGEN_CAT(EIGEN_CAT(ei_gl_,FUNC),_impl)<XprType,Scalar,Rows,Cols,false> { \ +struct EIGEN_CAT(EIGEN_CAT(internal::gl_,FUNC),_impl)<XprType,Scalar,Rows,Cols,false> { \ inline static void run(const XprType& p) { \ - EIGEN_CAT(EIGEN_CAT(ei_gl_,FUNC),_impl)<typename ei_plain_matrix_type_column_major<XprType>::type>::run(p); } \ + EIGEN_CAT(EIGEN_CAT(internal::gl_,FUNC),_impl)<typename internal::plain_matrix_type_column_major<XprType>::type>::run(p); } \ }; \ \ template<typename Derived> inline void FUNC(const Eigen::DenseBase<Derived>& p) { \ - EIGEN_CAT(EIGEN_CAT(ei_gl_,FUNC),_impl)<Derived>::run(p.derived()); \ + EIGEN_CAT(EIGEN_CAT(internal::gl_,FUNC),_impl)<Derived>::run(p.derived()); \ } #define EIGEN_GL_FUNC_SPECIALIZATION_MAT(FUNC,SCALAR,ROWS,COLS,SUFFIX) \ - template< typename XprType> struct EIGEN_CAT(EIGEN_CAT(ei_gl_,FUNC),_impl)<XprType, SCALAR, ROWS, COLS, true> { \ + template< typename XprType> struct EIGEN_CAT(EIGEN_CAT(internal::gl_,FUNC),_impl)<XprType, SCALAR, ROWS, COLS, true> { \ inline static void run(const XprType& p) { FUNC##SUFFIX(p.data()); } \ }; #define EIGEN_GL_FUNC_SPECIALIZATION_VEC(FUNC,SCALAR,SIZE,SUFFIX) \ - template< typename XprType> struct EIGEN_CAT(EIGEN_CAT(ei_gl_,FUNC),_impl)<XprType, SCALAR, SIZE, 1, true> { \ + template< typename XprType> struct EIGEN_CAT(EIGEN_CAT(internal::gl_,FUNC),_impl)<XprType, SCALAR, SIZE, 1, true> { \ inline static void run(const XprType& p) { FUNC##SUFFIX(p.data()); } \ }; \ - template< typename XprType> struct EIGEN_CAT(EIGEN_CAT(ei_gl_,FUNC),_impl)<XprType, SCALAR, 1, SIZE, true> { \ + template< typename XprType> struct EIGEN_CAT(EIGEN_CAT(internal::gl_,FUNC),_impl)<XprType, SCALAR, 1, SIZE, true> { \ inline static void run(const XprType& p) { FUNC##SUFFIX(p.data()); } \ }; @@ -202,6 +202,9 @@ template<typename Derived> void glRotate(const RotationBase<Derived,3>& rot) #define EIGEN_GL_EVAL(X) X #define EIGEN_GL_FUNC1_DECLARATION(FUNC,ARG1,CONST) \ + \ +namespace internal { \ + \ template< typename XprType, \ typename Scalar = typename XprType::Scalar, \ int Rows = XprType::RowsAtCompileTime, \ @@ -209,32 +212,38 @@ template< typename XprType, bool IsGLCompatible = bool(XprType::Flags&LinearAccessBit) \ && bool(XprType::Flags&DirectAccessBit) \ && (XprType::IsVectorAtCompileTime || (XprType::Flags&RowMajorBit)==0)> \ -struct EIGEN_CAT(EIGEN_CAT(ei_gl_,FUNC),_impl); \ +struct EIGEN_CAT(EIGEN_CAT(gl_,FUNC),_impl); \ \ template<typename XprType, typename Scalar, int Rows, int Cols> \ -struct EIGEN_CAT(EIGEN_CAT(ei_gl_,FUNC),_impl)<XprType,Scalar,Rows,Cols,false> { \ +struct EIGEN_CAT(EIGEN_CAT(internal::gl_,FUNC),_impl)<XprType,Scalar,Rows,Cols,false> { \ inline static void run(ARG1 a,EIGEN_GL_EVAL(EIGEN_GL_MAKE_CONST_##CONST) XprType& p) { \ - EIGEN_CAT(EIGEN_CAT(ei_gl_,FUNC),_impl)<typename ei_plain_matrix_type_column_major<XprType>::type>::run(a,p); } \ + EIGEN_CAT(EIGEN_CAT(gl_,FUNC),_impl)<typename internal::plain_matrix_type_column_major<XprType>::type>::run(a,p); } \ }; \ \ +} // end namespace internal \ + \ template<typename Derived> inline void FUNC(ARG1 a,EIGEN_GL_EVAL(EIGEN_GL_MAKE_CONST_##CONST) Eigen::DenseBase<Derived>& p) { \ - EIGEN_CAT(EIGEN_CAT(ei_gl_,FUNC),_impl)<Derived>::run(a,p.derived()); \ + EIGEN_CAT(EIGEN_CAT(internal::gl_,FUNC),_impl)<Derived>::run(a,p.derived()); \ } #define EIGEN_GL_FUNC1_SPECIALIZATION_MAT(FUNC,ARG1,CONST,SCALAR,ROWS,COLS,SUFFIX) \ - template< typename XprType> struct EIGEN_CAT(EIGEN_CAT(ei_gl_,FUNC),_impl)<XprType, SCALAR, ROWS, COLS, true> { \ +namespace internal { \ + template< typename XprType> struct EIGEN_CAT(EIGEN_CAT(gl_,FUNC),_impl)<XprType, SCALAR, ROWS, COLS, true> { \ inline static void run(ARG1 a, EIGEN_GL_EVAL(EIGEN_GL_MAKE_CONST_##CONST) XprType& p) { FUNC##SUFFIX(a,p.data()); } \ - }; + }; \ +} #define EIGEN_GL_FUNC1_SPECIALIZATION_VEC(FUNC,ARG1,CONST,SCALAR,SIZE,SUFFIX) \ - template< typename XprType> struct EIGEN_CAT(EIGEN_CAT(ei_gl_,FUNC),_impl)<XprType, SCALAR, SIZE, 1, true> { \ +namespace internal { \ + template< typename XprType> struct EIGEN_CAT(EIGEN_CAT(gl_,FUNC),_impl)<XprType, SCALAR, SIZE, 1, true> { \ inline static void run(ARG1 a, EIGEN_GL_EVAL(EIGEN_GL_MAKE_CONST_##CONST) XprType& p) { FUNC##SUFFIX(a,p.data()); } \ }; \ - template< typename XprType> struct EIGEN_CAT(EIGEN_CAT(ei_gl_,FUNC),_impl)<XprType, SCALAR, 1, SIZE, true> { \ + template< typename XprType> struct EIGEN_CAT(EIGEN_CAT(gl_,FUNC),_impl)<XprType, SCALAR, 1, SIZE, true> { \ inline static void run(ARG1 a, EIGEN_GL_EVAL(EIGEN_GL_MAKE_CONST_##CONST) XprType& p) { FUNC##SUFFIX(a,p.data()); } \ - }; + }; \ +} EIGEN_GL_FUNC1_DECLARATION (glGet,GLenum,_) EIGEN_GL_FUNC1_SPECIALIZATION_MAT(glGet,GLenum,_,float, 4,4,Floatv) diff --git a/unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h b/unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h index 0c79214bd..4fe168a88 100644 --- a/unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h +++ b/unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h @@ -62,7 +62,7 @@ public: void operator() (const InputType& x, ValueType* v, JacobianType* _jac=0) const { - ei_assert(v!=0); + eigen_assert(v!=0); if (!_jac) { Functor::operator()(x, v); diff --git a/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h b/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h index 9169c0b16..1809d4e93 100644 --- a/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h +++ b/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h @@ -27,18 +27,24 @@ namespace Eigen { +namespace internal { + template<typename A, typename B> -struct ei_make_coherent_impl { +struct make_coherent_impl { static void run(A&, B&) {} }; // resize a to match b is a.size()==0, and conversely. template<typename A, typename B> -void ei_make_coherent(const A& a, const B&b) +void make_coherent(const A& a, const B&b) { - ei_make_coherent_impl<A,B>::run(a.const_cast_derived(), b.const_cast_derived()); + make_coherent_impl<A,B>::run(a.const_cast_derived(), b.const_cast_derived()); } +template<typename _DerType, bool Enable> struct auto_diff_special_op; + +} // end namespace internal + /** \class AutoDiffScalar * \brief A scalar type replacement with automatic differentation capability * @@ -56,8 +62,8 @@ void ei_make_coherent(const A& a, const B&b) * * It supports the following list of global math function: * - std::abs, std::sqrt, std::pow, std::exp, std::log, std::sin, std::cos, - * - ei_abs, ei_sqrt, ei_pow, ei_exp, ei_log, ei_sin, ei_cos, - * - ei_conj, ei_real, ei_imag, ei_abs2. + * - internal::abs, internal::sqrt, internal::pow, internal::exp, internal::log, internal::sin, internal::cos, + * - internal::conj, internal::real, internal::imag, internal::abs2. * * AutoDiffScalar can be used as the scalar type of an Eigen::Matrix object. However, * in that case, the expression template mechanism only occurs at the top Matrix level, @@ -65,21 +71,18 @@ void ei_make_coherent(const A& a, const B&b) * */ -template<typename _DerType, bool Enable> struct ei_auto_diff_special_op; - - template<typename _DerType> class AutoDiffScalar - : public ei_auto_diff_special_op - <_DerType, !ei_is_same_type<typename ei_traits<typename ei_cleantype<_DerType>::type>::Scalar, - typename NumTraits<typename ei_traits<typename ei_cleantype<_DerType>::type>::Scalar>::Real>::ret> + : public internal::auto_diff_special_op + <_DerType, !internal::is_same_type<typename internal::traits<typename internal::cleantype<_DerType>::type>::Scalar, + typename NumTraits<typename internal::traits<typename internal::cleantype<_DerType>::type>::Scalar>::Real>::ret> { public: - typedef ei_auto_diff_special_op - <_DerType, !ei_is_same_type<typename ei_traits<typename ei_cleantype<_DerType>::type>::Scalar, - typename NumTraits<typename ei_traits<typename ei_cleantype<_DerType>::type>::Scalar>::Real>::ret> Base; - typedef typename ei_cleantype<_DerType>::type DerType; - typedef typename ei_traits<DerType>::Scalar Scalar; + typedef internal::auto_diff_special_op + <_DerType, !internal::is_same_type<typename internal::traits<typename internal::cleantype<_DerType>::type>::Scalar, + typename NumTraits<typename internal::traits<typename internal::cleantype<_DerType>::type>::Scalar>::Real>::ret> Base; + typedef typename internal::cleantype<_DerType>::type DerType; + typedef typename internal::traits<DerType>::Scalar Scalar; typedef typename NumTraits<Scalar>::Real Real; using Base::operator+; @@ -175,11 +178,11 @@ class AutoDiffScalar } template<typename OtherDerType> - inline const AutoDiffScalar<CwiseBinaryOp<ei_scalar_sum_op<Scalar>,DerType,typename ei_cleantype<OtherDerType>::type> > + inline const AutoDiffScalar<CwiseBinaryOp<internal::scalar_sum_op<Scalar>,DerType,typename internal::cleantype<OtherDerType>::type> > operator+(const AutoDiffScalar<OtherDerType>& other) const { - ei_make_coherent(m_derivatives, other.derivatives()); - return AutoDiffScalar<CwiseBinaryOp<ei_scalar_sum_op<Scalar>,DerType,typename ei_cleantype<OtherDerType>::type> >( + internal::make_coherent(m_derivatives, other.derivatives()); + return AutoDiffScalar<CwiseBinaryOp<internal::scalar_sum_op<Scalar>,DerType,typename internal::cleantype<OtherDerType>::type> >( m_value + other.value(), m_derivatives + other.derivatives()); } @@ -193,11 +196,11 @@ class AutoDiffScalar } template<typename OtherDerType> - inline const AutoDiffScalar<CwiseBinaryOp<ei_scalar_difference_op<Scalar>, DerType,typename ei_cleantype<OtherDerType>::type> > + inline const AutoDiffScalar<CwiseBinaryOp<internal::scalar_difference_op<Scalar>, DerType,typename internal::cleantype<OtherDerType>::type> > operator-(const AutoDiffScalar<OtherDerType>& other) const { - ei_make_coherent(m_derivatives, other.derivatives()); - return AutoDiffScalar<CwiseBinaryOp<ei_scalar_difference_op<Scalar>, DerType,typename ei_cleantype<OtherDerType>::type> >( + internal::make_coherent(m_derivatives, other.derivatives()); + return AutoDiffScalar<CwiseBinaryOp<internal::scalar_difference_op<Scalar>, DerType,typename internal::cleantype<OtherDerType>::type> >( m_value - other.value(), m_derivatives - other.derivatives()); } @@ -211,105 +214,105 @@ class AutoDiffScalar } template<typename OtherDerType> - inline const AutoDiffScalar<CwiseUnaryOp<ei_scalar_opposite_op<Scalar>, DerType> > + inline const AutoDiffScalar<CwiseUnaryOp<internal::scalar_opposite_op<Scalar>, DerType> > operator-() const { - return AutoDiffScalar<CwiseUnaryOp<ei_scalar_opposite_op<Scalar>, DerType> >( + return AutoDiffScalar<CwiseUnaryOp<internal::scalar_opposite_op<Scalar>, DerType> >( -m_value, -m_derivatives); } - inline const AutoDiffScalar<CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, DerType> > + inline const AutoDiffScalar<CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, DerType> > operator*(const Scalar& other) const { - return AutoDiffScalar<CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, DerType> >( + return AutoDiffScalar<CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, DerType> >( m_value * other, (m_derivatives * other)); } - friend inline const AutoDiffScalar<CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, DerType> > + friend inline const AutoDiffScalar<CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, DerType> > operator*(const Scalar& other, const AutoDiffScalar& a) { - return AutoDiffScalar<CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, DerType> >( + return AutoDiffScalar<CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, DerType> >( a.value() * other, a.derivatives() * other); } -// inline const AutoDiffScalar<typename CwiseUnaryOp<ei_scalar_multiple_op<Real>, DerType>::Type > +// inline const AutoDiffScalar<typename CwiseUnaryOp<internal::scalar_multiple_op<Real>, DerType>::Type > // operator*(const Real& other) const // { -// return AutoDiffScalar<typename CwiseUnaryOp<ei_scalar_multiple_op<Real>, DerType>::Type >( +// return AutoDiffScalar<typename CwiseUnaryOp<internal::scalar_multiple_op<Real>, DerType>::Type >( // m_value * other, // (m_derivatives * other)); // } // -// friend inline const AutoDiffScalar<typename CwiseUnaryOp<ei_scalar_multiple_op<Real>, DerType>::Type > +// friend inline const AutoDiffScalar<typename CwiseUnaryOp<internal::scalar_multiple_op<Real>, DerType>::Type > // operator*(const Real& other, const AutoDiffScalar& a) // { -// return AutoDiffScalar<typename CwiseUnaryOp<ei_scalar_multiple_op<Real>, DerType>::Type >( +// return AutoDiffScalar<typename CwiseUnaryOp<internal::scalar_multiple_op<Real>, DerType>::Type >( // a.value() * other, // a.derivatives() * other); // } - inline const AutoDiffScalar<CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, DerType> > + inline const AutoDiffScalar<CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, DerType> > operator/(const Scalar& other) const { - return AutoDiffScalar<CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, DerType> >( + return AutoDiffScalar<CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, DerType> >( m_value / other, (m_derivatives * (Scalar(1)/other))); } - friend inline const AutoDiffScalar<CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, DerType> > + friend inline const AutoDiffScalar<CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, DerType> > operator/(const Scalar& other, const AutoDiffScalar& a) { - return AutoDiffScalar<CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, DerType> >( + return AutoDiffScalar<CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, DerType> >( other / a.value(), a.derivatives() * (-Scalar(1)/other)); } -// inline const AutoDiffScalar<typename CwiseUnaryOp<ei_scalar_multiple_op<Real>, DerType>::Type > +// inline const AutoDiffScalar<typename CwiseUnaryOp<internal::scalar_multiple_op<Real>, DerType>::Type > // operator/(const Real& other) const // { -// return AutoDiffScalar<typename CwiseUnaryOp<ei_scalar_multiple_op<Real>, DerType>::Type >( +// return AutoDiffScalar<typename CwiseUnaryOp<internal::scalar_multiple_op<Real>, DerType>::Type >( // m_value / other, // (m_derivatives * (Real(1)/other))); // } // -// friend inline const AutoDiffScalar<typename CwiseUnaryOp<ei_scalar_multiple_op<Real>, DerType>::Type > +// friend inline const AutoDiffScalar<typename CwiseUnaryOp<internal::scalar_multiple_op<Real>, DerType>::Type > // operator/(const Real& other, const AutoDiffScalar& a) // { -// return AutoDiffScalar<typename CwiseUnaryOp<ei_scalar_multiple_op<Real>, DerType>::Type >( +// return AutoDiffScalar<typename CwiseUnaryOp<internal::scalar_multiple_op<Real>, DerType>::Type >( // other / a.value(), // a.derivatives() * (-Real(1)/other)); // } template<typename OtherDerType> - inline const AutoDiffScalar<CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, - CwiseBinaryOp<ei_scalar_difference_op<Scalar>, - CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, DerType>, - CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, typename ei_cleantype<OtherDerType>::type > > > > + inline const AutoDiffScalar<CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, + CwiseBinaryOp<internal::scalar_difference_op<Scalar>, + CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, DerType>, + CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, typename internal::cleantype<OtherDerType>::type > > > > operator/(const AutoDiffScalar<OtherDerType>& other) const { - ei_make_coherent(m_derivatives, other.derivatives()); - return AutoDiffScalar<CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, - CwiseBinaryOp<ei_scalar_difference_op<Scalar>, - CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, DerType>, - CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, typename ei_cleantype<OtherDerType>::type > > > >( + internal::make_coherent(m_derivatives, other.derivatives()); + return AutoDiffScalar<CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, + CwiseBinaryOp<internal::scalar_difference_op<Scalar>, + CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, DerType>, + CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, typename internal::cleantype<OtherDerType>::type > > > >( m_value / other.value(), ((m_derivatives * other.value()) - (m_value * other.derivatives())) * (Scalar(1)/(other.value()*other.value()))); } template<typename OtherDerType> - inline const AutoDiffScalar<CwiseBinaryOp<ei_scalar_sum_op<Scalar>, - CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, DerType>, - CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, typename ei_cleantype<OtherDerType>::type> > > + inline const AutoDiffScalar<CwiseBinaryOp<internal::scalar_sum_op<Scalar>, + CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, DerType>, + CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, typename internal::cleantype<OtherDerType>::type> > > operator*(const AutoDiffScalar<OtherDerType>& other) const { - ei_make_coherent(m_derivatives, other.derivatives()); - return AutoDiffScalar<CwiseBinaryOp<ei_scalar_sum_op<Scalar>, - CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, DerType>, - CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, typename ei_cleantype<OtherDerType>::type > > >( + internal::make_coherent(m_derivatives, other.derivatives()); + return AutoDiffScalar<CwiseBinaryOp<internal::scalar_sum_op<Scalar>, + CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, DerType>, + CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, typename internal::cleantype<OtherDerType>::type > > >( m_value * other.value(), (m_derivatives * other.value()) + (m_value * other.derivatives())); } @@ -333,18 +336,19 @@ class AutoDiffScalar }; +namespace internal { template<typename _DerType> -struct ei_auto_diff_special_op<_DerType, true> -// : ei_auto_diff_scalar_op<_DerType, typename NumTraits<Scalar>::Real, -// ei_is_same_type<Scalar,typename NumTraits<Scalar>::Real>::ret> +struct auto_diff_special_op<_DerType, true> +// : auto_diff_scalar_op<_DerType, typename NumTraits<Scalar>::Real, +// is_same_type<Scalar,typename NumTraits<Scalar>::Real>::ret> { - typedef typename ei_cleantype<_DerType>::type DerType; - typedef typename ei_traits<DerType>::Scalar Scalar; + typedef typename cleantype<_DerType>::type DerType; + typedef typename traits<DerType>::Scalar Scalar; typedef typename NumTraits<Scalar>::Real Real; -// typedef ei_auto_diff_scalar_op<_DerType, typename NumTraits<Scalar>::Real, -// ei_is_same_type<Scalar,typename NumTraits<Scalar>::Real>::ret> Base; +// typedef auto_diff_scalar_op<_DerType, typename NumTraits<Scalar>::Real, +// is_same_type<Scalar,typename NumTraits<Scalar>::Real>::ret> Base; // using Base::operator+; // using Base::operator+=; @@ -374,18 +378,18 @@ struct ei_auto_diff_special_op<_DerType, true> } - inline const AutoDiffScalar<typename CwiseUnaryOp<ei_scalar_multiple2_op<Scalar,Real>, DerType>::Type > + inline const AutoDiffScalar<typename CwiseUnaryOp<scalar_multiple2_op<Scalar,Real>, DerType>::Type > operator*(const Real& other) const { - return AutoDiffScalar<typename CwiseUnaryOp<ei_scalar_multiple2_op<Scalar,Real>, DerType>::Type >( + return AutoDiffScalar<typename CwiseUnaryOp<scalar_multiple2_op<Scalar,Real>, DerType>::Type >( derived().value() * other, derived().derivatives() * other); } - friend inline const AutoDiffScalar<typename CwiseUnaryOp<ei_scalar_multiple2_op<Scalar,Real>, DerType>::Type > + friend inline const AutoDiffScalar<typename CwiseUnaryOp<scalar_multiple2_op<Scalar,Real>, DerType>::Type > operator*(const Real& other, const AutoDiffScalar<_DerType>& a) { - return AutoDiffScalar<typename CwiseUnaryOp<ei_scalar_multiple2_op<Scalar,Real>, DerType>::Type >( + return AutoDiffScalar<typename CwiseUnaryOp<scalar_multiple2_op<Scalar,Real>, DerType>::Type >( a.value() * other, a.derivatives() * other); } @@ -398,7 +402,7 @@ struct ei_auto_diff_special_op<_DerType, true> }; template<typename _DerType> -struct ei_auto_diff_special_op<_DerType, false> +struct auto_diff_special_op<_DerType, false> { void operator*() const; void operator-() const; @@ -406,7 +410,7 @@ struct ei_auto_diff_special_op<_DerType, false> }; template<typename A_Scalar, int A_Rows, int A_Cols, int A_Options, int A_MaxRows, int A_MaxCols, typename B> -struct ei_make_coherent_impl<Matrix<A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRows, A_MaxCols>, B> { +struct make_coherent_impl<Matrix<A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRows, A_MaxCols>, B> { typedef Matrix<A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRows, A_MaxCols> A; static void run(A& a, B& b) { if((A_Rows==Dynamic || A_Cols==Dynamic) && (a.size()==0)) @@ -418,7 +422,7 @@ struct ei_make_coherent_impl<Matrix<A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRo }; template<typename A, typename B_Scalar, int B_Rows, int B_Cols, int B_Options, int B_MaxRows, int B_MaxCols> -struct ei_make_coherent_impl<A, Matrix<B_Scalar, B_Rows, B_Cols, B_Options, B_MaxRows, B_MaxCols> > { +struct make_coherent_impl<A, Matrix<B_Scalar, B_Rows, B_Cols, B_Options, B_MaxRows, B_MaxCols> > { typedef Matrix<B_Scalar, B_Rows, B_Cols, B_Options, B_MaxRows, B_MaxCols> B; static void run(A& a, B& b) { if((B_Rows==Dynamic || B_Cols==Dynamic) && (b.size()==0)) @@ -431,7 +435,7 @@ struct ei_make_coherent_impl<A, Matrix<B_Scalar, B_Rows, B_Cols, B_Options, B_Ma template<typename A_Scalar, int A_Rows, int A_Cols, int A_Options, int A_MaxRows, int A_MaxCols, typename B_Scalar, int B_Rows, int B_Cols, int B_Options, int B_MaxRows, int B_MaxCols> -struct ei_make_coherent_impl<Matrix<A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRows, A_MaxCols>, +struct make_coherent_impl<Matrix<A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRows, A_MaxCols>, Matrix<B_Scalar, B_Rows, B_Cols, B_Options, B_MaxRows, B_MaxCols> > { typedef Matrix<A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRows, A_MaxCols> A; typedef Matrix<B_Scalar, B_Rows, B_Cols, B_Options, B_MaxRows, B_MaxCols> B; @@ -449,31 +453,33 @@ struct ei_make_coherent_impl<Matrix<A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRo } }; -template<typename A_Scalar, int A_Rows, int A_Cols, int A_Options, int A_MaxRows, int A_MaxCols> struct ei_scalar_product_traits<Matrix<A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRows, A_MaxCols>,A_Scalar> +template<typename A_Scalar, int A_Rows, int A_Cols, int A_Options, int A_MaxRows, int A_MaxCols> struct scalar_product_traits<Matrix<A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRows, A_MaxCols>,A_Scalar> { typedef Matrix<A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRows, A_MaxCols> ReturnType; }; -template<typename A_Scalar, int A_Rows, int A_Cols, int A_Options, int A_MaxRows, int A_MaxCols> struct ei_scalar_product_traits<A_Scalar, Matrix<A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRows, A_MaxCols> > +template<typename A_Scalar, int A_Rows, int A_Cols, int A_Options, int A_MaxRows, int A_MaxCols> struct scalar_product_traits<A_Scalar, Matrix<A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRows, A_MaxCols> > { typedef Matrix<A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRows, A_MaxCols> ReturnType; }; template<typename DerType, typename T> -struct ei_scalar_product_traits<AutoDiffScalar<DerType>,T> +struct scalar_product_traits<AutoDiffScalar<DerType>,T> { typedef AutoDiffScalar<DerType> ReturnType; }; -} +} // end namespace internal + +} // end namespace Eigen #define EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(FUNC,CODE) \ template<typename DerType> \ - inline const Eigen::AutoDiffScalar<Eigen::CwiseUnaryOp<Eigen::ei_scalar_multiple_op<typename Eigen::ei_traits<typename Eigen::ei_cleantype<DerType>::type>::Scalar>, typename Eigen::ei_cleantype<DerType>::type> > \ + inline const Eigen::AutoDiffScalar<Eigen::CwiseUnaryOp<Eigen::internal::scalar_multiple_op<typename Eigen::internal::traits<typename Eigen::internal::cleantype<DerType>::type>::Scalar>, typename Eigen::internal::cleantype<DerType>::type> > \ FUNC(const Eigen::AutoDiffScalar<DerType>& x) { \ using namespace Eigen; \ - typedef typename ei_traits<typename ei_cleantype<DerType>::type>::Scalar Scalar; \ - typedef AutoDiffScalar<CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, typename ei_cleantype<DerType>::type> > ReturnType; \ + typedef typename internal::traits<typename internal::cleantype<DerType>::type>::Scalar Scalar; \ + typedef AutoDiffScalar<CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, typename internal::cleantype<DerType>::type> > ReturnType; \ CODE; \ } @@ -500,12 +506,12 @@ namespace std return ReturnType(std::log(x.value()),x.derivatives() * (Scalar(1)/x.value()));) template<typename DerType> - inline const Eigen::AutoDiffScalar<Eigen::CwiseUnaryOp<Eigen::ei_scalar_multiple_op<typename Eigen::ei_traits<DerType>::Scalar>, DerType> > - pow(const Eigen::AutoDiffScalar<DerType>& x, typename Eigen::ei_traits<DerType>::Scalar y) + inline const Eigen::AutoDiffScalar<Eigen::CwiseUnaryOp<Eigen::internal::scalar_multiple_op<typename Eigen::internal::traits<DerType>::Scalar>, DerType> > + pow(const Eigen::AutoDiffScalar<DerType>& x, typename Eigen::internal::traits<DerType>::Scalar y) { using namespace Eigen; - typedef typename ei_traits<DerType>::Scalar Scalar; - return AutoDiffScalar<CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, DerType> >( + typedef typename internal::traits<DerType>::Scalar Scalar; + return AutoDiffScalar<CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, DerType> >( std::pow(x.value(),y), x.derivatives() * (y * std::pow(x.value(),y-1))); } @@ -514,41 +520,45 @@ namespace std namespace Eigen { +namespace internal { + template<typename DerType> -inline const AutoDiffScalar<DerType>& ei_conj(const AutoDiffScalar<DerType>& x) { return x; } +inline const AutoDiffScalar<DerType>& conj(const AutoDiffScalar<DerType>& x) { return x; } template<typename DerType> -inline const AutoDiffScalar<DerType>& ei_real(const AutoDiffScalar<DerType>& x) { return x; } +inline const AutoDiffScalar<DerType>& real(const AutoDiffScalar<DerType>& x) { return x; } template<typename DerType> -inline typename DerType::Scalar ei_imag(const AutoDiffScalar<DerType>&) { return 0.; } +inline typename DerType::Scalar imag(const AutoDiffScalar<DerType>&) { return 0.; } -EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(ei_abs, - return ReturnType(ei_abs(x.value()), x.derivatives() * (sign(x.value())));) +EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(abs, + return ReturnType(abs(x.value()), x.derivatives() * (sign(x.value())));) -EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(ei_abs2, - return ReturnType(ei_abs2(x.value()), x.derivatives() * (Scalar(2)*x.value()));) +EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(abs2, + return ReturnType(abs2(x.value()), x.derivatives() * (Scalar(2)*x.value()));) -EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(ei_sqrt, - Scalar sqrtx = ei_sqrt(x.value()); +EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(sqrt, + Scalar sqrtx = sqrt(x.value()); return ReturnType(sqrtx,x.derivatives() * (Scalar(0.5) / sqrtx));) -EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(ei_cos, - return ReturnType(ei_cos(x.value()), x.derivatives() * (-ei_sin(x.value())));) +EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(cos, + return ReturnType(cos(x.value()), x.derivatives() * (-sin(x.value())));) -EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(ei_sin, - return ReturnType(ei_sin(x.value()),x.derivatives() * ei_cos(x.value()));) +EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(sin, + return ReturnType(sin(x.value()),x.derivatives() * cos(x.value()));) -EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(ei_exp, - Scalar expx = ei_exp(x.value()); +EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(exp, + Scalar expx = exp(x.value()); return ReturnType(expx,x.derivatives() * expx);) -EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(ei_log, - return ReturnType(ei_log(x.value()),x.derivatives() * (Scalar(1)/x.value()));) +EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(log, + return ReturnType(log(x.value()),x.derivatives() * (Scalar(1)/x.value()));) template<typename DerType> -inline const AutoDiffScalar<CwiseUnaryOp<ei_scalar_multiple_op<typename ei_traits<DerType>::Scalar>, DerType> > -ei_pow(const AutoDiffScalar<DerType>& x, typename ei_traits<DerType>::Scalar y) +inline const AutoDiffScalar<CwiseUnaryOp<scalar_multiple_op<typename traits<DerType>::Scalar>, DerType> > +pow(const AutoDiffScalar<DerType>& x, typename traits<DerType>::Scalar y) { return std::pow(x,y);} +} // end namespace internal + #undef EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY template<typename DerType> struct NumTraits<AutoDiffScalar<DerType> > diff --git a/unsupported/Eigen/src/AutoDiff/AutoDiffVector.h b/unsupported/Eigen/src/AutoDiff/AutoDiffVector.h index a160a216e..a8f041f6f 100644 --- a/unsupported/Eigen/src/AutoDiff/AutoDiffVector.h +++ b/unsupported/Eigen/src/AutoDiff/AutoDiffVector.h @@ -36,8 +36,8 @@ namespace Eigen { * * It supports the following list of global math function: * - std::abs, std::sqrt, std::pow, std::exp, std::log, std::sin, std::cos, - * - ei_abs, ei_sqrt, ei_pow, ei_exp, ei_log, ei_sin, ei_cos, - * - ei_conj, ei_real, ei_imag, ei_abs2. + * - internal::abs, internal::sqrt, internal::pow, internal::exp, internal::log, internal::sin, internal::cos, + * - internal::conj, internal::real, internal::imag, internal::abs2. * * AutoDiffScalar can be used as the scalar type of an Eigen::Matrix object. However, * in that case, the expression template mechanism only occurs at the top Matrix level, @@ -48,8 +48,8 @@ template<typename ValueType, typename JacobianType> class AutoDiffVector { public: - //typedef typename ei_traits<ValueType>::Scalar Scalar; - typedef typename ei_traits<ValueType>::Scalar BaseScalar; + //typedef typename internal::traits<ValueType>::Scalar Scalar; + typedef typename internal::traits<ValueType>::Scalar BaseScalar; typedef AutoDiffScalar<Matrix<BaseScalar,JacobianType::RowsAtCompileTime,1> > ActiveScalar; typedef ActiveScalar Scalar; typedef AutoDiffScalar<typename JacobianType::ColXpr> CoeffType; @@ -115,13 +115,13 @@ class AutoDiffVector template<typename OtherValueType,typename OtherJacobianType> inline const AutoDiffVector< - typename MakeCwiseBinaryOp<ei_scalar_sum_op<BaseScalar>,ValueType,OtherValueType>::Type, - typename MakeCwiseBinaryOp<ei_scalar_sum_op<BaseScalar>,JacobianType,OtherJacobianType>::Type > + typename MakeCwiseBinaryOp<internal::scalar_sum_op<BaseScalar>,ValueType,OtherValueType>::Type, + typename MakeCwiseBinaryOp<internal::scalar_sum_op<BaseScalar>,JacobianType,OtherJacobianType>::Type > operator+(const AutoDiffVector<OtherValueType,OtherJacobianType>& other) const { return AutoDiffVector< - typename MakeCwiseBinaryOp<ei_scalar_sum_op<BaseScalar>,ValueType,OtherValueType>::Type, - typename MakeCwiseBinaryOp<ei_scalar_sum_op<BaseScalar>,JacobianType,OtherJacobianType>::Type >( + typename MakeCwiseBinaryOp<internal::scalar_sum_op<BaseScalar>,ValueType,OtherValueType>::Type, + typename MakeCwiseBinaryOp<internal::scalar_sum_op<BaseScalar>,JacobianType,OtherJacobianType>::Type >( m_values + other.values(), m_jacobian + other.jacobian()); } @@ -137,13 +137,13 @@ class AutoDiffVector template<typename OtherValueType,typename OtherJacobianType> inline const AutoDiffVector< - typename MakeCwiseBinaryOp<ei_scalar_difference_op<Scalar>,ValueType,OtherValueType>::Type, - typename MakeCwiseBinaryOp<ei_scalar_difference_op<Scalar>,JacobianType,OtherJacobianType>::Type > + typename MakeCwiseBinaryOp<internal::scalar_difference_op<Scalar>,ValueType,OtherValueType>::Type, + typename MakeCwiseBinaryOp<internal::scalar_difference_op<Scalar>,JacobianType,OtherJacobianType>::Type > operator-(const AutoDiffVector<OtherValueType,OtherJacobianType>& other) const { return AutoDiffVector< - typename MakeCwiseBinaryOp<ei_scalar_difference_op<Scalar>,ValueType,OtherValueType>::Type, - typename MakeCwiseBinaryOp<ei_scalar_difference_op<Scalar>,JacobianType,OtherJacobianType>::Type >( + typename MakeCwiseBinaryOp<internal::scalar_difference_op<Scalar>,ValueType,OtherValueType>::Type, + typename MakeCwiseBinaryOp<internal::scalar_difference_op<Scalar>,JacobianType,OtherJacobianType>::Type >( m_values - other.values(), m_jacobian - other.jacobian()); } @@ -158,54 +158,54 @@ class AutoDiffVector } inline const AutoDiffVector< - typename MakeCwiseUnaryOp<ei_scalar_opposite_op<Scalar>, ValueType>::Type, - typename MakeCwiseUnaryOp<ei_scalar_opposite_op<Scalar>, JacobianType>::Type > + typename MakeCwiseUnaryOp<internal::scalar_opposite_op<Scalar>, ValueType>::Type, + typename MakeCwiseUnaryOp<internal::scalar_opposite_op<Scalar>, JacobianType>::Type > operator-() const { return AutoDiffVector< - typename MakeCwiseUnaryOp<ei_scalar_opposite_op<Scalar>, ValueType>::Type, - typename MakeCwiseUnaryOp<ei_scalar_opposite_op<Scalar>, JacobianType>::Type >( + typename MakeCwiseUnaryOp<internal::scalar_opposite_op<Scalar>, ValueType>::Type, + typename MakeCwiseUnaryOp<internal::scalar_opposite_op<Scalar>, JacobianType>::Type >( -m_values, -m_jacobian); } inline const AutoDiffVector< - typename MakeCwiseUnaryOp<ei_scalar_multiple_op<Scalar>, ValueType>::Type, - typename MakeCwiseUnaryOp<ei_scalar_multiple_op<Scalar>, JacobianType>::Type> + typename MakeCwiseUnaryOp<internal::scalar_multiple_op<Scalar>, ValueType>::Type, + typename MakeCwiseUnaryOp<internal::scalar_multiple_op<Scalar>, JacobianType>::Type> operator*(const BaseScalar& other) const { return AutoDiffVector< - typename MakeCwiseUnaryOp<ei_scalar_multiple_op<Scalar>, ValueType>::Type, - typename MakeCwiseUnaryOp<ei_scalar_multiple_op<Scalar>, JacobianType>::Type >( + typename MakeCwiseUnaryOp<internal::scalar_multiple_op<Scalar>, ValueType>::Type, + typename MakeCwiseUnaryOp<internal::scalar_multiple_op<Scalar>, JacobianType>::Type >( m_values * other, m_jacobian * other); } friend inline const AutoDiffVector< - typename MakeCwiseUnaryOp<ei_scalar_multiple_op<Scalar>, ValueType>::Type, - typename MakeCwiseUnaryOp<ei_scalar_multiple_op<Scalar>, JacobianType>::Type > + typename MakeCwiseUnaryOp<internal::scalar_multiple_op<Scalar>, ValueType>::Type, + typename MakeCwiseUnaryOp<internal::scalar_multiple_op<Scalar>, JacobianType>::Type > operator*(const Scalar& other, const AutoDiffVector& v) { return AutoDiffVector< - typename MakeCwiseUnaryOp<ei_scalar_multiple_op<Scalar>, ValueType>::Type, - typename MakeCwiseUnaryOp<ei_scalar_multiple_op<Scalar>, JacobianType>::Type >( + typename MakeCwiseUnaryOp<internal::scalar_multiple_op<Scalar>, ValueType>::Type, + typename MakeCwiseUnaryOp<internal::scalar_multiple_op<Scalar>, JacobianType>::Type >( v.values() * other, v.jacobian() * other); } // template<typename OtherValueType,typename OtherJacobianType> // inline const AutoDiffVector< -// CwiseBinaryOp<ei_scalar_multiple_op<Scalar>, ValueType, OtherValueType> -// CwiseBinaryOp<ei_scalar_sum_op<Scalar>, -// CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, JacobianType>, -// CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, OtherJacobianType> > > +// CwiseBinaryOp<internal::scalar_multiple_op<Scalar>, ValueType, OtherValueType> +// CwiseBinaryOp<internal::scalar_sum_op<Scalar>, +// CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, JacobianType>, +// CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, OtherJacobianType> > > // operator*(const AutoDiffVector<OtherValueType,OtherJacobianType>& other) const // { // return AutoDiffVector< -// CwiseBinaryOp<ei_scalar_multiple_op<Scalar>, ValueType, OtherValueType> -// CwiseBinaryOp<ei_scalar_sum_op<Scalar>, -// CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, JacobianType>, -// CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, OtherJacobianType> > >( +// CwiseBinaryOp<internal::scalar_multiple_op<Scalar>, ValueType, OtherValueType> +// CwiseBinaryOp<internal::scalar_sum_op<Scalar>, +// CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, JacobianType>, +// CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, OtherJacobianType> > >( // m_values.cwise() * other.values(), // (m_jacobian * other.values()) + (m_values * other.jacobian())); // } diff --git a/unsupported/Eigen/src/BVH/BVAlgorithms.h b/unsupported/Eigen/src/BVH/BVAlgorithms.h index 40320291d..2412680e7 100644 --- a/unsupported/Eigen/src/BVH/BVAlgorithms.h +++ b/unsupported/Eigen/src/BVH/BVAlgorithms.h @@ -25,21 +25,11 @@ #ifndef EIGEN_BVALGORITHMS_H #define EIGEN_BVALGORITHMS_H -/** Given a BVH, runs the query encapsulated by \a intersector. - * The Intersector type must provide the following members: \code - bool intersectVolume(const BVH::Volume &volume) //returns true if volume intersects the query - bool intersectObject(const BVH::Object &object) //returns true if the search should terminate immediately - \endcode - */ -template<typename BVH, typename Intersector> -void BVIntersect(const BVH &tree, Intersector &intersector) -{ - ei_intersect_helper(tree, intersector, tree.getRootIndex()); -} +namespace internal { #ifndef EIGEN_PARSED_BY_DOXYGEN template<typename BVH, typename Intersector> -bool ei_intersect_helper(const BVH &tree, Intersector &intersector, typename BVH::Index root) +bool intersect_helper(const BVH &tree, Intersector &intersector, typename BVH::Index root) { typedef typename BVH::Index Index; typedef typename BVH::VolumeIterator VolIter; @@ -67,29 +57,43 @@ bool ei_intersect_helper(const BVH &tree, Intersector &intersector, typename BVH #endif //not EIGEN_PARSED_BY_DOXYGEN template<typename Volume1, typename Object1, typename Object2, typename Intersector> -struct ei_intersector_helper1 +struct intersector_helper1 { - ei_intersector_helper1(const Object2 &inStored, Intersector &in) : stored(inStored), intersector(in) {} + intersector_helper1(const Object2 &inStored, Intersector &in) : stored(inStored), intersector(in) {} bool intersectVolume(const Volume1 &vol) { return intersector.intersectVolumeObject(vol, stored); } bool intersectObject(const Object1 &obj) { return intersector.intersectObjectObject(obj, stored); } Object2 stored; Intersector &intersector; private: - ei_intersector_helper1& operator=(const ei_intersector_helper1&); + intersector_helper1& operator=(const intersector_helper1&); }; template<typename Volume2, typename Object2, typename Object1, typename Intersector> -struct ei_intersector_helper2 +struct intersector_helper2 { - ei_intersector_helper2(const Object1 &inStored, Intersector &in) : stored(inStored), intersector(in) {} + intersector_helper2(const Object1 &inStored, Intersector &in) : stored(inStored), intersector(in) {} bool intersectVolume(const Volume2 &vol) { return intersector.intersectObjectVolume(stored, vol); } bool intersectObject(const Object2 &obj) { return intersector.intersectObjectObject(stored, obj); } Object1 stored; Intersector &intersector; private: - ei_intersector_helper2& operator=(const ei_intersector_helper2&); + intersector_helper2& operator=(const intersector_helper2&); }; +} // end namespace internal + +/** Given a BVH, runs the query encapsulated by \a intersector. + * The Intersector type must provide the following members: \code + bool intersectVolume(const BVH::Volume &volume) //returns true if volume intersects the query + bool intersectObject(const BVH::Object &object) //returns true if the search should terminate immediately + \endcode + */ +template<typename BVH, typename Intersector> +void BVIntersect(const BVH &tree, Intersector &intersector) +{ + internal::intersect_helper(tree, intersector, tree.getRootIndex()); +} + /** Given two BVH's, runs the query on their Cartesian product encapsulated by \a intersector. * The Intersector type must provide the following members: \code bool intersectVolumeVolume(const BVH1::Volume &v1, const BVH2::Volume &v2) //returns true if product of volumes intersects the query @@ -103,8 +107,8 @@ void BVIntersect(const BVH1 &tree1, const BVH2 &tree2, Intersector &intersector) { typedef typename BVH1::Index Index1; typedef typename BVH2::Index Index2; - typedef ei_intersector_helper1<typename BVH1::Volume, typename BVH1::Object, typename BVH2::Object, Intersector> Helper1; - typedef ei_intersector_helper2<typename BVH2::Volume, typename BVH2::Object, typename BVH1::Object, Intersector> Helper2; + typedef internal::intersector_helper1<typename BVH1::Volume, typename BVH1::Object, typename BVH2::Object, Intersector> Helper1; + typedef internal::intersector_helper2<typename BVH2::Volume, typename BVH2::Object, typename BVH1::Object, Intersector> Helper2; typedef typename BVH1::VolumeIterator VolIter1; typedef typename BVH1::ObjectIterator ObjIter1; typedef typename BVH2::VolumeIterator VolIter2; @@ -131,7 +135,7 @@ void BVIntersect(const BVH1 &tree1, const BVH2 &tree2, Intersector &intersector) for(oCur2 = oBegin2; oCur2 != oEnd2; ++oCur2) {//go through child objects of second tree Helper1 helper(*oCur2, intersector); - if(ei_intersect_helper(tree1, helper, *vBegin1)) + if(internal::intersect_helper(tree1, helper, *vBegin1)) return; //intersector said to stop query } } @@ -139,7 +143,7 @@ void BVIntersect(const BVH1 &tree1, const BVH2 &tree2, Intersector &intersector) for(; oBegin1 != oEnd1; ++oBegin1) { //go through child objects of first tree for(vCur2 = vBegin2; vCur2 != vEnd2; ++vCur2) { //go through child volumes of second tree Helper2 helper(*oBegin1, intersector); - if(ei_intersect_helper(tree2, helper, *vCur2)) + if(internal::intersect_helper(tree2, helper, *vCur2)) return; //intersector said to stop query } @@ -151,23 +155,11 @@ void BVIntersect(const BVH1 &tree1, const BVH2 &tree2, Intersector &intersector) } } -/** Given a BVH, runs the query encapsulated by \a minimizer. - * \returns the minimum value. - * The Minimizer type must provide the following members: \code - typedef Scalar //the numeric type of what is being minimized--not necessarily the Scalar type of the BVH (if it has one) - Scalar minimumOnVolume(const BVH::Volume &volume) - Scalar minimumOnObject(const BVH::Object &object) - \endcode - */ -template<typename BVH, typename Minimizer> -typename Minimizer::Scalar BVMinimize(const BVH &tree, Minimizer &minimizer) -{ - return ei_minimize_helper(tree, minimizer, tree.getRootIndex(), std::numeric_limits<typename Minimizer::Scalar>::max()); -} +namespace internal { #ifndef EIGEN_PARSED_BY_DOXYGEN template<typename BVH, typename Minimizer> -typename Minimizer::Scalar ei_minimize_helper(const BVH &tree, Minimizer &minimizer, typename BVH::Index root, typename Minimizer::Scalar minimum) +typename Minimizer::Scalar minimize_helper(const BVH &tree, Minimizer &minimizer, typename BVH::Index root, typename Minimizer::Scalar minimum) { typedef typename Minimizer::Scalar Scalar; typedef typename BVH::Index Index; @@ -201,31 +193,47 @@ typename Minimizer::Scalar ei_minimize_helper(const BVH &tree, Minimizer &minimi template<typename Volume1, typename Object1, typename Object2, typename Minimizer> -struct ei_minimizer_helper1 +struct minimizer_helper1 { typedef typename Minimizer::Scalar Scalar; - ei_minimizer_helper1(const Object2 &inStored, Minimizer &m) : stored(inStored), minimizer(m) {} + minimizer_helper1(const Object2 &inStored, Minimizer &m) : stored(inStored), minimizer(m) {} Scalar minimumOnVolume(const Volume1 &vol) { return minimizer.minimumOnVolumeObject(vol, stored); } Scalar minimumOnObject(const Object1 &obj) { return minimizer.minimumOnObjectObject(obj, stored); } Object2 stored; Minimizer &minimizer; private: - ei_minimizer_helper1& operator=(const ei_minimizer_helper1&) {} + minimizer_helper1& operator=(const minimizer_helper1&) {} }; template<typename Volume2, typename Object2, typename Object1, typename Minimizer> -struct ei_minimizer_helper2 +struct minimizer_helper2 { typedef typename Minimizer::Scalar Scalar; - ei_minimizer_helper2(const Object1 &inStored, Minimizer &m) : stored(inStored), minimizer(m) {} + minimizer_helper2(const Object1 &inStored, Minimizer &m) : stored(inStored), minimizer(m) {} Scalar minimumOnVolume(const Volume2 &vol) { return minimizer.minimumOnObjectVolume(stored, vol); } Scalar minimumOnObject(const Object2 &obj) { return minimizer.minimumOnObjectObject(stored, obj); } Object1 stored; Minimizer &minimizer; private: - ei_minimizer_helper2& operator=(const ei_minimizer_helper2&); + minimizer_helper2& operator=(const minimizer_helper2&); }; +} // end namespace internal + +/** Given a BVH, runs the query encapsulated by \a minimizer. + * \returns the minimum value. + * The Minimizer type must provide the following members: \code + typedef Scalar //the numeric type of what is being minimized--not necessarily the Scalar type of the BVH (if it has one) + Scalar minimumOnVolume(const BVH::Volume &volume) + Scalar minimumOnObject(const BVH::Object &object) + \endcode + */ +template<typename BVH, typename Minimizer> +typename Minimizer::Scalar BVMinimize(const BVH &tree, Minimizer &minimizer) +{ + return internal::minimize_helper(tree, minimizer, tree.getRootIndex(), std::numeric_limits<typename Minimizer::Scalar>::max()); +} + /** Given two BVH's, runs the query on their cartesian product encapsulated by \a minimizer. * \returns the minimum value. * The Minimizer type must provide the following members: \code @@ -242,8 +250,8 @@ typename Minimizer::Scalar BVMinimize(const BVH1 &tree1, const BVH2 &tree2, Mini typedef typename Minimizer::Scalar Scalar; typedef typename BVH1::Index Index1; typedef typename BVH2::Index Index2; - typedef ei_minimizer_helper1<typename BVH1::Volume, typename BVH1::Object, typename BVH2::Object, Minimizer> Helper1; - typedef ei_minimizer_helper2<typename BVH2::Volume, typename BVH2::Object, typename BVH1::Object, Minimizer> Helper2; + typedef internal::minimizer_helper1<typename BVH1::Volume, typename BVH1::Object, typename BVH2::Object, Minimizer> Helper1; + typedef internal::minimizer_helper2<typename BVH2::Volume, typename BVH2::Object, typename BVH1::Object, Minimizer> Helper2; typedef std::pair<Scalar, std::pair<Index1, Index2> > QueueElement; //first element is priority typedef typename BVH1::VolumeIterator VolIter1; typedef typename BVH1::ObjectIterator ObjIter1; @@ -271,7 +279,7 @@ typename Minimizer::Scalar BVMinimize(const BVH1 &tree1, const BVH2 &tree2, Mini for(vCur2 = vBegin2; vCur2 != vEnd2; ++vCur2) { //go through child volumes of second tree Helper2 helper(*oBegin1, minimizer); - minimum = std::min(minimum, ei_minimize_helper(tree2, helper, *vCur2, minimum)); + minimum = std::min(minimum, internal::minimize_helper(tree2, helper, *vCur2, minimum)); } } @@ -280,7 +288,7 @@ typename Minimizer::Scalar BVMinimize(const BVH1 &tree1, const BVH2 &tree2, Mini for(oCur2 = oBegin2; oCur2 != oEnd2; ++oCur2) {//go through child objects of second tree Helper1 helper(*oCur2, minimizer); - minimum = std::min(minimum, ei_minimize_helper(tree1, helper, *vBegin1, minimum)); + minimum = std::min(minimum, internal::minimize_helper(tree1, helper, *vBegin1, minimum)); } for(vCur2 = vBegin2; vCur2 != vEnd2; ++vCur2) { //go through child volumes of second tree diff --git a/unsupported/Eigen/src/BVH/KdBVH.h b/unsupported/Eigen/src/BVH/KdBVH.h index c4719607f..028b4811e 100644 --- a/unsupported/Eigen/src/BVH/KdBVH.h +++ b/unsupported/Eigen/src/BVH/KdBVH.h @@ -25,47 +25,51 @@ #ifndef KDBVH_H_INCLUDED #define KDBVH_H_INCLUDED +namespace internal { + //internal pair class for the BVH--used instead of std::pair because of alignment template<typename Scalar, int Dim> -struct ei_vector_int_pair +struct vector_int_pair { EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(Scalar, Dim) typedef Matrix<Scalar, Dim, 1> VectorType; - ei_vector_int_pair(const VectorType &v, int i) : first(v), second(i) {} + vector_int_pair(const VectorType &v, int i) : first(v), second(i) {} VectorType first; int second; }; //these templates help the tree initializer get the bounding boxes either from a provided -//iterator range or using ei_bounding_box in a unified way +//iterator range or using bounding_box in a unified way template<typename ObjectList, typename VolumeList, typename BoxIter> -struct ei_get_boxes_helper { +struct get_boxes_helper { void operator()(const ObjectList &objects, BoxIter boxBegin, BoxIter boxEnd, VolumeList &outBoxes) { outBoxes.insert(outBoxes.end(), boxBegin, boxEnd); - ei_assert(outBoxes.size() == objects.size()); + eigen_assert(outBoxes.size() == objects.size()); } }; template<typename ObjectList, typename VolumeList> -struct ei_get_boxes_helper<ObjectList, VolumeList, int> { +struct get_boxes_helper<ObjectList, VolumeList, int> { void operator()(const ObjectList &objects, int, int, VolumeList &outBoxes) { outBoxes.reserve(objects.size()); for(int i = 0; i < (int)objects.size(); ++i) - outBoxes.push_back(ei_bounding_box(objects[i])); + outBoxes.push_back(bounding_box(objects[i])); } }; +} // end namespace internal + /** \class KdBVH * \brief A simple bounding volume hierarchy based on AlignedBox * * \param _Scalar The underlying scalar type of the bounding boxes * \param _Dim The dimension of the space in which the hierarchy lives - * \param _Object The object type that lives in the hierarchy. It must have value semantics. Either ei_bounding_box(_Object) must + * \param _Object The object type that lives in the hierarchy. It must have value semantics. Either internal::bounding_box(_Object) must * be defined and return an AlignedBox<_Scalar, _Dim> or bounding boxes must be provided to the tree initializer. * * This class provides a simple (as opposed to optimized) implementation of a bounding volume hierarchy analogous to a Kd-tree. @@ -88,14 +92,14 @@ public: KdBVH() {} - /** Given an iterator range over \a Object references, constructs the BVH. Requires that ei_bounding_box(Object) return a Volume. */ + /** Given an iterator range over \a Object references, constructs the BVH. Requires that internal::bounding_box(Object) return a Volume. */ template<typename Iter> KdBVH(Iter begin, Iter end) { init(begin, end, 0, 0); } //int is recognized by init as not being an iterator type /** Given an iterator range over \a Object references and an iterator range over their bounding boxes, constructs the BVH */ template<typename OIter, typename BIter> KdBVH(OIter begin, OIter end, BIter boxBegin, BIter boxEnd) { init(begin, end, boxBegin, boxEnd); } /** Given an iterator range over \a Object references, constructs the BVH, overwriting whatever is in there currently. - * Requires that ei_bounding_box(Object) return a Volume. */ + * Requires that internal::bounding_box(Object) return a Volume. */ template<typename Iter> void init(Iter begin, Iter end) { init(begin, end, 0, 0); } /** Given an iterator range over \a Object references and an iterator range over their bounding boxes, @@ -116,7 +120,7 @@ public: VIPairList objCenters; //compute the bounding boxes depending on BIter type - ei_get_boxes_helper<ObjectList, VolumeList, BIter>()(objects, boxBegin, boxEnd, objBoxes); + internal::get_boxes_helper<ObjectList, VolumeList, BIter>()(objects, boxBegin, boxEnd, objBoxes); objCenters.reserve(n); boxes.reserve(n - 1); @@ -176,7 +180,7 @@ public: } private: - typedef ei_vector_int_pair<Scalar, Dim> VIPair; + typedef internal::vector_int_pair<Scalar, Dim> VIPair; typedef std::vector<VIPair, aligned_allocator<VIPair> > VIPairList; typedef Matrix<Scalar, Dim, 1> VectorType; struct VectorComparator //compares vectors, or, more specificall, VIPairs along a particular dimension @@ -191,7 +195,7 @@ private: //the two halves, and adds their parent node. TODO: a cache-friendlier layout void build(VIPairList &objCenters, int from, int to, const VolumeList &objBoxes, int dim) { - ei_assert(to - from > 1); + eigen_assert(to - from > 1); if(to - from == 2) { boxes.push_back(objBoxes[objCenters[from].second].merged(objBoxes[objCenters[from + 1].second])); children.push_back(from + (int)objects.size() - 1); //there are objects.size() - 1 tree nodes diff --git a/unsupported/Eigen/src/FFT/ei_fftw_impl.h b/unsupported/Eigen/src/FFT/ei_fftw_impl.h index c1f777e6d..84e4fcda5 100644 --- a/unsupported/Eigen/src/FFT/ei_fftw_impl.h +++ b/unsupported/Eigen/src/FFT/ei_fftw_impl.h @@ -22,7 +22,7 @@ // License and a copy of the GNU General Public License along with // Eigen. If not, see <http://www.gnu.org/licenses/>. - +namespace internal { // FFTW uses non-const arguments // so we must use ugly const_cast calls for all the args it uses @@ -34,40 +34,40 @@ // This assumes std::complex<T> layout is array of size 2 with real,imag template <typename T> inline - T * ei_fftw_cast(const T* p) + T * fftw_cast(const T* p) { return const_cast<T*>( p); } inline - fftw_complex * ei_fftw_cast( const std::complex<double> * p) + fftw_complex * fftw_cast( const std::complex<double> * p) { return const_cast<fftw_complex*>( reinterpret_cast<const fftw_complex*>(p) ); } inline - fftwf_complex * ei_fftw_cast( const std::complex<float> * p) + fftwf_complex * fftw_cast( const std::complex<float> * p) { return const_cast<fftwf_complex*>( reinterpret_cast<const fftwf_complex*>(p) ); } inline - fftwl_complex * ei_fftw_cast( const std::complex<long double> * p) + fftwl_complex * fftw_cast( const std::complex<long double> * p) { return const_cast<fftwl_complex*>( reinterpret_cast<const fftwl_complex*>(p) ); } template <typename T> - struct ei_fftw_plan {}; + struct fftw_plan {}; template <> - struct ei_fftw_plan<float> + struct fftw_plan<float> { typedef float scalar_type; typedef fftwf_complex complex_type; fftwf_plan m_plan; - ei_fftw_plan() :m_plan(NULL) {} - ~ei_fftw_plan() {if (m_plan) fftwf_destroy_plan(m_plan);} + fftw_plan() :m_plan(NULL) {} + ~fftw_plan() {if (m_plan) fftwf_destroy_plan(m_plan);} inline void fwd(complex_type * dst,complex_type * src,int nfft) { @@ -104,13 +104,13 @@ }; template <> - struct ei_fftw_plan<double> + struct fftw_plan<double> { typedef double scalar_type; typedef fftw_complex complex_type; fftw_plan m_plan; - ei_fftw_plan() :m_plan(NULL) {} - ~ei_fftw_plan() {if (m_plan) fftw_destroy_plan(m_plan);} + fftw_plan() :m_plan(NULL) {} + ~fftw_plan() {if (m_plan) fftw_destroy_plan(m_plan);} inline void fwd(complex_type * dst,complex_type * src,int nfft) { @@ -145,13 +145,13 @@ } }; template <> - struct ei_fftw_plan<long double> + struct fftw_plan<long double> { typedef long double scalar_type; typedef fftwl_complex complex_type; fftwl_plan m_plan; - ei_fftw_plan() :m_plan(NULL) {} - ~ei_fftw_plan() {if (m_plan) fftwl_destroy_plan(m_plan);} + fftw_plan() :m_plan(NULL) {} + ~fftw_plan() {if (m_plan) fftwl_destroy_plan(m_plan);} inline void fwd(complex_type * dst,complex_type * src,int nfft) { @@ -187,7 +187,7 @@ }; template <typename _Scalar> - struct ei_fftw_impl + struct fftw_impl { typedef _Scalar Scalar; typedef std::complex<Scalar> Complex; @@ -202,47 +202,47 @@ inline void fwd( Complex * dst,const Complex *src,int nfft) { - get_plan(nfft,false,dst,src).fwd(ei_fftw_cast(dst), ei_fftw_cast(src),nfft ); + get_plan(nfft,false,dst,src).fwd(fftw_cast(dst), fftw_cast(src),nfft ); } // real-to-complex forward FFT inline void fwd( Complex * dst,const Scalar * src,int nfft) { - get_plan(nfft,false,dst,src).fwd(ei_fftw_cast(dst), ei_fftw_cast(src) ,nfft); + get_plan(nfft,false,dst,src).fwd(fftw_cast(dst), fftw_cast(src) ,nfft); } // 2-d complex-to-complex inline void fwd2(Complex * dst, const Complex * src, int n0,int n1) { - get_plan(n0,n1,false,dst,src).fwd2(ei_fftw_cast(dst), ei_fftw_cast(src) ,n0,n1); + get_plan(n0,n1,false,dst,src).fwd2(fftw_cast(dst), fftw_cast(src) ,n0,n1); } // inverse complex-to-complex inline void inv(Complex * dst,const Complex *src,int nfft) { - get_plan(nfft,true,dst,src).inv(ei_fftw_cast(dst), ei_fftw_cast(src),nfft ); + get_plan(nfft,true,dst,src).inv(fftw_cast(dst), fftw_cast(src),nfft ); } // half-complex to scalar inline void inv( Scalar * dst,const Complex * src,int nfft) { - get_plan(nfft,true,dst,src).inv(ei_fftw_cast(dst), ei_fftw_cast(src),nfft ); + get_plan(nfft,true,dst,src).inv(fftw_cast(dst), fftw_cast(src),nfft ); } // 2-d complex-to-complex inline void inv2(Complex * dst, const Complex * src, int n0,int n1) { - get_plan(n0,n1,true,dst,src).inv2(ei_fftw_cast(dst), ei_fftw_cast(src) ,n0,n1); + get_plan(n0,n1,true,dst,src).inv2(fftw_cast(dst), fftw_cast(src) ,n0,n1); } protected: - typedef ei_fftw_plan<Scalar> PlanData; + typedef fftw_plan<Scalar> PlanData; typedef std::map<int64_t,PlanData> PlanMap; @@ -266,5 +266,7 @@ return m_plans[key]; } }; -/* vim: set filetype=cpp et sw=2 ts=2 ai: */ +} // end namespace internal + +/* vim: set filetype=cpp et sw=2 ts=2 ai: */ diff --git a/unsupported/Eigen/src/FFT/ei_kissfft_impl.h b/unsupported/Eigen/src/FFT/ei_kissfft_impl.h index 5db1bf37d..667638f40 100644 --- a/unsupported/Eigen/src/FFT/ei_kissfft_impl.h +++ b/unsupported/Eigen/src/FFT/ei_kissfft_impl.h @@ -22,13 +22,13 @@ // License and a copy of the GNU General Public License along with // Eigen. If not, see <http://www.gnu.org/licenses/>. - +namespace internal { // This FFT implementation was derived from kissfft http:sourceforge.net/projects/kissfft // Copyright 2003-2009 Mark Borgerding template <typename _Scalar> -struct ei_kiss_cpx_fft +struct kiss_cpx_fft { typedef _Scalar Scalar; typedef std::complex<Scalar> Complex; @@ -274,7 +274,7 @@ struct ei_kiss_cpx_fft }; template <typename _Scalar> -struct ei_kissfft_impl +struct kissfft_impl { typedef _Scalar Scalar; typedef std::complex<Scalar> Complex; @@ -378,7 +378,7 @@ struct ei_kissfft_impl } protected: - typedef ei_kiss_cpx_fft<Scalar> PlanData; + typedef kiss_cpx_fft<Scalar> PlanData; typedef std::map<int,PlanData> PlanMap; PlanMap m_plans; @@ -416,5 +416,7 @@ struct ei_kissfft_impl } }; +} // end namespace internal + /* vim: set filetype=cpp et sw=2 ts=2 ai: */ diff --git a/unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h b/unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h index 88339b354..f4851d316 100644 --- a/unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h +++ b/unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h @@ -50,14 +50,16 @@ #include <Eigen/Core> +namespace internal { + /** \ingroup IterativeSolvers_Module * Compute the pseudo inverse of the non-square matrix C such that * \f$ CINV = (C * C^T)^{-1} * C \f$ based on a conjugate gradient method. * - * This function is internally used by ei_constrained_cg. + * This function is internally used by constrained_cg. */ template <typename CMatrix, typename CINVMatrix> -void ei_pseudo_inverse(const CMatrix &C, CINVMatrix &CINV) +void pseudo_inverse(const CMatrix &C, CINVMatrix &CINV) { // optimisable : copie de la ligne, precalcul de C * trans(C). typedef typename CMatrix::Scalar Scalar; @@ -113,7 +115,7 @@ void ei_pseudo_inverse(const CMatrix &C, CINVMatrix &CINV) */ template<typename TMatrix, typename CMatrix, typename VectorX, typename VectorB, typename VectorF> -void ei_constrained_cg(const TMatrix& A, const CMatrix& C, VectorX& x, +void constrained_cg(const TMatrix& A, const CMatrix& C, VectorX& x, const VectorB& b, const VectorF& f, IterationController &iter) { typedef typename TMatrix::Scalar Scalar; @@ -127,11 +129,11 @@ void ei_constrained_cg(const TMatrix& A, const CMatrix& C, VectorX& x, memox(xSize); std::vector<bool> satured(C.rows()); p.setZero(); - iter.setRhsNorm(ei_sqrt(b.dot(b))); // gael vect_sp(PS, b, b) + iter.setRhsNorm(sqrt(b.dot(b))); // gael vect_sp(PS, b, b) if (iter.rhsNorm() == 0.0) iter.setRhsNorm(1.0); SparseMatrix<Scalar,RowMajor> CINV(C.rows(), C.cols()); - ei_pseudo_inverse(C, CINV); + pseudo_inverse(C, CINV); while(true) { @@ -191,4 +193,6 @@ void ei_constrained_cg(const TMatrix& A, const CMatrix& C, VectorX& x, } } +} // end namespace internal + #endif // EIGEN_CONSTRAINEDCG_H diff --git a/unsupported/Eigen/src/IterativeSolvers/IterationController.h b/unsupported/Eigen/src/IterativeSolvers/IterationController.h index 7d579a6fd..385d8c546 100644 --- a/unsupported/Eigen/src/IterativeSolvers/IterationController.h +++ b/unsupported/Eigen/src/IterativeSolvers/IterationController.h @@ -140,7 +140,7 @@ class IterationController bool converged() const { return m_res <= m_rhsn * m_resmax; } bool converged(double nr) { - m_res = ei_abs(nr); + m_res = internal::abs(nr); m_resminreach = std::min(m_resminreach, m_res); return converged(); } diff --git a/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h b/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h index 006371474..ae937acda 100644 --- a/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h +++ b/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h @@ -128,11 +128,11 @@ class MatrixExponential { */ void computeUV(float); - typedef typename ei_traits<MatrixType>::Scalar Scalar; + typedef typename internal::traits<MatrixType>::Scalar Scalar; typedef typename NumTraits<Scalar>::Real RealScalar; /** \brief Reference to matrix whose exponential is to be computed. */ - typename ei_nested<MatrixType>::type m_M; + typename internal::nested<MatrixType>::type m_M; /** \brief Even-degree terms in numerator of Padé approximant. */ MatrixType m_U; @@ -327,16 +327,18 @@ template<typename Derived> struct MatrixExponentialReturnValue MatrixExponentialReturnValue& operator=(const MatrixExponentialReturnValue&); }; +namespace internal { template<typename Derived> -struct ei_traits<MatrixExponentialReturnValue<Derived> > +struct traits<MatrixExponentialReturnValue<Derived> > { typedef typename Derived::PlainObject ReturnType; }; +} template <typename Derived> const MatrixExponentialReturnValue<Derived> MatrixBase<Derived>::exp() const { - ei_assert(rows() == cols()); + eigen_assert(rows() == cols()); return MatrixExponentialReturnValue<Derived>(derived()); } diff --git a/unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h b/unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h index e83e055e9..a4aa9baa7 100644 --- a/unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h +++ b/unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h @@ -34,14 +34,14 @@ * \tparam MatrixType type of the argument of the matrix function, * expected to be an instantiation of the Matrix class template. */ -template <typename MatrixType, int IsComplex = NumTraits<typename ei_traits<MatrixType>::Scalar>::IsComplex> +template <typename MatrixType, int IsComplex = NumTraits<typename internal::traits<MatrixType>::Scalar>::IsComplex> class MatrixFunction { private: - typedef typename ei_traits<MatrixType>::Index Index; - typedef typename ei_traits<MatrixType>::Scalar Scalar; - typedef typename ei_stem_function<Scalar>::type StemFunction; + typedef typename internal::traits<MatrixType>::Index Index; + typedef typename internal::traits<MatrixType>::Scalar Scalar; + typedef typename internal::stem_function<Scalar>::type StemFunction; public: @@ -76,7 +76,7 @@ class MatrixFunction<MatrixType, 0> { private: - typedef ei_traits<MatrixType> Traits; + typedef internal::traits<MatrixType> Traits; typedef typename Traits::Scalar Scalar; static const int Rows = Traits::RowsAtCompileTime; static const int Cols = Traits::ColsAtCompileTime; @@ -86,7 +86,7 @@ class MatrixFunction<MatrixType, 0> typedef std::complex<Scalar> ComplexScalar; typedef Matrix<ComplexScalar, Rows, Cols, Options, MaxRows, MaxCols> ComplexMatrix; - typedef typename ei_stem_function<Scalar>::type StemFunction; + typedef typename internal::stem_function<Scalar>::type StemFunction; public: @@ -117,7 +117,7 @@ class MatrixFunction<MatrixType, 0> } private: - typename ei_nested<MatrixType>::type m_A; /**< \brief Reference to argument of matrix function. */ + typename internal::nested<MatrixType>::type m_A; /**< \brief Reference to argument of matrix function. */ StemFunction *m_f; /**< \brief Stem function for matrix function under consideration */ MatrixFunction& operator=(const MatrixFunction&); @@ -132,14 +132,14 @@ class MatrixFunction<MatrixType, 1> { private: - typedef ei_traits<MatrixType> Traits; + typedef internal::traits<MatrixType> Traits; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Index Index; static const int RowsAtCompileTime = Traits::RowsAtCompileTime; static const int ColsAtCompileTime = Traits::ColsAtCompileTime; static const int Options = MatrixType::Options; typedef typename NumTraits<Scalar>::Real RealScalar; - typedef typename ei_stem_function<Scalar>::type StemFunction; + typedef typename internal::stem_function<Scalar>::type StemFunction; typedef Matrix<Scalar, Traits::RowsAtCompileTime, 1> VectorType; typedef Matrix<Index, Traits::RowsAtCompileTime, 1> IntVectorType; typedef Matrix<Index, Dynamic, 1> DynamicIntVectorType; @@ -167,7 +167,7 @@ class MatrixFunction<MatrixType, 1> void computeOffDiagonal(); DynMatrixType solveTriangularSylvester(const DynMatrixType& A, const DynMatrixType& B, const DynMatrixType& C); - typename ei_nested<MatrixType>::type m_A; /**< \brief Reference to argument of matrix function. */ + typename internal::nested<MatrixType>::type m_A; /**< \brief Reference to argument of matrix function. */ StemFunction *m_f; /**< \brief Stem function for matrix function under consideration */ MatrixType m_T; /**< \brief Triangular part of Schur decomposition */ MatrixType m_U; /**< \brief Unitary part of Schur decomposition */ @@ -260,7 +260,7 @@ void MatrixFunction<MatrixType,1>::partitionEigenvalues() // Look for other element to add to the set for (Index j=i+1; j<rows; ++j) { - if (ei_abs(diag(j) - diag(i)) <= separation() && std::find(qi->begin(), qi->end(), diag(j)) == qi->end()) { + if (internal::abs(diag(j) - diag(i)) <= separation() && std::find(qi->begin(), qi->end(), diag(j)) == qi->end()) { typename ListOfClusters::iterator qj = findCluster(diag(j)); if (qj == m_clusters.end()) { qi->push_back(diag(j)); @@ -346,7 +346,7 @@ void MatrixFunction<MatrixType,1>::permuteSchur() for (j = i; j < p.rows(); j++) { if (p(j) == i) break; } - ei_assert(p(j) == i); + eigen_assert(p(j) == i); for (Index k = j-1; k >= i; k--) { swapEntriesInSchur(k); std::swap(p.coeffRef(k), p.coeffRef(k+1)); @@ -445,12 +445,12 @@ typename MatrixFunction<MatrixType,1>::DynMatrixType MatrixFunction<MatrixType,1 const DynMatrixType& B, const DynMatrixType& C) { - ei_assert(A.rows() == A.cols()); - ei_assert(A.isUpperTriangular()); - ei_assert(B.rows() == B.cols()); - ei_assert(B.isUpperTriangular()); - ei_assert(C.rows() == A.rows()); - ei_assert(C.cols() == B.rows()); + eigen_assert(A.rows() == A.cols()); + eigen_assert(A.isUpperTriangular()); + eigen_assert(B.rows() == B.cols()); + eigen_assert(B.isUpperTriangular()); + eigen_assert(C.rows() == A.rows()); + eigen_assert(C.cols() == B.rows()); Index m = A.rows(); Index n = B.rows(); @@ -502,7 +502,7 @@ template<typename Derived> class MatrixFunctionReturnValue typedef typename Derived::Scalar Scalar; typedef typename Derived::Index Index; - typedef typename ei_stem_function<Scalar>::type StemFunction; + typedef typename internal::stem_function<Scalar>::type StemFunction; /** \brief Constructor. * @@ -529,58 +529,60 @@ template<typename Derived> class MatrixFunctionReturnValue Index cols() const { return m_A.cols(); } private: - typename ei_nested<Derived>::type m_A; + typename internal::nested<Derived>::type m_A; StemFunction *m_f; MatrixFunctionReturnValue& operator=(const MatrixFunctionReturnValue&); }; +namespace internal { template<typename Derived> -struct ei_traits<MatrixFunctionReturnValue<Derived> > +struct traits<MatrixFunctionReturnValue<Derived> > { typedef typename Derived::PlainObject ReturnType; }; +} /********** MatrixBase methods **********/ template <typename Derived> -const MatrixFunctionReturnValue<Derived> MatrixBase<Derived>::matrixFunction(typename ei_stem_function<typename ei_traits<Derived>::Scalar>::type f) const +const MatrixFunctionReturnValue<Derived> MatrixBase<Derived>::matrixFunction(typename internal::stem_function<typename internal::traits<Derived>::Scalar>::type f) const { - ei_assert(rows() == cols()); + eigen_assert(rows() == cols()); return MatrixFunctionReturnValue<Derived>(derived(), f); } template <typename Derived> const MatrixFunctionReturnValue<Derived> MatrixBase<Derived>::sin() const { - ei_assert(rows() == cols()); - typedef typename ei_stem_function<Scalar>::ComplexScalar ComplexScalar; + eigen_assert(rows() == cols()); + typedef typename internal::stem_function<Scalar>::ComplexScalar ComplexScalar; return MatrixFunctionReturnValue<Derived>(derived(), StdStemFunctions<ComplexScalar>::sin); } template <typename Derived> const MatrixFunctionReturnValue<Derived> MatrixBase<Derived>::cos() const { - ei_assert(rows() == cols()); - typedef typename ei_stem_function<Scalar>::ComplexScalar ComplexScalar; + eigen_assert(rows() == cols()); + typedef typename internal::stem_function<Scalar>::ComplexScalar ComplexScalar; return MatrixFunctionReturnValue<Derived>(derived(), StdStemFunctions<ComplexScalar>::cos); } template <typename Derived> const MatrixFunctionReturnValue<Derived> MatrixBase<Derived>::sinh() const { - ei_assert(rows() == cols()); - typedef typename ei_stem_function<Scalar>::ComplexScalar ComplexScalar; + eigen_assert(rows() == cols()); + typedef typename internal::stem_function<Scalar>::ComplexScalar ComplexScalar; return MatrixFunctionReturnValue<Derived>(derived(), StdStemFunctions<ComplexScalar>::sinh); } template <typename Derived> const MatrixFunctionReturnValue<Derived> MatrixBase<Derived>::cosh() const { - ei_assert(rows() == cols()); - typedef typename ei_stem_function<Scalar>::ComplexScalar ComplexScalar; + eigen_assert(rows() == cols()); + typedef typename internal::stem_function<Scalar>::ComplexScalar ComplexScalar; return MatrixFunctionReturnValue<Derived>(derived(), StdStemFunctions<ComplexScalar>::cosh); } diff --git a/unsupported/Eigen/src/MatrixFunctions/MatrixFunctionAtomic.h b/unsupported/Eigen/src/MatrixFunctions/MatrixFunctionAtomic.h index ceb0a84f1..87dc64ce1 100644 --- a/unsupported/Eigen/src/MatrixFunctions/MatrixFunctionAtomic.h +++ b/unsupported/Eigen/src/MatrixFunctions/MatrixFunctionAtomic.h @@ -41,7 +41,7 @@ class MatrixFunctionAtomic typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Index Index; typedef typename NumTraits<Scalar>::Real RealScalar; - typedef typename ei_stem_function<Scalar>::type StemFunction; + typedef typename internal::stem_function<Scalar>::type StemFunction; typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType; /** \brief Constructor @@ -99,7 +99,7 @@ MatrixType MatrixFunctionAtomic<MatrixType>::compute(const MatrixType& A) return F; } } - ei_assert("Taylor series does not converge" && 0); + eigen_assert("Taylor series does not converge" && 0); return F; } diff --git a/unsupported/Eigen/src/MoreVectorization/MathFunctions.h b/unsupported/Eigen/src/MoreVectorization/MathFunctions.h index a998a0615..bc948d0bd 100644 --- a/unsupported/Eigen/src/MoreVectorization/MathFunctions.h +++ b/unsupported/Eigen/src/MoreVectorization/MathFunctions.h @@ -26,12 +26,14 @@ #ifndef EIGEN_MOREVECTORIZATION_MATHFUNCTIONS_H #define EIGEN_MOREVECTORIZATION_MATHFUNCTIONS_H +namespace internal { + /** \internal \returns the arcsin of \a a (coeff-wise) */ -template<typename Packet> inline static Packet ei_pasin(Packet a) { return std::asin(a); } +template<typename Packet> inline static Packet pasin(Packet a) { return std::asin(a); } #ifdef EIGEN_VECTORIZE_SSE -template<> EIGEN_DONT_INLINE Packet4f ei_pasin(Packet4f x) +template<> EIGEN_DONT_INLINE Packet4f pasin(Packet4f x) { _EIGEN_DECLARE_CONST_Packet4f(half, 0.5); _EIGEN_DECLARE_CONST_Packet4f(minus_half, -0.5); @@ -48,9 +50,9 @@ template<> EIGEN_DONT_INLINE Packet4f ei_pasin(Packet4f x) _EIGEN_DECLARE_CONST_Packet4f(asin4, 7.4953002686E-2); _EIGEN_DECLARE_CONST_Packet4f(asin5, 1.6666752422E-1); - Packet4f a = ei_pabs(x);//got the absolute value + Packet4f a = pabs(x);//got the absolute value - Packet4f sign_bit= _mm_and_ps(x, ei_p4f_sign_mask);//extracted the sign bit + Packet4f sign_bit= _mm_and_ps(x, p4f_sign_mask);//extracted the sign bit Packet4f z1,z2;//will need them during computation @@ -58,34 +60,34 @@ template<> EIGEN_DONT_INLINE Packet4f ei_pasin(Packet4f x) //will compute the two branches for asin //so first compare with half - Packet4f branch_mask= _mm_cmpgt_ps(a, ei_p4f_half);//this is to select which branch to take + Packet4f branch_mask= _mm_cmpgt_ps(a, p4f_half);//this is to select which branch to take //both will be taken, and finally results will be merged //the branch for values >0.5 { //the core series expansion - z1=ei_pmadd(ei_p4f_minus_half,a,ei_p4f_half); - Packet4f x1=ei_psqrt(z1); - Packet4f s1=ei_pmadd(ei_p4f_asin1, z1, ei_p4f_asin2); - Packet4f s2=ei_pmadd(s1, z1, ei_p4f_asin3); - Packet4f s3=ei_pmadd(s2,z1, ei_p4f_asin4); - Packet4f s4=ei_pmadd(s3,z1, ei_p4f_asin5); - Packet4f temp=ei_pmul(s4,z1);//not really a madd but a mul by z so that the next term can be a madd - z1=ei_pmadd(temp,x1,x1); - z1=ei_padd(z1,z1); - z1=ei_psub(ei_p4f_pi_over_2,z1); + z1=pmadd(p4f_minus_half,a,p4f_half); + Packet4f x1=psqrt(z1); + Packet4f s1=pmadd(p4f_asin1, z1, p4f_asin2); + Packet4f s2=pmadd(s1, z1, p4f_asin3); + Packet4f s3=pmadd(s2,z1, p4f_asin4); + Packet4f s4=pmadd(s3,z1, p4f_asin5); + Packet4f temp=pmul(s4,z1);//not really a madd but a mul by z so that the next term can be a madd + z1=pmadd(temp,x1,x1); + z1=padd(z1,z1); + z1=psub(p4f_pi_over_2,z1); } { //the core series expansion Packet4f x2=a; - z2=ei_pmul(x2,x2); - Packet4f s1=ei_pmadd(ei_p4f_asin1, z2, ei_p4f_asin2); - Packet4f s2=ei_pmadd(s1, z2, ei_p4f_asin3); - Packet4f s3=ei_pmadd(s2,z2, ei_p4f_asin4); - Packet4f s4=ei_pmadd(s3,z2, ei_p4f_asin5); - Packet4f temp=ei_pmul(s4,z2);//not really a madd but a mul by z so that the next term can be a madd - z2=ei_pmadd(temp,x2,x2); + z2=pmul(x2,x2); + Packet4f s1=pmadd(p4f_asin1, z2, p4f_asin2); + Packet4f s2=pmadd(s1, z2, p4f_asin3); + Packet4f s3=pmadd(s2,z2, p4f_asin4); + Packet4f s4=pmadd(s3,z2, p4f_asin5); + Packet4f temp=pmul(s4,z2);//not really a madd but a mul by z so that the next term can be a madd + z2=pmadd(temp,x2,x2); } /* select the correct result from the two branch evaluations */ @@ -97,6 +99,7 @@ template<> EIGEN_DONT_INLINE Packet4f ei_pasin(Packet4f x) return _mm_xor_ps(z, sign_bit); } +} // end namespace internal #endif diff --git a/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h b/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h index 3308a4a34..a4863700e 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h +++ b/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h @@ -65,7 +65,7 @@ public: Parameters() : factor(Scalar(100.)) , maxfev(1000) - , xtol(ei_sqrt(NumTraits<Scalar>::epsilon())) + , xtol(internal::sqrt(NumTraits<Scalar>::epsilon())) , nb_of_subdiagonals(-1) , nb_of_superdiagonals(-1) , epsfcn(Scalar(0.)) {} @@ -83,7 +83,7 @@ public: HybridNonLinearSolverSpace::Status hybrj1( FVectorType &x, - const Scalar tol = ei_sqrt(NumTraits<Scalar>::epsilon()) + const Scalar tol = internal::sqrt(NumTraits<Scalar>::epsilon()) ); HybridNonLinearSolverSpace::Status solveInit(FVectorType &x); @@ -92,7 +92,7 @@ public: HybridNonLinearSolverSpace::Status hybrd1( FVectorType &x, - const Scalar tol = ei_sqrt(NumTraits<Scalar>::epsilon()) + const Scalar tol = internal::sqrt(NumTraits<Scalar>::epsilon()) ); HybridNonLinearSolverSpace::Status solveNumericalDiffInit(FVectorType &x); @@ -246,7 +246,7 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveOneStep(FVectorType &x) while (true) { /* determine the direction p. */ - ei_dogleg<Scalar>(R, diag, qtf, delta, wa1); + internal::dogleg<Scalar>(R, diag, qtf, delta, wa1); /* store the direction p and x + p. calculate the norm of p. */ wa1 = -wa1; @@ -266,14 +266,14 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveOneStep(FVectorType &x) /* compute the scaled actual reduction. */ actred = -1.; if (fnorm1 < fnorm) /* Computing 2nd power */ - actred = 1. - ei_abs2(fnorm1 / fnorm); + actred = 1. - internal::abs2(fnorm1 / fnorm); /* compute the scaled predicted reduction. */ wa3 = R.template triangularView<Upper>()*wa1 + qtf; temp = wa3.stableNorm(); prered = 0.; if (temp < fnorm) /* Computing 2nd power */ - prered = 1. - ei_abs2(temp / fnorm); + prered = 1. - internal::abs2(temp / fnorm); /* compute the ratio of the actual to the predicted reduction. */ ratio = 0.; @@ -290,7 +290,7 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveOneStep(FVectorType &x) ++ncsuc; if (ratio >= Scalar(.5) || ncsuc > 1) delta = std::max(delta, pnorm / Scalar(.5)); - if (ei_abs(ratio - 1.) <= Scalar(.1)) { + if (internal::abs(ratio - 1.) <= Scalar(.1)) { delta = pnorm / Scalar(.5); } } @@ -342,9 +342,9 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveOneStep(FVectorType &x) wa2 = (wa2-wa3)/pnorm; /* compute the qr factorization of the updated jacobian. */ - ei_r1updt<Scalar>(R, wa1, v_givens, w_givens, wa2, wa3, &sing); - ei_r1mpyq<Scalar>(n, n, fjac.data(), v_givens, w_givens); - ei_r1mpyq<Scalar>(1, n, qtf.data(), v_givens, w_givens); + internal::r1updt<Scalar>(R, wa1, v_givens, w_givens, wa2, wa3, &sing); + internal::r1mpyq<Scalar>(n, n, fjac.data(), v_givens, w_givens); + internal::r1mpyq<Scalar>(1, n, qtf.data(), v_givens, w_givens); jeval = false; } @@ -447,7 +447,7 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiffOneStep(FVectorType if (parameters.nb_of_superdiagonals<0) parameters.nb_of_superdiagonals= n-1; /* calculate the jacobian matrix. */ - if (ei_fdjac1(functor, x, fvec, fjac, parameters.nb_of_subdiagonals, parameters.nb_of_superdiagonals, parameters.epsfcn) <0) + if (internal::fdjac1(functor, x, fvec, fjac, parameters.nb_of_subdiagonals, parameters.nb_of_superdiagonals, parameters.epsfcn) <0) return HybridNonLinearSolverSpace::UserAksed; nfev += std::min(parameters.nb_of_subdiagonals+parameters.nb_of_superdiagonals+ 1, n); @@ -487,7 +487,7 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiffOneStep(FVectorType while (true) { /* determine the direction p. */ - ei_dogleg<Scalar>(R, diag, qtf, delta, wa1); + internal::dogleg<Scalar>(R, diag, qtf, delta, wa1); /* store the direction p and x + p. calculate the norm of p. */ wa1 = -wa1; @@ -507,14 +507,14 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiffOneStep(FVectorType /* compute the scaled actual reduction. */ actred = -1.; if (fnorm1 < fnorm) /* Computing 2nd power */ - actred = 1. - ei_abs2(fnorm1 / fnorm); + actred = 1. - internal::abs2(fnorm1 / fnorm); /* compute the scaled predicted reduction. */ wa3 = R.template triangularView<Upper>()*wa1 + qtf; temp = wa3.stableNorm(); prered = 0.; if (temp < fnorm) /* Computing 2nd power */ - prered = 1. - ei_abs2(temp / fnorm); + prered = 1. - internal::abs2(temp / fnorm); /* compute the ratio of the actual to the predicted reduction. */ ratio = 0.; @@ -531,7 +531,7 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiffOneStep(FVectorType ++ncsuc; if (ratio >= Scalar(.5) || ncsuc > 1) delta = std::max(delta, pnorm / Scalar(.5)); - if (ei_abs(ratio - 1.) <= Scalar(.1)) { + if (internal::abs(ratio - 1.) <= Scalar(.1)) { delta = pnorm / Scalar(.5); } } @@ -583,9 +583,9 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiffOneStep(FVectorType wa2 = (wa2-wa3)/pnorm; /* compute the qr factorization of the updated jacobian. */ - ei_r1updt<Scalar>(R, wa1, v_givens, w_givens, wa2, wa3, &sing); - ei_r1mpyq<Scalar>(n, n, fjac.data(), v_givens, w_givens); - ei_r1mpyq<Scalar>(1, n, qtf.data(), v_givens, w_givens); + internal::r1updt<Scalar>(R, wa1, v_givens, w_givens, wa2, wa3, &sing); + internal::r1mpyq<Scalar>(n, n, fjac.data(), v_givens, w_givens); + internal::r1mpyq<Scalar>(1, n, qtf.data(), v_givens, w_givens); jeval = false; } diff --git a/unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h b/unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h index a8f3f3e64..c43df3f7a 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h +++ b/unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h @@ -69,8 +69,8 @@ public: Parameters() : factor(Scalar(100.)) , maxfev(400) - , ftol(ei_sqrt(NumTraits<Scalar>::epsilon())) - , xtol(ei_sqrt(NumTraits<Scalar>::epsilon())) + , ftol(internal::sqrt(NumTraits<Scalar>::epsilon())) + , xtol(internal::sqrt(NumTraits<Scalar>::epsilon())) , gtol(Scalar(0.)) , epsfcn(Scalar(0.)) {} Scalar factor; @@ -86,7 +86,7 @@ public: LevenbergMarquardtSpace::Status lmder1( FVectorType &x, - const Scalar tol = ei_sqrt(NumTraits<Scalar>::epsilon()) + const Scalar tol = internal::sqrt(NumTraits<Scalar>::epsilon()) ); LevenbergMarquardtSpace::Status minimize(FVectorType &x); @@ -97,12 +97,12 @@ public: FunctorType &functor, FVectorType &x, Index *nfev, - const Scalar tol = ei_sqrt(NumTraits<Scalar>::epsilon()) + const Scalar tol = internal::sqrt(NumTraits<Scalar>::epsilon()) ); LevenbergMarquardtSpace::Status lmstr1( FVectorType &x, - const Scalar tol = ei_sqrt(NumTraits<Scalar>::epsilon()) + const Scalar tol = internal::sqrt(NumTraits<Scalar>::epsilon()) ); LevenbergMarquardtSpace::Status minimizeOptimumStorage(FVectorType &x); @@ -263,7 +263,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOneStep(FVectorType &x) if (fnorm != 0.) for (Index j = 0; j < n; ++j) if (wa2[permutation.indices()[j]] != 0.) - gnorm = std::max(gnorm, ei_abs( fjac.col(j).head(j+1).dot(qtf.head(j+1)/fnorm) / wa2[permutation.indices()[j]])); + gnorm = std::max(gnorm, internal::abs( fjac.col(j).head(j+1).dot(qtf.head(j+1)/fnorm) / wa2[permutation.indices()[j]])); /* test for convergence of the gradient norm. */ if (gnorm <= parameters.gtol) @@ -276,7 +276,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOneStep(FVectorType &x) do { /* determine the levenberg-marquardt parameter. */ - ei_lmpar2<Scalar>(qrfac, diag, qtf, delta, par, wa1); + internal::lmpar2<Scalar>(qrfac, diag, qtf, delta, par, wa1); /* store the direction p and x + p. calculate the norm of p. */ wa1 = -wa1; @@ -296,13 +296,13 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOneStep(FVectorType &x) /* compute the scaled actual reduction. */ actred = -1.; if (Scalar(.1) * fnorm1 < fnorm) - actred = 1. - ei_abs2(fnorm1 / fnorm); + actred = 1. - internal::abs2(fnorm1 / fnorm); /* compute the scaled predicted reduction and */ /* the scaled directional derivative. */ wa3 = fjac.template triangularView<Upper>() * (qrfac.colsPermutation().inverse() *wa1); - temp1 = ei_abs2(wa3.stableNorm() / fnorm); - temp2 = ei_abs2(ei_sqrt(par) * pnorm / fnorm); + temp1 = internal::abs2(wa3.stableNorm() / fnorm); + temp2 = internal::abs2(internal::sqrt(par) * pnorm / fnorm); prered = temp1 + temp2 / Scalar(.5); dirder = -(temp1 + temp2); @@ -340,9 +340,9 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOneStep(FVectorType &x) } /* tests for convergence. */ - if (ei_abs(actred) <= parameters.ftol && prered <= parameters.ftol && Scalar(.5) * ratio <= 1. && delta <= parameters.xtol * xnorm) + if (internal::abs(actred) <= parameters.ftol && prered <= parameters.ftol && Scalar(.5) * ratio <= 1. && delta <= parameters.xtol * xnorm) return LevenbergMarquardtSpace::RelativeErrorAndReductionTooSmall; - if (ei_abs(actred) <= parameters.ftol && prered <= parameters.ftol && Scalar(.5) * ratio <= 1.) + if (internal::abs(actred) <= parameters.ftol && prered <= parameters.ftol && Scalar(.5) * ratio <= 1.) return LevenbergMarquardtSpace::RelativeReductionTooSmall; if (delta <= parameters.xtol * xnorm) return LevenbergMarquardtSpace::RelativeErrorTooSmall; @@ -350,7 +350,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOneStep(FVectorType &x) /* tests for termination and stringent tolerances. */ if (nfev >= parameters.maxfev) return LevenbergMarquardtSpace::TooManyFunctionEvaluation; - if (ei_abs(actred) <= NumTraits<Scalar>::epsilon() && prered <= NumTraits<Scalar>::epsilon() && Scalar(.5) * ratio <= 1.) + if (internal::abs(actred) <= NumTraits<Scalar>::epsilon() && prered <= NumTraits<Scalar>::epsilon() && Scalar(.5) * ratio <= 1.) return LevenbergMarquardtSpace::FtolTooSmall; if (delta <= NumTraits<Scalar>::epsilon() * xnorm) return LevenbergMarquardtSpace::XtolTooSmall; @@ -451,7 +451,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorageOneStep(FVectorTyp Index rownb = 2; for (i = 0; i < m; ++i) { if (functor.df(x, wa3, rownb) < 0) return LevenbergMarquardtSpace::UserAsked; - ei_rwupdt<Scalar>(fjac, wa3, qtf, fvec[i]); + internal::rwupdt<Scalar>(fjac, wa3, qtf, fvec[i]); ++rownb; } ++njev; @@ -510,7 +510,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorageOneStep(FVectorTyp if (fnorm != 0.) for (j = 0; j < n; ++j) if (wa2[permutation.indices()[j]] != 0.) - gnorm = std::max(gnorm, ei_abs( fjac.col(j).head(j+1).dot(qtf.head(j+1)/fnorm) / wa2[permutation.indices()[j]])); + gnorm = std::max(gnorm, internal::abs( fjac.col(j).head(j+1).dot(qtf.head(j+1)/fnorm) / wa2[permutation.indices()[j]])); /* test for convergence of the gradient norm. */ if (gnorm <= parameters.gtol) @@ -523,7 +523,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorageOneStep(FVectorTyp do { /* determine the levenberg-marquardt parameter. */ - ei_lmpar<Scalar>(fjac, permutation.indices(), diag, qtf, delta, par, wa1); + internal::lmpar<Scalar>(fjac, permutation.indices(), diag, qtf, delta, par, wa1); /* store the direction p and x + p. calculate the norm of p. */ wa1 = -wa1; @@ -543,13 +543,13 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorageOneStep(FVectorTyp /* compute the scaled actual reduction. */ actred = -1.; if (Scalar(.1) * fnorm1 < fnorm) - actred = 1. - ei_abs2(fnorm1 / fnorm); + actred = 1. - internal::abs2(fnorm1 / fnorm); /* compute the scaled predicted reduction and */ /* the scaled directional derivative. */ wa3 = fjac.topLeftCorner(n,n).template triangularView<Upper>() * (permutation.inverse() * wa1); - temp1 = ei_abs2(wa3.stableNorm() / fnorm); - temp2 = ei_abs2(ei_sqrt(par) * pnorm / fnorm); + temp1 = internal::abs2(wa3.stableNorm() / fnorm); + temp2 = internal::abs2(internal::sqrt(par) * pnorm / fnorm); prered = temp1 + temp2 / Scalar(.5); dirder = -(temp1 + temp2); @@ -587,9 +587,9 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorageOneStep(FVectorTyp } /* tests for convergence. */ - if (ei_abs(actred) <= parameters.ftol && prered <= parameters.ftol && Scalar(.5) * ratio <= 1. && delta <= parameters.xtol * xnorm) + if (internal::abs(actred) <= parameters.ftol && prered <= parameters.ftol && Scalar(.5) * ratio <= 1. && delta <= parameters.xtol * xnorm) return LevenbergMarquardtSpace::RelativeErrorAndReductionTooSmall; - if (ei_abs(actred) <= parameters.ftol && prered <= parameters.ftol && Scalar(.5) * ratio <= 1.) + if (internal::abs(actred) <= parameters.ftol && prered <= parameters.ftol && Scalar(.5) * ratio <= 1.) return LevenbergMarquardtSpace::RelativeReductionTooSmall; if (delta <= parameters.xtol * xnorm) return LevenbergMarquardtSpace::RelativeErrorTooSmall; @@ -597,7 +597,7 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorageOneStep(FVectorTyp /* tests for termination and stringent tolerances. */ if (nfev >= parameters.maxfev) return LevenbergMarquardtSpace::TooManyFunctionEvaluation; - if (ei_abs(actred) <= NumTraits<Scalar>::epsilon() && prered <= NumTraits<Scalar>::epsilon() && Scalar(.5) * ratio <= 1.) + if (internal::abs(actred) <= NumTraits<Scalar>::epsilon() && prered <= NumTraits<Scalar>::epsilon() && Scalar(.5) * ratio <= 1.) return LevenbergMarquardtSpace::FtolTooSmall; if (delta <= NumTraits<Scalar>::epsilon() * xnorm) return LevenbergMarquardtSpace::XtolTooSmall; diff --git a/unsupported/Eigen/src/NonLinearOptimization/chkder.h b/unsupported/Eigen/src/NonLinearOptimization/chkder.h index 4cb4fbdef..e2bdf923c 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/chkder.h +++ b/unsupported/Eigen/src/NonLinearOptimization/chkder.h @@ -2,8 +2,10 @@ #define chkder_log10e 0.43429448190325182765 #define chkder_factor 100. +namespace internal { + template<typename Scalar> -void ei_chkder( +void chkder( const Matrix< Scalar, Dynamic, 1 > &x, const Matrix< Scalar, Dynamic, 1 > &fvec, const Matrix< Scalar, Dynamic, Dynamic > &fjac, @@ -15,9 +17,9 @@ void ei_chkder( { typedef DenseIndex Index; - const Scalar eps = ei_sqrt(NumTraits<Scalar>::epsilon()); + const Scalar eps = sqrt(NumTraits<Scalar>::epsilon()); const Scalar epsf = chkder_factor * NumTraits<Scalar>::epsilon(); - const Scalar epslog = chkder_log10e * ei_log(eps); + const Scalar epslog = chkder_log10e * log(eps); Scalar temp; const Index m = fvec.size(), n = x.size(); @@ -26,7 +28,7 @@ void ei_chkder( /* mode = 1. */ xp.resize(n); for (Index j = 0; j < n; ++j) { - temp = eps * ei_abs(x[j]); + temp = eps * abs(x[j]); if (temp == 0.) temp = eps; xp[j] = x[j] + temp; @@ -36,21 +38,22 @@ void ei_chkder( /* mode = 2. */ err.setZero(m); for (Index j = 0; j < n; ++j) { - temp = ei_abs(x[j]); + temp = abs(x[j]); if (temp == 0.) temp = 1.; err += temp * fjac.col(j); } for (Index i = 0; i < m; ++i) { temp = 1.; - if (fvec[i] != 0. && fvecp[i] != 0. && ei_abs(fvecp[i] - fvec[i]) >= epsf * ei_abs(fvec[i])) - temp = eps * ei_abs((fvecp[i] - fvec[i]) / eps - err[i]) / (ei_abs(fvec[i]) + ei_abs(fvecp[i])); + if (fvec[i] != 0. && fvecp[i] != 0. && abs(fvecp[i] - fvec[i]) >= epsf * abs(fvec[i])) + temp = eps * abs((fvecp[i] - fvec[i]) / eps - err[i]) / (abs(fvec[i]) + abs(fvecp[i])); err[i] = 1.; if (temp > NumTraits<Scalar>::epsilon() && temp < eps) - err[i] = (chkder_log10e * ei_log(temp) - epslog) / epslog; + err[i] = (chkder_log10e * log(temp) - epslog) / epslog; if (temp >= eps) err[i] = 0.; } } } +} // end namespace internal
\ No newline at end of file diff --git a/unsupported/Eigen/src/NonLinearOptimization/covar.h b/unsupported/Eigen/src/NonLinearOptimization/covar.h index 104898a30..6c77916f5 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/covar.h +++ b/unsupported/Eigen/src/NonLinearOptimization/covar.h @@ -1,9 +1,10 @@ +namespace internal { template <typename Scalar> -void ei_covar( +void covar( Matrix< Scalar, Dynamic, Dynamic > &r, const VectorXi &ipvt, - Scalar tol = ei_sqrt(NumTraits<Scalar>::epsilon()) ) + Scalar tol = sqrt(NumTraits<Scalar>::epsilon()) ) { typedef DenseIndex Index; @@ -14,14 +15,14 @@ void ei_covar( /* Function Body */ const Index n = r.cols(); - const Scalar tolr = tol * ei_abs(r(0,0)); + const Scalar tolr = tol * abs(r(0,0)); Matrix< Scalar, Dynamic, 1 > wa(n); assert(ipvt.size()==n); /* form the inverse of r in the full upper triangle of r. */ l = -1; for (k = 0; k < n; ++k) - if (ei_abs(r(k,k)) > tolr) { + if (abs(r(k,k)) > tolr) { r(k,k) = 1. / r(k,k); for (j = 0; j <= k-1; ++j) { temp = r(k,k) * r(j,k); @@ -61,3 +62,4 @@ void ei_covar( r.diagonal() = wa; } +} // end namespace internal diff --git a/unsupported/Eigen/src/NonLinearOptimization/dogleg.h b/unsupported/Eigen/src/NonLinearOptimization/dogleg.h index ab01d5c47..fffd9e0be 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/dogleg.h +++ b/unsupported/Eigen/src/NonLinearOptimization/dogleg.h @@ -1,6 +1,7 @@ +namespace internal { template <typename Scalar> -void ei_dogleg( +void dogleg( const Matrix< Scalar, Dynamic, Dynamic > &qrfac, const Matrix< Scalar, Dynamic, 1 > &diag, const Matrix< Scalar, Dynamic, 1 > &qtb, @@ -86,8 +87,8 @@ void ei_dogleg( /* at which the quadratic is minimized. */ bnorm = qtb.stableNorm(); temp = bnorm / gnorm * (bnorm / qnorm) * (sgnorm / delta); - temp = temp - delta / qnorm * ei_abs2(sgnorm / delta) + ei_sqrt(ei_abs2(temp - delta / qnorm) + (1.-ei_abs2(delta / qnorm)) * (1.-ei_abs2(sgnorm / delta))); - alpha = delta / qnorm * (1. - ei_abs2(sgnorm / delta)) / temp; + temp = temp - delta / qnorm * abs2(sgnorm / delta) + sqrt(abs2(temp - delta / qnorm) + (1.-abs2(delta / qnorm)) * (1.-abs2(sgnorm / delta))); + alpha = delta / qnorm * (1. - abs2(sgnorm / delta)) / temp; algo_end: /* form appropriate convex combination of the gauss-newton */ @@ -96,3 +97,4 @@ algo_end: x = temp * wa1 + alpha * x; } +} // end namespace internal diff --git a/unsupported/Eigen/src/NonLinearOptimization/fdjac1.h b/unsupported/Eigen/src/NonLinearOptimization/fdjac1.h index 74cf53b90..887b76fa1 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/fdjac1.h +++ b/unsupported/Eigen/src/NonLinearOptimization/fdjac1.h @@ -1,6 +1,7 @@ +namespace internal { template<typename FunctorType, typename Scalar> -DenseIndex ei_fdjac1( +DenseIndex fdjac1( const FunctorType &Functor, Matrix< Scalar, Dynamic, 1 > &x, Matrix< Scalar, Dynamic, 1 > &fvec, @@ -25,13 +26,13 @@ DenseIndex ei_fdjac1( Matrix< Scalar, Dynamic, 1 > wa1(n); Matrix< Scalar, Dynamic, 1 > wa2(n); - eps = ei_sqrt(std::max(epsfcn,epsmch)); + eps = sqrt(std::max(epsfcn,epsmch)); msum = ml + mu + 1; if (msum >= n) { /* computation of dense approximate jacobian. */ for (j = 0; j < n; ++j) { temp = x[j]; - h = eps * ei_abs(temp); + h = eps * abs(temp); if (h == 0.) h = eps; x[j] = temp + h; @@ -47,7 +48,7 @@ DenseIndex ei_fdjac1( for (k = 0; k < msum; ++k) { for (j = k; (msum<0) ? (j>n): (j<n); j += msum) { wa2[j] = x[j]; - h = eps * ei_abs(wa2[j]); + h = eps * abs(wa2[j]); if (h == 0.) h = eps; x[j] = wa2[j] + h; } @@ -56,7 +57,7 @@ DenseIndex ei_fdjac1( return iflag; for (j = k; (msum<0) ? (j>n): (j<n); j += msum) { x[j] = wa2[j]; - h = eps * ei_abs(wa2[j]); + h = eps * abs(wa2[j]); if (h == 0.) h = eps; fjac.col(j).setZero(); start = std::max<Index>(0,j-mu); @@ -68,3 +69,4 @@ DenseIndex ei_fdjac1( return 0; } +} // end namespace internal diff --git a/unsupported/Eigen/src/NonLinearOptimization/lmpar.h b/unsupported/Eigen/src/NonLinearOptimization/lmpar.h index 27138de96..a6bbc50ba 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/lmpar.h +++ b/unsupported/Eigen/src/NonLinearOptimization/lmpar.h @@ -1,6 +1,7 @@ +namespace internal { template <typename Scalar> -void ei_lmpar( +void lmpar( Matrix< Scalar, Dynamic, Dynamic > &r, const VectorXi &ipvt, const Matrix< Scalar, Dynamic, 1 > &diag, @@ -106,10 +107,10 @@ void ei_lmpar( /* evaluate the function at the current value of par. */ if (par == 0.) par = std::max(dwarf,Scalar(.001) * paru); /* Computing MAX */ - wa1 = ei_sqrt(par)* diag; + wa1 = sqrt(par)* diag; Matrix< Scalar, Dynamic, 1 > sdiag(n); - ei_qrsolv<Scalar>(r, ipvt, wa1, qtb, x, sdiag); + qrsolv<Scalar>(r, ipvt, wa1, qtb, x, sdiag); wa2 = diag.cwiseProduct(x); dxnorm = wa2.blueNorm(); @@ -119,7 +120,7 @@ void ei_lmpar( /* if the function is small enough, accept the current value */ /* of par. also test for the exceptional cases where parl */ /* is zero or the number of iterations has reached 10. */ - if (ei_abs(fp) <= Scalar(0.1) * delta || (parl == 0. && fp <= temp && temp < 0.) || iter == 10) + if (abs(fp) <= Scalar(0.1) * delta || (parl == 0. && fp <= temp && temp < 0.) || iter == 10) break; /* compute the newton correction. */ @@ -156,7 +157,7 @@ void ei_lmpar( } template <typename Scalar> -void ei_lmpar2( +void lmpar2( const ColPivHouseholderQR<Matrix< Scalar, Dynamic, Dynamic> > &qr, const Matrix< Scalar, Dynamic, 1 > &diag, const Matrix< Scalar, Dynamic, 1 > &qtb, @@ -243,10 +244,10 @@ void ei_lmpar2( /* evaluate the function at the current value of par. */ if (par == 0.) par = std::max(dwarf,Scalar(.001) * paru); /* Computing MAX */ - wa1 = ei_sqrt(par)* diag; + wa1 = sqrt(par)* diag; Matrix< Scalar, Dynamic, 1 > sdiag(n); - ei_qrsolv<Scalar>(s, qr.colsPermutation().indices(), wa1, qtb, x, sdiag); + qrsolv<Scalar>(s, qr.colsPermutation().indices(), wa1, qtb, x, sdiag); wa2 = diag.cwiseProduct(x); dxnorm = wa2.blueNorm(); @@ -256,7 +257,7 @@ void ei_lmpar2( /* if the function is small enough, accept the current value */ /* of par. also test for the exceptional cases where parl */ /* is zero or the number of iterations has reached 10. */ - if (ei_abs(fp) <= Scalar(0.1) * delta || (parl == 0. && fp <= temp && temp < 0.) || iter == 10) + if (abs(fp) <= Scalar(0.1) * delta || (parl == 0. && fp <= temp && temp < 0.) || iter == 10) break; /* compute the newton correction. */ @@ -286,3 +287,4 @@ void ei_lmpar2( return; } +} // end namespace internal diff --git a/unsupported/Eigen/src/NonLinearOptimization/qrsolv.h b/unsupported/Eigen/src/NonLinearOptimization/qrsolv.h index 2a602fedf..cb1764a41 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/qrsolv.h +++ b/unsupported/Eigen/src/NonLinearOptimization/qrsolv.h @@ -1,9 +1,10 @@ +namespace internal { // TODO : once qrsolv2 is removed, use ColPivHouseholderQR or PermutationMatrix instead of ipvt template <typename Scalar> -void ei_qrsolv( +void qrsolv( Matrix< Scalar, Dynamic, Dynamic > &s, - // TODO : use a PermutationMatrix once ei_lmpar is no more: + // TODO : use a PermutationMatrix once lmpar is no more: const VectorXi &ipvt, const Matrix< Scalar, Dynamic, 1 > &diag, const Matrix< Scalar, Dynamic, 1 > &qtb, @@ -83,3 +84,4 @@ void ei_qrsolv( for (j = 0; j < n; ++j) x[ipvt[j]] = wa[j]; } +} // end namespace internal diff --git a/unsupported/Eigen/src/NonLinearOptimization/r1mpyq.h b/unsupported/Eigen/src/NonLinearOptimization/r1mpyq.h index b2ea20d77..ffe505cd5 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/r1mpyq.h +++ b/unsupported/Eigen/src/NonLinearOptimization/r1mpyq.h @@ -1,8 +1,9 @@ +namespace internal { // TODO : move this to GivensQR once there's such a thing in Eigen template <typename Scalar> -void ei_r1mpyq(DenseIndex m, DenseIndex n, Scalar *a, const std::vector<JacobiRotation<Scalar> > &v_givens, const std::vector<JacobiRotation<Scalar> > &w_givens) +void r1mpyq(DenseIndex m, DenseIndex n, Scalar *a, const std::vector<JacobiRotation<Scalar> > &v_givens, const std::vector<JacobiRotation<Scalar> > &w_givens) { typedef DenseIndex Index; @@ -22,3 +23,4 @@ void ei_r1mpyq(DenseIndex m, DenseIndex n, Scalar *a, const std::vector<JacobiRo } } +} // end namespace internal diff --git a/unsupported/Eigen/src/NonLinearOptimization/r1updt.h b/unsupported/Eigen/src/NonLinearOptimization/r1updt.h index 881327af7..0b8ede119 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/r1updt.h +++ b/unsupported/Eigen/src/NonLinearOptimization/r1updt.h @@ -1,6 +1,7 @@ +namespace internal { template <typename Scalar> -void ei_r1updt( +void r1updt( Matrix< Scalar, Dynamic, Dynamic > &s, const Matrix< Scalar, Dynamic, 1> &u, std::vector<JacobiRotation<Scalar> > &v_givens, @@ -18,7 +19,7 @@ void ei_r1updt( Scalar temp; JacobiRotation<Scalar> givens; - // ei_r1updt had a broader usecase, but we dont use it here. And, more + // r1updt had a broader usecase, but we dont use it here. And, more // importantly, we can not test it. assert(m==n); assert(u.size()==m); @@ -88,3 +89,4 @@ void ei_r1updt( return; } +} // end namespace internal diff --git a/unsupported/Eigen/src/NonLinearOptimization/rwupdt.h b/unsupported/Eigen/src/NonLinearOptimization/rwupdt.h index ec97b707a..96263f8c0 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/rwupdt.h +++ b/unsupported/Eigen/src/NonLinearOptimization/rwupdt.h @@ -1,6 +1,7 @@ +namespace internal { template <typename Scalar> -void ei_rwupdt( +void rwupdt( Matrix< Scalar, Dynamic, Dynamic > &r, const Matrix< Scalar, Dynamic, 1> &w, Matrix< Scalar, Dynamic, 1> &b, @@ -44,3 +45,4 @@ void ei_rwupdt( } } +} // end namespace internal
\ No newline at end of file diff --git a/unsupported/Eigen/src/NumericalDiff/NumericalDiff.h b/unsupported/Eigen/src/NumericalDiff/NumericalDiff.h index e840dd461..dbf27c481 100644 --- a/unsupported/Eigen/src/NumericalDiff/NumericalDiff.h +++ b/unsupported/Eigen/src/NumericalDiff/NumericalDiff.h @@ -80,7 +80,7 @@ public: Scalar h; int nfev=0; const typename InputType::Index n = _x.size(); - const Scalar eps = ei_sqrt((std::max(epsfcn,NumTraits<Scalar>::epsilon() ))); + const Scalar eps = internal::sqrt((std::max(epsfcn,NumTraits<Scalar>::epsilon() ))); ValueType val1, val2; InputType x = _x; // TODO : we should do this only if the size is not already known @@ -102,7 +102,7 @@ public: // Function Body for (int j = 0; j < n; ++j) { - h = eps * ei_abs(x[j]); + h = eps * internal::abs(x[j]); if (h == 0.) { h = eps; } diff --git a/unsupported/Eigen/src/Polynomials/Companion.h b/unsupported/Eigen/src/Polynomials/Companion.h index bbd9073b3..608951d3c 100644 --- a/unsupported/Eigen/src/Polynomials/Companion.h +++ b/unsupported/Eigen/src/Polynomials/Companion.h @@ -31,14 +31,16 @@ #ifndef EIGEN_PARSED_BY_DOXYGEN +namespace internal { + template <typename T> -T ei_radix(){ return 2; } +T radix(){ return 2; } template <typename T> -T ei_radix2(){ return ei_radix<T>()*ei_radix<T>(); } +T radix2(){ return radix<T>()*radix<T>(); } template<int Size> -struct ei_decrement_if_fixed_size +struct decrement_if_fixed_size { enum { ret = (Size == Dynamic) ? Dynamic : Size-1 }; @@ -47,14 +49,14 @@ struct ei_decrement_if_fixed_size #endif template< typename _Scalar, int _Deg > -class ei_companion +class companion { public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_Deg==Dynamic ? Dynamic : _Deg) enum { Deg = _Deg, - Deg_1=ei_decrement_if_fixed_size<Deg>::ret + Deg_1=decrement_if_fixed_size<Deg>::ret }; typedef _Scalar Scalar; @@ -92,7 +94,7 @@ class ei_companion } template<typename VectorType> - ei_companion( const VectorType& poly ){ + companion( const VectorType& poly ){ setPolynomial( poly ); } public: @@ -150,7 +152,7 @@ class ei_companion template< typename _Scalar, int _Deg > inline -bool ei_companion<_Scalar,_Deg>::balanced( Scalar colNorm, Scalar rowNorm, +bool companion<_Scalar,_Deg>::balanced( Scalar colNorm, Scalar rowNorm, bool& isBalanced, Scalar& colB, Scalar& rowB ) { if( Scalar(0) == colNorm || Scalar(0) == rowNorm ){ return true; } @@ -161,22 +163,22 @@ bool ei_companion<_Scalar,_Deg>::balanced( Scalar colNorm, Scalar rowNorm, // \f$ 2^{2\sigma-1} < rowNorm / colNorm \le 2^{2\sigma+1} \f$ // then the balancing coefficient for the row is \f$ 1/2^{\sigma} \f$ // and the balancing coefficient for the column is \f$ 2^{\sigma} \f$ - rowB = rowNorm / ei_radix<Scalar>(); + rowB = rowNorm / radix<Scalar>(); colB = Scalar(1); const Scalar s = colNorm + rowNorm; while (colNorm < rowB) { - colB *= ei_radix<Scalar>(); - colNorm *= ei_radix2<Scalar>(); + colB *= radix<Scalar>(); + colNorm *= radix2<Scalar>(); } - rowB = rowNorm * ei_radix<Scalar>(); + rowB = rowNorm * radix<Scalar>(); while (colNorm >= rowB) { - colB /= ei_radix<Scalar>(); - colNorm /= ei_radix2<Scalar>(); + colB /= radix<Scalar>(); + colNorm /= radix2<Scalar>(); } //This line is used to avoid insubstantial balancing @@ -193,7 +195,7 @@ bool ei_companion<_Scalar,_Deg>::balanced( Scalar colNorm, Scalar rowNorm, template< typename _Scalar, int _Deg > inline -bool ei_companion<_Scalar,_Deg>::balancedR( Scalar colNorm, Scalar rowNorm, +bool companion<_Scalar,_Deg>::balancedR( Scalar colNorm, Scalar rowNorm, bool& isBalanced, Scalar& colB, Scalar& rowB ) { if( Scalar(0) == colNorm || Scalar(0) == rowNorm ){ return true; } @@ -204,9 +206,9 @@ bool ei_companion<_Scalar,_Deg>::balancedR( Scalar colNorm, Scalar rowNorm, * of the row and column norm */ const _Scalar q = colNorm/rowNorm; - if( !ei_isApprox( q, _Scalar(1) ) ) + if( !isApprox( q, _Scalar(1) ) ) { - rowB = ei_sqrt( colNorm/rowNorm ); + rowB = sqrt( colNorm/rowNorm ); colB = Scalar(1)/rowB; isBalanced = false; @@ -219,7 +221,7 @@ bool ei_companion<_Scalar,_Deg>::balancedR( Scalar colNorm, Scalar rowNorm, template< typename _Scalar, int _Deg > -void ei_companion<_Scalar,_Deg>::balance() +void companion<_Scalar,_Deg>::balance() { EIGEN_STATIC_ASSERT( Deg == Dynamic || 1 < Deg, YOU_MADE_A_PROGRAMMING_MISTAKE ); const Index deg = m_monic.size(); @@ -234,8 +236,8 @@ void ei_companion<_Scalar,_Deg>::balance() //First row, first column excluding the diagonal //============================================== - colNorm = ei_abs(m_bl_diag[0]); - rowNorm = ei_abs(m_monic[0]); + colNorm = abs(m_bl_diag[0]); + rowNorm = abs(m_monic[0]); //Compute balancing of the row and the column if( !balanced( colNorm, rowNorm, hasConverged, colB, rowB ) ) @@ -249,10 +251,10 @@ void ei_companion<_Scalar,_Deg>::balance() for( Index i=1; i<deg_1; ++i ) { // column norm, excluding the diagonal - colNorm = ei_abs(m_bl_diag[i]); + colNorm = abs(m_bl_diag[i]); // row norm, excluding the diagonal - rowNorm = ei_abs(m_bl_diag[i-1]) + ei_abs(m_monic[i]); + rowNorm = abs(m_bl_diag[i-1]) + abs(m_monic[i]); //Compute balancing of the row and the column if( !balanced( colNorm, rowNorm, hasConverged, colB, rowB ) ) @@ -268,7 +270,7 @@ void ei_companion<_Scalar,_Deg>::balance() const Index ebl = m_bl_diag.size()-1; VectorBlock<RightColumn,Deg_1> headMonic( m_monic, 0, deg_1 ); colNorm = headMonic.array().abs().sum(); - rowNorm = ei_abs( m_bl_diag[ebl] ); + rowNorm = abs( m_bl_diag[ebl] ); //Compute balancing of the row and the column if( !balanced( colNorm, rowNorm, hasConverged, colB, rowB ) ) @@ -279,5 +281,6 @@ void ei_companion<_Scalar,_Deg>::balance() } } +} // end namespace internal #endif // EIGEN_COMPANION_H diff --git a/unsupported/Eigen/src/Polynomials/PolynomialSolver.h b/unsupported/Eigen/src/Polynomials/PolynomialSolver.h index ba14b5911..417b93df2 100644 --- a/unsupported/Eigen/src/Polynomials/PolynomialSolver.h +++ b/unsupported/Eigen/src/Polynomials/PolynomialSolver.h @@ -85,7 +85,7 @@ class PolynomialSolverBase bi_seq.clear(); for(Index i=0; i<m_roots.size(); ++i ) { - if( ei_abs( m_roots[i].imag() ) < absImaginaryThreshold ){ + if( internal::abs( m_roots[i].imag() ) < absImaginaryThreshold ){ bi_seq.push_back( m_roots[i].real() ); } } } @@ -95,10 +95,10 @@ class PolynomialSolverBase inline const RootType& selectComplexRoot_withRespectToNorm( squaredNormBinaryPredicate& pred ) const { Index res=0; - RealScalar norm2 = ei_abs2( m_roots[0] ); + RealScalar norm2 = internal::abs2( m_roots[0] ); for( Index i=1; i<m_roots.size(); ++i ) { - const RealScalar currNorm2 = ei_abs2( m_roots[i] ); + const RealScalar currNorm2 = internal::abs2( m_roots[i] ); if( pred( currNorm2, norm2 ) ){ res=i; norm2=currNorm2; } } @@ -137,7 +137,7 @@ class PolynomialSolverBase for( Index i=0; i<m_roots.size(); ++i ) { - if( ei_abs( m_roots[i].imag() ) < absImaginaryThreshold ) + if( internal::abs( m_roots[i].imag() ) < absImaginaryThreshold ) { if( !hasArealRoot ) { @@ -157,11 +157,11 @@ class PolynomialSolverBase } else { - if( ei_abs( m_roots[i].imag() ) < ei_abs( m_roots[res].imag() ) ){ + if( internal::abs( m_roots[i].imag() ) < internal::abs( m_roots[res].imag() ) ){ res = i; } } } - return ei_real_ref(m_roots[res]); + return internal::real_ref(m_roots[res]); } @@ -177,7 +177,7 @@ class PolynomialSolverBase for( Index i=0; i<m_roots.size(); ++i ) { - if( ei_abs( m_roots[i].imag() ) < absImaginaryThreshold ) + if( internal::abs( m_roots[i].imag() ) < absImaginaryThreshold ) { if( !hasArealRoot ) { @@ -197,11 +197,11 @@ class PolynomialSolverBase } else { - if( ei_abs( m_roots[i].imag() ) < ei_abs( m_roots[res].imag() ) ){ + if( internal::abs( m_roots[i].imag() ) < internal::abs( m_roots[res].imag() ) ){ res = i; } } } - return ei_real_ref(m_roots[res]); + return internal::real_ref(m_roots[res]); } public: @@ -355,7 +355,7 @@ class PolynomialSolver : public PolynomialSolverBase<_Scalar,_Deg> void compute( const OtherPolynomial& poly ) { assert( Scalar(0) != poly[poly.size()-1] ); - ei_companion<Scalar,_Deg> companion( poly ); + internal::companion<Scalar,_Deg> companion( poly ); companion.balance(); m_eigenSolver.compute( companion.denseMatrix() ); m_roots = m_eigenSolver.eigenvalues(); diff --git a/unsupported/Eigen/src/Polynomials/PolynomialUtils.h b/unsupported/Eigen/src/Polynomials/PolynomialUtils.h index d10b8f4dc..65942c52a 100644 --- a/unsupported/Eigen/src/Polynomials/PolynomialUtils.h +++ b/unsupported/Eigen/src/Polynomials/PolynomialUtils.h @@ -60,7 +60,7 @@ T poly_eval( const Polynomials& poly, const T& x ) { typedef typename NumTraits<T>::Real Real; - if( ei_abs2( x ) <= Real(1) ){ + if( internal::abs2( x ) <= Real(1) ){ return poly_eval_horner( poly, x ); } else { @@ -95,7 +95,7 @@ typename NumTraits<typename Polynomial::Scalar>::Real cauchy_max_bound( const Po Real cb(0); for( DenseIndex i=0; i<poly.size()-1; ++i ){ - cb += ei_abs(poly[i]*inv_leading_coeff); } + cb += internal::abs(poly[i]*inv_leading_coeff); } return cb + Real(1); } @@ -120,7 +120,7 @@ typename NumTraits<typename Polynomial::Scalar>::Real cauchy_min_bound( const Po const Scalar inv_min_coeff = Scalar(1)/poly[i]; Real cb(1); for( DenseIndex j=i+1; j<poly.size(); ++j ){ - cb += ei_abs(poly[j]*inv_min_coeff); } + cb += internal::abs(poly[j]*inv_min_coeff); } return Real(1)/cb; } diff --git a/unsupported/Eigen/src/Skyline/SkylineInplaceLU.h b/unsupported/Eigen/src/Skyline/SkylineInplaceLU.h index fa8f81908..51537402e 100644 --- a/unsupported/Eigen/src/Skyline/SkylineInplaceLU.h +++ b/unsupported/Eigen/src/Skyline/SkylineInplaceLU.h @@ -134,8 +134,8 @@ void SkylineInplaceLU<MatrixType>::compute() { const size_t rows = m_lu.rows(); const size_t cols = m_lu.cols(); - ei_assert(rows == cols && "We do not (yet) support rectangular LU."); - ei_assert(!m_lu.IsRowMajor && "LU decomposition does not work with rowMajor Storage"); + eigen_assert(rows == cols && "We do not (yet) support rectangular LU."); + eigen_assert(!m_lu.IsRowMajor && "LU decomposition does not work with rowMajor Storage"); for (Index row = 0; row < rows; row++) { const double pivot = m_lu.coeffDiag(row); @@ -198,8 +198,8 @@ void SkylineInplaceLU<MatrixType>::computeRowMajor() { const size_t rows = m_lu.rows(); const size_t cols = m_lu.cols(); - ei_assert(rows == cols && "We do not (yet) support rectangular LU."); - ei_assert(m_lu.IsRowMajor && "You're trying to apply rowMajor decomposition on a ColMajor matrix !"); + eigen_assert(rows == cols && "We do not (yet) support rectangular LU."); + eigen_assert(m_lu.IsRowMajor && "You're trying to apply rowMajor decomposition on a ColMajor matrix !"); for (Index row = 0; row < rows; row++) { typename MatrixType::InnerLowerIterator llIt(m_lu, row); diff --git a/unsupported/Eigen/src/Skyline/SkylineMatrix.h b/unsupported/Eigen/src/Skyline/SkylineMatrix.h index 20fafafa8..31810df08 100644 --- a/unsupported/Eigen/src/Skyline/SkylineMatrix.h +++ b/unsupported/Eigen/src/Skyline/SkylineMatrix.h @@ -43,8 +43,9 @@ * * */ +namespace internal { template<typename _Scalar, int _Options> -struct ei_traits<SkylineMatrix<_Scalar, _Options> > { +struct traits<SkylineMatrix<_Scalar, _Options> > { typedef _Scalar Scalar; typedef Sparse StorageKind; @@ -57,6 +58,7 @@ struct ei_traits<SkylineMatrix<_Scalar, _Options> > { CoeffReadCost = NumTraits<Scalar>::ReadCost, }; }; +} template<typename _Scalar, int _Options> class SkylineMatrix @@ -158,8 +160,8 @@ public: const Index outer = IsRowMajor ? row : col; const Index inner = IsRowMajor ? col : row; - ei_assert(outer < outerSize()); - ei_assert(inner < innerSize()); + eigen_assert(outer < outerSize()); + eigen_assert(inner < innerSize()); if (outer == inner) return this->m_data.diag(outer); @@ -207,8 +209,8 @@ public: const Index outer = IsRowMajor ? row : col; const Index inner = IsRowMajor ? col : row; - ei_assert(outer < outerSize()); - ei_assert(inner < innerSize()); + eigen_assert(outer < outerSize()); + eigen_assert(inner < innerSize()); if (outer == inner) return this->m_data.diag(outer); @@ -217,34 +219,34 @@ public: if (col > row) //upper matrix { const Index minOuterIndex = inner - m_data.upperProfile(inner); - ei_assert(outer >= minOuterIndex && "you try to acces a coeff that do not exist in the storage"); + eigen_assert(outer >= minOuterIndex && "you try to acces a coeff that do not exist in the storage"); return this->m_data.upper(m_colStartIndex[inner] + outer - (inner - m_data.upperProfile(inner))); } if (col < row) //lower matrix { const Index minInnerIndex = outer - m_data.lowerProfile(outer); - ei_assert(inner >= minInnerIndex && "you try to acces a coeff that do not exist in the storage"); + eigen_assert(inner >= minInnerIndex && "you try to acces a coeff that do not exist in the storage"); return this->m_data.lower(m_rowStartIndex[outer] + inner - (outer - m_data.lowerProfile(outer))); } } else { if (outer > inner) //upper matrix { const Index maxOuterIndex = inner + m_data.upperProfile(inner); - ei_assert(outer <= maxOuterIndex && "you try to acces a coeff that do not exist in the storage"); + eigen_assert(outer <= maxOuterIndex && "you try to acces a coeff that do not exist in the storage"); return this->m_data.upper(m_colStartIndex[inner] + (outer - inner)); } if (outer < inner) //lower matrix { const Index maxInnerIndex = outer + m_data.lowerProfile(outer); - ei_assert(inner <= maxInnerIndex && "you try to acces a coeff that do not exist in the storage"); + eigen_assert(inner <= maxInnerIndex && "you try to acces a coeff that do not exist in the storage"); return this->m_data.lower(m_rowStartIndex[outer] + (inner - outer)); } } } inline Scalar coeffDiag(Index idx) const { - ei_assert(idx < outerSize()); - ei_assert(idx < innerSize()); + eigen_assert(idx < outerSize()); + eigen_assert(idx < innerSize()); return this->m_data.diag(idx); } @@ -252,9 +254,9 @@ public: const Index outer = IsRowMajor ? row : col; const Index inner = IsRowMajor ? col : row; - ei_assert(outer < outerSize()); - ei_assert(inner < innerSize()); - ei_assert(inner != outer); + eigen_assert(outer < outerSize()); + eigen_assert(inner < innerSize()); + eigen_assert(inner != outer); if (IsRowMajor) { const Index minInnerIndex = outer - m_data.lowerProfile(outer); @@ -276,9 +278,9 @@ public: const Index outer = IsRowMajor ? row : col; const Index inner = IsRowMajor ? col : row; - ei_assert(outer < outerSize()); - ei_assert(inner < innerSize()); - ei_assert(inner != outer); + eigen_assert(outer < outerSize()); + eigen_assert(inner < innerSize()); + eigen_assert(inner != outer); if (IsRowMajor) { const Index minOuterIndex = inner - m_data.upperProfile(inner); @@ -296,8 +298,8 @@ public: } inline Scalar& coeffRefDiag(Index idx) { - ei_assert(idx < outerSize()); - ei_assert(idx < innerSize()); + eigen_assert(idx < outerSize()); + eigen_assert(idx < innerSize()); return this->m_data.diag(idx); } @@ -305,17 +307,17 @@ public: const Index outer = IsRowMajor ? row : col; const Index inner = IsRowMajor ? col : row; - ei_assert(outer < outerSize()); - ei_assert(inner < innerSize()); - ei_assert(inner != outer); + eigen_assert(outer < outerSize()); + eigen_assert(inner < innerSize()); + eigen_assert(inner != outer); if (IsRowMajor) { const Index minInnerIndex = outer - m_data.lowerProfile(outer); - ei_assert(inner >= minInnerIndex && "you try to acces a coeff that do not exist in the storage"); + eigen_assert(inner >= minInnerIndex && "you try to acces a coeff that do not exist in the storage"); return this->m_data.lower(m_rowStartIndex[outer] + inner - (outer - m_data.lowerProfile(outer))); } else { const Index maxInnerIndex = outer + m_data.lowerProfile(outer); - ei_assert(inner <= maxInnerIndex && "you try to acces a coeff that do not exist in the storage"); + eigen_assert(inner <= maxInnerIndex && "you try to acces a coeff that do not exist in the storage"); return this->m_data.lower(m_rowStartIndex[outer] + (inner - outer)); } } @@ -324,9 +326,9 @@ public: const Index outer = IsRowMajor ? row : col; const Index inner = IsRowMajor ? col : row; - ei_assert(outer < outerSize()); - ei_assert(inner < innerSize()); - ei_assert(inner != outer); + eigen_assert(outer < outerSize()); + eigen_assert(inner < innerSize()); + eigen_assert(inner != outer); if (IsRowMajor) { const Index minInnerIndex = outer - m_data.lowerProfile(outer); @@ -341,17 +343,17 @@ public: const Index outer = IsRowMajor ? row : col; const Index inner = IsRowMajor ? col : row; - ei_assert(outer < outerSize()); - ei_assert(inner < innerSize()); - ei_assert(inner != outer); + eigen_assert(outer < outerSize()); + eigen_assert(inner < innerSize()); + eigen_assert(inner != outer); if (IsRowMajor) { const Index minOuterIndex = inner - m_data.upperProfile(inner); - ei_assert(outer >= minOuterIndex && "you try to acces a coeff that do not exist in the storage"); + eigen_assert(outer >= minOuterIndex && "you try to acces a coeff that do not exist in the storage"); return this->m_data.upper(m_colStartIndex[inner] + outer - (inner - m_data.upperProfile(inner))); } else { const Index maxOuterIndex = inner + m_data.upperProfile(inner); - ei_assert(outer <= maxOuterIndex && "you try to acces a coeff that do not exist in the storage"); + eigen_assert(outer <= maxOuterIndex && "you try to acces a coeff that do not exist in the storage"); return this->m_data.upper(m_colStartIndex[inner] + (outer - inner)); } } @@ -360,9 +362,9 @@ public: const Index outer = IsRowMajor ? row : col; const Index inner = IsRowMajor ? col : row; - ei_assert(outer < outerSize()); - ei_assert(inner < innerSize()); - ei_assert(inner != outer); + eigen_assert(outer < outerSize()); + eigen_assert(inner < innerSize()); + eigen_assert(inner != outer); if (IsRowMajor) { const Index minOuterIndex = inner - m_data.upperProfile(inner); @@ -412,8 +414,8 @@ public: const Index outer = IsRowMajor ? row : col; const Index inner = IsRowMajor ? col : row; - ei_assert(outer < outerSize()); - ei_assert(inner < innerSize()); + eigen_assert(outer < outerSize()); + eigen_assert(inner < innerSize()); if (outer == inner) return m_data.diag(col); @@ -549,7 +551,7 @@ public: else m_data.resize(rows(), cols(), rows(), m_colStartIndex[cols()] + 1, m_rowStartIndex[rows()] + 1); - // ei_assert(rows() == cols() && "memory reorganisatrion only works with suare matrix"); + // eigen_assert(rows() == cols() && "memory reorganisatrion only works with suare matrix"); // // Scalar* newArray = new Scalar[m_colStartIndex[cols()] + 1 + m_rowStartIndex[rows()] + 1]; // Index dataIdx = 0; @@ -601,7 +603,7 @@ public: const Index diagSize = rows > cols ? cols : rows; m_innerSize = IsRowMajor ? cols : rows; - ei_assert(rows == cols && "Skyline matrix must be square matrix"); + eigen_assert(rows == cols && "Skyline matrix must be square matrix"); if (diagSize % 2) { // diagSize is odd const Index k = (diagSize - 1) / 2; diff --git a/unsupported/Eigen/src/Skyline/SkylineMatrixBase.h b/unsupported/Eigen/src/Skyline/SkylineMatrixBase.h index 5f577de3d..4d0c2397c 100644 --- a/unsupported/Eigen/src/Skyline/SkylineMatrixBase.h +++ b/unsupported/Eigen/src/Skyline/SkylineMatrixBase.h @@ -39,26 +39,26 @@ template<typename Derived> class SkylineMatrixBase : public EigenBase<Derived> { public: - typedef typename ei_traits<Derived>::Scalar Scalar; - typedef typename ei_traits<Derived>::StorageKind StorageKind; - typedef typename ei_index<StorageKind>::type Index; + typedef typename internal::traits<Derived>::Scalar Scalar; + typedef typename internal::traits<Derived>::StorageKind StorageKind; + typedef typename internal::index<StorageKind>::type Index; enum { - RowsAtCompileTime = ei_traits<Derived>::RowsAtCompileTime, + RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime, /**< The number of rows at compile-time. This is just a copy of the value provided * by the \a Derived type. If a value is not known at compile-time, * it is set to the \a Dynamic constant. * \sa MatrixBase::rows(), MatrixBase::cols(), ColsAtCompileTime, SizeAtCompileTime */ - ColsAtCompileTime = ei_traits<Derived>::ColsAtCompileTime, + ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime, /**< The number of columns at compile-time. This is just a copy of the value provided * by the \a Derived type. If a value is not known at compile-time, * it is set to the \a Dynamic constant. * \sa MatrixBase::rows(), MatrixBase::cols(), RowsAtCompileTime, SizeAtCompileTime */ - SizeAtCompileTime = (ei_size_at_compile_time<ei_traits<Derived>::RowsAtCompileTime, - ei_traits<Derived>::ColsAtCompileTime>::ret), + SizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::RowsAtCompileTime, + internal::traits<Derived>::ColsAtCompileTime>::ret), /**< This is equal to the number of coefficients, i.e. the number of * rows times the number of columns, or to \a Dynamic if this is not * known at compile-time. \sa RowsAtCompileTime, ColsAtCompileTime */ @@ -66,7 +66,7 @@ public: MaxRowsAtCompileTime = RowsAtCompileTime, MaxColsAtCompileTime = ColsAtCompileTime, - MaxSizeAtCompileTime = (ei_size_at_compile_time<MaxRowsAtCompileTime, + MaxSizeAtCompileTime = (internal::size_at_compile_time<MaxRowsAtCompileTime, MaxColsAtCompileTime>::ret), IsVectorAtCompileTime = RowsAtCompileTime == 1 || ColsAtCompileTime == 1, @@ -75,12 +75,12 @@ public: * we are dealing with a column-vector (if there is only one column) or with * a row-vector (if there is only one row). */ - Flags = ei_traits<Derived>::Flags, + Flags = internal::traits<Derived>::Flags, /**< This stores expression \ref flags flags which may or may not be inherited by new expressions * constructed from this one. See the \ref flags "list of flags". */ - CoeffReadCost = ei_traits<Derived>::CoeffReadCost, + CoeffReadCost = internal::traits<Derived>::CoeffReadCost, /**< This is a rough measure of how expensive it is to read one coefficient from * this expression. */ @@ -212,8 +212,8 @@ public: * Notice that in the case of a plain matrix or vector (not an expression) this function just returns * a const reference, in order to avoid a useless copy. */ - EIGEN_STRONG_INLINE const typename ei_eval<Derived, IsSkyline>::type eval() const { - return typename ei_eval<Derived>::type(derived()); + EIGEN_STRONG_INLINE const typename internal::eval<Derived, IsSkyline>::type eval() const { + return typename internal::eval<Derived>::type(derived()); } protected: diff --git a/unsupported/Eigen/src/Skyline/SkylineProduct.h b/unsupported/Eigen/src/Skyline/SkylineProduct.h index aabd07241..5a374743f 100644 --- a/unsupported/Eigen/src/Skyline/SkylineProduct.h +++ b/unsupported/Eigen/src/Skyline/SkylineProduct.h @@ -27,17 +27,17 @@ template<typename Lhs, typename Rhs, int ProductMode> struct SkylineProductReturnType { - typedef const typename ei_nested<Lhs, Rhs::RowsAtCompileTime>::type LhsNested; - typedef const typename ei_nested<Rhs, Lhs::RowsAtCompileTime>::type RhsNested; + typedef const typename internal::nested<Lhs, Rhs::RowsAtCompileTime>::type LhsNested; + typedef const typename internal::nested<Rhs, Lhs::RowsAtCompileTime>::type RhsNested; typedef SkylineProduct<LhsNested, RhsNested, ProductMode> Type; }; template<typename LhsNested, typename RhsNested, int ProductMode> -struct ei_traits<SkylineProduct<LhsNested, RhsNested, ProductMode> > { +struct internal::traits<SkylineProduct<LhsNested, RhsNested, ProductMode> > { // clean the nested types: - typedef typename ei_cleantype<LhsNested>::type _LhsNested; - typedef typename ei_cleantype<RhsNested>::type _RhsNested; + typedef typename internal::cleantype<LhsNested>::type _LhsNested; + typedef typename internal::cleantype<RhsNested>::type _RhsNested; typedef typename _LhsNested::Scalar Scalar; enum { @@ -65,29 +65,30 @@ struct ei_traits<SkylineProduct<LhsNested, RhsNested, ProductMode> > { CoeffReadCost = Dynamic }; - typedef typename ei_meta_if<ResultIsSkyline, + typedef typename internal::meta_if<ResultIsSkyline, SkylineMatrixBase<SkylineProduct<LhsNested, RhsNested, ProductMode> >, MatrixBase<SkylineProduct<LhsNested, RhsNested, ProductMode> > >::ret Base; }; +namespace internal { template<typename LhsNested, typename RhsNested, int ProductMode> -class SkylineProduct : ei_no_assignment_operator, -public ei_traits<SkylineProduct<LhsNested, RhsNested, ProductMode> >::Base { +class SkylineProduct : no_assignment_operator, +public traits<SkylineProduct<LhsNested, RhsNested, ProductMode> >::Base { public: EIGEN_GENERIC_PUBLIC_INTERFACE(SkylineProduct) private: - typedef typename ei_traits<SkylineProduct>::_LhsNested _LhsNested; - typedef typename ei_traits<SkylineProduct>::_RhsNested _RhsNested; + typedef typename traits<SkylineProduct>::_LhsNested _LhsNested; + typedef typename traits<SkylineProduct>::_RhsNested _RhsNested; public: template<typename Lhs, typename Rhs> EIGEN_STRONG_INLINE SkylineProduct(const Lhs& lhs, const Rhs& rhs) : m_lhs(lhs), m_rhs(rhs) { - ei_assert(lhs.cols() == rhs.rows()); + eigen_assert(lhs.cols() == rhs.rows()); enum { ProductIsValid = _LhsNested::ColsAtCompileTime == Dynamic @@ -131,10 +132,10 @@ protected: // Note that here we force no inlining and separate the setZero() because GCC messes up otherwise template<typename Lhs, typename Rhs, typename Dest> -EIGEN_DONT_INLINE void ei_skyline_row_major_time_dense_product(const Lhs& lhs, const Rhs& rhs, Dest& dst) { - typedef typename ei_cleantype<Lhs>::type _Lhs; - typedef typename ei_cleantype<Rhs>::type _Rhs; - typedef typename ei_traits<Lhs>::Scalar Scalar; +EIGEN_DONT_INLINE void skyline_row_major_time_dense_product(const Lhs& lhs, const Rhs& rhs, Dest& dst) { + typedef typename cleantype<Lhs>::type _Lhs; + typedef typename cleantype<Rhs>::type _Rhs; + typedef typename traits<Lhs>::Scalar Scalar; enum { LhsIsRowMajor = (_Lhs::Flags & RowMajorBit) == RowMajorBit, @@ -194,10 +195,10 @@ EIGEN_DONT_INLINE void ei_skyline_row_major_time_dense_product(const Lhs& lhs, c } template<typename Lhs, typename Rhs, typename Dest> -EIGEN_DONT_INLINE void ei_skyline_col_major_time_dense_product(const Lhs& lhs, const Rhs& rhs, Dest& dst) { - typedef typename ei_cleantype<Lhs>::type _Lhs; - typedef typename ei_cleantype<Rhs>::type _Rhs; - typedef typename ei_traits<Lhs>::Scalar Scalar; +EIGEN_DONT_INLINE void skyline_col_major_time_dense_product(const Lhs& lhs, const Rhs& rhs, Dest& dst) { + typedef typename cleantype<Lhs>::type _Lhs; + typedef typename cleantype<Rhs>::type _Rhs; + typedef typename traits<Lhs>::Scalar Scalar; enum { LhsIsRowMajor = (_Lhs::Flags & RowMajorBit) == RowMajorBit, @@ -258,33 +259,35 @@ EIGEN_DONT_INLINE void ei_skyline_col_major_time_dense_product(const Lhs& lhs, c } template<typename Lhs, typename Rhs, typename ResultType, - int LhsStorageOrder = ei_traits<Lhs>::Flags&RowMajorBit> - struct ei_skyline_product_selector; + int LhsStorageOrder = traits<Lhs>::Flags&RowMajorBit> + struct skyline_product_selector; template<typename Lhs, typename Rhs, typename ResultType> -struct ei_skyline_product_selector<Lhs, Rhs, ResultType, RowMajor> { - typedef typename ei_traits<typename ei_cleantype<Lhs>::type>::Scalar Scalar; +struct skyline_product_selector<Lhs, Rhs, ResultType, RowMajor> { + typedef typename traits<typename cleantype<Lhs>::type>::Scalar Scalar; static void run(const Lhs& lhs, const Rhs& rhs, ResultType & res) { - ei_skyline_row_major_time_dense_product<Lhs, Rhs, ResultType > (lhs, rhs, res); + skyline_row_major_time_dense_product<Lhs, Rhs, ResultType > (lhs, rhs, res); } }; template<typename Lhs, typename Rhs, typename ResultType> -struct ei_skyline_product_selector<Lhs, Rhs, ResultType, ColMajor> { - typedef typename ei_traits<typename ei_cleantype<Lhs>::type>::Scalar Scalar; +struct skyline_product_selector<Lhs, Rhs, ResultType, ColMajor> { + typedef typename traits<typename cleantype<Lhs>::type>::Scalar Scalar; static void run(const Lhs& lhs, const Rhs& rhs, ResultType & res) { - ei_skyline_col_major_time_dense_product<Lhs, Rhs, ResultType > (lhs, rhs, res); + skyline_col_major_time_dense_product<Lhs, Rhs, ResultType > (lhs, rhs, res); } }; +} // end namespace internal + // template<typename Derived> // template<typename Lhs, typename Rhs > // Derived & MatrixBase<Derived>::lazyAssign(const SkylineProduct<Lhs, Rhs, SkylineTimeDenseProduct>& product) { -// typedef typename ei_cleantype<Lhs>::type _Lhs; -// ei_skyline_product_selector<typename ei_cleantype<Lhs>::type, -// typename ei_cleantype<Rhs>::type, +// typedef typename internal::cleantype<Lhs>::type _Lhs; +// internal::skyline_product_selector<typename internal::cleantype<Lhs>::type, +// typename internal::cleantype<Rhs>::type, // Derived>::run(product.lhs(), product.rhs(), derived()); // // return derived(); diff --git a/unsupported/Eigen/src/Skyline/SkylineUtil.h b/unsupported/Eigen/src/Skyline/SkylineUtil.h index 7781c33e7..e0512476f 100644 --- a/unsupported/Eigen/src/Skyline/SkylineUtil.h +++ b/unsupported/Eigen/src/Skyline/SkylineUtil.h @@ -64,11 +64,11 @@ EIGEN_STRONG_INLINE Derived& operator Op(const Other& scalar) \ #define _EIGEN_SKYLINE_GENERIC_PUBLIC_INTERFACE(Derived, BaseClass) \ typedef BaseClass Base; \ - typedef typename Eigen::ei_traits<Derived>::Scalar Scalar; \ + typedef typename Eigen::internal::traits<Derived>::Scalar Scalar; \ typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \ - typedef typename Eigen::ei_traits<Derived>::StorageKind StorageKind; \ - typedef typename Eigen::ei_index<StorageKind>::type Index; \ - enum { Flags = Eigen::ei_traits<Derived>::Flags, }; + typedef typename Eigen::internal::traits<Derived>::StorageKind StorageKind; \ + typedef typename Eigen::internal::index<StorageKind>::type Index; \ + enum { Flags = Eigen::internal::traits<Derived>::Flags, }; #define EIGEN_SKYLINE_GENERIC_PUBLIC_INTERFACE(Derived) \ _EIGEN_SKYLINE_GENERIC_PUBLIC_INTERFACE(Derived, Eigen::SkylineMatrixBase<Derived>) @@ -79,20 +79,23 @@ template<typename _Scalar, int _Flags = 0> class DynamicSkylineMatrix; template<typename _Scalar, int _Flags = 0> class SkylineVector; template<typename _Scalar, int _Flags = 0> class MappedSkylineMatrix; -template<typename Lhs, typename Rhs> struct ei_skyline_product_mode; -template<typename Lhs, typename Rhs, int ProductMode = ei_skyline_product_mode<Lhs,Rhs>::value> struct SkylineProductReturnType; +namespace internal { +template<typename Lhs, typename Rhs> struct skyline_product_mode; +template<typename Lhs, typename Rhs, int ProductMode = skyline_product_mode<Lhs,Rhs>::value> struct SkylineProductReturnType; -template<typename T> class ei_eval<T,IsSkyline> +template<typename T> class eval<T,IsSkyline> { - typedef typename ei_traits<T>::Scalar _Scalar; + typedef typename traits<T>::Scalar _Scalar; enum { - _Flags = ei_traits<T>::Flags + _Flags = traits<T>::Flags }; public: typedef SkylineMatrix<_Scalar, _Flags> type; }; +} // end namespace internal + #endif // EIGEN_SKYLINEUTIL_H diff --git a/unsupported/Eigen/src/SparseExtra/CholmodSupport.h b/unsupported/Eigen/src/SparseExtra/CholmodSupport.h index 8b500062b..aee4ae00a 100644 --- a/unsupported/Eigen/src/SparseExtra/CholmodSupport.h +++ b/unsupported/Eigen/src/SparseExtra/CholmodSupport.h @@ -25,38 +25,39 @@ #ifndef EIGEN_CHOLMODSUPPORT_H #define EIGEN_CHOLMODSUPPORT_H +namespace internal { template<typename Scalar, typename CholmodType> -void ei_cholmod_configure_matrix(CholmodType& mat) +void cholmod_configure_matrix(CholmodType& mat) { - if (ei_is_same_type<Scalar,float>::ret) + if (is_same_type<Scalar,float>::ret) { mat.xtype = CHOLMOD_REAL; mat.dtype = CHOLMOD_SINGLE; } - else if (ei_is_same_type<Scalar,double>::ret) + else if (is_same_type<Scalar,double>::ret) { mat.xtype = CHOLMOD_REAL; mat.dtype = CHOLMOD_DOUBLE; } - else if (ei_is_same_type<Scalar,std::complex<float> >::ret) + else if (is_same_type<Scalar,std::complex<float> >::ret) { mat.xtype = CHOLMOD_COMPLEX; mat.dtype = CHOLMOD_SINGLE; } - else if (ei_is_same_type<Scalar,std::complex<double> >::ret) + else if (is_same_type<Scalar,std::complex<double> >::ret) { mat.xtype = CHOLMOD_COMPLEX; mat.dtype = CHOLMOD_DOUBLE; } else { - ei_assert(false && "Scalar type not supported by CHOLMOD"); + eigen_assert(false && "Scalar type not supported by CHOLMOD"); } } template<typename _MatrixType> -cholmod_sparse ei_cholmod_map_eigen_to_sparse(_MatrixType& mat) +cholmod_sparse cholmod_map_eigen_to_sparse(_MatrixType& mat) { typedef typename _MatrixType::Scalar Scalar; cholmod_sparse res; @@ -73,7 +74,7 @@ cholmod_sparse ei_cholmod_map_eigen_to_sparse(_MatrixType& mat) res.dtype = 0; res.stype = -1; - ei_cholmod_configure_matrix<Scalar>(res); + cholmod_configure_matrix<Scalar>(res); if (_MatrixType::Flags & SelfAdjoint) @@ -92,9 +93,9 @@ cholmod_sparse ei_cholmod_map_eigen_to_sparse(_MatrixType& mat) } template<typename Derived> -cholmod_dense ei_cholmod_map_eigen_to_dense(MatrixBase<Derived>& mat) +cholmod_dense cholmod_map_eigen_to_dense(MatrixBase<Derived>& mat) { - EIGEN_STATIC_ASSERT((ei_traits<Derived>::Flags&RowMajorBit)==0,THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES); + EIGEN_STATIC_ASSERT((traits<Derived>::Flags&RowMajorBit)==0,THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES); typedef typename Derived::Scalar Scalar; cholmod_dense res; @@ -105,20 +106,20 @@ cholmod_dense ei_cholmod_map_eigen_to_dense(MatrixBase<Derived>& mat) res.x = mat.derived().data(); res.z = 0; - ei_cholmod_configure_matrix<Scalar>(res); + cholmod_configure_matrix<Scalar>(res); return res; } template<typename Scalar, int Flags, typename Index> -MappedSparseMatrix<Scalar,Flags,Index> ei_map_cholmod_sparse_to_eigen(cholmod_sparse& cm) +MappedSparseMatrix<Scalar,Flags,Index> map_cholmod_sparse_to_eigen(cholmod_sparse& cm) { return MappedSparseMatrix<Scalar,Flags,Index> (cm.nrow, cm.ncol, reinterpret_cast<Index*>(cm.p)[cm.ncol], reinterpret_cast<Index*>(cm.p), reinterpret_cast<Index*>(cm.i),reinterpret_cast<Scalar*>(cm.x) ); } - +} // end namespace internal template<typename _MatrixType> class SparseLLT<_MatrixType, Cholmod> : public SparseLLT<_MatrixType> @@ -164,11 +165,11 @@ class SparseLLT<_MatrixType, Cholmod> : public SparseLLT<_MatrixType> bool solveInPlace(MatrixBase<Derived> &b) const; template<typename Rhs> - inline const ei_solve_retval<SparseLLT<MatrixType, Cholmod>, Rhs> + inline const internal::solve_retval<SparseLLT<MatrixType, Cholmod>, Rhs> solve(const MatrixBase<Rhs>& b) const { - ei_assert(true && "SparseLLT is not initialized."); - return ei_solve_retval<SparseLLT<MatrixType, Cholmod>, Rhs>(*this, b.derived()); + eigen_assert(true && "SparseLLT is not initialized."); + return internal::solve_retval<SparseLLT<MatrixType, Cholmod>, Rhs>(*this, b.derived()); } void compute(const MatrixType& matrix); @@ -192,8 +193,8 @@ class SparseLLT<_MatrixType, Cholmod> : public SparseLLT<_MatrixType> template<typename _MatrixType, typename Rhs> - struct ei_solve_retval<SparseLLT<_MatrixType, Cholmod>, Rhs> - : ei_solve_retval_base<SparseLLT<_MatrixType, Cholmod>, Rhs> + struct internal::solve_retval<SparseLLT<_MatrixType, Cholmod>, Rhs> + : internal::solve_retval_base<SparseLLT<_MatrixType, Cholmod>, Rhs> { typedef SparseLLT<_MatrixType, Cholmod> SpLLTDecType; EIGEN_MAKE_SOLVE_HELPERS(SpLLTDecType,Rhs) @@ -201,7 +202,7 @@ template<typename _MatrixType, typename Rhs> template<typename Dest> void evalTo(Dest& dst) const { //Index size = dec().cholmodFactor()->n; - ei_assert((Index)dec().cholmodFactor()->n==rhs().rows()); + eigen_assert((Index)dec().cholmodFactor()->n==rhs().rows()); cholmod_factor* cholmodFactor = const_cast<cholmod_factor*>(dec().cholmodFactor()); cholmod_common* cholmodCommon = const_cast<cholmod_common*>(dec().cholmodCommon()); @@ -211,7 +212,7 @@ template<typename _MatrixType, typename Rhs> // Base::solveInPlace(b); // as long as our own triangular sparse solver is not fully optimal, // let's use CHOLMOD's one: - cholmod_dense cdb = ei_cholmod_map_eigen_to_dense(rhs().const_cast_derived()); + cholmod_dense cdb = internal::cholmod_map_eigen_to_dense(rhs().const_cast_derived()); cholmod_dense* x = cholmod_solve(CHOLMOD_A, cholmodFactor, &cdb, cholmodCommon); dst = Matrix<typename Base::Scalar,Dynamic,1>::Map(reinterpret_cast<typename Base::Scalar*>(x->x), rhs().rows()); @@ -235,7 +236,7 @@ void SparseLLT<_MatrixType,Cholmod>::compute(const _MatrixType& a) m_cholmodFactor = 0; } - cholmod_sparse A = ei_cholmod_map_eigen_to_sparse(const_cast<_MatrixType&>(a)); + cholmod_sparse A = internal::cholmod_map_eigen_to_sparse(const_cast<_MatrixType&>(a)); // m_cholmod.supernodal = CHOLMOD_AUTO; // TODO // if (m_flags&IncompleteFactorization) @@ -271,11 +272,11 @@ SparseLLT<_MatrixType,Cholmod>::matrixL() const { if (m_status & MatrixLIsDirty) { - ei_assert(!(m_status & SupernodalFactorIsDirty)); + eigen_assert(!(m_status & SupernodalFactorIsDirty)); cholmod_sparse* cmRes = cholmod_factor_to_sparse(m_cholmodFactor, &m_cholmod); const_cast<typename Base::CholMatrixType&>(m_matrix) = - ei_map_cholmod_sparse_to_eigen<Scalar,ColMajor,Index>(*cmRes); + internal::map_cholmod_sparse_to_eigen<Scalar,ColMajor,Index>(*cmRes); free(cmRes); m_status = (m_status & ~MatrixLIsDirty); @@ -291,7 +292,7 @@ template<typename Derived> bool SparseLLT<_MatrixType,Cholmod>::solveInPlace(MatrixBase<Derived> &b) const { //Index size = m_cholmodFactor->n; - ei_assert((Index)m_cholmodFactor->n==b.rows()); + eigen_assert((Index)m_cholmodFactor->n==b.rows()); // this uses Eigen's triangular sparse solver // if (m_status & MatrixLIsDirty) @@ -299,10 +300,10 @@ bool SparseLLT<_MatrixType,Cholmod>::solveInPlace(MatrixBase<Derived> &b) const // Base::solveInPlace(b); // as long as our own triangular sparse solver is not fully optimal, // let's use CHOLMOD's one: - cholmod_dense cdb = ei_cholmod_map_eigen_to_dense(b); + cholmod_dense cdb = internal::cholmod_map_eigen_to_dense(b); cholmod_dense* x = cholmod_solve(CHOLMOD_A, m_cholmodFactor, &cdb, &m_cholmod); - ei_assert(x && "Eigen: cholmod_solve failed."); + eigen_assert(x && "Eigen: cholmod_solve failed."); b = Matrix<typename Base::Scalar,Dynamic,1>::Map(reinterpret_cast<typename Base::Scalar*>(x->x),b.rows()); cholmod_free_dense(&x, &m_cholmod); @@ -362,11 +363,11 @@ class SparseLDLT<_MatrixType,Cholmod> : public SparseLDLT<_MatrixType> void solveInPlace(MatrixBase<Derived> &b) const; template<typename Rhs> - inline const ei_solve_retval<SparseLDLT<MatrixType, Cholmod>, Rhs> + inline const internal::solve_retval<SparseLDLT<MatrixType, Cholmod>, Rhs> solve(const MatrixBase<Rhs>& b) const { - ei_assert(true && "SparseLDLT is not initialized."); - return ei_solve_retval<SparseLDLT<MatrixType, Cholmod>, Rhs>(*this, b.derived()); + eigen_assert(true && "SparseLDLT is not initialized."); + return internal::solve_retval<SparseLDLT<MatrixType, Cholmod>, Rhs>(*this, b.derived()); } void compute(const _MatrixType& matrix); @@ -392,8 +393,8 @@ class SparseLDLT<_MatrixType,Cholmod> : public SparseLDLT<_MatrixType> template<typename _MatrixType, typename Rhs> - struct ei_solve_retval<SparseLDLT<_MatrixType, Cholmod>, Rhs> - : ei_solve_retval_base<SparseLDLT<_MatrixType, Cholmod>, Rhs> + struct internal::solve_retval<SparseLDLT<_MatrixType, Cholmod>, Rhs> + : internal::solve_retval_base<SparseLDLT<_MatrixType, Cholmod>, Rhs> { typedef SparseLDLT<_MatrixType, Cholmod> SpLDLTDecType; EIGEN_MAKE_SOLVE_HELPERS(SpLDLTDecType,Rhs) @@ -401,7 +402,7 @@ template<typename _MatrixType, typename Rhs> template<typename Dest> void evalTo(Dest& dst) const { //Index size = dec().cholmodFactor()->n; - ei_assert((Index)dec().cholmodFactor()->n==rhs().rows()); + eigen_assert((Index)dec().cholmodFactor()->n==rhs().rows()); cholmod_factor* cholmodFactor = const_cast<cholmod_factor*>(dec().cholmodFactor()); cholmod_common* cholmodCommon = const_cast<cholmod_common*>(dec().cholmodCommon()); @@ -411,7 +412,7 @@ template<typename _MatrixType, typename Rhs> // Base::solveInPlace(b); // as long as our own triangular sparse solver is not fully optimal, // let's use CHOLMOD's one: - cholmod_dense cdb = ei_cholmod_map_eigen_to_dense(rhs().const_cast_derived()); + cholmod_dense cdb = internal::cholmod_map_eigen_to_dense(rhs().const_cast_derived()); cholmod_dense* x = cholmod_solve(CHOLMOD_LDLt, cholmodFactor, &cdb, cholmodCommon); dst = Matrix<typename Base::Scalar,Dynamic,1>::Map(reinterpret_cast<typename Base::Scalar*>(x->x), rhs().rows()); @@ -434,7 +435,7 @@ void SparseLDLT<_MatrixType,Cholmod>::compute(const _MatrixType& a) m_cholmodFactor = 0; } - cholmod_sparse A = ei_cholmod_map_eigen_to_sparse(const_cast<_MatrixType&>(a)); + cholmod_sparse A = internal::cholmod_map_eigen_to_sparse(const_cast<_MatrixType&>(a)); //m_cholmod.supernodal = CHOLMOD_AUTO; m_cholmod.supernodal = CHOLMOD_SIMPLICIAL; @@ -473,7 +474,7 @@ SparseLDLT<_MatrixType,Cholmod>::matrixL() const { if (m_status & MatrixLIsDirty) { - ei_assert(!(m_status & SupernodalFactorIsDirty)); + eigen_assert(!(m_status & SupernodalFactorIsDirty)); cholmod_sparse* cmRes = cholmod_factor_to_sparse(m_cholmodFactor, &m_cholmod); const_cast<typename Base::CholMatrixType&>(m_matrix) = MappedSparseMatrix<Scalar>(*cmRes); @@ -494,7 +495,7 @@ template<typename Derived> void SparseLDLT<_MatrixType,Cholmod>::solveInPlace(MatrixBase<Derived> &b) const { //Index size = m_cholmodFactor->n; - ei_assert((Index)m_cholmodFactor->n == b.rows()); + eigen_assert((Index)m_cholmodFactor->n == b.rows()); // this uses Eigen's triangular sparse solver // if (m_status & MatrixLIsDirty) @@ -502,7 +503,7 @@ void SparseLDLT<_MatrixType,Cholmod>::solveInPlace(MatrixBase<Derived> &b) const // Base::solveInPlace(b); // as long as our own triangular sparse solver is not fully optimal, // let's use CHOLMOD's one: - cholmod_dense cdb = ei_cholmod_map_eigen_to_dense(b); + cholmod_dense cdb = internal::cholmod_map_eigen_to_dense(b); cholmod_dense* x = cholmod_solve(CHOLMOD_A, m_cholmodFactor, &cdb, &m_cholmod); b = Matrix<typename Base::Scalar,Dynamic,1>::Map(reinterpret_cast<typename Base::Scalar*>(x->x),b.rows()); cholmod_free_dense(&x, &m_cholmod); diff --git a/unsupported/Eigen/src/SparseExtra/RandomSetter.h b/unsupported/Eigen/src/SparseExtra/RandomSetter.h index f81eb693d..4ea41af85 100644 --- a/unsupported/Eigen/src/SparseExtra/RandomSetter.h +++ b/unsupported/Eigen/src/SparseExtra/RandomSetter.h @@ -305,8 +305,8 @@ class RandomSetter /** \returns a reference to the coefficient at given coordinates \a row, \a col */ Scalar& operator() (Index row, Index col) { - ei_assert(((!IsUpper) || (row<=col)) && "Invalid access to an upper triangular matrix"); - ei_assert(((!IsLower) || (col<=row)) && "Invalid access to an upper triangular matrix"); + eigen_assert(((!IsUpper) || (row<=col)) && "Invalid access to an upper triangular matrix"); + eigen_assert(((!IsLower) || (col<=row)) && "Invalid access to an upper triangular matrix"); const Index outer = SetterRowMajor ? row : col; const Index inner = SetterRowMajor ? col : row; const Index outerMajor = outer >> OuterPacketBits; // index of the packet/map diff --git a/unsupported/Eigen/src/SparseExtra/SparseLDLT.h b/unsupported/Eigen/src/SparseExtra/SparseLDLT.h index a852f2b0f..837d70295 100644 --- a/unsupported/Eigen/src/SparseExtra/SparseLDLT.h +++ b/unsupported/Eigen/src/SparseExtra/SparseLDLT.h @@ -99,7 +99,7 @@ class SparseLDLT SparseLDLT(int flags = 0) : m_flags(flags), m_status(0) { - ei_assert((MatrixType::Flags&RowMajorBit)==0); + eigen_assert((MatrixType::Flags&RowMajorBit)==0); m_precision = RealScalar(0.1) * Eigen::NumTraits<RealScalar>::dummy_precision(); } @@ -108,7 +108,7 @@ class SparseLDLT SparseLDLT(const MatrixType& matrix, int flags = 0) : m_matrix(matrix.rows(), matrix.cols()), m_flags(flags), m_status(0) { - ei_assert((MatrixType::Flags&RowMajorBit)==0); + eigen_assert((MatrixType::Flags&RowMajorBit)==0); m_precision = RealScalar(0.1) * Eigen::NumTraits<RealScalar>::dummy_precision(); compute(matrix); } @@ -166,11 +166,11 @@ class SparseLDLT bool solveInPlace(MatrixBase<Derived> &b) const; template<typename Rhs> - inline const ei_solve_retval<SparseLDLT<MatrixType>, Rhs> + inline const internal::solve_retval<SparseLDLT<MatrixType>, Rhs> solve(const MatrixBase<Rhs>& b) const { - ei_assert(true && "SparseLDLT is not initialized."); - return ei_solve_retval<SparseLDLT<MatrixType>, Rhs>(*this, b.derived()); + eigen_assert(true && "SparseLDLT is not initialized."); + return internal::solve_retval<SparseLDLT<MatrixType>, Rhs>(*this, b.derived()); } inline Index cols() const { return m_matrix.cols(); } @@ -193,13 +193,11 @@ class SparseLDLT bool m_succeeded; }; - - - +namespace internal { template<typename _MatrixType, typename Rhs> -struct ei_solve_retval<SparseLDLT<_MatrixType>, Rhs> - : ei_solve_retval_base<SparseLDLT<_MatrixType>, Rhs> +struct solve_retval<SparseLDLT<_MatrixType>, Rhs> + : solve_retval_base<SparseLDLT<_MatrixType>, Rhs> { typedef SparseLDLT<_MatrixType> SpLDLTDecType; EIGEN_MAKE_SOLVE_HELPERS(SpLDLTDecType,Rhs) @@ -207,7 +205,7 @@ struct ei_solve_retval<SparseLDLT<_MatrixType>, Rhs> template<typename Dest> void evalTo(Dest& dst) const { //Index size = dec().matrixL().rows(); - ei_assert(dec().matrixL().rows()==rhs().rows()); + eigen_assert(dec().matrixL().rows()==rhs().rows()); Rhs b(rhs().rows(), rhs().cols()); b = rhs(); @@ -225,7 +223,7 @@ struct ei_solve_retval<SparseLDLT<_MatrixType>, Rhs> }; - +} // end namespace internal /** Computes / recomputes the LDLT decomposition of matrix \a a * using the default algorithm. @@ -332,7 +330,7 @@ bool SparseLDLT<_MatrixType,Backend>::_numeric(const _MatrixType& a) Index i = Pinv ? Pinv[Ai[p]] : Ai[p]; /* get A(i,k) */ if (i <= k) { - y[i] += ei_conj(Ax[p]); /* scatter A(i,k) into Y (sum duplicates) */ + y[i] += internal::conj(Ax[p]); /* scatter A(i,k) into Y (sum duplicates) */ Index len; for (len = 0; tags[i] != k; i = m_parent[i]) { @@ -355,9 +353,9 @@ bool SparseLDLT<_MatrixType,Backend>::_numeric(const _MatrixType& a) Index p2 = Lp[i] + m_nonZerosPerCol[i]; Index p; for (p = Lp[i]; p < p2; ++p) - y[Li[p]] -= ei_conj(Lx[p]) * (yi); + y[Li[p]] -= internal::conj(Lx[p]) * (yi); Scalar l_ki = yi / m_diag[i]; /* the nonzero entry L(k,i) */ - m_diag[k] -= l_ki * ei_conj(yi); + m_diag[k] -= l_ki * internal::conj(yi); Li[p] = k; /* store L(k,i) in column form of L */ Lx[p] = (l_ki); ++m_nonZerosPerCol[i]; /* increment count of nonzeros in col i */ @@ -382,7 +380,7 @@ template<typename Derived> bool SparseLDLT<_MatrixType, Backend>::solveInPlace(MatrixBase<Derived> &b) const { //Index size = m_matrix.rows(); - ei_assert(m_matrix.rows()==b.rows()); + eigen_assert(m_matrix.rows()==b.rows()); if (!m_succeeded) return false; diff --git a/unsupported/Eigen/src/SparseExtra/SparseLLT.h b/unsupported/Eigen/src/SparseExtra/SparseLLT.h index 5be914b6a..ac042217b 100644 --- a/unsupported/Eigen/src/SparseExtra/SparseLLT.h +++ b/unsupported/Eigen/src/SparseExtra/SparseLLT.h @@ -112,11 +112,11 @@ class SparseLLT bool solveInPlace(MatrixBase<Derived> &b) const; template<typename Rhs> - inline const ei_solve_retval<SparseLLT<MatrixType>, Rhs> + inline const internal::solve_retval<SparseLLT<MatrixType>, Rhs> solve(const MatrixBase<Rhs>& b) const { - ei_assert(true && "SparseLLT is not initialized."); - return ei_solve_retval<SparseLLT<MatrixType>, Rhs>(*this, b.derived()); + eigen_assert(true && "SparseLLT is not initialized."); + return internal::solve_retval<SparseLLT<MatrixType>, Rhs>(*this, b.derived()); } inline Index cols() const { return m_matrix.cols(); } @@ -134,13 +134,11 @@ class SparseLLT }; - - - +namespace internal { template<typename _MatrixType, typename Rhs> -struct ei_solve_retval<SparseLLT<_MatrixType>, Rhs> - : ei_solve_retval_base<SparseLLT<_MatrixType>, Rhs> +struct solve_retval<SparseLLT<_MatrixType>, Rhs> + : solve_retval_base<SparseLLT<_MatrixType>, Rhs> { typedef SparseLLT<_MatrixType> SpLLTDecType; EIGEN_MAKE_SOLVE_HELPERS(SpLLTDecType,Rhs) @@ -148,7 +146,7 @@ struct ei_solve_retval<SparseLLT<_MatrixType>, Rhs> template<typename Dest> void evalTo(Dest& dst) const { const Index size = dec().matrixL().rows(); - ei_assert(size==rhs().rows()); + eigen_assert(size==rhs().rows()); Rhs b(rhs().rows(), rhs().cols()); b = rhs(); @@ -162,7 +160,7 @@ struct ei_solve_retval<SparseLLT<_MatrixType>, Rhs> }; - +} // end namespace internal /** Computes / recomputes the LLT decomposition of matrix \a a @@ -184,7 +182,7 @@ void SparseLLT<_MatrixType,Backend>::compute(const _MatrixType& a) m_matrix.reserve(a.nonZeros()*2); for (Index j = 0; j < size; ++j) { - Scalar x = ei_real(a.coeff(j,j)); + Scalar x = internal::real(a.coeff(j,j)); // TODO better estimate of the density ! tempVector.init(density>0.001? IsDense : IsSparse); @@ -193,7 +191,7 @@ void SparseLLT<_MatrixType,Backend>::compute(const _MatrixType& a) // init with current matrix a { typename _MatrixType::InnerIterator it(a,j); - ei_assert(it.index()==j && + eigen_assert(it.index()==j && "matrix must has non zero diagonal entries and only the lower triangular part must be stored"); ++it; // skip diagonal element for (; it; ++it) @@ -207,7 +205,7 @@ void SparseLLT<_MatrixType,Backend>::compute(const _MatrixType& a) if (it && it.index()==j) { Scalar y = it.value(); - x -= ei_abs2(y); + x -= internal::abs2(y); ++it; // skip j-th element, and process remaining column coefficients tempVector.restart(); for (; it; ++it) @@ -218,7 +216,7 @@ void SparseLLT<_MatrixType,Backend>::compute(const _MatrixType& a) } // copy the temporary vector to the respective m_matrix.col() // while scaling the result by 1/real(x) - RealScalar rx = ei_sqrt(ei_real(x)); + RealScalar rx = internal::sqrt(internal::real(x)); m_matrix.insert(j,j) = rx; // FIXME use insertBack Scalar y = Scalar(1)/rx; for (typename AmbiVector<Scalar,Index>::Iterator it(tempVector, m_precision*rx); it; ++it) @@ -236,7 +234,7 @@ template<typename Derived> bool SparseLLT<_MatrixType, Backend>::solveInPlace(MatrixBase<Derived> &b) const { const Index size = m_matrix.rows(); - ei_assert(size==b.rows()); + eigen_assert(size==b.rows()); m_matrix.template triangularView<Lower>().solveInPlace(b); m_matrix.adjoint().template triangularView<Upper>().solveInPlace(b); diff --git a/unsupported/Eigen/src/SparseExtra/SparseLU.h b/unsupported/Eigen/src/SparseExtra/SparseLU.h index f6ced52c9..3d10dbbee 100644 --- a/unsupported/Eigen/src/SparseExtra/SparseLU.h +++ b/unsupported/Eigen/src/SparseExtra/SparseLU.h @@ -103,7 +103,7 @@ class SparseLU void setOrderingMethod(int m) { - ei_assert( (m&~OrderingMask) == 0 && m!=0 && "invalid ordering method"); + eigen_assert( (m&~OrderingMask) == 0 && m!=0 && "invalid ordering method"); m_flags = m_flags&~OrderingMask | m&OrderingMask; } @@ -141,7 +141,7 @@ class SparseLU template<typename _MatrixType, typename Backend> void SparseLU<_MatrixType,Backend>::compute(const _MatrixType& ) { - ei_assert(false && "not implemented yet"); + eigen_assert(false && "not implemented yet"); } /** Computes *x = U^-1 L^-1 b @@ -156,7 +156,7 @@ template<typename _MatrixType, typename Backend> template<typename BDerived, typename XDerived> bool SparseLU<_MatrixType,Backend>::solve(const MatrixBase<BDerived> &, MatrixBase<XDerived>* , const int ) const { - ei_assert(false && "not implemented yet"); + eigen_assert(false && "not implemented yet"); return false; } diff --git a/unsupported/Eigen/src/SparseExtra/SuperLUSupport.h b/unsupported/Eigen/src/SparseExtra/SuperLUSupport.h index 9453aabce..31a0ee509 100644 --- a/unsupported/Eigen/src/SparseExtra/SuperLUSupport.h +++ b/unsupported/Eigen/src/SparseExtra/SuperLUSupport.h @@ -126,7 +126,7 @@ struct SluMatrix : SuperMatrix Store = &storage; else { - ei_assert(false && "storage type not supported"); + eigen_assert(false && "storage type not supported"); Store = 0; } } @@ -134,17 +134,17 @@ struct SluMatrix : SuperMatrix template<typename Scalar> void setScalarType() { - if (ei_is_same_type<Scalar,float>::ret) + if (internal::is_same_type<Scalar,float>::ret) Dtype = SLU_S; - else if (ei_is_same_type<Scalar,double>::ret) + else if (internal::is_same_type<Scalar,double>::ret) Dtype = SLU_D; - else if (ei_is_same_type<Scalar,std::complex<float> >::ret) + else if (internal::is_same_type<Scalar,std::complex<float> >::ret) Dtype = SLU_C; - else if (ei_is_same_type<Scalar,std::complex<double> >::ret) + else if (internal::is_same_type<Scalar,std::complex<double> >::ret) Dtype = SLU_Z; else { - ei_assert(false && "Scalar type not supported by SuperLU"); + eigen_assert(false && "Scalar type not supported by SuperLU"); } } @@ -152,7 +152,7 @@ struct SluMatrix : SuperMatrix static SluMatrix Map(Matrix<Scalar,Rows,Cols,Options,MRows,MCols>& mat) { typedef Matrix<Scalar,Rows,Cols,Options,MRows,MCols> MatrixType; - ei_assert( ((Options&RowMajor)!=RowMajor) && "row-major dense matrices is not supported by SuperLU"); + eigen_assert( ((Options&RowMajor)!=RowMajor) && "row-major dense matrices is not supported by SuperLU"); SluMatrix res; res.setStorageType(SLU_DN); res.setScalarType<Scalar>(); @@ -198,7 +198,7 @@ struct SluMatrix : SuperMatrix if (MatrixType::Flags & Lower) res.Mtype = SLU_TRL; if (MatrixType::Flags & SelfAdjoint) - ei_assert(false && "SelfAdjoint matrix shape not supported by SuperLU"); + eigen_assert(false && "SelfAdjoint matrix shape not supported by SuperLU"); return res; } }; @@ -209,7 +209,7 @@ struct SluMatrixMapHelper<Matrix<Scalar,Rows,Cols,Options,MRows,MCols> > typedef Matrix<Scalar,Rows,Cols,Options,MRows,MCols> MatrixType; static void run(MatrixType& mat, SluMatrix& res) { - ei_assert( ((Options&RowMajor)!=RowMajor) && "row-major dense matrices is not supported by SuperLU"); + eigen_assert( ((Options&RowMajor)!=RowMajor) && "row-major dense matrices is not supported by SuperLU"); res.setStorageType(SLU_DN); res.setScalarType<Scalar>(); res.Mtype = SLU_GE; @@ -256,21 +256,23 @@ struct SluMatrixMapHelper<SparseMatrixBase<Derived> > if (MatrixType::Flags & Lower) res.Mtype = SLU_TRL; if (MatrixType::Flags & SelfAdjoint) - ei_assert(false && "SelfAdjoint matrix shape not supported by SuperLU"); + eigen_assert(false && "SelfAdjoint matrix shape not supported by SuperLU"); } }; +namespace internal { + template<typename MatrixType> -SluMatrix ei_asSluMatrix(MatrixType& mat) +SluMatrix asSluMatrix(MatrixType& mat) { return SluMatrix::Map(mat); } /** View a Super LU matrix as an Eigen expression */ template<typename Scalar, int Flags, typename Index> -MappedSparseMatrix<Scalar,Flags,Index> ei_map_superlu(SluMatrix& sluMat) +MappedSparseMatrix<Scalar,Flags,Index> map_superlu(SluMatrix& sluMat) { - ei_assert((Flags&RowMajor)==RowMajor && sluMat.Stype == SLU_NR + eigen_assert((Flags&RowMajor)==RowMajor && sluMat.Stype == SLU_NR || (Flags&ColMajor)==ColMajor && sluMat.Stype == SLU_NC); Index outerSize = (Flags&RowMajor)==RowMajor ? sluMat.ncol : sluMat.nrow; @@ -280,6 +282,8 @@ MappedSparseMatrix<Scalar,Flags,Index> ei_map_superlu(SluMatrix& sluMat) sluMat.storage.outerInd, sluMat.storage.innerInd, reinterpret_cast<Scalar*>(sluMat.storage.values) ); } +} // end namespace internal + template<typename MatrixType> class SparseLU<MatrixType,SuperLU> : public SparseLU<MatrixType> { @@ -393,7 +397,7 @@ void SparseLU<MatrixType,SuperLU>::compute(const MatrixType& a) m_sluOptions.ColPerm = NATURAL; }; - m_sluA = ei_asSluMatrix(m_matrix); + m_sluA = internal::asSluMatrix(m_matrix); memset(&m_sluL,0,sizeof m_sluL); memset(&m_sluU,0,sizeof m_sluU); //m_sluEqued = 'B'; @@ -471,7 +475,7 @@ bool SparseLU<MatrixType,SuperLU>::solve(const MatrixBase<BDerived> &b, { const int size = m_matrix.rows(); const int rhsCols = b.cols(); - ei_assert(size==b.rows()); + eigen_assert(size==b.rows()); switch (transposed) { case SvNoTrans : m_sluOptions.Trans = NOTRANS; break; @@ -637,7 +641,7 @@ typename SparseLU<MatrixType,SuperLU>::Scalar SparseLU<MatrixType,SuperLU>::dete if (m_u._outerIndexPtr()[j+1]-m_u._outerIndexPtr()[j] > 0) { int lastId = m_u._outerIndexPtr()[j+1]-1; - ei_assert(m_u._innerIndexPtr()[lastId]<=j); + eigen_assert(m_u._innerIndexPtr()[lastId]<=j); if (m_u._innerIndexPtr()[lastId]==j) { det *= m_u._valuePtr()[lastId]; diff --git a/unsupported/Eigen/src/SparseExtra/UmfPackSupport.h b/unsupported/Eigen/src/SparseExtra/UmfPackSupport.h index 9d7e3e96e..4be1aca62 100644 --- a/unsupported/Eigen/src/SparseExtra/UmfPackSupport.h +++ b/unsupported/Eigen/src/SparseExtra/UmfPackSupport.h @@ -183,11 +183,11 @@ class SparseLU<_MatrixType,UmfPack> : public SparseLU<_MatrixType> bool solve(const MatrixBase<BDerived> &b, MatrixBase<XDerived>* x) const; template<typename Rhs> - inline const ei_solve_retval<SparseLU<MatrixType, UmfPack>, Rhs> + inline const internal::solve_retval<SparseLU<MatrixType, UmfPack>, Rhs> solve(const MatrixBase<Rhs>& b) const { - ei_assert(true && "SparseLU is not initialized."); - return ei_solve_retval<SparseLU<MatrixType, UmfPack>, Rhs>(*this, b.derived()); + eigen_assert(true && "SparseLU is not initialized."); + return internal::solve_retval<SparseLU<MatrixType, UmfPack>, Rhs>(*this, b.derived()); } void compute(const MatrixType& matrix); @@ -197,7 +197,7 @@ class SparseLU<_MatrixType,UmfPack> : public SparseLU<_MatrixType> inline const MatrixType& matrixLU() const { - //ei_assert(m_isInitialized && "LU is not initialized."); + //eigen_assert(m_isInitialized && "LU is not initialized."); return *m_matrixRef; } @@ -221,10 +221,11 @@ class SparseLU<_MatrixType,UmfPack> : public SparseLU<_MatrixType> mutable bool m_extractedDataAreDirty; }; +namespace internal { template<typename _MatrixType, typename Rhs> - struct ei_solve_retval<SparseLU<_MatrixType, UmfPack>, Rhs> - : ei_solve_retval_base<SparseLU<_MatrixType, UmfPack>, Rhs> + struct solve_retval<SparseLU<_MatrixType, UmfPack>, Rhs> + : solve_retval_base<SparseLU<_MatrixType, UmfPack>, Rhs> { typedef SparseLU<_MatrixType, UmfPack> SpLUDecType; EIGEN_MAKE_SOLVE_HELPERS(SpLUDecType,Rhs) @@ -233,8 +234,8 @@ template<typename _MatrixType, typename Rhs> { const int rhsCols = rhs().cols(); - ei_assert((Rhs::Flags&RowMajorBit)==0 && "UmfPack backend does not support non col-major rhs yet"); - ei_assert((Dest::Flags&RowMajorBit)==0 && "UmfPack backend does not support non col-major result yet"); + eigen_assert((Rhs::Flags&RowMajorBit)==0 && "UmfPack backend does not support non col-major rhs yet"); + eigen_assert((Dest::Flags&RowMajorBit)==0 && "UmfPack backend does not support non col-major result yet"); void* numeric = const_cast<void*>(dec().numeric()); @@ -244,13 +245,13 @@ template<typename _MatrixType, typename Rhs> errorCode = umfpack_solve(UMFPACK_A, dec().matrixLU()._outerIndexPtr(), dec().matrixLU()._innerIndexPtr(), dec().matrixLU()._valuePtr(), &dst.col(j).coeffRef(0), &rhs().const_cast_derived().col(j).coeffRef(0), numeric, 0, 0); - ei_assert(!errorCode && "UmfPack could not solve the system."); + eigen_assert(!errorCode && "UmfPack could not solve the system."); } } }; - +} // end namespace internal template<typename MatrixType> void SparseLU<MatrixType,UmfPack>::compute(const MatrixType& a) @@ -258,7 +259,7 @@ void SparseLU<MatrixType,UmfPack>::compute(const MatrixType& a) typedef typename MatrixType::Index Index; const Index rows = a.rows(); const Index cols = a.cols(); - ei_assert((MatrixType::Flags&RowMajorBit)==0 && "Row major matrices are not supported yet"); + eigen_assert((MatrixType::Flags&RowMajorBit)==0 && "Row major matrices are not supported yet"); m_matrixRef = &a; @@ -322,9 +323,9 @@ bool SparseLU<MatrixType,UmfPack>::solve(const MatrixBase<BDerived> &b, MatrixBa { //const int size = m_matrix.rows(); const int rhsCols = b.cols(); -// ei_assert(size==b.rows()); - ei_assert((BDerived::Flags&RowMajorBit)==0 && "UmfPack backend does not support non col-major rhs yet"); - ei_assert((XDerived::Flags&RowMajorBit)==0 && "UmfPack backend does not support non col-major result yet"); +// eigen_assert(size==b.rows()); + eigen_assert((BDerived::Flags&RowMajorBit)==0 && "UmfPack backend does not support non col-major rhs yet"); + eigen_assert((XDerived::Flags&RowMajorBit)==0 && "UmfPack backend does not support non col-major result yet"); int errorCode; for (int j=0; j<rhsCols; ++j) diff --git a/unsupported/doc/examples/BVH_Example.cpp b/unsupported/doc/examples/BVH_Example.cpp index d135fd990..9e9959a32 100644 --- a/unsupported/doc/examples/BVH_Example.cpp +++ b/unsupported/doc/examples/BVH_Example.cpp @@ -5,7 +5,7 @@ using namespace Eigen; typedef AlignedBox<double, 2> Box2d; -Box2d ei_bounding_box(const Vector2d &v) { return Box2d(v, v); } //compute the bounding box of a single point +Box2d internal::bounding_box(const Vector2d &v) { return Box2d(v, v); } //compute the bounding box of a single point struct PointPointMinimizer //how to compute squared distances between points and rectangles { diff --git a/unsupported/doc/examples/PolynomialSolver1.cpp b/unsupported/doc/examples/PolynomialSolver1.cpp index c875c9361..71e6b825f 100644 --- a/unsupported/doc/examples/PolynomialSolver1.cpp +++ b/unsupported/doc/examples/PolynomialSolver1.cpp @@ -49,5 +49,5 @@ int main() cout.precision(10); cout << "The last root in float then in double: " << psolvef.roots()[5] << "\t" << psolve6d.roots()[5] << endl; std::complex<float> castedRoot( psolve6d.roots()[5].real(), psolve6d.roots()[5].imag() ); - cout << "Norm of the difference: " << ei_abs( psolvef.roots()[5] - castedRoot ) << endl; + cout << "Norm of the difference: " << internal::abs( psolvef.roots()[5] - castedRoot ) << endl; } diff --git a/unsupported/test/BVH.cpp b/unsupported/test/BVH.cpp index 4abf7f5bd..ba5871e66 100644 --- a/unsupported/test/BVH.cpp +++ b/unsupported/test/BVH.cpp @@ -42,11 +42,15 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(double, Dim) double radius; }; +namespace Eigen { +namespace internal { -template<typename Scalar, int Dim> AlignedBox<Scalar, Dim> ei_bounding_box(const Matrix<Scalar, Dim, 1> &v) { return AlignedBox<Scalar, Dim>(v); } -template<int Dim> AlignedBox<double, Dim> ei_bounding_box(const Ball<Dim> &b) +template<typename Scalar, int Dim> AlignedBox<Scalar, Dim> bounding_box(const Matrix<Scalar, Dim, 1> &v) { return AlignedBox<Scalar, Dim>(v); } +template<int Dim> AlignedBox<double, Dim> bounding_box(const Ball<Dim> &b) { return AlignedBox<double, Dim>(b.center.array() - b.radius, b.center.array() + b.radius); } +} // end namespace internal +} template<int Dim> struct BallPointStuff //this class provides functions to be both an intersector and a minimizer, both for a ball and a point and for two trees @@ -113,7 +117,7 @@ struct TreeTest { BallTypeList b; for(int i = 0; i < 500; ++i) { - b.push_back(BallType(VectorType::Random(), 0.5 * ei_random(0., 1.))); + b.push_back(BallType(VectorType::Random(), 0.5 * internal::random(0., 1.))); } KdBVH<double, Dim, BallType> tree(b.begin(), b.end()); @@ -132,7 +136,7 @@ struct TreeTest { BallTypeList b; for(int i = 0; i < 500; ++i) { - b.push_back(BallType(VectorType::Random(), 0.01 * ei_random(0., 1.))); + b.push_back(BallType(VectorType::Random(), 0.01 * internal::random(0., 1.))); } KdBVH<double, Dim, BallType> tree(b.begin(), b.end()); @@ -155,7 +159,7 @@ struct TreeTest VectorTypeList v; for(int i = 0; i < 50; ++i) { - b.push_back(BallType(VectorType::Random(), 0.5 * ei_random(0., 1.))); + b.push_back(BallType(VectorType::Random(), 0.5 * internal::random(0., 1.))); for(int j = 0; j < 3; ++j) v.push_back(VectorType::Random()); } @@ -180,7 +184,7 @@ struct TreeTest VectorTypeList v; for(int i = 0; i < 50; ++i) { - b.push_back(BallType(VectorType::Random(), 1e-7 + 1e-6 * ei_random(0., 1.))); + b.push_back(BallType(VectorType::Random(), 1e-7 + 1e-6 * internal::random(0., 1.))); for(int j = 0; j < 3; ++j) v.push_back(VectorType::Random()); } diff --git a/unsupported/test/NonLinearOptimization.cpp b/unsupported/test/NonLinearOptimization.cpp index 851c534f6..196cf15e0 100644 --- a/unsupported/test/NonLinearOptimization.cpp +++ b/unsupported/test/NonLinearOptimization.cpp @@ -66,11 +66,11 @@ void testChkder() /* checking the jacobian matrix. */ x << 9.2e-1, 1.3e-1, 5.4e-1; - ei_chkder(x, fvec, fjac, xp, fvecp, 1, err); + internal::chkder(x, fvec, fjac, xp, fvecp, 1, err); fcn_chkder(x, fvec, fjac, 1); fcn_chkder(x, fvec, fjac, 2); fcn_chkder(xp, fvecp, fjac, 1); - ei_chkder(x, fvec, fjac, xp, fvecp, 2, err); + internal::chkder(x, fvec, fjac, xp, fvecp, 2, err); fvecp -= fvec; @@ -220,7 +220,7 @@ void testLmder() // check covariance covfac = fnorm*fnorm/(m-n); - ei_covar(lm.fjac, lm.permutation.indices()); // TODO : move this as a function of lm + internal::covar(lm.fjac, lm.permutation.indices()); // TODO : move this as a function of lm MatrixXd cov_ref(n,n); cov_ref << @@ -611,7 +611,7 @@ void testLmdif() // check covariance covfac = fnorm*fnorm/(m-n); - ei_covar(lm.fjac, lm.permutation.indices()); // TODO : move this as a function of lm + internal::covar(lm.fjac, lm.permutation.indices()); // TODO : move this as a function of lm MatrixXd cov_ref(n,n); cov_ref << diff --git a/unsupported/test/alignedvector3.cpp b/unsupported/test/alignedvector3.cpp index f4b6dd4d9..0b46ad561 100644 --- a/unsupported/test/alignedvector3.cpp +++ b/unsupported/test/alignedvector3.cpp @@ -28,8 +28,8 @@ template<typename Scalar> void alignedvector3() { - Scalar s1 = ei_random<Scalar>(); - Scalar s2 = ei_random<Scalar>(); + Scalar s1 = internal::random<Scalar>(); + Scalar s2 = internal::random<Scalar>(); typedef Matrix<Scalar,3,1> RefType; typedef Matrix<Scalar,3,3> Mat33; typedef AlignedVector3<Scalar> FastType; diff --git a/unsupported/test/matrix_exponential.cpp b/unsupported/test/matrix_exponential.cpp index 74b2634c8..17a0dadab 100644 --- a/unsupported/test/matrix_exponential.cpp +++ b/unsupported/test/matrix_exponential.cpp @@ -127,7 +127,7 @@ void randomTest(const MatrixType& m, double tol) MatrixType m1(rows, cols), m2(rows, cols), m3(rows, cols), identity = MatrixType::Identity(rows, rows); - typedef typename NumTraits<typename ei_traits<MatrixType>::Scalar>::Real RealScalar; + typedef typename NumTraits<typename internal::traits<MatrixType>::Scalar>::Real RealScalar; for(int i = 0; i < g_repeat; i++) { m1 = MatrixType::Random(rows, cols); diff --git a/unsupported/test/matrix_function.cpp b/unsupported/test/matrix_function.cpp index 3b4cbfec6..04167abfb 100644 --- a/unsupported/test/matrix_function.cpp +++ b/unsupported/test/matrix_function.cpp @@ -45,15 +45,15 @@ MatrixType randomMatrixWithRealEivals(const typename MatrixType::Index size) typedef typename MatrixType::RealScalar RealScalar; MatrixType diag = MatrixType::Zero(size, size); for (Index i = 0; i < size; ++i) { - diag(i, i) = Scalar(RealScalar(ei_random<int>(0,2))) - + ei_random<Scalar>() * Scalar(RealScalar(0.01)); + diag(i, i) = Scalar(RealScalar(internal::random<int>(0,2))) + + internal::random<Scalar>() * Scalar(RealScalar(0.01)); } MatrixType A = MatrixType::Random(size, size); HouseholderQR<MatrixType> QRofA(A); return QRofA.householderQ().inverse() * diag * QRofA.householderQ(); } -template <typename MatrixType, int IsComplex = NumTraits<typename ei_traits<MatrixType>::Scalar>::IsComplex> +template <typename MatrixType, int IsComplex = NumTraits<typename internal::traits<MatrixType>::Scalar>::IsComplex> struct randomMatrixWithImagEivals { // Returns a matrix with eigenvalues clustered around 0 and +/- i. @@ -71,12 +71,12 @@ struct randomMatrixWithImagEivals<MatrixType, 0> MatrixType diag = MatrixType::Zero(size, size); Index i = 0; while (i < size) { - Index randomInt = ei_random<Index>(-1, 1); + Index randomInt = internal::random<Index>(-1, 1); if (randomInt == 0 || i == size-1) { - diag(i, i) = ei_random<Scalar>() * Scalar(0.01); + diag(i, i) = internal::random<Scalar>() * Scalar(0.01); ++i; } else { - Scalar alpha = Scalar(randomInt) + ei_random<Scalar>() * Scalar(0.01); + Scalar alpha = Scalar(randomInt) + internal::random<Scalar>() * Scalar(0.01); diag(i, i+1) = alpha; diag(i+1, i) = -alpha; i += 2; @@ -100,8 +100,8 @@ struct randomMatrixWithImagEivals<MatrixType, 1> const Scalar imagUnit(0, 1); MatrixType diag = MatrixType::Zero(size, size); for (Index i = 0; i < size; ++i) { - diag(i, i) = Scalar(RealScalar(ei_random<Index>(-1, 1))) * imagUnit - + ei_random<Scalar>() * Scalar(RealScalar(0.01)); + diag(i, i) = Scalar(RealScalar(internal::random<Index>(-1, 1))) * imagUnit + + internal::random<Scalar>() * Scalar(RealScalar(0.01)); } MatrixType A = MatrixType::Random(size, size); HouseholderQR<MatrixType> QRofA(A); @@ -113,7 +113,7 @@ struct randomMatrixWithImagEivals<MatrixType, 1> template<typename MatrixType> void testMatrixExponential(const MatrixType& A) { - typedef typename ei_traits<MatrixType>::Scalar Scalar; + typedef typename internal::traits<MatrixType>::Scalar Scalar; typedef typename NumTraits<Scalar>::Real RealScalar; typedef std::complex<RealScalar> ComplexScalar; diff --git a/unsupported/test/mpreal_support.cpp b/unsupported/test/mpreal_support.cpp index 32570f092..4e8e583f0 100644 --- a/unsupported/test/mpreal_support.cpp +++ b/unsupported/test/mpreal_support.cpp @@ -17,7 +17,7 @@ void test_mpreal_support() std::cerr << "lowest = " << NumTraits<mpreal>::lowest() << "\n"; for(int i = 0; i < g_repeat; i++) { - int s = ei_random<int>(1,100); + int s = Eigen::internal::random<int>(1,100); MatrixXmp A = MatrixXmp::Random(s,s); MatrixXmp B = MatrixXmp::Random(s,s); MatrixXmp S = A.adjoint() * A; diff --git a/unsupported/test/openglsupport.cpp b/unsupported/test/openglsupport.cpp index a33e9950b..63e1b44eb 100644 --- a/unsupported/test/openglsupport.cpp +++ b/unsupported/test/openglsupport.cpp @@ -160,10 +160,10 @@ void test_openglsupport() VERIFY_MATRIX(glMultMatrix(md44), md44); // Quaternion - Quaterniond qd(AngleAxisd(ei_random<double>(), Vector3d::Random())); + Quaterniond qd(AngleAxisd(internal::random<double>(), Vector3d::Random())); VERIFY_MATRIX(glRotate(qd), Projective3d(qd).matrix()); - Quaternionf qf(AngleAxisf(ei_random<double>(), Vector3f::Random())); + Quaternionf qf(AngleAxisf(internal::random<double>(), Vector3f::Random())); VERIFY_MATRIX(glRotate(qf), Projective3f(qf).matrix()); // 3D Transform @@ -222,10 +222,10 @@ void test_openglsupport() Vector3d vd3; vd3.setRandom(); VERIFY_MATRIX(glScale(vd3), Projective3d(Scaling(vd3)).matrix()); - UniformScaling<float> usf(ei_random<float>()); + UniformScaling<float> usf(internal::random<float>()); VERIFY_MATRIX(glScale(usf), Projective3f(usf).matrix()); - UniformScaling<double> usd(ei_random<double>()); + UniformScaling<double> usd(internal::random<double>()); VERIFY_MATRIX(glScale(usd), Projective3d(usd).matrix()); } diff --git a/unsupported/test/polynomialsolver.cpp b/unsupported/test/polynomialsolver.cpp index f6a574a60..8120ef3e3 100644 --- a/unsupported/test/polynomialsolver.cpp +++ b/unsupported/test/polynomialsolver.cpp @@ -33,15 +33,17 @@ using namespace std; +namespace Eigen { +namespace internal { template<int Size> -struct ei_increment_if_fixed_size +struct increment_if_fixed_size { enum { ret = (Size == Dynamic) ? Dynamic : Size+1 }; }; - - +} +} template<int Deg, typename POLYNOMIAL, typename SOLVER> @@ -72,7 +74,7 @@ bool aux_evalSolver( const POLYNOMIAL& pols, SOLVER& psolve ) } #ifdef HAS_GSL - if (ei_is_same_type< Scalar, double>::ret) + if (internal::is_same_type< Scalar, double>::ret) { typedef GslTraits<Scalar> Gsl; RootsType gslRoots(deg); @@ -104,7 +106,7 @@ bool aux_evalSolver( const POLYNOMIAL& pols, SOLVER& psolve ) bool distinctModuli=true; for( size_t i=1; i<rootModuli.size() && distinctModuli; ++i ) { - if( ei_isApprox( rootModuli[i], rootModuli[i-1] ) ){ + if( internal::isApprox( rootModuli[i], rootModuli[i-1] ) ){ distinctModuli = false; } } VERIFY( evalToZero || !distinctModuli ); @@ -158,51 +160,51 @@ void evalSolverSugarFunction( const POLYNOMIAL& pols, const ROOTS& roots, const psolve.realRoots( calc_realRoots ); VERIFY( calc_realRoots.size() == (size_t)real_roots.size() ); - const Scalar psPrec = ei_sqrt( test_precision<Scalar>() ); + const Scalar psPrec = internal::sqrt( test_precision<Scalar>() ); for( size_t i=0; i<calc_realRoots.size(); ++i ) { bool found = false; for( size_t j=0; j<calc_realRoots.size()&& !found; ++j ) { - if( ei_isApprox( calc_realRoots[i], real_roots[j] ), psPrec ){ + if( internal::isApprox( calc_realRoots[i], real_roots[j] ), psPrec ){ found = true; } } VERIFY( found ); } //Test greatestRoot - VERIFY( ei_isApprox( roots.array().abs().maxCoeff(), - ei_abs( psolve.greatestRoot() ), psPrec ) ); + VERIFY( internal::isApprox( roots.array().abs().maxCoeff(), + internal::abs( psolve.greatestRoot() ), psPrec ) ); //Test smallestRoot - VERIFY( ei_isApprox( roots.array().abs().minCoeff(), - ei_abs( psolve.smallestRoot() ), psPrec ) ); + VERIFY( internal::isApprox( roots.array().abs().minCoeff(), + internal::abs( psolve.smallestRoot() ), psPrec ) ); bool hasRealRoot; //Test absGreatestRealRoot Real r = psolve.absGreatestRealRoot( hasRealRoot ); VERIFY( hasRealRoot == (real_roots.size() > 0 ) ); if( hasRealRoot ){ - VERIFY( ei_isApprox( real_roots.array().abs().maxCoeff(), ei_abs(r), psPrec ) ); } + VERIFY( internal::isApprox( real_roots.array().abs().maxCoeff(), internal::abs(r), psPrec ) ); } //Test absSmallestRealRoot r = psolve.absSmallestRealRoot( hasRealRoot ); VERIFY( hasRealRoot == (real_roots.size() > 0 ) ); if( hasRealRoot ){ - VERIFY( ei_isApprox( real_roots.array().abs().minCoeff(), ei_abs( r ), psPrec ) ); } + VERIFY( internal::isApprox( real_roots.array().abs().minCoeff(), internal::abs( r ), psPrec ) ); } //Test greatestRealRoot r = psolve.greatestRealRoot( hasRealRoot ); VERIFY( hasRealRoot == (real_roots.size() > 0 ) ); if( hasRealRoot ){ - VERIFY( ei_isApprox( real_roots.array().maxCoeff(), r, psPrec ) ); } + VERIFY( internal::isApprox( real_roots.array().maxCoeff(), r, psPrec ) ); } //Test smallestRealRoot r = psolve.smallestRealRoot( hasRealRoot ); VERIFY( hasRealRoot == (real_roots.size() > 0 ) ); if( hasRealRoot ){ - VERIFY( ei_isApprox( real_roots.array().minCoeff(), r, psPrec ) ); } + VERIFY( internal::isApprox( real_roots.array().minCoeff(), r, psPrec ) ); } } } @@ -210,7 +212,7 @@ void evalSolverSugarFunction( const POLYNOMIAL& pols, const ROOTS& roots, const template<typename _Scalar, int _Deg> void polynomialsolver(int deg) { - typedef ei_increment_if_fixed_size<_Deg> Dim; + typedef internal::increment_if_fixed_size<_Deg> Dim; typedef Matrix<_Scalar,Dim::ret,1> PolynomialType; typedef Matrix<_Scalar,_Deg,1> EvalRootsType; @@ -219,7 +221,7 @@ void polynomialsolver(int deg) evalSolver<_Deg,PolynomialType>( pols ); cout << "Hard cases" << endl; - _Scalar multipleRoot = ei_random<_Scalar>(); + _Scalar multipleRoot = internal::random<_Scalar>(); EvalRootsType allRoots = EvalRootsType::Constant(deg,multipleRoot); roots_to_monicPolynomial( allRoots, pols ); evalSolver<_Deg,PolynomialType>( pols ); @@ -250,7 +252,7 @@ template<typename _Scalar> void polynomialsolver_scalar() CALL_SUBTEST_8( (polynomialsolver<_Scalar,8>(8)) ); CALL_SUBTEST_9( (polynomialsolver<_Scalar,Dynamic>( - ei_random<int>(9,45) + internal::random<int>(9,45) )) ); } diff --git a/unsupported/test/polynomialutils.cpp b/unsupported/test/polynomialutils.cpp index 7f93c2f0d..7ff913c37 100644 --- a/unsupported/test/polynomialutils.cpp +++ b/unsupported/test/polynomialutils.cpp @@ -28,18 +28,22 @@ using namespace std; +namespace Eigen { +namespace internal { template<int Size> -struct ei_increment_if_fixed_size +struct increment_if_fixed_size { enum { ret = (Size == Dynamic) ? Dynamic : Size+1 }; }; +} +} template<typename _Scalar, int _Deg> void realRoots_to_monicPolynomial_test(int deg) { - typedef ei_increment_if_fixed_size<_Deg> Dim; + typedef internal::increment_if_fixed_size<_Deg> Dim; typedef Matrix<_Scalar,Dim::ret,1> PolynomialType; typedef Matrix<_Scalar,_Deg,1> EvalRootsType; @@ -68,7 +72,7 @@ template<typename _Scalar> void realRoots_to_monicPolynomial_scalar() CALL_SUBTEST_8( (realRoots_to_monicPolynomial_test<_Scalar,17>(17)) ); CALL_SUBTEST_9( (realRoots_to_monicPolynomial_test<_Scalar,Dynamic>( - ei_random<int>(18,26) )) ); + internal::random<int>(18,26) )) ); } @@ -77,7 +81,7 @@ template<typename _Scalar> void realRoots_to_monicPolynomial_scalar() template<typename _Scalar, int _Deg> void CauchyBounds(int deg) { - typedef ei_increment_if_fixed_size<_Deg> Dim; + typedef internal::increment_if_fixed_size<_Deg> Dim; typedef Matrix<_Scalar,Dim::ret,1> PolynomialType; typedef Matrix<_Scalar,_Deg,1> EvalRootsType; @@ -109,7 +113,7 @@ template<typename _Scalar> void CauchyBounds_scalar() CALL_SUBTEST_8( (CauchyBounds<_Scalar,17>(17)) ); CALL_SUBTEST_9( (CauchyBounds<_Scalar,Dynamic>( - ei_random<int>(18,26) )) ); + internal::random<int>(18,26) )) ); } void test_polynomialutils() diff --git a/unsupported/test/sparse_extra.cpp b/unsupported/test/sparse_extra.cpp index 6cf1f50c4..84dfbdda6 100644 --- a/unsupported/test/sparse_extra.cpp +++ b/unsupported/test/sparse_extra.cpp @@ -35,7 +35,7 @@ bool test_random_setter(SparseMatrix<Scalar,Options>& sm, const DenseType& ref, std::vector<Vector2i> remaining = nonzeroCoords; while(!remaining.empty()) { - int i = ei_random<int>(0,static_cast<int>(remaining.size())-1); + int i = internal::random<int>(0,static_cast<int>(remaining.size())-1); w(remaining[i].x(),remaining[i].y()) = ref.coeff(remaining[i].x(),remaining[i].y()); remaining[i] = remaining.back(); remaining.pop_back(); @@ -51,7 +51,7 @@ bool test_random_setter(DynamicSparseMatrix<T>& sm, const DenseType& ref, const std::vector<Vector2i> remaining = nonzeroCoords; while(!remaining.empty()) { - int i = ei_random<int>(0,static_cast<int>(remaining.size())-1); + int i = internal::random<int>(0,static_cast<int>(remaining.size())-1); sm.coeffRef(remaining[i].x(),remaining[i].y()) = ref.coeff(remaining[i].x(),remaining[i].y()); remaining[i] = remaining.back(); remaining.pop_back(); @@ -87,7 +87,7 @@ template<typename SparseMatrixType> void sparse_extra(const SparseMatrixType& re for (int i=0; i<(int)zeroCoords.size(); ++i) { VERIFY_IS_MUCH_SMALLER_THAN( m.coeff(zeroCoords[i].x(),zeroCoords[i].y()), eps ); - if(ei_is_same_type<SparseMatrixType,SparseMatrix<Scalar,Flags> >::ret) + if(internal::is_same_type<SparseMatrixType,SparseMatrix<Scalar,Flags> >::ret) VERIFY_RAISES_ASSERT( m.coeffRef(zeroCoords[0].x(),zeroCoords[0].y()) = 5 ); } VERIFY_IS_APPROX(m, refMat); @@ -105,7 +105,7 @@ template<typename SparseMatrixType> void sparse_extra(const SparseMatrixType& re // std::vector<Vector2i> remaining = nonzeroCoords; // while(!remaining.empty()) // { -// int i = ei_random<int>(0,remaining.size()-1); +// int i = internal::random<int>(0,remaining.size()-1); // w->coeffRef(remaining[i].x(),remaining[i].y()) = refMat.coeff(remaining[i].x(),remaining[i].y()); // remaining[i] = remaining.back(); // remaining.pop_back(); diff --git a/unsupported/test/sparse_ldlt.cpp b/unsupported/test/sparse_ldlt.cpp index 5af4b77b4..275839670 100644 --- a/unsupported/test/sparse_ldlt.cpp +++ b/unsupported/test/sparse_ldlt.cpp @@ -43,7 +43,7 @@ template<typename Scalar> void sparse_ldlt(int rows, int cols) initSparse<Scalar>(density, refMat2, m2, ForceNonZeroDiag|MakeUpperTriangular, 0, 0); for(int i=0; i<rows; ++i) - m2.coeffRef(i,i) = refMat2(i,i) = ei_abs(ei_real(refMat2(i,i))); + m2.coeffRef(i,i) = refMat2(i,i) = internal::abs(internal::real(refMat2(i,i))); refX = refMat2.template selfadjointView<Upper>().ldlt().solve(b); typedef SparseMatrix<Scalar,Upper|SelfAdjoint> SparseSelfAdjointMatrix; @@ -85,7 +85,7 @@ void test_sparse_ldlt() { for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1(sparse_ldlt<double>(8, 8) ); - int s = ei_random<int>(1,300); + int s = internal::random<int>(1,300); CALL_SUBTEST_2(sparse_ldlt<std::complex<double> >(s,s) ); CALL_SUBTEST_1(sparse_ldlt<double>(s,s) ); } diff --git a/unsupported/test/sparse_llt.cpp b/unsupported/test/sparse_llt.cpp index 72a8382a1..2ec850ea0 100644 --- a/unsupported/test/sparse_llt.cpp +++ b/unsupported/test/sparse_llt.cpp @@ -45,7 +45,7 @@ template<typename Scalar> void sparse_llt(int rows, int cols) initSparse<Scalar>(density, refMat2, m2, ForceNonZeroDiag|MakeLowerTriangular, 0, 0); for(int i=0; i<rows; ++i) - m2.coeffRef(i,i) = refMat2(i,i) = ei_abs(ei_real(refMat2(i,i))); + m2.coeffRef(i,i) = refMat2(i,i) = internal::abs(internal::real(refMat2(i,i))); refX = refMat2.template selfadjointView<Lower>().llt().solve(b); if (!NumTraits<Scalar>::IsComplex) @@ -78,7 +78,7 @@ void test_sparse_llt() { for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1(sparse_llt<double>(8, 8) ); - int s = ei_random<int>(1,300); + int s = internal::random<int>(1,300); CALL_SUBTEST_2(sparse_llt<std::complex<double> >(s,s) ); CALL_SUBTEST_1(sparse_llt<double>(s,s) ); } diff --git a/unsupported/test/sparse_lu.cpp b/unsupported/test/sparse_lu.cpp index 75aa7a924..e693499bb 100644 --- a/unsupported/test/sparse_lu.cpp +++ b/unsupported/test/sparse_lu.cpp @@ -109,7 +109,7 @@ void test_sparse_lu() { for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1(sparse_lu<double>(8, 8) ); - int s = ei_random<int>(1,300); + int s = internal::random<int>(1,300); CALL_SUBTEST_2(sparse_lu<std::complex<double> >(s,s) ); CALL_SUBTEST_1(sparse_lu<double>(s,s) ); } |