[BACK]Return to switch.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / kan96xx / Kan

Annotation of OpenXM/src/kan96xx/Kan/switch.c, Revision 1.2

1.2     ! takayama    1: /* $OpenXM$ */
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);
                     23:   printf("red@      [standard,module1,module2,module1rev]\n");
                     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)
                     36: char *fun;
                     37: char *arg;
                     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)
                    103: char *arg;
                    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)
                    122: char *arg;
                    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)
                    142: char *arg;
                    143: {
                    144:   if (strcmp(arg,"poly") == 0) {
                    145:     monomialAdd = monomialAdd_poly;
                    146:     F_monomialAdd = "poly";
                    147:   }else ;
                    148: }
                    149:
                    150: void switch_red(arg)
                    151: char *arg;
                    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";
                    205:   }else if (strcmp(arg,"debug") == 0) {
                    206:     reduction1 = reduction1_gen_debug;
                    207:     F_red = "debug";
                    208:   }else ;
                    209: }
                    210:
                    211: void switch_groebner(arg)
                    212: char *arg;
                    213: {
                    214:   if (strcmp(arg,"standard") == 0) {
                    215:     groebner = groebner_gen;
                    216:     F_groebner = "standard";
                    217:   } else if (strcmp(arg,"gm") == 0) {
                    218:     groebner = groebner_gm;
                    219:     F_groebner = "gm";
                    220:   } else ;
                    221: }
                    222:
                    223: /* called from switch_init */
                    224: void switch_isSameComponent(arg)
                    225: char *arg;
                    226: {
                    227:   if (strcmp(arg,"x") == 0) {
                    228:     isSameComponent = isSameComponent_x;
                    229:     F_isSameComponent = "x";
                    230:   } else if (strcmp(arg,"xd") == 0) {
                    231:     isSameComponent = isSameComponent_xd;
                    232:     F_isSameComponent = "xd";
                    233:   } else ;
                    234: }
                    235:
                    236: void switch_sp(arg)
                    237: char *arg;
                    238: {
                    239:   if (strcmp(arg,"standard") == 0) {
                    240:     sp = sp_gen;
                    241:     F_sp = "standard";
                    242:   } else ;
                    243: }
                    244:
                    245:
                    246: void switch_grade(arg)
                    247: char *arg;
                    248: {
                    249:   if (strcmp(arg,"standard")==0) {
                    250:     grade = grade_gen;
                    251:     F_grade = "standard";
                    252:   }else if (strcmp(arg,"firstvec")==0) {
                    253:     grade = grade_firstvec;
                    254:     F_grade = "firstvec";
                    255:   }else if (strcmp(arg,"module1")==0) {
                    256:     grade = grade_module1;
                    257:     F_grade = "module1";
                    258:   }else if (strcmp(arg,"module1v")==0) {
                    259:     grade = grade_module1v;
                    260:     F_grade = "module1v";
                    261:   }else ;
                    262:
                    263: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>