The LAPACK forum has moved to https://github.com/Reference-LAPACK/lapack/discussions.

Issue with ssyev

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

Issue with ssyev

Postby dimfifth » Mon Dec 15, 2008 1:58 pm

Dear All,

I am trying to use ssyev to compute eigenvalues of a large matrix, but I could not get it working.

Later, I tried just finding the eigenvalues of an identity matrix of size 4, but still the results I am getting
are very arbitrary. I am not sure why this is happening. I would appreciate any help in this direction.
I am giving my code here, which just computes the eigenvectors of Identity matrix of size 4. I do get
info = 0, for this as output!

Thank you all,
df.

Code: Select all
#include <acml.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

#define NSAMP 4

void printMatrix(float **mat, int r, int c, char*str = "Noname")
{

        fprintf(stderr,"\nBegMat----%s--\n",str);
        for(int i = 0; i < r; i++)
        {
                for(int j = 0; j < c; j++)
                        printf("%f ",mat[i][j]);
                printf("\n");
        }
        fprintf(stderr,"EndMat---------\n");
}
float **newMatrix(int r, int c)
{
        float **mat = (float **)calloc(r,sizeof(float *));
        for (int i = 0; i < r; i++)
                mat[i] = (float *)calloc(c,sizeof(float));
        return mat;
}
float **eye(int r)
{
        float **mat = newMatrix(r,r);
        for (int i = 0; i < r; i++)
                mat[i][i] = 1;
        return mat;
}
int main(int argc, char ** argv)
{
        // either load the pwdist from a file, or compute by calling the function
        const char *kernelFile = PWDISTFILE;
        const int nSamples = NSAMP;
        const float sigma = 1;
        float **pwdist = eye(4); // computes the identity matrix

        int LDZ = NSAMP;
        float Z[LDZ*nSamples];
        float *W =(float *)malloc(nSamples*sizeof(float));

        int lwork = 3*nSamples - 1;
        float WorkSpace[lwork];
        int info;

        ssyev('V','U',nSamples,&(pwdist[0][0]),nSamples,W,&info);

        printMatrix(&W,1,nSamples,"Eigvals");
        printMatrix(pwdist,nSamples,nSamples,"Eigvecs");
        fprintf(stderr,"Success Status: %d\n",info);
}
dimfifth
 
Posts: 2
Joined: Fri Dec 12, 2008 5:36 am

Re: Issue with ssyev

Postby dimfifth » Mon Dec 15, 2008 3:48 pm

I guess I figured it out. I think the input array must be one dimensional. How come the man page says the dimension is (LDA, N) ? Shouldn't it be LDA*N ? This is because for other arrays which are one-dimensional, (e.g. LWORK), the size is given as a single number.

Please correct me if I am wrong.

Thank you,
df.
dimfifth
 
Posts: 2
Joined: Fri Dec 12, 2008 5:36 am


Return to User Discussion

Who is online

Users browsing this forum: No registered users and 7 guests