Error in <TDecompChol::Decompose()>: matrix not positi

Error in : matrix not positive definite
Error in <TVectorT::operator=(const TVectorT &)>: vectors not compatible

These messages pop up sometimes when I am fitting gasilion of different TGraphError objects sequentially with same function “pol2”.

I would like to figure out what causes it, is there any flag set which I could check for and use to debug this thing ?

I need a handle to pick those “faulty” graphs amongst many and look at them.

You do not mention the ROOT version but generaly speaking, it
seems that you are trying to invert a singular matrix through a Cholesky
decomposition . The returned matrix will be made invalid which
can be checked through a “IsValid()” member function .

Probably you try later on an operation between a vector and a matrix
that is not valid and willl result in an invald vector .

So try to catch these cases through IsValid checks .


I am using latest CVS release of ROOT.

ALl I do is create TGraphError objects with at least 3 points in it and fit it to pol2.

if there are any flags to check for, then they should be in TGraphError or TF1 objects. But I can’t figure out what is it to check for really …

looks like some combination of X,Y values for those points in graph make fit go crazy.

Really reluctant to sift through lots of events by hand and watch for message on screen


I did not realize that you did not call TDecompChol yourself
but went through TGraphError .

I agree that the Fit function should return back with the right error
status .

For the time being try :

  1. set the gErrorAbortLevel so that you get a trace and find out
    what is going on with x and y .

  2. Use NormalEqn (as defined in TDecompCol.cxx) to solve your
    linear fit . The returned vector is invalid if you have a singular
    matrix .


Figured it out:

at least 3 points must have unique X values for pol1 or pol2 fits to work all the time.

So, before fitting anything I check for this condition and problem went away.

Still, would be good if Fit() checked against matrix singularity itself and returned error code.

1 Like


This is certainly a missing protection in the Fit functions.
We will look into this.