Changeset 3216ec in git for libpolys/coeffs/longrat.cc


Ignore:
Timestamp:
Aug 15, 2012, 1:44:30 PM (10 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'ad2543eab51733612ba7d118afc77edca719600e')
Children:
d8b0997ff6f148513d95e2f2a5a075c7386c7168
Parents:
a8ead8e63f3539f8915726efa18791dcc052733a
Message:
add: extgcd for bigint
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/longrat.cc

    ra8ead8 r3216ec  
    26052605}
    26062606
     2607number nlExtGcd(number a, number b, number *s, number *t, const coeffs)
     2608{
     2609  mpz_t aa,bb;
     2610  *s=ALLOC_RNUMBER();
     2611  mpz_init((*s)->z); (*s)->s=3;
     2612  (*t)=ALLOC_RNUMBER();
     2613  mpz_init((*t)->z); (*t)->s=3;
     2614  number g=ALLOC_RNUMBER();
     2615  mpz_init(g->z); g->s=3;
     2616  if (SR_HDL(a) & SR_INT)
     2617  {
     2618    mpz_init_set_si(aa,SR_TO_INT(a));
     2619  }
     2620  else
     2621  {
     2622    mpz_init_set(aa,a->z);
     2623  }
     2624  if (SR_HDL(b) & SR_INT)
     2625  {
     2626    mpz_init_set_si(bb,SR_TO_INT(b));
     2627  }
     2628  else
     2629  {
     2630    mpz_init_set(bb,b->z);
     2631  }
     2632  mpz_gcdext(g->z,(*s)->z,(*t)->z,aa,bb);
     2633  mpz_clear(aa);
     2634  mpz_clear(bb);
     2635  (*s)=nlShort3((*s));
     2636  (*t)=nlShort3((*t));
     2637  g=nlShort3(g);
     2638  return g;
     2639}
     2640
    26072641void    nlCoeffWrite  (const coeffs, BOOLEAN /*details*/)
    26082642{
     
    28162850  //r->cfIsUnit = NULL; // only for ring stuff
    28172851  //r->cfGetUnit = NULL; // only for ring stuff
    2818   //r->cfExtGcd = NULL; // only for ring stuff
    28192852  //r->cfDivBy = NULL; // only for ring stuff
    28202853  #endif
     
    28372870  r->cfGetNumerator = nlGetNumerator;
    28382871  r->cfGcd  = nlGcd;
     2872  r->cfExtGcd = nlExtGcd; // only for ring stuff and Z
    28392873  r->cfLcm  = nlLcm;
    28402874  r->cfDelete= nlDelete;
Note: See TracChangeset for help on using the changeset viewer.