08.02.2015 Views

Sage Reference Manual: Matrices and Spaces of Matrices - Mirrors

Sage Reference Manual: Matrices and Spaces of Matrices - Mirrors

Sage Reference Manual: Matrices and Spaces of Matrices - Mirrors

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Sage</strong> <strong>Reference</strong> <strong>Manual</strong>: <strong>Matrices</strong> <strong>and</strong> <strong>Spaces</strong> <strong>of</strong> <strong>Matrices</strong>, Release 6.1.1<br />

. False True<br />

+------------<br />

False| False True<br />

True| True True<br />

TESTS:<br />

Empty structures behave acceptably, though the ASCII table looks a bit odd. The LaTeX version works much<br />

better.<br />

sage: from sage.matrix.operation_table import OperationTable<br />

sage: L=FiniteSemigroups().example(())<br />

sage: L<br />

An example <strong>of</strong> a finite semigroup: the left regular b<strong>and</strong> generated by ()<br />

sage: T=OperationTable(L, operation=operator.mul)<br />

sage: T<br />

*<br />

+<br />

sage: T._latex_()<br />

’{\\setlength{\\arraycolsep}{2ex}\n\\begin{array}{r|*{0}{r}}\n\\multicolumn{1}{c|}{\\ast}\\\\\\h<br />

If the algebraic structure cannot be listed (like when it is infinite) then there is no way to create a table.<br />

sage: from sage.matrix.operation_table import OperationTable<br />

sage: OperationTable(ZZ, operator.mul)<br />

Traceback (most recent call last):<br />

...<br />

ValueError: Integer Ring is infinite<br />

The value <strong>of</strong> elements must be a subset <strong>of</strong> the algebraic structure, in forms that can be coerced into the<br />

structure. Here we demonstrate the proper use first:<br />

sage: from sage.matrix.operation_table import OperationTable<br />

sage: H=CyclicPermutationGroup(4)<br />

sage: H.list()<br />

[(), (1,2,3,4), (1,3)(2,4), (1,4,3,2)]<br />

sage: elts = [’()’, ’(1,3)(2,4)’]<br />

sage: OperationTable(H, operator.mul, elements=elts)<br />

* a b<br />

+----<br />

a| a b<br />

b| b a<br />

This can be rewritten so as to pass the actual elements <strong>of</strong> the group H, using a simple for loop:<br />

sage: L = H.list() #list <strong>of</strong> elements <strong>of</strong> the group H<br />

sage: elts = [L[i] for i in {0, 2}]<br />

sage: elts<br />

[(), (1,3)(2,4)]<br />

sage: OperationTable(H, operator.mul, elements=elts)<br />

* a b<br />

+----<br />

a| a b<br />

b| b a<br />

Here are a couple <strong>of</strong> improper uses<br />

sage: elts.append(5)<br />

sage: OperationTable(H, operator.mul, elements=elts)<br />

Traceback (most recent call last):<br />

407

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!