mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-11 19:29:02 +08:00
Merged eigen/eigen into default
This commit is contained in:
commit
31a25ab226
@ -432,6 +432,7 @@ using std::ptrdiff_t;
|
|||||||
|
|
||||||
#include "src/Core/util/IndexedViewHelper.h"
|
#include "src/Core/util/IndexedViewHelper.h"
|
||||||
#include "src/Core/ArithmeticSequence.h"
|
#include "src/Core/ArithmeticSequence.h"
|
||||||
|
#include "src/Core/IO.h"
|
||||||
#include "src/Core/DenseCoeffsBase.h"
|
#include "src/Core/DenseCoeffsBase.h"
|
||||||
#include "src/Core/DenseBase.h"
|
#include "src/Core/DenseBase.h"
|
||||||
#include "src/Core/MatrixBase.h"
|
#include "src/Core/MatrixBase.h"
|
||||||
@ -480,7 +481,6 @@ using std::ptrdiff_t;
|
|||||||
#include "src/Core/Redux.h"
|
#include "src/Core/Redux.h"
|
||||||
#include "src/Core/Visitor.h"
|
#include "src/Core/Visitor.h"
|
||||||
#include "src/Core/Fuzzy.h"
|
#include "src/Core/Fuzzy.h"
|
||||||
#include "src/Core/IO.h"
|
|
||||||
#include "src/Core/Swap.h"
|
#include "src/Core/Swap.h"
|
||||||
#include "src/Core/CommaInitializer.h"
|
#include "src/Core/CommaInitializer.h"
|
||||||
#include "src/Core/GeneralProduct.h"
|
#include "src/Core/GeneralProduct.h"
|
||||||
|
@ -25,7 +25,9 @@
|
|||||||
|
|
||||||
#include "SparseCore"
|
#include "SparseCore"
|
||||||
#include "OrderingMethods"
|
#include "OrderingMethods"
|
||||||
|
#ifndef EIGEN_MPL2_ONLY
|
||||||
#include "SparseCholesky"
|
#include "SparseCholesky"
|
||||||
|
#endif
|
||||||
#include "SparseLU"
|
#include "SparseLU"
|
||||||
#include "SparseQR"
|
#include "SparseQR"
|
||||||
#include "IterativeLinearSolvers"
|
#include "IterativeLinearSolvers"
|
||||||
|
@ -14,7 +14,7 @@ namespace Eigen {
|
|||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
#if !EIGEN_HAS_CXX11
|
#if (!EIGEN_HAS_CXX11) || !((!EIGEN_COMP_GNUC) || EIGEN_COMP_GNUC>=48)
|
||||||
template<typename T> struct aseq_negate {};
|
template<typename T> struct aseq_negate {};
|
||||||
|
|
||||||
template<> struct aseq_negate<Index> {
|
template<> struct aseq_negate<Index> {
|
||||||
@ -138,7 +138,7 @@ protected:
|
|||||||
|
|
||||||
public:
|
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)) {
|
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);
|
return seqN(m_first+(m_size+fix<-1>())*m_incr,m_size,-m_incr);
|
||||||
}
|
}
|
||||||
|
@ -463,7 +463,17 @@ template<typename Derived> class DenseBase
|
|||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
void visit(Visitor& func) const;
|
void visit(Visitor& func) const;
|
||||||
|
|
||||||
inline const WithFormat<Derived> 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<Derived> format(const IOFormat& fmt) const
|
||||||
|
{
|
||||||
|
return WithFormat<Derived>(derived(), fmt);
|
||||||
|
}
|
||||||
|
|
||||||
/** \returns the unique coefficient of a 1x1 expression */
|
/** \returns the unique coefficient of a 1x1 expression */
|
||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
|
@ -109,20 +109,6 @@ class WithFormat
|
|||||||
IOFormat m_format;
|
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<typename Derived>
|
|
||||||
inline const WithFormat<Derived>
|
|
||||||
DenseBase<Derived>::format(const IOFormat& fmt) const
|
|
||||||
{
|
|
||||||
return WithFormat<Derived>(derived(), fmt);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
// NOTE: This helper is kept for backward compatibility with previous code specializing
|
// NOTE: This helper is kept for backward compatibility with previous code specializing
|
||||||
|
@ -19,8 +19,8 @@ struct traits<IndexedView<XprType, RowIndices, ColIndices> >
|
|||||||
: traits<XprType>
|
: traits<XprType>
|
||||||
{
|
{
|
||||||
enum {
|
enum {
|
||||||
RowsAtCompileTime = array_size<RowIndices>::value,
|
RowsAtCompileTime = int(array_size<RowIndices>::value),
|
||||||
ColsAtCompileTime = array_size<ColIndices>::value,
|
ColsAtCompileTime = int(array_size<ColIndices>::value),
|
||||||
MaxRowsAtCompileTime = RowsAtCompileTime != Dynamic ? int(RowsAtCompileTime) : int(traits<XprType>::MaxRowsAtCompileTime),
|
MaxRowsAtCompileTime = RowsAtCompileTime != Dynamic ? int(RowsAtCompileTime) : int(traits<XprType>::MaxRowsAtCompileTime),
|
||||||
MaxColsAtCompileTime = ColsAtCompileTime != Dynamic ? int(ColsAtCompileTime) : int(traits<XprType>::MaxColsAtCompileTime),
|
MaxColsAtCompileTime = ColsAtCompileTime != Dynamic ? int(ColsAtCompileTime) : int(traits<XprType>::MaxColsAtCompileTime),
|
||||||
|
|
||||||
@ -29,8 +29,8 @@ struct traits<IndexedView<XprType, RowIndices, ColIndices> >
|
|||||||
: (MaxColsAtCompileTime==1&&MaxRowsAtCompileTime!=1) ? 0
|
: (MaxColsAtCompileTime==1&&MaxRowsAtCompileTime!=1) ? 0
|
||||||
: XprTypeIsRowMajor,
|
: XprTypeIsRowMajor,
|
||||||
|
|
||||||
RowIncr = get_compile_time_incr<RowIndices>::value,
|
RowIncr = int(get_compile_time_incr<RowIndices>::value),
|
||||||
ColIncr = get_compile_time_incr<ColIndices>::value,
|
ColIncr = int(get_compile_time_incr<ColIndices>::value),
|
||||||
InnerIncr = IsRowMajor ? ColIncr : RowIncr,
|
InnerIncr = IsRowMajor ? ColIncr : RowIncr,
|
||||||
OuterIncr = IsRowMajor ? RowIncr : ColIncr,
|
OuterIncr = IsRowMajor ? RowIncr : ColIncr,
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ struct traits<IndexedView<XprType, RowIndices, ColIndices> >
|
|||||||
|
|
||||||
// FIXME we deal with compile-time strides if and only if we have DirectAccessBit flag,
|
// FIXME we deal with compile-time strides if and only if we have DirectAccessBit flag,
|
||||||
// but this is too strict regarding negative strides...
|
// 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,
|
FlagsRowMajorBit = IsRowMajor ? RowMajorBit : 0,
|
||||||
FlagsLvalueBit = is_lvalue<XprType>::value ? LvalueBit : 0,
|
FlagsLvalueBit = is_lvalue<XprType>::value ? LvalueBit : 0,
|
||||||
Flags = (traits<XprType>::Flags & (HereditaryBits | DirectAccessMask)) | FlagsLvalueBit | FlagsRowMajorBit
|
Flags = (traits<XprType>::Flags & (HereditaryBits | DirectAccessMask)) | FlagsLvalueBit | FlagsRowMajorBit
|
||||||
|
@ -349,10 +349,12 @@
|
|||||||
# define __has_feature(x) 0
|
# define __has_feature(x) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Some old compilers do not support template specializations like:
|
||||||
|
// template<typename T,int N> 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)
|
#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
|
#else
|
||||||
#define EIGEN_HAS_INDEXED_VIEW 0
|
#define EIGEN_HAS_STATIC_ARRAY_TEMPLATE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Upperbound on the C++ version to use.
|
// Upperbound on the C++ version to use.
|
||||||
|
@ -97,17 +97,22 @@ template<> struct is_arithmetic<unsigned int> { enum { value = true }; };
|
|||||||
template<> struct is_arithmetic<signed long> { enum { value = true }; };
|
template<> struct is_arithmetic<signed long> { enum { value = true }; };
|
||||||
template<> struct is_arithmetic<unsigned long> { enum { value = true }; };
|
template<> struct is_arithmetic<unsigned long> { enum { value = true }; };
|
||||||
|
|
||||||
template<typename T> struct is_integral { enum { value = false }; };
|
#if EIGEN_HAS_CXX11
|
||||||
template<> struct is_integral<bool> { enum { value = true }; };
|
using std::is_integral;
|
||||||
template<> struct is_integral<char> { enum { value = true }; };
|
#else
|
||||||
template<> struct is_integral<signed char> { enum { value = true }; };
|
template<typename T> struct is_integral { enum { value = false }; };
|
||||||
template<> struct is_integral<unsigned char> { enum { value = true }; };
|
template<> struct is_integral<bool> { enum { value = true }; };
|
||||||
template<> struct is_integral<signed short> { enum { value = true }; };
|
template<> struct is_integral<char> { enum { value = true }; };
|
||||||
template<> struct is_integral<unsigned short> { enum { value = true }; };
|
template<> struct is_integral<signed char> { enum { value = true }; };
|
||||||
template<> struct is_integral<signed int> { enum { value = true }; };
|
template<> struct is_integral<unsigned char> { enum { value = true }; };
|
||||||
template<> struct is_integral<unsigned int> { enum { value = true }; };
|
template<> struct is_integral<signed short> { enum { value = true }; };
|
||||||
template<> struct is_integral<signed long> { enum { value = true }; };
|
template<> struct is_integral<unsigned short> { enum { value = true }; };
|
||||||
template<> struct is_integral<unsigned long> { enum { value = true }; };
|
template<> struct is_integral<signed int> { enum { value = true }; };
|
||||||
|
template<> struct is_integral<unsigned int> { enum { value = true }; };
|
||||||
|
template<> struct is_integral<signed long> { enum { value = true }; };
|
||||||
|
template<> struct is_integral<unsigned long> { enum { value = true }; };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
template <typename T> struct add_const { typedef const T type; };
|
template <typename T> struct add_const { typedef const T type; };
|
||||||
template <typename T> struct add_const<T&> { typedef T& type; };
|
template <typename T> struct add_const<T&> { typedef T& type; };
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
// 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/.
|
// 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)
|
#if !defined(EIGEN_PARSED_BY_DOXYGEN)
|
||||||
|
|
||||||
// This file is automatically included twice to generate const and non-const versions
|
// 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()));
|
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.
|
// The folowing three overloads are needed to handle raw Index[N] arrays.
|
||||||
|
|
||||||
template<typename RowIndicesT, std::size_t RowIndicesN, typename ColIndices>
|
template<typename RowIndicesT, std::size_t RowIndicesN, typename ColIndices>
|
||||||
@ -139,6 +140,8 @@ operator()(const RowIndicesT (&rowIndices)[RowIndicesN], const ColIndicesT (&col
|
|||||||
(derived(), rowIndices, colIndices);
|
(derived(), rowIndices, colIndices);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // EIGEN_HAS_STATIC_ARRAY_TEMPLATE
|
||||||
|
|
||||||
// Overloads for 1D vectors/arrays
|
// Overloads for 1D vectors/arrays
|
||||||
|
|
||||||
template<typename Indices>
|
template<typename Indices>
|
||||||
@ -182,6 +185,8 @@ operator()(const IndexType& id) EIGEN_INDEXED_VIEW_METHOD_CONST
|
|||||||
return Base::operator()(internal::eval_expr_given_size(id,size()));
|
return Base::operator()(internal::eval_expr_given_size(id,size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if EIGEN_HAS_STATIC_ARRAY_TEMPLATE
|
||||||
|
|
||||||
template<typename IndicesT, std::size_t IndicesN>
|
template<typename IndicesT, std::size_t IndicesN>
|
||||||
typename internal::enable_if<IsRowMajor,
|
typename internal::enable_if<IsRowMajor,
|
||||||
IndexedView<EIGEN_INDEXED_VIEW_METHOD_CONST Derived,IvcIndex,const IndicesT (&)[IndicesN]> >::type
|
IndexedView<EIGEN_INDEXED_VIEW_METHOD_CONST Derived,IvcIndex,const IndicesT (&)[IndicesN]> >::type
|
||||||
@ -202,6 +207,8 @@ operator()(const IndicesT (&indices)[IndicesN]) EIGEN_INDEXED_VIEW_METHOD_CONST
|
|||||||
(derived(), indices, IvcIndex(0));
|
(derived(), indices, IvcIndex(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // EIGEN_HAS_STATIC_ARRAY_TEMPLATE
|
||||||
|
|
||||||
#undef EIGEN_INDEXED_VIEW_METHOD_CONST
|
#undef EIGEN_INDEXED_VIEW_METHOD_CONST
|
||||||
#undef EIGEN_INDEXED_VIEW_METHOD_TYPE
|
#undef EIGEN_INDEXED_VIEW_METHOD_TYPE
|
||||||
|
|
||||||
@ -258,4 +265,3 @@ IndexedView_or_VectorBlock
|
|||||||
operator()(const Indices& indices);
|
operator()(const Indices& indices);
|
||||||
|
|
||||||
#endif // EIGEN_PARSED_BY_DOXYGEN
|
#endif // EIGEN_PARSED_BY_DOXYGEN
|
||||||
#endif // EIGEN_HAS_INDEXED_VIEW
|
|
||||||
|
@ -49,6 +49,22 @@ template<typename MatrixType> void basicStuff(const MatrixType& m)
|
|||||||
v1[r] = x;
|
v1[r] = x;
|
||||||
VERIFY_IS_APPROX(x, v1[r]);
|
VERIFY_IS_APPROX(x, v1[r]);
|
||||||
|
|
||||||
|
// test fetching with various index types.
|
||||||
|
Index r1 = internal::random<Index>(0, numext::mini(Index(127),rows-1));
|
||||||
|
x = v1(static_cast<char>(r1));
|
||||||
|
x = v1(static_cast<signed char>(r1));
|
||||||
|
x = v1(static_cast<unsigned char>(r1));
|
||||||
|
x = v1(static_cast<signed short>(r1));
|
||||||
|
x = v1(static_cast<unsigned short>(r1));
|
||||||
|
x = v1(static_cast<signed int>(r1));
|
||||||
|
x = v1(static_cast<unsigned int>(r1));
|
||||||
|
x = v1(static_cast<signed long>(r1));
|
||||||
|
x = v1(static_cast<unsigned long>(r1));
|
||||||
|
#if EIGEN_HAS_CXX11
|
||||||
|
x = v1(static_cast<long long int>(r1));
|
||||||
|
x = v1(static_cast<unsigned long long int>(r1));
|
||||||
|
#endif
|
||||||
|
|
||||||
VERIFY_IS_APPROX( v1, v1);
|
VERIFY_IS_APPROX( v1, v1);
|
||||||
VERIFY_IS_NOT_APPROX( v1, 2*v1);
|
VERIFY_IS_NOT_APPROX( v1, 2*v1);
|
||||||
VERIFY_IS_MUCH_SMALLER_THAN( vzero, v1);
|
VERIFY_IS_MUCH_SMALLER_THAN( vzero, v1);
|
||||||
|
@ -79,7 +79,6 @@ is_same_seq_type(const T1& a, const T2& b)
|
|||||||
|
|
||||||
void check_indexed_view()
|
void check_indexed_view()
|
||||||
{
|
{
|
||||||
#if EIGEN_HAS_INDEXED_VIEW
|
|
||||||
using Eigen::placeholders::all;
|
using Eigen::placeholders::all;
|
||||||
using Eigen::placeholders::last;
|
using Eigen::placeholders::last;
|
||||||
using Eigen::placeholders::end;
|
using Eigen::placeholders::end;
|
||||||
@ -298,6 +297,7 @@ void check_indexed_view()
|
|||||||
|
|
||||||
VERIFY_IS_APPROX( (A(std::array<int,3>{{1,3,5}}, std::array<int,4>{{9,6,3,0}})), A(seqN(1,3,2), seqN(9,4,-3)) );
|
VERIFY_IS_APPROX( (A(std::array<int,3>{{1,3,5}}, std::array<int,4>{{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<int,4>{{3, 1, 6, 5}}, all) );
|
VERIFY_IS_APPROX( A({3, 1, 6, 5}, all), A(std::array<int,4>{{3, 1, 6, 5}}, all) );
|
||||||
VERIFY_IS_APPROX( A(all,{3, 1, 6, 5}), A(all,std::array<int,4>{{3, 1, 6, 5}}) );
|
VERIFY_IS_APPROX( A(all,{3, 1, 6, 5}), A(all,std::array<int,4>{{3, 1, 6, 5}}) );
|
||||||
VERIFY_IS_APPROX( A({1,3,5},{3, 1, 6, 5}), A(std::array<int,3>{{1,3,5}},std::array<int,4>{{3, 1, 6, 5}}) );
|
VERIFY_IS_APPROX( A({1,3,5},{3, 1, 6, 5}), A(std::array<int,3>{{1,3,5}},std::array<int,4>{{3, 1, 6, 5}}) );
|
||||||
@ -310,6 +310,7 @@ void check_indexed_view()
|
|||||||
|
|
||||||
VERIFY_IS_APPROX( b({3, 1, 6, 5}), b(std::array<int,4>{{3, 1, 6, 5}}) );
|
VERIFY_IS_APPROX( b({3, 1, 6, 5}), b(std::array<int,4>{{3, 1, 6, 5}}) );
|
||||||
VERIFY_IS_EQUAL( b({1,3,5}).SizeAtCompileTime, 3 );
|
VERIFY_IS_EQUAL( b({1,3,5}).SizeAtCompileTime, 3 );
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -365,7 +366,6 @@ void check_indexed_view()
|
|||||||
VERIFY( is_same_eq( cA.middleRows<3>(1), cA.middleRows(1,fix<3>)) );
|
VERIFY( is_same_eq( cA.middleRows<3>(1), cA.middleRows(1,fix<3>)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // EIGEN_HAS_INDEXED_VIEW
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_indexed_view()
|
void test_indexed_view()
|
||||||
|
@ -12,7 +12,9 @@
|
|||||||
#include <Eigen/SparseCore>
|
#include <Eigen/SparseCore>
|
||||||
#include <Eigen/SparseLU>
|
#include <Eigen/SparseLU>
|
||||||
#include <Eigen/SparseQR>
|
#include <Eigen/SparseQR>
|
||||||
|
#include <Eigen/Sparse>
|
||||||
#include <Eigen/IterativeLinearSolvers>
|
#include <Eigen/IterativeLinearSolvers>
|
||||||
|
#include <Eigen/Eigen>
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user