Changeset af378f7 in git


Ignore:
Timestamp:
Jan 30, 2008, 7:49:43 PM (16 years ago)
Author:
Oliver Wienand <wienand@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'a69e2b93742879ecc5ec70006f5f272874f94e7e')
Children:
2f959e83f22c8e788ce3941f4ac3eb2fb1df74c1
Parents:
12ea9df042d8c883f3d3c722b2388c0424347a88
Message:
anpassungen an gmp


git-svn-id: file:///usr/local/Singular/svn/trunk@10538 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
kernel
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • kernel/kutil.cc

    r12ea9d raf378f7  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: kutil.cc,v 1.73 2008-01-30 09:14:04 wienand Exp $ */
     4/* $Id: kutil.cc,v 1.74 2008-01-30 18:49:42 wienand Exp $ */
    55/*
    66* ABSTRACT: kernel: utils for kStd
     
    26352635{
    26362636  number gcd = nGcd((number) 0, pGetCoeff(h), strat->tailRing);
    2637   if ((NATNUMBER) gcd > 1)
     2637  if (!nIsOne(gcd))
    26382638  {
    26392639    poly p = p_Copy(h->next, strat->tailRing);
    2640 /*    long a = ((long) ((h)->coef)) / 2;
    2641     long b = currRing->ch - 1;
    2642     while (a % 2 == 0)
    2643     {
    2644       a = a / 2;
    2645       b--;
    2646     }
    2647     p = p_Mult_nn(p, (number) twoPow(b), strat->tailRing); */
    2648     p = p_Mult_nn(p, nIntDiv(0, gcd), strat->tailRing);
     2640    gcd = nIntDiv(0, gcd);
     2641    p = p_Mult_nn(p, gcd, strat->tailRing);
     2642    nDelete(&gcd);
    26492643
    26502644    if (p != NULL)
  • kernel/p_Minus_mm_Mult_qq__T.cc

    r12ea9d raf378f7  
    77 *  Author:  obachman (Olaf Bachmann)
    88 *  Created: 8/00
    9  *  Version: $Id: p_Minus_mm_Mult_qq__T.cc,v 1.6 2007-05-10 08:12:42 wienand Exp $
     9 *  Version: $Id: p_Minus_mm_Mult_qq__T.cc,v 1.7 2008-01-30 18:49:43 wienand Exp $
    1010 *******************************************************************/
    1111
     
    6868  tb = n_Mult(pGetCoeff(q), tm, r);
    6969#ifdef HAVE_ZERODIVISORS
    70   if ((long) tb != 0) {
     70  if (!nIsZero(tb)) {
    7171#endif
    7272  tc = pGetCoeff(p);
     
    9999#ifdef HAVE_ZERODIVISORS
    100100  tb = n_Mult(pGetCoeff(q), tneg, r);
    101   if ((long) tb != 0)
     101  if (!nIsZero(tb))
    102102  {
    103103#endif
  • kernel/p_Mult_nn__T.cc

    r12ea9d raf378f7  
    77 *  Author:  obachman (Olaf Bachmann)
    88 *  Created: 8/00
    9  *  Version: $Id: p_Mult_nn__T.cc,v 1.9 2007-05-10 08:12:42 wienand Exp $
     9 *  Version: $Id: p_Mult_nn__T.cc,v 1.10 2008-01-30 18:49:43 wienand Exp $
    1010 *******************************************************************/
    1111
     
    3535#else
    3636    number tmp = n_Mult(n, pGetCoeff(p), r);
    37     if (tmp != NULL)
     37    if (!nIsZero(tmp))
    3838    {
    39        p_SetCoeff(p, tmp, r);
     39       number nc = pGetCoeff(p);
     40       p_SetCoeff0(p, tmp, r);
     41       n_Delete(&nc, r);
    4042       old = p;
    4143       pIter(p);
     
    4446    {
    4547      n_Delete(&tmp, r);
    46       if (old == NULL) { q = pNext(q); }
    47       else { pNext(old) = pNext(p); }
    48       pIter(p);    // TODO Free Monom OLIVER
     48      if (old == NULL)
     49      {
     50        pIter(p);
     51        p_DeleteLm(&q, r);
     52      }
     53      else
     54      {
     55        p_DeleteLm(&p, r);
     56        pNext(old) = p;
     57      }
    4958    }
    5059#endif
  • kernel/polys.cc

    r12ea9d raf378f7  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: polys.cc,v 1.26 2007-07-24 12:29:31 Singular Exp $ */
     4/* $Id: polys.cc,v 1.27 2008-01-30 18:49:43 wienand Exp $ */
    55
    66/*
     
    730730      if (!nIsOne(k))
    731731      {
    732         c = nDiv(pGetCoeff(p1), k);
     732        k = nInvers(k);
     733        c = nMult(pGetCoeff(p1), k); 
    733734        nDelete(&pGetCoeff(p1));
    734735        pSetCoeff0(p1, c);
     
    736737        while (h != NULL)
    737738        {
    738           c = nDiv(pGetCoeff(h), k);
     739          c = nMult(pGetCoeff(h), k);
    739740          nDelete(&pGetCoeff(h));
    740741          pSetCoeff0(h, c);
  • kernel/rintegers.cc

    r12ea9d raf378f7  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: rintegers.cc,v 1.5 2008-01-30 13:03:41 wienand Exp $ */
     4/* $Id: rintegers.cc,v 1.6 2008-01-30 18:49:43 wienand Exp $ */
    55/*
    66* ABSTRACT: numbers modulo n
     
    274274{
    275275  char * start=s;
    276 
     276  if (!(*s >= '0' && *s <= '9'))
     277  {
     278    mpz_init_set_si(i, 1);
     279    return s;
     280  }
     281  mpz_init(i);
    277282  while (*s >= '0' && *s <= '9') s++;
    278283  if (*s=='\0')
     
    290295}
    291296
     297
    292298char * nrzRead (char *s, number *a)
    293299{
  • kernel/rmodulon.cc

    r12ea9d raf378f7  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: rmodulon.cc,v 1.10 2008-01-30 16:14:25 wienand Exp $ */
     4/* $Id: rmodulon.cc,v 1.11 2008-01-30 18:49:43 wienand Exp $ */
    55/*
    66* ABSTRACT: numbers modulo n
     
    6161  int_number erg = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
    6262  mpz_init(erg);
     63  if (a == NULL) a = (number) nrnModul;
     64  if (b == NULL) b = (number) nrnModul;
    6365  mpz_gcd(erg, (int_number) a, (int_number) b);
    6466  return (number) erg;
    6567}
     68
     69number nrnGcd3 (number a,number b, number c,ring r)
     70{
     71  int_number erg = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
     72  mpz_init(erg);
     73  if (a == NULL) a = (number) nrnModul;
     74  if (b == NULL) b = (number) nrnModul;
     75  if (c == NULL) c = (number) nrnModul;
     76  mpz_gcd(erg, (int_number) a, (int_number) b);
     77  mpz_gcd(erg, erg, (int_number) c);
     78  return (number) erg;
     79}
     80
    6681
    6782/*
     
    87102  int_number erg = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
    88103  mpz_init(erg);
    89   mpz_pow_ui(erg, (int_number) a, i);
     104  mpz_powm_ui(erg, (int_number) a, i, nrnModul);
     105  *result = (number) erg;
     106}
     107
     108/*
     109 * create a number from int
     110 */
     111number nrnInit (int i)
     112{
     113  int_number erg = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
     114  mpz_init_set_si(erg, i);
    90115  mpz_mod(erg, erg, nrnModul);
    91 //  int_number tmp = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
    92 //  mpz_init(tmp);
    93 //  mpz_clear(erg);
    94 //  omFree(erg);
    95 //  erg = tmp;
    96   *result = (number) erg;
    97 }
    98 
    99 /*
    100  * create a number from int
    101  */
    102 number nrnInit (int i)
    103 {
    104   int_number erg = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
    105   mpz_init_set_si(erg, i);
    106116  return (number) erg;
    107117}
     
    139149}
    140150
    141 number  nrnGetUnit (number a)
    142 {
    143   return nrnDiv((number) nrnModul, nrnGcd(a, (number) nrnModul, NULL));
     151number  nrnGetUnit (number k)
     152{
     153  return nrnInit(1);
     154  number unit = nrnIntDiv(k, nrnGcd(k, 0, currRing));
     155  number gcd = nrnGcd(unit, 0, currRing);
     156  if (!nrnIsOne(gcd))
     157  {
     158    number tmp = nrnMult(unit, unit);
     159    number gcd_new = nrnGcd(tmp, 0, currRing);
     160    while (!nrnEqual(gcd_new, gcd))
     161    {
     162      nrnDelete(&gcd, NULL);
     163      gcd = gcd_new;
     164      tmp = nrnMult(tmp, unit);
     165      gcd_new = nrnGcd(tmp, 0, currRing);
     166    }
     167    unit = nrnAdd(unit, nrnIntDiv(0, gcd_new));
     168    nrnDelete(&gcd_new, NULL);
     169  }
     170  nrnDelete(&gcd, NULL);
     171  return unit;
    144172}
    145173
    146174BOOLEAN nrnIsUnit (number a)
    147175{
    148   return nrnIsOne(nrnGcd(a, (number) nrnModul, NULL));
     176  number tmp = nrnGcd(a, (number) nrnModul, NULL);
     177  bool res = nrnIsOne(tmp);
     178  nrnDelete(&tmp, NULL);
     179  return res;
    149180}
    150181
     
    189220BOOLEAN nrnDivBy (number a,number b)
    190221{
    191   return mpz_divisible_p((int_number) a, (int_number) b) != 0;
     222  number bs = nrnIntDiv(b, nrnGcd(a, b, NULL));
     223  bool res = nrnIsUnit(bs);
     224  nrnDelete(&bs, NULL);
     225  return res;
    192226}
    193227
    194228number nrnDiv (number a,number b)
    195229{
    196   int_number erg = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
    197   mpz_init(erg);
    198   if (nrnDivBy(a, b))
     230  if (a == NULL) a = (number) nrnModul;
     231  int_number erg = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
     232  mpz_init(erg);
     233  if (mpz_divisible_p((int_number) a, (int_number) b))
    199234  {
    200235    mpz_divexact(erg, (int_number) a, (int_number) b);
     
    234269  int_number erg = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
    235270  mpz_init(erg);
     271  if (a == NULL) a = (number) nrnModul;
    236272  mpz_tdiv_q(erg, (int_number) a, (int_number) b);
    237273  return (number) erg;
     
    339375{
    340376  char * start=s;
    341 
     377  if (!(*s >= '0' && *s <= '9'))
     378  {
     379    mpz_init_set_si(i, 1);
     380    return s;
     381  }
     382  mpz_init(i);
    342383  while (*s >= '0' && *s <= '9') s++;
    343384  if (*s=='\0')
     
    359400  int_number z = (int_number) omAlloc(sizeof(MP_INT)); // evtl. spaeter mit bin
    360401  {
    361     mpz_init(z);
    362402    s = nlCPEatLongC(s, z);
    363403  }
Note: See TracChangeset for help on using the changeset viewer.