Skip to content

Commit ec34286

Browse files
committed
Eigen 3.3.5
1 parent 95d0d2c commit ec34286

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+413
-248
lines changed

inst/include/Eigen/Core

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@
171171
#ifdef __AVX512DQ__
172172
#define EIGEN_VECTORIZE_AVX512DQ
173173
#endif
174+
#ifdef __AVX512ER__
175+
#define EIGEN_VECTORIZE_AVX512ER
176+
#endif
174177
#endif
175178

176179
// include files
@@ -384,6 +387,7 @@ using std::ptrdiff_t;
384387
#include "src/Core/arch/AVX/MathFunctions.h"
385388
#include "src/Core/arch/AVX/Complex.h"
386389
#include "src/Core/arch/AVX/TypeCasting.h"
390+
#include "src/Core/arch/SSE/TypeCasting.h"
387391
#elif defined EIGEN_VECTORIZE_SSE
388392
#include "src/Core/arch/SSE/PacketMath.h"
389393
#include "src/Core/arch/SSE/MathFunctions.h"

inst/include/Eigen/src/Cholesky/LDLT.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -570,13 +570,14 @@ void LDLT<_MatrixType,_UpLo>::_solve_impl(const RhsType &rhs, DstType &dst) cons
570570
// more precisely, use pseudo-inverse of D (see bug 241)
571571
using std::abs;
572572
const typename Diagonal<const MatrixType>::RealReturnType vecD(vectorD());
573-
// In some previous versions, tolerance was set to the max of 1/highest and the maximal diagonal entry * epsilon
574-
// as motivated by LAPACK's xGELSS:
573+
// In some previous versions, tolerance was set to the max of 1/highest (or rather numeric_limits::min())
574+
// and the maximal diagonal entry * epsilon as motivated by LAPACK's xGELSS:
575575
// RealScalar tolerance = numext::maxi(vecD.array().abs().maxCoeff() * NumTraits<RealScalar>::epsilon(),RealScalar(1) / NumTraits<RealScalar>::highest());
576576
// However, LDLT is not rank revealing, and so adjusting the tolerance wrt to the highest
577577
// diagonal element is not well justified and leads to numerical issues in some cases.
578578
// Moreover, Lapack's xSYTRS routines use 0 for the tolerance.
579-
RealScalar tolerance = RealScalar(1) / NumTraits<RealScalar>::highest();
579+
// Using numeric_limits::min() gives us more robustness to denormals.
580+
RealScalar tolerance = (std::numeric_limits<RealScalar>::min)();
580581

581582
for (Index i = 0; i < vecD.size(); ++i)
582583
{

inst/include/Eigen/src/Core/Assign_MKL.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ class vml_assign_traits
8484
struct Assignment<DstXprType, CwiseUnaryOp<scalar_##EIGENOP##_op<EIGENTYPE>, SrcXprNested>, assign_op<EIGENTYPE,EIGENTYPE>, \
8585
Dense2Dense, typename enable_if<vml_assign_traits<DstXprType,SrcXprNested>::EnableVml>::type> { \
8686
typedef CwiseUnaryOp<scalar_##EIGENOP##_op<EIGENTYPE>, SrcXprNested> SrcXprType; \
87-
static void run(DstXprType &dst, const SrcXprType &src, const assign_op<EIGENTYPE,EIGENTYPE> &/*func*/) { \
87+
static void run(DstXprType &dst, const SrcXprType &src, const assign_op<EIGENTYPE,EIGENTYPE> &func) { \
88+
resize_if_allowed(dst, src, func); \
8889
eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols()); \
8990
if(vml_assign_traits<DstXprType,SrcXprNested>::Traversal==LinearTraversal) { \
9091
VMLOP(dst.size(), (const VMLTYPE*)src.nestedExpression().data(), \
@@ -144,7 +145,8 @@ EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(ceil, Ceil, _)
144145
Dense2Dense, typename enable_if<vml_assign_traits<DstXprType,SrcXprNested>::EnableVml>::type> { \
145146
typedef CwiseBinaryOp<scalar_##EIGENOP##_op<EIGENTYPE,EIGENTYPE>, SrcXprNested, \
146147
const CwiseNullaryOp<internal::scalar_constant_op<EIGENTYPE>,Plain> > SrcXprType; \
147-
static void run(DstXprType &dst, const SrcXprType &src, const assign_op<EIGENTYPE,EIGENTYPE> &/*func*/) { \
148+
static void run(DstXprType &dst, const SrcXprType &src, const assign_op<EIGENTYPE,EIGENTYPE> &func) { \
149+
resize_if_allowed(dst, src, func); \
148150
eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols()); \
149151
VMLTYPE exponent = reinterpret_cast<const VMLTYPE&>(src.rhs().functor().m_other); \
150152
if(vml_assign_traits<DstXprType,SrcXprNested>::Traversal==LinearTraversal) \

inst/include/Eigen/src/Core/CoreEvaluators.h

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,14 +1020,16 @@ struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBa
10201020
EIGEN_DEVICE_FUNC explicit unary_evaluator(const XprType& block)
10211021
: m_argImpl(block.nestedExpression()),
10221022
m_startRow(block.startRow()),
1023-
m_startCol(block.startCol())
1023+
m_startCol(block.startCol()),
1024+
m_linear_offset(InnerPanel?(XprType::IsRowMajor ? block.startRow()*block.cols() : block.startCol()*block.rows()):0)
10241025
{ }
10251026

10261027
typedef typename XprType::Scalar Scalar;
10271028
typedef typename XprType::CoeffReturnType CoeffReturnType;
10281029

10291030
enum {
1030-
RowsAtCompileTime = XprType::RowsAtCompileTime
1031+
RowsAtCompileTime = XprType::RowsAtCompileTime,
1032+
ForwardLinearAccess = InnerPanel && bool(evaluator<ArgType>::Flags&LinearAccessBit)
10311033
};
10321034

10331035
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
@@ -1039,7 +1041,10 @@ struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBa
10391041
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
10401042
CoeffReturnType coeff(Index index) const
10411043
{
1042-
return coeff(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
1044+
if (ForwardLinearAccess)
1045+
return m_argImpl.coeff(m_linear_offset.value() + index);
1046+
else
1047+
return coeff(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
10431048
}
10441049

10451050
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
@@ -1051,7 +1056,10 @@ struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBa
10511056
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
10521057
Scalar& coeffRef(Index index)
10531058
{
1054-
return coeffRef(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
1059+
if (ForwardLinearAccess)
1060+
return m_argImpl.coeffRef(m_linear_offset.value() + index);
1061+
else
1062+
return coeffRef(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
10551063
}
10561064

10571065
template<int LoadMode, typename PacketType>
@@ -1065,8 +1073,11 @@ struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBa
10651073
EIGEN_STRONG_INLINE
10661074
PacketType packet(Index index) const
10671075
{
1068-
return packet<LoadMode,PacketType>(RowsAtCompileTime == 1 ? 0 : index,
1069-
RowsAtCompileTime == 1 ? index : 0);
1076+
if (ForwardLinearAccess)
1077+
return m_argImpl.template packet<LoadMode,PacketType>(m_linear_offset.value() + index);
1078+
else
1079+
return packet<LoadMode,PacketType>(RowsAtCompileTime == 1 ? 0 : index,
1080+
RowsAtCompileTime == 1 ? index : 0);
10701081
}
10711082

10721083
template<int StoreMode, typename PacketType>
@@ -1080,15 +1091,19 @@ struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBa
10801091
EIGEN_STRONG_INLINE
10811092
void writePacket(Index index, const PacketType& x)
10821093
{
1083-
return writePacket<StoreMode,PacketType>(RowsAtCompileTime == 1 ? 0 : index,
1084-
RowsAtCompileTime == 1 ? index : 0,
1085-
x);
1094+
if (ForwardLinearAccess)
1095+
return m_argImpl.template writePacket<StoreMode,PacketType>(m_linear_offset.value() + index, x);
1096+
else
1097+
return writePacket<StoreMode,PacketType>(RowsAtCompileTime == 1 ? 0 : index,
1098+
RowsAtCompileTime == 1 ? index : 0,
1099+
x);
10861100
}
10871101

10881102
protected:
10891103
evaluator<ArgType> m_argImpl;
10901104
const variable_if_dynamic<Index, (ArgType::RowsAtCompileTime == 1 && BlockRows==1) ? 0 : Dynamic> m_startRow;
10911105
const variable_if_dynamic<Index, (ArgType::ColsAtCompileTime == 1 && BlockCols==1) ? 0 : Dynamic> m_startCol;
1106+
const variable_if_dynamic<Index, InnerPanel ? Dynamic : 0> m_linear_offset;
10921107
};
10931108

10941109
// TODO: This evaluator does not actually use the child evaluator;

inst/include/Eigen/src/Core/Diagonal.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ template<typename MatrixType, int _DiagIndex> class Diagonal
7070
EIGEN_DENSE_PUBLIC_INTERFACE(Diagonal)
7171

7272
EIGEN_DEVICE_FUNC
73-
explicit inline Diagonal(MatrixType& matrix, Index a_index = DiagIndex) : m_matrix(matrix), m_index(a_index) {}
73+
explicit inline Diagonal(MatrixType& matrix, Index a_index = DiagIndex) : m_matrix(matrix), m_index(a_index)
74+
{
75+
eigen_assert( a_index <= m_matrix.cols() && -a_index <= m_matrix.rows() );
76+
}
7477

7578
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Diagonal)
7679

inst/include/Eigen/src/Core/Dot.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ struct dot_nocheck
3131
typedef scalar_conj_product_op<typename traits<T>::Scalar,typename traits<U>::Scalar> conj_prod;
3232
typedef typename conj_prod::result_type ResScalar;
3333
EIGEN_DEVICE_FUNC
34-
static inline ResScalar run(const MatrixBase<T>& a, const MatrixBase<U>& b)
34+
EIGEN_STRONG_INLINE
35+
static ResScalar run(const MatrixBase<T>& a, const MatrixBase<U>& b)
3536
{
3637
return a.template binaryExpr<conj_prod>(b).sum();
3738
}
@@ -43,7 +44,8 @@ struct dot_nocheck<T, U, true>
4344
typedef scalar_conj_product_op<typename traits<T>::Scalar,typename traits<U>::Scalar> conj_prod;
4445
typedef typename conj_prod::result_type ResScalar;
4546
EIGEN_DEVICE_FUNC
46-
static inline ResScalar run(const MatrixBase<T>& a, const MatrixBase<U>& b)
47+
EIGEN_STRONG_INLINE
48+
static ResScalar run(const MatrixBase<T>& a, const MatrixBase<U>& b)
4749
{
4850
return a.transpose().template binaryExpr<conj_prod>(b).sum();
4951
}
@@ -65,6 +67,7 @@ struct dot_nocheck<T, U, true>
6567
template<typename Derived>
6668
template<typename OtherDerived>
6769
EIGEN_DEVICE_FUNC
70+
EIGEN_STRONG_INLINE
6871
typename ScalarBinaryOpTraits<typename internal::traits<Derived>::Scalar,typename internal::traits<OtherDerived>::Scalar>::ReturnType
6972
MatrixBase<Derived>::dot(const MatrixBase<OtherDerived>& other) const
7073
{
@@ -102,7 +105,7 @@ EIGEN_STRONG_INLINE typename NumTraits<typename internal::traits<Derived>::Scala
102105
* \sa lpNorm(), dot(), squaredNorm()
103106
*/
104107
template<typename Derived>
105-
inline typename NumTraits<typename internal::traits<Derived>::Scalar>::Real MatrixBase<Derived>::norm() const
108+
EIGEN_STRONG_INLINE typename NumTraits<typename internal::traits<Derived>::Scalar>::Real MatrixBase<Derived>::norm() const
106109
{
107110
return numext::sqrt(squaredNorm());
108111
}
@@ -117,7 +120,7 @@ inline typename NumTraits<typename internal::traits<Derived>::Scalar>::Real Matr
117120
* \sa norm(), normalize()
118121
*/
119122
template<typename Derived>
120-
inline const typename MatrixBase<Derived>::PlainObject
123+
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::PlainObject
121124
MatrixBase<Derived>::normalized() const
122125
{
123126
typedef typename internal::nested_eval<Derived,2>::type _Nested;
@@ -139,7 +142,7 @@ MatrixBase<Derived>::normalized() const
139142
* \sa norm(), normalized()
140143
*/
141144
template<typename Derived>
142-
inline void MatrixBase<Derived>::normalize()
145+
EIGEN_STRONG_INLINE void MatrixBase<Derived>::normalize()
143146
{
144147
RealScalar z = squaredNorm();
145148
// NOTE: after extensive benchmarking, this conditional does not impact performance, at least on recent x86 CPU
@@ -160,7 +163,7 @@ inline void MatrixBase<Derived>::normalize()
160163
* \sa stableNorm(), stableNormalize(), normalized()
161164
*/
162165
template<typename Derived>
163-
inline const typename MatrixBase<Derived>::PlainObject
166+
EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::PlainObject
164167
MatrixBase<Derived>::stableNormalized() const
165168
{
166169
typedef typename internal::nested_eval<Derived,3>::type _Nested;
@@ -185,7 +188,7 @@ MatrixBase<Derived>::stableNormalized() const
185188
* \sa stableNorm(), stableNormalized(), normalize()
186189
*/
187190
template<typename Derived>
188-
inline void MatrixBase<Derived>::stableNormalize()
191+
EIGEN_STRONG_INLINE void MatrixBase<Derived>::stableNormalize()
189192
{
190193
RealScalar w = cwiseAbs().maxCoeff();
191194
RealScalar z = (derived()/w).squaredNorm();

inst/include/Eigen/src/Core/MathFunctions.h

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -348,31 +348,7 @@ struct norm1_retval
348348
* Implementation of hypot *
349349
****************************************************************************/
350350

351-
template<typename Scalar>
352-
struct hypot_impl
353-
{
354-
typedef typename NumTraits<Scalar>::Real RealScalar;
355-
static inline RealScalar run(const Scalar& x, const Scalar& y)
356-
{
357-
EIGEN_USING_STD_MATH(abs);
358-
EIGEN_USING_STD_MATH(sqrt);
359-
RealScalar _x = abs(x);
360-
RealScalar _y = abs(y);
361-
Scalar p, qp;
362-
if(_x>_y)
363-
{
364-
p = _x;
365-
qp = _y / p;
366-
}
367-
else
368-
{
369-
p = _y;
370-
qp = _x / p;
371-
}
372-
if(p==RealScalar(0)) return RealScalar(0);
373-
return p * sqrt(RealScalar(1) + qp*qp);
374-
}
375-
};
351+
template<typename Scalar> struct hypot_impl;
376352

377353
template<typename Scalar>
378354
struct hypot_retval
@@ -495,7 +471,7 @@ namespace std_fallback {
495471
typedef typename NumTraits<Scalar>::Real RealScalar;
496472
EIGEN_USING_STD_MATH(log);
497473
Scalar x1p = RealScalar(1) + x;
498-
return ( x1p == Scalar(1) ) ? x : x * ( log(x1p) / (x1p - RealScalar(1)) );
474+
return numext::equal_strict(x1p, Scalar(1)) ? x : x * ( log(x1p) / (x1p - RealScalar(1)) );
499475
}
500476
}
501477

inst/include/Eigen/src/Core/MathFunctionsImpl.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,29 @@ T generic_fast_tanh_float(const T& a_x)
7171
return pdiv(p, q);
7272
}
7373

74+
template<typename RealScalar>
75+
EIGEN_STRONG_INLINE
76+
RealScalar positive_real_hypot(const RealScalar& x, const RealScalar& y)
77+
{
78+
EIGEN_USING_STD_MATH(sqrt);
79+
RealScalar p, qp;
80+
p = numext::maxi(x,y);
81+
if(p==RealScalar(0)) return RealScalar(0);
82+
qp = numext::mini(y,x) / p;
83+
return p * sqrt(RealScalar(1) + qp*qp);
84+
}
85+
86+
template<typename Scalar>
87+
struct hypot_impl
88+
{
89+
typedef typename NumTraits<Scalar>::Real RealScalar;
90+
static inline RealScalar run(const Scalar& x, const Scalar& y)
91+
{
92+
EIGEN_USING_STD_MATH(abs);
93+
return positive_real_hypot<RealScalar>(abs(x), abs(y));
94+
}
95+
};
96+
7497
} // end namespace internal
7598

7699
} // end namespace Eigen

inst/include/Eigen/src/Core/Product.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ class Product : public ProductImpl<_Lhs,_Rhs,Option,
9797
&& "if you wanted a coeff-wise or a dot product use the respective explicit functions");
9898
}
9999

100-
EIGEN_DEVICE_FUNC inline Index rows() const { return m_lhs.rows(); }
101-
EIGEN_DEVICE_FUNC inline Index cols() const { return m_rhs.cols(); }
100+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rows() const { return m_lhs.rows(); }
101+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index cols() const { return m_rhs.cols(); }
102102

103103
EIGEN_DEVICE_FUNC const LhsNestedCleaned& lhs() const { return m_lhs; }
104104
EIGEN_DEVICE_FUNC const RhsNestedCleaned& rhs() const { return m_rhs; }
@@ -127,7 +127,7 @@ class dense_product_base<Lhs, Rhs, Option, InnerProduct>
127127
using Base::derived;
128128
typedef typename Base::Scalar Scalar;
129129

130-
operator const Scalar() const
130+
EIGEN_STRONG_INLINE operator const Scalar() const
131131
{
132132
return internal::evaluator<ProductXpr>(derived()).coeff(0,0);
133133
}
@@ -162,15 +162,15 @@ class ProductImpl<Lhs,Rhs,Option,Dense>
162162

163163
public:
164164

165-
EIGEN_DEVICE_FUNC Scalar coeff(Index row, Index col) const
165+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar coeff(Index row, Index col) const
166166
{
167167
EIGEN_STATIC_ASSERT(EnableCoeff, THIS_METHOD_IS_ONLY_FOR_INNER_OR_LAZY_PRODUCTS);
168168
eigen_assert( (Option==LazyProduct) || (this->rows() == 1 && this->cols() == 1) );
169169

170170
return internal::evaluator<Derived>(derived()).coeff(row,col);
171171
}
172172

173-
EIGEN_DEVICE_FUNC Scalar coeff(Index i) const
173+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar coeff(Index i) const
174174
{
175175
EIGEN_STATIC_ASSERT(EnableCoeff, THIS_METHOD_IS_ONLY_FOR_INNER_OR_LAZY_PRODUCTS);
176176
eigen_assert( (Option==LazyProduct) || (this->rows() == 1 && this->cols() == 1) );

0 commit comments

Comments
 (0)