|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
ObjectSparseElt
An abstract class representing elements of a sparse vector (a
SparseV) over an integral domain D. A
SparseElt is an immutable ordered pair consisting of an
index and an element of D. The
index is the index in the sparse vector. It must
be ≥ 0. The implementation will determine which
domain is used.
A SparseElt may have value zero, but it is an error if such a SparseElt becomes an element of a SparseV. (As a corollary, we require 0 ≠ 1 in D.)
Some implementations will have public constructors. Others
will have static makeInstance methods.
When possible, implementations should implement Comparable to compare SparseElts by < on their values.
Examples are when D is a subring of the real
numbers R or some other ordered field. To compare on
the indices, use INDEX_SORTER.
| Field Summary | |
static Comparator |
INDEX_SORTER
Compares two SparseElts by < on the indices. |
static SparseElt |
NEG_ONE
A formal "-1" object that can be combined in arithmetic operations with elements from another domain (a "complete" implementation of SparseElt), producing values in the other domain.
|
static SparseElt |
ONE
A formal "1" object that can be combined in arithmetic operations with elements from another domain (a "complete" implementation of SparseElt), producing values in the other domain.
|
static SparseElt |
ZERO
A formal "0" object that can be combined in arithmetic operations with elements from another domain (a "complete" implementation of SparseElt), producing values in the other domain.
|
| Constructor Summary | |
SparseElt()
|
|
| Method Summary | |
abstract SparseElt |
add(SparseElt y)
Returns a SparseElt whose value is the sum of the values in this and y, and whose index is that
of this. |
abstract int |
bitLength()
If the value is a BigInteger, returns its BigInteger.bitLength(); if the value is stored in a primitive
type, returns the bit length of the type. |
abstract SparseElt |
copy(int indexOfCopy)
Returns a SparseElt with the same value as this,
and with index indexOfCopy. |
abstract boolean |
divides(SparseElt y)
Whether the value of this divides the value of
y; that is, whether there is an x
such that x * this = y. |
boolean |
equals(Object o)
Says two SparseElts are equal if and only if they have the same index and satisfy isEqualValue(shh.csparse.SparseElt). |
int |
getIndex()
Returns the index. |
abstract SparseElt |
getNegOne()
Returns a SparseElt from the same integral domain as this, with value -1 and unspecified index. |
abstract SparseElt |
getOne()
Returns a SparseElt from the same integral domain as this, with value 1 and unspecified index. |
abstract String |
getPrintValue()
Returns the value in human-readable form. |
abstract SparseElt |
getZero()
Returns a SparseElt from the same integral domain as this, with value 0 and unspecified index. |
abstract int |
hashCode()
Must be consistent with equals(java.lang.Object). |
abstract boolean |
isEqualValue(SparseElt y)
Tests whether the values are equal, ignoring the indices. |
abstract boolean |
isNegOne()
Whether the value is -1. |
abstract boolean |
isOne()
Whether the value is one. |
abstract boolean |
isZero()
Whether the value is zero. |
abstract SparseElt |
multiply(int newIndex,
SparseElt y)
Returns a SparseElt with index newIndex and whose
value is the product of the values in this and
y. |
SparseElt |
multiply(SparseElt y)
Returns a SparseElt whose value is the product of the values in this and y, and whose index is that
of this. |
abstract SparseElt |
negate()
Returns a SparseElt whose value is the negative of the value of this, and whose index is that of
this. |
abstract SparseElt |
subtract(SparseElt y)
Returns a SparseElt whose value is (value of this)
minus (value of y), and whose index is that of
this. |
String |
toString()
Returns (index value). |
| Methods inherited from class Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final Comparator INDEX_SORTER
public static final SparseElt ZERO
SparseElt), producing values in the other domain.
Operations that wouldn't produce results in a "complete"
implementation are unsupported.
public static final SparseElt ONE
SparseElt), producing values in the other domain.
Operations that wouldn't produce results in a "complete"
implementation are unsupported.
public static final SparseElt NEG_ONE
SparseElt), producing values in the other domain.
Operations that wouldn't produce results in a "complete"
implementation are unsupported.
| Constructor Detail |
public SparseElt()
| Method Detail |
public abstract SparseElt add(SparseElt y)
this and y, and whose index is that
of this.
public abstract int bitLength()
BigInteger.bitLength(); if the value is stored in a primitive
type, returns the bit length of the type.
public abstract SparseElt copy(int indexOfCopy)
this,
and with index indexOfCopy.
public abstract boolean divides(SparseElt y)
this divides the value of
y; that is, whether there is an x
such that x * this = y.
ArithmeticException - If this is zero.public boolean equals(Object o)
isEqualValue(shh.csparse.SparseElt).
public int getIndex()
public abstract SparseElt getNegOne()
this, with value -1 and unspecified index.
public abstract SparseElt getOne()
this, with value 1 and unspecified index.
public abstract String getPrintValue()
public abstract SparseElt getZero()
this, with value 0 and unspecified index.
public abstract int hashCode()
equals(java.lang.Object).
public abstract boolean isEqualValue(SparseElt y)
public abstract boolean isNegOne()
public abstract boolean isOne()
public abstract boolean isZero()
public SparseElt multiply(SparseElt y)
this and y, and whose index is that
of this.
public abstract SparseElt multiply(int newIndex,
SparseElt y)
newIndex and whose
value is the product of the values in this and
y.
public abstract SparseElt negate()
this, and whose index is that of
this.
public abstract SparseElt subtract(SparseElt y)
this)
minus (value of y), and whose index is that of
this.
public String toString()
(index value).
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||