Skip to content

Commit 4dcbaf6

Browse files
committed
add defaults and more tests
1 parent 75e0d03 commit 4dcbaf6

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

src/interface/lq.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ default_lq_algorithm(A; kwargs...) = default_lq_algorithm(typeof(A); kwargs...)
7272
function default_lq_algorithm(T::Type; kwargs...)
7373
throw(MethodError(default_lq_algorithm, (T,)))
7474
end
75+
function default_lq_algorithm(::Type{T}; kwargs...) where {T <: AbstractMatrix}
76+
return Native_HouseholderLQ(; kwargs...)
77+
end
7578
function default_lq_algorithm(::Type{T}; kwargs...) where {T <: YALAPACK.BlasMat}
7679
return LAPACK_HouseholderLQ(; kwargs...)
7780
end

src/interface/qr.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ default_qr_algorithm(A; kwargs...) = default_qr_algorithm(typeof(A); kwargs...)
7272
function default_qr_algorithm(T::Type; kwargs...)
7373
throw(MethodError(default_qr_algorithm, (T,)))
7474
end
75+
function default_qr_algorithm(::Type{T}; kwargs...) where {T <: AbstractMatrix}
76+
return Native_HouseholderQR(; kwargs...)
77+
end
7578
function default_qr_algorithm(::Type{T}; kwargs...) where {T <: YALAPACK.BlasMat}
7679
return LAPACK_HouseholderQR(; kwargs...)
7780
end

test/lq.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ using LinearAlgebra: diag, I, Diagonal
66
using MatrixAlgebraKit: LQViaTransposedQR, LAPACK_HouseholderQR
77

88
lapack_eltypes = (Float32, Float64, ComplexF32, ComplexF64)
9-
native_eltypes = (lapack_eltypes..., BigFloat, Complex{BigFloat})
9+
native_eltypes = (lapack_eltypes..., Float16, BigFloat, Complex{BigFloat})
1010

1111
@testset "lq_compact! for T = $T" for T in lapack_eltypes
1212
rng = StableRNG(123)
@@ -299,5 +299,10 @@ end
299299
@test Q2 === Q
300300
@test L * Q A
301301
@test isunitary(Q)
302+
303+
if !(T lapack_eltypes)
304+
alg = MatrixAlgebraKit.select_algorithm(lq_compact!, A)
305+
@test alg == Native_HouseholderLQ()
306+
end
302307
end
303308
end

test/qr.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ using StableRNGs
55
using LinearAlgebra: diag, I, Diagonal
66

77
lapack_eltypes = (Float32, Float64, ComplexF32, ComplexF64)
8-
native_eltypes = (lapack_eltypes..., BigFloat, Complex{BigFloat})
8+
native_eltypes = (lapack_eltypes..., Float16, BigFloat, Complex{BigFloat})
99

1010
@testset "qr_compact! and qr_null! for T = $T" for T in lapack_eltypes
1111
rng = StableRNG(123)
@@ -269,5 +269,10 @@ end
269269
@test R2 === R
270270
@test Q * R ≈ A
271271
@test isunitary(Q)
272+
273+
if !(T ∈ lapack_eltypes)
274+
alg = MatrixAlgebraKit.select_algorithm(qr_compact!, A)
275+
@test alg == Native_HouseholderQR()
276+
end
272277
end
273278
end

0 commit comments

Comments
 (0)