summaryrefslogtreecommitdiff
path: root/lib/Numeric
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2010-03-28 18:42:42 +0000
committerAlberto Ruiz <aruiz@um.es>2010-03-28 18:42:42 +0000
commit47a3c55318a7eb5fa131c28a6548ed8643e6d6d1 (patch)
tree530e7b39af9a68acedccf49e495379e65b9fa48f /lib/Numeric
parentef333e80b4c4a87ea1b019a5e7c3934366e14c5f (diff)
solve benchmark
Diffstat (limited to 'lib/Numeric')
-rw-r--r--lib/Numeric/LinearAlgebra/Tests.hs19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/Numeric/LinearAlgebra/Tests.hs b/lib/Numeric/LinearAlgebra/Tests.hs
index 36efab6..922bfd5 100644
--- a/lib/Numeric/LinearAlgebra/Tests.hs
+++ b/lib/Numeric/LinearAlgebra/Tests.hs
@@ -328,6 +328,7 @@ makeUnitary v | realPart n > 1 = v / scalar n
328-- | Performance measurements. 328-- | Performance measurements.
329runBenchmarks :: IO () 329runBenchmarks :: IO ()
330runBenchmarks = do 330runBenchmarks = do
331 solveBench
331 subBench 332 subBench
332 multBench 333 multBench
333 svdBench 334 svdBench
@@ -341,7 +342,7 @@ time msg act = do
341 t0 <- getCPUTime 342 t0 <- getCPUTime
342 act `seq` putStr " " 343 act `seq` putStr " "
343 t1 <- getCPUTime 344 t1 <- getCPUTime
344 printf "%5.1f s CPU\n" $ (fromIntegral (t1 - t0) / (10^12 :: Double)) :: IO () 345 printf "%6.2f s CPU\n" $ (fromIntegral (t1 - t0) / (10^12 :: Double)) :: IO ()
345 return () 346 return ()
346 347
347-------------------------------- 348--------------------------------
@@ -410,3 +411,19 @@ svdBench = do
410 time "singular values 1000x1000" (singularValues b) 411 time "singular values 1000x1000" (singularValues b)
411 time "full svd 1000x1000" (fv $ svd b) 412 time "full svd 1000x1000" (fv $ svd b)
412 413
414--------------------------------
415
416solveBenchN n = do
417 let x = uniformSample 777 (2*n) (replicate n (-1,1))
418 a = trans x <> x
419 b = asColumn $ randomVector 666 Uniform n
420 a `seq` b `seq` putStrLn ""
421 time ("svd solve " ++ show n) (linearSolveSVD a b)
422 time (" ls solve " ++ show n) (linearSolveLS a b)
423 time (" solve " ++ show n) (linearSolve a b)
424 time ("cholSolve " ++ show n) (cholSolve (chol a) b)
425
426solveBench = do
427 solveBenchN 500
428 solveBenchN 1000
429 -- solveBenchN 1500