diff --git a/src/util.jl b/src/util.jl index b7923b5..cd69b9b 100644 --- a/src/util.jl +++ b/src/util.jl @@ -2,7 +2,7 @@ #using CSC format for interop with Julia's native sparse functionality import Base: length, size, ndims, eltype, similar, pointer, stride, - copy, convert, reinterpret, show, summary, copy!, get!, fill!, issym, + copy, convert, reinterpret, show, showarray, summary, copy!, get!, fill!, issym, ishermitian, isupper, islower import Base.LinAlg: BlasFloat, Hermitian, HermOrSym import CUDArt: device, to_host, free @@ -234,3 +234,11 @@ copy(Vec::CudaSparseVector; stream=null_stream) = copy!(similar(Vec),Vec;stream= copy(Mat::CudaSparseMatrixCSC; stream=null_stream) = copy!(similar(Mat),Mat;stream=null_stream) copy(Mat::CudaSparseMatrixCSR; stream=null_stream) = copy!(similar(Mat),Mat;stream=null_stream) copy(Mat::CudaSparseMatrixBSR; stream=null_stream) = copy!(similar(Mat),Mat;stream=null_stream) + +function showarray(io::IO, S::CudaSparseMatrix; + header::Bool=true, limit::Bool=Base._limit_output,rows = Base.tty_size()[1], repr=false) + to_host(S) + + s = to_host(S) + showarray(io,s;header=header,limit=limit,rows=rows,repr=repr) +end diff --git a/test/runtests.jl b/test/runtests.jl index 5d5ed61..7cb7961 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -25,6 +25,12 @@ d_y = CUSPARSE.switch2bsr(d_y,convert(Cint,blockdim)) d_x = CUSPARSE.switch2bsr(d_x,convert(Cint,blockdim)) @test_throws ArgumentError copy!(d_y,d_x) +# issue #21 +A = speye(20) +d_A = CudaSparseMatrixCSR(A) +@test sprint(show,d_A) == "\n\t[1 , 1] = 1.0\n\t[2 , 2] = 1.0\n\t[3 , 3] = 1.0\n\t[4 , 4] = 1.0\n\t[5 , 5] = 1.0\n\t[6 , 6] = 1.0\n\t[7 , 7] = 1.0\n\t[8 , 8] = 1.0\n\t[9 , 9] = 1.0\n\t[10, 10] = 1.0\n\t[11, 11] = 1.0\n\t[12, 12] = 1.0\n\t[13, 13] = 1.0\n\t[14, 14] = 1.0\n\t[15, 15] = 1.0\n\t[16, 16] = 1.0\n\t[17, 17] = 1.0\n\t[18, 18] = 1.0\n\t[19, 19] = 1.0\n\t[20, 20] = 1.0" + + # misc char tests @test_throws ArgumentError CUSPARSE.cusparseop('Z')