Message-ID: <20060307120514.75381.qmail@web27413.mail.ukl.yahoo.com>
Date: 2006-03-07T12:05:14Z
From: Bernd Kriegstein
Subject: double pointer matrix
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.