Class RealProperties
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanallClose(double[] src1, double[] src2) Checks if all data of two arrays are 'close'.static booleanallClose(double[] src1, double[] src2, double relTol, double absTol) Checks if all data of two arrays are 'close'.static intargmax(double... entries) Finds the index of the maximum value within a tensor.static intargmaxAbs(double... entries) Finds the first index of the maximum absolute value within a tensor.static intargmin(double... entries) Finds the index of the minimum value within a tensor.static intargminAbs(double... entries) Finds the index of the minimum absolute value within a tensor.static booleanisFinite(double[] src) Checks if all elements of a tensor are finite.static booleanisInfinite(double[] src) Checks if any of the elements of a tensor is infinite.static booleanisNaN(double[] src) Checks if any of the elements of a tensor contain aDouble.NaN.static booleanisNeg(double[] entries) Checks if a tensor only contain negative values.static booleanisOnes(double[] src) Checks if this tensor only contains ones.static booleanisPos(double[] entries) Checks if a tensor only contain positive values.static booleanisZeros(double[] src) Checks if an array contains only zeros.static doublemax(double... entries) Computes the maximum value in a tensor.static doublemaxAbs(double... entries) Computes the maximum absolute value in a tensor.static doublemaxAbs(double[] src, int start, int n, int stride) Returns the maximum absolute value amongnelements in the arraysrc, starting at indexstartand advancing bystridefor each subsequent element.static doublemin(double... entries) Computes the minimum value in a tensor.static doubleminAbs(double... entries) Computes the minimum absolute value in a tensor.static doubleminAbs(double[] src, int start, int n, int stride) Returns the minimum absolute value amongnelements in the arraysrc, starting at indexstartand advancing bystridefor each subsequent element.
-
Method Details
-
isPos
public static boolean isPos(double[] entries) Checks if a tensor only contain positive values. If the tensor is sparse, only the non-zero data are considered.- Parameters:
entries- Entries of the tensor in question.- Returns:
trueif the tensor contains only positive values;falseotherwise.
-
isNeg
public static boolean isNeg(double[] entries) Checks if a tensor only contain negative values. If the tensor is sparse, only the non-zero data are considered.- Parameters:
entries- Entries of the tensor in question.- Returns:
trueif the tensor contains only negative values;falseotherwise.
-
isZeros
public static boolean isZeros(double[] src) Checks if an array contains only zeros.- Parameters:
src- Array to check if it only contains zeros.- Returns:
- True if the
srcarray contains only zeros.
-
allClose
public static boolean allClose(double[] src1, double[] src2) Checks if all data of two arrays are 'close'.- Parameters:
src1- First array in comparison.src2- Second array in comparison.- Returns:
- True if both arrays have the same length and all data are 'close' element-wise, i.e.
elements
aandbat the same positions in the two arrays respectively and satisfy|a-b| <= (1E-08 + 1E-05*|b|). Otherwise, returns false. - See Also:
-
allClose
public static boolean allClose(double[] src1, double[] src2, double relTol, double absTol) Checks if all data of two arrays are 'close'.- Parameters:
src1- First array in comparison.src2- Second array in comparison.- Returns:
- True if both arrays have the same length and all data are 'close' element-wise, i.e.
elements
aandbat the same positions in the two arrays respectively and satisfy|a-b| <= (absTol + relTol*|b|). Otherwise, returns false. - See Also:
-
isOnes
public static boolean isOnes(double[] src) Checks if this tensor only contains ones.- Parameters:
src- Elements of the tensor.- Returns:
trueif this tensor only contains ones;falseotherwise.
-
isNaN
public static boolean isNaN(double[] src) Checks if any of the elements of a tensor contain aDouble.NaN.- Parameters:
src- Entries of the tensor.- Returns:
trueis any entry ofsrcisDouble.NaN;falseotherwise.
-
isFinite
public static boolean isFinite(double[] src) Checks if all elements of a tensor are finite.- Parameters:
src- Entries of the tensor.- Returns:
falseis any entry ofsrcis notfinite. Otherwise, returnstrue.
-
isInfinite
public static boolean isInfinite(double[] src) Checks if any of the elements of a tensor is infinite.- Parameters:
src- Entries of the tensor.- Returns:
trueis any entry ofsrcisinfinite;falseotherwise.
-
min
public static double min(double... entries) Computes the minimum value in a tensor. Note, if the data array is empty, this method will return 0 allowing this method to be used for real sparse or dense tensors.- Parameters:
entries- Entries of the tensor.- Returns:
- The minimum value in the tensor.
-
max
public static double max(double... entries) Computes the maximum value in a tensor. Note, if the data array is empty, this method will return 0 allowing this method to be used for real sparse or dense tensors.- Parameters:
entries- Entries of the tensor.- Returns:
- The maximum value in the tensor.
-
minAbs
public static double minAbs(double... entries) Computes the minimum absolute value in a tensor. Note, if the data array is empty, this method will return 0 allowing this method to be used for real sparse or dense tensors.- Parameters:
entries- Entries of the tensor.- Returns:
- The minimum absolute value in the tensor.
-
maxAbs
public static double maxAbs(double... entries) Computes the maximum absolute value in a tensor. Note, if the data array is empty, this method will return 0 allowing this method to be used for real sparse or dense tensors.- Parameters:
entries- Entries of the tensor.- Returns:
- The maximum absolute value in the tensor.
-
argmin
public static int argmin(double... entries) Finds the index of the minimum value within a tensor.- Parameters:
entries- The data of the tensor.- Returns:
- The index of the minimum values within
data. Ifdata.length == 0then -1 will be returned.
-
argmax
public static int argmax(double... entries) Finds the index of the maximum value within a tensor.- Parameters:
entries- The data of the tensor.- Returns:
- The index of the maximum values within
data. Ifdata.length == 0then -1 will be returned.
-
argminAbs
public static int argminAbs(double... entries) Finds the index of the minimum absolute value within a tensor.- Parameters:
entries- The data of the tensor.- Returns:
- The index of the minimum absolute values within
data. Ifdata.length == 0then -1 will be returned.
-
argmaxAbs
public static int argmaxAbs(double... entries) Finds the first index of the maximum absolute value within a tensor.- Parameters:
entries- The data of the tensor.- Returns:
- The index of the maximum absolute values within
data. Ifdata.length == 0then -1 will be returned.
-
maxAbs
public static double maxAbs(double[] src, int start, int n, int stride) Returns the maximum absolute value among
nelements in the arraysrc, starting at indexstartand advancing bystridefor each subsequent element.More formally, this method examines the elements at indices:
start,start + stride,start + 2*stride, ...,start + (n-1)*stride.This method will propagate
Double.NaNvalues meaning if at least one element considered isDouble.NaNthe result of this method will beDouble.NaN.This method may be used to find the maximum absolute value within the row or column of a
matrixaas follows:- Maximum absolute value within row
i:maxAbs(a.data, factor, i*a.numCols, a.numCols, 1); - Maximum absolute value within column
j:maxAbs(a.data, factor, j, a.numRows, a.numRows);
- Parameters:
src- The array to search for maximum absolute value within.start- The starting index insrcto search.n- The number of elements to consider withinsrc1.stride- The gap (in indices) between consecutive elements to search withinsrc.- Returns:
- If any element of
srcisDouble.NaNthen the result will beDouble.NaN. - Otherwise, the maximum absolute value found among all elements considered in
src.
- If any element of
- Throws:
IndexOutOfBoundsException- If the specified range extends beyond the array bounds.
- Maximum absolute value within row
-
minAbs
public static double minAbs(double[] src, int start, int n, int stride) Returns the minimum absolute value among
nelements in the arraysrc, starting at indexstartand advancing bystridefor each subsequent element.More formally, this method examines the elements at indices:
start,start + stride,start + 2*stride, ...,start + (n-1)*stride.This method will propagate
Double.NaNvalues meaning if at least one element considered isDouble.NaNthe result of this method will beDouble.NaN.This method may be used to find the minimum absolute value within the row or column of a
matrixaas follows:- Minimum absolute value within row
i:maxAbs(a.data, i*a.numCols, a.numCols, 1); - Minimum absolute value within column
j:maxAbs(a.data, j, a.numRows, a.numRows);
- Parameters:
src- The array to search for Minimum absolute value within.start- The starting index insrcto search.n- The number of elements to consider withinsrc1.stride- The gap (in indices) between consecutive elements to search withinsrc.- Returns:
- If
src.length == 0thenDouble.POSITIVE_INFINITYwill be returned. - If any element of
srcisDouble.NaNthen the result will beDouble.NaN. - Otherwise, the minimum absolute value found among all elements considered inn
src.
- If
- Throws:
IndexOutOfBoundsException- If the specified range extends beyond the array bounds.
- Minimum absolute value within row
-