From 70a58c577eaf067748c2ec31bfd0b0a614cffba6 Mon Sep 17 00:00:00 2001 From: Rasmus Munk Larsen Date: Mon, 22 Nov 2021 17:01:35 -0800 Subject: [PATCH] Replace usage of deprecated Eigen class MappedSparseMatrix. (#3499) * Replace usage of deprecated Eigen class Eigen::MappedSparseMatrix has been deprecated since Eigen 3.3 from 2016. Use the equivalent modern syntax Eigen::Map>. * Update eigen.h * Update eigen.h --- include/pybind11/eigen.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/pybind11/eigen.h b/include/pybind11/eigen.h index e43e484c6..965d66e8a 100644 --- a/include/pybind11/eigen.h +++ b/include/pybind11/eigen.h @@ -50,8 +50,12 @@ PYBIND11_NAMESPACE_BEGIN(detail) #if EIGEN_VERSION_AT_LEAST(3,3,0) using EigenIndex = Eigen::Index; +template +using EigenMapSparseMatrix = Eigen::Map>; #else using EigenIndex = EIGEN_DEFAULT_DENSE_INDEX_TYPE; +template +using EigenMapSparseMatrix = Eigen::MappedSparseMatrix; #endif // Matches Eigen::Map, Eigen::Ref, blocks, etc: @@ -571,9 +575,9 @@ struct type_caster::value>> { if (!values || !innerIndices || !outerIndices) return false; - value = Eigen::MappedSparseMatrix( + value = EigenMapSparseMatrix( shape[0].cast(), shape[1].cast(), nnz, outerIndices.mutable_data(), innerIndices.mutable_data(), values.mutable_data());