11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

136 • Chapter 3: <strong>Programming</strong> with Modules> local i;> [ seq( b[ i ], i = a ) ]> end proc;> G:-mul := () -> foldl( G:-‘.‘, G:-id, args );> G:-inv := proc( g )> local i, a;> a := array( 1 .. deg );> for i from 1 to deg do> a[ g[ i ] ] := i> end do;> [ seq( a[ i ], i = 1 .. deg ) ]> end proc;> G:-member := proc( g, S, pos::name )> if nargs = 1 then> type( g, ’list( posint )’ )> and { op( g ) } = { $ 1 .. deg }> else> :-member( args )> end if> end proc;> G:-eq := ( a, b ) -> evalb( a = b );> G:-gens := gens;> eval( G, 1 )> end proc:For example, to construct the group 〈(12), (123)〉 in the symmetric groupS 4 , use the PermutationGroup constructor as follows.> G := PermutationGroup( 4, { [2,1,3,4], [2,3,1,4] } );G := module()exportid , ‘.‘, mul , inv, eq, member, gens, order, elements;option record ;end moduleTo compute with its elements, use the methods exported by the instantiatedgroup G.> use G in> inv( [ 2,1,3,4 ] ) . [2,3,1,4];> end use;[3, 2, 1, 4]It is useful to provide more specialized permutation group constructorsfor special kinds of groups. Using the general constructorPermutationGroup, and overriding some of the exported methods, youcan define several of these specialized constructors as follows.

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

Saved successfully!

Ooh no, something went wrong!