 Timestamp:
 Feb 28, 2022, 9:47:08 PM (2 years ago)
 Branches:
 (u'fiekerDuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b21a664aa22dc6e196223af8a74ad4885e83547c')
 Children:
 5b4fbd8628e662e19ce83b185fe94dbc213f1305
 Parents:
 fc2e0d38db0650acaca55c5367712f26fd5ddb55
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

libpolys/polys/ext_fields/algext.cc
rfc2e0d r2ac2996 53 53 #ifdef LDEBUG 54 54 #define naTest(a) naDBTest(a,__FILE__,__LINE__,cf) 55 BOOLEAN naDBTest(number a, const char *f, const int l, const coeffs r);55 static BOOLEAN naDBTest(number a, const char *f, const int l, const coeffs r); 56 56 #else 57 57 #define naTest(a) do {} while (0) … … 71 71 72 72 /// forward declarations 73 BOOLEAN naGreaterZero(number a, const coeffs cf);74 BOOLEAN naGreater(number a, number b, const coeffs cf);75 BOOLEAN naEqual(number a, number b, const coeffs cf);76 BOOLEAN naIsOne(number a, const coeffs cf);77 BOOLEAN naIsMOne(number a, const coeffs cf);78 number naInit(long i, const coeffs cf);79 number naNeg(number a, const coeffs cf);80 number naInvers(number a, const coeffs cf);81 number naAdd(number a, number b, const coeffs cf);82 number naSub(number a, number b, const coeffs cf);83 number naMult(number a, number b, const coeffs cf);84 number naDiv(number a, number b, const coeffs cf);85 void naPower(number a, int exp, number *b, const coeffs cf);86 number naCopy(number a, const coeffs cf);87 void naWriteLong(number a, const coeffs cf);88 void naWriteShort(number a, const coeffs cf);89 number naGetDenom(number &a, const coeffs cf);90 number naGetNumerator(number &a, const coeffs cf);91 number naGcd(number a, number b, const coeffs cf);92 void naDelete(number *a, const coeffs cf);93 void naCoeffWrite(const coeffs cf, BOOLEAN details);73 static BOOLEAN naGreaterZero(number a, const coeffs cf); 74 static BOOLEAN naGreater(number a, number b, const coeffs cf); 75 static BOOLEAN naEqual(number a, number b, const coeffs cf); 76 static BOOLEAN naIsOne(number a, const coeffs cf); 77 static BOOLEAN naIsMOne(number a, const coeffs cf); 78 static number naInit(long i, const coeffs cf); 79 static number naNeg(number a, const coeffs cf); 80 static number naInvers(number a, const coeffs cf); 81 static number naAdd(number a, number b, const coeffs cf); 82 static number naSub(number a, number b, const coeffs cf); 83 static number naMult(number a, number b, const coeffs cf); 84 static number naDiv(number a, number b, const coeffs cf); 85 static void naPower(number a, int exp, number *b, const coeffs cf); 86 static number naCopy(number a, const coeffs cf); 87 static void naWriteLong(number a, const coeffs cf); 88 static void naWriteShort(number a, const coeffs cf); 89 static number naGetDenom(number &a, const coeffs cf); 90 static number naGetNumerator(number &a, const coeffs cf); 91 static number naGcd(number a, number b, const coeffs cf); 92 static void naDelete(number *a, const coeffs cf); 93 static void naCoeffWrite(const coeffs cf, BOOLEAN details); 94 94 //number naIntDiv(number a, number b, const coeffs cf); 95 const char * naRead(const char *s, number *a, const coeffs cf);95 static const char * naRead(const char *s, number *a, const coeffs cf); 96 96 97 97 static BOOLEAN naCoeffIsEqual(const coeffs cf, n_coeffType n, void * param); … … 249 249 #endif 250 250 251 void heuristicReduce(poly &p, poly reducer, const coeffs cf);252 void definiteReduce(poly &p, poly reducer, const coeffs cf);251 static void heuristicReduce(poly &p, poly reducer, const coeffs cf); 252 static void definiteReduce(poly &p, poly reducer, const coeffs cf); 253 253 254 254 /* returns the bottom field in this field extension tower; if the tower … … 270 270 } 271 271 272 BOOLEAN naIsZero(number a, const coeffs cf)272 static BOOLEAN naIsZero(number a, const coeffs cf) 273 273 { 274 274 naTest(a); … … 276 276 } 277 277 278 void naDelete(number * a, const coeffs cf)278 static void naDelete(number * a, const coeffs cf) 279 279 { 280 280 if (*a == NULL) return; … … 285 285 } 286 286 287 BOOLEAN naEqual(number a, number b, const coeffs cf)287 static BOOLEAN naEqual(number a, number b, const coeffs cf) 288 288 { 289 289 naTest(a); naTest(b); … … 294 294 } 295 295 296 number naCopy(number a, const coeffs cf)296 static number naCopy(number a, const coeffs cf) 297 297 { 298 298 naTest(a); … … 301 301 } 302 302 303 number naGetNumerator(number &a, const coeffs cf) 304 { 305 return naCopy(a, cf); 306 } 307 308 number naGetDenom(number &a, const coeffs cf) 309 { 310 naTest(a); 311 return naInit(1, cf); 312 } 313 314 BOOLEAN naIsOne(number a, const coeffs cf) 303 static BOOLEAN naIsOne(number a, const coeffs cf) 315 304 { 316 305 naTest(a); … … 320 309 } 321 310 322 BOOLEAN naIsMOne(number a, const coeffs cf)311 static BOOLEAN naIsMOne(number a, const coeffs cf) 323 312 { 324 313 naTest(a); … … 329 318 330 319 /// this is inplace, modifies a 331 number naNeg(number a, const coeffs cf)320 static number naNeg(number a, const coeffs cf) 332 321 { 333 322 naTest(a); … … 336 325 } 337 326 338 number naInit(long i, const coeffs cf)327 static number naInit(long i, const coeffs cf) 339 328 { 340 329 if (i == 0) return NULL; … … 348 337 } 349 338 350 long naInt(number &a, const coeffs cf)339 static long naInt(number &a, const coeffs cf) 351 340 { 352 341 naTest(a); … … 361 350 362 351 /* TRUE iff (a != 0 and (b == 0 or deg(a) > deg(b) or (deg(a)==deg(b) && lc(a)>lc(b))) */ 363 BOOLEAN naGreater(number a, number b, const coeffs cf)352 static BOOLEAN naGreater(number a, number b, const coeffs cf) 364 353 { 365 354 naTest(a); naTest(b); … … 381 370 382 371 /* TRUE iff a != 0 and (LC(a) > 0 or deg(a) > 0) */ 383 BOOLEAN naGreaterZero(number a, const coeffs cf)372 static BOOLEAN naGreaterZero(number a, const coeffs cf) 384 373 { 385 374 naTest(a); … … 390 379 } 391 380 392 void naCoeffWrite(const coeffs cf, BOOLEAN details)381 static void naCoeffWrite(const coeffs cf, BOOLEAN details) 393 382 { 394 383 assume( cf != NULL ); … … 440 429 } 441 430 442 number naAdd(number a, number b, const coeffs cf)431 static number naAdd(number a, number b, const coeffs cf) 443 432 { 444 433 naTest(a); naTest(b); … … 451 440 } 452 441 453 number naSub(number a, number b, const coeffs cf) 442 static void naInpAdd(number &a, number b, const coeffs cf) 443 { 444 naTest(a); naTest(b); 445 if (a == NULL) a=b; 446 else if (b != NULL) 447 { 448 poly aPlusB = p_Add_q((poly)a, p_Copy((poly)b, naRing), naRing); 449 a=(number)aPlusB; 450 } 451 } 452 453 static number naSub(number a, number b, const coeffs cf) 454 454 { 455 455 naTest(a); naTest(b); … … 462 462 } 463 463 464 number naMult(number a, number b, const coeffs cf)464 static number naMult(number a, number b, const coeffs cf) 465 465 { 466 466 naTest(a); naTest(b); … … 472 472 } 473 473 474 number naDiv(number a, number b, const coeffs cf) 474 static void naInpMult(number &a, number b, const coeffs cf) 475 { 476 naTest(a); naTest(b); 477 if ((a == NULL)(b == NULL)) { a=NULL; return;} 478 poly aTimesB = p_Mult_q((poly)a, p_Copy((poly)b,naRing), naRing); 479 definiteReduce(aTimesB, naMinpoly, cf); 480 p_Normalize(aTimesB,naRing); 481 a=(number)aTimesB; 482 } 483 484 static number naDiv(number a, number b, const coeffs cf) 475 485 { 476 486 naTest(a); naTest(b); … … 496 506 the inplace method heuristicReduce(poly, poly, coeffs); see there. 497 507 */ 498 void naPower(number a, int exp, number *b, const coeffs cf)508 static void naPower(number a, int exp, number *b, const coeffs cf) 499 509 { 500 510 naTest(a); … … 563 573 if (deg(p) > 10*deg(reducer) then perform reduction; 564 574 modifies p */ 565 void heuristicReduce(poly &p, poly reducer, const coeffs cf)575 static void heuristicReduce(poly &p, poly reducer, const coeffs cf) 566 576 { 567 577 #ifdef LDEBUG … … 573 583 } 574 584 575 void naWriteLong(number a, const coeffs cf)585 static void naWriteLong(number a, const coeffs cf) 576 586 { 577 587 naTest(a); … … 591 601 } 592 602 593 void naWriteShort(number a, const coeffs cf)603 static void naWriteShort(number a, const coeffs cf) 594 604 { 595 605 naTest(a); … … 609 619 } 610 620 611 const char * naRead(const char *s, number *a, const coeffs cf)621 static const char * naRead(const char *s, number *a, const coeffs cf) 612 622 { 613 623 poly aAsPoly; … … 620 630 #if 0 621 631 /* implemented by the rule lcm(a, b) = a * b / gcd(a, b) */ 622 number naLcm(number a, number b, const coeffs cf)632 static number naLcm(number a, number b, const coeffs cf) 623 633 { 624 634 naTest(a); naTest(b); … … 632 642 } 633 643 #endif 634 number napNormalizeHelper(number b, const coeffs cf)644 static number napNormalizeHelper(number b, const coeffs cf) 635 645 { 636 646 number h=n_Init(1,naRing>cf); … … 646 656 return h; 647 657 } 648 number naLcmContent(number a, number b, const coeffs cf)658 static number naLcmContent(number a, number b, const coeffs cf) 649 659 { 650 660 if (nCoeff_is_Zp(naRing>cf)) return naCopy(a,cf); … … 715 725 } 716 726 717 int naSize(number a, const coeffs cf)727 static int naSize(number a, const coeffs cf) 718 728 { 719 729 if (a == NULL) return 0; … … 733 743 of division of p by the reducer; 734 744 modifies p */ 735 void definiteReduce(poly &p, poly reducer, const coeffs cf)745 static void definiteReduce(poly &p, poly reducer, const coeffs cf) 736 746 { 737 747 #ifdef LDEBUG … … 745 755 } 746 756 747 void naNormalize(number &a, const coeffs cf)757 static void naNormalize(number &a, const coeffs cf) 748 758 { 749 759 poly aa=(poly)a; … … 753 763 } 754 764 755 number naConvFactoryNSingN( const CanonicalForm n, const coeffs cf)765 static number naConvFactoryNSingN( const CanonicalForm n, const coeffs cf) 756 766 { 757 767 if (n.isZero()) return NULL; … … 759 769 return (number)p; 760 770 } 761 CanonicalForm naConvSingNFactoryN( number n, BOOLEAN /*setChar*/, const coeffs cf )771 static CanonicalForm naConvSingNFactoryN( number n, BOOLEAN /*setChar*/, const coeffs cf ) 762 772 { 763 773 naTest(n); … … 773 783 in this strong sense but rather computes the gcd of 774 784 two given elements in the underlying polynomial ring. */ 775 number naGcd(number a, number b, const coeffs cf)785 static number naGcd(number a, number b, const coeffs cf) 776 786 { 777 787 if (a==NULL) return naCopy(b,cf); … … 821 831 } 822 832 823 number naInvers(number a, const coeffs cf)833 static number naInvers(number a, const coeffs cf) 824 834 { 825 835 naTest(a); … … 851 861 852 862 /* assumes that src = Q or Z, dst = Q(a) */ 853 number naMap00(number a, const coeffs src, const coeffs dst)863 static number naMap00(number a, const coeffs src, const coeffs dst) 854 864 { 855 865 if (n_IsZero(a, src)) return NULL; … … 861 871 862 872 /* assumes that src = Z, dst = K(a) */ 863 number naMapZ0(number a, const coeffs src, const coeffs dst)873 static number naMapZ0(number a, const coeffs src, const coeffs dst) 864 874 { 865 875 if (n_IsZero(a, src)) return NULL; … … 873 883 874 884 /* assumes that src = Z/p, dst = Q(a) */ 875 number naMapP0(number a, const coeffs src, const coeffs dst)885 static number naMapP0(number a, const coeffs src, const coeffs dst) 876 886 { 877 887 if (n_IsZero(a, src)) return NULL; … … 887 897 /* assumes that either src = Q(a), dst = Q(a), or 888 898 src = Z/p(a), dst = Z/p(a) */ 889 number naCopyMap(number a, const coeffs src, const coeffs dst)899 static number naCopyMap(number a, const coeffs src, const coeffs dst) 890 900 { 891 901 return naCopy(a, dst); … … 893 903 #endif 894 904 895 number naCopyTrans2AlgExt(number a, const coeffs src, const coeffs dst)905 static number naCopyTrans2AlgExt(number a, const coeffs src, const coeffs dst) 896 906 { 897 907 assume (nCoeff_is_transExt (src)); … … 941 951 942 952 /* assumes that src = Q, dst = Z/p(a) */ 943 number naMap0P(number a, const coeffs src, const coeffs dst)953 static number naMap0P(number a, const coeffs src, const coeffs dst) 944 954 { 945 955 if (n_IsZero(a, src)) return NULL; … … 954 964 955 965 /* assumes that src = Z/p, dst = Z/p(a) */ 956 number naMapPP(number a, const coeffs src, const coeffs dst)966 static number naMapPP(number a, const coeffs src, const coeffs dst) 957 967 { 958 968 if (n_IsZero(a, src)) return NULL; … … 964 974 965 975 /* assumes that src = Z/u, dst = Z/p(a), where u != p */ 966 number naMapUP(number a, const coeffs src, const coeffs dst)976 static number naMapUP(number a, const coeffs src, const coeffs dst) 967 977 { 968 978 if (n_IsZero(a, src)) return NULL; … … 975 985 } 976 986 977 number naGenMap(number a, const coeffs cf, const coeffs dst)987 static number naGenMap(number a, const coeffs cf, const coeffs dst) 978 988 { 979 989 if (a==NULL) return NULL; … … 990 1000 } 991 1001 992 number naGenTrans2AlgExt(number a, const coeffs cf, const coeffs dst)1002 static number naGenTrans2AlgExt(number a, const coeffs cf, const coeffs dst) 993 1003 { 994 1004 if (a==NULL) return NULL; … … 1071 1081 } 1072 1082 1073 int naParDeg(number a, const coeffs cf)1083 static int naParDeg(number a, const coeffs cf) 1074 1084 { 1075 1085 if (a == NULL) return 1; … … 1079 1089 1080 1090 /// return the specified parameter as a number in the given alg. field 1081 number naParameter(const int iParameter, const coeffs cf)1091 static number naParameter(const int iParameter, const coeffs cf) 1082 1092 { 1083 1093 assume(getCoeffType(cf) == n_algExt); … … 1310 1320 1311 1321 1312 void naClearDenominators(ICoeffsEnumerator& numberCollectionEnumerator, number& c, const coeffs cf)1322 static void naClearDenominators(ICoeffsEnumerator& numberCollectionEnumerator, number& c, const coeffs cf) 1313 1323 { 1314 1324 assume(cf != NULL); … … 1326 1336 } 1327 1337 1328 void naKillChar(coeffs cf)1338 static void naKillChar(coeffs cf) 1329 1339 { 1330 1340 rDecRefCnt(cf>extRing); … … 1356 1366 } 1357 1367 1358 number naChineseRemainder(number *x, number *q,int rl, BOOLEAN /*sym*/,CFArray &inv_cache,const coeffs cf)1368 static number naChineseRemainder(number *x, number *q,int rl, BOOLEAN /*sym*/,CFArray &inv_cache,const coeffs cf) 1359 1369 { 1360 1370 poly *P=(poly*)omAlloc(rl*sizeof(poly*)); … … 1368 1378 } 1369 1379 1370 number naFarey(number p, number n, const coeffs cf)1380 static number naFarey(number p, number n, const coeffs cf) 1371 1381 { 1372 1382 // n is really a bigint … … 1426 1436 cf>cfSub = naSub; 1427 1437 cf>cfMult = naMult; 1438 cf>cfInpMult = naInpMult; 1428 1439 cf>cfDiv = naDiv; 1429 1440 cf>cfExactDiv = naDiv; … … 1441 1452 cf>cfDelete = naDelete; 1442 1453 cf>cfSetMap = naSetMap; 1443 cf>cfGetDenom = naGetDenom;1444 cf>cfGetNumerator = naGetNumerator;1445 1454 cf>cfRePart = naCopy; 1446 1455 cf>cfCoeffWrite = naCoeffWrite; … … 1668 1677 cf>cfInpNeg = naNeg; 1669 1678 cf>cfAdd = naAdd; 1679 cf>cfInpAdd = naInpAdd; 1670 1680 cf>cfSub = naSub; 1671 1681 cf>cfMult = n2pMult; … … 1684 1694 cf>cfDelete = naDelete; 1685 1695 cf>cfSetMap = naSetMap; 1686 cf>cfGetDenom = naGetDenom;1687 cf>cfGetNumerator = naGetNumerator;1696 //cf>cfGetDenom = naGetDenom; // use nd* 1697 //cf>cfGetNumerator = naGetNumerator; // use nd* 1688 1698 cf>cfRePart = naCopy; 1689 1699 cf>cfCoeffWrite = n2pCoeffWrite;
Note: See TracChangeset
for help on using the changeset viewer.