|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--uk.org.ogsadai.activity.files.Sequence
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.
| 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 |
public Sequence(int[] items)
throws NonIncreasingSequenceException
Sequence with a provided array of ordered
seed integers.
items - the seed integers
NonIncreasingSequenceException| Method Detail |
public java.lang.String toString()
toString in class java.lang.Object
public boolean isMember(int val)
throws NonIncreasingSequenceException
val - the integer to test
true if the integer is a member of the sequencefalse otherwise
NonIncreasingSequenceException - if the sequence appears to be eventually constant
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||