Changeset 1f5565d in git


Ignore:
Timestamp:
Feb 22, 2012, 7:59:06 PM (12 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', '4a9821a93ffdc22a6696668bd4f6b8c9de3e6c5f')
Children:
762407dfdd4ce18e60ae114357800624f0b09308
Parents:
f23ccea9a38ee5dfa1e6454e84dd4bd11cd5ce90
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-02-22 19:59:06+01:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-02-23 20:35:09+01:00
Message:
added HWeyl

add: experimental handling of homogenized Weyl algebras (formulas/detection and related)
Location:
libpolys/polys/nc
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/nc/ncSACache.cc

    rf23cce r1f5565d  
    2323
    2424#ifndef NDEBUG
    25 #define OUTPUT 1
     25#define OUTPUT MYTEST
    2626#else
    2727#define OUTPUT 0
  • libpolys/polys/nc/ncSAFormula.cc

    rf23cce r1f5565d  
    2727
    2828#ifndef NDEBUG
    29 #define OUTPUT 1
     29#define OUTPUT MYTEST
    3030#else
    3131#define OUTPUT 0
     
    5252#if OUTPUT 
    5353  Print("ncInitSpecialPowersMultiplication(ring), ring: \n");
    54   rWrite(r);
     54  rWrite(r, TRUE);
    5555  PrintLn();
    5656#endif
     
    7777
    7878
     79
     80
     81// TODO: return q-coeff?
     82static inline BOOLEAN AreCommutingVariables(const ring r, int i, int j/*, number *qq*/)
     83{
     84#if OUTPUT 
     85  Print("AreCommutingVariables(ring, k: %d, i: %d)!", j, i);
     86  PrintLn();
     87#endif
     88
     89  assume(i != j);
     90
     91  assume(i > 0);
     92  assume(i <= r->N);
     93
     94
     95  assume(j > 0);
     96  assume(j <= r->N);
     97
     98  const BOOLEAN reverse = (i > j);
     99
     100  if (reverse) { int k = j; j = i; i = k; }
     101
     102  assume(i < j);
     103
     104  {
     105    const poly d = GetD(r, i, j);
     106
     107#if OUTPUT 
     108    Print("D_{%d, %d} = ", i, j); p_Write(d, r);
     109#endif
     110
     111    if( d != NULL)
     112      return FALSE;
     113  }
     114
     115
     116  {
     117    const number q = p_GetCoeff(GetC(r, i, j), r);
     118
     119    if( !n_IsOne(q, r) )
     120      return FALSE;
     121  }
     122
     123  return TRUE; // [VAR(I), VAR(J)] = 0!!
     124
     125/*
     126  if (reverse)
     127    *qq = n_Invers(q, r);
     128  else
     129    *qq = n_Copy(q, r);
     130  return TRUE;
     131*/
     132}
     133
    79134static inline Enum_ncSAType AnalyzePairType(const ring r, int i, int j)
    80135{
    81136#if OUTPUT 
    82   Print("AnalyzePair(ring, i: %d, j: %d)!", i, j);
     137  Print("AnalyzePair(ring, i: %d, j: %d):", i, j);
    83138  PrintLn();
    84139#endif
     
    91146
    92147
    93   const number q = p_GetCoeff(GetC(r, i, j), r);
     148  const poly c = GetC(r, i, j);
     149  const number q = p_GetCoeff(c, r);
    94150  const poly d = GetD(r, i, j);
    95151
    96 #if OUTPUT 
    97   Print("C_{%d, %d} = ", i, j);  { number t = n_Copy(q, r);  n_Write(t, r);  n_Delete(&t, r); };
     152#if 0 && OUTPUT 
     153  Print("C_{%d, %d} = ", i, j); p_Write(c, r); PrintLn();
    98154  Print("D_{%d, %d} = ", i, j); p_Write(d, r);
    99155#endif
     
    107163      return _ncSA_1xy0x0y0;
    108164
    109     if( n_IsMOne(q, r) )
     165    if( n_IsMOne(q, r) ) // anti-commutative
    110166      return _ncSA_Mxy0x0y0;
    111167
    112     return _ncSA_Qxy0x0y0;
     168    return _ncSA_Qxy0x0y0; // quasi-commutative
    113169  } else
    114170  {
    115171    if( n_IsOne(q, r) ) // "Lie" case
    116172    {
    117       if( pNext(d) == NULL ) // Our Main Special Case!
     173      if( pNext(d) == NULL ) // Our Main Special Case: d is only a term!
    118174      {
    119175//         const number g = p_GetCoeff(d, r); // not used for now
    120         if( p_LmIsConstantComp(d, r) ) // Weyl
     176        if( p_LmIsConstantComp(d, r) ) // Weyl
    121177          return _ncSA_1xy0x0yG;
    122178
    123179        const int k = p_IsPurePower(d, r); // k if not pure power
    124180
    125         if( k > 0 )
    126           if( p_GetExp(d, k, r) == 1 )
     181        if( k > 0 ) // d = var(k)^??
     182        {
     183          const int exp = p_GetExp(d, k, r);
     184         
     185          if (exp == 1)
    127186          {
    128             if(k == i)
     187            if(k == i) // 2 -ubalgebra in var(i) & var(j), with linear relation...?
    129188              return _ncSA_1xyAx0y0;
    130189
    131190            if(k == j)
    132191              return _ncSA_1xy0xBy0;             
     192          } else if ( exp == 2 && k!= i && k != j)  // Homogenized Weyl algebra [x, Dx] = t^2?
     193          {
     194//            number qi, qj;
     195            if (AreCommutingVariables(r, k, i/*, &qi*/) && AreCommutingVariables(r, k, j/*, &qj*/) ) // [x, t] = [Dx, t] = 0?
     196            {
     197              const number g = p_GetCoeff(d, r);
     198
     199              if (n_IsOne(g, r))
     200                return _ncSA_1xy0x0yT2; // save k!?, G = LC(d) == qi == qj == 1!!!
     201            }
    133202          }
     203        }
    134204      }
    135205    }
    136   }
     206    // Hmm, what about a more general case of q != 1???
     207  }
     208#if OUTPUT 
     209  Print("C_{%d, %d} = ", i, j); p_Write(c, r);
     210  Print("D_{%d, %d} = ", i, j); p_Write(d, r);
     211  PrintS("====>>>>_ncSA_notImplemented\n");
     212#endif
    137213
    138214  return _ncSA_notImplemented;
    139215}
    140 
    141216
    142217
     
    371446///////////////////////////////////////////////////////////////////////////////////////////
    372447///////////////////////////////////////////////////////////////////////////////////////////
     448static inline poly ncSA_1xy0x0yT2(const int i, const int j, const int n, const int m, const int m_k, const ring r)
     449{
     450#if OUTPUT 
     451  Print("ncSA_1xy0x0yT2(var(%d)^{%d}, var(%d)^{%d}, t: var(%d), r)!", j, m, i, n, m_k); 
     452  PrintLn();
     453#endif
     454
     455  int kn = n;
     456  int km = m;
     457
     458  // k == 0!
     459  number c = n_Init(1, r);
     460
     461  poly p = p_One( r );
     462
     463  p_SetExp(p, j, km--, r); // y ^ (m)
     464  p_SetExp(p, i, kn--, r); // x ^ (n)
     465//  p_SetExp(p, m_k, k << 1, r); // homogenization with var(m_k) ^ (2*k)
     466
     467  p_Setm(p, r); // pResult = x^n * y^m
     468
     469
     470  poly pResult = p;
     471  poly pLast = p;
     472
     473  int min = si_min(m, n);
     474
     475  int k = 1;
     476
     477  for(; k < min; k++ )
     478  {
     479    number t = n_Init(km + 1, r);
     480//    n_InpMult(t, m_g, r); // t = ((m - k) + 1) * gamma
     481    n_InpMult(c, t, r);   // c = c'* ((m - k) + 1) * gamma
     482    n_Delete(&t, r);
     483
     484    t = n_Init(kn + 1, r);
     485    n_InpMult(c, t, r);   // c = (c'* ((m - k) + 1) * gamma) * ((n - k) + 1)
     486    n_Delete(&t, r);
     487
     488    t = n_Init(k, r);
     489    c = n_Div(c, t, r);
     490    n_Delete(&t, r);
     491
     492// //    n_Normalize(c, r);
     493
     494    t = n_Copy(c, r); // not the last!
     495
     496    p = p_NSet(t, r);
     497
     498    p_SetExp(p, j, km--, r); // y ^ (m-k)
     499    p_SetExp(p, i, kn--, r); // x ^ (n-k)
     500
     501    p_SetExp(p, m_k, k << 1, r); // homogenization with var(m_k) ^ (2*k)
     502   
     503    p_Setm(p, r); // pResult = x^(n-k) * y^(m-k)
     504
     505    pNext(pLast) = p;
     506    pLast = p;
     507  }
     508
     509  assume(k == min);
     510  assume((km == 0) || (kn == 0) );
     511
     512  {
     513//    n_InpMult(c, m_g, r);   // c = c'* gamma
     514
     515    if( km > 0 )
     516    {
     517      number t = n_Init(km + 1, r);
     518      n_InpMult(c, t, r);   // c = (c'* gamma) * (m - k + 1)
     519      n_Delete(&t, r);
     520    }
     521
     522    if( kn > 0 )
     523    {
     524      number t = n_Init(kn + 1, r);
     525      n_InpMult(c, t, r);   // c = (c'* gamma) * (n - k + 1)
     526      n_Delete(&t, r);
     527    }
     528
     529    number t = n_Init(k, r); // c = ((c'* gamma) * ((n - k + 1) * (m - k + 1))) / k;
     530    c = n_Div(c, t, r);
     531    n_Delete(&t, r);
     532  }
     533
     534  p = p_NSet(c, r);
     535
     536  p_SetExp(p, j, km, r); // y ^ (m-k)
     537  p_SetExp(p, i, kn, r); // x ^ (n-k)
     538
     539  p_SetExp(p, m_k, k << 1, r); // homogenization with var(m_k) ^ (2*k)
     540
     541  p_Setm(p, r); //
     542
     543  pNext(pLast) = p;
     544
     545  CorrectPolyWRTOrdering(pResult, r);
     546
     547  return pResult;
     548}
     549///////////////////////////////////////////////////////////////////////////////////////////
     550
     551
     552
     553///////////////////////////////////////////////////////////////////////////////////////////
    373554static inline poly ncSA_ShiftAx(int i, int j, int n, int m, const number m_shiftCoef, const ring r)
    374555{
     
    501682  }
    502683
    503   const number g = p_GetCoeff(GetD(r, i, j), r);
     684  const poly d = GetD(r, i, j);
     685  const number g = p_GetCoeff(d, r);
    504686
    505687  if( type == _ncSA_1xy0x0yG ) // Weyl
    506688    return ::ncSA_1xy0x0yG(i, j, n, m, g, r);
    507689
     690  if( type == _ncSA_1xy0x0yT2 ) // Homogenous Weyl...
     691    return ::ncSA_1xy0x0yT2(i, j, n, m, p_IsPurePower(d, r), r);
     692 
    508693  if( type == _ncSA_1xyAx0y0 ) // Shift 1
    509694    return ::ncSA_1xyAx0y0(i, j, n, m, g, r);
     
    557742}
    558743
     744poly CFormulaPowerMultiplier::ncSA_1xy0x0yT2(const int i, const int j, const int n, const int m, const int k, const ring r)
     745{
     746  return ::ncSA_1xy0x0yT2(i, j, n, m, k, r);
     747}
     748
    559749poly CFormulaPowerMultiplier::ncSA_1xyAx0y0(const int i, const int j, const int n, const int m, const number m_shiftCoef, const ring r)
    560750{
  • libpolys/polys/nc/ncSAFormula.h

    rf23cce r1f5565d  
    1919{
    2020  _ncSA_notImplemented = -1,
    21   _ncSA_1xy0x0y0 = 0, // commutative
    22   _ncSA_Mxy0x0y0 = 1, // anti-commutative
    23   _ncSA_Qxy0x0y0 = 2, // quasi-commutative
    24   _ncSA_1xyAx0y0 = 10, // shift 1
    25   _ncSA_1xy0xBy0 = 20, // shift 2
    26   _ncSA_1xy0x0yG = 30 // Weyl 
     21  _ncSA_1xy0x0y0 = 0x00, // commutative
     22  _ncSA_Mxy0x0y0 = 0x01, // anti-commutative
     23  _ncSA_Qxy0x0y0 = 0x02, // quasi-commutative
     24  _ncSA_1xyAx0y0 = 0x10, // shift 1
     25  _ncSA_1xy0xBy0 = 0x20, // shift 2
     26  _ncSA_1xy0x0yG = 0x30, // Weyl 
     27  _ncSA_1xy0x0yT2 = 0x100 // homogenized Weyl algebra?
    2728};
    2829
     
    7475
    7576    static poly ncSA_1xy0x0yG(const int i, const int j, const int n, const int m, const number m_g, const ring r);
     77    static poly ncSA_1xy0x0yT2(const int i, const int j, const int n, const int m, const int k, const ring r);
    7678
    7779    static poly ncSA_1xyAx0y0(const int i, const int j, const int n, const int m, const number m_shiftCoef, const ring r);
  • libpolys/polys/nc/ncSAMult.cc

    rf23cce r1f5565d  
    2626
    2727#ifndef NDEBUG
    28 #define OUTPUT 1
     28#define OUTPUT MYTEST
    2929#else
    3030#define OUTPUT 0
     
    248248#endif
    249249
    250   if( p_Procs == NULL )
    251     p_Procs = rGR->p_Procs;
     250  assume( p_Procs != NULL );
    252251 
    253252  // "commutative"
     
    265264}
    266265
    267 bool ncInitSpecialPairMultiplication(ring r)
     266BOOLEAN ncInitSpecialPairMultiplication(ring r)
    268267{
    269268#if OUTPUT 
    270269  PrintS("ncInitSpecialPairMultiplication(ring), ring: \n");
    271   rWrite(r);
    272   PrintLn();
    273 #endif
    274  
    275   assume(rIsPluralRing(r));
    276   assume(!rIsSCA(r));
     270  rWrite(r, TRUE);
     271  PrintLn();
     272#endif
     273 
     274  if(!rIsPluralRing(r));
     275    return TRUE;
     276 
     277  if(rIsSCA(r))
     278    return TRUE;
    277279
    278280  if( r->GetNC()->GetGlobalMultiplier() != NULL )
    279281  {
    280282    WarnS("Already defined!");
    281     return false;
     283    return TRUE;
    282284  }
    283285
    284286  r->GetNC()->GetGlobalMultiplier() = new CGlobalMultiplier(r);
    285287
    286   ggnc_p_ProcsSet(r, NULL);
    287   return true;
     288  ggnc_p_ProcsSet(r, r->p_Procs);
     289  return FALSE; // ok!
    288290}
    289291
     
    654656}
    655657
     658///////////////////////////////////////////////////////////////////////////////////////////
     659CHWeylSpecialPairMultiplier::CHWeylSpecialPairMultiplier(ring r, int i, int j, int k):
     660    CSpecialPairMultiplier(r, i, j), m_k(k)
     661{
     662#if OUTPUT 
     663  Print("CHWeylSpecialPairMultiplier::CHWeylSpecialPairMultiplier(ring, i: %d, j: %d, k: %d)!", i, j, k);
     664  PrintLn();
     665#endif
     666}
     667
     668
     669CHWeylSpecialPairMultiplier::~CHWeylSpecialPairMultiplier()
     670{
     671#if OUTPUT 
     672  PrintS("CHWeylSpecialPairMultiplier::~CHWeylSpecialPairMultiplier()");
     673  PrintLn();
     674#endif
     675}
     676
     677// Exponent * Exponent
     678poly CHWeylSpecialPairMultiplier::MultiplyEE(const int expLeft, const int expRight)
     679{
     680#if OUTPUT 
     681  Print("CHWeylSpecialPairMultiplier::MultiplyEE(var(%d)^{%d}, var(%d)^{%d})!", GetJ(), expLeft, GetI(), expRight); 
     682  PrintLn();
     683#endif
     684  // Char == 0, otherwise - problem!
     685
     686
     687  const ring r = GetBasering();
     688
     689  assume( expLeft*expRight > 0 );
     690
     691  return CFormulaPowerMultiplier::ncSA_1xy0x0yT2(GetI(), GetJ(), expRight, expLeft, m_k, r);
     692}
     693
    656694
    657695///////////////////////////////////////////////////////////////////////////////////////////
     
    781819  if( type == _ncSA_1xy0xBy0 ) // Shift 2
    782820    return new CShiftSpecialPairMultiplier(r, i, j, j, g);
     821
     822  if( type == _ncSA_1xy0x0yT2 ) // simple homogenized Weyl algebra
     823    return new CHWeylSpecialPairMultiplier(r, i, j, p_IsPurePower(d, r));
    783824
    784825}
  • libpolys/polys/nc/ncSAMult.h

    rf23cce r1f5565d  
    2525//
    2626
    27 bool ncInitSpecialPairMultiplication(ring r);
     27BOOLEAN ncInitSpecialPairMultiplication(ring r);
    2828
    2929
     
    3232{
    3333  protected:
    34     ring m_basering;
    35     int  m_NVars; // N = number of variables
     34    const ring m_basering;
     35    const int  m_NVars; // N = number of variables
    3636
    3737  public:
     
    100100{
    101101  private:
    102     int m_i;
     102    int m_i; // 2-gen subalgebra in these variables...
    103103    int m_j;
    104104
     
    557557};
    558558
     559//////////////////////////////////////////////////////////////////////////
     560class CHWeylSpecialPairMultiplier: public CSpecialPairMultiplier
     561{
     562  private:
     563    const int m_k;
     564    // TODO: make cache for some 'good' powers!?
     565
     566  public:
     567    CHWeylSpecialPairMultiplier(ring r, int i, int j, int k);
     568    virtual ~CHWeylSpecialPairMultiplier();
     569
     570    // Exponent * Exponent
     571    virtual poly MultiplyEE(const int expLeft, const int expRight);   
     572};
     573
    559574
    560575//////////////////////////////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.