Changeset ce1f78 in git


Ignore:
Timestamp:
Mar 16, 2012, 8:22:15 PM (11 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
Children:
7fee87629a807b6be566a7757b3b60f36c22d651
Parents:
cd9796d49b820bd9ecc81b49dc04073e0bbf6012
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-03-16 20:22:15+01:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-03-16 21:36:33+01:00
Message:
fixed short/long output of coeffs depending on ShortOut/CanShortOut options of rings

Note: the ugly ShortOut correction p_String0Short/p_String0Long is due to Hans
Location:
libpolys
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/coeffs.h

    rcd9796 rce1f78  
    145145   number  (*cfRePart)(number a, const coeffs r);
    146146   number  (*cfImPart)(number a, const coeffs r);
    147    void    (*cfWrite)(number &a, const coeffs r);
     147
     148   /// print a given number (long format)
     149   void    (*cfWriteLong)(number &a, const coeffs r);
     150   
     151   /// print a given number in a shorter way, if possible
     152   /// e.g. in K(a): a2 instead of a^2
     153   void    (*cfWriteShort)(number &a, const coeffs r);
     154   
    148155   const char *  (*cfRead)(const char * s, number * a, const coeffs r);
    149156   void    (*cfNormalize)(number &a, const coeffs r);
     
    262269  short      float_len2; /* additional char-flags, rInit */
    263270
    264   BOOLEAN   CanShortOut; //< if the elements can be printed in short format
    265                        // this is set to FALSE if a parameter name has >2 chars
    266   BOOLEAN   ShortOut; //< if the elements should print in short format
     271//  BOOLEAN   CanShortOut; //< if the elements can be printed in short format
     272//                     // this is set to FALSE if a parameter name has >2 chars
     273//  BOOLEAN   ShortOut; //< if the elements should print in short format
    267274
    268275// ---------------------------------------------------
     
    449456
    450457/// write to the output buffer of the currently used reporter
    451 static inline void   n_Write(number& n,  const coeffs r)
    452 { assume(r != NULL); assume(r->cfWrite!=NULL); r->cfWrite(n,r); }
     458static inline void   n_WriteLong(number& n,  const coeffs r)
     459{ assume(r != NULL); assume(r->cfWriteLong!=NULL); r->cfWriteLong(n,r); }
     460
     461/// write to the output buffer of the currently used reporter
     462/// in a shortest possible way, e.g. in K(a): a2 instead of a^2
     463static inline void   n_WriteShort(number& n,  const coeffs r)
     464{ assume(r != NULL); assume(r->cfWriteShort!=NULL); r->cfWriteShort(n,r); }
     465
     466static inline void   n_Write(number& n,  const coeffs r, const BOOLEAN bShortOut = TRUE)
     467{ if (bShortOut) n_WriteShort(n, r); else n_WriteLong(n, r); }
     468
    453469
    454470/// @todo: Describe me!!! --> Hans
  • libpolys/coeffs/ffields.cc

    rcd9796 rce1f78  
    384384* write via StringAppend
    385385*/
    386 void nfWrite (number &a, const coeffs r)
     386static void nfWriteLong (number &a, const coeffs r)
    387387{
    388388#ifdef LDEBUG
     
    397397    if ((long)a!=1L)
    398398    {
    399       if(r->ShortOut==0)  StringAppendS("^");
     399      StringAppend("^%d",(int)((long)a)); // long output!
     400    }
     401  }
     402}
     403
     404
     405/*2
     406* write (shortert output) via StringAppend
     407*/
     408static void nfWriteShort (number &a, const coeffs r)
     409{
     410#ifdef LDEBUG
     411  nfTest(a, r);
     412#endif
     413  if ((long)a==(long)r->m_nfCharQ)  StringAppendS("0");
     414  else if ((long)a==0L)   StringAppendS("1");
     415  else if (nfIsMOne(a, r))   StringAppendS("-1");
     416  else
     417  {
     418    StringAppendS(r->m_nfParameter);
     419    if ((long)a!=1L)
     420    {
    400421      StringAppend("%d",(int)((long)a));
    401422    }
     
    786807  //r->cfRePart = ndCopy;
    787808  //r->cfImPart = ndReturn0;
    788   r->cfWrite = nfWrite;
     809 
     810  r->cfWriteLong = nfWriteLong;
     811 
    789812  r->cfRead = nfRead;
    790813  //r->cfNormalize=ndNormalize;
     
    824847  r->m_nfPlus1Table= NULL;
    825848
    826   if (strlen(name) > 1) {
    827     r->ShortOut = 0;
    828     r->CanShortOut = FALSE;
    829   } else {
    830     r->ShortOut = 1;
    831   }
     849  if (strlen(name) > 1)
     850    r->cfWriteShort = nfWriteLong;
     851  else
     852    r->cfWriteShort = nfWriteShort;
    832853
    833854  r->has_simple_Alloc=TRUE;
  • libpolys/coeffs/gnumpc.cc

    rcd9796 rce1f78  
    416416  n->cfIsMOne  = ngcIsMOne;
    417417  n->cfGreaterZero = ngcGreaterZero;
    418   n->cfWrite  = ngcWrite;
     418
     419  n->cfWriteLong  = ngcWrite;
     420  n->cfWriteShort = ngcWrite;
     421 
    419422  n->cfRead    = ngcRead;
    420423  n->cfPower   = ngcPower;
     
    459462  r->cfRePart = nl_Copy;
    460463  r->cfImPart = ndReturn0;
    461   r->cfWrite = nlWrite;
     464  r->cfWriteLong = nlWrite;
    462465  r->cfRead = nlRead;
    463466  r->cfNormalize=nlNormalize;
  • libpolys/coeffs/gnumpfl.cc

    rcd9796 rce1f78  
    428428  n->cfIsMOne  = ngfIsMOne;
    429429  n->cfGreaterZero = ngfGreaterZero;
    430   n->cfWrite  = ngfWrite;
     430  n->cfWriteLong  = ngfWrite;
    431431  n->cfRead    = ngfRead;
    432432  n->cfPower   = ngfPower;
  • libpolys/coeffs/longrat.cc

    rcd9796 rce1f78  
    26752675  r->cfRePart = nlCopy;
    26762676  //r->cfImPart = ndReturn0;
    2677   r->cfWrite = nlWrite;
     2677  r->cfWriteLong = nlWrite;
    26782678  r->cfRead = nlRead;
    26792679  r->cfNormalize=nlNormalize;
  • libpolys/coeffs/modulop.cc

    rcd9796 rce1f78  
    468468  //r->cfRePart = ndCopy;
    469469  //r->cfImPart = ndReturn0;
    470   r->cfWrite = npWrite;
     470  r->cfWriteLong = npWrite;
    471471  r->cfRead = npRead;
    472472  //r->cfNormalize=ndNormalize;
  • libpolys/coeffs/numbers.cc

    rcd9796 rce1f78  
    291291    if (n->cfGetUnit==NULL) n->cfGetUnit=n->cfCopy;
    292292#endif
    293    
     293
     294    if(n->cfWriteShort==NULL)
     295      n->cfWriteShort = n->cfWriteLong;
     296   
    294297#ifndef NDEBUG
    295298    assume(n->nCoeffIsEqual!=NULL);
     
    316319    assume(n->cfRePart!=NULL);
    317320    assume(n->cfImPart!=NULL);
    318     assume(n->cfWrite!=NULL);
     321
     322    assume(n->cfWriteLong!=NULL);
     323    assume(n->cfWriteShort!=NULL);
     324
     325
     326    if(n->cfWriteLong==NULL) Warn("cfWrite is NULL for coeff %d",t);
     327    if(n->cfWriteShort==NULL) Warn("cfWriteShort is NULL for coeff %d",t);
     328   
    319329    assume(n->cfRead!=NULL);
    320330    assume(n->cfNormalize!=NULL);
  • libpolys/coeffs/numbers.h

    rcd9796 rce1f78  
    2727#define nIsMOne(n)        n_IsMOne(n, currRing->cf)
    2828#define nGreaterZero(n)   n_GreaterZero(n, currRing->cf)
    29 #define nGreater(a, b)   n_Greater (a,b,currRing->cf)
    30 #define nWrite(n)         n_Write(n,currRing->cf)
     29#define nGreater(a, b)    n_Greater (a,b,currRing->cf)
     30#define nWrite(n)         n_Write(n, currRing->cf, rShortOut(currRing))
    3131#define nNormalize(n)     n_Normalize(n,currRing->cf)
    3232
  • libpolys/coeffs/rintegers.cc

    rcd9796 rce1f78  
    408408  r->cfInvers= nrzInvers;
    409409  r->cfCopy  = nrzCopy;
    410   r->cfWrite = nrzWrite;
     410  r->cfWriteLong = nrzWrite;
    411411  r->cfRead = nrzRead;
    412412  r->cfGreater = nrzGreater;
  • libpolys/coeffs/rmodulo2m.cc

    rcd9796 rce1f78  
    7777  r->cfIsMOne      = nr2mIsMOne;
    7878  r->cfGreaterZero = nr2mGreaterZero;
    79   r->cfWrite       = nr2mWrite;
     79  r->cfWriteLong       = nr2mWrite;
    8080  r->cfRead        = nr2mRead;
    8181  r->cfPower       = nr2mPower;
  • libpolys/coeffs/rmodulon.cc

    rcd9796 rce1f78  
    7878  r->cfIsMOne      = nrnIsMOne;
    7979  r->cfGreaterZero = nrnGreaterZero;
    80   r->cfWrite       = nrnWrite;
     80  r->cfWriteLong       = nrnWrite;
    8181  r->cfRead        = nrnRead;
    8282  r->cfPower       = nrnPower;
  • libpolys/coeffs/shortfl.cc

    rcd9796 rce1f78  
    567567  n->cfIsMOne = nrIsMOne;
    568568  n->cfGreaterZero = nrGreaterZero;
    569   n->cfWrite = nrWrite;
     569  n->cfWriteLong = nrWrite;
    570570  n->cfRead = nrRead;
    571571  n->cfPower = nrPower;
  • libpolys/coeffs/test.cc

    rcd9796 rce1f78  
    196196
    197197  assume( r->cfInit != NULL );
    198   assume( r->cfWrite != NULL );
     198  assume( r->cfWriteLong != NULL );
    199199  assume( r->cfAdd != NULL );
    200200  assume( r->cfDelete != NULL );
     
    203203  {
    204204    assume( r->cfInit == nlInit );
    205     assume( r->cfWrite == nlWrite );
    206205    assume( r->cfAdd == nlAdd );
    207206    assume( r->cfDelete == nlDelete );   
     
    210209  {
    211210    assume( r->cfInit == ngfInit );
    212     assume( r->cfWrite == ngfWrite );
    213211    assume( r->cfAdd == ngfAdd );
    214212    assume( r->cfDelete == ngfDelete );
     
    217215  {
    218216    assume( r->cfInit == ngcInit );
    219     assume( r->cfWrite == ngcWrite );
    220217    assume( r->cfAdd == ngcAdd );
    221218    assume( r->cfDelete == ngcDelete );   
     
    224221  {
    225222    assume( r->cfInit == nrInit );
    226     assume( r->cfWrite == nrWrite );
    227223    assume( r->cfAdd == nrAdd );
    228224//    assume( r->cfDelete == nrDelete ); // No?
     
    232228  {
    233229    assume( r->cfInit == nr2mInit );
    234     assume( r->cfWrite == nr2mWrite );
    235230    assume( r->cfAdd == nr2mAdd );
    236231    assume( r->cfDelete == ndDelete );
     
    239234  {
    240235    assume( r->cfInit == nrnInit );
    241     assume( r->cfWrite == nrnWrite );
    242236    assume( r->cfAdd == nrnAdd );
    243237    assume( r->cfDelete == nrnDelete );
     
    247241  {
    248242    assume( r->cfInit == nfInit );
    249     assume( r->cfWrite == nfWrite );
    250243    assume( r->cfAdd == nfAdd );
    251244    //assume( r->cfDelete == nfDelete );
  • libpolys/polys/coeffrings.h

    rcd9796 rce1f78  
    2727static inline int    n_Size(number n,    const ring r){ return n_Size(n,r->cf); }
    2828static inline void   n_Normalize(number& n, const ring r){ return n_Normalize(n,r->cf); }
    29 static inline void   n_Write(number& n,  const ring r){ return n_Write(n,r->cf); }
     29static inline void   n_Write(number& n,  const ring r){ return n_Write(n, r->cf, rShortOut(r)); }
    3030static inline number n_GetDenom(number& n, const ring r){ return n_GetDenom(n, r->cf);}
    3131static inline number n_GetNumerator(number& n, const ring r){ return n_GetNumerator(n, r->cf);}
  • libpolys/polys/ext_fields/algext.cc

    rcd9796 rce1f78  
    9292void     naPower(number a, int exp, number *b, const coeffs cf);
    9393number   naCopy(number a, const coeffs cf);
    94 void     naWrite(number &a, const coeffs cf);
     94void     naWriteLong(number &a, const coeffs cf);
     95void     naWriteShort(number &a, const coeffs cf);
    9596number   naRePart(number a, const coeffs cf);
    9697number   naImPart(number a, const coeffs cf);
     
    468469}
    469470
    470 void naWrite(number &a, const coeffs cf)
     471void naWriteLong(number &a, const coeffs cf)
    471472{
    472473  naTest(a);
     
    481482    BOOLEAN useBrackets = !(p_IsConstant(aAsPoly, naRing));
    482483    if (useBrackets) StringAppendS("(");
    483     p_String0(aAsPoly, naRing, naRing);
     484    p_String0Long(aAsPoly, naRing, naRing);
     485    if (useBrackets) StringAppendS(")");
     486  }
     487}
     488
     489void naWriteShort(number &a, const coeffs cf)
     490{
     491  naTest(a);
     492  if (a == NULL)
     493    StringAppendS("0");
     494  else
     495  {
     496    poly aAsPoly = (poly)a;
     497    /* basically, just write aAsPoly using p_Write,
     498       but use brackets around the output, if a is not
     499       a constant living in naCoeffs = cf->extRing->cf */
     500    BOOLEAN useBrackets = !(p_IsConstant(aAsPoly, naRing));
     501    if (useBrackets) StringAppendS("(");
     502    p_String0Short(aAsPoly, naRing, naRing);
    484503    if (useBrackets) StringAppendS(")");
    485504  }
     
    817836  cf->cfPower        = naPower;
    818837  cf->cfCopy         = naCopy;
    819   cf->cfWrite        = naWrite;
     838
     839  cf->cfWriteLong        = naWriteLong;
     840
     841  if( rCanShortOut(naRing) )
     842    cf->cfWriteShort = naWriteShort;
     843  else
     844    cf->cfWriteShort = naWriteLong;
     845   
    820846  cf->cfRead         = naRead;
    821847  cf->cfDelete       = naDelete;
  • libpolys/polys/ext_fields/transext.cc

    rcd9796 rce1f78  
    110110void     ntPower(number a, int exp, number *b, const coeffs cf);
    111111number   ntCopy(number a, const coeffs cf);
    112 void     ntWrite(number &a, const coeffs cf);
     112void     ntWriteLong(number &a, const coeffs cf);
     113void     ntWriteShort(number &a, const coeffs cf);
    113114number   ntRePart(number a, const coeffs cf);
    114115number   ntImPart(number a, const coeffs cf);
     
    896897}
    897898
    898 /* modifies a */
    899 void ntWrite(number &a, const coeffs cf)
     899// NOTE: modifies a
     900void ntWriteLong(number &a, const coeffs cf)
    900901{
    901902  ntTest(a);
     
    909910    BOOLEAN omitBrackets = p_IsConstant(NUM(f), ntRing);
    910911    if (!omitBrackets) StringAppendS("(");
    911     p_String0(NUM(f), ntRing, ntRing);
     912    p_String0Long(NUM(f), ntRing, ntRing);
    912913    if (!omitBrackets) StringAppendS(")");
    913914    if (!DENIS1(f))
     
    916917      omitBrackets = p_IsConstant(DEN(f), ntRing);
    917918      if (!omitBrackets) StringAppendS("(");
    918       p_String0(DEN(f), ntRing, ntRing);
     919      p_String0Long(DEN(f), ntRing, ntRing);
     920      if (!omitBrackets) StringAppendS(")");
     921    }   
     922  }
     923}
     924
     925// NOTE: modifies a
     926void ntWriteShort(number &a, const coeffs cf)
     927{
     928  ntTest(a);
     929  definiteGcdCancellation(a, cf, FALSE);
     930  if (IS0(a))
     931    StringAppendS("0");
     932  else
     933  {
     934    fraction f = (fraction)a;
     935    // stole logic from napWrite from kernel/longtrans.cc of legacy singular
     936    BOOLEAN omitBrackets = p_IsConstant(NUM(f), ntRing);
     937    if (!omitBrackets) StringAppendS("(");
     938    p_String0Short(NUM(f), ntRing, ntRing);
     939    if (!omitBrackets) StringAppendS(")");
     940    if (!DENIS1(f))
     941    {
     942      StringAppendS("/");
     943      omitBrackets = p_IsConstant(DEN(f), ntRing);
     944      if (!omitBrackets) StringAppendS("(");
     945      p_String0Short(DEN(f), ntRing, ntRing);
    919946      if (!omitBrackets) StringAppendS(")");
    920947    }
     
    13691396  cf->cfPower        = ntPower;
    13701397  cf->cfCopy         = ntCopy;
    1371   cf->cfWrite        = ntWrite;
     1398  cf->cfWriteLong    = ntWriteLong;
    13721399  cf->cfRead         = ntRead;
    13731400  cf->cfNormalize    = ntNormalize;
     
    13901417  cf->cfKillChar     = ntKillChar;
    13911418
     1419  if( rCanShortOut(ntRing) )
     1420    cf->cfWriteShort = ntWriteShort;
     1421  else
     1422    cf->cfWriteShort = ntWriteLong;
     1423
    13921424#ifndef HAVE_FACTORY
    13931425  PrintS("// Warning: The 'factory' module is not available.\n");
  • libpolys/polys/monomials/p_polys.cc

    rcd9796 rce1f78  
    33673367  {
    33683368    number zz = n_Copy(z, src->cf);
    3369     PrintS("z: "); n_Write(zz, src->cf);
     3369    PrintS("z: "); n_Write(zz, src);
    33703370    n_Delete(&zz, src->cf);
    33713371  }
  • libpolys/polys/monomials/p_polys.h

    rcd9796 rce1f78  
    379379 *
    380380 ***************************************************************/
     381/// print p according to ShortOut in lmRing & tailRing
     382char*     p_String0(poly p, ring lmRing, ring tailRing);
    381383char*     p_String(poly p, ring lmRing, ring tailRing);
    382 char*     p_String0(poly p, ring lmRing, ring tailRing);
    383384void      p_Write(poly p, ring lmRing, ring tailRing);
    384385void      p_Write0(poly p, ring lmRing, ring tailRing);
    385386void      p_wrp(poly p, ring lmRing, ring tailRing);
     387
     388/// print p in a short way, if possible
     389char* p_String0Short(const poly p, ring lmRing, ring tailRing);
     390
     391/// print p in a long way
     392char* p_String0Long(const poly p, ring lmRing, ring tailRing);
     393
    386394
    387395/***************************************************************
  • libpolys/polys/monomials/ring.cc

    rcd9796 rce1f78  
    241241    return; /*to avoid printing after errors....*/
    242242
     243  assume(r != NULL);
     244  const coeffs C = r->cf;
     245  assume(C != NULL);
     246 
    243247  int nblocks=rBlocks(r);
    244248
     
    252256  nblocks--;
    253257
    254   n_CoeffWrite(r->cf, details);
     258
     259  if( nCoeff_is_algExt(C) )
     260  {
     261    // NOTE: the following (non-thread-safe!) UGLYNESS
     262    // (changing naRing->ShortOut for a while) is due to Hans!
     263    // Just think of other ring using the VERY SAME naRing and possible
     264    // side-effects...
     265    ring R = C->extRing;
     266    const BOOLEAN bSaveShortOut = rShortOut(R); R->ShortOut = rShortOut(r) & rCanShortOut(R);
     267
     268    n_CoeffWrite(C, details); // for correct printing of minpoly... WHAT AN UGLYNESS!!!
     269   
     270    R->ShortOut = bSaveShortOut;
     271  }
     272  else
     273    n_CoeffWrite(C, details);
     274 
    255275#if 0
    256276  {
     
    279299      else
    280300      {
    281         StringSetS(""); n_Write(r->cf->minpoly,r->cf); PrintS(StringAppendS("\n"));
     301        StringSetS(""); n_Write(r->cf->minpoly, r); PrintS(StringAppendS("\n"));
    282302      }
    283303      //if (r->minideal!=NULL)
     
    29883008{
    29893009  r->VectorOut = (r->order[0] == ringorder_c);
    2990   r->ShortOut = TRUE;
     3010  r->CanShortOut = TRUE;
    29913011  {
    29923012    int i;
     
    29973017        if(strlen(rParameter(r)[i])>1)
    29983018        {
    2999           r->ShortOut=FALSE;
     3019          r->CanShortOut=FALSE;
    30003020          break;
    30013021        }
    30023022      }
    30033023    }
    3004     if (r->ShortOut)
     3024    if (r->CanShortOut)
    30053025    {
    30063026      // Hmm... sometimes (e.g., from maGetPreimage) new variables
     
    30143034        if(r->names[i] != NULL && strlen(r->names[i])>1)
    30153035        {
    3016           r->ShortOut=FALSE;
     3036          r->CanShortOut=FALSE;
    30173037          break;
    30183038        }
     
    30203040    }
    30213041  }
    3022   r->CanShortOut = r->ShortOut;
     3042  r->ShortOut = r->CanShortOut;
     3043
     3044  assume( !( !r->CanShortOut && r->ShortOut ) );
    30233045}
    30243046
  • libpolys/polys/monomials/ring.h

    rcd9796 rce1f78  
    522522static inline BOOLEAN rShortOut(const ring r)
    523523{
    524   assume(r != NULL); assume(r->cf != NULL); return (r->ShortOut);
     524  assume(r != NULL); return (r->ShortOut);
     525}
     526
     527static inline BOOLEAN rCanShortOut(const ring r)
     528{
     529  assume(r != NULL); return (r->CanShortOut);
    525530}
    526531
  • libpolys/polys/polys0.cc

    rcd9796 rce1f78  
    2020* uses form x*gen(.) if ko != coloumn number of p
    2121*/
    22 static void writemon(poly p, int ko, ring r)
    23 {
     22static void writemon(poly p, int ko, const ring r)
     23{
     24  assume(r != NULL);
     25  const coeffs C = r->cf;
     26  assume(C != NULL);
     27 
    2428  BOOLEAN wroteCoef=FALSE,writeGen=FALSE;
     29  const BOOLEAN bNotShortOut = (rShortOut(r) == FALSE);
    2530
    2631  if (pGetCoeff(p)!=NULL)
    27     n_Normalize(pGetCoeff(p),r->cf);
     32    n_Normalize(pGetCoeff(p),C);
    2833
    2934  if (((p_GetComp(p,r) == (short)ko)
    3035    &&(p_LmIsConstantComp(p, r)))
    31   || ((!n_IsOne(pGetCoeff(p),r->cf))
    32     && (!n_IsMOne(pGetCoeff(p),r->cf))
     36  || ((!n_IsOne(pGetCoeff(p),C))
     37    && (!n_IsMOne(pGetCoeff(p),C))
    3338  )
    3439  )
    3540  {
    36     n_Write(p->coef,r->cf);
    37     wroteCoef=(rShortOut(r) == FALSE)
     41    if( bNotShortOut )
     42      n_WriteLong(pGetCoeff(p),C);
     43    else
     44      n_WriteShort(pGetCoeff(p),C);
     45   
     46    wroteCoef=(bNotShortOut)
    3847    || (rParameter(r)!=NULL)
    3948    || rField_is_R(r) || (rField_is_long_R(r)) || (rField_is_long_C(r));
    4049    writeGen=TRUE;
    4150  }
    42   else if (n_IsMOne(pGetCoeff(p),r->cf))
    43   {
    44     if (n_GreaterZero(pGetCoeff(p),r->cf))
    45     {
    46       n_Write(p->coef,r->cf);
    47       wroteCoef=(rShortOut(r) == FALSE)
     51  else if (n_IsMOne(pGetCoeff(p),C))
     52  {
     53    if (n_GreaterZero(pGetCoeff(p),C))
     54    {
     55      if( bNotShortOut )
     56        n_WriteLong(pGetCoeff(p),C);
     57      else
     58        n_WriteShort(pGetCoeff(p),C);
     59     
     60      wroteCoef=(bNotShortOut)
    4861      || (rParameter(r)!=NULL)
    4962      || rField_is_R(r) || (rField_is_long_R(r)) || (rField_is_long_C(r));
     
    6477          StringAppendS("*");
    6578        //else
    66           wroteCoef=(rShortOut(r) == FALSE);
     79          wroteCoef=(bNotShortOut);
    6780        writeGen=TRUE;
    6881        StringAppendS(rRingVar(i, r));
    6982        if (ee != 1L)
    7083        {
    71           if (rShortOut(r)==0) StringAppendS("^");
     84          if (bNotShortOut) StringAppendS("^");
    7285          StringAppend("%ld", ee);
    7386        }
     
    8295  }
    8396}
     97
     98/// if possible print p in a short way...
     99char* p_String0Short(const poly p, ring lmRing, ring tailRing)
     100{
     101  // NOTE: the following (non-thread-safe!) UGLYNESS
     102  // (changing naRing->ShortOut for a while) is due to Hans!
     103  // Just think of other ring using the VERY SAME naRing and possible
     104  // side-effects...
     105  const BOOLEAN bLMShortOut = rShortOut(lmRing);
     106  const BOOLEAN bTAILShortOut = rShortOut(tailRing);
     107
     108  lmRing->ShortOut = rCanShortOut(lmRing);
     109  tailRing->ShortOut = rCanShortOut(tailRing);
     110 
     111  char* res = p_String0(p, lmRing, tailRing);
     112
     113  lmRing->ShortOut = bLMShortOut;
     114  tailRing->ShortOut = bTAILShortOut;
     115
     116  return res;
     117}
     118
     119/// print p in a long way...
     120char* p_String0Long(const poly p, ring lmRing, ring tailRing)
     121{
     122  // NOTE: the following (non-thread-safe!) UGLYNESS
     123  // (changing naRing->ShortOut for a while) is due to Hans!
     124  // Just think of other ring using the VERY SAME naRing and possible
     125  // side-effects...
     126  const BOOLEAN bLMShortOut = rShortOut(lmRing);
     127  const BOOLEAN bTAILShortOut = rShortOut(tailRing);
     128
     129  lmRing->ShortOut = FALSE;
     130  tailRing->ShortOut = FALSE;
     131
     132  char* res = p_String0(p, lmRing, tailRing);
     133
     134  lmRing->ShortOut = bLMShortOut;
     135  tailRing->ShortOut = bTAILShortOut;
     136
     137  return res;
     138}
     139
    84140
    85141char* p_String0(poly p, ring lmRing, ring tailRing)
  • libpolys/tests/coeffs_test.h

    rcd9796 rce1f78  
    250250
    251251  TS_ASSERT_DIFFERS( r->cfInit, NULLp );
    252   TS_ASSERT_DIFFERS( r->cfWrite, NULLp );
     252  TS_ASSERT_DIFFERS( r->cfWriteLong, NULLp );
    253253  TS_ASSERT_DIFFERS( r->cfAdd, NULLp );
    254254  TS_ASSERT_DIFFERS( r->cfDelete, NULLp );
     
    259259    {
    260260      TS_ASSERT_EQUALS( r->cfInit, nlInit );
    261       TS_ASSERT_EQUALS( r->cfWrite, nlWrite );
    262261      TS_ASSERT_EQUALS( r->cfAdd, nlAdd );
    263262      TS_ASSERT_EQUALS( r->cfDelete, nlDelete );
     
    289288    {
    290289      TS_ASSERT_EQUALS( r->cfInit, ngfInit );
    291       TS_ASSERT_EQUALS( r->cfWrite, ngfWrite );
    292290      TS_ASSERT_EQUALS( r->cfAdd, ngfAdd );
    293291      TS_ASSERT_EQUALS( r->cfDelete, ngfDelete );
     
    297295    {
    298296      TS_ASSERT_EQUALS( r->cfInit, ngcInit );
    299       TS_ASSERT_EQUALS( r->cfWrite, ngcWrite );
    300297      TS_ASSERT_EQUALS( r->cfAdd, ngcAdd );
    301298      TS_ASSERT_EQUALS( r->cfDelete, ngcDelete );
     
    305302    {
    306303      TS_ASSERT_EQUALS( r->cfInit, nrInit );
    307       TS_ASSERT_EQUALS( r->cfWrite, nrWrite );
    308304      TS_ASSERT_EQUALS( r->cfAdd, nrAdd );
    309305  //    TS_ASSERT_EQUALS( r->cfDelete, nrDelete ); // No?
     
    313309    {
    314310      TS_ASSERT_EQUALS( r->cfInit, nfInit );
    315       TS_ASSERT_EQUALS( r->cfWrite, nfWrite );
    316311      TS_ASSERT_EQUALS( r->cfAdd, nfAdd );
    317312      //TS_ASSERT_EQUALS( r->cfDelete, nfDelete );
     
    322317    {
    323318      TS_ASSERT_EQUALS( r->cfInit, nr2mInit );
    324       TS_ASSERT_EQUALS( r->cfWrite, nr2mWrite );
    325319      TS_ASSERT_EQUALS( r->cfAdd, nr2mAdd );
    326320      TS_ASSERT_EQUALS( r->cfDelete, ndDelete );
     
    330324    {
    331325      TS_ASSERT_EQUALS( r->cfInit, nrnInit );
    332       TS_ASSERT_EQUALS( r->cfWrite, nrnWrite );
    333326      TS_ASSERT_EQUALS( r->cfAdd, nrnAdd );
    334327      TS_ASSERT_EQUALS( r->cfDelete, nrnDelete );
Note: See TracChangeset for help on using the changeset viewer.