diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 886e5aa9..837ba41c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: image: [gapsystem/gap-docker, gapsystem/gap-docker-master] - os: [ ubuntu-18.04, ubuntu-20.04, ubuntu-latest ] + os: [ ubuntu-22.04, ubuntu-20.04, ubuntu-latest ] runs-on: ${{ matrix.os }} container: image: ${{ matrix.image }} diff --git a/TopcomInterface/README.md b/TopcomInterface/README.md index 1b50ce68..14e29ecf 100644 --- a/TopcomInterface/README.md +++ b/TopcomInterface/README.md @@ -1,5 +1,5 @@ # TopcomInterface -A `Gap4`-package which provides an interface to the software `topcom` (http://www.rambau.wm.uni-bayreuth.de/TOPCOM/). +A `Gap4`-package which provides an interface to the software `topcom` (http://www.rambau.wm.uni-bayreuth.de/TOPCOM/). This interface requires `topcom` version 1.1.2. It may or may not work with newer version. Communication with older version is most likely not possibly with this software. ## Installation diff --git a/TopcomInterface/examples/examples.g b/TopcomInterface/examples/examples.g index 49984c43..c069b61e 100644 --- a/TopcomInterface/examples/examples.g +++ b/TopcomInterface/examples/examples.g @@ -29,61 +29,63 @@ chiro := Concatenation( points2chiro( rays ); #! "3,2:+-+[]" chiro2dual( chiro ); -#! "12,8:0++----++-+--+-++--++--+---++-+++---+--++--+---++-++++-++--+++--\ -#! +-++-++--++-++---+--+++--+--++---++-+--+---++---++-+--+--++-+++--++-++\ -#! ---+--+++--+--++---++-+--+---++---++-+--+--++-++++--+++--+-++-++--+--+\ -#! --+--+-++--+--+++-++---++-++--+++--+-++-+++--+++--+-++-++--+----++---+\ -#! +-+--+--++-++-++-+++--++---++-+--+--++-++-++-+++-++-++---++--+--+++-++\ -#! ---++---++---++-+--+---++---++-+--+--++-++++--+++--+-++-++--+--+--+---\ -#! ++--+++--+-++-++--+--+--+---+--+--++--++---++-+--+-+--+--+--+----++-++\ -#! ---++-++---" +#! "12,8:+--+--+-+--+-++-+-+++--+--0+++-+--+-+-+----+-+++-+--+-+++-+--++-+-++--+-\ +#! +---++-+++-+-++-+---+-++--+-++-+-0++++--++---++-++-++-+-+-++++-+-----+--+-++++\ +#! +--++----+-+++++--++---++-++++-+--0-++--+++--++-+++---++-+--++-+-++-+-+--+--+-\ +#! -+-++-++--+++---+-++-++--+++--++-++0--+-+--++--+-+--++-+++-+-+++--+-+--++--+-+\ +#! --++-+++-+-+++-++-++--+-+--+-+-++-+-0+++--+++-++++--++++-+++-++++--++++-++--+-\ +#! ---+----++----+--++-+++++-+++--+----+0-+-++-++--+--+--+---+--+--++--++---++-+-\ +#! -+-+--+--+--+----++-++---++-++---" chiro2circuits( points2chiro( rays ) ); -#! "3,2:[[[0,1,2],[]]]" +#! [ [ [ 0, 1, 2 ], [ ] ] ] chiro2cocircuits( points2chiro( rays ) ); -#! "3,2:[[[0],[1]][[1],[2]][[0],[2]]]" +#! "3,2:[[[1],[2]][[0],[2]][[0],[1]]]" result := cocircuits2facets( chiro2cocircuits( chiro ) ); #! "" points2facets( rays ); #! "3,2:[]" points2nflips( rays ); -#! 3 +#! 0 points2flips( rays ); -#! "[3,2:[[[0,1,2],[]]->0]]" +#! "[3,2:[]]" chiro2placingtriang( chiro ); #! [ [ [ 0, 1, 2, 3 ], [ 1, 2, 3, 4 ], [ 0, 1, 3, 4 ], [ 0, 1, 2, 4 ], -#! [ 0, 2, 3, 5 ], [ 0, 3, 4, 6 ], [ 0, 2, 4, 6 ], [ 0, 3, 5, 6 ], -#! [ 0, 2, 5, 6 ], [ 2, 3, 4, 7 ], [ 2, 3, 5, 7 ], [ 3, 4, 7, 8 ], -#! [ 2, 4, 7, 8 ], [ 3, 5, 7, 8 ], [ 2, 5, 7, 8 ], [ 3, 4, 8, 9 ], -#! [ 2, 4, 8, 9 ], [ 3, 5, 8, 9 ], [ 2, 5, 8, 9 ], [ 3, 4, 6, 10 ], -#! [ 2, 4, 6, 10 ], [ 3, 5, 6, 10 ], [ 2, 5, 6, 10 ] ] ] +#!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, 1, 3, 4 ], [ 0, 1, 2, 4 ], +#! [ 0, 2, 3, 5 ], [ 2, 3, 4, 5 ], [ 0, 2, 4, 6 ], [ 0, 2, 5, 6 ], +#! [ 3, 4, 5, 6 ], [ 0, 3, 4, 7 ], [ 0, 3, 5, 7 ], [ 4, 5, 6, 7 ], +#! [ 3, 5, 6, 7 ], [ 3, 4, 6, 7 ], [ 0, 4, 6, 8 ], [ 0, 5, 6, 8 ], +#! [ 0, 4, 7, 8 ], [ 0, 5, 7, 8 ], [ 2, 4, 5, 9 ], [ 2, 4, 6, 9 ], +#! [ 4, 6, 8, 9 ], [ 5, 6, 8, 9 ], [ 4, 7, 8, 9 ], [ 5, 7, 8, 9 ], +#! [ 2, 5, 6, 10 ], [ 2, 6, 9, 10 ], [ 4, 7, 9, 10 ], [ 5, 7, 9, 10 ], +#! [ 4, 5, 7, 11 ], [ 2, 5, 9, 11 ], [ 2, 5, 10, 11 ], [ 4, 7, 10, 11 ] ] ] points2finetriang( rays ); #! [ [ [ 0, 1 ], [ 1, 2 ], [ 0, 2 ] ] ] chiro2triangs( points2chiro( rays ) ); -#! "T[0]:=[0->3,2:[[0,1],[1,2],[0,2]]];T[1]:=[1->3,2:[]];" +#! [ [ [ 0, 1 ], [ 0, 2 ], [ 1, 2 ] ] ] points2triangs( rays ); -#! "T[0]:=[0->3,2:[[0,1],[1,2],[0,2]]];T[1]:=[1->3,2:[]];" +#! [ [ [ 0, 1 ], [ 0, 2 ], [ 1, 2 ] ] ] chiro2ntriangs( points2chiro( rays ) ); -#! 2 +#! 1 points2ntriangs( rays ); -#! 2 +#! 1 chiro2finetriangs( points2chiro( rays ) ); -#! "T[0]:=[0->3,2:[[0,1],[1,2],[0,2]]];T[1]:=[1->3,2:[]];" +#! [ [ [ 0, 1 ], [ 0, 2 ], [ 1, 2 ] ] ] points2finetriang( rays ); #! [ [ [ 0, 1 ], [ 1, 2 ], [ 0, 2 ] ] ] chiro2nfinetriangs( points2chiro( rays ) ); -#! 2 +#! 1 points2nfinetriangs( rays ); -#! 2 +#! 1 chiro2alltriangs( points2chiro( rays ) ); #! [ [ [ 0, 1 ], [ 0, 2 ], [ 1, 2 ] ] ] points2alltriangs( rays ); @@ -111,5 +113,5 @@ rays2 := [ [0,0,1], [1,0,1], [2,0,1], [0,1,1], sample_triang2 := [ [2,1,0,5,4,3,8,7,6], [0,3,6,1,4,7,2,5,8] ]; #! [ [ 2, 1, 0, 5, 4, 3, 8, 7, 6 ], [ 0, 3, 6, 1, 4, 7, 2, 5, 8 ] ] points2ntriangs( rays2, sample_triang2, [] ); -#! 69 +#! 387 #! @EndExample diff --git a/TopcomInterface/gap/Functions.gi b/TopcomInterface/gap/Functions.gi index 4dbf7148..c8581caf 100644 --- a/TopcomInterface/gap/Functions.gi +++ b/TopcomInterface/gap/Functions.gi @@ -88,7 +88,7 @@ InstallMethod( chiro2circuits, [ IsString, IsList, IsList ], function( input1, input2, options_list ) - local topcomDirectory, result; + local topcomDirectory, result, substrings; # find the topcom binary topcomDirectory := FindTopcomDirectory( ); @@ -100,9 +100,13 @@ InstallMethod( chiro2circuits, input2, options_list ); - # finally evaluate the output - return result; - + # TODO Further processing necessary due to changed output of topcom + # TODO Further processing necessary due to changed output of topcom + + # Split at every occurance of ":" + substrings := SplitString(result, ':' ); + return List( [ 2 .. Length(substrings) ], i -> EvalString( List( [ 3 .. Length( substrings[ i ] ) ], j -> substrings[ i ][ j ] ) ) ); + end ); @@ -418,7 +422,7 @@ InstallMethod( chiro2triangs, [ IsString, IsList, IsList ], function( input1, input2, options_list ) - local topcomDirectory, result; + local topcomDirectory, result, substrings; # find the topcom binary topcomDirectory := FindTopcomDirectory( ); @@ -430,8 +434,12 @@ InstallMethod( chiro2triangs, input2, options_list ); - # finally evaluate the output - return result; + # TODO Further processing necessary due to changed output of topcom + # TODO Further processing necessary due to changed output of topcom + + # Split at every occurance of ":" + substrings := SplitString(result, ':' ); + return List( [ 2 .. Length(substrings) ], i -> EvalString( List( [ 3 .. Length( substrings[ i ] ) ], j -> substrings[ i ][ j ] ) ) ); end ); @@ -451,7 +459,7 @@ InstallMethod( points2triangs, [ IsList, IsList, IsList ], function( input1, input2, options_list ) - local topcomDirectory, result; + local topcomDirectory, result, substrings; # find the topcom binary topcomDirectory := FindTopcomDirectory( ); @@ -463,8 +471,12 @@ InstallMethod( points2triangs, input2, options_list ); - # finally evaluate the output - return result; + # TODO Further processing necessary due to changed output of topcom + # TODO Further processing necessary due to changed output of topcom + + # Split at every occurance of ":" + substrings := SplitString(result, ':' ); + return List( [ 2 .. Length(substrings) ], i -> EvalString( List( [ 3 .. Length( substrings[ i ] ) ], j -> substrings[ i ][ j ] ) ) ); end ); @@ -550,7 +562,7 @@ InstallMethod( chiro2finetriangs, [ IsString, IsList, IsList ], function( input1, input2, options_list ) - local topcomDirectory, result; + local topcomDirectory, result, substrings; # find the topcom binary topcomDirectory := FindTopcomDirectory( ); @@ -562,9 +574,13 @@ InstallMethod( chiro2finetriangs, input2, options_list ); - # finally evaluate the output - return result; - + # TODO Further processing necessary due to changed output of topcom + # TODO Further processing necessary due to changed output of topcom + + # Split at every occurance of ":" + substrings := SplitString(result, ':' ); + return List( [ 2 .. Length(substrings) ], i -> EvalString( List( [ 3 .. Length( substrings[ i ] ) ], j -> substrings[ i ][ j ] ) ) ); + end ); @@ -682,7 +698,7 @@ InstallMethod( chiro2alltriangs, [ IsString, IsList, IsList ], function( input1, input2, options_list ) - local topcomDirectory, result; + local topcomDirectory, result, substrings; # find the topcom binary topcomDirectory := FindTopcomDirectory( ); @@ -693,10 +709,14 @@ InstallMethod( chiro2alltriangs, input1, input2, options_list ); - - # finally evaluate the output - return EvalString( Concatenation( "[", result, "]" ) ); - + + # TODO Further processing necessary due to changed output of topcom + # TODO Further processing necessary due to changed output of topcom + + # Split at every occurance of ":" + substrings := SplitString(result, ':' ); + return List( [ 2 .. Length(substrings) ], i -> EvalString( List( [ 3 .. Length( substrings[ i ] ) ], j -> substrings[ i ][ j ] ) ) ); + end ); @@ -715,7 +735,7 @@ InstallMethod( points2alltriangs, [ IsList, IsList, IsList ], function( input1, input2, options_list ) - local topcomDirectory, result; + local topcomDirectory, result, substrings; # find the topcom binary topcomDirectory := FindTopcomDirectory( ); @@ -726,10 +746,14 @@ InstallMethod( points2alltriangs, input1, input2, options_list ); - - # finally evaluate the output - return EvalString( Concatenation( "[", result, "]" ) ); - + + # TODO Further processing necessary due to changed output of topcom + # TODO Further processing necessary due to changed output of topcom + + # Split at every occurance of ":" + substrings := SplitString(result, ':' ); + return List( [ 2 .. Length(substrings) ], i -> EvalString( List( [ 3 .. Length( substrings[ i ] ) ], j -> substrings[ i ][ j ] ) ) ); + end ); @@ -814,7 +838,7 @@ InstallMethod( chiro2allfinetriangs, [ IsString, IsList, IsList ], function( input1, input2, options_list ) - local topcomDirectory, result; + local topcomDirectory, result, substrings; # find the topcom binary topcomDirectory := FindTopcomDirectory( ); @@ -826,9 +850,13 @@ InstallMethod( chiro2allfinetriangs, input2, options_list ); - # finally evaluate the output - return EvalString( Concatenation( "[", result, "]" ) ); - + # TODO Further processing necessary due to changed output of topcom + # TODO Further processing necessary due to changed output of topcom + + # Split at every occurance of ":" + substrings := SplitString(result, ':' ); + return List( [ 2 .. Length(substrings) ], i -> EvalString( List( [ 3 .. Length( substrings[ i ] ) ], j -> substrings[ i ][ j ] ) ) ); + end ); @@ -847,7 +875,7 @@ InstallMethod( points2allfinetriangs, [ IsList, IsList, IsList ], function( points, ref_triangulation, options_list ) - local topcomDirectory, result; + local topcomDirectory, result, substrings; # find the topcom binary topcomDirectory := FindTopcomDirectory( ); @@ -858,9 +886,13 @@ InstallMethod( points2allfinetriangs, points, ref_triangulation, options_list ); - - # finally evaluate the output - return EvalString( Concatenation( "[", result, "]" ) ); + + # TODO Further processing necessary due to changed output of topcom + # TODO Further processing necessary due to changed output of topcom + + # Split at every occurance of ":" + substrings := SplitString(result, ':' ); + return List( [ 2 .. Length(substrings) ], i -> EvalString( List( [ 3 .. Length( substrings[ i ] ) ], j -> substrings[ i ][ j ] ) ) ); end ); diff --git a/TopcomInterface/gap/Tools.gi b/TopcomInterface/gap/Tools.gi index df9693e2..7179a3cc 100644 --- a/TopcomInterface/gap/Tools.gi +++ b/TopcomInterface/gap/Tools.gi @@ -74,7 +74,9 @@ InstallMethod( ExecuteTopcomForPoints, [ IsDirectory, IsString, IsList, IsList, IsList ], function( topcomDirectory, name_of_binary, input1, input2, options_list ) - local topcomBinary, output_string, output, input_string, input, options, supported_options, i, trias; + local topcomBinary, output_string, output, input, input_string, tmp_file_name, tmp_file, options, supported_options, i, trias; + + #input, options, supported_options, i, trias; # setup filename for this file topcomBinary := Filename( topcomDirectory, name_of_binary ); @@ -86,9 +88,16 @@ InstallMethod( ExecuteTopcomForPoints, output_string := ""; output := OutputTextString( output_string, true ); - # prepare input_stream to launch topcom + # write temporary file with instructions on what to compute + tmp_file_name := Filename( topcomDirectory, "input_file.dat" ); + tmp_file := OutputTextFile( tmp_file_name, false ); input_string := Concatenation( String( input1 ), " ", String( input2 )," " ); - input := InputTextString( input_string ); + RemoveCharacters(input_string, " \n\t\r"); + AppendTo( tmp_file, input_string ); + CloseStream( tmp_file ); + + # prepare input_stream + input := InputTextFile(tmp_file_name); # introduce the options currently supported by topcom and this interface supported_options := [ "checktriang", "flipdeficiency", "heights", "noinsertion", @@ -101,14 +110,20 @@ InstallMethod( ExecuteTopcomForPoints, fi; od; - # prepare options to be handed to topcom - options := ""; - for i in [ 1 .. Length( options_list ) ] do - options := Concatenation( options, "--", String( options_list[ i ] ), " " ); - od; - # execute topcom - Process( DirectoryCurrent(), topcomBinary, input, output, [ options ] ); + if Length(options_list) = 0 then + # no options - execute directly + Process( DirectoryCurrent(), topcomBinary, input, output, [ ] ); + else + # prepare options + options := ""; + for i in [ 1 .. Length( options_list ) -1 ] do + options := Concatenation( options, "--", String( options_list[ i ] ), " " ); + od; + options := Concatenation( options, "--", String( options_list[ Length( options_list ) ] ) ); + # and execute + Process( DirectoryCurrent(), topcomBinary, input, output, [ options ] ); + fi; # now process the triangulations output_string := ReplacedString( output_string, "}\n{", "],[" ); @@ -116,6 +131,9 @@ InstallMethod( ExecuteTopcomForPoints, output_string := ReplacedString( output_string, "}", "]" ); RemoveCharacters( output_string, "\n" ); + # remove the temporary file + RemoveFile(tmp_file_name); + # finally return the result return output_string; @@ -127,7 +145,7 @@ InstallMethod( ExecuteTopcomForChiro, [ IsDirectory, IsString, IsString, IsList, IsList ], function( topcomDirectory, name_of_binary, input1, input2, options_list ) - local topcomBinary, output_string, output, input_string, input, options, supported_options, i, trias; + local topcomBinary, output_string, output, input, input_string, tmp_file_name, tmp_file, options, supported_options, i, trias; # setup filename for this file topcomBinary := Filename( topcomDirectory, name_of_binary ); @@ -139,9 +157,16 @@ InstallMethod( ExecuteTopcomForChiro, output_string := ""; output := OutputTextString( output_string, true ); - # prepare input_stream to launch topcom - input_string := Concatenation( input1, " ", String( input2 )," " ); - input := InputTextString( input_string ); + # write temporary file with instructions on what to compute + tmp_file_name := Filename( topcomDirectory, "input_file.dat" ); + tmp_file := OutputTextFile( tmp_file_name, false ); + input_string := Concatenation( String( input1 ), " ", String( input2 )," " ); + RemoveCharacters(input_string, " \n\t\r"); + AppendTo( tmp_file, input_string ); + CloseStream( tmp_file ); + + # prepare input_stream + input := InputTextFile(tmp_file_name); # introduce the options currently supported by topcom and this interface supported_options := [ "checktriang", "flipdeficiency", "heights", "noinsertion", @@ -154,14 +179,20 @@ InstallMethod( ExecuteTopcomForChiro, fi; od; - # prepare options to be handed to topcom - options := ""; - for i in [ 1 .. Length( options_list ) ] do - options := Concatenation( options, "--", String( options_list[ i ] ), " " ); - od; - # execute topcom - Process( DirectoryCurrent(), topcomBinary, input, output, [ options ] ); + if Length(options_list) = 0 then + # no options - execute directly + Process( DirectoryCurrent(), topcomBinary, input, output, [ ] ); + else + # prepare options + options := ""; + for i in [ 1 .. Length( options_list ) -1 ] do + options := Concatenation( options, "--", String( options_list[ i ] ), " " ); + od; + options := Concatenation( options, "--", String( options_list[ Length( options_list ) ] ) ); + # and execute + Process( DirectoryCurrent(), topcomBinary, input, output, [ options ] ); + fi; # now process the triangulations output_string := ReplacedString( output_string, "}\n{", "],[" ); diff --git a/TopcomInterface/makefile b/TopcomInterface/makefile index f6ff3f40..817df6b4 100644 --- a/TopcomInterface/makefile +++ b/TopcomInterface/makefile @@ -13,7 +13,7 @@ docclean: (cd doc ; ./clean) install: uninstall - curl -sS https://www.wm.uni-bayreuth.de/de/team/rambau_joerg/TOPCOM-Downloads/TOPCOM-0_17_8.tgz > Topcom.tgz + curl -sS https://www.wm.uni-bayreuth.de/de/team/rambau_joerg/TOPCOM-Downloads/TOPCOM-1_1_2.tgz > Topcom.tgz tar -xf Topcom.tgz rm Topcom.tgz mv topcom* topcom diff --git a/makefile b/makefile index 8ccc97b0..1774049a 100644 --- a/makefile +++ b/makefile @@ -2,8 +2,7 @@ all: doc test .PHONY: test clean install uninstall -clean: - clean_all +clean: clean_all install: uninstall ( cd cohomCalgInterface; make install; cd .. )