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 <[EMAIL PROTECTED]>

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to