version 1.12, 2002/01/13 07:11:46 |
version 1.18, 2015/08/06 10:01:52 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2000/engine/Mgfs.c,v 1.11 2001/10/09 01:36:10 noro Exp $ */ |
/* $OpenXM: OpenXM_contrib2/asir2000/engine/Mgfs.c,v 1.17 2013/11/05 11:36:58 ohara Exp $ */ |
|
|
#include "ca.h" |
#include "ca.h" |
|
#include "inline.h" |
|
|
|
extern int current_gfs_p; |
extern int up_kara_mag, current_gfs_q1; |
extern int up_kara_mag, current_gfs_q1; |
extern int *current_gfs_plus1; |
extern int *current_gfs_plus1; |
|
|
#if defined(__GNUC__) |
#if defined(__GNUC__) |
#define INLINE inline |
#define INLINE static inline |
#elif defined(VISUAL) |
#elif defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__) |
#define INLINE __inline |
#define INLINE __inline |
#else |
#else |
#define INLINE |
#define INLINE |
Line 21 INLINE int _ADDSF(int a,int b) |
|
Line 23 INLINE int _ADDSF(int a,int b) |
|
return a; |
return a; |
|
|
a = IFTOF(a); b = IFTOF(b); |
a = IFTOF(a); b = IFTOF(b); |
|
|
|
if ( !current_gfs_ntoi ) { |
|
a = a+b-current_gfs_q; |
|
if ( a == 0 ) |
|
return 0; |
|
else { |
|
if ( a < 0 ) |
|
a += current_gfs_q; |
|
return FTOIF(a); |
|
} |
|
} |
|
|
if ( a > b ) { |
if ( a > b ) { |
/* tab[a]+tab[b] = tab[b](tab[a-b]+1) */ |
/* tab[a]+tab[b] = tab[b](tab[a-b]+1) */ |
a = current_gfs_plus1[a-b]; |
a = current_gfs_plus1[a-b]; |
Line 48 INLINE int _ADDSF(int a,int b) |
|
Line 62 INLINE int _ADDSF(int a,int b) |
|
|
|
INLINE int _MULSF(int a,int b) |
INLINE int _MULSF(int a,int b) |
{ |
{ |
|
int c; |
|
|
if ( !a || !b ) |
if ( !a || !b ) |
return 0; |
return 0; |
else { |
else if ( !current_gfs_ntoi ) { |
|
a = IFTOF(a); b = IFTOF(b); |
|
DMAR(a,b,0,current_gfs_q,c); |
|
return FTOIF(c); |
|
} else { |
a = IFTOF(a) + IFTOF(b); |
a = IFTOF(a) + IFTOF(b); |
if ( a >= current_gfs_q1 ) |
if ( a >= current_gfs_q1 ) |
a -= current_gfs_q1; |
a -= current_gfs_q1; |
Line 200 void kmulsfum(UM n1,UM n2,UM nr) |
|
Line 220 void kmulsfum(UM n1,UM n2,UM nr) |
|
len = (d+1)*d2; |
len = (d+1)*d2; |
r0 = (unsigned int *)ALLOCA(len*sizeof(int)); |
r0 = (unsigned int *)ALLOCA(len*sizeof(int)); |
bzero((char *)r0,len*sizeof(int)); |
bzero((char *)r0,len*sizeof(int)); |
m = W_UMALLOC(d2+1); |
m = W_UMALLOC(d1+d2+1); |
carry = W_UMALLOC(d2+1); |
carry = W_UMALLOC(d1+d2+1); |
t = W_UMALLOC(d1+d2+1); |
t = W_UMALLOC(d1+d2+1); |
s = W_UMALLOC(d1+d2+1); |
s = W_UMALLOC(d1+d2+1); |
for ( DEG(carry) = -1, i = 0, r = r0; i < d; i++, r += d2 ) { |
for ( DEG(carry) = -1, i = 0, r = r0; i < d; i++, r += d2 ) { |
Line 225 void kmulsfum(UM n1,UM n2,UM nr) |
|
Line 245 void kmulsfum(UM n1,UM n2,UM nr) |
|
|
|
void kmulsfummain(UM n1,UM n2,UM nr) |
void kmulsfummain(UM n1,UM n2,UM nr) |
{ |
{ |
int d1,d2,h,len; |
int d1,d2,h,len,d; |
UM n1lo,n1hi,n2lo,n2hi,hi,lo,mid1,mid2,mid,s1,s2,t1,t2; |
UM n1lo,n1hi,n2lo,n2hi,hi,lo,mid1,mid2,mid,s1,s2,t1,t2; |
|
|
d1 = DEG(n1)+1; d2 = DEG(n2)+1; h = (d1+1)/2; |
d1 = DEG(n1)+1; d2 = DEG(n2)+1; h = (d1+1)/2; |
n1lo = W_UMALLOC(d1+1); n1hi = W_UMALLOC(d1+1); |
d = d1+d2+1; |
n2lo = W_UMALLOC(d2+1); n2hi = W_UMALLOC(d2+1); |
n1lo = W_UMALLOC(d); n1hi = W_UMALLOC(d); |
lo = W_UMALLOC(d1+d2+1); hi = W_UMALLOC(d1+d2+1); |
n2lo = W_UMALLOC(d); n2hi = W_UMALLOC(d); |
mid1 = W_UMALLOC(d1+d2+1); mid2 = W_UMALLOC(d1+d2+1); |
lo = W_UMALLOC(d); hi = W_UMALLOC(d); |
mid = W_UMALLOC(d1+d2+1); |
mid1 = W_UMALLOC(d); mid2 = W_UMALLOC(d); |
s1 = W_UMALLOC(d1+d2+1); s2 = W_UMALLOC(d1+d2+1); |
mid = W_UMALLOC(d); |
|
s1 = W_UMALLOC(d); s2 = W_UMALLOC(d); |
extractum(n1,0,h,n1lo); extractum(n1,h,d1-h,n1hi); |
extractum(n1,0,h,n1lo); extractum(n1,h,d1-h,n1hi); |
extractum(n2,0,h,n2lo); extractum(n2,h,d2-h,n2hi); |
extractum(n2,0,h,n2lo); extractum(n2,h,d2-h,n2hi); |
kmulsfum(n1hi,n2hi,hi); kmulsfum(n1lo,n2lo,lo); |
kmulsfum(n1hi,n2hi,hi); kmulsfum(n1lo,n2lo,lo); |
Line 300 void diffsfum(UM f,UM fd) |
|
Line 321 void diffsfum(UM f,UM fd) |
|
|
|
for ( i = DEG(f), dp = COEF(fd)+i-1, sp = COEF(f)+i; |
for ( i = DEG(f), dp = COEF(fd)+i-1, sp = COEF(f)+i; |
i >= 1; i--, dp--, sp-- ) { |
i >= 1; i--, dp--, sp-- ) { |
*dp = _MULSF(*sp,_itosf(i)); |
*dp = _MULSF(*sp,_itosf(i%current_gfs_p)); |
} |
} |
degum(fd,DEG(f) - 1); |
degum(fd,DEG(f) - 1); |
} |
} |
Line 671 void sfmintdeg(VL vl,P fx,int dy,int c,P *fr) |
|
Line 692 void sfmintdeg(VL vl,P fx,int dy,int c,P *fr) |
|
|
|
/* create the head coeff */ |
/* create the head coeff */ |
for ( l = 0, k = dxdy-dy; l < dy; l++, k++ ) { |
for ( l = 0, k = dxdy-dy; l < dy; l++, k++ ) { |
if ( prev[k] ) { |
iftogfs(prev[k],&s); |
u = IFTOF(prev[k]); |
|
MKGFS(u,s); |
|
} else |
|
s = 0; |
|
COEF(h)[l] = (Num)s; |
COEF(h)[l] = (Num)s; |
} |
} |
for ( l = dy-1; l >= 0 && !COEF(h)[l]; l--); |
for ( l = dy-1; l >= 0 && !COEF(h)[l]; l--); |
Line 711 void sfmintdeg(VL vl,P fx,int dy,int c,P *fr) |
|
Line 728 void sfmintdeg(VL vl,P fx,int dy,int c,P *fr) |
|
for ( k = j = 0; k <= d; k++ ) |
for ( k = j = 0; k <= d; k++ ) |
for ( i = 0; i <= k; i++, j++ ) |
for ( i = 0; i <= k; i++, j++ ) |
if ( hist[j] ) { |
if ( hist[j] ) { |
u = IFTOF(hist[j]); |
iftogfs(hist[j],&s); |
MKGFS(u,s); |
|
/* mono = s*x^(k-i)*y^i */ |
/* mono = s*x^(k-i)*y^i */ |
create_bmono((P)s,x,k-i,y,i,&mono); |
create_bmono((P)s,x,k-i,y,i,&mono); |
addp(vl,f,mono,&f1); |
addp(vl,f,mono,&f1); |