summaryrefslogtreecommitdiff
path: root/lib/Numeric/GSL/Minimization.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-11-23 13:25:42 +0000
committerAlberto Ruiz <aruiz@um.es>2007-11-23 13:25:42 +0000
commit30fdf02aff2ac1c4da2bb9292fc08cc8330580d0 (patch)
tree82b062214626c20922959c82581decb3df2ba5ec /lib/Numeric/GSL/Minimization.hs
parent48139eb50c9052406839ee8375e378374e973207 (diff)
removed many -Wall warnings
Diffstat (limited to 'lib/Numeric/GSL/Minimization.hs')
-rw-r--r--lib/Numeric/GSL/Minimization.hs27
1 files changed, 13 insertions, 14 deletions
diff --git a/lib/Numeric/GSL/Minimization.hs b/lib/Numeric/GSL/Minimization.hs
index 235a88f..98c0ca9 100644
--- a/lib/Numeric/GSL/Minimization.hs
+++ b/lib/Numeric/GSL/Minimization.hs
@@ -24,7 +24,6 @@ module Numeric.GSL.Minimization (
24import Data.Packed.Internal 24import Data.Packed.Internal
25import Data.Packed.Matrix 25import Data.Packed.Matrix
26import Foreign 26import Foreign
27import Complex
28 27
29------------------------------------------------------------------------- 28-------------------------------------------------------------------------
30 29
@@ -84,9 +83,9 @@ minimizeNMSimplex f xi sz tol maxit = unsafePerformIO $ do
84 szv = fromList sz 83 szv = fromList sz
85 n = dim xiv 84 n = dim xiv
86 fp <- mkVecfun (iv (f.toList)) 85 fp <- mkVecfun (iv (f.toList))
87 rawpath <- ww2 withVector xiv withVector szv $ \xiv szv -> 86 rawpath <- ww2 withVector xiv withVector szv $ \xiv' szv' ->
88 createMIO maxit (n+3) 87 createMIO maxit (n+3)
89 (c_minimizeNMSimplex fp tol maxit // xiv // szv) 88 (c_minimizeNMSimplex fp tol maxit // xiv' // szv')
90 "minimizeNMSimplex" 89 "minimizeNMSimplex"
91 let it = round (rawpath @@> (maxit-1,0)) 90 let it = round (rawpath @@> (maxit-1,0))
92 path = takeRows it rawpath 91 path = takeRows it rawpath
@@ -150,9 +149,9 @@ minimizeConjugateGradient istep minimpar tol maxit f df xi = unsafePerformIO $ d
150 df' = (fromList . df . toList) 149 df' = (fromList . df . toList)
151 fp <- mkVecfun (iv f') 150 fp <- mkVecfun (iv f')
152 dfp <- mkVecVecfun (aux_vTov df') 151 dfp <- mkVecVecfun (aux_vTov df')
153 rawpath <- withVector xiv $ \xiv -> 152 rawpath <- withVector xiv $ \xiv' ->
154 createMIO maxit (n+2) 153 createMIO maxit (n+2)
155 (c_minimizeConjugateGradient fp dfp istep minimpar tol maxit // xiv) 154 (c_minimizeConjugateGradient fp dfp istep minimpar tol maxit // xiv')
156 "minimizeDerivV" 155 "minimizeDerivV"
157 let it = round (rawpath @@> (maxit-1,0)) 156 let it = round (rawpath @@> (maxit-1,0))
158 path = takeRows it rawpath 157 path = takeRows it rawpath
@@ -171,8 +170,8 @@ foreign import ccall "gsl-aux.h minimizeWithDeriv"
171--------------------------------------------------------------------- 170---------------------------------------------------------------------
172iv :: (Vector Double -> Double) -> (Int -> Ptr Double -> Double) 171iv :: (Vector Double -> Double) -> (Int -> Ptr Double -> Double)
173iv f n p = f (createV n copy "iv") where 172iv f n p = f (createV n copy "iv") where
174 copy n q = do 173 copy n' q = do
175 copyArray q p n 174 copyArray q p n'
176 return 0 175 return 0
177 176
178-- | conversion of Haskell functions into function pointers that can be used in the C side 177-- | conversion of Haskell functions into function pointers that can be used in the C side
@@ -187,12 +186,12 @@ foreign import ccall "wrapper"
187 186
188aux_vTov :: (Vector Double -> Vector Double) -> (Int -> Ptr Double -> Ptr Double -> IO()) 187aux_vTov :: (Vector Double -> Vector Double) -> (Int -> Ptr Double -> Ptr Double -> IO())
189aux_vTov f n p r = g where 188aux_vTov f n p r = g where
190 v@V {fptr = pr} = f x 189 V {fptr = pr} = f x
191 x = createV n copy "aux_vTov" 190 x = createV n copy "aux_vTov"
192 copy n q = do 191 copy n' q = do
193 copyArray q p n 192 copyArray q p n'
194 return 0 193 return 0
195 g = withForeignPtr pr $ \p -> copyArray r p n 194 g = withForeignPtr pr $ \p' -> copyArray r p' n
196 195
197-------------------------------------------------------------------- 196--------------------------------------------------------------------
198 197
@@ -202,6 +201,6 @@ createV n fun msg = unsafePerformIO $ do
202 return r 201 return r
203 202
204createMIO r c fun msg = do 203createMIO r c fun msg = do
205 r <- createMatrix RowMajor r c 204 res <- createMatrix RowMajor r c
206 app1 fun mat r msg 205 app1 fun mat res msg
207 return r 206 return res