Skip to content

Commit 7d3183d

Browse files
authored
Merge pull request #82 from RcppCore/feature/eigen-3.3.7
Eigen 3.3.7 (closes #80)
2 parents 3f822bb + a822bb3 commit 7d3183d

Some content is hidden

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

63 files changed

+733
-493
lines changed

inst/include/Eigen/CholmodSupport

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,3 @@ extern "C" {
4545
#include "src/Core/util/ReenableStupidWarnings.h"
4646

4747
#endif // EIGEN_CHOLMODSUPPORT_MODULE_H
48-

inst/include/Eigen/Core

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
#endif
5454

5555
#define EIGEN_DEVICE_FUNC __host__ __device__
56-
// We need math_functions.hpp to ensure that that EIGEN_USING_STD_MATH macro
56+
// We need cuda_runtime.h to ensure that that EIGEN_USING_STD_MATH macro
5757
// works properly on the device side
58-
#include <math_functions.hpp>
58+
#include <cuda_runtime.h>
5959
#else
6060
#define EIGEN_DEVICE_FUNC
6161
#endif

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ template<> struct ldlt_inplace<Lower>
305305
if (size <= 1)
306306
{
307307
transpositions.setIdentity();
308-
if (numext::real(mat.coeff(0,0)) > static_cast<RealScalar>(0) ) sign = PositiveSemiDef;
308+
if(size==0) sign = ZeroSign;
309+
else if (numext::real(mat.coeff(0,0)) > static_cast<RealScalar>(0) ) sign = PositiveSemiDef;
309310
else if (numext::real(mat.coeff(0,0)) < static_cast<RealScalar>(0)) sign = NegativeSemiDef;
310311
else sign = ZeroSign;
311312
return true;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ class Array
153153
: Base(std::move(other))
154154
{
155155
Base::_check_template_params();
156-
if (RowsAtCompileTime!=Dynamic && ColsAtCompileTime!=Dynamic)
157-
Base::_set_noalias(other);
158156
}
159157
EIGEN_DEVICE_FUNC
160158
Array& operator=(Array&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_assignable<Scalar>::value)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ rcond_estimate_helper(typename Decomposition::RealScalar matrix_norm, const Deco
160160
{
161161
typedef typename Decomposition::RealScalar RealScalar;
162162
eigen_assert(dec.rows() == dec.cols());
163-
if (dec.rows() == 0) return RealScalar(1);
163+
if (dec.rows() == 0) return NumTraits<RealScalar>::infinity();
164164
if (matrix_norm == RealScalar(0)) return RealScalar(0);
165165
if (dec.rows() == 1) return RealScalar(1);
166166
const RealScalar inverse_matrix_norm = rcond_invmatrix_L1_norm_estimate(dec);

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ template<typename Derived> class MapBase<Derived, ReadOnlyAccessors>
4343
enum {
4444
RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
4545
ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
46+
InnerStrideAtCompileTime = internal::traits<Derived>::InnerStrideAtCompileTime,
4647
SizeAtCompileTime = Base::SizeAtCompileTime
4748
};
4849

@@ -187,8 +188,11 @@ template<typename Derived> class MapBase<Derived, ReadOnlyAccessors>
187188
void checkSanity(typename internal::enable_if<(internal::traits<T>::Alignment>0),void*>::type = 0) const
188189
{
189190
#if EIGEN_MAX_ALIGN_BYTES>0
191+
// innerStride() is not set yet when this function is called, so we optimistically assume the lowest plausible value:
192+
const Index minInnerStride = InnerStrideAtCompileTime == Dynamic ? 1 : Index(InnerStrideAtCompileTime);
193+
EIGEN_ONLY_USED_FOR_DEBUG(minInnerStride);
190194
eigen_assert(( ((internal::UIntPtr(m_data) % internal::traits<Derived>::Alignment) == 0)
191-
|| (cols() * rows() * innerStride() * sizeof(Scalar)) < internal::traits<Derived>::Alignment ) && "data is not aligned");
195+
|| (cols() * rows() * minInnerStride * sizeof(Scalar)) < internal::traits<Derived>::Alignment ) && "data is not aligned");
192196
#endif
193197
}
194198

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

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -616,21 +616,28 @@ template<typename Scalar>
616616
struct random_default_impl<Scalar, false, true>
617617
{
618618
static inline Scalar run(const Scalar& x, const Scalar& y)
619-
{
620-
typedef typename conditional<NumTraits<Scalar>::IsSigned,std::ptrdiff_t,std::size_t>::type ScalarX;
621-
if(y<x)
619+
{
620+
if (y <= x)
622621
return x;
623-
// the following difference might overflow on a 32 bits system,
624-
// but since y>=x the result converted to an unsigned long is still correct.
625-
std::size_t range = ScalarX(y)-ScalarX(x);
626-
std::size_t offset = 0;
627-
// rejection sampling
628-
std::size_t divisor = 1;
629-
std::size_t multiplier = 1;
630-
if(range<RAND_MAX) divisor = (std::size_t(RAND_MAX)+1)/(range+1);
631-
else multiplier = 1 + range/(std::size_t(RAND_MAX)+1);
622+
// ScalarU is the unsigned counterpart of Scalar, possibly Scalar itself.
623+
typedef typename make_unsigned<Scalar>::type ScalarU;
624+
// ScalarX is the widest of ScalarU and unsigned int.
625+
// We'll deal only with ScalarX and unsigned int below thus avoiding signed
626+
// types and arithmetic and signed overflows (which are undefined behavior).
627+
typedef typename conditional<(ScalarU(-1) > unsigned(-1)), ScalarU, unsigned>::type ScalarX;
628+
// The following difference doesn't overflow, provided our integer types are two's
629+
// complement and have the same number of padding bits in signed and unsigned variants.
630+
// This is the case in most modern implementations of C++.
631+
ScalarX range = ScalarX(y) - ScalarX(x);
632+
ScalarX offset = 0;
633+
ScalarX divisor = 1;
634+
ScalarX multiplier = 1;
635+
const unsigned rand_max = RAND_MAX;
636+
if (range <= rand_max) divisor = (rand_max + 1) / (range + 1);
637+
else multiplier = 1 + range / (rand_max + 1);
638+
// Rejection sampling.
632639
do {
633-
offset = (std::size_t(std::rand()) * multiplier) / divisor;
640+
offset = (unsigned(std::rand()) * multiplier) / divisor;
634641
} while (offset > range);
635642
return Scalar(ScalarX(x) + offset);
636643
}
@@ -1006,7 +1013,8 @@ inline int log2(int x)
10061013

10071014
/** \returns the square root of \a x.
10081015
*
1009-
* It is essentially equivalent to \code using std::sqrt; return sqrt(x); \endcode,
1016+
* It is essentially equivalent to
1017+
* \code using std::sqrt; return sqrt(x); \endcode
10101018
* but slightly faster for float/double and some compilers (e.g., gcc), thanks to
10111019
* specializations when SSE is enabled.
10121020
*

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,6 @@ class Matrix
274274
: Base(std::move(other))
275275
{
276276
Base::_check_template_params();
277-
if (RowsAtCompileTime!=Dynamic && ColsAtCompileTime!=Dynamic)
278-
Base::_set_noalias(other);
279277
}
280278
EIGEN_DEVICE_FUNC
281279
Matrix& operator=(Matrix&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_assignable<Scalar>::value)

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

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -444,16 +444,24 @@ template<typename Derived> class MatrixBase
444444
///////// MatrixFunctions module /////////
445445

446446
typedef typename internal::stem_function<Scalar>::type StemFunction;
447-
const MatrixExponentialReturnValue<Derived> exp() const;
447+
#define EIGEN_MATRIX_FUNCTION(ReturnType, Name, Description) \
448+
/** \returns an expression of the matrix Description of \c *this. \brief This function requires the <a href="unsupported/group__MatrixFunctions__Module.html"> unsupported MatrixFunctions module</a>. To compute the coefficient-wise Description use ArrayBase::##Name . */ \
449+
const ReturnType<Derived> Name() const;
450+
#define EIGEN_MATRIX_FUNCTION_1(ReturnType, Name, Description, Argument) \
451+
/** \returns an expression of the matrix Description of \c *this. \brief This function requires the <a href="unsupported/group__MatrixFunctions__Module.html"> unsupported MatrixFunctions module</a>. To compute the coefficient-wise Description use ArrayBase::##Name . */ \
452+
const ReturnType<Derived> Name(Argument) const;
453+
454+
EIGEN_MATRIX_FUNCTION(MatrixExponentialReturnValue, exp, exponential)
455+
/** \brief Helper function for the <a href="unsupported/group__MatrixFunctions__Module.html"> unsupported MatrixFunctions module</a>.*/
448456
const MatrixFunctionReturnValue<Derived> matrixFunction(StemFunction f) const;
449-
const MatrixFunctionReturnValue<Derived> cosh() const;
450-
const MatrixFunctionReturnValue<Derived> sinh() const;
451-
const MatrixFunctionReturnValue<Derived> cos() const;
452-
const MatrixFunctionReturnValue<Derived> sin() const;
453-
const MatrixSquareRootReturnValue<Derived> sqrt() const;
454-
const MatrixLogarithmReturnValue<Derived> log() const;
455-
const MatrixPowerReturnValue<Derived> pow(const RealScalar& p) const;
456-
const MatrixComplexPowerReturnValue<Derived> pow(const std::complex<RealScalar>& p) const;
457+
EIGEN_MATRIX_FUNCTION(MatrixFunctionReturnValue, cosh, hyperbolic cosine)
458+
EIGEN_MATRIX_FUNCTION(MatrixFunctionReturnValue, sinh, hyperbolic sine)
459+
EIGEN_MATRIX_FUNCTION(MatrixFunctionReturnValue, cos, cosine)
460+
EIGEN_MATRIX_FUNCTION(MatrixFunctionReturnValue, sin, sine)
461+
EIGEN_MATRIX_FUNCTION(MatrixSquareRootReturnValue, sqrt, square root)
462+
EIGEN_MATRIX_FUNCTION(MatrixLogarithmReturnValue, log, logarithm)
463+
EIGEN_MATRIX_FUNCTION_1(MatrixPowerReturnValue, pow, power to \c p, const RealScalar& p)
464+
EIGEN_MATRIX_FUNCTION_1(MatrixComplexPowerReturnValue, pow, power to \c p, const std::complex<RealScalar>& p)
457465

458466
protected:
459467
EIGEN_DEVICE_FUNC MatrixBase() : Base() {}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ void TriangularViewImpl<MatrixType,Mode,Dense>::solveInPlace(const MatrixBase<Ot
169169
OtherDerived& other = _other.const_cast_derived();
170170
eigen_assert( derived().cols() == derived().rows() && ((Side==OnTheLeft && derived().cols() == other.rows()) || (Side==OnTheRight && derived().cols() == other.cols())) );
171171
eigen_assert((!(Mode & ZeroDiag)) && bool(Mode & (Upper|Lower)));
172+
// If solving for a 0x0 matrix, nothing to do, simply return.
173+
if (derived().cols() == 0)
174+
return;
172175

173176
enum { copy = (internal::traits<OtherDerived>::Flags & RowMajorBit) && OtherDerived::IsVectorAtCompileTime && OtherDerived::SizeAtCompileTime!=1};
174177
typedef typename internal::conditional<copy,

0 commit comments

Comments
 (0)