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

563640 views
1
/****************************************************************************
2
**
3
*A FreeSpace.c ANUPQ source Eamonn O'Brien
4
**
5
*Y Copyright 1995-2001, Lehrstuhl D fuer Mathematik, RWTH Aachen, Germany
6
*Y Copyright 1995-2001, School of Mathematical Sciences, ANU, Australia
7
**
8
*/
9
10
#include "pq_defs.h"
11
#include "pga_vars.h"
12
#include "pcp_vars.h"
13
14
/* free space used by vector, a, whose first index is start */
15
16
void free_vector(int *a, int start)
17
{
18
19
#ifdef DEBUG
20
printf("Free vector\n");
21
#endif
22
23
if (start)
24
++a;
25
free(a);
26
}
27
28
/* free space used by matrix, a, whose indices commence at either 0 or 1 */
29
30
void free_matrix(int **a, int n, int start)
31
{
32
register int i;
33
#ifdef DEBUG
34
printf("Free matrix\n");
35
#endif
36
37
if (n == 0)
38
n = 1;
39
40
for (i = start; i < start + n; ++i) {
41
if (start)
42
++a[i];
43
free(a[i]);
44
}
45
46
if (start)
47
++a;
48
free(a);
49
}
50
51
/* free space used by array, a, whose indices commence at either 0 or 1 */
52
53
void free_array(int ***a, int n, int m, int start)
54
{
55
register int i, j;
56
#ifdef DEBUG
57
printf("Free array\n");
58
#endif
59
60
if (n == 0)
61
n = 1;
62
if (m == 0)
63
m = 1;
64
65
for (i = start; i < start + n; ++i) {
66
for (j = start; j < start + m; ++j) {
67
if (start)
68
++a[i][j];
69
free(a[i][j]);
70
}
71
if (start)
72
++a[i];
73
free(a[i]);
74
}
75
76
if (start)
77
++a;
78
free(a);
79
}
80
81
/* free space used by character vector, a, whose first index is start */
82
83
void free_char_vector(char *a, int start)
84
{
85
86
#ifdef DEBUG
87
printf("Free char vector\n");
88
#endif
89
90
if (start)
91
++a;
92
free(a);
93
}
94
95
/* free space used by character matrix, a */
96
97
void free_char_matrix(char **a, int n)
98
{
99
register int i;
100
#ifdef DEBUG
101
printf("Free char matrix\n");
102
#endif
103
104
if (n == 0)
105
n = 1;
106
107
for (i = 0; i < n; ++i)
108
free(a[i]);
109
110
free(a);
111
}
112
113
/* free space used in computing orbits and stabilisers */
114
115
void free_space(Logical soluble_computation,
116
int **perms,
117
int *orbit_length,
118
int *a,
119
int *b,
120
char *c,
121
struct pga_vars *pga)
122
{
123
int nmr_of_perms = (pga->space_efficient ? 1 : pga->nmr_of_perms);
124
125
#ifdef DEBUG
126
printf("Free space routine\n");
127
#endif
128
129
free_matrix(perms, nmr_of_perms, 1);
130
free_vector(orbit_length, 1);
131
free_vector(a, 1);
132
if (soluble_computation) {
133
free_vector(b, 1);
134
free_char_vector(c, 1);
135
}
136
free_vector(pga->map, 1);
137
free_vector(pga->rep, 1);
138
free_vector(pga->powers, 0);
139
free_vector(pga->inverse_modp, 0);
140
}
141
142