86{
87 try
88 {
91 if(nrows < 0 || ncols < 0)
92 {
93 ERROR(
"internal error: matrix has a negative size %d by %d",
94 nrows,
95 ncols);
96 return nullptr;
97 }
98 engine_RawRingElementArrayArray entries =
100 entries->len = nrows;
103 for(int r = 0; r < nrows; r++)
104 {
105 engine_RawRingElementArray currRow =
107 currRow->len = ncols;
108 std::fill_n(currRow->array, ncols,
zero);
109 entries->array[r] = currRow;
110 }
111
112 for(int c = 0; c < ncols; c++)
113 {
114 const vec &column = M->
elem(c);
115 for(
const vecterm &term : column)
116 {
117 if(term.comp < 0 || term.comp >= nrows)
118 {
119 ERROR(
"internal error: matrix contains invalid entries:"
120 "row index %d out of range 0 .. %d",
121 term.comp,
122 nrows - 1);
123
124 continue;
125 }
126 entries->array[term.comp]->array[c] =
128 }
129 }
130 return entries;
132 {
134 return nullptr;
135 }
136 return nullptr;
137}
const Ring * get_ring() const
ring_elem elem(int i, int j) const
static RingElement * make_raw(const Ring *R, ring_elem f)
Front-end-visible "ring element" value: an engine ring_elem paired with the Ring* that gives it meani...
#define getmemarraytype(S, len)