=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2018/engine/Q.c,v retrieving revision 1.14 retrieving revision 1.17 diff -u -p -r1.14 -r1.17 --- OpenXM_contrib2/asir2018/engine/Q.c 2019/03/27 07:45:53 1.14 +++ OpenXM_contrib2/asir2018/engine/Q.c 2020/01/09 01:47:41 1.17 @@ -1,11 +1,11 @@ -/* $OpenXM: OpenXM_contrib2/asir2018/engine/Q.c,v 1.13 2019/03/18 07:00:33 noro Exp $ */ +/* $OpenXM: OpenXM_contrib2/asir2018/engine/Q.c,v 1.16 2019/05/22 02:41:16 noro Exp $ */ #include "ca.h" #include "gmp.h" #include "base.h" #include "inline.h" mpz_t ONEMPZ; -Z ONE; +extern Z ONE; int lf_lazy; Z current_mod_lf; int current_mod_lf_size; @@ -558,7 +558,7 @@ void subq(Q n1,Q n2,Q *nr) if ( !n1 ) { if ( !n2 ) *nr = 0; - else if ( n1->z ) chsgnz((Z)n1,(Z *)nr); + else if ( n2->z ) chsgnz((Z)n2,(Z *)nr); else { mpq_init(t); mpq_neg(t,BDY(n2)); MPQTOQ(t,*nr); } @@ -762,12 +762,15 @@ void lgp(P p,Z *g,Z *l); void ptozp(P p,int sgn,Q *c,P *pr) { - Z nm,dn; + Z nm,dn,nm1; if ( !p ) { *c = 0; *pr = 0; } else { lgp(p,&nm,&dn); + if ( sgn < 0 ) { + chsgnz(nm,&nm1); nm = nm1; + } divz(nm,dn,(Z *)c); divsp(CO,p,(P)*c,pr); }