Changeset 74f51f in git for libpolys/polys


Ignore:
Timestamp:
Feb 21, 2012, 8:54:54 PM (12 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
Children:
1114d2198efcbc84280b79e6a5090dda2ebf9f0e
Parents:
e4f491963f9660b7e75c9817b20efcc8c5fae6fa
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-02-21 20:54:54+01:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-02-23 20:35:11+01:00
Message:
fix induced degrees for the Schreyer ordering...

NOTE/TODO: it looks like r->pFDegOrig and/or r->pLDegOrig will be used uninitialized during std.
BUG for Hans: see the issue: https://github.com/Singular/Sources/issues/73
Location:
libpolys/polys/monomials
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/monomials/p_polys.cc

    re4f491 r74f51f  
    461461{
    462462  p_LmCheckPolyRing(a, r);
    463   assume(p_GetOrder(a, r) == p_WTotaldegree(a, r));
     463//  assume(p_GetOrder(a, r) == p_WTotaldegree(a, r)); // WRONG assume!
    464464  return p_GetOrder(a, r);
    465465}
     
    488488  p_LmCheckPolyRing(p, r);
    489489  int i, k;
     490  int pIS = 0;
    490491  long j =0;
    491492
     
    540541      case ringorder_S:
    541542      case ringorder_s:
    542       case ringorder_IS:
    543543      case ringorder_aa:
    544544        break;
     545      case ringorder_IS:
     546      {
     547        assume( b0 == b1 );
     548        assume( (-2 < b0) && (b0 < 2) ); // 0 => prefix! +/-1 => suffix!
     549
     550        if( b0 != 0) // suffix?
     551          break;
     552
     553        // only prefix adds the weight...
     554
     555        if( (k = p_GetComp(p, r)) == 0 )
     556          break;
     557
     558        const int ord_pos = rGetISPos(pIS++, r);
     559       
     560        const intvec* componentWeights = r->typ[ord_pos].data.is.componentWeights;
     561
     562        if( componentWeights == NULL )
     563          break;
     564             
     565        const int limit = r->typ[ord_pos].data.is.limit;
     566        assume( limit >= 0 );
     567       
     568        if( k > limit )
     569        {
     570          k -= (limit + 1);
     571          assume( k >= 0 );
     572         
     573          assume( componentWeights != NULL );
     574         
     575          if( k < componentWeights->length() )
     576            j += (*componentWeights)[k]; // j += the weight of k^th-component
     577#ifndef NDEBUG
     578          else
     579            Warn("Unknown (out of known-range (%d)) component index:%d for IS[%d at %d] ordering\n",componentWeights->length(), k, pIS-1, ord_pos);
     580#endif
     581        }
     582        break;
     583      }
    545584      case ringorder_a:
    546585        for (k=b0 /*r->block0[i]*/;k<=b1 /*r->block1[i]*/;k++)
     
    560599  return  j;
    561600}
     601
     602
     603/// compute the total monomial weight for the case of Induced ordering,
     604/// where we already have weight for module components!
     605/// It is only needed to be known by rOptimizeLDeg and rSetDegStuff
     606long p_TotaldegreeIS(poly p, const ring r)
     607{
     608  long s = p_Totaldegree(p, r);
     609
     610  int k = p_GetComp(p, r) - 1;
     611
     612  if ( (k > 0) && (r->typ!=NULL) )
     613  {
     614    int pIS = 0;
     615    for( int pos = 0; pos < r->OrdSize; pos++ )
     616      if( r->typ[pos].ord_typ == ro_is)
     617      {
     618        const intvec* componentWeights = r->typ[pos].data.is.componentWeights;
     619
     620        if( componentWeights == NULL )
     621          continue;
     622
     623        const int limit = r->typ[pos].data.is.limit;
     624        assume( limit >= 0 );
     625       
     626
     627        if( k > limit )
     628        {
     629          k -= (limit + 1);
     630          assume( k >= 0 );
     631
     632          assume( componentWeights != NULL );
     633
     634          if( k < componentWeights->length() )
     635            s += (*componentWeights)[k]; // j += the weight of k^th-component
     636#ifndef NDEBUG
     637          else
     638            Warn("Unknown (out of known-range (%d)) component index:%d for IS[%d at %d] ordering\n",componentWeights->length(), k, pIS-1, pos);
     639#endif
     640        }
     641
     642        pIS++;
     643
     644        return s; // multiple ro_is blocks are not really supported at the moment...
     645      }
     646  }
     647
     648  return s;
     649}
     650
    562651
    563652long p_DegW(poly p, const short *w, const ring R)
  • libpolys/polys/monomials/p_polys.h

    re4f491 r74f51f  
    2121#include <omalloc/omalloc.h>
    2222#include <misc/mylimits.h>
     23#include <misc/intvec.h>
    2324#include <coeffs/coeffs.h>
    2425
  • libpolys/polys/monomials/ring.cc

    re4f491 r74f51f  
    19061906    {
    19071907      sro_ord* o=&(r->typ[pos]);
    1908       if ((o->ord_typ == ro_syzcomp) || (o->ord_typ == ro_syz) || (o->ord_typ == ro_is) || (o->ord_typ == ro_isTemp)) return TRUE;
     1908      if (   (o->ord_typ == ro_syzcomp)
     1909          || (o->ord_typ == ro_syz)
     1910          || (o->ord_typ == ro_is)
     1911          || (o->ord_typ == ro_isTemp))
     1912        return TRUE;
    19091913    }
    19101914  }
     
    20472051          if(r->typ[j].data.is.pVarOffset[i] != -1)
    20482052          {
    2049             // ???
     2053            // TODO???
    20502054          }
    20512055
     
    30593063    case ringorder_IS:
    30603064    { // TODO: What is r->ComponentOrder???
    3061       r->MixedOrder=TRUE;
    3062 /*
    3063       if( r->block0[o] != 0 ) // Suffix has the comonent
     3065//      r->MixedOrder=TRUE;
     3066      if( r->block0[o] != 0 ) // Suffix has the component
    30643067        r->ComponentOrder = r->block0[o];
    3065       else // Prefix has level...
     3068/*      else // Prefix has level...
    30663069        r->ComponentOrder=-1;
    30673070*/
     3071      // TODO: think about this a bit...!?
    30683072      break;
    30693073    }
     
    31413145  int** wvhdl = r->wvhdl;
    31423146
     3147 
     3148
    31433149  if (order[0]==ringorder_S ||order[0]==ringorder_s || order[0]==ringorder_IS)
    31443150  {
     
    32273233
    32283234    /*the number of orderings:*/
    3229     int i = 0;
    3230     while (order[++i] != 0);
     3235    int i = 0; while (order[++i] != 0);
     3236
    32313237    do
    32323238    {
     
    32533259    r->pFDeg = p_Deg;
    32543260
     3261  if( rGetISPos(0, r) != -1 ) // Are there Schreyer induced blocks?
     3262  {
     3263    if( r->pFDeg == p_Totaldegree )
     3264    {
     3265      extern long p_TotaldegreeIS(poly p, const ring r);
     3266      r->pFDeg = p_TotaldegreeIS;
     3267    }
     3268#ifndef NDEBUG   
     3269    else
     3270      assume( r->pFDeg == p_Deg || r->pFDeg == p_WTotaldegree );
     3271#endif
     3272   
     3273    r->pLDeg = pLDeg1;
     3274  }
     3275
    32553276  r->pFDegOrig = r->pFDeg;
     3277  // NOTE: this leads to wrong ecart during std
     3278  // in Old/sre.tst
    32563279  rOptimizeLDeg(r); // also sets r->pLDegOrig
     3280
    32573281}
    32583282
     
    39914015
    39924016      if( r->typ[j].data.is.componentWeights == NULL )
    3993         PrintS("NULL == [0,...0]\n");
     4017        PrintS("NULL == [0,...,0]\n");
    39944018      else
    39954019      {
     
    40734097
    40744098  {
     4099    extern long p_TotaldegreeIS(poly p, const ring r);
     4100
     4101      PrintLn();
     4102      Print("pFDeg   : ");
    40754103#define pFDeg_CASE(A) if(r->pFDeg == A) PrintS( "" #A "" )
    4076     Print("\npFDeg   : ");
    4077 
    4078     pFDeg_CASE(p_Totaldegree); else
     4104      pFDeg_CASE(p_Totaldegree); else
    40794105      pFDeg_CASE(p_WFirstTotalDegree); else
    40804106      pFDeg_CASE(p_WTotaldegree); else
    40814107      pFDeg_CASE(p_Deg); else
     4108      pFDeg_CASE(p_TotaldegreeIS); else
     4109#undef pFDeg_CASE
     4110     
    40824111      Print("(%p)", (void*)(r->pFDeg)); // default case
    40834112
    4084     PrintS("\n");
    4085 #undef pFDeg_CASE
     4113    PrintLn();
     4114    Print("pLDeg   : (%p)", (void*)(r->pLDeg));   
     4115    PrintLn();
    40864116  }
    40874117
     
    47874817/// Finds p^th IS ordering, and returns its position in r->typ[]
    47884818/// returns -1 if something went wrong!
     4819/// p - starts with 0!
    47894820int rGetISPos(const int p, const ring r)
    47904821{
     
    47974828  if (r->typ==NULL)
    47984829  {
    4799     dReportError("'rIsIS:' Error: wrong ring! (typ == NULL)");
     4830//    dReportError("'rIsIS:' Error: wrong ring! (typ == NULL)");
    48004831    return -1;
    48014832  }
     
    48054836    if( r->typ[pos].ord_typ == ro_is)
    48064837      if( j-- == 0 )
    4807       {
    48084838        return pos;
    4809       }
    48104839
    48114840  return -1;
  • libpolys/polys/monomials/ring.h

    re4f491 r74f51f  
    741741BOOLEAN rSetISReference(const ring r, const ideal F, const int i = 0, const int p = 0, const intvec * componentWeights = NULL);
    742742
     743/// return the position of the p^th IS block order block in r->typ[]...
     744int rGetISPos(const int p, const ring r);
     745
    743746BOOLEAN rCheckIV(intvec *iv);
    744747int rTypeOfMatrixOrder(intvec * order);
Note: See TracChangeset for help on using the changeset viewer.