Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Implement a flipsign function #93

Closed
eschnett opened this issue Apr 6, 2021 · 1 comment
Closed

Implement a flipsign function #93

eschnett opened this issue Apr 6, 2021 · 1 comment

Comments

@eschnett
Copy link
Contributor

eschnett commented Apr 6, 2021

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
Copy link
Contributor

gquintin commented Apr 6, 2021

If you allow me, I will "merge" this issue with #92 to have all this operators at one place.

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

No branches or pull requests

2 participants