Changeset 2ac2996 in git


Ignore:
Timestamp:
Feb 28, 2022, 9:47:08 PM (2 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
Children:
5b4fbd8628e662e19ce83b185fe94dbc213f1305
Parents:
fc2e0d38db0650acaca55c5367712f26fd5ddb55
Message:
opt+InpAdd,InpMult for algext.cc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/ext_fields/algext.cc

    rfc2e0d r2ac2996  
    5353#ifdef LDEBUG
    5454#define naTest(a) naDBTest(a,__FILE__,__LINE__,cf)
    55 BOOLEAN  naDBTest(number a, const char *f, const int l, const coeffs r);
     55static BOOLEAN  naDBTest(number a, const char *f, const int l, const coeffs r);
    5656#else
    5757#define naTest(a) do {} while (0)
     
    7171
    7272/// forward declarations
    73 BOOLEAN  naGreaterZero(number a, const coeffs cf);
    74 BOOLEAN  naGreater(number a, number b, const coeffs cf);
    75 BOOLEAN  naEqual(number a, number b, const coeffs cf);
    76 BOOLEAN  naIsOne(number a, const coeffs cf);
    77 BOOLEAN  naIsMOne(number a, const coeffs cf);
    78 number   naInit(long i, const coeffs cf);
    79 number   naNeg(number a, const coeffs cf);
    80 number   naInvers(number a, const coeffs cf);
    81 number   naAdd(number a, number b, const coeffs cf);
    82 number   naSub(number a, number b, const coeffs cf);
    83 number   naMult(number a, number b, const coeffs cf);
    84 number   naDiv(number a, number b, const coeffs cf);
    85 void     naPower(number a, int exp, number *b, const coeffs cf);
    86 number   naCopy(number a, const coeffs cf);
    87 void     naWriteLong(number a, const coeffs cf);
    88 void     naWriteShort(number a, const coeffs cf);
    89 number   naGetDenom(number &a, const coeffs cf);
    90 number   naGetNumerator(number &a, const coeffs cf);
    91 number   naGcd(number a, number b, const coeffs cf);
    92 void     naDelete(number *a, const coeffs cf);
    93 void     naCoeffWrite(const coeffs cf, BOOLEAN details);
     73static BOOLEAN  naGreaterZero(number a, const coeffs cf);
     74static BOOLEAN  naGreater(number a, number b, const coeffs cf);
     75static BOOLEAN  naEqual(number a, number b, const coeffs cf);
     76static BOOLEAN  naIsOne(number a, const coeffs cf);
     77static BOOLEAN  naIsMOne(number a, const coeffs cf);
     78static number   naInit(long i, const coeffs cf);
     79static number   naNeg(number a, const coeffs cf);
     80static number   naInvers(number a, const coeffs cf);
     81static number   naAdd(number a, number b, const coeffs cf);
     82static number   naSub(number a, number b, const coeffs cf);
     83static number   naMult(number a, number b, const coeffs cf);
     84static number   naDiv(number a, number b, const coeffs cf);
     85static void     naPower(number a, int exp, number *b, const coeffs cf);
     86static number   naCopy(number a, const coeffs cf);
     87static void     naWriteLong(number a, const coeffs cf);
     88static void     naWriteShort(number a, const coeffs cf);
     89static number   naGetDenom(number &a, const coeffs cf);
     90static number   naGetNumerator(number &a, const coeffs cf);
     91static number   naGcd(number a, number b, const coeffs cf);
     92static void     naDelete(number *a, const coeffs cf);
     93static void     naCoeffWrite(const coeffs cf, BOOLEAN details);
    9494//number   naIntDiv(number a, number b, const coeffs cf);
    95 const char * naRead(const char *s, number *a, const coeffs cf);
     95static const char * naRead(const char *s, number *a, const coeffs cf);
    9696
    9797static BOOLEAN naCoeffIsEqual(const coeffs cf, n_coeffType n, void * param);
     
    249249#endif
    250250
    251 void heuristicReduce(poly &p, poly reducer, const coeffs cf);
    252 void definiteReduce(poly &p, poly reducer, const coeffs cf);
     251static void heuristicReduce(poly &p, poly reducer, const coeffs cf);
     252static void definiteReduce(poly &p, poly reducer, const coeffs cf);
    253253
    254254/* returns the bottom field in this field extension tower; if the tower
     
    270270}
    271271
    272 BOOLEAN naIsZero(number a, const coeffs cf)
     272static BOOLEAN naIsZero(number a, const coeffs cf)
    273273{
    274274  naTest(a);
     
    276276}
    277277
    278 void naDelete(number * a, const coeffs cf)
     278static void naDelete(number * a, const coeffs cf)
    279279{
    280280  if (*a == NULL) return;
     
    285285}
    286286
    287 BOOLEAN naEqual(number a, number b, const coeffs cf)
     287static BOOLEAN naEqual(number a, number b, const coeffs cf)
    288288{
    289289  naTest(a); naTest(b);
     
    294294}
    295295
    296 number naCopy(number a, const coeffs cf)
     296static number naCopy(number a, const coeffs cf)
    297297{
    298298  naTest(a);
     
    301301}
    302302
    303 number naGetNumerator(number &a, const coeffs cf)
    304 {
    305   return naCopy(a, cf);
    306 }
    307 
    308 number naGetDenom(number &a, const coeffs cf)
    309 {
    310   naTest(a);
    311   return naInit(1, cf);
    312 }
    313 
    314 BOOLEAN naIsOne(number a, const coeffs cf)
     303static BOOLEAN naIsOne(number a, const coeffs cf)
    315304{
    316305  naTest(a);
     
    320309}
    321310
    322 BOOLEAN naIsMOne(number a, const coeffs cf)
     311static BOOLEAN naIsMOne(number a, const coeffs cf)
    323312{
    324313  naTest(a);
     
    329318
    330319/// this is in-place, modifies a
    331 number naNeg(number a, const coeffs cf)
     320static number naNeg(number a, const coeffs cf)
    332321{
    333322  naTest(a);
     
    336325}
    337326
    338 number naInit(long i, const coeffs cf)
     327static number naInit(long i, const coeffs cf)
    339328{
    340329  if (i == 0) return NULL;
     
    348337}
    349338
    350 long naInt(number &a, const coeffs cf)
     339static long naInt(number &a, const coeffs cf)
    351340{
    352341  naTest(a);
     
    361350
    362351/* TRUE iff (a != 0 and (b == 0 or deg(a) > deg(b) or (deg(a)==deg(b) && lc(a)>lc(b))) */
    363 BOOLEAN naGreater(number a, number b, const coeffs cf)
     352static BOOLEAN naGreater(number a, number b, const coeffs cf)
    364353{
    365354  naTest(a); naTest(b);
     
    381370
    382371/* TRUE iff a != 0 and (LC(a) > 0 or deg(a) > 0) */
    383 BOOLEAN naGreaterZero(number a, const coeffs cf)
     372static BOOLEAN naGreaterZero(number a, const coeffs cf)
    384373{
    385374  naTest(a);
     
    390379}
    391380
    392 void naCoeffWrite(const coeffs cf, BOOLEAN details)
     381static void naCoeffWrite(const coeffs cf, BOOLEAN details)
    393382{
    394383  assume( cf != NULL );
     
    440429}
    441430
    442 number naAdd(number a, number b, const coeffs cf)
     431static number naAdd(number a, number b, const coeffs cf)
    443432{
    444433  naTest(a); naTest(b);
     
    451440}
    452441
    453 number naSub(number a, number b, const coeffs cf)
     442static void naInpAdd(number &a, number b, const coeffs cf)
     443{
     444  naTest(a); naTest(b);
     445  if (a == NULL) a=b;
     446  else if (b != NULL)
     447  {
     448    poly aPlusB = p_Add_q((poly)a, p_Copy((poly)b, naRing), naRing);
     449    a=(number)aPlusB;
     450  }
     451}
     452
     453static number naSub(number a, number b, const coeffs cf)
    454454{
    455455  naTest(a); naTest(b);
     
    462462}
    463463
    464 number naMult(number a, number b, const coeffs cf)
     464static number naMult(number a, number b, const coeffs cf)
    465465{
    466466  naTest(a); naTest(b);
     
    472472}
    473473
    474 number naDiv(number a, number b, const coeffs cf)
     474static void naInpMult(number &a, number b, const coeffs cf)
     475{
     476  naTest(a); naTest(b);
     477  if ((a == NULL)||(b == NULL)) { a=NULL; return;}
     478  poly aTimesB = p_Mult_q((poly)a, p_Copy((poly)b,naRing), naRing);
     479  definiteReduce(aTimesB, naMinpoly, cf);
     480  p_Normalize(aTimesB,naRing);
     481  a=(number)aTimesB;
     482}
     483
     484static number naDiv(number a, number b, const coeffs cf)
    475485{
    476486  naTest(a); naTest(b);
     
    496506   the in-place method heuristicReduce(poly, poly, coeffs); see there.
    497507*/
    498 void naPower(number a, int exp, number *b, const coeffs cf)
     508static void naPower(number a, int exp, number *b, const coeffs cf)
    499509{
    500510  naTest(a);
     
    563573      if (deg(p) > 10*deg(reducer) then perform reduction;
    564574   modifies p */
    565 void heuristicReduce(poly &p, poly reducer, const coeffs cf)
     575static void heuristicReduce(poly &p, poly reducer, const coeffs cf)
    566576{
    567577  #ifdef LDEBUG
     
    573583}
    574584
    575 void naWriteLong(number a, const coeffs cf)
     585static void naWriteLong(number a, const coeffs cf)
    576586{
    577587  naTest(a);
     
    591601}
    592602
    593 void naWriteShort(number a, const coeffs cf)
     603static void naWriteShort(number a, const coeffs cf)
    594604{
    595605  naTest(a);
     
    609619}
    610620
    611 const char * naRead(const char *s, number *a, const coeffs cf)
     621static const char * naRead(const char *s, number *a, const coeffs cf)
    612622{
    613623  poly aAsPoly;
     
    620630#if 0
    621631/* implemented by the rule lcm(a, b) = a * b / gcd(a, b) */
    622 number naLcm(number a, number b, const coeffs cf)
     632static number naLcm(number a, number b, const coeffs cf)
    623633{
    624634  naTest(a); naTest(b);
     
    632642}
    633643#endif
    634 number napNormalizeHelper(number b, const coeffs cf)
     644static number napNormalizeHelper(number b, const coeffs cf)
    635645{
    636646  number h=n_Init(1,naRing->cf);
     
    646656  return h;
    647657}
    648 number naLcmContent(number a, number b, const coeffs cf)
     658static number naLcmContent(number a, number b, const coeffs cf)
    649659{
    650660  if (nCoeff_is_Zp(naRing->cf)) return naCopy(a,cf);
     
    715725}
    716726
    717 int naSize(number a, const coeffs cf)
     727static int naSize(number a, const coeffs cf)
    718728{
    719729  if (a == NULL) return 0;
     
    733743   of division of p by the reducer;
    734744   modifies p */
    735 void definiteReduce(poly &p, poly reducer, const coeffs cf)
     745static void definiteReduce(poly &p, poly reducer, const coeffs cf)
    736746{
    737747  #ifdef LDEBUG
     
    745755}
    746756
    747 void  naNormalize(number &a, const coeffs cf)
     757static void  naNormalize(number &a, const coeffs cf)
    748758{
    749759  poly aa=(poly)a;
     
    753763}
    754764
    755 number naConvFactoryNSingN( const CanonicalForm n, const coeffs cf)
     765static number naConvFactoryNSingN( const CanonicalForm n, const coeffs cf)
    756766{
    757767  if (n.isZero()) return NULL;
     
    759769  return (number)p;
    760770}
    761 CanonicalForm naConvSingNFactoryN( number n, BOOLEAN /*setChar*/, const coeffs cf )
     771static CanonicalForm naConvSingNFactoryN( number n, BOOLEAN /*setChar*/, const coeffs cf )
    762772{
    763773  naTest(n);
     
    773783                   in this strong sense but rather computes the gcd of
    774784                   two given elements in the underlying polynomial ring. */
    775 number naGcd(number a, number b, const coeffs cf)
     785static number naGcd(number a, number b, const coeffs cf)
    776786{
    777787  if (a==NULL)  return naCopy(b,cf);
     
    821831}
    822832
    823 number naInvers(number a, const coeffs cf)
     833static number naInvers(number a, const coeffs cf)
    824834{
    825835  naTest(a);
     
    851861
    852862/* assumes that src = Q or Z, dst = Q(a) */
    853 number naMap00(number a, const coeffs src, const coeffs dst)
     863static number naMap00(number a, const coeffs src, const coeffs dst)
    854864{
    855865  if (n_IsZero(a, src)) return NULL;
     
    861871
    862872/* assumes that src = Z, dst = K(a) */
    863 number naMapZ0(number a, const coeffs src, const coeffs dst)
     873static number naMapZ0(number a, const coeffs src, const coeffs dst)
    864874{
    865875  if (n_IsZero(a, src)) return NULL;
     
    873883
    874884/* assumes that src = Z/p, dst = Q(a) */
    875 number naMapP0(number a, const coeffs src, const coeffs dst)
     885static number naMapP0(number a, const coeffs src, const coeffs dst)
    876886{
    877887  if (n_IsZero(a, src)) return NULL;
     
    887897/* assumes that either src = Q(a), dst = Q(a), or
    888898                       src = Z/p(a), dst = Z/p(a)     */
    889 number naCopyMap(number a, const coeffs src, const coeffs dst)
     899static number naCopyMap(number a, const coeffs src, const coeffs dst)
    890900{
    891901  return naCopy(a, dst);
     
    893903#endif
    894904
    895 number naCopyTrans2AlgExt(number a, const coeffs src, const coeffs dst)
     905static number naCopyTrans2AlgExt(number a, const coeffs src, const coeffs dst)
    896906{
    897907  assume (nCoeff_is_transExt (src));
     
    941951
    942952/* assumes that src = Q, dst = Z/p(a) */
    943 number naMap0P(number a, const coeffs src, const coeffs dst)
     953static number naMap0P(number a, const coeffs src, const coeffs dst)
    944954{
    945955  if (n_IsZero(a, src)) return NULL;
     
    954964
    955965/* assumes that src = Z/p, dst = Z/p(a) */
    956 number naMapPP(number a, const coeffs src, const coeffs dst)
     966static number naMapPP(number a, const coeffs src, const coeffs dst)
    957967{
    958968  if (n_IsZero(a, src)) return NULL;
     
    964974
    965975/* assumes that src = Z/u, dst = Z/p(a), where u != p */
    966 number naMapUP(number a, const coeffs src, const coeffs dst)
     976static number naMapUP(number a, const coeffs src, const coeffs dst)
    967977{
    968978  if (n_IsZero(a, src)) return NULL;
     
    975985}
    976986
    977 number naGenMap(number a, const coeffs cf, const coeffs dst)
     987static number naGenMap(number a, const coeffs cf, const coeffs dst)
    978988{
    979989  if (a==NULL) return NULL;
     
    9901000}
    9911001
    992 number naGenTrans2AlgExt(number a, const coeffs cf, const coeffs dst)
     1002static number naGenTrans2AlgExt(number a, const coeffs cf, const coeffs dst)
    9931003{
    9941004  if (a==NULL) return NULL;
     
    10711081}
    10721082
    1073 int naParDeg(number a, const coeffs cf)
     1083static int naParDeg(number a, const coeffs cf)
    10741084{
    10751085  if (a == NULL) return -1;
     
    10791089
    10801090/// return the specified parameter as a number in the given alg. field
    1081 number naParameter(const int iParameter, const coeffs cf)
     1091static number naParameter(const int iParameter, const coeffs cf)
    10821092{
    10831093  assume(getCoeffType(cf) == n_algExt);
     
    13101320
    13111321
    1312 void naClearDenominators(ICoeffsEnumerator& numberCollectionEnumerator, number& c, const coeffs cf)
     1322static void naClearDenominators(ICoeffsEnumerator& numberCollectionEnumerator, number& c, const coeffs cf)
    13131323{
    13141324  assume(cf != NULL);
     
    13261336}
    13271337
    1328 void naKillChar(coeffs cf)
     1338static void naKillChar(coeffs cf)
    13291339{
    13301340  rDecRefCnt(cf->extRing);
     
    13561366}
    13571367
    1358 number  naChineseRemainder(number *x, number *q,int rl, BOOLEAN /*sym*/,CFArray &inv_cache,const coeffs cf)
     1368static number  naChineseRemainder(number *x, number *q,int rl, BOOLEAN /*sym*/,CFArray &inv_cache,const coeffs cf)
    13591369{
    13601370  poly *P=(poly*)omAlloc(rl*sizeof(poly*));
     
    13681378}
    13691379
    1370 number  naFarey(number p, number n, const coeffs cf)
     1380static number  naFarey(number p, number n, const coeffs cf)
    13711381{
    13721382  // n is really a bigint
     
    14261436  cf->cfSub          = naSub;
    14271437  cf->cfMult         = naMult;
     1438  cf->cfInpMult      = naInpMult;
    14281439  cf->cfDiv          = naDiv;
    14291440  cf->cfExactDiv     = naDiv;
     
    14411452  cf->cfDelete       = naDelete;
    14421453  cf->cfSetMap       = naSetMap;
    1443   cf->cfGetDenom     = naGetDenom;
    1444   cf->cfGetNumerator = naGetNumerator;
    14451454  cf->cfRePart       = naCopy;
    14461455  cf->cfCoeffWrite   = naCoeffWrite;
     
    16681677  cf->cfInpNeg       = naNeg;
    16691678  cf->cfAdd          = naAdd;
     1679  cf->cfInpAdd       = naInpAdd;
    16701680  cf->cfSub          = naSub;
    16711681  cf->cfMult         = n2pMult;
     
    16841694  cf->cfDelete       = naDelete;
    16851695  cf->cfSetMap       = naSetMap;
    1686   cf->cfGetDenom     = naGetDenom;
    1687   cf->cfGetNumerator = naGetNumerator;
     1696  //cf->cfGetDenom     = naGetDenom; // use nd*
     1697  //cf->cfGetNumerator = naGetNumerator; // use nd*
    16881698  cf->cfRePart       = naCopy;
    16891699  cf->cfCoeffWrite   = n2pCoeffWrite;
Note: See TracChangeset for help on using the changeset viewer.