Skip to content

Working with sparse linear solvers #785

Discussion options

You must be logged in to vote

Nevermind what I said.

I must've messed up something because using nb::capsule does indeed work!

Except having to explicitly define noexcept when initialising the capsule, this approach is easy and avoids having to re-initialize objects many times. Also object ownership is very clear so this is a plus!

#include <nanobind/nanobind.h>
#include <nanobind/eigen/dense.h>

// Eigen modules
#include <Eigen/Sparse>
#include <Eigen/PardisoSupport>

namespace nb = nanobind;
using SparseMatrix = Eigen::Map<const Eigen::SparseMatrix<double, Eigen::ColMajor>>;
using SparseSolver = Eigen::PardisoLU<SparseMatrix>;
using solver_ptr = SparseSolver *;
using matrix_ptr = SparseMatrix *;

// Function to crea…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@wjakob
Comment options

@MarcelFerrari
Comment options

@MarcelFerrari
Comment options

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
2 participants