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

◆ syzygy()

void M2::ARingZZGMP::syzygy ( const ElementType & a,
const ElementType & b,
ElementType & x,
ElementType & y ) const

Definition at line 47 of file aring-zz-gmp.cpp.

51{
52 assert(!is_zero(b));
53 // First check the special cases a = 0, b = 1, -1. Other cases: use gcd.
54 if (is_zero(a))
55 {
56 set_from_long(x, 1);
57 set_zero(y);
58 return;
59 }
60 if (mpz_cmp_ui(&b, 1) == 0)
61 {
62 set_from_long(x, 1);
63 negate(y, a);
64 return;
65 }
66 if (mpz_cmp_si(&b, -1) == 0)
67 {
68 set_from_long(x, 1);
69 set(y, a);
70 return;
71 }
72 elem g;
73 init(g);
74 mpz_gcd(&g, &a, &b);
75 divide(y, a, g);
76 divide(x, b, g);
77 if (mpz_sgn(&x) > 0)
78 negate(y, y);
79 else
80 negate(x, x);
81 clear(g);
82}
void init(ElementType &result) const
ElementType elem
static void clear(ElementType &result)
void set(ElementType &result, const ElementType &a) const
void set_zero(ElementType &result) const
void negate(ElementType &result, const ElementType &a) const
void divide(ElementType &result, const ElementType &a, const ElementType &b) const
exact division of integers.
void set_from_long(ElementType &result, long a) const
bool is_zero(const ElementType &f) const
volatile int x

References clear(), divide(), init(), is_zero(), negate(), set(), set_from_long(), set_zero(), and x.