diff options
Diffstat (limited to 'packages/sundials/src/Main.hs')
-rw-r--r-- | packages/sundials/src/Main.hs | 14 |
1 files changed, 0 insertions, 14 deletions
diff --git a/packages/sundials/src/Main.hs b/packages/sundials/src/Main.hs index 89d6668..ab5b153 100644 --- a/packages/sundials/src/Main.hs +++ b/packages/sundials/src/Main.hs | |||
@@ -84,19 +84,6 @@ vectorToC vec len ptr = do | |||
84 | ptr' <- newForeignPtr_ ptr | 84 | ptr' <- newForeignPtr_ ptr |
85 | V.copy (VM.unsafeFromForeignPtr0 ptr' len) vec | 85 | V.copy (VM.unsafeFromForeignPtr0 ptr' len) vec |
86 | 86 | ||
87 | -- Provided you always call your function 'multiEq' then we can | ||
88 | -- probably solve any set of ODEs! But of course we don't want to | ||
89 | -- follow the Fortran way of interacting with sundials. | ||
90 | |||
91 | -- foreign export ccall multiEq :: Ptr CDouble -> Ptr CDouble -> Ptr CDouble -> Ptr CLong -> Ptr CDouble -> Ptr CInt -> IO () | ||
92 | |||
93 | multiEq :: Ptr CDouble -> Ptr CDouble -> Ptr CDouble -> Ptr CLong -> Ptr CDouble -> Ptr CInt -> IO () | ||
94 | multiEq tPtr yPtr yDotPtr iParPtr rParPtr ierPtr = do | ||
95 | t <- peek tPtr | ||
96 | y <- vectorFromC 1 yPtr | ||
97 | vectorToC (V.map realToFrac $ stiffish (realToFrac t) (V.map realToFrac y)) 1 yDotPtr | ||
98 | poke ierPtr 0 | ||
99 | |||
100 | stiffish :: Double -> V.Vector Double -> V.Vector Double | 87 | stiffish :: Double -> V.Vector Double -> V.Vector Double |
101 | stiffish t v = V.fromList [ lamda * u + 1.0 / (1.0 + t * t) - lamda * atan t ] | 88 | stiffish t v = V.fromList [ lamda * u + 1.0 / (1.0 + t * t) - lamda * atan t ] |
102 | where | 89 | where |
@@ -161,7 +148,6 @@ solveOdeC fun f0 = unsafePerformIO $ do | |||
161 | /* Here we use the C types defined in helpers.h which tie up with */ | 148 | /* Here we use the C types defined in helpers.h which tie up with */ |
162 | /* the Haskell types defined in Types */ | 149 | /* the Haskell types defined in Types */ |
163 | flag = ARKodeInit(arkode_mem, NULL, $fun:(int (* funIO) (double t, BarType y[], BarType dydt[], void * params)), T0, y); | 150 | flag = ARKodeInit(arkode_mem, NULL, $fun:(int (* funIO) (double t, BarType y[], BarType dydt[], void * params)), T0, y); |
164 | /* flag = ARKodeInit(arkode_mem, NULL, FARKfi, T0, y); */ | ||
165 | if (check_flag(&flag, "ARKodeInit", 1)) return 1; | 151 | if (check_flag(&flag, "ARKodeInit", 1)) return 1; |
166 | 152 | ||
167 | /* Set routines */ | 153 | /* Set routines */ |