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

◆ lift()

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

Implements Ring.

Definition at line 142 of file M2FreeAlgebra.cpp.

143{
144 // R is the target ring
145 // f1 is an element of 'this'.
146 // set result to be the "lift" of f in the ring R, return true if this is possible.
147 // otherwise return false.
148
149 // case: R is the coefficient ring of 'this'.
150 std::cout << "called lift NC case" << std::endl;
151 if (R == coefficientRing())
152 {
153 auto f = reinterpret_cast<const Poly*>(f1.get_Poly());
154 if (f->numTerms() != 1) return false;
155 auto i = f->cbegin();
156 if (monoid().is_one(i.monom()))
157 {
158 result = coefficientRing()->copy(i.coeff());
159 return true;
160 }
161 }
162
163 // at this point, we can't lift it.
164 return false;
165}
Polynomial< CoefficientRingType > Poly
const Ring * coefficientRing() const
const FreeMonoid & monoid() const
virtual ring_elem copy(const ring_elem f) const =0
VALGRIND_MAKE_MEM_DEFINED & result(result)

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