1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
#############################################################################
##
#F StringByFTLCollector . . . . . . . convert an ftl collector into a string
##
InstallMethod( String,
"from-the-left collector",
[ IsFromTheLeftCollectorRep ],
function( coll )
local name, n, S, i, j;
name := ValueOption( "name" );
if name = fail then
name := "ftl";
fi;
# Initialise the collector
n := coll![PC_NUMBER_OF_GENERATORS];
S := ShallowCopy( name );
Append( S, " := FromTheLeftCollector( " );
Append( S, String(n) );
Append( S, " );\n" );
# install power relations
for i in [1..n] do
if IsBound( coll![PC_EXPONENTS][i] ) then
Append( S, "SetRelativeOrder( " );
Append( S, name ); Append( S, ", " );
Append( S, String( i ) ); Append( S, ", " );
Append( S, String( coll![PC_EXPONENTS][i] ) );
Append( S, " );\n" );
Append( S, "SetPower( " );
Append( S, name ); Append( S, ", " );
Append( S, String(i) ); Append( S, ", " );
if IsBound( coll![PC_POWERS][i] ) then
Append( S, String( coll![PC_POWERS][i] ) );
else
Append( S, "[]" );
fi;
Append( S, " );\n" );
fi;
od;
# install conjugate relations
for j in [1..n] do
for i in [1..j-1] do
if IsBound(coll![PC_CONJUGATES][j][i]) then
Append( S, "SetConjugate( " );
Append( S, name ); Append( S, ", " );
Append( S, String(j) ); Append( S, ", " );
Append( S, String(i) ); Append( S, ", " );
Append( S, String( coll![PC_CONJUGATES][j][i] ) );
Append( S, " );\n" );
fi;
od;
od;
for j in [1..n] do
for i in [1..j-1] do
if IsBound(coll![PC_CONJUGATESINVERSE][j][i]) then
Append( S, "SetConjugate( " );
Append( S, name ); Append( S, ", " );
Append( S, String( j) ); Append( S, ", " );
Append( S, String(-i) ); Append( S, ", " );
Append( S, String( coll![PC_CONJUGATESINVERSE][j][i] ) );
Append( S, " );\n" );
fi;
od;
od;
for j in [1..n] do
for i in [1..j-1] do
if IsBound(coll![PC_INVERSECONJUGATES][j][i]) then
Append( S, "SetConjugate( " );
Append( S, name ); Append( S, ", " );
Append( S, String(-j) ); Append( S, ", " );
Append( S, String( i) ); Append( S, ", " );
Append( S, String( coll![PC_INVERSECONJUGATES][j][i] ) );
Append( S, " );\n" );
fi;
od;
od;
for j in [1..n] do
for i in [1..j-1] do
if IsBound(coll![PC_INVERSECONJUGATESINVERSE][j][i]) then
Append( S, "SetConjugate( " );
Append( S, name ); Append( S, ", " );
Append( S, String(-j) ); Append( S, ", " );
Append( S, String(-i) ); Append( S, ", " );
Append( S, String( coll![PC_INVERSECONJUGATESINVERSE][j][i] ) );
Append( S, " );\n" );
fi;
od;
od;
return S;
end );
#############################################################################
##
#F PcpUserInfo
##
BindGlobal( "PcpUserInfo", function()
local str, dir, date, out;
str := "";
dir := Directory( "./" );
out := OutputTextString( str, true );
## get user name
Process( dir, Filename( DirectoriesSystemPrograms(), "whoami" ),
InputTextNone(), out, [] );
## remove trailing newline character
str[ Length(str) ] := '@';
## get hostname name
Process( dir, Filename( DirectoriesSystemPrograms(), "hostname" ),
InputTextNone(), out, [] );
## remove trailing newline character
Unbind( str[ Length(str) ] );
Append( str, ": " );
## get date
Process( dir, Filename( DirectoriesSystemPrograms(), "date" ),
InputTextNone(), out, [] );
CloseStream( out );
return str;
end );
#############################################################################
##
#F FTLCollectorPrintTo( <file>, <name>, <coll> )
##
BindGlobal( "FTLCollectorPrintTo",
function( file, name, coll )
PrintTo( file, "##\n## ", PcpUserInfo(), "##\n" );
AppendTo( file, String( coll : name := name ) );
AppendTo( file, "\n\n" );
end );
#############################################################################
##
#F FTLCollectorAppendTo( <file>, <name>, <coll> )
##
BindGlobal( "FTLCollectorAppendTo",
function( file, name, coll )
AppendTo( file, "##\n## ", PcpUserInfo(), "##\n" );
AppendTo( file, String( coll : name := name ) );
AppendTo( file, "\n\n" );
end );
|