diff options
Diffstat (limited to 'lib/Numeric/GSL')
-rw-r--r-- | lib/Numeric/GSL/Internal.hs | 8 | ||||
-rw-r--r-- | lib/Numeric/GSL/Minimization.hs | 4 | ||||
-rw-r--r-- | lib/Numeric/GSL/ODE.hs | 4 | ||||
-rw-r--r-- | lib/Numeric/GSL/Root.hs | 4 |
4 files changed, 10 insertions, 10 deletions
diff --git a/lib/Numeric/GSL/Internal.hs b/lib/Numeric/GSL/Internal.hs index 37bcc1b..2ccc3ef 100644 --- a/lib/Numeric/GSL/Internal.hs +++ b/lib/Numeric/GSL/Internal.hs | |||
@@ -35,12 +35,12 @@ foreign import ccall "wrapper" | |||
35 | 35 | ||
36 | aux_vTov :: (Vector Double -> Vector Double) -> TVV | 36 | aux_vTov :: (Vector Double -> Vector Double) -> TVV |
37 | aux_vTov f n p nr r = g where | 37 | aux_vTov f n p nr r = g where |
38 | V {fptr = pr} = f x | 38 | v = f x |
39 | x = createV (fromIntegral n) copy "aux_vTov" | 39 | x = createV (fromIntegral n) copy "aux_vTov" |
40 | copy n' q = do | 40 | copy n' q = do |
41 | copyArray q p (fromIntegral n') | 41 | copyArray q p (fromIntegral n') |
42 | return 0 | 42 | return 0 |
43 | g = do withForeignPtr pr $ \p' -> copyArray r p' (fromIntegral nr) | 43 | g = do unsafeWith v $ \p' -> copyArray r p' (fromIntegral nr) |
44 | return 0 | 44 | return 0 |
45 | 45 | ||
46 | foreign import ccall "wrapper" | 46 | foreign import ccall "wrapper" |
@@ -51,12 +51,12 @@ foreign import ccall "wrapper" | |||
51 | 51 | ||
52 | aux_vTom :: (Vector Double -> Matrix Double) -> TVM | 52 | aux_vTom :: (Vector Double -> Matrix Double) -> TVM |
53 | aux_vTom f n p rr cr r = g where | 53 | aux_vTom f n p rr cr r = g where |
54 | V {fptr = pr} = flatten $ f x | 54 | v = flatten $ f x |
55 | x = createV (fromIntegral n) copy "aux_vTov" | 55 | x = createV (fromIntegral n) copy "aux_vTov" |
56 | copy n' q = do | 56 | copy n' q = do |
57 | copyArray q p (fromIntegral n') | 57 | copyArray q p (fromIntegral n') |
58 | return 0 | 58 | return 0 |
59 | g = do withForeignPtr pr $ \p' -> copyArray r p' (fromIntegral $ rr*cr) | 59 | g = do unsafeWith v $ \p' -> copyArray r p' (fromIntegral $ rr*cr) |
60 | return 0 | 60 | return 0 |
61 | 61 | ||
62 | createV n fun msg = unsafePerformIO $ do | 62 | createV n fun msg = unsafePerformIO $ do |
diff --git a/lib/Numeric/GSL/Minimization.hs b/lib/Numeric/GSL/Minimization.hs index 3240ddf..3bbb2b3 100644 --- a/lib/Numeric/GSL/Minimization.hs +++ b/lib/Numeric/GSL/Minimization.hs | |||
@@ -109,7 +109,7 @@ ww2 w1 o1 w2 o2 f = w1 o1 $ \a1 -> w2 o2 $ \a2 -> f a1 a2 | |||
109 | minimizeV method eps maxit szv f xiv = unsafePerformIO $ do | 109 | minimizeV method eps maxit szv f xiv = unsafePerformIO $ do |
110 | let n = dim xiv | 110 | let n = dim xiv |
111 | fp <- mkVecfun (iv f) | 111 | fp <- mkVecfun (iv f) |
112 | rawpath <- ww2 withVector xiv withVector szv $ \xiv' szv' -> | 112 | rawpath <- ww2 vec xiv vec szv $ \xiv' szv' -> |
113 | createMIO maxit (n+3) | 113 | createMIO maxit (n+3) |
114 | (c_minimize (fi (fromEnum method)) fp eps (fi maxit) // xiv' // szv') | 114 | (c_minimize (fi (fromEnum method)) fp eps (fi maxit) // xiv' // szv') |
115 | "minimize" | 115 | "minimize" |
@@ -166,7 +166,7 @@ minimizeVD method eps maxit istep tol f df xiv = unsafePerformIO $ do | |||
166 | df' = (checkdim1 n . df) | 166 | df' = (checkdim1 n . df) |
167 | fp <- mkVecfun (iv f') | 167 | fp <- mkVecfun (iv f') |
168 | dfp <- mkVecVecfun (aux_vTov df') | 168 | dfp <- mkVecVecfun (aux_vTov df') |
169 | rawpath <- withVector xiv $ \xiv' -> | 169 | rawpath <- vec xiv $ \xiv' -> |
170 | createMIO maxit (n+2) | 170 | createMIO maxit (n+2) |
171 | (c_minimizeD (fi (fromEnum method)) fp dfp istep tol eps (fi maxit) // xiv') | 171 | (c_minimizeD (fi (fromEnum method)) fp dfp istep tol eps (fi maxit) // xiv') |
172 | "minimizeD" | 172 | "minimizeD" |
diff --git a/lib/Numeric/GSL/ODE.hs b/lib/Numeric/GSL/ODE.hs index 9d890fc..f6f11f9 100644 --- a/lib/Numeric/GSL/ODE.hs +++ b/lib/Numeric/GSL/ODE.hs | |||
@@ -83,8 +83,8 @@ odeSolveV method h epsAbs epsRel f mbjac xiv ts = unsafePerformIO $ do | |||
83 | jp <- case mbjac of | 83 | jp <- case mbjac of |
84 | Just jac -> mkDoubleVecMatfun (\t -> aux_vTom (checkdim2 n . jac t)) | 84 | Just jac -> mkDoubleVecMatfun (\t -> aux_vTom (checkdim2 n . jac t)) |
85 | Nothing -> return nullFunPtr | 85 | Nothing -> return nullFunPtr |
86 | sol <- withVector xiv $ \xiv' -> | 86 | sol <- vec xiv $ \xiv' -> |
87 | withVector (checkTimes ts) $ \ts' -> | 87 | vec (checkTimes ts) $ \ts' -> |
88 | createMIO (dim ts) n | 88 | createMIO (dim ts) n |
89 | (ode_c (fi (fromEnum method)) h epsAbs epsRel fp jp // xiv' // ts' ) | 89 | (ode_c (fi (fromEnum method)) h epsAbs epsRel fp jp // xiv' // ts' ) |
90 | "ode" | 90 | "ode" |
diff --git a/lib/Numeric/GSL/Root.hs b/lib/Numeric/GSL/Root.hs index 840e8ee..ddb090d 100644 --- a/lib/Numeric/GSL/Root.hs +++ b/lib/Numeric/GSL/Root.hs | |||
@@ -79,7 +79,7 @@ rootGen m f xi epsabs maxit = unsafePerformIO $ do | |||
79 | let xiv = fromList xi | 79 | let xiv = fromList xi |
80 | n = dim xiv | 80 | n = dim xiv |
81 | fp <- mkVecVecfun (aux_vTov (checkdim1 n . fromList . f . toList)) | 81 | fp <- mkVecVecfun (aux_vTov (checkdim1 n . fromList . f . toList)) |
82 | rawpath <- withVector xiv $ \xiv' -> | 82 | rawpath <- vec xiv $ \xiv' -> |
83 | createMIO maxit (2*n+1) | 83 | createMIO maxit (2*n+1) |
84 | (c_root m fp epsabs (fi maxit) // xiv') | 84 | (c_root m fp epsabs (fi maxit) // xiv') |
85 | "root" | 85 | "root" |
@@ -117,7 +117,7 @@ rootJGen m f jac xi epsabs maxit = unsafePerformIO $ do | |||
117 | n = dim xiv | 117 | n = dim xiv |
118 | fp <- mkVecVecfun (aux_vTov (checkdim1 n . fromList . f . toList)) | 118 | fp <- mkVecVecfun (aux_vTov (checkdim1 n . fromList . f . toList)) |
119 | jp <- mkVecMatfun (aux_vTom (checkdim2 n . fromLists . jac . toList)) | 119 | jp <- mkVecMatfun (aux_vTom (checkdim2 n . fromLists . jac . toList)) |
120 | rawpath <- withVector xiv $ \xiv' -> | 120 | rawpath <- vec xiv $ \xiv' -> |
121 | createMIO maxit (2*n+1) | 121 | createMIO maxit (2*n+1) |
122 | (c_rootj m fp jp epsabs (fi maxit) // xiv') | 122 | (c_rootj m fp jp epsabs (fi maxit) // xiv') |
123 | "root" | 123 | "root" |