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