Package org.nd4j.linalg.util
Class NDArrayMath
- java.lang.Object
-
- org.nd4j.linalg.util.NDArrayMath
-
public class NDArrayMath extends Object
- Author:
- Adam Gibson
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
lengthPerSlice(INDArray arr)
Return the length of a slicestatic long
lengthPerSlice(INDArray arr, int... dimension)
The number of elements in a slice along a set of dimensionsstatic int
mapIndexOntoTensor(int index, INDArray arr, int... rank)
This maps an index of a vector on to a vector in the matrix that can be used for indexing in to a tensorstatic long
mapIndexOntoVector(int index, INDArray arr)
This maps an index of a vector on to a vector in the matrix that can be used for indexing in to a tensorstatic long
matricesPerSlice(INDArray arr)
The number of vectors in each slice of an ndarray.static long
numVectors(INDArray arr)
Return the number of vectors for an array the number of vectors for an arraystatic long
offsetForSlice(INDArray arr, int slice)
Compute the offset for a given slicestatic long
sliceOffsetForTensor(int index, INDArray arr, int[] tensorShape)
calculates the offset for a tensorstatic long
sliceOffsetForTensor(int index, INDArray arr, long[] tensorShape)
static long
tensorsPerSlice(INDArray arr, int[] tensorShape)
Computes the tensors per slice given a tensor shape and arraystatic long
vectorsPerSlice(INDArray arr)
The number of vectors in each slice of an ndarray.static long
vectorsPerSlice(INDArray arr, int... rank)
The number of vectors in each slice of an ndarray.
-
-
-
Method Detail
-
offsetForSlice
public static long offsetForSlice(INDArray arr, int slice)
Compute the offset for a given slice- Parameters:
arr
- the array to compute the offset frmslice
- the slice to compute the offset for- Returns:
- the offset for a given slice
-
lengthPerSlice
public static long lengthPerSlice(INDArray arr, int... dimension)
The number of elements in a slice along a set of dimensions- Parameters:
arr
- the array to calculate the length per slice fordimension
- the dimensions to do the calculations along- Returns:
- the number of elements in a slice along arbitrary dimensions
-
lengthPerSlice
public static long lengthPerSlice(INDArray arr)
Return the length of a slice- Parameters:
arr
- the array to get the length of a slice for- Returns:
- the number of elements per slice in an array
-
numVectors
public static long numVectors(INDArray arr)
Return the number of vectors for an array the number of vectors for an array- Parameters:
arr
- the array to calculate the number of vectors for- Returns:
- the number of vectors for the given array
-
vectorsPerSlice
public static long vectorsPerSlice(INDArray arr)
The number of vectors in each slice of an ndarray.- Parameters:
arr
- the array to get the number of vectors per slice for- Returns:
- the number of vectors per slice
-
tensorsPerSlice
public static long tensorsPerSlice(INDArray arr, int[] tensorShape)
Computes the tensors per slice given a tensor shape and array- Parameters:
arr
- the array to get the tensors per slice fortensorShape
- the desired tensor shape- Returns:
- the tensors per slice of an ndarray
-
matricesPerSlice
public static long matricesPerSlice(INDArray arr)
The number of vectors in each slice of an ndarray.- Parameters:
arr
- the array to get the number of vectors per slice for- Returns:
- the number of vectors per slice
-
vectorsPerSlice
public static long vectorsPerSlice(INDArray arr, int... rank)
The number of vectors in each slice of an ndarray.- Parameters:
arr
- the array to get the number of vectors per slice forrank
- the dimensions to get the number of vectors per slice for- Returns:
- the number of vectors per slice
-
sliceOffsetForTensor
public static long sliceOffsetForTensor(int index, INDArray arr, int[] tensorShape)
calculates the offset for a tensor- Parameters:
index
-arr
-tensorShape
-- Returns:
-
sliceOffsetForTensor
public static long sliceOffsetForTensor(int index, INDArray arr, long[] tensorShape)
-
mapIndexOntoTensor
public static int mapIndexOntoTensor(int index, INDArray arr, int... rank)
This maps an index of a vector on to a vector in the matrix that can be used for indexing in to a tensor- Parameters:
index
- the index to maparr
- the array to use for indexingrank
- the dimensions to compute a slice for- Returns:
- the mapped index
-
mapIndexOntoVector
public static long mapIndexOntoVector(int index, INDArray arr)
This maps an index of a vector on to a vector in the matrix that can be used for indexing in to a tensor- Parameters:
index
- the index to maparr
- the array to use for indexing- Returns:
- the mapped index
-
-