Re: [Rd] simple C function segfaults

From: Paul Roebuck <roebuck_at_mdanderson.org>
Date: Tue 21 Feb 2006 - 06:14:37 GMT

On Tue, 21 Feb 2006, Bernd Kriegstein wrote:

> I use the simplest of examples that somebody can think
> of in order to generate a matrix of random numbers
> from within C, calling appropriate R functions. The
> concrete example is below:
> [SNIP]

#define COLM(i,j,m) ((m * j) + i)

void pico(double *y, int *n, int *m) {

    register int i;

    GetRNGstate();
    for (i = 0; i < *n; i++) {

        register int j;

        for (j = 0; j < *m; j++) {
            y[COLM(i,j,*m)] = rnorm(0.0, 1.0);
        }

    }
    PutRNGstate();
}

$ R CMD SHLIB pico.c
$ R --vanilla < pico.R



SIGSIG -- signature too long (core dumped)

R-devel@r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue Feb 21 17:17:00 2006

This archive was generated by hypermail 2.1.8 : Tue 21 Feb 2006 - 22:34:55 GMT