Skip to content

Commit b5aad00

Browse files
committed
Cover the Vector{<:GPUMatrix} case too
1 parent 9e0a9e9 commit b5aad00

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

‎ext/MatrixAlgebraKitCUDAExt/MatrixAlgebraKitCUDAExt.jl‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ end
3838
function MatrixAlgebraKit.default_eigh_algorithm(::Type{T}; kwargs...) where {T <: StridedCuArray{<:BlasFloat, 3}}
3939
return Jacobi(; kwargs...)
4040
end
41+
function MatrixAlgebraKit.default_eigh_algorithm(::Type{T}; kwargs...) where {T <: Vector{<:StridedCuMatrix{<:BlasFloat}}}
42+
return Jacobi(; kwargs...)
43+
end
4144

4245
for f in (:geqrf!, :ungqr!, :unmqr!)
4346
@eval $f(::CUSOLVER, args...) = YACUSOLVER.$f(args...)

‎test/testsuite/decompositions/eigh.jl‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ function test_eigh_full_batched(
6969
Ad = device_batch(As)
7070
Ac = deepcopy(Ad)
7171
m, n = size(first(As))
72+
73+
D, V = @testinferred batched_eigh_full(As)
74+
@test D isa Vector{<:AbstractMatrix{real(eltype(T))}} && length(D) == batch_size
75+
@test length(V) == batch_size
76+
for (a, d, v) in zip(As, D, V)
77+
@test a * v ≈ v * Diagonal(d)
78+
@test isunitary(v)
79+
@test all(isreal, d)
80+
end
7281

7382
D, V = @testinferred batched_eigh_full(Ad)
7483
@test D isa AbstractMatrix{real(eltype(T))} && size(D) == (n, batch_size)
@@ -84,6 +93,10 @@ function test_eigh_full_batched(
8493
@test a * v2 ≈ v2 * Diagonal(d2)
8594
end
8695

96+
D3 = @testinferred batched_eigh_vals(As)
97+
for (d, dd) in zip(eachslice(D, dims = 2), D3)
98+
@test d ≈ dd
99+
end
87100
D3 = @testinferred batched_eigh_vals(Ad)
88101
for (d, dd) in zip(eachslice(D, dims = 2), eachslice(D3, dims = 2))
89102
@test d ≈ dd

0 commit comments

Comments
 (0)