I want to do the EVD wth this 4x4
covariance matrix:
cuDoubleComplex m_cov_[16] = {
make_cuDoubleComplex(2.0301223848037391, 3.4235008150792548e-17),
make_cuDoubleComplex(1.0365842528472908, -2.1028119220635375),
make_cuDoubleComplex(2.7516978261134084, 0.95059712173944222),
make_cuDoubleComplex(-1.350157109070875, -1.1815219722269694),
make_cuDoubleComplex(1.0365842528472908, 2.1028119220635375),
make_cuDoubleComplex(2.7073859851827988, 8.7392491301242207e-17),
make_cuDoubleComplex(0.42038828834095354, 3.3356003818061963),
make_cuDoubleComplex(0.53443422887585779, -2.0017874620940646),
make_cuDoubleComplex(2.7516978261134084, -0.95059712173944222),
make_cuDoubleComplex(0.42038828834095354, -3.3356003818061963),
make_cuDoubleComplex(4.1748595442022722, 2.0100622219496206e-17),
make_cuDoubleComplex(-2.3832926547827333, -0.9692696339061293),
make_cuDoubleComplex(-1.350157109070875, 1.1815219722269694),
make_cuDoubleComplex(0.53443422887585779, 2.0017874620940646),
make_cuDoubleComplex(-2.3832926547827333, 0.9692696339061293),
make_cuDoubleComplex(1.5855784922744534, -1.5877902777669332e-17)
};
// EVD
Eigen::SelfAdjointEigenSolver<Eigen::MatrixXcd> eigensolver(m_cov_);
eigenValues_ = eigensolver.eigenvalues();
eigenVectors_ = eigensolver.eigenvectors();
By C++ Eigen
lib, the eigen values
are below:
{{x = -2.2573766836348074e-15, y = 0},
{x = -9.709294041296323e-16, y = 0},
{x = 8.9445808618868127e-17, y = 0},
{x = 10.280850897111305, y = 0}}
And the 4x4
eigen vectors
are below:
{{x = -0.3470929425161523, y = 0}, {x = -0.77713832029830621, y = -0}, {x = -0.15994536685820598, y = 0}, {x = 0.5, y = 0}},
{{x = -0.4597724303808105, y = 0.48181665117044714}, {x = 0.12469176895072034, y = -0.019363390950754053}, {x = -0.28597710463196591, y = 0.45689839613393701}, {x = -0.21684345356939669, y = 0.45053181535169839}},
{{x = -0.42256553981019185, y = -0.42733105533794741}, {x = 0.41437862159459787, y = 0.29068296724286291}, {x = 0.33214873805084277, y = 0.14932354148008731}, {x = 0.45697128218787925, y = 0.2029217761985285}},
{{x = -0.21707002501160269, y = 0.16642011333440535}, {x = -0.27240794554375036, y = 0.22298146715732753}, {x = 0.60350719516570406, y = -0.43247796708208042}, {x = -0.38102789443353835, y = 0.32375568514474662}}}
But with the same input, cuBLAS return the different results.
I use the cuBLAS EVD function below:
CHECK_CUSOLVER(cusolverDnZheevd(cusolverH, CUSOLVER_EIG_MODE_VECTOR, CUBLAS_FILL_MODE_UPPER, N, m_eigen_vec.data(), N, m_eigen_value.data(), d_work, lwork, devInfo));
And the eigen values and eigen vectors are below:
// Eigen Values
{-5.2180864461495171e-16,
-3.0110342183593702e-16,
2.8548936444323134e-16,
10.497946406463264}
// Eigen Vectors
{{x = -0.38208898741712083, y = 0.41581487741664563}, {x = 0.32043709404849968,
y = -0.4517568232420171}, {x = 0.21717632600175682, y = -0.36577789346231687}, {x = -0.33093161501032731,
y = 0.28959813033042575}, {x = -0.17547383350755327, y = -0.69642001620440552}, {x = -0.10241833368805221,
y = -0.43952076894648784}, {x = 0.047402059701005216, y = 0.14281594546174881}, {x = 0.13099303872894871,
y = 0.49065012752041015}, {x = -0.32475905997549959, y = 0.077154117638887132}, {x = -0.32253254381877083,
y = 0.2157036870035538}, {x = -0.50261510442239055, y = 0.29617238148252628}, {x = -0.58415934115419899,
y = 0.23757380765099248}, {x = -0.23214840790484073, y = 0}, {x = 0.58224779741288002, y = 0}, {x = -0.67532037122395228,
y = 0}, {x = 0.38863480971863701, y = 0}}
You can notice that the sorted eigen values
calc from Eigen Lib
and from cuBLAS
are the same (three ~0 values and one larger value) but the eigen vectors
are totally different.
I’ve wrote a lot of unit tests for each step, and I’m sure that the eigen values and vectors from Eigen lib
are correct, can someone tell me how to get the same answer with cuBLAS
EVD?