com.perisic.ring
Class Ring

java.lang.Object
  extended by com.perisic.ring.Ring
Direct Known Subclasses:
DoubleField, F2Field, IntegerRing, Matrix2x2Ring, ModularIntegerRing, ModularRing, PolynomialRing, QuotientField, RationalField, UniversalRing

public abstract class Ring
extends java.lang.Object

Title: Ring

Description: An abstract Ring class.

This class is the base class for all rings and fields of the package. The following methods are abstract and have to be overridden by all child rings (a child ring is a child class of this class which implements a ring in the meaning of a ring in algebra): add(), mult(), zero(), neg() and equalZero().

The following methods are semi abstract, that means they throw an error message if they are called. If applicable for the ring, they have to be overridden: one() and inv().

Rings which are not a field might override the methods ediv(), mod() and tdiv() if applicable.

See the documentation below for details.

Version:
0.2
Author:
Marc Conrad

Field Summary
static ModularRing C
          The field C of complex numbers.
static F2Field F2
          The field F2 of integers modulo 2.
static RationalField Q
          The field Q of fractions.
static DoubleField R
          The field R of real numbers.
static IntegerRing Z
          The ring Z of integers.
 
Constructor Summary
Ring()
           
 
Method Summary
abstract  RingElt add(RingElt a, RingElt b)
          The addition a + b of two ring elements a and b.
 RingElt div(RingElt a, RingElt b)
          Computes a/b.
 RingElt ediv(RingElt a, RingElt b)
          Returns a div b (euclidian division).
 java.lang.String eltToString(RingElt a)
          Returns the Ring element a as a String.
 boolean equal(RingElt a, RingElt b)
          True if a == b.
abstract  boolean equalZero(RingElt a)
          Returns true if a == 0.
 RingElt evaluatePolynomial(RingElt p, RingElt b)
          Evaluates the Polynomial p at b.
 RingElt gcd(RingElt a, RingElt b)
          Returns gcd(a,b).
 RingElt inv(RingElt b)
          Returns b^-1.
 boolean isEuclidian()
          Is the ring Euclidian? By default false.
 boolean isField()
          Is the ring a field? By default false.
 boolean isUFD()
          Is the ring a UFD (unique factorization domain)? By default false.
 RingElt map(java.math.BigInteger a)
          Maps a into the Ring.
 RingElt map(int a)
          Maps a into the Ring.
 RingElt map(java.lang.Object a)
          By default, maps a into the Ring using appropriate methods if a is a RingElt, a BigInteger or a String.
 RingElt map(RingElt a)
          Maps a into the Ring.
 RingElt map(java.lang.String str)
          Maps a String into the Ring.
 RingElt mod(RingElt a, RingElt m)
          Returns a % m (euclidian division, a modulo m).
abstract  RingElt mult(RingElt a, RingElt b)
          The mutiplicaton a * b of two ring elements a and b.
abstract  RingElt neg(RingElt a)
          Returns the additive inverse -a of an ring element a.
 RingElt one()
          Returns the 1 of the ring.
 RingElt pow(RingElt b, java.math.BigInteger a)
          Returns b^a.
 RingElt pow(RingElt b, int a)
          Returns b^a.
 RingElt sub(RingElt a, RingElt b)
          Returns a - b.
 RingElt tdiv(RingElt a, RingElt b)
          Computes a/b (true division).
abstract  RingElt zero()
          Returns the 0 of the ring.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

C

public static final ModularRing C
The field C of complex numbers. This is constructed as a modular ring over R[i].


Z

public static final IntegerRing Z
The ring Z of integers. This is a wrapper class for BigInteger of the java.math package.


Q

public static final RationalField Q
The field Q of fractions.


R

public static final DoubleField R
The field R of real numbers. This is a wrapper class for the primitive data type double.


F2

public static final F2Field F2
The field F2 of integers modulo 2. This is a wrapper class for the primitive data type boolean

Constructor Detail

Ring

public Ring()
Method Detail

add

public abstract RingElt add(RingElt a,
                            RingElt b)
The addition a + b of two ring elements a and b. Should be associative.


mult

public abstract RingElt mult(RingElt a,
                             RingElt b)
The mutiplicaton a * b of two ring elements a and b. Should be associative and distributive concerning addition.


zero

public abstract RingElt zero()
Returns the 0 of the ring. The 0 is the unique element for which a + 0 = 0 + a = a for each element a of the ring.


neg

public abstract RingElt neg(RingElt a)
Returns the additive inverse -a of an ring element a.


equalZero

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


one

public RingElt one()
            throws RingException
Returns the 1 of the ring. This method throws a RingException. Child rings with one must override this method.

Throws:
RingException

inv

public RingElt inv(RingElt b)
            throws RingException
Returns b^-1. Returns one if b == one() (after mapping b in the ring). Otherwise throws a RingException.

Note for implementing a child class of Ring: Must be overridden for fields. Might be overridden in other child rings if applicable.

Throws:
RingException

sub

public RingElt sub(RingElt a,
                   RingElt b)
Returns a - b. This method is implemented as a + (-b) via the neg() method.


equal

public boolean equal(RingElt a,
                     RingElt b)
True if a == b. This method is implemented as (a - b) == 0 via the sub() and the equalZero() method.


div

public RingElt div(RingElt a,
                   RingElt b)
Computes a/b. This method is implemented as a * (b^-1) via the inv() and the mult() method.


tdiv

public RingElt tdiv(RingElt a,
                    RingElt b)
Computes a/b (true division). An error is thrown. if the division cannot be performed, i.e. if b divides not a. If the child ring is a field this method calls the div() method.


ediv

public RingElt ediv(RingElt a,
                    RingElt b)
             throws RingException
Returns a div b (euclidian division). If the child ring is a field then this method calls div(). Otherwise an error is thrown.

Note for implementing a child class of Ring: Euclidian child rings must override this method.

Throws:
RingException

mod

public RingElt mod(RingElt a,
                   RingElt m)
            throws RingException
Returns a % m (euclidian division, a modulo m). If the child ring is a field then this method returns zero(). Otherwise an error is thrown.

Note for implementing a child class of Ring: Euclidian child rings must override this method.

Throws:
RingException

gcd

public RingElt gcd(RingElt a,
                   RingElt b)
            throws RingException
Returns gcd(a,b). Returns one() if the ring is a field. For Euclidian rings the gcd is computed using mod(). Otherwise an error is thrown.

Throws:
RingException

isField

public boolean isField()
Is the ring a field? By default false.

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


isEuclidian

public boolean isEuclidian()
Is the ring Euclidian? By default false. True for a field.

Note for implementing a child class of Ring: Must be overridden in an Euclidian ring which is not a field.


isUFD

public boolean isUFD()
Is the ring a UFD (unique factorization domain)? By default false. True if euclidian (or field).

Note for implementing a child class of Ring: Must be overridden in an UFD which is not euclidian.


map

public RingElt map(int a)
Maps a into the Ring. For each ring R with one there is a canonical map Z -> R, which maps a into 1 + 1 + ... + 1 (a times). Throws an RingException, if one() is not implemented.


map

public RingElt map(java.math.BigInteger a)
Maps a into the Ring. For each ring R with one there is a canonical map Z -> R, which maps a into 1 + 1 + ... + 1 (a times). Throws an RingException, if one() is not implemented.


map

public RingElt map(RingElt a)
Maps a into the Ring. By default this method maps ring elements in the ring which are of Z or Q. The first one requires overriding of one(), the latter in addition overriding of tdiv().

In addition identical mapping, if the Ring of a is this ring, is supported.

Note: For each ring R with one there is a canonical map Z -> R, which maps a into 1 + 1 + ... + 1 (a times) and a canonical map Q-> R which maps a = r/s into R if the division is well defined in R for these values of r and s.


map

public RingElt map(java.lang.String str)
Maps a String into the Ring. This is done by first mapping it to Q (via the map method of RationalField.Q) and then to this Ring.


map

public RingElt map(java.lang.Object a)
By default, maps a into the Ring using appropriate methods if a is a RingElt, a BigInteger or a String. Otherwise an error is thrown.


pow

public RingElt pow(RingElt b,
                   int a)
Returns b^a. Note, if the method one() is not implemented, an error will be thrown for a == 0. If inv() is not implemented, an error will be thrown for a < 0.


pow

public RingElt pow(RingElt b,
                   java.math.BigInteger a)
Returns b^a. Note, if the method one() is not overridden, an error will be thrown for a == 0. If inv() is not overridden, an error will be thrown for a < 0.


eltToString

public java.lang.String eltToString(RingElt a)
Returns the Ring element a as a String. Since version 0.2. If not overridden returns map(a).toString().


evaluatePolynomial

public RingElt evaluatePolynomial(RingElt p,
                                  RingElt b)
Evaluates the Polynomial p at b. If p is not a polynomial it is assumed a constant polynomial and therfore p is mapped to the ring