00001 // Permutations on matrices 00002 // Matrices are seen either as transformations (mtransformation) or as polyhedra (mpolyhedron) 00003 // B. Meister 00004 00005 #ifndef __BM_MATRIX_PERMUTATIONS_H__ 00006 #define __BM_MATRIX_PERMUTATIONS_H__ 00007 00008 #include<polylib/polylib.h> 00009 #include<assert.h> 00010 00011 // Permutations here are vectors that give the future position for each variable 00012 00013 // utility function : bit count (i know, there are faster methods) 00014 unsigned int nb_bits(unsigned long long int x); 00015 00016 // gives the inverse permutation vector of a permutation vector 00017 unsigned int * permutation_inverse(unsigned int * perm, unsigned int nb_elems); 00018 00019 // Given a linear tranformation on initial variables, and a variable permutation, compute the tranformation for the permuted variables. 00020 // perm is a vector giving the new "position of the k^th variable, k \in [1..n] 00021 // we can call it a "permutation vector" if you wish 00022 // transf[x][y] -> permuted[permutation(x)][permutation(y)] 00023 Matrix * mtransformation_permute(Matrix * transf, unsigned int * permutation); 00024 00025 // permutes the variables of a matrix seen as a polyhedron 00026 Matrix * mpolyhedron_permute(Matrix * polyh, unsigned int * permutation); 00027 00028 // find a valid permutation : for a set of m equations, find m variables that will be put at the beginning (to be eliminated) 00029 // it must be possible to eliminate these variables : the submatrix built with their columns must be full-rank. 00030 // brute force method, that tests all the combinations until finding one which works. 00031 // LIMITATIONS : up to x-1 variables, where the long long format is x-1 bits (often 64 in year 2005). 00032 unsigned int * find_a_permutation(Matrix * Eqs, unsigned int nb_parms); 00033 00034 // compute the permutation of variables and parameters, according to some variables to keep. 00035 // put the variables not to be kept at the beginning, then the parameters and finally the variables to be kept. 00036 // strongly related to the function compress_to_full_dim2 00037 unsigned int * permutation_for_full_dim2(unsigned int * vars_to_keep, unsigned int nb_keep, unsigned int nb_vars_parms, unsigned int nb_parms); 00038 00039 #endif //__BM_MATRIX_PERMUTATIONS_H__