Changeset 12776


Ignore:
Timestamp:
07/27/12 14:36:27 (13 years ago)
Author:
Eric.Larour
Message:

Extended I/O capability

Location:
issm/trunk-jpl/src/c/python/io
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk-jpl/src/c/python/io/FetchPythonData.cpp

    r12493 r12776  
    1515#include "../../include/include.h"
    1616#include "../../shared/shared.h"
     17#include "../../io/io.h"
    1718
    1819/*Primitive data types*/
     
    8182}
    8283/*}}}*/
     84/*FUNCTION FetchData(int** pmatrix,int* pM, int* pN, PyObject* py_matrix){{{*/
     85void FetchData(int** pmatrix,int* pM,int *pN,PyObject* py_matrix){
     86
     87        /*output: */
     88        double* dmatrix=NULL;
     89        int* matrix=NULL;
     90        int M,N;
     91
     92        /*intermediary:*/
     93        int i;
     94        int ndim;
     95        npy_intp*  dims=NULL;
     96
     97        /*retrive dimensions: */
     98        ndim=PyArray_NDIM((const PyArrayObject*)py_matrix);
     99        if(ndim!=2)_error2_("expecting an MxN matrix in input!");
     100        dims=PyArray_DIMS((PyArrayObject*)py_matrix);
     101        M=dims[0]; N=dims[1];
     102       
     103        /*retrieve internal value: */
     104        dmatrix=(double*)PyArray_DATA((PyArrayObject*)py_matrix);
     105
     106        /*transform into integer matrix: */
     107        matrix=xNew<int>(M*N);
     108        for(i=0;i<M*N;i++)matrix[i]=(int)dmatrix[i];
     109
     110        /*output: */
     111        if(pM)*pM=M;
     112        if(pN)*pN=N;
     113        if(pmatrix)*pmatrix=matrix;
     114}
     115/*}}}*/
    83116/*FUNCTION FetchData(double** pvector,int* pM, PyObject* py_vector){{{*/
    84117void FetchData(double** pvector,int* pM,PyObject* py_vector){
     
    102135        if(pM)*pM=M;
    103136        if(pvector)*pvector=vector;
     137}
     138/*}}}*/
     139/*FUNCTION FetchData(Options** poptions,int istart, int nrhs,PyObject* arguments){{{*/
     140void FetchData(Options** poptions,int istart, int nrhs,PyObject* arguments){
     141
     142        /*Initialize output*/
     143        Options* options=new Options();
     144
     145        _pprintLine_("FetchData for Options not implemented yet, ignoring them!");
     146
     147        /*Assign output pointers:*/
     148        *poptions=options;
     149
    104150}
    105151/*}}}*/
  • TabularUnified issm/trunk-jpl/src/c/python/io/pythonio.h

    r12120 r12776  
    4747void FetchData(double** pvector,int* pM,PyObject* py_ref);
    4848void FetchData(double** pmatrix,int* pM,int *pN,PyObject* py_array);
     49void FetchData(int** pmatrix,int* pM,int *pN,PyObject* py_matrix);
    4950void FetchData(char** pstring,PyObject* py_unicode);
    5051void FetchData(double* pscalar,PyObject* py_float);
    5152void FetchData(int* pinteger,PyObject* py_long);
    5253void FetchData(bool* pbool,PyObject* py_boolean);
     54void FetchData(Options** poptions,int istart, int nrhs,PyObject* arguments);
    5355
    5456int CheckNumPythonArguments(PyObject* inputs,int NRHS, void (*function)( void ));
Note: See TracChangeset for help on using the changeset viewer.