SMat equality ignores sparse row positions and unequal list lengths
Nobody has claimed this yet.
- Dominant language
- Macaulay2
- Stars
- 435
- Forks
- 297
- Avg merge
- 4d 20h
- Merged PRs (30d)
- 11
Description
`SMat::is_equal` can return true for matrices with different sparse supports. In `Macaulay2/e/basic-mutable-matrices/smat.hpp`, `vec_equals` compares coefficients but does not compare row indices or check that both lists end together.
The following direct engine C++ examples use `SMat` over ZZ/101. Each pair has shape 3 x 1 and must compare unequal:
| Left column (top to bottom) | Right column | Actual `is_equal` |
| --- | --- | --- |
| `[0, 0, 0]` | `[2, 0, 0]` | `true` |
| `[2, 0, 0]` | `[0, 2, 0]` | `true` |
| `[0, 2, 0]` | `[3, 2, 0]` | `true` |
Minimal C++ reproduction (inside the engine unit-test harness):
```cpp
M2::ARingZZp ring(101);
SMat left(ring, 3, 1), right(ring, 3, 1);
M2::ARingZZp::Element two(ring);
ring.set(two, 2);
left.set_entry(0, 0, two);
right.set_entry(1, 0, two);
EXPECT_FALSE(left.is_equal(right)); // fails: actual is true
```
All three cases were reproduced with a Debug CMake engine build on macOS arm64. The production header was unchanged. Equality should compare row positions, coefficients, and the lengths of the sparse lists. This was found while adding dedicated SMat engine unit tests.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Macaulay2/e/basic-mutable-matrices/smat.hpp, at SMat::is_equal and its vec_equals helper. Run the engine unit-test harness with the provided ZZ/101 sparse-matrix examples, then verify that equality accounts for row positions, coefficients, and matching sparse-list lengths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 86/100