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

◆ lift()

bool M2FreeAlgebraQuotient::lift ( const Ring * R,
const ring_elem f,
ring_elem & result ) const
virtual

Implements Ring.

Definition at line 123 of file M2FreeAlgebraQuotient.cpp.

124{
125 // R is the target ring
126 // f1 is an element of 'this'.
127 // set result to be the "lift" of f in the ring R, return true if this is possible.
128 // otherwise return false.
129
130 // case: R is the coefficient ring of 'this'.
131 if (R == coefficientRing())
132 {
133 auto f = reinterpret_cast<const Poly*>(f1.get_Poly());
134 if (f->numTerms() != 1) return false;
135 auto i = f->cbegin();
136 if (monoid().is_one(i.monom()))
137 {
138 result = coefficientRing()->copy(i.coeff());
139 return true;
140 }
141 return false;
142 }
143 if (R == &m2FreeAlgebra())
144 {
145 // just copy the element into result, considered in the free algebra.
146 auto f = reinterpret_cast<const Poly*>(f1.get_Poly());
147 auto resultf = new Poly;
148 freeAlgebra().copy(*resultf, *f);
149 result = ring_elem(reinterpret_cast<void *>(resultf));
150 return true;
151 }
152
153 // at this point, we can't lift it.
154 return false;
155}
Polynomial< CoefficientRingType > Poly
void copy(Poly &result, Poly::const_iterator fBegin, Poly::const_iterator fEnd) const
const FreeAlgebra & freeAlgebra() const
const Ring * coefficientRing() const
const M2FreeAlgebra & m2FreeAlgebra() const
const FreeMonoid & monoid() const
virtual ring_elem copy(const ring_elem f) const =0
VALGRIND_MAKE_MEM_DEFINED & result(result)

References coefficientRing(), FreeAlgebra::copy(), Ring::copy(), freeAlgebra(), ring_elem::get_Poly(), m2FreeAlgebra(), monoid(), result(), and Ring::Ring().