polylib 5.22.8
NormalForms.c File Reference
#include <polylib/polylib.h>
#include <stdlib.h>

Go to the source code of this file.

Functions

static void moins_l (Value *a, int i, int n, int p)
 
static void moins_c (Value *a, int i, int n, int p)
 
static void echange_l (Value *a, int i, int j, int n, int p)
 
static void echange_c (Value *a, int i, int j, int n, int p)
 
static void ligne (Value *a, int i, int j, Value x, int n, int p)
 
static void colonne (Value *a, int i, int j, Value x, int n, int p)
 
static int petit_l (Value *a, int n, int p, int q)
 
static int petit_c (Value *a, int n, int p, int q)
 
static void identite (Value *a, int n, int p)
 
static void transpose (Value *a, int n, int q)
 
static int encore (Value *a, int n, int p, int q, Value val)
 
static void smith (Value *a, Value *b, Value *c, Value *b_inverse, Value *c_inverse, int n, int p, int q)
 
static void hermite (Value *a, Value *b, Value *d, int n, int p, int q)
 
static Value * ConvertPolMattoDarMat (Matrix *A)
 Convert PolmattoDarmat : This function converts the matrix of a Polylib to a int * as necessary for the functions in Darte's implementation. More...
 
static MatrixConvertDarMattoPolMat (Value *A, int NbRows, int NbCols)
 Convert DarmattoPolmat This function converts the matrix from Darte representation to a matrix in PolyLib. More...
 
void Smith (Matrix *A, Matrix **U, Matrix **V, Matrix **Product)
 Smith : This function takes a Matrix A of dim n * l as its input and returns the three matrices U, V and Product such that A = U * Product * V, where U is an unimodular matrix of dimension n * n and V is an unimodular matrix of dimension l * l. More...
 
void Hermite (Matrix *A, Matrix **H, Matrix **U)
 Hermite : This function takes a Matrix as its input and finds its HNF ( Left form ) More...
 

Function Documentation

◆ colonne()

static void colonne ( Value *  a,
int  i,
int  j,
Value  x,
int  n,
int  p 
)
static

Definition at line 129 of file NormalForms.c.

References n, and value_addmul.

Referenced by hermite(), and smith().

◆ ConvertDarMattoPolMat()

static Matrix * ConvertDarMattoPolMat ( Value *  A,
int  NbRows,
int  NbCols 
)
static

Convert DarmattoPolmat This function converts the matrix from Darte representation to a matrix in PolyLib.

Input : The matrix (a pointer to it), number of Rows, number of columns Output : The matrix of the PolyLib

Definition at line 598 of file NormalForms.c.

References Matrix_Alloc(), matrix::p, and value_assign.

Referenced by Hermite().

◆ ConvertPolMattoDarMat()

static Value * ConvertPolMattoDarMat ( Matrix A)
static

Convert PolmattoDarmat : This function converts the matrix of a Polylib to a int * as necessary for the functions in Darte's implementation.

Input : A Polylib Matrix ( a pointer to it ); Output : An int * with the matrix copied into it

Definition at line 574 of file NormalForms.c.

References matrix::NbColumns, matrix::NbRows, matrix::p, value_assign, and value_init.

Referenced by Hermite().

◆ echange_c()

static void echange_c ( Value *  a,
int  i,
int  j,
int  n,
int  p 
)
static

Definition at line 76 of file NormalForms.c.

References n, s, value_assign, value_clear, and value_init.

Referenced by hermite(), and smith().

◆ echange_l()

static void echange_l ( Value *  a,
int  i,
int  j,
int  n,
int  p 
)
static

Definition at line 50 of file NormalForms.c.

References s, value_assign, value_clear, and value_init.

Referenced by hermite(), and smith().

◆ encore()

static int encore ( Value *  a,
int  n,
int  p,
int  q,
Value  val 
)
static

Definition at line 314 of file NormalForms.c.

References n, value_absolute, value_clear, value_init, value_modulus, value_notzero_p, and value_zero_p.

Referenced by smith().

◆ Hermite()

void Hermite ( Matrix A,
Matrix **  H,
Matrix **  U 
)

Hermite : This function takes a Matrix as its input and finds its HNF ( Left form )

Input : A Matrix A (The Matrix A is not necessarily a Polylib matrix. It is just a matrix as far as Hermite is concerned. It does not even check if the matrix is a Polylib matrix or not) Output : The Hnf matrix H and the Unimodular matrix U such that A = H * U.

We use Alan Darte's implementation of Hermite to compute the HNF. Alan Darte's implementation computes the Upper Triangular HNF. So We work on the fact that if A = H * U then A (transpose) = U(transpose) * H (transpose) There are a set of interface functions written in Interface.c which convert a matrix from Polylib representationt to that of Alan Darte's and vice versa.

This Function Does the Following Step 1 : Given the matrix A it finds its Transpose. Step 2 : Finds the HNF (Right Form) using Alan Darte's Algorithm. Step 3 : The H1 and U1 obtained in Step2 are both Transposed to get the actual H and U such that A = HU.

Definition at line 663 of file NormalForms.c.

References ConvertDarMattoPolMat(), ConvertPolMattoDarMat(), hermite(), identite(), Matrix_Copy(), Matrix_Free(), matrix::NbColumns, matrix::NbRows, Transpose(), transpose(), value_clear, and value_init.

Referenced by AffineHermite(), findHermiteBasis(), isfulldim(), RearrangeMatforSolveDio(), and SolveDiophantine().

◆ hermite()

static void hermite ( Value *  a,
Value *  b,
Value *  d,
int  n,
int  p,
int  q 
)
static

◆ identite()

static void identite ( Value *  a,
int  n,
int  p 
)
static

Definition at line 257 of file NormalForms.c.

References n, and value_set_si.

Referenced by Hermite().

◆ ligne()

static void ligne ( Value *  a,
int  i,
int  j,
Value  x,
int  n,
int  p 
)
static

Definition at line 104 of file NormalForms.c.

References value_addmul.

Referenced by hermite(), and smith().

◆ moins_c()

static void moins_c ( Value *  a,
int  i,
int  n,
int  p 
)
static

Definition at line 31 of file NormalForms.c.

References n, and value_oppose.

Referenced by hermite(), and smith().

◆ moins_l()

static void moins_l ( Value *  a,
int  i,
int  n,
int  p 
)
static

Definition at line 12 of file NormalForms.c.

References value_oppose.

Referenced by hermite(), and smith().

◆ petit_c()

static int petit_c ( Value *  a,
int  n,
int  p,
int  q 
)
static

Definition at line 209 of file NormalForms.c.

References n, value_absolute, value_assign, value_clear, value_ge, value_init, and value_notzero_p.

Referenced by hermite(), and smith().

◆ petit_l()

static int petit_l ( Value *  a,
int  n,
int  p,
int  q 
)
static

Definition at line 156 of file NormalForms.c.

References value_absolute, value_assign, value_clear, value_ge, value_init, and value_notzero_p.

Referenced by smith().

◆ Smith()

void Smith ( Matrix A,
Matrix **  U,
Matrix **  V,
Matrix **  Product 
)

Smith : This function takes a Matrix A of dim n * l as its input and returns the three matrices U, V and Product such that A = U * Product * V, where U is an unimodular matrix of dimension n * n and V is an unimodular matrix of dimension l * l.

Product is a diagonal matrix of dimension n * l.

We use Alan Darte's implementation of Smith for computing the Smith Normal Form

Definition at line 621 of file NormalForms.c.

References Identity(), Matrix_Copy(), Matrix_Free(), matrix::NbColumns, matrix::NbRows, matrix::p_Init, and smith().

Referenced by AffineSmith(), and Lattice2LatticeUnion().

◆ smith()

static void smith ( Value *  a,
Value *  b,
Value *  c,
Value *  b_inverse,
Value *  c_inverse,
int  n,
int  p,
int  q 
)
static

◆ transpose()

static void transpose ( Value *  a,
int  n,
int  q 
)
static

Definition at line 282 of file NormalForms.c.

References n, transpose(), value_assign, value_clear, and value_init.

Referenced by Hermite(), Transpose(), and transpose().