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

563516 views
1
#include"typedef.h"
2
#include"getput.h"
3
#include"bravais.h"
4
#include"matrix.h"
5
#include"datei.h"
6
7
8
/* ---------------------------------------- */
9
/* Convert a single matrix in MAPLE format. */
10
/* ---------------------------------------- */
11
static void conv_mat_to_maple(matrix_TYP *A,
12
int i,
13
char *name){
14
int j, k;
15
16
17
Check_mat(A);
18
if (!A->flags.Integral){
19
rat2kgv(A);
20
}
21
printf("%s%d := array(1..%d,1..%d,[\n", name, i+1, A->rows, A->cols);
22
for (j=0;j<A->rows;j++){
23
printf("[");
24
for (k=0;k<A->cols;k++){
25
printf(" %d",A->array.SZ[j][k]);
26
if (!A->flags.Integral){
27
printf("/%d",A->kgv);
28
}
29
if (k!=(A->cols-1)){
30
printf(",");
31
}
32
}
33
if (j != (A->rows-1)){
34
printf("],\n");
35
}
36
else{
37
printf("]");
38
}
39
}
40
printf("]):\n");
41
}
42
43
44
45
/* ---------------------------------------- */
46
/* Convert a single matrix in GAP format. */
47
/* ---------------------------------------- */
48
static void conv_mat_to_gap(matrix_TYP *A,
49
int i,
50
char *name){
51
int j, k;
52
53
54
Check_mat(A);
55
if (!A->flags.Integral){
56
rat2kgv(A);
57
}
58
printf("%s%d := [", name, i+1);
59
for (j=0;j<A->rows;j++){
60
printf("[");
61
for (k=0;k<A->cols;k++){
62
printf(" %d",A->array.SZ[j][k]);
63
if (!A->flags.Integral){
64
printf("/%d",A->kgv);
65
}
66
if (k!=(A->cols-1)){
67
printf(",");
68
}
69
}
70
if (j != (A->rows-1)){
71
printf("],\n");
72
}
73
else{
74
printf("]");
75
}
76
}
77
printf("];;\n");
78
}
79
80
81
82
/* ---------------------------------------- */
83
/* Convert a single matrix in TeX format. */
84
/* ---------------------------------------- */
85
static void conv_mat_to_tex(matrix_TYP *A){
86
87
int j, k;
88
89
90
Check_mat(A);
91
if (!A->flags.Integral){
92
rat2kgv(A);
93
}
94
printf("\\left(\\begin{array}{");
95
for (j = 0; j < A->cols; j++)
96
printf("c");
97
printf("}\n");
98
for (j = 0; j < A->rows; j++){
99
for (k = 0;k < A->cols; k++){
100
if (A->array.SZ[j][k] % A->kgv == 0)
101
printf("%d ", A->array.SZ[j][k]/ A->kgv);
102
else
103
printf("%d/%d ", A->array.SZ[j][k], A->kgv);
104
if (k != A->cols - 1)
105
printf("& ");
106
}
107
printf("\\\\\n");
108
}
109
printf("\\end{array}\\right)\n");
110
}
111
112
113
114
/* ---------------------------------------- */
115
/* Main function. */
116
/* ---------------------------------------- */
117
int main (int argc, char *argv[])
118
{
119
int i,
120
anz,
121
flag;
122
123
matrix_TYP **A;
124
125
bravais_TYP *G;
126
127
char *name;
128
129
130
read_header(argc, argv);
131
if(FILEANZ < 1 || (is_option('h') && optionnumber('h') == 0) )
132
{
133
printf("Usage: Conv 'file' ['name'] -g -G -m -M -t -T\n");
134
printf("\n");
135
printf("file: matrix_TYP or bravais_TYP (only generators are converted).\n");
136
printf("name: (optional) a word\n");
137
printf("\n");
138
printf("Converts the matrix_TYP into the format of other\n");
139
printf("programs available. The options specify the program,\n");
140
printf("and only one of them is allowed at one time.\n");
141
printf("First of all the number of matrices is printed.\n");
142
printf("The matrices are called 'name.1', 'name.2', ... or\n");
143
printf("if name isn't given 'a.1', 'a.2', ...\n");
144
printf("\n");
145
printf("-g or -G: GAP-format\n");
146
printf("-m or -M: MAPLE-format\n");
147
printf("-t or -T: TeX-format (the matrices aren't named and\n");
148
printf(" the number of matrices isn't given)\n");
149
printf("\n");
150
if (is_option('h')){
151
exit(0);
152
}
153
else{
154
exit(31);
155
}
156
}
157
158
G = get_bravais(FILENAMES[0]);
159
anz = G->gen_no;
160
A = G->gen;
161
162
if (FILEANZ < 2)
163
name = "a";
164
else
165
name = FILENAMES[1];
166
167
flag = 0;
168
if (is_option('t') || is_option('T'))
169
flag = 3;
170
if (is_option('m') || is_option('M'))
171
flag = 2;
172
if (is_option('g') || is_option('G'))
173
flag = 1;
174
175
if (flag > 0 && flag < 3)
176
printf("%sNo := %i", name, anz);
177
178
switch(flag){
179
case 2:
180
printf(":\n");
181
for (i = 0; i < anz; i++)
182
conv_mat_to_maple(A[i], i, name);
183
break;
184
185
case 1:
186
printf(";;\n");
187
for (i = 0; i < anz; i++)
188
conv_mat_to_gap(A[i], i, name);
189
break;
190
191
case 3:
192
for (i = 0; i < anz; i++)
193
conv_mat_to_tex(A[i]);
194
break;
195
196
default:
197
printf("\nYou must specify at least one option. Try -h first.\n");
198
}
199
200
A = NULL;
201
free_bravais(G);
202
203
exit(0);
204
}
205
206
207
208
209
210
211
212
213
214
215
216