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.

3.6 Interfaces and Implementations • 143> Z:-test( [2,1,3] );false> Z:-test( [2,3,1] );false> Z:-test( [1,2,3] );trueSimilarly, you can write a constructor for the centralizer of an elementin a group.> Centralizer := proc( G, g )> SubGroup( G, proc( s )> use ‘.‘ = G:-‘.‘, ‘=‘ = G:-eq in> s . g = g . s> end use end proc )> end proc:Generic Interfaces Dimino’s algorithm is relatively slow. For manyclasses of groups, there are better alternatives for enumerating groupelements. Use Dimino’s algorithm only as a last resort. The advantageof Dimino’s algorithm is that it works for any finite group. To providea clean and uniform interface to the enumeration functionality, you candevelop a frontend procedure, which hides the details, to choose the bestavailable algorithm.> GroupElements := proc( G )> description "enumerate the elements of a finite group";> if type( G, ’Group’ ) then> if type( G:-elements, ’set’ ) then> G:-elements> elif type( G:-elements, ’procedure’ ) then> G:-procedure()> else> G:-elements := Dimino( G )> end if> else> ’procname’( args )> end if> end proc:

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

Saved successfully!

Ooh no, something went wrong!