I use C++ 14 and Eigen, I want to compute the determinant of a square matrix using LU decomposition. (link) but I have some issues: A is the main matrix (n size) and rez is the LU form of A.
PartialPivLU<MatrixXd> rez = PartialPivLU<MatrixXd>(A);
MatrixXd r1 = rez.matrixLU().triangularView<UpLoType::Upper>();
double det_r1 = 1;
for(int i=0;i<n;i++)
det_r1 = det_r1 * r1(i,i);
cout<<det_r1<<endl;
cout<<A.determinant();
Determinant of r1 is the product of the elements from main diagonal. The problem is that det(A) isn't equal to det(r1).
For exemple det(A) = 500 and det(r1) = -500. The problem is about sign of r1, how can I get the sign?
rez.determinant()
? – chtz