Changeset 6a70f3 in git


Ignore:
Timestamp:
Dec 9, 2014, 4:09:48 PM (9 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
Children:
56d8843ea10b1914d8654dce77191eb32927691a
Parents:
fb12237b139e55d2a8d2f4de2ccf1267e1f976cd
Message:
use standard names: int_number -> mpz_prt, NATNUMBER ->unsigned long
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • Singular/ipshell.cc

    rfb12237 r6a70f3  
    20732073  // 0: string: integer
    20742074  // no further entries --> Z
    2075   int_number modBase = NULL;
     2075  mpz_ptr modBase = NULL;
    20762076  unsigned int modExponent = 1;
    20772077
    2078   modBase = (int_number) omAlloc(sizeof(mpz_t));
     2078  modBase = (mpz_ptr) omAlloc(sizeof(mpz_t));
    20792079  if (L->nr == 0)
    20802080  {
     
    21302130  {
    21312131    //R->cf->ch = R->cf->modExponent;
    2132     if ((mpz_cmp_ui(modBase, 2) == 0) && (modExponent <= 8*sizeof(NATNUMBER)))
     2132    if ((mpz_cmp_ui(modBase, 2) == 0) && (modExponent <= 8*sizeof(unsigned long)))
    21332133    {
    21342134      /* this branch should be active for modExponent = 2..32 resp. 2..64,
     
    51235123#ifdef HAVE_RINGS
    51245124  //unsigned int ringtype = 0;
    5125   int_number modBase = NULL;
     5125  mpz_ptr modBase = NULL;
    51265126  unsigned int modExponent = 1;
    51275127#endif
     
    52665266  else if ((pn->name != NULL) && (strcmp(pn->name, "integer") == 0))
    52675267  {
    5268     modBase = (int_number) omAlloc(sizeof(mpz_t));
     5268    modBase = (mpz_ptr) omAlloc(sizeof(mpz_t));
    52695269    mpz_init_set_si(modBase, 0);
    52705270    if (pn->next!=NULL)
     
    53095309    if (modExponent > 1 && cf == NULL)
    53105310    {
    5311       if ((mpz_cmp_ui(modBase, 2) == 0) && (modExponent <= 8*sizeof(NATNUMBER)))
     5311      if ((mpz_cmp_ui(modBase, 2) == 0) && (modExponent <= 8*sizeof(unsigned long)))
    53125312      {
    53135313        /* this branch should be active for modExponent = 2..32 resp. 2..64,
  • Singular/number2.cc

    rfb12237 r6a70f3  
    4444    {
    4545      ZnmInfo info;
    46       mpz_ptr modBase= (int_number) omAlloc(sizeof(mpz_t));
     46      mpz_ptr modBase= (mpz_ptr) omAlloc(sizeof(mpz_t));
    4747      mpz_init_set_ui(modBase,i2);
    4848      info.base= modBase;
  • dox/Doxyfile.in

    rfb12237 r6a70f3  
    20432043IPASSIGN \
    20442044IPCONV \
    2045 NATNUMBER \
    20462045OLD_RES \
    20472046OMALLOC_USES_SYSTEM_MALLOC \
  • kernel/GBEngine/kstd2.cc

    rfb12237 r6a70f3  
    216216  poly p = input_p;
    217217  poly zeroPoly = NULL;
    218   NATNUMBER a = (NATNUMBER) pGetCoeff(p);
     218  unsigned long a = (unsigned long) pGetCoeff(p);
    219219
    220220  int k_ind2 = 0;
    221221  int a_ind2 = ind2(a);
    222222
    223   // NATNUMBER k = 1;
     223  // unsigned long k = 1;
    224224  // of interest is only k_ind2, special routine for improvement ... TODO OLIVER
    225225  for (int i = 1; i <= leadRing->N; i++)
     
    228228  }
    229229
    230   a = (NATNUMBER) pGetCoeff(p);
     230  a = (unsigned long) pGetCoeff(p);
    231231
    232232  number tmp1;
     
    251251      }
    252252      p_SetExp(lead_mult, i, p_GetExp(p, i,leadRing) - s_exp, tailRing);
    253       for (NATNUMBER j = 1; j <= s_exp; j++)
     253      for (unsigned long j = 1; j <= s_exp; j++)
    254254      {
    255255        tmp1 = nInit(j);
     
    280280    return tmp2;
    281281  }
    282 /*  NATNUMBER alpha_k = twoPow(leadRing->ch - k_ind2);
     282/*  unsigned long alpha_k = twoPow(leadRing->ch - k_ind2);
    283283  if (1 == 0 && alpha_k <= a)
    284284  {  // Temporarly disabled, reducing coefficients not compatible with std TODO Oliver
     
    286286    for (int i = 1; i <= leadRing->N; i++)
    287287    {
    288       for (NATNUMBER j = 1; j <= p_GetExp(p, i, leadRing); j++)
     288      for (unsigned long j = 1; j <= p_GetExp(p, i, leadRing); j++)
    289289      {
    290290        tmp1 = nInit(j);
     
    298298        else
    299299        {
    300           tmp3 = p_ISet((NATNUMBER) tmp1, tailRing);
     300          tmp3 = p_ISet((unsigned long) tmp1, tailRing);
    301301          zeroPoly = p_Mult_q(zeroPoly, p_Add_q(tmp2, tmp3, tailRing), tailRing);
    302302        }
    303303      }
    304304    }
    305     tmp2 = p_ISet((NATNUMBER) pGetCoeff(zeroPoly), leadRing);
     305    tmp2 = p_ISet((unsigned long) pGetCoeff(zeroPoly), leadRing);
    306306    for (int i = 1; i <= leadRing->N; i++)
    307307    {
  • kernel/structs.h

    rfb12237 r6a70f3  
    1515
    1616/* standard types */
    17 //#ifdef HAVE_RINGS
    18 //typedef unsigned long NATNUMBER;
    19 //typedef mpz_ptr int_number;
    20 //#endif
    21 
    2217#define BITSET  unsigned int
    2318
  • libpolys/coeffs/coeffs.h

    rfb12237 r6a70f3  
    5050
    5151/* standard types */
    52 #ifdef HAVE_RINGS
    53 typedef unsigned long NATNUMBER;
    54 typedef mpz_ptr int_number;
    55 #endif
    56 
    5752struct ip_sring;
    5853typedef struct ip_sring *         ring;
     
    372367  int npPminus1M; ///< characteristic - 1
    373368//-------------------------------------------
    374 #ifdef HAVE_RINGS
    375369   int     (*cfDivComp)(number a,number b,const coeffs r);
    376370   BOOLEAN (*cfIsUnit)(number a,const coeffs r);
     
    397391     in the files rmodulon.h and rmodulon.cc, whereas case 3.)
    398392     is implemented in the files rmodulo2m.h and rmodulo2m.cc. */
    399   int_number    modBase;
     393  mpz_ptr    modBase;
    400394  unsigned long modExponent;
    401   int_number    modNumber;
     395  mpz_ptr    modNumber;
    402396  unsigned long mod2mMask;
    403397  //returns coeffs with updated ch, modNumber and modExp
    404398  coeffs (*cfQuot1)(number c, const coeffs r);
    405 #endif
    406399
    407400  /*CF: for blackbox rings, contains data needed to define the ring.
  • libpolys/coeffs/modulop.cc

    rfb12237 r6a70f3  
    688688number npMapGMP(number from, const coeffs /*src*/, const coeffs dst)
    689689{
    690   int_number erg = (int_number) omAlloc(sizeof(mpz_t)); // evtl. spaeter mit bin
     690  mpz_ptr erg = (mpz_ptr) omAlloc(sizeof(mpz_t)); // evtl. spaeter mit bin
    691691  mpz_init(erg);
    692692
    693   mpz_mod_ui(erg, (int_number) from, dst->ch);
     693  mpz_mod_ui(erg, (mpz_ptr) from, dst->ch);
    694694  number r = (number) mpz_get_si(erg);
    695695
  • libpolys/coeffs/rintegers.cc

    rfb12237 r6a70f3  
    3838number nrzMult (number a, number b, const coeffs)
    3939{
    40   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     40  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    4141  mpz_init(erg);
    42   mpz_mul(erg, (int_number) a, (int_number) b);
     42  mpz_mul(erg, (mpz_ptr) a, (mpz_ptr) b);
    4343  return (number) erg;
    4444}
     
    4949number nrzLcm (number a,number b,const coeffs)
    5050{
    51   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     51  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    5252  mpz_init(erg);
    53   mpz_lcm(erg, (int_number) a, (int_number) b);
     53  mpz_lcm(erg, (mpz_ptr) a, (mpz_ptr) b);
    5454  return (number) erg;
    5555}
     
    6161number nrzGcd (number a,number b,const coeffs)
    6262{
    63   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     63  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    6464  mpz_init(erg);
    65   mpz_gcd(erg, (int_number) a, (int_number) b);
     65  mpz_gcd(erg, (mpz_ptr) a, (mpz_ptr) b);
    6666  return (number) erg;
    6767}
     
    7373number  nrzExtGcd (number a, number b, number *s, number *t, const coeffs)
    7474{
    75   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
    76   int_number bs = (int_number) omAllocBin(gmp_nrz_bin);
    77   int_number bt = (int_number) omAllocBin(gmp_nrz_bin);
     75  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
     76  mpz_ptr bs = (mpz_ptr) omAllocBin(gmp_nrz_bin);
     77  mpz_ptr bt = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    7878  mpz_init(erg);
    7979  mpz_init(bs);
    8080  mpz_init(bt);
    81   mpz_gcdext(erg, bs, bt, (int_number) a, (int_number) b);
     81  mpz_gcdext(erg, bs, bt, (mpz_ptr) a, (mpz_ptr) b);
    8282  *s = (number) bs;
    8383  *t = (number) bt;
     
    8787void nrzPower (number a, int i, number * result, const coeffs)
    8888{
    89   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     89  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    9090  mpz_init(erg);
    91   mpz_pow_ui(erg, (int_number) a, i);
     91  mpz_pow_ui(erg, (mpz_ptr) a, i);
    9292  *result = (number) erg;
    9393}
     
    9898number nrzInit (long i, const coeffs)
    9999{
    100   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     100  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    101101  mpz_init_set_si(erg, i);
    102102  return (number) erg;
     
    106106{
    107107  if (*a == NULL) return;
    108   mpz_clear((int_number) *a);
     108  mpz_clear((mpz_ptr) *a);
    109109  omFreeBin((ADDRESS) *a, gmp_nrz_bin);
    110110  *a = NULL;
     
    113113number nrzCopy(number a, const coeffs)
    114114{
    115   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
    116   mpz_init_set(erg, (int_number) a);
     115  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
     116  mpz_init_set(erg, (mpz_ptr) a);
    117117  return (number) erg;
    118118}
     
    136136int nrzInt(number &n, const coeffs)
    137137{
    138   return (int) mpz_get_si( (int_number)n);
     138  return (int) mpz_get_si( (mpz_ptr)n);
    139139}
    140140
    141141number nrzAdd (number a, number b, const coeffs)
    142142{
    143   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     143  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    144144  mpz_init(erg);
    145   mpz_add(erg, (int_number) a, (int_number) b);
     145  mpz_add(erg, (mpz_ptr) a, (mpz_ptr) b);
    146146  return (number) erg;
    147147}
     
    149149number nrzSub (number a, number b, const coeffs)
    150150{
    151   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     151  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    152152  mpz_init(erg);
    153   mpz_sub(erg, (int_number) a, (int_number) b);
     153  mpz_sub(erg, (mpz_ptr) a, (mpz_ptr) b);
    154154  return (number) erg;
    155155}
     
    162162BOOLEAN nrzIsUnit (number a, const coeffs)
    163163{
    164   return 0 == mpz_cmpabs_ui((int_number) a, 1);
     164  return 0 == mpz_cmpabs_ui((mpz_ptr) a, 1);
    165165}
    166166
    167167BOOLEAN nrzIsZero (number  a, const coeffs)
    168168{
    169   return 0 == mpz_cmpabs_ui((int_number) a, 0);
     169  return 0 == mpz_cmpabs_ui((mpz_ptr) a, 0);
    170170}
    171171
    172172BOOLEAN nrzIsOne (number a, const coeffs)
    173173{
    174   return (a!=NULL) && (0 == mpz_cmp_si((int_number) a, 1));
     174  return (a!=NULL) && (0 == mpz_cmp_si((mpz_ptr) a, 1));
    175175}
    176176
    177177BOOLEAN nrzIsMOne (number a, const coeffs)
    178178{
    179   return (a!=NULL) && (0 == mpz_cmp_si((int_number) a, -1));
     179  return (a!=NULL) && (0 == mpz_cmp_si((mpz_ptr) a, -1));
    180180}
    181181
    182182BOOLEAN nrzEqual (number a,number b, const coeffs)
    183183{
    184   return 0 == mpz_cmp((int_number) a, (int_number) b);
     184  return 0 == mpz_cmp((mpz_ptr) a, (mpz_ptr) b);
    185185}
    186186
    187187BOOLEAN nrzGreater (number a,number b, const coeffs)
    188188{
    189   return 0 < mpz_cmp((int_number) a, (int_number) b);
     189  return 0 < mpz_cmp((mpz_ptr) a, (mpz_ptr) b);
    190190}
    191191
    192192BOOLEAN nrzGreaterZero (number k, const coeffs)
    193193{
    194   return 0 < mpz_cmp_si((int_number) k, 0);
     194  return 0 < mpz_cmp_si((mpz_ptr) k, 0);
    195195}
    196196
     
    208208BOOLEAN nrzDivBy (number a,number b, const coeffs)
    209209{
    210   return mpz_divisible_p((int_number) a, (int_number) b) != 0;
     210  return mpz_divisible_p((mpz_ptr) a, (mpz_ptr) b) != 0;
    211211}
    212212
    213213number nrzDiv (number a,number b, const coeffs R)
    214214{
    215   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     215  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    216216  mpz_init(erg);
    217   int_number r = (int_number) omAllocBin(gmp_nrz_bin);
     217  mpz_ptr r = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    218218  mpz_init(r);
    219   mpz_tdiv_qr(erg, r, (int_number) a, (int_number) b);
     219  mpz_tdiv_qr(erg, r, (mpz_ptr) a, (mpz_ptr) b);
    220220  //if (!nrzIsZero((number) r, R))
    221221  //{
     
    230230number nrzExactDiv (number a,number b, const coeffs)
    231231{
    232   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     232  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    233233  mpz_init(erg);
    234   mpz_tdiv_q(erg, (int_number) a, (int_number) b);
     234  mpz_tdiv_q(erg, (mpz_ptr) a, (mpz_ptr) b);
    235235  return (number) erg;
    236236}
     
    238238number nrzIntMod (number a,number b, const coeffs)
    239239{
    240   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     240  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    241241  mpz_init(erg);
    242   int_number r = (int_number) omAllocBin(gmp_nrz_bin);
     242  mpz_ptr r = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    243243  mpz_init(r);
    244   mpz_tdiv_qr(erg, r, (int_number) a, (int_number) b);
     244  mpz_tdiv_qr(erg, r, (mpz_ptr) a, (mpz_ptr) b);
    245245  mpz_clear(erg);
    246246  omFreeBin(erg, gmp_nrz_bin);
     
    261261{
    262262// nNeg inplace !!!
    263   mpz_mul_si((int_number) c, (int_number) c, -1);
     263  mpz_mul_si((mpz_ptr) c, (mpz_ptr) c, -1);
    264264  return c;
    265265}
     
    267267number nrzMapMachineInt(number from, const coeffs /*src*/, const coeffs /*dst*/)
    268268{
    269   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
    270   mpz_init_set_ui(erg, (NATNUMBER) from);
     269  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
     270  mpz_init_set_ui(erg, (unsigned long) from);
    271271  return (number) erg;
    272272}
     
    274274number nrzMapZp(number from, const coeffs /*src*/, const coeffs /*dst*/)
    275275{
    276   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     276  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    277277  mpz_init_set_si(erg, (long) from);
    278278  return (number) erg;
     
    281281number nrzMapQ(number from, const coeffs src, const coeffs /*dst*/)
    282282{
    283   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     283  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    284284  mpz_init(erg);
    285285  nlGMP(from, (number) erg, src);
     
    338338  else
    339339  {
    340     int l=mpz_sizeinbase((int_number) a, 10) + 2;
     340    int l=mpz_sizeinbase((mpz_ptr) a, 10) + 2;
    341341    s=(char*)omAlloc(l);
    342     z=mpz_get_str(s,10,(int_number) a);
     342    z=mpz_get_str(s,10,(mpz_ptr) a);
    343343    StringAppendS(z);
    344344    omFreeSize((ADDRESS)s,l);
     
    391391  else
    392392  {
    393     int_number m = (int_number) omAllocBin(gmp_nrz_bin);
     393    mpz_ptr m = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    394394    gmp_numerator(n,m);
    395395    return (number) m;
     
    399399const char * nrzRead (const char *s, number *a, const coeffs)
    400400{
    401   int_number z = (int_number) omAllocBin(gmp_nrz_bin);
     401  mpz_ptr z = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    402402  {
    403403    mpz_init(z);
     
    421421{
    422422    int ch = r->cfInt(c, r);
    423     int_number dummy;
    424     dummy = (int_number) omAlloc(sizeof(mpz_t));
     423    mpz_ptr dummy;
     424    dummy = (mpz_ptr) omAlloc(sizeof(mpz_t));
    425425    mpz_init_set_ui(dummy, ch);
    426426    ZnmInfo info;
     
    512512  nrzWrite(x, NULL);
    513513#endif
    514   if (mpz_cmp_ui((int_number) x,(long)0)==0)
    515   {
    516     mpz_clear((int_number)x);
     514  if (mpz_cmp_ui((mpz_ptr) x,(long)0)==0)
     515  {
     516    mpz_clear((mpz_ptr)x);
    517517    omFreeBin(x, gmp_nrz_bin);
    518518#if CF_DEBUG
     
    521521    return INT_TO_SR(0);
    522522  }
    523   if (mpz_size1((int_number)x)<=MP_SMALL)
    524   {
    525     int ui=mpz_get_si((int_number)x);
     523  if (mpz_size1((mpz_ptr)x)<=MP_SMALL)
     524  {
     525    int ui=mpz_get_si((mpz_ptr)x);
    526526    if ((((ui<<3)>>3)==ui)
    527     && (mpz_cmp_si((int_number)x,(long)ui)==0))
    528     {
    529       mpz_clear((int_number)x);
     527    && (mpz_cmp_si((mpz_ptr)x,(long)ui)==0))
     528    {
     529      mpz_clear((mpz_ptr)x);
    530530      omFreeBin(x, gmp_nrz_bin);
    531531#if CF_DEBUG
     
    588588      return nrzInit(SR_HDL(u)>>2, R);
    589589    }
    590     int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     590    mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    591591    mpz_init(erg);
    592592    mpz_set_si(erg, SR_TO_INT(a));
     
    599599    if (SR_TO_INT(a)==0)
    600600      return a;
    601     int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
    602     mpz_init_set(erg, (int_number) b);
     601    mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
     602    mpz_init_set(erg, (mpz_ptr) b);
    603603    mpz_mul_si(erg, erg, SR_TO_INT(a));
    604604    nrzTest((number)erg);
     
    609609    if (SR_TO_INT(b)==0)
    610610      return b;
    611     int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
    612     mpz_init_set(erg, (int_number) a);
     611    mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
     612    mpz_init_set(erg, (mpz_ptr) a);
    613613    mpz_mul_si(erg, erg, SR_TO_INT(b));
    614614    nrzTest((number)erg);
     
    617617  else
    618618  {
    619     int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     619    mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    620620    mpz_init(erg);
    621     mpz_mul(erg, (int_number) a, (int_number) b);
     621    mpz_mul(erg, (mpz_ptr) a, (mpz_ptr) b);
    622622    nrzTest((number)erg);
    623623    return (number) erg;
     
    650650{
    651651  PrintS("nrzLcm\n");
    652   int_number erg;
     652  mpz_ptr erg;
    653653  if (n_Z_IS_SMALL(a) && n_Z_IS_SMALL(b))
    654654  {
     
    658658  else
    659659  {
    660     erg = (int_number) omAllocBin(gmp_nrz_bin);
     660    erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    661661    if (n_Z_IS_SMALL(a))
    662662    {
    663       mpz_init_set(erg, (int_number) b);
     663      mpz_init_set(erg, (mpz_ptr) b);
    664664      unsigned long g = mpz_gcd_ui(NULL, erg, (unsigned long) ABS(SR_TO_INT(a)));
    665665      mpz_mul_si(erg, erg, SR_TO_INT(a)/g);
     
    667667    else if (n_Z_IS_SMALL(b))
    668668    {
    669       mpz_init_set(erg, (int_number) a);
     669      mpz_init_set(erg, (mpz_ptr) a);
    670670      unsigned long g = mpz_gcd_ui(NULL, erg, (unsigned long) ABS(SR_TO_INT(b)));
    671671      mpz_mul_si(erg, erg, SR_TO_INT(b)/g);
     
    674674    {
    675675      mpz_init(erg);
    676       mpz_lcm(erg, (int_number) a, (int_number) b);
     676      mpz_lcm(erg, (mpz_ptr) a, (mpz_ptr) b);
    677677    }
    678678  }
     
    695695    if (a==INT_TO_SR(0))
    696696      return nrzCopy(b, R);
    697     unsigned long g = mpz_gcd_ui(NULL, (int_number)b, (unsigned long) ABS(SR_TO_INT(a)));
     697    unsigned long g = mpz_gcd_ui(NULL, (mpz_ptr)b, (unsigned long) ABS(SR_TO_INT(a)));
    698698    return INT_TO_SR( g);
    699699  }
     
    702702    if (b==INT_TO_SR(0))
    703703      return nrzCopy(a, R);
    704     unsigned long g = mpz_gcd_ui(NULL, (int_number)a, (unsigned long) ABS(SR_TO_INT(b)));
     704    unsigned long g = mpz_gcd_ui(NULL, (mpz_ptr)a, (unsigned long) ABS(SR_TO_INT(b)));
    705705    return INT_TO_SR(g);
    706706  }
    707707  else
    708708  {
    709     int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     709    mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    710710    mpz_init(erg);
    711     mpz_gcd(erg, (int_number) a, (int_number) b);
     711    mpz_gcd(erg, (mpz_ptr) a, (mpz_ptr) b);
    712712    return (number) erg;
    713713  }
     
    780780    else
    781781    {
    782       mpz_init_set(aa, (int_number) a);
     782      mpz_init_set(aa, (mpz_ptr) a);
    783783    }
    784784    if (n_Z_IS_SMALL(b))
     
    788788    else
    789789    {
    790       mpz_init_set(bb, (int_number) b);
    791     }
    792     int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
    793     int_number bs = (int_number) omAllocBin(gmp_nrz_bin);
    794     int_number bt = (int_number) omAllocBin(gmp_nrz_bin);
     790      mpz_init_set(bb, (mpz_ptr) b);
     791    }
     792    mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
     793    mpz_ptr bs = (mpz_ptr) omAllocBin(gmp_nrz_bin);
     794    mpz_ptr bt = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    795795    mpz_init(erg);
    796796    mpz_init(bs);
     
    853853    else
    854854    {
    855       mpz_init_set(aa, (int_number) a);
     855      mpz_init_set(aa, (mpz_ptr) a);
    856856    }
    857857    if (n_Z_IS_SMALL(b))
     
    861861    else
    862862    {
    863       mpz_init_set(bb, (int_number) b);
    864     }
    865     int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
    866     int_number bs = (int_number) omAllocBin(gmp_nrz_bin);
    867     int_number bt = (int_number) omAllocBin(gmp_nrz_bin);
     863      mpz_init_set(bb, (mpz_ptr) b);
     864    }
     865    mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
     866    mpz_ptr bs = (mpz_ptr) omAllocBin(gmp_nrz_bin);
     867    mpz_ptr bt = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    868868    mpz_init(erg);
    869869    mpz_init(bs);
     
    872872    mpz_gcdext(erg, bs, bt, aa, bb);
    873873
    874     int_number bu = (int_number) omAllocBin(gmp_nrz_bin);
    875     int_number bv = (int_number) omAllocBin(gmp_nrz_bin);
    876 
    877     mpz_init_set(bu, (int_number) bb);
    878     mpz_init_set(bv, (int_number) aa);
     874    mpz_ptr bu = (mpz_ptr) omAllocBin(gmp_nrz_bin);
     875    mpz_ptr bv = (mpz_ptr) omAllocBin(gmp_nrz_bin);
     876
     877    mpz_init_set(bu, (mpz_ptr) bb);
     878    mpz_init_set(bv, (mpz_ptr) aa);
    879879
    880880    mpz_clear(aa);
     
    937937  {
    938938    unsigned long rr;
    939     int_number qq = (int_number) omAllocBin(gmp_nrz_bin);
     939    mpz_ptr qq = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    940940    mpz_init(qq);
    941941    mpz_t rrr;
    942942    mpz_init(rrr);
    943     rr = mpz_divmod_ui(qq, rrr, (int_number) a, (unsigned long)ABS(SR_TO_INT(b)));
     943    rr = mpz_divmod_ui(qq, rrr, (mpz_ptr) a, (unsigned long)ABS(SR_TO_INT(b)));
    944944    mpz_clear(rrr);
    945945
     
    952952    return nrz_short((number)qq);
    953953  }
    954   int_number qq = (int_number) omAllocBin(gmp_nrz_bin),
    955              rr = (int_number) omAllocBin(gmp_nrz_bin);
     954  mpz_ptr qq = (mpz_ptr) omAllocBin(gmp_nrz_bin),
     955             rr = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    956956  mpz_init(qq);
    957957  mpz_init(rr);
    958   mpz_divmod(qq, rr, (int_number)a, (int_number)b);
     958  mpz_divmod(qq, rr, (mpz_ptr)a, (mpz_ptr)b);
    959959  if (r)
    960960    *r = (number) rr;
     
    970970void nrzPower (number a, int i, number * result, const coeffs)
    971971{
    972   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     972  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    973973  mpz_init(erg);
    974974  mpz_t aa;
     
    976976    mpz_init_set_si(aa, SR_TO_INT(a));
    977977  else
    978     mpz_init_set(aa, (int_number) a);
     978    mpz_init_set(aa, (mpz_ptr) a);
    979979  mpz_pow_ui(erg, aa, i);
    980980  *result = nrz_short((number) erg);
     
    987987number nrzInit (long i, const coeffs)
    988988{
    989   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     989  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    990990  mpz_init_set_si(erg, i);
    991991  return nrz_short((number) erg);
     
    997997  if (n_Z_IS_SMALL(*a)==0)
    998998  {
    999     mpz_clear((int_number) *a);
     999    mpz_clear((mpz_ptr) *a);
    10001000    omFreeBin((ADDRESS) *a, gmp_nrz_bin);
    10011001  }
     
    10061006{
    10071007  if (n_Z_IS_SMALL(a)) return a;
    1008   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
    1009   mpz_init_set(erg, (int_number) a);
     1008  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
     1009  mpz_init_set(erg, (mpz_ptr) a);
    10101010  return (number) erg;
    10111011}
     
    10151015  if (a == NULL) return 0;
    10161016  if (n_Z_IS_SMALL(a)) return 1;
    1017   return mpz_size1((int_number)a)+1;
     1017  return mpz_size1((mpz_ptr)a)+1;
    10181018}
    10191019
     
    10241024{
    10251025  if (n_Z_IS_SMALL(n)) return SR_TO_INT(n);
    1026   return (int) mpz_get_si( (int_number)n);
     1026  return (int) mpz_get_si( (mpz_ptr)n);
    10271027}
    10281028#if CF_DEBUG
     
    10521052    if (INT_IS_SMALL(c))
    10531053      return INT_TO_SR(c);
    1054     int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     1054    mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    10551055    mpz_init_set_si(erg, c);
    10561056
     
    10601060  else if (n_Z_IS_SMALL(a))
    10611061  {
    1062     int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     1062    mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    10631063    mpz_init(erg);
    10641064    if (SR_TO_INT(a)>0)
    1065       mpz_add_ui(erg, (int_number) b, (unsigned long)SR_TO_INT(a));
     1065      mpz_add_ui(erg, (mpz_ptr) b, (unsigned long)SR_TO_INT(a));
    10661066    else
    1067       mpz_sub_ui(erg, (int_number) b, (unsigned long)-(SR_TO_INT(a)));
     1067      mpz_sub_ui(erg, (mpz_ptr) b, (unsigned long)-(SR_TO_INT(a)));
    10681068    return nrz_short((number) erg);
    10691069  }
    10701070  else if (n_Z_IS_SMALL(b))
    10711071  {
    1072     int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     1072    mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    10731073    mpz_init(erg);
    10741074    if (SR_TO_INT(b)>0)
    1075       mpz_add_ui(erg, (int_number) a, (unsigned long)SR_TO_INT(b));
     1075      mpz_add_ui(erg, (mpz_ptr) a, (unsigned long)SR_TO_INT(b));
    10761076    else
    1077       mpz_sub_ui(erg, (int_number) a, (unsigned long)-(SR_TO_INT(b)));
     1077      mpz_sub_ui(erg, (mpz_ptr) a, (unsigned long)-(SR_TO_INT(b)));
    10781078    return nrz_short((number) erg);
    10791079  }
    10801080  else
    10811081  {
    1082     int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     1082    mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    10831083    mpz_init(erg);
    1084     mpz_add(erg, (int_number) a, (int_number) b);
     1084    mpz_add(erg, (mpz_ptr) a, (mpz_ptr) b);
    10851085    return nrz_short((number) erg);
    10861086  }
     
    10941094    if (INT_IS_SMALL(c))
    10951095      return INT_TO_SR(c);
    1096     int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     1096    mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    10971097    mpz_init_set_si(erg, c);
    10981098    nrzTest((number)erg);
     
    11011101  else if (n_Z_IS_SMALL(a))
    11021102  {
    1103     int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     1103    mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    11041104    mpz_init(erg);
    11051105
    11061106    if (SR_TO_INT(a)>0)
    1107       mpz_ui_sub(erg, (unsigned long)SR_TO_INT(a), (int_number) b);
     1107      mpz_ui_sub(erg, (unsigned long)SR_TO_INT(a), (mpz_ptr) b);
    11081108    else
    11091109    {
    1110       mpz_add_ui(erg, (int_number) b, (unsigned long)-SR_TO_INT(a));
     1110      mpz_add_ui(erg, (mpz_ptr) b, (unsigned long)-SR_TO_INT(a));
    11111111      mpz_neg(erg, erg);
    11121112    }
     
    11151115  else if (n_Z_IS_SMALL(b))
    11161116  {
    1117     int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     1117    mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    11181118    mpz_init(erg);
    11191119    if (SR_TO_INT(b)>0)
    1120       mpz_sub_ui(erg, (int_number) a, (unsigned long)SR_TO_INT(b));
     1120      mpz_sub_ui(erg, (mpz_ptr) a, (unsigned long)SR_TO_INT(b));
    11211121    else
    1122       mpz_add_ui(erg, (int_number) a, (unsigned long)-SR_TO_INT(b));
     1122      mpz_add_ui(erg, (mpz_ptr) a, (unsigned long)-SR_TO_INT(b));
    11231123    return nrz_short((number) erg);
    11241124  }
    11251125  else
    11261126  {
    1127     int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     1127    mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    11281128    mpz_init(erg);
    1129     mpz_sub(erg, (int_number) a, (int_number) b);
     1129    mpz_sub(erg, (mpz_ptr) a, (mpz_ptr) b);
    11301130    return nrz_short((number) erg);
    11311131  }
     
    11751175    return FALSE;
    11761176  else
    1177     return 0 == mpz_cmp((int_number) a, (int_number) b);
     1177    return 0 == mpz_cmp((mpz_ptr) a, (mpz_ptr) b);
    11781178}
    11791179
     
    11831183    return ((long)a)>((long)b);
    11841184  else if (n_Z_IS_SMALL(a))
    1185     return 0 > mpz_cmp_si((int_number)b,SR_TO_INT(a));
     1185    return 0 > mpz_cmp_si((mpz_ptr)b,SR_TO_INT(a));
    11861186  else if (n_Z_IS_SMALL(b))
    1187     return 0 < mpz_cmp_si((int_number)a,SR_TO_INT(b));
    1188   return 0 < mpz_cmp((int_number) a, (int_number) b);
     1187    return 0 < mpz_cmp_si((mpz_ptr)a,SR_TO_INT(b));
     1188  return 0 < mpz_cmp((mpz_ptr) a, (mpz_ptr) b);
    11891189}
    11901190
     
    12171217  else if (n_Z_IS_SMALL(b))
    12181218  {
    1219     return mpz_divisible_ui_p((int_number)a, (unsigned long)ABS(SR_TO_INT(b))) != 0;
    1220   }
    1221   else
    1222     return mpz_divisible_p((int_number) a, (int_number) b) != 0;
     1219    return mpz_divisible_ui_p((mpz_ptr)a, (unsigned long)ABS(SR_TO_INT(b))) != 0;
     1220  }
     1221  else
     1222    return mpz_divisible_p((mpz_ptr) a, (mpz_ptr) b) != 0;
    12231223}
    12241224
     
    12461246  else if (n_Z_IS_SMALL(b))
    12471247  {
    1248     int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     1248    mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    12491249    mpz_t r;
    12501250    mpz_init(r);
    12511251    mpz_init(erg);
    1252     if (mpz_divmod_ui(erg, r, (int_number) a, (unsigned long)ABS(SR_TO_INT(b)))) {
     1252    if (mpz_divmod_ui(erg, r, (mpz_ptr) a, (unsigned long)ABS(SR_TO_INT(b)))) {
    12531253    //  WerrorS("3:Division by non divisible element.");
    12541254    //  WerrorS("Result is without remainder.");
     
    12591259    return nrz_short((number) erg);
    12601260  }
    1261   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     1261  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    12621262  mpz_init(erg);
    12631263  mpz_t r;
    12641264  mpz_init(r);
    1265   mpz_tdiv_qr(erg, r, (int_number) a, (int_number) b);
     1265  mpz_tdiv_qr(erg, r, (mpz_ptr) a, (mpz_ptr) b);
    12661266#if CF_DEBUG
    12671267  StringSetS("division of");
     
    12951295    mpz_init_set_si(aa, SR_TO_INT(a));
    12961296  else
    1297     mpz_init_set(aa, (int_number) a);
     1297    mpz_init_set(aa, (mpz_ptr) a);
    12981298  if (n_Z_IS_SMALL(b))
    12991299    mpz_init_set_si(bb, SR_TO_INT(b));
    13001300  else
    1301     mpz_init_set(bb, (int_number) b);
    1302   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     1301    mpz_init_set(bb, (mpz_ptr) b);
     1302  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    13031303  mpz_init(erg);
    1304   mpz_tdiv_q(erg, (int_number) aa, (int_number) bb);
     1304  mpz_tdiv_q(erg, (mpz_ptr) aa, (mpz_ptr) bb);
    13051305  mpz_clear(aa);
    13061306  mpz_clear(bb);
     
    13161316    mpz_init_set_si(aa, SR_TO_INT(a));
    13171317  else
    1318     mpz_init_set(aa, (int_number) a);
     1318    mpz_init_set(aa, (mpz_ptr) a);
    13191319  if (n_Z_IS_SMALL(b))
    13201320    mpz_init_set_si(bb, SR_TO_INT(b));
    13211321  else
    1322     mpz_init_set(bb, (int_number) b);
     1322    mpz_init_set(bb, (mpz_ptr) b);
    13231323
    13241324  mpz_t erg;
    13251325  mpz_init(erg);
    1326   int_number r = (int_number) omAllocBin(gmp_nrz_bin);
     1326  mpz_ptr r = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    13271327  mpz_init(r);
    1328   mpz_tdiv_qr(erg, r, (int_number) aa, (int_number) bb);
     1328  mpz_tdiv_qr(erg, r, (mpz_ptr) aa, (mpz_ptr) bb);
    13291329  mpz_clear(erg);
    13301330  mpz_clear(aa);
     
    13491349  if (n_Z_IS_SMALL(c))
    13501350    return INT_TO_SR(-SR_TO_INT(c));
    1351   mpz_mul_si((int_number) c, (int_number) c, -1);
     1351  mpz_mul_si((mpz_ptr) c, (mpz_ptr) c, -1);
    13521352  return c;
    13531353}
     
    14261426number nrzMapMachineInt(number from, const coeffs /*src*/, const coeffs /*dst*/)
    14271427{
    1428   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
    1429   mpz_init_set_ui(erg, (NATNUMBER) from);
     1428  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
     1429  mpz_init_set_ui(erg, (unsigned long) from);
    14301430  return nrz_short((number) erg);
    14311431}
     
    14331433number nrzMapZp(number from, const coeffs /*src*/, const coeffs /*dst*/)
    14341434{
    1435   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     1435  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    14361436  mpz_init_set_si(erg, (long) from);
    14371437  return nrz_short((number) erg);
     
    14401440number nrzModNMap(number from, const coeffs /* src */, const coeffs /*dst*/)
    14411441{
    1442   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
    1443   mpz_init_set(erg, (int_number) from);
     1442  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
     1443  mpz_init_set(erg, (mpz_ptr) from);
    14441444  return nrz_short((number) erg);
    14451445}
     
    14541454    return NULL;
    14551455  }
    1456   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     1456  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    14571457  mpz_init_set(erg, from->z);
    14581458  return nrz_short((number) erg);
     
    15011501{
    15021502  if (SR_HDL(x) & SR_INT) return TRUE;
    1503   if (mpz_cmp_ui((int_number) x,(long)0)==0)
     1503  if (mpz_cmp_ui((mpz_ptr) x,(long)0)==0)
    15041504  {
    15051505    Print("gmp-0 %s:%d\n",f,l);
    15061506    return FALSE;
    15071507  }
    1508   if (mpz_size1((int_number)x)<=MP_SMALL)
    1509   {
    1510     int ui=mpz_get_si((int_number)x);
     1508  if (mpz_size1((mpz_ptr)x)<=MP_SMALL)
     1509  {
     1510    int ui=mpz_get_si((mpz_ptr)x);
    15111511    if ((((ui<<3)>>3)==ui)
    1512     && (mpz_cmp_si((int_number)x,(long)ui)==0))
     1512    && (mpz_cmp_si((mpz_ptr)x,(long)ui)==0))
    15131513    {
    15141514      Print("gmp-small %s:%d\n",f,l);
     
    15351535    else
    15361536    {
    1537       int l=mpz_sizeinbase((int_number) a, 10) + 2;
     1537      int l=mpz_sizeinbase((mpz_ptr) a, 10) + 2;
    15381538      s=(char*)omAlloc(l);
    1539       z=mpz_get_str(s,10,(int_number) a);
     1539      z=mpz_get_str(s,10,(mpz_ptr) a);
    15401540      StringAppendS(z);
    15411541      omFreeSize((ADDRESS)s,l);
     
    15731573const char * nrzRead (const char *s, number *a, const coeffs)
    15741574{
    1575   int_number z = (int_number) omAllocBin(gmp_nrz_bin);
     1575  mpz_ptr z = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    15761576  {
    15771577    mpz_init(z);
     
    16241624     return NULL;
    16251625    }
    1626     int_number z = (int_number) omAlloc0Bin(gmp_nrz_bin);
     1626    mpz_ptr z = (mpz_ptr) omAlloc0Bin(gmp_nrz_bin);
    16271627    gmp_numerator( n,z);
    16281628    return nrz_short((number)z);
     
    16351635    mpz_init_set_si(res, SR_TO_INT(a));
    16361636  else
    1637     mpz_init_set(res, (int_number) a);
     1637    mpz_init_set(res, (mpz_ptr) a);
    16381638}
    16391639
    16401640coeffs nrzQuot1(number c, const coeffs r)
    16411641{
    1642     int_number dummy;
    1643     dummy = (int_number) omAlloc(sizeof(mpz_t));
     1642    mpz_ptr dummy;
     1643    dummy = (mpz_ptr) omAlloc(sizeof(mpz_t));
    16441644    if(n_Z_IS_SMALL(c))
    16451645    {
     
    16491649    else
    16501650    {
    1651       mpz_init_set(dummy, (int_number)c);
     1651      mpz_init_set(dummy, (mpz_ptr)c);
    16521652    }
    16531653    ZnmInfo info;
  • libpolys/coeffs/rintegers.h

    rfb12237 r6a70f3  
    2020
    2121//extern int nrzExp;
    22 //extern NATNUMBER nrzModul;
     22//extern unsigned long nrzModul;
    2323
    2424BOOLEAN nrzInitChar    (coeffs r,  void * parameter);
  • libpolys/coeffs/rmodulo2m.cc

    rfb12237 r6a70f3  
    6262    mpz_init_set(a, r->modNumber);
    6363    mpz_init_set_ui(b, ch);
    64     int_number gcd;
    65     gcd = (int_number) omAlloc(sizeof(mpz_t));
     64    mpz_ptr gcd;
     65    gcd = (mpz_ptr) omAlloc(sizeof(mpz_t));
    6666    mpz_init(gcd);
    6767    mpz_gcd(gcd, a,b);
     
    111111  r->cfCoeffString = nr2mCoeffString;
    112112
    113   r->modBase = (int_number) omAllocBin (gmp_nrz_bin);
     113  r->modBase = (mpz_ptr) omAllocBin (gmp_nrz_bin);
    114114  mpz_init_set_si (r->modBase, 2L);
    115   r->modNumber= (int_number) omAllocBin (gmp_nrz_bin);
     115  r->modNumber= (mpz_ptr) omAllocBin (gmp_nrz_bin);
    116116  mpz_init (r->modNumber);
    117117  mpz_pow_ui (r->modNumber, r->modBase, r->modExponent);
     
    164164number nr2mMult(number a, number b, const coeffs r)
    165165{
    166   if (((NATNUMBER)a == 0) || ((NATNUMBER)b == 0))
     166  if (((unsigned long)a == 0) || ((unsigned long)b == 0))
    167167    return (number)0;
    168168  else
     
    175175number nr2mLcm(number a, number b, const coeffs)
    176176{
    177   NATNUMBER res = 0;
    178   if ((NATNUMBER)a == 0) a = (number) 1;
    179   if ((NATNUMBER)b == 0) b = (number) 1;
    180   while ((NATNUMBER)a % 2 == 0)
    181   {
    182     a = (number)((NATNUMBER)a / 2);
    183     if ((NATNUMBER)b % 2 == 0) b = (number)((NATNUMBER)b / 2);
     177  unsigned long res = 0;
     178  if ((unsigned long)a == 0) a = (number) 1;
     179  if ((unsigned long)b == 0) b = (number) 1;
     180  while ((unsigned long)a % 2 == 0)
     181  {
     182    a = (number)((unsigned long)a / 2);
     183    if ((unsigned long)b % 2 == 0) b = (number)((unsigned long)b / 2);
    184184    res++;
    185185  }
    186   while ((NATNUMBER)b % 2 == 0)
    187   {
    188     b = (number)((NATNUMBER)b / 2);
     186  while ((unsigned long)b % 2 == 0)
     187  {
     188    b = (number)((unsigned long)b / 2);
    189189    res++;
    190190  }
     
    198198number nr2mGcd(number a, number b, const coeffs)
    199199{
    200   NATNUMBER res = 0;
    201   if ((NATNUMBER)a == 0 && (NATNUMBER)b == 0) return (number)1;
    202   while ((NATNUMBER)a % 2 == 0 && (NATNUMBER)b % 2 == 0)
    203   {
    204     a = (number)((NATNUMBER)a / 2);
    205     b = (number)((NATNUMBER)b / 2);
     200  unsigned long res = 0;
     201  if ((unsigned long)a == 0 && (unsigned long)b == 0) return (number)1;
     202  while ((unsigned long)a % 2 == 0 && (unsigned long)b % 2 == 0)
     203  {
     204    a = (number)((unsigned long)a / 2);
     205    b = (number)((unsigned long)b / 2);
    206206    res++;
    207207  }
    208 //  if ((NATNUMBER)b % 2 == 0)
     208//  if ((unsigned long)b % 2 == 0)
    209209//  {
    210 //    return (number)((1L << res)); // * (NATNUMBER) a);  // (2**res)*a    a is a unit
     210//    return (number)((1L << res)); // * (unsigned long) a);  // (2**res)*a    a is a unit
    211211//  }
    212212//  else
    213213//  {
    214     return (number)((1L << res)); // * (NATNUMBER) b);  // (2**res)*b    b is a unit
     214    return (number)((1L << res)); // * (unsigned long) b);  // (2**res)*b    b is a unit
    215215//  }
    216216}
     
    222222number nr2mExtGcd(number a, number b, number *s, number *t, const coeffs r)
    223223{
    224   NATNUMBER res = 0;
    225   if ((NATNUMBER)a == 0 && (NATNUMBER)b == 0) return (number)1;
    226   while ((NATNUMBER)a % 2 == 0 && (NATNUMBER)b % 2 == 0)
    227   {
    228     a = (number)((NATNUMBER)a / 2);
    229     b = (number)((NATNUMBER)b / 2);
     224  unsigned long res = 0;
     225  if ((unsigned long)a == 0 && (unsigned long)b == 0) return (number)1;
     226  while ((unsigned long)a % 2 == 0 && (unsigned long)b % 2 == 0)
     227  {
     228    a = (number)((unsigned long)a / 2);
     229    b = (number)((unsigned long)b / 2);
    230230    res++;
    231231  }
    232   if ((NATNUMBER)b % 2 == 0)
     232  if ((unsigned long)b % 2 == 0)
    233233  {
    234234    *t = NULL;
    235235    *s = nr2mInvers(a,r);
    236     return (number)((1L << res)); // * (NATNUMBER) a);  // (2**res)*a    a is a unit
     236    return (number)((1L << res)); // * (unsigned long) a);  // (2**res)*a    a is a unit
    237237  }
    238238  else
     
    240240    *s = NULL;
    241241    *t = nr2mInvers(b,r);
    242     return (number)((1L << res)); // * (NATNUMBER) b);  // (2**res)*b    b is a unit
     242    return (number)((1L << res)); // * (unsigned long) b);  // (2**res)*b    b is a unit
    243243  }
    244244}
     
    248248  if (i == 0)
    249249  {
    250     *(NATNUMBER *)result = 1;
     250    *(unsigned long *)result = 1;
    251251  }
    252252  else if (i == 1)
     
    266266number nr2mInit(long i, const coeffs r)
    267267{
    268   if (i == 0) return (number)(NATNUMBER)i;
     268  if (i == 0) return (number)(unsigned long)i;
    269269
    270270  long ii = i;
    271   NATNUMBER j = (NATNUMBER)1;
     271  unsigned long j = (unsigned long)1;
    272272  if (ii < 0) { j = r->mod2mMask; ii = -ii; }
    273   NATNUMBER k = (NATNUMBER)ii;
     273  unsigned long k = (unsigned long)ii;
    274274  k = k & r->mod2mMask;
    275275  /* now we have: i = j * k mod 2^m */
     
    285285static long nr2mLong(number &n, const coeffs r)
    286286{
    287   NATNUMBER nn = (unsigned long)(NATNUMBER)n & r->mod2mMask;
     287  unsigned long nn = (unsigned long)(unsigned long)n & r->mod2mMask;
    288288  unsigned long l = r->mod2mMask >> 1; l++; /* now: l = 2^(m-1) */
    289   if ((NATNUMBER)nn > l)
    290     return (long)((NATNUMBER)nn - r->mod2mMask - 1);
    291   else
    292     return (long)((NATNUMBER)nn);
     289  if ((unsigned long)nn > l)
     290    return (long)((unsigned long)nn - r->mod2mMask - 1);
     291  else
     292    return (long)((unsigned long)nn);
    293293}
    294294int nr2mInt(number &n, const coeffs r)
     
    309309BOOLEAN nr2mIsUnit(number a, const coeffs)
    310310{
    311   return ((NATNUMBER)a % 2 == 1);
     311  return ((unsigned long)a % 2 == 1);
    312312}
    313313
     
    315315{
    316316  if (k == NULL) return (number)1;
    317   NATNUMBER erg = (NATNUMBER)k;
     317  unsigned long erg = (unsigned long)k;
    318318  while (erg % 2 == 0) erg = erg / 2;
    319319  return (number)erg;
     
    322322BOOLEAN nr2mIsZero(number a, const coeffs)
    323323{
    324   return 0 == (NATNUMBER)a;
     324  return 0 == (unsigned long)a;
    325325}
    326326
    327327BOOLEAN nr2mIsOne(number a, const coeffs)
    328328{
    329   return 1 == (NATNUMBER)a;
     329  return 1 == (unsigned long)a;
    330330}
    331331
    332332BOOLEAN nr2mIsMOne(number a, const coeffs r)
    333333{
    334   return (r->mod2mMask  == (NATNUMBER)a);
     334  return (r->mod2mMask  == (unsigned long)a);
    335335}
    336336
     
    352352  if (a == NULL)
    353353  {
    354     NATNUMBER c = r->mod2mMask + 1;
     354    unsigned long c = r->mod2mMask + 1;
    355355    if (c != 0) /* i.e., if no overflow */
    356       return (c % (NATNUMBER)b) == 0;
     356      return (c % (unsigned long)b) == 0;
    357357    else
    358358    {
    359359      /* overflow: we need to check whether b
    360360         is zero or a power of 2: */
    361       c = (NATNUMBER)b;
     361      c = (unsigned long)b;
    362362      while (c != 0)
    363363      {
     
    378378int nr2mDivComp(number as, number bs, const coeffs)
    379379{
    380   NATNUMBER a = (NATNUMBER)as;
    381   NATNUMBER b = (NATNUMBER)bs;
     380  unsigned long a = (unsigned long)as;
     381  unsigned long b = (unsigned long)bs;
    382382  assume(a != 0 && b != 0);
    383383  while (a % 2 == 0 && b % 2 == 0)
     
    406406BOOLEAN nr2mGreaterZero(number k, const coeffs r)
    407407{
    408   if ((NATNUMBER)k == 0) return FALSE;
    409   if ((NATNUMBER)k > ((r->mod2mMask >> 1) + 1)) return FALSE;
     408  if ((unsigned long)k == 0) return FALSE;
     409  if ((unsigned long)k > ((r->mod2mMask >> 1) + 1)) return FALSE;
    410410  return TRUE;
    411411}
     
    417417void specialXGCD(unsigned long& s, unsigned long a, const coeffs r)
    418418{
    419   int_number u = (int_number)omAlloc(sizeof(mpz_t));
     419  mpz_ptr u = (mpz_ptr)omAlloc(sizeof(mpz_t));
    420420  mpz_init_set_ui(u, a);
    421   int_number u0 = (int_number)omAlloc(sizeof(mpz_t));
     421  mpz_ptr u0 = (mpz_ptr)omAlloc(sizeof(mpz_t));
    422422  mpz_init(u0);
    423   int_number u1 = (int_number)omAlloc(sizeof(mpz_t));
     423  mpz_ptr u1 = (mpz_ptr)omAlloc(sizeof(mpz_t));
    424424  mpz_init_set_ui(u1, 1);
    425   int_number u2 = (int_number)omAlloc(sizeof(mpz_t));
     425  mpz_ptr u2 = (mpz_ptr)omAlloc(sizeof(mpz_t));
    426426  mpz_init(u2);
    427   int_number v = (int_number)omAlloc(sizeof(mpz_t));
     427  mpz_ptr v = (mpz_ptr)omAlloc(sizeof(mpz_t));
    428428  mpz_init_set_ui(v, r->mod2mMask);
    429429  mpz_add_ui(v, v, 1); /* now: v = 2^m */
    430   int_number v0 = (int_number)omAlloc(sizeof(mpz_t));
     430  mpz_ptr v0 = (mpz_ptr)omAlloc(sizeof(mpz_t));
    431431  mpz_init(v0);
    432   int_number v1 = (int_number)omAlloc(sizeof(mpz_t));
     432  mpz_ptr v1 = (mpz_ptr)omAlloc(sizeof(mpz_t));
    433433  mpz_init(v1);
    434   int_number v2 = (int_number)omAlloc(sizeof(mpz_t));
     434  mpz_ptr v2 = (mpz_ptr)omAlloc(sizeof(mpz_t));
    435435  mpz_init_set_ui(v2, 1);
    436   int_number q = (int_number)omAlloc(sizeof(mpz_t));
     436  mpz_ptr q = (mpz_ptr)omAlloc(sizeof(mpz_t));
    437437  mpz_init(q);
    438   int_number rr = (int_number)omAlloc(sizeof(mpz_t));
     438  mpz_ptr rr = (mpz_ptr)omAlloc(sizeof(mpz_t));
    439439  mpz_init(rr);
    440440
     
    473473}
    474474
    475 NATNUMBER InvMod(NATNUMBER a, const coeffs r)
    476 {
    477   assume((NATNUMBER)a % 2 != 0);
     475unsigned long InvMod(unsigned long a, const coeffs r)
     476{
     477  assume((unsigned long)a % 2 != 0);
    478478  unsigned long s;
    479479  specialXGCD(s, a, r);
     
    484484inline number nr2mInversM(number c, const coeffs r)
    485485{
    486   assume((NATNUMBER)c % 2 != 0);
     486  assume((unsigned long)c % 2 != 0);
    487487  // Table !!!
    488   NATNUMBER inv;
    489   inv = InvMod((NATNUMBER)c,r);
     488  unsigned long inv;
     489  inv = InvMod((unsigned long)c,r);
    490490  return (number)inv;
    491491}
     
    493493number nr2mDiv(number a, number b, const coeffs r)
    494494{
    495   if ((NATNUMBER)a == 0) return (number)0;
    496   else if ((NATNUMBER)b % 2 == 0)
    497   {
    498     if ((NATNUMBER)b != 0)
     495  if ((unsigned long)a == 0) return (number)0;
     496  else if ((unsigned long)b % 2 == 0)
     497  {
     498    if ((unsigned long)b != 0)
    499499    {
    500       while (((NATNUMBER)b % 2 == 0) && ((NATNUMBER)a % 2 == 0))
     500      while (((unsigned long)b % 2 == 0) && ((unsigned long)a % 2 == 0))
    501501      {
    502         a = (number)((NATNUMBER)a / 2);
    503         b = (number)((NATNUMBER)b / 2);
     502        a = (number)((unsigned long)a / 2);
     503        b = (number)((unsigned long)b / 2);
    504504      }
    505505    }
    506     if ((NATNUMBER)b % 2 == 0)
     506    if ((unsigned long)b % 2 == 0)
    507507    {
    508508      WerrorS("Division not possible, even by cancelling zero divisors.");
    509509      WerrorS("Result is integer division without remainder.");
    510       return (number) ((NATNUMBER) a / (NATNUMBER) b);
     510      return (number) ((unsigned long) a / (unsigned long) b);
    511511    }
    512512  }
     
    537537    power of 2 (<= 2^m) that is contained in b.
    538538  */
    539   assume((NATNUMBER) b != 0);
    540   NATNUMBER g = 1;
    541   NATNUMBER b_div = (NATNUMBER) b;
     539  assume((unsigned long) b != 0);
     540  unsigned long g = 1;
     541  unsigned long b_div = (unsigned long) b;
    542542
    543543  /*
     
    547547  */
    548548
    549   NATNUMBER rr = 0;
     549  unsigned long rr = 0;
    550550  while ((g < r->mod2mMask ) && (b_div > 0) && (b_div % 2 == 0))
    551551  {
     
    554554  } // g is now the gcd of 2^m and |b|
    555555
    556   if (g != 1) rr = (NATNUMBER)a % g;
     556  if (g != 1) rr = (unsigned long)a % g;
    557557  return (number)rr;
    558558}
     
    560560number nr2mIntDiv(number a, number b, const coeffs r)
    561561{
    562   if ((NATNUMBER)a == 0)
    563   {
    564     if ((NATNUMBER)b == 0)
     562  if ((unsigned long)a == 0)
     563  {
     564    if ((unsigned long)b == 0)
    565565      return (number)1;
    566     if ((NATNUMBER)b == 1)
     566    if ((unsigned long)b == 1)
    567567      return (number)0;
    568     NATNUMBER c = r->mod2mMask + 1;
     568    unsigned long c = r->mod2mMask + 1;
    569569    if (c != 0) /* i.e., if no overflow */
    570       return (number)(c / (NATNUMBER)b);
     570      return (number)(c / (unsigned long)b);
    571571    else
    572572    {
    573573      /* overflow: c = 2^32 resp. 2^64, depending on platform */
    574       int_number cc = (int_number)omAlloc(sizeof(mpz_t));
     574      mpz_ptr cc = (mpz_ptr)omAlloc(sizeof(mpz_t));
    575575      mpz_init_set_ui(cc, r->mod2mMask); mpz_add_ui(cc, cc, 1);
    576       mpz_div_ui(cc, cc, (unsigned long)(NATNUMBER)b);
     576      mpz_div_ui(cc, cc, (unsigned long)(unsigned long)b);
    577577      unsigned long s = mpz_get_ui(cc);
    578578      mpz_clear(cc); omFree((ADDRESS)cc);
    579       return (number)(NATNUMBER)s;
     579      return (number)(unsigned long)s;
    580580    }
    581581  }
    582582  else
    583583  {
    584     if ((NATNUMBER)b == 0)
     584    if ((unsigned long)b == 0)
    585585      return (number)0;
    586     return (number)((NATNUMBER) a / (NATNUMBER) b);
     586    return (number)((unsigned long) a / (unsigned long) b);
    587587  }
    588588}
     
    590590static number nr2mAnn(number b, const coeffs r)
    591591{
    592   if ((NATNUMBER)b == 0)
     592  if ((unsigned long)b == 0)
    593593    return NULL;
    594   if ((NATNUMBER)b == 1)
     594  if ((unsigned long)b == 1)
    595595    return NULL;
    596   NATNUMBER c = r->mod2mMask + 1;
     596  unsigned long c = r->mod2mMask + 1;
    597597  if (c != 0) /* i.e., if no overflow */
    598     return (number)(c / (NATNUMBER)b);
     598    return (number)(c / (unsigned long)b);
    599599  else
    600600  {
    601601    /* overflow: c = 2^32 resp. 2^64, depending on platform */
    602     int_number cc = (int_number)omAlloc(sizeof(mpz_t));
     602    mpz_ptr cc = (mpz_ptr)omAlloc(sizeof(mpz_t));
    603603    mpz_init_set_ui(cc, r->mod2mMask); mpz_add_ui(cc, cc, 1);
    604     mpz_div_ui(cc, cc, (unsigned long)(NATNUMBER)b);
     604    mpz_div_ui(cc, cc, (unsigned long)(unsigned long)b);
    605605    unsigned long s = mpz_get_ui(cc);
    606606    mpz_clear(cc); omFree((ADDRESS)cc);
    607     return (number)(NATNUMBER)s;
     607    return (number)(unsigned long)s;
    608608  }
    609609}
     
    611611number nr2mInvers(number c, const coeffs r)
    612612{
    613   if ((NATNUMBER)c % 2 == 0)
     613  if ((unsigned long)c % 2 == 0)
    614614  {
    615615    WerrorS("division by zero divisor");
     
    621621number nr2mNeg(number c, const coeffs r)
    622622{
    623   if ((NATNUMBER)c == 0) return c;
     623  if ((unsigned long)c == 0) return c;
    624624  return nr2mNegM(c, r);
    625625}
     
    627627number nr2mMapMachineInt(number from, const coeffs /*src*/, const coeffs dst)
    628628{
    629   NATNUMBER i = ((NATNUMBER)from) % dst->mod2mMask ;
     629  unsigned long i = ((unsigned long)from) % dst->mod2mMask ;
    630630  return (number)i;
    631631}
     
    633633number nr2mMapProject(number from, const coeffs /*src*/, const coeffs dst)
    634634{
    635   NATNUMBER i = ((NATNUMBER)from) % (dst->mod2mMask + 1);
     635  unsigned long i = ((unsigned long)from) % (dst->mod2mMask + 1);
    636636  return (number)i;
    637637}
     
    639639number nr2mMapZp(number from, const coeffs /*src*/, const coeffs dst)
    640640{
    641   NATNUMBER j = (NATNUMBER)1;
     641  unsigned long j = (unsigned long)1;
    642642  long ii = (long)from;
    643643  if (ii < 0) { j = dst->mod2mMask; ii = -ii; }
    644   NATNUMBER i = (NATNUMBER)ii;
     644  unsigned long i = (unsigned long)ii;
    645645  i = i & dst->mod2mMask;
    646646  /* now we have: from = j * i mod 2^m */
     
    650650number nr2mMapQ(number from, const coeffs src, const coeffs dst)
    651651{
    652   int_number erg = (int_number)omAllocBin(gmp_nrz_bin);
     652  mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
    653653  mpz_init(erg);
    654   int_number k = (int_number)omAlloc(sizeof(mpz_t));
     654  mpz_ptr k = (mpz_ptr)omAlloc(sizeof(mpz_t));
    655655  mpz_init_set_ui(k, dst->mod2mMask);
    656656
     
    667667number nr2mMapGMP(number from, const coeffs /*src*/, const coeffs dst)
    668668{
    669   int_number erg = (int_number)omAllocBin(gmp_nrz_bin);
     669  mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
    670670  mpz_init(erg);
    671   int_number k = (int_number)omAlloc(sizeof(mpz_t));
     671  mpz_ptr k = (mpz_ptr)omAlloc(sizeof(mpz_t));
    672672  mpz_init_set_ui(k, dst->mod2mMask);
    673673
    674   mpz_and(erg, (int_number)from, k);
     674  mpz_and(erg, (mpz_ptr)from, k);
    675675  number res = (number) mpz_get_ui(erg);
    676676
     
    766766BOOLEAN nr2mDBTest (number a, const char *, const int, const coeffs r)
    767767{
    768   //if ((NATNUMBER)a < 0) return FALSE; // is unsigned!
    769   if (((NATNUMBER)a & r->mod2mMask) != (NATNUMBER)a) return FALSE;
     768  //if ((unsigned long)a < 0) return FALSE; // is unsigned!
     769  if (((unsigned long)a & r->mod2mMask) != (unsigned long)a) return FALSE;
    770770  return TRUE;
    771771}
  • libpolys/coeffs/rmodulo2m.h

    rfb12237 r6a70f3  
    1111#include <coeffs/coeffs.h>
    1212#include <coeffs/rintegers.h>
    13 
    14 #ifndef NATNUMBER
    15 #define NATNUMBER unsigned long
    16 #endif
    1713
    1814BOOLEAN nr2mInitChar    (coeffs r, void*);
     
    6056{
    6157  return (number)
    62     ((((NATNUMBER) a) * ((NATNUMBER) b)) & ((NATNUMBER)r->mod2mMask));
     58    ((((unsigned long) a) * ((unsigned long) b)) & ((unsigned long)r->mod2mMask));
    6359}
    6460
     
    6662{
    6763  return (number)
    68     ((((NATNUMBER) a) + ((NATNUMBER) b)) & ((NATNUMBER)r->mod2mMask));
     64    ((((unsigned long) a) + ((unsigned long) b)) & ((unsigned long)r->mod2mMask));
    6965}
    7066
    7167static inline number nr2mSubM(number a, number b, const coeffs r)
    7268{
    73   return (number)((NATNUMBER)a < (NATNUMBER)b ?
    74                        r->mod2mMask - (NATNUMBER)b + (NATNUMBER)a + 1:
    75                        (NATNUMBER)a - (NATNUMBER)b);
     69  return (number)((unsigned long)a < (unsigned long)b ?
     70                       r->mod2mMask - (unsigned long)b + (unsigned long)a + 1:
     71                       (unsigned long)a - (unsigned long)b);
    7672}
    7773
    78 #define nr2mNegM(A,r) (number)((r->mod2mMask - (NATNUMBER)(A) + 1) & r->mod2mMask)
     74#define nr2mNegM(A,r) (number)((r->mod2mMask - (unsigned long)(A) + 1) & r->mod2mMask)
    7975#define nr2mEqualM(A,B)  ((A)==(B))
    8076
  • libpolys/coeffs/rmodulon.cc

    rfb12237 r6a70f3  
    7474    mpz_init_set(a, r->modNumber);
    7575    mpz_init_set_ui(b, ch);
    76     int_number gcd;
    77     gcd = (int_number) omAlloc(sizeof(mpz_t));
     76    mpz_ptr gcd;
     77    gcd = (mpz_ptr) omAlloc(sizeof(mpz_t));
    7878    mpz_init(gcd);
    7979    mpz_gcd(gcd, a,b);
     
    117117  assume( (getCoeffType(r) == ID) || (getCoeffType (r) == ID2) );
    118118  ZnmInfo * info= (ZnmInfo *) p;
    119   r->modBase= (int_number)nrnCopy((number)info->base, r); //this circumvents the problem
     119  r->modBase= (mpz_ptr)nrnCopy((number)info->base, r); //this circumvents the problem
    120120  //in bigintmat.cc where we cannot create a "legal" nrn that can be freed.
    121121  //If we take a copy, we can do whatever we want.
     
    183183number nrnInit(long i, const coeffs r)
    184184{
    185   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     185  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    186186  mpz_init_set_si(erg, i);
    187187  mpz_mod(erg, erg, r->modNumber);
     
    192192{
    193193  if (*a == NULL) return;
    194   mpz_clear((int_number) *a);
     194  mpz_clear((mpz_ptr) *a);
    195195  omFreeBin((void *) *a, gmp_nrz_bin);
    196196  *a = NULL;
     
    199199number nrnCopy(number a, const coeffs)
    200200{
    201   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
    202   mpz_init_set(erg, (int_number) a);
     201  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
     202  mpz_init_set(erg, (mpz_ptr) a);
    203203  return (number) erg;
    204204}
     
    215215int nrnInt(number &n, const coeffs)
    216216{
    217   return (int)mpz_get_si((int_number) n);
     217  return (int)mpz_get_si((mpz_ptr) n);
    218218}
    219219
     
    223223number nrnMult(number a, number b, const coeffs r)
    224224{
    225   int_number erg = (int_number)omAllocBin(gmp_nrz_bin);
    226   mpz_init(erg);
    227   mpz_mul(erg, (int_number)a, (int_number) b);
     225  mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
     226  mpz_init(erg);
     227  mpz_mul(erg, (mpz_ptr)a, (mpz_ptr) b);
    228228  mpz_mod(erg, erg, r->modNumber);
    229229  return (number) erg;
     
    232232void nrnPower(number a, int i, number * result, const coeffs r)
    233233{
    234   int_number erg = (int_number)omAllocBin(gmp_nrz_bin);
    235   mpz_init(erg);
    236   mpz_powm_ui(erg, (int_number)a, i, r->modNumber);
     234  mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
     235  mpz_init(erg);
     236  mpz_powm_ui(erg, (mpz_ptr)a, i, r->modNumber);
    237237  *result = (number) erg;
    238238}
     
    240240number nrnAdd(number a, number b, const coeffs r)
    241241{
    242   int_number erg = (int_number)omAllocBin(gmp_nrz_bin);
    243   mpz_init(erg);
    244   mpz_add(erg, (int_number)a, (int_number) b);
     242  mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
     243  mpz_init(erg);
     244  mpz_add(erg, (mpz_ptr)a, (mpz_ptr) b);
    245245  mpz_mod(erg, erg, r->modNumber);
    246246  return (number) erg;
     
    249249number nrnSub(number a, number b, const coeffs r)
    250250{
    251   int_number erg = (int_number)omAllocBin(gmp_nrz_bin);
    252   mpz_init(erg);
    253   mpz_sub(erg, (int_number)a, (int_number) b);
     251  mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
     252  mpz_init(erg);
     253  mpz_sub(erg, (mpz_ptr)a, (mpz_ptr) b);
    254254  mpz_mod(erg, erg, r->modNumber);
    255255  return (number) erg;
     
    260260  if( !nrnIsZero(c, r) )
    261261    // Attention: This method operates in-place.
    262     mpz_sub((int_number)c, r->modNumber, (int_number)c);
     262    mpz_sub((mpz_ptr)c, r->modNumber, (mpz_ptr)c);
    263263  return c;
    264264}
     
    266266number nrnInvers(number c, const coeffs r)
    267267{
    268   int_number erg = (int_number)omAllocBin(gmp_nrz_bin);
    269   mpz_init(erg);
    270   mpz_invert(erg, (int_number)c, r->modNumber);
     268  mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
     269  mpz_init(erg);
     270  mpz_invert(erg, (mpz_ptr)c, r->modNumber);
    271271  return (number) erg;
    272272}
     
    280280  number erg = nrnGcd(NULL, a, r);
    281281  number tmp = nrnGcd(NULL, b, r);
    282   mpz_lcm((int_number)erg, (int_number)erg, (int_number)tmp);
     282  mpz_lcm((mpz_ptr)erg, (mpz_ptr)erg, (mpz_ptr)tmp);
    283283  nrnDelete(&tmp, r);
    284284  return (number)erg;
     
    292292{
    293293  if ((a == NULL) && (b == NULL)) return nrnInit(0,r);
    294   int_number erg = (int_number)omAllocBin(gmp_nrz_bin);
     294  mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
    295295  mpz_init_set(erg, r->modNumber);
    296   if (a != NULL) mpz_gcd(erg, erg, (int_number)a);
    297   if (b != NULL) mpz_gcd(erg, erg, (int_number)b);
     296  if (a != NULL) mpz_gcd(erg, erg, (mpz_ptr)a);
     297  if (b != NULL) mpz_gcd(erg, erg, (mpz_ptr)b);
    298298  return (number)erg;
    299299}
     
    302302   number nrnGcd3(number a,number b, number c,ring r)
    303303{
    304   int_number erg = (int_number) omAllocBin(gmp_nrz_bin);
     304  mpz_ptr erg = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    305305  mpz_init(erg);
    306306  if (a == NULL) a = (number)r->modNumber;
    307307  if (b == NULL) b = (number)r->modNumber;
    308308  if (c == NULL) c = (number)r->modNumber;
    309   mpz_gcd(erg, (int_number)a, (int_number)b);
    310   mpz_gcd(erg, erg, (int_number)c);
     309  mpz_gcd(erg, (mpz_ptr)a, (mpz_ptr)b);
     310  mpz_gcd(erg, erg, (mpz_ptr)c);
    311311  mpz_gcd(erg, erg, r->modNumber);
    312312  return (number)erg;
     
    325325number nrnExtGcd(number a, number b, number *s, number *t, const coeffs r)
    326326{
    327   int_number erg = (int_number)omAllocBin(gmp_nrz_bin);
    328   int_number bs  = (int_number)omAllocBin(gmp_nrz_bin);
    329   int_number bt  = (int_number)omAllocBin(gmp_nrz_bin);
     327  mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
     328  mpz_ptr bs  = (mpz_ptr)omAllocBin(gmp_nrz_bin);
     329  mpz_ptr bt  = (mpz_ptr)omAllocBin(gmp_nrz_bin);
    330330  mpz_init(erg);
    331331  mpz_init(bs);
    332332  mpz_init(bt);
    333   mpz_gcdext(erg, bs, bt, (int_number)a, (int_number)b);
     333  mpz_gcdext(erg, bs, bt, (mpz_ptr)a, (mpz_ptr)b);
    334334  mpz_mod(bs, bs, r->modNumber);
    335335  mpz_mod(bt, bt, r->modNumber);
     
    360360#endif
    361361
    362   int_number one = (int_number)omAllocBin(gmp_nrz_bin);
    363   int_number erg = (int_number)omAllocBin(gmp_nrz_bin);
    364   int_number bs  = (int_number)omAllocBin(gmp_nrz_bin);
    365   int_number bt  = (int_number)omAllocBin(gmp_nrz_bin);
    366   int_number bu  = (int_number)omAllocBin(gmp_nrz_bin);
    367   int_number bv  = (int_number)omAllocBin(gmp_nrz_bin);
     362  mpz_ptr one = (mpz_ptr)omAllocBin(gmp_nrz_bin);
     363  mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
     364  mpz_ptr bs  = (mpz_ptr)omAllocBin(gmp_nrz_bin);
     365  mpz_ptr bt  = (mpz_ptr)omAllocBin(gmp_nrz_bin);
     366  mpz_ptr bu  = (mpz_ptr)omAllocBin(gmp_nrz_bin);
     367  mpz_ptr bv  = (mpz_ptr)omAllocBin(gmp_nrz_bin);
    368368  mpz_init(erg);
    369369  mpz_init(one);
    370   mpz_init_set(bs, (int_number) a);
    371   mpz_init_set(bt, (int_number) b);
     370  mpz_init_set(bs, (mpz_ptr) a);
     371  mpz_init_set(bt, (mpz_ptr) b);
    372372  mpz_init(bu);
    373373  mpz_init(bv);
     
    405405    nrnDelete(&ui, r);
    406406    ui = uii;
    407     int_number uu = (int_number)omAllocBin(gmp_nrz_bin);
    408     mpz_init_set(uu, (int_number)ui);
     407    mpz_ptr uu = (mpz_ptr)omAllocBin(gmp_nrz_bin);
     408    mpz_init_set(uu, (mpz_ptr)ui);
    409409    mpz_mul(bu, bu, uu);
    410410    mpz_mul(bv, bv, uu);
     
    443443  if (a == NULL) return FALSE;
    444444#endif
    445   return 0 == mpz_cmpabs_ui((int_number)a, 0);
     445  return 0 == mpz_cmpabs_ui((mpz_ptr)a, 0);
    446446}
    447447
     
    451451  if (a == NULL) return FALSE;
    452452#endif
    453   return 0 == mpz_cmp_si((int_number)a, 1);
     453  return 0 == mpz_cmp_si((mpz_ptr)a, 1);
    454454}
    455455
     
    459459  if (a == NULL) return FALSE;
    460460#endif
    461   mpz_t t; mpz_init_set(t, (int_number)a);
     461  mpz_t t; mpz_init_set(t, (mpz_ptr)a);
    462462  mpz_add_ui(t, t, 1);
    463463  bool erg = (0 == mpz_cmp(t, r->modNumber));
     
    468468BOOLEAN nrnEqual(number a, number b, const coeffs)
    469469{
    470   return 0 == mpz_cmp((int_number)a, (int_number)b);
     470  return 0 == mpz_cmp((mpz_ptr)a, (mpz_ptr)b);
    471471}
    472472
    473473BOOLEAN nrnGreater(number a, number b, const coeffs)
    474474{
    475   return 0 < mpz_cmp((int_number)a, (int_number)b);
     475  return 0 < mpz_cmp((mpz_ptr)a, (mpz_ptr)b);
    476476}
    477477
    478478BOOLEAN nrnGreaterZero(number k, const coeffs)
    479479{
    480   return 0 < mpz_cmp_si((int_number)k, 0);
     480  return 0 < mpz_cmp_si((mpz_ptr)k, 0);
    481481}
    482482
     
    491491number nrnGetUnit(number k, const coeffs r)
    492492{
    493   if (mpz_divisible_p(r->modNumber, (int_number)k)) return nrnInit(1,r);
    494 
    495   int_number unit = (int_number)nrnGcd(k, 0, r);
    496   mpz_tdiv_q(unit, (int_number)k, unit);
    497   int_number gcd = (int_number)nrnGcd((number)unit, 0, r);
     493  if (mpz_divisible_p(r->modNumber, (mpz_ptr)k)) return nrnInit(1,r);
     494
     495  mpz_ptr unit = (mpz_ptr)nrnGcd(k, 0, r);
     496  mpz_tdiv_q(unit, (mpz_ptr)k, unit);
     497  mpz_ptr gcd = (mpz_ptr)nrnGcd((number)unit, 0, r);
    498498  if (!nrnIsOne((number)gcd,r))
    499499  {
    500     int_number ctmp;
     500    mpz_ptr ctmp;
    501501    // tmp := unit^2
    502     int_number tmp = (int_number) nrnMult((number) unit,(number) unit,r);
     502    mpz_ptr tmp = (mpz_ptr) nrnMult((number) unit,(number) unit,r);
    503503    // gcd_new := gcd(tmp, 0)
    504     int_number gcd_new = (int_number) nrnGcd((number) tmp, 0, r);
     504    mpz_ptr gcd_new = (mpz_ptr) nrnGcd((number) tmp, 0, r);
    505505    while (!nrnEqual((number) gcd_new,(number) gcd,r))
    506506    {
     
    528528number nrnAnn(number k, const coeffs r)
    529529{
    530   int_number tmp = (int_number) omAllocBin(gmp_nrz_bin);
     530  mpz_ptr tmp = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    531531  mpz_init(tmp);
    532   mpz_gcd(tmp, (int_number) k, r->modNumber);
     532  mpz_gcd(tmp, (mpz_ptr) k, r->modNumber);
    533533  if (mpz_cmp_si(tmp, 1)==0) {
    534534    mpz_set_si(tmp, 0);
     
    542542{
    543543  if (a == NULL)
    544     return mpz_divisible_p(r->modNumber, (int_number)b);
     544    return mpz_divisible_p(r->modNumber, (mpz_ptr)b);
    545545  else
    546546  { /* b divides a iff b/gcd(a, b) is a unit in the given ring: */
    547547    number n = nrnGcd(a, b, r);
    548     mpz_tdiv_q((int_number)n, (int_number)b, (int_number)n);
     548    mpz_tdiv_q((mpz_ptr)n, (mpz_ptr)b, (mpz_ptr)n);
    549549    bool result = nrnIsUnit(n, r);
    550550    nrnDelete(&n, NULL);
     
    556556{
    557557  if (nrnEqual(a, b,r)) return 2;
    558   if (mpz_divisible_p((int_number) a, (int_number) b)) return -1;
    559   if (mpz_divisible_p((int_number) b, (int_number) a)) return 1;
     558  if (mpz_divisible_p((mpz_ptr) a, (mpz_ptr) b)) return -1;
     559  if (mpz_divisible_p((mpz_ptr) b, (mpz_ptr) a)) return 1;
    560560  return 0;
    561561}
     
    564564{
    565565  if (a == NULL) a = (number)r->modNumber;
    566   int_number erg = (int_number)omAllocBin(gmp_nrz_bin);
    567   mpz_init(erg);
    568   if (mpz_divisible_p((int_number)a, (int_number)b))
    569   {
    570     mpz_divexact(erg, (int_number)a, (int_number)b);
     566  mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
     567  mpz_init(erg);
     568  if (mpz_divisible_p((mpz_ptr)a, (mpz_ptr)b))
     569  {
     570    mpz_divexact(erg, (mpz_ptr)a, (mpz_ptr)b);
    571571    return (number)erg;
    572572  }
    573573  else
    574574  {
    575     int_number gcd = (int_number)nrnGcd(a, b, r);
    576     mpz_divexact(erg, (int_number)b, gcd);
     575    mpz_ptr gcd = (mpz_ptr)nrnGcd(a, b, r);
     576    mpz_divexact(erg, (mpz_ptr)b, gcd);
    577577    if (!nrnIsUnit((number)erg, r))
    578578    {
    579579      WerrorS("Division not possible, even by cancelling zero divisors.");
    580580      WerrorS("Result is integer division without remainder.");
    581       mpz_tdiv_q(erg, (int_number) a, (int_number) b);
     581      mpz_tdiv_q(erg, (mpz_ptr) a, (mpz_ptr) b);
    582582      nrnDelete((number*) &gcd, NULL);
    583583      return (number)erg;
    584584    }
    585585    // a / gcd(a,b) * [b / gcd (a,b)]^(-1)
    586     int_number tmp = (int_number)nrnInvers((number) erg,r);
    587     mpz_divexact(erg, (int_number)a, gcd);
     586    mpz_ptr tmp = (mpz_ptr)nrnInvers((number) erg,r);
     587    mpz_divexact(erg, (mpz_ptr)a, gcd);
    588588    mpz_mul(erg, erg, tmp);
    589589    nrnDelete((number*) &gcd, NULL);
     
    615615     Remark: according to mpz_mod: a,b are always non-negative
    616616  */
    617   int_number g = (int_number)omAllocBin(gmp_nrz_bin);
    618   int_number rr = (int_number)omAllocBin(gmp_nrz_bin);
     617  mpz_ptr g = (mpz_ptr)omAllocBin(gmp_nrz_bin);
     618  mpz_ptr rr = (mpz_ptr)omAllocBin(gmp_nrz_bin);
    619619  mpz_init(g);
    620620  mpz_init_set_si(rr, 0);
    621   mpz_gcd(g, (int_number)r->modNumber, (int_number)b); // g is now as above
    622   if (mpz_cmp_si(g, (long)1) != 0) mpz_mod(rr, (int_number)a, g); // the case g <> 1
     621  mpz_gcd(g, (mpz_ptr)r->modNumber, (mpz_ptr)b); // g is now as above
     622  if (mpz_cmp_si(g, (long)1) != 0) mpz_mod(rr, (mpz_ptr)a, g); // the case g <> 1
    623623  mpz_clear(g);
    624624  omFreeBin(g, gmp_nrz_bin);
     
    628628number nrnIntDiv(number a, number b, const coeffs r)
    629629{
    630   int_number erg = (int_number)omAllocBin(gmp_nrz_bin);
     630  mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
    631631  mpz_init(erg);
    632632  if (a == NULL) a = (number)r->modNumber;
    633   mpz_tdiv_q(erg, (int_number)a, (int_number)b);
     633  mpz_tdiv_q(erg, (mpz_ptr)a, (mpz_ptr)b);
    634634  return (number)erg;
    635635}
     
    653653{
    654654  mpz_t g, aa, bb;
    655   int_number qq = (int_number)omAllocBin(gmp_nrz_bin);
    656   int_number rr = (int_number)omAllocBin(gmp_nrz_bin);
     655  mpz_ptr qq = (mpz_ptr)omAllocBin(gmp_nrz_bin);
     656  mpz_ptr rr = (mpz_ptr)omAllocBin(gmp_nrz_bin);
    657657  mpz_init(qq);
    658658  mpz_init(rr);
    659659  mpz_init(g);
    660   mpz_init_set(aa, (int_number)a);
    661   mpz_init_set(bb, (int_number)b);
     660  mpz_init_set(aa, (mpz_ptr)a);
     661  mpz_init_set(bb, (mpz_ptr)b);
    662662
    663663  mpz_gcd(g, bb, r->modNumber);
     
    686686 */
    687687
    688 int_number nrnMapCoef = NULL;
     688mpz_ptr nrnMapCoef = NULL;
    689689
    690690number nrnMapModN(number from, const coeffs /*src*/, const coeffs dst)
     
    695695number nrnMap2toM(number from, const coeffs /*src*/, const coeffs dst)
    696696{
    697   int_number erg = (int_number)omAllocBin(gmp_nrz_bin);
    698   mpz_init(erg);
    699   mpz_mul_ui(erg, nrnMapCoef, (NATNUMBER)from);
     697  mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
     698  mpz_init(erg);
     699  mpz_mul_ui(erg, nrnMapCoef, (unsigned long)from);
    700700  mpz_mod(erg, erg, dst->modNumber);
    701701  return (number)erg;
     
    704704number nrnMapZp(number from, const coeffs /*src*/, const coeffs dst)
    705705{
    706   int_number erg = (int_number)omAllocBin(gmp_nrz_bin);
     706  mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
    707707  mpz_init(erg);
    708708  // TODO: use npInt(...)
    709   mpz_mul_si(erg, nrnMapCoef, (NATNUMBER)from);
     709  mpz_mul_si(erg, nrnMapCoef, (unsigned long)from);
    710710  mpz_mod(erg, erg, dst->modNumber);
    711711  return (number)erg;
     
    714714number nrnMapGMP(number from, const coeffs /*src*/, const coeffs dst)
    715715{
    716   int_number erg = (int_number)omAllocBin(gmp_nrz_bin);
    717   mpz_init(erg);
    718   mpz_mod(erg, (int_number)from, dst->modNumber);
     716  mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
     717  mpz_init(erg);
     718  mpz_mod(erg, (mpz_ptr)from, dst->modNumber);
    719719  return (number)erg;
    720720}
     
    723723number nrnMapZ(number from, const coeffs /*src*/, const coeffs dst)
    724724{
    725   int_number erg = (int_number)omAllocBin(gmp_nrz_bin);
     725  mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
    726726  if (n_Z_IS_SMALL(from))
    727727    mpz_init_set_si(erg, SR_TO_INT(from));
    728728  else
    729     mpz_init_set(erg, (int_number) from);
     729    mpz_init_set(erg, (mpz_ptr) from);
    730730  mpz_mod(erg, erg, dst->modNumber);
    731731  return (number)erg;
     
    758758  else
    759759  {
    760     int l=mpz_sizeinbase((int_number) a, 10) + 2;
     760    int l=mpz_sizeinbase((mpz_ptr) a, 10) + 2;
    761761    s=(char*)omAlloc(l);
    762     z=mpz_get_str(s,10,(int_number) a);
     762    z=mpz_get_str(s,10,(mpz_ptr) a);
    763763    StringAppendS(z);
    764764    omFreeSize((ADDRESS)s,l);
     
    769769number nrnMapQ(number from, const coeffs src, const coeffs dst)
    770770{
    771   int_number erg = (int_number)omAllocBin(gmp_nrz_bin);
     771  mpz_ptr erg = (mpz_ptr)omAllocBin(gmp_nrz_bin);
    772772  mpz_init(erg);
    773773  nlGMP(from, (number)erg, src);
     
    800800    else
    801801    {
    802       int_number nrnMapModul = (int_number) omAllocBin(gmp_nrz_bin);
     802      mpz_ptr nrnMapModul = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    803803      // Computing the n of Z/n
    804804      if (nCoeff_is_Zp(src))
     
    815815      if (nrnMapCoef == NULL)
    816816      {
    817         nrnMapCoef = (int_number) omAllocBin(gmp_nrz_bin);
     817        nrnMapCoef = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    818818        mpz_init(nrnMapCoef);
    819819      }
     
    826826      {
    827827        mpz_divexact(nrnMapCoef, dst->modNumber, nrnMapModul);
    828         int_number tmp = dst->modNumber;
     828        mpz_ptr tmp = dst->modNumber;
    829829        dst->modNumber = nrnMapModul;
    830830        if (!nrnIsUnit((number) nrnMapCoef,dst))
     
    834834          return NULL;
    835835        }
    836         int_number inv = (int_number) nrnInvers((number) nrnMapCoef,dst);
     836        mpz_ptr inv = (mpz_ptr) nrnInvers((number) nrnMapCoef,dst);
    837837        dst->modNumber = tmp;
    838838        mpz_mul(nrnMapCoef, nrnMapCoef, inv);
     
    867867
    868868  r->modExponent= m;
    869   r->modNumber = (int_number)omAllocBin(gmp_nrz_bin);
     869  r->modNumber = (mpz_ptr)omAllocBin(gmp_nrz_bin);
    870870  mpz_init_set (r->modNumber, r->modBase);
    871871  mpz_pow_ui (r->modNumber, r->modNumber, m);
     
    887887{
    888888  if (a==NULL) return TRUE;
    889   if ( (mpz_cmp_si((int_number) a, 0) < 0) || (mpz_cmp((int_number) a, r->modNumber) > 0) )
     889  if ( (mpz_cmp_si((mpz_ptr) a, 0) < 0) || (mpz_cmp((mpz_ptr) a, r->modNumber) > 0) )
    890890  {
    891891    return FALSE;
     
    924924const char * nrnRead (const char *s, number *a, const coeffs r)
    925925{
    926   int_number z = (int_number) omAllocBin(gmp_nrz_bin);
     926  mpz_ptr z = (mpz_ptr) omAllocBin(gmp_nrz_bin);
    927927  {
    928928    s = nlCPEatLongC((char *)s, z);
  • libpolys/coeffs/rmodulon.h

    rfb12237 r6a70f3  
    1111#include <coeffs/rintegers.h>
    1212
    13 #ifndef NATNUMBER
    14 #define NATNUMBER unsigned long
    15 #endif
    16 
    17 typedef struct { int_number base; NATNUMBER exp; } ZnmInfo;
     13typedef struct { mpz_ptr base;  unsigned long exp; } ZnmInfo;
    1814
    1915BOOLEAN nrnInitChar    (coeffs r, void*);
  • libpolys/polys/monomials/ring.h

    rfb12237 r6a70f3  
    246246// #ifdef HAVE_RINGS
    247247//   unsigned int  cf->ringtype;  /* cring = 0 => coefficient field, cring = 1 => coeffs from Z/2^m */
    248 //   int_number    cf->modBase; /* Z/(ringflag^cf->modExponent)=Z/cf->modNumber*/
     248//   mpz_ptr    cf->modBase; /* Z/(ringflag^cf->modExponent)=Z/cf->modNumber*/
    249249//   unsigned long cf->modExponent;
    250250//   unsigned long cf->modNumber;  /* Z/cf->modNumber */
    251 //   int_number    cf->modNumber;
     251//   mpz_ptr    cf->modNumber;
    252252// #endif
    253253
Note: See TracChangeset for help on using the changeset viewer.