Mercurial > hg > may
view yetilab/vector/test/test_blockfuncs.yeti @ 296:ec6a36d88f57
Move complex tests to complex package
author | Chris Cannam |
---|---|
date | Fri, 31 May 2013 22:02:03 +0100 |
parents | 197d23954a4e |
children | 07389b654ff0 |
line wrap: on
line source
module yetilab.vector.test.test_blockfuncs; stdSqrt = sqrt; { zeros, consts, ones, fromList, list } = load yetilab.vector; { sum, max, min, mean, add, subtract, multiply, divideBy, scaled, abs, 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 ), "add": \( compare (list (add (zeros 0) (ones 5))) [] and compare (list (add (consts 3 4) (fromList [1,2,3]))) [4,5,6] and compare (list (add (consts (-3) 4) (fromList [1,2,3]))) [-2,-1,0] ), "subtract": \( compare (list (subtract (zeros 0) (ones 5))) [] and compare (list (subtract (consts 3 4) (fromList [1,2,3]))) [2,1,0] and compare (list (subtract (consts (-3) 4) (fromList [1,2,3]))) [-4,-5,-6] ), "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] ), "scaled": \( compare (list (scaled 5 (ones 0))) [] and compare (list (scaled 5 (fromList [1,2,-3]))) [5,10,-15] ), "abs": \( compare (list (abs (ones 0))) [] and compare (list (abs (fromList [1,2,-3]))) [1,2,3] ), "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>;