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

◆ mutableMatrix_to_NTL_mat_ZZ()

NTL::mat_ZZ * mutableMatrix_to_NTL_mat_ZZ ( const MutableMatrix * M)

Definition at line 6 of file ntl-interface.cpp.

7{
8 // Creates the TRANSPOSE of M
9
10 // We assume or check that the ring is ZZ
11
12 // const SparseMutableMatrix *A = M->cast_to_SparseMutableMatrix();
13 const MutableMatrix *A = M;
14
15 int ncols = static_cast<int>(A->n_rows());
16 int nrows = static_cast<int>(A->n_cols());
17
18 NTL::mat_ZZ *X = makeNTLMatrixZZ(nrows, ncols);
19 for (int i = 0; i < ncols; i++)
20 for (int j = 0; j < nrows; j++)
21 {
22 ring_elem a;
23 if (A->get_entry(i, j, a))
24 {
25 mat_ZZ_set_entry(X, j, i, a.get_mpz());
26 }
27 }
28
29 return X;
30}
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
Abstract base class for mutable matrices over an arbitrary engine Ring, the in-place counterpart of t...
Definition mat.hpp:79
void mat_ZZ_set_entry(NTL::mat_ZZ *A, long i, long j, mpz_srcptr a)
NTL::mat_ZZ * makeNTLMatrixZZ(int nrows, int ncols)
mpz_srcptr get_mpz() const
Definition ringelem.hpp:127

References MutableMatrix::get_entry(), ring_elem::get_mpz(), makeNTLMatrixZZ(), mat_ZZ_set_entry(), MutableMatrix::n_cols(), and MutableMatrix::n_rows().

Referenced by ntl_LLL().