diff options
Diffstat (limited to 'packages/sundials/src/Numeric/Sundials/Arkode.hsc')
-rw-r--r-- | packages/sundials/src/Numeric/Sundials/Arkode.hsc | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/packages/sundials/src/Numeric/Sundials/Arkode.hsc b/packages/sundials/src/Numeric/Sundials/Arkode.hsc new file mode 100644 index 0000000..f5e5dc1 --- /dev/null +++ b/packages/sundials/src/Numeric/Sundials/Arkode.hsc | |||
@@ -0,0 +1,120 @@ | |||
1 | |module Numeric.Sundials.Arkode where | ||
2 | |||
3 | import Foreign | ||
4 | import Foreign.C.Types | ||
5 | |||
6 | |||
7 | #include <stdio.h> | ||
8 | #include <sundials/sundials_nvector.h> | ||
9 | #include <sundials/sundials_matrix.h> | ||
10 | #include <nvector/nvector_serial.h> | ||
11 | #include <sunmatrix/sunmatrix_dense.h> | ||
12 | #include <arkode/arkode.h> | ||
13 | #include <cvode/cvode.h> | ||
14 | |||
15 | |||
16 | #def typedef struct _generic_N_Vector SunVector; | ||
17 | #def typedef struct _N_VectorContent_Serial SunContent; | ||
18 | |||
19 | #def typedef struct _generic_SUNMatrix SunMatrix; | ||
20 | #def typedef struct _SUNMatrixContent_Dense SunMatrixContent; | ||
21 | |||
22 | getContentMatrixPtr :: Storable a => Ptr b -> IO a | ||
23 | getContentMatrixPtr ptr = (#peek SunMatrix, content) ptr | ||
24 | |||
25 | getNRows :: Ptr b -> IO CInt | ||
26 | getNRows ptr = (#peek SunMatrixContent, M) ptr | ||
27 | putNRows :: CInt -> Ptr b -> IO () | ||
28 | putNRows nr ptr = (#poke SunMatrixContent, M) ptr nr | ||
29 | |||
30 | getNCols :: Ptr b -> IO CInt | ||
31 | getNCols ptr = (#peek SunMatrixContent, N) ptr | ||
32 | putNCols :: CInt -> Ptr b -> IO () | ||
33 | putNCols nc ptr = (#poke SunMatrixContent, N) ptr nc | ||
34 | |||
35 | getMatrixData :: Storable a => Ptr b -> IO a | ||
36 | getMatrixData ptr = (#peek SunMatrixContent, data) ptr | ||
37 | |||
38 | getContentPtr :: Storable a => Ptr b -> IO a | ||
39 | getContentPtr ptr = (#peek SunVector, content) ptr | ||
40 | |||
41 | getData :: Storable a => Ptr b -> IO a | ||
42 | getData ptr = (#peek SunContent, data) ptr | ||
43 | |||
44 | cV_ADAMS :: Int | ||
45 | cV_ADAMS = #const CV_ADAMS | ||
46 | cV_BDF :: Int | ||
47 | cV_BDF = #const CV_BDF | ||
48 | |||
49 | arkSMax :: Int | ||
50 | arkSMax = #const ARK_S_MAX | ||
51 | |||
52 | mIN_DIRK_NUM, mAX_DIRK_NUM :: Int | ||
53 | mIN_DIRK_NUM = #const MIN_DIRK_NUM | ||
54 | mAX_DIRK_NUM = #const MAX_DIRK_NUM | ||
55 | |||
56 | -- FIXME: We could just use inline-c instead | ||
57 | |||
58 | -- Butcher table accessors -- implicit | ||
59 | sDIRK_2_1_2 :: Int | ||
60 | sDIRK_2_1_2 = #const SDIRK_2_1_2 | ||
61 | bILLINGTON_3_3_2 :: Int | ||
62 | bILLINGTON_3_3_2 = #const BILLINGTON_3_3_2 | ||
63 | tRBDF2_3_3_2 :: Int | ||
64 | tRBDF2_3_3_2 = #const TRBDF2_3_3_2 | ||
65 | kVAERNO_4_2_3 :: Int | ||
66 | kVAERNO_4_2_3 = #const KVAERNO_4_2_3 | ||
67 | aRK324L2SA_DIRK_4_2_3 :: Int | ||
68 | aRK324L2SA_DIRK_4_2_3 = #const ARK324L2SA_DIRK_4_2_3 | ||
69 | cASH_5_2_4 :: Int | ||
70 | cASH_5_2_4 = #const CASH_5_2_4 | ||
71 | cASH_5_3_4 :: Int | ||
72 | cASH_5_3_4 = #const CASH_5_3_4 | ||
73 | sDIRK_5_3_4 :: Int | ||
74 | sDIRK_5_3_4 = #const SDIRK_5_3_4 | ||
75 | kVAERNO_5_3_4 :: Int | ||
76 | kVAERNO_5_3_4 = #const KVAERNO_5_3_4 | ||
77 | aRK436L2SA_DIRK_6_3_4 :: Int | ||
78 | aRK436L2SA_DIRK_6_3_4 = #const ARK436L2SA_DIRK_6_3_4 | ||
79 | kVAERNO_7_4_5 :: Int | ||
80 | kVAERNO_7_4_5 = #const KVAERNO_7_4_5 | ||
81 | aRK548L2SA_DIRK_8_4_5 :: Int | ||
82 | aRK548L2SA_DIRK_8_4_5 = #const ARK548L2SA_DIRK_8_4_5 | ||
83 | |||
84 | -- #define DEFAULT_DIRK_2 SDIRK_2_1_2 | ||
85 | -- #define DEFAULT_DIRK_3 ARK324L2SA_DIRK_4_2_3 | ||
86 | -- #define DEFAULT_DIRK_4 SDIRK_5_3_4 | ||
87 | -- #define DEFAULT_DIRK_5 ARK548L2SA_DIRK_8_4_5 | ||
88 | |||
89 | -- Butcher table accessors -- explicit | ||
90 | hEUN_EULER_2_1_2 :: Int | ||
91 | hEUN_EULER_2_1_2 = #const HEUN_EULER_2_1_2 | ||
92 | bOGACKI_SHAMPINE_4_2_3 :: Int | ||
93 | bOGACKI_SHAMPINE_4_2_3 = #const BOGACKI_SHAMPINE_4_2_3 | ||
94 | aRK324L2SA_ERK_4_2_3 :: Int | ||
95 | aRK324L2SA_ERK_4_2_3 = #const ARK324L2SA_ERK_4_2_3 | ||
96 | zONNEVELD_5_3_4 :: Int | ||
97 | zONNEVELD_5_3_4 = #const ZONNEVELD_5_3_4 | ||
98 | aRK436L2SA_ERK_6_3_4 :: Int | ||
99 | aRK436L2SA_ERK_6_3_4 = #const ARK436L2SA_ERK_6_3_4 | ||
100 | sAYFY_ABURUB_6_3_4 :: Int | ||
101 | sAYFY_ABURUB_6_3_4 = #const SAYFY_ABURUB_6_3_4 | ||
102 | cASH_KARP_6_4_5 :: Int | ||
103 | cASH_KARP_6_4_5 = #const CASH_KARP_6_4_5 | ||
104 | fEHLBERG_6_4_5 :: Int | ||
105 | fEHLBERG_6_4_5 = #const FEHLBERG_6_4_5 | ||
106 | dORMAND_PRINCE_7_4_5 :: Int | ||
107 | dORMAND_PRINCE_7_4_5 = #const DORMAND_PRINCE_7_4_5 | ||
108 | aRK548L2SA_ERK_8_4_5 :: Int | ||
109 | aRK548L2SA_ERK_8_4_5 = #const ARK548L2SA_ERK_8_4_5 | ||
110 | vERNER_8_5_6 :: Int | ||
111 | vERNER_8_5_6 = #const VERNER_8_5_6 | ||
112 | fEHLBERG_13_7_8 :: Int | ||
113 | fEHLBERG_13_7_8 = #const FEHLBERG_13_7_8 | ||
114 | |||
115 | -- #define DEFAULT_ERK_2 HEUN_EULER_2_1_2 | ||
116 | -- #define DEFAULT_ERK_3 BOGACKI_SHAMPINE_4_2_3 | ||
117 | -- #define DEFAULT_ERK_4 ZONNEVELD_5_3_4 | ||
118 | -- #define DEFAULT_ERK_5 CASH_KARP_6_4_5 | ||
119 | -- #define DEFAULT_ERK_6 VERNER_8_5_6 | ||
120 | -- #define DEFAULT_ERK_8 FEHLBERG_13_7_8 | ||