Class ReduceArrays

java.lang.Object
edu.rit.pj.reduction.ReduceArrays

public class ReduceArrays extends Object
Class ReduceArrays provides static methods for reduction operations on arrays and matrices of primitive types and object types.

Note: The operations in class ReduceArrays are not multiple thread safe.

Version:
20-Jun-2007
Author:
Alan Kaminsky
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    reduce(boolean[][] src, Range srcRowRange, Range srcColRange, boolean[][] dst, Range dstRowRange, Range dstColRange, BooleanOp op)
    Combine a range of elements from one Boolean matrix with a range of elements in another Boolean matrix.
    static void
    reduce(boolean[] src, Range srcRange, boolean[] dst, Range dstRange, BooleanOp op)
    Combine a range of elements from one Boolean array with a range of elements in another Boolean array.
    static void
    reduce(byte[][] src, Range srcRowRange, Range srcColRange, byte[][] dst, Range dstRowRange, Range dstColRange, ByteOp op)
    Combine a range of elements from one byte matrix with a range of elements in another byte matrix.
    static void
    reduce(byte[] src, Range srcRange, byte[] dst, Range dstRange, ByteOp op)
    Combine a range of elements from one byte array with a range of elements in another byte array.
    static void
    reduce(char[][] src, Range srcRowRange, Range srcColRange, char[][] dst, Range dstRowRange, Range dstColRange, CharacterOp op)
    Combine a range of elements from one character matrix with a range of elements in another character matrix.
    static void
    reduce(char[] src, Range srcRange, char[] dst, Range dstRange, CharacterOp op)
    Combine a range of elements from one character array with a range of elements in another character array.
    static void
    reduce(double[][] src, Range srcRowRange, Range srcColRange, double[][] dst, Range dstRowRange, Range dstColRange, DoubleOp op)
    Combine a range of elements from one double matrix with a range of elements in another double matrix.
    static void
    reduce(double[] src, Range srcRange, double[] dst, Range dstRange, DoubleOp op)
    Combine a range of elements from one double array with a range of elements in another double array.
    static void
    reduce(float[][] src, Range srcRowRange, Range srcColRange, float[][] dst, Range dstRowRange, Range dstColRange, FloatOp op)
    Combine a range of elements from one float matrix with a range of elements in another float matrix.
    static void
    reduce(float[] src, Range srcRange, float[] dst, Range dstRange, FloatOp op)
    Combine a range of elements from one float array with a range of elements in another float array.
    static void
    reduce(int[][] src, Range srcRowRange, Range srcColRange, int[][] dst, Range dstRowRange, Range dstColRange, IntegerOp op)
    Combine a range of elements from one integer matrix with a range of elements in another integer matrix.
    static void
    reduce(int[] src, Range srcRange, int[] dst, Range dstRange, IntegerOp op)
    Combine a range of elements from one integer array with a range of elements in another integer array.
    static void
    reduce(long[][] src, Range srcRowRange, Range srcColRange, long[][] dst, Range dstRowRange, Range dstColRange, LongOp op)
    Combine a range of elements from one long matrix with a range of elements in another long matrix.
    static void
    reduce(long[] src, Range srcRange, long[] dst, Range dstRange, LongOp op)
    Combine a range of elements from one long array with a range of elements in another long array.
    static void
    reduce(short[][] src, Range srcRowRange, Range srcColRange, short[][] dst, Range dstRowRange, Range dstColRange, ShortOp op)
    Combine a range of elements from one short matrix with a range of elements in another short matrix.
    static void
    reduce(short[] src, Range srcRange, short[] dst, Range dstRange, ShortOp op)
    Combine a range of elements from one short array with a range of elements in another short array.
    static <DT, ST extends DT>
    void
    reduce(ST[][] src, Range srcRowRange, Range srcColRange, DT[][] dst, Range dstRowRange, Range dstColRange, ObjectOp<DT> op)
    Combine a range of elements from one object matrix with a range of elements in another object matrix.
    static <DT, ST extends DT>
    void
    reduce(ST[] src, Range srcRange, DT[] dst, Range dstRange, ObjectOp<DT> op)
    Combine a range of elements from one object array with a range of elements in another object array.

    Methods inherited from class java.lang.Object

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

    • reduce

      public static void reduce(boolean[] src, Range srcRange, boolean[] dst, Range dstRange, BooleanOp op)
      Combine a range of elements from one Boolean array with a range of elements in another Boolean array. The number of elements combined is the smaller of srcRange's length and dstRange's length. Either or both of srcRange's and dstRange's strides may be greater than 1.

      For each destination array element D in the destination range and each corresponding source array element S in the source range, D is set to D op S.

      Parameters:
      src - Source array.
      srcRange - Range of source elements.
      dst - Destination array.
      dstRange - Range of destination elements.
      op - Binary operation.
      Throws:
      NullPointerException - (unchecked exception) Thrown if any argument is null.
      IndexOutOfBoundsException - (unchecked exception) Thrown if any index in srcRange is outside the bounds of the source array. Thrown if any index in dstRange is outside the bounds of the destination array.
    • reduce

      public static void reduce(byte[] src, Range srcRange, byte[] dst, Range dstRange, ByteOp op)
      Combine a range of elements from one byte array with a range of elements in another byte array. The number of elements combined is the smaller of srcRange's length and dstRange's length. Either or both of srcRange's and dstRange's strides may be greater than 1.

      For each destination array element D in the destination range and each corresponding source array element S in the source range, D is set to D op S.

      Parameters:
      src - Source array.
      srcRange - Range of source elements.
      dst - Destination array.
      dstRange - Range of destination elements.
      op - Binary operation.
      Throws:
      NullPointerException - (unchecked exception) Thrown if any argument is null.
      IndexOutOfBoundsException - (unchecked exception) Thrown if any index in srcRange is outside the bounds of the source array. Thrown if any index in dstRange is outside the bounds of the destination array.
    • reduce

      public static void reduce(char[] src, Range srcRange, char[] dst, Range dstRange, CharacterOp op)
      Combine a range of elements from one character array with a range of elements in another character array. The number of elements combined is the smaller of srcRange's length and dstRange's length. Either or both of srcRange's and dstRange's strides may be greater than 1.

      For each destination array element D in the destination range and each corresponding source array element S in the source range, D is set to D op S.

      Parameters:
      src - Source array.
      srcRange - Range of source elements.
      dst - Destination array.
      dstRange - Range of destination elements.
      op - Binary operation.
      Throws:
      NullPointerException - (unchecked exception) Thrown if any argument is null.
      IndexOutOfBoundsException - (unchecked exception) Thrown if any index in srcRange is outside the bounds of the source array. Thrown if any index in dstRange is outside the bounds of the destination array.
    • reduce

      public static void reduce(double[] src, Range srcRange, double[] dst, Range dstRange, DoubleOp op)
      Combine a range of elements from one double array with a range of elements in another double array. The number of elements combined is the smaller of srcRange's length and dstRange's length. Either or both of srcRange's and dstRange's strides may be greater than 1.

      For each destination array element D in the destination range and each corresponding source array element S in the source range, D is set to D op S.

      Parameters:
      src - Source array.
      srcRange - Range of source elements.
      dst - Destination array.
      dstRange - Range of destination elements.
      op - Binary operation.
      Throws:
      NullPointerException - (unchecked exception) Thrown if any argument is null.
      IndexOutOfBoundsException - (unchecked exception) Thrown if any index in srcRange is outside the bounds of the source array. Thrown if any index in dstRange is outside the bounds of the destination array.
    • reduce

      public static void reduce(float[] src, Range srcRange, float[] dst, Range dstRange, FloatOp op)
      Combine a range of elements from one float array with a range of elements in another float array. The number of elements combined is the smaller of srcRange's length and dstRange's length. Either or both of srcRange's and dstRange's strides may be greater than 1.

      For each destination array element D in the destination range and each corresponding source array element S in the source range, D is set to D op S.

      Parameters:
      src - Source array.
      srcRange - Range of source elements.
      dst - Destination array.
      dstRange - Range of destination elements.
      op - Binary operation.
      Throws:
      NullPointerException - (unchecked exception) Thrown if any argument is null.
      IndexOutOfBoundsException - (unchecked exception) Thrown if any index in srcRange is outside the bounds of the source array. Thrown if any index in dstRange is outside the bounds of the destination array.
    • reduce

      public static void reduce(int[] src, Range srcRange, int[] dst, Range dstRange, IntegerOp op)
      Combine a range of elements from one integer array with a range of elements in another integer array. The number of elements combined is the smaller of srcRange's length and dstRange's length. Either or both of srcRange's and dstRange's strides may be greater than 1.

      For each destination array element D in the destination range and each corresponding source array element S in the source range, D is set to D op S.

      Parameters:
      src - Source array.
      srcRange - Range of source elements.
      dst - Destination array.
      dstRange - Range of destination elements.
      op - Binary operation.
      Throws:
      NullPointerException - (unchecked exception) Thrown if any argument is null.
      IndexOutOfBoundsException - (unchecked exception) Thrown if any index in srcRange is outside the bounds of the source array. Thrown if any index in dstRange is outside the bounds of the destination array.
    • reduce

      public static void reduce(long[] src, Range srcRange, long[] dst, Range dstRange, LongOp op)
      Combine a range of elements from one long array with a range of elements in another long array. The number of elements combined is the smaller of srcRange's length and dstRange's length. Either or both of srcRange's and dstRange's strides may be greater than 1.

      For each destination array element D in the destination range and each corresponding source array element S in the source range, D is set to D op S.

      Parameters:
      src - Source array.
      srcRange - Range of source elements.
      dst - Destination array.
      dstRange - Range of destination elements.
      op - Binary operation.
      Throws:
      NullPointerException - (unchecked exception) Thrown if any argument is null.
      IndexOutOfBoundsException - (unchecked exception) Thrown if any index in srcRange is outside the bounds of the source array. Thrown if any index in dstRange is outside the bounds of the destination array.
    • reduce

      public static void reduce(short[] src, Range srcRange, short[] dst, Range dstRange, ShortOp op)
      Combine a range of elements from one short array with a range of elements in another short array. The number of elements combined is the smaller of srcRange's length and dstRange's length. Either or both of srcRange's and dstRange's strides may be greater than 1.

      For each destination array element D in the destination range and each corresponding source array element S in the source range, D is set to D op S.

      Parameters:
      src - Source array.
      srcRange - Range of source elements.
      dst - Destination array.
      dstRange - Range of destination elements.
      op - Binary operation.
      Throws:
      NullPointerException - (unchecked exception) Thrown if any argument is null.
      IndexOutOfBoundsException - (unchecked exception) Thrown if any index in srcRange is outside the bounds of the source array. Thrown if any index in dstRange is outside the bounds of the destination array.
    • reduce

      public static <DT, ST extends DT> void reduce(ST[] src, Range srcRange, DT[] dst, Range dstRange, ObjectOp<DT> op)
      Combine a range of elements from one object array with a range of elements in another object array. The number of elements combined is the smaller of srcRange's length and dstRange's length. Either or both of srcRange's and dstRange's strides may be greater than 1.

      For each destination array element D in the destination range and each corresponding source array element S in the source range, D is set to D op S.

      Type Parameters:
      DT - Destination array element data type.
      ST - Data type that extends the destination matrix element data type.
      Parameters:
      src - Source array.
      srcRange - Range of source elements.
      dst - Destination array.
      dstRange - Range of destination elements.
      op - Binary operation.
      Throws:
      NullPointerException - (unchecked exception) Thrown if any argument is null.
      IndexOutOfBoundsException - (unchecked exception) Thrown if any index in srcRange is outside the bounds of the source array. Thrown if any index in dstRange is outside the bounds of the destination array.
    • reduce

      public static void reduce(boolean[][] src, Range srcRowRange, Range srcColRange, boolean[][] dst, Range dstRowRange, Range dstColRange, BooleanOp op)
      Combine a range of elements from one Boolean matrix with a range of elements in another Boolean matrix. The number of rows combined is the smaller of srcRowRange's length and dstRowRange's length. Within each row, the number of columns combined is the smaller of srcColRange's length and dstColRange's length. Any of srcRowRange's, srcColRange's, dstRowRange's, and dstColRange's strides may be greater than 1. It is assumed that the source matrix is fully allocated; each row in the source matrix is the same length; the destination matrix is fully allocated; and each row in the destination matrix is the same length.

      For each destination matrix element D in the destination row and column ranges and each corresponding source matrix element S in the source row and column ranges, D is set to D op S.

      Parameters:
      src - Source matrix.
      srcRowRange - Range of source rows.
      srcColRange - Range of source columns.
      dst - Destination matrix.
      dstRowRange - Range of destination rows.
      dstColRange - Range of destination columns.
      op - Binary operation.
      Throws:
      NullPointerException - (unchecked exception) Thrown if any argument is null.
      IndexOutOfBoundsException - (unchecked exception) Thrown if any index in srcRowRange is outside the row bounds of the source matrix. Thrown if any index in srcColRange is outside the column bounds of the source matrix. Thrown if any index in dstRowRange is outside the row bounds of the destination matrix. Thrown if any index in dstColRange is outside the column bounds of the destination matrix.
    • reduce

      public static void reduce(byte[][] src, Range srcRowRange, Range srcColRange, byte[][] dst, Range dstRowRange, Range dstColRange, ByteOp op)
      Combine a range of elements from one byte matrix with a range of elements in another byte matrix. The number of rows combined is the smaller of srcRowRange's length and dstRowRange's length. Within each row, the number of columns combined is the smaller of srcColRange's length and dstColRange's length. Any of srcRowRange's, srcColRange's, dstRowRange's, and dstColRange's strides may be greater than 1. It is assumed that the source matrix is fully allocated; each row in the source matrix is the same length; the destination matrix is fully allocated; and each row in the destination matrix is the same length.

      For each destination matrix element D in the destination row and column ranges and each corresponding source matrix element S in the source row and column ranges, D is set to D op S.

      Parameters:
      src - Source matrix.
      srcRowRange - Range of source rows.
      srcColRange - Range of source columns.
      dst - Destination matrix.
      dstRowRange - Range of destination rows.
      dstColRange - Range of destination columns.
      op - Binary operation.
      Throws:
      NullPointerException - (unchecked exception) Thrown if any argument is null.
      IndexOutOfBoundsException - (unchecked exception) Thrown if any index in srcRowRange is outside the row bounds of the source matrix. Thrown if any index in srcColRange is outside the column bounds of the source matrix. Thrown if any index in dstRowRange is outside the row bounds of the destination matrix. Thrown if any index in dstColRange is outside the column bounds of the destination matrix.
    • reduce

      public static void reduce(char[][] src, Range srcRowRange, Range srcColRange, char[][] dst, Range dstRowRange, Range dstColRange, CharacterOp op)
      Combine a range of elements from one character matrix with a range of elements in another character matrix. The number of rows combined is the smaller of srcRowRange's length and dstRowRange's length. Within each row, the number of columns combined is the smaller of srcColRange's length and dstColRange's length. Any of srcRowRange's, srcColRange's, dstRowRange's, and dstColRange's strides may be greater than 1. It is assumed that the source matrix is fully allocated; each row in the source matrix is the same length; the destination matrix is fully allocated; and each row in the destination matrix is the same length.

      For each destination matrix element D in the destination row and column ranges and each corresponding source matrix element S in the source row and column ranges, D is set to D op S.

      Parameters:
      src - Source matrix.
      srcRowRange - Range of source rows.
      srcColRange - Range of source columns.
      dst - Destination matrix.
      dstRowRange - Range of destination rows.
      dstColRange - Range of destination columns.
      op - Binary operation.
      Throws:
      NullPointerException - (unchecked exception) Thrown if any argument is null.
      IndexOutOfBoundsException - (unchecked exception) Thrown if any index in srcRowRange is outside the row bounds of the source matrix. Thrown if any index in srcColRange is outside the column bounds of the source matrix. Thrown if any index in dstRowRange is outside the row bounds of the destination matrix. Thrown if any index in dstColRange is outside the column bounds of the destination matrix.
    • reduce

      public static void reduce(double[][] src, Range srcRowRange, Range srcColRange, double[][] dst, Range dstRowRange, Range dstColRange, DoubleOp op)
      Combine a range of elements from one double matrix with a range of elements in another double matrix. The number of rows combined is the smaller of srcRowRange's length and dstRowRange's length. Within each row, the number of columns combined is the smaller of srcColRange's length and dstColRange's length. Any of srcRowRange's, srcColRange's, dstRowRange's, and dstColRange's strides may be greater than 1. It is assumed that the source matrix is fully allocated; each row in the source matrix is the same length; the destination matrix is fully allocated; and each row in the destination matrix is the same length.
      Parameters:
      src - Source matrix.
      srcRowRange - Range of source rows.
      srcColRange - Range of source columns.
      dst - Destination matrix.
      dstRowRange - Range of destination rows.
      dstColRange - Range of destination columns.
      op - Binary operation.
      Throws:
      NullPointerException - (unchecked exception) Thrown if any argument is null.
      IndexOutOfBoundsException - (unchecked exception) Thrown if any index in srcRowRange is outside the row bounds of the source matrix. Thrown if any index in srcColRange is outside the column bounds of the source matrix. Thrown if any index in dstRowRange is outside the row bounds of the destination matrix. Thrown if any index in dstColRange is outside the column bounds of the destination matrix.
    • reduce

      public static void reduce(float[][] src, Range srcRowRange, Range srcColRange, float[][] dst, Range dstRowRange, Range dstColRange, FloatOp op)
      Combine a range of elements from one float matrix with a range of elements in another float matrix. The number of rows combined is the smaller of srcRowRange's length and dstRowRange's length. Within each row, the number of columns combined is the smaller of srcColRange's length and dstColRange's length. Any of srcRowRange's, srcColRange's, dstRowRange's, and dstColRange's strides may be greater than 1. It is assumed that the source matrix is fully allocated; each row in the source matrix is the same length; the destination matrix is fully allocated; and each row in the destination matrix is the same length.

      For each destination matrix element D in the destination row and column ranges and each corresponding source matrix element S in the source row and column ranges, D is set to D op S.

      Parameters:
      src - Source matrix.
      srcRowRange - Range of source rows.
      srcColRange - Range of source columns.
      dst - Destination matrix.
      dstRowRange - Range of destination rows.
      dstColRange - Range of destination columns.
      op - Binary operation.
      Throws:
      NullPointerException - (unchecked exception) Thrown if any argument is null.
      IndexOutOfBoundsException - (unchecked exception) Thrown if any index in srcRowRange is outside the row bounds of the source matrix. Thrown if any index in srcColRange is outside the column bounds of the source matrix. Thrown if any index in dstRowRange is outside the row bounds of the destination matrix. Thrown if any index in dstColRange is outside the column bounds of the destination matrix.
    • reduce

      public static void reduce(int[][] src, Range srcRowRange, Range srcColRange, int[][] dst, Range dstRowRange, Range dstColRange, IntegerOp op)
      Combine a range of elements from one integer matrix with a range of elements in another integer matrix. The number of rows combined is the smaller of srcRowRange's length and dstRowRange's length. Within each row, the number of columns combined is the smaller of srcColRange's length and dstColRange's length. Any of srcRowRange's, srcColRange's, dstRowRange's, and dstColRange's strides may be greater than 1. It is assumed that the source matrix is fully allocated; each row in the source matrix is the same length; the destination matrix is fully allocated; and each row in the destination matrix is the same length.

      For each destination matrix element D in the destination row and column ranges and each corresponding source matrix element S in the source row and column ranges, D is set to D op S.

      Parameters:
      src - Source matrix.
      srcRowRange - Range of source rows.
      srcColRange - Range of source columns.
      dst - Destination matrix.
      dstRowRange - Range of destination rows.
      dstColRange - Range of destination columns.
      op - Binary operation.
      Throws:
      NullPointerException - (unchecked exception) Thrown if any argument is null.
      IndexOutOfBoundsException - (unchecked exception) Thrown if any index in srcRowRange is outside the row bounds of the source matrix. Thrown if any index in srcColRange is outside the column bounds of the source matrix. Thrown if any index in dstRowRange is outside the row bounds of the destination matrix. Thrown if any index in dstColRange is outside the column bounds of the destination matrix.
    • reduce

      public static void reduce(long[][] src, Range srcRowRange, Range srcColRange, long[][] dst, Range dstRowRange, Range dstColRange, LongOp op)
      Combine a range of elements from one long matrix with a range of elements in another long matrix. The number of rows combined is the smaller of srcRowRange's length and dstRowRange's length. Within each row, the number of columns combined is the smaller of srcColRange's length and dstColRange's length. Any of srcRowRange's, srcColRange's, dstRowRange's, and dstColRange's strides may be greater than 1. It is assumed that the source matrix is fully allocated; each row in the source matrix is the same length; the destination matrix is fully allocated; and each row in the destination matrix is the same length.

      For each destination matrix element D in the destination row and column ranges and each corresponding source matrix element S in the source row and column ranges, D is set to D op S.

      Parameters:
      src - Source matrix.
      srcRowRange - Range of source rows.
      srcColRange - Range of source columns.
      dst - Destination matrix.
      dstRowRange - Range of destination rows.
      dstColRange - Range of destination columns.
      op - Binary operation.
      Throws:
      NullPointerException - (unchecked exception) Thrown if any argument is null.
      IndexOutOfBoundsException - (unchecked exception) Thrown if any index in srcRowRange is outside the row bounds of the source matrix. Thrown if any index in srcColRange is outside the column bounds of the source matrix. Thrown if any index in dstRowRange is outside the row bounds of the destination matrix. Thrown if any index in dstColRange is outside the column bounds of the destination matrix.
    • reduce

      public static void reduce(short[][] src, Range srcRowRange, Range srcColRange, short[][] dst, Range dstRowRange, Range dstColRange, ShortOp op)
      Combine a range of elements from one short matrix with a range of elements in another short matrix. The number of rows combined is the smaller of srcRowRange's length and dstRowRange's length. Within each row, the number of columns combined is the smaller of srcColRange's length and dstColRange's length. Any of srcRowRange's, srcColRange's, dstRowRange's, and dstColRange's strides may be greater than 1. It is assumed that the source matrix is fully allocated; each row in the source matrix is the same length; the destination matrix is fully allocated; and each row in the destination matrix is the same length.

      For each destination matrix element D in the destination row and column ranges and each corresponding source matrix element S in the source row and column ranges, D is set to D op S.

      Parameters:
      src - Source matrix.
      srcRowRange - Range of source rows.
      srcColRange - Range of source columns.
      dst - Destination matrix.
      dstRowRange - Range of destination rows.
      dstColRange - Range of destination columns.
      op - Binary operation.
      Throws:
      NullPointerException - (unchecked exception) Thrown if any argument is null.
      IndexOutOfBoundsException - (unchecked exception) Thrown if any index in srcRowRange is outside the row bounds of the source matrix. Thrown if any index in srcColRange is outside the column bounds of the source matrix. Thrown if any index in dstRowRange is outside the row bounds of the destination matrix. Thrown if any index in dstColRange is outside the column bounds of the destination matrix.
    • reduce

      public static <DT, ST extends DT> void reduce(ST[][] src, Range srcRowRange, Range srcColRange, DT[][] dst, Range dstRowRange, Range dstColRange, ObjectOp<DT> op)
      Combine a range of elements from one object matrix with a range of elements in another object matrix. The number of rows combined is the smaller of srcRowRange's length and dstRowRange's length. Within each row, the number of columns combined is the smaller of srcColRange's length and dstColRange's length. Any of srcRowRange's, srcColRange's, dstRowRange's, and dstColRange's strides may be greater than 1. It is assumed that the source matrix is fully allocated; each row in the source matrix is the same length; the destination matrix is fully allocated; and each row in the destination matrix is the same length.

      For each destination matrix element D in the destination row and column ranges and each corresponding source matrix element S in the source row and column ranges, D is set to D op S.

      Type Parameters:
      DT - Destination matrix element data type.
      ST - Data type that extends the destination matrix element data type.
      Parameters:
      src - Source matrix.
      srcRowRange - Range of source rows.
      srcColRange - Range of source columns.
      dst - Destination matrix.
      dstRowRange - Range of destination rows.
      dstColRange - Range of destination columns.
      op - Binary operation.
      Throws:
      NullPointerException - (unchecked exception) Thrown if any argument is null.
      IndexOutOfBoundsException - (unchecked exception) Thrown if any index in srcRowRange is outside the row bounds of the source matrix. Thrown if any index in srcColRange is outside the column bounds of the source matrix. Thrown if any index in dstRowRange is outside the row bounds of the destination matrix. Thrown if any index in dstColRange is outside the column bounds of the destination matrix.