diff options
author | Alberto Ruiz <aruiz@um.es> | 2010-02-08 08:35:55 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2010-02-08 08:35:55 +0000 |
commit | 43303a91e7c045995775f67a332d8ed1068f9342 (patch) | |
tree | fb197c2245a1987c9364d003591db2ba2160d3c5 /lib/Numeric | |
parent | aef0333b5180ea79e539bd53194f1dfed20b7db5 (diff) |
check ts odeSolve
Diffstat (limited to 'lib/Numeric')
-rw-r--r-- | lib/Numeric/GSL/ODE.hs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Numeric/GSL/ODE.hs b/lib/Numeric/GSL/ODE.hs index 3450b91..7c711b7 100644 --- a/lib/Numeric/GSL/ODE.hs +++ b/lib/Numeric/GSL/ODE.hs | |||
@@ -84,7 +84,7 @@ odeSolveV method h epsAbs epsRel f mbjac xiv ts = unsafePerformIO $ do | |||
84 | Just jac -> mkDoubleVecMatfun (\t -> aux_vTom (checkdim2 n . jac t)) | 84 | Just jac -> mkDoubleVecMatfun (\t -> aux_vTom (checkdim2 n . jac t)) |
85 | Nothing -> return nullFunPtr | 85 | Nothing -> return nullFunPtr |
86 | sol <- withVector xiv $ \xiv' -> | 86 | sol <- withVector xiv $ \xiv' -> |
87 | withVector ts $ \ts' -> | 87 | withVector (checkTimes ts) $ \ts' -> |
88 | createMIO (dim ts) n | 88 | createMIO (dim ts) n |
89 | (ode_c (fi (fromEnum method)) h epsAbs epsRel fp jp // xiv' // ts' ) | 89 | (ode_c (fi (fromEnum method)) h epsAbs epsRel fp jp // xiv' // ts' ) |
90 | "ode" | 90 | "ode" |
@@ -105,3 +105,7 @@ checkdim2 n m | |||
105 | | rows m == n && cols m == n = m | 105 | | rows m == n && cols m == n = m |
106 | | otherwise = error $ "Error: "++ show n ++ "x" ++ show n | 106 | | otherwise = error $ "Error: "++ show n ++ "x" ++ show n |
107 | ++ " Jacobian expected in odeSolve" | 107 | ++ " Jacobian expected in odeSolve" |
108 | |||
109 | checkTimes ts | dim ts > 1 && all (>0) (zipWith subtract ts' (tail ts')) = ts | ||
110 | | otherwise = error "odeSolve requires increasing times" | ||
111 | where ts' = toList ts \ No newline at end of file | ||