com.perisic.ring
Class F2Field

java.lang.Object
  extended by com.perisic.ring.Ring
      extended by com.perisic.ring.F2Field

public class F2Field
extends Ring

The finite prime field of characteristic 2. This is a wrapper class for the primitive data type boolean where "and" is the multiplcaton and "exclusive or" is the addition.

Version:
0.2
Author:
Marc Conrad

Field Summary
static F2Field F2
          The field F2.
 
Fields inherited from class com.perisic.ring.Ring
C, Q, R, Z
 
Method Summary
 RingElt add(RingElt a, RingElt b)
          The addition a + b mod 2.
 boolean equalZero(RingElt a)
          Returns true if a == 0.
 RingElt inv(RingElt b)
          Returns b^-1.
 boolean isField()
          Is the ring a field? By default false.
 RingElt map(boolean b)
          Maps false to 0 and true to 1.
 RingElt map(RingElt b)
          If b is a modular integer ring, such that the modulus maps to 0, the value of b is mapped to F2.
 RingElt mult(RingElt a, RingElt b)
          The multiplicaton a * b mod 2.
 RingElt neg(RingElt a)
          Returns -a mod 2.
 RingElt one()
          Returns the 1 of the ring.
 boolean toBoolean(RingElt a)
          Returns the boolean value of a.
 java.lang.String toString()
          Returns the String "F2".
 RingElt zero()
          Returns 0 mod 2.
 
Methods inherited from class com.perisic.ring.Ring
div, ediv, eltToString, equal, evaluatePolynomial, gcd, isEuclidian, isUFD, map, map, map, map, mod, pow, pow, sub, tdiv
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

F2

public static F2Field F2
The field F2.

Method Detail

isField

public boolean isField()
Description copied from class: Ring
Is the ring a field? By default false.

Note for implementing a child class of Ring: Must be overridden in a field.

Overrides:
isField in class Ring

toString

public java.lang.String toString()
Returns the String "F2".

Overrides:
toString in class java.lang.Object

toBoolean

public boolean toBoolean(RingElt a)
Returns the boolean value of a. That is, true if a == 1 and false if a == 0.


add

public RingElt add(RingElt a,
                   RingElt b)
The addition a + b mod 2.

Specified by:
add in class Ring

mult

public RingElt mult(RingElt a,
                    RingElt b)
The multiplicaton a * b mod 2.

Specified by:
mult in class Ring

zero

public RingElt zero()
Returns 0 mod 2.

Specified by:
zero in class Ring

neg

public RingElt neg(RingElt a)
Returns -a mod 2. Note: As -a == +a mod 2, calling this method is the same as calling map(a).

Specified by:
neg in class Ring

equalZero

public boolean equalZero(RingElt a)
Returns true if a == 0.

Specified by:
equalZero in class Ring

one

public RingElt one()
Returns the 1 of the ring.

Overrides:
one in class Ring

inv

public RingElt inv(RingElt b)
            throws RingException
Returns b^-1. Throws a RingException for b == 0 mod 2 and returns map(b) otherwise.

Overrides:
inv in class Ring
Throws:
RingException

map

public RingElt map(boolean b)
Maps false to 0 and true to 1.


map

public RingElt map(RingElt b)
If b is a modular integer ring, such that the modulus maps to 0, the value of b is mapped to F2. Integers and Rationals are mapped as usual.

Overrides:
map in class Ring