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

◆ power()

void M2::ARingQQGMP::power ( ElementType & result,
const ElementType & a,
long n ) const
inline

Definition at line 231 of file aring-qq-gmp.hpp.

232 {
233 bool n_is_negative = false;
234 if (n < 0)
235 {
236 if (is_zero(a)) throw exc::division_by_zero_error();
237 n_is_negative = true;
238 n = -n;
239 }
240 mpz_pow_ui(mpq_numref(&result), mpq_numref(&a), n);
241 mpz_pow_ui(mpq_denref(&result), mpq_denref(&a), n);
242 if (n_is_negative)
243 mpq_inv(&result, &result);
244 }
bool is_zero(const ElementType &f) const
VALGRIND_MAKE_MEM_DEFINED & result(result)

References is_zero(), and result().

Referenced by power_mpz().