diff --git a/src/main/java/de/unijena/cheminf/clustering/art2a/clustering/euclideanClustering/Art2aEuclideanDoubleClustering.java b/src/main/java/de/unijena/cheminf/clustering/art2a/clustering/euclideanClustering/Art2aEuclideanDoubleClustering.java index 8c22179..0bfb598 100644 --- a/src/main/java/de/unijena/cheminf/clustering/art2a/clustering/euclideanClustering/Art2aEuclideanDoubleClustering.java +++ b/src/main/java/de/unijena/cheminf/clustering/art2a/clustering/euclideanClustering/Art2aEuclideanDoubleClustering.java @@ -216,36 +216,6 @@ private double[][] getCheckedAndScaledDataMatrix(double[][] aDataMatrix) throws return aDataMatrix; } // - /** - * Method that calculates the distance of the first rho value by iterating the component of the input vector and - * subtracting each component from the scaling factor. After that the result is squared and the square root is - * taken. - */ - private int getFirstRhoCompetition(double [] tmpInputVector){ - double tmpSumOfRho = 0.0; - for (int i = 0; i < this.numberOfComponents; i++){ - double tmpRho = this.scalingFactor - tmpInputVector[i]; - tmpSumOfRho += tmpRho * tmpRho; - } - return (int) Math.sqrt(tmpSumOfRho); - } - /** - * Method that calculates the distance of the second rho value by iterating the components of the vectors with a - * for loop. Then each component is subtracted and squared. Finally, the square root is taken. - */ - private int getSecondRhoCompetition(double[] tmpInputVector, double[] tmpRow) { - if (tmpInputVector != tmpRow) { - throw new IllegalArgumentException("The vectors need to have the same dimension!"); - } - double tmpSumOfRhoForExistingClusters = 0.0; - for (int i = 0; i < this.numberOfComponents; i++) { - double tmpRhoForExistingClusters = tmpRow[i] - tmpInputVector[i]; - tmpSumOfRhoForExistingClusters += tmpRhoForExistingClusters * tmpRhoForExistingClusters; - } - //square root of the sum of Rho for existing clusters. - return (int) Math.sqrt(tmpSumOfRhoForExistingClusters); - } - // /** * At the end of each epoch, it is checked whether the system has converged or not. If the system has not * converged, a new epoch is performed, otherwise the clustering is completed successfully. @@ -424,28 +394,29 @@ public IArt2aClusteringResult getClusterResult(boolean anIsClusteringResultExpor // //sum of scaling factor and non normalized components! tmpRho = 0.0; - for (int i = 0; i < this.numberOfComponents; i++){ - double tmpDifferenceOfScalingFactorAndInput = this.scalingFactor - tmpInputVector[i]; + double tmpDifferenceOfScalingFactorAndInput; + for (int tmpInputVectorComponent = 0; tmpInputVectorComponent < this.numberOfComponents; tmpInputVectorComponent++){ + tmpDifferenceOfScalingFactorAndInput = this.scalingFactor - tmpInputVector[tmpInputVectorComponent]; tmpRho += tmpDifferenceOfScalingFactorAndInput * tmpDifferenceOfScalingFactorAndInput; } tmpWinnerClusterIndex = tmpNumberOfDetectedClusters; boolean tmpIsMatchingClusterAvailable = true; - // // // tmpRho) { - tmpRho = tmpRhoForExistingClusters; + if(tmpRhoForExistingClustersSquared > tmpRho) { + tmpRho = tmpRhoForExistingClustersSquared; tmpWinnerClusterIndex = tmpCurrentClusterMatrixRowIndex; tmpIsMatchingClusterAvailable = false; } @@ -473,11 +444,11 @@ public IArt2aClusteringResult getClusterResult(boolean anIsClusteringResultExpor } } //