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

◆ make() [2/3]

const Matrix * Matrix::make ( const FreeModule * target,
int ncols,
const engine_RawRingElementArray M )
static

Definition at line 60 of file matrix.cpp.

63{
64 // Checks to make:
65 // each vector in V is over same ring.
66
67 const Ring *R = target->get_ring();
68
69 if (M != nullptr)
70 for (unsigned int i = 0; i < M->len; i++)
71 {
72 if (R != M->array[i]->get_ring())
73 {
74 ERROR("expected vectors in the same ring");
75 return nullptr;
76 }
77 }
78
79 MatrixConstructor mat(target, ncols);
80 if (M != nullptr)
81 {
82 unsigned int next = 0;
83 for (int r = 0; r < target->rank(); r++)
84 for (int c = 0; c < ncols && next < M->len; c++)
85 {
86 mat.set_entry(r, c, M->array[next]->get_value());
87 next++;
88 }
89 mat.compute_column_degrees();
90 }
91 return mat.to_matrix();
92}
const Ring * get_ring() const
Definition freemod.hpp:102
int rank() const
Definition freemod.hpp:105
friend class MatrixConstructor
Definition matrix.hpp:76
const int ERROR
Definition m2-mem.cpp:55

References MatrixConstructor::compute_column_degrees(), ERROR, FreeModule, FreeModule::get_ring(), make(), Matrix(), MatrixConstructor, FreeModule::rank(), MatrixConstructor::set_entry(), and MatrixConstructor::to_matrix().

Referenced by make(), make(), make(), and MatrixConstructor.