version 1.2, 2003/07/17 12:11:09 |
version 1.8, 2003/08/19 08:02:09 |
|
|
/* $OpenXM: OpenXM/src/kan96xx/Kan/ecart.c,v 1.1 2003/07/17 09:10:54 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kan96xx/Kan/ecart.c,v 1.7 2003/07/30 09:00:52 takayama Exp $ */ |
#include <stdio.h> |
#include <stdio.h> |
#include "datatype.h" |
#include "datatype.h" |
#include "extern2.h" |
#include "extern2.h" |
Line 16 struct ecartPolyArray { |
|
Line 16 struct ecartPolyArray { |
|
int size; |
int size; |
int limit; |
int limit; |
POLY *pa; |
POLY *pa; |
|
POLY *cf; |
|
POLY *syz; |
}; |
}; |
|
|
static struct ecartReducer ecartFindReducer(POLY r,struct gradedPolySet *gset,struct ecartPolyArray *epa); |
static struct ecartReducer ecartFindReducer(POLY r,struct gradedPolySet *gset,struct ecartPolyArray *epa); |
|
static struct ecartReducer ecartFindReducer_mod(POLY r,struct gradedPolySet *gset,struct ecartPolyArray *epa); |
static int ecartCheckPoly(POLY f); /* check if it does not contain s-variables */ |
static int ecartCheckPoly(POLY f); /* check if it does not contain s-variables */ |
static int ecartCheckEnv(); /* check if the environment is OK for ecart div*/ |
static int ecartCheckEnv(); /* check if the environment is OK for ecart div*/ |
static struct ecartPolyArray *ecartPutPolyInG(POLY g,struct ecartPolyArray *eparray); |
static struct ecartPolyArray *ecartPutPolyInG(POLY g,struct ecartPolyArray *eparray,POLY cf, POLY syz); |
static int ecartGetEll(POLY r,POLY g); |
static int ecartGetEll(POLY r,POLY g); |
static POLY ecartDivideSv(POLY r); |
static POLY ecartDivideSv(POLY r,int *d); |
|
/* No automatic homogenization and s is used as a standart var. */ |
|
static POLY reduction_ecart0(POLY r,struct gradedPolySet *gset, |
|
int needSyz, struct syz0 *syzp); |
|
/* Automatic homogenization and s->1 */ |
|
static POLY reduction_ecart1(POLY r,struct gradedPolySet *gset, |
|
int needSyz, struct syz0 *syzp); |
|
static POLY reduction_ecart1_mod(POLY r,struct gradedPolySet *gset); |
|
static POLY ecartCheckSyz0(POLY cf,POLY r_0,POLY syz, |
|
struct gradedPolySet *gg,POLY r); |
|
|
extern int DebugReductionRed; |
extern int DebugReductionRed; |
|
extern int TraceLift; |
|
struct ring *TraceLift_ringmod; |
|
int DebugReductionEcart = 0; |
|
|
/* This is used for goHomogenization */ |
/* This is used for goHomogenization */ |
extern int DegreeShifto_size; |
extern int DegreeShifto_size; |
extern int *DegreeShifto_vec; |
extern int *DegreeShifto_vec; |
|
|
|
/* It is used reduction_ecart() and ecartFindReducer() |
|
to determine if we homogenize in this function */ |
|
extern int EcartAutomaticHomogenization; |
|
|
#define LARGE 0x7fffffff |
#define LARGE 0x7fffffff |
|
|
|
|
static POLY ecartDivideSv(POLY r) { |
static POLY ecartDivideSv(POLY r,int *d) { |
POLY f; |
POLY f; |
int k; |
int k; |
|
*d = 0; |
if (r == POLYNULL) return r; |
if (r == POLYNULL) return r; |
f = r; k = LARGE; |
f = r; k = LARGE; |
while (r != POLYNULL) { |
while (r != POLYNULL) { |
Line 46 static POLY ecartDivideSv(POLY r) { |
|
Line 66 static POLY ecartDivideSv(POLY r) { |
|
r = r->next; |
r = r->next; |
} |
} |
if (k > 0) { |
if (k > 0) { |
|
*d = k; |
f = r; |
f = r; |
while (r != POLYNULL) { |
while (r != POLYNULL) { |
r->m->e[0].x -= k; |
r->m->e[0].x -= k; |
Line 79 static int ecartGetEll(POLY f,POLY g) { |
|
Line 100 static int ecartGetEll(POLY f,POLY g) { |
|
|
|
|
|
#define EP_SIZE 10 |
#define EP_SIZE 10 |
static struct ecartPolyArray *ecartPutPolyInG(POLY g,struct ecartPolyArray *eparray) |
static struct ecartPolyArray *ecartPutPolyInG(POLY g,struct ecartPolyArray *eparray,POLY cf,POLY syz) |
{ |
{ |
struct ecartPolyArray *a; |
struct ecartPolyArray *a; |
POLY *ep; |
POLY *ep; |
Line 89 static struct ecartPolyArray *ecartPutPolyInG(POLY g,s |
|
Line 110 static struct ecartPolyArray *ecartPutPolyInG(POLY g,s |
|
outofmemory(a); |
outofmemory(a); |
ep = (POLY *) sGC_malloc(sizeof(POLY)*EP_SIZE); |
ep = (POLY *) sGC_malloc(sizeof(POLY)*EP_SIZE); |
outofmemory(ep); |
outofmemory(ep); |
|
a->cf = (POLY *) sGC_malloc(sizeof(POLY)*EP_SIZE); |
|
outofmemory(a->cf); |
|
a->syz = (POLY *) sGC_malloc(sizeof(POLY)*EP_SIZE); |
|
outofmemory(a->syz); |
a->limit = EP_SIZE; |
a->limit = EP_SIZE; |
a->size = 0; |
a->size = 0; |
a->pa = ep; |
a->pa = ep; |
Line 99 static struct ecartPolyArray *ecartPutPolyInG(POLY g,s |
|
Line 124 static struct ecartPolyArray *ecartPutPolyInG(POLY g,s |
|
outofmemory(a); |
outofmemory(a); |
ep = (POLY *) sGC_malloc(sizeof(POLY)*((eparray->limit)*2)); |
ep = (POLY *) sGC_malloc(sizeof(POLY)*((eparray->limit)*2)); |
outofmemory(ep); |
outofmemory(ep); |
|
a->cf = (POLY *) sGC_malloc(sizeof(POLY)*((eparray->limit)*2)); |
|
outofmemory(a->cf); |
|
a->syz = (POLY *) sGC_malloc(sizeof(POLY)*((eparray->limit)*2)); |
|
outofmemory(a->syz); |
a->limit = (eparray->limit)*2; |
a->limit = (eparray->limit)*2; |
a->size = eparray->size; |
a->size = eparray->size; |
a->pa = ep; |
a->pa = ep; |
for (i=0; i<eparray->size; i++) { |
for (i=0; i<eparray->size; i++) { |
(a->pa)[i] = (eparray->pa)[i]; |
(a->pa)[i] = (eparray->pa)[i]; |
|
(a->cf)[i] = (eparray->cf)[i]; |
|
(a->syz)[i] = (eparray->syz)[i]; |
} |
} |
eparray = a; |
eparray = a; |
} |
} |
i = eparray->size; |
i = eparray->size; |
(eparray->pa)[i] = g; |
(eparray->pa)[i] = g; |
|
(eparray->cf)[i] = cf; |
|
(eparray->syz)[i] = syz; |
(eparray->size)++; |
(eparray->size)++; |
return eparray; |
return eparray; |
} |
} |
Line 133 static struct ecartReducer ecartFindReducer(POLY r,str |
|
Line 166 static struct ecartReducer ecartFindReducer(POLY r,str |
|
for (i=0; i<set->size; i++) { |
for (i=0; i<set->size; i++) { |
if (set->gh[i] == POLYNULL) { |
if (set->gh[i] == POLYNULL) { |
/* goHomogenize set->gh[i] */ |
/* goHomogenize set->gh[i] */ |
set->gh[i] = goHomogenize11(set->g[i],DegreeShifto_vec,DegreeShifto_size,-1,1); |
if (EcartAutomaticHomogenization) { |
|
set->gh[i] = goHomogenize11(set->g[i],DegreeShifto_vec,DegreeShifto_size,-1,1); |
|
}else{ |
|
set->gh[i] = set->g[i]; |
|
} |
} |
} |
ell = ecartGetEll(r,set->gh[i]); |
ell = ecartGetEll(r,set->gh[i]); |
if ((ell>=0) && (ell < ell1)) { |
if ((ell>=0) && (ell < ell1)) { |
Line 154 static struct ecartReducer ecartFindReducer(POLY r,str |
|
Line 191 static struct ecartReducer ecartFindReducer(POLY r,str |
|
} |
} |
} |
} |
|
|
if (DebugReductionRed) { |
if (DebugReductionRed || (DebugReductionEcart&1)) { |
printf("ecartFindReducer(): ell1=%d, ell2=%d, minGrade=%d, minGseti=%d, minGgi=%d\n",ell1,ell2,minGrade,minGseti,minGgi); |
printf("ecartFindReducer(): ell1=%d, ell2=%d, minGrade=%d, minGseti=%d, minGgi=%d\n",ell1,ell2,minGrade,minGseti,minGgi); |
} |
} |
if (ell1 <= ell2) { |
if (ell1 <= ell2) { |
Line 176 static struct ecartReducer ecartFindReducer(POLY r,str |
|
Line 213 static struct ecartReducer ecartFindReducer(POLY r,str |
|
} |
} |
} |
} |
|
|
|
static POLY ecartCheckSyz0(POLY cf,POLY r_0,POLY syz, |
|
struct gradedPolySet *gg,POLY r) |
|
{ |
|
POLY f; |
|
int grd,i; |
|
POLY q; |
|
struct coeff *c; |
|
f = ppMult(cf,r_0); |
|
while (syz != POLYNULL) { |
|
grd = syz->m->e[0].x; |
|
i = syz->m->e[0].D; |
|
c = syz->coeffp; |
|
if (c->tag == POLY_COEFF) { |
|
q = c->val.f; |
|
}else{ |
|
q = POLYNULL; |
|
} |
|
f = ppAdd(f,ppMult(q,((gg->polys[grd])->g)[i])); |
|
/* not gh, works only for _ecart0 */ |
|
syz = syz->next; |
|
} |
|
f = ppSub(f,r); |
|
return f; |
|
} |
|
|
|
|
|
POLY reduction_ecart(r,gset,needSyz,syzp) |
|
POLY r; |
|
struct gradedPolySet *gset; |
|
int needSyz; |
|
struct syz0 *syzp; /* set */ |
|
{ |
|
POLY rn; |
|
if (TraceLift) { |
|
if (EcartAutomaticHomogenization) { |
|
if (TraceLift_ringmod == NULL) { |
|
warningPoly("reduction_ecart: TraceLift_ringmod is not set.\n"); |
|
return reduction_ecart1(r,gset,needSyz,syzp); |
|
} |
|
rn = reduction_ecart1_mod(r,gset); |
|
if (rn == POLYNULL) return rn; |
|
else return reduction_ecart1(r,gset,needSyz,syzp); |
|
}else{ |
|
return reduction_ecart0(r,gset,needSyz,syzp); |
|
} |
|
}else{ |
|
if (EcartAutomaticHomogenization) { |
|
return reduction_ecart1(r,gset,needSyz,syzp); |
|
}else{ |
|
return reduction_ecart0(r,gset,needSyz,syzp); |
|
} |
|
} |
|
} |
|
|
/* |
/* |
r and gset are assumed to be (0,1)-homogenized (h-homogenized) |
r and gset are assumed to be (0,1)-homogenized (h-homogenized) |
|
Polynomials r and gset are assumed |
|
to be double homogenized (h-homogenized and s(H)-homogenized) |
*/ |
*/ |
POLY reduction_ecart(r,gset,needSyz,syzp) |
static POLY reduction_ecart0(r,gset,needSyz,syzp) |
POLY r; |
POLY r; |
struct gradedPolySet *gset; |
struct gradedPolySet *gset; |
int needSyz; |
int needSyz; |
Line 195 POLY reduction_ecart(r,gset,needSyz,syzp) |
|
Line 288 POLY reduction_ecart(r,gset,needSyz,syzp) |
|
struct ecartPolyArray *gg; |
struct ecartPolyArray *gg; |
POLY pp; |
POLY pp; |
int ell; |
int ell; |
|
POLY cf_o; |
|
POLY syz_o; |
|
POLY r_0; |
|
|
extern struct ring *CurrentRingp; |
extern struct ring *CurrentRingp; |
struct ring *rp; |
struct ring *rp; |
|
|
|
r_0 = r; |
gg = NULL; |
gg = NULL; |
if (needSyz) { |
if (needSyz) { |
if (r ISZERO) { rp = CurrentRingp; } else { rp = r->m->ringp; } |
if (r ISZERO) { rp = CurrentRingp; } else { rp = r->m->ringp; } |
Line 207 POLY reduction_ecart(r,gset,needSyz,syzp) |
|
Line 304 POLY reduction_ecart(r,gset,needSyz,syzp) |
|
} |
} |
|
|
if (r != POLYNULL) { |
if (r != POLYNULL) { |
rp = r->m->ringp; |
rp = r->m->ringp; |
if (! rp->weightedHomogenization) { |
if (! rp->weightedHomogenization) { |
errorKan1("%s\n","ecart.c: the given ring must be declared with [(weightedHomogenization) 1]"); |
errorKan1("%s\n","ecart.c: the given ring must be declared with [(weightedHomogenization) 1]"); |
} |
} |
} |
} |
|
|
|
if (DebugReductionEcart&1) printf("--------------------------------------\n"); |
|
do { |
|
if (DebugReductionRed) printf("r=%s\n",POLYToString(r,'*',1)); |
|
if (DebugReductionEcart & 1) printf("r=%s+...\n",POLYToString(head(r),'*',1)); |
|
ells = ecartFindReducer(r,gset,gg); |
|
ell = ells.ell; |
|
if (ell > 0) { |
|
if (DebugReductionEcart & 2) printf("*"); |
|
if (needSyz) { |
|
gg = ecartPutPolyInG(r,gg,cf,syz); |
|
}else{ |
|
gg = ecartPutPolyInG(r,gg,POLYNULL,POLYNULL); |
|
} |
|
} |
|
if (ell >= 0) { |
|
if (ells.first) { |
|
pp = ((gset->polys[ells.grade])->gh)[ells.gseti]; |
|
}else{ |
|
if (DebugReductionEcart & 4) printf("#"); |
|
pp = (gg->pa)[ells.ggi]; |
|
} |
|
if (ell > 0) r = mpMult(cxx(1,0,ell,rp),r); /* r = s^ell r */ |
|
r = (*reduction1)(r,pp,needSyz,&cc,&cg); |
|
if (needSyz) { |
|
if (ells.first) { |
|
if (ell >0) cc = ppMult(cc,cxx(1,0,ell,rp)); |
|
cf = ppMult(cc,cf); |
|
syz = cpMult(toSyzCoeff(cc),syz); |
|
syz = ppAdd(syz,toSyzPoly(cg,ells.grade,ells.gseti)); |
|
}else{ |
|
if (ell >0) cc = ppMult(cc,cxx(1,0,ell,rp)); |
|
cf_o = (gg->cf)[ells.ggi]; |
|
syz_o = (gg->syz)[ells.ggi]; |
|
cf = ppMult(cc,cf); |
|
cf = ppAdd(cf,ppMult(cg,cf_o)); |
|
syz = cpMult(toSyzCoeff(cc),syz); |
|
syz = ppAdd(syz,cpMult(toSyzCoeff(cg),syz_o)); |
|
/* Note. 2003.07.19 */ |
|
} |
|
if (DebugReductionRed) { |
|
POLY tp; |
|
tp = ecartCheckSyz0(cf,r_0,syz,gset,r); |
|
if (tp != POLYNULL) { |
|
fprintf(stderr,"reduction_ecart0(): sygyzy is broken. Return the Current values.\n"); |
|
fprintf(stderr,"%s\n",POLYToString(tp,'*',1)); |
|
syzp->cf = cf; |
|
syzp->syz = syz; |
|
return r; |
|
} |
|
} |
|
} |
|
if (r ISZERO) goto ss; |
|
/*r = ecartDivideSv(r,&se); r = r/s^? Don't do this. */ |
|
} |
|
}while (ell >= 0); |
|
|
|
ss: ; |
|
if (needSyz) { |
|
syzp->cf = cf; /* cf is in the CurrentRingp */ |
|
syzp->syz = syz; /* syz is in the SyzRingp */ |
|
} |
|
|
|
return(r); |
|
} |
|
|
|
/* |
|
r and gset are assumed to be (0,1)-homogenized (h-homogenized) |
|
r and gset are not assumed |
|
to be double homogenized (h-homogenized and s(H)-homogenized) |
|
They are automatically s(H)-homogenized, and s is set to 1 |
|
when this function returns. |
|
*/ |
|
static POLY reduction_ecart1(r,gset,needSyz,syzp) |
|
POLY r; |
|
struct gradedPolySet *gset; |
|
int needSyz; |
|
struct syz0 *syzp; /* set */ |
|
{ |
|
int reduced,reduced1,reduced2; |
|
int grd; |
|
struct polySet *set; |
|
POLY cf,syz; |
|
int i; |
|
POLY cc,cg; |
|
struct ecartReducer ells; |
|
struct ecartPolyArray *gg; |
|
POLY pp; |
|
int ell; |
|
int se; |
|
|
|
extern struct ring *CurrentRingp; |
|
struct ring *rp; |
|
|
|
gg = NULL; |
|
if (needSyz) { |
|
if (r ISZERO) { rp = CurrentRingp; } else { rp = r->m->ringp; } |
|
cf = cxx(1,0,0,rp); |
|
syz = ZERO; |
|
} |
|
|
|
if (r != POLYNULL) { |
|
rp = r->m->ringp; |
|
if (! rp->weightedHomogenization) { |
|
errorKan1("%s\n","ecart.c: the given ring must be declared with [(weightedHomogenization) 1]"); |
|
} |
|
} |
|
|
r = goHomogenize11(r,DegreeShifto_vec,DegreeShifto_size,-1,1); |
r = goHomogenize11(r,DegreeShifto_vec,DegreeShifto_size,-1,1); |
/* 1 means homogenize only s */ |
/* 1 means homogenize only s */ |
|
|
|
if (DebugReductionEcart&1) printf("=======================================\n"); |
do { |
do { |
if (DebugReductionRed) printf("r=%s\n",POLYToString(r,'*',1)); |
if (DebugReductionRed) printf("(ecart1(d)) r=%s\n",POLYToString(r,'*',1)); |
|
if (DebugReductionEcart & 1) printf("r=%s+,,,\n",POLYToString(head(r),'*',1)); |
|
|
ells = ecartFindReducer(r,gset,gg); |
ells = ecartFindReducer(r,gset,gg); |
ell = ells.ell; |
ell = ells.ell; |
if (ell > 0) { |
if (ell > 0) { |
gg = ecartPutPolyInG(r,gg); |
if (DebugReductionEcart & 2) printf("%"); |
|
gg = ecartPutPolyInG(r,gg,POLYNULL,POLYNULL); |
} |
} |
if (ell >= 0) { |
if (ell >= 0) { |
if (ells.first) { |
if (ells.first) { |
pp = ((gset->polys[ells.grade])->gh)[ells.gseti]; |
pp = ((gset->polys[ells.grade])->gh)[ells.gseti]; |
}else{ |
}else{ |
|
if (DebugReductionEcart & 4) printf("+"); |
pp = (gg->pa)[ells.ggi]; |
pp = (gg->pa)[ells.ggi]; |
} |
} |
if (ell > 0) r = mpMult(cxx(1,0,ell,rp),r); /* r = s^ell r */ |
if (ell > 0) r = mpMult(cxx(1,0,ell,rp),r); /* r = s^ell r */ |
Line 237 POLY reduction_ecart(r,gset,needSyz,syzp) |
|
Line 446 POLY reduction_ecart(r,gset,needSyz,syzp) |
|
syz = cpMult(toSyzCoeff(cc),syz); |
syz = cpMult(toSyzCoeff(cc),syz); |
syz = ppAddv(syz,toSyzPoly(cg,ells.grade,ells.gseti)); |
syz = ppAddv(syz,toSyzPoly(cg,ells.grade,ells.gseti)); |
}else{ |
}else{ |
|
fprintf(stderr,"It has not yet implemented.\n"); |
|
exit(10); |
/* BUG: not yet */ |
/* BUG: not yet */ |
} |
} |
} |
} |
if (r ISZERO) goto ss; |
if (r ISZERO) goto ss1; |
r = ecartDivideSv(r); /* r = r/s^? */ |
r = ecartDivideSv(r,&se); /* r = r/s^? */ |
} |
} |
}while (ell >= 0); |
}while (ell >= 0); |
|
|
ss: ; |
ss1: ; |
if (needSyz) { |
if (needSyz) { |
syzp->cf = cf; /* cf is in the CurrentRingp */ |
syzp->cf = cf; /* cf is in the CurrentRingp */ |
syzp->syz = syz; /* syz is in the SyzRingp */ |
syzp->syz = syz; /* syz is in the SyzRingp */ |
/* BUG: dehomogenize the syzygy */ |
/* BUG: dehomogenize the syzygy */ |
|
fprintf(stderr,"It has not yet implemented.\n"); |
|
exit(10); |
} |
} |
/* |
|
r = goDeHomogenizeS(r); |
r = goDeHomogenizeS(r); |
*/ |
|
|
return(r); |
|
} |
|
|
|
/* Functions for trace lift */ |
|
static struct ecartReducer ecartFindReducer_mod(POLY r, |
|
struct gradedPolySet *gset, |
|
struct ecartPolyArray *epa) |
|
{ |
|
int grd; |
|
struct polySet *set; |
|
int minGrade = 0; |
|
int minGseti = 0; |
|
int minGgi = 0; |
|
int ell1 = LARGE; |
|
int ell2 = LARGE; |
|
int ell; |
|
int i; |
|
struct ecartReducer er; |
|
/* Try to find a reducer in gset; */ |
|
grd = 0; |
|
while (grd < gset->maxGrade) { |
|
set = gset->polys[grd]; |
|
for (i=0; i<set->size; i++) { |
|
if (set->gh[i] == POLYNULL) { |
|
/* goHomogenize set->gh[i] */ |
|
if (EcartAutomaticHomogenization) { |
|
set->gh[i] = goHomogenize11(set->g[i],DegreeShifto_vec,DegreeShifto_size,-1,1); |
|
}else{ |
|
set->gh[i] = set->g[i]; |
|
} |
|
} |
|
if (TraceLift && (set->gmod[i] == POLYNULL)) { |
|
set->gmod[i] = modulop(set->gh[i],TraceLift_ringmod); |
|
} |
|
if (TraceLift) { |
|
ell = ecartGetEll(r,set->gmod[i]); |
|
}else{ |
|
ell = ecartGetEll(r,set->gh[i]); |
|
} |
|
if ((ell>=0) && (ell < ell1)) { |
|
ell1 = ell; |
|
minGrade = grd; minGseti=i; |
|
} |
|
} |
|
grd++; |
|
} |
|
if (epa != NULL) { |
|
/* Try to find in the second group. */ |
|
for (i=0; i< epa->size; i++) { |
|
ell = ecartGetEll(r,(epa->pa)[i]); |
|
if ((ell>=0) && (ell < ell2)) { |
|
ell2 = ell; |
|
minGgi = i; |
|
} |
|
} |
|
} |
|
|
|
if (DebugReductionRed || (DebugReductionEcart&1)) { |
|
printf("ecartFindReducer_mod(): ell1=%d, ell2=%d, minGrade=%d, minGseti=%d, minGgi=%d, p=%d\n",ell1,ell2,minGrade,minGseti,minGgi,TraceLift_ringmod->p); |
|
} |
|
if (ell1 <= ell2) { |
|
if (ell1 == LARGE) { |
|
er.ell = -1; |
|
return er; |
|
}else{ |
|
er.ell = ell1; |
|
er.first = 1; |
|
er.grade = minGrade; |
|
er.gseti = minGseti; |
|
return er; |
|
} |
|
}else{ |
|
er.ell = ell2; |
|
er.first = 0; |
|
er.ggi = minGgi; |
|
return er; |
|
} |
|
} |
|
|
|
static POLY reduction_ecart1_mod(r,gset) |
|
POLY r; |
|
struct gradedPolySet *gset; |
|
{ |
|
int reduced,reduced1,reduced2; |
|
int grd; |
|
struct polySet *set; |
|
int i; |
|
POLY cc,cg; |
|
struct ecartReducer ells; |
|
struct ecartPolyArray *gg; |
|
POLY pp; |
|
int ell; |
|
int se; |
|
|
|
extern struct ring *CurrentRingp; |
|
struct ring *rp; |
|
|
|
gg = NULL; |
|
|
|
if (r != POLYNULL) { |
|
rp = r->m->ringp; |
|
if (! rp->weightedHomogenization) { |
|
errorKan1("%s\n","ecart.c: the given ring must be declared with [(weightedHomogenization) 1]"); |
|
} |
|
} |
|
|
|
r = goHomogenize11(r,DegreeShifto_vec,DegreeShifto_size,-1,1); |
|
/* 1 means homogenize only s */ |
|
/*printf("r=%s (mod 0)\n",POLYToString(head(r),'*',1)); |
|
KshowRing(TraceLift_ringmod); **/ |
|
|
|
r = modulop(r,TraceLift_ringmod); |
|
rp = r->m->ringp; /* reset rp */ |
|
|
|
/* printf("r=%s (mod p)\n",POLYToString(head(r),'*',1)); **/ |
|
|
|
if (DebugReductionEcart&1) printf("=====================================mod\n"); |
|
do { |
|
if (DebugReductionRed) printf("(ecart1_mod(d)) r=%s\n",POLYToString(r,'*',1)); |
|
if (DebugReductionEcart & 1) printf("r=%s+,,,\n",POLYToString(head(r),'*',1)); |
|
|
|
ells = ecartFindReducer_mod(r,gset,gg); |
|
ell = ells.ell; |
|
if (ell > 0) { |
|
if (DebugReductionEcart & 2) printf("%"); |
|
gg = ecartPutPolyInG(r,gg,POLYNULL,POLYNULL); |
|
} |
|
if (ell >= 0) { |
|
if (ells.first) { |
|
pp = ((gset->polys[ells.grade])->gmod)[ells.gseti]; |
|
}else{ |
|
if (DebugReductionEcart & 4) printf("+"); |
|
pp = (gg->pa)[ells.ggi]; |
|
} |
|
if (ell > 0) r = mpMult(cxx(1,0,ell,rp),r); /* r = s^ell r */ |
|
r = (*reduction1)(r,pp,0,&cc,&cg); |
|
if (r ISZERO) goto ss1; |
|
r = ecartDivideSv(r,&se); /* r = r/s^? */ |
|
} |
|
}while (ell >= 0); |
|
|
|
ss1: ; |
|
|
|
r = goDeHomogenizeS(r); |
|
|
return(r); |
return(r); |
} |
} |