19 using std::cout;
using std::endl;
22 #include "monomial.hpp" 25 #include "polynomial_ring.hpp" 26 #include "indeterminate.hpp" 30 DEG_TYPE a [] = {1, 0, 5, 2, 0};
32 cout <<
"t = " << t << endl;
35 cout <<
"u = " << u << endl << endl;
37 cout <<
"Does t divide u? " << u.
divisible_by(t) << endl;
38 cout <<
"Does u divide t? " << t.
divisible_by(u) << endl;
39 cout <<
"lcm(t,u) = " << t.
lcm(u) << endl;
40 cout <<
"lcm(u,t) = " << u.
lcm(t) << endl;
41 cout <<
"gcd(t,u) = " << t.
gcd(u) << endl;
42 cout <<
"gcd(u,t) = " << u.
gcd(t) << endl;
46 cout <<
"tu = " << w << endl;
49 cout << endl <<
"v = " << v << endl;
53 cout <<
"lcm(t,v)/t = " << tv << endl;
54 Monomial larger { 0, 0, 2, 0, 1, 0 };
55 Monomial smaller { 0, 1, 0, 1, 1, 0 };
56 cout << smaller <<
" < " << larger <<
" ? " << (smaller < larger) << endl;
57 cout << larger <<
" < " << smaller <<
" ? " << (larger < smaller) << endl;
60 string var_names [] = {
"x",
"y" };
66 x2.
print(
true, cout, var_names);
68 xy.
print(
true, cout, var_names);
71 x3y_first.
print(
false, cout, var_names); cout <<
',';
72 x3y_second.
print(
true, cout, var_names);
Information necessary for a field modulo a prime.
void print(bool=true, ostream &=cout, const string *names=nullptr) const
prints the monomial to the give stream with the given names; adds a newline if the boolean is true ...
bool divisible_by(const Monomial &other) const
Divisible by other?
virtual Indeterminate * indeterminates()
an array of the ring’s indeterminates; use only to biuld polynomials
Implementation of indeterminates, for easier building of polynomials.
Implementation of monomials.
Encapsulates information about a polynomial ring for easy access: ground field, number of indetermina...
Monomial lcm(const Monomial &u) const
Least common multiple: largest exponents.
Monomial gcd(const Monomial &u) const
Greatest common divisor: smallest exponents.