Macaulay2 / Macaulay2/M2

MonomialOrderings::product drops weight blocks during offsetting

Open Beginner friendly
#4,714 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Engine
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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.