From 050bcf61261d5b3bcc86b2c5afc7e35d3fd16ff7 Mon Sep 17 00:00:00 2001 From: Alexey Frunze Date: Wed, 8 Aug 2018 20:19:32 -0700 Subject: [PATCH 01/21] bug #1584: Improve random (avoid undefined behavior). --- Eigen/src/Core/MathFunctions.h | 31 +++++++++++++++++++------------ Eigen/src/Core/util/Meta.h | 21 +++++++++++++++++++++ 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index f16476a92..58cf7021a 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -684,20 +684,27 @@ struct random_default_impl { static inline Scalar run(const Scalar& x, const Scalar& y) { - typedef typename conditional::IsSigned,std::ptrdiff_t,std::size_t>::type ScalarX; - if(y=x the result converted to an unsigned long is still correct. - std::size_t range = ScalarX(y)-ScalarX(x); - std::size_t offset = 0; - // rejection sampling - std::size_t divisor = 1; - std::size_t multiplier = 1; - if(range::type ScalarU; + // ScalarX is the widest of ScalarU and unsigned int. + // We'll deal only with ScalarX and unsigned int below thus avoiding signed + // types and arithmetic and signed overflows (which are undefined behavior). + typedef typename conditional<(ScalarU(-1) > unsigned(-1)), ScalarU, unsigned>::type ScalarX; + // The following difference doesn't overflow, provided our integer types are two's + // complement and have the same number of padding bits in signed and unsigned variants. + // This is the case in most modern implementations of C++. + ScalarX range = ScalarX(y) - ScalarX(x); + ScalarX offset = 0; + ScalarX divisor = 1; + ScalarX multiplier = 1; + const unsigned rand_max = RAND_MAX; + if (range <= rand_max) divisor = (rand_max + 1) / (range + 1); + else multiplier = 1 + range / (rand_max + 1); + // Rejection sampling. do { - offset = (std::size_t(std::rand()) * multiplier) / divisor; + offset = (unsigned(std::rand()) * multiplier) / divisor; } while (offset > range); return Scalar(ScalarX(x) + offset); } diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index f27b8e85d..1e4f95581 100755 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -128,6 +128,27 @@ template<> struct is_integral { enum { value = true }; } #endif #endif +#if EIGEN_HAS_CXX11 +using std::make_unsigned; +#else +// TODO: Possibly improve this implementation of make_unsigned. +// It is currently used only by +// template struct random_default_impl. +template struct make_unsigned; +template<> struct make_unsigned { typedef unsigned char type; }; +template<> struct make_unsigned { typedef unsigned char type; }; +template<> struct make_unsigned { typedef unsigned char type; }; +template<> struct make_unsigned { typedef unsigned short type; }; +template<> struct make_unsigned { typedef unsigned short type; }; +template<> struct make_unsigned { typedef unsigned int type; }; +template<> struct make_unsigned { typedef unsigned int type; }; +template<> struct make_unsigned { typedef unsigned long type; }; +template<> struct make_unsigned { typedef unsigned long type; }; +#if EIGEN_COMP_MSVC +template<> struct make_unsigned { typedef unsigned __int64 type; }; +template<> struct make_unsigned { typedef unsigned __int64 type; }; +#endif +#endif template struct add_const { typedef const T type; }; template struct add_const { typedef T& type; }; From 42f3ee4fb878b3e16a8cbc99ec90ed330f59899c Mon Sep 17 00:00:00 2001 From: Christoph Hertzberg Date: Tue, 28 Aug 2018 11:44:15 +0200 Subject: [PATCH 02/21] Old gcc versions have problems with recursive #pragma GCC diagnostic push/pop Workaround: Don't include "DisableStupidWarnings.h" before including other main-headers --- Eigen/Eigenvalues | 4 ++-- Eigen/Geometry | 4 ++-- Eigen/QR | 4 ++-- Eigen/SparseQR | 1 - unsupported/Eigen/ArpackSupport | 4 ++-- unsupported/Eigen/Polynomials | 4 ++-- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Eigen/Eigenvalues b/Eigen/Eigenvalues index f3f661b07..7d6ac787b 100644 --- a/Eigen/Eigenvalues +++ b/Eigen/Eigenvalues @@ -10,14 +10,14 @@ #include "Core" -#include "src/Core/util/DisableStupidWarnings.h" - #include "Cholesky" #include "Jacobi" #include "Householder" #include "LU" #include "Geometry" +#include "src/Core/util/DisableStupidWarnings.h" + /** \defgroup Eigenvalues_Module Eigenvalues module * * diff --git a/Eigen/Geometry b/Eigen/Geometry index 131a4edfc..04aa316cb 100644 --- a/Eigen/Geometry +++ b/Eigen/Geometry @@ -10,12 +10,12 @@ #include "Core" -#include "src/Core/util/DisableStupidWarnings.h" - #include "SVD" #include "LU" #include +#include "src/Core/util/DisableStupidWarnings.h" + /** \defgroup Geometry_Module Geometry module * * This module provides support for: diff --git a/Eigen/QR b/Eigen/QR index c7e914469..1be1863a1 100644 --- a/Eigen/QR +++ b/Eigen/QR @@ -10,12 +10,12 @@ #include "Core" -#include "src/Core/util/DisableStupidWarnings.h" - #include "Cholesky" #include "Jacobi" #include "Householder" +#include "src/Core/util/DisableStupidWarnings.h" + /** \defgroup QR_Module QR module * * diff --git a/Eigen/SparseQR b/Eigen/SparseQR index a6f3b7f7d..f5fc5fa7f 100644 --- a/Eigen/SparseQR +++ b/Eigen/SparseQR @@ -28,7 +28,6 @@ * */ -#include "OrderingMethods" #include "src/SparseCore/SparseColEtree.h" #include "src/SparseQR/SparseQR.h" diff --git a/unsupported/Eigen/ArpackSupport b/unsupported/Eigen/ArpackSupport index 37a2799ef..a0d4820e1 100644 --- a/unsupported/Eigen/ArpackSupport +++ b/unsupported/Eigen/ArpackSupport @@ -11,8 +11,6 @@ #include -#include - /** \defgroup ArpackSupport_Module Arpack support module * * This module provides a wrapper to Arpack, a library for sparse eigenvalue decomposition. @@ -23,6 +21,8 @@ */ #include + +#include #include "src/Eigenvalues/ArpackSelfAdjointEigenSolver.h" #include diff --git a/unsupported/Eigen/Polynomials b/unsupported/Eigen/Polynomials index cece56337..334b03142 100644 --- a/unsupported/Eigen/Polynomials +++ b/unsupported/Eigen/Polynomials @@ -11,10 +11,10 @@ #include -#include - #include +#include + // Note that EIGEN_HIDE_HEAVY_CODE has to be defined per module #if (defined EIGEN_EXTERN_INSTANTIATIONS) && (EIGEN_EXTERN_INSTANTIATIONS>=2) #ifndef EIGEN_HIDE_HEAVY_CODE From befaf83f5f4cfafc7b17c8e384e0457c8493393f Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 28 Aug 2018 13:21:28 +0200 Subject: [PATCH 03/21] bug #1590: fix collision with some system headers defining the macro FP32 --- Eigen/src/Core/arch/GPU/Half.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Eigen/src/Core/arch/GPU/Half.h b/Eigen/src/Core/arch/GPU/Half.h index aca56fa72..b44a4356a 100644 --- a/Eigen/src/Core/arch/GPU/Half.h +++ b/Eigen/src/Core/arch/GPU/Half.h @@ -399,7 +399,7 @@ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC __half_raw raw_uint16_to_half(unsigned sho return h; } -union FP32 { +union float32_bits { unsigned int u; float f; }; @@ -416,11 +416,11 @@ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC __half_raw float_to_half_rtne(float ff) { return h; #else - FP32 f; f.f = ff; + float32_bits f; f.f = ff; - const FP32 f32infty = { 255 << 23 }; - const FP32 f16max = { (127 + 16) << 23 }; - const FP32 denorm_magic = { ((127 - 15) + (23 - 10) + 1) << 23 }; + const float32_bits f32infty = { 255 << 23 }; + const float32_bits f16max = { (127 + 16) << 23 }; + const float32_bits denorm_magic = { ((127 - 15) + (23 - 10) + 1) << 23 }; unsigned int sign_mask = 0x80000000u; __half_raw o; o.x = static_cast(0x0u); @@ -470,9 +470,9 @@ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC float half_to_float(__half_raw h) { return _cvtsh_ss(h.x); #else - const FP32 magic = { 113 << 23 }; + const float32_bits magic = { 113 << 23 }; const unsigned int shifted_exp = 0x7c00 << 13; // exponent mask after shift - FP32 o; + float32_bits o; o.u = (h.x & 0x7fff) << 13; // exponent/mantissa bits unsigned int exp = shifted_exp & o.u; // just the exponent From ef4d79fed8b84f03fe3c7ace98442c822cf3472a Mon Sep 17 00:00:00 2001 From: Christoph Hertzberg Date: Tue, 28 Aug 2018 18:26:22 +0200 Subject: [PATCH 04/21] Disable/ReenableStupidWarnings did not work properly, when included recursively --- Eigen/src/Core/util/DisableStupidWarnings.h | 8 ++++++++ Eigen/src/Core/util/ReenableStupidWarnings.h | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Eigen/src/Core/util/DisableStupidWarnings.h b/Eigen/src/Core/util/DisableStupidWarnings.h index af832ae77..d04b52649 100755 --- a/Eigen/src/Core/util/DisableStupidWarnings.h +++ b/Eigen/src/Core/util/DisableStupidWarnings.h @@ -80,4 +80,12 @@ #pragma diag_suppress 2739 #endif +#else +// warnings already disabled: +# ifndef EIGEN_WARNINGS_DISABLED_2 +# define EIGEN_WARNINGS_DISABLED_2 +# elif defined(EIGEN_INTERNAL_DEBUGGING) +# error "Do not include \"DisableStupidWarnings.h\" recursively more than twice!" +# endif + #endif // not EIGEN_WARNINGS_DISABLED diff --git a/Eigen/src/Core/util/ReenableStupidWarnings.h b/Eigen/src/Core/util/ReenableStupidWarnings.h index e9353a623..e23a128d1 100644 --- a/Eigen/src/Core/util/ReenableStupidWarnings.h +++ b/Eigen/src/Core/util/ReenableStupidWarnings.h @@ -1,4 +1,8 @@ -#ifdef EIGEN_WARNINGS_DISABLED +#ifdef EIGEN_WARNINGS_DISABLED_2 +// "DisableStupidWarnings.h" was included twice recursively: Do not reenable warnings yet! +# undef EIGEN_WARNINGS_DISABLED_2 + +#elif defined(EIGEN_WARNINGS_DISABLED) #undef EIGEN_WARNINGS_DISABLED #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS From 73ca600bca42f5ccf507ca4be1f53921973b44fe Mon Sep 17 00:00:00 2001 From: Christoph Hertzberg Date: Tue, 28 Aug 2018 18:32:39 +0200 Subject: [PATCH 05/21] Fix numerous shadow-warnings for GCC<=4.8 --- Eigen/SparseLU | 4 ++++ Eigen/src/StlSupport/StdDeque.h | 2 +- Eigen/src/StlSupport/StdList.h | 2 +- Eigen/src/StlSupport/StdVector.h | 2 +- blas/common.h | 8 ++++++++ test/mapstaticmethods.cpp | 4 ++++ unsupported/Eigen/AlignedVector3 | 4 ++++ unsupported/Eigen/AutoDiff | 6 ++++++ unsupported/Eigen/CXX11/Tensor | 4 ++-- unsupported/Eigen/FFT | 5 +++++ unsupported/Eigen/IterativeSolvers | 8 ++++++-- unsupported/Eigen/LevenbergMarquardt | 4 ++++ unsupported/Eigen/MatrixFunctions | 4 ++++ unsupported/Eigen/Splines | 4 ++++ unsupported/test/NumericalDiff.cpp | 2 +- unsupported/test/autodiff.cpp | 2 +- unsupported/test/dgmres.cpp | 2 +- unsupported/test/forward_adolc.cpp | 2 +- 18 files changed, 58 insertions(+), 11 deletions(-) diff --git a/Eigen/SparseLU b/Eigen/SparseLU index 38b38b531..37c4a5c5a 100644 --- a/Eigen/SparseLU +++ b/Eigen/SparseLU @@ -23,6 +23,8 @@ // Ordering interface #include "OrderingMethods" +#include "src/Core/util/DisableStupidWarnings.h" + #include "src/SparseLU/SparseLU_gemm_kernel.h" #include "src/SparseLU/SparseLU_Structs.h" @@ -43,4 +45,6 @@ #include "src/SparseLU/SparseLU_Utils.h" #include "src/SparseLU/SparseLU.h" +#include "src/Core/util/ReenableStupidWarnings.h" + #endif // EIGEN_SPARSELU_MODULE_H diff --git a/Eigen/src/StlSupport/StdDeque.h b/Eigen/src/StlSupport/StdDeque.h index cf1fedf92..8adfbb5c1 100644 --- a/Eigen/src/StlSupport/StdDeque.h +++ b/Eigen/src/StlSupport/StdDeque.h @@ -36,7 +36,7 @@ namespace std \ deque(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) : deque_base(first, last, a) {} \ deque(const deque& c) : deque_base(c) {} \ explicit deque(size_type num, const value_type& val = value_type()) : deque_base(num, val) {} \ - deque(iterator start, iterator end) : deque_base(start, end) {} \ + deque(iterator start_, iterator end_) : deque_base(start_, end_) {} \ deque& operator=(const deque& x) { \ deque_base::operator=(x); \ return *this; \ diff --git a/Eigen/src/StlSupport/StdList.h b/Eigen/src/StlSupport/StdList.h index e1eba4985..1b6d44061 100644 --- a/Eigen/src/StlSupport/StdList.h +++ b/Eigen/src/StlSupport/StdList.h @@ -35,7 +35,7 @@ namespace std \ list(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) : list_base(first, last, a) {} \ list(const list& c) : list_base(c) {} \ explicit list(size_type num, const value_type& val = value_type()) : list_base(num, val) {} \ - list(iterator start, iterator end) : list_base(start, end) {} \ + list(iterator start_, iterator end_) : list_base(start_, end_) {} \ list& operator=(const list& x) { \ list_base::operator=(x); \ return *this; \ diff --git a/Eigen/src/StlSupport/StdVector.h b/Eigen/src/StlSupport/StdVector.h index ec22821d2..7787edd72 100644 --- a/Eigen/src/StlSupport/StdVector.h +++ b/Eigen/src/StlSupport/StdVector.h @@ -36,7 +36,7 @@ namespace std \ vector(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) : vector_base(first, last, a) {} \ vector(const vector& c) : vector_base(c) {} \ explicit vector(size_type num, const value_type& val = value_type()) : vector_base(num, val) {} \ - vector(iterator start, iterator end) : vector_base(start, end) {} \ + vector(iterator start_, iterator end_) : vector_base(start_, end_) {} \ vector& operator=(const vector& x) { \ vector_base::operator=(x); \ return *this; \ diff --git a/blas/common.h b/blas/common.h index 61d8344d9..960c09cc6 100644 --- a/blas/common.h +++ b/blas/common.h @@ -10,6 +10,14 @@ #ifndef EIGEN_BLAS_COMMON_H #define EIGEN_BLAS_COMMON_H +#ifdef __GNUC__ +# if __GNUC__<5 +// GCC < 5.0 does not like the global Scalar typedef +// we just keep shadow-warnings disabled permanently +# define EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS +# endif +#endif + #include "../Eigen/Core" #include "../Eigen/Jacobi" diff --git a/test/mapstaticmethods.cpp b/test/mapstaticmethods.cpp index f32c0beec..d0128ba94 100644 --- a/test/mapstaticmethods.cpp +++ b/test/mapstaticmethods.cpp @@ -9,8 +9,12 @@ #include "main.h" +// GCC<=4.8 has spurious shadow warnings, because `ptr` re-appears inside template instantiations +// workaround: put these in an anonymous namespace +namespace { float *ptr; const float *const_ptr; +} template +#include "../../Eigen/src/Core/util/DisableStupidWarnings.h" + namespace Eigen { /** @@ -221,4 +223,6 @@ struct evaluator > } +#include "../../Eigen/src/Core/util/ReenableStupidWarnings.h" + #endif // EIGEN_ALIGNED_VECTOR3 diff --git a/unsupported/Eigen/AutoDiff b/unsupported/Eigen/AutoDiff index abf5b7d67..7a4ff460c 100644 --- a/unsupported/Eigen/AutoDiff +++ b/unsupported/Eigen/AutoDiff @@ -28,11 +28,17 @@ namespace Eigen { //@{ } +#include "../../Eigen/src/Core/util/DisableStupidWarnings.h" + #include "src/AutoDiff/AutoDiffScalar.h" // #include "src/AutoDiff/AutoDiffVector.h" #include "src/AutoDiff/AutoDiffJacobian.h" +#include "../../Eigen/src/Core/util/ReenableStupidWarnings.h" + + + namespace Eigen { //@} } diff --git a/unsupported/Eigen/CXX11/Tensor b/unsupported/Eigen/CXX11/Tensor index 47514703a..0165d0144 100644 --- a/unsupported/Eigen/CXX11/Tensor +++ b/unsupported/Eigen/CXX11/Tensor @@ -26,9 +26,9 @@ #include #endif -#include - #include "../SpecialFunctions" + +#include #include "src/util/CXX11Meta.h" #include "src/util/MaxSizeVector.h" diff --git a/unsupported/Eigen/FFT b/unsupported/Eigen/FFT index d8cf3e642..8ae053677 100644 --- a/unsupported/Eigen/FFT +++ b/unsupported/Eigen/FFT @@ -68,6 +68,8 @@ */ +#include "../../Eigen/src/Core/util/DisableStupidWarnings.h" + #ifdef EIGEN_FFTW_DEFAULT // FFTW: faster, GPL -- incompatible with Eigen in LGPL form, bigger code size # include @@ -415,5 +417,8 @@ void fft_inv_proxy::evalTo(T_DestMat& dst) const } } + +#include "../../Eigen/src/Core/util/ReenableStupidWarnings.h" + #endif /* vim: set filetype=cpp et sw=2 ts=2 ai: */ diff --git a/unsupported/Eigen/IterativeSolvers b/unsupported/Eigen/IterativeSolvers index 31e880bdc..fe8a6d00d 100644 --- a/unsupported/Eigen/IterativeSolvers +++ b/unsupported/Eigen/IterativeSolvers @@ -11,6 +11,8 @@ #define EIGEN_ITERATIVE_SOLVERS_MODULE_H #include +#include "../../Eigen/Jacobi" +#include "../../Eigen/Householder" /** * \defgroup IterativeSolvers_Module Iterative solvers module @@ -24,19 +26,21 @@ */ //@{ +#include "../../Eigen/src/Core/util/DisableStupidWarnings.h" + #ifndef EIGEN_MPL2_ONLY #include "src/IterativeSolvers/IterationController.h" #include "src/IterativeSolvers/ConstrainedConjGrad.h" #endif #include "src/IterativeSolvers/IncompleteLU.h" -#include "../../Eigen/Jacobi" -#include "../../Eigen/Householder" #include "src/IterativeSolvers/GMRES.h" #include "src/IterativeSolvers/DGMRES.h" //#include "src/IterativeSolvers/SSORPreconditioner.h" #include "src/IterativeSolvers/MINRES.h" +#include "../../Eigen/src/Core/util/ReenableStupidWarnings.h" + //@} #endif // EIGEN_ITERATIVE_SOLVERS_MODULE_H diff --git a/unsupported/Eigen/LevenbergMarquardt b/unsupported/Eigen/LevenbergMarquardt index 0fe2680ba..e77b746c9 100644 --- a/unsupported/Eigen/LevenbergMarquardt +++ b/unsupported/Eigen/LevenbergMarquardt @@ -30,6 +30,9 @@ */ #include "Eigen/SparseCore" + +#include "../../Eigen/src/Core/util/DisableStupidWarnings.h" + #ifndef EIGEN_PARSED_BY_DOXYGEN #include "src/LevenbergMarquardt/LMqrsolv.h" @@ -41,5 +44,6 @@ #include "src/LevenbergMarquardt/LevenbergMarquardt.h" #include "src/LevenbergMarquardt/LMonestep.h" +#include "../../Eigen/src/Core/util/ReenableStupidWarnings.h" #endif // EIGEN_LEVENBERGMARQUARDT_MODULE diff --git a/unsupported/Eigen/MatrixFunctions b/unsupported/Eigen/MatrixFunctions index 0320606c1..17eef8813 100644 --- a/unsupported/Eigen/MatrixFunctions +++ b/unsupported/Eigen/MatrixFunctions @@ -53,12 +53,16 @@ * */ +#include "../../Eigen/src/Core/util/DisableStupidWarnings.h" + #include "src/MatrixFunctions/MatrixExponential.h" #include "src/MatrixFunctions/MatrixFunction.h" #include "src/MatrixFunctions/MatrixSquareRoot.h" #include "src/MatrixFunctions/MatrixLogarithm.h" #include "src/MatrixFunctions/MatrixPower.h" +#include "../../Eigen/src/Core/util/ReenableStupidWarnings.h" + /** \page matrixbaseextra_page diff --git a/unsupported/Eigen/Splines b/unsupported/Eigen/Splines index 322e6b9f5..2ca581364 100644 --- a/unsupported/Eigen/Splines +++ b/unsupported/Eigen/Splines @@ -24,8 +24,12 @@ namespace Eigen */ } +#include "../../Eigen/src/Core/util/DisableStupidWarnings.h" + #include "src/Splines/SplineFwd.h" #include "src/Splines/Spline.h" #include "src/Splines/SplineFitting.h" +#include "../../Eigen/src/Core/util/ReenableStupidWarnings.h" + #endif // EIGEN_SPLINES_MODULE_H diff --git a/unsupported/test/NumericalDiff.cpp b/unsupported/test/NumericalDiff.cpp index 35f2f6d7c..6d836413b 100644 --- a/unsupported/test/NumericalDiff.cpp +++ b/unsupported/test/NumericalDiff.cpp @@ -24,7 +24,7 @@ struct Functor int m_inputs, m_values; Functor() : m_inputs(InputsAtCompileTime), m_values(ValuesAtCompileTime) {} - Functor(int inputs, int values) : m_inputs(inputs), m_values(values) {} + Functor(int inputs_, int values_) : m_inputs(inputs_), m_values(values_) {} int inputs() const { return m_inputs; } int values() const { return m_values; } diff --git a/unsupported/test/autodiff.cpp b/unsupported/test/autodiff.cpp index 495cee03e..bafea6ae9 100644 --- a/unsupported/test/autodiff.cpp +++ b/unsupported/test/autodiff.cpp @@ -44,7 +44,7 @@ struct TestFunc1 int m_inputs, m_values; TestFunc1() : m_inputs(InputsAtCompileTime), m_values(ValuesAtCompileTime) {} - TestFunc1(int inputs, int values) : m_inputs(inputs), m_values(values) {} + TestFunc1(int inputs_, int values_) : m_inputs(inputs_), m_values(values_) {} int inputs() const { return m_inputs; } int values() const { return m_values; } diff --git a/unsupported/test/dgmres.cpp b/unsupported/test/dgmres.cpp index 04f5ad670..5f63161b2 100644 --- a/unsupported/test/dgmres.cpp +++ b/unsupported/test/dgmres.cpp @@ -9,7 +9,7 @@ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. #include "../../test/sparse_solver.h" -#include +#include template void test_dgmres_T() { diff --git a/unsupported/test/forward_adolc.cpp b/unsupported/test/forward_adolc.cpp index 688594eff..14a909d3b 100644 --- a/unsupported/test/forward_adolc.cpp +++ b/unsupported/test/forward_adolc.cpp @@ -35,7 +35,7 @@ struct TestFunc1 int m_inputs, m_values; TestFunc1() : m_inputs(InputsAtCompileTime), m_values(ValuesAtCompileTime) {} - TestFunc1(int inputs, int values) : m_inputs(inputs), m_values(values) {} + TestFunc1(int inputs_, int values_) : m_inputs(inputs_), m_values(values_) {} int inputs() const { return m_inputs; } int values() const { return m_values; } From 20ba2eee6d4bc75fe2fbcd2af7218e47abcb76df Mon Sep 17 00:00:00 2001 From: Christoph Hertzberg Date: Tue, 28 Aug 2018 18:33:24 +0200 Subject: [PATCH 06/21] gcc thinks this may not be initialized --- unsupported/test/NonLinearOptimization.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unsupported/test/NonLinearOptimization.cpp b/unsupported/test/NonLinearOptimization.cpp index cc95cea29..2770c3c49 100644 --- a/unsupported/test/NonLinearOptimization.cpp +++ b/unsupported/test/NonLinearOptimization.cpp @@ -565,7 +565,7 @@ void testLmdif1() // do the computation lmdif_functor functor; - DenseIndex nfev; + DenseIndex nfev = -1; // initialize to avoid maybe-uninitialized warning info = LevenbergMarquardt::lmdif1(functor, x, &nfev); // check return value From 7ec8b40ad90bcc63d36fc5a36b517d4a07c60b4b Mon Sep 17 00:00:00 2001 From: Mehdi Goli Date: Tue, 28 Aug 2018 14:20:48 +0100 Subject: [PATCH 07/21] Collapsed revision * Separating SYCL math function. * Converting function overload to function specialisation. * Applying the suggested design. --- Eigen/src/Core/MathFunctions.h | 253 ++++++++++++++++----------------- 1 file changed, 123 insertions(+), 130 deletions(-) diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index 58cf7021a..72116e144 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -876,7 +876,7 @@ template T generic_fast_tanh_float(const T& a_x); namespace numext { -#if (!defined(EIGEN_GPUCC) || defined(EIGEN_CONSTEXPR_ARE_DEVICE_FUNC)) && !defined(__SYCL_DEVICE_ONLY__) +#if (!defined(EIGEN_GPUCC) || defined(EIGEN_CONSTEXPR_ARE_DEVICE_FUNC)) template EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T mini(const T& x, const T& y) @@ -892,80 +892,6 @@ EIGEN_ALWAYS_INLINE T maxi(const T& x, const T& y) EIGEN_USING_STD_MATH(max); return max EIGEN_NOT_A_MACRO (x,y); } - -#elif defined(__SYCL_DEVICE_ONLY__) -template -EIGEN_ALWAYS_INLINE T mini(const T& x, const T& y) -{ - return y < x ? y : x; -} - -template -EIGEN_ALWAYS_INLINE T maxi(const T& x, const T& y) -{ - return x < y ? y : x; -} - -EIGEN_ALWAYS_INLINE int mini(const int& x, const int& y) -{ - return cl::sycl::min(x,y); -} - -EIGEN_ALWAYS_INLINE int maxi(const int& x, const int& y) -{ - return cl::sycl::max(x,y); -} - -EIGEN_ALWAYS_INLINE unsigned int mini(const unsigned int& x, const unsigned int& y) -{ - return cl::sycl::min(x,y); -} - -EIGEN_ALWAYS_INLINE unsigned int maxi(const unsigned int& x, const unsigned int& y) -{ - return cl::sycl::max(x,y); -} - -EIGEN_ALWAYS_INLINE long mini(const long & x, const long & y) -{ - return cl::sycl::min(x,y); -} - -EIGEN_ALWAYS_INLINE long maxi(const long & x, const long & y) -{ - return cl::sycl::max(x,y); -} - -EIGEN_ALWAYS_INLINE unsigned long mini(const unsigned long& x, const unsigned long& y) -{ - return cl::sycl::min(x,y); -} - -EIGEN_ALWAYS_INLINE unsigned long maxi(const unsigned long& x, const unsigned long& y) -{ - return cl::sycl::max(x,y); -} - -EIGEN_ALWAYS_INLINE float mini(const float& x, const float& y) -{ - return cl::sycl::fmin(x,y); -} - -EIGEN_ALWAYS_INLINE float maxi(const float& x, const float& y) -{ - return cl::sycl::fmax(x,y); -} - -EIGEN_ALWAYS_INLINE double mini(const double& x, const double& y) -{ - return cl::sycl::fmin(x,y); -} - -EIGEN_ALWAYS_INLINE double maxi(const double& x, const double& y) -{ - return cl::sycl::fmax(x,y); -} - #else template EIGEN_DEVICE_FUNC @@ -1028,6 +954,75 @@ EIGEN_ALWAYS_INLINE long double maxi(const long double& x, const long double& y) } #endif +#if defined(__SYCL_DEVICE_ONLY__) + + +#define SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_BINARY(NAME, FUNC) \ + SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_char) \ + SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_short) \ + SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_int) \ + SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_long) +#define SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_UNARY(NAME, FUNC) \ + SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_char) \ + SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_short) \ + SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_int) \ + SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_long) +#define SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_BINARY(NAME, FUNC) \ + SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_uchar) \ + SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_ushort) \ + SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_uint) \ + SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_ulong) +#define SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_UNARY(NAME, FUNC) \ + SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_uchar) \ + SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_ushort) \ + SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_uint) \ + SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_ulong) +#define SYCL_SPECIALIZE_INTEGER_TYPES_BINARY(NAME, FUNC) \ + SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_BINARY(NAME, FUNC) \ + SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_BINARY(NAME, FUNC) +#define SYCL_SPECIALIZE_INTEGER_TYPES_UNARY(NAME, FUNC) \ + SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_UNARY(NAME, FUNC) \ + SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_UNARY(NAME, FUNC) +#define SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(NAME, FUNC) \ + SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_float) \ + SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC,cl::sycl::cl_double) +#define SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(NAME, FUNC) \ + SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_float) \ + SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC,cl::sycl::cl_double) +#define SYCL_SPECIALIZE_FLOATING_TYPES_UNARY_FUNC_RET_TYPE(NAME, FUNC, RET_TYPE) \ + SYCL_SPECIALIZE_GEN_UNARY_FUNC(NAME, FUNC, RET_TYPE, cl::sycl::cl_float) \ + SYCL_SPECIALIZE_GEN_UNARY_FUNC(NAME, FUNC, RET_TYPE, cl::sycl::cl_double) + +#define SYCL_SPECIALIZE_GEN_UNARY_FUNC(NAME, FUNC, RET_TYPE, ARG_TYPE) \ +template<> \ + EIGEN_DEVICE_FUNC \ + EIGEN_ALWAYS_INLINE RET_TYPE NAME(const ARG_TYPE& x) { \ + return cl::sycl::FUNC(x); \ + } + +#define SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, TYPE) \ + SYCL_SPECIALIZE_GEN_UNARY_FUNC(NAME, FUNC, TYPE, TYPE) + +#define SYCL_SPECIALIZE_GEN1_BINARY_FUNC(NAME, FUNC, RET_TYPE, ARG_TYPE1, ARG_TYPE2) \ + template<> \ + EIGEN_DEVICE_FUNC \ + EIGEN_ALWAYS_INLINE RET_TYPE NAME(const ARG_TYPE1& x, const ARG_TYPE2& y) { \ + return cl::sycl::FUNC(x, y); \ + } + +#define SYCL_SPECIALIZE_GEN2_BINARY_FUNC(NAME, FUNC, RET_TYPE, ARG_TYPE) \ + SYCL_SPECIALIZE_GEN1_BINARY_FUNC(NAME, FUNC, RET_TYPE, ARG_TYPE, ARG_TYPE) + +#define SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, TYPE) \ + SYCL_SPECIALIZE_GEN2_BINARY_FUNC(NAME, FUNC, TYPE, TYPE) + +SYCL_SPECIALIZE_INTEGER_TYPES_BINARY(mini, min) +SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(mini, fmin) +SYCL_SPECIALIZE_INTEGER_TYPES_BINARY(maxi, max) +SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(maxi, fmax) + +#endif // defined(__SYCL_DEVICE_ONLY__) + template EIGEN_DEVICE_FUNC @@ -1109,6 +1104,10 @@ inline EIGEN_MATHFUNC_RETVAL(hypot, Scalar) hypot(const Scalar& x, const Scalar& return EIGEN_MATHFUNC_IMPL(hypot, Scalar)::run(x, y); } +#if defined(__SYCL_DEVICE_ONLY__) + SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(hypot, hypot) +#endif // defined(__SYCL_DEVICE_ONLY__) + template EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(log1p, Scalar) log1p(const Scalar& x) @@ -1117,9 +1116,8 @@ inline EIGEN_MATHFUNC_RETVAL(log1p, Scalar) log1p(const Scalar& x) } #if defined(__SYCL_DEVICE_ONLY__) -EIGEN_ALWAYS_INLINE float log1p(float x) { return cl::sycl::log1p(x); } -EIGEN_ALWAYS_INLINE double log1p(double x) { return cl::sycl::log1p(x); } -#endif // defined(__SYCL_DEVICE_ONLY__) +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(log1p, log1p) +#endif //defined(__SYCL_DEVICE_ONLY__) #if defined(EIGEN_GPUCC) template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE @@ -1137,8 +1135,7 @@ inline typename internal::pow_impl::result_type pow(const Scala } #if defined(__SYCL_DEVICE_ONLY__) -EIGEN_ALWAYS_INLINE float pow(float x, float y) { return cl::sycl::pow(x, y); } -EIGEN_ALWAYS_INLINE double pow(double x, double y) { return cl::sycl::pow(x, y); } +SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(pow, pow) #endif // defined(__SYCL_DEVICE_ONLY__) template EIGEN_DEVICE_FUNC bool (isnan) (const T &x) { return internal::isnan_impl(x); } @@ -1146,12 +1143,9 @@ template EIGEN_DEVICE_FUNC bool (isinf) (const T &x) { return inte template EIGEN_DEVICE_FUNC bool (isfinite)(const T &x) { return internal::isfinite_impl(x); } #if defined(__SYCL_DEVICE_ONLY__) -EIGEN_ALWAYS_INLINE float isnan(float x) { return cl::sycl::isnan(x); } -EIGEN_ALWAYS_INLINE double isnan(double x) { return cl::sycl::isnan(x); } -EIGEN_ALWAYS_INLINE float isinf(float x) { return cl::sycl::isinf(x); } -EIGEN_ALWAYS_INLINE double isinf(double x) { return cl::sycl::isinf(x); } -EIGEN_ALWAYS_INLINE float isfinite(float x) { return cl::sycl::isfinite(x); } -EIGEN_ALWAYS_INLINE double isfinite(double x) { return cl::sycl::isfinite(x); } +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY_FUNC_RET_TYPE(isnan, isnan, bool) +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY_FUNC_RET_TYPE(isinf, isinf, bool) +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY_FUNC_RET_TYPE(isfinite, isfinite, bool) #endif // defined(__SYCL_DEVICE_ONLY__) template @@ -1162,8 +1156,7 @@ inline EIGEN_MATHFUNC_RETVAL(round, Scalar) round(const Scalar& x) } #if defined(__SYCL_DEVICE_ONLY__) -EIGEN_ALWAYS_INLINE float round(float x) { return cl::sycl::round(x); } -EIGEN_ALWAYS_INLINE double round(double x) { return cl::sycl::round(x); } +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(round, round) #endif // defined(__SYCL_DEVICE_ONLY__) template @@ -1175,8 +1168,7 @@ T (floor)(const T& x) } #if defined(__SYCL_DEVICE_ONLY__) -EIGEN_ALWAYS_INLINE float floor(float x) { return cl::sycl::floor(x); } -EIGEN_ALWAYS_INLINE double floor(double x) { return cl::sycl::floor(x); } +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(floor, floor) #endif // defined(__SYCL_DEVICE_ONLY__) #if defined(EIGEN_GPUCC) @@ -1196,8 +1188,7 @@ T (ceil)(const T& x) } #if defined(__SYCL_DEVICE_ONLY__) -EIGEN_ALWAYS_INLINE float ceil(float x) { return cl::sycl::ceil(x); } -EIGEN_ALWAYS_INLINE double ceil(double x) { return cl::sycl::ceil(x); } +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(ceil, ceil) #endif // defined(__SYCL_DEVICE_ONLY__) #if defined(EIGEN_GPUCC) @@ -1241,8 +1232,7 @@ T sqrt(const T &x) } #if defined(__SYCL_DEVICE_ONLY__) -EIGEN_ALWAYS_INLINE float sqrt(float x) { return cl::sycl::sqrt(x); } -EIGEN_ALWAYS_INLINE double sqrt(double x) { return cl::sycl::sqrt(x); } +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(sqrt, sqrt) #endif // defined(__SYCL_DEVICE_ONLY__) template @@ -1253,8 +1243,7 @@ T log(const T &x) { } #if defined(__SYCL_DEVICE_ONLY__) -EIGEN_ALWAYS_INLINE float log(float x) { return cl::sycl::log(x); } -EIGEN_ALWAYS_INLINE double log(double x) { return cl::sycl::log(x); } +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(log, log) #endif // defined(__SYCL_DEVICE_ONLY__) @@ -1282,8 +1271,8 @@ abs(const T &x) { } #if defined(__SYCL_DEVICE_ONLY__) -EIGEN_ALWAYS_INLINE float abs(float x) { return cl::sycl::fabs(x); } -EIGEN_ALWAYS_INLINE double abs(double x) { return cl::sycl::fabs(x); } +SYCL_SPECIALIZE_INTEGER_TYPES_UNARY(abs, abs) +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(abs, fabs) #endif // defined(__SYCL_DEVICE_ONLY__) #if defined(EIGEN_GPUCC) @@ -1312,8 +1301,7 @@ T exp(const T &x) { } #if defined(__SYCL_DEVICE_ONLY__) -EIGEN_ALWAYS_INLINE float exp(float x) { return cl::sycl::exp(x); } -EIGEN_ALWAYS_INLINE double exp(double x) { return cl::sycl::exp(x); } +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(exp, exp) #endif // defined(__SYCL_DEVICE_ONLY__) #if defined(EIGEN_GPUCC) @@ -1348,8 +1336,7 @@ inline EIGEN_MATHFUNC_RETVAL(expm1, Scalar) expm1(const Scalar& x) } #if defined(__SYCL_DEVICE_ONLY__) -EIGEN_ALWAYS_INLINE float expm1(float x) { return cl::sycl::expm1(x); } -EIGEN_ALWAYS_INLINE double expm1(double x) { return cl::sycl::expm1(x); } +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(expm1, expm1) #endif // defined(__SYCL_DEVICE_ONLY__) #if defined(EIGEN_GPUCC) @@ -1368,8 +1355,7 @@ T cos(const T &x) { } #if defined(__SYCL_DEVICE_ONLY__) -EIGEN_ALWAYS_INLINE float cos(float x) { return cl::sycl::cos(x); } -EIGEN_ALWAYS_INLINE double cos(double x) { return cl::sycl::cos(x); } +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(cos,cos) #endif // defined(__SYCL_DEVICE_ONLY__) #if defined(EIGEN_GPUCC) @@ -1388,8 +1374,7 @@ T sin(const T &x) { } #if defined(__SYCL_DEVICE_ONLY__) -EIGEN_ALWAYS_INLINE float sin(float x) { return cl::sycl::sin(x); } -EIGEN_ALWAYS_INLINE double sin(double x) { return cl::sycl::sin(x); } +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(sin, sin) #endif // defined(__SYCL_DEVICE_ONLY__) #if defined(EIGEN_GPUCC) @@ -1408,8 +1393,7 @@ T tan(const T &x) { } #if defined(__SYCL_DEVICE_ONLY__) -EIGEN_ALWAYS_INLINE float tan(float x) { return cl::sycl::tan(x); } -EIGEN_ALWAYS_INLINE double tan(double x) { return cl::sycl::tan(x); } +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(tan, tan) #endif // defined(__SYCL_DEVICE_ONLY__) #if defined(EIGEN_GPUCC) @@ -1437,10 +1421,8 @@ T acosh(const T &x) { #endif #if defined(__SYCL_DEVICE_ONLY__) -EIGEN_ALWAYS_INLINE float acos(float x) { return cl::sycl::acos(x); } -EIGEN_ALWAYS_INLINE double acos(double x) { return cl::sycl::acos(x); } -EIGEN_ALWAYS_INLINE float acosh(float x) { return cl::sycl::acosh(x); } -EIGEN_ALWAYS_INLINE double acosh(double x) { return cl::sycl::acosh(x); } +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(acos, acos) +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(acosh, acosh) #endif // defined(__SYCL_DEVICE_ONLY__) #if defined(EIGEN_GPUCC) @@ -1468,10 +1450,8 @@ T asinh(const T &x) { #endif #if defined(__SYCL_DEVICE_ONLY__) -EIGEN_ALWAYS_INLINE float asin(float x) { return cl::sycl::asin(x); } -EIGEN_ALWAYS_INLINE double asin(double x) { return cl::sycl::asin(x); } -EIGEN_ALWAYS_INLINE float asinh(float x) { return cl::sycl::asinh(x); } -EIGEN_ALWAYS_INLINE double asinh(double x) { return cl::sycl::asinh(x); } +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(asin, asin) +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(asinh, asinh) #endif // defined(__SYCL_DEVICE_ONLY__) #if defined(EIGEN_GPUCC) @@ -1499,10 +1479,8 @@ T atanh(const T &x) { #endif #if defined(__SYCL_DEVICE_ONLY__) -EIGEN_ALWAYS_INLINE float atan(float x) { return cl::sycl::atan(x); } -EIGEN_ALWAYS_INLINE double atan(double x) { return cl::sycl::atan(x); } -EIGEN_ALWAYS_INLINE float atanh(float x) { return cl::sycl::atanh(x); } -EIGEN_ALWAYS_INLINE double atanh(double x) { return cl::sycl::atanh(x); } +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(atan, atan) +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(atanh, atanh) #endif // defined(__SYCL_DEVICE_ONLY__) #if defined(EIGEN_GPUCC) @@ -1522,8 +1500,7 @@ T cosh(const T &x) { } #if defined(__SYCL_DEVICE_ONLY__) -EIGEN_ALWAYS_INLINE float cosh(float x) { return cl::sycl::cosh(x); } -EIGEN_ALWAYS_INLINE double cosh(double x) { return cl::sycl::cosh(x); } +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(cosh, cosh) #endif // defined(__SYCL_DEVICE_ONLY__) #if defined(EIGEN_GPUCC) @@ -1542,8 +1519,7 @@ T sinh(const T &x) { } #if defined(__SYCL_DEVICE_ONLY__) -EIGEN_ALWAYS_INLINE float sinh(float x) { return cl::sycl::sinh(x); } -EIGEN_ALWAYS_INLINE double sinh(double x) { return cl::sycl::sinh(x); } +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(sinh, sinh) #endif // defined(__SYCL_DEVICE_ONLY__) #if defined(EIGEN_GPUCC) @@ -1561,14 +1537,15 @@ T tanh(const T &x) { return tanh(x); } -#if defined(__SYCL_DEVICE_ONLY__) -EIGEN_ALWAYS_INLINE float tanh(float x) { return cl::sycl::tanh(x); } -EIGEN_ALWAYS_INLINE double tanh(double x) { return cl::sycl::tanh(x); } -#elif (!defined(EIGEN_GPUCC)) && EIGEN_FAST_MATH +#if (!defined(EIGEN_GPUCC)) && EIGEN_FAST_MATH && (!defined(__SYCL_DEVICE_ONLY__)) EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float tanh(float x) { return internal::generic_fast_tanh_float(x); } #endif +#if defined(__SYCL_DEVICE_ONLY__) +SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(tanh, tanh) +#endif // defined(__SYCL_DEVICE_ONLY__) + #if defined(EIGEN_GPUCC) template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float tanh(const float &x) { return ::tanhf(x); } @@ -1585,8 +1562,7 @@ T fmod(const T& a, const T& b) { } #if defined(__SYCL_DEVICE_ONLY__) -EIGEN_ALWAYS_INLINE float fmod(float x, float y) { return cl::sycl::fmod(x, y); } -EIGEN_ALWAYS_INLINE double fmod(double x, double y) { return cl::sycl::fmod(x, y); } +SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(fmod, fmod) #endif // defined(__SYCL_DEVICE_ONLY__) #if defined(EIGEN_GPUCC) @@ -1603,6 +1579,23 @@ double fmod(const double& a, const double& b) { } #endif +#if defined(__SYCL_DEVICE_ONLY__) +#undef SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_BINARY +#undef SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_UNARY +#undef SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_BINARY +#undef SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_UNARY +#undef SYCL_SPECIALIZE_INTEGER_TYPES_BINARY +#undef SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_UNARY +#undef SYCL_SPECIALIZE_FLOATING_TYPES_BINARY +#undef SYCL_SPECIALIZE_FLOATING_TYPES_UNARY +#undef SYCL_SPECIALIZE_FLOATING_TYPES_UNARY_FUNC_RET_TYPE +#undef SYCL_SPECIALIZE_GEN_UNARY_FUNC +#undef SYCL_SPECIALIZE_UNARY_FUNC +#undef SYCL_SPECIALIZE_GEN1_BINARY_FUNC +#undef SYCL_SPECIALIZE_GEN2_BINARY_FUNC +#undef SYCL_SPECIALIZE_BINARY_FUNC +#endif // defined(__SYCL_DEVICE_ONLY__) + } // end namespace numext namespace internal { From 946c3e2544da35ed0539e433cc906c93c9bda3ed Mon Sep 17 00:00:00 2001 From: Deven Desai Date: Mon, 27 Aug 2018 23:04:08 +0000 Subject: [PATCH 08/21] adding EIGEN_DEVICE_FUNC attribute to fix some GPU unit tests that are broken in HIP mode --- unsupported/Eigen/CXX11/src/Tensor/TensorBlock.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorBlock.h b/unsupported/Eigen/CXX11/src/Tensor/TensorBlock.h index 4cb49e9b8..9b92b6179 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorBlock.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorBlock.h @@ -79,7 +79,7 @@ struct TensorOpResourceRequirements { }; // Tries to merge multiple resource requirements. -EIGEN_STRONG_INLINE void MergeResourceRequirements( +EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void MergeResourceRequirements( const std::vector& resources, TensorBlockShapeType* block_shape, Index* block_total_size) { if (resources.empty()) { From ddbc5643860d6033fdca88145d2427ae52716a9d Mon Sep 17 00:00:00 2001 From: Christoph Hertzberg Date: Thu, 30 Aug 2018 16:33:03 +0200 Subject: [PATCH 09/21] Fixed a few more shadowing warnings when compiling with g++ (and c++03) --- Eigen/src/StlSupport/StdDeque.h | 2 +- Eigen/src/StlSupport/StdList.h | 2 +- Eigen/src/StlSupport/StdVector.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Eigen/src/StlSupport/StdDeque.h b/Eigen/src/StlSupport/StdDeque.h index 8adfbb5c1..045da7b4d 100644 --- a/Eigen/src/StlSupport/StdDeque.h +++ b/Eigen/src/StlSupport/StdDeque.h @@ -62,7 +62,7 @@ namespace std { : deque_base(first, last, a) {} \ deque(const deque& c) : deque_base(c) {} \ explicit deque(size_type num, const value_type& val = value_type()) : deque_base(num, val) {} \ - deque(iterator start, iterator end) : deque_base(start, end) {} \ + deque(iterator start_, iterator end_) : deque_base(start_, end_) {} \ deque& operator=(const deque& x) { \ deque_base::operator=(x); \ return *this; \ diff --git a/Eigen/src/StlSupport/StdList.h b/Eigen/src/StlSupport/StdList.h index 1b6d44061..8ba3fada0 100644 --- a/Eigen/src/StlSupport/StdList.h +++ b/Eigen/src/StlSupport/StdList.h @@ -62,7 +62,7 @@ namespace std : list_base(first, last, a) {} \ list(const list& c) : list_base(c) {} \ explicit list(size_type num, const value_type& val = value_type()) : list_base(num, val) {} \ - list(iterator start, iterator end) : list_base(start, end) {} \ + list(iterator start_, iterator end_) : list_base(start_, end_) {} \ list& operator=(const list& x) { \ list_base::operator=(x); \ return *this; \ diff --git a/Eigen/src/StlSupport/StdVector.h b/Eigen/src/StlSupport/StdVector.h index 7787edd72..9fcf19bce 100644 --- a/Eigen/src/StlSupport/StdVector.h +++ b/Eigen/src/StlSupport/StdVector.h @@ -62,7 +62,7 @@ namespace std { : vector_base(first, last, a) {} \ vector(const vector& c) : vector_base(c) {} \ explicit vector(size_type num, const value_type& val = value_type()) : vector_base(num, val) {} \ - vector(iterator start, iterator end) : vector_base(start, end) {} \ + vector(iterator start_, iterator end_) : vector_base(start_, end_) {} \ vector& operator=(const vector& x) { \ vector_base::operator=(x); \ return *this; \ From c2f4e8c08e1fc74f426f21ba4e05decaa7dbf53b Mon Sep 17 00:00:00 2001 From: Christoph Hertzberg Date: Thu, 30 Aug 2018 17:12:53 +0200 Subject: [PATCH 10/21] Fix integer conversion warning --- unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h b/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h index ce91bc2a6..7c26b1682 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h @@ -194,7 +194,7 @@ template ::value; @@ -208,7 +208,7 @@ template ::value; default: eigen_assert(false && "index overflow"); - return static_cast(-1); + return static_cast(-1); } } From 023ed6b9a83b89bdba7c4b689bc9e69acd1af79f Mon Sep 17 00:00:00 2001 From: Christoph Hertzberg Date: Thu, 30 Aug 2018 17:14:52 +0200 Subject: [PATCH 11/21] Product of empty array must be 1 and not 0. --- unsupported/Eigen/CXX11/src/util/EmulateCXX11Meta.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unsupported/Eigen/CXX11/src/util/EmulateCXX11Meta.h b/unsupported/Eigen/CXX11/src/util/EmulateCXX11Meta.h index f3aa1b144..8a536faf6 100644 --- a/unsupported/Eigen/CXX11/src/util/EmulateCXX11Meta.h +++ b/unsupported/Eigen/CXX11/src/util/EmulateCXX11Meta.h @@ -188,7 +188,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE t array_prod(const array& a) { } template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE t array_prod(const array& /*a*/) { - return 0; + return 1; } template From ff4e835d6b974ff70bdf12288e58bc073eefe4fb Mon Sep 17 00:00:00 2001 From: Christoph Hertzberg Date: Thu, 30 Aug 2018 20:10:11 +0200 Subject: [PATCH 12/21] "sparse_product.cpp" must be included before "sparse_basic.cpp", otherwise EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN has no effect --- unsupported/test/sparse_extra.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unsupported/test/sparse_extra.cpp b/unsupported/test/sparse_extra.cpp index 4ac53a9a7..51ba83b13 100644 --- a/unsupported/test/sparse_extra.cpp +++ b/unsupported/test/sparse_extra.cpp @@ -10,8 +10,8 @@ // import basic and product tests for deprecated DynamicSparseMatrix #define EIGEN_NO_DEPRECATED_WARNING -#include "sparse_basic.cpp" #include "sparse_product.cpp" +#include "sparse_basic.cpp" #include template From edeee16a16373dbd86ff0a1129e3d94e3c7e93a7 Mon Sep 17 00:00:00 2001 From: Alexey Frunze Date: Fri, 31 Aug 2018 14:11:10 -0700 Subject: [PATCH 13/21] Fix build failures in matrix_power and matrix_exponential tests. This fixes the static assertion complaining about double being used in place of long double. This happened on MIPS32, where double and long double have the same type representation. This can be simulated on x86 as well if we pass -mlong-double-64 to g++. --- unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h b/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h index 54037d58d..8aebcd67a 100644 --- a/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h +++ b/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h @@ -234,12 +234,13 @@ struct matrix_exp_computeUV template struct matrix_exp_computeUV { + typedef typename NumTraits::Scalar>::Real RealScalar; template static void run(const ArgType& arg, MatrixType& U, MatrixType& V, int& squarings) { using std::frexp; using std::pow; - const double l1norm = arg.cwiseAbs().colwise().sum().maxCoeff(); + const RealScalar l1norm = arg.cwiseAbs().colwise().sum().maxCoeff(); squarings = 0; if (l1norm < 1.495585217958292e-002) { matrix_exp_pade3(arg, U, V); @@ -250,10 +251,10 @@ struct matrix_exp_computeUV } else if (l1norm < 2.097847961257068e+000) { matrix_exp_pade9(arg, U, V); } else { - const double maxnorm = 5.371920351148152; + const RealScalar maxnorm = 5.371920351148152; frexp(l1norm / maxnorm, &squarings); if (squarings < 0) squarings = 0; - MatrixType A = arg.unaryExpr(MatrixExponentialScalingOp(squarings)); + MatrixType A = arg.unaryExpr(MatrixExponentialScalingOp(squarings)); matrix_exp_pade13(A, U, V); } } From c6066ac4115cafd00db7e02a179957290978142c Mon Sep 17 00:00:00 2001 From: cgs1019 Date: Thu, 6 Sep 2018 11:04:17 -0400 Subject: [PATCH 14/21] Make param name and docs constistent for JacobiRotation::makeGivens Previously the rendered math in the doc string called the optional return value 'r', while the actual parameter and the doc string text referred to the parameter as 'z'. This changeset renames all the z's to r's to match the math. --- Eigen/src/Jacobi/Jacobi.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Eigen/src/Jacobi/Jacobi.h b/Eigen/src/Jacobi/Jacobi.h index 176ff9d07..4ccd49a04 100644 --- a/Eigen/src/Jacobi/Jacobi.h +++ b/Eigen/src/Jacobi/Jacobi.h @@ -73,13 +73,13 @@ template class JacobiRotation bool makeJacobi(const RealScalar& x, const Scalar& y, const RealScalar& z); EIGEN_DEVICE_FUNC - void makeGivens(const Scalar& p, const Scalar& q, Scalar* z=0); + void makeGivens(const Scalar& p, const Scalar& q, Scalar* r=0); protected: EIGEN_DEVICE_FUNC - void makeGivens(const Scalar& p, const Scalar& q, Scalar* z, internal::true_type); + void makeGivens(const Scalar& p, const Scalar& q, Scalar* r, internal::true_type); EIGEN_DEVICE_FUNC - void makeGivens(const Scalar& p, const Scalar& q, Scalar* z, internal::false_type); + void makeGivens(const Scalar& p, const Scalar& q, Scalar* r, internal::false_type); Scalar m_c, m_s; }; @@ -145,7 +145,7 @@ inline bool JacobiRotation::makeJacobi(const MatrixBase& m, Ind * \f$ V = \left ( \begin{array}{c} p \\ q \end{array} \right )\f$ yields: * \f$ G^* V = \left ( \begin{array}{c} r \\ 0 \end{array} \right )\f$. * - * The value of \a z is returned if \a z is not null (the default is null). + * The value of \a r is returned if \a r is not null (the default is null). * Also note that G is built such that the cosine is always real. * * Example: \include Jacobi_makeGivens.cpp @@ -159,9 +159,9 @@ inline bool JacobiRotation::makeJacobi(const MatrixBase& m, Ind */ template EIGEN_DEVICE_FUNC -void JacobiRotation::makeGivens(const Scalar& p, const Scalar& q, Scalar* z) +void JacobiRotation::makeGivens(const Scalar& p, const Scalar& q, Scalar* r) { - makeGivens(p, q, z, typename internal::conditional::IsComplex, internal::true_type, internal::false_type>::type()); + makeGivens(p, q, r, typename internal::conditional::IsComplex, internal::true_type, internal::false_type>::type()); } From ec38f07b799e2e3b82921ac3a5839f90ea3333c4 Mon Sep 17 00:00:00 2001 From: Alexey Frunze Date: Thu, 6 Sep 2018 15:40:09 -0700 Subject: [PATCH 15/21] bug #1595: Don't use C++11's std::isnan() in MIPS/MSA packet math. This removes reliance on C++11 and improves generated code. --- Eigen/src/Core/arch/MSA/PacketMath.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Eigen/src/Core/arch/MSA/PacketMath.h b/Eigen/src/Core/arch/MSA/PacketMath.h index 94c15d132..094c874ee 100644 --- a/Eigen/src/Core/arch/MSA/PacketMath.h +++ b/Eigen/src/Core/arch/MSA/PacketMath.h @@ -1178,7 +1178,7 @@ EIGEN_STRONG_INLINE double predux_min(const Packet2d& a) { return v[0]; #else double a0 = a[0], a1 = a[1]; - return ((std::isnan)(a0) || a0 < a1) ? a0 : a1; + return ((numext::isnan)(a0) || a0 < a1) ? a0 : a1; #endif } @@ -1193,7 +1193,7 @@ EIGEN_STRONG_INLINE double predux_max(const Packet2d& a) { return v[0]; #else double a0 = a[0], a1 = a[1]; - return ((std::isnan)(a0) || a0 > a1) ? a0 : a1; + return ((numext::isnan)(a0) || a0 > a1) ? a0 : a1; #endif } From edfb7962fdae447125e188a03bfea33b47df010a Mon Sep 17 00:00:00 2001 From: Christoph Hertzberg Date: Fri, 7 Sep 2018 14:08:39 +0200 Subject: [PATCH 16/21] Use `static const int` instead of `enum` to avoid numerous `local-type-template-args` warnings in C++03 mode --- unsupported/Eigen/src/EulerAngles/EulerSystem.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/unsupported/Eigen/src/EulerAngles/EulerSystem.h b/unsupported/Eigen/src/EulerAngles/EulerSystem.h index 65c2e94c7..88acabcf8 100644 --- a/unsupported/Eigen/src/EulerAngles/EulerSystem.h +++ b/unsupported/Eigen/src/EulerAngles/EulerSystem.h @@ -173,15 +173,14 @@ namespace Eigen EIGEN_EULER_ANGLES_CLASS_STATIC_ASSERT((unsigned)BetaAxisAbs != (unsigned)GammaAxisAbs, BETA_AXIS_CANT_BE_EQUAL_TO_GAMMA_AXIS); - enum - { + static const int // I, J, K are the pivot indexes permutation for the rotation matrix, that match this Euler system. // They are used in this class converters. // They are always different from each other, and their possible values are: 0, 1, or 2. I = AlphaAxisAbs - 1, J = (AlphaAxisAbs - 1 + 1 + IsOdd)%3, K = (AlphaAxisAbs - 1 + 2 - IsOdd)%3 - }; + ; // TODO: Get @mat parameter in form that avoids double evaluation. template From 6dcd2642aae67d0bc46eee959a9f196e6ea51e7c Mon Sep 17 00:00:00 2001 From: Jiandong Ruan Date: Sat, 8 Sep 2018 12:05:33 -0700 Subject: [PATCH 17/21] bug #1526 - CUDA compilation fails on CUDA 9.x SDK when arch is set to compute_60 and/or above --- Eigen/src/Core/arch/GPU/Half.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Eigen/src/Core/arch/GPU/Half.h b/Eigen/src/Core/arch/GPU/Half.h index b44a4356a..aef1eb079 100644 --- a/Eigen/src/Core/arch/GPU/Half.h +++ b/Eigen/src/Core/arch/GPU/Half.h @@ -272,7 +272,11 @@ namespace half_impl { // conversion steps back and forth. EIGEN_STRONG_INLINE __device__ half operator + (const half& a, const half& b) { +#if defined(EIGEN_CUDACC_VER) && EIGEN_CUDACC_VER >= 90000 + return __hadd(::__half(a), ::__half(b)); +#else return __hadd(a, b); +#endif } EIGEN_STRONG_INLINE __device__ half operator * (const half& a, const half& b) { return __hmul(a, b); @@ -281,9 +285,13 @@ EIGEN_STRONG_INLINE __device__ half operator - (const half& a, const half& b) { return __hsub(a, b); } EIGEN_STRONG_INLINE __device__ half operator / (const half& a, const half& b) { +#if defined(EIGEN_CUDACC_VER) && EIGEN_CUDACC_VER >= 90000 + return __hdiv(a, b); +#else float num = __half2float(a); float denom = __half2float(b); return __float2half(num / denom); +#endif } EIGEN_STRONG_INLINE __device__ half operator - (const half& a) { return __hneg(a); From a80a290079499a12246939d79e955dbce5f6fc4a Mon Sep 17 00:00:00 2001 From: Christoph Hertzberg Date: Mon, 10 Sep 2018 18:57:28 +0200 Subject: [PATCH 18/21] Fix 'template argument uses local type'-warnings (when compiled in C++03 mode) --- test/indexed_view.cpp | 10 ++++++++++ test/integer_types.cpp | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/test/indexed_view.cpp b/test/indexed_view.cpp index 7219c777f..e6ffe5a74 100644 --- a/test/indexed_view.cpp +++ b/test/indexed_view.cpp @@ -77,6 +77,9 @@ is_same_seq_type(const T1& a, const T2& b) #define VERIFY_EQ_INT(A,B) VERIFY_IS_APPROX(int(A),int(B)) +// C++03 does not allow local or unnamed enums as index +enum DummyEnum { XX=0, YY=1 }; + void check_indexed_view() { using Eigen::placeholders::all; @@ -375,9 +378,16 @@ void check_indexed_view() } // Check compilation of enums as index type: + a(XX) = 1; + A(XX,YY) = 1; + // Anonymous enums only work with C++11 +#if EIGEN_HAS_CXX11 enum { X=0, Y=1 }; a(X) = 1; A(X,Y) = 1; + A(XX,Y) = 1; + A(X,YY) = 1; +#endif // Check compilation of varying integer types as index types: Index i = n/2; diff --git a/test/integer_types.cpp b/test/integer_types.cpp index e9e514f12..3f9030d77 100644 --- a/test/integer_types.cpp +++ b/test/integer_types.cpp @@ -134,8 +134,8 @@ template void integer_type_tests(const MatrixType& m) template void integer_types_extra() { - VERIFY_IS_EQUAL(internal::scalar_div_cost::value, 8); - VERIFY_IS_EQUAL(internal::scalar_div_cost::value, 8); + VERIFY_IS_EQUAL(int(internal::scalar_div_cost::value), 8); + VERIFY_IS_EQUAL(int(internal::scalar_div_cost::value), 8); if(sizeof(long)>sizeof(int)) { VERIFY(int(internal::scalar_div_cost::value) > int(internal::scalar_div_cost::value)); VERIFY(int(internal::scalar_div_cost::value) > int(internal::scalar_div_cost::value)); From 2cbd9dd49806d686a40841b6d888a83c816efccf Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Fri, 7 Sep 2018 15:50:19 -0400 Subject: [PATCH 19/21] [PATCH] cmake: Support source include with add_subdirectory and find_package use This commit allows the sources of the project to be included in a parent project CMakeLists.txt and support use of "find_package(Eigen3 CONFIG REQUIRED)" Here is an example allowing to test the changes. It is not particularly useful in itself. This change will allow to support one of the scenario allowing to create custom 3D Slicer application bundling associated plugins. /tmp/eigen-git-mirror # Eigen sources /tmp/test/CMakeLists.txt: cmake_minimum_required(VERSION 3.12) project(test) add_subdirectory("/tmp/eigen-git-mirror" "eigen-git-mirror") find_package(Eigen3 CONFIG REQUIRED) and configuring it using: mkdir /tmp/test-build && cd $_ cmake \ -DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY:BOOL=1 \ -DEigen3_DIR:PATH=/tmp/test-build/eigen-git-mirror \ /tmp/test Co-authored-by: Pablo Hernandez --- CMakeLists.txt | 1 + cmake/Eigen3Config.cmake.in | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) --- CMakeLists.txt | 1 + cmake/Eigen3Config.cmake.in | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dbf0999ce..6d74709a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -538,6 +538,7 @@ if (NOT CMAKE_VERSION VERSION_LESS 3.0) # Imported target support add_library (eigen INTERFACE) + add_library (Eigen3::Eigen ALIAS eigen) target_compile_definitions (eigen INTERFACE ${EIGEN_DEFINITIONS}) target_include_directories (eigen INTERFACE diff --git a/cmake/Eigen3Config.cmake.in b/cmake/Eigen3Config.cmake.in index c5c546887..0a1ac61c9 100644 --- a/cmake/Eigen3Config.cmake.in +++ b/cmake/Eigen3Config.cmake.in @@ -3,7 +3,9 @@ @PACKAGE_INIT@ -include ("${CMAKE_CURRENT_LIST_DIR}/Eigen3Targets.cmake") +if (NOT TARGET eigen) + include ("${CMAKE_CURRENT_LIST_DIR}/Eigen3Targets.cmake") +endif () # Legacy variables, do *not* use. May be removed in the future. From 43fd42a33b484914ca92931ea63583b672c5e67b Mon Sep 17 00:00:00 2001 From: "luz.paz\"" Date: Wed, 1 Aug 2018 21:34:47 -0400 Subject: [PATCH 20/21] Fix doxy and misc. typos Found via `codespell -q 3 -I ../eigen-word-whitelist.txt` --- Eigen/src/Core/ProductEvaluators.h | 4 ++-- Eigen/src/Core/arch/GPU/Half.h | 2 +- Eigen/src/Core/util/Memory.h | 2 +- Eigen/src/Geometry/Hyperplane.h | 2 +- Eigen/src/Geometry/Transform.h | 2 +- Eigen/src/Geometry/Translation.h | 12 ++++++------ doc/PreprocessorDirectives.dox | 2 +- doc/TutorialGeometry.dox | 2 +- test/boostmultiprec.cpp | 2 +- test/triangular.cpp | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) --- Eigen/src/Core/ProductEvaluators.h | 4 ++-- Eigen/src/Core/arch/GPU/Half.h | 2 +- Eigen/src/Core/util/Memory.h | 2 +- Eigen/src/Geometry/Hyperplane.h | 2 +- Eigen/src/Geometry/Transform.h | 2 +- Eigen/src/Geometry/Translation.h | 12 ++++++------ doc/PreprocessorDirectives.dox | 2 +- doc/TutorialGeometry.dox | 2 +- test/boostmultiprec.cpp | 2 +- test/triangular.cpp | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Eigen/src/Core/ProductEvaluators.h b/Eigen/src/Core/ProductEvaluators.h index 0330b5741..2787987e7 100644 --- a/Eigen/src/Core/ProductEvaluators.h +++ b/Eigen/src/Core/ProductEvaluators.h @@ -20,7 +20,7 @@ namespace internal { /** \internal * Evaluator of a product expression. * Since products require special treatments to handle all possible cases, - * we simply deffer the evaluation logic to a product_evaluator class + * we simply defer the evaluation logic to a product_evaluator class * which offers more partial specialization possibilities. * * \sa class product_evaluator @@ -128,7 +128,7 @@ protected: PlainObject m_result; }; -// The following three shortcuts are enabled only if the scalar types match excatly. +// The following three shortcuts are enabled only if the scalar types match exactly. // TODO: we could enable them for different scalar types when the product is not vectorized. // Dense = Product diff --git a/Eigen/src/Core/arch/GPU/Half.h b/Eigen/src/Core/arch/GPU/Half.h index aef1eb079..65b38bbfb 100644 --- a/Eigen/src/Core/arch/GPU/Half.h +++ b/Eigen/src/Core/arch/GPU/Half.h @@ -60,7 +60,7 @@ struct __half_raw { #if defined(EIGEN_HAS_OLD_HIP_FP16) // Make a __half_raw definition that is // ++ compatible with that of Eigen and -// ++ add a implcit conversion to the native __half of the old HIP implementation. +// ++ add an implicit conversion to the native __half of the old HIP implementation. // // Keeping ".x" as "unsigned short" keeps the interface the same between the Eigen and HIP implementation. // diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h index 8dbd4d93b..056070159 100644 --- a/Eigen/src/Core/util/Memory.h +++ b/Eigen/src/Core/util/Memory.h @@ -177,7 +177,7 @@ EIGEN_DEVICE_FUNC inline void* aligned_malloc(std::size_t size) #endif #if EIGEN_DEFAULT_ALIGN_BYTES==16 - eigen_assert((size<16 || (std::size_t(result)%16)==0) && "System's malloc returned an unaligned pointer. Compile with EIGEN_MALLOC_ALREADY_ALIGNED=0 to fallback to handmade alignd memory allocator."); + eigen_assert((size<16 || (std::size_t(result)%16)==0) && "System's malloc returned an unaligned pointer. Compile with EIGEN_MALLOC_ALREADY_ALIGNED=0 to fallback to handmade aligned memory allocator."); #endif #else result = handmade_aligned_malloc(size); diff --git a/Eigen/src/Geometry/Hyperplane.h b/Eigen/src/Geometry/Hyperplane.h index 05929b299..cebe03557 100644 --- a/Eigen/src/Geometry/Hyperplane.h +++ b/Eigen/src/Geometry/Hyperplane.h @@ -119,7 +119,7 @@ public: * If the dimension of the ambient space is greater than 2, then there isn't uniqueness, * so an arbitrary choice is made. */ - // FIXME to be consitent with the rest this could be implemented as a static Through function ?? + // FIXME to be consistent with the rest this could be implemented as a static Through function ?? EIGEN_DEVICE_FUNC explicit Hyperplane(const ParametrizedLine& parametrized) { normal() = parametrized.direction().unitOrthogonal(); diff --git a/Eigen/src/Geometry/Transform.h b/Eigen/src/Geometry/Transform.h index 2d36dfadf..75991aaed 100644 --- a/Eigen/src/Geometry/Transform.h +++ b/Eigen/src/Geometry/Transform.h @@ -115,7 +115,7 @@ template struct transform_make_affine; * \end{array} \right) \f$ * * Note that for a projective transformation the last row can be anything, - * and then the interpretation of different parts might be sightly different. + * and then the interpretation of different parts might be slightly different. * * However, unlike a plain matrix, the Transform class provides many features * simplifying both its assembly and usage. In particular, it can be composed diff --git a/Eigen/src/Geometry/Translation.h b/Eigen/src/Geometry/Translation.h index 51d9a82eb..23b19f74f 100644 --- a/Eigen/src/Geometry/Translation.h +++ b/Eigen/src/Geometry/Translation.h @@ -70,18 +70,18 @@ public: /** Constructs and initialize the translation transformation from a vector of translation coefficients */ EIGEN_DEVICE_FUNC explicit inline Translation(const VectorType& vector) : m_coeffs(vector) {} - /** \brief Retruns the x-translation by value. **/ + /** \brief Returns the x-translation by value. **/ EIGEN_DEVICE_FUNC inline Scalar x() const { return m_coeffs.x(); } - /** \brief Retruns the y-translation by value. **/ + /** \brief Returns the y-translation by value. **/ EIGEN_DEVICE_FUNC inline Scalar y() const { return m_coeffs.y(); } - /** \brief Retruns the z-translation by value. **/ + /** \brief Returns the z-translation by value. **/ EIGEN_DEVICE_FUNC inline Scalar z() const { return m_coeffs.z(); } - /** \brief Retruns the x-translation as a reference. **/ + /** \brief Returns the x-translation as a reference. **/ EIGEN_DEVICE_FUNC inline Scalar& x() { return m_coeffs.x(); } - /** \brief Retruns the y-translation as a reference. **/ + /** \brief Returns the y-translation as a reference. **/ EIGEN_DEVICE_FUNC inline Scalar& y() { return m_coeffs.y(); } - /** \brief Retruns the z-translation as a reference. **/ + /** \brief Returns the z-translation as a reference. **/ EIGEN_DEVICE_FUNC inline Scalar& z() { return m_coeffs.z(); } EIGEN_DEVICE_FUNC const VectorType& vector() const { return m_coeffs; } diff --git a/doc/PreprocessorDirectives.dox b/doc/PreprocessorDirectives.dox index b49f7d3cf..d801798c9 100644 --- a/doc/PreprocessorDirectives.dox +++ b/doc/PreprocessorDirectives.dox @@ -66,7 +66,7 @@ functions by defining EIGEN_HAS_C99_MATH=1. Automatic detection disabled if EIGEN_MAX_CPP_VER<11. - \b EIGEN_HAS_CXX11_MATH - controls the implementation of some functions such as round, logp1, isinf, isnan, etc. Automatic detection disabled if EIGEN_MAX_CPP_VER<11. - - \b EIGEN_HAS_RVALUE_REFERENCES - defines whetehr rvalue references are supported + - \b EIGEN_HAS_RVALUE_REFERENCES - defines whether rvalue references are supported Automatic detection disabled if EIGEN_MAX_CPP_VER<11. - \b EIGEN_HAS_STD_RESULT_OF - defines whether std::result_of is supported Automatic detection disabled if EIGEN_MAX_CPP_VER<11. diff --git a/doc/TutorialGeometry.dox b/doc/TutorialGeometry.dox index 2e1420f98..86e9f1e72 100644 --- a/doc/TutorialGeometry.dox +++ b/doc/TutorialGeometry.dox @@ -111,7 +111,7 @@ rot3 = rot1.slerp(alpha,rot2);\endcode top\section TutorialGeoTransform Affine transformations -Generic affine transformations are represented by the Transform class which internaly +Generic affine transformations are represented by the Transform class which internally is a (Dim+1)^2 matrix. In Eigen we have chosen to not distinghish between points and vectors such that all points are actually represented by displacement vectors from the origin ( \f$ \mathbf{p} \equiv \mathbf{p}-0 \f$ ). With that in mind, real points and diff --git a/test/boostmultiprec.cpp b/test/boostmultiprec.cpp index 1588eb86d..579a6fd25 100644 --- a/test/boostmultiprec.cpp +++ b/test/boostmultiprec.cpp @@ -156,7 +156,7 @@ EIGEN_DECLARE_TEST(boostmultiprec) std::cout << "NumTraits::highest() = " << NumTraits::highest() << std::endl; std::cout << "NumTraits::digits10() = " << NumTraits::digits10() << std::endl; - // chekc stream output + // check stream output { Mat A(10,10); A.setRandom(); diff --git a/test/triangular.cpp b/test/triangular.cpp index 73b6fc46b..99ef1dcda 100644 --- a/test/triangular.cpp +++ b/test/triangular.cpp @@ -68,7 +68,7 @@ template void triangular_square(const MatrixType& m) while (numext::abs2(m1(i,i))(); Transpose trm4(m4); - // test back and forward subsitution with a vector as the rhs + // test back and forward substitution with a vector as the rhs m3 = m1.template triangularView(); VERIFY(v2.isApprox(m3.adjoint() * (m1.adjoint().template triangularView().solve(v2)), largerEps)); m3 = m1.template triangularView(); From 4827bec7768e5b58fb2e001d6c1360373d6dd0c2 Mon Sep 17 00:00:00 2001 From: Justin Carpentier Date: Tue, 11 Sep 2018 09:33:21 +0200 Subject: [PATCH 21/21] LLT: correct doc and add missing reference for the return type of rankUpdate --- Eigen/src/Cholesky/LLT.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- Eigen/src/Cholesky/LLT.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Eigen/src/Cholesky/LLT.h b/Eigen/src/Cholesky/LLT.h index 22e4be75d..868766365 100644 --- a/Eigen/src/Cholesky/LLT.h +++ b/Eigen/src/Cholesky/LLT.h @@ -100,7 +100,7 @@ template class LLT compute(matrix.derived()); } - /** \brief Constructs a LDLT factorization from a given matrix + /** \brief Constructs a LLT factorization from a given matrix * * This overloaded constructor is provided for \link InplaceDecomposition inplace decomposition \endlink when * \c MatrixType is a Eigen::Ref. @@ -200,7 +200,7 @@ template class LLT inline Index cols() const { return m_matrix.cols(); } template - LLT rankUpdate(const VectorType& vec, const RealScalar& sigma = 1); + LLT & rankUpdate(const VectorType& vec, const RealScalar& sigma = 1); #ifndef EIGEN_PARSED_BY_DOXYGEN template @@ -458,7 +458,7 @@ LLT& LLT::compute(const EigenBase */ template template -LLT<_MatrixType,_UpLo> LLT<_MatrixType,_UpLo>::rankUpdate(const VectorType& v, const RealScalar& sigma) +LLT<_MatrixType,_UpLo> & LLT<_MatrixType,_UpLo>::rankUpdate(const VectorType& v, const RealScalar& sigma) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorType); eigen_assert(v.size()==m_matrix.cols());