fix matrix input issue
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12124 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
090ec2d78c
commit
e16a959732
6 changed files with 317 additions and 100 deletions
|
|
@ -7,6 +7,17 @@ double sumitems(double *first, int nbRow, int nbCol) {
|
|||
return total;
|
||||
}
|
||||
|
||||
void sumitems_argoutput(double *first, int nbRow, int nbCol,double** result,int* nbrowres,int* nbcolsres) {
|
||||
int i;
|
||||
*nbrowres=nbRow;
|
||||
*nbcolsres=nbCol;
|
||||
*result=malloc(nbRow*nbCol*sizeof(double));
|
||||
for (i=0; i<(nbRow*nbCol); i++) {
|
||||
(*result)[i]=first[i]+first[i];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
double* getValues(int *numberOfRow, int *numberOfCol) {
|
||||
*numberOfRow=23; *numberOfCol=3;
|
||||
double *tempMatrix = (double*)malloc(sizeof(double) * *numberOfRow * *numberOfCol);
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
%module matrixlib
|
||||
%include "matrix.i"
|
||||
extern double sumitems(double *, int, int);
|
||||
%typemap (in, numinputs=0) (int *numberOfRow, int *numberOfCol) {
|
||||
$1 = &iRowsOut;
|
||||
$2 = &iColsOut;
|
||||
}
|
||||
%include matrix.i
|
||||
|
||||
|
||||
|
||||
|
||||
%apply (double* matrixAsInput,int rows,int cols){(double *first, int nbRow, int nbCol)}
|
||||
%apply (double** matrixAsArgOutput,int* rows,int* cols){(double **result,int* nbRowOut,int* nbColOut)}
|
||||
%inline {
|
||||
extern double sumitems(double *first, int nbRow, int nbCol);
|
||||
extern void sumitems_argoutput(double *first, int nbRow, int nbCol,double **result,int* nbRowOut,int* nbColOut);
|
||||
extern double* getValues(int *numberOfRow, int *numberOfCol);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue