Changeset 7fee876 in git for libpolys/polys


Ignore:
Timestamp:
Mar 16, 2012, 9:26:19 PM (12 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
5a72fe43aa1fbae0fb93ebbff5685375e726f93c
Parents:
ce1f78b09d525de2d3babcf986a9f4821e60ed00
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-03-16 21:26:19+01:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-03-17 05:41:42+01:00
Message:
moved prarameter-handling to coeffs from rings.* and related fixes

chg: removed complex_parameter, m_nfParameter
add: n_NumberOfParameters, n_ParameterNames, n_Param(coeffs)
fix: par(1) (n_Param) for n_GF & n_long_C
fix/chg: n_long_C is an Extension as well (rIsExtension)
fix: n_long_C ngcCoeffWrite: additional space needed for compatibility with legacy Singular
fix: complexToStr over non-C coeffs!
fix: rRenameVars renames _new_ VARIABLES instead of _old_ parameters!
fix: coeff construction was broken in walk.cc
add/fix: nfKillChar, ngcKillChar
chg: cleanup of headers & tests
chg: parameter output during "make check"
Location:
libpolys/polys
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/OBSOLETE_pInitContent.cc

    rce1f78 r7fee876  
    797797            {
    798798              number c=pGetCoeff(qq);
    799               number ee=nfPar(1);
     799              number ee=n_Parameter(1, currRing->cf); // ?
    800800              number eee;nfPower(ee,e,&eee); //nfDelete(ee,currRing);
    801801              ee=nfMult(c,eee);
  • libpolys/polys/ext_fields/algext.cc

    rce1f78 r7fee876  
    788788}
    789789
     790/// return the specified parameter as a number in the given alg. field
     791static number naParameter(const int iParameter, const coeffs cf)
     792{
     793  assume(getCoeffType(cf) == ID);
     794
     795  const ring R = cf->extRing;
     796  assume( R != NULL ); 
     797  assume( 0 < iParameter && iParameter <= rVar(R) );
     798
     799  poly p = p_One(R); p_SetExp(p, iParameter, 1, R); p_Setm(p, R);
     800
     801  return (number) p;
     802}
     803
     804
     805/// if m == var(i)/1 => return i,
     806int naIsParam(number m, const coeffs cf)
     807{
     808  assume(getCoeffType(cf) == ID);
     809
     810  const ring R = cf->extRing;
     811  assume( R != NULL ); 
     812
     813  return p_Var( (poly)m, R );
     814}
     815
    790816BOOLEAN naInitChar(coeffs cf, void * infoStruct)
    791817
     
    805831  assume( cf != NULL );
    806832  assume(getCoeffType(cf) == ID);                     // coeff type;
    807  
    808   cf->extRing           = e->r;
    809   cf->extRing->ref ++; // increase the ref.counter for the ground poly. ring!
    810 
    811   cf->extRing->minideal = e->i; // make a copy?
     833
     834  ring R = e->r;
     835  assume(R != NULL);
     836 
     837  R->ref ++; // increase the ref.counter for the ground poly. ring!
     838
     839  R->minideal = e->i; // make a copy?
     840
     841  cf->extRing           = R;
    812842
    813843  /* propagate characteristic up so that it becomes
    814844     directly accessible in cf: */
    815   cf->ch = cf->extRing->cf->ch;
    816  
     845  cf->ch = R->cf->ch;
     846
    817847  #ifdef LDEBUG
    818848  p_Test((poly)naMinpoly, naRing);
     
    868898  cf->cfParDeg = naParDeg;
    869899 
     900  cf->iNumberOfParameters = rVar(R);
     901  cf->pParameterNames = R->names;
     902  cf->cfParameter = naParameter;
     903 
    870904  return FALSE;
    871905}
    872 
    873 
    874 number naParam(const short iParameter, const coeffs cf)
    875 {
    876   assume(getCoeffType(cf) == ID);
    877  
    878   const ring R = cf->extRing;
    879   assume( R != NULL ); 
    880   assume( 0 < iParameter && iParameter <= rVar(R) );
    881  
    882   poly p = p_One(R); p_SetExp(p, iParameter, 1, R); p_Setm(p, R);
    883  
    884   return (number) p;
    885 }
    886 
    887 
    888 /// if m == var(i)/1 => return i,
    889 int naIsParam(number m, const coeffs cf)
    890 {
    891   assume(getCoeffType(cf) == ID);
    892 
    893   const ring R = cf->extRing;
    894   assume( R != NULL ); 
    895 
    896   return p_Var( (poly)m, R );
    897 }
  • libpolys/polys/ext_fields/algext.h

    rce1f78 r7fee876  
    4646BOOLEAN  naInitChar(coeffs cf, void* infoStruct);
    4747
    48 /* Private hidden interface
    49 BOOLEAN  naGreaterZero(number a, const coeffs cf);
    50 BOOLEAN  naGreater(number a, number b, const coeffs cf);
    51 BOOLEAN  naEqual(number a, number b, const coeffs cf);
    52 BOOLEAN  naIsOne(number a, const coeffs cf);
    53 BOOLEAN  naIsMOne(number a, const coeffs cf);
    54 BOOLEAN  naIsZero(number a, const coeffs cf);
    55 number   naInit(long i, const coeffs cf);
    56 int      naInt(number &a, const coeffs cf);
    57 number   naNeg(number a, const coeffs cf);
    58 number   naInvers(number a, const coeffs cf);
    59 number   naAdd(number a, number b, const coeffs cf);
    60 number   naSub(number a, number b, const coeffs cf);
    61 number   naMult(number a, number b, const coeffs cf);
    62 number   naDiv(number a, number b, const coeffs cf);
    63 void     naPower(number a, int exp, number *b, const coeffs cf);
    64 number   naCopy(number a, const coeffs cf);
    65 void     naWrite(number &a, const coeffs cf);
    66 number   naRePart(number a, const coeffs cf);
    67 number   naImPart(number a, const coeffs cf);
    68 number   naGetDenom(number &a, const coeffs cf);
    69 number   naGetNumerator(number &a, const coeffs cf);
    70 number   naGcd(number a, number b, const coeffs cf);
    71 number   naLcm(number a, number b, const coeffs cf);
    72 number   naSize(number a, const coeffs cf);
    73 void     naDelete(number * a, const coeffs cf);
    74 void     naCoeffWrite(const coeffs cf);
    75 number   naIntDiv(number a, number b, const coeffs cf);
    76 const char * naRead(const char *s, number *a, const coeffs cf);
    77 static BOOLEAN naCoeffIsEqual(const coeffs cf, n_coeffType n, void * param);
    78 */
    79 
    80 /// return the specified parameter as a number in the given alg. field
    81 number naParam(short iParameter, const coeffs cf);
    82 
    83 
    8448/// if m == var(i)/1 => return i,
    8549int naIsParam(number, const coeffs);
  • libpolys/polys/ext_fields/transext.cc

    rce1f78 r7fee876  
    13571357}
    13581358
     1359/// return the specified parameter as a number in the given trans.ext.
     1360static number ntParameter(const int iParameter, const coeffs cf)
     1361{
     1362  assume(getCoeffType(cf) == ID);
     1363
     1364  const ring R = cf->extRing;
     1365  assume( R != NULL );
     1366  assume( 0 < iParameter && iParameter <= rVar(R) );
     1367
     1368  poly p = p_One(R); p_SetExp(p, iParameter, 1, R); p_Setm(p, R);
     1369
     1370//  return (number) p;
     1371
     1372  fraction f = (fraction)omAlloc0Bin(fractionObjectBin);
     1373  NUM(f) = p;
     1374  DEN(f) = NULL;
     1375  COM(f) = 0;
     1376
     1377  return (number)f;
     1378}
     1379
     1380/// if m == var(i)/1 => return i,
     1381int ntIsParam(number m, const coeffs cf)
     1382{
     1383  assume(getCoeffType(cf) == ID);
     1384
     1385  const ring R = cf->extRing;
     1386  assume( R != NULL );
     1387
     1388  fraction f = (fraction)m;
     1389
     1390  if( DEN(f) != NULL )
     1391    return 0;
     1392
     1393  return p_Var( NUM(f), R );
     1394}
     1395
    13591396BOOLEAN ntInitChar(coeffs cf, void * infoStruct)
    13601397{
     
    13711408  assume(getCoeffType(cf) == ID);                // coeff type;
    13721409
    1373   cf->extRing           = e->r;
    1374   cf->extRing->ref ++; // increase the ref.counter for the ground poly. ring!
    1375   cf->factoryVarOffset = cf->extRing->cf->factoryVarOffset+rVar(cf->extRing);
    1376 
     1410  ring R = e->r;
     1411  assume(R != NULL);
     1412 
     1413  R->ref ++; // increase the ref.counter for the ground poly. ring!
     1414
     1415  cf->extRing           = R;
    13771416  /* propagate characteristic up so that it becomes
    13781417     directly accessible in cf: */
    1379   cf->ch = cf->extRing->cf->ch;
    1380 
     1418  cf->ch = R->cf->ch;
     1419  cf->factoryVarOffset = R->cf->factoryVarOffset + rVar(R);
     1420 
    13811421  cf->cfGreaterZero  = ntGreaterZero;
    13821422  cf->cfGreater      = ntGreater;
     
    14321472  cf->cfParDeg = ntParDeg;
    14331473
     1474  cf->iNumberOfParameters = rVar(R);
     1475  cf->pParameterNames = R->names;
     1476  cf->cfParameter = ntParameter;
     1477
     1478
    14341479  return FALSE;
    14351480}
    1436 
    1437 
    1438 number ntParam(const short iParameter, const coeffs cf)
    1439 {
    1440   assume(getCoeffType(cf) == ID);
    1441 
    1442   const ring R = cf->extRing;
    1443   assume( R != NULL );
    1444   assume( 0 < iParameter && iParameter <= rVar(R) );
    1445 
    1446   poly p = p_One(R); p_SetExp(p, iParameter, 1, R); p_Setm(p, R);
    1447 
    1448 //  return (number) p;
    1449 
    1450   fraction f = (fraction)omAlloc0Bin(fractionObjectBin);
    1451   NUM(f) = p;
    1452   DEN(f) = NULL;
    1453   COM(f) = 0;
    1454 
    1455   return (number)f;
    1456 }
    1457 
    1458 
    1459 /// if m == var(i)/1 => return i,
    1460 int ntIsParam(number m, const coeffs cf)
    1461 {
    1462   assume(getCoeffType(cf) == ID);
    1463 
    1464   const ring R = cf->extRing;
    1465   assume( R != NULL );
    1466 
    1467   fraction f = (fraction)m;
    1468 
    1469   if( DEN(f) != NULL )
    1470     return 0;
    1471 
    1472   return p_Var( NUM(f), R );
    1473 }
  • libpolys/polys/ext_fields/transext.h

    rce1f78 r7fee876  
    130130*/
    131131
    132 /// return the specified parameter as a number in the given trans.ext.
    133 number ntParam(short iParameter, const coeffs cf);
    134 
    135132/// if m == var(i)/1 => return i,
    136133int ntIsParam(number, const coeffs);
  • libpolys/polys/monomials/maps.cc

    rce1f78 r7fee876  
    157157}
    158158
    159 void maFindPerm(char **preim_names, int preim_n, char **preim_par, int preim_p,
    160                 char **names,       int n,       char **par,       int nop,
     159void maFindPerm(char const * const * const preim_names, int preim_n, char const * const * const preim_par, int preim_p,
     160                char const * const * const names,       int n,       char const * const * const par,       int nop,
    161161                int * perm, int *par_perm, n_coeffType ch)
    162162{
  • libpolys/polys/monomials/maps.h

    rce1f78 r7fee876  
    2323poly maIMap(ring src_ring, ring dst_ring, poly p);
    2424
    25 void maFindPerm(char **preim_names, int preim_n, char **preim_par, int preim_p,
    26                 char **names,       int n,       char **par,       int nop,
     25void maFindPerm(char const * const * const preim_names, int preim_n, char const * const * const preim_par, int preim_p,
     26                char const * const * const names,       int n,       char const * const * const par,       int nop,
    2727                int * perm, int *par_perm, n_coeffType ch);
    2828poly pSubstPoly(poly p, int var, poly image);
  • libpolys/polys/monomials/p_polys.cc

    rce1f78 r7fee876  
    35203520            if (rField_is_GF(dst))
    35213521            {
    3522                assume( dst->cf->extRing == NULL );
    3523               number ee = nfPar(1, dst->cf); // NOTE: using nfPar is a BAD thing to do...
     3522              assume( dst->cf->extRing == NULL );
     3523              number ee = n_Param(1, dst);
    35243524
    35253525              number eee;
  • libpolys/polys/monomials/ring.cc

    rce1f78 r7fee876  
    276276  {
    277277    PrintS("//   characteristic : ");
    278     if (rParameter(r)!=NULL)
     278   
     279    char const * const * const params = rParameter(r);
     280   
     281    if (params!=NULL)
    279282    {
    280283      Print ("//   %d parameter    : ",rPar(r));
    281       char **sp= rParameter(r);
     284     
     285      char const * const * sp= params;
    282286      int nop=0;
    283287      while (nop<rPar(r))
     
    291295      {
    292296        // i^2+1:
    293         Print("(%s^2+1)\n",rParameter(r)[0]);
     297        Print("(%s^2+1)\n", params[0]);
    294298      }
    295299      else if (rMinpolyIsNULL(r))
     
    666670    return omStrDup("real"); /* short real */
    667671  }
    668   char **params = rParameter(r);
     672  char const * const * const params = rParameter(r);
    669673  if (params==NULL)
    670674  {
     
    690694  for(i=0; i<rPar(r);i++)
    691695  {
    692     l+=(strlen(rParameter(r)[i])+1);
     696    l+=(strlen(params[i])+1);
    693697  }
    694698  s=(char *)omAlloc((long)(l+MAX_INT_LEN+1));
     
    701705  {
    702706    strcat(s,tt);
    703     strcat(s,rParameter(r)[i]);
     707    strcat(s,params[i]);
    704708  }
    705709  return s;
     
    709713{
    710714  if ((r==NULL)||(rParameter(r)==NULL)) return omStrDup("");
     715
     716  char const * const * const params = rParameter(r);
    711717
    712718  int i;
     
    715721  for (i=0; i<rPar(r); i++)
    716722  {
    717     l+=strlen(rParameter(r)[i])+1;
     723    l+=strlen(params[i])+1;
    718724  }
    719725  char *s=(char *)omAlloc((long)l);
     
    721727  for (i=0; i<rPar(r)-1; i++)
    722728  {
    723     strcat(s,rParameter(r)[i]);
     729    strcat(s, params[i]);
    724730    strcat(s,",");
    725731  }
    726   strcat(s,rParameter(r)[i]);
     732  strcat(s, params[i]);
    727733  return s;
    728734}
     
    56345640
    56355641
    5636 
    5637 number n_Param(const short iParameter, const ring r)
     5642/// TODO: rewrite somehow...
     5643int n_IsParam(const number m, const ring r)
    56385644{
    56395645  assume(r != NULL);
     
    56415647  assume(C != NULL);
    56425648
    5643   const n_coeffType _filed_type = getCoeffType(C);
    5644 
    5645   if ( iParameter <= 0 || iParameter > rPar(r) )
    5646     // Wrong parameter
    5647     return NULL;
    5648 
    5649   if( _filed_type == n_algExt )
    5650     return naParam(iParameter, C);
    5651 
    5652   if( _filed_type == n_transExt )
    5653     return ntParam(iParameter, C);
    5654 
    5655   return NULL;
    5656 }
    5657 
    5658 
    5659 
    5660 int n_IsParam(number m, const ring r)
    5661 {
    5662   assume(r != NULL);
    5663   const coeffs C = r->cf;
    5664   assume(C != NULL);
     5649  assume( nCoeff_is_Extension(C) );
    56655650
    56665651  const n_coeffType _filed_type = getCoeffType(C);
     
    56725657    return ntIsParam(m, C);
    56735658
     5659  Werror("n_IsParam: IsParam is not to be used for (coeff_type = %d)",getCoeffType(C));
     5660 
    56745661  return 0;
    56755662}
  • libpolys/polys/monomials/ring.h

    rce1f78 r7fee876  
    538538
    539539/// (r->cf->P)
    540 static inline short rPar(const ring r)
     540static inline int rPar(const ring r)
    541541{
    542542  assume(r != NULL);
     
    544544  assume(C != NULL);
    545545
    546   if( rField_is_Extension(r) )
    547   {
    548     const ring R = C->extRing;
    549     assume( R != NULL );
    550     return rVar( R );
    551   }
    552   else if (nCoeff_is_long_C(C))
    553   {
    554     return 1;
    555   }
    556   return 0;
     546  return n_NumberOfParameters(C);
     547//   if( nCoeff_is_Extension(C) )
     548//   {
     549//     const ring R = C->extRing;
     550//     assume( R != NULL );
     551//     return rVar( R );
     552//   }
     553//   else if (nCoeff_is_GF(C))
     554//   {
     555//     return 1;
     556//   }
     557//   else if (nCoeff_is_long_C(C))
     558//   {
     559//     return 1;
     560//   }
     561//   return 0;
    557562}
    558563
    559564
    560565/// (r->cf->parameter)
    561 static inline char** rParameter(const ring r)
     566static inline char const * const * rParameter(const ring r)
    562567{
    563568  assume(r != NULL);
     
    565570  assume(C != NULL);
    566571
    567   if( rField_is_Extension(r) ) // only alg / trans. exts...
    568   {
    569     const ring R = C->extRing;
    570     assume( R != NULL );
    571     return R->names;
    572   }
    573   else if (nCoeff_is_GF(C))
    574   {
    575     return &(C->m_nfParameter);
    576   }
    577   else if (nCoeff_is_long_C(C))
    578   {
    579     return &(C->complex_parameter);
    580   }
    581   return NULL;
     572  return n_ParameterNames(C);
     573//   if( nCoeff_is_Extension(C) ) // only alg / trans. exts...
     574//   {
     575//     const ring R = C->extRing;
     576//     assume( R != NULL );
     577//     return R->names;
     578//   }
     579//   else if (nCoeff_is_GF(C))
     580//   {
     581//     return &(C->m_nfParameter);
     582//   }
     583//   else if (nCoeff_is_long_C(C))
     584//   {
     585//     return &(C->complex_parameter);
     586//   }
     587//   return NULL;
    582588}
    583589
     
    585591/// polynomial ring, or NULL if invalid
    586592/// parameters (as variables) begin with 1!
    587 number n_Param(const short iParameter, const ring r);
     593static inline number n_Param(const short iParameter, const ring r)
     594{
     595  assume(r != NULL);
     596  const coeffs C = r->cf;
     597  assume(C != NULL);
     598  return n_Param(iParameter, C);
     599//   const n_coeffType _filed_type = getCoeffType(C);
     600//
     601//   if ( iParameter <= 0 || iParameter > rPar(r) )
     602//     // Wrong parameter
     603//     return NULL;
     604//
     605//   if( _filed_type == n_algExt )
     606//     return naParameter(iParameter, C);
     607//
     608//   if( _filed_type == n_transExt )
     609//     return ntParameter(iParameter, C);
     610//
     611//   if (_filed_type == n_GF)// if (nCoeff_is_GF(C))
     612//   {
     613//     number nfPar (int i, const coeffs);
     614//     return nfPar(iParameter, C);
     615//   }
     616//   
     617//   if (_filed_type == n_long_C) // if (nCoeff_is_long_C(C))
     618//   {
     619//     number   ngcPar(int i, const coeffs r);   
     620//     return ngcPar(iParameter, C);
     621//   }
     622//
     623//   return NULL;
     624}
    588625
    589626/// if m == var(i)/1 => return i,
     
    603640static inline BOOLEAN rIsExtension(const ring r)
    604641{
     642  assume(r != NULL);
     643  const coeffs C = r->cf;
     644  assume(C != NULL);
    605645//  assume( (rParameter(r)!=NULL) == rField_is_Extension(r) ); // ?
    606   return rField_is_Extension(r) || nCoeff_is_GF(r->cf) ;
     646  return nCoeff_is_Extension(C) || nCoeff_is_GF(C) || nCoeff_is_long_C(C);
    607647}
    608648
Note: See TracChangeset for help on using the changeset viewer.