This repository has been archived by the owner on May 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Florian Lautenschlager
committed
Feb 19, 2016
1 parent
6cdebe9
commit f7b8454
Showing
31 changed files
with
916 additions
and
2,283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
language: java | ||
|
||
jdk: | ||
- oraclejdk8 | ||
|
||
before_install: | ||
- chmod +x gradlew | ||
|
||
script: ./gradlew build jacocoTestReport | ||
|
||
after_success: ./gradlew jacocoRootReport coveralls |
22 changes: 22 additions & 0 deletions
22
src/main/java/de/qaware/chronix/distance/BinaryDistance.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Arrays.java Jul 14, 2004 | ||
* | ||
* Copyright (c) 2004 Stan Salvador | ||
* [email protected] | ||
*/ | ||
|
||
package de.qaware.chronix.distance; | ||
|
||
|
||
import java.util.Arrays; | ||
|
||
public final class BinaryDistance implements DistanceFunction { | ||
public double calcDistance(double[] vector1, double[] vector2) { | ||
if (Arrays.equals(vector1, vector2)) { | ||
return 0.0; | ||
} else { | ||
return 1.0; | ||
} | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/de/qaware/chronix/distance/DistanceFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Arrays.java Jul 14, 2004 | ||
* | ||
* Copyright (c) 2004 Stan Salvador | ||
* [email protected] | ||
*/ | ||
|
||
package de.qaware.chronix.distance; | ||
|
||
|
||
public interface DistanceFunction { | ||
double calcDistance(double[] vector1, double[] vector2); | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/de/qaware/chronix/distance/DistanceFunctionFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Arrays.java Jul 14, 2004 | ||
* | ||
* Copyright (c) 2004 Stan Salvador | ||
* [email protected] | ||
*/ | ||
|
||
package de.qaware.chronix.distance; | ||
|
||
|
||
public final class DistanceFunctionFactory { | ||
public static DistanceFunction EUCLIDEAN_DIST_FN = new EuclideanDistance(); | ||
public static DistanceFunction MANHATTAN_DIST_FN = new ManhattanDistance(); | ||
public static DistanceFunction BINARY_DIST_FN = new BinaryDistance(); | ||
|
||
public static DistanceFunction getDistFnByName(String distFnName) { | ||
switch (distFnName) { | ||
case "EuclideanDistance": | ||
return EUCLIDEAN_DIST_FN; | ||
case "ManhattanDistance": | ||
return MANHATTAN_DIST_FN; | ||
case "BinaryDistance": | ||
return BINARY_DIST_FN; | ||
default: | ||
throw new IllegalArgumentException("There is no DistanceFunction for the name " + distFnName); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/de/qaware/chronix/distance/EuclideanDistance.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Arrays.java Jul 14, 2004 | ||
* | ||
* Copyright (c) 2004 Stan Salvador | ||
* [email protected] | ||
*/ | ||
|
||
package de.qaware.chronix.distance; | ||
|
||
|
||
public final class EuclideanDistance implements DistanceFunction { | ||
public double calcDistance(double[] vector1, double[] vector2) { | ||
double sqSum = 0.0; | ||
for (int x = 0; x < vector1.length; x++) | ||
sqSum += Math.pow(vector1[x] - vector2[x], 2.0); | ||
|
||
return Math.sqrt(sqSum); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/de/qaware/chronix/distance/ManhattanDistance.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Arrays.java Jul 14, 2004 | ||
* | ||
* Copyright (c) 2004 Stan Salvador | ||
* [email protected] | ||
*/ | ||
|
||
package de.qaware.chronix.distance; | ||
|
||
|
||
public final class ManhattanDistance implements DistanceFunction { | ||
public double calcDistance(double[] vector1, double[] vector2) { | ||
double diffSum = 0.0; | ||
for (int x = 0; x < vector1.length; x++) | ||
diffSum += Math.abs(vector1[x] - vector2[x]); | ||
|
||
return diffSum; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,4 @@ interface CostMatrix | |
double get(int col, int row); | ||
|
||
int size(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.