Helper class for instantiating Index
objects.
Public Constructors
Indices()
|
Public Methods
static Index |
all()
An index that returns all elements of a dimension in the original order.
|
static Index | |
static Index |
at(long coord, boolean keepDim)
A coordinate that selects a specific element on a given dimension.
|
static Index |
at(long coord)
A coordinate that selects a specific element on a given dimension.
|
static Index | |
static Index |
ellipsis()
An index that expands to fill all available source dimensions.
|
static Index |
even()
An index that returns only elements found at an even position in the original dimension.
|
static Index |
flip()
An index that returns only elements on a given dimension between two coordinates.
|
static Index |
hyperslab(long start, long stride, long count, long block)
An index that returns elements according to an hyperslab defined by
start , stride , count ,
block . |
static Index |
newAxis()
An index that inserts a new dimension of size 1 into the resulting array.
|
static Index |
odd()
An index that returns only elements found at an odd position in the original dimension.
|
static Index |
range(long start, long end)
An index that returns only elements on a given dimension between two coordinates.
|
static Index | |
static Index |
seq(long... coords)
An index that returns only specific elements on a given dimension.
|
static Index |
slice(long start, long end, long stride)
An index that returns every
stride -th element between start and end . |
static Index |
slice(Long start, Long end)
An index that returns elements between
start and end . |
static Index |
slice(long start, long end)
An index that returns elements between
start and end . |
static Index |
slice(Long start, Long end, long stride)
An index that returns every
stride -th element between start and end . |
static Index |
sliceFrom(long start)
An index that returns only elements on a given dimension starting at a specific coordinate.
|
static Index |
sliceFrom(long start, long stride)
An index that returns only elements on a given dimension starting at a specific coordinate, using the given
stride.
|
static Index |
sliceTo(long end)
An index that returns only elements on a given dimension up to a specific coordinate.
|
static Index |
sliceTo(long end, long stride)
An index that returns only elements on a given dimension up to a specific coordinate, using the given stride.
|
static Index |
step(long stride)
An index that skips a fixed amount of coordinates between each values returned.
|
Inherited Methods
Public Constructors
public Indices ()
Public Methods
public static Index all ()
An index that returns all elements of a dimension in the original order.
Applying this index to a given dimension will return the original dimension directly.
For example, given a vector with n
elements, all()
returns
x0, x1, ..., xn-1
Returns
- index
public static Index at (NdArray<? extends Number> coord)
A coordinate that selects a specific element on a given dimension.
This is equivalent to call at(long)
but where the value of the coordinate is
provided by an N-dimensional array.
Parameters
coord | scalar indicating the coordinate of the element on the indexed axis |
---|
Returns
- index
Throws
IllegalRankException | if coord is not a scalar (rank 0)
|
---|
public static Index at (long coord, boolean keepDim)
A coordinate that selects a specific element on a given dimension.
When this index is applied to a given dimension, the dimension is resolved as a
single element and therefore, if keepDim
is false, is excluded from the computation of the rank. If
keepDim is true, the dimension is collapsed down to one element.
For example, given a 3D matrix on the axis [x, y, z], if
matrix.slice(all(), at(0), at(0)
, then the rank of the returned slice is 1 and its number of elements is
x.numElements()
Parameters
coord | coordinate of the element on the indexed axis |
---|---|
keepDim | whether to remove the dimension. |
Returns
- index
public static Index at (long coord)
A coordinate that selects a specific element on a given dimension.
When this index is applied to a given dimension, the dimension is resolved as a single element and therefore is excluded from the computation of the rank.
For example, given a 3D matrix on the axis [x, y, z], if
matrix.slice(all(), at(0), at(0)
, then the rank of the returned slice is 1 and its number of elements is
x.numElements()
Parameters
coord | coordinate of the element on the indexed axis |
---|
Returns
- index
public static Index at (NdArray<? extends Number> coord, boolean keepDim)
A coordinate that selects a specific element on a given dimension.
This is equivalent to call at(long, boolean)
but where the value of the coordinate is
provided by an N-dimensional array.
If keepDim is true, the dimension is collapsed down to one element instead of being removed.
Parameters
coord | scalar indicating the coordinate of the element on the indexed axis |
---|---|
keepDim | whether to remove the dimension. |
Returns
- index
Throws
IllegalRankException | if coord is not a scalar (rank 0)
|
---|
public static Index ellipsis ()
An index that expands to fill all available source dimensions. Works the same as Python's ...
.
Returns
- index
public static Index even ()
An index that returns only elements found at an even position in the original dimension.
For example, given a vector with n
elements on the x
axis, and n is even,
even()
returns x0, x2, ..., xn-2
Returns
- index
public static Index flip ()
An index that returns only elements on a given dimension between two coordinates.
For example, given a vector with n
elements on the x
axis, and n > k > j
,
range(j, k)
returns xj, xj+1, ..., xk
Returns
- index
public static Index hyperslab (long start, long stride, long count, long block)
An index that returns elements according to an hyperslab defined by start
, stride
, count
,
block
. See ERROR(/Hyperslab)
.
Parameters
start | Starting location for the hyperslab. |
---|---|
stride | The number of elements to separate each element or block to be selected. |
count | The number of elements or blocks to select along the dimension. |
block | The size of the block selected from the dimension. |
Returns
- index
public static Index newAxis ()
An index that inserts a new dimension of size 1 into the resulting array.
Returns
- index
public static Index odd ()
An index that returns only elements found at an odd position in the original dimension.
For example, given a vector with n
elements on the x
axis, and n is even,
odd()
returns x1, x3, ..., xn-1
Returns
- index
public static Index range (long start, long end)
An index that returns only elements on a given dimension between two coordinates.
For example, given a vector with n
elements on the x
axis, and n > k > j
,
range(j, k)
returns xj, xj+1, ..., xk
Parameters
start | coordinate of the first element of the sequence |
---|---|
end | coordinate of the last element of the sequence (exclusive) |
Returns
- index
public static Index seq (NdArray<? extends Number> coords)
An index that returns only specific elements on a given dimension.
This is equivalent to seq(long)
but where the coordinates of the elements in
the sequence are provided by an N-dimensional array.
Parameters
coords | vector of coordinates of the elements in the sequence |
---|
Returns
- index
Throws
IllegalRankException | if coords is not a vector (rank 1)
|
---|
public static Index seq (long... coords)
An index that returns only specific elements on a given dimension.
For example, given a vector with n
elements on the x
axis, and n > 10
,
seq(8, 0, 3)
returns x8, x0, x3
Parameters
coords | coordinates of the elements in the sequence |
---|
Returns
- index
public static Index slice (long start, long end, long stride)
An index that returns every stride
-th element between start
and end
. If start
or
end
is null
, starts or ends at the beginning or the end, respectively.
Analogous to Python's :
slice syntax.
Returns
- index
public static Index slice (Long start, Long end)
An index that returns elements between start
and end
. If start
or end
is null
, starts or ends at the beginning or the end, respectively.
Analogous to Python's :
slice syntax.
Returns
- index
public static Index slice (long start, long end)
An index that returns elements between start
and end
. If start
or end
is null
, starts or ends at the beginning or the end, respectively.
Analogous to Python's :
slice syntax.
Returns
- index
public static Index slice (Long start, Long end, long stride)
An index that returns every stride
-th element between start
and end
. If start
or
end
is null
, starts or ends at the beginning or the end, respectively.
Analogous to Python's :
slice syntax.
Returns
- index
public static Index sliceFrom (long start)
An index that returns only elements on a given dimension starting at a specific coordinate.
For example, given a vector with n
elements on the x
axis, and n > k
,
from(k)
returns xk, xk+1, ..., xn-1
Parameters
start | coordinate of the first element of the sequence |
---|
Returns
- index
public static Index sliceFrom (long start, long stride)
An index that returns only elements on a given dimension starting at a specific coordinate, using the given stride.
For example, given a vector with n
elements on the x
axis, and n > k
,
from(k)
returns xk, xk+1, ..., xn-1
Parameters
start | coordinate of the first element of the sequence |
---|---|
stride | the stride to use |
Returns
- index
See Also
public static Index sliceTo (long end)
An index that returns only elements on a given dimension up to a specific coordinate.
For example, given a vector with n
elements on the x
axis, and n > k
,
to(k)
returns x0, x1, ..., xk
Parameters
end | coordinate of the last element of the sequence (exclusive) |
---|
Returns
- index
public static Index sliceTo (long end, long stride)
An index that returns only elements on a given dimension up to a specific coordinate, using the given stride.
For example, given a vector with n
elements on the x
axis, and n > k
,
to(k)
returns x0, x1, ..., xk
Parameters
end | coordinate of the last element of the sequence (exclusive) |
---|---|
stride | the stride to use |
Returns
- index
See Also
public static Index step (long stride)
An index that skips a fixed amount of coordinates between each values returned.
For example, given a vector with n
elements on the x
axis,
step(k)
returns x0, xk, xk*2, ...
Parameters
stride | the number of elements between each steps |
---|
Returns
- index