- Timestamp:
- Jan 18, 2020, 10:59:58 PM (4 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- c417af59af93bdad5278db69f84585a318ee2ba5
- Parents:
- da6d43a81ee1ba91b8ecae7bb3a89f608e66b354
- git-author:
- Karim Abou Zeid <karim23697@gmail.com>2020-01-18 22:59:58+01:00
- git-committer:
- Karim Abou Zeid <karim23697@gmail.com>2020-01-18 23:05:58+01:00
- Location:
- Singular
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/fpaprops.lib
rda6d43a r7f5789 28 28 lpGlDimBound(<GB>); compute an upper bound for the global dimension of A/<GB> 29 29 lpSubstitute(); substitute a variable with polynomials (ring homomorphism) 30 lpUfGraph(<GB>); constructs the Ufnarovskij graph for <LM(GB)>31 30 lpCalcSubstDegBound(); utility for lpSubstitute 32 31 "; … … 44 43 example lpGlDimBound; 45 44 example lpSubstitute; 46 example lpUfGraph;47 45 example lpCalcSubstDegBound; 48 46 }; … … 90 88 if (l == 1) { 91 89 int n = lpVarBlockSize(basering); // variable count 90 int ncgenCount = lpNcgenCount(basering); 92 91 int k = size(G); 93 if (k == n ) { // only the field left92 if (k == n - ncgenCount) { // only the field left 94 93 return(3); // every field is noetherian 95 94 } 96 if (k == n -1) { // V = {1} with loop95 if (k == n - ncgenCount - 1) { // V = {1} with loop 97 96 return(3); 98 97 } 99 if (k <= n -2) { // V = {1} with more than one loop98 if (k <= n ncgenCount - 2) { // V = {1} with more than one loop 100 99 return(0); 101 100 } 102 101 } 103 102 104 intmat UG = lpUfGraph(G) ;103 intmat UG = lpUfGraph(G)[1]; 105 104 106 105 // check special case 2 … … 311 310 } 312 311 313 list VUG = lpUfGraph(G , 1);312 list VUG = lpUfGraph(G); 314 313 intmat UG = VUG[1]; // the Ufnarovskij graph 315 314 ideal V = VUG[2]; // the vertices of UG (standard words with length = l-1) … … 419 418 } 420 419 421 list VUG = lpUfGraph(G , 1);420 list VUG = lpUfGraph(G); 422 421 intmat UG = VUG[1]; // the Ufnarovskij graph 423 422 ideal V = VUG[2]; // the vertices of UG (standard words with length = l-1) … … 726 725 } 727 726 728 proc lpUfGraph(ideal G, list #) 729 "USAGE: lpUfGraph(G); G a set of monomials in a letterplace ring. 730 RETURN: intmat or list 731 NOTE: lpUfGraph(G); returns intmat. lpUfGraph(G,1); returns list L with L[1] an intmat and L[2] an ideal. 732 The intmat is the Ufnarovskij Graph and the ideal contains the vertices. 733 PURPOSE: Constructs the Ufnarovskij graph induced by G 734 the adjacency matrix of the Ufnarovskij graph induced by G 735 ASSUME: - basering is a Letterplace ring 736 - G are the leading monomials of a Groebner basis 737 " 738 { 739 dbprint("computing maxDeg"); 740 int l = maxDeg(G); 741 if (l - 1 == 0) { 742 // TODO: how should the graph look like when l - 1 = 0 ? 743 ERROR("Ufnarovskij graph not implemented for l = 1"); 744 } 745 int lV = lpVarBlockSize(basering); 746 // TODO: what if l <= 0? 747 dbprint("computing standard words"); 748 ideal SW = lpStandardWords(G, l - 1); // vertices 749 int n = ncols(SW); 750 dbprint("n = " + string(n)); 751 intmat UG[n][n]; // Ufnarovskij graph 752 for (int i = 1; i <= n; i++) { 753 for (int j = 1; j <= n; j++) { 754 dbprint("Ufnarovskii graph: " + string((i-1)*n + j) + "/" + string(n*n) + " entries"); 755 // [Studzinski page 76] 756 poly v = SW[i]; 757 poly w = SW[j]; 758 intvec v_overlap; 759 intvec w_overlap; 760 if (l - 1 > 1) { 761 v_overlap = leadexp(v); 762 w_overlap = leadexp(w); 763 v_overlap = v_overlap[(lV+1) .. (l-1)*lV]; 764 w_overlap = w_overlap[1 .. (l-2)*lV]; 765 } 766 if (v_overlap == w_overlap && !lpLmDivides(G, v * lpVarAt(w, l - 1))) { 767 UG[i,j] = 1; 768 } 769 kill v; kill w; kill v_overlap; kill w_overlap; 770 } kill j; 771 } kill i; 772 if (size(#) > 0) { 773 if (typeof(#[1]) == "int") { 774 if (#[1] != 0) { 775 list ret = UG; 776 ret[2] = SW; // the vertices 777 return (ret); 778 } 779 } 780 } 781 return (UG); 782 } 783 example 784 { 785 "EXAMPLE:"; echo = 2; 786 ring r = 0,(x,y,z),dp; 787 def R = freeAlgebra(r, 5); // constructs a Letterplace ring 788 setring R; // sets basering to Letterplace ring 789 ideal I = x*y, x*z, z*y, z*z; 790 lpUfGraph(I); 791 lpUfGraph(I,1); 792 } 727 // Ufnarovskii graph is now implemented in the dynamic module (freeAlgebra.cc) 728 /* proc lpUfGraph(ideal G, list #) */ 729 /* "USAGE: lpUfGraph(G); G a set of monomials in a letterplace ring. */ 730 /* RETURN: intmat or list */ 731 /* NOTE: lpUfGraph(G); returns intmat. lpUfGraph(G,1); returns list L with L[1] an intmat and L[2] an ideal. */ 732 /* The intmat is the Ufnarovskij Graph and the ideal contains the vertices. */ 733 /* PURPOSE: Constructs the Ufnarovskij graph induced by G */ 734 /* the adjacency matrix of the Ufnarovskij graph induced by G */ 735 /* ASSUME: - basering is a Letterplace ring */ 736 /* - G are the leading monomials of a Groebner basis */ 737 /* " */ 738 /* { */ 739 /* dbprint("computing maxDeg"); */ 740 /* int l = maxDeg(G); */ 741 /* if (l - 1 == 0) { */ 742 /* // TODO: how should the graph look like when l - 1 = 0 ? */ 743 /* ERROR("Ufnarovskij graph not implemented for l = 1"); */ 744 /* } */ 745 /* int lV = lpVarBlockSize(basering); */ 746 /* // TODO: what if l <= 0? */ 747 /* dbprint("computing standard words"); */ 748 /* ideal SW = lpStandardWords(G, l - 1); // vertices */ 749 /* int n = ncols(SW); */ 750 /* dbprint("n = " + string(n)); */ 751 /* intmat UG[n][n]; // Ufnarovskij graph */ 752 /* for (int i = 1; i <= n; i++) { */ 753 /* for (int j = 1; j <= n; j++) { */ 754 /* dbprint("Ufnarovskii graph: " + string((i-1)*n + j) + "/" + string(n*n) + " entries"); */ 755 /* // [Studzinski page 76] */ 756 /* poly v = SW[i]; */ 757 /* poly w = SW[j]; */ 758 /* intvec v_overlap; */ 759 /* intvec w_overlap; */ 760 /* if (l - 1 > 1) { */ 761 /* v_overlap = leadexp(v); */ 762 /* w_overlap = leadexp(w); */ 763 /* v_overlap = v_overlap[(lV+1) .. (l-1)*lV]; */ 764 /* w_overlap = w_overlap[1 .. (l-2)*lV]; */ 765 /* } */ 766 /* if (v_overlap == w_overlap && !lpLmDivides(G, v * lpVarAt(w, l - 1))) { */ 767 /* UG[i,j] = 1; */ 768 /* } */ 769 /* kill v; kill w; kill v_overlap; kill w_overlap; */ 770 /* } kill j; */ 771 /* } kill i; */ 772 /* if (size(#) > 0) { */ 773 /* if (typeof(#[1]) == "int") { */ 774 /* if (#[1] != 0) { */ 775 /* list ret = UG; */ 776 /* ret[2] = SW; // the vertices */ 777 /* return (ret); */ 778 /* } */ 779 /* } */ 780 /* } */ 781 /* return (UG); */ 782 /* } */ 783 /* example */ 784 /* { */ 785 /* "EXAMPLE:"; echo = 2; */ 786 /* ring r = 0,(x,y,z),dp; */ 787 /* def R = freeAlgebra(r, 5); // constructs a Letterplace ring */ 788 /* setring R; // sets basering to Letterplace ring */ 789 /* ideal I = x*y, x*z, z*y, z*z; */ 790 /* lpUfGraph(I); */ 791 /* lpUfGraph(I,1); */ 792 /* } */ 793 793 794 794 static proc maxDeg(ideal G) … … 833 833 return (words); // no standard words 834 834 } 835 int lV = lpVarBlockSize(basering); // variable count835 int nVars = lpVarBlockSize(basering) - lpNcgenCount(basering); // variable count 836 836 list prevWords = ivStandardWords(G, length - 1); 837 837 list words; 838 for (int i = 1; i <= lV; i++) {838 for (int i = 1; i <= nVars; i++) { 839 839 for (int j = 1; j <= size(prevWords); j++) { 840 840 intvec word = prevWords[j]; … … 919 919 920 920 /* dbprint("computing Ufnarovskii graph"); */ 921 /* intmat UG = lpUfGraph(G) ; */921 /* intmat UG = lpUfGraph(G)[1]; */ 922 922 /* if (printlevel >= voice + 1) { */ 923 923 /* UG; */ … … 1002 1002 if (size(G1) > 0) { 1003 1003 while (size(G1) > 0) { 1004 if (lpVarBlockSize(R) > 1) {1004 if (lpVarBlockSize(R) - lpNcgenCount(R) > 1) { 1005 1005 def @R = R - string(G1[1]); 1006 1006 R = @R; -
Singular/LIB/freegb.lib
rda6d43a r7f5789 26 26 lpDegBound(R); returns the degree bound of a letterplace ring 27 27 lpVarBlockSize(R); returns the size of the letterplace blocks 28 lpNcgenCount(R); returns the number of ncgen variables 28 29 lpDivision(f,I); two-sided division with remainder 29 30 lpGBPres2Poly(L,I); reconstructs a polynomial from the output of lpDivision … … 1004 1005 def R = freeAlgebra(r, 7); 1005 1006 isFreeAlgebra(R); 1007 } 1008 1009 proc lpNcgenCount(def R) 1010 "USAGE: lpNcgenCount(R); R a letterplace ring 1011 RETURN: int 1012 PURPOSE: returns the number of ncgen variables in the letterplace ring. 1013 EXAMPLE: example ncgenCount; shows examples 1014 " 1015 { 1016 return(attrib(R, "ncgenCount")); 1017 } 1018 example 1019 { 1020 "EXAMPLE:"; echo = 2; 1021 ring r = 0,(x,y,z),dp; 1022 def R = freeAlgebra(r, 7, 10); 1023 lpNcgenCount(R); // should be 10 1006 1024 } 1007 1025 -
Singular/attrib.cc
rda6d43a r7f5789 259 259 #ifdef HAVE_SHIFTBBA 260 260 PrintS("attr:isLetterplaceRing, type int\n"); 261 PrintS("attr:ncgenCount, type int\n"); 261 262 #endif 262 263 … … 331 332 res->data=(void *)(long)(((ring)v->Data())->isLPring); 332 333 } 334 else if ((strcmp(name,"ncgenCount")==0) 335 &&(/*v->Typ()*/t==RING_CMD)) 336 { 337 res->rtyp=INT_CMD; 338 res->data=(void *)(long)(((ring)v->Data())->LPncGenCount); 339 } 333 340 #endif 334 341 else … … 436 443 } 437 444 } 445 else if ((strcmp(name,"ncgenCount")==0) 446 &&(/*v->Typ()*/t==RING_CMD)) 447 { 448 if (c->Typ()==INT_CMD) 449 ((ring)v->Data())->LPncGenCount=(int)(long)c->Data(); 450 else 451 { 452 WerrorS("attribute `ncgenCount` must be int"); 453 return TRUE; 454 } 455 } 438 456 #endif 439 457 else -
Singular/dyn_modules/freealgebra/freealgebra.cc
rda6d43a r7f5789 191 191 192 192 // NULL if graph is undefined 193 static intvec* ufnarovskiGraph(ideal G )193 static intvec* ufnarovskiGraph(ideal G, ideal &standardWords) 194 194 { 195 195 long l = 0; … … 204 204 int lV = currRing->isLPring; 205 205 206 idealstandardWords = computeStandardWords(l, G);206 standardWords = computeStandardWords(l, G); 207 207 208 208 int n = IDELEMS(standardWords); … … 251 251 } 252 252 253 static BOOLEAN lpUfGraph(leftv res, leftv h) 254 { 255 const short t[]={1,IDEAL_CMD}; 256 if (iiCheckTypes(h,t,1)) 257 { 258 ideal I = (ideal) h->Data(); 259 res->rtyp = LIST_CMD; 260 261 ideal standardWords; 262 intvec* graph = ufnarovskiGraph(I, standardWords); 263 264 lists li=(lists)omAllocBin(slists_bin); 265 li->Init(2); 266 li->m[0].rtyp=INTMAT_CMD; 267 li->m[1].rtyp=IDEAL_CMD; 268 li->m[0].data=graph; 269 li->m[1].data=standardWords; 270 271 res->data = li; 272 273 if (errorreported) return TRUE; 274 return FALSE; 275 } 276 else return TRUE; 277 } 278 253 279 static std::vector<int> countCycles(const intvec* _G, int v, std::vector<int> path, std::vector<BOOLEAN> visited, std::vector<BOOLEAN> cyclic, std::vector<int> cache) 254 280 { … … 392 418 } 393 419 394 intvec* UG = ufnarovskiGraph(G); 420 ideal standardWords; 421 intvec* UG = ufnarovskiGraph(G, standardWords); 395 422 if (errorreported || UG == NULL) return -2; 396 423 return graphGrowth(UG); … … 423 450 p->iiAddCproc("freealgebra.so","lpVarAt",FALSE,lpVarAt); 424 451 p->iiAddCproc("freealgebra.so","lpGkDim",FALSE,lpGkDim); 452 p->iiAddCproc("freealgebra.so","lpUfGraph",FALSE,lpUfGraph); 425 453 426 454 p->iiAddCproc("freealgebra.so","stest",TRUE,stest);
Note: See TracChangeset
for help on using the changeset viewer.