save GAP output to GAP.log

This commit is contained in:
kalmarek 2018-01-04 10:46:40 +01:00
parent 86cadd0440
commit 122ebe92bf

View File

@ -2,9 +2,11 @@ using JLD
function GAP_code(group_code, dir, R; maxeqns=10_000, infolevel=2) function GAP_code(group_code, dir, R; maxeqns=10_000, infolevel=2)
code = """ code = """
LogTo("$(dir)/GAP.log");
RequirePackage("kbmag"); RequirePackage("kbmag");
SetInfoLevel(InfoRWS, $infolevel); SetInfoLevel(InfoRWS, $infolevel);
MetricBalls := function(rws, R) MetricBalls := function(rws, R)
local l, basis, sizes, i; local l, basis, sizes, i;
l := EnumerateReducedWords(rws, 0, R);; l := EnumerateReducedWords(rws, 0, R);;
@ -53,7 +55,7 @@ end;;
$group_code $group_code
G:= SimplifiedFpGroup(G); # G:= SimplifiedFpGroup(G);
RWS := KBMAGRewritingSystem(G); RWS := KBMAGRewritingSystem(G);
# ResetRewritingSystem(RWS); # ResetRewritingSystem(RWS);
O:=OptionsRecordOfKBMAGRewritingSystem(RWS);; O:=OptionsRecordOfKBMAGRewritingSystem(RWS);;
@ -70,7 +72,7 @@ t := Runtime();
res := MetricBalls(RWS,$(2*R));; res := MetricBalls(RWS,$(2*R));;
Print("Metric-Balls generation: \t", StringTime(Runtime()-t), "\\n"); Print("Metric-Balls generation: \t", StringTime(Runtime()-t), "\\n");
B := res[1];; sizes := res[2];; B := res[1];; sizes := res[2];;
Print(sizes, "\\n"); Print("Sizes of generated Balls: \t", sizes, "\\n");
t := Runtime(); t := Runtime();
pm := ProductMatrix(RWS, B, sizes[$R]);; pm := ProductMatrix(RWS, B, sizes[$R]);;
@ -96,7 +98,7 @@ function GAP_groupcode(S, rels)
code = """ code = """
F := $F; F := $F;
AssignGeneratorVariables(F);; AssignGeneratorVariables(F);;
relations := $rels; relations := $rels;;
G := F/relations; G := F/relations;
""" """
return code return code
@ -111,14 +113,13 @@ function GAP_execute(gap_code, dir)
open(GAP_file, "w") do io open(GAP_file, "w") do io
write(io, gap_code) write(io, gap_code)
end end
run(`gap -q $(GAP_file)`) run(pipeline(`cat $(GAP_file)`, `gap -q`))
end end
function prepare_pm_delta_csv(name, group_code, R; maxeqns=10_000, infolevel=2) function prepare_pm_delta_csv(name, group_code, R; maxeqns=10_000, infolevel=2)
info("Preparing multiplication table using GAP (via kbmag)") info("Preparing multiplication table using GAP (via kbmag)")
gap_code = GAP_code(group_code, name, R, maxeqns=maxeqns, infolevel=infolevel) gap_code = GAP_code(group_code, name, R, maxeqns=maxeqns, infolevel=infolevel)
o = GAP_execute(gap_code, name) GAP_execute(gap_code, name)
return o
end end
function prepare_pm_delta(name, group_code, R; maxeqns=100_000, infolevel=2) function prepare_pm_delta(name, group_code, R; maxeqns=100_000, infolevel=2)