Here you can find the source of normalizeInnerPointDistanceMax(double[][] distances, double maxDist)
Parameter | Description |
---|---|
distances | double[][] of inner-point distances |
maxDist | maximum inner-point distance after normalization |
static double[][] normalizeInnerPointDistanceMax(double[][] distances, double maxDist)
//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; } }