polylib 5.22.8
matrix_addon.h File Reference
#include <assert.h>
#include <polylib/polylib.h>

Go to the source code of this file.

Macros

#define show_matrix(M)
 Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set of constraints). More...
 
#define ensureMatrix(M, r, c)
 Allocates a matrix if it is null, or else asserts that it has at least a certain size. More...
 
#define Constraints_compressLastVars(a, b)   mpolyhedron_compress_last_vars(a, b)
 
#define Constraints_eliminateFirstVars(a, b)    mpolyhedron_eliminate_first_variables(a, b)
 

Functions

MatrixconstraintsView (Polyhedron *P)
 Creates a view of the constraints of a polyhedron as a Matrix *. More...
 
void constraintsView_Free (Matrix *M)
 "Frees" a view of the constraints of a polyhedron More...
 
void split_constraints (Matrix const *M, Matrix **Eqs, Matrix **Ineqs)
 splits a matrix of constraints M into a matrix of equalities Eqs and a matrix of inequalities Ineqs allocs the new matrices. More...
 
MatrixIdentity_Matrix (unsigned int dim)
 
void Matrix_identity (unsigned int dim, Matrix **I)
 returns the dim-dimensional identity matrix. More...
 
void mtransformation_inverse (Matrix *transf, Matrix **inv, Value *g)
 given a n x n integer transformation matrix transf, compute its inverse M/g, where M is a nxn integer matrix. More...
 
void mpolyhedron_simplify (Matrix *polyh)
 simplify a matrix seen as a polyhedron, by dividing its rows by the gcd of their elements. More...
 
void mpolyhedron_inflate (Matrix *polyh, unsigned int nb_parms)
 inflates a polyhedron (represented as a matrix) P, so that the apx of its Ehrhart Polynomial is an upper bound of the Ehrhart polynomial of P WARNING: this inflation is supposed to be applied on full-dimensional polyhedra. More...
 
void mpolyhedron_deflate (Matrix *polyh, unsigned int nb_parms)
 deflates a polyhedron (represented as a matrix) P, so that the apx of its Ehrhart Polynomial is a lower bound of the Ehrhart polynomial of P WARNING: this deflation is supposed to be applied on full-dimensional polyhedra. More...
 
void eliminate_var_with_constr (Matrix *Eliminator, unsigned int eliminator_row, Matrix *Victim, unsigned int victim_row, unsigned int var_to_elim)
 use an eliminator row to eliminate a variable in a victim row (without changing the sign of the victim row -> important if it is an inequality). More...
 
void mpolyhedron_compress_last_vars (Matrix *M, Matrix *compression)
 compress the last vars/pars of the polyhedron M expressed as a polylib matrix More...
 
unsigned int mpolyhedron_eliminate_first_variables (Matrix *Eqs, Matrix *Ineqs)
 use a set of m equalities Eqs to eliminate m variables in the polyhedron Ineqs represented as a matrix eliminates the m first variables More...
 
void Matrix_subMatrix (Matrix *M, unsigned int sr, unsigned int sc, unsigned int nbR, unsigned int nbC, Matrix **sub)
 returns a contiguous submatrix of a matrix. More...
 
void Matrix_clone (Matrix *M, Matrix **Cl)
 Cloning function. More...
 
void Matrix_copySubMatrix (Matrix *M1, unsigned int sr1, unsigned int sc1, unsigned int nbR, unsigned int nbC, Matrix *M2, unsigned int sr2, unsigned int sc2)
 Copies a contiguous submatrix of M1 into M2, at the indicated position. More...
 
void Matrix_oppose (Matrix *M)
 given a matrix M into -M More...
 

Macro Definition Documentation

◆ Constraints_compressLastVars

#define Constraints_compressLastVars (   a,
 
)    mpolyhedron_compress_last_vars(a, b)

Definition at line 83 of file matrix_addon.h.

◆ Constraints_eliminateFirstVars

#define Constraints_eliminateFirstVars (   a,
 
)     mpolyhedron_eliminate_first_variables(a, b)

Definition at line 90 of file matrix_addon.h.

◆ ensureMatrix

#define ensureMatrix (   M,
  r,
 
)
Value:
{ \
if (M == NULL) \
M = Matrix_Alloc(r, c); \
assert(M->NbRows >= r && M->NbColumns >= c); \
}
#define assert(ex)
Definition: assert.h:16
Matrix * Matrix_Alloc(unsigned NbRows, unsigned NbColumns)
Definition: matrix.c:24

Allocates a matrix if it is null, or else asserts that it has at least a certain size.

Definition at line 28 of file matrix_addon.h.

◆ show_matrix

#define show_matrix (   M)
Value:
{ \
printf(#M "= \n"); \
if (M != NULL) { \
Matrix_Print(stderr, P_VALUE_FMT, (M)); \
} else { \
printf("<NULL>\n"); \
} \
}
#define P_VALUE_FMT
Definition: types.h:39

Polylib matrix addons Mainly, deals with polyhedra represented in implicit form (set of constraints).

Author
Benoit Meister Shortcut for Matrix_Print

Definition at line 15 of file matrix_addon.h.

Function Documentation

◆ constraintsView()

Matrix * constraintsView ( Polyhedron P)

Creates a view of the constraints of a polyhedron as a Matrix *.

Id
matrix_addon.c,v 1.17 2007/03/18 18:49:08 skimo Exp

Polylib matrix addons Mainly, deals with polyhedra represented as a matrix (implicit form)

Author
Benoit Meister meist.nosp@m.er@i.nosp@m.cps.u.nosp@m.-str.nosp@m.asbg..nosp@m.fr

Definition at line 15 of file matrix_addon.c.

References polyhedron::Constraint, polyhedron::Dimension, matrix::NbColumns, polyhedron::NbConstraints, matrix::NbRows, and matrix::p.

◆ constraintsView_Free()

void constraintsView_Free ( Matrix M)

"Frees" a view of the constraints of a polyhedron

Definition at line 24 of file matrix_addon.c.

◆ eliminate_var_with_constr()

void eliminate_var_with_constr ( Matrix Eliminator,
unsigned int  eliminator_row,
Matrix Victim,
unsigned int  victim_row,
unsigned int  var_to_elim 
)

use an eliminator row to eliminate a variable in a victim row (without changing the sign of the victim row -> important if it is an inequality).

Parameters
Eliminatorthe matrix containing the eliminator row
eliminator_rowthe index of the eliminator row in Eliminator
Victimthe matrix containing the row to be eliminated
victim_rowthe row to be eliminated in Victim
var_to_elimthe variable to be eliminated.

Definition at line 213 of file matrix_addon.c.

References matrix::NbColumns, matrix::p, value_addto, value_clear, value_division, value_init, value_lcm, value_multiply, value_notzero_p, value_oppose, and value_pos_p.

Referenced by Constraints_Remove_parm_eqs(), and mpolyhedron_eliminate_first_variables().

◆ Identity_Matrix()

Matrix * Identity_Matrix ( unsigned int  dim)

◆ Matrix_clone()

void Matrix_clone ( Matrix M,
Matrix **  Cl 
)

Cloning function.

Similar to Matrix_Copy() but allocates the target matrix if it is set to NULL.

Definition at line 345 of file matrix_addon.c.

References Matrix_subMatrix(), matrix::NbColumns, and matrix::NbRows.

Referenced by Constraints_removeElimCols().

◆ Matrix_copySubMatrix()

void Matrix_copySubMatrix ( Matrix M1,
unsigned int  sr1,
unsigned int  sc1,
unsigned int  nbR,
unsigned int  nbC,
Matrix M2,
unsigned int  sr2,
unsigned int  sc2 
)

Copies a contiguous submatrix of M1 into M2, at the indicated position.

M1 and M2 are assumed t be allocated already.

M1 and M2 are assumed t be allocated already.

Parameters
M1the source matrix
sr1the starting source row
sc1the starting source column
nbRthe number of rows
nbCthe number of columns
M2the target matrix
sr2the starting target row
sc2the starting target column

Definition at line 361 of file matrix_addon.c.

References matrix::p, and Vector_Copy().

Referenced by Equalities_intModBasis(), Equalities_validityLattice(), Lattice_extractSubLattice(), and linearInter().

◆ Matrix_identity()

void Matrix_identity ( unsigned int  dim,
Matrix **  I 
)

returns the dim-dimensional identity matrix.

If I is set to NULL, allocates it first. Else, assumes an existing, allocated Matrix.

Definition at line 77 of file matrix_addon.c.

References assert, Identity_Matrix(), and value_set_si.

Referenced by Constraints_fullDimensionize().

◆ Matrix_oppose()

void Matrix_oppose ( Matrix M)

given a matrix M into -M

given a matrix M into -M

Definition at line 373 of file matrix_addon.c.

References matrix::NbColumns, matrix::NbRows, matrix::p, and value_oppose.

Referenced by Equalities_integerSolution().

◆ Matrix_subMatrix()

void Matrix_subMatrix ( Matrix M,
unsigned int  sr,
unsigned int  sc,
unsigned int  er,
unsigned int  ec,
Matrix **  sub 
)

returns a contiguous submatrix of a matrix.

Parameters
Mthe input matrix
srthe index of the starting row
scthe index of the starting column
erthe index ofthe ending row (excluded)
ecthe ined of the ending colummn (excluded)
sub(returned), the submatrix. Allocated if set to NULL, assumed to be already allocated else.

Definition at line 325 of file matrix_addon.c.

References assert, Matrix_Alloc(), matrix::p, and Vector_Copy().

Referenced by Equalities_integerSolution(), Equalities_validityLattice(), int_ker(), Lattice_extractSubLattice(), linearInter(), and Matrix_clone().

◆ mpolyhedron_compress_last_vars()

void mpolyhedron_compress_last_vars ( Matrix M,
Matrix compression 
)

compress the last vars/pars of the polyhedron M expressed as a polylib matrix

  • adresses the full-rank compressions only
  • modfies M

Definition at line 261 of file matrix_addon.c.

References assert, Matrix_Alloc(), Matrix_Free(), matrix::NbColumns, matrix::NbRows, matrix::p, value_addmul, value_assign, and value_set_si.

Referenced by Ehrhart_Quick_Apx(), and full_dimensionize().

◆ mpolyhedron_deflate()

void mpolyhedron_deflate ( Matrix polyh,
unsigned int  nb_parms 
)

deflates a polyhedron (represented as a matrix) P, so that the apx of its Ehrhart Polynomial is a lower bound of the Ehrhart polynomial of P WARNING: this deflation is supposed to be applied on full-dimensional polyhedra.

Definition at line 186 of file matrix_addon.c.

References matrix::NbColumns, matrix::NbRows, matrix::p, value_addto, value_clear, value_init, value_pos_p, value_set_si, and value_subtract.

Referenced by main().

◆ mpolyhedron_eliminate_first_variables()

unsigned int mpolyhedron_eliminate_first_variables ( Matrix Eqs,
Matrix Ineqs 
)

use a set of m equalities Eqs to eliminate m variables in the polyhedron Ineqs represented as a matrix eliminates the m first variables

  • assumes that Eqs allow to eliminate the m equalities
  • modifies Eqs and Ineqs

Definition at line 288 of file matrix_addon.c.

References eliminate_var_with_constr(), matrix::NbRows, matrix::p, value_cmp_si, and value_set_si.

Referenced by full_dimensionize().

◆ mpolyhedron_inflate()

void mpolyhedron_inflate ( Matrix polyh,
unsigned int  nb_parms 
)

inflates a polyhedron (represented as a matrix) P, so that the apx of its Ehrhart Polynomial is an upper bound of the Ehrhart polynomial of P WARNING: this inflation is supposed to be applied on full-dimensional polyhedra.

Definition at line 164 of file matrix_addon.c.

References matrix::NbColumns, matrix::NbRows, matrix::p, value_addto, value_clear, value_init, value_neg_p, value_set_si, and value_subtract.

Referenced by main().

◆ mpolyhedron_simplify()

void mpolyhedron_simplify ( Matrix polyh)

simplify a matrix seen as a polyhedron, by dividing its rows by the gcd of their elements.

Definition at line 145 of file matrix_addon.c.

References matrix::NbColumns, matrix::NbRows, matrix::p, value_clear, value_init, value_print, Vector_AntiScale(), and Vector_Gcd().

◆ mtransformation_inverse()

void mtransformation_inverse ( Matrix transf,
Matrix **  inverse,
Value *  g 
)

given a n x n integer transformation matrix transf, compute its inverse M/g, where M is a nxn integer matrix.

g is a common denominator for elements of (transf^{-1})

Definition at line 98 of file matrix_addon.c.

References MatInverse(), Matrix_Alloc(), Matrix_Copy(), Matrix_Free(), matrix::NbColumns, matrix::NbRows, matrix::p, value_clear, value_division, value_init, value_lcm, value_multiply, and value_set_si.

◆ split_constraints()

void split_constraints ( Matrix const *  M,
Matrix **  Eqs,
Matrix **  Ineqs 
)

splits a matrix of constraints M into a matrix of equalities Eqs and a matrix of inequalities Ineqs allocs the new matrices.

Allocates Eqs and Ineqs.

Definition at line 31 of file matrix_addon.c.

References Matrix_Alloc(), matrix::NbColumns, matrix::NbRows, matrix::p, value_assign, and value_zero_p.

Referenced by Constraints_fullDimensionize(), and full_dimensionize().