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

◆ power()

void M2::ARingGFM2::power ( elem & result,
elem a,
long n ) const
inline

Definition at line 333 of file aring-m2-gf.hpp.

334 {
335 if (a != 0)
336 {
337 long order1 = static_cast<long>(mGF.orderMinusOne());
338 result = static_cast<elem>((a * n) % order1);
339 if (result <= 0) result += mGF.orderMinusOne();
340 }
341 else
342 {
343 // a is the zero element
344 if (n > 0)
345 result = 0;
346 else if (n == 0)
347 result = mGF.one();
348 else
349 throw exc::division_by_zero_error();
350 }
351 }
GaloisFieldTable mGF
VALGRIND_MAKE_MEM_DEFINED & result(result)

References mGF, and result().

Referenced by fromSmallIntegerCoefficients(), and power_mpz().