Changeset f12f9a in git
 Timestamp:
 Jun 14, 2012, 10:14:36 PM (11 years ago)
 Branches:
 (u'jengelhdatetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
 Children:
 2c16b81352589f222e0e327ed8ce64db62736728
 Parents:
 9e69e026591b541d6cf5548fcb1dee77c6c1f9ed
 gitauthor:
 Oleksandr Motsak <motsak@mathematik.unikl.de>20120614 22:14:36+02:00
 gitcommitter:
 Oleksandr Motsak <motsak@mathematik.unikl.de>20140507 04:41:45+02:00
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

dyn_modules/syzextra/mod_main.cc
r9e69e0 rf12f9a 619 619 620 620 621 622 static ideal ComputeLeadingSyzygyTerms(const ideal& id, const ring r) 623 { 624 // 1. set of components S? 625 // 2. for each component c from S: set of indices of leading terms 626 // with this component? 627 // 3. short exp. vectors for each leading term? 628 629 const int size = IDELEMS(id); 630 631 if( size < 2 ) 632 { 633 const ideal newid = idInit(1, 0); newid>m[0] = NULL; // zero ideal... 634 return newid; 635 } 636 637 638 // TODO/NOTE: input is supposed to be (reverse) sorted wrt "(c,ds)"!?? 639 640 // components should come in groups: count elements in each group 641 // && estimate the real size!!! 642 643 644 // use just a vector instead??? 645 const ideal newid = idInit( (size * (size1))/2, size); // maximal size: ideal case! 646 647 int k = 0; 648 649 for (int j = 0; j < size; j++) 650 { 651 const poly p = id>m[j]; 652 assume( p != NULL ); 653 const int c = p_GetComp(p, r); 654 655 for (int i = j  1; i >= 0; i) 656 { 657 const poly pp = id>m[i]; 658 assume( pp != NULL ); 659 const int cc = p_GetComp(pp, r); 660 661 if( c != cc ) 662 continue; 663 664 const poly m = p_Init(r); // p_New??? 665 666 // m = LCM(p, pp) / p! // TODO: optimize: knowing the ring structure: (C/lp)! 667 for (int v = rVar(r); v > 0; v) 668 { 669 assume( v > 0 ); 670 assume( v <= rVar(r) ); 671 672 const short e1 = p_GetExp(p , v, r); 673 const short e2 = p_GetExp(pp, v, r); 674 675 if( e1 >= e2 ) 676 p_SetExp(m, v, 0, r); 677 else 678 p_SetExp(m, v, e2  e1, r); 679 680 } 681 682 assume( (j > i) && (i >= 0) ); 683 684 p_SetComp(m, j + 1, r); 685 pNext(m) = NULL; 686 p_SetCoeff0(m, n_Init(1, r>cf), r); // for later... 687 688 p_Setm(m, r); // should not do anything!!! 689 690 newid>m[k++] = m; 691 } 692 } 693 694 // if( __DEBUG__ && FALSE ) 695 // { 696 // PrintS("ComputeLeadingSyzygyTerms::Temp0: \n"); 697 // dPrint(newid, r, r, 1); 698 // } 699 700 // the rest of newid is assumed to be zeroes... 701 702 // simplify(newid, 2 + 32)?? 703 // sort(newid, "C,ds")[1]??? 704 id_DelDiv(newid, r); // #define SIMPL_LMDIV 32 705 706 // if( __DEBUG__ && FALSE ) 707 // { 708 // PrintS("ComputeLeadingSyzygyTerms::Temp1: \n"); 709 // dPrint(newid, r, r, 1); 710 // } 711 712 idSkipZeroes(newid); // #define SIMPL_NULL 2 713 714 // if( __DEBUG__ ) 715 // { 716 // PrintS("ComputeLeadingSyzygyTerms::Output: \n"); 717 // dPrint(newid, r, r, 1); 718 // } 719 720 const int sizeNew = IDELEMS(newid); 721 722 if( sizeNew >= 2 ) 723 qsort_my(newid>m, sizeNew, sizeof(poly), r, cmp_c_ds); 724 725 newid>rank = id_RankFreeModule(newid, r); 726 727 return newid; 728 } 729 730 621 731 static BOOLEAN ComputeLeadingSyzygyTerms(leftv res, leftv h) 622 732 { … … 665 775 h = h>Next(); assume (h == NULL); 666 776 667 // 1. set of components S? 668 // 2. for each component c from S: set of indices of leading terms 669 // with this component? 670 // 3. short exp. vectors for each leading term? 671 672 const int size = IDELEMS(id); 673 674 if( size < 2 ) 675 { 676 const ideal newid = idInit(1, 0); // zero ideal... 677 678 newid>m[0] = NULL; 679 680 res>data = newid; 681 res>rtyp = MODUL_CMD; 682 683 return FALSE; 684 } 777 const ideal newid = ComputeLeadingSyzygyTerms(id, r); 685 778 686 687 // TODO/NOTE: input is supposed to be (reverse) sorted wrt "(c,ds)"!?? 688 689 // components should come in groups: count elements in each group 690 // && estimate the real size!!! 691 692 693 // use just a vector instead??? 694 const ideal newid = idInit( (size * (size1))/2, size); // maximal size: ideal case! 695 696 int k = 0; 697 698 for (int j = 0; j < size; j++) 699 { 700 const poly p = id>m[j]; 701 assume( p != NULL ); 702 const int c = p_GetComp(p, r); 703 704 for (int i = j  1; i >= 0; i) 705 { 706 const poly pp = id>m[i]; 707 assume( pp != NULL ); 708 const int cc = p_GetComp(pp, r); 709 710 if( c != cc ) 711 continue; 712 713 const poly m = p_Init(r); // p_New??? 714 715 // m = LCM(p, pp) / p! // TODO: optimize: knowing the ring structure: (C/lp)! 716 for (int v = rVar(r); v > 0; v) 717 { 718 assume( v > 0 ); 719 assume( v <= rVar(r) ); 720 721 const short e1 = p_GetExp(p , v, r); 722 const short e2 = p_GetExp(pp, v, r); 723 724 if( e1 >= e2 ) 725 p_SetExp(m, v, 0, r); 726 else 727 p_SetExp(m, v, e2  e1, r); 728 729 } 730 731 assume( (j > i) && (i >= 0) ); 732 733 p_SetComp(m, j + 1, r); 734 pNext(m) = NULL; 735 p_SetCoeff0(m, n_Init(1, r>cf), r); // for later... 736 737 p_Setm(m, r); // should not do anything!!! 738 739 newid>m[k++] = m; 740 } 741 } 742 743 if( __DEBUG__ && FALSE ) 744 { 745 PrintS("ComputeLeadingSyzygyTerms::Temp0: \n"); 746 dPrint(newid, r, r, 1); 747 } 748 749 // the rest of newid is assumed to be zeroes... 750 751 // simplify(newid, 2 + 32)?? 752 // sort(newid, "C,ds")[1]??? 753 id_DelDiv(newid, r); // #define SIMPL_LMDIV 32 754 755 if( __DEBUG__ && FALSE ) 756 { 757 PrintS("ComputeLeadingSyzygyTerms::Temp1: \n"); 758 dPrint(newid, r, r, 1); 759 } 760 761 idSkipZeroes(newid); // #define SIMPL_NULL 2 762 763 if( __DEBUG__ ) 764 { 765 PrintS("ComputeLeadingSyzygyTerms::Output: \n"); 766 dPrint(newid, r, r, 1); 767 } 768 769 const int sizeNew = IDELEMS(newid); 770 771 if( sizeNew >= 2 ) 772 qsort_my(newid>m, sizeNew, sizeof(poly), r, cmp_c_ds); 773 774 if (IDELEMS(newid) == 0  (IDELEMS(newid) == 1 && newid>m[0] == NULL) ) 775 newid>rank = 1; 776 777 // TODO: add sorting wrt <c,ds> & reversing... 778 779 res>data = newid; 780 res>rtyp = MODUL_CMD; 781 779 res>data = newid; res>rtyp = MODUL_CMD; 782 780 return FALSE; 783 781 } … … 865 863 866 864 867 static BOOLEAN Compute2LeadingSyzygyTerms(leftv res, leftv h) 868 { 869 const ring r = currRing; 870 NoReturn(res); 871 872 if( h == NULL ) 873 { 874 WarnS("Compute2LeadingSyzygyTerms needs an argument..."); 875 return TRUE; 876 } 877 878 assume( h != NULL ); 879 865 static ideal Compute2LeadingSyzygyTerms(const ideal& id, const ring r) 866 { 880 867 #ifndef NDEBUG 881 868 const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)TRUE))); … … 885 872 886 873 const BOOLEAN __TAILREDSYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"TAILREDSYZ",INT_CMD, (void*)0))); 874 const BOOLEAN __SYZCHECK__ = (BOOLEAN)((long)(atGet(currRingHdl,"SYZCHECK",INT_CMD, (void*)0))); 875 876 877 878 // 1. set of components S? 879 // 2. for each component c from S: set of indices of leading terms 880 // with this component? 881 // 3. short exp. vectors for each leading term? 882 883 const int size = IDELEMS(id); 884 885 if( size < 2 ) 886 { 887 const ideal newid = idInit(1, 1); newid>m[0] = NULL; // zero module... 888 return newid; 889 } 890 891 892 // TODO/NOTE: input is supposed to be sorted wrt "C,ds"!?? 893 894 // components should come in groups: count elements in each group 895 // && estimate the real size!!! 896 897 898 // use just a vector instead??? 899 ideal newid = idInit( (size * (size1))/2, size); // maximal size: ideal case! 900 901 int k = 0; 902 903 for (int j = 0; j < size; j++) 904 { 905 const poly p = id>m[j]; 906 assume( p != NULL ); 907 const int c = p_GetComp(p, r); 908 909 for (int i = j  1; i >= 0; i) 910 { 911 const poly pp = id>m[i]; 912 assume( pp != NULL ); 913 const int cc = p_GetComp(pp, r); 914 915 if( c != cc ) 916 continue; 917 918 // allocate memory & zero it out! 919 const poly m = p_Init(r); const poly mm = p_Init(r); 920 921 922 // m = LCM(p, pp) / p! mm = LCM(p, pp) / pp! 923 // TODO: optimize: knowing the ring structure: (C/lp)! 924 925 for (int v = rVar(r); v > 0; v) 926 { 927 assume( v > 0 ); 928 assume( v <= rVar(r) ); 929 930 const short e1 = p_GetExp(p , v, r); 931 const short e2 = p_GetExp(pp, v, r); 932 933 if( e1 >= e2 ) 934 p_SetExp(mm, v, e1  e2, r); // p_SetExp(m, v, 0, r); 935 else 936 p_SetExp(m, v, e2  e1, r); // p_SetExp(mm, v, 0, r); 937 938 } 939 940 assume( (j > i) && (i >= 0) ); 941 942 p_SetComp(m, j + 1, r); 943 p_SetComp(mm, i + 1, r); 944 945 const number& lc1 = p_GetCoeff(p , r); 946 const number& lc2 = p_GetCoeff(pp, r); 947 948 number g = n_Lcm( lc1, lc2, r ); 949 950 p_SetCoeff0(m , n_Div(g, lc1, r), r); 951 p_SetCoeff0(mm, n_Neg(n_Div(g, lc2, r), r), r); 952 953 n_Delete(&g, r); 954 955 p_Setm(m, r); // should not do anything!!! 956 p_Setm(mm, r); // should not do anything!!! 957 958 pNext(m) = mm; // pNext(mm) = NULL; 959 960 newid>m[k++] = m; 961 } 962 } 963 964 // if( __DEBUG__ && FALSE ) 965 // { 966 // PrintS("Compute2LeadingSyzygyTerms::Temp0: \n"); 967 // dPrint(newid, r, r, 1); 968 // } 969 970 if( !__TAILREDSYZ__ ) 971 { 972 // simplify(newid, 2 + 32)?? 973 // sort(newid, "C,ds")[1]??? 974 id_DelDiv(newid, r); // #define SIMPL_LMDIV 32 975 976 // if( __DEBUG__ && FALSE ) 977 // { 978 // PrintS("Compute2LeadingSyzygyTerms::Temp1 (deldiv): \n"); 979 // dPrint(newid, r, r, 1); 980 // } 981 } 982 else 983 { 984 // option(redSB); option(redTail); 985 // TEST_OPT_REDSB 986 // TEST_OPT_REDTAIL 987 assume( r == currRing ); 988 BITSET _save_test = test; 989 test = (Sy_bit(OPT_REDTAIL)  Sy_bit(OPT_REDSB)); 990 991 intvec* w=new intvec(IDELEMS(newid)); 992 ideal tmp = kStd(newid, currQuotient, isHomog, &w); 993 delete w; 994 995 test = _save_test; 996 997 id_Delete(&newid, r); 998 newid = tmp; 999 1000 // if( __DEBUG__ && FALSE ) 1001 // { 1002 // PrintS("Compute2LeadingSyzygyTerms::Temp1 (std): \n"); 1003 // dPrint(newid, r, r, 1); 1004 // } 1005 1006 } 1007 1008 idSkipZeroes(newid); 1009 1010 const int sizeNew = IDELEMS(newid); 1011 1012 if( sizeNew >= 2 ) 1013 qsort_my(newid>m, sizeNew, sizeof(poly), r, cmp_c_ds); 1014 1015 newid>rank = id_RankFreeModule(newid, r); 1016 1017 return newid; 1018 } 1019 1020 1021 1022 static BOOLEAN Compute2LeadingSyzygyTerms(leftv res, leftv h) 1023 { 1024 const ring r = currRing; 1025 NoReturn(res); 1026 1027 if( h == NULL ) 1028 { 1029 WarnS("Compute2LeadingSyzygyTerms needs an argument..."); 1030 return TRUE; 1031 } 1032 1033 assume( h != NULL ); 1034 1035 #ifndef NDEBUG 1036 const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)TRUE))); 1037 #else 1038 const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)FALSE))); 1039 #endif 1040 887 1041 const BOOLEAN __LEAD2SYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"LEAD2SYZ",INT_CMD, (void*)0))); 888 const BOOLEAN __SYZCHECK__ = (BOOLEAN)((long)(atGet(currRingHdl,"SYZCHECK",INT_CMD, (void*)0))); 889 890 1042 891 1043 assume( __LEAD2SYZ__ ); 892 1044 … … 900 1052 { 901 1053 PrintS("Compute2LeadingSyzygyTerms::Input: \n"); 902 903 Print("\nSYZCHECK: \t%d", __SYZCHECK__); 904 Print(", DEBUG: \t%d", __DEBUG__); 905 Print(", LEAD2SYZ: \t%d", __LEAD2SYZ__); 906 Print(", TAILREDSYZ: \t%d\n", __TAILREDSYZ__); 907 908 dPrint(id, r, r, 1); 1054 dPrint(id, r, r, 0); 909 1055 } 910 1056 911 1057 h = h>Next(); assume (h == NULL); 912 1058 913 // 1. set of components S? 914 // 2. for each component c from S: set of indices of leading terms 915 // with this component? 916 // 3. short exp. vectors for each leading term? 917 918 const int size = IDELEMS(id); 919 920 if( size < 2 ) 921 { 922 const ideal newid = idInit(1, 1); // zero module... 923 924 newid>m[0] = NULL; 925 926 res>data = newid; 927 res>rtyp = MODUL_CMD; 928 929 return FALSE; 930 } 931 932 933 // TODO/NOTE: input is supposed to be sorted wrt "C,ds"!?? 934 935 // components should come in groups: count elements in each group 936 // && estimate the real size!!! 937 938 939 // use just a vector instead??? 940 ideal newid = idInit( (size * (size1))/2, size); // maximal size: ideal case! 941 942 int k = 0; 943 944 for (int j = 0; j < size; j++) 945 { 946 const poly p = id>m[j]; 947 assume( p != NULL ); 948 const int c = p_GetComp(p, r); 949 950 for (int i = j  1; i >= 0; i) 951 { 952 const poly pp = id>m[i]; 953 assume( pp != NULL ); 954 const int cc = p_GetComp(pp, r); 955 956 if( c != cc ) 957 continue; 958 959 // allocate memory & zero it out! 960 const poly m = p_Init(r); const poly mm = p_Init(r); 961 962 963 // m = LCM(p, pp) / p! mm = LCM(p, pp) / pp! 964 // TODO: optimize: knowing the ring structure: (C/lp)! 965 966 for (int v = rVar(r); v > 0; v) 967 { 968 assume( v > 0 ); 969 assume( v <= rVar(r) ); 970 971 const short e1 = p_GetExp(p , v, r); 972 const short e2 = p_GetExp(pp, v, r); 973 974 if( e1 >= e2 ) 975 p_SetExp(mm, v, e1  e2, r); // p_SetExp(m, v, 0, r); 976 else 977 p_SetExp(m, v, e2  e1, r); // p_SetExp(mm, v, 0, r); 978 979 } 980 981 assume( (j > i) && (i >= 0) ); 982 983 p_SetComp(m, j + 1, r); 984 p_SetComp(mm, i + 1, r); 985 986 const number& lc1 = p_GetCoeff(p , r); 987 const number& lc2 = p_GetCoeff(pp, r); 988 989 number g = n_Lcm( lc1, lc2, r ); 990 991 p_SetCoeff0(m , n_Div(g, lc1, r), r); 992 p_SetCoeff0(mm, n_Neg(n_Div(g, lc2, r), r), r); 993 994 n_Delete(&g, r); 995 996 p_Setm(m, r); // should not do anything!!! 997 p_Setm(mm, r); // should not do anything!!! 998 999 pNext(m) = mm; // pNext(mm) = NULL; 1000 1001 newid>m[k++] = m; 1002 } 1003 } 1004 1005 if( __DEBUG__ && FALSE ) 1006 { 1007 PrintS("Compute2LeadingSyzygyTerms::Temp0: \n"); 1008 dPrint(newid, r, r, 1); 1009 } 1010 1011 if( !__TAILREDSYZ__ ) 1012 { 1013 // simplify(newid, 2 + 32)?? 1014 // sort(newid, "C,ds")[1]??? 1015 id_DelDiv(newid, r); // #define SIMPL_LMDIV 32 1016 1017 if( __DEBUG__ && FALSE ) 1018 { 1019 PrintS("Compute2LeadingSyzygyTerms::Temp1 (deldiv): \n"); 1020 dPrint(newid, r, r, 1); 1021 } 1022 } 1023 else 1024 { 1025 // option(redSB); option(redTail); 1026 // TEST_OPT_REDSB 1027 // TEST_OPT_REDTAIL 1028 assume( r == currRing ); 1029 BITSET _save_test = test; 1030 test = (Sy_bit(OPT_REDTAIL)  Sy_bit(OPT_REDSB)); 1031 1032 intvec* w=new intvec(IDELEMS(newid)); 1033 ideal tmp = kStd(newid, currQuotient, isHomog, &w); 1034 delete w; 1035 1036 test = _save_test; 1037 1038 id_Delete(&newid, r); 1039 newid = tmp; 1040 1041 if( __DEBUG__ && FALSE ) 1042 { 1043 PrintS("Compute2LeadingSyzygyTerms::Temp1 (std): \n"); 1044 dPrint(newid, r, r, 1); 1045 } 1046 1047 } 1048 1049 idSkipZeroes(newid); 1050 1051 const int sizeNew = IDELEMS(newid); 1052 1053 if( sizeNew >= 2 ) 1054 qsort_my(newid>m, sizeNew, sizeof(poly), r, cmp_c_ds); 1055 1056 if (IDELEMS(newid) == 0  (IDELEMS(newid) == 1 && newid>m[0] == NULL) ) 1057 newid>rank = 1; 1058 1059 // TODO: add sorting wrt <c,ds> & reversing... 1060 1061 res>data = newid; 1059 res>data = Compute2LeadingSyzygyTerms(id, r); 1062 1060 res>rtyp = MODUL_CMD; 1063 1061
Note: See TracChangeset
for help on using the changeset viewer.