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

◆ gbvector_remove_content_ZZ()

void GBRing::gbvector_remove_content_ZZ ( gbvector * f,
gbvector * fsyz,
bool use_denom,
ring_elem & denom ) const
protected

Definition at line 1315 of file gbring.cpp.

1322{
1323 // This routine assumes that the coeff ring is ZZ (originally QQ).
1324 gbvector *g = f;
1325 gbvector *gsyz = fsyz;
1326 mpz_t content;
1327 int leadsign;
1328 if (g != nullptr)
1329 {
1330 leadsign = mpz_sgn(g->coeff.get_mpz());
1331 mpz_init_set(content, g->coeff.get_mpz());
1332 g = g->next;
1333 }
1334 else if (gsyz != nullptr)
1335 {
1336 leadsign = mpz_sgn(gsyz->coeff.get_mpz());
1337 mpz_init_set(content, gsyz->coeff.get_mpz());
1338 gsyz = gsyz->next;
1339 }
1340 else
1341 return;
1342
1343 lower_content_ZZ(g, content);
1344 lower_content_ZZ(gsyz, content);
1345
1346 mpz_abs(content, content);
1347 if (mask_mpz_cmp_si(content, 1) == 0)
1348 {
1349 mpz_clear(content);
1350
1351 if (leadsign < 0)
1352 {
1354 gbvector_negate_to(fsyz);
1355 }
1356 return;
1357 }
1358
1359 if (leadsign < 0) mpz_neg(content, content);
1360 divide_coeff_exact_to_ZZ(f, content);
1361 divide_coeff_exact_to_ZZ(fsyz, content);
1362 if (use_denom)
1363 {
1364 denom = globalZZ->mult(denom, ring_elem(content));
1365 }
1366 mpz_clear(content);
1367}
int mask_mpz_cmp_si(mpz_srcptr x, long int i)
Definition ZZ.hpp:53
void lower_content_ZZ(gbvector *f, mpz_ptr content) const
Definition gbring.cpp:1303
void gbvector_negate_to(gbvector *f) const
Definition gbring.cpp:562
void divide_coeff_exact_to_ZZ(gbvector *f, gmp_ZZ u) const
Definition gbring.cpp:1291
virtual ring_elem mult(const ring_elem f, const ring_elem g) const
Definition ZZ.cpp:267
RingZZ * globalZZ
Definition relem.cpp:13
ring_elem coeff
Definition gbring.hpp:81
gbvector * next
Definition gbring.hpp:80
mpz_srcptr get_mpz() const
Definition ringelem.hpp:127

References gbvector::coeff, divide_coeff_exact_to_ZZ(), gbvector_negate_to(), ring_elem::get_mpz(), globalZZ, lower_content_ZZ(), mask_mpz_cmp_si(), and gbvector::next.

Referenced by gbvector_remove_content().