diff --git a/Eigen/Core b/Eigen/Core index 9f1c63826..d18835613 100644 --- a/Eigen/Core +++ b/Eigen/Core @@ -432,6 +432,7 @@ using std::ptrdiff_t; #include "src/Core/util/IndexedViewHelper.h" #include "src/Core/ArithmeticSequence.h" +#include "src/Core/IO.h" #include "src/Core/DenseCoeffsBase.h" #include "src/Core/DenseBase.h" #include "src/Core/MatrixBase.h" @@ -480,7 +481,6 @@ using std::ptrdiff_t; #include "src/Core/Redux.h" #include "src/Core/Visitor.h" #include "src/Core/Fuzzy.h" -#include "src/Core/IO.h" #include "src/Core/Swap.h" #include "src/Core/CommaInitializer.h" #include "src/Core/GeneralProduct.h" diff --git a/Eigen/Sparse b/Eigen/Sparse index a2ef7a665..136e681a1 100644 --- a/Eigen/Sparse +++ b/Eigen/Sparse @@ -25,7 +25,9 @@ #include "SparseCore" #include "OrderingMethods" +#ifndef EIGEN_MPL2_ONLY #include "SparseCholesky" +#endif #include "SparseLU" #include "SparseQR" #include "IterativeLinearSolvers" diff --git a/Eigen/src/Core/ArithmeticSequence.h b/Eigen/src/Core/ArithmeticSequence.h index 99b954432..ada1571f1 100644 --- a/Eigen/src/Core/ArithmeticSequence.h +++ b/Eigen/src/Core/ArithmeticSequence.h @@ -14,7 +14,7 @@ namespace Eigen { namespace internal { -#if !EIGEN_HAS_CXX11 +#if (!EIGEN_HAS_CXX11) || !((!EIGEN_COMP_GNUC) || EIGEN_COMP_GNUC>=48) template struct aseq_negate {}; template<> struct aseq_negate { @@ -138,7 +138,7 @@ protected: public: -#if EIGEN_HAS_CXX11 +#if EIGEN_HAS_CXX11 && ((!EIGEN_COMP_GNUC) || EIGEN_COMP_GNUC>=48) auto reverse() const -> decltype(Eigen::seqN(m_first+(m_size+fix<-1>())*m_incr,m_size,-m_incr)) { return seqN(m_first+(m_size+fix<-1>())*m_incr,m_size,-m_incr); } diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h index a8229cf03..fc807577b 100644 --- a/Eigen/src/Core/DenseBase.h +++ b/Eigen/src/Core/DenseBase.h @@ -463,7 +463,17 @@ template class DenseBase EIGEN_DEVICE_FUNC void visit(Visitor& func) const; - inline const WithFormat format(const IOFormat& fmt) const; + /** \returns a WithFormat proxy object allowing to print a matrix the with given + * format \a fmt. + * + * See class IOFormat for some examples. + * + * \sa class IOFormat, class WithFormat + */ + inline const WithFormat format(const IOFormat& fmt) const + { + return WithFormat(derived(), fmt); + } /** \returns the unique coefficient of a 1x1 expression */ EIGEN_DEVICE_FUNC diff --git a/Eigen/src/Core/IO.h b/Eigen/src/Core/IO.h index 644228c3f..da7fd6cce 100644 --- a/Eigen/src/Core/IO.h +++ b/Eigen/src/Core/IO.h @@ -109,20 +109,6 @@ class WithFormat IOFormat m_format; }; -/** \returns a WithFormat proxy object allowing to print a matrix the with given - * format \a fmt. - * - * See class IOFormat for some examples. - * - * \sa class IOFormat, class WithFormat - */ -template -inline const WithFormat -DenseBase::format(const IOFormat& fmt) const -{ - return WithFormat(derived(), fmt); -} - namespace internal { // NOTE: This helper is kept for backward compatibility with previous code specializing diff --git a/Eigen/src/Core/IndexedView.h b/Eigen/src/Core/IndexedView.h index 63878428e..8c57a277c 100644 --- a/Eigen/src/Core/IndexedView.h +++ b/Eigen/src/Core/IndexedView.h @@ -19,8 +19,8 @@ struct traits > : traits { enum { - RowsAtCompileTime = array_size::value, - ColsAtCompileTime = array_size::value, + RowsAtCompileTime = int(array_size::value), + ColsAtCompileTime = int(array_size::value), MaxRowsAtCompileTime = RowsAtCompileTime != Dynamic ? int(RowsAtCompileTime) : int(traits::MaxRowsAtCompileTime), MaxColsAtCompileTime = ColsAtCompileTime != Dynamic ? int(ColsAtCompileTime) : int(traits::MaxColsAtCompileTime), @@ -29,8 +29,8 @@ struct traits > : (MaxColsAtCompileTime==1&&MaxRowsAtCompileTime!=1) ? 0 : XprTypeIsRowMajor, - RowIncr = get_compile_time_incr::value, - ColIncr = get_compile_time_incr::value, + RowIncr = int(get_compile_time_incr::value), + ColIncr = int(get_compile_time_incr::value), InnerIncr = IsRowMajor ? ColIncr : RowIncr, OuterIncr = IsRowMajor ? RowIncr : ColIncr, @@ -51,7 +51,7 @@ struct traits > // FIXME we deal with compile-time strides if and only if we have DirectAccessBit flag, // but this is too strict regarding negative strides... - DirectAccessMask = (InnerIncr!=UndefinedIncr && OuterIncr!=UndefinedIncr && InnerIncr>=0 && OuterIncr>=0) ? DirectAccessBit : 0, + DirectAccessMask = (int(InnerIncr)!=UndefinedIncr && int(OuterIncr)!=UndefinedIncr && InnerIncr>=0 && OuterIncr>=0) ? DirectAccessBit : 0, FlagsRowMajorBit = IsRowMajor ? RowMajorBit : 0, FlagsLvalueBit = is_lvalue::value ? LvalueBit : 0, Flags = (traits::Flags & (HereditaryBits | DirectAccessMask)) | FlagsLvalueBit | FlagsRowMajorBit diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index 0e2863306..12531e342 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -349,10 +349,12 @@ # define __has_feature(x) 0 #endif +// Some old compilers do not support template specializations like: +// template void foo(const T x[N]); #if !( EIGEN_COMP_CLANG && ((EIGEN_COMP_CLANG<309) || defined(__apple_build_version__)) || EIGEN_COMP_GNUC_STRICT && EIGEN_COMP_GNUC<49) -#define EIGEN_HAS_INDEXED_VIEW 1 +#define EIGEN_HAS_STATIC_ARRAY_TEMPLATE 1 #else -#define EIGEN_HAS_INDEXED_VIEW 0 +#define EIGEN_HAS_STATIC_ARRAY_TEMPLATE 0 #endif // Upperbound on the C++ version to use. diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index ee0531b32..90eda6e70 100755 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -97,17 +97,22 @@ template<> struct is_arithmetic { enum { value = true }; }; template<> struct is_arithmetic { enum { value = true }; }; template<> struct is_arithmetic { enum { value = true }; }; -template struct is_integral { enum { value = false }; }; -template<> struct is_integral { enum { value = true }; }; -template<> struct is_integral { enum { value = true }; }; -template<> struct is_integral { enum { value = true }; }; -template<> struct is_integral { enum { value = true }; }; -template<> struct is_integral { enum { value = true }; }; -template<> struct is_integral { enum { value = true }; }; -template<> struct is_integral { enum { value = true }; }; -template<> struct is_integral { enum { value = true }; }; -template<> struct is_integral { enum { value = true }; }; -template<> struct is_integral { enum { value = true }; }; +#if EIGEN_HAS_CXX11 +using std::is_integral; +#else +template struct is_integral { enum { value = false }; }; +template<> struct is_integral { enum { value = true }; }; +template<> struct is_integral { enum { value = true }; }; +template<> struct is_integral { enum { value = true }; }; +template<> struct is_integral { enum { value = true }; }; +template<> struct is_integral { enum { value = true }; }; +template<> struct is_integral { enum { value = true }; }; +template<> struct is_integral { enum { value = true }; }; +template<> struct is_integral { enum { value = true }; }; +template<> struct is_integral { enum { value = true }; }; +template<> struct is_integral { enum { value = true }; }; +#endif + template struct add_const { typedef const T type; }; template struct add_const { typedef T& type; }; diff --git a/Eigen/src/plugins/IndexedViewMethods.h b/Eigen/src/plugins/IndexedViewMethods.h index 81e463623..22c1666c5 100644 --- a/Eigen/src/plugins/IndexedViewMethods.h +++ b/Eigen/src/plugins/IndexedViewMethods.h @@ -7,7 +7,6 @@ // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -#if EIGEN_HAS_INDEXED_VIEW #if !defined(EIGEN_PARSED_BY_DOXYGEN) // This file is automatically included twice to generate const and non-const versions @@ -113,6 +112,8 @@ operator()(const RowIndices& rowIndices, const ColIndices& colIndices) EIGEN_IND return Base::operator()(internal::eval_expr_given_size(rowIndices,rows()),internal::eval_expr_given_size(colIndices,cols())); } +#if EIGEN_HAS_STATIC_ARRAY_TEMPLATE + // The folowing three overloads are needed to handle raw Index[N] arrays. template @@ -139,6 +140,8 @@ operator()(const RowIndicesT (&rowIndices)[RowIndicesN], const ColIndicesT (&col (derived(), rowIndices, colIndices); } +#endif // EIGEN_HAS_STATIC_ARRAY_TEMPLATE + // Overloads for 1D vectors/arrays template @@ -182,6 +185,8 @@ operator()(const IndexType& id) EIGEN_INDEXED_VIEW_METHOD_CONST return Base::operator()(internal::eval_expr_given_size(id,size())); } +#if EIGEN_HAS_STATIC_ARRAY_TEMPLATE + template typename internal::enable_if >::type @@ -202,6 +207,8 @@ operator()(const IndicesT (&indices)[IndicesN]) EIGEN_INDEXED_VIEW_METHOD_CONST (derived(), indices, IvcIndex(0)); } +#endif // EIGEN_HAS_STATIC_ARRAY_TEMPLATE + #undef EIGEN_INDEXED_VIEW_METHOD_CONST #undef EIGEN_INDEXED_VIEW_METHOD_TYPE @@ -258,4 +265,3 @@ IndexedView_or_VectorBlock operator()(const Indices& indices); #endif // EIGEN_PARSED_BY_DOXYGEN -#endif // EIGEN_HAS_INDEXED_VIEW diff --git a/test/basicstuff.cpp b/test/basicstuff.cpp index 99d91f9da..c346ce6cb 100644 --- a/test/basicstuff.cpp +++ b/test/basicstuff.cpp @@ -49,6 +49,22 @@ template void basicStuff(const MatrixType& m) v1[r] = x; VERIFY_IS_APPROX(x, v1[r]); + // test fetching with various index types. + Index r1 = internal::random(0, numext::mini(Index(127),rows-1)); + x = v1(static_cast(r1)); + x = v1(static_cast(r1)); + x = v1(static_cast(r1)); + x = v1(static_cast(r1)); + x = v1(static_cast(r1)); + x = v1(static_cast(r1)); + x = v1(static_cast(r1)); + x = v1(static_cast(r1)); + x = v1(static_cast(r1)); +#if EIGEN_HAS_CXX11 + x = v1(static_cast(r1)); + x = v1(static_cast(r1)); +#endif + VERIFY_IS_APPROX( v1, v1); VERIFY_IS_NOT_APPROX( v1, 2*v1); VERIFY_IS_MUCH_SMALLER_THAN( vzero, v1); diff --git a/test/indexed_view.cpp b/test/indexed_view.cpp index 4cbc00639..7245cf378 100644 --- a/test/indexed_view.cpp +++ b/test/indexed_view.cpp @@ -79,7 +79,6 @@ is_same_seq_type(const T1& a, const T2& b) void check_indexed_view() { -#if EIGEN_HAS_INDEXED_VIEW using Eigen::placeholders::all; using Eigen::placeholders::last; using Eigen::placeholders::end; @@ -298,6 +297,7 @@ void check_indexed_view() VERIFY_IS_APPROX( (A(std::array{{1,3,5}}, std::array{{9,6,3,0}})), A(seqN(1,3,2), seqN(9,4,-3)) ); +#if EIGEN_HAS_STATIC_ARRAY_TEMPLATE VERIFY_IS_APPROX( A({3, 1, 6, 5}, all), A(std::array{{3, 1, 6, 5}}, all) ); VERIFY_IS_APPROX( A(all,{3, 1, 6, 5}), A(all,std::array{{3, 1, 6, 5}}) ); VERIFY_IS_APPROX( A({1,3,5},{3, 1, 6, 5}), A(std::array{{1,3,5}},std::array{{3, 1, 6, 5}}) ); @@ -310,6 +310,7 @@ void check_indexed_view() VERIFY_IS_APPROX( b({3, 1, 6, 5}), b(std::array{{3, 1, 6, 5}}) ); VERIFY_IS_EQUAL( b({1,3,5}).SizeAtCompileTime, 3 ); +#endif #endif @@ -365,7 +366,6 @@ void check_indexed_view() VERIFY( is_same_eq( cA.middleRows<3>(1), cA.middleRows(1,fix<3>)) ); } -#endif // EIGEN_HAS_INDEXED_VIEW } void test_indexed_view() diff --git a/test/mpl2only.cpp b/test/mpl2only.cpp index 5ef0d2b2e..7d04d6bba 100644 --- a/test/mpl2only.cpp +++ b/test/mpl2only.cpp @@ -12,7 +12,9 @@ #include #include #include +#include #include +#include int main() {