Skip to content

Commit

Permalink
doc: add missing docstrings to SparseArrays (#31286)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarrasch authored and ViralBShah committed Apr 3, 2019
1 parent e0bef65 commit db428ef
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions stdlib/SparseArrays/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ section of the standard library reference.
# [Sparse Arrays](@id stdlib-sparse-arrays)

```@docs
SparseArrays.AbstractSparseArray
SparseArrays.AbstractSparseVector
SparseArrays.AbstractSparseMatrix
SparseArrays.SparseVector
SparseArrays.SparseMatrixCSC
SparseArrays.sparse
Expand All @@ -217,6 +220,7 @@ SparseArrays.sprandn
SparseArrays.nonzeros
SparseArrays.rowvals
SparseArrays.nzrange
SparseArrays.droptol!
SparseArrays.dropzeros!
SparseArrays.dropzeros
SparseArrays.permute
Expand Down
18 changes: 18 additions & 0 deletions stdlib/SparseArrays/src/abstractsparse.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license
"""
AbstractSparseArray{Tv,Ti,N}
Supertype for `N`-dimensional sparse arrays (or array-like types) with elements
of type `Tv` and index type `Ti`. [`SparseMatrixCSC`](@ref), [`SparseVector`](@ref)
and `SuiteSparse.CHOLMOD.Sparse` are subtypes of this.
"""
abstract type AbstractSparseArray{Tv,Ti,N} <: AbstractArray{Tv,N} end

"""
AbstractSparseVector{Tv,Ti}
Supertype for one-dimensional sparse arrays (or array-like types) with elements
of type `Tv` and index type `Ti`. Alias for `AbstractSparseArray{Tv,Ti,1}``.
"""
const AbstractSparseVector{Tv,Ti} = AbstractSparseArray{Tv,Ti,1}
"""
AbstractSparseMatrix{Tv,Ti}
Supertype for two-dimensional sparse arrays (or array-like types) with elements
of type `Tv` and index type `Ti`. Alias for `AbstractSparseArray{Tv,Ti,2}`.
"""
const AbstractSparseMatrix{Tv,Ti} = AbstractSparseArray{Tv,Ti,2}

"""
Expand Down
7 changes: 7 additions & 0 deletions stdlib/SparseArrays/src/sparsematrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,13 @@ tril!(A::SparseMatrixCSC, k::Integer = 0, trim::Bool = true) =
triu!(A::SparseMatrixCSC, k::Integer = 0, trim::Bool = true) =
fkeep!(A, (i, j, x) -> j >= i + k, trim)

"""
droptol!(A::SparseMatrixCSC, tol; trim::Bool = true)
Removes stored values from `A` whose absolute value is (strictly) larger than `tol`,
optionally trimming resulting excess space from `A.rowval` and `A.nzval` when `trim`
is `true`.
"""
droptol!(A::SparseMatrixCSC, tol; trim::Bool = true) =
fkeep!(A, (i, j, x) -> abs(x) > tol, trim)

Expand Down
7 changes: 7 additions & 0 deletions stdlib/SparseArrays/src/sparsevector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1911,6 +1911,13 @@ function fkeep!(x::SparseVector, f, trim::Bool = true)
x
end

"""
droptol!(x::SparseVector, tol; trim::Bool = true)
Removes stored values from `x` whose absolute value is (strictly) larger than `tol`,
optionally trimming resulting excess space from `A.rowval` and `A.nzval` when `trim`
is `true`.
"""
droptol!(x::SparseVector, tol; trim::Bool = true) = fkeep!(x, (i, x) -> abs(x) > tol, trim)

"""
Expand Down

0 comments on commit db428ef

Please sign in to comment.