mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
Some further cleanup
This commit is contained in:
parent
14c32c60f3
commit
cc11e240ac
@ -98,9 +98,7 @@
|
||||
#include <array>
|
||||
|
||||
// for std::is_nothrow_move_assignable
|
||||
#ifdef EIGEN_INCLUDE_TYPE_TRAITS
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
// for outputting debug info
|
||||
#ifdef EIGEN_DEBUG_ASSIGN
|
||||
|
@ -16,59 +16,6 @@ namespace Eigen {
|
||||
|
||||
namespace internal {
|
||||
|
||||
#if !((!EIGEN_COMP_GNUC) || EIGEN_COMP_GNUC>=48)
|
||||
template<typename T> struct aseq_negate {};
|
||||
|
||||
template<> struct aseq_negate<Index> {
|
||||
typedef Index type;
|
||||
};
|
||||
|
||||
template<int N> struct aseq_negate<FixedInt<N> > {
|
||||
typedef FixedInt<-N> type;
|
||||
};
|
||||
|
||||
// Compilation error in the following case:
|
||||
template<> struct aseq_negate<FixedInt<DynamicIndex> > {};
|
||||
|
||||
template<typename FirstType,typename SizeType,typename IncrType,
|
||||
bool FirstIsSymbolic=symbolic::is_symbolic<FirstType>::value,
|
||||
bool SizeIsSymbolic =symbolic::is_symbolic<SizeType>::value>
|
||||
struct aseq_reverse_first_type {
|
||||
typedef Index type;
|
||||
};
|
||||
|
||||
template<typename FirstType,typename SizeType,typename IncrType>
|
||||
struct aseq_reverse_first_type<FirstType,SizeType,IncrType,true,true> {
|
||||
typedef symbolic::AddExpr<FirstType,
|
||||
symbolic::ProductExpr<symbolic::AddExpr<SizeType,symbolic::ValueExpr<FixedInt<-1> > >,
|
||||
symbolic::ValueExpr<IncrType> >
|
||||
> type;
|
||||
};
|
||||
|
||||
template<typename SizeType,typename IncrType,typename EnableIf = void>
|
||||
struct aseq_reverse_first_type_aux {
|
||||
typedef Index type;
|
||||
};
|
||||
|
||||
template<typename SizeType,typename IncrType>
|
||||
struct aseq_reverse_first_type_aux<SizeType,IncrType,typename internal::enable_if<bool((SizeType::value+IncrType::value)|0x1)>::type> {
|
||||
typedef FixedInt<(SizeType::value-1)*IncrType::value> type;
|
||||
};
|
||||
|
||||
template<typename FirstType,typename SizeType,typename IncrType>
|
||||
struct aseq_reverse_first_type<FirstType,SizeType,IncrType,true,false> {
|
||||
typedef typename aseq_reverse_first_type_aux<SizeType,IncrType>::type Aux;
|
||||
typedef symbolic::AddExpr<FirstType,symbolic::ValueExpr<Aux> > type;
|
||||
};
|
||||
|
||||
template<typename FirstType,typename SizeType,typename IncrType>
|
||||
struct aseq_reverse_first_type<FirstType,SizeType,IncrType,false,true> {
|
||||
typedef symbolic::AddExpr<symbolic::ProductExpr<symbolic::AddExpr<SizeType,symbolic::ValueExpr<FixedInt<-1> > >,
|
||||
symbolic::ValueExpr<IncrType> >,
|
||||
symbolic::ValueExpr<> > type;
|
||||
};
|
||||
#endif
|
||||
|
||||
// Helper to cleanup the type of the increment:
|
||||
template<typename T> struct cleanup_seq_incr {
|
||||
typedef typename cleanup_index_type<T,DynamicIndex>::type type;
|
||||
@ -139,21 +86,9 @@ protected:
|
||||
IncrType m_incr;
|
||||
|
||||
public:
|
||||
|
||||
#if (!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);
|
||||
}
|
||||
#else
|
||||
protected:
|
||||
typedef typename internal::aseq_negate<IncrType>::type ReverseIncrType;
|
||||
typedef typename internal::aseq_reverse_first_type<FirstType,SizeType,IncrType>::type ReverseFirstType;
|
||||
public:
|
||||
ArithmeticSequence<ReverseFirstType,SizeType,ReverseIncrType>
|
||||
reverse() const {
|
||||
return seqN(m_first+(m_size+fix<-1>())*m_incr,m_size,-m_incr);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
/** \returns an ArithmeticSequence starting at \a first, of length \a size, and increment \a incr
|
||||
|
@ -85,12 +85,10 @@ namespace numext {
|
||||
// TODO: Replace by std::bit_cast (available in C++20)
|
||||
template <typename Tgt, typename Src>
|
||||
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Tgt bit_cast(const Src& src) {
|
||||
#if EIGEN_HAS_TYPE_TRAITS
|
||||
// The behaviour of memcpy is not specified for non-trivially copyable types
|
||||
EIGEN_STATIC_ASSERT(std::is_trivially_copyable<Src>::value, THIS_TYPE_IS_NOT_SUPPORTED);
|
||||
EIGEN_STATIC_ASSERT(std::is_trivially_copyable<Tgt>::value && std::is_default_constructible<Tgt>::value,
|
||||
THIS_TYPE_IS_NOT_SUPPORTED);
|
||||
#endif
|
||||
EIGEN_STATIC_ASSERT(sizeof(Src) == sizeof(Tgt), THIS_TYPE_IS_NOT_SUPPORTED);
|
||||
|
||||
Tgt tgt;
|
||||
|
@ -983,11 +983,7 @@ namespace internal {
|
||||
template <typename Derived, typename OtherDerived, bool IsVector>
|
||||
struct conservative_resize_like_impl
|
||||
{
|
||||
#if EIGEN_HAS_TYPE_TRAITS
|
||||
static const bool IsRelocatable = std::is_trivially_copyable<typename Derived::Scalar>::value;
|
||||
#else
|
||||
static const bool IsRelocatable = !NumTraits<typename Derived::Scalar>::RequireInitialization;
|
||||
#endif
|
||||
static void run(DenseBase<Derived>& _this, Index rows, Index cols)
|
||||
{
|
||||
if (_this.rows() == rows && _this.cols() == cols) return;
|
||||
|
@ -450,15 +450,6 @@ struct packet_traits<uint64_t> : default_packet_traits
|
||||
};
|
||||
};
|
||||
|
||||
#if EIGEN_GNUC_AT_MOST(4, 4) && !EIGEN_COMP_LLVM
|
||||
// workaround gcc 4.2, 4.3 and 4.4 compilation issue
|
||||
EIGEN_STRONG_INLINE float32x4_t vld1q_f32(const float* x) { return ::vld1q_f32((const float32_t*)x); }
|
||||
EIGEN_STRONG_INLINE float32x2_t vld1_f32(const float* x) { return ::vld1_f32 ((const float32_t*)x); }
|
||||
EIGEN_STRONG_INLINE float32x2_t vld1_dup_f32(const float* x) { return ::vld1_dup_f32 ((const float32_t*)x); }
|
||||
EIGEN_STRONG_INLINE void vst1q_f32(float* to, float32x4_t from) { ::vst1q_f32((float32_t*)to,from); }
|
||||
EIGEN_STRONG_INLINE void vst1_f32 (float* to, float32x2_t from) { ::vst1_f32 ((float32_t*)to,from); }
|
||||
#endif
|
||||
|
||||
template<> struct unpacket_traits<Packet2f>
|
||||
{
|
||||
typedef float type;
|
||||
|
@ -137,17 +137,9 @@ template<> EIGEN_STRONG_INLINE void prefetch<std::complex<float> >(const std::co
|
||||
|
||||
template<> EIGEN_STRONG_INLINE std::complex<float> pfirst<Packet2cf>(const Packet2cf& a)
|
||||
{
|
||||
#if EIGEN_GNUC_AT_MOST(4,3)
|
||||
// Workaround gcc 4.2 ICE - this is not performance wise ideal, but who cares...
|
||||
// This workaround also fix invalid code generation with gcc 4.3
|
||||
EIGEN_ALIGN16 std::complex<float> res[2];
|
||||
_mm_store_ps((float*)res, a.v);
|
||||
return res[0];
|
||||
#else
|
||||
std::complex<float> res;
|
||||
_mm_storel_pi((__m64*)&res, a.v);
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
|
||||
template<> EIGEN_STRONG_INLINE Packet2cf preverse(const Packet2cf& a) { return Packet2cf(_mm_castpd_ps(preverse(Packet2d(_mm_castps_pd(a.v))))); }
|
||||
|
@ -91,11 +91,6 @@
|
||||
// try to keep heap alignment even when we have to disable static alignment.
|
||||
#if EIGEN_COMP_GNUC && !(EIGEN_ARCH_i386_OR_x86_64 || EIGEN_ARCH_ARM_OR_ARM64 || EIGEN_ARCH_PPC || EIGEN_ARCH_IA64 || EIGEN_ARCH_MIPS)
|
||||
#define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 1
|
||||
#elif EIGEN_ARCH_ARM_OR_ARM64 && EIGEN_COMP_GNUC_STRICT && EIGEN_GNUC_AT_MOST(4, 6)
|
||||
// Old versions of GCC on ARM, at least 4.4, were once seen to have buggy static alignment support.
|
||||
// Not sure which version fixed it, hopefully it doesn't affect 4.7, which is still somewhat in use.
|
||||
// 4.8 and newer seem definitely unaffected.
|
||||
#define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 1
|
||||
#else
|
||||
#define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 0
|
||||
#endif
|
||||
|
@ -53,20 +53,9 @@ template<typename Derived, int Level> class DenseCoeffsBase;
|
||||
|
||||
template<typename Scalar_, int Rows_, int Cols_,
|
||||
int Options_ = AutoAlign |
|
||||
#if EIGEN_GNUC_AT(3,4)
|
||||
// workaround a bug in at least gcc 3.4.6
|
||||
// the innermost ?: ternary operator is misparsed. We write it slightly
|
||||
// differently and this makes gcc 3.4.6 happy, but it's ugly.
|
||||
// The error would only show up with EIGEN_DEFAULT_TO_ROW_MAJOR is defined
|
||||
// (when EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION is RowMajor)
|
||||
( (Rows_==1 && Cols_!=1) ? Eigen::RowMajor
|
||||
: !(Cols_==1 && Rows_!=1) ? EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION
|
||||
: Eigen::ColMajor ),
|
||||
#else
|
||||
( (Rows_==1 && Cols_!=1) ? Eigen::RowMajor
|
||||
: (Cols_==1 && Rows_!=1) ? Eigen::ColMajor
|
||||
: EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION ),
|
||||
#endif
|
||||
int MaxRows_ = Rows_,
|
||||
int MaxCols_ = Cols_
|
||||
> class Matrix;
|
||||
@ -246,20 +235,9 @@ struct IOFormat;
|
||||
// Array module
|
||||
template<typename Scalar_, int Rows_, int Cols_,
|
||||
int Options_ = AutoAlign |
|
||||
#if EIGEN_GNUC_AT(3,4)
|
||||
// workaround a bug in at least gcc 3.4.6
|
||||
// the innermost ?: ternary operator is misparsed. We write it slightly
|
||||
// differently and this makes gcc 3.4.6 happy, but it's ugly.
|
||||
// The error would only show up with EIGEN_DEFAULT_TO_ROW_MAJOR is defined
|
||||
// (when EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION is RowMajor)
|
||||
( (Rows_==1 && Cols_!=1) ? Eigen::RowMajor
|
||||
: !(Cols_==1 && Rows_!=1) ? EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION
|
||||
: Eigen::ColMajor ),
|
||||
#else
|
||||
( (Rows_==1 && Cols_!=1) ? Eigen::RowMajor
|
||||
: (Cols_==1 && Rows_!=1) ? Eigen::ColMajor
|
||||
: EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION ),
|
||||
#endif
|
||||
int MaxRows_ = Rows_, int MaxCols_ = Cols_> class Array;
|
||||
template<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType> class Select;
|
||||
template<typename MatrixType, typename BinaryOp, int Direction> class PartialReduxExpr;
|
||||
|
@ -79,14 +79,10 @@ public:
|
||||
template<int M>
|
||||
FixedInt<N&M> operator&( FixedInt<M>) const { return FixedInt<N&M>(); }
|
||||
|
||||
#if EIGEN_HAS_CXX14_VARIABLE_TEMPLATES
|
||||
// Needed in C++14 to allow fix<N>():
|
||||
FixedInt operator() () const { return *this; }
|
||||
|
||||
VariableAndFixedInt<N> operator() (int val) const { return VariableAndFixedInt<N>(val); }
|
||||
#else
|
||||
FixedInt ( FixedInt<N> (*)() ) {}
|
||||
#endif
|
||||
|
||||
FixedInt(std::integral_constant<int,N>) {}
|
||||
};
|
||||
@ -138,12 +134,6 @@ template<int N,int Default> struct get_fixed_value<FixedInt<N>,Default> {
|
||||
static const int value = N;
|
||||
};
|
||||
|
||||
#if !EIGEN_HAS_CXX14_VARIABLE_TEMPLATES
|
||||
template<int N,int Default> struct get_fixed_value<FixedInt<N> (*)(),Default> {
|
||||
static const int value = N;
|
||||
};
|
||||
#endif
|
||||
|
||||
template<int N,int Default> struct get_fixed_value<VariableAndFixedInt<N>,Default> {
|
||||
static const int value = N ;
|
||||
};
|
||||
@ -154,9 +144,6 @@ struct get_fixed_value<variable_if_dynamic<T,N>,Default> {
|
||||
};
|
||||
|
||||
template<typename T> EIGEN_DEVICE_FUNC Index get_runtime_value(const T &x) { return x; }
|
||||
#if !EIGEN_HAS_CXX14_VARIABLE_TEMPLATES
|
||||
template<int N> EIGEN_DEVICE_FUNC Index get_runtime_value(FixedInt<N> (*)()) { return N; }
|
||||
#endif
|
||||
|
||||
// Cleanup integer/FixedInt/VariableAndFixedInt/etc types:
|
||||
|
||||
@ -166,11 +153,6 @@ template<typename T, int DynamicKey=Dynamic, typename EnableIf=void> struct clea
|
||||
// Convert any integral type (e.g., short, int, unsigned int, etc.) to Eigen::Index
|
||||
template<typename T, int DynamicKey> struct cleanup_index_type<T,DynamicKey,typename internal::enable_if<internal::is_integral<T>::value>::type> { typedef Index type; };
|
||||
|
||||
#if !EIGEN_HAS_CXX14_VARIABLE_TEMPLATES
|
||||
// In c++98/c++11, fix<N> is a pointer to function that we better cleanup to a true FixedInt<N>:
|
||||
template<int N, int DynamicKey> struct cleanup_index_type<FixedInt<N> (*)(), DynamicKey> { typedef FixedInt<N> type; };
|
||||
#endif
|
||||
|
||||
// If VariableAndFixedInt does not match DynamicKey, then we turn it to a pure compile-time value:
|
||||
template<int N, int DynamicKey> struct cleanup_index_type<VariableAndFixedInt<N>, DynamicKey> { typedef FixedInt<N> type; };
|
||||
// If VariableAndFixedInt matches DynamicKey, then we turn it to a pure runtime-value (aka Index):
|
||||
@ -182,18 +164,8 @@ template<int N, int DynamicKey> struct cleanup_index_type<std::integral_constant
|
||||
|
||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||
|
||||
#if EIGEN_HAS_CXX14_VARIABLE_TEMPLATES
|
||||
template<int N>
|
||||
static const internal::FixedInt<N> fix{};
|
||||
#else
|
||||
template<int N>
|
||||
inline internal::FixedInt<N> fix() { return internal::FixedInt<N>(); }
|
||||
|
||||
// The generic typename T is mandatory. Otherwise, a code like fix<N> could refer to either the function above or this next overload.
|
||||
// This way a code like fix<N> can only refer to the previous function.
|
||||
template<int N,typename T>
|
||||
inline internal::VariableAndFixedInt<N> fix(T val) { return internal::VariableAndFixedInt<N>(internal::convert_index<int>(val)); }
|
||||
#endif
|
||||
|
||||
#else // EIGEN_PARSED_BY_DOXYGEN
|
||||
|
||||
|
@ -612,14 +612,6 @@
|
||||
#define EIGEN_COMP_CXXVER 03
|
||||
#endif
|
||||
|
||||
#ifndef EIGEN_HAS_CXX14_VARIABLE_TEMPLATES
|
||||
#if defined(__cpp_variable_templates) && __cpp_variable_templates >= 201304
|
||||
#define EIGEN_HAS_CXX14_VARIABLE_TEMPLATES 1
|
||||
#else
|
||||
#define EIGEN_HAS_CXX14_VARIABLE_TEMPLATES 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// The macros EIGEN_HAS_CXX?? defines a rough estimate of available c++ features
|
||||
// but in practice we should not rely on them but rather on the availability of
|
||||
@ -675,18 +667,6 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Does the compiler support type_traits?
|
||||
// - full support of type traits was added only to GCC 5.1.0.
|
||||
// - 20150626 corresponds to the last release of 4.x libstdc++
|
||||
#ifndef EIGEN_HAS_TYPE_TRAITS
|
||||
#if (!defined(__GLIBCXX__)) || __GLIBCXX__ > 20150626
|
||||
#define EIGEN_HAS_TYPE_TRAITS 1
|
||||
#define EIGEN_INCLUDE_TYPE_TRAITS
|
||||
#else
|
||||
#define EIGEN_HAS_TYPE_TRAITS 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Does the compiler fully support const expressions? (as in c++14)
|
||||
#ifndef EIGEN_HAS_CONSTEXPR
|
||||
#if defined(EIGEN_CUDACC)
|
||||
@ -982,14 +962,8 @@ namespace Eigen {
|
||||
// General, NEON.
|
||||
// Clang doesn't like "r",
|
||||
// error: non-trivial scalar-to-vector conversion, possible invalid
|
||||
// constraint for vector type
|
||||
// GCC < 5 doesn't like "g",
|
||||
// error: 'asm' operand requires impossible reload
|
||||
#if EIGEN_COMP_GNUC_STRICT && EIGEN_GNUC_AT_MOST(5, 0)
|
||||
#define EIGEN_OPTIMIZATION_BARRIER(X) __asm__ ("" : "+r,w" (X));
|
||||
#else
|
||||
#define EIGEN_OPTIMIZATION_BARRIER(X) __asm__ ("" : "+g,w" (X));
|
||||
#endif
|
||||
// constraint for vector typ
|
||||
#define EIGEN_OPTIMIZATION_BARRIER(X) __asm__ ("" : "+g,w" (X));
|
||||
#elif EIGEN_ARCH_i386_OR_x86_64
|
||||
// General, SSE.
|
||||
#define EIGEN_OPTIMIZATION_BARRIER(X) __asm__ ("" : "+g,x" (X));
|
||||
@ -1249,7 +1223,6 @@ namespace Eigen {
|
||||
#endif
|
||||
|
||||
|
||||
#define EIGEN_INCLUDE_TYPE_TRAITS
|
||||
#define EIGEN_NOEXCEPT noexcept
|
||||
#define EIGEN_NOEXCEPT_IF(x) noexcept(x)
|
||||
#define EIGEN_NO_THROW noexcept(true)
|
||||
|
@ -14,7 +14,7 @@
|
||||
// just a workaround because GCC seems to not really like empty structs
|
||||
// FIXME: gcc 4.3 generates bad code when strict-aliasing is enabled
|
||||
// so currently we simply disable this optimization for gcc 4.3
|
||||
#if EIGEN_COMP_GNUC && !EIGEN_GNUC_AT(4,3)
|
||||
#if EIGEN_COMP_GNUC
|
||||
#define EIGEN_EMPTY_STRUCT_CTOR(X) \
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE X() {} \
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE X(const X& ) {}
|
||||
@ -39,15 +39,7 @@ inline IndexDest convert_index(const IndexSrc& idx) {
|
||||
// true if T can be considered as an integral index (i.e., and integral type or enum)
|
||||
template<typename T> struct is_valid_index_type
|
||||
{
|
||||
enum { value =
|
||||
#if EIGEN_HAS_TYPE_TRAITS
|
||||
internal::is_integral<T>::value || std::is_enum<T>::value
|
||||
#elif EIGEN_COMP_MSVC
|
||||
internal::is_integral<T>::value || __is_enum(T)
|
||||
#else
|
||||
// without C++11, we use is_convertible to Index instead of is_integral in order to treat enums as Index.
|
||||
internal::is_convertible<T,Index>::value && !internal::is_same<T,float>::value && !is_same<T,double>::value
|
||||
#endif
|
||||
enum { value = internal::is_integral<T>::value || std::is_enum<T>::value
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
#include <Eigen/Core>
|
||||
|
||||
#if EIGEN_HAS_TYPE_TRAITS
|
||||
using DenseStorageD3x3 = Eigen::DenseStorage<double, 3, 3, 3, 3>;
|
||||
static_assert(std::is_trivially_move_constructible<DenseStorageD3x3>::value, "DenseStorage not trivially_move_constructible");
|
||||
static_assert(std::is_trivially_move_assignable<DenseStorageD3x3>::value, "DenseStorage not trivially_move_assignable");
|
||||
@ -22,7 +21,6 @@ static_assert(std::is_trivially_copy_constructible<DenseStorageD3x3>::value, "De
|
||||
static_assert(std::is_trivially_copy_assignable<DenseStorageD3x3>::value, "DenseStorage not trivially_copy_assignable");
|
||||
static_assert(std::is_trivially_copyable<DenseStorageD3x3>::value, "DenseStorage not trivially_copyable");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
template <typename T, int Size, int Rows, int Cols>
|
||||
void dense_storage_copy(int rows, int cols)
|
||||
|
@ -60,7 +60,6 @@ void check_symbolic_index()
|
||||
VERIFY_IS_EQUAL( ( lastp1-3*last ).eval(last=size-1), size- 3*(size-1) );
|
||||
VERIFY_IS_EQUAL( ( (lastp1-3*last)/lastp1 ).eval(last=size-1), (size- 3*(size-1))/size );
|
||||
|
||||
#if EIGEN_HAS_CXX14_VARIABLE_TEMPLATES
|
||||
{
|
||||
struct x_tag {}; static const symbolic::SymbolExpr<x_tag> x;
|
||||
struct y_tag {}; static const symbolic::SymbolExpr<y_tag> y;
|
||||
@ -68,7 +67,6 @@ void check_symbolic_index()
|
||||
|
||||
VERIFY_IS_APPROX( int(((x+3)/y+z).eval(x=6,y=3,z=-13)), (6+3)/3+(-13) );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
EIGEN_DECLARE_TEST(symbolic_index)
|
||||
|
@ -89,14 +89,12 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_, IndexTyp
|
||||
protected:
|
||||
TensorStorage<Scalar, Dimensions, Options> m_storage;
|
||||
|
||||
#ifdef EIGEN_HAS_SFINAE
|
||||
template<typename CustomIndices>
|
||||
struct isOfNormalIndex{
|
||||
static const bool is_array = internal::is_base_of<array<Index, NumIndices>, CustomIndices>::value;
|
||||
static const bool is_int = NumTraits<CustomIndices>::IsInteger;
|
||||
static const bool value = is_array | is_int;
|
||||
};
|
||||
#endif
|
||||
|
||||
public:
|
||||
// Metadata
|
||||
@ -129,7 +127,6 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_, IndexTyp
|
||||
}
|
||||
|
||||
// custom indices
|
||||
#ifdef EIGEN_HAS_SFINAE
|
||||
template<typename CustomIndices,
|
||||
EIGEN_SFINAE_ENABLE_IF( !(isOfNormalIndex<CustomIndices>::value) )
|
||||
>
|
||||
@ -137,7 +134,6 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_, IndexTyp
|
||||
{
|
||||
return coeff(internal::customIndices2Array<Index,NumIndices>(indices));
|
||||
}
|
||||
#endif
|
||||
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar& coeff() const
|
||||
{
|
||||
@ -167,7 +163,6 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_, IndexTyp
|
||||
}
|
||||
|
||||
// custom indices
|
||||
#ifdef EIGEN_HAS_SFINAE
|
||||
template<typename CustomIndices,
|
||||
EIGEN_SFINAE_ENABLE_IF( !(isOfNormalIndex<CustomIndices>::value) )
|
||||
>
|
||||
@ -175,7 +170,6 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_, IndexTyp
|
||||
{
|
||||
return coeffRef(internal::customIndices2Array<Index,NumIndices>(indices));
|
||||
}
|
||||
#endif
|
||||
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef()
|
||||
{
|
||||
@ -198,7 +192,6 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_, IndexTyp
|
||||
}
|
||||
|
||||
// custom indices
|
||||
#ifdef EIGEN_HAS_SFINAE
|
||||
template<typename CustomIndices,
|
||||
EIGEN_SFINAE_ENABLE_IF( !(isOfNormalIndex<CustomIndices>::value) )
|
||||
>
|
||||
@ -206,7 +199,6 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_, IndexTyp
|
||||
{
|
||||
return coeff(internal::customIndices2Array<Index,NumIndices>(indices));
|
||||
}
|
||||
#endif
|
||||
|
||||
// normal indices
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar& operator()(const array<Index, NumIndices>& indices) const
|
||||
@ -248,7 +240,6 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_, IndexTyp
|
||||
}
|
||||
|
||||
// custom indices
|
||||
#ifdef EIGEN_HAS_SFINAE
|
||||
template<typename CustomIndices,
|
||||
EIGEN_SFINAE_ENABLE_IF( !(isOfNormalIndex<CustomIndices>::value) )
|
||||
>
|
||||
@ -256,7 +247,6 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_, IndexTyp
|
||||
{
|
||||
return coeffRef(internal::customIndices2Array<Index,NumIndices>(indices));
|
||||
}
|
||||
#endif
|
||||
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& operator()(Index index)
|
||||
{
|
||||
@ -411,7 +401,6 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_, IndexTyp
|
||||
#endif
|
||||
|
||||
/** Custom Dimension */
|
||||
#ifdef EIGEN_HAS_SFINAE
|
||||
template<typename CustomDimension,
|
||||
EIGEN_SFINAE_ENABLE_IF( !(isOfNormalIndex<CustomDimension>::value) )
|
||||
>
|
||||
@ -419,7 +408,6 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_, IndexTyp
|
||||
{
|
||||
resize(internal::customIndices2Array<Index,NumIndices>(dimensions));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef EIGEN_EMULATE_CXX11_META_H
|
||||
template <typename std::ptrdiff_t... Indices>
|
||||
|
@ -26,15 +26,6 @@
|
||||
* void foo(){}
|
||||
*/
|
||||
|
||||
// SFINAE requires variadic templates
|
||||
#if !defined(EIGEN_GPUCC)
|
||||
#ifdef EIGEN_COMP_GNUC
|
||||
#define EIGEN_HAS_SFINAE
|
||||
#else
|
||||
#define EIGEN_HAS_SFINAE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define EIGEN_SFINAE_ENABLE_IF( __condition__ ) \
|
||||
typename internal::enable_if< ( __condition__ ) , int >::type = 0
|
||||
|
||||
|
@ -264,7 +264,6 @@ template <typename Idx> struct IndexPair {
|
||||
};
|
||||
|
||||
|
||||
#ifdef EIGEN_HAS_SFINAE
|
||||
namespace internal {
|
||||
|
||||
template<typename IndexType, typename Index, Index... Is>
|
||||
@ -308,9 +307,6 @@ namespace internal {
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
} // namespace Eigen
|
||||
|
||||
|
@ -11,10 +11,6 @@
|
||||
#define EIGEN_CXX11_THREADPOOL_THREAD_YIELD_H
|
||||
|
||||
// Try to come up with a portable way to yield
|
||||
#if EIGEN_COMP_GNUC && EIGEN_GNUC_AT_MOST(4, 7)
|
||||
#define EIGEN_THREAD_YIELD() sched_yield()
|
||||
#else
|
||||
#define EIGEN_THREAD_YIELD() std::this_thread::yield()
|
||||
#endif
|
||||
|
||||
#endif // EIGEN_CXX11_THREADPOOL_THREAD_YIELD_H
|
||||
|
@ -20,7 +20,6 @@ using Eigen::Tensor;
|
||||
template <int DataLayout>
|
||||
static void test_map_as_index()
|
||||
{
|
||||
#ifdef EIGEN_HAS_SFINAE
|
||||
Tensor<float, 4, DataLayout> tensor(2, 3, 5, 7);
|
||||
tensor.setRandom();
|
||||
|
||||
@ -35,14 +34,12 @@ static void test_map_as_index()
|
||||
|
||||
VERIFY_IS_EQUAL(tensor.coeff(coeffC), tensor.coeff(coeff));
|
||||
VERIFY_IS_EQUAL(tensor.coeffRef(coeffC), tensor.coeffRef(coeff));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
template <int DataLayout>
|
||||
static void test_matrix_as_index()
|
||||
{
|
||||
#ifdef EIGEN_HAS_SFINAE
|
||||
Tensor<float, 4, DataLayout> tensor(2, 3, 5, 7);
|
||||
tensor.setRandom();
|
||||
|
||||
@ -53,14 +50,12 @@ static void test_matrix_as_index()
|
||||
|
||||
VERIFY_IS_EQUAL(tensor.coeff(coeffC), tensor.coeff(coeff));
|
||||
VERIFY_IS_EQUAL(tensor.coeffRef(coeffC), tensor.coeffRef(coeff));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
template <int DataLayout>
|
||||
static void test_varlist_as_index()
|
||||
{
|
||||
#ifdef EIGEN_HAS_SFINAE
|
||||
Tensor<float, 4, DataLayout> tensor(2, 3, 5, 7);
|
||||
tensor.setRandom();
|
||||
|
||||
@ -68,14 +63,12 @@ static void test_varlist_as_index()
|
||||
|
||||
VERIFY_IS_EQUAL(tensor.coeff({1,2,4,1}), tensor.coeff(coeff));
|
||||
VERIFY_IS_EQUAL(tensor.coeffRef({1,2,4,1}), tensor.coeffRef(coeff));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
template <int DataLayout>
|
||||
static void test_sizes_as_index()
|
||||
{
|
||||
#ifdef EIGEN_HAS_SFINAE
|
||||
Tensor<float, 4, DataLayout> tensor(2, 3, 5, 7);
|
||||
tensor.setRandom();
|
||||
|
||||
@ -84,7 +77,6 @@ static void test_sizes_as_index()
|
||||
|
||||
VERIFY_IS_EQUAL(tensor.coeff(coeffC), tensor.coeff(coeff));
|
||||
VERIFY_IS_EQUAL(tensor.coeffRef(coeffC), tensor.coeffRef(coeff));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user