[Q] TDecompSVD index start from 0, Bug or Feature?

Hello,

I’m using Root versions
4.02/00
4.01/02

And when I try to use matrix/vector index start from “1” not “0”,
say
TMatrixD A(1,3, 1,3);
TvectorD y(1,3);

TDecompSVD UwVt(A);

It looks to me that “TDecompSVD” returns GetSig()/GetU()/GetV()
vector/matrix w/ index start from “0”, not “1” and it crashes when
I attemp to call Solve() – see below.
Do I need to use Vector/Matrix index always start from “0”?
Or is this a feature?

Also, standard text book says matrix (mxn) A can be decomposed
to
A = U w V^T
where U = (mxn), w = disg (nxn), and V = (nxn) matrices. But Root
"TDecompSVD" documentation says,
[–
For an (m x n) matrix A with m >= n, the singular value decomposition
is
an (m x m) orthogonal matrix fU, an (m x n) diagonal matrix fS, and
an (n x n) orthogonal matrix fV so that A = USV’.
–]
It may confuse people? (documentation may be incorrect?)

Thanks,
Chul Su

PS –
TDecompSVD crashes when I sttempt to call Decompose()/GetSig()/GetU()/…/Solve(),
with
Error messages

Error in <TVectorD::operator*=(const TMatrixD &)>: vector and matrix incompatible
Error in <TVectorD::operator=(const TVectorD &)>: vectors not compatible

Fatal in TVectorD::: IsValid() violated at line 1235 of `matrix/src/TVectorD.cxx’

Hi Chul Su,

Thanks for pointing out this bug in the indexing of the decomposed
matrix elements in case the matrix indices do not start from 0 .
Shortly a patch will be installed in CVS that will allow you to work
with TDecompSVD as expected .

The indexing will now be as follows:

// If the row/column index of A starts at (rowLwb,colLwb) then the //
// decomposed matrices/vectors start at : //
// fU : (rowLwb,colLwb) //
// fV : (colLwb,colLwb) //
// fSig : (colLwb) //

The currently installed SVD algorithm does have a matrix fU
with size (m x m) . The algorithm is extensively documented in
"Data Analysis" by Siegmund Brandt .

If you want to continue working in 4.02/00 or 4.01/02, you
could perform a Shift operation on your matrix before decomposing
it :

TMatrixD A(1,3,1,3);
A.Shift(-1,-1);

Eddy