11 #include "GmshConfig.h"
12 #if defined(HAVE_KBIPACK)
23 #include "gmp_normal_form.h"
26 #include "gmp_normal_form.h"
39 gmp_matrix *_hMatrix[5];
47 gmp_matrix *_jMatrix[5];
49 gmp_matrix *_qMatrix[5];
52 gmp_matrix *_hbasis[5];
55 std::vector<long int> _torsion[5];
62 std::map<Cell *, int, CellPtrLessThan> _cellIndices[4];
65 void setHMatrix(
int dim, gmp_matrix *matrix)
67 if(dim > -1 && dim < 5) _hMatrix[dim] = matrix;
69 void setKerHMatrix(
int dim, gmp_matrix *matrix)
71 if(dim > -1 && dim < 5) _kerH[dim] = matrix;
73 void setCodHMatrix(
int dim, gmp_matrix *matrix)
75 if(dim > -1 && dim < 5) _codH[dim] = matrix;
77 void setJMatrix(
int dim, gmp_matrix *matrix)
79 if(dim > -1 && dim < 5) _jMatrix[dim] = matrix;
81 void setQMatrix(
int dim, gmp_matrix *matrix)
83 if(dim > -1 && dim < 5) _qMatrix[dim] = matrix;
85 void setHbasis(
int dim, gmp_matrix *matrix)
87 if(dim > -1 && dim < 5) _hbasis[dim] = matrix;
91 gmp_matrix *getHMatrix(
int dim)
const
93 if(dim > -1 && dim < 5)
98 gmp_matrix *getKerHMatrix(
int dim)
const
100 if(dim > -1 && dim < 5)
105 gmp_matrix *getCodHMatrix(
int dim)
const
107 if(dim > -1 && dim < 5)
112 gmp_matrix *getJMatrix(
int dim)
const
114 if(dim > -1 && dim < 5)
115 return _jMatrix[dim];
119 gmp_matrix *getQMatrix(
int dim)
const
121 if(dim > -1 && dim < 5)
122 return _qMatrix[dim];
126 gmp_matrix *getHbasis(
int dim)
const
128 if(dim > -1 && dim < 5)
135 bool deformChain(std::map<Cell *, int, CellPtrLessThan> &cells,
136 std::pair<Cell *, int> cell,
bool bend);
137 bool deform(std::map<Cell *, int, CellPtrLessThan> &cells,
138 std::map<Cell *, int, CellPtrLessThan> &cellsInChain,
139 std::map<Cell *, int, CellPtrLessThan> &cellsNotInChain);
140 void smoothenChain(std::map<Cell *, int, CellPtrLessThan> &cells);
141 void eraseNullCells(std::map<Cell *, int, CellPtrLessThan> &cells);
142 void deImmuneCells(std::map<Cell *, int, CellPtrLessThan> &cells);
148 ChainComplex(
CellComplex *cellComplex,
int domain = 0);
151 int getDim()
const {
return _dim; }
157 gmp_matrix *getBasis(
int dim,
int basis);
158 gmp_matrix *getBoundaryOp(
int dim)
160 if(dim > -1 && dim < 5)
161 return _hMatrix[dim];
168 void KerCod(
int dim);
172 void Inclusion(
int lowDim,
int highDim);
176 void Quotient(
int dim,
int setDim);
180 void transposeHMatrices();
181 void transposeHMatrix(
int dim);
184 void computeHomology(
bool dual =
false);
186 typedef std::map<Cell *, int, CellPtrLessThan>::iterator citer;
187 citer firstCell(
int dim) {
return _cellIndices[dim].begin(); }
188 citer lastCell(
int dim) {
return _cellIndices[dim].end(); }
190 int getCellIndex(
Cell *cell)
192 auto cit = _cellIndices[cell->
getDim()].find(cell);
193 if(cit != lastCell(cell->
getDim()))
200 std::vector<int> getCoeffVector(
int dim,
int chainNumber);
205 void getBasisChain(std::map<Cell *, int, CellPtrLessThan> &chain,
int num,
206 int dim,
int basis,
bool deform =
false);
208 int getBasisSize(
int dim,
int basis);
210 int getTorsion(
int dim,
int num);
213 void transformBasis(gmp_matrix *T,
int dim,
int basis)
215 if(basis == 3 && _hbasis[dim] !=
nullptr) {
216 gmp_matrix_right_mult(_hbasis[dim], T);
222 int printMatrix(gmp_matrix *matrix)
224 printf(
"%d rows and %d columns\n", (
int)gmp_matrix_rows(matrix),
225 (
int)gmp_matrix_cols(matrix));
226 return gmp_matrix_printf(matrix);