Index: Singular/iparith.cc
===================================================================
--- Singular/iparith.cc	(revision 66a322a436b2789167c21fea3dd3bc12fa72e53a)
+++ Singular/iparith.cc	(revision 4a1fb878bfdf0417563882a38427ef60ca87a5ce)
@@ -5988,6 +5988,27 @@
        most. (Cached monomials are counted over all cached polynomials.)
   */
-  const matrix m = (const matrix)v->Data();
-  const int mk = (const int)(long)v->next->Data();
+  matrix m;
+  leftv u=v->next;
+  v->next=NULL;
+  if (v->Typ()==MATRIX_CMD)
+  {
+     m = (const matrix)v->Data();
+  }
+  else
+  {
+    // try to convert to MATRIX:
+    int ii=iiTestConvert(v->Typ(),MATRIX_CMD);
+    BOOLEAN bo;
+    sleftv tmp;
+    if (ii>0) bo=iiConvert(v->Typ(),MATRIX_CMD,ii,v,&tmp);
+    else bo=TRUE;
+    if (bo)
+    { 
+      Werror("cannot convert %s to matrix",Tok2Cmdname(v->Typ()));
+      return TRUE;
+    }
+    m=(matrix)tmp.data;
+  }
+  const int mk = (const int)(long)u->Data();
   bool noIdeal = true; bool noK = true; bool noAlgorithm = true;
   bool noCacheMinors = true; bool noCacheMonomials = true;
@@ -5995,24 +6016,24 @@
   
   /* here come the different cases of correct argument sets */
-  if ((v->next->next != NULL) && (v->next->next->Typ() == IDEAL_CMD))
-  {
-    IasSB = (ideal)v->next->next->Data();
+  if ((u->next != NULL) && (u->next->Typ() == IDEAL_CMD))
+  {
+    IasSB = (ideal)u->next->Data();
     noIdeal = false;
-    if ((v->next->next->next != NULL) && (v->next->next->next->Typ() == INT_CMD))
-    {
-      k = (int)(long)v->next->next->next->Data();
+    if ((u->next->next != NULL) && (u->next->next->Typ() == INT_CMD))
+    {
+      k = (int)(long)u->next->next->Data();
       noK = false;
       assume(k != 0);
-      if ((v->next->next->next->next != NULL) && (v->next->next->next->next->Typ() == STRING_CMD))
-      {
-        algorithm = (char*)v->next->next->next->next->Data();
+      if ((u->next->next->next != NULL) && (u->next->next->next->Typ() == STRING_CMD))
+      {
+        algorithm = (char*)u->next->next->next->Data();
         noAlgorithm = false;
-        if ((v->next->next->next->next->next != NULL) && (v->next->next->next->next->next->Typ() == INT_CMD))
+        if ((u->next->next->next->next != NULL) && (u->next->next->next->next->Typ() == INT_CMD))
         {
-          cacheMinors = (int)(long)v->next->next->next->next->next->Data();
+          cacheMinors = (int)(long)u->next->next->next->next->Data();
           noCacheMinors = false;
-          if ((v->next->next->next->next->next->next != NULL) && (v->next->next->next->next->next->next->Typ() == INT_CMD))
+          if ((u->next->next->next->next->next != NULL) && (u->next->next->next->next->next->Typ() == INT_CMD))
           {
-            cacheMonomials = (int)(long)v->next->next->next->next->next->next->Data();
+            cacheMonomials = (int)(long)u->next->next->next->next->next->Data();
             noCacheMonomials = false;
           }
@@ -6021,20 +6042,20 @@
     }
   }
-  else if ((v->next->next != NULL) && (v->next->next->Typ() == INT_CMD))
-  {
-    k = (int)(long)v->next->next->Data();
+  else if ((u->next != NULL) && (u->next->Typ() == INT_CMD))
+  {
+    k = (int)(long)u->next->Data();
     noK = false;
     assume(k != 0);
-    if ((v->next->next->next != NULL) && (v->next->next->next->Typ() == STRING_CMD))
-    {
-      algorithm = (char*)v->next->next->next->Data();
+    if ((u->next->next != NULL) && (u->next->next->Typ() == STRING_CMD))
+    {
+      algorithm = (char*)u->next->next->Data();
       noAlgorithm = false;
-      if ((v->next->next->next->next != NULL) && (v->next->next->next->next->Typ() == INT_CMD))
-      {
-        cacheMinors = (int)(long)v->next->next->next->next->Data();
+      if ((u->next->next->next != NULL) && (u->next->next->next->Typ() == INT_CMD))
+      {
+        cacheMinors = (int)(long)u->next->next->next->Data();
         noCacheMinors = false;
-        if ((v->next->next->next->next->next != NULL) && (v->next->next->next->next->next->Typ() == INT_CMD))
+        if ((u->next->next->next->next != NULL) && (u->next->next->next->next->Typ() == INT_CMD))
         {
-          cacheMonomials = (int)(long)v->next->next->next->next->next->Data();
+          cacheMonomials = (int)(long)u->next->next->next->next->Data();
           noCacheMonomials = false;
         }
@@ -6042,15 +6063,15 @@
     }
   }
-  else if ((v->next->next != NULL) && (v->next->next->Typ() == STRING_CMD))
-  {
-    algorithm = (char*)v->next->next->Data();
+  else if ((u->next != NULL) && (u->next->Typ() == STRING_CMD))
+  {
+    algorithm = (char*)u->next->Data();
     noAlgorithm = false;
-    if ((v->next->next->next != NULL) && (v->next->next->next->Typ() == INT_CMD))
-    {
-      cacheMinors = (int)(long)v->next->next->next->Data();
+    if ((u->next->next != NULL) && (u->next->next->Typ() == INT_CMD))
+    {
+      cacheMinors = (int)(long)u->next->next->Data();
       noCacheMinors = false;
-      if ((v->next->next->next->next != NULL) && (v->next->next->next->next->Typ() == INT_CMD))
-      {
-        cacheMonomials = (int)(long)v->next->next->next->next->Data();
+      if ((u->next->next->next != NULL) && (u->next->next->next->Typ() == INT_CMD))
+      {
+        cacheMonomials = (int)(long)u->next->next->next->Data();
         noCacheMonomials = false;
       }
@@ -6062,16 +6083,16 @@
   {
     if (strcmp(algorithm, "bareiss") == 0)
-      algorithm = "Bareiss";
+      algorithm = (char*)"Bareiss";
     if (strcmp(algorithm, "laplace") == 0)
-      algorithm = "Laplace";
+      algorithm = (char*)"Laplace";
     if (strcmp(algorithm, "cache") == 0)
-      algorithm = "Cache";
-  }
-
+      algorithm = (char*)"Cache";
+  }
+
+  v->next=u;
   /* here come some tests */
-  if ((!noIdeal) && (!hasFlag(v->next->next, FLAG_STD)))
-  {
-    WerrorS("Provided ideal is not a standard basis.");
-    return TRUE;
+  if (!noIdeal)
+  {
+    assumeStdFlag(u->next);
   }
   if ((!noK) && (k == 0))
