Changeset 0838d7 in git


Ignore:
Timestamp:
Nov 22, 2012, 10:25:46 PM (11 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', '52dcfddee5ec87d404d5e0fb44f2d627608208f1')
Children:
c4138f219380e1837aed8b4bcdfc42c73bee603b
Parents:
4ca3e3c15a08dab1cfe6bed017b0254dc13734b3
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-11-22 22:25:46+01:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2014-05-07 04:41:48+02:00
Message:
Reuse s/k-buckets + removal of CPolynomialSummator

chg: do not explicitly compute length for bucket addition
Location:
dyn_modules/syzextra
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • dyn_modules/syzextra/syzextra.cc

    r4ca3e3 r0838d7  
    3333
    3434#include <polys/kbuckets.h> // for kBucket*
    35 #include <polys/nc/summator.h> // for CPolynomialSummator
     35#include <polys/sbuckets.h> // for sBucket*
     36//#include <polys/nc/summator.h> // for CPolynomialSummator
    3637#include <polys/operations/p_Mult_q.h> // for MIN_LENGTH_BUCKET
    3738
     
    237238  extern void id_Delete (ideal*, const ring);
    238239   
    239  id_Delete(const_cast<ideal*>(&m_idTails), m_rBaseRing); // TODO!!!   
     240  id_Delete(const_cast<ideal*>(&m_idTails), m_rBaseRing); // TODO!!!
     241
     242  if( m_sum_bucket != NULL )
     243  {
     244    sBucketDestroy(&m_sum_bucket);
     245    m_sum_bucket = NULL;
     246  }
     247
     248  if( m_spoly_bucket != NULL )
     249  {
     250    kBucketDestroy(&m_spoly_bucket);
     251    m_spoly_bucket = NULL;
     252  } 
    240253}
    241254  /*
     
    740753  const ring& R = m_rBaseRing;
    741754
     755  if( m_sum_bucket == NULL )
     756    m_sum_bucket = sBucketCreate(R);
     757
     758  if( m_spoly_bucket == NULL )
     759    m_spoly_bucket = kBucketCreate(R);
     760
     761
    742762  assume( IDELEMS(L) == IDELEMS(T) );
    743763#ifndef NDEBUG
     
    941961
    942962  assume( c >= 0 && c < IDELEMS(T) );
    943   kBucket_pt bucket = kBucketCreate(r); kbTest(bucket);
     963  sBucket_pt& tail   = m_sum_bucket; assume( tail != NULL );
     964  kBucket_pt& bucket = m_spoly_bucket; assume( bucket != NULL ); kbTest(bucket);
     965
    944966
    945967//  kBucketInit(bucket, NULL, 0); // not needed!?
     
    947969  poly p = leadmonom(syz_lead, r); // :( 
    948970//  poly spoly = pp_Mult_qq(p, T->m[c], r); 
    949   kBucket_Plus_mm_Mult_pp(bucket, p, T->m[c], pLength(T->m[c])); // TODO: store length of tails separately!?
     971  kBucket_Plus_mm_Mult_pp(bucket, p, T->m[c], 0); // TODO: store pLength(T->m[c]) separately!?
     972  p_Delete(&p, r);
     973 
    950974  kbTest(bucket); 
    951   p_Delete(&p, r);
    952975
    953976  c = p_GetComp(syz_2, r) - 1;
     
    956979  p = leadmonom(syz_2, r); // :(
    957980//  spoly = p_Add_q(spoly, pp_Mult_qq(p, T->m[c], r), r);
    958   kBucket_Plus_mm_Mult_pp(bucket, p, T->m[c], pLength(T->m[c]));
     981  kBucket_Plus_mm_Mult_pp(bucket, p, T->m[c], 0); // pLength(T->m[c])?!
    959982  kbTest(bucket);
    960983  p_Delete(&p, r);
    961984
    962985  // TODO: use bucket!?
    963   const bool bUsePolynomial = TEST_OPT_NOT_BUCKETS; //  || (pLength(spoly) < MIN_LENGTH_BUCKET);
    964   CPolynomialSummator tail(r, bUsePolynomial);
    965   tail.AddAndDelete(syz_2, 1); 
    966 
     986//  const bool bUsePolynomial = TEST_OPT_NOT_BUCKETS; //  || (pLength(spoly) < MIN_LENGTH_BUCKET);
     987//  CPolynomialSummator tail(r, bUsePolynomial);                       
     988  sBucket_Add_p(tail, syz_2, 1); // tail.AddAndDelete(syz_2, 1); 
    967989 
    968990  kbTest(bucket);
     
    9791001      assume( c >= 0 && c < IDELEMS(T) );
    9801002
    981       kBucket_Plus_mm_Mult_pp(bucket, p, T->m[c], pLength(T->m[c])); 
     1003      kBucket_Plus_mm_Mult_pp(bucket, p, T->m[c], 0); // pLength(T->m[c])?
    9821004//      spoly = p_Add_q(spoly, pp_Mult_qq(p, T->m[c], r), r);
    9831005
    9841006      p_Delete(&p, r);
    9851007
    986       tail.AddAndDelete(t, 1); 
     1008      sBucket_Add_p(tail, t, 1); // tail.AddAndDelete(t, 1);
    9871009    } // otherwise discard that leading term altogether!
    9881010    kbTest(bucket);
     
    9921014  kbTest(bucket);
    9931015  assume( kBucketClear(bucket) == NULL );
    994   kBucketDestroy(&bucket); // TODO: reuse the bucket!!!
    995      
    996   return tail;
     1016
     1017  poly result; int len;
     1018  sBucketClearAdd(tail, &result, &len); // TODO: use Merge with sBucket???
     1019  assume( pLength(result) == len );
     1020     
     1021  return result;
    9971022}
    9981023
     
    10281053  if( (!__TAILREDSYZ__) || m_lcm.Check(multiplier) )
    10291054  {
    1030     const bool bUsePolynomial = TEST_OPT_NOT_BUCKETS; //  || (pLength(tail) < MIN_LENGTH_BUCKET);
    1031     CPolynomialSummator sum(r, bUsePolynomial);
     1055//    const bool bUsePolynomial = TEST_OPT_NOT_BUCKETS; //  || (pLength(tail) < MIN_LENGTH_BUCKET);
     1056    sBucket_pt& sum   = m_sum_bucket; assume( sum != NULL );
     1057    poly s; int len;
     1058   
     1059//    CPolynomialSummator sum(r, bUsePolynomial);
    10321060//    poly s = NULL;
    10331061    for(poly p = tail; p != NULL; p = pNext(p))   // iterate over the tail
    1034       sum += ReduceTerm(multiplier, p, NULL);
    1035     return sum;
     1062    {
     1063      // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     1064      // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     1065      // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     1066      const poly rt = ReduceTerm(multiplier, p, NULL); // TODO: also return/store length?
     1067      // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     1068      // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     1069      // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     1070     
     1071      const int lp = pLength(rt);
     1072      if( rt != NULL && lp != 0 )
     1073        sBucket_Add_p(sum, rt, lp);
     1074    }
     1075
     1076    sBucketClearAdd(sum, &s, &len);
     1077    assume( pLength(s) == len );
     1078    return s;
    10361079  }
    10371080
  • dyn_modules/syzextra/syzextra.h

    r4ca3e3 r0838d7  
    328328   
    329329/// TODO: look into m_idTailTerms!!!!!!!!!!!!!!!!!!!!!!!! map? heaps???
     330    // NOTE/TODO: the following globally shared buckets violate reentrance - they should rather belong to TLS!
     331   
     332    /// used for simple summing up
     333    mutable sBucket_pt m_sum_bucket;
     334   
     335    /// for S-Polynomial reductions
     336    mutable kBucket_pt m_spoly_bucket;
    330337};
    331338
Note: See TracChangeset for help on using the changeset viewer.