Class StrideIndex

java.lang.Object
org.bytedeco.javacpp.indexer.Index
org.bytedeco.javacpp.indexer.StrideIndex
Direct Known Subclasses:
HyperslabIndex

public class StrideIndex extends Index
An Index that computes a linear index from given array sizes and strides.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final long[]
    The number of elements to skip to reach the next element in a given dimension.

    Fields inherited from class org.bytedeco.javacpp.indexer.Index

    sizes
  • Constructor Summary

    Constructors
    Constructor
    Description
    StrideIndex(long... sizes)
    Calls StrideIndex(sizes, defaultStrides(sizes)).
    StrideIndex(long[] sizes, long[] strides)
    Constructor to set the Index.sizes and strides.
  • Method Summary

    Modifier and Type
    Method
    Description
    static long[]
    defaultStrides(long... sizes)
    Returns default (row-major contiguous) strides for the given sizes.
    long
    index(long i)
    Returns i * strides[0].
    long
    index(long... indices)
    Computes the linear index as the dot product of indices and strides.
    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[]
    Returns strides.

    Methods inherited from class org.bytedeco.javacpp.indexer.Index

    create, create, create, create, create, rank, size, sizes

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • strides

      protected final long[] strides
      The 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)
      Calls StrideIndex(sizes, defaultStrides(sizes)).
    • StrideIndex

      public StrideIndex(long[] sizes, long[] strides)
      Constructor to set the Index.sizes and strides.
  • Method Details

    • defaultStrides

      public static long[] defaultStrides(long... sizes)
      Returns default (row-major contiguous) strides for the given sizes.
    • strides

      public long[] strides()
      Returns strides.
    • index

      public long index(long i)
      Returns i * strides[0].
      Overrides:
      index in class Index
    • index

      public long index(long i, long j)
      Returns i * strides[0] + j * strides[1].
      Overrides:
      index in class Index
    • index

      public long index(long i, long j, long k)
      Returns i * strides[0] + j * strides[1] + k * strides[2].
      Overrides:
      index in class Index
    • index

      public long index(long... indices)
      Computes the linear index as the dot product of indices and strides.
      Specified by:
      index in class Index
      Parameters:
      indices - of each dimension
      Returns:
      index to access array or buffer