Changeset c8fd40 in git
- Timestamp:
- Nov 9, 2018, 4:09:43 PM (6 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'd08f5f0bb3329b8ca19f23b74cb1473686415c3a')
- Children:
- 6fac22d0e553731fefbeacc9e5e1cc9683b38ec2
- Parents:
- 4aa50a694d58bf7ccd9553bb5644b3297c61b608
- git-author:
- Karim Abou Zeid <karim23697@gmail.com>2018-11-09 16:09:43+01:00
- git-committer:
- Karim Abou Zeid <karim23697@gmail.com>2018-11-14 16:38:23+01:00
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/fpaprops.lib
r4aa50a rc8fd40 622 622 // iterate through all vertices 623 623 624 intvec visited; 625 visited[n] = 0; 626 627 intvec cyclic; 628 cyclic[n] = 0; 624 intvec visited = 0:n; 625 intvec cyclic = 0:n; 626 intvec countedCycles = -2:n; 629 627 630 628 int maxCycleCount = 0; 631 629 for (int v = 1; v <= n; v++) { 632 int cycleCount = countCycles(UG, v, visited, cyclic, 0); 633 if (cycleCount == -1) { 630 countedCycles = countCycles(UG, v, visited, cyclic, 0, countedCycles); 631 dbprint("counted: " + string(v) + "/" + string(n)); 632 if (countedCycles[v] == -1) { 634 633 return(-1); 635 634 } 636 if (cycleCount > maxCycleCount) { 637 maxCycleCount = cycleCount; 638 } 639 kill cycleCount; 635 if (countedCycles[v] > maxCycleCount) { 636 maxCycleCount = countedCycles[v]; 637 } 640 638 } kill v; 641 return (maxCycleCount);642 } 643 644 static proc countCycles(intmat G, int v, intvec visited, intvec cyclic, intvec path )639 return (maxCycleCount); 640 } 641 642 static proc countCycles(intmat G, int v, intvec visited, intvec cyclic, intvec path, intvec countedCycles) 645 643 "USAGE: countCycles(G, v, visited, cyclic, path); G a Graph, v the vertex to 646 644 start. The parameter visited, cyclic and path should be 0. … … 651 649 " 652 650 { 651 if (countedCycles[v] > -2) { 652 return (countedCycles); 653 } 653 654 // Mark the current vertex as visited 654 655 visited[v] = 1; … … 669 670 if(cyclic[path[j]] == 1) { 670 671 // 1.1 if yes, return -1 671 return (-1); 672 countedCycles[v] = -1; 673 return (countedCycles); 672 674 } 673 675 if (path[j] == w) { … … 694 696 int maxCycleCount = 0; 695 697 for (int j = size(path); j >= 1; j--) { 696 int cycleCount = countCycles(G, path[j], visited, cyclic, path); 697 if(cycleCount == -1) { 698 return (-1); 698 countedCycles = countCycles(G, path[j], visited, cyclic, path, countedCycles); 699 if(countedCycles[path[j]] == -1) { 700 countedCycles[v] = -1; 701 return (countedCycles); 699 702 } 700 if (c ycleCount> maxCycleCount) {701 maxCycleCount = c ycleCount;703 if (countedCycles[path[j]] > maxCycleCount) { 704 maxCycleCount = countedCycles[path[j]]; 702 705 } 703 kill cycleCount;704 706 if (path[j] == w) { 705 707 break; … … 711 713 kill maxCycleCount; 712 714 } else { 713 int cycleCount = countCycles(G, w, visited, cyclic, path);714 if (c ycleCount== -1) {715 return(-1);716 }717 if (cycleCount > cycles) {718 cycles = cycleCount;719 }720 kill cycleCount;715 countedCycles = countCycles(G, w, visited, cyclic, path, countedCycles); 716 if (countedCycles[w] == -1) { 717 countedCycles[v] = -1; 718 return (countedCycles); 719 } 720 if (countedCycles[w] > cycles) { 721 cycles = countedCycles[w]; 722 } 721 723 } 722 724 } 723 725 } kill w; 724 726 // printf("Path: %s countCycles: %s", path, cycles); // DEBUG 725 return(cycles); 727 countedCycles[v] = cycles; 728 return (countedCycles); 726 729 } 727 730 … … 738 741 " 739 742 { 743 dbprint("computing maxDeg"); 740 744 int l = maxDeg(G); 741 list LG = lpId2ivLi(G); 742 list SW = ivStandardWords(LG, l - 1); // vertices 743 int n = size(SW); 745 if (l - 1 == 0) { 746 // TODO: how should the graph look like when l - 1 = 0 ? 747 ERROR("Ufnarovskij graph not implemented for l = 1"); 748 } 749 int lV = attrib(basering, "isLetterplaceRing"); 750 // TODO: what if l <= 0? 751 dbprint("computing standard words"); 752 ideal SW = lpStandardWords(G, l - 1); // vertices 753 int n = ncols(SW); 754 dbprint("n = " + string(n)); 744 755 intmat UG[n][n]; // Ufnarovskij graph 745 756 for (int i = 1; i <= n; i++) { 746 757 for (int j = 1; j <= n; j++) { 758 dbprint("Ufnarovskii graph: " + string((i-1)*n + j) + "/" + string(n*n) + " entries"); 747 759 // [Studzinski page 76] 748 intvecv = SW[i];749 intvecw = SW[j];760 poly v = SW[i]; 761 poly w = SW[j]; 750 762 intvec v_overlap; 751 763 intvec w_overlap; 752 //TODO how should the graph look like when l - 1 = 0 ?753 if (l - 1 == 0) {754 ERROR("Ufnarovskij graph not implemented for l = 1");755 }756 764 if (l - 1 > 1) { 757 v_overlap = v[2 .. l-1];758 w_overlap = w[1 .. l-2];759 }760 intvec vw = v;761 vw[l] = w[l-1];762 if (v_overlap == w_overlap && ! ivdivides(LG, vw)) {765 v_overlap = leadexp(v); 766 w_overlap = leadexp(w); 767 v_overlap = v_overlap[(lV+1) .. (l-1)*lV]; 768 w_overlap = w_overlap[1 .. (l-2)*lV]; 769 } 770 if (v_overlap == w_overlap && !lpdivides(G, v * lpVarAt(w, l - 1))) { 763 771 UG[i,j] = 1; 764 772 } 765 kill v; kill w; kill v_overlap; kill w_overlap; kill vw;773 kill v; kill w; kill v_overlap; kill w_overlap; 766 774 } kill j; 767 775 } kill i; … … 799 807 } kill i; 800 808 return (l); 809 } 810 811 static proc lpVarAt(poly p, int pos) { 812 return (system("lpVarAt", p, pos)); 813 } 814 815 static proc lpStandardWords(ideal G, int length) 816 "ASSUME: G is simplified 817 " 818 { 819 if (length < 0) { 820 return (delete(ideal(0), 1)); // no standard words 821 } 822 823 ideal words = maxideal(length); 824 for (int i = ncols(words); i >= 1; i--) { 825 if (lpdivides(G, words[i])) { 826 words = delete(words, i); 827 } 828 } kill i; 829 return (words); 801 830 } 802 831 … … 841 870 } 842 871 872 proc lpdivides(ideal I, poly p) { 873 for (int i = 1; i <= ncols(I); i++) { 874 if (system("lpdivides", I[i], p)) { 875 return (1); 876 } 877 } kill i; 878 return (0); 879 } 880 843 881 static proc ivdivides(list G, intvec iv) { 844 882 for (int k = 1; k <= size(G); k++) { … … 858 896 RETURN: int 859 897 PURPOSE: Determines the Gelfand Kirillov dimension of A/<G> 860 @* -1 means it ispositive infinite898 @* -1 means positive infinite 861 899 ASSUME: - basering is a Letterplace ring 862 900 @* - G is a Groebner basis … … 877 915 // also if G is the whole ring return minus infinity 878 916 if (leadmonom(G[i]) == 1) { 879 ERROR("G k-Dim not defined for 0-ring")917 ERROR("GK-Dim not defined for 0-ring") 880 918 } 881 919 kill d; … … 896 934 } 897 935 936 dbprint("computing Ufnarovskii graph"); 898 937 intmat UG = lpUfGraph(G); 938 dbprint("Ufnarovskii graph: ", string(UG)); 899 939 900 940 // check special case 2 … … 905 945 906 946 // check special case 3 947 dbprint("topological sorting of Ufnarovskii graph"); 907 948 UG = topologicalSort(UG); 908 949 950 dbprint("check if Ufnarovskii graph is DAG"); 909 951 if (imIsUpRightTriangle(UG)) { 910 952 UG = eliminateZerosUpTriangle(UG); … … 912 954 return (0) 913 955 } 956 dbprint("DAG detected, using URTNZD growth alg"); 914 957 return(UfGraphURTNZDGrowth(UG)); 915 958 } 916 959 917 960 // otherwise count cycles in the Ufnarovskij Graph 961 dbprint("not a DAG, using regular growth alg"); 918 962 return(UfGraphGrowth(UG)); 919 963 } -
Singular/extra.cc
r4aa50a rc8fd40 1209 1209 else 1210 1210 #endif 1211 /*==================== divide-test for freeGB =================*/ 1212 #ifdef HAVE_SHIFTBBA 1213 if (strcmp(sys_cmd, "lpdivides") == 0) 1214 { 1215 const short t[]={2,POLY_CMD,POLY_CMD}; 1216 if (iiCheckTypes(h,t,1)) 1217 { 1218 poly p=(poly)h->CopyD(); 1219 poly q=(poly)h->next->CopyD(); 1220 res->rtyp = INT_CMD; 1221 res->data = (void*)(long)p_LPDivisibleBy(p, q, currRing); 1222 return FALSE; 1223 } 1224 else return TRUE; 1225 } 1226 else 1227 #endif 1228 /*==================== get var for freeGB ====================*/ 1229 #ifdef HAVE_SHIFTBBA 1230 if (strcmp(sys_cmd, "lpVarAt") == 0) 1231 { 1232 const short t[]={2,POLY_CMD,INT_CMD}; 1233 if (iiCheckTypes(h,t,1)) 1234 { 1235 poly p=(poly)h->CopyD(); 1236 int pos=(int)((long)(h->next->Data())); 1237 res->rtyp = POLY_CMD; 1238 res->data = p_LPVarAt(p, pos, currRing); 1239 return FALSE; 1240 } 1241 else return TRUE; 1242 } 1243 else 1244 #endif 1211 1245 /*==================== pcv ==================================*/ 1212 1246 #ifdef HAVE_PCV -
libpolys/polys/shiftop.cc
r4aa50a rc8fd40 659 659 omFreeSize((ADDRESS) B, (b+1)*sizeof(int)); 660 660 return(1); 661 } 662 663 BOOLEAN p_LPDivisibleBy(poly a, poly b, const ring r) 664 { 665 pIfThen1(b!=NULL, p_LmCheckPolyRing1(b, r)); 666 pIfThen1(a!=NULL, p_LmCheckPolyRing1(a, r)); 667 668 if (b == NULL) return TRUE; 669 if (a != NULL && (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))) 670 return _p_LPLmDivisibleByNoComp(a,b,r); 671 return FALSE; 672 } 673 674 BOOLEAN p_LPLmDivisibleBy(poly a, poly b, const ring r) 675 { 676 p_LmCheckPolyRing1(b, r); 677 pIfThen1(a != NULL, p_LmCheckPolyRing1(b, r)); 678 if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r)) 679 return _p_LPLmDivisibleByNoComp(a, b, r); 680 return FALSE; 681 } 682 683 BOOLEAN _p_LPLmDivisibleByNoComp(poly a, poly b, const ring r) 684 { 685 if(p_LmIsConstantComp(a, r)) 686 return TRUE; 687 #ifdef SHIFT_MULT_COMPAT_MODE 688 a = p_Head(a, r); 689 p_mLPunshift(a, r); 690 b = p_Head(b, r); 691 p_mLPunshift(b, r); 692 #endif 693 int i = (r->N / r->isLPring) - p_LastVblock(a, r); 694 do { 695 int j = r->N - (i * r->isLPring); 696 bool divisible = true; 697 do 698 { 699 if (p_GetExp(a, j, r) > p_GetExp(b, j + (i * r->isLPring), r)) 700 { 701 divisible = false; 702 break; 703 } 704 j--; 705 } 706 while (j); 707 if (divisible) return TRUE; 708 i--; 709 } 710 while (i > -1); 711 #ifdef SHIFT_MULT_COMPAT_MODE 712 p_Delete(&a, r); 713 p_Delete(&b, r); 714 #endif 715 return FALSE; 716 } 717 718 poly p_LPVarAt(poly p, int pos, const ring r) 719 { 720 if (p == NULL || pos < 1 || pos > (r->N / r->isLPring)) return NULL; 721 poly v = p_One(r); 722 for (int i = (pos-1) * r->isLPring + 1; i <= pos * r->isLPring; i++) { 723 if (p_GetExp(p, i, r)) { 724 p_SetExp(v, i - (pos-1) * r->isLPring, 1, r); 725 return v; 726 } 727 } 728 return v; 661 729 } 662 730 -
libpolys/polys/shiftop.h
r4aa50a rc8fd40 48 48 #define pmIsInV(p) p_mIsInV(p, currRing) 49 49 50 BOOLEAN p_LPDivisibleBy(poly a, poly b, const ring r); 51 BOOLEAN p_LPLmDivisibleBy(poly a, poly b, const ring r); 52 BOOLEAN _p_LPLmDivisibleByNoComp(poly a, poly b, const ring r); 53 54 poly p_LPVarAt(poly p, int pos, const ring r); 55 50 56 ring freeAlgebra(ring r, int d); 51 57 #endif
Note: See TracChangeset
for help on using the changeset viewer.