summaryrefslogtreecommitdiff
path: root/packages/tests/src/Numeric/GSL/Tests.hs
diff options
context:
space:
mode:
Diffstat (limited to 'packages/tests/src/Numeric/GSL/Tests.hs')
-rw-r--r--packages/tests/src/Numeric/GSL/Tests.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/packages/tests/src/Numeric/GSL/Tests.hs b/packages/tests/src/Numeric/GSL/Tests.hs
index 2eacd30..9dff6f5 100644
--- a/packages/tests/src/Numeric/GSL/Tests.hs
+++ b/packages/tests/src/Numeric/GSL/Tests.hs
@@ -1,3 +1,4 @@
1{-# OPTIONS_GHC -fno-warn-unused-imports -fno-warn-incomplete-patterns #-}
1{- | 2{- |
2Module : Numeric.GLS.Tests 3Module : Numeric.GLS.Tests
3Copyright : (c) Alberto Ruiz 2014 4Copyright : (c) Alberto Ruiz 2014
@@ -50,7 +51,7 @@ odeTest = utest "ode" (last (toLists sol) ~~ newsol)
50 sol = odeSolveV RK8pd 1E-6 1E-6 0 (l2v $ vanderpol 10) (fromList [1,0]) ts 51 sol = odeSolveV RK8pd 1E-6 1E-6 0 (l2v $ vanderpol 10) (fromList [1,0]) ts
51 ts = linspace 101 (0,100) 52 ts = linspace 101 (0,100)
52 l2v f = \t -> fromList . f t . toList 53 l2v f = \t -> fromList . f t . toList
53 vanderpol mu _t [x,y] = [y, -x + mu * y * (1-x^2) ] 54 vanderpol mu _t [x,y] = [y, -x + mu * y * (1-x**2) ]
54 newsol = [-1.758888036617841, 8.364349410519058e-2] 55 newsol = [-1.758888036617841, 8.364349410519058e-2]
55 -- oldsol = [-1.7588880332411019, 8.364348908711941e-2] 56 -- oldsol = [-1.7588880332411019, 8.364348908711941e-2]
56 57
@@ -61,7 +62,7 @@ rootFindingTest = TestList [ utest "root Hybrids" (fst sol1 ~~ [1,1])
61 ] 62 ]
62 where sol1 = root Hybrids 1E-7 30 (rosenbrock 1 10) [-10,-5] 63 where sol1 = root Hybrids 1E-7 30 (rosenbrock 1 10) [-10,-5]
63 sol2 = rootJ Newton 1E-7 30 (rosenbrock 1 10) (jacobian 1 10) [-10,-5] 64 sol2 = rootJ Newton 1E-7 30 (rosenbrock 1 10) (jacobian 1 10) [-10,-5]
64 rosenbrock a b [x,y] = [ a*(1-x), b*(y-x^2) ] 65 rosenbrock a b [x,y] = [ a*(1-x), b*(y-x**2) ]
65 jacobian a b [x,_y] = [ [-a , 0] 66 jacobian a b [x,_y] = [ [-a , 0]
66 , [-2*b*x, b] ] 67 , [-2*b*x, b] ]
67 68
@@ -71,7 +72,7 @@ minimizationTest = TestList
71 [ utest "minimization conjugatefr" (minim1 f df [5,7] ~~ [1,2]) 72 [ utest "minimization conjugatefr" (minim1 f df [5,7] ~~ [1,2])
72 , utest "minimization nmsimplex2" (minim2 f [5,7] `elem` [24,25]) 73 , utest "minimization nmsimplex2" (minim2 f [5,7] `elem` [24,25])
73 ] 74 ]
74 where f [x,y] = 10*(x-1)^2 + 20*(y-2)^2 + 30 75 where f [x,y] = 10*(x-1)**2 + 20*(y-2)**2 + 30
75 df [x,y] = [20*(x-1), 40*(y-2)] 76 df [x,y] = [20*(x-1), 40*(y-2)]
76 minim1 g dg ini = fst $ minimizeD ConjugateFR 1E-3 30 1E-2 1E-4 g dg ini 77 minim1 g dg ini = fst $ minimizeD ConjugateFR 1E-3 30 1E-2 1E-4 g dg ini
77 minim2 g ini = rows $ snd $ minimize NMSimplex2 1E-2 30 [1,1] g ini 78 minim2 g ini = rows $ snd $ minimize NMSimplex2 1E-2 30 [1,1] g ini
@@ -123,7 +124,7 @@ runTests n = do
123 , rootFindingTest 124 , rootFindingTest
124 , minimizationTest 125 , minimizationTest
125 , utest "deriv" derivTest 126 , utest "deriv" derivTest
126 , utest "integrate" (abs (volSphere 2.5 - 4/3*pi*2.5^3) < 1E-8) 127 , utest "integrate" (abs (volSphere 2.5 - 4/3*pi*2.5**3) < 1E-8)
127 , utest "polySolve" (polySolveProp [1,2,3,4]) 128 , utest "polySolve" (polySolveProp [1,2,3,4])
128 ] 129 ]
129 when (errors c + failures c > 0) exitFailure 130 when (errors c + failures c > 0) exitFailure