F4
Library for Gröebner basis computation in finite field.
 All Classes Namespaces Files Functions Variables Friends Pages
matrix-generic.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Antoine Joux, Vanessa Vitse and Titouan Coladon
3  *
4  * This file is part of F4.
5  *
6  * F4 is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * F4 is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with F4. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
26 #ifndef F4_MATRIX_GENERIC_H
27 #define F4_MATRIX_GENERIC_H
28 
30 #include <iostream>
31 #include <cassert>
32 #include <ctime>
33 #include <chrono>
34 #include <string>
35 #include <fstream>
36 #include <sstream>
37 #include <givaro/modular-balanced.h>
38 #include <fflas-ffpack/ffpack/ffpack.h>
39 #include <fflas-ffpack/utils/Matio.h>
45 namespace F4
46 {
51  template <class Field>
53  {
54  public:
55 
56  /* Constructor */
57 
62  MatrixGeneric(Field & f);
63 
70  MatrixGeneric(Field & f, int height, int width);
71 
77  MatrixGeneric(Field & f, std::string const & filename);
78 
83  MatrixGeneric(MatrixGeneric const & matrix);
84 
89  MatrixGeneric(MatrixGeneric && matrix);
90 
91 
92  /* Destructor */
93 
98 
102  void erase();
103 
104 
106 
108  //* \brief Modify matrix element.
109  //* \param row: Row of the element.
110  //* \param col: Column of the element.
111  //* \return Reference on the element.
112  //*/
113  //Field::Element & operator() (int row, int col);
114 
116  //* \brief Get matrix element.
117  //* \param row: Row of the element.
118  //* \param col: Column of the element.
119  //* \return Element.
120  //*/
121  //Field::Element operator() (int row, int col) const;
122 
124  //* \brief Get matrix element.
125  //* \param row: Row of the element.
126  //* \param col: Column of the element.
127  //* \return Element.
128  //*/
129  //Field::Element getElement(int row, int col) const;
130 
132  //* \brief Modify matrix element.
133  //* \param row: Row of the element.
134  //* \param col: Column of the element.
135  //* \param element: Element.
136  //*/
137  //void setElement (int row, int col, Field::Element const & element);
138 
140  //* \brief Get the row-th row of this.
141  //* \param row: Index of the row.
142  //*/
143  //Field::Element * getRow (int row);
144 
148  int getHeight() const;
149 
153  int getWidth() const;
154 
158  void setNbPiv(int nbPiv);
159 
163  int getNbPiv() const;
164 
168  void setTau(int * tau);
169 
173  int * getTau();
174 
178  void setSigma(int * sigma);
179 
183  int * getSigma();
184 
188  void setStartTail(int * startTail);
189 
193  int * getStartTail();
194 
198  void setEndCol(int * encCol);
199 
203  int * getEndCol();
204 
208  void setInfo(int nbPiv, int *tau, int *sigma, int * startTail, int * endCol);
209 
210 
211  /* Miscellaneous */
212 
216  void printMatrix (std::ostream & stream) const;
217 
221  void printMatrix (std::string const & filename) const;
222 
230  bool isZero(int row, int col) const;
231 
236  int echelonize ();
237 
238 
240 
242  //* \brief Overload the operator =.
243  //* \pre The static variable MODULO must be set beforehand.
244  //* \param matrix: MatrixGeneric to copy.
245  //* \return Reference on this.
246  //*/
247  //MatrixGeneric & operator=(MatrixGeneric const & matrix);
248 
250  //* \brief Overload the operator = (move assignment). Used when mon is unnamed (only copy the pointer).
251  //* \pre The static variable MODULO must be set beforehand.
252  //* \param matrix: MatrixGeneric to copy.
253  //* \return Reference on this.
254  //*/
255  //MatrixGeneric & operator=(MatrixGeneric && matrix);
256 
257  private:
258  typename Field::Element * _matrix;
259  typename Field::Element * _A;
260  typename Field::Element * _B;
261  typename Field::Element * _C;
262  typename Field::Element * _D;
263  Field _F;
264  int _height;
265  int _width;
266  int _nbPiv;
267  int * _tau;
268  int * _sigma;
269  int * _startTail;
270  int * _endCol;
271  };
272 
273 
274  /* Internal operator */
275 
280  template <typename Element>
281  std::ostream & operator<<(std::ostream & stream, MatrixGeneric<Element> const & matrix);
282 }
283 
284 #include "../src/matrix-generic.inl"
285 
286 #endif // F4_MATRIX_GENERIC_H
int * getEndCol()
Get the array _endCol.
Field::Element * _A
void printMatrix(std::ostream &stream) const
Print the matrix.
int * getSigma()
Get the permutation _sigma.
int getHeight() const
Modify matrix element.
void setTau(int *tau)
Specify the permutation _tau.
void setStartTail(int *startTail)
Specify the array _startTail.
MatrixGeneric(Field &f)
Constructor.
bool isZero(int row, int col) const
Test if _matrix(row,col) is zero.
Field::Element * _matrix
Overload the operator =.
Field::Element * _B
~MatrixGeneric()
Destructor.
int * getTau()
Get the permutation _tau.
int * getStartTail()
Get the array _startTail.
void setInfo(int nbPiv, int *tau, int *sigma, int *startTail, int *endCol)
Set the informations required by echelonize.
int echelonize()
Echelonize the matrix mat using the shape of the F4 matrix.
void erase()
Delete _startTail, _endCol, _sigma, _tau.
Field::Element * _D
int getNbPiv() const
Get the number of pivots.
void setEndCol(int *encCol)
Specify the array _endCol.
void setNbPiv(int nbPiv)
Specify the number of pivots.
int getWidth() const
Get the width of the matrix (number of columns).
Field::Element * _C
void setSigma(int *sigma)
Specify the permutation _sigma.