public class Vector
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
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[] |
of(int n,
double v)
Returns a vector filled with the given value.
|
static double[][] |
orthogonalize(double[][] vs)
Returns the orthogonal basis for the specified vectors using the
Gram-Schmidt process.
|
static double[] |
orthogonalize(double[] u,
java.lang.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 . |
public static double[] of(int n, double v)
n
- the length of the vectorv
- the fill valuepublic static double[] subtract(double[] u, double[] v)
u - v
.
The two vectors must be of the same length.u
- the first vectorv
- the second vectoru - v
java.lang.IllegalArgumentException
- if the two vectors are not the same lengthpublic static double[] add(double[] u, double[] v)
u + v
. The two
vectors must be of the same length.u
- the first vectorv
- the second vectoru + v
java.lang.IllegalArgumentException
- if the two vectors are not the same lengthpublic static double[] multiply(double a, double[] u)
a * u
.a
- the scalar valueu
- the vectora * u
public static double[] negate(double[] u)
-u
. This is
equivalent to calling multiply(-1, u)
.u
- the vector-u
public static double[] divide(double[] u, double a)
u / a
.u
- the vectora
- the scalar value (the denominator)u / a
public static double dot(double[] u, double[] v)
u
- the first vectorv
- the second vectorjava.lang.IllegalArgumentException
- if the two vectors are not the same lengthpublic static double magnitude(double[] u)
u
- the vectorpublic static double[] normalize(double[] u)
u
- the vectorjava.lang.IllegalArgumentException
- if the specified vector contains all zerospublic static double[] project(double[] u, double[] v)
u
onto v
. The two vectors must
be the same length.u
- the vector being projectedv
- the vector onto which u
is being projectedu
onto v
java.lang.IllegalArgumentException
- if the two vectors are not the same
lengthpublic static double[][] orthogonalize(double[][] vs)
vs
- the vectors to be orthogonalizedpublic static double[] orthogonalize(double[] u, java.lang.Iterable<double[]> vs)
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); }
u
- the vectorvs
- the already orthogonalized vectorsu
orthogonal to the already orthogonalized
vectors vs
public static double[] mean(double[][] vs)
vs
- the vectorsjava.lang.IllegalArgumentException
- if the specified vectors is emptypublic static boolean isZero(double[] u)
true
if the specified vector contains all zeros;
false
otherwise.u
- the vectortrue
if the specified vector contains all zeros;
false
otherwiseCopyright 2009-2024 David Hadka and other contributors. All rights reserved.
Licensed under the GNU Lesser General Public License.
Return to the MOEA Framework homepage.