11
11
_ mat.Mutable = (* COO )(nil )
12
12
)
13
13
14
- // COO is a COOrdinate format sparse matrix implementation (sometimes called `Tiplet ` format) and implements the
15
- // Matrix interface from gonum/matrix. This allows large sparse (mostly zero values ) matrices to be stored
14
+ // COO is a COOrdinate format sparse matrix implementation (sometimes called `Triplet ` format) and implements the
15
+ // Matrix interface from gonum/matrix. This allows large sparse (mostly zero-valued ) matrices to be stored
16
16
// efficiently in memory (only storing non-zero values). COO matrices are good for constructing sparse matrices
17
17
// initially and very good at converting to CSR and CSC formats but poor for arithmetic operations. As this
18
18
// type implements the gonum mat.Matrix interface, it may be used with any of the Gonum mat functions that
@@ -25,7 +25,7 @@ type COO struct {
25
25
data []float64
26
26
}
27
27
28
- // NewCOO creates a new DIAgonal format sparse matrix.
28
+ // NewCOO creates a new COOrdinate format sparse matrix.
29
29
// The matrix is initialised to the size of the specified r * c dimensions (rows * columns)
30
30
// with the specified slices containing either nil or containing rows and cols indexes of non-zero elements
31
31
// and the non-zero data values themselves respectively. If not nil, the supplied slices will be used as the
@@ -54,12 +54,14 @@ func NewCOO(r int, c int, rows []int, cols []int, data []float64) *COO {
54
54
return coo
55
55
}
56
56
57
- // NNZ returns the Number of Non Zero elements in the sparse matrix.
57
+ // NNZ returns the number of stored data elements. This number includes explicit
58
+ // zeroes, if stored, and may be exceed the total number of matrix elements
59
+ // (rows * columns) if duplicate coordinates are stored.
58
60
func (c * COO ) NNZ () int {
59
61
return len (c .data )
60
62
}
61
63
62
- // DoNonZero calls the function fn for each of the non-zero elements of the receiver.
64
+ // DoNonZero calls the function fn for each of the stored data elements in the receiver.
63
65
// The function fn takes a row/column index and the element value of the receiver at
64
66
// (i, j). The order of visiting to each non-zero element is not guaranteed.
65
67
func (c * COO ) DoNonZero (fn func (i , j int , v float64 )) {
0 commit comments