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

Berend Hasselman bhh at xs4all.nl
Sat Apr 21 18:47:10 CEST 2012


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:
>>> 
>>> <start R code>
>>> # 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
>> 
>> dyn.load(file.path(R.home("modules"),"lapack.so"))
>> 
>> lets run geigen1.R run on Mac OS X and Ubuntu unchanged.
>> Hopefully this is the proper way to load Lapack as provided by R.
>> How to do it on Windows, I can't test.
>> 
>> Berend
>> 
>> ______________________________________________
>> R-help@ mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>> 
> 
> My system is a Windows 7 and the following function solved the dyn.load.
> 
> 
> dynlib.load <- function(x, dir){
> 	dynname <- paste(x, .Platform$dynlib.ext, sep="")
> 	dynname <- file.path(R.home(dir), dynname)
> 	dyn.load(dynname)
> }
> 
> # In windows it's these names
> dynlib.load("Rlapack", "bin")
> 
> 
> The rest worked at the first try.
> Note that this function is independent of the sub-architecture, like the
> help page for R.home() says:
> 
> "The return value for "modules" and on Windows "bin" is to a
> sub-architecture-specific location. "
> 
> (R.home("bin") returns .../bin/i386 or .../bin/x64)
> 

Thank you.
I've now changed the dyn.load line to this

if( .Platform$OS.type == "windows" ) {
    Lapack.so <- file.path(R.home("bin"),paste0("Rlapack",.Platform$dynlib.ext))
} else {
    Lapack.so <- file.path(R.home("modules"),paste0("lapack",.Platform$dynlib.ext))
}
    
dyn.load(Lapack.so)

Hopefully that will do.

BTW: lapack.so on Mac OS X is located in a sub-architecture-specific location.

Berend



More information about the R-help mailing list