Re: [ROOT] TMatrix Invert Mult

From: Carlos Muņoz Camacho (cmunoz@clipper.ens.fr)
Date: Thu May 01 2003 - 17:45:00 MEST


Hi,

After you do a.Invert(), a is the inverse of the original a matrix, so
when you do a.b you're actually multiplying the inverted matrix by itself.
You need to save a copy of the original matrix a if you want to do your
test that way.

Carlos


On Thu, 1 May 2003, sdean wrote:

>Hi there,
>
>Please inspect the following piece of code which attempts to perform one
>of the most basic matrix operations, that of multiplying a matrix by its
>inverse to obtain the unit matrix:
>
>root [0] TMatrix a(2,2)
>root [1] a(0,0)=1.0;
>root [2] a(1,0)=2.0;
>root [3] a(0,1)=3.0;
>root [4] a(1,1)=4.0;
>root [5] TMatrix b(2,2)
>root [6] b=a.Invert();
>root [7] TMatrix c(2,2)
>root [8] c.Mult(b,a)
>root [9] c(0,0)
>(Real_t)5.50000000000000000e+00
>root [10] c(1,0)
>(Real_t)(-2.50000000000000000e+00)
>root [11] c(0,1)
>(Real_t)(-3.75000000000000000e+00)
>root [12] c(1,1)
>(Real_t)1.75000000000000000e+00
>
>The results look much too precise for this to be a conversion error. Can
>anyone see where I'm going wrong?
>
>cheers,
>
>Simon
>



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