Changeset ba2359 in git
- Timestamp:
- May 6, 2011, 2:38:32 PM (13 years ago)
- Branches:
- (u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
- Children:
- 69fb9d0d6c21f84c7aee223d5b4651e2fc1c7b7e
- Parents:
- fba6f18e59118e933bb2d9c5b69b31879517ddff
- git-author:
- Frank Seelisch <seelisch@mathematik.uni-kl.de>2011-05-06 14:38:32+02:00
- git-committer:
- Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:31:38+01:00
- Location:
- libpolys/polys
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/polys/ext_fields/algext.cc
rfba6f18 rba2359 36 36 37 37 #include <polys/ext_fields/algext.h> 38 39 /// our own type40 static const n_coeffType naID = n_Ext;41 42 /// polynomial ring in which our numbers live; to be set by naInitChar43 static ring naRing = NULL;44 45 /* coeffs object in which the coefficients of our numbers live;46 * to be set by naInitChar;47 * methods attached to naCoeffs may be used to compute with the48 * coefficients of our numbers, e.g., use naCoeffs->nAdd to add49 * coefficients of our numbers */50 static coeffs naCoeffs = NULL;51 52 /// minimal polynomial; to be set by naInitChar53 static poly naMinpoly = NULL;54 38 55 39 /// forward declarations … … 76 60 number naGetDenom(number a, const coeffs cf); 77 61 number naGetNumerator(number a, const coeffs cf); 78 number naGcd(number a, const coeffs cf);79 number naLcm(number a, const coeffs cf);80 numbernaSize(number a, const coeffs cf);62 number naGcd(number a, number b, const coeffs cf); 63 number naLcm(number a, number b, const coeffs cf); 64 int naSize(number a, const coeffs cf); 81 65 void naDelete(number *a, const coeffs cf); 82 66 void naCoeffWrite(const coeffs cf); 83 number naIntDiv(number a, number b, const coeffs r); 84 number naPar(int i, const coeffs r); 85 number naInit_bigint(number a, const coeffs src, const coeffs dst); 67 number naIntDiv(number a, number b, const coeffs cf); 86 68 const char * naRead(const char *s, number *a, const coeffs cf); 87 69 static BOOLEAN naCoeffIsEqual(const coeffs cf, n_coeffType n, void * param); 88 70 89 71 #ifdef LDEBUG 90 BOOLEAN naDBTest(number a, const char *f, const int l, const coeffs r)91 { 92 assume(getCoeffType( r) == naID);72 BOOLEAN naDBTest(number a, const char *f, const int l, const coeffs cf) 73 { 74 assume(getCoeffType(cf) == naID); 93 75 #ifdef LDEBUG 94 76 omCheckAddr(&a); 95 77 #endif 96 /// What else is there to test here?78 assume(p_Deg((poly)a, naRing) <= p_Deg(naMinpoly, naRing)); 97 79 return TRUE; 98 80 } 99 81 #endif 82 83 void heuristicReduce(poly p, poly reducer, const coeffs cf); 84 void definiteReduce(poly p, poly reducer, const coeffs cf); 100 85 101 86 BOOLEAN naIsZero(number a, const coeffs cf) … … 135 120 } 136 121 137 number naGetNumerator(number &a, const coeffs cf) 138 { 139 naTest(a); 122 number naCopy(number &a, const coeffs cf) 123 { 124 naTest(a); 125 if (a == NULL) return NULL; 140 126 return (number)p_Copy((poly)a, naRing); 141 127 } … … 167 153 if (a != NULL) a = (number)p_Neg((poly)a, naRing); 168 154 return a; 169 }170 171 number naRePart(number a, const coeffs cf)172 {173 naTest(a);174 return (number)p_Copy((poly)a, naRing);175 155 } 176 156 … … 225 205 } 226 206 227 ///////////////////////////////////////////////////////////////////// 228 /////// to be corrected --> ///////////////////////////////////////// 229 ///////////////////////////////////////////////////////////////////// 230 231 nMapFunc naSetMap(const coeffs src, const coeffs dst) 232 { 233 assume(dst->type == naID); 234 return NULL; 207 number naPar(int i, const coeffs cf) 208 { 209 assume(i == 1); // there is only one parameter in this extension field 210 poly p = p_ISet(1, naRing); // p = 1 211 p_SetExp(p, 1, 1, naRing); // p = the sole extension variable 212 p_Setm(p, naRing); 213 return (number)p; 214 } 215 216 number naAdd(number a, number b, const coeffs cf) 217 { 218 naTest(a); naTest(b); 219 if (a == NULL) return naCopy(b, cf); 220 if (b == NULL) return naCopy(a, cf); 221 poly aPlusB = p_Add_q(p_Copy((poly)a, naRing), 222 p_Copy((poly)b, naRing), naRing); 223 definiteReduce(aPlusB, naMinpoly); 224 return (number)aMinusB; 235 225 } 236 226 237 227 number naSub(number a, number b, const coeffs cf) 238 228 { 239 return naInit(17, cf); 240 } 241 242 ///////////////////////////////////////////////////////////////////// 243 /////// <-- to be corrected ///////////////////////////////////////// 244 ///////////////////////////////////////////////////////////////////// 245 246 BOOLEAN naInitChar(coeffs cf, void* infoStruct) 229 naTest(a); naTest(b); 230 if (b == NULL) return naCopy(a, cf); 231 poly minusB = p_Neg(p_Copy((poly)b, naRing), naRing); 232 if (a == NULL) return minusB; 233 poly aMinusB = p_Add_q(p_Copy((poly)a, naRing), minusB, naRing); 234 definiteReduce(aMinusB, naMinpoly); 235 return (number)aMinusB; 236 } 237 238 number naMult(number a, number b, const coeffs cf) 239 { 240 naTest(a); naTest(b); 241 if (a == NULL) return NULL; 242 if (b == NULL) return NULL; 243 poly aTimesB = p_Mult_q(p_Copy((poly)a, naRing), 244 p_Copy((poly)b, naRing), naRing); 245 definiteReduce(aTimesB, naMinpoly); 246 return (number)aMinusB; 247 } 248 249 number naDiv(number a, number b, const coeffs cf) 250 { 251 naTest(a); naTest(b); 252 if (b == NULL) WerrorS(nDivBy0); 253 if (a == NULL) return NULL; 254 poly bInverse = (poly)naInvers(b, cf); 255 poly aDivB = p_Mult_q(p_Copy((poly)a, naRing), bInverse, naRing); 256 definiteReduce(aDivB, naMinpoly); 257 return (number)aMinusB; 258 } 259 260 /* 0^0 = 0; 261 for |exp| <= 7 compute power by a simple multiplication loop; 262 for |exp| >= 8 compute power along binary presentation of |exp|, e.g. 263 p^13 = p^1 * p^4 * p^8, where we utilise that 264 p^(2^(k+1)) = p^(2^k) * p^(2^k) 265 intermediate reduction modulo the minimal polynomial is controlled by 266 the in-place method heuristicReduce(poly, poly, coeffs); see there. 267 */ 268 void naPower(number a, int exp, number *b, const coeffs cf) 269 { 270 naTest(a); 271 272 /* special cases first */ 273 if (a == NULL) 274 { 275 if (exp >= 0) return NULL; 276 else WerrorS(nDivBy0); 277 } 278 else if (exp == 0) return naInit(1, cf); 279 else if (exp == 1) return naCopy(a, cf); 280 else if (exp == -1) return naInvers(a, cf); 281 282 int expAbs = exp; if (expAbs < 0) expAbs = -expAbs; 283 284 /* now compute 'a' to the 'expAbs'-th power */ 285 poly pow; poly aAsPoly = (poly)a; 286 if (expAbs <= 7) 287 { 288 pow = p_Copy(aAsPoly, naRing); 289 for (int i = 2; i <= expAbs; i++) 290 { 291 pow = p_Mult_q(pow, p_Copy(aAsPoly, naRing), naRing); 292 heuristicReduce(pow, naMinpoly, cf); 293 } 294 definiteReduce(pow, naMinpoly, cf); 295 } 296 else 297 { 298 pow = p_ISet(1, naRing); 299 poly factor = p_Copy(aAsPoly, naRing); 300 while (expAbs != 0) 301 { 302 if (expAbs & 1) 303 { 304 pow = p_Mult_q(pow, p_Copy(factor, naRing), naRing); 305 heuristicReduce(pow, naMinpoly, cf); 306 } 307 expAbs = expAbs / 2; 308 if (expAbs != 0) 309 { 310 factor = p_Mult_q(factor, factor, naRing); 311 heuristicReduce(factor, naMinpoly, cf); 312 } 313 } 314 p_Delete(factor, naRing); 315 definiteReduce(pow, naMinpoly, cf); 316 } 317 318 /* invert if original exponent was negative */ 319 number n = (number)pow; 320 if (exp < 0) 321 { 322 number m = naInvers(n, cf); 323 naDelete(&n, cf); 324 n = m; 325 } 326 *b = n; 327 } 328 329 /* may reduce p module the reducer by calling definiteReduce; 330 the decision is made based on the following heuristic 331 (which should also only be changed here in this method): 332 if (deg(p) > 10*deg(reducer) then perform reduction */ 333 void heuristicReduce(poly p, poly reducer, const coeffs cf) 334 { 335 #ifdef LDEBUG 336 omCheckAddr(p); omCheckAddr(reducer); 337 #endif 338 if (p_Deg(p, naRing) > 10 * p_Deg(reducer, naRing)) 339 definiteReduce(p, reducer, cf); 340 } 341 342 void naWrite(number &a, const coeffs cf) 343 { 344 naTest(a); 345 if (a == NULL) 346 StringAppendS("0"); 347 else 348 { 349 poly aAsPoly = (poly)a; 350 /* basically, just write aAsPoly using p_Write, 351 but use brackets around the output, if a is not 352 a constant living in naCoeffs = cf->algring->cf */ 353 BOOLEAN useBrackets = TRUE; 354 if (p_Deg(aAsPoly, naRing) == 0) useBrackets = FALSE; 355 if (useBrackets) StringAppendS("("); 356 p_Write(aAsPoly, naRing); 357 if (useBrackets) StringAppendS(")"); 358 } 359 } 360 361 const char * naRead(const char *s, number *a, const coeffs cf) 362 { 363 poly aAsPoly; 364 const char * result = p_Read(s, aAsPoly, naRing); 365 *a = (number)aAsPoly; 366 return result; 367 } 368 369 /* implemented by the rule lcm(a, b) = a * b / gcd(a, b) */ 370 number naLcm(number a, number b, const coeffs cf) 371 { 372 naTest(a); naTest(b); 373 if (a == NULL) return NULL; 374 if (b == NULL) return NULL; 375 number theProduct = (number)p_Mult_q(p_Copy((poly)a, naRing), 376 p_Copy((poly)b, naRing), naRing); 377 /* note that theProduct needs not be reduced w.r.t. naMinpoly; 378 but the final division will take care of the necessary reduction */ 379 number theGcd = naGcd(a, b, cf); 380 return naDiv(product, theGcd); 381 } 382 383 /* expects *param to be castable to ExtInfo */ 384 static BOOLEAN naCoeffIsEqual(const coeffs cf, n_coeffType n, void * param) 385 { 386 if (naID != n) return FALSE; 387 ExtInfo *e = (ExtInfo *)param; 388 /* for extension coefficient fields we expect the underlying 389 polynomials rings to be IDENTICAL, i.e. the SAME OBJECT; 390 this expectation is based on the assumption that we have properly 391 registered cf and perform reference counting rather than creating 392 multiple copies of the same coefficient field/domain/ring */ 393 return (naRing == e->r); 394 /* (Note that then also the minimal ideals will necessarily be 395 the same, as they are attached to the ring.) */ 396 } 397 398 int naSize(number a, const coeffs cf) 399 { 400 if (a == NULL) return -1; 401 /* this has been taken from the old implementation of field extensions, 402 where we computed the sum of the degree and the number of terms in 403 (poly)a; so we leave it at that, for the time being; 404 maybe, the number of terms alone is a better measure? */ 405 poly aAsPoly = (poly)a; 406 int theDegree = 0; int noOfTerms = 0; 407 while (aAsPoly != NULL) 408 { 409 noOfTerms++; 410 int d = 0; 411 for (int i = 1; i <= rVar(r); i++) d += p_GetExp(aAsPoly, i, naRing); 412 if (d > theDegree) theDegree = d; 413 pIter(aAsPoly); 414 } 415 return theDegree + noOfTerms; 416 } 417 418 /* performs polynomial division and overrides p by the remainder 419 of division of p by the reducer */ 420 void definiteReduce(poly p, poly reducer, const coeffs cf) 421 { 422 #ifdef LDEBUG 423 omCheckAddr(p); omCheckAddr(reducer); 424 #endif 425 p_PolyDiv(*p, reducer, FALSE, naRing); 426 } 427 428 number naGcd(number a, number b, const coeffs cf) 429 { 430 naTest(a); naTest(b); 431 if ((a == NULL) && (b == NULL)) WerrorS(nDivBy0); 432 return (number)p_Gcd((poly)a, (poly)b, naRing); 433 } 434 435 number naInvers(number a, const coeffs cf) 436 { 437 naTest(a); 438 if (a == NULL) WerrorS(nDivBy0); 439 poly *aFactor; poly *mFactor; 440 poly theGcd = p_ExtGcd((poly)a, *aFactor, naMinpoly, *mFactor, naRing); 441 /* the gcd must be one since naMinpoly is irreducible and a != NULL: */ 442 assume(naIsOne(theGcd, cf)); 443 pDelete(&theGcd, naRing); 444 pDelete(mFactor, naRing); 445 return aInverse = (number)(*aFactor); 446 } 447 448 /* assumes that src = Q, dst = Q(a) */ 449 number naMap00(number a, const coeffs src, const coeffs dst) 450 { 451 assume(src == dst->algring->cf); 452 poly result = p_Init(1, dst->algring); 453 p_SetCoeff(result, naCopy(a, src), dst->algRing); 454 return (number)result; 455 } 456 457 /* assumes that src = Z/p, dst = Q(a) */ 458 number naMapP0(number a, const coeffs src, const coeffs dst) 459 { 460 /* mapping via intermediate int: */ 461 int n = n_Int(a, src); 462 number q = n_Init(n, dst->algring->cf); 463 poly result = p_Init(1, dst->algring); 464 p_SetCoeff(result, q, dst->algRing); 465 return (number)result; 466 } 467 468 /* assumes that either src = Q(a), dst = Q(a), or 469 src = Zp(a), dst = Zp(a) */ 470 number naCopyMap(number a, const coeffs src, const coeffs dst) 471 { 472 return naCopy(a, dst); 473 } 474 475 /* assumes that src = Q, dst = Z/p(a) */ 476 number naMap0P(number a, const coeffs src, const coeffs dst) 477 { 478 int p = rChar(dst); 479 int n = nlModP(a, p, src); 480 number q = n_Init(n, dst->algring->cf); 481 poly result = p_Init(1, dst->algring); 482 p_SetCoeff(result, q, dst->algRing); 483 return (number)result; 484 } 485 486 /* assumes that src = Z/p, dst = Z/p(a) */ 487 number naMapPP(number a, const coeffs src, const coeffs dst) 488 { 489 assume(src == dst->algring->cf); 490 poly result = p_Init(1, dst->algring); 491 p_SetCoeff(result, naCopy(a, src), dst->algRing); 492 return (number)result; 493 } 494 495 /* assumes that src = Z/u, dst = Z/p(a), where u != p */ 496 number naMapUP(number a, const coeffs src, const coeffs dst) 497 { 498 /* mapping via intermediate int: */ 499 int n = n_Int(a, src); 500 number q = n_Init(n, dst->algring->cf); 501 poly result = p_Init(1, dst->algring); 502 p_SetCoeff(result, q, dst->algRing); 503 return (number)result; 504 } 505 506 nMapFunc naSetMap(const ring src, const ring dst) 507 { 508 /* dst->cf is expected to be an (algebraic) extension field */ 509 assume(dst->type == n_Ext); 510 511 if (rField_is_Q(src) && rField_is_Q_a(dst)) 512 return naMap00; /// Q --> Q(a) 513 514 if (rField_is_Zp(src) && rField_is_Q_a(dst)) 515 return naMapP0; /// Z/p --> Q(a) 516 517 if (rField_is_Q_a(src) && rField_is_Q_a(dst)) 518 { 519 if (strcmp(src->parameter[0], dst->parameter[0]) == 0) 520 return naCopyMap; /// Q(a) --> Q(a) 521 else 522 return NULL; /// Q(b) --> Q(a) 523 } 524 525 if (rField_is_Q(src) && rField_is_Zp_a(dst)) 526 return naMap0P; /// Q --> Z/p(a) 527 528 if (rField_is_Zp(src) && rField_is_Zp_a(dst)) 529 { 530 if (rChar(src) == rChar(dst)) return naMapPP; /// Z/p --> Z/p(a) 531 else return naMapUP; /// Z/u --> Z/p(a) 532 } 533 534 if (rField_is_Zp_a(src) && rField_is_Zp_a(dst)) 535 { 536 if (strcmp(src->parameter[0], dst->parameter[0]) == 0) 537 return naCopyMap; /// Z/p(a) --> Z/p(a) 538 else 539 return NULL; /// Z/p(b) --> Z/p(a) 540 } 541 542 return NULL; /// default 543 } 544 545 BOOLEAN naInitChar(coeffs cf, void * infoStruct) 247 546 { 248 547 ExtInfo *e = (ExtInfo *)infoStruct; … … 258 557 assume(getCoeffType(cf) == naID); // coeff type; 259 558 260 naRing = cf->algring;261 naCoeffs = cf->algring->cf;262 naMinpoly = naRing->minideal->m[0];263 559 #ifdef LDEBUG 264 560 omCheckAddr(naMinpoly); … … 274 570 cf->cfInt = naInt; 275 571 cf->cfNeg = naNeg; 276 cf->cfInvers = NULL; //naInvers; 277 cf->cfPar = NULL; //naPar; 278 cf->cfAdd = NULL; //naAdd; 572 cf->cfPar = naPar; 573 cf->cfAdd = naAdd; 279 574 cf->cfSub = naSub; 280 cf->cfMult = NULL; //naMult;281 cf->cfDiv = NULL; //naDiv;282 cf->cfExactDiv = NULL; //just write here 'naDiv' when naDiv is available;283 cf->cfPower = NULL; //naPower;284 cf->cfCopy = NULL; //naCopy;285 cf->cfWrite = NULL; //naWrite;286 cf->cfRead = NULL; //naRead;575 cf->cfMult = naMult; 576 cf->cfDiv = naDiv; 577 cf->cfExactDiv = naDiv; 578 cf->cfPower = naPower; 579 cf->cfCopy = naCopy; 580 cf->cfWrite = naWrite; 581 cf->cfRead = naRead; 287 582 cf->cfDelete = naDelete; 288 583 cf->cfSetMap = naSetMap; 289 584 cf->cfGetDenom = naGetDenom; 290 cf->cfGetNumerator = na GetNumerator;291 cf->cfRePart = na RePart;585 cf->cfGetNumerator = naCopy; 586 cf->cfRePart = naCopy; 292 587 cf->cfImPart = naImPart; 293 cf->cfGcd = NULL; //naGcd;294 cf->cfLcm = NULL; //naLcm;295 cf->cfCoeffWrite = NULL; //naCoeffWrite;296 cf->cfSize = NULL; //naSize;297 588 cf->cfCoeffWrite = naCoeffWrite; 298 cf->nCoeffIsEqual = NULL; //naCoeffIsEqual;299 cf->cfIntDiv = NULL; //naCoeffIsEqual;300 cf->cfPar = NULL; //naPar;301 589 cf->cfDBTest = naDBTest; 302 cf->cfInit_bigint = NULL; //naInit_bigint; 590 cf->cfGcd = naGcd; 591 cf->cfLcm = naLcm; 592 cf->cfSize = naSize; 593 cf->nCoeffIsEqual = naCoeffIsEqual; 594 cf->cfInvers = naInvers; 595 cf->cfIntDiv = naDiv; 303 596 304 597 return FALSE; -
libpolys/polys/ext_fields/algext.h
rfba6f18 rba2359 66 66 number naGetDenom(number a, const coeffs cf); 67 67 number naGetNumerator(number a, const coeffs cf); 68 number naGcd(number a, const coeffs cf);69 number naLcm(number a, const coeffs cf);68 number naGcd(number a, number b, const coeffs cf); 69 number naLcm(number a, number b, const coeffs cf); 70 70 number naSize(number a, const coeffs cf); 71 71 void naDelete(number *a, const coeffs cf); 72 72 void naCoeffWrite(const coeffs cf); 73 number naIntDiv(number a, number b, const coeffs r); 74 number naPar(int i, const coeffs r); 75 number naInit_bigint(number a, const coeffs src, const coeffs dst); 73 number naIntDiv(number a, number b, const coeffs cf); 76 74 const char * naRead(const char *s, number *a, const coeffs cf); 77 75 static BOOLEAN naCoeffIsEqual(const coeffs cf, n_coeffType n, void * param); … … 85 83 #endif 86 84 85 /* our own type */ 86 #define naID n_Ext 87 88 /* polynomial ring in which our numbers live */ 89 #define naRing cf->algring 90 91 /* coeffs object in which the coefficients of our numbers live; 92 * methods attached to naCoeffs may be used to compute with the 93 * coefficients of our numbers, e.g., use naCoeffs->nAdd to add 94 * coefficients of our numbers */ 95 #define naCoeffs cf->algring->cf 96 97 /* minimal polynomial */ 98 #define naMinpoly naRing->minideal->m[0] 99 87 100 #endif 88 101 /* ALGEXT_H */ -
libpolys/polys/monomials/p_polys.cc
rfba6f18 rba2359 1430 1430 p_SetComp(m, si_max(p_GetComp(a,r), p_GetComp(b,r)),r); 1431 1431 /* Don't do a pSetm here, otherwise hres/lres chockes */ 1432 } 1433 1434 /* assumes that *p and divisor are univariate polynomials in r, 1435 mentioning the same variable; 1436 assumes divisor != NULL; 1437 *p may be NULL; 1438 assumes a global monomial ordering in r; 1439 performs polynomial division of *p by divisor: 1440 - afterwards *p contains the remainder of the division, i.e., 1441 *p_before = result * divisor + *p_afterwards; 1442 - if needResult == TRUE, then the method computes and returns 'result', 1443 otherwise NULL is returned (This parametrization can be used when 1444 one is only interested in the remainder of the division. In this 1445 case, the method will be faster.) */ 1446 poly p_PolyDiv(poly *p, poly divisor, BOOLEAN needResult, ring r) 1447 { 1448 assume(divisor != NULL); 1449 if (*p == NULL) return NULL; 1450 1451 /* yet to be implemented by Frank S.; 1452 for the time being, this should at least compile */ 1453 return NULL; 1454 } 1455 1456 /* assumes that p and q are univariate polynomials in r, 1457 mentioning the same variable; 1458 assumes a global monomial ordering in r; 1459 assumes that not both p and q are NULL; 1460 returns the gcd of p and q */ 1461 poly p_Gcd(poly p, poly q, ring r) 1462 { 1463 assume((p != NULL) || (q != NULL)); 1464 if (p == NULL) return q; 1465 if (q == NULL) return p; 1466 1467 /* yet to be implemented by Frank S.; 1468 for the time being, this should at least compile */ 1469 return NULL; 1470 } 1471 1472 /* assumes that p and q are univariate polynomials in r, 1473 mentioning the same variable; 1474 assumes a global monomial ordering in r; 1475 assumes that not both p and q are NULL; 1476 returns the gcd of p and q; 1477 moreover, afterwards *pFactor and *qFactor contain appropriate 1478 factors such that gcd(p, q) = p * (*pFactor) + q * (*qFactor) */ 1479 poly p_ExtGcd(poly p, poly *pFactor, poly q, poly *qFactor, ring r) 1480 { 1481 assume((p != NULL) || (q != NULL)); 1482 if (p == NULL) { *pFactor = NULL; *qFactor = p_ISet(1, r); return q; }; 1483 if (q == NULL) { *qFactor = NULL; *pFactor = p_ISet(1, r); return p; }; 1484 1485 /* yet to be implemented by Frank S.; 1486 for the time being, this should at least compile */ 1487 return NULL; 1432 1488 } 1433 1489 -
libpolys/polys/monomials/p_polys.h
rfba6f18 rba2359 214 214 ***************************************************************/ 215 215 /*2 216 * returns the length of a (numbers of monomials)216 * returns the length of a polynomial (numbers of monomials) 217 217 */ 218 218 static inline int pLength(poly a) … … 361 361 ***************************************************************/ 362 362 363 // returns the length of a (numbers of monomials)363 // returns the length of a polynomial (numbers of monomials) 364 364 // respect syzComp 365 365 // static inline poly pLast(poly a, int &length); … … 1808 1808 int p_Weight(int c, const ring r); 1809 1809 1810 /* assumes that *p and divisor are univariate polynomials in r, 1811 mentioning the same variable; 1812 assumes divisor != NULL; 1813 *p may be NULL; 1814 assumes a global monomial ordering in r; 1815 performs polynomial division of *p by divisor: 1816 - afterwards *p contains the remainder of the division, i.e., 1817 *p_before = result * divisor + *p_afterwards; 1818 - if needResult == TRUE, then the method computes and returns 'result', 1819 otherwise NULL is returned (This parametrization can be used when 1820 one is only interested in the remainder of the division. In this 1821 case, the method will be faster.) */ 1822 poly p_PolyDiv(poly *p, poly divisor, BOOLEAN needResult, ring r); 1823 1824 /* assumes that p and q are univariate polynomials in r, 1825 mentioning the same variable; 1826 assumes a global monomial ordering in r; 1827 assumes that not both p and q are NULL; 1828 returns the gcd of p and q */ 1829 poly p_Gcd(poly p, poly q, ring r); 1830 1831 /* assumes that p and q are univariate polynomials in r, 1832 mentioning the same variable; 1833 assumes a global monomial ordering in r; 1834 assumes that not both p and q are NULL; 1835 returns the gcd of p and q; 1836 moreover, afterwards *pFactor and *qFactor contain appropriate 1837 factors such that gcd(p, q) = p * (*pFactor) + q * (*qFactor) */ 1838 poly p_ExtGcd(poly p, poly *pFactor, poly q, poly *qFactor, ring r); 1839 1810 1840 /* syszygy stuff */ 1811 1841 BOOLEAN p_VectorHasUnitB(poly p, int * k, const ring r);
Note: See TracChangeset
for help on using the changeset viewer.