Changeset 3f7e6ee in git for libpolys/polys/ext_fields/transext.cc
- Timestamp:
- Sep 9, 2013, 4:37:38 PM (11 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- fc5f58cad717ce5735572253f71f32b365e53989
- Parents:
- ba49bf104d6b7507ed3b20c7e82c411b63cd90c3
- git-author:
- Hans Schoenemann <hannes@mathematik.uni-kl.de>2013-09-09 16:37:38+02:00
- git-committer:
- Janko Boehm <boehm@mathematik.uni-kl.de>2013-09-10 15:30:18+02:00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/polys/ext_fields/transext.cc
rba49bf1 r3f7e6ee 141 141 void handleNestedFractionsOverQ(fraction f, const coeffs cf); 142 142 143 /* test routine, usualy disabled * 144 * if want to activate it, activate also the calls to check_N * 145 * 146 void check_normalized(number t,const coeffs cf, const char *f, int l) 147 { 148 if (IS0(t)) return; 149 if(rField_is_Q(ntRing)) 150 { 151 poly pp=NUM(t); 152 while(pp!=NULL) 153 { 154 if (((SR_HDL(pGetCoeff(pp)) & SR_INT)==0)&&(SR_HDL(pGetCoeff(pp))!=NULL)) 155 { 156 if (pGetCoeff(pp)->s==0) 157 { 158 Print("NUM not normalized in %s:%d\n",f,l); 159 p_Normalize(pp,ntRing); 160 } 161 else if (pGetCoeff(pp)->s==1) 162 Print("NUM is rational in %s:%d\n",f,l); 163 } 164 pIter(pp); 165 } 166 pp=DEN(t); 167 while(pp!=NULL) 168 { 169 if (((SR_HDL(pGetCoeff(pp)) & SR_INT)==0)&&(SR_HDL(pGetCoeff(pp))!=NULL)) 170 { 171 if (pGetCoeff(pp)->s==0) 172 { 173 Print("NUM not normalized in %s:%d\n",f,l); 174 p_Normalize(pp,ntRing); 175 } 176 else if (pGetCoeff(pp)->s==1) 177 Print("DEN is rational in %s:%d\n",f,l); 178 } 179 pIter(pp); 180 } 181 } 182 } 183 #define check_N(A,B) check_normalized(A,B,__FILE__,__LINE__) 184 */ 185 143 186 #ifdef LDEBUG 144 187 BOOLEAN ntDBTest(number a, const char *f, const int l, const coeffs cf) … … 150 193 const fraction t = (fraction)a; 151 194 195 //check_N(a,cf); 152 196 const poly num = NUM(t); 153 197 assume(num != NULL); /**< t != 0 ==> numerator(t) != 0 */ … … 240 284 BOOLEAN ntIsZero(number a, const coeffs cf) 241 285 { 286 //check_N(a,cf); 242 287 ntTest(a); // !!! 243 288 return (IS0(a)); … … 246 291 void ntDelete(number * a, const coeffs cf) 247 292 { 293 //check_N(*a,cf); 248 294 ntTest(*a); // !!! 249 295 fraction f = (fraction)(*a); … … 257 303 BOOLEAN ntEqual(number a, number b, const coeffs cf) 258 304 { 305 //check_N(a,cf); 306 //check_N(b,cf); 259 307 ntTest(a); 260 308 ntTest(b); … … 301 349 number ntCopy(number a, const coeffs cf) 302 350 { 351 //check_N(a,cf); 303 352 ntTest(a); // !!! 304 353 if (IS0(a)) return NULL; … … 317 366 number ntGetNumerator(number &a, const coeffs cf) 318 367 { 368 //check_N(a,cf); 319 369 ntTest(a); 320 370 if (IS0(a)) return NULL; … … 370 420 371 421 ntTest((number)result); 422 //check_N((number)result,cf); 372 423 return (number)result; 373 424 } … … 376 427 number ntGetDenom(number &a, const coeffs cf) 377 428 { 429 //check_N(a,cf); 378 430 ntTest(a); 379 431 … … 382 434 COM (result)= 0; 383 435 384 if (IS0(a)) 436 if (IS0(a)) 385 437 { 386 438 NUM (result) = p_One(ntRing); 387 439 return (number)result; 388 440 } 389 441 390 442 definiteGcdCancellation(a, cf, FALSE); 391 443 392 444 fraction f = (fraction)a; 393 445 394 446 assume( !IS0(f) ); 395 447 396 448 const BOOLEAN denis1 = DENIS1 (f); 397 449 398 450 if( denis1 && (getCoeffType (ntCoeffs) != n_Q) ) // */1 or 0 399 451 { … … 471 523 472 524 ntTest((number)result); 525 //check_N((number)result,cf); 473 526 return (number)result; 474 527 } … … 476 529 BOOLEAN ntIsOne(number a, const coeffs cf) 477 530 { 531 //check_N(a,cf); 478 532 ntTest(a); // !!! 479 533 definiteGcdCancellation(a, cf, FALSE); … … 484 538 BOOLEAN ntIsMOne(number a, const coeffs cf) 485 539 { 540 //check_N(a,cf); 486 541 ntTest(a); 487 542 definiteGcdCancellation(a, cf, FALSE); … … 496 551 number ntNeg(number a, const coeffs cf) 497 552 { 553 //check_N(a,cf); 498 554 ntTest(a); 499 555 if (!IS0(a)) … … 553 609 554 610 ntTest((number)result); 611 //check_N((number)result,cf); 555 612 556 613 return (number)result; … … 570 627 //COM(result) = 0; // done by omAlloc0Bin 571 628 ntTest((number)result); 629 //check_N((number)result,cf); 572 630 return (number)result; 573 631 } … … 587 645 { 588 646 number g; 589 // TODO/NOTE: the following should not be necessary (due to590 // Hannes!) as NUM (f) should be over Z!!!591 // but it is not: normalize it647 // the following is necessary because 648 // NUM (f) should be over Z, 649 // while p may be over Q 592 650 CPolyCoeffsEnumerator itr(p); 593 651 … … 606 664 { 607 665 DEN (f) = p_NSet(g, ntRing); 666 p_Normalize(DEN(f), ntRing); 608 667 assume( DEN (f) != NULL ); 609 668 } … … 615 674 } 616 675 676 p_Normalize(p, ntRing); 617 677 NUM(f) = p; 618 678 COM(f) = 0; 619 679 680 //check_N((number)f,cf); 620 681 ntTest((number)f); 621 682 return (number)f; … … 624 685 int ntInt(number &a, const coeffs cf) 625 686 { 687 //check_N(a,cf); 626 688 ntTest(a); 627 689 if (IS0(a)) return 0; … … 651 713 BOOLEAN ntGreater(number a, number b, const coeffs cf) 652 714 { 715 //check_N(a,cf); 716 //check_N(b,cf); 653 717 ntTest(a); 654 718 ntTest(b); … … 702 766 BOOLEAN ntGreaterZero(number a, const coeffs cf) 703 767 { 768 //check_N(a,cf); 704 769 ntTest(a); 705 770 if (IS0(a)) return FALSE; … … 749 814 number ntDiff(number a, number d, const coeffs cf) 750 815 { 816 //check_N(a,cf); 817 //check_N(d,cf); 751 818 ntTest(a); 752 819 ntTest(d); … … 773 840 774 841 fraction fa = (fraction)a; 775 if (DENIS1(fa)) {776 842 if (DENIS1(fa)) 843 { 777 844 fraction result = (fraction)omAlloc0Bin(fractionObjectBin); 778 845 NUM(result) = p_Diff(NUM(fa),k,ntRing); … … 780 847 DEN(result) = NULL; 781 848 COM(result) = COM(fa); 849 //check_N((number)result,cf); 782 850 return (number)result; 783 851 } … … 792 860 heuristicGcdCancellation((number)result, cf); 793 861 862 //check_N((number)result,cf); 794 863 return (number)result; 795 864 } … … 798 867 number ntAdd(number a, number b, const coeffs cf) 799 868 { 869 //check_N(a,cf); 870 //check_N(b,cf); 800 871 ntTest(a); 801 872 ntTest(b); … … 830 901 // ntTest((number)result); 831 902 903 //check_N((number)result,cf); 832 904 return (number)result; 833 905 } … … 835 907 number ntSub(number a, number b, const coeffs cf) 836 908 { 909 //check_N(a,cf); 910 //check_N(b,cf); 837 911 ntTest(a); 838 912 ntTest(b); … … 865 939 heuristicGcdCancellation((number)result, cf); 866 940 // ntTest((number)result); 941 //check_N((number)result,cf); 867 942 return (number)result; 868 943 } … … 870 945 number ntMult(number a, number b, const coeffs cf) 871 946 { 947 //check_N(a,cf); 948 //check_N(b,cf); 872 949 ntTest(a); // !!!? 873 950 ntTest(b); // !!!? … … 890 967 891 968 969 //check_N((number)result,cf); 892 970 if (db == NULL) 893 971 { … … 906 984 COM(result) = COM(fa) + MULT_COMPLEXITY; 907 985 heuristicGcdCancellation((number)result, cf); 908 } 909 } else 986 //check_N((number)result,cf); 987 } 988 } 989 else 910 990 { // b = ?? / ?? 911 991 if (da == NULL) … … 915 995 COM(result) = COM(fb) + MULT_COMPLEXITY; 916 996 heuristicGcdCancellation((number)result, cf); 997 //check_N((number)result,cf); 917 998 } 918 999 else /* both den's are != 1 */ … … 922 1003 COM(result) = COM(fa) + COM(fb) + MULT_COMPLEXITY; 923 1004 heuristicGcdCancellation((number)result, cf); 1005 //check_N((number)result,cf); 924 1006 } 925 1007 } … … 927 1009 // ntTest((number)result); 928 1010 1011 //check_N((number)result,cf); 929 1012 return (number)result; 930 1013 } … … 932 1015 number ntDiv(number a, number b, const coeffs cf) 933 1016 { 1017 //check_N(a,cf); 1018 //check_N(b,cf); 934 1019 ntTest(a); 935 1020 ntTest(b); … … 963 1048 heuristicGcdCancellation((number)result, cf); 964 1049 // ntTest((number)result); 1050 //check_N((number)result,cf); 965 1051 return (number)result; 966 1052 } … … 1037 1123 *b = pow; 1038 1124 ntTest(*b); 1125 //check_N(*b,cf); 1039 1126 } 1040 1127 … … 1070 1157 1071 1158 { /* step (1); see documentation of this procedure above */ 1072 p_Normalize(NUM(f), ntRing);1073 p_Normalize(DEN(f), ntRing);1074 1159 number lcmOfDenominators = n_Init(1, ntCoeffs); 1075 1160 number c; number tmp; … … 1164 1249 1165 1250 fraction f = (fraction)a; 1166 if (COM(f)!=0) p_Normalize(NUM(f),ntRing);1251 p_Normalize(NUM(f),ntRing); 1167 1252 if (DENIS1(f) || NUMIS1(f)) { COM(f) = 0; return; } 1168 1253 1169 p_Normalize(DEN(f), ntRing);1170 1171 1254 assume( DEN(f) != NULL ); 1255 p_Normalize(DEN(f),ntRing); 1172 1256 1173 1257 /* check whether NUM(f) = DEN(f), and - if so - replace 'a' by 1 */ … … 1220 1304 1221 1305 if (IS0(a)) return; 1222 if (NUM(f)!=NULL) p_Normalize(NUM(f), ntRing);1223 if (DEN(f)!=NULL) p_Normalize(DEN(f), ntRing);1224 1306 if (!simpleTestsHaveAlreadyBeenPerformed) 1225 1307 { 1226 //p_Normalize(NUM(f), ntRing);1227 //if (DEN(f)!=NULL) p_Normalize(DEN(f), ntRing);1228 1308 if (DENIS1(f) || NUMIS1(f)) { COM(f) = 0; return; } 1229 1309 … … 1663 1743 number ntInvers(number a, const coeffs cf) 1664 1744 { 1745 //check_N(a,cf); 1665 1746 ntTest(a); 1666 1747 if (IS0(a)) … … 1713 1794 } 1714 1795 ntTest((number)result); // !!!! 1796 //check_N((number)result,cf); 1715 1797 return (number)result; 1716 1798 } … … 1735 1817 else DEN(ff)=p_NSet(nn,dst->extRing); 1736 1818 n_Test((number)ff,dst); 1819 //check_N((number)ff,dst); 1737 1820 return (number)ff; 1738 1821 } … … 1783 1866 DEN(result) = h; 1784 1867 COM(result) = COM(f); 1868 //check_N((number)result,dst); 1785 1869 assume(n_Test((number)result, dst)); 1786 1870 return (number)result; … … 1791 1875 assume( n_Test(a, cf) ); 1792 1876 if (n_IsZero(a, cf)) return NULL; 1793 1794 fraction f = (fraction)omAlloc0Bin(fractionObjectBin); 1795 // DEN(f) = NULL; COM(f) = 0; 1796 NUM(f) = prCopyR((poly)a, cf->extRing, dst->extRing); 1797 assume(n_Test((number)f, dst)); 1798 return (number)f; 1877 return ntInit(prCopyR((poly)a, cf->extRing, dst->extRing),dst); 1799 1878 } 1800 1879 … … 1818 1897 NUM(f) = g; // DEN(f) = NULL; COM(f) = 0; 1819 1898 assume(n_Test((number)f, dst)); 1899 //check_N((number)f,dst); 1820 1900 return (number)f; 1821 1901 } … … 1832 1912 NUM(f) = p; DEN(f) = NULL; COM(f) = 0; 1833 1913 assume(n_Test((number)f, dst)); 1914 //check_N((number)f,dst); 1834 1915 return (number)f; 1835 1916 } … … 1854 1935 NUM(f) = p; DEN(f) = NULL; COM(f) = 0; 1855 1936 assume(n_Test((number)f, dst)); 1937 //check_N((number)f,dst); 1856 1938 return (number)f; 1857 1939 } … … 1952 2034 if (n.isZero()) return NULL; 1953 2035 poly p=convFactoryPSingP(n,ntRing); 2036 p_Normalize(p,ntRing); 1954 2037 fraction result = (fraction)omAlloc0Bin(fractionObjectBin); 1955 2038 NUM(result) = p;
Note: See TracChangeset
for help on using the changeset viewer.