Package org.tweetyproject.commons.util
Class VectorTools
java.lang.Object
org.tweetyproject.commons.util.VectorTools
This class contains some auxiliary methods for
working with vectors.
- Author:
- Matthias Thimm
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
manhattanDistance
(double[] left, double[] right) Computes the Manhattan distance between the two given vectors.static double
manhattanDistance
(List<Double> left, List<Double> right) Computes the Manhattan distance between the two given lists.static double
manhattanDistanceToZero
(double[] values) Computes the Manhattan distance of the given value vector to zerostatic double
manhattanDistanceToZero
(List<Double> values) Computes the Manhattan distance of the given value vector to zerostatic double[]
midPoint
(double[] left, double[] right) Computes the midpoint of the two given vectors.static double[]
normalize
(double[] v, double sum) Normalizes the given vector such that the sum of the elements equals "sum"static double
sum
(double[] v) Computes the sum of the elements in v
-
Constructor Details
-
VectorTools
public VectorTools()
-
-
Method Details
-
midPoint
public static double[] midPoint(double[] left, double[] right) Computes the midpoint of the two given vectors.- Parameters:
left
- some vectorright
- some vector- Returns:
- the midpoint of the two given vectors.
-
sum
public static double sum(double[] v) Computes the sum of the elements in v- Parameters:
v
- some vector- Returns:
- the sum of the elements in v
-
manhattanDistance
public static double manhattanDistance(double[] left, double[] right) Computes the Manhattan distance between the two given vectors.- Parameters:
left
- some vectorright
- some vector- Returns:
- the Manhattan distance between the two given vectors.
-
manhattanDistance
Computes the Manhattan distance between the two given lists.- Parameters:
left
- some vectorright
- some vector- Returns:
- the Manhattan distance between the two given lists.
-
manhattanDistanceToZero
Computes the Manhattan distance of the given value vector to zero- Parameters:
values
- a list of doubles.- Returns:
- the distance to zero
-
manhattanDistanceToZero
public static double manhattanDistanceToZero(double[] values) Computes the Manhattan distance of the given value vector to zero- Parameters:
values
- a list of doubles.- Returns:
- the distance to zero
-
normalize
public static double[] normalize(double[] v, double sum) Normalizes the given vector such that the sum of the elements equals "sum"- Parameters:
v
- some vectorsum
- some vector- Returns:
- the normalized array
-