TMatrixT Get Eigenvalues

Hello all. I have a square TMatrixT of doubles, and am trying to get the E.vectors & E.values. Eigenvectors is simple enough, there’s the TMatrixT.EigenVectors function for that - but it takes as an argument a TVectorT of the Eigenvalues, and there doesn’t seem to be a function to get the eigenvalues (at least according to the documentation). I’m probably missing something obvious but would appreciate the help.

Thanks.

EigenVector will set the eigen-values into the eigenValues argument, you do not need to provide them. Consider the following example:

root [0] TMatrixD a(2, 2)
(TMatrixD &) Name: TMatrixT<double> Title:
root [1] a(0,0) = 1
(double) 1.00000
root [2] a(1,1) = 1
(double) 1.00000
root [3] TVectorD values
(TVectorD &) Name: TVectorT<double> Title:
root [4] TMatrixD vectors = a.EigenVectors(values)
(TMatrixD &) Name: TMatrixT<double> Title:
root [5] for (Int_t i = 0; i < values.GetNrows(); ++i) { TVectorD vector(TMatrixTColumn_const<double>(vectors, i)); std::cout << "eigen-value " << i << " is " << values(i) << " with eigen-vector"; vector.Print(); }
1 Like

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