Changeset 7fee876 in git


Ignore:
Timestamp:
Mar 16, 2012, 9:26:19 PM (12 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
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"
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • Singular/ipshell.cc

    rce1f78 r7fee876  
    20742074      if (strcmp(rParameter(R)[i],R->names[j])==0)
    20752075      {
    2076         Warn("name conflict par(%d) and var(%d): `%s`, rename to `@@(%d)`",i+1,j+1,R->names[j],i+1);
    2077         omFree(rParameter(R)[i]);
    2078         rParameter(R)[i]=(char *)omAlloc(10);
    2079         sprintf(rParameter(R)[i],"@@(%d)",i+1);
     2076        Warn("name conflict par(%d) and var(%d): `%s`, renaming the VARIABLE to `@@(%d)`",i+1,j+1,R->names[j],i+1);
     2077//        omFree(rParameter(R)[i]);
     2078//        rParameter(R)[i]=(char *)omAlloc(10);
     2079//        sprintf(rParameter(R)[i],"@@(%d)",i+1);
     2080       
     2081        omFree(R->names[j]);
     2082        R->names[j]=(char *)omAlloc(10);
     2083        sprintf(R->names[j],"@@(%d)",i+1);
    20802084      }
    20812085    }
  • Singular/walk.cc

    rce1f78 r7fee876  
    19431943  res->VarOffset = NULL;
    19441944  res->ref=0;
    1945   if (currRing->cf->extRing!=NULL)
    1946     currRing->cf->extRing->ref++;
    1947 
    1948   if (rParameter (currRing)!=NULL)
    1949   {
    1950     res->cf->extRing->minideal->m[0]=p_Copy(currRing->cf->extRing->minideal->m[0],currRing->cf->extRing);
    1951     int l=rPar(currRing);
    1952     res->cf->extRing->names=(char **)omAlloc(l*sizeof(char_ptr));
    1953 
    1954     for(i=l-1;i>=0;i--)
    1955       rParameter (res)[i]=omStrDup(rParameter (currRing)[i]);
    1956   }
     1945
     1946  res->cf = currRing->cf; currRing->cf->ref++;
     1947           
     1948//   if (currRing->cf->extRing!=NULL)
     1949//     currRing->cf->extRing->ref++;
     1950//
     1951//   if (rParameter (currRing)!=NULL)
     1952//   {
     1953//     res->cf->extRing->minideal->m[0]=p_Copy(currRing->cf->extRing->minideal->m[0],currRing->cf->extRing);
     1954//     int l=rPar(currRing);
     1955//     
     1956//     res->cf->extRing->names=(char **)omAlloc(l*sizeof(char_ptr));
     1957//
     1958//     for(i=l-1;i>=0;i--)
     1959//       rParameter (res)[i]=omStrDup(rParameter (currRing)[i]);
     1960//   }
    19571961
    19581962  intvec* iva = va;
     
    20222026  r->VarOffset = NULL;
    20232027  r->ref=0;
    2024   if (currRing->cf->extRing!=NULL)
    2025     currRing->cf->extRing->ref++;
    2026 
    2027   if (rParameter (currRing)!=NULL)
    2028   {
    2029     r->cf->extRing->minideal->m[0]=p_Copy(currRing->cf->extRing->minideal->m[0], currRing->cf->extRing);
    2030     int l=rPar(currRing);
    2031     r->cf->extRing->names=(char **)omAlloc(l*sizeof(char_ptr));
    2032 
    2033     for(i=l-1;i>=0;i--)
    2034       rParameter(r)[i]=omStrDup(rParameter (currRing)[i]);
    2035   }
     2028
     2029  r->cf = currRing->cf; currRing->cf->ref++;
     2030 
     2031//   if (currRing->cf->extRing!=NULL)
     2032//     currRing->cf->extRing->ref++;
     2033//
     2034//   if (rParameter (currRing)!=NULL)
     2035//   {
     2036//     r->cf->extRing->minideal->m[0]=p_Copy(currRing->cf->extRing->minideal->m[0], currRing->cf->extRing);
     2037//     int l=rPar(currRing);
     2038//     r->cf->extRing->names=(char **)omAlloc(l*sizeof(char_ptr));
     2039//
     2040//     for(i=l-1;i>=0;i--)
     2041//       rParameter(r)[i]=omStrDup(rParameter (currRing)[i]);
     2042//   }
    20362043
    20372044
     
    20732080
    20742081
    2075   if (rParameter(currRing)!=NULL)
    2076   {
    2077     r->cf->extRing->minideal->m[0]=p_Copy(currRing->cf->extRing->minideal->m[0], currRing->cf->extRing);
    2078     int l=rPar(currRing);
    2079     r->cf->extRing->names=(char **)omAlloc(l*sizeof(char_ptr));
    2080 
    2081     for(i=l-1;i>=0;i--)
    2082       rParameter(r)[i]=omStrDup(rParameter(currRing)[i]);
    2083   }
     2082//   if (rParameter(currRing)!=NULL)
     2083//   {
     2084//     r->cf->extRing->minideal->m[0]=p_Copy(currRing->cf->extRing->minideal->m[0], currRing->cf->extRing);
     2085//     int l=rPar(currRing);
     2086//     r->cf->extRing->names=(char **)omAlloc(l*sizeof(char_ptr));
     2087//
     2088//     for(i=l-1;i>=0;i--)
     2089//       rParameter(r)[i]=omStrDup(rParameter(currRing)[i]);
     2090//   }
    20842091
    20852092  /* complete ring intializations */
  • libpolys/coeffs/coeffs.h

    rce1f78 r7fee876  
    195195   int (*cfParDeg)(number x,const coeffs r);
    196196
     197   /// create i^th parameter or NULL if not possible
     198   number  (*cfParameter)(const int i, const coeffs r);
     199
    197200#ifdef HAVE_FACTORY
    198201   number (*convFactoryNSingN)( const CanonicalForm n, const coeffs r);
     
    213216   n_coeffType type;
    214217
     218
     219   /// Number of Parameters in the coeffs (default 0)
     220   int iNumberOfParameters;
     221
     222   /// array containing the names of Parameters (default NULL)
     223   char const * const * pParameterNames;
     224   // NOTE that it replaces the following:
     225// char* complex_parameter; //< the name of sqrt(-1) in n_long_C , i.e. 'i' or 'j' etc...?
     226// char * m_nfParameter; //< the name of parameter in n_GF
     227
    215228   /////////////////////////////////////////////
    216229   // the union stuff
     
    227240
    228241//-------------------------------------------
    229   char* complex_parameter; //< the name of sqrt(-1), i.e. 'i' or 'j' etc...?
    230 
    231242#ifdef HAVE_RINGS
    232243  /* The following members are for representing the ring Z/n,
     
    282293  unsigned short *m_nfPlus1Table;
    283294  int *m_nfMinPoly;
    284   char * m_nfParameter;
    285 
     295 
    286296// ---------------------------------------------------
    287297// for Zp:
     
    636646}
    637647
     648/// Returns the number of parameters
     649static inline int n_NumberOfParameters(const coeffs r){ return r->iNumberOfParameters; }
     650
     651/// Returns a (const!) pointer to (const char*) names of parameters
     652static inline char const * const * n_ParameterNames(const coeffs r){ return r->pParameterNames; }
     653
     654
     655/// return the (iParameter^th) parameter as a NEW number
     656/// NOTE: parameter numbering: 1..n_NumberOfParameters(...)
     657static inline number n_Param(const int iParameter, const coeffs r)
     658{
     659  assume(r != NULL);
     660  assume((iParameter >= 1) || (iParameter <= n_NumberOfParameters(r)));
     661  assume(r->cfParameter != NULL);
     662  return r->cfParameter(iParameter, r); 
     663}
     664
     665
    638666static inline number  n_Init_bigint(number i, const coeffs dummy,
    639667                const coeffs dst)
  • libpolys/coeffs/ffields.cc

    rce1f78 r7fee876  
    77*/
    88
     9#include "config.h"
     10
     11#include <omalloc/omalloc.h>
     12
    913#include <misc/auxiliary.h>
    10 #include <string.h>
     14#include <misc/mylimits.h>
     15
     16#include <reporter/reporter.h>
     17#include <resources/feFopen.h>
     18
    1119#include <coeffs/coeffs.h>
    12 #include <misc/mylimits.h>
    13 #include <omalloc/omalloc.h>
    14 #include <reporter/reporter.h>
    1520#include <coeffs/numbers.h>
    1621#include <coeffs/ffields.h>
    17 #include <resources/feFopen.h>
     22
     23#include <string.h>
    1824#include <math.h>
    1925
     26BOOLEAN nfGreaterZero (number k, const coeffs r);
     27number  nfMult        (number a, number b, const coeffs r);
     28number  nfInit        (long i, const coeffs r);
     29number  nfParameter   (int i, const coeffs r);
     30int     nfParDeg      (number n, const coeffs r);
     31int     nfInt         (number &n, const coeffs r);
     32number  nfAdd         (number a, number b, const coeffs r);
     33number  nfSub         (number a, number b, const coeffs r);
     34void    nfPower       (number a, int i, number * result, const coeffs r);
     35BOOLEAN nfIsZero      (number a, const coeffs r);
     36BOOLEAN nfIsOne       (number a, const coeffs r);
     37BOOLEAN nfIsMOne      (number a, const coeffs r);
     38number  nfDiv         (number a, number b, const coeffs r);
     39number  nfNeg         (number c, const coeffs r);
     40number  nfInvers      (number c, const coeffs r);
     41BOOLEAN nfGreater     (number a, number b, const coeffs r);
     42BOOLEAN nfEqual       (number a, number b, const coeffs r);
     43const char *  nfRead  (const char *s, number *a, const coeffs r);
     44#ifdef LDEBUG
     45BOOLEAN nfDBTest      (number a, const char *f, const int l, const coeffs r);
     46#endif
     47//void    nfSetChar     (const coeffs r);
     48
     49nMapFunc nfSetMap     (const coeffs src, const coeffs dst);
     50char *  nfName        (number n, const coeffs r);
     51void    nfReadTable   (const int c, const coeffs r);
     52
     53void    nfCoeffWrite(const coeffs r, BOOLEAN details);
     54void    nfShowMipo(const coeffs r);
     55
     56
     57
     58/// Our Type!
     59static const n_coeffType ID = n_GF;
    2060
    2161//unsigned short *nfPlus1Table=NULL; /* the table i=log(z^i) -> log(z^i+1) */
     
    184224* the generating element `z`
    185225*/
    186 number nfPar (int i, const coeffs)
     226number nfParameter (int i, const coeffs)
    187227{
    188228  assume(i==1);
    189   return (number)1;
     229 
     230  if( i == 1 )
     231    return (number)1;
     232
     233  return NULL;
    190234}
    191235
     
    394438  else
    395439  {
    396     StringAppendS(r->m_nfParameter);
     440    StringAppendS(n_ParameterNames(r)[0]);
    397441    if ((long)a!=1L)
    398442    {
     
    416460  else
    417461  {
    418     StringAppendS(r->m_nfParameter);
     462    StringAppendS(n_ParameterNames(r)[0]);
    419463    if ((long)a!=1L)
    420464    {
     
    433477#endif
    434478  char *s;
    435   char *nfParameter=r->m_nfParameter;
     479  const char * const nf_Parameter=n_ParameterNames(r)[0];
    436480  if (((long)a==(long)r->m_nfCharQ) || ((long)a==0L)) return NULL;
    437481  else if ((long)a==1L)
    438482  {
    439     return omStrDup(nfParameter);
     483    return omStrDup(nf_Parameter);
    440484  }
    441485  else
    442486  {
    443     s=(char *)omAlloc(4+strlen(nfParameter));
    444     sprintf(s,"%s%d",nfParameter,(int)((long)a));
     487    s=(char *)omAlloc(4+strlen(nf_Parameter));
     488    sprintf(s,"%s%d",nf_Parameter,(int)((long)a));
    445489  }
    446490  return s;
     
    513557    *a = nfDiv(z,n,r);
    514558  }
    515   char *nfParameter=r->m_nfParameter;
    516   if (strncmp(s,nfParameter,strlen(nfParameter))==0)
    517   {
    518     s+=strlen(nfParameter);
     559  const char * const nf_Parameter = n_ParameterNames(r)[0];
     560  const int N = strlen(nf_Parameter);
     561  if (strncmp(s,nf_Parameter, N)==0)
     562  {
     563    s += N;
    519564    if ((*s >= '0') && (*s <= '9'))
    520565    {
     
    573618    j++;
    574619    if (nfMinPoly[j]!=0)
    575       StringAppend("%d*%s^%d",nfMinPoly[j],r->m_nfParameter,i);
     620      StringAppend("%d*%s^%d",nfMinPoly[j],n_ParameterNames(r)[0],i);
    576621    i--;
    577622    if(i<0) break;
     
    779824static BOOLEAN nfCoeffIsEqual(const coeffs, n_coeffType, void*);
    780825
     826static void nfKillChar(coeffs r)
     827{
     828  char** p = (char**)n_ParameterNames(r);
     829
     830  const int P = n_NumberOfParameters(r);
     831 
     832  for( int i = 1; i <= P; i++ )
     833    if (p[i-1] != NULL)
     834      omFree( (ADDRESS)p[i-1] );
     835 
     836  omFreeSize((ADDRESS)p, P * sizeof(char*)); 
     837}
     838
    781839BOOLEAN nfInitChar(coeffs r,  void * parameter)
    782840{
    783841  //r->cfInitChar=npInitChar;
    784   //r->cfKillChar=nfKillChar;
     842  r->cfKillChar=nfKillChar;
    785843  r->nCoeffIsEqual=nfCoeffIsEqual;
    786844
     
    844902  r->m_nfCharP = p->GFChar;
    845903  r->m_nfCharQ1 = 0;
    846   r->m_nfParameter= omStrDup(name); //TODO use omAlloc for allocating memory and use strcpy?
     904
     905  r->iNumberOfParameters = 1;
     906  r->cfParameter = nfParameter;
     907
     908  char ** pParameterNames = (char **) omAlloc0(sizeof(char *));
     909  pParameterNames[0] = omStrDup(name); //TODO use omAlloc for allocating memory and use strcpy?
     910
     911  assume( pParameterNames != NULL );
     912  assume( pParameterNames[0] != NULL );
     913 
     914  r->pParameterNames = pParameterNames;
     915  // NOTE: r->m_nfParameter was replaced by n_ParameterNames(r)[0]
     916
     917  // TODO: nfKillChar MUST destroy r->pParameterNames[0] (0-term. string) && r->pParameterNames (array of size 1)
     918
    847919  r->m_nfPlus1Table= NULL;
    848920
     
    893965  // m_nfCharQ = p^k where p is the characteristic (r->CharP) and k is GFDegree
    894966  Print("//   # ground field : %d\n",r->m_nfCharQ);
    895   Print("//   primitive element : %s\n", r->m_nfParameter);
     967  Print("//   primitive element : %s\n", n_ParameterNames(r)[0]);
    896968  if ( details )
    897969  {
     
    908980    GFInfo* p = (GFInfo *)(parameter);
    909981    int c = pow (p->GFChar, p->GFDegree);
    910     if ((c == r->m_nfCharQ) && (strcmp(r->m_nfParameter,p->GFPar_name) == 0))
     982    if ((c == r->m_nfCharQ) && (strcmp(n_ParameterNames(r)[0], p->GFPar_name) == 0))
    911983      return TRUE;
    912984  }
  • libpolys/coeffs/ffields.h

    rce1f78 r7fee876  
    88* ABSTRACT: finite fields with a none-prime number of elements (via tables)
    99*/
    10 #include <coeffs/coeffs.h>
     10#include <misc/auxiliary.h>
    1111
     12struct n_Procs_s;
     13typedef struct  n_Procs_s  *coeffs;
     14
     15//// Initialize r (n_GF)
    1216BOOLEAN nfInitChar(coeffs r, void*);
    1317
    14 BOOLEAN nfGreaterZero (number k, const coeffs r);
    15 number  nfMult        (number a, number b, const coeffs r);
    16 number  nfInit        (long i, const coeffs r);
    17 number  nfPar         (int i, const coeffs r);
    18 int     nfParDeg      (number n, const coeffs r);
    19 int     nfInt         (number &n, const coeffs r);
    20 number  nfAdd         (number a, number b, const coeffs r);
    21 number  nfSub         (number a, number b, const coeffs r);
    22 void    nfPower       (number a, int i, number * result, const coeffs r);
    23 BOOLEAN nfIsZero      (number a, const coeffs r);
    24 BOOLEAN nfIsOne       (number a, const coeffs r);
    25 BOOLEAN nfIsMOne      (number a, const coeffs r);
    26 number  nfDiv         (number a, number b, const coeffs r);
    27 number  nfNeg         (number c, const coeffs r);
    28 number  nfInvers      (number c, const coeffs r);
    29 BOOLEAN nfGreater     (number a, number b, const coeffs r);
    30 BOOLEAN nfEqual       (number a, number b, const coeffs r);
    31 void    nfWrite       (number &a, const coeffs r);
    32 const char *  nfRead  (const char *s, number *a, const coeffs r);
    33 #ifdef LDEBUG
    34 BOOLEAN nfDBTest      (number a, const char *f, const int l, const coeffs r);
     18/// Show the mininimal polynom....
     19/// NOTE: this is used by char *  sleftv::String(void *d, BOOLEAN typed, int dim) (from Singular/subexpr.cc)
     20/// TODO: rewrite this UGLYNESS!!!
     21void    nfShowMipo(const coeffs r);
     22
    3523#endif
    36 //void    nfSetChar     (const coeffs r);
    37 
    38 nMapFunc nfSetMap     (const coeffs src, const coeffs dst);
    39 char *  nfName        (number n, const coeffs r);
    40 void    nfReadTable   (const int c, const coeffs r);
    41 
    42 void    nfCoeffWrite(const coeffs r, BOOLEAN details);
    43 void    nfShowMipo(const coeffs r);
    44 #endif
  • libpolys/coeffs/gnumpc.cc

    rce1f78 r7fee876  
    1111#include "config.h"
    1212
     13#include <omalloc/omalloc.h>
     14
     15#include <misc/auxiliary.h>
     16#include <misc/mylimits.h>
     17
     18#include <reporter/reporter.h>
     19#include <resources/feFopen.h>
     20
    1321#include <coeffs/coeffs.h>
    1422#include <coeffs/numbers.h>
     23
    1524#include <coeffs/longrat.h>
    1625#include <coeffs/modulop.h>
     26
    1727#include <coeffs/gnumpc.h>
    1828#include <coeffs/gnumpfl.h>
     29#include <coeffs/shortfl.h>
     30
    1931#include <coeffs/mpr_complex.h>
    20 #include <reporter/reporter.h>
    21 #include <omalloc/omalloc.h>
    22 
    23 
    24 #include <coeffs/shortfl.h>
     32
     33
     34/// Get a mapping function from src into the domain of this type: long_C!
     35nMapFunc  ngcSetMap(const coeffs src, const coeffs dst);
     36
     37number ngcMapQ(number from, const coeffs r, const coeffs aRing);
     38
     39void ngcSetChar(const coeffs r);
     40
     41// Private interface should be hidden!!!
     42
     43/// Note: MAY NOT WORK AS EXPECTED!
     44BOOLEAN  ngcGreaterZero(number za, const coeffs r);
     45BOOLEAN  ngcGreater(number a, number b, const coeffs r);
     46BOOLEAN  ngcEqual(number a, number b, const coeffs r);
     47BOOLEAN  ngcIsOne(number a, const coeffs r);
     48BOOLEAN  ngcIsMOne(number a, const coeffs r);
     49BOOLEAN  ngcIsZero(number za, const coeffs r);
     50number   ngcInit(long i, const coeffs r);
     51int      ngcInt(number &n, const coeffs r);
     52number   ngcNeg(number za, const coeffs r);
     53number   ngcInvers(number a, const coeffs r);
     54number   ngcParameter(int i, const coeffs r);
     55number   ngcAdd(number la, number li, const coeffs r);
     56number   ngcSub(number la, number li, const coeffs r);
     57number   ngcMult(number a, number b, const coeffs r);
     58number   ngcDiv(number a, number b, const coeffs r);
     59void     ngcPower(number x, int exp, number *lu, const coeffs r);
     60number   ngcCopy(number a, const coeffs r);
     61number   ngc_Copy(number a, coeffs r);
     62const char * ngcRead (const char *s, number *a, const coeffs r);
     63void     ngcWrite(number &a, const coeffs r);
     64number   ngcRePart(number a, const coeffs r);
     65number   ngcImPart(number a, const coeffs r);
     66
     67void     ngcDelete(number *a, const coeffs r);
     68void     ngcCoeffWrite(const coeffs r, BOOLEAN details);
     69
     70#ifdef LDEBUG
     71BOOLEAN  ngcDBTest(number a, const char *f, const int l, const coeffs r);
     72#endif
     73
     74
     75// Why is this here? who needs it?
     76// number ngcMapQ(number from, const coeffs r, const coeffs aRing);
    2577
    2678/// Our Type!
     
    3890#endif
    3991
    40 /*
    41 number   ngcPar(int i, const coeffs r)
     92number   ngcParameter(int i, const coeffs r)
    4293{
    4394  assume( getCoeffType(r) == ID );
    4495  assume(i==1);
    4596
    46   gmp_complex* n= new gmp_complex( (long)0, (long)1 );
    47   return (number)n;
    48 }
    49 */
     97  if( i == 1 )
     98    return (number)(new gmp_complex( (long)0, (long)1 ));
     99
     100  return NULL; // new gmp_complex( )  // 0?
     101}
    50102
    51103/*2
     
    329381{
    330382  assume( getCoeffType(r) == ID );
    331   assume( r->complex_parameter != NULL );
     383  const char * const complex_parameter = n_ParameterNames(r)[0];
     384  assume( complex_parameter != NULL );
     385  const int N = strlen(complex_parameter);
    332386
    333387  if ((*s >= '0') && (*s <= '9'))
     
    339393    delete re;
    340394  }
    341   else if (strncmp(s, r->complex_parameter,strlen(r->complex_parameter))==0)
    342   {
    343     s+=strlen(r->complex_parameter);
     395  else if (strncmp(s, complex_parameter, N)==0)
     396  {
     397    s += N;
    344398    gmp_complex *aa=new gmp_complex((long)0,(long)1);
    345399    *a=(number)aa;
     
    385439        (p->float_len2 == r->float_len2)
    386440       )
    387       if (strcmp(p->par_name, r->complex_parameter) == 0)
     441      if (strcmp(p->par_name, n_ParameterNames(r)[0]) == 0)
    388442        return (TRUE);
    389443  }
     
    391445}
    392446
     447static void ngcKillChar(coeffs r)
     448{
     449  char** p = (char**)n_ParameterNames(r);
     450
     451  const int P = n_NumberOfParameters(r);
     452
     453  for( int i = 1; i <= P; i++ )
     454    if (p[i-1] != NULL)
     455      omFree( (ADDRESS)p[i-1] );
     456
     457  omFreeSize((ADDRESS)p, P * sizeof(char*)); 
     458}
     459
    393460BOOLEAN ngcInitChar(coeffs n, void* parameter)
    394461{
    395462  assume( getCoeffType(n) == ID );
    396463
    397   n->cfKillChar = ndKillChar; /* dummy */
     464  n->cfKillChar = ngcKillChar;
    398465  n->ch = 0;
    399466
     
    496563  r->has_simple_Inverse=FALSE;
    497564*/
    498    
     565
     566  n->iNumberOfParameters = 1;
     567  n->cfParameter = ngcParameter;
     568
     569  char ** pParameterNames = (char **) omAlloc0(sizeof(char *));
     570
    499571  if( parameter != NULL)
    500572  {
    501573    LongComplexInfo* p = (LongComplexInfo*)parameter;
    502     n->complex_parameter = omStrDup(p->par_name);
     574    pParameterNames[0] = omStrDup(p->par_name); //TODO use omAlloc for allocating memory and use strcpy?
    503575    n->float_len = p->float_len;
    504576    n->float_len2 = p->float_len2;
     
    506578  } else // default values, just for testing!
    507579  {
    508     n->complex_parameter = omStrDup("i");
     580    pParameterNames[0] = omStrDup("i");
    509581    n->float_len = SHORT_REAL_LENGTH;
    510582    n->float_len2 = SHORT_REAL_LENGTH;     
     
    513585  assume( n->float_len <= n->float_len2 );
    514586  assume( n->float_len2 >= SHORT_REAL_LENGTH );
    515   assume( n->complex_parameter != NULL );
    516 
     587  assume( pParameterNames != NULL );
     588  assume( pParameterNames[0] != NULL );
     589 
     590  n->pParameterNames = pParameterNames;
     591
     592  // NOTE: n->complex_parameter was replaced by n_ParameterNames(n)[0]
     593  // TODO: nfKillChar MUST destroy n->pParameterNames[0] (0-term. string) && n->pParameterNames (array of size 1)
     594 
    517595  return FALSE;
    518596}
     
    623701  Print("//   characteristic : 0 (complex:%d digits, additional %d digits)\n",
    624702        r->float_len, r->float_len2);  /* long C */
    625   Print("//   1 parameter    : %s\n", r->complex_parameter);
    626   Print("//   minpoly        : (%s^2+1)\n", r->complex_parameter); 
    627 }
     703  Print("//   1 parameter    : %s \n", n_ParameterNames(r)[0]); // this trailing space is for compatibility with the legacy Singular
     704  Print("//   minpoly        : (%s^2+1)\n", n_ParameterNames(r)[0]); 
     705}
  • libpolys/coeffs/gnumpc.h

    rce1f78 r7fee876  
    88* ABSTRACT: computations with GMP floating-point numbers
    99*/
    10 #include <coeffs/coeffs.h>
     10#include <misc/auxiliary.h>
    1111
    12 /// Get a mapping function from src into the domain of this type: long_C!
    13 nMapFunc  ngcSetMap(const coeffs src, const coeffs dst);
     12struct n_Procs_s;
     13typedef struct  n_Procs_s  *coeffs;
    1414
    15 /// Initialize r
     15/// Initialize r (n_long_C)
    1616BOOLEAN ngcInitChar(coeffs r, void*);
    1717
    18 void ngcSetChar(const coeffs r);
    19 
    20 // Private interface should be hidden!!!
    21      
    22 /// Note: MAY NOT WORK AS EXPECTED!
    23 BOOLEAN  ngcGreaterZero(number za, const coeffs r);
    24 BOOLEAN  ngcGreater(number a, number b, const coeffs r);
    25 BOOLEAN  ngcEqual(number a, number b, const coeffs r);
    26 BOOLEAN  ngcIsOne(number a, const coeffs r);
    27 BOOLEAN  ngcIsMOne(number a, const coeffs r);
    28 BOOLEAN  ngcIsZero(number za, const coeffs r);
    29 number   ngcInit(long i, const coeffs r);
    30 int      ngcInt(number &n, const coeffs r);
    31 number   ngcNeg(number za, const coeffs r);
    32 number   ngcInvers(number a, const coeffs r);
    33 number   ngcPar(int i, const coeffs r);
    34 number   ngcAdd(number la, number li, const coeffs r);
    35 number   ngcSub(number la, number li, const coeffs r);
    36 number   ngcMult(number a, number b, const coeffs r);
    37 number   ngcDiv(number a, number b, const coeffs r);
    38 void     ngcPower(number x, int exp, number *lu, const coeffs r);
    39 number   ngcCopy(number a, const coeffs r);
    40 number   ngc_Copy(number a, coeffs r);
    41 const char * ngcRead (const char *s, number *a, const coeffs r);
    42 void     ngcWrite(number &a, const coeffs r);
    43 number   ngcRePart(number a, const coeffs r);
    44 number   ngcImPart(number a, const coeffs r);
    45 
    46 void     ngcDelete(number *a, const coeffs r);
    47 void     ngcCoeffWrite(const coeffs r, BOOLEAN details);
    48 
    49 #ifdef LDEBUG
    50 BOOLEAN  ngcDBTest(number a, const char *f, const int l, const coeffs r);
    51 #endif
    52 
    53 
    54 number ngcMapQ(number from, const coeffs r, const coeffs aRing);
    5518#endif
    5619/* GMPCOMPLEX_H */
  • libpolys/coeffs/gnumpfl.cc

    rce1f78 r7fee876  
    454454  assume( n->float_len <= n->float_len2 );
    455455  assume( n->float_len2 >= SHORT_REAL_LENGTH );
    456   assume( n->complex_parameter == NULL );
     456 
     457  assume( n_NumberOfParameters(n) == 0 );
     458  assume( n_ParameterNames(n) == NULL );
    457459
    458460  return FALSE;
  • libpolys/coeffs/mpr_complex.cc

    rce1f78 r7fee876  
    708708char *complexToStr( gmp_complex & c, const unsigned int oprec, const coeffs src )
    709709{
    710   assume( src->complex_parameter != NULL );
     710  const char * complex_parameter = "I";
     711  int N = 1; // strlen(complex_parameter);
     712   
     713  if (nCoeff_is_long_C(src))
     714  {
     715    complex_parameter = n_ParameterNames(src)[0];
     716    N = strlen(complex_parameter);
     717  }
     718
     719  assume( complex_parameter != NULL && N > 0);
    711720 
    712721  char *out,*in_imag,*in_real;
     
    721730    if (nCoeff_is_long_C(src))
    722731    {
    723       int len=(strlen(in_real)+strlen(in_imag)+7+strlen(src->complex_parameter))*sizeof(char);
     732      int len=(strlen(in_real)+strlen(in_imag)+7+N)*sizeof(char);
    724733      out=(char*)omAlloc(len);
    725734      memset(out,0,len);
    726735      if (  !c.real().isZero() )  // (-23-i*5.43) or (15.1+i*5.3)
    727         sprintf(out,"(%s%s%s*%s)",in_real,c.imag().sign()>=0?"+":"-",src->complex_parameter,in_imag);
     736        sprintf(out,"(%s%s%s*%s)",in_real,c.imag().sign()>=0?"+":"-",complex_parameter,in_imag);
    728737      else // (-i*43) or (i*34)
    729738      {
    730739        if (c.imag().isOne())
    731           sprintf(out,"%s",src->complex_parameter);
     740          sprintf(out,"%s", complex_parameter);
    732741        else if (c.imag().isMOne())
    733           sprintf(out,"-%s",src->complex_parameter);
     742          sprintf(out,"-%s", complex_parameter);
    734743        else
    735           sprintf(out,"(%s%s*%s)",c.imag().sign()>=0?"":"-",src->complex_parameter,in_imag);
     744          sprintf(out,"(%s%s*%s)",c.imag().sign()>=0?"":"-", complex_parameter,in_imag);
    736745      }
    737746    }
  • libpolys/coeffs/numbers.cc

    rce1f78 r7fee876  
    9292}
    9393
     94static number ndParameter(const int i, const coeffs r)
     95{
     96  Werror("ndParameter: n_Parameter is not implemented/relevant for (coeff_type = %d)",getCoeffType(r));
     97  return NULL;
     98}
    9499
    95100BOOLEAN n_IsZeroDivisor( number a, const coeffs r)
     
    258263    n->cfFarey = ndFarey;
    259264    n->cfParDeg = ndParDeg;
     265   
     266    n->cfParameter = ndParameter;
    260267
    261268#ifdef HAVE_RINGS
     
    323330    assume(n->cfWriteShort!=NULL);
    324331
     332    assume(n->iNumberOfParameters>= 0);
     333
     334    assume( (n->iNumberOfParameters == 0 && n->pParameterNames == NULL) ||
     335            (n->iNumberOfParameters >  0 && n->pParameterNames != NULL) );           
     336
     337    assume(n->cfParameter!=NULL);
     338    assume(n->cfParDeg!=NULL);
    325339
    326340    if(n->cfWriteLong==NULL) Warn("cfWrite is NULL for coeff %d",t);
  • libpolys/coeffs/test.cc

    rce1f78 r7fee876  
    7777  PrintS("two: "); PrintSized(two, r);
    7878
    79   if (getCoeffType(r) == n_GF) //some special test for GF
    80   {
    81     number z = nfPar (0, r); // also any integer instead of 0//?
    82 
    83     PrintS("Generator: "); PrintSized(z, r);
     79  if (n_NumberOfParameters(r) > 0)
     80  {
     81    number z = n_Param(1, r); // also any integer instead of 0//?
     82
     83    PrintS("Parameter: "); PrintSized(z, r);
    8484   
    8585    n_Delete(&z, r);   
     
    214214  else if( type == n_long_C )
    215215  {
    216     assume( r->cfInit == ngcInit );
    217     assume( r->cfAdd == ngcAdd );
    218     assume( r->cfDelete == ngcDelete );   
     216//     assume( r->cfInit == ngcInit );
     217//     assume( r->cfAdd == ngcAdd );
     218//     assume( r->cfDelete == ngcDelete );   
    219219  }
    220220  else if( type == n_R )
     
    240240  else if( type == n_GF )
    241241  {
    242     assume( r->cfInit == nfInit );
    243     assume( r->cfAdd == nfAdd );
     242//     assume( r->cfInit == nfInit );
     243//     assume( r->cfAdd == nfAdd );
    244244    //assume( r->cfDelete == nfDelete );
    245245  }
  • 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
  • libpolys/tests/coeffs_test.h

    rce1f78 r7fee876  
    234234  }
    235235
    236 
    237   if (getCoeffType(r) == n_GF) //some special test for GF
    238   {
    239     number z = nfPar (0, r); // also any integer instead of 0//?
    240     clog << "Generator: "; PrintSized(z, r);
    241     n_Delete(&z, r);
     236  if (n_NumberOfParameters(r) > 0)
     237  {
     238    number z = n_Param(1, r); // also any integer instead of 0//?
     239    PrintS("Parameter: "); PrintSized(z, r);
     240    n_Delete(&z, r);   
    242241  }
     242   
    243243
    244244  clog << "Char: " << n_GetChar(r) << endl;
     
    294294    case n_long_C:
    295295    {
    296       TS_ASSERT_EQUALS( r->cfInit, ngcInit );
    297       TS_ASSERT_EQUALS( r->cfAdd, ngcAdd );
    298       TS_ASSERT_EQUALS( r->cfDelete, ngcDelete );
     296//       TS_ASSERT_EQUALS( r->cfInit, ngcInit );
     297//       TS_ASSERT_EQUALS( r->cfAdd, ngcAdd );
     298//       TS_ASSERT_EQUALS( r->cfDelete, ngcDelete );
    299299      break;
    300300    }
     
    308308    case n_GF:
    309309    {
    310       TS_ASSERT_EQUALS( r->cfInit, nfInit );
    311       TS_ASSERT_EQUALS( r->cfAdd, nfAdd );
     310//       TS_ASSERT_EQUALS( r->cfInit, nfInit );
     311//       TS_ASSERT_EQUALS( r->cfAdd, nfAdd );
    312312      //TS_ASSERT_EQUALS( r->cfDelete, nfDelete );
    313313      break;
Note: See TracChangeset for help on using the changeset viewer.