PIPS
matrix.h
Go to the documentation of this file.
1 /* Warning! Do not modify this file that is automatically generated! */
2 /* Modify src/Libs/matrix/matrix-local.h instead, to add your own modifications. */
3 
4 /* header file built by cproto */
5 
6 #ifndef matrix_header_included
7 #define matrix_header_included
8 /* matrix-local.h */
9 /*
10 
11  $Id: matrix-local.h 1641 2016-03-02 08:20:19Z coelho $
12 
13  Copyright 1989-2016 MINES ParisTech
14 
15  This file is part of Linear/C3 Library.
16 
17  Linear/C3 Library is free software: you can redistribute it and/or modify it
18  under the terms of the GNU Lesser General Public License as published by
19  the Free Software Foundation, either version 3 of the License, or
20  any later version.
21 
22  Linear/C3 Library is distributed in the hope that it will be useful, but WITHOUT ANY
23  WARRANTY; without even the implied warranty of MERCHANTABILITY or
24  FITNESS FOR A PARTICULAR PURPOSE.
25 
26  See the GNU Lesser General Public License for more details.
27 
28  You should have received a copy of the GNU Lesser General Public License
29  along with Linear/C3 Library. If not, see <http://www.gnu.org/licenses/>.
30 
31 */
32 
33 /* package matrice
34  *
35  * Neil Butler, Corinne Ancourt, Francois Irigoin, Yi-qing Yang
36  *
37  */
38 
39 /* Les matrices sont des matrices pleines, a coeffcients rationnels.
40  *
41  * Les matrices sont representes par des tableaux d'entiers mono-dimensionnels
42  * Elles sont stockees par colonne ("column-major"), comme en Fortran.
43  * Les indices commencent a 1, toujours comme en Fortran et non comme en C.
44  *
45  * Le denominateur doit etre strictement positif, i.e. plus grand ou egal
46  * a un. Un denominateur nul n'aurait pas de sens. Un denominateur negatif
47  * doublerait le nombre de representations possibles d'une matrice.
48  *
49  * Les matrices renvoyees par certaines routines, comme matrix_multiply(),
50  * ne sont pas normalisees par le pgcd des coefficients et du denominateur
51  * pour des raisons d'efficacite. Mais les routines de test, comme
52  * matrix_identity_p(), supposent leurs arguments normalises.
53  *
54  * Il faudrait sans doute introduire deux niveaux de procedure, un niveau
55  * externe sur garantissant la normalisation, et un niveau interne efficace
56  * sans normalisation automatique.
57  *
58  * La bibliotheque utilise une notion de sous-matrice, definie systematiquement
59  * par un parametre appele "level". Seuls les elements dont les indices
60  * de lignes et de colonnes sont superieurs a level+1
61  * sont pris en consideration. Il s'agit donc de sous-matrice dont le
62  * premier element se trouve sur la diagonale de la matrice complete et
63  * dont le dernier element et le dernier element de la matrice complete.
64  *
65  * Note: en cas detection d'incoherence, Neil Butler renvoyait un code
66  * d'erreur particulier; Francois Irigoin a supprime ces codes de retour
67  * et a traite les exceptions par des appels a assert(), et indirectement
68  * a abort()
69  */
70 
71 typedef struct {
72  Value denominator;
73  int number_of_lines;
74  int number_of_columns;
75  Value * coefficients;
77 
78 #define MATRIX_UNDEFINED ((Pmatrix) NULL)
79 
80 /* Allocation et desallocation d'une matrice */
81 #define matrix_free(m) (free(m), (m)=(Pmatrix) NULL)
82 
83 /* Macros d'acces aux elements d'une matrice */
84 
85 /* int MATRIX_ELEM(int * matrix, int i, int j):
86  * acces a l'element (i,j) de la matrice matrix.
87  */
88 #define MATRIX_ELEM(matrix, i, j) \
89  ((matrix)->coefficients[(((j)-1)*((matrix)->number_of_lines))+((i)-1)])
90 
91 /* int MATRIX_DENONIMATOR(matrix): acces au denominateur global
92  * d'une matrice matrix
93  */
94 #define MATRIX_DENOMINATOR(matrix) ((matrix)->denominator)
95 #define MATRIX_NB_LINES(matrix) ((matrix)->number_of_lines)
96 #define MATRIX_NB_COLUMNS(matrix) ((matrix)->number_of_columns)
97 
98 /* bool matrix_triangular_inferieure_p(matrice a):
99  * test de triangularite de la matrice a
100  */
101 #define matrix_triangular_inferieure_p(a) \
102  matrix_triangular_p(a, true)
103 
104 /* bool matrix_triangular_superieure_p(matrice a, int n, int m):
105  * test de triangularite de la matrice a
106  */
107 #define matrix_triangular_superieure_p(a) \
108  matrix_triangular_p(a, false)
109 
110 /* MATRIX_RIGHT_INF_ELEM Permet d'acceder des sous-matrices dont le
111  * coin infe'rieur droit (i.e. le premier element) se trouve sur la
112  * diagonal
113  */
114 #define SUB_MATRIX_ELEM(matrix, i, j, level) \
115  (matrix->coefficients[((j)-1+(level))* \
116  ((matrix)->number_of_lines) + (i) - 1 + (level)])
117 /* cproto-generated files */
118 /* alloc.c */
119 extern Pmatrix matrix_new(int /*m*/, int /*n*/);
120 extern void matrix_rm(Pmatrix /*a*/);
121 /* determinant.c */
122 extern void matrix_determinant(Pmatrix /*a*/, Value /*result*/[]);
123 extern void matrix_sub_determinant(Pmatrix /*a*/, int /*i*/, int /*j*/, Value /*result*/[]);
124 /* hermite.c */
125 extern void matrix_hermite(Pmatrix /*MAT*/, Pmatrix /*P*/, Pmatrix /*H*/, Pmatrix /*Q*/, Value */*det_p*/, Value */*det_q*/);
126 extern int matrix_hermite_rank(Pmatrix /*a*/);
127 extern int matrix_dim_hermite(Pmatrix /*H*/);
128 /* inversion.c */
129 extern void matrix_unimodular_triangular_inversion(Pmatrix /*u*/, Pmatrix /*inv_u*/, bool /*infer*/);
130 extern void matrix_diagonal_inversion(Pmatrix /*s*/, Pmatrix /*inv_s*/);
131 extern void matrix_triangular_inversion(Pmatrix /*h*/, Pmatrix /*inv_h*/, bool /*infer*/);
132 extern void matrix_general_inversion(Pmatrix /*a*/, Pmatrix /*inv_a*/);
133 extern void matrix_unimodular_inversion(Pmatrix /*u*/, Pmatrix /*inv_u*/);
134 /* matrix.c */
135 extern Value *matrix_elem_ref(Pmatrix /*M*/, int /*r*/, int /*c*/);
136 extern Value matrix_elem(Pmatrix /*M*/, int /*r*/, int /*c*/);
137 extern void matrix_transpose(const Pmatrix /*A*/, Pmatrix /*At*/);
138 extern void matrix_multiply(const Pmatrix /*a*/, const Pmatrix /*b*/, Pmatrix /*c*/);
139 extern void matrix_normalize(Pmatrix /*a*/);
140 extern void matrix_normalizec(Pmatrix /*MAT*/);
141 extern void matrix_swap_columns(Pmatrix /*A*/, int /*c1*/, int /*c2*/);
142 extern void matrix_swap_rows(Pmatrix /*A*/, int /*r1*/, int /*r2*/);
143 extern void matrix_assign(Pmatrix /*A*/, Pmatrix /*B*/);
144 extern bool matrix_equality(Pmatrix /*A*/, Pmatrix /*B*/);
145 extern void matrix_nulle(Pmatrix /*Z*/);
146 extern bool matrix_nulle_p(Pmatrix /*Z*/);
147 extern bool matrix_diagonal_p(Pmatrix /*Z*/);
148 extern bool matrix_triangular_p(Pmatrix /*Z*/, bool /*inferieure*/);
149 extern bool matrix_triangular_unimodular_p(Pmatrix /*Z*/, bool /*inferieure*/);
150 extern void matrix_substract(Pmatrix /*a*/, Pmatrix /*b*/, Pmatrix /*c*/);
151 extern void matrix_add(Pmatrix /*a*/, Pmatrix /*b*/, Pmatrix /*c*/);
152 extern void matrix_subtraction_column(Pmatrix /*MAT*/, int /*c1*/, int /*c2*/, Value /*x*/);
153 extern void matrix_subtraction_line(Pmatrix /*MAT*/, int /*r1*/, int /*r2*/, Value /*x*/);
154 extern void matrix_uminus(Pmatrix /*A*/, Pmatrix /*mA*/);
155 /* matrix_io.c */
156 extern void matrix_fprint(FILE */*f*/, Pmatrix /*a*/);
157 extern void matrix_print(Pmatrix /*a*/);
158 extern void matrix_fscan(FILE */*f*/, Pmatrix */*a*/, int */*n*/, int */*m*/);
159 extern void matrix_pr_quot(FILE */*f*/, Value /*a*/, Value /*b*/);
160 /* smith.c */
161 extern void matrix_smith(Pmatrix /*MAT*/, Pmatrix /*P*/, Pmatrix /*D*/, Pmatrix /*Q*/);
162 extern int matrices_to_1D_lattice(Pmatrix /*A*/, Pmatrix /*B*/, int /*n*/, int /*m*/, int /*i*/, Value */*gcd_p*/, Value */*c_p*/);
163 /* sub-matrix.c */
164 extern int matrix_line_nnul(Pmatrix /*MAT*/, int /*level*/);
165 extern void matrix_perm_col(Pmatrix /*MAT*/, int /*k*/, int /*level*/);
166 extern void matrix_perm_line(Pmatrix /*MAT*/, int /*k*/, int /*level*/);
167 extern void matrix_min(Pmatrix /*MAT*/, int */*i_min*/, int */*j_min*/, int /*level*/);
168 extern void matrix_maj_col(Pmatrix /*A*/, Pmatrix /*P*/, int /*level*/);
169 extern void matrix_maj_line(Pmatrix /*A*/, Pmatrix /*Q*/, int /*level*/);
170 extern void matrix_identity(Pmatrix /*ID*/, int /*level*/);
171 extern bool matrix_identity_p(Pmatrix /*ID*/, int /*level*/);
172 extern int matrix_line_el(Pmatrix /*MAT*/, int /*level*/);
173 extern int matrix_col_el(Pmatrix /*MAT*/, int /*level*/);
174 extern void matrix_coeff_nnul(Pmatrix /*MAT*/, int */*lg_nnul*/, int */*cl_nnul*/, int /*level*/);
175 extern void ordinary_sub_matrix(Pmatrix /*A*/, Pmatrix /*A_sub*/, int /*i1*/, int /*i2*/, int /*j1*/, int /*j2*/);
176 extern void insert_sub_matrix(Pmatrix /*A*/, Pmatrix /*A_sub*/, int /*i1*/, int /*i2*/, int /*j1*/, int /*j2*/);
177 #endif /* matrix_header_included */
int Value
void matrix_transpose(const Pmatrix, Pmatrix)
void matrix_transpose(Pmatrix a, Pmatrix a_t): transpose an (nxm) rational matrix a into a (mxn) rati...
Definition: matrix.c:64
void ordinary_sub_matrix(Pmatrix, Pmatrix, int, int, int, int)
void ordinary_sub_matrix(Pmatrix A, A_sub, int i1, i2, j1, j2) input : a initialized matrix A,...
Definition: sub-matrix.c:469
void matrix_triangular_inversion(Pmatrix, Pmatrix, bool)
void matrix_triangular_inversion(Pmatrix h, Pmatrix inv_h,bool infer) calcul de l'inversion du matric...
Definition: inversion.c:137
void matrix_swap_rows(Pmatrix, int, int)
void matrix_swap_rows(Pmatrix a, int r1, int r2): exchange rows r1 and r2 of an (nxm) rational matrix...
Definition: matrix.c:230
void matrix_unimodular_inversion(Pmatrix, Pmatrix)
void matrix_unimodular_inversion(Pmatrix u, Pmatrix inv_u) calcul de l'inversion de la matrice unimod...
Definition: inversion.c:261
void matrix_hermite(Pmatrix, Pmatrix, Pmatrix, Pmatrix, Value *, Value *)
hermite.c
Definition: hermite.c:78
Value * matrix_elem_ref(Pmatrix, int, int)
matrix.c
Definition: matrix.c:41
int matrix_dim_hermite(Pmatrix)
Calcul de la dimension de la matrice de Hermite H.
Definition: hermite.c:194
struct Pmatrix Smatrix
int matrix_hermite_rank(Pmatrix)
int matrix_hermite_rank(Pmatrix a): rang d'une matrice en forme de hermite
Definition: hermite.c:174
void matrix_coeff_nnul(Pmatrix, int *, int *, int)
void matrix_coeff_nnul(Pmatrix MAT, int * lg_nnul, int * cl_nnul, int level) renvoie les coordonnees ...
Definition: sub-matrix.c:421
bool matrix_triangular_unimodular_p(Pmatrix, bool)
bool matrix_triangular_unimodular_p(Pmatrix Z, bool inferieure) test de la triangulaire et unimodulai...
Definition: matrix.c:403
void matrix_sub_determinant(Pmatrix, int, int, Value[])
void matrix_perm_col(Pmatrix, int, int)
void matrix_perm_col(Pmatrix MAT, int k, int level): Calcul de la matrice de permutation permettant ...
Definition: sub-matrix.c:115
void matrix_subtraction_column(Pmatrix, int, int, Value)
void matrix_subtraction_column(Pmatrix MAT,int c1,int c2,int x): Soustrait x fois la colonne c2 de la...
Definition: matrix.c:518
void matrix_multiply(const Pmatrix, const Pmatrix, Pmatrix)
void matrix_multiply(Pmatrix a, Pmatrix b, Pmatrix c): multiply rational matrix a by rational matrix ...
Definition: matrix.c:95
void matrix_print(Pmatrix)
void matrix_print(matrice a): print an (nxm) rational matrix
Definition: matrix_io.c:70
void matrix_normalize(Pmatrix)
void matrix_normalize(Pmatrix a)
Definition: matrix.c:136
void matrix_unimodular_triangular_inversion(Pmatrix, Pmatrix, bool)
inversion.c
Definition: inversion.c:53
void matrix_maj_col(Pmatrix, Pmatrix, int)
void matrix_maj_col(Pmatrix A, matrice P, int level): Calcul de la matrice permettant de remplacer ch...
Definition: sub-matrix.c:256
void matrix_general_inversion(Pmatrix, Pmatrix)
void matrix_general_inversion(Pmatrix a; Pmatrix inv_a) calcul de l'inversion du matrice general.
Definition: inversion.c:216
int matrix_line_el(Pmatrix, int)
int matrix_line_el(Pmatrix MAT, int level) renvoie le numero de colonne absolu du premier element non...
Definition: sub-matrix.c:379
bool matrix_nulle_p(Pmatrix)
bool matrix_nulle_p(Pmatrix Z): test de nullite de la matrice Z
Definition: matrix.c:311
void matrix_identity(Pmatrix, int)
void matrix_identity(Pmatrix ID, int level) Construction d'une sous-matrice identity dans ID(level+1....
Definition: sub-matrix.c:322
Pmatrix matrix_new(int, int)
cproto-generated files
Definition: alloc.c:41
void matrix_subtraction_line(Pmatrix, int, int, Value)
void matrix_subtraction_line(Pmatrix MAT,int r1,int r2,int x): Soustrait x fois la ligne r2 de la lig...
Definition: matrix.c:541
void matrix_perm_line(Pmatrix, int, int)
void matrix_perm_line(Pmatrix MAT, int k, int level): Calcul de la matrice de permutation permettant...
Definition: sub-matrix.c:150
void matrix_pr_quot(FILE *, Value, Value)
Value matrix_elem(Pmatrix, int, int)
Definition: matrix.c:49
void matrix_swap_columns(Pmatrix, int, int)
void matrix_swap_columns(Pmatrix a, int c1, int c2): exchange columns c1,c2 of an (nxm) rational matr...
Definition: matrix.c:209
void matrix_fprint(FILE *, Pmatrix)
matrix_io.c
Definition: matrix_io.c:44
void matrix_rm(Pmatrix)
Definition: alloc.c:52
bool matrix_identity_p(Pmatrix, int)
bool matrix_identity_p(Pmatrix ID, int level) test d'une sous-matrice dans ID(level+1....
Definition: sub-matrix.c:352
void matrix_substract(Pmatrix, Pmatrix, Pmatrix)
void matrix_substract(Pmatrix a, Pmatrix b, Pmatrix c): substract rational matrix c from rational mat...
Definition: matrix.c:435
void matrix_add(Pmatrix, Pmatrix, Pmatrix)
a = b + c
Definition: matrix.c:471
void matrix_determinant(Pmatrix, Value[])
determinant.c
void matrix_smith(Pmatrix, Pmatrix, Pmatrix, Pmatrix)
smith.c
Definition: smith.c:68
void matrix_uminus(Pmatrix, Pmatrix)
void matrix_uminus(A, mA)
Definition: matrix.c:558
void matrix_fscan(FILE *, Pmatrix *, int *, int *)
void matrix_fscan(FILE * f, matrice * a, int * n, int * m): read an (nxm) rational matrix in an ASCII...
Definition: matrix_io.c:93
int matrix_line_nnul(Pmatrix, int)
sub-matrix.c
Definition: sub-matrix.c:72
int matrix_col_el(Pmatrix, int)
int matrix_col_el(Pmatrix MAT, int level) renvoie le numero de ligne absolu du premier element non nu...
Definition: sub-matrix.c:401
void matrix_diagonal_inversion(Pmatrix, Pmatrix)
void matrix_diagonal_inversion(Pmatrix s,Pmatrix inv_s) calcul de l'inversion du matrice en forme red...
Definition: inversion.c:93
void matrix_nulle(Pmatrix)
void matrix_nulle(Pmatrix Z): Initialisation de la matrice Z a la valeur matrice nulle
Definition: matrix.c:293
bool matrix_diagonal_p(Pmatrix)
bool matrix_diagonal_p(Pmatrix Z): test de nullite de la matrice Z
Definition: matrix.c:336
void matrix_min(Pmatrix, int *, int *, int)
void matrix_min(Pmatrix MAT, int * i_min, int * j_min, int level): Recherche des coordonnees (*i_min,...
Definition: sub-matrix.c:196
void matrix_maj_line(Pmatrix, Pmatrix, int)
void matrix_maj_line(Pmatrix A, matrice Q, int level): Calcul de la matrice permettant de remplacer c...
Definition: sub-matrix.c:294
void insert_sub_matrix(Pmatrix, Pmatrix, int, int, int, int)
void insert_sub_matrix(A, A_sub, i1, i2, j1, j2) input: matrix A and smaller A_sub output: nothing mo...
Definition: sub-matrix.c:487
bool matrix_triangular_p(Pmatrix, bool)
bool matrix_triangular_p(Pmatrix Z, bool inferieure): test de triangularite de la matrice Z
Definition: matrix.c:367
int matrices_to_1D_lattice(Pmatrix, Pmatrix, int, int, int, Value *, Value *)
Under the assumption A x = B, A[n,m] and B[n], compute the 1-D lattice for x_i of x[m] as.
Definition: smith.c:195
bool matrix_equality(Pmatrix, Pmatrix)
bool matrix_equality(Pmatrix A, Pmatrix B) test de l'egalite de deux matrices A et B; elles doivent a...
Definition: matrix.c:273
void matrix_normalizec(Pmatrix)
void matrix_normalizec(Pmatrix MAT): Normalisation des coefficients de la matrice MAT,...
Definition: matrix.c:187
void matrix_assign(Pmatrix, Pmatrix)
void matrix_assign(Pmatrix A, Pmatrix B) Copie de la matrice A dans la matrice B
Definition: matrix.c:259
package matrice
Definition: matrix-local.h:63