Exponentiation. This is the default function, if a class doesn't define this.
Reimplemented in FractionField, GF, LocalRing, M2::ConcreteRing< RingType >, M2::ConcreteRing< ARingQQ >, M2::ConcreteRing< M2::ARingCCC >, M2::ConcreteRing< M2::ARingRRR >, M2FreeAlgebra, M2FreeAlgebraQuotient, PolyRing, PolyRingQuotient, RingZZ, SchurRing, SkewPolynomialRing, SolvableAlgebra, WeylAlgebra, and Z_mod.
Definition at line 109 of file ring.cpp.
110{
111 ring_elem ff = gg;
112 int cmp = mpz_sgn(m);
113 if (cmp == 0)
return one();
114 mpz_t n;
115 mpz_init_set(n, m);
116
117
118
119#if 0
120 if (cmp < 0)
122 mpz_init_set(n, m);
123 mpz_t n;
124 if (cmp < 0)
125 mpz_neg(n, n);
126#endif
127 if (cmp < 0)
128 {
129 mpz_neg(n, n);
131 ff);
133 {
135 "either element not invertible, or no method available to "
136 "compute its inverse");
137 mpz_clear(n);
138 return ff;
139 }
140 }
143 ring_elem tmp;
144
145 for (;;)
146 {
148 {
150 prod = tmp;
151 }
152 mpz_tdiv_q_2exp(n, n, 1);
153 if (mpz_sgn(n) == 0)
154 {
155 mpz_clear(n);
156 return prod;
157 }
158 else
159 {
162 }
163 }
164}
virtual ring_elem invert(const ring_elem f) const =0
virtual ring_elem from_long(long n) const =0
virtual ring_elem copy(const ring_elem f) const =0
virtual bool is_zero(const ring_elem f) const =0
virtual ring_elem mult(const ring_elem f, const ring_elem g) const =0
static unsigned int mod_ui(mpz_srcptr n, unsigned int p)
static CanonicalForm base
References base, copy(), ERROR, from_long(), invert(), is_zero(), RingZZ::mod_ui(), mult(), and one().
Referenced by convertToM2(), GF::eval(), M2::ARingGFFlint::eval(), M2::ARingGFM2::eval(), FreeAlgebra::power(), PolyRingQuotient::power(), PolyRingQuotient::power(), SkewPolynomialRing::power(), SolvableAlgebra::power(), WeylAlgebra::power(), TEST(), and Matrix::top_coefficients().