Interface Vector<S extends Space>
- Type Parameters:
S- Type of the space.
- All Superinterfaces:
Point<S>, Serializable
-
Method Summary
Modifier and TypeMethodDescriptionAdd a scaled vector to the instance.Add a vector to the instance.doubleCompute the distance between the instance and another vector according to the L2 norm.doubleCompute the distance between the instance and another vector according to the L1 norm.doubledistanceInf(Vector<S> v) Compute the distance between the instance and another vector according to the L∞ norm.doubledistanceSq(Vector<S> v) Compute the square of the distance between the instance and another vector.doubledotProduct(Vector<S> v) Compute the dot-product of the instance and another vector.doublegetNorm()Get the L2 norm for the vector.doublegetNorm1()Get the L1 norm for the vector.doubleGet the L∞ norm for the vector.doubleGet the square of the norm for the vector.getZero()Get the null vector of the vectorial space or origin point of the affine space.booleanReturns true if any coordinate of this vector is infinite and none are NaN; false otherwisenegate()Get the opposite of the instance.Get a normalized vector aligned with the instance.scalarMultiply(double a) Multiply the instance by a scalar.Subtract a scaled vector from the instance.Subtract a vector from the instance.toString(NumberFormat format) Get a string representation of this vector.
-
Method Details
-
getZero
-
getNorm1
double getNorm1()Get the L1 norm for the vector.- Returns:
- L1 norm for the vector
-
getNorm
double getNorm()Get the L2 norm for the vector.- Returns:
- Euclidean norm for the vector
-
getNormSq
double getNormSq()Get the square of the norm for the vector.- Returns:
- square of the Euclidean norm for the vector
-
getNormInf
double getNormInf()Get the L∞ norm for the vector.- Returns:
- L∞ norm for the vector
-
add
-
add
-
subtract
-
subtract
-
negate
-
normalize
Get a normalized vector aligned with the instance.- Returns:
- a new normalized vector
- Throws:
MathArithmeticException- if the norm is zero
-
scalarMultiply
-
isInfinite
boolean isInfinite()Returns true if any coordinate of this vector is infinite and none are NaN; false otherwise- Returns:
- true if any coordinate of this vector is infinite and none are NaN; false otherwise
-
distance1
Compute the distance between the instance and another vector according to the L1 norm.Calling this method is equivalent to calling:
q.subtract(p).getNorm1()except that no intermediate vector is built- Parameters:
v- second vector- Returns:
- the distance between the instance and p according to the L1 norm
-
distance
Compute the distance between the instance and another vector according to the L2 norm.Calling this method is equivalent to calling:
q.subtract(p).getNorm()except that no intermediate vector is built- Parameters:
v- second vector- Returns:
- the distance between the instance and p according to the L2 norm
-
distanceInf
Compute the distance between the instance and another vector according to the L∞ norm.Calling this method is equivalent to calling:
q.subtract(p).getNormInf()except that no intermediate vector is built- Parameters:
v- second vector- Returns:
- the distance between the instance and p according to the L∞ norm
-
distanceSq
Compute the square of the distance between the instance and another vector.Calling this method is equivalent to calling:
q.subtract(p).getNormSq()except that no intermediate vector is built- Parameters:
v- second vector- Returns:
- the square of the distance between the instance and p
-
dotProduct
-
toString
Get a string representation of this vector.- Parameters:
format- the custom format for components- Returns:
- a string representation of this vector
-