[Rd] pythag missing in src/appl/ROUTINES (PR#544)
Roger.Bivand@nhh.no
Roger.Bivand@nhh.no
Mon, 15 May 2000 16:26:11 +0200 (MET DST)
Full_Name: Roger Bivand
Version: 1.0.1
OS: Linux RH 6.1
Submission from: (NULL) (158.37.102.52)
I am trying to use pythag() from src/appl in a .Call() function.
pythag seems to be missing from the ROUTINES list in appl - putting
it in solved the problem:
> x <- 1
> y <- 1
> sqrt(x^2 + y^2)
[1] 1.414214
> dyn.load("pythagtry.so")
Error in dyn.load(x, as.logical(local), as.logical(now)) :
unable to load shared library "/home/rsb/tmp/pythagtry.so":
/home/rsb/tmp/pythagtry.so: undefined symbol: pythag
> is.loaded("pythag")
[1] FALSE
-----------------------------------------
/* pythagtry.c */
#include <R.h>
#include <Rdefines.h>
#include <R_ext/Applic.h>
SEXP pytry(SEXP x, SEXP y)
{
SEXP ans;
double xa, xb;
xa = NUMERIC_POINTER(x)[0];
xb = NUMERIC_POINTER(y)[0];
PROTECT(ans = NEW_NUMERIC(1));
NUMERIC_POINTER(ans)[0] = pythag(xa, xb);
UNPROTECT(1);
return(ans);
}
-------------------------------------------------------------
$ R_HOME=/usr/local/lib/R gcc -I/usr/local/lib/R/include -c pythagtry.c
$ gcc -shared -o pythagtry.so pythagtry.o
-----------------------------------------------------------
added:
C_FUNCTION(pythag)
to /usr/local/src/R-1.0.1/src/appl/ROUTINES
make
make install
> x <- 1
> y <- 1
> sqrt(x^2 + y^2)
[1] 1.414214
> is.loaded("pythag")
[1] TRUE
> dyn.load("pythagtry.so")
> .Call("pytry", x, y)
[1] 1.414214
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._