[ROOT] TMatrix::Invert() bug

From: Chris Crawford (chris2@lns.mit.edu)
Date: Wed Feb 05 2003 - 18:15:11 MET


Hello,
  TMatrix::Invert() fails on symmetric, matrixes with a zero in the 
diagonal (even nonsingular ones).  Example: (v3.05/00)

root [11] float x[]={0,1,1,1,1,0,1,1,1,1,1,0,1,1,0,1}
float x[]={0,1,1,1,1,0,1,1,1,1,1,0,1,1,0,1}
root [12] TMatrix n(4,4,x)
TMatrix n(4,4,x)
root [13] n->Determinant()
n->Determinant()
(const Double_t)3.00000000000000000e+00
root [14] n->Invert()
n->Invert()
Fatal in <TMatrix::>: val != 0.0 violated at line 895 of 
`matrix/src/TMatrix.cxx'
aborting


Here is patch to fix the problem:

--- TMatrix.cxx.~1.37.~    2002-12-10 14:00:48.000000000 +0000
+++ TMatrix.cxx    2003-02-05 16:57:59.000000000 +0000
@@ -1159,6 +1159,9 @@
    TVector diag(fNrows);
    if (symmetric) {
      diag = TMatrixDiag(*this);
+     for (int idx=0; idx<diag.fNrows; idx++) {
+       if (diag.fElements[idx] < 1.0) diag.fElements[idx] = 1.0;
+     }
      this->NormByDiag(diag);
    }



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:09 MET