From: Bernd Kriegstein <kriegstn_at_yahoo.de>

Date: Tue 21 Feb 2006 - 04:42:45 GMT

}

R-devel@r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue Feb 21 15:45:13 2006

Date: Tue 21 Feb 2006 - 04:42:45 GMT

Hello,

- file pico.c

*#include <stdio.h>
**#include <stdlib.h>
*

#include <math.h>

*#include <R.h>
**#include <Rmath.h>
*

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

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

int i, j; GetRNGstate(); for ( i=0; i<n; i++ ) { for ( j=0; j<m; j++ ) { y[ COLM( i,j,m ) ] = rnorm( 0, 1 ); } } PutRNGstate();

}

- file pico.R

dyn.load("pico.so");

if( is.loaded( symbol.C( "pico" ) ) )

n<-10; m<-5; y<-matrix( 0, n, m ); a<- .C( "pico", as.double(y), as.integer(n),as.integer(m) );

The code, when executed within R, gives a segmentation fault. I looked at the writing R extensions, but not much can be inferred from there on the subject. In fact, I would be indebted if I could have a pointer to a beginnner's guide to the R API.

Thank you for any answers,

- b.

PS. if this is not the appropriate section of R maillists that this post should be in, I apologise in advance.

R-devel@r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue Feb 21 15:45:13 2006

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