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

Fix exp10 fallback and exp2 and exp10 for Float16 #22716

Merged
merged 4 commits into from
Jul 16, 2017
Merged

Conversation

musm
Copy link
Contributor

@musm musm commented Jul 8, 2017

exp2 was not added to the Float16 definitions and hence calls the very slow fallback to 2^x.

exp10 does not have any fallback definitions and thus things like

julia> exp10(Float16(2.0))
ERROR: StackOverflowError:

lead to a StackOverFlow or with other AbstractFloat

test/math.jl Outdated
@@ -661,3 +661,17 @@ end
@test sincos(big(1)) == (sin(big(1)), cos(big(1)))
@test sincos(big(1.0)) == (sin(big(1.0)), cos(big(1.0)))
end

@testset "Float16 fallbacks" begin
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps integrate with

@test exp2(Float16(2.)) exp2(2.)
?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

base/math.jl Outdated
@@ -263,14 +263,27 @@ cbrt(x::AbstractFloat) = x < 0 ? -(-x)^(1//3) : x^(1//3)
"""
exp2(x)

Compute ``2^x``.
Compute the base `2` exponential of `x`, in other words ``2^x``.

```jldoctest
Copy link
Member

Choose a reason for hiding this comment

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

# Examples
```jldoctest

base/math.jl Outdated

Compute the base `10` exponential of `x`, in other words ``10^x``.

```jldoctest
Copy link
Member

Choose a reason for hiding this comment

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

# Examples
```jldoctest

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks will fix later

test/math.jl Outdated
end

# test AbstractFloat fallback
struct Float32432{T<:AbstractFloat} <: AbstractFloat
Copy link
Contributor

Choose a reason for hiding this comment

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

what is this number referring to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing, just a random string of numbers so it doesn't clash with another name

Copy link
Contributor

Choose a reason for hiding this comment

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

use the issue number or a word, less confusing that way

Copy link
Contributor Author

@musm musm Jul 9, 2017

Choose a reason for hiding this comment

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

I will change to use the PR number since I didn't open an issue for this

@musm
Copy link
Contributor Author

musm commented Jul 9, 2017

Appveyor looks missing, restarting

@musm musm closed this Jul 9, 2017
@musm musm reopened this Jul 9, 2017
@musm
Copy link
Contributor Author

musm commented Jul 14, 2017

Anything else to do here?

base/math.jl Outdated
@@ -263,14 +263,29 @@ cbrt(x::AbstractFloat) = x < 0 ? -(-x)^(1//3) : x^(1//3)
"""
exp2(x)

Compute ``2^x``.
Compute the base `2` exponential of `x`, in other words ``2^x``.
Copy link
Member

Choose a reason for hiding this comment

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

2 should probably not be code highlighted? Likewise 10 in the docstring below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see a harm in highlighting the number, maybe others have a different thought on this? Will update accordingly.

Copy link
Contributor

Choose a reason for hiding this comment

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

don't think it needs it for just the number on its own

@tkelman tkelman merged commit 3ff6eac into JuliaLang:master Jul 16, 2017
jeffwong pushed a commit to jeffwong/julia that referenced this pull request Jul 24, 2017
* Fix exp10 fallback and exp2 and exp10 for Float16

* Update docstring and test

* Change float struct name

* Update math.jl
ararslan pushed a commit that referenced this pull request Jul 3, 2018
* Fix exp10 fallback and exp2 and exp10 for Float16

* Update docstring and test

* Change float struct name

* Update math.jl

(cherry picked from commit 3ff6eac)
@musm musm deleted the expf branch May 15, 2019 17:00
@musm musm restored the expf branch May 15, 2019 17:00
@musm musm deleted the expf branch May 15, 2019 17:01
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.

None yet

3 participants