Changeset 45cc512 in git


Ignore:
Timestamp:
Dec 5, 2013, 3:34:22 PM (9 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '5bec8f88c9ee2573d328cf7c3aff2bcb301d2395')
Children:
0acf3e38387201ff9fd3220d3febd9296fda35dd
Parents:
6cce775fcf124d803afe198a1cae685953241af3
Message:
chg: rCharstr is now a wrapper for r->cf->cfCoeffString

fixes also: charstr for integer,2,3
Location:
libpolys
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/coeffs.h

    r6cce775 r45cc512  
    111111   /// output of coeff description via Print
    112112   void (*cfCoeffWrite)(const coeffs r, BOOLEAN details);
     113
     114   /// string output of coeff description
     115   char* (*cfCoeffString)(const coeffs r);
    113116
    114117   // ?
  • libpolys/coeffs/ffields.cc

    r6cce775 r45cc512  
    819819}
    820820
     821static char* nfCoeffString(const coeffs r)
     822{
     823  const char *p=n_ParameterNames(r)[0];
     824  char *s=(char*)omAlloc(11+1+strlen(p));
     825  sprintf(s,"%d,%s",r->m_nfCharQ,p);
     826  return s;
     827}
     828
    821829BOOLEAN nfInitChar(coeffs r,  void * parameter)
    822830{
     
    824832  r->cfKillChar=nfKillChar;
    825833  r->nCoeffIsEqual=nfCoeffIsEqual;
     834  r->cfCoeffString=nfCoeffString;
    826835
    827836  r->cfMult  = nfMult;
  • libpolys/coeffs/gnumpc.cc

    r6cce775 r45cc512  
    458458}
    459459
     460static char* ngcCoeffString(const coeffs r)
     461{
     462  const char *p=n_ParameterNames(r)[0];
     463  char *s=(char*)omAlloc(21+strlen(p));
     464  sprintf(s,"complex,%d,%s",r->float_len,p);
     465  return s;
     466}
     467
    460468BOOLEAN ngcInitChar(coeffs n, void* parameter)
    461469{
     
    464472  n->cfKillChar = ngcKillChar;
    465473  n->ch = 0;
     474  n->cfCoeffString=ngcCoeffString;
    466475
    467476  n->cfDelete  = ngcDelete;
  • libpolys/coeffs/gnumpfl.cc

    r6cce775 r45cc512  
    402402}
    403403
     404static char* ngfCoeffString(const coeffs r)
     405{
     406  char *s=(char*)omAlloc(27);
     407  snprintf(s,27,"real,%d,%d",r->float_len,r->float_len2);
     408  return s;
     409}
     410
    404411BOOLEAN ngfInitChar(coeffs n, void *parameter)
    405412{
     
    410417  n->cfSetChar = ngfSetChar;
    411418  n->ch = 0;
     419  n->cfCoeffString=ngfCoeffString;
    412420 
    413421  n->cfDelete  = ngfDelete;
  • libpolys/coeffs/longrat.cc

    r6cce775 r45cc512  
    28262826}
    28272827
     2828static char* nlCoeffString(const coeffs r)
     2829{
     2830  return omStrDup("0");
     2831}
     2832
    28282833BOOLEAN nlInitChar(coeffs r, void*)
    28292834{
     
    28332838  r->nCoeffIsEqual=ndCoeffIsEqual;
    28342839  r->cfKillChar = ndKillChar; /* dummy */
     2840  r->cfCoeffString=nlCoeffString;
    28352841
    28362842  r->cfInitMPZ = nlInitMPZ;
  • libpolys/coeffs/modulop.cc

    r6cce775 r45cc512  
    425425}
    426426
     427static char* npCoeffString(const coeffs r)
     428{
     429  char *s=(char*)omAlloc(11);
     430  snprintf(s,11,"%d",r->ch);
     431  return s;
     432}
     433
    427434BOOLEAN npInitChar(coeffs r, void* p)
    428435{
     
    440447  r->cfKillChar=npKillChar;
    441448  r->nCoeffIsEqual=npCoeffsEqual;
     449  r->cfCoeffString=npCoeffString;
    442450
    443451  r->cfMult  = npMult;
  • libpolys/coeffs/numbers.cc

    r6cce775 r45cc512  
    5050void   nNew(number* d) { *d=NULL; }
    5151void   ndDelete(number* d, const coeffs) { *d=NULL; }
     52char* ndCoeffString(const coeffs r)
     53{
     54  char *s=(char *)omAlloc(11);snprintf(s,11,"Coeffs(%d)",r->type);
     55  return s;
     56}
    5257void   ndInpMult(number &a, number b, const coeffs r)
    5358{
     
    323328    n->cfImPart=ndReturn0;
    324329    n->cfDelete= ndDelete;
     330    n->cfCoeffString = ndCoeffString; // should alway be changed!
    325331    n->cfInpMult=ndInpMult;
    326332    n->cfInpAdd=ndInpAdd;
     
    385391    assume(n->nCoeffIsEqual!=NULL);
    386392    assume(n->cfSetChar!=NULL);
     393    assume(n->cfCoeffString!=ndCoeffString);
    387394    assume(n->cfMult!=NULL);
    388395    assume(n->cfSub!=NULL);
     
    451458    if(n->cfWriteLong==NULL) Warn("cfWrite is NULL for coeff %d",t);
    452459    if(n->cfWriteShort==NULL) Warn("cfWriteShort is NULL for coeff %d",t);
     460    if(n->cfCoeffString==ndCoeffString) Warn("cfCoeffString is undefined for coeff %d",t);
    453461#endif
    454462     
  • libpolys/coeffs/rintegers.cc

    r6cce775 r45cc512  
    383383}
    384384
     385static char* nrzCoeffString(const coeffs r)
     386{
     387  return omStrDup("integer");
     388}
    385389
    386390BOOLEAN nrzInitChar(coeffs r,  void *)
     
    388392  assume( getCoeffType(r) == ID );
    389393  r->nCoeffIsEqual = ndCoeffIsEqual;
     394  r->cfCoeffString = nrzCoeffString;
    390395  r->cfKillChar = ndKillChar;
    391396  r->cfMult  = nrzMult;
  • libpolys/coeffs/rmodulo2m.cc

    r6cce775 r45cc512  
    4646  return FALSE;
    4747}
     48
     49static char* nr2mCoeffString(const coeffs r)
     50{
     51  char* s = (char*) omAlloc(11+11);
     52  sprintf(s,"integer,2,%lu",r->modExponent);
     53  return s;
     54}
     55
    4856/* for initializing function pointers */
    4957BOOLEAN nr2mInitChar (coeffs r, void* p)
     
    5361  r->cfKillChar    = ndKillChar; /* dummy*/
    5462  r->nCoeffIsEqual = nr2mCoeffIsEqual;
     63  r->cfCoeffString = nr2mCoeffString;
    5564
    5665  r->modBase = (int_number) omAllocBin (gmp_nrz_bin);
  • libpolys/coeffs/rmodulon.cc

    r6cce775 r45cc512  
    4747}
    4848
     49static char* nrnCoeffString(const coeffs r)
     50{
     51  char* s = (char*) omAlloc(7+11+2);
     52  sprintf(s,"integer,%lu",r->modExponent);
     53  return s;
     54}
    4955
    5056/* for initializing function pointers */
     
    6066     is a GMP number */
    6167  r->ch = mpz_get_ui(r->modNumber);
     68
     69  r->cfCoeffString = nrnCoeffString;
    6270
    6371  r->cfInit        = nrnInit;
  • libpolys/coeffs/shortfl.cc

    r6cce775 r45cc512  
    630630}
    631631
     632static char* nrCoeffString(const coeffs r)
     633{
     634  return omStrDup("real");
     635}
     636
    632637BOOLEAN nrInitChar(coeffs n, void* p)
    633638{
     
    638643  n->cfKillChar = ndKillChar; /* dummy */
    639644  n->ch = 0;
     645  n->cfCoeffString = nrCoeffString;
    640646
    641647  n->cfInit = nrInit;
  • libpolys/polys/ext_fields/algext.cc

    r6cce775 r45cc512  
    13271327}
    13281328
    1329 
     1329char* naCoeffString(const coeffs r) // currently also for tranext.
     1330{
     1331  const char* const* p=n_ParameterNames(r);
     1332  int l=0;
     1333  int i;
     1334  for(i=0; i<n_NumberOfParameters(r);i++)
     1335  {
     1336    l+=(strlen(p[i])+1);
     1337  }
     1338  char *s=(char *)omAlloc(l+10+1);
     1339  s[0]='\0';
     1340  snprintf(s,10+1,"%d",r->ch); /* Fp(a) or Q(a) */
     1341  char tt[2];
     1342  tt[0]=',';
     1343  tt[1]='\0';
     1344  for(i=0; i<n_NumberOfParameters(r);i++)
     1345  {
     1346    strcat(s,tt);
     1347    strcat(s,p[i]);
     1348  }
     1349  return s;
     1350}
    13301351
    13311352BOOLEAN naInitChar(coeffs cf, void * infoStruct)
     
    13581379  p_Test((poly)naMinpoly, naRing);
    13591380  #endif
     1381
     1382  cf->cfCoeffString = naCoeffString;
    13601383
    13611384  cf->cfGreaterZero  = naGreaterZero;
  • libpolys/polys/ext_fields/transext.cc

    r6cce775 r45cc512  
    23652365  cf->ch = R->cf->ch;
    23662366  cf->factoryVarOffset = R->cf->factoryVarOffset + rVar(R);
     2367  extern char* naCoeffString(const coeffs r);
     2368  cf->cfCoeffString = naCoeffString;
    23672369
    23682370  cf->cfGreaterZero  = ntGreaterZero;
  • libpolys/polys/monomials/ring.cc

    r6cce775 r45cc512  
    619619/// Decompose & Compose, rParameter & rPar
    620620char * rCharStr(ring r)
    621 {
    622   char *s;
    623   int i;
    624 
    625 #ifdef HAVE_RINGS
    626   if (rField_is_Ring_Z(r))
    627   {
    628     s=omStrDup("integer");                   // Z
    629     return s;
    630   }
    631   if(rField_is_Ring_2toM(r))
    632   {
    633     char* s = (char*) omAlloc(7+10+2);
    634     sprintf(s,"integer,%lu",r->cf->modExponent);
    635     return s;
    636   }
    637   if(rField_is_Ring_ModN(r))
    638   {
    639     long l = (long)mpz_sizeinbase(r->cf->modBase, 10) + 2+7;
    640     char* s = (char*) omAlloc(l);
    641     gmp_sprintf(s,"integer,%Zd",r->cf->modBase);
    642     return s;
    643   }
    644   if(rField_is_Ring_PtoM(r))
    645   {
    646     long l = (long)mpz_sizeinbase(r->cf->modBase, 10) + 2+7+10;
    647     char* s = (char*) omAlloc(l);
    648     gmp_sprintf(s,"integer,%Zd^%lu",r->cf->modBase,r->cf->modExponent);
    649     return s;
    650   }
    651 #endif
    652   if (rField_is_long_R(r))
    653   {
    654     i = MAX_INT_LEN*2+7; // 2 integers and real,,
    655     s=(char *)omAlloc(i);
    656     snprintf(s,i,"real,%d,%d",r->cf->float_len,r->cf->float_len2); /* long_R */
    657     return s;
    658   }
    659   if (rField_is_R(r))
    660   {
    661     return omStrDup("real"); /* short real */
    662   }
    663   char const * const * const params = rParameter(r);
    664   if (params==NULL)
    665   {
    666     s=(char *)omAlloc(MAX_INT_LEN+1);
    667     snprintf(s,MAX_INT_LEN+1,"%d",n_GetChar(r->cf));         /* Q, Z/p */
    668     return s;
    669   }
    670   if (rField_is_long_C(r))
    671   {
    672     i=strlen(params[0])+21;
    673     s=(char *)omAlloc(i);
    674     snprintf(s,i,"complex,%d,%s",r->cf->float_len,params[0]);   /* C */
    675     return s;
    676   }
    677   if (nCoeff_is_GF(r->cf))
    678   {
    679     i=strlen(params[0])+21;
    680     s=(char *)omAlloc(i);
    681     snprintf(s,i,"%d,%s",r->cf->m_nfCharQ,params[0]); /* GF(q)  */
    682     return s;
    683   }
    684   int l=0;
    685   for(i=0; i<rPar(r);i++)
    686   {
    687     l+=(strlen(params[i])+1);
    688   }
    689   s=(char *)omAlloc((long)(l+MAX_INT_LEN+1));
    690   s[0]='\0';
    691   snprintf(s,MAX_INT_LEN+1,"%d",r->cf->ch); /* Fp(a) or Q(a) */
    692   char tt[2];
    693   tt[0]=',';
    694   tt[1]='\0';
    695   for(i=0; i<rPar(r);i++)
    696   {
    697     strcat(s,tt);
    698     strcat(s,params[i]);
    699   }
    700   return s;
    701 }
     621{ return r->cf->cfCoeffString(r->cf); }
    702622
    703623char * rParStr(ring r)
Note: See TracChangeset for help on using the changeset viewer.