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

◆ TEST() [10/19]

TEST ( NCReduction ,
NaivePolynomialHeap  )

Definition at line 188 of file NCGroebnerTest.cpp.

189{
191 { "x", "y", "z"},
192 degreeRing(1),
193 {1,1,1},
194 {},
195 {1}
196 );
197 FreeAlgebraElement x(A), y(A), z(A), f(A), g(A), h(A), mh(A);
198 FreeAlgebraElement F(A), G(A);
199 A->var(*x, 0);
200 A->var(*y, 1);
201 A->var(*z, 2);
202 f = x + y;
203 g = y + z;
204 h = x + y + y + z;
205 mh = -h;
206 // strangely enough, this doesn't give an error unless you use *all* the terms
207 // stopping F early will not cause the error.
208 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;
209 G = -y*z*x*z - y*z*y*y - y*z*z*x;
210
212 std::cout << H->getName() << std::endl;
213 H->addPolynomial(*f);
214 std::cout << "H->value() = " << FreeAlgebraElement(A, *H->value()) << std::endl;
215 H->addPolynomial(*g);
216 std::cout << "H->value() = " << FreeAlgebraElement(A, *H->value()) << std::endl;
217 EXPECT_TRUE(A->is_equal(* H->value(), *h));
218 EXPECT_TRUE(A->is_equal(* H->value(), *h));
219
220 std::cout << "about to call removeLeadTerm" << std::endl;
221
222 H->removeLeadTerm();
223 EXPECT_FALSE(H->isZero());
224
225 H->removeLeadTerm();
226 EXPECT_FALSE(H->isZero());
227
228 H->removeLeadTerm();
229 EXPECT_TRUE(H->isZero());
230 EXPECT_TRUE(A->is_zero(* H->value()));
231 H->addPolynomial(*h);
232 H->addPolynomial(*mh);
233 EXPECT_TRUE(H->isZero());
234 EXPECT_TRUE(A->is_zero(* H->value()));
235
236 H->addPolynomial(*F);
237 H->addPolynomial(*G);
238 buffer o;
239 A->elem_text_out(o,* (H->value()), true, false, false);
240 std::cout << o.str() << std::endl;
241}
std::unique_ptr< PolynomialHeap > makePolynomialHeap(HeapType type, const FreeAlgebra &F)
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(), NaiveGeobucket, buffer::str(), FreeAlgebra::var(), and x.