Package unifeat.util

Class ArraysFunc

java.lang.Object
unifeat.util.ArraysFunc

public final class ArraysFunc extends Object
This java class is used to implement various utility methods for manipulating arrays and matrices. The methods in this class are contained brief description of the applications.
Author:
Sina Tabakhi
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int[]
    Converts the ArrayList type to an array of integer values
    static double[][]
    Converts the string input to double values
    static double[][]
    copyDoubleArray2D(double[][] initArray)
    Creates a copy of the two dimensional array
    static double[][]
    copyDoubleArray2D(double[][] initArray, int indexStart, int indexEnd)
    Creates a copy of the two dimensional array by using the indices of rows
    static void
    sortArray1D(double[] array, boolean descending)
    Sorts the one dimensional array (double values) as descending or ascending order
    static void
    sortArray1D(int[] array, boolean descending)
    Sorts the one dimensional array (integer values) as descending or ascending order
    static void
    sortArray1D(int[] array, boolean descending, int indexStart, int indexEnd)
    Sorts the one dimensional array (integer values) as descending or ascending order
    static void
    sortArray2D(double[][] array, int col)
    Sorts the two dimensional array by using the index of column as ascending order
    static void
    sortArray2D(double[][] array, int col, int indexStart, int indexEnd)
    Sorts the two dimensional array by using the index of column as ascending order
    static int[]
    sortWithIndex(double[] array, boolean descending)
    Sorts the one dimensional array (double values) by values and returns a list of indices
    static int[]
    sortWithIndex(int[] array, boolean descending)
    Sorts the one dimensional array (integer values) by values and returns a list of indices

    Methods inherited from class java.lang.Object

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

    • ArraysFunc

      public ArraysFunc()
  • Method Details

    • copyDoubleArray2D

      public static double[][] copyDoubleArray2D(double[][] initArray)
      Creates a copy of the two dimensional array
      Parameters:
      initArray - initial array
      Returns:
      a copy array of the input array
    • copyDoubleArray2D

      public static double[][] copyDoubleArray2D(double[][] initArray, int indexStart, int indexEnd)
      Creates a copy of the two dimensional array by using the indices of rows
      Parameters:
      initArray - initial array
      indexStart - the start index of the data
      indexEnd - the end index of the data
      Returns:
      a copy array of the input array
    • sortArray2D

      public static void sortArray2D(double[][] array, int col)
      Sorts the two dimensional array by using the index of column as ascending order
      Parameters:
      array - the input array
      col - the index of the column
    • sortArray2D

      public static void sortArray2D(double[][] array, int col, int indexStart, int indexEnd)
      Sorts the two dimensional array by using the index of column as ascending order
      Parameters:
      array - the input array
      col - the index of the column
      indexStart - the start index of the data
      indexEnd - the end index of the data
    • sortArray1D

      public static void sortArray1D(double[] array, boolean descending)
      Sorts the one dimensional array (double values) as descending or ascending order
      Parameters:
      array - the input array
      descending - indicates the type of sorting
    • sortArray1D

      public static void sortArray1D(int[] array, boolean descending)
      Sorts the one dimensional array (integer values) as descending or ascending order
      Parameters:
      array - the input array
      descending - indicates the type of sorting
    • sortArray1D

      public static void sortArray1D(int[] array, boolean descending, int indexStart, int indexEnd)
      Sorts the one dimensional array (integer values) as descending or ascending order
      Parameters:
      array - the input array
      descending - indicates the type of sorting
      indexStart - the start index of the data
      indexEnd - the end index of the data
    • sortWithIndex

      public static int[] sortWithIndex(double[] array, boolean descending)
      Sorts the one dimensional array (double values) by values and returns a list of indices
      Parameters:
      array - the input array
      descending - indicates the type of sorting
      Returns:
      the sorted array
    • sortWithIndex

      public static int[] sortWithIndex(int[] array, boolean descending)
      Sorts the one dimensional array (integer values) by values and returns a list of indices
      Parameters:
      array - the input array
      descending - indicates the type of sorting
      Returns:
      the sorted array
    • convertStringToDouble

      public static double[][] convertStringToDouble(String[][] array)
      Converts the string input to double values
      Parameters:
      array - the string input array
      Returns:
      the double array obtained from input array
    • convertArrayListToInt

      public static int[] convertArrayListToInt(ArrayList<Integer> list)
      Converts the ArrayList type to an array of integer values
      Parameters:
      list - the input ArrayList
      Returns:
      an array of integer values