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

Berend Hasselman bhh at xs4all.nl
Tue May 5 14:38:58 CEST 2015


> On 05-05-2015, at 13:01, Lees, Jonathan M <jonathan.lees at unc.edu> wrote:
> 
> Thank you for your kind remarks - I will do my best to
> fix this hack.
> I was not familiar Makevars/Lapack - a good example would be useful.
> 
> I will also provide example tests, no problem.
> 

Look in package geigen how to write a Fortran wrapper and use Makevars.
It’s not difficult.

You should check the Lapack included in R to see if it contains dggsvd.
If not you’ll have to include dggsvd.f and dependencies from Lapack in your package.

I checked the source of R-3.1.3 and R-3.2.0 and dggsvd is included in the R sources:  src/modules/lapack/dlapack.f
which means  if I’m correct that you may assume it is always available.

Berend

> Jonathan
> 
> 
> 
> ==========================================
> Prof. Jonathan M. Lees
> Chair, Department of Geological Sciences
> CB #3315, Mitchell Hall
> University of North Carolina
> Chapel Hill, NC  27599-3315
> (919) 962-1562
> (919) 962-3869 (Chair Office)
> FAX (919) 966-4519
> 
> jonathan_lees at unc.edu
> http://www.unc.edu/~leesj
> 
> ==========================================
> 
> 
> 
> 
> 
> On 5/5/15, 4:07 AM, "Berend Hasselman" <bhh at xs4all.nl> wrote:
> 
>> 
>>> 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:
>>> 
>>>> GSVD
>>> 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...
>> 
>> Correct.
>> 
>> 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.
>> 
>> Berend
>> 
> 



More information about the R-SIG-Mac mailing list