File: print_ct.c

package info (click to toggle)
magnus 20060324-5.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 19,436 kB
  • ctags: 20,462
  • sloc: cpp: 130,217; ansic: 37,090; tcl: 10,970; perl: 1,109; makefile: 966; sh: 403; yacc: 372; csh: 57; awk: 33; asm: 10
file content (300 lines) | stat: -rw-r--r-- 8,260 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
/* File print_ct.c */
#include "print_ct.h"
#include <string.h>
#include <stdlib.h>

#define CT_T(i,j)	ct[(i-1) * NCOL + j + 1]
Void
tc_print_ct(n1, n2, n3, tc_pvar)
Int	n1;
Int	n2;
Int	n3;
struct  tc_str_vars     *tc_pvar;
{
/* #include "tc_void.h" */
char    gen_l;
Int     gen_n;
Int     i,j;
Int     *ct;
Int	cosrepl;
Int	row1;
Int	row2;
Int	step;
Int 	o;

/* subroutine to write out the coset table. 
*  when n is positive, prints the first n rows of the coset table.
*  when n=0 prints all of the table.
*  when n is negative, prints the first n rows of the table with the
*  corresponding coset representation.
*/
/* print the head of the coset table */
        ct = COSET_TABLE;
        fprintf(fout,"      ");
        if (Gen_st[1].gen == '0')
                for(i = 1; i <= NCOL; i++) {
                        gen_n = COL_TO_GEN[i];
                        fprintf(fout,"    %d ",gen_n);
                }
        else
                for(i = 1; i <= NCOL; i++) {
                        gen_n = COL_TO_GEN[i];
                        if (gen_n < 0) {
                                gen_l = Gen_st[-gen_n].gen;
                                fprintf(fout,"    %c ",toupper(gen_l));
                        } else {
                                gen_l = Gen_st[gen_n].gen;
                                fprintf(fout,"     %c ",gen_l);
                        }
                }
        fprintf(fout,"\n");
/*  print coset table. if n < 0 allocate COSREP for cosets representative. */
	if (n1 < 0) {
		free(COSREP);
		free(COSREP_A);
		COSREP = (int *) eemalloc(sizeof(int) * (MST_LEVEL + 1));
		COSREP_A = (char *) eemalloc(MST_LEVEL + 1);
	}
	if (n1 == 0) {
		row1 = 1;
		row2 = NALIVE;
		step = 1;
	} else if ((iabs(n2)) > NALIVE) {
		row1 = iabs(n1);
		row2 = NALIVE;
		step = iabs(n3);
	} else {
		row1 = iabs(n1);
                row2 = iabs(n2);
		step = iabs(n3);
	}

        for(i = row1; i <= row2; i += step) {
                fprintf(fout,"%5d.",i);
/* prints out row i. */
                for(j = 1; j <= NCOL; j++)
			fprintf(fout,"%7d", CT_T(i,j));
		fprintf(fout,"\n");
		if (n1 < 0 && i != 1) {
/* prints out the representative of coset i. call tc_cosrep() to get coset
*  representative which is stored in COSREP[] and tc_cosrep() returns
*  the length of the coset representative. o will bring back the order of 
* the coset representative, but we ignore it here.
*/
			cosrepl = tc_cosrep(i, &o, tc_pvar);
			{  PrintCosetRep;  }
		}
	}
}
/* End File */
tc_sc(n, tc_pvar)
Int     n;
struct  tc_str_vars     *tc_pvar;
{
char    gen_l;
Int     gen_n;
Int     i,j;
Int     *ct;
Int     cosrepl;
Int	n1;
Int  	sc_flag;
Int	o;

	ct = COSET_TABLE;
	sc_flag = 0;
/* print the head of the coset table 
        fprintf(fout,"      ");
        if (Gen_st[1].gen == '0')
                for(i = 1; i <= NCOL; i++) {
                        gen_n = COL_TO_GEN[i];
                        fprintf(fout,"    %d ",gen_n);
                }
        else
                for(i = 1; i <= NCOL; i++) {
                        gen_n = COL_TO_GEN[i];
                        if (gen_n < 0) {
                                gen_l = Gen_st[-gen_n].gen;
                                fprintf(fout,"    %c ",toupper(gen_l));
                        } else {
                                gen_l = Gen_st[gen_n].gen;
                                fprintf(fout,"     %c ",gen_l);
                        }
                }
        fprintf(fout,"\n");
*/
/*  print coset table. if n <= 0 allocate COSREP for cosets representative. */
        if (n <= 0) {
                free(COSREP);
		free(COSREP_A);
                COSREP = (int *) eemalloc(sizeof(int) * (MST_LEVEL + 1));
		COSREP_A = (char *) eemalloc(MST_LEVEL + 1);
        }
        if (n == 0 || n > NALIVE)
                n1 = NALIVE;
        else
                n1 = iabs(n);
/* print stabilising cosets.  */
        for (i = 2; i <= n1; i++) {
                if (0 == tc_normal(i, tc_pvar))
                        continue;
/* i is stabilising.  */
		if (sc_flag == 0) {
			fprintf(fout," Stabilising cosets:\n  %d ", i);
			sc_flag = 1;
		} else 
			fprintf(fout,"  %d ",i);
/*
                for(j = 1; j <= NCOL; j++)
                        fprintf(fout,"%7d", CT_T(i,j));
                fprintf(fout,"\n");
*/
                if (n <= 0){
/* prints out the representative of coset i. call tc_cosrep() to get coset
*  representative which is stored in COSREP[] and tc_cosrep() returns
*  the length of the coset representative. o will bring back the order of
* the coset representative, but we ignore it here.
*/
                        cosrepl = tc_cosrep(i, &o, tc_pvar);
			{  PrintCosetRep;  }
                }
        }
	fprintf(fout,"\n");
	if (sc_flag == 0)
		fprintf(fout," No stabilising cosets.\n");
}
tc_cycles(tc_pvar)
struct  tc_str_vars     *tc_pvar;
{
#define  LINEWIDTH	76
register Int i;
register Int j;
register Int t;
register Int *y;
register Int *p;
register Int n;
register Int length;
register Int k;
register Int kn;
register Int *ct;
char	tem[30];
/* print out the coset table in cycle (permutation representation). */

	ct = COSET_TABLE;
	for (j = 1; j <= NDGEN; j++) {
/* find the column corresponding to generators.  */
		k = GEN_TO_COL[j];
		if (Gen_st[1].gen == '0') 
			fprintf(fout,"%d=",j);
		else
			fprintf(fout,"%c=",Gen_st[j].gen);
		length = 2;
		for (i = 1; i <= NALIVE; i++) {
/* is i an one_cycle?  */
			if (CT_T(i, k) == i) {
				CT_T(i, k) = -i;
				continue;
			}
/* have we used coset i in previous cycle?  */
			if (CT_T((kn = i),k) <= 0)
				continue;
/* no, trace out this cycle.  */
			sprintf(tem,"%d",kn);
			n = strlen(tem);
			length += n;
			if (length + 1 >= LINEWIDTH) {
                                fprintf(fout,"\n  ");
                                length = 2 + n;
                        }
/* SER, printf( replaced by fprintf(fout, */
			fprintf (fout,"(%d",kn);
			length++;
			t = CT_T(kn, k);
/* mark this coset number as be used previously.  */
                        CT_T(kn, k) = -t;
                        kn = t;
			while (CT_T(kn,k) > 0) {
				sprintf(tem,"%d",kn);
				n = strlen(tem);
				length += n + 1;
				if (length > LINEWIDTH) {
					fprintf(fout,",\n  %d",kn);
					length = n + 3;
				} else 
					fprintf(fout,",%d",kn);
				t = CT_T(kn, k);
/* mark this coset number as be used previously.  */
				CT_T(kn, k) = -t;
				kn = t;
			}
/* we reached the end of the cycle. */
			fprintf(fout,")");
			length++;
		}
		if (length == 2) 
			fprintf(fout,"(1)\n");
		else
			fprintf(fout,"\n");
	}
/* change all negative values in the coset table back to positive values; */
	/*  y = &CT(Num2Addr(COSET1), 1);
	p = &CT(Num2Addr(NEXTDF), 1);   BUGGY CODE SER ?? */
	y = &CT(COSET1, 1);
	p = &CT(NEXTDF, 1);
	for (; y < p; y++)
		*y = (*y < 0) ? -*y : *y;
}	
tc_o(o, tc_pvar)
Int	o;
struct  tc_str_vars     *tc_pvar;
{
register Int    j;
register Int    i;
register Int    cosrepl;
Int    order;
/* find a coset with order iabs(o) mod the subgroup and print out its
*  coset representative.
*  if o < 0 all cosets of order iabs(o) are printed.
*  if o == 0, print an ordered list of all orders found in the 
*  	 coset table, mod the subgroup.
*/
	if (INDEX1) {
		fprintf(fout,"INDEX 1\n");
		return;
	}
	if (CTFLG == 0) {
		fprintf(fout,"NO COSET TABLE\n");
		return;
	}
	if (STDCT == 0) {
/* get the standard coset table.  */
		tc_compact(tc_pvar);
                tc_ctrenumber(tc_pvar);
        }
	if (MSTFLG == 0) 
		tc_mst(tc_pvar); /* construct ms tree. */
/* allocate COSREP for cosets representative. */
        free(COSREP);
	free(COSREP_A);
        COSREP = (int *) eemalloc(sizeof(int) * (MST_LEVEL + 1));
	COSREP_A = (char *) eemalloc(MST_LEVEL + 1);
	for (i = 2; i <= NALIVE; i++) {
/* get the coset representative and its length. order will return the order
*  of the coset representative.
*/
		cosrepl = tc_cosrep(i, &order, tc_pvar);	
		if (o == 0) {
/* print an ordered list of all orders found in the
*        coset table, mod the subgroup.
*/ 
			fprintf(fout,"%d. Order=%d\n", i, order);
			continue;
		} 
		if (iabs(o) == order) {
/* print the satisfied cosets. */
			fprintf(fout,"%d. Order=%d\n", i, order);
			{ PrintCosetRep; }
			if (o > 0)
				break;
		}
	}
}