Hi the list,
Is there a way to give a matrix to a C function, and then to use it as a matrix ?
I write a function to print a matrix, but I use it as a vector :

1. void printMatrix(double *mTraj,int *nbCol, int *nbLigne){
2.     int i=0,j=0;
3.     for(i=0 ;  i < *nbLigne ; i++){
4.     for(j=0 ; j < *nbCol ; j++){
5.         Rprintf(" %f",mTraj[i * *nbCol + j]);
6.     }
7.     Rprintf("\n");
8.    }
9. }

I would like to use it as a matrix (line 5 changes) :

1. void printMatrix(double *mTraj,int *nbCol, int *nbLigne){
2.     int i=0,j=0;
3.     for(i=0 ;  i < *nbLigne ; i++){
4.     for(j=0 ; j < *nbCol ; j++){
5.         Rprintf(" %f",mTraj[i,j]);
6.     }
7.     Rprintf("\n");
8.    }
9. }

It does not work, but is there an solution close to this ?

Thanks.
Christophe

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to