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