Changeset e95747 in git


Ignore:
Timestamp:
Apr 13, 2016, 3:13:58 PM (7 years ago)
Author:
Andreas Steenpass <steenpass@…>
Branches:
(u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
Children:
c64ae28929a59f8f299f7b19c3a1f8e0add66d6c
Parents:
7d09f3ae72357972dd5a2f399332c16aa125f56b
git-author:
Andreas Steenpass <steenpass@mathematik.uni-kl.de>2016-04-13 15:13:58+02:00
git-committer:
Andreas Steenpass <steenpass@mathematik.uni-kl.de>2017-12-15 12:17:07+01:00
Message:
chg: remove class CReducerFinder_test
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/GBEngine/syz4.cc

    r7d09f3 re95747  
    294294} CLeadingTerm_struct;
    295295
    296 class CReducerFinder_test
    297 {
    298   public:
    299     typedef long TComponentKey;
    300     typedef std::vector<const CLeadingTerm_struct*> TReducers;
    301 
    302   private:
    303     typedef std::map< TComponentKey, TReducers> CReducersHash;
    304 
    305   public:
    306     /// goes over all leading terms
    307     CReducerFinder_test(const ideal L);
    308 
    309     void redefine(const ideal L);
    310 
    311     void Initialize(const ideal L);
    312 
    313     ~CReducerFinder_test();
    314 
    315     static poly FindReducer(const poly multiplier, const poly monom, const poly syzterm, const CReducerFinder_test& checker);
    316 
    317     bool IsDivisible(const poly q) const;
    318 
    319     inline bool IsNonempty() const { return !m_hash.empty(); }
    320 
    321     int PreProcessTerm(const poly t, CReducerFinder_test& syzChecker) const;
    322 
    323   private:
    324     ideal m_L; ///< only for debug
    325 
    326     CReducersHash m_hash; // can also be replaced with a vector indexed by components
    327 
    328   private:
    329     CReducerFinder_test(const CReducerFinder_test&);
    330     void operator=(const CReducerFinder_test&);
    331 };
    332 
    333 CReducerFinder_test::CReducerFinder_test(const ideal L):
    334     m_L(const_cast<ideal>(L)), // for debug anyway
    335     m_hash()
    336 {
    337   if( L != NULL )
    338     Initialize(L);
    339 }
    340 
    341 CReducerFinder_test::~CReducerFinder_test()
    342 {
    343   for( CReducersHash::iterator it = m_hash.begin(); it != m_hash.end(); it++ )
    344   {
    345     TReducers& v = it->second;
    346     for(TReducers::const_iterator vit = v.begin(); vit != v.end(); vit++ )
    347       omfree(const_cast<CLeadingTerm_struct*>(*vit));
    348     v.erase(v.begin(), v.end());
    349   }
    350   m_hash.erase(m_hash.begin(), m_hash.end());
    351 }
    352 
    353 void CReducerFinder_test::redefine(const ideal L)
    354 {
    355   m_L = const_cast<ideal>(L); // for debug anyway
    356   for( CReducersHash::iterator it = m_hash.begin(); it != m_hash.end(); it++ )
    357   {
    358     TReducers& v = it->second;
    359     for(TReducers::const_iterator vit = v.begin(); vit != v.end(); vit++ )
    360       omfree(const_cast<CLeadingTerm_struct*>(*vit));
    361     v.erase(v.begin(), v.end());
    362   }
    363   m_hash.erase(m_hash.begin(), m_hash.end());
    364   m_hash.clear();
    365   if( L != NULL )
    366     Initialize(L);
    367 }
    368 
    369 static CReducerFinder_test m_checker(NULL);
    370 static CReducerFinder_test m_div(NULL);
    371 
    372 poly CReducerFinder_test::FindReducer(const poly multiplier, const poly t,
    373                                  const poly syzterm,
    374                                  const CReducerFinder_test& syz_checker)
     296typedef std::vector<const CLeadingTerm_struct*> TReducers_test;
     297typedef std::map<long, TReducers_test> CReducersHash_test;
     298
     299static void deleteCRH(CReducersHash_test *C)
     300{
     301    for (CReducersHash_test::iterator it = C->begin(); it != C->end(); it++) {
     302        TReducers_test& v = it->second;
     303        for (TReducers_test::const_iterator vit = v.begin(); vit != v.end();
     304            vit++) {
     305            omfree(const_cast<CLeadingTerm_struct*>(*vit));
     306        }
     307        v.erase(v.begin(), v.end());
     308    }
     309    C->erase(C->begin(), C->end());
     310}
     311
     312static void initialize(CReducersHash_test &C, const ideal L);
     313
     314static void redefine(CReducersHash_test *C, const ideal L)
     315{
     316    deleteCRH(C);
     317    initialize(*C, L);
     318}
     319
     320static CReducersHash_test m_checker;
     321static CReducersHash_test m_div;
     322
     323bool IsDivisible(const CReducersHash_test *C, const poly product);
     324
     325poly FindReducer(const poly multiplier, const poly t, const poly syzterm,
     326    const CReducersHash_test &syz_checker)
    375327{
    376328  const ring r = currRing;
    377   CReducerFinder_test::CReducersHash::const_iterator m_itr
    378       = m_div.m_hash.find(p_GetComp(t, currRing));
    379   if (m_itr == m_div.m_hash.end()) {
     329  CReducersHash_test::const_iterator m_itr
     330      = m_div.find(p_GetComp(t, currRing));
     331  if (m_itr == m_div.end()) {
    380332    return NULL;
    381333  }
    382   CReducerFinder_test::TReducers::const_iterator m_current
    383       = (m_itr->second).begin();
    384   CReducerFinder_test::TReducers::const_iterator m_finish
    385       = (m_itr->second).end();
     334  TReducers_test::const_iterator m_current = (m_itr->second).begin();
     335  TReducers_test::const_iterator m_finish  = (m_itr->second).end();
    386336  if (m_current == m_finish) {
    387337    return NULL;
     
    390340  if (syzterm != NULL)
    391341    c = p_GetComp(syzterm, r) - 1;
    392   const BOOLEAN to_check = (syz_checker.IsNonempty());
     342  const BOOLEAN to_check = !syz_checker.empty();
    393343  const poly q = p_New(r);
    394344  pNext(q) = NULL;
     
    413363    // cannot allow something like: a*gen(i) - a*gen(i)
    414364    if (syzterm != NULL && (k == c))
    415     if (p_ExpVectorEqual(syzterm, q, r))
    416     {
     365    if (p_ExpVectorEqual(syzterm, q, r)) {
    417366      continue;
    418367    }
    419     // while the complement (the fraction) is not reducible by leading syzygies
    420     if( to_check && syz_checker.IsDivisible(q) )
    421     {
     368    if (to_check && IsDivisible(&syz_checker, q)) {
    422369      continue;
    423370    }
    424     number n = n_Mult( p_GetCoeff(multiplier, r), p_GetCoeff(t, r), r);
     371    number n = n_Mult(p_GetCoeff(multiplier, r), p_GetCoeff(t, r), r);
    425372    p_SetCoeff0(q, n_InpNeg(n, r), r);
    426373    return q;
     
    430377}
    431378
    432 bool CReducerFinder_test::IsDivisible(const poly product) const
    433 {
    434     CReducerFinder_test::CReducersHash::const_iterator m_itr
    435         = (*this).m_hash.find(p_GetComp(product, currRing));
    436     if (m_itr == (*this).m_hash.end()) {
     379bool IsDivisible(const CReducersHash_test *C, const poly product)
     380{
     381    CReducersHash_test::const_iterator m_itr
     382        = C->find(p_GetComp(product, currRing));
     383    if (m_itr == C->end()) {
    437384        return false;
    438385    }
    439     CReducerFinder_test::TReducers::const_iterator m_current
    440         = (m_itr->second).begin();
    441     CReducerFinder_test::TReducers::const_iterator m_finish
    442         = (m_itr->second).end();
     386    TReducers_test::const_iterator m_current = (m_itr->second).begin();
     387    TReducers_test::const_iterator m_finish  = (m_itr->second).end();
    443388    const unsigned long m_not_sev = ~p_GetShortExpVector(product, currRing);
    444389    for ( ; m_current != m_finish; ++m_current) {
     
    457402  if( CLCM_test_Check(m_lcm, multiplier) )
    458403  {
    459     s = CReducerFinder_test::FindReducer(multiplier, term4reduction, syztermCheck, m_checker);
     404    s = FindReducer(multiplier, term4reduction, syztermCheck, m_checker);
    460405  }
    461406  if( s == NULL )
     
    472417}
    473418
    474 void CReducerFinder_test::Initialize(const ideal L)
    475 {
    476   if( m_L == NULL )
    477     m_L = L;
     419static void initialize(CReducersHash_test &C, const ideal L)
     420{
    478421  if( L != NULL )
    479422  {
     
    489432        CLT->sev = p_GetShortExpVector(a, R);
    490433        CLT->label = k;
    491         m_hash[p_GetComp(a, R)].push_back( CLT );
     434        C[p_GetComp(a, R)].push_back( CLT );
    492435      }
    493436    }
     
    679622        m_idLeads_test->m[i]->next = NULL;
    680623    }
    681     m_div.redefine(m_idLeads_test);
     624    redefine(&m_div, m_idLeads_test);
    682625    m_lcm = CLCM_test_redefine(m_idLeads_test);
    683626    m_syzLeads_test = idCopy(res[index]);
     
    686629        m_syzLeads_test->m[i]->next = NULL;
    687630    }
    688     m_checker.redefine(m_syzLeads_test);
     631    redefine(&m_checker, m_syzLeads_test);
    689632#if CACHE
    690633    for (TCache_test::iterator it = m_cache_test.begin();
Note: See TracChangeset for help on using the changeset viewer.