Annotation of OpenXM/src/kan96xx/Kan/switch.c, Revision 1.4
1.4 ! takayama 1: /* $OpenXM: OpenXM/src/kan96xx/Kan/switch.c,v 1.3 2001/05/04 01:06:26 takayama Exp $ */
1.1 maekawa 2: #include <stdio.h>
3: #include "datatype.h"
4: #include "extern2.h"
5: #include "gradedset.h"
6:
7: /********** flags for switch status **************/
8: char *F_mmLarger = "???";
9: char *F_mpMult = "???";
10: char *F_monomialAdd = "???";
11: char *F_red = "???";
12: char *F_sp = "???";
13: char *F_groebner = "???";
14: char *F_grade = "???";
15: char *F_isSameComponent = "???";
16:
17:
18: void print_switch_status(void) {
19: printf("------------------------------------\n");
20: printf("mmLarger [matrix,lexicographic,tower] %s\n",F_mmLarger);
21: printf("mpMult [poly,diff,difference] %s\n",F_mpMult);
22: printf("monomialAdd [poly] %s\n",F_monomialAdd);
1.4 ! takayama 23: printf("red@ [standard,module1,module2,module1rev,ecart]\n");
1.1 maekawa 24: printf(" %s\n",F_red);
25: printf("isSameComponent [x,xd] %s\n",F_isSameComponent);
26: printf("sp [standard] %s\n",F_sp);
27: printf("grade [standard,firstvec,module1,module1v] %s\n",F_grade);
28: printf("groebner [standard,gm] %s\n",F_groebner);
29: }
30:
31: /* called from stackmachine.c,
32: ex. $sp$ $so$ switch_function
33: or (report) (function) switch_function value(string)
34: */
35: char *switch_function(fun,arg)
1.3 takayama 36: char *fun;
37: char *arg;
1.1 maekawa 38: {
39: char *ans = NULL;
40: if (strcmp(fun,"mmLarger")==0) {
41: switch_mmLarger(arg);
42: }else if (strcmp(fun,"mpMult")==0) {
43: switch_mpMult(arg);
44: }else if (strcmp(fun,"monomialAdd")==0) {
45: switch_monomialAdd(arg);
46: }else if (strcmp(fun,"red@")==0) {
47: switch_red(arg);
48: }else if (strcmp(fun,"sp")==0) {
49: switch_sp(arg);
50: }else if (strcmp(fun,"isSameComponent")==0) {
51: switch_isSameComponent(arg);
52: }else if (strcmp(fun,"groebner")==0) {
53: switch_groebner(arg);
54: }else if (strcmp(fun,"grade")==0) {
55: switch_grade(arg);
56: }else if (strcmp(fun,"report")==0) {
57: ans = (char *)sGC_malloc(128); /* 128 >= max(strlen(F_*))+1 */
58: ans[0] = '\0';
59: if (strcmp(arg,"mmLarger")==0) {
60: strcpy(ans,F_mmLarger);
61: }else if (strcmp(arg,"mpMult")==0) {
62: strcpy(ans,F_mpMult);
63: }else if (strcmp(arg,"monomialAdd")==0) {
64: strcpy(ans,F_monomialAdd);
65: }else if (strcmp(arg,"red@")==0) {
66: strcpy(ans,F_red);
67: }else if (strcmp(arg,"isSameComponent")==0) {
68: strcpy(ans,F_isSameComponent);
69: }else if (strcmp(arg,"sp")==0) {
70: strcpy(ans,F_sp);
71: }else if (strcmp(arg,"groebner")==0) {
72: strcpy(ans,F_groebner);
73: }else if (strcmp(arg,"grade")==0) {
74: strcpy(ans,F_grade);
75: }else {
76: fprintf(stderr,"Unknown argument for switch_function():report\n");
77: }
78: }else {
79: fprintf(stderr,"Unknown argument for switch_function()\n");
80: }
81: return(ans);
82: }
83:
84: /* 1. called from KinitKan() (poly.c)
85: */
86: void switch_init(void) {
87: switch_mmLarger("matrix");
88: switch_mpMult("poly");
89: switch_monomialAdd("poly");
90: switch_red("standard");
91: switch_isSameComponent("x");
92: switch_sp("standard");
93: switch_groebner("standard");
94: switch_grade("standard");
95: }
96:
97: /*
98: 1. called from switch_init(), switch_function();
99: 2. setOrderByMatrix().
100: */
101:
102: void switch_mmLarger(arg)
1.3 takayama 103: char *arg;
1.1 maekawa 104: {
105: if (strcmp(arg,"matrix") == 0) {
106: mmLarger = mmLarger_matrix;
107: F_mmLarger = "matrix";
108: } else if (strcmp(arg,"lexicographic") == 0) {
109: mmLarger = mmLarger_pureLexicographic;
110: F_mmLarger = "lexicographic";
111: } else if (strcmp(arg,"tower") == 0) {
112: mmLarger = mmLarger_tower;
113: F_mmLarger = "tower";
114: }else ;
115: }
116:
117: /*
118: 1. called from switch_init(), switch_function();
119: */
120:
121: void switch_mpMult(arg)
1.3 takayama 122: char *arg;
1.1 maekawa 123: {
124: if (strcmp(arg,"poly") == 0) {
125: mpMult = mpMult_poly;
126: F_mpMult = "poly";
127: } if (strcmp(arg,"diff") == 0 ) {
128: mpMult = mpMult_diff;
129: F_mpMult = "diff";
130: } if (strcmp(arg,"difference") == 0 ) {
131: mpMult = mpMult_difference;
132: F_mpMult = "difference";
133: /* cf. a dirty trick in mpMult_difference() in poly3.c. */
134: }else ;
135: }
136:
137: /*
138: 1. called from switch_init(), switch_function();
139: */
140:
141: void switch_monomialAdd(arg)
1.3 takayama 142: char *arg;
1.1 maekawa 143: {
144: if (strcmp(arg,"poly") == 0) {
145: monomialAdd = monomialAdd_poly;
146: F_monomialAdd = "poly";
147: }else ;
148: }
149:
150: void switch_red(arg)
1.3 takayama 151: char *arg;
1.1 maekawa 152: {
153: if (strcmp(arg,"standard") == 0) {
154: switch_sp("standard");
155: isReducible = isReducible_gen;
156: reduction1 = reduction1_gen;
157: reduction = reduction_gen;
158:
159: isCdrReducible = isCdrReducible_gen;
160: reduction1Cdr = reduction1Cdr_gen;
161: reductionCdr = reductionCdr_gen;
162:
163: lcm = lcm_gen;
164: switch_grade("standard");
165: F_red = "standard";
166: }else if (strcmp(arg,"module1") == 0) {
167: switch_sp("standard");
168: isReducible = isReducible_module;
169: reduction1 = reduction1_gen;
170: reduction = reduction_gen;
171:
172: isCdrReducible = isCdrReducible_gen;
173: reduction1Cdr = reduction1Cdr_gen;
174: reductionCdr = reductionCdr_gen;
175:
176: lcm = lcm_module;
177: switch_grade("module1");
178: F_red = "module1";
179: }else if (strcmp(arg,"module1rev") == 0) {
180: switch_sp("standard");
181: isReducible = isReducible_module;
182: reduction1 = reduction1_gen;
183: reduction = reduction_gen_rev;
184:
185: isCdrReducible = isCdrReducible_gen;
186: reduction1Cdr = reduction1Cdr_gen;
187: reductionCdr = reductionCdr_gen;
188:
189: lcm = lcm_module;
190: switch_grade("module1");
191: F_red = "module1rev";
192: }else if (strcmp(arg,"module2") == 0) {
193: switch_sp("standard");
194: isReducible = isReducible_module;
195: reduction1 = reduction1_gen;
196: reduction = reduction_gen;
197:
198: isCdrReducible = isCdrReducible_gen;
199: reduction1Cdr = reduction1Cdr_gen;
200: reductionCdr = reductionCdr_gen;
201:
202: lcm = lcm_module;
203: switch_grade("standard");
204: F_red = "module2";
1.4 ! takayama 205: }else if (strcmp(arg,"ecart") == 0) {
! 206: switch_sp("standard");
! 207: isReducible = isReducible_module;
! 208: reduction1 = reduction1_gen;
! 209: reduction = reduction_ecart;
! 210:
! 211: isCdrReducible = isCdrReducible_gen;
! 212: reduction1Cdr = reduction1Cdr_gen;
! 213: reductionCdr = reductionCdr_gen;
! 214:
! 215: lcm = lcm_module;
! 216: switch_grade("module1");
! 217: F_red = "ecart";
1.1 maekawa 218: }else if (strcmp(arg,"debug") == 0) {
219: reduction1 = reduction1_gen_debug;
220: F_red = "debug";
221: }else ;
222: }
223:
224: void switch_groebner(arg)
1.3 takayama 225: char *arg;
1.1 maekawa 226: {
227: if (strcmp(arg,"standard") == 0) {
228: groebner = groebner_gen;
229: F_groebner = "standard";
230: } else if (strcmp(arg,"gm") == 0) {
231: groebner = groebner_gm;
232: F_groebner = "gm";
233: } else ;
234: }
235:
236: /* called from switch_init */
237: void switch_isSameComponent(arg)
1.3 takayama 238: char *arg;
1.1 maekawa 239: {
240: if (strcmp(arg,"x") == 0) {
241: isSameComponent = isSameComponent_x;
242: F_isSameComponent = "x";
243: } else if (strcmp(arg,"xd") == 0) {
244: isSameComponent = isSameComponent_xd;
245: F_isSameComponent = "xd";
246: } else ;
247: }
248:
249: void switch_sp(arg)
1.3 takayama 250: char *arg;
1.1 maekawa 251: {
252: if (strcmp(arg,"standard") == 0) {
253: sp = sp_gen;
254: F_sp = "standard";
255: } else ;
256: }
257:
258:
259: void switch_grade(arg)
1.3 takayama 260: char *arg;
1.1 maekawa 261: {
262: if (strcmp(arg,"standard")==0) {
263: grade = grade_gen;
264: F_grade = "standard";
265: }else if (strcmp(arg,"firstvec")==0) {
266: grade = grade_firstvec;
267: F_grade = "firstvec";
268: }else if (strcmp(arg,"module1")==0) {
269: grade = grade_module1;
270: F_grade = "module1";
271: }else if (strcmp(arg,"module1v")==0) {
272: grade = grade_module1v;
273: F_grade = "module1v";
274: }else ;
275:
276: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>