Package org.nd4j.linalg.indexing
Class SpecifiedIndex
- java.lang.Object
-
- org.nd4j.linalg.indexing.SpecifiedIndex
-
- All Implemented Interfaces:
INDArrayIndex
public class SpecifiedIndex extends Object implements INDArrayIndex
A SpecifiedIndex refers to a concrete set of points to be selectively pulled from a given dimension. Note that using this index will always trigger a copy. Pulling random indices from an array wil not allow a view to be computed. Negative indices can also be specified allowing for dynamic resolution of dimensions/coordinates at runtime.- Author:
- Adam Gibson
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classSpecifiedIndex.SingleGeneratorclassSpecifiedIndex.SparseSingleGeneratorstatic classSpecifiedIndex.SparseSpecifiedIndexesGeneratorA generator forSpecifiedIndexforItertools.product(Generator)to iterate over an array given a set of iteratorsstatic classSpecifiedIndex.SpecifiedIndexesGeneratorA generator forSpecifiedIndexforItertools.product(Generator)to iterate over an array given a set of iterators
-
Constructor Summary
Constructors Constructor Description SpecifiedIndex(int... indexes)SpecifiedIndex(long... indexes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description INDArrayIndexdup()Deep copy of thisINDArrayIndexlongend()The ending for this indexnet.ericaro.neoitertools.Generator<List<Long>>generator()voidinit(long begin, long end)Initialize based on the specified begin and endvoidinit(long begin, long end, long max)voidinit(INDArray arr, int dimension)Init the index wrt the dimension and the given nd arrayvoidinit(INDArray arr, long begin, int dimension)Init the index wrt the dimension and the given nd arraybooleaninitialized()Returns true if this index has been initialized.booleanisInterval()Returns true if the index is an intervalstatic net.ericaro.neoitertools.Generator<List<List<Long>>>iterate(INDArrayIndex... indexes)Iterate over a cross product of the coordinatesstatic net.ericaro.neoitertools.Generator<List<List<Long>>>iterateOverSparse(INDArrayIndex... indexes)Iterate over a cross product of the coordinateslonglength()The total length of this index (end - start)longoffset()The start of this indexvoidreverse()Reverse the indexesnet.ericaro.neoitertools.Generator<List<Long>>sparseGenerator()longstride()The stride for the index (most of the time will be 1)
-
-
-
Method Detail
-
end
public long end()
Description copied from interface:INDArrayIndexThe ending for this index- Specified by:
endin interfaceINDArrayIndex- Returns:
-
offset
public long offset()
Description copied from interface:INDArrayIndexThe start of this index- Specified by:
offsetin interfaceINDArrayIndex- Returns:
-
length
public long length()
Description copied from interface:INDArrayIndexThe total length of this index (end - start)- Specified by:
lengthin interfaceINDArrayIndex- Returns:
-
stride
public long stride()
Description copied from interface:INDArrayIndexThe stride for the index (most of the time will be 1)- Specified by:
stridein interfaceINDArrayIndex- Returns:
-
reverse
public void reverse()
Description copied from interface:INDArrayIndexReverse the indexes- Specified by:
reversein interfaceINDArrayIndex
-
isInterval
public boolean isInterval()
Description copied from interface:INDArrayIndexReturns true if the index is an interval- Specified by:
isIntervalin interfaceINDArrayIndex- Returns:
-
init
public void init(INDArray arr, long begin, int dimension)
Description copied from interface:INDArrayIndexInit the index wrt the dimension and the given nd array- Specified by:
initin interfaceINDArrayIndex- Parameters:
arr- the array to initialize onbegin- the beginning indexdimension- the dimension to initialize on
-
init
public void init(INDArray arr, int dimension)
Description copied from interface:INDArrayIndexInit the index wrt the dimension and the given nd array- Specified by:
initin interfaceINDArrayIndex- Parameters:
arr- the array to initialize ondimension- the dimension to initialize on
-
init
public void init(long begin, long end, long max)- Specified by:
initin interfaceINDArrayIndex
-
init
public void init(long begin, long end)Description copied from interface:INDArrayIndexInitialize based on the specified begin and end- Specified by:
initin interfaceINDArrayIndex
-
initialized
public boolean initialized()
Description copied from interface:INDArrayIndexReturns true if this index has been initialized. Sometimes indices may define certain constraints such as negative indices that may not be resolved until use.INDArray.get(INDArrayIndex...)will check for when an index is initialized and if not initialize it upon use.- Specified by:
initializedin interfaceINDArrayIndex- Returns:
-
dup
public INDArrayIndex dup()
Description copied from interface:INDArrayIndexDeep copy of thisINDArrayIndex- Specified by:
dupin interfaceINDArrayIndex- Returns:
-
iterate
public static net.ericaro.neoitertools.Generator<List<List<Long>>> iterate(INDArrayIndex... indexes)
Iterate over a cross product of the coordinates- Parameters:
indexes- the coordinates to iterate over. Each element of the array should be of opTypeSpecifiedIndexotherwise it will end up throwing an exception- Returns:
- the generator for iterating over all the combinations of the specified indexes.
-
iterateOverSparse
public static net.ericaro.neoitertools.Generator<List<List<Long>>> iterateOverSparse(INDArrayIndex... indexes)
Iterate over a cross product of the coordinates- Parameters:
indexes- the coordinates to iterate over. Each element of the array should be of opTypeSpecifiedIndexotherwise it will end up throwing an exception- Returns:
- the generator for iterating over all the combinations of the specified indexes.
-
-