Commit 9723fde
committed
FIX: Allocate row_ics with the correct nnz length in SPMatrix::new
`SPMatrix::new(row, col, nnz)` initialised `row_ics` with
`vec![0usize, nnz]` (a literal two-element vector `[0, nnz]`) instead
of `vec![0usize; nnz]` (an `nnz`-length zeroed vector). Anything that
allocated a fresh `SPMatrix` for in-place writes - most importantly
`SPMatrix::transpose` - then panicked with
`index out of bounds: the len is 2 but the index is K` on any matrix
with more than two non-zeros.
The bug surfaced while wiring the sparse-transpose path into
`examples/clippy_verify` during the Phase 2 clippy refactor; the test
was kept disabled at the time and noted in the commit log of 2f33cb2.
Fix the single-character typo and re-enable the sparse section of the
determinism oracle, asserting both a hashed transpose result and a
double-transpose round-trip on two distinct matrices. Verified
separately that the new `transpose().to_dense()` agrees element-wise
with the dense `Matrix::transpose` on the same input.1 parent c94a0c8 commit 9723fde
2 files changed
Lines changed: 13 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
231 | 235 | | |
232 | 236 | | |
233 | 237 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
0 commit comments