Skip to content

Commit 4338a00

Browse files
authored
Add number_of_stored_values as a key. (#52)
1 parent 51647ae commit 4338a00

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

spec/latest/index.bs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ outside of the "binsparse" namespace.
5656
<div class=example>
5757

5858
Example of a JSON descriptor for a compressed-sparse column (CSC) matrix with 10
59-
rows and 12 columns, containing float32 values, along with user-defined
59+
rows and 12 columns, containing 20 float32 values, along with user-defined
6060
attributes.
6161

6262
```json
@@ -65,6 +65,7 @@ attributes.
6565
"version": "0.1",
6666
"format": "CSC",
6767
"shape": [10, 12],
68+
"number_of_stored_values": 20,
6869
"data_types": {
6970
"pointers_to_1": "uint64",
7071
"indices_1": "uint64",
@@ -98,6 +99,18 @@ contain the vector's dimension.
9899
Note: a matrix has shape [`number_of_rows`, `number_of_columns`] regardless of whether
99100
the format orientation is row-wise or column-wise.
100101

102+
Number of Stored Values {#key_number_of_stored_values}
103+
------------------------------------------------------
104+
105+
The `number_of_stored_values` key must be present and shall define the number
106+
of explicit values that are stored as explicit entries in the sparse tensor
107+
format.
108+
109+
Note: For sparse tensors with all values the same (ISO), `number_of_stored_values`
110+
still refers to the number of explicit entries in the sparse tensor format whose
111+
indices are stored, regardless of the fact that the individual scalar values
112+
themselves are not explicitly stored.
113+
101114
Fill {#key_fill}
102115
--------------------
103116
The `fill` key may be present. If the `fill` key is present, it shall have a
@@ -670,6 +683,7 @@ Example of a CSR Matrix whose values are all 7.
670683
"version": "0.1",
671684
"format": "CSR",
672685
"shape": [5, 5],
686+
"number_of_stored_values": 6,
673687
"data_types": {
674688
"pointers_to_1": "uint64",
675689
"indices_1": "uint64",
@@ -807,6 +821,7 @@ Example of a symmetric CSR matrix.
807821
"version": "0.1",
808822
"format": "CSR",
809823
"shape": [5, 5],
824+
"number_of_stored_values": 9,
810825
"structure": "symmetric_lower",
811826
"data_types": {
812827
"pointers_to_1": "uint64",
@@ -820,6 +835,13 @@ Example of a symmetric CSR matrix.
820835
- `indices_1` = [0, 0, 1, 0, 2, 1, 3, 2, 4]
821836
- `values` = [1, 2, 9, 7, 2, 2, 3, 3, 7]
822837

838+
Note: `number_of_stored_values` reflects the number of entries explicitly stored
839+
in the sparse tensor format. This means that for symmetric, Hermittion, and
840+
skew-symmetric matrices, `number_of_stored_values` reflects the number of values
841+
that are stored, not the number of logical values in both matrix triangles.
842+
If the optional attribute `number_of_diagonal_elements` is provided, the
843+
number of logical values in both triangles can be computed in constant time.
844+
823845
</div>
824846

825847
Attributes {#key_attributes}

0 commit comments

Comments
 (0)