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 <matrix.h>
4
#include <base.h>
5
6
#include <longtools.h>
7
#include <bravais.h>
8
#include <idem.h>
9
10
int INFO_LEVEL;
11
extern int SFLAG;
12
13
main(int argc,char **argv){
14
15
matrix_TYP **x,
16
*y,
17
*z;
18
19
char comment[1000];
20
21
int i,
22
j,
23
anz;
24
25
read_header(argc,argv);
26
27
if ((is_option('h') && optionnumber('h')==0) || (FILEANZ < 1)){
28
printf("Usage: %s file [-r]\n",argv[0]);
29
printf("\n");
30
printf("file: matrix_TYP containing a set of integral square matrices.\n");
31
printf("\n");
32
printf("Calculates the minimal polynomial of each matrix in file.\n");
33
printf("WARNING: If a given matrix is not integral, the result will be incorrect.\n");
34
printf("\n");
35
printf("-r : calculate the integral roots of the given polynomials.\n");
36
printf("\n");
37
if (is_option('h')){
38
exit(0);
39
}
40
else{
41
exit(31);
42
}
43
}
44
45
INFO_LEVEL = optionnumber('h');
46
47
if (INFO_LEVEL & 12){
48
SFLAG = 1;
49
}
50
51
x = mget_mat(FILENAMES[0],&anz);
52
53
for (j=0;j<anz;j++){
54
y = min_pol(x[j]);
55
56
printf("The minimal polynomial to the %d matrix of %s\n",j+1,FILENAMES[0]);
57
58
if (y->array.SZ[0][y->cols-1] == 1)
59
printf(" X^%d",y->cols-1);
60
else
61
printf(" %d * X^%d",y->array.SZ[0][y->cols-1],y->cols-1);
62
63
for (i=y->cols-2;i>0;i--)
64
if (y->array.SZ[0][i] > 1)
65
printf(" + %d * X^%d",y->array.SZ[0][i],i);
66
else if (y->array.SZ[0][i] < -1)
67
printf(" - %d * X^%d",-(y->array.SZ[0][i]),i);
68
else if (y->array.SZ[0][i] == -1)
69
printf(" - X^%d",i);
70
else if (y->array.SZ[0][i] == 1)
71
printf(" + X^%d",i);
72
73
if (y->array.SZ[0][0]>0)
74
printf(" + %d \n",y->array.SZ[0][0]);
75
else if (y->array.SZ[0][0]<0)
76
printf(" - %d \n",-(y->array.SZ[0][0]));
77
78
printf("\n");
79
/* put_mat(y,NULL,NULL,2); */
80
81
if (is_option('r')){
82
z = zeros(y);
83
printf("Integral roots of the polynomial\n");
84
put_mat(z,NULL,NULL,2);
85
free_mat(z);
86
}
87
88
free_mat(y);
89
free_mat(x[j]);
90
}
91
92
free(x);
93
94
if (INFO_LEVEL & 12){
95
pointer_statistics(0,0);
96
}
97
98
exit(1);
99
100
} /* main */
101
102