java.lang.Object
org.maxicp.util.Arrays
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidapplyPermutation(int[] x, int[] permutation) permutes x according to the permutationstatic <E> voidapplyPermutation(E[] x, int[] permutation) static intargMax(int[] values) static intargMin(int[] values) static intargProb(double[] proba) static intargSoftMax(int[] values) static <E> ArrayList<E> flatten(E[][] a) static int[]getRandomPermutation(int n, int seed) Generates a random permutationstatic int[]getSlice(int[][] a, int c) static intmax(int... a) static intmax(int[][] a) static intmin(int... a) static intmin(int[][] a) static intprod(int[] a) static int[]replicate(int v, int n) static double[]softMax(int[] values) static <E> voidsort(E[] x, int[] w) sorts x increasingly according to the weights wstatic int[]sortPerm(int[] w) static doublesum(double[] a) static intsum(int[] a) static intsum(int[][] a)
-
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
- 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 permutepermutation-
-
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-
-