PIPS
smith.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include "linear_assert.h"
#include "boolean.h"
#include "arithmetique.h"
#include "matrice.h"
+ Include dependency graph for smith.c:

Go to the source code of this file.

Macros

#define MALLOC(s, t, f)   malloc((unsigned)(s))
 package matrice More...
 
#define FREE(s, t, f)   free((char *)(s))
 

Functions

void matrice_smith (matrice MAT, int n, int m, matrice P, matrice D, matrice Q)
 void matrice_smith(matrice MAT, int n, int m, matrice P, matrice D, matrice Q): Calcul de la forme reduite de Smith D d'une matrice entiere MAT et des deux matrices de changement de base unimodulaires associees, P et Q. More...
 

Macro Definition Documentation

◆ FREE

#define FREE (   s,
  t,
  f 
)    free((char *)(s))

Definition at line 43 of file smith.c.

◆ MALLOC

#define MALLOC (   s,
  t,
  f 
)    malloc((unsigned)(s))

package matrice

Definition at line 42 of file smith.c.

Function Documentation

◆ matrice_smith()

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

void matrice_smith(matrice MAT, int n, int m, matrice P, matrice D, matrice Q): Calcul de la forme reduite de Smith D d'une matrice entiere MAT et des deux matrices de changement de base unimodulaires associees, P et Q.

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 value_one_p(val)
int Value
#define value_division(ref, val)
#define D(A)
Definition: iabrev.h:56
#define DENOMINATOR(matrix)
int DENOMINATEUR(matrix): acces au denominateur global d'une matrice matrix La combinaison *(&()) est...
Definition: matrice-local.h:93
#define ACCESS(matrix, column, i, j)
Macros d'acces aux elements d'une matrice.
Definition: matrice-local.h:86
#define ACC_ELEM(matrix, column, i, j, level)
FI: Corinne, peux-tu expliquer la raison d'etre de cette macro?
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_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 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_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_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
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)
#define assert(ex)
Definition: newgen_assert.h:41
#define Q
Definition: pip__type.h:39
#define ALL
Definition: readmakefile.c:178
#define level
int printf()
static char * x
Definition: split_file.c:159

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: