Skip to content

Commit 3683c5e

Browse files
committed
Eigen 3.3.9 released yesterday
1 parent 09e8a6d commit 3683c5e

File tree

86 files changed

+1243
-918
lines changed

Some content is hidden

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

86 files changed

+1243
-918
lines changed

inst/include/Eigen/CholmodSupport

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "src/Core/util/DisableStupidWarnings.h"
1414

1515
extern "C" {
16-
#include <RcppEigenCholmod.h>
16+
#include <cholmod.h>
1717
}
1818

1919
/** \ingroup Support_modules
@@ -45,3 +45,4 @@ extern "C" {
4545
#include "src/Core/util/ReenableStupidWarnings.h"
4646

4747
#endif // EIGEN_CHOLMODSUPPORT_MODULE_H
48+

inst/include/Eigen/Core

+6-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,10 @@
279279
#include <cmath>
280280
#include <cassert>
281281
#include <functional>
282-
#include <iosfwd>
282+
#include <sstream>
283+
#ifndef EIGEN_NO_IO
284+
#include <iosfwd>
285+
#endif
283286
#include <cstring>
284287
#include <string>
285288
#include <limits>
@@ -375,7 +378,9 @@ using std::ptrdiff_t;
375378

376379
#if defined EIGEN_VECTORIZE_AVX512
377380
#include "src/Core/arch/SSE/PacketMath.h"
381+
#include "src/Core/arch/SSE/MathFunctions.h"
378382
#include "src/Core/arch/AVX/PacketMath.h"
383+
#include "src/Core/arch/AVX/MathFunctions.h"
379384
#include "src/Core/arch/AVX512/PacketMath.h"
380385
#include "src/Core/arch/AVX512/MathFunctions.h"
381386
#elif defined EIGEN_VECTORIZE_AVX

inst/include/Eigen/Eigenvalues

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111
#include "Core"
1212

13-
#include "src/Core/util/DisableStupidWarnings.h"
14-
1513
#include "Cholesky"
1614
#include "Jacobi"
1715
#include "Householder"
1816
#include "LU"
1917
#include "Geometry"
2018

19+
#include "src/Core/util/DisableStupidWarnings.h"
20+
2121
/** \defgroup Eigenvalues_Module Eigenvalues module
2222
*
2323
*

inst/include/Eigen/Geometry

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111
#include "Core"
1212

13-
#include "src/Core/util/DisableStupidWarnings.h"
14-
1513
#include "SVD"
1614
#include "LU"
1715
#include <limits>
1816

17+
#include "src/Core/util/DisableStupidWarnings.h"
18+
1919
/** \defgroup Geometry_Module Geometry module
2020
*
2121
* This module provides support for:

inst/include/Eigen/QR

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111
#include "Core"
1212

13-
#include "src/Core/util/DisableStupidWarnings.h"
14-
1513
#include "Cholesky"
1614
#include "Jacobi"
1715
#include "Householder"
1816

17+
#include "src/Core/util/DisableStupidWarnings.h"
18+
1919
/** \defgroup QR_Module QR module
2020
*
2121
*

inst/include/Eigen/SparseQR

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
*
2929
*/
3030

31-
#include "OrderingMethods"
3231
#include "src/SparseCore/SparseColEtree.h"
3332
#include "src/SparseQR/SparseQR.h"
3433

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ template<typename Derived> class ArrayBase
153153
// inline void evalTo(Dest& dst) const { dst = matrix(); }
154154

155155
protected:
156-
EIGEN_DEVICE_FUNC
157-
ArrayBase() : Base() {}
156+
EIGEN_DEFAULT_COPY_CONSTRUCTOR(ArrayBase)
157+
EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(ArrayBase)
158158

159159
private:
160160
explicit ArrayBase(Index);

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

+2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ class CwiseUnaryViewImpl<ViewOp,MatrixType,Dense>
121121
{
122122
return derived().nestedExpression().outerStride() * sizeof(typename internal::traits<MatrixType>::Scalar) / sizeof(Scalar);
123123
}
124+
protected:
125+
EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(CwiseUnaryViewImpl)
124126
};
125127

126128
} // end namespace Eigen

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static inline void check_DenseIndex_is_signed() {
4040
*/
4141
template<typename Derived> class DenseBase
4242
#ifndef EIGEN_PARSED_BY_DOXYGEN
43-
: public DenseCoeffsBase<Derived>
43+
: public DenseCoeffsBase<Derived, internal::accessors_level<Derived>::value>
4444
#else
4545
: public DenseCoeffsBase<Derived,DirectWriteAccessors>
4646
#endif // not EIGEN_PARSED_BY_DOXYGEN
@@ -71,7 +71,7 @@ template<typename Derived> class DenseBase
7171
typedef Scalar value_type;
7272

7373
typedef typename NumTraits<Scalar>::Real RealScalar;
74-
typedef DenseCoeffsBase<Derived> Base;
74+
typedef DenseCoeffsBase<Derived, internal::accessors_level<Derived>::value> Base;
7575

7676
using Base::derived;
7777
using Base::const_cast_derived;
@@ -587,11 +587,12 @@ template<typename Derived> class DenseBase
587587
}
588588

589589
protected:
590+
EIGEN_DEFAULT_COPY_CONSTRUCTOR(DenseBase)
590591
/** Default constructor. Do nothing. */
591592
EIGEN_DEVICE_FUNC DenseBase()
592593
{
593594
/* Just checks for self-consistency of the flags.
594-
* Only do it when debugging Eigen, as this borders on paranoiac and could slow compilation down
595+
* Only do it when debugging Eigen, as this borders on paranoia and could slow compilation down
595596
*/
596597
#ifdef EIGEN_INTERNAL_DEBUGGING
597598
EIGEN_STATIC_ASSERT((EIGEN_IMPLIES(MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1, int(IsRowMajor))

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ template<typename T, int _Options> class DenseStorage<T, Dynamic, Dynamic, Dynam
404404
if(size != m_rows*m_cols)
405405
{
406406
internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, m_rows*m_cols);
407-
if (size)
407+
if (size>0) // >0 and not simply !=0 to let the compiler knows that size cannot be negative
408408
m_data = internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size);
409409
else
410410
m_data = 0;
@@ -479,7 +479,7 @@ template<typename T, int _Rows, int _Options> class DenseStorage<T, Dynamic, _Ro
479479
if(size != _Rows*m_cols)
480480
{
481481
internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Rows*m_cols);
482-
if (size)
482+
if (size>0) // >0 and not simply !=0 to let the compiler knows that size cannot be negative
483483
m_data = internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size);
484484
else
485485
m_data = 0;
@@ -553,7 +553,7 @@ template<typename T, int _Cols, int _Options> class DenseStorage<T, Dynamic, Dyn
553553
if(size != m_rows*_Cols)
554554
{
555555
internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Cols*m_rows);
556-
if (size)
556+
if (size>0) // >0 and not simply !=0 to let the compiler knows that size cannot be negative
557557
m_data = internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size);
558558
else
559559
m_data = 0;

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

+3-6
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,7 @@ template<typename Packet> EIGEN_DEVICE_FUNC inline Packet preverse(const Packet&
351351
/** \internal \returns \a a with real and imaginary part flipped (for complex type only) */
352352
template<typename Packet> EIGEN_DEVICE_FUNC inline Packet pcplxflip(const Packet& a)
353353
{
354-
// FIXME: uncomment the following in case we drop the internal imag and real functions.
355-
// using std::imag;
356-
// using std::real;
357-
return Packet(imag(a),real(a));
354+
return Packet(a.imag(),a.real());
358355
}
359356

360357
/**************************
@@ -524,10 +521,10 @@ inline void palign(PacketType& first, const PacketType& second)
524521
#ifndef __CUDACC__
525522

526523
template<> inline std::complex<float> pmul(const std::complex<float>& a, const std::complex<float>& b)
527-
{ return std::complex<float>(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); }
524+
{ return std::complex<float>(a.real()*b.real() - a.imag()*b.imag(), a.imag()*b.real() + a.real()*b.imag()); }
528525

529526
template<> inline std::complex<double> pmul(const std::complex<double>& a, const std::complex<double>& b)
530-
{ return std::complex<double>(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); }
527+
{ return std::complex<double>(a.real()*b.real() - a.imag()*b.imag(), a.imag()*b.real() + a.real()*b.imag()); }
531528

532529
#endif
533530

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

+5
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ template<typename Derived> class MapBase<Derived, ReadOnlyAccessors>
182182
#endif
183183

184184
protected:
185+
EIGEN_DEFAULT_COPY_CONSTRUCTOR(MapBase)
186+
EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(MapBase)
185187

186188
template<typename T>
187189
EIGEN_DEVICE_FUNC
@@ -294,6 +296,9 @@ template<typename Derived> class MapBase<Derived, WriteAccessors>
294296
// In theory we could simply refer to Base:Base::operator=, but MSVC does not like Base::Base,
295297
// see bugs 821 and 920.
296298
using ReadOnlyMapBase::Base::operator=;
299+
protected:
300+
EIGEN_DEFAULT_COPY_CONSTRUCTOR(MapBase)
301+
EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(MapBase)
297302
};
298303

299304
#undef EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS

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

+11-5
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ struct abs2_impl_default<Scalar, true> // IsComplex
287287
EIGEN_DEVICE_FUNC
288288
static inline RealScalar run(const Scalar& x)
289289
{
290-
return real(x)*real(x) + imag(x)*imag(x);
290+
return x.real()*x.real() + x.imag()*x.imag();
291291
}
292292
};
293293

@@ -313,14 +313,17 @@ struct abs2_retval
313313
****************************************************************************/
314314

315315
template<typename Scalar, bool IsComplex>
316-
struct norm1_default_impl
316+
struct norm1_default_impl;
317+
318+
template<typename Scalar>
319+
struct norm1_default_impl<Scalar,true>
317320
{
318321
typedef typename NumTraits<Scalar>::Real RealScalar;
319322
EIGEN_DEVICE_FUNC
320323
static inline RealScalar run(const Scalar& x)
321324
{
322325
EIGEN_USING_STD_MATH(abs);
323-
return abs(real(x)) + abs(imag(x));
326+
return abs(x.real()) + abs(x.imag());
324327
}
325328
};
326329

@@ -662,8 +665,8 @@ struct random_default_impl<Scalar, true, false>
662665
{
663666
static inline Scalar run(const Scalar& x, const Scalar& y)
664667
{
665-
return Scalar(random(real(x), real(y)),
666-
random(imag(x), imag(y)));
668+
return Scalar(random(x.real(), y.real()),
669+
random(x.imag(), y.imag()));
667670
}
668671
static inline Scalar run()
669672
{
@@ -916,6 +919,9 @@ inline EIGEN_MATHFUNC_RETVAL(abs2, Scalar) abs2(const Scalar& x)
916919
return EIGEN_MATHFUNC_IMPL(abs2, Scalar)::run(x);
917920
}
918921

922+
EIGEN_DEVICE_FUNC
923+
inline bool abs2(bool x) { return x; }
924+
919925
template<typename Scalar>
920926
EIGEN_DEVICE_FUNC
921927
inline EIGEN_MATHFUNC_RETVAL(norm1, Scalar) norm1(const Scalar& x)

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,8 @@ template<typename Derived> class MatrixBase
464464
EIGEN_MATRIX_FUNCTION_1(MatrixComplexPowerReturnValue, pow, power to \c p, const std::complex<RealScalar>& p)
465465

466466
protected:
467-
EIGEN_DEVICE_FUNC MatrixBase() : Base() {}
467+
EIGEN_DEFAULT_COPY_CONSTRUCTOR(MatrixBase)
468+
EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(MatrixBase)
468469

469470
private:
470471
EIGEN_DEVICE_FUNC explicit MatrixBase(int);

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

-28
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,6 @@ class PermutationBase : public EigenBase<Derived>
8787
return derived();
8888
}
8989

90-
#ifndef EIGEN_PARSED_BY_DOXYGEN
91-
/** This is a special case of the templated operator=. Its purpose is to
92-
* prevent a default operator= from hiding the templated operator=.
93-
*/
94-
Derived& operator=(const PermutationBase& other)
95-
{
96-
indices() = other.indices();
97-
return derived();
98-
}
99-
#endif
100-
10190
/** \returns the number of rows */
10291
inline Index rows() const { return Index(indices().size()); }
10392

@@ -333,12 +322,6 @@ class PermutationMatrix : public PermutationBase<PermutationMatrix<SizeAtCompile
333322
inline PermutationMatrix(const PermutationBase<OtherDerived>& other)
334323
: m_indices(other.indices()) {}
335324

336-
#ifndef EIGEN_PARSED_BY_DOXYGEN
337-
/** Standard copy constructor. Defined only to prevent a default copy constructor
338-
* from hiding the other templated constructor */
339-
inline PermutationMatrix(const PermutationMatrix& other) : m_indices(other.indices()) {}
340-
#endif
341-
342325
/** Generic constructor from expression of the indices. The indices
343326
* array has the meaning that the permutations sends each integer i to indices[i].
344327
*
@@ -373,17 +356,6 @@ class PermutationMatrix : public PermutationBase<PermutationMatrix<SizeAtCompile
373356
return Base::operator=(tr.derived());
374357
}
375358

376-
#ifndef EIGEN_PARSED_BY_DOXYGEN
377-
/** This is a special case of the templated operator=. Its purpose is to
378-
* prevent a default operator= from hiding the templated operator=.
379-
*/
380-
PermutationMatrix& operator=(const PermutationMatrix& other)
381-
{
382-
m_indices = other.m_indices;
383-
return *this;
384-
}
385-
#endif
386-
387359
/** const version of indices(). */
388360
const IndicesType& indices() const { return m_indices; }
389361
/** \returns a reference to the stored array representing the permutation. */

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

+7-5
Original file line numberDiff line numberDiff line change
@@ -737,8 +737,10 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
737737
EIGEN_DEVICE_FUNC
738738
EIGEN_STRONG_INLINE void _init2(Index rows, Index cols, typename internal::enable_if<Base::SizeAtCompileTime!=2,T0>::type* = 0)
739739
{
740-
EIGEN_STATIC_ASSERT(bool(NumTraits<T0>::IsInteger) &&
741-
bool(NumTraits<T1>::IsInteger),
740+
const bool t0_is_integer_alike = internal::is_valid_index_type<T0>::value;
741+
const bool t1_is_integer_alike = internal::is_valid_index_type<T1>::value;
742+
EIGEN_STATIC_ASSERT(t0_is_integer_alike &&
743+
t1_is_integer_alike,
742744
FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED)
743745
resize(rows,cols);
744746
}
@@ -773,9 +775,9 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
773775
&& ((!internal::is_same<typename internal::traits<Derived>::XprKind,ArrayXpr>::value || Base::SizeAtCompileTime==Dynamic)),T>::type* = 0)
774776
{
775777
// NOTE MSVC 2008 complains if we directly put bool(NumTraits<T>::IsInteger) as the EIGEN_STATIC_ASSERT argument.
776-
const bool is_integer = NumTraits<T>::IsInteger;
777-
EIGEN_UNUSED_VARIABLE(is_integer);
778-
EIGEN_STATIC_ASSERT(is_integer,
778+
const bool is_integer_alike = internal::is_valid_index_type<T>::value;
779+
EIGEN_UNUSED_VARIABLE(is_integer_alike);
780+
EIGEN_STATIC_ASSERT(is_integer_alike,
779781
FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED)
780782
resize(size);
781783
}

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

+27-1
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ struct generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,CoeffBasedProductMode>
396396
// but easier on the compiler side
397397
call_assignment_no_alias(dst, lhs.lazyProduct(rhs), internal::assign_op<typename Dst::Scalar,Scalar>());
398398
}
399-
399+
400400
template<typename Dst>
401401
static EIGEN_STRONG_INLINE void addTo(Dst& dst, const Lhs& lhs, const Rhs& rhs)
402402
{
@@ -410,6 +410,32 @@ struct generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,CoeffBasedProductMode>
410410
// dst.noalias() -= lhs.lazyProduct(rhs);
411411
call_assignment_no_alias(dst, lhs.lazyProduct(rhs), internal::sub_assign_op<typename Dst::Scalar,Scalar>());
412412
}
413+
414+
// Catch "dst {,+,-}= (s*A)*B" and evaluate it lazily by moving out the scalar factor:
415+
// dst {,+,-}= s * (A.lazyProduct(B))
416+
// This is a huge benefit for heap-allocated matrix types as it save one costly allocation.
417+
// For them, this strategy is also faster than simply by-passing the heap allocation through
418+
// stack allocation.
419+
// For fixed sizes matrices, this is less obvious, it is sometimes x2 faster, but sometimes x3 slower,
420+
// and the behavior depends also a lot on the compiler... so let's be conservative and enable them for dynamic-size only,
421+
// that is when coming from generic_product_impl<...,GemmProduct> in file GeneralMatrixMatrix.h
422+
template<typename Dst, typename Scalar1, typename Scalar2, typename Plain1, typename Xpr2, typename Func>
423+
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
424+
void eval_dynamic(Dst& dst, const CwiseBinaryOp<internal::scalar_product_op<Scalar1,Scalar2>,
425+
const CwiseNullaryOp<internal::scalar_constant_op<Scalar1>, Plain1>, Xpr2>& lhs, const Rhs& rhs, const Func &func)
426+
{
427+
call_assignment_no_alias(dst, lhs.lhs().functor().m_other * lhs.rhs().lazyProduct(rhs), func);
428+
}
429+
430+
// Here, we we always have LhsT==Lhs, but we need to make it a template type to make the above
431+
// overload more specialized.
432+
template<typename Dst, typename LhsT, typename Func>
433+
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
434+
void eval_dynamic(Dst& dst, const LhsT& lhs, const Rhs& rhs, const Func &func)
435+
{
436+
call_assignment_no_alias(dst, lhs.lazyProduct(rhs), func);
437+
}
438+
413439

414440
// template<typename Dst>
415441
// static inline void scaleAndAddTo(Dst& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha)

0 commit comments

Comments
 (0)