Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

## Eigenvalue/Eigenvectors calculation

New Contributor I
1,636 Views

I am trying to use the dsytrd/dorg function to calculate the eigenvalues and eigen vectors for a symmetric matrix. For some reason (probably my incorrect way of calling them), it does not seem to do the job. All the results are wrong. This is a very simple code snipet using the dsytrd to do the tridiagonal decomposition. The output in array d (for the eigenvalues) is completely wrong.

Any help appreciated.

John

double[] a = new double[] { 1, 2, 2, 1 };
double[] d = new double[2];
double[] e = new double[2];
double[] tau = new double[2];
unsafe
{
fixed (double* pa = a, pd = d, pe = e, ptau = tau)
{
int info = LAPACKE_dsytrd(LAPACK_ROW_MAJOR, 'L', 2, pa, 2, pd, pe, ptau);
}
}

1 Solution
Moderator
1,429 Views

Hi,

Reminder:

Has the solution provided helped.

If this resolves your issue, make sure to accept this as a solution. This would help others with similar issue. Thank you!

Best Regards,

Shanmukh.SS

8 Replies
Valued Contributor III
1,611 Views

May I kindly suggest that:

1. You consider using Pardiso and feast

2. @mecej4  very kindly set up PARDISO and feast to solve this type of problem for me, (I could not get the packing to work) in a program called Lothuur - Norse God.

It works. You will need to pull out the bits you need, but it is pretty modular.

Moderator
1,564 Views

Hi,

Thanks for reaching out to us.

Kindly share us the complete reproducer, so that we could troubleshoot the issue from end.

In addition, for your information, Below function is used to reduce a real symmetric matrix to tridiagonal form. (Attaching the developer link for your reference)

lapack_int LAPACKE_dsytrd (int matrix_layout, char uplo, lapack_int n, double* a, lapack_int lda, double* d, double* e, double* tau);

https://www.intel.com/content/www/us/en/develop/documentation/onemkl-developer-reference-c/top/lapack-routines/lapack-least-squares-and-eigenvalue-problem/lapack-least-square-eigenvalue-problem-computation/symmetric-eigenvalue-problems-lapack-computation/sytrd.html

To compute all eigenvalues and optionally, to compute all eigenvectors of a real symmetric matrix using divide and conquer algorithm below function is used. (Attaching the developer reference link for your reference)

lapack_int LAPACKE_dsyevd (int matrix_layout, char jobz, char uplo, lapack_int n, double* a, lapack_int lda, double* w);

https://www.intel.com/content/www/us/en/develop/documentation/onemkl-developer-reference-c/top/lapack-routines/lapack-least-squares-and-eigenvalue-problem/lapack-least-squares-eigenvalue-problem-driver/symmetric-eigenvalue-problems-lapack-driver/syevd.html

Besides this, you can refer to examples over path C:\Program Files (x86)\Intel\oneAPI\mkl\latest\examples\examples_core_c.zip\c\lapack\source\

Best Regards,

Shanmukh.SS

Moderator
1,531 Views

Hi,

Reminder:

Has the solution provided helped? Is your issue resolved? Please let us know if the issue still persists.

Best Regards,

Shanmukh.SS

New Contributor I
1,498 Views

Many thanks for the reply. I did try LAPACKE_dsyevd  and it works!. I didn't know there were two categories of functions, computational routines and driver routines. The latter is probably is more suitable for my application. But I have not got the computational routine working (see the beginning of the post). My understanding is that after the decomposition into tridiagonal matrix, the results stored in array 'd' should be the eigenvalues. But in my case, it is not.

New Contributor I
1,495 Views

To further explain the problem I have, I have attached a screenshot. Basically, I tried to decompose a very simple symmetric matrix

[1, 2]

[2, 1]

The eigenvalues should be 3 and -1.  But as you see in the screenshot, after calling the function, I get 1 and 1 in the d array.

Please let me know if there is any wrong with the way I called the function. Thanks.

John

Moderator
1,457 Views

Hi,

To find all eigenvalues of a tridiagonal matrix T, you could use the function "sterf" which computes all eigenvalues of a real symmetric tridiagonal matrix using QR algorithm.

sterf functionality:

https://www.intel.com/content/www/us/en/develop/documentation/onemkl-developer-reference-c/top/lapack-routines/lapack-least-squares-and-eigenvalue-problem/lapack-least-square-eigenvalue-problem-computation/symmetric-eigenvalue-problems-lapack-computation/sterf.html#sterf

Symmetric Eigenvalue Problems: LAPACK Computational Routines:

https://www.intel.com/content/www/us/en/develop/documentation/onemkl-developer-reference-c/top/lapack-routines/lapack-least-squares-and-eigenvalue-problem/lapack-least-square-eigenvalue-problem-computation/symmetric-eigenvalue-problems-lapack-computation.html

The eigenvalues should be 3 and -1. But as you see in the screenshot, after calling the function, I get 1 and 1 in the d array.

>> As per the sytrd functionality, d contains the diagonal elements of the matrix T which is the same as output provided by you.

To further clarify the significance of each parameter, attaching the reference link for "sytrd" functionality which reduces a real symmetric matrix to tridiagonal form.

https://www.intel.com/content/www/us/en/develop/documentation/onemkl-developer-reference-c/top/lapack-routines/lapack-least-squares-and-eigenvalue-problem/lapack-least-square-eigenvalue-problem-computation/symmetric-eigenvalue-problems-lapack-computation/sytrd.html

Best Regards,

Shanmukh.SS

Moderator
1,430 Views

Hi,

Reminder:

Has the solution provided helped.

If this resolves your issue, make sure to accept this as a solution. This would help others with similar issue. Thank you!

Best Regards,

Shanmukh.SS

Moderator
1,411 Views

Hi,

Thanks for accepting our solution. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.

Best Regards,

Shanmukh.SS