You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
which shows Union{Array{Float64,2}, Array{Int64,2}}. The reason seems to be that ^(A::Matrix{Int64}, p::Int64) returns a Matrix{Float64} if p<0.
This is inconsistent with the behavior of ^(x::Int64, p::Int64), which returns an Int64 if p>=0 or if x==1 or x==-1. Otherwise, it throws a DomainError.
The text was updated successfully, but these errors were encountered:
A related issue (also fixed by JuliaLang/julia#23368 ) is that ^(::AbstractArray{S}, ::T) where S<:Integer, T<:Integer does not promote types the same way as ^(::S, ::T). For example, [1 1;1 0]^big(10000) returns a Matrix{Int64} (which overflows) rather than Matrix{BigInt}. This behavior is different from 2^big(10000), which returns a BigInt.
I'll adjust the title of the issue to reflect this.
afniedermayer
changed the title
^(::Matrix{Int64}, ::Int64) is not type stable
Behavior of ^(::Matrix{<:Integer}, ::Integer) inconsistent with behavior of ^(::Integer, ::Integer)Aug 23, 2017
^(::Matrix{Int64}, ::Int64)
is type unstable. See e.g.which shows
Union{Array{Float64,2}, Array{Int64,2}}
. The reason seems to be that^(A::Matrix{Int64}, p::Int64)
returns aMatrix{Float64}
if p<0.This is inconsistent with the behavior of
^(x::Int64, p::Int64)
, which returns anInt64
if p>=0 or if x==1 or x==-1. Otherwise, it throws aDomainError
.The text was updated successfully, but these errors were encountered: