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

◆ power()

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

Definition at line 408 of file aring-CCi.hpp.

409 {
410 if (n >= 2)
411 {
412 ElementType b;
413 init(b);
414 if (n%2 == 0)
415 {
416 power(b,a,n/2);
417 mult(result,b,b);
418 }
419 else
420 {
421 power(b,a,n-1);
422 mult(result,a,b);
423 }
424 }
425 else if (n == 1)
426 {
427 mpfi_set(&result.re,&a.re);
428 mpfi_set(&result.im,&a.im);
429 }
430 else if (n == 0)
431 {
432 mpfi_set_si(&result.re,1);
433 mpfi_set_si(&result.im,0);
434 }
435 else if (n<0)
436 throw 20;
437 }
void mult(ElementType &result, const ElementType &a, const ElementType &b) const
void init(ElementType &result) const
void power(ElementType &result, const ElementType &a, int n) const
VALGRIND_MAKE_MEM_DEFINED & result(result)

References cci_struct::im, init(), mult(), power(), cci_struct::re, and result().

Referenced by power().