Changeset 67e0dc in git for libpolys/polys
- Timestamp:
- Oct 21, 2015, 2:57:17 PM (9 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '38dfc5131670d387a89455159ed1e071997eec94')
- Children:
- 5bd9ec36b87fa8f176a21995de2b56724d67be2d
- Parents:
- a1b6c917a1c8886b1bba1b05680ff06cfd39c82def1a968e317a12b42f88e04cd7f9483e47fba2f7
- Location:
- libpolys/polys
- Files:
-
- 1 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/polys/ext_fields/transext.cc
ref1a968 r67e0dc 72 72 73 73 #ifdef LDEBUG 74 #define ntTest(a) ntDBTest(a,__FILE__,__LINE__,cf)75 74 BOOLEAN ntDBTest(number a, const char *f, const int l, const coeffs r); 76 #else77 #define ntTest(a) do {} while (0)78 75 #endif 76 77 #define ntTest(a) n_Test(a, cf) 79 78 80 79 /// Our own type! … … 184 183 //check_N(a,cf); 185 184 const poly num = NUM(t); 186 assume(num != NULL); / **< t != 0 ==> numerator(t) != 0 */185 assume(num != NULL); ///< t != 0 ==> numerator(t) != 0 187 186 188 187 p_Test(num, ntRing); 189 188 189 if (getCoeffType(ntCoeffs)==n_Q) 190 for( poly p = num; p != NULL; pIter(p) ) 191 if (! nlIsInteger( p_GetCoeff(p, ntRing), ntCoeffs) ) 192 { 193 Print("ERROR in %s:%d: non-integer Q coeff in num. poly\n",f,l); 194 Print("TERM: "); p_wrp(p, ntRing); PrintLn(); 195 return FALSE; 196 } 197 190 198 const poly den = DEN(t); 191 199 … … 193 201 { 194 202 p_Test(den, ntRing); 203 204 if (getCoeffType(ntCoeffs)==n_Q) 205 for( poly p = den; p != NULL; pIter(p) ) 206 if (! nlIsInteger( p_GetCoeff(p, ntRing), ntCoeffs) ) 207 { 208 Print("ERROR in %s:%d: non-integer Q coeff in den. poly\n",f,l); 209 Print("TERM: "); p_wrp(p, ntRing); PrintLn(); 210 return FALSE; 211 } 212 213 if (getCoeffType(ntCoeffs)==n_Zp) 214 { 215 if( p_IsConstant(den, ntRing) ) 216 { 217 Print("ERROR in %s:%d: constant den. poly / Zp\n",f,l); 218 Print("NUM: "); p_Write(num, ntRing); 219 Print("DEN: "); p_Write(den, ntRing); 220 return FALSE; 221 } 222 223 if( !n_IsOne(pGetCoeff(den), ntCoeffs) ) 224 { 225 Print("ERROR in %s:%d: non-monic den. poly / Zp\n",f,l); 226 Print("NUM: "); p_Write(num, ntRing); 227 Print("DEN: "); p_Write(den, ntRing); 228 return FALSE; 229 } 230 } 231 232 if (COM(t)==0) 233 { 234 poly gcd = singclap_gcd_r( num, den, ntRing ); 235 if( !p_IsOne(gcd, ntRing) ) 236 { 237 Print("ERROR in %s:%d: 1 != GCD between num. & den. poly\n",f,l); 238 Print("GCD: "); p_Write(gcd, ntRing); 239 Print("NUM: "); p_Write(num, ntRing); 240 Print("DEN: "); p_Write(den, ntRing); 241 return FALSE; 242 } 243 p_Delete( &gcd, ntRing ); 244 } 245 return TRUE; 246 247 248 195 249 if(p_IsConstant(den, ntRing) && (n_IsOne(pGetCoeff(den), ntCoeffs))) 196 250 { … … 206 260 } 207 261 else 208 { // num != NULL // den == NULL 262 { 263 return TRUE; 264 265 // num != NULL // den == NULL 209 266 // if( COM(t) != 0 ) 210 267 // { … … 279 336 //check_N(*a,cf); 280 337 ntTest(*a); // !!! 338 281 339 fraction f = (fraction)(*a); 282 340 if (IS0(f)) return; … … 580 638 if (p == NULL) return NULL; 581 639 640 p_Test( p, ntRing); 582 641 fraction f = (fraction)omAlloc0Bin(fractionObjectBin); 583 642 … … 792 851 COM(result) = COM(fa); 793 852 //check_N((number)result,cf); 853 ntTest((number)result); 794 854 return (number)result; 795 855 } … … 804 864 805 865 //check_N((number)result,cf); 866 ntTest((number)result); 806 867 return (number)result; 807 868 } … … 845 906 846 907 //check_N((number)result,cf); 908 ntTest((number)result); 847 909 return (number)result; 848 910 } … … 883 945 // ntTest((number)result); 884 946 //check_N((number)result,cf); 947 ntTest((number)result); 885 948 return (number)result; 886 949 } … … 953 1016 954 1017 //check_N((number)result,cf); 1018 ntTest((number)result); 955 1019 return (number)result; 956 1020 } … … 989 1053 } 990 1054 COM(result) = COM(fa) + COM(fb) + MULT_COMPLEXITY; 1055 // definiteGcdCancellation((number)result, cf,FALSE); 991 1056 heuristicGcdCancellation((number)result, cf); 992 1057 // ntTest((number)result); 993 1058 //check_N((number)result,cf); 1059 ntTest((number)result); 994 1060 return (number)result; 995 1061 } … … 1186 1252 1187 1253 /* modifies a */ 1254 /* this is an intermediate simplification routine - not a comple "normalize" */ 1188 1255 void heuristicGcdCancellation(number a, const coeffs cf) 1189 1256 { 1190 // ntTest(a); // !!!!????1191 1257 if (IS0(a)) return; 1192 1258 … … 1232 1298 } 1233 1299 } 1234 } 1235 } 1236 1237 ntTest(a); 1300 if ((DEN(f)!=NULL) 1301 && (pNext(DEN(f))==NULL)) 1302 { 1303 poly den_f=DEN(f); 1304 poly h=NUM(f); 1305 loop 1306 { 1307 if (h==NULL) 1308 { 1309 h=NUM(f); 1310 do 1311 { 1312 p_ExpVectorDiff(h,h,den_f,ntRing); 1313 pIter(h); 1314 } while(h!=NULL); 1315 p_ExpVectorDiff(den_f,den_f,den_f,ntRing); 1316 break; 1317 } 1318 int i=0; 1319 do 1320 { 1321 i++; 1322 if (p_GetExp(den_f,i,ntRing) > p_GetExp(h,i,ntRing)) return; 1323 } while(i<ntRing->N); 1324 pIter(h); 1325 } 1326 } 1327 } 1328 } 1238 1329 } 1239 1330 … … 1242 1333 BOOLEAN simpleTestsHaveAlreadyBeenPerformed) 1243 1334 { 1244 ntTest(a); // !!!!1335 // ntTest(a); // !!!! 1245 1336 1246 1337 fraction f = (fraction)a; 1247 1338 1248 1339 if (IS0(a)) return; 1249 if (DENIS1(f) || NUMIS1(f)) { COM(f) = 0; return; }1340 if (DENIS1(f) || NUMIS1(f)) { COM(f) = 0; ntTest(a); return; } 1250 1341 if (!simpleTestsHaveAlreadyBeenPerformed) 1251 1342 { … … 1344 1435 to be != 1. */ 1345 1436 if (p_IsConstant(DEN(f), ntRing) && 1346 1437 n_IsOne(p_GetCoeff(DEN(f), ntRing), ntCoeffs)) 1347 1438 { 1348 1439 /* DEN(f) = 1 needs to be represented by NULL! */ … … 1367 1458 } 1368 1459 } 1460 p_Delete(&pGcd, ntRing); 1369 1461 COM(f) = 0; 1370 p_Delete(&pGcd, ntRing);1371 1462 1372 1463 if( DEN(f) != NULL ) 1464 { 1373 1465 if( !n_GreaterZero(pGetCoeff(DEN(f)), ntCoeffs) ) 1374 1466 { … … 1383 1475 } 1384 1476 } 1477 } 1385 1478 ntTest(a); // !!!! 1386 1479 } … … 1442 1535 if (p == NULL) *a = NULL; 1443 1536 else *a = ntInit(p, cf); 1537 ntTest(*a); 1444 1538 return result; 1445 1539 } … … 1570 1664 return (number)result; 1571 1665 1572 return NULL;1666 return NULL; 1573 1667 } 1574 1668 … … 1661 1755 int noOfTerms = 0; 1662 1756 int numDegree = 0; 1663 while (p != NULL) 1664 { 1665 noOfTerms++; 1666 int d = 0; 1667 for (int i = 1; i <= rVar(ntRing); i++) 1668 d += p_GetExp(p, i, ntRing); 1669 if (d > numDegree) numDegree = d; 1670 pIter(p); 1757 if (p!=NULL) 1758 { 1759 numDegree = p_Totaldegree(p,ntRing); 1760 noOfTerms = pLength(p); 1671 1761 } 1672 1762 int denDegree = 0; 1673 1763 if (!DENIS1(f)) 1674 1764 { 1675 p = DEN(f); 1676 while (p != NULL) 1677 { 1678 noOfTerms++; 1679 int d = 0; 1680 for (int i = 1; i <= rVar(ntRing); i++) 1681 d += p_GetExp(p, i, ntRing); 1682 if (d > denDegree) denDegree = d; 1683 pIter(p); 1684 } 1765 denDegree = p_Totaldegree(DEN(f),ntRing); 1766 noOfTerms += pLength(DEN(f)); 1685 1767 } 1686 1768 ntTest(a); // !!!! … … 1748 1830 number ntMap00(number a, const coeffs src, const coeffs dst) 1749 1831 { 1832 n_Test(a, src); 1833 1750 1834 if (n_IsZero(a, src)) return NULL; 1751 n_Test(a, src);1752 1835 assume(src->rep == dst->extRing->cf->rep); 1753 1836 if ((SR_HDL(a) & SR_INT) || (a->s==3)) 1754 1837 { 1755 1838 number res=ntInit(p_NSet(n_Copy(a, src), dst->extRing), dst); 1756 n_Test(res, dst);1839 n_Test(res, dst); 1757 1840 return res; 1758 1841 } … … 1763 1846 if (n_IsOne(nn,src)) DEN(ff)=NULL; 1764 1847 else DEN(ff)=p_NSet(nn,dst->extRing); 1848 1765 1849 n_Test((number)ff,dst); 1766 1850 //check_N((number)ff,dst); … … 1770 1854 number ntMapZ0(number a, const coeffs src, const coeffs dst) 1771 1855 { 1856 n_Test(a, src); 1772 1857 if (n_IsZero(a, src)) return NULL; 1773 n_Test(a, src);1774 1858 nMapFunc nMap=n_SetMap(src,dst->extRing->cf); 1775 1859 poly p=p_NSet(nMap(a, src,dst->extRing->cf), dst->extRing); … … 1784 1868 number ntMapP0(number a, const coeffs src, const coeffs dst) 1785 1869 { 1870 n_Test(a, src); 1786 1871 if (n_IsZero(a, src)) return NULL; 1787 n_Test(a, src);1788 1872 /* mapping via intermediate int: */ 1789 1873 int n = n_Int(a, src); … … 2380 2464 { 2381 2465 fraction result = (fraction)omAlloc0Bin(fractionObjectBin); 2382 int i;2383 2466 2384 2467 poly *P=(poly*)omAlloc(rl*sizeof(poly*)); 2385 2468 number *X=(number *)omAlloc(rl*sizeof(number)); 2469 2470 int i; 2386 2471 2387 2472 for(i=0;i<rl;i++) P[i]=p_Copy(NUM((fraction)(x[i])),cf->extRing); … … 2402 2487 p_Delete(&DEN(result),ntRing); 2403 2488 } 2489 ntTest((number)result); 2404 2490 return ((number)result); 2405 2491 } … … 2411 2497 NUM(result)=p_Farey(p_Copy(NUM((fraction)p),cf->extRing),n,cf->extRing); 2412 2498 DEN(result)=p_Farey(p_Copy(DEN((fraction)p),cf->extRing),n,cf->extRing); 2499 ntTest((number)result); 2413 2500 return ((number)result); 2414 2501 } -
libpolys/polys/kbuckets.cc
ra1b6c91 r67e0dc 14 14 #include <coeffs/coeffs.h> 15 15 #include <polys/monomials/ring.h> 16 //#include <kernel/p_Procs.h>17 16 //#include <kernel/GBEngine/kutil.h> 18 17 #include <polys/kbuckets.h> -
libpolys/polys/kbuckets.h
ref1a968 r67e0dc 193 193 194 194 #ifndef HAVE_PSEUDO_BUCKETS 195 inline void kBucketAdjustBucketsUsed(kBucket_pt bucket)195 static inline void kBucketAdjustBucketsUsed(kBucket_pt bucket) 196 196 { 197 197 while ( bucket->buckets_used > 0 && -
libpolys/polys/monomials/p_polys.cc
ref1a968 r67e0dc 116 116 { 117 117 hh=xx[j]; 118 if ((hh!=NULL) && (p_LmCmp( r,hh,R)==0))118 if ((hh!=NULL) && (p_LmCmp(h,hh,R)==0)) 119 119 { 120 120 x[j]=pGetCoeff(hh); … … 2258 2258 n_Normalize(pGetCoeff(ph),r->cf); 2259 2259 if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r); 2260 if (rField_is_Q(r) ) // should not be used anymore if CLEARENUMERATORS is 12260 if (rField_is_Q(r)||(getCoeffType(r->cf)==n_transExt)) // should not be used anymore if CLEARENUMERATORS is 1 2261 2261 { 2262 2262 h=p_InitContent(ph,r); … … 2448 2448 2449 2449 static number p_InitContent(poly ph, const ring r) 2450 // only for coefficients in Q 2450 // only for coefficients in Q and rational functions 2451 2451 #if 0 2452 2452 { … … 2499 2499 { 2500 2500 number d=pGetCoeff(ph); 2501 if(SR_HDL(d)&SR_INT) return d; 2502 int s=mpz_size1(d->z); 2501 int s; 2503 2502 int s2=-1; 2504 number d2; 2503 if(rField_is_Q(r)) 2504 { 2505 if (SR_HDL(d)&SR_INT) return d; 2506 s=mpz_size1(d->z); 2507 } 2508 else 2509 s=n_Size(d,r); 2510 number d2=d; 2505 2511 loop 2506 2512 { … … 2511 2517 break; 2512 2518 } 2513 if (SR_HDL(pGetCoeff(ph))&SR_INT) 2514 { 2515 s2=s; 2516 d2=d; 2517 s=0; 2518 d=pGetCoeff(ph); 2519 if (s2==0) break; 2519 if (rField_is_Q(r)) 2520 { 2521 if (SR_HDL(pGetCoeff(ph))&SR_INT) 2522 { 2523 s2=s; 2524 d2=d; 2525 s=0; 2526 d=pGetCoeff(ph); 2527 if (s2==0) break; 2528 } 2529 else if (mpz_size1((pGetCoeff(ph)->z))<=s) 2530 { 2531 s2=s; 2532 d2=d; 2533 d=pGetCoeff(ph); 2534 s=mpz_size1(d->z); 2535 } 2520 2536 } 2521 2537 else 2522 if (mpz_size1((pGetCoeff(ph)->z))<=s) 2523 { 2524 s2=s; 2525 d2=d; 2526 d=pGetCoeff(ph); 2527 s=mpz_size1(d->z); 2528 } 2529 } 2530 return n_Gcd(d,d2,r->cf); 2538 { 2539 int ns=n_Size(pGetCoeff(ph),r); 2540 if (ns<=3) 2541 { 2542 s2=s; 2543 d2=d; 2544 d=pGetCoeff(ph); 2545 s=ns; 2546 if (s2<=3) break; 2547 } 2548 else if (ns<s) 2549 { 2550 s2=s; 2551 d2=d; 2552 d=pGetCoeff(ph); 2553 s=ns; 2554 } 2555 } 2556 } 2557 return n_SubringGcd(d,d2,r->cf); 2531 2558 } 2532 2559 #endif … … 3095 3122 { 3096 3123 int count = 0; 3124 if (r->cf->has_simple_Alloc) 3125 return pLength(p); 3097 3126 while ( p != NULL ) 3098 3127 { … … 4531 4560 { 4532 4561 assume(p != NULL); 4533 if (p == NULL) return 0;4534 4562 unsigned long ev = 0; // short exponent vector 4535 4563 unsigned int n = BIT_SIZEOF_LONG / r->N; // number of bits per exp 4536 4564 unsigned int m1; // highest bit which is filled with (n+1) 4537 unsigned int i = 0,j=1;4565 int i=0,j=1; 4538 4566 4539 4567 if (n == 0) … … 4546 4574 else 4547 4575 { 4548 for (; j<= (unsigned long)r->N; j++)4576 for (; j<=r->N; j++) 4549 4577 { 4550 4578 if (p_GetExp(p,j,r) > 0) i++; … … 4552 4580 } 4553 4581 if (i>0) 4554 ev = ~( (unsigned long)0) >> ((unsigned long) (BIT_SIZEOF_LONG - i));4582 ev = ~(0UL) >> (BIT_SIZEOF_LONG - i); 4555 4583 return ev; 4556 4584 } … … 4580 4608 4581 4609 4610 /// p_GetShortExpVector of p * pp 4582 4611 unsigned long p_GetShortExpVector(const poly p, const poly pp, const ring r) 4583 4612 { 4584 4613 assume(p != NULL); 4585 4614 assume(pp != NULL); 4586 if (p == NULL || pp == NULL) return 0;4587 4615 4588 4616 unsigned long ev = 0; // short exponent vector 4589 4617 unsigned int n = BIT_SIZEOF_LONG / r->N; // number of bits per exp 4590 4618 unsigned int m1; // highest bit which is filled with (n+1) 4591 unsigned int i = 0, j=1; 4619 int j=1; 4620 unsigned long i = 0L; 4592 4621 4593 4622 if (n == 0) … … 4600 4629 else 4601 4630 { 4602 for (; j<= (unsigned long)r->N; j++)4631 for (; j<=r->N; j++) 4603 4632 { 4604 4633 if (p_GetExp(p,j,r) > 0 || p_GetExp(pp,j,r) > 0) i++; … … 4606 4635 } 4607 4636 if (i>0) 4608 ev = ~( (unsigned long)0) >> ((unsigned long) (BIT_SIZEOF_LONG - i));4637 ev = ~(0UL) >> (BIT_SIZEOF_LONG - i); 4609 4638 return ev; 4610 4639 } -
libpolys/polys/monomials/p_polys.h
ra1b6c91 r67e0dc 1583 1583 while (i>=0); 1584 1584 } 1585 #ifdef HAVE_RINGS1585 /*#ifdef HAVE_RINGS 1586 1586 pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == n_DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r), r->cf)); 1587 1587 return (!rField_is_Ring(r)) || n_DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r), r->cf); 1588 1588 #else 1589 */ 1589 1590 pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == TRUE); 1590 1591 return TRUE; 1591 #endif1592 //#endif 1592 1593 } 1593 1594 … … 1604 1605 } 1605 1606 while (i); 1606 #ifdef HAVE_RINGS1607 /*#ifdef HAVE_RINGS 1607 1608 return n_DivBy(p_GetCoeff(b, r_b), p_GetCoeff(a, r_a), r_a->cf); 1608 1609 #else 1610 */ 1609 1611 return TRUE; 1610 #endif1612 //#endif 1611 1613 } 1612 1614 … … 1624 1626 } 1625 1627 while (i>=start); 1626 #ifdef HAVE_RINGS1628 /*#ifdef HAVE_RINGS 1627 1629 return n_DivBy(p_GetCoeff(b, r_b), p_GetCoeff(a, r_a), r_a->cf); 1628 1630 #else 1631 */ 1629 1632 return TRUE; 1630 #endif1633 //#endif 1631 1634 } 1632 1635 static inline BOOLEAN _p_LmDivisibleByPart(poly a, const ring r_a, poly b, const ring r_b,const int start, const int end) -
libpolys/polys/monomials/ring.cc
ra1b6c91 r67e0dc 4891 4891 { 4892 4892 return rAssure_Global(ringorder_C, ringorder_dp, r); 4893 } 4894 4895 ring rAssure_c_dp(const ring r) 4896 { 4897 return rAssure_Global(ringorder_c, ringorder_dp, r); 4893 4898 } 4894 4899 -
libpolys/polys/monomials/ring.h
ra1b6c91 r67e0dc 728 728 ring rAssure_dp_C(const ring r); 729 729 ring rAssure_C_dp(const ring r); 730 ring rAssure_c_dp(const ring r); 730 731 731 732 /// makes sure that c/C ordering is last ordering -
libpolys/polys/prCopy.cc
ref1a968 r67e0dc 54 54 poly dest = &dest_s; 55 55 56 poly prev; 56 57 while (src != NULL) 57 58 { 58 poly prev=dest; 59 pNext(dest) = (poly) p_Init(dest_r); pIter(dest); 59 pNext(dest) = (poly) p_Init(dest_r); 60 prev = dest; 61 pIter(dest); 60 62 61 63 pSetCoeff0(dest, nMap(pGetCoeff(src),src_r->cf,dest_r->cf)); … … 63 65 if (n_IsZero(pGetCoeff(dest),dest_r->cf)) 64 66 { 65 p_LmDelete(pNext(prev),dest_r); 66 dest=pNext(prev); 67 p_LmDelete(&pNext(prev),dest_r); 67 68 } 68 69 pIter(src); -
libpolys/polys/simpleideals.cc
ra1b6c91 r67e0dc 73 73 for (int i = 0; i <= j; i++) 74 74 { 75 Print("generator %d: ",i); p_wrp(id->m[i], lmRing, tailRing); 75 Print("generator %d: ",i); p_wrp(id->m[i], lmRing, tailRing);PrintLn(); 76 76 } 77 77 } -
libpolys/polys/simpleideals.h
ref1a968 r67e0dc 14 14 /// thoughout Singular. Basic use-cases for it are: 15 15 /// * ideal/module: nrows = 1, ncols >=0 and rank:1 for ideals, rank>=0 for modules 16 /// * matrix: nrows, ncols >=0, rank == nrows! see mp_* procedures 16 /// * matrix: nrows, ncols >=0, rank == nrows! see mp_* procedures 17 17 /// NOTE: the m member point to memory chunk of size (ncols*nrows*sizeof(poly)) or is NULL 18 18 struct sip_sideal
Note: See TracChangeset
for help on using the changeset viewer.