Changeset d79a74 in git
- Timestamp:
- Dec 9, 2014, 6:59:51 PM (9 years ago)
- Branches:
- (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
- Children:
- 70eecb25f735a5ffd8523ba1253e0d8a08f8c1a9
- Parents:
- 56d8843ea10b1914d8654dce77191eb32927691a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/schreyer.lib
r56d884 rd79a74 549 549 ERROR("Sorry: need an ideal or a module for input"); 550 550 } 551 552 // TODO! DONE?553 551 def @save = basering; 554 552 … … 588 586 } 589 587 590 588 int @RINGCHANGE = 0; 589 590 if( typeof( attrib(SSinit, "RINGCHANGE") ) == "int" ) 591 { 592 @RINGCHANGE = attrib(SSinit, "@RINGCHANGE"); 593 } 594 595 591 596 if( @DEBUG ) 592 597 { 593 598 "SSinit::Input"; 594 599 type(M); 595 // DetailedPrint(M);596 600 attrib(M); 597 601 } … … 606 610 option(set, opts); 607 611 kill opts; 608 }// else 609 // { 610 M = simplify(M, 1 + 2 + 4 + 32); // interreduce? 611 // } 612 } 613 614 M = simplify(M, 1 + 2 + 4 + 32); 612 615 613 616 if( @IGNORETAILS ) … … 621 624 } 622 625 } 623 624 625 626 626 627 def @N = MySort(M); // TODO: replace with inplace sorting!!! 627 628 def LEAD = lead(@N); … … 672 673 673 674 // TODO: what about real modules? weighted ones? 674 675 list @l = ringlist(@save); 676 677 int @z = 0; ideal @m = maxideal(1); intvec @wdeg = deg(@m[1..ncols(@m)]); 678 679 // NOTE: @wdeg will be ignored anyway :( 680 @l[3] = list(list("C", @z), list("lp", @wdeg)); 681 682 kill @z, @wdeg; // since these vars are ring independent! 683 684 def S = ring(@l); // --MakeInducedSchreyerOrdering(1); 685 686 module F = freemodule(@RANK); 687 intvec @V = deg(F[1..@RANK]); 688 689 setring S; // ring with an easy divisibility test ("C, lex") 690 691 if( @DEBUG ) 692 { 693 "SSinit::NewRing(C, lex)"; 694 basering; 695 DetailedPrint(basering); 696 } 675 676 if( @RINGCHANGE ) 677 { 678 list @l = ringlist(@save); 679 int @z = 0; ideal @m = maxideal(1); intvec @wdeg = deg(@m[1..ncols(@m)]); 680 // NOTE: @wdeg will be ignored anyway :( 681 @l[3] = list(list("C", @z), list("lp", @wdeg)); 682 kill @z, @m, @wdeg; // since these vars are ring independent! 683 def S = ring(@l); // --MakeInducedSchreyerOrdering(1); 684 kill @l; 685 setring S; // ring with an easy divisibility test ("C, lex") // or not!??? 686 if( @DEBUG ) 687 { 688 "SSinit::NewRing(C,lex)?"; 689 basering; 690 DetailedPrint(basering); 691 } 692 } else 693 { def S = basering; } 697 694 698 695 // Setup the leading syzygy^{-1} module to zero: 699 696 module Z = 0; Z[@RANK] = 0; attrib(Z, "isHomog", intvec(0)); 697 698 if( !@RINGCHANGE ) 699 { 700 if( defined(RES) ) { if( @DEBUG ){ "WARN: killing existing object: RES!"; }; kill RES; } 701 if( defined(MRES) ) { if( @DEBUG ){ "WARN: killing existing object: MRES!"; }; kill MRES; } 702 if( defined(LRES) ) { if( @DEBUG ){ "WARN: killing existing object: LRES!"; }; kill LRES; } 703 if( defined(TRES) ) { if( @DEBUG ){ "WARN: killing existing object: TRES!"; }; kill TRES; } 704 } 700 705 701 706 module MRES = Z; … … 704 709 list LRES; LRES[1] = Z; 705 710 list TRES; TRES[1] = Z; 706 707 def M = imap(@save, M); 708 711 712 if( !defined(M) ) 713 { 714 def M = imap(@save, M); 715 } 716 717 module F = freemodule(@RANK); intvec @V = deg(F[1..@RANK]); kill F; 718 709 719 attrib(M, "isHomog", @V); 710 720 attrib(M, "isSB", 1); 711 721 attrib(M, "degrees", @DEGS); 712 722 713 def LEAD = imap(@save, LEAD); 723 if( !defined(LEAD) ) 724 { 725 def LEAD = imap(@save, LEAD); 726 } 714 727 715 728 attrib(LEAD, "isHomog", @V); 716 729 attrib(LEAD, "isSB", 1); 717 730 718 def TAIL = imap(@save, TAIL); 731 if( !defined(TAIL) ) 732 { 733 def TAIL = imap(@save, TAIL); 734 } 719 735 720 736 if( @DEBUG ) … … 724 740 attrib(M); 725 741 attrib(M, "isHomog"); 726 // DetailedPrint(M);727 742 } 728 743 … … 765 780 } 766 781 767 768 782 if( typeof( attrib(SSinit, "HYBRIDNF") ) == "int" ) 769 783 { … … 773 787 attrib(S, "HYBRIDNF", 0); 774 788 } 775 789 790 // maybe resetting existing ring attributes! 776 791 attrib(S, "DEBUG", @DEBUG); 777 792 attrib(S, "SYZCHECK", @SYZCHECK); … … 2128 2143 } 2129 2144 2145 static proc SRES_minres(SRES SR) 2146 { 2147 def save = basering; 2148 SRES S; 2149 def R = SR.r; S.r = R; 2150 setring R; 2151 S.rsltn = minres(SR.rsltn); // in target ring :( 2152 return (S); 2153 } 2154 2155 2130 2156 // cannot be automatically used via overloading :( 2131 proc SRES_list(SRES SR) 2132 "TODO!" 2133 { 2157 proc SRES_list(def SR) 2158 "USAGE: SRES_list(resolution) 2159 RETURN: list 2160 PURPOSE: convert given resolution to a list 2161 NOTE: result is over basering 2162 SEE ALSO: s_res, resolution 2163 EXAMPLE: example s_res; shows an example 2164 " 2165 { 2166 if( typeof(SR) != "SRES" ) 2167 { 2168 list L = SR; 2169 return (L); 2170 } 2171 2134 2172 def save = basering; 2135 2173 def R = SR.r; 2136 2174 2137 if( 0 ) // ( save == R ) // TODO: not implemented :((( 2138 { 2139 list L = SR.rsltn; 2140 return (L); 2141 } 2175 // if( 0 ) // ( save == R ) // TODO: not implemented :((( 2176 // { list L = SR.rsltn; return (L); } 2142 2177 2143 2178 setring R; 2144 2179 list L = SR.rsltn; 2145 2180 setring save; 2146 return (imap( R, L )); 2147 } 2148 2149 static proc SRES_minres(SRES SR) 2150 { 2151 def save = basering; 2152 SRES S; 2153 def R = SR.r; S.r = R; 2154 setring R; 2155 S.rsltn = minres(SR.rsltn); 2156 return (S); 2181 return (imap( R, L )); 2157 2182 } 2158 2183 2159 2184 static proc loadme() 2160 2185 { 2161 int @DEBUG = 0; // !system("with", "ndebug"); 2162 2163 if( @DEBUG ) 2164 { 2186 int @DEBUG = 0; // !system("with", "ndebug"); // "om_ndebug?: ", system("with", "om_ndebug"); 2187 2188 if( @DEBUG ) { listvar(Syzextra); listvar(Schreyer); listvar(Top); } 2189 2190 if( !defined(Schreyer::ComputeResolution) ) 2191 { 2192 load("syzextra.so"); 2193 2194 if( @DEBUG ){ listvar(Syzextra); } 2195 2196 // exportto(Top, Syzextra::ClearContent); // exportto(Top, Syzextra::ClearDenominators); exportto(Schreyer, Syzextra::noop); 2197 // exportto(Schreyer, Syzextra::leadrawexp); // exportto(Schreyer, Syzextra::ISUpdateComponents); 2198 // exportto(Schreyer, Syzextra::GetAMData);// exportto(Schreyer, Syzextra::SetSyzComp); 2199 // exportto(Schreyer, Syzextra::MakeSyzCompOrdering); // exportto(Schreyer, Syzextra::reduce_syz);// exportto(Schreyer, Syzextra::p_Content); 2200 exportto(Schreyer, Syzextra::DetailedPrint); 2201 exportto(Schreyer, Syzextra::m2_end); 2202 exportto(Schreyer, Syzextra::leadmonomial); 2203 exportto(Schreyer, Syzextra::leadcomp); 2204 exportto(Schreyer, Syzextra::SetInducedReferrence); 2205 exportto(Schreyer, Syzextra::GetInducedData); 2206 exportto(Schreyer, Syzextra::MakeInducedSchreyerOrdering); 2207 exportto(Schreyer, Syzextra::idPrepare); 2165 2208 2166 // "ndebug?: ", system("with", "ndebug"); 2167 // "om_ndebug?: ", system("with", "om_ndebug"); 2168 2169 listvar(Syzextra); 2170 listvar(Schreyer); 2171 listvar(Top); 2172 } 2173 2174 if( !defined(Schreyer::DetailedPrint) ) 2175 { 2176 if( 1 ) 2177 { 2178 /* 2179 if( system("with", "ndebug") ) 2180 { 2181 "Loading the Debug version!"; 2182 } else 2183 { 2184 "Loading the Release version!"; 2185 } 2186 */ 2187 load("syzextra.so"); 2188 2189 if( @DEBUG ) 2190 { 2191 listvar(Syzextra); 2192 } 2193 2194 // exportto(Top, Syzextra::ClearContent); 2195 // exportto(Top, Syzextra::ClearDenominators); 2196 exportto(Schreyer, Syzextra::m2_end); 2197 2198 // export Syzextra; 2199 2200 // exportto(Schreyer, Syzextra::noop); 2201 exportto(Schreyer, Syzextra::DetailedPrint); 2202 exportto(Schreyer, Syzextra::leadmonomial); 2203 exportto(Schreyer, Syzextra::leadcomp); 2204 // exportto(Schreyer, Syzextra::leadrawexp); 2205 // exportto(Schreyer, Syzextra::ISUpdateComponents); 2206 exportto(Schreyer, Syzextra::SetInducedReferrence); 2207 exportto(Schreyer, Syzextra::GetInducedData); 2208 // exportto(Schreyer, Syzextra::GetAMData); 2209 // exportto(Schreyer, Syzextra::SetSyzComp); 2210 exportto(Schreyer, Syzextra::MakeInducedSchreyerOrdering); 2211 // exportto(Schreyer, Syzextra::MakeSyzCompOrdering); 2212 exportto(Schreyer, Syzextra::idPrepare); 2213 // exportto(Schreyer, Syzextra::reduce_syz); 2214 // exportto(Schreyer, Syzextra::p_Content); 2215 2216 exportto(Schreyer, Syzextra::ProfilerStart); exportto(Schreyer, Syzextra::ProfilerStop); 2217 2218 exportto(Schreyer, Syzextra::Tail); 2219 exportto(Schreyer, Syzextra::ComputeLeadingSyzygyTerms); 2220 exportto(Schreyer, Syzextra::Compute2LeadingSyzygyTerms); 2221 exportto(Schreyer, Syzextra::Sort_c_ds); 2222 2223 exportto(Schreyer, Syzextra::FindReducer); 2224 2225 exportto(Schreyer, Syzextra::ReduceTerm); 2226 exportto(Schreyer, Syzextra::TraverseTail); 2227 2228 exportto(Schreyer, Syzextra::SchreyerSyzygyNF); 2229 exportto(Schreyer, Syzextra::ComputeSyzygy); 2230 2231 exportto(Schreyer, Syzextra::ComputeResolution); 2232 2233 exportto(Schreyer, Syzextra::NumberStatsInit); 2234 exportto(Schreyer, Syzextra::NumberStatsPrint); 2235 2236 newstruct("SRES","ring r,resolution rsltn"); // http://www.singular.uni-kl.de/Manual/latest/sing_179.htm#SEC218 2237 // TODO: SSres - return SRESOLUTION? 2238 2209 exportto(Schreyer, Syzextra::ProfilerStart); exportto(Schreyer, Syzextra::ProfilerStop); 2210 exportto(Schreyer, Syzextra::NumberStatsInit); exportto(Schreyer, Syzextra::NumberStatsPrint); 2211 2212 exportto(Schreyer, Syzextra::Tail); 2213 exportto(Schreyer, Syzextra::ComputeLeadingSyzygyTerms); 2214 exportto(Schreyer, Syzextra::Compute2LeadingSyzygyTerms); 2215 exportto(Schreyer, Syzextra::Sort_c_ds); 2216 2217 exportto(Schreyer, Syzextra::FindReducer); 2218 2219 exportto(Schreyer, Syzextra::ReduceTerm); 2220 exportto(Schreyer, Syzextra::TraverseTail); 2221 2222 exportto(Schreyer, Syzextra::SchreyerSyzygyNF); 2223 exportto(Schreyer, Syzextra::ComputeSyzygy); 2224 exportto(Schreyer, Syzextra::ComputeResolution); 2225 2226 // TODO: SSres - return SRESOLUTION? 2227 newstruct("SRES","ring r,resolution rsltn"); // http://www.singular.uni-kl.de/Manual/latest/sing_179.htm#SEC218 2239 2228 // system("install","SRES","string",SRES_string, 1); 2240 system("install","SRES","print",SRES_print, 1); 2241 2242 system("install","SRES","betti",SRES_betti1, 1); // http://www.singular.uni-kl.de/Manual/latest/sing_260.htm#SEC299 2243 system("install","SRES","betti",SRES_betti2, 2); // http://www.singular.uni-kl.de/Manual/latest/sing_260.htm#SEC299 2244 system("install","SRES","minres",SRES_minres, 1); // http://www.singular.uni-kl.de/Manual/latest/sing_344.htm#SEC383 2245 2246 // system("install","SRES","list", SRES_list, 1); // will never work :((( 2247 2248 // TODO: SSsyz? SSYZYGY? // TODO: C/C++ computation for Syzygy? 2249 // newstruct("SSYZ","ring r,module szg"); // http://www.singular.uni-kl.de/Manual/latest/sing_179.htm#SEC218 2250 // system("install","SSYZYGY","string",SSYZYGY_string, 1); 2251 // system("install","SSYZYGY","print",SSYZYGY_print, 1); 2252 // system("install","SSYZYGY","module",SSYZYGY_module, 1); 2253 } 2229 system("install","SRES","print",SRES_print, 1); 2230 system("install","SRES","betti",SRES_betti1, 1); // http://www.singular.uni-kl.de/Manual/latest/sing_260.htm#SEC299 2231 system("install","SRES","betti",SRES_betti2, 2); // http://www.singular.uni-kl.de/Manual/latest/sing_260.htm#SEC299 2232 system("install","SRES","minres",SRES_minres, 1); // http://www.singular.uni-kl.de/Manual/latest/sing_344.htm#SEC383 2233 system("install","SRES","list", SRES_list, 1); // will never work :((( 2254 2234 2255 2235 // exportto(Top, DetailedPrint); 2256 // exportto(Top, GetInducedData); 2257 2258 if( @DEBUG ) 2259 { 2260 listvar(Top); 2261 listvar(Schreyer); 2262 } 2236 // exportto(Top, s_res); // GetInducedData); 2237 2238 if( @DEBUG ) { listvar(Top); listvar(Schreyer); } 2263 2239 } 2264 2240 … … 2270 2246 static proc mod_assure_load() 2271 2247 { 2272 if( !defined( GetInducedData) )2273 { 2274 "ERROR: Sorry but we are missing the dynamic module (syzextra.so)...";2275 $2248 if( !defined(Schreyer::ComputeResolution) ) 2249 { 2250 "ERROR: Sorry but you seems to be missing the necessary dynamic module (syzextra.so)!"; 2251 // $ 2276 2252 // m2_end(666); // :( 2277 2253 } … … 2556 2532 proc s_res(def I, int l) 2557 2533 "USAGE: s_res(ideal/module M, int len) 2558 RETURN: SRES, a blackbox object containing a (part of) Schreyer resolution2534 RETURN: resolution object or SRES 2559 2535 PURPOSE: compute a Schreyer resolution of M of length at most len (see [BMSS]) 2560 2536 NOTE: If given len is zero then nvars(basering) + 1 is used instead. 2561 @* SRES can be printed, treated by betti and minres or converted to list & mapped into the current ring with @code{SRES_list}2562 2537 @* This functions is not related to other helpers from this library. 2563 2538 @* One can switch on computation protocol and statistic (depending on the build) by setting the @code{prot} option. … … 2570 2545 { 2571 2546 int @prot = (find(option(),"prot") != 0) && (defined(NumberStatsInit)) && (defined(NumberStatsPrint)); 2572 def R=SSinit(I); setring R; int @l = size(RES); 2573 SRES ret; ret.r = R; 2547 def @save = basering; 2548 2549 int @RINGCHANGE = 0; 2550 2551 if( typeof( attrib(SSinit, "RINGCHANGE") ) == "int" ) 2552 { 2553 @RINGCHANGE = attrib(SSinit, "@RINGCHANGE"); 2554 } 2555 2556 def R=SSinit(I); 2557 if( @RINGCHANGE ){ setring R; } 2558 2559 int @l = size(RES); 2574 2560 if(@prot){ NumberStatsInit(); } 2575 ret.rsltn = ComputeResolution(RES[@l], LRES[@l], TRES[@l], l);2561 def rsltn = ComputeResolution(RES[@l], LRES[@l], TRES[@l], l); 2576 2562 if(@prot){ NumberStatsPrint("Number statistic for s_res with ComputeResolution"); } 2563 2564 if( !@RINGCHANGE ) 2565 { 2566 return (rsltn); // ret 2567 } 2568 2569 SRES ret; ret.r = R; ret.rsltn = rsltn; 2577 2570 return (ret); 2578 2571 } … … 2581 2574 ring R; 2582 2575 module M = maxideal(1); M; 2583 SRESrs = s_res(M, 0);2576 def rs = s_res(M, 0); 2584 2577 print(rs); 2585 2578 print(betti(rs, 0)); // non-minimal betties … … 2620 2613 @m=rtimer; 2621 2614 if(@PROFILE){ProfilerStop();} 2622 RR=minres(RR); def S=betti(RR,1);@t=rtimer;2615 RR=minres(RR); def S=betti(RR,1);@t=rtimer; 2623 2616 // DetailedPrint(RR,0); print(RR); print(S, "betti"); 2624 2617 SCheck(R);
Note: See TracChangeset
for help on using the changeset viewer.