Java Utililty Methods Array Normalize

List of utility methods to do Array Normalize

Description

The list of methods to do Array Normalize are organized into topic(s).

Method

double[]normalizeToSumUpTo(double[] x, double sumUp)
normalize To Sum Up To
return normalizeToSumUpTo(x, x.length, sumUp);
char[]normalizeTrimmedText(char[] ch)
normalize Trimmed Text
char[] ch2 = new char[ch.length];
boolean inWhitespace = false;
int j = 0;
for (int i = 0; i < ch.length; i++) {
    char c = ch[i];
    boolean isWhitespace = Character.isWhitespace(c);
    if (isWhitespace && !inWhitespace) {
        ch2[j] = ' ';
...
voidNormalizeVec2D(double[] vec)
Normalize Vec D
double one_over_length = 1.0 / Math.sqrt(vec[0] * vec[0] + vec[1] * vec[1] + EPSILON);
vec[0] *= one_over_length;
vec[1] *= one_over_length;
;
voidnormalizeVector(double[] input)
This method normalizes the input vector to 1.
int index = 0;
double sum = 0;
while (index < input.length) {
    sum += input[index];
    index++;
index = 0;
while (index < input.length) {
...
Double[]normalizeVector(Double[] vector)
Takes a vector and returns it normal
Double norm = vectorLength(vector);
for (int i = 0; i < vector.length; i++) {
    vector[i] = vector[i] / norm;
return vector;
voidnormalizeVector(final double[] v)
normalize Vector
final double norm = Math.sqrt(innerProduct(v, v));
v[0] /= norm;
v[1] /= norm;
v[2] /= norm;
float[]normalizeVector(float[] samples)
Normalizes vector so that all values are in the range [0, 1]
float[] out = new float[samples.length];
float maxValue = findMaxAbs(samples);
if (maxValue != 0) {
    for (int i = 0; i < samples.length; i++) {
        out[i] = samples[i] / Math.abs(maxValue);
return out;
...
voidnormalizeVectorMax(double[] input)
normalize Vector Max
double max = getMax(input);
int index = 0;
while (index < input.length) {
    input[index] = input[index] / max;
    index++;
float[]normalizeVectorMaxMin(float[] samples)
Normalizes vector so that all values are in the range [0, 1]
float[] out = new float[samples.length];
float maxValue = findMax(samples);
float minValue = findMin(samples);
if (maxValue > minValue) {
    for (int i = 0; i < samples.length; i++) {
        out[i] = (samples[i] - minValue) / (maxValue - minValue);
} else {
...
float[][]normalizeVectors(float[][] vectors, boolean maxMin)
normalize Vectors
float[][] out = new float[vectors.length][];
for (int i = 0; i < vectors.length; i++) {
    if (!maxMin) {
        out[i] = normalizeVector(vectors[i]);
    } else {
        out[i] = normalizeVectorMaxMin(vectors[i]);
return out;