From 9098dc7c349da90cfa0d2b999e6b4db66903a38e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Justus=20Sagem=C3=BCller?= Date: Sat, 10 Aug 2024 02:00:13 +0200 Subject: [PATCH] Correct `signum` function according to the Haskell report. In Haskell, `signum x` is defined to be -1 if x is negative, 1 if it is positive, and 0 if x is 0. This is different from ArrayFire's `sign` function, but it can be implemented in terms of this function. --- src/ArrayFire/Orphans.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ArrayFire/Orphans.hs b/src/ArrayFire/Orphans.hs index e4d1c8a..63b2f4f 100644 --- a/src/ArrayFire/Orphans.hs +++ b/src/ArrayFire/Orphans.hs @@ -32,7 +32,7 @@ instance (Num a, AFType a) => Num (Array a) where x + y = A.add x y x * y = A.mul x y abs = A.abs - signum = A.sign + signum x = A.sign (-x) - A.sign x negate arr = do let (w,x,y,z) = A.getDims arr A.cast (A.constant @a [w,x,y,z] 0) `A.sub` arr