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

563665 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_hnf.c
10
@---------------------------------------------------------------------------
11
@---------------------------------------------------------------------------
12
@ The function to the same as the functions in long_gauss.c,
13
@ they additionaly clear the columns upwards and transform 'Mat'
14
@ to a matrix in Hermite-normal-form
15
\**************************************************************************/
16
17
18
/**************************************************************************\
19
@---------------------------------------------------------------------------
20
@ int long_row_hnf(Mat)
21
@ matrix_TYP *Mat;
22
@
23
@---------------------------------------------------------------------------
24
\**************************************************************************/
25
int long_row_hnf(Mat)
26
matrix_TYP *Mat;
27
{
28
int rang;
29
MP_INT **M;
30
31
M = matrix_to_MP_mat(Mat);
32
rang = MP_hnf(M, Mat->rows, Mat->cols);
33
write_MP_mat_to_matrix(Mat, M);
34
free_MP_mat(M, Mat->rows, Mat->cols);
35
free(M);
36
return(rang);
37
}
38
39
int long_col_hnf(Mat)
40
matrix_TYP *Mat;
41
{
42
int i,
43
j,
44
rang;
45
46
matrix_TYP *Mattr;
47
48
Mattr = tr_pose(Mat);
49
50
rang = long_row_hnf(Mattr);
51
52
/* transpose the array */
53
for (i=0;i<Mat->cols;i++)
54
for (j=0;j<Mat->rows;j++)
55
Mat->array.SZ[j][i] = Mattr->array.SZ[i][j];
56
57
Check_mat(Mat);
58
free_mat(Mattr);
59
60
return rang;
61
}
62
63
/**************************************************************************\
64
@---------------------------------------------------------------------------
65
@ int long_row_trf_hnf(Mat, T)
66
@ matrix_TYP *Mat, *T;
67
@
68
@---------------------------------------------------------------------------
69
\**************************************************************************/
70
int long_row_trf_hnf(M, T)
71
matrix_TYP *M, *T;
72
{
73
int rang;
74
MP_INT **N, **S;
75
76
N = matrix_to_MP_mat(M);
77
S = init_MP_mat(M->rows, M->rows);
78
rang = MP_trf_hnf(N, S, M->rows, M->cols);
79
write_MP_mat_to_matrix(M, N);
80
write_MP_mat_to_matrix(T, S);
81
free_MP_mat(N, M->rows, M->cols); free_MP_mat(S, M->rows, M->rows);
82
free(N); free(S);
83
return(rang);
84
}
85
86
87
88
89
/**************************************************************************\
90
@---------------------------------------------------------------------------
91
@ int long_row_hnf_simultaneous(A, B)
92
@ matrix_TYP *A, *B;
93
@
94
@---------------------------------------------------------------------------
95
\**************************************************************************/
96
int long_row_hnf_simultaneous(A, B)
97
matrix_TYP *A, *B;
98
{
99
int rang;
100
MP_INT **MA, **MB;
101
102
MA = matrix_to_MP_mat(A);
103
MB = matrix_to_MP_mat(B);
104
rang = MP_hnf_simultaneous(MA, A->rows, A->cols, MB, B->cols);
105
write_MP_mat_to_matrix(A, MA);
106
write_MP_mat_to_matrix(B, MB);
107
free_MP_mat(MA, A->rows, A->cols); free_MP_mat(MB, B->rows, B->cols);
108
free(MA); free(MB);
109
return(rang);
110
}
111
112