Java Array Normalize normalizeInnerPointDistanceMax(double[][] distances, double maxDist)

Here you can find the source of normalizeInnerPointDistanceMax(double[][] distances, double maxDist)

Description

normalizes the inner point distances of the point in the distance matrix, such that die maximum inner-point distance is maxDist

License

Open Source License

Parameter

Parameter Description
distances double[][] of inner-point distances
maxDist maximum inner-point distance after normalization

Return

the normalized distance matrix

Declaration

static double[][] normalizeInnerPointDistanceMax(double[][] distances,
        double maxDist) 

Method Source Code

//package com.java2s;
/*//ww w .  j  ava2s .c o  m
 * Copyright (C) 2013-14  Susanne Westphal
 * CONRAD is developed as an Open Source project under the GNU General Public License (GPL).
 */

public class Main {
    /**
     * normalizes the inner point distances of the point in the distance matrix, such that die maximum inner-point distance is maxDist
     * @param distances double[][] of inner-point distances
     * @param maxDist maximum inner-point distance after normalization
     * @return the normalized distance matrix
     */
    static double[][] normalizeInnerPointDistanceMax(double[][] distances,
            double maxDist) {

        double max = -1;
        for (int i = 0; i < distances.length; ++i) {
            for (int j = i + 1; j < distances[i].length; ++j) {
                if (max < distances[i][j] || max == -1) {
                    max = distances[i][j];
                }
            }
        }
        for (int i = 0; i < distances.length; ++i) {
            for (int j = 0; j < distances[i].length; ++j) {
                distances[i][j] = distances[i][j] / max * maxDist;
            }
        }
        return distances;

    }
}

Related

  1. normalizeHeightMap(float heightMap[])
  2. normalizeHeightMapCopy(float heightMap[])
  3. normalizeHistogram(int[] h)
  4. normalizeHistogram(int[] hist)
  5. normalizeHistogramToBase(int[] hist, double base)
  6. normalizeL2(double[] a)
  7. normalizeL2(double[] histogram)
  8. normalizeLengthInPlace(double[] in)
  9. normalizeLog(double[] logs)