Skip to content

Commit

Permalink
Tests for MIME printing and indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyatt committed Mar 11, 2025
1 parent c75b56f commit d215d1a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 0 additions & 2 deletions lib/cusparse/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,6 @@ end

LinearAlgebra.issymmetric(M::Union{CuSparseMatrixCSC,CuSparseMatrixCSR}) = size(M, 1) == size(M, 2) ? norm(M - transpose(M), Inf) == 0 : false
LinearAlgebra.ishermitian(M::Union{CuSparseMatrixCSC,CuSparseMatrixCSR}) = size(M, 1) == size(M, 2) ? norm(M - adjoint(M), Inf) == 0 : false
LinearAlgebra.issymmetric(M::Symmetric{CuSparseMatrixCSC}) = true
LinearAlgebra.ishermitian(M::Hermitian{CuSparseMatrixCSC}) = true

LinearAlgebra.istriu(M::UpperTriangular{T,S}) where {T<:BlasFloat, S<:AbstractCuSparseMatrix} = true
LinearAlgebra.istril(M::UpperTriangular{T,S}) where {T<:BlasFloat, S<:AbstractCuSparseMatrix} = false
Expand Down
6 changes: 6 additions & 0 deletions test/libraries/cusparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ blockdim = 5
@test size(d_x,3) == 1
@test ndims(d_x) == 2
CUDA.@allowscalar begin
@test sprint(show, MIME"text/plain"(), d_x) == replace(sprint(show, MIME"text/plain"(), x), "SparseMatrixCSC{Float64, Int64}"=>"CuSparseMatrixCSC{Float64, Int32}")
@test Array(d_x[:]) == x[:]
@test d_x[firstindex(d_x)] == x[firstindex(x)]
@test d_x[div(end, 2)] == x[div(end, 2)]
Expand Down Expand Up @@ -135,6 +136,9 @@ blockdim = 5
for i in 1:size(y, 1)
@test d_y[i, :] y[i, :]
end
for j in 1:size(y, 2)
@test d_y[:, j] y[:, j]
end
@test d_y[1, 1] y[1, 1]
end
d_y = CuSparseMatrixBSR(d_y, blockdim)
Expand All @@ -160,6 +164,8 @@ blockdim = 5
x = sprand(ComplexF64, m, m, 0.2)
d_x = Hermitian(CuSparseMatrixCSC(x + x'))
@test ishermitian(d_x)
d_x = Hermitian{ComplexF64}(CuSparseMatrixCSC(x + x'))
@test ishermitian(d_x)
x = sprand(m,m,0.2)
d_x = UpperTriangular(CuSparseMatrixCSC(x))
@test istriu(d_x)
Expand Down

0 comments on commit d215d1a

Please sign in to comment.