Changeset ea68ed in git


Ignore:
Timestamp:
Apr 21, 2005, 6:16:47 PM (19 years ago)
Author:
Viktor Levandovskyy <levandov@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '98550b669234b32be762076c32b3be2c35188ac4')
Children:
8c8c809bf53ba83e18c7c2ebd0c767279e305509
Parents:
eeb1337dbd6e03efdc6f0d3d5aa17c7b2655e1b9
Message:
*levandov: changes, related to the ordering check during elimination and minor fixes


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

Legend:

Unmodified
Added
Removed
  • kernel/gring.cc

    reeb133 rea68ed  
    77 *  Author:  levandov (Viktor Levandovsky)
    88 *  Created: 8/00 - 11/00
    9  *  Version: $Id: gring.cc,v 1.21 2005-02-11 20:19:46 levandov Exp $
     9 *  Version: $Id: gring.cc,v 1.22 2005-04-21 16:16:45 levandov Exp $
    1010 *******************************************************************/
    1111#include "mod2.h"
     
    137137      {
    138138        /* REPORT_ERROR */
     139#ifdef PDEBUG
    139140        const char* s;
    140141        if (side==1) s="nc_p_Mult_mm";
    141142        else s="nc_mm_Mult_p";
    142143        Print("%s: exponent mismatch %d and %d\n",s,expP,expM);
     144#endif
    143145        expOut=0;
    144146      }
     
    12101212  if (p_GetComp(p1,r)!=p_GetComp(p2,r))
    12111213  {
     1214#ifdef PDEBUG
    12121215    Print("spShort:exponent mismatch!");
     1216#endif
    12131217    return(NULL);
    12141218  }
     
    15951599  id_Delete((ideal *)&(r->nc->C),r->nc->basering);
    15961600  id_Delete((ideal *)&(r->nc->D),r->nc->basering);
     1601  r->nc->basering->ref--;
     1602  if (r->nc->basering<=0)
     1603  {
     1604    rKill(r->nc->basering);
     1605  }
    15971606  omFreeSize((ADDRESS)r->nc,sizeof(nc_struct));
    15981607  r->nc=NULL;
     
    16131622  else
    16141623  {
    1615     //    nFunc nMap = nSetMap();
    16161624    return(prCopyR_NoSort(a,r->nc->basering,r));
    16171625  }
     
    16301638
    16311639int nc_CheckSubalgebra(poly PolyVar, ring r)
    1632   /* returns TRUE if product of vars from PolyVar defines */
     1640  /* returns TRUE if there were errors */
     1641  /* checks whether product of vars from PolyVar defines */
    16331642  /* an admissible subalgebra of r */
    1634 {
     1643  /* r is indeed currRing */
     1644{
     1645  ring save = currRing;
     1646  int WeChangeRing = 0;
     1647  if (currRing != r)
     1648  {
     1649    rChangeCurrRing(r);
     1650    WeChangeRing = 1;
     1651  }
    16351652  int rN=r->N;
    16361653  int *ExpVar=(int*)omAlloc0((rN+1)*sizeof(int));
     
    16401657  poly test=NULL;
    16411658  int OK=1;
    1642   for (i=1;i<rN;i++)
     1659  for (i=1; i<rN; i++)
    16431660  {
    16441661    if (ExpVar[i]==0) /* i.e. not in PolyVar */
    16451662    { 
    1646       for (j=i+1;j<=rN;j++)
     1663      for (j=i+1; j<=rN; j++)
    16471664      {
    16481665        if (ExpVar[j]==0)
    16491666        {
    1650           test=nc_p_CopyGet(MATELEM(r->nc->D,i,j),r);
     1667          test = nc_p_CopyGet(MATELEM(r->nc->D,i,j),r);
    16511668          while (test!=NULL)
    16521669          {
     
    16601677              }
    16611678            }
    1662             if (!OK) return(FALSE);
     1679            if (!OK) return(TRUE);
    16631680            pIter(test);
    16641681          }
     
    16701687  freeT(ExpVar,rN);
    16711688  freeT(ExpTmp,rN);
    1672   return(TRUE);
    1673 }
    1674 
    1675 // int Commutative_Context(ring r, leftv expression)
    1676 //   /* returns 1 if expression consists */
    1677 //   /*  of commutative elements */
    1678 // {
    1679 //   /* crucial: poly -> ideal, module, matrix  */
    1680  
    1681 // }
    1682 
    1683 // int Comm_Context_Poly(ring r, poly p)
    1684 // {
    1685 //   poly COMM=r->nc->COMM;
    1686 //   poly pp=pOne();
    1687 //   memset(pp->exp,0,r->ExpL_Size*sizeof(long));
    1688 //   while (p!=NULL)
    1689 //   {
    1690 //     for (i=0;i<=r->ExpL_Size;i++)
    1691 //     {
    1692 //       if ((p->exp[i]) && (pp->exp[i]))  return(FALSE);
    1693 //       /* nonzero exponent of non-comm variable */
    1694 //     }
    1695 //     pIter(p);
    1696 //   }
    1697 //   return(TRUE);
    1698 // }
     1689  if ( WeChangeRing )
     1690    rChangeCurrRing(save);
     1691  return(FALSE);
     1692}
     1693
     1694int nc_CheckOrdCondition(matrix D, ring r)
     1695/* returns TRUE if there were errors */
     1696/* checks whether the current ordering */
     1697/* is admissible for r and D == r->nc->D */
     1698/* to be executed in a currRing */
     1699{
     1700  /* analyze D: an upper triangular matrix of polys */
     1701  /* check the ordering condition for D */
     1702  ring save = currRing;
     1703  int WeChangeRing = 0;
     1704  if (currRing != r)
     1705  {
     1706    rChangeCurrRing(r);
     1707    WeChangeRing = 1;
     1708  }
     1709  poly p,q;
     1710  int i,j;
     1711  int report = 1;
     1712  for(i=1; i<r->N; i++)
     1713  {
     1714    for(j=i+1; j<=r->N; j++)
     1715    {
     1716      p = nc_p_CopyGet(MATELEM(D,i,j),r);
     1717      if ( p != NULL)
     1718      {
     1719        q = p_ISet(1,r); // replaces pOne();
     1720        p_SetExp(q,i,1,r);
     1721        p_SetExp(q,j,1,r);
     1722        p_Setm(q,r);
     1723        if (p_LmCmp(q,p,r) != 1) /* i.e. lm(p)< lm(q)  */
     1724        {
     1725          Print("Bad ordering at %d,%d\n",i,j);
     1726#ifdef PDEBUG
     1727          p_Write(p,r);
     1728          p_Write(q,r);
     1729#endif
     1730          report = 0;
     1731        }
     1732        p_Delete(&q,r);
     1733        p_Delete(&p,r);
     1734        p = NULL;
     1735      }
     1736    }
     1737  }
     1738  if ( WeChangeRing )
     1739    rChangeCurrRing(save);
     1740  return(!report);
     1741}
     1742
     1743
    16991744
    17001745BOOLEAN nc_CallPlural(matrix CCC, matrix DDD, poly CCN, poly DDN, ring r)
     
    17251770    }
    17261771  }
     1772  ring save = currRing;
     1773  int WeChangeRing = 0;
     1774  if (currRing!=r)
     1775  {
     1776    rChangeCurrRing(r);
     1777    WeChangeRing = 1;
     1778  }
    17271779  r->nc = (nc_struct *)omAlloc0(sizeof(nc_struct));
    17281780  r->nc->ref = 1;
    17291781  r->nc->basering = r;
     1782  r->ref++;
    17301783  r->nc->type = nc_undef;
    17311784
     
    17431796      Werror("Square %d x %d  matrix expected",r->N,r->N);
    17441797      ncCleanUp(r);
     1798      if (WeChangeRing)
     1799        rChangeCurrRing(save);
    17451800      return TRUE;
    17461801    }
     
    17621817      Werror("Square %d x %d  matrix expected",r->N,r->N);
    17631818      ncCleanUp(r);
     1819      if (WeChangeRing)
     1820        rChangeCurrRing(save);
    17641821      return TRUE;
    17651822    }
     
    17771834      Werror("Incorrect input : zero coefficients are not allowed");
    17781835      ncCleanUp(r);
     1836      if (WeChangeRing)
     1837        rChangeCurrRing(save);
    17791838      return TRUE;
    17801839    }
     
    18191878          Werror("Incorrect input : matrix of coefficients contains zeros in the upper triangle");
    18201879          ncCleanUp(r);
     1880          if (WeChangeRing)
     1881            rChangeCurrRing(save);
    18211882          return TRUE;
    18221883        }
     
    18681929  /* analyze D */
    18691930  /* check the ordering condition for D (both matrix and poly cases) */
    1870   poly p,q;
    1871   int report = 1;
    1872   for(i=1; i<r->N; i++)
    1873   {
    1874     for(j=i+1; j<=r->N; j++)
    1875     {
    1876       p = MATELEM(D,i,j);
    1877       if ( p != NULL)
    1878       {
    1879         q = p_ISet(1,r); // replaces pOne();
    1880         p_SetExp(q,i,1,r);
    1881         p_SetExp(q,j,1,r);
    1882         p_Setm(q,r);
    1883         if (p_LmCmp(q,p,r) != 1) /* i.e. lm(p)<=lm(q)  */
    1884         {
    1885           Print("Bad ordering at %d,%d",i,j);
    1886           report = 0;
    1887         }
    1888         p_Delete(&q,r);
    1889         p = NULL;
    1890       }
    1891     }
    1892   }
    1893   if (!report)
    1894   {
     1931
     1932  if ( nc_CheckOrdCondition(D, r) )
     1933  {
     1934    ncCleanUp(r);
     1935    if (WeChangeRing)
     1936      rChangeCurrRing(save);
    18951937    Werror("Matrix of polynomials violates the ordering condition");
    1896     ncCleanUp(r);
    18971938    return TRUE;
    18981939  }
    18991940  r->nc->C = C;
    19001941  r->nc->D = D;
     1942  if (WeChangeRing)
     1943    rChangeCurrRing(save);
    19011944  return nc_InitMultiplication(r);
    19021945}
     
    20162059      pSetExpV(pre,PRE);
    20172060      pSetm(pre);
    2018       pSetComp(pre,PRE[0]);
    20192061      res = nc_mm_Mult_p(pre,res,currRing);
    20202062      /* multiply with suffix */
     
    20222064      pSetExpV(suf,SUF);
    20232065      pSetm(suf);
    2024       pSetComp(suf,PRE[0]);
    20252066      res = nc_p_Mult_mm(res,suf,currRing);
    20262067      res = p_Mult_nn(res,C,currRing);
     2068      pSetComp(res,PRE[0]);
    20272069    }
    20282070    else /* pow==0 */
     
    24102452
    24112453#endif
     2454
     2455
     2456// int Commutative_Context(ring r, leftv expression)
     2457//   /* returns 1 if expression consists */
     2458//   /*  of commutative elements */
     2459// {
     2460//   /* crucial: poly -> ideal, module, matrix  */
     2461// }
     2462
     2463// int Comm_Context_Poly(ring r, poly p)
     2464// {
     2465//   poly COMM=r->nc->COMM;
     2466//   poly pp=pOne();
     2467//   memset(pp->exp,0,r->ExpL_Size*sizeof(long));
     2468//   while (p!=NULL)
     2469//   {
     2470//     for (i=0;i<=r->ExpL_Size;i++)
     2471//     {
     2472//       if ((p->exp[i]) && (pp->exp[i]))  return(FALSE);
     2473//       /* nonzero exponent of non-comm variable */
     2474//     }
     2475//     pIter(p);
     2476//   }
     2477//   return(TRUE);
     2478// }
  • kernel/gring.h

    reeb133 rea68ed  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: gring.h,v 1.9 2004-10-18 18:57:06 levandov Exp $ */
     6/* $Id: gring.h,v 1.10 2005-04-21 16:16:45 levandov Exp $ */
    77/*
    88* ABSTRACT additional defines etc for --with-plural
     
    1818/* the part, related to the interface */
    1919BOOLEAN nc_CallPlural(matrix CC, matrix DD, poly CN, poly DN, ring r);
     20int nc_CheckOrdCondition(matrix D, ring r);
     21int nc_CheckSubalgebra(poly PolyVar, ring r);
    2022BOOLEAN nc_InitMultiplication(ring r);
    2123BOOLEAN rIsLikeOpposite(ring rBase, ring rCandidate);
     
    8284matrix nc_PrintMat(int a, int b, ring r, int metric);
    8385
    84 int nc_CheckSubalgebra(poly PolyVar, ring r);
    85 
    8686poly p_CopyEmbed(poly p, ring srcRing, int shift, int par_shift);
    8787poly pOppose(ring Rop, poly p);
  • kernel/ideals.cc

    reeb133 rea68ed  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: ideals.cc,v 1.8 2005-03-17 14:13:02 Singular Exp $ */
     4/* $Id: ideals.cc,v 1.9 2005-04-21 16:16:46 levandov Exp $ */
    55/*
    66* ABSTRACT - all basic methods to manipulate ideals
     
    23762376    if (currRing->nc->type!=nc_skew)
    23772377    {
    2378       if (!nc_CheckSubalgebra(delVar,currRing))
     2378      if (nc_CheckSubalgebra(delVar,currRing))
    23792379      {
    23802380        WerrorS("no elimination is possible: subalgebra is not admissible");
     
    24252425  rComplete(&tmpR, 1);
    24262426
     2427#ifdef HAVE_PLURAL
     2428  // update nc structure on tmpR
     2429  // in particular, tests the admissibility of the ordering
     2430  if (nc_rComplete(origR, &tmpR))
     2431  {
     2432    WerrorS("no elimination is possible: subalgebra is not admissible");
     2433    // goto cleanup
     2434    omFree((ADDRESS)wv[0]);
     2435    omFreeSize((ADDRESS)wv,ordersize*sizeof(int**));
     2436    omFreeSize((ADDRESS)ord,ordersize*sizeof(int));
     2437    omFreeSize((ADDRESS)block0,ordersize*sizeof(int));
     2438    omFreeSize((ADDRESS)block1,ordersize*sizeof(int));
     2439    rUnComplete(&tmpR);
     2440    if (w!=NULL)
     2441      delete w;
     2442    return idCopy(h1);
     2443  }
     2444#endif
    24272445  // change into the new ring
    24282446  //pChangeRing(pVariables,currRing->OrdSgn,ord,block0,block1,wv);
    24292447  rChangeCurrRing(&tmpR);
     2448
    24302449  h = idInit(IDELEMS(h1),h1->rank);
    24312450  // fetch data from the old ring
  • kernel/ring.cc

    reeb133 rea68ed  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: ring.cc,v 1.31 2005-03-14 16:45:15 Singular Exp $ */
     4/* $Id: ring.cc,v 1.32 2005-04-21 16:16:46 levandov Exp $ */
    55
    66/*
     
    39153915  return Renv;
    39163916}
     3917
     3918BOOLEAN nc_rComplete(ring src, ring dest)
     3919/* returns TRUE is there were errors */
     3920/* dest is actualy equals src with the different ordering */
     3921/* we map src->nc correctly to dest->src */
     3922/* to be executed after rComplete, before rChangeCurrRing */
     3923
     3924{
     3925  if (!rIsPluralRing(src))
     3926    return FALSE;
     3927  int i,j;
     3928  int N = dest->N;
     3929  if (src->N != N)
     3930  {
     3931    WarnS("wrong nc_rComplete call");
     3932    return TRUE;
     3933  }
     3934//   ncKill(dest); // in order to init new
     3935//   if (nc_CallPlural(src->nc->C, src->nc->D, NULL, NULL, dest))
     3936//   {
     3937//     return TRUE;
     3938//   }
     3939//   else
     3940//     return FALSE;
     3941  //  if (dest->nc != NULL)
     3942  //    ncKill(dest);
     3943  //  dest->nc           = (nc_struct *)omAlloc0(sizeof(nc_struct));
     3944  //  dest->nc->ref      = 1;
     3945  //  dest->nc->basering = dest;
     3946  //  dest->nc->type     =  src->nc->type;
     3947  ring save = currRing;
     3948  int WeChangeRing = 0;
     3949  if (dest != currRing)
     3950  {
     3951    WeChangeRing = 1;
     3952    rChangeCurrRing(dest);
     3953  }
     3954  matrix C = mpNew(N,N);
     3955  matrix D = mpNew(N,N);
     3956  matrix C0 = src->nc->C;
     3957  matrix D0 = src->nc->D;
     3958  poly p = NULL;
     3959  number n = NULL;
     3960  for (i=1; i< N; i++)
     3961  {
     3962    for (j= i+1; j<= N; j++)
     3963    {
     3964      //      n = p_GetCoeff(MATELEM(C0,i,j), src);
     3965      //      p = pOne();
     3966      //      p_SetCoeff(p,n,dest);
     3967      //      MATELEM(C,i,j) = nc_p_CopyPut(p, dest);
     3968      p = prCopyR(MATELEM(C0,i,j), src, dest); // like in nc_p_CopyGet
     3969      MATELEM(C,i,j) = p; //nc_p_CopyPut(p, dest);
     3970      //      p_Delete(&p,dest);
     3971      p = NULL;
     3972      if (MATELEM(D0,i,j) != NULL)
     3973      {
     3974        p = prCopyR(MATELEM(D0,i,j), src, dest); // like in nc_p_CopyGet
     3975        MATELEM(D,i,j) = p; //nc_p_CopyPut(p, dest);
     3976        //      p_Delete(&p,dest);
     3977        p = NULL;
     3978      }
     3979    }
     3980  }
     3981  idTest((ideal)C);
     3982  idTest((ideal)D);
     3983  id_Delete((ideal *)&(dest->nc->C),dest->nc->basering);
     3984  id_Delete((ideal *)&(dest->nc->D),dest->nc->basering);
     3985  dest->nc->C = C;
     3986  dest->nc->D = D;
     3987  if ( WeChangeRing )
     3988    rChangeCurrRing(save);
     3989  if (nc_InitMultiplication(dest))
     3990  {
     3991    WarnS("Error initializing multiplication!");
     3992    return TRUE;
     3993  }
     3994  return FALSE;
     3995}
  • kernel/ring.h

    reeb133 rea68ed  
    77* ABSTRACT - the interpreter related ring operations
    88*/
    9 /* $Id: ring.h,v 1.6 2004-11-04 19:56:12 levandov Exp $ */
     9/* $Id: ring.h,v 1.7 2005-04-21 16:16:47 levandov Exp $ */
    1010
    1111/* includes */
     
    143143BOOLEAN rComplete(ring r, int force = 0);
    144144// use this to free fields created by rComplete
     145
     146BOOLEAN nc_rComplete(ring src, ring dest);
     147
    145148void rUnComplete(ring r);
    146149inline int rBlocks(ring r)
Note: See TracChangeset for help on using the changeset viewer.