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

2012-04-23 Thread Jonathan Greenberg
Building in Berend's suggestions I think this function should work for most people (I'm going to wrap it into a package but figured people may want to grab this directly): # Please see http://www.netlib.org/lapack/double/dggev.f for a description of inputs and outputs. Rdggev <- function(A,B,JOBVL

Re: [R] Solve an ordinary or generalized eigenvalue problem in R

2012-04-23 Thread John C Nash
:27:23 +0200 From: Berend Hasselman To: Jonathan Greenberg Cc: R Project Help Subject: Re: [R] Solve an ordinary or generalized eigenvalue problem in R? Message-ID: <378c084b-5cf5-4087-9aba-116c5155d...@xs4all.nl> Content-Type: text/plain; charset=us-ascii On 22-04-2012, at 21:08, Jonat

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

2012-04-22 Thread Berend Hasselman
On 22-04-2012, at 21:08, Jonathan Greenberg wrote: > Thanks all (particularly to you, Berend) -- I'll push forward with these > solutions and integrate them into my code. I did come across geigen while > rooting around in the CCA code but its not formally documented (it just says > "for inter

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

2012-04-22 Thread Jonathan Greenberg
Thanks all (particularly to you, Berend) -- I'll push forward with these solutions and integrate them into my code. I did come across geigen while rooting around in the CCA code but its not formally documented (it just says "for internal use" or something along those lines) and as you found out ab

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

2012-04-21 Thread Berend Hasselman
On 21-04-2012, at 20:20, peter dalgaard wrote: > >> >> The eigenvalues are identical upto the printed 9 digits but the eigenvectors >> appear to be quite different. >> Maybe this is what Luke meant. >> >> Berend >> > > > They look quite similar to me: > >> ev <- eigen(solve(B,A) )$vectors

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

2012-04-21 Thread peter dalgaard
On Apr 21, 2012, at 19:13 , Berend Hasselman wrote: > > On 21-04-2012, at 16:40, peter dalgaard wrote: > >> >> On Apr 21, 2012, at 15:22 , Luke Hartigan wrote: >> >>> Hi all, >>> >>> In my experience, using eigen to solve generalized eigenvalue / eigenvector >>> problems only gives correct l

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

2012-04-21 Thread Berend Hasselman
On 21-04-2012, at 16:40, peter dalgaard wrote: > > On Apr 21, 2012, at 15:22 , Luke Hartigan wrote: > >> Hi all, >> >> In my experience, using eigen to solve generalized eigenvalue / eigenvector >> problems only gives correct looking eigenvalues while the eigenvectors seem >> to be wrong (in c

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

2012-04-21 Thread Berend Hasselman
On 21-04-2012, at 17:37, Rui Barradas wrote: > Hello, > > > Berend Hasselman wrote >> >> On 21-04-2012, at 11:40, Berend Hasselman wrote: >> >>> >>> . >>> See this: >>> >>> >>> # This works on Mac OS X >>> # Change as needed for other systems >>> # or compile geigen into a standalone s

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

2012-04-21 Thread Rui Barradas
Hello, Berend Hasselman wrote > > On 21-04-2012, at 11:40, Berend Hasselman wrote: > >> >> . >> See this: >> >> >> # This works on Mac OS X >> # Change as needed for other systems >> # or compile geigen into a standalone shared object. >> >> dyn.load(file.path(R.home("lib"),"libRlapack.

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

2012-04-21 Thread peter dalgaard
On Apr 21, 2012, at 15:22 , Luke Hartigan wrote: > Hi all, > > In my experience, using eigen to solve generalized eigenvalue / eigenvector > problems only gives correct looking eigenvalues while the eigenvectors seem > to be wrong (in comparison to results from MATLAB's 'eig' function for > exam

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

2012-04-21 Thread Berend Hasselman
On 21-04-2012, at 11:40, Berend Hasselman wrote: > > . > See this: > > > # This works on Mac OS X > # Change as needed for other systems > # or compile geigen into a standalone shared object. > > dyn.load(file.path(R.home("lib"),"libRlapack.dylib")) > Replacing the dyn.load line with d

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

2012-04-21 Thread Luke Hartigan
Hi all, In my experience, using eigen to solve generalized eigenvalue / eigenvector problems only gives correct looking eigenvalues while the eigenvectors seem to be wrong (in comparison to results from MATLAB's 'eig' function for example). However, I think it is possible to solve generalized eig

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

2012-04-21 Thread Berend Hasselman
On 20-04-2012, at 21:18, Jonathan Greenberg wrote: > Ok, I figured out a solution and I'd like to get some feedback on this from > the R-helpers as to how I could modify the following to be "package > friendly" -- the main thing I'm worried about is how to dynamically set the > "dyn.load" stateme

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

2012-04-20 Thread Paul Johnson
On Fri, Apr 20, 2012 at 2:18 PM, Jonathan Greenberg wrote: > Ok, I figured out a solution and I'd like to get some feedback on this from > the R-helpers as to how I could modify the following to be "package > friendly" -- the main thing I'm worried about is how to dynamically set the There's doc

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

2012-04-20 Thread Jonathan Greenberg
My apologies: When reviewing my initial email I made a typo -- what I needed was dggev, not dgeev. I have confirmed that my function reproduces the scipy outputs I mentioned in my first email. The function is part of lapack. I'm not an R noob, I just haven't dealt with external Fortran or C cal

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

2012-04-20 Thread Berend Hasselman
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")

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

2012-04-20 Thread Jonathan Greenberg
Ok, I figured out a solution and I'd like to get some feedback on this from the R-helpers as to how I could modify the following to be "package friendly" -- the main thing I'm worried about is how to dynamically set the "dyn.load" statement below correctly (obviously, its hard coded to my particula

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

2012-04-20 Thread Jonathan Greenberg
Incidentally, if you want to test this out: > A [,1] [,2] [,3] [1,] 1457.738 1053.181 1256.953 [2,] 1053.181 1213.728 1302.838 [3,] 1256.953 1302.838 1428.269 > B [,1] [,2] [,3] [1,] 4806.033 1767.480 2622.744 [2,] 1767.480 3353.603 3259.680 [3,] 2622.744 3259.68

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

2012-04-20 Thread Jonathan Greenberg
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,

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

2012-04-19 Thread Berend Hasselman
On 19-04-2012, at 20:50, Jonathan Greenberg wrote: > Folks: > > I'm trying to port some code from python over to R, and I'm running into a > wall finding R code that can solve a generalized eigenvalue problem > following this function model: > > http://docs.scipy.org/doc/scipy/reference/generat

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

2012-04-19 Thread Jonathan Greenberg
Folks: I'm trying to port some code from python over to R, and I'm running into a wall finding R code that can solve a generalized eigenvalue problem following this function model: http://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eig.html Any ideas? I don't want to call python f