Changeset 0fb5991 in git
- Timestamp:
- May 9, 2011, 12:44:46 PM (12 years ago)
- Branches:
- (u'spielwiese', 'f6c3dc58b0df4bd712574325fe76d0626174ad97')
- Children:
- abb478768b4e6470e8184a28c8fd2546f40af8de
- Parents:
- 3b0ba67abd225a2bb2c09c675cfe3085aaf67f12
- git-author:
- Frank Seelisch <seelisch@mathematik.uni-kl.de>2011-05-09 12:44:46+02:00
- git-committer:
- Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:31:39+01:00
- Location:
- libpolys
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/coeffs/longrat.h
r3b0ba67 r0fb5991 84 84 const char * nlRead (const char *s, number *a, const coeffs r); 85 85 void nlWrite(number &a, const coeffs r); 86 int nlModP(number n, int p );86 int nlModP(number n, int p, const coeffs r); 87 87 int nlSize(number n, const coeffs r); 88 88 number nlGetDenom(number &n, const coeffs r); -
libpolys/polys/ext_fields/algext.cc
r3b0ba67 r0fb5991 30 30 #include <coeffs/coeffs.h> 31 31 #include <coeffs/numbers.h> 32 #include <coeffs/longrat.h> 32 33 33 34 #include <polys/monomials/ring.h> … … 58 59 number naRePart(number a, const coeffs cf); 59 60 number naImPart(number a, const coeffs cf); 60 number naGetDenom(number a, const coeffs cf);61 number naGetNumerator(number a, const coeffs cf);61 number naGetDenom(number &a, const coeffs cf); 62 number naGetNumerator(number &a, const coeffs cf); 62 63 number naGcd(number a, number b, const coeffs cf); 63 64 number naLcm(number a, number b, const coeffs cf); … … 120 121 } 121 122 122 number naCopy(number &a, const coeffs cf)123 number naCopy(number a, const coeffs cf) 123 124 { 124 125 naTest(a); 125 126 if (a == NULL) return NULL; 126 127 return (number)p_Copy((poly)a, naRing); 128 } 129 130 number naGetNumerator(number &a, const coeffs cf) 131 { 132 return naCopy(a, cf); 127 133 } 128 134 … … 221 227 poly aPlusB = p_Add_q(p_Copy((poly)a, naRing), 222 228 p_Copy((poly)b, naRing), naRing); 223 definiteReduce(aPlusB, naMinpoly );224 return (number)a MinusB;229 definiteReduce(aPlusB, naMinpoly, cf); 230 return (number)aPlusB; 225 231 } 226 232 … … 230 236 if (b == NULL) return naCopy(a, cf); 231 237 poly minusB = p_Neg(p_Copy((poly)b, naRing), naRing); 232 if (a == NULL) return minusB;238 if (a == NULL) return (number)minusB; 233 239 poly aMinusB = p_Add_q(p_Copy((poly)a, naRing), minusB, naRing); 234 definiteReduce(aMinusB, naMinpoly );240 definiteReduce(aMinusB, naMinpoly, cf); 235 241 return (number)aMinusB; 236 242 } … … 243 249 poly aTimesB = p_Mult_q(p_Copy((poly)a, naRing), 244 250 p_Copy((poly)b, naRing), naRing); 245 definiteReduce(aTimesB, naMinpoly );246 return (number)a MinusB;251 definiteReduce(aTimesB, naMinpoly, cf); 252 return (number)aTimesB; 247 253 } 248 254 … … 254 260 poly bInverse = (poly)naInvers(b, cf); 255 261 poly aDivB = p_Mult_q(p_Copy((poly)a, naRing), bInverse, naRing); 256 definiteReduce(aDivB, naMinpoly );257 return (number)a MinusB;262 definiteReduce(aDivB, naMinpoly, cf); 263 return (number)aDivB; 258 264 } 259 265 … … 273 279 if (a == NULL) 274 280 { 275 if (exp >= 0) returnNULL;281 if (exp >= 0) *b = NULL; 276 282 else WerrorS(nDivBy0); 277 283 } 278 else if (exp == 0) returnnaInit(1, cf);279 else if (exp == 1) returnnaCopy(a, cf);280 else if (exp == -1) returnnaInvers(a, cf);284 else if (exp == 0) *b = naInit(1, cf); 285 else if (exp == 1) *b = naCopy(a, cf); 286 else if (exp == -1) *b = naInvers(a, cf); 281 287 282 288 int expAbs = exp; if (expAbs < 0) expAbs = -expAbs; … … 312 318 } 313 319 } 314 p_Delete( factor, naRing);320 p_Delete(&factor, naRing); 315 321 definiteReduce(pow, naMinpoly, cf); 316 322 } … … 378 384 but the final division will take care of the necessary reduction */ 379 385 number theGcd = naGcd(a, b, cf); 380 return naDiv( product, theGcd);386 return naDiv(theProduct, theGcd, cf); 381 387 } 382 388 … … 409 415 noOfTerms++; 410 416 int d = 0; 411 for (int i = 1; i <= rVar(r); i++) d += p_GetExp(aAsPoly, i, naRing); 417 for (int i = 1; i <= rVar(naRing); i++) 418 d += p_GetExp(aAsPoly, i, naRing); 412 419 if (d > theDegree) theDegree = d; 413 420 pIter(aAsPoly); … … 423 430 omCheckAddr(p); omCheckAddr(reducer); 424 431 #endif 425 p_PolyDiv( *p, reducer, FALSE, naRing);432 p_PolyDiv(&p, reducer, FALSE, naRing); 426 433 } 427 434 … … 438 445 if (a == NULL) WerrorS(nDivBy0); 439 446 poly *aFactor; poly *mFactor; 440 poly theGcd = p_ExtGcd((poly)a, *aFactor, naMinpoly, *mFactor, naRing);447 poly theGcd = p_ExtGcd((poly)a, aFactor, naMinpoly, mFactor, naRing); 441 448 /* the gcd must be one since naMinpoly is irreducible and a != NULL: */ 442 assume(naIsOne( theGcd, cf));443 p Delete(&theGcd, naRing);444 p Delete(mFactor, naRing);445 return aInverse =(number)(*aFactor);449 assume(naIsOne((number)theGcd, cf)); 450 p_Delete(&theGcd, naRing); 451 p_Delete(mFactor, naRing); 452 return (number)(*aFactor); 446 453 } 447 454 … … 450 457 { 451 458 assume(src == dst->algring->cf); 452 poly result = p_ Init(1,dst->algring);453 p_SetCoeff(result, naCopy(a, src), dst->alg Ring);459 poly result = p_One(dst->algring); 460 p_SetCoeff(result, naCopy(a, src), dst->algring); 454 461 return (number)result; 455 462 } … … 461 468 int n = n_Int(a, src); 462 469 number q = n_Init(n, dst->algring->cf); 463 poly result = p_ Init(1,dst->algring);464 p_SetCoeff(result, q, dst->alg Ring);470 poly result = p_One(dst->algring); 471 p_SetCoeff(result, q, dst->algring); 465 472 return (number)result; 466 473 } … … 476 483 number naMap0P(number a, const coeffs src, const coeffs dst) 477 484 { 478 int p = rChar(dst );485 int p = rChar(dst->algring); 479 486 int n = nlModP(a, p, src); 480 487 number q = n_Init(n, dst->algring->cf); 481 poly result = p_ Init(1,dst->algring);482 p_SetCoeff(result, q, dst->alg Ring);488 poly result = p_One(dst->algring); 489 p_SetCoeff(result, q, dst->algring); 483 490 return (number)result; 484 491 } … … 488 495 { 489 496 assume(src == dst->algring->cf); 490 poly result = p_ Init(1,dst->algring);491 p_SetCoeff(result, naCopy(a, src), dst->alg Ring);497 poly result = p_One(dst->algring); 498 p_SetCoeff(result, naCopy(a, src), dst->algring); 492 499 return (number)result; 493 500 } … … 499 506 int n = n_Int(a, src); 500 507 number q = n_Init(n, dst->algring->cf); 501 poly result = p_ Init(1,dst->algring);502 p_SetCoeff(result, q, dst->alg Ring);508 poly result = p_One(dst->algring); 509 p_SetCoeff(result, q, dst->algring); 503 510 return (number)result; 504 511 } … … 507 514 { 508 515 /* dst->cf is expected to be an (algebraic) extension field */ 509 assume(dst-> type == n_Ext);516 assume(dst->cf->type == n_Ext); 510 517 511 518 if (rField_is_Q(src) && rField_is_Q_a(dst)) … … 517 524 if (rField_is_Q_a(src) && rField_is_Q_a(dst)) 518 525 { 519 if (strcmp( src->parameter[0], dst->parameter[0]) == 0)526 if (strcmp(rParameter(src)[0], rParameter(dst)[0]) == 0) 520 527 return naCopyMap; /// Q(a) --> Q(a) 521 528 else … … 534 541 if (rField_is_Zp_a(src) && rField_is_Zp_a(dst)) 535 542 { 536 if (strcmp( src->parameter[0], dst->parameter[0]) == 0)543 if (strcmp(rParameter(src)[0], rParameter(dst)[0]) == 0) 537 544 return naCopyMap; /// Z/p(a) --> Z/p(a) 538 545 else … … 583 590 cf->cfSetMap = naSetMap; 584 591 cf->cfGetDenom = naGetDenom; 585 cf->cfGetNumerator = na Copy;592 cf->cfGetNumerator = naGetNumerator; 586 593 cf->cfRePart = naCopy; 587 594 cf->cfImPart = naImPart; -
libpolys/polys/ext_fields/algext.h
r3b0ba67 r0fb5991 64 64 number naRePart(number a, const coeffs cf); 65 65 number naImPart(number a, const coeffs cf); 66 number naGetDenom(number a, const coeffs cf);67 number naGetNumerator(number a, const coeffs cf);66 number naGetDenom(number &a, const coeffs cf); 67 number naGetNumerator(number &a, const coeffs cf); 68 68 number naGcd(number a, number b, const coeffs cf); 69 69 number naLcm(number a, number b, const coeffs cf);
Note: See TracChangeset
for help on using the changeset viewer.