Module org.maxicp

Class Arrays

java.lang.Object
org.maxicp.util.Arrays

public class Arrays extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    applyPermutation(int[] x, int[] permutation)
    permutes x according to the permutation
    static <E> void
    applyPermutation(E[] x, int[] permutation)
     
    static int
    argMax(int[] values)
     
    static int
    argMin(int[] values)
     
    static int
    argProb(double[] proba)
     
    static int
    argSoftMax(int[] values)
     
    static <E> ArrayList<E>
    flatten(E[][] a)
     
    static int[]
    getRandomPermutation(int n, int seed)
    Generates a random permutation
    static int[]
    getSlice(int[][] a, int c)
     
    static int
    max(int... a)
     
    static int
    max(int[][] a)
     
    static int
    min(int... a)
     
    static int
    min(int[][] a)
     
    static int
    prod(int[] a)
     
    static int[]
    replicate(int v, int n)
     
    static double[]
    softMax(int[] values)
     
    static <E> void
    sort(E[] x, int[] w)
    sorts x increasingly according to the weights w
    static int[]
    sortPerm(int[] w)
     
    static double
    sum(double[] a)
     
    static int
    sum(int[] a)
     
    static int
    sum(int[][] a)
     

    Methods inherited from class java.lang.Object

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

    • Arrays

      public Arrays()
  • Method Details

    • argMax

      public static int argMax(int[] values)
    • argMin

      public static int argMin(int[] values)
    • argProb

      public static int argProb(double[] proba)
    • softMax

      public static double[] softMax(int[] values)
    • argSoftMax

      public static int argSoftMax(int[] values)
    • max

      public static int max(int... a)
      Parameters:
      a -
      Returns:
      the maximum value in a
    • max

      public static int max(int[][] a)
      Parameters:
      a -
      Returns:
      the maximum value in a
    • min

      public static int min(int... a)
      Parameters:
      a -
      Returns:
      the minimum value in a
    • min

      public static int min(int[][] a)
      Parameters:
      a -
      Returns:
      the minimum value in a
    • sum

      public static int sum(int[] a)
      Parameters:
      a -
      Returns:
      the sum of the values in a
    • sum

      public static double sum(double[] a)
      Parameters:
      a -
      Returns:
      the sum of the values in a
    • sum

      public static int sum(int[][] a)
      Parameters:
      a -
      Returns:
      the sum of the values in a
    • prod

      public static int prod(int[] a)
      Parameters:
      a -
      Returns:
      the product of values in a
    • getSlice

      public static int[] getSlice(int[][] a, int c)
      Parameters:
      a - matrix array
      Returns:
      the column c that is [a[0][c] , ... , a[n-1][c]]
    • replicate

      public static int[] replicate(int v, int n)
      Parameters:
      v -
      n -
      Returns:
      an array of length n each entry with value v
    • flatten

      public static <E> ArrayList<E> flatten(E[][] a)
      Type Parameters:
      E -
      Parameters:
      a -
      Returns:
      a flattened array list of all elements in a
    • getRandomPermutation

      public static int[] getRandomPermutation(int n, int seed)
      Generates a random permutation
      Parameters:
      n -
      seed - for the random number generator
      Returns:
      a random permutation from 0 to n-1
    • applyPermutation

      public static <E> void applyPermutation(E[] x, int[] permutation)
      Type Parameters:
      E -
      Parameters:
      x -
      permutation - a valid permutation of x (all numbers from 0 to x.length-1 present),
      permutation[i] represents the index of the entry of x that must come in position i in the permuted array
    • applyPermutation

      public static void applyPermutation(int[] x, int[] permutation)
      permutes x according to the permutation
      Parameters:
      x - the array to permute
      permutation -
    • sortPerm

      public static int[] sortPerm(int[] w)
      Parameters:
      w -
      Returns:
      the sorting permutation perm of w, i.e. w[perm[0]],w[perm[1]],...,w[perm[w.length-1]] is sorted increasingly
    • sort

      public static <E> void sort(E[] x, int[] w)
      sorts x increasingly according to the weights w
      Parameters:
      x -
      w -