[R] generalized eigenvalues - porting code using eig() from Matlab to R

Gavin Simpson gavin.simpson at ucl.ac.uk
Mon Sep 13 19:47:22 CEST 2004


Dear list,

I am porting some Matlab routines to R. I am looking for the equivalent 
function in R for the Matlab function eig(), such that eig(A, B) 
<quote>produces a diagonal matrix D of generalized eigenvalues and a 
full matrix V whose columns are the corresponding eigenvectors so that 
A*V = B*V*D</quote>[1].

More specifically, I want to find the eigenvalues and eigenvectors of 
eig(ZKZt, diag(K1)) where:

ZKZt
              [,1]          [,2]         [,3]          [,4]
[1,]  0.024326360 -0.0087060425 -0.029307513 -0.0131484613
[2,] -0.001316161  0.0028641451  0.003249924  0.0003892546
[3,] -0.016591044  0.0061132182  0.021493284  0.0083083670
[4,] -0.006419155 -0.0002713207  0.004564305  0.0044508397

and

diag(K1)
           [,1]      [,2]      [,3]      [,4]
[1,] 0.2307692 0.0000000 0.0000000 0.0000000
[2,] 0.0000000 0.2307692 0.0000000 0.0000000
[3,] 0.0000000 0.0000000 0.3076923 0.0000000
[4,] 0.0000000 0.0000000 0.0000000 0.2307692

How would I go about doing this in R?

Thanks in advance,

Gavin

[1] 
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/eig.html?cmdname=eig
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson                     [T] +44 (0)20 7679 5522
ENSIS Research Fellow             [F] +44 (0)20 7679 7565
ENSIS Ltd. & ECRC                 [E] gavin.simpson at ucl.ac.uk
UCL Department of Geography       [W] http://www.ucl.ac.uk/~ucfagls/cv/
26 Bedford Way                    [W] http://www.ucl.ac.uk/~ucfagls/
London.  WC1H 0AP.
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%




More information about the R-help mailing list