Ignore:
Timestamp:
Aug 1, 2012, 5:25:00 PM (11 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '1d362c315e551a5b527ab0759f8839cf0e94f3a5')
Children:
495328d14a955b215ad10b598e995ab522243881
Parents:
026171e1f09fe373a5c6ea5ed0b8db1abeb952f3
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-08-01 17:25:00+02:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2014-05-07 04:41:46+02:00
Message:
separated FindReducer into a separate class CReducerFinder (m_div)

TODO: deal with m_LS via another CReducerFinder?

NOTE: this change resulted in some speedups esp. for Hybrid approach (see schreyer.lib)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • dyn_modules/syzextra/syzextra.cc

    r026171 rdd24e5  
    251251  }
    252252
    253 
    254253  // TODO/NOTE: input is supposed to be (reverse-) sorted wrt "(c,ds)"!??
    255254
     
    489488}
    490489
     490
     491CReducerFinder::CLeadingTerm::CLeadingTerm(unsigned int _label,  const poly _lt, const ring R):
     492    m_sev( p_GetShortExpVector(_lt, R) ),  m_label( _label ),  m_lt( _lt )
     493    { }
     494
     495
     496CReducerFinder::~CReducerFinder()
     497{
     498  for( CReducersHash::const_iterator it = m_hash.begin(); it != m_hash.end(); it++ )
     499  {
     500    const TReducers& v = it->second;
     501    for(TReducers::const_iterator vit = v.begin(); vit != v.end(); vit++ )
     502      delete const_cast<CLeadingTerm*>(*vit);
     503  }
     504}
     505                                   
     506CReducerFinder::CReducerFinder(const SchreyerSyzygyComputation& data): m_data(data), m_hash()
     507{
     508
     509  const ideal& L = data.m_idLeads;
     510  const ring&  R = data.m_rBaseRing;
     511//   const SchreyerSyzygyComputationFlags& attributes = data.m_atttributes;
     512//
     513//   const BOOLEAN __DEBUG__      = attributes.__DEBUG__;
     514//   const BOOLEAN __SYZCHECK__   = attributes.__SYZCHECK__;
     515//   const BOOLEAN __HYBRIDNF__   = attributes.__HYBRIDNF__;
     516//   const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__;
     517
     518
     519  assume( L != NULL );
     520  assume( R != NULL );
     521  assume( R == currRing );
     522
     523  for( int k = IDELEMS(L) - 1; k >= 0; k-- )
     524  {
     525    const poly a = L->m[k]; assume( a != NULL );
     526
     527    // NOTE: label is k \in 0 ... |L|-1!!!
     528    m_hash[p_GetComp(a, R)].push_back( new CLeadingTerm(k, a, R) );
     529  }
     530}
     531
     532
    491533CLCM::CLCM(const SchreyerSyzygyComputation& data): std::vector<bool>(), m_data(data), m_compute(false)
    492534{
     
    606648    poly a2 = pNext(a);   
    607649
     650    // Splitting 2-terms Leading syzygy module
    608651    if( a2 != NULL )
    609652    {
     
    633676      if( a2 == NULL )
    634677      {
    635         aa = p_Mult_mm(aa, L->m[r], R);
    636         a2 = FindReducer(aa, a);
     678        aa = p_Mult_mm(aa, L->m[r], R); a2 = m_div.FindReducer(aa, a);
    637679      }
    638680      assume( a2 != NULL );
     
    677719}
    678720
    679 poly SchreyerSyzygyComputation::FindReducer(poly product, poly syzterm) const
     721poly CReducerFinder::FindReducer(const poly product, const poly syzterm) const
    680722{
    681723//  return FROM_NAMESPACE(INTERNAL, _FindReducer(product, syzterm, m_idLeads, m_LS, m_rBaseRing, m_atttributes));
     
    685727//                     const SchreyerSyzygyComputationFlags attributes)
    686728
    687   const ideal& L = m_idLeads;
    688   const ideal& LS = m_LS;
    689   const ring& r = m_rBaseRing;
    690   const SchreyerSyzygyComputationFlags& attributes = m_atttributes;
     729  const ideal& L = m_data.m_idLeads;
     730  const ideal& LS = m_data.m_LS;
     731  const ring& r = m_data.m_rBaseRing;
     732  const SchreyerSyzygyComputationFlags& attributes = m_data.m_atttributes;
    691733
    692734
     
    700742  assume( L != NULL );
    701743
    702   int c = 0;
     744  long c = 0;
    703745
    704746  if (syzterm != NULL)
     
    706748
    707749  assume( c >= 0 && c < IDELEMS(L) );
    708 
    709   if (__SYZCHECK__ && syzterm != NULL)
     750 
     751  if (__DEBUG__ && (syzterm != NULL))
    710752  {
    711753    const poly m = L->m[c];
     
    722764  }
    723765
    724   // looking for an appropriate diviser q = L[k]...
    725   for( int k = IDELEMS(L)-1; k>= 0; k-- )
    726   {
    727     const poly p = L->m[k];   
    728 
    729     // ... which divides the product, looking for the _1st_ appropriate one!
    730     if( !p_LmDivisibleBy(p, product, r) )
    731       continue;
     766  const long comp = p_GetComp(product, r);
     767  const unsigned long not_sev = ~p_GetShortExpVector(product, r);
     768
     769  assume( comp >= 0 );
     770
     771   // looking for an appropriate diviser p = L[k]...
     772#if 1
     773  CReducersHash::const_iterator it = m_hash.find(p_GetComp(product, r)); // same module component
     774   
     775  if( it == m_hash.end() )
     776    return NULL;
     777
     778  const TReducers& reducers = it->second; 
     779 
     780  for(TReducers::const_iterator vit = reducers.begin(); vit != reducers.end(); vit++ )
     781  {
     782     const poly p = (*vit)->m_lt;
     783
     784     assume( p_GetComp(p, r) == comp );
     785     
     786     const int k = (*vit)->m_label;
     787
     788     assume( L->m[k] == p );
     789     
     790     const unsigned long p_sev = (*vit)->m_sev;
     791
     792     assume( p_sev == p_GetShortExpVector(p, r) );     
     793#else 
     794   for( int k = IDELEMS(L)-1; k>= 0; k-- )
     795   {
     796     const poly p = L->m[k];
     797     
     798     if ( p_GetComp(p, r) != comp )
     799       continue;
     800       
     801     const unsigned long p_sev = p_GetShortExpVector(p, r); // to be stored in m_hash!!!
     802#endif
     803     
     804     if( !p_LmShortDivisibleByNoComp(p, p_sev, product, not_sev, r) )
     805       continue;     
     806
     807//     // ... which divides the product, looking for the _1st_ appropriate one!
     808//     if( !p_LmDivisibleByNoComp(p, product, r) ) // included inside  p_LmShortDivisibleBy!
     809//       continue;
    732810
    733811
     
    758836      BOOLEAN ok = TRUE;
    759837
     838      // TODO: FindReducer in LS !!! there should be no divisors!
    760839      for(int kk = IDELEMS(LS)-1; kk>= 0; kk-- )
    761840      {
     
    842921  while (spoly != NULL)
    843922  {
    844     poly t = FindReducer(spoly, NULL);
     923    poly t = m_div.FindReducer(spoly, NULL);
    845924
    846925    p_LmDelete(&spoly, r);
     
    9421021    // NOTE: only LT(term4reduction) should be used in the following:
    9431022    poly product = pp_Mult_mm(multiplier, term4reduction, r);
    944     s = FindReducer(product, syztermCheck);
     1023    s = m_div.FindReducer(product, syztermCheck);
    9451024    p_Delete(&product, r);
    9461025  }
Note: See TracChangeset for help on using the changeset viewer.