Macaulay2 Engine
Loading...
Searching...
No Matches

◆ TEST() [9/19]

TEST ( NCReduction ,
NaiveDedupPolynomialHeap  )

Definition at line 135 of file NCGroebnerTest.cpp.

136{
138 { "x", "y", "z"},
139 degreeRing(1),
140 {1,1,1},
141 {},
142 {1}
143 );
144 FreeAlgebraElement x(A), y(A), z(A), f(A), g(A), h(A), mh(A);
145 FreeAlgebraElement F(A), G(A);
146 A->var(*x, 0);
147 A->var(*y, 1);
148 A->var(*z, 2);
149 f = x + y;
150 g = y + z;
151 h = x + y + y + z;
152 mh = -h;
153 // strangely enough, this doesn't give an error unless you use *all* the terms
154 // stopping F early will not cause the error.
155 F = y*z*x*z - y*z*y*y - y*z*z*x - z*x*y*z + z*x*z*y - z*y*y*y - z*z*x*y - z*z*y*x - z*z*z*z;
156 G = -y*z*x*z - y*z*y*y - y*z*z*x;
157
159 std::cout << H->getName() << std::endl;
160 H->addPolynomial(*f);
161 H->addPolynomial(*g);
162 std::cout << "H->value() = " << FreeAlgebraElement(A, *H->value());
163 std::cout << " H->value() = " << FreeAlgebraElement(A, *H->value()) << std::endl;
164 EXPECT_TRUE(A->is_equal(* H->value(), *h));
165 EXPECT_TRUE(A->is_equal(* H->value(), *h));
166
167 H->removeLeadTerm();
168 EXPECT_FALSE(H->isZero());
169
170 H->removeLeadTerm();
171 EXPECT_FALSE(H->isZero());
172
173 H->removeLeadTerm();
174 EXPECT_TRUE(H->isZero());
175 EXPECT_TRUE(A->is_zero(* H->value()));
176 H->addPolynomial(*h);
177 H->addPolynomial(*mh);
178 EXPECT_TRUE(H->isZero());
179 EXPECT_TRUE(A->is_zero(* H->value()));
180
181 H->addPolynomial(*F);
182 H->addPolynomial(*G);
183 buffer o;
184 A->elem_text_out(o,* (H->value()), true, false, false);
185 std::cout << o.str() << std::endl;
186}
std::unique_ptr< PolynomialHeap > makePolynomialHeap(HeapType type, const FreeAlgebra &F)
@ NaiveDedupGeobucket
const RingQQ * globalQQ
Definition aring.cpp:24
void var(Poly &result, int v) const
bool is_zero(const Poly &f) const
static FreeAlgebra * create(const Ring *K, const std::vector< std::string > &names, const PolynomialRing *degreeRing, const std::vector< int > &degrees, const std::vector< int > &wtvecs, const std::vector< int > &heftVector)
void elem_text_out(buffer &o, const Poly &f, bool p_one, bool p_plus, bool p_parens) const
bool is_equal(const Poly &f, const Poly &g) const
Owned Poly value paired with its FreeAlgebra*, providing natural operator-overloaded arithmetic.
Free associative algebra over a coefficient ring: the non-commutative analogue of PolynomialRing.
char * str()
Definition buffer.hpp:72
volatile int x
tbb::flow::graph G
const PolynomialRing * degreeRing(const std::vector< std::string > &names)

References FreeAlgebra::create(), degreeRing(), FreeAlgebra::elem_text_out(), G, globalQQ, FreeAlgebra::is_equal(), FreeAlgebra::is_zero(), makePolynomialHeap(), NaiveDedupGeobucket, buffer::str(), FreeAlgebra::var(), and x.