Skip to content

Exposing Eigen::SparseMatrix class causes segfault in setFromTriplets #800

Discussion options

You must be logged in to vote

It seem like the core issue lies with how the nb::DRef class interacts with regular Eigen objects.

My iterator class originally stored const references to Eigen objects:

const Eigen::Array<Index, Eigen::Dynamic, 1>& rows_;
const Eigen::Array<Index, Eigen::Dynamic, 1>& cols_;
const Eigen::Array<Scalar, Eigen::Dynamic, 1>& values_;

When passing nb::Dref objects to the iterator, no errors are raised and everything looks fine.
However, accessing the values results in completely corrupted data.

Replacing the Eigen types with nb::Dref results in the correct and expected behaviour.

using IndexArray = nb::DRef<Eigen::Array<Index, Eigen::Dynamic, 1>>;
using ScalarArray = nb::DRef<Eigen::Array<Sca…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by MarcelFerrari
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant