Skip to content

Conversation

@andreasnoack
Copy link
Member

Following up on #15552.

  1. Use the julia implementation of hypot. On my MacBook it is more that 2x faster than the libm version.
  2. Loosen signature to allow for complex input
  3. Make a few changes to make sure that the return type is correctly inferred for more exotic types. (Hopefully, one day the dead branches that cause type instability can be eliminated such that it's not necessary to convert the return elements in the dead branches.)
  4. Add an arbitrary argument version of hypot. This supersedes Extend hypot to 1-arg, 3-arg and varargs #15552. (just realized that doc update is missing. I'll push that tomorrow.)
test/math.jl Outdated
@test isinf(log1p(-one(T)))
@test isnan(log1p(convert(T,NaN)))
@test_throws DomainError log1p(convert(T,-2.0))
@test hypot(T(0), T(0)) == T(0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=== to test for type equality too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Just did that.

end
if x == 0
r = y/one(x)
if ax == 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is comparing to 0 sufficient or do we need if ax == zero(ax) ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For comparisons, you don't need to call zero. It's only useful when you want a specific type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants