Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for return values from user provided functions. #36

Merged
merged 4 commits into from Nov 15, 2016
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -17,3 +17,4 @@ dist
_build
.tox
.spyderproject
.cache
13 changes: 6 additions & 7 deletions scikits/odes/sundials/c_cvode.pxd
Expand Up @@ -44,9 +44,8 @@ cdef extern from "cvode/cvode.h":
enum: CV_BAD_DKY # -26
enum: CV_TOO_CLOSE # -27

ctypedef int (*CVRhsFn)(realtype t, N_Vector y,
N_Vector ydot, void *user_data)
ctypedef int (*CVRootFn)(realtype t, N_Vector y, realtype *gout, void *user_data)
ctypedef int (*CVRhsFn)(realtype t, N_Vector y, N_Vector ydot, void *user_data) except? -1
ctypedef int (*CVRootFn)(realtype t, N_Vector y, realtype *gout, void *user_data) except? -1
ctypedef int (*CVEwtFn)(N_Vector y, N_Vector ewt, void *user_data)
ctypedef void (*CVErrHandlerFn)(int error_code,
char *module, char *function,
Expand Down Expand Up @@ -132,7 +131,7 @@ cdef extern from "cvode/cvode_direct.h":
ctypedef int (*CVDlsDenseJacFn)(long int N, realtype t,
N_Vector y, N_Vector fy,
DlsMat Jac, void *user_data,
N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) except? -1
ctypedef int (*CVDlsBandJacFn)(long int N, long int mupper, long int mlower,
realtype t, N_Vector y, N_Vector fy,
DlsMat Jac, void *user_data,
Expand Down Expand Up @@ -213,14 +212,14 @@ cdef extern from "cvode/cvode_spils.h":
booleantype jok, booleantype *jcurPtr,
realtype gamma, void *user_data,
N_Vector tmp1, N_Vector tmp2,
N_Vector tmp3)
N_Vector tmp3) except? -1
ctypedef int (*CVSpilsPrecSolveFn)(realtype t, N_Vector y, N_Vector fy,
N_Vector r, N_Vector z,
realtype gamma, realtype delta,
int lr, void *user_data, N_Vector tmp)
int lr, void *user_data, N_Vector tmp) except? -1
ctypedef int (*CVSpilsJacTimesVecFn)(N_Vector v, N_Vector Jv, realtype t,
N_Vector y, N_Vector fy,
void *user_data, N_Vector tmp)
void *user_data, N_Vector tmp) except? -1

int CVSpilsSetPrecType(void *cvode_mem, int pretype)
int CVSpilsSetGSType(void *cvode_mem, int gstype)
Expand Down
18 changes: 12 additions & 6 deletions scikits/odes/sundials/cvode.pxd
Expand Up @@ -9,7 +9,8 @@ cdef class CV_RhsFunction:
cpdef int evaluate(self, DTYPE_t t,
np.ndarray[DTYPE_t, ndim=1] y,
np.ndarray[DTYPE_t, ndim=1] ydot,
object userdata = *)
object userdata = *) except? -1

cdef class CV_WrapRhsFunction(CV_RhsFunction):
cpdef public object _rhsfn
cdef public int with_userdata
Expand All @@ -19,7 +20,8 @@ cdef class CV_RootFunction:
cpdef int evaluate(self, DTYPE_t t,
np.ndarray[DTYPE_t, ndim=1] y,
np.ndarray[DTYPE_t, ndim=1] g,
object userdata = *)
object userdata = *) except? -1

cdef class CV_WrapRootFunction(CV_RootFunction):
cpdef object _rootfn
cdef int with_userdata
Expand All @@ -28,7 +30,8 @@ cdef class CV_WrapRootFunction(CV_RootFunction):
cdef class CV_JacRhsFunction:
cpdef int evaluate(self, DTYPE_t t,
np.ndarray[DTYPE_t, ndim=1] y,
np.ndarray[DTYPE_t, ndim=2] J)
np.ndarray[DTYPE_t, ndim=2] J) except? -1

cdef class CV_WrapJacRhsFunction(CV_JacRhsFunction):
cpdef public object _jacfn
cdef int with_userdata
Expand All @@ -40,7 +43,8 @@ cdef class CV_PrecSetupFunction:
bint jok,
object jcurPtr,
DTYPE_t gamma,
object userdata = *)
object userdata = *) except? -1

cdef class CV_WrapPrecSetupFunction(CV_PrecSetupFunction):
cpdef object _prec_setupfn
cdef int with_userdata
Expand All @@ -54,7 +58,8 @@ cdef class CV_PrecSolveFunction:
DTYPE_t gamma,
DTYPE_t delta,
int lr,
object userdata = *)
object userdata = *) except? -1

cdef class CV_WrapPrecSolveFunction(CV_PrecSolveFunction):
cpdef object _prec_solvefn
cdef int with_userdata
Expand All @@ -67,7 +72,8 @@ cdef class CV_JacTimesVecFunction:
np.ndarray[DTYPE_t, ndim=1] Jv,
DTYPE_t t,
np.ndarray[DTYPE_t, ndim=1] y,
object userdata = *)
object userdata = *) except? -1

cdef class CV_WrapJacTimesVecFunction(CV_JacTimesVecFunction):
cpdef object _jac_times_vecfn
cdef int with_userdata
Expand Down