From 51cac5fbc8571b11ac1841ec21cbff66150c7a62 Mon Sep 17 00:00:00 2001 From: Dominic Steinitz Date: Tue, 17 Apr 2018 14:32:47 +0100 Subject: Mimic hmatrix-gsl some more --- .../sundials/src/Numeric/Sundials/ARKode/ODE.hs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'packages/sundials/src/Numeric/Sundials/ARKode/ODE.hs') diff --git a/packages/sundials/src/Numeric/Sundials/ARKode/ODE.hs b/packages/sundials/src/Numeric/Sundials/ARKode/ODE.hs index 380b1d6..f6f6884 100644 --- a/packages/sundials/src/Numeric/Sundials/ARKode/ODE.hs +++ b/packages/sundials/src/Numeric/Sundials/ARKode/ODE.hs @@ -105,6 +105,7 @@ module Numeric.Sundials.ARKode.ODE ( odeSolve , odeSolveV , odeSolveVWith + , odeSolveVWith' , ButcherTable(..) , butcherTable , ODEMethod(..) @@ -289,6 +290,27 @@ odeSolve f y0 ts = nC = length y0 g t x0 = V.fromList $ f t (V.toList x0) +odeSolveVWith' :: + ODEMethod + -> StepControl + -> Maybe Double -- ^ initial step size - by default, ARKode + -- estimates the initial step size to be the + -- solution \(h\) of the equation + -- \(\|\frac{h^2\ddot{y}}{2}\| = 1\), where + -- \(\ddot{y}\) is an estimated value of the second + -- derivative of the solution at \(t_0\) + -> (Double -> V.Vector Double -> V.Vector Double) -- ^ The RHS of the system \(\dot{y} = f(t,y)\) + -> V.Vector Double -- ^ Initial conditions + -> V.Vector Double -- ^ Desired solution times + -> Matrix Double -- ^ Error code or solution +odeSolveVWith' method control initStepSize f y0 tt = + case odeSolveVWith method control initStepSize f y0 tt of + Left c -> error $ show c -- FIXME + Right (v, _d) -> (nR >< nC) (V.toList v) + where + nR = V.length tt + nC = V.length y0 + odeSolveVWith :: ODEMethod -> StepControl -- cgit v1.2.3