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

◆ to_M2_MutableMatrix() [1/2]

MutableMatrix * ResF4toM2Interface::to_M2_MutableMatrix ( SchreyerFrame & C,
const Ring * K,
int lev,
int degree )
static

Definition at line 320 of file res-f4-m2-interface.cpp.

324{
325 // The ring K should be the coefficient ring of the poly ring of C,
326 // OR: if the coefficient ring is QQ, then it can be RR, or a finite field.
327
328 // Now we loop through the elements of degree 'degree' at level 'lev'
329 auto& thislevel = C.level(lev);
330 int n = 0;
331 for (auto p = thislevel.begin(); p != thislevel.end(); ++p)
332 {
333 if (p->mDegree == degree) n++;
334 }
335
336 auto& prevlevel = C.level(lev - 1);
337 int* newcomps = new int[prevlevel.size()];
338 int nextcomp = 0;
339 for (int i = 0; i < prevlevel.size(); i++)
340 if (prevlevel[i].mDegree == degree)
341 newcomps[i] = nextcomp++;
342 else
343 newcomps[i] = -1;
344
345 // create the mutable matrix
346 MutableMatrix* result = MutableMatrix::zero_matrix(K, nextcomp, n, true);
347 // Now loop through the elements at thislevel,
348 // and for each, loop through the terms of mSyzygy.
349 // if the component x satisfies newcomps[x] >= 0, then place
350 // this coeff into the mutable matrix.
351 int col = 0;
352
353 for (auto p = thislevel.begin(); p != thislevel.end(); ++p)
354 {
355 if (p->mDegree != degree) continue;
356 auto& f = p->mSyzygy;
357 auto end = ResPolynomialIterator(C.ring(), f, 1);
358 auto i = ResPolynomialIterator(C.ring(), f);
359 for (; i != end; ++i)
360 {
361 long comp = C.monoid().get_component(i.monomial());
362 if (newcomps[comp] >= 0)
363 {
365 f.coeffs, i.coefficient_index());
366 result->set_entry(newcomps[comp], col, a);
367 }
368 }
369 ++col;
370 }
371
372 delete[] newcomps;
373 return result;
374}
static MutableMatrix * zero_matrix(const Ring *R, size_t nrows, size_t ncols, bool dense)
Definition mat.cpp:54
component_index get_component(res_const_packed_monomial m) const
const VectorArithmetic & vectorArithmetic() const
const ResMonoid & monoid() const
std::vector< FrameElement > & level(int lev)
const ResPolyRing & ring() const
ring_elem ringElemFromElementArray(const ElementArray &coeffs, int index) const
int p
VALGRIND_MAKE_MEM_DEFINED & result(result)
TermIterator< Nterm > end(Nterm *)
Definition ringelem.cpp:5

References end(), ResMonoidDense::get_component(), SchreyerFrame::level(), SchreyerFrame::monoid(), p, result(), SchreyerFrame::ring(), VectorArithmetic::ringElemFromElementArray(), ResPolyRing::vectorArithmetic(), and MutableMatrix::zero_matrix().