From 686bd51792648dee967c611225cb1a59efa6b1c2 Mon Sep 17 00:00:00 2001 From: Dominic Steinitz Date: Thu, 3 May 2018 08:14:30 +0100 Subject: Improve documentation --- .../sundials/src/Numeric/Sundials/ARKode/ODE.hs | 51 +++++++++++++++++++++- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/packages/sundials/src/Numeric/Sundials/ARKode/ODE.hs b/packages/sundials/src/Numeric/Sundials/ARKode/ODE.hs index ce46968..fafc237 100644 --- a/packages/sundials/src/Numeric/Sundials/ARKode/ODE.hs +++ b/packages/sundials/src/Numeric/Sundials/ARKode/ODE.hs @@ -20,8 +20,7 @@ -- Stability : provisional -- -- Solution of ordinary differential equation (ODE) initial value problems. --- --- +-- See for more detail. -- -- A simple example: -- @@ -65,6 +64,54 @@ -- (renderAxis $ lSaxis $ [0.0, 0.1 .. 10.0]:(toLists $ tr res1)) -- @ -- +-- With Sundials ARKode, it is possible to retrieve the Butcher tableau for the solver. +-- +-- @ +-- import Numeric.Sundials.ARKode.ODE +-- import Numeric.LinearAlgebra +-- +-- import Data.List (intercalate) +-- +-- import Text.PrettyPrint.HughesPJClass +-- +-- +-- butcherTableauTex :: ButcherTable -> String +-- butcherTableauTex (ButcherTable m c b b2) = +-- render $ +-- vcat [ text ("\n\\begin{array}{c|" ++ (concat $ replicate n "c") ++ "}") +-- , us +-- , text "\\hline" +-- , text bs <+> text "\\\\" +-- , text b2s <+> text "\\\\" +-- , text "\\end{array}" +-- ] +-- where +-- n = rows m +-- rs = toLists m +-- ss = map (\r -> intercalate " & " $ map show r) rs +-- ts = zipWith (\i r -> show i ++ " & " ++ r) (toList c) ss +-- us = vcat $ map (\r -> text r <+> text "\\\\") ts +-- bs = " & " ++ (intercalate " & " $ map show $ toList b) +-- b2s = " & " ++ (intercalate " & " $ map show $ toList b2) +-- +-- main :: IO () +-- main = do +-- +-- let res = butcherTable (SDIRK_2_1_2 undefined) +-- putStrLn $ show res +-- putStrLn $ butcherTableauTex res +-- +-- let resA = butcherTable (KVAERNO_4_2_3 undefined) +-- putStrLn $ show resA +-- putStrLn $ butcherTableauTex resA +-- +-- let resB = butcherTable (SDIRK_5_3_4 undefined) +-- putStrLn $ show resB +-- putStrLn $ butcherTableauTex resB +-- @ +-- +-- Using the code above from the examples gives +-- -- KVAERNO_4_2_3 -- -- \[ -- cgit v1.2.3