public class FloatArrayMath
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
protected |
FloatArrayMath() |
Modifier and Type | Method and Description |
---|---|
protected static int |
_commonLength(float[] array1,
float[] array2,
java.lang.String methodName)
Throw an exception if the two arrays are not of the same length,
or if either array is null.
|
static float[] |
add(float[] array,
float z)
Return a new array that is the formed by adding z to each element
of the input array.
|
static float[] |
add(float[] array1,
float[] array2)
Return a new array that is the element-by-element sum of the two
input arrays.
|
static float[] |
append(float[] array1,
float[] array2)
Return a new array that is the result of appending array2 to the end
of array1.
|
static float[] |
append(float[] array1,
int idx1,
int length1,
float[] array2,
int idx2,
int length2)
Return a new array that is the result of appending length2
elements of array2, starting from the array1[idx2] to length1
elements of array1, starting from array1[idx1].
|
static float[] |
applyBinaryOperation(FloatBinaryOperation op,
float[] array,
float z)
Return a new array that is formed by applying an instance of a
FloatBinaryOperation to each element in the input array
and z, using the array elements as the left operands and z
as the right operand in all cases.
|
static float[] |
applyBinaryOperation(FloatBinaryOperation op,
float[] array1,
float[] array2)
Return a new array that is formed by applying an instance of a
FloatBinaryOperation to the two arrays, element by element,
using the elements of the first array as the left operands and the
elements of the second array as the right operands.
|
static float[] |
applyBinaryOperation(FloatBinaryOperation op,
float z,
float[] array)
Return a new array that is formed by applying an instance of a
FloatBinaryOperation to each element in the input array,
using z as the left operand in all cases and the array elements
as the right operands (op.operate(z, array[i])).
|
static float[] |
applyUnaryOperation(FloatUnaryOperation op,
float[] array)
Return a new array that is formed by applying an instance of a
FloatUnaryOperation to each element in the input array
(op.operate(array[i])).
|
static float[] |
divide(float[] array,
float num)
Return a new array that is the element-by-element division of
the first array by the given value.
|
static float[] |
divideElements(float[] array1,
float[] array2)
Return a new array that is the element-by-element division of
the first array by the second array (array1[i] / array2[i]).
|
static float |
dotProduct(float[] array1,
float[] array2)
Return the dot product of the two arrays.
|
static float |
l2norm(float[] array)
Return the L2-norm of the array, that is, the square root of
the sum of the squares of the elements.
|
static float[] |
limit(float[] array,
float bottom,
float top)
Return a new array that is a copy of the argument except that
the elements are limited to lie within the specified range.
|
static float[] |
multiply(float[] array,
float factor)
Return a new array that is constructed from the argument by
multiplying each element in the array by the second argument, which is
a float.
|
static float[] |
multiply(float[] array1,
float[] array2)
Return a new array that is the element-by-element multiplication of
the two input arrays.
|
static float[] |
negative(float[] array)
Return a new array that is the formed by the additive inverse of each
element of the input array (-array[i]).
|
static float[] |
normalize(float[] array)
Return a new array that is formed by scaling the array so that
it has a L2-norm of 1.
|
static float[] |
padMiddle(float[] array,
int newLength)
Return a new array of floats that is formed by padding the
middle of the array with 0's.
|
static float[] |
resize(float[] array,
int newLength)
Return a new array of length newLength that is formed by
either truncating or padding the input array.
|
static float[] |
resize(float[] array,
int newLength,
int startIdx)
Return a new array of length newLength that is formed by
either truncating or padding the input array.
|
static float[] |
scale(float[] array,
float scaleFactor)
Return a new array of floats produced by scaling the input
array elements by scaleFactor.
|
static float[] |
subtract(float[] array1,
float[] array2)
Return a new array that is the element-by-element difference of the
two input arrays, i.e. the first array minus the second array
(array1[i] - array2[i]).
|
static float |
sumOfSquares(float[] array)
Return the sum of the squares of all of the elements in the array.
|
static Complex[] |
toComplexArray(float[] array)
Return a new array that is formed by converting the floats in
the argument array to complex numbers.
|
static double[] |
toDoubleArray(float[] array)
Return a new array that is formed by converting the floats in
the argument array to doubles.
|
static int[] |
toIntegerArray(float[] array)
Return a new array that is formed by converting the floats in
the argument array to integers.
|
static long[] |
toLongArray(float[] array)
Return a new array that is formed by converting the floats in
the argument array to longs.
|
static java.lang.String |
toString(float[] array)
Return a new String representing the array, formatted as
in Java array initializers.
|
static java.lang.String |
toString(float[] array,
java.lang.String elementDelimiter,
java.lang.String vectorBegin,
java.lang.String vectorEnd)
Return a new String representing the array, formatted as
specified by the ArrayStringFormat argument.
|
static boolean |
within(float[] array1,
float[] array2,
float maxError)
Return true if all the distances between corresponding elements
array1 and array2 are all less than or equal to
the corresponding elements in maxError.
|
static boolean |
within(float[] array1,
float[] array2,
float[] maxError)
Return true if all the distances between corresponding elements
array1 and array2 are all less than or equal to
the corresponding elements in maxError.
|
public static final float[] add(float[] array, float z)
public static final float[] add(float[] array1, float[] array2)
public static final float[] append(float[] array1, float[] array2)
public static final float[] append(float[] array1, int idx1, int length1, float[] array2, int idx2, int length2)
array1
- The first array of floats.idx1
- The starting index for array1.length1
- The number of elements of array1 to use.array2
- The second array of floats, which is appended.idx2
- The starting index for array2.length2
- The number of elements of array2 to append.public static final float[] applyBinaryOperation(FloatBinaryOperation op, float[] array, float z)
public static final float[] applyBinaryOperation(FloatBinaryOperation op, float z, float[] array)
public static final float[] applyBinaryOperation(FloatBinaryOperation op, float[] array1, float[] array2)
public static final float[] applyUnaryOperation(FloatUnaryOperation op, float[] array)
public static final float[] divideElements(float[] array1, float[] array2)
array1
- The first array of floats.array2
- The second array of floats.public static final float[] divide(float[] array, float num)
array
- The array of float numbers.num
- The float scalar.public static final float dotProduct(float[] array1, float[] array2)
public static final float l2norm(float[] array)
public static final float[] limit(float[] array, float bottom, float top)
array
- An array of floats.bottom
- The bottom limit.top
- The top limit.public static final float[] multiply(float[] array1, float[] array2)
public static final float[] multiply(float[] array, float factor)
array
- An array of floats.factor
- A float.public static final float[] negative(float[] array)
public static final float[] normalize(float[] array)
public static final float[] padMiddle(float[] array, int newLength)
array
- An array of floats.newLength
- The desired length of the returned array.public static final float[] resize(float[] array, int newLength)
array
- An array of floats.newLength
- The desired length of the output array.public static final float[] resize(float[] array, int newLength, int startIdx)
array
- An array of floats.newLength
- The desired length of the output array.startIdx
- The starting index for the input array.public static final float[] scale(float[] array, float scaleFactor)
public static final float[] subtract(float[] array1, float[] array2)
public static final float sumOfSquares(float[] array)
public static final Complex[] toComplexArray(float[] array)
array
- An array of floats.public static final double[] toDoubleArray(float[] array)
array
- An array of float.public static final int[] toIntegerArray(float[] array)
array
- An array of float.public static final long[] toLongArray(float[] array)
array
- An array of float.public static final java.lang.String toString(float[] array)
public static final java.lang.String toString(float[] array, java.lang.String elementDelimiter, java.lang.String vectorBegin, java.lang.String vectorEnd)
public static final boolean within(float[] array1, float[] array2, float maxError)
array1
- The first array.array2
- The second array.maxError
- The threshold for the magnitude of the difference.java.lang.IllegalArgumentException
- If the arrays are not of the same
length.public static final boolean within(float[] array1, float[] array2, float[] maxError)
array1
- The first array.array2
- The second array.maxError
- The array of thresholds for the magnitudes of
the difference.java.lang.IllegalArgumentException
- If the arrays are not of the same
length.protected static final int _commonLength(float[] array1, float[] array2, java.lang.String methodName)
array1
- The first array of floats.array2
- The second array of floats.methodName
- A String representing the method name of the caller,
without parentheses.