public class ArrayUtil extends Object
Constructor and Description |
---|
ArrayUtil() |
Modifier and Type | Method and Description |
---|---|
static boolean |
anyLess(int[] target,
int[] test) |
static boolean |
anyMore(int[] target,
int[] test) |
static void |
assertSquare(double[]... d) |
static int[] |
calcStrides(int[] shape)
Computes the standard packed array strides for a given shape.
|
static int[] |
calcStrides(int[] shape,
int startValue)
Computes the standard packed array strides for a given shape.
|
static int[] |
calcStridesFortran(int[] shape)
Computes the standard packed array strides for a given shape.
|
static int[] |
calcStridesFortran(int[] shape,
int startNum)
Computes the standard packed array strides for a given shape.
|
static <E> E[] |
combine(E[]... arrs) |
static double[] |
combine(float[]... ints)
Combines a applyTransformToDestination of int arrays in to one flat int array
|
static int[] |
combine(int[]... ints)
Combines a applyTransformToDestination of int arrays in to one flat int array
|
static float[] |
combine(List<float[]> nums)
Combines a applyTransformToDestination of int arrays in to one flat int array
|
static double[] |
combineDouble(List<double[]> nums)
Combines a applyTransformToDestination of int arrays in to one flat int array
|
static float[] |
combineFloat(List<float[]> nums)
Combines a applyTransformToDestination of int arrays in to one flat int array
|
static int[] |
consArray(int a,
int[] as) |
static float[] |
copy(float[] data) |
static int[] |
copy(int[] copy) |
static int |
dotProduct(int[] xs,
int[] ys) |
static double[] |
doubleCopyOf(float[] data) |
static int[] |
empty() |
static boolean |
equals(float[] data,
double[] data2) |
static double[] |
flatten(double[][] arr) |
static float[] |
flatten(float[][] arr) |
static int[] |
flatten(int[][] arr) |
static float[] |
floatCopyOf(double[] data) |
static boolean |
isZero(int[] as) |
static int |
nonOneStride(int[] arr)
For use with row vectors to ensure consistent strides
with varying offsets
|
static int[] |
of(int... arr) |
static int |
offsetFor(int[] stride,
int i)
Calculate the offset for a given stride array
|
static int[] |
plus(int[] ints,
int mult) |
static int |
prod(int[] mult)
Product of an int array
|
static int[] |
randomPermutation(int size)
Credit to mikio braun from jblas
Create a random permutation of the numbers 0, ..., size - 1.
|
static double[] |
range(double[] data,
int to)
Returns a subset of an array from 0 to "to"
|
static double[] |
range(double[] data,
int to,
int stride)
Returns a subset of an array from 0 to "to"
using the specified stride
|
static double[] |
range(double[] data,
int to,
int stride,
int numElementsEachStride)
Returns a subset of an array from 0 to "to"
using the specified stride
|
static int[] |
range(int from,
int to)
Generate an int array ranging from
from to to.
|
static int[] |
range(int from,
int to,
int increment)
Generate an int array ranging from
from to to.
|
static double[] |
read(int length,
DataInputStream dis) |
static double[] |
readDouble(int length,
DataInputStream dis) |
static float[] |
readFloat(int length,
DataInputStream dis) |
static int[] |
removeIndex(int[] data,
int index)
Return a copy of this array with the
given index omitted
|
static Integer[] |
removeIndex(Integer[] data,
int index)
Returns the array with the item in index
removed, if the array is empty it will return the array itself
|
static int[] |
replace(int[] data,
int index,
int newValue)
Return a copy of this array with the
given index omitted
|
static <E> void |
reverse(E[] e) |
static void |
reverse(int[] e)
Reverse the passed in array in place
|
static <E> E[] |
reverseCopy(E[] e) |
static float[] |
reverseCopy(float[] e) |
static int[] |
reverseCopy(int[] e)
Create a backwards copy of the given array
|
static int |
sum(int[] add)
Sum of an int array
|
static int[] |
times(int[] ints,
int mult) |
static int[] |
times(int[] ints,
int[] mult) |
static int[] |
toArray(List<Integer> list) |
static double[] |
toArrayDouble(List<Double> list) |
static double[] |
toDouble(int[] data) |
static double[][] |
toDouble(int[][] arr) |
static double[] |
toDoubles(float[] ints) |
static double[] |
toDoubles(int[] ints) |
static double[] |
toDoubles(int[][] ints) |
static float[] |
toFloats(double[] ints) |
static float[] |
toFloats(int[] ints) |
static float[] |
toFloats(int[][] ints) |
static int[] |
toInts(double[] data) |
static int[] |
toInts(float[] data) |
static int[] |
toInts(INDArray n) |
static INDArray |
toNDArray(int[] nums) |
static INDArray |
toNDArray(int[][] nums) |
static int[] |
toOutcomeArray(int outcome,
int numOutcomes) |
static void |
write(double[] data,
DataOutputStream dos) |
static void |
write(float[] data,
DataOutputStream dos) |
public static int[] randomPermutation(int size)
public static INDArray toNDArray(int[][] nums)
public static INDArray toNDArray(int[] nums)
public static int[] toInts(INDArray n)
public static int[] toInts(float[] data)
public static int[] toInts(double[] data)
public static int offsetFor(int[] stride, int i)
stride
- the stride to usei
- the offset to calculate forpublic static int sum(int[] add)
add
- the elements
to calculate the sum forpublic static int prod(int[] mult)
mult
- the elements
to calculate the sum forpublic static boolean equals(float[] data, double[] data2)
public static int[] consArray(int a, int[] as)
public static boolean isZero(int[] as)
public static boolean anyMore(int[] target, int[] test)
public static boolean anyLess(int[] target, int[] test)
public static int dotProduct(int[] xs, int[] ys)
public static int[] empty()
public static int[] of(int... arr)
public static int[] copy(int[] copy)
public static double[] doubleCopyOf(float[] data)
public static float[] floatCopyOf(double[] data)
public static double[] range(double[] data, int to)
data
- the data to getFromOrigin a subset ofto
- the end point of the datapublic static double[] range(double[] data, int to, int stride)
data
- the data to getFromOrigin a subset ofto
- the end point of the datastride
- the stride to go through the arraypublic static double[] range(double[] data, int to, int stride, int numElementsEachStride)
data
- the data to getFromOrigin a subset ofto
- the end point of the datastride
- the stride to go through the arraynumElementsEachStride
- the number of elements to collect at each stridepublic static int[] range(int from, int to, int increment)
from
- the fromto
- the end point of the dataincrement
- the amount to increment bypublic static int[] range(int from, int to)
from
- the fromto
- the end point of the datapublic static double[] toDoubles(int[] ints)
public static double[] toDoubles(float[] ints)
public static float[] toFloats(int[][] ints)
public static double[] toDoubles(int[][] ints)
public static float[] toFloats(int[] ints)
public static float[] toFloats(double[] ints)
public static int[] replace(int[] data, int index, int newValue)
data
- the data to copyindex
- the index of the item to removenewValue
- the newValue to replacepublic static int[] removeIndex(int[] data, int index)
data
- the data to copyindex
- the index of the item to removepublic static Integer[] removeIndex(Integer[] data, int index)
data
- the data to remove data fromindex
- the index of the item to removepublic static int[] calcStridesFortran(int[] shape, int startNum)
shape
- the shape of a matrix:startNum
- the start number for the stridespublic static int[] calcStridesFortran(int[] shape)
shape
- the shape of a matrix:public static int[] calcStrides(int[] shape, int startValue)
shape
- the shape of a matrix:startValue
- the startValue for the stridespublic static int[] plus(int[] ints, int mult)
public static int[] times(int[] ints, int mult)
public static int[] times(int[] ints, int[] mult)
public static int nonOneStride(int[] arr)
arr
- the array to getScalar the stride forpublic static int[] calcStrides(int[] shape)
shape
- the shape of a matrix:public static int[] reverseCopy(int[] e)
e
- the array to createComplex a reverse clone ofpublic static double[] read(int length, DataInputStream dis) throws IOException
IOException
public static void write(double[] data, DataOutputStream dos) throws IOException
IOException
public static double[] readDouble(int length, DataInputStream dis) throws IOException
IOException
public static float[] readFloat(int length, DataInputStream dis) throws IOException
IOException
public static void write(float[] data, DataOutputStream dos) throws IOException
IOException
public static void assertSquare(double[]... d)
public static void reverse(int[] e)
e
- the array to reversepublic static float[] reverseCopy(float[] e)
public static <E> E[] reverseCopy(E[] e)
public static <E> void reverse(E[] e)
public static float[] flatten(float[][] arr)
public static int[] flatten(int[][] arr)
public static double[] flatten(double[][] arr)
public static double[][] toDouble(int[][] arr)
public static float[] combineFloat(List<float[]> nums)
nums
- the int arrays to combineDoublepublic static float[] combine(List<float[]> nums)
nums
- the int arrays to combineDoublepublic static double[] combineDouble(List<double[]> nums)
nums
- the int arrays to combineDoublepublic static double[] combine(float[]... ints)
ints
- the int arrays to combineDoublepublic static int[] combine(int[]... ints)
ints
- the int arrays to combineDoublepublic static <E> E[] combine(E[]... arrs)
public static int[] toOutcomeArray(int outcome, int numOutcomes)
public static double[] toDouble(int[] data)
public static float[] copy(float[] data)
Copyright © 2015. All Rights Reserved.