diff --git a/src/Profiles/Function.cpp b/src/Profiles/Function.cpp index 3dfe099b0..d39994722 100755 --- a/src/Profiles/Function.cpp +++ b/src/Profiles/Function.cpp @@ -8,22 +8,25 @@ using namespace std; // 1D double Function_Python1D::valueAt( double time ) { + double v; SMILEI_PY_ACQUIRE_GIL - double v = PyTools::runPyFunction( py_profile, time ); + v = PyTools::runPyFunction( py_profile, time ); SMILEI_PY_RELEASE_GIL return v; } double Function_Python1D::valueAt( vector, double time ) { + double v; SMILEI_PY_ACQUIRE_GIL - double v = PyTools::runPyFunction( py_profile, time ); + v = PyTools::runPyFunction( py_profile, time ); SMILEI_PY_RELEASE_GIL return v; } double Function_Python1D::valueAt( vector x_cell ) { + double v; SMILEI_PY_ACQUIRE_GIL - double v = PyTools::runPyFunction( py_profile, x_cell[0] ); + v = PyTools::runPyFunction( py_profile, x_cell[0] ); SMILEI_PY_RELEASE_GIL return v; } @@ -31,30 +34,34 @@ double Function_Python1D::valueAt( vector x_cell ) // 2D double Function_Python2D::valueAt( vector x_cell, double time ) { + double v; SMILEI_PY_ACQUIRE_GIL - double v = PyTools::runPyFunction( py_profile, x_cell[0], time ); + v = PyTools::runPyFunction( py_profile, x_cell[0], time ); SMILEI_PY_RELEASE_GIL return v; } double Function_Python2D::valueAt( vector x_cell ) { + double v; SMILEI_PY_ACQUIRE_GIL - double v = PyTools::runPyFunction( py_profile, x_cell[0], x_cell[1] ); + v = PyTools::runPyFunction( py_profile, x_cell[0], x_cell[1] ); SMILEI_PY_RELEASE_GIL return v; } // 2D complex std::complex Function_Python2D::complexValueAt( vector x_cell, double time ) { + std::complex v; SMILEI_PY_ACQUIRE_GIL - std::complex v = PyTools::runPyFunction>( py_profile, x_cell[0], time ); + v = PyTools::runPyFunction>( py_profile, x_cell[0], time ); SMILEI_PY_RELEASE_GIL return v; } std::complex Function_Python2D::complexValueAt( vector x_cell ) { + std::complex v; SMILEI_PY_ACQUIRE_GIL - std::complex v = PyTools::runPyFunction>( py_profile, x_cell[0], x_cell[1] ); + v = PyTools::runPyFunction>( py_profile, x_cell[0], x_cell[1] ); SMILEI_PY_RELEASE_GIL return v; } @@ -62,23 +69,26 @@ std::complex Function_Python2D::complexValueAt( vector x_cell ) // 3D double Function_Python3D::valueAt( vector x_cell, double time ) { + double v; SMILEI_PY_ACQUIRE_GIL - double v = PyTools::runPyFunction( py_profile, x_cell[0], x_cell[1], time ); + v = PyTools::runPyFunction( py_profile, x_cell[0], x_cell[1], time ); SMILEI_PY_RELEASE_GIL return v; } double Function_Python3D::valueAt( vector x_cell ) { + double v; SMILEI_PY_ACQUIRE_GIL - double v = PyTools::runPyFunction( py_profile, x_cell[0], x_cell[1], x_cell[2] ); + v = PyTools::runPyFunction( py_profile, x_cell[0], x_cell[1], x_cell[2] ); SMILEI_PY_RELEASE_GIL return v; } // 3D complex std::complex Function_Python3D::complexValueAt( vector x_cell, double time ) { + std::complex v; SMILEI_PY_ACQUIRE_GIL - std::complex v = PyTools::runPyFunction>( py_profile, x_cell[0], x_cell[1], time ); + v = PyTools::runPyFunction>( py_profile, x_cell[0], x_cell[1], time ); SMILEI_PY_RELEASE_GIL return v; } @@ -86,16 +96,18 @@ std::complex Function_Python3D::complexValueAt( vector x_cell, d // 4D double Function_Python4D::valueAt( vector x_cell, double time ) { + double v; SMILEI_PY_ACQUIRE_GIL - double v = PyTools::runPyFunction( py_profile, x_cell[0], x_cell[1], x_cell[2], time ); + v = PyTools::runPyFunction( py_profile, x_cell[0], x_cell[1], x_cell[2], time ); SMILEI_PY_RELEASE_GIL return v; } // 4D complex std::complex Function_Python4D::complexValueAt( vector x_cell, double time ) { + std::complex v; SMILEI_PY_ACQUIRE_GIL - std::complex v = PyTools::runPyFunction>( py_profile, x_cell[0], x_cell[1], x_cell[2], time ); + v = PyTools::runPyFunction>( py_profile, x_cell[0], x_cell[1], x_cell[2], time ); SMILEI_PY_RELEASE_GIL return v; } @@ -104,30 +116,34 @@ std::complex Function_Python4D::complexValueAt( vector x_cell, d #ifdef SMILEI_USE_NUMPY PyArrayObject *Function_Python1D::valueAt( std::vector x ) { + PyArrayObject * v; SMILEI_PY_ACQUIRE_GIL - PyArrayObject * v = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], NULL ); + v = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], NULL ); SMILEI_PY_RELEASE_GIL return v; } PyArrayObject *Function_Python2D::valueAt( std::vector x ) { + PyArrayObject * v; SMILEI_PY_ACQUIRE_GIL - PyArrayObject * v = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], x[1], NULL ); + v = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], x[1], NULL ); SMILEI_PY_RELEASE_GIL return v; } PyArrayObject *Function_Python3D::valueAt( std::vector x ) { + PyArrayObject * v; SMILEI_PY_ACQUIRE_GIL - PyArrayObject * v = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], x[1], x[2], NULL ); + v = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], x[1], x[2], NULL ); SMILEI_PY_RELEASE_GIL return v; } PyArrayObject *Function_Python2D::complexValueAt( std::vector x ) { + PyArrayObject *cvalues; SMILEI_PY_ACQUIRE_GIL PyObject *values = PyObject_CallFunctionObjArgs( py_profile, x[0], x[1], NULL ); - PyArrayObject *cvalues = ( PyArrayObject * )PyObject_CallMethod( values, const_cast("astype"), const_cast("s"), const_cast("complex"), NULL ); + cvalues = ( PyArrayObject * )PyObject_CallMethod( values, const_cast("astype"), const_cast("s"), const_cast("complex"), NULL ); Py_DECREF( values ); SMILEI_PY_RELEASE_GIL return cvalues; @@ -137,55 +153,61 @@ PyArrayObject *Function_Python2D::complexValueAt( std::vector x PyArrayObject *Function_Python1D::valueAt( std::vector, double time ) { + PyArrayObject * ret; SMILEI_PY_ACQUIRE_GIL PyObject *t = PyFloat_FromDouble( time ); - PyArrayObject * ret = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, t, NULL ); + ret = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, t, NULL ); Py_DECREF( t ); SMILEI_PY_RELEASE_GIL return ret; } PyArrayObject *Function_Python2D::valueAt( std::vector x, double time ) { + PyArrayObject * ret; SMILEI_PY_ACQUIRE_GIL PyObject *t = PyFloat_FromDouble( time ); - PyArrayObject * ret = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], t, NULL ); + ret = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], t, NULL ); Py_DECREF( t ); SMILEI_PY_RELEASE_GIL return ret; } PyArrayObject *Function_Python3D::valueAt( std::vector x, double time ) { + PyArrayObject * ret; SMILEI_PY_ACQUIRE_GIL PyObject *t = PyFloat_FromDouble( time ); - PyArrayObject * ret = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], x[1], t, NULL ); + ret = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], x[1], t, NULL ); Py_DECREF( t ); SMILEI_PY_RELEASE_GIL return ret; } PyArrayObject *Function_Python4D::valueAt( std::vector x, double time ) { + PyArrayObject * ret; SMILEI_PY_ACQUIRE_GIL PyObject *t = PyFloat_FromDouble( time ); - PyArrayObject * ret = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], x[1], x[2], t, NULL ); + ret = ( PyArrayObject * )PyObject_CallFunctionObjArgs( py_profile, x[0], x[1], x[2], t, NULL ); Py_DECREF( t ); SMILEI_PY_RELEASE_GIL return ret; }PyArrayObject *Function_Python4D::complexValueAt( std::vector x, double time ) { + PyArrayObject *cvalues; SMILEI_PY_ACQUIRE_GIL PyObject *t = PyFloat_FromDouble( time ); PyObject * values = PyObject_CallFunctionObjArgs( py_profile, x[0], x[1], x[2], t, NULL ); Py_DECREF( t ); - PyArrayObject *cvalues = ( PyArrayObject * )PyObject_CallMethod( values, const_cast("astype"), const_cast("s"), const_cast("complex"), NULL ); + cvalues = ( PyArrayObject * )PyObject_CallMethod( values, const_cast("astype"), const_cast("s"), const_cast("complex"), NULL ); Py_DECREF( values ); SMILEI_PY_RELEASE_GIL return cvalues; } PyArrayObject *Function_Python4D::complexValueAt( std::vector x, PyArrayObject *t ) { + PyArrayObject *cvalues; SMILEI_PY_ACQUIRE_GIL PyObject *values = PyObject_CallFunctionObjArgs( py_profile, x[0], x[1], x[2], t, NULL ); - PyArrayObject *cvalues = ( PyArrayObject * )PyObject_CallMethod( values, const_cast("astype"), const_cast("s"), const_cast("complex"), NULL ); + cvalues = ( PyArrayObject * )PyObject_CallMethod( values, const_cast("astype"), const_cast("s"), const_cast("complex"), NULL ); Py_DECREF( values ); SMILEI_PY_RELEASE_GIL return cvalues;