Class ArrayUtil


  • public class ArrayUtil
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void add​(double[] sum, double[] summand)  
      static java.util.List<java.lang.Integer> argMax​(double[] array)  
      static java.util.List<java.lang.Integer> argMax​(int[] array)  
      static int argMaxFirst​(double[] array)  
      static int argMaxFirst​(int[] array)  
      static java.util.List<java.lang.Integer> argMin​(int[] array)  
      static int argMinFirst​(int[] array)  
      static <T> T[] copyArrayExlcuding​(T[] array, java.util.Collection<java.lang.Integer> columnsToExclude)
      Copies an array of type without copying the columns in columnsToExclude.
      static <T> T[] copyArrayRetaining​(T[] array, java.util.Collection<java.lang.Integer> columnsToRetain)
      Copies an array of type retaining the columns in columnsToRetain.
      static double[] extractColumn​(double[][] matrix, int columnIndex)  
      static int[] extractColumn​(int[][] matrix, int columnIndex)  
      static <T> T[] mergeArrays​(T[] array0, T[] array1)  
      static double[] parseStringToDoubleArray​(java.lang.String arrayString)  
      static int[] parseStringToIntArray​(java.lang.String arrayString)  
      static java.lang.String[] parseStringToStringArray​(java.lang.String arrayString)  
      static int[] thresholdDoubleToBinaryArray​(double[] array, double threshold)  
      static int[][] thresholdDoubleToBinaryMatrix​(double[][] matrix, double threshold)  
      static int[][] thresholdDoubleToBinaryMatrix​(double[][] matrix, double[] threshold)  
      static double[][] transposeDoubleMatrix​(double[][] matrix)
      Transposes a matrix A and returns A^T.
      static int[][] transposeIntegerMatrix​(int[][] matrix)  
      static double[][] transposeMatrix​(double[][] matrix)
      Transposes a double matrix A and returns A^T.
      static int[][] transposeMatrix​(int[][] matrix)
      Transposes an int matrix A and returns A^T.
      static <T> T[][] transposeMatrix​(T[][] matrix)
      Transposes a generic matrix A and returns A^T.
      • Methods inherited from class java.lang.Object

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

      • copyArrayExlcuding

        public static <T> T[] copyArrayExlcuding​(T[] array,
                                                 java.util.Collection<java.lang.Integer> columnsToExclude)
        Copies an array of type without copying the columns in columnsToExclude.
        Type Parameters:
        T - The data type of objects contained in the array.
        Parameters:
        array - The array to copy excluding the given columns.
        columnsToExclude - The columns to exclude when copying.
        clazz - The class object for the type T.
        Returns:
        The copy of the original array without the excluded values.
      • copyArrayRetaining

        public static <T> T[] copyArrayRetaining​(T[] array,
                                                 java.util.Collection<java.lang.Integer> columnsToRetain)
        Copies an array of type retaining the columns in columnsToRetain.
        Type Parameters:
        T - The data type of objects contained in the array.
        Parameters:
        array - The array to copy retaining the given columns.
        columnsToExclude - The columns to retain when copying.
        clazz - The class object for the type T.
        Returns:
        The copy of the original array retaining the given column values only.
      • transposeDoubleMatrix

        public static double[][] transposeDoubleMatrix​(double[][] matrix)
        Transposes a matrix A and returns A^T.
        Parameters:
        matrix - The given matrix A.
        Returns:
        The transposed matrix A^T originating from A.
      • transposeIntegerMatrix

        public static int[][] transposeIntegerMatrix​(int[][] matrix)
      • parseStringToDoubleArray

        public static double[] parseStringToDoubleArray​(java.lang.String arrayString)
      • parseStringToIntArray

        public static int[] parseStringToIntArray​(java.lang.String arrayString)
      • parseStringToStringArray

        public static java.lang.String[] parseStringToStringArray​(java.lang.String arrayString)
      • argMax

        public static java.util.List<java.lang.Integer> argMax​(double[] array)
      • argMax

        public static java.util.List<java.lang.Integer> argMax​(int[] array)
      • argMaxFirst

        public static int argMaxFirst​(int[] array)
      • argMaxFirst

        public static int argMaxFirst​(double[] array)
      • argMin

        public static java.util.List<java.lang.Integer> argMin​(int[] array)
      • argMinFirst

        public static int argMinFirst​(int[] array)
      • transposeMatrix

        public static double[][] transposeMatrix​(double[][] matrix)
        Transposes a double matrix A and returns A^T.
        Parameters:
        matrix - The given double matrix A.
        Returns:
        The transposed double matrix A^T originating from A.
      • transposeMatrix

        public static int[][] transposeMatrix​(int[][] matrix)
        Transposes an int matrix A and returns A^T.
        Parameters:
        matrix - The given int matrix A.
        Returns:
        The transposed int matrix A^T originating from A.
      • transposeMatrix

        public static <T> T[][] transposeMatrix​(T[][] matrix)
        Transposes a generic matrix A and returns A^T.
        Parameters:
        matrix - The given generic matrix A with entries of type .
        Returns:
        The transposed generic matrix A^T originating from A. The type of objects contained in the matrix.
      • thresholdDoubleToBinaryArray

        public static int[] thresholdDoubleToBinaryArray​(double[] array,
                                                         double threshold)
      • thresholdDoubleToBinaryMatrix

        public static int[][] thresholdDoubleToBinaryMatrix​(double[][] matrix,
                                                            double threshold)
      • thresholdDoubleToBinaryMatrix

        public static int[][] thresholdDoubleToBinaryMatrix​(double[][] matrix,
                                                            double[] threshold)
      • extractColumn

        public static double[] extractColumn​(double[][] matrix,
                                             int columnIndex)
      • extractColumn

        public static int[] extractColumn​(int[][] matrix,
                                          int columnIndex)
      • add

        public static void add​(double[] sum,
                               double[] summand)
      • mergeArrays

        public static <T> T[] mergeArrays​(T[] array0,
                                          T[] array1)