3#include <ladel_global.h>
11 ladel_sparse_matrix res{};
12 res.nzmax = mat.nonZeros();
13 res.nrow = mat.rows();
14 res.ncol = mat.cols();
15 res.p = mat.outerIndexPtr();
16 res.i = mat.innerIndexPtr();
17 res.x = mat.valuePtr();
18 res.nz = mat.innerNonZeroPtr();
20 res.symmetry = symmetry;
26 ::ladel_sparse_free(M);
31 index_t nnz, ladel_int symmetry,
32 bool values,
bool nonzeros) {
34 ::ladel_sparse_alloc(
static_cast<ladel_int
>(rows),
35 static_cast<ladel_int
>(cols),
36 static_cast<ladel_int
>(nnz), symmetry,
43 bool nz = mat.innerNonZeroPtr() !=
nullptr;
46 assert(mat.outerSize() + 1 <= res->ncol + 1);
47 std::copy_n(mat.outerIndexPtr(), mat.outerSize() + 1, res->p);
48 assert(mat.nonZeros() <= res->nzmax);
49 std::copy_n(mat.innerIndexPtr(), mat.nonZeros(), res->i);
50 assert(mat.nonZeros() <= res->nzmax);
51 std::copy_n(mat.valuePtr(), mat.nonZeros(), res->x);
53 assert(mat.outerSize() <= res->ncol);
54 std::copy_n(mat.innerNonZeroPtr(), mat.outerSize(), res->nz);
ladel_sparse_matrix_ptr eigen_to_ladel_copy(const sparse_mat_ref_t &mat, ladel_int symmetry=UNSYMMETRIC)
Similar to eigen_to_ladel, but creates a copy of all data, in such a way that the returned matrix is ...
Eigen::Ref< const sparse_mat_t > sparse_mat_ref_t
Read-only reference to a sparse matrix.
ladel_sparse_matrix_ptr ladel_sparse_create(index_t rows, index_t cols, index_t nnz, ladel_int symmetry, bool values=true, bool nonzeros=false)
Create an LADEL sparse matrix of the given dimensions.
std::unique_ptr< ladel_sparse_matrix, alloc::ladel_sparse_matrix_deleter > ladel_sparse_matrix_ptr
Smart pointer that automatically cleans up an owning ladel_sparse_matrix object.
ladel_sparse_matrix eigen_to_ladel(sparse_mat_t &mat, ladel_int symmetry=UNSYMMETRIC)
Convert an Eigen sparse matrix to a LADEL sparse matrix, without creating a copy.
Eigen::Index index_t
Index types for vectors and matrices.
Eigen::SparseMatrix< c_float, Eigen::ColMajor, sp_index_t > sparse_mat_t
Owning sparse matrix type.
void operator()(ladel_sparse_matrix *) const