小编Nic*_*ton的帖子

使用 PartialPivLU 进行 LU 分解

我在 MATLAB 中有以下代码,在尝试计算lamb我包含的代码以提供一些上下文之前,它会执行 LU 分解。

P=[1,2,3;4,5,6;7,8,9];
U=[0;1;2];
[F,J]=lu(P);
Jlamda=F\U;
lamb=J\Jlamda;
Run Code Online (Sandbox Code Playgroud)

F 是:

P=[1,2,3;4,5,6;7,8,9];
U=[0;1;2];
[F,J]=lu(P);
Jlamda=F\U;
lamb=J\Jlamda;
Run Code Online (Sandbox Code Playgroud)

U 是:

0.142857142857143   1                   0
0.571428571428571   0.500000000000000   1
1                   0                   0
Run Code Online (Sandbox Code Playgroud)

当我尝试使用以下代码在 Eigen 中复制此内容时:

MatrixXd P(3, 3);
P << 1, 2, 3, 4, 5, 6, 7, 8, 9;
MatrixXd U(3, 1);
U << 0, 1, 2;

PartialPivLU<MatrixXd> lu = PartialPivLU<MatrixXd>(P);
MatrixXd J = lu.matrixLU().triangularView<UpLoType::Upper>();
MatrixXd F = lu.matrixLU().triangularView<UpLoType::UnitLower>();

MatrixXd Jlamda = F.lu().solve(U);
MatrixXd l = J.lu().solve(Jlamda);

cout << F << endl; …
Run Code Online (Sandbox Code Playgroud)

c++ matlab matrix linear-algebra eigen3

2
推荐指数
1
解决办法
1251
查看次数

标签 统计

c++ ×1

eigen3 ×1

linear-algebra ×1

matlab ×1

matrix ×1