Changeset 4eba3ad in git for dyn_modules/syzextra/syzextra.cc
- Timestamp:
- Apr 28, 2014, 8:49:00 PM (9 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- c7d29b194535c9015230fc587b2ae178c075ef3e
- Parents:
- 92992c08c2f387188f53d5f874a342fb60dccc06
- git-author:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2014-04-28 20:49:00+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
r92992c r4eba3ad 92 92 //return -( compare (c, qsorts) ) 93 93 94 #ifndef NDEBUG 94 95 const int __DEBUG__ = 0; 95 96 #ifndef NDEBUG97 96 if( __DEBUG__ ) 98 97 { … … 216 215 217 216 if( sizeNew >= 2 ) 218 qsort_my(id->m, sizeNew, sizeof(poly), r, SORT_c_ds::cmp_c_ds);217 qsort_my(id->m, sizeNew, sizeof(poly), r, FROM_NAMESPACE(SORT_c_ds, cmp_c_ds)); 219 218 220 219 #undef qsort_my … … 226 225 BEGIN_NAMESPACE(INTERNAL) 227 226 228 ideal ComputeLeadingSyzygyTerms(const ideal& id, const ring r) 229 { 227 ideal _ComputeLeadingSyzygyTerms(const ideal& id, 228 const ring r, 229 const SchreyerSyzygyComputationFlags attributes) 230 { 231 // const BOOLEAN __DEBUG__ = attributes.__DEBUG__; 232 // const BOOLEAN __SYZCHECK__ = attributes.__SYZCHECK__; 233 const BOOLEAN __LEAD2SYZ__ = attributes.__LEAD2SYZ__; 234 // const BOOLEAN __HYBRIDNF__ = attributes.__HYBRIDNF__; 235 // const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__; 236 237 assume(!__LEAD2SYZ__); 238 230 239 // 1. set of components S? 231 240 // 2. for each component c from S: set of indices of leading terms … … 329 338 } 330 339 331 332 333 334 ideal Compute2LeadingSyzygyTerms(const ideal& id, const ring r) 335 { 336 #ifndef NDEBUG 337 const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)TRUE))); 338 #else 339 const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)FALSE))); 340 #endif 341 342 const BOOLEAN __TAILREDSYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"TAILREDSYZ",INT_CMD, (void*)0))); 343 const BOOLEAN __SYZCHECK__ = (BOOLEAN)((long)(atGet(currRingHdl,"SYZCHECK",INT_CMD, (void*)0))); 344 345 340 ideal _Compute2LeadingSyzygyTerms(const ideal& id, 341 const ring r, 342 const SchreyerSyzygyComputationFlags attributes) 343 { 344 // const BOOLEAN __DEBUG__ = attributes.__DEBUG__; 345 // const BOOLEAN __SYZCHECK__ = attributes.__SYZCHECK__; 346 // const BOOLEAN __LEAD2SYZ__ = attributes.__LEAD2SYZ__; 347 // const BOOLEAN __HYBRIDNF__ = attributes.__HYBRIDNF__; 348 const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__; 349 346 350 347 351 // 1. set of components S? … … 482 486 } 483 487 484 poly FindReducer(poly product, poly syzterm, 485 ideal L, ideal LS, 486 const ring r) 487 { 488 poly _FindReducer(poly product, poly syzterm, 489 ideal L, ideal LS, 490 const ring r, 491 const SchreyerSyzygyComputationFlags attributes) 492 { 493 const BOOLEAN __DEBUG__ = attributes.__DEBUG__; 494 const BOOLEAN __SYZCHECK__ = attributes.__SYZCHECK__; 495 // const BOOLEAN __LEAD2SYZ__ = attributes.__LEAD2SYZ__; 496 // const BOOLEAN __HYBRIDNF__ = attributes.__HYBRIDNF__; 497 // const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__; 498 488 499 assume( product != NULL ); 489 500 assume( L != NULL ); … … 495 506 496 507 assume( c >= 0 && c < IDELEMS(L) ); 497 498 #ifndef NDEBUG499 const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)TRUE)));500 #else501 const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)FALSE)));502 #endif503 504 long debug = __DEBUG__;505 const BOOLEAN __SYZCHECK__ = (BOOLEAN)((long)(atGet(currRingHdl,"SYZCHECK",INT_CMD, (void*)debug)));506 508 507 509 if (__SYZCHECK__ && syzterm != NULL) … … 542 544 if( __DEBUG__ ) 543 545 { 544 Print(" FindReducer::Test SYZTERM: q == syzterm !:((, syzterm is: ");546 Print("_FindReducer::Test SYZTERM: q == syzterm !:((, syzterm is: "); 545 547 dPrint(syzterm, r, r, 1); 546 548 } … … 564 566 if( __DEBUG__ ) 565 567 { 566 Print(" FindReducer::Test LS: q is divisible by LS[%d] !:((, diviser is: ", kk+1);568 Print("_FindReducer::Test LS: q is divisible by LS[%d] !:((, diviser is: ", kk+1); 567 569 dPrint(pp, r, r, 1); 568 570 } … … 589 591 } 590 592 591 poly TraverseTail(poly multiplier, poly tail, 592 ideal L, ideal T, ideal LS, 593 const ring r) 594 { 593 poly _ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck, 594 ideal L, ideal T, ideal LS, 595 const ring r, const SchreyerSyzygyComputationFlags attributes); 596 597 poly _TraverseTail(poly multiplier, poly tail, 598 ideal L, ideal T, ideal LS, 599 const ring r, 600 const SchreyerSyzygyComputationFlags attributes) 601 { 602 // const BOOLEAN __DEBUG__ = attributes.__DEBUG__; 603 // const BOOLEAN __SYZCHECK__ = attributes.__SYZCHECK__; 604 // const BOOLEAN __LEAD2SYZ__ = attributes.__LEAD2SYZ__; 605 // const BOOLEAN __HYBRIDNF__ = attributes.__HYBRIDNF__; 606 // const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__; 607 595 608 assume( multiplier != NULL ); 596 609 … … 602 615 // iterate over the tail 603 616 for(poly p = tail; p != NULL; p = pNext(p)) 604 s = p_Add_q(s, ReduceTerm(multiplier, p, NULL, L, T, LS, r), r);617 s = p_Add_q(s, _ReduceTerm(multiplier, p, NULL, L, T, LS, r, attributes), r); 605 618 606 619 return s; … … 608 621 609 622 610 poly ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck, 611 ideal L, ideal T, ideal LS, const ring r) 612 { 623 poly _ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck, 624 ideal L, ideal T, ideal LS, 625 const ring r, 626 const SchreyerSyzygyComputationFlags attributes) 627 { 628 // const BOOLEAN __DEBUG__ = attributes.__DEBUG__; 629 // const BOOLEAN __SYZCHECK__ = attributes.__SYZCHECK__; 630 // const BOOLEAN __LEAD2SYZ__ = attributes.__LEAD2SYZ__; 631 // const BOOLEAN __HYBRIDNF__ = attributes.__HYBRIDNF__; 632 // const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__; 633 613 634 assume( multiplier != NULL ); 614 635 assume( term4reduction != NULL ); … … 627 648 // NOTE: only LT(term4reduction) should be used in the following: 628 649 poly product = pp_Mult_mm(multiplier, term4reduction, r); 629 s = FindReducer(product, syztermCheck, L, LS, r);650 s = _FindReducer(product, syztermCheck, L, LS, r, attributes); 630 651 p_Delete(&product, r); 631 652 } … … 642 663 643 664 if( tail != NULL ) 644 s = p_Add_q(s, TraverseTail(b, tail, L, T, LS, r), r);665 s = p_Add_q(s, _TraverseTail(b, tail, L, T, LS, r, attributes), r); 645 666 646 667 return s; … … 648 669 649 670 650 poly SchreyerSyzygyNF(poly syz_lead, poly syz_2, ideal L, ideal T, ideal LS, const ring r) 651 { 671 poly _SchreyerSyzygyNF(poly syz_lead, poly syz_2, 672 ideal L, ideal T, ideal LS, 673 const ring r, 674 const SchreyerSyzygyComputationFlags attributes) 675 { 676 // const BOOLEAN __DEBUG__ = attributes.__DEBUG__; 677 // const BOOLEAN __SYZCHECK__ = attributes.__SYZCHECK__; 678 // const BOOLEAN __LEAD2SYZ__ = attributes.__LEAD2SYZ__; 679 // const BOOLEAN __HYBRIDNF__ = attributes.__HYBRIDNF__; 680 // const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__; 681 652 682 assume( syz_lead != NULL ); 653 683 assume( syz_2 != NULL ); … … 678 708 while (spoly != NULL) 679 709 { 680 poly t = FindReducer(spoly, NULL, L, LS, r);710 poly t = _FindReducer(spoly, NULL, L, LS, r, attributes); 681 711 682 712 p_LmDelete(&spoly, r); … … 701 731 702 732 703 void ComputeSyzygy(const ideal L, const ideal T, ideal& LL, ideal& TT, const ring R) 704 { 733 void _ComputeSyzygy(const ideal L, const ideal T, 734 ideal& LL, ideal& TT, 735 const ring R, 736 const SchreyerSyzygyComputationFlags attributes) 737 { 738 // const BOOLEAN __DEBUG__ = attributes.__DEBUG__; 739 // const BOOLEAN __SYZCHECK__ = attributes.__SYZCHECK__; 740 const BOOLEAN __LEAD2SYZ__ = attributes.__LEAD2SYZ__; 741 const BOOLEAN __HYBRIDNF__ = attributes.__HYBRIDNF__; 742 const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__; 743 705 744 assume( R == currRing ); // For attributes :-/ 706 745 707 746 assume( IDELEMS(L) == IDELEMS(T) ); 708 747 709 #ifndef NDEBUG710 const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)TRUE)));711 #else712 const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)FALSE)));713 #endif714 715 const BOOLEAN __LEAD2SYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"LEAD2SYZ",INT_CMD, (void*)1)));716 const BOOLEAN __TAILREDSYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"TAILREDSYZ",INT_CMD, (void*)1)));717 const BOOLEAN __SYZCHECK__ = (BOOLEAN)((long)(atGet(currRingHdl,"SYZCHECK",INT_CMD, (void*)__DEBUG__)));718 719 const BOOLEAN __HYBRIDNF__ = (BOOLEAN)((long)(atGet(currRingHdl,"HYBRIDNF",INT_CMD, (void*)0)));720 721 722 748 if( __LEAD2SYZ__ ) 723 LL = Compute2LeadingSyzygyTerms(L, R); // 2 terms!749 LL = _Compute2LeadingSyzygyTerms(L, R, attributes); // 2 terms! 724 750 else 725 LL = ComputeLeadingSyzygyTerms(L, R); // 1 term!751 LL = _ComputeLeadingSyzygyTerms(L, R, attributes); // 1 term! 726 752 727 753 const int size = IDELEMS(LL); … … 758 784 if( ! __HYBRIDNF__ ) 759 785 { 760 poly t = TraverseTail(aa, T->m[r], L, T, LS, R);786 poly t = _TraverseTail(aa, T->m[r], L, T, LS, R, attributes); 761 787 762 788 if( a2 != NULL ) … … 768 794 assume( r2 >= 0 && r2 < IDELEMS(T) ); 769 795 770 TT->m[k] = p_Add_q(a2, p_Add_q(t, TraverseTail(aa2, T->m[r2], L, T, LS, R), R), R);796 TT->m[k] = p_Add_q(a2, p_Add_q(t, _TraverseTail(aa2, T->m[r2], L, T, LS, R, attributes), R), R); 771 797 772 798 p_Delete(&aa2, R); 773 799 } else 774 TT->m[k] = p_Add_q(t, ReduceTerm(aa, L->m[r], a, L, T, LS, R), R);800 TT->m[k] = p_Add_q(t, _ReduceTerm(aa, L->m[r], a, L, T, LS, R, attributes), R); 775 801 776 802 } else … … 779 805 { 780 806 aa = p_Mult_mm(aa, L->m[r], R); 781 a2 = FindReducer(aa, a, L, LS, R);807 a2 = _FindReducer(aa, a, L, LS, R, attributes); 782 808 } 783 809 assume( a2 != NULL ); 784 810 785 TT->m[k] = SchreyerSyzygyNF(a, a2, L, T, LS, R); // will copy a2 :(811 TT->m[k] = _SchreyerSyzygyNF(a, a2, L, T, LS, R, attributes); // will copy a2 :( 786 812 787 813 p_Delete(&a2, R); … … 796 822 797 823 824 // TODO: wrapper layer, just for now... dissolve! 825 798 826 void SchreyerSyzygyComputation::ComputeSyzygy() 799 827 { 800 828 /// assumes m_syzLeads == m_syzTails == NULL! 801 INTERNAL::ComputeSyzygy(m_idLeads, m_idTails, m_syzLeads, m_syzTails, m_rBaseRing); // TODO: just a wrapper for now :/829 FROM_NAMESPACE(INTERNAL, _ComputeSyzygy(m_idLeads, m_idTails, m_syzLeads, m_syzTails, m_rBaseRing, m_atttributes)); // TODO: just a wrapper for now :/ 802 830 } 803 831 … … 805 833 { 806 834 if( bComputeSecondTerms ) 807 m_syzLeads = INTERNAL::Compute2LeadingSyzygyTerms(m_idLeads, m_rBaseRing);835 m_syzLeads = FROM_NAMESPACE(INTERNAL, _Compute2LeadingSyzygyTerms(m_idLeads, m_rBaseRing, m_atttributes)); 808 836 else 809 m_syzLeads = INTERNAL::ComputeLeadingSyzygyTerms(m_idLeads, m_rBaseRing);837 m_syzLeads = FROM_NAMESPACE(INTERNAL, _ComputeLeadingSyzygyTerms(m_idLeads, m_rBaseRing, m_atttributes)); 810 838 811 839 // NOTE: set m_LS if tails are to be reduced! 812 840 } 813 841 814 poly SchreyerSyzygyComputation::FindReducer(poly product, poly syzterm) 815 { 816 return INTERNAL::FindReducer(product, syzterm, m_idLeads, m_LS, m_rBaseRing); 817 } 818 819 poly SchreyerSyzygyComputation::SchreyerSyzygyNF(poly syz_lead, poly syz_2) 820 { 821 return INTERNAL::SchreyerSyzygyNF(syz_lead, syz_2, m_idLeads, m_idTails, m_LS, m_rBaseRing); 822 } 823 824 poly SchreyerSyzygyComputation::TraverseTail(poly multiplier, poly tail) 825 { 826 return INTERNAL::TraverseTail(multiplier, tail, m_idLeads, m_idTails, m_LS, m_rBaseRing); 827 } 828 829 poly SchreyerSyzygyComputation::ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck) 830 { 831 return INTERNAL::ReduceTerm(multiplier, term4reduction, syztermCheck, m_idLeads, m_idTails, m_LS, m_rBaseRing); 832 } 833 842 poly SchreyerSyzygyComputation::FindReducer(poly product, poly syzterm) const 843 { 844 return FROM_NAMESPACE(INTERNAL, _FindReducer(product, syzterm, m_idLeads, m_LS, m_rBaseRing, m_atttributes)); 845 } 846 847 poly SchreyerSyzygyComputation::SchreyerSyzygyNF(poly syz_lead, poly syz_2) const 848 { 849 return FROM_NAMESPACE(INTERNAL, _SchreyerSyzygyNF(syz_lead, syz_2, m_idLeads, m_idTails, m_LS, m_rBaseRing, m_atttributes)); 850 } 851 852 poly SchreyerSyzygyComputation::TraverseTail(poly multiplier, poly tail) const 853 { 854 return FROM_NAMESPACE(INTERNAL, _TraverseTail(multiplier, tail, m_idLeads, m_idTails, m_LS, m_rBaseRing, m_atttributes)); 855 } 856 857 poly SchreyerSyzygyComputation::ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck) const 858 { 859 return FROM_NAMESPACE(INTERNAL, _ReduceTerm(multiplier, term4reduction, syztermCheck, m_idLeads, m_idTails, m_LS, m_rBaseRing, m_atttributes)); 860 } 861 862 863 BEGIN_NAMESPACE_NONAME 834 864 865 static inline int atGetInt(idhdl rootRingHdl, const char* attribute, int def) 866 { 867 return ((int)(long)(atGet(rootRingHdl, attribute, INT_CMD, (void*)def))); 868 } 869 870 END_NAMESPACE 871 872 SchreyerSyzygyComputationFlags::SchreyerSyzygyComputationFlags(idhdl rootRingHdl): 873 #ifndef NDEBUG 874 __DEBUG__( (BOOLEAN)atGetInt(rootRingHdl,"DEBUG", TRUE) ), 875 #else 876 __DEBUG__( (BOOLEAN)atGetInt(rootRingHdl,"DEBUG", FALSE) ), 877 #endif 878 __SYZCHECK__( (BOOLEAN)atGetInt(rootRingHdl, "SYZCHECK", __DEBUG__) ), 879 __LEAD2SYZ__( (BOOLEAN)atGetInt(rootRingHdl, "LEAD2SYZ", 1) ), 880 __TAILREDSYZ__( (BOOLEAN)atGetInt(rootRingHdl, "TAILREDSYZ", 1) ), 881 __HYBRIDNF__( (BOOLEAN)atGetInt(rootRingHdl, "HYBRIDNF", 0) ) 882 { 883 if( __DEBUG__ ) 884 { 885 PrintS("SchreyerSyzygyComputationFlags: \n"); 886 Print(" DEBUG : \t%d\n", __DEBUG__); 887 Print(" SYZCHECK : \t%d\n", __SYZCHECK__); 888 Print(" LEAD2SYZ : \t%d\n", __LEAD2SYZ__); 889 Print(" TAILREDSYZ: \t%d\n", __TAILREDSYZ__); 890 } 891 892 // TODO: just current setting! 893 assume( rootRingHdl == currRingHdl ); 894 assume( rootRingHdl->typ == RING_CMD ); 895 assume( rootRingHdl->data.uring == currRing ); 896 // move the global ring here inside??? 897 } 898 899 835 900 836 901
Note: See TracChangeset
for help on using the changeset viewer.