Macaulay2 Engine
Loading...
Searching...
No Matches
dmat-gf-flint.hpp
Go to the documentation of this file.
1// Copyright 2014 Michael E. Stillman
2
3#ifndef _dmat_gf_flint__hpp_
4#define _dmat_gf_flint__hpp_
5
41
42#include <utility> // for swap
43#include "aring-gf-flint.hpp" // for ARingGFFlint
44
45// The following needs to be included before any flint files are included.
46#include <M2/gc-include.h>
47
48#pragma GCC diagnostic push
49#pragma GCC diagnostic ignored "-Wconversion"
50#include <flint/fq_nmod_mat.h> // for fq_zech_mat_entry, fq_zech_mat_clear
51#include <flint/fq_zech_mat.h> // for fq_zech_mat_t
52#pragma GCC diagnostic pop
53
54template <typename ACoeffRing>
55class DMat;
56
70// Flint: use fq_nmod_mat for implementation of dense matrices //
72template <>
73class DMat<M2::ARingGFFlint>
74{
75 public:
79 // typedef ElementType elem;
80 // typedef ACoeffRing::Element Element;
81
82 DMat() : mRing(0) {}
83 DMat(const ACoeffRing& R, size_t nrows, size_t ncols) : mRing(&R)
84 {
85 fq_zech_mat_init(mArray, nrows, ncols, ring().flintContext());
86 }
87
88 DMat(const DMat<ACoeffRing>& M) : mRing(&M.ring())
89 {
90 fq_zech_mat_init_set(mArray, M.mArray, ring().flintContext());
91 }
92
93 ~DMat() { fq_zech_mat_clear(mArray, ring().flintContext()); }
94
95 // swap the actual matrices of 'this' and 'M'.
96 // The rings must be the same.
98 {
101 }
102
103 const ACoeffRing& ring() const { return *mRing; }
104 size_t numRows() const
105 {
106 return fq_zech_mat_nrows(mArray, ring().flintContext());
107 }
108 size_t numColumns() const
109 {
110 return fq_zech_mat_ncols(mArray, ring().flintContext());
111 }
112
113 ElementType& entry(size_t row, size_t column)
114 {
115 return *fq_zech_mat_entry(mArray, row, column);
116 }
117 const ElementType& entry(size_t row, size_t column) const
118 {
119 return *fq_zech_mat_entry(mArray, row, column);
120 }
121
122 void resize(size_t new_nrows, size_t new_ncols)
123 {
124 DMat newMatrix(ring(), new_nrows, new_ncols);
125 swap(newMatrix);
126 }
127
128 // These are labelled 'unsafe', as it s possible the rows
129 // are out of order (which happens in particular if
130 // certain flint functions created this.
131 const ElementType* unsafeArray() const { return mArray->entries; }
132 ElementType*& unsafeArray() { return mArray->entries; }
133
134 public:
135 // Access routines so that the flint fq_zech_mat interface may be used
136 const fq_zech_mat_t& fq_zech_mat() const { return mArray; }
137 fq_zech_mat_t& fq_zech_mat() { return mArray; }
138 private:
140 fq_zech_mat_t mArray;
141};
142
143#endif
144
145// Local Variables:
146// compile-command: "make -C $M2BUILDDIR/Macaulay2/e "
147// indent-tabs-mode: nil
148// End:
M2::ARingGFFlint — small GF(p^k) via FLINT Zech-logarithm tables.
M2::ARingGFFlint ACoeffRing
const ACoeffRing * mRing
const ElementType * unsafeArray() const
DMat(const DMat< ACoeffRing > &M)
ACoeffRing::ElementType ElementType
const fq_zech_mat_t & fq_zech_mat() const
ElementType & entry(size_t row, size_t column)
fq_zech_mat_t & fq_zech_mat()
DMat(const ACoeffRing &R, size_t nrows, size_t ncols)
const ACoeffRing & ring() const
void swap(DMat< ACoeffRing > &M)
const ElementType & entry(size_t row, size_t column) const
ElementType *& unsafeArray()
void resize(size_t new_nrows, size_t new_ncols)
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
fq_zech_struct ElementType
aring-style adapter for FLINT's Zech-logarithm representation of small finite fields GF(p^n).
#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