diff options
author | Tom Smeding <tom@tomsmeding.com> | 2025-02-16 00:30:25 +0100 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2025-02-16 00:30:25 +0100 |
commit | c14017f4bc28951be7e298d01769b5b49384a7c3 (patch) | |
tree | dd7ea8e90b28e37ac46251d11be2eb6c0ffc699b /test/Tests | |
parent | b0fae0894f4440c6cd9cd74b5a3515baa8bd8c35 (diff) |
arith: Unary int ops on strided arrays without normalisation
Diffstat (limited to 'test/Tests')
-rw-r--r-- | test/Tests/C.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/Tests/C.hs b/test/Tests/C.hs index 0530f53..97b425f 100644 --- a/test/Tests/C.hs +++ b/test/Tests/C.hs @@ -97,6 +97,17 @@ prop_sum_replicated doTranspose = property $ let rarr = rfromOrthotope inrank2 arrTrans almostEq 1e-8 (rtoOrthotope (rsumOuter1 rarr)) (orSumOuter1 outrank arrTrans) +prop_negate_normalised :: Property +prop_negate_normalised = property $ + genRank $ \rank@(SNat @n) -> do + sh <- forAll $ genShR rank + guard (all (> 0) (toList sh)) + arr <- forAllT $ OR.fromVector @Double @n (toList sh) <$> + genStorables (Range.singleton (product sh)) + (\w -> fromIntegral w / fromIntegral (maxBound :: Word64)) + let rarr = rfromOrthotope rank arr + rtoOrthotope (negate rarr) === OR.mapA negate arr + tests :: TestTree tests = testGroup "C" [testGroup "sum" @@ -106,4 +117,7 @@ tests = testGroup "C" ,testProperty "replicated" (prop_sum_replicated False) ,testProperty "replicated_transposed" (prop_sum_replicated True) ] + ,testGroup "negate" + [testProperty "normalised" prop_negate_normalised + ] ] |