public class FractionArrayMath
extends java.lang.Object
Unless explicitly noted otherwise, all array arguments are assumed to be non-null. If a null array is passed to a method, a NullPointerException will be thrown in the method or called methods.
Modifier | Constructor and Description |
---|---|
protected |
FractionArrayMath() |
Modifier and Type | Method and Description |
---|---|
protected static int |
_commonLength(Fraction[] array1,
Fraction[] 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 Fraction[] |
add(Fraction[] array,
Fraction z)
Return a new array that is the formed by adding z to each element
of the input array.
|
static Fraction[] |
add(Fraction[] array1,
Fraction[] array2)
Return a new array that is the element-by-element sum of the two
input arrays.
|
static Fraction[] |
allocCopy(Fraction[] array)
Return a new array that is a copy of the array argument.
|
static Fraction[] |
append(Fraction[] array1,
Fraction[] array2)
Return a new array that is the result of appending array2 to the end
of array1.
|
static Fraction[] |
append(Fraction[] array1,
int idx1,
int length1,
Fraction[] array2,
int idx2,
int length2)
Return a new array that is the result of appending length2
elements of array2, starting from the array2[idx2] to length1
elements of array1, starting from array1[idx1].
|
static Fraction[] |
divide(Fraction[] num,
Fraction[] den)
Return a new array that is the element-by-element division of
the first array by the second array.
|
static Fraction |
dotProduct(Fraction[] array1,
Fraction[] array2)
Return the dot product of the two arrays.
|
static boolean |
equals(Fraction[] array1,
Fraction[] array2)
Returns true if the two input arrays have all elements
equal.
|
static Fraction[] |
multiply(Fraction[] array,
Fraction 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 Fraction.
|
static Fraction[] |
multiply(Fraction[] array1,
Fraction[] array2)
Return a new array that is the element-by-element multiplication of
the two input arrays.
|
static Fraction[] |
negative(Fraction[] array)
Return a new array that is the formed by the additive inverse of each
element of the input array (-array[i]).
|
static Fraction[] |
subtract(Fraction[] array1,
Fraction[] 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 Fraction |
sum(Fraction[] array)
Return the sum of the elements in the array.
|
static double[] |
toDoubleArray(Fraction[] array)
Return a new array that is formed by converting the Fractions in
the argument array to doubles.
|
static java.lang.String |
toString(Fraction[] array)
Return a new String representing the array, formatted as
in Java array initializers.
|
static java.lang.String |
toString(Fraction[] 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.
|
public static final Fraction[] add(Fraction[] array, Fraction z)
public static final Fraction[] add(Fraction[] array1, Fraction[] array2)
public static final Fraction[] allocCopy(Fraction[] array)
array
- An array of Fractions.public static final Fraction[] append(Fraction[] array1, Fraction[] array2)
public static final Fraction[] append(Fraction[] array1, int idx1, int length1, Fraction[] array2, int idx2, int length2)
array1
- The first array of Fractions.idx1
- The starting index for array1.length1
- The number of elements of array1 to use.array2
- The second array of Fractions, which is appended.idx2
- The starting index for array2.length2
- The number of elements of array2 to append.public static final Fraction[] divide(Fraction[] num, Fraction[] den)
num
- The numerator array of Fractions.den
- The denominator array of Fractions.public static final Fraction dotProduct(Fraction[] array1, Fraction[] array2)
public static final boolean equals(Fraction[] array1, Fraction[] array2)
array1
- The first input array.array2
- The second input array.public static final Fraction[] multiply(Fraction[] array1, Fraction[] array2)
public static final Fraction[] multiply(Fraction[] array, Fraction factor)
array
- An array of Fractions.factor
- A Fraction.public static final Fraction[] negative(Fraction[] array)
public static final Fraction[] subtract(Fraction[] array1, Fraction[] array2)
public static final Fraction sum(Fraction[] array)
public static final double[] toDoubleArray(Fraction[] array)
array
- An array of Fractions.public static final java.lang.String toString(Fraction[] array)
public static final java.lang.String toString(Fraction[] array, java.lang.String elementDelimiter, java.lang.String vectorBegin, java.lang.String vectorEnd)
protected static final int _commonLength(Fraction[] array1, Fraction[] array2, java.lang.String methodName)
array1
- The first array of Fractions.array2
- The second array of Fractions.methodName
- A String representing the method name of the caller,
without parentheses.