3#include <ladel_global.h>
10 ladel_sparse_matrix res{};
11 res.nzmax = mat.nonZeros();
12 res.nrow = mat.rows();
13 res.ncol = mat.cols();
14 res.p = mat.outerIndexPtr();
15 res.i = mat.innerIndexPtr();
16 res.x = mat.valuePtr();
17 res.nz = mat.innerNonZeroPtr();
19 res.symmetry = symmetry;
25 ::ladel_sparse_free(M);
30 ladel_int nz = mat.innerNonZeroPtr() ==
nullptr ?
FALSE :
TRUE;
31 auto res = ::ladel_sparse_alloc(mat.rows(), mat.cols(), mat.nonZeros(),
32 UNSYMMETRIC,
TRUE, nz);
33 assert(mat.outerSize() + 1 <= res->ncol + 1);
34 std::copy_n(mat.outerIndexPtr(), mat.outerSize() + 1, res->p);
35 assert(mat.nonZeros() <= res->nzmax);
36 std::copy_n(mat.innerIndexPtr(), mat.nonZeros(), res->i);
37 assert(mat.nonZeros() <= res->nzmax);
38 std::copy_n(mat.valuePtr(), mat.nonZeros(), res->x);
39 if (mat.innerNonZeroPtr() !=
nullptr) {
40 assert(mat.outerSize() <= res->ncol);
41 std::copy_n(mat.innerNonZeroPtr(), mat.outerSize(), res->nz);
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.
QPALM_CXX_EXPORT 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::SparseMatrix< c_float, Eigen::ColMajor, sp_index_t > sparse_mat_t
Owning sparse matrix type.
QPALM_CXX_EXPORT ladel_sparse_matrix_ptr eigen_to_ladel_copy(const sparse_mat_t &mat)
Similar to eigen_to_ladel, but creates a copy of all data, in such a way that the returned matrix is ...
QPALM_CXX_EXPORT void operator()(ladel_sparse_matrix *) const