@@ -1763,35 +1763,6 @@ end
17631763
17641764# # fkeep! and children tril!, triu!, droptol!, dropzeros[!]
17651765
1766- """
1767- fkeep!(f, A::AbstractSparseArray)
1768-
1769- Keep elements of `A` for which test `f` returns `true`. `f`'s signature should be
1770-
1771- f(i::Integer, [j::Integer,] x) -> Bool
1772-
1773- where `i` and `j` are an element's row and column indices and `x` is the element's
1774- value. This method makes a single sweep
1775- through `A`, requiring `O(size(A, 2), nnz(A))`-time for matrices and `O(nnz(A))`-time for vectors
1776- and no space beyond that passed in.
1777-
1778- # Examples
1779- ```jldoctest
1780- julia> A = sparse(Diagonal([1, 2, 3, 4]))
1781- 4×4 SparseMatrixCSC{Int64, Int64} with 4 stored entries:
1782- 1 ⋅ ⋅ ⋅
1783- ⋅ 2 ⋅ ⋅
1784- ⋅ ⋅ 3 ⋅
1785- ⋅ ⋅ ⋅ 4
1786-
1787- julia> SparseArrays.fkeep!((i, j, v) -> isodd(v), A)
1788- 4×4 SparseMatrixCSC{Int64, Int64} with 2 stored entries:
1789- 1 ⋅ ⋅ ⋅
1790- ⋅ ⋅ ⋅ ⋅
1791- ⋅ ⋅ 3 ⋅
1792- ⋅ ⋅ ⋅ ⋅
1793- ```
1794- """
17951766function _fkeep! (f:: F , A:: AbstractSparseMatrixCSC ) where F<: Function
17961767 An = size (A, 2 )
17971768 Acolptr = getcolptr (A)
@@ -1839,6 +1810,35 @@ function _fkeep!_fixed(f::F, A::AbstractSparseMatrixCSC) where F<:Function
18391810 return A
18401811end
18411812
1813+ """
1814+ fkeep!(f, A::AbstractSparseArray)
1815+
1816+ Keep elements of `A` for which test `f` returns `true`. `f`'s signature should be
1817+
1818+ f(i::Integer, [j::Integer,] x) -> Bool
1819+
1820+ where `i` and `j` are an element's row and column indices and `x` is the element's
1821+ value. This method makes a single sweep
1822+ through `A`, requiring `O(size(A, 2), nnz(A))`-time for matrices and `O(nnz(A))`-time for vectors
1823+ and no space beyond that passed in.
1824+
1825+ # Examples
1826+ ```jldoctest
1827+ julia> A = sparse(Diagonal([1, 2, 3, 4]))
1828+ 4×4 SparseMatrixCSC{Int64, Int64} with 4 stored entries:
1829+ 1 ⋅ ⋅ ⋅
1830+ ⋅ 2 ⋅ ⋅
1831+ ⋅ ⋅ 3 ⋅
1832+ ⋅ ⋅ ⋅ 4
1833+
1834+ julia> SparseArrays.fkeep!((i, j, v) -> isodd(v), A)
1835+ 4×4 SparseMatrixCSC{Int64, Int64} with 2 stored entries:
1836+ 1 ⋅ ⋅ ⋅
1837+ ⋅ ⋅ ⋅ ⋅
1838+ ⋅ ⋅ 3 ⋅
1839+ ⋅ ⋅ ⋅ ⋅
1840+ ```
1841+ """
18421842fkeep! (f:: F , A:: AbstractSparseMatrixCSC ) where F<: Function = _is_fixed (A) ? _fkeep!_fixed (f, A) : _fkeep! (f, A)
18431843
18441844# deprecated syntax
0 commit comments