Changeset 52f3e2 in git for libpolys/coeffs


Ignore:
Timestamp:
Oct 30, 2017, 5:22:14 PM (7 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '98550b669234b32be762076c32b3be2c35188ac4')
Children:
79cf8deb6345ba7a1926425bdd8e4a960457dd8e
Parents:
a0d56992e4e80ffc9703185cade05f3a601f3645
Message:
opt: better 0-test for mpz_t
Location:
libpolys/coeffs
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/flintcf_Q.cc

    ra0d569 r52f3e2  
    264264    mpq_get_num(num,m);
    265265    mpq_get_den(den,m);
    266     if (mpz_cmp_ui(num,0)!=0)
     266    if (mpz_sgn1(num)!=0)
    267267    {
    268       if (need_plus && (mpz_cmp_si(num,0)>0))
     268      if (need_plus && (mpz_sgn1(num)>0))
    269269        StringAppendS("+");
    270270      need_plus=TRUE;
  • libpolys/coeffs/longrat.cc

    ra0d569 r52f3e2  
    116116{
    117117  assume(x->s==3);
    118   if (mpz_cmp_ui(x->z,0L)==0)
     118  if (mpz_sgn1(x->z)==0)
    119119  {
    120120    mpz_clear(x->z);
     
    149149
    150150#define MP_SMALL 1
    151 //#define mpz_isNeg(A) (mpz_cmp_si(A,0L)<0)
     151//#define mpz_isNeg(A) (mpz_sgn1(A)<0)
    152152#define mpz_isNeg(A) ((A)->_mp_size<0)
    153153#define mpz_limb_size(A) ((A)->_mp_size)
     
    13251325{
    13261326  assume(x->s<2);
    1327   if (mpz_cmp_ui(x->z,0L)==0)
     1327  if (mpz_sgn1(x->z)==0)
    13281328  {
    13291329    _nlDelete_NoImm(&x);
     
    17031703        mpz_add(u->z,b->z,x);
    17041704        mpz_clear(x);
    1705         if (mpz_cmp_ui(u->z,0L)==0)
     1705        if (mpz_sgn1(u->z)==0)
    17061706        {
    17071707          mpz_clear(u->z);
     
    17521752            mpz_clear(x);
    17531753
    1754             if (mpz_cmp_ui(u->z,0L)==0)
     1754            if (mpz_sgn1(u->z)==0)
    17551755            {
    17561756              mpz_clear(u->z);
     
    17751775            mpz_mul(u->z,b->z,a->n);
    17761776            mpz_add(u->z,u->z,a->z);
    1777             if (mpz_cmp_ui(u->z,0L)==0)
     1777            if (mpz_sgn1(u->z)==0)
    17781778            {
    17791779              mpz_clear(u->z);
     
    18041804            mpz_mul(u->z,a->z,b->n);
    18051805            mpz_add(u->z,u->z,b->z);
    1806             if (mpz_cmp_ui(u->z,0L)==0)
     1806            if (mpz_sgn1(u->z)==0)
    18071807            {
    18081808              mpz_clear(u->z);
     
    19981998        mpz_sub(u->z,x,b->z);
    19991999        mpz_clear(x);
    2000         if (mpz_cmp_ui(u->z,0L)==0)
     2000        if (mpz_sgn1(u->z)==0)
    20012001        {
    20022002          mpz_clear(u->z);
     
    20452045        mpz_sub(u->z,a->z,x);
    20462046        mpz_clear(x);
    2047         if (mpz_cmp_ui(u->z,0L)==0)
     2047        if (mpz_sgn1(u->z)==0)
    20482048        {
    20492049          mpz_clear(u->z);
     
    20992099            mpz_clear(x);
    21002100            mpz_clear(y);
    2101             if (mpz_cmp_ui(u->z,0L)==0)
     2101            if (mpz_sgn1(u->z)==0)
    21022102            {
    21032103              mpz_clear(u->z);
     
    21252125            mpz_sub(u->z,a->z,x);
    21262126            mpz_clear(x);
    2127             if (mpz_cmp_ui(u->z,0L)==0)
     2127            if (mpz_sgn1(u->z)==0)
    21282128            {
    21292129              mpz_clear(u->z);
     
    21572157            mpz_sub(u->z,x,b->z);
    21582158            mpz_clear(x);
    2159             if (mpz_cmp_ui(u->z,0L)==0)
     2159            if (mpz_sgn1(u->z)==0)
    21602160            {
    21612161              mpz_clear(u->z);
     
    28232823  mpz_init2(tmp,bits);
    28242824  number z=INT_TO_SR(0);
    2825   while(mpz_cmp_si(N,0L)!=0)
     2825  while(mpz_sgn1(N)!=0)
    28262826  {
    28272827    mpz_mul(tmp,N,N);
  • libpolys/coeffs/rintegers.cc

    ra0d569 r52f3e2  
    203203static BOOLEAN nrzIsOne (number a, const coeffs)
    204204{
    205   return (a!=NULL) && (0 == mpz_cmp_si((mpz_ptr) a, 1));
     205  return (a!=NULL) && (0 == mpz_cmp_ui((mpz_ptr) a, 1));
    206206}
    207207
     
    223223static BOOLEAN nrzGreaterZero (number k, const coeffs)
    224224{
    225   return 0 < mpz_cmp_si((mpz_ptr) k, 0);
     225  return 0 < mpz_sgn1((mpz_ptr) k);
    226226}
    227227
     
    653653  nrzWrite(x, NULL);
    654654#endif
    655   if (mpz_cmp_ui((mpz_ptr) x,0L)==0)
     655  if (mpz_sgn1((mpz_ptr) x)==0)
    656656  {
    657657    mpz_clear((mpz_ptr)x);
     
    14231423#endif
    14241424
    1425   if (mpz_cmp_si(r, 0)!=0)
     1425  if (mpz_sgn1(r)!=0)
    14261426  {
    14271427    //WerrorS("4:Division by non divisible element.");
     
    16451645{
    16461646  if (SR_HDL(x) & SR_INT) return TRUE;
    1647   if (mpz_cmp_ui((mpz_ptr) x,0L)==0)
     1647  if (mpz_sgn1((mpz_ptr) x)==0)
    16481648  {
    16491649    Print("gmp-0 %s:%d\n",f,l);
  • libpolys/coeffs/rmodulo2m.cc

    ra0d569 r52f3e2  
    212212  mpz_init(rr);
    213213
    214   while (mpz_cmp_ui(v, 0) != 0) /* i.e., while v != 0 */
     214  while (mpz_sgn1(v) != 0) /* i.e., while v != 0 */
    215215  {
    216216    mpz_div(q, u, v);
     
    226226  }
    227227
    228   while (mpz_cmp_ui(u1, 0) < 0) /* i.e., while u1 < 0 */
     228  while (mpz_sgn1(u1) < 0) /* i.e., while u1 < 0 */
    229229  {
    230230    /* we add 2^m = (2^m - 1) + 1 to u1: */
  • libpolys/coeffs/rmodulon.cc

    ra0d569 r52f3e2  
    481481static BOOLEAN nrnGreaterZero(number k, const coeffs)
    482482{
    483   return 0 < mpz_cmp_si((mpz_ptr)k, 0);
     483  return 0 < mpz_sgn1((mpz_ptr)k);
    484484}
    485485
     
    850850
    851851#ifdef LDEBUG
    852 BOOLEAN nrnDBTest (number a, const char *, const int, const coeffs r)
     852BOOLEAN nrnDBTest (number a, const char *f, const int l, const coeffs r)
    853853{
    854854  if (a==NULL) return TRUE;
    855   if ( (mpz_cmp_si((mpz_ptr) a, 0) < 0) || (mpz_cmp((mpz_ptr) a, r->modNumber) > 0) )
    856   {
     855  if ( (mpz_sgn1((mpz_ptr) a) < 0) || (mpz_cmp((mpz_ptr) a, r->modNumber) > 0) )
     856  {
     857    Warn("mod-n: out of range at %s:%d\n",f,l);
    857858    return FALSE;
    858859  }
  • libpolys/coeffs/si_gmp.h

    ra0d569 r52f3e2  
    1111// This is taken from longrat.h: it seems to be generally GMP-related
    1212#define mpz_size1(A) (ABS((A)->_mp_size))
     13#define mpz_sgn1(A) ((A)->_mp_size)
    1314//#define mpz_size1(A) mpz_size(A)
    1415#endif // mpz_size1
Note: See TracChangeset for help on using the changeset viewer.