|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.math3.linear.RealVector org.apache.commons.math3.linear.SparseRealVector org.apache.commons.math3.linear.OpenMapRealVector
@Deprecated public class OpenMapRealVector
This class implements the RealVector
interface with a
OpenIntToDoubleHashMap
backing store.
Nested Class Summary | |
---|---|
protected class |
OpenMapRealVector.OpenMapEntry
Deprecated. Implementation of Entry optimized for OpenMap. |
protected class |
OpenMapRealVector.OpenMapSparseIterator
Deprecated. Iterator class to do iteration over just the non-zero elements. |
Nested classes/interfaces inherited from class org.apache.commons.math3.linear.RealVector |
---|
RealVector.Entry, RealVector.SparseEntryIterator |
Field Summary | |
---|---|
static double |
DEFAULT_ZERO_TOLERANCE
Deprecated. Default Tolerance for having a value considered zero. |
Constructor Summary | |
---|---|
|
OpenMapRealVector()
Deprecated. Build a 0-length vector. |
|
OpenMapRealVector(double[] values)
Deprecated. Create from an array. |
|
OpenMapRealVector(Double[] values)
Deprecated. Create from an array. |
|
OpenMapRealVector(double[] values,
double epsilon)
Deprecated. Create from an array, specifying zero tolerance. |
|
OpenMapRealVector(Double[] values,
double epsilon)
Deprecated. Create from an array. |
|
OpenMapRealVector(int dimension)
Deprecated. Construct a vector of zeroes. |
|
OpenMapRealVector(int dimension,
double epsilon)
Deprecated. Construct a vector of zeroes, specifying zero tolerance. |
|
OpenMapRealVector(int dimension,
int expectedSize)
Deprecated. Build a vector with known the sparseness (for advanced use only). |
|
OpenMapRealVector(int dimension,
int expectedSize,
double epsilon)
Deprecated. Build a vector with known the sparseness and zero tolerance setting (for advanced use only). |
|
OpenMapRealVector(OpenMapRealVector v)
Deprecated. Copy constructor. |
protected |
OpenMapRealVector(OpenMapRealVector v,
int resize)
Deprecated. Build a resized vector, for use with append. |
|
OpenMapRealVector(RealVector v)
Deprecated. Generic copy constructor. |
Method Summary | |
---|---|
OpenMapRealVector |
add(OpenMapRealVector v)
Deprecated. Optimized method to add two OpenMapRealVectors. |
RealVector |
add(RealVector v)
Deprecated. Compute the sum of this vector and v . |
OpenMapRealVector |
append(double d)
Deprecated. Construct a new vector by appending a double to this vector. |
OpenMapRealVector |
append(OpenMapRealVector v)
Deprecated. Optimized method to append a OpenMapRealVector. |
OpenMapRealVector |
append(RealVector v)
Deprecated. Construct a new vector by appending a vector to this vector. |
OpenMapRealVector |
copy()
Deprecated. Returns a (deep) copy of this vector. |
double |
dotProduct(OpenMapRealVector v)
Deprecated. as of 3.1 (to be removed in 4.0). The computation is performed by the parent class. The method must be kept to maintain backwards compatibility. |
OpenMapRealVector |
ebeDivide(RealVector v)
Deprecated. Element-by-element division. |
OpenMapRealVector |
ebeMultiply(RealVector v)
Deprecated. Element-by-element multiplication. |
boolean |
equals(Object obj)
Deprecated. Test for the equality of two real vectors. |
int |
getDimension()
Deprecated. Returns the size of the vector. |
double |
getDistance(OpenMapRealVector v)
Deprecated. Optimized method to compute distance. |
double |
getDistance(RealVector v)
Deprecated. Distance between two vectors. |
double |
getEntry(int index)
Deprecated. Return the entry at the specified index. |
double |
getL1Distance(OpenMapRealVector v)
Deprecated. Distance between two vectors. |
double |
getL1Distance(RealVector v)
Deprecated. Distance between two vectors. |
double |
getLInfDistance(RealVector v)
Deprecated. Distance between two vectors. |
double |
getSparsity()
Deprecated. |
OpenMapRealVector |
getSubVector(int index,
int n)
Deprecated. Get a subvector from consecutive elements. |
int |
hashCode()
Deprecated. . |
protected boolean |
isDefaultValue(double value)
Deprecated. Determine if this value is within epsilon of zero. |
boolean |
isInfinite()
Deprecated. Check whether any coordinate of this vector is infinite and none are NaN . |
boolean |
isNaN()
Deprecated. Check whether any coordinate of this vector is NaN . |
OpenMapRealVector |
mapAdd(double d)
Deprecated. Add a value to each entry. |
OpenMapRealVector |
mapAddToSelf(double d)
Deprecated. Add a value to each entry. |
void |
set(double value)
Deprecated. Set all elements to a single value. |
void |
setEntry(int index,
double value)
Deprecated. Set a single element. |
void |
setSubVector(int index,
RealVector v)
Deprecated. Set a sequence of consecutive elements. |
Iterator<RealVector.Entry> |
sparseIterator()
Deprecated. Create a sparse iterator over the vector, which may omit some entries. |
OpenMapRealVector |
subtract(OpenMapRealVector v)
Deprecated. Optimized method to subtract OpenMapRealVectors. |
RealVector |
subtract(RealVector v)
Deprecated. Subtract v from this vector. |
double[] |
toArray()
Deprecated. Convert the vector to an array of double s. |
void |
unitize()
Deprecated. Converts this vector into a unit vector. |
OpenMapRealVector |
unitVector()
Deprecated. Creates a unit vector pointing in the direction of this vector. |
Methods inherited from class org.apache.commons.math3.linear.RealVector |
---|
addToEntry, checkIndex, checkIndices, checkVectorDimensions, checkVectorDimensions, combine, combineToSelf, cosine, dotProduct, getL1Norm, getLInfNorm, getMaxIndex, getMaxValue, getMinIndex, getMinValue, getNorm, iterator, map, mapDivide, mapDivideToSelf, mapMultiply, mapMultiplyToSelf, mapSubtract, mapSubtractToSelf, mapToSelf, outerProduct, projection, unmodifiableRealVector, walkInDefaultOrder, walkInDefaultOrder, walkInDefaultOrder, walkInDefaultOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInOptimizedOrder |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final double DEFAULT_ZERO_TOLERANCE
Constructor Detail |
---|
public OpenMapRealVector()
OpenMapRealVector(OpenMapRealVector, int)
constructor
or one of the append
method (append(double)
,
append(RealVector)
) to gather data into this vector.
public OpenMapRealVector(int dimension)
dimension
- Size of the vector.public OpenMapRealVector(int dimension, double epsilon)
dimension
- Size of the vector.epsilon
- Tolerance below which a value considered zero.protected OpenMapRealVector(OpenMapRealVector v, int resize)
v
- Original vector.resize
- Amount to add.public OpenMapRealVector(int dimension, int expectedSize)
dimension
- Size of the vector.expectedSize
- The expected number of non-zero entries.public OpenMapRealVector(int dimension, int expectedSize, double epsilon)
dimension
- Size of the vector.expectedSize
- Expected number of non-zero entries.epsilon
- Tolerance below which a value is considered zero.public OpenMapRealVector(double[] values)
values
- Set of values to create from.public OpenMapRealVector(double[] values, double epsilon)
values
- Set of values to create from.epsilon
- Tolerance below which a value is considered zero.public OpenMapRealVector(Double[] values)
values
- The set of values to create frompublic OpenMapRealVector(Double[] values, double epsilon)
values
- Set of values to create from.epsilon
- Tolerance below which a value is considered zero.public OpenMapRealVector(OpenMapRealVector v)
v
- Instance to copy from.public OpenMapRealVector(RealVector v)
v
- Instance to copy from.Method Detail |
---|
protected boolean isDefaultValue(double value)
value
- Value to test
true
if this value is within epsilon to zero,
false
otherwise.public RealVector add(RealVector v) throws DimensionMismatchException
v
.
Returns a new vector. Does not change instance data.
add
in class RealVector
v
- Vector to be added.
this
+ v
.
DimensionMismatchException
- if v
is not the same size as
this
vector.public OpenMapRealVector add(OpenMapRealVector v) throws DimensionMismatchException
v
- Vector to add.
this
and v
.
DimensionMismatchException
- if the dimensions do not match.public OpenMapRealVector append(OpenMapRealVector v)
v
- vector to append
v
to selfpublic OpenMapRealVector append(RealVector v)
append
in class RealVector
v
- vector to append to this one.
public OpenMapRealVector append(double d)
append
in class RealVector
d
- double to append.
public OpenMapRealVector copy()
copy
in class RealVector
@Deprecated public double dotProduct(OpenMapRealVector v) throws DimensionMismatchException
v
- Vector.
v
.
DimensionMismatchException
- if v
is not the same size as
this
vector.public OpenMapRealVector ebeDivide(RealVector v) throws DimensionMismatchException
ebeDivide
in class RealVector
v
- Vector by which instance elements must be divided.
DimensionMismatchException
- if v
is not the same size as
this
vector.public OpenMapRealVector ebeMultiply(RealVector v) throws DimensionMismatchException
ebeMultiply
in class RealVector
v
- Vector by which instance elements must be multiplied
DimensionMismatchException
- if v
is not the same size as
this
vector.public OpenMapRealVector getSubVector(int index, int n) throws NotPositiveException, OutOfRangeException
getSubVector
in class RealVector
index
- index of first element.n
- number of elements to be retrieved.
NotPositiveException
- if the number of elements is not positive.
OutOfRangeException
- if the index is not valid.public int getDimension()
getDimension
in class RealVector
public double getDistance(OpenMapRealVector v) throws DimensionMismatchException
v
- Vector to compute distance to.
this
and v
.
DimensionMismatchException
- if the dimensions do not match.public double getDistance(RealVector v) throws DimensionMismatchException
This method computes the distance consistent with the L2 norm, i.e. the square root of the sum of element differences, or Euclidean distance.
getDistance
in class RealVector
v
- Vector to which distance is requested.
DimensionMismatchException
- if v
is not the same size as
this
vector.RealVector.getL1Distance(RealVector)
,
RealVector.getLInfDistance(RealVector)
,
RealVector.getNorm()
public double getEntry(int index) throws OutOfRangeException
getEntry
in class RealVector
index
- Index location of entry to be fetched.
index
.
OutOfRangeException
- if the index is not valid.RealVector.setEntry(int, double)
public double getL1Distance(OpenMapRealVector v) throws DimensionMismatchException
v
- Vector to which distance is requested.
v
.
DimensionMismatchException
- if the dimensions do not match.public double getL1Distance(RealVector v) throws DimensionMismatchException
This method computes the distance consistent with L1 norm, i.e. the sum of the absolute values of the elements differences.
getL1Distance
in class RealVector
v
- Vector to which distance is requested.
DimensionMismatchException
- if v
is not the same size as
this
vector.public double getLInfDistance(RealVector v) throws DimensionMismatchException
This method computes the distance consistent with L∞ norm, i.e. the max of the absolute values of element differences.
getLInfDistance
in class RealVector
v
- Vector to which distance is requested.
DimensionMismatchException
- if v
is not the same size as
this
vector.RealVector.getDistance(RealVector)
,
RealVector.getL1Distance(RealVector)
,
RealVector.getLInfNorm()
public boolean isInfinite()
NaN
.
isInfinite
in class RealVector
true
if any coordinate of this vector is infinite and
none are NaN
, false
otherwise.public boolean isNaN()
NaN
.
isNaN
in class RealVector
true
if any coordinate of this vector is NaN
,
false
otherwise.public OpenMapRealVector mapAdd(double d)
mapAdd
in class RealVector
d
- Value to be added to each entry.
this
+ d
.public OpenMapRealVector mapAddToSelf(double d)
mapAddToSelf
in class RealVector
d
- Value to be added to each entry.
this
.public void setEntry(int index, double value) throws OutOfRangeException
setEntry
in class RealVector
index
- element index.value
- new value for the element.
OutOfRangeException
- if the index is not valid.RealVector.getEntry(int)
public void setSubVector(int index, RealVector v) throws OutOfRangeException
setSubVector
in class RealVector
index
- index of first element to be set.v
- vector containing the values to set.
OutOfRangeException
- if the index is not valid.public void set(double value)
set
in class RealVector
value
- Single value to set for all elements.public OpenMapRealVector subtract(OpenMapRealVector v) throws DimensionMismatchException
v
- Vector to subtract from this
.
this
and v
.
DimensionMismatchException
- if the dimensions do not match.public RealVector subtract(RealVector v) throws DimensionMismatchException
v
from this vector.
Returns a new vector. Does not change instance data.
subtract
in class RealVector
v
- Vector to be subtracted.
this
- v
.
DimensionMismatchException
- if v
is not the same size as
this
vector.public OpenMapRealVector unitVector() throws MathArithmeticException
unitVector
in class RealVector
MathArithmeticException
- if the norm is zero.public void unitize() throws MathArithmeticException
unitize
in class RealVector
MathArithmeticException
- if the norm is zero.public double[] toArray()
double
s.
The array is independent from this vector data: the elements
are copied.
toArray
in class RealVector
public int hashCode()
RealVector
(current implementation throws an
exception).
Implementation Note: This works on exact values, and as a result
it is possible for a.subtract(b)
to be the zero vector, while
a.hashCode() != b.hashCode()
.
hashCode
in class RealVector
public boolean equals(Object obj)
Test for the equality of two real vectors. If all coordinates of two real
vectors are exactly the same, and none are NaN
, the two real
vectors are considered to be equal. NaN
coordinates are
considered to affect globally the vector and be equals to each other -
i.e, if either (or all) coordinates of the real vector are equal to
NaN
, the real vector is equal to a vector with all NaN
coordinates.
This method must be overriden by concrete subclasses of
RealVector
(the current implementation throws an exception).
a.subtract(b
} to be the zero vector, while
a.equals(b) == false
.
equals
in class RealVector
obj
- Object to test for equality.
true
if two vector objects are equal, false
if
other
is null, not an instance of RealVector
, or
not equal to this RealVector
instance.public double getSparsity()
public Iterator<RealVector.Entry> sparseIterator()
RealVector.iterator()
.
Note: derived classes are required to return an Iterator
that
returns non-null RealVector.Entry
objects as long as Iterator.hasNext()
returns true
.
sparseIterator
in class RealVector
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |