Message: Eigenvalues of a matrix Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Eigenvalues of a matrix 

Forum: Analysis
Date: 04 Apr, 2018
From: Patrick Asenov <Patrick Asenov>

Hello, dear friends, comrades and colleagues!

I've been trying lately to perform a linear regression with 8 points. For that reason I need the eigenvalues of a matrix. What I've done until now and didn't work is:

include <Eigen/Eigenvalues>

[...]

M[0][0] = (1/8)*((At.x())^2 + (Bt.x())^2 + (Ct.x())^2 + (Dt.x())^2 + (Gt.x())^2 + (Ht.x())^2 + (It.x())^2 + (Jt.x())^2);
 M[0][1] = M[1][0] = (1/8)*((At.x())*(At.y()) + (Bt.x())*(Bt.y()) + (Ct.x())*(Ct.y()) + (Dt.x())*(Dt.y()) + (Gt.x())*(Gt.y()) + (Ht.x())*(Ht.y()) + (It.x())*(It.y()) + (Jt.x())*(Jt.y()));
 M[0][2] = M[2][0] = (1/8)*((At.x())*(At.z()) + (Bt.x())*(Bt.z()) + (Ct.x())*(Ct.z()) + (Dt.x())*(Dt.z()) + (Gt.x())*(Gt.z()) + (Ht.x())*(Ht.z()) + (It.x())*(It.z()) + (Jt.x())*(Jt.z()));
 M[1][1] = (1/8)*((At.y())^2 + (Bt.y())^2 + (Ct.y())^2 + (Dt.y())^2 + (Gt.y())^2 + (Ht.y())^2 + (It.y())^2 + (Jt.y())^2);
 M[1][2] = M[2][1] = (1/8)*((At.y())*(At.z()) + (Bt.y())*(Bt.z()) + (Ct.y())*(Ct.z()) + (Dt.y())*(Dt.z()) + (Gt.y())*(Gt.z()) + (Ht.y())*(Ht.z()) + (It.y())*(It.z()) + (Jt.y())*(Jt.z()));
 M[2][2] = (1/8)*((At.z())^2 + (Bt.z())^2 + (Ct.z())^2 + (Dt.z())^2 + (Gt.z())^2 + (Ht.z())^2 + (It.z())^2 + (Jt.z())^2);

 Matrix3f A;
 A << M[0][0], M[0][1], M[0][2], M[1][0], M[1][1], M[1][2], M[2][0], M[2][1], M[2][2];

 SelfAdjointEigenSolver <Matrix3f> es(A);
 lambda = es.eigenvalues().[0];
 lambdaVector = es.eigenvectors().col(0);
 if (es.eigenvalues().[1]>lambda)   {
     lambda = es.eigenvalues().[1];
     lambdaVector = es.eigenvectors().col(1);
 }
 if (es.eigenvalues().[2]>lambda)   {
     lambda = es.eigenvalues().[2];
     lambdaVector = es.eigenvectors().col(2);
 }

 //The fitted AJ line is Rav + t*lambdaVector, t real.
 tE = (E.z() - Rav.z())/lambdaVector(2);
 Et.x() = Rav.x() + tE*lambdaVector(0);
 Et.y() = Rav.y() + tE*lambdaVector(1);
 Et.z() = E.z();
 EtEx = E.x() - Et.x();
 EtEy = E.y() - Et.y();
 analysisManager->FillH1(85, EtEx);
 analysisManager->FillH1(86, EtEy);

 tF = (F.z() - Rav.z())/lambdaVector(2);
 Ft.x() = Rav.x() + tF*lambdaVector(0);
 Ft.y() = Rav.y() + tF*lambdaVector(1);
 Ft.z() = F.z();
 FtFx = F.x() - Ft.x();
 FtFy = F.y() - Ft.y();
 analysisManager->FillH1(87, FtFx);
 analysisManager->FillH1(88, FtFy);

Unfortunately it didn't work. Geant4 doesn't recognize Eigen/Eigenvalues. Any ideas how to use it (or anything equivalent)?

If any help was provided I'd be thankful!

 Add Message Add Message
to: "Eigenvalues of a matrix"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]