Changeset 14518b in git
- Timestamp:
- Mar 25, 2003, 10:57:35 AM (21 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
- Children:
- 46be47e4e5356f0e94a026afe9a85d4df18e9586
- Parents:
- b02e9fd0f795bd1e05a604e2ca3555ce3c4b82f1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/longrat.cc
rb02e9f r14518b 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: longrat.cc,v 1.4 7 2003-01-09 17:04:32Singular Exp $ */4 /* $Id: longrat.cc,v 1.48 2003-03-25 09:56:57 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: computation with long rational numbers (Hubert Grassmann) … … 98 98 99 99 number nlOne=nlInit(1); 100 101 #if (__GNU_MP_VERSION*10+__GNU_MP_VERSION_MINOR < 31) 102 void 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 100 113 101 114 static int nlPrimeM; … … 871 884 if (b->s<2) 872 885 { 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)); 880 887 } 881 888 else … … 900 907 { 901 908 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)); 909 910 } 910 911 else … … 1383 1384 MP_INT bb; 1384 1385 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)); 1394 1387 bo=(mpz_cmp(&bb,&b->z)==0); 1395 1388 mpz_clear(&bb); … … 1505 1498 MP_INT x; 1506 1499 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)); 1516 1501 mpz_add(&u->z,&b->z,&x); 1517 1502 mpz_clear(&x); … … 1704 1689 MP_INT x; 1705 1690 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)); 1715 1692 mpz_sub(&u->z,&x,&b->z); 1716 1693 mpz_clear(&x); … … 1774 1751 MP_INT x; 1775 1752 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)); 1785 1754 mpz_sub(&u->z,&a->z,&x); 1786 1755 mpz_clear(&x); … … 1970 1939 #endif 1971 1940 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)); 1982 1943 #ifdef LDEBUG 1983 1944 nlTest(u);
Note: See TracChangeset
for help on using the changeset viewer.