summaryrefslogtreecommitdiff
path: root/lib/Numeric/LinearAlgebra/Tests.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Numeric/LinearAlgebra/Tests.hs')
-rw-r--r--lib/Numeric/LinearAlgebra/Tests.hs10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Numeric/LinearAlgebra/Tests.hs b/lib/Numeric/LinearAlgebra/Tests.hs
index 278df78..4f73e3a 100644
--- a/lib/Numeric/LinearAlgebra/Tests.hs
+++ b/lib/Numeric/LinearAlgebra/Tests.hs
@@ -36,6 +36,8 @@ a ^ b = a Prelude.^ (b :: Int)
36 36
37utest str b = TestCase $ assertBool str b 37utest str b = TestCase $ assertBool str b
38 38
39a ~~ b = fromList a |~| fromList b
40
39feye n = flipud (ident n) :: Matrix Double 41feye n = flipud (ident n) :: Matrix Double
40 42
41detTest1 = det m == 26 43detTest1 = det m == 26
@@ -112,12 +114,17 @@ minimizationTest = TestList [ utest "minimization conj grad" (minim1 f df [5,7]
112 ] 114 ]
113 where f [x,y] = 10*(x-1)^2 + 20*(y-2)^2 + 30 115 where f [x,y] = 10*(x-1)^2 + 20*(y-2)^2 + 30
114 df [x,y] = [20*(x-1), 40*(y-2)] 116 df [x,y] = [20*(x-1), 40*(y-2)]
115 a ~~ b = fromList a |~| fromList b
116 minim1 g dg ini = fst $ minimizeConjugateGradient 1E-2 1E-4 1E-3 30 g dg ini 117 minim1 g dg ini = fst $ minimizeConjugateGradient 1E-2 1E-4 1E-3 30 g dg ini
117 minim2 g dg ini = fst $ minimizeVectorBFGS2 1E-2 1E-2 1E-3 30 g dg ini 118 minim2 g dg ini = fst $ minimizeVectorBFGS2 1E-2 1E-2 1E-3 30 g dg ini
118 119
119--------------------------------------------------------------------- 120---------------------------------------------------------------------
120 121
122rootFindingTest = utest "root Hybrids" (sol ~~ [1,1])
123 where sol = fst $ root Hybrids 1E-7 30 (rosenbrock 1 10) [-10,-5]
124 rosenbrock a b [x,y] = [ a*(1-x), b*(y-x^2) ]
125
126---------------------------------------------------------------------
127
121rot :: Double -> Matrix Double 128rot :: Double -> Matrix Double
122rot a = (3><3) [ c,0,s 129rot a = (3><3) [ c,0,s
123 , 0,1,0 130 , 0,1,0
@@ -217,6 +224,7 @@ runTests n = do
217 , utest "integrate" (abs (volSphere 2.5 - 4/3*pi*2.5^3) < 1E-8) 224 , utest "integrate" (abs (volSphere 2.5 - 4/3*pi*2.5^3) < 1E-8)
218 , utest "polySolve" (polySolveProp [1,2,3,4]) 225 , utest "polySolve" (polySolveProp [1,2,3,4])
219 , minimizationTest 226 , minimizationTest
227 , rootFindingTest
220 ] 228 ]
221 return () 229 return ()
222 230