import sage.interfaces.gap sage.interfaces.gap.gap_cmd = "/usr/local/bin/gap"
Author Log:
Module-level Functions
| [use_workspace_cache=True], [local=True]) |
| [use_workspace_cache=True]) |
Spawn a new GAP command-line session.
sage: gap.console() #not tested GAP4, Version: 4.4.10 of 02-Oct-2007, x86_64-unknown-linux-gnu-gcc gap>
| [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
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.
| ) |
Returns the version of GAP being used.
sage: gap_version() '4.4.10'
| x, F) |
Input:
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
| x) |
Returns True if x is a GapElement.
sage: is_GapElement(gap(2)) True sage: is_GapElement(2) False
| ) |
Returns an invalid GAP element. Note that this is the object returned when a GAP element is unpickled.
sage: from sage.interfaces.gap import reduce_load sage: reduce_load() (invalid object -- defined in terms of closed session) sage: loads(dumps(gap(2))) (invalid object -- defined in terms of closed session)
| ) |
Returns the GAP interface object definedin sage.interfaces.gap.
sage: from sage.interfaces.gap import reduce_load_GAP sage: reduce_load_GAP() Gap
Class: Gap
Author: William Stein and David Joyner
| self, [max_workspace_size=None], [maxread=100000], [script_subdirectory=None], [use_workspace_cache=True], [server=None], [server_tmpdir=None], [logfile=None]) |
sage: gap == loads(dumps(gap)) True
Functions: console,
cputime,
eval,
get,
help,
load_package,
save_workspace,
set,
trait_names,
unbind,
version
| self) |
Spawn a new GAP command-line session.
sage: gap.console() #not tested GAP4, Version: 4.4.10 of 02-Oct-2007, x86_64-unknown-linux-gnu-gcc gap>
| self, [t=None]) |
Returns the amount of CPU time that the GAP session has used. If t is not None, then it returns the difference between the current CPU time and t.
sage: t = gap.cputime() sage: t #random 0.13600000000000001 sage: gap.Order(gap.SymmetricGroup(5)) 120 sage: gap.cputime(t) #random 0.059999999999999998
| 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:
sage: gap.eval('2+2')
'4'
| self, var, [use_file=False]) |
Get the string representation of the variable var.
sage: gap.set('x', '2')
sage: gap.get('x')
'2'
| self, s, [pager=True]) |
Print help on a given topic.
sage: print gap.help('SymmetricGroup', pager=False)
Basic Groups _____________________________________________ Group Libraries
...
| self, pkg, [verbose=False]) |
Load the Gap package with the given name.
If loading fails, raise a RuntimeError exception.
| self, var, value) |
Set the variable var to the given value.
sage: gap.set('x', '2')
sage: gap.get('x')
'2'
| self) |
sage: c = gap.trait_names() sage: len(c) > 100 True sage: 'Order' in c True
| self, var) |
Clear the variable named var.
sage: gap.set('x', '2')
sage: gap.get('x')
'2'
sage: gap.unbind('x')
sage: gap.get('x')
Traceback (most recent call last):
...
RuntimeError: Gap produced error output
Variable: 'x' must have a value
...
| self) |
Returns the version of GAP being used.
sage: gap.version() '4.4.10'
Special Functions: __init__,
__reduce__,
_contains,
_continuation_prompt,
_equality_symbol,
_eval_line,
_eval_line_using_file,
_execute_line,
_false_symbol,
_function_class,
_function_element_class,
_keyboard_interrupt,
_next_var_name,
_object_class,
_post_interact,
_pre_interact,
_quit_string,
_read_in_file_command,
_start,
_true_symbol
| self) |
sage: gap.__reduce__() (<function reduce_load_GAP at 0x...>, ()) sage: f, args = _ sage: f(*args) Gap
| self, v1, v2) |
sage: Integers = gap('Integers')
sage: two = gap(2)
sage: gap._contains(two.name(), Integers.name())
True
sage: 2 in gap('Integers')
True
| self) |
Returns the continuation prompt in GAP.
sage: gap._continuation_prompt() '> '
| self) |
Returns the symbol for equality in GAP.
sage: gap._equality_symbol() '=' sage: gap(2) == gap(2) True
| self, line, [allow_use_file=True], [wait_for_prompt=True]) |
sage: gap._eval_line('2+2;')
'4'
| self) |
Returns the symbol for falsity in GAP.
sage: gap._false_symbol() 'false' sage: gap(2) == gap(3) False
| self) |
Returns the GapFunction class.
sage: gap._function_class() <class 'sage.interfaces.gap.GapFunction'>
sage: type(gap.Order) <class 'sage.interfaces.gap.GapFunction'>
| self) |
Returns the GapFunctionElement class.
sage: gap._function_element_class() <class 'sage.interfaces.gap.GapFunctionElement'> sage: type(gap.SymmetricGroup(4).Order) <class 'sage.interfaces.gap.GapFunctionElement'>
| self) |
Returns the next unused variable name.
sage: g = Gap() sage: g._next_var_name() '$sage1' sage: g(2)^2 4 sage: g._next_var_name() '$sage5'
| self) |
Returns the GapElement class.
sage: gap._object_class() <class 'sage.interfaces.gap.GapElement'> sage: type(gap(2)) <class 'sage.interfaces.gap.GapElement'>
| self) |
sage: gap._pre_interact() sage: gap._post_interact()
| self) |
sage: gap._pre_interact() sage: gap._post_interact()
| self) |
Returns the string used to quit GAP.
sage: gap._quit_string() 'quit'
sage: g = Gap() sage: a = g(2); g.is_running() True sage: g.quit() sage: g.is_running() False
| self, filename) |
Returns the command use to read in a file in GAP.
sage: gap._read_in_file_command('test')
'Read("test");'
sage: filename = tmp_filename()
sage: f = open(filename, 'w')
sage: f.write('xx := 22;
')
sage: f.close()
sage: gap.read(filename)
sage: gap.get('xx').strip()
'22'
| self) |
sage: g = Gap() sage: g.is_running() False sage: g._start() sage: g.is_running() True sage: g.quit()
| self) |
Returns the symbol for truth in GAP.
sage: gap._true_symbol() 'true' sage: gap(2) == gap(2) True
Class: GapElement
Functions: bool,
str,
trait_names
| self) |
sage: bool(gap(2))
True
sage: gap(0).bool()
False
sage: gap('false').bool()
False
| self, [use_file=False]) |
sage: print gap(2) 2
| self) |
sage: s5 = gap.SymmetricGroup(5) sage: 'Centralizer' in s5.trait_names() True
Special Functions: __getitem__,
__len__,
__reduce__,
__repr__,
_latex_,
_matrix_
| self, n) |
sage: a = gap([1,2,3]) sage: a[1] 1
| 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
| self) |
Note that GAP elements cannot be pickled.
sage: gap(2).__reduce__() (<function reduce_load at 0x...>, ()) sage: f, args = _ sage: f(*args) (invalid object -- defined in terms of closed session)
| self) |
sage: gap(2) 2
| self) |
sage: s = gap("[[1,2], [3/4, 5/6]]")
sage: latex(s)
\left(\begin{array}{rr} 1\&2\\ 3/4\&\frac{5}{6}\\ \end{array}\right)
| 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
Special Functions: _sage_doc_
| self) |
sage: print gap.SymmetricGroup._sage_doc_() Basic Groups _____________________________________________ Group Libraries ...
Class: GapFunctionElement
Special Functions: _sage_doc_
| self) |
sage: print gap(4).SymmetricGroup._sage_doc_() Basic Groups _____________________________________________ Group Libraries ...
See About this document... for information on suggesting changes.