Macaulay2 Engine
Loading...
Searching...
No Matches
FreeAlgebraQuotient.cpp
Go to the documentation of this file.
2
3#include "monoid.hpp" // for Monoid
4#include "ring.hpp" // for Ring, SumCollector
5
7{
8 return mFreeAlgebra.make_SumCollector();
9}
10
12 const ConstPolyList& GB,
13 int maxdeg)
14 : mFreeAlgebra(A),
15 mGroebner(A,GB,maxdeg,0),
16 mMaxdeg(maxdeg)
17{
18 // this NCGroebner object is used for reductions only.
19 // will eventually separate the 'reduction' code from the 'GB' code
20 // into two separate classes, but for now we have just one.
21 mGroebner.initReductionOnly();
22}
23
25{
26 // for now, we will simply reduce the poly f and copy the result into f.
27 // TODO: Make this work 'in place'.
28 auto fRed = mGroebner.twoSidedReduction(&f);
29 freeAlgebra().swap(f,*fRed);
30}
31
33{
34 // TODO: need Polynomial type to allow us access, or have a clear function itself.
35 setZero(f);
36}
37
39{
40 mFreeAlgebra.setZero(f);
41}
42
44{
45 mFreeAlgebra.from_coefficient(result, a);
47}
48
53
58
59bool FreeAlgebraQuotient::from_rational(Poly& result, const mpq_srcptr q) const
60{
61 ring_elem cq; // in coeff ring.
62 bool worked = coefficientRing()->from_rational(q, cq);
63 if (!worked) return false;
65 return true;
66}
67
69{
70 mFreeAlgebra.copy(result, f);
71}
72
74{
75 mFreeAlgebra.swap(f,g);
76}
77
79{
80 mFreeAlgebra.var(result, v);
82}
83
84void FreeAlgebraQuotient::from_word(Poly& result, ring_elem coeff, const std::vector<int>& word) const
85{
86 mFreeAlgebra.from_word(result, coeff, word);
88}
89
90void FreeAlgebraQuotient::from_word(Poly& result, const std::vector<int>& word) const
91{
93}
94
96{
97 return mFreeAlgebra.is_unit(f); // TODO: this is not correct: if f = 1 + (nilpotent).
98}
99
100int FreeAlgebraQuotient::compare_elems(const Poly& f, const Poly& g) const
101{
102 return mFreeAlgebra.compare_elems(f, g);
103}
104
105bool FreeAlgebraQuotient::is_equal(const Poly& f, const Poly& g) const
106{
107 return mFreeAlgebra.is_equal(f, g);
108}
109
111{
112 return mFreeAlgebra.negate(result, f);
113}
114
115void FreeAlgebraQuotient::add(Poly& result, const Poly& f, const Poly& g) const
116{
117 return mFreeAlgebra.add(result, f, g);
118}
119
120void FreeAlgebraQuotient::subtract(Poly& result, const Poly& f, const Poly& g) const
121{
122 return mFreeAlgebra.subtract(result, f, g);
123}
124
125void FreeAlgebraQuotient::mult(Poly& result, const Poly& f, const Poly& g) const
126{
127 mFreeAlgebra.mult(result, f, g);
129}
130
131void FreeAlgebraQuotient::power(Poly& result, const Poly& f, int n) const
132{
133 mFreeAlgebra.power(result, f, n);
135}
136
137void FreeAlgebraQuotient::power(Poly& result, const Poly& f, mpz_srcptr n) const
138{
139 mFreeAlgebra.power(result, f, n);
141}
142
143ring_elem FreeAlgebraQuotient::eval(const RingMap *map, const Poly& f, int first_var) const
144{
145 // For now, just call the freeAlgebra eval function, and normalize at the end.
146 // Not sure there is a better way unless we move part of eval out.
147 return mFreeAlgebra.eval(map,f,first_var);
148}
149
151 const Poly& f,
152 bool p_one,
153 bool p_plus,
154 bool p_parens) const
155{
156 mFreeAlgebra.elem_text_out(o, f, p_one, p_plus, p_parens);
157}
158
160{
161 return mFreeAlgebra.is_homogeneous(f);
162}
163
165 monomial already_allocated_degree_vector) const
166{
167 return mFreeAlgebra.multi_degree(f, already_allocated_degree_vector);
168}
169
170// Local Variables:
171// compile-command: "make -C $M2BUILDDIR/Macaulay2/e "
172// indent-tabs-mode: nil
173// End:
A FreeAlgebra modulo a two-sided ideal carried by an embedded NCGroebner.
std::vector< int > word
gc_vector< const Poly * > ConstPolyList
Polynomial< CoefficientRingType > Poly
void swap(Poly &f, Poly &g) const
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
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
int compare_elems(const Poly &f, const Poly &g) const
void swap(Poly &f, Poly &g) const
bool is_unit(const Poly &f) 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
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 FreeAlgebra & freeAlgebra() const
void subtract(Poly &result, const Poly &f, const Poly &g) 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
virtual bool from_rational(const mpq_srcptr q, ring_elem &result) const =0
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
VALGRIND_MAKE_MEM_DEFINED & result(result)
Monoid — variable count, naming, grading, and monomial order of a polynomial ring.
Ring — the legacy abstract base class for every coefficient and polynomial ring.