Multiple calls to Decompose method in decomposition class

Hi,

a have been playing around with some of the decomposition classes in Root (5.18), looking at condition numbers and determinants and inverting matrices. I have performed most of my tests with TDecompSVD, but my observations summarized in the following might apply to other of the decomposition classes as well.

It took me some time to realize that the order of some of the operations is quite relevant and that calling the Decompose method twice causes subsequent calculations to fail.

I have attached a short macro that I have used for testing. It operates on a nice and simple non-singular diagonal matrix.

Everything works well if I

  • invoke Decompose (step 1),
  • calculate the determinant (step 2),
  • ask for the condition number (step 3) and then
  • invert the matrix (step 4).

The following modifications are also fine:

  • leaving out any of the above steps, this implies, of course, skipping the explicit call to the Decompose method or performing any of the operations stand-alone
  • changing the order of the steps 2, 3 and 4
  • performing any of the steps 2, 3 and 4 more than once
    I still get the correct determinant and the correctly inverted matrix.

This is not longer the case as soon as I

  • do step 1, i.e. explicitly invoke Decompose, more than once or
  • do step 1 after any of the other three steps.
    I then get (without any warnings or errors) always a determinant of 1 and not the correctly inverted matrix (actually I get an unit matrix for the example given in the attached macro, but I have also seen other things in the case of attempting to invert non-diagonal matrices).

Experts may understand this behaviour. I guess it has to do with the fact that that steps 2, 3 and 4 implicitly call the Decompose method if it has not been called before.

I have seen the table in the Root documentation (Chapter 14, Section “Matrix Decompositions”) on the different states of the decomposition process. I have not read that Decompose() should not be invoked more than once.

As a non-expert, I don’t know why it might have to be like that. If a matrix has already been decomposed, the decomposition class should know it and every subsequent call to the Decompose method should be without effect.

If, for some reason, this is not possible, Root should give some warning or error so that users know that further results returned by the decomposition object might be incorrect. And maybe it would be good then to also add a comment to the documentation.

I hope there is not just a simple shortcoming in my code or in my conclusions. I would be happy to understand all this a little better, so I appreciate any reply.

Best regards,
Sebastian
testTDecompSVD.C (1.47 KB)

Hi Sebastian,

Your observed behavior is due to a bug in root 5.18 .

Its was not checked that the matrix was already decomposed.

This bug has been fixed on Feb 7 2008:

root.cern.ch/viewvc/trunk/math/m … x?view=log

Eddy

Hi Eddy,

it’s good to hear that I was not wrong and that this bug has been fixed.

Unfortunately I will still have to stick to Root 5.18 for the time being since I am working in some software framework with built-in Root (and there it is 5.18 at the moment)… :frowning:

Thanks for your reply!

Sebastian