Skip to content

Commit 0391e5f

Browse files
committed
Merge branch 'main' into wma/levels
2 parents 8a4dad4 + 122e1e9 commit 0391e5f

1 file changed

Lines changed: 153 additions & 21 deletions

File tree

spec/latest/index.bs

Lines changed: 153 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ attributes.
6565
"format": "CSC",
6666
"shape": [10, 12],
6767
"data_types": {
68-
"pointers_0": "uint64",
68+
"pointers_to_1": "uint64",
6969
"indices_1": "uint64",
7070
"values": "float32"
7171
}
@@ -93,9 +93,8 @@ Fill {#key_fill}
9393
--------------------
9494
The `fill` key may be present. If the `fill` key is present, it shall have a
9595
boolean value. If the value is true, it signifies the presence of a `fill_value`
96-
array, whose single element defines the fill (zero) value of the sparse tensor,
97-
or the value of the array at indices not otherwise specified by the sparse
98-
tensor structure.
96+
array, whose single element defines the value at indices not specified
97+
by the sparse tensor structure.
9998

10099
Format {#key_format}
101100
--------------------
@@ -128,15 +127,15 @@ The element of the vector located at index `indices_0[i]` has scalar value
128127

129128
Compressed-Sparse Row format
130129

131-
: pointers_0
130+
: pointers_to_1
132131
:: Array of size `number_of_rows + 1` containing start and end positions by row.
133132
: indices_1
134133
:: Array of size `number_of_elements` containing 0-based column indices.
135134
: values
136135
:: Array of size `number_of_elements` containing stored values.
137136

138137
The column indices of the stored values located in row `i` are located in the range
139-
`[pointers_0[i], pointers_0[i+1])` in the `indices_1` array. The scalar values for
138+
`[pointers_to_1[i], pointers_to_1[i+1])` in the `indices_1` array. The scalar values for
140139
each of those stored values is stored in the corresponding index in the `values` array.
141140

142141
Within a row, elements shall be sorted by column index and must not be duplicated.
@@ -145,15 +144,15 @@ Within a row, elements shall be sorted by column index and must not be duplicate
145144

146145
Compressed-Sparse Column format
147146

148-
: pointers_0
147+
: pointers_to_1
149148
:: Array of size `number_of_columns + 1` containing start and end positions by column.
150149
: indices_1
151150
:: Array of size `number_of_elements` containing 0-based row indices.
152151
: values
153152
:: Array of size `number_of_elements` containing stored values.
154153

155154
The rows indices of the stored values located in column `j` are located in the range
156-
`[pointers_0[j], pointers_0[j+1])` in the `indices_1` array. The scalar values for
155+
`[pointers_to_1[j], pointers_to_1[j+1])` in the `indices_1` array. The scalar values for
157156
each of those stored values is stored in the corresponding index in the `values` array.
158157

159158
Within a column, elements shall be sorted by row index and must not be duplicated.
@@ -164,16 +163,16 @@ Doubly Compressed-Sparse Row format
164163

165164
: indices_0
166165
:: Array of size `number_of_nonempty_rows` containing 0-based row indices corresponding
167-
to positions within `pointers_0`.
168-
: pointers_0
166+
to positions within `pointers_to_1`.
167+
: pointers_to_1
169168
:: Array of size `number_of_nonempty_rows + 1` containing start and end positions.
170169
: indices_1
171170
:: Array of size `number_of_elements` containing 0-based column indices.
172171
: values
173172
:: Array of size `number_of_elements` containing stored values.
174173

175-
DCSR is similar to CSR, except that rows which are entirely empty are not stored. `pointers_0`
176-
contains no repeated values. Because the position within `pointers_0` no longer dictates the
174+
DCSR is similar to CSR, except that rows which are entirely empty are not stored. `pointers_to_1`
175+
contains no repeated values. Because the position within `pointers_to_1` no longer dictates the
177176
corresponding row index, `indices_0` provides the row index.
178177

179178
Rows shall be sorted and must not be duplicated.
@@ -185,16 +184,16 @@ Doubly Compressed-Sparse Column format
185184

186185
: indices_0
187186
:: Array of size `number_of_nonempty_columns` containing 0-based column indices
188-
corresponding to positions within `pointers_0`.
189-
: pointers_0
187+
corresponding to positions within `pointers_to_1`.
188+
: pointers_to_1
190189
:: Array of size `number_of_nonempty_columns + 1` containing start and end positions.
191190
: indices_1
192191
:: Array of size `number_of_elements` containing 0-based row indices.
193192
: values
194193
:: Array of size `number_of_elements` containing stored values.
195194

196-
DCSC is similar to CSC, except that columns which are entirely empty are not stored. `pointers_0`
197-
contains no repeated values. Because the position within `pointers_0` no longer dictates the
195+
DCSC is similar to CSC, except that columns which are entirely empty are not stored. `pointers_to_1`
196+
contains no repeated values. Because the position within `pointers_to_1` no longer dictates the
198197
corresponding column index, `indices_0` provides the column index.
199198

200199
Columns shall be sorted and not duplicated.
@@ -317,11 +316,11 @@ Assume that this level represents `n`-dimensional subarrays and the root array
317316
is `N`-dimensional. The sparse level implies the following binary arrays are
318317
present:
319318

320-
: pointers_(N - n - 1)
321-
:: Array of size `number_of_positions + 1` whose 1st element is equal to `0` and whose `p + 1`th element is equal to the sum of `pointers_N[p]` and the number of explicitly represented slices in the `p`th position.
319+
: pointers_to_(N - n)
320+
:: Array of size `number_of_positions + 1` whose 1st element is equal to `0` and whose `p + 1`th element is equal to the sum of `pointers_to_(N - n)[p]` and the number of explicitly represented slices in the `p`th position.
322321

323322
: indices_(N - n), ..., indices(N - n + r - 1)
324-
:: There are `r` such arrays. When `A[i_0, ..., i_(r - 1), :, ..., :]` is explicitly represented by the subarray in position `q`, `indices_(N-n+s)[q] = i_s`. The arrays must be ordered such that the tuples `(indices_(N-n)[q], ..., indices_(N-n+r-1)[q])` are unique and appear in lexicographic order for all `q` in each range `pos[p] <= q < pos[p + 1]`. This array must contain no other elements.
323+
:: There are `r` such arrays. When `A[i_0, ..., i_(r - 1), :, ..., :]` is explicitly represented by the subarray in position `q`, `indices_(N-n+s)[q] = i_s`. The arrays must be ordered such that the tuples `(indices_(N-n)[q], ..., indices_(N-n+r-1)[q])` are unique and appear in lexicographic order for all `q` in each range `pointers_to_(N-n)[p] <= q < pointers_to_(N-n)[p + 1]`. This array must contain no other elements.
325324

326325
Special note: If the sparse level is the root level, the `pointers` array should
327326
be ommitted, as its first value will be `0` and its last value will be the
@@ -596,14 +595,14 @@ Example of a CSR Matrix whose values are all 7.
596595
},
597596
"shape": [5, 5],
598597
"data_types": {
599-
"pointers_0": "uint64",
598+
"pointers_to_1": "uint64",
600599
"indices_1": "uint64",
601600
"values": "iso[int8]"
602601
}
603602
}
604603
```
605604

606-
- `pointers_0` = [0, 1, 3, 3, 5, 6]
605+
- `pointers_to_1` = [0, 1, 3, 3, 5, 6]
607606
- `indices_1` = [3, 1, 4, 1, 2, 3]
608607
- `values` = [7]
609608

@@ -613,6 +612,139 @@ Note: Structure-only matrices (allowed in matrix market format) can be stored
613612
using this technique with a value of 1. This adds only a small amount of
614613
overhead while describing essentially the same matrix.
615614

615+
Structure {#key_structure}
616+
--------------------------
617+
The `structure` key, if present, denotes a special matrix structure in which
618+
only one triangle of the matrix is stored and the structure and values in the
619+
other triangle are inferred.
620+
621+
### Pre-Defined Structures ### {#predefined_structure}
622+
623+
The follow pre-defined values can be supplied for the `structure` key to indicate
624+
the structure of the matrix.
625+
626+
#### symmetric_lower #### {#symmetric_lower_structure}
627+
628+
The `symmetric_lower` value indicates that the matrix has a symmetric structure
629+
with only the lower triangle stored. For all matrix entries with row and column
630+
indices `i,j` and value `v`, `i >= j`. If `i != j`, the entry implies the
631+
presence of an entry at row and column index `j,i` with value `v`.
632+
633+
#### symmetric_upper #### {#symmetric_upper_structure}
634+
635+
The `symmetric_upper` value indicates that the matrix has a symmetric structure
636+
with only the upper triangle stored. For all matrix entries with row and column
637+
indices `i,j` and value `v`, `i <= j`. If `i != j`, the entry implies the
638+
presence of an entry at row and column index `j,i` with value `v`.
639+
640+
#### hermitian_lower #### {#hermitian_lower_structure}
641+
642+
The `hermitian_lower` value indicates that the matrix has a Hermitian structure
643+
with only the lower triangle stored. For all matrix entries with row and column
644+
indices `i,j` and value `v`, `i >= j`. If `i != j`, the entry implies the
645+
presence of an entry at row and column index `j,i` with a value equal to the
646+
complex conjugate of `v`. The matrix's value type must be complex.
647+
648+
#### hermitian_upper #### {#hermitian_upper_structure}
649+
650+
The `hermitian_upper` value indicates that the matrix has a Hermitian structure
651+
with only the upper triangle stored. For all matrix entries with row and column
652+
indices `i,j` and value `v`, `i <= j`. If `i != j`, the entry implies the
653+
presence of an entry at row and column index `j,i` with a value equal to the
654+
complex conjugate of `v`. The matrix's value type must be complex.
655+
656+
#### skew_symmetric_lower #### {#skew_symmetric_lower_structure}
657+
658+
The `skew_symmetric_lower` value indicates that the matrix has a skew-symmetric structure
659+
with only the lower triangle stored. For all matrix entries with row and column
660+
indices `i,j` and value `v`, `i >= j`. If `i != j`, the entry implies the
661+
presence of an entry at row and column index `j,i` with value `-v`.
662+
663+
#### skew_symmetric_upper #### {#skew_symmetric_upper_structure}
664+
665+
The `symmetric_upper` value indicates that the matrix has a skew-symmetric structure
666+
with only the upper triangle stored. For all matrix entries with row and column
667+
indices `i,j` and value `v`, `i <= j`. If `i != j`, the entry implies the
668+
presence of an entry at row and column index `j,i` with value `-v`.
669+
670+
<div class=example>
671+
672+
Example of a symmetric CSR matrix.
673+
674+
<table>
675+
<thead>
676+
<tr>
677+
<th> </th>
678+
<th>0</th>
679+
<th>1</th>
680+
<th>2</th>
681+
<th>3</th>
682+
<th>4</th>
683+
</tr>
684+
</thead>
685+
<tbody>
686+
<tr>
687+
<th>0</th>
688+
<td>1</td>
689+
<td>.</td>
690+
<td>.</td>
691+
<td>.</td>
692+
<td>.</td>
693+
</tr>
694+
<tr>
695+
<th>1</th>
696+
<td>2</td>
697+
<td>9</td>
698+
<td>.</td>
699+
<td>.</td>
700+
<td>.</td>
701+
</tr>
702+
<tr>
703+
<th>2</th>
704+
<td>7</td>
705+
<td>.</td>
706+
<td>2</td>
707+
<td>.</td>
708+
<td>.</td>
709+
</tr>
710+
<tr>
711+
<th>3</th>
712+
<td>.</td>
713+
<td>2</td>
714+
<td>.</td>
715+
<td>3</td>
716+
<td>.</td>
717+
</tr>
718+
<tr>
719+
<th>4</th>
720+
<td>.</td>
721+
<td>.</td>
722+
<td>3</td>
723+
<td>.</td>
724+
<td>7</td>
725+
</tr>
726+
</tbody>
727+
</table>
728+
729+
```json
730+
{
731+
"format": "CSR",
732+
"shape": [5, 5],
733+
"structure": "symmetric_lower",
734+
"data_types": {
735+
"pointers_to_1": "uint64",
736+
"indices_1": "uint64",
737+
"values": "int8"
738+
}
739+
}
740+
```
741+
742+
- `pointers_to_1` = [0, 1, 3, 5, 7, 9]
743+
- `indices_1` = [0, 0, 1, 0, 2, 1, 3, 2, 4]
744+
- `values` = [1, 2, 9, 7, 2, 2, 3, 3, 7]
745+
746+
</div>
747+
616748
Binary Containers {#binary_container}
617749
=====================================
618750
Binary containers must store binary arrays in a standardized, cross-platform

0 commit comments

Comments
 (0)