Message-ID: <CA0BCF3BED56294AB91E3AD74B849FD57F403E@us-arlington-0668.mail.saic.com>
Date: 2005-04-26T17:19:54Z
From: Tuszynski, Jaroslaw W.
Subject: Advice for calling a C function
I think it is a problem with matrices in R and C being stored in different
row/column order
> void gowsim ( double *mat, int *OBJ, int *MATDESC) {
> double x [*MATDESC][*OBJ];
> int i, j, nrow, ncol;
> nrow = *OBJ;
> ncol = *MATDESC;
>
> /* Rebuild Matrix */
> for (j=0; j < ncol; j++) {
> for (i=0; i < nrow; i++) {
> x[i][j] = *mat;
Swapping x[i][j] to x[j][i] should fix the problem. Sorry, I did not test
it.
> Rprintf("row %d col %d value %f\n", i, j, x[i][j]);
> mat++;
> }
> }
> for (i=0; i< nrow; i++) {
> Rprintf("%f %f %f %f\n", x[i][0], x[i][1], x[i][2], x[i][3]);
> }
>}
Jarek
====================================================\=======
Jarek Tuszynski, PhD. o / \
Science Applications International Corporation <\__,|
(703) 676-4192 "> \
Jaroslaw.W.Tuszynski at saic.com ` \