blob: e667ef1a82b982fa248db8de504651bf6f635f2d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
{-# OPTIONS_GHC -Wall #-}
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
let resC = butcherTable (FEHLBERG_6_4_5 undefined)
putStrLn $ show resC
putStrLn $ butcherTableauTex resC
|