Changeset af42ca in git


Ignore:
Timestamp:
Jan 29, 2003, 5:13:12 PM (21 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
Children:
cc86cd3b37e46f65f8f2f4c0bea2f9c0a3438043
Parents:
18e9f2f7714c20737d239d02c81a2a64fcc2e65b
Message:
*hannes: ref count etc.


git-svn-id: file:///usr/local/Singular/svn/trunk@6442 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
Singular
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • Singular/ChangeLog.plural

    r18e9f2f raf42ca  
     129.11.02
     2        ref for ncstruct introduced,
     3        used in extra.cc ("PLURAL"), rCopy0, rKill
     4        new routine ncKill
     5
    1629.11.02
    27        qring q=system("twostd",i); is introduced and tested
  • Singular/extra.cc

    r18e9f2f raf42ca  
    22*  Computer Algebra System SINGULAR      *
    33*****************************************/
    4 /* $Id: extra.cc,v 1.192 2003-01-29 16:04:18 levandov Exp $ */
     4/* $Id: extra.cc,v 1.193 2003-01-29 16:13:10 Singular Exp $ */
    55/*
    66* ABSTRACT: general interface to internals of Singular ("system" command)
     
    14001400      {
    14011401        currRing->nc=(nc_struct *)omAlloc0(sizeof(nc_struct));
     1402        currRing->nc->ref=1;
    14021403      }
    14031404      else
    14041405      {
    14051406        WarnS("redefining algebra structure");
    1406         /* kill the previous nc data */
     1407        if (currRing->nc->ref>1) // in use by somebody else
     1408          currRing->nc->ref--;
     1409        else
     1410          ncKill(currRing); /* kill the previous nc data */
     1411        currRing->nc=(nc_struct *)omAlloc0(sizeof(nc_struct));
     1412        currRing->nc->ref=1;
    14071413      }
    14081414      currRing->nc->type=nc_general;
  • Singular/gring.cc

    r18e9f2f raf42ca  
    77 *  Author:  levandov (Viktor Levandovsky)
    88 *  Created: 8/00 - 11/00
    9  *  Version: $Id: gring.cc,v 1.19 2003-01-29 16:04:17 levandov Exp $
     9 *  Version: $Id: gring.cc,v 1.20 2003-01-29 16:13:11 Singular Exp $
    1010 *******************************************************************/
    1111#include "mod2.h"
     
    9191    p_Test(v,r);
    9292    p_Test(p,r);
    93    
     93
    9494    expP=p_GetComp(v,r);
    9595    if (expP==0)
     
    102102      {
    103103        expOut=expM;
    104       }     
     104      }
    105105    }
    106106    else
     
    113113      {
    114114        /* REPORT_ERROR */
    115         Print("nc_p_Mult_mm: exponent mismatch %d and %d\n",expP,expM);
     115        Print("nc_p_Mult_mm: exponent mismatch %d and %d\n",expP,expM);
    116116        expOut=0;
    117117      }
    118118    }
    119    
     119
    120120    p_GetExpV(v,P,r);
    121121    cP=p_GetCoeff(v,r);
     
    165165
    166166  sBucket_pt bu_out=sBucketCreate(r);
    167  
     167
    168168  while (p!=NULL)
    169169  {
     
    171171    p_Test(v,r);
    172172    p_Test(p,r);
    173    
     173
    174174    expP=p_GetComp(v,r);
    175175    if (expP==0)
     
    182182      {
    183183        expOut=expM;
    184       }     
     184      }
    185185    }
    186186    else
     
    193193      {
    194194        /* REPORT_ERROR */
    195         Print("nc_mm_Mult_p: exponent mismatch %d and %d\n",expP,expM);
     195        Print("nc_mm_Mult_p: exponent mismatch %d and %d\n",expP,expM);
    196196        expOut=0;
    197197      }
     
    234234  F[0]=0;
    235235  G[0]=0;
    236  
     236
    237237  iF=r->N;
    238238  while ((F[iF]==0)&&(iF>=1)) iF--; /* last exp_num of F */
     
    249249    {
    250250      F[i]=F[i]+G[i];
    251     } 
     251    }
    252252    p_SetExpV(out,F,r);
    253253    p_Setm(out,r);
     
    266266    return(out);
    267267  }
    268  
     268
    269269  number n1=n_Init(1,r);
    270270  Exponent_t *Prv=(Exponent_t *)omAlloc0(ExpSize);
     
    342342       p_Setm(Pn,r);
    343343       p_Test(Pn,r);
    344        
     344
    345345//       if (pNext(D)==0)
    346346// is D a monomial? could be postponed higher
     
    350350//       else
    351351//       {
    352        Rout=nc_p_Mult_mm(D,Pn,r); 
     352       Rout=nc_p_Mult_mm(D,Pn,r);
    353353//       }
    354354     }
     
    358358       D=NULL;
    359359     }
    360      
     360
    361361     if (Rout!=NULL)
    362362     {
     
    405405  int i;
    406406  number num=NULL;
    407  
     407
    408408  int iF=r->N;
    409409  while ((F[iF]==0)&&(iF>0)) iF-- ;   /* last exponent_num of F */
     
    434434   return(out);
    435435  }
    436  
     436
    437437  Exponent_t *Prv=(Exponent_t*)omAlloc0((r->N+1)*sizeof(Exponent_t));
    438438  Exponent_t *Nxt=(Exponent_t*)omAlloc0((r->N+1)*sizeof(Exponent_t));
     
    484484  number *c=(number *)omAlloc0((cnt+2)*sizeof(number));
    485485  c[cnt+1]=n_Init(1,r);
    486   i=cnt+2;      /* later in freeN */
     486  i=cnt+2;         /* later in freeN */
    487487  Exponent_t *Op=Nxt;
    488488  Exponent_t *On=(Exponent_t *)omAlloc0((r->N+1)*sizeof(Exponent_t));
     
    525525       kk=lF[cnt+1];
    526526       On[kk]=F[kk];
    527        
     527
    528528       Pn=pOne();
    529529       p_SetExpV(Pn,On,r);
     
    597597  poly out=pOne();
    598598  number tmp_number=NULL;
    599  
     599
    600600  /* Now check zero exeptions, commutativity and should we do something at all?  */
    601601  if (i==j)
     
    610610  p_Setm(out,r);
    611611  if ((a==0)||(b==0)||(i<=j)) return(out);/* zero exeptions and usual case */
    612  
     612
    613613  if (MATELEM(r->nc->COM,j,i)!=NULL)
    614614    /* commutative or quasicommutative case */
     
    617617    {
    618618      return(out);
    619     }     
     619    }
    620620    else
    621621    {
     
    640640    return (out);
    641641  }
    642  
     642
    643643  /*  poly C=MATELEM(r->nc->C,j,i);               */
    644644  /*  number c=p_GetCoeff(C,r); //coeff           */
    645645  /*  p_Delete(&C,r); */
    646      
     646
    647647  int newcMTsize=0;
    648648  int k,m;
     
    653653     newcMTsize = newcMTsize+cMTsize;
    654654     matrix tmp = mpNew(newcMTsize,newcMTsize);
    655      
     655
    656656     for (k=1;k<=cMTsize;k++)
    657657     {
     
    659659        {
    660660           MATELEM(tmp,k,m) = MATELEM(r->nc->MT[UPMATELEM(j,i,r->N)],k,m);
    661            //      omCheckAddr(tmp->m);
     661           //           omCheckAddr(tmp->m);
    662662           MATELEM(r->nc->MT[UPMATELEM(j,i,r->N)],k,m)=NULL;
    663            //      omCheckAddr(r->nc->MT[UPMATELEM(j,i,r->N)]->m);
     663           //           omCheckAddr(r->nc->MT[UPMATELEM(j,i,r->N)]->m);
    664664        }
    665665     }
     
    673673  poly x=pOne();p_SetExp(x,j,1,r);p_Setm(x,r);p_Test(x,r);/* var(j); */
    674674  poly y=pOne();p_SetExp(y,i,1,r);p_Setm(y,r);p_Test(y,r);/*var(i);  for convenience */
    675  
     675
    676676  poly t=NULL;
    677677/* ------------ Main Cycles ----------------------------*/
     
    686686        t = nc_mm_Mult_p(y,t,r);
    687687        MATELEM(cMT,k,1) = t;
    688         //      omCheckAddr(cMT->m);
     688        //        omCheckAddr(cMT->m);
    689689     }
    690690     t=NULL;
    691691  }
    692  
     692
    693693  for (m=2;m<=b;m++)
    694694  {
     
    699699        t = nc_p_Mult_mm(t,x,r);
    700700        MATELEM(cMT,a,m) = t;
    701         //      omCheckAddr(cMT->m);
     701        //        omCheckAddr(cMT->m);
    702702     }
    703703     t=NULL;
     
    725725  }/* zero exeptions and usual case */
    726726  /*  if ((a==0)||(b==0)||(i<=j)) return(out); */
    727  
     727
    728728  if (MATELEM(r->nc->COM,j,i)!=NULL)
    729729    /* commutative or quasicommutative case */
     
    732732    {
    733733      return(out);
    734     }     
     734    }
    735735    else
    736736    {
     
    760760    }
    761761  }
    762   int k,m;   
     762  int k,m;
    763763  if (newcMTsize > cMTsize)
    764764  {
     
    785785    //    matrix tmp = (matrix)omAlloc0(inM*inM*sizeof(poly));
    786786    matrix tmp = mpNew(newcMTsize,newcMTsize);
    787      
     787
    788788    for (k=1;k<=cMTsize;k++)
    789789    {
    790790      for (m=1;m<=cMTsize;m++)
    791791      {
    792         if ( MATELEM(r->nc->MT[UPMATELEM(j,i,r->N)],k,m) != NULL )
    793         {
    794           MATELEM(tmp,k,m) = MATELEM(r->nc->MT[UPMATELEM(j,i,r->N)],k,m);
    795           //       omCheckAddr(tmp->m);
    796           MATELEM(r->nc->MT[UPMATELEM(j,i,r->N)],k,m)=NULL;
    797           //       omCheckAddr(r->nc->MT[UPMATELEM(j,i,r->N)]->m);
    798         }
     792        if ( MATELEM(r->nc->MT[UPMATELEM(j,i,r->N)],k,m) != NULL )
     793        {
     794          MATELEM(tmp,k,m) = MATELEM(r->nc->MT[UPMATELEM(j,i,r->N)],k,m);
     795          //           omCheckAddr(tmp->m);
     796          MATELEM(r->nc->MT[UPMATELEM(j,i,r->N)],k,m)=NULL;
     797          //           omCheckAddr(r->nc->MT[UPMATELEM(j,i,r->N)]->m);
     798        }
    799799      }
    800800    }
     
    809809  poly x=pOne();p_SetExp(x,j,1,r);p_Setm(x,r);p_Test(x,r); /* var(j); */
    810810  poly y=pOne();p_SetExp(y,i,1,r);p_Setm(y,r);p_Test(y,r); /*var(i);  for convenience */
    811  
     811
    812812  poly t=NULL;
    813813
     
    824824      if (t==NULL)   /* remove after debug */
    825825      {
    826         t = p_Copy(MATELEM(cMT,1,m-1),r);
    827         t = nc_p_Mult_mm(t,x,r);
    828         MATELEM(cMT,1,m) = t;
    829         /*      omCheckAddr(cMT->m); */
     826        t = p_Copy(MATELEM(cMT,1,m-1),r);
     827        t = nc_p_Mult_mm(t,x,r);
     828        MATELEM(cMT,1,m) = t;
     829        /*        omCheckAddr(cMT->m); */
    830830      }
    831831      else
    832       {   
    833         /* Error, should never get there */
    834         WarnS("Error: a=1; MATELEM!=0");
     832      {
     833        /* Error, should never get there */
     834        WarnS("Error: a=1; MATELEM!=0");
    835835      }
    836836      t=NULL;
     
    848848      if (t==NULL)   /* remove after debug */
    849849      {
    850         t = p_Copy(MATELEM(cMT,m-1,1),r);
    851         t = nc_mm_Mult_p(y,t,r);
    852         MATELEM(cMT,m,1) = t;
    853         /*      omCheckAddr(cMT->m); */
     850        t = p_Copy(MATELEM(cMT,m-1,1),r);
     851        t = nc_mm_Mult_p(y,t,r);
     852        MATELEM(cMT,m,1) = t;
     853        /*        omCheckAddr(cMT->m); */
    854854      }
    855855      else
    856       {   
    857         /* Error, should never get there */
    858         WarnS("Error: b=1, MATELEM!=0");
     856      {
     857        /* Error, should never get there */
     858        WarnS("Error: b=1, MATELEM!=0");
    859859      }
    860860      t=NULL;
     
    870870  /* dYX = distance for computing y-mult, then x-mult */
    871871  int toX=a-1; int toY=b-1; /* toX = to axe X, toY = to axe Y */
    872   toXY=b-1; toYX=a-1; 
     872  toXY=b-1; toYX=a-1;
    873873  /* if toX==0, toXY = dist. to computed y * x^toXY */
    874874  /* if toY==0, toYX = dist. to computed y^toYX * x */
     
    890890  }
    891891  dYX=dYX+b-toY; /* the distance to nearest computed y^a x^toY */
    892  
     892
    893893  if (dYX>=dXY)
    894894  {
     
    898898      for (m=toXY+1;m<=b;m++)
    899899      {
    900         t=MATELEM(cMT,1,m);
    901         if (t==NULL)   /* remove after debug */
    902         {
    903           t = p_Copy(MATELEM(cMT,1,m-1),r);
    904           t = nc_p_Mult_mm(t,x,r);
    905           MATELEM(cMT,1,m) = t;
    906           /*    omCheckAddr(cMT->m); */
    907         }
    908         else
    909         {         
    910           /* Error, should never get there */
    911           WarnS("dYX>=dXY,toXY; MATELEM==0");
    912         }
    913         t=NULL;
     900        t=MATELEM(cMT,1,m);
     901        if (t==NULL)   /* remove after debug */
     902        {
     903          t = p_Copy(MATELEM(cMT,1,m-1),r);
     904          t = nc_p_Mult_mm(t,x,r);
     905          MATELEM(cMT,1,m) = t;
     906          /*        omCheckAddr(cMT->m); */
     907        }
     908        else
     909        {
     910          /* Error, should never get there */
     911          WarnS("dYX>=dXY,toXY; MATELEM==0");
     912        }
     913        t=NULL;
    914914      }
    915915      toX=1; /* y*x^b is computed */
     
    924924        t = nc_mm_Mult_p(y,t,r);
    925925        MATELEM(cMT,k,b) = t;
    926         /*      omCheckAddr(cMT->m); */
     926        /*        omCheckAddr(cMT->m); */
    927927      }
    928928      else
    929929      {
    930         /* Error, should never get there */
    931         WarnS("dYX>=dXY,toX; MATELEM==0");
     930        /* Error, should never get there */
     931        WarnS("dYX>=dXY,toX; MATELEM==0");
    932932      }
    933933      t=NULL;
     
    943943      for (m=toYX+1;m<=a;m++)
    944944      {
    945         t=MATELEM(cMT,m,1);
    946         if (t==NULL)   /* remove after debug */
    947         {
    948           t = p_Copy(MATELEM(cMT,m-1,1),r);
    949           t = nc_mm_Mult_p(y,t,r);
    950           MATELEM(cMT,m,1) = t;
    951           /*    omCheckAddr(cMT->m); */
    952         }
    953         else
    954         {         
    955           /* Error, should never get there */
    956           WarnS("dYX<dXY,toYX; MATELEM==0");
    957         }
    958         t=NULL;
     945        t=MATELEM(cMT,m,1);
     946        if (t==NULL)   /* remove after debug */
     947        {
     948          t = p_Copy(MATELEM(cMT,m-1,1),r);
     949          t = nc_mm_Mult_p(y,t,r);
     950          MATELEM(cMT,m,1) = t;
     951          /*        omCheckAddr(cMT->m); */
     952        }
     953        else
     954        {
     955          /* Error, should never get there */
     956          WarnS("dYX<dXY,toYX; MATELEM==0");
     957        }
     958        t=NULL;
    959959      }
    960960      toY=1; /* y^a*x is computed */
     
    969969        t = nc_p_Mult_mm(t,x,r);
    970970        MATELEM(cMT,a,k) = t;
    971         /*      omCheckAddr(cMT->m); */
     971        /*        omCheckAddr(cMT->m); */
    972972      }
    973973      else
    974974      {
    975         /* Error, should never get there */
    976         WarnS("dYX<dXY,toY; MATELEM==0");
     975        /* Error, should never get there */
     976        WarnS("dYX<dXY,toY; MATELEM==0");
    977977      }
    978978      t=NULL;
    979979    }
    980980  } /* endif (dYX<dXY) */
    981        
     981
    982982  p_Delete(&x,r);
    983983  p_Delete(&y,r);
     
    999999  if (p_GetComp(p1,r)!=p_GetComp(p2,r))
    10001000  {
    1001     Print("nc_spGSpolyRed: different components");   
     1001    Print("nc_spGSpolyRed: different components");
    10021002    return(NULL);
    10031003  }
    10041004  poly m=pOne();
    10051005  p_ExpVectorDiff(m,p2,p1,r);
    1006   p_Setm(m,r); 
     1006  p_Setm(m,r);
    10071007  p_Test(m,r);
    10081008  /* pSetComp(m,r)=0? */
     
    10141014  N=p_Add_q(N,out,r);
    10151015  number MinusOne=n_Init(-1,r);
    1016   if (!n_Equal(cF,MinusOne,r)) 
     1016  if (!n_Equal(cF,MinusOne,r))
    10171017  {
    10181018    cF=n_Neg(cF,r);
     
    10461046  if (p_GetComp(p1,r)!=p_GetComp(p2,r))
    10471047  {
    1048     Print("nc_spGSpolyCreate : different components!");   
     1048    Print("nc_spGSpolyCreate : different components!");
    10491049    return(NULL);
    10501050  }
     
    11121112  poly Q=pNext(q2);
    11131113  number cQ=p_GetCoeff(Q,r);
    1114   poly m=pOne(); 
     1114  poly m=pOne();
    11151115  p_ExpVectorDiff(m,Q,p1,r);
    1116   p_Setm(m,r); 
     1116  p_Setm(m,r);
    11171117  p_Test(m,r);
    11181118  /* pSetComp(m,r)=0? */
     
    11251125  {
    11261126    cQ=nNeg(cQ);
    1127     M=p_Mult_nn(M,cQ,r);   
     1127    M=p_Mult_nn(M,cQ,r);
    11281128  }
    11291129  Q=p_Add_q(Q,M,r);
     
    11701170  if (!nEqual(n,MinusOne))
    11711171  {
    1172     nn=nNeg(nInvers(n));   
     1172    nn=nNeg(nInvers(n));
    11731173  }
    11741174  else nn=nInit(1);
     
    12001200  if (!nEqual(n,MinusOne))
    12011201  {
    1202     nn=nNeg(nInvers(n));   
     1202    nn=nNeg(nInvers(n));
    12031203  }
    12041204  else nn=nInit(1);
     
    12281228    {
    12291229      pres=nc_mm_Bracket_nn(p,Q); /* since no coeffs are taken into account there */
    1230       if (pres!=NULL) 
    1231       {
    1232         coef=nMult(pGetCoeff(p),pGetCoeff(Q));
    1233         if (!nIsOne(coef)) pres=p_Mult_nn(pres,coef,currRing);
    1234         res=p_Add_q(res,pres,currRing);
     1230      if (pres!=NULL)
     1231      {
     1232        coef=nMult(pGetCoeff(p),pGetCoeff(Q));
     1233        if (!nIsOne(coef)) pres=p_Mult_nn(pres,coef,currRing);
     1234        res=p_Add_q(res,pres,currRing);
    12351235        nDelete(&coef);
    12361236      }
     
    12701270      for (j=1;j<=currRing->N;j++)
    12711271      {
    1272         if (M1[j]!=0)
    1273         {
    1274           bres=NULL;
    1275           /* compute [ x_j^M1[j],x_i^M2[i] ] */
    1276           if (i<j) {nMax=j;  nMin=i;} else {nMax=i;  nMin=j;}
    1277           if ( (i==j) || ((MATELEM(currRing->nc->COM,nMin,nMax)!=NULL) && nIsOne(pGetCoeff(MATELEM(currRing->nc->C,nMin,nMax))) )) /* not (the same exp. or commuting exps)*/
    1278           { bres=NULL; }
    1279           else
    1280           {
    1281             if (i<j) { bres=nc_uu_Mult_ww(j,M1[j],i,M2[i],currRing); }
    1282             else bres=nc_uu_Mult_ww(i,M2[i],j,M1[j],currRing);
    1283             if (nIsOne(pGetCoeff(bres)))
    1284             {
    1285               bres=pLmDeleteAndNext(bres);
    1286             }
    1287             else
    1288             {
    1289               nTmp=nInit(1);
    1290               nTmp=nSub(pGetCoeff(bres),nTmp);
    1291               pSetCoeff(bres,nTmp); /* only lc ! */
    1292             }
    1293             pTest(bres);
    1294             if (i>j)  bres=p_Mult_nn(bres, MinusOne,currRing);
    1295           }
    1296           if (bres!=NULL)
    1297           {
    1298             /* now mult (prefix, bres, suffix) */
    1299             memcpy(SUFFIX, M1,(currRing->N+1)*sizeof(Exponent_t));
    1300             memcpy(PREFIX, M1,(currRing->N+1)*sizeof(Exponent_t));
    1301             for (k=1;k<=j;k++) SUFFIX[k]=0;
    1302             for (k=j;k<=currRing->N;k++) PREFIX[k]=0;
    1303             SUFFIX[0]=0;
    1304             PREFIX[0]=0;
    1305             prefix=pOne();
    1306             suffix=pOne();
    1307             pSetExpV(prefix,PREFIX);
    1308             pSetm(prefix);
    1309             pSetExpV(suffix,SUFFIX);
    1310             pSetm(suffix);
    1311             if (!pLmIsConstant(prefix)) bres = nc_mm_Mult_p(prefix, bres,currRing);
    1312             if (!pLmIsConstant(suffix)) bres = nc_p_Mult_mm(bres, suffix,currRing);
    1313             ares=p_Add_q(ares, bres,currRing);
    1314             /* What to give free? */
    1315             pDelete(&prefix);
    1316             pDelete(&suffix);
    1317           }
    1318         }
     1272        if (M1[j]!=0)
     1273        {
     1274          bres=NULL;
     1275          /* compute [ x_j^M1[j],x_i^M2[i] ] */
     1276          if (i<j) {nMax=j;  nMin=i;} else {nMax=i;  nMin=j;}
     1277          if ( (i==j) || ((MATELEM(currRing->nc->COM,nMin,nMax)!=NULL) && nIsOne(pGetCoeff(MATELEM(currRing->nc->C,nMin,nMax))) )) /* not (the same exp. or commuting exps)*/
     1278          { bres=NULL; }
     1279          else
     1280          {
     1281            if (i<j) { bres=nc_uu_Mult_ww(j,M1[j],i,M2[i],currRing); }
     1282            else bres=nc_uu_Mult_ww(i,M2[i],j,M1[j],currRing);
     1283            if (nIsOne(pGetCoeff(bres)))
     1284            {
     1285              bres=pLmDeleteAndNext(bres);
     1286            }
     1287            else
     1288            {
     1289              nTmp=nInit(1);
     1290              nTmp=nSub(pGetCoeff(bres),nTmp);
     1291              pSetCoeff(bres,nTmp); /* only lc ! */
     1292            }
     1293            pTest(bres);
     1294            if (i>j)  bres=p_Mult_nn(bres, MinusOne,currRing);
     1295          }
     1296          if (bres!=NULL)
     1297          {
     1298            /* now mult (prefix, bres, suffix) */
     1299            memcpy(SUFFIX, M1,(currRing->N+1)*sizeof(Exponent_t));
     1300            memcpy(PREFIX, M1,(currRing->N+1)*sizeof(Exponent_t));
     1301            for (k=1;k<=j;k++) SUFFIX[k]=0;
     1302            for (k=j;k<=currRing->N;k++) PREFIX[k]=0;
     1303            SUFFIX[0]=0;
     1304            PREFIX[0]=0;
     1305            prefix=pOne();
     1306            suffix=pOne();
     1307            pSetExpV(prefix,PREFIX);
     1308            pSetm(prefix);
     1309            pSetExpV(suffix,SUFFIX);
     1310            pSetm(suffix);
     1311            if (!pLmIsConstant(prefix)) bres = nc_mm_Mult_p(prefix, bres,currRing);
     1312            if (!pLmIsConstant(suffix)) bres = nc_p_Mult_mm(bres, suffix,currRing);
     1313            ares=p_Add_q(ares, bres,currRing);
     1314            /* What to give free? */
     1315            pDelete(&prefix);
     1316            pDelete(&suffix);
     1317          }
     1318        }
    13191319      }
    13201320      if (ares!=NULL)
    13211321      {
    1322         /* now mult (prefix, bres, suffix) */
    1323         memcpy(SUFFIX, M2,(currRing->N+1)*sizeof(Exponent_t));
    1324         memcpy(PREFIX, M2,(currRing->N+1)*sizeof(Exponent_t));
    1325         for (k=1;k<=i;k++) SUFFIX[k]=0;
    1326         for (k=i;k<=currRing->N;k++) PREFIX[k]=0;
    1327         SUFFIX[0]=0;
    1328         PREFIX[0]=0;
    1329         prefix=pOne();
    1330         suffix=pOne();
    1331         pSetExpV(prefix,PREFIX);
    1332         pSetm(prefix);
    1333         pSetExpV(suffix,SUFFIX);
    1334         pSetm(suffix);
    1335         bres=ares;
    1336         if (!pLmIsConstant(prefix)) bres = nc_mm_Mult_p(prefix, bres,currRing);
    1337         if (!pLmIsConstant(suffix)) bres = nc_p_Mult_mm(bres, suffix,currRing);
    1338         res=p_Add_q(res, bres,currRing);
    1339         pDelete(&prefix);
    1340         pDelete(&suffix);
     1322        /* now mult (prefix, bres, suffix) */
     1323        memcpy(SUFFIX, M2,(currRing->N+1)*sizeof(Exponent_t));
     1324        memcpy(PREFIX, M2,(currRing->N+1)*sizeof(Exponent_t));
     1325        for (k=1;k<=i;k++) SUFFIX[k]=0;
     1326        for (k=i;k<=currRing->N;k++) PREFIX[k]=0;
     1327        SUFFIX[0]=0;
     1328        PREFIX[0]=0;
     1329        prefix=pOne();
     1330        suffix=pOne();
     1331        pSetExpV(prefix,PREFIX);
     1332        pSetm(prefix);
     1333        pSetExpV(suffix,SUFFIX);
     1334        pSetm(suffix);
     1335        bres=ares;
     1336        if (!pLmIsConstant(prefix)) bres = nc_mm_Mult_p(prefix, bres,currRing);
     1337        if (!pLmIsConstant(suffix)) bres = nc_p_Mult_mm(bres, suffix,currRing);
     1338        res=p_Add_q(res, bres,currRing);
     1339        pDelete(&prefix);
     1340        pDelete(&suffix);
    13411341      }
    13421342    }
     
    13511351ideal twostd(ideal I)
    13521352{
    1353   int i; 
    1354   int j; 
    1355   int s; 
     1353  int i;
     1354  int j;
     1355  int s;
    13561356  int flag;
    13571357  poly p=NULL;
     
    13741374      p=J->m[i];
    13751375      for (j=1;j<=currRing->N;j++)
    1376       {   
    1377         varj=pOne();
    1378         pSetExp(varj,j,1);
    1379         pSetm(varj);
    1380         q=nc_p_Mult_mm(pCopy(p),varj,currRing); 
    1381         pDelete(&varj);
    1382         q=nc_spGSpolyRed(p,q,NULL,currRing);
    1383         q = kNF(J,Quot,q,0,0);
     1376      {
     1377        varj=pOne();
     1378        pSetExp(varj,j,1);
     1379        pSetm(varj);
     1380        q=nc_p_Mult_mm(pCopy(p),varj,currRing);
     1381        pDelete(&varj);
     1382        q=nc_spGSpolyRed(p,q,NULL,currRing);
     1383        q = kNF(J,Quot,q,0,0);
    13841384        if (q!=NULL)
    13851385        {
    1386           if (pIsConstant(q))
    1387           {
    1388             Q=idInit(1,1);
    1389             Q->m[0]=pOne();
    1390             idDelete(&J);
    1391             pDelete(&q);
    1392             if (K!=NULL) idDelete(&K);
    1393             return(Q);
    1394           }
     1386          if (pIsConstant(q))
     1387          {
     1388            Q=idInit(1,1);
     1389            Q->m[0]=pOne();
     1390            idDelete(&J);
     1391            pDelete(&q);
     1392            if (K!=NULL) idDelete(&K);
     1393            return(Q);
     1394          }
    13951395          flag=1;
    1396           Q=idInit(1,1);
    1397           Q->m[0]=q;
    1398           id_tmp=idSimpleAdd(K,Q);
    1399           idDelete(&K);
    1400           K=id_tmp;
    1401           idDelete(&Q);   
    1402         }   
    1403       }
    1404     }
    1405     if (flag==0) 
     1396          Q=idInit(1,1);
     1397          Q->m[0]=q;
     1398          id_tmp=idSimpleAdd(K,Q);
     1399          idDelete(&K);
     1400          K=id_tmp;
     1401          idDelete(&Q);
     1402        }
     1403      }
     1404    }
     1405    if (flag==0)
    14061406      /* i.e. all elements are two-sided */
    14071407    {
    14081408      idDelete(&K);
    1409       return(J); 
     1409      return(J);
    14101410    }
    14111411    id_tmp=idAdd(J,K);
     
    14211421  /* returns matrix with the info on noncomm multiplication */
    14221422{
    1423  
     1423
    14241424  if ( (a==b) || !rIsPluralRing(r) ) return(NULL);
    14251425  int i;
     
    14521452      p=MATELEM(M,s,t);
    14531453      if (p==NULL)
    1454       { 
    1455         MATELEM(res,s,t)=0;
     1454      {
     1455        MATELEM(res,s,t)=0;
    14561456      }
    14571457      else
    14581458      {
    1459         length = pLength(p);
    1460         if (metric==0) /* length */
    1461         {       
    1462           MATELEM(res,s,t)= p_ISet(length,r);
    1463         }
    1464         else if (metric==1) /* sum of deg divided by the length */
    1465         {
    1466           totdeg=0;
    1467           while (p!=NULL)
    1468           {
    1469             totdeg=totdeg+pDeg(p,r);
    1470             pIter(p);
    1471           }
    1472           number ntd = nInit(totdeg);
    1473           number nln = nInit(length);
    1474           number nres=nDiv(ntd,nln);
    1475           nDelete(&ntd);
    1476           nDelete(&nln);
    1477           MATELEM(res,s,t)=p_NSet(nres,r);       
    1478         }
     1459        length = pLength(p);
     1460        if (metric==0) /* length */
     1461        {
     1462          MATELEM(res,s,t)= p_ISet(length,r);
     1463        }
     1464        else if (metric==1) /* sum of deg divided by the length */
     1465        {
     1466          totdeg=0;
     1467          while (p!=NULL)
     1468          {
     1469            totdeg=totdeg+pDeg(p,r);
     1470            pIter(p);
     1471          }
     1472          number ntd = nInit(totdeg);
     1473          number nln = nInit(length);
     1474          number nres=nDiv(ntd,nln);
     1475          nDelete(&ntd);
     1476          nDelete(&nln);
     1477          MATELEM(res,s,t)=p_NSet(nres,r);
     1478        }
    14791479      }
    14801480    }
     
    14831483}
    14841484
     1485void ncKill(ring r)
     1486{
     1487  int i,j;
     1488  for(i=1;i<r->N;i++)
     1489  {
     1490    for(j=i+1;j<=r->N;j++)
     1491    {
     1492      id_Delete((ideal *)&(r->nc->MT[UPMATELEM(i,j,r->N)]),r);
     1493    }
     1494  }
     1495  omFreeSize((ADDRESS)r->nc->MT,r->N*(r->N-1)/2*sizeof(matrix));
     1496  omFreeSize((ADDRESS)r->nc->MTsize,r->N*(r->N-1)/2*sizeof(int));
     1497  id_Delete((ideal *)&(r->nc->C),r);
     1498  id_Delete((ideal *)&(r->nc->D),r);
     1499  id_Delete((ideal *)&(r->nc->COM),r);
     1500  omFreeSize((ADDRESS)r->nc,sizeof(nc_struct));
     1501  r->nc=NULL;
     1502}
     1503
    14851504#endif
  • Singular/gring.h

    r18e9f2f raf42ca  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: gring.h,v 1.15 2003-01-29 16:04:18 levandov Exp $ */
     6/* $Id: gring.h,v 1.16 2003-01-29 16:13:11 Singular Exp $ */
    77/*
    88* ABSTRACT additional defines etc for --with-plural
     
    1111#ifdef HAVE_PLURAL
    1212#include "structs.h"
     13
     14void ncKill(ring r);
    1315
    1416#define UPMATELEM(i,j,nVar) ( (nVar * ((i)-1) - ((i) * ((i)-1))/2 + (j)-1)-(i) )
  • Singular/structs.h

    r18e9f2f raf42ca  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: structs.h,v 1.67 2002-11-26 13:54:44 Singular Exp $ */
     6/* $Id: structs.h,v 1.68 2003-01-29 16:13:10 Singular Exp $ */
    77/*
    88* ABSTRACT
     
    352352struct nc_struct
    353353{
     354  short ref;
    354355  nc_type type;
    355356  matrix C;
Note: See TracChangeset for help on using the changeset viewer.