Changeset c10f46 in git
- Timestamp:
- Aug 3, 2012, 1:06:22 PM (11 years ago)
- Branches:
- (u'spielwiese', 'e7cc1ebecb61be8b9ca6c18016352af89940b21a')
- Children:
- b0732eb4254fbe76540d72c337f3d7f985adf948
- Parents:
- b8610796eaca5ba7db8dc75f8bc88d698e077b365abb0e7fdca82a2bad9778e410148c74d7b49a0b
- Files:
-
- 2 added
- 48 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/modstd.lib
rb86107 rc10f46 1 1 //////////////////////////////////////////////////////////////////////////////// 2 version="$Id $";2 version="$Id: modstd.lib 14375 2011-08-23 09:29:47Z steidel $"; 3 3 category = "Commutative Algebra"; 4 4 info=" … … 8 8 @* G. Pfister pfister@mathematik.uni-kl.de 9 9 @* H. Schoenemann hannes@mathematik.uni-kl.de 10 @* A. Steenpass steenpass@mathematik.uni-kl.de 10 11 @* S. Steidel steidel@mathematik.uni-kl.de 11 12 … … 26 27 LIB "poly.lib"; 27 28 LIB "ring.lib"; 29 LIB "parallel.lib"; 28 30 29 31 //////////////////////////////////////////////////////////////////////////////// … … 243 245 if(printlevel >= 11) 244 246 { 245 "isIncluded( K,J) takes "+string(timer - t)+" seconds";247 "isIncluded(J,K) takes "+string(timer - t)+" seconds"; 246 248 "j = "+string(j); 247 249 } … … 373 375 //////////////////////////////////////////////////////////////////////////////// 374 376 375 proc primeTest( idealI, bigint p)377 proc primeTest(def II, bigint p) 376 378 { 379 if(typeof(II) == "string") 380 { 381 execute("ideal I = "+II+";"); 382 } 383 else 384 { 385 ideal I = II; 386 } 387 388 I = simplify(I, 2); // erase zero generators 389 377 390 int i,j; 391 poly f; 392 number cnt; 378 393 for(i = 1; i <= size(I); i++) 379 394 { 380 for(j = 1; j <= size(I[i]); j++) 381 { 382 if((numerator(leadcoef(I[i][j])) mod p) == 0) { return(0); } 383 if((denominator(leadcoef(I[i][j])) mod p) == 0) { return(0); } 395 f = cleardenom(I[i]); 396 if(f == 0) { return(0); } 397 cnt = leadcoef(I[i])/leadcoef(f); 398 if((numerator(cnt) mod p) == 0) { return(0); } 399 if((denominator(cnt) mod p) == 0) { return(0); } 400 for(j = size(f); j > 0; j--) 401 { 402 if((leadcoef(f[j]) mod p) == 0) { return(0); } 384 403 } 385 404 } … … 390 409 391 410 proc primeList(ideal I, int n, list #) 392 "USAGE: primeList(I,n); ( resp. primeList(I,n,L); ) I ideal, n integer 393 RETURN: the intvec of n greatest primes <= 2147483647 (resp. n greatest primes 411 "USAGE: primeList(I,n[,ncores]); ( resp. primeList(I,n[,L,ncores]); ) I ideal, 412 n integer 413 RETURN: the intvec of n greatest primes <= 2147483647 (resp. n greatest primes 394 414 < L[size(L)] union with L) such that none of these primes divides any 395 415 coefficient occuring in I 416 NOTE: The number of cores to use can be defined by ncores, default is 1. 396 417 EXAMPLE: example primList; shows an example 397 418 " … … 399 420 intvec L; 400 421 int i,p; 422 int ncores = 1; 423 424 //----------------- Initialize optional parameter ncores --------------------- 425 if(size(#) > 0) 426 { 427 if(size(#) == 1) 428 { 429 if(typeof(#[1]) == "int") 430 { 431 ncores = #[1]; 432 # = list(); 433 } 434 } 435 else 436 { 437 ncores = #[2]; 438 } 439 } 440 401 441 if(size(#) == 0) 402 442 { … … 421 461 } 422 462 if(p == 2) { ERROR("no more primes"); } 423 for(i = 2; i <= n; i++) 424 { 425 p = prime(p-1); 426 while(!primeTest(I,p)) 463 if(ncores == 1) 464 { 465 for(i = 2; i <= n; i++) 427 466 { 428 467 p = prime(p-1); 429 if(p == 2) { ERROR("no more primes"); } 430 } 431 L[size(L)+1] = p; 468 while(!primeTest(I,p)) 469 { 470 p = prime(p-1); 471 if(p == 2) { ERROR("no more primes"); } 472 } 473 L[size(L)+1] = p; 474 } 475 } 476 else 477 { 478 int neededSize = size(L)+n-1;; 479 list parallelResults; 480 list arguments; 481 int neededPrimes = neededSize-size(L); 482 while(neededPrimes > 0) 483 { 484 arguments = list(); 485 for(i = ((neededPrimes div ncores)+1-(neededPrimes%ncores == 0)) 486 *ncores; i > 0; i--) 487 { 488 p = prime(p-1); 489 if(p == 2) { ERROR("no more primes"); } 490 arguments[i] = list("I", p); 491 } 492 parallelResults = parallelWaitAll("primeTest", arguments, 493 list(list(list(ncores)))); 494 for(i = size(arguments); i > 0; i--) 495 { 496 if(parallelResults[i]) 497 { 498 L[size(L)+1] = arguments[i][2]; 499 } 500 } 501 neededPrimes = neededSize-size(L); 502 } 503 if(size(L) > neededSize) 504 { 505 L = L[1..neededSize]; 506 } 432 507 } 433 508 return(L); … … 470 545 ideal I = imap(R,I); 471 546 547 intvec opt = option(get); 472 548 option(none); 473 549 option(prompt); … … 504 580 505 581 setring R; 582 option(set, opt); 506 583 return(imap(newR,sI),imap(newR,T)); 507 584 } … … 537 614 The standard basis computation modulo p does also vary depending on the 538 615 integer variant, namely 539 @* - variant = 1/4: std(.,#[1]) resp. groebner, 540 @* - variant = 2/5: groebner, 541 @* - variant = 3/6: homog. - std(.,#[1]) resp. groebner - dehomog.. 616 @* - variant = 1: std(.,#[1]) resp. groebner, 617 @* - variant = 2: groebner, 618 @* - variant = 3: homog. - std(.,#[1]) resp. groebner - dehomog., 619 @* - variant = 4: fglm. 542 620 EXAMPLE: example modpStd; shows an example 543 621 " … … 552 630 option(redSB); 553 631 554 int t = timer; 555 if((variant == 1) || (variant == 4)) 632 if(variant == 1) 556 633 { 557 634 if(size(#) > 0) … … 565 642 } 566 643 567 if( (variant == 2) || (variant == 5))644 if(variant == 2) 568 645 { 569 646 i = groebner(i); 570 647 } 571 648 572 if( (variant == 3) || (variant == 6))649 if(variant == 3) 573 650 { 574 651 list rl = ringlist(@r); … … 607 684 } 608 685 609 t = timer;610 686 i = subst(i, homvar, 1); 611 687 i = simplify(i, 34); … … 615 691 i = interred(i); 616 692 kill HomR; 693 } 694 695 if(variant == 4) 696 { 697 def R1 = changeord("dp"); 698 setring R1; 699 ideal i = fetch(@r,i); 700 i = std(i); 701 setring @r; 702 i = fglm(R1,i); 617 703 } 618 704 … … 646 732 RETURN: a standard basis of I if no warning appears; 647 733 NOTE: The procedure computes a standard basis of I (over the rational 648 numbers) by using modular methods. If a warning appears then the 649 result is a standard basis containing I and with high probability 650 a standard basis of I. 734 numbers) by using modular methods. 651 735 By default the procedure computes a standard basis of I for sure, but 652 736 if the optional parameter #[2] = 0, it computes a standard basis of I 653 with high probability and a warning appears at the end.737 with high probability. 654 738 The procedure distinguishes between different variants for the standard 655 739 basis computation in positive characteristic depending on the ordering 656 740 of the basering, the parameter #[2] and if the ideal I is homogeneous. 657 @* - variant = 1, if I is homogeneous and exactness = 0, 658 @* - variant = 2, if I is not homogeneous, 1-block-ordering and 659 exactness = 0, 741 @* - variant = 1, if I is homogeneous, 742 @* - variant = 2, if I is not homogeneous, 1-block-ordering, 660 743 @* - variant = 3, if I is not homogeneous, complicated ordering (lp or 661 > 1 block) and exactness = 0, 662 @* - variant = 4, if I is homogeneous and exactness = 1, 663 @* - variant = 5, if I is not homogeneous, 1-block-ordering and 664 exactness = 1, 665 @* - variant = 6, if I is not homogeneous, complicated ordering (lp or 666 > 1 block) and exactness = 1. 744 > 1 block), 745 @* - variant = 4, if I is not homogeneous, ordering lp, dim(I) = 0. 667 746 EXAMPLE: example modStd; shows an example 668 747 " … … 752 831 if(printlevel >= 10) 753 832 { 754 "n1 = "+string(n1)+", n2 = "+string(n2)+", n3 = "+string(n3); 833 "n1 = "+string(n1)+", n2 = "+string(n2)+", n3 = "+string(n3) 834 +", exactness = "+string(exactness); 755 835 } 756 836 … … 761 841 762 842 //-------------------- Initialize the list of primes ------------------------- 763 intvec L = primeList(I,n2); 843 int tt = timer; 844 int rt = rtimer; 845 intvec L = primeList(I,n2,n1); 846 if(printlevel >= 10) 847 { 848 "CPU-time for primeList: "+string(timer-tt)+" seconds."; 849 "Real-time for primeList: "+string(rtimer-rt)+" seconds."; 850 } 764 851 L[5] = prime(random(an,en)); 765 852 … … 768 855 int h = homog(I); 769 856 770 inttt = timer;771 intrt = rtimer;857 tt = timer; 858 rt = rtimer; 772 859 773 860 if(!mixedTest()) … … 775 862 if(h) 776 863 { 777 if(exactness == 0) 778 { 779 variant = 1; 780 if(printlevel >= 10) { "variant = 1"; } 781 } 782 if(exactness == 1) 783 { 784 variant = 4; 785 if(printlevel >= 10) { "variant = 4"; } 786 } 864 variant = 1; 865 if(printlevel >= 10) { "variant = 1"; } 866 787 867 rl[1] = L[5]; 788 868 def @r = ring(rl); … … 802 882 if((find(ordstr_R0, "M") > 0) || (find(ordstr_R0, "a") > 0) || neg) 803 883 { 804 if(exactness == 0) 805 { 806 variant = 2; 807 if(printlevel >= 10) { "variant = 2"; } 808 } 809 if(exactness == 1) 810 { 811 variant = 5; 812 if(printlevel >= 10) { "variant = 5"; } 813 } 884 variant = 2; 885 if(printlevel >= 10) { "variant = 2"; } 814 886 } 815 887 else … … 827 899 if((order == "simple") || (size(rl) > 4)) 828 900 { 829 if(exactness == 0) 901 variant = 2; 902 if(printlevel >= 10) { "variant = 2"; } 903 } 904 else 905 { 906 rl[1] = L[5]; 907 def @r = ring(rl); 908 setring @r; 909 910 def @s = changeord("dp"); 911 setring @s; 912 ideal I = std(fetch(R0,I)); 913 if(dim(I) == 0) 830 914 { 831 variant = 2;832 if(printlevel >= 10) { "variant = 2"; }915 variant = 4; 916 if(printlevel >= 10) { "variant = 4"; } 833 917 } 834 if(exactness == 1) 835 { 836 variant = 5; 837 if(printlevel >= 10) { "variant = 5"; } 838 } 839 } 840 else 841 { 842 if(exactness == 0) 918 else 843 919 { 844 920 variant = 3; 845 921 if(printlevel >= 10) { "variant = 3"; } 922 923 int nvar@r = nvars(@r); 924 intvec w; 925 for(i = 1; i <= nvar@r; i++) 926 { 927 w[i] = deg(var(i)); 928 } 929 w[nvar@r + 1] = 1; 930 931 list hiRi = hilbRing(fetch(R0,I),w); 932 intvec W = hiRi[2]; 933 @s = hiRi[1]; 934 setring @s; 935 936 Id(1) = std(Id(1)); 937 intvec hi = hilb(Id(1), 1, W); 846 938 } 847 if(exactness == 1) 848 { 849 variant = 6; 850 if(printlevel >= 10) { "variant = 6"; } 851 } 852 853 rl[1] = L[5]; 854 def @r = ring(rl); 855 setring @r; 856 int nvar@r = nvars(@r); 857 intvec w; 858 for(i = 1; i <= nvar@r; i++) 859 { 860 w[i] = deg(var(i)); 861 } 862 w[nvar@r + 1] = 1; 863 864 list hiRi = hilbRing(fetch(R0,I),w); 865 intvec W = hiRi[2]; 866 def @s = hiRi[1]; 867 setring @s; 868 869 Id(1) = std(Id(1)); 870 intvec hi = hilb(Id(1), 1, W); 871 939 872 940 setring R0; 873 941 kill @r,@s; … … 971 1039 link l(i) = "ssi:fork"; 972 1040 open(l(i)); 973 if((variant == 1) || (variant == 3) || 974 (variant == 4) || (variant == 6)) 1041 if((variant == 1) || (variant == 3)) 975 1042 { 976 1043 write(l(i), quote(modpStd(I_for_fork, eval(L[i + 1]), 977 1044 eval(variant), eval(hi)))); 978 1045 } 979 if((variant == 2) || (variant == 5))1046 if((variant == 2) || (variant == 4)) 980 1047 { 981 1048 write(l(i), quote(modpStd(I_for_fork, eval(L[i + 1]), … … 985 1052 986 1053 int t = timer; 987 if((variant == 1) || (variant == 3) || (variant == 4) || (variant == 6))1054 if((variant == 1) || (variant == 3)) 988 1055 { 989 1056 P = modpStd(I_for_fork, L[1], variant, hi); 990 1057 } 991 if((variant == 2) || (variant == 5))1058 if((variant == 2) || (variant == 4)) 992 1059 { 993 1060 P = modpStd(I_for_fork, L[1], variant); … … 1005 1072 //-------------- Main standard basis computations in positive ---------------- 1006 1073 //---------------------- characteristic start here --------------------------- 1074 1075 list arguments_farey, results_farey; 1007 1076 1008 1077 while(1) … … 1029 1098 if(j <= size(L)) 1030 1099 { 1031 if((variant == 1) || (variant == 3) || 1032 (variant == 4) || (variant == 6)) 1100 if((variant == 1) || (variant == 3)) 1033 1101 { 1034 1102 write(l(i), quote(modpStd(I_for_fork, eval(L[j]), … … 1036 1104 j++; 1037 1105 } 1038 if((variant == 2) || (variant == 5))1106 if((variant == 2) || (variant == 4)) 1039 1107 { 1040 1108 write(l(i), quote(modpStd(I_for_fork, … … 1062 1130 while(j <= size(L)) 1063 1131 { 1064 if((variant == 1) || (variant == 3) || 1065 (variant == 4) || (variant == 6)) 1132 if((variant == 1) || (variant == 3)) 1066 1133 { 1067 1134 P = modpStd(I, L[j], variant, hi); 1068 1135 } 1069 if((variant == 2) || (variant == 5))1136 if((variant == 2) || (variant == 4)) 1070 1137 { 1071 1138 P = modpStd(I, L[j], variant); … … 1095 1162 //------------------- Lift results to basering via farey --------------------- 1096 1163 1097 tt = timer; 1164 tt = timer; rt = rtimer; 1098 1165 N = T2[1]; 1099 1166 for(i = 2; i <= size(T2); i++) { N = N*T2[i]; } 1100 1167 H = chinrem(T1,T2); 1101 J = farey(H,N); 1102 if(printlevel >= 10) { "Lifting-process takes "+string(timer - tt) 1103 +" seconds"; } 1168 if(n1 == 1) 1169 { 1170 J = farey(H,N); 1171 } 1172 else 1173 { 1174 for(i = ncols(H); i > 0; i--) 1175 { 1176 arguments_farey[i] = list(ideal(H[i]), N); 1177 } 1178 results_farey = parallelWaitAll("farey", arguments_farey, 1179 list(list(list(n1)))); 1180 for(i = ncols(H); i > 0; i--) 1181 { 1182 J[i] = results_farey[i][1]; 1183 } 1184 } 1185 if(printlevel >= 10) 1186 { 1187 "CPU-time for lifting-process is "+string(timer - tt)+" seconds."; 1188 "Real-time for lifting-process is "+string(rtimer - rt)+" seconds."; 1189 } 1104 1190 1105 1191 //---------------- Test if we already have a standard basis of I -------------- 1106 1192 1107 1193 tt = timer; rt = rtimer; 1108 if((variant == 1) || (variant == 3) || (variant == 4) || (variant == 6))1194 if((variant == 1) || (variant == 3)) 1109 1195 { 1110 1196 pTest = pTestSB(I,J,L,variant,hi); 1111 1197 } 1112 if((variant == 2) || (variant == 5))1198 if((variant == 2) || (variant == 4)) 1113 1199 { 1114 1200 pTest = pTestSB(I,J,L,variant); … … 1132 1218 1133 1219 attrib(J,"isSB",1); 1134 tt = timer; rt = rtimer; 1135 sizeTest = 1 - isIncluded(I,J,n1); 1136 1137 if(printlevel >= 10) 1138 { 1139 "CPU-time for checking if I subset <G> is " 1140 +string(timer - tt)+" seconds."; 1141 "Real-time for checking if I subset <G> is " 1142 +string(rtimer - rt)+" seconds."; 1143 } 1144 1145 if(sizeTest == 0) 1146 { 1147 if((variant == 1) || (variant == 2) || (variant == 3)) 1148 { 1149 "==========================================================="; 1150 "WARNING: Output might not be a standard basis of the input."; 1151 "==========================================================="; 1152 option(set, opt); 1153 if(n1 > 1) { kill I_for_fork; } 1154 return(J); 1155 } 1156 if((variant == 4) || (variant == 5) || (variant == 6)) 1220 1221 if(exactness == 0) 1222 { 1223 option(set, opt); 1224 if(n1 > 1) { kill I_for_fork; } 1225 return(J); 1226 } 1227 1228 if(exactness == 1) 1229 { 1230 tt = timer; rt = rtimer; 1231 sizeTest = 1 - isIncluded(I,J,n1); 1232 1233 if(printlevel >= 10) 1234 { 1235 "CPU-time for checking if I subset <G> is " 1236 +string(timer - tt)+" seconds."; 1237 "Real-time for checking if I subset <G> is " 1238 +string(rtimer - rt)+" seconds."; 1239 } 1240 1241 if(sizeTest == 0) 1157 1242 { 1158 1243 tt = timer; rt = rtimer; … … 1185 1270 1186 1271 j = size(L) + 1; 1187 L = primeList(I,n3,L); 1272 tt = timer; rt = rtimer; 1273 L = primeList(I,n3,L,n1); 1274 if(printlevel >= 10) 1275 { 1276 "CPU-time for primeList: "+string(timer-tt)+" seconds."; 1277 "Real-time for primeList: "+string(rtimer-rt)+" seconds."; 1278 } 1188 1279 1189 1280 if(n1 > 1) … … 1192 1283 { 1193 1284 open(l(i)); 1194 if((variant == 1) || (variant == 3) || 1195 (variant == 4) || (variant == 6)) 1285 if((variant == 1) || (variant == 3)) 1196 1286 { 1197 1287 write(l(i), quote(modpStd(I_for_fork, eval(L[j+i-1]), 1198 1288 eval(variant), eval(hi)))); 1199 1289 } 1200 if((variant == 2) || (variant == 5))1290 if((variant == 2) || (variant == 4)) 1201 1291 { 1202 1292 write(l(i), quote(modpStd(I_for_fork, eval(L[j+i-1]), … … 1318 1408 def S = ring(rl); 1319 1409 setring S; 1410 intvec opt = option(get); 1320 1411 option(redSB); 1321 1412 module Z,M,Z2; … … 1362 1453 if(size(reduce(G3,testG1)) == 0) 1363 1454 { 1455 option(set, opt); 1364 1456 return(G3); 1365 1457 } -
Singular/LIB/parallel.lib
rb86107 rc10f46 3 3 category="General purpose"; 4 4 info=" 5 LIBRARY: parallel.lib An Interfacefor Parallelization5 LIBRARY: parallel.lib Tools for Parallelization 6 6 AUTHOR: Andreas Steenpass, e-mail: steenpass@mathematik.uni-kl.de 7 8 OVERVIEW: 9 This library provides tools to do several computations in parallel. They 10 are aimed at ordinary Singular users as well as authors of Singular 11 libraries. 12 @* Even without this library, it is possible to do execute self-defined 13 Singular commands in parallel using @ref{links}, but the handling of 14 such links can be quite tedious. With the pocedures described below, 15 this can be done by one-line commands. 16 @* There are many parallel 'skeletons' (i.e. ways in which parallel 17 tasks rely upon and interact with each other). A few of them are already 18 implemented. Future plans include an abstraction layer for modular 19 techniques, 'worker farms', and parallel tests. 7 20 8 21 SEE ALSO: link, modstd_lib, assprimeszerodim_lib … … 26 39 RETURN: a list, containing the results of commands[i] applied to arg[i], 27 40 i = 1, ..., size(commands). 28 @* The entries of the list commands must be strings.29 @* The entries of the list args must be lists.30 41 @* The procedure waits for N jobs to finish. 31 @* An optional timeout in ms can be provided. Default is 0 which 42 43 @* OPTIONAL PARAMETERS: 44 45 An optional timeout in ms can be provided. Default is 0 which 32 46 disables the timeout. 33 @* Supported linktypes are up to now \"ssi\" and \"mp\", see 47 48 Supported linktypes are up to now \"ssi\" and \"mp\", see 34 49 @ref{Ssi links} and @ref{MP links}. 50 51 Servers: 35 52 @* Each server is given by a list containing the address of the server, 36 53 the number of cores to use on this server and the command to start 37 Singular. If the address is \"localhost\", the processes will 38 be generated on the same machine using forks. If the command to 39 start Singular is \"\" (the empty string), \"Singular\" will be 40 used. Default is @code{list(\"localhost\", system(\"cpu\"), \"\")}. 41 There are some obvious shortcuts for servers, e.g. \"myserver\" is 54 Singular. 55 @* If the address is \"localhost\", the processes will be generated on 56 the same machine using forks. If the command to start Singular is 57 \"\" (the empty string), \"Singular\" will be used. 58 @* Default is @code{list(\"localhost\", system(\"cpu\"), \"\")}. 59 @* There are some obvious shortcuts for servers, e.g. \"myserver\" is 42 60 a shortcut for 43 61 @code{list(\"myserver\", [nb. of cores on myserver], \"\")}, or 3 44 62 for @code{list(\"localhost\", 3, \"\")}. 63 64 Memory limits: 45 65 @* If an intvec maxmemory of size @code{size(commands)} is given, the 46 66 i-th job will be killed if it uses more than maxmemory[i] MB of 47 67 memory. If maxmemory[i] is 0, there will be no restraint for the 48 68 i-th job. Default is @code{0:size(commands)}. 49 NOTE: The returned list may contain more than N results if several jobs 69 NOTE: The entries of the list commands must be strings. 70 @* The entries of the list args must be lists. 71 @* The returned list may contain more than N results if several jobs 50 72 finished \"at the same time\". It may contain less than N results in 51 73 the case of timeout or errors occurring. … … 368 390 } 369 391 write(l(i), quote(execute("result = "+eval(commands[k]) 370 +"(currentargs[1..size(currentargs)]);")));392 +"("+argsToString("currentargs", size(currentargs))+");"))); 371 393 assignment[i] = k; 372 394 k++; … … 455 477 } 456 478 write(l(wait), quote(execute("def result = "+eval(commands[k]) 457 +"(currentargs[1..size(currentargs)]);")));479 +"("+argsToString("currentargs", size(currentargs))+");"))); 458 480 assignment[wait] = k; 459 481 k++; … … 542 564 ideal i = z8+z6+4z5+4z3+4z2+4, y-z2; 543 565 ideal j = 3x3y+x3+xy3+y2z2, 2x3z-xy-xz3-y4-z2, 2x2yz-2xy2+xz2-y4; 544 list commands = list("std", "primdecGTZ", "primdecSY", "std", "primdecGTZ",545 " primdecSY");566 list commands = list("std", "primdecGTZ", "primdecSY", 567 "std", "primdecGTZ", "primdecSY"); 546 568 list args = list(list(i), list(i), list(i), list(j), list(j), list(j)); 547 569 parallelWaitN(commands, args, 3); … … 717 739 return(i); 718 740 } 741 742 static proc argsToString(string name, int length) 743 { 744 string arglist; 745 if(length > 0) { 746 arglist = name+"[1]"; 747 } 748 int i; 749 for(i = 2; i <= length; i++) { 750 arglist = arglist+", "+name+"["+string(i)+"]"; 751 } 752 return(arglist); 753 } -
Singular/LIB/realclassify.lib
rb86107 rc10f46 9 9 OVERVIEW: 10 10 A library for classifying isolated hypersurface singularities over the reals 11 w.r.t. right 12 equivalence, based on the determinator of singularities by V.I. Arnold. 13 This library is based on classify.lib by Kai Krueger, but handles the real 14 case, while classify.lib does the complex classification. 11 w.r.t. right equivalence, based on the determinator of singularities by 12 V.I. Arnold. This library is based on classify.lib by Kai Krueger, but 13 handles the real case, while classify.lib does the complex classification. 14 15 REFERENCES: 16 Arnold, Varchenko, Gusein-Zade: Singularities of Differentiable Maps. 17 Vol. 1: The classification of critical points caustics and wave fronts. 18 Birkh\"auser, Boston 1985 19 20 Greuel, Lossen, Shustin: Introduction to singularities and deformations. 21 Springer, Berlin 2007 15 22 16 23 PROCEDURES: … … 31 38 RETURN: A list containing (in this order) 32 39 @* - the type of the singularity as a string, 33 @* - the normal form as well as40 @* - the normal form, 34 41 @* - the corank, the Milnor number, the inertia index and 35 42 a bound for the determinacy as integers. … … 778 785 "EXAMPLE:"; 779 786 echo = 2; 780 LIB "realclassify.lib";781 787 ring r = 0, (x,y,z), ds; 782 788 poly f = (x2+3y-2z)^2+xyz-(x-y3+x2z3)^3; … … 1006 1012 "EXAMPLE:"; 1007 1013 echo = 2; 1008 LIB "realclassify.lib";1009 1014 ring r = 0, (x,y,z), ds; 1010 1015 poly f = (x2+3y-2z)^2+xyz-(x-y3+x2z3)^3; … … 1053 1058 "EXAMPLE:"; 1054 1059 echo = 2; 1055 LIB "realclassify.lib";1056 1060 ring r = 0, (x,y), ds; 1057 1061 poly f = x3+y4; … … 1145 1149 "EXAMPLE:"; 1146 1150 echo = 2; 1147 LIB "realclassify.lib";1148 1151 ring r = 0, (x,y), ds; 1149 1152 poly f = x3+xy3; -
factory/libfac/Makefile.am
r5abb0e7 rc10f46 48 48 EXTRA_DIST = factor/class.cc \ 49 49 factor/test.cc test.cc testcs.cc header.tpl \ 50 testscharset/tests bin \50 charset/tests bin \ 51 51 ChangeLog 00README 52 52 -
factory/libfac/charset/alg_factor.cc
r5abb0e7 rc10f46 2 2 // emacs edit mode for this file is -*- C++ -*- 3 3 //////////////////////////////////////////////////////////// 4 //////////////////////////////////////////////////////////// 4 5 5 // FACTORY - Includes 6 6 #include <factory.h> … … 18 18 #include "alg_factor.h" 19 19 20 void out_cf(c har *s1,const CanonicalForm &f,char *s2);20 void out_cf(const char *s1,const CanonicalForm &f,const char *s2); 21 21 22 22 #ifdef ALGFACTORDEBUG … … 80 80 // replacement for factory's broken psr 81 81 static CanonicalForm 82 mypsr ( const CanonicalForm &rr, const CanonicalForm &vv, const Variable & x ){ 82 mypsr ( const CanonicalForm &rr, const CanonicalForm &vv, const Variable & x ) 83 { 83 84 CanonicalForm r=rr, v=vv, l, test, lu, lv, t, retvalue; 84 85 int dr, dv, d,n=0; … … 104 105 // replacement for factory's broken resultant 105 106 static CanonicalForm 106 resultante( const CanonicalForm & f, const CanonicalForm& g, const Variable & v ){ 107 resultante( const CanonicalForm & f, const CanonicalForm& g, const Variable & v ) 108 { 107 109 bool on_rational = isOn(SW_RATIONAL); 108 110 On(SW_RATIONAL); … … 113 115 if (!on_rational) Off(SW_RATIONAL); 114 116 115 return resultant(fz,gz,v);117 return resultant(fz,gz,v); 116 118 } 117 119 … … 133 135 sqrf_norm_sub( const CanonicalForm & f, const CanonicalForm & PPalpha, 134 136 CFGenerator & myrandom, CanonicalForm & s, CanonicalForm & g, 135 CanonicalForm & R){ 137 CanonicalForm & R) 138 { 136 139 Variable y=PPalpha.mvar(),vf=f.mvar(); 137 140 CanonicalForm temp, Palpha=PPalpha, t; … … 147 150 148 151 // Norm, resultante taken with respect to y 149 while ( !sqfreetest ){ 152 while ( !sqfreetest ) 153 { 150 154 DEBOUTLN(CERR, "sqrf_norm_sub: Palpha= ", Palpha); 151 155 R = resultante(Palpha, g, y); R= R* bCommonDen(R); … … 160 164 DEBOUTLN(CERR, "sqrf_norm_sub: sqfreetest= ", sqfreetest); 161 165 } 162 else{ 166 else 167 { 163 168 DEBOUTMSG(CERR, "Starting SqrFreeTest(R)!"); 164 169 // Look at SqrFreeTest! … … 169 174 if (getAlgVar(R,X)) 170 175 { 171 if (R.isUnivariate())172 176 testlist=factorize( R, X ); 173 else174 testlist= Factorize(R, X, 0);175 177 } 176 178 else … … 183 185 DEBOUTLN(CERR, "SqrFreeTest(R)= ", sqfreetest); 184 186 } 185 if ( ! sqfreetest ){ 187 if ( ! sqfreetest ) 188 { 186 189 myrandom.next(); 187 190 DEBOUTLN(CERR, "sqrf_norm_sub generated new myrandom item: ", myrandom.item()); … … 198 201 sqrf_agnorm_sub( const CanonicalForm & f, const CanonicalForm & PPalpha, 199 202 AlgExtGenerator & myrandom, CanonicalForm & s, CanonicalForm & g, 200 CanonicalForm & R){ 203 CanonicalForm & R) 204 { 201 205 Variable y=PPalpha.mvar(),vf=f.mvar(); 202 206 CanonicalForm temp, Palpha=PPalpha, t; … … 212 216 213 217 // Norm, resultante taken with respect to y 214 while ( !sqfreetest ){ 218 while ( !sqfreetest ) 219 { 215 220 DEBOUTLN(CERR, "sqrf_norm_sub: Palpha= ", Palpha); 216 221 R = resultante(Palpha, g, y); R= R* bCommonDen(R); … … 225 230 DEBOUTLN(CERR, "sqrf_norm_sub: sqfreetest= ", sqfreetest); 226 231 } 227 else{ 232 else 233 { 228 234 DEBOUTMSG(CERR, "Starting SqrFreeTest(R)!"); 229 235 // Look at SqrFreeTest! … … 234 240 if (getAlgVar(R,X)) 235 241 { 236 if (R.isUnivariate())237 242 testlist=factorize( R, X ); 238 else239 testlist= Factorize(R, X, 0);240 243 } 241 244 else … … 248 251 DEBOUTLN(CERR, "SqrFreeTest(R)= ", sqfreetest); 249 252 } 250 if ( ! sqfreetest ){ 253 if ( ! sqfreetest ) 254 { 251 255 myrandom.next(); 252 256 DEBOUTLN(CERR, "sqrf_norm_sub generated new myrandom item: ", myrandom.item()); … … 264 268 sqrf_norm( const CanonicalForm & f, const CanonicalForm & PPalpha, 265 269 const Variable & Extension, CanonicalForm & s, CanonicalForm & g, 266 CanonicalForm & R) {267 270 CanonicalForm & R) 271 { 268 272 DEBOUTLN(CERR, "sqrf_norm: f= ", f); 269 273 DEBOUTLN(CERR, "sqrf_norm: Palpha= ", PPalpha); 270 if ( getCharacteristic() == 0 ) { 274 if ( getCharacteristic() == 0 ) 275 { 271 276 IntGenerator myrandom; 272 277 DEBOUTMSG(CERR, "sqrf_norm: no extension, char=0"); … … 278 283 DEBOUTLN(CERR, "sqrf_norm: R= ", R); 279 284 } 280 else if ( degree(Extension) > 0 ){ // working over Extensions 285 else if ( degree(Extension) > 0 ) // working over Extensions 286 { 281 287 DEBOUTLN(CERR, "sqrf_norm: degree of extension is ", degree(Extension)); 282 288 AlgExtGenerator myrandom(Extension); 283 289 sqrf_agnorm_sub(f,PPalpha, myrandom, s,g,R); 284 290 } 285 else{ 291 else 292 { 286 293 FFGenerator myrandom; 287 294 DEBOUTMSG(CERR, "sqrf_norm: degree of extension is 0"); … … 296 303 Variable x; 297 304 298 for ( VarlistIterator i=uord; i.hasItem(); i++){ 305 for ( VarlistIterator i=uord; i.hasItem(); i++) 306 { 299 307 x=i.getItem(); 300 for ( CFListIterator j=Astar; j.hasItem(); j++ ){ 308 for ( CFListIterator j=Astar; j.hasItem(); j++ ) 309 { 301 310 elem= j.getItem(); 302 if ( degree(elem,x) > 0 ){ // x actually occures in Astar 311 if ( degree(elem,x) > 0 ) // x actually occures in Astar 312 { 303 313 output.append(x); 304 314 break; … … 312 322 // Must be a power of p: i.e. y^{p^e}-x 313 323 static int 314 inseperable(const CFList & Astar){ 324 inseperable(const CFList & Astar) 325 { 315 326 CanonicalForm elem; 316 327 int Counter= 1; 317 328 318 329 if ( Astar.length() == 0 ) return 0; 319 for ( CFListIterator i=Astar; i.hasItem(); i++){ 330 for ( CFListIterator i=Astar; i.hasItem(); i++) 331 { 320 332 elem= i.getItem(); 321 333 if ( elem.deriv() == elem.genZero() ) return Counter; … … 327 339 // calculate gcd of f and g in char=0 328 340 static CanonicalForm 329 gcd0( CanonicalForm f, CanonicalForm g ){ 341 gcd0( CanonicalForm f, CanonicalForm g ) 342 { 330 343 int charac= getCharacteristic(); 331 344 int save=isOn(SW_RATIONAL); … … 333 346 CanonicalForm ff= mapinto(f), gg= mapinto(g); 334 347 CanonicalForm result= gcd(ff,gg); 335 setCharacteristic(charac); 348 setCharacteristic(charac); 336 349 if (save) On(SW_RATIONAL); 337 350 return mapinto(result); … … 344 357 // have enough elements to plug in. 345 358 static int 346 getextension( IntList & degreelist, int n){ 359 getextension( IntList & degreelist, int n) 360 { 347 361 int charac= getCharacteristic(); 348 362 setCharacteristic(0); // need it for k ! … … 543 557 544 558 static CFFList 545 endler( const CanonicalForm & f, const CFList & AS, const Varlist & uord ){ 559 endler( const CanonicalForm & f, const CFList & AS, const Varlist & uord ) 560 { 546 561 CanonicalForm F=f, g, q,r; 547 562 CFFList Output; … … 551 566 Variable vg; 552 567 553 for (i=as; i.hasItem(); i++){ 568 for (i=as; i.hasItem(); i++) 569 { 554 570 g= i.getItem(); 555 if (g.deriv() == 0 ){ 571 if (g.deriv() == 0 ) 572 { 556 573 DEBOUTLN(CERR, "Inseperable extension detected: ", g); 557 for (j=uord; j.hasItem(); j++){ 574 for (j=uord; j.hasItem(); j++) 575 { 558 576 if ( degree(g,j.getItem()) > 0 ) vg= j.getItem(); 559 577 } … … 568 586 // Now transform all remaining polys in as: 569 587 int x=0; 570 for (ii=i; ii.hasItem(); ii++){ 571 if ( x != 0 ){ 588 for (ii=i; ii.hasItem(); ii++) 589 { 590 if ( x != 0 ) 591 { 572 592 divrem(ii.getItem(), gg, q,r); 573 593 // CERR << ii.getItem() << " divided by " << gg << "\n"; … … 595 615 596 616 // Transform back: 597 for ( CFFListIterator k=factorlist; k.hasItem(); k++){ 617 for ( CFFListIterator k=factorlist; k.hasItem(); k++) 618 { 598 619 CanonicalForm factor= k.getItem().factor(); 599 620 ii=One; 600 for (i=Two; i.hasItem(); i++){ 621 for (i=Two; i.hasItem(); i++) 622 { 601 623 DEBOUTLN(CERR, "Mapping ", i.getItem()); 602 624 DEBOUTLN(CERR, " to ", ii.getItem()); … … 618 640 // no transcendentals, seperable and inseperable extensions 619 641 CFFList 620 newfactoras( const CanonicalForm & f, const CFList & as, int &success){ 642 newfactoras( const CanonicalForm & f, const CFList & as, int &success) 643 { 621 644 Variable vf=f.mvar(); 622 645 CFListIterator i; … … 751 774 752 775 CFFList 753 newcfactor(const CanonicalForm & f, const CFList & as, int & success ){ 776 newcfactor(const CanonicalForm & f, const CFList & as, int & success ) 777 { 754 778 Off(SW_RATIONAL); 755 CFFList Output, output, Factors=Factorize(f); On(SW_RATIONAL); 779 CFFList Output, output, Factors=Factorize(f); 780 On(SW_RATIONAL); 756 781 Factors.removeFirst(); 757 782 … … 760 785 761 786 success=1; 762 for ( CFFListIterator i=Factors; i.hasItem(); i++ ){ 787 for ( CFFListIterator i=Factors; i.hasItem(); i++ ) 788 { 763 789 output=newfactoras(i.getItem().factor(),as, success); 764 790 for ( CFFListIterator j=output; j.hasItem(); j++) -
factory/libfac/charset/charset.cc
r5abb0e7 rc10f46 493 493 if ( degree(elem) > 1 ) // linear poly's are irreduzible 494 494 { 495 qs = Factorize(elem);495 qs = factorize(elem); 496 496 // remove a constant 497 497 if (qs.getFirst().factor().degree()==0) qs.removeFirst(); -
factory/libfac/configure
r5abb0e7 rc10f46 530 530 libfac_name="\"Factorization and characteristic sets library\"" 531 531 532 libfac_version="3.1. 3"532 libfac_version="3.1.5" 533 533 cat >> confdefs.h <<EOF 534 534 #define LIBFAC_VERSION "$libfac_version" … … 536 536 537 537 538 libfac_date="\" March 2011\""538 libfac_date="\"July 2012\"" 539 539 cat >> confdefs.h <<EOF 540 540 #define LIBFAC_DATE $libfac_date -
factory/libfac/configure.in
r5abb0e7 rc10f46 15 15 libfac_name="\"Factorization and characteristic sets library\"" 16 16 AC_SUBST(libfac_name) 17 libfac_version="3.1. 3"17 libfac_version="3.1.5" 18 18 AC_DEFINE_UNQUOTED(LIBFAC_VERSION,"$libfac_version") 19 19 AC_SUBST(libfac_version) 20 libfac_date="\" March 2011\""20 libfac_date="\"July 2012\"" 21 21 AC_DEFINE_UNQUOTED(LIBFAC_DATE,$libfac_date) 22 22 AC_SUBST(libfac_date) -
factory/libfac/factor/Factor.cc
r5abb0e7 rc10f46 27 27 28 28 #include "alg_factor.h" 29 void out_cf(c har *s1,const CanonicalForm &f,char *s2);29 void out_cf(const char *s1,const CanonicalForm &f,const char *s2); 30 30 void out_cff(CFFList &L); 31 31 … … 52 52 * ( in factorize, alpha.level() must be < 0 ) 53 53 */ 54 static 54 55 CFFList factorize2 ( const CanonicalForm & f, 55 56 const Variable & alpha, const CanonicalForm & mipo ) … … 61 62 else 62 63 { 63 bool repl=(f.mvar() != alpha);64 64 //out_cf("f2 - factor:",f,"\n"); 65 65 //out_cf("f2 - ext:",alpha,"\n"); … … 67 67 Variable X=rootOf(mipo); 68 68 CanonicalForm F=f; 69 if (repl)F=replacevar(f,alpha,X);69 F=replacevar(f,alpha,X); 70 70 //out_cf("call - factor:",F,"\n"); 71 71 //out_cf("call - ext:",X,"\n"); … … 73 73 CFFList L=factorize(F,X); 74 74 CFFListIterator i=L; 75 if (repl)76 75 { 77 76 CFFList Outputlist; … … 82 81 i.getItem().exp())); 83 82 } 83 //out_cff(Outputlist); 84 84 return Outputlist; 85 85 } 86 else return L;87 86 } 88 87 } … … 393 392 generate_mipo( int degree_of_Extension , const Variable & Extension ){ 394 393 FFRandom gen; 395 if ( degree(Extension) > 0 ) GFRandom gen; 396 else { 397 if ( degree(Extension) == 0 ) FFRandom gen; 398 else 399 { 400 factoryError("libfac: evaluate: Extension not inFF() or inGF() !"); 401 } 402 } 394 if (degree (Extension) < 0) 395 factoryError("libfac: evaluate: Extension not inFF() or inGF() !"); 403 396 return find_irreducible( degree_of_Extension, gen, Variable(1) ); 404 397 } … … 465 458 466 459 static int 467 specializePoly(const CanonicalForm & f, Variable & Extension, int deg, SFormList & Substitutionlist, int i,int j){ 460 specializePoly(const CanonicalForm & f, Variable & Extension, int deg, SFormList & Substitutionlist, int i,int j) 461 { 468 462 Variable minpoly= Extension; 469 463 int ok,extended= degree(Extension), working_over_extension; … … 474 468 // First try: 475 469 ok = try_specializePoly(f,minpoly,deg,Substitutionlist,i,j); 476 while ( ! ok ){ // we have to extend! 470 while ( ! ok ) // we have to extend! 471 { 472 SFormList origS=Substitutionlist; 477 473 extended+= 1; 478 if ( ! working_over_extension ){ 479 minpoly= rootOf(generate_mipo( extended,Extension )); 474 if ( ! working_over_extension ) 475 { 476 if (!hasMipo(Extension)) 477 minpoly= rootOf (generate_mipo (extended, Extension)); 478 else 479 { 480 setReduce (Extension, false); 481 setMipo (minpoly, generate_mipo ( extended, Extension)); 482 setReduce (Extension, true); 483 } 480 484 Extension= minpoly; 481 485 ok= try_specializePoly(f,minpoly,deg,Substitutionlist,i,j); 486 if (!ok) 487 Substitutionlist=origS; 482 488 } 483 489 else … … 804 810 { 805 811 //out_cf("Factorize ",F,"\n"); 806 CFFList Outputlist,SqrFreeList,Intermediatelist,Outputlist2; 807 ListIterator<CFFactor> i,j; 808 CanonicalForm g=1,unit=1,r=1; 809 Variable minpoly; // dummy 810 int exp; 811 CFMap m; 812 CFFList Outputlist; 812 813 813 814 // INTERRUPTHANDLER … … 831 832 return Outputlist; 832 833 } 834 CFFList SqrFreeList,Intermediatelist,Outputlist2; 835 ListIterator<CFFactor> i,j; 836 CanonicalForm g=1,unit=1,r=1; 837 Variable minpoly; // dummy 838 int exp; 839 CFMap m; 833 840 TIMING_START(factorize_time); 834 841 // search an "optimal" main variavble -
factory/variable.cc
r5abb0e7 rc10f46 215 215 } 216 216 217 /*void setMipo ( const Variable & alpha, const CanonicalForm & mipo)217 void setMipo ( const Variable & alpha, const CanonicalForm & mipo) 218 218 { 219 219 ASSERT( alpha.level() < 0 && alpha.level() != LEVELBASE, "illegal extension" ); 220 220 algextensions[-alpha.level()]= ext_entry((InternalPoly*)(conv2mipo( mipo, alpha ).getval()), true ); 221 } */221 } 222 222 223 223 bool hasMipo( const Variable & alpha ) 224 224 { 225 ASSERT( alpha.level() < 0 && alpha.level() != LEVELBASE, "illegal extension" );226 return ( (algextensions!=NULL) && getReduce(alpha) );225 ASSERT( alpha.level() < 0, "illegal extension" ); 226 return (alpha.level() != LEVELBASE && (algextensions!=NULL) && getReduce(alpha) ); 227 227 } 228 228 -
factory/variable.h
r5abb0e7 rc10f46 78 78 inline char name( const Variable & v ) { return v.name(); } 79 79 80 void setReduce( const Variable & alpha, bool reduce ); 81 void setMipo ( const Variable & alpha, const CanonicalForm & mipo); 80 82 CanonicalForm getMipo( const Variable & alpha, const Variable & x ); 81 83 bool hasMipo( const Variable & alpha ); … … 93 95 InternalPoly * getInternalMipo ( const Variable & alpha ); 94 96 bool getReduce( const Variable & alpha ); 95 void setReduce( const Variable & alpha, bool reduce );96 97 97 98 #endif /* ! INCL_VARIABLE_H */
Note: See TracChangeset
for help on using the changeset viewer.