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[]normaliseSum(double[] a)
normalise Sum
double sumInv = 1.0 / sum(a);
for (int i = 0; i < a.length; i++)
    a[i] *= sumInv;
return a;
StringnormaliseUnicode(String unicodeText, char[] mappings)
normalise Unicode
String result = unicodeText;
for (int i = 0; i < mappings.length; i += 2) {
    result = result.replace(mappings[i], mappings[i + 1]);
return result;
voidnormalize(byte[] data, byte maximum, byte minimum)
Normalize the original byte data to specified range.
if (data.length == 0)
    return;
byte max = data[0];
byte min = data[0];
for (byte d : data) {
    if (d > max)
        max = d;
    if (d < min)
...
double[]normalize(double arr[])
normalize
double sum = fsum(arr);
for (int i = 0; i < arr.length; i++) {
    arr[i] = arr[i] / sum;
return arr;
voidnormalize(double wheelSpeeds[])
Normalize all wheel speeds if the magnitude of any wheel is greater than 1.0.
double maxMagnitude = Math.abs(wheelSpeeds[0]);
int i;
for (i = 1; i < wheelSpeeds.length; i++) {
    double temp = Math.abs(wheelSpeeds[i]);
    if (maxMagnitude < temp) {
        maxMagnitude = temp;
if (maxMagnitude > 1.0) {
    for (i = 0; i < wheelSpeeds.length; i++) {
        wheelSpeeds[i] = wheelSpeeds[i] / maxMagnitude;
voidnormalize(double[] a)
normalize
double sum = sum(a);
if (sum <= 0.0)
    return;
divide(a, sum);
sum = sum(a);
a[a.length - 1] = 1.0 - (sum - a[a.length - 1]);
voidnormalize(double[] a)
normalize
double total = sum(a);
for (int i = 0; i < a.length; i++) {
    a[i] /= total;
double[]normalize(double[] a)
normalize
double l = length(a);
if (l < 0.1) {
    l = 0.1;
double[] v = new double[a.length];
for (int i = 0; i < a.length; ++i) {
    v[i] = a[i] / l;
return v;
doublenormalize(double[] a)
This method normalizes the given array (vector) and returns the normalizing constant.
double sum = 0.0;
for (int i = 0; i < a.length; i++) {
    sum += a[i];
if (sum == 0) {
    sum = 1;
for (int i = 0; i < a.length; i++) {
...
voidnormalize(double[] a)
L1 normalization
double sum = 0;
for (double x : a)
    sum += x;
if (sum == 0)
    for (int i = 0; i < a.length; i++)
        a[i] = 1 / a.length;
else
    for (int i = 0; i < a.length; i++)
...