Changeset 010f3b in git
- Timestamp:
- Jun 29, 2011, 5:54:28 PM (12 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- df43d9eede47de2604d4c0ff334af81427c1ec57
- Parents:
- de90c019d739dd11bb7004ab4f6d1147833c69bc
- git-author:
- Frank Seelisch <seelisch@mathematik.uni-kl.de>2011-06-29 17:54:28+02:00
- git-committer:
- Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:39:10+01:00
- Location:
- libpolys
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/polys/ext_fields/transext.cc
rde90c01 r010f3b 66 66 67 67 void heuristicGcdCancellation(number a, const coeffs cf); 68 void definiteGcdCancellation(number a, const coeffs cf); 68 void definiteGcdCancellation(number a, const coeffs cf, 69 BOOLEAN skipSimpleTests); 69 70 70 71 #ifdef LDEBUG … … 175 176 { 176 177 ntTest(a); 177 definiteGcdCancellation(a, cf );178 definiteGcdCancellation(a, cf, FALSE); 178 179 if (is0(a)) return NULL; 179 180 fraction f = (fraction)a; … … 189 190 { 190 191 ntTest(a); 191 definiteGcdCancellation(a, cf );192 definiteGcdCancellation(a, cf, FALSE); 192 193 fraction f = (fraction)a; 193 194 poly g; … … 204 205 { 205 206 ntTest(a); 206 definiteGcdCancellation(a, cf); 207 fraction f = (fraction)a; 208 if (!denIs1(f)) return FALSE; 209 poly g = num(f); 210 if (!p_IsConstant(g, ntRing)) return FALSE; 211 return n_IsOne(p_GetCoeff(g, ntRing), ntCoeffs); 207 definiteGcdCancellation(a, cf, FALSE); 208 fraction f = (fraction)a; 209 return denIs1(f) && numIs1(f); 212 210 } 213 211 … … 215 213 { 216 214 ntTest(a); 217 definiteGcdCancellation(a, cf );215 definiteGcdCancellation(a, cf, FALSE); 218 216 fraction f = (fraction)a; 219 217 if (!denIs1(f)) return FALSE; … … 258 256 ntTest(a); 259 257 if (is0(a)) return 0; 260 definiteGcdCancellation(a, cf );258 definiteGcdCancellation(a, cf, FALSE); 261 259 fraction f = (fraction)a; 262 260 if (!denIs1(f)) return 0; … … 532 530 ntTest(a); 533 531 if (is0(a)) return; 534 fraction f = (fraction)a; 535 if (denIs1(f) || n_IsOne(p_GetCoeff(num(f), ntRing), ntCoeffs)) 536 { c(f) = 0; return; } 532 533 fraction f = (fraction)a; 534 if (denIs1(f) || numIs1(f)) { c(f) = 0; return; } 535 536 /* check whether num(f) = den(f), and - if so - replace 'a' by 1 */ 537 poly difference = p_Add_q(p_Copy(num(f), ntRing), 538 p_Neg(p_Copy(den(f), ntRing), ntRing), 539 ntRing); 540 if (difference == NULL) 541 { /* we also know that numerator and denominator are both != 1 */ 542 p_Delete(&num(f), ntRing); num(f) = p_ISet(1, ntRing); 543 p_Delete(&den(f), ntRing); den(f) = NULL; 544 c(f) = 0; 545 return; 546 } 547 else p_Delete(&difference, ntRing); 548 537 549 if (c(f) <= BOUND_COMPLEXITY) return; 538 else definiteGcdCancellation(a, cf );550 else definiteGcdCancellation(a, cf, TRUE); 539 551 } 540 552 541 553 /* modifies a */ 542 void definiteGcdCancellation(number a, const coeffs cf) 543 { 544 ntTest(a); 545 if (is0(a)) return; 546 fraction f = (fraction)a; 547 if (denIs1(f) || n_IsOne(p_GetCoeff(num(f), ntRing), ntCoeffs)) 548 { c(f) = 0; return; } 549 if (c(f) > BOUND_COMPLEXITY) 550 { 551 /* TO BE IMPLEMENTED! 552 for the time, cancellation of gcd's does not take place */ 553 Print("// TO BE IMPLEMENTED: transext.cc:definiteGcdCancellation\n"); 554 Print("// (complexity of number = %d exceeds the bound = %d\n", 555 c(f), BOUND_COMPLEXITY); 556 } 554 void definiteGcdCancellation(number a, const coeffs cf, 555 BOOLEAN skipSimpleTests) 556 { 557 ntTest(a); 558 559 fraction f = (fraction)a; 560 561 if (!skipSimpleTests) 562 { 563 if (is0(a)) return; 564 if (denIs1(f) || numIs1(f)) { c(f) = 0; return; } 565 566 /* check whether num(f) = den(f), and - if so - replace 'a' by 1 */ 567 poly difference = p_Add_q(p_Copy(num(f), ntRing), 568 p_Neg(p_Copy(den(f), ntRing), ntRing), 569 ntRing); 570 if (difference == NULL) 571 { /* we also know that numerator and denominator are both != 1 */ 572 p_Delete(&num(f), ntRing); num(f) = p_ISet(1, ntRing); 573 p_Delete(&den(f), ntRing); den(f) = NULL; 574 c(f) = 0; 575 return; 576 } 577 else p_Delete(&difference, ntRing); 578 } 579 580 /* TO BE IMPLEMENTED! 581 for the time being, cancellation of gcd's does not take place */ 582 Print("// TO BE IMPLEMENTED: transext.cc:definiteGcdCancellation\n"); 583 Print("// (complexity of number = %d, bound = %d)\n", 584 c(f), BOUND_COMPLEXITY); 557 585 } 558 586 … … 560 588 { 561 589 ntTest(a); 562 definiteGcdCancellation(a, cf );590 definiteGcdCancellation(a, cf, FALSE); 563 591 if (is0(a)) 564 592 StringAppendS("0"); -
libpolys/polys/ext_fields/transext.h
rde90c01 r010f3b 63 63 #define den(f) f->denominator 64 64 #define denIs1(f) (f->denominator == NULL) /**< TRUE iff den. represents 1 */ 65 #define numIs1(f) (p_IsConstant(f->numerator, cf->extRing) && \ 66 n_IsOne(p_GetCoeff(num(f), cf->extRing), cf->extRing->cf)) 67 /**< TRUE iff num. represents 1 */ 65 68 #define c(f) f->complexity 66 69 -
libpolys/tests/polys_test.h
rde90c01 r010f3b 231 231 TS_ASSERT( n_IsOne(n2, cf) ); 232 232 n_Delete(&n1, cf); n_Delete(&n2, cf); 233 } 234 /* assumes that cf represents a rational function field; 235 does NOT copy p, i.e. uses p directly inside the resulting number */ 236 number toFractionNumber(poly p, const coeffs cf) 237 { 238 number n = n_Init(1, cf); 239 fraction f = (fraction)n; 240 p_Delete(&(f->numerator), cf->extRing); 241 f->numerator = p; 242 return n; 233 243 } 234 244 void TestArithCf(const coeffs r) … … 933 943 Test(s); 934 944 945 /* some special tests: */ 946 poly v1 = NULL; 947 plusTerm(v1, 1, 1, 1, cf->extRing); // s 948 plusTerm(v1, 1, 1, 0, cf->extRing); // s + 1 949 poly v2 = NULL; 950 plusTerm(v2, 1, 1, 1, cf->extRing); // s 951 plusTerm(v2, 2, 2, 1, cf->extRing); // s + 2t 952 poly v = p_Mult_q(v1, v2, cf->extRing); // (s + 1) * (s + 2t) 953 number v_n = toFractionNumber(v, cf); 954 PrintSized(v_n, cf); 955 poly w = NULL; 956 plusTerm(w, 1, 1, 1, cf->extRing); // s 957 plusTerm(w, 1, 1, 0, cf->extRing); // s + 1 958 number w_n = toFractionNumber(w, cf); 959 PrintSized(w_n, cf); 960 number vOverW_n = n_Div(v_n, w_n, cf); 961 PrintSized(vOverW_n, cf); 962 number wOverV_n = n_Invers(vOverW_n, cf); 963 PrintSized(wOverV_n, cf); 964 number prod = n_Mult(vOverW_n, wOverV_n, cf); 965 PrintSized(prod, cf); 966 number tmp; number nn = n_Copy(vOverW_n, cf); 967 for (int i = 1; i <= 20; i++) 968 { 969 tmp = n_Div(nn, v_n, cf); 970 n_Delete(&nn, cf); 971 nn = tmp; 972 clog << i << ". "; PrintSized(nn, cf); 973 } 974 n_Delete(&prod, cf); n_Delete(&nn, cf); 975 n_Delete(&v_n, cf); n_Delete(&w_n, cf); 976 n_Delete(&vOverW_n, cf); n_Delete(&wOverV_n, cf); 977 935 978 rDelete(s); // kills 'cf' and 'r' as well 936 979 }
Note: See TracChangeset
for help on using the changeset viewer.