diff options
author | Alberto Ruiz <aruiz@um.es> | 2014-05-08 13:43:07 +0200 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2014-05-08 13:43:07 +0200 |
commit | 551cf7498c33bc0948bb4cb8444ae6f8af7278ea (patch) | |
tree | ec86ff73151746f5e13b83549ea5c60ed442764d /packages/hmatrix/src/Numeric/GSL/Minimization.hs | |
parent | 561a6c0e21bb77c21114ccbbd86d3af5ddb5a3f1 (diff) |
separation ok
Diffstat (limited to 'packages/hmatrix/src/Numeric/GSL/Minimization.hs')
-rw-r--r-- | packages/hmatrix/src/Numeric/GSL/Minimization.hs | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/packages/hmatrix/src/Numeric/GSL/Minimization.hs b/packages/hmatrix/src/Numeric/GSL/Minimization.hs index 1879dab..056d463 100644 --- a/packages/hmatrix/src/Numeric/GSL/Minimization.hs +++ b/packages/hmatrix/src/Numeric/GSL/Minimization.hs | |||
@@ -1,13 +1,9 @@ | |||
1 | {-# LANGUAGE ForeignFunctionInterface #-} | ||
2 | ----------------------------------------------------------------------------- | ||
3 | {- | | 1 | {- | |
4 | Module : Numeric.GSL.Minimization | 2 | Module : Numeric.GSL.Minimization |
5 | Copyright : (c) Alberto Ruiz 2006-9 | 3 | Copyright : (c) Alberto Ruiz 2006-9 |
6 | License : GPL-style | 4 | License : GPL |
7 | 5 | Maintainer : Alberto Ruiz | |
8 | Maintainer : Alberto Ruiz (aruiz at um dot es) | ||
9 | Stability : provisional | 6 | Stability : provisional |
10 | Portability : uses ffi | ||
11 | 7 | ||
12 | Minimization of a multidimensional function using some of the algorithms described in: | 8 | Minimization of a multidimensional function using some of the algorithms described in: |
13 | 9 | ||
@@ -48,7 +44,7 @@ The nmsimplex2 version is a new O(N) implementation of the earlier O(N^2) nmsimp | |||
48 | 44 | ||
49 | -} | 45 | -} |
50 | 46 | ||
51 | ----------------------------------------------------------------------------- | 47 | |
52 | module Numeric.GSL.Minimization ( | 48 | module Numeric.GSL.Minimization ( |
53 | minimize, minimizeV, MinimizeMethod(..), | 49 | minimize, minimizeV, MinimizeMethod(..), |
54 | minimizeD, minimizeVD, MinimizeMethodD(..), | 50 | minimizeD, minimizeVD, MinimizeMethodD(..), |
@@ -60,8 +56,7 @@ module Numeric.GSL.Minimization ( | |||
60 | ) where | 56 | ) where |
61 | 57 | ||
62 | 58 | ||
63 | import Data.Packed.Internal | 59 | import Data.Packed |
64 | import Data.Packed.Matrix | ||
65 | import Numeric.GSL.Internal | 60 | import Numeric.GSL.Internal |
66 | 61 | ||
67 | import Foreign.Ptr(Ptr, FunPtr, freeHaskellFunPtr) | 62 | import Foreign.Ptr(Ptr, FunPtr, freeHaskellFunPtr) |
@@ -112,7 +107,7 @@ uniMinimizeGen m f xmin xl xu epsrel maxit = unsafePerformIO $ do | |||
112 | 107 | ||
113 | 108 | ||
114 | foreign import ccall safe "uniMinimize" | 109 | foreign import ccall safe "uniMinimize" |
115 | c_uniMinize:: CInt -> FunPtr (Double -> Double) -> Double -> CInt -> Double -> Double -> Double -> TM | 110 | c_uniMinize:: CInt -> FunPtr (Double -> Double) -> Double -> CInt -> Double -> Double -> Double -> TM Res |
116 | 111 | ||
117 | data MinimizeMethod = NMSimplex | 112 | data MinimizeMethod = NMSimplex |
118 | | NMSimplex2 | 113 | | NMSimplex2 |
@@ -150,13 +145,13 @@ minimizeV method eps maxit szv f xiv = unsafePerformIO $ do | |||
150 | "minimize" | 145 | "minimize" |
151 | let it = round (rawpath @@> (maxit-1,0)) | 146 | let it = round (rawpath @@> (maxit-1,0)) |
152 | path = takeRows it rawpath | 147 | path = takeRows it rawpath |
153 | sol = cdat $ dropColumns 3 $ dropRows (it-1) path | 148 | sol = flatten $ dropColumns 3 $ dropRows (it-1) path |
154 | freeHaskellFunPtr fp | 149 | freeHaskellFunPtr fp |
155 | return (sol, path) | 150 | return (sol, path) |
156 | 151 | ||
157 | 152 | ||
158 | foreign import ccall safe "gsl-aux.h minimize" | 153 | foreign import ccall safe "gsl-aux.h minimize" |
159 | c_minimize:: CInt -> FunPtr (CInt -> Ptr Double -> Double) -> Double -> CInt -> TVVM | 154 | c_minimize:: CInt -> FunPtr (CInt -> Ptr Double -> Double) -> Double -> CInt -> TV(TV(TM Res)) |
160 | 155 | ||
161 | ---------------------------------------------------------------------------------- | 156 | ---------------------------------------------------------------------------------- |
162 | 157 | ||
@@ -207,7 +202,7 @@ minimizeVD method eps maxit istep tol f df xiv = unsafePerformIO $ do | |||
207 | "minimizeD" | 202 | "minimizeD" |
208 | let it = round (rawpath @@> (maxit-1,0)) | 203 | let it = round (rawpath @@> (maxit-1,0)) |
209 | path = takeRows it rawpath | 204 | path = takeRows it rawpath |
210 | sol = cdat $ dropColumns 2 $ dropRows (it-1) path | 205 | sol = flatten $ dropColumns 2 $ dropRows (it-1) path |
211 | freeHaskellFunPtr fp | 206 | freeHaskellFunPtr fp |
212 | freeHaskellFunPtr dfp | 207 | freeHaskellFunPtr dfp |
213 | return (sol,path) | 208 | return (sol,path) |
@@ -215,9 +210,9 @@ minimizeVD method eps maxit istep tol f df xiv = unsafePerformIO $ do | |||
215 | foreign import ccall safe "gsl-aux.h minimizeD" | 210 | foreign import ccall safe "gsl-aux.h minimizeD" |
216 | c_minimizeD :: CInt | 211 | c_minimizeD :: CInt |
217 | -> FunPtr (CInt -> Ptr Double -> Double) | 212 | -> FunPtr (CInt -> Ptr Double -> Double) |
218 | -> FunPtr TVV | 213 | -> FunPtr (TV (TV Res)) |
219 | -> Double -> Double -> Double -> CInt | 214 | -> Double -> Double -> Double -> CInt |
220 | -> TVM | 215 | -> TV (TM Res) |
221 | 216 | ||
222 | --------------------------------------------------------------------- | 217 | --------------------------------------------------------------------- |
223 | 218 | ||