Changeset 17e473 in git for libpolys/coeffs/coeffs.h


Ignore:
Timestamp:
Apr 20, 2011, 9:43:24 PM (13 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
03bf555de3ab718b020a7fd0a086b5c2e493dbd0
Parents:
1ddd044275ba5d4433a597ff9edee1abfce81a0e
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2011-04-20 21:43:24+02:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:31:23+01:00
Message:
FIX: we can link against libpolys
FIX: rField_*(r...) all should call corresponding nCoeff_*(r->cf...)
ADD: first tests of polynomial rings

TODO for Frank: change ring.* wrt ring-related variables (moved to coeffs &&& renamed!)
TODO: poly. algs. over rings are UNusable at the moment
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/coeffs.h

    r1ddd04 r17e473  
    207207static inline n_coeffType getCoeffType(const coeffs r)
    208208{
     209  assume(r != NULL);
    209210  return r->type;
    210211}
    211212
    212 /// returns true for coeffs being a domain
    213 static inline bool nField_is_Domain(const coeffs r)
    214 {
    215 #ifdef HAVE_RINGS
    216   return (r->ringtype == 4 || r->ringtype == 0);
    217 #else
    218   return true;
    219 #endif
    220 }
    221 
    222 
    223213static inline int nInternalChar(const coeffs r)
    224214{
     215  assume(r != NULL);
    225216  return r->ch;
    226217}
     
    248239/// return a copy of a
    249240static inline number n_Copy(number n,    const coeffs r)
    250 { return r->cfCopy(n, r); }
     241{   assume(r != NULL); return r->cfCopy(n, r); }
    251242
    252243static inline void   n_Delete(number* p, const coeffs r)
    253 { r->cfDelete(p, r); }
     244{   assume(r != NULL); r->cfDelete(p, r); }
    254245
    255246static inline BOOLEAN n_Equal(number a, number b, const coeffs r)
    256 { return r->cfEqual(a, b, r); }
     247{ assume(r != NULL); return r->cfEqual(a, b, r); }
    257248
    258249static inline BOOLEAN n_IsZero(number n, const coeffs r)
    259 { return r->cfIsZero(n,r); }
     250{ assume(r != NULL); return r->cfIsZero(n,r); }
    260251
    261252static inline BOOLEAN n_IsOne(number n,  const coeffs r)
    262 { return r->cfIsOne(n,r); }
     253{ assume(r != NULL); return r->cfIsOne(n,r); }
    263254
    264255static inline BOOLEAN n_IsMOne(number n, const coeffs r)
    265 { return r->cfIsMOne(n,r); }
     256{ assume(r != NULL); return r->cfIsMOne(n,r); }
    266257
    267258static inline BOOLEAN n_GreaterZero(number n, const coeffs r)
    268 { return r->cfGreaterZero(n,r); }
     259{ assume(r != NULL); return r->cfGreaterZero(n,r); }
    269260// cfGreater?
    270261
    271262#ifdef HAVE_RINGS
    272263static inline BOOLEAN n_IsUnit(number n, const coeffs r)
    273 { return r->cfIsUnit(n,r); }
     264{ assume(r != NULL); return r->cfIsUnit(n,r); }
    274265
    275266static inline number n_GetUnit(number n, const coeffs r)
    276 { return r->cfGetUnit(n,r); }
     267{ assume(r != NULL); return r->cfGetUnit(n,r); }
    277268
    278269static inline BOOLEAN n_DivBy(number a, number b, const coeffs r)
    279 { return r->cfDivBy(a,b,r); }
     270{ assume(r != NULL); return r->cfDivBy(a,b,r); }
    280271#endif
    281272
    282273/// init with an integer
    283274static inline number n_Init(int i,       const coeffs r)
    284 { return r->cfInit(i,r); }
     275{ assume(r != NULL); return r->cfInit(i,r); }
    285276
    286277/// changes argument  inline: a:= -a
    287278static inline number n_Neg(number n,     const coeffs r)
    288 { return r->cfNeg(n,r); }
     279{ assume(r != NULL); return r->cfNeg(n,r); }
    289280
    290281/// return 1/a
    291282static inline number n_Invers(number a,  const coeffs r)
    292 { return r->cfInvers(a,r); }
     283{ assume(r != NULL); return r->cfInvers(a,r); }
    293284
    294285/// use for pivot strategies, (0) => 0, otherwise positive
    295286static inline int    n_Size(number n,    const coeffs r)
    296 { return r->cfSize(n,r); }
     287{ assume(r != NULL); return r->cfSize(n,r); }
    297288
    298289/// normalize the number. i.e. go to some canonnical representation (inplace)
    299290static inline void   n_Normalize(number& n, const coeffs r)
    300 { return r->cfNormalize(n,r); }
     291{ assume(r != NULL); return r->cfNormalize(n,r); }
    301292
    302293/// Normalize and Write to the output buffer of reporter
    303294static inline void   n_Write(number& n,  const coeffs r)
    304 { return r->cfWrite(n,r); }
     295{ assume(r != NULL); return r->cfWrite(n,r); }
    305296
    306297/// Normalize and get denomerator
    307298static inline number n_GetDenom(number& n, const coeffs r)
    308 { return r->cfGetDenom(n, r); }
     299{ assume(r != NULL); return r->cfGetDenom(n, r); }
    309300
    310301/// Normalize and get numerator
    311302static inline number n_GetNumerator(number& n, const coeffs r)
    312 { return r->cfGetNumerator(n, r); }
     303{ assume(r != NULL); return r->cfGetNumerator(n, r); }
    313304
    314305static inline void   n_Power(number a, int b, number *res, const coeffs r)
    315 { r->cfPower(a,b,res,r); }
     306{ assume(r != NULL); r->cfPower(a,b,res,r); }
    316307
    317308static inline number n_Mult(number a, number b, const coeffs r)
    318 { return r->cfMult(a, b, r); }
     309{ assume(r != NULL); return r->cfMult(a, b, r); }
    319310
    320311/// Inplace multiplication: a := a * b
    321312static inline void n_InpMult(number &a, number b, const coeffs r)
    322 { r->cfInpMult(a,b,r); }
     313{ assume(r != NULL); r->cfInpMult(a,b,r); }
    323314
    324315static inline number n_Sub(number a, number b, const coeffs r)
    325 { return r->cfSub(a, b, r); }
     316{ assume(r != NULL); return r->cfSub(a, b, r); }
    326317
    327318static inline number n_Add(number a, number b, const coeffs r)
    328 { return r->cfAdd(a, b, r); }
     319{ assume(r != NULL); return r->cfAdd(a, b, r); }
    329320
    330321static inline number n_Div(number a, number b, const coeffs r)
    331 { return r->cfDiv(a,b,r); }
     322{ assume(r != NULL); return r->cfDiv(a,b,r); }
    332323
    333324static inline number n_IntDiv(number a, number b, const coeffs r)
    334 { return r->cfIntDiv(a,b,r); }
     325{ assume(r != NULL); return r->cfIntDiv(a,b,r); }
    335326
    336327static inline number n_ExactDiv(number a, number b, const coeffs r)
    337 { return r->cfExactDiv(a,b,r); }
     328{ assume(r != NULL); return r->cfExactDiv(a,b,r); }
    338329
    339330static inline number n_Gcd(number a, number b, const coeffs r)
    340 { return r->cfGcd(a,b,r); }
     331{ assume(r != NULL); return r->cfGcd(a,b,r); }
    341332
    342333static inline number n_Lcm(number a, number b, const coeffs r)
    343 { return r->cfLcm(a,b,r); }
     334{ assume(r != NULL); return r->cfLcm(a,b,r); }
    344335
    345336static inline nMapFunc n_SetMap(const coeffs src, const coeffs dst)
    346 { return dst->cfSetMap(src,dst); }
     337{ assume(src != NULL && dst != NULL); return dst->cfSetMap(src,dst); }
    347338
    348339static inline number n_Par(int n, const coeffs r)
    349 { return r->cfPar(n,r); }
     340{ assume(r != NULL); return r->cfPar(n,r); }
    350341
    351342static inline int n_ParDeg(number n, const coeffs r)
    352 { return r->cfParDeg(n,r); }
     343{ assume(r != NULL); return r->cfParDeg(n,r); }
    353344
    354345/// Tests whether n is a correct number: only used if LDEBUG is defined
    355346static inline BOOLEAN n_DBTest(number n, const char *filename, const int linenumber, const coeffs r)
    356347{
     348  assume(r != NULL);
    357349#ifdef LDEBUG
    358350  return (r)->cfDBTest(n, filename, linenumber, r);
     
    364356// Tests:
    365357static inline BOOLEAN nCoeff_is_Ring_2toM(const coeffs r)
    366 { return (r->ringtype == 1); }
     358{ assume(r != NULL); return (r->ringtype == 1); }
    367359
    368360static inline BOOLEAN nCoeff_is_Ring_ModN(const coeffs r)
    369 { return (r->ringtype == 2); }
     361{ assume(r != NULL); return (r->ringtype == 2); }
    370362
    371363static inline BOOLEAN nCoeff_is_Ring_PtoM(const coeffs r)
    372 { return (r->ringtype == 3); }
     364{ assume(r != NULL); return (r->ringtype == 3); }
    373365
    374366static inline BOOLEAN nCoeff_is_Ring_Z(const coeffs r)
    375 { return (r->ringtype == 4); }
     367{ assume(r != NULL); return (r->ringtype == 4); }
    376368
    377369static inline BOOLEAN nCoeff_is_Ring(const coeffs r)
    378 { return (r->ringtype != 0); }
     370{ assume(r != NULL); return (r->ringtype != 0); }
    379371
    380372/// returns TRUE, if r is not a field and r has no zero divisors (i.e is a domain)
    381373static inline BOOLEAN nCoeff_is_Domain(const coeffs r)
    382 { return (r->ringtype == 4 || r->ringtype == 0); }
     374{
     375  assume(r != NULL);
     376#ifdef HAVE_RINGS
     377  return (r->ringtype == 4 || r->ringtype == 0);
     378#else
     379  return TRUE;
     380#endif
     381}
    383382
    384383/// returns TRUE, if r is not a field and r has non-trivial units
    385384static inline BOOLEAN nCoeff_has_Units(const coeffs r)
    386 { return ((r->ringtype == 1) || (r->ringtype == 2) || (r->ringtype == 3)); }
     385{ assume(r != NULL); return ((r->ringtype == 1) || (r->ringtype == 2) || (r->ringtype == 3)); }
    387386
    388387static inline BOOLEAN nCoeff_is_Zp(const coeffs r)
    389 { return getCoeffType(r)==n_Zp; }
     388{ assume(r != NULL); return getCoeffType(r)==n_Zp; }
    390389
    391390static inline BOOLEAN nCoeff_is_Zp(const coeffs r, int p)
    392 { return (getCoeffType(r)  && (r->ch == ABS(p))); }
     391{ assume(r != NULL); return (getCoeffType(r)  && (r->ch == ABS(p))); }
    393392
    394393static inline BOOLEAN nCoeff_is_Q(const coeffs r)
    395 { return getCoeffType(r)==n_Q; }
     394{ assume(r != NULL); return getCoeffType(r)==n_Q; }
    396395
    397396static inline BOOLEAN nCoeff_is_numeric(const coeffs r) /* R, long R, long C */
    398 {  return (getCoeffType(r)==n_R) || (getCoeffType(r)==n_long_R) || (getCoeffType(r)==n_long_C); }
     397{ assume(r != NULL);  return (getCoeffType(r)==n_R) || (getCoeffType(r)==n_long_R) || (getCoeffType(r)==n_long_C); }
     398// (r->ringtype == 0) && (r->ch ==  -1); ??
     399
    399400
    400401static inline BOOLEAN nCoeff_is_R(const coeffs r)
    401 { return getCoeffType(r)==n_R; }
     402{ assume(r != NULL); return getCoeffType(r)==n_R; }
    402403
    403404static inline BOOLEAN nCoeff_is_GF(const coeffs r)
    404 { return getCoeffType(r)==n_GF; }
     405{ assume(r != NULL); return getCoeffType(r)==n_GF; }
    405406
    406407static inline BOOLEAN nCoeff_is_GF(const coeffs r, int q)
    407 { return (getCoeffType(r)==n_GF) && (r->ch == q); }
     408{ assume(r != NULL); return (getCoeffType(r)==n_GF) && (r->ch == q); }
    408409
    409410static inline BOOLEAN nCoeff_is_Zp_a(const coeffs r)
    410 { return (r->ringtype == 0) && (r->ch < -1); }
     411{ assume(r != NULL); return (r->ringtype == 0) && (r->ch < -1); }
    411412
    412413static inline BOOLEAN nCoeff_is_Zp_a(const coeffs r, int p)
    413 { return (r->ringtype == 0) && (r->ch < -1 ) && (-(r->ch) == ABS(p)); }
     414{ assume(r != NULL); return (r->ringtype == 0) && (r->ch < -1 ) && (-(r->ch) == ABS(p)); }
    414415
    415416static inline BOOLEAN nCoeff_is_Q_a(const coeffs r)
    416 { return (r->ringtype == 0) && (r->ch == 1); }
     417{ assume(r != NULL); return (r->ringtype == 0) && (r->ch == 1); }
    417418
    418419static inline BOOLEAN nCoeff_is_long_R(const coeffs r)
    419 { return getCoeffType(r)==n_long_R; }
     420{ assume(r != NULL); return getCoeffType(r)==n_long_R; }
    420421
    421422static inline BOOLEAN nCoeff_is_long_C(const coeffs r)
    422 { return getCoeffType(r)==n_long_C; }
     423{ assume(r != NULL); return getCoeffType(r)==n_long_C; }
    423424
    424425static inline BOOLEAN nCoeff_is_CF(const coeffs r)
    425 { return getCoeffType(r)==n_CF; }
     426{ assume(r != NULL); return getCoeffType(r)==n_CF; }
    426427
    427428/// TRUE, if the computation of the inverse is fast (i.e. prefer leading coeff. 1 over content)
    428429static inline BOOLEAN nCoeff_has_simple_inverse(const coeffs r)
    429 { return r->has_simple_Inverse; }
     430{ assume(r != NULL); return r->has_simple_Inverse; }
    430431/* Z/2^n, Z/p, GF(p,n), R, long_R, long_C*/
     432// /* { return (r->ch>1) || (r->ch== -1); } *//* Z/p, GF(p,n), R, long_R, long_C*/
     433// #ifdef HAVE_RINGS
     434// { return (r->ringtype > 0) || (r->ch>1) || ((r->ch== -1) && (r->float_len < 10)); } /* Z/2^n, Z/p, GF(p,n), R, long_R, long_C*/
     435// #else
     436// { return (r->ch>1) || ((r->ch== -1) && (r->float_len < 10)); } /* Z/p, GF(p,n), R, long_R, long_C*/
     437// #endif
     438
     439
    431440
    432441/// TRUE if n_Delete/n_New are empty operations
    433442static inline BOOLEAN nCoeff_has_simple_Alloc(const coeffs r)
    434 { return r->has_simple_Alloc; }
     443{ assume(r != NULL); return r->has_simple_Alloc; }
    435444/* Z/p, GF(p,n), R, Ring_2toM: nCopy, nNew, nDelete are dummies*/
     445// return (rField_is_Zp(r)
     446//         || rField_is_GF(r)
     447// #ifdef HAVE_RINGS
     448//             || rField_is_Ring_2toM(r)
     449// #endif
     450//             || rField_is_R(r)); }
     451
    436452
    437453static inline BOOLEAN nCoeff_is_Extension(const coeffs r)
    438 { return (nCoeff_is_Q_a(r)) || (nCoeff_is_Zp_a(r)); } /* Z/p(a) and Q(a)*/
     454{ assume(r != NULL); return (nCoeff_is_Q_a(r)) || (nCoeff_is_Zp_a(r)); } /* Z/p(a) and Q(a)*/
    439455
    440456/// BOOLEAN n_Test(number a, const coeffs r)
     
    448464// Deprecated:
    449465static inline int n_GetChar(const coeffs r)
    450 { return nInternalChar(r); }
    451 
    452 
    453 
    454 #endif
    455 
     466{ assume(r != NULL); return nInternalChar(r); }
     467
     468
     469
     470#endif
     471
Note: See TracChangeset for help on using the changeset viewer.