Changeset fd01a8 in git


Ignore:
Timestamp:
May 24, 2011, 5:00:23 PM (13 years ago)
Author:
Frank Seelisch <seelisch@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '0bc2210f8055033868008a3836878db65ec6f89e')
Children:
48a994659e87a54916c1ebffdba59be9375387e4
Parents:
e0ae1cb631677ee4e2ec77c8413a6cc7fbd22bc8
git-author:
Frank Seelisch <seelisch@mathematik.uni-kl.de>2011-05-24 17:00:23+02:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:36:51+01:00
Message:
testing multivariate gcd from factory: problem in p_polys.cc ('longalg missing')
Location:
libpolys
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/coeffs.h

    re0ae1c rfd01a8  
    1616
    1717#ifdef HAVE_FACTORY
     18#include <factory/factory.h>
    1819class CanonicalForm;
    1920#endif
  • libpolys/polys/clapsing.h

    re0ae1c rfd01a8  
    2020//#include <kernel/longtrans.h>
    2121
     22/* destroys f and g */
    2223poly singclap_gcd ( poly f, poly g, const ring r );
     24
    2325/*
    2426napoly singclap_alglcm ( napoly f, napoly g );
  • libpolys/polys/ext_fields/algext.cc

    re0ae1c rfd01a8  
    359359       but use brackets around the output, if a is not
    360360       a constant living in naCoeffs = cf->algring->cf */
    361     BOOLEAN useBrackets = TRUE;
    362     if (p_Deg(aAsPoly, naRing) == 0) useBrackets = FALSE;
     361    BOOLEAN useBrackets = !(p_IsConstant(aAsPoly, naRing));
    363362    if (useBrackets) StringAppendS("(");
    364     p_Write(aAsPoly, naRing);
     363    p_String0(aAsPoly, naRing, naRing);
    365364    if (useBrackets) StringAppendS(")");
    366365  }
  • libpolys/polys/monomials/p_polys.cc

    re0ae1c rfd01a8  
    20592059      h = nlInit(1, r->cf);
    20602060      p=ph;
    2061       Werror("longalg missing");
     2061      Werror("longalg missing 1");
    20622062      #if 0
    20632063      while (p!=NULL)
     
    33973397    {
    33983398      qq=p_One(dst);
    3399       WerrorS("longalg missing");
     3399      WerrorS("longalg missing 2");
    34003400      #if 0
    34013401      aq=naPermNumber(pGetCoeff(p),par_perm,OldPar, oldRing);
     
    34483448            else
    34493449            {
    3450               WerrorS("longalg missing");
     3450              WerrorS("longalg missing 3");
    34513451              #if 0
    34523452              lnumber c=(lnumber)pGetCoeff(qq);
  • libpolys/tests/polys_test.h

    re0ae1c rfd01a8  
    2020
    2121#include <polys/simpleideals.h>
     22#include <polys/clapsing.h>
    2223
    2324class MyGlobalPrintingFixture : public GlobalPrintingFixture
     
    209210{
    210211private:
    211   /* replaces n by n + c * var^exp (in-place);
     212  /* replaces p by p + c * var(i)^exp (in-place);
    212213     expects exp >= 0 */
    213   void plusTerm(number &n, int c, int exp, const coeffs cf)
    214   {
    215     number x = n_Par(1, cf);
    216     number pow = n_Init(1, cf);
    217     number temp;
    218     for (int i = 1; i <= exp; i++)
    219     {
    220       temp = n_Mult(pow, x, cf);
    221       n_Delete(&pow, cf);
    222       pow = temp;
    223     }
    224     n_Delete(&x, cf);
    225     number m = n_Init(c, cf);
    226     number t = n_Mult(m, pow, cf);
    227     n_Delete(&m, cf); n_Delete(&pow, cf);
    228     temp = n_Add(n, t, cf);
    229     n_Delete(&n, cf); n_Delete(&t, cf);
    230     n = temp;
     214  void plusTerm(poly &p, int c, int i, int exp, const ring r)
     215  {
     216    poly t = p_ISet(c, r); p_SetExp(t, i, exp, r); p_Setm(t, r);
     217    p = p_Add_q(p, t, r);
    231218  }
    232219  void checkInverse(number n, const coeffs cf)
     
    597584    TestSumCf(cf, 101);
    598585    TestSumCf(cf, 1001);
    599     TestSumCf(cf, 9000);
     586    TestSumCf(cf, 2000);
    600587
    601588    clog << "Finally create the polynomial ring (Q[a]/<a2+1>)[x, y]..."
     
    624611         << endl;
    625612   
    626     number u;
    627     u = NULL; plusTerm(u, 1, 1, cf); plusTerm(u, 1, 0, cf);  // a + 1
    628     checkInverse(u, cf); n_Delete(&u, cf);
    629     u = NULL; plusTerm(u, 1, 1, cf); plusTerm(u, -1, 0, cf); // a - 1
    630     checkInverse(u, cf); n_Delete(&u, cf);
    631     u = NULL; plusTerm(u, 1, 1, cf); plusTerm(u, 5, 0, cf);  // a + 5
    632     checkInverse(u, cf); n_Delete(&u, cf);
    633     u = NULL; plusTerm(u, 1, 1, cf); plusTerm(u, -5, 0, cf); // a - 5
    634     checkInverse(u, cf); n_Delete(&u, cf);
    635     u = NULL; plusTerm(u, 17, 1, cf); plusTerm(u, 5, 0, cf); // 17a + 5
    636     checkInverse(u, cf); n_Delete(&u, cf);
     613    poly u;
     614    u = NULL; plusTerm(u, 1, 1, 1, cf->algring);
     615    plusTerm(u, 1, 1, 0, cf->algring);  // a + 1
     616    checkInverse((number)u, cf); p_Delete(&u, cf->algring);
     617    u = NULL; plusTerm(u, 1, 1, 1, cf->algring);
     618    plusTerm(u, -1, 1, 0, cf->algring); // a - 1
     619    checkInverse((number)u, cf); p_Delete(&u, cf->algring);
     620    u = NULL; plusTerm(u, 1, 1, 1, cf->algring);
     621    plusTerm(u, 5, 1, 0, cf->algring);  // a + 5
     622    checkInverse((number)u, cf); p_Delete(&u, cf->algring);
     623    u = NULL; plusTerm(u, 1, 1, 1, cf->algring);
     624    plusTerm(u, -5, 1, 0, cf->algring); // a - 5
     625    checkInverse((number)u, cf); p_Delete(&u, cf->algring);
     626    u = NULL; plusTerm(u, 17, 1, 1, cf->algring);
     627    plusTerm(u, 5, 1, 0, cf->algring); // 17a + 5
     628    checkInverse((number)u, cf); p_Delete(&u, cf->algring);
    637629
    638630    rDelete(s); // kills 'cf' and 'r' as well
     
    717709         << endl;
    718710         
    719     number u;
    720     u = NULL; plusTerm(u, 1, 2, cf); plusTerm(u, 33, 0, cf);    // b^2 + 33
    721     checkInverse(u, cf); n_Delete(&u, cf);
    722     u = NULL; plusTerm(u, 1, 5, cf); plusTerm(u, -137, 0, cf);  // b^5 - 137
    723     checkInverse(u, cf); n_Delete(&u, cf);
     711    poly u;
     712    u = NULL; plusTerm(u, 1, 1, 2, cf->algring);
     713    plusTerm(u, 33, 1, 0, cf->algring);     // b^2 + 33
     714    checkInverse((number)u, cf); p_Delete(&u, cf->algring);
     715    u = NULL; plusTerm(u, 1, 1, 5, cf->algring);
     716    plusTerm(u, -137, 1, 0, cf->algring);   // b^5 - 137
     717    checkInverse((number)u, cf); p_Delete(&u, cf->algring);
    724718
    725719    clog << endl
     
    727721         << endl;
    728722   
    729     number v;
    730     v = NULL; plusTerm(v, 1, 2, cf); plusTerm(v, 7, 1, cf);
    731     plusTerm(v, 1, 0, cf);        // b^2 + 7b + 1
    732     number w = n_Mult(v, v, cf);  // (b^2 + 7b + 1)^2
    733     number y = n_Mult(v, w, cf);  // (b^2 + 7b + 1)^3
    734     n_Delete(&v, cf);
    735     v = NULL; plusTerm(v, 2, 2, cf); plusTerm(v, -61, 1, cf);   // 2b^2 - 61b
    736     number z = n_Mult(w, v, cf);   // (b^2 + 7b + 1)^2 * (2b^2 - 61b)
    737     n_Delete(&v, cf);
    738    
    739     clog << "z = "; n_Write(z, cf);
    740     clog << "y = "; n_Write(y, cf);
     723    poly v;
     724    v = NULL; plusTerm(v, 1, 1, 2, cf->algring);
     725    plusTerm(v, 7, 1, 1, cf->algring);
     726    plusTerm(v, 1, 1, 0, cf->algring);            // b^2 + 7b + 1
     727    number w = n_Mult((number)v, (number)v, cf);  // (b^2 + 7b + 1)^2
     728    number y = n_Mult((number)v, (number)w, cf);  // (b^2 + 7b + 1)^3
     729    p_Delete(&v, cf->algring);
     730    v = NULL; plusTerm(v, 2, 1, 2, cf->algring);
     731    plusTerm(v, -61, 1, 1, cf->algring);          // 2b^2 - 61b
     732    number z = n_Mult((number)w,
     733                      (number)v, cf);   // (b^2 + 7b + 1)^2 * (2b^2 - 61b)
     734    p_Delete(&v, cf->algring);
     735   
     736    clog << "z = "; p_Write((poly)z, cf->algring);
     737    clog << "y = "; p_Write((poly)y, cf->algring);
    741738    number theGcd = n_Gcd(z, y, cf);   // should yield w = (b^2 + 7b + 1)^2
    742     clog << "gcd(z, y) = "; n_Write(theGcd, cf);
    743    
    744     v = n_Sub(theGcd, w, cf);
     739    clog << "gcd(z, y) = "; p_Write((poly)theGcd, cf->algring);
     740   
     741    v = (poly)n_Sub(theGcd, w, cf);
    745742    TS_ASSERT( v == NULL );
    746     n_Delete(&v, cf);
     743    p_Delete(&v, cf->algring);
    747744   
    748745    clog << endl
     
    752749    poly zFactor; poly yFactor;
    753750    poly ppp = p_ExtGcd((poly)z, zFactor, (poly)y, yFactor, cf->algring);
    754     v = n_Sub(theGcd, (number)ppp, cf);
     751    v = (poly)n_Sub(theGcd, (number)ppp, cf);
    755752    TS_ASSERT( v == NULL );
    756     clog << "z = "; n_Write(z, cf);
     753    clog << "z = "; p_Write((poly)z, cf->algring);
    757754    clog << "zFactor = "; p_Write(zFactor, cf->algring);
    758     clog << "y = "; n_Write(y, cf);
    759     clog << "yFactor = "; p_Write(yFactor, cf->algring);
     755    clog << "y = "; p_Write((poly)y, cf->algring);
     756    clog << "yFactor = "; p_Write((poly)yFactor, cf->algring);
    760757    number v1 = n_Mult(z, (number)zFactor, cf);
    761758    number v2 = n_Mult(y, (number)yFactor, cf);
    762759    number v3 = n_Add(v1, v2, cf);
    763     clog << "z * zFactor + y * yFactor = "; n_Write(v3, cf);
     760    clog << "z * zFactor + y * yFactor = "; p_Write((poly)v3, cf->algring);
    764761    clog << "gcd(z, y) = "; p_Write(ppp, cf->algring);
    765762    number v4 = n_Sub(v3, w, cf);
     
    769766    p_Delete(&yFactor, cf->algring);
    770767    n_Delete(&z, cf); n_Delete(&y, cf); n_Delete(&w, cf);
    771     n_Delete(&theGcd, cf); n_Delete(&v, cf); n_Delete(&v1, cf);
     768    n_Delete(&theGcd, cf); p_Delete(&v, cf->algring); n_Delete(&v1, cf);
    772769    n_Delete(&v2, cf); n_Delete(&v3, cf); n_Delete(&v4, cf);
    773770
    774771    rDelete(s); // kills 'cf' and 'r' as well
    775772  }
     773  void test_Z_17_Ext_a()
     774  {
     775    clog << "Start by creating Z_17[a]..." << endl;
     776
     777    char* n[] = {"a"};
     778    ring r = rDefault( 17, 1, n);   // Z/17Z[a]
     779    TS_ASSERT_DIFFERS( r, NULLp );
     780
     781    PrintRing(r);
     782
     783    TS_ASSERT( rField_is_Domain(r) );
     784    TS_ASSERT( !rField_is_Q(r) );
     785   
     786    TS_ASSERT( rField_is_Zp(r) );
     787    TS_ASSERT( rField_is_Zp(r, 17) );
     788
     789    TS_ASSERT_EQUALS( rVar(r), 1);
     790
     791    poly minPoly = p_ISet(1, r);                    // minPoly = 1
     792    p_SetExp(minPoly, 1, 2, r); p_Setm(minPoly, r); // minPoly = a^2
     793    minPoly = p_Add_q(minPoly, p_ISet(3, r), r);    // minPoly = a^2 + 3
     794    ideal minIdeal = idInit(1);                     // minIdeal = < 0 >
     795    minIdeal->m[0] = minPoly;                       // minIdeal = < a^2 + 3 >
     796
     797    n_coeffType type = nRegister(n_Ext, naInitChar);
     798    TS_ASSERT(type == n_Ext);
     799
     800    ExtInfo extParam;
     801    extParam.r = r;
     802    extParam.i = minIdeal;
     803   
     804    clog << "Next create the extension field Z_17[a]/<a^2+3>..." << endl;
     805
     806    const coeffs cf = nInitChar(type, &extParam);   // Z_17[a]/<a^2+3>
     807   
     808    if( cf == NULL )
     809      TS_FAIL("Could not get needed coeff. domain");
     810
     811    TS_ASSERT_DIFFERS( cf->cfCoeffWrite, NULLp );
     812   
     813    if( cf->cfCoeffWrite != NULL )
     814    {
     815      clog << "Coeff-domain: "  << endl;
     816      n_CoeffWrite(cf); PrintLn();
     817    }
     818   
     819    // some tests for the coefficient field represented by cf:
     820    TestArithCf(cf);
     821    TestSumCf(cf, 10);
     822    TestSumCf(cf, 100);
     823    TestSumCf(cf, 101);
     824    TestSumCf(cf, 1001);
     825    TestSumCf(cf, 9000);
     826
     827    clog << "Finally create the polynomial ring (Z_17[a]/<a^2+3>)[u, v, w]..."
     828         << endl;
     829   
     830    char* m[] = {"u", "v", "w"};
     831    ring s = rDefault(cf, 3, m);   // (Z_17[a]/<a^2+3>)[u, v, w]
     832    TS_ASSERT_DIFFERS(s, NULLp);
     833
     834    PrintRing(s);
     835
     836    TS_ASSERT( rField_is_Domain(s) );
     837    TS_ASSERT( !rField_is_Q(s) );
     838    TS_ASSERT( !rField_is_Zp(s) );
     839    TS_ASSERT( !rField_is_Zp(s, 11) );
     840    TS_ASSERT( !rField_is_Zp(s, 17) );
     841    TS_ASSERT( !rField_is_GF(s) );
     842    TS_ASSERT( rField_is_Extension(s) );
     843    TS_ASSERT( !rField_is_GF(s, 25) );
     844    TS_ASSERT_EQUALS(rVar(s), 3);
     845
     846    Test(s);
     847   
     848    poly f = p_ISet(3, s);
     849    p_SetExp(f, 1, 3, s);
     850    p_SetExp(f, 2, 1, s);
     851    p_SetExp(f, 3, 5, s);
     852    p_Setm(f, r);   // 3*u^3*v*w^5
     853    plusTerm(f, -2, 1, 6, s); // -2*u^6 + 3*u^3*v*w^5
     854    p_Write(f, s);
     855    poly g = p_ISet(7, s);
     856    p_SetExp(g, 1, 5, s);
     857    p_SetExp(g, 2, 6, s);
     858    p_SetExp(g, 3, 2, s);
     859    p_Setm(g, r);   // 7*u^5*v^6*w^2
     860    plusTerm(g, 8, 1, 4, s); // 7*u^5*v^6*w^2 + 8*u^4
     861    p_Write(g, s);
     862    poly h = singclap_gcd(f, g, s);   // u^3*v*w^2, destroys f and g
     863    p_Write(h, s);
     864    p_Test(h, s);
     865    p_Delete(&h, s);
     866   
     867    rDelete(s); // kills 'cf' and 'r' as well
     868  }
    776869};
    777870
Note: See TracChangeset for help on using the changeset viewer.