packages feed

hmatrix-tests 0.1.0.0 → 0.2

raw patch · 2 files changed

+55/−10 lines, 2 filesdep ~hmatrixPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: hmatrix

API changes (from Hackage documentation)

Files

hmatrix-tests.cabal view
@@ -1,15 +1,15 @@ Name:               hmatrix-tests-Version:            0.1.0.0+Version:            0.2 License:            GPL License-file:       LICENSE Author:             Alberto Ruiz Maintainer:         Alberto Ruiz <aruiz@um.es> Stability:          provisional-Homepage:           http://perception.inf.um.es/hmatrix+Homepage:           https://github.com/albertoruiz/hmatrix Synopsis:           Tests for hmatrix Description:        Tests for hmatrix Category:           Math-tested-with:        GHC==7.0.4+tested-with:        GHC==7.4  cabal-version:      >=1.8 @@ -21,7 +21,7 @@ library      Build-Depends:      base >= 4 && < 5,-                        hmatrix >= 0.13,+                        hmatrix >= 0.14,                         QuickCheck >= 2, HUnit, random      hs-source-dirs:     src@@ -36,7 +36,7 @@  source-repository head     type:     git-    location: https://github.com/AlbertoRuiz/hmatrix+    location: https://github.com/albertoruiz/hmatrix  Test-Suite basic     Build-Depends: base, hmatrix-tests
src/Numeric/LinearAlgebra/Tests.hs view
@@ -43,6 +43,8 @@ import Debug.Trace import Control.Monad(when) +import Data.Packed.ST+ import Test.QuickCheck(Arbitrary,arbitrary,coarbitrary,choose,vector                       ,sized,classify,Testable,Property                       ,quickCheckWithResult,maxSize,stdArgs,shrink)@@ -167,11 +169,14 @@  --------------------------------------------------------------------- -odeTest = utest "ode" (last (toLists sol) ~~ [-1.7588880332411019, 8.364348908711941e-2])-    where sol = odeSolveV RK8pd 1E-6 1E-6 0 (l2v $ vanderpol 10) Nothing (fromList [1,0]) ts-          ts = linspace 101 (0,100)-          l2v f = \t -> fromList  . f t . toList-          vanderpol mu _t [x,y] = [y, -x + mu * y * (1-x^2) ]+odeTest = utest "ode" (last (toLists sol) ~~ newsol)+  where+    sol = odeSolveV RK8pd 1E-6 1E-6 0 (l2v $ vanderpol 10) (fromList [1,0]) ts+    ts = linspace 101 (0,100)+    l2v f = \t -> fromList  . f t . toList+    vanderpol mu _t [x,y] = [y, -x + mu * y * (1-x^2) ]+    newsol = [-1.758888036617841,  8.364349410519058e-2]+    -- oldsol = [-1.7588880332411019, 8.364348908711941e-2]  --------------------------------------------------------------------- @@ -622,6 +627,7 @@ runBenchmarks = do     solveBench     subBench+    mkVecBench     multBench     cholBench     svdBench@@ -638,6 +644,14 @@     printf "%6.2f s CPU\n" $ (fromIntegral (t1 - t0) / (10^12 :: Double)) :: IO ()     return () +timeR msg act = do+    putStr (msg++" ")+    t0 <- getCPUTime+    putStr (show act)+    t1 <- getCPUTime+    printf "%6.2f s CPU\n" $ (fromIntegral (t1 - t0) / (10^12 :: Double)) :: IO ()+    return ()+ --------------------------------  manymult n = foldl1' (<>) (map rot2 angles) where@@ -650,6 +664,37 @@               s = sin a  multb n = foldl1' (<>) (replicate (10^6) (ident n :: Matrix Double))++--------------------------------++manyvec0 xs = sum $ map (\x -> x + x**2 + x**3) xs+manyvec1 xs = sumElements $ fromRows $ map (\x -> fromList [x,x**2,x**3]) xs+manyvec5 xs = sumElements $ fromRows $ map (\x -> vec3 x (x**2) (x**3)) xs+++manyvec2 xs = sum $ map (\x -> sqrt(x^2 + (x**2)^2 +(x**3)^2)) xs+manyvec3 xs = sum $ map (pnorm PNorm2 . (\x -> fromList [x,x**2,x**3])) xs++manyvec4 xs = sum $ map (pnorm PNorm2 . (\x -> vec3 x (x**2) (x**3))) xs++vec3 :: Double -> Double -> Double -> Vector Double+vec3 a b c = runSTVector $ do+    v <- newUndefinedVector 3+    writeVector v 0 a+    writeVector v 1 b+    writeVector v 2 c+    return v++mkVecBench = do+    let n = 1000000+        xs = toList $ linspace n (0,1::Double)+    putStr "\neval data... "; print (sum xs)+    timeR "listproc        " $ manyvec0 xs+    timeR "fromList matrix " $ manyvec1 xs+    timeR "vec3 matrix     " $ manyvec5 xs+    timeR "listproc norm   " $ manyvec2 xs+    timeR "norm fromList   " $ manyvec3 xs+    timeR "norm vec3       " $ manyvec4 xs  --------------------------------