Skip to content

Commit 22305bd

Browse files
authored
Tests for MIME printing and indexing (#2686)
1 parent ff3a713 commit 22305bd

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/cusparse/array.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,15 +348,13 @@ end
348348

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

354352
LinearAlgebra.istriu(M::UpperTriangular{T,S}) where {T<:BlasFloat, S<:AbstractCuSparseMatrix} = true
355353
LinearAlgebra.istril(M::UpperTriangular{T,S}) where {T<:BlasFloat, S<:AbstractCuSparseMatrix} = false
356354
LinearAlgebra.istriu(M::LowerTriangular{T,S}) where {T<:BlasFloat, S<:AbstractCuSparseMatrix} = false
357355
LinearAlgebra.istril(M::LowerTriangular{T,S}) where {T<:BlasFloat, S<:AbstractCuSparseMatrix} = true
358356

359-
Hermitian{T}(Mat::CuSparseMatrix{T}) where T = Hermitian{T,typeof(Mat)}(Mat,'U')
357+
Hermitian{T}(Mat::CuSparseMatrix{T}) where {T} = Hermitian{eltype(Mat),typeof(Mat)}(Mat,'U')
360358

361359
SparseArrays.nnz(g::CuSparseMatrixBSR) = g.nnzb * g.blockDim * g.blockDim
362360

test/libraries/cusparse.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ blockdim = 5
5252
@test size(d_x,3) == 1
5353
@test ndims(d_x) == 2
5454
CUDA.@allowscalar begin
55+
@test sprint(show, MIME"text/plain"(), d_x) == replace(sprint(show, MIME"text/plain"(), x), "SparseMatrixCSC{Float64, Int64}"=>"CuSparseMatrixCSC{Float64, Int32}")
5556
@test Array(d_x[:]) == x[:]
5657
@test d_x[firstindex(d_x)] == x[firstindex(x)]
5758
@test d_x[div(end, 2)] == x[div(end, 2)]
@@ -135,6 +136,9 @@ blockdim = 5
135136
for i in 1:size(y, 1)
136137
@test d_y[i, :] y[i, :]
137138
end
139+
for j in 1:size(y, 2)
140+
@test d_y[:, j] y[:, j]
141+
end
138142
@test d_y[1, 1] y[1, 1]
139143
end
140144
d_y = CuSparseMatrixBSR(d_y, blockdim)
@@ -160,6 +164,8 @@ blockdim = 5
160164
x = sprand(ComplexF64, m, m, 0.2)
161165
d_x = Hermitian(CuSparseMatrixCSC(x + x'))
162166
@test ishermitian(d_x)
167+
d_x = Hermitian{ComplexF64}(CuSparseMatrixCSC(x + x'))
168+
@test ishermitian(d_x)
163169
x = sprand(m,m,0.2)
164170
d_x = UpperTriangular(CuSparseMatrixCSC(x))
165171
@test istriu(d_x)

0 commit comments

Comments
 (0)