[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.5

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

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