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

◆ polyListToMatrix()

template<typename PolyL>
const Matrix * polyListToMatrix ( const M2FreeAlgebraOrQuotient * A,
const PolyL & elems,
int numrows,
int numcols )

Definition at line 927 of file groebner.cpp.

931{
932 if (elems.size() != numrows*numcols)
933 ERROR("Number of elements in list does not match matrix size.");
934 MatrixConstructor mat(A->make_FreeModule(numrows), numcols);
935 for (auto i = 0; i < elems.size(); ++i)
936 {
937 int curCol = i % numcols;
938 int curRow = (i - curCol) / numcols;
939 ring_elem a = const_cast<Nterm*>(reinterpret_cast<const Nterm*>(elems[i]));
940 mat.set_entry(curRow, curCol, a);
941 }
942 mat.compute_column_degrees();
943 return mat.to_matrix();
944}
Mutable builder used to assemble an immutable Matrix one column (or one term) at a time.
virtual FreeModule * make_FreeModule() const
Definition ring.cpp:53
const int ERROR
Definition m2-mem.cpp:55
Singly linked-list node carrying one term of a polynomial-ring element.
Definition ringelem.hpp:156

References MatrixConstructor::compute_column_degrees(), ERROR, Ring::make_FreeModule(), Matrix, MatrixConstructor::set_entry(), and MatrixConstructor::to_matrix().

Referenced by rawNCBasis(), rawNCGroebnerBasisTwoSided(), and rawNCReductionTwoSided().