Index: Singular/iparith.cc
===================================================================
--- Singular/iparith.cc	(revision 52c2fbd6f734a6e530dac2589becda5a013ced56)
+++ Singular/iparith.cc	(revision f99917fc47a2b22bde5ec1bddc687567f3cd4dba)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: iparith.cc,v 1.133 1999-03-09 14:23:07 Singular Exp $ */
+/* $Id: iparith.cc,v 1.134 1999-03-11 15:58:05 Singular Exp $ */
 
 /*
@@ -1495,9 +1495,9 @@
         // Allow imap to be make an exception only for:
         if ( (rField_is_Q_a(r) &&  // Q(a..) -> Q(a..) || Q || Zp || Zp(a)
-              (rField_is_Q() || rField_is_Q_a() || 
+              (rField_is_Q() || rField_is_Q_a() ||
                (rField_is_Zp() || rField_is_Zp_a())))
              ||
              (rField_is_Zp_a(r) &&  // Zp(a..) -> Zp(a..) || Zp
-              (rField_is_Zp(currRing, rInternalChar(r)) || 
+              (rField_is_Zp(currRing, rInternalChar(r)) ||
                rField_is_Zp_a(currRing, rInternalChar(r)))) )
         {
@@ -1975,4 +1975,5 @@
 
 /*=================== operations with 2 args.: table =================*/
+
 struct sValCmd2 dArith2[]=
 {
@@ -2508,32 +2509,45 @@
   assumeStdFlag(v);
   ideal I=(ideal)v->Data();
-  BOOLEAN *UsedAxis=(BOOLEAN *)Alloc0(pVariables*sizeof(BOOLEAN));
-  int i,n;
-  poly po;
-  for(i=IDELEMS(I)-1;i>=0;i--)
-  {
-    po=I->m[i];
-    if ((po!=NULL) &&((n=pIsPurePower(po))!=0)) UsedAxis[n-1]=TRUE;
-  }
-  for(i=pVariables-1;i>=0;i--)
-  {
-    if(UsedAxis[i]==FALSE) return FALSE; // not zero-dim.
-  }
-  if (currRing->OrdSgn==1)
-  {
-    res->data=pOne();
-    return FALSE;
-  }
-  po=NULL;
-  scComputeHC(I,0,po);
-  if (po!=NULL)
-  {
-    pGetCoeff(po)=nInit(1);
-    for (i=pVariables; i>0; i--)
-    {
-      if (pGetExp(po, i) > 0) pDecrExp(po,i);
-    }
-    pSetm(po);
-  }
+  res->data=(void *)iiHighCorner(I,0);
+  return FALSE;
+}
+static BOOLEAN jjHIGHCORNER_M(leftv res, leftv v)
+{
+  assumeStdFlag(v);
+  intvec *module_w=new intvec(*(intvec*)atGet(v,"isHomog"));
+  ideal I=(ideal)v->Data();
+  int i;
+  poly p=NULL,po=NULL;
+  int rk=idRankFreeModule(I);
+  if (module_w==NULL)
+    module_w = new intvec(rk);
+  for(i=rk;i>0;i--)
+  {
+    p=iiHighCorner(I,i);
+    if (p==NULL)
+    {
+      Werror("module must be zero-dimensional");
+      delete module_w;
+      return TRUE;
+    }
+    if (po==NULL)
+      po=p;
+    else
+    {
+      // now po!=NULL, p!=NULL
+      int d=(pFDeg(po)+(*module_w)[pGetComp(po)] - pFDeg(p)+ (*module_w)[i]);
+      if (d==0)
+        d=pComp0(po,p);
+      if (d < 0)
+      {
+        pDelete(&po); po=p;
+      }
+      else // (d > 0)
+      {
+        pDelete(&p);
+      }
+    }
+  }
+  delete module_w;
   res->data=(void *)po;
   return FALSE;
@@ -3401,4 +3415,5 @@
 ,{jjGETDUMP,    GETDUMP_CMD,     NONE,           LINK_CMD }
 ,{jjHIGHCORNER, HIGHCORNER_CMD,  POLY_CMD,       IDEAL_CMD }
+,{jjHIGHCORNER_M, HIGHCORNER_CMD,VECTOR_CMD,     MODUL_CMD }
 ,{jjHILBERT,    HILBERT_CMD,     NONE,           IDEAL_CMD }
 ,{jjHILBERT,    HILBERT_CMD,     NONE,           MODUL_CMD }
Index: Singular/ipshell.cc
===================================================================
--- Singular/ipshell.cc	(revision 52c2fbd6f734a6e530dac2589becda5a013ced56)
+++ Singular/ipshell.cc	(revision f99917fc47a2b22bde5ec1bddc687567f3cd4dba)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: ipshell.cc,v 1.36 1999-03-09 12:28:48 obachman Exp $ */
+/* $Id: ipshell.cc,v 1.37 1999-03-11 15:58:06 Singular Exp $ */
 /*
 * ABSTRACT:
@@ -31,4 +31,5 @@
 #include "ipconv.h"
 #include "silink.h"
+#include "stairc.h"
 #include "ipshell.h"
 
@@ -1065,2 +1066,37 @@
   return FALSE;
 }
+
+poly    iiHighCorner(ideal I, int ak)
+{
+  BOOLEAN *UsedAxis=(BOOLEAN *)Alloc0(pVariables*sizeof(BOOLEAN));
+  int i,n;
+  poly po;
+  for(i=IDELEMS(I)-1;i>=0;i--)
+  {
+    po=I->m[i];
+    if ((po!=NULL) &&((n=pIsPurePower(po))!=0)) UsedAxis[n-1]=TRUE;
+  }
+  for(i=pVariables-1;i>=0;i--)
+  {
+    if(UsedAxis[i]==FALSE) return NULL; // not zero-dim.
+  }
+  if (currRing->OrdSgn== -1)
+  {
+    po=NULL;
+    scComputeHC(I,ak,po);
+    if (po!=NULL)
+    {
+      pGetCoeff(po)=nInit(1);
+      for (i=pVariables; i>0; i--)
+      {
+        if (pGetExp(po, i) > 0) pDecrExp(po,i);
+      }
+    }
+  }
+  if (po!=NULL)
+  {
+    pSetComp(po,ak);
+    pSetm(po);
+  }
+  return po;
+}
Index: Singular/ipshell.h
===================================================================
--- Singular/ipshell.h	(revision 52c2fbd6f734a6e530dac2589becda5a013ced56)
+++ Singular/ipshell.h	(revision f99917fc47a2b22bde5ec1bddc687567f3cd4dba)
@@ -4,5 +4,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: ipshell.h,v 1.15 1998-10-22 12:26:11 krueger Exp $ */
+/* $Id: ipshell.h,v 1.16 1999-03-11 15:58:07 Singular Exp $ */
 /*
 * ABSTRACT
@@ -71,4 +71,5 @@
 void    iiDebug();
 BOOLEAN iiCheckRing(int i);
+poly    iiHighCorner(ideal i, int ak);
 /* ================================================================== */
 /* Expressions : */
Index: Singular/matpol.cc
===================================================================
--- Singular/matpol.cc	(revision 52c2fbd6f734a6e530dac2589becda5a013ced56)
+++ Singular/matpol.cc	(revision f99917fc47a2b22bde5ec1bddc687567f3cd4dba)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: matpol.cc,v 1.21 1999-03-08 17:30:42 Singular Exp $ */
+/* $Id: matpol.cc,v 1.22 1999-03-11 15:58:08 Singular Exp $ */
 
 /*
@@ -780,5 +780,7 @@
   poly sel, h;
   int l, i;
+  int pos_of_1 = -1;
   matrix co;
+
   if (f==NULL)
   {
@@ -795,8 +797,10 @@
     for (i=l; i>=1; i--)
     {
-      h = pHead(sel);
+      h = sel;
+      pIter(sel);
+      pNext(h)=NULL;
       MATELEM(co,1,i) = h;
       MATELEM(co,2,i) = NULL;
-      sel = sel->next;
+      if (pIsConstant(h)) pos_of_1 = i;
     }
   }
@@ -805,8 +809,10 @@
     for (i=1; i<=l; i++)
     {
-      h = pHead(sel);
+      h = sel;
+      pIter(sel);
+      pNext(h)=NULL;
       MATELEM(co,1,i) = h;
       MATELEM(co,2,i) = NULL;
-      sel = sel->next;
+      if (pIsConstant(h)) pos_of_1 = i;
     }
   }
@@ -816,14 +822,25 @@
     loop
     {
-      h = mpExdiv(f, MATELEM(co,1,i));
-      if (h!=NULL)
-      {
-        MATELEM(co,2,i) = pAdd(MATELEM(co,2,i), h);
+      if (i!=pos_of_1)
+      {
+        h = mpExdiv(f, MATELEM(co,1,i));
+        if (h!=NULL)
+        {
+          MATELEM(co,2,i) = pAdd(MATELEM(co,2,i), h);
+          break;
+        }
+      }
+      if (i == l) 
+      {
+        // check monom 1 last:
+        h = mpExdiv(f, MATELEM(co,1,pos_of_1));
+        if (h!=NULL)
+        {
+          MATELEM(co,2,pos_of_1) = pAdd(MATELEM(co,2,pos_of_1), h);
+          break;
+        }
         break;
-      }
-      if (i < l)
-        i++;
-      else
-        break;
+      }	
+      i ++;
     }
     pIter(f);
Index: Singular/ring.cc
===================================================================
--- Singular/ring.cc	(revision 52c2fbd6f734a6e530dac2589becda5a013ced56)
+++ Singular/ring.cc	(revision f99917fc47a2b22bde5ec1bddc687567f3cd4dba)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: ring.cc,v 1.44 1999-03-08 18:11:50 Singular Exp $ */
+/* $Id: ring.cc,v 1.45 1999-03-11 15:58:09 Singular Exp $ */
 
 /*
@@ -673,7 +673,7 @@
 {
   int VarCompIndex, VarLowIndex, VarHighIndex;
-  
+
   r->VarOffset = (int*) Alloc((r->N + 1)*sizeof(int));
-  pGetVarIndicies(r, r->VarOffset, VarCompIndex, 
+  pGetVarIndicies(r, r->VarOffset, VarCompIndex,
                   VarLowIndex, VarHighIndex);
   r->VarCompIndex = VarCompIndex;
@@ -732,12 +732,19 @@
 
   if (rField_is_GF(r))
-    PrintS("//   # ground field : ");
+  {
+    Print("//   # ground field : %d\n",rInternalChar(r));
+    Print("//   primitive element : %s\n", r->parameter[0]);
+    if (r==currRing)
+    {
+      StringSetS("//   minpoly        : ");
+      nfShowMipo();PrintS(StringAppend("\n"));
+    }
+  }
   else
+  {
     PrintS("//   characteristic : ");
-  if ( rField_is_R(r) )        PrintS("0 (real)\n");  /* R */
-  else Print ("%d\n",rChar(r)); /* Fp(a) */
-  if (r->parameter!=NULL)
-  {
-    if (r->ch<2)
+    if ( rField_is_R(r) )        PrintS("0 (real)\n");  /* R */
+    else Print ("%d\n",rChar(r)); /* Fp(a) */
+    if (r->parameter!=NULL)
     {
       Print ("//   %d parameter    : ",rPar(r));
@@ -762,13 +769,4 @@
       {
         PrintS("...\n");
-      }
-    }
-    else
-    {
-      Print("//   primitive element : %s\n", r->parameter[0]);
-      if (r==currRing)
-      {
-        StringSetS("//   minpoly        : ");
-        nfShowMipo();PrintS(StringAppend("\n"));
       }
     }
@@ -1346,10 +1344,10 @@
             tmpR.P=1;
             nSetChar(rInternalChar(currRing),TRUE,currRing->parameter,
-	      rPar(currRing));
+              rPar(currRing));
           }
           else
           {
             nSetChar(rInternalChar(currRing),TRUE,currRing->parameter,
-	      rPar(currRing));
+              rPar(currRing));
             WerrorS("different minpolys");
             return -1;
@@ -1367,5 +1365,5 @@
             tmpR.minpoly=naCopy(r1->minpoly);
             nSetChar(rInternalChar(currRing),TRUE,currRing->parameter,
-	      rPar(currRing));
+              rPar(currRing));
           }
           else
@@ -1389,5 +1387,5 @@
             tmpR.minpoly=naCopy(r2->minpoly);
             nSetChar(rInternalChar(currRing),TRUE,currRing->parameter,
-	      rPar(currRing));
+              rPar(currRing));
           }
           else
@@ -1444,5 +1442,5 @@
           tmpR.minpoly=naCopy(r1->minpoly);
           nSetChar(rInternalChar(currRing),TRUE,currRing->parameter,
-	    rPar(currRing));
+            rPar(currRing));
         }
       }
@@ -1471,5 +1469,5 @@
           tmpR.minpoly=naCopy(r2->minpoly);
           nSetChar(rInternalChar(currRing),TRUE,currRing->parameter,
-	    rPar(currRing));
+            rPar(currRing));
         }
       }
@@ -1507,5 +1505,5 @@
           tmpR.minpoly=naCopy(r1->minpoly);
           nSetChar(rInternalChar(currRing),TRUE,currRing->parameter,
-	    rPar(currRing));
+            rPar(currRing));
         }
       }
@@ -1537,5 +1535,5 @@
           tmpR.minpoly=naCopy(r2->minpoly);
           nSetChar(rInternalChar(currRing),TRUE,currRing->parameter,
-	    rPar(currRing));
+            rPar(currRing));
         }
       }
@@ -1920,5 +1918,5 @@
 
   if (r->N == 0) return true;
-  
+
   if (r->VarOffset == NULL)
   {
@@ -1927,15 +1925,15 @@
     return false;
   }
-  
-  int  
-    VarCompIndex = r->VarCompIndex, 
-    VarLowIndex  = r->VarLowIndex, 
+
+  int
+    VarCompIndex = r->VarCompIndex,
+    VarLowIndex  = r->VarLowIndex,
     VarHighIndex = r->VarHighIndex,
     i;
   BOOLEAN ok = false;
   int* VarOffset = r->VarOffset;
-  
+
   rComplete(r);
-  
+
   if (   VarCompIndex != r->VarCompIndex ||
          VarLowIndex  != r->VarLowIndex ||
@@ -1946,5 +1944,5 @@
     ok = FALSE;
   }
-  
+
   for (i=0; i<=r->N; i++)
   {
