jcuda.utils
Class Compare

java.lang.Object
  extended by jcuda.utils.Compare

public class Compare
extends java.lang.Object

Utility functions for comparing arrays.
Some of the functions are ported from the CUTIL comparison functions.


Method Summary
static boolean compare(byte[] reference, byte[] data)
          Returns whether the given arrays are equal
static 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 equal
static 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 equal
static 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

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 array
data - the actual data array

compare

public static boolean compare(int[] reference,
                              int[] data)
Returns whether the given arrays are equal

Parameters:
reference - The reference array
data - the actual data array

compare

public static boolean compare(byte[] reference,
                              byte[] data)
Returns whether the given arrays are equal

Parameters:
reference - The reference array
data - the actual data array

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 array
data - the actual data array
epsilon - The epsilon for the comparison
threshold - The % of array elements that may be differ by more than the given epsilon
Returns:
Whether the arrays are equal within the given limits.

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 array
data - the actual data array
epsilon - The epsilon for the comparison
Returns:
Whether the arrays are equal within the given limits.

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 array
data - the actual data array
epsilon - The epsilon for the comparison, must be >=0
threshold - The % of array elements that may be differ by more than the given epsilon
Returns:
Whether the arrays are equal within the given limits.

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 array
data - the actual data array
epsilon - The epsilon for the comparison, must be >=0
Returns:
Whether the arrays are equal within the given limits.

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 array
data - the actual data array
epsilon - 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 array
data - the actual data array
epsilon - The epsilon for the comparison, must be >=0
threshold - The % of array elements that may be differ by more than the given epsilon
Returns:
Whether the arrays are equal within the given limits.

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 array
data - the actual data array
epsilon - The epsilon for the comparison, must be >=0
Returns:
Whether the arrays are equal within the given limits.