Changeset 17e473 in git for libpolys/coeffs/coeffs.h
- Timestamp:
- Apr 20, 2011, 9:43:24 PM (13 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/coeffs/coeffs.h
r1ddd04 r17e473 207 207 static inline n_coeffType getCoeffType(const coeffs r) 208 208 { 209 assume(r != NULL); 209 210 return r->type; 210 211 } 211 212 212 /// returns true for coeffs being a domain213 static inline bool nField_is_Domain(const coeffs r)214 {215 #ifdef HAVE_RINGS216 return (r->ringtype == 4 || r->ringtype == 0);217 #else218 return true;219 #endif220 }221 222 223 213 static inline int nInternalChar(const coeffs r) 224 214 { 215 assume(r != NULL); 225 216 return r->ch; 226 217 } … … 248 239 /// return a copy of a 249 240 static inline number n_Copy(number n, const coeffs r) 250 { return r->cfCopy(n, r); }241 { assume(r != NULL); return r->cfCopy(n, r); } 251 242 252 243 static inline void n_Delete(number* p, const coeffs r) 253 { r->cfDelete(p, r); }244 { assume(r != NULL); r->cfDelete(p, r); } 254 245 255 246 static 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); } 257 248 258 249 static inline BOOLEAN n_IsZero(number n, const coeffs r) 259 { return r->cfIsZero(n,r); }250 { assume(r != NULL); return r->cfIsZero(n,r); } 260 251 261 252 static inline BOOLEAN n_IsOne(number n, const coeffs r) 262 { return r->cfIsOne(n,r); }253 { assume(r != NULL); return r->cfIsOne(n,r); } 263 254 264 255 static inline BOOLEAN n_IsMOne(number n, const coeffs r) 265 { return r->cfIsMOne(n,r); }256 { assume(r != NULL); return r->cfIsMOne(n,r); } 266 257 267 258 static inline BOOLEAN n_GreaterZero(number n, const coeffs r) 268 { return r->cfGreaterZero(n,r); }259 { assume(r != NULL); return r->cfGreaterZero(n,r); } 269 260 // cfGreater? 270 261 271 262 #ifdef HAVE_RINGS 272 263 static inline BOOLEAN n_IsUnit(number n, const coeffs r) 273 { return r->cfIsUnit(n,r); }264 { assume(r != NULL); return r->cfIsUnit(n,r); } 274 265 275 266 static inline number n_GetUnit(number n, const coeffs r) 276 { return r->cfGetUnit(n,r); }267 { assume(r != NULL); return r->cfGetUnit(n,r); } 277 268 278 269 static 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); } 280 271 #endif 281 272 282 273 /// init with an integer 283 274 static inline number n_Init(int i, const coeffs r) 284 { return r->cfInit(i,r); }275 { assume(r != NULL); return r->cfInit(i,r); } 285 276 286 277 /// changes argument inline: a:= -a 287 278 static inline number n_Neg(number n, const coeffs r) 288 { return r->cfNeg(n,r); }279 { assume(r != NULL); return r->cfNeg(n,r); } 289 280 290 281 /// return 1/a 291 282 static inline number n_Invers(number a, const coeffs r) 292 { return r->cfInvers(a,r); }283 { assume(r != NULL); return r->cfInvers(a,r); } 293 284 294 285 /// use for pivot strategies, (0) => 0, otherwise positive 295 286 static inline int n_Size(number n, const coeffs r) 296 { return r->cfSize(n,r); }287 { assume(r != NULL); return r->cfSize(n,r); } 297 288 298 289 /// normalize the number. i.e. go to some canonnical representation (inplace) 299 290 static inline void n_Normalize(number& n, const coeffs r) 300 { return r->cfNormalize(n,r); }291 { assume(r != NULL); return r->cfNormalize(n,r); } 301 292 302 293 /// Normalize and Write to the output buffer of reporter 303 294 static inline void n_Write(number& n, const coeffs r) 304 { return r->cfWrite(n,r); }295 { assume(r != NULL); return r->cfWrite(n,r); } 305 296 306 297 /// Normalize and get denomerator 307 298 static inline number n_GetDenom(number& n, const coeffs r) 308 { return r->cfGetDenom(n, r); }299 { assume(r != NULL); return r->cfGetDenom(n, r); } 309 300 310 301 /// Normalize and get numerator 311 302 static inline number n_GetNumerator(number& n, const coeffs r) 312 { return r->cfGetNumerator(n, r); }303 { assume(r != NULL); return r->cfGetNumerator(n, r); } 313 304 314 305 static 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); } 316 307 317 308 static 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); } 319 310 320 311 /// Inplace multiplication: a := a * b 321 312 static 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); } 323 314 324 315 static 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); } 326 317 327 318 static 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); } 329 320 330 321 static 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); } 332 323 333 324 static 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); } 335 326 336 327 static 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); } 338 329 339 330 static 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); } 341 332 342 333 static 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); } 344 335 345 336 static 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); } 347 338 348 339 static inline number n_Par(int n, const coeffs r) 349 { return r->cfPar(n,r); }340 { assume(r != NULL); return r->cfPar(n,r); } 350 341 351 342 static inline int n_ParDeg(number n, const coeffs r) 352 { return r->cfParDeg(n,r); }343 { assume(r != NULL); return r->cfParDeg(n,r); } 353 344 354 345 /// Tests whether n is a correct number: only used if LDEBUG is defined 355 346 static inline BOOLEAN n_DBTest(number n, const char *filename, const int linenumber, const coeffs r) 356 347 { 348 assume(r != NULL); 357 349 #ifdef LDEBUG 358 350 return (r)->cfDBTest(n, filename, linenumber, r); … … 364 356 // Tests: 365 357 static inline BOOLEAN nCoeff_is_Ring_2toM(const coeffs r) 366 { return (r->ringtype == 1); }358 { assume(r != NULL); return (r->ringtype == 1); } 367 359 368 360 static inline BOOLEAN nCoeff_is_Ring_ModN(const coeffs r) 369 { return (r->ringtype == 2); }361 { assume(r != NULL); return (r->ringtype == 2); } 370 362 371 363 static inline BOOLEAN nCoeff_is_Ring_PtoM(const coeffs r) 372 { return (r->ringtype == 3); }364 { assume(r != NULL); return (r->ringtype == 3); } 373 365 374 366 static inline BOOLEAN nCoeff_is_Ring_Z(const coeffs r) 375 { return (r->ringtype == 4); }367 { assume(r != NULL); return (r->ringtype == 4); } 376 368 377 369 static inline BOOLEAN nCoeff_is_Ring(const coeffs r) 378 { return (r->ringtype != 0); }370 { assume(r != NULL); return (r->ringtype != 0); } 379 371 380 372 /// returns TRUE, if r is not a field and r has no zero divisors (i.e is a domain) 381 373 static 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 } 383 382 384 383 /// returns TRUE, if r is not a field and r has non-trivial units 385 384 static 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)); } 387 386 388 387 static inline BOOLEAN nCoeff_is_Zp(const coeffs r) 389 { return getCoeffType(r)==n_Zp; }388 { assume(r != NULL); return getCoeffType(r)==n_Zp; } 390 389 391 390 static 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))); } 393 392 394 393 static inline BOOLEAN nCoeff_is_Q(const coeffs r) 395 { return getCoeffType(r)==n_Q; }394 { assume(r != NULL); return getCoeffType(r)==n_Q; } 396 395 397 396 static 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 399 400 400 401 static inline BOOLEAN nCoeff_is_R(const coeffs r) 401 { return getCoeffType(r)==n_R; }402 { assume(r != NULL); return getCoeffType(r)==n_R; } 402 403 403 404 static inline BOOLEAN nCoeff_is_GF(const coeffs r) 404 { return getCoeffType(r)==n_GF; }405 { assume(r != NULL); return getCoeffType(r)==n_GF; } 405 406 406 407 static 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); } 408 409 409 410 static 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); } 411 412 412 413 static 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)); } 414 415 415 416 static 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); } 417 418 418 419 static 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; } 420 421 421 422 static 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; } 423 424 424 425 static inline BOOLEAN nCoeff_is_CF(const coeffs r) 425 { return getCoeffType(r)==n_CF; }426 { assume(r != NULL); return getCoeffType(r)==n_CF; } 426 427 427 428 /// TRUE, if the computation of the inverse is fast (i.e. prefer leading coeff. 1 over content) 428 429 static inline BOOLEAN nCoeff_has_simple_inverse(const coeffs r) 429 { return r->has_simple_Inverse; }430 { assume(r != NULL); return r->has_simple_Inverse; } 430 431 /* 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 431 440 432 441 /// TRUE if n_Delete/n_New are empty operations 433 442 static inline BOOLEAN nCoeff_has_simple_Alloc(const coeffs r) 434 { return r->has_simple_Alloc; }443 { assume(r != NULL); return r->has_simple_Alloc; } 435 444 /* 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 436 452 437 453 static 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)*/ 439 455 440 456 /// BOOLEAN n_Test(number a, const coeffs r) … … 448 464 // Deprecated: 449 465 static 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.