org.nd4j.linalg.indexing
Class Indices
- java.lang.Object
-
- org.nd4j.linalg.indexing.Indices
-
public class Indices extends java.lang.ObjectIndexing util.
-
-
Constructor Summary
Constructors Constructor and Description Indices()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static NDArrayIndex[]adjustIndices(int[] originalShape, NDArrayIndex... indexes)Prunes indices of greater length than the shape and fills in missing indices if there are anystatic NDArrayIndex[]fillIn(int[] shape, NDArrayIndex... indexes)Fill in the missing indices to be the same length as the original shape.static booleanisContiguous(int[] indices)Returns whether the indices are contiguous by one or notstatic booleanisContiguous(int[] indices, int diff)Returns whether indices are contiguous by a certain amount or notstatic booleanisContiguous(int diff, NDArrayIndex... indexes)Returns whether indices are contiguous by a certain amount or notstatic booleanisContiguous(NDArrayIndex... indexes)Returns whether the indices are contiguous by one or notstatic int[]offsets(NDArrayIndex... indices)The offsets (begin index) for each indexstatic int[]shape(int[] shape, NDArrayIndex... indices)Calculate the shape for the given set of indices.static int[]shape(NDArrayIndex... indices)Calculate the shape for the given set of indices.static int[]strides(char ordering, NDArrayIndex... indexes)Calculate the strides based on the given indices
-
-
-
Method Detail
-
offsets
public static int[] offsets(NDArrayIndex... indices)
The offsets (begin index) for each index- Parameters:
indices- the indices- Returns:
- the offsets for the given set of indices
-
fillIn
public static NDArrayIndex[] fillIn(int[] shape, NDArrayIndex... indexes)
Fill in the missing indices to be the same length as the original shape. Think of this as what fills in the indices for numpy or matlab: Given a which is (4,3,2) in numpy: a[1:3] is filled in by the rest to give back the full slice This algorithm fills in that delta- Parameters:
shape- the original shapeindexes- the indexes to start from- Returns:
- the filled in indices
-
adjustIndices
public static NDArrayIndex[] adjustIndices(int[] originalShape, NDArrayIndex... indexes)
Prunes indices of greater length than the shape and fills in missing indices if there are any- Parameters:
originalShape- the original shape to adjust toindexes- the indexes to adjust- Returns:
- the adjusted indices
-
strides
public static int[] strides(char ordering, NDArrayIndex... indexes)Calculate the strides based on the given indices- Parameters:
ordering- the ordering to calculate strides forindexes- the indices to calculate stride for- Returns:
- the strides for the given indices
-
shape
public static int[] shape(NDArrayIndex... indices)
Calculate the shape for the given set of indices. The shape is defined as (for each dimension) the difference between the end index + 1 and the begin index- Parameters:
indices- the indices to calculate the shape for- Returns:
- the shape for the given indices
-
isContiguous
public static boolean isContiguous(NDArrayIndex... indexes)
Returns whether the indices are contiguous by one or not- Parameters:
indexes- the indices to test- Returns:
- whether the indices are contiguous by one or not
-
isContiguous
public static boolean isContiguous(int diff, NDArrayIndex... indexes)Returns whether indices are contiguous by a certain amount or not- Parameters:
indexes- the indices to testdiff- the difference considered to be contiguous- Returns:
- whether the given indices are contiguous or not
-
isContiguous
public static boolean isContiguous(int[] indices)
Returns whether the indices are contiguous by one or not- Parameters:
indices- the indices to test- Returns:
- whether the indices are contiguous by one or not
-
isContiguous
public static boolean isContiguous(int[] indices, int diff)Returns whether indices are contiguous by a certain amount or not- Parameters:
indices- the indices to testdiff- the difference considered to be contiguous- Returns:
- whether the given indices are contiguous or not
-
shape
public static int[] shape(int[] shape, NDArrayIndex... indices)Calculate the shape for the given set of indices. The shape is defined as (for each dimension) the difference between the end index + 1 and the begin index If specified, this will check for whether any of the indices are >= to end - 1 and if so, prune it down- Parameters:
shape- the original shapeindices- the indices to calculate the shape for- Returns:
- the shape for the given indices
-
-
DMelt 3.0 © DataMelt by jWork.ORG