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

◆ remainderAndQuotient()

ring_elem PolyRing::remainderAndQuotient ( const ring_elem f,
const ring_elem g,
ring_elem & quot ) const
virtual

Reimplemented from Ring.

Definition at line 1163 of file poly.cpp.

1166{
1167 if (K_->get_precision() > 0)
1168 {
1169 throw exc::engine_error(
1170 "polynomial division not yet implemented for RR or CC coefficients");
1171 }
1172 Nterm *q, *r;
1173 ring_elem rem;
1174 if (is_zero(f))
1175 {
1176 // In this case both the remainder and quotient are 0.
1177 quot = from_long(0);
1178 return from_long(0);
1179 }
1180 if (is_zero(g))
1181 {
1182 quot = from_long(0);
1183 return copy(f);
1184 }
1185 else
1186 {
1187 bool has_negative_exponent_variables = getMonoid()->numInvertibleVariables() > 0;
1188 bool has_vars_lt_one = getMonoid()->numNonTermOrderVariables() > 0;
1189
1190 if (has_negative_exponent_variables and not has_vars_lt_one)
1191 {
1192 Nterm* f1 = f;
1193 Nterm* g1 = g;
1195 quot = q;
1196 return r;
1197 }
1198 else if (has_vars_lt_one)
1199 {
1200 Nterm *f1 = f;
1201 Nterm *g1 = g;
1202 r = powerseries_division_algorithm(f1, g1, q);
1203 quot = q;
1204 return r;
1205 }
1206 else
1207 {
1208 rem = division_algorithm(f, g, q);
1209 quot = q;
1210 return rem;
1211 }
1212 }
1213 quot = from_long(0);
1214 return from_long(0);
1215}
int numNonTermOrderVariables() const
Definition monoid.hpp:190
int numInvertibleVariables() const
Definition monoid.hpp:189
virtual ring_elem from_long(long n) const
Definition poly.cpp:169
Nterm * division_algorithm_with_laurent_variables(Nterm *f, Nterm *g, Nterm *&quot) const
Definition poly.cpp:1422
virtual ring_elem copy(const ring_elem f) const
Definition poly.cpp:653
Nterm * division_algorithm(Nterm *f, Nterm *g, Nterm *&quot) const
Definition poly.cpp:1458
Nterm * powerseries_division_algorithm(Nterm *f, Nterm *g, Nterm *&quot) const
Definition poly.cpp:1553
virtual bool is_zero(const ring_elem f) const
Definition poly.cpp:487
const Ring * K_
Definition polyring.hpp:123
virtual const Monoid * getMonoid() const
Definition polyring.hpp:282
const mpreal rem(const mpreal &x, const mpreal &y, mp_rnd_t rnd_mode=mpreal::get_default_rnd())
Definition mpreal.h:2628

References copy(), division_algorithm(), division_algorithm_with_laurent_variables(), from_long(), PolynomialRing::getMonoid(), is_zero(), PolynomialRing::K_, Monoid::numInvertibleVariables(), Monoid::numNonTermOrderVariables(), and powerseries_division_algorithm().

Referenced by divide(), gcd(), gcd_extended(), quotient(), and remainder().