=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/engine/gfs.c,v retrieving revision 1.15 retrieving revision 1.18 diff -u -p -r1.15 -r1.18 --- OpenXM_contrib2/asir2000/engine/gfs.c 2003/01/06 01:16:39 1.15 +++ OpenXM_contrib2/asir2000/engine/gfs.c 2017/02/27 05:14:54 1.18 @@ -45,7 +45,7 @@ * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. * - * $OpenXM: OpenXM_contrib2/asir2000/engine/gfs.c,v 1.14 2002/12/18 06:15:40 noro Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/engine/gfs.c,v 1.17 2003/05/07 06:26:49 noro Exp $ */ #include "ca.h" #include "inline.h" @@ -511,6 +511,7 @@ void setmod_sf(int p,int n) for ( i = 0, q = 1; i < n; i++ ) q *= p; + if ( p == current_gfs_p && q == current_gfs_q ) return; dp = UMALLOC(n); r = search_defpoly_and_primitive_root(p,n,dp); if ( !r ) { @@ -727,6 +728,8 @@ void qtogfs(Q a,GFS *c) { int s; + if ( a && (SGN(a) < 1) ) + error("qtogfs : invalid argument"); s = QTOS(a)%current_gfs_q; itogfs(s,c); } @@ -748,6 +751,21 @@ void gfstomq(GFS a,MQ *c) } else { UTOMQ(current_gfs_iton[CONT(a)],*c); } +} + +void gfstopgfs(GFS a,V v,P *c) +{ + MQ t; + Q q; + + if ( !a ) + *c = 0; + else if ( !current_gfs_ntoi ) { + UTOMQ(CONT(a),t); + STOQ(CONT(t),q); + *c = (P)q; + } else + enc_to_p(current_gfs_p,current_gfs_iton[CONT(a)],v,c); } void ntogfs(Obj a,GFS *b)