Class Compare

java.lang.Object
jcuda.utils.Compare

public class Compare extends Object
Utility functions for comparing arrays.
Some of the functions are ported from the CUTIL comparison functions.
  • Method Summary

    Modifier and Type
    Method
    Description
    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

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 array
      data - 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 array
      data - 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 array
      data - 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 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.
      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 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.
      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 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.
      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 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.
      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 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.
      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 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.
      Throws:
      jcuda.CudaException - If the given epsilon is negative