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 * Permutations on matrices 00020 * Matrices are seen either as transformations (mtransformation) or as 00021 * polyhedra (mpolyhedron or Constraints). 00022 * @author B. Meister 00023 */ 00024 00025 #ifndef __BM_MATRIX_PERMUTATIONS_H__ 00026 #define __BM_MATRIX_PERMUTATIONS_H__ 00027 00028 #include<polylib/polylib.h> 00029 #include<assert.h> 00030 00031 /* Permutations here are vectors that give the future position for each 00032 variable */ 00033 00034 /* utility function : bit count */ 00035 unsigned int nb_bits(unsigned long long int x); 00036 00037 /* gives the inverse permutation vector of a permutation vector */ 00038 unsigned int * permutation_inverse(unsigned int * perm, unsigned int nb_elems); 00039 00040 /* 00041 * Given a linear tranformation on initial variables, and a variable 00042 * permutation, compute the tranformation for the permuted variables. perm is 00043 * a vector giving the new "position of the k^th variable, k \in [1..n] we can 00044 * call it a "permutation vector" if you wish transf[x][y] -> 00045 * permuted[permutation(x)][permutation(y)] 00046 */ 00047 Matrix * mtransformation_permute(Matrix * transf, unsigned int * permutation); 00048 00049 /* permutes the variables of a matrix seen as a polyhedron */ 00050 Matrix * mpolyhedron_permute(Matrix * polyh, unsigned int * permutation); 00051 00052 /* permutes the variables of a matrix seen as a polyhedron */ 00053 void Constraints_permute(Matrix * C, unsigned int * perm, Matrix ** Cp); 00054 00055 /** Given a set of <i>equalities</i>, find a set of variables that can be 00056 * eliminated using these equalities. The variables that we agree to eliminate 00057 * are in a zone of contiguous variables (or parameters). <p> 00058 * Notes: 00059 <ul> 00060 <li>brute force, surely enhanceable algorithm</li> 00061 <li>limited number of variables in the zone: limit = bitwidth of long long 00062 </ul> 00063 * @param Eqs the matrix of equalities. 00064 * @param start the rank of the first variable (inclusive) of the zone in Eqs 00065 * @param end the rank of the last variable (inclusive) of the zone 00066 * return a bitfield where bits set to one define the variables to eliminate 00067 */ 00068 unsigned long long int eliminable_vars(Matrix * Eqs, unsigned start, 00069 unsigned end); 00070 00071 /* 00072 * find a valid permutation : for a set of m equations, find m variables that 00073 * will be put at the beginning (to be eliminated) it must be possible to 00074 * eliminate these variables : the submatrix built with their columns must be 00075 * full-rank. brute force method, that tests all the combinations until finding 00076 * one which works. 00077 * <b>LIMITATIONS</b> : up to x-1 variables, where the long long 00078 * format is x-1 bits (often 64 in year 2005). 00079 */ 00080 unsigned int * find_a_permutation(Matrix * Eqs, unsigned int nb_parms); 00081 00082 /* 00083 * compute the permutation of variables and parameters, according to some 00084 * variables to keep. put the variables not to be kept at the beginning, then 00085 * the parameters and finally the variables to be kept. strongly related to the 00086 * function compress_to_full_dim2 00087 */ 00088 unsigned int * permutation_for_full_dim2(unsigned int * vars_to_keep, 00089 unsigned int nb_keep, 00090 unsigned int nb_vars_parms, 00091 unsigned int nb_parms); 00092 00093 #endif /*__BM_MATRIX_PERMUTATIONS_H__ */