public class StrideIndex extends Index
Modifier and Type | Field and Description |
---|---|
protected long[] |
strides
The number of elements to skip to reach the next element in a given dimension.
|
Constructor and Description |
---|
StrideIndex(long... sizes)
Calls
StrideIndex(sizes, defaultStrides(sizes)) . |
StrideIndex(long[] sizes,
long[] strides)
Constructor to set the
Index.sizes and strides . |
Modifier and Type | Method and Description |
---|---|
static long[] |
defaultStrides(long... sizes)
Returns default (row-major contiguous) strides for the given sizes.
|
long |
index(long... indices)
Computes the linear index as the dot product of indices and strides.
|
long |
index(long i)
Returns
i * strides[0] . |
long |
index(long i,
long j)
Returns
i * strides[0] + j * strides[1] . |
long |
index(long i,
long j,
long k)
Returns
i * strides[0] + j * strides[1] + k * strides[2] . |
long[] |
strides()
Returns
strides . |
protected final long[] strides
strides[i] > strides[i + 1] && strides[strides.length - 1] == 1
preferred.public StrideIndex(long... sizes)
StrideIndex(sizes, defaultStrides(sizes))
.public StrideIndex(long[] sizes, long[] strides)
Index.sizes
and strides
.public static long[] defaultStrides(long... sizes)
public long[] strides()
strides
.public long index(long i, long j)
i * strides[0] + j * strides[1]
.public long index(long i, long j, long k)
i * strides[0] + j * strides[1] + k * strides[2]
.Copyright © 2024. All rights reserved.