Skip to content

Commit dee2038

Browse files
committed
Add similar constructor for ExtendableSparse
Provide better show function (flushing and calling the CSC method)
1 parent 4fb397d commit dee2038

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ExtendableSparse"
22
uuid = "95c220a8-a1cf-11e9-0c77-dbfce5f500b3"
33
authors = ["Juergen Fuhrmann <[email protected]>"]
4-
version = "0.3.3"
4+
version = "0.3.4"
55

66
[deps]
77
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"

src/extendable.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ function ExtendableSparseMatrix(csc::SparseMatrixCSC{Tv,Ti}) where{Tv,Ti<:Intege
7070
return ExtendableSparseMatrix{Tv,Ti}(csc, nothing, time())
7171
end
7272

73+
"""
74+
$(SIGNATURES)
75+
Create similar extendableSparseMatrix
76+
"""
77+
Base.similar(m::ExtendableSparseMatrix{Tv,Ti}) where {Tv,Ti}=ExtendableSparseMatrix{Tv,Ti}(size(m)...)
7378

7479

7580
"""
@@ -155,6 +160,24 @@ Base.size(ext::ExtendableSparseMatrix) = (ext.cscmatrix.m, ext.cscmatrix.n)
155160

156161

157162

163+
"""
164+
$(SIGNATURES)
165+
166+
Show matrix
167+
"""
168+
function Base.show(io::IO,::MIME"text/plain",ext::ExtendableSparseMatrix)
169+
flush!(ext)
170+
xnnz = nnz(ext)
171+
m, n = size(ext)
172+
print(io, m, "×", n, " ", typeof(ext), " with ", xnnz, " stored ",
173+
xnnz == 1 ? "entry" : "entries")
174+
if !(m == 0 || n == 0 || xnnz==0)
175+
print(io, ":")
176+
show(IOContext(io), ext.cscmatrix)
177+
end
178+
end
179+
180+
158181
"""
159182
$(SIGNATURES)
160183

0 commit comments

Comments
 (0)