I am really afraid if there is another similar topic about this issue here, but the last topic I was able to find is about 2 years ago with no solution.

I am trying to use the GetCovarianceMatrix method from TPrincipal class. I am supposed to use the covariance matrix to do some Math. However, I cannot be able to obtain a symmetric matrix. The member returns with a pointer to a Matrix that is NOT symmetric. This matrix shows just the lower left elements of the actual covariance matrix. How could I solve this problem?

Apparently, the authors only stored half of the covariance matrix. @BiaseGabriel, you could try the following (untested):

auto original = pca.GetCovarianceMatrix();
TMatrixD copy(*original);
TMatrixDSym sym;
sym.Use(covarianceMatrix.GetNrows(), covarianceMatrix.GetMatrixArray());
sym.Print("");

If you are lucky, it understands how to take the correct half of the matrix, and you can do math with sym. If it doesn’t understand it, you can symmetrise the matrix by assigning the elements copy[i][j] = copy[j][i]
in the right order.

@moneta:
It looks like TPrincipal should be using an eigen-matrix from the start …

Thank you so much for your help. I do not know why TPrincipal::GetCovarianceMatrix() does not offer a symmetric matrix, showing just the lower left now. I noted that some people mentioned this information in the past.
I worked on some math to turns it into symmetric with the help of TMatrixDDiag(). That works for what I need for now, although it may not be the best way to more complex implementations.