Changeset de90c01 in git


Ignore:
Timestamp:
Jun 28, 2011, 5:24:13 PM (13 years ago)
Author:
Frank Seelisch <seelisch@…>
Branches:
(u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
Children:
010f3bf0c665c71ec55b5bb0d7d518fd24e73ed0
Parents:
f59722f94f8a42963b69fe4389c1ce3850e4f87e
git-author:
Frank Seelisch <seelisch@mathematik.uni-kl.de>2011-06-28 17:24:13+02:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:39:10+01:00
Message:
poly_tests for transcendental ext fields
Location:
libpolys
Files:
3 edited

Legend:

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

    rf59722 rde90c01  
    3030/// our type has been defined as a macro in transext.h
    3131/// and is accessible by 'ntID'
     32
     33extern omBin fractionObjectBin = omGetSpecBin(sizeof(fractionObject));
    3234
    3335/// forward declarations
     
    340342  fraction fa = (fraction)a;
    341343  fraction fb = (fraction)b;
     344 
     345  poly g = p_Copy(num(fa), ntRing);
     346  if (!denIs1(fb)) g = p_Mult_q(g, p_Copy(den(fb), ntRing), ntRing);
     347  poly h = p_Copy(num(fb), ntRing);
     348  if (!denIs1(fa)) h = p_Mult_q(h, p_Copy(den(fa), ntRing), ntRing);
     349  g = p_Add_q(g, h, ntRing);
     350 
     351  if (g == NULL) return NULL;
     352 
    342353  poly f;
    343354  if      (denIs1(fa) && denIs1(fb))  f = NULL;
     
    347358                                                   p_Copy(den(fb), ntRing),
    348359                                                   ntRing);
    349   poly g = p_Copy(num(fa), ntRing);
    350   if (!denIs1(fb)) g = p_Mult_q(g, p_Copy(den(fb), ntRing), ntRing);
    351   poly h = p_Copy(num(fb), ntRing);
    352   if (!denIs1(fa)) h = p_Mult_q(h, p_Copy(den(fa), ntRing), ntRing);
    353   g = p_Add_q(g, h, ntRing);
     360 
    354361  fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
    355362  num(result) = g;
     
    368375  fraction fa = (fraction)a;
    369376  fraction fb = (fraction)b;
     377 
     378  poly g = p_Copy(num(fa), ntRing);
     379  if (!denIs1(fb)) g = p_Mult_q(g, p_Copy(den(fb), ntRing), ntRing);
     380  poly h = p_Copy(num(fb), ntRing);
     381  if (!denIs1(fa)) h = p_Mult_q(h, p_Copy(den(fa), ntRing), ntRing);
     382  g = p_Add_q(g, p_Neg(h, ntRing), ntRing);
     383 
     384  if (g == NULL) return NULL;
     385 
    370386  poly f;
    371387  if      (denIs1(fa) && denIs1(fb))  f = NULL;
     
    375391                                                   p_Copy(den(fb), ntRing),
    376392                                                   ntRing);
    377   poly g = p_Copy(num(fa), ntRing);
    378   if (!denIs1(fb)) g = p_Mult_q(g, p_Copy(den(fb), ntRing), ntRing);
    379   poly h = p_Copy(num(fb), ntRing);
    380   if (!denIs1(fa)) h = p_Mult_q(h, p_Copy(den(fa), ntRing), ntRing);
    381   g = p_Add_q(g, p_Neg(h, ntRing), ntRing);
     393 
    382394  fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
    383395  num(result) = g;
     
    395407  fraction fa = (fraction)a;
    396408  fraction fb = (fraction)b;
     409 
     410  poly g = p_Copy(num(fa), ntRing);
     411  poly h = p_Copy(num(fb), ntRing);
     412  g = p_Mult_q(g, h, ntRing);
     413 
     414  if (g == NULL) return NULL;   /* may happen due to zero divisors */
     415 
    397416  poly f;
    398417  if      (denIs1(fa) && denIs1(fb))  f = NULL;
     
    402421                                                   p_Copy(den(fb), ntRing),
    403422                                                   ntRing);
    404   poly g = p_Copy(num(fa), ntRing);
    405   poly h = p_Copy(num(fb), ntRing);
    406   g = p_Mult_q(g, h, ntRing);
     423 
    407424  fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
    408425  num(result) = g;
     
    421438  fraction fa = (fraction)a;
    422439  fraction fb = (fraction)b;
     440 
     441  poly g = p_Copy(num(fa), ntRing);
     442  if (!denIs1(fb)) g = p_Mult_q(g, p_Copy(den(fb), ntRing), ntRing);
     443 
     444  if (g == NULL) return NULL;   /* may happen due to zero divisors */
     445 
    423446  poly f = p_Copy(num(fb), ntRing);
    424447  if (!denIs1(fa)) f = p_Mult_q(f, p_Copy(den(fa), ntRing), ntRing);
    425   poly g = p_Copy(num(fa), ntRing);
    426   if (!denIs1(fb)) g = p_Mult_q(g, p_Copy(den(fb), ntRing), ntRing);
     448 
    427449  fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
    428450  num(result) = g;
     
    559581}
    560582
    561 /* this just reads polynomials;
    562    the rest will be taken care of by the interpreter: When it encounters
    563    a "/", then it will impose a division that will finally lead to a
    564    rational function */
    565583const char * ntRead(const char *s, number *a, const coeffs cf)
    566584{
  • libpolys/polys/ext_fields/transext.h

    rf59722 rde90c01  
    5252};
    5353typedef struct fractionObject * fraction;
    54 
    55 omBin fractionObjectBin = omGetSpecBin(sizeof(fractionObject));
    5654
    5755/* constants for controlling the complexity of numbers */
  • libpolys/tests/polys_test.h

    rf59722 rde90c01  
    1616
    1717#include <polys/ext_fields/algext.h>
     18#include <polys/ext_fields/transext.h>
    1819#include <polys/monomials/ring.h>
    1920#include <polys/monomials/p_polys.h>
     
    2122#include <polys/simpleideals.h>
    2223
    23 #ifdef HAVE_FACTORY
     24#if 0 //ifdef HAVE_FACTORY
    2425#include <polys/clapsing.h>
    2526#include <factory/factory.h>
     
    223224  void checkInverse(number n, const coeffs cf)
    224225  {
    225     clog << "n = "; n_Write(n, cf);
     226    clog << "n = "; p_Write((poly)n, cf->extRing);
    226227    number n1 = n_Invers(n, cf);
    227     clog << "==> n^(-1) = "; n_Write(n1, cf);
     228    clog << "==> n^(-1) = "; p_Write((poly)n1, cf->extRing);
    228229    number n2 = n_Mult(n, n1, cf);
    229     clog << "(check: n * n^(-1) = "; n_Write(n2, cf);
     230    clog << "check: n * n^(-1) = "; p_Write((poly)n2, cf->extRing);
    230231    TS_ASSERT( n_IsOne(n2, cf) );
    231232    n_Delete(&n1, cf); n_Delete(&n2, cf);
     
    858859
    859860    Test(s);
    860     /*
    861 #ifdef HAVE_FACTORY
    862     poly f = p_ISet(3, s);
    863     p_SetExp(f, 1, 3, s);
    864     p_SetExp(f, 2, 1, s);
    865     p_SetExp(f, 3, 5, s);
    866     p_Setm(f, r);   // 3*u^3*v*w^5
    867     plusTerm(f, -2, 1, 6, s); // -2*u^6 + 3*u^3*v*w^5
    868     p_Write(f, s);
    869     poly g = p_ISet(7, s);
    870     p_SetExp(g, 1, 5, s);
    871     p_SetExp(g, 2, 6, s);
    872     p_SetExp(g, 3, 2, s);
    873     p_Setm(g, r);   // 7*u^5*v^6*w^2
    874     plusTerm(g, 8, 1, 4, s); // 7*u^5*v^6*w^2 + 8*u^4
    875     p_Write(g, s);
    876     poly h = singclap_gcd(f, g, s);   // at least u^3, destroys f and g
    877     p_Write(h, s);
    878     p_Test(h, s);
    879     p_Delete(&h, s);
    880 #endif
    881     */
     861   
    882862    rDelete(s); // kills 'cf' and 'r' as well
    883863  }
     864  void test_Q_Ext_s_t()
     865  {
     866    clog << "Start by creating Q[s, t]..." << endl;
     867
     868    char* n[] = {"s", "t"};
     869    ring r = rDefault( 0, 2, n);   // Q[s, t]
     870    TS_ASSERT_DIFFERS( r, NULLp );
     871
     872    PrintRing(r);
     873
     874    TS_ASSERT( rField_is_Domain(r) );
     875    TS_ASSERT( rField_is_Q(r) );
     876
     877    TS_ASSERT( !rField_is_Zp(r) );
     878    TS_ASSERT( !rField_is_Zp(r, 17) );
     879
     880    TS_ASSERT_EQUALS( rVar(r), 2);
     881
     882    n_coeffType type = nRegister(n_transExt, ntInitChar);
     883    TS_ASSERT(type == n_transExt);
     884
     885    TransExtInfo extParam;
     886    extParam.r = r;
     887
     888    clog << "Next create the rational function field Q(s, t)..." << endl;
     889
     890    const coeffs cf = nInitChar(type, &extParam);   // Q(s, t)
     891
     892    if( cf == NULL )
     893      TS_FAIL("Could not get needed coeff. domain");
     894
     895    TS_ASSERT_DIFFERS( cf->cfCoeffWrite, NULLp );
     896
     897    if( cf->cfCoeffWrite != NULL )
     898    {
     899      clog << "Coeff-domain: "  << endl;
     900      n_CoeffWrite(cf); PrintLn();
     901    }
     902
     903    TS_ASSERT( !nCoeff_is_algExt(cf) );
     904    TS_ASSERT( nCoeff_is_transExt(cf) );
     905
     906    // some tests for the coefficient field represented by cf:
     907    TestArithCf(cf);
     908    TestSumCf(cf, 10);
     909    TestSumCf(cf, 100);
     910    TestSumCf(cf, 101);
     911    TestSumCf(cf, 1001);
     912    TestSumCf(cf, 9000);
     913
     914    clog << "Finally create the polynomial ring Q(s, t)[x, y, z]..."
     915         << endl;
     916
     917    char* m[] = {"x", "y", "z"};
     918    ring s = rDefault(cf, 3, m);   // Q(s, t)[x, y, z]
     919    TS_ASSERT_DIFFERS(s, NULLp);
     920
     921    PrintRing(s);
     922
     923    TS_ASSERT( rField_is_Domain(s) );
     924    TS_ASSERT( !rField_is_Q(s) );
     925    TS_ASSERT( !rField_is_Zp(s) );
     926    TS_ASSERT( !rField_is_Zp(s, 11) );
     927    TS_ASSERT( !rField_is_Zp(s, 17) );
     928    TS_ASSERT( !rField_is_GF(s) );
     929    TS_ASSERT( rField_is_Extension(s) );
     930    TS_ASSERT( !rField_is_GF(s, 25) );
     931    TS_ASSERT_EQUALS(rVar(s), 3);
     932
     933    Test(s);
     934   
     935    rDelete(s); // kills 'cf' and 'r' as well
     936  }
    884937};
    885938
Note: See TracChangeset for help on using the changeset viewer.