Extracts a slice from an array using static (compile-time) indices.
For dynamic indexing, use nv_subset() instead.
Arguments
- x
(
arrayish)
One input. Can be any data type. An R value materializes at its default data type.- start_indices
(
integer())
Start indices (inclusive), one per axis.- limit_indices
(
integer())
End indices (inclusive), one per axis.- strides
(
integer())
Step sizes, one per axis. A stride of 1 selects every element.
Value
(arrayish)
Has x's data type and shape
ceiling((limit_indices - start_indices + 1) / strides) per axis.
See also
nv_subset(), prim_static_slice() for the underlying primitive.
Examples
# elements 2 through 5, the limit being inclusive
x <- nv_array(1:10)
nv_static_slice(x, start_indices = 2L, limit_indices = 5L, strides = 1L)
#> AnvlArray
#> 2
#> 3
#> 4
#> 5
#> [ CPUi32{4} ]