Class ArrayUtil


  • public class ArrayUtil
    extends Object
    Author:
    Kilian
    • Constructor Summary

      Constructors 
      Constructor Description
      ArrayUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static void add​(byte[] arr, byte summand)
      Add the supplied argument to every field in the array
      static void add​(char[] arr, char summand)
      Add the supplied argument to every field in the array
      static void add​(double[] arr, double summand)
      Add the supplied argument to every field in the array
      static void add​(float[] arr, float summand)
      Add the supplied argument to every field in the array
      static void add​(int[] arr, int summand)
      Add the supplied argument to every field in the array
      static void add​(long[] arr, long summand)
      Add the supplied argument to every field in the array
      static void add​(short[] arr, short summand)
      Add the supplied argument to every field in the array
      static <T> boolean allNotNull​(T[] array)
      Check if all values in the array are not null
      static <T> boolean allNull​(T[] array)
      Check if all values in the array are null
      static double average​(byte[] array)
      Calculates the average value of the array.
      static double average​(byte[][] array)
      Calculates the average value of the 2d array.
      static double average​(char[] array)
      Calculates the average value of the array.
      static double average​(char[][] array)
      Calculates the average value of the 2d array.
      static double average​(double[] array)
      Calculates the average value of the array.
      static double average​(double[][] array)
      Calculates the average value of the 2d array.
      static double average​(float[] array)
      Calculates the average value of the array.
      static double average​(float[][] array)
      Calculates the average value of the 2d array.
      static double average​(int[] array)
      Calculates the average value of the array.
      static double average​(int[][] array)
      Calculates the average value of the 2d array.
      static double average​(long[] array)
      Calculates the average value of the array.
      static double average​(long[][] array)
      Calculates the average value of the 2d array.
      static double average​(short[] array)
      Calculates the average value of the array.
      static double average​(short[][] array)
      Calculates the average value of the 2d array.
      static boolean deepAllNotNull​(Object[] array)
      Check if all values in the array are not null.
      static <T> T[] deepArrayCopy​(T[] array)
      Deep copy nested arrays.
      static <T> T[] deepArrayCopyClone​(T[] array)
      Deprecated.
      static String deepToString​(Object[] array)
      Returns a string representation of the "deep contents" of the specified array.
      static String deepToStringFormatted​(Object[] array)
      Returns a string representation of the "deep contents" of the specified array.
      static void divide​(byte[] arrDividend, byte divisor)
      Calculate the quotient for each field in the array
      static void divide​(byte[] arrDivisor, byte[] dividend)
      Pairwise divide the two vectors.
      static void divide​(char[] arrDividend, char divisor)
      Calculate the quotient for each field in the array
      static void divide​(char[] arrDivisor, char[] dividend)
      Pairwise divide the two vectors.
      static void divide​(double[] arrDividend, double divisor)
      Calculate the quotient for each field in the array
      static void divide​(double[] arrDivisor, double[] dividend)
      Pairwise divide the two vectors.
      static void divide​(float[] arrDividend, float divisor)
      Calculate the quotient for each field in the array
      static void divide​(float[] arrDivisor, float[] dividend)
      Pairwise divide the two vectors.
      static void divide​(int[] arrDividend, int divisor)
      Calculate the quotient for each field in the array
      static void divide​(int[] arrDivisor, int[] dividend)
      Pairwise divide the two vectors.
      static void divide​(long[] arrDividend, long divisor)
      Calculate the quotient for each field in the array
      static void divide​(long[] arrDivisor, long[] dividend)
      Pairwise divide the two vectors.
      static void divide​(short[] arrDividend, short divisor)
      Calculate the quotient for each field in the array
      static void divide​(short[] arrDivisor, short[] dividend)
      Pairwise divide the two vectors.
      static void fillArray​(boolean[] array, Function<Integer,​Boolean> supplier)
      Fill the array with values returned by the supplier
      static void fillArray​(boolean[] array, Supplier<Boolean> s)
      Fill the entire array with the value returned by the supplier.
      static void fillArray​(byte[] array, Supplier<Byte> s)
      Fill the entire array with the value returned by the supplier.
      static void fillArray​(char[] array, Function<Integer,​Character> supplier)
      Fill the array with values returned by the supplier
      static void fillArray​(char[] array, Supplier<Character> s)
      Fill the entire array with the value returned by the supplier.
      static void fillArray​(double[] array, Function<Integer,​Double> supplier)
      Fill the array with values returned by the supplier
      static void fillArray​(double[] array, Supplier<Double> s)
      Fill the entire array with the value returned by the supplier.
      static void fillArray​(float[] array, Function<Integer,​Float> supplier)
      Fill the array with values returned by the supplier
      static void fillArray​(float[] array, Supplier<Float> s)
      Fill the entire array with the value returned by the supplier.
      static void fillArray​(int[] array, Function<Integer,​Integer> supplier)
      Fill the array with values returned by the supplier
      static void fillArray​(int[] array, Supplier<Integer> s)
      Fill the entire array with the value returned by the supplier.
      static void fillArray​(long[] array, Function<Integer,​Long> supplier)
      Fill the array with values returned by the supplier
      static void fillArray​(long[] array, Supplier<Long> s)
      Fill the entire array with the value returned by the supplier.
      static void fillArray​(short[] array, Function<Integer,​Short> supplier)
      Fill the array with values returned by the supplier
      static void fillArray​(short[] array, Supplier<Short> s)
      Fill the entire array with the value returned by the supplier.
      static <T> void fillArray​(T[] array, Function<Integer,​T> supplier)
      Fill the array with values returned by the supplier
      static <T> void fillArray​(T[] array, Supplier<T> s)
      Fill the entire array with the value returned by the supplier.
      static <T> T fillArrayMulti​(T array, Function<Integer,​T> s)
      Fill a multi dimensional array with the value returned by the supplier
      static <T> T fillArrayMulti​(T array, Supplier<T> s)
      Fill a multi dimensional array with the value returned by the supplier
      static <T> int frontBackSearch​(T[] array, T needle)
      Search the specified array for the specified value.
      static <T> int frontBackSearch​(T[] array, T needle, int from, int to)
      Search the specified array for the specified value.
      static <T> T get​(Object array, int... index)  
      static int[] getSortedIndices​(boolean[] array, boolean descending)
      Compute the sorted indices for the array.
      static int[] getSortedIndices​(byte[] array, boolean descending)
      Compute the sorted indices for the array.
      static int[] getSortedIndices​(char[] array, boolean descending)
      Compute the sorted indices for the array.
      static int[] getSortedIndices​(double[] array, boolean descending)
      Compute the sorted indices for the array.
      static int[] getSortedIndices​(float[] array, boolean descending)
      Compute the sorted indices for the array.
      static int[] getSortedIndices​(int[] array, boolean descending)
      Compute the sorted indices for the array.
      static int[] getSortedIndices​(long[] array, boolean descending)
      Compute the sorted indices for the array.
      static int[] getSortedIndices​(short[] array, boolean descending)
      Compute the sorted indices for the array.
      static <T> int linearSearch​(T[] array, T needle)
      Search the specified array for the specified value.
      static <T> int linearSearch​(T[] array, T needle, int start, int stop)
      Search the specified array for the specified value.
      static byte maximum​(byte[] array)
      Find the maximum value of the array
      static char maximum​(char[] array)
      Find the maximum value of the array
      static double maximum​(double[] array)
      Find the maximum value of the array
      static float maximum​(float[] array)
      Find the maximum value of the array
      static int maximum​(int[] array)
      Find the maximum value of the array
      static long maximum​(long[] array)
      Find the maximum value of the array
      static short maximum​(short[] array)
      Find the maximum value of the array
      static int maximumIndex​(byte[] array)
      Find the index of the maximum value of the array.
      static int maximumIndex​(char[] array)
      Find the index of the maximum value of the array.
      static int maximumIndex​(double[] array)
      Find the index of the maximum value of the array.
      static int maximumIndex​(float[] array)
      Find the index of the maximum value of the array.
      static int maximumIndex​(int[] array)
      Find the index of the maximum value of the array.
      static int maximumIndex​(long[] array)
      Find the index of the maximum value of the array.
      static int maximumIndex​(short[] array)
      Find the index of the maximum value of the array.
      static double median​(byte[] array)
      Calculate the median value of the array
      static double median​(char[] array)
      Calculate the median value of the array
      static double median​(double[] array)
      Calculate the median value of the array
      static double median​(float[] array)
      Calculate the median value of the array
      static double median​(int[] array)
      Calculate the median value of the array
      static double median​(long[] array)
      Calculate the median value of the array
      static double median​(short[] array)
      Calculate the median value of the array
      static byte minimum​(byte[] array)
      Find the minimum value of the array
      static char minimum​(char[] array)
      Find the minimum value of the array
      static double minimum​(double[] array)
      Find the minimum value of the array
      static float minimum​(float[] array)
      Find the minimum value of the array
      static int minimum​(int[] array)
      Find the minimum value of the array
      static long minimum​(long[] array)
      Find the minimum value of the array
      static short minimum​(short[] array)
      Find the minimum value of the array
      static int minimumIndex​(byte[] array)
      Find the index of the minimum value of the array.
      static int minimumIndex​(char[] array)
      Find the index of the minimum value of the array.
      static int minimumIndex​(double[] array)
      Find the index of the minimum value of the array.
      static int minimumIndex​(float[] array)
      Find the index of the minimum value of the array.
      static int minimumIndex​(int[] array)
      Find the index of the minimum value of the array.
      static int minimumIndex​(long[] array)
      Find the index of the minimum value of the array.
      static int minimumIndex​(short[] array)
      Find the index of the minimum value of the array.
      static void multiply​(byte[] arr, byte factor)
      Scalar Multiplication.
      static void multiply​(byte[] arr, byte[] factors)
      Pairwise multiply the two vectors.
      static void multiply​(char[] arr, char factor)
      Scalar Multiplication.
      static void multiply​(char[] arr, char[] factors)
      Pairwise multiply the two vectors.
      static void multiply​(double[] arr, double factor)
      Scalar Multiplication.
      static void multiply​(double[] arr, double[] factors)
      Pairwise multiply the two vectors.
      static void multiply​(float[] arr, float factor)
      Scalar Multiplication.
      static void multiply​(float[] arr, float[] factors)
      Pairwise multiply the two vectors.
      static void multiply​(int[] arr, int factor)
      Scalar Multiplication.
      static void multiply​(int[] arr, int[] factors)
      Pairwise multiply the two vectors.
      static void multiply​(long[] arr, long factor)
      Scalar Multiplication.
      static void multiply​(long[] arr, long[] factors)
      Pairwise multiply the two vectors.
      static void multiply​(short[] arr, short factor)
      Scalar Multiplication.
      static void multiply​(short[] arr, short[] factors)
      Pairwise multiply the two vectors.
      static void subtract​(byte[] arrMinuend, byte subtrahend)
      Calculate the difference for each field in the array
      static void subtract​(char[] arrMinuend, char subtrahend)
      Calculate the difference for each field in the array
      static void subtract​(double[] arrMinuend, double subtrahend)
      Calculate the difference for each field in the array
      static void subtract​(float[] arrMinuend, float subtrahend)
      Calculate the difference for each field in the array
      static void subtract​(int[] arrMinuend, int subtrahend)
      Calculate the difference for each field in the array
      static void subtract​(long[] arrMinuend, long subtrahend)
      Calculate the difference for each field in the array
      static void subtract​(short[] arrMinuend, short subtrahend)
      Calculate the difference for each field in the array
      static String toString​(double[] array, int decimalPlaces)
      Return the string representation of an array containing floating point numbers with fixed decimal places.The string representation consists of a list of the array's elements,enclosed in square brackets ("[]").
      static String toString​(float[] array, int decimalPlaces)
      Return the string representation of an array containing floating point numbers with fixed decimal places.
      static String toString​(Object[] array)
      Returns a string representation of the contents of the specified array.If the array contains other arrays as elements, they are converted to strings by the Object.toString method inherited from Object, which describes their identities rather than their contents.
      static int twoDimtoOneDim​(int x, int y, int width)
      Map 2 dimensional coordinates to a one dimensional array
    • Constructor Detail

      • ArrayUtil

        public ArrayUtil()
    • Method Detail

      • toString

        public static String toString​(double[] array,
                                      int decimalPlaces)
        Return the string representation of an array containing floating point numbers with fixed decimal places.The string representation consists of a list of the array's elements,enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (a comma followed by a space). Elements are converted to strings as by String.valueOf(double). Returns "null" if a is null.
        Parameters:
        array - The array content to convert to a string
        decimalPlaces - the number of fractional numbers shown for each entry
        Returns:
        a string representation of the double array
        Since:
        1.0.0 com.github.kilianB
      • toString

        public static String toString​(float[] array,
                                      int decimalPlaces)
        Return the string representation of an array containing floating point numbers with fixed decimal places. The string representation consists of a list of the array's elements,enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (a comma followed by a space). Elements are converted to strings as by String.valueOf(float). Returns "null" if a is null.
        Parameters:
        array - The array content to convert to a string
        decimalPlaces - the number of fractional numbers shown for each entry
        Returns:
        a string representation of the float array
        Since:
        1.0.0 com.github.kilianB
      • deepToStringFormatted

        public static String deepToStringFormatted​(Object[] array)
        Returns a string representation of the "deep contents" of the specified array. If the array contains other arrays as elements, the string representation contains their contents and so on. This method is designed for converting multidimensional arrays to strings.

        A linebreak is introduced after every array useful to visualize 2d datastructures.

        Parameters:
        array - the array whose string representation to return
        Returns:
        a formatted string representation of the array
        Since:
        1.5.0 com.github.kilianB
      • deepToString

        public static String deepToString​(Object[] array)
        Returns a string representation of the "deep contents" of the specified array. If the array contains other arrays as elements, the string representation contains their contents and so on. This method is designed for converting multidimensional arrays to strings.
        Parameters:
        array - the array whose string representation to return
        Returns:
        a formatted string representation of the array
        Since:
        1.5.0 com.github.kilianB
      • toString

        public static String toString​(Object[] array)
        Returns a string representation of the contents of the specified array.If the array contains other arrays as elements, they are converted to strings by the Object.toString method inherited from Object, which describes their identities rather than their contents.
        Parameters:
        array - the array whose string representation to return
        Returns:
        a string representation of the array
        Since:
        1.5.0 com.github.kilianB
      • deepArrayCopy

        public static <T> T[] deepArrayCopy​(T[] array)
        Deep copy nested arrays. A shallow copy of each array contained in this array will be created allowing to alter the values without affecting the original data structure. Be aware that the individual components are only copied and still point to the same object.

        If a true deep clone is required take a look at deepArrayCopyClone(Object[]) instead.

        Type Parameters:
        T - the type of the array
        Parameters:
        array - The array to clone
        Returns:
        an new array with all nested arrays being replaced by copies.
        Since:
        1.0.0 com.github.kilianB
      • deepArrayCopyClone

        @Deprecated
        public static <T> T[] deepArrayCopyClone​(T[] array)
                                          throws Exception
        Deprecated.
        Deep copies the array structures as well as attempts to call Object.clone() if the element implements the the cloneable interface. Even if cloneable is implemented no guarantee is made that the returned element is in fact a deep clone of the base object. The class specific clone implementation has to be looked at individually. Untested
        Type Parameters:
        T - the type of the array
        Parameters:
        array - The array to clone
        Returns:
        a truly deep cloned array
        Throws:
        Exception - if an exception occurs during cloning of individual objects
        Since:
        1.0.0 com.github.kilianB
      • deepAllNotNull

        public static boolean deepAllNotNull​(Object[] array)
        Check if all values in the array are not null. This operation supports nested arrays
        Parameters:
        array - to check
        Returns:
        true if all elements in the array are not null
        Since:
        1.0.0 com.github.kilianB
      • allNotNull

        public static <T> boolean allNotNull​(T[] array)
        Check if all values in the array are not null
        Type Parameters:
        T - the type of the array
        Parameters:
        array - to check
        Returns:
        true if all elements in the array are not null
        Since:
        1.0.0 com.github.kilianB
      • allNull

        public static <T> boolean allNull​(T[] array)
        Check if all values in the array are null
        Type Parameters:
        T - the type of the array
        Parameters:
        array - to check
        Returns:
        true if all elements in the array are null
        Since:
        1.0.0 com.github.kilianB
      • twoDimtoOneDim

        public static int twoDimtoOneDim​(int x,
                                         int y,
                                         int width)
        Map 2 dimensional coordinates to a one dimensional array
        Parameters:
        x - The first coordinate
        y - The second coordinate
        width - the width of the 2 dim array
        Returns:
        a mapped integer.
        Since:
        1.0.0 com.github.kilianB
      • fillArray

        public static <T> void fillArray​(T[] array,
                                         Supplier<T> s)
        Fill the entire array with the value returned by the supplier.
        Type Parameters:
        T - The type of the array
        Parameters:
        array - The array to fill
        s - The supplier used
        Since:
        1.0.0 com.github.kilianB
      • fillArrayMulti

        public static <T> T fillArrayMulti​(T array,
                                           Supplier<T> s)
        Fill a multi dimensional array with the value returned by the supplier
        Type Parameters:
        T - the type of the array
        Parameters:
        array - The array to fill
        s - The supplier
        Returns:
        the supplied array. The return value is used to allow recursive behavior of the method and can safely be ignored by the user. The original supplied array is identical to the returned reference. If the supplied array is not an array null will be returned.
        Since:
        1.2.0 com.github.kilianB
      • fillArrayMulti

        public static <T> T fillArrayMulti​(T array,
                                           Function<Integer,​T> s)
        Fill a multi dimensional array with the value returned by the supplier
        Type Parameters:
        T - the type of the array
        Parameters:
        array - The array to fill
        s - The supplier taking the index of the current array as argument
        Returns:
        the supplied array. The return value is used to allow recursive behavior of the method and can safely be ignored by the user. The original supplied array is identical to the returned reference. If the supplied array is not an array null will be returned.
        Since:
        1.2.0 com.github.kilianB
      • fillArray

        public static void fillArray​(boolean[] array,
                                     Supplier<Boolean> s)
        Fill the entire array with the value returned by the supplier.
        Parameters:
        array - The array to fill
        s - The supplier used
        Since:
        1.0.0 com.github.kilianB
      • fillArray

        public static void fillArray​(byte[] array,
                                     Supplier<Byte> s)
        Fill the entire array with the value returned by the supplier.
        Parameters:
        array - The array to fill
        s - The supplier used
        Since:
        1.0.0 com.github.kilianB
      • fillArray

        public static void fillArray​(char[] array,
                                     Supplier<Character> s)
        Fill the entire array with the value returned by the supplier.
        Parameters:
        array - The array to fill
        s - The supplier used
        Since:
        1.0.0 com.github.kilianB
      • fillArray

        public static void fillArray​(short[] array,
                                     Supplier<Short> s)
        Fill the entire array with the value returned by the supplier.
        Parameters:
        array - The array to fill
        s - The supplier used
        Since:
        1.0.0 com.github.kilianB
      • fillArray

        public static void fillArray​(int[] array,
                                     Supplier<Integer> s)
        Fill the entire array with the value returned by the supplier.
        Parameters:
        array - The array to fill
        s - The supplier used
        Since:
        1.0.0 com.github.kilianB
      • fillArray

        public static void fillArray​(long[] array,
                                     Supplier<Long> s)
        Fill the entire array with the value returned by the supplier.
        Parameters:
        array - The array to fill
        s - The supplier used
        Since:
        1.0.0 com.github.kilianB
      • fillArray

        public static void fillArray​(float[] array,
                                     Supplier<Float> s)
        Fill the entire array with the value returned by the supplier.
        Parameters:
        array - The array to fill
        s - The supplier used
        Since:
        1.0.0 com.github.kilianB
      • fillArray

        public static void fillArray​(double[] array,
                                     Supplier<Double> s)
        Fill the entire array with the value returned by the supplier.
        Parameters:
        array - The array to fill
        s - The supplier used
        Since:
        1.0.0 com.github.kilianB
      • fillArray

        public static void fillArray​(boolean[] array,
                                     Function<Integer,​Boolean> supplier)
        Fill the array with values returned by the supplier
        Parameters:
        array - the array to fill
        supplier - A function returning a value whose argument takes the index of the array
        Since:
        1.4.4 com.github.kilianB
      • fillArray

        public static void fillArray​(char[] array,
                                     Function<Integer,​Character> supplier)
        Fill the array with values returned by the supplier
        Parameters:
        array - the array to fill
        supplier - A function returning a value whose argument takes the index of the array
        Since:
        1.4.4 com.github.kilianB
      • fillArray

        public static void fillArray​(short[] array,
                                     Function<Integer,​Short> supplier)
        Fill the array with values returned by the supplier
        Parameters:
        array - the array to fill
        supplier - A function returning a value whose argument takes the index of the array
        Since:
        1.4.4 com.github.kilianB
      • fillArray

        public static void fillArray​(int[] array,
                                     Function<Integer,​Integer> supplier)
        Fill the array with values returned by the supplier
        Parameters:
        array - the array to fill
        supplier - A function returning a value whose argument takes the index of the array
        Since:
        1.4.4 com.github.kilianB
      • fillArray

        public static void fillArray​(long[] array,
                                     Function<Integer,​Long> supplier)
        Fill the array with values returned by the supplier
        Parameters:
        array - the array to fill
        supplier - A function returning a value whose argument takes the index of the array
        Since:
        1.4.4 com.github.kilianB
      • fillArray

        public static void fillArray​(float[] array,
                                     Function<Integer,​Float> supplier)
        Fill the array with values returned by the supplier
        Parameters:
        array - the array to fill
        supplier - A function returning a value whose argument takes the index of the array
        Since:
        1.4.4 com.github.kilianB
      • fillArray

        public static void fillArray​(double[] array,
                                     Function<Integer,​Double> supplier)
        Fill the array with values returned by the supplier
        Parameters:
        array - the array to fill
        supplier - A function returning a value whose argument takes the index of the array
        Since:
        1.4.4 com.github.kilianB
      • fillArray

        public static <T> void fillArray​(T[] array,
                                         Function<Integer,​T> supplier)
        Fill the array with values returned by the supplier
        Type Parameters:
        T - the type of the array
        Parameters:
        array - the array to fill
        supplier - A function returning a value whose argument takes the index of the array
        Since:
        1.4.4 com.github.kilianB
      • linearSearch

        public static <T> int linearSearch​(T[] array,
                                           T needle,
                                           int start,
                                           int stop)
        Search the specified array for the specified value. This operation works on unsorted array but has a O(N) worst case time complexity. For efficient searching consider Arrays.binarySearch(long[], long).

        If the same array gets searched consistently you may also consider creating a hash index to bring down the search to O(1).

        Type Parameters:
        T - the type of the array
        Parameters:
        array - the array to be searched
        needle - the value to search for
        start - the index position to start searching from
        stop - the last index position to stop search at
        Returns:
        the index position of the value if found or -1 if not present
        Since:
        1.0.0 com.github.kilianB
      • linearSearch

        public static <T> int linearSearch​(T[] array,
                                           T needle)
        Search the specified array for the specified value. This operation works on unsorted array but has a O(N) worst case time complexity. For efficient searching consider Arrays.binarySearch(long[], long).

        If the same array gets searched consistently you may also consider creating a hash index to bring down the search to O(1).

        Type Parameters:
        T - the type of the array
        Parameters:
        array - the array to be searched
        needle - the value to search for
        Returns:
        the index position of the value if found or -1 if not present
        Since:
        1.0.0 com.github.kilianB
      • frontBackSearch

        public static <T> int frontBackSearch​(T[] array,
                                              T needle,
                                              int from,
                                              int to)
        Search the specified array for the specified value. This operation tries to minimize the number of comparisons. The array is search from the beginning and end simultaneously resulting in worst case performance if the searched value is exactly in the middle. For efficient searching consider Arrays.binarySearch(long[], long).

        If the same array gets searched consistently you may also consider creating a hash index to bring down the search to O(1).

        Type Parameters:
        T - the type of the array
        Parameters:
        array - the array to be searched
        needle - the value to search for
        from - the index position to start searching from
        to - the last index positin to stop search at
        Returns:
        the index position of the value if found or -1 if not present
        Throws:
        ArrayIndexOutOfBoundsException - if from or two are outside of the array
        Since:
        1.0.0 com.github.kilianB
      • frontBackSearch

        public static <T> int frontBackSearch​(T[] array,
                                              T needle)
        Search the specified array for the specified value. This operation tries to minimize the number of comparisons. The array is search from the beginning and end simultaneously resulting in worst case performance if the searched value is exactly in the middle. For efficient searching consider Arrays.binarySearch(long[], long).

        If the same array gets searched consistently you may also consider creating a hash index to bring down the search to O(1).

        Type Parameters:
        T - the type of the array
        Parameters:
        array - the array to be searched
        needle - the value to search for
        Returns:
        the index position of the value if found or -1 if not present
        Since:
        1.0.0 com.github.kilianB
      • getSortedIndices

        public static int[] getSortedIndices​(boolean[] array,
                                             boolean descending)
        Compute the sorted indices for the array. The indices can be used to access the content of the array in sorted order. The first index of the returned array will either point to the highest or lowest value, the second index to the second highest/lowest ... found in the array.

        If duplicate values exist in the array no stability guarantee is made.

        ImplNote: TODO: check the performance of this method. An additional class can be constructed holding index value pairs and sorting this omitting the creation of a map. In turn this would mean that a new class must be created for every primitive type. If this is considered to slow maybe even using optimized collections like Colt's int int hashmap might be suitable.

        Parameters:
        array - the array to compute the sorted indexes for
        descending - if true compute descending indices else ascending
        Returns:
        an array containing sort indices
        Since:
        1.4.4 com.github.kilianB
      • getSortedIndices

        public static int[] getSortedIndices​(byte[] array,
                                             boolean descending)
        Compute the sorted indices for the array. The indices can be used to access the content of the array in sorted order. The first index of the returned array will either point to the highest or lowest value, the second index to the second highest/lowest ... found in the array.

        If duplicate values exist in the array no stability guarantee is made.

        ImplNote: TODO: check the performance of this method. An additional class can be constructed holding index value pairs and sorting this omitting the creation of a map. In turn this would mean that a new class must be created for every primitive type. If this is considered to slow maybe even using optimized collections like Colt's int int hashmap might be suitable.

        Parameters:
        array - the array to compute the sorted indexes for
        descending - if true compute descending indices else ascending
        Returns:
        an array containing sort indices
        Since:
        1.4.4 com.github.kilianB
      • getSortedIndices

        public static int[] getSortedIndices​(char[] array,
                                             boolean descending)
        Compute the sorted indices for the array. The indices can be used to access the content of the array in sorted order. The first index of the returned array will either point to the highest or lowest value, the second index to the second highest/lowest ... found in the array.

        If duplicate values exist in the array no stability guarantee is made.

        ImplNote: TODO: check the performance of this method. An additional class can be constructed holding index value pairs and sorting this omitting the creation of a map. In turn this would mean that a new class must be created for every primitive type. If this is considered to slow maybe even using optimized collections like Colt's int int hashmap might be suitable.

        Parameters:
        array - the array to compute the sorted indexes for
        descending - if true compute descending indices else ascending
        Returns:
        an array containing sort indices
        Since:
        1.4.4 com.github.kilianB
      • getSortedIndices

        public static int[] getSortedIndices​(short[] array,
                                             boolean descending)
        Compute the sorted indices for the array. The indices can be used to access the content of the array in sorted order. The first index of the returned array will either point to the highest or lowest value, the second index to the second highest/lowest ... found in the array.

        If duplicate values exist in the array no stability guarantee is made.

        ImplNote: TODO: check the performance of this method. An additional class can be constructed holding index value pairs and sorting this omitting the creation of a map. In turn this would mean that a new class must be created for every primitive type. If this is considered to slow maybe even using optimized collections like Colt's int int hashmap might be suitable.

        Parameters:
        array - the array to compute the sorted indexes for
        descending - if true compute descending indices else ascending
        Returns:
        an array containing sort indices
        Since:
        1.4.4 com.github.kilianB
      • getSortedIndices

        public static int[] getSortedIndices​(int[] array,
                                             boolean descending)
        Compute the sorted indices for the array. The indices can be used to access the content of the array in sorted order. The first index of the returned array will either point to the highest or lowest value, the second index to the second highest/lowest ... found in the array.

        If duplicate values exist in the array no stability guarantee is made.

        ImplNote: TODO: check the performance of this method. An additional class can be constructed holding index value pairs and sorting this omitting the creation of a map. In turn this would mean that a new class must be created for every primitive type. If this is considered to slow maybe even using optimized collections like Colt's int int hashmap might be suitable.

        Parameters:
        array - the array to compute the sorted indexes for
        descending - if true compute descending indices else ascending
        Returns:
        an array containing sort indices
        Since:
        1.4.4 com.github.kilianB
      • getSortedIndices

        public static int[] getSortedIndices​(long[] array,
                                             boolean descending)
        Compute the sorted indices for the array. The indices can be used to access the content of the array in sorted order. The first index of the returned array will either point to the highest or lowest value, the second index to the second highest/lowest ... found in the array.

        If duplicate values exist in the array no stability guarantee is made.

        ImplNote: TODO: check the performance of this method. An additional class can be constructed holding index value pairs and sorting this omitting the creation of a map. In turn this would mean that a new class must be created for every primitive type. If this is considered to slow maybe even using optimized collections like Colt's int int hashmap might be suitable.

        Parameters:
        array - the array to compute the sorted indexes for
        descending - if true compute descending indices else ascending
        Returns:
        an array containing sort indices
        Since:
        1.4.4 com.github.kilianB
      • getSortedIndices

        public static int[] getSortedIndices​(float[] array,
                                             boolean descending)
        Compute the sorted indices for the array. The indices can be used to access the content of the array in sorted order. The first index of the returned array will either point to the highest or lowest value, the second index to the second highest/lowest ... found in the array.

        If duplicate values exist in the array no stability guarantee is made.

        ImplNote: TODO: check the performance of this method. An additional class can be constructed holding index value pairs and sorting this omitting the creation of a map. In turn this would mean that a new class must be created for every primitive type. If this is considered to slow maybe even using optimized collections like Colt's int int hashmap might be suitable.

        Parameters:
        array - the array to compute the sorted indexes for
        descending - if true compute descending indices else ascending
        Returns:
        an array containing sort indices
        Since:
        1.4.4 com.github.kilianB
      • getSortedIndices

        public static int[] getSortedIndices​(double[] array,
                                             boolean descending)
        Compute the sorted indices for the array. The indices can be used to access the content of the array in sorted order. The first index of the returned array will either point to the highest or lowest value, the second index to the second highest/lowest ... found in the array.

        If duplicate values exist in the array no stability guarantee is made.

        ImplNote: TODO: check the performance of this method. An additional class can be constructed holding index value pairs and sorting this omitting the creation of a map. In turn this would mean that a new class must be created for every primitive type. If this is considered to slow maybe even using optimized collections like Colt's int int hashmap might be suitable.

        Parameters:
        array - the array to compute the sorted indexes for
        descending - if true compute descending indices else ascending
        Returns:
        an array containing sort indices
        Since:
        1.4.4 com.github.kilianB
      • minimumIndex

        public static int minimumIndex​(byte[] array)
        Find the index of the minimum value of the array.

        If the minimum value is present multiple times the first occurrence will be returned.

        Parameters:
        array - the array to check
        Returns:
        the index of the minimum value of the array or -1 if the array is empty
        Throws:
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • minimumIndex

        public static int minimumIndex​(char[] array)
        Find the index of the minimum value of the array.

        If the minimum value is present multiple times the first occurrence will be returned.

        Parameters:
        array - the array to check
        Returns:
        the index of the minimum value of the array or -1 if the array is empty
        Throws:
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • minimumIndex

        public static int minimumIndex​(short[] array)
        Find the index of the minimum value of the array.

        If the minimum value is present multiple times the first occurrence will be returned.

        Parameters:
        array - the array to check
        Returns:
        the index of the minimum value of the array or -1 if the array is empty
        Throws:
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • minimumIndex

        public static int minimumIndex​(int[] array)
        Find the index of the minimum value of the array.

        If the minimum value is present multiple times the first occurrence will be returned.

        Parameters:
        array - the array to check
        Returns:
        the index of the minimum value of the array or -1 if the array is empty
        Throws:
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • minimumIndex

        public static int minimumIndex​(long[] array)
        Find the index of the minimum value of the array.

        If the minimum value is present multiple times the first occurrence will be returned.

        Parameters:
        array - the array to check
        Returns:
        the index of the minimum value of the array or -1 if the array is empty
        Throws:
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • minimumIndex

        public static int minimumIndex​(float[] array)
        Find the index of the minimum value of the array.

        If the minimum value is present multiple times the first occurrence will be returned.

        Parameters:
        array - the array to check
        Returns:
        the index of the minimum value of the array or -1 if the array is empty
        Throws:
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • minimumIndex

        public static int minimumIndex​(double[] array)
        Find the index of the minimum value of the array.

        If the minimum value is present multiple times the first occurrence will be returned.

        Parameters:
        array - the array to check
        Returns:
        the index of the minimum value of the array or -1 if the array is empty
        Throws:
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • minimum

        public static byte minimum​(byte[] array)
        Find the minimum value of the array
        Parameters:
        array - the array to check
        Returns:
        the minimum value of the array
        Throws:
        IndexOutOfBoundsException - if the array is empty
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • minimum

        public static char minimum​(char[] array)
        Find the minimum value of the array
        Parameters:
        array - the array to check
        Returns:
        the minimum value of the array
        Throws:
        IndexOutOfBoundsException - if the array is empty
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • minimum

        public static short minimum​(short[] array)
        Find the minimum value of the array
        Parameters:
        array - the array to check
        Returns:
        the minimum value of the array
        Throws:
        IndexOutOfBoundsException - if the array is empty
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • minimum

        public static int minimum​(int[] array)
        Find the minimum value of the array
        Parameters:
        array - the array to check
        Returns:
        the minimum value of the array
        Throws:
        IndexOutOfBoundsException - if the array is empty
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • minimum

        public static long minimum​(long[] array)
        Find the minimum value of the array
        Parameters:
        array - the array to check
        Returns:
        the minimum value of the array
        Throws:
        IndexOutOfBoundsException - if the array is empty
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • minimum

        public static float minimum​(float[] array)
        Find the minimum value of the array
        Parameters:
        array - the array to check
        Returns:
        the minimum value of the array
        Throws:
        IndexOutOfBoundsException - if the array is empty
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • minimum

        public static double minimum​(double[] array)
        Find the minimum value of the array
        Parameters:
        array - the array to check
        Returns:
        the minimum value of the array
        Throws:
        IndexOutOfBoundsException - if the array is empty
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • maximumIndex

        public static int maximumIndex​(byte[] array)
        Find the index of the maximum value of the array.

        If the maximum value is present multiple times the first occurrence will be returned.

        Parameters:
        array - the array to check
        Returns:
        the index of the maximum value of the array or -1 if the array is empty
        Throws:
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • maximumIndex

        public static int maximumIndex​(char[] array)
        Find the index of the maximum value of the array.

        If the maximum value is present multiple times the first occurrence will be returned.

        Parameters:
        array - the array to check
        Returns:
        the index of the maximum value of the array or -1 if the array is empty
        Throws:
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • maximumIndex

        public static int maximumIndex​(short[] array)
        Find the index of the maximum value of the array.

        If the maximum value is present multiple times the first occurrence will be returned.

        Parameters:
        array - the array to check
        Returns:
        the index of the maximum value of the array or -1 if the array is empty
        Throws:
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • maximumIndex

        public static int maximumIndex​(int[] array)
        Find the index of the maximum value of the array.

        If the maximum value is present multiple times the first occurrence will be returned.

        Parameters:
        array - the array to check
        Returns:
        the index of the maximum value of the array or -1 if the array is empty
        Throws:
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • maximumIndex

        public static int maximumIndex​(long[] array)
        Find the index of the maximum value of the array.

        If the maximum value is present multiple times the first occurrence will be returned.

        Parameters:
        array - the array to check
        Returns:
        the index of the maximum value of the array or -1 if the array is empty
        Throws:
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • maximumIndex

        public static int maximumIndex​(float[] array)
        Find the index of the maximum value of the array.

        If the maximum value is present multiple times the first occurrence will be returned.

        Parameters:
        array - the array to check
        Returns:
        the index of the maximum value of the array or -1 if the array is empty
        Throws:
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • maximumIndex

        public static int maximumIndex​(double[] array)
        Find the index of the maximum value of the array.

        If the maximum value is present multiple times the first occurrence will be returned.

        Parameters:
        array - the array to check
        Returns:
        the index of the maximum value of the array or -1 if the array is empty
        Throws:
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • maximum

        public static byte maximum​(byte[] array)
        Find the maximum value of the array
        Parameters:
        array - the array to check
        Returns:
        the maximum value of the array
        Throws:
        IndexOutOfBoundsException - if the array is empty
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • maximum

        public static char maximum​(char[] array)
        Find the maximum value of the array
        Parameters:
        array - the array to check
        Returns:
        the maximum value of the array
        Throws:
        IndexOutOfBoundsException - if the array is empty
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • maximum

        public static short maximum​(short[] array)
        Find the maximum value of the array
        Parameters:
        array - the array to check
        Returns:
        the maximum value of the array
        Throws:
        IndexOutOfBoundsException - if the array is empty
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • maximum

        public static int maximum​(int[] array)
        Find the maximum value of the array
        Parameters:
        array - the array to check
        Returns:
        the maximum value of the array
        Throws:
        IndexOutOfBoundsException - if the array is empty
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • maximum

        public static long maximum​(long[] array)
        Find the maximum value of the array
        Parameters:
        array - the array to check
        Returns:
        the maximum value of the array
        Throws:
        IndexOutOfBoundsException - if the array is empty
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • maximum

        public static float maximum​(float[] array)
        Find the maximum value of the array
        Parameters:
        array - the array to check
        Returns:
        the maximum value of the array
        Throws:
        IndexOutOfBoundsException - if the array is empty
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • maximum

        public static double maximum​(double[] array)
        Find the maximum value of the array
        Parameters:
        array - the array to check
        Returns:
        the maximum value of the array
        Throws:
        IndexOutOfBoundsException - if the array is empty
        NullPointerException - if the array is null
        Since:
        1.4.0 com.github.kilianB
      • add

        public static void add​(byte[] arr,
                               byte summand)
        Add the supplied argument to every field in the array
        Parameters:
        arr - the array holding the first summand
        summand - the value to add to each field
        Since:
        1.4.0 com.github.kilianB
      • add

        public static void add​(char[] arr,
                               char summand)
        Add the supplied argument to every field in the array
        Parameters:
        arr - the array holding the first summand
        summand - the value to add to each field
        Since:
        1.4.0 com.github.kilianB
      • add

        public static void add​(short[] arr,
                               short summand)
        Add the supplied argument to every field in the array
        Parameters:
        arr - the array holding the first summand
        summand - the value to add to each field
        Since:
        1.4.0 com.github.kilianB
      • add

        public static void add​(int[] arr,
                               int summand)
        Add the supplied argument to every field in the array
        Parameters:
        arr - the array holding the first summand
        summand - the value to add to each field
        Since:
        1.4.0 com.github.kilianB
      • add

        public static void add​(long[] arr,
                               long summand)
        Add the supplied argument to every field in the array
        Parameters:
        arr - the array holding the first summand
        summand - the value to add to each field
        Since:
        1.4.0 com.github.kilianB
      • add

        public static void add​(float[] arr,
                               float summand)
        Add the supplied argument to every field in the array
        Parameters:
        arr - the array holding the first summand
        summand - the value to add to each field
        Since:
        1.4.0 com.github.kilianB
      • add

        public static void add​(double[] arr,
                               double summand)
        Add the supplied argument to every field in the array
        Parameters:
        arr - the array holding the first summand
        summand - the value to add to each field
        Since:
        1.4.0 com.github.kilianB
      • subtract

        public static void subtract​(byte[] arrMinuend,
                                    byte subtrahend)
        Calculate the difference for each field in the array
        Parameters:
        arrMinuend - the array holding the minuend
        subtrahend - the value to subtracted from each field
        Since:
        1.4.0 com.github.kilianB
      • subtract

        public static void subtract​(char[] arrMinuend,
                                    char subtrahend)
        Calculate the difference for each field in the array
        Parameters:
        arrMinuend - the array holding the minuend
        subtrahend - the value to subtracted from each field
        Since:
        1.4.0 com.github.kilianB
      • subtract

        public static void subtract​(short[] arrMinuend,
                                    short subtrahend)
        Calculate the difference for each field in the array
        Parameters:
        arrMinuend - the array holding the minuend
        subtrahend - the value to subtracted from each field
        Since:
        1.4.0 com.github.kilianB
      • subtract

        public static void subtract​(int[] arrMinuend,
                                    int subtrahend)
        Calculate the difference for each field in the array
        Parameters:
        arrMinuend - the array holding the minuend
        subtrahend - the value to subtracted from each field
        Since:
        1.4.0 com.github.kilianB
      • subtract

        public static void subtract​(long[] arrMinuend,
                                    long subtrahend)
        Calculate the difference for each field in the array
        Parameters:
        arrMinuend - the array holding the minuend
        subtrahend - the value to subtracted from each field
        Since:
        1.4.0 com.github.kilianB
      • subtract

        public static void subtract​(float[] arrMinuend,
                                    float subtrahend)
        Calculate the difference for each field in the array
        Parameters:
        arrMinuend - the array holding the minuend
        subtrahend - the value to subtracted from each field
        Since:
        1.4.0 com.github.kilianB
      • subtract

        public static void subtract​(double[] arrMinuend,
                                    double subtrahend)
        Calculate the difference for each field in the array
        Parameters:
        arrMinuend - the array holding the minuend
        subtrahend - the value to subtracted from each field
        Since:
        1.4.0 com.github.kilianB
      • multiply

        public static void multiply​(byte[] arr,
                                    byte factor)
        Scalar Multiplication. Calculate the product for each field in the array.
        Parameters:
        arr - the array holding the first factor
        factor - the value to multiply each field by
        Since:
        1.4.0 com.github.kilianB
      • multiply

        public static void multiply​(char[] arr,
                                    char factor)
        Scalar Multiplication. Calculate the product for each field in the array
        Parameters:
        arr - the array holding the first factor
        factor - the value to multiply each field by
        Since:
        1.4.0 com.github.kilianB
      • multiply

        public static void multiply​(short[] arr,
                                    short factor)
        Scalar Multiplication. Calculate the product for each field in the array
        Parameters:
        arr - the array holding the first factor
        factor - the value to multiply each field by
        Since:
        1.4.0 com.github.kilianB
      • multiply

        public static void multiply​(int[] arr,
                                    int factor)
        Scalar Multiplication. Calculate the product for each field in the array
        Parameters:
        arr - the array holding the first factor
        factor - the value to multiply each field by
        Since:
        1.4.0 com.github.kilianB
      • multiply

        public static void multiply​(long[] arr,
                                    long factor)
        Scalar Multiplication. Calculate the product for each field in the array
        Parameters:
        arr - the array holding the first factor
        factor - the value to multiply each field by
        Since:
        1.4.0 com.github.kilianB
      • multiply

        public static void multiply​(float[] arr,
                                    float factor)
        Scalar Multiplication. Calculate the product for each field in the array
        Parameters:
        arr - the array holding the first factor
        factor - the value to multiply each field by
        Since:
        1.4.0 com.github.kilianB
      • multiply

        public static void multiply​(double[] arr,
                                    double factor)
        Scalar Multiplication. Calculate the product for each field in the array
        Parameters:
        arr - the array holding the first factor
        factor - the value to multiply each field by
        Since:
        1.4.0 com.github.kilianB
      • divide

        public static void divide​(byte[] arrDividend,
                                  byte divisor)
        Calculate the quotient for each field in the array
        Parameters:
        arrDividend - the array holding the dividend
        divisor - the divisor each field is divided by
        Since:
        1.4.0 com.github.kilianB
      • divide

        public static void divide​(char[] arrDividend,
                                  char divisor)
        Calculate the quotient for each field in the array
        Parameters:
        arrDividend - the array holding the dividend
        divisor - the divisor each field is divided by
        Since:
        1.4.0 com.github.kilianB
      • divide

        public static void divide​(short[] arrDividend,
                                  short divisor)
        Calculate the quotient for each field in the array
        Parameters:
        arrDividend - the array holding the dividend
        divisor - the divisor each field is divided by
        Since:
        1.4.0 com.github.kilianB
      • divide

        public static void divide​(int[] arrDividend,
                                  int divisor)
        Calculate the quotient for each field in the array
        Parameters:
        arrDividend - the array holding the dividend
        divisor - the divisor each field is divided by
        Since:
        1.4.0 com.github.kilianB
      • divide

        public static void divide​(long[] arrDividend,
                                  long divisor)
        Calculate the quotient for each field in the array
        Parameters:
        arrDividend - the array holding the dividend
        divisor - the divisor each field is divided by
        Since:
        1.4.0 com.github.kilianB
      • divide

        public static void divide​(float[] arrDividend,
                                  float divisor)
        Calculate the quotient for each field in the array
        Parameters:
        arrDividend - the array holding the dividend
        divisor - the divisor each field is divided by
        Since:
        1.4.0 com.github.kilianB
      • divide

        public static void divide​(double[] arrDividend,
                                  double divisor)
        Calculate the quotient for each field in the array
        Parameters:
        arrDividend - the array holding the dividend
        divisor - the divisor each field is divided by
        Since:
        1.4.0 com.github.kilianB
      • multiply

        public static void multiply​(byte[] arr,
                                    byte[] factors)
        Pairwise multiply the two vectors. res[i] = a[i] * b[i]
        Parameters:
        arr - the array to be multiplied by the factors
        factors - of the multiplication.
        Throws:
        IndexOutOfBoundsException - if factors array is shorter than the first array
        Since:
        1.4.3 com.github.kilianB
      • multiply

        public static void multiply​(char[] arr,
                                    char[] factors)
        Pairwise multiply the two vectors. res[i] = a[i] * b[i]
        Parameters:
        arr - the array to be multiplied by the factors
        factors - of the multiplication.
        Throws:
        IndexOutOfBoundsException - if factors array is shorter than the first array
        Since:
        1.4.3 com.github.kilianB
      • multiply

        public static void multiply​(short[] arr,
                                    short[] factors)
        Pairwise multiply the two vectors. res[i] = a[i] * b[i]
        Parameters:
        arr - the array to be multiplied by the factors
        factors - of the multiplication.
        Throws:
        IndexOutOfBoundsException - if factors array is shorter than the first array
        Since:
        1.4.3 com.github.kilianB
      • multiply

        public static void multiply​(int[] arr,
                                    int[] factors)
        Pairwise multiply the two vectors. res[i] = a[i] * b[i]
        Parameters:
        arr - the array to be multiplied by the factors
        factors - of the multiplication.
        Throws:
        IndexOutOfBoundsException - if factors array is shorter than the first array
        Since:
        1.4.3 com.github.kilianB
      • multiply

        public static void multiply​(long[] arr,
                                    long[] factors)
        Pairwise multiply the two vectors. res[i] = a[i] * b[i]
        Parameters:
        arr - the array to be multiplied by the factors
        factors - of the multiplication.
        Throws:
        IndexOutOfBoundsException - if factors array is shorter than the first array
        Since:
        1.4.3 com.github.kilianB
      • multiply

        public static void multiply​(float[] arr,
                                    float[] factors)
        Pairwise multiply the two vectors. res[i] = a[i] * b[i]
        Parameters:
        arr - the array to be multiplied by the factors
        factors - of the multiplication.
        Throws:
        IndexOutOfBoundsException - if factors array is shorter than the first array
        Since:
        1.4.3 com.github.kilianB
      • multiply

        public static void multiply​(double[] arr,
                                    double[] factors)
        Pairwise multiply the two vectors. res[i] = a[i] * b[i]
        Parameters:
        arr - the array to be multiplied by the factors
        factors - of the multiplication.
        Throws:
        IndexOutOfBoundsException - if factors array is shorter than the first array
        Since:
        1.4.3 com.github.kilianB
      • divide

        public static void divide​(byte[] arrDivisor,
                                  byte[] dividend)
        Pairwise divide the two vectors. res[i] = a[i] / b[i]
        Parameters:
        arrDivisor - the array to be divided by the dividend
        dividend - of the division.
        Throws:
        IndexOutOfBoundsException - if dividend array is shorter than the first array
        Since:
        1.4.3 com.github.kilianB
      • divide

        public static void divide​(char[] arrDivisor,
                                  char[] dividend)
        Pairwise divide the two vectors. res[i] = a[i] / b[i]
        Parameters:
        arrDivisor - the array to be divided by the dividend
        dividend - of the division.
        Throws:
        IndexOutOfBoundsException - if dividend array is shorter than the first array
        Since:
        1.4.3 com.github.kilianB
      • divide

        public static void divide​(short[] arrDivisor,
                                  short[] dividend)
        Pairwise divide the two vectors. res[i] = a[i] / b[i]
        Parameters:
        arrDivisor - the array to be divided by the dividend
        dividend - of the division.
        Throws:
        IndexOutOfBoundsException - if dividend array is shorter than the first array
        Since:
        1.4.3 com.github.kilianB
      • divide

        public static void divide​(int[] arrDivisor,
                                  int[] dividend)
        Pairwise divide the two vectors. res[i] = a[i] / b[i]
        Parameters:
        arrDivisor - the array to be divided by the dividend
        dividend - of the division.
        Throws:
        IndexOutOfBoundsException - if dividend array is shorter than the first array
        Since:
        1.4.3 com.github.kilianB
      • divide

        public static void divide​(long[] arrDivisor,
                                  long[] dividend)
        Pairwise divide the two vectors. res[i] = a[i] / b[i]
        Parameters:
        arrDivisor - the array to be divided by the dividend
        dividend - of the division.
        Throws:
        IndexOutOfBoundsException - if dividend array is shorter than the first array
        Since:
        1.4.3 com.github.kilianB
      • divide

        public static void divide​(float[] arrDivisor,
                                  float[] dividend)
        Pairwise divide the two vectors. res[i] = a[i] / b[i]
        Parameters:
        arrDivisor - the array to be divided by the dividend
        dividend - of the division.
        Throws:
        IndexOutOfBoundsException - if dividend array is shorter than the first array
        Since:
        1.4.3 com.github.kilianB
      • divide

        public static void divide​(double[] arrDivisor,
                                  double[] dividend)
        Pairwise divide the two vectors. res[i] = a[i] / b[i]
        Parameters:
        arrDivisor - the array to be divided by the dividend
        dividend - of the division.
        Throws:
        IndexOutOfBoundsException - if dividend array is shorter than the first array
        Since:
        1.4.3 com.github.kilianB
      • average

        public static double average​(byte[] array)
        Calculates the average value of the array.
        Parameters:
        array - the array to compute the average value for
        Returns:
        the average value of the array or 0 if the array has a length of 0
        Since:
        1.5.5 com.github.kilianB
      • average

        public static double average​(char[] array)
        Calculates the average value of the array.
        Parameters:
        array - the array to compute the average value for
        Returns:
        the average value of the array or 0 if the array has a length of 0
        Since:
        1.5.5 com.github.kilianB
      • average

        public static double average​(short[] array)
        Calculates the average value of the array.
        Parameters:
        array - the array to compute the average value for
        Returns:
        the average value of the array or 0 if the array has a length of 0
        Since:
        1.5.5 com.github.kilianB
      • average

        public static double average​(int[] array)
        Calculates the average value of the array.
        Parameters:
        array - the array to compute the average value for
        Returns:
        the average value of the array or 0 if the array has a length of 0
        Since:
        1.5.5 com.github.kilianB
      • average

        public static double average​(long[] array)
        Calculates the average value of the array.
        Parameters:
        array - the array to compute the average value for
        Returns:
        the average value of the array or 0 if the array has a length of 0
        Since:
        1.5.5 com.github.kilianB
      • average

        public static double average​(float[] array)
        Calculates the average value of the array.
        Parameters:
        array - the array to compute the average value for
        Returns:
        the average value of the array or 0 if the array has a length of 0
        Since:
        1.5.5 com.github.kilianB
      • average

        public static double average​(double[] array)
        Calculates the average value of the array.
        Parameters:
        array - the array to compute the average value for
        Returns:
        the average value of the array or 0 if the array has a length of 0
        Since:
        1.5.5 com.github.kilianB
      • average

        public static double average​(byte[][] array)
        Calculates the average value of the 2d array.
        Parameters:
        array - the array to compute the average value for
        Returns:
        the average value of the array or 0 if the array has a length of 0
        Since:
        1.5.5 com.github.kilianB
      • average

        public static double average​(char[][] array)
        Calculates the average value of the 2d array.
        Parameters:
        array - the array to compute the average value for
        Returns:
        the average value of the array or 0 if the array has a length of 0
        Since:
        1.5.5 com.github.kilianB
      • average

        public static double average​(short[][] array)
        Calculates the average value of the 2d array.
        Parameters:
        array - the array to compute the average value for
        Returns:
        the average value of the array or 0 if the array has a length of 0
        Since:
        1.5.5 com.github.kilianB
      • average

        public static double average​(int[][] array)
        Calculates the average value of the 2d array.
        Parameters:
        array - the array to compute the average value for
        Returns:
        the average value of the array or 0 if the array has a length of 0
        Since:
        1.5.5 com.github.kilianB
      • average

        public static double average​(long[][] array)
        Calculates the average value of the 2d array.
        Parameters:
        array - the array to compute the average value for
        Returns:
        the average value of the array or 0 if the array has a length of 0
        Since:
        1.5.5 com.github.kilianB
      • average

        public static double average​(float[][] array)
        Calculates the average value of the 2d array.
        Parameters:
        array - the array to compute the average value for
        Returns:
        the average value of the array or 0 if the array has a length of 0
        Since:
        1.5.5 com.github.kilianB
      • average

        public static double average​(double[][] array)
        Calculates the average value of the 2d array.
        Parameters:
        array - the array to compute the average value for
        Returns:
        the average value of the array or 0 if the array has a length of 0
        Since:
        1.5.5 com.github.kilianB
      • median

        public static double median​(byte[] array)
        Calculate the median value of the array
        Parameters:
        array - the array to calculate the median value for.
        Returns:
        the median value of the array
        Throws:
        ArrayIndexOutOfBoundsException - if the array has a length of 0
        Since:
        1.5.5 com.github.kilianB
      • median

        public static double median​(char[] array)
        Calculate the median value of the array
        Parameters:
        array - the array to calculate the median value for.
        Returns:
        the median value of the array
        Throws:
        ArrayIndexOutOfBoundsException - if the array has a length of 0
        Since:
        1.5.5 com.github.kilianB
      • median

        public static double median​(short[] array)
        Calculate the median value of the array
        Parameters:
        array - the array to calculate the median value for.
        Returns:
        the median value of the array
        Throws:
        ArrayIndexOutOfBoundsException - if the array has a length of 0
        Since:
        1.5.5 com.github.kilianB
      • median

        public static double median​(int[] array)
        Calculate the median value of the array
        Parameters:
        array - the array to calculate the median value for.
        Returns:
        the median value of the array
        Throws:
        ArrayIndexOutOfBoundsException - if the array has a length of 0
        Since:
        1.5.5 com.github.kilianB
      • median

        public static double median​(long[] array)
        Calculate the median value of the array
        Parameters:
        array - the array to calculate the median value for.
        Returns:
        the median value of the array
        Throws:
        ArrayIndexOutOfBoundsException - if the array has a length of 0
        Since:
        1.5.5 com.github.kilianB
      • median

        public static double median​(float[] array)
        Calculate the median value of the array
        Parameters:
        array - the array to calculate the median value for.
        Returns:
        the median value of the array
        Throws:
        ArrayIndexOutOfBoundsException - if the array has a length of 0
        Since:
        1.5.5 com.github.kilianB
      • median

        public static double median​(double[] array)
        Calculate the median value of the array
        Parameters:
        array - the array to calculate the median value for.
        Returns:
        the median value of the array
        Throws:
        ArrayIndexOutOfBoundsException - if the array has a length of 0
        Since:
        1.5.5 com.github.kilianB
      • get

        public static <T> T get​(Object array,
                                int... index)