[Rd] Lapack / dgesvx function declaration

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Jun 6 11:37:14 CEST 2014


On 04/06/2014 10:53, Kristian Buchardt wrote:
> Hello there
>
> I'm writing some c-code to solve a numerically tough problem for me in
> R. Looking in Lapack.h, i find the following line
>
> F77_NAME(dgesvx)(const int* fact, const char* trans, const int* n,
>
> and I believe that "fact" should've been char instead of int, i.e.
>
> F77_NAME(dgesvx)(const char* fact, const char* trans, const int* n,
>
>
> My reasoning: In the R-source:
> src/modules/lapack/dlapack.f
>
> I find the following lines:
>
> *       SUBROUTINE DGESVX( FACT, TRANS, N, NRHS, A, LDA, AF, LDAF, IPIV,
> *                          EQUED, R, C, B, LDB, X, LDX, RCOND, FERR, BERR,
> *                          WORK, IWORK, INFO )
> *
> *       .. Scalar Arguments ..
> *       CHARACTER          EQUED, FACT, TRANS
> *       INTEGER            INFO, LDA, LDAF, LDB, LDX, N, NRHS
> *       DOUBLE PRECISION   RCOND
>
> where FACT is specified to a char.
>
>
> Might this simply be an error in Lapack.h? And can I just edit my
> Lapack.h and compile?

It is an error.  Thanks for reporting it: we will change future R 
sources and you can edit locally as well.

Note though that passing FORTRAN CHARACTER variables from C is tricky 
(see 'Writing R Extensions') and for portable code we would recommend a 
FORTRAN wrapper which converted integer codes sent from C to FORTRAN 
CHARACTER variables.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list