summaryrefslogtreecommitdiff
path: root/packages/sundials/src/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'packages/sundials/src/Main.hs')
-rw-r--r--packages/sundials/src/Main.hs32
1 files changed, 8 insertions, 24 deletions
diff --git a/packages/sundials/src/Main.hs b/packages/sundials/src/Main.hs
index 3d5f941..bab5710 100644
--- a/packages/sundials/src/Main.hs
+++ b/packages/sundials/src/Main.hs
@@ -55,6 +55,13 @@ vectorToC vec len ptr = do
55 ptr' <- newForeignPtr_ ptr 55 ptr' <- newForeignPtr_ ptr
56 V.copy (VM.unsafeFromForeignPtr0 ptr' len) vec 56 V.copy (VM.unsafeFromForeignPtr0 ptr' len) vec
57 57
58foreign export ccall singleEq :: Double -> Double -> IO Double
59
60singleEq :: Double -> Double -> IO Double
61singleEq t u = return $ lamda * u + 1.0 / (1.0 + t * t) - lamda * atan t
62 where
63 lamda = -100.0
64
58solve :: (CDouble -> V.Vector CDouble -> V.Vector CDouble) -> 65solve :: (CDouble -> V.Vector CDouble -> V.Vector CDouble) ->
59 V.Vector Double -> 66 V.Vector Double ->
60 CDouble -> 67 CDouble ->
@@ -89,29 +96,6 @@ solve fun f0 lambda = unsafePerformIO $ do
89 realtype abstol = 1.0e-10; 96 realtype abstol = 1.0e-10;
90 realtype lamda = -100.0; /* stiffness parameter */ 97 realtype lamda = -100.0; /* stiffness parameter */
91 98
92 /* Beginning of stolen code from the Fortran interface */
93
94 N_Vector F2C_ARKODE_vec;
95 F2C_ARKODE_vec = NULL;
96 F2C_ARKODE_vec = N_VNewEmpty_Serial(NEQ); /* was *N */
97 if (F2C_ARKODE_vec == NULL) return 1;
98
99 /* Check for required vector operations */
100 if(F2C_ARKODE_vec->ops->nvgetarraypointer == NULL) {
101 fprintf(stderr, "Error: getarraypointer vector operation is not implemented.\n\n");
102 return 1;
103 }
104 if(F2C_ARKODE_vec->ops->nvsetarraypointer == NULL) {
105 fprintf(stderr, "Error: setarraypointer vector operation is not implemented.\n\n");
106 return 1;
107 }
108 if(F2C_ARKODE_vec->ops->nvcloneempty == NULL) {
109 fprintf(stderr, "Error: cloneempty vector operation is not implemented.\n\n");
110 return 1;
111 }
112
113 /* End of stolen code from the Fortran interface */
114
115 /* Initial diagnostics output */ 99 /* Initial diagnostics output */
116 printf("\nAnalytical ODE test problem:\n"); 100 printf("\nAnalytical ODE test problem:\n");
117 printf(" lamda = %"GSYM"\n", lamda); 101 printf(" lamda = %"GSYM"\n", lamda);
@@ -130,7 +114,7 @@ solve fun f0 lambda = unsafePerformIO $ do
130 /* right-hand side function in y'=f(t,y), the inital time T0, and */ 114 /* right-hand side function in y'=f(t,y), the inital time T0, and */
131 /* the initial dependent variable vector y. Note: since this */ 115 /* the initial dependent variable vector y. Note: since this */
132 /* problem is fully implicit, we set f_E to NULL and f_I to f. */ 116 /* problem is fully implicit, we set f_E to NULL and f_I to f. */
133 flag = ARKodeInit(arkode_mem, NULL, f, T0, y); 117 flag = ARKodeInit(arkode_mem, NULL, FARKfi, T0, y);
134 if (check_flag(&flag, "ARKodeInit", 1)) return 1; 118 if (check_flag(&flag, "ARKodeInit", 1)) return 1;
135 119
136 /* Set routines */ 120 /* Set routines */