- Timestamp:
- Feb 15, 2024, 4:01:00 PM (3 months ago)
- Branches:
- (u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
- Children:
- 97bbaa1d86e16934259160dd8ac8a6cd0731f80c
- Parents:
- 083f003065d6d79ac5e85e9da00f276e58a5aacb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/dyn_modules/cohomo/cohomo.cc
r083f00 r66844e 460 460 p = pOne();pSetExp(p, vbase[i], 1);pSetm(p);pSetCoeff(p, nInit(1)); 461 461 //pWrite(p); 462 q=p p_Mult_mm(q,p,currRing);462 q=p_Mult_m(q,p,currRing); 463 463 } 464 464 return q; … … 470 470 ideal id_re=idInit(1,1); 471 471 poly p; 472 int i,lv=vecs.size();473 for(i =0;i<lv;i++)472 int lv=vecs.size(); 473 for(int i=0;i<lv;i++) 474 474 { 475 475 p=pMaken(vecs[i]); … … 485 485 static std::vector<std::vector<int> > b_subsets(std::vector<int> vec) 486 486 { 487 int i,j;488 487 std::vector<int> bv; 489 488 std::vector<std::vector<int> > vecs; 490 for(i =0;i<vec.size();i++)489 for(int i=0;i<vec.size();i++) 491 490 { 492 491 bv.push_back(vec[i]); … … 495 494 } 496 495 //listsprint(vecs); 497 for(i =0;i<vecs.size();i++)498 { 499 for( j=i+1;j<vecs.size();j++)496 for(int i=0;i<vecs.size();i++) 497 { 498 for(int j=i+1;j<vecs.size();j++) 500 499 { 501 500 bv=vecUnion(vecs[i], vecs[j]); … … 511 510 static int idvert(ideal h) 512 511 { 513 int i, j, vert=0;514 512 if(idIs0(h)) 515 return vert;516 for(i =currRing->N;i>0;i--)517 { 518 for( j=0;j<IDELEMS(h);j++)513 return 0; 514 for(int i=currRing->N;i>0;i--) 515 { 516 for(int j=0;j<IDELEMS(h);j++) 519 517 { 520 518 if(pGetExp(h->m[j],i)>0) 521 519 { 522 vert=i; 523 return vert; 524 } 525 } 526 } 527 return vert; 520 return i; 521 } 522 } 523 } 524 return 0; 528 525 } 529 526 530 527 static int pvert(poly p) 531 528 { 532 int i, vert=0; 533 for(i=currRing->N;i>0;i--) 529 for(int i=currRing->N;i>0;i--) 534 530 { 535 531 if(pGetExp(p,i)>0) 536 532 { 537 vert=i; 538 return vert; 539 } 540 } 541 return vert; 533 return i; 534 } 535 } 536 return 0; 542 537 } 543 538 … … 607 602 { 608 603 ideal h=idInit(1,1); 609 int i,j,eq=0;610 for(i =0;i<IDELEMS(h1);i++)604 int eq=0; 605 for(int i=0;i<IDELEMS(h1);i++) 611 606 { 612 607 eq=0; 613 for( j=0;j<IDELEMS(h2);j++)614 { 615 if(p_EqualPolys( pCopy(h1->m[i]),pCopy(h2->m[j]), currRing))608 for(int j=0;j<IDELEMS(h2);j++) 609 { 610 if(p_EqualPolys(h1->m[i],h2->m[j], currRing)) 616 611 { 617 612 eq=1; … … 632 627 static bool p_Ifsfree(poly P) 633 628 { 634 int i,sf=1;635 for(i =1;i<=rVar(currRing);i++)629 int sf=1; 630 for(int i=1;i<=rVar(currRing);i++) 636 631 { 637 632 if (pGetExp(P,i)>1) … … 647 642 static ideal sfreemon(ideal h,int deg) 648 643 { 649 int j; 650 ideal temp; 651 temp=idInit(1,1); 644 ideal temp=idInit(1,1); 652 645 if(!idIs0(h)) 653 646 { 654 for( j=0;j<IDELEMS(h);j++)655 { 656 if( (p_Ifsfree(h->m[j]))&&(pTotaldegree(h->m[j])==deg))657 { 658 idInsertPoly(temp, h->m[j]);647 for(int j=0;j<IDELEMS(h);j++) 648 { 649 if(p_Ifsfree(h->m[j])&&(pTotaldegree(h->m[j])==deg)) 650 { 651 idInsertPoly(temp, pCopy(h->m[j])); 659 652 } 660 653 } … … 669 662 { 670 663 ideal asfmons,sfmons,mons; 671 int j,vert=idvert(h);664 int vert=idvert(h); 672 665 mons=id_MaxIdeal(1, currRing); 673 666 asfmons=sfreemon(mons,1); 674 for( j=2;j<=vert;j++)667 for(int j=2;j<=vert;j++) 675 668 { 676 669 mons=id_MaxIdeal(j, currRing); 677 670 sfmons=sfreemon(mons,j); 671 idDelete(&mons); 672 ideal old_asfmons=asfmons; 678 673 asfmons=id_Add(asfmons,sfmons,currRing); 674 idDelete(&sfmons); 675 idDelete(&old_asfmons); 679 676 } 680 677 return asfmons; … … 687 684 static ideal id_complement(ideal h) 688 685 { 689 int j,vert=idvert(h);686 int vert=idvert(h); 690 687 ideal i1=id_sfmon(h); 691 688 ideal i3=idInit(1,1); 692 689 poly p; 693 for( j=0;j<IDELEMS(i1);j++)694 { 695 p= pCopy(i1->m[j]);690 for(int j=0;j<IDELEMS(i1);j++) 691 { 692 p=i1->m[j]; 696 693 if(pvert(p)<=vert) 697 694 { 698 idInsertPoly(i3, p );695 idInsertPoly(i3, pCopy(p)); 699 696 } 700 697 } 701 698 ideal i2=idMinus(i3,h); 699 idDelete(&i3); 700 idDelete(&i1); 702 701 idSkipZeroes(i2); 703 702 return (i2); … … 708 707 static bool IsInX(poly p,ideal X) 709 708 { 710 int i; 711 for(i=0;i<IDELEMS(X);i++) 709 for(int i=0;i<IDELEMS(X);i++) 712 710 { 713 711 if(pEqualPolys(p,X->m[i])) … … 727 725 h=idAdd(h1,h2); 728 726 qrh=scKBase(deg,h); 727 idDelete(&h); 729 728 return qrh; 730 729 } … … 733 732 static int id_maxdeg(ideal h) 734 733 { 735 int i,max; 736 max=pTotaldegree(h->m[0]); 737 for(i=1;i<IDELEMS(h);i++) 734 int max=pTotaldegree(h->m[0]); 735 for(int i=1;i<IDELEMS(h);i++) 738 736 { 739 737 if(pTotaldegree(h->m[i]) > max) … … 747 745 static ideal idsrRing(ideal h) 748 746 { 749 int i,n;750 747 ideal pp,qq,rsr,ppp,hc=idCopy(h); 751 for(i =1;i<=rVar(currRing);i++)748 for(int i=1;i<=rVar(currRing);i++) 752 749 { 753 750 pp=sfreemon(hc,i); 751 ideal old_pp=pp; 754 752 pp=scKBase(i,pp);//quotient ring (R/I_i)_i 753 idDelete(&old_pp); 755 754 if(!idIs0(pp)) 756 755 { 756 old_pp=pp; 757 757 pp=sfreemon(pp,i); 758 idDelete(&old_pp); 758 759 rsr=pp; 759 760 //Print("This is the first quotient generators %d:\n",i); … … 762 763 } 763 764 } 764 for( n=i+1;n<=rVar(currRing);n++)765 for(int n=i+1;n<=rVar(currRing);n++) 765 766 { 766 767 qq=sfreemon(hc,n); 767 768 pp=qringadd(qq,rsr,n); 768 769 ppp=sfreemon(pp,n); 770 ideal old_rsr=rsr; 769 771 rsr=idAdd(rsr,ppp); 772 idDelete(&old_rsr); 773 idDelete(&ppp); 770 774 } 771 775 idSkipZeroes(rsr); … … 776 780 static ideal SimFacset(poly p) 777 781 { 778 int i,j,max=pTotaldegree(p);782 int max=pTotaldegree(p); 779 783 ideal h1,mons,id_re=idInit(1,1); 780 for(i =1;i<max;i++)784 for(int i=1;i<max;i++) 781 785 { 782 786 mons=id_MaxIdeal(i, currRing); 783 787 h1=sfreemon(mons,i); 784 785 for(j=0;j<IDELEMS(h1);j++) 788 idDelete(&mons); 789 790 for(int j=0;j<IDELEMS(h1);j++) 786 791 { 787 792 if(p_DivisibleBy(h1->m[j],p,currRing)) 788 793 { 789 794 idInsertPoly(id_re, h1->m[j]); 790 } 791 } 795 h1->m[j]=NULL; 796 } 797 } 798 idDelete(&h1); 792 799 } 793 800 idSkipZeroes(id_re); … … 802 809 if(!IsInX(h1->m[i],h)) 803 810 { 804 idInsertPoly(h, h1->m[i]);811 idInsertPoly(h, pCopy(h1->m[i])); 805 812 } 806 813 } … … 809 816 if(!IsInX(h2->m[i],h)) 810 817 { 811 idInsertPoly(h, h2->m[i]);818 idInsertPoly(h, pCopy(h2->m[i])); 812 819 } 813 820 } … … 821 828 static ideal IsSimplex(ideal h) 822 829 { 823 int i,max=id_maxdeg(h);830 int max=id_maxdeg(h); 824 831 poly e=pOne(); 825 832 ideal id_re, id_so=idCopy(h); 826 for(i =0;i<IDELEMS(h);i++)833 for(int i=0;i<IDELEMS(h);i++) 827 834 { 828 835 id_re=SimFacset(h->m[i]); 829 836 if(!idIs0(id_re)) 830 837 { 838 ideal old_id_so=id_so; 831 839 id_so=idadda(id_so, id_re);//idAdd(id_so,id_re); 832 } 840 idDelete(&old_id_so); 841 } 842 idDelete(&id_re); 833 843 } 834 844 idInsertPoly(id_so,e); 835 845 idSkipZeroes(id_so); 836 return (idMinus(id_so,h)); 846 ideal res=idMinus(id_so,h); 847 idDelete(&id_so); 848 return res; 837 849 } 838 850 … … 842 854 static ideal complementsimplex(ideal h) 843 855 { 844 int i,j;poly p,e=pOne();856 poly p,e=pOne(); 845 857 ideal h1=idInit(1,1), pp, h3; 846 for(i =1;i<=rVar(currRing);i++)847 { 848 p = pOne(); pSetExp(p, i, 2); pSetm(p); pSetCoeff(p, nInit(1));858 for(int i=1;i<=rVar(currRing);i++) 859 { 860 p = pOne(); pSetExp(p, i, 2); pSetm(p); 849 861 idInsertPoly(h1, p); 850 862 } 851 863 idSkipZeroes(h1); 852 864 ideal h2=idAdd(h,h1); 865 idDelete(&h1); 853 866 pp=scKBase(1,h2); 854 h3= idCopy(pp);855 for( j=2;j<=rVar(currRing);j++)867 h3=pp; 868 for(int j=2;j<=rVar(currRing);j++) 856 869 { 857 870 pp=scKBase(j,h2); 871 ideal old_h3=h3; 858 872 h3=idAdd(h3,pp); 873 idDelete(&old_h3); 874 idDelete(&pp); 859 875 } 860 876 idInsertPoly(h3, e); … … 865 881 static int dim_sim(ideal h) 866 882 { 867 int dim=pTotaldegree(h->m[0]) , i;868 for(i =1; i<IDELEMS(h);i++)883 int dim=pTotaldegree(h->m[0]); 884 for(int i=1; i<IDELEMS(h);i++) 869 885 { 870 886 if(dim<pTotaldegree(h->m[i])) … … 899 915 ideal ib=id_sfmon(h), nonf=id_complement(h), bset=idInit(1,1); 900 916 poly e=pOne(); 901 int i,j; 902 for(i=0;i<IDELEMS(ib);i++) 903 { 904 for(j=0;j<IDELEMS(nonf);j++) 917 for(int i=0;i<IDELEMS(ib);i++) 918 { 919 for(int j=0;j<IDELEMS(nonf);j++) 905 920 { 906 921 if(p_DivisibleBy(ib->m[i],nonf->m[j],currRing)) 907 922 { 908 923 idInsertPoly(bset, ib->m[i]); 924 ib->m[i]=NULL; 909 925 break; 910 926 } … … 913 929 idInsertPoly(bset,e); 914 930 idSkipZeroes(bset); 931 idDelete(&ib); 932 idDelete(&nonf); 915 933 return bset; 916 934 }
Note: See TracChangeset
for help on using the changeset viewer.