net.sf.tweety.commons.util

## Class VectorTools

• java.lang.Object
• net.sf.tweety.commons.util.VectorTools

• ```public class VectorTools
extends java.lang.Object```
This class contains some auxiliary methods for working with vectors.
Author:
Matthias Thimm
• ### Constructor Summary

Constructors
Constructor and Description
`VectorTools()`
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static double` ```manhattanDistance(double[] left, double[] right)```
Computes the Manhattan distance between the two given vectors.
`static double` ```manhattanDistance(java.util.List<java.lang.Double> left, java.util.List<java.lang.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 zero
`static double` `manhattanDistanceToZero(java.util.List<java.lang.Double> values)`
Computes the Manhattan distance of the given value vector to zero
`static 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
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Constructor Detail

• #### VectorTools

`public VectorTools()`
• ### Method Detail

• #### midPoint

```public static double[] midPoint(double[] left,
double[] right)```
Computes the midpoint of the two given vectors.
Parameters:
`left` -
`right` -
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` -
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` -
`right` -
Returns:
the Manhattan distance between the two given vectors.
• #### manhattanDistance

```public static double manhattanDistance(java.util.List<java.lang.Double> left,
java.util.List<java.lang.Double> right)```
Computes the Manhattan distance between the two given lists.
Parameters:
`left` -
`right` -
Returns:
the Manhattan distance between the two given lists.
• #### manhattanDistanceToZero

`public static double manhattanDistanceToZero(java.util.List<java.lang.Double> values)`
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` -
`sum` -
Returns:
the normalized array