Changeset bb865e in git for libpolys


Ignore:
Timestamp:
Jul 27, 2017, 3:49:53 PM (7 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '2a584933abf2a2d3082034c7586d38bb6de1a30a')
Children:
6310b17eabaf8a6adfd0f335e522b7de83ddd648
Parents:
99c34cc0dbf214fef21abb247bd17d346ebe019c
Message:
opt: npInpAdd, npInpMult
Location:
libpolys/coeffs
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/modulop.cc

    r99c34c rbb865e  
    2929number  npInit        (long i, const coeffs r);
    3030long    npInt         (number &n, const coeffs r);
    31 number  npAdd         (number a, number b,const coeffs r);
    32 number  npSub         (number a, number b,const coeffs r);
    3331void    npPower       (number a, int i, number * result,const coeffs r);
    3432BOOLEAN npIsZero      (number a,const coeffs r);
     
    123121}
    124122
    125 number npAdd (number a, number b, const coeffs r)
    126 {
    127   n_Test(a, r);
    128   n_Test(b, r);
    129 
    130   number c = npAddM(a,b, r);
    131 
    132   n_Test(c, r);
    133 
    134   return c;
    135 }
    136 
    137 number npSub (number a, number b, const coeffs r)
    138 {
    139   n_Test(a, r);
    140   n_Test(b, r);
    141 
    142   number c = npSubM(a,b,r);
    143 
    144   n_Test(c, r);
    145 
    146   return c;
    147 }
    148 
    149123BOOLEAN npIsZero (number  a, const coeffs r)
    150124{
     
    497471
    498472  r->cfMult  = npMult;
    499   r->cfSub   = npSub;
    500   r->cfAdd   = npAdd;
     473  r->cfInpMult  = npInpMultM;
     474  r->cfSub   = npSubM;
     475  r->cfAdd   = npAddM;
     476  r->cfInpAdd   = npInpAddM;
    501477  r->cfDiv   = npDiv;
    502478  r->cfInit = npInit;
  • libpolys/coeffs/modulop.h

    r99c34c rbb865e  
    4646    ((((unsigned long) a)*((unsigned long) b)) % ((unsigned long) r->ch));
    4747}
     48static inline void npInpMultM(number &a, number b, const coeffs r)
     49{
     50  a=(number)
     51    ((((unsigned long) a)*((unsigned long) b)) % ((unsigned long) r->ch));
     52}
    4853#else
    4954static inline number npMultM(number a, number b, const coeffs r)
     
    5156  long x = (long)r->npLogTable[(long)a]+ r->npLogTable[(long)b];
    5257  return (number)(long)r->npExpTable[x<r->npPminus1M ? x : x- r->npPminus1M];
     58}
     59static inline void npInpMultM(number &a, number b, const coeffs r)
     60{
     61  long x = (long)r->npLogTable[(long)a]+ r->npLogTable[(long)b];
     62  a=(number)(long)r->npExpTable[x<r->npPminus1M ? x : x- r->npPminus1M];
    5363}
    5464#endif
     
    8090  return (number)(R >= r->ch ? R - r->ch : R);
    8191}
     92static inline void npInpAddM(number &a, number b, const coeffs r)
     93{
     94  unsigned long R = (unsigned long)a + (unsigned long)b;
     95  a=(number)(R >= r->ch ? R - r->ch : R);
     96}
    8297static inline number npSubM(number a, number b, const coeffs r)
    8398{
     
    96111#endif
    97112   return (number)res;
     113}
     114static inline void npInpAddM(number &a, number b, const coeffs r)
     115{
     116   unsigned long res = (long)((unsigned long)a + (unsigned long)b);
     117   res -= r->ch;
     118#if SIZEOF_LONG == 8
     119   res += ((long)res >> 63) & r->ch;
     120#else
     121   res += ((long)res >> 31) & r->ch;
     122#endif
     123   a=(number)res;
    98124}
    99125static inline number npSubM(number a, number b, const coeffs r)
Note: See TracChangeset for help on using the changeset viewer.