File tree Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ Standard library changes
8484 * ` current_project() ` now searches the parent directories of a Git repository for a ` Project.toml ` file.
8585 This also affects the behavior of the ` --project ` command line option when using the default
8686 ` --project=@. ` ([ #29108 ] ).
87+ * Exponentiation operator ` ^ ` now supports raising a ` Irrational ` to an ` AbstractMatrix ` power ([ #29782 ] ).
8788
8889Compiler/Runtime improvements
8990-----------------------------
Original file line number Diff line number Diff line change @@ -371,6 +371,8 @@ LinearAlgebra.pinv
371371LinearAlgebra.nullspace
372372Base.kron
373373LinearAlgebra.exp(::StridedMatrix{<:LinearAlgebra.BlasFloat})
374+ Base.:^(::AbstractMatrix, ::Number)
375+ Base.:^(::Number, ::AbstractMatrix)
374376LinearAlgebra.log(::StridedMatrix)
375377LinearAlgebra.sqrt(::StridedMatrix{<:Real})
376378LinearAlgebra.cos(::StridedMatrix{<:Real})
Original file line number Diff line number Diff line change @@ -433,6 +433,20 @@ function (^)(A::AbstractMatrix{T}, p::Real) where T
433433 # Otherwise, use Schur decomposition
434434 return schurpow (A, p)
435435end
436+
437+ """
438+ ^(A::AbstractMatrix, p::Number)
439+
440+ Matrix power, equivalent to ``\\ exp(p\\ log(A))``
441+
442+ # Examples
443+ ```jldoctest
444+ julia> [1 2; 0 3]^3
445+ 2×2 Array{Int64,2}:
446+ 1 26
447+ 0 27
448+ ```
449+ """
436450(^ )(A:: AbstractMatrix , p:: Number ) = exp (p* log (A))
437451
438452# Matrix exponential
@@ -467,6 +481,28 @@ julia> exp(A)
467481exp (A:: StridedMatrix{<:BlasFloat} ) = exp! (copy (A))
468482exp (A:: StridedMatrix{<:Union{Integer,Complex{<:Integer}}} ) = exp! (float .(A))
469483
484+ """
485+ ^(b::Number, A::AbstractMatrix)
486+
487+ Matrix exponential, equivalent to ``\\ exp(\\ log(b)A)``.
488+
489+ !!! compat "Julia 1.1"
490+ Support for raising `Irrational` numbers (like `ℯ`)
491+ to a matrix was added in Julia 1.1.
492+
493+ # Examples
494+ ```jldoctest
495+ julia> 2^[1 2; 0 3]
496+ 2×2 Array{Float64,2}:
497+ 2.0 6.0
498+ 0.0 8.0
499+
500+ julia> ℯ^[1 2; 0 3]
501+ 2×2 Array{Float64,2}:
502+ 2.71828 17.3673
503+ 0.0 20.0855
504+ ```
505+ """
470506Base.:^ (b:: Number , A:: AbstractMatrix ) = exp! (log (b)* A)
471507# method for ℯ to explicitly elide the log(b) multiplication
472508Base.:^ (:: Irrational{:ℯ} , A:: AbstractMatrix ) = exp (A)
You can’t perform that action at this time.
0 commit comments