Index: Singular/extra.cc
===================================================================
--- Singular/extra.cc	(revision d88b030aab30132964e13441edf50d4075a99fb2)
+++ Singular/extra.cc	(revision 0e4337544d5e40b9b6dcd35e9c376c7044c0a909)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR      *
 *****************************************/
-/* $Id: extra.cc,v 1.162 2001-02-22 19:12:57 levandov Exp $ */
+/* $Id: extra.cc,v 1.163 2001-02-26 15:08:42 levandov Exp $ */
 /*
 * ABSTRACT: general interface to internals of Singular ("system" command)
@@ -69,4 +69,5 @@
 
 #ifdef HAVE_PLURAL
+#include "ring.h"
 #include "gring.h"
 #endif
@@ -1180,5 +1181,5 @@
       matrix C;
       matrix D;
-
+      matrix COM;
       if ((h!=NULL) && (h->Typ()==MATRIX_CMD))
       {
@@ -1195,25 +1196,32 @@
       {
         currRing->nc=(nc_struct *)omAlloc0(sizeof(nc_struct));
-	currRing->nc->MT=(matrix *)omAlloc0(pVariables*(pVariables-1)/2*sizeof(matrix));
-	currRing->nc->MTsize=(int *)omAlloc0(pVariables*(pVariables-1)/2*sizeof(int));
+        currRing->nc->MT=(matrix *)omAlloc0(currRing->N*(currRing->N-1)/2*sizeof(matrix));
+        currRing->nc->MTsize=(int *)omAlloc0(currRing->N*(currRing->N-1)/2*sizeof(int));
       }
       else
       {
         WarnS("redefining algebra structure");
-      }
+      }     
       currRing->nc->type=nc_general;
       currRing->nc->C=C;
       currRing->nc->D=D;
-      {
-        int i,j;
-        poly p;
-        short DefMTsize=7;
-        int nv=pVariables;
-        for(i=1;i<nv;i++)
-        {
-          for(j=i+1;j<=nv;j++)
-          { 
-            currRing->nc->MTsize[UPMATELEM(i,j,curring->N)]=DefMTsize; /* default sizes */
-            currRing->nc->MT[UPMATELEM(i,j,curring->N)]=mpNew(DefMTsize,DefMTsize);
+      COM=mpCopy(currRing->nc->C);
+      int i,j;
+      poly p;
+      short DefMTsize=7;
+      int nv=currRing->N;
+      for(i=1;i<nv;i++)
+      {
+        for(j=i+1;j<=nv;j++)
+        {
+          if (MATELEM(D,i,j)==NULL)
+          {
+            currRing->nc->MTsize[UPMATELEM(i,j,currRing->N)]=0;
+          }
+          else
+          {
+            MATELEM(COM,i,j)=NULL;
+            currRing->nc->MTsize[UPMATELEM(i,j,currRing->N)]=DefMTsize; /* default sizes */
+            currRing->nc->MT[UPMATELEM(i,j,currRing->N)]=mpNew(DefMTsize,DefMTsize);
             p=pOne();
             pSetCoeff(p,nCopy(pGetCoeff(MATELEM(currRing->nc->C,i,j))));
@@ -1222,14 +1230,12 @@
             pSetm(p);
             p=pAdd(p,pCopy(MATELEM(currRing->nc->D,i,j)));
-            MATELEM(currRing->nc->MT[UPMATELEM(i,j,curring->N)],1,1)=p;
-            /* set MT[i,j,1,1] to c_i_j*x_i*x_j + D_i_j */
+            MATELEM(currRing->nc->MT[UPMATELEM(i,j,currRing->N)],1,1)=p;
           }
-        }
-      }
-      // set p_Procs:
-//      currRing->p_Procs->pp_Mult_mm =nc_pp_Mult_mm;
-//      currRing->p_Procs->p_Mult_mm =nc_p_Mult_mm;
-//      currRing->p_Procs->p_Minus_mm_Mult_qq =nc_p_Minus_mm_Mult_qq;
-
+          
+          /* set MT[i,j,1,1] to c_i_j*x_i*x_j + D_i_j */
+        }
+      }
+      
+      currRing->nc->COM=COM;
       return FALSE;
     }
Index: Singular/gring.cc
===================================================================
--- Singular/gring.cc	(revision d88b030aab30132964e13441edf50d4075a99fb2)
+++ Singular/gring.cc	(revision 0e4337544d5e40b9b6dcd35e9c376c7044c0a909)
@@ -7,9 +7,16 @@
  *  Author:  levandov (Viktor Levandovsky)
  *  Created: 8/00 - 11/00
- *  Version: $Id: gring.cc,v 1.7 2001-02-23 16:44:13 levandov Exp $
+ *  Version: $Id: gring.cc,v 1.8 2001-02-26 15:08:43 levandov Exp $
  *******************************************************************/
 #include "mod2.h"
+#ifdef HAVE_PLURAL
 #include "gring.h"
-#ifdef HAVE_PLURAL
+#include "febase.h"
+#include "ring.h"
+#include "polys.h"
+#include "numbers.h"
+#include "ideals.h"
+#include "matpol.h"
+
 
 //global nc_macros :
@@ -39,10 +46,10 @@
   /* destroy p,q */
 {
-  poly res=0;
-  poly ghost;
+  poly res=NULL;
+  poly ghost=NULL;
   while (q!=NULL)
     {
       res=p_Add_q(res,nc_pp_Mult_mm(p,p_Head(q,r),r,ghost),r);
-      p_LmDeleteAndNext(q,r);
+      q=p_LmDeleteAndNext(q,r);
     }
   p_Delete(&p,r);
@@ -117,5 +124,5 @@
     out = p_Add_q(out,v,r);
     //    p_DeleteLm(&p,r);
-    p_LmDeleteAndNext(p,r);
+    p=p_LmDeleteAndNext(p,r);
   }
   freeT(P,r->N);
@@ -586,5 +593,31 @@
   number tmp_number=NULL;
   
-// first check wether the polynom is alredy computed
+//Now check zero exeptions, commutativity and should we do something at all?  
+  out=pOne();
+  p_SetExp(out,j,b,r);
+  p_SetExp(out,i,a,r);
+  if (i==j) p_SetExp(out,j,a+b,r);
+  p_Setm(out,r);
+  if ((a==0)||(b==0)||(i<=j)) return(out);//zero exeptions and usual case
+  
+  if (MATELEM(r->nc->COM,j,i)!=NULL)
+//commutative or quasicommutative case
+  {
+    if (r->cf->nIsOne(p_GetCoeff(MATELEM(r->nc->COM,j,i),r))) //commutative case
+    {
+      return(out);
+    }     
+    else
+    {
+      tmp_number=p_GetCoeff(MATELEM(r->nc->COM,j,i),r); //quasicommutative case
+      nPower(tmp_number,a*b,&tmp_number);
+      p_SetCoeff(out,tmp_number,r);
+      return(out);
+    }
+  }// end commutative or quasicommutative case
+
+  //we are here if  i>j and variables do not commute or quasicommute
+  //in fact, now a>=1 and b>=1; and j<i
+  // now check wether the polynom is alredy computed
   int vik = UPMATELEM(j,i,r->N);
   matrix cMT=r->nc->MT[vik];
@@ -593,34 +626,8 @@
   if (((a<cMTsize)&&(b<cMTsize))&&(MATELEM(cMT,a,b)!=NULL))
   {
-     out=p_Copy(MATELEM(cMT,a,b),r);
-     return (out);
-  }
-
-//Now check zero exeptions, commutativity and should we do something at all?  
-      out=pOne();
-      p_SetExp(out,j,b,r);
-      p_SetExp(out,i,a,r);
-      if (i==j) p_SetExp(out,j,a+b,r);
-      p_Setm(out,r);
-      if ((a==0)||(b==0)||(i<=j)) return(out);//zero exeptions and usual case
-      
-      if (p_GetCoeff(r->nc->COM[UPMATELEM(i,j,r->N)],r)!=0) //commutative or quasicommutative case
-      {
-        if (p_GetCoeff(r->nc->COM[UPMATELEM(i,j,r->N)],r)!=n_Init(1,r)) //commutative case
-        {
-          return(out);
-        }     
-        else
-        {
-          tmp_number=p_GetCoeff(r->nc->COM[UPMATELEM(i,j,r->N)],r); //quasicommutative case
-          nPower(tmp_number,a*b,&tmp_number);
-          p_SetCoeff(out,tmp_number,r);
-          return(out);
-        }
-      }// end commutative or quasicommutative case
-
-//we are here if  i>j and variables do not commute or quasicommute
-//in fact, now a>=1 and b>=1; and j<i
-
+    out=p_Copy(MATELEM(cMT,a,b),r);
+    return (out);
+  }
+  
 //  poly C=MATELEM(r->nc->C,j,i);               
 //  number c=p_GetCoeff(C,r); //coeff           
@@ -628,6 +635,7 @@
       
   int newcMTsize=0;
-  
+  int k,m;
   p_Delete(&out,r);//Shura thinks it is nesessary
+
   
   if (a>=b) {newcMTsize=a;} else {newcMTsize=b;}
@@ -636,5 +644,4 @@
      newcMTsize = newcMTsize+cMTsize;
      matrix tmp = mpNew(newcMTsize,newcMTsize);
-     int k,m;
      
      for (k=1;k<r->N;k++)
Index: Singular/gring.h
===================================================================
--- Singular/gring.h	(revision d88b030aab30132964e13441edf50d4075a99fb2)
+++ Singular/gring.h	(revision 0e4337544d5e40b9b6dcd35e9c376c7044c0a909)
@@ -4,5 +4,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: gring.h,v 1.5 2001-02-23 16:28:24 levandov Exp $ */
+/* $Id: gring.h,v 1.6 2001-02-26 15:08:44 levandov Exp $ */
 /*
 * ABSTRACT additional defines etc for --with-plural
@@ -11,9 +11,5 @@
 #include "mod2.h"
 #ifdef HAVE_PLURAL
-#include "polys.h" // do we need it really?
-#include "numbers.h"
-#include "matpol.h"
-/* #include "p_Procs.h" */
-#include "ideals.h"
+#include "structs.h"
 
 #define UPMATELEM(i,j,nVar) ( (nVar * ((i)-1) - ((i) * ((i)-1))/2 + (j)-1)-(i) )
@@ -27,4 +23,5 @@
 poly nc_mm_Mult_uu (Exponent_t *F,int jG,int bG, const ring r);
 poly nc_uu_Mult_ww (int i, int a, int j, int b, const ring r);
+poly _nc_p_Mult_q(poly p, poly q, const int copy, const ring r);
 
 #endif /* HAVE_PLURAL */
Index: Singular/pInline2.h
===================================================================
--- Singular/pInline2.h	(revision d88b030aab30132964e13441edf50d4075a99fb2)
+++ Singular/pInline2.h	(revision 0e4337544d5e40b9b6dcd35e9c376c7044c0a909)
@@ -7,5 +7,5 @@
  *  Author:  obachman (Olaf Bachmann)
  *  Created: 8/00
- *  Version: $Id: pInline2.h,v 1.26 2001-02-23 16:28:24 levandov Exp $
+ *  Version: $Id: pInline2.h,v 1.27 2001-02-26 15:08:44 levandov Exp $
  *******************************************************************/
 #ifndef PINLINE2_H
@@ -26,4 +26,5 @@
 #ifdef HAVE_PLURAL
 #include "gring.h"
+#include "ring.h"
 #endif
 
Index: Singular/structs.h
===================================================================
--- Singular/structs.h	(revision d88b030aab30132964e13441edf50d4075a99fb2)
+++ Singular/structs.h	(revision 0e4337544d5e40b9b6dcd35e9c376c7044c0a909)
@@ -4,5 +4,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: structs.h,v 1.57 2001-02-20 09:45:43 Singular Exp $ */
+/* $Id: structs.h,v 1.58 2001-02-26 15:08:45 levandov Exp $ */
 /*
 * ABSTRACT
@@ -353,4 +353,5 @@
   matrix D;
   matrix *MT;
+  matrix COM;
   int *MTsize;
 };
