mikera.arrayz
Class Arrayz
- java.lang.Object
-
- mikera.arrayz.Arrayz
-
public class Arrayz extends java.lang.ObjectStatic function class for array operations
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static voidcheckShape(INDArray array, int dimension, int index)Checks that a specified index exists along a specified dimension.static INDArraycreate(INDArray a)Create a new mutable array instance with the given source data.static INDArraycreate(java.util.List<?> slices)Creates an array from the given List of slices.static INDArraycreate(java.lang.Object object)Creates an array from the given data.static <T> INDArraycreate(T[] data)Creates an array using the given data as slices.static INDArraycreateFromVector(AVector a, int... shape)Creates a new array using the elements in the specified vector.static INDArraycreateSparse(INDArray a)Creates a sparse copy of the given array.static <T> INDArraycreateSparse(java.util.List<T> o)Creates a sparse array given the provided List of slice objectsstatic INDArraycreateSparse(java.lang.Object o)Creates a sparse array given the provided input object Supports - Numbers (wrapped as scalars) - Existing INDArrays (copied into sparse format) - Iterable objects (interpreted as ordered lists of major slices) - Java Arrays (interpreted as arrays of slices Objects)static <T> INDArraycreateSparse(T... slices)Creates a sparse copy of the given data, given an array of slices to make sparse.static INDArraycreateSparseArray(int... shape)Creates a mutable sparse array of the specified shape.static INDArraycreateSparseMutable(INDArray a)Creates a fully mutable sparse clone of the given arraystatic INDArraycreateZeroArray(int... shape)Creates an immutable zero-filled array of the given shapestatic voidfillNormal(INDArray a, long seed)static voidfillNormal(INDArray a, java.util.Random random)static voidfillRandom(INDArray a, long seed)static voidfillRandom(INDArray a, java.util.Random random)static booleanisPackedLayout(double[] data, int offset, int[] shape, int[] strides)Returns true if the offset, shape and strides describe a fully packed, row-major dense layout for the given data array.static booleanisPackedStrides(int[] shape, int[] strides)Checks if the given set of strides represents a fully packed, row major layout for the given shapestatic INDArrayload(java.io.Reader reader)static INDArraynewArray(int... shape)Create a new mutable array instance with the given shape.static INDArrayparse(java.lang.String ednString)Parse an array from a String.static INDArraywrap(double[] data, int[] shape)Creates an INDArray instance wrapping the given double data, with the provided shape.static INDArraywrapStrided(double[] data, int offset, int[] shape, int[] strides)Wraps a Java double[] as a general, mutable strided array.
-
-
-
Method Detail
-
create
public static INDArray create(java.lang.Object object)
Creates an array from the given data. Makes a copy of underlying data as necessary. Handles double arrays, Java arrays, INDArray instances, and lists- Parameters:
object-- Returns:
-
create
public static INDArray create(java.util.List<?> slices)
Creates an array from the given List of slices. Calls create recursively on underlying slices if needed, so that nested structures can be used- Parameters:
object-- Returns:
-
newArray
public static INDArray newArray(int... shape)
Create a new mutable array instance with the given shape. New array will be filled with zeros. Uses the most efficient densely packed format where possible.- Parameters:
shape-- Returns:
-
create
public static INDArray create(INDArray a)
Create a new mutable array instance with the given source data. Uses the most efficient densely packed format where possible.- Parameters:
shape-- Returns:
-
create
public static <T> INDArray create(T[] data)
Creates an array using the given data as slices.- Parameters:
data-- Returns:
-
wrap
public static INDArray wrap(double[] data, int[] shape)
Creates an INDArray instance wrapping the given double data, with the provided shape.- Parameters:
data-shape-- Returns:
-
createFromVector
public static INDArray createFromVector(AVector a, int... shape)
Creates a new array using the elements in the specified vector. Truncates or zero-pads the data as required to fill the new array- Parameters:
data-rows-columns-- Returns:
-
load
public static INDArray load(java.io.Reader reader)
-
parse
public static INDArray parse(java.lang.String ednString)
Parse an array from a String. String should be in edn format- Parameters:
ednString-- Returns:
-
wrapStrided
public static INDArray wrapStrided(double[] data, int offset, int[] shape, int[] strides)
Wraps a Java double[] as a general, mutable strided array. Selects the most appropriate Vectorz type (Vector, Matrix, Array etc.)- Parameters:
data-offset-shape-strides-- Returns:
-
isPackedLayout
public static boolean isPackedLayout(double[] data, int offset, int[] shape, int[] strides)Returns true if the offset, shape and strides describe a fully packed, row-major dense layout for the given data array.- Parameters:
data-offset-shape-strides-- Returns:
-
isPackedStrides
public static boolean isPackedStrides(int[] shape, int[] strides)Checks if the given set of strides represents a fully packed, row major layout for the given shape- Parameters:
shape-strides-- Returns:
-
createSparse
public static INDArray createSparse(INDArray a)
Creates a sparse copy of the given array. May or may not be mutable.- Parameters:
a-- Returns:
-
createSparse
public static <T> INDArray createSparse(T... slices)
Creates a sparse copy of the given data, given an array of slices to make sparse.- Parameters:
a-- Returns:
-
createSparse
public static INDArray createSparse(java.lang.Object o)
Creates a sparse array given the provided input object Supports - Numbers (wrapped as scalars) - Existing INDArrays (copied into sparse format) - Iterable objects (interpreted as ordered lists of major slices) - Java Arrays (interpreted as arrays of slices Objects)
-
createSparse
public static <T> INDArray createSparse(java.util.List<T> o)
Creates a sparse array given the provided List of slice objects
-
createSparseMutable
public static INDArray createSparseMutable(INDArray a)
Creates a fully mutable sparse clone of the given array- Parameters:
a-- Returns:
-
createZeroArray
public static INDArray createZeroArray(int... shape)
Creates an immutable zero-filled array of the given shape- Parameters:
shape-- Returns:
-
createSparseArray
public static INDArray createSparseArray(int... shape)
Creates a mutable sparse array of the specified shape.- Parameters:
shape-- Returns:
-
fillRandom
public static void fillRandom(INDArray a, long seed)
-
fillRandom
public static void fillRandom(INDArray a, java.util.Random random)
-
fillNormal
public static void fillNormal(INDArray a, long seed)
-
fillNormal
public static void fillNormal(INDArray a, java.util.Random random)
-
checkShape
public static void checkShape(INDArray array, int dimension, int index)
Checks that a specified index exists along a specified dimension. Throws an exception if the index does not exist.- Parameters:
array-dimension-index-- Throws:
java.lang.IndexOutOfBoundsException- if the specified index or dimension does not exist.
-
-
DMelt 3.0 © DataMelt by jWork.ORG