Boost logo

Ublas :

Subject: Re: [ublas] Newbie getting started
From: petros (pmamales_at_[hidden])
Date: 2012-04-11 12:24:30

Assuming that your LAPACK.lib has a c-interface (o/wise clapack is wehat you
want - unless you want to do
C to FORTRAN calls ),
you need to wrap a function like xGEEV ( where x is s, d, c or z depending
on the type - float, double, complex, complex double ).
Its signature is :
void dgeev( const char* jobvl, const char* jobvr, const MKL_INT* n,
            double* a, const MKL_INT* lda,
            double* wr, double* wi,
            double* vl, const MKL_INT* ldvl,
            double* vr, const MKL_INT* ldvr,
            double* work, const MKL_INT* lwork,
            MKL_INT* info );
(assume MKL_INT to be an int).
In your wrapper you say ( A your matrix):

char jobvl = 'N' ; //do not compute left eigenvectors
char jobvr = 'N'; // nor the right ones (if you want them, say 'V').
int n = A.nbrRows() ;
double * a = &A(0,0) ;
int lda = A.nbrRows(); // ( for column major matrices - lapack being
fortran-written was column based)

The output arrays vl and vr host the left/right eigenvectors. If you choose
to ask for them ( jobvl/r='V'),
you have to pre-allocate them ( for you: create two matrices L and R and
resize them to nXn and pass
the address of the first element and for leading dimension (ld..whatever) n
( n = A.nbrRows() )

lwork is the size of a buffer needed for the computations.
If you call the function after you set lwork = -1, then lapack will put in
area pointed by work the optimal size.
Then you resize work ( boost::ublas::..::UnboundedArray is OK for work ) (
in case of lwork = -1, though, just put
int workQry, and call with &workQry and then use the UnboundedArray's
&work[0] ).
Anyway, put it to be 3*n for jobvl/r='N', or 4*n o/wise.

I believe ldvl and ldvr have to be at leat 1, even if you don't ask for

Finally - and this is the juice for you - wr, wi are the real and imaginary
parts of the eigenvalues..
You need to allocate the buffers beforehand!!!

On return :
info = 0 ---> lapack call succeded
info = -i ---> ith arg is messed up
info = i ---> QR decomposition failed. e-values i+1 to n are OK though.


-----Original Message-----
From: Ushtarador
Sent: Wednesday, April 11, 2012 10:45 AM
To: ublas_at_[hidden]
Subject: [ublas] Newbie getting started

Hey there,

I am trying to calculate eigenvalues of small, dense matrices. Since the
project is already using boost, I am trying to get LAPACK working, but since
i am not very experienced, I am stuck at the moment. I've been searching for
hours now, but noboy seems to have such basic problems.
I now have:
- The library file LAPACK.lib
- A Visual Studio 2008 project where I would like to calculate eigenvalues
of a boost matrix

I also added the svn repository
to the boost-directory on my harddisk, but I am not sure if I did something

Could someone please give me step-by-step instructions how to proceed now?

Thanks very much in advance, Christoph

View this message in context:
Sent from the Boost - uBLAS mailing list archive at
ublas mailing list
Sent to: pmamales_at_[hidden]