uk.org.ogsadai.activity.files
Class Sequence

java.lang.Object
  |
  +--uk.org.ogsadai.activity.files.Sequence

public class Sequence
extends java.lang.Object

This class represents a countable, increasing chain in the set of integers under the < relation. Note that since the relation is a strict inequality, the chain may not be eventually constant.

The chain d1 < d2 < d3 < ... is defined by:

dn =def P(n)
where P(n) is the Lagrange interpolating polynomial generated from co-ordinates (pn, n), where {pn} is a sequence of "seed integers".

The seed integers are passed to the constructor of this class, from which the Lagrange interpolating polynomial is generated. This polynomial can then be used to extrapolate the sequence to infinity. The isMember method can be used to test whether a given integer n is a member of this sequence, i.e. whether P(i) = n for any positive integer i.

For example, if the seed integers are p1 = 2 and pn = 4, then P(n) = 2n, so isMember will return true when passed any even positive integer.

Note that the indiscriminant use of the Lagrange interpolating polynomial restricts the sequences we can represent. For example, we can represent linear progressions such as 1, 3, 5, ... (with P(n) = 2n - 1); quadratic progressions such as 0, 1, 4, 9 (with P(n) = n2 - 2n + 1); etc, but not exponential progressions.

Author:
The OGSA-DAI Project Team

Constructor Summary
Sequence(int[] items)
          Construct a new Sequence with a provided array of ordered seed integers.
 
Method Summary
 boolean isMember(int val)
          Tests to see if a particular integer is a member of the sequence.
 java.lang.String toString()
          Returns a string representation of this sequence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Sequence

public Sequence(int[] items)
         throws NonIncreasingSequenceException
Construct a new Sequence with a provided array of ordered seed integers.

Parameters:
items - the seed integers
Throws:
NonIncreasingSequenceException
Method Detail

toString

public java.lang.String toString()
Returns a string representation of this sequence. For debugging purposes only.

Overrides:
toString in class java.lang.Object
Returns:
a string representation

isMember

public boolean isMember(int val)
                 throws NonIncreasingSequenceException
Tests to see if a particular integer is a member of the sequence.

Parameters:
val - the integer to test
Returns:
true if the integer is a member of the sequence
false otherwise
Throws:
NonIncreasingSequenceException - if the sequence appears to be eventually constant