Ignore:
Timestamp:
Jul 8, 2015, 5:21:19 PM (9 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
3f2942fb2df02ef47a6e1125188f5c588a05e8d2
Parents:
f0e1f60636ea63dea4a25bf2abff929dd68198db
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2015-07-08 17:21:19+02:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2015-07-08 17:22:49+02:00
Message:
Testing correctness in trans ext
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/ext_fields/transext.cc

    rf0e1f6 rfc2acf  
    7272
    7373#ifdef LDEBUG
    74 #define ntTest(a) ntDBTest(a,__FILE__,__LINE__,cf)
    7574BOOLEAN  ntDBTest(number a, const char *f, const int l, const coeffs r);
    76 #else
    77 #define ntTest(a) do {} while (0)
    7875#endif
     76
     77#define ntTest(a) n_Test(a, cf)
    7978
    8079/// Our own type!
     
    184183  //check_N(a,cf);
    185184  const poly num = NUM(t);
    186   assume(num != NULL);   /**< t != 0 ==> numerator(t) != 0 */
     185  assume(num != NULL);   ///< t != 0 ==> numerator(t) != 0
    187186
    188187  p_Test(num, ntRing);
    189188
     189  if (getCoeffType(ntCoeffs)==n_Q)
     190    for( poly p = num; p != NULL; pIter(p) )
     191      if (! nlIsInteger( p_GetCoeff(p, ntRing), ntCoeffs) )
     192      {
     193        Print("ERROR: non-integer Q coeff in num. poly in %s:%d\n",f,l);       
     194        return FALSE;     
     195      }
     196
    190197  const poly den = DEN(t);
    191198
     
    193200  {
    194201    p_Test(den, ntRing);
     202
     203    if (getCoeffType(ntCoeffs)==n_Q)
     204      for( poly p = den; p != NULL; pIter(p) )
     205        if (! nlIsInteger( p_GetCoeff(p, ntRing), ntCoeffs) )
     206        {
     207          Print("ERROR: non-integer Q coeff in den. poly in %s:%d\n",f,l);       
     208          return FALSE;     
     209        }
     210
     211    if (getCoeffType(ntCoeffs)==n_Zp)
     212    {
     213      if( p_IsConstant(den, ntRing) )
     214      {
     215        Print("ERROR: constant den. poly / Zp in %s:%d\n",f,l);       
     216        return FALSE;
     217      }
     218         
     219      if( !n_IsOne(pGetCoeff(den), ntCoeffs) )
     220      {       
     221        Print("ERROR: non-monic den. poly / Zp in %s:%d\n",f,l);       
     222        return FALSE;
     223      }
     224    }
     225   
     226    poly gcd = singclap_gcd_r( num, den, ntRing );
     227
     228    if( !(p_IsConstant(gcd, ntRing) && (n_IsOne(pGetCoeff(gcd), ntCoeffs))) )
     229    {
     230      Print("ERROR: 1 != GCD between num. & den. poly in %s:%d\n",f,l);       
     231      return FALSE;
     232    }
     233
     234    p_Delete( &gcd, ntRing );
     235
     236    return TRUE;
     237   
     238
     239   
    195240    if(p_IsConstant(den, ntRing) && (n_IsOne(pGetCoeff(den), ntCoeffs)))
    196241    {
     
    206251  }
    207252  else
    208   {  // num != NULL // den == NULL
     253  {
     254    return TRUE;
     255
     256    // num != NULL // den == NULL
    209257//    if( COM(t) != 0 )
    210258//    {
     
    279327  //check_N(*a,cf);
    280328  ntTest(*a); // !!!
     329 
    281330  fraction f = (fraction)(*a);
    282331  if (IS0(f)) return;
     
    580629  if (p == NULL) return NULL;
    581630
     631  p_Test( p, ntRing);
    582632  fraction f = (fraction)omAlloc0Bin(fractionObjectBin);
    583633
     
    792842     COM(result) = COM(fa);
    793843     //check_N((number)result,cf);
     844     ntTest((number)result);
    794845     return (number)result;
    795846  }
     
    804855
    805856  //check_N((number)result,cf);
     857  ntTest((number)result);
    806858  return (number)result;
    807859}
     
    845897
    846898  //check_N((number)result,cf);
     899  ntTest((number)result);
    847900  return (number)result;
    848901}
     
    883936//  ntTest((number)result);
    884937  //check_N((number)result,cf);
     938  ntTest((number)result);
    885939  return (number)result;
    886940}
     
    9531007
    9541008  //check_N((number)result,cf);
     1009  ntTest((number)result);
    9551010  return (number)result;
    9561011}
     
    9921047//  ntTest((number)result);
    9931048  //check_N((number)result,cf);
     1049  ntTest((number)result);
    9941050  return (number)result;
    9951051}
     
    12421298                             BOOLEAN simpleTestsHaveAlreadyBeenPerformed)
    12431299{
    1244   ntTest(a); // !!!!
     1300//  ntTest(a); // !!!!
    12451301
    12461302  fraction f = (fraction)a;
    12471303
    12481304  if (IS0(a)) return;
    1249   if (DENIS1(f) || NUMIS1(f)) { COM(f) = 0; return; }
     1305  if (DENIS1(f) || NUMIS1(f)) { COM(f) = 0; ntTest(a); return; }
    12501306  if (!simpleTestsHaveAlreadyBeenPerformed)
    12511307  {
     
    14421498  if (p == NULL) *a = NULL;
    14431499  else *a = ntInit(p, cf);
     1500  ntTest(*a);
    14441501  return result;
    14451502}
     
    15701627    return (number)result;
    15711628
    1572   return NULL;
     1629    return NULL;
    15731630}
    15741631
     
    17481805number ntMap00(number a, const coeffs src, const coeffs dst)
    17491806{
     1807  n_Test(a, src);
     1808 
    17501809  if (n_IsZero(a, src)) return NULL;
    1751   n_Test(a, src);
    17521810  assume(src->rep == dst->extRing->cf->rep);
    17531811  if ((SR_HDL(a) & SR_INT) || (a->s==3))
    17541812  {
    17551813    number res=ntInit(p_NSet(n_Copy(a, src), dst->extRing), dst);
    1756     n_Test(res,dst);
     1814    n_Test(res, dst);
    17571815    return res;
    17581816  }
     
    17631821  if (n_IsOne(nn,src)) DEN(ff)=NULL;
    17641822  else                 DEN(ff)=p_NSet(nn,dst->extRing);
     1823 
    17651824  n_Test((number)ff,dst);
    17661825  //check_N((number)ff,dst);
     
    17701829number ntMapZ0(number a, const coeffs src, const coeffs dst)
    17711830{
     1831  n_Test(a, src);
    17721832  if (n_IsZero(a, src)) return NULL;
    1773   n_Test(a, src);
    17741833  nMapFunc nMap=n_SetMap(src,dst->extRing->cf);
    17751834  poly p=p_NSet(nMap(a, src,dst->extRing->cf), dst->extRing);
     
    17841843number ntMapP0(number a, const coeffs src, const coeffs dst)
    17851844{
     1845  n_Test(a, src);
    17861846  if (n_IsZero(a, src)) return NULL;
    1787   n_Test(a, src);
    17881847  /* mapping via intermediate int: */
    17891848  int n = n_Int(a, src);
     
    23802439{
    23812440  fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
    2382   int i;
    23832441
    23842442  poly *P=(poly*)omAlloc(rl*sizeof(poly*));
    23852443  number *X=(number *)omAlloc(rl*sizeof(number));
     2444
     2445  int i;
    23862446
    23872447  for(i=0;i<rl;i++) P[i]=p_Copy(NUM((fraction)(x[i])),cf->extRing);
     
    24022462    p_Delete(&DEN(result),ntRing);
    24032463  }
     2464  ntTest((number)result);
    24042465  return ((number)result);
    24052466}
     
    24112472  NUM(result)=p_Farey(p_Copy(NUM((fraction)p),cf->extRing),n,cf->extRing);
    24122473  DEN(result)=p_Farey(p_Copy(DEN((fraction)p),cf->extRing),n,cf->extRing);
     2474  ntTest((number)result);
    24132475  return ((number)result);
    24142476}
Note: See TracChangeset for help on using the changeset viewer.