Class RealProperties
java.lang.Object
org.flag4j.operations.common.real.RealProperties
This class provides low level methods for checking tensor properties. These methods can be applied to
either sparse or dense real tensors.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
allClose
(double[] src1, double[] src2) Checks if all entries of two arrays are 'close'.static boolean
allClose
(double[] src1, double[] src2, double relTol, double absTol) Checks if all entries of two arrays are 'close'.static boolean
isNeg
(double[] entries) Checks if a tensor only contain negative values.static boolean
isPos
(double[] entries) Checks if a tensor only contain positive values.static boolean
isZeros
(double[] src) Checks if an array contains only zeros.
-
Constructor Details
-
RealProperties
private RealProperties()
-
-
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 entries are considered.- Parameters:
entries
- Entries of the tensor in question.- Returns:
- True if the tensor contains only positive values. Otherwise, returns false.
-
isNeg
public static boolean isNeg(double[] entries) Checks if a tensor only contain negative values. If the tensor is sparse, only the non-zero entries are considered.- Parameters:
entries
- Entries of the tensor in question.- Returns:
- True if the tensor contains only negative values. Otherwise, returns false.
-
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
src
array contains only zeros.
-
allClose
public static boolean allClose(double[] src1, double[] src2) Checks if all entries 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 entries are 'close' element-wise, i.e.
elements
a
andb
at the same positions in the two arrays respectively and satisfy|a-b| <= (1E-05 + 1E-08*|b|)
. Otherwise, returns false. - See Also:
-
allClose
public static boolean allClose(double[] src1, double[] src2, double relTol, double absTol) Checks if all entries 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 entries are 'close' element-wise, i.e.
elements
a
andb
at the same positions in the two arrays respectively and satisfy|a-b| <= (absTol + relTol*|b|)
. Otherwise, returns false. - See Also:
-