-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
incorrect code for Matrix^Number #21143
Comments
Looks like the |
Hello, is anyone working on this? If not I'd want to try and fix it. I think that @stevengj is right. |
A rebase went completely wrong in #12584 so the branch is pretty messy. I've cherry picked the relevant commits in https://github.com/JuliaLang/julia/tree/anj/powm so it is probably a good idea to use that branch if you want to work on this issue. It looks like most of the work is done. |
By the looks of it, julia> A = [2 1; 1 2]
2×2 Array{Int64,2}:
2 1
1 2
julia> expm(logm(A))
2×2 Array{Float64,2}:
2.0 1.0
1.0 2.0
julia> B = [3 2; -5 -3]
2×2 Array{Int64,2}:
3 2
-5 -3
julia> expm(logm(B))
2×2 Array{Float64,2}:
-5.33599 -5.66504
17.5616 18.4572 (In MATLAB So, I think that if we fix |
That seems like an expensive way to compute |
@stevengj You are obviously correct. What I meant was that by fixing 1 function: |
@iamnapo If you want to work on |
This is taking longer than anticipated, so moving out of 0.6.0 milestone. |
There are several issues with the
^(A::AbstractMatrix, p::Number)
method, illustrated by this example:The promotion is wrong for
Matrix{Int}^Float64
, since it doesn't promote the matrix if the power is integer-valued. The result is type-unstable and, more importantly, potentially wrong (since integers might overflow for large powers).It computes the eigenvalues
v
and checks whether they are negative viaany(v.<0)
, but this check is nonsensical if the eigenvalues are complex.Because it relies on the eigenvalue decomposition, it is potentially very inaccurate if the matrix is close to defective (and can fail entirely if it is defective, of course). It would be better to use something like our
expm
algorithm here.This is a pretty basic routine, so I was a little surprised to find it to be so buggy.
cc @jiahao and @andreasnoack (who have both touched this code).
The text was updated successfully, but these errors were encountered: