Skip to content

Commit 2d8fa6f

Browse files
committed
Bug fix: distance between arrays of floats
1 parent 500d75a commit 2d8fa6f

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424
* Bug in Permutation.toString which was inserting an extra space at end.
2525
* Added validation checking for all permutation distance measures validating same length permutations (except for EditDistance which can handle that case).
2626
* Bug in ReversalDistance.max in case when permutation length is 2, and also added missing parameter validation.
27+
* Minor bug fix in KendallTauSequenceDistance in the case of distance between arrays of floats.
2728

2829
### CI/CD
2930
* Migrated build process from Ant to Maven, including GitHub workflows.

src/org/cicirello/sequences/distance/KendallTauSequenceDistance.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2019 Vincent A. Cicirello, <https://www.cicirello.org/>.
2+
* Copyright 2018-2021 Vincent A. Cicirello, <https://www.cicirello.org/>.
33
*
44
* This file is part of JavaPermutationTools (https://jpt.cicirello.org/).
55
*
@@ -72,13 +72,12 @@
7272
* assumes permutations of the integers from 0 to N-1.</p>
7373
*
7474
* <p>This distance metric, and both algorithms, is first described in the paper:<br>
75-
* V.A. Cicirello, <a href="https://www.cicirello.org/publications/cicirello2019arXiv.html" target=_top>"Kendall Tau
75+
* V.A. Cicirello, <a href="https://www.cicirello.org/publications/eai.13-7-2018.163925.pdf" target=_top>"Kendall Tau
7676
* Sequence Distance: Extending Kendall Tau from Ranks to Sequences,"</a>
77-
* arXiv preprint arXiv:1905.02752 [cs.DM], May 2019.</p>
77+
* Industrial Networks and Intelligent Systems, 7(23), Article e1, April 2020.</p>
7878
*
7979
* @author <a href=https://www.cicirello.org/ target=_top>Vincent A. Cicirello</a>, <a href=https://www.cicirello.org/ target=_top>https://www.cicirello.org/</a>
80-
* @version 1.19.6.10
81-
* @since 1.1
80+
* @version 1.30.2021
8281
*/
8382
public final class KendallTauSequenceDistance extends AbstractSequenceDistanceMeasurer {
8483

@@ -112,8 +111,6 @@ public KendallTauSequenceDistance() {
112111
* cost to hash objects, or if the objects are of a class that implements Comparable but
113112
* which does not provide an implementation of hashCode.</p>
114113
*
115-
* @since 1.2.3
116-
*
117114
* @param useAlternateAlg To use the alternate algorithm pass true. To use the default algorithm pass false.
118115
*/
119116
public KendallTauSequenceDistance(boolean useAlternateAlg) {
@@ -411,7 +408,7 @@ private int relabelElementsWithHash(double[] s1, double[] s2, int[][] relabeling
411408
}
412409

413410
private int relabelElementsWithHash(float[] s1, float[] s2, int[][] relabeling) {
414-
DoubleHT labelMap = new DoubleHT((int)(1.334 * relabeling.length)+2);
411+
FloatHT labelMap = new FloatHT((int)(1.334 * relabeling.length)+2);
415412
int current = -1;
416413
for (int i = 0; i < relabeling.length; i++) {
417414
if (!labelMap.containsKey(s1[i])) {

0 commit comments

Comments
 (0)