diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 29b42801..287d42fb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,67 +11,67 @@ jobs: matrix: include: - python-version: "3.7" - sundials-version: 5.7.0 + sundials-version: "6.5.0" tox-env: py37 sundials-precision: double sundials-index-size: 64 - python-version: "3.8" - sundials-version: 5.7.0 + sundials-version: "6.5.0" tox-env: py38 sundials-precision: double sundials-index-size: 64 - python-version: "3.9" - sundials-version: 5.7.0 + sundials-version: "6.5.0" tox-env: py39 sundials-precision: double sundials-index-size: 64 - python-version: "3.10" - sundials-version: 5.7.0 + sundials-version: "6.5.0" tox-env: py310 sundials-precision: double sundials-index-size: 64 - python-version: "3.11" - sundials-version: 5.7.0 + sundials-version: "6.5.0" tox-env: py311 sundials-precision: double sundials-index-size: 64 - python-version: "3.12" - sundials-version: 5.7.0 + sundials-version: "6.5.0" tox-env: py312 sundials-precision: double sundials-index-size: 64 - python-version: "3.11" - sundials-version: 5.7.0 + sundials-version: "6.5.0" tox-env: doctr sundials-precision: double sundials-index-size: 64 - python-version: "3.11" - sundials-version: 5.7.0 + sundials-version: "6.5.0" tox-env: docs sundials-precision: double sundials-index-size: 64 - python-version: "3.11" - sundials-version: 5.7.0 + sundials-version: "6.5.0" tox-env: check-manifest sundials-precision: double sundials-index-size: 64 - python-version: "3.11" - sundials-version: 5.7.0 + sundials-version: "6.5.0" tox-env: checkreadme sundials-precision: double sundials-index-size: 64 - python-version: "3.11" - sundials-version: 5.7.0 + sundials-version: "6.5.0" tox-env: py311 sundials-precision: double sundials-index-size: 32 - python-version: "3.11" - sundials-version: 5.7.0 + sundials-version: "6.5.0" tox-env: py311 sundials-precision: single sundials-index-size: 64 - python-version: "3.11" - sundials-version: 5.7.0 + sundials-version: "6.5.0" tox-env: py311 sundials-precision: extended sundials-index-size: 64 @@ -123,7 +123,9 @@ jobs: - name: Run tests run: | - source sundials_env.sh + cat sundials_env.sh + source sundials_env.sh && + env && tox env: TOXENV: ${{ matrix.tox-env }} diff --git a/scikits/odes/sundials/c_cvode.pxd b/scikits/odes/sundials/c_cvode.pxd index 9348d3d1..9863cd38 100644 --- a/scikits/odes/sundials/c_cvode.pxd +++ b/scikits/odes/sundials/c_cvode.pxd @@ -47,20 +47,20 @@ cdef extern from "cvode/cvode.h": enum: CV_UNRECOGNIZED_ERR # -99 - 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 (*CVRhsFn)(sunrealtype t, N_Vector y, N_Vector ydot, void *user_data) except? -1 + ctypedef int (*CVRootFn)(sunrealtype t, N_Vector y, sunrealtype *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, char *msg, void *user_data) - void *CVodeCreate(int lmm) + void *CVodeCreate(int lmm, SUNContext sunctx) - int CVodeInit(void *cvode_mem, CVRhsFn f, realtype t0, N_Vector y0) - int CVodeReInit(void *cvode_mem, realtype t0, N_Vector y0) + int CVodeInit(void *cvode_mem, CVRhsFn f, sunrealtype t0, N_Vector y0) + int CVodeReInit(void *cvode_mem, sunrealtype t0, N_Vector y0) - int CVodeSStolerances(void *cvode_mem, realtype reltol, realtype abstol) - int CVodeSVtolerances(void *cvode_mem, realtype reltol, N_Vector abstol) + int CVodeSStolerances(void *cvode_mem, sunrealtype reltol, sunrealtype abstol) + int CVodeSVtolerances(void *cvode_mem, sunrealtype reltol, N_Vector abstol) int CVodeWFtolerances(void *cvode_mem, CVEwtFn efun) int CVodeSetErrHandlerFn(void *cvode_mem, CVErrHandlerFn ehfun, void *eh_data) @@ -69,15 +69,15 @@ cdef extern from "cvode/cvode.h": int CVodeSetMaxOrd(void *cvode_mem, int maxord) int CVodeSetMaxNumSteps(void *cvode_mem, long int mxsteps) int CVodeSetMaxHnilWarns(void *cvode_mem, int mxhnil) - int CVodeSetStabLimDet(void *cvode_mem, booleantype stldet) - int CVodeSetInitStep(void *cvode_mem, realtype hin) - int CVodeSetMinStep(void *cvode_mem, realtype hmin) - int CVodeSetMaxStep(void *cvode_mem, realtype hmax) - int CVodeSetStopTime(void *cvode_mem, realtype tstop) + int CVodeSetStabLimDet(void *cvode_mem, sunbooleantype stldet) + int CVodeSetInitStep(void *cvode_mem, sunrealtype hin) + int CVodeSetMinStep(void *cvode_mem, sunrealtype hmin) + int CVodeSetMaxStep(void *cvode_mem, sunrealtype hmax) + int CVodeSetStopTime(void *cvode_mem, sunrealtype tstop) int CVodeSetMaxErrTestFails(void *cvode_mem, int maxnef) int CVodeSetMaxNonlinIters(void *cvode_mem, int maxcor) int CVodeSetMaxConvFails(void *cvode_mem, int maxncf) - int CVodeSetNonlinConvCoef(void *cvode_mem, realtype nlscoef) + int CVodeSetNonlinConvCoef(void *cvode_mem, sunrealtype nlscoef) int CVodeSetConstraints(void *cvode_mem, N_Vector constraints) int CVodeSetNonlinearSolver(void *cvode_mem, SUNNonlinearSolver NLS) @@ -86,9 +86,9 @@ cdef extern from "cvode/cvode.h": int CVodeSetRootDirection(void *cvode_mem, int *rootdir) int CVodeSetNoInactiveRootWarn(void *cvode_mem) - int CVode(void *cvode_mem, realtype tout, N_Vector yout, - realtype *tret, int itask) - int CVodeGetDky(void *cvode_mem, realtype t, int k, N_Vector dky) + int CVode(void *cvode_mem, sunrealtype tout, N_Vector yout, + sunrealtype *tret, int itask) + int CVodeGetDky(void *cvode_mem, sunrealtype t, int k, N_Vector dky) int CVodeGetWorkSpace(void *cvode_mem, long int *lenrw, long int *leniw) int CVodeGetNumSteps(void *cvode_mem, long int *nsteps) @@ -97,14 +97,14 @@ cdef extern from "cvode/cvode.h": int CVodeGetNumErrTestFails(void *cvode_mem, long int *netfails) int CVodeGetLastOrder(void *cvode_mem, int *qlast) int CVodeGetCurrentOrder(void *cvode_mem, int *qcur) - int CVodeGetCurrentGamma(void *cvode_mem, realtype *gamma) + int CVodeGetCurrentGamma(void *cvode_mem, sunrealtype *gamma) int CVodeGetNumStabLimOrderReds(void *cvode_mem, long int *nslred) - int CVodeGetActualInitStep(void *cvode_mem, realtype *hinused) - int CVodeGetLastStep(void *cvode_mem, realtype *hlast) - int CVodeGetCurrentStep(void *cvode_mem, realtype *hcur) + int CVodeGetActualInitStep(void *cvode_mem, sunrealtype *hinused) + int CVodeGetLastStep(void *cvode_mem, sunrealtype *hlast) + int CVodeGetCurrentStep(void *cvode_mem, sunrealtype *hcur) int CVodeGetCurrentState(void *cvode_mem, N_Vector *y) - int CVodeGetCurrentTime(void *cvode_mem, realtype *tcur) - int CVodeGetTolScaleFactor(void *cvode_mem, realtype *tolsfac) + int CVodeGetCurrentTime(void *cvode_mem, sunrealtype *tcur) + int CVodeGetTolScaleFactor(void *cvode_mem, sunrealtype *tolsfac) int CVodeGetErrWeights(void *cvode_mem, N_Vector eweight) int CVodeGetEstLocalErrors(void *cvode_mem, N_Vector ele) int CVodeGetNumGEvals(void *cvode_mem, long int *ngevals) @@ -113,8 +113,8 @@ cdef extern from "cvode/cvode.h": int CVodeGetIntegratorStats(void *cvode_mem, long int *nsteps, long int *nfevals, long int *nlinsetups, long int *netfails, int *qlast, - int *qcur, realtype *hinused, realtype *hlast, - realtype *hcur, realtype *tcur) + int *qcur, sunrealtype *hinused, sunrealtype *hlast, + sunrealtype *hcur, sunrealtype *tcur) int CVodeGetNumNonlinSolvIters(void *cvode_mem, long int *nniters) int CVodeGetNumNonlinSolvConvFails(void *cvode_mem, long int *nncfails) @@ -136,28 +136,28 @@ cdef extern from "cvode/cvode_ls.h": enum: CVLS_SUNMAT_FAIL # -8 enum: CVLS_SUNLS_FAIL # -9 - ctypedef int (*CVLsJacFn)(realtype t, N_Vector y, N_Vector fy, + ctypedef int (*CVLsJacFn)(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix Jac, void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) except? -1 - ctypedef int (*CVLsPrecSetupFn)(realtype t, N_Vector y, N_Vector fy, - booleantype jok, booleantype *jcurPtr, - realtype gamma, void *user_data) except? -1 + ctypedef int (*CVLsPrecSetupFn)(sunrealtype t, N_Vector y, N_Vector fy, + sunbooleantype jok, sunbooleantype *jcurPtr, + sunrealtype gamma, void *user_data) except? -1 - ctypedef int (*CVLsPrecSolveFn)(realtype t, N_Vector y, N_Vector fy, - N_Vector r, N_Vector z, realtype gamma, - realtype delta, int lr, void *user_data) except? -1 + ctypedef int (*CVLsPrecSolveFn)(sunrealtype t, N_Vector y, N_Vector fy, + N_Vector r, N_Vector z, sunrealtype gamma, + sunrealtype delta, int lr, void *user_data) except? -1 - ctypedef int (*CVLsJacTimesSetupFn)(realtype t, N_Vector y, + ctypedef int (*CVLsJacTimesSetupFn)(sunrealtype t, N_Vector y, N_Vector fy, void *user_data) except? -1 - ctypedef int (*CVLsJacTimesVecFn)(N_Vector v, N_Vector Jv, realtype t, + ctypedef int (*CVLsJacTimesVecFn)(N_Vector v, N_Vector Jv, sunrealtype t, N_Vector y, N_Vector fy, void *user_data, N_Vector tmp) except? -1 - ctypedef int (*CVLsLinSysFn)(realtype t, N_Vector y, N_Vector fy, - SUNMatrix A, booleantype jok, - booleantype *jcur, realtype gamma, + ctypedef int (*CVLsLinSysFn)(sunrealtype t, N_Vector y, N_Vector fy, + SUNMatrix A, sunbooleantype jok, + sunbooleantype *jcur, sunrealtype gamma, void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) @@ -166,7 +166,7 @@ cdef extern from "cvode/cvode_ls.h": int CVodeSetJacFn(void *cvode_mem, CVLsJacFn jac) int CVodeSetMaxStepsBetweenJac(void *cvode_mem, long int msbj) - int CVodeSetEpsLin(void *cvode_mem, realtype eplifac) + int CVodeSetEpsLin(void *cvode_mem, sunrealtype eplifac) int CVodeSetPreconditioner(void *cvode_mem, CVLsPrecSetupFn pset, CVLsPrecSolveFn psolve) int CVodeSetJacTimes(void *cvode_mem, CVLsJacTimesSetupFn jtsetup, @@ -187,16 +187,14 @@ cdef extern from "cvode/cvode_ls.h": char *CVodeGetLinReturnFlagName(long int flag) cdef extern from "cvode/cvode_direct.h": - ctypedef CVLsJacFn CVDlsJacFn + ctypedef CVLsJacFn CVodeJacFn - int CVDlsSetLinearSolver(void *cvode_mem, SUNLinearSolver LS, - SUNMatrix A) - int CVDlsSetJacFn(void *cvode_mem, CVDlsJacFn jac) - int CVDlsGetWorkSpace(void *cvode_mem, long int *lenrwLS, long int *leniwLS) - int CVDlsGetNumJacEvals(void *cvode_mem, long int *njevals) - int CVDlsGetNumRhsEvals(void *cvode_mem, long int *nfevalsLS) - int CVDlsGetLastFlag(void *cvode_mem, long int *flag) - char *CVDlsGetReturnFlagName(long int flag) + int CVodeSetJacFn(void *cvode_mem, CVodeJacFn jac) + int CVodeGetWorkSpace(void *cvode_mem, long int *lenrwLS, long int *leniwLS) + int CVodeGetNumJacEvals(void *cvode_mem, long int *njevals) + int CVodeGetNumRhsEvals(void *cvode_mem, long int *nfevalsLS) + int CVodeGetLastFlag(void *cvode_mem, long int *flag) + char *CVodeGetReturnFlagName(long int flag) cdef extern from "cvode/cvode_bandpre.h": int CVBandPrecInit(void *cvode_mem, sunindextype N, sunindextype mu, @@ -224,42 +222,41 @@ cdef extern from "cvode/cvode_diag.h": char *CVDiagGetReturnFlagName(long int flag) cdef extern from "cvode/cvode_bbdpre.h": - ctypedef int (*CVLocalFn)(sunindextype Nlocal, realtype t, N_Vector y, + ctypedef int (*CVLocalFn)(sunindextype Nlocal, sunrealtype t, N_Vector y, N_Vector g, void *user_data) - ctypedef int (*CVCommFn)(sunindextype Nlocal, realtype t, N_Vector y, + ctypedef int (*CVCommFn)(sunindextype Nlocal, sunrealtype t, N_Vector y, void *user_data) int CVBBDPrecInit(void *cvode_mem, sunindextype Nlocal, sunindextype mudq, sunindextype mldq, sunindextype mukeep, sunindextype mlkeep, - realtype dqrely, CVLocalFn gloc, CVCommFn cfn) + sunrealtype dqrely, CVLocalFn gloc, CVCommFn cfn) int CVBBDPrecReInit(void *cvode_mem, sunindextype mudq, sunindextype mldq, - realtype dqrely) + sunrealtype dqrely) int CVBBDPrecGetWorkSpace(void *cvode_mem, long int *lenrwBBDP, long int *leniwBBDP) int CVBBDPrecGetNumGfnEvals(void *cvode_mem, long int *ngevalsBBDP) cdef extern from "cvode/cvode_spils.h": - ctypedef CVLsPrecSetupFn CVSpilsPrecSetupFn - ctypedef CVLsPrecSolveFn CVSpilsPrecSolveFn - ctypedef CVLsJacTimesSetupFn CVSpilsJacTimesSetupFn - ctypedef CVLsJacTimesVecFn CVSpilsJacTimesVecFn - - int CVSpilsSetLinearSolver(void *cvode_mem, SUNLinearSolver LS) - int CVSpilsSetEpsLin(void *cvode_mem, realtype eplifac) - int CVSpilsSetPreconditioner(void *cvode_mem, CVSpilsPrecSetupFn pset, - CVSpilsPrecSolveFn psolve) - int CVSpilsSetJacTimes(void *cvode_mem, CVSpilsJacTimesSetupFn jtsetup, - CVSpilsJacTimesVecFn jtimes) - - int CVSpilsGetWorkSpace(void *cvode_mem, long int *lenrwLS, long int *leniwLS) - int CVSpilsGetNumPrecEvals(void *cvode_mem, long int *npevals) - int CVSpilsGetNumPrecSolves(void *cvode_mem, long int *npsolves) - int CVSpilsGetNumLinIters(void *cvode_mem, long int *nliters) - int CVSpilsGetNumConvFails(void *cvode_mem, long int *nlcfails) - int CVSpilsGetNumJTSetupEvals(void *cvode_mem, long int *njtsetups) - int CVSpilsGetNumJtimesEvals(void *cvode_mem, long int *njvevals) - int CVSpilsGetNumRhsEvals(void *cvode_mem, long int *nfevalsLS) - int CVSpilsGetLastFlag(void *cvode_mem, long int *flag) - char *CVSpilsGetReturnFlagName(long int flag) + ctypedef CVLsPrecSetupFn CVodePrecSetupFn + ctypedef CVLsPrecSolveFn CVodePrecSolveFn + ctypedef CVLsJacTimesSetupFn CVodeJacTimesSetupFn + ctypedef CVLsJacTimesVecFn CVodeJacTimesVecFn + + int CVodeSetEpsLin(void *cvode_mem, sunrealtype eplifac) + int CVodeSetPreconditioner(void *cvode_mem, CVodePrecSetupFn pset, + CVodePrecSolveFn psolve) + int CVodeSetJacTimes(void *cvode_mem, CVodeJacTimesSetupFn jtsetup, + CVodeJacTimesVecFn jtimes) + + int CVodeGetWorkSpace(void *cvode_mem, long int *lenrwLS, long int *leniwLS) + int CVodeGetNumPrecEvals(void *cvode_mem, long int *npevals) + int CVodeGetNumPrecSolves(void *cvode_mem, long int *npsolves) + int CVodeGetNumLinIters(void *cvode_mem, long int *nliters) + int CVodeGetNumConvFails(void *cvode_mem, long int *nlcfails) + int CVodeGetNumJTSetupEvals(void *cvode_mem, long int *njtsetups) + int CVodeGetNumJtimesEvals(void *cvode_mem, long int *njvevals) + int CVodeGetNumRhsEvals(void *cvode_mem, long int *nfevalsLS) + int CVodeGetLastFlag(void *cvode_mem, long int *flag) + char *CVodeGetReturnFlagName(long int flag) diff --git a/scikits/odes/sundials/c_cvodes.pxd b/scikits/odes/sundials/c_cvodes.pxd index b26e38c3..22336065 100644 --- a/scikits/odes/sundials/c_cvodes.pxd +++ b/scikits/odes/sundials/c_cvodes.pxd @@ -90,45 +90,45 @@ cdef extern from "cvodes/cvodes.h": enum: CV_FWD_FAIL # -106 enum: CV_GETY_BADT # -107 - 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 (*CVRhsFn)(sunrealtype t, N_Vector y, N_Vector ydot, void *user_data) except? -1 + ctypedef int (*CVRootFn)(sunrealtype t, N_Vector y, sunrealtype *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, char *msg, void *user_data) - ctypedef int (*CVQuadRhsFn)(realtype t, N_Vector y, + ctypedef int (*CVQuadRhsFn)(sunrealtype t, N_Vector y, N_Vector yQdot, void *user_data) - ctypedef int (*CVSensRhsFn)(int Ns, realtype t, N_Vector y, N_Vector ydot, + ctypedef int (*CVSensRhsFn)(int Ns, sunrealtype t, N_Vector y, N_Vector ydot, N_Vector *yS, N_Vector *ySdot, void *user_data, N_Vector tmp1, N_Vector tmp2) - ctypedef int (*CVSensRhs1Fn)(int Ns, realtype t, N_Vector y, N_Vector ydot, + ctypedef int (*CVSensRhs1Fn)(int Ns, sunrealtype t, N_Vector y, N_Vector ydot, int iS, N_Vector yS, N_Vector ySdot, void *user_data, N_Vector tmp1, N_Vector tmp2) - ctypedef int (*CVQuadSensRhsFn)(int Ns, realtype t, N_Vector y, + ctypedef int (*CVQuadSensRhsFn)(int Ns, sunrealtype t, N_Vector y, N_Vector *yS, N_Vector yQdot, N_Vector *yQSdot, void *user_data, N_Vector tmp, N_Vector tmpQ) - ctypedef int (*CVRhsFnB)(realtype t, N_Vector y, N_Vector yB, + ctypedef int (*CVRhsFnB)(sunrealtype t, N_Vector y, N_Vector yB, N_Vector yBdot, void *user_dataB) - ctypedef int (*CVRhsFnBS)(realtype t, N_Vector y, N_Vector *yS, + ctypedef int (*CVRhsFnBS)(sunrealtype t, N_Vector y, N_Vector *yS, N_Vector yB, N_Vector yBdot, void *user_dataB) - ctypedef int (*CVQuadRhsFnB)(realtype t, N_Vector y, N_Vector yB, + ctypedef int (*CVQuadRhsFnB)(sunrealtype t, N_Vector y, N_Vector yB, N_Vector qBdot, void *user_dataB) - ctypedef int (*CVQuadRhsFnBS)(realtype t, N_Vector y, N_Vector *yS, + ctypedef int (*CVQuadRhsFnBS)(sunrealtype t, N_Vector y, N_Vector *yS, N_Vector yB, N_Vector qBdot, void *user_dataB) # Exported Functions -- Forward Problems - void *CVodeCreate(int lmm) + void *CVodeCreate(int lmm, SUNContext sunctx) - int CVodeInit(void *cvode_mem, CVRhsFn f, realtype t0, N_Vector y0) - int CVodeReInit(void *cvode_mem, realtype t0, N_Vector y0) + int CVodeInit(void *cvode_mem, CVRhsFn f, sunrealtype t0, N_Vector y0) + int CVodeReInit(void *cvode_mem, sunrealtype t0, N_Vector y0) - int CVodeSStolerances(void *cvode_mem, realtype reltol, realtype abstol) - int CVodeSVtolerances(void *cvode_mem, realtype reltol, N_Vector abstol) + int CVodeSStolerances(void *cvode_mem, sunrealtype reltol, sunrealtype abstol) + int CVodeSVtolerances(void *cvode_mem, sunrealtype reltol, N_Vector abstol) int CVodeWFtolerances(void *cvode_mem, CVEwtFn efun) int CVodeSetErrHandlerFn(void *cvode_mem, CVErrHandlerFn ehfun, void *eh_data) @@ -137,15 +137,15 @@ cdef extern from "cvodes/cvodes.h": int CVodeSetMaxOrd(void *cvode_mem, int maxord) int CVodeSetMaxNumSteps(void *cvode_mem, long int mxsteps) int CVodeSetMaxHnilWarns(void *cvode_mem, int mxhnil) - int CVodeSetStabLimDet(void *cvode_mem, booleantype stldet) - int CVodeSetInitStep(void *cvode_mem, realtype hin) - int CVodeSetMinStep(void *cvode_mem, realtype hmin) - int CVodeSetMaxStep(void *cvode_mem, realtype hmax) - int CVodeSetStopTime(void *cvode_mem, realtype tstop) + int CVodeSetStabLimDet(void *cvode_mem, sunbooleantype stldet) + int CVodeSetInitStep(void *cvode_mem, sunrealtype hin) + int CVodeSetMinStep(void *cvode_mem, sunrealtype hmin) + int CVodeSetMaxStep(void *cvode_mem, sunrealtype hmax) + int CVodeSetStopTime(void *cvode_mem, sunrealtype tstop) int CVodeSetMaxErrTestFails(void *cvode_mem, int maxnef) int CVodeSetMaxNonlinIters(void *cvode_mem, int maxcor) int CVodeSetMaxConvFails(void *cvode_mem, int maxncf) - int CVodeSetNonlinConvCoef(void *cvode_mem, realtype nlscoef) + int CVodeSetNonlinConvCoef(void *cvode_mem, sunrealtype nlscoef) int CVodeSetConstraints(void *cvode_mem, N_Vector constraints) int CVodeSetNonlinearSolver(void *cvode_mem, SUNNonlinearSolver NLS) @@ -154,9 +154,9 @@ cdef extern from "cvodes/cvodes.h": int CVodeSetRootDirection(void *cvode_mem, int *rootdir) int CVodeSetNoInactiveRootWarn(void *cvode_mem) - int CVode(void *cvode_mem, realtype tout, N_Vector yout, - realtype *tret, int itask) - int CVodeGetDky(void *cvode_mem, realtype t, int k, N_Vector dky) + int CVode(void *cvode_mem, sunrealtype tout, N_Vector yout, + sunrealtype *tret, int itask) + int CVodeGetDky(void *cvode_mem, sunrealtype t, int k, N_Vector dky) int CVodeGetWorkSpace(void *cvode_mem, long int *lenrw, long int *leniw) int CVodeGetNumSteps(void *cvode_mem, long int *nsteps) @@ -165,14 +165,14 @@ cdef extern from "cvodes/cvodes.h": int CVodeGetNumErrTestFails(void *cvode_mem, long int *netfails) int CVodeGetLastOrder(void *cvode_mem, int *qlast) int CVodeGetCurrentOrder(void *cvode_mem, int *qcur) - int CVodeGetCurrentGamma(void *cvode_mem, realtype *gamma) + int CVodeGetCurrentGamma(void *cvode_mem, sunrealtype *gamma) int CVodeGetNumStabLimOrderReds(void *cvode_mem, long int *nslred) - int CVodeGetActualInitStep(void *cvode_mem, realtype *hinused) - int CVodeGetLastStep(void *cvode_mem, realtype *hlast) - int CVodeGetCurrentStep(void *cvode_mem, realtype *hcur) + int CVodeGetActualInitStep(void *cvode_mem, sunrealtype *hinused) + int CVodeGetLastStep(void *cvode_mem, sunrealtype *hlast) + int CVodeGetCurrentStep(void *cvode_mem, sunrealtype *hcur) int CVodeGetCurrentState(void *cvode_mem, N_Vector *y) - int CVodeGetCurrentTime(void *cvode_mem, realtype *tcur) - int CVodeGetTolScaleFactor(void *cvode_mem, realtype *tolsfac) + int CVodeGetCurrentTime(void *cvode_mem, sunrealtype *tcur) + int CVodeGetTolScaleFactor(void *cvode_mem, sunrealtype *tolsfac) int CVodeGetErrWeights(void *cvode_mem, N_Vector eweight) int CVodeGetEstLocalErrors(void *cvode_mem, N_Vector ele) int CVodeGetNumGEvals(void *cvode_mem, long int *ngevals) @@ -181,8 +181,8 @@ cdef extern from "cvodes/cvodes.h": int CVodeGetIntegratorStats(void *cvode_mem, long int *nsteps, long int *nfevals, long int *nlinsetups, long int *netfails, int *qlast, - int *qcur, realtype *hinused, realtype *hlast, - realtype *hcur, realtype *tcur) + int *qcur, sunrealtype *hinused, sunrealtype *hlast, + sunrealtype *hcur, sunrealtype *tcur) int CVodeGetNumNonlinSolvIters(void *cvode_mem, long int *nniters) int CVodeGetNumNonlinSolvConvFails(void *cvode_mem, long int *nncfails) @@ -195,15 +195,15 @@ cdef extern from "cvodes/cvodes.h": int CVodeQuadInit(void *cvode_mem, CVQuadRhsFn fQ, N_Vector yQ0) int CVodeQuadReInit(void *cvode_mem, N_Vector yQ0) - int CVodeQuadSStolerances(void *cvode_mem, realtype reltolQ, - realtype abstolQ) - int CVodeQuadSVtolerances(void *cvode_mem, realtype reltolQ, + int CVodeQuadSStolerances(void *cvode_mem, sunrealtype reltolQ, + sunrealtype abstolQ) + int CVodeQuadSVtolerances(void *cvode_mem, sunrealtype reltolQ, N_Vector abstolQ) - int CVodeSetQuadErrCon(void *cvode_mem, booleantype errconQ) + int CVodeSetQuadErrCon(void *cvode_mem, sunbooleantype errconQ) - int CVodeGetQuad(void *cvode_mem, realtype *tret, N_Vector yQout) - int CVodeGetQuadDky(void *cvode_mem, realtype t, int k, N_Vector dky) + int CVodeGetQuad(void *cvode_mem, sunrealtype *tret, N_Vector yQout) + int CVodeGetQuadDky(void *cvode_mem, sunrealtype t, int k, N_Vector dky) int CVodeGetQuadNumRhsEvals(void *cvode_mem, long int *nfQevals) int CVodeGetQuadNumErrTestFails(void *cvode_mem, long int *nQetfails) @@ -220,17 +220,17 @@ cdef extern from "cvodes/cvodes.h": CVSensRhs1Fn fS1, N_Vector *yS0) int CVodeSensReInit(void *cvode_mem, int ism, N_Vector *yS0) - int CVodeSensSStolerances(void *cvode_mem, realtype reltolS, - realtype *abstolS) - int CVodeSensSVtolerances(void *cvode_mem, realtype reltolS, + int CVodeSensSStolerances(void *cvode_mem, sunrealtype reltolS, + sunrealtype *abstolS) + int CVodeSensSVtolerances(void *cvode_mem, sunrealtype reltolS, N_Vector *abstolS) int CVodeSensEEtolerances(void *cvode_mem) - int CVodeSetSensDQMethod(void *cvode_mem, int DQtype, realtype DQrhomax) - int CVodeSetSensErrCon(void *cvode_mem, booleantype errconS) + int CVodeSetSensDQMethod(void *cvode_mem, int DQtype, sunrealtype DQrhomax) + int CVodeSetSensErrCon(void *cvode_mem, sunbooleantype errconS) int CVodeSetSensMaxNonlinIters(void *cvode_mem, int maxcorS) - int CVodeSetSensParams(void *cvode_mem, realtype *p, - realtype *pbar, int *plist) + int CVodeSetSensParams(void *cvode_mem, sunrealtype *p, + sunrealtype *pbar, int *plist) int CVodeSetNonlinearSolverSensSim(void *cvode_mem, SUNNonlinearSolver NLS) @@ -241,12 +241,12 @@ cdef extern from "cvodes/cvodes.h": int CVodeSensToggleOff(void *cvode_mem) - int CVodeGetSens(void *cvode_mem, realtype *tret, N_Vector *ySout) - int CVodeGetSens1(void *cvode_mem, realtype *tret, int iss, + int CVodeGetSens(void *cvode_mem, sunrealtype *tret, N_Vector *ySout) + int CVodeGetSens1(void *cvode_mem, sunrealtype *tret, int iss, N_Vector ySout) # rename is to iss, is protected in python - int CVodeGetSensDky(void *cvode_mem, realtype t, int k, + int CVodeGetSensDky(void *cvode_mem, sunrealtype t, int k, N_Vector *dkyA) - int CVodeGetSensDky1(void *cvode_mem, realtype t, int k, int iss, + int CVodeGetSensDky1(void *cvode_mem, sunrealtype t, int k, int iss, N_Vector dky) # rename is to iss, is protected in python int CVodeGetSensNumRhsEvals(void *cvode_mem, long int *nfSevals) @@ -273,21 +273,21 @@ cdef extern from "cvodes/cvodes.h": N_Vector *yQS0) int CVodeQuadSensReInit(void *cvode_mem, N_Vector *yQS0) - int CVodeQuadSensSStolerances(void *cvode_mem, realtype reltolQS, - realtype *abstolQS) - int CVodeQuadSensSVtolerances(void *cvode_mem, realtype reltolQS, + int CVodeQuadSensSStolerances(void *cvode_mem, sunrealtype reltolQS, + sunrealtype *abstolQS) + int CVodeQuadSensSVtolerances(void *cvode_mem, sunrealtype reltolQS, N_Vector *abstolQS) int CVodeQuadSensEEtolerances(void *cvode_mem) - int CVodeSetQuadSensErrCon(void *cvode_mem, booleantype errconQS) + int CVodeSetQuadSensErrCon(void *cvode_mem, sunbooleantype errconQS) - int CVodeGetQuadSens(void *cvode_mem, realtype *tret, N_Vector *yQSout) - int CVodeGetQuadSens1(void *cvode_mem, realtype *tret, int iss, + int CVodeGetQuadSens(void *cvode_mem, sunrealtype *tret, N_Vector *yQSout) + int CVodeGetQuadSens1(void *cvode_mem, sunrealtype *tret, int iss, N_Vector yQSout) # rename is to iss, is protected in python - int CVodeGetQuadSensDky(void *cvode_mem, realtype t, int k, + int CVodeGetQuadSensDky(void *cvode_mem, sunrealtype t, int k, N_Vector *dkyQS_all) - int CVodeGetQuadSensDky1(void *cvode_mem, realtype t, int k, + int CVodeGetQuadSensDky1(void *cvode_mem, sunrealtype t, int k, int iss, N_Vector dkyQS) # rename is to iss, is protected in python int CVodeGetQuadSensNumRhsEvals(void *cvode_mem, long int *nfQSevals) @@ -305,15 +305,15 @@ cdef extern from "cvodes/cvodes.h": void CVodeAdjFree(void *cvode_mem) int CVodeCreateB(void *cvode_mem, int lmmB, int *which) - int CVodeInitB(void *cvode_mem, int which, CVRhsFnB fB, realtype tB0, + int CVodeInitB(void *cvode_mem, int which, CVRhsFnB fB, sunrealtype tB0, N_Vector yB0) int CVodeInitBS(void *cvode_mem, int which, CVRhsFnBS fBs, - realtype tB0, N_Vector yB0) - int CVodeReInitB(void *cvode_mem, int which, realtype tB0, N_Vector yB0) - int CVodeSStolerancesB(void *cvode_mem, int which, realtype reltolB, - realtype abstolB) + sunrealtype tB0, N_Vector yB0) + int CVodeReInitB(void *cvode_mem, int which, sunrealtype tB0, N_Vector yB0) + int CVodeSStolerancesB(void *cvode_mem, int which, sunrealtype reltolB, + sunrealtype abstolB) int CVodeSVtolerancesB(void *cvode_mem, int which, - realtype reltolB, N_Vector abstolB) + sunrealtype reltolB, N_Vector abstolB) int CVodeQuadInitB(void *cvode_mem, int which, CVQuadRhsFnB fQB, N_Vector yQB0) @@ -322,16 +322,16 @@ cdef extern from "cvodes/cvodes.h": int CVodeQuadReInitB(void *cvode_mem, int which, N_Vector yQB0) int CVodeQuadSStolerancesB(void *cvode_mem, int which, - realtype reltolQB, realtype abstolQB) + sunrealtype reltolQB, sunrealtype abstolQB) int CVodeQuadSVtolerancesB(void *cvode_mem, int which, - realtype reltolQB, N_Vector abstolQB) + sunrealtype reltolQB, N_Vector abstolQB) # Solver Function For Forward Problems - int CVodeF(void *cvode_mem, realtype tout, N_Vector yout, - realtype *tret, int itask, int *ncheckPtr) + int CVodeF(void *cvode_mem, sunrealtype tout, N_Vector yout, + sunrealtype *tret, int itask, int *ncheckPtr) # Solver Function For Backward Problems - int CVodeB(void *cvode_mem, realtype tBout, int itaskB) + int CVodeB(void *cvode_mem, sunrealtype tBout, int itaskB) # Optional Input Functions For Adjoint Problems int CVodeSetAdjNoSensi(void *cvode_mem) @@ -339,42 +339,42 @@ cdef extern from "cvodes/cvodes.h": int CVodeSetUserDataB(void *cvode_mem, int which, void *user_dataB) int CVodeSetMaxOrdB(void *cvode_mem, int which, int maxordB) int CVodeSetMaxNumStepsB(void *cvode_mem, int which, long int mxstepsB) - int CVodeSetStabLimDetB(void *cvode_mem, int which, booleantype stldetB) - int CVodeSetInitStepB(void *cvode_mem, int which, realtype hinB) - int CVodeSetMinStepB(void *cvode_mem, int which, realtype hminB) - int CVodeSetMaxStepB(void *cvode_mem, int which, realtype hmaxB) + int CVodeSetStabLimDetB(void *cvode_mem, int which, sunbooleantype stldetB) + int CVodeSetInitStepB(void *cvode_mem, int which, sunrealtype hinB) + int CVodeSetMinStepB(void *cvode_mem, int which, sunrealtype hminB) + int CVodeSetMaxStepB(void *cvode_mem, int which, sunrealtype hmaxB) int CVodeSetConstraintsB(void *cvode_mem, int which, N_Vector constraintsB) - int CVodeSetQuadErrConB(void *cvode_mem, int which, booleantype errconQB) + int CVodeSetQuadErrConB(void *cvode_mem, int which, sunbooleantype errconQB) int CVodeSetNonlinearSolverB(void *cvode_mem, int which, SUNNonlinearSolver NLS) # Extraction And Dense Output Functions For Backward Problems - int CVodeGetB(void *cvode_mem, int which, realtype *tBret, N_Vector yB) - int CVodeGetQuadB(void *cvode_mem, int which, realtype *tBret, N_Vector qB) + int CVodeGetB(void *cvode_mem, int which, sunrealtype *tBret, N_Vector yB) + int CVodeGetQuadB(void *cvode_mem, int which, sunrealtype *tBret, N_Vector qB) # Optional Output Functions For Backward Problems void *CVodeGetAdjCVodeBmem(void *cvode_mem, int which) - int CVodeGetAdjY(void *cvode_mem, realtype t, N_Vector y) + int CVodeGetAdjY(void *cvode_mem, sunrealtype t, N_Vector y) struct _CVadjCheckPointRec: void *my_addr void *next_addr - realtype t0 - realtype t1 + sunrealtype t0 + sunrealtype t1 long int nstep int order - realtype step + sunrealtype step ctypedef _CVadjCheckPointRec CVadjCheckPointRec int CVodeGetAdjCheckPointsInfo(void *cvode_mem, CVadjCheckPointRec *ckpnt) int CVodeGetAdjDataPointHermite(void *cvode_mem, int which, - realtype *t, N_Vector y, N_Vector yd) + sunrealtype *t, N_Vector y, N_Vector yd) int CVodeGetAdjDataPointPolynomial(void *cvode_mem, int which, - realtype *t, int *order, N_Vector y) + sunrealtype *t, int *order, N_Vector y) int CVodeGetAdjCurrentCheckPoint(void *cvode_mem, void **addr) @@ -396,28 +396,28 @@ cdef extern from "cvodes/cvodes_ls.h": enum: CVLS_NO_ADJ # -101 enum: CVLS_LMEMB_NULL # -102 - ctypedef int (*CVLsJacFn)(realtype t, N_Vector y, N_Vector fy, + ctypedef int (*CVLsJacFn)(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix Jac, void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) except? -1 - ctypedef int (*CVLsPrecSetupFn)(realtype t, N_Vector y, N_Vector fy, - booleantype jok, booleantype *jcurPtr, - realtype gamma, void *user_data) except? -1 + ctypedef int (*CVLsPrecSetupFn)(sunrealtype t, N_Vector y, N_Vector fy, + sunbooleantype jok, sunbooleantype *jcurPtr, + sunrealtype gamma, void *user_data) except? -1 - ctypedef int (*CVLsPrecSolveFn)(realtype t, N_Vector y, N_Vector fy, - N_Vector r, N_Vector z, realtype gamma, - realtype delta, int lr, void *user_data) except? -1 + ctypedef int (*CVLsPrecSolveFn)(sunrealtype t, N_Vector y, N_Vector fy, + N_Vector r, N_Vector z, sunrealtype gamma, + sunrealtype delta, int lr, void *user_data) except? -1 - ctypedef int (*CVLsJacTimesSetupFn)(realtype t, N_Vector y, + ctypedef int (*CVLsJacTimesSetupFn)(sunrealtype t, N_Vector y, N_Vector fy, void *user_data) except? -1 - ctypedef int (*CVLsJacTimesVecFn)(N_Vector v, N_Vector Jv, realtype t, + ctypedef int (*CVLsJacTimesVecFn)(N_Vector v, N_Vector Jv, sunrealtype t, N_Vector y, N_Vector fy, void *user_data, N_Vector tmp) except? -1 - ctypedef int (*CVLsLinSysFn)(realtype t, N_Vector y, N_Vector fy, - SUNMatrix A, booleantype jok, - booleantype *jcur, realtype gamma, + ctypedef int (*CVLsLinSysFn)(sunrealtype t, N_Vector y, N_Vector fy, + SUNMatrix A, sunbooleantype jok, + sunbooleantype *jcur, sunrealtype gamma, void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) @@ -426,7 +426,7 @@ cdef extern from "cvodes/cvodes_ls.h": int CVodeSetJacFn(void *cvode_mem, CVLsJacFn jac) int CVodeSetMaxStepsBetweenJac(void *cvode_mem, long int msbj) - int CVodeSetEpsLin(void *cvode_mem, realtype eplifac) + int CVodeSetEpsLin(void *cvode_mem, sunrealtype eplifac) int CVodeSetPreconditioner(void *cvode_mem, CVLsPrecSetupFn pset, CVLsPrecSolveFn psolve) int CVodeSetJacTimes(void *cvode_mem, CVLsJacTimesSetupFn jtsetup, @@ -447,65 +447,65 @@ cdef extern from "cvodes/cvodes_ls.h": char *CVodeGetLinReturnFlagName(long int flag) # Backward problems - ctypedef int (*CVLsJacFnB)(realtype t, N_Vector y, N_Vector yB, + ctypedef int (*CVLsJacFnB)(sunrealtype t, N_Vector y, N_Vector yB, N_Vector fyB, SUNMatrix JB, void *user_dataB, N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B) - ctypedef int (*CVLsJacFnBS)(realtype t, N_Vector y, N_Vector *yS, + ctypedef int (*CVLsJacFnBS)(sunrealtype t, N_Vector y, N_Vector *yS, N_Vector yB, N_Vector fyB, SUNMatrix JB, void *user_dataB, N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B) - ctypedef int (*CVLsPrecSetupFnB)(realtype t, N_Vector y, N_Vector yB, - N_Vector fyB, booleantype jokB, - booleantype *jcurPtrB, - realtype gammaB, void *user_dataB) + ctypedef int (*CVLsPrecSetupFnB)(sunrealtype t, N_Vector y, N_Vector yB, + N_Vector fyB, sunbooleantype jokB, + sunbooleantype *jcurPtrB, + sunrealtype gammaB, void *user_dataB) - ctypedef int (*CVLsPrecSetupFnBS)(realtype t, N_Vector y, + ctypedef int (*CVLsPrecSetupFnBS)(sunrealtype t, N_Vector y, N_Vector *yS, N_Vector yB, - N_Vector fyB, booleantype jokB, - booleantype *jcurPtrB, - realtype gammaB, void *user_dataB) + N_Vector fyB, sunbooleantype jokB, + sunbooleantype *jcurPtrB, + sunrealtype gammaB, void *user_dataB) - ctypedef int (*CVLsPrecSolveFnB)(realtype t, N_Vector y, N_Vector yB, + ctypedef int (*CVLsPrecSolveFnB)(sunrealtype t, N_Vector y, N_Vector yB, N_Vector fyB, N_Vector rB, - N_Vector zB, realtype gammaB, - realtype deltaB, int lrB, + N_Vector zB, sunrealtype gammaB, + sunrealtype deltaB, int lrB, void *user_dataB) - ctypedef int (*CVLsPrecSolveFnBS)(realtype t, N_Vector y, N_Vector *yS, + ctypedef int (*CVLsPrecSolveFnBS)(sunrealtype t, N_Vector y, N_Vector *yS, N_Vector yB, N_Vector fyB, N_Vector rB, N_Vector zB, - realtype gammaB, realtype deltaB, + sunrealtype gammaB, sunrealtype deltaB, int lrB, void *user_dataB) - ctypedef int (*CVLsJacTimesSetupFnB)(realtype t, N_Vector y, N_Vector yB, + ctypedef int (*CVLsJacTimesSetupFnB)(sunrealtype t, N_Vector y, N_Vector yB, N_Vector fyB, void *jac_dataB) - ctypedef int (*CVLsJacTimesSetupFnBS)(realtype t, N_Vector y, + ctypedef int (*CVLsJacTimesSetupFnBS)(sunrealtype t, N_Vector y, N_Vector *yS, N_Vector yB, N_Vector fyB, void *jac_dataB) - ctypedef int (*CVLsJacTimesVecFnB)(N_Vector vB, N_Vector JvB, realtype t, + ctypedef int (*CVLsJacTimesVecFnB)(N_Vector vB, N_Vector JvB, sunrealtype t, N_Vector y, N_Vector yB, N_Vector fyB, void *jac_dataB, N_Vector tmpB) ctypedef int (*CVLsJacTimesVecFnBS)(N_Vector vB, N_Vector JvB, - realtype t, N_Vector y, N_Vector *yS, + sunrealtype t, N_Vector y, N_Vector *yS, N_Vector yB, N_Vector fyB, void *jac_dataB, N_Vector tmpB) - ctypedef int (*CVLsLinSysFnB)(realtype t, N_Vector y, N_Vector yB, - N_Vector fyB, SUNMatrix AB, booleantype jokB, - booleantype *jcurB, realtype gammaB, + ctypedef int (*CVLsLinSysFnB)(sunrealtype t, N_Vector y, N_Vector yB, + N_Vector fyB, SUNMatrix AB, sunbooleantype jokB, + sunbooleantype *jcurB, sunrealtype gammaB, void *user_dataB, N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B) - ctypedef int (*CVLsLinSysFnBS)(realtype t, N_Vector y, N_Vector* yS, + ctypedef int (*CVLsLinSysFnBS)(sunrealtype t, N_Vector y, N_Vector* yS, N_Vector yB, N_Vector fyB, SUNMatrix AB, - booleantype jokB, booleantype *jcurB, - realtype gammaB, void *user_dataB, + sunbooleantype jokB, sunbooleantype *jcurB, + sunrealtype gammaB, void *user_dataB, N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B) @@ -515,7 +515,7 @@ cdef extern from "cvodes/cvodes_ls.h": int CVodeSetJacFnB(void *cvode_mem, int which, CVLsJacFnB jacB) int CVodeSetJacFnBS(void *cvode_mem, int which, CVLsJacFnBS jacBS) - int CVodeSetEpsLinB(void *cvode_mem, int which, realtype eplifacB) + int CVodeSetEpsLinB(void *cvode_mem, int which, sunrealtype eplifacB) int CVodeSetPreconditionerB(void *cvode_mem, int which, CVLsPrecSetupFnB psetB, @@ -535,23 +535,19 @@ cdef extern from "cvodes/cvodes_ls.h": int CVodeSetLinSysFnBS(void *cvode_mem, int which, CVLsLinSysFnBS linsys) cdef extern from "cvodes/cvodes_direct.h": - ctypedef CVLsJacFn CVDlsJacFn - ctypedef CVLsJacFnB CVDlsJacFnB - ctypedef CVLsJacFnBS CVDlsJacFnBS - - int CVDlsSetLinearSolver(void *cvode_mem, SUNLinearSolver LS, - SUNMatrix A) - int CVDlsSetJacFn(void *cvode_mem, CVDlsJacFn jac) - int CVDlsGetWorkSpace(void *cvode_mem, long int *lenrwLS, long int *leniwLS) - int CVDlsGetNumJacEvals(void *cvode_mem, long int *njevals) - int CVDlsGetNumRhsEvals(void *cvode_mem, long int *nfevalsLS) - int CVDlsGetLastFlag(void *cvode_mem, long int *flag) - char *CVDlsGetReturnFlagName(long int flag) - - int CVDlsSetLinearSolverB(void *cvode_mem, int which, - SUNLinearSolver LS, SUNMatrix A) - int CVDlsSetJacFnB(void *cvode_mem, int which, CVDlsJacFnB jacB) - int CVDlsSetJacFnBS(void *cvode_mem, int which, CVDlsJacFnBS jacBS) + ctypedef CVLsJacFn CVodeJacFn + ctypedef CVLsJacFnB CVodeJacFnB + ctypedef CVLsJacFnBS CVodeJacFnBS + + int CVodeSetJacFn(void *cvode_mem, CVodeJacFn jac) + int CVodeGetWorkSpace(void *cvode_mem, long int *lenrwLS, long int *leniwLS) + int CVodeGetNumJacEvals(void *cvode_mem, long int *njevals) + int CVodeGetNumRhsEvals(void *cvode_mem, long int *nfevalsLS) + int CVodeGetLastFlag(void *cvode_mem, long int *flag) + char *CVodeGetReturnFlagName(long int flag) + + int CVodeSetJacFnB(void *cvode_mem, int which, CVodeJacFnB jacB) + int CVodeSetJacFnBS(void *cvode_mem, int which, CVodeJacFnBS jacBS) cdef extern from "cvodes/cvodes_bandpre.h": int CVBandPrecInit(void *cvode_mem, sunindextype N, sunindextype mu, @@ -586,82 +582,80 @@ cdef extern from "cvodes/cvodes_diag.h": int CVDiagB(void *cvode_mem, int which) cdef extern from "cvodes/cvodes_bbdpre.h": - ctypedef int (*CVLocalFn)(sunindextype Nlocal, realtype t, N_Vector y, + ctypedef int (*CVLocalFn)(sunindextype Nlocal, sunrealtype t, N_Vector y, N_Vector g, void *user_data) - ctypedef int (*CVCommFn)(sunindextype Nlocal, realtype t, N_Vector y, + ctypedef int (*CVCommFn)(sunindextype Nlocal, sunrealtype t, N_Vector y, void *user_data) int CVBBDPrecInit(void *cvode_mem, sunindextype Nlocal, sunindextype mudq, sunindextype mldq, sunindextype mukeep, sunindextype mlkeep, - realtype dqrely, CVLocalFn gloc, CVCommFn cfn) + sunrealtype dqrely, CVLocalFn gloc, CVCommFn cfn) int CVBBDPrecReInit(void *cvode_mem, sunindextype mudq, sunindextype mldq, - realtype dqrely) + sunrealtype dqrely) int CVBBDPrecGetWorkSpace(void *cvode_mem, long int *lenrwBBDP, long int *leniwBBDP) int CVBBDPrecGetNumGfnEvals(void *cvode_mem, long int *ngevalsBBDP) - ctypedef int (*CVLocalFnB)(sunindextype NlocalB, realtype t, + ctypedef int (*CVLocalFnB)(sunindextype NlocalB, sunrealtype t, N_Vector y, N_Vector yB, N_Vector gB, void *user_dataB) - ctypedef int (*CVCommFnB)(sunindextype NlocalB, realtype t, + ctypedef int (*CVCommFnB)(sunindextype NlocalB, sunrealtype t, N_Vector y, N_Vector yB, void *user_dataB) int CVBBDPrecInitB(void *cvode_mem, int which, sunindextype NlocalB, sunindextype mudqB, sunindextype mldqB, sunindextype mukeepB, sunindextype mlkeepB, - realtype dqrelyB, CVLocalFnB glocB, CVCommFnB cfnB) + sunrealtype dqrelyB, CVLocalFnB glocB, CVCommFnB cfnB) int CVBBDPrecReInitB(void *cvode_mem, int which, sunindextype mudqB, sunindextype mldqB, - realtype dqrelyB) + sunrealtype dqrelyB) cdef extern from "cvodes/cvodes_spils.h": - ctypedef CVLsPrecSetupFn CVSpilsPrecSetupFn - ctypedef CVLsPrecSolveFn CVSpilsPrecSolveFn - ctypedef CVLsJacTimesSetupFn CVSpilsJacTimesSetupFn - ctypedef CVLsJacTimesVecFn CVSpilsJacTimesVecFn + ctypedef CVLsPrecSetupFn CVodePrecSetupFn + ctypedef CVLsPrecSolveFn CVodePrecSolveFn + ctypedef CVLsJacTimesSetupFn CVodeJacTimesSetupFn + ctypedef CVLsJacTimesVecFn CVodeJacTimesVecFn - ctypedef CVLsPrecSetupFnB CVSpilsPrecSetupFnB; - ctypedef CVLsPrecSetupFnBS CVSpilsPrecSetupFnBS; - ctypedef CVLsPrecSolveFnB CVSpilsPrecSolveFnB; - ctypedef CVLsPrecSolveFnBS CVSpilsPrecSolveFnBS; - ctypedef CVLsJacTimesSetupFnB CVSpilsJacTimesSetupFnB; - ctypedef CVLsJacTimesSetupFnBS CVSpilsJacTimesSetupFnBS; - ctypedef CVLsJacTimesVecFnB CVSpilsJacTimesVecFnB; - ctypedef CVLsJacTimesVecFnBS CVSpilsJacTimesVecFnBS; - - int CVSpilsSetLinearSolver(void *cvode_mem, SUNLinearSolver LS) - int CVSpilsSetEpsLin(void *cvode_mem, realtype eplifac) - int CVSpilsSetPreconditioner(void *cvode_mem, CVSpilsPrecSetupFn pset, - CVSpilsPrecSolveFn psolve) - int CVSpilsSetJacTimes(void *cvode_mem, CVSpilsJacTimesSetupFn jtsetup, - CVSpilsJacTimesVecFn jtimes) - - int CVSpilsGetWorkSpace(void *cvode_mem, long int *lenrwLS, long int *leniwLS) - int CVSpilsGetNumPrecEvals(void *cvode_mem, long int *npevals) - int CVSpilsGetNumPrecSolves(void *cvode_mem, long int *npsolves) - int CVSpilsGetNumLinIters(void *cvode_mem, long int *nliters) - int CVSpilsGetNumConvFails(void *cvode_mem, long int *nlcfails) - int CVSpilsGetNumJTSetupEvals(void *cvode_mem, long int *njtsetups) - int CVSpilsGetNumJtimesEvals(void *cvode_mem, long int *njvevals) - int CVSpilsGetNumRhsEvals(void *cvode_mem, long int *nfevalsLS) - int CVSpilsGetLastFlag(void *cvode_mem, long int *flag) - char *CVSpilsGetReturnFlagName(long int flag) - - int CVSpilsSetLinearSolverB(void *cvode_mem, int which, SUNLinearSolver LS) - int CVSpilsSetEpsLinB(void *cvode_mem, int which, realtype eplifacB) - int CVSpilsSetPreconditionerB(void *cvode_mem, int which, - CVSpilsPrecSetupFnB psetB, - CVSpilsPrecSolveFnB psolveB) - int CVSpilsSetPreconditionerBS(void *cvode_mem, int which, - CVSpilsPrecSetupFnBS psetBS, - CVSpilsPrecSolveFnBS psolveBS) - int CVSpilsSetJacTimesB(void *cvode_mem, int which, - CVSpilsJacTimesSetupFnB jtsetupB, - CVSpilsJacTimesVecFnB jtimesB) - int CVSpilsSetJacTimesBS(void *cvode_mem, int which, - CVSpilsJacTimesSetupFnBS jtsetupBS, - CVSpilsJacTimesVecFnBS jtimesBS) + ctypedef CVLsPrecSetupFnB CVodePrecSetupFnB; + ctypedef CVLsPrecSetupFnBS CVodePrecSetupFnBS; + ctypedef CVLsPrecSolveFnB CVodePrecSolveFnB; + ctypedef CVLsPrecSolveFnBS CVodePrecSolveFnBS; + ctypedef CVLsJacTimesSetupFnB CVodeJacTimesSetupFnB; + ctypedef CVLsJacTimesSetupFnBS CVodeJacTimesSetupFnBS; + ctypedef CVLsJacTimesVecFnB CVodeJacTimesVecFnB; + ctypedef CVLsJacTimesVecFnBS CVodeJacTimesVecFnBS; + + int CVodeSetEpsLin(void *cvode_mem, sunrealtype eplifac) + int CVodeSetPreconditioner(void *cvode_mem, CVodePrecSetupFn pset, + CVodePrecSolveFn psolve) + int CVodeSetJacTimes(void *cvode_mem, CVodeJacTimesSetupFn jtsetup, + CVodeJacTimesVecFn jtimes) + + int CVodeGetWorkSpace(void *cvode_mem, long int *lenrwLS, long int *leniwLS) + int CVodeGetNumPrecEvals(void *cvode_mem, long int *npevals) + int CVodeGetNumPrecSolves(void *cvode_mem, long int *npsolves) + int CVodeGetNumLinIters(void *cvode_mem, long int *nliters) + int CVodeGetNumConvFails(void *cvode_mem, long int *nlcfails) + int CVodeGetNumJTSetupEvals(void *cvode_mem, long int *njtsetups) + int CVodeGetNumJtimesEvals(void *cvode_mem, long int *njvevals) + int CVodeGetNumRhsEvals(void *cvode_mem, long int *nfevalsLS) + int CVodeGetLastFlag(void *cvode_mem, long int *flag) + char *CVodeGetReturnFlagName(long int flag) + + int CVodeSetEpsLinB(void *cvode_mem, int which, sunrealtype eplifacB) + int CVodeSetPreconditionerB(void *cvode_mem, int which, + CVodePrecSetupFnB psetB, + CVodePrecSolveFnB psolveB) + int CVodeSetPreconditionerBS(void *cvode_mem, int which, + CVodePrecSetupFnBS psetBS, + CVodePrecSolveFnBS psolveBS) + int CVodeSetJacTimesB(void *cvode_mem, int which, + CVodeJacTimesSetupFnB jtsetupB, + CVodeJacTimesVecFnB jtimesB) + int CVodeSetJacTimesBS(void *cvode_mem, int which, + CVodeJacTimesSetupFnBS jtsetupBS, + CVodeJacTimesVecFnBS jtimesBS) diff --git a/scikits/odes/sundials/c_ida.pxd b/scikits/odes/sundials/c_ida.pxd index e5b8c201..d4997969 100644 --- a/scikits/odes/sundials/c_ida.pxd +++ b/scikits/odes/sundials/c_ida.pxd @@ -52,11 +52,11 @@ cdef extern from "ida/ida.h": enum: IDA_UNRECOGNIZED_ERROR #-99 - ctypedef int (*IDAResFn)(realtype tt, N_Vector yy, N_Vector yp, + ctypedef int (*IDAResFn)(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector rr, void *user_data) - ctypedef int (*IDARootFn)(realtype t, N_Vector y, N_Vector yp, - realtype *gout, void *user_data) + ctypedef int (*IDARootFn)(sunrealtype t, N_Vector y, N_Vector yp, + sunrealtype *gout, void *user_data) ctypedef int (*IDAEwtFn)(N_Vector y, N_Vector ewt, void *user_data) @@ -64,23 +64,23 @@ cdef extern from "ida/ida.h": const char *function, char *msg, void *user_data) - void *IDACreate() + void *IDACreate(SUNContext sunctx) int IDAInit(void *ida_mem, IDAResFn res, - realtype t0, N_Vector yy0, N_Vector yp0) + sunrealtype t0, N_Vector yy0, N_Vector yp0) int IDAReInit(void *ida_mem, - realtype t0, N_Vector yy0, N_Vector yp0) - int IDASStolerances(void *ida_mem, realtype reltol, realtype abstol) - int IDASVtolerances(void *ida_mem, realtype reltol, N_Vector abstol) + sunrealtype t0, N_Vector yy0, N_Vector yp0) + int IDASStolerances(void *ida_mem, sunrealtype reltol, sunrealtype abstol) + int IDASVtolerances(void *ida_mem, sunrealtype reltol, N_Vector abstol) int IDAWFtolerances(void *ida_mem, IDAEwtFn efun) - int IDACalcIC(void *ida_mem, int icopt, realtype tout1) + int IDACalcIC(void *ida_mem, int icopt, sunrealtype tout1) - int IDASetNonlinConvCoefIC(void *ida_mem, realtype epiccon) + int IDASetNonlinConvCoefIC(void *ida_mem, sunrealtype epiccon) int IDASetMaxNumStepsIC(void *ida_mem, int maxnh) int IDASetMaxNumJacsIC(void *ida_mem, int maxnj) int IDASetMaxNumItersIC(void *ida_mem, int maxnit) - int IDASetLineSearchOffIC(void *ida_mem, booleantype lsoff) - int IDASetStepToleranceIC(void *ida_mem, realtype steptol) + int IDASetLineSearchOffIC(void *ida_mem, sunbooleantype lsoff) + int IDASetStepToleranceIC(void *ida_mem, sunrealtype steptol) int IDASetMaxBacksIC(void *ida_mem, int maxbacks) int IDASetErrHandlerFn(void *ida_mem, IDAErrHandlerFn ehfun, void *eh_data) @@ -88,14 +88,14 @@ cdef extern from "ida/ida.h": int IDASetUserData(void *ida_mem, void *user_data) int IDASetMaxOrd(void *ida_mem, int maxord) int IDASetMaxNumSteps(void *ida_mem, long int mxsteps) - int IDASetInitStep(void *ida_mem, realtype hin) - int IDASetMaxStep(void *ida_mem, realtype hmax) - int IDASetStopTime(void *ida_mem, realtype tstop) - int IDASetNonlinConvCoef(void *ida_mem, realtype epcon) + int IDASetInitStep(void *ida_mem, sunrealtype hin) + int IDASetMaxStep(void *ida_mem, sunrealtype hmax) + int IDASetStopTime(void *ida_mem, sunrealtype tstop) + int IDASetNonlinConvCoef(void *ida_mem, sunrealtype epcon) int IDASetMaxErrTestFails(void *ida_mem, int maxnef) int IDASetMaxNonlinIters(void *ida_mem, int maxcor) int IDASetMaxConvFails(void *ida_mem, int maxncf) - int IDASetSuppressAlg(void *ida_mem, booleantype suppressalg) + int IDASetSuppressAlg(void *ida_mem, sunbooleantype suppressalg) int IDASetId(void *ida_mem, N_Vector id) int IDASetConstraints(void *ida_mem, N_Vector constraints) @@ -105,13 +105,13 @@ cdef extern from "ida/ida.h": int IDASetRootDirection(void *ida_mem, int *rootdir) int IDASetNoInactiveRootWarn(void *ida_mem) - int IDASolve(void *ida_mem, realtype tout, realtype *tret, + int IDASolve(void *ida_mem, sunrealtype tout, sunrealtype *tret, N_Vector yret, N_Vector ypret, int itask) int IDAComputeY(void *ida_mem, N_Vector ycor, N_Vector y) int IDAComputeYp(void *ida_mem, N_Vector ycor, N_Vector yp) - int IDAGetDky(void *ida_mem, realtype t, int k, N_Vector dky) + int IDAGetDky(void *ida_mem, sunrealtype t, int k, N_Vector dky) int IDAGetWorkSpace(void *ida_mem, long int *lenrw, long int *leniw) int IDAGetNumSteps(void *ida_mem, long int *nsteps) @@ -122,14 +122,14 @@ cdef extern from "ida/ida.h": int IDAGetConsistentIC(void *ida_mem, N_Vector yy0_mod, N_Vector yp0_mod) int IDAGetLastOrder(void *ida_mem, int *klast) int IDAGetCurrentOrder(void *ida_mem, int *kcur) - int IDAGetCurrentCj(void *ida_mem, realtype *cj) + int IDAGetCurrentCj(void *ida_mem, sunrealtype *cj) int IDAGetCurrentY(void *ida_mem, N_Vector *ycur) int IDAGetCurrentYp(void *ida_mem, N_Vector *ypcur) - int IDAGetActualInitStep(void *ida_mem, realtype *hinused) - int IDAGetLastStep(void *ida_mem, realtype *hlast) - int IDAGetCurrentStep(void *ida_mem, realtype *hcur) - int IDAGetCurrentTime(void *ida_mem, realtype *tcur) - int IDAGetTolScaleFactor(void *ida_mem, realtype *tolsfact) + int IDAGetActualInitStep(void *ida_mem, sunrealtype *hinused) + int IDAGetLastStep(void *ida_mem, sunrealtype *hlast) + int IDAGetCurrentStep(void *ida_mem, sunrealtype *hcur) + int IDAGetCurrentTime(void *ida_mem, sunrealtype *tcur) + int IDAGetTolScaleFactor(void *ida_mem, sunrealtype *tolsfact) int IDAGetErrWeights(void *ida_mem, N_Vector eweight) int IDAGetEstLocalErrors(void *ida_mem, N_Vector ele) int IDAGetNumGEvals(void *ida_mem, long int *ngevals) @@ -137,8 +137,8 @@ cdef extern from "ida/ida.h": int IDAGetIntegratorStats(void *ida_mem, long int *nsteps, long int *nrevals, long int *nlinsetups, long int *netfails, int *qlast, int *qcur, - realtype *hinused, realtype *hlast, - realtype *hcur, realtype *tcur) + sunrealtype *hinused, sunrealtype *hlast, + sunrealtype *hcur, sunrealtype *tcur) int IDAGetNumNonlinSolvIters(void *ida_mem, long int *nniters) int IDAGetNumNonlinSolvConvFails(void *ida_mem, long int *nncfails) int IDAGetNonlinSolvStats(void *ida_mem, long int *nniters, @@ -159,29 +159,29 @@ cdef extern from "ida/ida_ls.h": enum: IDALS_SUNMAT_FAIL #-8 enum: IDALS_SUNLS_FAIL #-9 - ctypedef int (*IDALsJacFn)(realtype t, realtype c_j, N_Vector y, + ctypedef int (*IDALsJacFn)(sunrealtype t, sunrealtype c_j, N_Vector y, N_Vector yp, N_Vector r, SUNMatrix Jac, void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) - ctypedef int (*IDALsPrecSetupFn)(realtype tt, N_Vector yy, + ctypedef int (*IDALsPrecSetupFn)(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector rr, - realtype c_j, void *user_data) + sunrealtype c_j, void *user_data) - ctypedef int (*IDALsPrecSolveFn)(realtype tt, N_Vector yy, + ctypedef int (*IDALsPrecSolveFn)(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector rr, N_Vector rvec, N_Vector zvec, - realtype c_j, realtype delta, + sunrealtype c_j, sunrealtype delta, void *user_data) - ctypedef int (*IDALsJacTimesSetupFn)(realtype tt, N_Vector yy, + ctypedef int (*IDALsJacTimesSetupFn)(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector rr, - realtype c_j, void *user_data) except? -1 + sunrealtype c_j, void *user_data) except? -1 - ctypedef int (*IDALsJacTimesVecFn)(realtype tt, N_Vector yy, + ctypedef int (*IDALsJacTimesVecFn)(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector rr, N_Vector v, N_Vector Jv, - realtype c_j, void *user_data, + sunrealtype c_j, void *user_data, N_Vector tmp1, N_Vector tmp2) except? -1 int IDASetLinearSolver(void *ida_mem, SUNLinearSolver LS, SUNMatrix A) @@ -191,8 +191,8 @@ cdef extern from "ida/ida_ls.h": IDALsPrecSolveFn psolve) int IDASetJacTimes(void *ida_mem, IDALsJacTimesSetupFn jtsetup, IDALsJacTimesVecFn jtimes) - int IDASetEpsLin(void *ida_mem, realtype eplifac) - int IDASetIncrementFactor(void *ida_mem, realtype dqincfac) + int IDASetEpsLin(void *ida_mem, sunrealtype eplifac) + int IDASetIncrementFactor(void *ida_mem, sunrealtype dqincfac) int IDAGetLinWorkSpace(void *ida_mem, long int *lenrwLS, long int *leniwLS) int IDAGetNumJacEvals(void *ida_mem, long int *njevals) @@ -208,60 +208,58 @@ cdef extern from "ida/ida_ls.h": cdef extern from "ida/ida_direct.h": - ctypedef IDALsJacFn IDADlsJacFn + ctypedef IDALsJacFn IDAJacFn - int IDADlsSetLinearSolver(void *ida_mem, SUNLinearSolver LS, SUNMatrix A) - int IDADlsSetJacFn(void *ida_mem, IDADlsJacFn jac) + int IDASetJacFn(void *ida_mem, IDAJacFn jac) - int IDADlsGetWorkSpace(void *ida_mem, long int *lenrwLS, long int *leniwLS) - int IDADlsGetNumJacEvals(void *ida_mem, long int *njevals) - int IDADlsGetNumResEvals(void *ida_mem, long int *nfevalsLS) - int IDADlsGetLastFlag(void *ida_mem, long int *flag) - char *IDADlsGetReturnFlagName(long int flag) + int IDAGetWorkSpace(void *ida_mem, long int *lenrwLS, long int *leniwLS) + int IDAGetNumJacEvals(void *ida_mem, long int *njevals) + int IDAGetNumResEvals(void *ida_mem, long int *nfevalsLS) + int IDAGetLastFlag(void *ida_mem, long int *flag) + char *IDAGetReturnFlagName(long int flag) cdef extern from "ida/ida_spils.h": - ctypedef IDALsPrecSetupFn IDASpilsPrecSetupFn; - ctypedef IDALsPrecSolveFn IDASpilsPrecSolveFn; - ctypedef IDALsJacTimesSetupFn IDASpilsJacTimesSetupFn; - ctypedef IDALsJacTimesVecFn IDASpilsJacTimesVecFn; - - int IDASpilsSetLinearSolver(void *ida_mem, SUNLinearSolver LS) - int IDASpilsSetPreconditioner(void *ida_mem, - IDASpilsPrecSetupFn pset, - IDASpilsPrecSolveFn psolve) - int IDASpilsSetJacTimes(void *ida_mem, IDASpilsJacTimesSetupFn jtsetup, - IDASpilsJacTimesVecFn jtimes) - int IDASpilsSetEpsLin(void *ida_mem, realtype eplifac) - int IDASpilsSetIncrementFactor(void *ida_mem, realtype dqincfac) - int IDASpilsGetWorkSpace(void *ida_mem, long int *lenrwLS, long int *leniwLS) - int IDASpilsGetNumPrecEvals(void *ida_mem, long int *npevals) - int IDASpilsGetNumPrecSolves(void *ida_mem, long int *npsolves) - int IDASpilsGetNumLinIters(void *ida_mem, long int *nliters) - int IDASpilsGetNumConvFails(void *ida_mem, long int *nlcfails) - int IDASpilsGetNumJTSetupEvals(void *ida_mem, long int *njtsetups) - int IDASpilsGetNumJtimesEvals(void *ida_mem, long int *njvevals) - int IDASpilsGetNumResEvals(void *ida_mem, long int *nrevalsLS) - int IDASpilsGetLastFlag(void *ida_mem, long int *flag) - char *IDASpilsGetReturnFlagName(long int flag) + ctypedef IDALsPrecSetupFn IDAPrecSetupFn; + ctypedef IDALsPrecSolveFn IDAPrecSolveFn; + ctypedef IDALsJacTimesSetupFn IDAJacTimesSetupFn; + ctypedef IDALsJacTimesVecFn IDAJacTimesVecFn; + + int IDASetPreconditioner(void *ida_mem, + IDAPrecSetupFn pset, + IDAPrecSolveFn psolve) + int IDASetJacTimes(void *ida_mem, IDAJacTimesSetupFn jtsetup, + IDAJacTimesVecFn jtimes) + int IDASetEpsLin(void *ida_mem, sunrealtype eplifac) + int IDASetIncrementFactor(void *ida_mem, sunrealtype dqincfac) + int IDAGetWorkSpace(void *ida_mem, long int *lenrwLS, long int *leniwLS) + int IDAGetNumPrecEvals(void *ida_mem, long int *npevals) + int IDAGetNumPrecSolves(void *ida_mem, long int *npsolves) + int IDAGetNumLinIters(void *ida_mem, long int *nliters) + int IDAGetNumConvFails(void *ida_mem, long int *nlcfails) + int IDAGetNumJTSetupEvals(void *ida_mem, long int *njtsetups) + int IDAGetNumJtimesEvals(void *ida_mem, long int *njvevals) + int IDAGetNumResEvals(void *ida_mem, long int *nrevalsLS) + int IDAGetLastFlag(void *ida_mem, long int *flag) + char *IDAGetReturnFlagName(long int flag) cdef extern from "ida/ida_bbdpre.h": - ctypedef int (*IDABBDLocalFn)(sunindextype Nlocal, realtype tt, + ctypedef int (*IDABBDLocalFn)(sunindextype Nlocal, sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector gval, void *user_data) - ctypedef int (*IDABBDCommFn)(sunindextype Nlocal, realtype tt, + ctypedef int (*IDABBDCommFn)(sunindextype Nlocal, sunrealtype tt, N_Vector yy, N_Vector yp, void *user_data) int IDABBDPrecInit(void *ida_mem, sunindextype Nlocal, sunindextype mudq, sunindextype mldq, sunindextype mukeep, sunindextype mlkeep, - realtype dq_rel_yy, + sunrealtype dq_rel_yy, IDABBDLocalFn Gres, IDABBDCommFn Gcomm) int IDABBDPrecReInit(void *ida_mem, sunindextype mudq, sunindextype mldq, - realtype dq_rel_yy) + sunrealtype dq_rel_yy) int IDABBDPrecGetWorkSpace(void *ida_mem, long int *lenrwBBDP, long int *leniwBBDP) int IDABBDPrecGetNumGfnEvals(void *ida_mem, long int *ngevalsBBDP) diff --git a/scikits/odes/sundials/c_idas.pxd b/scikits/odes/sundials/c_idas.pxd index ccdedab3..baf3e941 100644 --- a/scikits/odes/sundials/c_idas.pxd +++ b/scikits/odes/sundials/c_idas.pxd @@ -88,11 +88,11 @@ cdef extern from "idas/idas.h": enum: IDA_GETY_BADT # -107 - ctypedef int (*IDAResFn)(realtype tt, N_Vector yy, N_Vector yp, + ctypedef int (*IDAResFn)(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector rr, void *user_data) - ctypedef int (*IDARootFn)(realtype t, N_Vector y, N_Vector yp, - realtype *gout, void *user_data) + ctypedef int (*IDARootFn)(sunrealtype t, N_Vector y, N_Vector yp, + sunrealtype *gout, void *user_data) ctypedef int (*IDAEwtFn)(N_Vector y, N_Vector ewt, void *user_data) @@ -101,16 +101,16 @@ cdef extern from "idas/idas.h": void *user_data) - ctypedef int (*IDAQuadRhsFn)(realtype tres, N_Vector yy, N_Vector yp, + ctypedef int (*IDAQuadRhsFn)(sunrealtype tres, N_Vector yy, N_Vector yp, N_Vector rrQ, void *user_data) - ctypedef int (*IDASensResFn)(int Ns, realtype t, + ctypedef int (*IDASensResFn)(int Ns, sunrealtype t, N_Vector yy, N_Vector yp, N_Vector resval, N_Vector *yyS, N_Vector *ypS, N_Vector *resvalS, void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) - ctypedef int (*IDAQuadSensRhsFn)(int Ns, realtype t, + ctypedef int (*IDAQuadSensRhsFn)(int Ns, sunrealtype t, N_Vector yy, N_Vector yp, N_Vector *yyS, N_Vector *ypS, N_Vector rrQ, N_Vector *rhsvalQS, @@ -118,45 +118,45 @@ cdef extern from "idas/idas.h": N_Vector yytmp, N_Vector yptmp, N_Vector tmpQS) - ctypedef int (*IDAResFnB)(realtype tt, + ctypedef int (*IDAResFnB)(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector yyB, N_Vector ypB, N_Vector rrB, void *user_dataB) - ctypedef int (*IDAResFnBS)(realtype t, + ctypedef int (*IDAResFnBS)(sunrealtype t, N_Vector yy, N_Vector yp, N_Vector *yyS, N_Vector *ypS, N_Vector yyB, N_Vector ypB, N_Vector rrBS, void *user_dataB) - ctypedef int (*IDAQuadRhsFnB)(realtype tt, + ctypedef int (*IDAQuadRhsFnB)(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector yyB, N_Vector ypB, N_Vector rhsvalBQ, void *user_dataB) - ctypedef int (*IDAQuadRhsFnBS)(realtype t, + ctypedef int (*IDAQuadRhsFnBS)(sunrealtype t, N_Vector yy, N_Vector yp, N_Vector *yyS, N_Vector *ypS, N_Vector yyB, N_Vector ypB, N_Vector rhsvalBQS, void *user_dataB) - void *IDACreate() + void *IDACreate(SUNContext sunctx) int IDAInit(void *ida_mem, IDAResFn res, - realtype t0, N_Vector yy0, N_Vector yp0) + sunrealtype t0, N_Vector yy0, N_Vector yp0) int IDAReInit(void *ida_mem, - realtype t0, N_Vector yy0, N_Vector yp0) - int IDASStolerances(void *ida_mem, realtype reltol, realtype abstol) - int IDASVtolerances(void *ida_mem, realtype reltol, N_Vector abstol) + sunrealtype t0, N_Vector yy0, N_Vector yp0) + int IDASStolerances(void *ida_mem, sunrealtype reltol, sunrealtype abstol) + int IDASVtolerances(void *ida_mem, sunrealtype reltol, N_Vector abstol) int IDAWFtolerances(void *ida_mem, IDAEwtFn efun) - int IDACalcIC(void *ida_mem, int icopt, realtype tout1) + int IDACalcIC(void *ida_mem, int icopt, sunrealtype tout1) - int IDASetNonlinConvCoefIC(void *ida_mem, realtype epiccon) + int IDASetNonlinConvCoefIC(void *ida_mem, sunrealtype epiccon) int IDASetMaxNumStepsIC(void *ida_mem, int maxnh) int IDASetMaxNumJacsIC(void *ida_mem, int maxnj) int IDASetMaxNumItersIC(void *ida_mem, int maxnit) - int IDASetLineSearchOffIC(void *ida_mem, booleantype lsoff) - int IDASetStepToleranceIC(void *ida_mem, realtype steptol) + int IDASetLineSearchOffIC(void *ida_mem, sunbooleantype lsoff) + int IDASetStepToleranceIC(void *ida_mem, sunrealtype steptol) int IDASetMaxBacksIC(void *ida_mem, int maxbacks) int IDASetErrHandlerFn(void *ida_mem, IDAErrHandlerFn ehfun, void *eh_data) @@ -164,14 +164,14 @@ cdef extern from "idas/idas.h": int IDASetUserData(void *ida_mem, void *user_data) int IDASetMaxOrd(void *ida_mem, int maxord) int IDASetMaxNumSteps(void *ida_mem, long int mxsteps) - int IDASetInitStep(void *ida_mem, realtype hin) - int IDASetMaxStep(void *ida_mem, realtype hmax) - int IDASetStopTime(void *ida_mem, realtype tstop) - int IDASetNonlinConvCoef(void *ida_mem, realtype epcon) + int IDASetInitStep(void *ida_mem, sunrealtype hin) + int IDASetMaxStep(void *ida_mem, sunrealtype hmax) + int IDASetStopTime(void *ida_mem, sunrealtype tstop) + int IDASetNonlinConvCoef(void *ida_mem, sunrealtype epcon) int IDASetMaxErrTestFails(void *ida_mem, int maxnef) int IDASetMaxNonlinIters(void *ida_mem, int maxcor) int IDASetMaxConvFails(void *ida_mem, int maxncf) - int IDASetSuppressAlg(void *ida_mem, booleantype suppressalg) + int IDASetSuppressAlg(void *ida_mem, sunbooleantype suppressalg) int IDASetId(void *ida_mem, N_Vector id) int IDASetConstraints(void *ida_mem, N_Vector constraints) @@ -181,13 +181,13 @@ cdef extern from "idas/idas.h": int IDASetRootDirection(void *ida_mem, int *rootdir) int IDASetNoInactiveRootWarn(void *ida_mem) - int IDASolve(void *ida_mem, realtype tout, realtype *tret, + int IDASolve(void *ida_mem, sunrealtype tout, sunrealtype *tret, N_Vector yret, N_Vector ypret, int itask) int IDAComputeY(void *ida_mem, N_Vector ycor, N_Vector y) int IDAComputeYp(void *ida_mem, N_Vector ycor, N_Vector yp) - int IDAGetDky(void *ida_mem, realtype t, int k, N_Vector dky) + int IDAGetDky(void *ida_mem, sunrealtype t, int k, N_Vector dky) int IDAGetWorkSpace(void *ida_mem, long int *lenrw, long int *leniw) int IDAGetNumSteps(void *ida_mem, long int *nsteps) @@ -198,14 +198,14 @@ cdef extern from "idas/idas.h": int IDAGetConsistentIC(void *ida_mem, N_Vector yy0_mod, N_Vector yp0_mod) int IDAGetLastOrder(void *ida_mem, int *klast) int IDAGetCurrentOrder(void *ida_mem, int *kcur) - int IDAGetCurrentCj(void *ida_mem, realtype *cj) + int IDAGetCurrentCj(void *ida_mem, sunrealtype *cj) int IDAGetCurrentY(void *ida_mem, N_Vector *ycur) int IDAGetCurrentYp(void *ida_mem, N_Vector *ypcur) - int IDAGetActualInitStep(void *ida_mem, realtype *hinused) - int IDAGetLastStep(void *ida_mem, realtype *hlast) - int IDAGetCurrentStep(void *ida_mem, realtype *hcur) - int IDAGetCurrentTime(void *ida_mem, realtype *tcur) - int IDAGetTolScaleFactor(void *ida_mem, realtype *tolsfact) + int IDAGetActualInitStep(void *ida_mem, sunrealtype *hinused) + int IDAGetLastStep(void *ida_mem, sunrealtype *hlast) + int IDAGetCurrentStep(void *ida_mem, sunrealtype *hcur) + int IDAGetCurrentTime(void *ida_mem, sunrealtype *tcur) + int IDAGetTolScaleFactor(void *ida_mem, sunrealtype *tolsfact) int IDAGetErrWeights(void *ida_mem, N_Vector eweight) int IDAGetEstLocalErrors(void *ida_mem, N_Vector ele) int IDAGetNumGEvals(void *ida_mem, long int *ngevals) @@ -213,8 +213,8 @@ cdef extern from "idas/idas.h": int IDAGetIntegratorStats(void *ida_mem, long int *nsteps, long int *nrevals, long int *nlinsetups, long int *netfails, int *qlast, int *qcur, - realtype *hinused, realtype *hlast, - realtype *hcur, realtype *tcur) + sunrealtype *hinused, sunrealtype *hlast, + sunrealtype *hcur, sunrealtype *tcur) int IDAGetNumNonlinSolvIters(void *ida_mem, long int *nniters) int IDAGetNumNonlinSolvConvFails(void *ida_mem, long int *nncfails) int IDAGetNonlinSolvStats(void *ida_mem, long int *nniters, @@ -228,13 +228,13 @@ cdef extern from "idas/idas.h": int IDAQuadInit(void *ida_mem, IDAQuadRhsFn rhsQ, N_Vector yQ0) int IDAQuadReInit(void *ida_mem, N_Vector yQ0) - int IDAQuadSStolerances(void *ida_mem, realtype reltolQ, realtype abstolQ) - int IDAQuadSVtolerances(void *ida_mem, realtype reltolQ, N_Vector abstolQ) + int IDAQuadSStolerances(void *ida_mem, sunrealtype reltolQ, sunrealtype abstolQ) + int IDAQuadSVtolerances(void *ida_mem, sunrealtype reltolQ, N_Vector abstolQ) - int IDASetQuadErrCon(void *ida_mem, booleantype errconQ) + int IDASetQuadErrCon(void *ida_mem, sunbooleantype errconQ) - int IDAGetQuad(void *ida_mem, realtype *t, N_Vector yQout) - int IDAGetQuadDky(void *ida_mem, realtype t, int k, N_Vector dky) + int IDAGetQuad(void *ida_mem, sunrealtype *t, N_Vector yQout) + int IDAGetQuadDky(void *ida_mem, sunrealtype t, int k, N_Vector dky) int IDAGetQuadNumRhsEvals(void *ida_mem, long int *nrhsQevals) int IDAGetQuadNumErrTestFails(void *ida_mem, long int *nQetfails) @@ -248,27 +248,27 @@ cdef extern from "idas/idas.h": IDASensResFn resS, N_Vector *yS0, N_Vector *ypS0) int IDASensReInit(void *ida_mem, int ism, N_Vector *yS0, N_Vector *ypS0) - int IDASensSStolerances(void *ida_mem, realtype reltolS, realtype *abstolS) - int IDASensSVtolerances(void *ida_mem, realtype reltolS, N_Vector *abstolS) + int IDASensSStolerances(void *ida_mem, sunrealtype reltolS, sunrealtype *abstolS) + int IDASensSVtolerances(void *ida_mem, sunrealtype reltolS, N_Vector *abstolS) int IDASensEEtolerances(void *ida_mem) int IDAGetSensConsistentIC(void *ida_mem, N_Vector *yyS0, N_Vector *ypS0) - int IDASetSensDQMethod(void *ida_mem, int DQtype, realtype DQrhomax) - int IDASetSensErrCon(void *ida_mem, booleantype errconS) + int IDASetSensDQMethod(void *ida_mem, int DQtype, sunrealtype DQrhomax) + int IDASetSensErrCon(void *ida_mem, sunbooleantype errconS) int IDASetSensMaxNonlinIters(void *ida_mem, int maxcorS) - int IDASetSensParams(void *ida_mem, realtype *p, realtype *pbar, int *plist) + int IDASetSensParams(void *ida_mem, sunrealtype *p, sunrealtype *pbar, int *plist) int IDASetNonlinearSolverSensSim(void *ida_mem, SUNNonlinearSolver NLS) int IDASetNonlinearSolverSensStg(void *ida_mem, SUNNonlinearSolver NLS) int IDASensToggleOff(void *ida_mem) - int IDAGetSens(void *ida_mem, realtype *tret, N_Vector *yySout) - int IDAGetSens1(void *ida_mem, realtype *tret, int iss, N_Vector yySret) # rename is to iss, is protected in python + int IDAGetSens(void *ida_mem, sunrealtype *tret, N_Vector *yySout) + int IDAGetSens1(void *ida_mem, sunrealtype *tret, int iss, N_Vector yySret) # rename is to iss, is protected in python - int IDAGetSensDky(void *ida_mem, realtype t, int k, N_Vector *dkyS) - int IDAGetSensDky1(void *ida_mem, realtype t, int k, int iss, N_Vector dkyS) # rename is to iss, is protected in python + int IDAGetSensDky(void *ida_mem, sunrealtype t, int k, N_Vector *dkyS) + int IDAGetSensDky1(void *ida_mem, sunrealtype t, int k, int iss, N_Vector dkyS) # rename is to iss, is protected in python int IDAGetSensNumResEvals(void *ida_mem, long int *nresSevals) int IDAGetNumResEvalsSens(void *ida_mem, long int *nresevalsS) @@ -291,18 +291,18 @@ cdef extern from "idas/idas.h": N_Vector *yQS0) int IDAQuadSensReInit(void *ida_mem, N_Vector *yQS0) - int IDAQuadSensSStolerances(void *ida_mem, realtype reltolQS, - realtype *abstolQS) - int IDAQuadSensSVtolerances(void *ida_mem, realtype reltolQS, + int IDAQuadSensSStolerances(void *ida_mem, sunrealtype reltolQS, + sunrealtype *abstolQS) + int IDAQuadSensSVtolerances(void *ida_mem, sunrealtype reltolQS, N_Vector *abstolQS) int IDAQuadSensEEtolerances(void *ida_mem) - int IDASetQuadSensErrCon(void *ida_mem, booleantype errconQS) + int IDASetQuadSensErrCon(void *ida_mem, sunbooleantype errconQS) - int IDAGetQuadSens(void *ida_mem, realtype *tret, N_Vector *yyQSout) - int IDAGetQuadSens1(void *ida_mem, realtype *tret, int iss, N_Vector yyQSret) # rename is to iss, is protected in python - int IDAGetQuadSensDky(void *ida_mem, realtype t, int k, N_Vector *dkyQS) - int IDAGetQuadSensDky1(void *ida_mem, realtype t, int k, int iss, + int IDAGetQuadSens(void *ida_mem, sunrealtype *tret, N_Vector *yyQSout) + int IDAGetQuadSens1(void *ida_mem, sunrealtype *tret, int iss, N_Vector yyQSret) # rename is to iss, is protected in python + int IDAGetQuadSensDky(void *ida_mem, sunrealtype t, int k, N_Vector *dkyQS) + int IDAGetQuadSensDky1(void *ida_mem, sunrealtype t, int k, int iss, N_Vector dkyQS) # rename is to iss, is protected in python int IDAGetQuadSensNumRhsEvals(void *ida_mem, long int *nrhsQSevals) @@ -320,79 +320,79 @@ cdef extern from "idas/idas.h": int IDACreateB(void *ida_mem, int *which) int IDAInitB(void *ida_mem, int which, IDAResFnB resB, - realtype tB0, N_Vector yyB0, N_Vector ypB0) + sunrealtype tB0, N_Vector yyB0, N_Vector ypB0) int IDAInitBS(void *ida_mem, int which, IDAResFnBS resS, - realtype tB0, N_Vector yyB0, N_Vector ypB0) + sunrealtype tB0, N_Vector yyB0, N_Vector ypB0) int IDAReInitB(void *ida_mem, int which, - realtype tB0, N_Vector yyB0, N_Vector ypB0) + sunrealtype tB0, N_Vector yyB0, N_Vector ypB0) int IDASStolerancesB(void *ida_mem, int which, - realtype relTolB, realtype absTolB) + sunrealtype relTolB, sunrealtype absTolB) int IDASVtolerancesB(void *ida_mem, int which, - realtype relTolB, N_Vector absTolB) + sunrealtype relTolB, N_Vector absTolB) int IDAQuadInitB(void *ida_mem, int which, IDAQuadRhsFnB rhsQB, N_Vector yQB0) int IDAQuadInitBS(void *ida_mem, int which, IDAQuadRhsFnBS rhsQS, N_Vector yQB0) int IDAQuadReInitB(void *ida_mem, int which, N_Vector yQB0) int IDAQuadSStolerancesB(void *ida_mem, int which, - realtype reltolQB, realtype abstolQB) + sunrealtype reltolQB, sunrealtype abstolQB) int IDAQuadSVtolerancesB(void *ida_mem, int which, - realtype reltolQB, N_Vector abstolQB) + sunrealtype reltolQB, N_Vector abstolQB) - int IDACalcICB (void *ida_mem, int which, realtype tout1, + int IDACalcICB (void *ida_mem, int which, sunrealtype tout1, N_Vector yy0, N_Vector yp0) - int IDACalcICBS(void *ida_mem, int which, realtype tout1, + int IDACalcICBS(void *ida_mem, int which, sunrealtype tout1, N_Vector yy0, N_Vector yp0, N_Vector *yyS0, N_Vector *ypS0) - int IDASolveF(void *ida_mem, realtype tout, realtype *tret, + int IDASolveF(void *ida_mem, sunrealtype tout, sunrealtype *tret, N_Vector yret, N_Vector ypret, int itask, int *ncheckPtr) - int IDASolveB(void *ida_mem, realtype tBout, int itaskB) + int IDASolveB(void *ida_mem, sunrealtype tBout, int itaskB) int IDAAdjSetNoSensi(void *ida_mem) int IDASetUserDataB(void *ida_mem, int which, void *user_dataB) int IDASetMaxOrdB(void *ida_mem, int which, int maxordB) int IDASetMaxNumStepsB(void *ida_mem, int which, long int mxstepsB) - int IDASetInitStepB(void *ida_mem, int which, realtype hinB) - int IDASetMaxStepB(void *ida_mem, int which, realtype hmaxB) - int IDASetSuppressAlgB(void *ida_mem, int which, booleantype suppressalgB) + int IDASetInitStepB(void *ida_mem, int which, sunrealtype hinB) + int IDASetMaxStepB(void *ida_mem, int which, sunrealtype hmaxB) + int IDASetSuppressAlgB(void *ida_mem, int which, sunbooleantype suppressalgB) int IDASetIdB(void *ida_mem, int which, N_Vector idB) int IDASetConstraintsB(void *ida_mem, int which, N_Vector constraintsB) int IDASetQuadErrConB(void *ida_mem, int which, int errconQB) int IDASetNonlinearSolverB(void *ida_mem, int which, SUNNonlinearSolver NLS) - int IDAGetB(void* ida_mem, int which, realtype *tret, + int IDAGetB(void* ida_mem, int which, sunrealtype *tret, N_Vector yy, N_Vector yp) - int IDAGetQuadB(void *ida_mem, int which, realtype *tret, N_Vector qB) + int IDAGetQuadB(void *ida_mem, int which, sunrealtype *tret, N_Vector qB) void *IDAGetAdjIDABmem(void *ida_mem, int which) int IDAGetConsistentICB(void *ida_mem, int which, N_Vector yyB0, N_Vector ypB0) - int IDAGetAdjY(void *ida_mem, realtype t, N_Vector yy, N_Vector yp) + int IDAGetAdjY(void *ida_mem, sunrealtype t, N_Vector yy, N_Vector yp) struct _IDAadjCheckPointRec: void *my_addr void *next_addr - realtype t0 - realtype t1 + sunrealtype t0 + sunrealtype t1 long int nstep int order - realtype step + sunrealtype step ctypedef _IDAadjCheckPointRec IDAadjCheckPointRec int IDAGetAdjCheckPointsInfo(void *ida_mem, IDAadjCheckPointRec *ckpnt) int IDAGetAdjDataPointHermite(void *ida_mem, int which, - realtype *t, N_Vector yy, N_Vector yd) + sunrealtype *t, N_Vector yy, N_Vector yd) int IDAGetAdjDataPointPolynomial(void *ida_mem, int which, - realtype *t, int *order, N_Vector y) + sunrealtype *t, int *order, N_Vector y) int IDAGetAdjCurrentCheckPoint(void *ida_mem, void **addr) @@ -412,29 +412,29 @@ cdef extern from "idas/idas_ls.h": enum: IDALS_NO_ADJ # -101 enum: IDALS_LMEMB_NULL # -102 - ctypedef int (*IDALsJacFn)(realtype t, realtype c_j, N_Vector y, + ctypedef int (*IDALsJacFn)(sunrealtype t, sunrealtype c_j, N_Vector y, N_Vector yp, N_Vector r, SUNMatrix Jac, void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) - ctypedef int (*IDALsPrecSetupFn)(realtype tt, N_Vector yy, + ctypedef int (*IDALsPrecSetupFn)(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector rr, - realtype c_j, void *user_data) + sunrealtype c_j, void *user_data) - ctypedef int (*IDALsPrecSolveFn)(realtype tt, N_Vector yy, + ctypedef int (*IDALsPrecSolveFn)(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector rr, N_Vector rvec, N_Vector zvec, - realtype c_j, realtype delta, + sunrealtype c_j, sunrealtype delta, void *user_data) - ctypedef int (*IDALsJacTimesSetupFn)(realtype tt, N_Vector yy, + ctypedef int (*IDALsJacTimesSetupFn)(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector rr, - realtype c_j, void *user_data) except? -1 + sunrealtype c_j, void *user_data) except? -1 - ctypedef int (*IDALsJacTimesVecFn)(realtype tt, N_Vector yy, + ctypedef int (*IDALsJacTimesVecFn)(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector rr, N_Vector v, N_Vector Jv, - realtype c_j, void *user_data, + sunrealtype c_j, void *user_data, N_Vector tmp1, N_Vector tmp2) except? -1 int IDASetLinearSolver(void *ida_mem, SUNLinearSolver LS, SUNMatrix A) @@ -444,8 +444,8 @@ cdef extern from "idas/idas_ls.h": IDALsPrecSolveFn psolve) int IDASetJacTimes(void *ida_mem, IDALsJacTimesSetupFn jtsetup, IDALsJacTimesVecFn jtimes) - int IDASetEpsLin(void *ida_mem, realtype eplifac) - int IDASetIncrementFactor(void *ida_mem, realtype dqincfac) + int IDASetEpsLin(void *ida_mem, sunrealtype eplifac) + int IDASetIncrementFactor(void *ida_mem, sunrealtype dqincfac) int IDAGetLinWorkSpace(void *ida_mem, long int *lenrwLS, long int *leniwLS) int IDAGetNumJacEvals(void *ida_mem, long int *njevals) @@ -459,69 +459,69 @@ cdef extern from "idas/idas_ls.h": int IDAGetLastLinFlag(void *ida_mem, long int *flag) char *IDAGetLinReturnFlagName(long int flag) - ctypedef int (*IDALsJacFnB)(realtype tt, realtype c_jB, N_Vector yy, + ctypedef int (*IDALsJacFnB)(sunrealtype tt, sunrealtype c_jB, N_Vector yy, N_Vector yp, N_Vector yyB, N_Vector ypB, N_Vector rrB, SUNMatrix JacB, void *user_dataB, N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B) - ctypedef int (*IDALsJacFnBS)(realtype tt, realtype c_jB, N_Vector yy, + ctypedef int (*IDALsJacFnBS)(sunrealtype tt, sunrealtype c_jB, N_Vector yy, N_Vector yp, N_Vector *yS, N_Vector *ypS, N_Vector yyB, N_Vector ypB, N_Vector rrB, SUNMatrix JacB, void *user_dataB, N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B) - ctypedef int (*IDALsPrecSetupFnB)(realtype tt, N_Vector yy, + ctypedef int (*IDALsPrecSetupFnB)(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector yyB, N_Vector ypB, N_Vector rrB, - realtype c_jB, void *user_dataB) + sunrealtype c_jB, void *user_dataB) - ctypedef int (*IDALsPrecSetupFnBS)(realtype tt, N_Vector yy, + ctypedef int (*IDALsPrecSetupFnBS)(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector *yyS, N_Vector *ypS, N_Vector yyB, N_Vector ypB, N_Vector rrB, - realtype c_jB, void *user_dataB) + sunrealtype c_jB, void *user_dataB) - ctypedef int (*IDALsPrecSolveFnB)(realtype tt, N_Vector yy, + ctypedef int (*IDALsPrecSolveFnB)(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector yyB, N_Vector ypB, N_Vector rrB, N_Vector rvecB, N_Vector zvecB, - realtype c_jB, realtype deltaB, + sunrealtype c_jB, sunrealtype deltaB, void *user_dataB) - ctypedef int (*IDALsPrecSolveFnBS)(realtype tt, N_Vector yy, + ctypedef int (*IDALsPrecSolveFnBS)(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector *yyS, N_Vector *ypS, N_Vector yyB, N_Vector ypB, N_Vector rrB, N_Vector rvecB, N_Vector zvecB, - realtype c_jB, realtype deltaB, + sunrealtype c_jB, sunrealtype deltaB, void *user_dataB) - ctypedef int (*IDALsJacTimesSetupFnB)(realtype t, N_Vector yy, + ctypedef int (*IDALsJacTimesSetupFnB)(sunrealtype t, N_Vector yy, N_Vector yp, N_Vector yyB, N_Vector ypB, N_Vector rrB, - realtype c_jB, void *user_dataB) + sunrealtype c_jB, void *user_dataB) - ctypedef int (*IDALsJacTimesSetupFnBS)(realtype t, N_Vector yy, + ctypedef int (*IDALsJacTimesSetupFnBS)(sunrealtype t, N_Vector yy, N_Vector yp, N_Vector *yyS, N_Vector *ypS, N_Vector yyB, N_Vector ypB, N_Vector rrB, - realtype c_jB, void *user_dataB) + sunrealtype c_jB, void *user_dataB) - ctypedef int (*IDALsJacTimesVecFnB)(realtype t, N_Vector yy, + ctypedef int (*IDALsJacTimesVecFnB)(sunrealtype t, N_Vector yy, N_Vector yp, N_Vector yyB, N_Vector ypB, N_Vector rrB, N_Vector vB, N_Vector JvB, - realtype c_jB, void *user_dataB, + sunrealtype c_jB, void *user_dataB, N_Vector tmp1B, N_Vector tmp2B) - ctypedef int (*IDALsJacTimesVecFnBS)(realtype t, N_Vector yy, + ctypedef int (*IDALsJacTimesVecFnBS)(sunrealtype t, N_Vector yy, N_Vector yp, N_Vector *yyS, N_Vector *ypS, N_Vector yyB, N_Vector ypB, N_Vector rrB, N_Vector vB, N_Vector JvB, - realtype c_jB, void *user_dataB, + sunrealtype c_jB, void *user_dataB, N_Vector tmp1B, N_Vector tmp2B) int IDASetLinearSolverB(void *ida_mem, int which, SUNLinearSolver LS, @@ -530,8 +530,8 @@ cdef extern from "idas/idas_ls.h": int IDASetJacFnB(void *ida_mem, int which, IDALsJacFnB jacB) int IDASetJacFnBS(void *ida_mem, int which, IDALsJacFnBS jacBS) - int IDASetEpsLinB(void *ida_mem, int which, realtype eplifacB) - int IDASetIncrementFactorB(void *ida_mem, int which, realtype dqincfacB) + int IDASetEpsLinB(void *ida_mem, int which, sunrealtype eplifacB) + int IDASetIncrementFactorB(void *ida_mem, int which, sunrealtype dqincfacB) int IDASetPreconditionerB(void *ida_mem, int which, IDALsPrecSetupFnB psetB, IDALsPrecSolveFnB psolveB) @@ -548,122 +548,114 @@ cdef extern from "idas/idas_ls.h": cdef extern from "idas/idas_direct.h": - ctypedef IDALsJacFn IDADlsJacFn - ctypedef IDALsJacFnB IDADlsJacFnB - ctypedef IDALsJacFnBS IDADlsJacFnBS + ctypedef IDALsJacFn IDAJacFn + ctypedef IDALsJacFnB IDAJacFnB + ctypedef IDALsJacFnBS IDAJacFnBS - int IDADlsSetLinearSolver(void *ida_mem, SUNLinearSolver LS, SUNMatrix A) - int IDADlsSetJacFn(void *ida_mem, IDADlsJacFn jac) + int IDASetJacFn(void *ida_mem, IDAJacFn jac) - int IDADlsGetWorkSpace(void *ida_mem, long int *lenrwLS, long int *leniwLS) - int IDADlsGetNumJacEvals(void *ida_mem, long int *njevals) - int IDADlsGetNumResEvals(void *ida_mem, long int *nfevalsLS) - int IDADlsGetLastFlag(void *ida_mem, long int *flag) - char *IDADlsGetReturnFlagName(long int flag) - - int IDADlsSetLinearSolverB(void *ida_mem, int which, - SUNLinearSolver LS, SUNMatrix A) - - int IDADlsSetJacFnB(void *ida_mem, int which, IDADlsJacFnB jacB) + int IDAGetWorkSpace(void *ida_mem, long int *lenrwLS, long int *leniwLS) + int IDAGetNumJacEvals(void *ida_mem, long int *njevals) + int IDAGetNumResEvals(void *ida_mem, long int *nfevalsLS) + int IDAGetLastFlag(void *ida_mem, long int *flag) + char *IDAGetReturnFlagName(long int flag) + + int IDASetJacFnB(void *ida_mem, int which, IDAJacFnB jacB) - int IDADlsSetJacFnBS(void *ida_mem, int which, IDADlsJacFnBS jacBS) + int IDASetJacFnBS(void *ida_mem, int which, IDAJacFnBS jacBS) cdef extern from "idas/idas_spils.h": - ctypedef IDALsPrecSetupFn IDASpilsPrecSetupFn; - ctypedef IDALsPrecSolveFn IDASpilsPrecSolveFn; - ctypedef IDALsJacTimesSetupFn IDASpilsJacTimesSetupFn; - ctypedef IDALsJacTimesVecFn IDASpilsJacTimesVecFn; - - ctypedef IDALsPrecSetupFnB IDASpilsPrecSetupFnB - ctypedef IDALsPrecSetupFnBS IDASpilsPrecSetupFnBS - ctypedef IDALsPrecSolveFnB IDASpilsPrecSolveFnB - ctypedef IDALsPrecSolveFnBS IDASpilsPrecSolveFnBS - ctypedef IDALsJacTimesSetupFnB IDASpilsJacTimesSetupFnB - ctypedef IDALsJacTimesSetupFnBS IDASpilsJacTimesSetupFnBS - ctypedef IDALsJacTimesVecFnB IDASpilsJacTimesVecFnB - ctypedef IDALsJacTimesVecFnBS IDASpilsJacTimesVecFnBS - - int IDASpilsSetLinearSolver(void *ida_mem, SUNLinearSolver LS) - int IDASpilsSetPreconditioner(void *ida_mem, - IDASpilsPrecSetupFn pset, - IDASpilsPrecSolveFn psolve) - int IDASpilsSetJacTimes(void *ida_mem, IDASpilsJacTimesSetupFn jtsetup, - IDASpilsJacTimesVecFn jtimes) - int IDASpilsSetEpsLin(void *ida_mem, realtype eplifac) - int IDASpilsSetIncrementFactor(void *ida_mem, realtype dqincfac) - int IDASpilsGetWorkSpace(void *ida_mem, long int *lenrwLS, long int *leniwLS) - int IDASpilsGetNumPrecEvals(void *ida_mem, long int *npevals) - int IDASpilsGetNumPrecSolves(void *ida_mem, long int *npsolves) - int IDASpilsGetNumLinIters(void *ida_mem, long int *nliters) - int IDASpilsGetNumConvFails(void *ida_mem, long int *nlcfails) - int IDASpilsGetNumJTSetupEvals(void *ida_mem, long int *njtsetups) - int IDASpilsGetNumJtimesEvals(void *ida_mem, long int *njvevals) - int IDASpilsGetNumResEvals(void *ida_mem, long int *nrevalsLS) - int IDASpilsGetLastFlag(void *ida_mem, long int *flag) - char *IDASpilsGetReturnFlagName(long int flag) - - int IDASpilsSetLinearSolverB(void *ida_mem, int which, - SUNLinearSolver LS) - - int IDASpilsSetEpsLinB(void *ida_mem, int which, realtype eplifacB) + ctypedef IDALsPrecSetupFn IDAPrecSetupFn; + ctypedef IDALsPrecSolveFn IDAPrecSolveFn; + ctypedef IDALsJacTimesSetupFn IDAJacTimesSetupFn; + ctypedef IDALsJacTimesVecFn IDAJacTimesVecFn; + + ctypedef IDALsPrecSetupFnB IDAPrecSetupFnB + ctypedef IDALsPrecSetupFnBS IDAPrecSetupFnBS + ctypedef IDALsPrecSolveFnB IDAPrecSolveFnB + ctypedef IDALsPrecSolveFnBS IDAPrecSolveFnBS + ctypedef IDALsJacTimesSetupFnB IDAJacTimesSetupFnB + ctypedef IDALsJacTimesSetupFnBS IDAJacTimesSetupFnBS + ctypedef IDALsJacTimesVecFnB IDAJacTimesVecFnB + ctypedef IDALsJacTimesVecFnBS IDAJacTimesVecFnBS + + int IDASetPreconditioner(void *ida_mem, + IDAPrecSetupFn pset, + IDAPrecSolveFn psolve) + int IDASetJacTimes(void *ida_mem, IDAJacTimesSetupFn jtsetup, + IDAJacTimesVecFn jtimes) + int IDASetEpsLin(void *ida_mem, sunrealtype eplifac) + int IDASetIncrementFactor(void *ida_mem, sunrealtype dqincfac) + int IDAGetWorkSpace(void *ida_mem, long int *lenrwLS, long int *leniwLS) + int IDAGetNumPrecEvals(void *ida_mem, long int *npevals) + int IDAGetNumPrecSolves(void *ida_mem, long int *npsolves) + int IDAGetNumLinIters(void *ida_mem, long int *nliters) + int IDAGetNumConvFails(void *ida_mem, long int *nlcfails) + int IDAGetNumJTSetupEvals(void *ida_mem, long int *njtsetups) + int IDAGetNumJtimesEvals(void *ida_mem, long int *njvevals) + int IDAGetNumResEvals(void *ida_mem, long int *nrevalsLS) + int IDAGetLastFlag(void *ida_mem, long int *flag) + char *IDAGetReturnFlagName(long int flag) + + int IDASetEpsLinB(void *ida_mem, int which, sunrealtype eplifacB) - int IDASpilsSetIncrementFactorB(void *ida_mem, int which, - realtype dqincfacB) + int IDASetIncrementFactorB(void *ida_mem, int which, + sunrealtype dqincfacB) - int IDASpilsSetPreconditionerB(void *ida_mem, int which, - IDASpilsPrecSetupFnB psetB, - IDASpilsPrecSolveFnB psolveB) + int IDASetPreconditionerB(void *ida_mem, int which, + IDAPrecSetupFnB psetB, + IDAPrecSolveFnB psolveB) - int IDASpilsSetPreconditionerBS(void *ida_mem, int which, - IDASpilsPrecSetupFnBS psetBS, - IDASpilsPrecSolveFnBS psolveBS) + int IDASetPreconditionerBS(void *ida_mem, int which, + IDAPrecSetupFnBS psetBS, + IDAPrecSolveFnBS psolveBS) - int IDASpilsSetJacTimesB(void *ida_mem, int which, - IDASpilsJacTimesSetupFnB jtsetupB, - IDASpilsJacTimesVecFnB jtimesB) + int IDASetJacTimesB(void *ida_mem, int which, + IDAJacTimesSetupFnB jtsetupB, + IDAJacTimesVecFnB jtimesB) - int IDASpilsSetJacTimesBS(void *ida_mem, int which, - IDASpilsJacTimesSetupFnBS jtsetupBS, - IDASpilsJacTimesVecFnBS jtimesBS) + int IDASetJacTimesBS(void *ida_mem, int which, + IDAJacTimesSetupFnBS jtsetupBS, + IDAJacTimesVecFnBS jtimesBS) cdef extern from "idas/idas_bbdpre.h": - ctypedef int (*IDABBDLocalFn)(sunindextype Nlocal, realtype tt, + ctypedef int (*IDABBDLocalFn)(sunindextype Nlocal, sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector gval, void *user_data) - ctypedef int (*IDABBDCommFn)(sunindextype Nlocal, realtype tt, + ctypedef int (*IDABBDCommFn)(sunindextype Nlocal, sunrealtype tt, N_Vector yy, N_Vector yp, void *user_data) int IDABBDPrecInit(void *ida_mem, sunindextype Nlocal, sunindextype mudq, sunindextype mldq, sunindextype mukeep, sunindextype mlkeep, - realtype dq_rel_yy, + sunrealtype dq_rel_yy, IDABBDLocalFn Gres, IDABBDCommFn Gcomm) int IDABBDPrecReInit(void *ida_mem, sunindextype mudq, sunindextype mldq, - realtype dq_rel_yy) + sunrealtype dq_rel_yy) int IDABBDPrecGetWorkSpace(void *ida_mem, long int *lenrwBBDP, long int *leniwBBDP) int IDABBDPrecGetNumGfnEvals(void *ida_mem, long int *ngevalsBBDP) - ctypedef int (*IDABBDLocalFnB)(sunindextype NlocalB, realtype tt, + ctypedef int (*IDABBDLocalFnB)(sunindextype NlocalB, sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector yyB, N_Vector ypB, N_Vector gvalB, void *user_dataB) - ctypedef int (*IDABBDCommFnB)(sunindextype NlocalB, realtype tt, + ctypedef int (*IDABBDCommFnB)(sunindextype NlocalB, sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector yyB, N_Vector ypB, void *user_dataB) int IDABBDPrecInitB(void *ida_mem, int which, sunindextype NlocalB, sunindextype mudqB, sunindextype mldqB, sunindextype mukeepB, sunindextype mlkeepB, - realtype dq_rel_yyB, + sunrealtype dq_rel_yyB, IDABBDLocalFnB GresB, IDABBDCommFnB GcommB) int IDABBDPrecReInitB(void *ida_mem, int which, sunindextype mudqB, sunindextype mldqB, - realtype dq_rel_yyB) + sunrealtype dq_rel_yyB) diff --git a/scikits/odes/sundials/c_nvector_serial.pxd b/scikits/odes/sundials/c_nvector_serial.pxd index 4aece446..abb420ee 100644 --- a/scikits/odes/sundials/c_nvector_serial.pxd +++ b/scikits/odes/sundials/c_nvector_serial.pxd @@ -4,14 +4,14 @@ from .c_sundials cimport * cdef extern from "nvector/nvector_serial.h": cdef struct _N_VectorContent_Serial: sunindextype length - booleantype own_data - realtype *data + sunbooleantype own_data + sunrealtype *data ctypedef _N_VectorContent_Serial *N_VectorContent_Serial - N_Vector N_VNew_Serial(sunindextype vec_length) - N_Vector N_VNewEmpty_Serial(sunindextype vec_length) - N_Vector N_VMake_Serial(sunindextype vec_length, realtype *v_data) + N_Vector N_VNew_Serial(sunindextype vec_length, SUNContext sunctx) + N_Vector N_VNewEmpty_Serial(sunindextype vec_length, SUNContext sunctx) + N_Vector N_VMake_Serial(sunindextype vec_length, sunrealtype *v_data, SUNContext sunctx) N_Vector *N_VCloneVectorArray_Serial(int count, N_Vector w) N_Vector *N_VCloneVectorArrayEmpty_Serial(int count, N_Vector w) void N_VDestroyVectorArray_Serial(N_Vector *vs, int count) @@ -24,71 +24,71 @@ cdef extern from "nvector/nvector_serial.h": N_Vector N_VClone_Serial(N_Vector w) void N_VDestroy_Serial(N_Vector v) void N_VSpace_Serial(N_Vector v, sunindextype *lrw, sunindextype *liw) - realtype *N_VGetArrayPointer_Serial(N_Vector v) - void N_VSetArrayPointer_Serial(realtype *v_data, N_Vector v) - void N_VLinearSum_Serial(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z) - void N_VConst_Serial(realtype c, N_Vector z) + sunrealtype *N_VGetArrayPointer_Serial(N_Vector v) + void N_VSetArrayPointer_Serial(sunrealtype *v_data, N_Vector v) + void N_VLinearSum_Serial(sunrealtype a, N_Vector x, sunrealtype b, N_Vector y, N_Vector z) + void N_VConst_Serial(sunrealtype c, N_Vector z) void N_VProd_Serial(N_Vector x, N_Vector y, N_Vector z) void N_VDiv_Serial(N_Vector x, N_Vector y, N_Vector z) - void N_VScale_Serial(realtype c, N_Vector x, N_Vector z) + void N_VScale_Serial(sunrealtype c, N_Vector x, N_Vector z) void N_VAbs_Serial(N_Vector x, N_Vector z) void N_VInv_Serial(N_Vector x, N_Vector z) - void N_VAddConst_Serial(N_Vector x, realtype b, N_Vector z) - realtype N_VDotProd_Serial(N_Vector x, N_Vector y) - realtype N_VMaxNorm_Serial(N_Vector x) - realtype N_VWrmsNorm_Serial(N_Vector x, N_Vector w) - realtype N_VWrmsNormMask_Serial(N_Vector x, N_Vector w, N_Vector id) - realtype N_VMin_Serial(N_Vector x) - realtype N_VWL2Norm_Serial(N_Vector x, N_Vector w) - realtype N_VL1Norm_Serial(N_Vector x) - void N_VCompare_Serial(realtype c, N_Vector x, N_Vector z) - booleantype N_VInvTest_Serial(N_Vector x, N_Vector z) - booleantype N_VConstrMask_Serial(N_Vector c, N_Vector x, N_Vector m) - realtype N_VMinQuotient_Serial(N_Vector num, N_Vector denom) + void N_VAddConst_Serial(N_Vector x, sunrealtype b, N_Vector z) + sunrealtype N_VDotProd_Serial(N_Vector x, N_Vector y) + sunrealtype N_VMaxNorm_Serial(N_Vector x) + sunrealtype N_VWrmsNorm_Serial(N_Vector x, N_Vector w) + sunrealtype N_VWrmsNormMask_Serial(N_Vector x, N_Vector w, N_Vector id) + sunrealtype N_VMin_Serial(N_Vector x) + sunrealtype N_VWL2Norm_Serial(N_Vector x, N_Vector w) + sunrealtype N_VL1Norm_Serial(N_Vector x) + void N_VCompare_Serial(sunrealtype c, N_Vector x, N_Vector z) + sunbooleantype N_VInvTest_Serial(N_Vector x, N_Vector z) + sunbooleantype N_VConstrMask_Serial(N_Vector c, N_Vector x, N_Vector m) + sunrealtype N_VMinQuotient_Serial(N_Vector num, N_Vector denom) - int N_VLinearCombination_Serial(int nvec, realtype* c, N_Vector* V, + int N_VLinearCombination_Serial(int nvec, sunrealtype* c, N_Vector* V, N_Vector z) - int N_VScaleAddMulti_Serial(int nvec, realtype* a, N_Vector x, + int N_VScaleAddMulti_Serial(int nvec, sunrealtype* a, N_Vector x, N_Vector* Y, N_Vector* Z) int N_VDotProdMulti_Serial(int nvec, N_Vector x, N_Vector* Y, - realtype* dotprods) + sunrealtype* dotprods) - int N_VLinearSumVectorArray_Serial(int nvec, realtype a, N_Vector* X, - realtype b, N_Vector* Y, N_Vector* Z) - int N_VScaleVectorArray_Serial(int nvec, realtype* c, + int N_VLinearSumVectorArray_Serial(int nvec, sunrealtype a, N_Vector* X, + sunrealtype b, N_Vector* Y, N_Vector* Z) + int N_VScaleVectorArray_Serial(int nvec, sunrealtype* c, N_Vector* X, N_Vector* Z) - int N_VConstVectorArray_Serial(int nvecs, realtype c, N_Vector* Z) + int N_VConstVectorArray_Serial(int nvecs, sunrealtype c, N_Vector* Z) int N_VWrmsNormVectorArray_Serial(int nvecs, N_Vector* X, - N_Vector* W, realtype* nrm) + N_Vector* W, sunrealtype* nrm) int N_VWrmsNormMaskVectorArray_Serial(int nvecs, N_Vector* X, N_Vector* W, N_Vector id, - realtype* nrm) - int N_VScaleAddMultiVectorArray_Serial(int nvec, int nsum, realtype* a, + sunrealtype* nrm) + int N_VScaleAddMultiVectorArray_Serial(int nvec, int nsum, sunrealtype* a, N_Vector* X, N_Vector** Y, N_Vector** Z) int N_VLinearCombinationVectorArray_Serial(int nvec, int nsum, - realtype* c, + sunrealtype* c, N_Vector** X, N_Vector* Z) - realtype N_VWSqrSumLocal_Serial(N_Vector x, N_Vector w) - realtype N_VWSqrSumMaskLocal_Serial(N_Vector x, N_Vector w, N_Vector id) + sunrealtype N_VWSqrSumLocal_Serial(N_Vector x, N_Vector w) + sunrealtype N_VWSqrSumMaskLocal_Serial(N_Vector x, N_Vector w, N_Vector id) - int N_VEnableFusedOps_Serial(N_Vector v, booleantype tf) + int N_VEnableFusedOps_Serial(N_Vector v, sunbooleantype tf) - int N_VEnableLinearCombination_Serial(N_Vector v, booleantype tf) - int N_VEnableScaleAddMulti_Serial(N_Vector v, booleantype tf) - int N_VEnableDotProdMulti_Serial(N_Vector v, booleantype tf) + int N_VEnableLinearCombination_Serial(N_Vector v, sunbooleantype tf) + int N_VEnableScaleAddMulti_Serial(N_Vector v, sunbooleantype tf) + int N_VEnableDotProdMulti_Serial(N_Vector v, sunbooleantype tf) - int N_VEnableLinearSumVectorArray_Serial(N_Vector v, booleantype tf) - int N_VEnableScaleVectorArray_Serial(N_Vector v, booleantype tf) - int N_VEnableConstVectorArray_Serial(N_Vector v, booleantype tf) - int N_VEnableWrmsNormVectorArray_Serial(N_Vector v, booleantype tf) - int N_VEnableWrmsNormMaskVectorArray_Serial(N_Vector v, booleantype tf) - int N_VEnableScaleAddMultiVectorArray_Serial(N_Vector v, booleantype tf) - int N_VEnableLinearCombinationVectorArray_Serial(N_Vector v, booleantype tf) + int N_VEnableLinearSumVectorArray_Serial(N_Vector v, sunbooleantype tf) + int N_VEnableScaleVectorArray_Serial(N_Vector v, sunbooleantype tf) + int N_VEnableConstVectorArray_Serial(N_Vector v, sunbooleantype tf) + int N_VEnableWrmsNormVectorArray_Serial(N_Vector v, sunbooleantype tf) + int N_VEnableWrmsNormMaskVectorArray_Serial(N_Vector v, sunbooleantype tf) + int N_VEnableScaleAddMultiVectorArray_Serial(N_Vector v, sunbooleantype tf) + int N_VEnableLinearCombinationVectorArray_Serial(N_Vector v, sunbooleantype tf) # Macros sunindextype NV_LENGTH_S(N_Vector vc_s) - realtype* NV_DATA_S(N_Vector vc_s) + sunrealtype* NV_DATA_S(N_Vector vc_s) diff --git a/scikits/odes/sundials/c_sundials.pxd b/scikits/odes/sundials/c_sundials.pxd index 7226fe2e..259648f9 100644 --- a/scikits/odes/sundials/c_sundials.pxd +++ b/scikits/odes/sundials/c_sundials.pxd @@ -1,10 +1,23 @@ from libc.stdio cimport FILE cdef extern from "sundials/sundials_types.h": - ctypedef float realtype - ctypedef unsigned int booleantype + ctypedef float sunrealtype + ctypedef unsigned int sunbooleantype ctypedef long sunindextype +cdef extern from "sundials/sundials_context.h": + struct _SUNContext: + pass + ctypedef _SUNContext* SUNContext + + int SUNContext_Create(void* comm, SUNContext* ctx) + # Need to include profiler/logger headers + #int SUNContext_GetProfiler(SUNContext sunctx, SUNProfiler* profiler) + #int SUNContext_SetProfiler(SUNContext sunctx, SUNProfiler profiler) + #int SUNContext_GetLogger(SUNContext sunctx, SUNLogger* logger) + #int SUNContext_SetLogger(SUNContext sunctx, SUNLogger logger) + int SUNContext_Free(SUNContext* ctx) + cdef extern from "sundials/sundials_version.h": #Fill a string with SUNDIALS version information */ @@ -35,9 +48,9 @@ cdef extern from "sundials/sundials_nvector.h": pass struct _generic_N_Vector: pass - ctypedef _generic_N_Vector *N_Vector - ctypedef _generic_N_Vector_Ops *N_Vector_Ops - ctypedef N_Vector *N_Vector_S + ctypedef _generic_N_Vector* N_Vector + ctypedef _generic_N_Vector_Ops* N_Vector_Ops + ctypedef N_Vector* N_Vector_S struct _generic_N_Vector_Ops: N_Vector_ID (*nvgetvectorid)(N_Vector) @@ -45,54 +58,54 @@ cdef extern from "sundials/sundials_nvector.h": N_Vector (*nvcloneempty)(N_Vector) void (*nvdestroy)(N_Vector) void (*nvspace)(N_Vector, sunindextype *, sunindextype *) - realtype* (*nvgetarraypointer)(N_Vector) - void (*nvsetarraypointer)(realtype *, N_Vector) + sunrealtype* (*nvgetarraypointer)(N_Vector) + void (*nvsetarraypointer)(sunrealtype *, N_Vector) void* (*nvgetcommunicator)(N_Vector) sunindextype (*nvgetlength)(N_Vector) - void (*nvlinearsum)(realtype, N_Vector, realtype, N_Vector, N_Vector) - void (*nvconst)(realtype, N_Vector) + void (*nvlinearsum)(sunrealtype, N_Vector, sunrealtype, N_Vector, N_Vector) + void (*nvconst)(sunrealtype, N_Vector) void (*nvprod)(N_Vector, N_Vector, N_Vector) void (*nvdiv)(N_Vector, N_Vector, N_Vector) - void (*nvscale)(realtype, N_Vector, N_Vector) + void (*nvscale)(sunrealtype, N_Vector, N_Vector) void (*nvabs)(N_Vector, N_Vector) void (*nvinv)(N_Vector, N_Vector) - void (*nvaddconst)(N_Vector, realtype, N_Vector) - realtype (*nvdotprod)(N_Vector, N_Vector) - realtype (*nvmaxnorm)(N_Vector) - realtype (*nvwrmsnorm)(N_Vector, N_Vector) - realtype (*nvwrmsnormmask)(N_Vector, N_Vector, N_Vector) - realtype (*nvmin)(N_Vector) - realtype (*nvwl2norm)(N_Vector, N_Vector) - realtype (*nvl1norm)(N_Vector) - void (*nvcompare)(realtype, N_Vector, N_Vector) - booleantype (*nvinvtest)(N_Vector, N_Vector) - booleantype (*nvconstrmask)(N_Vector, N_Vector, N_Vector) - realtype (*nvminquotient)(N_Vector, N_Vector) - int (*nvlinearcombination)(int, realtype*, N_Vector*, N_Vector) - int (*nvscaleaddmulti)(int, realtype*, N_Vector, N_Vector*, N_Vector*) - int (*nvdotprodmulti)(int, N_Vector, N_Vector*, realtype*) + void (*nvaddconst)(N_Vector, sunrealtype, N_Vector) + sunrealtype (*nvdotprod)(N_Vector, N_Vector) + sunrealtype (*nvmaxnorm)(N_Vector) + sunrealtype (*nvwrmsnorm)(N_Vector, N_Vector) + sunrealtype (*nvwrmsnormmask)(N_Vector, N_Vector, N_Vector) + sunrealtype (*nvmin)(N_Vector) + sunrealtype (*nvwl2norm)(N_Vector, N_Vector) + sunrealtype (*nvl1norm)(N_Vector) + void (*nvcompare)(sunrealtype, N_Vector, N_Vector) + sunbooleantype (*nvinvtest)(N_Vector, N_Vector) + sunbooleantype (*nvconstrmask)(N_Vector, N_Vector, N_Vector) + sunrealtype (*nvminquotient)(N_Vector, N_Vector) + int (*nvlinearcombination)(int, sunrealtype*, N_Vector*, N_Vector) + int (*nvscaleaddmulti)(int, sunrealtype*, N_Vector, N_Vector*, N_Vector*) + int (*nvdotprodmulti)(int, N_Vector, N_Vector*, sunrealtype*) - int (*nvlinearsumvectorarray)(int, realtype, N_Vector*, realtype, + int (*nvlinearsumvectorarray)(int, sunrealtype, N_Vector*, sunrealtype, N_Vector*, N_Vector*) - int (*nvscalevectorarray)(int, realtype*, N_Vector*, N_Vector*) - int (*nvconstvectorarray)(int, realtype, N_Vector*) - int (*nvwrmsnormvectorarray)(int, N_Vector*, N_Vector*, realtype*) + int (*nvscalevectorarray)(int, sunrealtype*, N_Vector*, N_Vector*) + int (*nvconstvectorarray)(int, sunrealtype, N_Vector*) + int (*nvwrmsnormvectorarray)(int, N_Vector*, N_Vector*, sunrealtype*) int (*nvwrmsnormmaskvectorarray)(int, N_Vector*, N_Vector*, N_Vector, - realtype*) - int (*nvscaleaddmultivectorarray)(int, int, realtype*, N_Vector*, + sunrealtype*) + int (*nvscaleaddmultivectorarray)(int, int, sunrealtype*, N_Vector*, N_Vector**, N_Vector**) - int (*nvlinearcombinationvectorarray)(int, int, realtype*, N_Vector**, + int (*nvlinearcombinationvectorarray)(int, int, sunrealtype*, N_Vector**, N_Vector*) - realtype (*nvdotprodlocal)(N_Vector, N_Vector) - realtype (*nvmaxnormlocal)(N_Vector) - realtype (*nvminlocal)(N_Vector) - realtype (*nvl1normlocal)(N_Vector) - booleantype (*nvinvtestlocal)(N_Vector, N_Vector) - booleantype (*nvconstrmasklocal)(N_Vector, N_Vector, N_Vector) - realtype (*nvminquotientlocal)(N_Vector, N_Vector) - realtype (*nvwsqrsumlocal)(N_Vector, N_Vector) - realtype (*nvwsqrsummasklocal)(N_Vector, N_Vector, N_Vector) + sunrealtype (*nvdotprodlocal)(N_Vector, N_Vector) + sunrealtype (*nvmaxnormlocal)(N_Vector) + sunrealtype (*nvminlocal)(N_Vector) + sunrealtype (*nvl1normlocal)(N_Vector) + sunbooleantype (*nvinvtestlocal)(N_Vector, N_Vector) + sunbooleantype (*nvconstrmasklocal)(N_Vector, N_Vector, N_Vector) + sunrealtype (*nvminquotientlocal)(N_Vector, N_Vector) + sunrealtype (*nvwsqrsumlocal)(N_Vector, N_Vector) + sunrealtype (*nvwsqrsummasklocal)(N_Vector, N_Vector, N_Vector) struct _generic_N_Vector: void *content @@ -100,7 +113,7 @@ cdef extern from "sundials/sundials_nvector.h": # * FUNCTIONS * - N_Vector N_VNewEmpty() + N_Vector N_VNewEmpty(SUNContext sunctx) void N_VFreeEmpty(N_Vector v) int N_VCopyOps(N_Vector w, N_Vector v) @@ -109,69 +122,69 @@ cdef extern from "sundials/sundials_nvector.h": N_Vector N_VCloneEmpty(N_Vector w) void N_VDestroy(N_Vector v) void N_VSpace(N_Vector v, sunindextype *lrw, sunindextype *liw) - realtype *N_VGetArrayPointer(N_Vector v) - void N_VSetArrayPointer(realtype *v_data, N_Vector v) + sunrealtype *N_VGetArrayPointer(N_Vector v) + void N_VSetArrayPointer(sunrealtype *v_data, N_Vector v) void *N_VGetCommunicator(N_Vector v) sunindextype N_VGetLength(N_Vector v) - void N_VLinearSum(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z) - void N_VConst(realtype c, N_Vector z) + void N_VLinearSum(sunrealtype a, N_Vector x, sunrealtype b, N_Vector y, N_Vector z) + void N_VConst(sunrealtype c, N_Vector z) void N_VProd(N_Vector x, N_Vector y, N_Vector z) void N_VDiv(N_Vector x, N_Vector y, N_Vector z) - void N_VScale(realtype c, N_Vector x, N_Vector z) + void N_VScale(sunrealtype c, N_Vector x, N_Vector z) void N_VAbs(N_Vector x, N_Vector z) void N_VInv(N_Vector x, N_Vector z) - void N_VAddConst(N_Vector x, realtype b, N_Vector z) - realtype N_VDotProd(N_Vector x, N_Vector y) - realtype N_VMaxNorm(N_Vector x) - realtype N_VWrmsNorm(N_Vector x, N_Vector w) - realtype N_VWrmsNormMask(N_Vector x, N_Vector w, N_Vector id) - realtype N_VMin(N_Vector x) - realtype N_VWL2Norm(N_Vector x, N_Vector w) - realtype N_VL1Norm(N_Vector x) - void N_VCompare(realtype c, N_Vector x, N_Vector z) - booleantype N_VInvTest(N_Vector x, N_Vector z) - booleantype N_VConstrMask(N_Vector c, N_Vector x, N_Vector m) - realtype N_VMinQuotient(N_Vector num, N_Vector denom) + void N_VAddConst(N_Vector x, sunrealtype b, N_Vector z) + sunrealtype N_VDotProd(N_Vector x, N_Vector y) + sunrealtype N_VMaxNorm(N_Vector x) + sunrealtype N_VWrmsNorm(N_Vector x, N_Vector w) + sunrealtype N_VWrmsNormMask(N_Vector x, N_Vector w, N_Vector id) + sunrealtype N_VMin(N_Vector x) + sunrealtype N_VWL2Norm(N_Vector x, N_Vector w) + sunrealtype N_VL1Norm(N_Vector x) + void N_VCompare(sunrealtype c, N_Vector x, N_Vector z) + sunbooleantype N_VInvTest(N_Vector x, N_Vector z) + sunbooleantype N_VConstrMask(N_Vector c, N_Vector x, N_Vector m) + sunrealtype N_VMinQuotient(N_Vector num, N_Vector denom) # /* OPTIONAL fused vector operations */ - int N_VLinearCombination(int nvec, realtype* c, N_Vector* X, N_Vector z) + int N_VLinearCombination(int nvec, sunrealtype* c, N_Vector* X, N_Vector z) - int N_VScaleAddMulti(int nvec, realtype* a, N_Vector x, + int N_VScaleAddMulti(int nvec, sunrealtype* a, N_Vector x, N_Vector* Y, N_Vector* Z) - int N_VDotProdMulti(int nvec, N_Vector x, N_Vector* Y, realtype* dotprods) + int N_VDotProdMulti(int nvec, N_Vector x, N_Vector* Y, sunrealtype* dotprods) #/* OPTIONAL vector array operations */ - int N_VLinearSumVectorArray(int nvec, realtype a, N_Vector* X, - realtype b, N_Vector* Y, N_Vector* Z) + int N_VLinearSumVectorArray(int nvec, sunrealtype a, N_Vector* X, + sunrealtype b, N_Vector* Y, N_Vector* Z) - int N_VScaleVectorArray(int nvec, realtype* c, N_Vector* X, N_Vector* Z) + int N_VScaleVectorArray(int nvec, sunrealtype* c, N_Vector* X, N_Vector* Z) - int N_VConstVectorArray(int nvec, realtype c, N_Vector* Z) + int N_VConstVectorArray(int nvec, sunrealtype c, N_Vector* Z) int N_VWrmsNormVectorArray(int nvec, N_Vector* X, N_Vector* W, - realtype* nrm) + sunrealtype* nrm) int N_VWrmsNormMaskVectorArray(int nvec, N_Vector* X, N_Vector* W, - N_Vector id, realtype* nrm) + N_Vector id, sunrealtype* nrm) - int N_VScaleAddMultiVectorArray(int nvec, int nsum, realtype* a, + int N_VScaleAddMultiVectorArray(int nvec, int nsum, sunrealtype* a, N_Vector* X, N_Vector** Y, N_Vector** Z) - int N_VLinearCombinationVectorArray(int nvec, int nsum, realtype* c, + int N_VLinearCombinationVectorArray(int nvec, int nsum, sunrealtype* c, N_Vector** X, N_Vector* Z) #/* OPTIONAL local reduction kernels (no parallel communication) */ - realtype N_VDotProdLocal(N_Vector x, N_Vector y) - realtype N_VMaxNormLocal(N_Vector x) - realtype N_VMinLocal(N_Vector x) - realtype N_VL1NormLocal(N_Vector x) - realtype N_VWSqrSumLocal(N_Vector x, N_Vector w) - realtype N_VWSqrSumMaskLocal(N_Vector x, N_Vector w, N_Vector id) - booleantype N_VInvTestLocal(N_Vector x, N_Vector z) - booleantype N_VConstrMaskLocal(N_Vector c, N_Vector x, N_Vector m) - realtype N_VMinQuotientLocal(N_Vector num, N_Vector denom) + sunrealtype N_VDotProdLocal(N_Vector x, N_Vector y) + sunrealtype N_VMaxNormLocal(N_Vector x) + sunrealtype N_VMinLocal(N_Vector x) + sunrealtype N_VL1NormLocal(N_Vector x) + sunrealtype N_VWSqrSumLocal(N_Vector x, N_Vector w) + sunrealtype N_VWSqrSumMaskLocal(N_Vector x, N_Vector w, N_Vector id) + sunbooleantype N_VInvTestLocal(N_Vector x, N_Vector z) + sunbooleantype N_VConstrMaskLocal(N_Vector c, N_Vector x, N_Vector m) + sunrealtype N_VMinQuotientLocal(N_Vector num, N_Vector denom) # * Additional functions exported by NVECTOR module @@ -205,8 +218,8 @@ cdef extern from "sundials/sundials_matrix.h": void (*destroy)(SUNMatrix) int (*zero)(SUNMatrix) int (*copy)(SUNMatrix, SUNMatrix) - int (*scaleadd)(realtype, SUNMatrix, SUNMatrix) - int (*scaleaddi)(realtype, SUNMatrix) + int (*scaleadd)(sunrealtype, SUNMatrix, SUNMatrix) + int (*scaleaddi)(sunrealtype, SUNMatrix) int (*matvecsetup)(SUNMatrix); int (*matvec)(SUNMatrix, N_Vector, N_Vector) int (*space)(SUNMatrix, long int*, long int*) @@ -216,7 +229,7 @@ cdef extern from "sundials/sundials_matrix.h": SUNMatrix_Ops ops # * FUNCTIONS * - SUNMatrix SUNMatNewEmpty() + SUNMatrix SUNMatNewEmpty(SUNContext sunctx) void SUNMatFreeEmpty(SUNMatrix A) int SUNMatCopyOps(SUNMatrix A, SUNMatrix B) SUNMatrix_ID SUNMatGetID(SUNMatrix A) @@ -224,32 +237,32 @@ cdef extern from "sundials/sundials_matrix.h": void SUNMatDestroy(SUNMatrix A) int SUNMatZero(SUNMatrix A) int SUNMatCopy(SUNMatrix A, SUNMatrix B) - int SUNMatScaleAdd(realtype c, SUNMatrix A, SUNMatrix B) - int SUNMatScaleAddI(realtype c, SUNMatrix A) + int SUNMatScaleAdd(sunrealtype c, SUNMatrix A, SUNMatrix B) + int SUNMatScaleAddI(sunrealtype c, SUNMatrix A) int SUNMatMatvecSetup(SUNMatrix A) int SUNMatMatvec(SUNMatrix A, N_Vector x, N_Vector y) int SUNMatSpace(SUNMatrix A, long int *lenrw, long int *leniw) cdef extern from "sundials/sundials_iterative.h": enum: - PREC_NONE - PREC_LEFT - PREC_RIGHT - PREC_BOTH + SUN_PREC_NONE + SUN_PREC_LEFT + SUN_PREC_RIGHT + SUN_PREC_BOTH enum: - MODIFIED_GS = 1 - CLASSICAL_GS = 2 - ctypedef int (*ATimesFn)(void *A_data, N_Vector v, N_Vector z) - ctypedef int (*PSetupFn)(void *P_data) - ctypedef int (*PSolveFn)(void *P_data, N_Vector r, N_Vector z, - realtype tol, int lr) - - int ModifiedGS(N_Vector *v, realtype **h, int k, int p, - realtype *new_vk_norm) - int ClassicalGS(N_Vector *v, realtype **h, int k, int p, - realtype *new_vk_norm, N_Vector temp, realtype *s) - int QRfact(int n, realtype **h, realtype *q, int job) - int QRsol(int n, realtype **h, realtype *q, realtype *b) + SUN_MODIFIED_GS = 1 + SUN_CLASSICAL_GS = 2 + ctypedef int (*SUNATimesFn)(void *A_data, N_Vector v, N_Vector z) + ctypedef int (*SUNPSetupFn)(void *P_data) + ctypedef int (*SUNPSolveFn)(void *P_data, N_Vector r, N_Vector z, + sunrealtype tol, int lr) + + int ModifiedGS(N_Vector *v, sunrealtype **h, int k, int p, + sunrealtype *new_vk_norm) + int ClassicalGS(N_Vector *v, sunrealtype **h, int k, int p, + sunrealtype *new_vk_norm, N_Vector temp, sunrealtype *s) + int QRfact(int n, sunrealtype **h, sunrealtype *q, int job) + int QRsol(int n, sunrealtype **h, sunrealtype *q, sunrealtype *b) enum: SUNMAT_SUCCESS # 0 /* function successfull */ enum: SUNMAT_ILL_INPUT # -701 /* illegal function input */ @@ -291,17 +304,17 @@ cdef extern from "sundials/sundials_linearsolver.h": struct _generic_SUNLinearSolver_Ops: SUNLinearSolver_Type (*gettype)(SUNLinearSolver) SUNLinearSolver_ID (*getid)(SUNLinearSolver); - int (*setatimes)(SUNLinearSolver, void*, ATimesFn) + int (*setatimes)(SUNLinearSolver, void*, SUNATimesFn) int (*setpreconditioner)(SUNLinearSolver, void*, - PSetupFn, PSolveFn) + SUNPSetupFn, SUNPSolveFn) int (*setscalingvectors)(SUNLinearSolver, N_Vector, N_Vector) int (*initialize)(SUNLinearSolver) int (*setup)(SUNLinearSolver, SUNMatrix) int (*solve)(SUNLinearSolver, SUNMatrix, N_Vector, - N_Vector, realtype) + N_Vector, sunrealtype) int (*numiters)(SUNLinearSolver) - realtype (*resnorm)(SUNLinearSolver) + sunrealtype (*resnorm)(SUNLinearSolver) long int (*lastflag)(SUNLinearSolver) int (*space)(SUNLinearSolver, long int*, long int*) N_Vector (*resid)(SUNLinearSolver) @@ -311,7 +324,7 @@ cdef extern from "sundials/sundials_linearsolver.h": void *content SUNLinearSolver_Ops ops - SUNLinearSolver SUNLinSolNewEmpty() + SUNLinearSolver SUNLinSolNewEmpty(SUNContext sunctx) void SUNLinSolFreeEmpty(SUNLinearSolver S) @@ -319,17 +332,17 @@ cdef extern from "sundials/sundials_linearsolver.h": SUNLinearSolver_ID SUNLinSolGetID(SUNLinearSolver S) int SUNLinSolSetATimes(SUNLinearSolver S, void* A_data, - ATimesFn ATimes) + SUNATimesFn ATimes) int SUNLinSolSetPreconditioner(SUNLinearSolver S, void* P_data, - PSetupFn Pset, PSolveFn Psol) + SUNPSetupFn Pset, SUNPSolveFn Psol) int SUNLinSolSetScalingVectors(SUNLinearSolver S, N_Vector s1, N_Vector s2) int SUNLinSolInitialize(SUNLinearSolver S) int SUNLinSolSetup(SUNLinearSolver S, SUNMatrix A) int SUNLinSolSolve(SUNLinearSolver S, SUNMatrix A, N_Vector x, - N_Vector b, realtype tol) + N_Vector b, sunrealtype tol) int SUNLinSolNumIters(SUNLinearSolver S) - realtype SUNLinSolResNorm(SUNLinearSolver S) + sunrealtype SUNLinSolResNorm(SUNLinearSolver S) N_Vector SUNLinSolResid(SUNLinearSolver S) long int SUNLinSolLastFlag(SUNLinearSolver S) int SUNLinSolSpace(SUNLinearSolver S, long int *lenrwLS, @@ -370,77 +383,77 @@ cdef extern from "sundials/sundials_direct.h": sunindextype mu sunindextype ml sunindextype s_mu - realtype *data + sunrealtype *data sunindextype ldata - realtype **cols + sunrealtype **cols - ctypedef _DlsMat *DlsMat + ctypedef _DlsMat *SUNDlsMat - DlsMat NewDenseMat(sunindextype M, sunindextype N) - DlsMat NewBandMat(sunindextype N, sunindextype mu, sunindextype ml, sunindextype smu) - void DestroyMat(DlsMat A) + SUNDlsMat NewDenseMat(sunindextype M, sunindextype N) + SUNDlsMat NewBandMat(sunindextype N, sunindextype mu, sunindextype ml, sunindextype smu) + void DestroyMat(SUNDlsMat A) int *NewIntArray(int N) sunindextype *NewIndexArray(sunindextype N) - realtype *NewRealArray(long int N) + sunrealtype *NewRealArray(long int N) void DestroyArray(void *p) - void AddIdentity(DlsMat A) - void SetToZero(DlsMat A) - void PrintMat(DlsMat A, FILE *outfile) - - # * Exported function prototypes (functions working on realtype**) - realtype **newDenseMat(sunindextype m, sunindextype n) - realtype **newBandMat(sunindextype n, sunindextype smu, sunindextype ml) - void destroyMat(realtype **a) + void AddIdentity(SUNDlsMat A) + void SetToZero(SUNDlsMat A) + void PrintMat(SUNDlsMat A, FILE *outfile) + + # * Exported function prototypes (functions working on sunrealtype**) + sunrealtype **newDenseMat(sunindextype m, sunindextype n) + sunrealtype **newBandMat(sunindextype n, sunindextype smu, sunindextype ml) + void destroyMat(sunrealtype **a) int *newIntArray(int n) sunindextype *newIndexArray(sunindextype n) - realtype *newRealArray(sunindextype m) + sunrealtype *newRealArray(sunindextype m) void destroyArray(void *v) cdef extern from "sundials/sundials_band.h": - sunindextype BandGBTRF(DlsMat A, sunindextype *p) - sunindextype bandGBTRF(realtype **a, sunindextype n, sunindextype mu, sunindextype ml, + sunindextype SUNDlsMat_BandGBTRF(SUNDlsMat A, sunindextype *p) + sunindextype SUNDlsMat_bandGBTRF(sunrealtype **a, sunindextype n, sunindextype mu, sunindextype ml, sunindextype smu, sunindextype *p) - void BandGBTRS(DlsMat A, sunindextype *p, realtype *b) - void bandGBTRS(realtype **a, sunindextype n, sunindextype smu, sunindextype ml, - sunindextype *p, realtype *b) - void BandCopy(DlsMat A, DlsMat B, sunindextype copymu, sunindextype copyml) - void bandCopy(realtype **a, realtype **b, sunindextype n, sunindextype a_smu, + void SUNDlsMat_BandGBTRS(SUNDlsMat A, sunindextype *p, sunrealtype *b) + void SUNDlsMat_bandGBTRS(sunrealtype **a, sunindextype n, sunindextype smu, sunindextype ml, + sunindextype *p, sunrealtype *b) + void SUNDlsMat_BandCopy(SUNDlsMat A, SUNDlsMat B, sunindextype copymu, sunindextype copyml) + void SUNDlsMat_bandCopy(sunrealtype **a, sunrealtype **b, sunindextype n, sunindextype a_smu, sunindextype b_smu, sunindextype copymu, sunindextype copyml) - void BandScale(realtype c, DlsMat A) - void bandScale(realtype c, realtype **a, sunindextype n, sunindextype mu, + void SUNDlsMat_BandScale(sunrealtype c, SUNDlsMat A) + void SUNDlsMat_bandScale(sunrealtype c, sunrealtype **a, sunindextype n, sunindextype mu, sunindextype ml, sunindextype smu) - void bandAddIdentity(realtype **a, sunindextype n, sunindextype smu) - void BandMatvec(DlsMat A, realtype *x, realtype *y) - void bandMatvec(realtype **a, realtype *x, realtype *y, sunindextype n, + void SUNDlsMat_bandAddIdentity(sunrealtype **a, sunindextype n, sunindextype smu) + void SUNDlsMat_BandMatvec(SUNDlsMat A, sunrealtype *x, sunrealtype *y) + void SUNDlsMat_bandMatvec(sunrealtype **a, sunrealtype *x, sunrealtype *y, sunindextype n, sunindextype mu, sunindextype ml, sunindextype smu) cdef extern from "sundials/sundials_dense.h": - sunindextype DenseGETRF(DlsMat A, sunindextype *p) - void DenseGETRS(DlsMat A, sunindextype *p, realtype *b) + sunindextype SUNDlsMat_DenseGETRF(SUNDlsMat A, sunindextype *p) + void SUNDlsMat_DenseGETRS(SUNDlsMat A, sunindextype *p, sunrealtype *b) - sunindextype denseGETRF(realtype **a, sunindextype m, sunindextype n, sunindextype *p) - void denseGETRS(realtype **a, sunindextype n, sunindextype *p, realtype *b) + sunindextype SUNDlsMat_denseGETRF(sunrealtype **a, sunindextype m, sunindextype n, sunindextype *p) + void SUNDlsMat_denseGETRS(sunrealtype **a, sunindextype n, sunindextype *p, sunrealtype *b) - sunindextype DensePOTRF(DlsMat A) - void DensePOTRS(DlsMat A, realtype *b) + sunindextype SUNDlsMat_DensePOTRF(SUNDlsMat A) + void SUNDlsMat_DensePOTRS(SUNDlsMat A, sunrealtype *b) - sunindextype densePOTRF(realtype **a, sunindextype m) - void densePOTRS(realtype **a, sunindextype m, realtype *b) + sunindextype SUNDlsMat_densePOTRF(sunrealtype **a, sunindextype m) + void SUNDlsMat_densePOTRS(sunrealtype **a, sunindextype m, sunrealtype *b) - int DenseGEQRF(DlsMat A, realtype *beta, realtype *wrk) - int DenseORMQR(DlsMat A, realtype *beta, realtype *vn, realtype *vm, - realtype *wrk) + int SUNDlsMat_DenseGEQRF(SUNDlsMat A, sunrealtype *beta, sunrealtype *wrk) + int SUNDlsMat_DenseORMQR(SUNDlsMat A, sunrealtype *beta, sunrealtype *vn, sunrealtype *vm, + sunrealtype *wrk) - int denseGEQRF(realtype **a, sunindextype m, sunindextype n, realtype *beta, realtype *v) - int denseORMQR(realtype **a, sunindextype m, sunindextype n, realtype *beta, - realtype *v, realtype *w, realtype *wrk) - void DenseCopy(DlsMat A, DlsMat B) - void denseCopy(realtype **a, realtype **b, sunindextype m, sunindextype n) - void DenseScale(realtype c, DlsMat A) - void denseScale(realtype c, realtype **a, sunindextype m, sunindextype n) - void denseAddIdentity(realtype **a, sunindextype n) - void DenseMatvec(DlsMat A, realtype *x, realtype *y) - void denseMatvec(realtype **a, realtype *x, realtype *y, sunindextype m, sunindextype n) + int SUNDlsMat_denseGEQRF(sunrealtype **a, sunindextype m, sunindextype n, sunrealtype *beta, sunrealtype *v) + int SUNDlsMat_denseORMQR(sunrealtype **a, sunindextype m, sunindextype n, sunrealtype *beta, + sunrealtype *v, sunrealtype *w, sunrealtype *wrk) + void SUNDlsMat_DenseCopy(SUNDlsMat A, SUNDlsMat B) + void SUNDlsMat_denseCopy(sunrealtype **a, sunrealtype **b, sunindextype m, sunindextype n) + void SUNDlsMat_DenseScale(sunrealtype c, SUNDlsMat A) + void SUNDlsMat_denseScale(sunrealtype c, sunrealtype **a, sunindextype m, sunindextype n) + void SUNDlsMat_denseAddIdentity(sunrealtype **a, sunindextype n) + void SUNDlsMat_DenseMatvec(SUNDlsMat A, sunrealtype *x, sunrealtype *y) + void SUNDlsMat_denseMatvec(sunrealtype **a, sunrealtype *x, sunrealtype *y, sunindextype m, sunindextype n) cdef extern from "sundials/sundials_nonlinearsolver.h": @@ -452,12 +465,12 @@ cdef extern from "sundials/sundials_nonlinearsolver.h": ctypedef _generic_SUNNonlinearSolver *SUNNonlinearSolver ctypedef int (*SUNNonlinSolSysFn)(N_Vector y, N_Vector F, void* mem) - ctypedef int (*SUNNonlinSolLSetupFn)(booleantype jbad, - booleantype* jcur, void* mem) + ctypedef int (*SUNNonlinSolLSetupFn)(sunbooleantype jbad, + sunbooleantype* jcur, void* mem) ctypedef int (*SUNNonlinSolLSolveFn)(N_Vector b, void* mem) # rename reserved del into del_t for python! ctypedef int (*SUNNonlinSolConvTestFn)(SUNNonlinearSolver NLS, N_Vector y, - N_Vector del_t, realtype tol, + N_Vector del_t, sunrealtype tol, N_Vector ewt, void* mem) cdef enum SUNNonlinearSolver_Type: @@ -468,8 +481,8 @@ cdef extern from "sundials/sundials_nonlinearsolver.h": SUNNonlinearSolver_Type (*gettype)(SUNNonlinearSolver) int (*initialize)(SUNNonlinearSolver) int (*setup)(SUNNonlinearSolver, N_Vector, void*) - int (*solve)(SUNNonlinearSolver, N_Vector, N_Vector, N_Vector, realtype, - booleantype, void*) + int (*solve)(SUNNonlinearSolver, N_Vector, N_Vector, N_Vector, sunrealtype, + sunbooleantype, void*) int (*free)(SUNNonlinearSolver) int (*setsysfn)(SUNNonlinearSolver, SUNNonlinSolSysFn) int (*setlsetupfn)(SUNNonlinearSolver, SUNNonlinSolLSetupFn) @@ -484,7 +497,7 @@ cdef extern from "sundials/sundials_nonlinearsolver.h": void *content SUNNonlinearSolver_Ops ops - SUNNonlinearSolver SUNNonlinSolNewEmpty(); + SUNNonlinearSolver SUNNonlinSolNewEmpty(SUNContext sunctx); void SUNNonlinSolFreeEmpty(SUNNonlinearSolver NLS); SUNNonlinearSolver_Type SUNNonlinSolGetType(SUNNonlinearSolver NLS) @@ -492,8 +505,8 @@ cdef extern from "sundials/sundials_nonlinearsolver.h": int SUNNonlinSolInitialize(SUNNonlinearSolver NLS) int SUNNonlinSolSetup(SUNNonlinearSolver NLS, N_Vector y, void* mem) int SUNNonlinSolSolve(SUNNonlinearSolver NLS, N_Vector y0, N_Vector y, - N_Vector w, realtype tol, - booleantype callLSetup, void *mem) + N_Vector w, sunrealtype tol, + sunbooleantype callLSetup, void *mem) int SUNNonlinSolFree(SUNNonlinearSolver NLS) int SUNNonlinSolSetSysFn(SUNNonlinearSolver NLS, SUNNonlinSolSysFn SysFn) diff --git a/scikits/odes/sundials/c_sunlinsol.pxd b/scikits/odes/sundials/c_sunlinsol.pxd index fef2a2b1..1c654267 100644 --- a/scikits/odes/sundials/c_sunlinsol.pxd +++ b/scikits/odes/sundials/c_sunlinsol.pxd @@ -12,7 +12,7 @@ cdef extern from "sunlinsol/sunlinsol_dense.h": ctypedef _SUNLinearSolverContent_Dense *SUNLinearSolverContent_Dense - SUNLinearSolver SUNLinSol_Dense(N_Vector y, SUNMatrix A) + SUNLinearSolver SUNLinSol_Dense(N_Vector y, SUNMatrix A, SUNContext sunctx) SUNLinearSolver SUNDenseLinearSolver(N_Vector y, SUNMatrix A) #deprecated SUNLinearSolver_Type SUNLinSolGetType_Dense(SUNLinearSolver S) @@ -20,7 +20,7 @@ cdef extern from "sunlinsol/sunlinsol_dense.h": int SUNLinSolInitialize_Dense(SUNLinearSolver S) int SUNLinSolSetup_Dense(SUNLinearSolver S, SUNMatrix A) int SUNLinSolSolve_Dense(SUNLinearSolver S, SUNMatrix A, - N_Vector x, N_Vector b, realtype tol) + N_Vector x, N_Vector b, sunrealtype tol) sunindextype SUNLinSolLastFlag_Dense(SUNLinearSolver S) int SUNLinSolSpace_Dense(SUNLinearSolver S, long int *lenrwLS, long int *leniwLS) @@ -35,7 +35,7 @@ cdef extern from "sunlinsol/sunlinsol_band.h": ctypedef _SUNLinearSolverContent_Band *SUNLinearSolverContent_Band - SUNLinearSolver SUNLinSol_Band(N_Vector y, SUNMatrix A) + SUNLinearSolver SUNLinSol_Band(N_Vector y, SUNMatrix A, SUNContext sunctx) SUNLinearSolver SUNBandLinearSolver(N_Vector y, SUNMatrix A) # deprecated SUNLinearSolver_Type SUNLinSolGetType_Band(SUNLinearSolver S) @@ -43,7 +43,7 @@ cdef extern from "sunlinsol/sunlinsol_band.h": int SUNLinSolInitialize_Band(SUNLinearSolver S) int SUNLinSolSetup_Band(SUNLinearSolver S, SUNMatrix A) int SUNLinSolSolve_Band(SUNLinearSolver S, SUNMatrix A, - N_Vector x, N_Vector b, realtype tol) + N_Vector x, N_Vector b, sunrealtype tol) sunindextype SUNLinSolLastFlag_Band(SUNLinearSolver S) int SUNLinSolSpace_Band(SUNLinearSolver S, long int *lenrwLS, long int *leniwLS) @@ -62,7 +62,7 @@ IF SUNDIALS_BLAS_LAPACK: ctypedef _SUNLinearSolverContent_LapackDense *SUNLinearSolverContent_LapackDense - SUNLinearSolver SUNLinSol_LapackDense(N_Vector y, SUNMatrix A) + SUNLinearSolver SUNLinSol_LapackDense(N_Vector y, SUNMatrix A, SUNContext sunctx) SUNLinearSolver SUNLapackDense(N_Vector y, SUNMatrix A) #deprecated SUNLinearSolver_Type SUNLinSolGetType_LapackDense(SUNLinearSolver S) @@ -70,7 +70,7 @@ IF SUNDIALS_BLAS_LAPACK: int SUNLinSolInitialize_LapackDense(SUNLinearSolver S) int SUNLinSolSetup_LapackDense(SUNLinearSolver S, SUNMatrix A) int SUNLinSolSolve_LapackDense(SUNLinearSolver S, SUNMatrix A, - N_Vector x, N_Vector b, realtype tol) + N_Vector x, N_Vector b, sunrealtype tol) sunindextype SUNLinSolLastFlag_LapackDense(SUNLinearSolver S) int SUNLinSolSpace_LapackDense(SUNLinearSolver S, long int *lenrwLS, long int *leniwLS) @@ -86,7 +86,7 @@ IF SUNDIALS_BLAS_LAPACK: ctypedef _SUNLinearSolverContent_LapackBand *SUNLinearSolverContent_LapackBand - SUNLinearSolver SUNLinSol_LapackBand(N_Vector y, SUNMatrix A) + SUNLinearSolver SUNLinSol_LapackBand(N_Vector y, SUNMatrix A, SUNContext sunctx) SUNLinearSolver SUNLapackBand(N_Vector y, SUNMatrix A) # deprecated SUNLinearSolver_Type SUNLinSolGetType_LapackBand(SUNLinearSolver S) @@ -94,7 +94,7 @@ IF SUNDIALS_BLAS_LAPACK: int SUNLinSolInitialize_LapackBand(SUNLinearSolver S) int SUNLinSolSetup_LapackBand(SUNLinearSolver S, SUNMatrix A) int SUNLinSolSolve_LapackBand(SUNLinearSolver S, SUNMatrix A, - N_Vector x, N_Vector b, realtype tol) + N_Vector x, N_Vector b, sunrealtype tol) sunindextype SUNLinSolLastFlag_LapackBand(SUNLinearSolver S) int SUNLinSolSpace_LapackBand(SUNLinearSolver S, long int *lenrwLS, long int *leniwLS) @@ -107,13 +107,13 @@ cdef extern from "sunlinsol/sunlinsol_pcg.h": int maxl int pretype int numiters - realtype resnorm + sunrealtype resnorm long int last_flag - ATimesFn ATimes + SUNATimesFn ATimes void* ATData - PSetupFn Psetup - PSolveFn Psolve + SUNPSetupFn Psetup + SUNPSolveFn Psolve void* PData N_Vector s @@ -124,7 +124,7 @@ cdef extern from "sunlinsol/sunlinsol_pcg.h": ctypedef _SUNLinearSolverContent_PCG *SUNLinearSolverContent_PCG - SUNLinearSolver SUNLinSol_PCG(N_Vector y, int pretype, int maxl) + SUNLinearSolver SUNLinSol_PCG(N_Vector y, int pretype, int maxl, SUNContext sunctx) int SUNLinSol_PCGSetPrecType(SUNLinearSolver S, int pretype) int SUNLinSol_PCGSetMaxl(SUNLinearSolver S, int maxl) SUNLinearSolver SUNPCG(N_Vector y, int pretype, int maxl) #deprecated @@ -134,16 +134,16 @@ cdef extern from "sunlinsol/sunlinsol_pcg.h": SUNLinearSolver_Type SUNLinSolGetType_PCG(SUNLinearSolver S) SUNLinearSolver_ID SUNLinSolGetID_PCG(SUNLinearSolver S) int SUNLinSolInitialize_PCG(SUNLinearSolver S) - int SUNLinSolSetATimes_PCG(SUNLinearSolver S, void* A_data, ATimesFn ATimes) + int SUNLinSolSetATimes_PCG(SUNLinearSolver S, void* A_data, SUNATimesFn ATimes) int SUNLinSolSetPreconditioner_PCG(SUNLinearSolver S, void* P_data, - PSetupFn Pset, PSolveFn Psol) + SUNPSetupFn Pset, SUNPSolveFn Psol) int SUNLinSolSetScalingVectors_PCG(SUNLinearSolver S, N_Vector s, N_Vector nul) int SUNLinSolSetup_PCG(SUNLinearSolver S, SUNMatrix nul) int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNMatrix nul, - N_Vector x, N_Vector b, realtype tol) + N_Vector x, N_Vector b, sunrealtype tol) int SUNLinSolNumIters_PCG(SUNLinearSolver S) - realtype SUNLinSolResNorm_PCG(SUNLinearSolver S) + sunrealtype SUNLinSolResNorm_PCG(SUNLinearSolver S) N_Vector SUNLinSolResid_PCG(SUNLinearSolver S) sunindextype SUNLinSolLastFlag_PCG(SUNLinearSolver S) int SUNLinSolSpace_PCG(SUNLinearSolver S, long int *lenrwLS, @@ -157,13 +157,13 @@ cdef extern from "sunlinsol/sunlinsol_spbcgs.h": int maxl int pretype int numiters - realtype resnorm + sunrealtype resnorm long int last_flag - ATimesFn ATimes + SUNATimesFn ATimes void* ATData - PSetupFn Psetup - PSolveFn Psolve + SUNPSetupFn Psetup + SUNPSolveFn Psolve void* PData N_Vector s1 @@ -178,7 +178,7 @@ cdef extern from "sunlinsol/sunlinsol_spbcgs.h": ctypedef _SUNLinearSolverContent_SPBCGS *SUNLinearSolverContent_SPBCGS - SUNLinearSolver SUNLinSol_SPBCGS(N_Vector y, int pretype, int maxl) + SUNLinearSolver SUNLinSol_SPBCGS(N_Vector y, int pretype, int maxl, SUNContext sunctx) int SUNLinSol_SPBCGSSetPrecType(SUNLinearSolver S, int pretype) int SUNLinSol_SPBCGSSetMaxl(SUNLinearSolver S, int maxl) SUNLinearSolver SUNSPBCGS(N_Vector y, int pretype, int maxl) # deprecated @@ -189,19 +189,19 @@ cdef extern from "sunlinsol/sunlinsol_spbcgs.h": SUNLinearSolver_ID SUNLinSolGetID_SPBCGS(SUNLinearSolver S) int SUNLinSolInitialize_SPBCGS(SUNLinearSolver S) int SUNLinSolSetATimes_SPBCGS(SUNLinearSolver S, void* A_data, - ATimesFn ATimes) + SUNATimesFn ATimes) int SUNLinSolSetPreconditioner_SPBCGS(SUNLinearSolver S, void* P_data, - PSetupFn Pset, - PSolveFn Psol) + SUNPSetupFn Pset, + SUNPSolveFn Psol) int SUNLinSolSetScalingVectors_SPBCGS(SUNLinearSolver S, N_Vector s1, N_Vector s2) int SUNLinSolSetup_SPBCGS(SUNLinearSolver S, SUNMatrix A) int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNMatrix A, - N_Vector x, N_Vector b, realtype tol) + N_Vector x, N_Vector b, sunrealtype tol) int SUNLinSolNumIters_SPBCGS(SUNLinearSolver S) - realtype SUNLinSolResNorm_SPBCGS(SUNLinearSolver S) + sunrealtype SUNLinSolResNorm_SPBCGS(SUNLinearSolver S) N_Vector SUNLinSolResid_SPBCGS(SUNLinearSolver S) sunindextype SUNLinSolLastFlag_SPBCGS(SUNLinearSolver S) int SUNLinSolSpace_SPBCGS(SUNLinearSolver S, @@ -218,31 +218,31 @@ cdef extern from "sunlinsol/sunlinsol_spfgmr.h": int gstype int max_restarts int numiters - realtype resnorm + sunrealtype resnorm long int last_flag - ATimesFn ATimes + SUNATimesFn ATimes void* ATData - PSetupFn Psetup - PSolveFn Psolve + SUNPSetupFn Psetup + SUNPSolveFn Psolve void* PData N_Vector s1 N_Vector s2 N_Vector *V N_Vector *Z - realtype **Hes - realtype *givens + sunrealtype **Hes + sunrealtype *givens N_Vector xcor - realtype *yg + sunrealtype *yg N_Vector vtemp - realtype *cv + sunrealtype *cv N_Vector *Xv ctypedef _SUNLinearSolverContent_SPFGMR *SUNLinearSolverContent_SPFGMR - SUNLinearSolver SUNLinSol_SPFGMR(N_Vector y, int pretype, int maxl) + SUNLinearSolver SUNLinSol_SPFGMR(N_Vector y, int pretype, int maxl, SUNContext sunctx) int SUNLinSol_SPFGMRSetPrecType(SUNLinearSolver S, int pretype) int SUNLinSol_SPFGMRSetGSType(SUNLinearSolver S, int gstype) int SUNLinSol_SPFGMRSetMaxRestarts(SUNLinearSolver S, int maxrs) @@ -255,19 +255,19 @@ cdef extern from "sunlinsol/sunlinsol_spfgmr.h": SUNLinearSolver_ID SUNLinSolGetID_SPFGMR(SUNLinearSolver S) int SUNLinSolInitialize_SPFGMR(SUNLinearSolver S) int SUNLinSolSetATimes_SPFGMR(SUNLinearSolver S, void* A_data, - ATimesFn ATimes) + SUNATimesFn ATimes) int SUNLinSolSetPreconditioner_SPFGMR(SUNLinearSolver S, void* P_data, - PSetupFn Pset, - PSolveFn Psol) + SUNPSetupFn Pset, + SUNPSolveFn Psol) int SUNLinSolSetScalingVectors_SPFGMR(SUNLinearSolver S, N_Vector s1, N_Vector s2) int SUNLinSolSetup_SPFGMR(SUNLinearSolver S, SUNMatrix A) int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNMatrix A, - N_Vector x, N_Vector b, realtype tol) + N_Vector x, N_Vector b, sunrealtype tol) int SUNLinSolNumIters_SPFGMR(SUNLinearSolver S) - realtype SUNLinSolResNorm_SPFGMR(SUNLinearSolver S) + sunrealtype SUNLinSolResNorm_SPFGMR(SUNLinearSolver S) N_Vector SUNLinSolResid_SPFGMR(SUNLinearSolver S) sunindextype SUNLinSolLastFlag_SPFGMR(SUNLinearSolver S) int SUNLinSolSpace_SPFGMR(SUNLinearSolver S, long int *lenrwLS, @@ -283,30 +283,30 @@ cdef extern from "sunlinsol/sunlinsol_spgmr.h": int gstype int max_restarts int numiters - realtype resnorm + sunrealtype resnorm long int last_flag - ATimesFn ATimes + SUNATimesFn ATimes void* ATData - PSetupFn Psetup - PSolveFn Psolve + SUNPSetupFn Psetup + SUNPSolveFn Psolve void* PData N_Vector s1 N_Vector s2 N_Vector *V - realtype **Hes - realtype *givens + sunrealtype **Hes + sunrealtype *givens N_Vector xcor - realtype *yg + sunrealtype *yg N_Vector vtemp - realtype *cv + sunrealtype *cv N_Vector *Xv ctypedef _SUNLinearSolverContent_SPGMR *SUNLinearSolverContent_SPGMR - SUNLinearSolver SUNLinSol_SPGMR(N_Vector y, int pretype, int maxl) + SUNLinearSolver SUNLinSol_SPGMR(N_Vector y, int pretype, int maxl, SUNContext sunctx) int SUNLinSol_SPGMRSetPrecType(SUNLinearSolver S, int pretype) int SUNLinSol_SPGMRSetGSType(SUNLinearSolver S, int gstype) int SUNLinSol_SPGMRSetMaxRestarts(SUNLinearSolver S, int maxrs) @@ -320,16 +320,16 @@ cdef extern from "sunlinsol/sunlinsol_spgmr.h": SUNLinearSolver_ID SUNLinSolGetID_SPGMR(SUNLinearSolver S) int SUNLinSolInitialize_SPGMR(SUNLinearSolver S) int SUNLinSolSetATimes_SPGMR(SUNLinearSolver S, void* A_data, - ATimesFn ATimes) + SUNATimesFn ATimes) int SUNLinSolSetPreconditioner_SPGMR(SUNLinearSolver S, void* P_data, - PSetupFn Pset, PSolveFn Psol) + SUNPSetupFn Pset, SUNPSolveFn Psol) int SUNLinSolSetScalingVectors_SPGMR(SUNLinearSolver S, N_Vector s1, N_Vector s2) int SUNLinSolSetup_SPGMR(SUNLinearSolver S, SUNMatrix A) int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNMatrix A, - N_Vector x, N_Vector b, realtype tol) + N_Vector x, N_Vector b, sunrealtype tol) int SUNLinSolNumIters_SPGMR(SUNLinearSolver S) - realtype SUNLinSolResNorm_SPGMR(SUNLinearSolver S) + sunrealtype SUNLinSolResNorm_SPGMR(SUNLinearSolver S) N_Vector SUNLinSolResid_SPGMR(SUNLinearSolver S) sunindextype SUNLinSolLastFlag_SPGMR(SUNLinearSolver S) int SUNLinSolSpace_SPGMR(SUNLinearSolver S, long int *lenrwLS, @@ -343,13 +343,13 @@ cdef extern from "sunlinsol/sunlinsol_sptfqmr.h": int maxl int pretype int numiters - realtype resnorm + sunrealtype resnorm long int last_flag - ATimesFn ATimes + SUNATimesFn ATimes void* ATData - PSetupFn Psetup - PSolveFn Psolve + SUNPSetupFn Psetup + SUNPSolveFn Psolve void* PData N_Vector s1 @@ -367,7 +367,7 @@ cdef extern from "sunlinsol/sunlinsol_sptfqmr.h": ctypedef _SUNLinearSolverContent_SPTFQMR *SUNLinearSolverContent_SPTFQMR - SUNLinearSolver SUNLinSol_SPTFQMR(N_Vector y, int pretype, int maxl) + SUNLinearSolver SUNLinSol_SPTFQMR(N_Vector y, int pretype, int maxl, SUNContext sunctx) int SUNLinSol_SPTFQMRSetPrecType(SUNLinearSolver S, int pretype) int SUNLinSol_SPTFQMRSetMaxl(SUNLinearSolver S, int maxl) SUNLinearSolver SUNSPTFQMR(N_Vector y, int pretype, int maxl) # deprecated @@ -378,16 +378,16 @@ cdef extern from "sunlinsol/sunlinsol_sptfqmr.h": SUNLinearSolver_ID SUNLinSolGetID_SPTFQMR(SUNLinearSolver S) int SUNLinSolInitialize_SPTFQMR(SUNLinearSolver S) int SUNLinSolSetATimes_SPTFQMR(SUNLinearSolver S, void* A_data, - ATimesFn ATimes) + SUNATimesFn ATimes) int SUNLinSolSetPreconditioner_SPTFQMR(SUNLinearSolver S, void* P_data, - PSetupFn Pset, PSolveFn Psol) + SUNPSetupFn Pset, SUNPSolveFn Psol) int SUNLinSolSetScalingVectors_SPTFQMR(SUNLinearSolver S, N_Vector s1, N_Vector s2) int SUNLinSolSetup_SPTFQMR(SUNLinearSolver S, SUNMatrix A) int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNMatrix A, - N_Vector x, N_Vector b, realtype tol) + N_Vector x, N_Vector b, sunrealtype tol) int SUNLinSolNumIters_SPTFQMR(SUNLinearSolver S) - realtype SUNLinSolResNorm_SPTFQMR(SUNLinearSolver S) + sunrealtype SUNLinSolResNorm_SPTFQMR(SUNLinearSolver S) N_Vector SUNLinSolResid_SPTFQMR(SUNLinearSolver S) long int SUNLinSolLastFlag_SPTFQMR(SUNLinearSolver S) int SUNLinSolSpace_SPTFQMR(SUNLinearSolver S, long int *lenrwLS, @@ -406,7 +406,7 @@ cdef extern from "sunlinsol/sunlinsol_sptfqmr.h": # sunindextype *perm_r, *perm_c # sunindextype N # int num_threads -# realtype diag_pivot_thresh +# sunrealtype diag_pivot_thresh # int ordering # superlumt_options_t *options # @@ -419,7 +419,7 @@ cdef extern from "sunlinsol/sunlinsol_sptfqmr.h": # int SUNLinSolInitialize_SuperLUMT(SUNLinearSolver S) # int SUNLinSolSetup_SuperLUMT(SUNLinearSolver S, SUNMatrix A) # int SUNLinSolSolve_SuperLUMT(SUNLinearSolver S, SUNMatrix A, -# N_Vector x, N_Vector b, realtype tol) +# N_Vector x, N_Vector b, sunrealtype tol) # long int SUNLinSolLastFlag_SuperLUMT(SUNLinearSolver S) # int SUNLinSolSpace_SuperLUMT(SUNLinearSolver S, long int *lenrwLS, # long int *leniwLS) diff --git a/scikits/odes/sundials/c_sunmatrix.pxd b/scikits/odes/sundials/c_sunmatrix.pxd index 43af4b4f..7734b382 100644 --- a/scikits/odes/sundials/c_sunmatrix.pxd +++ b/scikits/odes/sundials/c_sunmatrix.pxd @@ -6,27 +6,27 @@ cdef extern from "sunmatrix/sunmatrix_dense.h": cdef struct _SUNMatrixContent_Dense: sunindextype M sunindextype N - realtype *data + sunrealtype *data sunindextype ldata - realtype **cols + sunrealtype **cols ctypedef _SUNMatrixContent_Dense *SUNMatrixContent_Dense - SUNMatrix SUNDenseMatrix(sunindextype M, sunindextype N) + SUNMatrix SUNDenseMatrix(sunindextype M, sunindextype N, SUNContext sunctx) void SUNDenseMatrix_Print(SUNMatrix A, FILE* outfile) sunindextype SUNDenseMatrix_Rows(SUNMatrix A) sunindextype SUNDenseMatrix_Columns(SUNMatrix A) sunindextype SUNDenseMatrix_LData(SUNMatrix A) - realtype* SUNDenseMatrix_Data(SUNMatrix A) - realtype** SUNDenseMatrix_Cols(SUNMatrix A) - realtype* SUNDenseMatrix_Column(SUNMatrix A, sunindextype j) + sunrealtype* SUNDenseMatrix_Data(SUNMatrix A) + sunrealtype** SUNDenseMatrix_Cols(SUNMatrix A) + sunrealtype* SUNDenseMatrix_Column(SUNMatrix A, sunindextype j) SUNMatrix_ID SUNMatGetID_Dense(SUNMatrix A) SUNMatrix SUNMatClone_Dense(SUNMatrix A) void SUNMatDestroy_Dense(SUNMatrix A) int SUNMatZero_Dense(SUNMatrix A) int SUNMatCopy_Dense(SUNMatrix A, SUNMatrix B) - int SUNMatScaleAdd_Dense(realtype c, SUNMatrix A, SUNMatrix B) - int SUNMatScaleAddI_Dense(realtype c, SUNMatrix A) + int SUNMatScaleAdd_Dense(sunrealtype c, SUNMatrix A, SUNMatrix B) + int SUNMatScaleAddI_Dense(sunrealtype c, SUNMatrix A) int SUNMatMatvec_Dense(SUNMatrix A, N_Vector x, N_Vector y) int SUNMatSpace_Dense(SUNMatrix A, long int *lenrw, long int *leniw) @@ -40,17 +40,17 @@ cdef extern from "sunmatrix/sunmatrix_band.h": sunindextype mu sunindextype ml sunindextype s_mu - realtype *data + sunrealtype *data sunindextype ldata - realtype **cols + sunrealtype **cols ctypedef _SUNMatrixContent_Band *SUNMatrixContent_Band SUNMatrix SUNBandMatrix(sunindextype N, sunindextype mu, - sunindextype ml) + sunindextype ml, SUNContext sunctx) SUNMatrix SUNBandMatrixStorage(sunindextype N, sunindextype mu, - sunindextype ml, sunindextype smu) + sunindextype ml, sunindextype smu, SUNContext sunctx) void SUNBandMatrix_Print(SUNMatrix A, FILE* outfile) @@ -60,17 +60,17 @@ cdef extern from "sunmatrix/sunmatrix_band.h": sunindextype SUNBandMatrix_UpperBandwidth(SUNMatrix A) sunindextype SUNBandMatrix_StoredUpperBandwidth(SUNMatrix A) sunindextype SUNBandMatrix_LDim(SUNMatrix A) - realtype* SUNBandMatrix_Data(SUNMatrix A) - realtype** SUNBandMatrix_Cols(SUNMatrix A) - realtype* SUNBandMatrix_Column(SUNMatrix A, sunindextype j) + sunrealtype* SUNBandMatrix_Data(SUNMatrix A) + sunrealtype** SUNBandMatrix_Cols(SUNMatrix A) + sunrealtype* SUNBandMatrix_Column(SUNMatrix A, sunindextype j) SUNMatrix_ID SUNMatGetID_Band(SUNMatrix A) SUNMatrix SUNMatClone_Band(SUNMatrix A) void SUNMatDestroy_Band(SUNMatrix A) int SUNMatZero_Band(SUNMatrix A) int SUNMatCopy_Band(SUNMatrix A, SUNMatrix B) - int SUNMatScaleAdd_Band(realtype c, SUNMatrix A, SUNMatrix B) - int SUNMatScaleAddI_Band(realtype c, SUNMatrix A) + int SUNMatScaleAdd_Band(sunrealtype c, SUNMatrix A, SUNMatrix B) + int SUNMatScaleAddI_Band(sunrealtype c, SUNMatrix A) int SUNMatMatvec_Band(SUNMatrix A, N_Vector x, N_Vector y) int SUNMatSpace_Band(SUNMatrix A, long int *lenrw, long int *leniw) @@ -82,7 +82,7 @@ cdef extern from "sunmatrix/sunmatrix_sparse.h": sunindextype N sunindextype NNZ sunindextype NP - realtype *data + sunrealtype *data int sparsetype sunindextype *indexvals sunindextype *indexptrs @@ -98,9 +98,9 @@ cdef extern from "sunmatrix/sunmatrix_sparse.h": SUNMatrix SUNSparseMatrix(sunindextype M, sunindextype N, sunindextype NNZ, int sparsetype) - SUNMatrix SUNSparseFromDenseMatrix(SUNMatrix A, realtype droptol, + SUNMatrix SUNSparseFromDenseMatrix(SUNMatrix A, sunrealtype droptol, int sparsetype) - SUNMatrix SUNSparseFromBandMatrix(SUNMatrix A, realtype droptol, + SUNMatrix SUNSparseFromBandMatrix(SUNMatrix A, sunrealtype droptol, int sparsetype) int SUNSparseMatrix_Realloc(SUNMatrix A) void SUNSparseMatrix_Print(SUNMatrix A, FILE* outfile) @@ -110,7 +110,7 @@ cdef extern from "sunmatrix/sunmatrix_sparse.h": sunindextype SUNSparseMatrix_NNZ(SUNMatrix A) sunindextype SUNSparseMatrix_NP(SUNMatrix A) int SUNSparseMatrix_SparseType(SUNMatrix A) - realtype* SUNSparseMatrix_Data(SUNMatrix A) + sunrealtype* SUNSparseMatrix_Data(SUNMatrix A) sunindextype* SUNSparseMatrix_IndexValues(SUNMatrix A) sunindextype* SUNSparseMatrix_IndexPointers(SUNMatrix A) @@ -119,7 +119,7 @@ cdef extern from "sunmatrix/sunmatrix_sparse.h": void SUNMatDestroy_Sparse(SUNMatrix A) int SUNMatZero_Sparse(SUNMatrix A) int SUNMatCopy_Sparse(SUNMatrix A, SUNMatrix B) - int SUNMatScaleAdd_Sparse(realtype c, SUNMatrix A, SUNMatrix B) - int SUNMatScaleAddI_Sparse(realtype c, SUNMatrix A) + int SUNMatScaleAdd_Sparse(sunrealtype c, SUNMatrix A, SUNMatrix B) + int SUNMatScaleAddI_Sparse(sunrealtype c, SUNMatrix A) int SUNMatMatvec_Sparse(SUNMatrix A, N_Vector x, N_Vector y) int SUNMatSpace_Sparse(SUNMatrix A, long int *lenrw, long int *leniw) diff --git a/scikits/odes/sundials/c_sunnonlinsol.pxd b/scikits/odes/sundials/c_sunnonlinsol.pxd index 9cf6ff57..556c57c3 100644 --- a/scikits/odes/sundials/c_sunnonlinsol.pxd +++ b/scikits/odes/sundials/c_sunnonlinsol.pxd @@ -14,7 +14,7 @@ cdef extern from "sunnonlinsol/sunnonlinsol_newton.h": SUNNonlinSolConvTestFn CTest N_Vector delta - booleantype jcur + sunbooleantype jcur int curiter int maxiters long int niters @@ -23,15 +23,15 @@ cdef extern from "sunnonlinsol/sunnonlinsol_newton.h": ctypedef _SUNNonlinearSolverContent_Newton *SUNNonlinearSolverContent_Newton; - SUNNonlinearSolver SUNNonlinSol_Newton(N_Vector y) - SUNNonlinearSolver SUNNonlinSol_NewtonSens(int count, N_Vector y) + SUNNonlinearSolver SUNNonlinSol_Newton(N_Vector y, SUNContext sunctx) + SUNNonlinearSolver SUNNonlinSol_NewtonSens(int count, N_Vector y, SUNContext sunctx) SUNNonlinearSolver_Type SUNNonlinSolGetType_Newton(SUNNonlinearSolver NLS) int SUNNonlinSolInitialize_Newton(SUNNonlinearSolver NLS) int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, N_Vector y0, - N_Vector y, N_Vector w, realtype tol, - booleantype callLSetup, void *mem) + N_Vector y, N_Vector w, sunrealtype tol, + sunbooleantype callLSetup, void *mem) int SUNNonlinSolFree_Newton(SUNNonlinearSolver NLS) int SUNNonlinSolSetSysFn_Newton(SUNNonlinearSolver NLS, @@ -64,9 +64,9 @@ cdef extern from "sunnonlinsol/sunnonlinsol_fixedpoint.h": int m int *imap - realtype *R - realtype *gamma - realtype *cvals + sunrealtype *R + sunrealtype *gamma + sunrealtype *cvals N_Vector *df N_Vector *dg N_Vector *q @@ -84,16 +84,16 @@ cdef extern from "sunnonlinsol/sunnonlinsol_fixedpoint.h": ctypedef _SUNNonlinearSolverContent_FixedPoint *SUNNonlinearSolverContent_FixedPoint - SUNNonlinearSolver SUNNonlinSol_FixedPoint(N_Vector y, int m) - SUNNonlinearSolver SUNNonlinSol_FixedPointSens(int count, N_Vector y, int m) + SUNNonlinearSolver SUNNonlinSol_FixedPoint(N_Vector y, int m, SUNContext sunctx) + SUNNonlinearSolver SUNNonlinSol_FixedPointSens(int count, N_Vector y, int m, SUNContext sunctx) SUNNonlinearSolver_Type SUNNonlinSolGetType_FixedPoint(SUNNonlinearSolver NLS) int SUNNonlinSolInitialize_FixedPoint(SUNNonlinearSolver NLS) int SUNNonlinSolSolve_FixedPoint(SUNNonlinearSolver NLS, N_Vector y0, N_Vector y, - N_Vector w, realtype tol, - booleantype callSetup, void *mem) + N_Vector w, sunrealtype tol, + sunbooleantype callSetup, void *mem) int SUNNonlinSolFree_FixedPoint(SUNNonlinearSolver NLS) int SUNNonlinSolSetSysFn_FixedPoint(SUNNonlinearSolver NLS, @@ -132,14 +132,14 @@ cdef extern from "sunnonlinsol/sunnonlinsol_fixedpoint.h": # # ctypedef _SUNNonlinearSolverContent_PetscSNES *SUNNonlinearSolverContent_PetscSNES # -# SUNNonlinearSolver SUNNonlinSol_PetscSNES(N_Vector y, SNES snes) +# SUNNonlinearSolver SUNNonlinSol_PetscSNES(N_Vector y, SNES snes, SUNContext sunctx) # SUNNonlinearSolver_Type SUNNonlinSolGetType_PetscSNES(SUNNonlinearSolver NLS) # # int SUNNonlinSolInitialize_PetscSNES(SUNNonlinearSolver NLS) # int SUNNonlinSolSolve_PetscSNES(SUNNonlinearSolver NLS, # N_Vector y0, N_Vector y, -# N_Vector w, realtype tol, -# booleantype callLSetup, void* mem) +# N_Vector w, sunrealtype tol, +# sunbooleantype callLSetup, void* mem) # # int SUNNonlinSolSetSysFn_PetscSNES(SUNNonlinearSolver NLS, # SUNNonlinSolSysFn SysFn) diff --git a/scikits/odes/sundials/common_defs.pxd b/scikits/odes/sundials/common_defs.pxd index 26e29847..44fb27bf 100644 --- a/scikits/odes/sundials/common_defs.pxd +++ b/scikits/odes/sundials/common_defs.pxd @@ -1,5 +1,5 @@ cimport numpy as np -from .c_sundials cimport N_Vector, DlsMat, SUNMatrix +from .c_sundials cimport N_Vector, SUNDlsMat, SUNMatrix include "sundials_config.pxi" diff --git a/scikits/odes/sundials/common_defs.pyx b/scikits/odes/sundials/common_defs.pyx index 1b381d32..73f098d1 100644 --- a/scikits/odes/sundials/common_defs.pyx +++ b/scikits/odes/sundials/common_defs.pyx @@ -4,7 +4,7 @@ import numpy as np cimport numpy as np import inspect from .c_sundials cimport ( - realtype, sunindextype, N_Vector, DlsMat, booleantype, + sunrealtype, sunindextype, N_Vector, SUNDlsMat, sunbooleantype, SUNMatrix, SUNMatGetID, SUNMATRIX_DENSE, SUNMATRIX_BAND, SUNMATRIX_SPARSE, SUNMATRIX_CUSTOM, ) @@ -43,73 +43,73 @@ else: has_lapack = SUNDIALS_BLAS_LAPACK -ctypedef realtype *DlsMat_col -ctypedef realtype *nv_content_data_s +ctypedef sunrealtype *DlsMat_col +ctypedef sunrealtype *nv_content_data_s # N_Vector content access functions # These lack an equivalent we can use from cython -cdef inline realtype get_nv_ith_s(nv_content_data_s vcd_s, int i): +cdef inline sunrealtype get_nv_ith_s(nv_content_data_s vcd_s, int i): return vcd_s[i] cdef inline void set_nv_ith_s(nv_content_data_s vcd_s, int i, - realtype new_value): + sunrealtype new_value): vcd_s[i] = new_value # Dense matrix: access functions -cdef inline int get_dense_N(DlsMat A): +cdef inline int get_dense_N(SUNDlsMat A): return A.N -cdef inline int get_dense_M(DlsMat A): +cdef inline int get_dense_M(SUNDlsMat A): return A.M -cdef inline int get_band_mu(DlsMat A): +cdef inline int get_band_mu(SUNDlsMat A): return A.mu -cdef inline int get_band_ml(DlsMat A): +cdef inline int get_band_ml(SUNDlsMat A): return A.ml -cdef inline realtype* get_dense_col(DlsMat A, int j): +cdef inline sunrealtype* get_dense_col(SUNDlsMat A, int j): return (A.cols)[j] -cdef inline void set_dense_col(DlsMat A, int j, realtype *data): +cdef inline void set_dense_col(SUNDlsMat A, int j, sunrealtype *data): (A.cols)[j] = data -cdef inline realtype get_dense_element(DlsMat A, int i, int j): +cdef inline sunrealtype get_dense_element(SUNDlsMat A, int i, int j): return (A.cols)[j][i] -cdef inline void set_dense_element(DlsMat A, int i, int j, realtype aij): +cdef inline void set_dense_element(SUNDlsMat A, int i, int j, sunrealtype aij): (A.cols)[j][i] = aij # Band matrix access functions -cdef inline DlsMat_col get_band_col(DlsMat A, int j): +cdef inline DlsMat_col get_band_col(SUNDlsMat A, int j): return ((A.cols)[j] + (A.s_mu)) -cdef inline void set_band_col(DlsMat A, int j, realtype *data): +cdef inline void set_band_col(SUNDlsMat A, int j, sunrealtype *data): ((A.cols)[j]) = data -cdef inline realtype get_band_col_elem(DlsMat_col col_j, int i, int j): +cdef inline sunrealtype get_band_col_elem(DlsMat_col col_j, int i, int j): return col_j[(i)-(j)] -cdef inline void set_band_col_elem(DlsMat_col col_j, int i, int j, realtype aij): +cdef inline void set_band_col_elem(DlsMat_col col_j, int i, int j, sunrealtype aij): col_j[(i)-(j)] = aij -cdef inline realtype get_band_element(DlsMat A, int i, int j): +cdef inline sunrealtype get_band_element(SUNDlsMat A, int i, int j): return ((A.cols)[j][(i)-(j)+(A.s_mu)]) -cdef inline void set_band_element(DlsMat A, int i, int j, realtype aij): +cdef inline void set_band_element(SUNDlsMat A, int i, int j, sunrealtype aij): (A.cols)[j][(i)-(j)+(A.s_mu)] = aij diff --git a/scikits/odes/sundials/cvode.pxd b/scikits/odes/sundials/cvode.pxd index aadcd131..b3773bda 100644 --- a/scikits/odes/sundials/cvode.pxd +++ b/scikits/odes/sundials/cvode.pxd @@ -1,7 +1,7 @@ #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION cimport numpy as np -from .c_sundials cimport N_Vector, realtype +from .c_sundials cimport N_Vector, sunrealtype, SUNContext from .common_defs cimport DTYPE_t, INDEX_TYPE_t cdef class CV_RhsFunction: @@ -127,6 +127,7 @@ cdef class CV_data: cdef class CVODE: cdef N_Vector atol cdef void* _cv_mem + cdef SUNContext sunctx cdef dict options cdef bint parallel_implementation, initialized, _old_api, _step_compute, _validate_flags cdef CV_data aux_data @@ -141,6 +142,7 @@ cdef class CVODE: cdef int verbosity # Functions + cpdef _create_suncontext(self) cpdef _init_step(self, DTYPE_t t0, np.ndarray[DTYPE_t, ndim=1] y0) cpdef _reinit_IC(self, DTYPE_t t0, np.ndarray[DTYPE_t, ndim=1] y0) diff --git a/scikits/odes/sundials/cvode.pyx b/scikits/odes/sundials/cvode.pyx index 48eb50de..91ce51ca 100644 --- a/scikits/odes/sundials/cvode.pyx +++ b/scikits/odes/sundials/cvode.pyx @@ -1,10 +1,7 @@ # cython: embedsignature=True from cpython.exc cimport PyErr_CheckSignals from collections import namedtuple -try: - from enum import IntEnum -except ImportError: - from enum34 import IntEnum +from enum import IntEnum import inspect from warnings import warn @@ -18,7 +15,9 @@ from . import ( _get_num_args, ) -from .c_sundials cimport realtype, N_Vector +from .c_sundials cimport ( + sunrealtype, N_Vector, SUNContext_Create, SUNContext_Free, +) from .c_nvector_serial cimport * from .c_sunmatrix cimport * from .c_sunlinsol cimport * @@ -155,7 +154,7 @@ cdef class CV_WrapRhsFunction(CV_RhsFunction): user_flag = 0 return user_flag -cdef int _rhsfn(realtype tt, N_Vector yy, N_Vector yp, +cdef int _rhsfn(sunrealtype tt, N_Vector yy, N_Vector yp, void *auxiliary_data) except? -1: """ function with the signature of CVRhsFn, that calls python Rhs """ cdef np.ndarray[DTYPE_t, ndim=1] yy_tmp, yp_tmp @@ -221,7 +220,7 @@ cdef class CV_WrapRootFunction(CV_RootFunction): user_flag = 0 return user_flag -cdef int _rootfn(realtype t, N_Vector y, realtype *gout, void *auxiliary_data) except? -1: +cdef int _rootfn(sunrealtype t, N_Vector y, sunrealtype *gout, void *auxiliary_data) except? -1: """ function with the signature of CVRootFn """ aux_data = auxiliary_data @@ -242,7 +241,7 @@ cdef int _rootfn(realtype t, N_Vector y, realtype *gout, void *auxiliary_data) e raise NotImplemented else: for i in np.arange(len(g_tmp)): - gout[i] = g_tmp[i] + gout[i] = g_tmp[i] return user_flag @@ -297,11 +296,11 @@ cdef class CV_WrapJacRhsFunction(CV_JacRhsFunction): user_flag = 0 return user_flag -cdef int _jacdense(realtype tt, +cdef int _jacdense(sunrealtype tt, N_Vector yy, N_Vector ff, SUNMatrix Jac, void *auxiliary_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) except? -1: - """function with the signature of CVDlsJacFn that calls python Jac + """function with the signature of CVodeJacFn that calls python Jac Note: signature of Jac is SUNMatrix """ cdef np.ndarray[DTYPE_t, ndim=1] yy_tmp, ff_tmp @@ -386,8 +385,8 @@ class MutableBool(object): def __init__(self, value): self.value = value -cdef int _prec_setupfn(realtype tt, N_Vector yy, N_Vector ff, booleantype jok, - booleantype *jcurPtr, realtype gamma, +cdef int _prec_setupfn(sunrealtype tt, N_Vector yy, N_Vector ff, sunbooleantype jok, + sunbooleantype *jcurPtr, sunrealtype gamma, void *auxiliary_data) except -1: """ function with the signature of CVLsPrecSetupFn, that calls python function """ cdef np.ndarray[DTYPE_t, ndim=1] yy_tmp @@ -468,8 +467,8 @@ cdef class CV_WrapPrecSolveFunction(CV_PrecSolveFunction): user_flag = 0 return user_flag -cdef int _prec_solvefn(realtype tt, N_Vector yy, N_Vector ff, N_Vector r, - N_Vector z, realtype gamma, realtype delta, int lr, +cdef int _prec_solvefn(sunrealtype tt, N_Vector yy, N_Vector ff, N_Vector r, + N_Vector z, sunrealtype gamma, sunrealtype delta, int lr, void *auxiliary_data) except? -1: """ function with the signature of CVLsPrecSolveFn, that calls python function """ cdef np.ndarray[DTYPE_t, ndim=1] yy_tmp, r_tmp, z_tmp @@ -552,9 +551,9 @@ cdef class CV_WrapJacTimesVecFunction(CV_JacTimesVecFunction): user_flag = 0 return user_flag -cdef int _jac_times_vecfn(N_Vector v, N_Vector Jv, realtype t, N_Vector y, +cdef int _jac_times_vecfn(N_Vector v, N_Vector Jv, sunrealtype t, N_Vector y, N_Vector fy, void *user_data, N_Vector tmp) except? -1: - """ function with the signature of CVSpilsJacTimesVecFn, that calls python function """ + """ function with the signature of CVodeJacTimesVecFn, that calls python function """ cdef np.ndarray[DTYPE_t, ndim=1] y_tmp, v_tmp, Jv_tmp aux_data = user_data @@ -633,9 +632,9 @@ cdef class CV_WrapJacTimesSetupFunction(CV_JacTimesSetupFunction): user_flag = 0 return user_flag -cdef int _jac_times_setupfn(realtype t, N_Vector y, N_Vector fy, +cdef int _jac_times_setupfn(sunrealtype t, N_Vector y, N_Vector fy, void *user_data) except? -1: - """ function with the signature of CVSpilsJacTimesSetupFn, that calls python function """ + """ function with the signature of CVodeJacTimesSetupFn, that calls python function """ cdef np.ndarray[DTYPE_t, ndim=1] y_tmp, fy_tmp aux_data = user_data @@ -794,8 +793,14 @@ cdef class CVODE: self._validate_flags = False # don't validate by default self.set_options(rfn=Rfn, **options) self._cv_mem = NULL + self.sunctx = NULL self.initialized = False + cpdef _create_suncontext(self): + cdef int res = SUNContext_Create(NULL, &self.sunctx) + if res < 0: + raise RuntimeError("Failed to create Sundials context") + def set_options(self, **options): """ Reads the options list and assigns values for the solver. @@ -1140,8 +1145,8 @@ cdef class CVODE: self.atol = NULL if np.isscalar(opts_atol): - flag = CVodeSStolerances(cv_mem, opts_rtol, - opts_atol) + flag = CVodeSStolerances(cv_mem, opts_rtol, + opts_atol) else: np_atol = np.asarray(opts_atol, dtype=DTYPE) if len(np_atol) != self.N: @@ -1152,8 +1157,8 @@ cdef class CVODE: if self.parallel_implementation: raise NotImplemented else: - atol = N_VMake_Serial(self.N, np_atol.data) - flag = CVodeSVtolerances(cv_mem, opts_rtol, atol) + atol = N_VMake_Serial(self.N, np_atol.data, self.sunctx) + flag = CVodeSVtolerances(cv_mem, opts_rtol, atol) self.atol = atol @@ -1168,7 +1173,7 @@ cdef class CVODE: opts_tstop = options['tstop'] self.options['tstop'] = opts_tstop if (not opts_tstop is None) and (opts_tstop > 0.): - flag = CVodeSetStopTime(cv_mem, opts_tstop) + flag = CVodeSetStopTime(cv_mem, opts_tstop) if flag == CV_ILL_INPUT: raise ValueError('CVodeSetStopTime::Stop value is beyond ' 'current value.') @@ -1299,13 +1304,16 @@ cdef class CVODE: N_VDestroy(self.y) N_VDestroy(self.yp) + if self.sunctx is NULL: + self._create_suncontext() + # Initialize y0, y, yp if self.parallel_implementation: raise NotImplemented else: - self.y0 = N_VMake_Serial(N, y0.data) + self.y0 = N_VMake_Serial(N, y0.data, self.sunctx) self.y = N_VClone(self.y0) - self.yp = N_VNew_Serial(N) + self.yp = N_VNew_Serial(N, self.sunctx) cdef int flag cdef void* cv_mem = self._cv_mem @@ -1313,15 +1321,15 @@ cdef class CVODE: if (cv_mem is NULL) or (self.N != N): if (not cv_mem is NULL): CVodeFree(&cv_mem) - cv_mem = CVodeCreate(lmm) + cv_mem = CVodeCreate(lmm, self.sunctx) if cv_mem is NULL: raise MemoryError('CVodeCreate:MemoryError: Could not create ' 'cv_mem object') self._cv_mem = cv_mem - flag = CVodeInit(cv_mem, _rhsfn, t0, self.y0) + flag = CVodeInit(cv_mem, _rhsfn, t0, self.y0) elif self.N == N: - flag = CVodeReInit(cv_mem, t0, self.y0) + flag = CVodeReInit(cv_mem, t0, self.y0) else: raise ValueError('CVodeInit:Error: You should not be here...') if flag == CV_ILL_INPUT: @@ -1434,11 +1442,11 @@ cdef class CVODE: if lmm_type == 'bdf': CVodeSetStabLimDet(cv_mem, opts['bdf_stability_detection']) if opts['first_step_size'] > 0.: - CVodeSetInitStep(cv_mem, opts['first_step_size']) + CVodeSetInitStep(cv_mem, opts['first_step_size']) if (opts['min_step_size'] > 0.): - CVodeSetMinStep(cv_mem, opts['min_step_size']) + CVodeSetMinStep(cv_mem, opts['min_step_size']) if opts['max_step_size'] > 0.: - flag = CVodeSetMaxStep(cv_mem, opts['max_step_size']) + flag = CVodeSetMaxStep(cv_mem, opts['max_step_size']) if flag == CV_ILL_INPUT: raise ValueError('CVodeSetMaxStep: max_step_size is negative ' 'or smaller than min_step_size.') @@ -1453,8 +1461,8 @@ cdef class CVODE: linsolver = opts['linsolver'].lower() if nonlinsolver == 'newton': if linsolver == 'dense': - A = SUNDenseMatrix(N, N) - LS = SUNDenseLinearSolver(self.y0, A) + A = SUNDenseMatrix(N, N, self.sunctx) + LS = SUNLinSol_Dense(self.y0, A, self.sunctx) # check if memory was allocated if (A == NULL or LS == NULL): raise ValueError('Could not allocate matrix or linear solver') @@ -1469,8 +1477,8 @@ cdef class CVODE: raise ValueError('CVodeSetLinearSolver failed with code {}' .format(flag)) elif linsolver == 'band': - A = SUNBandMatrix(N, opts['uband'], opts['lband']); - LS = SUNBandLinearSolver(self.y0, A); + A = SUNBandMatrix(N, opts['uband'], opts['lband'], self.sunctx); + LS = SUNLinSol_Band(self.y0, A, self.sunctx); if (A == NULL or LS == NULL): raise ValueError('Could not allocate matrix or linear solver') flag = CVodeSetLinearSolver(cv_mem, LS, A) @@ -1497,27 +1505,27 @@ cdef class CVODE: or (linsolver == 'sptfqmr')): precond_type = opts['precond_type'].lower() if precond_type == 'none': - pretype = PREC_NONE + pretype = SUN_PREC_NONE elif precond_type == 'left': - pretype = PREC_LEFT + pretype = SUN_PREC_LEFT elif precond_type == 'right': - pretype = PREC_RIGHT + pretype = SUN_PREC_RIGHT elif precond_type == 'both': - pretype = PREC_BOTH + pretype = SUN_PREC_BOTH else: raise ValueError('LinSolver::Precondition: Unknown type: %s' % opts['precond_type']) if linsolver == 'spgmr': - LS = SUNSPGMR(self.y0, pretype, opts['maxl']); + LS = SUNLinSol_SPGMR(self.y0, pretype, opts['maxl'], self.sunctx); if LS == NULL: raise ValueError('Could not allocate linear solver') elif linsolver == 'spbcgs': - LS = SUNSPBCGS(self.y0, pretype, opts['maxl']); + LS = SUNLinSol_SPBCGS(self.y0, pretype, opts['maxl'], self.sunctx); if LS == NULL: raise ValueError('Could not allocate linear solver') elif linsolver == 'sptfqmr': - LS = SUNSPTFQMR(self.y0, pretype, opts['maxl']); + LS = SUNLinSol_SPTFQMR(self.y0, pretype, opts['maxl'], self.sunctx); if LS == NULL: raise ValueError('Could not allocate linear solver') else: @@ -1525,7 +1533,7 @@ cdef class CVODE: flag = CVodeSetLinearSolver(cv_mem, LS, NULL); if flag == CVLS_MEM_FAIL: - raise MemoryError('LinSolver:CVSpils memory allocation ' + raise MemoryError('LinSolver:CVode memory allocation ' 'error.') elif flag != CVLS_SUCCESS: raise ValueError('CVodeSetLinearSolver failed with code {}' @@ -1534,7 +1542,7 @@ cdef class CVODE: #flag = SUNSPGMRSetGSType(LS, gstype); # TODO make option - #flag = CVSpilsSetEpsLin(cvode_mem, DELT); + #flag = CVodeSetEpsLin(cvode_mem, DELT); if self.aux_data.prec_solvefn: if self.aux_data.prec_setupfn: flag = CVodeSetPreconditioner(cv_mem, _prec_setupfn, _prec_solvefn) @@ -1561,12 +1569,12 @@ cdef class CVODE: raise ValueError('LinSolver: The cvspils linear solver has ' 'not been initialized.') elif flag != CVLS_SUCCESS: - raise ValueError('CVSpilsSetJacTimes failed with code {}' + raise ValueError('CVodeSetJacTimes failed with code {}' .format(flag)) else: if SUNDIALS_BLAS_LAPACK: if linsolver == 'lapackdense': - A = SUNDenseMatrix(N, N) + A = SUNDenseMatrix(N, N, self.sunctx) LS = SUNLapackDense(self.y0, A) # check if memory was allocated if (A == NULL or LS == NULL): @@ -1582,7 +1590,7 @@ cdef class CVODE: raise ValueError('CVodeSetLinearSolver failed with code {}' .format(flag)) elif linsolver == 'lapackband': - A = SUNBandMatrix(N, opts['uband'], opts['lband']) + A = SUNBandMatrix(N, opts['uband'], opts['lband'], self.sunctx) LS = SUNLapackBand(self.y0, A) if (A == NULL or LS == NULL): raise ValueError('Could not allocate matrix or linear solver') @@ -1606,7 +1614,7 @@ cdef class CVODE: % opts['linsolver']) elif nonlinsolver == 'fixedpoint': # create fixed point nonlinear solver object - NLS = SUNNonlinSol_FixedPoint(self.y0, 0); + NLS = SUNNonlinSol_FixedPoint(self.y0, 0, self.sunctx); # attach nonlinear solver object to CVode flag = CVodeSetNonlinearSolver(cv_mem, NLS) if flag != CV_SUCCESS: @@ -1625,7 +1633,7 @@ cdef class CVODE: ) else: self.aux_data.jac_tmp = np.empty((len(y0), len(y0)), DTYPE) - CVDlsSetJacFn(cv_mem, _jacdense) + CVodeSetJacFn(cv_mem, _jacdense) #we test if jac don't give errors due to bad coding, as #cvode will ignore errors, it only checks return value (0 or 1 for error) @@ -1705,11 +1713,11 @@ cdef class CVODE: cdef INDEX_TYPE_t N N = len(y0) if N == self.N: - self.y0 = N_VMake_Serial(N, y0.data) + self.y0 = N_VMake_Serial(N, y0.data, self.sunctx) else: raise ValueError("Cannot re-init IC with array of unequal lenght.") - flag = CVodeReInit(self._cv_mem, t0, self.y0) + flag = CVodeReInit(self._cv_mem, t0, self.y0) if flag == CV_ILL_INPUT: raise ValueError('CVodeReInit: Ill input') @@ -1806,7 +1814,7 @@ cdef class CVODE: cdef DTYPE_t t cdef int flag = 0 cdef void *cv_mem = self._cv_mem - cdef realtype t_out + cdef sunrealtype t_out cdef N_Vector y = self.y cdef CV_ContinuationFunction onroot = self.options['onroot'] cdef CV_ContinuationFunction ontstop = self.options['ontstop'] @@ -1817,7 +1825,7 @@ cdef class CVODE: t = tspan[idx] while True: - flag = CVode(cv_mem, t, y, &t_out, CV_NORMAL) + flag = CVode(cv_mem, t, y, &t_out, CV_NORMAL) nv_s2ndarray(y, y_last) @@ -1912,19 +1920,19 @@ cdef class CVODE: 'the first call of ''step'' method.') cdef N_Vector y = self.y - cdef realtype t_out + cdef sunrealtype t_out cdef int flagCV if self._old_api: if t>0.0: - flagCV = CVode(self._cv_mem, t, y, &t_out, CV_NORMAL) + flagCV = CVode(self._cv_mem, t, y, &t_out, CV_NORMAL) else: - flagCV = CVode(self._cv_mem, -t, y, &t_out, CV_ONE_STEP) + flagCV = CVode(self._cv_mem, -t, y, &t_out, CV_ONE_STEP) else: if self._step_compute: - flagCV = CVode(self._cv_mem, t, y, &t_out, CV_ONE_STEP) + flagCV = CVode(self._cv_mem, t, y, &t_out, CV_ONE_STEP) else: - flagCV = CVode(self._cv_mem, t, y, &t_out, CV_NORMAL) + flagCV = CVode(self._cv_mem, t, y, &t_out, CV_NORMAL) if self._old_api: warn("Old api is deprecated, move to new api", DeprecationWarning) @@ -2009,7 +2017,7 @@ cdef class CVODE: cdef int flagCV cdef long int nsteps, nfevals, nlinsetups, netfails cdef int qlast, qcur - cdef realtype hinused, hlast, hcur, tcur + cdef sunrealtype hinused, hlast, hcur, tcur # for extra output from SPILS modules (SPGMR, SPBCGS, SPTFQMR) cdef long int npevals, npsolves, njvevals, nliters, nfevalsLS @@ -2028,11 +2036,11 @@ cdef class CVODE: linsolver = self.options['linsolver'].lower() if linsolver == 'spgmr' or linsolver == 'spbcgs' or linsolver == 'sptfqmr': - flagCV = CVSpilsGetNumPrecEvals(self._cv_mem, &npevals) - flagCV = CVSpilsGetNumPrecSolves(self._cv_mem, &npsolves) - flagCV = CVSpilsGetNumJtimesEvals(self._cv_mem, &njvevals) - flagCV = CVSpilsGetNumLinIters(self._cv_mem, &nliters) - flagCV = CVSpilsGetNumRhsEvals(self._cv_mem, &nfevalsLS) + flagCV = CVodeGetNumPrecEvals(self._cv_mem, &npevals) + flagCV = CVodeGetNumPrecSolves(self._cv_mem, &npsolves) + flagCV = CVodeGetNumJtimesEvals(self._cv_mem, &njvevals) + flagCV = CVodeGetNumLinIters(self._cv_mem, &nliters) + flagCV = CVodeGetNumRhsEvals(self._cv_mem, &nfevalsLS) info.update({'NumPrecEvals': npevals, 'NumPrecSolves': npsolves, 'NumJtimesEvals': njvevals, 'NumLinIters': nliters, 'NumRhsEvalsJtimesFD': nfevalsLS}) @@ -2040,9 +2048,10 @@ cdef class CVODE: return info def __dealloc__(self): - if not self._cv_mem is NULL: CVodeFree(&self._cv_mem) + if self._cv_mem is not NULL: CVodeFree(&self._cv_mem) #TODO: when implementing parallel, does N_VDestroy be called separately # for parallel version or it's a generic one? - if not self.y0 is NULL: N_VDestroy(self.y0) - if not self.y is NULL: N_VDestroy(self.y) - if not self.atol is NULL: N_VDestroy(self.atol) + if self.y0 is not NULL: N_VDestroy(self.y0) + if self.y is not NULL: N_VDestroy(self.y) + if self.atol is not NULL: N_VDestroy(self.atol) + if self.sunctx is not NULL: SUNContext_Free(&self.sunctx) diff --git a/scikits/odes/sundials/cvodes.pxd b/scikits/odes/sundials/cvodes.pxd index 2c85dc5c..37ff740c 100644 --- a/scikits/odes/sundials/cvodes.pxd +++ b/scikits/odes/sundials/cvodes.pxd @@ -1,7 +1,7 @@ #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION cimport numpy as np -from .c_sundials cimport N_Vector, realtype +from .c_sundials cimport N_Vector, sunrealtype from .common_defs cimport DTYPE_t, INDEX_TYPE_t from .cvode cimport (CV_RhsFunction, CV_WrapRhsFunction, CV_RootFunction, diff --git a/scikits/odes/sundials/cvodes.pyx b/scikits/odes/sundials/cvodes.pyx index fa243dbf..69905d26 100644 --- a/scikits/odes/sundials/cvodes.pyx +++ b/scikits/odes/sundials/cvodes.pyx @@ -1,10 +1,7 @@ # cython: embedsignature=True from cpython.exc cimport PyErr_CheckSignals from collections import namedtuple -try: - from enum import IntEnum -except ImportError: - from enum34 import IntEnum +from enum import IntEnum import inspect from warnings import warn @@ -18,7 +15,7 @@ from . import ( _get_num_args, ) -from .c_sundials cimport realtype, N_Vector +from .c_sundials cimport sunrealtype, N_Vector from .c_nvector_serial cimport * from .c_sunmatrix cimport * from .c_sunlinsol cimport * diff --git a/scikits/odes/sundials/ida.pxd b/scikits/odes/sundials/ida.pxd index e3a8b97a..554e6044 100644 --- a/scikits/odes/sundials/ida.pxd +++ b/scikits/odes/sundials/ida.pxd @@ -1,5 +1,5 @@ cimport numpy as np -from .c_sundials cimport N_Vector, realtype +from .c_sundials cimport N_Vector, sunrealtype, SUNContext from .common_defs cimport DTYPE_t cdef class IDA_RhsFunction: @@ -114,7 +114,7 @@ cdef class IDA_ContinuationFunction: np.ndarray[DTYPE_t, ndim=1] ydot, IDA solver) -cdef int _res(realtype tt, N_Vector yy, N_Vector yp, N_Vector rr, void *self_obj) +cdef int _res(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector rr, void *self_obj) cdef class IDA_ErrHandler: cpdef evaluate(self, @@ -169,20 +169,20 @@ cdef class IDA: cdef bint initialized cdef void* _ida_mem + cdef SUNContext sunctx cdef dict options cdef bint parallel_implementation cdef bint _old_api, _step_compute, _validate_flags - cdef realtype t, t0 + cdef sunrealtype t, t0 cdef IDA_data aux_data cdef int verbosity - #cdef realtype *y0, *yprime0 + #cdef sunrealtype *y0, *yprime0 # Functions - - #def set_options(self, dict options) + cpdef _create_suncontext(self) cpdef _init_step(self, DTYPE_t t0, np.ndarray[DTYPE_t, ndim=1] y0, np.ndarray[DTYPE_t, ndim=1] yp0, @@ -196,4 +196,3 @@ cdef class IDA: np.ndarray[DTYPE_t, ndim=1] yp0) cpdef _set_runtime_changeable_options(self, object options, bint supress_supported_check=*) - #def step(self, realtype t) diff --git a/scikits/odes/sundials/ida.pyx b/scikits/odes/sundials/ida.pyx index 710eb5db..b5879ebb 100644 --- a/scikits/odes/sundials/ida.pyx +++ b/scikits/odes/sundials/ida.pyx @@ -14,7 +14,9 @@ import numpy as np cimport numpy as np -from .c_sundials cimport realtype, N_Vector +from .c_sundials cimport ( + sunrealtype, N_Vector, SUNContext_Create, SUNContext_Free, +) from .c_nvector_serial cimport * from .c_sunmatrix cimport * from .c_sunlinsol cimport * @@ -164,7 +166,7 @@ cdef class IDA_WrapRhsFunction(IDA_RhsFunction): return user_flag -cdef int _res(realtype tt, N_Vector yy, N_Vector yp, +cdef int _res(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector rr, void *auxiliary_data): """ function with the signature of IDAResFn """ cdef np.ndarray[DTYPE_t, ndim=1] residual_tmp, yy_tmp, yp_tmp @@ -232,8 +234,8 @@ cdef class IDA_WrapRootFunction(IDA_RootFunction): user_flag = 0 return user_flag -cdef int _rootfn(realtype t, N_Vector yy, N_Vector yp, - realtype *gout, void *auxiliary_data): +cdef int _rootfn(sunrealtype t, N_Vector yy, N_Vector yp, + sunrealtype *gout, void *auxiliary_data): """ function with the signature of IDARootFn """ aux_data = auxiliary_data @@ -256,7 +258,7 @@ cdef int _rootfn(realtype t, N_Vector yy, N_Vector yp, raise NotImplemented else: for i in np.arange(len(g_tmp)): - gout[i] = g_tmp[i] + gout[i] = g_tmp[i] return user_flag @@ -321,10 +323,10 @@ cdef class IDA_WrapJacRhsFunction(IDA_JacRhsFunction): user_flag = 0 return user_flag -cdef int _jacdense(realtype tt, realtype cj, +cdef int _jacdense(sunrealtype tt, sunrealtype cj, N_Vector yy, N_Vector yp, N_Vector rr, SUNMatrix Jac, void *auxiliary_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3): - """function with the signature of IDADlsJacFn """ + """function with the signature of IDAJacFn """ cdef np.ndarray[DTYPE_t, ndim=1] yy_tmp, yp_tmp, residual_tmp cdef np.ndarray jac_tmp @@ -407,10 +409,10 @@ cdef class IDA_WrapPrecSetupFunction(IDA_PrecSetupFunction): user_flag = 0 return user_flag -cdef int _prec_setupfn(realtype tt, N_Vector yy, N_Vector yp, N_Vector rr, - realtype cj, +cdef int _prec_setupfn(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector rr, + sunrealtype cj, void *auxiliary_data): - """ function with the signature of IDASpilsPrecSetupFn, that calls + """ function with the signature of IDAPrecSetupFn, that calls the python function """ cdef np.ndarray[DTYPE_t, ndim=1] yy_tmp, rp_tmp, residual_tmp @@ -493,10 +495,10 @@ cdef class IDA_WrapPrecSolveFunction(IDA_PrecSolveFunction): user_flag = 0 return user_flag -cdef int _prec_solvefn(realtype tt, N_Vector yy, N_Vector yp, N_Vector r, - N_Vector rvec, N_Vector z, realtype cj, - realtype delta, void *auxiliary_data): - """ function with the signature of CVSpilsPrecSolveFn, that calls python function """ +cdef int _prec_solvefn(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector r, + N_Vector rvec, N_Vector z, sunrealtype cj, + sunrealtype delta, void *auxiliary_data): + """ function with the signature of CVodePrecSolveFn, that calls python function """ cdef np.ndarray[DTYPE_t, ndim=1] yy_tmp, r_tmp, z_tmp aux_data = auxiliary_data @@ -596,8 +598,8 @@ cdef class IDA_WrapJacTimesVecFunction(IDA_JacTimesVecFunction): user_flag = 0 return user_flag -cdef int _jac_times_vecfn(realtype t, N_Vector yy, N_Vector yp, N_Vector rr, N_Vector v, - N_Vector Jv, realtype cj, void *user_data, N_Vector tmp1, N_Vector tmp2) except? -1: +cdef int _jac_times_vecfn(sunrealtype t, N_Vector yy, N_Vector yp, N_Vector rr, N_Vector v, + N_Vector Jv, sunrealtype cj, void *user_data, N_Vector tmp1, N_Vector tmp2) except? -1: """ function with the signature of IDA_JacTimesVecFunction, that calls python function """ cdef np.ndarray[DTYPE_t, ndim=1] yy_tmp, yp_tmp, rr_tmp, v_tmp, Jv_tmp @@ -679,8 +681,8 @@ cdef class IDA_WrapJacTimesSetupFunction(IDA_JacTimesSetupFunction): user_flag = 0 return user_flag -cdef int _jac_times_setupfn(realtype tt, N_Vector yy, N_Vector yp, N_Vector rr, - realtype cj, void *user_data) except? -1: +cdef int _jac_times_setupfn(sunrealtype tt, N_Vector yy, N_Vector yp, N_Vector rr, + sunrealtype cj, void *user_data) except? -1: """ function with the signature of IDA_JacTimesSetupFunction, that calls python function """ cdef np.ndarray[DTYPE_t, ndim=1] yy_tmp, yp_tmp, rr_tmp @@ -841,8 +843,14 @@ cdef class IDA: self._validate_flags = False # don't validate by default self.set_options(rfn=Rfn, **options) self._ida_mem = NULL + self.sunctx = NULL self.initialized = False + cpdef _create_suncontext(self): + cdef int res = SUNContext_Create(NULL, &self.sunctx) + if res < 0: + raise RuntimeError("Failed to create Sundials context") + def set_options(self, **options): """ Reads the options list and assigns values for the solver. @@ -1216,8 +1224,8 @@ cdef class IDA: self.atol = NULL if np.isscalar(opts_atol): - flag = IDASStolerances(ida_mem, opts_rtol, - opts_atol) + flag = IDASStolerances(ida_mem, opts_rtol, + opts_atol) else: np_atol = np.asarray(opts_atol, dtype=DTYPE) if len(np_atol) != self.N: @@ -1228,8 +1236,8 @@ cdef class IDA: if self.parallel_implementation: raise NotImplemented else: - atol = N_VMake_Serial(self.N, np_atol.data) - flag = IDASVtolerances(ida_mem, opts_rtol, atol) + atol = N_VMake_Serial(self.N, np_atol.data, self.sunctx) + flag = IDASVtolerances(ida_mem, opts_rtol, atol) self.atol = atol @@ -1242,7 +1250,7 @@ cdef class IDA: opts_tstop = options['tstop'] self.options['tstop'] = opts_tstop if (not opts_tstop is None) and (opts_tstop > 0.): - flag = IDASetStopTime(ida_mem, opts_tstop) + flag = IDASetStopTime(ida_mem, opts_tstop) if flag == IDA_ILL_INPUT: raise ValueError('IDASetStopTime::Stop value is beyond ' 'current value.') @@ -1429,12 +1437,15 @@ cdef class IDA: N_VDestroy(self.y) N_VDestroy(self.yp) + if self.sunctx is NULL: + self._create_suncontext() + if self.parallel_implementation: raise NotImplemented else: - self.y0 = N_VMake_Serial(N, y0.data) - self.yp0 = N_VMake_Serial(N, yp0.data) - self.residual = N_VNew_Serial(N) + self.y0 = N_VMake_Serial(N, y0.data, self.sunctx) + self.yp0 = N_VMake_Serial(N, yp0.data, self.sunctx) + self.residual = N_VNew_Serial(N, self.sunctx) self.y = N_VClone(self.y0) #clone does not copy data! self.yp = N_VClone(self.yp0) #clone does not copy data! @@ -1445,15 +1456,15 @@ cdef class IDA: if (ida_mem is NULL) or (self.N != N): if (not ida_mem is NULL): IDAFree(&ida_mem) - ida_mem = IDACreate() + ida_mem = IDACreate(self.sunctx) if ida_mem is NULL: raise MemoryError('IDACreate:MemoryError: Could not allocate ' 'ida_mem object') self._ida_mem = ida_mem - flag = IDAInit(ida_mem, _res, t0, self.y0, self.yp0) + flag = IDAInit(ida_mem, _res, t0, self.y0, self.yp0) elif self.N == N: - flag = IDAReInit(ida_mem, t0, self.y0, self.yp0) + flag = IDAReInit(ida_mem, t0, self.y0, self.yp0) else: raise ValueError('IDAInit:Error: You should not be here...') if flag == IDA_ILL_INPUT: @@ -1555,9 +1566,9 @@ cdef class IDA: IDASetMaxOrd(ida_mem, opts['order']) IDASetMaxNumSteps(ida_mem, opts['max_steps']) if opts['first_step_size'] > 0.: - IDASetInitStep(ida_mem, opts['first_step_size']) + IDASetInitStep(ida_mem, opts['first_step_size']) if opts['max_step_size'] > 0.: - flag = IDASetMaxStep(ida_mem, opts['max_step_size']) + flag = IDASetMaxStep(ida_mem, opts['max_step_size']) if flag == IDA_ILL_INPUT: raise ValueError('IDASetMaxStep: max_step_size is negative or ' 'smaller than allowed.') @@ -1572,34 +1583,34 @@ cdef class IDA: linsolver = opts['linsolver'].lower() if linsolver == 'dense': - A = SUNDenseMatrix(N, N) - LS = SUNDenseLinearSolver(self.y0, A) + A = SUNDenseMatrix(N, N, self.sunctx) + LS = SUNLinSol_Dense(self.y0, A, self.sunctx) # check if memory was allocated if (A == NULL or LS == NULL): raise ValueError('Could not allocate matrix or linear solver') # attach matrix and linear solver to cvode - flag = IDADlsSetLinearSolver(ida_mem, LS, A) + flag = IDASetLinearSolver(ida_mem, LS, A) if flag == IDALS_ILL_INPUT: raise ValueError('IDADense linear solver setting failed, ' 'arguments incompatible') elif flag == IDALS_MEM_NULL: raise MemoryError('IDADense linear solver memory allocation error.') elif flag != IDALS_SUCCESS: - raise ValueError('IDADlsSetLinearSolver failed with code {}' + raise ValueError('IDASetLinearSolver failed with code {}' .format(flag)) elif linsolver == 'band': - A = SUNBandMatrix(N, opts['uband'], opts['lband']); - LS = SUNBandLinearSolver(self.y0, A); + A = SUNBandMatrix(N, opts['uband'], opts['lband'], self.sunctx); + LS = SUNLinSol_Band(self.y0, A, self.sunctx); if (A == NULL or LS == NULL): raise ValueError('Could not allocate matrix or linear solver') - flag = IDADlsSetLinearSolver(ida_mem, LS, A) + flag = IDASetLinearSolver(ida_mem, LS, A) if flag == IDALS_ILL_INPUT: raise ValueError('IDABand linear solver setting failed, ' 'arguments incompatible') elif flag == IDALS_MEM_NULL: raise MemoryError('IDABand linear solver memory allocation error.') elif flag != IDALS_SUCCESS: - raise ValueError('IDADlsSetLinearSolver failed with code {}' + raise ValueError('IDASetLinearSolver failed with code {}' .format(flag)) elif ((linsolver == 'spgmr') or (linsolver == 'spbcg') or (linsolver == 'sptfqmr')): @@ -1607,106 +1618,106 @@ cdef class IDA: precond_type = opts['precond_type'].lower() if precond_type == 'none': - pretype = PREC_NONE + pretype = SUN_PREC_NONE elif precond_type == 'left': - pretype = PREC_LEFT + pretype = SUN_PREC_LEFT elif precond_type == 'right': - pretype = PREC_RIGHT + pretype = SUN_PREC_RIGHT elif precond_type == 'both': - pretype = PREC_BOTH + pretype = SUN_PREC_BOTH else: raise ValueError('LinSolver::Precondition: Unknown type: %s' % opts['precond_type']) if linsolver == 'spgmr': - LS = SUNSPGMR(self.y0, pretype, maxl); + LS = SUNLinSol_SPGMR(self.y0, pretype, maxl, self.sunctx); if LS == NULL: raise ValueError('Could not allocate linear solver') elif linsolver == 'spbcgs': - LS = SUNSPBCGS(self.y0, pretype, maxl); + LS = SUNLinSol_SPBCGS(self.y0, pretype, maxl, self.sunctx); if LS == NULL: raise ValueError('Could not allocate linear solver') elif linsolver == 'sptfqmr': - LS = SUNSPTFQMR(self.y0, pretype, maxl); + LS = SUNLinSol_SPTFQMR(self.y0, pretype, maxl, self.sunctx); if LS == NULL: raise ValueError('Could not allocate linear solver') else: raise ValueError('Given linsolver {} not implemented in odes'.format(linsolver)) - flag = IDASpilsSetLinearSolver(ida_mem, LS); + flag = IDASetLinearSolver(ida_mem, LS, NULL); if flag == IDALS_MEM_NULL: raise MemoryError('IDA memory was NULL') elif flag == IDALS_ILL_INPUT: raise MemoryError('linear solver memory was NULL') elif flag != IDALS_SUCCESS: - raise ValueError('IDASpilsSetLinearSolver failed with code {}' + raise ValueError('IDASetLinearSolver failed with code {}' .format(flag)) # TODO: make option for the Gram-Schmidt orthogonalization #flag = SUNSPGMRSetGSType(LS, gstype); # TODO make option - #flag = IDASpilsSetEpsLin(cvode_mem, DELT); + #flag = IDASetEpsLin(cvode_mem, DELT); if self.aux_data.prec_solvefn: if self.aux_data.prec_setupfn: - flag = IDASpilsSetPreconditioner(ida_mem, _prec_setupfn, + flag = IDASetPreconditioner(ida_mem, _prec_setupfn, _prec_solvefn) else: - flag = IDASpilsSetPreconditioner(ida_mem, NULL, _prec_solvefn) + flag = IDASetPreconditioner(ida_mem, NULL, _prec_solvefn) if flag == IDALS_MEM_NULL: raise ValueError('LinSolver: The cvode mem pointer is NULL.') elif flag == IDALS_LMEM_NULL: raise ValueError('LinSolver: The cvspils linear solver has ' 'not been initialized.') elif flag != IDALS_SUCCESS: - raise ValueError('IDASpilsSetPreconditioner failed with code {}' + raise ValueError('IDASetPreconditioner failed with code {}' .format(flag)) if self.aux_data.jac_times_vecfn: if self.aux_data.jac_times_setupfn: - flag = IDASpilsSetJacTimes(ida_mem, _jac_times_setupfn, _jac_times_vecfn) + flag = IDASetJacTimes(ida_mem, _jac_times_setupfn, _jac_times_vecfn) else: - flag = IDASpilsSetJacTimes(ida_mem, NULL, _jac_times_vecfn) + flag = IDASetJacTimes(ida_mem, NULL, _jac_times_vecfn) if flag == IDALS_MEM_NULL: raise ValueError('LinSolver: The ida mem pointer is NULL.') elif flag == IDALS_LMEM_NULL: raise ValueError('LinSolver: The idaspils linear solver has ' 'not been initialized.') elif flag != IDALS_SUCCESS: - raise ValueError('IDASpilsSetJacTimes failed with code {}' + raise ValueError('IDASetJacTimes failed with code {}' .format(flag)) else: if SUNDIALS_BLAS_LAPACK: if linsolver == 'lapackdense': - A = SUNDenseMatrix(N, N) + A = SUNDenseMatrix(N, N, self.sunctx) LS = SUNLapackDense(self.y0, A) # check if memory was allocated if (A == NULL or LS == NULL): raise ValueError('Could not allocate matrix or linear solver') # attach matrix and linear solver to cvode - flag = IDADlsSetLinearSolver(ida_mem, LS, A) + flag = IDASetLinearSolver(ida_mem, LS, A) if flag == IDALS_ILL_INPUT: raise ValueError('IDADense linear solver setting failed, ' 'arguments incompatible') elif flag == IDALS_MEM_NULL: raise MemoryError('IDADense linear solver memory allocation error.') elif flag != IDALS_SUCCESS: - raise ValueError('IDADlsSetLinearSolver failed with code {}' + raise ValueError('IDASetLinearSolver failed with code {}' .format(flag)) elif linsolver == 'lapackband': - A = SUNBandMatrix(N, opts['uband'], opts['lband']); + A = SUNBandMatrix(N, opts['uband'], opts['lband'], self.sunctx); LS = SUNLapackBand(self.y0, A) if (A == NULL or LS == NULL): raise ValueError('Could not allocate matrix or linear solver') - flag = IDADlsSetLinearSolver(ida_mem, LS, A) + flag = IDASetLinearSolver(ida_mem, LS, A) if flag == IDALS_ILL_INPUT: raise ValueError('IDABand linear solver setting failed, ' 'arguments incompatible') elif flag == IDALS_MEM_NULL: raise MemoryError('IDABand linear solver memory allocation error.') elif flag != IDALS_SUCCESS: - raise ValueError('IDADlsSetLinearSolver failed with code {}' + raise ValueError('IDASetLinearSolver failed with code {}' .format(flag)) else: raise ValueError('LinSolver: Unknown solver type: %s' @@ -1718,13 +1729,13 @@ cdef class IDA: if (linsolver in ['dense', 'lapackdense']) and self.aux_data.jac: self.aux_data.jac_tmp = np.empty((len(y0), len(y0)), DTYPE) - flag = IDADlsSetJacFn(ida_mem, _jacdense) + flag = IDASetJacFn(ida_mem, _jacdense) if flag == IDALS_MEM_NULL: raise MemoryError('IDA Memory NULL.') if flag == IDALS_LMEM_NULL: raise ValueError('IDA linear solver memory NULL') elif flag != IDALS_SUCCESS: - raise ValueError('IDADlsSetJacFn failed with code {}' + raise ValueError('IDASetJacFn failed with code {}' .format(flag)) # Constraints @@ -1754,7 +1765,7 @@ cdef class IDA: raise NotImplemented else: self.constraints =\ - N_VMake_Serial(N, constraints_vars.data) + N_VMake_Serial(N, constraints_vars.data, self.sunctx) flag = IDASetConstraints(ida_mem, self.constraints) if flag == IDA_ILL_INPUT: raise ValueError('IDAConstraints: ''constraints_type'' contains' @@ -1787,7 +1798,7 @@ cdef class IDA: if self.parallel_implementation: raise NotImplemented else: - self.dae_vars_id = N_VMake_Serial(N, dae_vars.data) + self.dae_vars_id = N_VMake_Serial(N, dae_vars.data, self.sunctx) IDASetId(ida_mem, self.dae_vars_id) @@ -1796,7 +1807,7 @@ cdef class IDA: # Initial condition cdef bint compute_initcond_p - cdef realtype ic_t0 = opts['compute_initcond_t0'] + cdef sunrealtype ic_t0 = opts['compute_initcond_t0'] if compute_initcond in [None, 'y0', 'yp0', '']: compute_initcond_p = (compute_initcond == 'y0' or @@ -1911,12 +1922,12 @@ cdef class IDA: N = len(y0) Np = len(yp0) if N == self.N and Np == N: - self.y0 = N_VMake_Serial(N, y0.data) - self.yp0 = N_VMake_Serial(N, yp0.data) + self.y0 = N_VMake_Serial(N, y0.data, self.sunctx) + self.yp0 = N_VMake_Serial(N, yp0.data, self.sunctx) else: raise ValueError("Cannot re-init IC with array of unequal lenght.") - flag = IDAReInit(self._ida_mem, t0, self.y0, self.yp0) + flag = IDAReInit(self._ida_mem, t0, self.y0, self.yp0) if flag == IDA_ILL_INPUT: raise ValueError('IDA[Re]Init: Ill input') @@ -1993,7 +2004,7 @@ cdef class IDA: #check to avoid typical error cdef dict opts = self.options - cdef realtype ic_t0 = opts['compute_initcond_t0'] + cdef sunrealtype ic_t0 = opts['compute_initcond_t0'] if ((len(tspan)>1 and ic_t0 > 0. and tspan[1] > tspan[0]) or (len(tspan)>1 and ic_t0 < 0. and tspan[1] < tspan[0])): pass @@ -2030,7 +2041,7 @@ cdef class IDA: cdef unsigned int last_idx = len(tspan) cdef DTYPE_t t cdef void *ida_mem = self._ida_mem - cdef realtype t_out + cdef sunrealtype t_out cdef N_Vector y = self.y cdef N_Vector yp = self.yp cdef IDA_ContinuationFunction onroot = self.options['onroot'] @@ -2043,7 +2054,7 @@ cdef class IDA: t = tspan[idx] while True: - flag = IDASolve(self._ida_mem, t, &t_out, y, yp, + flag = IDASolve(self._ida_mem, t, &t_out, y, yp, IDA_NORMAL) nv_s2ndarray(y, y_last) @@ -2178,21 +2189,21 @@ cdef class IDA: 'the first call of ''step'' method.') cdef N_Vector y = self.y cdef N_Vector yp = self.yp - cdef realtype t_out + cdef sunrealtype t_out cdef int flagIDA if self._old_api: if t>0.0: - flagIDA = IDASolve(self._ida_mem, t, &t_out, y, yp, + flagIDA = IDASolve(self._ida_mem, t, &t_out, y, yp, IDA_NORMAL) else: - flagIDA = IDASolve(self._ida_mem, -t, &t_out, y, yp, + flagIDA = IDASolve(self._ida_mem, -t, &t_out, y, yp, IDA_ONE_STEP) else: if self._step_compute: - flagIDA = IDASolve(self._ida_mem, t, &t_out, y, yp, + flagIDA = IDASolve(self._ida_mem, t, &t_out, y, yp, IDA_ONE_STEP) else: - flagIDA = IDASolve(self._ida_mem, t, &t_out, y, yp, + flagIDA = IDASolve(self._ida_mem, t, &t_out, y, yp, IDA_NORMAL) cdef np.ndarray[DTYPE_t, ndim=1] y_out @@ -2293,3 +2304,4 @@ cdef class IDA: if not self.residual is NULL: N_VDestroy(self.residual) if not self.dae_vars_id is NULL: N_VDestroy(self.dae_vars_id) if not self.constraints is NULL: N_VDestroy(self.constraints) + if self.sunctx is not NULL: SUNContext_Free(&self.sunctx) diff --git a/scikits/odes/sundials/idas.pxd b/scikits/odes/sundials/idas.pxd index f9a178bb..6c0c2f6e 100644 --- a/scikits/odes/sundials/idas.pxd +++ b/scikits/odes/sundials/idas.pxd @@ -1,5 +1,5 @@ cimport numpy as np -from .c_sundials cimport N_Vector, realtype +from .c_sundials cimport N_Vector, sunrealtype from .common_defs cimport DTYPE_t from .ida cimport (IDA_RhsFunction, IDA_WrapRhsFunction, IDA_RootFunction, diff --git a/scikits/odes/sundials/idas.pyx b/scikits/odes/sundials/idas.pyx index 51491aff..19e262d5 100644 --- a/scikits/odes/sundials/idas.pyx +++ b/scikits/odes/sundials/idas.pyx @@ -1,10 +1,7 @@ # cython: embedsignature=True from cpython.exc cimport PyErr_CheckSignals from collections import namedtuple -try: - from enum import IntEnum -except ImportError: - from enum34 import IntEnum +from enum import IntEnum import inspect from warnings import warn @@ -14,7 +11,7 @@ import numpy as np cimport numpy as np -from .c_sundials cimport realtype, N_Vector +from .c_sundials cimport sunrealtype, N_Vector from .c_nvector_serial cimport * from .c_sunmatrix cimport * from .c_sunlinsol cimport * diff --git a/setup.py b/setup.py index b1f7e9e9..1c963457 100644 --- a/setup.py +++ b/setup.py @@ -51,7 +51,7 @@ long_description = LONG_DESCRIPTION, url = URL, license = LICENSE, - setup_requires = BUILD_REQUIRES, +# setup_requires = BUILD_REQUIRES, install_requires = INSTALL_REQUIRES, packages = find_packages(), namespace_packages = ['scikits'],