Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

implement for as<arma::sp_mat> for Matrix classes other than dgCMatrix #17

Closed
@fabian-s

Description

@fabian-s

It would nice if RcppArmadillo knew how to deal with all Matrix-objects inheriting fromCsparseMatrix (i.e. all Matrix classes in sorted compressed column-oriented form), not justdgCMatrix. ThengCMatrix-class doesn't have an x-slot, for example, because the entries are all TRUE/FALSE, so the current implementation ofas<arma::sp_mat> fails.
Of course it's usually possible to do a conversion todgCMatrix on the R-side, but that's messy -- right now, in R you have to do something like

as(as(X, "CsparseMatrix"), "dMatrix")

to every Matrix-object you're handing over to RcppArmadillo to be sort-of-safe that it ends up having the correct class -- but the above will still fail to create adgC-matrix if X inherits fromsymmetricMatrix, for example. You have to do the conversion in this roundabout way because, as Martin Maechler explicitly writes in the Matrix docs,as(X, <MatrixClass>) should only be used to convertX to "virtual Matrix super classes" likeCsparseMatrix and not actual classes likedgCMatrix, and there aren't any directas-methods to make adgCMatrix from, say, anngTMatrix or addiMatrix.

These conversions in R can be costly as the matrix gets copied around, it would be more efficient to create thesp_mat directly. If that is too difficult, the RcppArmadillo-converter could at least check the class of its input to give more informative/correct error messages.

Thanks for all your great work on these packages!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp