Changeset 16f8f1 in git


Ignore:
Timestamp:
Mar 3, 2011, 2:26:34 PM (12 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
Children:
f47f569bdf07891fa2a30df0f1c5315e6fe1f5d1
Parents:
fb0a6994525982ae391932afdd4d24384a163fda
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2011-03-03 14:26:34+01:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:01:04+01:00
Message:
ADD: minor changes to coeffs, numbers and tests
Location:
libpolys
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/coeffs.h

    rfb0a699 r16f8f1  
    248248/// in case of an error return NULL
    249249coeffs nInitChar(n_coeffType t, void * parameter);
     250
    250251/// undo all initialisations
    251252void nKillChar(coeffs r);
     253
    252254/// initialisations after each ring change
    253255static inline void nSetChar(const coeffs r)
     
    257259}
    258260
    259 // nach einer heissen Diskussion
    260261void           nNew(number * a);
    261262#define n_New(n, r)           nNew(n)
     
    267268static inline number n_Copy(number n,    const coeffs r)
    268269{ return r->cfCopy(n, r); }
     270
    269271static inline void   n_Delete(number* p, const coeffs r)
    270272{ r->cfDelete(p, r); }
     
    272274static inline BOOLEAN n_Equal(number a, number b, const coeffs r)
    273275{ return r->cfEqual(a, b, r); }
     276
    274277static inline BOOLEAN n_IsZero(number n, const coeffs r)
    275278{ return r->cfIsZero(n,r); }
     279
    276280static inline BOOLEAN n_IsOne(number n,  const coeffs r)
    277281{ return r->cfIsOne(n,r); }
     282
    278283static inline BOOLEAN n_IsMOne(number n, const coeffs r)
    279284{ return r->cfIsMOne(n,r); }
     285
    280286static inline BOOLEAN n_GreaterZero(number n, const coeffs r)
    281287{ return r->cfGreaterZero(n,r); }
    282288// cfGreater?
     289
    283290#ifdef HAVE_RINGS
    284291static inline BOOLEAN n_IsUnit(number n, const coeffs r)
    285292{ return r->cfIsUnit(n,r); }
     293
    286294static inline number n_GetUnit(number n, const coeffs r)
    287295{ return r->cfGetUnit(n,r); }
     296
    288297static inline BOOLEAN n_DivBy(number a, number b, const coeffs r)
    289298{ return r->cfDivBy(a,b,r); }
  • libpolys/coeffs/numbers.cc

    rfb0a699 r16f8f1  
    146146    //n->cfGetUnit = (nMapFunc)NULL;
    147147#endif
    148   #if 0 /*vertagt*/
    149   if (nField_is_Extension(r))
    150   {
    151     //ntInitChar(c,TRUE,r);
    152     n->cfDelete       = ntDelete;
    153     n->nNormalize     = ntNormalize;
    154     n->cfInit         = ntInit;
    155     n->nPar           = ntPar;
    156     n->nParDeg        = ntParDeg;
    157     n->n_Int          = ntInt;
    158     n->nAdd           = ntAdd;
    159     n->nSub           = ntSub;
    160     n->nMult          = ntMult;
    161     n->nDiv           = ntDiv;
    162     n->nExactDiv      = ntDiv;
    163     n->nIntDiv        = ntIntDiv;
    164     n->nNeg           = ntNeg;
    165     n->nInvers        = ntInvers;
    166     //n->nCopy          = ntCopy;
    167     n->cfCopy         = nt_Copy;
    168     n->nGreater       = ntGreater;
    169     n->nEqual         = ntEqual;
    170     n->nIsZero        = ntIsZero;
    171     n->nIsOne         = ntIsOne;
    172     n->nIsMOne        = ntIsMOne;
    173     n->nGreaterZero   = ntGreaterZero;
    174     n->cfWrite        = ntWrite;
    175     n->nRead          = ntRead;
    176     n->nPower         = ntPower;
    177     n->nGcd           = ntGcd;
    178     n->nLcm           = ntLcm;
    179     n->cfSetMap       = ntSetMap;
    180     n->nName          = ntName;
    181     n->nSize          = ntSize;
    182     n->cfGetDenom     = napGetDenom;
    183     n->cfGetNumerator = napGetNumerator;
    184 #ifdef LDEBUG
    185     n->nDBTest        = naDBTest;
    186 #endif
    187   }
    188   #endif
    189148   
    190149    BOOLEAN nOK=TRUE;
  • libpolys/coeffs/test.cc

    rfb0a699 r16f8f1  
    2525#pragma GCC diagnostic ignored "-Wwrite-strings"
    2626
    27 bool Test(const coeffs r)
     27void Print(/*const*/ number a, const coeffs r, BOOLEAN eoln = TRUE)
     28{
     29  n_Test(a,r);
     30
     31  StringSetS("");
     32  n_Write(a, r);
     33
     34  char* s = NULL;
     35
     36  if( eoln )
     37    s = StringAppend("\n");
     38  else
     39    s = StringAppend("");
     40
     41  PrintS(s);
     42
     43  // free s?
     44}
     45
     46
     47void PrintSized(/*const*/ number a, const coeffs r, BOOLEAN eoln = TRUE)
     48{
     49  Print(a, r, FALSE);
     50  Print(", of size: %d", n_Size(a, r));
     51 
     52  if( eoln )
     53    PrintLn();
     54}
     55 
     56
     57
     58bool TestArith(const coeffs r)
    2859{
    2960  number a = n_Init(66666, r);
    3061   
    31   StringSetS("a: ");
    32   n_Test(a,r);
    33   n_Write(a, r);
    34   PrintS(StringAppend("\n"));
     62  PrintS("a: "); PrintSized(a, r);
    3563
    3664  number two = n_Init(2, r);
    3765 
    38   StringSetS("two: ");
    39   n_Test(two,r);
    40   n_Write(two, r);
    41   PrintS(StringAppend("\n"));
     66  PrintS("two: "); PrintSized(two, r);
    4267
    4368  if (getCoeffType(r) == n_GF) //some special test for GF
    4469  {
    45     number z = nfPar (0, r); // also any integer instead of 0
    46     StringSetS("Generator: ");
    47     n_Test(z,r); n_Write (z,r);
    48     PrintS(StringAppend("\n"));
     70    number z = nfPar (0, r); // also any integer instead of 0//?
     71
     72    PrintS("Generator: "); PrintSized(z, r);
     73   
    4974    n_Delete(&z, r);   
    5075  }
     
    5277  number aa = n_Add(a, a, r);
    5378
    54   StringSetS("aa = a + a: ");
    55   n_Test(aa,r); n_Write(aa, r);
    56   PrintS(StringAppend("\n"));
     79  PrintS("aa = a + a: "); PrintSized(aa, r);
    5780 
    5881  number aa2 = n_Mult(a, two, r);
    5982
    60   StringSetS("aa2 = a * 2: ");
    61   n_Test(aa2, r); n_Write(aa2, r);
    62   PrintS(StringAppend("\n"));
     83  PrintS("aa2 = a * 2: "); PrintSized(aa2, r);
    6384
    6485  number aa1 = n_Mult(two, a, r);
    6586 
    66   StringSetS("aa1 = 2 * a: ");
    67   n_Test(aa1,r); n_Write(aa1, r);
    68   PrintS(StringAppend("\n"));
    69 
     87  PrintS("aa1 = 2 * a: "); PrintSized(aa1, r);
    7088
    7189  n_Delete(&a, r);
     
    7593  a = n_Sub( aa, aa1, r );
    7694 
    77   StringSetS("a = aa - aa1: ");
    78   n_Test(a,r); n_Write(a, r);
    79   PrintS(StringAppend("\n"));
     95  PrintS("a = aa - aa1: "); PrintSized(a, r);
    8096
    8197  if( !n_IsZero(a, r) )
    82     WarnS("ERROR: a != 0 !!!\n");
     98    WarnS("TestArith: ERROR: a != 0 !!!\n");
    8399
    84100  n_Delete(&a, r);
    85101
    86 
    87 
    88102  a = n_Sub( aa, aa2, r );
    89103
    90   StringSetS("a = aa - aa2: ");
    91   n_Test(a,r); n_Write(a, r);
    92   PrintS(StringAppend("\n"));
     104  PrintS("a = aa - aa2: "); PrintSized(a, r);
    93105
    94106  if( !n_IsZero(a, r) )
    95     WarnS("ERROR: a != 0 !!!\n");
     107    WarnS("TestArith: ERROR: a != 0 !!!\n");
    96108
    97109  n_Delete(&a, r);
     
    100112  a = n_Sub( aa1, aa2, r );
    101113
    102   StringSetS("a = aa1 - aa2: ");
    103   n_Test(a,r); n_Write(a, r);
    104   PrintS(StringAppend("\n"));
     114  PrintS("a = aa1 - aa2: "); PrintSized(a, r);
    105115
    106116  if( !n_IsZero(a, r) )
    107     WarnS("ERROR: a != 0 !!!\n");
     117    WarnS("TestArith: ERROR: a != 0 !!!\n");
    108118
    109119  n_Delete(&a, r);
     
    112122 
    113123  if( !n_Equal(aa, aa1, r) )
    114     WarnS("ERROR: aa != aa1  !!!\n");
     124    WarnS("TestArith: ERROR: aa != aa1  !!!\n");
    115125
    116126  if( !n_Equal(aa, aa2, r) )
    117     WarnS("ERROR: aa != aa2  !!!\n");
     127    WarnS("TestArith: ERROR: aa != aa2  !!!\n");
    118128
    119129  if( !n_Equal(aa1, aa2, r) )
    120     WarnS("ERROR: aa1 != aa2  !!!\n");
     130    WarnS("TestArith: ERROR: aa1 != aa2  !!!\n");
    121131 
    122132
     
    235245  }
    236246
    237   bool ret = Test( r );
     247  bool ret = TestArith( r );
    238248
    239249  nKillChar( r );
     
    251261  n_coeffType type;
    252262
    253   // rings needed for: n_Zp_a, n_Q_a ?
    254 #ifdef HAVE_RINGS
    255   TODO(Frank, Segmentation fault! (if used wihout omalloc???). Please_ investigate!);
    256 /*
     263
     264#ifdef HAVE_RINGS
     265//  TODO(Frank, Segmentation fault! (if used wihout omalloc???). Please_ investigate!);
     266  type = nRegister( n_Z2m, nr2mInitChar); assume( type == n_Z2m );
     267  if( Test(type, (void*) 4) )
     268    c ++;
     269#endif
     270
     271  type = nRegister( n_Zp, npInitChar); assume( type == n_Zp );
     272  if( Test(type, (void*) 101) )
     273    c ++;
     274
     275#ifdef HAVE_RINGS
     276//  TODO(Frank, memmory corruption_ if used wihout omalloc??? Please_ investigate!);
     277
     278  type = nRegister( n_Z2m, nr2mInitChar); assume( type == n_Z2m );
     279  if( Test(type, (void*) 8) )
     280    c ++;
     281
     282#endif
     283
     284 
     285  type = nRegister( n_Q, nlInitChar); assume( type == n_Q );
     286  if( Test(type) )
     287    c ++;
     288
     289  type = nRegister( n_R, nrInitChar); assume( type == n_R );
     290  if( Test(type) )
     291    c ++;
     292
     293#ifdef HAVE_RINGS
     294  type = nRegister( n_Z, nrzInitChar); assume( type == n_Z ); // No need in GMP?
     295  if( Test(type) )
     296    c ++;
     297#endif
     298   type = nRegister( n_GF, nfInitChar); assume( type == n_GF );
     299
     300
     301   GFInfo* param = new GFInfo();
     302
     303   param->GFChar= 5;
     304   param->GFDegree= 12;
     305   param->GFPar_name= (const char*)"q";
     306
     307   if( Test(type, (void*) param) )
     308     c ++;
     309
     310   // it should not be used by numbers... right?
     311   // TODO: what is our policy wrt param-pointer-ownership?
     312   delete param;
     313   // Q: no way to deRegister a type?
     314
     315   param = new GFInfo();
     316
     317   param->GFChar= 5;
     318   param->GFDegree= 2;
     319   param->GFPar_name= (const char*)"Q";
     320
     321   if( Test(type, (void*) param) )
     322     c ++;
     323
     324   delete param;
     325
     326
     327
     328
     329#ifdef HAVE_RINGS
     330//  TODO(Somebody, This will result in memory corruption at Z_2^m later on (due to the succs. setGMPFloatDigits?)...!?); // ????
     331
     332  type = nRegister( n_Zn, nrnInitChar); assume( type == n_Zn );
     333
     334  if( Test(type, (void*) 3) )
     335    c ++;
     336
     337#endif
     338
     339  TODO(Somebody, floating arithmetics via GMP rely on two global variables (see setGMPFloatDigits). Please fix it!);
     340  setGMPFloatDigits( 10, 5 ); // Init global variables in mpr_complex.cc for gmp_float's... // Note that this seems also to be required for Z_2^m (and Zn?)!????
     341
     342
     343  type = nRegister( n_long_C, ngcInitChar); assume( type == n_long_C );
     344  if( Test(type) )
     345    c ++;
     346
     347  type = nRegister( n_long_R, ngfInitChar); assume( type == n_long_R );
     348  if( Test(type) )
     349    c ++;
     350
     351#ifdef HAVE_RINGS
    257352  type = nRegister( n_Z2m, nr2mInitChar); assume( type == n_Z2m );
    258353  if( Test(type, (void*) 2) )
    259354    c ++;
    260 */
    261 #endif
    262 
    263   type = nRegister( n_Zp, npInitChar); assume( type == n_Zp );
    264   if( Test(type, (void*) 11) )
    265     c ++;
    266 
    267 #ifdef HAVE_RINGS
    268   TODO(Frank, memmory corruption_ if used wihout omalloc??? Please_ investigate!);
    269 /*
    270   type = nRegister( n_Z2m, nr2mInitChar); assume( type == n_Z2m );
    271   if( Test(type, (void*) 2) )
    272     c ++;
    273 */   
    274 #endif
    275 
    276  
    277   type = nRegister( n_Q, nlInitChar); assume( type == n_Q );
    278   if( Test(type) )
    279     c ++;
    280 
    281   type = nRegister( n_R, nrInitChar); assume( type == n_R );
    282   if( Test(type) )
    283     c ++;
    284 
    285 #ifdef HAVE_RINGS
    286   type = nRegister( n_Z, nrzInitChar); assume( type == n_Z ); // No need in GMP?
    287   if( Test(type) )
    288     c ++;
    289 #endif
    290    GFInfo param;
    291    type = nRegister( n_GF, nfInitChar); assume( type == n_GF );
    292 
    293 
    294    param.GFChar= 5;
    295    param.GFDegree= 12;
    296    param.GFPar_name= (const char*)"q";
    297 
    298    if( Test(type, (void*) &param) )
    299      c ++;
    300 
    301 
    302    param.GFChar= 5;
    303    param.GFDegree= 2;
    304    param.GFPar_name= (const char*)"Q";
    305 
    306    if( Test(type, (void*) &param) )
    307      c ++;
    308 
    309 
    310   TODO(Somebody, floating arithmetics via GMP rely on two global variables (see setGMPFloatDigits). Please fix it!);
    311 
    312 
    313 
    314 #ifdef HAVE_RINGS
    315   TODO(Somebody, This will result in memory corruption at Z_2^m later on (due to the succs. setGMPFloatDigits?)...!?);
    316 /*
     355#endif
     356
     357
     358#ifdef HAVE_RINGS
    317359  type = nRegister( n_Zn, nrnInitChar); assume( type == n_Zn );
    318360
    319361  if( Test(type, (void*) 3) )
    320362    c ++;
    321 */
    322 #endif
    323 
    324   setGMPFloatDigits( 10, 5 ); // Init global variables in mpr_complex.cc for gmp_float's... // Note that this seems also to be required for Z_2^m (and Zn?)!????
    325 
    326 
    327   type = nRegister( n_long_C, ngcInitChar); assume( type == n_long_C );
    328   if( Test(type) )
    329     c ++;
    330 
    331   type = nRegister( n_long_R, ngfInitChar); assume( type == n_long_R );
    332   if( Test(type) )
    333     c ++;
    334 
    335 #ifdef HAVE_RINGS
    336   type = nRegister( n_Z2m, nr2mInitChar); assume( type == n_Z2m );
    337   if( Test(type, (void*) 2) )
    338     c ++;
    339 #endif
    340 
    341 
    342 #ifdef HAVE_RINGS
    343   type = nRegister( n_Zn, nrnInitChar); assume( type == n_Zn );
    344 
    345   if( Test(type, (void*) 3) )
    346     c ++;
    347 #endif
    348  
     363#endif
     364 
     365  // polynomial rings needed for: n_Zp_a, n_Q_a ?
    349366 
    350367  return c;
  • libpolys/polys/ext_fields/longtrans.cc

    rfb0a699 r16f8f1  
    3333int  ntParsToCopy;
    3434int  ntNumbOfPar;
     35
     36
     37  #if 0 /*vertagt*/
     38  if (nField_is_Extension(r))
     39  {
     40    //ntInitChar(c,TRUE,r);
     41    n->cfDelete       = ntDelete;
     42    n->nNormalize     = ntNormalize;
     43    n->cfInit         = ntInit;
     44    n->nPar           = ntPar;
     45    n->nParDeg        = ntParDeg;
     46    n->n_Int          = ntInt;
     47    n->nAdd           = ntAdd;
     48    n->nSub           = ntSub;
     49    n->nMult          = ntMult;
     50    n->nDiv           = ntDiv;
     51    n->nExactDiv      = ntDiv;
     52    n->nIntDiv        = ntIntDiv;
     53    n->nNeg           = ntNeg;
     54    n->nInvers        = ntInvers;
     55    //n->nCopy          = ntCopy;
     56    n->cfCopy         = nt_Copy;
     57    n->nGreater       = ntGreater;
     58    n->nEqual         = ntEqual;
     59    n->nIsZero        = ntIsZero;
     60    n->nIsOne         = ntIsOne;
     61    n->nIsMOne        = ntIsMOne;
     62    n->nGreaterZero   = ntGreaterZero;
     63    n->cfWrite        = ntWrite;
     64    n->nRead          = ntRead;
     65    n->nPower         = ntPower;
     66    n->nGcd           = ntGcd;
     67    n->nLcm           = ntLcm;
     68    n->cfSetMap       = ntSetMap;
     69    n->nName          = ntName;
     70    n->nSize          = ntSize;
     71    n->cfGetDenom     = napGetDenom;
     72    n->cfGetNumerator = napGetNumerator;
     73#ifdef LDEBUG
     74    n->nDBTest        = ntDBTest;
     75#endif
     76  }
     77  #endif
     78
    3579
    3680numberfunc  nacMult, nacSub, nacAdd, nacDiv, nacIntDiv;
Note: See TracChangeset for help on using the changeset viewer.