00001 // Polylib Matrix addons 00002 // Mainly deals with polyhedra represented as a matrix (implicit form) 00003 // B. Meister 00004 00005 #ifndef __BM_MATRIX_ADDON_H__ 00006 #define __BM_MATRIX_ADDON_H__ 00007 00008 #include<polylib/polylib.h> 00009 #include<assert.h> 00010 00011 00012 #define show_matrix(M) {printf(#M"= \n"); Matrix_Print(stderr,P_VALUE_FMT,(M));} 00013 00014 // splits a matrix of constraints M into a matrix of equalities Eqs and a matrix of inequalities Ineqs 00015 // allocs the new matrices. 00016 void split_constraints(Matrix const * M, Matrix ** Eqs, Matrix **Ineqs); 00017 00018 // returns the dim-dimensional identity matrix 00019 Matrix * Identity_Matrix(unsigned int dim); 00020 00021 // given a n x n integer transformation matrix transf, compute its inverse M/g, where M is a nxn integer matrix. 00022 // g is a common denominator for elements of (transf^{-1}) 00023 void mtransformation_inverse(Matrix * transf, Matrix ** inv, Value * g); 00024 00025 // simplify a matrix seen as a polyhedron, by dividing its rows by the gcd of their elements. 00026 void mpolyhedron_simplify(Matrix * polyh); 00027 00028 // inflates a polyhedron (represented as a matrix) P, so that the apx of its Ehrhart Polynomial is an upper bound of the Ehrhart polynomial of P 00029 // WARNING: this inflation is supposed to be applied on full-dimensional polyhedra. 00030 void mpolyhedron_inflate(Matrix * polyh, unsigned int nb_parms); 00031 00032 // deflates a polyhedron (represented as a matrix) P, so that the apx of its Ehrhart Polynomial is a lower bound of the Ehrhart polynomial of P 00033 // WARNING: this deflation is supposed to be applied on full-dimensional polyhedra. 00034 void mpolyhedron_deflate(Matrix * polyh, unsigned int nb_parms); 00035 00036 // use an eliminator row to eliminate a variable in a victim row (without changing the sign of the victim row -> important if it is an inequality). 00037 void eliminate_var_with_constr(Matrix * Eliminator, unsigned int eliminator_row, Matrix * Victim, unsigned int victim_row, unsigned int var_to_elim); 00038 00039 00040 00041 // PARTIAL MAPPINGS 00042 00043 // compress the last vars/pars of the polyhedron M expressed as a polylib matrix 00044 // - adresses the full-rank compressions only 00045 // - modfies M 00046 void mpolyhedron_compress_last_vars(Matrix * M, Matrix * compression); 00047 00048 // use a set of m equalities Eqs to eliminate m variables in the polyhedron Ineqs represented as a matrix 00049 // eliminates the m first variables 00050 // - assumes that Eqs allows to eliminate the m equalities 00051 // - modifies Ineqs 00052 unsigned int mpolyhedron_eliminate_first_variables(Matrix * Eqs, Matrix * Ineqs); 00053 00054 00055 #endif // __BM_MATRIX_ADDON_H__