summaryrefslogtreecommitdiff
path: root/packages/sundials/src/Main.hs
diff options
context:
space:
mode:
authorDominic Steinitz <dominic@steinitz.org>2018-04-09 15:05:28 +0100
committerDominic Steinitz <dominic@steinitz.org>2018-04-09 15:05:28 +0100
commite022e6b2d96f89376113241d89e31e2affd4faaf (patch)
tree3109cf5ceb48a2bdb5947debc9553770325f89a8 /packages/sundials/src/Main.hs
parentf5dc976be9ee31095fbcd2f825375bbb42f44b64 (diff)
Improve haddock
Diffstat (limited to 'packages/sundials/src/Main.hs')
-rw-r--r--packages/sundials/src/Main.hs45
1 files changed, 20 insertions, 25 deletions
diff --git a/packages/sundials/src/Main.hs b/packages/sundials/src/Main.hs
index d22fafa..b65d668 100644
--- a/packages/sundials/src/Main.hs
+++ b/packages/sundials/src/Main.hs
@@ -94,44 +94,39 @@ kSaxis :: [(Double, Double)] -> P.Axis B D.V2 Double
94kSaxis xs = P.r2Axis &~ do 94kSaxis xs = P.r2Axis &~ do
95 P.linePlot' xs 95 P.linePlot' xs
96 96
97butcherTableauTex :: (Show a, Element a) => Matrix a -> String 97butcherTableauTex :: ButcherTable -> String
98butcherTableauTex m = render $ 98butcherTableauTex (ButcherTable m c b b2) =
99 vcat [ text ("\n\\begin{array}{c|" ++ (concat $ replicate n "c") ++ "}") 99 render $
100 , us 100 vcat [ text ("\n\\begin{array}{c|" ++ (concat $ replicate n "c") ++ "}")
101 , text "\\end{array}" 101 , us
102 ] 102 , text "\\hline"
103 , text bs <+> text "\\\\"
104 , text b2s <+> text "\\\\"
105 , text "\\end{array}"
106 ]
103 where 107 where
104 n = rows m 108 n = rows m
105 rs = toLists m 109 rs = toLists m
106 ss = map (\r -> intercalate " & " $ map show r) rs 110 ss = map (\r -> intercalate " & " $ map show r) rs
107 ts = zipWith (\i r -> "c_" ++ show i ++ " & " ++ r) [1..n] ss 111 ts = zipWith (\i r -> show i ++ " & " ++ r) (toList c) ss
108 us = vcat $ map (\r -> text r <+> text "\\\\") ts 112 us = vcat $ map (\r -> text r <+> text "\\\\") ts
113 bs = " & " ++ (intercalate " & " $ map show $ toList b)
114 b2s = " & " ++ (intercalate " & " $ map show $ toList b2)
109 115
110main :: IO () 116main :: IO ()
111main = do 117main = do
112 -- $$ 118
113 -- \begin{array}{c|cccc} 119 let res = butcherTable (SDIRK_2_1_2 undefined)
114 -- c_1 & a_{11} & a_{12}& \dots & a_{1s}\\
115 -- c_2 & a_{21} & a_{22}& \dots & a_{2s}\\
116 -- \vdots & \vdots & \vdots& \ddots& \vdots\\
117 -- c_s & a_{s1} & a_{s2}& \dots & a_{ss} \\
118 -- \hline
119 -- & b_1 & b_2 & \dots & b_s\\
120 -- & b^*_1 & b^*_2 & \dots & b^*_s\\
121 -- \end{array}
122 -- $$
123
124 let res = btGet (SDIRK_2_1_2 undefined)
125 putStrLn $ show res 120 putStrLn $ show res
126 putStrLn $ butcherTableauTex $ fst res 121 putStrLn $ butcherTableauTex res
127 122
128 let res = btGet (KVAERNO_4_2_3 undefined) 123 let res = butcherTable (KVAERNO_4_2_3 undefined)
129 putStrLn $ show res 124 putStrLn $ show res
130 putStrLn $ butcherTableauTex $ fst res 125 putStrLn $ butcherTableauTex res
131 126
132 let res = btGet (SDIRK_5_3_4 undefined) 127 let res = butcherTable (SDIRK_5_3_4 undefined)
133 putStrLn $ show res 128 putStrLn $ show res
134 putStrLn $ butcherTableauTex $ fst res 129 putStrLn $ butcherTableauTex res
135 130
136 let res1 = odeSolve brusselator [1.2, 3.1, 3.0] (fromList [0.0, 0.1 .. 10.0]) 131 let res1 = odeSolve brusselator [1.2, 3.1, 3.0] (fromList [0.0, 0.1 .. 10.0])
137 renderRasterific "diagrams/brusselator.png" 132 renderRasterific "diagrams/brusselator.png"