Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mat] corrected bug in Gauss Jordan decomposition (thanks Damien Massé!) #156

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/core/matrices/codac2_GaussJordan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* codac2_GaussJordan.cpp
* ----------------------------------------------------------------------------
* \date 2024
* \author Simon Rohou
* \author Luc Jaulin, Simon Rohou, Damien Massé
* \copyright Copyright 2024 Codac Team
* \license GNU Lesser General Public License (LGPL)
*/
Expand Down Expand Up @@ -40,17 +40,18 @@ namespace codac2

Matrix gauss_jordan(const Matrix& A)
{
Index n = A.rows();//, m = A.cols();
Index n = A.rows(), m = A.cols();
Eigen::FullPivLU<Matrix> lu(A);

Matrix L = Matrix::Identity(n,n);
//if(std::pow(L.determinant(),2) < 1e-5)
//{
// cout << "[Matrix gauss_jordan(const Matrix& A)] -> eye Matrix" << endl;
// return Matrix::eye(n,n);
//}
if(std::pow(L.determinant(),2) < 1e-5)
{
cout << "[Matrix gauss_jordan(const Matrix& A)] -> eye Matrix" << endl;
return Matrix::eye(n,n);
}

L.block(0,0,n,n).triangularView<Eigen::StrictlyLower>() = lu.matrixLU();
L.block(0,0,n,std::min(m,n)).triangularView<Eigen::StrictlyLower>() =
lu.matrixLU().block(0,0,n,std::min(m,n));

Matrix P = lu.permutationP();
Matrix U = lu.matrixLU().triangularView<Eigen::Upper>();
Expand Down
4 changes: 3 additions & 1 deletion src/core/matrices/codac2_GaussJordan.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \file codac2_GaussJordan.h
* ----------------------------------------------------------------------------
* \date 2024
* \author Simon Rohou
* \author Luc Jaulin, Simon Rohou, Damien Massé
* \copyright Copyright 2024 Codac Team
* \license GNU Lesser General Public License (LGPL)
*/
Expand All @@ -16,4 +16,6 @@ namespace codac2
{
// Gauss Jordan band diagonalization preconditioning
Matrix gauss_jordan(const Matrix& A);

// From https://www.ensta-bretagne.fr/jaulin/centered.html
}
2 changes: 1 addition & 1 deletion src/core/matrices/codac2_matrices.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace Eigen
* (this is a standard C++ macro which disables all asserts).
* https://eigen.tuxfamily.org/dox/TopicPreprocessorDirectives.html
*/
#define EIGEN_NO_DEBUG
//#define EIGEN_NO_DEBUG // uncomment to disable Eigen's assertions
#endif

#include <Eigen/Core>
Expand Down
Loading