OPENF4
Library for Gröebner basis computations over finite fields.
 All Classes Namespaces Files Functions Variables Friends Pages
Public Member Functions | Private Attributes | List of all members
F4::Matrix< Element > Class Template Reference

Represent a matrix. More...

#include <matrix.h>

Public Member Functions

 Matrix ()
 Constructor.
 
 Matrix (int height, int width)
 Constructor. More...
 
 Matrix (std::string const &filename)
 Constructor. More...
 
 Matrix (Matrix const &matrix)
 Copy constructor. More...
 
 Matrix (Matrix &&matrix)
 Move constructor. More...
 
 ~Matrix ()
 Destructor.
 
Element & operator() (int row, int col)
 Modify matrix element. More...
 
Element operator() (int row, int col) const
 Get matrix element. More...
 
Element getElement (int row, int col) const
 Get matrix element. More...
 
void setElement (int row, int col, Element const &element)
 Modify matrix element. More...
 
Element * getRow (int row)
 Get the row-th row of this. More...
 
int getHeight () const
 Get the height of the matrix (number of rows).
 
int getWidth () const
 Get the width of the matrix (number of columns).
 
void setNbPiv (int nbPiv)
 Specify the number of pivots.
 
int getNbPiv () const
 Get the number of pivots.
 
void setTau (int *tau)
 Specify the permutation _tau.
 
int * getTau ()
 Get the permutation _tau.
 
void setSigma (int *sigma)
 Specify the permutation _sigma.
 
int * getSigma ()
 Get the permutation _sigma.
 
void setStartTail (int *startTail)
 Specify the array _startTail.
 
int * getStartTail ()
 Get the array _startTail.
 
void setEndCol (int *encCol)
 Specify the array _endCol.
 
int * getEndCol ()
 Get the array _endCol.
 
void setInfo (int nbPiv, int *tau, int *sigma, int *startTail, int *endCol)
 Set the informations required by echelonize.
 
void printMatrix (std::ostream &stream) const
 Print the matrix.
 
void printMatrix (std::string const &filename) const
 Print the matrix.
 
void printMatrixTxt (std::string const &filename) const
 Print the matrix in a format readable by constructor.
 
void printMatrixSage (std::string const &filename) const
 Print the matrix in a format readable by sage.
 
bool isZero (int row, int col) const
 Test if _matrix(row,col) is zero. More...
 
void normalizeRow (Element *row, int start, int end)
 Normalize a slice of the row-th row. More...
 
void normalizeRowPrime (Element *row, int start, int end)
 Specialisation of normalizeRow for ElementPrime type. More...
 
void normalizeRowGF2Extension (Element *row, int start, int end)
 Specialisation of normalizeRow for ElementGF2Extension type. More...
 
void multRow (Element *row, Element const &element, int start, int end)
 Multiply a slice of the row-th row by element. More...
 
void multRowPrime (Element *row, Element const &element, int start, int end)
 Specialisation of multRow for ElementPrime type. More...
 
void multRowGF2Extension (Element *row, Element const &element, int start, int end)
 Specialisation of multRow for ElementGF2Extension type. More...
 
void addMultRow (Element *row1, Element *row2, Element element, int start, int end)
 Multiply a slice of the row1-th row by element and add a slice of the row2-th row. More...
 
void addMultRowPrime (Element *row1, Element *row2, Element element, int start, int end)
 Specialisation of addMultRow for ElementPrime type. More...
 
void addMultRowGF2Extension (Element *row1, Element *row2, Element element, int start, int end)
 Specialisation of addMultRow for ElementGF2Extension type. More...
 
void doubleAddMultRowGF2Extension (Element *dest1, Element *dest2, Element mult1, Element mult2, Element *vec, int start, int end)
 dest1 += mult1 * vec, dest2 += mult2 * vec. More...
 
void tripleAddMultRowGF2Extension (Element *dest1, Element *dest2, Element *dest3, Element mult1, Element mult2, Element mult3, Element *vec, int start, int end)
 dest1 += mult1 * vec, dest2 += mult2 * vec, dest3 += mult3 * vec. More...
 
void quadAddMultRowGF2Extension (Element *dest1, Element *dest2, Element *dest3, Element *dest4, Element mult1, Element mult2, Element mult3, Element mult4, Element *vec, int start, int end)
 dest1 += mult1 * vec, dest2 += mult2 * vec, dest3 += mult3 * vec, dest4 += mult4 * vec. More...
 
void octAddMultRowGF2Extension (Element *dest1, Element *dest2, Element *dest3, Element *dest4, Element *dest5, Element *dest6, Element *dest7, Element *dest8, Element mult1, Element mult2, Element mult3, Element mult4, Element mult5, Element mult6, Element mult7, Element mult8, Element *vec, int start, int end)
 dest1 += mult1 * vec, dest2 += mult2 * vec, dest3 += mult3 * vec, dest4 += mult4 * vec, dest5 += mult5 * vec, dest6 += mult6 * vec, dest7 += mult7 * vec, dest8 += mult8 * vec. More...
 
void groupAddMultRowGF2Extension (int ll, int dec, int startL2, int endL2, int start, int end)
 Use octAddMultRowGF2Extension, quadAddMultRowGF2Extension, tripleAddMultRowGF2Extension, doubleAddMultRowGF2Extension and addMultRowGF2Extension to suppress elements in column ll+dec from row startL2 to row endL2 using multiple of row ll. More...
 
void swapRow (int numRow1, int numRow2)
 Swap a slice of the row1-th row with a slice of the row2-th row. More...
 
void swapCol (int numCol1, int numCol2, int start, int end)
 Swap a slice of the row1-th row with a slice of the row2-th row. More...
 
int echelonizeRight (chrono::duration< int, milli > &tmp_ech_db, chrono::duration< int, milli > &tmp_ech_dh)
 Echelonize the left slice of the matrix using FFLAS-FFPACK routines. More...
 
int echelonize ()
 Echelonize the matrix using the shape of the F4 matrix. More...
 
int echelonizePrime ()
 Specialisation of echelonize for ElementPrime Type, use lazy arithmetic. More...
 
int echelonizeGF2Extension ()
 Specialisation of echelonize for ElementGF2Extension Type. More...
 
Matrixoperator= (Matrix const &matrix)
 Overload the operator =. More...
 
Matrixoperator= (Matrix &&matrix)
 Overload the operator = (move assignment). Used when mon is unnamed (only copy the pointer). More...
 

Private Attributes

Element ** _matrix
 
int _height
 
int _width
 
int _nbPiv
 
int * _tau
 
int * _sigma
 
int * _startTail
 
int * _endCol
 

Detailed Description

template<typename Element>
class F4::Matrix< Element >

Represent a matrix.

Definition at line 80 of file matrix.h.

Constructor & Destructor Documentation

template<typename Element>
F4::Matrix< Element >::Matrix ( int  height,
int  width 
)

Constructor.

Parameters
heightHeight of _matrix.
widthWidth of _matrix.
template<typename Element>
F4::Matrix< Element >::Matrix ( std::string const &  filename)

Constructor.

Parameters
filenameName of a matrix file.
template<typename Element>
F4::Matrix< Element >::Matrix ( Matrix< Element > const &  matrix)

Copy constructor.

Parameters
matrixMatrix.
template<typename Element>
F4::Matrix< Element >::Matrix ( Matrix< Element > &&  matrix)

Move constructor.

Parameters
matrixMatrix.

Member Function Documentation

template<typename Element>
void F4::Matrix< Element >::addMultRow ( Element *  row1,
Element *  row2,
Element  element,
int  start,
int  end 
)

Multiply a slice of the row1-th row by element and add a slice of the row2-th row.

Parameters
row1Row of the matrix. The one to modify.
row2Row of the matrix.
elementElement used to multiply each element of the slice.
startBeginning of the slice.
endEnd of the slice.
template<typename Element>
void F4::Matrix< Element >::addMultRowGF2Extension ( Element *  row1,
Element *  row2,
Element  element,
int  start,
int  end 
)

Specialisation of addMultRow for ElementGF2Extension type.

Parameters
row1Row of the matrix. The one to modify.
row2Row of the matrix.
elementElement used to multiply each element of the slice.
startBeginning of the slice.
endEnd of the slice.
template<typename Element>
void F4::Matrix< Element >::addMultRowPrime ( Element *  row1,
Element *  row2,
Element  element,
int  start,
int  end 
)

Specialisation of addMultRow for ElementPrime type.

Parameters
row1Row of the matrix. The one to modify.
row2Row of the matrix.
elementElement used to multiply each element of the slice.
startBeginning of the slice.
endEnd of the slice.
template<typename Element>
void F4::Matrix< Element >::doubleAddMultRowGF2Extension ( Element *  dest1,
Element *  dest2,
Element  mult1,
Element  mult2,
Element *  vec,
int  start,
int  end 
)

dest1 += mult1 * vec, dest2 += mult2 * vec.

Parameters
dest1Row of the matrix to modify.
dest2Row of the matrix to modify.
mult1Element used to multiply each element of the slice.
mult2Element used to multiply each element of the slice.
vecRow of the matrix to add.
startBeginning of the slice.
endEnd of the slice.
template<typename Element>
int F4::Matrix< Element >::echelonize ( )

Echelonize the matrix using the shape of the F4 matrix.

Returns
Height of the echelonized matrix.
template<typename Element>
int F4::Matrix< Element >::echelonizeGF2Extension ( )

Specialisation of echelonize for ElementGF2Extension Type.

Returns
Height of the echelonized matrix.
template<typename Element>
int F4::Matrix< Element >::echelonizePrime ( )

Specialisation of echelonize for ElementPrime Type, use lazy arithmetic.

Returns
Height of the echelonized matrix.
template<typename Element>
int F4::Matrix< Element >::echelonizeRight ( chrono::duration< int, milli > &  tmp_ech_db,
chrono::duration< int, milli > &  tmp_ech_dh 
)

Echelonize the left slice of the matrix using FFLAS-FFPACK routines.

Returns
Height of the echelonized matrix.
template<typename Element>
Element F4::Matrix< Element >::getElement ( int  row,
int  col 
) const

Get matrix element.

Parameters
rowRow of the element.
colColumn of the element.
Returns
Element.
template<typename Element>
Element* F4::Matrix< Element >::getRow ( int  row)

Get the row-th row of this.

Parameters
rowIndex of the row.
template<typename Element>
void F4::Matrix< Element >::groupAddMultRowGF2Extension ( int  ll,
int  dec,
int  startL2,
int  endL2,
int  start,
int  end 
)

Use octAddMultRowGF2Extension, quadAddMultRowGF2Extension, tripleAddMultRowGF2Extension, doubleAddMultRowGF2Extension and addMultRowGF2Extension to suppress elements in column ll+dec from row startL2 to row endL2 using multiple of row ll.

Parameters
llPivot row.
decGap between ll and modified column.
startL2First row to modify (set 0 in _matrix[startL2][ll+dec]).
endL2Last row to modify is endL2-1 (set 0 in _matrix[endL2-1][ll+dec]).
startBeginning of the slice to modify.
endEnd of the slice.
template<typename Element>
bool F4::Matrix< Element >::isZero ( int  row,
int  col 
) const

Test if _matrix(row,col) is zero.

Parameters
rowRow of the element.
colColumn of the element.
Returns
true if _matrix(row,col) is zero.
false otherwise.
template<typename Element>
void F4::Matrix< Element >::multRow ( Element *  row,
Element const &  element,
int  start,
int  end 
)

Multiply a slice of the row-th row by element.

Parameters
rowRow of the matrix.
elementElement used to multiply each element of the slice.
startBeginning of the slice.
endEnd of the slice.
template<typename Element>
void F4::Matrix< Element >::multRowGF2Extension ( Element *  row,
Element const &  element,
int  start,
int  end 
)

Specialisation of multRow for ElementGF2Extension type.

Parameters
rowRow of the matrix.
elementElement used to multiply each element of the slice.
startBeginning of the slice.
endEnd of the slice.
template<typename Element>
void F4::Matrix< Element >::multRowPrime ( Element *  row,
Element const &  element,
int  start,
int  end 
)

Specialisation of multRow for ElementPrime type.

Parameters
rowRow of the matrix.
elementElement used to multiply each element of the slice.
startBeginning of the slice.
endEnd of the slice.
template<typename Element>
void F4::Matrix< Element >::normalizeRow ( Element *  row,
int  start,
int  end 
)

Normalize a slice of the row-th row.

Parameters
rowRow to normalize.
startBeginning of the slice.
endEnd of the slice.
template<typename Element>
void F4::Matrix< Element >::normalizeRowGF2Extension ( Element *  row,
int  start,
int  end 
)

Specialisation of normalizeRow for ElementGF2Extension type.

Parameters
rowRow to normalize.
startBeginning of the slice.
endEnd of the slice.
template<typename Element>
void F4::Matrix< Element >::normalizeRowPrime ( Element *  row,
int  start,
int  end 
)

Specialisation of normalizeRow for ElementPrime type.

Parameters
rowRow to normalize.
startBeginning of the slice.
endEnd of the slice.
template<typename Element>
void F4::Matrix< Element >::octAddMultRowGF2Extension ( Element *  dest1,
Element *  dest2,
Element *  dest3,
Element *  dest4,
Element *  dest5,
Element *  dest6,
Element *  dest7,
Element *  dest8,
Element  mult1,
Element  mult2,
Element  mult3,
Element  mult4,
Element  mult5,
Element  mult6,
Element  mult7,
Element  mult8,
Element *  vec,
int  start,
int  end 
)

dest1 += mult1 * vec, dest2 += mult2 * vec, dest3 += mult3 * vec, dest4 += mult4 * vec, dest5 += mult5 * vec, dest6 += mult6 * vec, dest7 += mult7 * vec, dest8 += mult8 * vec.

Parameters
dest1Row of the matrix to modify.
dest2Row of the matrix to modify.
dest3Row of the matrix to modify.
dest4Row of the matrix to modify.
dest5Row of the matrix to modify.
dest6Row of the matrix to modify.
dest7Row of the matrix to modify.
dest8Row of the matrix to modify.
mult1Element used to multiply each element of the slice.
mult2Element used to multiply each element of the slice.
mult3Element used to multiply each element of the slice.
mult4Element used to multiply each element of the slice.
mult5Element used to multiply each element of the slice.
mult6Element used to multiply each element of the slice.
mult7Element used to multiply each element of the slice.
mult8Element used to multiply each element of the slice.
vecRow of the matrix to add.
startBeginning of the slice.
endEnd of the slice.
template<typename Element>
Element& F4::Matrix< Element >::operator() ( int  row,
int  col 
)

Modify matrix element.

Parameters
rowRow of the element.
colColumn of the element.
Returns
Reference on the element.
template<typename Element>
Element F4::Matrix< Element >::operator() ( int  row,
int  col 
) const

Get matrix element.

Parameters
rowRow of the element.
colColumn of the element.
Returns
Element.
template<typename Element>
Matrix& F4::Matrix< Element >::operator= ( Matrix< Element > const &  matrix)

Overload the operator =.

Precondition
The static variable MODULO must be set beforehand.
Parameters
matrixMatrix to copy.
Returns
Reference on this.
template<typename Element>
Matrix& F4::Matrix< Element >::operator= ( Matrix< Element > &&  matrix)

Overload the operator = (move assignment). Used when mon is unnamed (only copy the pointer).

Precondition
The static variable MODULO must be set beforehand.
Parameters
matrixMatrix to copy.
Returns
Reference on this.
template<typename Element>
void F4::Matrix< Element >::quadAddMultRowGF2Extension ( Element *  dest1,
Element *  dest2,
Element *  dest3,
Element *  dest4,
Element  mult1,
Element  mult2,
Element  mult3,
Element  mult4,
Element *  vec,
int  start,
int  end 
)

dest1 += mult1 * vec, dest2 += mult2 * vec, dest3 += mult3 * vec, dest4 += mult4 * vec.

Parameters
dest1Row of the matrix to modify.
dest2Row of the matrix to modify.
dest3Row of the matrix to modify.
dest4Row of the matrix to modify.
mult1Element used to multiply each element of the slice.
mult2Element used to multiply each element of the slice.
mult3Element used to multiply each element of the slice.
mult4Element used to multiply each element of the slice.
vecRow of the matrix to add.
startBeginning of the slice.
endEnd of the slice.
template<typename Element>
void F4::Matrix< Element >::setElement ( int  row,
int  col,
Element const &  element 
)

Modify matrix element.

Parameters
rowRow of the element.
colColumn of the element.
elementElement.
template<typename Element>
void F4::Matrix< Element >::swapCol ( int  numCol1,
int  numCol2,
int  start,
int  end 
)

Swap a slice of the row1-th row with a slice of the row2-th row.

Parameters
numCol1Number of the column.
numCol2Number of the column.
startBeginning of the slice.
endEnd of the slice.
template<typename Element>
void F4::Matrix< Element >::swapRow ( int  numRow1,
int  numRow2 
)

Swap a slice of the row1-th row with a slice of the row2-th row.

Parameters
numRow1Number of the row.
numRow2Number of the row.
template<typename Element>
void F4::Matrix< Element >::tripleAddMultRowGF2Extension ( Element *  dest1,
Element *  dest2,
Element *  dest3,
Element  mult1,
Element  mult2,
Element  mult3,
Element *  vec,
int  start,
int  end 
)

dest1 += mult1 * vec, dest2 += mult2 * vec, dest3 += mult3 * vec.

Parameters
dest1Row of the matrix to modify.
dest2Row of the matrix to modify.
dest3Row of the matrix to modify.
mult1Element used to multiply each element of the slice.
mult2Element used to multiply each element of the slice.
mult3Element used to multiply each element of the slice.
vecRow of the matrix to add.
startBeginning of the slice.
endEnd of the slice.

Member Data Documentation

template<typename Element>
int* F4::Matrix< Element >::_endCol
private

endCol[i] = end of column i if i < nbPiv. Otherwise endCol[i]=end of column i without taking into account the lines under nbPiv.

Definition at line 487 of file matrix.h.

template<typename Element>
int F4::Matrix< Element >::_height
private

Height of _matrix.

Definition at line 481 of file matrix.h.

template<typename Element>
Element** F4::Matrix< Element >::_matrix
private

"Macaulay" matrix

Definition at line 480 of file matrix.h.

template<typename Element>
int F4::Matrix< Element >::_nbPiv
private

Number of pivots.

Definition at line 483 of file matrix.h.

template<typename Element>
int* F4::Matrix< Element >::_sigma
private

_sigma[i]=index in tab_mon of the column i monomial.

Definition at line 485 of file matrix.h.

template<typename Element>
int* F4::Matrix< Element >::_startTail
private

startTail[i]=column of the first possibly non zero coefficient (in line i) after nb_piv if i < nb_piv. Otherwise startTail[i]=0. startTail[i] = min{j>=nb_piv : _igma[i]<_sigma[j]}.

Definition at line 486 of file matrix.h.

template<typename Element>
int* F4::Matrix< Element >::_tau
private

Permutation, _sigma(_tau(i))=_tau(_sigma(i))=i. _tau[i]=column of the monomial tab_mon[i].

Definition at line 484 of file matrix.h.

template<typename Element>
int F4::Matrix< Element >::_width
private

Width of _matrix.

Definition at line 482 of file matrix.h.


The documentation for this class was generated from the following file: