/* In the standard form, reads from a file a rack and a cocycle with * integers values, then a monomial and finally a list of derivatives * to apply to it. Then, it applies them. * With the parameter -s reads any line after the cocycle as a monomial * and searches for each of them for a derivation in the same degree which * gives nonzero on it. * With the parameter -sb reads one monomial and one derivation. The derivation * can have a degree < degree of monomial. It applies the derivation to the * monomial and then searches for a way to complete it for it to give a nonzero * result. * With -ss acts like -s except that it reads several lines in the form * n mon, where n is an integer, and looks for a nonzero derivation of the element * which is the linear combination of monomials with coefficients the 'n' in each line. * With the parameter -d reads one or more monomials and one or more derivations, * divided by a line beginning with "%D". Then takes derivatives for each monomial * and each derivation. * An example of the syntax of the input file (for standard form) is: * ---------------- %Rack abcdefghij %Braid: aefgbcdhij ebhiafgcdj fhcjeagbid gijdefahbc bacdehifgj cbadhfjeig dbcaijghef acbdfeghji adcbgfejih abdcegfihj %Cocycle -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 %Monomial abacabacdabacabacdabadcabacdefegefeghihj %Derivatives jihifjhgifhedijeidfeigdjihdihgidchfhcbea * ---------------------------- * This computes derivatives of the longest monomial in the * Nichols algebra generated by transpos. in S_5. */ #include #include #define MAXRACK 35 /* Max size of rack allowed */ #define MAXDEG 50 /* Max degree allowed */ #define MAXTERM 4000000 /* Max number of terms in each derivation */ #define MAXMON 10000 /* Max number of monomials to derivate with option -sb */ #define MAXDER 20 /* Max number of derivations with option -d */ static char rack[MAXRACK]; /* the elements of the rack */ static int cardx; /* cardinality of the rack */ static int braid[MAXRACK*MAXRACK]; /* braiding */ static int cocycle[MAXRACK*MAXRACK];/* 2-cocycle */ static int mon[MAXDEG]; /* monomial to derivate */ static int der[MAXDEG]; /* derivations to apply */ static int dertoim[MAXDEG]; /* derivations to apply for printing matters */ static int *smon[MAXMON]; /* monomials to derivate with option -sb */ static int *sder[MAXDER]; /* derivations to apply with option -d */ static int degmon; /* degree of mon[] */ static int degder; /* number of derivations */ static int *toder[MAXTERM]; /* terms to derivate */ static int *result[MAXTERM]; /* results of sucessive derivatives */ static int numterms; /* number of terms (<=MAXTERM) */ static int numtermsres; /* number of terms resulting */ static int srch=0; /* do we want it to search ? */ static int count[MAXRACK]; /* counts number of times each element in the rack appears */ static float percentcompleted=0; /* computes how much is completed with option -s */ static int whentoprint=6; /* the higher, the more info printed with option -s */ static int nummonomials=0; /* number of monomials to look for with option -sb */ static int numderivs=0; /* number of derivations to compute with option -d */ int compterms(void const*, void const*); int cmpcount(void const*, void const*); int charinstr(char*, char); readrackcocmonder (FILE *in) { // reads rack, cocycle, monomial and derivations to apply int siga,i,j,n; char c; siga=1; i=0; while (siga) { // read rack set c=getc(in); if (c=='%') { while (getc(in) != '\n'); continue; } if (c=='\n') siga=0; else rack[i++]=c; } rack[i]='\0'; cardx=i; i=0; while (i max allowed degree.\n"); exit(1); } else mon[i++]=charinstr(rack,c)-1; } else if ( (srch==4) ) { if (i==MAXDEG-1) { printf("I'm sorry, degree of monomial > max allowed degree.\n"); exit(1); } else if (i==0) { ungetc(c, in); mon[i++]=atoif(in); // printf("\nread mon[%d]=%d ", nummonomials, mon[0]); } else { mon[i++]=charinstr(rack,c)-1; // printf("%c", rack[mon[i-1]]); fflush(stdout); } } } degmon=i; siga=1; i=0; if (srch==1 || srch==4) return(1); while (siga) { // read derivations c=getc(in); if (c=='%') { while (getc(in) != '\n'); continue; } if (c=='\n') { if (srch==3) { sder[numderivs]=calloc(MAXDEG, sizeof(int)); for (j=0; j degree of monomial = %d. Result.... 0\n", degmon); exit(0); } else der[i++]=charinstr(rack, c)-1; } if (c==EOF) siga=0; } degder=i; } charinstr(char *s, char c) { int i=0; while (*(s+i) && *(s+i)!=c) i++; if (*(s+i)) return(i+1); else return(0); } beginstr(char *a, char *b) { while (*a && *b && *a==*b) { a++; b++; } if (*a) return(0); else return(1); } equalstr(char *a, char *b) { while(*a && *b && *a==*b) { a++; b++; } if (*a || *b) return(0); else return(1); } deriveterm(int i, int d, int l) { int j, k, doi; for (j=1; j<=l; j++) { if (toder[i][j]==d) { result[numtermsres]=calloc(l+1, sizeof(int)); for (k=1; k0; b--) r *= a; return(r); } atoif(FILE *in) { int r=0, s=1; char c; while ( (((c=getc(in))<'0') || (c>'9')) && (c != '-') && (c != '+') ); if (c=='-') s=-1; if ((c >= '0') && (c <= '9')) r=c-'0'; while ( (c=getc(in)) != ' ' ) r = r*10+c-'0'; return(r*s); } countelems(int locnumterms, int **loctoder, int locdegmon) { int i,j; for (i=0; idegmon/2)?whentoprint:degmon/2; if (srch==1) { for (j=0; j