Macaulay2 Engine
Loading...
Searching...
No Matches
res-poly-ring.cpp
Go to the documentation of this file.
1/* Copyright 2015-2021, Michael E. Stillman */
2
4#include "schreyer-resolution/res-monomial-sorter.hpp" // for ResMonomialSorter
6
10
12 long& nterms,
13 long& bytes_used,
14 long& bytes_alloc) const
15{
16 long sz = 0;
17 // sz = f.len * sizeof(FieldElement); // TODO MES: what to add here?
18 sz += f.monoms.size() * sizeof(res_monomial_word);
19 nterms += f.len;
20 bytes_used += sz;
21 bytes_alloc += sz;
22}
23
24#if 0
25bool check_poly(const ResPolyRing& R,
26 const ResPolynomial& f,
27 const ResSchreyerOrder& ord)
28{
29 // We loop through each monomial, checking it against the one before
30 // The order used is the Schreyer order given.
31 auto& M = R.monoid();
34 res_const_packed_monomial prev = nullptr;
35 for (; i != end; ++i)
36 {
37 if (prev == nullptr)
38 prev = i.monomial();
39 else
40 {
41 // Now compare to previous monomial
42 long comp1 = M.get_component(prev);
43 long comp2 = M.get_component(i.monomial());
44 int result = M.compare_schreyer(prev,
45 i.monomial(),
46 ord.mTotalMonom[comp1],
47 ord.mTotalMonom[comp2],
48 ord.mTieBreaker[comp1],
49 ord.mTieBreaker[comp2]);
50 if (result == EQ or result == GT)
51 {
52 return false;
53 }
54 prev = i.monomial();
55 }
56 }
57 return true;
58}
59#endif
60
61bool check_poly(const ResPolyRing& R,
62 const ResPolynomial& f,
63 const ResSchreyerOrder& ord)
64{
65 std::vector<int*> monoms;
66 auto end = ResPolynomialIterator(R,f,1);
67 for (auto i = ResPolynomialIterator(R,f); i != end; ++i)
68 {
69 monoms.push_back(const_cast<res_packed_monomial>(i.monomial()));
70 }
71 ResMonomialSorter S(R.originalMonoid(), R.monoid(), ord, monoms);
72 return S.ordered();
73}
74
75// Local Variables:
76// compile-command: "make -C $M2BUILDDIR/Macaulay2/e "
77// indent-tabs-mode: nil
78// End:
Sorter that orders res_packed_monomials by their total (Schreyer) monomial, with a stable tiebreaker ...
const Monoid & originalMonoid() const
const ResMonoid & monoid() const
void memUsage(const ResPolynomial &f, long &nterms, long &bytes_used, long &bytes_alloc) const
The polynomial-ring view the F4 resolution engine reduces against: coefficient arithmetic plus the en...
std::vector< res_monomial_word > monoms
static long npoly_destructor
Polynomial type used by the F4 resolution engine: parallel coefficient vector and concatenated monomi...
Forward iterator over the terms of a ResPolynomial.
VALGRIND_MAKE_MEM_DEFINED & result(result)
Schreyer-order column sorters for the F4 resolution Macaulay matrix.
const res_monomial_word * res_const_packed_monomial
myword res_monomial_word
res_monomial_word * res_packed_monomial
bool check_poly(const ResPolyRing &R, const ResPolynomial &f, const ResSchreyerOrder &ord)
ResPolyRing and ResPolynomial — resolution-tuned polynomial-ring view and value type.
TermIterator< Nterm > end(Nterm *)
Definition ringelem.cpp:5
std::vector< res_packed_monomial > mTotalMonom
std::vector< component_index > mTieBreaker
Per-level Schreyer-order data attached to a SchreyerFrame::Level.
const int EQ
Definition style.hpp:40
const int GT
Definition style.hpp:41