Symmetrize triangular matrix

Hi all,

I have computed a covariance data using TPrincipal Class.
This class, for some reason, return a lower triangular matrix instead of a symmetric matrix.

Ho can I symmetrize it?

I have tried:

TMatrixD* m = p.GetCovarianceMatrix();
TMatrixDSym sym; sym.Use(m->GetNrows(),m->GetMatrixArray());

where p is the TPrincipal object
But this seems not to work.
I attach plots for the matrices “m” and “sym” which are exactly identical.



Hi Maddalena,

These operations will not force a matrix to be symmetric. For that do something like:

const TMatrixD* m = p.GetCovarianceMatrix();
TMatrixD mt = *m; mt.T();
TMatrixDSym sym = *m+mt;