Changeset 495328 in git for dyn_modules/syzextra
- Timestamp:
- Aug 2, 2012, 8:11:43 PM (11 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'f875bbaccd0831e36aaed09ff6adeb3eb45aeb94')
- Children:
- 5cecde90d96d1acc0cbd216cf0037bd2db293c31
- Parents:
- dd24e5dded66979eda13e955b93fc284cbb341e7
- git-author:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-08-02 20:11:43+02:00
- git-committer:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2014-05-07 04:41:46+02:00
- Location:
- dyn_modules/syzextra
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
dyn_modules/syzextra/mod_main.cc
rdd24e5 r495328 517 517 // const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__; 518 518 519 const ring r = currRing;519 const ring r = attributes.m_rBaseRing; 520 520 NoReturn(res); 521 521 … … 544 544 h = h->Next(); assume (h == NULL); 545 545 546 const ideal newid = ComputeLeadingSyzygyTerms(id, r,attributes);546 const ideal newid = ComputeLeadingSyzygyTerms(id, attributes); 547 547 548 548 res->data = newid; res->rtyp = MODUL_CMD; … … 569 569 NoReturn(res); 570 570 571 const ring r = currRing;571 const ring r = attributes.m_rBaseRing; 572 572 NoReturn(res); 573 573 … … 629 629 // const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__; 630 630 631 const ring r = currRing;631 const ring r = attributes.m_rBaseRing; 632 632 NoReturn(res); 633 633 … … 656 656 h = h->Next(); assume (h == NULL); 657 657 658 res->data = Compute2LeadingSyzygyTerms(id, r,attributes);658 res->data = Compute2LeadingSyzygyTerms(id, attributes); 659 659 res->rtyp = MODUL_CMD; 660 660 … … 680 680 681 681 const char* usage = "`FindReducer(<poly/vector>, <vector/0>, <ideal/module>[,<module>])` expected"; 682 const ring r = currRing;682 const ring r = attributes.m_rBaseRing; 683 683 684 684 NoReturn(res); … … 750 750 751 751 res->rtyp = VECTOR_CMD; 752 res->data = FindReducer(product, syzterm, L, LS, r,attributes);752 res->data = FindReducer(product, syzterm, L, LS, attributes); 753 753 754 754 if( __DEBUG__ ) … … 774 774 775 775 const char* usage = "`SchreyerSyzygyNF(<vector>, <vector>, <ideal/module>, <ideal/module>[,<module>])` expected"; 776 const ring r = currRing;776 const ring r = attributes.m_rBaseRing; 777 777 778 778 NoReturn(res); … … 852 852 853 853 res->rtyp = VECTOR_CMD; 854 res->data = SchreyerSyzygyNF(syz_lead, syz_2, L, T, LS, r,attributes);854 res->data = SchreyerSyzygyNF(syz_lead, syz_2, L, T, LS, attributes); 855 855 856 856 if( __DEBUG__ ) … … 873 873 874 874 const BOOLEAN __DEBUG__ = attributes.__DEBUG__; 875 const BOOLEAN __SYZCHECK__ = attributes.__SYZCHECK__;875 // const BOOLEAN __SYZCHECK__ = attributes.__SYZCHECK__; 876 876 // const BOOLEAN __LEAD2SYZ__ = attributes.__LEAD2SYZ__; 877 877 // const BOOLEAN __HYBRIDNF__ = attributes.__HYBRIDNF__; … … 879 879 880 880 const char* usage = "`ReduceTerm(<poly>, <poly/vector>, <vector/0>, <ideal/module>, <ideal/module>[,<module>])` expected"; 881 const ring r = currRing;881 const ring r = attributes.m_rBaseRing; 882 882 883 883 NoReturn(res); … … 970 970 971 971 972 if (__ SYZCHECK__ && syztermCheck != NULL)972 if (__DEBUG__ && syztermCheck != NULL) 973 973 { 974 974 const int c = p_GetComp(syztermCheck, r) - 1; … … 992 992 993 993 res->rtyp = VECTOR_CMD; 994 res->data = ReduceTerm(multiplier, term4reduction, syztermCheck, L, T, LS, r,attributes);994 res->data = ReduceTerm(multiplier, term4reduction, syztermCheck, L, T, LS, attributes); 995 995 996 996 … … 1021 1021 1022 1022 const char* usage = "`TraverseTail(<poly>, <poly/vector>, <ideal/module>, <ideal/module>[,<module>])` expected"; 1023 const ring r = currRing;1023 const ring r = attributes.m_rBaseRing; 1024 1024 1025 1025 NoReturn(res); … … 1099 1099 1100 1100 res->rtyp = VECTOR_CMD; 1101 res->data = TraverseTail(multiplier, tail, L, T, LS, r,attributes);1101 res->data = TraverseTail(multiplier, tail, L, T, LS, attributes); 1102 1102 1103 1103 … … 1126 1126 1127 1127 const char* usage = "`ComputeSyzygy(<ideal/module>, <ideal/module>])` expected"; 1128 const ring r = currRing;1128 const ring r = attributes.m_rBaseRing; 1129 1129 1130 1130 NoReturn(res); … … 1163 1163 ideal LL, TT; 1164 1164 1165 ComputeSyzygy(L, T, LL, TT, r,attributes);1165 ComputeSyzygy(L, T, LL, TT, attributes); 1166 1166 1167 1167 lists l = (lists)omAllocBin(slists_bin); l->Init(2); -
dyn_modules/syzextra/syzextra.cc
rdd24e5 r495328 227 227 const ideal& id = m_idLeads; 228 228 const ring& r = m_rBaseRing; 229 const SchreyerSyzygyComputationFlags& attributes = m_atttributes; 230 231 232 // const BOOLEAN __DEBUG__ = attributes.__DEBUG__; 229 // const SchreyerSyzygyComputationFlags& attributes = m_atttributes; 230 231 // const BOOLEAN __DEBUG__ = attributes.__DEBUG__; 233 232 // const BOOLEAN __SYZCHECK__ = attributes.__SYZCHECK__; 234 const BOOLEAN __LEAD2SYZ__ = attributes.__LEAD2SYZ__;233 // const BOOLEAN __LEAD2SYZ__ = attributes.__LEAD2SYZ__; 235 234 // const BOOLEAN __HYBRIDNF__ = attributes.__HYBRIDNF__; 236 235 // const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__; … … 342 341 const ideal& id = m_idLeads; 343 342 const ring& r = m_rBaseRing; 344 const SchreyerSyzygyComputationFlags& attributes = m_atttributes;343 // const SchreyerSyzygyComputationFlags& attributes = m_atttributes; 345 344 346 345 // const BOOLEAN __DEBUG__ = attributes.__DEBUG__; … … 348 347 // const BOOLEAN __LEAD2SYZ__ = attributes.__LEAD2SYZ__; 349 348 // const BOOLEAN __HYBRIDNF__ = attributes.__HYBRIDNF__; 350 const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__;349 // const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__; 351 350 352 351 … … 488 487 } 489 488 490 491 CReducerFinder::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 496 CReducerFinder::~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 506 CReducerFinder::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 533 CLCM::CLCM(const SchreyerSyzygyComputation& data): std::vector<bool>(), m_data(data), m_compute(false)534 {535 const ideal& L = data.m_idLeads;536 const ring& R = data.m_rBaseRing;537 const SchreyerSyzygyComputationFlags& attributes = data.m_atttributes;538 539 // const BOOLEAN __DEBUG__ = attributes.__DEBUG__;540 // const BOOLEAN __SYZCHECK__ = attributes.__SYZCHECK__;541 const BOOLEAN __HYBRIDNF__ = attributes.__HYBRIDNF__;542 const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__;543 544 545 assume( L != NULL );546 assume( R != NULL );547 assume( R == currRing );548 549 if( __TAILREDSYZ__ && !__HYBRIDNF__ )550 {551 const int l = IDELEMS(L);552 553 resize(l, false);554 555 const unsigned int N = rVar(R);556 557 for( int k = l - 1; k >= 0; k-- )558 {559 const poly a = L->m[k]; assume( a != NULL );560 561 for (unsigned int j = N; j > 0; j--)562 if ( !(*this)[j] )563 (*this)[j] = (p_GetExp(a, j, R) > 0);564 }565 566 m_compute = true;567 }568 }569 570 571 bool CLCM::Check(const poly m) const572 {573 assume( m != NULL );574 if( m_compute && (m != NULL))575 {576 const ring& R = m_data.m_rBaseRing;577 const SchreyerSyzygyComputationFlags& attributes = m_data.m_atttributes;578 579 // const BOOLEAN __DEBUG__ = attributes.__DEBUG__;580 // const BOOLEAN __SYZCHECK__ = attributes.__SYZCHECK__;581 const BOOLEAN __HYBRIDNF__ = attributes.__HYBRIDNF__;582 const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__;583 584 assume( R != NULL );585 assume( R == currRing );586 587 assume( __TAILREDSYZ__ && !__HYBRIDNF__ );588 589 const unsigned int N = rVar(R);590 591 for (unsigned int j = N; j > 0; j--)592 if ( (*this)[j] )593 if(p_GetExp(m, j, R) > 0)594 return true;595 596 return false;597 598 } else return true;599 }600 601 489 void SchreyerSyzygyComputation::ComputeSyzygy() 602 490 { … … 611 499 ideal& TT = m_syzTails; 612 500 const ring& R = m_rBaseRing; 613 const SchreyerSyzygyComputationFlags& attributes = m_atttributes;501 // const SchreyerSyzygyComputationFlags& attributes = m_atttributes; 614 502 615 503 // const BOOLEAN __DEBUG__ = attributes.__DEBUG__; 616 504 // const BOOLEAN __SYZCHECK__ = attributes.__SYZCHECK__; 617 const BOOLEAN __LEAD2SYZ__ = attributes.__LEAD2SYZ__;618 const BOOLEAN __HYBRIDNF__ = attributes.__HYBRIDNF__;505 // const BOOLEAN __LEAD2SYZ__ = attributes.__LEAD2SYZ__; 506 // const BOOLEAN __HYBRIDNF__ = attributes.__HYBRIDNF__; 619 507 // const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__; 620 508 … … 692 580 void SchreyerSyzygyComputation::ComputeLeadingSyzygyTerms(bool bComputeSecondTerms) 693 581 { 694 const SchreyerSyzygyComputationFlags& attributes = m_atttributes;695 696 const BOOLEAN __LEAD2SYZ__ = attributes.__LEAD2SYZ__;697 const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__;582 // const SchreyerSyzygyComputationFlags& attributes = m_atttributes; 583 584 // const BOOLEAN __LEAD2SYZ__ = attributes.__LEAD2SYZ__; 585 // const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__; 698 586 699 587 if( bComputeSecondTerms ) … … 718 606 (void)( __LEAD2SYZ__ ); 719 607 } 608 609 poly SchreyerSyzygyComputation::SchreyerSyzygyNF(poly syz_lead, poly syz_2) const 610 { 611 // return FROM_NAMESPACE(INTERNAL, _SchreyerSyzygyNF(syz_lead, syz_2, m_idLeads, m_idTails, m_LS, m_rBaseRing, m_atttributes)); 612 // poly _SchreyerSyzygyNF(poly syz_lead, poly syz_2, 613 // ideal L, ideal T, ideal LS, 614 // const ring r, 615 // const SchreyerSyzygyComputationFlags attributes) 616 // { 617 618 const ideal& L = m_idLeads; 619 const ideal& T = m_idTails; 620 // const ideal& LS = m_LS; 621 const ring& r = m_rBaseRing; 622 623 // const SchreyerSyzygyComputationFlags& attributes = m_atttributes; 624 // const BOOLEAN __DEBUG__ = attributes.__DEBUG__; 625 // const BOOLEAN __SYZCHECK__ = attributes.__SYZCHECK__; 626 // const BOOLEAN __LEAD2SYZ__ = attributes.__LEAD2SYZ__; 627 // const BOOLEAN __HYBRIDNF__ = attributes.__HYBRIDNF__; 628 // const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__; 629 630 assume( syz_lead != NULL ); 631 assume( syz_2 != NULL ); 632 633 assume( L != NULL ); 634 assume( T != NULL ); 635 636 assume( IDELEMS(L) == IDELEMS(T) ); 637 638 int c = p_GetComp(syz_lead, r) - 1; 639 640 assume( c >= 0 && c < IDELEMS(T) ); 641 642 poly p = leadmonom(syz_lead, r); // :( 643 poly spoly = pp_Mult_qq(p, T->m[c], r); 644 p_Delete(&p, r); 645 646 647 c = p_GetComp(syz_2, r) - 1; 648 assume( c >= 0 && c < IDELEMS(T) ); 649 650 p = leadmonom(syz_2, r); // :( 651 spoly = p_Add_q(spoly, pp_Mult_qq(p, T->m[c], r), r); 652 p_Delete(&p, r); 653 654 poly tail = p_Copy(syz_2, r); // TODO: use bucket!? 655 656 while (spoly != NULL) 657 { 658 poly t = m_div.FindReducer(spoly, NULL); 659 660 p_LmDelete(&spoly, r); 661 662 if( t != NULL ) 663 { 664 p = leadmonom(t, r); // :( 665 c = p_GetComp(t, r) - 1; 666 667 assume( c >= 0 && c < IDELEMS(T) ); 668 669 spoly = p_Add_q(spoly, pp_Mult_qq(p, T->m[c], r), r); 670 671 p_Delete(&p, r); 672 673 tail = p_Add_q(tail, t, r); 674 } 675 } 676 677 return tail; 678 } 679 680 681 poly SchreyerSyzygyComputation::TraverseTail(poly multiplier, poly tail) const 682 { 683 const ideal& L = m_idLeads; 684 const ideal& T = m_idTails; 685 // const ideal& LS = m_LS; 686 const ring& r = m_rBaseRing; 687 // const SchreyerSyzygyComputationFlags& attributes = m_atttributes; 688 689 // return FROM_NAMESPACE(INTERNAL, _TraverseTail(multiplier, tail, m_idLeads, m_idTails, m_LS, m_rBaseRing, m_atttributes)); 690 // poly _TraverseTail(poly multiplier, poly tail, 691 // ideal L, ideal T, ideal LS, 692 // const ring r, 693 // const SchreyerSyzygyComputationFlags attributes) 694 // { 695 696 697 // const BOOLEAN __DEBUG__ = attributes.__DEBUG__; 698 // const BOOLEAN __SYZCHECK__ = attributes.__SYZCHECK__; 699 // const BOOLEAN __LEAD2SYZ__ = attributes.__LEAD2SYZ__; 700 // const BOOLEAN __HYBRIDNF__ = attributes.__HYBRIDNF__; 701 // const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__; 702 703 assume( multiplier != NULL ); 704 705 assume( L != NULL ); 706 assume( T != NULL ); 707 708 poly s = NULL; 709 710 if( (!__TAILREDSYZ__) || m_lcm.Check(multiplier) ) 711 for(poly p = tail; p != NULL; p = pNext(p)) // iterate over the tail 712 s = p_Add_q(s, ReduceTerm(multiplier, p, NULL), r); 713 714 return s; 715 } 716 717 718 719 720 poly SchreyerSyzygyComputation::ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck) const 721 { 722 const ideal& L = m_idLeads; 723 const ideal& T = m_idTails; 724 // const ideal& LS = m_LS; 725 const ring& r = m_rBaseRing; 726 // const SchreyerSyzygyComputationFlags& attributes = m_atttributes; 727 728 // return FROM_NAMESPACE(INTERNAL, _ReduceTerm(multiplier, term4reduction, syztermCheck, m_idLeads, m_idTails, m_LS, m_rBaseRing, m_atttributes)); 729 // poly _ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck, 730 // ideal L, ideal T, ideal LS, 731 // const ring r, 732 // const SchreyerSyzygyComputationFlags attributes) 733 734 735 736 // const BOOLEAN __DEBUG__ = attributes.__DEBUG__; 737 // const BOOLEAN __SYZCHECK__ = attributes.__SYZCHECK__; 738 // const BOOLEAN __LEAD2SYZ__ = attributes.__LEAD2SYZ__; 739 // const BOOLEAN __HYBRIDNF__ = attributes.__HYBRIDNF__; 740 // const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__; 741 742 assume( multiplier != NULL ); 743 assume( term4reduction != NULL ); 744 745 746 assume( L != NULL ); 747 assume( T != NULL ); 748 749 // assume(r == currRing); // ? 750 751 // simple implementation with FindReducer: 752 poly s = NULL; 753 754 if( (!__TAILREDSYZ__) || m_lcm.Check(multiplier) ) 755 { 756 // NOTE: only LT(term4reduction) should be used in the following: 757 poly product = pp_Mult_mm(multiplier, term4reduction, r); 758 s = m_div.FindReducer(product, syztermCheck); 759 p_Delete(&product, r); 760 } 761 762 if( s == NULL ) // No Reducer? 763 return s; 764 765 poly b = leadmonom(s, r); 766 767 const int c = p_GetComp(s, r) - 1; 768 assume( c >= 0 && c < IDELEMS(T) ); 769 770 const poly tail = T->m[c]; 771 772 if( tail != NULL ) 773 s = p_Add_q(s, TraverseTail(b, tail), r); 774 775 return s; 776 } 777 778 779 780 781 782 BEGIN_NAMESPACE_NONAME 783 784 static inline int atGetInt(idhdl rootRingHdl, const char* attribute, long def) 785 { 786 return ((int)(long)(atGet(rootRingHdl, attribute, INT_CMD, (void*)def))); 787 } 788 789 END_NAMESPACE 790 791 SchreyerSyzygyComputationFlags::SchreyerSyzygyComputationFlags(idhdl rootRingHdl): 792 #ifndef NDEBUG 793 __DEBUG__( (BOOLEAN)atGetInt(rootRingHdl,"DEBUG", TRUE) ), 794 #else 795 __DEBUG__( (BOOLEAN)atGetInt(rootRingHdl,"DEBUG", FALSE) ), 796 #endif 797 // __SYZCHECK__( (BOOLEAN)atGetInt(rootRingHdl, "SYZCHECK", __DEBUG__) ), 798 __LEAD2SYZ__( (BOOLEAN)atGetInt(rootRingHdl, "LEAD2SYZ", 1) ), 799 __TAILREDSYZ__( (BOOLEAN)atGetInt(rootRingHdl, "TAILREDSYZ", 1) ), 800 __HYBRIDNF__( (BOOLEAN)atGetInt(rootRingHdl, "HYBRIDNF", 0) ), 801 m_rBaseRing( rootRingHdl->data.uring ) 802 { 803 if( __DEBUG__ ) 804 { 805 PrintS("SchreyerSyzygyComputationFlags: \n"); 806 Print(" DEBUG : \t%d\n", __DEBUG__); 807 // Print(" SYZCHECK : \t%d\n", __SYZCHECK__); 808 Print(" LEAD2SYZ : \t%d\n", __LEAD2SYZ__); 809 Print(" TAILREDSYZ: \t%d\n", __TAILREDSYZ__); 810 } 811 812 // TODO: just current setting! 813 assume( rootRingHdl == currRingHdl ); 814 assume( rootRingHdl->typ == RING_CMD ); 815 assume( m_rBaseRing == currRing ); 816 // move the global ring here inside??? 817 } 818 819 820 821 CReducerFinder::CLeadingTerm::CLeadingTerm(unsigned int _label, const poly _lt, const ring R): 822 m_sev( p_GetShortExpVector(_lt, R) ), m_label( _label ), m_lt( _lt ) 823 { } 824 825 826 CReducerFinder::~CReducerFinder() 827 { 828 for( CReducersHash::const_iterator it = m_hash.begin(); it != m_hash.end(); it++ ) 829 { 830 const TReducers& v = it->second; 831 for(TReducers::const_iterator vit = v.begin(); vit != v.end(); vit++ ) 832 delete const_cast<CLeadingTerm*>(*vit); 833 } 834 } 835 836 CReducerFinder::CReducerFinder(const SchreyerSyzygyComputation& data): 837 SchreyerSyzygyComputationFlags(data), 838 m_data(data), 839 m_hash() 840 { 841 const ring& R = m_rBaseRing; 842 assume( data.m_rBaseRing == R ); 843 assume( R != NULL ); 844 // const SchreyerSyzygyComputationFlags& attributes = data.m_atttributes; 845 // 846 // const BOOLEAN __DEBUG__ = attributes.__DEBUG__; 847 // const BOOLEAN __SYZCHECK__ = attributes.__SYZCHECK__; 848 // const BOOLEAN __HYBRIDNF__ = attributes.__HYBRIDNF__; 849 // const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__; 850 851 852 const ideal& L = data.m_idLeads; assume( L != NULL ); 853 854 for( int k = IDELEMS(L) - 1; k >= 0; k-- ) 855 { 856 const poly a = L->m[k]; assume( a != NULL ); 857 858 // NOTE: label is k \in 0 ... |L|-1!!! 859 m_hash[p_GetComp(a, R)].push_back( new CLeadingTerm(k, a, R) ); 860 } 861 } 862 720 863 721 864 poly CReducerFinder::FindReducer(const poly product, const poly syzterm) const … … 729 872 const ideal& L = m_data.m_idLeads; 730 873 const ideal& LS = m_data.m_LS; 731 const ring& r = m_ data.m_rBaseRing;732 const SchreyerSyzygyComputationFlags& attributes = m_data.m_atttributes;733 734 735 const BOOLEAN __DEBUG__ = attributes.__DEBUG__;736 const BOOLEAN __SYZCHECK__ = attributes.__SYZCHECK__;874 const ring& r = m_rBaseRing; 875 // const SchreyerSyzygyComputationFlags& attributes = m_data.m_atttributes; 876 877 878 // const BOOLEAN __DEBUG__ = m_data.__DEBUG__; 879 // const BOOLEAN __SYZCHECK__ = m_data.__SYZCHECK__; 737 880 // const BOOLEAN __LEAD2SYZ__ = attributes.__LEAD2SYZ__; 738 881 // const BOOLEAN __HYBRIDNF__ = attributes.__HYBRIDNF__; 739 const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__;882 // const BOOLEAN __TAILREDSYZ__ = m_data.__TAILREDSYZ__; 740 883 741 884 assume( product != NULL ); … … 748 891 749 892 assume( c >= 0 && c < IDELEMS(L) ); 750 893 751 894 if (__DEBUG__ && (syzterm != NULL)) 752 895 { … … 772 915 #if 1 773 916 CReducersHash::const_iterator it = m_hash.find(p_GetComp(product, r)); // same module component 774 917 775 918 if( it == m_hash.end() ) 776 919 return NULL; 777 920 778 921 const TReducers& reducers = it->second; 779 922 780 923 for(TReducers::const_iterator vit = reducers.begin(); vit != reducers.end(); vit++ ) 781 924 { 782 783 784 785 786 787 788 789 790 791 792 925 const poly p = (*vit)->m_lt; 926 927 assume( p_GetComp(p, r) == comp ); 928 929 const int k = (*vit)->m_label; 930 931 assume( L->m[k] == p ); 932 933 const unsigned long p_sev = (*vit)->m_sev; 934 935 assume( p_sev == p_GetShortExpVector(p, r) ); 793 936 #else 794 795 796 797 798 799 800 801 937 for( int k = IDELEMS(L)-1; k>= 0; k-- ) 938 { 939 const poly p = L->m[k]; 940 941 if ( p_GetComp(p, r) != comp ) 942 continue; 943 944 const unsigned long p_sev = p_GetShortExpVector(p, r); // to be stored in m_hash!!! 802 945 #endif 803 804 805 946 947 if( !p_LmShortDivisibleByNoComp(p, p_sev, product, not_sev, r) ) 948 continue; 806 949 807 950 // // ... which divides the product, looking for the _1st_ appropriate one! … … 872 1015 873 1016 874 poly SchreyerSyzygyComputation::SchreyerSyzygyNF(poly syz_lead, poly syz_2) const 875 { 876 // return FROM_NAMESPACE(INTERNAL, _SchreyerSyzygyNF(syz_lead, syz_2, m_idLeads, m_idTails, m_LS, m_rBaseRing, m_atttributes)); 877 // poly _SchreyerSyzygyNF(poly syz_lead, poly syz_2, 878 // ideal L, ideal T, ideal LS, 879 // const ring r, 880 // const SchreyerSyzygyComputationFlags attributes) 881 // { 882 883 const ideal& L = m_idLeads; 884 const ideal& T = m_idTails; 885 // const ideal& LS = m_LS; 886 const ring& r = m_rBaseRing; 887 888 // const SchreyerSyzygyComputationFlags& attributes = m_atttributes; 889 // const BOOLEAN __DEBUG__ = attributes.__DEBUG__; 890 // const BOOLEAN __SYZCHECK__ = attributes.__SYZCHECK__; 891 // const BOOLEAN __LEAD2SYZ__ = attributes.__LEAD2SYZ__; 892 // const BOOLEAN __HYBRIDNF__ = attributes.__HYBRIDNF__; 893 // const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__; 894 895 assume( syz_lead != NULL ); 896 assume( syz_2 != NULL ); 897 898 assume( L != NULL ); 899 assume( T != NULL ); 900 901 assume( IDELEMS(L) == IDELEMS(T) ); 902 903 int c = p_GetComp(syz_lead, r) - 1; 904 905 assume( c >= 0 && c < IDELEMS(T) ); 906 907 poly p = leadmonom(syz_lead, r); // :( 908 poly spoly = pp_Mult_qq(p, T->m[c], r); 909 p_Delete(&p, r); 910 911 912 c = p_GetComp(syz_2, r) - 1; 913 assume( c >= 0 && c < IDELEMS(T) ); 914 915 p = leadmonom(syz_2, r); // :( 916 spoly = p_Add_q(spoly, pp_Mult_qq(p, T->m[c], r), r); 917 p_Delete(&p, r); 918 919 poly tail = p_Copy(syz_2, r); // TODO: use bucket!? 920 921 while (spoly != NULL) 922 { 923 poly t = m_div.FindReducer(spoly, NULL); 924 925 p_LmDelete(&spoly, r); 926 927 if( t != NULL ) 1017 1018 CLCM::CLCM(const SchreyerSyzygyComputation& data): 1019 SchreyerSyzygyComputationFlags(data), std::vector<bool>(), m_data(data), m_compute(false) 1020 { 1021 1022 const ring& R = m_rBaseRing; 1023 assume( data.m_rBaseRing == R ); 1024 assume( R != NULL ); 1025 // const SchreyerSyzygyComputationFlags& attributes = data.m_atttributes; 1026 1027 // const BOOLEAN __DEBUG__ = attributes.__DEBUG__; 1028 // const BOOLEAN __SYZCHECK__ = attributes.__SYZCHECK__; 1029 // const BOOLEAN __HYBRIDNF__ = m_data.__HYBRIDNF__; 1030 // const BOOLEAN __TAILREDSYZ__ = m_data.__TAILREDSYZ__; 1031 1032 1033 const ideal& L = data.m_idLeads; 1034 assume( L != NULL ); 1035 1036 if( __TAILREDSYZ__ && !__HYBRIDNF__ ) 928 1037 { 929 p = leadmonom(t, r); // :( 930 c = p_GetComp(t, r) - 1; 931 932 assume( c >= 0 && c < IDELEMS(T) ); 933 934 spoly = p_Add_q(spoly, pp_Mult_qq(p, T->m[c], r), r); 935 936 p_Delete(&p, r); 937 938 tail = p_Add_q(tail, t, r); 939 } 940 } 941 942 return tail; 943 } 944 945 946 poly SchreyerSyzygyComputation::TraverseTail(poly multiplier, poly tail) const 947 { 948 const ideal& L = m_idLeads; 949 const ideal& T = m_idTails; 950 // const ideal& LS = m_LS; 951 const ring& r = m_rBaseRing; 952 const SchreyerSyzygyComputationFlags& attributes = m_atttributes; 953 954 // return FROM_NAMESPACE(INTERNAL, _TraverseTail(multiplier, tail, m_idLeads, m_idTails, m_LS, m_rBaseRing, m_atttributes)); 955 // poly _TraverseTail(poly multiplier, poly tail, 956 // ideal L, ideal T, ideal LS, 957 // const ring r, 958 // const SchreyerSyzygyComputationFlags attributes) 959 // { 960 961 962 // const BOOLEAN __DEBUG__ = attributes.__DEBUG__; 963 // const BOOLEAN __SYZCHECK__ = attributes.__SYZCHECK__; 964 // const BOOLEAN __LEAD2SYZ__ = attributes.__LEAD2SYZ__; 965 // const BOOLEAN __HYBRIDNF__ = attributes.__HYBRIDNF__; 966 const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__; 967 968 assume( multiplier != NULL ); 969 970 assume( L != NULL ); 971 assume( T != NULL ); 972 973 poly s = NULL; 974 975 if( (!__TAILREDSYZ__) || m_lcm.Check(multiplier) ) 976 for(poly p = tail; p != NULL; p = pNext(p)) // iterate over the tail 977 s = p_Add_q(s, ReduceTerm(multiplier, p, NULL), r); 978 979 return s; 980 } 981 982 983 984 985 poly SchreyerSyzygyComputation::ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck) const 986 { 987 const ideal& L = m_idLeads; 988 const ideal& T = m_idTails; 989 // const ideal& LS = m_LS; 990 const ring& r = m_rBaseRing; 991 const SchreyerSyzygyComputationFlags& attributes = m_atttributes; 992 993 // return FROM_NAMESPACE(INTERNAL, _ReduceTerm(multiplier, term4reduction, syztermCheck, m_idLeads, m_idTails, m_LS, m_rBaseRing, m_atttributes)); 994 // poly _ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck, 995 // ideal L, ideal T, ideal LS, 996 // const ring r, 997 // const SchreyerSyzygyComputationFlags attributes) 998 999 1000 1001 // const BOOLEAN __DEBUG__ = attributes.__DEBUG__; 1002 // const BOOLEAN __SYZCHECK__ = attributes.__SYZCHECK__; 1003 // const BOOLEAN __LEAD2SYZ__ = attributes.__LEAD2SYZ__; 1004 // const BOOLEAN __HYBRIDNF__ = attributes.__HYBRIDNF__; 1005 const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__; 1006 1007 assume( multiplier != NULL ); 1008 assume( term4reduction != NULL ); 1009 1010 1011 assume( L != NULL ); 1012 assume( T != NULL ); 1013 1014 // assume(r == currRing); // ? 1015 1016 // simple implementation with FindReducer: 1017 poly s = NULL; 1018 1019 if( (!__TAILREDSYZ__) || m_lcm.Check(multiplier) ) 1020 { 1021 // NOTE: only LT(term4reduction) should be used in the following: 1022 poly product = pp_Mult_mm(multiplier, term4reduction, r); 1023 s = m_div.FindReducer(product, syztermCheck); 1024 p_Delete(&product, r); 1025 } 1026 1027 if( s == NULL ) // No Reducer? 1028 return s; 1029 1030 poly b = leadmonom(s, r); 1031 1032 const int c = p_GetComp(s, r) - 1; 1033 assume( c >= 0 && c < IDELEMS(T) ); 1034 1035 const poly tail = T->m[c]; 1036 1037 if( tail != NULL ) 1038 s = p_Add_q(s, TraverseTail(b, tail), r); 1039 1040 return s; 1041 } 1042 1043 1044 1045 1046 1047 BEGIN_NAMESPACE_NONAME 1048 1049 static inline int atGetInt(idhdl rootRingHdl, const char* attribute, long def) 1050 { 1051 return ((int)(long)(atGet(rootRingHdl, attribute, INT_CMD, (void*)def))); 1052 } 1053 1054 END_NAMESPACE 1055 1056 SchreyerSyzygyComputationFlags::SchreyerSyzygyComputationFlags(idhdl rootRingHdl): 1057 #ifndef NDEBUG 1058 __DEBUG__( (BOOLEAN)atGetInt(rootRingHdl,"DEBUG", TRUE) ), 1059 #else 1060 __DEBUG__( (BOOLEAN)atGetInt(rootRingHdl,"DEBUG", FALSE) ), 1061 #endif 1062 __SYZCHECK__( (BOOLEAN)atGetInt(rootRingHdl, "SYZCHECK", __DEBUG__) ), 1063 __LEAD2SYZ__( (BOOLEAN)atGetInt(rootRingHdl, "LEAD2SYZ", 1) ), 1064 __TAILREDSYZ__( (BOOLEAN)atGetInt(rootRingHdl, "TAILREDSYZ", 1) ), 1065 __HYBRIDNF__( (BOOLEAN)atGetInt(rootRingHdl, "HYBRIDNF", 0) ) 1066 { 1067 if( __DEBUG__ ) 1068 { 1069 PrintS("SchreyerSyzygyComputationFlags: \n"); 1070 Print(" DEBUG : \t%d\n", __DEBUG__); 1071 Print(" SYZCHECK : \t%d\n", __SYZCHECK__); 1072 Print(" LEAD2SYZ : \t%d\n", __LEAD2SYZ__); 1073 Print(" TAILREDSYZ: \t%d\n", __TAILREDSYZ__); 1074 } 1075 1076 // TODO: just current setting! 1077 assume( rootRingHdl == currRingHdl ); 1078 assume( rootRingHdl->typ == RING_CMD ); 1079 assume( rootRingHdl->data.uring == currRing ); 1080 // move the global ring here inside??? 1081 } 1082 1083 1038 const int l = IDELEMS(L); 1039 1040 resize(l, false); 1041 1042 const unsigned int N = rVar(R); 1043 1044 for( int k = l - 1; k >= 0; k-- ) 1045 { 1046 const poly a = L->m[k]; assume( a != NULL ); 1047 1048 for (unsigned int j = N; j > 0; j--) 1049 if ( !(*this)[j] ) 1050 (*this)[j] = (p_GetExp(a, j, R) > 0); 1051 } 1052 1053 m_compute = true; 1054 } 1055 } 1056 1057 1058 bool CLCM::Check(const poly m) const 1059 { 1060 assume( m != NULL ); 1061 if( m_compute && (m != NULL)) 1062 { 1063 const ring& R = m_data.m_rBaseRing; 1064 // const SchreyerSyzygyComputationFlags& attributes = m_data.m_atttributes; 1065 1066 // const BOOLEAN __DEBUG__ = attributes.__DEBUG__; 1067 // const BOOLEAN __SYZCHECK__ = attributes.__SYZCHECK__; 1068 // const BOOLEAN __HYBRIDNF__ = m_data.__HYBRIDNF__; 1069 // const BOOLEAN __TAILREDSYZ__ = m_data.__TAILREDSYZ__; 1070 1071 assume( R != NULL ); 1072 assume( R == currRing ); 1073 1074 assume( __TAILREDSYZ__ && !__HYBRIDNF__ ); 1075 1076 const unsigned int N = rVar(R); 1077 1078 for (unsigned int j = N; j > 0; j--) 1079 if ( (*this)[j] ) 1080 if(p_GetExp(m, j, R) > 0) 1081 return true; 1082 1083 return false; 1084 1085 } else return true; 1086 } 1087 1088 1084 1089 1085 1090 -
dyn_modules/syzextra/syzextra.h
rdd24e5 r495328 63 63 { 64 64 SchreyerSyzygyComputationFlags(idhdl rootRingHdl); 65 65 SchreyerSyzygyComputationFlags(const SchreyerSyzygyComputationFlags& attr): 66 __DEBUG__(attr.__DEBUG__), 67 // __SYZCHECK__(attr.__SYZCHECK__), 68 __LEAD2SYZ__(attr.__LEAD2SYZ__), __TAILREDSYZ__(attr.__TAILREDSYZ__), 69 __HYBRIDNF__(attr.__HYBRIDNF__), m_rBaseRing(attr.m_rBaseRing) 70 {} 71 72 66 73 /// output all the intermediate states 67 74 const bool __DEBUG__; // DebugOutput; 68 75 69 /// ? 70 const bool __SYZCHECK__; // CheckSyzygyProperty; 76 // const bool __SYZCHECK__; // CheckSyzygyProperty: never tested here... 71 77 72 78 /// ? … … 79 85 const bool __HYBRIDNF__; // UseHybridNF 80 86 87 /// global base ring 88 const ring m_rBaseRing; 89 81 90 }; 82 91 83 92 class SchreyerSyzygyComputation; 84 93 85 class CLCM: public std::vector<bool>94 class CLCM: public SchreyerSyzygyComputationFlags, public std::vector<bool> 86 95 { 87 96 public: … … 97 106 98 107 99 class CReducerFinder 108 class CReducerFinder: public SchreyerSyzygyComputationFlags 100 109 { 101 110 private: … … 148 157 * @sa Schreyer Syzygy Computation Paper & Talk & Python prototype 149 158 */ 150 class SchreyerSyzygyComputation 159 class SchreyerSyzygyComputation: public SchreyerSyzygyComputationFlags 151 160 { 152 161 friend class CLCM; … … 156 165 157 166 /// Construct a global object for given input data (separated into leads & tails) 158 SchreyerSyzygyComputation(const ideal idLeads, const ideal idTails, const ring rBaseRing, const SchreyerSyzygyComputationFlags attribues):159 m_rBaseRing(rBaseRing),167 SchreyerSyzygyComputation(const ideal idLeads, const ideal idTails, const SchreyerSyzygyComputationFlags setting): 168 SchreyerSyzygyComputationFlags(setting), 160 169 m_idLeads(idLeads), m_idTails(idTails), 161 m_syzLeads(NULL), m_syzTails(NULL), m_LS(NULL), m_atttributes(attribues),170 m_syzLeads(NULL), m_syzTails(NULL), m_LS(NULL), 162 171 m_lcm(*this), m_div(*this) 163 172 { … … 166 175 167 176 /// Construct a global object for given input data (separated into leads & tails) 168 SchreyerSyzygyComputation(const ideal idLeads, const ideal idTails, const ideal syzLeads, const ring rBaseRing, const SchreyerSyzygyComputationFlags attribues):169 m_rBaseRing(rBaseRing),177 SchreyerSyzygyComputation(const ideal idLeads, const ideal idTails, const ideal syzLeads, const SchreyerSyzygyComputationFlags setting): 178 SchreyerSyzygyComputationFlags(setting), 170 179 m_idLeads(idLeads), m_idTails(idTails), 171 m_syzLeads(NULL), m_syzTails(NULL), m_LS(syzLeads), m_atttributes(attribues),180 m_syzLeads(NULL), m_syzTails(NULL), m_LS(syzLeads), 172 181 m_lcm(*this), m_div(*this) 173 182 { … … 219 228 220 229 private: 221 /// global base ring222 const ring m_rBaseRing;223 224 230 /// input leading terms 225 231 const ideal m_idLeads; … … 235 241 236 242 /*mutable?*/ ideal m_LS; ///< leading syzygy terms used for reducing syzygy tails 237 238 const SchreyerSyzygyComputationFlags m_atttributes;239 243 240 244 /// Bitmask for variables occuring in leading terms … … 248 252 // The following wrappers are just for testing separate functions on highest level (within schreyer.lib) 249 253 250 static inline void ComputeSyzygy(const ideal L, const ideal T, ideal& LL, ideal& TT, const ring R, constSchreyerSyzygyComputationFlags A)251 { 252 SchreyerSyzygyComputation syz(L, T, R,A);254 static inline void ComputeSyzygy(const ideal L, const ideal T, ideal& LL, ideal& TT, const SchreyerSyzygyComputationFlags A) 255 { 256 SchreyerSyzygyComputation syz(L, T, A); 253 257 syz.ComputeSyzygy(); 254 258 syz.ReadOffResult(LL, TT); 255 259 } 256 260 257 static inline ideal ComputeLeadingSyzygyTerms(const ideal& L, const ring R, constSchreyerSyzygyComputationFlags A)258 { 259 SchreyerSyzygyComputation syz(L, NULL, R,A);261 static inline ideal ComputeLeadingSyzygyTerms(const ideal& L, const SchreyerSyzygyComputationFlags A) 262 { 263 SchreyerSyzygyComputation syz(L, NULL, A); 260 264 syz.ComputeLeadingSyzygyTerms(false); 261 265 ideal LL, TT; … … 264 268 } 265 269 266 static inline ideal Compute2LeadingSyzygyTerms(const ideal& L, const ring R, constSchreyerSyzygyComputationFlags A)267 { 268 SchreyerSyzygyComputation syz(L, NULL, R,A);270 static inline ideal Compute2LeadingSyzygyTerms(const ideal& L, const SchreyerSyzygyComputationFlags A) 271 { 272 SchreyerSyzygyComputation syz(L, NULL, A); 269 273 syz.ComputeLeadingSyzygyTerms(true); 270 274 ideal LL, TT; … … 274 278 275 279 static inline poly FindReducer(poly product, poly syzterm, 276 ideal L, ideal LS, const ring R, constSchreyerSyzygyComputationFlags A)277 { 278 SchreyerSyzygyComputation syz(L, NULL, LS, R,A);280 ideal L, ideal LS, const SchreyerSyzygyComputationFlags A) 281 { 282 SchreyerSyzygyComputation syz(L, NULL, LS, A); 279 283 return syz._FindReducer(product, syzterm); 280 284 } 281 285 282 286 static inline poly TraverseTail(poly multiplier, poly tail, 283 ideal L, ideal T, ideal LS, const ring R, constSchreyerSyzygyComputationFlags A)284 { 285 SchreyerSyzygyComputation syz(L, T, LS, R,A);287 ideal L, ideal T, ideal LS, const SchreyerSyzygyComputationFlags A) 288 { 289 SchreyerSyzygyComputation syz(L, T, LS, A); 286 290 return syz.TraverseTail(multiplier, tail); 287 291 } 288 292 289 293 static inline poly ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck, 290 ideal L, ideal T, ideal LS, const ring R, constSchreyerSyzygyComputationFlags A)291 { 292 SchreyerSyzygyComputation syz(L, T, LS, R,A);294 ideal L, ideal T, ideal LS, const SchreyerSyzygyComputationFlags A) 295 { 296 SchreyerSyzygyComputation syz(L, T, LS, A); 293 297 return syz.ReduceTerm(multiplier, term4reduction, syztermCheck); 294 298 } … … 296 300 297 301 static inline poly SchreyerSyzygyNF(poly syz_lead, poly syz_2, 298 ideal L, ideal T, ideal LS, const ring R, constSchreyerSyzygyComputationFlags A)299 { 300 SchreyerSyzygyComputation syz(L, T, LS, R,A);302 ideal L, ideal T, ideal LS, const SchreyerSyzygyComputationFlags A) 303 { 304 SchreyerSyzygyComputation syz(L, T, LS, A); 301 305 return syz.SchreyerSyzygyNF(syz_lead, syz_2); 302 306 }
Note: See TracChangeset
for help on using the changeset viewer.