Changeset 44d5ad in git
- Timestamp:
- Jul 12, 2011, 2:09:23 PM (12 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- 964389e50adfc08d7756a47697064d105b4d086b
- Parents:
- 0afa076b284b40edfd3ac479c184b33b3cdc12b6
- git-author:
- Frank Seelisch <seelisch@mathematik.uni-kl.de>2011-07-12 14:09:23+02:00
- git-committer:
- Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:39:14+01:00
- Location:
- libpolys/coeffs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/coeffs/coeffs.h
r0afa07 r44d5ad 275 275 // the access methods (part 2): 276 276 277 /// return a copy of a277 /// return a copy of 'n' 278 278 static inline number n_Copy(number n, const coeffs r) 279 279 { assume(r != NULL); assume(r->cfCopy!=NULL); return r->cfCopy(n, r); } 280 280 281 /// delete 'p' 281 282 static inline void n_Delete(number* p, const coeffs r) 282 283 { assume(r != NULL); assume(r->cfDelete!= NULL); r->cfDelete(p, r); } 283 284 285 /// TRUE iff 'a' and 'b' represent the same number; 286 /// they may have different representations 284 287 static inline BOOLEAN n_Equal(number a, number b, const coeffs r) 285 288 { assume(r != NULL); assume(r->cfEqual!=NULL); return r->cfEqual(a, b, r); } 286 289 290 /// TRUE iff 'n' represents the zero element 287 291 static inline BOOLEAN n_IsZero(number n, const coeffs r) 288 292 { assume(r != NULL); assume(r->cfIsZero!=NULL); return r->cfIsZero(n,r); } 289 293 294 /// TRUE iff 'n' represents the one element 290 295 static inline BOOLEAN n_IsOne(number n, const coeffs r) 291 296 { assume(r != NULL); assume(r->cfIsOne!=NULL); return r->cfIsOne(n,r); } 292 297 298 /// TRUE iff 'n' represents the additive inverse of the one element, i.e. -1 293 299 static inline BOOLEAN n_IsMOne(number n, const coeffs r) 294 300 { assume(r != NULL); assume(r->cfIsMOne!=NULL); return r->cfIsMOne(n,r); } 295 301 302 /// ordered fields: TRUE iff 'n' is positive; 303 /// in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long 304 /// representing n 305 /// in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or 306 /// (Im(n) == 0 and Re(n) >= 0) 307 /// in K(a)/<p(a)>: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) 308 /// in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) 309 /// or (LC(numerator(n) is not a constant) 310 /// in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) 311 /// in Z/mZ: TRUE iff the internal mpz is greater than zero 312 /// in Z: TRUE iff n > 0 313 /// 314 /// !!! Recommendation: remove implementations for unordered fields 315 /// !!! and raise errors instead, in these cases 296 316 static inline BOOLEAN n_GreaterZero(number n, const coeffs r) 297 { assume(r != NULL); assume(r->cfGreaterZero!=NULL); return r->cfGreaterZero(n,r); } 317 { 318 assume(r != NULL); assume(r->cfGreaterZero!=NULL); 319 return r->cfGreaterZero(n,r); 320 } 321 322 /// ordered fields: TRUE iff 'a' is larger than 'b'; 323 /// in Z/pZ: TRUE iff la > lb, where la and lb are the long's representing 324 // a and b, respectively 325 /// in C: TRUE iff (Im(a) > Im(b)) 326 /// in K(a)/<p(a)>: TRUE iff (a != 0 and (b == 0 or deg(a) > deg(b)) 327 /// in K(t_1, ..., t_n): TRUE only if one or both numerator polynomials are 328 /// zero or if their degrees are equal. In this case, 329 /// TRUE if LC(numerator(a)) > LC(numerator(b)) 330 /// in Z/2^kZ: TRUE if n_DivBy(a, b) 331 /// in Z/mZ: TRUE iff the internal mpz's fulfill the relation '>' 332 /// in Z: TRUE iff a > b 333 /// 334 /// !!! Recommendation: remove implementations for unordered fields 335 /// !!! and raise errors instead, in these cases 298 336 static inline BOOLEAN n_Greater(number a, number b, const coeffs r) 299 337 { assume(r != NULL); assume(r->cfGreater!=NULL); return r->cfGreater(a,b,r); } 300 338 301 339 #ifdef HAVE_RINGS 340 /// TRUE iff n has a multiplicative inverse in the given coeff field/ring r 302 341 static inline BOOLEAN n_IsUnit(number n, const coeffs r) 303 342 { assume(r != NULL); assume(r->cfIsUnit!=NULL); return r->cfIsUnit(n,r); } 304 343 344 /// in Z: 1 345 /// in Z/kZ (where k is not a prime): largest divisor of n (taken in Z) that 346 /// is co-prime with k 347 /// in Z/2^kZ: largest odd divisor of n (taken in Z) 348 /// other cases: not implemented 305 349 static inline number n_GetUnit(number n, const coeffs r) 306 350 { assume(r != NULL); assume(r->cfGetUnit!=NULL); return r->cfGetUnit(n,r); } 307 351 #endif 308 352 309 /// init with an integer353 /// a number representing i in the given coeff field/ring r 310 354 static inline number n_Init(int i, const coeffs r) 311 355 { assume(r != NULL); assume(r->cfInit!=NULL); return r->cfInit(i,r); } 312 356 313 /// conversion to int; 0 if not possible 357 /// conversion of n to an int; 0 if not possible 358 /// in Z/pZ: the representing int lying in (-p/2 .. p/2] 314 359 static inline int n_Int(number &n, const coeffs r) 315 360 { assume(r != NULL); assume(r->cfInt!=NULL); return r->cfInt(n,r); } 316 361 317 /// changes argument inline: a:= -a362 /// in-place negation of n 318 363 static inline number n_Neg(number n, const coeffs r) 319 364 { assume(r != NULL); assume(r->cfNeg!=NULL); return r->cfNeg(n,r); } 320 365 321 /// return 1/a 366 /// return the multiplicative inverse of 'a'; 367 /// raise an error if 'a' is not invertible 368 /// 369 /// !!! Recommendation: rename to 'n_Inverse' 322 370 static inline number n_Invers(number a, const coeffs r) 323 371 { assume(r != NULL); assume(r->cfInvers!=NULL); return r->cfInvers(a,r); } 324 372 325 /// use for pivot strategies, (0) => 0, otherwise positive 373 /// return a non-negative measure for the complexity of n; 374 /// return 0 only when n represents zero; 375 /// (used for pivot strategies in matrix computations with entries from r) 326 376 static inline int n_Size(number n, const coeffs r) 327 377 { assume(r != NULL); assume(r->cfSize!=NULL); return r->cfSize(n,r); } 328 378 329 /// normalize the number. i.e. go to some canonnical representation (inplace) 379 /// inplace-normalization of n; 380 /// produces some canonical representation of n; 381 /// 382 /// !!! Recommendation: remove this method from the user-interface, i.e., 383 /// !!! this should be hidden 330 384 static inline void n_Normalize(number& n, const coeffs r) 331 385 { assume(r != NULL); assume(r->cfNormalize!=NULL); r->cfNormalize(n,r); } 332 386 333 /// Normalize and Write to the output buffer ofreporter387 /// write to the output buffer of the currently used reporter 334 388 static inline void n_Write(number& n, const coeffs r) 335 389 { assume(r != NULL); assume(r->cfWrite!=NULL); r->cfWrite(n,r); } 336 390 337 /// @todo: Describe me!!! 391 /// @todo: Describe me!!! --> Hans 392 /// 393 /// !!! Recommendation: This method is to cryptic to be part of the user- 394 /// !!! interface. As defined here, it is merely a helper 395 /// !!! method for parsing number input strings. 338 396 static inline const char *n_Read(const char * s, number * a, const coeffs r) 339 397 { assume(r != NULL); assume(r->cfRead!=NULL); return r->cfRead(s, a, r); } 340 398 341 /// Normalize and get denomerator 399 /// return the denominator of n 400 /// (if elements of r are by nature not fractional, result is 1) 342 401 static inline number n_GetDenom(number& n, const coeffs r) 343 402 { assume(r != NULL); assume(r->cfGetDenom!=NULL); return r->cfGetDenom(n, r); } 344 403 345 /// Normalize and get numerator 404 /// return the numerator of n 405 /// (if elements of r are by nature not fractional, result is n) 346 406 static inline number n_GetNumerator(number& n, const coeffs r) 347 407 { assume(r != NULL); assume(r->cfGetNumerator!=NULL); return r->cfGetNumerator(n, r); } 348 408 409 /// fill res with the power a^b 349 410 static inline void n_Power(number a, int b, number *res, const coeffs r) 350 411 { assume(r != NULL); assume(r->cfPower!=NULL); r->cfPower(a,b,res,r); } 351 412 413 /// return the product of 'a' and 'b', i.e., a*b 352 414 static inline number n_Mult(number a, number b, const coeffs r) 353 415 { assume(r != NULL); assume(r->cfMult!=NULL); return r->cfMult(a, b, r); } 354 416 355 /// Inplace multiplication: a := a * b 417 /// multiplication of 'a' and 'b'; 418 /// replacement of 'a' by the product a*b 356 419 static inline void n_InpMult(number &a, number b, const coeffs r) 357 420 { assume(r != NULL); assume(r->cfInpMult!=NULL); r->cfInpMult(a,b,r); } 358 421 422 /// return the difference of 'a' and 'b', i.e., a-b 359 423 static inline number n_Sub(number a, number b, const coeffs r) 360 424 { assume(r != NULL); assume(r->cfSub!=NULL); return r->cfSub(a, b, r); } 361 425 426 /// return the sum of 'a' and 'b', i.e., a+b 362 427 static inline number n_Add(number a, number b, const coeffs r) 363 428 { assume(r != NULL); assume(r->cfAdd!=NULL); return r->cfAdd(a, b, r); } 364 429 430 /// return the quotient of 'a' and 'b', i.e., a/b; 431 /// raise an error if 'b' is not invertible in r 365 432 static inline number n_Div(number a, number b, const coeffs r) 366 433 { assume(r != NULL); assume(r->cfDiv!=NULL); return r->cfDiv(a,b,r); } 367 434 435 /// in Z: largest c such that c*b <= a 436 /// in Z/nZ, Z/2^kZ: computed as in the case Z (from integers representing 437 /// 'a' and 'b') 438 /// in Z/pZ: return a/b 439 /// in K(a)/<p(a)>: return a/b 440 /// in K(t_1, ..., t_n): return a/b 441 /// other fields: not implemented 368 442 static inline number n_IntDiv(number a, number b, const coeffs r) 369 443 { assume(r != NULL); assume(r->cfIntDiv!=NULL); return r->cfIntDiv(a,b,r); } 370 444 445 /// @todo: Describe me!!! 446 /// 447 /// What is the purpose of this method, especially in comparison with 448 /// n_Div? 449 /// !!! Recommendation: remove this method from the user-interface. 371 450 static inline number n_ExactDiv(number a, number b, const coeffs r) 372 451 { assume(r != NULL); assume(r->cfExactDiv!=NULL); return r->cfExactDiv(a,b,r); } 373 452 453 /// in Z: return the gcd of 'a' and 'b' 454 /// in Z/nZ, Z/2^kZ: computed as in the case Z 455 /// in Z/pZ, C, R: not implemented 456 /// in Q: return the gcd of the numerators of 'a' and 'b' 457 /// in K(a)/<p(a)>: not implemented 458 /// in K(t_1, ..., t_n): not implemented 374 459 static inline number n_Gcd(number a, number b, const coeffs r) 375 460 { assume(r != NULL); assume(r->cfGcd!=NULL); return r->cfGcd(a,b,r); } 376 461 462 /// in Z: return the lcm of 'a' and 'b' 463 /// in Z/nZ, Z/2^kZ: computed as in the case Z 464 /// in Z/pZ, C, R: not implemented 465 /// in Q: return the lcm of the numerators of 'a' and the denominator of 'b' 466 /// in K(a)/<p(a)>: not implemented 467 /// in K(t_1, ..., t_n): not implemented 377 468 static inline number n_Lcm(number a, number b, const coeffs r) 378 469 { assume(r != NULL); assume(r->cfLcm!=NULL); return r->cfLcm(a,b,r); } 379 470 471 /// set the mapping function pointers for translating numbers from src to dst 380 472 static inline nMapFunc n_SetMap(const coeffs src, const coeffs dst) 381 473 { assume(src != NULL && dst != NULL); assume(dst->cfSetMap!=NULL); return dst->cfSetMap(src,dst); } 382 474 383 /// Tests whether n is a correct number: only used if LDEBUG is defined 475 /// test whether n is a correct number; 476 /// only used if LDEBUG is defined 384 477 static inline BOOLEAN n_DBTest(number n, const char *filename, const int linenumber, const coeffs r) 385 478 { … … 424 517 } 425 518 426 /// Test whether a can be divided by b? 519 /// test whether 'a' is divisible 'b'; 520 /// for r encoding a field: TRUE iff 'b' does not represent zero 521 /// in Z: TRUE iff 'b' divides 'a' (with remainder = zero) 522 /// in Z/nZ: TRUE iff (a = 0 and b divides n in Z) or 523 /// (a != 0 and b/gcd(a, b) is co-prime with n, i.e. 524 /// a unit in Z/nZ) 525 /// in Z/2^kZ: TRUE iff ((a = 0 mod 2^k) and (b = 0 or b is a power of 2)) 526 /// or ((a, b <> 0) and (b/gcd(a, b) is odd)) 427 527 static inline BOOLEAN n_DivBy(number a, number b, const coeffs r) 428 528 { … … 517 617 { assume(r != NULL); return getCoeffType(r)==n_CF; } 518 618 519 /// TRUE, if the computation of the inverse is fast (i.e. prefer leading coeff. 1 over content) 619 /// TRUE, if the computation of the inverse is fast, 620 /// i.e. prefer leading coeff. 1 over content 520 621 static inline BOOLEAN nCoeff_has_simple_inverse(const coeffs r) 521 622 { assume(r != NULL); return r->has_simple_Inverse; } 522 /* Z/2^n, Z/p, GF(p,n), R, long_R, long_C*/523 // /* { return (r->ch>1) || (r->ch== -1); } *//* Z/p, GF(p,n), R, long_R, long_C*/524 // #ifdef HAVE_RINGS525 // { 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*/526 // #else527 // { return (r->ch>1) || ((r->ch== -1) && (r->float_len < 10)); } /* Z/p, GF(p,n), R, long_R, long_C*/528 // #endif529 623 530 624 /// TRUE if n_Delete/n_New are empty operations 531 625 static inline BOOLEAN nCoeff_has_simple_Alloc(const coeffs r) 532 626 { assume(r != NULL); return r->has_simple_Alloc; } 533 /* Z/p, GF(p,n), R, Ring_2toM: nCopy, nNew, nDelete are dummies*/ 534 // return (rField_is_Zp(r) 535 // || rField_is_GF(r) 536 // #ifdef HAVE_RINGS 537 // || rField_is_Ring_2toM(r) 538 // #endif 539 // || rField_is_R(r)); } 540 541 /* TRUE iff r represents an algebraic extension field */ 627 628 /// TRUE iff r represents an algebraic extension field 542 629 static inline BOOLEAN nCoeff_is_algExt(const coeffs r) 543 630 { assume(r != NULL); return (getCoeffType(r)==n_algExt); } 544 631 545 / * TRUE iff r represents a transcendental extension field */632 /// TRUE iff r represents a transcendental extension field 546 633 static inline BOOLEAN nCoeff_is_transExt(const coeffs r) 547 634 { assume(r != NULL); return (getCoeffType(r)==n_transExt); } … … 554 641 // HAVE_RINGS: cfDivComp, cfExtGcd... 555 642 556 557 558 643 // Deprecated: 559 644 static inline int n_GetChar(const coeffs r) -
libpolys/coeffs/modulop.cc
r0afa07 r44d5ad 61 61 62 62 /*2 63 * convert a number to int (-p/2 .. p/2)63 * convert a number to an int in (-p/2 .. p/2] 64 64 */ 65 65 int npInt(number &n, const coeffs r) -
libpolys/coeffs/rmodulo2m.cc
r0afa07 r44d5ad 278 278 } 279 279 280 /* Is a divisible by b? There are two cases:280 /* Is 'a' divisible by 'b'? There are two cases: 281 281 1) a = 0 mod 2^m; then TRUE iff b = 0 or b is a power of 2 282 2) a, b <> 0; then TRUE iff b/gcd(a, b) is a unit mod 2^m 283 TRUE iff b(gcd(a, b) is a unit */ 282 2) a, b <> 0; then TRUE iff b/gcd(a, b) is a unit mod 2^m */ 284 283 BOOLEAN nr2mDivBy (number a, number b, const coeffs r) 285 284 {
Note: See TracChangeset
for help on using the changeset viewer.