^(::Matrix{Int64}, ::Int64) is type unstable. See e.g.
fibonacci_Q = [1 1;1 0]
@code_warntype fibonacci_Q^2
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.
^(::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 anInt64if p>=0 or if x==1 or x==-1. Otherwise, it throws aDomainError.