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

◆ set_from_mpq()

bool DRing::set_from_mpq ( TowerPolynomial & result,
mpq_srcptr r )

Definition at line 1510 of file dpoly.cpp.

1511{
1512 // returns false if r doesn't lift
1513 mpz_t a;
1514 mpz_init(a);
1515 mpz_mod_ui(a, mpq_numref(r), P);
1516 long ctop = mpz_get_si(a);
1517 mpz_mod_ui(a, mpq_denref(r), P);
1518 long cbottom = mpz_get_si(a);
1519 mpz_clear(a);
1520 if (ctop < 0) ctop += P;
1521 if (cbottom < 0) cbottom += P;
1522 if (cbottom == 0)
1523 {
1524 result = nullptr;
1525 return false;
1526 }
1527 ZZp_INVERT(P, cbottom, cbottom);
1528 ZZp_MULT(P, ctop, cbottom);
1529
1530 result = D.from_long(level, ctop);
1531 return true;
1532}
long P
Definition dpoly.hpp:269
int level
Definition dpoly.hpp:267
DPoly D
Definition dpoly.hpp:268
void ZZp_MULT(long charac, long &a, long b)
Definition dpoly.cpp:63
void ZZp_INVERT(long charac, long &result, long b)
Definition dpoly.cpp:68
VALGRIND_MAKE_MEM_DEFINED & result(result)

References D, level, P, result(), ZZp_INVERT(), and ZZp_MULT().