=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/builtin/fctr.c,v retrieving revision 1.19 retrieving revision 1.24 diff -u -p -r1.19 -r1.24 --- OpenXM_contrib2/asir2000/builtin/fctr.c 2003/01/13 06:40:40 1.19 +++ OpenXM_contrib2/asir2000/builtin/fctr.c 2017/02/27 05:14:54 1.24 @@ -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/builtin/fctr.c,v 1.18 2003/01/06 01:16:38 noro Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/builtin/fctr.c,v 1.23 2004/07/30 07:34:40 noro Exp $ */ #include "ca.h" #include "parse.h" @@ -338,12 +338,42 @@ P *rp; void Pptozp(arg,rp) NODE arg; -P *rp; +Obj *rp; { Q t; + NODE tt,p; + NODE n,n0; + char *key; + P pp; + LIST list; + int get_factor=0; asir_assert(ARG0(arg),O_P,"ptozp"); - ptozp((P)ARG0(arg),1,&t,rp); + + /* analyze the option */ + if ( current_option ) { + for ( tt = current_option; tt; tt = NEXT(tt) ) { + p = BDY((LIST)BDY(tt)); + key = BDY((STRING)BDY(p)); + /* value = (Obj)BDY(NEXT(p)); */ + if ( !strcmp(key,"factor") ) get_factor=1; + else { + error("ptozp: unknown option."); + } + } + } + + ptozp((P)ARG0(arg),1,&t,&pp); + + /* printexpr(NULL,t); */ + /* if the option factor is given, then it returns the answer + in the format [zpoly, num] where num*zpoly is equal to the argument.*/ + if (get_factor) { + n0 = mknode(2,pp,t); + MKLIST(list,n0); + *rp = (Obj)list; + } else + *rp = (Obj)pp; } void Pafctr(arg,rp) @@ -408,7 +438,7 @@ LIST *rp; modfctrp(ARG0(arg),mod,NEWDDD,&dc); else { /* XXX 16384 should be replaced by a macro */ - for ( i = 0, t = 1; t*mod < 16384; t *= mod, i++ ); + for ( i = 1, t = mod; t*mod < 16384; t *= mod, i++ ); current_ff = FF_GFS; setmod_sf(mod,i); simp_ff((Obj)p,&u);