-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Hey there!
My lab spends a lot of time taking SVDs of, let's say, "nearly nice" matrices. For these matrices, we can often compute t(A) %*% x
and A %*% x
in a reasonable amount of time if we give A
a custom class and then implement the multiplication in C++
via RcppEigen
. In our cases, A
is often sparse, and this introduces a problem. While we can implement matrix multiplication in C++
and make it fast, using sparse matrices incurs a copying cost. This makes irlba
slow for us: either we implement matrix multiplication in R, which is slow in our case, or we do it in C++, and pay many copying costs for each SVD. We have to take the SVD many times since we're doing matrix completion work, and anyway this all adds up.
Ideally, irlba
would expose a C++ level interface, so that we could copy A
just once for each SVD, or even better, just once for the whole matrix completion algorithm if we implemented it in C++. For example, spectra
does this for eigendecompositions, and make custom eigendecompositions very nice via the "custom op" interface at the C++ level. However, it doesn't seem like irlba
offers the same functionality, even though it seems like irlba
may be more appropriate for SVDs (yixuan/spectra#11).
I know this is a large ask, but would you consider (possibly in the long term) refactoring the C/C++ code to a structure more like spectra
so that we can take advantage of irlba
's SVD implementation?