PIPS
|
#include <stdio.h>
#include <stdlib.h>
#include "linear_assert.h"
#include "boolean.h"
#include "arithmetique.h"
#include "matrice.h"
Go to the source code of this file.
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.
References B.
Referenced by matrice_hermite(), and matrice_smith().
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.
References ACCESS, and value_notzero_p.
Referenced by matrice_diagonale_inversion().
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.
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
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
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
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
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
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.
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().
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
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.
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().
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()
MAT | AT |
Definition at line 175 of file matrice.c.
References pgcd, value_division, value_gt, and VALUE_ONE.
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.
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().
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.
References ACCESS, and value_notzero_p.
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 colonne c2 de la colonne c1 Precondition: n > 0; m > 0; 0 < c1, c2 < m; Effet: c1[0..n-1] = c1[0..n-1] - x*c2[0..n-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 c1 : numero du colonne int c2 : numero du colonne int x :
Definition at line 523 of file matrice.c.
References ACCESS, value_product, value_substract, and x.
Referenced by matrice_hermite(), matrice_smith(), and matrice_unimodulaire_triangulaire_inversion().
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 :
MAT | AT |
r1 | 1 |
r2 | 2 |
Definition at line 554 of file matrice.c.
References ACCESS, value_product, value_substract, and x.
Referenced by matrice_smith().
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
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
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.
References ACCESS, assert, DENOMINATOR, ppcm(), value_div, value_minus, value_pos_p, and value_product.
Referenced by unstructured_to_complexity().
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
matrix | atrix |
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 |
c2 | 2 |
Definition at line 200 of file matrice.c.
References ACCESS, assert, and loop1.
Referenced by matrice_hermite(), and matrice_smith().
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
n | Precondition: n > 0; m > 0; 1 <= r1 <= n; 1 <= r2 <= n input and output matrix |
m | Precondition: n > 0; m > 0; 1 <= r1 <= n; 1 <= r2 <= n number of columns |
r1 | Precondition: n > 0; m > 0; 1 <= r1 <= n; 1 <= r2 <= n number of rows |
r2 | 2 |
Definition at line 230 of file matrice.c.
References ACCESS, assert, and loop1.
Referenced by matrice_hermite(), matrice_smith(), and scanning_base_hyperplane().
package matrice
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
a_t | _t |
Definition at line 48 of file matrice.c.
References ACCESS, assert, DENOMINATOR, and loop1.
Referenced by base_G_h1_unnull(), broadcast_conditions(), make_primal(), partial_broadcast_coefficients(), and system_inversion_restrict().
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
inferieure | nferieure |
Definition at line 394 of file matrice.c.
References ACCESS, and value_notzero_p.
Referenced by matrice_triangulaire_inversion(), and matrice_triangulaire_unimodulaire_p().
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
inferieure | nferieure |
Definition at line 434 of file matrice.c.
References ACCESS, matrice_triangulaire_p(), and value_notone_p.
Referenced by matrice_unimodulaire_inversion(), and matrice_unimodulaire_triangulaire_inversion().