Changeset 54bb6b in git for libpolys/coeffs/rintegers.cc


Ignore:
Timestamp:
Jul 3, 2018, 5:23:27 PM (5 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'e7cc1ebecb61be8b9ca6c18016352af89940b21a')
Children:
acb07ec581d8593b7eb367dd1cbd785808f4ae86
Parents:
417a91a95b5bf03f8ca333971553909c72f2568f
Message:
opt: Z/n, Z: always !=NULL (except in Copy/Delete)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/rintegers.cc

    r417a91a r54bb6b  
    135135static void nrzDelete(number *a, const coeffs)
    136136{
    137   if (*a == NULL) return;
    138   mpz_clear((mpz_ptr) *a);
    139   omFreeBin((ADDRESS) *a, gmp_nrz_bin);
    140   *a = NULL;
     137  if (*a != NULL)
     138  {
     139    mpz_clear((mpz_ptr) *a);
     140    omFreeBin((ADDRESS) *a, gmp_nrz_bin);
     141    *a = NULL;
     142  }
    141143}
    142144
     
    158160static int nrzSize(number a, const coeffs)
    159161{
    160   if (a == NULL) return 0;
    161   return (((mpz_ptr)a)->_mp_alloc);
     162  mpz_ptr p=(mpz_ptr)a;
     163  int s=p->_mp_alloc;
     164  if (s==1) s=(mpz_cmp_ui(p,0)!=0);
     165  return s;
     166
    162167}
    163168
     
    203208static BOOLEAN nrzIsOne (number a, const coeffs)
    204209{
    205   return (a!=NULL) && (0 == mpz_cmp_ui((mpz_ptr) a, 1));
     210  return (0 == mpz_cmp_ui((mpz_ptr) a, 1));
    206211}
    207212
    208213static BOOLEAN nrzIsMOne (number a, const coeffs)
    209214{
    210   return (a!=NULL) && (0 == mpz_cmp_si((mpz_ptr) a, -1));
     215  return (0 == mpz_cmp_si((mpz_ptr) a, -1));
    211216}
    212217
     
    303308  {
    304309    WerrorS("Non invertible element.");
    305     return (number)0; //TODO
     310    return (number)NULL;
    306311  }
    307312  return nrzCopy(c,r);
     
    685690static int nrzSize(number a, const coeffs)
    686691{
    687   if (a == NULL) return 0;
    688692  if (a==INT_TO_SR(0)) return 0;
    689693  if (n_Z_IS_SMALL(a)) return 1;
     
    717721#endif
    718722{
    719   if (n_Z_IS_SMALL(a) && n_Z_IS_SMALL(b)) {
     723  if (n_Z_IS_SMALL(a) && n_Z_IS_SMALL(b))
     724  {
    720725  //from longrat.cc
    721726    if (SR_TO_INT(a)==0)
     
    13151320static BOOLEAN nrzIsZero (number  a, const coeffs)
    13161321{
    1317   return (a==NULL) || (a==INT_TO_SR(0));
     1322  return (a==INT_TO_SR(0));
    13181323}
    13191324
     
    14831488  {
    14841489    WerrorS("Non invertible element.");
    1485     return (number)0; //TODO
     1490    return (number)NULL;
    14861491  }
    14871492  return c; // has to be 1 or -1....
Note: See TracChangeset for help on using the changeset viewer.