Skip to content

Commit b379bfd

Browse files
Update Common/src/linear_algebra/CSysMatrix.cpp
Co-authored-by: Pedro Gomes <[email protected]>
1 parent 09d964c commit b379bfd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Common/src/linear_algebra/CSysMatrix.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,9 +578,11 @@ void CSysMatrix<ScalarType>::MatrixInverse(ScalarType* matrix, ScalarType* inver
578578
for (auto jVar = 0ul; jVar < iVar; jVar++) {
579579
/*--- Regularize pivot if too small to prevent divide-by-zero ---*/
580580
if (std::abs(A(jVar, jVar)) < eps) {
581-
A(jVar, jVar) = (A(jVar, jVar) >= 0.0 ? eps : -eps);
582-
std::cout << "DEBUG MatrixInverse: Regularized small pivot A(" << jVar << "," << jVar << ") to "
581+
A(jVar, jVar) = std::copysign(eps, SU2_TYPE::GetValue(A(jVar, jVar)));
582+
#ifndef NDEBUG
583+
std::cout << "MatrixInverse: Regularized small pivot A(" << jVar << "," << jVar << ") to "
583584
<< A(jVar, jVar) << " at iVar=" << iVar << std::endl;
585+
#endif
584586
}
585587

586588
ScalarType weight = A(iVar, jVar) / A(jVar, jVar);

0 commit comments

Comments
 (0)