Commit 85f7b74
sparsematrix: fix swaprows! storage moves (#721)
reported on discourse, mostly oneshot by codex 5.5
----------------------------------------------------------------------------------------------------------------
Fix SparseMatrixCSC row swaps when exactly one swapped row is stored in
a column. The j search range used a local i index as an absolute storage
index, and the single-row move rotations were reversed.
On master:
```julia
julia> A = sparse([1.0 2.0 3.0; 0.0 0.0 0.0; 4.0 5.0 6.0]); Base.swaprows!(A, 1, 2); A
3×3 SparseMatrixCSC{Float64, Int64} with 6 stored entries:
⋅ 1.0 ⋅
2.0 ⋅ 3.0
4.0 5.0 6.0
julia> B = sparse(reshape([1.0, 2.0, 3.0, 4.0, 0.0, 0.0], 6, 1)); Base.swaprows!(B, 2, 6); rowvals(B)
4-element Vector{Int64}:
1
4
6
3
```
---------
Co-authored-by: OpenAI Codex <codex@openai.com>1 parent f7b1e19 commit 85f7b74
2 files changed
Lines changed: 20 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4513 | 4513 | | |
4514 | 4514 | | |
4515 | 4515 | | |
4516 | | - | |
| 4516 | + | |
4517 | 4517 | | |
4518 | 4518 | | |
4519 | 4519 | | |
| |||
4527 | 4527 | | |
4528 | 4528 | | |
4529 | 4529 | | |
4530 | | - | |
4531 | 4530 | | |
4532 | | - | |
4533 | | - | |
| 4531 | + | |
| 4532 | + | |
4534 | 4533 | | |
4535 | 4534 | | |
4536 | 4535 | | |
4537 | 4536 | | |
4538 | | - | |
4539 | 4537 | | |
4540 | | - | |
4541 | | - | |
| 4538 | + | |
| 4539 | + | |
4542 | 4540 | | |
4543 | 4541 | | |
4544 | 4542 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1426 | 1426 | | |
1427 | 1427 | | |
1428 | 1428 | | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
1429 | 1444 | | |
1430 | 1445 | | |
1431 | 1446 | | |
| |||
0 commit comments