Skip to content

Commit 447dfb0

Browse files
committed
Synchronized with upstream 5.0.1 release (via git tag in 5.0 branch)
1 parent e937884 commit 447dfb0

30 files changed

Lines changed: 292 additions & 240 deletions

inst/include/Eigen/CholmodSupport

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#include "src/Core/util/DisableStupidWarnings.h"
1414

15-
#include <RcppEigenCholmod.h>
15+
#include <cholmod.h>
1616

1717
/** \ingroup Support_modules
1818
* \defgroup CholmodSupport_Module CholmodSupport module

inst/include/Eigen/Core

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@
106106
#include <thread>
107107
#endif
108108

109+
// for __cpp_lib feature test macros
110+
#if defined(__has_include) && __has_include(<version>)
111+
#include <version>
112+
#endif
113+
109114
// for std::bit_cast()
110115
#if defined(__cpp_lib_bit_cast) && __cpp_lib_bit_cast >= 201806L
111116
#include <bit>

inst/include/Eigen/Version

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
// As of Eigen3 5.0.0, we have moved to Semantic Versioning (semver.org).
77
#define EIGEN_MAJOR_VERSION 5
88
#define EIGEN_MINOR_VERSION 0
9-
#define EIGEN_PATCH_VERSION 0
9+
#define EIGEN_PATCH_VERSION 1
1010
#define EIGEN_PRERELEASE_VERSION ""
1111
#define EIGEN_BUILD_VERSION ""
12-
#define EIGEN_VERSION_STRING "5.0.0"
12+
#define EIGEN_VERSION_STRING "5.0.1"
1313

1414
#endif // EIGEN_VERSION_H

inst/include/Eigen/src/CholmodSupport/CholmodSupport.h

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
// IWYU pragma: private
1414
#include "./InternalHeaderCheck.h"
1515

16-
#ifndef R_MATRIX_CHOLMOD
17-
# define R_MATRIX_CHOLMOD(_NAME_) cholmod_ ## _NAME_
18-
#endif
19-
2016
namespace Eigen {
2117

2218
namespace internal {
@@ -88,8 +84,8 @@ cholmod_sparse viewAsCholmod(Ref<SparseMatrix<Scalar_, Options_, StorageIndex_>
8884

8985
if (internal::is_same<StorageIndex_, int>::value) {
9086
res.itype = CHOLMOD_INT;
91-
// } else if (internal::is_same<StorageIndex_, SuiteSparse_long>::value) {
92-
// res.itype = CHOLMOD_LONG;
87+
} else if (internal::is_same<StorageIndex_, SuiteSparse_long>::value) {
88+
res.itype = CHOLMOD_LONG;
9389
} else {
9490
eigen_assert(false && "Index type not supported yet");
9591
}
@@ -176,14 +172,22 @@ namespace internal {
176172
#define EIGEN_CHOLMOD_SPECIALIZE0(ret, name) \
177173
template <typename StorageIndex_> \
178174
inline ret cm_##name(cholmod_common& Common) { \
179-
return R_MATRIX_CHOLMOD(name)(&Common); \
180-
}
175+
return cholmod_##name(&Common); \
176+
} \
177+
template <> \
178+
inline ret cm_##name<SuiteSparse_long>(cholmod_common & Common) { \
179+
return cholmod_l_##name(&Common); \
180+
}
181181

182-
#define EIGEN_CHOLMOD_SPECIALIZE1(ret, name, t1, a1) \
183-
template <typename StorageIndex_> \
184-
inline ret cm_##name(t1& a1, cholmod_common& Common) { \
185-
return R_MATRIX_CHOLMOD(name) (&a1, &Common); \
186-
}
182+
#define EIGEN_CHOLMOD_SPECIALIZE1(ret, name, t1, a1) \
183+
template <typename StorageIndex_> \
184+
inline ret cm_##name(t1& a1, cholmod_common& Common) { \
185+
return cholmod_##name(&a1, &Common); \
186+
} \
187+
template <> \
188+
inline ret cm_##name<SuiteSparse_long>(t1 & a1, cholmod_common & Common) { \
189+
return cholmod_l_##name(&a1, &Common); \
190+
}
187191

188192
EIGEN_CHOLMOD_SPECIALIZE0(int, start)
189193
EIGEN_CHOLMOD_SPECIALIZE0(int, finish)
@@ -197,33 +201,33 @@ EIGEN_CHOLMOD_SPECIALIZE1(cholmod_sparse*, factor_to_sparse, cholmod_factor, L)
197201

198202
template <typename StorageIndex_>
199203
inline cholmod_dense* cm_solve(int sys, cholmod_factor& L, cholmod_dense& B, cholmod_common& Common) {
200-
return R_MATRIX_CHOLMOD(solve) (sys, &L, &B, &Common);
204+
return cholmod_solve(sys, &L, &B, &Common);
205+
}
206+
template <>
207+
inline cholmod_dense* cm_solve<SuiteSparse_long>(int sys, cholmod_factor& L, cholmod_dense& B, cholmod_common& Common) {
208+
return cholmod_l_solve(sys, &L, &B, &Common);
201209
}
202-
// template <>
203-
// inline cholmod_dense* cm_solve<SuiteSparse_long>(int sys, cholmod_factor& L, cholmod_dense& B, cholmod_common& Common) {
204-
// return cholmod_l_solve(sys, &L, &B, &Common);
205-
// }
206210

207211
template <typename StorageIndex_>
208212
inline cholmod_sparse* cm_spsolve(int sys, cholmod_factor& L, cholmod_sparse& B, cholmod_common& Common) {
209-
return R_MATRIX_CHOLMOD(spsolve) (sys, &L, &B, &Common);
213+
return cholmod_spsolve(sys, &L, &B, &Common);
214+
}
215+
template <>
216+
inline cholmod_sparse* cm_spsolve<SuiteSparse_long>(int sys, cholmod_factor& L, cholmod_sparse& B,
217+
cholmod_common& Common) {
218+
return cholmod_l_spsolve(sys, &L, &B, &Common);
210219
}
211-
// template <>
212-
// inline cholmod_sparse* cm_spsolve<SuiteSparse_long>(int sys, cholmod_factor& L, cholmod_sparse& B,
213-
// cholmod_common& Common) {
214-
// return cholmod_l_spsolve(sys, &L, &B, &Common);
215-
// }
216220

217221
template <typename StorageIndex_>
218222
inline int cm_factorize_p(cholmod_sparse* A, double beta[2], StorageIndex_* fset, std::size_t fsize, cholmod_factor* L,
219223
cholmod_common& Common) {
220-
return R_MATRIX_CHOLMOD(factorize_p) (A, beta, fset, fsize, L, &Common);
224+
return cholmod_factorize_p(A, beta, fset, fsize, L, &Common);
225+
}
226+
template <>
227+
inline int cm_factorize_p<SuiteSparse_long>(cholmod_sparse* A, double beta[2], SuiteSparse_long* fset,
228+
std::size_t fsize, cholmod_factor* L, cholmod_common& Common) {
229+
return cholmod_l_factorize_p(A, beta, fset, fsize, L, &Common);
221230
}
222-
// template <>
223-
// inline int cm_factorize_p<SuiteSparse_long>(cholmod_sparse* A, double beta[2], SuiteSparse_long* fset,
224-
// std::size_t fsize, cholmod_factor* L, cholmod_common& Common) {
225-
// return cholmod_l_factorize_p(A, beta, fset, fsize, L, &Common);
226-
// }
227231

228232
#undef EIGEN_CHOLMOD_SPECIALIZE0
229233
#undef EIGEN_CHOLMOD_SPECIALIZE1

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ class vml_assign_traits {
5656
: int(Dst::MaxRowsAtCompileTime),
5757
MaxSizeAtCompileTime = Dst::SizeAtCompileTime,
5858

59-
MightEnableVml = StorageOrdersAgree && DstHasDirectAccess && SrcHasDirectAccess &&
59+
MightEnableVml = bool(StorageOrdersAgree) && bool(DstHasDirectAccess) && bool(SrcHasDirectAccess) &&
6060
Src::InnerStrideAtCompileTime == 1 && Dst::InnerStrideAtCompileTime == 1,
61-
MightLinearize = MightEnableVml && (int(Dst::Flags) & int(Src::Flags) & LinearAccessBit),
62-
VmlSize = MightLinearize ? MaxSizeAtCompileTime : InnerMaxSize,
63-
LargeEnough = VmlSize == Dynamic || VmlSize >= EIGEN_MKL_VML_THRESHOLD
61+
MightLinearize = bool(MightEnableVml) && (int(Dst::Flags) & int(Src::Flags) & LinearAccessBit),
62+
VmlSize = bool(MightLinearize) ? MaxSizeAtCompileTime : InnerMaxSize,
63+
LargeEnough = (VmlSize == Dynamic) || VmlSize >= EIGEN_MKL_VML_THRESHOLD
6464
};
6565

6666
public:

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class CwiseNullaryOp : public internal::dense_xpr_base<CwiseNullaryOp<NullaryOp,
9494
* the returned matrix. Must be compatible with this MatrixBase type.
9595
*
9696
* This variant is meant to be used for dynamic-size matrix types. For fixed-size types,
97-
* it is redundant to pass \a rows and \a cols as arguments, so Zero() should be used
97+
* it is redundant to pass \a rows and \a cols as arguments, so NullaryExpr(const CustomNullaryOp&) should be used
9898
* instead.
9999
*
100100
* The template parameter \a CustomNullaryOp is the type of the functor.
@@ -121,7 +121,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
121121
* \only_for_vectors
122122
*
123123
* This variant is meant to be used for dynamic-size vector types. For fixed-size types,
124-
* it is redundant to pass \a size as argument, so Zero() should be used
124+
* it is redundant to pass \a size as argument, so NullaryExpr(const CustomNullaryOp&) should be used
125125
* instead.
126126
*
127127
* The template parameter \a CustomNullaryOp is the type of the functor.
@@ -174,7 +174,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
174174
* the returned matrix. Must be compatible with this DenseBase type.
175175
*
176176
* This variant is meant to be used for dynamic-size matrix types. For fixed-size types,
177-
* it is redundant to pass \a rows and \a cols as arguments, so Zero() should be used
177+
* it is redundant to pass \a rows and \a cols as arguments, so Constant(const Scalar&) should be used
178178
* instead.
179179
*
180180
* The template parameter \a CustomNullaryOp is the type of the functor.
@@ -195,7 +195,7 @@ DenseBase<Derived>::Constant(Index rows, Index cols, const Scalar& value) {
195195
* \only_for_vectors
196196
*
197197
* This variant is meant to be used for dynamic-size vector types. For fixed-size types,
198-
* it is redundant to pass \a size as argument, so Zero() should be used
198+
* it is redundant to pass \a size as argument, so Constant(const Scalar&) should be used
199199
* instead.
200200
*
201201
* The template parameter \a CustomNullaryOp is the type of the functor.

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,15 @@ struct plain_array {
6565

6666
template <typename T, int Size, int MatrixOrArrayOptions>
6767
struct plain_array<T, Size, MatrixOrArrayOptions, 0> {
68-
T array[Size];
68+
// on some 32-bit platforms, stack-allocated arrays are aligned to 4 bytes, not the preferred alignment of T
69+
EIGEN_ALIGN_TO_BOUNDARY(alignof(T)) T array[Size];
6970
#if defined(EIGEN_NO_DEBUG) || defined(EIGEN_TESTING_PLAINOBJECT_CTOR)
7071
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr plain_array() = default;
7172
#else
7273
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr plain_array() { EIGEN_MAKE_STACK_ALLOCATION_ASSERT(Size * sizeof(T)) }
7374
#endif
7475
};
7576

76-
template <typename T, int MatrixOrArrayOptions, int Alignment>
77-
struct plain_array<T, 0, MatrixOrArrayOptions, Alignment> {
78-
T array[1];
79-
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr plain_array() = default;
80-
};
81-
8277
template <typename T, int Size, int Options, int Alignment>
8378
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr void swap_plain_array(plain_array<T, Size, Options, Alignment>& a,
8479
plain_array<T, Size, Options, Alignment>& b,

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,15 @@ struct eigen_zero_impl<Xpr, /*use_memset*/ false> {
115115
template <typename Xpr>
116116
struct eigen_zero_impl<Xpr, /*use_memset*/ true> {
117117
using Scalar = typename Xpr::Scalar;
118-
static constexpr size_t max_bytes = (std::numeric_limits<std::ptrdiff_t>::max)();
119118
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Xpr& dst) {
120-
const size_t num_bytes = dst.size() * sizeof(Scalar);
121-
if (num_bytes == 0) return;
119+
const std::ptrdiff_t num_bytes = dst.size() * static_cast<std::ptrdiff_t>(sizeof(Scalar));
120+
if (num_bytes <= 0) return;
122121
void* dst_ptr = static_cast<void*>(dst.data());
123122
#ifndef EIGEN_NO_DEBUG
124-
if (num_bytes > max_bytes) throw_std_bad_alloc();
125123
eigen_assert((dst_ptr != nullptr) && "null pointer dereference error!");
126124
#endif
127125
EIGEN_USING_STD(memset);
128-
memset(dst_ptr, 0, num_bytes);
126+
memset(dst_ptr, 0, static_cast<std::size_t>(num_bytes));
129127
}
130128
template <typename SrcXpr>
131129
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Xpr& dst, const SrcXpr& src) {

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,14 @@ struct scalar_inner_product_op {
211211
static constexpr bool PacketAccess = false;
212212
};
213213

214+
// Partial specialization for packet access if and only if
215+
// LhsScalar == RhsScalar == ScalarBinaryOpTraits<LhsScalar, RhsScalar>::ReturnType.
214216
template <typename Scalar, bool Conj>
215-
struct scalar_inner_product_op<Scalar, Scalar, Conj> {
217+
struct scalar_inner_product_op<
218+
Scalar,
219+
typename std::enable_if<internal::is_same<typename ScalarBinaryOpTraits<Scalar, Scalar>::ReturnType, Scalar>::value,
220+
Scalar>::type,
221+
Conj> {
216222
using result_type = Scalar;
217223
using conj_helper = conditional_conj<Scalar, Conj>;
218224
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar coeff(const Scalar& a, const Scalar& b) const {

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,8 +1004,7 @@ struct madd_impl {
10041004
}
10051005
};
10061006

1007-
// Use FMA if there is a single CPU instruction.
1008-
#ifdef EIGEN_VECTORIZE_FMA
1007+
#if EIGEN_SCALAR_MADD_USE_FMA
10091008
template <typename Scalar>
10101009
struct madd_impl<Scalar, std::enable_if_t<has_fma<Scalar>::value>> {
10111010
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run(const Scalar& x, const Scalar& y, const Scalar& z) {
@@ -1927,7 +1926,6 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar arithmetic_shift_right(const Scalar
19271926
return bit_cast<Scalar, SignedScalar>(bit_cast<SignedScalar, Scalar>(a) >> n);
19281927
}
19291928

1930-
// Otherwise, rely on template implementation.
19311929
template <typename Scalar>
19321930
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar fma(const Scalar& x, const Scalar& y, const Scalar& z) {
19331931
return internal::fma_impl<Scalar>::run(x, y, z);

0 commit comments

Comments
 (0)