MonomialOrderings::product drops weight blocks during offsetting
Nobody has claimed this yet.
- Dominant language
- Macaulay2
- Stars
- 435
- Forks
- 297
- Avg merge
- 4d 20h
- Merged PRs (30d)
- 11
Description
The C++ ordering interface declared in `monomials/monordering.hpp` produces a null block when a product contains a weight order.
```cpp
auto* weighted = MonomialOrderings::join({
MonomialOrderings::Weights({2,3}), MonomialOrderings::GRevLex(2)});
auto* product = MonomialOrderings::product({
MonomialOrderings::Lex(1), weighted});
```
Expected: three non-null blocks, with the second a weight block `[0,2,3]`, shifted by the preceding variable.
Actual: `product->len == 3`, but `product->array[1] == nullptr`. Formatting or converting that result to a matrix can dereference the null block.
In `M2/Macaulay2/e/interface/monomial-ordering.cpp`, `M2_mo_offset` allocates and fills the weight block `q` but never assigns it to `result->array[i]`.
Reproduced with an `ASSERT_NE` on the block pointer in a direct Debug engine test at c156fdcba4 (Apple Clang 21), before attempting any dereference. No production changes.
### Failing unit-test blocks
- `TEST(MonomialOrdering, DISABLED_weightedProduct)` in `M2/Macaulay2/e/unit-tests/MonomialOrderingTest.cpp`.
These regressions were explicitly run and confirmed to fail against the current implementation. They assert the intended corrected behavior and remain disabled in normal runs until the defect is fixed.
Run from the CMake build directory after building `M2-unit-tests`:
```sh
./Macaulay2/e/M2-unit-tests \
--gtest_also_run_disabled_tests \
--gtest_filter='MonomialOrdering.DISABLED_weightedProduct'
```
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
In M2/Macaulay2/e/interface/monomial-ordering.cpp, inspect M2_mo_offset and trace the weighted-product path described in the issue. Build M2-unit-tests, run the disabled MonomialOrdering.DISABLED_weightedProduct test from the CMake build directory, and confirm the product has three non-null blocks with the shifted weight block.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- backend, testing-qa
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100