public class NDArrayIndex extends Object implements INDArrayIndex
Constructor and Description |
---|
NDArrayIndex(int... indices)
NDArrayIndexing based on the given
indexes
|
Modifier and Type | Method and Description |
---|---|
static INDArrayIndex |
all()
Represents collecting all elements
|
static INDArrayIndex[] |
allFor(INDArray arr)
Generate an all index
equal to the rank of the given array
|
static INDArrayIndex[] |
create(INDArray index)
Create from a matrix.
|
static INDArrayIndex[] |
createCoveringShape(int[] shape)
Creates an index covering the given shape
(for each dimension 0,shape[i])
|
int |
current()
Return the current index
without incrementing the counter
|
static INDArrayIndex |
empty()
Represents collecting no elements
|
int |
end()
The ending for this index
|
boolean |
equals(Object o) |
int |
hashCode() |
boolean |
hasNext()
Returns true if there is another element
in the index to iterate over
otherwise false
|
static INDArrayIndex[] |
indexesFor(int... shape)
Add indexes for the given shape
|
void |
init(INDArray arr,
int dimension)
Init the index wrt
the dimension and the given nd array
|
void |
init(INDArray arr,
int begin,
int dimension)
Init the index wrt
the dimension and the given nd array
|
void |
init(int begin,
int end)
Initiailize based on the specified begin and end
|
static INDArrayIndex |
interval(int begin,
int end)
Generates an interval from begin (inclusive) to end (exclusive)
|
static INDArrayIndex |
interval(int begin,
int end,
boolean inclusive)
Generates an interval from begin (inclusive) to end (exclusive)
|
static INDArrayIndex |
interval(int begin,
int stride,
int end)
Generates an interval from begin (inclusive) to end (exclusive)
|
static INDArrayIndex |
interval(int begin,
int stride,
int end,
boolean inclusive)
Generates an interval from begin (inclusive) to end (exclusive)
|
boolean |
isInterval()
Returns true
if the index is an interval
|
int |
length()
Returns the length of the indices
|
static INDArrayIndex |
newAxis()
Represents adding a new dimension
|
int |
next()
Returns the next index
|
static INDArrayIndex[] |
nTimes(INDArrayIndex copy,
int n)
Repeat a copy of copy n times
|
static int |
numNewAxis(INDArrayIndex... axes)
Given an array of indexes
return the number of new axis elements
in teh array
|
static int |
numPoints(INDArrayIndex... indexes)
Number of point indexes
|
int |
offset()
The start of this index
|
static int |
offset(INDArray arr,
INDArrayIndex... indices)
Compute the offset given an array of offsets.
|
static int |
offset(INDArray arr,
int... offsets)
Compute the offset given an array of offsets.
|
static int |
offset(int[] strides,
int[] offsets)
Compute the offset given an array of offsets.
|
static INDArrayIndex |
point(int point)
Returns a point index
|
static INDArrayIndex[] |
rangeOfLength(INDArrayIndex[] indexes)
Create a range based on the given indexes.
|
void |
reset() |
static INDArrayIndex[] |
resolve(INDArray arr,
INDArrayIndex... intendedIndexes)
Given an all index and
the intended indexes, return an
index array containing a combination of all elements
for slicing and overriding particular indexes where necessary
|
static INDArrayIndex[] |
resolve(INDArrayIndex[] allIndex,
INDArrayIndex... intendedIndexes)
Given an all index and
the intended indexes, return an
index array containing a combination of all elements
for slicing and overriding particular indexes where necessary
|
static INDArrayIndex[] |
resolve(int[] shape,
INDArrayIndex... intendedIndexes)
Given an all index and
the intended indexes, return an
index array containing a combination of all elements
for slicing and overriding particular indexes where necessary
|
void |
reverse()
Reverse the indexes
|
void |
setInterval(boolean isInterval) |
int |
stride()
The stride for the index (most of the time will be 1)
|
String |
toString() |
static void |
updateForNewAxes(INDArray arr,
INDArrayIndex... indexes)
Set the shape and stride for
new axes based dimensions
|
protected static INDArrayIndex |
validate(int size,
INDArrayIndex index) |
public NDArrayIndex(int... indices)
indices
- public static INDArrayIndex point(int point)
point
- the point indexpublic static INDArrayIndex[] indexesFor(int... shape)
shape
- the shape ot convert to indexespublic static int offset(INDArray arr, int... offsets)
arr
- the array to compute the offset foroffsets
- the offsets for each dimensionpublic static int offset(INDArray arr, INDArrayIndex... indices)
arr
- the array to compute the offset forindices
- the offsets for each dimensionpublic static void updateForNewAxes(INDArray arr, INDArrayIndex... indexes)
arr
- the array to update
the shape/strides forindexes
- the indexes to update based onpublic static int offset(int[] strides, int[] offsets)
strides
- the strides to compute the offset foroffsets
- the offsets for each dimensionpublic static INDArrayIndex[] nTimes(INDArrayIndex copy, int n)
copy
- the ndarray index to copyn
- the number of times to copypublic static INDArrayIndex empty()
public static INDArrayIndex all()
public static INDArrayIndex newAxis()
public static INDArrayIndex[] resolve(INDArray arr, INDArrayIndex... intendedIndexes)
arr
- the array to resolve indexes forintendedIndexes
- the indexes specified by the userpublic static int numPoints(INDArrayIndex... indexes)
indexes
- the indexes
to count for pointspublic static INDArrayIndex[] resolve(int[] shape, INDArrayIndex... intendedIndexes)
shape
- the index containing all elementsintendedIndexes
- the indexes specified by the userprotected static INDArrayIndex validate(int size, INDArrayIndex index)
public static INDArrayIndex[] resolve(INDArrayIndex[] allIndex, INDArrayIndex... intendedIndexes)
allIndex
- the index containing all elementsintendedIndexes
- the indexes specified by the userpublic static int numNewAxis(INDArrayIndex... axes)
axes
- the indexes to get the number
of new axes forpublic static INDArrayIndex[] allFor(INDArray arr)
arr
- the array to generate the all index forpublic static INDArrayIndex[] createCoveringShape(int[] shape)
shape
- the shape to coverpublic static INDArrayIndex[] rangeOfLength(INDArrayIndex[] indexes)
indexes
- the indexes to create the range forpublic static INDArrayIndex[] create(INDArray index)
index
- the matrix to getFloat indices frompublic static INDArrayIndex interval(int begin, int stride, int end)
begin
- the beginstride
- the stride at which to incrementend
- the end indexpublic static INDArrayIndex interval(int begin, int stride, int end, boolean inclusive)
begin
- the beginstride
- the stride at which to incrementend
- the end indexinclusive
- whether the end should be inclusive or notpublic static INDArrayIndex interval(int begin, int end)
begin
- the beginend
- the end indexpublic static INDArrayIndex interval(int begin, int end, boolean inclusive)
begin
- the beginend
- the end indexinclusive
- whether the end should be inclusive or notpublic int end()
INDArrayIndex
end
in interface INDArrayIndex
public int offset()
INDArrayIndex
offset
in interface INDArrayIndex
public int length()
length
in interface INDArrayIndex
public int stride()
INDArrayIndex
stride
in interface INDArrayIndex
public int current()
INDArrayIndex
current
in interface INDArrayIndex
public boolean hasNext()
INDArrayIndex
hasNext
in interface INDArrayIndex
public int next()
INDArrayIndex
next
in interface INDArrayIndex
public void reverse()
INDArrayIndex
reverse
in interface INDArrayIndex
public boolean isInterval()
INDArrayIndex
isInterval
in interface INDArrayIndex
public void setInterval(boolean isInterval)
setInterval
in interface INDArrayIndex
public void init(INDArray arr, int begin, int dimension)
INDArrayIndex
init
in interface INDArrayIndex
arr
- the array to initialize onbegin
- the beginning indexdimension
- the dimension to initialize onpublic void init(INDArray arr, int dimension)
INDArrayIndex
init
in interface INDArrayIndex
arr
- the array to initialize ondimension
- the dimension to initialize onpublic void init(int begin, int end)
INDArrayIndex
init
in interface INDArrayIndex
public void reset()
reset
in interface INDArrayIndex
Copyright © 2015. All Rights Reserved.