1
1
2
+ """
3
+ struct SparseMatrixCSR{T,Ti<:Integer} <: AbstractSparseMatrix{T,Ti}
4
+
5
+ Matrix type for storing sparse matrices in the
6
+ Compressed Sparse Row format. The standard way
7
+ of constructing SparseMatrixCSR is through the [`sparsecsr`](@ref) function.
8
+ """
2
9
struct SparseMatrixCSR{T,Ti<: Integer } <: AbstractSparseMatrix{T,Ti}
3
10
transpose :: SparseMatrixCSC{T,Ti}
4
11
end
@@ -8,15 +15,61 @@ show(io::IO, A::SparseMatrixCSR) = show(io, A.transpose)
8
15
size (A:: SparseMatrixCSR ) = (A. transpose. n, A. transpose. m)
9
16
getindex (A:: SparseMatrixCSR , x:: Integer , y:: Integer ) = getindex (A. transpose,y,x)
10
17
11
- nnz (S:: SparseMatrixCSR ) = nnz (S. transpose)
18
+ """
19
+ nnz(S::SparseMatrixCSR)
20
+
21
+ Returns the number of stored (filled) elements in a sparse array.
22
+ """
23
+ nnz (S:: SparseMatrixCSR ) = nnz (S. transpose)
24
+
25
+ """
26
+ count(pred, S::SparseMatrixCSR) -> Integer
27
+
28
+ Count the number of elements in S for which predicate pred returns true.
29
+ """
12
30
count (pred, S:: SparseMatrixCSR ) = count (pred, S. transpose)
13
31
32
+ """
33
+ nonzeros(S::SparseMatrixCSR)
34
+
35
+ Return a vector of the structural nonzero values in sparse array S.
36
+ This includes zeros that are explicitly stored in the sparse array.
37
+ The returned vector points directly to the internal nonzero storage of A,
38
+ and any modifications to the returned vector will mutate A as well.
39
+ """
14
40
nonzeros (S:: SparseMatrixCSR ) = S. transpose. nzval
15
41
42
+ """
43
+ nzrange(S::SparseMatrixCSR, row::Integer)
44
+
45
+ Return the range of indices to the structural nonzero values of a
46
+ sparse matrix row.
47
+ """
16
48
nzrange (S:: SparseMatrixCSR , row:: Integer ) = nzrange (S. transpose, row)
17
49
50
+ """
51
+ findnz(S::SparseMatrixCSR)
52
+
53
+ Return a tuple (I, J, V) where I and J are the row and column indices
54
+ of the stored ("structurally non-zero") values in sparse matrix A,
55
+ and V is a vector of the values.
56
+ """
18
57
findnz (S:: SparseMatrixCSR ) = findnz (S. transpose)
19
58
59
+ """
60
+ sparsecsr(I, J, V, [m, n, combine])
61
+
62
+ Create a sparse matrix S of dimensions m x n such that S[I[k], J[k]] = V[k].
63
+ The combine function is used to combine duplicates.
64
+ If m and n are not specified, they are set to
65
+ maximum(I) and maximum(J) respectively.
66
+ If the combine function is not supplied, combine defaults to +
67
+ unless the elements of V are Booleans in which case combine defaults to |.
68
+ All elements of I must satisfy 1 <= I[k] <= m,
69
+ and all elements of J must satisfy 1 <= J[k] <= n.
70
+ Numerical zeros in (I, J, V) are retained as structural nonzeros;
71
+ to drop numerical zeros, use dropzeros!.
72
+ """
20
73
sparsecsr (I,J,kwargs... ) = SparseMatrixCSR (sparse (J,I,kwargs... ))
21
74
22
75
0 commit comments