diff options
Diffstat (limited to 'lib/Numeric/GSL/Minimization.hs')
-rw-r--r-- | lib/Numeric/GSL/Minimization.hs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/Numeric/GSL/Minimization.hs b/lib/Numeric/GSL/Minimization.hs index 0a2d577..a1d009b 100644 --- a/lib/Numeric/GSL/Minimization.hs +++ b/lib/Numeric/GSL/Minimization.hs | |||
@@ -31,14 +31,14 @@ import Foreign.C.Types(CInt) | |||
31 | {- | The method of Nelder and Mead, implemented by /gsl_multimin_fminimizer_nmsimplex/. The gradient of the function is not required. This is the example in the GSL manual: | 31 | {- | The method of Nelder and Mead, implemented by /gsl_multimin_fminimizer_nmsimplex/. The gradient of the function is not required. This is the example in the GSL manual: |
32 | 32 | ||
33 | @minimize f xi = minimizeNMSimplex f xi (replicate (length xi) 1) 1e-2 100 | 33 | @minimize f xi = minimizeNMSimplex f xi (replicate (length xi) 1) 1e-2 100 |
34 | \ | 34 | \ -- |
35 | f [x,y] = 10*(x-1)^2 + 20*(y-2)^2 + 30 | 35 | f [x,y] = 10*(x-1)^2 + 20*(y-2)^2 + 30 |
36 | \ | 36 | \ -- |
37 | main = do | 37 | main = do |
38 | let (s,p) = minimize f [5,7] | 38 | let (s,p) = minimize f [5,7] |
39 | print s | 39 | print s |
40 | print p | 40 | print p |
41 | \ | 41 | \ -- |
42 | \> main | 42 | \> main |
43 | [0.9920430849306285,1.9969168063253164] | 43 | [0.9920430849306285,1.9969168063253164] |
44 | 0. 512.500 1.082 6.500 5. | 44 | 0. 512.500 1.082 6.500 5. |
@@ -104,14 +104,14 @@ foreign import ccall "gsl-aux.h minimize" | |||
104 | 104 | ||
105 | @minimize = minimizeConjugateGradient 1E-2 1E-4 1E-3 30 | 105 | @minimize = minimizeConjugateGradient 1E-2 1E-4 1E-3 30 |
106 | f [x,y] = 10*(x-1)^2 + 20*(y-2)^2 + 30 | 106 | f [x,y] = 10*(x-1)^2 + 20*(y-2)^2 + 30 |
107 | \ | 107 | \ -- |
108 | df [x,y] = [20*(x-1), 40*(y-2)] | 108 | df [x,y] = [20*(x-1), 40*(y-2)] |
109 | \ | 109 | \ -- |
110 | main = do | 110 | main = do |
111 | let (s,p) = minimize f df [5,7] | 111 | let (s,p) = minimize f df [5,7] |
112 | print s | 112 | print s |
113 | print p | 113 | print p |
114 | \ | 114 | \ -- |
115 | \> main | 115 | \> main |
116 | [1.0,2.0] | 116 | [1.0,2.0] |
117 | 0. 687.848 4.996 6.991 | 117 | 0. 687.848 4.996 6.991 |