Core: Fix compiler warnings from the CI build logs libeigen/eigen!3360
diff --git a/.agents/ci.md b/.agents/ci.md index 75f9123..d37c30a 100644 --- a/.agents/ci.md +++ b/.agents/ci.md
@@ -228,6 +228,66 @@ python3 scripts/add_spdx_headers.py --paths path/to/new-file.cpp ``` +## Compiler Warnings + +Test builds compile with the warning set in the top-level [`CMakeLists.txt`](../CMakeLists.txt) (`-Wall -Wextra`, +`-Wshorten-64-to-32`, `-Wdouble-promotion`, `-Wundef`, `-Wshadow`, among others), and no job fails on a warning. A +new warning therefore turns up only in a build log. Do not add a warning. When a new warning is a compiler false +positive, keep the code and say so in the merge request rather than suppressing it. Read the build-job logs of the +merge request pipeline, and compare them against a scheduled or web pipeline on the target branch. Those pipelines run +every build job, while default-branch pushes run only a few. Prefer one at the merge request's base commit; the newest +scheduled pipeline can be days older, and the master changes in between then show up in the diff: + +```bash +base=$(glab api "projects/libeigen%2Feigen/merge_requests/<iid>" | + python3 -c 'import json, sys; print(json.load(sys.stdin)["diff_refs"]["base_sha"])') +glab api "projects/libeigen%2Feigen/pipelines?sha=$base&per_page=100" | # base pipeline id, if one exists + python3 -c 'import json, sys; print(*[p["id"] for p in json.load(sys.stdin) if p["source"] in ("schedule", "web")][:1])' +glab api "projects/libeigen%2Feigen/pipelines?ref=master&source=schedule&per_page=1" # otherwise the newest scheduled +warnings() { # warnings() <pipeline-id>: one line per build job and warning site + glab api --paginate "projects/libeigen%2Feigen/pipelines/$1/jobs?per_page=100" | python3 -c ' +import json, sys +s, d, i = sys.stdin.read(), json.JSONDecoder(), 0 +while i < len(s): + page, i = d.raw_decode(s, i) + for j in page: + if j["stage"] == "build" and j["status"] in ("success", "failed"): print(j["id"], j["name"])' | + while read -r id name; do + name=${name%:affected} + glab api "projects/libeigen%2Feigen/jobs/$id/trace" | + sed -E 's/\x1b\[[0-9;]*[mK]//g; s/\r//; s/^[0-9-]+T[0-9:.]+Z [0-9A-Z]+ //' | + grep -E ': warning[: #]|warning C[0-9]{4}' | + sed -E "s|\\\\|/|g; s|^.*/eigen/||; s|:[0-9]+:[0-9]+:|:|; s|\([0-9]+\)||; s|^|$name: |" + done | sort -u +} +diff <(warnings <base-id>) <(warnings <mr-id>) +``` + +The normalization strips what differs between runs of the same warning: the `:affected` suffix that merge request +build jobs carry, the runners' per-line timestamps, line numbers in both the `file:12:3:` and the MSVC/nvcc +`file(12):` forms, and the checkout prefix, which on Windows is a backslash path with a per-run runner directory. +Without it, every warning in a merge request pipeline reads as new. A warning in a changed file that +appears on both sides can still come from a changed line, so check those as well. The default merge request +pipeline builds only the smoke targets. Most warnings below appear only in configurations that the `affected-tests` +labels enable. + +Many warnings show up in only one configuration, so an x86-64 build that compiles cleanly proves little: + +- 32-bit ARM, where `Index` is `int`: a `StorageIndex` of `long long` that is narrowed to `Index` + (`-Wshorten-64-to-32`), and a comparison of an unsigned `StorageIndex` with `Index` (`-Wsign-compare`). +- Clang with a `long double` scalar or reference: `-Wdouble-promotion`, including from direct initialization + `T x(0.5)`. Write `T(0.5)`. +- An `int` index type, as in Tensor contractions, which instantiate the GEMM/GEMV kernels with `Index = int`: + narrowing inside kernels written against `Eigen::Index`. +- gcc-10 (`-Wdeprecated-copy`, `-Wignored-attributes` on packet template arguments), MSVC (`C4xxx`), and nvcc + (`#177-D` for unused entities in a test split). + +Each build log prints its configure line (`+++ cmake -G Ninja ...`); rerun it locally, without the sccache launcher +and emulator arguments, to reproduce a job's warnings. `-fsyntax-only` with the commands from +`compile_commands.json` reports the same front-end warnings and needs no target libraries. To convert +`StorageIndex` to `Index`, use `internal::convert_index<Index>(x)`, or follow the local file's idiom. A warning from +a third-party build, such as Doxygen's own sources, is outside a change's scope. + ## Clang-Tidy Lint an implementation header with the CI driver below, not by running clang-tidy on it directly. The driver compiles @@ -278,7 +338,9 @@ 2. Format and check the task's changed lines and new files using the Worktree-Safe Formatting recipes above. 3. Run the focused builds and tests documented in [`testing.md`](testing.md). 4. Run applicable spelling, REUSE, and clang-tidy checks. -5. When the change touches Doxygen markup, a documented name, a module `README`, or a snippet, apply the `docs-build` +5. Check the build logs for new compiler warnings, as described under Compiler Warnings above, including the + configurations where `Index` or `StorageIndex` has a different width. +6. When the change touches Doxygen markup, a documented name, a module `README`, or a snippet, apply the `docs-build` label. The recommended test labels do not trigger the documentation job; [`docs.md`](docs.md) records its coverage and validation requirements. -6. State what ran, what did not run, and why. Do not claim coverage from jobs or hardware that were unavailable. +7. State what ran, what did not run, and why. Do not claim coverage from jobs or hardware that were unavailable.
diff --git a/Eigen/src/Core/MathFunctionsImpl.h b/Eigen/src/Core/MathFunctionsImpl.h index c455059..b97a069 100644 --- a/Eigen/src/Core/MathFunctionsImpl.h +++ b/Eigen/src/Core/MathFunctionsImpl.h
@@ -276,7 +276,7 @@ T b = atan2(z.imag(), z.real()); // log|z| is finite where |z| itself overflows or rounds to a subnormal: scale z exactly by a power of two first. if (EIGEN_PREDICT_FALSE((numext::isinf)(a) && (numext::isfinite)(z.real()) && (numext::isfinite)(z.imag()))) { - const T half(0.5); + const T half = T(0.5); return ComplexT(numext::log(numext::abs(ComplexT(z.real() * half, z.imag() * half))) + T(EIGEN_LN2), b); } if (EIGEN_PREDICT_FALSE(a < (numext::numeric_limits<T>::min)() && !numext::is_exactly_zero(a))) {
diff --git a/Eigen/src/Core/PermutationMatrix.h b/Eigen/src/Core/PermutationMatrix.h index 860d8fc..212f8f6 100644 --- a/Eigen/src/Core/PermutationMatrix.h +++ b/Eigen/src/Core/PermutationMatrix.h
@@ -142,7 +142,7 @@ template <typename DenseDerived> void evalTo(MatrixBase<DenseDerived>& other) const { other.setZero(); - for (Index i = 0; i < rows(); ++i) other.coeffRef(indices().coeff(i), i) = typename DenseDerived::Scalar(1); + for (Index i = 0; i < rows(); ++i) other.coeffRef(Index(indices().coeff(i)), i) = typename DenseDerived::Scalar(1); } #endif @@ -200,9 +200,9 @@ } } for (Index k = 0; k < size(); ++k) { - if (indices().coeff(k) == i) + if (indices().coeff(k) == StorageIndex(i)) indices().coeffRef(k) = StorageIndex(j); - else if (indices().coeff(k) == j) + else if (indices().coeff(k) == StorageIndex(j)) indices().coeffRef(k) = StorageIndex(i); } return derived(); @@ -245,7 +245,7 @@ protected: template <typename OtherDerived> void assignTranspose(const PermutationBase<OtherDerived>& other) { - for (Index i = 0; i < rows(); ++i) indices().coeffRef(other.indices().coeff(i)) = StorageIndex(i); + for (Index i = 0; i < rows(); ++i) indices().coeffRef(Index(other.indices().coeff(i))) = StorageIndex(i); } template <typename Lhs, typename Rhs> void assignProduct(const Lhs& lhs, const Rhs& rhs) { @@ -274,7 +274,7 @@ EIGEN_INTERNAL_ASSERT_SAME_ROWS(*this, rhs); PlainPermutationType result(size()); // (P * Q.inverse())(Q(i)) = P(i). - for (Index i = 0; i < size(); ++i) result.indices().coeffRef(rhs.indices().coeff(i)) = indices().coeff(i); + for (Index i = 0; i < size(); ++i) result.indices().coeffRef(Index(rhs.indices().coeff(i))) = indices().coeff(i); return result; } @@ -360,7 +360,7 @@ /** Constructs an uninitialized permutation matrix of given size. */ EIGEN_DEVICE_FUNC explicit PermutationMatrix(Index size) : m_indices(size) { - eigen_internal_assert(size <= NumTraits<StorageIndex>::highest()); + internal::convert_index<StorageIndex>(size); // asserts that size fits StorageIndex } /** Copy constructor. */ @@ -407,7 +407,7 @@ template <typename Other> PermutationMatrix(const InverseImpl<Other, PermutationStorage>& other) : m_indices(other.derived().nestedExpression().size()) { - eigen_internal_assert(m_indices.size() <= NumTraits<StorageIndex>::highest()); + internal::convert_index<StorageIndex>(m_indices.size()); // asserts that size fits StorageIndex Base::assignTranspose(other.derived().nestedExpression()); } template <typename Lhs, typename Rhs>
diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h index 15cf038..0620806 100644 --- a/Eigen/src/Core/Transpose.h +++ b/Eigen/src/Core/Transpose.h
@@ -247,9 +247,9 @@ using Packet = typename internal::packet_traits<typename MatrixType::Scalar>::type; const Index PacketSize = internal::packet_traits<Scalar>::size; EIGEN_INTERNAL_ASSERT_SQUARE(m); - int row_start = 0; + Index row_start = 0; for (; row_start + PacketSize <= m.rows(); row_start += PacketSize) { - for (int col_start = row_start; col_start + PacketSize <= m.cols(); col_start += PacketSize) { + for (Index col_start = row_start; col_start + PacketSize <= m.cols(); col_start += PacketSize) { PacketBlock<Packet> A; if (row_start == col_start) { for (Index i = 0; i < PacketSize; ++i)
diff --git a/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h b/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h index d2bb687..d93df65 100644 --- a/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h +++ b/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h
@@ -119,7 +119,7 @@ // If OpenBLAS with BUILD_BFLOAT16=1 support is available, // use sbgemm for bfloat16. -#if EIGEN_USE_OPENBLAS_BFLOAT16 +#if defined(EIGEN_USE_OPENBLAS_BFLOAT16) && EIGEN_USE_OPENBLAS_BFLOAT16 extern "C" { // OpenBLAS prototype.
diff --git a/Eigen/src/Core/products/GeneralMatrixVector.h b/Eigen/src/Core/products/GeneralMatrixVector.h index 040c5d5..95485c2 100644 --- a/Eigen/src/Core/products/GeneralMatrixVector.h +++ b/Eigen/src/Core/products/GeneralMatrixVector.h
@@ -81,7 +81,9 @@ }; template <typename Packet, int Order, typename Mapper> struct gemv_segment_loader<Packet, Order, Mapper, true> { - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet run(const Mapper& m, Index i, Index j, Index count) { + // i and j keep the kernel's index type, which is the mapper's. + template <typename RowIndex, typename ColIndex> + static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet run(const Mapper& m, RowIndex i, ColIndex j, Index count) { return ploaduSegment<Packet>(&m(i, j), 0, count); } };
diff --git a/Eigen/src/IterativeLinearSolvers/DGMRES.h b/Eigen/src/IterativeLinearSolvers/DGMRES.h index 0e7ed97..a5034ef 100644 --- a/Eigen/src/IterativeLinearSolvers/DGMRES.h +++ b/Eigen/src/IterativeLinearSolvers/DGMRES.h
@@ -163,7 +163,7 @@ * Set the number of eigenvalues to deflate at each restart */ void setEigenv(const Index neig) { - m_neig = neig; + m_neig = internal::convert_index<StorageIndex>(neig); if (neig + 1 > m_maxNeig) m_maxNeig = neig + 1; // To allow for complex conjugates }
diff --git a/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h b/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h index 7ad42e3..779a5d1 100644 --- a/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +++ b/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h
@@ -42,12 +42,13 @@ #ifndef EIGEN_NO_DEBUG const Index m_maxSize; Stack(StorageIndex* data, StorageIndex size, StorageIndex maxSize) - : m_data(data), m_size(size), m_maxSize(maxSize) { + : m_data(data), m_size(convert_index<Index>(size)), m_maxSize(convert_index<Index>(maxSize)) { eigen_assert(size >= 0); eigen_assert(maxSize >= size); } #else - Stack(StorageIndex* data, StorageIndex size, StorageIndex /*maxSize*/) : m_data(data), m_size(size) {} + Stack(StorageIndex* data, StorageIndex size, StorageIndex /*maxSize*/) + : m_data(data), m_size(convert_index<Index>(size)) {} #endif bool empty() const { return m_size == 0; } Index size() const { return m_size; } @@ -100,7 +101,7 @@ // Computes the outer index array of the higher adjacency matrix. static void calc_hadj_outer(const StorageIndex size, const CholMatrixType& ap, StorageIndex* outerIndex) { for (StorageIndex j = 1; j < size; j++) { - for (InnerIterator it(ap, j); it; ++it) { + for (InnerIterator it(ap, convert_index<Index>(j)); it; ++it) { StorageIndex i = it.index(); if (i < j) outerIndex[i + 1]++; } @@ -114,7 +115,7 @@ std::fill_n(tmp, size, 0); for (StorageIndex j = 1; j < size; j++) { - for (InnerIterator it(ap, j); it; ++it) { + for (InnerIterator it(ap, convert_index<Index>(j)); it; ++it) { StorageIndex i = it.index(); if (i < j) { StorageIndex b = outerIndex[i] + tmp[i]; @@ -139,7 +140,7 @@ DisjointSet ancestor(tmp, size); for (StorageIndex j = 1; j < size; j++) { - for (InnerIterator it(ap, j); it; ++it) { + for (InnerIterator it(ap, convert_index<Index>(j)); it; ++it) { StorageIndex i = it.index(); if (i < j) { StorageIndex r = ancestor.find(i); @@ -245,15 +246,15 @@ static void init_matrix(const StorageIndex size, const StorageIndex* nonZerosPerCol, CholMatrixType& L) { eigen_assert(L.outerIndexPtr()[0] == 0); std::partial_sum(nonZerosPerCol, nonZerosPerCol + size, L.outerIndexPtr() + 1); - L.resizeNonZeros(L.outerIndexPtr()[size]); + L.resizeNonZeros(convert_index<Index>(L.outerIndexPtr()[size])); } // Driver routine for the symbolic sparse Cholesky factorization. static void run(const StorageIndex size, const CholMatrixType& ap, CholMatrixType& L, VectorI& parent, VectorI& workSpace, bool doLDLT) { - parent.resize(size); - workSpace.resize(4 * size); - L.resize(size, size); + parent.resize(convert_index<Index>(size)); + workSpace.resize(4 * convert_index<Index>(size)); + L.resize(convert_index<Index>(size), convert_index<Index>(size)); StorageIndex* tmp1 = workSpace.data(); StorageIndex* tmp2 = workSpace.data() + size; @@ -264,7 +265,8 @@ StorageIndex* hadj_outer = L.outerIndexPtr(); calc_hadj_outer(size, ap, hadj_outer); // Request additional temporary storage for the inner indices of the higher adjacency pattern. - ei_declare_aligned_stack_constructed_variable(StorageIndex, hadj_inner, hadj_outer[size], nullptr); + ei_declare_aligned_stack_constructed_variable(StorageIndex, hadj_inner, convert_index<Index>(hadj_outer[size]), + nullptr); calc_hadj_inner(size, ap, hadj_outer, hadj_inner, tmp1); calc_etree(size, ap, parent.data(), tmp1); @@ -331,13 +333,13 @@ StorageIndex* Li = m_matrix.innerIndexPtr(); Scalar* Lx = m_matrix.valuePtr(); - ei_declare_aligned_stack_constructed_variable(Scalar, y, size, 0); + ei_declare_aligned_stack_constructed_variable(Scalar, y, internal::convert_index<Index>(size), 0); StorageIndex* nonZerosPerCol = m_workSpace.data(); StorageIndex* pattern = m_workSpace.data() + size; StorageIndex* tags = m_workSpace.data() + 2 * size; bool ok = true; - m_diag.resize(DoLDLT ? size : 0); + m_diag.resize(DoLDLT ? internal::convert_index<Index>(size) : 0); for (StorageIndex k = 0; k < size; ++k) { // compute nonzero pattern of kth row of L, in topological order @@ -345,12 +347,12 @@ StorageIndex top = size; // stack for pattern is empty tags[k] = k; // mark node k as visited nonZerosPerCol[k] = 0; // count of nonzeros in column k of L - for (typename CholMatrixType::InnerIterator it(ap, k); it; ++it) { + for (typename CholMatrixType::InnerIterator it(ap, internal::convert_index<Index>(k)); it; ++it) { StorageIndex i = it.index(); if (i <= k) { y[i] += getSymm(it.value()); /* scatter A(i,k) into Y (sum duplicates) */ Index len; - for (len = 0; tags[i] != k; i = m_parent[i]) { + for (len = 0; tags[i] != k; i = m_parent[internal::convert_index<Index>(i)]) { pattern[len++] = i; /* L(k,i) is nonzero */ tags[i] = k; /* mark i as visited */ } @@ -364,7 +366,7 @@ getDiag(y[k]) * m_shiftScale + m_shiftOffset; // get D(k,k), apply the shift function, and clear Y(k) y[k] = Scalar(0); for (; top < size; ++top) { - Index i = pattern[top]; /* pattern[top:n-1] is pattern of L(:,k) */ + Index i = internal::convert_index<Index>(pattern[top]); /* pattern[top:n-1] is pattern of L(:,k) */ Scalar yi = y[i]; /* get and clear Y(i) */ y[i] = Scalar(0); @@ -375,8 +377,8 @@ else yi = l_ki = yi / Lx[Lp[i]]; - Index p2 = Lp[i] + nonZerosPerCol[i]; - Index p = Lp[i] + (DoLDLT ? 0 : 1); + Index p2 = internal::convert_index<Index>(Lp[i] + nonZerosPerCol[i]); + Index p = internal::convert_index<Index>(Lp[i]) + (DoLDLT ? 0 : 1); EIGEN_IF_CONSTEXPR (UsePackets) p += internal::sparse_scatter_sub_packets<!NonHermitian>(y, Li + p, Lx + p, p2 - p, yi); for (; p < p2; ++p) y[Li[p]] -= getSymm(Lx[p]) * yi; @@ -386,13 +388,13 @@ ++nonZerosPerCol[i]; /* increment count of nonzeros in col i */ } EIGEN_IF_CONSTEXPR (DoLDLT) { - m_diag[k] = d; + m_diag[internal::convert_index<Index>(k)] = d; if (d == RealScalar(0)) { ok = false; /* failure, D(k,k) is zero */ break; } } else { - Index p = Lp[k] + nonZerosPerCol[k]++; + Index p = internal::convert_index<Index>(Lp[k] + nonZerosPerCol[k]++); Li[p] = k; /* store L(k,k) = sqrt (d) in column k */ bool failed; EIGEN_IF_CONSTEXPR (NonHermitian) {
diff --git a/Eigen/src/SparseCore/SparseAssign.h b/Eigen/src/SparseCore/SparseAssign.h index 3a75390..2a38b89 100644 --- a/Eigen/src/SparseCore/SparseAssign.h +++ b/Eigen/src/SparseCore/SparseAssign.h
@@ -210,7 +210,7 @@ dst.startVec(j); for (typename SrcEvaluatorType::InnerIterator it(srcEvaluator, j); it; ++it) { Scalar v = it.value(); - dst.insertBackByOuterInner(j, it.index()) = v; + dst.insertBackByOuterInner(j, Index(it.index())) = v; } } dst.finalize(); @@ -228,7 +228,7 @@ temp.startVec(j); for (typename SrcEvaluatorType::InnerIterator it(srcEvaluator, j); it; ++it) { Scalar v = it.value(); - temp.insertBackByOuterInner(transpose ? it.index() : j, transpose ? j : it.index()) = v; + temp.insertBackByOuterInner(transpose ? Index(it.index()) : j, transpose ? j : Index(it.index())) = v; } } temp.finalize();
diff --git a/Eigen/src/SparseCore/SparseCompressedBase.h b/Eigen/src/SparseCore/SparseCompressedBase.h index 5e948ca..be5342a 100644 --- a/Eigen/src/SparseCore/SparseCompressedBase.h +++ b/Eigen/src/SparseCore/SparseCompressedBase.h
@@ -68,9 +68,9 @@ else if (derived().outerSize() == 0) return 0; else if (isCompressed()) - return outerIndexPtr()[derived().outerSize()] - outerIndexPtr()[0]; + return internal::convert_index<Index>(outerIndexPtr()[derived().outerSize()] - outerIndexPtr()[0]); else - return innerNonZeros().sum(); + return internal::convert_index<Index>(innerNonZeros().sum()); } /** \returns a const pointer to the array of values. @@ -197,9 +197,9 @@ const Index outer = Derived::IsRowMajor ? row : col; const Index inner = Derived::IsRowMajor ? col : row; - Index start = this->outerIndexPtr()[outer]; - Index end = this->isCompressed() ? this->outerIndexPtr()[outer + 1] - : this->outerIndexPtr()[outer] + this->innerNonZeroPtr()[outer]; + Index start = internal::convert_index<Index>(this->outerIndexPtr()[outer]); + Index end = this->isCompressed() ? internal::convert_index<Index>(this->outerIndexPtr()[outer + 1]) + : start + internal::convert_index<Index>(this->innerNonZeroPtr()[outer]); eigen_assert(end >= start && "you are using a non finalized sparse matrix or written coefficient does not exist"); internal::LowerBoundIndex p; p.value = @@ -242,11 +242,11 @@ m_id = 0; m_end = mat.nonZeros(); } else { - m_id = mat.outerIndexPtr()[outer]; + m_id = internal::convert_index<Index>(mat.outerIndexPtr()[outer]); if (mat.isCompressed()) - m_end = mat.outerIndexPtr()[outer + 1]; + m_end = internal::convert_index<Index>(mat.outerIndexPtr()[outer + 1]); else - m_end = m_id + mat.innerNonZeroPtr()[outer]; + m_end = m_id + internal::convert_index<Index>(mat.innerNonZeroPtr()[outer]); } } @@ -279,8 +279,8 @@ inline StorageIndex index() const { return m_indices[m_id]; } inline Index outer() const { return m_outer.value(); } - inline Index row() const { return IsRowMajor ? m_outer.value() : index(); } - inline Index col() const { return IsRowMajor ? index() : m_outer.value(); } + inline Index row() const { return IsRowMajor ? m_outer.value() : Index(index()); } + inline Index col() const { return IsRowMajor ? Index(index()) : m_outer.value(); } inline operator bool() const { return m_id < m_end; } @@ -527,8 +527,9 @@ static inline void run(SparseCompressedBase<Derived>& obj, Index begin, Index end) { const bool is_compressed = obj.isCompressed(); for (Index outer = begin; outer < end; outer++) { - Index begin_offset = obj.outerIndexPtr()[outer]; - Index end_offset = is_compressed ? obj.outerIndexPtr()[outer + 1] : (begin_offset + obj.innerNonZeroPtr()[outer]); + Index begin_offset = internal::convert_index<Index>(obj.outerIndexPtr()[outer]); + Index end_offset = is_compressed ? internal::convert_index<Index>(obj.outerIndexPtr()[outer + 1]) + : (begin_offset + internal::convert_index<Index>(obj.innerNonZeroPtr()[outer])); CompressedStorageIterator<Scalar, StorageIndex> begin_it(begin_offset, obj.innerIndexPtr(), obj.valuePtr()); CompressedStorageIterator<Scalar, StorageIndex> end_it(end_offset, obj.innerIndexPtr(), obj.valuePtr()); std::sort(begin_it, end_it, Comp()); @@ -537,8 +538,9 @@ static inline Index check(const SparseCompressedBase<Derived>& obj, Index begin, Index end) { const bool is_compressed = obj.isCompressed(); for (Index outer = begin; outer < end; outer++) { - Index begin_offset = obj.outerIndexPtr()[outer]; - Index end_offset = is_compressed ? obj.outerIndexPtr()[outer + 1] : (begin_offset + obj.innerNonZeroPtr()[outer]); + Index begin_offset = internal::convert_index<Index>(obj.outerIndexPtr()[outer]); + Index end_offset = is_compressed ? internal::convert_index<Index>(obj.outerIndexPtr()[outer + 1]) + : (begin_offset + internal::convert_index<Index>(obj.innerNonZeroPtr()[outer])); const StorageIndex* begin_it = obj.innerIndexPtr() + begin_offset; const StorageIndex* end_it = obj.innerIndexPtr() + end_offset; bool is_sorted = std::is_sorted(begin_it, end_it, Comp());
diff --git a/Eigen/src/SparseCore/SparseCwiseBinaryOp.h b/Eigen/src/SparseCore/SparseCwiseBinaryOp.h index 341dcf6..a80e19e 100644 --- a/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +++ b/Eigen/src/SparseCore/SparseCwiseBinaryOp.h
@@ -82,16 +82,16 @@ EIGEN_STRONG_INLINE InnerIterator& operator++() { if (m_lhsIter && m_rhsIter && (m_lhsIter.index() == m_rhsIter.index())) { - m_id = m_lhsIter.index(); + m_id = convert_index<StorageIndex>(m_lhsIter.index()); m_value = m_functor(m_lhsIter.value(), m_rhsIter.value()); ++m_lhsIter; ++m_rhsIter; } else if (m_lhsIter && (!m_rhsIter || (m_lhsIter.index() < m_rhsIter.index()))) { - m_id = m_lhsIter.index(); + m_id = convert_index<StorageIndex>(m_lhsIter.index()); m_value = m_functor(m_lhsIter.value(), Scalar(0)); ++m_lhsIter; } else if (m_rhsIter && (!m_lhsIter || (m_lhsIter.index() > m_rhsIter.index()))) { - m_id = m_rhsIter.index(); + m_id = convert_index<StorageIndex>(m_rhsIter.index()); m_value = m_functor(Scalar(0), m_rhsIter.value()); ++m_rhsIter; } else {
diff --git a/Eigen/src/SparseCore/SparseMatrix.h b/Eigen/src/SparseCore/SparseMatrix.h index 4a90737..9295d0d 100644 --- a/Eigen/src/SparseCore/SparseMatrix.h +++ b/Eigen/src/SparseCore/SparseMatrix.h
@@ -383,7 +383,7 @@ m_outerIndex[m_outerSize] = m_outerIndex[m_outerSize - 1] + m_innerNonZeros[m_outerSize - 1] + internal::convert_index<StorageIndex>(reserveSizes[m_outerSize - 1]); - m_data.resize(m_outerIndex[m_outerSize]); + m_data.resize(internal::convert_index<Index>(m_outerIndex[m_outerSize])); } else { StorageIndex* newOuterIndex = internal::conditional_aligned_new_auto<StorageIndex, true>(m_outerSize + 1); @@ -403,7 +403,8 @@ StorageIndex innerNNZ = m_innerNonZeros[j]; StorageIndex begin = m_outerIndex[j]; StorageIndex target = newOuterIndex[j]; - m_data.moveChunk(begin, target, innerNNZ); + m_data.moveChunk(internal::convert_index<Index>(begin), internal::convert_index<Index>(target), + internal::convert_index<Index>(innerNNZ)); } std::swap(m_outerIndex, newOuterIndex); @@ -437,7 +438,7 @@ StorageIndex p = m_outerIndex[outer + 1]; ++m_outerIndex[outer + 1]; m_data.append(Scalar(0), inner); - return m_data.value(p); + return m_data.value(internal::convert_index<Index>(p)); } /** \internal @@ -569,11 +570,12 @@ Scalar& insertByOuterInner(Index j, Index i) { eigen_assert(j >= 0 && j < m_outerSize && "invalid outer index"); eigen_assert(i >= 0 && i < m_innerSize && "invalid inner index"); - Index start = m_outerIndex[j]; - Index end = isCompressed() ? m_outerIndex[j + 1] : start + m_innerNonZeros[j]; + Index start = internal::convert_index<Index>(m_outerIndex[j]); + Index end = isCompressed() ? internal::convert_index<Index>(m_outerIndex[j + 1]) + : start + internal::convert_index<Index>(m_innerNonZeros[j]); Index dst = start == end ? end : m_data.searchLowerIndex(start, end, i); if (dst == end) { - Index capacity = m_outerIndex[j + 1] - end; + Index capacity = internal::convert_index<Index>(m_outerIndex[j + 1]) - end; if (capacity > 0) { // implies uncompressed: push to back of vector m_innerNonZeros[j]++; @@ -597,23 +599,23 @@ StorageIndex start = m_outerIndex[1]; m_outerIndex[1] = m_innerNonZeros[0]; // try to move fewer, larger contiguous chunks - Index copyStart = start; - Index copyTarget = m_innerNonZeros[0]; + Index copyStart = internal::convert_index<Index>(start); + Index copyTarget = internal::convert_index<Index>(m_innerNonZeros[0]); for (Index j = 1; j < m_outerSize; j++) { StorageIndex end = start + m_innerNonZeros[j]; StorageIndex nextStart = m_outerIndex[j + 1]; // dont forget to move the last chunk! bool breakUpCopy = (end != nextStart) || (j == m_outerSize - 1); if (breakUpCopy) { - Index chunkSize = end - copyStart; + Index chunkSize = internal::convert_index<Index>(end) - copyStart; if (chunkSize > 0) m_data.moveChunk(copyStart, copyTarget, chunkSize); - copyStart = nextStart; + copyStart = internal::convert_index<Index>(nextStart); copyTarget += chunkSize; } start = nextStart; m_outerIndex[j + 1] = m_outerIndex[j] + m_innerNonZeros[j]; } - m_data.resize(m_outerIndex[m_outerSize]); + m_data.resize(internal::convert_index<Index>(m_outerIndex[m_outerSize])); // release as much memory as possible internal::conditional_aligned_delete_auto<StorageIndex, true>(m_innerNonZeros, m_outerSize); @@ -1678,9 +1680,9 @@ // find a vector with capacity, starting at `outer` and searching to the left and right for (Index leftTarget = outer - 1, rightTarget = outer; (leftTarget >= 0) || (rightTarget < m_outerSize);) { if (rightTarget < m_outerSize) { - Index start = m_outerIndex[rightTarget]; - Index end = start + m_innerNonZeros[rightTarget]; - Index nextStart = m_outerIndex[rightTarget + 1]; + Index start = internal::convert_index<Index>(m_outerIndex[rightTarget]); + Index end = start + internal::convert_index<Index>(m_innerNonZeros[rightTarget]); + Index nextStart = internal::convert_index<Index>(m_outerIndex[rightTarget + 1]); Index capacity = nextStart - end; if (capacity > 0) { // move [dst, end) to dst+1 and insert at dst @@ -1695,9 +1697,9 @@ rightTarget++; } if (leftTarget >= 0) { - Index start = m_outerIndex[leftTarget]; - Index end = start + m_innerNonZeros[leftTarget]; - Index nextStart = m_outerIndex[leftTarget + 1]; + Index start = internal::convert_index<Index>(m_outerIndex[leftTarget]); + Index end = start + internal::convert_index<Index>(m_innerNonZeros[leftTarget]); + Index nextStart = internal::convert_index<Index>(m_outerIndex[leftTarget + 1]); Index capacity = nextStart - end; if (capacity > 0) { // tricky: dst is a lower bound, so we must insert at dst-1 when shifting left @@ -1717,7 +1719,7 @@ // no room for interior insertion // nonZeros() == m_data.size() // record offset as outerIndexPtr will change - Index dst_offset = dst - m_outerIndex[outer]; + Index dst_offset = dst - internal::convert_index<Index>(m_outerIndex[outer]); // allocate space for random insertion if (m_data.allocatedSize() == 0) { // fast method to allocate space for one element per vector in empty matrix @@ -1744,8 +1746,8 @@ } } // insert element at `dst` with new outer indices - Index start = m_outerIndex[outer]; - Index end = start + m_innerNonZeros[outer]; + Index start = internal::convert_index<Index>(m_outerIndex[outer]); + Index end = start + internal::convert_index<Index>(m_innerNonZeros[outer]); Index new_dst = start + dst_offset; Index chunkSize = end - new_dst; if (chunkSize > 0) m_data.moveChunk(new_dst, new_dst + 1, chunkSize);
diff --git a/Eigen/src/SparseCore/SparseSelfAdjointView.h b/Eigen/src/SparseCore/SparseSelfAdjointView.h index f49089a..a6a653e 100644 --- a/Eigen/src/SparseCore/SparseSelfAdjointView.h +++ b/Eigen/src/SparseCore/SparseSelfAdjointView.h
@@ -454,12 +454,12 @@ count.setZero(); dest.resize(size, size); for (Index j = 0; j < size; ++j) { - Index jp = perm ? perm[j] : j; + Index jp = perm ? internal::convert_index<Index>(perm[j]) : j; for (MatIterator it(matEval, j); it; ++it) { - Index i = it.index(); + Index i = internal::convert_index<Index>(it.index()); Index r = it.row(); Index c = it.col(); - Index ip = perm ? perm[i] : i; + Index ip = perm ? internal::convert_index<Index>(perm[i]) : i; EIGEN_IF_CONSTEXPR (Mode == int(Upper | Lower)) count[StorageOrderMatch ? jp : ip]++; else if (r == c) @@ -470,7 +470,7 @@ } } } - Index nnz = count.sum(); + Index nnz = internal::convert_index<Index>(count.sum()); // reserve space dest.resizeNonZeros(nnz); @@ -480,7 +480,7 @@ // copy data for (StorageIndex j = 0; j < size; ++j) { - for (MatIterator it(matEval, j); it; ++it) { + for (MatIterator it(matEval, internal::convert_index<Index>(j)); it; ++it) { StorageIndex i = internal::convert_index<StorageIndex>(it.index()); Index r = it.row(); Index c = it.col(); @@ -489,19 +489,19 @@ StorageIndex ip = perm ? perm[i] : i; EIGEN_IF_CONSTEXPR (Mode == int(Upper | Lower)) { - Index k = count[StorageOrderMatch ? jp : ip]++; + StorageIndex k = count[internal::convert_index<Index>(StorageOrderMatch ? jp : ip)]++; dest.innerIndexPtr()[k] = StorageOrderMatch ? ip : jp; dest.valuePtr()[k] = it.value(); } else if (r == c) { - Index k = count[ip]++; + StorageIndex k = count[internal::convert_index<Index>(ip)]++; dest.innerIndexPtr()[k] = ip; dest.valuePtr()[k] = it.value(); } else if (((Mode & Lower) == Lower && r > c) || ((Mode & Upper) == Upper && r < c)) { EIGEN_IF_CONSTEXPR (!StorageOrderMatch) std::swap(ip, jp); - Index k = count[jp]++; + StorageIndex k = count[internal::convert_index<Index>(jp)]++; dest.innerIndexPtr()[k] = ip; dest.valuePtr()[k] = it.value(); - k = count[ip]++; + k = count[internal::convert_index<Index>(ip)]++; dest.innerIndexPtr()[k] = jp; dest.valuePtr()[k] = (NonHermitian ? it.value() : numext::conj(it.value())); } @@ -535,28 +535,29 @@ dest.resize(size, size); for (StorageIndex j = 0; j < size; ++j) { StorageIndex jp = perm ? perm[j] : j; - for (MatIterator it(matEval, j); it; ++it) { + for (MatIterator it(matEval, internal::convert_index<Index>(j)); it; ++it) { StorageIndex i = it.index(); if ((int(SrcMode) == int(Lower) && i < j) || (int(SrcMode) == int(Upper) && i > j)) continue; StorageIndex ip = perm ? perm[i] : i; - count[int(DstMode) == int(Lower) ? (std::min)(ip, jp) : (std::max)(ip, jp)]++; + count[internal::convert_index<Index>(int(DstMode) == int(Lower) ? (std::min)(ip, jp) : (std::max)(ip, jp))]++; } } dest.outerIndexPtr()[0] = 0; for (Index j = 0; j < size; ++j) dest.outerIndexPtr()[j + 1] = dest.outerIndexPtr()[j] + count[j]; - dest.resizeNonZeros(dest.outerIndexPtr()[size]); + dest.resizeNonZeros(internal::convert_index<Index>(dest.outerIndexPtr()[size])); for (Index j = 0; j < size; ++j) count[j] = dest.outerIndexPtr()[j]; for (StorageIndex j = 0; j < size; ++j) { - for (MatIterator it(matEval, j); it; ++it) { + for (MatIterator it(matEval, internal::convert_index<Index>(j)); it; ++it) { StorageIndex i = it.index(); if ((int(SrcMode) == int(Lower) && i < j) || (int(SrcMode) == int(Upper) && i > j)) continue; StorageIndex jp = perm ? perm[j] : j; StorageIndex ip = perm ? perm[i] : i; - Index k = count[int(DstMode) == int(Lower) ? (std::min)(ip, jp) : (std::max)(ip, jp)]++; + StorageIndex k = + count[internal::convert_index<Index>(int(DstMode) == int(Lower) ? (std::min)(ip, jp) : (std::max)(ip, jp))]++; dest.innerIndexPtr()[k] = int(DstMode) == int(Lower) ? (std::max)(ip, jp) : (std::min)(ip, jp); EIGEN_IF_CONSTEXPR (!StorageOrderMatch) std::swap(ip, jp);
diff --git a/Eigen/src/SparseCore/SparseTriangularView.h b/Eigen/src/SparseCore/SparseTriangularView.h index 01f9fcf..83bcb6f 100644 --- a/Eigen/src/SparseCore/SparseTriangularView.h +++ b/Eigen/src/SparseCore/SparseTriangularView.h
@@ -144,8 +144,8 @@ } } - inline Index row() const { return (ArgType::Flags & RowMajorBit ? Base::outer() : this->index()); } - inline Index col() const { return (ArgType::Flags & RowMajorBit ? this->index() : Base::outer()); } + inline Index row() const { return (ArgType::Flags & RowMajorBit ? Base::outer() : Index(this->index())); } + inline Index col() const { return (ArgType::Flags & RowMajorBit ? Index(this->index()) : Base::outer()); } inline StorageIndex index() const { EIGEN_IF_CONSTEXPR (HasUnitDiag) { if (m_returnOne) return internal::convert_index<StorageIndex>(Base::outer());
diff --git a/contrib/Eigen/src/StructuredMatrices/KroneckerSparseView.h b/contrib/Eigen/src/StructuredMatrices/KroneckerSparseView.h index cdc6366..dd5664e 100644 --- a/contrib/Eigen/src/StructuredMatrices/KroneckerSparseView.h +++ b/contrib/Eigen/src/StructuredMatrices/KroneckerSparseView.h
@@ -163,8 +163,8 @@ kron_view_iterator(const Factor& f, Index outer) : m_values(f.valuePtr()), m_indices(f.innerIndexPtr()), - m_pos(f.outerIndexPtr()[outer]), - m_end(f.outerIndexPtr()[outer + 1]) { + m_pos(convert_index<Index>(f.outerIndexPtr()[outer])), + m_end(convert_index<Index>(f.outerIndexPtr()[outer + 1])) { eigen_internal_assert(f.isCompressed()); } explicit operator bool() const { return m_pos < m_end; } @@ -172,7 +172,7 @@ ++m_pos; return *this; } - Index index() const { return m_indices[m_pos]; } + Index index() const { return Index(m_indices[m_pos]); } Scalar value() const { return m_values[m_pos]; } private:
diff --git a/contrib/test/GPU/cusolver_llt.cpp b/contrib/test/GPU/cusolver_llt.cpp index 5c7a533..377cc1b 100644 --- a/contrib/test/GPU/cusolver_llt.cpp +++ b/contrib/test/GPU/cusolver_llt.cpp
@@ -41,7 +41,7 @@ std::atomic<bool> release{false}; }; -static void CUDART_CB wait_for_host_input_gate(void* data) { +EIGEN_UNUSED static void CUDART_CB wait_for_host_input_gate(void* data) { HostInputGate* gate = static_cast<HostInputGate*>(data); gate->entered.store(true, std::memory_order_release); while (!gate->release.load(std::memory_order_acquire)) std::this_thread::yield();
diff --git a/test/eigensolver_selfadjoint.cpp b/test/eigensolver_selfadjoint.cpp index cc0c915..f22b822 100644 --- a/test/eigensolver_selfadjoint.cpp +++ b/test/eigensolver_selfadjoint.cpp
@@ -1195,7 +1195,7 @@ using MatrixType = Matrix<Scalar, 3, 3, Options>; using WideMatrix = Matrix<long double, 3, 3>; using WideVector = Matrix<long double, 3, 1>; - const long double epsilon = NumTraits<Scalar>::epsilon(); + const long double epsilon = static_cast<long double>(NumTraits<Scalar>::epsilon()); const Scalar scale = numext::ldexp(Scalar(1), std::numeric_limits<Scalar>::max_exponent - 1); const long double repeated = 2 - 64 * epsilon; const long double tolerance = 48 * epsilon;
diff --git a/test/fp_control.h b/test/fp_control.h index af578d6..e0e9d5d 100644 --- a/test/fp_control.h +++ b/test/fp_control.h
@@ -93,7 +93,7 @@ #if EIGEN_TEST_HAS_X86_DAZ if (flushToZeroModeIncludes(requested, FlushToZeroMode::Inputs)) wanted |= x86DenormalsAreZeroMask(); #endif - _mm_setcsr(static_cast<unsigned int>((control_state_ & ~x86FlushMask()) | wanted)); + _mm_setcsr(static_cast<unsigned int>((static_cast<std::uint32_t>(control_state_) & ~x86FlushMask()) | wanted)); restore_ = true; const std::uint32_t actual = static_cast<std::uint32_t>(_mm_getcsr()) & x86FlushMask(); mode_ = static_cast<FlushToZeroMode>(((actual & x86FlushToZeroMask()) != 0 ? 1 : 0) |
diff --git a/test/packetmath_gpu.cu b/test/packetmath_gpu.cu index 58eea92..e87291c 100644 --- a/test/packetmath_gpu.cu +++ b/test/packetmath_gpu.cu
@@ -38,7 +38,7 @@ } // namespace test } // namespace Eigen -namespace { +namespace packetmath_gpu_test { using Eigen::Index; using Eigen::internal::packet_traits; @@ -49,19 +49,9 @@ using test::Buffer; using test::packet_layout; -// Named budgets. rsqrt is the one approximate intrinsic among the core operations: the CUDA Math API documents -// 2 ulp for rsqrtf and 1 ulp for rsqrt. The float reference rounds 1/sqrt from double. The double reference uses -// long double, which is double itself under MSVC; rounding y = sqrt(x) and then 1/y is still within 1.5 ulp of -// 1/sqrt(x), so a device result within 1 ulp is at most 2 representable steps from the reference. -const uint64_t kRsqrtFloatUlps = 3; -const uint64_t kRsqrtDoubleUlps = 2; -// The CUDA Math API's documented maximum error for each function, plus one for the rounding of the reference from -// the wider type. The Windows CRT expm1 reference can be 3 ulps off, and its long double has no extra precision. struct MathUlpBudget { uint64_t log, log1p, exp, exp2, expm1; }; -const MathUlpBudget kFloatUlps = {2, 2, 3, 3, 2}; -const MathUlpBudget kDoubleUlps = {2, 2, 2, 2, EIGEN_COMP_MSVC ? 3 : 2}; // The reference uses the next floating-point type; long double is not wider on MSVC. template <typename Scalar> @@ -658,7 +648,10 @@ void packetmath_gpu_real_math() { using Packet = typename packet_traits<Scalar>::type; const int kSize = packet_layout<Packet>::kSize; - const MathUlpBudget& budget = std::is_same<Scalar, double>::value ? kDoubleUlps : kFloatUlps; + // The CUDA Math API's documented maximum error for each function, plus one for the rounding of the reference from + // the wider type. The Windows CRT expm1 reference can be 3 ulps off, and its long double has no extra precision. + const MathUlpBudget budget = std::is_same<Scalar, double>::value ? MathUlpBudget{2, 2, 2, 2, EIGEN_COMP_MSVC ? 3 : 2} + : MathUlpBudget{2, 2, 3, 3, 2}; const std::vector<int> traits = device_traits<Scalar>(); VERIFY_IS_EQUAL(traits[kHasExp], 1); @@ -735,7 +728,11 @@ const compare_bits<Scalar> bits{true}; const compare_bits<Scalar> bits_and_payload{false}; const auto values = test::areEqual<Scalar>; - const uint64_t rsqrt_ulps = std::is_same<Scalar, double>::value ? kRsqrtDoubleUlps : kRsqrtFloatUlps; + // rsqrt is the one approximate intrinsic among the core operations: the CUDA Math API documents 2 ulp for rsqrtf + // and 1 ulp for rsqrt. The float reference rounds 1/sqrt from double. The double reference uses long double, which + // is double itself under MSVC; rounding y = sqrt(x) and then 1/y is still within 1.5 ulp of 1/sqrt(x), so a device + // result within 1 ulp is at most 2 representable steps from the reference. + const uint64_t rsqrt_ulps = std::is_same<Scalar, double>::value ? 2 : 3; // The device's view of the type, and what this part covers of it. const std::vector<int> traits = device_traits<Scalar>(); @@ -1333,7 +1330,9 @@ VERIFY(clamped(1) >= 0.0f && clamped(1) <= 1.0f); } -} // namespace +} // namespace packetmath_gpu_test + +using namespace packetmath_gpu_test; EIGEN_DECLARE_TEST(packetmath_gpu) { ei_test_init_gpu();
diff --git a/test/sparse_product.cpp b/test/sparse_product.cpp index 6ae13be..a9c2a49 100644 --- a/test/sparse_product.cpp +++ b/test/sparse_product.cpp
@@ -10,14 +10,13 @@ static long int nb_temporaries; -template <typename = void> inline void on_temporary_creation() { // here's a great place to set a breakpoint when debugging failures in this test! nb_temporaries++; } #define EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN \ - { on_temporary_creation<>(); } + { on_temporary_creation(); } #include "sparse.h"
diff --git a/test/sparse_scatter.cpp b/test/sparse_scatter.cpp index f944d70..6f2af7b 100644 --- a/test/sparse_scatter.cpp +++ b/test/sparse_scatter.cpp
@@ -36,7 +36,7 @@ for (Index size = 0; size <= 65; ++size) { const Map<const Vector> values(storage.data() + 1, size); actual = expected = initial; - for (Index i = 0; i < size; ++i) expected[indices[i]] -= scale * numext::conj(values[i]); + for (Index i = 0; i < size; ++i) expected[Index(indices[i])] -= scale * numext::conj(values[i]); const Index expectedProcessed = apply_sparse_scatter(actual.data(), indices.data(), scale * values.conjugate()); VERIFY((actual - expected).cwiseAbs().maxCoeff() <= tolerance); @@ -44,12 +44,12 @@ const Index processed = internal::sparse_scatter_sub_packets<true>(actual.data(), indices.data(), values.data(), size, scale); VERIFY_IS_EQUAL(processed, expectedProcessed); - for (Index i = processed; i < size; ++i) actual[indices[i]] -= numext::conj(values[i]) * scale; + for (Index i = processed; i < size; ++i) actual[Index(indices[i])] -= numext::conj(values[i]) * scale; VERIFY((actual - expected).cwiseAbs().maxCoeff() <= tolerance); const Map<const Vector, Unaligned, InnerStride<2>> strided(storage.data() + 1, size); actual = expected = initial; - for (Index i = 0; i < size; ++i) expected[indices[i]] -= strided[i] * scale; + for (Index i = 0; i < size; ++i) expected[Index(indices[i])] -= strided[i] * scale; apply_sparse_scatter(actual.data(), indices.data(), strided * scale); VERIFY((actual - expected).cwiseAbs().maxCoeff() <= tolerance); }
diff --git a/test/tridiagonal_eigensolver.cpp b/test/tridiagonal_eigensolver.cpp index 84cd996..b2ab6c8 100644 --- a/test/tridiagonal_eigensolver.cpp +++ b/test/tridiagonal_eigensolver.cpp
@@ -456,7 +456,7 @@ d << RealScalar(1), RealScalar(0), RealScalar(0); e << RealScalar(0), c * eps; for (const auto& range : {EigenvalueRange::all(), EigenvalueRange::indices(0, 2), EigenvalueRange::indices(1, 2), - EigenvalueRange::values(-0.5, 0.5)}) { + EigenvalueRange::values(-0.5L, 0.5L)}) { TridiagonalEigenSolver<RealScalar> blocks; blocks.computeEigenvalues(d, e, range); const VectorType values = blocks.eigenvalues();
diff --git a/test/trig_sign_fastmath.cpp b/test/trig_sign_fastmath.cpp index 57f3ad1..fe3f992 100644 --- a/test/trig_sign_fastmath.cpp +++ b/test/trig_sign_fastmath.cpp
@@ -17,7 +17,7 @@ static Packet eval(const Packet& p, std::integral_constant<int, 2>) { return internal::ptan(p); } static void run() { - constexpr Index kSize = internal::unpacket_traits<Packet>::size; + constexpr Index kSize = internal::packet_traits<Scalar>::size; const Index n = numext::maxi<Index>(32, kSize); std::vector<Scalar> x(n), y(n); // +-(0.3 + 0.7 k) covers all four quadrants with sin, cos and tan bounded away from 0.
diff --git a/test/umeyama.cpp b/test/umeyama.cpp index 5701da9..984144f 100644 --- a/test/umeyama.cpp +++ b/test/umeyama.cpp
@@ -48,7 +48,7 @@ } template <typename MatrixType> -void run_test(int dim, int num_elements) { +void run_test(unsigned dim, int num_elements) { using std::abs; typedef typename internal::traits<MatrixType>::Scalar Scalar; typedef Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> MatrixX; @@ -118,7 +118,7 @@ const int num_elements = internal::random<int>(40, 500); // works also for dimensions bigger than 3... - for (int dim = 2; dim < 8; ++dim) { + for (unsigned dim = 2; dim < 8; ++dim) { CALL_SUBTEST_1(run_test<MatrixXd>(dim, num_elements)); CALL_SUBTEST_2(run_test<MatrixXf>(dim, num_elements)); }
diff --git a/test/unary_pow.cpp b/test/unary_pow.cpp index 31c4534..7e5b656 100644 --- a/test/unary_pow.cpp +++ b/test/unary_pow.cpp
@@ -501,7 +501,8 @@ for (int n = -12; n <= 12; ++n) { if (n == 0) continue; double tiny = std::copysign(std::ldexp(1.0, -60), double(s)); - std::complex<double> w = swapped ? std::complex<double>(tiny, a) : std::complex<double>(a, tiny); + std::complex<double> w = + swapped ? std::complex<double>(tiny, double(a)) : std::complex<double>(double(a), tiny); if (n < 0) w = std::conj(w) / std::norm(w); std::complex<double> reference = w; for (int k = 1; k < numext::abs(n); ++k) reference *= w;