Index: Singular/iparith.cc
===================================================================
--- Singular/iparith.cc	(revision 1378915d904a163ade5fd8be0a96eb3e73bac75c)
+++ Singular/iparith.cc	(revision 32d2a9c9252a1380b1f12522da4f43553091f048)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: iparith.cc,v 1.492 2009-01-16 02:21:09 motsak Exp $ */
+/* $Id: iparith.cc,v 1.493 2009-01-17 10:19:17 Singular Exp $ */
 
 /*
@@ -261,5 +261,5 @@
   { "hilb",        0, HILBERT_CMD ,       CMD_123},
   { "highcorner",  0, HIGHCORNER_CMD,     CMD_1},
-  { "homog",       0, HOMOG_CMD ,         CMD_12},
+  { "homog",       0, HOMOG_CMD ,         CMD_123},
   { "hres",        0, HRES_CMD ,          CMD_2},
   { "ideal",       0, IDEAL_CMD ,         IDEAL_CMD},
@@ -898,5 +898,5 @@
   {
      Werror("matrix size not compatible(%dx%d, %dx%d)",
-	     MATROWS(A),MATCOLS(A),MATROWS(B),MATCOLS(B));
+             MATROWS(A),MATCOLS(A),MATROWS(B),MATCOLS(B));
      return TRUE;
   }
@@ -977,5 +977,5 @@
   {
      Werror("matrix size not compatible(%dx%d, %dx%d)",
-	     MATROWS(A),MATCOLS(A),MATROWS(B),MATCOLS(B));
+             MATROWS(A),MATCOLS(A),MATROWS(B),MATCOLS(B));
      return TRUE;
   }
@@ -1103,5 +1103,5 @@
   {
      Werror("matrix size not compatible(%dx%d, %dx%d)",
-	     MATROWS(A),MATCOLS(A),MATROWS(B),MATCOLS(B));
+             MATROWS(A),MATCOLS(A),MATROWS(B),MATCOLS(B));
      return TRUE;
   }
@@ -2304,4 +2304,24 @@
     WerrorS("variable must have weight 1");
   return (d!=1);
+}
+static BOOLEAN jjHOMOG1_W(leftv res, leftv v, leftv u)
+{
+  intvec *w=new intvec(rVar(currRing));
+  intvec *vw=(intvec*)u->Data();
+  ideal v_id=(ideal)v->Data();
+  pFDegProc save_FDeg=pFDeg;
+  pLDegProc save_LDeg=pLDeg;
+  BOOLEAN save_pLexOrder=pLexOrder;
+  pLexOrder=FALSE;
+  kHomW=vw;
+  kModW=w;
+  pSetDegProcs(kHomModDeg);
+  res->data=(void *)(long)idHomModule(v_id,currQuotient,&w);
+  pLexOrder=save_pLexOrder;
+  kHomW=NULL;
+  kModW=NULL;
+  pRestoreDegProcs(save_FDeg,save_LDeg);
+  if (w!=NULL) delete w;
+  return FALSE;
 }
 static BOOLEAN jjINDEPSET2(leftv res, leftv u, leftv v)
@@ -2819,5 +2839,5 @@
     if (weights!=NULL) (*w) += add_row_shift;
     atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
-    delete w;
+    w=NULL;
   }
   else
@@ -3352,4 +3372,6 @@
 ,{jjHILBERT2,  HILBERT_CMD,    INTVEC_CMD,     IDEAL_CMD,  INT_CMD NO_PLURAL}
 ,{jjHILBERT2,  HILBERT_CMD,    INTVEC_CMD,     MODUL_CMD,  INT_CMD NO_PLURAL}
+,{jjHOMOG1_W,  HOMOG_CMD,      INT_CMD,        IDEAL_CMD,  INTVEC_CMD ALLOW_PLURAL}
+,{jjHOMOG1_W,  HOMOG_CMD,      INT_CMD,        MODUL_CMD,   INTVEC_CMD ALLOW_PLURAL}
 ,{jjHOMOG_P,   HOMOG_CMD,      POLY_CMD,       POLY_CMD,   POLY_CMD ALLOW_PLURAL}
 ,{jjHOMOG_P,   HOMOG_CMD,      VECTOR_CMD,     VECTOR_CMD, POLY_CMD ALLOW_PLURAL}
@@ -3934,16 +3956,28 @@
   {
     res->data=(void *)(long)idHomModule(v_id,currQuotient,&w);
-    if ((res->data!=NULL) && (v->rtyp==IDHDL))
-    {
-      char *isHomog=omStrDup("isHomog");
+    if (res->data!=NULL) 
+    {
+      if (v->rtyp==IDHDL)
+      {
+        char *isHomog=omStrDup("isHomog");
+        if (v->e==NULL)
+          atSet((idhdl)(v->data),isHomog,w,INTVEC_CMD);
+        else
+          atSet((idhdl)(v->LData()),isHomog,w,INTVEC_CMD);
+      }
+      else if (w!=NULL) delete w;
+    } // if res->data==NULL then w==NULL
+  }
+  else
+  {
+    res->data=(void *)(long)idTestHomModule(v_id,currQuotient,w);
+    if((res->data==NULL) && (v->rtyp==IDHDL))
+    {
       if (v->e==NULL)
-        atSet((idhdl)(v->data),isHomog,w,INTVEC_CMD);
+        atKill((idhdl)(v->data),"isHomog");
       else
-        atSet((idhdl)(v->LData()),isHomog,w,INTVEC_CMD);
-    }
-    else if (w!=NULL) delete w;
-  }
-  else
-    res->data=(void *)(long)idTestHomModule(v_id,currQuotient,w);
+        atKill((idhdl)(v->LData()),"isHomog");
+    }
+  }
   return FALSE;
 }
@@ -4054,21 +4088,20 @@
 static BOOLEAN jjJACOB_M(leftv res, leftv a)
 {
-
-	ideal id = (ideal)a->Data();
-	id = idTransp(id);
-	int W = IDELEMS(id);
-
-	ideal result = idInit(W * pVariables, id->rank); 
-	poly *p = result->m;
-	
-	for( int v = 1; v <= pVariables; v++ )
+  ideal id = (ideal)a->Data();
+  id = idTransp(id);
+  int W = IDELEMS(id);
+
+  ideal result = idInit(W * pVariables, id->rank); 
+  poly *p = result->m;
+        
+  for( int v = 1; v <= pVariables; v++ )
   {
     poly* q = id->m;
-	  for( int i = 0; i < W; i++, p++, q++ ) 
-		  *p = pDiff( *q, v );
-  }
-	idDelete(&id);
-
-	res->data = (char *)result;
+    for( int i = 0; i < W; i++, p++, q++ ) 
+      *p = pDiff( *q, v );
+  }
+  idDelete(&id);
+
+  res->data = (char *)result;
   return FALSE;
 }
@@ -5631,4 +5664,40 @@
   return TRUE;
 }
+static BOOLEAN jjHOMOG_ID_W(leftv res, leftv u, leftv v, leftv w)
+{
+  PrintS("TODO\n");
+  int i=pVar((poly)v->Data());
+  if (i==0)
+  {
+    WerrorS("ringvar expected");
+    return TRUE;
+  }
+  poly p=pOne(); pSetExp(p,i,1); pSetm(p);
+  int d=pWTotaldegree(p);
+  pLmDelete(p);
+  if (d==1)
+    res->data = (char *)idHomogen((ideal)u->Data(),i);
+  else
+    WerrorS("variable must have weight 1");
+  return (d!=1);
+}
+static BOOLEAN jjHOMOG_P_W(leftv res, leftv u, leftv v,leftv w)
+{
+  PrintS("TODO\n");
+  int i=pVar((poly)v->Data());
+  if (i==0)
+  {
+    WerrorS("ringvar expected");
+    return TRUE;
+  }
+  poly p=pOne(); pSetExp(p,i,1); pSetm(p);
+  int d=pWTotaldegree(p);
+  pLmDelete(p);
+  if (d==1)
+    res->data = (char *)pHomogen((poly)u->Data(),i);
+  else
+    WerrorS("variable must have weight 1");
+  return (d!=1);
+}
 static BOOLEAN jjINTMAT3(leftv res, leftv u, leftv v,leftv w)
 {
@@ -6090,4 +6159,8 @@
 ,{jjHILBERT3,       HILBERT_CMD,INTVEC_CMD, IDEAL_CMD,  INT_CMD,    INTVEC_CMD NO_PLURAL}
 ,{jjHILBERT3,       HILBERT_CMD,INTVEC_CMD, MODUL_CMD,  INT_CMD,    INTVEC_CMD NO_PLURAL}
+,{jjHOMOG_P_W,      HOMOG_CMD,  POLY_CMD,   POLY_CMD,   POLY_CMD,   INTVEC_CMD ALLOW_PLURAL}
+,{jjHOMOG_P_W,      HOMOG_CMD,  VECTOR_CMD, VECTOR_CMD, POLY_CMD,   INTVEC_CMD ALLOW_PLURAL}
+,{jjHOMOG_ID_W,     HOMOG_CMD,  IDEAL_CMD,  IDEAL_CMD,  POLY_CMD,   INTVEC_CMD ALLOW_PLURAL}
+,{jjHOMOG_ID_W,     HOMOG_CMD,  MODUL_CMD,  MODUL_CMD,  POLY_CMD,   INTVEC_CMD ALLOW_PLURAL}
 ,{jjCALL3MANY,      IDEAL_CMD,  IDEAL_CMD,  DEF_CMD,    DEF_CMD,    DEF_CMD ALLOW_PLURAL}
 ,{lInsert3,         INSERT_CMD, LIST_CMD,   LIST_CMD,   DEF_CMD,    INT_CMD ALLOW_PLURAL}
@@ -6357,5 +6430,5 @@
       {
         number b=(number)h->Data();
-	number n=nInit_bigint(b);
+        number n=nInit_bigint(b);
         if (!nIsZero(n))
         {
