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

◆ promote()

bool GF::promote ( const Ring * R,
const ring_elem f,
ring_elem & result ) const
virtual

Implements Ring.

Definition at line 251 of file GF.cpp.

252{
253 // Rf = Z/p[x]/F(x) ---> GF(p,n)
254 // promotion: need to be able to know the value of 'x'.
255 // lift: need to compute (primite_element)^e
256
257 if (Rf != _originalR) return false;
258
259 const Ring *K = _originalR->getCoefficients();
260
261 result = from_long(0);
262 int exp[1];
263 for (Nterm& t : f)
264 {
265 std::pair<bool, long> b = K->coerceToLongInteger(t.coeff);
266 assert(b.first);
267 ring_elem coef = from_long(b.second);
268 _originalR->getMonoid()->to_expvector(t.monom, exp);
269 // exp[0] is the variable we want. Notice that since the ring is a
270 // quotient,
271 // this degree is < n (where Q_ = P^n).
272 ring_elem g = power(_x_exponent, exp[0]);
273 g = mult(g, coef);
274 result = ring_elem(internal_add(result.get_int(), g.get_int()));
275 }
276 return true;
277}
int internal_add(int f, int g) const
Definition GF.cpp:326
int _x_exponent
Definition GF.hpp:67
const PolynomialRing * _originalR
Definition GF.hpp:64
virtual ring_elem from_long(long n) const
Definition GF.cpp:208
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 GF.cpp:397
virtual ring_elem mult(const ring_elem f, const ring_elem g) const
Definition GF.cpp:372
virtual std::pair< bool, long > coerceToLongInteger(ring_elem a) const
Definition ring.cpp:236
Ring()
Definition ring.hpp:136
VALGRIND_MAKE_MEM_DEFINED & result(result)
const mpreal exp(const mpreal &x, mp_rnd_t r=mpreal::get_default_rnd())
Definition mpreal.h:2298
int get_int() const
Definition ringelem.hpp:124

References _originalR, _x_exponent, Ring::coerceToLongInteger(), from_long(), ring_elem::get_int(), internal_add(), mult(), power(), result(), and Ring::Ring().