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
6
main (int argc, char *argv[])
7
{
8
int anz,
9
i,
10
j,
11
k,
12
rows,
13
cols;
14
15
char comment[1000];
16
17
matrix_TYP **F,
18
*tmp;
19
20
read_header(argc, argv);
21
if(FILEANZ < 1 || is_option('h'))
22
{
23
printf("Usage: %s 'file' [-c=n1] [-r=n2]\n",argv[0]);
24
printf("\n");
25
printf("file: matrix_TYP.\n");
26
printf("\n");
27
printf("Writes the lines of the matrices given in file in\n");
28
printf("seperate matrices. The default assumption is that\n");
29
printf("the resulting matrices should be square.\n");
30
printf("In case either option r or c are given, the matrices\n");
31
printf("are given as n2xn1 matrices, where n1*n2=#columns of the\n");
32
printf("matrices of file.\n");
33
printf("Note that this function does exactly the inverse of Mtl!\n");
34
printf("\n");
35
printf("OPTIONS:\n");
36
printf("\n");
37
printf("-c=n1: the matrices will have n1 columns.\n");
38
printf("-r=n2: the matrices will have n2 rows.\n");
39
printf("\n");
40
printf("Cf. Mtl\n");
41
if (is_option('h')){
42
exit(0);
43
}
44
else{
45
exit(31);
46
}
47
}
48
49
F = mget_mat(FILENAMES[0],&anz);
50
51
for (i=0;i<anz;i++){
52
rat2kgv(F[i]);
53
if ((F[i]->cols != F[0]->cols) || (F[i]->rows != F[0]->rows)){
54
printf("The matrices given in %s must have same dimensions\n",
55
FILENAMES[0]);
56
exit(3);
57
}
58
}
59
60
if (is_option('r') && is_option('c')){
61
rows=optionnumber('r');
62
cols=optionnumber('c');
63
}
64
else if(is_option('r')){
65
rows = optionnumber('r');
66
cols = floor(F[0]->cols/rows + 0.5);
67
}
68
else if(is_option('c')){
69
cols = optionnumber('c');
70
rows = floor(F[0]->cols/cols + 0.5);
71
}
72
else{
73
cols = floor(sqrt(F[0]->cols)+0.5);
74
rows = floor(sqrt(F[0]->cols)+0.5);
75
}
76
77
if ((rows*cols) != F[0]->cols){
78
printf("The specification is not suitable\n");
79
exit(3);
80
}
81
82
printf("#%d\n",anz*F[0]->rows);
83
84
tmp = init_mat(rows,cols,"");
85
86
for (i=0;i<anz;i++){
87
for (j=0;j<F[0]->rows;j++){
88
tmp->kgv = F[i]->kgv;
89
for (k=0;k<F[0]->cols;k++){
90
tmp->array.SZ[(k - (k%cols))/cols][k % cols]=F[i]->array.SZ[j][k];
91
}
92
sprintf(comment,"Ltm on file %s",FILENAMES[0]);
93
Check_mat(tmp);
94
put_mat(tmp,NULL,comment,2);
95
}
96
}
97
98
99
exit(0);
100
}
101
102
103