Class 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 long[] strides
      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

      All Methods Static Methods Instance Methods Concrete Methods 
      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[] strides()
      Returns strides.
      • Methods inherited from class java.lang.Object

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

      • 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 Detail

      • 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 Detail

      • 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