Re: [ROOT] bug in TMatrix - Invert !?

From: Eddy Offermann (eddy@rentec.com)
Date: Wed May 07 2003 - 19:12:52 MEST


Hi Martin,

Yes a bug, thanks !

Since 3.05 We have hard-coded the inverse for dim <=3 for speed reasons.
Unfortunately, I forgot that the matrix is stored column-wise which
results in an our for dim=3.

Rene, I have attached the patch

Eddy
> 
> hello all,
>  the script :
> 
> {
> 	TMatrix M(3,3);
> 	M(0,0) = 1;     M(0,1) = 4;     M(0,2) =  2;
> 	M(1,0) = 2;     M(1,1) = 7;     M(1,2) = -3;
> 	M(2,0) = 3;     M(2,1) = 2;     M(2,2) =  1;
> 
> 	// inverted matrix and test im M*Minv=E
> 	TMatrix Minv(TMatrix::kInverted,M);
> 	TMatrix E(M,TMatrix::kMult,Minv);
> 
> 	cout << "###\n# MATRIX M"<<endl;         M.Print();
> 	cout << "###\n# MATRIX Minv"<<endl;      Minv.Print();
> 	cout << "###\n# MATRIX E (?):" <<endl;	 E.Print();
> }
> 
>    results in different output using v3.02.07 and v3.05.04.
>    the main problem is, that the old version to me seems to be right.
>    i have noticed, that in v3.05.02 some (major) changes in TMatrix have
>    been made. now i puzzle if i missed something, or this is a bug.
> 
>  (SuSE 7.3, gcc 2.95)
> greetings,
>  martin
> 
> 
> ps: following - output of the script for both versions
> output  ## v3.02.07 ##
> ###
> # MATRIX M
> 
> Matrix 3x3 is as follows
> 
>      |        0  |        1  |        2  |
> ------------------------------------------------------------------
>    0 |          1           4           2
>    1 |          2           7          -3
>    2 |          3           2           1
> 
> ###
> # MATRIX Minv
> 
> Matrix 3x3 is as follows
> 
>      |        0  |        1  |        2  |
> ------------------------------------------------------------------
>    0 |       -0.2           0         0.4
>    1 |     0.1692     0.07692     -0.1077
>    2 |     0.2615     -0.1538     0.01538
> 
> ###
> # MATRIX E (?):
> 
> Matrix 3x3 is as follows
> 
>      |        0  |        1  |        2  |
> ------------------------------------------------------------------
>    0 |          1           0  -1.863e-08
>    1 |  1.788e-07           1  -6.147e-08
>    2 |   1.49e-08           0           1
> 
> -------------------------------------------------------------
> #############################################################
> output ## v3.05.04 ##
> ###
> # MATRIX M
> 
> Matrix 3x3 is as follows
> 
>      |        0  |        1  |        2  |
> ------------------------------------------------------------------
>    0 |          1           4           2
>    1 |          2           7          -3
>    2 |          3           2           1
> 
> ###
> # MATRIX Minv
> 
> Matrix 3x3 is as follows
> 
>      |        0  |        1  |        2  |
> ------------------------------------------------------------------
>    0 |       -0.2      0.1692      0.2615
>    1 |          0     0.07692     -0.1538
>    2 |        0.4     -0.1077     0.01538
> 
> ###
> # MATRIX E (?):
> 
> Matrix 3x3 is as follows
> 
>      |        0  |        1  |        2  |
> ------------------------------------------------------------------
>    0 |        0.6      0.2615     -0.3231
>    1 |       -1.6         1.2        -0.6
>    2 |       -0.2      0.5538      0.4923
> 
> 
> 
> 
> 






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