Class Group


class Group
Defines a mathematical group, which is a Set, coupled with an operation.
Defined in Group.js

Variable Summary
private boolean hasAssociativity
Whether or not the group is associative
private boolean hasClosure
Whether or not the group has closure
private boolean hasIdentity
Whether or not the group has an identity element
private boolean hasInverse
Whether or not the group satisfies the inverse axiom
private Number identity
the identity element, if it exists
Function operation
Either a function, or a string 'addition' or 'multiplication'

Constructor Summary
Group (Array elements, Function operator)
Group (Set set, Function operator)
Generator function for a new group (mathematical).

Function Summary
public Number getIdentity()
Gets the identity element if it exists.
public Set getSet()
Returns the set of this group, on which set operations can be done.
public boolean isGroup()
Tests to see whether the group satisfies all four axioms in the definition of a formal group.
public Number operand (Number el1, Number el2)
The actual binary operation that is carried out for the group.
public Set setIdentity()
Sets the identity element if it exists and hasIdentity to true.
public boolean testAssociativity()
Tests whether or not group is associative.
public boolean testClosure()
Determines if the group does or does not have closure and sets the boolean hasClosure.
public boolean testCycle (int[] array)
Tests if a given array (in this case, a permutation) is a cycle of the set.
public boolean testIdentity()
Tells whether or not group has identity element.
public boolean testInverse()
Tests for the existence of an inverse element for every element.

Variable Details

variable private boolean hasAssociativity

Whether or not the group is associative

variable private boolean hasClosure

Whether or not the group has closure

variable private boolean hasIdentity

Whether or not the group has an identity element

variable private boolean hasInverse

Whether or not the group satisfies the inverse axiom

variable private Number identity

the identity element, if it exists

variable Function operation

Either a function, or a string 'addition' or 'multiplication'

Constructor Details

constructor Group

Group(Array elements, Function operator)
Group(Set set, Function operator)
Generator function for a new group (mathematical).
Parameters:
fromArray
elements - the set of elements that defines the set in the group
operator - if a function, must take two parameters (elements of the set); if a string: 'addition' or 'multiplication'
fromSet
set - the set to use in the Group
operator - if a function, must take two parameters (elements of the set); if a string: 'addition' or 'multiplication'

Function Details

function getIdentity

public Number getIdentity()
Gets the identity element if it exists. Should be called after setIdentity() already has been.
Returns:
the identity element if it exists, false otherwise

function getSet

public Set getSet()
Returns the set of this group, on which set operations can be done.
Returns:
the set of this group
See also:

function isGroup

public boolean isGroup()
Tests to see whether the group satisfies all four axioms in the definition of a formal group. Call after testInverse, testIdentity, testAssociativity and testClosure.
Returns:
true if the group does, false otherwise

function operand

public Number operand(Number el1, Number el2)
The actual binary operation that is carried out for the group.
Parameters:
el1 - the first element
el2 - the second element
Returns:
(el1 operation el2)*

function setIdentity

public Set setIdentity()
Sets the identity element if it exists and hasIdentity to true.
Returns:
this set

function testAssociativity

public boolean testAssociativity()
Tests whether or not group is associative.
Returns:
true if group is associative, false otherwise

function testClosure

public boolean testClosure()
Determines if the group does or does not have closure and sets the boolean hasClosure.
Returns:
true if group has closure, false otherwise

function testCycle

public boolean testCycle(int[] array)
Tests if a given array (in this case, a permutation) is a cycle of the set.
Parameters:
array - the array to test
Returns:
true if array is a cycle, false otherwise

function testIdentity

public boolean testIdentity()
Tells whether or not group has identity element. Should be called after setIdentity() already has been.
Returns:
true if has identity element, false otherwise

function testInverse

public boolean testInverse()
Tests for the existence of an inverse element for every element. Should be called after setIdentity().
Returns:
true if every element has an inverse, false otherwise