计算稀疏矩阵的零空间

时间:2022-05-29 23:36:59

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).

我找到了一个函数(null或nullspace)来寻找R中正则矩阵的零空间,但是我找不到任何一个稀疏矩阵(sparseMatrix)的函数或包。

Does anybody know how to do this?

有人知道怎么做吗?

1 个解决方案

#1


3  

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.

如果您看一下ggm::null的代码,您会发现它是基于输入矩阵的QR分解。

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

另一方面,矩阵包为计算稀疏矩阵的QR分解提供了自己的方法。

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]

#1


3  

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.

如果您看一下ggm::null的代码,您会发现它是基于输入矩阵的QR分解。

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

另一方面,矩阵包为计算稀疏矩阵的QR分解提供了自己的方法。

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]