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

◆ division_algorithm_with_laurent_variables()

Nterm * PolyRing::division_algorithm_with_laurent_variables ( Nterm * f,
Nterm * g,
Nterm *& quot ) const
protected

Definition at line 1422 of file poly.cpp.

1423{
1424 // Step 1: replace f with f1, m1 (f = m1 * f1, f1 has only exponents >= 0, and no monomial factors)
1425 // Same: g = n1 * g1.
1426 // then if f1 = q * g1 + r, (q, r polynomials with only non-negative exponents)
1427 // then f = (q*m1*n1^(-1)) * g + m1*r
1428 //std::pair<Nterm*, int*> factor_out_inverse_variables(f);
1429 auto expf = setNegativeExponentMonomial(f);
1430 auto expg = setNegativeExponentMonomial(g);
1431 monomial m = getMonoid()->make_one();
1432 monomial n = getMonoid()->make_one();
1433 getMonoid()->from_expvector(expf.data(), m);
1434 getMonoid()->from_expvector(expg.data(), n);
1435
1436 for (auto& a : expf) a = -a;
1437 for (auto& a : expg) a = -a;
1438 monomial minv = getMonoid()->make_one();
1439 monomial ninv = getMonoid()->make_one();
1440 getMonoid()->from_expvector(expf.data(), minv);
1441 getMonoid()->from_expvector(expg.data(), ninv);
1442
1443 for (int i=0; i<n_vars(); ++i)
1444 expf[i] = -expf[i] + expg[i];
1445 monomial mninv = getMonoid()->make_one();
1446 getMonoid()->from_expvector(expf.data(), mninv);
1447
1448 ring_elem c = getCoefficientRing()->from_long(1);
1449 Nterm* f1 = mult_by_term(f, c, minv); // f1 = m^-1 * f, m only involves the variables which allow negative exponents
1450 Nterm* g1 = mult_by_term(g, c, ninv); // g1 = n^-1 * g.
1451 Nterm* quot1 = nullptr;
1452 Nterm* rem1 = division_algorithm(f1, g1, quot1);
1453 Nterm* rem = mult_by_term(rem1, c, m);
1454 quot = mult_by_term(quot1, c, mninv);
1455 return rem;
1456}
monomial make_one() const
Definition monoid.cpp:455
void from_expvector(const_exponents exp, monomial result) const
Definition monoid.cpp:742
std::vector< int > setNegativeExponentMonomial(Nterm *f) const
Create an exponent vector whose i-th value is the minimum of the exponents of that variable,...
Definition poly.cpp:1401
virtual ring_elem mult_by_term(const ring_elem f, const ring_elem c, const_monomial m) const
Definition poly.cpp:781
Nterm * division_algorithm(Nterm *f, Nterm *g, Nterm *&quot) const
Definition poly.cpp:1458
const Ring * getCoefficientRing() const
Definition polyring.hpp:200
virtual const Monoid * getMonoid() const
Definition polyring.hpp:282
int n_vars() const
Definition polyring.hpp:196
virtual ring_elem from_long(long n) const =0
#define monomial
Definition gb-toric.cpp:11
const mpreal rem(const mpreal &x, const mpreal &y, mp_rnd_t rnd_mode=mpreal::get_default_rnd())
Definition mpreal.h:2628

References division_algorithm(), Monoid::from_expvector(), Ring::from_long(), PolynomialRing::getCoefficientRing(), PolynomialRing::getMonoid(), Monoid::make_one(), monomial, mult_by_term(), PolynomialRing::n_vars(), and setNegativeExponentMonomial().

Referenced by remainderAndQuotient().