Skip to content

Commit 6e3c23a

Browse files
Correct signum function according to the Haskell report. (#60)
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.
1 parent 8a674d9 commit 6e3c23a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/ArrayFire/Orphans.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ instance (Num a, AFType a) => Num (Array a) where
3232
x + y = A.add x y
3333
x * y = A.mul x y
3434
abs = A.abs
35-
signum = A.sign
35+
signum x = A.sign (-x) - A.sign x
3636
negate arr = do
3737
let (w,x,y,z) = A.getDims arr
3838
A.cast (A.constant @a [w,x,y,z] 0) `A.sub` arr

0 commit comments

Comments
 (0)