ikr.simlib.support

## Class Vectors

• java.lang.Object
• ikr.simlib.support.Vectors

• public final class Vectors
extends java.lang.Object
This class contains support functions for vector math.
• ### Constructor Summary

Constructors
Constructor and Description
Vectors()
• ### Method Summary

Methods
Modifier and Type Method and Description
static double[] add(double[] vecA, double[] vecB)
Adds each element from two vectors and returns the result as a new vector.
static double length(double[] vec)
Calculates the (geometric) length of a vector.
static double[] max(double[] vecA, double[] vecB)
Creates a new vector containing the larger elements from both vectors, that is r[n] = max(a[n], b[n]).
static double[] min(double[] vecA, double[] vecB)
Creates a new vector containing the smaller elements from both vectors, that is r[n] = min(a[n], b[n]).
static void normalize(double[] vec)
Normalizes all elements of a vector.
static double sum(double[] vec)
Calculates the sum of a vector.
• ### Methods inherited from class java.lang.Object

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

• #### Vectors

public Vectors()
• ### Method Detail

public static double[] add(double[] vecA,
double[] vecB)
Adds each element from two vectors and returns the result as a new vector.
Returns:
the new vector containing the per element sum
• #### max

public static double[] max(double[] vecA,
double[] vecB)
Creates a new vector containing the larger elements from both vectors, that is r[n] = max(a[n], b[n]).
Returns:
the new vector containing the larger elements
• #### min

public static double[] min(double[] vecA,
double[] vecB)
Creates a new vector containing the smaller elements from both vectors, that is r[n] = min(a[n], b[n]).
Returns:
the new vector containing the smaller elements
• #### sum

public static double sum(double[] vec)
Calculates the sum of a vector.
Returns:
the sum of all elements
• #### length

public static double length(double[] vec)
Calculates the (geometric) length of a vector.
Returns:
the geometric length of the vector
• #### normalize

public static void normalize(double[] vec)
Normalizes all elements of a vector.