Changeset 14518b in git


Ignore:
Timestamp:
Mar 25, 2003, 10:57:35 AM (21 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
Children:
46be47e4e5356f0e94a026afe9a85d4df18e9586
Parents:
b02e9fd0f795bd1e05a604e2ca3555ce3c4b82f1
Message:
*hannes: use mpz_mul_si


git-svn-id: file:///usr/local/Singular/svn/trunk@6629 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/longrat.cc

    rb02e9f r14518b  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: longrat.cc,v 1.47 2003-01-09 17:04:32 Singular Exp $ */
     4/* $Id: longrat.cc,v 1.48 2003-03-25 09:56:57 Singular Exp $ */
    55/*
    66* ABSTRACT: computation with long rational numbers (Hubert Grassmann)
     
    9898
    9999number nlOne=nlInit(1);
     100
     101#if (__GNU_MP_VERSION*10+__GNU_MP_VERSION_MINOR < 31)
     102void mpz_mul_si (mpz_ptr r, mpz_srcptr s, long int si)
     103{
     104  if (si>=0)
     105    mpz_mul_ui(r,s,si);
     106  else
     107  {
     108    mpz_mul_ui(r,s,-si);
     109    mpz_neg(r,r);
     110  }
     111}
     112#endif
    100113
    101114static int nlPrimeM;
     
    871884      if (b->s<2)
    872885      {
    873         if ((int)a>=0)
    874           mpz_mul_ui(&u->z,&b->n,SR_TO_INT(a));
    875         else
    876         {
    877           mpz_mul_ui(&u->z,&b->n,-SR_TO_INT(a));
    878           mpz_neg(&u->z,&u->z);
    879         }
     886        mpz_mul_si(&u->z,&b->n,SR_TO_INT(a));
    880887      }
    881888      else
     
    900907      {
    901908        mpz_init_set(&u->n,&a->n);
    902         if ((int)b>0)
    903           mpz_mul_ui(&u->n,&u->n,SR_TO_INT(b));
    904         else
    905         {
    906           mpz_mul_ui(&u->n,&u->n,-SR_TO_INT(b));
    907           mpz_neg(&u->z,&u->z);
    908         }
     909        mpz_mul_si(&u->n,&u->n,SR_TO_INT(b));
    909910      }
    910911      else
     
    13831384    MP_INT  bb;
    13841385    mpz_init_set(&bb,&b->n);
    1385     if ((int)a<0)
    1386     {
    1387       mpz_neg(&bb,&bb);
    1388       mpz_mul_ui(&bb,&bb,(long)-SR_TO_INT(a));
    1389     }
    1390     else
    1391     {
    1392       mpz_mul_ui(&bb,&bb,(long)SR_TO_INT(a));
    1393     }
     1386    mpz_mul_si(&bb,&bb,(long)SR_TO_INT(a));
    13941387    bo=(mpz_cmp(&bb,&b->z)==0);
    13951388    mpz_clear(&bb);
     
    15051498        MP_INT x;
    15061499        mpz_init(&x);
    1507         if ((int)a>0)
    1508         {
    1509           mpz_mul_ui(&x,&b->n,SR_TO_INT(a));
    1510         }
    1511         else
    1512         {
    1513           mpz_mul_ui(&x,&b->n,-SR_TO_INT(a));
    1514           mpz_neg(&x,&x);
    1515         }
     1500        mpz_mul_si(&x,&b->n,SR_TO_INT(a));
    15161501        mpz_add(&u->z,&b->z,&x);
    15171502        mpz_clear(&x);
     
    17041689        MP_INT x;
    17051690        mpz_init(&x);
    1706         if ((int)a>0)
    1707         {
    1708           mpz_mul_ui(&x,&b->n,SR_TO_INT(a));
    1709         }
    1710         else
    1711         {
    1712           mpz_mul_ui(&x,&b->n,-SR_TO_INT(a));
    1713           mpz_neg(&x,&x);
    1714         }
     1691        mpz_mul_si(&x,&b->n,SR_TO_INT(a));
    17151692        mpz_sub(&u->z,&x,&b->z);
    17161693        mpz_clear(&x);
     
    17741751        MP_INT x;
    17751752        mpz_init(&x);
    1776         if ((int)b>0)
    1777         {
    1778           mpz_mul_ui(&x,&a->n,SR_TO_INT(b));
    1779         }
    1780         else
    1781         {
    1782           mpz_mul_ui(&x,&a->n,-SR_TO_INT(b));
    1783           mpz_neg(&x,&x);
    1784         }
     1753        mpz_mul_si(&x,&a->n,SR_TO_INT(b));
    17851754        mpz_sub(&u->z,&a->z,&x);
    17861755        mpz_clear(&x);
     
    19701939#endif
    19711940  u->s=3;
    1972   if ((int)b>0)
    1973   {
    1974     mpz_init_set_si(&u->z,(long)SR_TO_INT(a));
    1975     mpz_mul_ui(&u->z,&u->z,(unsigned long)SR_TO_INT(b));
    1976   }
    1977   else
    1978   {
    1979     mpz_init_set_si(&u->z,(long)(-SR_TO_INT(a)));
    1980     mpz_mul_ui(&u->z,&u->z,(long)(-SR_TO_INT(b)));
    1981   }
     1941  mpz_init_set_si(&u->z,(long)SR_TO_INT(a));
     1942  mpz_mul_si(&u->z,&u->z,(unsigned long)SR_TO_INT(b));
    19821943#ifdef LDEBUG
    19831944  nlTest(u);
Note: See TracChangeset for help on using the changeset viewer.