Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/host/sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function LinearAlgebra.opnorm(A::AbstractGPUSparseMatrixCSR, p::Real=2)
end
end

LinearAlgebra.opnorm(A::AbstractGPUSparseMatrixCSC, p::Real=2) = opnorm(_csr_type(A)(A), p)
LinearAlgebra.opnorm(A::AbstractGPUSparseMatrixCSC, p::Real=2) = opnorm(csr_type(A)(A), p)

function LinearAlgebra.norm(A::AbstractGPUSparseMatrix{T}, p::Real=2) where T
if p == Inf
Expand Down
25 changes: 25 additions & 0 deletions test/testsuite/sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
matrix_construction(sparse_AT, eltypes)
broadcasting_matrix(sparse_AT, eltypes)
mapreduce_matrix(sparse_AT, eltypes)
linalg(sparse_AT, eltypes)
end
end
end
Expand Down Expand Up @@ -336,3 +337,27 @@ function mapreduce_matrix(AT, eltypes)
end
end
end

function linalg(AT, eltypes)
dense_AT = GPUArrays.dense_array_type(AT)
for ET in eltypes
# sprandn doesn't work nicely with these...
if !(ET <: Union{Int16, Int32, Int64, Complex{Int16}, Complex{Int32}, Complex{Int64}})
@testset "Sparse matrix($ET) linear algebra" begin
m = 10
A = sprandn(ET, m, m, 0.2)
B = sprandn(ET, m, m, 0.3)
ZA = spzeros(ET, m, m)
C = I(div(m, 2))
dA = AT(A)
dB = AT(B)
dZA = AT(ZA)
@testset "opnorm and norm" begin
@test opnorm(A, Inf) ≈ opnorm(dA, Inf)
@test opnorm(A, 1) ≈ opnorm(dA, 1)
@test_throws ArgumentError opnorm(dA, 2)
end
end
end
end
end
Loading