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

◆ power()

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

Definition at line 361 of file aring-CC.hpp.

362 {
363 ElementType curr_pow;
364 init(curr_pow);
366 if (n == 0)
367 {
368 }
369 else if (n < 0)
370 {
371 n = -n;
372 invert(curr_pow, a);
373 }
374 else
375 {
376 set(curr_pow, a);
377 }
378 while (n > 0)
379 {
380 if (n % 2)
381 {
382 mult(result, result, curr_pow);
383 }
384 n = n / 2;
385 mult(curr_pow, curr_pow, curr_pow);
386 }
387 clear(curr_pow);
388 }
void set_from_long(ElementType &result, long a) const
Definition aring-CC.hpp:171
void invert(ElementType &res, const ElementType &a) const
Definition aring-CC.hpp:234
void set(ElementType &result, const ElementType &a) const
Definition aring-CC.hpp:157
void mult(ElementType &res, const ElementType &a, const RealElementType &b) const
Definition aring-CC.hpp:303
elem ElementType
Definition aring-CC.hpp:81
void init(ElementType &result) const
Definition aring-CC.hpp:150
static void clear(ElementType &result)
Definition aring-CC.hpp:164
VALGRIND_MAKE_MEM_DEFINED & result(result)

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

Referenced by power_mpz(), and TEST().