Mercurial > hg > may
view yetilab/vector/test/test_blockfuncs.yeti @ 238:0c86d9284f20 sparse
Implement sparse matrix construction, add tests for sparse matrices (currently failing)
author | Chris Cannam |
---|---|
date | Mon, 20 May 2013 14:18:14 +0100 |
parents | ac1373067054 |
children | 97e97a2e6a4e |
line wrap: on
line source
module yetilab.vector.test.test_blockfuncs; stdSqrt = sqrt; { zeros, consts, ones, fromList, list } = load yetilab.vector.vector; { sum, max, min, mean, multiply, divideBy, sqr, sqrt, rms, fftshift, ifftshift } = load yetilab.vector.blockfuncs; { compare } = load yetilab.test.test; [ "sum": \( compare ((sum . zeros) 0) 0 and compare ((sum . zeros) 5) 0 and compare ((sum . ones) 5) 5 and compare ((sum . fromList) [1,-2,3,0]) 2 ), "max": \( compare ((max . fromList) [1,-2,3,0]) 3 and compare ((max . fromList) [-1,-2,-3]) (-1) and compare ((max . fromList) [4,1]) 4 and compare ((max . fromList) []) 0 ), "min": \( compare ((min . fromList) [1,-2,3,0]) (-2) and compare ((min . fromList) [-1,-2,-3]) (-3) and compare ((min . fromList) [4,1]) 1 and compare ((min . fromList) []) 0 ), "mean": \( compare ((mean . zeros) 0) 0 and compare ((mean . zeros) 5) 0 and compare ((mean . ones) 5) 1 and compare ((mean . fromList) [1,-2,3,0]) 0.5 ), "multiply": \( compare (list (multiply (zeros 0) (ones 5))) [] and compare (list (multiply (consts (-3) 4) (fromList [1,2,3]))) [-3,-6,-9] ), "divideBy": \( compare (list (divideBy 5 (ones 0))) [] and compare (list (divideBy 5 (fromList [1,2,-3]))) [0.2,0.4,-0.6] ), "sqr": \( compare ((list . sqr . zeros) 0) [] and compare ((list . sqr . ones) 5) [1,1,1,1,1] and compare ((list . sqr . fromList) [0.5,-2,3,0]) [0.25,4,9,0] ), "sqrt": \( compare ((list . sqrt . zeros) 0) [] and compare ((list . sqrt . ones) 5) [1,1,1,1,1] and compare ((list . sqrt . fromList) [0.25,4,9,0]) [0.5,2,3,0] ), "rms": \( compare ((rms . zeros) 0) 0 and compare ((rms . ones) 5) 1 and compare ((rms . fromList) [-1,2,2]) (stdSqrt 3) ), "fftshift": \( compare ((list . fftshift . zeros) 0) [] and compare ((list . fftshift . fromList) [1,2,3,4]) [3,4,1,2] and compare ((list . fftshift . fromList) [1,2,3,4,5]) [4,5,1,2,3] ), "ifftshift": \( compare ((list . ifftshift . zeros) 0) [] and compare ((list . ifftshift . fromList) [3,4,1,2]) [1,2,3,4] and compare ((list . ifftshift . fromList) [4,5,1,2,3]) [1,2,3,4,5] ), ] is hash<string, () -> boolean>;