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

missing matrix exponentiation methods for \euler #579

Closed
ExpandingMan opened this issue Oct 19, 2018 · 5 comments · Fixed by JuliaLang/julia#29782
Closed

missing matrix exponentiation methods for \euler #579

ExpandingMan opened this issue Oct 19, 2018 · 5 comments · Fixed by JuliaLang/julia#29782

Comments

@ExpandingMan
Copy link
Contributor

Is there any reason for this? Currently the following is defined in base/mathconstants.jl:

for T in (AbstractIrrational, Rational, Integer, Number, Complex)
    Base.:^(::Irrational{:ℯ}, x::T) = exp(x)
end

Is there any reason why this is not simply

Base.:^(::Irrational{:ℯ}, x) = exp(x)
@StefanKarpinski
Copy link
Member

I can't recall, but one thing that occurs to me is that it might cause a lot of method ambiguities?

@ExpandingMan
Copy link
Contributor Author

Why? The type on the first argument is Irrational{:\euler}, that's pretty specific.

@StefanKarpinski
Copy link
Member

It is, but the other argument is as general as it gets so this would be ambiguous with ^(::Number, ::T) for any type that's more specific than Any, for example.

@ExpandingMan
Copy link
Contributor Author

ExpandingMan commented Oct 19, 2018

Oh yeah, I didn't think of that, that could be bad. So, I suppose what it should be is

for T  (AbstractIrrational, Rational, Integer, Number, Complex)
    Base.:^(::Irrational{:ℯ}, x::T) = exp(x)
    Base.:^(::Irrational{:ℯ}, x::AbstractArray{T}) = exp(x)
end

Could probably make it just AbstractMatrix to cut down on the ambituity further.

I can put in a PR if nobody foresees any other obvious potential issues.

@ExpandingMan
Copy link
Contributor Author

Wow, there's even a comment right there that says it was to avoid ambiguities for ^(::Number, x). I feel really stupid.

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 a pull request may close this issue.

3 participants