Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

563604 views
1
#include "typedef.h"
2
#include "gmp.h"
3
/* #include "gmp-impl.h" */
4
#include "longtools.h"
5
#include "matrix.h"
6
/**************************************************************************\
7
@---------------------------------------------------------------------------
8
@---------------------------------------------------------------------------
9
@ FILE: long_kernel_mat.c
10
@---------------------------------------------------------------------------
11
@---------------------------------------------------------------------------
12
@
13
\**************************************************************************/
14
15
/************************************************************************\
16
@ matrix_TYP *long_kernel_mat(A)
17
@ matrix_TYP *A;
18
@
19
@ long_kernel_mat(A) calculates Matrix X with AX = 0
20
@ the cols of X are a Z-basis of the solution space.
21
@ The functions uses GNU MP
22
\************************************************************************/
23
matrix_TYP *long_kernel_mat(A)
24
matrix_TYP *A;
25
{
26
MP_INT ***E, **MA;
27
MP_INT Ekgv;
28
int Ecols, i,j;
29
matrix_TYP *erg, *ergt;
30
31
32
MA = matrix_to_MP_mat(A);
33
mpz_init(&Ekgv);
34
E = MP_solve_mat(MA, A->rows, A->cols, NULL, 0, &Ecols, &Ekgv);
35
for(i=0;i<A->rows;i++)
36
{
37
for(j=0;j<A->cols;j++)
38
mpz_clear(&MA[i][j]);
39
free(MA[i]);
40
}
41
free(MA);
42
43
44
if(E[1] != NULL)
45
{
46
erg = MP_mat_to_matrix(E[1], Ecols, A->cols);
47
for(i=0;i<Ecols;i++)
48
{
49
for(j=0;j<A->cols;j++)
50
mpz_clear(&E[1][i][j]);
51
free(E[1][i]);
52
}
53
free(E[1]);
54
}
55
else
56
erg = NULL;
57
free(E);
58
mpz_clear(&Ekgv);
59
60
if (erg){
61
ergt = tr_pose(erg);
62
}
63
else{
64
ergt = NULL;
65
}
66
67
/* inserted the if 28/1/97 tilman, problems with a matrix having
68
0 rows */
69
if (erg != NULL){
70
free_mat(erg);
71
}
72
return(ergt);
73
}
74
75