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

563667 views
1
#include "typedef.h"
2
#include "datei.h"
3
4
static int smaller(char *s1,char *s2)
5
{
6
7
int i,
8
j;
9
10
/* the first criterion is the dimension */
11
sscanf(s1,"%d",&i);
12
sscanf(s2,"%d",&j);
13
14
if (i<j){
15
return TRUE;
16
}
17
else if (i>j){
18
return FALSE;
19
}
20
21
/* are these multiples of the same symbol ? */
22
i = strcspn(s1,",");
23
j = strcspn(s2,",");
24
if ( (i==j) && strncmp(s1,s2,i)==0){
25
if (strlen(s1)<strlen(s2)){
26
return TRUE;
27
}
28
else{
29
return FALSE;
30
}
31
}
32
33
/* we are now in the position to distinguish it on one atomic symbol */
34
/* the symbol has to contain a '-' now */
35
s1 = strchr(s1,'-');
36
s2 = strchr(s2,'-');
37
s1++;
38
s2++;
39
sscanf(s1,"%d",&i);
40
sscanf(s2,"%d",&j);
41
42
if (i>j){
43
return TRUE;
44
}
45
else if (i<j){
46
return FALSE;
47
}
48
49
/* now one of them is of the form a-b', and the other one of a-b */
50
/* a-b' < a-b */
51
if (strchr(s1,'\'') == NULL){
52
return TRUE;
53
}
54
55
return FALSE;
56
}
57
58
void right_order(char *string)
59
{
60
61
int i,
62
j,
63
ordered,
64
hom_no;
65
66
char *irr_symbol[MAXDIM],
67
*tmp,
68
*tmp2,
69
*tmp3;
70
71
for (i=0;i<MAXDIM;i++){
72
irr_symbol[i] = (char *) calloc(20 , sizeof(char));
73
}
74
75
tmp = (char *) calloc(20 * MAXDIM, sizeof(char));
76
77
/* get the irreducible symbols, ie. those seperated by `;' */
78
strcpy(tmp,string);
79
tmp3 = tmp2 = tmp;
80
hom_no = 0;
81
while (tmp3 != NULL){
82
tmp3 = strchr(tmp2,';');
83
if (tmp3 == NULL){
84
strcpy(irr_symbol[hom_no],tmp2);
85
}
86
else{
87
strncpy(irr_symbol[hom_no],tmp2,strlen(tmp2)-strlen(tmp3));
88
tmp2 = tmp3+1;
89
}
90
hom_no++;
91
}
92
93
94
/* order the symbols */
95
ordered = FALSE;
96
while (!ordered){
97
ordered = TRUE;
98
for (i=0;i<hom_no-1;i++){
99
if (smaller(irr_symbol[i],irr_symbol[i+1])){
100
tmp2 = irr_symbol[i];
101
irr_symbol[i] = irr_symbol[i+1];
102
irr_symbol[i+1] = tmp2;
103
ordered = FALSE;
104
}
105
}
106
}
107
108
/* reprint them into string */
109
sprintf(string,"%s",irr_symbol[0]);
110
for (i=1;i<hom_no;i++){
111
sprintf(tmp,"%s;%s",string,irr_symbol[i]);
112
sprintf(string,"%s",tmp);
113
}
114
115
/* free */
116
for (i=0;i<MAXDIM;i++){
117
free(irr_symbol[i]);
118
}
119
free(tmp);
120
121
return;
122
123
}
124
125