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

◆ IM2_MutableMatrix_get_entries()

engine_RawRingElementArrayArrayOrNull IM2_MutableMatrix_get_entries ( const MutableMatrix * M)

Definition at line 204 of file mutable-matrix.cpp.

205{
206 try
207 {
208 int ncols = M->n_cols();
209 int nrows = M->n_rows();
210 if(nrows < 0 || ncols < 0)
211 {
212 ERROR("internal error: matrix has a negative size %d by %d",
213 nrows,
214 ncols);
215 return nullptr;
216 }
217 engine_RawRingElementArrayArray entries =
218 getmemarraytype(engine_RawRingElementArrayArray, nrows);
219 entries->len = nrows;
220 for(int r = 0; r < nrows; r++)
221 {
222 engine_RawRingElementArray currRow =
223 getmemarraytype(engine_RawRingElementArray, ncols);
224 currRow->len = ncols;
225 entries->array[r] = currRow;
226 }
227 for(int r = 0; r < nrows; r++)
228 {
229 for(int c = 0; c < ncols; c++)
230 {
232 M->get_entry(r, c, result);
233 entries->array[r]->array[c] =
235 }
236 }
237 return entries;
238 } catch (const exc::engine_error& e)
239 {
240 ERROR(e.what());
241 return nullptr;
242 }
243 return nullptr;
244}
virtual size_t n_rows() const =0
virtual size_t n_cols() const =0
virtual bool get_entry(size_t r, size_t c, ring_elem &result) const =0
virtual const Ring * get_ring() const =0
static RingElement * make_raw(const Ring *R, ring_elem f)
Definition relem.cpp:20
const int ERROR
Definition m2-mem.cpp:55
VALGRIND_MAKE_MEM_DEFINED & result(result)
#define getmemarraytype(S, len)
Definition m2-mem.h:142

References ERROR, MutableMatrix::get_entry(), MutableMatrix::get_ring(), getmemarraytype, RingElement::make_raw(), MutableMatrix::n_cols(), MutableMatrix::n_rows(), and result().