Changeset 146c603 in git for libpolys/coeffs/longrat.cc


Ignore:
Timestamp:
Nov 9, 2011, 10:13:02 AM (12 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
8f40312428677d88ab37a31824f2ec53f144a18a
Parents:
fc497757365979d0168460de9969b49bc49c53f2
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2011-11-09 10:13:02+01:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 16:14:12+01:00
Message:
fix: nlModP (should not use nvDiv/npDiv
implement conversion to/from factory for algext
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/longrat.cc

    rfc4977 r146c603  
    12681268  {
    12691269    int in=mpz_fdiv_ui(n->n,(unsigned long)p);
    1270     #ifdef NV_OPS
    1271     if (p>NV_MAX_PRIME)
    1272     return (int)((long)nvDiv((number)iz,(number)in,(const coeffs)r));
    1273     #endif
    1274     return (int)((long)npDiv((number)iz,(number)in,(const coeffs)r));
     1270    long  s, t;
     1271
     1272    long  u, v, u0, v0, u1, v1, u2, v2, q, r;
     1273
     1274     u1=1; v1=0;
     1275     u2=0; v2=1;
     1276     u = in; v = p;
     1277
     1278     while (v != 0)
     1279     {
     1280        q = u / v;
     1281        r = u % v;
     1282        u = v;
     1283        v = r;
     1284        u0 = u2;
     1285        v0 = v2;
     1286        u2 =  u1 - q*u2;
     1287        v2 = v1- q*v2;
     1288        u1 = u0;
     1289        v1 = v0;
     1290     }
     1291
     1292     s = u1;
     1293     if (s < 0) s+=p;
     1294     u=(s*((long)iz)) % ((long)p);
     1295     return (int)u;
    12751296  }
    12761297  return iz;
Note: See TracChangeset for help on using the changeset viewer.