Package gnu.lists

Class GeneralArray<E>

  • All Implemented Interfaces:
    Array<E>
    Direct Known Subclasses:
    GeneralArray1

    public class GeneralArray<E>
    extends TransformedArray<E>
    A class to handle general multi-dimensional arrays. If the number of dimensions (the "rank") is one, should use a class that implements Sequence. GeneralArray uses a SimpleVector 'base' to store the actual data, and provides general linear mapping from the array indexes to an element index in the 'base' SimpleVector. Thus such uperations as transposing an array can be implement as just creating a simple re-mapping of the indexes.
    • Constructor Detail

      • GeneralArray

        public GeneralArray()
      • GeneralArray

        public GeneralArray​(int[] dimensions)
      • GeneralArray

        public GeneralArray​(AVector<E> base,
                            int[] dimensions,
                            int[] lowBounds,
                            int[] strides,
                            int offset)
      • GeneralArray

        public GeneralArray​(AVector<E> base,
                            int[] dimensions,
                            int[] lowBounds)
    • Method Detail

      • nextIndex

        protected int nextIndex​(int ipos)
        Description copied from class: AbstractSequence
        Get the offset from the beginning corresponding to a position cookie.
        Overrides:
        nextIndex in class AbstractSequence<E>
      • makeSimple

        public static Array makeSimple​(int[] lowBounds,
                                       int[] dimensions,
                                       SimpleVector base)
      • init

        protected void init​(AVector<E> base,
                            int[] dimensions,
                            int[] lowBounds,
                            int[] strides,
                            int offset)
      • make

        public static <E> GeneralArray<E> make​(AVector<E> base,
                                               int[] dimensions,
                                               int[] lowBounds,
                                               int[] strides,
                                               int offset)
      • setBase

        public void setBase​(AVector<E> base)
      • setBase

        public void setBase​(E[] data)
      • setStrides

        public void setStrides​(int[] strides,
                               int offset)
      • getDimensions

        public int[] getDimensions()
      • getLowBounds

        public int[] getLowBounds()
      • rank

        public int rank()
        Description copied from interface: Array
        Get the rank (number of dimensions) of this array. The rank of a scalar is 0, of a Sequence is 1, of a matrix is 2, etc.
        Specified by:
        rank in interface Array<E>
        Overrides:
        rank in class AbstractSequence<E>
      • resolve

        public int resolve​(int[] indexes)
        Calculate corresponding index in base array. effectiveIndex[indexes] == base.effectiveIndex(resolve[indexes])
      • getLowBound

        public int getLowBound​(int dim)
        Description copied from interface: Array
        Get the least dimension along the specified dimension.
        Specified by:
        getLowBound in interface Array<E>
        Overrides:
        getLowBound in class AbstractSequence<E>
      • getSize

        public int getSize​(int dim)
        Description copied from interface: Array
        Get length along specified dimension.
        Specified by:
        getSize in interface Array<E>
        Overrides:
        getSize in class AbstractSequence<E>
      • getTag

        public String getTag()