Class Vectors
- java.lang.Object
-
- org.apache.commons.geometry.euclidean.internal.Vectors
-
public final class Vectors extends java.lang.Object
This class consists exclusively of static vector utility methods.
-
-
Constructor Summary
Constructors Modifier Constructor Description private
Vectors()
Private constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double
checkedNorm(double norm)
Throws anIllegalArgumentException
if the given norm value is not real (ie, not NaN or infinite) or zero.static double
checkedNorm(Vector<?> vec)
Returns the vector's norm value, throwing anIllegalArgumentException
if the value is not real (ie, not NaN or infinite) or zero.static java.lang.IllegalArgumentException
illegalNorm(double norm)
Return an exception indicating an illegal norm value.static boolean
isRealNonZero(double value)
Returns true if the given value is real (ie, not NaN or infinite) and not equal to zero.static double
linearCombination(double a1, double b1, double a2, double b2)
Compute the linear combination \(a_1 b_1 + a_2 b_2 \) with high accuracy.static double
linearCombination(double a1, double b1, double a2, double b2, double a3, double b3)
Compute the linear combination \(a_1 b_1 + a_2 b_2 + a_3 b_3 \) with high accuracy.static double
norm(double x)
Get the L2 norm (commonly known as the Euclidean norm) for the vector with the given components.static double
norm(double x1, double x2)
Get the L2 norm (commonly known as the Euclidean norm) for the vector with the given components.static double
norm(double x1, double x2, double x3)
Get the L2 norm (commonly known as the Euclidean norm) for the vector with the given components.static double
normSq(double x)
Get the square of the L2 norm (also known as the Euclidean norm) for the vector with the given components.static double
normSq(double x1, double x2)
Get the square of the L2 norm (also known as the Euclidean norm) for the vector with the given components.static double
normSq(double x1, double x2, double x3)
Get the square of the L2 norm (also known as the Euclidean norm) for the vector with the given components.
-
-
-
Method Detail
-
isRealNonZero
public static boolean isRealNonZero(double value)
Returns true if the given value is real (ie, not NaN or infinite) and not equal to zero.- Parameters:
value
- the value to test- Returns:
- true if
value
is not NaN, infinite, or zero; otherwise false
-
checkedNorm
public static double checkedNorm(double norm)
Throws anIllegalArgumentException
if the given norm value is not real (ie, not NaN or infinite) or zero. The argument is returned to allow this method to be called inline.- Parameters:
norm
- vector norm value- Returns:
- the validated norm value
- Throws:
java.lang.IllegalArgumentException
- if the given norm value is NaN, infinite, or zero
-
checkedNorm
public static double checkedNorm(Vector<?> vec)
Returns the vector's norm value, throwing anIllegalArgumentException
if the value is not real (ie, not NaN or infinite) or zero.- Parameters:
vec
- vector to obtain the real, non-zero norm of- Returns:
- the validated norm value
- Throws:
java.lang.IllegalArgumentException
- if the vector norm value is NaN, infinite, or zero
-
illegalNorm
public static java.lang.IllegalArgumentException illegalNorm(double norm)
Return an exception indicating an illegal norm value.- Parameters:
norm
- illegal norm value- Returns:
- exception indicating an illegal norm value
-
norm
public static double norm(double x)
Get the L2 norm (commonly known as the Euclidean norm) for the vector with the given components. This corresponds to the common notion of vector magnitude or length and is defined as the square root of the sum of the squares of all vector components.- Parameters:
x
- vector component- Returns:
- L2 norm for the vector with the given components
- See Also:
- L2 Norm
-
norm
public static double norm(double x1, double x2)
Get the L2 norm (commonly known as the Euclidean norm) for the vector with the given components. This corresponds to the common notion of vector magnitude or length and is defined as the square root of the sum of the squares of all vector components.- Parameters:
x1
- first vector componentx2
- second vector component- Returns:
- L2 norm for the vector with the given components
- See Also:
- L2 Norm
-
norm
public static double norm(double x1, double x2, double x3)
Get the L2 norm (commonly known as the Euclidean norm) for the vector with the given components. This corresponds to the common notion of vector magnitude or length and is defined as the square root of the sum of the squares of all vector components.- Parameters:
x1
- first vector componentx2
- second vector componentx3
- third vector component- Returns:
- L2 norm for the vector with the given components
- See Also:
- L2 Norm
-
normSq
public static double normSq(double x)
Get the square of the L2 norm (also known as the Euclidean norm) for the vector with the given components. This is equal to the sum of the squares of all vector components.- Parameters:
x
- vector component- Returns:
- square of the L2 norm for the vector with the given components
- See Also:
norm(double)
-
normSq
public static double normSq(double x1, double x2)
Get the square of the L2 norm (also known as the Euclidean norm) for the vector with the given components. This is equal to the sum of the squares of all vector components.- Parameters:
x1
- first vector componentx2
- second vector component- Returns:
- square of the L2 norm for the vector with the given components
- See Also:
norm(double, double)
-
normSq
public static double normSq(double x1, double x2, double x3)
Get the square of the L2 norm (also known as the Euclidean norm) for the vector with the given components. This is equal to the sum of the squares of all vector components.- Parameters:
x1
- first vector componentx2
- second vector componentx3
- third vector component- Returns:
- square of the L2 norm for the vector with the given components
- See Also:
norm(double, double, double)
-
linearCombination
public static double linearCombination(double a1, double b1, double a2, double b2)
Compute the linear combination \(a_1 b_1 + a_2 b_2 \) with high accuracy.- Parameters:
a1
- first factor of the first termb1
- second factor of the first terma2
- first factor of the second termb2
- second factor of the seconf term- Returns:
- linear combination.
- See Also:
Sum
-
linearCombination
public static double linearCombination(double a1, double b1, double a2, double b2, double a3, double b3)
Compute the linear combination \(a_1 b_1 + a_2 b_2 + a_3 b_3 \) with high accuracy.- Parameters:
a1
- first factor of the first termb1
- second factor of the first terma2
- first factor of the second termb2
- second factor of the seconf terma3
- first factor of the third termb3
- second factor of the third term- Returns:
- linear combination.
- See Also:
Sum
-
-