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 promotion of diagonal integer matrix to non-integer power #23510

Merged
merged 1 commit into from
Aug 30, 2017

Conversation

fredrikekre
Copy link
Member

julia> A = [1 0; 0 2];

julia> A^2.5
ERROR: InexactError: convert(Int64, 5.656854249492381)
Stacktrace:
 [1] convert at ./float.jl:703 [inlined]
 [2] setindex! at ./array.jl:802 [inlined]
 [3] ^(::Array{Int64,2}, ::Float64) at ./linalg/dense.jl:410

@fredrikekre fredrikekre added bugfix This change fixes an existing bug linear algebra Linear algebra labels Aug 30, 2017
@@ -405,7 +405,8 @@ function (^)(A::AbstractMatrix{T}, p::Real) where T

# Quicker return if A is diagonal
if isdiag(A)
retmat = copy(A)
TT = promote_op(^, T, typeof(p))
retmat = copy!(similar(A, TT), A)
Copy link
Member

Choose a reason for hiding this comment

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

You can use copy_oftype(A, TT) here.

@fredrikekre
Copy link
Member Author

spawn failure on macOS

Error in testset spawn:
Error During Test
  Got an exception of type LoadError outside of a @test
  LoadError: InterruptException:
  while loading /private/tmp/julia/share/julia/test/spawn.jl, in expression starting on line 73
ERROR: LoadError: Test run finished with errors
while loading /private/tmp/julia/share/julia/test/runtests.jl, in expression starting on line 29

@fredrikekre fredrikekre merged commit a969c2a into master Aug 30, 2017
@fredrikekre fredrikekre deleted the fe/diagonal-pow branch August 30, 2017 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug linear algebra Linear algebra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants