Recovering an invalid TMtarix

Hello!

I’m using ROOT 4.00/03.
I’m inverting a TMatrix with UL method; sometimes it happens that inversion fails, then I get an invalid (nRow = -1) matrix.
Now, I want to recover that matrix to reinitialize it with other data (life still goes on).
Which (fast) method can I use? The dimension of that matrix must be the same as the old one, so no memory reallocation is needed; anyway, ResizeTo() fails (there is an assertion on IsValid()) and I can’t figure which other method I’m supposed to use to resurrect it.

–
Hamlet

Hi Hamlet,

I have installed your request to be able to reset an invalidate matrix .
It should be in CVS soon .
For this, a new data member in the vector/matrix classes has been
introduced : fStatus . Now we will not set the fNrows = -1 in order to
invalidate the matrix (which made us lose the number of rows) .

Use “MakeValid()” to reset the status bit .

On another note . If you are inverting matrices of the same
dimensions, invoking in place inversion through “Invert()” might not
be the best way to go . The method “Invert()” makes each time an
instance of the class TDecompLU for a matrix of a certain dimension .

Better (faster) is to do a

TDecompLU lu(n); outside your loop . The decomposition class is now

setup for matrices of n x n . Inside your loop you now do a

lu.SetMatrix(a); thereby assigning your matrix a . If matrix a is

of dimension n x n, no memery allocation has to be performed by lu .

Now you can call either lu.Invert(a), which replaces a by its inversion
or TMatrixD a_inv = lu.Invert();

Eddy

Thanks for your support!

I’m still a little confused about your suggestion; reading TMatrixD::Invert() method it seems to me that TMatrixD does not use any real TDecompLU object, using TDecompLU static members instead and passing them itself as the data on which to act.

–
Hamlet

Oops, start forgetting my own code . yes, you are right, I changed the
Invert code so that it only uses some static functions . It is still true
for the Deteminant() functionality

Eddy