Class Compare
java.lang.Object
jcuda.utils.Compare
Utility functions for comparing arrays.
Some of the functions are ported from the CUTIL comparison functions.
Some of the functions are ported from the CUTIL comparison functions.
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
compare
(byte[] reference, byte[] data) Returns whether the given arrays are equalstatic boolean
compare
(byte[] reference, byte[] data, float epsilon) Checks if two arrays are equal within the given limits.static boolean
compare
(byte[] reference, byte[] data, float epsilon, float threshold) Checks if two arrays are equal within the given limits.static boolean
compare
(float[] reference, float[] data) Returns whether the given arrays are equalstatic boolean
compare
(float[] reference, float[] data, float epsilon) Checks if two arrays are equal within the given limits.static boolean
compare
(float[] reference, float[] data, float epsilon, float threshold) Checks if two arrays are equal within the given limits.static boolean
compare
(int[] reference, int[] data) Returns whether the given arrays are equalstatic boolean
compare
(int[] reference, int[] data, float epsilon) Checks if two arrays are equal within the given limits.static boolean
compare
(int[] reference, int[] data, float epsilon, float threshold) Checks if two arrays are equal within the given limits.static boolean
compareL2
(float[] reference, float[] data, float epsilon) Checks if two arrays are equal using the L2 norm.static void
setVerbose
(boolean verbose) Set the flag which indicates whether the output will be verbose and printing information about the differences between the arrays that are compared.
-
Method Details
-
setVerbose
public static void setVerbose(boolean verbose) Set the flag which indicates whether the output will be verbose and printing information about the differences between the arrays that are compared.- Parameters:
verbose
- Whether the output will be verbose
-
compare
public static boolean compare(float[] reference, float[] data) Returns whether the given arrays are equal- Parameters:
reference
- The reference arraydata
- the actual data array- Returns:
- Whether the given arrays are equal
-
compare
public static boolean compare(int[] reference, int[] data) Returns whether the given arrays are equal- Parameters:
reference
- The reference arraydata
- the actual data array- Returns:
- Whether the given arrays are equal
-
compare
public static boolean compare(byte[] reference, byte[] data) Returns whether the given arrays are equal- Parameters:
reference
- The reference arraydata
- the actual data array- Returns:
- Whether the given arrays are equal
-
compare
public static boolean compare(byte[] reference, byte[] data, float epsilon, float threshold) Checks if two arrays are equal within the given limits. If the arrays have different lengths, only the number of elements of the shorter array will be compared.- Parameters:
reference
- The reference arraydata
- the actual data arrayepsilon
- The epsilon for the comparison, must be >=0threshold
- The % of array elements that may be differ by more than the given epsilon- Returns:
- Whether the arrays are equal within the given limits.
- Throws:
jcuda.CudaException
- If the given epsilon is negative
-
compare
public static boolean compare(byte[] reference, byte[] data, float epsilon) Checks if two arrays are equal within the given limits. If the arrays have different lengths, only the number of elements of the shorter array will be compared.- Parameters:
reference
- The reference arraydata
- the actual data arrayepsilon
- The epsilon for the comparison, must be >=0- Returns:
- Whether the arrays are equal within the given limits.
- Throws:
jcuda.CudaException
- If the given epsilon is negative
-
compare
public static boolean compare(int[] reference, int[] data, float epsilon, float threshold) Checks if two arrays are equal within the given limits. If the arrays have different lengths, only the number of elements of the shorter array will be compared.- Parameters:
reference
- The reference arraydata
- the actual data arrayepsilon
- The epsilon for the comparison, must be >=0threshold
- The % of array elements that may be differ by more than the given epsilon- Returns:
- Whether the arrays are equal within the given limits.
- Throws:
jcuda.CudaException
- If the given epsilon is negative
-
compare
public static boolean compare(int[] reference, int[] data, float epsilon) Checks if two arrays are equal within the given limits. If the arrays have different lengths, only the number of elements of the shorter array will be compared.- Parameters:
reference
- The reference arraydata
- the actual data arrayepsilon
- The epsilon for the comparison, must be >=0- Returns:
- Whether the arrays are equal within the given limits.
- Throws:
jcuda.CudaException
- If the given epsilon is negative
-
compare
public static boolean compare(float[] reference, float[] data, float epsilon) Checks if two arrays are equal within the given limits. If the arrays have different lengths, only the number of elements of the shorter array will be compared.- Parameters:
reference
- The reference arraydata
- the actual data arrayepsilon
- The epsilon for the comparison- Returns:
- Whether the arrays are equal within the given limits.
-
compare
public static boolean compare(float[] reference, float[] data, float epsilon, float threshold) Checks if two arrays are equal within the given limits. If the arrays have different lengths, only the number of elements of the shorter array will be compared.- Parameters:
reference
- The reference arraydata
- the actual data arrayepsilon
- The epsilon for the comparison, must be >=0threshold
- The % of array elements that may be differ by more than the given epsilon- Returns:
- Whether the arrays are equal within the given limits.
- Throws:
jcuda.CudaException
- If the given epsilon is negative
-
compareL2
public static boolean compareL2(float[] reference, float[] data, float epsilon) Checks if two arrays are equal using the L2 norm. If the arrays have different lengths, only the number of elements of the shorter array will be compared.- Parameters:
reference
- The reference arraydata
- the actual data arrayepsilon
- The epsilon for the comparison, must be >=0- Returns:
- Whether the arrays are equal within the given limits.
- Throws:
jcuda.CudaException
- If the given epsilon is negative
-