Changeset 9936d6 in git for dyn_modules/syzextra/syzextra.cc
- Timestamp:
- Feb 12, 2013, 6:46:45 PM (11 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 31a08c219875a2199e6c67adcf1eef18ba4a3a4f
- Parents:
- 13a431151fe0f14cbbed84bbf95df65eff7bc567
- git-author:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2013-02-12 18:46:45+01:00
- git-committer:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2014-05-07 04:41:47+02:00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
dyn_modules/syzextra/syzextra.cc
r13a431 r9936d6 30 30 #include <polys/monomials/p_polys.h> 31 31 #include <polys/monomials/ring.h> 32 #include <polys/simpleideals.h> 32 33 33 34 #include <kernel/kstd1.h> … … 36 37 #include <kernel/ideals.h> 37 38 39 #include <kernel/timer.h> 38 40 39 41 … … 152 154 /// return a new term: leading coeff * leading monomial of p 153 155 /// with 0 leading component! 154 poly leadmonom(const poly p, const ring r )156 poly leadmonom(const poly p, const ring r, const bool bSetZeroComp) 155 157 { 156 158 poly m = NULL; … … 164 166 p_SetCoeff0(m, n_Copy(p_GetCoeff(p, r), r), r); 165 167 166 p_SetComp(m, 0, r); 168 if( bSetZeroComp ) 169 p_SetComp(m, 0, r); 167 170 p_Setm(m, r); 168 171 169 assume( p_GetComp(m, r) == 0 );172 170 173 assume( m != NULL ); 171 174 assume( pNext(m) == NULL ); 172 175 assume( p_LmTest(m, r) ); 176 177 if( bSetZeroComp ) 178 assume( p_GetComp(m, r) == 0 ); 173 179 } 174 180 … … 225 231 void SchreyerSyzygyComputation::CleanUp() 226 232 { 233 extern void id_Delete (ideal*, const ring); 234 235 id_Delete(const_cast<ideal*>(&m_idTails), m_rBaseRing); // TODO!!! 236 } 227 237 /* 228 238 for( TTailTerms::const_iterator it = m_idTailTerms.begin(); it != m_idTailTerms.end(); it++ ) … … 233 243 } 234 244 */ 235 } 236 237 238 239 void SchreyerSyzygyComputation::SetUpTailTerms(const ideal idTails) 240 { 245 246 247 248 bool CReducerFinder::PreProcessTerm(const poly t, CReducerFinder& syzChecker) const 249 { 250 assume( t != NULL ); 251 252 if( __DEBUG__ && __TAILREDSYZ__ ) 253 assume( !IsDivisible(t) ); // each input term should NOT be in <L> 254 255 const ring r = m_rBaseRing; 256 257 258 if( __TAILREDSYZ__ ) 259 if( p_LmIsConstant(t, r) ) // most basic case of baing coprime with L, whatever that is... 260 return true; // TODO: prove this...? 261 262 // return false; // appears to be fine 263 264 const long comp = p_GetComp(t, r); 265 266 CReducersHash::const_iterator itr = m_hash.find(comp); 267 268 if ( itr == m_hash.end() ) 269 return true; // no such leading component!!! 270 271 const bool bIdealCase = (comp == 0); 272 const bool bSyzCheck = syzChecker.IsNonempty(); // need to check even in ideal case????? proof? "&& !bIdealCase" 273 274 // return false; 275 if( __TAILREDSYZ__ && (bIdealCase || bSyzCheck) ) 276 { 277 const TReducers& v = itr->second; 278 const int N = rVar(r); 279 // TODO: extract exps of t beforehand?! 280 bool coprime = true; 281 for(TReducers::const_iterator vit = v.begin(); (vit != v.end()) && coprime; ++vit ) 282 { 283 assume( m_L->m[(*vit)->m_label] == (*vit)->m_lt ); 284 285 const poly p = (*vit)->m_lt; 286 287 assume( p_GetComp(p, r) == comp ); 288 289 // TODO: check if coprime with Leads... if __TAILREDSYZ__ ! 290 for( int var = N; var > 0; --var ) 291 if( (p_GetExp(p, var, r) != 0) && (p_GetExp(t, var, r) != 0) ) 292 { 293 if( __DEBUG__ || 0) 294 { 295 PrintS("CReducerFinder::PreProcessTerm, 't' is NOT co-prime with the following leading term: \n"); 296 dPrint(p, r, r, 1); 297 } 298 coprime = false; // t not coprime with p! 299 break; 300 } 301 302 if( bSyzCheck && coprime ) 303 { 304 poly ss = p_LmInit(t, r); 305 p_SetCoeff0(ss, n_Init(1, r), r); // for delete & printout only!... 306 p_SetComp(ss, (*vit)->m_label + 1, r); // coeff? 307 p_Setm(ss, r); 308 309 coprime = ( syzChecker.IsDivisible(ss) ); 310 311 if( __DEBUG__ && !coprime) 312 { 313 PrintS("CReducerFinder::PreProcessTerm, 't' is co-prime with p but may lead to NOT divisible syz.term: \n"); 314 dPrint(ss, r, r, 1); 315 } 316 317 p_LmDelete(&ss, r); // deletes coeff as well??? 318 } 319 320 } 321 322 if( __DEBUG__ && coprime ) 323 PrintS("CReducerFinder::PreProcessTerm, the following 't' is 'co-prime' with all of leading terms! \n"); 324 325 return coprime; // t was coprime with all of leading terms!!! 326 327 } 328 // return true; // delete the term 329 330 return false; 331 332 333 } 334 335 336 void SchreyerSyzygyComputation::SetUpTailTerms() 337 { 338 const ideal idTails = m_idTails; 241 339 assume( idTails != NULL ); 242 340 assume( idTails->m != NULL ); 341 const ring r = m_rBaseRing; 342 343 if( __DEBUG__ || 0) 344 { 345 PrintS("SchreyerSyzygyComputation::SetUpTailTerms(): Tails: \n"); 346 dPrint(idTails, r, r, 0); 347 } 348 349 unsigned long pp = 0; // count preprocessed terms... 350 351 for( int p = IDELEMS(idTails) - 1; p >= 0; --p ) 352 for( poly* tt = &(idTails->m[p]); (*tt) != NULL; ) 353 { 354 const poly t = *tt; 355 if( m_div.PreProcessTerm(t, m_checker) ) 356 { 357 if( __DEBUG__ || 0) 358 { 359 PrintS("SchreyerSyzygyComputation::SetUpTailTerms(): PP the following TT: \n"); 360 dPrint(t, r, r, 1); 361 } 362 ++pp; 363 364 (*tt) = p_LmDeleteAndNext(t, r); // delete the lead and next... 365 } 366 else 367 tt = &pNext(t); // go next? 368 369 } 370 371 if( TEST_OPT_PROT || 1) 372 Print("**!!** SchreyerSyzygyComputation::SetUpTailTerms()::PreProcessing has eliminated %u terms!\n", pp); 373 374 375 if( __DEBUG__ || 0) 376 { 377 PrintS("SchreyerSyzygyComputation::SetUpTailTerms(): Preprocessed Tails: \n"); 378 dPrint(idTails, r, r, 0); 379 } 380 } 243 381 /* 244 382 m_idTailTerms.resize( IDELEMS(idTails) ); … … 265 403 } 266 404 */ 267 }268 405 269 406 … … 568 705 569 706 570 571 707 void SchreyerSyzygyComputation::ComputeSyzygy() 572 708 { … … 581 717 582 718 assume( IDELEMS(L) == IDELEMS(T) ); 719 int t, r; 583 720 584 721 if( m_syzLeads == NULL ) 722 { 723 if( TEST_OPT_PROT && 1) 724 { 725 /* initTimer(); 726 initRTimer(); 727 startTimer(); 728 startRTimer();*/ 729 730 t = getTimer(); 731 r = getRTimer(); 732 Print("%d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::ComputeLeadingSyzygyTerms: t: %d, r: %d\n", getRTimer(), t, r); 733 } 734 585 735 ComputeLeadingSyzygyTerms( __LEAD2SYZ__ && !__IGNORETAILS__ ); // 2 terms OR 1 term! 736 if( TEST_OPT_PROT && 1) 737 { 738 t = getTimer() - t; 739 r = getRTimer() - r; 740 741 Print("%d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::ComputeLeadingSyzygyTerms: t: %d, r: %d\n", getRTimer(), t, r); 742 } 743 744 } 745 586 746 587 747 assume( m_syzLeads != NULL ); … … 596 756 if( size == 1 && LL->m[0] == NULL ) 597 757 return; 598 758 759 if( !__IGNORETAILS__) 760 { 761 if( T != NULL ) 762 { 763 764 if( TEST_OPT_PROT && 1 ) 765 { 766 // initTimer(); 767 // initRTimer(); 768 // startTimer(); 769 // startRTimer(); 770 771 t = getTimer(); 772 r = getRTimer(); 773 Print("%d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::SetUpTailTerms(): t: %d, r: %d\n", getRTimer(), t, r); 774 } 775 776 SetUpTailTerms(); 777 778 if( TEST_OPT_PROT && 1) 779 { 780 t = getTimer() - t; 781 r = getRTimer() - r; 782 783 Print("%d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::SetUpTailTerms(): t: %d, r: %d\n", getRTimer(), t, r); 784 } 785 786 787 788 } 789 } 790 791 if( TEST_OPT_PROT && 1) 792 { 793 // initTimer(); 794 // initRTimer(); 795 // startTimer(); 796 // startRTimer(); 797 798 t = getTimer(); 799 r = getRTimer(); 800 Print("%d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::SyzygyLift: t: %d, r: %d\n", getRTimer(), t, r); 801 } 599 802 600 803 for( int k = size - 1; k >= 0; k-- ) … … 631 834 632 835 } 633 634 TT->rank = id_RankFreeModule(TT, R); 836 837 if( TEST_OPT_PROT && 1) 838 { 839 t = getTimer() - t; 840 r = getRTimer(); - r; 841 842 Print("%d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::SyzygyLift: t: %d, r: %d\n", getRTimer(), t, r); 843 } 844 845 846 847 TT->rank = id_RankFreeModule(TT, R); 635 848 } 636 849 … … 772 985 assume( tail >= 0 && tail < IDELEMS(m_idTails) ); 773 986 774 const poly t = m_idTails->m[tail]; 987 const poly t = m_idTails->m[tail]; // !!! 775 988 776 989 if(t != NULL) … … 1335 1548 poly lm = p_Mult_mm(leadmonom(syzterm, r), m, r); 1336 1549 1337 poly pr = p_Mult_q( p_LmInit(multiplier, r), p_LmInit(t, r), r);1550 poly pr = p_Mult_q( leadmonom(multiplier, r, false), leadmonom(t, r, false), r); 1338 1551 1339 1552 assume( p_EqualPolys(lm, pr, r) ); … … 1394 1607 return q; 1395 1608 } 1396 1397 p_LmFree(q, r); 1398 1399 return NULL; 1400 1401 1402 1403 1404 1405 #if 0 1609 1610 /* 1406 1611 const long comp = p_GetComp(t, r); assume( comp >= 0 ); 1407 1612 const unsigned long not_sev = ~p_GetShortExpVector(multiplier, t, r); // ! … … 1484 1689 return q; 1485 1690 } 1691 */ 1486 1692 1487 1693 p_LmFree(q, r); 1488 1694 1489 1695 return NULL; 1490 #endif 1696 1491 1697 } 1492 1698 … … 1494 1700 poly CReducerFinder::FindReducer(const poly product, const poly syzterm, const CReducerFinder& syz_checker) const 1495 1701 { 1702 CDivisorEnumerator itr(*this, product); 1703 if( !itr.Reset() ) 1704 return NULL; 1705 1706 1496 1707 const ring& r = m_rBaseRing; 1497 1708 … … 1522 1733 } 1523 1734 1524 const long comp = p_GetComp(product, r);1525 const unsigned long not_sev = ~p_GetShortExpVector(product, r);1526 1527 assume( comp >= 0 );1528 1529 // for( int k = IDELEMS(L)-1; k>= 0; k-- )1530 // {1531 // const poly p = L->m[k];1532 //1533 // if ( p_GetComp(p, r) != comp )1534 // continue;1535 //1536 // const unsigned long p_sev = p_GetShortExpVector(p, r); // to be stored in m_hash!!!1537 1538 // looking for an appropriate diviser p = L[k]...1539 CReducersHash::const_iterator it = m_hash.find(comp); // same module component1540 1541 if( it == m_hash.end() )1542 return NULL;1543 1544 assume( m_L != NULL );1545 1546 const TReducers& reducers = it->second;1547 1735 1548 1736 const BOOLEAN to_check = (syz_checker.IsNonempty()); // __TAILREDSYZ__ && … … 1552 1740 if( __DEBUG__ ) 1553 1741 p_SetCoeff0(q, 0, r); // for printing q 1554 1555 for(TReducers::const_iterator vit = reducers.begin(); vit != reducers.end(); vit++ ) 1556 { 1557 const poly p = (*vit)->m_lt; 1558 1559 assume( p_GetComp(p, r) == comp ); 1560 1561 const int k = (*vit)->m_label; 1562 1563 assume( L->m[k] == p ); 1564 1565 const unsigned long p_sev = (*vit)->m_sev; 1566 1567 assume( p_sev == p_GetShortExpVector(p, r) ); 1568 1569 if( !p_LmShortDivisibleByNoComp(p, p_sev, product, not_sev, r) ) 1570 continue; 1571 1572 // // ... which divides the product, looking for the _1st_ appropriate one! 1573 // if( !p_LmDivisibleByNoComp(p, product, r) ) // included inside p_LmShortDivisibleBy! 1574 // continue; 1575 1742 1743 while( itr.MoveNext() ) 1744 { 1745 const poly p = itr.Current().m_lt; 1746 const int k = itr.Current().m_label; 1747 1576 1748 p_ExpVectorDiff(q, product, p, r); // (LM(product) / LM(L[k])) 1577 1749 p_SetComp(q, k + 1, r); … … 1598 1770 PrintS("_FindReducer::Test LS: q is divisible by LS[?] !:((: "); 1599 1771 } 1772 1773 continue; 1774 } 1775 1776 p_SetCoeff0(q, n_Neg( n_Div( p_GetCoeff(product, r), p_GetCoeff(p, r), r), r), r); 1777 1778 return q; 1779 } 1780 1781 1782 1783 /* 1784 const long comp = p_GetComp(product, r); 1785 const unsigned long not_sev = ~p_GetShortExpVector(product, r); 1786 1787 assume( comp >= 0 ); 1788 1789 // for( int k = IDELEMS(L)-1; k>= 0; k-- ) 1790 // { 1791 // const poly p = L->m[k]; 1792 // 1793 // if ( p_GetComp(p, r) != comp ) 1794 // continue; 1795 // 1796 // const unsigned long p_sev = p_GetShortExpVector(p, r); // to be stored in m_hash!!! 1797 1798 // looking for an appropriate diviser p = L[k]... 1799 CReducersHash::const_iterator it = m_hash.find(comp); // same module component 1800 1801 if( it == m_hash.end() ) 1802 return NULL; 1803 1804 assume( m_L != NULL ); 1805 1806 const TReducers& reducers = it->second; 1807 1808 const BOOLEAN to_check = (syz_checker.IsNonempty()); // __TAILREDSYZ__ && 1809 1810 const poly q = p_New(r); pNext(q) = NULL; 1811 1812 if( __DEBUG__ ) 1813 p_SetCoeff0(q, 0, r); // for printing q 1814 1815 for(TReducers::const_iterator vit = reducers.begin(); vit != reducers.end(); vit++ ) 1816 { 1817 const poly p = (*vit)->m_lt; 1818 1819 assume( p_GetComp(p, r) == comp ); 1820 1821 const int k = (*vit)->m_label; 1822 1823 assume( L->m[k] == p ); 1824 1825 const unsigned long p_sev = (*vit)->m_sev; 1826 1827 assume( p_sev == p_GetShortExpVector(p, r) ); 1828 1829 if( !p_LmShortDivisibleByNoComp(p, p_sev, product, not_sev, r) ) 1830 continue; 1831 1832 // // ... which divides the product, looking for the _1st_ appropriate one! 1833 // if( !p_LmDivisibleByNoComp(p, product, r) ) // included inside p_LmShortDivisibleBy! 1834 // continue; 1835 1836 p_ExpVectorDiff(q, product, p, r); // (LM(product) / LM(L[k])) 1837 p_SetComp(q, k + 1, r); 1838 p_Setm(q, r); 1839 1840 // cannot allow something like: a*gen(i) - a*gen(i) 1841 if (syzterm != NULL && (k == c)) 1842 if (p_ExpVectorEqual(syzterm, q, r)) 1843 { 1844 if( __DEBUG__ ) 1845 { 1846 Print("_FindReducer::Test SYZTERM: q == syzterm !:((, syzterm is: "); 1847 dPrint(syzterm, r, r, 1); 1848 } 1849 1850 continue; 1851 } 1852 1853 // while the complement (the fraction) is not reducible by leading syzygies 1854 if( to_check && syz_checker.IsDivisible(q) ) 1855 { 1856 if( __DEBUG__ ) 1857 { 1858 PrintS("_FindReducer::Test LS: q is divisible by LS[?] !:((: "); 1859 } 1600 1860 1601 1861 continue; … … 1605 1865 return q; 1606 1866 } 1867 */ 1607 1868 1608 1869 p_LmFree(q, r);
Note: See TracChangeset
for help on using the changeset viewer.