/* \file MatlabNArrayToNArray.cpp * \brief: convert a sparse or dense matlab n-dimensional array to cpp n-dimensional array */ #ifdef HAVE_CONFIG_H #include #else #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" #endif #include "../../shared/shared.h" #include "../../include/include.h" #include /*FUNCTION MatlabNArrayToNArray(double** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){{{*/ int MatlabNArrayToNArray(double** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){ int i,j,rows,cols; int numel,ndims; int *size,*dims; double* mxmatrix_ptr=NULL; const mwSize* ipt=NULL; /*output: */ double* matrix=NULL; /*matlab indices: */ mwIndex* ir=NULL; mwIndex* jc=NULL; double* pr=NULL; int count; int nnz; int nz; /*get Matlab matrix information: */ numel=mxGetNumberOfElements(mxmatrix); ndims=mxGetNumberOfDimensions(mxmatrix); ipt =mxGetDimensions(mxmatrix); size =(int *) xcalloc(ndims,sizeof(int)); for (i=0; i