在R中,有一个Null方法可以获取矩阵的零空间。

但是,有没有R代码可以获取矩阵的行和列空间?

最佳答案

尝试orth中的nullspacepracma package

这是一个例子:

> library(pracma)
> m <- matrix(1:12, 2, 6)
> m
     [,1] [,2] [,3] [,4] [,5] [,6]
[1,]    1    3    5    7    9   11
[2,]    2    4    6    8   10   12
> orth(m) # column space
           [,1]       [,2]
[1,] -0.6632348 -0.7484114
[2,] -0.7484114  0.6632348
> orth(t(m)) # row space (as columns)
            [,1]        [,2]
[1,] -0.08476661 -0.71876571
[2,] -0.19556039 -0.50694598
[3,] -0.30635416 -0.29512626
[4,] -0.41714794 -0.08330653
[5,] -0.52794171  0.12851320
[6,] -0.63873549  0.34033292
> nullspace(m)
           [,1]       [,2]        [,3]        [,4]
[1,] -0.3364616 -0.3421368 -0.34781203 -0.35348723
[2,] -0.1608384  0.1264967  0.41383172  0.70116676
[3,]  0.8982385 -0.0817188 -0.06167608 -0.04163337
[4,] -0.1177038  0.8420338 -0.19822864 -0.23849104
[5,] -0.1336462 -0.2342137  0.66521880 -0.43534872
[6,] -0.1495885 -0.3104611 -0.47133376  0.36779360

08-24 17:35