Class JamArr

java.lang.Object
org.jamdev.jpamutils.JamArr

public class JamArr
extends Object
  • Constructor Summary

    Constructors 
    Constructor Description
    JamArr()  
  • Method Summary

    Modifier and Type Method Description
    static double[][] add​(double[][] img, double b)
    Add a number to a 2D array.
    static double[] add​(double[] a, double b)
    Subtract a number from an array.
    static double[] add​(double[] a, double[] b)
    Add two arrays together
    static int[] add​(int[] a, int b)
    Subtract a number from an array.
    static int[] add​(int[] a, int[] b)
    Add two arrays together
    static String array2String​(double[] array, int decimalPlaces)
    Convert an array to a comma delimited string.
    static String array2String​(double[] array, int decimalPlaces, String delimiter)
    Convert an array to a delimited string.
    static String array2String​(float[] array, int decimalPlaces, String delimiter)
    Convert an array to a delimited string.
    static String array2String​(Number[] array, int decimalPlaces, String delimiter)
    Convert an array to a delimited string.
    static boolean contains​(int[] arr, int num)
    Check whether an array contains a number.
    static double[][] divide​(double[][] array, double divisor)
    Divide each element in a 2D array by a number
    static double[] divide​(double[] array, double divisor)
    Divide each element in an array by a number.
    static double[][] divide​(double divisor, double[][] array)
    Divide each element in a 2D array by a number
    static double[][] exp​(double[][] img)
    Take the exponential of every element in a 2D array
    static boolean isATrue​(boolean[] boolArray)
    Check whether there is a single true value in a boolean array.
    static double[] list2ArrayD​(List<Double> listArray)
    Convert a list to a primitive double array.
    static double max​(double[] arr)
    Calculate the maximum value in an array
    static double max​(double[][] arr)
    Calculate the maximum double value of a 2D double array.
    static double max​(float[] arr)
    Calculate the maximum value in an array
    static int max​(int[] arr)
    Calculate the maximum value in an array
    static int max​(int[][] arr)
    Calculate the maximum int value of a 2D int array.
    static double mean​(double[] data)
    Calculate the mean for a double[] array
    static double mean​(double[][] data)
    Calculate the mean over all elements of a double[][] array.
    static double[] mean​(double[][] data, int dim)
    Calculate the mean of all rows or columns in a double[][] array.
    static double mean​(int[] data)
    Calculate the mean for a int[] array
    static Double mean​(ArrayList<? extends Number> array, double InitialtoIgnorePercentage)
    Calculate the mean of an array of double values, ignoring an 'initialtoIgnorePercentage' percentage of jumps
    static double mean​(ArrayList<double[]> array, double InitialtoIgnorePercentage, int dim)
    Calculate the mean of one dimension within a list of points.
    static double meanf​(ArrayList<Float> array, double initialtoIgnorePercentage)
    Calculate the mean of an array of float values, ignoring an 'initialtoIgnorePercentage' percentage of jumps
    static double median​(double[] numArray)
    Calculate the median value of an array
    static double median​(double[][] data)
    Calculate the median of a double[][] array.
    static double[] median​(double[][] data, int dim)
    Calculate the median of all rows or columns in a double[][] array.
    static double median​(ArrayList<? extends Number> array)
    Find the median of an ArrayList of doubles
    static double median​(ArrayList<? extends Number> array, double ignorePercentage)
    Find the median of an ArrayList of doubles
    static double min​(double[] arr)
    Get the minimum value in an array
    static double min​(double[][] arr)
    Calculate the minimum double value of a 2D double array.
    static int min​(int[] arr)
    Get the minimum value in an array
    static int min​(int[][] arr)
    Calculate the minimum int value of a 2D int array.
    static double[] minmax​(double[] arr)
    Calculate the minimum and maximum value of an array.
    static double[] minmax​(double[][] arr)
    Calculate the minimum and maximum value of a 2D array.
    static int[] minmax​(int[][] arr)
    Calculate the minimum and maximum value of a 2D array.
    static double minmaxdiff​(double[] arr)
    Calculate the difference between the minimum and maximum value of an array.
    static double[] normalise​(double[] arr)
    Normalise an array
    static double[] normalise​(double[] arr, double scaleFactor)
    Normalise an array
    static double[] pow​(double[] array, double exp)
    Square or raise the power all elements in an array
    static void printArray​(double[] array)
    Print an array to the console.
    static void printArray​(double[][] array)
    Print a 2D double array
    static void printArray​(int[] array)  
    static void printArray​(int[][] array)
    Print a 2D int array
    static double[][] product​(double[][] img, double b)
    Multiple a 2D array by a number;
    static double[][] product​(double[][] img1, double[][] img2)
    Multiply two images together,
    static double[] product​(double[] a, double b)
    Multiply an array by a number.
    static double[] product​(double[] a, double[] b)
    /** Multiply two arrays together
    static double[] product​(int[] a, double b)
    Multiply an array by a number.
    static int[] product​(int[] a, int b)
    Multiply an array by a number.
    static int[] product​(int[] a, int[] b)
    Multiply two arrays together
    static double[] rearrange​(double[] arr, int[] pos)
    Shuffle an array according to the given order of elements
    static float[] rearrange​(float[] arr, int[] pos)
    Shuffle an array according to the given order of elements
    static int[] rearrange​(int[] arr, int[] pos)
    Shuffle an array according to the given order of elements
    static String[] rearrange​(String[] arr, int[] pos)
    Shuffle a string array according to the given order of elements
    static List<Integer> sort​(ArrayList<? extends Number> array)
    Sorts and array and returns the index of the sorted elements of the array.
    static <T> ArrayList<T> sort​(ArrayList<? extends Number> arrayOrdered, ArrayList<T> arrayToSort)
    Sort one array by the ordering of another array.
    static double std​(double[] data)
    Calculate the standard deviation for a double[] array
    static double std​(double[][] data)
    Calculate the standard deviation of an array, The standard deviaiton is computed for the flattened array.
    static double[] std​(double[][] data, int dim)
    Calculate the standard deviation of all rows or columns in a double[][] array.
    static double std​(ArrayList<? extends Number> array)
    Calculate the standard deviation of an array of float values, ignoring an 'initialtoIgnorePercentage' percentage of jumps
    static double std​(ArrayList<? extends Number> array, double initialtoIgnorePercentage)
    Calculate the standard deviation of an array of doubles, ignoring an 'initialtoIgnorePercentage' percentage of jumps
    static double std​(ArrayList<double[]> array, double initialtoIgnorePercentage, int dim)
    Calculate the standard deviation of an array of doubles, ignoring an 'initialtoIgnorePercentage' percentage of jumps
    static double stdf​(ArrayList<Float> array)
    Calculate the standard deviation of an array of float values, ignoring an 'initialtoIgnorePercentage' percentage of jumps
    static double stdf​(ArrayList<Float> array, double initialToIgnorePercentage)
    Calculate the standard deviation of an array of float values, ignoring an 'initialtoIgnorePercentage' percentage of jumps
    static double[] string2array​(String array)
    Convert a comma delimited string array to a double array.
    static double[] string2array​(String array, String delimitter)
    Convert a delimited string array to a double array.
    static double[][] subtract​(double[][] img, double b)
    Subtract a number from a 2D array.
    static double[] subtract​(double[] a, double b)
    Subtract a number from an array.
    static double[] subtract​(double[] a, double[] b)
    Subtract two array from each other.
    static int[] subtract​(int[] a, int b)
    Subtract a number from an array.
    static int[] subtract​(int[] a, int[] b)
    Subtract two array from each other.
    static double sum​(double[] array)
    Sum the elements in an array
    static double sum​(double[][] array2)
    Sum the elements in a 2D array.
    static int sum​(int[] array)
    Sum the elements in an array
    static double[][] transposeMatrix​(double[][] m)
    Transpose a double[][] matrix
    static boolean unique​(double[] array)
    Check whether there are duplicates within an array
    static double varience​(double[] data)
    Calculate the variance for a double[] array

    Methods inherited from class java.lang.Object

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

  • Method Details

    • mean

      public static double mean​(ArrayList<double[]> array, double InitialtoIgnorePercentage, int dim)
      Calculate the mean of one dimension within a list of points. e.g. the points might be a list of [x y z] co-ordinates in which case the dim=0 would return the mean of all x points.
      Parameters:
      array - - a list of points
      InitialtoIgnorePercentage - : ignore the first percentage of results
      dim - - the dimension of the point to calculate the average for
      Returns:
      the mean of one dimension of the list of the points.
    • std

      public static double std​(ArrayList<double[]> array, double initialtoIgnorePercentage, int dim)
      Calculate the standard deviation of an array of doubles, ignoring an 'initialtoIgnorePercentage' percentage of jumps
      Parameters:
      array -
      initialtoIgnorePercentage - - percentage of initial values to ignore.
      Returns:
      standard deviation of array.
    • mean

      public static Double mean​(ArrayList<? extends Number> array, double InitialtoIgnorePercentage)
      Calculate the mean of an array of double values, ignoring an 'initialtoIgnorePercentage' percentage of jumps
      Parameters:
      array - of float values.
      InitialtoIgnorePercentage - - the percentahe of results to ignore.
      Returns:
      mean of the array values
    • std

      public static double std​(ArrayList<? extends Number> array, double initialtoIgnorePercentage)
      Calculate the standard deviation of an array of doubles, ignoring an 'initialtoIgnorePercentage' percentage of jumps
      Parameters:
      array -
      initialtoIgnorePercentage - - percentage of initial values to ignore.
      Returns:
      standard deviation of array.
    • std

      public static double std​(ArrayList<? extends Number> array)
      Calculate the standard deviation of an array of float values, ignoring an 'initialtoIgnorePercentage' percentage of jumps
      Parameters:
      array - of float values.
      Returns:
      standard deviation of the array values.
    • median

      public static double median​(ArrayList<? extends Number> array, double ignorePercentage)
      Find the median of an ArrayList of doubles
      Parameters:
      array - the array to calculate the median for
      ignorePercentage - the percentage of initial results on the array to ignore
      Returns:
      the median of the results whihc are not included in the ignorePercentage
    • median

      public static double median​(ArrayList<? extends Number> array)
      Find the median of an ArrayList of doubles
      Parameters:
      array -
      Returns:
      median of the array.
    • median

      public static double median​(double[] numArray)
      Calculate the median value of an array
      Parameters:
      numArray - - the number array
      Returns:
      the median value.
    • meanf

      public static double meanf​(ArrayList<Float> array, double initialtoIgnorePercentage)
      Calculate the mean of an array of float values, ignoring an 'initialtoIgnorePercentage' percentage of jumps
      Parameters:
      array - of float values.
      InitialtoIgnorePercentage - .
      Returns:
      mean of the array values.
    • stdf

      public static double stdf​(ArrayList<Float> array)
      Calculate the standard deviation of an array of float values, ignoring an 'initialtoIgnorePercentage' percentage of jumps
      Parameters:
      array - of float values.
      Returns:
      standard deviation of the array values.
    • stdf

      public static double stdf​(ArrayList<Float> array, double initialToIgnorePercentage)
      Calculate the standard deviation of an array of float values, ignoring an 'initialtoIgnorePercentage' percentage of jumps
      Parameters:
      array - of float values.
      initialtoIgnorePercentage - - percentage of initial values to ignore.
      Returns:
      standard deviation of the array values.
    • mean

      public static double mean​(double[] data)
      Calculate the mean for a double[] array
      Parameters:
      data - array of doubles
      Returns:
      the mean of the array
    • mean

      public static double mean​(int[] data)
      Calculate the mean for a int[] array
      Parameters:
      data - array of integers
      Returns:
      the mean of the array
    • mean

      public static double mean​(double[][] data)
      Calculate the mean over all elements of a double[][] array.
      Parameters:
      data - - 2D array of double
      Returns:
      the mean over all elements.
    • mean

      public static double[] mean​(double[][] data, int dim)
      Calculate the mean of all rows or columns in a double[][] array.
      Parameters:
      data - - 2D array of double - must not be a ragged array.
      dim - - which dimensions to average over. -1 averages across all elements in the array. 0 averages rows and 1 averages columns.
      Returns:
      the mean values, a single value or the mean of all rows/columns
    • median

      public static double median​(double[][] data)
      Calculate the median of a double[][] array. Flattens the array and then takes the median value of all elements.
      Parameters:
      data - - 2D array of double;
      Returns:
      the median value of all elements in the array,
    • median

      public static double[] median​(double[][] data, int dim)
      Calculate the median of all rows or columns in a double[][] array.
      Parameters:
      data - - 2D array of double - must not be a ragged array.
      dim - - which dimensions to average over. -1 calculates the median for a flattened version of all elements in the array. 0 calculates the median of rows and 1 calculates the median of columns.
      Returns:
      the mean values, a single value or the mean of all rows/columns
    • std

      public static double std​(double[][] data)
      Calculate the standard deviation of an array, The standard deviaiton is computed for the flattened array.
      Parameters:
      data - - the input array.
      Returns:
      - the standard deviation.
    • std

      public static double[] std​(double[][] data, int dim)
      Calculate the standard deviation of all rows or columns in a double[][] array.
      Parameters:
      data - - 2D array of double - must not be a ragged array.
      dim - - which dimensions to average over. -1 calculates the standard deviation for a flattened array. 0 calculates the standard deviation of rows and 1 calculates the standard deviation of columns.
      Returns:
      the mean values, a single value or the mean of all rows/columns
    • varience

      public static double varience​(double[] data)
      Calculate the variance for a double[] array
      Parameters:
      data - array of doubles
      Returns:
      the variance
    • std

      public static double std​(double[] data)
      Calculate the standard deviation for a double[] array
      Parameters:
      data - array of doubles
      Returns:
      the standard deviation
    • transposeMatrix

      public static double[][] transposeMatrix​(double[][] m)
      Transpose a double[][] matrix
      Parameters:
      m - - the matrix transdpose
      Returns:
      the transposed matrix
    • sort

      public static List<Integer> sort​(ArrayList<? extends Number> array)
      Sorts and array and returns the index of the sorted elements of the array. Handles duplicate values.
      Parameters:
      array - - the array to sort
      Returns:
      an integer array showing the index of sorted elements from the original input array
    • sort

      public static <T> ArrayList<T> sort​(ArrayList<? extends Number> arrayOrdered, ArrayList<T> arrayToSort)
      Sort one array by the ordering of another array. This is a convenience function which sorts one array and then uses the index of that sort to sort another array. The returned array is the sorted arrayToSort. Useful if sorting one ArrayList by another ArrayList
      Parameters:
      arrayOrdered - - the array to sort by
      arrayToSort - - the array to sort. Must be same size as arrayOrdered.
      Returns:
      the arrayToSort with elements sorted by the arrayOrdered.
    • minmaxdiff

      public static double minmaxdiff​(double[] arr)
      Calculate the difference between the minimum and maximum value of an array.
      Parameters:
      arr - - the array to find the maximum value of.
      Returns:
      the maximum value in the array
    • minmax

      public static double[] minmax​(double[] arr)
      Calculate the minimum and maximum value of an array.
      Parameters:
      arr - - the array to find the maximum value of.
      Returns:
      the minimum and maximum value in the array
    • minmax

      public static double[] minmax​(double[][] arr)
      Calculate the minimum and maximum value of a 2D array.
      Parameters:
      arr - - the array to find the maximum value of.
      Returns:
      the minimum and maximum value in the array
    • minmax

      public static int[] minmax​(int[][] arr)
      Calculate the minimum and maximum value of a 2D array.
      Parameters:
      arr - - the array to find the maximum value of.
      Returns:
      the minimum and maximum value in the array
    • max

      public static double max​(double[] arr)
      Calculate the maximum value in an array
      Parameters:
      arr - - the array to find the maximum value of.
      Returns:
      the maximum value in the array
    • max

      public static int max​(int[][] arr)
      Calculate the maximum int value of a 2D int array.
      Parameters:
      arr - - the array to find the maximum value of.
      Returns:
      the minimum and maximum value in the array
    • max

      public static double max​(double[][] arr)
      Calculate the maximum double value of a 2D double array.
      Parameters:
      arr - - the array to find the maximum value of.
      Returns:
      the minimum and maximum value in the array
    • max

      public static double max​(float[] arr)
      Calculate the maximum value in an array
      Parameters:
      arr - - the array to find the maximum value of.
      Returns:
      the maximum value in the array
    • max

      public static int max​(int[] arr)
      Calculate the maximum value in an array
      Parameters:
      arr - - the array to find the maximum value of.
      Returns:
      the maximum value in the array
    • min

      public static double min​(double[] arr)
      Get the minimum value in an array
      Parameters:
      arr - - the array to find the minimu m value of.
      Returns:
      the minimum value in the array.
    • min

      public static int min​(int[] arr)
      Get the minimum value in an array
      Parameters:
      arr - - the array to find the minimum value of.
      Returns:
      the minimum value in the array.
    • min

      public static int min​(int[][] arr)
      Calculate the minimum int value of a 2D int array.
      Parameters:
      arr - - the array to find the maximum value of.
      Returns:
      the minimum and maximum value in the array
    • min

      public static double min​(double[][] arr)
      Calculate the minimum double value of a 2D double array.
      Parameters:
      arr - - the array to find the maximum value of.
      Returns:
      the minimum and maximum value in the array
    • normalise

      public static double[] normalise​(double[] arr)
      Normalise an array
      Parameters:
      arr - - the array to normalise
      Returns:
      normalised copy of the array
    • normalise

      public static double[] normalise​(double[] arr, double scaleFactor)
      Normalise an array
      Parameters:
      arr - - the array to normalise
      scaleFactor - - multiply the resulting array by a scale factor.
      Returns:
      normalised copy of the array
    • pow

      public static double[] pow​(double[] array, double exp)
      Square or raise the power all elements in an array
      Parameters:
      array - - the array
      Returns:
      array with all elements raised to the power of exp.
    • sum

      public static int sum​(int[] array)
      Sum the elements in an array
      Parameters:
      array - - the array to sum.
      Returns:
      the summation of all the elements in the array.
    • sum

      public static double sum​(double[] array)
      Sum the elements in an array
      Parameters:
      array - - the array to sum.
      Returns:
      the summation of all the elements in the array.
    • sum

      public static double sum​(double[][] array2)
      Sum the elements in a 2D array.
      Parameters:
      array2 - - the array to sum.
      Returns:
      the summation of all the elements in the array.
    • printArray

      public static void printArray​(double[] array)
      Print an array to the console.
      Parameters:
      array - to print
    • printArray

      public static void printArray​(int[] array)
    • printArray

      public static void printArray​(double[][] array)
      Print a 2D double array
      Parameters:
      array - - the array
    • printArray

      public static void printArray​(int[][] array)
      Print a 2D int array
      Parameters:
      array - - the array
    • list2ArrayD

      public static double[] list2ArrayD​(List<Double> listArray)
      Convert a list to a primitive double array.
      Parameters:
      listArray - - the list.
      Returns:
      the primitive double.
    • unique

      public static boolean unique​(double[] array)
      Check whether there are duplicates within an array
      Parameters:
      the - array.
      Returns:
      true if there are duplicates.
    • divide

      public static double[] divide​(double[] array, double divisor)
      Divide each element in an array by a number.
      Parameters:
      array - - the array to divide.
      divisor - - the number to divide by.
      Returns:
      an array with all elements divided by divisor.
    • divide

      public static double[][] divide​(double[][] array, double divisor)
      Divide each element in a 2D array by a number
      Parameters:
      array - - the array to divide.
      divisor - - the number to divide by.
      Returns:
      a new array with all elements divided by divisor.
    • divide

      public static double[][] divide​(double divisor, double[][] array)
      Divide each element in a 2D array by a number
      Parameters:
      array - - the array to divide.
      divisor - - the number to divide by.
      Returns:
      a new array with all elements divided by divisor.
    • array2String

      public static String array2String​(float[] array, int decimalPlaces, String delimiter)
      Convert an array to a delimited string.
      Parameters:
      array - - the input array to convert to a string
      decimalplaces - - the number of decimal places to save as characters. More means a longer string.
      delimitter - - the delimiter e.g. ",".
      Returns:
      the input array.
    • array2String

      public static String array2String​(double[] array, int decimalPlaces, String delimiter)
      Convert an array to a delimited string.
      Parameters:
      array - - the input array to convert to a string
      decimalplaces - - the number of decimal places to save as characters. More means a longer string.
      delimitter - - the delimiter e.g. ",".
      Returns:
      the input array.
    • array2String

      public static String array2String​(Number[] array, int decimalPlaces, String delimiter)
      Convert an array to a delimited string.
      Parameters:
      array - - the input array to convert to a string
      decimalplaces - - the number of decimal places to save as characters. More means a longer string.
      delimitter - - the delimiter e.g. ",".
      Returns:
      the input array.
    • string2array

      public static double[] string2array​(String array, String delimitter)
      Convert a delimited string array to a double array.
      Parameters:
      array - - the input string containing the number array.
      delimitter - - the delimiter e.g. ",".
      Returns:
      the input array.
    • array2String

      public static String array2String​(double[] array, int decimalPlaces)
      Convert an array to a comma delimited string.
      Parameters:
      array - - the input array to convert to a string
      decimalplaces - - the number of decimal places to save as characters. More means a longer string.
      Returns:
      the input array.
    • string2array

      public static double[] string2array​(String array)
      Convert a comma delimited string array to a double array.
      Parameters:
      array - - the input string containing the number array.
      Returns:
      the input array.
    • isATrue

      public static boolean isATrue​(boolean[] boolArray)
      Check whether there is a single true value in a boolean array.
      Parameters:
      boolArray - - any array of booleans.
      Returns:
      true if there is at least one true in the array.
    • contains

      public static boolean contains​(int[] arr, int num)
      Check whether an array contains a number.
      Parameters:
      arr - - the array.
      num - - the number to check.
      Returns:
      true if the number is contained within the array,
    • subtract

      public static double[] subtract​(double[] a, double[] b)
      Subtract two array from each other.
      Parameters:
      a - - the first array.
      b - - the second array. Must be the same length as a
      Returns:
      elements in a minus elements in b.
    • subtract

      public static double[] subtract​(double[] a, double b)
      Subtract a number from an array.
      Parameters:
      a - - the first array.
      b - - the number to subtract from all elements in a.
      Returns:
      elements in a minus b.
    • subtract

      public static double[][] subtract​(double[][] img, double b)
      Subtract a number from a 2D array.
      Parameters:
      img - - the array.
      b - - the number to subtract from all elements in a.
      Returns:
      elements in img minus b.
    • add

      public static double[] add​(double[] a, double[] b)
      Add two arrays together
      Parameters:
      a - - the first array.
      b - - the second array. Must be the same length as a
      Returns:
      elements in a plus elements in b.
    • add

      public static double[] add​(double[] a, double b)
      Subtract a number from an array.
      Parameters:
      a - - the first array.
      b - - the number to add to all elements in a.
      Returns:
      elements in a plus b.
    • add

      public static double[][] add​(double[][] img, double b)
      Add a number to a 2D array.
      Parameters:
      img - - the array.
      b - - the number to add to elements.
      Returns:
      elements in img plus b.
    • product

      public static double[] product​(double[] a, double[] b)
      /** Multiply two arrays together
      Parameters:
      a - - the first array.
      b - - the second array. Must be the same length as a
      Returns:
      elements in a multiplied by elements in b.
    • product

      public static double[] product​(double[] a, double b)
      Multiply an array by a number.
      Parameters:
      a - - the first array.
      b - - the number to add to all elements in a.
      Returns:
      elements in a multiplied by b.
    • subtract

      public static int[] subtract​(int[] a, int[] b)
      Subtract two array from each other.
      Parameters:
      a - - the first array.
      b - - the second array. Must be the same length as a
      Returns:
      elements in a minus elements in b.
    • subtract

      public static int[] subtract​(int[] a, int b)
      Subtract a number from an array.
      Parameters:
      a - - the first array.
      b - - the number to subtract from all elements in a.
      Returns:
      elements in a minus b.
    • add

      public static int[] add​(int[] a, int[] b)
      Add two arrays together
      Parameters:
      a - - the first array.
      b - - the second array. Must be the same length as a
      Returns:
      elements in a plus elements in b.
    • add

      public static int[] add​(int[] a, int b)
      Subtract a number from an array.
      Parameters:
      a - - the first array.
      b - - the number to add to all elements in a.
      Returns:
      elements in a plus b.
    • product

      public static int[] product​(int[] a, int[] b)
      Multiply two arrays together
      Parameters:
      a - - the first array.
      b - - the second array. Must be the same length as a
      Returns:
      elements in a multiplied by elements in b.
    • product

      public static int[] product​(int[] a, int b)
      Multiply an array by a number.
      Parameters:
      a - - the first array.
      b - - the number to add to all elements in a.
      Returns:
      elements in a multiplied by b.
    • product

      public static double[] product​(int[] a, double b)
      Multiply an array by a number.
      Parameters:
      a - - the first array.
      b - - the number to add to all elements in a.
      Returns:
      elements in a multiplied by b.
    • product

      public static double[][] product​(double[][] img, double b)
      Multiple a 2D array by a number;
      Parameters:
      a - - the array.
      b - - the number to multiply all elements by.
      Returns:
      the array multiplied by b.
    • exp

      public static double[][] exp​(double[][] img)
      Take the exponential of every element in a 2D array
      Parameters:
      img - - the array
      Returns:
      a new array with the exponent of every element
    • product

      public static double[][] product​(double[][] img1, double[][] img2)
      Multiply two images together,
      Parameters:
      img1 - - the img.
      img2 - - the scaling.
      Returns:
      - the product of the two matrices.
    • rearrange

      public static int[] rearrange​(int[] arr, int[] pos)
      Shuffle an array according to the given order of elements
      Parameters:
      arr - - the input array to shuffle
      pos - - the index array.
    • rearrange

      public static double[] rearrange​(double[] arr, int[] pos)
      Shuffle an array according to the given order of elements
      Parameters:
      arr - - the input array to shuffle
      pos - - the index array.
    • rearrange

      public static float[] rearrange​(float[] arr, int[] pos)
      Shuffle an array according to the given order of elements
      Parameters:
      arr - - the input array to shuffle
      pos - - the index array.
    • rearrange

      public static String[] rearrange​(String[] arr, int[] pos)
      Shuffle a string array according to the given order of elements
      Parameters:
      arr - - the input array to shuffle
      pos - - the index array.