summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/sundials/src/Numeric/Sundials/Arkode/ODE.hs17
1 files changed, 8 insertions, 9 deletions
diff --git a/packages/sundials/src/Numeric/Sundials/Arkode/ODE.hs b/packages/sundials/src/Numeric/Sundials/Arkode/ODE.hs
index 15d2747..7b0cb0d 100644
--- a/packages/sundials/src/Numeric/Sundials/Arkode/ODE.hs
+++ b/packages/sundials/src/Numeric/Sundials/Arkode/ODE.hs
@@ -42,10 +42,10 @@ C.include "<stdio.h>"
42C.include "<math.h>" 42C.include "<math.h>"
43C.include "<arkode/arkode.h>" -- prototypes for ARKODE fcts., consts. 43C.include "<arkode/arkode.h>" -- prototypes for ARKODE fcts., consts.
44C.include "<nvector/nvector_serial.h>" -- serial N_Vector types, fcts., macros 44C.include "<nvector/nvector_serial.h>" -- serial N_Vector types, fcts., macros
45C.include "<sunmatrix/sunmatrix_dense.h>" -- access to dense SUNMatrix 45C.include "<sunmatrix/sunmatrix_dense.h>" -- access to dense SUNMatrix
46C.include "<sunlinsol/sunlinsol_dense.h>" -- access to dense SUNLinearSolver 46C.include "<sunlinsol/sunlinsol_dense.h>" -- access to dense SUNLinearSolver
47C.include "<arkode/arkode_direct.h>" -- access to ARKDls interface 47C.include "<arkode/arkode_direct.h>" -- access to ARKDls interface
48C.include "<sundials/sundials_types.h>" -- definition of type realtype 48C.include "<sundials/sundials_types.h>" -- definition of type realtype
49C.include "<sundials/sundials_math.h>" 49C.include "<sundials/sundials_math.h>"
50C.include "../../../helpers.h" 50C.include "../../../helpers.h"
51 51
@@ -110,7 +110,7 @@ odeSolve f y0 ts = case solveOde g (V.fromList y0) (V.fromList $ toList ts) of
110 nC = length y0 110 nC = length y0
111 g t x0 = V.fromList $ f t (V.toList x0) 111 g t x0 = V.fromList $ f t (V.toList x0)
112 112
113solveOde :: 113solveOde ::
114 (Double -> V.Vector Double -> V.Vector Double) -- ^ The RHS of the system \(\dot{y} = f(t,y)\) 114 (Double -> V.Vector Double -> V.Vector Double) -- ^ The RHS of the system \(\dot{y} = f(t,y)\)
115 -> V.Vector Double -- ^ Initial conditions 115 -> V.Vector Double -- ^ Initial conditions
116 -> V.Vector Double -- ^ Desired solution times 116 -> V.Vector Double -- ^ Desired solution times
@@ -118,7 +118,7 @@ solveOde ::
118solveOde f y0 tt = case solveOdeC (coerce f) (coerce y0) (coerce tt) of 118solveOde f y0 tt = case solveOdeC (coerce f) (coerce y0) (coerce tt) of
119 Left c -> Left $ fromIntegral c 119 Left c -> Left $ fromIntegral c
120 Right (v, d) -> Right (coerce v, d) 120 Right (v, d) -> Right (coerce v, d)
121 121
122solveOdeC :: 122solveOdeC ::
123 (CDouble -> V.Vector CDouble -> V.Vector CDouble) -- ^ The RHS of the system \(\dot{y} = f(t,y)\) 123 (CDouble -> V.Vector CDouble -> V.Vector CDouble) -- ^ The RHS of the system \(\dot{y} = f(t,y)\)
124 -> V.Vector CDouble -- ^ Initial conditions 124 -> V.Vector CDouble -- ^ Initial conditions
@@ -287,13 +287,13 @@ solveOdeC fun f0 ts = unsafePerformIO $ do
287 flag = ARKDlsGetNumRhsEvals(arkode_mem, &nfeLS); 287 flag = ARKDlsGetNumRhsEvals(arkode_mem, &nfeLS);
288 check_flag(&flag, "ARKDlsGetNumRhsEvals", 1); 288 check_flag(&flag, "ARKDlsGetNumRhsEvals", 1);
289 ($vec-ptr:(long int *diagMut))[9] = ncfn; 289 ($vec-ptr:(long int *diagMut))[9] = ncfn;
290 290
291 /* Clean up and return */ 291 /* Clean up and return */
292 N_VDestroy(y); /* Free y vector */ 292 N_VDestroy(y); /* Free y vector */
293 ARKodeFree(&arkode_mem); /* Free integrator memory */ 293 ARKodeFree(&arkode_mem); /* Free integrator memory */
294 SUNLinSolFree(LS); /* Free linear solver */ 294 SUNLinSolFree(LS); /* Free linear solver */
295 SUNMatDestroy(A); /* Free A matrix */ 295 SUNMatDestroy(A); /* Free A matrix */
296 296
297 return flag; 297 return flag;
298 } |] 298 } |]
299 if res == 0 299 if res == 0
@@ -313,4 +313,3 @@ solveOdeC fun f0 ts = unsafePerformIO $ do
313 return $ Right (m, d) 313 return $ Right (m, d)
314 else do 314 else do
315 return $ Left res 315 return $ Left res
316