I was writing a C# class library to manage finite groups. A group is a set G of elements with a defined binary operation *, where:
a * b is in G (closure)
a * (b * c) = (a * b) * c (associative)
a * a’ = e (inverse and identity)
a * e = e * a (identity)
The solution code is in my AjCodeKata Google Project, under trunk/AjGroups:
The key interfaces are:
IElement has a method Multiply, that receives another IElement and returns the result IElement. IElement.Order is the number of elements to be multiplied to get the identity:
a * a * a ….. * a = e
IGroup.Elements is the collection of IElements that are the elements of the group. IGroup.Order is the count of elements.
There are two implementations of that interfaces: one based on permutations, another based on named elements (such “a”, “e”) and a table describing their multiplications.
There are methods to:
- Get the subgroups of a group
- Get the normal subgroups of a group
- Answer if two groups are isomorphic
I followed TDD ideas during development. All tests in green:
Good code coverage:
I should make some refactoring, but the project is taking form. I will write posts describing the permutation implementation, and the abstract elements implementation.
Keep tuned!
Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez
[...] my previous post I presented AjGroups, a class library written in C# that implements finite group concepts and [...]
Pingback by Permutations in AjGroups « Angel “Java” Lopez on Blog — January 3, 2011 @ 9:30 am
[...] Presenting AjGroups: Finite Groups Library Permutations in AjGroups [...]
Pingback by Abstract Elements in AjGroups « Angel “Java” Lopez on Blog — January 5, 2011 @ 10:41 am
[...] Presenting AjGroups: Finite Groups Library Permutations in AjGroups [...]
Pingback by Elementos abstractos en AjGroups - Angel "Java" Lopez — January 6, 2011 @ 9:32 am