public class ArrayUtils
extends java.lang.Object
Constructor and Description |
---|
ArrayUtils() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
add(byte[] a,
byte[] b) |
static double[][][] |
add(double[][][] a,
double[][][] b) |
static double[][] |
add(double[][] a,
double[][] b) |
static double[] |
add(double[] a,
double[] b) |
static double[] |
add(double[] a,
double[] b,
double[] c) |
static float[][] |
add(float[][] a,
float[][] b) |
static float[] |
add(float[] a,
float[] b) |
static int[][] |
add(int[][] a,
int[][] b) |
static int[] |
add(int[] a,
int[] b) |
static long[][][] |
add(long[][][] a,
long[][][] b) |
static long[][] |
add(long[][] a,
long[][] b) |
static long[] |
add(long[] nums,
long a) |
static long[] |
add(long[] a,
long[] b) |
static double[][] |
append(double[][] a,
double[][] b) |
static double[] |
append(double[] a,
double[] b) |
static java.lang.String[] |
append(java.lang.String[] a,
java.lang.String[] b) |
static <T> T[] |
append(T[] a,
T... b) |
static double |
avg(double[] nums) |
static double |
avg(long[] nums) |
static boolean |
contains(int[] a,
int d) |
static boolean |
contains(java.lang.String[] names,
java.lang.String name) |
static double[] |
copyAndFillOf(double[] original,
int newLength,
double padding) |
static long[] |
copyAndFillOf(long[] original,
int newLength,
long padding) |
static <T> T[] |
copyAndFillOf(T[] original,
int newLength,
T padding) |
static double[][] |
deepClone(double[][] ary) |
static int[] |
difference(int[] a,
int[] b) |
static java.lang.String[] |
difference(java.lang.String[] a,
java.lang.String[] b) |
static double[][] |
div(double[][] ds,
long[] n) |
static double[] |
div(double[] nums,
double n) |
static double[] |
div(double[] ds,
long[] n) |
static float[] |
div(float[] nums,
float n) |
static float[] |
div(float[] nums,
int n) |
static java.lang.String[] |
domainUnion(java.lang.String[] a,
java.lang.String[] b)
Clever union of String arrays.
|
static <T> int |
find(T[] ts,
T elem) |
static <T> T[] |
flat(T[][] arr)
Flatenize given array.
|
static double[][] |
gaussianArray(int n,
int m) |
static double[][] |
gaussianArray(int n,
int m,
long seed) |
static double[] |
gaussianVector(int n) |
static double[] |
gaussianVector(int n,
long seed) |
static double[][] |
generateLineSearchVecs(double[] srcVec,
double[] gradient,
int n,
double step) |
static boolean |
hasNaNsOrInfs(double[] ary) |
static boolean |
hasNaNsOrInfs(float[] ary) |
static double |
innerProduct(double[] x,
double[] y) |
static boolean |
isInt(java.lang.String s) |
static float[] |
join(float[] a,
float[] b) |
static long[] |
join(long[] a,
long[] b) |
static <T> T[] |
join(T[] a,
T[] b) |
static double |
l1norm(double[] x) |
static double |
l1norm(double[] x,
boolean skipLast) |
static double |
l2norm(double[] x) |
static double |
l2norm(double[] x,
boolean skipLast) |
static double |
l2norm2(double[] x) |
static double |
l2norm2(double[] x,
boolean skipLast) |
static double |
linfnorm(double[] x,
boolean skipLast) |
static int |
maxIndex(double[] from) |
static int |
maxIndex(float[] from,
java.util.Random rand) |
static int |
maxIndex(int[] from) |
static int |
maxIndex(int[] from,
java.util.Random rand)
Returns the index of the largest value in the array.
|
static int |
maxIndex(long[] from) |
static double |
maxValue(double[] ary) |
static double |
maxValue(double[] ary,
int from,
int to) |
static float |
maxValue(float[] ary) |
static float |
maxValue(float[] ary,
int from,
int to) |
static long |
maxValue(long[] from) |
static int |
minIndex(float[] from) |
static int |
minIndex(int[] from) |
static double |
minValue(double[] from) |
static float |
minValue(float[] from) |
static long |
minValue(long[] from) |
static double[] |
mult(double[] nums,
double n) |
static float[] |
mult(float[] nums,
float n) |
static double[][] |
multArrArr(double[][] ary1,
double[][] ary2) |
static double[] |
multArrVec(double[][] ary,
double[] nums) |
static double[] |
multVecArr(double[] nums,
double[][] ary) |
static int |
numInts(java.lang.String... a)
Returns number of strings which represents a number.
|
static boolean[] |
or(boolean[] a,
boolean[] b) |
static double[][] |
outerProduct(double[] x,
double[] y) |
static double[][] |
permuteCols(double[][] ary,
int[] idx) |
static java.lang.String[] |
permuteCols(java.lang.String[] vec,
int[] idx) |
static java.lang.String |
pprint(double[][] arr) |
static java.lang.String |
pprint(double[][] arr,
java.text.DecimalFormat dformat) |
static java.lang.String[] |
prepend(java.lang.String[] ary,
java.lang.String s) |
static java.lang.String[] |
select(java.lang.String[] ary,
int[] idxs) |
static int[] |
seq(int start,
int stop)
Generates sequence (start, stop) of integers: (start, start+1, ...., stop-1)
|
static int[] |
shuffleArray(int[] a,
int n,
int[] result,
long seed,
int startIndex)
Extract a shuffled array of integers
|
static void |
shuffleArray(long[] a,
long seed) |
static void |
sort(int[] idxs,
double[] values)
Sort an integer array of indices based on values
Updates indices in place, keeps values the same
|
static void |
sort(int[] idxs,
double[] values,
int cutoff) |
static void |
sortedMerge(int[] aIds,
double[] aVals,
int[] bIds,
double[] bVals,
int[] resIds,
double[] resVals) |
static <T> T[] |
subarray(T[] a,
int off,
int len) |
static double[] |
subtract(double[] a,
double[] b) |
static void |
subtract(double[] a,
double[] b,
double[] c) |
static double |
sum(double[] from) |
static float |
sum(float[] from) |
static int |
sum(int[] from) |
static long |
sum(long[] from) |
static int[] |
toInt(java.lang.String[] a,
int off,
int len) |
static java.lang.String[] |
toString(int[] dom) |
static java.lang.String[] |
toString(long[] dom) |
static double[][] |
transpose(double[][] ary) |
static int[] |
union(int[] a,
int[] b)
Returns a union of given sorted arrays.
|
static java.lang.String[] |
union(java.lang.String[] a,
java.lang.String[] b,
boolean lexo)
Union of given String arrays.
|
static java.lang.String[] |
union(java.lang.String[] a,
java.lang.String[] b,
int aoff,
int alen,
int boff,
int blen,
boolean lexo) |
static int[] |
unpackInts(long... longs) |
static double[] |
wadd(double[] a,
double[] b,
double w) |
public static long sum(long[] from)
public static int sum(int[] from)
public static float sum(float[] from)
public static double sum(double[] from)
public static double innerProduct(double[] x, double[] y)
public static double[][] outerProduct(double[] x, double[] y)
public static double l2norm2(double[] x)
public static double l2norm2(double[] x, boolean skipLast)
public static double l1norm(double[] x)
public static double l1norm(double[] x, boolean skipLast)
public static double linfnorm(double[] x, boolean skipLast)
public static double l2norm(double[] x)
public static double l2norm(double[] x, boolean skipLast)
public static byte[] add(byte[] a, byte[] b)
public static int[] add(int[] a, int[] b)
public static int[][] add(int[][] a, int[][] b)
public static long[] add(long[] a, long[] b)
public static long[][] add(long[][] a, long[][] b)
public static long[][][] add(long[][][] a, long[][][] b)
public static float[] add(float[] a, float[] b)
public static float[][] add(float[][] a, float[][] b)
public static boolean[] or(boolean[] a, boolean[] b)
public static double[][] deepClone(double[][] ary)
public static double[] add(double[] a, double[] b)
public static double[] wadd(double[] a, double[] b, double w)
public static double[] add(double[] a, double[] b, double[] c)
public static double[][] add(double[][] a, double[][] b)
public static double[][][] add(double[][][] a, double[][][] b)
public static double avg(double[] nums)
public static double avg(long[] nums)
public static long[] add(long[] nums, long a)
public static float[] div(float[] nums, int n)
public static float[] div(float[] nums, float n)
public static double[] div(double[] nums, double n)
public static double[][] div(double[][] ds, long[] n)
public static double[] div(double[] ds, long[] n)
public static float[] mult(float[] nums, float n)
public static double[] mult(double[] nums, double n)
public static double[] multArrVec(double[][] ary, double[] nums)
public static double[] multVecArr(double[] nums, double[][] ary)
public static double[][] multArrArr(double[][] ary1, double[][] ary2)
public static double[][] transpose(double[][] ary)
public static java.lang.String[] permuteCols(java.lang.String[] vec, int[] idx)
public static double[][] permuteCols(double[][] ary, int[] idx)
public static double[][] generateLineSearchVecs(double[] srcVec, double[] gradient, int n, double step)
public static java.lang.String[] toString(long[] dom)
public static java.lang.String[] toString(int[] dom)
public static boolean contains(java.lang.String[] names, java.lang.String name)
public static boolean contains(int[] a, int d)
public static <T> T[] subarray(T[] a, int off, int len)
public static int maxIndex(int[] from, java.util.Random rand)
public static int maxIndex(float[] from, java.util.Random rand)
public static int maxIndex(int[] from)
public static int maxIndex(long[] from)
public static int maxIndex(double[] from)
public static int minIndex(int[] from)
public static int minIndex(float[] from)
public static double maxValue(double[] ary)
public static double maxValue(double[] ary, int from, int to)
public static float maxValue(float[] ary)
public static float maxValue(float[] ary, int from, int to)
public static float minValue(float[] from)
public static double minValue(double[] from)
public static long maxValue(long[] from)
public static long minValue(long[] from)
public static <T> int find(T[] ts, T elem)
public static java.lang.String pprint(double[][] arr)
public static java.lang.String pprint(double[][] arr, java.text.DecimalFormat dformat)
public static int[] unpackInts(long... longs)
public static int[] shuffleArray(int[] a, int n, int[] result, long seed, int startIndex)
a
- input arrayn
- number of elements to extractresult
- array to store the results into (will be of size n)seed
- random number seedstartIndex
- offset into apublic static void shuffleArray(long[] a, long seed)
public static double[][] gaussianArray(int n, int m)
public static double[][] gaussianArray(int n, int m, long seed)
public static double[] gaussianVector(int n)
public static double[] gaussianVector(int n, long seed)
public static int numInts(java.lang.String... a)
public static boolean isInt(java.lang.String s)
public static int[] toInt(java.lang.String[] a, int off, int len)
public static java.lang.String[] domainUnion(java.lang.String[] a, java.lang.String[] b)
a
- a set of stringsb
- a set of stringspublic static java.lang.String[] union(java.lang.String[] a, java.lang.String[] b, boolean lexo)
a
- first arrayb
- second arraylexo
- - true if domains are sorted in lexicographical order or false for numeric domainspublic static java.lang.String[] union(java.lang.String[] a, java.lang.String[] b, int aoff, int alen, int boff, int blen, boolean lexo)
public static int[] union(int[] a, int[] b)
public static long[] join(long[] a, long[] b)
public static float[] join(float[] a, float[] b)
public static <T> T[] join(T[] a, T[] b)
public static final boolean hasNaNsOrInfs(double[] ary)
public static final boolean hasNaNsOrInfs(float[] ary)
public static int[] seq(int start, int stop)
public static int[] difference(int[] a, int[] b)
public static java.lang.String[] difference(java.lang.String[] a, java.lang.String[] b)
public static double[][] append(double[][] a, double[][] b)
public static double[] append(double[] a, double[] b)
public static java.lang.String[] append(java.lang.String[] a, java.lang.String[] b)
public static <T> T[] append(T[] a, T... b)
public static java.lang.String[] prepend(java.lang.String[] ary, java.lang.String s)
public static <T> T[] copyAndFillOf(T[] original, int newLength, T padding)
public static double[] copyAndFillOf(double[] original, int newLength, double padding)
public static long[] copyAndFillOf(long[] original, int newLength, long padding)
public static void sortedMerge(int[] aIds, double[] aVals, int[] bIds, double[] bVals, int[] resIds, double[] resVals)
public static java.lang.String[] select(java.lang.String[] ary, int[] idxs)
public static void sort(int[] idxs, double[] values)
idxs
- indicesvalues
- valuespublic static void sort(int[] idxs, double[] values, int cutoff)
public static double[] subtract(double[] a, double[] b)
public static void subtract(double[] a, double[] b, double[] c)
public static <T> T[] flat(T[][] arr)
T
- any typearr
- array of arrays