[R] load shared object
Federico Cantini
cantini at ifc.cnr.it
Wed Aug 4 11:45:06 CEST 2004
Hi all,
i have some problem in using shared objects.
I tried the example found in "Writing R Extension", pg. 33
I used the .c file prova.c :
-------------------------------------------------------------------
#include <R.h>
#include <Rinternals.h>
void convolve(double *a, int *na, double *b, int *nb, double *ab)
{
int i, j , nab = *na + *nb - 1;
for (i = 0; i < nab; i++)
ab[i] = 0.0;
for (i = 0; i < *na; i++)
for (j = 0; i < *nb; i++)
ab[i + j] += a[i] * b [j];
}
-------------------------------------------------------------------
I generated shared object with
R CMD SHLIB prova.c
i run R and so
> dyn.load("prova.so", local = TRUE, now = TRUE)
>convolve1<-function(a,b).C("convolve",as.double(a),as.integer(length(a)),as.double(b),as.integer(length(b)),ab = double(length(a) + length(b) - 1)$ab)
> a<-1:10
> b<-a
typing convolve1(a,b) i get a Segmentation fault.
Can anyone tell me what's the problem
Regards
--
Federico Cantini <cantini at ifc.cnr.it>
More information about the R-help
mailing list