## Regarding LAPACKE_dsyev api usage

Open discussion regarding features, bugs, issues, vendors, etc.

### Regarding LAPACKE_dsyev api usage

I am using following code to compute eign value and eigh vectors:

Code: Select all
`#include <stdlib.h>#include <stdio.h>#include "lapacke.h"/* Auxiliary routines prototypes */extern void print_matrix( char* desc, lapack_int m, lapack_int n, double* a, lapack_int lda );/* Parameters */#define N 3#define LDA N/* Main program */int main() {        /* Locals */        lapack_int n = N, lda = LDA, info;        /* Local arrays */        double w[N];        double a[LDA*N] = {        3,2,4,   2,0,2,   4,2,3   };        /* Executable statements */        printf( "LAPACKE_dsyev (row-major, high-level) Example Program Results\n" );        /* Solve eigenproblem */        info = LAPACKE_dsyev( LAPACK_ROW_MAJOR, 'V', 'U', n, a, lda, w );        /* Check for convergence */        if( info > 0 ) {                printf( "The algorithm failed to compute eigenvalues.\n" );                exit( 1 );        }        print_matrix( "Eigenvalues", 1, n, w, 1 );        print_matrix( "Eigenvectors (stored columnwise)", n, n, a, lda );        exit( 0 );} /* End of LAPACKE_dsyev Example *//* Auxiliary routine: printing a matrix */void print_matrix( char* desc, lapack_int m, lapack_int n, double* a, lapack_int lda ) {        lapack_int i, j;        printf( "\n %s\n", desc );        for( i = 0; i < m; i++ ) {                for( j = 0; j < n; j++ ) printf( " %6.2f", a[i*lda+j] );                printf( "\n" );        }}`

i also have another code for doing the same:
Code: Select all
`#include <stdlib.h>#include <stdio.h>#include "lapacke.h"/* Parameters *//* Main program */int main() {        char jobz='N',uplo='U';        int i;        double w;        lapack_int lda=3,n=3,info=8;        double a = {         3,2,4,         2,0,2,        4,2,3        };        info=LAPACKE_dsyev(LAPACK_ROW_MAJOR,jobz,uplo,  n  ,&a,  lda  , &w);        if( info > 0 ) {                printf( "The algorithm failed to compute eigenvalues.\n" );                exit( 1 );        }        for(i=0;i<9;i++)        {                printf("%f\n",w[i]);        }        exit( 0 );} /* End of LAPACKE_dsyev Example */`

but i am getting code 1:

Eigenvalues
-1.00 -1.00 8.00

Eigenvectors (stored columnwise)
-0.49 -0.56 0.67
-0.47 0.82 0.33
0.73 0.15 0.67

and code 2 :

-1.000000
-1.000000
8.000000

8399042787434929076379500977075822760523682999640557766090814118267425172824413287923039437671358267392.000000
0.000000
0.000000
0.000000
0.000000
0.000000

the eign values are okay ,
but the eign vectors are the problem here because :
http://math.oregonstate.edu/home/progra ... eigen.html
for k=-1: <1,-2,0> and <4,2,-5> for k=8: <2,1,2>

Where am i going wrong in both code 1 and code 2??
Any help/hint will be appreciated.
puneet336

Posts: 1
Joined: Tue Sep 01, 2015 1:18 am

### Re: Regarding LAPACKE_dsyev api usage

there are plenty of post on "Eigenvectors corresponding to equal eigenvectors are not unique"
See https://icl.cs.utk.edu/lapack-forum/vie ... ?f=2&t=178 for example
Hope it helps