org.inria.myriads.snoozenode.util
Class MathUtils

java.lang.Object
  extended by org.inria.myriads.snoozenode.util.MathUtils

public final class MathUtils
extends Object

Math utility.

Author:
Eugen Feller

Field Summary
static int RESOURCE_VECTOR_SIZE
          Size of the resource vectors.
 
Method Summary
static ArrayList<Double> addVectors(List<Double> firstVector, List<Double> secondVector)
          Adds two vectors.
static double computeEuclidNorm(List<Double> values)
          Computes the Euclid norm.
static double computeL1Norm(List<Double> values)
          Computes the L1 norm.
static double computeMaxNorm(List<Double> values)
          Computes the Max norm.
static ArrayList<Double> createCustomVector(double cpu, double memory, org.inria.myriads.snoozecommon.communication.virtualcluster.monitoring.NetworkDemand networkDemand)
          Creates virtual machine utilization vector.
static ArrayList<Double> createEmptyVector()
          Creates and empty vector.
static ArrayList<Double> divideVector(List<Double> vector, int divisor)
          Divides all values of a vector by a number.
static boolean isCorrectDimension(List<Double> firstVector, List<Double> secondVector)
          Verifies the dimensions.
static double roundDoubleValue(double value)
          Rounds a double value to the first two digits.
static ArrayList<Double> substractVector(List<Double> firstVector, List<Double> secondVector)
          Divides all values of a vector by a number.
static boolean vectorCompareIsGreater(List<Double> firstVector, List<Double> secondVector)
          Compares two vectors.
static boolean vectorCompareIsLess(List<Double> firstVector, List<Double> secondVector)
          Compares two vectors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE_VECTOR_SIZE

public static final int RESOURCE_VECTOR_SIZE
Size of the resource vectors.

See Also:
Constant Field Values
Method Detail

vectorCompareIsLess

public static boolean vectorCompareIsLess(List<Double> firstVector,
                                          List<Double> secondVector)
Compares two vectors.

Parameters:
firstVector - The first vector
secondVector - The second vector
Returns:
true if first is less, false otherwise

roundDoubleValue

public static double roundDoubleValue(double value)
Rounds a double value to the first two digits.

Parameters:
value - The original value
Returns:
The rounded value

vectorCompareIsGreater

public static boolean vectorCompareIsGreater(List<Double> firstVector,
                                             List<Double> secondVector)
Compares two vectors.

Parameters:
firstVector - The first vector
secondVector - The second vector
Returns:
true if first is greater, false otherwise

isCorrectDimension

public static boolean isCorrectDimension(List<Double> firstVector,
                                         List<Double> secondVector)
Verifies the dimensions.

Parameters:
firstVector - The first vector
secondVector - The second vector
Returns:
true if dimensions are ok, false otherwise

addVectors

public static ArrayList<Double> addVectors(List<Double> firstVector,
                                           List<Double> secondVector)
Adds two vectors.

Parameters:
firstVector - The first vector
secondVector - The second vector
Returns:
The new vector

divideVector

public static ArrayList<Double> divideVector(List<Double> vector,
                                             int divisor)
Divides all values of a vector by a number.

Parameters:
vector - The vector
divisor - The divisor
Returns:
The new vector

substractVector

public static ArrayList<Double> substractVector(List<Double> firstVector,
                                                List<Double> secondVector)
Divides all values of a vector by a number.

Parameters:
firstVector - The first vector
secondVector - The second vector
Returns:
The new vector

computeL1Norm

public static double computeL1Norm(List<Double> values)
Computes the L1 norm.

Parameters:
values - The data
Returns:
The L1 norm value

computeMaxNorm

public static double computeMaxNorm(List<Double> values)
Computes the Max norm.

Parameters:
values - The data
Returns:
The max norm value

createCustomVector

public static ArrayList<Double> createCustomVector(double cpu,
                                                   double memory,
                                                   org.inria.myriads.snoozecommon.communication.virtualcluster.monitoring.NetworkDemand networkDemand)
Creates virtual machine utilization vector.

Parameters:
cpu - The cpu utilization
memory - The memory usage
networkDemand - The network demand
Returns:
The vector of values

createEmptyVector

public static ArrayList<Double> createEmptyVector()
Creates and empty vector. s

Returns:
The vector of values

computeEuclidNorm

public static double computeEuclidNorm(List<Double> values)
Computes the Euclid norm.

Parameters:
values - The data
Returns:
The euclid norm value


Copyright © 2012. All Rights Reserved.