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

doublenorm(final double[] x)
Returns sqrt(x*x), the Euclidean norm.
return Math.sqrt(normSquared(x));
doublenorm(float[] data)
norm
double d = 0;
for (int i = 0; i < data.length; i++)
    d += data[i] * data[i];
return Math.sqrt(d);
doublenorm(int D, double vec[])
norm
double norm = 0.0D;
for (int i = D - 1; i >= 0; i--)
    norm += vec[i] * vec[i];
return Math.sqrt(norm);
doublenorm2(double[] vec)
returns the norm2 of an array
double result = 0.0;
for (int i = 0; i < vec.length; ++i)
    result += Math.pow(vec[i], 2);
return Math.pow(result, 0.5);
doublenorm2(double[] vector)
Get the norm of a 2 dimension vector
return distance(vector, new double[] { 0, 0 });
doublenorm2(double[] x)
norm
double result = innerProduct(x, x);
return Math.pow(result, 0.5);
doublenorm2DoubleArray(double[] v)
norm Double Array
double normSum = 0;
for (double d : v) {
    normSum += d * d;
return Math.sqrt(normSum);
doublenorm_variance(double[] array)
norvariance
double sum = 0;
for (int i = 0; i < array.length; i++) {
    sum += array[i];
double[] temp = new double[array.length];
for (int i = 0; i < array.length; i++) {
    temp[i] = array[i] / sum;
double avg = 1.0 / array.length;
double var = 0;
for (int i = 0; i < temp.length; i++) {
    var += (temp[i] - avg) * (temp[i] - avg);
return var;
double[]norm_vec(double[] vec)
norvec
double norm = Math.sqrt(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]);
double[] temp = { vec[0] / norm, vec[1] / norm, vec[2] / norm };
return temp;
double[]normal0(double[] p1, double[] p2, double[] p3)
computes the unit normal vector on the plane p1p2p3 as normalize(p2p1 x p2p3)
double[] v21 = subtract(p1, p2);
double[] v23 = subtract(p3, p2);
return (normalize(crossprod(v21, v23)));