public final class VectorMath extends Object
Modifier and Type | Method and Description |
---|---|
static double |
cosineSimilarity(float[] x,
float[] y,
double normY)
Computes cosine similarity of values in two given arrays, when the norm of one array is
known in advance, which is a not-uncommon case.
|
static double |
dot(float[] x,
float[] y) |
static double |
norm(double[] x) |
static double |
norm(float[] x) |
static double[] |
parseVector(String[] values) |
static float[] |
randomVectorF(int features,
org.apache.commons.math3.random.RandomGenerator random) |
static double[] |
transposeTimesSelf(Collection<float[]> M) |
public static double dot(float[] x, float[] y)
x
- one arrayy
- the other arraypublic static double norm(float[] x)
x
- vector for whom norm to be calculatedpublic static double norm(double[] x)
x
- vector for whom norm to be calculatedpublic static double cosineSimilarity(float[] x, float[] y, double normY)
x
- one arrayy
- the other arraynormY
- norm of ypublic static double[] transposeTimesSelf(Collection<float[]> M)
M
- tall, skinny matrixpublic static double[] parseVector(String[] values)
values
- numeric values as String
sdouble[]
public static float[] randomVectorF(int features, org.apache.commons.math3.random.RandomGenerator random)
features
- dimension of vectorrandom
- random number generatorCopyright © 2014–2018. All rights reserved.