Changeset b12b7c in git


Ignore:
Timestamp:
Jun 16, 2010, 3:56:13 PM (13 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
Children:
a296bb8b3051f16b293d46d397aec1747775e971
Parents:
5dcc9a60fe5f6363361635bb231ee206f6a174b4
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2010-06-16 15:56:13+02:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 11:55:11+01:00
Message:
Inlines instead of macroses!
Location:
coeffs
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • coeffs/coeffs.h

    r5dcc9a6 rb12b7c  
    3838typedef mpz_ptr int_number;
    3939#endif
    40 
    41 //
    42 // the access macros:
    43 
    44 #define n_Copy(n, r)          (r)->cfCopy(n,r)
    45 #define n_Delete(n, r)        (r)->cfDelete(n,r)
    46 #define n_Mult(n1, n2, r)     (r)->cfMult(n1, n2,r)
    47 #define n_Add(n1, n2, r)      (r)->cfAdd(n1, n2,r)
    48 #define n_IsZero(n, r)        (r)->cfIsZero(n,r)
    49 #define n_Equal(n1, n2, r)    (r)->cfEqual(n1, n2,r)
    50 #define n_Neg(n, r)           (r)->cfNeg(n,r)
    51 #define n_Sub(n1, n2, r)      (r)->cfSub(n1, n2,r)
    52 #define n_GetChar(r)          nInternalChar(r)
    53 #define n_Init(i, r)          (r)->cfInit(i,r)
    54 #define n_IsOne(n, r)         (r)->cfIsOne(n,r)
    55 #define n_IsMOne(n, r)        (r)->cfIsMOne(n,r)
    56 #define n_GreaterZero(n, r)   (r)->cfGreaterZero(n,r)
    57 #define n_Write(n, r)         (r)->cfWrite(n,r)
    58 #define n_Normalize(n, r)     (r)->cfNormalize(n,r)
    59 #define n_Gcd(a, b, r)        (r)->cfGcd(a,b,r)
    60 #define n_IntDiv(a, b, r)     (r)->cfIntDiv(a,b,r)
    61 #define n_Div(a, b, r)        (r)->cfDiv(a,b,r)
    62 #define n_Invers(a, r)        (r)->cfInvers(a,r)
    63 #define n_ExactDiv(a, b, r)   (r)->cfExactDiv(a,b,r)
    64 // #define n_Test(a,r)           (r)->cfDBTest(a,r,__FILE__,__LINE__)
    65 #define n_InpMult(a, b, r)    (r)->cfInpMult(a,b,r)
    66 #define n_Power(a, b, res, r) (r)->cfPower(a,b,res,r)
    67 #define n_Size(n,r)           (r)->cfSize(n,r)
    68 #define n_GetDenom(N,r)       (r)->cfGetDenom((N),r)
    69 #define n_GetNumerator(N,r)   (r)->cfGetNumerator((N),r)
    7040
    7141// and the routines w.r.t. currRing:
     
    155125   /// convertion, 0 if impossible
    156126   int     (*cfInt)(number &n, const coeffs r);
     127
    157128#ifdef HAVE_RINGS
    158129   int     (*cfDivComp)(number a,number b,const coeffs r);
     
    161132   number  (*cfExtGcd)(number a, number b, number *s, number *t,const coeffs r);
    162133#endif
     134
    163135   /// changes argument  inline: a:= -a
    164136   number  (*cfNeg)(number a, const coeffs r);
     
    182154           (*cfIsMOne)(number a, const coeffs r),
    183155           (*cfGreaterZero)(number a, const coeffs r);
     156   
    184157   void    (*cfPower)(number a, int i, number * result, const coeffs r);
    185158   number  (*cfGetDenom)(number &n, const coeffs r);
     
    200173#ifdef LDEBUG
    201174   /// Test: is "a" a correct number?
    202    BOOLEAN (*cfDBTest)(number a, const char *f,const int l,const coeffs r);
     175   BOOLEAN (*cfDBTest)(number a, const char *f, const int l, const coeffs r);
    203176#endif
    204177
     
    252225#define n_New(n, r)           nNew(n)
    253226
    254 static inline BOOLEAN n_DBTest(number a, const char *filename, const int linenumber, const coeffs r)
     227
     228// the access methods:
     229
     230/// return a copy of a
     231static inline number n_Copy(number n,    const coeffs r){ return (r)->cfCopy(n, r); }
     232static inline void   n_Delete(number* p, const coeffs r){ return (r)->cfDelete(p, r); }
     233
     234static inline BOOLEAN n_AreEqual(number a, number b, const coeffs r){ return (r)->cfEqual(a, b, r); }
     235static inline BOOLEAN n_IsZero(number n, const coeffs r){ return (r)->cfIsZero(n,r); }
     236static inline BOOLEAN n_IsOne(number n,  const coeffs r){ return (r)->cfIsOne(n,r); }
     237static inline BOOLEAN n_IsMOne(number n, const coeffs r){ return (r)->cfIsMOne(n,r); }
     238static inline BOOLEAN n_IsGreaterZero(number n, const coeffs r){ return (r)->cfGreaterZero(n,r); }
     239// cfGreater?
     240
     241/// init with an integer
     242static inline number n_Init(int i,       const coeffs r){ return (r)->cfInit(i,r); }
     243
     244/// changes argument  inline: a:= -a
     245static inline number n_Neg(number n,     const coeffs r){ return (r)->cfNeg(n,r); }
     246
     247/// return 1/a
     248static inline number n_Invers(number a,  const coeffs r){ return (r)->cfInvers(a,r); }
     249
     250/// how complicated, (0) => 0, otherwise positive
     251static inline int    n_Size(number n,    const coeffs r){ return (r)->cfSize(n,r); }
     252
     253/// normalize the number. i.e. go to some canonnical representation (inplace)
     254static inline void   n_Normalize(number& n, const coeffs r){ return (r)->cfNormalize(n,r); }
     255
     256/// Normalize and Write
     257static inline void   n_Write(number& n,  const coeffs r){ return (r)->cfWrite(n,r); }
     258
     259/// Normalize and get denomerator
     260static inline number n_GetDenom(number& n, const coeffs r){ return (r)->cfGetDenom(n, r); }
     261
     262/// Normalize and get numerator
     263static inline number n_GetNumerator(number& n, const coeffs r){ return (r)->cfGetNumerator(n, r); }
     264
     265static inline void   n_Power(number a, int b, number *res, const coeffs r){ return (r)->cfPower(a,b,res,r); }
     266
     267
     268static inline number n_Mult(number a, number b, const coeffs r){ return (r)->cfMult(a, b, r); }
     269/// Inplace multiplication: a := a * b
     270static inline void n_InpMult(number &a, number b, const coeffs r){ return (r)->cfInpMult(a,b,r); }
     271
     272static inline number n_Sub(number a, number b, const coeffs r){ return (r)->cfSub(a, b, r); }
     273static inline number n_Add(number a, number b, const coeffs r){ return (r)->cfAdd(a, b, r); }
     274
     275static inline number n_Div(number a, number b, const coeffs r){ return (r)->cfDiv(a,b,r); }
     276static inline number n_IntDiv(number a, number b, const coeffs r){ return (r)->cfIntDiv(a,b,r); }
     277static inline number n_ExactDiv(number a, number b, const coeffs r){ return (r)->cfExactDiv(a,b,r); }
     278
     279static inline number n_Gcd(number a, number b, const coeffs r){ return (r)->cfGcd(a,b,r); }
     280
     281/// Tests whether n is a correct number.
     282static inline BOOLEAN n_DBTest(number n, const char *filename, const int linenumber, const coeffs r)
    255283{
    256284#ifdef LDEBUG
    257   return (r)->cfDBTest(a, filename, linenumber, r);
    258 //  return (r)->cfDBTest(a,r,filename,linenumber); // testing error message
     285  return (r)->cfDBTest(n, filename, linenumber, r);
    259286#else
    260287  return TRUE;
     
    264291#define n_Test(a,r)  n_DBTest(a, __FILE__, __LINE__, r)
    265292
    266 #endif
    267 
     293// Missing wrappers for:
     294// cfIntMod, cfPar, cfParDeg, cfInt, cfRePart, cfImPart, cfRead, cfLcm, cfSetMap, cfName, cfInit_bigint
     295// HAVE_RINGS: cfDivComp, cfIsUnit, cfGetUnit, cfExtGcd... cfDivBy
     296
     297
     298// Deprecated:
     299static inline BOOLEAN n_GreaterZero(number n, const coeffs r){ return n_IsGreaterZero(n,r); }
     300static inline BOOLEAN n_Equal(number a, number b, const coeffs r){ return n_AreEqual(a, b, r); }
     301
     302// Deprecated:
     303static inline int n_GetChar(const coeffs r){ return nInternalChar(r); }
     304
     305#endif
     306
  • coeffs/test.cc

    r5dcc9a6 rb12b7c  
    1919bool Test(const coeffs r)
    2020{
    21   number a = r->cfInit(666, r);
     21  number a = n_Init(666, r);
    2222  n_Test(a,r);
    2323 
    24   number b = r->cfAdd( a, a, r);
     24  number b = n_Add(a, a, r);
    2525  n_Test(b,r);
    2626 
    27   StringSetS("a: ");r->cfWrite( a, r );PrintS(StringAppend("\n"));
    28   StringSetS("b: "); r->cfWrite( b, r );PrintS(StringAppend("\n"));
     27  StringSetS("a: "); n_Write(a, r);PrintS(StringAppend("\n"));
     28  StringSetS("b: "); n_Write(b, r);PrintS(StringAppend("\n"));
    2929
    30   r->cfDelete( &a, r);
    31   r->cfDelete( &b, r);
     30  n_Delete(&a, r);
     31  n_Delete(&b, r);
    3232
    3333  return false;
Note: See TracChangeset for help on using the changeset viewer.