Macaulay2 Engine
Loading...
Searching...
No Matches
FreeAlgebraQuotient.hpp
Go to the documentation of this file.
1#ifndef _free_algebra_quotient_hpp_
2#define _free_algebra_quotient_hpp_
3
44
45#include "NCAlgebras/FreeAlgebra.hpp" // for FreeAlgebra
46#include "NCAlgebras/FreeMonoid.hpp" // for FreeMonoid
47#include "NCAlgebras/NCGroebner.hpp" // for NCGroebner
48#include "Polynomial.hpp" // for Poly, ConstPolyList
49#include "newdelete.hpp" // for our_new_delete
50#include "ringelem.hpp" // for ring_elem
51
52#include <vector> // for vector
53
54class Ring;
55class SumCollector;
56class buffer;
57struct Monoid;
58struct RingMap;
59
76{
77private:
80 // placed word tables in NCGroebner object
81 //WordTable mWordTable;
82 //SuffixTree mWordTable;
84
85public:
86 FreeAlgebraQuotient(const FreeAlgebra& A, const ConstPolyList& GB, int maxdeg);
87
88 const FreeMonoid& monoid() const { return mFreeAlgebra.monoid(); }
89 const Monoid& degreeMonoid() const { return monoid().degreeMonoid(); }
90 const FreeAlgebra& freeAlgebra() const { return mFreeAlgebra; }
91
92 const Ring* coefficientRing() const { return mFreeAlgebra.coefficientRing(); }
93
94 int numVars() const { return monoid().numVars(); }
95
96 unsigned int computeHashValue(const Poly& a) const; // TODO
97
98 void normalizeInPlace(Poly& f) const;
99
100 void init(Poly& f) const { (void) f; }
101 void clear(Poly& f) const;
102 void setZero(Poly& f) const;
103
104 void from_coefficient(Poly& result, const ring_elem a) const;
105 void from_long(Poly& result, long n) const;
106 void from_int(Poly& result, mpz_srcptr n) const;
107 bool from_rational(Poly& result, const mpq_srcptr q) const;
108 void copy(Poly& result, const Poly& f) const;
109 void swap(Poly& f, Poly& g) const; // TODO
110 void var(Poly& result, int v) const;
111 void from_word(Poly& result, const std::vector<int>& word) const;
112 void from_word(Poly& result, ring_elem coeff, const std::vector<int>& word) const;
113
114 long n_terms(const Poly& f) const { return f.numTerms(); }
115 bool is_unit(const Poly& f) const;
116 bool is_zero(const Poly& f) const { return n_terms(f) == 0; }
117 bool is_equal(const Poly& f, const Poly& g) const;
118 int compare_elems(const Poly& f, const Poly& g) const;
119
120 void negate(Poly& result, const Poly& f) const;
121 void add(Poly& result, const Poly& f, const Poly& g) const;
122 void subtract(Poly& result, const Poly& f, const Poly& g) const;
123 void mult(Poly& result, const Poly& f, const Poly& g) const;
124 void power(Poly& result, const Poly& f, int n) const;
125 void power(Poly& result, const Poly& f, mpz_srcptr n) const;
126
127 ring_elem eval(const RingMap *map, const Poly& f, int first_var) const;
128
129 void elem_text_out(buffer &o,
130 const Poly& f,
131 bool p_one,
132 bool p_plus,
133 bool p_parens) const;
134
135 bool is_homogeneous(const Poly& f) const;
136 // FIXME: copied from ring.hpp because this doesn't inherit from Ring
137 inline const_monomial degree(const Poly& f) const
138 {
139 auto d = degreeMonoid().make_one();
140 multi_degree(f, d);
141 return d;
142 }
143 // returns true if f is homogeneous, and sets already_allocated_degree_vector
144 // to be the LCM of the exponent vectors of the degrees of all terms in f.
145 bool multi_degree(const Poly& f, monomial already_allocated_degree_vector) const;
146
148};
149
162// for debugging purposes
164{
165public:
167 : mRing(F)
168 {
169 mRing->init(mPoly);
170 }
172 {
173 mRing->clear(mPoly);
174 }
176 {
177 return mPoly;
178 }
179 const Poly& operator*() const
180 {
181 return mPoly;
182 }
184 {
185 return this->mRing->is_equal(**this,*g);
186 }
188 {
190 mRing->add(*result, **this, *g);
191 return result; // this is a copy
192 }
194 {
196 mRing->subtract(*result, **this, *g);
197 return result; // this is a copy
198 }
200 {
202 mRing->mult(*result, **this, *g);
203 return result; // this is a copy
204 }
206 {
208 mRing->power(*result, **this, n);
209 return result; // this is a copy
210 }
211
212private:
215};
216
217#endif
218
219// Local Variables:
220// compile-command: "make -C $M2BUILDDIR/Macaulay2/e "
221// indent-tabs-mode: nil
222// End:
223
Free associative algebra k<x_1,...,x_n> over an arbitrary coefficient ring.
FreeMonoid — monoid of length-prefixed non-commutative words with weight-vector prefix.
NCGroebner — Buchberger-style two-sided Gröbner basis driver over a FreeAlgebra.
std::vector< int > word
gc_vector< const Poly * > ConstPolyList
Polynomial< CoefficientRingType > Poly
Modern Monom / Polynomial value types shared by NC algebras and the refactored F4.
Free associative algebra over a coefficient ring: the non-commutative analogue of PolynomialRing.
void from_coefficient(Poly &result, const ring_elem a) const
SumCollector * make_SumCollector() const
const Monoid & degreeMonoid() const
void mult(Poly &result, const Poly &f, const Poly &g) const
void setZero(Poly &f) const
bool from_rational(Poly &result, const mpq_srcptr q) const
FreeAlgebraQuotient(const FreeAlgebra &A, const ConstPolyList &GB, int maxdeg)
void elem_text_out(buffer &o, const Poly &f, bool p_one, bool p_plus, bool p_parens) const
void from_long(Poly &result, long n) const
ring_elem eval(const RingMap *map, const Poly &f, int first_var) const
const FreeMonoid & monoid() const
int compare_elems(const Poly &f, const Poly &g) const
bool is_unit(const Poly &f) const
unsigned int computeHashValue(const Poly &a) const
void power(Poly &result, const Poly &f, int n) const
void from_word(Poly &result, const std::vector< int > &word) const
const FreeAlgebra & mFreeAlgebra
bool is_homogeneous(const Poly &f) const
long n_terms(const Poly &f) const
void from_int(Poly &result, mpz_srcptr n) const
void add(Poly &result, const Poly &f, const Poly &g) const
void var(Poly &result, int v) const
const Ring * coefficientRing() const
const_monomial degree(const Poly &f) const
const FreeAlgebra & freeAlgebra() const
void init(Poly &f) const
void subtract(Poly &result, const Poly &f, const Poly &g) const
bool is_zero(const Poly &f) const
bool multi_degree(const Poly &f, monomial already_allocated_degree_vector) const
void clear(Poly &f) const
bool is_equal(const Poly &f, const Poly &g) const
void copy(Poly &result, const Poly &f) const
void normalizeInPlace(Poly &f) const
void negate(Poly &result, const Poly &f) const
const FreeAlgebraQuotient * mRing
FreeAlgebraQuotientElement(const FreeAlgebraQuotient *F)
FreeAlgebraQuotientElement operator^(int n)
FreeAlgebraQuotientElement operator-(const FreeAlgebraQuotientElement &g)
FreeAlgebraQuotientElement operator*(const FreeAlgebraQuotientElement &g)
FreeAlgebraQuotientElement operator+(const FreeAlgebraQuotientElement &g)
bool operator==(const FreeAlgebraQuotientElement &g) const
Quotient of a FreeAlgebra by a Groebner basis up to a fixed degree bound.
const Monoid & degreeMonoid() const
unsigned int numVars() const
The free non-commutative monoid on a set of named variables, with monomial ordering and degree / weig...
monomial make_one() const
Definition monoid.cpp:455
Engine-side commutative monomial monoid: variable names, ordering, multidegree machinery,...
Definition monoid.hpp:89
One-overlap-at-a-time Groebner basis driver for the free associative algebra (the "Naive" companion t...
xxx xxx xxx
Definition ring.hpp:102
Engine-side ring homomorphism: stores, for each source-ring variable, the target-ring element it maps...
Definition ringmap.hpp:60
Abstract incremental accumulator that builds a ring_elem from many add(f) calls.
Definition ring.hpp:669
#define monomial
Definition gb-toric.cpp:11
const int * const_monomial
Definition imonorder.hpp:45
VALGRIND_MAKE_MEM_DEFINED & result(result)
#define swap(a, b, t)
Definition monsort.hpp:127
our_new_delete — per-class opt-in routing of new / delete through bdwgc.
ring_elem — the universal value type carried by every Ring* in the engine.