mirror of
https://github.com/RYDE-WORK/pybind11.git
synced 2026-02-02 13:15:52 +08:00
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<Eigen::SparseMatrix<...>>. * Update eigen.h * Update eigen.h
This commit is contained in:
parent
fe65693c72
commit
70a58c577e
@ -50,8 +50,12 @@ PYBIND11_NAMESPACE_BEGIN(detail)
|
|||||||
|
|
||||||
#if EIGEN_VERSION_AT_LEAST(3,3,0)
|
#if EIGEN_VERSION_AT_LEAST(3,3,0)
|
||||||
using EigenIndex = Eigen::Index;
|
using EigenIndex = Eigen::Index;
|
||||||
|
template<typename Scalar, int Flags, typename StorageIndex>
|
||||||
|
using EigenMapSparseMatrix = Eigen::Map<Eigen::SparseMatrix<Scalar, Flags, StorageIndex>>;
|
||||||
#else
|
#else
|
||||||
using EigenIndex = EIGEN_DEFAULT_DENSE_INDEX_TYPE;
|
using EigenIndex = EIGEN_DEFAULT_DENSE_INDEX_TYPE;
|
||||||
|
template<typename Scalar, int Flags, typename StorageIndex>
|
||||||
|
using EigenMapSparseMatrix = Eigen::MappedSparseMatrix<Scalar, Flags, StorageIndex>;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Matches Eigen::Map, Eigen::Ref, blocks, etc:
|
// Matches Eigen::Map, Eigen::Ref, blocks, etc:
|
||||||
@ -571,9 +575,9 @@ struct type_caster<Type, enable_if_t<is_eigen_sparse<Type>::value>> {
|
|||||||
if (!values || !innerIndices || !outerIndices)
|
if (!values || !innerIndices || !outerIndices)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
value = Eigen::MappedSparseMatrix<Scalar,
|
value = EigenMapSparseMatrix<Scalar,
|
||||||
Type::Flags & (Eigen::RowMajor | Eigen::ColMajor),
|
Type::Flags & (Eigen::RowMajor | Eigen::ColMajor),
|
||||||
StorageIndex>(
|
StorageIndex>(
|
||||||
shape[0].cast<Index>(), shape[1].cast<Index>(), nnz,
|
shape[0].cast<Index>(), shape[1].cast<Index>(), nnz,
|
||||||
outerIndices.mutable_data(), innerIndices.mutable_data(), values.mutable_data());
|
outerIndices.mutable_data(), innerIndices.mutable_data(), values.mutable_data());
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user