Changeset 13298a in git


Ignore:
Timestamp:
Nov 18, 2014, 4:49:36 PM (10 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'c7af8613769b29c741d6c338945669719f1fc4f8')
Children:
ca90c606ac5700642199c11e9336ebe0ffd08636
Parents:
c268ebdb845b116662ce209cd17398864b707404
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2014-11-18 16:49:36+01:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2014-11-19 19:12:42+01:00
Message:
Added STATISTIC() macro for counting operations with numbers

add: count cancellations (addition & subtraction)

NOTE: define HAVE_NUMSTAT if order to switch this on (or add -DHAVE_NUMSTAT to CPPFLAGS in configuretion time)
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • Singular/dyn_modules/syzextra/mod_main.cc

    rc268eb r13298a  
    263263    const ring r = currRing;
    264264
    265 #ifdef LDEBUG
    266     r->cf->cfDBTest(n,__FILE__,__LINE__,r->cf);
    267 #endif
     265    n_Test(n, r->cf);
    268266
    269267    StringSetS("");
  • libpolys/coeffs/Makefile.am

    rc268eb r13298a  
    2424libcoeffs_la_include_HEADERS = \
    2525  coeffs.h numbers.h si_gmp.h gnumpc.h gnumpfl.h longrat.h modulop.h ffields.h rintegers.h rmodulo2m.h rmodulon.h \
    26   shortfl.h mpr_complex.h mpr_global.h \
     26  shortfl.h mpr_complex.h mpr_global.h numstats.h \
    2727  bigintmat.h Enumerator.h AE.h OPAE.h AEp.h OPAEp.h AEQ.h OPAEQ.h
    2828
  • libpolys/coeffs/coeffs.h

    rc268eb r13298a  
    1717
    1818#include <coeffs/si_gmp.h>
    19 
    2019#include <coeffs/Enumerator.h>
     20#include <coeffs/numstats.h> // for STATISTIC(F) counting macro
    2121
    2222class CanonicalForm;
     
    268268   nMapFunc (*cfSetMap)(const coeffs src, const coeffs dst);
    269269
    270    /// io via ssi:
    271270   void    (*cfWriteFd)(number a, FILE *f, const coeffs r);
    272271   number  (*cfReadFd)( s_buff f, const coeffs r);
     
    416415#endif
    417416};
    418 //
     417
    419418// test properties and type
    420419/// Returns the type of coeffs domain
    421420static inline n_coeffType getCoeffType(const coeffs r)
    422 {
    423   assume(r != NULL);
    424   return r->type;
    425 }
     421{ assume(r != NULL); return r->type; }
    426422
    427423/// one-time initialisations for new coeffs
     
    430426
    431427/// "copy" coeffs, i.e. increment ref
    432 static inline coeffs nCopyCoeff(const coeffs cf) { cf->ref++; return cf;}
     428static inline coeffs nCopyCoeff(const coeffs r)
     429{ assume(r!=NULL); r->ref++; return r;}
    433430
    434431/// undo all initialisations
     
    437434/// initialisations after each ring change
    438435static inline void nSetChar(const coeffs r)
    439 {
    440   assume(r!=NULL); // r==NULL is an error
    441   assume(r->cfSetChar != NULL);
    442   r->cfSetChar(r);
    443 }
     436{ STATISTIC(nSetChar);  assume(r!=NULL); assume(r->cfSetChar != NULL); r->cfSetChar(r); }
    444437
    445438void           nNew(number * a);
     
    448441
    449442/// Return the characteristic of the coeff. domain.
    450 static inline int n_GetChar(const coeffs r)
    451 {
    452   assume(r != NULL);
    453   return r->ch;
    454 }
     443static inline int n_GetChar(const coeffs r)
     444{ STATISTIC(n_GetChar); assume(r != NULL); return r->ch; }
    455445
    456446
     
    458448
    459449/// return a copy of 'n'
    460 static inline number n_Copy(number n,    const coeffs r)
    461 {   assume(r != NULL); assume(r->cfCopy!=NULL); return r->cfCopy(n, r); }
     450static inline number n_Copy(number n,    const coeffs r) 
     451{ STATISTIC(n_Copy);   assume(r != NULL); assume(r->cfCopy!=NULL); return r->cfCopy(n, r); }
    462452
    463453/// delete 'p'
    464 static inline void   n_Delete(number* p, const coeffs r)
    465 {   assume(r != NULL); assume(r->cfDelete!= NULL); r->cfDelete(p, r); }
     454static inline void   n_Delete(number* p, const coeffs r) 
     455{ STATISTIC(n_Delete);   assume(r != NULL); assume(r->cfDelete!= NULL); r->cfDelete(p, r); }
    466456
    467457/// TRUE iff 'a' and 'b' represent the same number;
    468458/// they may have different representations
    469 static inline BOOLEAN n_Equal(number a, number b, const coeffs r)
    470 { assume(r != NULL); assume(r->cfEqual!=NULL); return r->cfEqual(a, b, r); }
     459static inline BOOLEAN n_Equal(number a, number b, const coeffs r) 
     460{ STATISTIC(n_Equal); assume(r != NULL); assume(r->cfEqual!=NULL); return r->cfEqual(a, b, r); }
    471461
    472462/// TRUE iff 'n' represents the zero element
    473 static inline BOOLEAN n_IsZero(number n, const coeffs r)
    474 { assume(r != NULL); assume(r->cfIsZero!=NULL); return r->cfIsZero(n,r); }
     463static inline BOOLEAN n_IsZero(number n, const coeffs r) 
     464{ STATISTIC(n_IsZero); assume(r != NULL); assume(r->cfIsZero!=NULL); return r->cfIsZero(n,r); }
    475465
    476466/// TRUE iff 'n' represents the one element
    477 static inline BOOLEAN n_IsOne(number n,  const coeffs r)
    478 { assume(r != NULL); assume(r->cfIsOne!=NULL); return r->cfIsOne(n,r); }
     467static inline BOOLEAN n_IsOne(number n,  const coeffs r) 
     468{ STATISTIC(n_IsOne); assume(r != NULL); assume(r->cfIsOne!=NULL); return r->cfIsOne(n,r); }
    479469
    480470/// TRUE iff 'n' represents the additive inverse of the one element, i.e. -1
    481 static inline BOOLEAN n_IsMOne(number n, const coeffs r)
    482 { assume(r != NULL); assume(r->cfIsMOne!=NULL); return r->cfIsMOne(n,r); }
     471static inline BOOLEAN n_IsMOne(number n, const coeffs r) 
     472{ STATISTIC(n_IsMOne); assume(r != NULL); assume(r->cfIsMOne!=NULL); return r->cfIsMOne(n,r); }
    483473
    484474/// ordered fields: TRUE iff 'n' is positive;
     
    501491///     start with -
    502492///
    503 static inline BOOLEAN n_GreaterZero(number n, const coeffs r)
    504 {
    505   assume(r != NULL); assume(r->cfGreaterZero!=NULL);
    506   return r->cfGreaterZero(n,r);
    507 }
     493static inline BOOLEAN n_GreaterZero(number n, const coeffs r)
     494{ STATISTIC(n_GreaterZero); assume(r != NULL); assume(r->cfGreaterZero!=NULL); return r->cfGreaterZero(n,r); }
    508495
    509496/// ordered fields: TRUE iff 'a' is larger than 'b';
     
    521508/// !!! Recommendation: remove implementations for unordered fields
    522509/// !!!                 and raise errors instead, in these cases
    523 static inline BOOLEAN n_Greater(number a, number b, const coeffs r)
    524 { assume(r != NULL); assume(r->cfGreater!=NULL); return r->cfGreater(a,b,r); }
     510static inline BOOLEAN n_Greater(number a, number b, const coeffs r) 
     511{ STATISTIC(n_Greater); assume(r != NULL); assume(r->cfGreater!=NULL); return r->cfGreater(a,b,r); }
    525512
    526513#ifdef HAVE_RINGS
    527 static inline int n_DivComp(number a, number b, const coeffs r)
    528 { assume(r != NULL); assume(r->cfDivComp!=NULL); return r->cfDivComp (a,b,r); }
     514static inline int n_DivComp(number a, number b, const coeffs r) 
     515{ STATISTIC(n_DivComp); assume(r != NULL); assume(r->cfDivComp!=NULL); return r->cfDivComp (a,b,r); }
    529516
    530517/// TRUE iff n has a multiplicative inverse in the given coeff field/ring r
    531 static inline BOOLEAN n_IsUnit(number n, const coeffs r)
    532 { assume(r != NULL); assume(r->cfIsUnit!=NULL); return r->cfIsUnit(n,r); }
     518static inline BOOLEAN n_IsUnit(number n, const coeffs r) 
     519{ STATISTIC(n_IsUnit); assume(r != NULL); assume(r->cfIsUnit!=NULL); return r->cfIsUnit(n,r); }
    533520
    534521/// in Z: 1
     
    539526// CF: shold imply that n/GetUnit(n) is normalized in Z/kZ
    540527//   it would make more sense to return the inverse...
    541 static inline number n_GetUnit(number n, const coeffs r)
    542 { assume(r != NULL); assume(r->cfGetUnit!=NULL); return r->cfGetUnit(n,r); }
    543 
    544 static inline coeffs n_CoeffRingQuot1(number c, const coeffs r)
    545 { assume(r != NULL); assume(r->cfQuot1 != NULL); return r->cfQuot1(c, r); }
     528static inline number n_GetUnit(number n, const coeffs r) 
     529{ STATISTIC(n_GetUnit); assume(r != NULL); assume(r->cfGetUnit!=NULL); return r->cfGetUnit(n,r); }
     530
     531static inline coeffs n_CoeffRingQuot1(number c, const coeffs r) 
     532{ STATISTIC(n_CoeffRingQuot1); assume(r != NULL); assume(r->cfQuot1 != NULL); return r->cfQuot1(c, r); }
    546533#endif
    547534
    548535/// a number representing i in the given coeff field/ring r
    549 static inline number n_Init(long i,       const coeffs r)
    550 { assume(r != NULL); assume(r->cfInit!=NULL); return r->cfInit(i,r); }
     536static inline number n_Init(long i,       const coeffs r) 
     537{ STATISTIC(n_Init); assume(r != NULL); assume(r->cfInit!=NULL); return r->cfInit(i,r); }
    551538
    552539/// conversion of a GMP integer to number
    553 static inline number n_InitMPZ(mpz_t n,     const coeffs r)
    554 { assume(r != NULL); assume(r->cfInitMPZ != NULL); return r->cfInitMPZ(n,r); }
     540static inline number n_InitMPZ(mpz_t n,     const coeffs r) 
     541{ STATISTIC(n_InitMPZ); assume(r != NULL); assume(r->cfInitMPZ != NULL); return r->cfInitMPZ(n,r); }
    555542
    556543/// conversion of n to an int; 0 if not possible
    557544/// in Z/pZ: the representing int lying in (-p/2 .. p/2]
    558 static inline int n_Int(number &n,       const coeffs r)
    559 { assume(r != NULL); assume(r->cfInt!=NULL); return r->cfInt(n,r); }
     545static inline int n_Int(number &n,       const coeffs r) 
     546{ STATISTIC(n_Int); assume(r != NULL); assume(r->cfInt!=NULL); return r->cfInt(n,r); }
    560547
    561548/// conversion of n to a GMP integer; 0 if not possible
    562 static inline void n_MPZ(mpz_t result, number &n,       const coeffs r)
    563 { assume(r != NULL); assume(r->cfMPZ!=NULL); r->cfMPZ(result, n, r); }
     549static inline void n_MPZ(mpz_t result, number &n,       const coeffs r) 
     550{ STATISTIC(n_MPZ); assume(r != NULL); assume(r->cfMPZ!=NULL); r->cfMPZ(result, n, r); }
    564551
    565552
    566553/// in-place negation of n
    567554/// MUST BE USED: n = n_InpNeg(n) (no copy is returned)
    568 static inline number n_InpNeg(number n,     const coeffs r)
    569 { assume(r != NULL); assume(r->cfInpNeg!=NULL); return r->cfInpNeg(n,r); }
     555static inline number n_InpNeg(number n,     const coeffs r) 
     556{ STATISTIC(n_InpNeg); assume(r != NULL); assume(r->cfInpNeg!=NULL); return r->cfInpNeg(n,r); }
    570557
    571558/// return the multiplicative inverse of 'a';
     
    573560///
    574561/// !!! Recommendation: rename to 'n_Inverse'
    575 static inline number n_Invers(number a,  const coeffs r)
    576 { assume(r != NULL); assume(r->cfInvers!=NULL); return r->cfInvers(a,r); }
     562static inline number n_Invers(number a,  const coeffs r) 
     563{ STATISTIC(n_Invers); assume(r != NULL); assume(r->cfInvers!=NULL); return r->cfInvers(a,r); }
    577564
    578565/// return a non-negative measure for the complexity of n;
    579566/// return 0 only when n represents zero;
    580567/// (used for pivot strategies in matrix computations with entries from r)
    581 static inline int    n_Size(number n,    const coeffs r)
    582 { assume(r != NULL); assume(r->cfSize!=NULL); return r->cfSize(n,r); }
     568static inline int    n_Size(number n,    const coeffs r) 
     569{ STATISTIC(n_Size); assume(r != NULL); assume(r->cfSize!=NULL); return r->cfSize(n,r); }
    583570
    584571/// inplace-normalization of n;
     
    587574/// !!! Recommendation: remove this method from the user-interface, i.e.,
    588575/// !!!                 this should be hidden
    589 static inline void   n_Normalize(number& n, const coeffs r)
    590 { assume(r != NULL); assume(r->cfNormalize!=NULL); r->cfNormalize(n,r); }
     576static inline void   n_Normalize(number& n, const coeffs r) 
     577{ STATISTIC(n_Normalize); assume(r != NULL); assume(r->cfNormalize!=NULL); r->cfNormalize(n,r); }
    591578
    592579/// write to the output buffer of the currently used reporter
    593580//CF: the "&" should be removed, as one wants to write constants as well
    594 static inline void   n_WriteLong(number& n,  const coeffs r)
    595 { assume(r != NULL); assume(r->cfWriteLong!=NULL); r->cfWriteLong(n,r); }
     581static inline void   n_WriteLong(number& n,  const coeffs r) 
     582{ STATISTIC(n_WriteLong); assume(r != NULL); assume(r->cfWriteLong!=NULL); r->cfWriteLong(n,r); }
    596583
    597584/// write to the output buffer of the currently used reporter
    598585/// in a shortest possible way, e.g. in K(a): a2 instead of a^2
    599 static inline void   n_WriteShort(number& n,  const coeffs r)
    600 { assume(r != NULL); assume(r->cfWriteShort!=NULL); r->cfWriteShort(n,r); }
    601 
    602 static inline void   n_Write(number& n,  const coeffs r, const BOOLEAN bShortOut = TRUE)
    603 { if (bShortOut) n_WriteShort(n, r); else n_WriteLong(n, r); }
     586static inline void   n_WriteShort(number& n,  const coeffs r) 
     587{ STATISTIC(n_WriteShort); assume(r != NULL); assume(r->cfWriteShort!=NULL); r->cfWriteShort(n,r); }
     588
     589static inline void   n_Write(number& n,  const coeffs r, const BOOLEAN bShortOut = TRUE) 
     590{ STATISTIC(n_Write); if (bShortOut) n_WriteShort(n, r); else n_WriteLong(n, r); }
    604591
    605592
     
    607594/// !!!                 interface. As defined here, it is merely a helper
    608595/// !!!                 method for parsing number input strings.
    609 static inline const char *n_Read(const char * s, number * a, const coeffs r)
    610 { assume(r != NULL); assume(r->cfRead!=NULL); return r->cfRead(s, a, r); }
     596static inline const char *n_Read(const char * s, number * a, const coeffs r) 
     597{ STATISTIC(n_Read); assume(r != NULL); assume(r->cfRead!=NULL); return r->cfRead(s, a, r); }
    611598
    612599/// return the denominator of n
    613600/// (if elements of r are by nature not fractional, result is 1)
    614 static inline number n_GetDenom(number& n, const coeffs r)
    615 { assume(r != NULL); assume(r->cfGetDenom!=NULL); return r->cfGetDenom(n, r); }
     601static inline number n_GetDenom(number& n, const coeffs r) 
     602{ STATISTIC(n_GetDenom); assume(r != NULL); assume(r->cfGetDenom!=NULL); return r->cfGetDenom(n, r); }
    616603
    617604/// return the numerator of n
    618605/// (if elements of r are by nature not fractional, result is n)
    619 static inline number n_GetNumerator(number& n, const coeffs r)
    620 { assume(r != NULL); assume(r->cfGetNumerator!=NULL); return r->cfGetNumerator(n, r); }
    621 
    622 /// fill res with the power a^b
    623 static inline void   n_Power(number a, int b, number *res, const coeffs r)
    624 { assume(r != NULL); assume(r->cfPower!=NULL); r->cfPower(a,b,res,r); }
    625 
    626 /// return the product of 'a' and 'b', i.e., a*b
    627 static inline number n_Mult(number a, number b, const coeffs r)
    628 { assume(r != NULL); assume(r->cfMult!=NULL); return r->cfMult(a, b, r); }
    629 
    630 /// multiplication of 'a' and 'b';
    631 /// replacement of 'a' by the product a*b
    632 static inline void n_InpMult(number &a, number b, const coeffs r)
    633 { assume(r != NULL); assume(r->cfInpMult!=NULL); r->cfInpMult(a,b,r); }
    634 
    635 /// addition of 'a' and 'b';
    636 /// replacement of 'a' by the sum a+b
    637 static inline void n_InpAdd(number &a, number b, const coeffs r)
    638 { assume(r != NULL); assume(r->cfInpAdd!=NULL); r->cfInpAdd(a,b,r); }
    639 
    640 /// return the difference of 'a' and 'b', i.e., a-b
    641 static inline number n_Sub(number a, number b, const coeffs r)
    642 { assume(r != NULL); assume(r->cfSub!=NULL); return r->cfSub(a, b, r); }
    643 
    644 /// return the sum of 'a' and 'b', i.e., a+b
    645 static inline number n_Add(number a, number b, const coeffs r)
    646 { assume(r != NULL); assume(r->cfAdd!=NULL); return r->cfAdd(a, b, r); }
     606static inline number n_GetNumerator(number& n, const coeffs r)
     607{ STATISTIC(n_GetNumerator); assume(r != NULL); assume(r->cfGetNumerator!=NULL); return r->cfGetNumerator(n, r); }
    647608
    648609/// return the quotient of 'a' and 'b', i.e., a/b;
    649610/// raise an error if 'b' is not invertible in r
    650 static inline number n_Div(number a, number b, const coeffs r)
    651 { assume(r != NULL); assume(r->cfDiv!=NULL); return r->cfDiv(a,b,r); }
    652 
    653 /// for r a field, return n_Init(0,r)
    654 /// otherwise: n_Div(a,b,r)*b+n_IntMod(a,b,r)==a
    655 static inline number n_IntMod(number a, number b, const coeffs r)
    656 { assume(r != NULL); return r->cfIntMod(a,b,r); }
     611static inline number n_Div(number a, number b, const coeffs r)
     612{ STATISTIC(n_Div); assume(r != NULL); assume(r->cfDiv!=NULL); return r->cfDiv(a,b,r); }
    657613
    658614/// assume that there is a canonical subring in cf and we know
     
    660616/// n_ExactDiv performs it, may skip additional tests.
    661617/// Can always be substituted by n_Div at the cost of larger  computing time.
    662 static inline number n_ExactDiv(number a, number b, const coeffs r)
    663 { assume(r != NULL); assume(r->cfExactDiv!=NULL); return r->cfExactDiv(a,b,r); }
     618static inline number n_ExactDiv(number a, number b, const coeffs r)
     619{ STATISTIC(n_ExactDiv); assume(r != NULL); assume(r->cfExactDiv!=NULL); return r->cfExactDiv(a,b,r); }
     620
     621/// for r a field, return n_Init(0,r)
     622/// otherwise: n_Div(a,b,r)*b+n_IntMod(a,b,r)==a
     623static inline number n_IntMod(number a, number b, const coeffs r)
     624{ STATISTIC(n_IntMod); assume(r != NULL); return r->cfIntMod(a,b,r); }
     625
     626/// fill res with the power a^b
     627static inline void   n_Power(number a, int b, number *res, const coeffs r)
     628{ STATISTIC(n_Power); assume(r != NULL); assume(r->cfPower!=NULL); r->cfPower(a,b,res,r); }
     629
     630/// return the product of 'a' and 'b', i.e., a*b
     631static inline number n_Mult(number a, number b, const coeffs r)
     632{ STATISTIC(n_Mult); assume(r != NULL); assume(r->cfMult!=NULL); return r->cfMult(a, b, r); }
     633
     634/// multiplication of 'a' and 'b';
     635/// replacement of 'a' by the product a*b
     636static inline void n_InpMult(number &a, number b, const coeffs r)
     637{ STATISTIC(n_InpMult); assume(r != NULL); assume(r->cfInpMult!=NULL); r->cfInpMult(a,b,r); }
     638
     639/// addition of 'a' and 'b';
     640/// replacement of 'a' by the sum a+b
     641static inline void n_InpAdd(number &a, number b, const coeffs r)
     642{ STATISTIC(n_InpAdd); assume(r != NULL); assume(r->cfInpAdd!=NULL); r->cfInpAdd(a,b,r);
     643
     644#ifdef HAVE_NUMSTATS
     645  // avoid double counting
     646  if( r->cfIsZero(a,r) ) STATISTIC(n_CancelOut);
     647#endif
     648}
     649
     650/// return the sum of 'a' and 'b', i.e., a+b
     651static inline number n_Add(number a, number b, const coeffs r)
     652{ STATISTIC(n_Add); assume(r != NULL); assume(r->cfAdd!=NULL); const number sum = r->cfAdd(a, b, r);
     653   
     654#ifdef HAVE_NUMSTATS
     655  // avoid double counting
     656  if( r->cfIsZero(sum,r) ) STATISTIC(n_CancelOut);
     657#endif
     658   
     659 return sum;
     660}
     661
     662
     663/// return the difference of 'a' and 'b', i.e., a-b
     664static inline number n_Sub(number a, number b, const coeffs r)
     665{ STATISTIC(n_Sub); assume(r != NULL); assume(r->cfSub!=NULL); const number d = r->cfSub(a, b, r);
     666
     667#ifdef HAVE_NUMSTATS
     668  // avoid double counting
     669  if( r->cfIsZero(d,r) ) STATISTIC(n_CancelOut);
     670#endif
     671
     672  return d;
     673}
    664674
    665675/// in Z: return the gcd of 'a' and 'b'
     
    669679/// in K(a)/<p(a)>: not implemented
    670680/// in K(t_1, ..., t_n): not implemented
    671 static inline number n_Gcd(number a, number b, const coeffs r)
    672 { assume(r != NULL); assume(r->cfGcd!=NULL); return r->cfGcd(a,b,r); }
    673 static inline number n_SubringGcd(number a, number b, const coeffs r)
    674 { assume(r != NULL); assume(r->cfSubringGcd!=NULL); return r->cfSubringGcd(a,b,r); }
     681static inline number n_Gcd(number a, number b, const coeffs r) 
     682{ STATISTIC(n_Gcd); assume(r != NULL); assume(r->cfGcd!=NULL); return r->cfGcd(a,b,r); }
     683static inline number n_SubringGcd(number a, number b, const coeffs r) 
     684{ STATISTIC(n_SubringGcd); assume(r != NULL); assume(r->cfSubringGcd!=NULL); return r->cfSubringGcd(a,b,r); }
    675685
    676686/// beware that ExtGCD is only relevant for a few chosen coeff. domains
    677687/// and may perform something unexpected in some cases...
    678 static inline number n_ExtGcd(number a, number b, number *s, number *t, const coeffs r)
    679 { assume(r != NULL); assume(r->cfExtGcd!=NULL); return r->cfExtGcd (a,b,s,t,r); }
    680 static inline number n_XExtGcd(number a, number b, number *s, number *t, number *u, number *v, const coeffs r)
    681 { assume(r != NULL); assume(r->cfXExtGcd!=NULL); return r->cfXExtGcd (a,b,s,t,u,v,r); }
    682 static inline number  n_EucNorm(number a, const coeffs r)
    683 { assume(r != NULL); assume(r->cfEucNorm!=NULL); return r->cfEucNorm (a,r); }
     688static inline number n_ExtGcd(number a, number b, number *s, number *t, const coeffs r) 
     689{ STATISTIC(n_ExtGcd); assume(r != NULL); assume(r->cfExtGcd!=NULL); return r->cfExtGcd (a,b,s,t,r); }
     690static inline number n_XExtGcd(number a, number b, number *s, number *t, number *u, number *v, const coeffs r) 
     691{ STATISTIC(n_XExtGcd); assume(r != NULL); assume(r->cfXExtGcd!=NULL); return r->cfXExtGcd (a,b,s,t,u,v,r); }
     692static inline number  n_EucNorm(number a, const coeffs r) 
     693{ STATISTIC(n_EucNorm); assume(r != NULL); assume(r->cfEucNorm!=NULL); return r->cfEucNorm (a,r); }
    684694/// if r is a ring with zero divisors, return an annihilator!=0 of b
    685695/// otherwise return NULL
    686 static inline number  n_Ann(number a, const coeffs r)
    687 { assume(r != NULL); return r->cfAnn (a,r); }
    688 static inline number  n_QuotRem(number a, number b, number *q, const coeffs r)
    689 { assume(r != NULL); assume(r->cfQuotRem!=NULL); return r->cfQuotRem (a,b,q,r); }
     696static inline number  n_Ann(number a, const coeffs r) 
     697{ STATISTIC(n_Ann); assume(r != NULL); return r->cfAnn (a,r); }
     698static inline number  n_QuotRem(number a, number b, number *q, const coeffs r) 
     699{ STATISTIC(n_QuotRem); assume(r != NULL); assume(r->cfQuotRem!=NULL); return r->cfQuotRem (a,b,q,r); }
    690700
    691701
     
    695705/// in K(a)/<p(a)>: not implemented
    696706/// in K(t_1, ..., t_n): not implemented
    697 static inline number n_Lcm(number a, number b, const coeffs r)
    698 { assume(r != NULL); assume(r->cfLcm!=NULL); return r->cfLcm(a,b,r); }
     707static inline number n_Lcm(number a, number b, const coeffs r) 
     708{ STATISTIC(n_Lcm); assume(r != NULL); assume(r->cfLcm!=NULL); return r->cfLcm(a,b,r); }
    699709
    700710/// assume that r is a quotient field (otherwise, return 1)
    701711/// for arguments (a1/a2,b1/b2) return (lcm(a1,b2)/1)
    702 static inline number n_NormalizeHelper(number a, number b, const coeffs r)
    703 { assume(r != NULL); assume(r->cfNormalizeHelper!=NULL); return r->cfNormalizeHelper(a,b,r); }
     712static inline number n_NormalizeHelper(number a, number b, const coeffs r) 
     713{ STATISTIC(n_NormalizeHelper); assume(r != NULL); assume(r->cfNormalizeHelper!=NULL); return r->cfNormalizeHelper(a,b,r); }
    704714
    705715/// set the mapping function pointers for translating numbers from src to dst
    706 static inline nMapFunc n_SetMap(const coeffs src, const coeffs dst)
    707 { assume(src != NULL && dst != NULL); assume(dst->cfSetMap!=NULL); return dst->cfSetMap(src,dst); }
    708 
     716static inline nMapFunc n_SetMap(const coeffs src, const coeffs dst)
     717{ STATISTIC(n_SetMap); assume(src != NULL && dst != NULL); assume(dst->cfSetMap!=NULL); return dst->cfSetMap(src,dst); }
     718
     719#ifdef LDEBUG
    709720/// test whether n is a correct number;
    710721/// only used if LDEBUG is defined
    711 #ifdef LDEBUG
    712 static inline BOOLEAN n_DBTest(number n, const char *filename, const int linenumber, const coeffs r)
     722static inline BOOLEAN n_DBTest(number n, const char *filename, const int linenumber, const coeffs r)
     723{ STATISTIC(n_Test); assume(r != NULL); assume(r->cfDBTest != NULL); return r->cfDBTest(n, filename, linenumber, r); }
    713724#else
    714 static inline BOOLEAN n_DBTest(number, const char*, const int, const coeffs) // is it really necessary to define this function in any case?
     725// is it really necessary to define this function in any case?
     726/// test whether n is a correct number;
     727/// only used if LDEBUG is defined
     728static inline BOOLEAN n_DBTest(number, const char*, const int, const coeffs)
     729{ STATISTIC(n_Test);  return TRUE; }
    715730#endif
    716 {
    717 #ifndef LDEBUG
    718   return TRUE;
    719 #else
    720   assume(r != NULL); assume(r->cfDBTest != NULL);
    721   return r->cfDBTest(n, filename, linenumber, r);
    722 #endif
    723 }
    724731
    725732/// output the coeff description
    726 static inline void   n_CoeffWrite(const coeffs r, BOOLEAN details = TRUE)
    727 { assume(r != NULL); assume(r->cfCoeffWrite != NULL); r->cfCoeffWrite(r, details); }
     733static inline void   n_CoeffWrite(const coeffs r, BOOLEAN details = TRUE) 
     734{ STATISTIC(n_CoeffWrite); assume(r != NULL); assume(r->cfCoeffWrite != NULL); r->cfCoeffWrite(r, details); }
    728735
    729736// Tests:
     
    758765/// in Z/2^kZ: TRUE iff ((a = 0 mod 2^k) and (b = 0 or b is a power of 2))
    759766///                  or ((a, b <> 0) and (b/gcd(a, b) is odd))
    760 static inline BOOLEAN n_DivBy(number a, number b, const coeffs r)
    761 {
    762   assume(r != NULL);
     767static inline BOOLEAN n_DivBy(number a, number b, const coeffs r)
     768{ STATISTIC(n_DivBy); assume(r != NULL);
    763769#ifdef HAVE_RINGS
    764770  if( nCoeff_is_Ring(r) )
     
    770776}
    771777
    772 static inline number n_ChineseRemainderSym(number *a, number *b, int rl, BOOLEAN sym,const coeffs r)
    773 {
    774   assume(r != NULL); assume(r->cfChineseRemainder != NULL); return r->cfChineseRemainder(a,b,rl,sym,r);
    775 }
    776 
    777 static inline number n_Farey(number a, number b, const coeffs r)
    778 {
    779   assume(r != NULL); assume(r->cfFarey != NULL); return r->cfFarey(a,b,r);
    780 }
    781 
    782 static inline int n_ParDeg(number n, const coeffs r)
    783 {
    784   assume(r != NULL); assume(r->cfParDeg != NULL); return r->cfParDeg(n,r);
    785 }
     778static inline number n_ChineseRemainderSym(number *a, number *b, int rl, BOOLEAN sym,const coeffs r)
     779{ STATISTIC(n_ChineseRemainderSym); assume(r != NULL); assume(r->cfChineseRemainder != NULL); return r->cfChineseRemainder(a,b,rl,sym,r); }
     780
     781static inline number n_Farey(number a, number b, const coeffs r)
     782{ STATISTIC(n_Farey); assume(r != NULL); assume(r->cfFarey != NULL); return r->cfFarey(a,b,r); }
     783
     784static inline int n_ParDeg(number n, const coeffs r)
     785{ STATISTIC(n_ParDeg); assume(r != NULL); assume(r->cfParDeg != NULL); return r->cfParDeg(n,r); }
    786786
    787787/// Returns the number of parameters
    788 static inline int n_NumberOfParameters(const coeffs r){ return r->iNumberOfParameters; }
     788static inline int n_NumberOfParameters(const coeffs r)
     789{ STATISTIC(n_NumberOfParameters); assume(r != NULL); return r->iNumberOfParameters; }
    789790
    790791/// Returns a (const!) pointer to (const char*) names of parameters
    791 static inline char const * * n_ParameterNames(const coeffs r){ return r->pParameterNames; }
    792 
     792static inline char const * * n_ParameterNames(const coeffs r) 
     793{ STATISTIC(n_ParameterNames); assume(r != NULL); return r->pParameterNames; }
    793794
    794795/// return the (iParameter^th) parameter as a NEW number
    795796/// NOTE: parameter numbering: 1..n_NumberOfParameters(...)
    796 static inline number n_Param(const int iParameter, const coeffs r)
    797 {
    798   assume(r != NULL);
     797static inline number n_Param(const int iParameter, const coeffs r)
     798{ assume(r != NULL);
    799799  assume((iParameter >= 1) || (iParameter <= n_NumberOfParameters(r)));
    800800  assume(r->cfParameter != NULL);
    801   return r->cfParameter(iParameter, r);
     801  STATISTIC(n_Param); return r->cfParameter(iParameter, r);
    802802}
    803803
    804 static inline number  n_RePart(number i, const coeffs cf)
    805 {
    806   assume(cf != NULL); assume(cf->cfRePart!=NULL);
    807   return cf->cfRePart(i,cf);
    808 }
    809 static inline number  n_ImPart(number i, const coeffs cf)
    810 {
    811   assume(cf != NULL); assume(cf->cfImPart!=NULL);
    812   return cf->cfImPart(i,cf);
    813 }
     804static inline number  n_RePart(number i, const coeffs cf)
     805{ STATISTIC(n_RePart); assume(cf != NULL); assume(cf->cfRePart!=NULL); return cf->cfRePart(i,cf); }
     806
     807static inline number  n_ImPart(number i, const coeffs cf)
     808{ STATISTIC(n_ImPart); assume(cf != NULL); assume(cf->cfImPart!=NULL); return cf->cfImPart(i,cf); }
    814809
    815810/// returns TRUE, if r is not a field and r has non-trivial units
     
    928923/// NOTE/TODO: see also the description by Hans
    929924/// TODO: rename into n_ClearIntegerContent
    930 static inline void n_ClearContent(ICoeffsEnumerator& numberCollectionEnumerator, number& c, const coeffs r)
    931 {
    932   assume(r != NULL);
    933   r->cfClearContent(numberCollectionEnumerator, c, r);
    934 }
     925static inline void n_ClearContent(ICoeffsEnumerator& numberCollectionEnumerator, number& c, const coeffs r)
     926{ STATISTIC(n_ClearContent); assume(r != NULL); r->cfClearContent(numberCollectionEnumerator, c, r); }
    935927
    936928/// (inplace) Clears denominators on a collection of numbers
     
    938930/// with which all the number coeffs. were multiplied)
    939931/// NOTE/TODO: see also the description by Hans
    940 static inline void n_ClearDenominators(ICoeffsEnumerator& numberCollectionEnumerator, number& d, const coeffs r)
    941 {
    942   assume(r != NULL);
    943   r->cfClearDenominators(numberCollectionEnumerator, d, r);
    944 }
     932static inline void n_ClearDenominators(ICoeffsEnumerator& numberCollectionEnumerator, number& d, const coeffs r)
     933{ STATISTIC(n_ClearDenominators); assume(r != NULL); r->cfClearDenominators(numberCollectionEnumerator, d, r); }
    945934
    946935// convenience helpers (no number returned - but the input enumeration
     
    950939// *p_Content) and p_Cleardenom_n (which doesn't)!!!
    951940
    952 static inline void n_ClearContent(ICoeffsEnumerator& numberCollectionEnumerator, const coeffs r)
    953 {
    954   number c;
    955   n_ClearContent(numberCollectionEnumerator, c, r);
    956   n_Delete(&c, r);
    957 }
    958 
    959 static inline void n_ClearDenominators(ICoeffsEnumerator& numberCollectionEnumerator, const coeffs r)
    960 {
    961   assume(r != NULL);
    962   number d;
    963   n_ClearDenominators(numberCollectionEnumerator, d, r);
    964   n_Delete(&d, r);
    965 }
     941static inline void n_ClearContent(ICoeffsEnumerator& numberCollectionEnumerator, const coeffs r)
     942{ STATISTIC(n_ClearContent); number c; n_ClearContent(numberCollectionEnumerator, c, r); n_Delete(&c, r); }
     943
     944static inline void n_ClearDenominators(ICoeffsEnumerator& numberCollectionEnumerator, const coeffs r)
     945{ STATISTIC(n_ClearDenominators); assume(r != NULL); number d; n_ClearDenominators(numberCollectionEnumerator, d, r); n_Delete(&d, r); }
    966946
    967947
     
    970950void   n_Print(number& a,  const coeffs r);
    971951
     952
     953
     954/// TODO: make it a virtual method of coeffs, together with:
     955/// Decompose & Compose, rParameter & rPar
     956static inline char * nCoeffString(const coeffs cf)
     957{ STATISTIC(nCoeffString); assume( cf != NULL ); return cf->cfCoeffString(cf); }
     958
     959
     960static inline char * nCoeffName (const coeffs cf)
     961{ STATISTIC(nCoeffName); assume( cf != NULL ); return cf->cfCoeffName(cf); }
     962
     963static inline number n_Random(siRandProc p, number p1, number p2, const coeffs cf)
     964{ STATISTIC(n_Random); assume( cf != NULL ); assume( cf->cfRandom != NULL );  return cf->cfRandom(p, p1, p2, cf); }
     965
     966/// io via ssi:
     967static inline void n_WriteFd(number a, FILE *f, const coeffs r)
     968{ STATISTIC(n_WriteFd); assume(r != NULL); assume(r->cfWriteFd != NULL); return r->cfWriteFd(a, f, r); }
     969
     970/// io via ssi:
     971static inline number n_ReadFd( s_buff f, const coeffs r)
     972{ STATISTIC(n_ReadFd); assume(r != NULL); assume(r->cfReadFd != NULL); return r->cfReadFd(f, r); }
     973
     974
     975number n_convFactoryNSingN( const CanonicalForm n, const coeffs r);
     976
     977CanonicalForm n_convSingNFactoryN( number n, BOOLEAN setChar, const coeffs r );
     978
    972979#endif
    973980
  • libpolys/coeffs/numbers.cc

    rc268eb r13298a  
    1010#include <stdlib.h>
    1111
    12 
    13 
    14 
    1512#include <misc/auxiliary.h>
    16 
     13#include <omalloc/omalloc.h>
    1714#include <factory/factory.h>
    1815
    19 #include "coeffs.h"
     16#include <reporter/reporter.h>
     17
     18#include <coeffs/coeffs.h>
    2019#include <coeffs/numbers.h>
    2120
    22 #include <reporter/reporter.h>
    23 #include <omalloc/omalloc.h>
    2421#include <coeffs/numbers.h>
    2522#include <coeffs/longrat.h>
     
    4138#endif
    4239
     40
     41#ifdef HAVE_NUMSTATS
     42struct SNumberStatistic number_stats;
     43#endif /* HAVE_NUMSTATS */
    4344
    4445
     
    486487void nKillChar(coeffs r)
    487488{
     489  STATISTIC(nKillChar);
    488490  if (r!=NULL)
    489491  {
     
    553555   { char* s = StringEndS(); Print("%s", s); omFree(s); }
    554556}
     557
     558
     559number n_convFactoryNSingN( const CanonicalForm n, const coeffs r)
     560{ STATISTIC(n_convFactoryNSingN); assume(r != NULL); assume(r->convFactoryNSingN != NULL); return r->convFactoryNSingN(n, r); }
     561
     562
     563
     564CanonicalForm n_convSingNFactoryN( number n, BOOLEAN setChar, const coeffs r )
     565{ STATISTIC(n_convSingNFactoryN); assume(r != NULL); assume(r->convSingNFactoryN != NULL); return r->convSingNFactoryN(n, setChar, r); }
  • libpolys/misc/auxiliary.h.in

    rc268eb r13298a  
    6262#endif
    6363
     64
     65#ifndef HAVE_NUMSTATS
     66// #define HAVE_NUMSTATS
     67#undef HAVE_NUMSTATS
     68#endif
    6469// ----------------  end of parts/extensions
    6570
  • libpolys/polys/pDebug.cc

    rc268eb r13298a  
    249249    // number/coef check
    250250    _pPolyAssumeReturnMsg(p->coef != NULL || (n_GetChar(r->cf) >= 2), "NULL coef",p,r);
     251
    251252    #ifdef LDEBUG
    252     _pPolyAssumeReturnMsg(r->cf->cfDBTest(p->coef,__FILE__,__LINE__,r->cf),"coeff err",p,r);
     253    _pPolyAssumeReturnMsg(n_Test(p->coef,r->cf),"coeff err",p,r);
    253254    #endif
    254255    _pPolyAssumeReturnMsg(!n_IsZero(p->coef, r->cf), "Zero coef",p,r);
  • libpolys/polys/templates/p_Numbers.h

    rc268eb r13298a  
    1616
    1717static inline number n_Copy_FieldGeneral(number n,    const ring r)
    18 { return r->cf->cfCopy(n,r->cf); }
     18{ return n_Copy(n,r->cf); }
    1919
    2020static inline void   n_Delete_FieldGeneral(number* p, const ring r)
    21 { r->cf->cfDelete(p,r->cf); }
     21{ n_Delete(p,r->cf); }
    2222
    2323static inline number n_Mult_FieldGeneral(number n1, number n2, const ring r)
    24 { return r->cf->cfMult(n1, n2, r->cf); }
     24{ return n_Mult(n1, n2, r->cf); }
    2525
    2626static inline number n_Add_FieldGeneral(number n1, number n2, const ring r)
    27 { return r->cf->cfAdd(n1, n2, r->cf); }
     27{ return n_Add(n1, n2, r->cf); }
    2828
    2929static inline BOOLEAN n_IsZero_FieldGeneral(number n, const ring r)
    30 { return r->cf->cfIsZero(n, r->cf); }
     30{ return n_IsZero(n, r->cf); }
    3131
    3232static inline BOOLEAN n_Equal_FieldGeneral(number n1, number n2, const ring r)
    33 { return r->cf->cfEqual(n1, n2, r->cf); }
     33{ return n_Equal(n1, n2, r->cf); }
    3434
    3535static inline number n_Neg_FieldGeneral(number n,     const ring r)
    36 { return r->cf->cfInpNeg(n, r->cf); }
     36{ return n_InpNeg(n, r->cf); }
    3737
    3838static inline number n_Sub_FieldGeneral(number n1, number n2, const ring r)
    39 { return r->cf->cfSub(n1, n2, r->cf); }
     39{ return n_Sub(n1, n2, r->cf); }
    4040
    4141static inline void n_InpMult_FieldGeneral(number &n1, number n2, const ring r)
    42 { ndInpMult(n1, n2, r->cf); }
     42{ n_InpMult(n1, n2, r->cf); }
    4343
    4444static inline void n_InpAdd_FieldGeneral(number &n1, number n2, const ring r)
     
    4646
    4747#ifdef HAVE_RINGS
    48 #define n_Copy_RingGeneral(n, r)           r->cf->cfCopy(n,r->cf)
    49 #define n_Delete_RingGeneral(n, r)         r->cf->cfDelete(n,r->cf)
    50 #define n_Mult_RingGeneral(n1, n2, r)      r->cf->cfMult(n1, n2, r->cf)
    51 #define n_Add_RingGeneral(n1, n2, r)       r->cf->cfAdd(n1, n2, r->cf)
    52 #define n_IsZero_RingGeneral(n, r)         r->cf->cfIsZero(n, r->cf)
    53 #define n_Equal_RingGeneral(n1, n2, r)     r->cf->cfEqual(n1, n2, r->cf)
    54 #define n_Neg_RingGeneral(n, r)            r->cf->cfInpNeg(n, r->cf)
    55 #define n_Sub_RingGeneral(n1, n2, r)       r->cf->cfSub(n1, n2, r->cf)
    56 //#define n_InpMult_RingGeneral(n1, n2, r)   r->cf->nInpMult(n1, n2, r->cf)
    57 #define n_InpMult_RingGeneral(n1, n2, r)   ndInpMult(n1, n2, r->cf)
     48#define n_Copy_RingGeneral(n, r)           n_Copy_FieldGeneral(n, r)
     49#define n_Delete_RingGeneral(n, r)         n_Delete_FieldGeneral(n, r)
     50#define n_Mult_RingGeneral(n1, n2, r)      n_Mult_FieldGeneral(n1, n2, r)
     51#define n_Add_RingGeneral(n1, n2, r)       n_Add_FieldGeneral(n1, n2, r)
     52#define n_IsZero_RingGeneral(n, r)         n_IsZero_FieldGeneral(n, r)
     53#define n_Equal_RingGeneral(n1, n2, r)     n_Equal_FieldGeneral(n1, n2, r)
     54#define n_Neg_RingGeneral(n, r)            n_Neg_FieldGeneral(n, r)
     55#define n_Sub_RingGeneral(n1, n2, r)       n_Sub_FieldGeneral(n1, n2, r)
     56//#define n_InpMult_RingGeneral(n1, n2, r)   n_InpMult_FieldGeneral(n1, n2, r)
     57#define n_InpMult_RingGeneral(n1, n2, r)   n_InpMult_FieldGeneral(n1, n2, r)
     58
    5859static inline void n_InpAdd_RingGeneral(number &n1, number n2, const ring r)
    59 { assume(rField_is_Ring(r)); n_InpAdd(n1, n2, r->cf); }
     60{  assume(rField_is_Ring(r)); n_InpAdd(n1, n2, r->cf); }
    6061#endif
    6162
    6263#include <coeffs/modulop.h>
     64
    6365#define n_Copy_FieldZp(n, r)        n
    6466#define n_Delete_FieldZp(n, r)      do {} while (0)
    65 #define n_Mult_FieldZp(n1, n2, r)   npMultM(n1,n2, r->cf)
    66 #define n_Add_FieldZp(n1, n2, r)    npAddM(n1, n2, r->cf)
    67 #define n_IsZero_FieldZp(n, r)      npIsZeroM(n, r->cf)
    68 #define n_Equal_FieldZp(n1, n2, r)  npEqualM(n1, n2, r->cf)
    69 #define n_Neg_FieldZp(n, r)         npNegM(n, r->cf)
    70 #define n_Sub_FieldZp(n1, n2, r)    npSubM(n1, n2, r->cf)
    71 #define n_InpMult_FieldZp(n1, n2, r) n1=npMultM(n1, n2, r->cf)
     67
     68static inline number n_Mult_FieldZp(number n1, number n2, const ring r)
     69{ STATISTIC(n_Mult); return npMultM(n1, n2, r->cf); }
     70
     71static inline number n_Add_FieldZp(number n1, number n2, const ring r)
     72{ STATISTIC(n_Add); const number sum = npAddM(n1, n2, r->cf);   
     73#ifdef HAVE_NUMSTATS
     74  // avoid double counting
     75  if( npIsZeroM(sum,r->cf) ) STATISTIC(n_CancelOut);
     76#endif
     77 return sum;
     78
     79}
     80
     81static inline number n_Sub_FieldZp(number n1, number n2, const ring r)
     82{ STATISTIC(n_Sub); const number d = npSubM(n1, n2, r->cf);   
     83#ifdef HAVE_NUMSTATS
     84  // avoid double counting
     85  if( npIsZeroM(d,r->cf) ) STATISTIC(n_CancelOut);
     86#endif 
     87  return d;
     88}
     89
     90static inline BOOLEAN n_IsZero_FieldZp(number n, const ring r)
     91{ STATISTIC(n_IsZero); return npIsZeroM(n, r->cf); }
     92
     93static inline BOOLEAN n_Equal_FieldZp(number n1, number n2, const ring r)
     94{ STATISTIC(n_Equal); return  npEqualM(n1, n2, r->cf); }
     95
     96static inline number n_Neg_FieldZp(number n,     const ring r)
     97{ STATISTIC(n_InpNeg); return npNegM(n, r->cf); }
     98
     99static inline void n_InpMult_FieldZp(number &n1, number n2, const ring r)
     100{ STATISTIC(n_InpMult); n1=npMultM(n1, n2, r->cf);  }
    72101
    73102static inline void n_InpAdd_FieldZp(number &n1, number n2, const ring r)
    74 { assume(rField_is_Zp(r)); n1=npAddM(n1, n2, r->cf); }
     103{
     104  STATISTIC(n_InpAdd); assume(rField_is_Zp(r)); n1=npAddM(n1, n2, r->cf);
     105
     106#ifdef HAVE_NUMSTATS
     107  // avoid double counting
     108  if( npIsZeroM(n1,r->cf) ) STATISTIC(n_CancelOut);
     109#endif
     110}
    75111
    76112#define DO_LINLINE
    77 #include <coeffs/longrat.cc> // TODO: fix this Uglyness?!!!
     113#include <coeffs/longrat.cc> // for inlining... TODO: fix this Uglyness?!!!
    78114
    79 #define n_Copy_FieldQ(n, r)        nlCopy(n, r->cf)
    80 #define n_Delete_FieldQ(n, r)      nlDelete(n,r->cf)
    81 #define n_Mult_FieldQ(n1, n2, r)   nlMult(n1,n2, r->cf)
    82 #define n_Add_FieldQ(n1, n2, r)    nlAdd(n1, n2, r->cf)
    83 #define n_IsZero_FieldQ(n, r)      nlIsZero(n, r->cf)
    84 #define n_Equal_FieldQ(n1, n2, r)  nlEqual(n1, n2, r->cf)
    85 #define n_Neg_FieldQ(n, r)         nlNeg(n, r->cf)
    86 #define n_Sub_FieldQ(n1, n2, r)    nlSub(n1, n2, r->cf)
    87 #define n_InpMult_FieldQ(n1, n2, r) nlInpMult(n1, n2, r->cf)
     115static inline number n_Copy_FieldQ(number n,    const ring r)
     116{ STATISTIC(n_Copy); return nlCopy(n, r->cf); }
     117
     118static inline void   n_Delete_FieldQ(number* n, const ring r)
     119{ STATISTIC(n_Delete); nlDelete(n,r->cf); }
     120
     121static inline number n_Mult_FieldQ(number n1, number n2, const ring r)
     122{ STATISTIC(n_Mult); return nlMult(n1,n2, r->cf); }
     123
     124static inline number n_Add_FieldQ(number n1, number n2, const ring r)
     125{ STATISTIC(n_Add); const number sum = nlAdd(n1, n2, r->cf);
     126
     127#ifdef HAVE_NUMSTATS
     128  // avoid double counting
     129  if( nlIsZero(sum,r->cf) ) STATISTIC(n_CancelOut);
     130#endif
     131
     132 return sum;
     133}
     134
     135static inline number n_Sub_FieldQ(number n1, number n2, const ring r)
     136{ STATISTIC(n_Sub); const number d = nlSub(n1, n2, r->cf);
     137
     138#ifdef HAVE_NUMSTATS
     139  // avoid double counting
     140  if( nlIsZero(d,r->cf) ) STATISTIC(n_CancelOut);
     141#endif
     142
     143  return d;
     144}
     145
     146static inline BOOLEAN n_IsZero_FieldQ(number n, const ring r)
     147{ STATISTIC(n_IsZero); return nlIsZero(n, r->cf); }
     148
     149static inline BOOLEAN n_Equal_FieldQ(number n1, number n2, const ring r)
     150{ STATISTIC(n_Equal); return  nlEqual(n1, n2, r->cf); }
     151
     152static inline number n_Neg_FieldQ(number n,     const ring r)
     153{ STATISTIC(n_InpNeg); return nlNeg(n, r->cf); }
     154
     155static inline void n_InpMult_FieldQ(number &n1, number n2, const ring r)
     156{ STATISTIC(n_InpMult); nlInpMult(n1, n2, r->cf); }
    88157
    89158static inline void n_InpAdd_FieldQ(number &n1, number n2, const ring r)
    90 { assume(rField_is_Q(r)); nlInpAdd(n1, n2, r->cf); }
     159{ STATISTIC(n_InpAdd); assume(rField_is_Q(r)); nlInpAdd(n1, n2, r->cf);
     160
     161#ifdef HAVE_NUMSTATS
     162  // avoid double counting
     163  if( nlIsZero(n1,r->cf) ) STATISTIC(n_CancelOut);
    91164#endif
     165}
     166
     167#endif
Note: See TracChangeset for help on using the changeset viewer.