Changeset 4775bd in git


Ignore:
Timestamp:
May 12, 2011, 11:33:35 PM (13 years ago)
Author:
Viktor Levandovskyy <levandov@…>
Branches:
(u'spielwiese', '2a584933abf2a2d3082034c7586d38bb6de1a30a')
Children:
dd2a9b3d2d1e9ae68171cc7c0f20c0d6b2aa0632
Parents:
e92dc4a2ac737df19d2c317609ccd85d14e7df55
Message:
*levandov: moduloSlim generalized to arbitrary matrices, embedMat introduced

git-svn-id: file:///usr/local/Singular/svn/trunk@14213 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/nctools.lib

    re92dc4a r4775bd  
    3636AltVarStart();       return first alternating variable of a super-commutative algebra,
    3737AltVarEnd();         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
     38IsSCA();             check whether current ring is a super-commutative algebra,
     39makeModElimRing(R);  equip a ring with module elimination ordering,
     40embedMat(M,m,n);     embeds matrix M in a left upper corner of m times n matrix
    4041";
    4142
     
    16331634//////////////////////////////////////////////////////////////////////
    16341635
    1635 proc moduloSlim (module A, module B)
     1636proc embedMat(matrix A, int m, int n)
     1637"USAGE:  embedMat(A,m,n); A,B matrix/module
     1638RETURN:  matrix
     1639PURPOSE: embed A in the left upper corner of mxn matrix
     1640EXAMPLE: 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}
     1661example
     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
     1672proc moduloSlim (matrix A, matrix B)
    16361673"USAGE:  moduloSlim(A,B); A,B module/matrix/ideal
    16371674RETURN:  module
     
    16411678{
    16421679  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);
    16481695  }
    16491696  def mering = makeModElimRing(save);
     
    16511698  module A = imap(save, A);
    16521699  module B = imap(save, B);
    1653   int cA = ncols(A);  int cB = ncols(B);
    16541700  // create matrix C
    16551701  //  matrix C[2*rA][cA+cB];
     
    16661712//   }
    16671713  C = C[2..ncols(C)];
     1714  print(C);
    16681715  matrix D = slimgb(C);
    1669   module E;
     1716  module E; int k;
     1717  // TODO: why only first row? need smth like rA rows...
    16701718  for(i=1; i<= ncols(D); i++)
    16711719  {
    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) )
    16731730    {
    16741731      E = E,D[i];
    16751732    }
    16761733  }
    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
    16781742  // 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)));
    16821745  setring save;
    16831746  module E = imap(mering,E);
    16841747  kill mering;
     1748  // TODO: clean components!
    16851749  return(E);
    16861750}
     
    17011765  T = std( NF(std(H2+T),H2) );
    17021766  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);
    17031774}
    17041775
Note: See TracChangeset for help on using the changeset viewer.