00001 /* 00002 This file is part of PolyLib. 00003 00004 PolyLib is free software: you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation, either version 3 of the License, or 00007 (at your option) any later version. 00008 00009 PolyLib is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with PolyLib. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 /** 00019 * @author B. Meister 12/2003-2006 00020 * LSIIT -ICPS 00021 * UMR 7005 CNRS 00022 * Louis Pasteur University (ULP), Strasbourg, France 00023 */ 00024 #ifndef __BM_COMPRESS_PARMS_H__ 00025 #define __BM_COMPRESS_PARMS_H__ 00026 00027 #include "matrix_addon.h" 00028 #include "matrix_permutations.h" 00029 #include <assert.h> 00030 00031 00032 /* ----- functions applying on equalities ----- */ 00033 00034 /** 00035 * Given a system of non-redundant equalities, looks if it has an integer 00036 * solution in the combined space, and if yes, returns one solution. 00037 */ 00038 void Equalities_integerSolution(Matrix * Eqs, Matrix ** sol); 00039 00040 /** 00041 * Computes the validity lattice of a set of equalities. I.e., the lattice 00042 * induced on the last <tt>b</tt> variables by the equalities involving the 00043 * first <tt>a</tt> integer existential variables. 00044 */ 00045 void Equalities_validityLattice(Matrix * Eqs, int a, Matrix** vl); 00046 00047 /** 00048 * Given an integer matrix B with m rows and integer m-vectors C and d, 00049 * computes the basis of the integer solutions to (BN+C) mod d = 0 (1). 00050 * This is an affine lattice (G): (N 1)^T= G(N' 1)^T, forall N' in Z^b. 00051 * If there is no solution, returns NULL. 00052 */ 00053 void Equalities_intModBasis(Matrix * B, Matrix * C, Matrix * d, Matrix ** imb); 00054 00055 00056 /* ----- functions applying on constraints ----- */ 00057 00058 00059 /** 00060 * Eliminates all the equalities in a set of constraints and returns the set of 00061 * constraints defining a full-dimensional polyhedron, such that there is a 00062 * bijection between integer points of the original polyhedron and these of the 00063 * resulting (projected) polyhedron). 00064 */ 00065 void Constraints_fullDimensionize(Matrix ** M, Matrix ** C, Matrix ** VL, 00066 Matrix ** Eqs, Matrix ** ParmEqs, 00067 unsigned int ** elimVars, 00068 unsigned int ** elimParms, 00069 int maxRays); 00070 00071 /* extracts equalities involving only parameters */ 00072 #define Constraints_removeParmEqs(a,b,c,d) Constraints_Remove_parm_eqs(a,b,c,d) 00073 Matrix * Constraints_Remove_parm_eqs(Matrix ** M, Matrix ** Ctxt, 00074 int renderSpace, 00075 unsigned int ** elimParms); 00076 00077 /** 00078 * Eliminates the columns corresponding to a list of eliminated parameters. 00079 */ 00080 void Constraints_removeElimCols(Matrix * M, unsigned int nbVars, 00081 unsigned int *elimParms, Matrix ** newM); 00082 00083 00084 /* ----- function applying on a lattice ----- */ 00085 00086 /** 00087 * Given a matrix that defines a full-dimensional affine lattice, returns the 00088 * affine sub-lattice spanned in the k first dimensions. 00089 * Useful for instance when you only look for the parameters' validity lattice. 00090 */ 00091 void Lattice_extractSubLattice(Matrix * lat, unsigned int k, Matrix ** subLat); 00092 00093 00094 /* ----- functions applying on a polyhedron ----- */ 00095 00096 00097 Polyhedron * Polyhedron_Remove_parm_eqs(Polyhedron ** P, Polyhedron ** C, 00098 int renderSpace, 00099 unsigned int ** elimParms, 00100 int maxRays); 00101 #define Polyhedron_removeParmEqs(a,b,c,d,e) Polyhedron_Remove_parm_eqs(a,b,c,d,e) 00102 00103 00104 /* ----- functions kept for backwards compatibility ----- */ 00105 00106 00107 /** 00108 * given a full-row-rank nxm matrix M(made of row-vectors), 00109 * computes the basis K (made of n-m column-vectors) of the integer kernel of M 00110 * so we have: M.K = 0 00111 */ 00112 Matrix * int_ker(Matrix * M); 00113 00114 /* given a matrix of m parameterized equations, compress the parameters and 00115 transform the variable space into a n-m space. */ 00116 Matrix * full_dimensionize(Matrix const * M, int nb_parms, 00117 Matrix ** Validity_Lattice); 00118 00119 /* Compute the overall period of the variables I for (MI) mod |d|, 00120 where M is a matrix and |d| a vector 00121 Produce a diagonal matrix S = (s_k) where s_k is the overall period of i_k */ 00122 Matrix * affine_periods(Matrix * M, Matrix * d); 00123 00124 /* given a matrix B' with m rows and m-vectors C' and d, computes the 00125 basis of the integer solutions to (B'N+C') mod d = 0. 00126 returns NULL if there is no integer solution */ 00127 Matrix * int_mod_basis(Matrix * Bp, Matrix * Cp, Matrix * d); 00128 00129 /* given a parameterized constraints matrix with m equalities, computes the 00130 compression matrix C such that there is an integer solution in the variables 00131 space for each value of N', with N = Cmp N' (N are the original parameters) */ 00132 Matrix * compress_parms(Matrix * E, int nb_parms); 00133 00134 00135 #endif /* __BM_COMPRESS_PARMS_H__ */