public interface Vector
| Modifier and Type | Method and Description |
|---|---|
double |
at(int i)
Return the element at index i, where indexing begins at 0.
|
double |
dotProduct(Vector other)
Compute and return the dot product of this vector and the given vector.
|
double[] |
elements()
The elements of the vector as an array of primitive doubles.
|
static Vector |
from(double... elements)
Create a new vector from the given elements.
|
Vector |
minus(double scalar)
Subtract the given scalar from this vector and return the resulting vector.
|
Vector |
minus(Vector other)
Subtract the given vector from this vector and return the resulting vector.
|
double |
norm()
Compute and return the L2 length of this vector.
|
static Vector |
ones(int n)
Create a new vector of ones with the given size.
|
Matrix |
outerProduct(Vector other)
Compute and return the outer product of this vector and the given vector.
|
Vector |
plus(Vector other)
Add this vector to the given vector and return the resulting vector.
|
Vector |
push(double value)
Push the provided value to the front of this vector and return the resulting vector.
|
Vector |
scaledBy(double alpha)
Scale this vector by the given scalar and return the resulting vector.
|
int |
size()
The number of elements in this vector.
|
double |
sum()
Compute and return the sum of the elements of this vector.
|
double |
sumOfSquares()
Compute and return the sum of squared elements of this vector.
|
static Vector |
zeros(int n)
Create a new vector of zeros with the given size.
|
static Vector ones(int n)
n - the size of the new vector.static Vector zeros(int n)
n - the size of the new vector.static Vector from(double... elements)
elements - the elements of the new vector.double[] elements()
double at(int i)
i - the index of the element.int size()
Vector plus(Vector other)
other - the vector to add to this vector.Vector minus(Vector other)
other - the vector to subtract from this vector.Vector minus(double scalar)
scalar - the scalar to subtract from this vector.Vector scaledBy(double alpha)
alpha - the scalar to scale this vector by.double dotProduct(Vector other)
other - the vector to take the dot product with.Matrix outerProduct(Vector other)
other - the vector to compute the outer product of this vector with.double norm()
double sum()
double sumOfSquares()
Vector push(double value)
value - the value to push to the front of the vector.