Exemple #1
0
void vfield(int *n, double *t, double *x, double *f,
	    double *rpar, int *ipar) {

  FillCurrentExtInputValues(gIData, *t);

  vfieldfunc(*n, (unsigned) gIData->paramDim, *t, x,
	     rpar, f, (unsigned) gIData->extraSpaceSize, gIData->gExtraSpace,
	     (unsigned) gIData->nExtInputs, gIData->gCurrentExtInputVals);
}
Exemple #2
0
PyObject* Vfield(double t, double *x, double *p) {
  PyObject *OutObj = NULL;
  PyObject *PointsOut = NULL;
  
  double *ftemp = NULL;
  int i; 

  import_array();

  if( (gIData == NULL) || (gIData->isInitBasic == 0) ) {
    Py_INCREF(Py_None);
    return Py_None;
  }
  else if( (gIData->nExtInputs > 0) && (gIData->isInitExtInputs == 0) ) {
    Py_INCREF(Py_None);
    return Py_None;
  }
  else {
    OutObj = PyTuple_New(1);
    assert(OutObj);

    ftemp = (double *)PyMem_Malloc((gIData->phaseDim)*sizeof(double));
    assert(ftemp);

    if( gIData->nExtInputs > 0 ) {
      FillCurrentExtInputValues( gIData, t );
    }

    vfieldfunc(gIData->phaseDim, gIData->paramDim, t, x, p, ftemp, 
	       gIData->extraSpaceSize, gIData->gExtraSpace, 
	       gIData->nExtInputs, gIData->gCurrentExtInputVals);
    
    npy_intp dims[1] = {gIData->phaseDim};
    PointsOut = PyArray_SimpleNewFromData(1, dims, NPY_DOUBLE, ftemp);
    if(!PointsOut) {
        PyMem_Free(ftemp);
        Py_INCREF(Py_None);
        return Py_None;
    }
    PyArray_UpdateFlags((PyArrayObject *)PointsOut, NPY_ARRAY_CARRAY | NPY_ARRAY_OWNDATA);
    PyTuple_SetItem(OutObj, 0, PointsOut);
    return OutObj;
  }
}