[R] Solve an ordinary or generalized eigenvalue problem in R?

Berend Hasselman bhh at xs4all.nl
Fri Apr 20 21:31:46 CEST 2012


On 20-04-2012, at 18:58, Jonathan Greenberg wrote:

> So I am a complete noob at doing this type of linking.  When I write this statement (all the input values are assigned, but I have to confess I don't know what to do with the output variables -- in this call they are all assigned "NA"):
> 
> .Call("La_dgeev", JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHAR=NA, ALPHAI=NA, BETA=NA,
> + 			VL=NA, LDVL, VR=NA, LDVR, WORK=NA, LWORK, INFO=NA, PACKAGE="base")
> 
> I get:
> 
> Error in .Call("La_dgeev", JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHAR = NA,  : 
>   C symbol name "La_dgeev" not in DLL for package "base"
> 
> I'm running this on Windows 7 x64 version of R 2.14.2.  The R_ext/Lapack.h file states:
> 
> /* DGEEV - compute for an N-by-N real nonsymmetric matrix A, the */
> /* eigenvalues and, optionally, the left and/or right eigenvectors */
> La_extern void
> F77_NAME(dgeev)(const char* jobvl, const char* jobvr,
> 		const int* n, double* a, const int* lda,
> 		double* wr, double* wi, double* vl, const int* ldvl,
> 		double* vr, const int* ldvr,
> 		double* work, const int* lwork, int* info);
> 
> Any ideas?  
> 

Yes. Stop this.

You are completely on the wrong track and  getting yourself into a real muddle.

1. you are mixing up dgeev and dggev. You are using the dggev arguments to call dgeev. Even if you got it all correct this would result in nasty errors.
2. La_dgeev doesn't exist in the R sources (nor does it exist in Lapack) and you don't need to use dgeev. See below.

Since you are a "noob" I would advise you to not try and interface with Fortran or C at this moment.

It is possible to interface with dggev for generalized eigenvalues but it is not a straightforward and easy job to do.
I've had a look at the R and C code used in the R sources to interface with dgeev. It would need a lot of TLC.

As I told you before: R provides a function eigen for calculating "normal"  eigenvalues end eigenvectors.

It's probably a good idea to explain why you need generalized eigenvalues.
Then someone may be able to come up with suggestions and/or alternatives.

Berend



More information about the R-help mailing list