Changeset 74afe1f in git
- Timestamp:
- May 23, 2012, 8:26:06 PM (11 years ago)
- Branches:
- (u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
- Children:
- 8e650e4e942e4e3510a0d6fddf77ac0f30d32fb5
- Parents:
- 5020a60f5779ffc1406febfaaefb86db176ddc13
- git-author:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-05-23 20:26:06+02:00
- git-committer:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2014-05-07 04:41:43+02:00
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/schreyer.lib
r5020a6 r74afe1f 703 703 704 704 // attrib(S, "InducionStart", @RANK); 705 attrib(S, "LEAD2SYZ", 0);705 attrib(S, "LEAD2SYZ", 1); 706 706 attrib(S, "TAILREDSYZ", 1); 707 707 attrib(S, "DEBUG", @DEBUG); … … 857 857 858 858 /// Compute Syz(L), where L is a monomial (leading) module 859 proc SSCompute2LeadingSyzygyTerms(def L , int @TAILREDSYZ)859 proc SSCompute2LeadingSyzygyTerms(def L) 860 860 { 861 861 if( typeof( attrib(basering, "DEBUG") ) == "int" ) … … 874 874 int @SYZCHECK = @DEBUG; 875 875 } 876 877 int @TAILREDSYZ = 1; 878 if( typeof( attrib(basering, "TAILREDSYZ") ) == "int" ) 879 { 880 @TAILREDSYZ = attrib(basering, "TAILREDSYZ"); 881 } 882 876 883 877 884 if( @DEBUG ) … … 879 886 "SSCompute2LeadingSyzygyTerms::Input: "; 880 887 L; 881 "@TAILREDSYZ: ", @TAILREDSYZ;882 888 } 883 889 … … 956 962 } 957 963 } 958 } 964 965 module SS = Compute2LeadingSyzygyTerms(L); 966 967 "S: "; DetailedPrint(S); 968 "SS: "; DetailedPrint(SS); 969 970 if( size(module(matrix(S) - matrix(SS))) > 0 ) 971 { 972 "ERROR: S != SS "; 973 974 "basering: "; 975 DetailedPrint(basering); 976 977 "S: "; S; 978 DetailedPrint(S, 2); 979 "SS: "; SS; 980 DetailedPrint(SS, 2); 981 982 "DIFF: "; 983 print(matrix(S) - matrix(SS)); 984 DetailedPrint(module(matrix(S) - matrix(SS)), 4); 985 $ 986 } 987 988 } 959 989 960 990 module S2 = Tail(S); … … 1146 1176 def a2; int r2; poly aa2; 1147 1177 module LL, LL2; 1148 (LL, LL2) = SSCompute2LeadingSyzygyTerms(L , @TAILREDSYZ); // ++1178 (LL, LL2) = SSCompute2LeadingSyzygyTerms(L); // ++ 1149 1179 } else 1150 1180 { … … 1562 1592 exportto(Schreyer, Syzextra::Tail); 1563 1593 exportto(Schreyer, Syzextra::ComputeLeadingSyzygyTerms); 1594 exportto(Schreyer, Syzextra::Compute2LeadingSyzygyTerms); 1564 1595 exportto(Schreyer, Syzextra::Sort_c_ds); 1565 1596 } … … 1605 1636 exportto(Schreyer, Syzextra_g::Tail); 1606 1637 exportto(Schreyer, Syzextra_g::ComputeLeadingSyzygyTerms); 1638 exportto(Schreyer, Syzextra_g::Compute2LeadingSyzygyTerms); 1607 1639 exportto(Schreyer, Syzextra_g::Sort_c_ds); 1608 1640 -
dyn_modules/syzextra/mod_main.cc
r5020a6 r74afe1f 8 8 9 9 #include <misc/intvec.h> 10 #include <misc/options.h> 10 11 11 12 #include <coeffs/coeffs.h> … … 531 532 const poly b = *(const poly*)p2; 532 533 534 assume( a != NULL ); 535 assume( b != NULL ); 536 533 537 assume( p_LmTest(a, r) ); 534 538 assume( p_LmTest(b, r) ); … … 629 633 const BOOLEAN __LEAD2SYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"LEAD2SYZ",INT_CMD, (void*)0))); 630 634 const BOOLEAN __TAILREDSYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"TAILREDSYZ",INT_CMD, (void*)0))); 631 const BOOLEAN __SYZCHECK__ = (BOOLEAN)((long)(atGet(currRingHdl,"SYZCHECK",INT_CMD, (void*)0))); 635 const BOOLEAN __SYZCHECK__ = (BOOLEAN)((long)(atGet(currRingHdl,"SYZCHECK",INT_CMD, (void*)0))); 636 632 637 633 638 Print("\nSYZCHECK: \t%d", __SYZCHECK__); … … 637 642 638 643 dPrint(id, r, r, 1); 644 645 assume( !__LEAD2SYZ__ ); 639 646 } 640 647 … … 747 754 if( sizeNew >= 2 ) 748 755 qsort_r(newid->m, sizeNew, sizeof(poly), cmp_c_ds, r); 756 757 if (IDELEMS(newid) == 0 || (IDELEMS(newid) == 1 && newid->m[0] == NULL) ) 758 newid->rank = 1; 749 759 750 760 // TODO: add sorting wrt <c,ds> & reversing... … … 836 846 } 837 847 848 849 850 static BOOLEAN Compute2LeadingSyzygyTerms(leftv res, leftv h) 851 { 852 const ring r = currRing; 853 NoReturn(res); 854 855 if( h == NULL ) 856 { 857 WarnS("Compute2LeadingSyzygyTerms needs an argument..."); 858 return TRUE; 859 } 860 861 assume( h != NULL ); 862 863 #ifndef NDEBUG 864 const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)TRUE))); 865 #else 866 const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)FALSE))); 867 #endif 868 869 const BOOLEAN __TAILREDSYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"TAILREDSYZ",INT_CMD, (void*)0))); 870 const BOOLEAN __LEAD2SYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"LEAD2SYZ",INT_CMD, (void*)0))); 871 const BOOLEAN __SYZCHECK__ = (BOOLEAN)((long)(atGet(currRingHdl,"SYZCHECK",INT_CMD, (void*)0))); 872 873 874 assume( __LEAD2SYZ__ ); 875 876 if( h->Typ() == IDEAL_CMD || h->Typ() == MODUL_CMD) 877 { 878 const ideal id = (const ideal)h->Data(); 879 880 assume(id != NULL); 881 882 if( __DEBUG__ ) 883 { 884 PrintS("Compute2LeadingSyzygyTerms::Input: \n"); 885 886 Print("\nSYZCHECK: \t%d", __SYZCHECK__); 887 Print(", DEBUG: \t%d", __DEBUG__); 888 Print(", LEAD2SYZ: \t%d", __LEAD2SYZ__); 889 Print(", TAILREDSYZ: \t%d\n", __TAILREDSYZ__); 890 891 dPrint(id, r, r, 1); 892 } 893 894 h = h->Next(); assume (h == NULL); 895 896 // 1. set of components S? 897 // 2. for each component c from S: set of indices of leading terms 898 // with this component? 899 // 3. short exp. vectors for each leading term? 900 901 const int size = IDELEMS(id); 902 903 if( size < 2 ) 904 { 905 const ideal newid = idInit(1, 1); // zero module... 906 907 newid->m[0] = NULL; 908 909 res->data = newid; 910 res->rtyp = MODUL_CMD; 911 912 return FALSE; 913 } 914 915 916 // TODO/NOTE: input is supposed to be sorted wrt "C,ds"!?? 917 918 // components should come in groups: count elements in each group 919 // && estimate the real size!!! 920 921 922 // use just a vector instead??? 923 ideal newid = idInit( (size * (size-1))/2, size); // maximal size: ideal case! 924 925 int k = 0; 926 927 for (int j = 0; j < size; j++) 928 { 929 const poly p = id->m[j]; 930 assume( p != NULL ); 931 const int c = p_GetComp(p, r); 932 933 for (int i = j - 1; i >= 0; i--) 934 { 935 const poly pp = id->m[i]; 936 assume( pp != NULL ); 937 const int cc = p_GetComp(pp, r); 938 939 if( c != cc ) 940 continue; 941 942 // allocate memory & zero it out! 943 const poly m = p_Init(r); const poly mm = p_Init(r); 944 945 946 // m = LCM(p, pp) / p! mm = LCM(p, pp) / pp! 947 // TODO: optimize: knowing the ring structure: (C/lp)! 948 949 for (int v = rVar(r); v > 0; v--) 950 { 951 assume( v > 0 ); 952 assume( v <= rVar(r) ); 953 954 const short e1 = p_GetExp(p , v, r); 955 const short e2 = p_GetExp(pp, v, r); 956 957 if( e1 >= e2 ) 958 p_SetExp(mm, v, e1 - e2, r); // p_SetExp(m, v, 0, r); 959 else 960 p_SetExp(m, v, e2 - e1, r); // p_SetExp(mm, v, 0, r); 961 962 } 963 964 assume( (j > i) && (i >= 0) ); 965 966 p_SetComp(m, j + 1, r); 967 p_SetComp(mm, i + 1, r); 968 969 const number& lc1 = p_GetCoeff(p , r); 970 const number& lc2 = p_GetCoeff(pp, r); 971 972 number g = n_Lcm( lc1, lc2, r ); 973 974 p_SetCoeff0(m , n_Div(g, lc1, r), r); 975 p_SetCoeff0(mm, n_Neg(n_Div(g, lc2, r), r), r); 976 977 n_Delete(&g, r); 978 979 p_Setm(m, r); // should not do anything!!! 980 p_Setm(mm, r); // should not do anything!!! 981 982 pNext(m) = mm; // pNext(mm) = NULL; 983 984 newid->m[k++] = m; 985 } 986 } 987 988 if( __DEBUG__ && FALSE ) 989 { 990 PrintS("Compute2LeadingSyzygyTerms::Temp0: \n"); 991 dPrint(newid, r, r, 1); 992 } 993 994 if( !__TAILREDSYZ__ ) 995 { 996 // simplify(newid, 2 + 32)?? 997 // sort(newid, "C,ds")[1]??? 998 id_DelDiv(newid, r); // #define SIMPL_LMDIV 32 999 1000 if( __DEBUG__ && FALSE ) 1001 { 1002 PrintS("Compute2LeadingSyzygyTerms::Temp1 (deldiv): \n"); 1003 dPrint(newid, r, r, 1); 1004 } 1005 } 1006 else 1007 { 1008 // option(redSB); option(redTail); 1009 // TEST_OPT_REDSB 1010 // TEST_OPT_REDTAIL 1011 assume( r == currRing ); 1012 BITSET _save_test = test; 1013 test |= (Sy_bit(OPT_REDTAIL) | Sy_bit(OPT_REDSB)); 1014 1015 intvec* w=new intvec(IDELEMS(newid)); 1016 ideal tmp = kStd(newid, currQuotient, isHomog, &w); 1017 delete w; 1018 1019 test = _save_test; 1020 1021 id_Delete(&newid, r); 1022 newid = tmp; 1023 1024 if( __DEBUG__ && FALSE ) 1025 { 1026 PrintS("Compute2LeadingSyzygyTerms::Temp1 (std): \n"); 1027 dPrint(newid, r, r, 1); 1028 } 1029 1030 } 1031 1032 idSkipZeroes(newid); 1033 1034 const int sizeNew = IDELEMS(newid); 1035 1036 if( sizeNew >= 2 ) 1037 qsort_r(newid->m, sizeNew, sizeof(poly), cmp_c_ds, r); 1038 1039 if (IDELEMS(newid) == 0 || (IDELEMS(newid) == 1 && newid->m[0] == NULL) ) 1040 newid->rank = 1; 1041 1042 // TODO: add sorting wrt <c,ds> & reversing... 1043 1044 res->data = newid; 1045 res->rtyp = MODUL_CMD; 1046 1047 return FALSE; 1048 } 1049 1050 WarnS("Compute2LeadingSyzygyTerms needs a single ideal/module argument..."); 1051 return TRUE; 1052 } 838 1053 839 1054 … … 1484 1699 1485 1700 ADD(psModulFunctions, currPack->libname, "Tail", FALSE, Tail); 1701 1486 1702 ADD(psModulFunctions, currPack->libname, "ComputeLeadingSyzygyTerms", FALSE, ComputeLeadingSyzygyTerms); 1703 ADD(psModulFunctions, currPack->libname, "Compute2LeadingSyzygyTerms", FALSE, Compute2LeadingSyzygyTerms); 1704 1487 1705 ADD(psModulFunctions, currPack->libname, "Sort_c_ds", FALSE, Sort_c_ds); 1488 1706
Note: See TracChangeset
for help on using the changeset viewer.