=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/Kan/redm.c,v retrieving revision 1.2 retrieving revision 1.6 diff -u -p -r1.2 -r1.6 --- OpenXM/src/kan96xx/Kan/redm.c 2000/01/16 07:55:41 1.2 +++ OpenXM/src/kan96xx/Kan/redm.c 2003/08/24 05:19:43 1.6 @@ -1,4 +1,4 @@ -/* $OpenXM$ */ +/* $OpenXM: OpenXM/src/kan96xx/Kan/redm.c,v 1.5 2003/07/17 09:10:54 takayama Exp $ */ #include #include "datatype.h" #include "extern2.h" @@ -10,8 +10,8 @@ static int DebugReduction = 0; int isReducible_module(f,g) -POLY f; -POLY g; + POLY f; + POLY g; { int n,i; MONOMIAL tf; @@ -33,8 +33,8 @@ POLY g; int isSameComponent_x(f,g) -POLY f; -POLY g; + POLY f; + POLY g; { static int nn,mm,ll,cc,n,m,l,c; static struct ring *cr = (struct ring *)NULL; @@ -77,8 +77,8 @@ POLY g; } int isSameComponent_xd(f,g) -POLY f; -POLY g; + POLY f; + POLY g; { static int nn,mm,ll,cc,n,m,l,c; static struct ring *cr = (struct ring *)NULL; @@ -122,8 +122,8 @@ POLY g; POLY lcm_module(f,g) -POLY f; -POLY g; + POLY f; + POLY g; { MONOMIAL tf,tg; MONOMIAL lcm; @@ -143,7 +143,7 @@ POLY g; int grade_module1v(f) -POLY f; + POLY f; { int r; int i; @@ -188,7 +188,7 @@ POLY f; int grade_module1(f) -POLY f; + POLY f; { int r; int i; @@ -222,7 +222,7 @@ POLY f; int grade_firstvec(f) /* grading by the first vector and h */ -POLY f; + POLY f; { int r; int i,k; @@ -254,7 +254,7 @@ POLY f; } int eliminated(ff) -POLY ff; + POLY ff; { #define RULEMAX 10 int r; @@ -320,5 +320,139 @@ POLY ff; if (tf->e[i].x) return 0; } return(1); +} + +/* Grading by the weight vector (0,1). Note 2003.07.10 + dGrade1 is the grade of the in(f). +*/ +int dGrade1(f) + POLY f; +{ + int r; + int i; + MONOMIAL tf; + static int nn,mm,ll,cc,n,m,l,c; + static struct ring *cr = (struct ring *)NULL; + extern int *DegreeShiftD_vec; + extern int DegreeShiftD_size; + + if (f ISZERO) return(-1); + tf = f->m; + if (tf->ringp != cr) { + n = tf->ringp->n; + m = tf->ringp->m; + l = tf->ringp->l; + c = tf->ringp->c; + nn = tf->ringp->nn; + mm = tf->ringp->mm; + ll = tf->ringp->ll; + cc = tf->ringp->cc; + cr = tf->ringp; + } + + r = 0; + for (i=m; ie[i].D; + } + if (DegreeShiftD_size > 0) { + if ((tf->e[n-1].x e[n-1].x >= 0)) { + r += DegreeShiftD_vec[tf->e[n-1].x]; + }else{ + /* warning. out of range. */ + } + } + return(r); +} + +/* Grading by the weight vector (0,1). Note 2003.07.10 +*/ +int dGrade(f) + POLY f; +{ + int r, first, t; + if (f ISZERO) return(-1); + first = 1; + while (f != POLYNULL) { + if (first) { + r = dGrade1(f); + first = 0; + }else{ + t = dGrade1(f); + if (t > r) r = t; + } + } + return r; +} + +/* Grading by the weight vector (u,v) + and degree shift ds. Note 2003.07.10 + uvGrade1 is the grade of the in(f). + ei ( element index ). If it is < 0, then e[n-1]->x will be used, + else ei is used. +*/ +int uvGrade1(POLY f,int u[],int v[],int ds[],int dssize,int ei) +{ + int r; + int i,t; + MONOMIAL tf; + static int nn,mm,ll,cc,n,m,l,c; + static struct ring *cr = (struct ring *)NULL; + + if (f ISZERO) return(-1); + tf = f->m; + if (tf->ringp != cr) { + n = tf->ringp->n; + m = tf->ringp->m; + l = tf->ringp->l; + c = tf->ringp->c; + nn = tf->ringp->nn; + mm = tf->ringp->mm; + ll = tf->ringp->ll; + cc = tf->ringp->cc; + cr = tf->ringp; + } + + r = 0; + for (i=0; ie[i].x)*u[i]; + r += (tf->e[i].D)*v[i]; + } + /* Degree shift */ + if (ei <0) { + t = tf->e[n-1].x; + if ((t = 0)) { + r += ds[t]; + }else{ + /* Warning! ds[t] is assumed to be zero. */ + } + }else{ + t = ei; + if ((t = 0)) { + r += ds[t]; + }else{ + /* Warning! ds[t] is assumed to be zero. */ + } + } + return(r); +} + +/* Grading by the weight vector (u,v) + and degree shift ds. Note 2003.07.10 +*/ +int uvGrade(POLY f,int u[],int v[],int ds[],int dssize,int ei) +{ + int r, first, t; + if (f ISZERO) return(LARGE_NEGATIVE_NUMBER); + first = 1; + while (f != POLYNULL) { + if (first) { + r = uvGrade1(f,u,v,ds,dssize,ei); + first = 0; + }else{ + t = uvGrade1(f,u,v,ds,dssize,ei); + if (t > r) r = t; + } + } + return r; }