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

◆ IM2_Matrix_promote()

const Matrix * IM2_Matrix_promote ( const FreeModule * newTarget,
const Matrix * f )

Matrix interface routines

Definition at line 764 of file matrix.cpp.

766{
767 try
768 {
769 ring_elem a;
770 const Ring *R = f->get_ring();
771 const Ring *S = newTarget->get_ring();
772 MatrixConstructor mat(newTarget, f->n_cols());
773 Matrix::iterator i(f);
774 for (int c = 0; c < f->n_cols(); c++)
775 for (i.set(c); i.valid(); i.next())
776 if (S->promote(R, i.entry(), a))
777 mat.set_entry(i.row(), c, a);
778 else
779 {
780 ERROR("cannot promote given matrix");
781 return nullptr;
782 }
783 mat.compute_column_degrees();
784 return mat.to_matrix();
785 } catch (const exc::engine_error& e)
786 {
787 ERROR(e.what());
788 return nullptr;
789 }
790}
const Ring * get_ring() const
Definition freemod.hpp:102
const Ring * get_ring() const
Definition matrix.hpp:134
int n_cols() const
Definition matrix.hpp:147
Mutable builder used to assemble an immutable Matrix one column (or one term) at a time.
virtual bool promote(const Ring *R, const ring_elem f, ring_elem &result) const =0
xxx xxx xxx
Definition ring.hpp:102
const int ERROR
Definition m2-mem.cpp:55

References MatrixConstructor::compute_column_degrees(), Matrix::iterator::entry(), ERROR, FreeModule::get_ring(), Matrix::get_ring(), Matrix, Matrix::n_cols(), Matrix::iterator::next(), Ring::promote(), Matrix::iterator::row(), Matrix::iterator::set(), MatrixConstructor::set_entry(), MatrixConstructor::to_matrix(), and Matrix::iterator::valid().