Error while taking Transpose in TDecompChol: function 'T' not viable: 'this' argument has type 'const TMatrixD'

Dear Experts,

I am getting the following error while taking transpose of the Cholesky decomposition matrix defined with TDecompChol class.

error: member function 'T' not viable: 'this' argument has type 'const TMatrixD' (aka 'const TMatrixT<double>'), but function is not marked const

I have formatted my code so that you can reproduce the error. Please find the attached necessary files. I am using root version 6.14.

Could anyone please let me know how to resolve this error? Thanks in advance!
check.C (409 Bytes)
KspipiCovariancematrix_cisi.root (1.9 KB)

Hi @niharika ,
and welcome to the ROOT forum!

As the error message says (or tries to say) when you do a.T() you are calling the non-const method T() on the const TMatrix variable a. The error goes away if you change

const TMatrixD a = decompMat.GetU();


TMatrixD a = decompMat.GetU();


Hi Enrico,

Thanks! That worked.
I understood the other way around, so introduced this const TMatrixD in my actual code. But, it was a mistake. Now my code is working fine.

Alright! :+1: const means that the value of the variable won’t change, but then of course T() tries to change it, and the compiler complains.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.