|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.aliasi.matrix.AbstractVector
public abstract class AbstractVector
An AbstractVector implements most of a vector's
functionality in terms of methods for dimensionality and values.
| Constructor Summary | |
|---|---|
protected |
AbstractVector()
Construct an abstract vector. |
| Method Summary | |
|---|---|
Vector |
add(Vector v)
Returns the result of adding the specified vector to this vector. |
double |
cosine(Vector v)
Returns the cosine of this vector and the specified vector. |
double |
dotProduct(Vector v)
Returns the dot product (inner product) of this vector with the specified vector. |
boolean |
equals(Object that)
Returns true if the specified object is a vector
with the same dimensionality and values as this vector. |
int |
hashCode()
Returns the hash code for this vector according to the specification. |
void |
increment(double scale,
Vector v)
Adds the specified vector multiplied by the specified scalar to this vector. |
double |
length()
Returns the length of this vector. |
int[] |
nonZeroDimensions()
Returns an array with the non-zero dimensions of this vector. |
abstract int |
numDimensions()
Returns the number of dimensions of this vector. |
void |
setValue(int dimension,
double value)
Throws an unsupported operation exception. |
abstract double |
value(int dimension)
The value of this vector for the specified dimension. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected AbstractVector()
| Method Detail |
|---|
public int[] nonZeroDimensions()
nonZeroDimensions in interface Vector
public void increment(double scale,
Vector v)
increment in interface Vectorscale - The scalar multiplier for the added vector.v - Vector to scale and add to this vector.
IllegalArgumentException - If the specified vector is not
of the same dimensionality as this vector.public abstract int numDimensions()
value(int).
numDimensions in interface Vectorpublic abstract double value(int dimension)
numDimensions().
value in interface Vectordimension - Dimension whose value is returned.
IndexOutOfBoundsException - If the dimension is less than
zero or greater than or equal to the number of dimensions.
public void setValue(int dimension,
double value)
setValue in interface Vectordimension - Ignored.value - Ignored.
UnsupportedOperationException - Always.public double length()
the implementation iterates over the dimensions once accessing each value.
length in interface Vectorpublic Vector add(Vector v)
Implementation Note: The result is a dense vector and this method iterates over the dimensions adding. Subclasses may override this with a more specific implementation and then fall back on this implementation for the general case.
add in interface Vectorv - Vector to add to this vector.
IllegalArgumentException - If the specified vector does
not have the same dimensionality as this vector.public double dotProduct(Vector v)
Implementation Note: This method iterates over the dimensions, accessing values for this vector and the specified vector for each dimension.
dotProduct in interface Vectorv - The specified vector.
IllegalArgumentException - If the specified vector
is not of the same dimensionality as this vector.public double cosine(Vector v)
Implementation Note: This method iterates over the dimensions once and accesses the value of each vector once per dimension.
cosine in interface Vectorv - The specified vector.
IllegalArgumentException - If the specified vector
is not of the same dimensionality as this vector.public boolean equals(Object that)
true if the specified object is a vector
with the same dimensionality and values as this vector. Note
that labels are not considered for equality. This
implementation is consistent with hash codes.
equals in interface Vectorequals in class Objectthat - Specified object.
true if the specified object is a vector
with the same dimensionality and values as this vector.public int hashCode()
hashCode in interface VectorhashCode in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||