Changeset 2a4de8 in git
- Timestamp:
- May 7, 2007, 7:00:36 PM (16 years ago)
- Branches:
- (u'spielwiese', 'd1ba061a762c62d3a25159d8da8b6e17332291fa')
- Children:
- 4bebba7353438f052b4ad581ede34fa6f31e5a71
- Parents:
- 3332cc62f3084f897a059b454c1a0aaff2be7c9a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/solve.lib
r3332cc6 r2a4de8 1 1 /////////////////////////////////////////////////////////////////////////////// 2 version="$Id: solve.lib,v 1.3 5 2006-07-18 15:22:15Singular Exp $";2 version="$Id: solve.lib,v 1.36 2007-05-07 17:00:36 Singular Exp $"; 3 3 category="Symbolic-numerical solving"; 4 4 info=" … … 570 570 { 571 571 int sofar=1; 572 if (typeof(#[1])=="int"){ 572 if (typeof(#[1])=="int") 573 { 573 574 outprec = #[1]; 574 575 if (outprec<4){outprec = 4;} 575 if (size(#)>1){ 576 if (typeof(#[2])=="int"){ 576 if (size(#)>1) 577 { 578 if (typeof(#[2])=="int") 579 { 577 580 mu = #[2]; 578 if (size(#)>2){ 579 if (typeof(#[3])=="int"){ 581 if (size(#)>2) 582 { 583 if (typeof(#[3])=="int") 584 { 580 585 prec = #[3]; 581 586 if (prec<8){prec = 8;} 582 587 } 583 else { 588 else 589 { 584 590 if(mu!=0){prec = 60;} 585 591 if (#[3]=="oldring"){ oldr=1; } … … 589 595 } 590 596 } 591 else { 597 else 598 { 592 599 if (#[2]=="oldring"){ oldr=1; } 593 600 if (#[2]=="nodisplay"){ nodisp=1; } … … 596 603 } 597 604 } 598 else { 605 else 606 { 599 607 if (#[1]=="oldring"){ oldr=1; } 600 608 if (#[1]=="nodisplay"){ nodisp=1; } 601 609 } 602 for (ii=sofar+1;ii<=size(#);ii++) { // check for additional strings 603 if (typeof(#[ii])=="string") 604 { 605 if (#[ii]=="oldring"){ oldr=1; } 606 if (#[ii]=="nodisplay"){ nodisp=1; } 607 } 610 for (ii=sofar+1;ii<=size(#);ii++) 611 { // check for additional strings 612 if (typeof(#[ii])=="string") 613 { 614 if (#[ii]=="oldring"){ oldr=1; } 615 if (#[ii]=="nodisplay"){ nodisp=1; } 616 } 608 617 } 609 618 } … … 617 626 for (ii=1;ii<=size(LL);ii++) 618 627 { 619 if (typeof(`LL[ii]`)=="ring") { 620 if (find(charstr(`LL[ii]`),"complex,"+string(outprec))){ 628 if (typeof(`LL[ii]`)=="ring") 629 { 630 if (find(charstr(`LL[ii]`),"complex,"+string(outprec))) 631 { 621 632 jj++; 622 633 Out[jj]=LL[ii]; … … 624 635 } 625 636 } 626 if (size(Out)>0) { 637 if (size(Out)>0) 638 { 627 639 print("// *** You may select between the following rings for storing "+ 628 640 "the list of"); … … 634 646 while (chosen=="") { chosen=read(""); } 635 647 execute("def tchosen = "+chosen); 636 if (typeof(tchosen)=="int") { 637 if ((tchosen>0) and (tchosen<=size(Out))) { 648 if (typeof(tchosen)=="int") 649 { 650 if ((tchosen>0) and (tchosen<=size(Out))) 651 { 638 652 string outR = Out[tchosen]; 639 653 print("// *** You have chosen the ring "+ outR +". In this ring" … … 648 662 } 649 663 } 650 else { 664 else 665 { 651 666 print("No appropriate ring for storing the list of solutions found " + 652 667 "=> new ring created and returned"); … … 683 698 int vdG=vdim(G); 684 699 } 685 if (oldr!=1) { 700 if (oldr!=1) 701 { 686 702 execute("ring rinC =(complex,"+string(outprec)+ 687 703 "),("+varstr(basering)+"),lp;"); … … 700 716 return(rinC); 701 717 } 702 else { 718 else 719 { 703 720 setring (Top::`outR`); 704 721 list SOL; … … 715 732 716 733 // look for reduced standard basis in lex 717 if (sb*lp==0) { 718 if (sb==0) { 734 if (sb*lp==0) 735 { 736 if (sb==0) 737 { 719 738 execute("ring dphilb=("+charstr(rin)+"),("+ varstr(rin)+"),dp;"); 720 739 ideal G = imap(rin,G); … … 722 741 if (dim(G)!=0){ERROR("ideal not zero-dimensional");} 723 742 } 724 else { 743 else 744 { 725 745 def dphilb = basering; 726 746 G=interred(G); … … 733 753 H = simplify(H,2); 734 754 if (lp){setring rin;} 735 else {736 execute("ring lplex=("+charstr(rin)+"),("+737 varstr(rin)+"),lp;");755 else 756 { 757 execute("ring lplex=("+charstr(rin)+"),("+varstr(rin)+"),lp;"); 738 758 } 739 759 ideal H = imap(lexhilb,H); … … 744 764 // only 1 variable 745 765 def hr = basering; 746 if (nv==1) { 747 if ((mu==0) and (charstr(basering)[1]=="0")) { // special case 766 if (nv==1) 767 { 768 if ((mu==0) and (charstr(basering)[1]=="0")) 769 { // special case 748 770 list L = laguerre_solve(H[1],prec,prec,mu,0); // list of strings 749 if (oldr!=1) {750 execute("ring rinC =(complex,"+string(outprec)+751 771 if (oldr!=1) 772 { 773 execute("ring rinC =(complex,"+string(outprec)+"),("+varstr(basering)+"),lp;"); 752 774 list SOL; 753 775 for (ii=1; ii<=size(L); ii++ ) { execute("SOL[ii]="+L[ii]+";"); } … … 763 785 return(rinC); 764 786 } 765 else { 787 else 788 { 766 789 setring (Top::`outR`); 767 790 list SOL; … … 775 798 } 776 799 } 777 else {778 execute("ring internC=(complex,"+string(prec)+779 800 else 801 { 802 execute("ring internC=(complex,"+string(prec)+"),("+varstr(basering)+"),lp;"); 780 803 ideal H = imap(hr,H); 781 804 list sp = splittolist(splitsqrfree(H[1],var(1))); … … 787 810 } 788 811 setring hr; 789 if (oldr!=1) {790 execute("ring rinC =(complex,"+string(outprec)+791 812 if (oldr!=1) 813 { 814 execute("ring rinC =(complex,"+string(outprec)+"),("+varstr(basering)+"),lp;"); 792 815 list SOL; 793 816 list sp=imap(internC,sp); 794 817 if(mu!=0){ SOL=sp; } 795 else { 818 else 819 { 796 820 jj = size(sp); 797 821 SOL=sp[jj][1]; 798 while(jj>1) { 822 while(jj>1) 823 { 799 824 jj--; 800 825 SOL = sp[jj][1]+SOL; … … 812 837 return(rinC); 813 838 } 814 else { 839 else 840 { 815 841 setring (Top::`outR`); 816 842 list SOL; 817 843 list sp=imap(internC,sp); 818 844 if(mu!=0){ SOL=sp; } 819 else { 845 else 846 { 820 847 jj = size(sp); 821 848 SOL=sp[jj][1]; 822 while(jj>1) { 849 while(jj>1) 850 { 823 851 jj--; 824 852 SOL = sp[jj][1]+SOL; … … 836 864 } 837 865 838 839 866 // the triangular sets (not univariate case) 840 867 attrib(H,"isSB",1); … … 851 878 if (outprec<prec) 852 879 { 853 execute("ring internC=(complex,"+string(prec)+ 854 "),("+varstr(hr)+"),lp;"); 880 execute("ring internC=(complex,"+string(prec)+"),("+varstr(hr)+"),lp;"); 855 881 } 856 882 else 857 883 { 858 execute("ring rinC =(complex,"+string(outprec)+ 859 "),("+varstr(basering)+"),lp;"); 884 execute("ring rinC =(complex,"+string(outprec)+"),("+varstr(basering)+"),lp;"); 860 885 } 861 886 list triC = imap(hr,sp); … … 886 911 // final computations 887 912 option(set,ovec); 888 if (outprec==prec) { // we are in ring rinC 889 if (oldr!=1) { 913 if (outprec==prec) 914 { // we are in ring rinC 915 if (oldr!=1) 916 { 890 917 list SOL=ret1; 891 918 export SOL; … … 899 926 return(rinC); 900 927 } 901 else { 928 else 929 { 902 930 setring (Top::`outR`); 903 931 list SOL=imap(rinC,ret1); … … 909 937 } 910 938 } 911 else { 912 if (oldr!=1) { 913 execute("ring rinC =(complex,"+string(outprec)+ 914 "),("+varstr(basering)+"),lp;"); 939 else 940 { 941 if (oldr!=1) 942 { 943 execute("ring rinC =(complex,"+string(outprec)+"),("+varstr(basering)+"),lp;"); 915 944 list SOL=imap(internC,ret1); 916 945 export SOL; … … 924 953 return(rinC); 925 954 } 926 else { 955 else 956 { 927 957 setring (Top::`outR`); 928 958 list SOL=imap(internC,ret1); … … 1019 1049 } 1020 1050 attrib(re,"isSB",1); 1021 k = size(reduce(A,re ));1051 k = size(reduce(A,re,1)); 1022 1052 if (k){return(i);} 1023 1053 } … … 1373 1403 " 1374 1404 { 1375 1376 1377 1378 1379 1380 1381 1382 1383 1405 int typ=0;// defaults 1406 int prec=30; 1407 1408 if ( size(#) > 0 ) 1409 { 1410 typ= #[1]; 1411 if ( typ < 0 || typ > 1 ) 1412 { 1413 ERROR("Valid values for second parameter k are: 1384 1414 0: use sparse Resultant (default) 1385 1415 1: use Macaulay Resultant"); 1386 } 1387 } 1388 if ( size(#) > 1 ) 1389 { 1390 prec= #[2]; 1391 if ( prec < 8 ) 1392 { 1393 prec = 8; 1394 } 1395 } 1396 1397 list LL=uressolve(gls,typ,prec,1); 1398 int sizeLL=size(LL); 1399 if (sizeLL==0) { 1400 dbprint(printlevel-voice+3,"No solution found!"); 1401 return(list()); 1402 } 1403 if (typeof(LL[1][1])=="string") { 1404 int ii,jj; 1405 int nv=size(LL[1]); 1406 execute("ring rinC =(complex,"+string(prec)+",I),(" 1416 } 1417 } 1418 if ( size(#) > 1 ) 1419 { 1420 prec= #[2]; 1421 if ( prec < 8 ) 1422 { 1423 prec = 8; 1424 } 1425 } 1426 1427 list LL=uressolve(gls,typ,prec,1); 1428 int sizeLL=size(LL); 1429 if (sizeLL==0) 1430 { 1431 dbprint(printlevel-voice+3,"No solution found!"); 1432 return(list()); 1433 } 1434 if (typeof(LL[1][1])=="string") 1435 { 1436 int ii,jj; 1437 int nv=size(LL[1]); 1438 execute("ring rinC =(complex,"+string(prec)+",I),(" 1407 1439 +varstr(basering)+"),lp;"); 1408 list SOL,SOLnew; 1409 for (ii=1; ii<=sizeLL; ii++) { 1410 SOLnew=list(); 1411 for (jj=1; jj<=nv; jj++) { 1412 execute("SOLnew["+string(jj)+"]="+LL[ii][jj]+";"); 1413 } 1414 SOL[ii]=SOLnew; 1415 } 1416 kill SOLnew; 1417 export SOL; 1418 dbprint( printlevel-voice+3," 1440 list SOL,SOLnew; 1441 for (ii=1; ii<=sizeLL; ii++) 1442 { 1443 SOLnew=list(); 1444 for (jj=1; jj<=nv; jj++) 1445 { 1446 execute("SOLnew["+string(jj)+"]="+LL[ii][jj]+";"); 1447 } 1448 SOL[ii]=SOLnew; 1449 } 1450 kill SOLnew; 1451 export SOL; 1452 dbprint( printlevel-voice+3," 1419 1453 // 'ures_solve' created a ring, in which a list SOL of numbers (the complex 1420 1454 // solutions) is stored. … … 1422 1456 // to the return value): 1423 1457 setring R; SOL; "); 1424 return(rinC); 1425 } 1426 else { 1427 return(LL); 1428 } 1458 return(rinC); 1459 } 1460 else 1461 { 1462 return(LL); 1463 } 1429 1464 } 1430 1465 example … … 1450 1485 " 1451 1486 { 1452 1453 1454 1455 1456 1457 1458 1459 1487 int typ=0; 1488 1489 if ( size(#) > 0 ) 1490 { 1491 typ= #[1]; 1492 if ( typ < 0 || typ > 1 ) 1493 { 1494 ERROR("Valid values for third parameter are: 1460 1495 0: sparse resultant (default) 1461 1496 1: Macaulay resultant"); 1462 } 1463 } 1464 1465 return(mpresmat(i,typ)); 1466 1497 } 1498 } 1499 return(mpresmat(i,typ)); 1467 1500 } 1468 1501 example
Note: See TracChangeset
for help on using the changeset viewer.