PIPS
matrix-local.h
Go to the documentation of this file.
1 /*
2 
3  $Id: matrix-local.h 1641 2016-03-02 08:20:19Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of Linear/C3 Library.
8 
9  Linear/C3 Library is free software: you can redistribute it and/or modify it
10  under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  Linear/C3 Library is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with Linear/C3 Library. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 
25 /* package matrice
26  *
27  * Neil Butler, Corinne Ancourt, Francois Irigoin, Yi-qing Yang
28  *
29  */
30 
31 /* Les matrices sont des matrices pleines, a coeffcients rationnels.
32  *
33  * Les matrices sont representes par des tableaux d'entiers mono-dimensionnels
34  * Elles sont stockees par colonne ("column-major"), comme en Fortran.
35  * Les indices commencent a 1, toujours comme en Fortran et non comme en C.
36  *
37  * Le denominateur doit etre strictement positif, i.e. plus grand ou egal
38  * a un. Un denominateur nul n'aurait pas de sens. Un denominateur negatif
39  * doublerait le nombre de representations possibles d'une matrice.
40  *
41  * Les matrices renvoyees par certaines routines, comme matrix_multiply(),
42  * ne sont pas normalisees par le pgcd des coefficients et du denominateur
43  * pour des raisons d'efficacite. Mais les routines de test, comme
44  * matrix_identity_p(), supposent leurs arguments normalises.
45  *
46  * Il faudrait sans doute introduire deux niveaux de procedure, un niveau
47  * externe sur garantissant la normalisation, et un niveau interne efficace
48  * sans normalisation automatique.
49  *
50  * La bibliotheque utilise une notion de sous-matrice, definie systematiquement
51  * par un parametre appele "level". Seuls les elements dont les indices
52  * de lignes et de colonnes sont superieurs a level+1
53  * sont pris en consideration. Il s'agit donc de sous-matrice dont le
54  * premier element se trouve sur la diagonale de la matrice complete et
55  * dont le dernier element et le dernier element de la matrice complete.
56  *
57  * Note: en cas detection d'incoherence, Neil Butler renvoyait un code
58  * d'erreur particulier; Francois Irigoin a supprime ces codes de retour
59  * et a traite les exceptions par des appels a assert(), et indirectement
60  * a abort()
61  */
62 
63 typedef struct {
69 
70 #define MATRIX_UNDEFINED ((Pmatrix) NULL)
71 
72 /* Allocation et desallocation d'une matrice */
73 #define matrix_free(m) (free(m), (m)=(Pmatrix) NULL)
74 
75 /* Macros d'acces aux elements d'une matrice */
76 
77 /* int MATRIX_ELEM(int * matrix, int i, int j):
78  * acces a l'element (i,j) de la matrice matrix.
79  */
80 #define MATRIX_ELEM(matrix, i, j) \
81  ((matrix)->coefficients[(((j)-1)*((matrix)->number_of_lines))+((i)-1)])
82 
83 /* int MATRIX_DENONIMATOR(matrix): acces au denominateur global
84  * d'une matrice matrix
85  */
86 #define MATRIX_DENOMINATOR(matrix) ((matrix)->denominator)
87 #define MATRIX_NB_LINES(matrix) ((matrix)->number_of_lines)
88 #define MATRIX_NB_COLUMNS(matrix) ((matrix)->number_of_columns)
89 
90 /* bool matrix_triangular_inferieure_p(matrice a):
91  * test de triangularite de la matrice a
92  */
93 #define matrix_triangular_inferieure_p(a) \
94  matrix_triangular_p(a, true)
95 
96 /* bool matrix_triangular_superieure_p(matrice a, int n, int m):
97  * test de triangularite de la matrice a
98  */
99 #define matrix_triangular_superieure_p(a) \
100  matrix_triangular_p(a, false)
101 
102 /* MATRIX_RIGHT_INF_ELEM Permet d'acceder des sous-matrices dont le
103  * coin infe'rieur droit (i.e. le premier element) se trouve sur la
104  * diagonal
105  */
106 #define SUB_MATRIX_ELEM(matrix, i, j, level) \
107  (matrix->coefficients[((j)-1+(level))* \
108  ((matrix)->number_of_lines) + (i) - 1 + (level)])
int Value
struct Pmatrix Smatrix
package matrice
Definition: matrix-local.h:63
Value * coefficients
Definition: matrix-local.h:67
int number_of_lines
Definition: matrix-local.h:65
int number_of_columns
Definition: matrix-local.h:66
Value denominator
Definition: matrix-local.h:64