[R-SIG-Mac] Problem with GSUB in PEIP

Berend Hasselman bhh at xs4all.nl
Tue May 5 10:07:43 CEST 2015

> On 04-05-2015, at 22:22, Simon Urbanek <simon.urbanek at r-project.org> wrote:
> You may want to report to the maintainer - the GSVD sources have the following which is completely broken:
> function (A, B) 
> {
>    SS = Sys.info()
>    ssysname = SS[[1]]
>    if (ssysname == "Linux") {
>        lpath = paste(R.home(), "/lib/libRlapack.so", sep = "")
>    }
>    else {
>        lpath = paste(R.home(), "lib/i386/libRlapack.dylib", 
>            sep = "")
>    }
> [...]
>    dyn.load(lpath)
> It seems like the author failed to use the proper flags for linking LAPACK and then tried to hack around it in a horrible way that doesn't really work.
> I suppose this happens when you don't even have a single test that a particular function works otherwise CRAN checks would not allow it in...


And there is another issue with GSVD: it uses .Fortran to call the Lapack routine dggsvd with as.character(..) for the dggsvd 
Fortran character arguments. This is not guaranteed to work on all platforms.
I ran into this with my package geigen.

A solution is to write a wrapper around dggsvd in Fortran that accepts integer arguments for the JOB? options and converts these in the Fortran wrapper to the appropriate Lapack characters. You can then use a Makevars file to specify that your fortran code needs the Lapack library which would save you from the error prone method in PEIP.

And test your function that it works and is able to handle input errors.


More information about the R-SIG-Mac mailing list