Changeset 5cecde in git for dyn_modules/syzextra/syzextra.cc
- Timestamp:
- Aug 2, 2012, 9:58:56 PM (11 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'c987db42cd2ec943b97ac5746c99892ceddf909c')
- Children:
- e98c64edd3cf15f4e5d15991052a7bbcbb1184a5
- Parents:
- 495328d14a955b215ad10b598e995ab522243881
- git-author:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-08-02 21:58:56+02:00
- git-committer:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2014-05-07 04:41:46+02:00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
dyn_modules/syzextra/syzextra.cc
r495328 r5cecde 511 511 assume( IDELEMS(L) == IDELEMS(T) ); 512 512 513 ComputeLeadingSyzygyTerms( __LEAD2SYZ__ ); // 2 terms OR 1 term! 513 if( m_syzLeads == NULL ) 514 ComputeLeadingSyzygyTerms( __LEAD2SYZ__ ); // 2 terms OR 1 term! 515 516 assume( m_syzLeads != NULL ); 517 518 if( __TAILREDSYZ__ ) 519 assume( m_checker.IsNonempty() ); 514 520 515 521 ideal& LL = m_syzLeads; 522 516 523 517 524 const int size = IDELEMS(LL); … … 564 571 if( a2 == NULL ) 565 572 { 566 aa = p_Mult_mm(aa, L->m[r], R); a2 = m_div.FindReducer(aa, a );573 aa = p_Mult_mm(aa, L->m[r], R); a2 = m_div.FindReducer(aa, a, m_checker); 567 574 } 568 575 assume( a2 != NULL ); … … 600 607 601 608 // NOTE: set m_LS if tails are to be reduced! 602 603 if (__TAILREDSYZ__) 609 assume( m_syzLeads!= NULL ); 610 611 if (__TAILREDSYZ__ && (IDELEMS(m_syzLeads) > 0)) 612 { 604 613 m_LS = m_syzLeads; 614 m_checker.Initialize(m_syzLeads); 615 } 605 616 606 617 (void)( __LEAD2SYZ__ ); … … 618 629 const ideal& L = m_idLeads; 619 630 const ideal& T = m_idTails; 620 // const ideal& LS = m_LS;621 631 const ring& r = m_rBaseRing; 622 632 … … 656 666 while (spoly != NULL) 657 667 { 658 poly t = m_div.FindReducer(spoly, NULL );668 poly t = m_div.FindReducer(spoly, NULL, m_checker); 659 669 660 670 p_LmDelete(&spoly, r); … … 756 766 // NOTE: only LT(term4reduction) should be used in the following: 757 767 poly product = pp_Mult_mm(multiplier, term4reduction, r); 758 s = m_div.FindReducer(product, syztermCheck );768 s = m_div.FindReducer(product, syztermCheck, m_checker); 759 769 p_Delete(&product, r); 760 770 } … … 834 844 } 835 845 836 CReducerFinder::CReducerFinder(const SchreyerSyzygyComputation& data): 837 SchreyerSyzygyComputationFlags(data), 838 m_data(data), 846 847 void CReducerFinder::Initialize(const ideal L) 848 { 849 assume( m_L == NULL || m_L == L ); 850 if( m_L == NULL ) 851 m_L = L; 852 853 assume( m_L == L ); 854 855 if( L != NULL ) 856 { 857 const ring& R = m_rBaseRing; 858 assume( R != NULL ); 859 860 for( int k = IDELEMS(L) - 1; k >= 0; k-- ) 861 { 862 const poly a = L->m[k]; // assume( a != NULL ); 863 864 // NOTE: label is k \in 0 ... |L|-1!!! 865 if( a != NULL ) 866 m_hash[p_GetComp(a, R)].push_back( new CLeadingTerm(k, a, R) ); 867 } 868 } 869 } 870 871 CReducerFinder::CReducerFinder(const ideal L, const SchreyerSyzygyComputationFlags& flags): 872 SchreyerSyzygyComputationFlags(flags), 873 m_L(const_cast<ideal>(L)), // for debug anyway 839 874 m_hash() 840 875 { 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 863 864 poly CReducerFinder::FindReducer(const poly product, const poly syzterm) const 865 { 866 // return FROM_NAMESPACE(INTERNAL, _FindReducer(product, syzterm, m_idLeads, m_LS, m_rBaseRing, m_atttributes)); 867 // poly _FindReducer(poly product, poly syzterm, 868 // ideal L, ideal LS, 869 // const ring r, 870 // const SchreyerSyzygyComputationFlags attributes) 871 872 const ideal& L = m_data.m_idLeads; 873 const ideal& LS = m_data.m_LS; 876 assume( flags.m_rBaseRing == m_rBaseRing ); 877 if( L != NULL ) 878 Initialize(L); 879 } 880 881 882 bool CReducerFinder::IsDivisible(const poly product) const 883 { 874 884 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__; 880 // const BOOLEAN __LEAD2SYZ__ = attributes.__LEAD2SYZ__; 881 // const BOOLEAN __HYBRIDNF__ = attributes.__HYBRIDNF__; 882 // const BOOLEAN __TAILREDSYZ__ = m_data.__TAILREDSYZ__; 885 886 const long comp = p_GetComp(product, r); 887 const unsigned long not_sev = ~p_GetShortExpVector(product, r); 888 889 assume( comp >= 0 ); 890 891 CReducersHash::const_iterator it = m_hash.find(comp); // same module component 892 893 if( it == m_hash.end() ) 894 return false; 895 896 assume( m_L != NULL ); 897 898 const TReducers& reducers = it->second; 899 900 for(TReducers::const_iterator vit = reducers.begin(); vit != reducers.end(); vit++ ) 901 { 902 const poly p = (*vit)->m_lt; 903 904 assume( p_GetComp(p, r) == comp ); 905 906 const int k = (*vit)->m_label; 907 908 assume( m_L->m[k] == p ); 909 910 const unsigned long p_sev = (*vit)->m_sev; 911 912 assume( p_sev == p_GetShortExpVector(p, r) ); 913 914 if( !p_LmShortDivisibleByNoComp(p, p_sev, product, not_sev, r) ) 915 continue; 916 917 if( __DEBUG__ ) 918 { 919 Print("_FindReducer::Test LS: q is divisible by LS[%d] !:((, diviser is: ", k+1); 920 dPrint(p, r, r, 1); 921 } 922 923 return true; 924 } 925 926 return false; 927 } 928 929 930 poly CReducerFinder::FindReducer(const poly product, const poly syzterm, const CReducerFinder& syz_checker) const 931 { 932 const ring& r = m_rBaseRing; 883 933 884 934 assume( product != NULL ); 885 assume( L != NULL ); 935 936 const ideal& L = m_L; assume( L != NULL ); // for debug/testing only! 886 937 887 938 long c = 0; … … 912 963 assume( comp >= 0 ); 913 964 965 // for( int k = IDELEMS(L)-1; k>= 0; k-- ) 966 // { 967 // const poly p = L->m[k]; 968 // 969 // if ( p_GetComp(p, r) != comp ) 970 // continue; 971 // 972 // const unsigned long p_sev = p_GetShortExpVector(p, r); // to be stored in m_hash!!! 973 914 974 // looking for an appropriate diviser p = L[k]... 915 #if 1 916 CReducersHash::const_iterator it = m_hash.find(p_GetComp(product, r)); // same module component 975 CReducersHash::const_iterator it = m_hash.find(comp); // same module component 917 976 918 977 if( it == m_hash.end() ) 919 978 return NULL; 920 979 921 const TReducers& reducers = it->second; 922 980 assume( m_L != NULL ); 981 982 const TReducers& reducers = it->second; 983 984 const BOOLEAN to_check = __TAILREDSYZ__ && (syz_checker.IsNonempty()); 985 986 const poly q = p_New(r); pNext(q) = NULL; 987 988 if( __DEBUG__ ) 989 p_SetCoeff0(q, 0, r); // for printing q 990 923 991 for(TReducers::const_iterator vit = reducers.begin(); vit != reducers.end(); vit++ ) 924 992 { … … 934 1002 935 1003 assume( p_sev == p_GetShortExpVector(p, r) ); 936 #else937 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!!!945 #endif946 1004 947 1005 if( !p_LmShortDivisibleByNoComp(p, p_sev, product, not_sev, r) ) … … 952 1010 // continue; 953 1011 954 955 const poly q = p_New(r);956 pNext(q) = NULL;957 1012 p_ExpVectorDiff(q, product, p, r); // (LM(product) / LM(L[k])) 958 1013 p_SetComp(q, k + 1, r); … … 969 1024 } 970 1025 971 p_LmFree(q, r);972 1026 continue; 973 1027 } 974 1028 975 1029 // while the complement (the fraction) is not reducible by leading syzygies 976 if( LS != NULL )1030 if( to_check && syz_checker.IsDivisible(q) ) 977 1031 { 978 assume( __TAILREDSYZ__ ); 979 BOOLEAN ok = TRUE; 980 981 // TODO: FindReducer in LS !!! there should be no divisors! 982 for(int kk = IDELEMS(LS)-1; kk>= 0; kk-- ) 1032 if( __DEBUG__ ) 983 1033 { 984 const poly pp = LS->m[kk]; 985 986 if( p_LmDivisibleBy(pp, q, r) ) 987 { 988 989 if( __DEBUG__ ) 990 { 991 Print("_FindReducer::Test LS: q is divisible by LS[%d] !:((, diviser is: ", kk+1); 992 dPrint(pp, r, r, 1); 993 } 994 995 ok = FALSE; // q in <LS> :(( 996 break; 997 } 1034 PrintS("_FindReducer::Test LS: q is divisible by LS[?] !:((: "); 998 1035 } 999 1000 if(!ok) 1001 { 1002 p_LmFree(q, r); 1003 continue; 1004 } 1036 1037 continue; 1005 1038 } 1006 1039 1007 1040 p_SetCoeff0(q, n_Neg( n_Div( p_GetCoeff(product, r), p_GetCoeff(p, r), r), r), r); 1008 1041 return q; 1009 1010 } 1011 1042 } 1043 1044 p_LmFree(q, r); 1012 1045 1013 1046 return NULL; … … 1016 1049 1017 1050 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 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__)1051 CLCM::CLCM(const ideal& L, const SchreyerSyzygyComputationFlags& flags): 1052 SchreyerSyzygyComputationFlags(flags), std::vector<bool>(), 1053 m_compute(false), m_N(rVar(flags.m_rBaseRing)) 1054 { 1055 const ring& R = m_rBaseRing; 1056 assume( flags.m_rBaseRing == R ); 1057 assume( R != NULL ); 1058 1059 assume( L != NULL ); 1060 1061 if( __TAILREDSYZ__ && !__HYBRIDNF__ && (L != NULL)) 1062 { 1063 const int l = IDELEMS(L); 1064 1065 assume( l > 0 ); 1066 1067 resize(l, false); 1068 1069 for( int k = l - 1; k >= 0; k-- ) 1037 1070 { 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; 1071 const poly a = L->m[k]; assume( a != NULL ); 1072 1073 for (unsigned int j = m_N; j > 0; j--) 1074 if ( !(*this)[j] ) 1075 (*this)[j] = (p_GetExp(a, j, R) > 0); 1054 1076 } 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 } 1077 1078 m_compute = true; 1079 } 1080 } 1081 1082 1083 bool CLCM::Check(const poly m) const 1084 { 1085 assume( m != NULL ); 1086 if( m_compute && (m != NULL)) 1087 { 1088 const ring& R = m_rBaseRing; 1089 1090 assume( __TAILREDSYZ__ && !__HYBRIDNF__ ); 1091 1092 for (unsigned int j = m_N; j > 0; j--) 1093 if ( (*this)[j] ) 1094 if(p_GetExp(m, j, R) > 0) 1095 return true; 1096 1097 return false; 1098 1099 } else return true; 1100 } 1087 1101 1088 1102
Note: See TracChangeset
for help on using the changeset viewer.