Skip to content
Back to formatted view

Raw Message

Message-ID: <BF20B805-1DC0-4DDB-9A46-ED19750A05E1@xs4all.nl>
Date: 2019-09-12T09:07:06Z
From: Berend Hasselman
Subject: Calling a LAPACK subroutine from R
In-Reply-To: <026463ed-e8df-3d28-fef9-94ac3b1c740b@insa-toulouse.fr>

> On 12 Sep 2019, at 10:36, Serguei Sokol <sokol at insa-toulouse.fr> wrote:
> 
> On 11/09/2019 21:38, Berend Hasselman wrote:
>> The Lapack library is loaded automatically by R itself when it needs it  for doing some calculation.
>> You can force it to do that with a (dummy) solve for example.
>> Put this at start of your script:
>> 
>> <code>
>> # dummy code to get LAPACK library loaded
>> X1 <- diag(2,2)
>> x1 <- rep(2,2)
>> # X1;x1
>> z <- solve(X1,x1)
>> </code>
> another way is to use directly dyn.load():
> 
> lapack.path <- paste0(file.path(R.home(), ifelse(.Platform$OS.type == "windows",
>          file.path("bin", .Platform$r_arch, "Rlapack"), file.path("lib", "libRlapack"))),
>          .Platform$dynlib.ext)
> dyn.load(lapack.path)


This will not work on macOS.
The extension for dynamic libraries is .dylib.
So you would need 

lapack.path <- paste0(file.path(R.home(), ifelse(.Platform$OS.type == "windows",
         file.path("bin", .Platform$r_arch, "Rlapack"), file.path("lib", "libRlapack"))),
         ".dylib")

See the help for .Platform and dyn.load for the details for macOS.

Berend