diff --git a/Eigen/CholmodSupport b/Eigen/CholmodSupport
index bed8924..1037bd5 100644
--- a/Eigen/CholmodSupport
+++ b/Eigen/CholmodSupport
@@ -22,7 +22,7 @@ extern "C" {
* This module provides an interface to the Cholmod library which is part of the suitesparse package.
* It provides the two following main factorization classes:
* - class CholmodSupernodalLLT: a supernodal LLT Cholesky factorization.
- * - class CholmodDecomposiiton: a general L(D)LT Cholesky factorization with automatic or explicit runtime selection of the underlying factorization method (supernodal or simplicial).
+ * - class CholmodDecomposition: a general L(D)LT Cholesky factorization with automatic or explicit runtime selection of the underlying factorization method (supernodal or simplicial).
*
* For the sake of completeness, this module also propose the two following classes:
* - class CholmodSimplicialLLT
diff --git a/Eigen/Core b/Eigen/Core
index 5921e15..bb16c86 100644
--- a/Eigen/Core
+++ b/Eigen/Core
@@ -83,8 +83,8 @@
#include
#include
#include
-#include
#ifndef EIGEN_NO_IO
+ #include
#include
#endif
#include
@@ -109,7 +109,8 @@
#endif
// required for __cpuid, needs to be included after cmath
-#if EIGEN_COMP_MSVC && EIGEN_ARCH_i386_OR_x86_64 && !EIGEN_OS_WINCE
+// also required for _BitScanReverse on Windows on ARM
+#if EIGEN_COMP_MSVC && (EIGEN_ARCH_i386_OR_x86_64 || EIGEN_ARCH_ARM64) && !EIGEN_OS_WINCE
#include
#endif
@@ -346,7 +347,7 @@ using std::ptrdiff_t;
#include "src/Core/CoreIterators.h"
#include "src/Core/ConditionEstimator.h"
-#if defined(EIGEN_VECTORIZE_ALTIVEC) || defined(EIGEN_VECTORIZE_VSX)
+#if defined(EIGEN_VECTORIZE_VSX)
#include "src/Core/arch/AltiVec/MatrixProduct.h"
#elif defined EIGEN_VECTORIZE_NEON
#include "src/Core/arch/NEON/GeneralBlockPanelKernel.h"
diff --git a/Eigen/SparseLU b/Eigen/SparseLU
index 37c4a5c..047cf0d 100644
--- a/Eigen/SparseLU
+++ b/Eigen/SparseLU
@@ -25,8 +25,6 @@
#include "src/Core/util/DisableStupidWarnings.h"
-#include "src/SparseLU/SparseLU_gemm_kernel.h"
-
#include "src/SparseLU/SparseLU_Structs.h"
#include "src/SparseLU/SparseLU_SupernodalMatrix.h"
#include "src/SparseLU/SparseLUImpl.h"
diff --git a/Eigen/src/Core/ArithmeticSequence.h b/Eigen/src/Core/ArithmeticSequence.h
index b6200fa..d04f726 100644
--- a/Eigen/src/Core/ArithmeticSequence.h
+++ b/Eigen/src/Core/ArithmeticSequence.h
@@ -172,7 +172,8 @@ seqN(FirstType first, SizeType size) {
return ArithmeticSequence::type,typename internal::cleanup_index_type::type>(first,size);
}
-#ifdef EIGEN_PARSED_BY_DOXYGEN
+
+#if EIGEN_HAS_CXX11
/** \returns an ArithmeticSequence starting at \a f, up (or down) to \a l, and with positive (or negative) increment \a incr
*
@@ -183,24 +184,6 @@ seqN(FirstType first, SizeType size) {
*
* \sa seqN(FirstType,SizeType,IncrType), seq(FirstType,LastType)
*/
-template
-auto seq(FirstType f, LastType l, IncrType incr);
-
-/** \returns an ArithmeticSequence starting at \a f, up (or down) to \a l, and unit increment
- *
- * It is essentially an alias to:
- * \code
- * seqN(f,l-f+1);
- * \endcode
- *
- * \sa seqN(FirstType,SizeType), seq(FirstType,LastType,IncrType)
- */
-template
-auto seq(FirstType f, LastType l);
-
-#else // EIGEN_PARSED_BY_DOXYGEN
-
-#if EIGEN_HAS_CXX11
template
auto seq(FirstType f, LastType l) -> decltype(seqN(typename internal::cleanup_index_type::type(f),
( typename internal::cleanup_index_type::type(l)
@@ -211,6 +194,15 @@ auto seq(FirstType f, LastType l) -> decltype(seqN(typename internal::cleanup_in
-typename internal::cleanup_index_type::type(f)+fix<1>()));
}
+/** \returns an ArithmeticSequence starting at \a f, up (or down) to \a l, and unit increment
+ *
+ * It is essentially an alias to:
+ * \code
+ * seqN(f,l-f+1);
+ * \endcode
+ *
+ * \sa seqN(FirstType,SizeType), seq(FirstType,LastType,IncrType)
+ */
template
auto seq(FirstType f, LastType l, IncrType incr)
-> decltype(seqN(typename internal::cleanup_index_type::type(f),
@@ -317,26 +309,12 @@ seq(const symbolic::BaseExpr &f, const symbolic::BaseExpr)*incr, size, incr) \endcode
- *
- * \sa lastN(SizeType), seqN(FirstType,SizeType), seq(FirstType,LastType,IncrType) */
-template
-auto lastN(SizeType size, IncrType incr)
--> decltype(seqN(Eigen::last-(size-fix<1>())*incr, size, incr))
-{
- return seqN(Eigen::last-(size-fix<1>())*incr, size, incr);
-}
-
+#if EIGEN_HAS_CXX11
/** \cpp11
* \returns a symbolic ArithmeticSequence representing the last \a size elements with a unit increment.
*
+ * \anchor indexing_lastN
+ *
* It is a shortcut for: \code seq(last+fix<1>-size, last) \endcode
*
* \sa lastN(SizeType,IncrType, seqN(FirstType,SizeType), seq(FirstType,LastType) */
@@ -346,6 +324,21 @@ auto lastN(SizeType size)
{
return seqN(Eigen::last+fix<1>()-size, size);
}
+
+/** \cpp11
+ * \returns a symbolic ArithmeticSequence representing the last \a size elements with increment \a incr.
+ *
+ * \anchor indexing_lastN_with_incr
+ *
+ * It is a shortcut for: \code seqN(last-(size-fix<1>)*incr, size, incr) \endcode
+ *
+ * \sa lastN(SizeType), seqN(FirstType,SizeType), seq(FirstType,LastType,IncrType) */
+template
+auto lastN(SizeType size, IncrType incr)
+-> decltype(seqN(Eigen::last-(size-fix<1>())*incr, size, incr))
+{
+ return seqN(Eigen::last-(size-fix<1>())*incr, size, incr);
+}
#endif
namespace internal {
diff --git a/Eigen/src/Core/Array.h b/Eigen/src/Core/Array.h
index 20c789b..6d50ea4 100644
--- a/Eigen/src/Core/Array.h
+++ b/Eigen/src/Core/Array.h
@@ -163,7 +163,15 @@ class Array
#endif
#if EIGEN_HAS_CXX11
- /** \copydoc PlainObjectBase(const Scalar& a0, const Scalar& a1, const Scalar& a2, const Scalar& a3, const ArgTypes&... args)
+ /** \brief Construct a row of column vector with fixed size from an arbitrary number of coefficients. \cpp11
+ *
+ * \only_for_vectors
+ *
+ * This constructor is for 1D array or vectors with more than 4 coefficients.
+ * There exists C++98 analogue constructors for fixed-size array/vector having 1, 2, 3, or 4 coefficients.
+ *
+ * \warning To construct a column (resp. row) vector of fixed length, the number of values passed to this
+ * constructor must match the the fixed number of rows (resp. columns) of \c *this.
*
* Example: \include Array_variadic_ctor_cxx11.cpp
* Output: \verbinclude Array_variadic_ctor_cxx11.out
diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h
index 3206d66..9d89b60 100644
--- a/Eigen/src/Core/Block.h
+++ b/Eigen/src/Core/Block.h
@@ -260,19 +260,19 @@ template
- inline PacketScalar packet(Index rowId, Index colId) const
+ EIGEN_DEVICE_FUNC inline PacketScalar packet(Index rowId, Index colId) const
{
return m_xpr.template packet(rowId + m_startRow.value(), colId + m_startCol.value());
}
template
- inline void writePacket(Index rowId, Index colId, const PacketScalar& val)
+ EIGEN_DEVICE_FUNC inline void writePacket(Index rowId, Index colId, const PacketScalar& val)
{
m_xpr.template writePacket(rowId + m_startRow.value(), colId + m_startCol.value(), val);
}
template
- inline PacketScalar packet(Index index) const
+ EIGEN_DEVICE_FUNC inline PacketScalar packet(Index index) const
{
return m_xpr.template packet
(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
@@ -280,7 +280,7 @@ template
- inline void writePacket(Index index, const PacketScalar& val)
+ EIGEN_DEVICE_FUNC inline void writePacket(Index index, const PacketScalar& val)
{
m_xpr.template writePacket
(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
@@ -334,6 +334,17 @@ class BlockImpl_dense
enum {
XprTypeIsRowMajor = (int(traits::Flags)&RowMajorBit) != 0
};
+
+ /** \internal Returns base+offset (unless base is null, in which case returns null).
+ * Adding an offset to nullptr is undefined behavior, so we must avoid it.
+ */
+ template
+ EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR EIGEN_ALWAYS_INLINE
+ static Scalar* add_to_nullable_pointer(Scalar* base, Index offset)
+ {
+ return base != NULL ? base+offset : NULL;
+ }
+
public:
typedef MapBase Base;
@@ -344,8 +355,9 @@ class BlockImpl_dense
*/
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
BlockImpl_dense(XprType& xpr, Index i)
- : Base(xpr.data() + i * ( ((BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) && (!XprTypeIsRowMajor))
- || ((BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) && ( XprTypeIsRowMajor)) ? xpr.innerStride() : xpr.outerStride()),
+ : Base((BlockRows == 0 || BlockCols == 0) ? NULL : add_to_nullable_pointer(xpr.data(),
+ i * ( ((BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) && (!XprTypeIsRowMajor))
+ || ((BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) && ( XprTypeIsRowMajor)) ? xpr.innerStride() : xpr.outerStride())),
BlockRows==1 ? 1 : xpr.rows(),
BlockCols==1 ? 1 : xpr.cols()),
m_xpr(xpr),
@@ -359,7 +371,8 @@ class BlockImpl_dense
*/
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
BlockImpl_dense(XprType& xpr, Index startRow, Index startCol)
- : Base(xpr.data()+xpr.innerStride()*(XprTypeIsRowMajor?startCol:startRow) + xpr.outerStride()*(XprTypeIsRowMajor?startRow:startCol)),
+ : Base((BlockRows == 0 || BlockCols == 0) ? NULL : add_to_nullable_pointer(xpr.data(),
+ xpr.innerStride()*(XprTypeIsRowMajor?startCol:startRow) + xpr.outerStride()*(XprTypeIsRowMajor?startRow:startCol))),
m_xpr(xpr), m_startRow(startRow), m_startCol(startCol)
{
init();
@@ -371,7 +384,9 @@ class BlockImpl_dense
BlockImpl_dense(XprType& xpr,
Index startRow, Index startCol,
Index blockRows, Index blockCols)
- : Base(xpr.data()+xpr.innerStride()*(XprTypeIsRowMajor?startCol:startRow) + xpr.outerStride()*(XprTypeIsRowMajor?startRow:startCol), blockRows, blockCols),
+ : Base((blockRows == 0 || blockCols == 0) ? NULL : add_to_nullable_pointer(xpr.data(),
+ xpr.innerStride()*(XprTypeIsRowMajor?startCol:startRow) + xpr.outerStride()*(XprTypeIsRowMajor?startRow:startCol)),
+ blockRows, blockCols),
m_xpr(xpr), m_startRow(startRow), m_startCol(startCol)
{
init();
diff --git a/Eigen/src/Core/BooleanRedux.h b/Eigen/src/Core/BooleanRedux.h
index 852de8b..fa4d7c3 100644
--- a/Eigen/src/Core/BooleanRedux.h
+++ b/Eigen/src/Core/BooleanRedux.h
@@ -14,54 +14,56 @@ namespace Eigen {
namespace internal {
-template
+template
struct all_unroller
{
enum {
- col = (UnrollCount-1) / Rows,
- row = (UnrollCount-1) % Rows
+ IsRowMajor = (int(Derived::Flags) & int(RowMajor)),
+ i = (UnrollCount-1) / InnerSize,
+ j = (UnrollCount-1) % InnerSize
};
EIGEN_DEVICE_FUNC static inline bool run(const Derived &mat)
{
- return all_unroller::run(mat) && mat.coeff(row, col);
+ return all_unroller::run(mat) && mat.coeff(IsRowMajor ? i : j, IsRowMajor ? j : i);
}
};
-template
-struct all_unroller
+template
+struct all_unroller
{
EIGEN_DEVICE_FUNC static inline bool run(const Derived &/*mat*/) { return true; }
};
-template
-struct all_unroller
+template
+struct all_unroller
{
EIGEN_DEVICE_FUNC static inline bool run(const Derived &) { return false; }
};
-template
+template
struct any_unroller
{
enum {
- col = (UnrollCount-1) / Rows,
- row = (UnrollCount-1) % Rows
+ IsRowMajor = (int(Derived::Flags) & int(RowMajor)),
+ i = (UnrollCount-1) / InnerSize,
+ j = (UnrollCount-1) % InnerSize
};
-
+
EIGEN_DEVICE_FUNC static inline bool run(const Derived &mat)
{
- return any_unroller::run(mat) || mat.coeff(row, col);
+ return any_unroller::run(mat) || mat.coeff(IsRowMajor ? i : j, IsRowMajor ? j : i);
}
};
-template
-struct any_unroller
+template
+struct any_unroller
{
EIGEN_DEVICE_FUNC static inline bool run(const Derived & /*mat*/) { return false; }
};
-template
-struct any_unroller
+template
+struct any_unroller
{
EIGEN_DEVICE_FUNC static inline bool run(const Derived &) { return false; }
};
@@ -85,12 +87,12 @@ EIGEN_DEVICE_FUNC inline bool DenseBase::all() const
};
Evaluator evaluator(derived());
if(unroll)
- return internal::all_unroller::RowsAtCompileTime>::run(evaluator);
+ return internal::all_unroller::run(evaluator);
else
{
- for(Index j = 0; j < cols(); ++j)
- for(Index i = 0; i < rows(); ++i)
- if (!evaluator.coeff(i, j)) return false;
+ for(Index i = 0; i < derived().outerSize(); ++i)
+ for(Index j = 0; j < derived().innerSize(); ++j)
+ if (!evaluator.coeff(IsRowMajor ? i : j, IsRowMajor ? j : i)) return false;
return true;
}
}
@@ -109,12 +111,12 @@ EIGEN_DEVICE_FUNC inline bool DenseBase::any() const
};
Evaluator evaluator(derived());
if(unroll)
- return internal::any_unroller::RowsAtCompileTime>::run(evaluator);
+ return internal::any_unroller::run(evaluator);
else
{
- for(Index j = 0; j < cols(); ++j)
- for(Index i = 0; i < rows(); ++i)
- if (evaluator.coeff(i, j)) return true;
+ for(Index i = 0; i < derived().outerSize(); ++i)
+ for(Index j = 0; j < derived().innerSize(); ++j)
+ if (evaluator.coeff(IsRowMajor ? i : j, IsRowMajor ? j : i)) return true;
return false;
}
}
@@ -156,7 +158,7 @@ inline bool DenseBase::allFinite() const
return !((derived()-derived()).hasNaN());
#endif
}
-
+
} // end namespace Eigen
#endif // EIGEN_ALLANDANY_H
diff --git a/Eigen/src/Core/CwiseNullaryOp.h b/Eigen/src/Core/CwiseNullaryOp.h
index 289ec51..ba07e71 100644
--- a/Eigen/src/Core/CwiseNullaryOp.h
+++ b/Eigen/src/Core/CwiseNullaryOp.h
@@ -292,7 +292,7 @@ DenseBase::LinSpaced(Index size, const Scalar& low, const Scalar& high)
}
/**
- * \copydoc DenseBase::LinSpaced(Index, const Scalar&, const Scalar&)
+ * \copydoc DenseBase::LinSpaced(Index, const DenseBase::Scalar&, const DenseBase::Scalar&)
* Special version for fixed size types which does not require the size parameter.
*/
template
diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h
index 9b16db6..cdd0f5f 100644
--- a/Eigen/src/Core/DenseBase.h
+++ b/Eigen/src/Core/DenseBase.h
@@ -324,9 +324,9 @@ template class DenseBase
typedef Transpose TransposeReturnType;
EIGEN_DEVICE_FUNC
TransposeReturnType transpose();
- typedef typename internal::add_const >::type ConstTransposeReturnType;
+ typedef Transpose ConstTransposeReturnType;
EIGEN_DEVICE_FUNC
- ConstTransposeReturnType transpose() const;
+ const ConstTransposeReturnType transpose() const;
EIGEN_DEVICE_FUNC
void transposeInPlace();
diff --git a/Eigen/src/Core/Diagonal.h b/Eigen/src/Core/Diagonal.h
index 3112d2c..ad5bccd 100644
--- a/Eigen/src/Core/Diagonal.h
+++ b/Eigen/src/Core/Diagonal.h
@@ -191,7 +191,8 @@ MatrixBase::diagonal()
/** This is the const version of diagonal(). */
template
-EIGEN_DEVICE_FUNC inline typename MatrixBase::ConstDiagonalReturnType
+EIGEN_DEVICE_FUNC inline
+const typename MatrixBase::ConstDiagonalReturnType
MatrixBase::diagonal() const
{
return ConstDiagonalReturnType(derived());
@@ -209,18 +210,18 @@ MatrixBase::diagonal() const
*
* \sa MatrixBase::diagonal(), class Diagonal */
template
-EIGEN_DEVICE_FUNC inline typename MatrixBase::DiagonalDynamicIndexReturnType
+EIGEN_DEVICE_FUNC inline Diagonal
MatrixBase::diagonal(Index index)
{
- return DiagonalDynamicIndexReturnType(derived(), index);
+ return Diagonal(derived(), index);
}
/** This is the const version of diagonal(Index). */
template
-EIGEN_DEVICE_FUNC inline typename MatrixBase::ConstDiagonalDynamicIndexReturnType
+EIGEN_DEVICE_FUNC inline const Diagonal
MatrixBase::diagonal(Index index) const
{
- return ConstDiagonalDynamicIndexReturnType(derived(), index);
+ return Diagonal(derived(), index);
}
/** \returns an expression of the \a DiagIndex-th sub or super diagonal of the matrix \c *this
@@ -237,20 +238,20 @@ MatrixBase::diagonal(Index index) const
template
template
EIGEN_DEVICE_FUNC
-inline typename MatrixBase::template DiagonalIndexReturnType::Type
+inline Diagonal
MatrixBase::diagonal()
{
- return typename DiagonalIndexReturnType::Type(derived());
+ return Diagonal(derived());
}
/** This is the const version of diagonal(). */
template
template
EIGEN_DEVICE_FUNC
-inline typename MatrixBase::template ConstDiagonalIndexReturnType::Type
+inline const Diagonal
MatrixBase::diagonal() const
{
- return typename ConstDiagonalIndexReturnType::Type(derived());
+ return Diagonal(derived());
}
} // end namespace Eigen
diff --git a/Eigen/src/Core/Dot.h b/Eigen/src/Core/Dot.h
index 5c3441b..abac7ad 100644
--- a/Eigen/src/Core/Dot.h
+++ b/Eigen/src/Core/Dot.h
@@ -18,14 +18,9 @@ namespace internal {
// with mismatched types, the compiler emits errors about failing to instantiate cwiseProduct BEFORE
// looking at the static assertions. Thus this is a trick to get better compile errors.
template
+ bool NeedToTranspose = T::IsVectorAtCompileTime && U::IsVectorAtCompileTime &&
+ ((int(T::RowsAtCompileTime) == 1 && int(U::ColsAtCompileTime) == 1) ||
+ (int(T::ColsAtCompileTime) == 1 && int(U::RowsAtCompileTime) == 1))>
struct dot_nocheck
{
typedef scalar_conj_product_op::Scalar,typename traits::Scalar> conj_prod;
diff --git a/Eigen/src/Core/GenericPacketMath.h b/Eigen/src/Core/GenericPacketMath.h
index cf677a1..af45f39 100644
--- a/Eigen/src/Core/GenericPacketMath.h
+++ b/Eigen/src/Core/GenericPacketMath.h
@@ -160,7 +160,7 @@ struct eigen_packet_wrapper
{
EIGEN_ALWAYS_INLINE operator T&() { return m_val; }
EIGEN_ALWAYS_INLINE operator const T&() const { return m_val; }
- EIGEN_ALWAYS_INLINE eigen_packet_wrapper() {}
+ EIGEN_ALWAYS_INLINE eigen_packet_wrapper() {};
EIGEN_ALWAYS_INLINE eigen_packet_wrapper(const T &v) : m_val(v) {}
EIGEN_ALWAYS_INLINE eigen_packet_wrapper& operator=(const T &v) {
m_val = v;
@@ -258,7 +258,7 @@ struct ptrue_impl {
// uses a comparison to zero, so this should still work in most cases. We don't
// have another option, since the scalar type requires initialization.
template
-struct ptrue_impl::value && NumTraits::RequireInitialization>::type > {
static EIGEN_DEVICE_FUNC inline T run(const T& /*a*/){
return T(1);
@@ -356,16 +356,16 @@ struct bytewise_bitwise_helper {
EIGEN_DEVICE_FUNC static inline T bitwise_and(const T& a, const T& b) {
return binary(a, b, bit_and());
}
- EIGEN_DEVICE_FUNC static inline T bitwise_or(const T& a, const T& b) {
+ EIGEN_DEVICE_FUNC static inline T bitwise_or(const T& a, const T& b) {
return binary(a, b, bit_or());
}
EIGEN_DEVICE_FUNC static inline T bitwise_xor(const T& a, const T& b) {
return binary(a, b, bit_xor());
}
- EIGEN_DEVICE_FUNC static inline T bitwise_not(const T& a) {
+ EIGEN_DEVICE_FUNC static inline T bitwise_not(const T& a) {
return unary(a,bit_not());
}
-
+
private:
template
EIGEN_DEVICE_FUNC static inline T unary(const T& a, Op op) {
@@ -440,7 +440,7 @@ struct pselect_impl {
// For scalars, use ternary select.
template
-struct pselect_impl::value>::type > {
static EIGEN_DEVICE_FUNC inline Packet run(const Packet& mask, const Packet& a, const Packet& b) {
return numext::equal_strict(mask, Packet(0)) ? b : a;
@@ -807,7 +807,7 @@ Packet plog10(const Packet& a) { EIGEN_USING_STD(log10); return log10(a); }
template EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
Packet plog2(const Packet& a) {
typedef typename internal::unpacket_traits::type Scalar;
- return pmul(pset1(Scalar(EIGEN_LOG2E)), plog(a));
+ return pmul(pset1(Scalar(EIGEN_LOG2E)), plog(a));
}
/** \internal \returns the square-root of \a a (coeff-wise) */
@@ -881,7 +881,7 @@ predux(const Packet& a)
template
EIGEN_DEVICE_FUNC inline typename unpacket_traits::type predux_mul(
const Packet& a) {
- typedef typename unpacket_traits::type Scalar;
+ typedef typename unpacket_traits::type Scalar;
return predux_helper(a, EIGEN_BINARY_OP_NAN_PROPAGATION(Scalar, (pmul)));
}
@@ -889,14 +889,14 @@ EIGEN_DEVICE_FUNC inline typename unpacket_traits::type predux_mul(
template
EIGEN_DEVICE_FUNC inline typename unpacket_traits::type predux_min(
const Packet &a) {
- typedef typename unpacket_traits::type Scalar;
+ typedef typename unpacket_traits::type Scalar;
return predux_helper(a, EIGEN_BINARY_OP_NAN_PROPAGATION(Scalar, (pmin)));
}
template
EIGEN_DEVICE_FUNC inline typename unpacket_traits::type predux_min(
const Packet& a) {
- typedef typename unpacket_traits::type Scalar;
+ typedef typename unpacket_traits::type Scalar;
return predux_helper(a, EIGEN_BINARY_OP_NAN_PROPAGATION(Scalar, (pmin)));
}
@@ -904,14 +904,14 @@ EIGEN_DEVICE_FUNC inline typename unpacket_traits::type predux_min(
template
EIGEN_DEVICE_FUNC inline typename unpacket_traits::type predux_max(
const Packet &a) {
- typedef typename unpacket_traits::type Scalar;
+ typedef typename unpacket_traits::type Scalar;
return predux_helper(a, EIGEN_BINARY_OP_NAN_PROPAGATION(Scalar, (pmax)));
}
template
EIGEN_DEVICE_FUNC inline typename unpacket_traits::type predux_max(
const Packet& a) {
- typedef typename unpacket_traits::type Scalar;
+ typedef typename unpacket_traits::type Scalar;
return predux_helper(a, EIGEN_BINARY_OP_NAN_PROPAGATION(Scalar, (pmax)));
}
diff --git a/Eigen/src/Core/IndexedView.h b/Eigen/src/Core/IndexedView.h
index 0847625..05c2bc9 100644
--- a/Eigen/src/Core/IndexedView.h
+++ b/Eigen/src/Core/IndexedView.h
@@ -122,10 +122,10 @@ public:
{}
/** \returns number of rows */
- Index rows() const { return internal::size(m_rowIndices); }
+ Index rows() const { return internal::index_list_size(m_rowIndices); }
/** \returns number of columns */
- Index cols() const { return internal::size(m_colIndices); }
+ Index cols() const { return internal::index_list_size(m_colIndices); }
/** \returns the nested expression */
const typename internal::remove_all::type&
@@ -189,12 +189,16 @@ struct unary_evaluator, IndexBased>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
CoeffReturnType coeff(Index row, Index col) const
{
+ eigen_assert(m_xpr.rowIndices()[row] >= 0 && m_xpr.rowIndices()[row] < m_xpr.nestedExpression().rows()
+ && m_xpr.colIndices()[col] >= 0 && m_xpr.colIndices()[col] < m_xpr.nestedExpression().cols());
return m_argImpl.coeff(m_xpr.rowIndices()[row], m_xpr.colIndices()[col]);
}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Scalar& coeffRef(Index row, Index col)
{
+ eigen_assert(m_xpr.rowIndices()[row] >= 0 && m_xpr.rowIndices()[row] < m_xpr.nestedExpression().rows()
+ && m_xpr.colIndices()[col] >= 0 && m_xpr.colIndices()[col] < m_xpr.nestedExpression().cols());
return m_argImpl.coeffRef(m_xpr.rowIndices()[row], m_xpr.colIndices()[col]);
}
@@ -204,6 +208,8 @@ struct unary_evaluator, IndexBased>
EIGEN_STATIC_ASSERT_LVALUE(XprType)
Index row = XprType::RowsAtCompileTime == 1 ? 0 : index;
Index col = XprType::RowsAtCompileTime == 1 ? index : 0;
+ eigen_assert(m_xpr.rowIndices()[row] >= 0 && m_xpr.rowIndices()[row] < m_xpr.nestedExpression().rows()
+ && m_xpr.colIndices()[col] >= 0 && m_xpr.colIndices()[col] < m_xpr.nestedExpression().cols());
return m_argImpl.coeffRef( m_xpr.rowIndices()[row], m_xpr.colIndices()[col]);
}
@@ -212,6 +218,8 @@ struct unary_evaluator, IndexBased>
{
Index row = XprType::RowsAtCompileTime == 1 ? 0 : index;
Index col = XprType::RowsAtCompileTime == 1 ? index : 0;
+ eigen_assert(m_xpr.rowIndices()[row] >= 0 && m_xpr.rowIndices()[row] < m_xpr.nestedExpression().rows()
+ && m_xpr.colIndices()[col] >= 0 && m_xpr.colIndices()[col] < m_xpr.nestedExpression().cols());
return m_argImpl.coeffRef( m_xpr.rowIndices()[row], m_xpr.colIndices()[col]);
}
@@ -220,6 +228,8 @@ struct unary_evaluator, IndexBased>
{
Index row = XprType::RowsAtCompileTime == 1 ? 0 : index;
Index col = XprType::RowsAtCompileTime == 1 ? index : 0;
+ eigen_assert(m_xpr.rowIndices()[row] >= 0 && m_xpr.rowIndices()[row] < m_xpr.nestedExpression().rows()
+ && m_xpr.colIndices()[col] >= 0 && m_xpr.colIndices()[col] < m_xpr.nestedExpression().cols());
return m_argImpl.coeff( m_xpr.rowIndices()[row], m_xpr.colIndices()[col]);
}
diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h
index 61b78f4..764c41c 100644
--- a/Eigen/src/Core/MathFunctions.h
+++ b/Eigen/src/Core/MathFunctions.h
@@ -588,12 +588,8 @@ struct arg_default_impl {
EIGEN_DEVICE_FUNC
static inline RealScalar run(const Scalar& x)
{
- #if defined(EIGEN_HIP_DEVICE_COMPILE)
- // HIP does not seem to have a native device side implementation for the math routine "arg"
+ // There is no official ::arg on device in CUDA/HIP, so we always need to use std::arg.
using std::arg;
- #else
- EIGEN_USING_STD(arg);
- #endif
return static_cast(arg(x));
}
};
@@ -881,13 +877,159 @@ struct meta_floor_log2
// no value, error at compile time
};
-template
-struct random_default_impl
-{
- static inline Scalar run(const Scalar& x, const Scalar& y)
- {
- if (y <= x)
- return x;
+template
+struct count_bits_impl {
+ static EIGEN_DEVICE_FUNC inline int clz(BitsType bits) {
+ EIGEN_STATIC_ASSERT(
+ is_integral::value && !NumTraits::IsSigned,
+ THIS_TYPE_IS_NOT_SUPPORTED);
+ int n = CHAR_BIT * sizeof(BitsType);
+ int shift = n / 2;
+ while (bits > 0 && shift > 0) {
+ BitsType y = bits >> shift;
+ if (y > 0) {
+ n -= shift;
+ bits = y;
+ }
+ shift /= 2;
+ }
+ if (shift == 0) {
+ --n;
+ }
+ return n;
+ }
+
+ static EIGEN_DEVICE_FUNC inline int ctz(BitsType bits) {
+ EIGEN_STATIC_ASSERT(
+ is_integral::value && !NumTraits::IsSigned,
+ THIS_TYPE_IS_NOT_SUPPORTED);
+ int n = CHAR_BIT * sizeof(BitsType);
+ int shift = n / 2;
+ while (bits > 0 && shift > 0) {
+ BitsType y = bits << shift;
+ if (y > 0) {
+ n -= shift;
+ bits = y;
+ }
+ shift /= 2;
+ }
+ if (shift == 0) {
+ --n;
+ }
+ return n;
+ }
+};
+
+// Count leading zeros.
+template
+EIGEN_DEVICE_FUNC inline int clz(BitsType bits) {
+ return count_bits_impl::clz(bits);
+}
+
+// Count trailing zeros.
+template
+EIGEN_DEVICE_FUNC inline int ctz(BitsType bits) {
+ return count_bits_impl::ctz(bits);
+}
+
+#if EIGEN_COMP_GNUC || EIGEN_COMP_CLANG
+
+template
+struct count_bits_impl::type> {
+ static const int kNumBits = static_cast(sizeof(BitsType) * CHAR_BIT);
+ static EIGEN_DEVICE_FUNC inline int clz(BitsType bits) {
+ EIGEN_STATIC_ASSERT(is_integral::value, THIS_TYPE_IS_NOT_SUPPORTED);
+ static const int kLeadingBitsOffset = (sizeof(unsigned int) - sizeof(BitsType)) * CHAR_BIT;
+ return bits == 0 ? kNumBits : __builtin_clz(static_cast(bits)) - kLeadingBitsOffset;
+ }
+
+ static EIGEN_DEVICE_FUNC inline int ctz(BitsType bits) {
+ EIGEN_STATIC_ASSERT(is_integral::value, THIS_TYPE_IS_NOT_SUPPORTED);
+ return bits == 0 ? kNumBits : __builtin_ctz(static_cast(bits));
+ }
+};
+
+template
+struct count_bits_impl<
+ BitsType, typename enable_if::type> {
+ static const int kNumBits = static_cast(sizeof(BitsType) * CHAR_BIT);
+ static EIGEN_DEVICE_FUNC inline int clz(BitsType bits) {
+ EIGEN_STATIC_ASSERT(is_integral::value, THIS_TYPE_IS_NOT_SUPPORTED);
+ static const int kLeadingBitsOffset = (sizeof(unsigned long) - sizeof(BitsType)) * CHAR_BIT;
+ return bits == 0 ? kNumBits : __builtin_clzl(static_cast(bits)) - kLeadingBitsOffset;
+ }
+
+ static EIGEN_DEVICE_FUNC inline int ctz(BitsType bits) {
+ EIGEN_STATIC_ASSERT(is_integral::value, THIS_TYPE_IS_NOT_SUPPORTED);
+ return bits == 0 ? kNumBits : __builtin_ctzl(static_cast(bits));
+ }
+};
+
+template
+struct count_bits_impl::type> {
+ static const int kNumBits = static_cast(sizeof(BitsType) * CHAR_BIT);
+ static EIGEN_DEVICE_FUNC inline int clz(BitsType bits) {
+ EIGEN_STATIC_ASSERT(is_integral::value, THIS_TYPE_IS_NOT_SUPPORTED);
+ static const int kLeadingBitsOffset = (sizeof(unsigned long long) - sizeof(BitsType)) * CHAR_BIT;
+ return bits == 0 ? kNumBits : __builtin_clzll(static_cast(bits)) - kLeadingBitsOffset;
+ }
+
+ static EIGEN_DEVICE_FUNC inline int ctz(BitsType bits) {
+ EIGEN_STATIC_ASSERT(is_integral::value, THIS_TYPE_IS_NOT_SUPPORTED);
+ return bits == 0 ? kNumBits : __builtin_ctzll(static_cast(bits));
+ }
+};
+
+#elif EIGEN_COMP_MSVC
+
+template
+struct count_bits_impl::type> {
+ static const int kNumBits = static_cast(sizeof(BitsType) * CHAR_BIT);
+ static EIGEN_DEVICE_FUNC inline int clz(BitsType bits) {
+ EIGEN_STATIC_ASSERT(is_integral::value, THIS_TYPE_IS_NOT_SUPPORTED);
+ unsigned long out;
+ _BitScanReverse(&out, static_cast(bits));
+ return bits == 0 ? kNumBits : (kNumBits - 1) - static_cast(out);
+ }
+
+ static EIGEN_DEVICE_FUNC inline int ctz(BitsType bits) {
+ EIGEN_STATIC_ASSERT(is_integral::value, THIS_TYPE_IS_NOT_SUPPORTED);
+ unsigned long out;
+ _BitScanForward(&out, static_cast(bits));
+ return bits == 0 ? kNumBits : static_cast(out);
+ }
+};
+
+#ifdef _WIN64
+
+template
+struct count_bits_impl<
+ BitsType, typename enable_if::type> {
+ static const int kNumBits = static_cast(sizeof(BitsType) * CHAR_BIT);
+ static EIGEN_DEVICE_FUNC inline int clz(BitsType bits) {
+ EIGEN_STATIC_ASSERT(is_integral::value, THIS_TYPE_IS_NOT_SUPPORTED);
+ unsigned long out;
+ _BitScanReverse64(&out, static_cast(bits));
+ return bits == 0 ? kNumBits : (kNumBits - 1) - static_cast(out);
+ }
+
+ static EIGEN_DEVICE_FUNC inline int ctz(BitsType bits) {
+ EIGEN_STATIC_ASSERT(is_integral::value, THIS_TYPE_IS_NOT_SUPPORTED);
+ unsigned long out;
+ _BitScanForward64(&out, static_cast(bits));
+ return bits == 0 ? kNumBits : static_cast(out);
+ }
+};
+
+#endif // _WIN64
+
+#endif // EIGEN_COMP_GNUC || EIGEN_COMP_CLANG
+
+template
+struct random_default_impl {
+ static inline Scalar run(const Scalar& x, const Scalar& y) {
+ if (y <= x) return x;
// ScalarU is the unsigned counterpart of Scalar, possibly Scalar itself.
typedef typename make_unsigned::type ScalarU;
// ScalarX is the widest of ScalarU and unsigned int.
@@ -1032,11 +1174,15 @@ template EIGEN_DEVICE_FUNC bool isinf_msvc_helper(T x)
}
//MSVC defines a _isnan builtin function, but for double only
+#ifndef EIGEN_GPU_COMPILE_PHASE
EIGEN_DEVICE_FUNC inline bool isnan_impl(const long double& x) { return _isnan(x)!=0; }
+#endif
EIGEN_DEVICE_FUNC inline bool isnan_impl(const double& x) { return _isnan(x)!=0; }
EIGEN_DEVICE_FUNC inline bool isnan_impl(const float& x) { return _isnan(x)!=0; }
+#ifndef EIGEN_GPU_COMPILE_PHASE
EIGEN_DEVICE_FUNC inline bool isinf_impl(const long double& x) { return isinf_msvc_helper(x); }
+#endif
EIGEN_DEVICE_FUNC inline bool isinf_impl(const double& x) { return isinf_msvc_helper(x); }
EIGEN_DEVICE_FUNC inline bool isinf_impl(const float& x) { return isinf_msvc_helper(x); }
@@ -1050,12 +1196,16 @@ EIGEN_DEVICE_FUNC inline bool isinf_impl(const float& x) { return isinf_ms
#define EIGEN_TMP_NOOPT_ATTRIB EIGEN_DEVICE_FUNC inline __attribute__((noinline,optimize("no-finite-math-only")))
#endif
+#ifndef EIGEN_GPU_COMPILE_PHASE
template<> EIGEN_TMP_NOOPT_ATTRIB bool isnan_impl(const long double& x) { return __builtin_isnan(x); }
+#endif
template<> EIGEN_TMP_NOOPT_ATTRIB bool isnan_impl(const double& x) { return __builtin_isnan(x); }
template<> EIGEN_TMP_NOOPT_ATTRIB bool isnan_impl(const float& x) { return __builtin_isnan(x); }
template<> EIGEN_TMP_NOOPT_ATTRIB bool isinf_impl(const double& x) { return __builtin_isinf(x); }
template<> EIGEN_TMP_NOOPT_ATTRIB bool isinf_impl(const float& x) { return __builtin_isinf(x); }
+#ifndef EIGEN_GPU_COMPILE_PHASE
template<> EIGEN_TMP_NOOPT_ATTRIB bool isinf_impl(const long double& x) { return __builtin_isinf(x); }
+#endif
#undef EIGEN_TMP_NOOPT_ATTRIB
@@ -1112,6 +1262,8 @@ EIGEN_ALWAYS_INLINE double mini(const double& x, const double& y)
{
return fmin(x, y);
}
+
+#ifndef EIGEN_GPU_COMPILE_PHASE
template<>
EIGEN_DEVICE_FUNC
EIGEN_ALWAYS_INLINE long double mini(const long double& x, const long double& y)
@@ -1123,6 +1275,7 @@ EIGEN_ALWAYS_INLINE long double mini(const long double& x, const long double& y)
return fminl(x, y);
#endif
}
+#endif
template
EIGEN_DEVICE_FUNC
@@ -1142,6 +1295,7 @@ EIGEN_ALWAYS_INLINE double maxi(const double& x, const double& y)
{
return fmax(x, y);
}
+#ifndef EIGEN_GPU_COMPILE_PHASE
template<>
EIGEN_DEVICE_FUNC
EIGEN_ALWAYS_INLINE long double maxi(const long double& x, const long double& y)
@@ -1154,6 +1308,7 @@ EIGEN_ALWAYS_INLINE long double maxi(const long double& x, const long double& y)
#endif
}
#endif
+#endif
#if defined(SYCL_DEVICE_ONLY)
@@ -1310,8 +1465,8 @@ EIGEN_ALWAYS_INLINE double absdiff(const double& x, const double& y)
return fabs(x - y);
}
-#if !defined(EIGEN_GPUCC)
// HIP and CUDA do not support long double.
+#ifndef EIGEN_GPU_COMPILE_PHASE
template<>
EIGEN_DEVICE_FUNC
EIGEN_ALWAYS_INLINE long double absdiff(const long double& x, const long double& y) {
diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h
index f0e59a9..29c3b5c 100644
--- a/Eigen/src/Core/Matrix.h
+++ b/Eigen/src/Core/Matrix.h
@@ -225,8 +225,6 @@ class Matrix
return Base::_set(other);
}
- /* Here, doxygen failed to copy the brief information when using \copydoc */
-
/**
* \brief Copies the generic expression \a other into *this.
* \copydetails DenseBase::operator=(const EigenBase &other)
@@ -284,7 +282,15 @@ class Matrix
#endif
#if EIGEN_HAS_CXX11
- /** \copydoc PlainObjectBase(const Scalar&, const Scalar&, const Scalar&, const Scalar&, const ArgTypes&... args)
+ /** \brief Construct a row of column vector with fixed size from an arbitrary number of coefficients. \cpp11
+ *
+ * \only_for_vectors
+ *
+ * This constructor is for 1D array or vectors with more than 4 coefficients.
+ * There exists C++98 analogue constructors for fixed-size array/vector having 1, 2, 3, or 4 coefficients.
+ *
+ * \warning To construct a column (resp. row) vector of fixed length, the number of values passed to this
+ * constructor must match the the fixed number of rows (resp. columns) of \c *this.
*
* Example: \include Matrix_variadic_ctor_cxx11.cpp
* Output: \verbinclude Matrix_variadic_ctor_cxx11.out
@@ -297,6 +303,8 @@ class Matrix
: Base(a0, a1, a2, a3, args...) {}
/** \brief Constructs a Matrix and initializes it from the coefficients given as initializer-lists grouped by row. \cpp11
+ *
+ * \anchor matrix_constructor_initializer_list
*
* In the general case, the constructor takes a list of rows, each row being represented as a list of coefficients:
*
@@ -480,16 +488,21 @@ class Matrix
#define EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \
/** \ingroup matrixtypedefs */ \
+/** \brief \noop */ \
typedef Matrix Matrix##SizeSuffix##TypeSuffix; \
/** \ingroup matrixtypedefs */ \
+/** \brief \noop */ \
typedef Matrix Vector##SizeSuffix##TypeSuffix; \
/** \ingroup matrixtypedefs */ \
+/** \brief \noop */ \
typedef Matrix RowVector##SizeSuffix##TypeSuffix;
#define EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, Size) \
/** \ingroup matrixtypedefs */ \
+/** \brief \noop */ \
typedef Matrix Matrix##Size##X##TypeSuffix; \
/** \ingroup matrixtypedefs */ \
+/** \brief \noop */ \
typedef Matrix Matrix##X##Size##TypeSuffix;
#define EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \
diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h
index 45c3a59..d93a7e3 100644
--- a/Eigen/src/Core/MatrixBase.h
+++ b/Eigen/src/Core/MatrixBase.h
@@ -206,28 +206,22 @@ template class MatrixBase
EIGEN_DEVICE_FUNC
DiagonalReturnType diagonal();
- typedef typename internal::add_const >::type ConstDiagonalReturnType;
+ typedef Diagonal ConstDiagonalReturnType;
EIGEN_DEVICE_FUNC
- ConstDiagonalReturnType diagonal() const;
-
- template struct DiagonalIndexReturnType { typedef Diagonal Type; };
- template struct ConstDiagonalIndexReturnType { typedef const Diagonal Type; };
+ const ConstDiagonalReturnType diagonal() const;
template
EIGEN_DEVICE_FUNC
- typename DiagonalIndexReturnType::Type diagonal();
+ Diagonal diagonal();
template
EIGEN_DEVICE_FUNC
- typename ConstDiagonalIndexReturnType::Type diagonal() const;
-
- typedef Diagonal DiagonalDynamicIndexReturnType;
- typedef typename internal::add_const >::type ConstDiagonalDynamicIndexReturnType;
+ const Diagonal diagonal() const;
EIGEN_DEVICE_FUNC
- DiagonalDynamicIndexReturnType diagonal(Index index);
+ Diagonal diagonal(Index index);
EIGEN_DEVICE_FUNC
- ConstDiagonalDynamicIndexReturnType diagonal(Index index) const;
+ const Diagonal diagonal(Index index) const;
template struct TriangularViewReturnType { typedef TriangularView Type; };
template struct ConstTriangularViewReturnType { typedef const TriangularView Type; };
diff --git a/Eigen/src/Core/NumTraits.h b/Eigen/src/Core/NumTraits.h
index 72eac5a..7c2c50b 100644
--- a/Eigen/src/Core/NumTraits.h
+++ b/Eigen/src/Core/NumTraits.h
@@ -98,6 +98,7 @@ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Tgt bit_cast(const Src& src) {
}
} // namespace numext
+// clang-format off
/** \class NumTraits
* \ingroup Core_Module
*
@@ -109,45 +110,47 @@ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Tgt bit_cast(const Src& src) {
*
* The provided data consists of:
* \li A typedef \c Real, giving the "real part" type of \a T. If \a T is already real,
- * then \c Real is just a typedef to \a T. If \a T is \c std::complex then \c Real
+ * then \c Real is just a typedef to \a T. If \a T is `std::complex` then \c Real
* is a typedef to \a U.
* \li A typedef \c NonInteger, giving the type that should be used for operations producing non-integral values,
* such as quotients, square roots, etc. If \a T is a floating-point type, then this typedef just gives
- * \a T again. Note however that many Eigen functions such as internal::sqrt simply refuse to
+ * \a T again. Note however that many Eigen functions such as `internal::sqrt` simply refuse to
* take integers. Outside of a few cases, Eigen doesn't do automatic type promotion. Thus, this typedef is
* only intended as a helper for code that needs to explicitly promote types.
- * \li A typedef \c Literal giving the type to use for numeric literals such as "2" or "0.5". For instance, for \c std::complex, Literal is defined as \c U.
+ * \li A typedef \c Literal giving the type to use for numeric literals such as "2" or "0.5". For instance, for `std::complex`,
+ * Literal is defined as \c U.
* Of course, this type must be fully compatible with \a T. In doubt, just use \a T here.
- * \li A typedef \a Nested giving the type to use to nest a value inside of the expression tree. If you don't know what
+ * \li A typedef \c Nested giving the type to use to nest a value inside of the expression tree. If you don't know what
* this means, just use \a T here.
- * \li An enum value \a IsComplex. It is equal to 1 if \a T is a \c std::complex
+ * \li An enum value \c IsComplex. It is equal to 1 if \a T is a \c std::complex
* type, and to 0 otherwise.
- * \li An enum value \a IsInteger. It is equal to \c 1 if \a T is an integer type such as \c int,
+ * \li An enum value \c IsInteger. It is equal to \c 1 if \a T is an integer type such as \c int,
* and to \c 0 otherwise.
- * \li Enum values ReadCost, AddCost and MulCost representing a rough estimate of the number of CPU cycles needed
+ * \li Enum values \c ReadCost, \c AddCost and \c MulCost representing a rough estimate of the number of CPU cycles needed
* to by move / add / mul instructions respectively, assuming the data is already stored in CPU registers.
* Stay vague here. No need to do architecture-specific stuff. If you don't know what this means, just use \c Eigen::HugeCost.
- * \li An enum value \a IsSigned. It is equal to \c 1 if \a T is a signed type and to 0 if \a T is unsigned.
- * \li An enum value \a RequireInitialization. It is equal to \c 1 if the constructor of the numeric type \a T must
+ * \li An enum value \c IsSigned. It is equal to \c 1 if \a T is a signed type and to 0 if \a T is unsigned.
+ * \li An enum value \c RequireInitialization. It is equal to \c 1 if the constructor of the numeric type \a T must
* be called, and to 0 if it is safe not to call it. Default is 0 if \a T is an arithmetic type, and 1 otherwise.
- * \li An epsilon() function which, unlike std::numeric_limits::epsilon(),
- * it returns a \a Real instead of a \a T.
- * \li A dummy_precision() function returning a weak epsilon value. It is mainly used as a default
+ * \li An `epsilon()` function which, unlike `std::numeric_limits::epsilon()`,
+ * it returns a \c Real instead of a \a T.
+ * \li A `dummy_precision()` function returning a weak epsilon value. It is mainly used as a default
* value by the fuzzy comparison operators.
- * \li highest() and lowest() functions returning the highest and lowest possible values respectively.
- * \li digits() function returning the number of radix digits (non-sign digits for integers, mantissa for floating-point). This is
+ * \li `highest()` and `lowest()` functions returning the highest and lowest possible values respectively.
+ * \li `digits()` function returning the number of radix digits (non-sign digits for integers, mantissa for floating-point). This is
* the analogue of std::numeric_limits::digits
* which is used as the default implementation if specialized.
- * \li digits10() function returning the number of decimal digits that can be represented without change. This is
+ * \li `digits10()` function returning the number of decimal digits that can be represented without change. This is
* the analogue of std::numeric_limits::digits10
* which is used as the default implementation if specialized.
- * \li min_exponent() and max_exponent() functions returning the highest and lowest possible values, respectively,
+ * \li `min_exponent()` and `max_exponent()` functions returning the highest and lowest possible values, respectively,
* such that the radix raised to the power exponent-1 is a normalized floating-point number. These are equivalent to
- * std::numeric_limits::min_exponent/
- * std::numeric_limits::max_exponent.
- * \li infinity() function returning a representation of positive infinity, if available.
- * \li quiet_NaN function returning a non-signaling "not-a-number", if available.
+ * `std::numeric_limits::min_exponent`/
+ * `std::numeric_limits::max_exponent`.
+ * \li `infinity()` function returning a representation of positive infinity, if available.
+ * \li `quiet_NaN` function returning a non-signaling "not-a-number", if available.
*/
+ // clang-format on
template struct GenericNumTraits
{
@@ -245,12 +248,25 @@ template<> struct NumTraits : GenericNumTraits
static inline double dummy_precision() { return 1e-12; }
};
+// GPU devices treat `long double` as `double`.
+#ifndef EIGEN_GPU_COMPILE_PHASE
template<> struct NumTraits
: GenericNumTraits
{
- EIGEN_CONSTEXPR
- static inline long double dummy_precision() { return 1e-15l; }
+ EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
+ static inline long double dummy_precision() { return static_cast(1e-15l); }
+
+#if defined(EIGEN_ARCH_PPC) && (__LDBL_MANT_DIG__ == 106)
+ // PowerPC double double causes issues with some values
+ EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
+ static inline long double epsilon()
+ {
+ // 2^(-(__LDBL_MANT_DIG__)+1)
+ return static_cast(2.4651903288156618919116517665087e-32l);
+ }
+#endif
};
+#endif
template struct NumTraits