Skip to content

Commit

Permalink
fix promotion of diagonal integer matrix to non-integer power (#23510)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre authored Aug 30, 2017
1 parent 9c6e496 commit a969c2a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion base/linalg/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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_oftype(A, TT)
for i in 1:n
retmat[i, i] = retmat[i, i] ^ p
end
Expand Down
5 changes: 5 additions & 0 deletions test/linalg/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,11 @@ end
end
end

@testset "diagonal integer matrix to real power" begin
A = Matrix(Diagonal([1, 2, 3]))
@test A^2.3 float(A)^2.3
end

@testset "issue #23366 (Int Matrix to Int power)" begin
@testset "Tests for $elty" for elty in (Int128, Int16, Int32, Int64, Int8,
UInt128, UInt16, UInt32, UInt64, UInt8,
Expand Down

3 comments on commit a969c2a

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

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

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

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

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

@fredrikekre
Copy link
Member Author

Choose a reason for hiding this comment

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

Are the regressions here something we should look into?

Please sign in to comment.