vector element indexing is 0-based -- e.g., getEntry(0)
returns the first element of the vector.
The code map and mapToSelf methods operate
on vectors element-wise, i.e. they perform the same operation (adding a scalar,
applying a function ...) on each element in turn. The map
versions create a new vector to hold the result and do not change the instance.
The mapToSelf version uses the instance itself to store the
results, so the instance is changed by this method. In all cases, the result
vector is returned by the methods, allowing the fluent API
style, like this:
RealVector result = v.mapAddToSelf(3.4).mapToSelf(new Tan()).mapToSelf(new Power(2.3));
| Modifier and Type | Class and Description |
|---|---|
| protected class | RealVector.
An entry in the vector. |
| protected class | RealVector.
This class should rarely be used, but is here to provide a default implementation of sparseIterator(), which is implemented by walking over the entries, skipping those that are zero. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public RealVector | |
| public void | addToEntry(int
Index location of entry to be set. index, double Value to add to the vector entry. increment)Change an entry at the specified index. |
| public abstract RealVector | Returns: a new vector.vector to append to this one. v)Construct a new vector by appending a vector to this vector. |
| public abstract RealVector | Returns: a new vector.double to append. d)Construct a new vector by appending a double to this vector. |
| protected void | |
| protected void | checkIndices(final int
the index of the first entry of the subvector start, final int the index of the last entry of the subvector (inclusive) end)Checks that the indices of a subvector are valid. |
| protected void | checkVectorDimensions(RealVector
Vector to compare instance with. v)Check if instance and specified vectors have the same dimension. |
| protected void | checkVectorDimensions(int
Expected dimension. n)Check if instance dimension is equal to some expected value. |
| public RealVector | Returns: a vector containinga * this[i] + b * y[i] for all
i.Coefficient of a, double this.Coefficient of b, RealVector y.Vector with which y)this is linearly combined.Returns a new vector representing |
| public RealVector | Returns: this, with components equal to
a * this[i] + b * y[i] for all i.Weight of a, double this.Weight of b, RealVector y.Vector with which y)this is linearly combined.Updates |
| public abstract RealVector | |
| public double | Returns: the cosine of the angle between this vector andv.Vector. v)Computes the cosine of the angle between this vector and the argument. |
| public double | Returns: the scalar dot product between this instance andv.Vector with which dot product should be computed v)Compute the dot product of this vector with |
| public abstract RealVector | Returns: a vector containing this[i] / v[i] for all i.Vector by which instance elements must be divided. v)Element-by-element division. |
| public abstract RealVector | Returns: a vector containing this[i] * v[i] for all i.Vector by which instance elements must be multiplied v)Element-by-element multiplication. |
| public boolean | Returns: true if two vector objects are equal, false if
other is null, not an instance of RealVector, or
not equal to this RealVector instance.Object to test for equality. other)Overrides java. Test for the equality of two real vectors. |
| public abstract int | |
| public double | Returns: the distance between two vectors.Vector to which distance is requested. v)Distance between two vectors. |
| public abstract double | Returns: the vector entry atindex.Index location of entry to be fetched. index)Return the entry at the specified index. |
| public double | Returns: the distance between two vectors.Vector to which distance is requested. v)Distance between two vectors. |
| public double | |
| public double | Returns: the distance between two vectors.Vector to which distance is requested. v)Distance between two vectors. |
| public double | |
| public int | Returns: the index of the maximum entry or -1 if vector length is 0 or all entries areNaNGet the index of the maximum entry. |
| public double | Returns: the value of the maximum entry orNaN if all
entries are NaN.Get the value of the maximum entry. |
| public int | Returns: the index of the minimum entry or -1 if vector length is 0 or all entries areNaN.Get the index of the minimum entry. |
| public double | Returns: the value of the minimum entry orNaN if all
entries are NaN.Get the value of the minimum entry. |
| public double | |
| public abstract RealVector | Returns: a vector containing n elements.index of first element. index, int number of elements to be retrieved. n)Get a subvector from consecutive elements. |
| public int | |
| public abstract boolean | Returns: true if any coordinate of this vector is infinite and
none are NaN, false otherwise.Check whether any coordinate of this vector is infinite and none are |
| public abstract boolean | Returns: true if any coordinate of this vector is NaN,
false otherwise.Check whether any coordinate of this vector is |
| public Iterator | |
| public RealVector | Returns: a new vector.Function to apply to each entry. function)Acts as if implemented as: return copy().mapToSelf(function); |
| public RealVector | |
| public RealVector | |
| public RealVector | |
| public RealVector | |
| public RealVector | |
| public RealVector | |
| public RealVector | |
| public RealVector | |
| public RealVector | Returns: a reference to this vector.Function to apply to each entry. function)Acts as if it is implemented as:
Entry e = null;
for(Iterator<entry> it = iterator(); it.hasNext(); e = it.next()) {
e.setValue(function.value(e.getValue()));
}
|
| public RealMatrix | Returns: the matrix outer product between this instance andv.Vector with which outer product should be computed. v)Compute the outer product. |
| public RealVector | Returns: projection of the instance ontov.vector onto which instance must be projected. v)Find the orthogonal projection of this vector onto another vector. |
| public void | |
| public abstract void | |
| public abstract void | setSubVector(int
index of first element to be set. index, RealVector vector containing the values to set. v)Set a sequence of consecutive elements. |
| public Iterator | Returns: a sparse iterator.Create a sparse iterator over the vector, which may omit some entries. |
| public RealVector | |
| public double[] | Returns: an array containing a copy of the vector elements.Convert the vector to an array of |
| public void | |
| public RealVector | Returns: a unit vector pointing in direction of this vector.Creates a unit vector pointing in the direction of this vector. |
| public static RealVector | Returns: an unmodifiable view ofv.Vector for which an unmodifiable view is to be returned. v)Returns an unmodifiable view of the specified vector. |
| public double | Returns: the value returned byRealVectorPreservingVisitor#end()
at the end of the walkthe visitor to be used to process the entries of this
vector visitor)Visits (but does not alter) all entries of this vector in default order (increasing index). |
| public double | Returns: the value returned byRealVectorPreservingVisitor#end()
at the end of the walkvisitor to be used to process the entries of this vector visitor, final int the index of the first entry to be visited start, final int the index of the last entry to be visited (inclusive) end)Visits (but does not alter) some entries of this vector in default order (increasing index). |
| public double | Returns: the value returned byRealVectorChangingVisitor#end()
at the end of the walkthe visitor to be used to process and modify the entries
of this vector visitor)Visits (and possibly alters) all entries of this vector in default order (increasing index). |
| public double | Returns: the value returned byRealVectorChangingVisitor#end()
at the end of the walkvisitor to be used to process the entries of this vector visitor, final int the index of the first entry to be visited start, final int the index of the last entry to be visited (inclusive) end)Visits (and possibly alters) some entries of this vector in default order (increasing index). |
| public double | Returns: the value returned byRealVectorPreservingVisitor#end()
at the end of the walkthe visitor to be used to process the entries of this
vector visitor)Visits (but does not alter) all entries of this vector in optimized order. |
| public double | Returns: the value returned byRealVectorPreservingVisitor#end()
at the end of the walkvisitor to be used to process the entries of this vector visitor, final int the index of the first entry to be visited start, final int the index of the last entry to be visited (inclusive) end)Visits (but does not alter) some entries of this vector in optimized order. |
| public double | Returns: the value returned byRealVectorChangingVisitor#end()
at the end of the walkthe visitor to be used to process the entries of this
vector visitor)Visits (and possibly alters) all entries of this vector in optimized order. |
| public double | Returns: the value returned byRealVectorChangingVisitor#end()
at the end of the walkvisitor to be used to process the entries of this vector visitor, final int the index of the first entry to be visited start, final int the index of the last entry to be visited (inclusive) end)Visits (and possibly change) some entries of this vector in optimized order. |