Changeset e5422d in git


Ignore:
Timestamp:
Apr 19, 2011, 6:16:27 PM (13 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '648d28f488f6ff08f5607ff229b9ad9e4a5b93c2')
Children:
7f602bf34cba1848ae22dbe21a65ea4f2460604f
Parents:
8c99125adf3766ea3c93c4198e3f4aeed1b29b5f
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2011-04-19 18:16:27+02:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:31:20+01:00
Message:
fixed zero divisior issue in Z/2^mZ
coauthor: Frank Seelisch <seelisch@mathematik.uni-kl.de>
Location:
libpolys
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/numbers.cc

    r8c9912 re5422d  
    6666}
    6767#endif
     68
     69
     70BOOLEAN ndIsZeroDivisor( number a, const coeffs r)
     71{
     72  int c = n_GetChar(r);
     73  BOOLEAN ret = n_IsZero(a, r);
     74  if( (c != 0) && !ret )
     75  {
     76    number ch = n_Init( c, r );
     77    number g = n_Gcd( ch, a, r );
     78    ret = !n_IsOne (g, r);
     79    n_Delete(&ch, r);
     80    n_Delete(&g, r);
     81  }
     82  return ret;
     83}
    6884
    6985void   ndNormalize(number& d, const coeffs r) { }
  • libpolys/coeffs/numbers.h

    r8c9912 re5422d  
    7070void   ndInpAdd(number &a, number b, const coeffs r);
    7171
     72/// Test whether a is a zero divisor in r
     73/// i.e. not coprime with char. of r
     74BOOLEAN ndIsZeroDivisor( number a, const coeffs r);
     75
    7276#ifdef LDEBUG
    7377void nDBDummy1(number* d,char *f, int l);
  • libpolys/coeffs/rmodulo2m.cc

    r8c9912 re5422d  
    244244BOOLEAN nr2mEqual(number a, number b, const coeffs r)
    245245{
    246   return a == b;
     246  return (a == b);
    247247}
    248248
     
    623623    r->mod2mMask = 3; /* i.e., '11' in binary representation */
    624624  }
     625  r->ch = r->mod2mMask + 1;
    625626}
    626627
  • libpolys/tests/coeffs_test.h

    r8c9912 re5422d  
    3939 
    4040  number sum1 = n_Init(ssss, r);
    41   clog<< "sum1(int): "; PrintSized(sum1, r);
     41  clog<< "N*(N+1)/2 (int: " << ssss << "): "; PrintSized(sum1, r);
    4242
    4343  number s, ss, i, res;
     
    4848  n_Delete(&i, r);
    4949 
     50  clog<< "N*(N+1): ("<< N*(N+1) << ")"; PrintSized(s, r); 
     51 
    5052  i = n_Init(2, r);
     53  clog<< "2: "; PrintSized(i, r); 
    5154
    5255  if( !n_IsZero( i, r) )
     
    5558    res = n_Div(s, i, r);
    5659 
    57     clog<< "res: "; PrintSized(res, r);
    58 
    59     TS_ASSERT( n_Equal(sum1, res, r) );
    60     TS_ASSERT( n_Equal(res, sum1, r) );
     60    clog<< "N*(N+1)/2: "; PrintSized(res, r);
     61    number d = n_Sub(res, sum1, r);
     62   
     63    TS_ASSERT( ndIsZeroDivisor(d, r) );
     64   
     65    if( n_GetChar(r) == 0 )
     66    {
     67      TS_ASSERT( n_Equal(sum1, res, r) );
     68      TS_ASSERT( n_Equal(res, sum1, r) );
     69    }
    6170  } else
    6271    TS_ASSERT_EQUALS( n_GetChar(r), 2);
     
    8291
    8392  ss = n_Neg(ss, r); // ss = -ss
    84  
    85  
     93 
     94  clog<< "real sum    : "; PrintSized(s, r);
     95  clog<< "real sum(--): "; PrintSized(ss, r); 
     96
    8697  TS_ASSERT( n_Equal(s, ss, r) );
    8798  TS_ASSERT( n_Equal(ss, s, r) );
    8899
    89   clog<< "s: "; PrintSized(s, r);
    90   clog<< "ss: "; PrintSized(ss, r); 
    91 
    92100  n_Delete(&s, r);   
    93101  n_Delete(&ss, r);   
     102
     103  clog << ( " >>> TEST DONE!" );
     104  clog << endl;
     105
    94106}
    95107
     
    161173  n_Delete(&aa1, r);
    162174  n_Delete(&aa2, r);
     175
     176
     177  clog << ( " >>> TEST DONE!" );
     178  clog << endl;
     179
    163180}
    164181
     
    212229      TS_ASSERT(  nCoeff_is_Q( r ));
    213230      TS_ASSERT(  nCoeff_is_Domain( r ));
    214       TS_ASSERT(  nCoeff_has_Units( r ));
    215       TS_ASSERT(  nCoeff_has_simple_inverse( r ));// ?
    216       TS_ASSERT(  nCoeff_has_simple_Alloc( r )); // ?
     231
     232      TS_ASSERT( !nCoeff_has_Units( r )); // ?
     233      TS_ASSERT( !nCoeff_has_simple_inverse( r ));// ?
     234      TS_ASSERT( !nCoeff_has_simple_Alloc( r )); // ?
    217235
    218236      TS_ASSERT( !nCoeff_is_Ring_2toM( r ));
     
    291309
    292310  TestArith( r );
     311  TestSum( r, 10 );
    293312  TestSum( r, 100 );
    294   TestSum( r, 1000 );
     313  TestSum( r, 101 );
     314  TestSum( r, 1001 );
     315  TestSum( r, 9000 );
    295316
    296317  nKillChar( r );
    297 
    298   clog << ( " >>> TEST DONE!" );
    299   clog << endl;
    300318
    301319  return TRUE;
Note: See TracChangeset for help on using the changeset viewer.