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

◆ syzygy()

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

Definition at line 60 of file aring-zz-flint.cpp.

64{
65 assert(!is_zero(b));
66 // First check the special cases a = 0, b = 1, -1. Other cases: use gcd.
67 if (is_zero(a))
68 {
69 set_from_long(x, 1);
70 set_zero(y);
71 return;
72 }
73 if (fmpz_cmp_ui(&b, 1) == 0)
74 {
75 set_from_long(x, 1);
76 negate(y, a);
77 return;
78 }
79 if (fmpz_cmp_si(&b, -1) == 0)
80 {
81 set_from_long(x, 1);
82 set(y, a);
83 return;
84 }
86 init(g);
87 fmpz_gcd(&g, &a, &b);
88 divide(y, a, g);
89 divide(x, b, g);
90 if (fmpz_sgn(&x) > 0)
91 negate(y, y);
92 else
93 negate(x, x);
94 clear(g);
95}
bool is_zero(const ElementType &f) const
void set(ElementType &result, const ElementType &a) const
void negate(ElementType &result, const ElementType &a) const
void set_zero(ElementType &result) const
bool divide(ElementType &result, const ElementType &a, const ElementType &b) const
test doc
void init(ElementType &result) const
void set_from_long(ElementType &result, long a) const
static void clear(ElementType &result)
volatile int x

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