Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
Licence changes.
Browse files Browse the repository at this point in the history
More tests.
  • Loading branch information
FlorianLautenschlager committed Feb 23, 2016
1 parent 8866090 commit c2c047f
Show file tree
Hide file tree
Showing 23 changed files with 140 additions and 92 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 QAware GmbH
Copyright (c) 2016 Stan Salvador ([email protected]), Philip Chan ([email protected]), QAware GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 QAware GmbH
* Copyright (c) 2016 Stan Salvador ([email protected]), Philip Chan ([email protected]), QAware GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 QAware GmbH
* Copyright (c) 2016 Stan Salvador ([email protected]), Philip Chan ([email protected]), QAware GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 QAware GmbH
* Copyright (c) 2016 Stan Salvador ([email protected]), Philip Chan ([email protected]), QAware GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 QAware GmbH
* Copyright (c) 2016 Stan Salvador ([email protected]), Philip Chan ([email protected]), QAware GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 QAware GmbH
* Copyright (c) 2016 Stan Salvador ([email protected]), Philip Chan ([email protected]), QAware GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 QAware GmbH
* Copyright (c) 2016 Stan Salvador ([email protected]), Philip Chan ([email protected]), QAware GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/qaware/chronix/dt/IntList.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 QAware GmbH
* Copyright (c) 2016 Stan Salvador ([email protected]), Philip Chan ([email protected]), QAware GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/qaware/chronix/dt/ListUtil.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 QAware GmbH
* Copyright (c) 2016 Stan Salvador ([email protected]), Philip Chan ([email protected]), QAware GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/qaware/chronix/dt/LongList.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 QAware GmbH
* Copyright (c) 2016 Stan Salvador ([email protected]), Philip Chan ([email protected]), QAware GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/qaware/chronix/dtw/CostMatrix.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 QAware GmbH
* Copyright (c) 2016 Stan Salvador ([email protected]), Philip Chan ([email protected]), QAware GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/de/qaware/chronix/dtw/DTW.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 QAware GmbH
* Copyright (c) 2016 Stan Salvador ([email protected]), Philip Chan ([email protected]), QAware GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -105,7 +105,7 @@ private static TimeWarpInfo dynamicTimeWarp(MultivariateTimeSeries tsI, Multivar
final WarpPath minCostPath = new WarpPath(maxI + maxJ - 1);
int i = maxI;
int j = maxJ;
minCostPath.addFirst(i, j);
minCostPath.add(i, j);
while ((i > 0) || (j > 0)) {
// Find the costs of moving in all three possible directions (left,
// down, and diagonal (down and left at the same time).
Expand Down Expand Up @@ -143,7 +143,7 @@ else if (i <= j) // leftCost==rightCost > diagCost
i--;

// Add the current step to the warp path.
minCostPath.addFirst(i, j);
minCostPath.add(i, j);
}

return new TimeWarpInfo(minimumCost, minCostPath, tsI.size(), tsJ.size());
Expand Down Expand Up @@ -209,7 +209,7 @@ private static TimeWarpInfo constrainedTimeWarp(MultivariateTimeSeries tsI, Mult
final WarpPath minCostPath = new WarpPath(maxI + maxJ - 1);
int i = maxI;
int j = maxJ;
minCostPath.addFirst(i, j);
minCostPath.add(i, j);
while ((i > 0) || (j > 0)) {
// Find the costs of moving in all three possible directions (left,
// down, and diagonal (down and left at the same time).
Expand Down Expand Up @@ -247,7 +247,7 @@ else if (i <= j) // leftCost==rightCost > diagCost
i--;

// Add the current step to the warp path.
minCostPath.addFirst(i, j);
minCostPath.add(i, j);
} // end while loop

return new TimeWarpInfo(minimumCost, minCostPath, tsI.size(), tsJ.size());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/qaware/chronix/dtw/ExpandedResWindow.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 QAware GmbH
* Copyright (c) 2016 Stan Salvador ([email protected]), Philip Chan ([email protected]), QAware GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/qaware/chronix/dtw/FastDTW.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 QAware GmbH
* Copyright (c) 2016 Stan Salvador ([email protected]), Philip Chan ([email protected]), QAware GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 QAware GmbH
* Copyright (c) 2016 Stan Salvador ([email protected]), Philip Chan ([email protected]), QAware GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/qaware/chronix/dtw/SearchWindow.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 QAware GmbH
* Copyright (c) 2016 Stan Salvador ([email protected]), Philip Chan ([email protected]), QAware GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/qaware/chronix/dtw/TimeWarpInfo.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 QAware GmbH
* Copyright (c) 2016 Stan Salvador ([email protected]), Philip Chan ([email protected]), QAware GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
111 changes: 44 additions & 67 deletions src/main/java/de/qaware/chronix/dtw/WarpPath.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 QAware GmbH
* Copyright (c) 2016 Stan Salvador ([email protected]), Philip Chan ([email protected]), QAware GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -26,6 +26,8 @@

import de.qaware.chronix.dt.IntList;
import de.qaware.chronix.matrix.ColMajorCell;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

import java.util.NoSuchElementException;

Expand All @@ -34,96 +36,67 @@
* @author f.lautenschlager
*/
public final class WarpPath {
private final IntList tsIindexes; // ArrayList of Integer
private final IntList tsJindexes; // ArrayList of Integer

public WarpPath() {
tsIindexes = new IntList();
tsJindexes = new IntList();
}
private final IntList tsIindexes;
private final IntList tsJindexes;


public WarpPath(int initialCapacity) {
tsIindexes = new IntList(initialCapacity);
tsJindexes = new IntList(initialCapacity);
}


/**
* @return the size of the warp path
*/
public int size() {
return tsIindexes.size();
}

/**
* @return the min i index (last element), -1 if empty
*/
public int minI() {
return tsIindexes.get(tsIindexes.size() - 1);
if (tsIindexes.size() > 0) {
return tsIindexes.get(tsIindexes.size() - 1);
}
return -1;
}

/**
* @return the min j index
*/
public int minJ() {
return tsJindexes.get(tsJindexes.size() - 1);
if (tsJindexes.size() > 0) {
return tsJindexes.get(tsJindexes.size() - 1);
}
return -1;
}

/**
* @return max i index (first element), -1 if empty
*/
public int maxI() {
return tsIindexes.get(0);
if (tsIindexes.size() > 0) {
return tsIindexes.get(0);
}
return -1;
}

/**
* @return max j index (first element), -1 if empty
*/
public int maxJ() {
return tsJindexes.get(0);
if (tsJindexes.size() > 0) {
return tsJindexes.get(0);
}
return -1;
}

public void addFirst(int i, int j) {
public void add(int i, int j) {
tsIindexes.add(i);
tsJindexes.add(j);
}

public void addLast(int i, int j) {
tsIindexes.add(0, i);
tsJindexes.add(0, j);
}


public IntList getMatchingIndexesForI(int i) {
int index = tsIindexes.indexOf(i);
if (index < 0)
throw new InternalError("ERROR: index '" + i + " is not in the " + "warp path.");
final IntList matchingJs = new IntList(tsIindexes.size());
while (index < tsIindexes.size() && tsIindexes.get(index) == i)
matchingJs.add(tsJindexes.get(index++));

return matchingJs;
}


public IntList getMatchingIndexesForJ(int j) {
int index = tsJindexes.indexOf(j);
if (index < 0)
throw new InternalError("ERROR: index '" + j + " is not in the " + "warp path.");
final IntList matchingIs = new IntList(tsJindexes.size());
while (index < tsJindexes.size() && tsJindexes.get(index) == j)
matchingIs.add(tsIindexes.get(index++));

return matchingIs;
}


// Create a new WarpPath that is the same as THIS WarpPath, but J is the reference template, rather than I.
public WarpPath invertedCopy() {
final WarpPath newWarpPath = new WarpPath();
for (int x = 0; x < tsIindexes.size(); x++)
newWarpPath.addLast(tsJindexes.get(x), tsIindexes.get(x));

return newWarpPath;
}


// Swap I and J so that the warp path now indicates that J is the template rather than I.
public void invert() {
for (int x = 0; x < tsIindexes.size(); x++) {
final int temp = tsIindexes.get(x);
tsIindexes.set(x, tsJindexes.get(x));
tsJindexes.set(x, temp);
}
}


public ColMajorCell get(int index) {
if ((index > this.size()) || (index < 0))
throw new NoSuchElementException();
Expand All @@ -132,6 +105,7 @@ public ColMajorCell get(int index) {
}


@Override
public String toString() {
StringBuilder outStr = new StringBuilder("[");
for (int x = 0; x < tsIindexes.size(); x++) {
Expand All @@ -145,6 +119,7 @@ public String toString() {
}


@Override
public boolean equals(Object obj) {
if ((obj instanceof WarpPath)) // trivial false test
{
Expand All @@ -163,9 +138,11 @@ public boolean equals(Object obj) {
return false;
}


@Override
public int hashCode() {
return tsIindexes.hashCode() * tsJindexes.hashCode();
return new HashCodeBuilder()
.append(tsIindexes)
.append(tsJindexes)
.toHashCode();
}

}
2 changes: 1 addition & 1 deletion src/main/java/de/qaware/chronix/dtw/WindowMatrix.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 QAware GmbH
* Copyright (c) 2016 Stan Salvador ([email protected]), Philip Chan ([email protected]), QAware GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/qaware/chronix/matrix/ColMajorCell.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 QAware GmbH
* Copyright (c) 2016 Stan Salvador ([email protected]), Philip Chan ([email protected]), QAware GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 QAware GmbH
* Copyright (c) 2016 Stan Salvador ([email protected]), Philip Chan ([email protected]), QAware GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

0 comments on commit c2c047f

Please sign in to comment.