Changeset 4775bd in git
- Timestamp:
- May 12, 2011, 11:33:35 PM (12 years ago)
- Branches:
- (u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
- Children:
- dd2a9b3d2d1e9ae68171cc7c0f20c0d6b2aa0632
- Parents:
- e92dc4a2ac737df19d2c317609ccd85d14e7df55
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/nctools.lib
re92dc4a r4775bd 36 36 AltVarStart(); return first alternating variable of a super-commutative algebra, 37 37 AltVarEnd(); return last alternating variable of a super-commutative algebra, 38 IsSCA(); check whether current ring is a super-commutative algebra 39 makeModElimRing(R); equip a ring with module elimination ordering 38 IsSCA(); check whether current ring is a super-commutative algebra, 39 makeModElimRing(R); equip a ring with module elimination ordering, 40 embedMat(M,m,n); embeds matrix M in a left upper corner of m times n matrix 40 41 "; 41 42 … … 1633 1634 ////////////////////////////////////////////////////////////////////// 1634 1635 1635 proc moduloSlim (module A, module B) 1636 proc embedMat(matrix A, int m, int n) 1637 "USAGE: embedMat(A,m,n); A,B matrix/module 1638 RETURN: matrix 1639 PURPOSE: embed A in the left upper corner of mxn matrix 1640 EXAMPLE: example embedMat; shows an example 1641 " 1642 { 1643 // returns A embedded in the left upper corner of mxn matrix 1644 int rA = nrows(A); 1645 int cA = ncols(A); 1646 if ((rA >m) || (cA>n)) 1647 { 1648 ERROR("wrong dimensions of the new matrix"); 1649 } 1650 matrix @M[m][n]; 1651 int i,j; 1652 for(i=1;i<=rA; i++) 1653 { 1654 for(j=1;j<=cA; j++) 1655 { 1656 @M[i,j]=A[i,j]; 1657 } 1658 } 1659 return(@M); 1660 } 1661 example 1662 { 1663 "EXAMPLE:"; echo = 2; 1664 ring r = 0,(a,b,c,d),dp; 1665 matrix M[2][3]; M[1,1]=a; M[1,2]=b;M[2,2]=d;M[1,3]=c; 1666 print(M); 1667 print(embedMat(M,3,4)); 1668 matrix N = M; N[2,2]=0; 1669 print(embedMat(N,3,4)); 1670 } 1671 1672 proc moduloSlim (matrix A, matrix B) 1636 1673 "USAGE: moduloSlim(A,B); A,B module/matrix/ideal 1637 1674 RETURN: module … … 1641 1678 { 1642 1679 def save = basering; 1643 int rA = nrows(A); 1644 if (rA != nrows(B)) 1645 { 1646 // add 0 rows? 1647 ERROR("incorrect input: different rank"); 1680 int rA = nrows(A); int rB = nrows(B); 1681 int cA = ncols(A); int cB = ncols(B); 1682 int j; 1683 int dab; // difference a,b 1684 dab = rA - rB; 1685 if (dab <0) 1686 { 1687 // rA<rB: add zero rows to A 1688 dab = -dab; 1689 A = embedMat(A,rB,cA); 1690 } 1691 else 1692 { 1693 // rA>rB: add zero rows to B 1694 B = embedMat(B,rA,cB); 1648 1695 } 1649 1696 def mering = makeModElimRing(save); … … 1651 1698 module A = imap(save, A); 1652 1699 module B = imap(save, B); 1653 int cA = ncols(A); int cB = ncols(B);1654 1700 // create matrix C 1655 1701 // matrix C[2*rA][cA+cB]; … … 1666 1712 // } 1667 1713 C = C[2..ncols(C)]; 1714 print(C); 1668 1715 matrix D = slimgb(C); 1669 module E; 1716 module E; int k; 1717 // TODO: why only first row? need smth like rA rows... 1670 1718 for(i=1; i<= ncols(D); i++) 1671 1719 { 1672 if (D[1,i]==0) 1720 k=1; 1721 // determine first zero in the column 1722 while ( (D[k,i]==0) && (k<= cA+rA) ) 1723 { 1724 k++; 1725 } 1726 // what can that be: k = cA+rA+1=> zero column 1727 // k<=rA => column not in ker 1728 // rA+1 <= k <= rA+cA => column in ker 1729 if ( ( k>=rA+1) && (k<=rA+cA) ) 1673 1730 { 1674 1731 E = E,D[i]; 1675 1732 } 1676 1733 } 1677 // this E has 1st column and 1st row zero 1734 // for(i=1; i<= ncols(D); i++) 1735 // { 1736 // if (D[1,i]==0) 1737 // { 1738 // E = E,D[i]; 1739 // } 1740 // } 1741 // // this E has 1st column and 1st row zero 1678 1742 // use submat@matrix.lib 1679 E = submat(E,2..nrows(E),2..ncols(E)); 1680 // E = E[2..ncols(E)]; // skip 1st 0 row // E = transpose(E); 1681 // E = E[2..ncols(E)]; // skip 1st 0 row // E = transpose(E); 1743 // E = submat(E,intvec(2..nrows(E)),intvec(2..ncols(E))); 1744 E = submat(E,intvec(rA+1..nrows(E)),intvec(2..ncols(E))); 1682 1745 setring save; 1683 1746 module E = imap(mering,E); 1684 1747 kill mering; 1748 // TODO: clean components! 1685 1749 return(E); 1686 1750 } … … 1701 1765 T = std( NF(std(H2+T),H2) ); 1702 1766 T; 1767 // now, a matrix example: 1768 ring r2 = 0,(x,d), (dp); 1769 def R = nc_algebra(1,1); setring R; 1770 matrix M[2][2] = d, 0, 0, d*(x*d); 1771 matrix P[2][1] = (8x+7)*d+9x, (x2+1)*d + 5*x; 1772 module X = moduloSlim(P,M); 1773 print(X); 1703 1774 } 1704 1775
Note: See TracChangeset
for help on using the changeset viewer.