Registered Member
|
Hi all
I have the following code #include <iostream> #include <string> #include <Eigen/Dense> using std::cout; using std::endl; using namespace Eigen; #define n 5 int main(){ MatrixXd m = MatrixXd::Random(n,n); cout << m.lu().matrixLU() << endl; cout << endl; MatrixXd l= MatrixXd::Identity(n,n); MatrixXd u= MatrixXd::Zero(n,n); (l=m.lu().matrixLU().triangularView<StrictlyLower>()) += MatrixXd::Identity(n,n); u=m.lu().matrixLU().triangularView<Upper>(); cout << l << endl<<endl; cout << u << endl; cout << "Are they equal" << endl; cout << m.lu().permutationP().inverse()*( l*u) << endl; cout << endl; cout << m.lu().reconstructedMatrix() << endl; // cout << m << endl; cout << endl; } when I compute m.lu().permutationP().inverse()*( l*u) shouldn't this be equal to m? Any thought is appreciated. Thanks! |
Moderator
|
hm yes, and here they are indeed equal.... what's the matter?
Note that you can also use "m.lu().matrixLU().triangularView<UnitLower>()" instead of adding the identity matrix. |
Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], q.ignora