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
/**************************************************************************\
3
@---------------------------------------------------------------------------
4
@---------------------------------------------------------------------------
5
@ FILE: hyp_isom.c
6
@---------------------------------------------------------------------------
7
@---------------------------------------------------------------------------
8
@
9
\**************************************************************************/
10
11
12
13
/**************************************************************************\
14
@---------------------------------------------------------------------------
15
@ matrix_TYP *hyperbolic_isometry(x1, x2, S)
16
@ matrix_TYP *x1, *x2, *S;
17
@
18
@ The first row in the matrix x1 (resp. x2) is interpreted as a vector
19
@ v1 (resp. v2) in Z^n.
20
@ The function calculates a matrix A in GL_n(Q) (if exists) with
21
@ v1A = v2 and ASA^{tr} = S
22
@ Any integral matrix with this property must be of the form BA where
23
@ B is a matrix of the group that can be caluclated with
24
@ B = hyperbolic_stabilizer(x1, S)
25
@---------------------------------------------------------------------------
26
@
27
\**************************************************************************/
28
matrix_TYP *hyperbolic_isometry(x1, x2, S)
29
matrix_TYP *x1, *x2, *S;
30
{
31
matrix_TYP *x1S, *x2S, *x1SO, *x2SO, **S1red, **S2red, *T1,*T1i, *T2;
32
matrix_TYP *Y1, *Y1i, *Y2, *Y;
33
int i,j,k, n;
34
35
extern matrix_TYP *solve_mat();
36
extern matrix_TYP *mat_mul();
37
extern matrix_TYP *mat_inv();
38
extern matrix_TYP *scal_pr();
39
extern matrix_TYP *pr_isom();
40
extern matrix_TYP *init_mat();
41
42
n = x1->cols;
43
if((S1red = (matrix_TYP **)malloc(1 *sizeof(matrix_TYP *))) == NULL)
44
{
45
printf("malloc of 'S1red' in 'hyperbolic_isometry' failed\n");
46
exit(2);
47
}
48
if((S2red = (matrix_TYP **)malloc(1 *sizeof(matrix_TYP *))) == NULL)
49
{
50
printf("malloc of 'S2red' in 'hyperbolic_isometry' failed\n");
51
exit(2);
52
}
53
x1S = mat_mul(x1, S);
54
x1SO = solve_mat(x1S);
55
S1red[0] = scal_pr(x1SO, S, 1);
56
x2S = mat_mul(x2, S);
57
x2SO = solve_mat(x2S);
58
S2red[0] = scal_pr(x2SO, S, 1);
59
Y1 = pr_isom(S1red, S2red, 1, NULL, 0, NULL);
60
free_mat(S1red[0]); free(S1red);
61
free_mat(S2red[0]); free(S2red);
62
free_mat(x1S); free_mat(x2S);
63
if(Y1 == NULL)
64
{
65
free_mat(x1SO); free_mat(x2SO);
66
return(NULL);
67
}
68
T1 = init_mat(n,n,"");
69
for(i=0;i<n-1;i++)
70
for(j=0;j<n;j++)
71
T1->array.SZ[i][j] = x1SO->array.SZ[i][j];
72
for(i=0;i<n;i++)
73
T1->array.SZ[n-1][i] = x1->array.SZ[0][i];
74
T1i = mat_inv(T1);
75
free_mat(T1);
76
free_mat(x1SO);
77
78
T2 = init_mat(n,n,"");
79
Y1i = mat_inv(Y1);
80
Y2 = mat_mul(Y1i, x2SO);
81
for(i=0;i<n-1;i++)
82
for(j=0;j<n;j++)
83
T2->array.SZ[i][j] = Y2->array.SZ[i][j];
84
for(i=0;i<n;i++)
85
T2->array.SZ[n-1][i] = x2->array.SZ[0][i];
86
free_mat(x2SO);
87
free_mat(Y2);
88
free_mat(Y1);
89
free_mat(Y1i);
90
91
Y = mat_mul(T1i, T2);
92
free_mat(T1i); free_mat(T2);
93
return(Y);
94
}
95
96