Skip to content

Commit 9437f99

Browse files
author
ripley
committed
document some LINPACK routines as part of the API
git-svn-id: https://svn.r-project.org/R/trunk@88123 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 50c64b4 commit 9437f99

File tree

2 files changed

+69
-16
lines changed

2 files changed

+69
-16
lines changed

doc/manual/R-exts.texi

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6390,7 +6390,7 @@ warning: argument 1 value '18446744073709551615' exceeds maximum object
63906390
@item
63916391
Some authors feel the need to print (using @code{Rprintf} or
63926392
similar) vector lengths or indices which are of type @code{R_xlen_t}.
6393-
That may be a 32-bit or (most commonly) 64-bit type but which integer
6393+
That is (almost always) a 64-bit type but which integer
63946394
type it is mapped to is platform-specific. The safest way is to cast
63956395
the length to double and use a double format. So one could use
63966396
something like
@@ -6419,7 +6419,7 @@ So the values will need to be cast to the type assumed by the format
64196419
@I{Variadic} macros in C or C++ only portably allow a non-zero number of
64206420
arguments, although some compilers have allowed zero, often with a
64216421
warning. The latter was standardized in C++20 using the @code{__VA_OPT__}
6422-
macro. C23 also allows zero arguments in a similar way.
6422+
macro. C23 allows zero arguments in a similar way.
64236423

64246424
@end itemize
64256425

@@ -6430,10 +6430,10 @@ by @I{Martyn Plummer}.
64306430
Several OSes have or currently do provide multiple C++ runtimes ---
64316431
Solaris did and the @I{LLVM} @command{clang} compiler has a native C++
64326432
runtime library @code{libc++} but is also used with GCC's
6433-
@code{libstdc++} (by default on Debian/Ubuntu). This makes it unsafe to
6434-
assume that OS libraries with a C++ interface are compatible with the
6435-
C++ compiler specified by @R{}. Many of these system libraries also
6436-
have C interfaces which should be used in preference to their C++
6433+
@code{libstdc++} (by default on Debian/Ubuntu/Fedora). This makes it
6434+
unsafe to assume that OS libraries with a C++ interface are compatible
6435+
with the C++ compiler specified by @R{}. Many of these system libraries
6436+
also have C interfaces which should be used in preference to their C++
64376437
interface. Otherwise it is essential that a package checks
64386438
compatibility in its @command{configure} script, including that C++ code
64396439
using the library can both be linked @emph{and loaded}.
@@ -15737,8 +15737,8 @@ Cdgemm(const char *transa, const char *transb, const int *m,
1573715737
@end example
1573815738

1573915739
@noindent
15740-
Alternatively, do as @R{} does as from version 3.6.2 and pass
15741-
the character length(s) from C to Fortran. A portable way to do this is
15740+
Alternatively, do as @R{} does and pass the character length(s) from C
15741+
to Fortran. A portable way to do this is
1574215742
@example
1574315743
// before any R headers, or define in PKG_CPPFLAGS
1574415744
#ifndef USE_FC_LEN_T
@@ -15755,9 +15755,9 @@ the character length(s) from C to Fortran. A portable way to do this is
1575515755
@end example
1575615756
@noindent
1575715757
(Note there is no comma before or between the @code{FCONE} invocations.)
15758-
It is strongly recommended that packages which call from C/C++
15759-
BLAS/LAPACK routines with character arguments adopt this approach:
15760-
packages not using it will fail to install as from @R{} 4.3.0.
15758+
Packages which call from C/C++ BLAS/LAPACK routines with character
15759+
arguments must adopt this approach: packages not using it will now fail
15760+
to install.
1576115761

1576215762
@node Fortran LOGICAL
1576315763
@subsection Fortran LOGICAL
@@ -16696,6 +16696,59 @@ the original functions by Fox, Hall and @I{Schryer} on @I{Netlib} at
1669616696
@apifun d1mach
1669716697
@apifun i1mach
1669816698

16699+
@node Linear algebra
16700+
@section Linear algebra
16701+
16702+
The preferred way to do numerical linear algebra from C/Fortran code is
16703+
to use BLAS/LAPACK@footnote{The distinction is increasing blurred, with
16704+
the reference BLAS being distributed as part of the LAPACK sources.}
16705+
Declarations callable from C/C++ are provided in headers
16706+
@file{R_ext/BLAS.h} and @file{R_ext/LAPACK.h}.
16707+
16708+
However, a number of Fortran routines are included in @R{} and underlie
16709+
@code{lm.fit()}, @code{lm.wfit()} and @code{qr(LAPACK = FALSE)} and its
16710+
helper functions. These remain available to packages which wish to
16711+
emulate what @R{} does, and are declared as a C/C++ interface in header
16712+
@file{R_ext/Applic.h}. But they are also often called @emph{via}
16713+
@code{.Fortran()} and from Fortran code.
16714+
16715+
@apifun dqrqty
16716+
@apifun dqrqy
16717+
@apifun dqrcf
16718+
@apifun dqrrsd
16719+
@apifun dqrxb
16720+
@apifun dqrls
16721+
@apifun dqrdc2
16722+
@example
16723+
void F77_NAME(dqrqty)(double *x, int *n, int *k, double *qraux,
16724+
double *y, int *ny, double *qty);
16725+
void F77_NAME(dqrqy)(double *x, int *n, int *k, double *qraux,
16726+
double *y, int *ny, double *qy);
16727+
void F77_NAME(dqrcf)(double *x, int *n, int *k, double *qraux,
16728+
double *y, int *ny, double *b, int *info);
16729+
void F77_NAME(dqrrsd)(double *x, int *n, int *k, double *qraux,
16730+
double *y, int *ny, double *rsd);
16731+
void F77_NAME(dqrxb)(double *x, int *n, int *k, double *qraux,
16732+
double *y, int *ny, double *xb);
16733+
void F77_NAME(dqrls)(double *x, int *n, int *p, double *y, int *ny,
16734+
double *tol, double *b, double *rsd,
16735+
double *qty, int *k,
16736+
int *jpvt, double *qraux, double *work);
16737+
void F77_NAME(dqrdc2)(double *x, int *ldx, int *n, int *p,
16738+
double *tol, int *rank,
16739+
double *qraux, int *pivot, double *work);
16740+
@end example
16741+
@noindent
16742+
For further datails see their source files in directory @file{src/Appl}
16743+
in the @R{} sources or @uref{https://netlib.org/linpack/}.
16744+
@code{dqrdc2} is an extensive @R{} modification to LINPACK's
16745+
@code{dqrdc} which uses column pivoting and computes the (numerical)
16746+
rank.
16747+
16748+
These are for the time being regarded as part of the API but may in
16749+
future be supplemented or replaced by interfaces using Fortran 2003's
16750+
@code{bind(C)}.
16751+
1669916752

1670016753
@node Re-encoding
1670116754
@section Re-encoding

src/include/R_ext/Applic.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* R : A Computer Language for Statistical Data Analysis
3-
* Copyright (C) 1998-2024 The R Core Team
3+
* Copyright (C) 1998-2025 The R Core Team
44
*
55
* This header file is free software; you can redistribute it and/or modify
66
* it under the terms of the GNU Lesser General Public License as published by
@@ -89,7 +89,7 @@ int findInterval(double *xt, int n, double x,
8989
int *mflag);
9090
// findInterval2() is only in Utils.h (and hence Rinternals.h)
9191

92-
/* The following are registered for use in .C/.Fortran */
92+
/* The following are registered for use in .Fortran */
9393

9494
/* ../../appl/dqrutl.f: interfaces to dqrsl */
9595
void F77_NAME(dqrqty)(double *x, int *n, int *k, double *qraux,
@@ -102,18 +102,18 @@ void F77_NAME(dqrrsd)(double *x, int *n, int *k, double *qraux,
102102
double *y, int *ny, double *rsd);
103103
void F77_NAME(dqrxb)(double *x, int *n, int *k, double *qraux,
104104
double *y, int *ny, double *xb);
105-
/* end of registered */
106-
107105
/* find qr decomposition, dqrdc2() is basis of R's qr(),
108106
also used by nlme and many other packages. */
109107
void F77_NAME(dqrdc2)(double *x, int *ldx, int *n, int *p,
110108
double *tol, int *rank,
111109
double *qraux, int *pivot, double *work);
110+
/* end of registered */
112111
void F77_NAME(dqrls)(double *x, int *n, int *p, double *y, int *ny,
113112
double *tol, double *b, double *rsd,
114113
double *qty, int *k,
115114
int *jpvt, double *qraux, double *work);
116-
115+
/* dtrco (for .kappa.tri) is registered but not in the API */
116+
117117
/* ------------------ Entry points NOT in the R API --------------- */
118118

119119
/* hidden, for use in R.bin/R.dll/libR.so */

0 commit comments

Comments
 (0)