[Rd] double pointer matrix
Bernd Kriegstein
kriegstn at yahoo.de
Tue Mar 7 13:05:14 CET 2006
Hello,
I'm having some difficulty to understand how I could
take the proper result from the following listing:
-- cut ---
#include <stdlib.h>
#include <R.h>
#include <Rmath.h>
void retMat ( double **y, int *n, int *m, double *a,
double *b) {
int i, j;
y = malloc( (*n) * sizeof( double ) );
for (i=0; i<*n; i++) {
y[i] = malloc ( (*m) * sizeof( double
) );
}
GetRNGstate();
for (i=0; i<*n; i++) {
for (j=0; j<*m; j++) {
y[i][j] = (i+1)*(j+1)*rbeta(
*a, *b );
}
}
PutRNGstate();
}
---
I understand that I will have to make the matrix
initialized in the double for loop above to be somehow
visible as a vector, because of the way that the
matrix elements are passed in the argument when used
in the R space. Is there a way to accomplish this?
Thanks for any answers,
- b.
More information about the R-devel
mailing list