From 49a3d719221cd9484a64688ffcdbeb13cb8e55a0 Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Fri, 5 Jun 2009 18:53:07 +0000 Subject: check dim in root function --- examples/root.hs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'examples/root.hs') diff --git a/examples/root.hs b/examples/root.hs index 9a674fd..69db243 100644 --- a/examples/root.hs +++ b/examples/root.hs @@ -1,27 +1,17 @@ -- root finding examples import Numeric.GSL import Numeric.LinearAlgebra -import Graphics.Plot import Text.Printf(printf) rosenbrock a b [x,y] = [ a*(1-x), b*(y-x^2) ] -disp = putStrLn . format " " (printf "%.3f") - --- Numerical estimation of the gradient -gradient f v = [partialDerivative k f v | k <- [0 .. length v -1]] - -partialDerivative n f v = fst (derivCentral 0.01 g (v!!n)) where - g x = f (concat [a,x:b]) - (a,_:b) = splitAt n v - test method = do print method let (s,p) = root method 1E-7 30 (rosenbrock 1 10) [-10,-5] print s -- solution disp p -- evolution of the algorithm --- let [x,y] = tail (toColumns p) --- mplot [x,y] -- path from the starting point to the solution + +disp = putStrLn . format " " (printf "%.3f") main = do test Hybrids -- cgit v1.2.3