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

◆ homogenize() [1/2]

RingElement * RingElement::homogenize ( int v,
const std::vector< int > & wts ) const

Definition at line 245 of file relem.cpp.

246{
247 const PolynomialRing *P = R->cast_to_PolynomialRing();
248 if (P == nullptr)
249 {
250 ERROR("expected polynomial ring");
251 return nullptr;
252 }
253 if (v < 0 || v >= P->n_vars())
254 {
255 ERROR("homogenization: improper ring variable");
256 return nullptr;
257 }
258 if (wts.size() == 0 || wts.size() != static_cast<unsigned int>(P->n_vars()))
259 {
260 ERROR("homogenization: improper weight function");
261 return nullptr;
262 }
263 if (wts[v] == 0)
264 {
265 ERROR("homogenization: variable weight is zero");
266 return nullptr;
267 }
268
269 RingElement *result = new RingElement(P, P->homogenize(val, v, wts));
270 if (error()) return nullptr;
271 return result;
272}
virtual ring_elem homogenize(const ring_elem f, int v, int deg, const std::vector< int > &wts) const =0
int n_vars() const
Definition polyring.hpp:196
RingElement(const Ring *R, ring_elem f)
Definition relem.hpp:166
ring_elem val
Definition relem.hpp:69
const Ring * R
Definition relem.hpp:68
int error()
Definition error.c:48
const int ERROR
Definition m2-mem.cpp:55
VALGRIND_MAKE_MEM_DEFINED & result(result)

References ERROR, error(), PolynomialRing::homogenize(), PolynomialRing::n_vars(), R, result(), RingElement(), and val.

Referenced by IM2_RingElement_homogenize(), and IM2_RingElement_homogenize_to_degree().