LU分解与行枢轴

use*_*215 5 r linear-algebra

以下函数不使用行旋转进行LU分解.R中是否存在使用行枢轴进行 LU分解的现有函数?

> require(Matrix)
> expand(lu(matrix(rnorm(16),4,4)))
$L
4 x 4 Matrix of class "dtrMatrix"
     [,1]        [,2]        [,3]        [,4]       
[1,]  1.00000000           .           .           .
[2,]  0.13812836  1.00000000           .           .
[3,]  0.27704442  0.39877260  1.00000000           .
[4,] -0.08512341 -0.24699820  0.04347201  1.00000000

$U
4 x 4 Matrix of class "dtrMatrix"
     [,1]       [,2]       [,3]       [,4]      
[1,]  1.5759031 -0.2074224 -1.5334082 -0.5959756
[2,]          . -1.3096874 -0.6301727  1.1953838
[3,]          .          .  1.6316292  0.6256619
[4,]          .          .          .  0.8078140

$P
4 x 4 sparse Matrix of class "pMatrix"

[1,] | . . .
[2,] . | . .
[3,] . . . |
[4,] . . | .
Run Code Online (Sandbox Code Playgroud)

Dav*_*ber 5

luR中的功能使用部分(行)枢轴。您没有在示例中提供原始矩阵,因此我将创建一个新示例进行演示。

luR中的函数是计算A = PLU,这等效于计算矩阵A的LU分解,矩阵A的行由置换矩阵P -1P -1 A = LU置换。有关更多信息,请参见Matrix软件包文档

> A <- matrix(c(1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1), 4)
> A
     [,1] [,2] [,3] [,4]
[1,]    1    1    1    1
[2,]    1    1   -1   -1
[3,]    1   -1   -1    1
[4,]    1   -1    1   -1
Run Code Online (Sandbox Code Playgroud)

这是L因素:

> luDec <- lu(A)
> L <- expand(luDec)$L
> L
4 x 4 Matrix of class "dtrMatrix" (unitriangular)
     [,1] [,2] [,3] [,4]
[1,]    1    .    .    .
[2,]    1    1    .    .
[3,]    1    0    1    .
[4,]    1    1   -1    1
Run Code Online (Sandbox Code Playgroud)

这是U因素:

> U <- expand(luDec)$U
> U
4 x 4 Matrix of class "dtrMatrix"
     [,1] [,2] [,3] [,4]
[1,]    1    1    1    1
[2,]    .   -2   -2    0
[3,]    .    .   -2   -2
[4,]    .    .    .   -4
Run Code Online (Sandbox Code Playgroud)

这是置换矩阵:

> P <- expand(luDec)$P
> P
4 x 4 sparse Matrix of class "pMatrix"

[1,] | . . .
[2,] . . | .
[3,] . | . .
[4,] . . . |
Run Code Online (Sandbox Code Playgroud)

我们可以看到这LU是行的排列版本A

> L %*% U
4 x 4 Matrix of class "dgeMatrix"
     [,1] [,2] [,3] [,4]
[1,]    1    1    1    1
[2,]    1   -1   -1    1
[3,]    1    1   -1   -1
[4,]    1   -1    1   -1
Run Code Online (Sandbox Code Playgroud)

回到原始身份A = PLU,我们可以恢复A(与A上面比较):

> P %*% L %*% U
4 x 4 Matrix of class "dgeMatrix"
     [,1] [,2] [,3] [,4]
[1,]    1    1    1    1
[2,]    1    1   -1   -1
[3,]    1   -1   -1    1
[4,]    1   -1    1   -1
Run Code Online (Sandbox Code Playgroud)


Geo*_*tas 1

也许可以完成工作。但是,没有 Windows 二进制文件,我无法尝试。