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

◆ power()

void M2::ARingCCC::power ( ElementType & result,
const ElementType & a,
int n ) const
inline

Definition at line 460 of file aring-CCC.hpp.

461 {
462 ElementType curr_pow;
463 init(curr_pow);
465 if (n == 0)
466 {
467 }
468 else if (n < 0)
469 {
470 n = -n;
471 invert(curr_pow, a);
472 }
473 else
474 {
475 set(curr_pow, a);
476 }
477 while (n > 0)
478 {
479 if (n % 2)
480 {
481 mult(result, result, curr_pow);
482 }
483 n = n / 2;
484 mult(curr_pow, curr_pow, curr_pow);
485 }
486 clear(curr_pow);
487 }
void set_from_long(ElementType &result, long a) const
void init(ElementType &result) const
void mult(ElementType &res, const ElementType &a, const RealElementType &b) const
static void clear(ElementType &result)
void set(ElementType &result, const ElementType &a) const
void invert(ElementType &result, const ElementType &a) const
VALGRIND_MAKE_MEM_DEFINED & result(result)

References clear(), init(), invert(), mult(), result(), set(), and set_from_long().

Referenced by power_mpz(), and TEST().