public class VectorUtil
extends java.lang.Object
Constructor and Description |
---|
VectorUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
assertDimensionalitiesAllEqual(java.lang.Iterable<? extends Vectorizable> data,
int dimensionality)
Asserts that all of the dimensionalities of the vectors in the
given set of data equal the given dimensionality.
|
static Vector |
divideByNorm1(Vector input)
Returns a new vector whose elements are the elements of the original
vector, divided by the 1-norm of the vector (the sum of the absolute
values of the elements).
|
static void |
divideByNorm1Equals(Vector vector)
Divides all of the given elements of the vector by the 1-norm (the sum
of the absolute values of the elements).
|
static Vector |
divideByNorm2(Vector input)
Returns a new vector whose elements are the elements of the original
vector, divided by the 2-norm of the vector (the square root of the sum
of the squared values of the elements).
|
static void |
divideByNorm2Equals(Vector vector)
Divides all of the given elements of the vector by the 2-norm (the square
root of the sum of the squared values of the elements).
|
static Vector |
interpolateLinear(Vectorizable first,
Vectorizable second,
double percent)
Performs linear interpolation between two vectors.
|
static Vector |
interpolateLinear(Vector first,
Vector second,
double percent)
Performs linear interpolation between two vectors.
|
static int |
safeGetDimensionality(Vector vector)
Gets the dimensionality of the given vector, if it is not null.
|
static int |
safeGetDimensionality(Vectorizable vector)
Gets the dimensionality of the given vector, if it is not null.
|
public static int safeGetDimensionality(Vectorizable vector)
vector
- The vector to get the dimensionality of.public static int safeGetDimensionality(Vector vector)
vector
- The vector to get the dimensionality of.public static Vector divideByNorm1(Vector input)
input
- The vector to divide by its 1-norm.public static void divideByNorm1Equals(Vector vector)
vector
- The vector to divide the elements by the 1-norm. It is modified by
this method.public static Vector divideByNorm2(Vector input)
input
- The vector to divide by its 2-norm.public static void divideByNorm2Equals(Vector vector)
vector
- The vector to divide the elements by the 2-norm. It is modified by
this method.public static Vector interpolateLinear(Vectorizable first, Vectorizable second, double percent)
first
- The first vector. Sometimes this is referred to as x.second
- The second vector. Sometimes this is referred to as y.percent
- A value between 0.0 and 1.0 to interpolate between the two vectors.
Sometimes this is also referred to as alpha.public static Vector interpolateLinear(Vector first, Vector second, double percent)
first
- The first vector. Sometimes this is referred to as x.second
- The second vector. Sometimes this is referred to as y.percent
- A value between 0.0 and 1.0 to interpolate between the two vectors.
Sometimes this is also referred to as alpha.public static void assertDimensionalitiesAllEqual(java.lang.Iterable<? extends Vectorizable> data, int dimensionality)
data
- A collection of input-output pairs.dimensionality
- The dimensionality that all the inputs must have.DimensionalityMismatchException
- If the dimensionalities are not all equal.