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

◆ power_mpz()

void M2::ARingCCi::power_mpz ( ElementType & result,
const ElementType & a,
mpz_srcptr n ) const
inline

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

441 {
442 if (mpz_cmp_si(n,2)>=0)
443 {
444 mpz_t r;
445 mpz_init(r);
446 mpz_fdiv_r_ui(r,n,2);
447
448 ElementType b;
449 init(b);
450
451 mpz_t m;
452 mpz_init(m);
453
454 if (mpz_cmp_si(r,0) == 0)
455 {
456 mpz_cdiv_q_ui(m,n,2);
457
458 power_mpz(b,a,m);
459 mult(result,b,b);
460 }
461 else
462 {
463 mpz_sub_ui(m,n,1);
464
465 power_mpz(b,a,m);
466 mult(result,a,b);
467 }
468 mpz_clear(r);
469 mpz_clear(m);
470 }
471 else if (mpz_cmp_si(n,1)==0)
472 {
473 mpfi_set(&result.re,&a.re);
474 mpfi_set(&result.im,&a.im);
475 }
476 else if (mpz_cmp_si(n,0)==0)
477 {
478 mpfi_set_si(&result.re,1);
479 mpfi_set_si(&result.im,0);
480 }
481 else if (mpz_cmp_si(n,0)<0)
482 throw 20;
483 }
void power_mpz(ElementType &result, const ElementType &a, mpz_srcptr n) const
void mult(ElementType &result, const ElementType &a, const ElementType &b) const
void init(ElementType &result) const
VALGRIND_MAKE_MEM_DEFINED & result(result)

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

Referenced by power_mpz().