From 1ca064df150a0b461b6c8e9c8e4be837a11f06d6 Mon Sep 17 00:00:00 2001 From: sanderdemeyer Date: Fri, 3 Jul 2026 11:46:43 +0200 Subject: [PATCH 1/8] restrict types diagonal --- src/implementations/exponential.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/implementations/exponential.jl b/src/implementations/exponential.jl index cbaebeed..356788f8 100644 --- a/src/implementations/exponential.jl +++ b/src/implementations/exponential.jl @@ -98,7 +98,7 @@ end # Diagonal logic # -------------- -function exponential!(A, expA, alg::DiagonalAlgorithm) +function exponential!(A::AbstractMatrix, expA::AbstractMatrix, alg::DiagonalAlgorithm) check_input(exponential!, A, expA, alg) return map_diagonal!(exp, expA, A) end From 23ff1dc77ff4645bcb557ac5740bc819b4c0dea0 Mon Sep 17 00:00:00 2001 From: sanderdemeyer Date: Fri, 3 Jul 2026 17:40:33 +0200 Subject: [PATCH 2/8] DefaultAlgorithm intercepts for Diagonal --- src/implementations/exponential.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/implementations/exponential.jl b/src/implementations/exponential.jl index 356788f8..41154ef4 100644 --- a/src/implementations/exponential.jl +++ b/src/implementations/exponential.jl @@ -40,6 +40,12 @@ function check_input(::typeof(exponential!), (τ, A)::Tuple{Number, AbstractMatr return nothing end +# DefaultAlgorithm intercepts +# --------------------------- + +exponential!(t::Tuple{E, T}, ::DefaultAlgorithm) where {E <: Number, T <: Diagonal} = MAK.exponential!(t, DiagonalAlgorithm()) +exponential!(t::Tuple{E, T1}, out::T2, ::DefaultAlgorithm) where {E <: Number, T1 <: Diagonal, T2 <: Diagonal} = MAK.exponential!(t, out, DiagonalAlgorithm()) + # Outputs # ------- initialize_output(::typeof(exponential!), A::AbstractMatrix, ::AbstractAlgorithm) = A From b9a0af923fd4adecb39da48ef402a809e2600f77 Mon Sep 17 00:00:00 2001 From: sanderdemeyer Date: Sat, 4 Jul 2026 12:32:33 +0200 Subject: [PATCH 3/8] update to `default_algorithm` --- src/interface/exponential.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/interface/exponential.jl b/src/interface/exponential.jl index dd4d00d9..bebcdb1f 100644 --- a/src/interface/exponential.jl +++ b/src/interface/exponential.jl @@ -35,5 +35,9 @@ function default_algorithm(::typeof(exponential!), ::Type{A}; kwargs...) where { end function default_algorithm(::typeof(exponential!), ::Tuple{A, B}; kwargs...) where {A, B} - return default_exponential_algorithm(B; kwargs...) + return default_algorithm(exponential!, B; kwargs...) +end + +function default_algorithm(::typeof(exponential!), ::Type{Tuple{A, B}}; kwargs...) where {A, B} + return default_algorithm(exponential!, B; kwargs...) end From 4a2fae78c6845aa0be5e7a62c68ebba3321772a5 Mon Sep 17 00:00:00 2001 From: sanderdemeyer Date: Sat, 4 Jul 2026 12:55:52 +0200 Subject: [PATCH 4/8] Algorithm selection --- src/implementations/exponential.jl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/implementations/exponential.jl b/src/implementations/exponential.jl index 41154ef4..8499a0f2 100644 --- a/src/implementations/exponential.jl +++ b/src/implementations/exponential.jl @@ -40,11 +40,12 @@ function check_input(::typeof(exponential!), (τ, A)::Tuple{Number, AbstractMatr return nothing end -# DefaultAlgorithm intercepts +# Algorithm selection # --------------------------- - -exponential!(t::Tuple{E, T}, ::DefaultAlgorithm) where {E <: Number, T <: Diagonal} = MAK.exponential!(t, DiagonalAlgorithm()) -exponential!(t::Tuple{E, T1}, out::T2, ::DefaultAlgorithm) where {E <: Number, T1 <: Diagonal, T2 <: Diagonal} = MAK.exponential!(t, out, DiagonalAlgorithm()) +exponential!(A::AbstractMatrix, alg::DefaultAlgorithm) = exponential!(A, select_algorithm(exponential!, A, nothing; alg.kwargs...)) +exponential!(A::AbstractMatrix, out, alg::DefaultAlgorithm) = exponential!(A, out, select_algorithm(exponential!, A, nothing; alg.kwargs...)) +exponential!((τ, A)::Tuple{Number, AbstractMatrix}, alg::DefaultAlgorithm) = exponential!(A, select_algorithm(exponential!, A, nothing; alg.kwargs...)) +exponential!((τ, A)::Tuple{Number, AbstractMatrix}, out, alg::DefaultAlgorithm) = exponential!(A, out, select_algorithm(exponential!, A, nothing; alg.kwargs...)) # Outputs # ------- From 7714f3ecf60fc9b00ee08ac1b578250c0246bd8b Mon Sep 17 00:00:00 2001 From: Sander De Meyer <74001142+sanderdemeyer@users.noreply.github.com> Date: Sat, 4 Jul 2026 13:53:00 +0200 Subject: [PATCH 5/8] Update src/implementations/exponential.jl Co-authored-by: Lukas Devos --- src/implementations/exponential.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/implementations/exponential.jl b/src/implementations/exponential.jl index 8499a0f2..e16eff92 100644 --- a/src/implementations/exponential.jl +++ b/src/implementations/exponential.jl @@ -44,8 +44,8 @@ end # --------------------------- exponential!(A::AbstractMatrix, alg::DefaultAlgorithm) = exponential!(A, select_algorithm(exponential!, A, nothing; alg.kwargs...)) exponential!(A::AbstractMatrix, out, alg::DefaultAlgorithm) = exponential!(A, out, select_algorithm(exponential!, A, nothing; alg.kwargs...)) -exponential!((τ, A)::Tuple{Number, AbstractMatrix}, alg::DefaultAlgorithm) = exponential!(A, select_algorithm(exponential!, A, nothing; alg.kwargs...)) -exponential!((τ, A)::Tuple{Number, AbstractMatrix}, out, alg::DefaultAlgorithm) = exponential!(A, out, select_algorithm(exponential!, A, nothing; alg.kwargs...)) +exponential!(τA::Tuple{Number, AbstractMatrix}, alg::DefaultAlgorithm) = exponential!(τA, select_algorithm(exponential!, τA, nothing; alg.kwargs...)) +exponential!(τA::Tuple{Number, AbstractMatrix}, out, alg::DefaultAlgorithm) = exponential!(τA, out, select_algorithm(exponential!, τA, nothing; alg.kwargs...)) # Outputs # ------- From e078300b1bc0324d2ab326689b5566a24daff9ac Mon Sep 17 00:00:00 2001 From: sanderdemeyer Date: Mon, 6 Jul 2026 00:46:36 +0200 Subject: [PATCH 6/8] remove ambiguity --- src/implementations/exponential.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/implementations/exponential.jl b/src/implementations/exponential.jl index 8499a0f2..626d603d 100644 --- a/src/implementations/exponential.jl +++ b/src/implementations/exponential.jl @@ -43,9 +43,9 @@ end # Algorithm selection # --------------------------- exponential!(A::AbstractMatrix, alg::DefaultAlgorithm) = exponential!(A, select_algorithm(exponential!, A, nothing; alg.kwargs...)) -exponential!(A::AbstractMatrix, out, alg::DefaultAlgorithm) = exponential!(A, out, select_algorithm(exponential!, A, nothing; alg.kwargs...)) +exponential!(A::AbstractMatrix, out::AbstractMatrix, alg::DefaultAlgorithm) = exponential!(A, out, select_algorithm(exponential!, A, nothing; alg.kwargs...)) exponential!((τ, A)::Tuple{Number, AbstractMatrix}, alg::DefaultAlgorithm) = exponential!(A, select_algorithm(exponential!, A, nothing; alg.kwargs...)) -exponential!((τ, A)::Tuple{Number, AbstractMatrix}, out, alg::DefaultAlgorithm) = exponential!(A, out, select_algorithm(exponential!, A, nothing; alg.kwargs...)) +exponential!((τ, A)::Tuple{Number, AbstractMatrix}, out::AbstractMatrix, alg::DefaultAlgorithm) = exponential!(A, out, select_algorithm(exponential!, A, nothing; alg.kwargs...)) # Outputs # ------- From 5e2ac5c3f3f3462a63732f7f18435fc8de851f0f Mon Sep 17 00:00:00 2001 From: sanderdemeyer Date: Mon, 6 Jul 2026 00:48:28 +0200 Subject: [PATCH 7/8] Remove ambiguity --- src/implementations/exponential.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/implementations/exponential.jl b/src/implementations/exponential.jl index e16eff92..7479a5c7 100644 --- a/src/implementations/exponential.jl +++ b/src/implementations/exponential.jl @@ -43,9 +43,9 @@ end # Algorithm selection # --------------------------- exponential!(A::AbstractMatrix, alg::DefaultAlgorithm) = exponential!(A, select_algorithm(exponential!, A, nothing; alg.kwargs...)) -exponential!(A::AbstractMatrix, out, alg::DefaultAlgorithm) = exponential!(A, out, select_algorithm(exponential!, A, nothing; alg.kwargs...)) +exponential!(A::AbstractMatrix, out::AbstractMatrix, alg::DefaultAlgorithm) = exponential!(A, out, select_algorithm(exponential!, A, nothing; alg.kwargs...)) exponential!(τA::Tuple{Number, AbstractMatrix}, alg::DefaultAlgorithm) = exponential!(τA, select_algorithm(exponential!, τA, nothing; alg.kwargs...)) -exponential!(τA::Tuple{Number, AbstractMatrix}, out, alg::DefaultAlgorithm) = exponential!(τA, out, select_algorithm(exponential!, τA, nothing; alg.kwargs...)) +exponential!(τA::Tuple{Number, AbstractMatrix}, out::AbstractMatrix, alg::DefaultAlgorithm) = exponential!(τA, out, select_algorithm(exponential!, τA, nothing; alg.kwargs...)) # Outputs # ------- From 34a772929d9569ab1f833db8e996047d0a4a828c Mon Sep 17 00:00:00 2001 From: lkdvos Date: Mon, 6 Jul 2026 18:46:19 -0400 Subject: [PATCH 8/8] alter ambiguity fix to be in line with decompositions --- src/implementations/exponential.jl | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/implementations/exponential.jl b/src/implementations/exponential.jl index 7479a5c7..bb036916 100644 --- a/src/implementations/exponential.jl +++ b/src/implementations/exponential.jl @@ -8,14 +8,14 @@ copy_input(::typeof(exponential), A::Diagonal) = copy(A) copy_input(::typeof(exponential), (τ, A)::Tuple{Number, AbstractMatrix}) = (τ, copy!(similar(A, float(eltype(A))), A)) copy_input(::typeof(exponential), (τ, A)::Tuple{Number, Diagonal}) = τ, copy(A) -function check_input(::typeof(exponential!), A::AbstractMatrix, expA::AbstractMatrix, alg::AbstractAlgorithm) +function check_input(::typeof(exponential!), A::AbstractMatrix, expA, alg::AbstractAlgorithm) m = LinearAlgebra.checksquare(A) @check_size(expA, (m, m)) @check_scalar(expA, A) return nothing end -function check_input(::typeof(exponential!), A::AbstractMatrix, expA::AbstractMatrix, ::DiagonalAlgorithm) +function check_input(::typeof(exponential!), A::AbstractMatrix, expA, ::DiagonalAlgorithm) m = LinearAlgebra.checksquare(A) @assert isdiag(A) @assert expA isa Diagonal @@ -24,14 +24,14 @@ function check_input(::typeof(exponential!), A::AbstractMatrix, expA::AbstractMa return nothing end -function check_input(::typeof(exponential!), (τ, A)::Tuple{Number, AbstractMatrix}, expA::AbstractMatrix, alg::AbstractAlgorithm) +function check_input(::typeof(exponential!), (τ, A)::Tuple{Number, AbstractMatrix}, expA, alg::AbstractAlgorithm) m = LinearAlgebra.checksquare(A) @check_size(expA, (m, m)) @check_scalar(expA, A, (τ isa Real) ? identity : complex) return nothing end -function check_input(::typeof(exponential!), (τ, A)::Tuple{Number, AbstractMatrix}, expA::AbstractMatrix, ::DiagonalAlgorithm) +function check_input(::typeof(exponential!), (τ, A)::Tuple{Number, AbstractMatrix}, expA, ::DiagonalAlgorithm) m = LinearAlgebra.checksquare(A) @assert isdiag(A) @assert expA isa Diagonal @@ -43,9 +43,9 @@ end # Algorithm selection # --------------------------- exponential!(A::AbstractMatrix, alg::DefaultAlgorithm) = exponential!(A, select_algorithm(exponential!, A, nothing; alg.kwargs...)) -exponential!(A::AbstractMatrix, out::AbstractMatrix, alg::DefaultAlgorithm) = exponential!(A, out, select_algorithm(exponential!, A, nothing; alg.kwargs...)) +exponential!(A::AbstractMatrix, out, alg::DefaultAlgorithm) = exponential!(A, out, select_algorithm(exponential!, A, nothing; alg.kwargs...)) exponential!(τA::Tuple{Number, AbstractMatrix}, alg::DefaultAlgorithm) = exponential!(τA, select_algorithm(exponential!, τA, nothing; alg.kwargs...)) -exponential!(τA::Tuple{Number, AbstractMatrix}, out::AbstractMatrix, alg::DefaultAlgorithm) = exponential!(τA, out, select_algorithm(exponential!, τA, nothing; alg.kwargs...)) +exponential!(τA::Tuple{Number, AbstractMatrix}, out, alg::DefaultAlgorithm) = exponential!(τA, out, select_algorithm(exponential!, τA, nothing; alg.kwargs...)) # Outputs # ------- @@ -55,22 +55,22 @@ initialize_output(::typeof(exponential!), (τ, A)::Tuple{Number, AbstractMatrix} # Implementation # -------------- -function exponential!(A::AbstractMatrix, expA::AbstractMatrix, alg::MatrixFunctionViaLA) +function exponential!(A::AbstractMatrix, expA, alg::MatrixFunctionViaLA) check_input(exponential!, A, expA, alg) A = LinearAlgebra.exp!(A) A === expA || copy!(expA, A) return expA end -exponential!(A::AbstractMatrix, expA::AbstractMatrix, alg::MatrixFunctionViaEigh) = exponential!((one(eltype(A)), A), expA, alg) -exponential!(A::AbstractMatrix, expA::AbstractMatrix, alg::MatrixFunctionViaEig) = exponential!((one(eltype(A)), A), expA, alg) +exponential!(A::AbstractMatrix, expA, alg::MatrixFunctionViaEigh) = exponential!((one(eltype(A)), A), expA, alg) +exponential!(A::AbstractMatrix, expA, alg::MatrixFunctionViaEig) = exponential!((one(eltype(A)), A), expA, alg) -function exponential!((τ, A)::Tuple{Number, AbstractMatrix}, expA::AbstractMatrix, alg::AbstractAlgorithm) +function exponential!((τ, A)::Tuple{Number, AbstractMatrix}, expA, alg::AbstractAlgorithm) expA .= A .* τ return exponential!(expA, expA, alg) end -function exponential!((τ, A)::Tuple{Number, AbstractMatrix}, expA::AbstractMatrix, alg::MatrixFunctionViaEigh) +function exponential!((τ, A)::Tuple{Number, AbstractMatrix}, expA, alg::MatrixFunctionViaEigh) check_input(exponential!, (τ, A), expA, alg) D, V = eigh_full!(A, alg.eigh_alg) if eltype(A) <: Real @@ -90,7 +90,7 @@ function exponential!((τ, A)::Tuple{Number, AbstractMatrix}, expA::AbstractMatr end end -function exponential!((τ, A)::Tuple{Number, AbstractMatrix}, expA::AbstractMatrix, alg::MatrixFunctionViaEig) +function exponential!((τ, A)::Tuple{Number, AbstractMatrix}, expA, alg::MatrixFunctionViaEig) check_input(exponential!, (τ, A), expA, alg) D, V = eig_full!(A, alg.eig_alg) if eltype(A) <: Real && eltype(τ) <: Real @@ -105,12 +105,12 @@ end # Diagonal logic # -------------- -function exponential!(A::AbstractMatrix, expA::AbstractMatrix, alg::DiagonalAlgorithm) +function exponential!(A::AbstractMatrix, expA, alg::DiagonalAlgorithm) check_input(exponential!, A, expA, alg) return map_diagonal!(exp, expA, A) end -function exponential!((τ, A)::Tuple{Number, AbstractMatrix}, expA::AbstractMatrix, alg::DiagonalAlgorithm) +function exponential!((τ, A)::Tuple{Number, AbstractMatrix}, expA, alg::DiagonalAlgorithm) check_input(exponential!, (τ, A), expA, alg) return map_diagonal!(x -> exp(x * τ), expA, A) end