Changeset d08de4 in git for libpolys


Ignore:
Timestamp:
Nov 24, 2018, 4:47:57 PM (5 years ago)
Author:
Karim Abou Zeid <karim23697@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'd08f5f0bb3329b8ca19f23b74cb1473686415c3a')
Children:
2b556a233dfaeb437351a31315ce8aa41a63ef72
Parents:
352a92c88d03b3b9cf5dcabdeb7619670ccc7228
git-author:
Karim Abou Zeid <karim23697@gmail.com>2018-11-24 16:47:57+01:00
git-committer:
Karim Abou Zeid <karim23697@gmail.com>2018-11-28 06:55:27+01:00
Message:
Better priniting of invalid letterplace monomials

examples:
x(2)*y(4) = _*x*_*y
x(2)*x(3)*y(3)*x(5) = _*x*x&y*_*x

nothing changes if the monomial is valid:
x(1)*y(2)*x(3) = x*y*x
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/polys0.cc

    r352a92c rd08de4  
    2828  assume(C != NULL);
    2929
    30 #ifdef HAVE_SHIFTBBA
    31   if (r->isLPring)
    32   {
    33     if (!p_mIsInV(p, r))
    34     {
    35       /*
    36       * the monomial is not a valid letterplace monomial
    37       * without this warning one cannot distinguish between
    38       * x(1)*x(3) and x(1)*x(2) because they would both be displayed
    39       * as x*x
    40       */
    41       int *expV = (int *) omAlloc((r->N+1)*sizeof(int));
    42       p_GetExpV(p, expV, r);
    43       char* s = LPExpVString(expV, r);
    44       Warn("invalid letterplace monomial: (%s)", s);
    45       omFreeSize((ADDRESS) expV, (r->N+1)*sizeof(int));
    46       omFree(s);
    47     }
    48   }
    49 #endif
    50 
    5130  BOOLEAN wroteCoef=FALSE,writeGen=FALSE;
    5231  const BOOLEAN bNotShortOut = (rShortOut(r) == FALSE);
     
    8867
    8968  int i;
    90   for (i=0; i<rVar(r); i++)
    91   {
    92     {
    93       long ee = p_GetExp(p,i+1,r);
    94       if (ee!=0L)
     69#ifdef HAVE_SHIFTBBA
     70  if (rIsLPRing(r))
     71  {
     72    int lV = r->isLPring;
     73    int lastVar = p_mLastVblock(p, r) * lV;
     74    BOOLEAN wroteBlock = FALSE;
     75    for (i=0; i<rVar(r); i++)
     76    {
    9577      {
    96         if (wroteCoef)
    97           StringAppendS("*");
    98         //else
     78        long ee = p_GetExp(p,i+1,r);
     79        BOOLEAN endOfBlock = ((i+1) % lV) == 0;
     80        BOOLEAN writeEmptyBlock = ee==0L && endOfBlock && !wroteBlock && i < lastVar;
     81        if (ee!=0L || writeEmptyBlock)
     82        {
     83          if (wroteBlock)
     84            StringAppendS("&");
     85          else if (wroteCoef)
     86            StringAppendS("*");
     87          //else
    9988          wroteCoef=(bNotShortOut);
    100         writeGen=TRUE;
    101         StringAppendS(rRingVar(i, r));
    102         if (ee != 1L)
     89          writeGen=TRUE;
     90          if (writeEmptyBlock)
     91            StringAppendS("_");
     92          else
     93          {
     94            StringAppendS(rRingVar(i, r));
     95            if (ee != 1L)
     96            {
     97              if (bNotShortOut) StringAppendS("^");
     98              StringAppend("%ld", ee);
     99            }
     100            wroteBlock = TRUE;
     101          }
     102        }
     103        if (endOfBlock)
     104          wroteBlock = FALSE;
     105      }
     106    }
     107  }
     108  else
     109#endif
     110  {
     111    for (i=0; i<rVar(r); i++)
     112    {
     113      {
     114        long ee = p_GetExp(p,i+1,r);
     115        if (ee!=0L)
    103116        {
    104           if (bNotShortOut) StringAppendS("^");
    105           StringAppend("%ld", ee);
     117          if (wroteCoef)
     118            StringAppendS("*");
     119          //else
     120          wroteCoef=(bNotShortOut);
     121          writeGen=TRUE;
     122          StringAppendS(rRingVar(i, r));
     123          if (ee != 1L)
     124          {
     125            if (bNotShortOut) StringAppendS("^");
     126            StringAppend("%ld", ee);
     127          }
    106128        }
    107129      }
Note: See TracChangeset for help on using the changeset viewer.