version 1.2, 2000/01/16 07:55:40 |
version 1.9, 2020/10/06 11:33:46 |
|
|
/* $OpenXM$ */ |
/* $OpenXM: OpenXM/src/kan96xx/Kan/poly3.c,v 1.8 2004/06/12 07:29:46 takayama Exp $ */ |
#include <stdio.h> |
#include <stdio.h> |
#include "datatype.h" |
#include "datatype.h" |
#include "extern2.h" |
#include "extern2.h" |
|
|
|
void outputTable(void); |
|
|
int Homogenize = 1; |
int Homogenize = 1; |
|
|
#define I(i,j) (i*N0+j) |
#define I(i,j) (i*N0+j) |
|
|
static POLY *RList; |
static POLY *RList; |
static POLY *RListRoot; |
static POLY *RListRoot; |
static struct coeff *Tc = (struct coeff *)NULL; |
static struct coeff *Tc = (struct coeff *)NULL; |
/* It is initialized in mpMult_diff() */ |
/* It is initialized in mpMult_diff() */ |
|
|
void initT(void) { |
void initT(void) { |
int i; |
int i; |
Line 28 void initT(void) { |
|
Line 30 void initT(void) { |
|
EList = (int *)sGC_malloc(sizeof(int)*Lsize); |
EList = (int *)sGC_malloc(sizeof(int)*Lsize); |
Mark = (int *)sGC_malloc(sizeof(int)*Lsize); |
Mark = (int *)sGC_malloc(sizeof(int)*Lsize); |
/* The following line causes the warning 'needed to allocate blacklisted..' |
/* The following line causes the warning 'needed to allocate blacklisted..' |
|
DList = (int *)sGC_malloc(sizeof(int)*Lsize*N0); |
|
MList = (int *)sGC_malloc(sizeof(int)*Lsize*N0); |
|
*/ |
DList = (int *)sGC_malloc(sizeof(int)*Lsize*N0); |
DList = (int *)sGC_malloc(sizeof(int)*Lsize*N0); |
MList = (int *)sGC_malloc(sizeof(int)*Lsize*N0); |
MList = (int *)sGC_malloc(sizeof(int)*Lsize*N0); |
*/ |
|
DList = (int *)malloc(sizeof(int)*Lsize*N0); |
|
MList = (int *)malloc(sizeof(int)*Lsize*N0); |
|
|
|
RList = (POLY *)sGC_malloc(sizeof(POLY)*Lsize); |
RList = (POLY *)sGC_malloc(sizeof(POLY)*Lsize); |
RListRoot = (POLY *)sGC_malloc(sizeof(POLY)*Lsize); |
RListRoot = (POLY *)sGC_malloc(sizeof(POLY)*Lsize); |
Line 41 void initT(void) { |
|
Line 43 void initT(void) { |
|
} |
} |
|
|
void makeTable(c,e,ringp) |
void makeTable(c,e,ringp) |
struct coeff *c; /* read only */ |
struct coeff *c; /* read only */ |
struct exps e[]; |
struct exps e[]; |
struct ring *ringp; |
struct ring *ringp; |
{ |
{ |
int i,j,k,p,q,deg,m,n; |
int i,j,k,p,q,deg,m,n; |
m = ringp->m; n = ringp->n; |
m = ringp->m; n = ringp->n; |
Line 66 struct ring *ringp; |
|
Line 68 struct ring *ringp; |
|
/* Copy j-th row to k-th row and modify it. */ |
/* Copy j-th row to k-th row and modify it. */ |
for (j=0; j<Plist; j++) { |
for (j=0; j<Plist; j++) { |
for (q=1; q<=DList[I(j,i)]; q++) { |
for (q=1; q<=DList[I(j,i)]; q++) { |
for (p=0; p<Maxv; p++) { /* copy */ |
for (p=0; p<Maxv; p++) { /* copy */ |
DList[I(k,p)] = DList[I(j,p)]; |
DList[I(k,p)] = DList[I(j,p)]; |
MList[I(k,p)] = MList[I(j,p)]; |
MList[I(k,p)] = MList[I(j,p)]; |
} |
} |
/* modify */ |
/* modify */ |
DList[I(k,i)] -= q; |
DList[I(k,i)] -= q; |
MList[I(k,i)] += q; |
MList[I(k,i)] += q; |
|
|
CiiComb(Tc,DList[I(j,i)],q); |
CiiComb(Tc,DList[I(j,i)],q); |
/* Tc->val.bigp is read only. */ |
/* Tc->val.bigp is read only. */ |
CList[k] = coeffCopy(Tc); |
CList[k] = coeffCopy(Tc); |
Cmult(CList[k],CList[k],CList[j]); |
Cmult(CList[k],CList[k],CList[j]); |
/*CList[k] = normalize(CList[j]*BiiComb(DList[I(j,i)],q));*/ |
/*CList[k] = normalize(CList[j]*BiiComb(DList[I(j,i)],q));*/ |
|
|
EList[k] = EList[j]-2*q; |
EList[k] = EList[j]-2*q; |
Mark[k] = 0; |
Mark[k] = 0; |
k++; |
k++; |
if (k>= Lsize) { |
if (k>= Lsize) { |
errorPoly("makeTable(): Lsize is not large enough.\n"); |
errorPoly("makeTable(): Lsize is not large enough.\n"); |
} |
} |
} |
} |
} |
} |
Plist = k; |
Plist = k; |
Line 93 struct ring *ringp; |
|
Line 95 struct ring *ringp; |
|
} |
} |
|
|
void monomialMult_diff(e,f) |
void monomialMult_diff(e,f) |
struct exps e[]; |
struct exps e[]; |
POLY f; |
POLY f; |
/* (e) * f = [Plist] monomials */ |
/* (e) * f = [Plist] monomials */ |
{ |
{ |
|
|
int n,k,c,l,q,i,m; |
int n,k,c,l,q,i,m, weightedHomogenization; |
struct coeff *a; |
struct coeff *a; |
struct monomial tmp; |
struct monomial tmp; |
struct ring *ringp; |
struct ring *ringp; |
|
|
|
|
tmp.ringp = ringp = f->m->ringp; |
tmp.ringp = ringp = f->m->ringp; |
n = ringp->n; c = ringp->c; l = ringp->l; m = ringp->m; |
n = ringp->n; c = ringp->c; l = ringp->l; m = ringp->m; |
|
weightedHomogenization = ringp->weightedHomogenization; |
for (k=Plist-1; k>=0; k--) { |
for (k=Plist-1; k>=0; k--) { |
/* coeff */ |
/* coeff */ |
a = coeffCopy(CList[k]); |
a = coeffCopy(CList[k]); |
|
|
for (i=0; i<n; i++) { |
for (i=0; i<n; i++) { |
tmp.e[i] = f->m->e[i]; |
tmp.e[i] = f->m->e[i]; |
} |
} |
if (Homogenize) { |
if ((!weightedHomogenization) && Homogenize) { |
tmp.e[0].D += EList[k]; /* homogenization. |
if (Homogenize == 3) { |
e[0].D will be added later. */ |
tmp.e[0].D += EList[k]/2; /* Double homogenization. */ |
} |
tmp.e[0].x += EList[k]/2; /* Dx x = x Dx + h H */ |
|
}else{ |
|
tmp.e[0].D += EList[k]; /* homogenization. |
|
e[0].D will be added later. */ |
|
} |
|
}else if (weightedHomogenization && Homogenize) { |
|
tmp.e[0].D += EList[k]/2 ; /* homogenization. Weight is (1,0) (special). |
|
*/ |
|
} |
|
|
/* from m to n: Differential variables. */ |
/* from m to n: Differential variables. */ |
for (i=0; i<Maxv; i++) { |
for (i=0; i<Maxv; i++) { |
|
|
if (l-c > 0) { |
if (l-c > 0) { |
q =0; |
q =0; |
for (i=c; i<l; i++) { |
for (i=c; i<l; i++) { |
q += (e[i].D)*(tmp.e[i].x); /* Don't repeat these things. */ |
q += (e[i].D)*(tmp.e[i].x); /* Don't repeat these things. */ |
tmp.e[i].D += e[i].D; |
tmp.e[i].D += e[i].D; |
} |
} |
/*printf("l=%d, q=%d\n",l,q);*/ |
/*printf("l=%d, q=%d\n",l,q);*/ |
if (ringp->next == (struct ring *)NULL) { |
if (ringp->next == (struct ring *)NULL) { |
tmp.e[0].x += q; |
tmp.e[0].x += q; |
}else{ |
}else{ |
Cmult(a,a,polyToCoeff(cxx(1,0,q,ringp->next),ringp)); |
Cmult(a,a,polyToCoeff(cxx(1,0,q,ringp->next),ringp)); |
/* x[0]^q */ |
/* x[0]^q */ |
} |
} |
} |
} |
|
|
Line 214 POLY mpMult_diff(POLY f,POLY g) |
|
Line 225 POLY mpMult_diff(POLY f,POLY g) |
|
return(r); |
return(r); |
} |
} |
|
|
POLY mpMult_difference(POLY f,POLY g) |
POLY mpMult_difference_org(POLY f,POLY g) |
{ |
{ |
POLY r; |
POLY r; |
int m,l; |
int m,l; |
Line 237 POLY mpMult_difference(POLY f,POLY g) |
|
Line 248 POLY mpMult_difference(POLY f,POLY g) |
|
if (f->m->e[i].D) { |
if (f->m->e[i].D) { |
lRule[size] = cxx(1,i,1,f->m->ringp); |
lRule[size] = cxx(1,i,1,f->m->ringp); |
if (Homogenize) { |
if (Homogenize) { |
rRule[size] = ppAdd(cxx(1,i,1,f->m->ringp),cdd(f->m->e[i].D,0,1,f->m->ringp)); |
rRule[size] = ppAdd(cxx(1,i,1,f->m->ringp),cdd(f->m->e[i].D,0,1,f->m->ringp)); |
/* x_i + e[i].D h */ |
/* x_i + e[i].D h */ |
}else{ |
}else{ |
rRule[size] = ppAdd(cxx(1,i,1,f->m->ringp),cdd(f->m->e[i].D,0,0,f->m->ringp)); |
rRule[size] = ppAdd(cxx(1,i,1,f->m->ringp),cdd(f->m->e[i].D,0,0,f->m->ringp)); |
/* x_i + e[i].D */ |
/* x_i + e[i].D */ |
} |
} |
size++; |
size++; |
} |
} |
} |
} |
Line 253 POLY mpMult_difference(POLY f,POLY g) |
|
Line 264 POLY mpMult_difference(POLY f,POLY g) |
|
return(r); |
return(r); |
} |
} |
|
|
outputTable() { |
void outputTable() { |
int i,j; |
int i,j; |
printf("Maxv = %d Plist=%d\n",Maxv,Plist); |
printf("Maxv = %d Plist=%d\n",Maxv,Plist); |
for (i=0; i<Maxv; i++) printf("%5d",V[i]); |
for (i=0; i<Maxv; i++) printf("%5d",V[i]); |