Changeset 7af488e in git


Ignore:
Timestamp:
May 27, 2011, 11:39:02 AM (13 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '2a584933abf2a2d3082034c7586d38bb6de1a30a')
Children:
9bb545791780a99344a26d6177decb3870f6da87
Parents:
6ccdd3ad26bd7de442ab57e7cc95352fcf0de398
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2011-05-27 11:39:02+02:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:39:06+01:00
Message:
nRegister not needed any more for standard coeffs
Location:
libpolys
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/numbers.cc

    r6ccdd3a r7af488e  
    3030#endif
    3131
     32#ifdef HAVE_POLYEXTENSIONS
     33#include <polys/ext_fields/algext.h>
     34#endif
     35
    3236#ifdef HAVE_FACTORY
    3337#include <factory/factory.h>
     
    153157}
    154158
    155 static n_coeffType nLastCoeffs=n_Z2m;
    156 static cfInitCharProc *nInitCharTable=NULL;
     159static n_coeffType nLastCoeffs=n_CF;
     160cfInitCharProc nInitCharTableDefault[]=
     161{ NULL,        /*n_unknown */
     162 npInitChar,   /* n_Zp */
     163 nlInitChar,   /* n_Q */
     164 nrInitChar,   /* n_R */
     165 nfInitChar,   /* n_GF */
     166 ngfInitChar,  /* n_long_R */
     167 #ifdef HAVE_POLYEXTENSIONS
     168 naInitChar,  /* n_algExt */
     169 #else
     170 NULL,        /* n_algExt */
     171 #endif
     172 NULL, /* n_transExt */
     173 ngcInitChar,  /* n_long_C */
     174 #ifdef HAVE_RINGS
     175 nrzInitChar,  /* n_Z */
     176 nrnInitChar,  /* n_Zn */
     177 NULL,         /* n_Zpn */
     178 nr2mInitChar, /* n_Z2m */
     179 #else
     180 NULL,         /* n_Z */
     181 NULL,         /* n_Zn */
     182 NULL,         /* n_Zpn */
     183 NULL,         /* n_Z2m */
     184 #endif
     185 NULL   /* n_CF */
     186};
     187
     188static cfInitCharProc *nInitCharTable=nInitCharTableDefault;
    157189/*2
    158190* init operations for coeffs r
     
    206238    BOOLEAN nOK=TRUE;
    207239    // init
    208     if ((nInitCharTable!=NULL) && (t<=nLastCoeffs))
     240    if ((t<=nLastCoeffs) && (nInitCharTable[t]!=NULL))
    209241      nOK = (nInitCharTable[t])(n,parameter);
    210242    else
    211        Werror("coeff init missing for %d",(int)t);
     243       Werror("nInitCharTable[%d] missing",(int)t);
    212244    if (nOK)
    213245    {
     
    311343}
    312344
     345
    313346n_coeffType nRegister(n_coeffType n, cfInitCharProc p)
    314347{
     
    316349  {
    317350    nLastCoeffs=(n_coeffType)(int(nLastCoeffs)+1);
    318     if (nInitCharTable==NULL)
     351    if (nInitCharTable==nInitCharTableDefault)
    319352    {
    320353      nInitCharTable=(cfInitCharProc*)omAlloc0(
    321354                                          nLastCoeffs*sizeof(cfInitCharProc));
     355      memcpy(nInitCharTable,nInitCharTableDefault,
     356              (nLastCoeffs-1)*sizeof(cfInitCharProc));
    322357    }
    323358    else
     
    333368  else
    334369  {
    335     if (nInitCharTable==NULL)
    336     {
    337       nInitCharTable=(cfInitCharProc*)omAlloc0(
    338                                          ((int) nLastCoeffs)*sizeof(cfInitCharProc));
    339     }
     370    if (nInitCharTable[n]!=NULL) Print("coeff %d already initialized\n",n);
    340371    nInitCharTable[n]=p;
    341372    return n;
  • libpolys/coeffs/test.cc

    r6ccdd3a r7af488e  
    274274#ifdef HAVE_RINGS
    275275//  TODO(Frank, Segmentation fault! (if used wihout omalloc???). Please_ investigate!);
    276   type = nRegister( n_Z2m, nr2mInitChar); assume( type == n_Z2m );
     276  type =  n_Z2m;
    277277  if( Test(type, (void*) 4) )
    278278    c ++;
    279279#endif
    280280
    281   type = nRegister( n_Zp, npInitChar); assume( type == n_Zp );
     281  type =  n_Zp;
    282282  if( Test(type, (void*) 101) )
    283283    c ++;
     
    286286//  TODO(Frank, memmory corruption_ if used wihout omalloc??? Please_ investigate!);
    287287
    288   type = nRegister( n_Z2m, nr2mInitChar); assume( type == n_Z2m );
     288  type = n_Z2m;
    289289  if( Test(type, (void*) 8) )
    290290    c ++;
     
    293293
    294294 
    295   type = nRegister( n_Q, nlInitChar); assume( type == n_Q );
    296   if( Test(type) )
    297     c ++;
    298 
    299   type = nRegister( n_R, nrInitChar); assume( type == n_R );
    300   if( Test(type) )
    301     c ++;
    302 
    303 #ifdef HAVE_RINGS
    304   type = nRegister( n_Z, nrzInitChar); assume( type == n_Z ); // No need in GMP?
    305   if( Test(type) )
    306     c ++;
    307 #endif
    308    type = nRegister( n_GF, nfInitChar); assume( type == n_GF );
     295  type =  n_Q;
     296  if( Test(type) )
     297    c ++;
     298
     299  type = n_R;
     300  if( Test(type) )
     301    c ++;
     302
     303#ifdef HAVE_RINGS
     304  type = n_Z;
     305  if( Test(type) )
     306    c ++;
     307#endif
     308   type = n_GF;
    309309
    310310
     
    340340//  TODO(Somebody, This will result in memory corruption at Z_2^m later on (due to the succs. setGMPFloatDigits?)...!?); // ????
    341341
    342   type = nRegister( n_Zn, nrnInitChar); assume( type == n_Zn );
     342  type = n_Zn;
    343343
    344344  if( Test(type, (void*) 3) )
     
    351351
    352352
    353   type = nRegister( n_long_C, ngcInitChar); assume( type == n_long_C );
    354   if( Test(type) )
    355     c ++;
    356 
    357   type = nRegister( n_long_R, ngfInitChar); assume( type == n_long_R );
    358   if( Test(type) )
    359     c ++;
    360 
    361 #ifdef HAVE_RINGS
    362   type = nRegister( n_Z2m, nr2mInitChar); assume( type == n_Z2m );
     353  type = n_long_C;
     354  if( Test(type) )
     355    c ++;
     356
     357  type = n_long_R;
     358  if( Test(type) )
     359    c ++;
     360
     361#ifdef HAVE_RINGS
     362  type = n_Z2m;
    363363  if( Test(type, (void*) 2) )
    364364    c ++;
     
    367367
    368368#ifdef HAVE_RINGS
    369   type = nRegister( n_Zn, nrnInitChar); assume( type == n_Zn );
     369  type = n_Zn;
    370370
    371371  if( Test(type, (void*) 3) )
  • libpolys/misc/auxiliary.h.in

    r6ccdd3a r7af488e  
    3939#endif
    4040
     41#ifndef HAVE_POLYEXTENSIONS
     42#undef HAVE_POLYEXTENSIONS
     43#endif
    4144// ----------------  end of parts/extensions
    4245// -----------------  configure stuff
  • libpolys/tests/coeffs_test.h

    r6ccdd3a r7af488e  
    370370   {
    371371#ifdef HAVE_RINGS
    372      n_coeffType type = nRegister( n_Z2m, nr2mInitChar); TS_ASSERT( type == n_Z2m );
     372     n_coeffType type = n_Z2m;
    373373     TS_ASSERT( Test(type, (void*) 4) );
    374374#endif
     
    377377   void test_Zp101()
    378378   {
    379      n_coeffType type = nRegister( n_Zp, npInitChar); TS_ASSERT( type == n_Zp );
     379     n_coeffType type = n_Zp;
    380380     TS_ASSERT( Test(type, (void*) 101) );
    381381   }
     
    384384   {
    385385#ifdef HAVE_RINGS
    386      n_coeffType type = nRegister( n_Z2m, nr2mInitChar); TS_ASSERT( type == n_Z2m );
     386     n_coeffType type =  n_Z2m;
    387387     TS_ASSERT( Test(type, (void*) 8) );
    388388#endif
    389389   }
    390390   
    391    void simple(const n_coeffType _type, cfInitCharProc p)
    392    {
    393      n_coeffType type = nRegister( _type, p);
     391   void simple(const n_coeffType _type)
     392   {
     393     n_coeffType type = _type;
    394394     TS_ASSERT( type == _type ); // ?
    395395     TS_ASSERT( Test(type) );
     
    398398   void test_Q()
    399399   {
    400      simple(n_Q, nlInitChar);
     400     simple(n_Q);
    401401   }
    402402   
    403403   void test_R()
    404404   {
    405      simple(n_R, nrInitChar);
     405     simple(n_R);
    406406   }
    407407
     
    410410   {
    411411#ifdef HAVE_RINGS
    412      simple(n_Z, nrzInitChar);  // No need in GMP?
     412     simple(n_Z);  // No need in GMP?
    413413#endif
    414414   }
     
    417417   void test_GF_toobig()
    418418   {
    419      n_coeffType type = nRegister( n_GF, nfInitChar);
    420      TS_ASSERT( type == n_GF );
     419     n_coeffType type = n_GF;
    421420
    422421     GFInfo param;
     
    436435     // TODO: what if it was already registered?
    437436     // Q: no way to deRegister a type?
    438      n_coeffType type = nRegister( n_GF, nfInitChar);
    439      TS_ASSERT( type == n_GF );
     437     n_coeffType type = n_GF;
    440438
    441439     GFInfo param;
     
    456454#ifdef HAVE_RINGS
    457455     //  TODO(Somebody, This will result in memory corruption at Z_2^m later on (due to the succs. setGMPFloatDigits?)...!?); // ????
    458      n_coeffType type = nRegister( n_Zn, nrnInitChar); TS_ASSERT( type == n_Zn );
     456     n_coeffType type = n_Zn;
    459457
    460458     TS_ASSERT( Test(type, (void*) 3) );
     
    465463   {
    466464#ifdef HAVE_RINGS
    467      n_coeffType type = nRegister( n_Z2m, nr2mInitChar); TS_ASSERT( type == n_Z2m );
     465     n_coeffType type = n_Z2m;
    468466
    469467     TS_ASSERT( Test(type, (void*) 2) );
     
    476474   {
    477475     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?)!????
    478      simple(n_long_R, ngfInitChar);
     476     simple(n_long_R);
    479477   }
    480478   
     
    482480   {
    483481     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?)!????
    484      simple(n_long_C, ngcInitChar);
     482     simple(n_long_C);
    485483   } 
    486484
  • libpolys/tests/polys_test.h

    r6ccdd3a r7af488e  
    3131    virtual bool setUpWorld()
    3232    {
    33    
     33
    3434      GlobalPrintingFixture::setUpWorld();
    35      
    36 
    37       TS_ASSERT_EQUALS( nRegister( n_Zp, npInitChar), n_Zp );
    38       TS_ASSERT_EQUALS( nRegister( n_GF, nfInitChar), n_GF );
    39       TS_ASSERT_EQUALS( nRegister( n_R, nrInitChar), n_R );
    40       TS_ASSERT_EQUALS( nRegister( n_Q, nlInitChar), n_Q );
    41       TS_ASSERT_EQUALS( nRegister( n_R, nrInitChar), n_R );
    42      
     35
     36
     37      //TS_ASSERT_EQUALS( nRegister( n_Zp, npInitChar), n_Zp );
     38      //TS_ASSERT_EQUALS( nRegister( n_GF, nfInitChar), n_GF );
     39      //TS_ASSERT_EQUALS( nRegister( n_R, nrInitChar), n_R );
     40      //TS_ASSERT_EQUALS( nRegister( n_Q, nlInitChar), n_Q );
     41      //TS_ASSERT_EQUALS( nRegister( n_R, nrInitChar), n_R );
     42
    4343#ifdef HAVE_RINGS
    44       TS_ASSERT_EQUALS( nRegister( n_Z, nrzInitChar), n_Z ); // these are UNusable at the moment!
     44      //TS_ASSERT_EQUALS( nRegister( n_Z, nrzInitChar), n_Z ); // these are UNusable at the moment!
    4545#endif
    46      
     46
    4747      return true;
    4848    }
     
    5959namespace
    6060{
    61  
     61
    6262  void PrintRing(const ring r)
    6363  {
     
    7171  {
    7272    p_Test(a,r);
    73    
     73
    7474    StringSetS("");
    7575    p_Write(a, r);
     
    7979    std::stringstream ss;  ss << s;
    8080
    81     StringSetS(""); 
     81    StringSetS("");
    8282    return ss.str();
    8383  }
     
    8787    std::clog << _2S(a, r) << ", of size: " << p_Size(a, r);
    8888
    89     if( eoln ) 
    90       std::clog << std::endl; 
     89    if( eoln )
     90      std::clog << std::endl;
    9191  }
    9292
     
    103103  TS_ASSERT_DIFFERS( r    , NULLp);
    104104  TS_ASSERT_DIFFERS( r->cf, NULLp);
    105  
    106  
     105
     106
    107107  clog << ( _2S("TEST: sum[0..") + _2S(N) + "]: ");
    108108  clog << endl;
     
    111111
    112112  const int ssss = (N * (N+1)) / 2;
    113  
     113
    114114  poly sum1 = p_ISet(ssss, r);
    115115  clog<< "poly(N*(N+1)/2) (int: " << ssss << "): "; PrintSized(sum1, r);
     
    122122  i = p_Mult_q(s, i, r); s = NULL;
    123123
    124   clog<< "poly(N)*poly(N+1): (int: "<< N*(N+1) << "): "; PrintSized(i, r); 
     124  clog<< "poly(N)*poly(N+1): (int: "<< N*(N+1) << "): "; PrintSized(i, r);
    125125
    126126  number t = n_Init(2, r->cf);
    127   clog<< "number(2): "; PrintSized(t, r->cf); 
     127  clog<< "number(2): "; PrintSized(t, r->cf);
    128128
    129129  if( !n_IsZero( t, r->cf) )
     
    132132    {
    133133      number ii = p_GetCoeff(i, r);
    134       clog<< "number(poly(N)*poly(N+1)): "; PrintSized(ii, r->cf); 
     134      clog<< "number(poly(N)*poly(N+1)): "; PrintSized(ii, r->cf);
    135135
    136136#ifdef HAVE_RINGS
     
    139139       res = p_Div_nn(i, t, r); i = NULL;
    140140    }
    141    
    142      
     141
     142
    143143
    144144    clog<< "(poly(N)*poly(N+1))/number(2): "; PrintSized(res, r);
     
    157157  } else
    158158    TS_ASSERT_EQUALS( n_GetChar(r->cf), 2);
    159  
     159
    160160  n_Delete(&t, r->cf);
    161161
     
    171171    ss = p_Add_q(ss, i, r); // ss -= i
    172172  }
    173  
    174   clog<< "ss(-sum): "; PrintSized(ss, r); 
     173
     174  clog<< "ss(-sum): "; PrintSized(ss, r);
    175175
    176176  ss = p_Neg(ss, r); // ss = -ss
    177  
     177
    178178  clog<< "real sum    : "; PrintSized(s, r);
    179   clog<< "real sum(--): "; PrintSized(ss, r); 
     179  clog<< "real sum(--): "; PrintSized(ss, r);
    180180
    181181  TS_ASSERT( p_EqualPolys(s, ss, r) );
     
    184184  TODO(somebody, fix the delete method!);
    185185
    186   Delete(sum1, r); 
     186  Delete(sum1, r);
    187187  Delete(res, r);
    188188
    189   Delete(s, r);   
    190   Delete(ss, r);   
     189  Delete(s, r);
     190  Delete(ss, r);
    191191
    192192  clog << ( " >>> TEST DONE!" );
     
    194194
    195195}
    196    
     196
    197197void Test(const ring r)
    198198{
     
    211211}
    212212
    213 class PolysTestSuite : public CxxTest::TestSuite 
     213class PolysTestSuite : public CxxTest::TestSuite
    214214{
    215215private:
     
    238238    number two = n_Init(2, r);
    239239
    240     number t = n_Init(1, r); 
    241     ndInpAdd(t, t, r); 
     240    number t = n_Init(1, r);
     241    ndInpAdd(t, t, r);
    242242    TS_ASSERT( n_Equal(two, t, r) );
    243243    n_Delete(&t, r);
    244  
     244
    245245    if( getCoeffType(r) == n_Q )
    246246    {
    247       number t = n_Init(1, r); 
     247      number t = n_Init(1, r);
    248248      nlInpAdd(t, t, r);
    249249      TS_ASSERT( n_Equal(two, t, r) );
    250250      n_Delete(&t, r);
    251251    }
    252  
     252
    253253    const int N = 66666;
    254254
    255255    number a = n_Init(N, r);
    256    
     256
    257257    clog<< "a: "; PrintSized(a, r);
    258258
     
    264264
    265265    clog<< "aa = a + a: "; PrintSized(aa, r);
    266  
     266
    267267    number aa2 = n_Mult(a, two, r);
    268268
     
    270270
    271271    number aa1 = n_Mult(two, a, r);
    272  
     272
    273273    clog<< "aa1 = 2 * a: "; PrintSized(aa1, r);
    274274
     
    277277
    278278    a = n_Sub( aa, aa1, r );
    279  
     279
    280280    clog<< "a = aa - aa1: "; PrintSized(a, r);
    281281
     
    303303    TS_ASSERT( n_Equal(aa, aa2, r) );
    304304    TS_ASSERT( n_Equal(aa1, aa2, r) );
    305  
     305
    306306    TS_ASSERT( n_Equal(aa0, aa, r) );
    307307    TS_ASSERT( n_Equal(aa0, aa1, r) );
     
    325325
    326326    const unsigned long ssss = (N * (N+1)) / 2;
    327    
     327
    328328    number sum1 = n_Init(ssss, r);
    329329    clog<< "N*(N+1)/2 (int: " << ssss << "): "; PrintSized(sum1, r);
     
    335335    ndInpMult(s, i, r);
    336336    n_Delete(&i, r);
    337    
    338     clog<< "N*(N+1): ("<< N*(N+1) << ")"; PrintSized(s, r); 
    339    
     337
     338    clog<< "N*(N+1): ("<< N*(N+1) << ")"; PrintSized(s, r);
     339
    340340    i = n_Init(2, r);
    341     clog<< "2: "; PrintSized(i, r); 
     341    clog<< "2: "; PrintSized(i, r);
    342342
    343343    if( !n_IsZero( i, r) )
     
    346346      TS_ASSERT( n_DivBy(s, i, r) );
    347347  #endif
    348        
     348
    349349      res = n_Div(s, i, r);
    350    
     350
    351351      clog<< "N*(N+1)/2: "; PrintSized(res, r);
    352352
     
    355355      TS_ASSERT( n_IsZeroDivisor(d, r) );
    356356      n_Delete(&d, r);
    357      
     357
    358358      if( n_GetChar(r) == 0 )
    359359      {
     
    363363    } else
    364364      TS_ASSERT_EQUALS( n_GetChar(r), 2);
    365    
     365
    366366
    367367    n_Delete(&s, r);  n_Delete(&i, r);
    368    
    369     n_Delete(&sum1, r); n_Delete(&res, r);   
    370    
     368
     369    n_Delete(&sum1, r); n_Delete(&res, r);
     370
    371371
    372372    s = n_Init(0  , r);
     
    379379      i = n_Neg(i, r);
    380380      ndInpAdd(ss, i, r); // ss -= i
    381      
    382       n_Delete(&i, r);   
     381
     382      n_Delete(&i, r);
    383383    }
    384     clog<< "ss: "; PrintSized(ss, r); 
     384    clog<< "ss: "; PrintSized(ss, r);
    385385
    386386    ss = n_Neg(ss, r); // ss = -ss
    387    
     387
    388388    clog<< "real sum    : "; PrintSized(s, r);
    389     clog<< "real sum(--): "; PrintSized(ss, r); 
     389    clog<< "real sum(--): "; PrintSized(ss, r);
    390390
    391391    TS_ASSERT( n_Equal(s, ss, r) );
    392392    TS_ASSERT( n_Equal(ss, s, r) );
    393393
    394     n_Delete(&s, r);   
    395     n_Delete(&ss, r);   
     394    n_Delete(&s, r);
     395    n_Delete(&ss, r);
    396396
    397397    clog << ( " >>> TEST DONE!" );
     
    405405
    406406    char* n[] = {"t"};
    407     ring r = rDefault( 13, 1, n);     
     407    ring r = rDefault( 13, 1, n);
    408408    TS_ASSERT_DIFFERS( r, NULLp );
    409409
     
    420420
    421421    Test(r);
    422      
     422
    423423    rDelete(r);
    424424  }
     
    429429
    430430    char* n[] = {"s"};
    431     ring r = rDefault( 0, 1, n);     
     431    ring r = rDefault( 0, 1, n);
    432432    TS_ASSERT_DIFFERS( r, NULLp );
    433433
     
    436436    TS_ASSERT( rField_is_Domain(r) );
    437437    TS_ASSERT( rField_is_Q(r) );
    438    
     438
    439439    TS_ASSERT( !rField_is_Zp(r) );
    440440    TS_ASSERT( !rField_is_Zp(r, 11) );
     
    446446    rDelete(r);
    447447  }
    448  
     448
    449449  void test_Z11_x_y_z()
    450450  {
    451451     clog << "Creating  Z/11[x, y, z]: " << endl;
    452      
     452
    453453     char* n[] = {"x", "y", "z"};
    454      ring r = rDefault( 11, 3, n);     
     454     ring r = rDefault( 11, 3, n);
    455455     TS_ASSERT_DIFFERS( r, NULLp );
    456456
    457457     PrintRing(r);
    458      
     458
    459459     TS_ASSERT( rField_is_Domain(r) );
    460460     TS_ASSERT( !rField_is_Q(r) );
     
    467467
    468468     Test(r);
    469      
     469
    470470     rDelete(r);
    471471  }
     
    475475
    476476     char* n[] = {"x", "y", "z", "u"};
    477      ring r = rDefault( 0, 4, n);     
     477     ring r = rDefault( 0, 4, n);
    478478     TS_ASSERT_DIFFERS( r, NULLp );
    479479
     
    489489
    490490     Test(r);
    491      
     491
    492492     rDelete(r);
    493493   }
     
    535535     rDelete(r); // kills 'cf' as well!
    536536   }
    537    
     537
    538538  void test_Q_Ext_a()
    539539  {
     
    548548    TS_ASSERT( rField_is_Domain(r) );
    549549    TS_ASSERT( rField_is_Q(r) );
    550    
     550
    551551    TS_ASSERT( !rField_is_Zp(r) );
    552552    TS_ASSERT( !rField_is_Zp(r, 11) );
     
    560560    minIdeal->m[0] = minPoly;                       // minIdeal = < a^2 + 1 >
    561561
    562     n_coeffType type = nRegister(n_algExt, naInitChar); 
     562    n_coeffType type = nRegister(n_algExt, naInitChar);
    563563    TS_ASSERT(type == n_algExt);
    564564
     
    566566    extParam.r = r;
    567567    extParam.i = minIdeal;
    568    
     568
    569569    clog << "Next create the extension field Q[a]/<a2+1>..." << endl;
    570570
    571571    const coeffs cf = nInitChar(type, &extParam);   // Q[a]/<a2+1>
    572    
     572
    573573    if( cf == NULL )
    574574      TS_FAIL("Could not get needed coeff. domain");
    575575
    576576    TS_ASSERT_DIFFERS( cf->cfCoeffWrite, NULLp );
    577  
     577
    578578    if( cf->cfCoeffWrite != NULL )
    579579    {
    580       clog << "Coeff-domain: "  << endl; 
     580      clog << "Coeff-domain: "  << endl;
    581581      n_CoeffWrite(cf); PrintLn();
    582582    }
    583    
     583
    584584    TS_ASSERT( nCoeff_is_algExt(cf) );
    585585    TS_ASSERT( !nCoeff_is_transExt(cf) );
    586    
     586
    587587    // some tests for the coefficient field represented by cf:
    588588    TestArithCf(cf);
     
    595595    clog << "Finally create the polynomial ring (Q[a]/<a2+1>)[x, y]..."
    596596         << endl;
    597    
     597
    598598    char* m[] = {"x", "y"};
    599599    ring s = rDefault(cf, 2, m);   // (Q[a]/<a2+1>)[x, y]
     
    613613
    614614    Test(s);
    615    
     615
    616616    clog << endl
    617617         << "Now let's compute some inverses in Q[a]/<a^2+1>..."
    618618         << endl;
    619    
     619
    620620    poly u;
    621621    u = NULL; plusTerm(u, 1, 1, 1, cf->extRing);
     
    649649    TS_ASSERT( rField_is_Domain(r) );
    650650    TS_ASSERT( rField_is_Q(r) );
    651    
     651
    652652    TS_ASSERT( !rField_is_Zp(r) );
    653653    TS_ASSERT( !rField_is_Zp(r, 11) );
     
    661661    minIdeal->m[0] = minPoly;                       // minIdeal = < b^7 + 17 >
    662662
    663     n_coeffType type = nRegister(n_algExt, naInitChar); 
     663    n_coeffType type = nRegister(n_algExt, naInitChar);
    664664    TS_ASSERT(type == n_algExt);
    665665
     
    667667    extParam.r = r;
    668668    extParam.i = minIdeal;
    669    
     669
    670670    clog << "Next create the extension field Q[b]/<b^7+17>..." << endl;
    671671
    672672    const coeffs cf = nInitChar(type, &extParam);   // Q[b]/<b^7+17>
    673    
     673
    674674    if( cf == NULL )
    675675      TS_FAIL("Could not get needed coeff. domain");
    676676
    677677    TS_ASSERT_DIFFERS( cf->cfCoeffWrite, NULLp );
    678  
     678
    679679    if( cf->cfCoeffWrite != NULL )
    680680    {
    681       clog << "Coeff-domain: "  << endl; 
     681      clog << "Coeff-domain: "  << endl;
    682682      n_CoeffWrite(cf); PrintLn();
    683683    }
    684    
     684
    685685    TS_ASSERT( nCoeff_is_algExt(cf) );
    686686    TS_ASSERT( !nCoeff_is_transExt(cf) );
    687    
     687
    688688    // some tests for the coefficient field represented by cf:
    689689    TestArithCf(cf);
     
    696696    clog << "Finally create the polynomial ring (Q[b]/<b^7+17>)[u, v, w]..."
    697697         << endl;
    698    
     698
    699699    char* m[] = {"u", "v", "w"};
    700700    ring s = rDefault(cf, 3, m);   // (Q[b]/<b^7+17>)[u, v, w]
     
    714714
    715715    Test(s);
    716    
     716
    717717    clog << endl
    718718         << "Now let's compute some inverses in Q[b]/<b^7+17>..."
    719719         << endl;
    720          
     720
    721721    poly u;
    722722    u = NULL; plusTerm(u, 1, 1, 2, cf->extRing);
     
    730730         << "Now let's check a gcd computation in Q[b]..."
    731731         << endl;
    732    
     732
    733733    poly v;
    734734    v = NULL; plusTerm(v, 1, 1, 2, cf->extRing);
     
    743743                      (number)v, cf);   // (b^2 + 7b + 1)^2 * (2b^2 - 61b)
    744744    p_Delete(&v, cf->extRing);
    745    
     745
    746746    clog << "z = "; p_Write((poly)z, cf->extRing);
    747747    clog << "y = "; p_Write((poly)y, cf->extRing);
    748748    number theGcd = n_Gcd(z, y, cf);   // should yield w = (b^2 + 7b + 1)^2
    749749    clog << "gcd(z, y) = "; p_Write((poly)theGcd, cf->extRing);
    750    
     750
    751751    v = (poly)n_Sub(theGcd, w, cf);
    752752    TS_ASSERT( v == NULL );
    753753    p_Delete(&v, cf->extRing);
    754    
     754
    755755    clog << endl
    756756         << "Now let's check an ext_gcd computation in Q[b]..."
    757757         << endl;
    758          
     758
    759759    poly zFactor; poly yFactor;
    760760    poly ppp = p_ExtGcd((poly)z, zFactor, (poly)y, yFactor, cf->extRing);
     
    772772    number v4 = n_Sub(v3, w, cf);
    773773    TS_ASSERT( v4 == NULL );
    774    
     774
    775775    p_Delete(&ppp, cf->extRing); p_Delete(&zFactor, cf->extRing);
    776776    p_Delete(&yFactor, cf->extRing);
     
    793793    TS_ASSERT( rField_is_Domain(r) );
    794794    TS_ASSERT( !rField_is_Q(r) );
    795    
     795
    796796    TS_ASSERT( rField_is_Zp(r) );
    797797    TS_ASSERT( rField_is_Zp(r, 17) );
     
    805805    minIdeal->m[0] = minPoly;                       // minIdeal = < a^2 + 3 >
    806806
    807     n_coeffType type = nRegister(n_algExt, naInitChar); 
     807    n_coeffType type = nRegister(n_algExt, naInitChar);
    808808    TS_ASSERT(type == n_algExt);
    809809
     
    811811    extParam.r = r;
    812812    extParam.i = minIdeal;
    813    
     813
    814814    clog << "Next create the extension field Z_17[a]/<a^2+3>..." << endl;
    815815
    816816    const coeffs cf = nInitChar(type, &extParam);   // Z_17[a]/<a^2+3>
    817    
     817
    818818    if( cf == NULL )
    819819      TS_FAIL("Could not get needed coeff. domain");
    820820
    821821    TS_ASSERT_DIFFERS( cf->cfCoeffWrite, NULLp );
    822    
     822
    823823    if( cf->cfCoeffWrite != NULL )
    824824    {
    825       clog << "Coeff-domain: "  << endl; 
     825      clog << "Coeff-domain: "  << endl;
    826826      n_CoeffWrite(cf); PrintLn();
    827827    }
    828    
     828
    829829    TS_ASSERT( nCoeff_is_algExt(cf) );
    830830    TS_ASSERT( !nCoeff_is_transExt(cf) );
    831    
     831
    832832    // some tests for the coefficient field represented by cf:
    833833    TestArithCf(cf);
     
    840840    clog << "Finally create the polynomial ring (Z_17[a]/<a^2+3>)[u, v, w]..."
    841841         << endl;
    842    
     842
    843843    char* m[] = {"u", "v", "w"};
    844844    ring s = rDefault(cf, 3, m);   // (Z_17[a]/<a^2+3>)[u, v, w]
  • libpolys/tests/rings_test.h

    r6ccdd3a r7af488e  
    3131     
    3232
    33       TS_ASSERT_EQUALS( nRegister( n_Zp, npInitChar), n_Zp );
    34       TS_ASSERT_EQUALS( nRegister( n_GF, nfInitChar), n_GF );
    35       TS_ASSERT_EQUALS( nRegister( n_R, nrInitChar), n_R );
    36       TS_ASSERT_EQUALS( nRegister( n_Q, nlInitChar), n_Q );
    37       TS_ASSERT_EQUALS( nRegister( n_R, nrInitChar), n_R );
     33      //TS_ASSERT_EQUALS( nRegister( n_Zp, npInitChar), n_Zp );
     34      //TS_ASSERT_EQUALS( nRegister( n_GF, nfInitChar), n_GF );
     35      //TS_ASSERT_EQUALS( nRegister( n_R, nrInitChar), n_R );
     36      //TS_ASSERT_EQUALS( nRegister( n_Q, nlInitChar), n_Q );
     37      //TS_ASSERT_EQUALS( nRegister( n_R, nrInitChar), n_R );
    3838     
    3939#ifdef HAVE_RINGS
    40       TS_ASSERT_EQUALS( nRegister( n_Z, nrzInitChar), n_Z ); // these are UNusable at the moment!
     40      //TS_ASSERT_EQUALS( nRegister( n_Z, nrzInitChar), n_Z ); // these are UNusable at the moment!
    4141#endif
    4242     
Note: See TracChangeset for help on using the changeset viewer.