Changeset e78f35 in git
- Timestamp:
- Feb 19, 2013, 8:32:57 PM (10 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'f875bbaccd0831e36aaed09ff6adeb3eb45aeb94')
- Children:
- 2a3743b6431021631dff0bb9d7b7888a205302b1bc03ea6301177ce6360abcfc3922ff0edc5f9a73
- Parents:
- 26e817f3b4db82c0b0a5376b16c2e9648ecf55e3d81e39d347055cad093a2ae53302e036ae2a449c
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/MinorInterface.cc
r26e817f re78f35 190 190 /* before we return the result, let's omit zero generators 191 191 in iii which come after the computed minors */ 192 ideal jjj; 193 if (collectedMinors == 0) jjj = idInit(1); 194 else jjj = idCopyFirstK(iii, collectedMinors); 195 idDelete(&iii); 192 idKeepFirstK(iii, collectedMinors); 196 193 delete[] myColumnIndices; 197 194 delete[] myRowIndices; 198 return jjj;195 return(iii); 199 196 } 200 197 … … 542 539 else 543 540 { /* k == 0, i.e., all minors are requested */ 544 int minorCount = 1; 545 for (int i = rowCount - minorSize + 1; i <= rowCount; i++) 546 minorCount = minorCount * i; 547 for (int i = 2; i <= minorSize; i++) minorCount = minorCount / i; 548 for (int i = columnCount - minorSize + 1; i <= columnCount; i++) 549 minorCount = minorCount * i; 550 for (int i = 2; i <= minorSize; i++) minorCount = minorCount / i; 551 /* now: minorCount = (rowCount over minorSize) 552 * (columnCount over minorSize) */ 541 int minorCount = binom(rowCount, minorSize); 542 minorCount *= binom(columnCount, minorSize); 553 543 if ((minorSize >= 3) && (vars <= 4) 554 544 && (minorCount >= 100)) c = true; -
kernel/ideals.cc
r26e817f re78f35 11 11 12 12 #include <omalloc/omalloc.h> 13 #include <misc/auxiliary.h>14 15 13 16 14 #ifndef NDEBUG … … 2559 2557 */ 2560 2558 2561 2562 2559 /// keeps the first k (>= 1) entries of the given ideal 2560 /// (Note that the kept polynomials may be zero.) 2561 void idKeepFirstK(ideal id, const int k) 2562 { 2563 for (int i = IDELEMS(id)-1; i >= k; i--) 2564 { 2565 if (id->m[i] != NULL) pDelete(&id->m[i]); 2566 } 2567 int kk=k; 2568 if (k==0) kk=1; /* ideals must have at least one element(0)*/ 2569 pEnlargeSet(&(id->m), IDELEMS(id), kk-IDELEMS(id)); 2570 IDELEMS(id) = kk; 2571 } 2572 2573 /* 2574 * compare the leading terms of a and b 2575 */ 2576 static int tCompare(const poly a, const poly b) 2577 { 2578 if (b == NULL) return(a != NULL); 2579 if (a == NULL) return(-1); 2580 2581 /* a != NULL && b != NULL */ 2582 int r = pLmCmp(a, b); 2583 if (r != 0) return(r); 2584 number h = nSub(pGetCoeff(a), pGetCoeff(b)); 2585 r = -1 + nIsZero(h) + 2*nGreaterZero(h); /* -1: <, 0:==, 1: > */ 2586 nDelete(&h); 2587 return(r); 2588 } 2589 2590 /* 2591 * compare a and b (rev-lex on terms) 2592 */ 2593 static int pCompare(const poly a, const poly b) 2594 { 2595 int r = tCompare(a, b); 2596 if (r != 0) return(r); 2597 2598 poly aa = a; 2599 poly bb = b; 2600 while (r == 0 && aa != NULL && bb != NULL) 2601 { 2602 pIter(aa); 2603 pIter(bb); 2604 r = tCompare(aa, bb); 2605 } 2606 return(r); 2607 } 2608 2609 typedef struct 2610 { 2611 poly p; 2612 int index; 2613 } poly_sort; 2614 2615 int pCompare_qsort(const void *a, const void *b) 2616 { 2617 int res = pCompare(((poly_sort *)a)->p, ((poly_sort *)b)->p); 2618 return(res); 2619 } 2620 2621 void idSort_qsort(poly_sort *id_sort, int idsize) 2622 { 2623 qsort(id_sort, idsize, sizeof(poly_sort), pCompare_qsort); 2624 } 2625 2626 /*2 2627 * ideal id = (id[i]) 2628 * if id[i] = id[j] then id[j] is deleted for j > i 2629 */ 2630 void idDelEquals(ideal id) 2631 { 2632 int idsize = IDELEMS(id); 2633 poly_sort *id_sort = (poly_sort *)omAlloc0(idsize*sizeof(poly_sort)); 2634 for (int i = 0; i < idsize; i++) 2635 { 2636 id_sort[i].p = id->m[i]; 2637 id_sort[i].index = i; 2638 } 2639 idSort_qsort(id_sort, idsize); 2640 int index, index_i, index_j; 2641 int i = 0; 2642 for (int j = 1; j < idsize; j++) 2643 { 2644 if (id_sort[i].p != NULL && pEqualPolys(id_sort[i].p, id_sort[j].p)) 2645 { 2646 index_i = id_sort[i].index; 2647 index_j = id_sort[j].index; 2648 if (index_j > index_i) 2649 { 2650 index = index_j; 2651 } 2652 else 2653 { 2654 index = index_i; 2655 i = j; 2656 } 2657 pDelete(&id->m[index]); 2658 } 2659 else 2660 { 2661 i = j; 2662 } 2663 } 2664 omFreeSize((ADDRESS)(id_sort), idsize*sizeof(poly_sort)); 2665 } -
kernel/ideals.h
r26e817f re78f35 24 24 } 25 25 26 void idKeepFirstK(ideal ide, const int k); 27 void idDelEquals(ideal id); 28 26 29 /// delete an ideal 27 30 inline void idDelete (ideal* h, ring r = currRing)
Note: See TracChangeset
for help on using the changeset viewer.