Skip to content

Commit 8b43e04

Browse files
manavbhatiaManav Bhatia
authored andcommitted
-- Bug-fix in scaling of left eigenvector in ZGGEV base. Additional modification now scales right eigenvectors to unit norm.
1 parent 59ef83c commit 8b43e04

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/numerics/lapack_zggev_base.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,17 @@ namespace MAST {
8585
void scale_eigenvectors_to_identity_innerproduct() {
8686
libmesh_assert(info_val == 0);
8787

88-
// scale the right eigenvectors so that they all have the same norm
89-
Real l2 = this->VR.col(0).norm();
88+
// scale the right eigenvectors so that they all have unit norm
89+
Real l2 = 0.;
9090

91-
libmesh_assert(l2 > 0.);
92-
93-
for (unsigned int i=1; i<this->VR.cols(); i++)
94-
this->VR.col(i) *= l2 / this->VR.col(i).norm();
91+
for (unsigned int i=0; i<this->VR.cols(); i++) {
92+
93+
l2 = this->VR.col(i).norm();
94+
libmesh_assert(l2 > 0.);
95+
96+
// scale all right eigenvectors to unit length
97+
this->VR.col(i) /= l2;
98+
}
9599

96100
// this product should be an identity matrix
97101
ComplexMatrixX r = this->VL.conjugate().transpose() * _B * this->VR;
@@ -102,7 +106,7 @@ namespace MAST {
102106
for (unsigned int i=0; i<_B.cols(); i++) {
103107
val = r(i,i);
104108
if (std::abs(val) > 0.)
105-
this->VR.col(i) *= (1./val);
109+
this->VL.col(i) *= (1./val);
106110
}
107111
}
108112

0 commit comments

Comments
 (0)