14.3.5 Changing which GAP is used

Use this code to change which GAP interpreter is run. E.g.,
   import sage.interfaces.gap
   sage.interfaces.gap.gap_cmd = "/usr/local/bin/gap"

Author Log:

Module-level Functions

gap_command( [use_workspace_cache=True], [local=True])

gap_console( [use_workspace_cache=True])

gap_reset_workspace( [max_workspace_size=None], [verbose=False])

Call this to completely reset the GAP workspace, which is used by default when SAGE first starts GAP.

The first time you start GAP from SAGE, it saves the startup state of GAP in the file

        $HOME/.sage/gap-workspace
This is useful, since then subsequent startup of GAP is at least 10 times as fast. Unfortunately, if you install any new code for GAP, it won't be noticed unless you explicitly load it, e.g., with gap.load_package("my_package")

The packages sonata, guava, factint, gapdoc, grape, design, toric, and laguna are loaded in all cases before the workspace is saved, if they are available.

gap_version( )

gfq_gap_to_sage( x, F)

Input:

x
- gap finite field element
F
- SAGE finite field
Output: element of F

sage: x = gap('Z(13)')
sage: F = GF(13, 'a')
sage: F(x)
2
sage: F(gap('0*Z(13)'))
0
sage: F = GF(13^2, 'a')
sage: x = gap('Z(13)')
sage: F(x)
2
sage: x = gap('Z(13^2)^3')
sage: F(x)
12*a + 11
sage: F.multiplicative_generator()^3
12*a + 11

Author: David Joyner and William Stein

is_GapElement( x)

reduce_load( )

reduce_load_GAP( )

Class: Gap

class Gap
Interface to the GAP interpreter.

Author: William Stein and David Joyner

Gap( self, [max_workspace_size=None], [maxread=100000], [script_subdirectory=None], [use_workspace_cache=True], [server=None], [server_tmpdir=None], [logfile=None])

Functions: console,$ \,$ cputime,$ \,$ eval,$ \,$ get,$ \,$ help,$ \,$ load_package,$ \,$ save_workspace,$ \,$ set,$ \,$ trait_names,$ \,$ version

eval( self, x, [newlines=False], [strip=True])

Send the code in the string s to the GAP interpreter and return the output as a string.

Input:

s
- string containing GAP code.
newlines
- bool (default: True); if False, remove all backslash-newlines inserted by the GAP output formatter.
strip
- ignored

get( self, var, [use_file=False])

Get the string representation of the variable var.

help( self, s, [pager=True])

Print help on a given topic.

load_package( self, pkg, [verbose=False])

Load the Gap package with the given name.

If loading fails, raise a RuntimeError exception.

set( self, var, value)

Set the variable var to the given value.

Special Functions: __init__,$ \,$ __reduce__,$ \,$ _contains,$ \,$ _continuation_prompt,$ \,$ _equality_symbol,$ \,$ _eval_line,$ \,$ _eval_line_using_file,$ \,$ _execute_line,$ \,$ _false_symbol,$ \,$ _is_true_string,$ \,$ _keyboard_interrupt,$ \,$ _next_var_name,$ \,$ _object_class,$ \,$ _post_interact,$ \,$ _pre_interact,$ \,$ _quit_string,$ \,$ _read_in_file_command,$ \,$ _start,$ \,$ _true_symbol

Class: GapElement

class GapElement

Functions: str,$ \,$ trait_names

Special Functions: __getitem__,$ \,$ __len__,$ \,$ __reduce__,$ \,$ __repr__,$ \,$ _latex_,$ \,$ _matrix_

__len__( self)

sage: v = gap('[1,2,3]'); v
[ 1, 2, 3 ]
sage: len(v)
3

len is also called implicitly by if:

sage: if gap('1+1 = 2'):
...    print "1 plus 1 does equal 2"
1 plus 1 does equal 2

sage: if gap('1+1 = 3'): 
...    print "it is true"
... else:
...    print "it is false"
it is false

_matrix_( self, R)

Return matrix over the (Sage) ring R determined by self, where self should be a Gap matrix.

sage: s = gap("(Z(7)^0)*[[1,2,3],[4,5,6]]"); s
[ [ Z(7)^0, Z(7)^2, Z(7) ], [ Z(7)^4, Z(7)^5, Z(7)^3 ] ]
sage: s._matrix_(GF(7))
[1 2 3]
[4 5 6]

sage: s = gap("[[1,2], [3/4, 5/6]]"); s
[ [ 1, 2 ], [ 3/4, 5/6 ] ]
sage: m = s._matrix_(QQ); m
[  1   2]
[3/4 5/6]            
sage: parent(m)
Full MatrixSpace of 2 by 2 dense matrices over Rational Field

sage: s = gap('[[Z(16),Z(16)^2],[Z(16)^3,Z(16)]]')
sage: s._matrix_(GF(16,'a'))
[  a a^2]
[a^3   a]

Class: GapFunction

class GapFunction

Special Functions: _sage_doc_

Class: GapFunctionElement

class GapFunctionElement

Special Functions: _sage_doc_

See About this document... for information on suggesting changes.