Package org.bytedeco.javacpp.indexer
Class StrideIndex
java.lang.Object
org.bytedeco.javacpp.indexer.Index
org.bytedeco.javacpp.indexer.StrideIndex
- Direct Known Subclasses:
HyperslabIndex
An Index that computes a linear index from given array sizes and strides.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final long[]
The number of elements to skip to reach the next element in a given dimension. -
Constructor Summary
ConstructorsConstructorDescriptionStrideIndex
(long... sizes) CallsStrideIndex(sizes, defaultStrides(sizes))
.StrideIndex
(long[] sizes, long[] strides) Constructor to set theIndex.sizes
andstrides
. -
Method Summary
Modifier and TypeMethodDescriptionstatic long[]
defaultStrides
(long... sizes) Returns default (row-major contiguous) strides for the given sizes.long
index
(long i) Returnsi * strides[0]
.long
index
(long... indices) Computes the linear index as the dot product of indices and strides.long
index
(long i, long j) Returnsi * strides[0] + j * strides[1]
.long
index
(long i, long j, long k) Returnsi * strides[0] + j * strides[1] + k * strides[2]
.long[]
strides()
Returnsstrides
.
-
Field Details
-
strides
protected final long[] stridesThe number of elements to skip to reach the next element in a given dimension.strides[i] > strides[i + 1] && strides[strides.length - 1] == 1
preferred.
-
-
Constructor Details
-
StrideIndex
public StrideIndex(long... sizes) CallsStrideIndex(sizes, defaultStrides(sizes))
. -
StrideIndex
public StrideIndex(long[] sizes, long[] strides) Constructor to set theIndex.sizes
andstrides
.
-
-
Method Details
-
defaultStrides
public static long[] defaultStrides(long... sizes) Returns default (row-major contiguous) strides for the given sizes. -
strides
public long[] strides()Returnsstrides
. -
index
public long index(long i) Returnsi * strides[0]
. -
index
public long index(long i, long j) Returnsi * strides[0] + j * strides[1]
. -
index
public long index(long i, long j, long k) Returnsi * strides[0] + j * strides[1] + k * strides[2]
. -
index
public long index(long... indices) Computes the linear index as the dot product of indices and strides.
-