32 unsigned int i, j, k_eq, k_ineq, nb_eqs = 0;
35 for (i = 0; i < M->
NbRows; i++)
44 for (i = 0; i < M->
NbRows; i++) {
61 for (i = 0; i < dim; i++) {
62 for (j = 0; j < dim; j++) {
82 assert((*I)->NbRows >= dim && (*I)->NbColumns >= dim);
83 for (i = 0; i < dim; i++) {
84 for (j = 0; j < dim; j++) {
114 for (i = 0; i < inv->
NbRows; i++)
116 for (i = 0; i < inv->
NbRows; i++) {
118 for (j = 0; j < (*inverse)->NbColumns; j++)
131 int offset = new_dim - M->
NbRows;
137 for (i = 0; i < M->
NbRows; i++)
138 for (j = 0; j < M->
NbRows; j++)
149 for (i = 0; i < polyh->
NbRows; i++) {
151 printf(
" gcd[%d] = ", i);
166 unsigned nb_vars = polyh->
NbColumns - nb_parms - 2;
170 for (i = 0; i < polyh->
NbRows; i++) {
172 for (j = 0; j < nb_vars; j++) {
188 unsigned nb_vars = polyh->
NbColumns - nb_parms - 2;
192 for (i = 0; i < polyh->
NbRows; i++) {
194 for (j = 0; j < nb_vars; j++) {
214 Matrix *Victim,
unsigned int victim_row,
215 unsigned int var_to_elim) {
216 Value cur_lcm, mul_a, mul_b;
227 value_lcm(cur_lcm, Eliminator->
p[eliminator_row][var_to_elim + 1],
228 Victim->
p[victim_row][var_to_elim + 1]);
231 Eliminator->
p[eliminator_row][var_to_elim + 1]);
232 value_division(mul_b, cur_lcm, Victim->
p[victim_row][var_to_elim + 1]);
241 for (k = 1; k < Victim->
NbColumns; k++) {
262 unsigned int i, j, k;
270 for (i = 0; i < M->
NbRows; i++) {
271 for (j = 0; j < compression->
NbRows; j++) {
273 for (k = 0; k < compression->
NbRows; k++) {
274 value_addmul(M_tmp->
p[0][j], M->
p[i][k + offset], compression->
p[k][j]);
277 for (j = 0; j < compression->
NbRows; j++)
289 unsigned int i, j, k;
291 for (i = 0; i < Eqs->
NbRows; i++) {
293 for (j = 0; j < Eqs->
NbRows &&
303 for (k = j + 1; k < Eqs->
NbRows; k++)
305 for (k = 0; k < Ineqs->
NbRows; k++)
311 for (i = 0; i < Eqs->
NbRows; i++)
326 unsigned int er,
unsigned int ec,
Matrix **sub) {
330 assert(er <= M->NbRows && ec <= M->NbColumns);
331 if ((*sub) == NULL) {
334 if (nbR == 0 || nbC == 0)
336 for (i = 0; i < nbR; i++) {
362 unsigned int nbR,
unsigned int nbC,
Matrix *M2,
363 unsigned int sr2,
unsigned int sc2) {
365 for (i = 0; i < nbR; i++) {
366 Vector_Copy(&(M1->
p[i + sr1][sc1]), &(M2->
p[i + sr2][sc2]), nbC);
375 for (i = 0; i < M->
NbRows; i++) {
Matrix * Matrix_Copy(Matrix const *Src)
#define value_oppose(ref, val)
#define value_notzero_p(val)
#define value_lcm(ref, val1, val2)
#define value_zero_p(val)
#define value_assign(v1, v2)
#define value_set_si(val, i)
#define value_addmul(ref, val1, val2)
#define value_division(ref, val1, val2)
#define value_multiply(ref, val1, val2)
#define value_print(Dst, fmt, val)
#define value_subtract(ref, val1, val2)
#define value_addto(ref, val1, val2)
#define value_cmp_si(val, n)
Matrix * Matrix_Alloc(unsigned NbRows, unsigned NbColumns)
int MatInverse(Matrix *Mat, Matrix *MatInv)
void Matrix_Free(Matrix *Mat)
void mpolyhedron_deflate(Matrix *polyh, unsigned int nb_parms)
deflates a polyhedron (represented as a matrix) P, so that the apx of its Ehrhart Polynomial is a low...
void split_constraints(Matrix const *M, Matrix **Eqs, Matrix **Ineqs)
splits a matrix of constraints M into a matrix of equalities Eqs and a matrix of inequalities Ineqs a...
void Matrix_subMatrix(Matrix *M, unsigned int sr, unsigned int sc, unsigned int er, unsigned int ec, Matrix **sub)
returns a contiguous submatrix of a matrix.
void mpolyhedron_compress_last_vars(Matrix *M, Matrix *compression)
compress the last vars/pars of the polyhedron M expressed as a polylib matrix
Matrix * Identity_Matrix(unsigned int dim)
unsigned int mpolyhedron_eliminate_first_variables(Matrix *Eqs, Matrix *Ineqs)
use a set of m equalities Eqs to eliminate m variables in the polyhedron Ineqs represented as a matri...
void eliminate_var_with_constr(Matrix *Eliminator, unsigned int eliminator_row, Matrix *Victim, unsigned int victim_row, unsigned int var_to_elim)
use an eliminator row to eliminate a variable in a victim row (without changing the sign of the victi...
void Matrix_clone(Matrix *M, Matrix **Cl)
Cloning function.
void constraintsView_Free(Matrix *M)
"Frees" a view of the constraints of a polyhedron
void mtransformation_inverse(Matrix *transf, Matrix **inverse, Value *g)
given a n x n integer transformation matrix transf, compute its inverse M/g, where M is a nxn integer...
Matrix * mtransformation_expand_left_to_dim(Matrix *M, int new_dim)
takes a transformation matrix, and expands it to a higher dimension with the identity matrix regardle...
void mpolyhedron_inflate(Matrix *polyh, unsigned int nb_parms)
inflates a polyhedron (represented as a matrix) P, so that the apx of its Ehrhart Polynomial is an up...
void Matrix_copySubMatrix(Matrix *M1, unsigned int sr1, unsigned int sc1, unsigned int nbR, unsigned int nbC, Matrix *M2, unsigned int sr2, unsigned int sc2)
Copies a contiguous submatrix of M1 into M2, at the indicated position.
void Matrix_oppose(Matrix *M)
transforms a matrix M into -M
void mpolyhedron_simplify(Matrix *polyh)
simplify a matrix seen as a polyhedron, by dividing its rows by the gcd of their elements.
void Matrix_identity(unsigned int dim, Matrix **I)
returns the dim-dimensional identity matrix.
Matrix * constraintsView(Polyhedron *P)
Creates a view of the constraints of a polyhedron as a Matrix *.
void Vector_Gcd(Value *p, unsigned length, Value *min)
void Vector_AntiScale(Value *p1, Value *p2, Value lambda, unsigned length)
void Vector_Copy(Value *p1, Value *p2, unsigned length)