Skip to content

Commit c575811

Browse files
authored
Mention vectors in more docstrings (#591)
Some functions were documented as applying only to matrices but they actually work for vectors too.
1 parent 4fd3aad commit c575811

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

src/sparsematrix.jl

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ nonzeros(S::UpperTriangular{<:Any,<:SparseMatrixCSCUnion}) = nonzeros(S.data)
259259
nonzeros(S::LowerTriangular{<:Any,<:SparseMatrixCSCUnion}) = nonzeros(S.data)
260260

261261
"""
262-
rowvals(A::AbstractSparseMatrixCSC)
262+
rowvals(A)
263263
264-
Return a vector of the row indices of `A`. Any modifications to the returned
264+
Return a vector of the row indices of sparse array `A`. Any modifications to the returned
265265
vector will mutate `A` as well. Providing access to how the row indices are
266266
stored internally can be useful in conjunction with iterating over structural
267267
nonzero values. See also [`nonzeros`](@ref) and [`nzrange`](@ref).
@@ -287,10 +287,10 @@ rowvals(S::UpperTriangular{<:Any,<:SparseMatrixCSCUnion}) = rowvals(S.data)
287287
rowvals(S::LowerTriangular{<:Any,<:SparseMatrixCSCUnion}) = rowvals(S.data)
288288

289289
"""
290-
nzrange(A::AbstractSparseMatrixCSC, col::Integer)
290+
nzrange(A, col::Integer)
291291
292-
Return the range of indices to the structural nonzero values of a sparse matrix
293-
column. In conjunction with [`nonzeros`](@ref) and
292+
Return the range of indices to the structural nonzero values of column `col`
293+
of sparse array `A`. In conjunction with [`nonzeros`](@ref) and
294294
[`rowvals`](@ref), this allows for convenient iterating over a sparse matrix :
295295
296296
A = sparse(I,J,V)
@@ -994,9 +994,10 @@ float(S::SparseMatrixCSC) = SparseMatrixCSC(size(S, 1), size(S, 2), getcolptr(S)
994994
complex(S::SparseMatrixCSC) = SparseMatrixCSC(size(S, 1), size(S, 2), getcolptr(S), rowvals(S), complex(nonzeros(S)))
995995

996996
"""
997-
sparse(A)
997+
sparse(A::Union{AbstractVector, AbstractMatrix})
998998
999-
Convert an AbstractMatrix `A` into a sparse matrix.
999+
Convert a vector or matrix `A` into a sparse array.
1000+
Numerical zeros in `A` are turned into structural zeros.
10001001
10011002
# Examples
10021003
```jldoctest
@@ -1011,6 +1012,17 @@ julia> sparse(A)
10111012
1.0 ⋅ ⋅
10121013
⋅ 1.0 ⋅
10131014
⋅ ⋅ 1.0
1015+
1016+
julia> [1.0, 0.0, 1.0]
1017+
3-element Vector{Float64}:
1018+
1.0
1019+
0.0
1020+
1.0
1021+
1022+
julia> sparse([1.0, 0.0, 1.0])
1023+
3-element SparseVector{Float64, Int64} with 2 stored entries:
1024+
[1] = 1.0
1025+
[3] = 1.0
10141026
```
10151027
"""
10161028
sparse(A::AbstractMatrix{Tv}) where {Tv} = convert(SparseMatrixCSC{Tv}, A)

src/sparsevector.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ FixedSparseVector(s::AbstractSparseMatrixCSC{Tv,Ti}) where {Tv,Ti} = move_fixed(
511511
sparsevec(A)
512512
513513
Convert a vector `A` into a sparse vector of length `m`.
514+
Numerical zeros in `A` are turned into structural zeros.
514515
515516
# Examples
516517
```jldoctest

0 commit comments

Comments
 (0)