From 054aa2dd796411238b8667fafd2ffb40e016469f Mon Sep 17 00:00:00 2001 From: xsjk Date: Sun, 22 Dec 2024 15:24:44 +0800 Subject: [PATCH 1/2] Replace std::copy with manual copy to support EIGEN_DEVICE_FUNC --- Eigen/src/Core/PlainObjectBase.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Eigen/src/Core/PlainObjectBase.h b/Eigen/src/Core/PlainObjectBase.h index 22f132982..8a5401438 100644 --- a/Eigen/src/Core/PlainObjectBase.h +++ b/Eigen/src/Core/PlainObjectBase.h @@ -525,7 +525,10 @@ class PlainObjectBase : public internal::dense_xpr_base::type eigen_assert(list_size == static_cast(RowsAtCompileTime) || RowsAtCompileTime == Dynamic); resize(list_size, ColsAtCompileTime); if (list.begin()->begin() != nullptr) { - std::copy(list.begin()->begin(), list.begin()->end(), m_storage.data()); + Index index = 0; + for (const Scalar& e : *list.begin()) { + coeffRef(index++) = e; + } } } else { eigen_assert(list.size() == static_cast(RowsAtCompileTime) || RowsAtCompileTime == Dynamic); -- GitLab From 2ae140ebc97854b9ba6aa2d922b9eee88d8e8da0 Mon Sep 17 00:00:00 2001 From: xsjk Date: Wed, 25 Dec 2024 00:41:29 +0800 Subject: [PATCH 2/2] Add missing EIGEN_DEVICE_FUNC in DiagonalMatrix.h --- Eigen/src/Core/DiagonalMatrix.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Eigen/src/Core/DiagonalMatrix.h b/Eigen/src/Core/DiagonalMatrix.h index 248e4586f..4115b64fe 100644 --- a/Eigen/src/Core/DiagonalMatrix.h +++ b/Eigen/src/Core/DiagonalMatrix.h @@ -389,8 +389,9 @@ struct AssignmentKind { // Diagonal matrix to Dense assignment template struct Assignment { - static void run(DstXprType& dst, const SrcXprType& src, - const internal::assign_op& /*func*/) { + static EIGEN_DEVICE_FUNC void run( + DstXprType& dst, const SrcXprType& src, + const internal::assign_op& /*func*/) { Index dstRows = src.rows(); Index dstCols = src.cols(); if ((dst.rows() != dstRows) || (dst.cols() != dstCols)) dst.resize(dstRows, dstCols); @@ -399,13 +400,15 @@ struct Assignment { dst.diagonal() = src.diagonal(); } - static void run(DstXprType& dst, const SrcXprType& src, - const internal::add_assign_op& /*func*/) { + static EIGEN_DEVICE_FUNC void run( + DstXprType& dst, const SrcXprType& src, + const internal::add_assign_op& /*func*/) { dst.diagonal() += src.diagonal(); } - static void run(DstXprType& dst, const SrcXprType& src, - const internal::sub_assign_op& /*func*/) { + static EIGEN_DEVICE_FUNC void run( + DstXprType& dst, const SrcXprType& src, + const internal::sub_assign_op& /*func*/) { dst.diagonal() -= src.diagonal(); } }; -- GitLab