Skip to content

Conversation

leftaroundabout
Copy link
Contributor

In Haskell, signum x is defined to be -1 if x is negative, 1 if it is positive, and 0 if x is 0.

(In particular, signum x * abs x ≡ x should hold.)

This is different from ArrayFire's sign function (which yields 1 for a negative number and 0 else), but it can be implemented in terms of that function:

  • For negative x, we have A.sign (-x) - A.sign x = 0 - 1 = -1
  • For x=0, we have A.sign (-x) - A.sign x = 1 - 1 = 0
  • For positive x, we have A.sign (-x) - A.sign x = 1 - 0 = 1

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant