Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compute the null space of a sparse matrix

I found the function (null OR nullspace) to find the null space of a regular matrix in R, but I couldn't find any function or package for a sparse matrix (sparseMatrix).

Does anybody know how to do this?

like image 456
Mahin Avatar asked Apr 24 '26 02:04

Mahin


1 Answers

If you take a look at the code of ggm::null, you will see that it is based on the QR decomposition of the input matrix.

On the other hand, the Matrix package provides its own method to compute the QR decomposition of a sparse matrix.

For example:

require(Matrix)
A <- matrix(rep(0:1, 3), 3, 2)
As <- Matrix(A, sparse = TRUE)

qr.Q(qr(A), complete=TRUE)[, 2:3]
qr.Q(qr(As), complete=TRUE)[, 2:3]
like image 94
Vincent Guillemot Avatar answered Apr 25 '26 17:04

Vincent Guillemot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!