Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Provide more "inline" operators such as copysign, isfinite, etc... #92

Open
eschnett opened this issue Apr 6, 2021 · 2 comments
Open
Labels
enhancement New feature or request

Comments

@eschnett
Copy link
Contributor

eschnett commented Apr 6, 2021

Certain math functions such as copysign can be implemented efficiently with bitwise operations. It would be convenient to have these available:

  • copysign
  • isfinite
  • isinf
  • isnan
  • isnormal
  • signbit

I find the non-standard flipsign function https://docs.julialang.org/en/v1/base/math/#Base.flipsign convenient, e.g. to implement upwind finite differencing stencils. It can be defined as

flipsign(x, y) = copysign(1, y) * x

but can be implemented more efficiently as

flipsign(x, y) = x ^ (y & SIGNMASK)
@gquintin gquintin added the enhancement New feature or request label Apr 6, 2021
@gquintin
Copy link
Contributor

gquintin commented Apr 6, 2021

This issue is more general than #32, so I am closing #32.

This was referenced Apr 6, 2021
@gquintin gquintin changed the title Provide copysign etc. Provide more "inline" operators such as copysign, isfinite, etc... Apr 6, 2021
@gquintin
Copy link
Contributor

gquintin commented Apr 6, 2021

I put the text of issue #93 into your orginal request to have it all here.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants