示例#1
0
PyMODINIT_FUNC init_combine(void)
{
	PyObject *m, *d;
	m = Py_InitModule("_combine", _combineMethods);
	d = PyModule_GetDict(m);
	_Error = PyErr_NewException("_combine.error", NULL, NULL);
	PyDict_SetItemString(d, "error", _Error);
	import_libnumarray();
}
示例#2
0
PyMODINIT_FUNC initcAction(void) 
{
    Py_InitModule3("cAction", cAction_methods, "c ext for action.py");
    ActionError = PyErr_NewException("cAction.error", NULL, NULL);
    Py_INCREF(ActionError);
    
    import_array();
    import_libnumarray();
}
PyMODINIT_FUNC
initrtaudio(void) 
{
  PyEval_InitThreads();
  import_libnumarray();
  import_libnumeric();

  PyObject* module;
  
  if (PyType_Ready(&RtAudio_type) < 0)
    return;
  
  module = Py_InitModule3("rtaudio", rtaudio_methods,
			  "RtAudio wrapper.");

  PyRTAUDIO_SINT8 = PyLong_FromUnsignedLong(RTAUDIO_SINT8);
  PyModule_AddObject(module, "RTAUDIO_SINT8", PyRTAUDIO_SINT8);
  Py_INCREF(PyRTAUDIO_SINT8);

  PyRTAUDIO_SINT16 = PyLong_FromUnsignedLong(RTAUDIO_SINT16);
  PyModule_AddObject(module, "RTAUDIO_SINT16", PyRTAUDIO_SINT16);
  Py_INCREF(PyRTAUDIO_SINT16);

  PyRTAUDIO_SINT24 = PyLong_FromUnsignedLong(RTAUDIO_SINT24);
  PyModule_AddObject(module, "RTAUDIO_SINT24", PyRTAUDIO_SINT24);
  Py_INCREF(PyRTAUDIO_SINT24);

  PyRTAUDIO_SINT32 = PyLong_FromUnsignedLong(RTAUDIO_SINT32);
  PyModule_AddObject(module, "RTAUDIO_SINT32", PyRTAUDIO_SINT32);
  Py_INCREF(PyRTAUDIO_SINT32);

  PyRTAUDIO_FLOAT32 = PyLong_FromUnsignedLong(RTAUDIO_FLOAT32);
  PyModule_AddObject(module, "RTAUDIO_FLOAT32", PyRTAUDIO_FLOAT32);
  Py_INCREF(PyRTAUDIO_FLOAT32);

  PyRTAUDIO_FLOAT64 = PyLong_FromUnsignedLong(RTAUDIO_FLOAT64);
  PyModule_AddObject(module, "RTAUDIO_FLOAT64", PyRTAUDIO_FLOAT64);
  Py_INCREF(PyRTAUDIO_FLOAT64);
  
  Py_INCREF(&RtAudio_type);
  PyModule_AddObject(module, "RtAudio", (PyObject *)&RtAudio_type);
  
  RtAudioError = PyErr_NewException("rtaudio.RtError", NULL, NULL);
  PyModule_AddObject(module, "RtError", RtAudioError);
  Py_INCREF(RtAudioError);
}
示例#4
0
/**
 * Start up the Python interpreter if needed, importing all necessary stuff.
 */
void interpreter_initialize()
{
    if (!interpreter.initialized) {
        void *handle;
        void (*f)();

        dlopen_python_hack(); /* necessary evil :( */
        Py_Initialize();

        if (!interpreter.array_imported) {
#ifdef NUMERIC
            import_array();
#endif
#ifdef NUMARRAY
            import_libnumarray();
            import_libnumeric();
#endif
#ifdef NUMPY
            import_array();
#endif
        }
        interpreter.initialized = 1;
    }
}
示例#5
0
文件: radau5mod.c 项目: F-A/pydstool
PyObject* Integrate(double *ic, double t, double hinit, double hmax,
		    double safety,
		    double jacRecompute, double newtonStop,
		    double stepChangeLB, double stepChangeUB,
		    double stepSizeLB, double stepSizeUB,
		    int hessenberg,  int maxNewton,
		    int newtonStart, int index1dim, int index2dim,
		    int index3dim, int stepSizeStrategy,
		    int DAEstructureM1, int DAEstructureM2,
		    int useJac, int useMass, int verbose,
		    int calcAux, int calcSpecTimes) {
  int i, j;
  double stats[7];
  double hlast = -1;
  int idid = 0;                   /* Return code from radau5. Codes are:
				     1 - Successful
				     2 - Successful, interrupted by solout
				     -1 - Input not consistent
				     -2 - Larger max steps is needed
				     -3 - Step size becomes too small
				     -4 - Matrix is repeatedly singular
				  */

  int iout = DENSE_OUTPUT_CALL; /* Call solout at each step */
  int itol = VECTOR_ERR_TOL;      /* rtol, atol are vectors; must pass point to int */
  int *ipar = NULL; /* No integer parameter array */

  int phaseDim = 0;
  double tinit = 0;
  double tend = 0;

  int ijac = 0; /* if we setup Jac to return correctly oriented jacobian */
  int imas = 0; /* supposed to be identity, so not DAE */
  int mljac = 0;
  int mujac = 0; /* Bandedness not accounted for yet. */
  int mlmas = 0;
  int mumas = 0;

  int lwork = 0;
  int liwork = 0;

  FILE *ErrOut = NULL;

  assert( gIData );
  assert( gICs );
  assert( ic );

  if( gIData->isInitBasic != 1 || gIData->isInitIntegData != 1 ) {
    return PackOut(gIData, gICs, FAILURE, stats, hlast, idid);
  }

  /* Set whether to calculate output at specific times on this run */
  gIData->calcSpecTimes = calcSpecTimes;
  gIData->calcAux = calcAux;

  for( i = 0; i < gIData->phaseDim; i++ ) {
    gIData->gIC[i] = ic[i];
  }

  /* Call RADAU5 */

  if( verbose == 1 )
    ErrOut = stderr;

  /* for NumArray compatibility */
  import_libnumarray();


  phaseDim = gIData->phaseDim;
  tinit = t;
  tend = gIData->tEnd;
  ijac = (useJac && gIData->hasJac) ? 1 : 0;
  imas = (useMass && gIData->hasMass) ? 1 : 0;

  /* Set the direction of integration */
  gIData->direction = (t < gIData->tEnd ) ? 1 : -1;

  /* Call RADAU5 */
  if( InitializeRadauOptions( gIData, UROUND, safety,
			      jacRecompute, newtonStop,
			      stepChangeLB, stepChangeUB,
			      hmax, stepSizeLB, stepSizeUB,
			      hessenberg, gIData->maxPts, maxNewton,
			      newtonStart, index1dim, index2dim,
			      index3dim, stepSizeStrategy,
			      DAEstructureM1, DAEstructureM2 )
      != SUCCESS ) {
        return PackOut(gIData, gICs, FAILURE, stats, hlast, idid);
  }

  mljac = gIData->jacLowerBandwidth;
  mujac = gIData->jacUpperBandwidth;

  mlmas = gIData->masLowerBandwidth;
  mumas = gIData->masUpperBandwidth;

  lwork = gIData->workArrayLen;
  liwork = gIData->intWorkArrayLen;

  radau5_(&phaseDim, vfield, &tinit, gIData->gIC, &tend, &hinit, gIData->gRTol,
	  gIData->gATol, &itol, vfieldjac, &ijac, &mljac, &mujac,
	  vfieldmas, &imas, &mlmas, &mumas, radau_solout, &iout,
	  gIData->gWorkArray, &lwork, gIData->gIntWorkArray, &liwork, gIData->gParams,
	  ipar, &idid, radau_adjust_h);

  gIData->hasRun = 1;

  /* Stats are:
     0 - Num function evals
     1 - Num Jacobian evals
     2 - Num computed steps
     3 - Num accepted steps
     4 - Num rejected steps
     5 - Num LU decompositions
     6 - Num Forward-Backward substitutions
  */
  for( i = 0; i < 7; i++ ) {
    stats[i] = gIData->gIntWorkArray[i + 13];
  }

  /* FORTRAN Radau5 routine puts last H step in hinit */
  hlast = hinit;

  if( N_AUXVARS > 0  && calcAux != 0 ) {
    AuxVarCalc( gIData );
  }

  return PackOut(gIData, gICs, SUCCESS, stats, hlast, idid);
}
示例#6
0
//line54
void initreal(void)
{
  Py_InitModule("real", realMethods);
  import_libnumarray();
}