Changeset e95747 in git
- Timestamp:
- Apr 13, 2016, 3:13:58 PM (7 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/GBEngine/syz4.cc
r7d09f3 re95747 294 294 } CLeadingTerm_struct; 295 295 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) 296 typedef std::vector<const CLeadingTerm_struct*> TReducers_test; 297 typedef std::map<long, TReducers_test> CReducersHash_test; 298 299 static 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 312 static void initialize(CReducersHash_test &C, const ideal L); 313 314 static void redefine(CReducersHash_test *C, const ideal L) 315 { 316 deleteCRH(C); 317 initialize(*C, L); 318 } 319 320 static CReducersHash_test m_checker; 321 static CReducersHash_test m_div; 322 323 bool IsDivisible(const CReducersHash_test *C, const poly product); 324 325 poly FindReducer(const poly multiplier, const poly t, const poly syzterm, 326 const CReducersHash_test &syz_checker) 375 327 { 376 328 const ring r = currRing; 377 CReducer Finder_test::CReducersHash::const_iterator m_itr378 = 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()) { 380 332 return NULL; 381 333 } 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(); 386 336 if (m_current == m_finish) { 387 337 return NULL; … … 390 340 if (syzterm != NULL) 391 341 c = p_GetComp(syzterm, r) - 1; 392 const BOOLEAN to_check = (syz_checker.IsNonempty());342 const BOOLEAN to_check = !syz_checker.empty(); 393 343 const poly q = p_New(r); 394 344 pNext(q) = NULL; … … 413 363 // cannot allow something like: a*gen(i) - a*gen(i) 414 364 if (syzterm != NULL && (k == c)) 415 if (p_ExpVectorEqual(syzterm, q, r)) 416 { 365 if (p_ExpVectorEqual(syzterm, q, r)) { 417 366 continue; 418 367 } 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)) { 422 369 continue; 423 370 } 424 number n = n_Mult( 371 number n = n_Mult(p_GetCoeff(multiplier, r), p_GetCoeff(t, r), r); 425 372 p_SetCoeff0(q, n_InpNeg(n, r), r); 426 373 return q; … … 430 377 } 431 378 432 bool CReducerFinder_test::IsDivisible(const poly product) const433 { 434 CReducer Finder_test::CReducersHash::const_iterator m_itr435 = (*this).m_hash.find(p_GetComp(product, currRing));436 if (m_itr == (*this).m_hash.end()) {379 bool 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()) { 437 384 return false; 438 385 } 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(); 443 388 const unsigned long m_not_sev = ~p_GetShortExpVector(product, currRing); 444 389 for ( ; m_current != m_finish; ++m_current) { … … 457 402 if( CLCM_test_Check(m_lcm, multiplier) ) 458 403 { 459 s = CReducerFinder_test::FindReducer(multiplier, term4reduction, syztermCheck, m_checker);404 s = FindReducer(multiplier, term4reduction, syztermCheck, m_checker); 460 405 } 461 406 if( s == NULL ) … … 472 417 } 473 418 474 void CReducerFinder_test::Initialize(const ideal L) 475 { 476 if( m_L == NULL ) 477 m_L = L; 419 static void initialize(CReducersHash_test &C, const ideal L) 420 { 478 421 if( L != NULL ) 479 422 { … … 489 432 CLT->sev = p_GetShortExpVector(a, R); 490 433 CLT->label = k; 491 m_hash[p_GetComp(a, R)].push_back( CLT );434 C[p_GetComp(a, R)].push_back( CLT ); 492 435 } 493 436 } … … 679 622 m_idLeads_test->m[i]->next = NULL; 680 623 } 681 m_div.redefine(m_idLeads_test);624 redefine(&m_div, m_idLeads_test); 682 625 m_lcm = CLCM_test_redefine(m_idLeads_test); 683 626 m_syzLeads_test = idCopy(res[index]); … … 686 629 m_syzLeads_test->m[i]->next = NULL; 687 630 } 688 m_checker.redefine(m_syzLeads_test);631 redefine(&m_checker, m_syzLeads_test); 689 632 #if CACHE 690 633 for (TCache_test::iterator it = m_cache_test.begin();
Note: See TracChangeset
for help on using the changeset viewer.