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

◆ power() [2/2]

void FreeAlgebra::power ( Poly & result,
const Poly & f,
mpz_srcptr n ) const

Definition at line 708 of file FreeAlgebra.cpp.

709{
710 if (mpz_sgn(n) == 0) from_long(result, 1);
711 else if (is_zero(f)) from_long(result, 0);
712 else if (is_unit(f)) // really want a routine 'is_scalar'...
713 {
714 ring_elem coeff = f.cbegin().coeff();
715 ring_elem a = coefficientRing()->power(coeff, n);
717 }
718 else
719 {
720 std::pair<bool, int> n1 = RingZZ::get_si(n);
721 if (mpz_sgn(n) > 0 and n1.first)
722 power(result, f, n1.second);
723 else
724 {
725 ERROR("exponent too large");
726 from_long(result, 0);
727 }
728 }
729}
const Ring * coefficientRing() const
void power(Poly &result, const Poly &f, int n) const
bool is_unit(const Poly &f) const
void from_long(Poly &result, long n) const
void from_coefficient(Poly &result, const ring_elem a) const
bool is_zero(const Poly &f) const
virtual ring_elem power(const ring_elem f, mpz_srcptr n) const
Exponentiation. This is the default function, if a class doesn't define this.
Definition ring.cpp:109
static std::pair< bool, int > get_si(mpz_srcptr n)
Definition ZZ.cpp:46
const int ERROR
Definition m2-mem.cpp:55
VALGRIND_MAKE_MEM_DEFINED & result(result)

References coefficientRing(), ERROR, from_coefficient(), from_long(), RingZZ::get_si(), is_unit(), is_zero(), power(), Ring::power(), and result().