Main Page | Class List | File List | Class Members | File Members

matrix_addon.h

Go to the documentation of this file.
00001 /** 
00002  * $Id: matrix_addon.h,v 1.8 2006/10/01 02:10:46 meister Exp $
00003  * 
00004  * Polylib matrix addons
00005  * Mainly, deals with polyhedra represented in implicit form (set of
00006  * constraints).
00007  * @author Benoit Meister 
00008  */
00009 
00010 #ifndef __BM_MATRIX_ADDON_H__
00011 #define __BM_MATRIX_ADDON_H__
00012 
00013 #include<polylib/polylib.h>
00014 #include<assert.h>
00015 
00016 /** Shortcut for Matrix_Print */
00017 #define show_matrix(M) { printf(#M"= \n"); \
00018                          if (M!=NULL) { \
00019                          Matrix_Print(stderr,P_VALUE_FMT,(M));} \
00020                          else {printf("<NULL>\n");} \
00021                        } 
00022 
00023 /** 
00024  * Allocates a matrix if it is null, or else asserts that it has at least a
00025  * certain size */
00026 #define ensureMatrix(M, r, c) { if (M==NULL) M = Matrix_Alloc(r,c); \
00027                                 else assert (M->NbRows>=r && M->NbColumns>=c); \
00028                               } 
00029 
00030 /* Creates a view of the constraints of a polyhedron as a Matrix * */
00031 Matrix * constraintsView(Polyhedron * P);
00032 
00033 /* "Frees" a view of the constraints of a polyhedron */
00034 void constraintsView_Free(Matrix * M);
00035 
00036 /* splits a matrix of constraints M into a matrix of equalities Eqs and a
00037    matrix of inequalities Ineqs allocs the new matrices. */
00038 void split_constraints(Matrix const * M, Matrix ** Eqs, Matrix **Ineqs);
00039 
00040 /* returns the dim-dimensional identity matrix */
00041 Matrix * Identity_Matrix(unsigned int dim);
00042 
00043 /* given a n x n integer transformation matrix transf, compute its inverse M/g,
00044  where M is a nxn integer matrix.  g is a common denominator for elements of
00045  (transf^{-1})*/
00046 void mtransformation_inverse(Matrix * transf, Matrix ** inv, Value * g);
00047 
00048 /* simplifies a matrix seen as a polyhedron, by dividing its rows by the gcd of
00049 their elements. */
00050 void mpolyhedron_simplify(Matrix * polyh);
00051 
00052 /* inflates a polyhedron (represented as a matrix) P, so that the apx of its
00053    Ehrhart Polynomial is an upper bound of the Ehrhart polynomial of P WARNING:
00054    this inflation is supposed to be applied on full-dimensional polyhedra. */
00055 void mpolyhedron_inflate(Matrix * polyh, unsigned int nb_parms);
00056 
00057 /* deflates a polyhedron (represented as a matrix) P, so that the apx of its
00058    Ehrhart Polynomial is a lower bound of the Ehrhart polynomial of P WARNING:
00059    this deflation is supposed to be applied on full-dimensional polyhedra. */
00060 void mpolyhedron_deflate(Matrix * polyh, unsigned int nb_parms);
00061 
00062 /* use an eliminator row to eliminate a variable in a victim row (without
00063 changing the sign of the victim row -> important if it is an inequality).  */
00064 void eliminate_var_with_constr(Matrix * Eliminator, 
00065                                unsigned int eliminator_row, Matrix * Victim, 
00066                                unsigned int victim_row, 
00067                                unsigned int var_to_elim);
00068 
00069 
00070 /* ----- PARTIAL MAPPINGS ----- */
00071 
00072 /* compresses the last vars/pars of the polyhedron M expressed as a polylib
00073    matrix
00074  - adresses the full-rank compressions only
00075  - modfies M */
00076 void mpolyhedron_compress_last_vars(Matrix * M, Matrix * compression);
00077 #define Constraints_compressLastVars(a, b) mpolyhedron_compress_last_vars(a, b)
00078 
00079 /* uses a set of m equalities Eqs to eliminate m variables in the polyhedron.
00080  Ineqs represented as a matrix eliminates the m first variables 
00081 - assumes that Eqs allows to eliminate the m equalities 
00082 - modifies Ineqs */
00083 unsigned int mpolyhedron_eliminate_first_variables(Matrix * Eqs, 
00084                                                    Matrix * Ineqs);
00085 #define Constraints_eliminateFirstVars(a,b) mpolyhedron_eliminate_first_variables(a,b)
00086 
00087 /** returns a contiguous submatrix of a matrix. */
00088 void Matrix_subMatrix(Matrix * M, unsigned int sr, unsigned int sc, 
00089                       unsigned int nbR, unsigned int nbC, Matrix ** sub);
00090 
00091 /**
00092  * Copies a contiguous submatrix of M1 into M2, at the indicated position.
00093  * M1 and M2 are assumed t be allocated already.
00094  */
00095 void Matrix_copySubMatrix(Matrix *M1,
00096                           unsigned int sr1, unsigned int sc1,
00097                           unsigned int nbR, unsigned int nbC,
00098                           Matrix * M2,
00099                           unsigned int sr2, unsigned int sc2);
00100 
00101 /** 
00102  * given a matrix M into -M
00103  */
00104 void Matrix_oppose(Matrix * M);
00105 
00106 #endif /* __BM_MATRIX_ADDON_H__ */

Generated on Mon Apr 23 19:23:52 2007 for polylib by doxygen 1.3.5