RfastOfficial / Rfast

A collection of Rfast functions for data analysis. Note 1: The vast majority of the functions accept matrices only, not data.frames. Note 2: Do not have matrices or vectors with have missing data (i.e NAs). We do no check about them and C++ internally transforms them into zeros (0), so you may get wrong results. Note 3: In general, make sure you give the correct input, in order to get the correct output. We do no checks and this is one of the many reasons we are fast.
144 stars 19 forks source link

Is it possible to support sparse matrix multiplication #6

Open sqjin opened 4 years ago

sqjin commented 4 years ago

Thanks for sharing this great package. For the matrix multiplication, it looks like Rfast does not support the sparse inputs, e.g., as(x, "dgCMatrix"). When I tried the sparse inputs, there is an error: Error in mat.mult(x, y) : Not compatible with requested type: [type=S4; target=double].

Sparse matrix is important in dealing with large data. In particular for the matrix multiplication of two sparse matrices, there should have some ways to do it more faster. Is it possible to support the sparse inputs?

Thanks so much!

Best, Suoqin

ManosPapadakis95 commented 4 years ago

Great idea. I will check it to see if RcppArmadillo support this. It depends on this. I will leave this open to inform you.

sqjin commented 4 years ago

@ManosPapadakis95 Here is a post showing that the use of sparse matrix in RcppArmadillo is faster than the dense matrix: https://gallery.rcpp.org/articles/armadillo-sparse-matrix-performance/ . Thanks!

ManosPapadakis95 commented 4 years ago

The link is broken...I think. Anyway, sparse is not faster than dense. That can not happen. Although, I am trying to find a way to make it faster but without success. Patience and I will find another way. Also check package "slam". It is another package which uses sparse matrices with less memory in under specific sircumstances.

sqjin commented 4 years ago

@ManosPapadakis95 Thank so much!