Changeset 29c4ee in git
- Timestamp:
- Feb 3, 2011, 2:31:47 PM (12 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- c7b57f22ef0dbc32c7a7cd866e9c64d75e5f9f64
- Parents:
- ba490a26293bfdb10c1245e8aa0a20a4f29cd236
- Location:
- Singular
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/general.lib
rba490a2 r29c4ee 654 654 655 655 proc sort (id, list #) 656 "USAGE: sort(id[,v,o,n]); id = ideal/module/intvec/list (of intvec's or int's)656 "USAGE: sort(id[,v,o,n]); id = ideal/module/intvec/list 657 657 @* sort may be called with 1, 2 or 3 arguments in the following way: 658 658 @* sort(id[,v,n]); v=intvec of positive integers, n=integer, … … 667 667 NOTE: generators with SMALLER(!) leading term come FIRST 668 668 (e.g. sort(id); sorts backwards to actual monomial ordering) 669 - if id=list of intvec's or int's: consider a list element, say 670 id[1]=3,2,5, as exponent vector of the monomial x^3*y^2*z^5; 671 the corresponding monomials are ordered w.r.t. intvec v (s.a.). 672 If no v is present, the monomials are sorted w.r.t. ordering o 673 (if o is given) or w.r.t. lexicographical ordering (if no o is 674 given). The corresponding ordered list of exponent vectors is 675 returned. 676 (e.g. sort(id); sorts lexicographically, smaller int's come first) 677 WARNING: Since negative exponents create the 0 polynomial in 678 Singular, id should not contain negative integers: the result 679 might not be as expected 680 - if id=intvec: id is treated as list of integers 669 - if id=list or intvec: sorted w.r.t. < (indep. of other arguments) 681 670 - if n!=0 the ordering is inverse, i.e. w.r.t. v(size(v)..1) 682 671 default: n=0 … … 718 707 } 719 708 } 720 if ( typeof(id)=="intvec" or typeof(id)=="list" and n==0 ) 721 { 722 string o; 723 if ( size(#)==0 ) { o = "lp"; n=1; } 724 if ( size(#)>=1 ) 725 { 726 if ( typeof(#[1])=="string" ) { o = #[1]; n=1; } 727 } 728 } 729 if ( typeof(id)=="intvec" or typeof(id)=="list" and n==1 ) 730 { 731 if ( typeof(id)=="list" ) 732 { 733 for (ii=1; ii<=size(id); ii++) 734 { 735 if (typeof(id[ii]) != "intvec" and typeof(id[ii]) != "int") 736 { ERROR("// list elements must be intvec/int"); } 737 else 738 { s=size(id[ii])*(s < size(id[ii])) + s*(s >= size(id[ii])); } 739 } 740 } 741 execute("ring r=0,x(1..s),("+o+");"); 742 ideal i; 743 poly f; 744 for (ii=1; ii<=size(id); ii++) 745 { 746 f=1; 747 for (jj=1; jj<=size(id[ii]); jj++) 748 { 749 f=f*x(jj)^(id[ii])[jj]; 750 } 751 i[ii]=f; 752 } 753 v = sort(i)[2]; 709 if ( typeof(id)=="intvec" or typeof(id)=="list" ) 710 { 711 int Bn,Bi,Bj,Bb; 712 intvec pivot; 713 for(Bi=size(id);Bi>0;Bi--) { pivot[Bi]=Bi; } 714 while(Bj==0) 715 { 716 Bi++; 717 Bj=1; 718 for(Bn=1;Bn<=size(id)-Bi;Bn++) 719 { 720 if(id[pivot[Bn]]>id[pivot[Bn+1]]) 721 { 722 Bb=pivot[Bn]; 723 pivot[Bn]=pivot[Bn+1]; 724 pivot[Bn+1]=Bb; 725 Bj=0; 726 } 727 } 728 } 729 def Br=id; 730 for(Bi=size(id);Bi>0;Bi--) { Br[Bi]=id[pivot[Bi]]; } 731 return(list(Br,pivot)); 754 732 } 755 733 if ( size(#)!=0 and n==0 ) { v = #[1]; } … … 798 776 sort( M, sort(lead(M), "c,dp")[2] )[1]; 799 777 800 // BUG: Please, don't use this sort for integer vectors or lists 778 // BUG: Please, don't use this sort for integer vectors or lists 801 779 // with them if there can be negative integers! 802 780 // TODO: for some HiWi 803 sort(3..-3)[1]; 804 sort(list(-v, v))[1]; 781 sort(3..-3)[1]; 782 sort(list(-v, v))[1]; 805 783 806 784 } -
Singular/iparith.cc
rba490a2 r29c4ee 496 496 { 497 497 int v_i=(int)(long)v->Data(); 498 if (v_i<0) 499 { 500 Werror("negative exponent %d of a poly",v_i); 501 return TRUE; 502 } 498 503 poly u_p=(poly)u->CopyD(POLY_CMD); 499 504 int dummy;
Note: See TracChangeset
for help on using the changeset viewer.