Description
Validate CSR pointer arity, monotonicity, final entry count and minor bounds; duplicates/unsorted minor indexes remain legal observations.
A sparse matrix can be stored as coordinate triplets or as pointer/index/value arrays. Stored entries are not necessarily distinct numerical nonzeros: duplicates and explicit zeros can matter to representation checks. Row and column coordinates here are zero-based, and omitted entries are handled only as stated for the particular operation.
Validate CSR pointer arity, monotonicity, final entry count and minor bounds; duplicates/unsorted minor indexes remain legal observations.
When to use this tool
Use this tool to validate CSR pointer arity, monotonicity, final entry count and minor bounds; duplicates/unsorted minor indexes remain legal observations.
How to use the tool and how it works
- Enter pointers, indexes, values, major, minor using the field definitions below.
- Run the operation. Correct input errors before interpreting an output.
- Read result.valid, result.entries, result.emptyMajorIndexes. Use the ordering, boundary rules and absence conditions described below.
Require a zero first pointer, nondecreasing pointers, final pointer equal to entry count, aligned values and in-range column indexes. Return valid true and empty row indexes.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| pointers | Zero-based cumulative row or column pointers, starting at 0 and ending at entry count. | Dense list of at most 128 finite numbers; integer/shape constraints above also apply. |
| indexes | Minor-axis integer indexes aligned with values, not source-record positions. | Dense list of at most 128 finite numbers; integer/shape constraints above also apply. |
| values | Finite stored entry values aligned with indexes. | Dense list of at most 128 finite numbers; integer/shape constraints above also apply. |
| major | Row count for row pointers; column count for column pointers. Integer 0–127. | A finite safe integer within the operation’s stated bounds. |
| minor | Opposite-axis size, an integer 0–128. | A finite safe integer within the operation’s stated bounds. |
| Output field | Interpretation |
|---|---|
| result | Object containing the named fields below. |
| result.valid | True after the layout/record validation succeeds; malformed input causes an error. |
| result.entries | Number of explicitly stored entries, including duplicate and zero records. |
| result.emptyMajorIndexes | Zero-based rows or columns whose adjacent pointers are equal. |
{
"input": {
"pointers": [
0,
0,
1
],
"indexes": [
1
],
"values": [
2
],
"major": 2,
"minor": 2
},
"output": {
"result": {
"valid": true,
"entries": 1,
"emptyMajorIndexes": [
0
]
}
}
} Limitations and assumptions
- An invalid layout raises an error rather than returning false; duplicates and unsorted indexes are allowed.
- Triplets are JSON records with row, column and value. Coordinate shapes are ordinarily bounded to 128 per axis; compressed major dimensions are limited to 127 for pointer-list capacity. The dense-budget operation has separate larger shape limits and returns exact counts as decimal text.
- Every declared top-level input field is required and unexpected fields are rejected. Ordinary strings are limited to 8,192 UTF-16 code units and lists to 128 entries, with tighter operation-specific bounds where stated. JSON text has bounded nesting and node counts.
- Numeric outputs must be finite and no larger in absolute magnitude than the safe-integer limit; operations returning exact large integers use decimal text. Positions are zero-based and spans end exclusively unless the operation explicitly states a different convention.
Alternative or Complementary methods
Distinguish stored-record counts, coordinate-pattern checks and arithmetic matrix properties. Combine duplicates or prune zeros explicitly when required, and use a matrix library for numerical linear algebra.
References
Similar or alternative tools
- Sparse Column Pointer Layout Validator
Validate CSC pointer arity, monotonicity, final entry count and minor bounds; duplicates/unsorted minor indexes remain legal observations.
- Sparse Coordinate Row Pointer Builder
Build stable CSR row pointers and aligned column/value/source-index arrays from COO observations; no duplicate combination or per-row column sorting.