MOEA Framework 2.5
API Specification

org.moeaframework.util
Class Vector

java.lang.Object
  extended by org.moeaframework.util.Vector

public class Vector
extends Object

Mathematical operators for manipulating vectors (double arrays).


Method Summary
static double[] add(double[] u, double[] v)
          Returns the sum of the two specified vectors, u + v.
static double[] divide(double[] u, double a)
          Returns the scalar division of the specified vector, u / a.
static double dot(double[] u, double[] v)
          Returns the dot (inner) product of the two specified vectors.
static boolean isZero(double[] u)
          Returns true if the specified vector contains all zeros; false otherwise.
static double magnitude(double[] u)
          Returns the magnitude (Euclidean norm) of the specified vector.
static double[] mean(double[][] vs)
          Returns the mean vector of the specified vectors.
static double[] multiply(double a, double[] u)
          Returns the scalar multiple of the specified vector, a * u.
static double[] negate(double[] u)
          Returns the negation of the specified vector, -u.
static double[] normalize(double[] u)
          Returns the specified vector normalized to have a magnitude of 1.
static double[][] orthogonalize(double[][] vs)
          Returns the orthogonal basis for the specified vectors using the Gram-Schmidt process.
static double[] orthogonalize(double[] u, Iterable<double[]> vs)
          Returns the vector u orthogonal to the already orthogonalized vectors vs.
static double[] project(double[] u, double[] v)
          Returns the projection of u onto v.
static double[] subtract(double[] u, double[] v)
          Returns the difference between the two specified vectors, u - v.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

subtract

public static double[] subtract(double[] u,
                                double[] v)
Returns the difference between the two specified vectors, u - v. The two vectors must be of the same length.

Parameters:
u - the first vector
v - the second vector
Returns:
the difference between the two specified vectors, u - v
Throws:
IllegalArgumentException - if the two vectors are not the same length

add

public static double[] add(double[] u,
                           double[] v)
Returns the sum of the two specified vectors, u + v. The two vectors must be of the same length.

Parameters:
u - the first vector
v - the second vector
Returns:
the sum of the two specified vectors, u + v
Throws:
IllegalArgumentException - if the two vectors are not the same length

multiply

public static double[] multiply(double a,
                                double[] u)
Returns the scalar multiple of the specified vector, a * u.

Parameters:
a - the scalar value
u - the vector
Returns:
the scalar multiple of the specified vector, a * u

negate

public static double[] negate(double[] u)
Returns the negation of the specified vector, -u. This is equivalent to calling multiply(-1, u).

Parameters:
u - the vector
Returns:
the negation of the specified vector, -u

divide

public static double[] divide(double[] u,
                              double a)
Returns the scalar division of the specified vector, u / a.

Parameters:
u - the vector
a - the scalar value (the denominator)
Returns:
the scalar division of the specified vector, u / a

dot

public static double dot(double[] u,
                         double[] v)
Returns the dot (inner) product of the two specified vectors. The two vectors must be the same length.

Parameters:
u - the first vector
v - the second vector
Returns:
the dot (inner) product of the two specified vectors
Throws:
IllegalArgumentException - if the two vectors are not the same length

magnitude

public static double magnitude(double[] u)
Returns the magnitude (Euclidean norm) of the specified vector.

Parameters:
u - the vector
Returns:
the magnitude (Euclidean norm) of the specified vector

normalize

public static double[] normalize(double[] u)
Returns the specified vector normalized to have a magnitude of 1. The specified vector must contain at least one non-zero component; otherwise an exception is thrown.

Parameters:
u - the vector
Returns:
the specified vector normalized to have a magnitude of 1
Throws:
IllegalArgumentException - if the specified vector contains all zeros

project

public static double[] project(double[] u,
                               double[] v)
Returns the projection of u onto v. The two vectors must be the same length.

Parameters:
u - the vector being projected
v - the vector onto which u is being projected
Returns:
the projection of u onto v
Throws:
IllegalArgumentException - if the two vectors are not the same length

orthogonalize

public static double[][] orthogonalize(double[][] vs)
Returns the orthogonal basis for the specified vectors using the Gram-Schmidt process.

Parameters:
vs - the vectors to be orthogonalized
Returns:
the orthogonal basis

orthogonalize

public static double[] orthogonalize(double[] u,
                                     Iterable<double[]> vs)
Returns the vector u orthogonal to the already orthogonalized vectors vs. This method is provided to allow incremental construction of the orthogonal basis:
 List<double[]> basis = new ArrayList<double[]>();
 for (double[] v : vectors) {
        double[] e = orthogonalize(v, basis);
        basis.add(e);
 }
 

Parameters:
u - the vector
vs - the already orthogonalized vectors
Returns:
the vector u orthogonal to the already orthogonalized vectors vs

mean

public static double[] mean(double[][] vs)
Returns the mean vector of the specified vectors.

Parameters:
vs - the vectors
Returns:
the mean vector of the specified vectors
Throws:
IllegalArgumentException - if the specified vectors is empty

isZero

public static boolean isZero(double[] u)
Returns true if the specified vector contains all zeros; false otherwise.

Parameters:
u - the vector
Returns:
true if the specified vector contains all zeros; false otherwise

MOEA Framework 2.5
API Specification

Copyright 2009-2015 MOEA Framework. All rights reserved.
Licensed under the GNU Lesser General Public License.
Return to the MOEA Framework homepage. Hosted by Get MOEA Framework at SourceForge.net. Fast, secure and Free Open Source software downloads