diff --git a/Eigen/Eigenvalues b/Eigen/Eigenvalues index c11f42ad4..803900058 100644 --- a/Eigen/Eigenvalues +++ b/Eigen/Eigenvalues @@ -15,6 +15,7 @@ #include "Householder" #include "LU" #include "Geometry" +#include "Sparse" // Needed by ComplexQZ. #include "src/Core/util/DisableStupidWarnings.h" diff --git a/Eigen/src/Core/arch/AVX/PacketMath.h b/Eigen/src/Core/arch/AVX/PacketMath.h index 0cd9e6cd6..b1dfb07ff 100644 --- a/Eigen/src/Core/arch/AVX/PacketMath.h +++ b/Eigen/src/Core/arch/AVX/PacketMath.h @@ -2831,7 +2831,7 @@ inline __m128i segment_mask_4x8(Index begin, Index count) { mask <<= CHAR_BIT * count; mask--; mask <<= CHAR_BIT * begin; -#if defined(_WIN32) && !defined(_WIN64) +#if !EIGEN_ARCH_x86_64 return _mm_loadl_epi64(reinterpret_cast(&mask)); #else return _mm_cvtsi64_si128(mask); @@ -2847,7 +2847,7 @@ inline __m128i segment_mask_8x8(Index begin, Index count) { mask <<= (CHAR_BIT / 2) * count; mask--; mask <<= CHAR_BIT * begin; -#if defined(_WIN32) && !defined(_WIN64) +#if !EIGEN_ARCH_x86_64 return _mm_loadl_epi64(reinterpret_cast(&mask)); #else return _mm_cvtsi64_si128(mask); diff --git a/Eigen/src/Eigenvalues/ComplexQZ.h b/Eigen/src/Eigenvalues/ComplexQZ.h index 20f2a77bb..ed32ea3da 100644 --- a/Eigen/src/Eigenvalues/ComplexQZ.h +++ b/Eigen/src/Eigenvalues/ComplexQZ.h @@ -14,8 +14,6 @@ #ifndef EIGEN_COMPLEX_QZ_H_ #define EIGEN_COMPLEX_QZ_H_ -#include "../../Sparse" - // IWYU pragma: private #include "./InternalHeaderCheck.h" @@ -126,9 +124,7 @@ class ComplexQZ { computeQZ ? n : (MatrixType::ColsAtCompileTime == Eigen::Dynamic ? 0 : MatrixType::ColsAtCompileTime)), m_ws(2 * n), m_computeQZ(computeQZ), - m_maxIters(maxIters){ - - }; + m_maxIters(maxIters) {} /** \brief Constructor. computes the QZ decomposition of given matrices * upon creation @@ -178,14 +174,14 @@ class ComplexQZ { * * \returns \c Success if computation was successfull, \c NoConvergence otherwise. */ - ComputationInfo info() const { return m_info; }; + ComputationInfo info() const { return m_info; } /** \brief number of performed QZ steps */ unsigned int iterations() const { eigen_assert(m_isInitialized && "ComplexQZ is not initialized."); return m_global_iter; - }; + } private: Index m_n; @@ -569,7 +565,9 @@ void ComplexQZ::push_down_zero_ST(Index k, Index l) { for (Index j = k + 1; j <= l; j++) { // Create a 0 at _T(j, j) J.makeGivens(m_T(j - 1, j), m_T(j, j), &m_T.coeffRef(j - 1, j)); - m_T.rightCols(m_n - j - 1).applyOnTheLeft(j - 1, j, J.adjoint()); + if (m_n - j - 1 > 0) { + m_T.rightCols(m_n - j - 1).applyOnTheLeft(j - 1, j, J.adjoint()); + } m_T.coeffRef(j, j) = Scalar(0); m_S.applyOnTheLeft(j - 1, j, J.adjoint()); diff --git a/Eigen/src/Householder/Householder.h b/Eigen/src/Householder/Householder.h index 96b1daf5f..e5d2d4fac 100644 --- a/Eigen/src/Householder/Householder.h +++ b/Eigen/src/Householder/Householder.h @@ -65,7 +65,6 @@ template EIGEN_DEVICE_FUNC void MatrixBase::makeHouseholder(EssentialPart& essential, Scalar& tau, RealScalar& beta) const { using numext::conj; - using numext::sqrt; EIGEN_STATIC_ASSERT_VECTOR_ONLY(EssentialPart) VectorBlock tail(derived(), 1, size() - 1); @@ -79,7 +78,7 @@ EIGEN_DEVICE_FUNC void MatrixBase::makeHouseholder(EssentialPart& essen beta = numext::real(c0); essential.setZero(); } else { - beta = sqrt(numext::abs2(c0) + tailSqNorm); + beta = numext::sqrt(numext::abs2(c0) + tailSqNorm); if (numext::real(c0) >= RealScalar(0)) beta = -beta; essential = tail / (c0 - beta); tau = conj((beta - c0) / beta); diff --git a/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h b/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h index 3c65541b8..97f214201 100644 --- a/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +++ b/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h @@ -89,7 +89,7 @@ struct simpl_chol_helper { m_set[u] = v; u = next; } - }; + } }; // Computes the higher adjacency pattern by transposing the input lower adjacency matrix. diff --git a/Eigen/src/SparseCore/SparseVector.h b/Eigen/src/SparseCore/SparseVector.h index d19a00dd9..c8d34e318 100644 --- a/Eigen/src/SparseCore/SparseVector.h +++ b/Eigen/src/SparseCore/SparseVector.h @@ -140,7 +140,7 @@ class SparseVector : public SparseCompressedBase=3.4.0 but <6.0.0. +find_package(Eigen3 3.4...5 REQUIRED NO_MODULE) # Any version >=3.4.1 but <6.0.0. ``` Do not forget to set the \c CMAKE_PREFIX_PATH variable if Eigen is not installed in a default location or if you want to pick a specific version. For instance: diff --git a/test/complex_qz.cpp b/test/complex_qz.cpp index a6b05dc92..28ab08e93 100644 --- a/test/complex_qz.cpp +++ b/test/complex_qz.cpp @@ -18,11 +18,9 @@ template void generate_random_matrix_pair(const Index dim, MatrixType& A, MatrixType& B) { - A.resize(dim, dim); - B.resize(dim, dim); - A.setRandom(); - B.setRandom(); - // Set each row of B with a probability of 10% to 0 + A.setRandom(dim, dim); + B.setRandom(dim, dim); + // Zero out each row of B to with a probability of 10%. for (int i = 0; i < dim; i++) { if (internal::random(0, 10) == 0) B.row(i).setZero(); } @@ -59,8 +57,6 @@ void complex_qz(const MatrixType& A, const MatrixType& B) { } EIGEN_DECLARE_TEST(complex_qz) { - // const Index dim1 = 15; - // const Index dim2 = 80; for (int i = 0; i < g_repeat; i++) { // Check for very small, fixed-sized double- and float complex matrices Eigen::Matrix2cd A_2x2, B_2x2; @@ -71,16 +67,18 @@ EIGEN_DECLARE_TEST(complex_qz) { A_3x3.setRandom(); B_3x3.setRandom(); B_3x3.col(i % 3).setRandom(); - // Test for small float complex matrices - Eigen::MatrixXcf A_float, B_float; - const Index dim1 = internal::random(15, 80), dim2 = internal::random(15, 80); - generate_random_matrix_pair(dim1, A_float, B_float); - // Test for a bit larger double complex matrices - Eigen::MatrixXcd A_double, B_double; - generate_random_matrix_pair(dim2, A_double, B_double); CALL_SUBTEST_1(complex_qz(A_2x2, B_2x2)); CALL_SUBTEST_2(complex_qz(A_3x3, B_3x3)); + + // Test for float complex matrices + const Index dim = internal::random(15, 80); + Eigen::MatrixXcf A_float, B_float; + generate_random_matrix_pair(dim, A_float, B_float); CALL_SUBTEST_3(complex_qz(A_float, B_float)); + + // Test for double complex matrices + Eigen::MatrixXcd A_double, B_double; + generate_random_matrix_pair(dim, A_double, B_double); CALL_SUBTEST_4(complex_qz(A_double, B_double)); } } diff --git a/test/main.h b/test/main.h index db4d484fb..fa7053e96 100644 --- a/test/main.h +++ b/test/main.h @@ -186,7 +186,7 @@ inline void on_temporary_creation(long int size, int) { namespace Eigen { static std::vector g_test_stack; -// level == 0 <=> abort if test fail +// level == 0 <=> return 1 if test fail // level >= 1 <=> warning message to std::cerr if test fail static int g_test_level = 0; static int g_repeat = 1; @@ -356,7 +356,7 @@ inline void verify_impl(bool condition, const char* testname, const char* file, const int test_stack_size = static_cast(Eigen::g_test_stack.size()); for (int i = test_stack_size - 1; i >= 0; --i) std::cerr << " - " << Eigen::g_test_stack[i] << "\n"; std::cerr << "\n"; - if (Eigen::g_test_level == 0) abort(); + if (Eigen::g_test_level == 0) exit(1); } } @@ -858,6 +858,12 @@ inline void set_seed_from_string(const char* str) { g_has_set_seed = true; } +inline void set_seed_from_time() { + using namespace std::chrono; + long long ns = duration_cast(high_resolution_clock::now().time_since_epoch()).count(); + g_seed = static_cast(ns); +} + int main(int argc, char* argv[]) { g_has_set_repeat = false; g_has_set_seed = false; @@ -896,7 +902,7 @@ int main(int argc, char* argv[]) { char* env_EIGEN_SEED = getenv("EIGEN_SEED"); if (!g_has_set_seed && env_EIGEN_SEED) set_seed_from_string(env_EIGEN_SEED); - if (!g_has_set_seed) g_seed = (unsigned int)time(NULL); + if (!g_has_set_seed) set_seed_from_time(); if (!g_has_set_repeat) g_repeat = DEFAULT_REPEAT; std::cout << "Initializing random number generator with seed " << g_seed << std::endl; diff --git a/unsupported/Eigen/src/Eigenvalues/ArpackSelfAdjointEigenSolver.h b/unsupported/Eigen/src/Eigenvalues/ArpackSelfAdjointEigenSolver.h index 54db9bf29..bc21d94cc 100644 --- a/unsupported/Eigen/src/Eigenvalues/ArpackSelfAdjointEigenSolver.h +++ b/unsupported/Eigen/src/Eigenvalues/ArpackSelfAdjointEigenSolver.h @@ -454,8 +454,16 @@ ArpackGeneralizedSelfAdjointEigenSolver::compu } } - if (!(mode == 1 && isBempty) && !(mode == 2 && isBempty) && OP.info() != Success) - std::cout << "Error factoring matrix" << std::endl; + if (!(mode == 1 && isBempty) && !(mode == 2 && isBempty) && OP.info() != Success) { + m_info = OP.info() delete[] v; + delete[] iparam; + delete[] ipntr; + delete[] workd; + delete[] workl; + delete[] resid; + m_isInitialized = false; + return *this; + } do { internal::arpack_wrapper::saupd(&ido, bmat, &n, whch, &nev, &tol, resid, &ncv, v, &ldv, iparam, @@ -572,7 +580,7 @@ ArpackGeneralizedSelfAdjointEigenSolver::compu delete[] workl; delete[] resid; - m_isInitialized = true; + m_isInitialized = (m_info == Success); return *this; }