Changeset 90d772 in git
- Timestamp:
- May 2, 2005, 3:28:15 PM (18 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- c4e65ede88881de04fe2115143cd0fb9a0e67317
- Parents:
- 17695492ed27b2e174eb4ae917d029b1027d83a9
- Location:
- Singular/LIB
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/general.lib
r176954 r90d772 3 3 //eric, added absValue 11.04.2002 4 4 /////////////////////////////////////////////////////////////////////////////// 5 version="$Id: general.lib,v 1.4 4 2004-08-13 14:09:21Singular Exp $";5 version="$Id: general.lib,v 1.45 2005-05-02 13:28:15 Singular Exp $"; 6 6 category="General purpose"; 7 7 info=" … … 27 27 which(command); search for command and return absolute path, if found 28 28 primecoeffs(J[,q]); primefactors <= min(p,32003) of coeffs of J 29 primefactors(n [,p]); primefactors <= min(p,32003) of n 29 primefactors(n[,p]); primefactors <= min(p,32003) of n 30 timeStd(i,d) std(i) if the standard basis computation finished 31 after d-1 seconds and i otherwhise 32 timeFactorize(p,d) factorize(p) if the factorization finished after d-1 33 seconds otherwhise f is considered to be irreducible 34 factorH(p) changes variables to become the last variable the 35 principal one in the multivariate factorization and 36 factorizes then the polynomial 37 30 38 (parameters in square brackets [] are optional) 31 39 "; … … 1506 1514 } 1507 1515 /////////////////////////////////////////////////////////////////////////////// 1516 proc timeFactorize(poly i,list #) 1517 "USAGE: timeFactorize(p,d) poly p , integer d 1518 RETURN: factorize(p) if the factorization finished after d-1 1519 seconds otherwhise f is considered to be irreducible 1520 EXAMPLE: example timeFactorize; shows an example 1521 " 1522 { 1523 def P=basering; 1524 if (size(#) > 0) 1525 { 1526 if (system("with", "MP")) 1527 { 1528 if ((typeof(#[1]) == "int")&&(#[1])) 1529 { 1530 int wait = #[1]; 1531 int j = 10; 1532 1533 string bs = nameof(basering); 1534 link l_fork = "MPtcp:fork"; 1535 open(l_fork); 1536 write(l_fork, quote(system("pid"))); 1537 int pid = read(l_fork); 1538 write(l_fork, quote(timeFactorize(eval(i)))); 1539 1540 // sleep in small intervalls for appr. one second 1541 if (wait > 0) 1542 { 1543 while(j < 1000000) 1544 { 1545 if (status(l_fork, "read", "ready", j)) {break;} 1546 j = j + j; 1547 } 1548 } 1549 1550 // sleep in intervalls of one second from now on 1551 j = 1; 1552 while (j < wait) 1553 { 1554 if (status(l_fork, "read", "ready", 1000000)) {break;} 1555 j = j + 1; 1556 } 1557 1558 if (status(l_fork, "read", "ready")) 1559 { 1560 def result = read(l_fork); 1561 if (bs != nameof(basering)) 1562 { 1563 def PP = basering; 1564 setring P; 1565 def result = imap(PP, result); 1566 kill PP; 1567 } 1568 kill (l_fork); 1569 } 1570 else 1571 { 1572 list result; 1573 intvec v=1,1; 1574 result[1]=list(1,i); 1575 result[2]=v; 1576 j = system("sh", "kill " + string(pid)); 1577 } 1578 return (result); 1579 } 1580 } 1581 } 1582 return(factorH(i)); 1583 } 1584 example 1585 { "EXAMPLE:"; echo = 2; 1586 ring r=0,(x,y),dp; 1587 poly p=((x2+y3)^2+xy6)*((x3+y2)^2+x10y); 1588 p=p^2; 1589 //timeFactorize(p,2); 1590 //timeFactorize(p,20); 1591 } 1592 1593 proc timeStd(ideal i,list #) 1594 "USAGE: timeStd(i,d), i ideal, d integer 1595 RETURN: std(i) if the standard basis computation finished after 1596 d-1 seconds and i otherwhise 1597 EXAMPLE: example timeStd; shows an example 1598 " 1599 { 1600 def P=basering; 1601 if (size(#) > 0) 1602 { 1603 if (system("with", "MP")) 1604 { 1605 if ((typeof(#[1]) == "int")&&(#[1])) 1606 { 1607 int wait = #[1]; 1608 int j = 10; 1609 1610 string bs = nameof(basering); 1611 link l_fork = "MPtcp:fork"; 1612 open(l_fork); 1613 write(l_fork, quote(system("pid"))); 1614 int pid = read(l_fork); 1615 write(l_fork, quote(timeStd(eval(i)))); 1616 1617 // sleep in small intervalls for appr. one second 1618 if (wait > 0) 1619 { 1620 while(j < 1000000) 1621 { 1622 if (status(l_fork, "read", "ready", j)) {break;} 1623 j = j + j; 1624 } 1625 } 1626 j = 1; 1627 while (j < wait) 1628 { 1629 if (status(l_fork, "read", "ready", 1000000)) {break;} 1630 j = j + 1; 1631 } 1632 if (status(l_fork, "read", "ready")) 1633 { 1634 def result = read(l_fork); 1635 if (bs != nameof(basering)) 1636 { 1637 def PP = basering; 1638 setring P; 1639 def result = imap(PP, result); 1640 kill PP; 1641 } 1642 kill (l_fork); 1643 } 1644 else 1645 { 1646 ideal result=i; 1647 j = system("sh", "kill " + string(pid)); 1648 } 1649 return (result); 1650 } 1651 } 1652 } 1653 return(std(i)); 1654 } 1655 example 1656 { "EXAMPLE:"; echo = 2; 1657 ring r=32003,(a,b,c,d,e),dp; 1658 int n=6; 1659 ideal i= 1660 a^n-b^n, 1661 b^n-c^n, 1662 c^n-d^n, 1663 d^n-e^n, 1664 a^(n-1)*b+b^(n-1)*c+c^(n-1)*d+d^(n-1)*e+e^(n-1)*a; 1665 timeStd(i,2); 1666 timeStd(i,20); 1667 } 1668 1669 proc factorH(poly p) 1670 "USAGE: factorH(p) p poly 1671 RETURN: factorize(p) 1672 NOTE: changes variables to become the last variable the principal 1673 one in the multivariate factorization and factorizes then 1674 the polynomial 1675 EXAMPLE: example factorH; shows an example 1676 " 1677 { 1678 def R=basering; 1679 int i,j; 1680 int n=1; 1681 int d=nrows(coeffs(p,var(1))); 1682 for(i=1;i<=nvars(R);i++) 1683 { 1684 j=nrows(coeffs(p,var(i))); 1685 if(d>j) 1686 { 1687 n=i; 1688 d=j; 1689 } 1690 } 1691 ideal ma=maxideal(1); //die letzte Variable ist die Hauptvariable 1692 ma[nvars(R)]=var(n); 1693 ma[n]=var(nvars(R)); 1694 map phi=R,ma; 1695 list fac=factorize(phi(p)); 1696 list re=phi(fac); 1697 return(re); 1698 } 1699 example 1700 { "EXAMPLE:"; echo = 2; 1701 system("random",992851144); 1702 ring r=32003,(x,y,z,w,t),lp; 1703 poly p=y2w9+yz7t-yz5w4-z2w4t4-w8t3; 1704 factorize(p); //fast 1705 system("random",992851262); 1706 //factorize(p); //slow 1707 system("random",992851262); 1708 factorH(p); 1709 } -
Singular/LIB/standard.lib
r176954 r90d772 1 1 ////////////////////////////////////////////////////////////////////////////// 2 version="$Id: standard.lib,v 1.6 8 2005-04-29 16:11:41Singular Exp $";2 version="$Id: standard.lib,v 1.69 2005-05-02 13:28:14 Singular Exp $"; 3 3 category="Miscellaneous"; 4 4 info=" … … 14 14 fprintf(link,fmt,..) writes formatted string to link 15 15 printf(fmt,...) displays formatted string 16 timeStd(i,d) std(i) if the standard basis computation finished after17 d-1 seconds and i otherwhise18 timeFactorize(p,d) factorize(p) if the factorization finished after d-119 seconds otherwhise f is considered to be irreducible20 factorH(p) changes variables to become the last variable the21 principal one in the multivariate factorization and22 factorizes then the polynomial23 24 16 "; 25 17 … … 1037 1029 } 1038 1030 1039 proc timeFactorize(poly i,list #)1040 "USAGE: timeFactorize(p,d) poly p , integer d1041 RETURN: factorize(p) if the factorization finished after d-11042 seconds otherwhise f is considered to be irreducible1043 EXAMPLE: example timeFactorize; shows an example1044 "1045 {1046 def P=basering;1047 if (size(#) > 0)1048 {1049 if (system("with", "MP"))1050 {1051 if ((typeof(#[1]) == "int")&&(#[1]))1052 {1053 int wait = #[1];1054 int j = 10;1055 1056 string bs = nameof(basering);1057 link l_fork = "MPtcp:fork";1058 open(l_fork);1059 write(l_fork, quote(system("pid")));1060 int pid = read(l_fork);1061 write(l_fork, quote(timeFactorize(eval(i))));1062 1063 // sleep in small intervalls for appr. one second1064 if (wait > 0)1065 {1066 while(j < 1000000)1067 {1068 if (status(l_fork, "read", "ready", j)) {break;}1069 j = j + j;1070 }1071 }1072 1073 // sleep in intervalls of one second from now on1074 j = 1;1075 while (j < wait)1076 {1077 if (status(l_fork, "read", "ready", 1000000)) {break;}1078 j = j + 1;1079 }1080 1081 if (status(l_fork, "read", "ready"))1082 {1083 def result = read(l_fork);1084 if (bs != nameof(basering))1085 {1086 def PP = basering;1087 setring P;1088 def result = imap(PP, result);1089 kill PP;1090 }1091 kill (l_fork);1092 }1093 else1094 {1095 list result;1096 intvec v=1,1;1097 result[1]=list(1,i);1098 result[2]=v;1099 j = system("sh", "kill " + string(pid));1100 }1101 return (result);1102 }1103 }1104 }1105 return(factorH(i));1106 }1107 example1108 { "EXAMPLE:"; echo = 2;1109 ring r=0,(x,y),dp;1110 poly p=((x2+y3)^2+xy6)*((x3+y2)^2+x10y);1111 p=p^2;1112 //timeFactorize(p,2);1113 //timeFactorize(p,20);1114 }1115 1116 proc timeStd(ideal i,list #)1117 "USAGE: timeStd(i,d), i ideal, d integer1118 RETURN: std(i) if the standard basis computation finished after1119 d-1 seconds and i otherwhise1120 EXAMPLE: example timeStd; shows an example1121 "1122 {1123 def P=basering;1124 if (size(#) > 0)1125 {1126 if (system("with", "MP"))1127 {1128 if ((typeof(#[1]) == "int")&&(#[1]))1129 {1130 int wait = #[1];1131 int j = 10;1132 1133 string bs = nameof(basering);1134 link l_fork = "MPtcp:fork";1135 open(l_fork);1136 write(l_fork, quote(system("pid")));1137 int pid = read(l_fork);1138 write(l_fork, quote(timeStd(eval(i))));1139 1140 // sleep in small intervalls for appr. one second1141 if (wait > 0)1142 {1143 while(j < 1000000)1144 {1145 if (status(l_fork, "read", "ready", j)) {break;}1146 j = j + j;1147 }1148 }1149 j = 1;1150 while (j < wait)1151 {1152 if (status(l_fork, "read", "ready", 1000000)) {break;}1153 j = j + 1;1154 }1155 if (status(l_fork, "read", "ready"))1156 {1157 def result = read(l_fork);1158 if (bs != nameof(basering))1159 {1160 def PP = basering;1161 setring P;1162 def result = imap(PP, result);1163 kill PP;1164 }1165 kill (l_fork);1166 }1167 else1168 {1169 ideal result=i;1170 j = system("sh", "kill " + string(pid));1171 }1172 return (result);1173 }1174 }1175 }1176 return(std(i));1177 }1178 example1179 { "EXAMPLE:"; echo = 2;1180 ring r=32003,(a,b,c,d,e),dp;1181 int n=6;1182 ideal i=1183 a^n-b^n,1184 b^n-c^n,1185 c^n-d^n,1186 d^n-e^n,1187 a^(n-1)*b+b^(n-1)*c+c^(n-1)*d+d^(n-1)*e+e^(n-1)*a;1188 timeStd(i,2);1189 timeStd(i,20);1190 }1191 1192 proc factorH(poly p)1193 "USAGE: factorH(p) p poly1194 RETURN: factorize(p)1195 NOTE: changes variables to become the last variable the principal1196 one in the multivariate factorization and factorizes then1197 the polynomial1198 EXAMPLE: example factorH; shows an example1199 "1200 {1201 def R=basering;1202 int i,j;1203 int n=1;1204 int d=nrows(coeffs(p,var(1)));1205 for(i=1;i<=nvars(R);i++)1206 {1207 j=nrows(coeffs(p,var(i)));1208 if(d>j)1209 {1210 n=i;1211 d=j;1212 }1213 }1214 ideal ma=maxideal(1); //die letzte Variable ist die Hauptvariable1215 ma[nvars(R)]=var(n);1216 ma[n]=var(nvars(R));1217 map phi=R,ma;1218 list fac=factorize(phi(p));1219 list re=phi(fac);1220 return(re);1221 }1222 example1223 { "EXAMPLE:"; echo = 2;1224 system("random",992851144);1225 ring r=32003,(x,y,z,w,t),lp;1226 poly p=y2w9+yz7t-yz5w4-z2w4t4-w8t3;1227 factorize(p); //fast1228 system("random",992851262);1229 //factorize(p); //slow1230 system("random",992851262);1231 factorH(p);1232 }1233 1031 ////////////////////////////////////////////////////////////////////////// 1234 1032
Note: See TracChangeset
for help on using the changeset viewer.