packages feed

hmatrix 0.8.0.0 → 0.8.1.0

raw patch · 3 files changed

+77/−4 lines, 3 filesdep ~arraydep ~haskell98

Dependency ranges changed: array, haskell98

Files

CHANGES view
@@ -1,3 +1,8 @@+0.8.1.0+=======++- runBenchmarks+ 0.8.0.0 ======= 
hmatrix.cabal view
@@ -1,5 +1,5 @@ Name:               hmatrix-Version:            0.8.0.0+Version:            0.8.1.0 License:            GPL License-file:       LICENSE Author:             Alberto Ruiz@@ -64,11 +64,11 @@  library     if flag(splitBase)-      build-depends:    base >= 3 && < 5, array+      build-depends:    base >= 3 && < 5, array < 0.3.0     else       build-depends:    base < 3 -    Build-Depends:      haskell98,+    Build-Depends:      haskell98 < 1.0.1.1,                         QuickCheck, HUnit,                         storable-complex,                         process
lib/Numeric/LinearAlgebra/Tests.hs view
@@ -17,7 +17,7 @@ module Numeric.LinearAlgebra.Tests( --  module Numeric.LinearAlgebra.Tests.Instances, --  module Numeric.LinearAlgebra.Tests.Properties,-  qCheck, runTests+  qCheck, runTests, runBenchmarks --, runBigTests ) where @@ -31,6 +31,9 @@ import Numeric.GSL hiding (sin,cos,exp,choose) import Prelude hiding ((^)) import qualified Prelude+import System.CPUTime+import Text.Printf+ #include "Tests/quickCheckCompat.h"  a ^ b = a Prelude.^ (b :: Int)@@ -286,3 +289,68 @@ -- -- | Some additional tests on big matrices. They take a few minutes. -- runBigTests :: IO () -- runBigTests = undefined++--------------------------------------------------------------------------------++-- | Performance measurements.+runBenchmarks :: IO ()+runBenchmarks = do+    multBench+    svdBench+    eigBench+    putStrLn ""++--------------------------------++time msg act = do+    putStr (msg++" ")+    t0 <- getCPUTime+    act `seq` putStr " "+    t1 <- getCPUTime+    printf "%5.1f s CPU\n" $ (fromIntegral (t1 - t0) / (10^12 :: Double)) :: IO ()+    return ()++--------------------------------++manymult n = foldl1' (<>) (map rot2 angles) where+    angles = toList $ linspace n (0,1)+    rot2 :: Double -> Matrix Double+    rot2 a = (3><3) [ c,0,s+                    , 0,1,0+                    ,-s,0,c ]+        where c = cos a+              s = sin a++--------------------------------++multBench = do+    let a = ident 1000 :: Matrix Double+    let b = ident 2000 :: Matrix Double+    a `seq` b `seq` putStrLn ""+    time "product of 1M different 3x3 matrices" (manymult (10^6))+    time "product (1000 x 1000)<>(1000 x 1000)" (a<>a)+    time "product (2000 x 2000)<>(2000 x 2000)" (b<>b)++--------------------------------++eigBench = do+    let m = reshape 1000 (randomVector 777 Uniform (1000*1000))+        s = m + trans m+    m `seq` s `seq` putStrLn ""+    time "eigenvalues  symmetric 1000x1000" (eigenvaluesSH' m)+    time "eigenvectors symmetric 1000x1000" (snd $ eigSH' m)+    time "eigenvalues  general   1000x1000" (eigenvalues m)+    time "eigenvectors general   1000x1000" (snd $ eig m)++--------------------------------++svdBench = do+    let a = reshape 500  (randomVector 777 Uniform (3000*500))+        b = reshape 1000 (randomVector 777 Uniform (1000*1000))+        fv (_,_,v) = v@@>(0,0)+    a `seq` b `seq` putStrLn ""+    time "singular values  3000x500" (singularValues a)+    time "thin svd         3000x500" (fv $ thinSVD a)+    time "full svd         3000x500" (fv $ svd a)+    time "singular values 1000x1000" (singularValues b)+    time "full svd        1000x1000" (fv $ svd b)