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

◆ gcd()

ring_elem PolyRing::gcd ( const ring_elem f,
const ring_elem g ) const

Definition at line 1060 of file poly.cpp.

1061{
1062 if (nvars_ != 1)
1063 {
1064 ERROR("multivariate gcd not yet implemented");
1065 return ZERO_RINGELEM;
1066 }
1067 ring_elem f = copy(ff);
1068 ring_elem g = copy(gg);
1069 ring_elem s, rem;
1070 while (!is_zero(g))
1071 {
1072 rem = remainderAndQuotient(f, g, s);
1073 f = g;
1074 g = rem;
1075 }
1076#if 0
1077// #warning commented out make monic in gcd
1078// make_monic(f);
1079#endif
1080 return f;
1081}
virtual ring_elem copy(const ring_elem f) const
Definition poly.cpp:653
virtual ring_elem remainderAndQuotient(const ring_elem f, const ring_elem g, ring_elem &quot) const
Definition poly.cpp:1163
virtual bool is_zero(const ring_elem f) const
Definition poly.cpp:487
void size_t s
Definition m2-mem.cpp:271
const int ERROR
Definition m2-mem.cpp:55
const mpreal rem(const mpreal &x, const mpreal &y, mp_rnd_t rnd_mode=mpreal::get_default_rnd())
Definition mpreal.h:2628
#define ZERO_RINGELEM
Definition ring.hpp:677

References copy(), ERROR, is_zero(), PolynomialRing::nvars_, remainderAndQuotient(), s, and ZERO_RINGELEM.