Changeset 8f963e in git for libpolys/polys/matpol.cc
- Timestamp:
- Mar 3, 2017, 10:07:48 AM (7 years ago)
- Branches:
- (u'spielwiese', 'e7cc1ebecb61be8b9ca6c18016352af89940b21a')
- Children:
- 814a65342deba6307f8681b5318b625767ed2bc9
- Parents:
- 77ba486a2bb537dad7c328a5710ec099c240c06f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/polys/matpol.cc
r77ba48 r8f963e 1725 1725 } 1726 1726 } 1727 1727 // helper for mp_Tensor 1728 // destroyes f, keeps B 1728 1729 static ideal mp_MultAndShift(poly f, ideal B, int s, const ring r) 1729 1730 { 1731 assume(f!=NULL); 1730 1732 ideal res=idInit(IDELEMS(B),B->rank+s); 1731 if (f!=NULL) 1732 { 1733 int q=IDELEMS(B); // p x q 1734 for(int j=0;j<q;j++) 1735 { 1736 poly h=pp_Mult_qq(f,B->m[j],r); 1737 if (h!=NULL) 1738 { 1739 if (s>0) p_Shift(&h,s,r); 1740 res->m[j]=h; 1741 } 1742 } 1743 } 1733 int q=IDELEMS(B); // p x q 1734 for(int j=0;j<q;j++) 1735 { 1736 poly h=pp_Mult_qq(f,B->m[j],r); 1737 if (h!=NULL) 1738 { 1739 if (s>0) p_Shift(&h,s,r); 1740 res->m[j]=h; 1741 } 1742 } 1743 p_Delete(&f,r); 1744 1744 return res; 1745 1745 } 1746 static ideal mp_AddSubMat(ideal res, ideal sm, int col, const ring r) 1746 // helper for mp_Tensor 1747 // updates res, destroyes contents of sm 1748 static void mp_AddSubMat(ideal res, ideal sm, int col, const ring r) 1747 1749 { 1748 1750 for(int i=0;i<IDELEMS(sm);i++) … … 1751 1753 sm->m[i]=NULL; 1752 1754 } 1753 return res;1754 1755 } 1755 1756 … … 1762 1763 int p=B->rank; 1763 1764 ideal res=idInit(n*q,m*p); 1764 poly *a=(poly*)omAlloc 0(m*sizeof(poly));1765 poly *a=(poly*)omAlloc(m*sizeof(poly)); 1765 1766 for(int i=0; i<n; i++) 1766 1767 { 1768 memset(a,0,m*sizeof(poly)); 1767 1769 p_DecomposeComp(p_Copy(A->m[i],r),a,m,r); 1768 1770 for(int j=0;j<m;j++) 1769 1771 { 1770 ideal sm=mp_MultAndShift(a[j], // A_i_j 1771 B, 1772 j*p, // shift j*p down 1773 r); 1774 res=mp_AddSubMat(res,sm,i*q,r); // add this colums to col i*q ff 1775 id_Delete(&sm,r); 1776 } 1777 memset(a,0,m*sizeof(poly)); 1772 if (a[j]!=NULL) 1773 { 1774 ideal sm=mp_MultAndShift(a[j], // A_i_j 1775 B, 1776 j*p, // shift j*p down 1777 r); 1778 mp_AddSubMat(res,sm,i*q,r); // add this columns to col i*q ff 1779 id_Delete(&sm,r); // delete the now empty ideal 1780 } 1781 } 1778 1782 } 1779 1783 omFreeSize(a,m*sizeof(poly));
Note: See TracChangeset
for help on using the changeset viewer.