Skip to content

Commit ea4901b

Browse files
committed
define default algorithm for base wrapper types
1 parent 0475754 commit ea4901b

5 files changed

Lines changed: 35 additions & 5 deletions

File tree

src/interface/eig.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,18 @@ See also [`eig_full(!)`](@ref eig_full) and [`eig_trunc(!)`](@ref eig_trunc).
161161
# -------------------
162162
default_eig_algorithm(A; kwargs...) = default_eig_algorithm(typeof(A); kwargs...)
163163
default_eig_algorithm(T::Type; kwargs...) = throw(MethodError(default_eig_algorithm, (T,)))
164-
function default_eig_algorithm(::Type{T}; kwargs...) where {T <: YALAPACK.MaybeBlasMat}
164+
function default_eig_algorithm(::Type{T}; kwargs...) where {T <: YALAPACK.MaybeBlasVecOrMat}
165165
return LAPACK_Expert(; kwargs...)
166166
end
167167
function default_eig_algorithm(::Type{T}; kwargs...) where {T <: Diagonal}
168168
return DiagonalAlgorithm(; kwargs...)
169169
end
170+
function default_eig_algorithm(::Type{<:Base.ReshapedArray{T, N, A}}) where {T, N, A}
171+
return default_eig_algorithm(A)
172+
end
173+
function default_eig_algorithm(::Type{SubArray{T, N, A}}) where {T, N, A}
174+
return default_eig_algorithm(A)
175+
end
170176

171177
for f in (:eig_full!, :eig_vals!)
172178
@eval function default_algorithm(::typeof($f), ::Type{A}; kwargs...) where {A}

src/interface/eigh.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,18 @@ default_eigh_algorithm(A; kwargs...) = default_eigh_algorithm(typeof(A); kwargs.
167167
function default_eigh_algorithm(T::Type; kwargs...)
168168
throw(MethodError(default_eigh_algorithm, (T,)))
169169
end
170-
function default_eigh_algorithm(::Type{T}; kwargs...) where {T <: YALAPACK.MaybeBlasMat}
170+
function default_eigh_algorithm(::Type{T}; kwargs...) where {T <: YALAPACK.MaybeBlasVecOrMat}
171171
return LAPACK_MultipleRelativelyRobustRepresentations(; kwargs...)
172172
end
173173
function default_eigh_algorithm(::Type{T}; kwargs...) where {T <: Diagonal}
174174
return DiagonalAlgorithm(; kwargs...)
175175
end
176+
function default_eigh_algorithm(::Type{<:Base.ReshapedArray{T, N, A}}) where {T, N, A}
177+
return default_eigh_algorithm(A)
178+
end
179+
function default_eigh_algorithm(::Type{SubArray{T, N, A}}) where {T, N, A}
180+
return default_eigh_algorithm(A)
181+
end
176182

177183
for f in (:eigh_full!, :eigh_vals!)
178184
@eval function default_algorithm(::typeof($f), ::Type{A}; kwargs...) where {A}

src/interface/lq.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,18 @@ end
7575
function default_lq_algorithm(::Type{T}; kwargs...) where {T <: AbstractMatrix}
7676
return Native_HouseholderLQ(; kwargs...)
7777
end
78-
function default_lq_algorithm(::Type{T}; kwargs...) where {T <: YALAPACK.MaybeBlasMat}
78+
function default_lq_algorithm(::Type{T}; kwargs...) where {T <: YALAPACK.MaybeBlasVecOrMat}
7979
return LAPACK_HouseholderLQ(; kwargs...)
8080
end
8181
function default_lq_algorithm(::Type{T}; kwargs...) where {T <: Diagonal}
8282
return DiagonalAlgorithm(; kwargs...)
8383
end
84+
function default_lq_algorithm(::Type{<:Base.ReshapedArray{T, N, A}}) where {T, N, A}
85+
return default_lq_algorithm(A)
86+
end
87+
function default_lq_algorithm(::Type{SubArray{T, N, A}}) where {T, N, A}
88+
return default_lq_algorithm(A)
89+
end
8490

8591
for f in (:lq_full!, :lq_compact!, :lq_null!)
8692
@eval function default_algorithm(::typeof($f), ::Type{A}; kwargs...) where {A}

src/interface/qr.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,18 @@ end
7575
function default_qr_algorithm(::Type{T}; kwargs...) where {T <: AbstractMatrix}
7676
return Native_HouseholderQR(; kwargs...)
7777
end
78-
function default_qr_algorithm(::Type{T}; kwargs...) where {T <: YALAPACK.MaybeBlasMat}
78+
function default_qr_algorithm(::Type{T}; kwargs...) where {T <: YALAPACK.MaybeBlasVecOrMat}
7979
return LAPACK_HouseholderQR(; kwargs...)
8080
end
8181
function default_qr_algorithm(::Type{T}; kwargs...) where {T <: Diagonal}
8282
return DiagonalAlgorithm(; kwargs...)
8383
end
84+
function default_qr_algorithm(::Type{<:Base.ReshapedArray{T, N, A}}) where {T, N, A}
85+
return default_qr_algorithm(A)
86+
end
87+
function default_qr_algorithm(::Type{SubArray{T, N, A}}) where {T, N, A}
88+
return default_qr_algorithm(A)
89+
end
8490

8591
for f in (:qr_full!, :qr_compact!, :qr_null!)
8692
@eval function default_algorithm(::typeof($f), ::Type{A}; kwargs...) where {A}

src/interface/svd.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,18 @@ default_svd_algorithm(A; kwargs...) = default_svd_algorithm(typeof(A); kwargs...
161161
function default_svd_algorithm(T::Type; kwargs...)
162162
throw(MethodError(default_svd_algorithm, (T,)))
163163
end
164-
function default_svd_algorithm(::Type{T}; kwargs...) where {T <: YALAPACK.MaybeBlasMat}
164+
function default_svd_algorithm(::Type{T}; kwargs...) where {T <: YALAPACK.MaybeBlasVecOrMat}
165165
return LAPACK_DivideAndConquer(; kwargs...)
166166
end
167167
function default_svd_algorithm(::Type{T}; kwargs...) where {T <: Diagonal}
168168
return DiagonalAlgorithm(; kwargs...)
169169
end
170+
function default_svd_algorithm(::Type{<:Base.ReshapedArray{T, N, A}}) where {T, N, A}
171+
return default_svd_algorithm(A)
172+
end
173+
function default_svd_algorithm(::Type{SubArray{T, N, A}}) where {T, N, A}
174+
return default_svd_algorithm(A)
175+
end
170176

171177
for f in (:svd_full!, :svd_compact!, :svd_vals!)
172178
@eval function default_algorithm(::typeof($f), ::Type{A}; kwargs...) where {A}

0 commit comments

Comments
 (0)