Class CompareRing

java.lang.Object
org.flag4j.linalg.ops.common.ring_ops.CompareRing

public final class CompareRing extends Object
This utility class provides methods useful for comparing elements of a Ring.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T extends Ring<T>>
    int
    argmaxAbs(T... values)
    Computes the index of the maximum absolute value in the specified array.
    static <T extends Ring<T>>
    int
    argminAbs(T... values)
    Computes the index of the minimum absolute value in the specified array.
    static <T extends Ring<T>>
    double
    maxAbs(T... values)
    Computes the maximum absolute value in the specified array.
    static <T extends Ring<T>>
    double
    maxAbs(T[] src, int start, int n, int stride)
    Returns the maximum absolute value among n elements in the array src, starting at index start and advancing by stride for each subsequent element.
    static <T extends Ring<T>>
    double
    minAbs(T... values)
    Computes the minimum absolute value in the specified array.
    static <T extends Ring<T>>
    double
    minAbs(T[] src, int start, int n, int stride)
    Returns the minimum absolute value among n elements in the array src, starting at index start and advancing by stride for each subsequent element.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • maxAbs

      public static <T extends Ring<T>> double maxAbs(T... values)
      Computes the maximum absolute value in the specified array. This is done according to the ordering imposed by Double.compareTo(x.mag(), y.mag()) where x and y are elements of values.
      Parameters:
      values - Values to commute maximum of.
      Returns:
      The maximum value in values. If values.length equals zero, then Double.NaN is returned.
    • minAbs

      public static <T extends Ring<T>> double minAbs(T... values)
      Computes the minimum absolute value in the specified array. This is done according to the ordering imposed by Double.compareTo(x.mag(), y.mag()) where x and y are elements of values.
      Parameters:
      values - Values to compute minimum of.
      Returns:
      The minimum value in values. If values.length equals zero, then Double.NaN is returned.
    • argmaxAbs

      public static <T extends Ring<T>> int argmaxAbs(T... values)
      Computes the index of the maximum absolute value in the specified array.
      Parameters:
      values - Values for which compute index of maximum absolute value.
      Returns:
      The index of the maximum absolute value in values. If the maximum absolute value occurs more than once, the index of the first occurrence is returned. If values.length equals zero, then -1 is returned.
    • argminAbs

      public static <T extends Ring<T>> int argminAbs(T... values)
      Computes the index of the minimum absolute value in the specified array.
      Parameters:
      values - Values for which compute index of the minimum absolute value.
      Returns:
      The index of the minimum absolute value in values. If the minimum absolute value occurs more than once, the index of the first occurrence is returned. If values.length equals zero, then -1 is returned.
    • maxAbs

      public static <T extends Ring<T>> double maxAbs(T[] src, int start, int n, int stride)

      Returns the maximum absolute value among n elements in the array src, starting at index start and advancing by stride for each subsequent element.

      More formally, this method examines the elements at indices: start, start + stride, start + 2*stride, ..., start + (n-1)*stride.

      This method may be used to find the maximum absolute value within the row or column of a matrix a as follows:

      • Maximum absolute value within row i:
        maxAbs(a.data, i*a.numCols, a.numCols, 1);
      • Maximum absolute value within column j:
        maxAbs(a.data, j, a.numRows, a.numRows);
      Parameters:
      src - The array to search for maximum absolute value within.
      start - The starting index in src to search.
      n - The number of elements to consider within src1.
      stride - The gap (in indices) between consecutive elements to search within src.
      Returns:
      The maximum absolute value found among all elements considered in src.
    Throws:
    IndexOutOfBoundsException - If the specified range extends beyond the array bounds.