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

◆ power() [1/2]

ring_elem Z_mod::power ( const ring_elem f,
int n ) const
virtual

Reimplemented from Ring.

Definition at line 251 of file ZZp.cpp.

252{
253 if (f.get_int() == _ZERO) {
254 if (n < 0)
255 throw exc::division_by_zero_error();
256 else if (n == 0)
257 return ring_elem(0); // this is the element one in this ring. (P-1) is the zero element...
258 return ring_elem(_ZERO);
259 }
260 int m = (f.get_int() * n) % _P1;
261 if (m < 0) m += _P1;
262 return ring_elem(m);
263}
int _ZERO
Definition ZZp.hpp:68
int _P1
Definition ZZp.hpp:67
int get_int() const
Definition ringelem.hpp:124

References _P1, _ZERO, and ring_elem::get_int().