- Timestamp:
- May 30, 2014, 4:28:26 PM (10 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
- Children:
- 7152fa73f01fce2a5964817eb2444114fc5888e4
- Parents:
- 05c60b24c590ed8dce06d86378489249390eca5e121ad4a2fe86746537b889b9ac969034ed1c0dd1
- Location:
- libpolys
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/coeffs/longrat.cc
r05c60b2 r75424e 17 17 18 18 // 64 bit version: 19 //#if SIZEOF_LONG == 820 #if 019 #if SIZEOF_LONG == 8 20 //#if 0 21 21 #define MAX_NUM_SIZE 60 22 22 #define POW_2_28 (1L<<60) … … 265 265 if ( SR_HDL(n) & SR_INT ) 266 266 { 267 term = SR_TO_INT(n); 267 int nn=SR_TO_INT(n); 268 if ((long)nn==SR_TO_INT(n)) 269 term = nn; 270 else 271 { 272 mpz_t dummy; 273 mpz_init_set_si(dummy, SR_TO_INT(n)); 274 term = make_cf(dummy); 275 } 268 276 } 269 277 else … … 534 542 nlTest(i, r); 535 543 nlNormalize(i,r); 536 if (SR_HDL(i) &SR_INT) return SR_TO_INT(i); 544 if (SR_HDL(i) & SR_INT) 545 { 546 int dummy = SR_TO_INT(i); 547 if((long)dummy == SR_TO_INT(i)) 548 return SR_TO_INT(i); 549 else 550 return 0; 551 } 537 552 if (i->s==3) 538 553 { … … 563 578 nlTest(i, r); 564 579 nlNormalize(i,r); 565 if (SR_HDL(i) & SR_INT) return (i);580 if (SR_HDL(i) & SR_INT) return (i); 566 581 if (i->s==3) 567 582 { … … 786 801 { 787 802 LONG bb=SR_TO_INT(b); 788 LONG c=SR_TO_INT(a)%bb; 803 LONG c=SR_TO_INT(a) % bb; 804 /*if(c < 0) 805 { 806 if(bb < 0) 807 c = c - bb; 808 else 809 c = c + bb; 810 }*/ 811 /*if((((SR_TO_INT(a)) / (bb))*bb+c) != SR_TO_INT(a)) 812 { 813 printf("\nERROR longrat:819\n"); 814 printf("\na = %ld\n",SR_TO_INT(a)); 815 printf("\nb = %ld\n",bb); 816 printf("\nc = %ld\n",c); 817 }*/ 789 818 return INT_TO_SR(c); 790 819 } 791 820 if (SR_HDL(a) & SR_INT) 792 821 { 793 /* a is a small and b is a large int: -> a */ 794 return a; 822 // a is a small and b is a large int: -> a 823 // INCORRECT, IT COULD HAPPEN THAT b IS A SMALL NUMBER 824 number aa; 825 aa=ALLOC_RNUMBER(); 826 mpz_init(aa->z); 827 mpz_set_si(aa->z, SR_TO_INT(a)); 828 u=ALLOC_RNUMBER(); 829 #if defined(LDEBUG) 830 u->debug=123456; 831 #endif 832 u->s = 3; 833 mpz_init(u->z); 834 mpz_mod(u->z,aa->z,b->z); 835 if (mpz_isNeg(u->z)) 836 { 837 if (mpz_isNeg(b->z)) 838 mpz_sub(u->z,aa->z,b->z); 839 else 840 mpz_add(u->z,aa->z,b->z); 841 } 842 /*mpz_t dummy; 843 mpz_init(dummy); 844 mpz_fdiv_q(dummy, aa->z, b->z); 845 mpz_mul(dummy, dummy, b->z); 846 mpz_add(dummy, dummy, u->z); 847 if(mpz_cmp(dummy,aa->z) != 0) 848 { 849 printf("\nERROR longrat:911\n"); 850 printf("\na = ");n_Print(aa,r); 851 gmp_printf("\ndummy = %Zd",dummy); 852 mpz_clear(dummy);mpz_init(dummy);mpz_tdiv_q(dummy, a->z, b->z); 853 gmp_printf("\na div b = %Zd\n u = ", dummy); 854 n_Print(u,r); 855 } 856 mpz_clear(dummy);*/ 857 if (aa!=NULL) 858 { 859 mpz_clear(aa->z); 860 #if defined(LDEBUG) 861 aa->debug=654324; 862 #endif 863 FREE_RNUMBER(aa); 864 } 865 u=nlShort3(u); 866 nlTest(u,r); 867 return u; 795 868 } 796 869 number bb=NULL; … … 807 880 u->s = 3; 808 881 mpz_mod(u->z,a->z,b->z); 809 if (bb!=NULL)810 {811 mpz_clear(bb->z);812 #if defined(LDEBUG)813 bb->debug=654324;814 #endif815 FREE_RNUMBER(bb);816 }817 882 if (mpz_isNeg(u->z)) 818 883 { … … 822 887 mpz_add(u->z,u->z,b->z); 823 888 } 889 if (bb!=NULL) 890 { 891 mpz_clear(bb->z); 892 #if defined(LDEBUG) 893 bb->debug=654324; 894 #endif 895 FREE_RNUMBER(bb); 896 } 897 /*mpz_t dummy; 898 mpz_init(dummy); 899 mpz_fdiv_q(dummy, a->z, b->z); 900 mpz_mul(dummy, dummy, b->z); 901 mpz_add(dummy, dummy, u->z); 902 if(mpz_cmp(dummy,a->z) != 0) 903 { 904 printf("\nERROR longrat:911\n"); 905 printf("\na = ");n_Print(a,r); 906 gmp_printf("\ndummy = %Zd",dummy); 907 mpz_clear(dummy);mpz_init(dummy);mpz_tdiv_q(dummy, a->z, b->z); 908 gmp_printf("\na div b = %Zd\n u = ", dummy); 909 n_Print(u,r); 910 } 911 mpz_clear(dummy);*/ 824 912 u=nlShort3(u); 825 913 nlTest(u,r); … … 2092 2180 assume( getCoeffType(dst) == ID ); 2093 2181 assume( getCoeffType(src) == ID ); 2094 2095 2182 if ((SR_HDL(a) & SR_INT)||(a==NULL)) 2096 2183 { … … 2693 2780 2694 2781 nlInpGcd(cand, n, cf); 2695 2696 2782 assume( nlGreaterZero(cand,cf) ); 2697 2783 -
libpolys/coeffs/mpr_complex.cc
r05c60b2 r75424e 377 377 if (SR_HDL(num) & SR_INT) 378 378 { 379 r= SR_TO_INT(num); 379 //n_Print(num, src);printf("\n"); 380 int nn = SR_TO_INT(num); 381 if((long)nn == SR_TO_INT(num)) 382 r = SR_TO_INT(num); 383 else 384 r = gmp_float(SR_TO_INT(num)); 385 //int dd = 20; 386 //gmp_printf("\nr = %.*Ff\n",dd,*r.mpfp()); 387 //getchar(); 380 388 } 381 389 else … … 436 444 if (SR_HDL(num) & SR_INT) 437 445 { 438 r= SR_TO_INT(num); 446 int nn = SR_TO_INT(num); 447 if((long)nn == SR_TO_INT(num)) 448 r = SR_TO_INT(num); 449 else 450 r = gmp_float(SR_TO_INT(num)); 439 451 } 440 452 else … … 446 458 if (SR_HDL(num) & SR_INT) 447 459 { 448 r= SR_TO_INT(num); 460 int nn = SR_TO_INT(num); 461 if((long)nn == SR_TO_INT(num)) 462 r = SR_TO_INT(num); 463 else 464 r = gmp_float(SR_TO_INT(num)); 449 465 } 450 466 else -
libpolys/coeffs/numbers.cc
r121ad4 r75424e 413 413 assume(n->cfInpNeg!=NULL); 414 414 assume(n->cfCopy!=NULL); 415 assume(n->cfRePart!=NULL);416 assume(n->cfImPart!=NULL);417 415 418 416 assume(n->cfWriteLong!=NULL); -
libpolys/coeffs/shortfl.cc
r05c60b2 r75424e 425 425 #define SR_HDL(A) ((long)(A)) 426 426 #define IS_INT(A) ((A)->s==3) 427 #define IS_IMM(A) (SR_HDL(A) &SR_INT)427 #define IS_IMM(A) (SR_HDL(A) & SR_INT) 428 428 #define GET_NOM(A) ((A)->z) 429 429 #define GET_DENOM(A) ((A)->n) -
libpolys/polys/ext_fields/algext.cc
r121ad4 r75424e 98 98 void naWriteLong(number &a, const coeffs cf); 99 99 void naWriteShort(number &a, const coeffs cf); 100 number naRePart(number a, const coeffs cf);101 number naImPart(number a, const coeffs cf);102 100 number naGetDenom(number &a, const coeffs cf); 103 101 number naGetNumerator(number &a, const coeffs cf); … … 248 246 BOOLEAN naDBTest(number a, const char *f, const int l, const coeffs cf) 249 247 { 250 assume(getCoeffType(cf) == ID);251 248 if (a == NULL) return TRUE; 252 249 p_Test((poly)a, naRing); 253 if((((poly)a)!=naMinpoly) 254 && p_Totaldegree((poly)a, naRing) >= p_Totaldegree(naMinpoly, naRing) 255 && (p_Totaldegree((poly)a, naRing)> 1)) // allow to output par(1) 256 { 257 dReportError("deg >= deg(minpoly) in %s:%d\n",f,l); 258 return FALSE; 250 if (getCoeffType(cf)==n_algExt) 251 { 252 if((((poly)a)!=naMinpoly) 253 && p_Totaldegree((poly)a, naRing) >= p_Totaldegree(naMinpoly, naRing) 254 && (p_Totaldegree((poly)a, naRing)> 1)) // allow to output par(1) 255 { 256 dReportError("deg >= deg(minpoly) in %s:%d\n",f,l); 257 return FALSE; 258 } 259 259 } 260 260 return TRUE; … … 348 348 if (a != NULL) a = (number)p_Neg((poly)a, naRing); 349 349 return a; 350 }351 352 number naImPart(number a, const coeffs cf)353 {354 naTest(a);355 return NULL;356 350 } 357 351 … … 486 480 poly aPlusB = p_Add_q(p_Copy((poly)a, naRing), 487 481 p_Copy((poly)b, naRing), naRing); 488 definiteReduce(aPlusB, naMinpoly, cf);482 //definiteReduce(aPlusB, naMinpoly, cf); 489 483 return (number)aPlusB; 490 484 } … … 497 491 if (a == NULL) return (number)minusB; 498 492 poly aMinusB = p_Add_q(p_Copy((poly)a, naRing), minusB, naRing); 499 definiteReduce(aMinusB, naMinpoly, cf);493 //definiteReduce(aMinusB, naMinpoly, cf); 500 494 return (number)aMinusB; 501 495 } … … 724 718 static BOOLEAN naCoeffIsEqual(const coeffs cf, n_coeffType n, void * param) 725 719 { 726 if ( ID!= n) return FALSE;720 if (n_algExt != n) return FALSE; 727 721 AlgExtInfo *e = (AlgExtInfo *)param; 728 722 /* for extension coefficient fields we expect the underlying … … 1421 1415 e->r->ref ++; // increase the ref.counter for the ground poly. ring! 1422 1416 const ring R = e->r; // no copy! 1423 assume( R->qideal == e->r->qideal );1424 1417 cf->extRing = R; 1425 1418 … … 1445 1438 cf->cfChineseRemainder= naChineseRemainder; 1446 1439 cf->cfInt = naInt; 1447 cf->cfInpNeg 1440 cf->cfInpNeg = naNeg; 1448 1441 cf->cfAdd = naAdd; 1449 1442 cf->cfSub = naSub; … … 1467 1460 cf->cfGetNumerator = naGetNumerator; 1468 1461 cf->cfRePart = naCopy; 1469 cf->cfImPart = naImPart;1470 1462 cf->cfCoeffWrite = naCoeffWrite; 1471 1463 cf->cfNormalize = naNormalize; … … 1503 1495 template class IAccessor<snumber*>; 1504 1496 1497 /* --------------------------------------------------------------------*/ 1498 #if 0 1499 void npolyCoeffWrite(const coeffs cf, BOOLEAN details) 1500 { 1501 assume( cf != NULL ); 1502 1503 const ring A = cf->extRing; 1504 1505 assume( A != NULL ); 1506 Print("// polynomial ring as coefficient ring :\n"); 1507 rWrite(A); 1508 PrintLn(); 1509 } 1510 number npolyMult(number a, number b, const coeffs cf) 1511 { 1512 naTest(a); naTest(b); 1513 if ((a == NULL)||(b == NULL)) return NULL; 1514 poly aTimesB = p_Mult_q(p_Copy((poly)a, naRing), 1515 p_Copy((poly)b, naRing), naRing); 1516 return (number)aTimesB; 1517 } 1518 1519 number npolyDiv(number a, number b, const coeffs cf) 1520 { 1521 naTest(a); naTest(b); 1522 if (b == NULL) WerrorS(nDivBy0); 1523 if (a == NULL) return NULL; 1524 poly p=singclap_pdivide((poly)a,(poly)b,naRing); 1525 return (number)p; 1526 } 1527 1528 1529 BOOLEAN npolyInitChar(coeffs cf, void * infoStruct) 1530 { 1531 assume( infoStruct != NULL ); 1532 1533 AlgExtInfo *e = (AlgExtInfo *)infoStruct; 1534 /// first check whether cf->extRing != NULL and delete old ring??? 1535 1536 assume(e->r != NULL); // extRing; 1537 assume(e->r->cf != NULL); // extRing->cf; 1538 1539 assume( cf != NULL ); 1540 1541 e->r->ref ++; // increase the ref.counter for the ground poly. ring! 1542 const ring R = e->r; // no copy! 1543 cf->extRing = R; 1544 1545 /* propagate characteristic up so that it becomes 1546 directly accessible in cf: */ 1547 cf->ch = R->cf->ch; 1548 1549 cf->cfCoeffString = naCoeffString; 1550 1551 cf->cfGreaterZero = naGreaterZero; 1552 cf->cfGreater = naGreater; 1553 cf->cfEqual = naEqual; 1554 cf->cfIsZero = naIsZero; 1555 cf->cfIsOne = naIsOne; 1556 cf->cfIsMOne = naIsMOne; 1557 cf->cfInit = naInit; 1558 cf->cfInit_bigint = naInit_bigint; 1559 cf->cfFarey = naFarey; 1560 cf->cfChineseRemainder= naChineseRemainder; 1561 cf->cfInt = naInt; 1562 cf->cfInpNeg = naNeg; 1563 cf->cfAdd = naAdd; 1564 cf->cfSub = naSub; 1565 cf->cfMult = npolyMult; 1566 cf->cfDiv = npolyDiv; 1567 cf->cfPower = naPower; 1568 cf->cfCopy = naCopy; 1569 1570 cf->cfWriteLong = naWriteLong; 1571 1572 if( rCanShortOut(naRing) ) 1573 cf->cfWriteShort = naWriteShort; 1574 else 1575 cf->cfWriteShort = naWriteLong; 1576 1577 cf->cfRead = naRead; 1578 cf->cfDelete = naDelete; 1579 cf->cfSetMap = naSetMap; 1580 cf->cfGetDenom = naGetDenom; 1581 cf->cfGetNumerator = naGetNumerator; 1582 cf->cfRePart = naCopy; 1583 cf->cfCoeffWrite = npolyCoeffWrite; 1584 cf->cfNormalize = npolyNormalize; 1585 cf->cfKillChar = naKillChar; 1586 #ifdef LDEBUG 1587 cf->cfDBTest = naDBTest; 1588 #endif 1589 cf->cfGcd = naGcd; 1590 cf->cfLcm = naLcmContent; 1591 cf->cfSize = naSize; 1592 cf->nCoeffIsEqual = naCoeffIsEqual; 1593 cf->cfInvers = npolyInvers; 1594 cf->cfIntDiv = npolyDiv; 1595 cf->convFactoryNSingN=naConvFactoryNSingN; 1596 cf->convSingNFactoryN=naConvSingNFactoryN; 1597 cf->cfParDeg = naParDeg; 1598 1599 cf->iNumberOfParameters = rVar(R); 1600 cf->pParameterNames = (const char**)R->names; 1601 cf->cfParameter = naParameter; 1602 cf->has_simple_Inverse=FALSE; 1603 /* cf->has_simple_Alloc= FALSE; */ 1604 1605 if( nCoeff_is_Q(R->cf) ) 1606 { 1607 cf->cfClearContent = naClearContent; 1608 cf->cfClearDenominators = naClearDenominators; 1609 } 1610 1611 return FALSE; 1612 } 1613 #endif
Note: See TracChangeset
for help on using the changeset viewer.