Macaulay2 Engine
Loading...
Searching...
No Matches
res-moninfo-sparse.hpp File Reference

ResMonoidSparse — sparse-multiset encoding alternative to ResMonoidDense. More...

#include <iostream>
#include <memory>
#include <vector>
#include "schreyer-resolution/res-monomial-types.hpp"
#include "skew.hpp"

Go to the source code of this file.

Classes

class  ResMonoidSparse
 Sparse / varpower-format ResMonoid implementation: monomials laid out as length-prefixed lists of (variable, exponent) pairs. More...

Detailed Description

ResMonoidSparse — sparse-multiset encoding alternative to ResMonoidDense.

Note
AI-generated documentation. Verify against the source before relying on it.

Declares the compact alternative res-moninfo.hpp keeps in the codebase for swap-in benchmarking against the production dense layout. Each monomial is encoded as [length, hash, component, weight_1, ..., weight_{mNumWeights}, v_1, v_2, ..., v_d] (slot 0 is the total array length so monomial_size(m) = *m); the variable tail is a non-increasing list v_1 >= v_2 >= ... >= v_d >= 0 where each variable index is repeated e_i times. So a monomial x^2 y z^5 with nvars = 3 (x=0, y=1, z=2, no weight slots) records the 11-slot array [11, hash, Computations, 2, 2, 2, 2, 2, 1, 0, 0] (from_expvector iterates i from nvars-1 down to 0 to build it). Memory is O(total_degree) per monomial rather than O(nvars), which wins big for rings with many variables and low-support monomials.

Hashing is the additive Steel trick: from_expvector accumulates hash += hashfcn[i] once per unit of e[i], so hash(m) = sum_i hashfcn[i] * e_i and mult updates hashes by addition. The class-level mask is not part of the hash — it is used only by check_monomial to AND-detect overflow in stored slots. Leading weight slots front-load comparison so the order test can short-circuit before walking the variable suffix. Skew multiplication lives in skew_vars / skew_mult_sign, both of which take a SkewMultiplication* by parameter; the class does not own or inherit one, and mult is plain commutative.

The class exposes the same mult / divide / monomial_size / compare_schreyer / to_expvector / from_expvector / from_varpower_monomial surface as ResMonoidDense, plus a live compare_grevlex (the dense twin has its compare_grevlex #if 0-d out, so switching the typedef in res-moninfo.hpp materially changes which grevlex comparator the rest of the resolution sees). A bank of mutable unsigned long ncalls_* counters records every operation for the home-grown profiler.

See also
res-moninfo.hpp
res-moninfo-dense.hpp
res-monomial-types.hpp
res-poly-ring.hpp
skew.hpp

Definition in file res-moninfo-sparse.hpp.