version 1.8, 2003/08/19 08:02:09 |
version 1.10, 2003/08/20 05:18:35 |
|
|
/* $OpenXM: OpenXM/src/kan96xx/Kan/ecart.c,v 1.7 2003/07/30 09:00:52 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kan96xx/Kan/ecart.c,v 1.9 2003/08/20 01:39:17 takayama Exp $ */ |
#include <stdio.h> |
#include <stdio.h> |
#include "datatype.h" |
#include "datatype.h" |
#include "extern2.h" |
#include "extern2.h" |
Line 36 static POLY reduction_ecart1(POLY r,struct gradedPolyS |
|
Line 36 static POLY reduction_ecart1(POLY r,struct gradedPolyS |
|
static POLY reduction_ecart1_mod(POLY r,struct gradedPolySet *gset); |
static POLY reduction_ecart1_mod(POLY r,struct gradedPolySet *gset); |
static POLY ecartCheckSyz0(POLY cf,POLY r_0,POLY syz, |
static POLY ecartCheckSyz0(POLY cf,POLY r_0,POLY syz, |
struct gradedPolySet *gg,POLY r); |
struct gradedPolySet *gg,POLY r); |
|
static int shouldReduceContent(POLY f,int ss); |
|
|
extern int DebugReductionRed; |
extern int DebugReductionRed; |
extern int TraceLift; |
extern int TraceLift; |
struct ring *TraceLift_ringmod; |
struct ring *TraceLift_ringmod; |
|
extern DoCancel; |
int DebugReductionEcart = 0; |
int DebugReductionEcart = 0; |
|
|
/* This is used for goHomogenization */ |
/* This is used for goHomogenization */ |
Line 252 POLY reduction_ecart(r,gset,needSyz,syzp) |
|
Line 254 POLY reduction_ecart(r,gset,needSyz,syzp) |
|
warningPoly("reduction_ecart: TraceLift_ringmod is not set.\n"); |
warningPoly("reduction_ecart: TraceLift_ringmod is not set.\n"); |
return reduction_ecart1(r,gset,needSyz,syzp); |
return reduction_ecart1(r,gset,needSyz,syzp); |
} |
} |
rn = reduction_ecart1_mod(r,gset); |
rn = reduction_ecart1_mod(r,gset); /* BUG: syzygy is not obtained. */ |
if (rn == POLYNULL) return rn; |
if (rn == POLYNULL) return rn; |
else return reduction_ecart1(r,gset,needSyz,syzp); |
else return reduction_ecart1(r,gset,needSyz,syzp); |
}else{ |
}else{ |
Line 399 static POLY reduction_ecart1(r,gset,needSyz,syzp) |
|
Line 401 static POLY reduction_ecart1(r,gset,needSyz,syzp) |
|
POLY pp; |
POLY pp; |
int ell; |
int ell; |
int se; |
int se; |
|
struct coeff *cont; |
|
|
extern struct ring *CurrentRingp; |
extern struct ring *CurrentRingp; |
struct ring *rp; |
struct ring *rp; |
|
extern struct ring *SmallRingp; |
|
|
gg = NULL; |
gg = NULL; |
if (needSyz) { |
if (needSyz) { |
Line 419 static POLY reduction_ecart1(r,gset,needSyz,syzp) |
|
Line 423 static POLY reduction_ecart1(r,gset,needSyz,syzp) |
|
|
|
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 (DoCancel && (r != POLYNULL)) shouldReduceContent(r,1); |
|
|
if (DebugReductionEcart&1) printf("=======================================\n"); |
if (DebugReductionEcart&1) printf("=======================================\n"); |
do { |
do { |
Line 435 static POLY reduction_ecart1(r,gset,needSyz,syzp) |
|
Line 440 static POLY reduction_ecart1(r,gset,needSyz,syzp) |
|
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("+"); |
if (DebugReductionEcart & 4) {printf("+"); fflush(NULL);} |
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 */ |
r = (*reduction1)(r,pp,needSyz,&cc,&cg); |
r = (*reduction1)(r,pp,needSyz,&cc,&cg); |
|
|
|
if (DoCancel && (r != POLYNULL)) { /* BUG: syzygy should be corrected. */ |
|
if (shouldReduceContent(r,0)) { |
|
r = reduceContentOfPoly(r,&cont); |
|
shouldReduceContent(r,1); |
|
if (DebugReductionEcart || DebugReductionRed) printf("CONT=%d ",coeffToString(cont)); |
|
} |
|
} |
|
|
if (needSyz) { |
if (needSyz) { |
if (ells.first) { |
if (ells.first) { |
cf = ppMult(cc,cf); |
cf = ppMult(cc,cf); |
Line 466 static POLY reduction_ecart1(r,gset,needSyz,syzp) |
|
Line 480 static POLY reduction_ecart1(r,gset,needSyz,syzp) |
|
} |
} |
|
|
r = goDeHomogenizeS(r); |
r = goDeHomogenizeS(r); |
|
if (DoCancel && (r != POLYNULL)) { /* BUG: syzygy should be corrected. */ |
|
if (r->m->ringp->p == 0) { |
|
if (coeffSizeMin(r) >= DoCancel) { |
|
r = reduceContentOfPoly(r,&cont); |
|
if (DebugReductionEcart || DebugReductionRed) printf("cont=%d ",coeffToString(cont)); |
|
} |
|
} |
|
} |
|
|
return(r); |
return(r); |
} |
} |
Line 598 static POLY reduction_ecart1_mod(r,gset) |
|
Line 620 static POLY reduction_ecart1_mod(r,gset) |
|
if (ells.first) { |
if (ells.first) { |
pp = ((gset->polys[ells.grade])->gmod)[ells.gseti]; |
pp = ((gset->polys[ells.grade])->gmod)[ells.gseti]; |
}else{ |
}else{ |
if (DebugReductionEcart & 4) printf("+"); |
if (DebugReductionEcart & 4) {printf("+"); fflush(NULL);} |
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 613 static POLY reduction_ecart1_mod(r,gset) |
|
Line 635 static POLY reduction_ecart1_mod(r,gset) |
|
r = goDeHomogenizeS(r); |
r = goDeHomogenizeS(r); |
|
|
return(r); |
return(r); |
|
} |
|
|
|
static int shouldReduceContent(POLY f,int ss) { |
|
static int prevSize = 1; |
|
int size; |
|
if (f == POLYNULL) return 0; |
|
if (f->m->ringp->p != 0) return 0; |
|
if (f->coeffp->tag != MP_INTEGER) return 0; |
|
size = mpz_size(f->coeffp->val.bigp); |
|
if (ss > 0) { |
|
prevSize = size; |
|
return 0; |
|
} |
|
if (size > 2*prevSize) { |
|
return 1; |
|
}else{ |
|
return 0; |
|
} |
} |
} |