Macaulay2 Engine
Loading...
Searching...
No Matches
dmat-gf-flint-big.hpp
Go to the documentation of this file.
1// Copyright 2014 Michael E. Stillman
2
3#ifndef _dmat_gf_flint_big_hpp_
4#define _dmat_gf_flint_big_hpp_
5
40
41#include <utility> // for swap
42#include "aring-gf-flint-big.hpp" // for ARingGFFlintBig
43
44// The following needs to be included before any flint files are included.
45#include <M2/gc-include.h>
46
47#pragma GCC diagnostic push
48#pragma GCC diagnostic ignored "-Wconversion"
49#include <flint/fq_nmod_mat.h> // for fq_nmod_mat_t, fq_nmod_mat_entry, ...
50#pragma GCC diagnostic pop
51
52template <typename ACoeffRing>
53class DMat;
54
68// Flint: use fq_nmod_mat for implementation of dense matrices //
70template <>
71class DMat<M2::ARingGFFlintBig>
72{
73 public:
77 // typedef ElementType elem;
78 // typedef ACoeffRing::Element Element;
79
80 DMat() : mRing(0) {}
81 DMat(const ACoeffRing& R, size_t nrows, size_t ncols) : mRing(&R)
82 {
83 fq_nmod_mat_init(mArray, nrows, ncols, ring().flintContext());
84 }
85
86 DMat(const DMat<ACoeffRing>& M) : mRing(&M.ring())
87 {
88 fq_nmod_mat_init_set(mArray, M.mArray, ring().flintContext());
89 }
90
91 ~DMat() { fq_nmod_mat_clear(mArray, ring().flintContext()); }
92
93 // swap the actual matrices of 'this' and 'M'.
94 // The rings must be the same.
96 {
99 }
100
101 const ACoeffRing& ring() const { return *mRing; }
102 size_t numRows() const
103 {
104 return fq_nmod_mat_nrows(mArray, ring().flintContext());
105 }
106 size_t numColumns() const
107 {
108 return fq_nmod_mat_ncols(mArray, ring().flintContext());
109 }
110
111 ElementType& entry(size_t row, size_t column)
112 {
113 return *fq_nmod_mat_entry(mArray, row, column);
114 }
115 const ElementType& entry(size_t row, size_t column) const
116 {
117 return *fq_nmod_mat_entry(mArray, row, column);
118 }
119
120 void resize(size_t new_nrows, size_t new_ncols)
121 {
122 DMat newMatrix(ring(), new_nrows, new_ncols);
123 swap(newMatrix);
124 }
125
126 // These are labelled 'unsafe', as it s possible the rows
127 // are out of order (which happens in particular if
128 // certain flint functions created this.
129 const ElementType* unsafeArray() const { return mArray->entries; }
130 ElementType*& unsafeArray() { return mArray->entries; }
131
132 public:
133 // Access routines so that the flint fq_nmod_mat interface may be used
134 const fq_nmod_mat_t& fq_nmod_mat() const { return mArray; }
135 fq_nmod_mat_t& fq_nmod_mat() { return mArray; }
136 private:
138 fq_nmod_mat_t mArray;
139};
140
141#endif
142
143// Local Variables:
144// compile-command: "make -C $M2BUILDDIR/Macaulay2/e "
145// indent-tabs-mode: nil
146// End:
M2::ARingGFFlintBig — arbitrary-degree GF(p^k) via FLINT fq_nmod.
const ElementType * unsafeArray() const
void resize(size_t new_nrows, size_t new_ncols)
ACoeffRing::ElementType ElementType
const ACoeffRing & ring() const
ElementType & entry(size_t row, size_t column)
DMat(const ACoeffRing &R, size_t nrows, size_t ncols)
const fq_nmod_mat_t & fq_nmod_mat() const
DMat(const DMat< ACoeffRing > &M)
void swap(DMat< ACoeffRing > &M)
const ElementType & entry(size_t row, size_t column) const
const ACoeffRing * mRing
Definition dmat.hpp:174
ElementType * mArray
Definition dmat.hpp:177
const ACoeffRing & ring() const
Definition dmat.hpp:143
Definition dmat.hpp:62
aring-style adapter for FLINT's polynomial-quotient representation of finite fields GF(p^n) that are ...
#define swap(a, b, t)
Definition monsort.hpp:127
Definition aring-CC.cpp:3
void swap(mpfr::mpreal &x, mpfr::mpreal &y)
Definition mpreal.h:3244