PIPS
matrice.h File Reference

Go to the source code of this file.

Macros

#define MATRICE_UNDEFINED   ((matrice) NULL)
 
#define MATRICE_NULLE   ((matrice) NULL)
 
#define matrice_new(n, m)   ((matrice) malloc(sizeof(Value)*((n*m)+1)))
 Allocation et desallocation d'une matrice. More...
 
#define matrice_free(m)   (free((char *) (m)))
 
#define ACCESS(matrix, column, i, j)   ((matrix)[(((j)-1)*(column))+(i)])
 Macros d'acces aux elements d'une matrice. More...
 
#define DENOMINATOR(matrix)   ((matrix)[0])
 int DENOMINATEUR(matrix): acces au denominateur global d'une matrice matrix La combinaison *(&()) est necessaire pour avoir des parentheses autour de matrix[0] et pour pouvoir simultanement utiliser cette macro comme lhs. More...
 
#define matrice_triangulaire_inferieure_p(a, n, m)    matrice_triangulaire_p(a,n,m,true)
 bool matrice_triangulaire_inferieure_p(matrice a, int n, int m): test de triangularite de la matrice a More...
 
#define matrice_triangulaire_superieure_p(a, n, m)    matrice_triangulaire_p(a,n,m,false)
 bool matrice_triangulaire_superieure_p(matrice a, int n, int m): test de triangularite de la matrice a More...
 
#define ACC_ELEM(matrix, column, i, j, level)    (matrix[((j)-1+(level))*(column) + (i) + (level)])
 FI: Corinne, peux-tu expliquer la raison d'etre de cette macro? More...
 
#define VALIDATION   0
 FI: Corinne, pourrais-tu nous eclairer sur la signification de ces constantes? More...
 
#define MATRIX   0
 FI #define NULL 0. More...
 

Typedefs

typedef Valuematrice
 Warning! Do not modify this file that is automatically generated! More...
 

Functions

void matrice_determinant (matrice, int, Value[])
 definition temporaire d'une vraie fonction pour dbx More...
 
void matrice_sous_determinant (matrice, int, int, int, Value[])
 
void matrice_hermite (Value *, int, int, Value *, Value *, Value *, Value *, Value *)
 hermite.c More...
 
int matrice_hermite_rank (matrice, int, int)
 
int dim_H (matrice, int, int)
 Calcul de la dimension de la matrice de Hermite H. More...
 
void matrice_unimodulaire_triangulaire_inversion (matrice, matrice, int, bool)
 inversion.c More...
 
void matrice_diagonale_inversion (matrice, matrice, int)
 void matrice_diagonale_inversion(matrice s,matrice inv_s,int n) calcul de l'inversion du matrice en forme reduite smith. More...
 
void matrice_triangulaire_inversion (matrice, matrice, int, bool)
 void matrice_triangulaire_inversion(matrice h, matrice inv_h, int n,bool infer) calcul de l'inversion du matrice en forme triangulaire. More...
 
void matrice_general_inversion (matrice, matrice, int)
 void matrice_general_inversion(matrice a; matrice inv_a; int n) calcul de l'inversion du matrice general. More...
 
void matrice_unimodulaire_inversion (matrice, matrice, int)
 void matrice_unimodulaire_inversion(matrice u, matrice inv_u, int n) calcul de l'inversion de la matrice unimodulaire. More...
 
void matrice_transpose (matrice, matrice, int, int)
 matrice.c More...
 
void matrice_multiply (matrice, matrice, matrice, int, int, int)
 void matrice_multiply(matrice a, matrice b, matrice c, int p, int q, int r): multiply rational matrix a by rational matrix b and store result in matrix c More...
 
void matrice_normalize (matrice, int, int)
 void matrice_normalize(matrice a, int n, int m) More...
 
void matrice_normalizec (matrice, int, int)
 void matrice_normalizec(matrice MAT, int n, int m): Normalisation des coefficients de la matrice MAT, i.e. More...
 
void matrice_swap_columns (matrice, int, int, int, int)
 void matrice_swap_columns(matrice matrix, int n, int m, int c1, int c2): exchange columns c1,c2 of an (nxm) rational matrix More...
 
void matrice_swap_rows (matrice, int, int, int, int)
 void matrice_swap_rows(matrice a, int n, int m, int r1, int r2): exchange rows r1 and r2 of an (nxm) rational matrix a More...
 
void matrice_assign (matrice, matrice, int, int)
 void matrice_assign(matrice A, matrice B, int n, int m) Copie de la matrice A dans la matrice B More...
 
bool matrice_egalite (matrice, matrice, int, int)
 bool matrice_egalite(matrice A, matrice B, int n, int m) test de l'egalite de deux matrices A et B; elles doivent avoir ete normalisees au prealable pour que le test soit mathematiquement exact More...
 
void matrice_nulle (matrice, int, int)
 void matrice_nulle(matrice Z, int n, int m): Initialisation de la matrice Z a la valeur matrice nulle More...
 
bool matrice_nulle_p (matrice, int, int)
 bool matrice_nulle_p(matrice Z, int n, int m): test de nullite de la matrice Z More...
 
bool matrice_diagonale_p (matrice, int, int)
 bool matrice_diagonale_p(matrice Z, int n, int m): test de nullite de la matrice Z More...
 
bool matrice_triangulaire_p (matrice, int, int, bool)
 bool matrice_triangulaire_p(matrice Z, int n, int m, bool inferieure): test de triangularite de la matrice Z More...
 
bool matrice_triangulaire_unimodulaire_p (matrice, int, bool)
 bool matrice_triangulaire_unimodulaire_p(matrice Z, int n, bool inferieure) test de la triangulaire et unimodulaire de la matrice Z. More...
 
void matrice_substract (matrice, matrice, matrice, int, int)
 void matrice_substract(matrice a, matrice b, matrice c, int n, int m): substract rational matrix c from rational matrix b and store result in matrix a More...
 
void matrice_soustraction_colonne (matrice, int, int, int, int, Value)
 
void matrice_soustraction_ligne (matrice, int, int, int, int, Value)
 void matrice_soustraction_ligne(matrice MAT,int n,int m,int r1,int r2,int x): Soustrait x fois la ligne r2 de la ligne r1 Precondition: n > 0; m > 0; 0 < r1, r2 < n; Effet: r1[0..m-1] = r1[0..m-1] - x*r2[0..m-1] More...
 
void matrice_fprint (FILE *, matrice, int, int)
 matrice_io.c More...
 
void matrice_print (matrice, int, int)
 void matrice_print(matrice a, int n, int m): print an (nxm) rational matrix More...
 
void matrice_fscan (FILE *, matrice *, int *, int *)
 void matrice_fscan(FILE * f, matrice * a, int * n, int * m): read an (nxm) rational matrix in an ASCII file accessible via file descriptor f; a is allocated as a function of its number of columns and rows, n and m. More...
 
void matrice_smith (matrice, int, int, matrice, matrice, matrice)
 smith.c More...
 
int mat_lig_nnul (matrice, int, int, int)
 sous-matrice.c More...
 
void mat_perm_col (matrice, int, int, int, int)
 
void mat_perm_lig (matrice, int, int, int, int)
 
void mat_min (matrice, int, int, int *, int *, int)
 void mat_min(matrice MAT, int n, int m, int * i_min, int * j_min, int level): Recherche des coordonnees (*i_min, *j_min) de l'element de la sous-matrice MAT(level+1 ..n, level+1 ..m) dont la valeur absolue est la plus petite et non nulle. More...
 
void mat_maj_col (matrice, int, int, matrice, int)
 
void mat_maj_lig (matrice, int, int, matrice, int)
 void mat_maj_lig(matrice A, int n, int m, matrice Q, int level): Calcul de la matrice permettant de remplacer chaque terme de la premiere ligne autre que le premier terme A11=A(level+1,level+1) par le reste de sa division entiere par A11 More...
 
void matrice_identite (matrice, int, int)
 void matrice_identite(matrice ID, int n, int level) Construction d'une sous-matrice identite dans ID(level+1..n, level+1..n) More...
 
bool matrice_identite_p (matrice, int, int)
 bool matrice_identite_p(matrice ID, int n, int level) test d'une sous-matrice dans ID(level+1..n, level+1..n) pour savoir si c'est une matrice identite. More...
 
int mat_lig_el (matrice, int, int, int)
 int mat_lig_el(matrice MAT, int n, int m, int level) renvoie le numero de colonne absolu du premier element non nul de la sous-ligne MAT(level+1,level+2..m); renvoie 0 si la sous-ligne est vide. More...
 
int mat_col_el (matrice, int, int, int)
 
void mat_coeff_nnul (matrice, int, int, int *, int *, int)
 void mat_coeff_nnul(matrice MAT, int n, int m, int * lg_nnul, int * cl_nnul, int level) renvoie les coordonnees du plus petit element non-nul de la premiere sous-ligne non nulle 'lg_nnul' de la sous-matrice MAT(level+1..n, level+1..m) More...
 

Macro Definition Documentation

◆ ACC_ELEM

#define ACC_ELEM (   matrix,
  column,
  i,
  j,
  level 
)     (matrix[((j)-1+(level))*(column) + (i) + (level)])

FI: Corinne, peux-tu expliquer la raison d'etre de cette macro?

d'apres ce que je comprends de la suite, ca permet de definir des sous-matrices dont le coin superieur droit (i.e. le premier element) se trouve sur la diagonal?

Definition at line 120 of file matrice.h.

◆ ACCESS

#define ACCESS (   matrix,
  column,
  i,
 
)    ((matrix)[(((j)-1)*(column))+(i)])

Macros d'acces aux elements d'une matrice.

int ACCESS(int * matrix, int column, int i, int j): acces a l'element (i,j) de la matrice matrix, dont la taille des colonnes, i.e. le nombre de lignes, est column.

Definition at line 94 of file matrice.h.

◆ DENOMINATOR

#define DENOMINATOR (   matrix)    ((matrix)[0])

int DENOMINATEUR(matrix): acces au denominateur global d'une matrice matrix La combinaison *(&()) est necessaire pour avoir des parentheses autour de matrix[0] et pour pouvoir simultanement utiliser cette macro comme lhs.

#define DENOMINATOR(matrix) *(&((matrix)[0]))

Definition at line 101 of file matrice.h.

◆ matrice_free

#define matrice_free (   m)    (free((char *) (m)))

Definition at line 86 of file matrice.h.

◆ matrice_new

#define matrice_new (   n,
 
)    ((matrice) malloc(sizeof(Value)*((n*m)+1)))

Allocation et desallocation d'une matrice.

Definition at line 85 of file matrice.h.

◆ MATRICE_NULLE

#define MATRICE_NULLE   ((matrice) NULL)

Definition at line 82 of file matrice.h.

◆ matrice_triangulaire_inferieure_p

#define matrice_triangulaire_inferieure_p (   a,
  n,
 
)     matrice_triangulaire_p(a,n,m,true)

bool matrice_triangulaire_inferieure_p(matrice a, int n, int m): test de triangularite de la matrice a

Definition at line 106 of file matrice.h.

◆ matrice_triangulaire_superieure_p

#define matrice_triangulaire_superieure_p (   a,
  n,
 
)     matrice_triangulaire_p(a,n,m,false)

bool matrice_triangulaire_superieure_p(matrice a, int n, int m): test de triangularite de la matrice a

Definition at line 112 of file matrice.h.

◆ MATRICE_UNDEFINED

#define MATRICE_UNDEFINED   ((matrice) NULL)

Definition at line 81 of file matrice.h.

◆ MATRIX

#define MATRIX   0

FI #define NULL 0.

Definition at line 128 of file matrice.h.

◆ VALIDATION

#define VALIDATION   0

FI: Corinne, pourrais-tu nous eclairer sur la signification de ces constantes?

Definition at line 126 of file matrice.h.

Typedef Documentation

◆ matrice

typedef Value* matrice

Warning! Do not modify this file that is automatically generated!

Modify src/Libs/matrice/matrice-local.h instead, to add your own modifications. header file built by cproto matrice-local.h package matrice

Neil Butler, Corinne Ancourt, Francois Irigoin, Yi-qing Yang Les matrices sont des matrices pleines, a coefficients rationnels.

Les matrices sont representes par des tableaux d'entiers mono-dimensionnels dont l'element 0 represente le denominateur global. Elles sont stockees par colonne ("column-major"), comme en Fortran. Les indices commencent a 1, toujours comme en Fortran et non comme en C. Les deux dimensions sont implicites et doivent etre passees en parametre avec la matrice dans les appels de procedures.

Le denominateur doit etre strictement positif, i.e. plus grand ou egal a un. Un denominateur nul n'aurait pas de sens. Un denominateur negatif doublerait le nombre de representations possibles d'une matrice.

Les matrices renvoyees par certaines routines, comme matrice_multiply(), ne sont pas normalisees par le pgcd des coefficients et du denominateur pour des raisons d'efficacite. Mais les routines de test, comme matrice_identite_p(), supposent leurs arguments normalises.

Il faudrait sans doute introduire deux niveaux de procedure, un niveau externe sur garantissant la normalisation, et un niveau interne efficace sans normalisation automatique.

La bibliotheque utilise une notion de sous-matrice, definie systematiquement par un parametre appele "level". Seuls les elements dont les indices de lignes et de colonnes sont superieurs a level+1 (ou level? FI->CA) sont pris en consideration. Il s'agit donc de sous-matrice dont le premier element se trouve sur la diagonale de la matrice complete et dont le dernier element et le dernier element de la matrice complete.

Note: en cas detection d'incoherence, Neil Butler renvoyait un code d'erreur particulier; Francois Irigoin a supprime ces codes de retour et a traite les exceptions par des appels a assert(), et indirectement a abort()

Definition at line 79 of file matrice.h.

Function Documentation

◆ dim_H()

int dim_H ( matrice  H,
int  n,
int  m 
)

Calcul de la dimension de la matrice de Hermite H.

La matrice de Hermite est une matrice tres particuliere, pour laquelle il est tres facile de calculer sa dimension. Elle est egale au nombre de colonnes non nulles de la matrice.

Definition at line 197 of file hermite.c.

200 {
201 
202 
203  int i,j;
204  bool trouve_j = false;
205  int res=0;
206 
207  for (j = 1; j<=m && !trouve_j;j++) {
208  for (i=1; i<= n && value_zero_p(ACCESS(H,n,i,j)); i++);
209  if (i>n) {
210  trouve_j = true;
211  res= j-1;
212  }
213  }
214 
215 
216  if (!trouve_j && m>=1) res = m;
217  return (res);
218 
219 }
#define value_zero_p(val)
#define ACCESS(matrix, column, i, j)
Macros d'acces aux elements d'une matrice.
Definition: matrice-local.h:86

References ACCESS, and value_zero_p.

Referenced by prototype_dimension(), and sc_image_computation().

+ Here is the caller graph for this function:

◆ mat_coeff_nnul()

void mat_coeff_nnul ( matrice  MAT,
int  n,
int  m,
int lg_nnul,
int cl_nnul,
int  level 
)

void mat_coeff_nnul(matrice MAT, int n, int m, int * lg_nnul, int * cl_nnul, int level) renvoie les coordonnees du plus petit element non-nul de la premiere sous-ligne non nulle 'lg_nnul' de la sous-matrice MAT(level+1..n, level+1..m)

recherche de la premiere ligne non nulle de la sous-matrice MAT(level+1 .. n,level+1 .. m)

recherche du plus petit (en valeur absolue) element non nul de cette ligne

Parameters
MATAT
lg_nnulg_nnul
cl_nnull_nnul
levelevel

Definition at line 426 of file sous-matrice.c.

431 {
432  bool trouve = false;
433  int j;
434  register Value min=VALUE_ZERO,val;
435 
436  *lg_nnul = 0;
437  *cl_nnul = 0;
438 
439  /* recherche de la premiere ligne non nulle de la
440  sous-matrice MAT(level+1 .. n,level+1 .. m) */
441 
442  *lg_nnul= mat_lig_nnul(MAT,n,m,level);
443 
444  /* recherche du plus petit (en valeur absolue)
445  * element non nul de cette ligne */
446  if (*lg_nnul) {
447  for (j=1+level;j<=m && !trouve; j++) {
448  min = ACCESS(MAT,n,*lg_nnul,j);
450  if (value_notzero_p(min)) {
451  trouve = true;
452  *cl_nnul=j;
453  }
454  }
455  for (j=1+level;j<=m && value_gt(min,VALUE_ONE); j++) {
456  val = ACCESS(MAT,n,*lg_nnul,j);
457  value_absolute(val);
458  if (value_notzero_p(val) && value_lt(val,min)) {
459  min = val;
460  *cl_nnul =j;
461  }
462  }
463  }
464 }
#define VALUE_ZERO
#define value_absolute(ref)
#define value_gt(v1, v2)
#define value_notzero_p(val)
int Value
#define VALUE_ONE
#define value_lt(v1, v2)
#define min(a, b)
#define level
int mat_lig_nnul(matrice MAT, int n, int m, int level)
int mat_lig_nnul(matrice MAT, int n, int m, int level): Recherche de la premiere ligne non nulle de l...
Definition: sous-matrice.c:65

References ACCESS, level, mat_lig_nnul(), min, value_absolute, value_gt, value_lt, value_notzero_p, VALUE_ONE, and VALUE_ZERO.

Referenced by matrice_hermite().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mat_col_el()

int mat_col_el ( matrice  ,
int  ,
int  ,
int   
)

Referenced by matrice_smith().

+ Here is the caller graph for this function:

◆ mat_lig_el()

int mat_lig_el ( matrice  MAT,
int  n,
int  m,
int  level 
)

int mat_lig_el(matrice MAT, int n, int m, int level) renvoie le numero de colonne absolu du premier element non nul de la sous-ligne MAT(level+1,level+2..m); renvoie 0 si la sous-ligne est vide.

RGUSED

recherche du premier element non nul de la sous-ligne MAT(level+1,level+2..m)

Parameters
MATAT
levelevel

Definition at line 381 of file sous-matrice.c.

385 {
386  int j;
387  int j_min = 0;
388 
389  /* recherche du premier element non nul de la sous-ligne
390  MAT(level+1,level+2..m) */
391  for(j = level+2; j<=m && value_zero_p(ACCESS(MAT,n,1+level,j)) ; j++);
392  if(j < m+1)
393  j_min = j-1;
394  return (j_min);
395 }

References ACCESS, level, and value_zero_p.

Referenced by matrice_hermite(), and matrice_smith().

+ Here is the caller graph for this function:

◆ mat_lig_nnul()

int mat_lig_nnul ( matrice  MAT,
int  n,
int  m,
int  level 
)

sous-matrice.c

sous-matrice.c

resultat retourne par la fonction :

int : numero de la premiere ligne non nulle de la matrice MAT; ou 0 si la sous-matrice MAT(level+1 ..n,level+1 ..m) est identiquement nulle;

parametres de la fonction :

int MAT[] : matrice int n : nombre de lignes de la matrice int m : nombre de colonnes de la matrice int level : niveau de la matrice i.e. numero de la premiere ligne et de la premiere colonne a partir duquel on commence a prendre en compte les elements de la matrice

recherche du premier element non nul de la sous-matrice

on dumpe la colonne J...

Parameters
MATAT
levelevel

Definition at line 65 of file sous-matrice.c.

69 {
70  int i,j;
71  int I = 0;
72  bool trouve = false;
73 
74  /* recherche du premier element non nul de la sous-matrice */
75  for (i = level+1; i<=n && !trouve ; i++) {
76  for (j = level+1; j<= m && value_zero_p(ACCESS(MAT,n,i,j)); j++);
77  if(j <= m) {
78  /* on dumpe la colonne J... */
79  trouve = true;
80  I = i;
81  }
82  }
83  return (I);
84 }

References ACCESS, level, and value_zero_p.

Referenced by mat_coeff_nnul().

+ Here is the caller graph for this function:

◆ mat_maj_col()

void mat_maj_col ( matrice  ,
int  ,
int  ,
matrice  ,
int   
)

◆ mat_maj_lig()

void mat_maj_lig ( matrice  A,
int  n,
int  m,
matrice  Q,
int  level 
)

void mat_maj_lig(matrice A, int n, int m, matrice Q, int level): Calcul de la matrice permettant de remplacer chaque terme de la premiere ligne autre que le premier terme A11=A(level+1,level+1) par le reste de sa division entiere par A11

La matrice Q est modifiee.

Les parametres de la fonction :

int A[] : matrice int n : nombre de lignes de la matrice int m : nombre de colonnes de la matrice !int Q[] : matrice int level : niveau de la matrice i.e. numero de la premiere ligne et de la premiere colonne a partir duquel on commence a prendre en compte les elements de la matrice

Parameters
levelevel

Definition at line 292 of file sous-matrice.c.

297 {
298  register Value A11;
299  int j;
300  register Value x;
301 
302  matrice_identite(Q,m,0);
303  A11 = ACC_ELEM(A,n,1,1,level);
304  for (j=2+level; j<=m; j++) {
305  x = ACCESS(A,n,1+level,j);
306  value_division(x,A11);
307  ACCESS(Q,m,1+level,j) = value_uminus(x);
308  }
309 }
#define value_uminus(val)
unary operators on values
#define value_division(ref, val)
#define ACC_ELEM(matrix, column, i, j, level)
FI: Corinne, peux-tu expliquer la raison d'etre de cette macro?
#define Q
Definition: pip__type.h:39
void matrice_identite(matrice ID, int n, int level)
void matrice_identite(matrice ID, int n, int level) Construction d'une sous-matrice identite dans ID(...
Definition: sous-matrice.c:322
static char * x
Definition: split_file.c:159
Definition: pip__tab.h:25

References ACC_ELEM, ACCESS, level, matrice_identite(), Q, value_division, value_uminus, and x.

+ Here is the call graph for this function:

◆ mat_min()

void mat_min ( matrice  MAT,
int  n,
int  m,
int i_min,
int j_min,
int  level 
)

void mat_min(matrice MAT, int n, int m, int * i_min, int * j_min, int level): Recherche des coordonnees (*i_min, *j_min) de l'element de la sous-matrice MAT(level+1 ..n, level+1 ..m) dont la valeur absolue est la plus petite et non nulle.

QQ i dans [level+1 ..n] QQ j dans [level+1 ..m] | MAT[*i_min, *j_min] | <= | MAT[i, j]

resultat retourne par la fonction :

les parametres i_min et j_min sont modifies.

parametres de la fonction :

int MAT[] : matrice int n : nombre de lignes de la matrice int m : nombre de colonnes de la matrice !int i_min : numero de la ligne a laquelle se trouve le plus petit element !int j_min : numero de la colonne a laquelle se trouve le plus petit int level : niveau de la matrice i.e. numero de la premiere ligne et de la premiere colonne a partir duquel on commence a prendre en compte les elements de la matrice element

initialisation du minimum car recherche d'un minimum non nul

Parameters
MATAT
i_min_min
j_min_min
levelevel

Definition at line 193 of file sous-matrice.c.

198 {
199  int i,j;
200  int vali= 0;
201  int valj=0;
202  register Value min=VALUE_ZERO, val;
203  bool trouve = false;
204 
205 
206  /* initialisation du minimum car recherche d'un minimum non nul*/
207  for (i=1+level;i<=n && !trouve;i++)
208  for(j = level+1; j <= m && !trouve; j++) {
209  min = ACCESS(MAT,n,i,j);
211  if(min != 0) {
212  trouve = true;
213  vali = i;
214  valj = j;
215  }
216  }
217 
218  for (i=1+level;i<=n;i++)
219  for (j=1+level;j<=m && value_gt(min,VALUE_ONE); j++) {
220  val = ACCESS(MAT,n,i,j);
221  value_absolute(val);
222  if (value_notzero_p(val) && value_lt(val,min)) {
223  min = val;
224  vali= i;
225  valj =j;
226  }
227  }
228  *i_min = vali;
229  *j_min = valj;
230 }

References ACCESS, level, min, value_absolute, value_gt, value_lt, value_notzero_p, VALUE_ONE, and VALUE_ZERO.

Referenced by matrice_smith().

+ Here is the caller graph for this function:

◆ mat_perm_col()

void mat_perm_col ( matrice  ,
int  ,
int  ,
int  ,
int   
)

◆ mat_perm_lig()

void mat_perm_lig ( matrice  ,
int  ,
int  ,
int  ,
int   
)

◆ matrice_assign()

void matrice_assign ( matrice  A,
matrice  B,
int  n,
int  m 
)

void matrice_assign(matrice A, matrice B, int n, int m) Copie de la matrice A dans la matrice B

Les parametres de la fonction :

int A[] : matrice !int B[] : matrice int n : nombre de lignes de la matrice int m : nombre de colonnes de la matrice

Ancien nom: mat_dup

Definition at line 264 of file matrice.c.

267 {
268  int i, size=n*m;
269  for (i = 0 ;i<=size;i++)
270  B[i] = A[i];
271 }
#define B(A)
Definition: iabrev.h:61

References B.

Referenced by matrice_hermite(), and matrice_smith().

+ Here is the caller graph for this function:

◆ matrice_determinant()

void matrice_determinant ( matrice  ,
int  ,
Value  [] 
)

definition temporaire d'une vraie fonction pour dbx

#define matrice_print(a,n,m) matrice_fprint(stdout,a,n,m) cproto-generated files determinant.c

◆ matrice_diagonale_inversion()

void matrice_diagonale_inversion ( matrice  s,
matrice  inv_s,
int  n 
)

void matrice_diagonale_inversion(matrice s,matrice inv_s,int n) calcul de l'inversion du matrice en forme reduite smith.

s est un matrice de la forme reduite smith, inv_s est l'inversion de s ; telles que s * inv_s = I.

les parametres de la fonction : matrice s : matrice en forme reduite smith – input int n : dimension de la matrice caree – input matrice inv_s : l'inversion de s – output

tests des preconditions

calcul de la ppcm(s[1,1],s[2,2],...s[n,n])

Parameters
inv_snv_s

Definition at line 95 of file inversion.c.

99 {
100  Value d, d1;
101  Value gcd, lcm;
102  int i;
103 
104  /* tests des preconditions */
105  assert(matrice_diagonale_p(s,n,n));
106  assert(matrice_hermite_rank(s,n,n)==n);
108 
109  matrice_nulle(inv_s,n,n);
110  /* calcul de la ppcm(s[1,1],s[2,2],...s[n,n]) */
111  lcm = ACCESS(s,n,1,1);
112  for (i=2; i<=n; i++)
113  lcm = ppcm(lcm,ACCESS(s,n,i,i));
114 
115  d = DENOMINATOR(s);
116  gcd = pgcd_slow(lcm,d);
117  d1 = value_div(d,gcd);
118  for (i=1; i<=n; i++) {
119  Value tmp = value_div(lcm,ACCESS(s,n,i,i));
120  ACCESS(inv_s,n,i,i) = value_mult(d1,tmp);
121  }
122  DENOMINATOR(inv_s) = value_div(lcm,gcd);
123 }
#define value_pos_p(val)
#define value_mult(v, w)
whether the default is protected or not this define makes no sense any more...
#define value_div(v1, v2)
Value ppcm(Value, Value)
ppcm.c
Definition: ppcm.c:42
Value pgcd_slow(Value, Value)
pgcd.c
Definition: pgcd.c:44
#define DENOMINATOR(matrix)
int DENOMINATEUR(matrix): acces au denominateur global d'une matrice matrix La combinaison *(&()) est...
Definition: matrice-local.h:93
int matrice_hermite_rank(matrice a, int n, int m __attribute__((unused)))
int matrice_hermite_rank(matrice a, int n, int m): rang d'une matrice en forme de hermite
Definition: hermite.c:178
bool matrice_diagonale_p(matrice Z, int n, int m)
bool matrice_diagonale_p(matrice Z, int n, int m): test de nullite de la matrice Z
Definition: matrice.c:362
void matrice_nulle(matrice Z, int n, int m)
void matrice_nulle(matrice Z, int n, int m): Initialisation de la matrice Z a la valeur matrice nulle
Definition: matrice.c:311
#define assert(ex)
Definition: newgen_assert.h:41

References ACCESS, assert, DENOMINATOR, matrice_diagonale_p(), matrice_hermite_rank(), matrice_nulle(), pgcd_slow(), ppcm(), value_div, value_mult, and value_pos_p.

+ Here is the call graph for this function:

◆ matrice_diagonale_p()

bool matrice_diagonale_p ( matrice  Z,
int  n,
int  m 
)

bool matrice_diagonale_p(matrice Z, int n, int m): test de nullite de la matrice Z

QQ i dans [1..n] QQ j dans [1..n] Z(i,j) == 0 && i != j || i == j

Les parametres de la fonction :

int Z[] : matrice int n : nombre de lignes de la matrice int m : nombre de colonnes de la matrice

Definition at line 362 of file matrice.c.

365 {
366  int i,j;
367 
368  for (i=1;i<=n;i++)
369  for (j=1;j<=m;j++)
370  if(i!=j && value_notzero_p(ACCESS(Z,n,i,j)))
371  return(false);
372  return(true);
373 }

References ACCESS, and value_notzero_p.

Referenced by matrice_diagonale_inversion().

+ Here is the caller graph for this function:

◆ matrice_egalite()

bool matrice_egalite ( matrice  A,
matrice  B,
int  n,
int  m 
)

bool matrice_egalite(matrice A, matrice B, int n, int m) test de l'egalite de deux matrices A et B; elles doivent avoir ete normalisees au prealable pour que le test soit mathematiquement exact

Les parametres de la fonction :

int A[] : matrice int B[] : matrice int n : nombre de lignes de la matrice int m : nombre de colonnes de la matrice

Definition at line 285 of file matrice.c.

288 {
289  int i;
290  for (i = 0 ;i<= n*m;i++)
291  if(value_ne(B[i],A[i]))
292  return(false);
293  return(true);
294 }
#define value_ne(v1, v2)

References B, and value_ne.

◆ matrice_fprint()

void matrice_fprint ( FILE *  f,
matrice  a,
int  n,
int  m 
)

matrice_io.c

matrice_io.c

Note: the output format is incompatible with matrice_fscan() row size

Parameters
mNote: the output format is incompatible with matrice_fscan() column size

Definition at line 62 of file matrice_io.c.

67 {
68  int loop1,loop2;
69 
71 
72  (void) fprintf(f,"\n\n");
73 
74  for(loop1=1; loop1<=n; loop1++) {
75  for(loop2=1; loop2<=m; loop2++)
76  pr_quot(f, ACCESS(a,n,loop1,loop2), DENOMINATOR(a));
77  (void) fprintf(f,"\n\n");
78  }
79  (void) fprintf(f," ......denominator = ");
81  fprintf(f, "\n");
82 }
void fprint_Value(FILE *, Value)
Definition: io.c:42
loop loop1
tiling_sequence.c
static void pr_quot(FILE *f, Value a, Value b __attribute__((unused)))
package matrice
Definition: matrice_io.c:47
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...

References ACCESS, assert, DENOMINATOR, f(), fprint_Value(), fprintf(), loop1, pr_quot(), and value_notzero_p.

Referenced by average_probability_matrix(), hyperplane(), interactive_partitioning_matrix(), local_tile_constraints(), make_tile_constraints(), matrice_print(), parallel_tiling(), partial_broadcast_coefficients(), prototype_dimension(), sc_image_computation(), tile_hyperplane_constraints(), tile_membership(), tile_membership_constraints(), tiling_transformation(), transformer_equality_fix_point(), and unstructured_to_complexity().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ matrice_fscan()

void matrice_fscan ( FILE *  f,
matrice a,
int n,
int m 
)

void matrice_fscan(FILE * f, matrice * a, int * n, int * m): read an (nxm) rational matrix in an ASCII file accessible via file descriptor f; a is allocated as a function of its number of columns and rows, n and m.

Format:

n m denominator a[1,1] a[1,2] ... a[1,m] a[2,1] ... a[2,m] ... a[n,m]

After the two dimensions and the global denominator, the matrix as usually displayed, line by line. Line feed can be used anywhere. Example for a (2x3) integer matrix: 2 3 1 1 2 3 4 5 6 row size

number of read elements

read dimensions

allocate a

read denominator

necessaires pour eviter les divisions par zero

pour "normaliser" un peu les representations

Parameters
mFormat:

n m denominator a[1,1] a[1,2] ... a[1,m] a[2,1] ... a[2,m] ... a[n,m]

After the two dimensions and the global denominator, the matrix as usually displayed, line by line. Line feed can be used anywhere. Example for a (2x3) integer matrix: 2 3 1 1 2 3 4 5 6 column size

Definition at line 115 of file matrice_io.c.

120 {
121  int r;
122  int c;
123 
124  /* number of read elements */
125  int n_read;
126 
127  /* read dimensions */
128  n_read = fscanf(f,"%d%d", n, m);
129  assert(n_read==2);
130  assert(1 <= *n && 1 <= *m);
131 
132  /* allocate a */
133  *a = matrice_new(*n,*m);
134 
135  /* read denominator */
136  n_read = fscan_Value(f,&(DENOMINATOR(*a)));
137  assert(n_read == 1);
138  /* necessaires pour eviter les divisions par zero */
140  /* pour "normaliser" un peu les representations */
142 
143  for(r = 1; r <= *n; r++)
144  for(c = 1; c <= *m; c++) {
145  n_read = fscan_Value(f,&ACCESS(*a,*n,r,c));
146  assert(n_read == 1);
147  }
148 }
int fscan_Value(FILE *, Value *)
Definition: io.c:58
#define matrice_new(n, m)
Allocation et desallocation d'une matrice.
Definition: matrice-local.h:77

References ACCESS, assert, DENOMINATOR, f(), fscan_Value(), matrice_new, value_notzero_p, and value_pos_p.

Referenced by unimodular().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ matrice_general_inversion()

void matrice_general_inversion ( matrice  a,
matrice  inv_a,
int  n 
)

void matrice_general_inversion(matrice a; matrice inv_a; int n) calcul de l'inversion du matrice general.

Algorithme : calcul P, Q, H telque : PAQ = H ; -1 -1 si rank(H) = n ; A = Q H P .

les parametres de la fonction : matrice a : matrice general -— input matrice inv_a : l'inversion de a -— output int n : dimensions de la matrice caree -— input

ne utilise pas

test

Parameters
inv_anv_a

Definition at line 222 of file inversion.c.

226 {
227  matrice p = matrice_new(n,n);
228  matrice q = matrice_new(n,n);
229  matrice h = matrice_new(n,n);
230  matrice inv_h = matrice_new(n,n);
231  matrice temp = matrice_new(n,n);
232  Value deno;
233  Value det_p, det_q; /* ne utilise pas */
234 
235  /* test */
237 
238  deno = DENOMINATOR(a);
239  DENOMINATOR(a) = VALUE_ONE;
240  matrice_hermite(a,n,n,p,h,q,&det_p,&det_q);
241  DENOMINATOR(a) = deno;
242  if ( matrice_hermite_rank(h,n,n) == n){
243  DENOMINATOR(h) = deno;
244  matrice_triangulaire_inversion(h,inv_h,n,true);
245  matrice_multiply(q,inv_h,temp,n,n,n);
246  matrice_multiply(temp,p,inv_a,n,n,n);
247  }
248  else{
249  printf(" L'inverse de la matrice a n'existe pas!\n");
250  exit(1);
251  }
252 }
Value * matrice
package matrice
Definition: matrice-local.h:71
void matrice_hermite(Value *MAT, int n, int m, Value *P, Value *H, Value *Q, Value *det_p, Value *det_q)
package matrice
Definition: hermite.c:78
void matrice_triangulaire_inversion(matrice h, matrice inv_h, int n, bool infer)
void matrice_triangulaire_inversion(matrice h, matrice inv_h, int n,bool infer) calcul de l'inversion...
Definition: inversion.c:140
void matrice_multiply(matrice a, matrice b, matrice c, int p, int q, int r)
void matrice_multiply(matrice a, matrice b, matrice c, int p, int q, int r): multiply rational matrix...
Definition: matrice.c:82
#define exit(code)
Definition: misc-local.h:54
int printf()

References assert, DENOMINATOR, exit, matrice_hermite(), matrice_hermite_rank(), matrice_multiply(), matrice_new, matrice_triangulaire_inversion(), printf(), VALUE_ONE, and value_pos_p.

Referenced by base_G_h1_unnull(), broadcast_conditions(), local_tile_constraints(), make_tile_constraints(), parallel_tiling(), system_inversion_restrict(), tile_membership(), tiling_transformation(), and unimodular().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ matrice_hermite()

void matrice_hermite ( Value MAT,
int  n,
int  m,
Value P,
Value H,
Value Q,
Value det_p,
Value det_q 
)

hermite.c

hermite.c

void matrice_hermite(matrice MAT, int n, int m, matrice P, matrice H, matrice Q, int *det_p, int *det_q): calcul de la forme reduite de Hermite H de la matrice MAT avec les deux matrices de changement de base unimodulaire P et Q, telles que H = P x MAT x Q et en le meme temp, produit les determinants des P et Q. det_p = |P|, det_q = |Q|.

(c.f. Programmation Lineaire. Theorie et algorithmes. tome 2. M.MINOUX. Dunod (1983)) FI: Quels est l'invariant de l'algorithme? MAT = P x H x Q? FI: Quelle est la norme decroissante? La condition d'arret?

Les parametres de la fonction :

int MAT[n,m]: matrice int n : nombre de lignes de la matrice int m : nombre de colonnes de la matrice int P[n,n] : matrice int H[n,m] : matrice reduite de Hermite int Q[m,m] : matrice int *det_p : determinant de P (nombre de permutation de ligne) int *det_q : determinant de Q (nombre de permutation de colonne)

Les 3 matrices P(nxn), Q(mxm) et H(nxm) doivent etre allouees avant le calcul.

Note: les denominateurs de MAT, P, A et H ne sont pas utilises.

Auteurs: Corinne Ancourt, Yi-qing Yang

Modifications:

  • modification du profil de la fonction pour permettre le calcul du determinant de MAT
  • permutation de colonnes directe, remplacant une permutation par produit de matrices
  • suppression des copies entre H, P, Q et NH, PN, QN

indice de la ligne et indice de la colonne correspondant au plus petit element de la sous-matrice traitee

niveau de la sous-matrice traitee

le plus petit element sur la diagonale

la rest de la division par ALL

if ((n>0) && (m>0) && MAT)

Initialisation des matrices

tant qu'il reste des termes non nuls dans la partie triangulaire superieure de la matrice H,
on cherche le plus petit element de la sous-matrice

la sous-matrice restante est nulle, on a terminee

s'il existe un plus petit element non nul dans la partie triangulaire superieure de la sous-matrice, on amene cet element en haut sur la diagonale. si cet element est deja sur la diagonale, et que tous les termes de la ligne correspondante sont nuls, on effectue les calculs sur la sous-matrice de rang superieur

Parameters
MATAT
det_pet_p
det_qet_q

Definition at line 78 of file hermite.c.

87 {
88  Value *PN=NULL;
89  Value *QN=NULL;
90  Value *HN = NULL;
91 
92  /* indice de la ligne et indice de la colonne correspondant
93  au plus petit element de la sous-matrice traitee */
94  int ind_n,ind_m;
95 
96  /* niveau de la sous-matrice traitee */
97  int level = 0;
98 
99  register Value ALL; /* le plus petit element sur la diagonale */
100  register Value x; /* la rest de la division par ALL */
101  bool stop = false;
102  int i;
103 
104  *det_p = VALUE_ONE;
105  *det_q = VALUE_ONE;
106 
107  /* if ((n>0) && (m>0) && MAT) */
108  assert((n > 0) && (m > 0));
110 
111  HN = matrice_new(n, m);
112  PN = matrice_new(n, n);
113  QN = matrice_new(m, m);
114 
115  /* Initialisation des matrices */
116 
117  matrice_assign(MAT,H,n,m);
118  matrice_identite(PN,n,0);
119  matrice_identite(QN,m,0);
120  matrice_identite(P,n,0);
121  matrice_identite(Q,m,0);
122  matrice_nulle(HN,n,m);
123 
124  while (!stop) {
125  /* tant qu'il reste des termes non nuls dans la partie
126  triangulaire superieure de la matrice H,
127  on cherche le plus petit element de la sous-matrice */
128  mat_coeff_nnul(H,n,m,&ind_n,&ind_m,level);
129 
130  if (ind_n == 0 && ind_m == 0)
131  /* la sous-matrice restante est nulle, on a terminee */
132  stop = true;
133  else {
134  /* s'il existe un plus petit element non nul dans la partie
135  triangulaire superieure de la sous-matrice,
136  on amene cet element en haut sur la diagonale.
137  si cet element est deja sur la diagonale, et que tous les
138  termes de la ligne correspondante sont nuls,
139  on effectue les calculs sur la sous-matrice de rang superieur*/
140 
141  if (ind_n > level + 1) {
142  matrice_swap_rows(H,n,m,level+1,ind_n);
143  matrice_swap_rows(PN,n,n,level+1,ind_n);
144  value_oppose(*det_p);
145  }
146 
147  if (ind_m > level+1) {
148  matrice_swap_columns(H,n,m,level+1,ind_m);
149  matrice_swap_columns(QN,m,m,level+1,ind_m);
150  value_oppose(*det_q);
151  }
152 
153  if(mat_lig_el(H,n,m,level) != 0) {
154  ALL = ACC_ELEM(H,n,1,1,level);
155  for (i=level+2; i<=m; i++) {
156  x = ACCESS(H,n,level+1,i);
160  }
161 
162  }
163  else level++;
164  }
165  }
166 
167  matrice_assign(PN,P,n,n);
168  matrice_assign(QN,Q,m,m);
169 
170  matrice_free(HN);
171  matrice_free(PN);
172  matrice_free(QN);
173 }
#define value_oppose(ref)
#define value_one_p(val)
#define matrice_free(m)
Definition: matrice-local.h:78
void matrice_soustraction_colonne(matrice MAT, int n, int m __attribute__((unused)), int c1, int c2, Value x)
void matrice_soustraction_colonne(matrice MAT,int n,int m,int c1,int c2,int x): Soustrait x fois la c...
Definition: matrice.c:523
void matrice_assign(matrice A, matrice B, int n, int m)
void matrice_assign(matrice A, matrice B, int n, int m) Copie de la matrice A dans la matrice B
Definition: matrice.c:264
void matrice_swap_rows(matrice a, int n, int m, int r1, int r2)
void matrice_swap_rows(matrice a, int n, int m, int r1, int r2): exchange rows r1 and r2 of an (nxm) ...
Definition: matrice.c:230
void matrice_swap_columns(matrice matrix, int n, int m, int c1, int c2)
void matrice_swap_columns(matrice matrix, int n, int m, int c1, int c2): exchange columns c1,...
Definition: matrice.c:200
int mat_lig_el(matrice, int, int, int)
int mat_lig_el(matrice MAT, int n, int m, int level) renvoie le numero de colonne absolu du premier e...
Definition: sous-matrice.c:381
void mat_coeff_nnul(matrice, int, int, int *, int *, int)
void mat_coeff_nnul(matrice MAT, int n, int m, int * lg_nnul, int * cl_nnul, int level) renvoie les c...
Definition: sous-matrice.c:426
void matrice_identite(matrice, int, int)
void matrice_identite(matrice ID, int n, int level) Construction d'une sous-matrice identite dans ID(...
Definition: sous-matrice.c:322
#define ALL
Definition: readmakefile.c:178

References ACC_ELEM, ACCESS, ALL, assert, DENOMINATOR, level, mat_coeff_nnul(), mat_lig_el(), matrice_assign(), matrice_free, matrice_identite(), matrice_new, matrice_nulle(), matrice_soustraction_colonne(), matrice_swap_columns(), matrice_swap_rows(), Q, value_division, VALUE_ONE, value_one_p, value_oppose, and x.

Referenced by broadcast_of_dataflow(), matrice_determinant(), matrice_general_inversion(), matrice_unimodulaire_inversion(), prototype_dimension(), sc_image_computation(), and vecteurs_libres_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ matrice_hermite_rank()

int matrice_hermite_rank ( matrice  ,
int  ,
int   
)

◆ matrice_identite()

void matrice_identite ( matrice  ID,
int  n,
int  level 
)

void matrice_identite(matrice ID, int n, int level) Construction d'une sous-matrice identite dans ID(level+1..n, level+1..n)

Les parametres de la fonction :

!int ID[] : matrice int n : nombre de lignes de la matrice int level : niveau de la matrice i.e. numero de la premiere ligne et de la premiere colonne a partir duquel on commence a prendre en compte les elements de la matrice

Parameters
IDD
levelevel

Definition at line 322 of file sous-matrice.c.

326 {
327  int i,j;
328 
329  for(i = level+1; i <= n; i++) {
330  for(j = level+1; j <= n; j++)
331  ACCESS(ID,n,i,j) = VALUE_ZERO;
332  ACCESS(ID,n,i,i) = VALUE_ONE;
333  }
334 
335  DENOMINATOR(ID) = VALUE_ONE;
336 }

References ACCESS, DENOMINATOR, level, VALUE_ONE, and VALUE_ZERO.

Referenced by check_tiling_legality(), local_tile_constraints(), mat_maj_col(), mat_maj_lig(), matrice_hermite(), matrice_smith(), matrice_unimodulaire_triangulaire_inversion(), sc_image_computation(), tile_hyperplane_constraints(), tiling_transformation(), and unstructured_to_complexity().

+ Here is the caller graph for this function:

◆ matrice_identite_p()

bool matrice_identite_p ( matrice  ID,
int  n,
int  level 
)

bool matrice_identite_p(matrice ID, int n, int level) test d'une sous-matrice dans ID(level+1..n, level+1..n) pour savoir si c'est une matrice identite.

Le test n'est correct que si la matrice ID passee en argument est normalisee (cf. matrice_normalize())

Pour tester toute la matrice ID, appeler avec level==0

Les parametres de la fonction :

int ID[] : matrice int n : nombre de lignes (et de colonnes) de la matrice ID int level : niveau de la matrice i.e. numero de la premiere ligne et de la premiere colonne a partir duquel on commence a prendre en compte les elements de la matrice

i!=j

Parameters
IDD
levelevel

Definition at line 353 of file sous-matrice.c.

357 {
358  int i,j;
359 
360  for(i = level+1; i <= n; i++) {
361  for(j = level+1; j <= n; j++) {
362  if(i==j) {
363  if(value_notone_p(ACCESS(ID,n,i,i)))
364  return(false);
365  }
366  else /* i!=j */
367  if(value_notzero_p(ACCESS(ID,n,i,j)))
368  return(false);
369  }
370  }
371  return(true);
372 }
#define value_notone_p(val)

References ACCESS, level, value_notone_p, and value_notzero_p.

◆ matrice_multiply()

void matrice_multiply ( matrice  a,
matrice  b,
matrice  c,
int  p,
int  q,
int  r 
)

void matrice_multiply(matrice a, matrice b, matrice c, int p, int q, int r): multiply rational matrix a by rational matrix b and store result in matrix c

 a is a (pxq) matrix, b a (qxr) and c a (pxr)

 c := a x b ;

Algorithm used is directly from definition, and space has to be provided for output matrix c by caller. Matrix c is not necessarily normalized: its denominator may divide all its elements (see matrice_normalize()).

Precondition: p > 0; q > 0; r > 0; c != a; c != b; – aliasing between c and a or b – is not supported input

validate dimensions

simplified aliasing test

set denominator

use ordinary school book algorithm

Parameters
b
 a is a (pxq) matrix, b a (qxr) and c a (pxr)

 c := a x b ;
Algorithm used is directly from definition, and space has to be provided for output matrix c by caller. Matrix c is not necessarily normalized: its denominator may divide all its elements (see matrice_normalize()).

Precondition: p > 0; q > 0; r > 0; c != a; c != b; – aliasing between c and a or b – is not supported input

Parameters
c
 a is a (pxq) matrix, b a (qxr) and c a (pxr)

 c := a x b ;
Algorithm used is directly from definition, and space has to be provided for output matrix c by caller. Matrix c is not necessarily normalized: its denominator may divide all its elements (see matrice_normalize()).

Precondition: p > 0; q > 0; r > 0; c != a; c != b; – aliasing between c and a or b – is not supported input

Parameters
p
 a is a (pxq) matrix, b a (qxr) and c a (pxr)

 c := a x b ;
Algorithm used is directly from definition, and space has to be provided for output matrix c by caller. Matrix c is not necessarily normalized: its denominator may divide all its elements (see matrice_normalize()).

Precondition: p > 0; q > 0; r > 0; c != a; c != b; – aliasing between c and a or b – is not supported output

Parameters
q
 a is a (pxq) matrix, b a (qxr) and c a (pxr)

 c := a x b ;
Algorithm used is directly from definition, and space has to be provided for output matrix c by caller. Matrix c is not necessarily normalized: its denominator may divide all its elements (see matrice_normalize()).

Precondition: p > 0; q > 0; r > 0; c != a; c != b; – aliasing between c and a or b – is not supported input

Parameters
r
 a is a (pxq) matrix, b a (qxr) and c a (pxr)

 c := a x b ;
Algorithm used is directly from definition, and space has to be provided for output matrix c by caller. Matrix c is not necessarily normalized: its denominator may divide all its elements (see matrice_normalize()).

Precondition: p > 0; q > 0; r > 0; c != a; c != b; – aliasing between c and a or b – is not supported input

Definition at line 82 of file matrice.c.

89 {
90  int loop1,loop2,loop3;
91  register Value i,va,vb;
92 
93  /* validate dimensions */
94  assert(p > 0 && q > 0 && r > 0);
95  /* simplified aliasing test */
96  assert(c != a && c != b);
97 
98  /* set denominator */
100 
101  /* use ordinary school book algorithm */
102  for(loop1=1; loop1<=p; loop1++)
103  for(loop2=1; loop2<=r; loop2++) {
104  i = VALUE_ZERO;
105  for(loop3=1; loop3<=q; loop3++)
106  {
107  va = ACCESS(a,p,loop1,loop3);
108  vb = ACCESS(b,q,loop3,loop2);
109  value_addto(i,value_mult(va,vb));
110  }
111  ACCESS(c,p,loop1,loop2) = i;
112  }
113 }
#define value_addto(ref, val)

References ACCESS, assert, DENOMINATOR, loop1, value_addto, value_mult, and VALUE_ZERO.

Referenced by hyperplane(), matrice_general_inversion(), matrice_unimodulaire_inversion(), sc_image_computation(), and unimodular().

+ Here is the caller graph for this function:

◆ matrice_normalize()

void matrice_normalize ( matrice  a,
int  n,
int  m 
)

void matrice_normalize(matrice a, int n, int m)

 A rational matrix is stored as an integer one with one extra
 integer, the denominator for all the elements. To normalise the
 matrix in this sense means to reduce this denominator to the 
 smallest positive number possible. All elements are also reduced
 to their smallest possible value.

Precondition: DENOMINATOR(a)!=0 output

we must find the GCD of all elements of matrix

factor out

ensure denominator is positive

FI: this code is useless because pgcd()always return a positive integer, even if a is the null matrix; its denominator CANNOT be 0

Parameters
n
 A rational matrix is stored as an integer one with one extra
 integer, the denominator for all the elements. To normalise the
 matrix in this sense means to reduce this denominator to the 
 smallest positive number possible. All elements are also reduced
 to their smallest possible value.
Precondition: DENOMINATOR(a)!=0 input
m
 A rational matrix is stored as an integer one with one extra
 integer, the denominator for all the elements. To normalise the
 matrix in this sense means to reduce this denominator to the 
 smallest positive number possible. All elements are also reduced
 to their smallest possible value.
Precondition: DENOMINATOR(a)!=0 input

Definition at line 125 of file matrice.c.

129 {
130  int loop1,loop2;
131  Value factor;
132 
134 
135  /* we must find the GCD of all elements of matrix */
136  factor = DENOMINATOR(a);
137 
138  for(loop1=1; loop1<=n; loop1++)
139  for(loop2=1; loop2<=m; loop2++)
140  factor = pgcd(factor,ACCESS(a,n,loop1,loop2));
141 
142  /* factor out */
143  if (value_notone_p(factor)) {
144  for(loop1=1; loop1<=n; loop1++)
145  for(loop2=1; loop2<=m; loop2++)
146  value_division(ACCESS(a,n,loop1,loop2),factor);
147  value_division(DENOMINATOR(a),factor);
148  }
149 
150  /* ensure denominator is positive */
151  /* FI: this code is useless because pgcd()always return a positive integer,
152  even if a is the null matrix; its denominator CANNOT be 0 */
154  /*
155  if(DENOMINATOR(a) < 0) {
156  DENOMINATOR(a) = DENOMINATOR(a)*-1;
157  for(loop1=1; loop1<=n; loop1++)
158  for(loop2=1; loop2<=m; loop2++)
159  value_oppose(ACCESS(a,n,loop1,loop2));
160  }*/
161 }
#define pgcd(a, b)
Pour la recherche de performance, selection d'une implementation particuliere des fonctions.

References ACCESS, assert, DENOMINATOR, loop1, pgcd, value_division, value_notone_p, value_notzero_p, and value_pos_p.

Referenced by average_probability_matrix(), make_tile_constraints(), and tile_membership().

+ Here is the caller graph for this function:

◆ matrice_normalizec()

void matrice_normalizec ( matrice  MAT,
int  n,
int  m 
)

void matrice_normalizec(matrice MAT, int n, int m): Normalisation des coefficients de la matrice MAT, i.e.

division des coefficients de la matrice MAT et de son denominateur par leur pgcd

La matrice est modifiee.

Les parametres de la fonction :

!int MAT[] : matrice de dimension (n,m) int n : nombre de lignes de la matrice int m : nombre de colonnes de la matrice

FI What an awful test! It should be an assert()

Parameters
MATAT

Definition at line 175 of file matrice.c.

178 {
179  int i;
180  Value a;
181 
182  /* FI What an awful test! It should be an assert() */
183  if (n && m) {
184  a = MAT[0];
185  for (i = 1;(i<=n*m) && value_gt(a,VALUE_ONE);i++)
186  a = pgcd(a,MAT[i]);
187 
188  if (value_gt(a,VALUE_ONE)) {
189  for (i = 0;i<=n*m;i++)
190  value_division(MAT[i],a);
191  }
192  }
193 }

References pgcd, value_division, value_gt, and VALUE_ONE.

◆ matrice_nulle()

void matrice_nulle ( matrice  Z,
int  n,
int  m 
)

void matrice_nulle(matrice Z, int n, int m): Initialisation de la matrice Z a la valeur matrice nulle

Post-condition:

QQ i dans [1..n] QQ j dans [1..n] Z(i,j) == 0

Les parametres de la fonction :

!int Z[] : matrice int n : nombre de lignes de la matrice int m : nombre de colonnes de la matrice

Definition at line 311 of file matrice.c.

314 {
315  int i,j;
316 
317  for (i=1;i<=n;i++)
318  for (j=1;j<=m;j++)
319  ACCESS(Z,n,i,j)=VALUE_ZERO;
320  DENOMINATOR(Z) = VALUE_ONE;
321 }

References ACCESS, DENOMINATOR, VALUE_ONE, and VALUE_ZERO.

Referenced by average_probability_matrix(), base_G_h1_unnull(), broadcast_conditions(), build_transfer_matrix(), contraintes_with_sym_cst_to_matrices(), loop_nest_to_tile(), loop_sc_to_matrices(), make_primal(), mat_perm_col(), mat_perm_lig(), matrice_diagonale_inversion(), matrice_hermite(), matrice_triangulaire_inversion(), partial_broadcast_coefficients(), pu_contraintes_to_matrices(), sc_image_computation(), sc_to_matrices(), sys_matrice_index(), and system_inversion_restrict().

+ Here is the caller graph for this function:

◆ matrice_nulle_p()

bool matrice_nulle_p ( matrice  Z,
int  n,
int  m 
)

bool matrice_nulle_p(matrice Z, int n, int m): test de nullite de la matrice Z

QQ i dans [1..n] QQ j dans [1..n] Z(i,j) == 0

Les parametres de la fonction :

int Z[] : matrice int n : nombre de lignes de la matrice int m : nombre de colonnes de la matrice

Definition at line 336 of file matrice.c.

339 {
340  int i,j;
341 
342  for (i=1;i<=n;i++)
343  for (j=1;j<=m;j++)
344  if(value_notzero_p(ACCESS(Z,n,i,j)))
345  return(false);
346  return(true);
347 }

References ACCESS, and value_notzero_p.

◆ matrice_print()

void matrice_print ( matrice  a,
int  n,
int  m 
)

void matrice_print(matrice a, int n, int m): print an (nxm) rational matrix

Note: the output format is incompatible with matrice_fscan() this should be implemented as a macro, but it's a function for dbx's sake row size

Parameters
mNote: the output format is incompatible with matrice_fscan() this should be implemented as a macro, but it's a function for dbx's sake column size

Definition at line 90 of file matrice_io.c.

94 {
95  matrice_fprint(stdout,a,n,m);
96 }
void matrice_fprint(FILE *f, matrice a, int n, int m)
void matrice_fprint(File * f, matrice a,n,m): print an (nxm) rational matrix
Definition: matrice_io.c:62

References matrice_fprint().

Referenced by matrice_smith().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ matrice_smith()

void matrice_smith ( matrice  MAT,
int  n,
int  m,
matrice  P,
matrice  D,
matrice  Q 
)

smith.c

smith.c

D est la forme reduite de Smith, P et Q sont des matrices unimodulaires; telles que D == P x MAT x Q

(c.f. Programmation Lineaire. M.MINOUX. (83))

int MAT[n,m] : matrice int n : nombre de lignes de la matrice MAT int m : nombre de colonnes de la matrice MAT int P[n,n] : matrice int D[n,m] : matrice (quasi-diagonale) reduite de Smith int Q[m,m] : matrice

Les 3 matrices P(nxn), Q(mxm) et D(nxm) doivent etre allouees avant le calcul.

Note: les determinants des matrices MAT, P, Q et D ne sont pas utilises.

le plus petit element sur la diagonale

le rest de la division par ALL

precondition sur les parametres

le transformation n'est pas fini.

Parameters
MATAT

Definition at line 68 of file smith.c.

74 {
75  int n_min,m_min;
76  int level = 0;
77  register Value ALL; /* le plus petit element sur la diagonale */
78  register Value x; /* le rest de la division par ALL */
79  int i;
80 
81  bool stop = false;
82  bool next = true;
83 
84  /* precondition sur les parametres */
85  assert(m > 0 && n >0);
86  matrice_assign(MAT,D,n,m);
88 
89  matrice_identite(P,n,0);
90  matrice_identite(Q,m,0);
91 
92  while (!stop) {
93  mat_min(D,n,m,&n_min,&m_min,level);
94 
95  if ((n_min == 0) && (m_min == 0))
96  stop = true;
97  else {
98  /* le transformation n'est pas fini. */
99  if (n_min > level +1) {
100  matrice_swap_rows(D,n,m,level+1,n_min);
101  matrice_swap_rows(P,n,n,level+1,n_min);
102  }
103 #ifdef TRACE
104  (void) printf (" apres alignement du plus petit element a la premiere ligne \n");
105  matrice_print(D,n,m);
106 #endif
107  if (m_min >1+level) {
108  matrice_swap_columns(D,n,m,level+1,m_min);
109  matrice_swap_columns(Q,m,m,level+1,m_min);
110  }
111 #ifdef TRACE
112  (void) printf (" apres alignement du plus petit element"
113  " a la premiere colonne\n");
114  matrice_print(D,n,m);
115 #endif
116 
117  ALL = ACC_ELEM(D,n,1,1,level);
118  if (mat_lig_el(D,n,m,level) != 0)
119  for (i=level+2; i<=m; i++) {
120  x = ACCESS(D,n,level+1,i);
124  next = false;
125  }
126  if (mat_col_el(D,n,m,level) != 0)
127  for(i=level+2;i<=n;i++) {
128  x = ACCESS(D,n,i,level+1);
132  next = false;
133  }
134 #ifdef TRACE
135  (void) printf("apres division par A(%d,%d) des termes de la %d-ieme ligne et de la %d-em colonne \n",level+1,level+1,level+1,level+1);
136  matrice_print(D,n,m);
137 #endif
138  if (next) level++;
139  next = true;
140  }
141  }
142 
143 #ifdef TRACE
144  (void) printf (" la matrice D apres transformation est la suivante :");
145  matrice_print(D,n,m);
146 
147  (void) printf (" la matrice P est \n");
148  matrice_print(P,n,n);
149 
150  (void) printf (" la matrice Q est \n");
151  matrice_print(Q,m,m);
152 #endif
153 }
#define D(A)
Definition: iabrev.h:56
void matrice_soustraction_ligne(matrice MAT, int n, int m, int r1, int r2, Value x)
void matrice_soustraction_ligne(matrice MAT,int n,int m,int r1,int r2,int x): Soustrait x fois la lig...
Definition: matrice.c:554
void mat_min(matrice, int, int, int *, int *, int)
void mat_min(matrice MAT, int n, int m, int * i_min, int * j_min, int level): Recherche des coordonne...
Definition: sous-matrice.c:193
void matrice_print(matrice, int, int)
void matrice_print(matrice a, int n, int m): print an (nxm) rational matrix
Definition: matrice_io.c:90
int mat_col_el(matrice, int, int, int)

References ACC_ELEM, ACCESS, ALL, assert, D, DENOMINATOR, level, mat_col_el(), mat_lig_el(), mat_min(), matrice_assign(), matrice_identite(), matrice_print(), matrice_soustraction_colonne(), matrice_soustraction_ligne(), matrice_swap_columns(), matrice_swap_rows(), printf(), Q, value_division, value_one_p, and x.

Referenced by transformer_equality_fix_point().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ matrice_sous_determinant()

void matrice_sous_determinant ( matrice  ,
int  ,
int  ,
int  ,
Value  [] 
)

◆ matrice_soustraction_colonne()

void matrice_soustraction_colonne ( matrice  ,
int  ,
int  ,
int  ,
int  ,
Value   
)

◆ matrice_soustraction_ligne()

void matrice_soustraction_ligne ( matrice  MAT,
int  n,
int  m,
int  r1,
int  r2,
Value  x 
)

void matrice_soustraction_ligne(matrice MAT,int n,int m,int r1,int r2,int x): Soustrait x fois la ligne r2 de la ligne r1 Precondition: n > 0; m > 0; 0 < r1, r2 < n; Effet: r1[0..m-1] = r1[0..m-1] - x*r2[0..m-1]

Les parametres de la fonction :

int MAT[] : matrice int n : nombre de lignes de la matrice int m : nombre de colonnes de la matrice int r1 : numero du ligne int r2 : numero du ligne int x :

Parameters
MATAT
r11
r22

Definition at line 554 of file matrice.c.

559 {
560  int i;
561  register Value p;
562  for (i=1; i<=m; i++)
563  {
564  p = ACCESS(MAT,n,r2,i);
565  value_product(p,x);
566  value_substract(ACCESS(MAT,n,r1,i),p);
567  }
568 }
#define value_product(v, w)
#define value_substract(ref, val)

References ACCESS, value_product, value_substract, and x.

Referenced by matrice_smith().

+ Here is the caller graph for this function:

◆ matrice_substract()

void matrice_substract ( matrice  a,
matrice  b,
matrice  c,
int  n,
int  m 
)

void matrice_substract(matrice a, matrice b, matrice c, int n, int m): substract rational matrix c from rational matrix b and store result in matrix a

 a is a (nxm) matrix, b a (nxm) and c a (nxm)

 a = b - c ;

Algorithm used is directly from definition, and space has to be provided for output matrix a by caller. Matrix a is not necessarily normalized: its denominator may divide all its elements (see matrice_normalize()).

Precondition: n > 0; m > 0; Note: aliasing between a and b or c is supported input

denominators of b, c

ppcm of b,c

precondition

Parameters
b
 a is a (nxm) matrix, b a (nxm) and c a (nxm)

 a = b - c ;
Algorithm used is directly from definition, and space has to be provided for output matrix a by caller. Matrix a is not necessarily normalized: its denominator may divide all its elements (see matrice_normalize()).

Precondition: n > 0; m > 0; Note: aliasing between a and b or c is supported output

Parameters
n
 a is a (nxm) matrix, b a (nxm) and c a (nxm)

 a = b - c ;
Algorithm used is directly from definition, and space has to be provided for output matrix a by caller. Matrix a is not necessarily normalized: its denominator may divide all its elements (see matrice_normalize()).

Precondition: n > 0; m > 0; Note: aliasing between a and b or c is supported input

Definition at line 468 of file matrice.c.

472 {
473  register Value d1,d2; /* denominators of b, c */
474  register Value lcm; /* ppcm of b,c */
475  int i,j;
476 
477  /* precondition */
478  assert(n>0 && m>0);
481 
482  d1 = DENOMINATOR(b);
483  d2 = DENOMINATOR(c);
484  if (d1 == d2){
485  for (i=1; i<=n; i++)
486  for (j=1; j<=m; j++)
487  ACCESS(a,n,i,j) = value_minus(ACCESS(b,n,i,j),
488  ACCESS(c,n,i,j));
489  DENOMINATOR(a) = d1;
490  }
491  else{
492  register Value v1,v2;
493  lcm = ppcm(d1,d2);
494  DENOMINATOR(a) = lcm;
495  d1 = value_div(lcm,d1);
496  d2 = value_div(lcm,d2);
497  for (i=1; i<=n; i++)
498  for (j=1; j<=m; j++)
499  {
500  v1 = ACCESS(b,n,i,j);
501  value_product(v1, d1);
502  v2 = ACCESS(c,n,i,j);
503  value_product(v2, d2);
504  ACCESS(a,n,i,j) = value_minus(v1,v2);
505  }
506  }
507 }
#define value_minus(v1, v2)

References ACCESS, assert, DENOMINATOR, ppcm(), value_div, value_minus, value_pos_p, and value_product.

Referenced by unstructured_to_complexity().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ matrice_swap_columns()

void matrice_swap_columns ( matrice  matrix,
int  n,
int  m,
int  c1,
int  c2 
)

void matrice_swap_columns(matrice matrix, int n, int m, int c1, int c2): exchange columns c1,c2 of an (nxm) rational matrix

 Precondition:      n > 0; m > 0; 0 < c1 <= m; 0 < c2 <= m; 

column numbers

validation step

Parameters
matrixatrix
n
 Precondition:      n > 0; m > 0; 0 < c1 <= m; 0 < c2 <= m; 
input and output matrix
m
 Precondition:      n > 0; m > 0; 0 < c1 <= m; 0 < c2 <= m; 
number of rows
c1
 Precondition:      n > 0; m > 0; 0 < c1 <= m; 0 < c2 <= m; 
number of columns
c22

Definition at line 200 of file matrice.c.

205 {
206  int loop1;
207  register Value temp;
208 
209  /* validation step */
210  /*
211  * if ((n < 1) || (m < 1)) return(-208);
212  * if ((c1 > m) || (c2 > m)) return(-209);
213  */
214  assert(n > 0 && m > 0);
215  assert(0 < c1 && c1 <= m);
216  assert(0 < c2 && c2 <= m);
217 
218  for(loop1=1; loop1<=n; loop1++) {
219  temp = ACCESS(matrix,n,loop1,c1);
220  ACCESS(matrix,n,loop1,c1) = ACCESS(matrix,n,loop1,c2);
221  ACCESS(matrix,n,loop1,c2) = temp;
222  }
223 }

References ACCESS, assert, and loop1.

Referenced by matrice_hermite(), and matrice_smith().

+ Here is the caller graph for this function:

◆ matrice_swap_rows()

void matrice_swap_rows ( matrice  a,
int  n,
int  m,
int  r1,
int  r2 
)

void matrice_swap_rows(matrice a, int n, int m, int r1, int r2): exchange rows r1 and r2 of an (nxm) rational matrix a

Precondition: n > 0; m > 0; 1 <= r1 <= n; 1 <= r2 <= n row numbers

validation

Parameters
nPrecondition: n > 0; m > 0; 1 <= r1 <= n; 1 <= r2 <= n input and output matrix
mPrecondition: n > 0; m > 0; 1 <= r1 <= n; 1 <= r2 <= n number of columns
r1Precondition: n > 0; m > 0; 1 <= r1 <= n; 1 <= r2 <= n number of rows
r22

Definition at line 230 of file matrice.c.

235 {
236  int loop1;
237  register Value temp;
238 
239  /* validation */
240  assert(n > 0);
241  assert(m > 0);
242  assert(0 < r1 && r1 <= n);
243  assert(0 < r2 && r2 <= n);
244 
245  for(loop1=1; loop1<=m; loop1++) {
246  temp = ACCESS(a,n,r1,loop1);
247  ACCESS(a,n,r1,loop1) = ACCESS(a,n,r2,loop1);
248  ACCESS(a,n,r2,loop1) = temp;
249  }
250 }

References ACCESS, assert, and loop1.

Referenced by matrice_hermite(), matrice_smith(), and scanning_base_hyperplane().

+ Here is the caller graph for this function:

◆ matrice_transpose()

void matrice_transpose ( matrice  a,
matrice  a_t,
int  n,
int  m 
)

matrice.c

matrice.c

void matrice_transpose(matrice a, matrice a_t, int n, int m): transpose an (nxm) rational matrix a into a (mxn) rational matrix a_t

    t

a_t := a ;

verification step

copy from a to a_t

Parameters
a_t_t

Definition at line 48 of file matrice.c.

53 {
54  int loop1,loop2;
55 
56  /* verification step */
57  assert(n >= 0 && m >= 0);
58 
59  /* copy from a to a_t */
60  DENOMINATOR(a_t) = DENOMINATOR(a);
61  for(loop1=1; loop1<=n; loop1++)
62  for(loop2=1; loop2<=m; loop2++)
63  ACCESS(a_t,m,loop2,loop1) = ACCESS(a,n,loop1,loop2);
64 }

References ACCESS, assert, DENOMINATOR, and loop1.

Referenced by base_G_h1_unnull(), broadcast_conditions(), make_primal(), partial_broadcast_coefficients(), and system_inversion_restrict().

+ Here is the caller graph for this function:

◆ matrice_triangulaire_inversion()

void matrice_triangulaire_inversion ( matrice  h,
matrice  inv_h,
int  n,
bool  infer 
)

void matrice_triangulaire_inversion(matrice h, matrice inv_h, int n,bool infer) calcul de l'inversion du matrice en forme triangulaire.

soit h matrice de la reduite triangulaire; inv_h est l'inversion de h ; telle que : h * inv_h = I. selon les proprietes de la matrice triangulaire: Aii = a11* ...aii-1*aii+1...*ann; Aij = 0 i>j pour la matrice triangulaire inferieure (infer==true) i<j pour la matrice triangulaire superieure (infer==false)

les parametres de la fonction : matrice h : matrice en forme triangulaire – input matrice inv_h : l'inversion de h – output int n : dimension de la matrice caree – input bool infer : le type de triangulaire – input

denominateur

determinant

tests des preconditions

calcul du determinant de h

calcul du denominateur de inv_h

calcul des sous_determinants des Aii

calcul des sous_determinants des Aij (i<j)

Parameters
inv_hnv_h
infernfer

Definition at line 140 of file inversion.c.

145 {
146  Value deno,deno1; /* denominateur */
147  Value determinant,sous_determinant; /* determinant */
148  Value gcd;
149  int i,j;
150  Value aij[2];
151  register Value a;
152 
153  /* tests des preconditions */
154  assert(matrice_triangulaire_p(h,n,n,infer));
155  assert(matrice_hermite_rank(h,n,n)==n);
157 
158  matrice_nulle(inv_h,n,n);
159  deno = DENOMINATOR(h);
160  deno1 = deno;
161  DENOMINATOR(h) = VALUE_ONE;
162  /* calcul du determinant de h */
163  determinant = VALUE_ONE;
164  for (i= 1; i<=n; i++){
165  a = ACCESS(h,n,i,i);
166  value_product(determinant,a);
167  }
168  /* calcul du denominateur de inv_h */
169  gcd = pgcd_slow(deno1,determinant);
170  if (value_notone_p(gcd)){
171  value_division(deno1,gcd);
172  value_division(determinant,gcd);
173  }
174  if (value_neg_p(determinant)){
175  value_oppose(deno1);
176  value_oppose(determinant);
177  }
178  DENOMINATOR(inv_h) = determinant;
179  /* calcul des sous_determinants des Aii */
180  for (i=1; i<=n; i++){
181  sous_determinant = VALUE_ONE;
182  for (j=1; j<=n; j++)
183  if (j != i) {
184  a = ACCESS(h,n,j,j);
185  value_product(sous_determinant,a) ;
186  }
187  ACCESS(inv_h,n,i,i) = value_mult(sous_determinant,deno1);
188  }
189  /* calcul des sous_determinants des Aij (i<j) */
190  if (infer) {
191  for (i=1; i<=n; i++)
192  for(j=i+1; j<=n;j++){
193  matrice_sous_determinant(h,n,i,j,aij);
194  assert(aij[0] == VALUE_ONE);
195  ACCESS(inv_h,n,j,i) = value_mult(aij[1],deno1);
196  }
197  }
198  else {
199  for (i=1; i<=n; i++)
200  for(j=1; j<i; j++){
201  matrice_sous_determinant(h,n,i,j,aij);
202  assert(aij[0] == VALUE_ONE);
203  ACCESS(inv_h,n,j,i) = value_mult(aij[1],deno1);
204  }
205  }
206 
207  DENOMINATOR(h) = deno;
208 }
#define value_neg_p(val)
void matrice_sous_determinant(matrice a, int n, int i, int j, result)
void matrice_sous_determinant(matrice a, int n,int i, int j, int result[]) calculate sub determinant ...
Definition: determinant.c:156
bool matrice_triangulaire_p(matrice Z, int n, int m, bool inferieure)
bool matrice_triangulaire_p(matrice Z, int n, int m, bool inferieure): test de triangularite de la ma...
Definition: matrice.c:394

References ACCESS, assert, DENOMINATOR, matrice_hermite_rank(), matrice_nulle(), matrice_sous_determinant(), matrice_triangulaire_p(), pgcd_slow(), value_division, value_mult, value_neg_p, value_notone_p, VALUE_ONE, value_oppose, value_pos_p, and value_product.

Referenced by matrice_general_inversion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ matrice_triangulaire_p()

bool matrice_triangulaire_p ( matrice  Z,
int  n,
int  m,
bool  inferieure 
)

bool matrice_triangulaire_p(matrice Z, int n, int m, bool inferieure): test de triangularite de la matrice Z

si inferieure == true QQ i dans [1..n] QQ j dans [i+1..m] Z(i,j) == 0

si inferieure == false (triangulaire superieure) QQ i dans [1..n] QQ j dans [1..i-1] Z(i,j) == 0

Les parametres de la fonction :

int Z[] : matrice int n : nombre de lignes de la matrice int m : nombre de colonnes de la matrice

Parameters
inferieurenferieure

Definition at line 394 of file matrice.c.

398 {
399  int i,j;
400 
401  for (i=1; i <= n; i++)
402  if(inferieure) {
403  for (j=i+1; j <= m; j++)
404  if(value_notzero_p(ACCESS(Z,n,i,j)))
405  return(false);
406  }
407  else
408  for (j=1; j <= i-1; j++)
409  if(value_notzero_p(ACCESS(Z,n,i,j)))
410  return(false);
411  return(true);
412 }

References ACCESS, and value_notzero_p.

Referenced by matrice_triangulaire_inversion(), and matrice_triangulaire_unimodulaire_p().

+ Here is the caller graph for this function:

◆ matrice_triangulaire_unimodulaire_p()

bool matrice_triangulaire_unimodulaire_p ( matrice  Z,
int  n,
bool  inferieure 
)

bool matrice_triangulaire_unimodulaire_p(matrice Z, int n, bool inferieure) test de la triangulaire et unimodulaire de la matrice Z.

si inferieure == true QQ i dans [1..n] QQ j dans [i+1..n] Z(i,j) == 0 i dans [1..n] Z(i,i) == 1

si inferieure == false (triangulaire superieure) QQ i dans [1..n] QQ j dans [1..i-1] Z(i,j) == 0 i dans [1..n] Z(i,i) == 1

les parametres de la fonction : matrice Z : la matrice entre int n : la dimension de la martice caree

Parameters
inferieurenferieure

Definition at line 434 of file matrice.c.

438 {
439  bool triangulaire;
440  int i;
441  triangulaire = matrice_triangulaire_p(Z,n,n,inferieure);
442  if (triangulaire == false)
443  return(false);
444  else{
445  for(i=1; i<=n; i++)
446  if (value_notone_p(ACCESS(Z,n,i,i)))
447  return(false);
448  return(true);
449  }
450 }

References ACCESS, matrice_triangulaire_p(), and value_notone_p.

Referenced by matrice_unimodulaire_inversion(), and matrice_unimodulaire_triangulaire_inversion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ matrice_unimodulaire_inversion()

void matrice_unimodulaire_inversion ( matrice  u,
matrice  inv_u,
int  n 
)

void matrice_unimodulaire_inversion(matrice u, matrice inv_u, int n) calcul de l'inversion de la matrice unimodulaire.

algorithme :

  1. calcul la forme hermite de la matrice u : PUQ = H_U (unimodulaire triangulaire); -1 -1
  2. U = Q (H_U) P.

les parametres de la fonction : matrice u : matrice unimodulaire -— input matrice inv_u : l'inversion de u -— output int n : dimension de la matrice -— input

ne utilise pas

test

Parameters
inv_unv_u

Definition at line 267 of file inversion.c.

271 {
272  matrice p = matrice_new(n,n);
273  matrice q = matrice_new(n,n);
274  matrice h_u = matrice_new(n,n);
275  matrice inv_h_u = matrice_new(n,n);
276  matrice temp = matrice_new(n,n);
277  Value det_p,det_q; /* ne utilise pas */
278 
279  /* test */
281 
282  matrice_hermite(u,n,n,p,h_u,q,&det_p,&det_q);
285  matrice_multiply(q,inv_h_u,temp,n,n,n);
286  matrice_multiply(temp,p,inv_u,n,n,n);
287 }
void matrice_unimodulaire_triangulaire_inversion(matrice u, matrice inv_u, int n, bool infer)
package matrice
Definition: inversion.c:54
bool matrice_triangulaire_unimodulaire_p(matrice Z, int n, bool inferieure)
bool matrice_triangulaire_unimodulaire_p(matrice Z, int n, bool inferieure) test de la triangulaire e...
Definition: matrice.c:434

References assert, DENOMINATOR, matrice_hermite(), matrice_multiply(), matrice_new, matrice_triangulaire_unimodulaire_p(), matrice_unimodulaire_triangulaire_inversion(), and value_one_p.

+ Here is the call graph for this function:

◆ matrice_unimodulaire_triangulaire_inversion()

void matrice_unimodulaire_triangulaire_inversion ( matrice  u,
matrice  inv_u,
int  n,
bool  infer 
)

inversion.c

inversion.c

void matrice_unimodulaire_triangulaire_inversion(matrice u ,matrice inv_u, int n, * bool infer) u soit le matrice unimodulaire triangulaire. si infer = true (triangulaire inferieure), infer = false (triangulaire superieure). calcul de l'inversion de matrice u telle que I = U x INV_U . Les parametres de la fonction :

matrice u : matrice unimodulaire triangulaire – inpout int n : dimension de la matrice caree – inpout bool infer : type de triangulaire – input matrice inv_u : l'inversion de matrice u – output

test de l'unimodularite et de la trangularite de u

Parameters
inv_unv_u
infernfer

Definition at line 54 of file inversion.c.

59 {
60  int i, j;
61  Value x;
62 
63  /* test de l'unimodularite et de la trangularite de u */
65 
66  matrice_identite(inv_u,n,0);
67  if (infer){
68  for (i=n; i>=1;i--)
69  for (j=i-1; j>=1; j--){
70  x = ACCESS(u,n,i,j);
71  if (value_notzero_p(x))
72  matrice_soustraction_colonne(inv_u,n,n,j,i,x);
73  }
74  }
75  else{
76  for (i=1; i<=n; i++)
77  for(j=i+1; j<=n; j++){
78  x = ACCESS(u,n,i,j);
79  if (value_notzero_p(x))
80  matrice_soustraction_colonne(inv_u,n,n,j,i,x);
81  }
82  }
83 }

References ACCESS, assert, matrice_identite(), matrice_soustraction_colonne(), matrice_triangulaire_unimodulaire_p(), value_notzero_p, and x.

Referenced by matrice_unimodulaire_inversion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: