Goto Chapter: Top 1 2 3 4 5 6 7 8 Bib Ind
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 

7 Various other functions
 7.1 Operations on folders
 7.2 File operations
 7.3 LaTeX strings
 7.4 Applicable Methods
 7.5 Conversion to Magma string

7 Various other functions

7.1 Operations on folders

7.1-1 FindMatchingFiles
‣ FindMatchingFiles( pkg, dirs, extns )( function )
‣ CreateDirIfMissing( str )( function )

These functions have been copied from package AutoDoc where they were named AutoDoc_FindMatchingFiles and AutoDoc_CreateDirIfMissing (the originals will continue to exist).

FindMatchingFiles scans the given (by name) subdirectories of a package directory for files with one of the given extensions, and returns the corresponding filenames, as paths relative to the package directory.

CreateDirIfMissing checks whether the given directory exists and, if not, attempts to create it. In either case true is returned.

Warning: this function relies on the undocumented library function CreateDir, so use it with caution.


gap> dir := DirectoriesPackageLibrary( "example", "tst" );
[ dir("/Applications/gap/gap4r9/pkg/Example-4.1.1/tst/") ]
gap> FindMatchingFiles( dir, [ "" ], [ "g", "tst" ] );            
[ "hello.tst", "recipe.tst", "testall.g" ]
gap> dir := DirectoriesPackageLibrary( "utils" );         
[ dir("/Applications/gap/my-dev/pkg/utils/lib/") ]
gap> FindMatchingFiles( dir, [ "" ], [ "gd", "gi" ] ); 
[ "app-meth.gd", "app-meth.gi", "files.gd", "files.gi", "groups.gd", 
  "groups.gi", "latex.gd", "latex.gi", "lists.gd", "lists.gi", "magma.gd", 
  "magma.gi", "maps.gd", "maps.gi", "number.gd", "number.gi", "print.gd", 
  "print.gi", "record.gd", "record.gi", "start.gd", "string.gd", "string.gi" ]
gap> dirname := Filename( dir[1], "tmp/" );
"/Applications/gap/my-dev/pkg/utils/lib/tmp/"
gap> CreateDirIfMissing( dirname );
true
gap> filename := Concatenation( dirname, "hello.log" );
"/Applications/gap/my-dev/pkg/utils/lib/tmp/hello.log"
gap> LogTo( filename );
gap> Print( "hello\n" );
hello
gap> LogTo();                                    
gap> FindMatchingFiles( dir, [ "tmp" ], [ "log" ] );
[ "tmp/hello.log" ]

7.2 File operations

7.2-1 Log2HTML
‣ Log2HTML( filename )( function )

This function has been transferred from package RCWA.

This function converts the GAP logfile filename to HTML. It appears that the logfile should be in your current directory. The extension of the input file must be *.log. The name of the output file is the same as the one of the input file except that the extension *.log is replaced by *.html. There is a sample CSS file in utils/doc/gaplog.css, which you can adjust to your taste.


gap> LogTo( "log2html.log" );
gap> dir := DirectoriesPackageLibrary( "utils", "tst" );;
gap> FindMatchingFiles( dir, [ "" ], [ "tst" ] );
[ "groups.tst", "lists.tst", "number.tst", "others.tst", "print.tst", 
  "record.tst", "string.tst" ]
gap> LogTo(); 
gap> Log2HTML( "log2html.log" );     

7.3 LaTeX strings

7.3-1 IntOrOnfinityToLaTeX
‣ IntOrOnfinityToLaTeX( n )( function )

This function has been transferred from package ResClasses.

IntOrInfinityToLaTeX(n) returns the LaTeX string for n.


gap> IntOrInfinityToLaTeX( 10^3 );
"1000"
gap> IntOrInfinityToLaTeX( infinity );
"\\infty"

7.3-2 LaTeXStringFactorsInt
‣ LaTeXStringFactorsInt( n )( function )

This function has been transferred from package RCWA.

It returns the prime factorization of the integer n as a string in LaTeX format.


gap> LaTeXStringFactorsInt( Factorial(12) );
"2^{10} \\cdot 3^5 \\cdot 5^2 \\cdot 7 \\cdot 11"

7.4 Applicable Methods

The function PrintApplicableMethod, which was included in versions from 0.41 to 0.58, has been removed since it was considered superfluous. The example shows how to print out a function.


gap> ApplicableMethod( IsCyclic, [ Group((1,2,3),(4,5)) ], 1, 1 );
#I  Searching Method for IsCyclic with 1 arguments:
#I  Total: 7 entries
#I  Method 4: ``IsCyclic'' at /Applications/gap/gap4r9/lib/grp.gi:30 , value: 
36
function( G ) ... end
gap> Print( last );
function ( G )
    if Length( GeneratorsOfGroup( G ) ) = 1 then
        return true;
    else
        TryNextMethod();
    fi;
    return;
end
gap> ApplicableMethod( IsCyclic, [ Group((1,2,3),(4,5)) ], 0, 3 );
function( <1 unnamed arguments> ) ... end
gap> Print( last );                                               
function ( <<arg-1>> )
    <<compiled GAP code from GAPROOT/lib/oper1.g:578>>
end

7.5 Conversion to Magma string

7.5-1 ConvertToMagmaInputString
‣ ConvertToMagmaInputString( arg )( function )

The function ConvertToMagmaInputString( obj [, str] ) attempts to output a string s which can be read into Magma [BCP97] so as to produce the same group in that computer algebra system. In the second form the user specifies the name of the resulting object, so that the output string has the form "str := ...". When obj is a permutation group, the operation PermGroupToMagmaFormat(obj) is called. This function has been taken from other.gi in the main library where it was called MagmaInputString. When obj is a pc-group, the operation PcGroupToMagmaFormat(obj) is called. This function was private code of Max Horn. When obj is a matrix group over a finite field, the operation MatrixGroupToMagmaFormat(obj) is called. This function is a modification of private code of Frank L├╝beck.

Hopefully code for other types of group will be added in due course.

These functions should be considered experimental, and more testing is desirable.


gap> ConvertToMagmaInputString( Group( (1,2,3,4,5), (3,4,5) ) );
"PermutationGroup<5|(1,2,3,4,5),\n(3,4,5)>;\n"
gap> ConvertToMagmaInputString( Group( (1,2,3,4,5) ), "c5" );        
"c5:=PermutationGroup<5|(1,2,3,4,5)>;\n"
gap> ConvertToMagmaInputString( DihedralGroup( IsPcGroup, 10 ) );
"PolycyclicGroup< f1,f2 |\nf1^2,\nf2^5,\nf2^f1 = f2^4\n>;\n"
gap> M := GL(2,5);;  Size(M); 
480
gap> s1 := ConvertToMagmaInputString( M );
"F := GF(5);\nP := GL(2,F);\ngens := [\nP![2,0,0,1],\nP![4,1,4,0]\n];\nsub<P |\
 gens>;\n"
gap> Print( s1 );
F := GF(5);
P := GL(2,F);
gens := [
P![2,0,0,1],
P![4,1,4,0]
];
sub<P | gens>;
gap> n1 := [ [ Z(9)^0, Z(9)^0 ], [ Z(9)^0, Z(9) ] ];;
gap> n2 := [ [ Z(9)^0, Z(9)^3 ], [ Z(9)^4, Z(9)^2 ] ];;
gap> N := Group( n1, n2 );;  Size( N );
5760
gap> s2 := ConvertToMagmaInputString( N, "gpN" );;
gap> Print( s2 );
F := GF(3^2);
P := GL(2,F);
w := PrimitiveElement(F);
gens := [
P![ 1, 1, 1,w^1],
P![ 1,w^3, 2,w^2]
];
gpN := sub<P | gens>;

 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 
Goto Chapter: Top 1 2 3 4 5 6 7 8 Bib Ind

generated by GAPDoc2HTML