Package gnu.lists
Class GeneralArray<E>
- java.lang.Object
-
- gnu.lists.AbstractSequence<E>
-
- gnu.lists.TransformedArray<E>
-
- gnu.lists.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.
-
-
Field Summary
-
Fields inherited from class gnu.lists.TransformedArray
base
-
Fields inherited from class gnu.lists.AbstractSequence
noInts
-
-
Constructor Summary
Constructors Constructor Description GeneralArray()GeneralArray(int[] dimensions)GeneralArray(AVector<E> base, int[] dimensions, int[] lowBounds)GeneralArray(AVector<E> base, int[] dimensions, int[] lowBounds, int[] strides, int offset)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description inteffectiveIndex()inteffectiveIndex(int i)inteffectiveIndex(int i, int j)inteffectiveIndex(int i, int j, int k, int... rest)Eget(int[] indexes)AVector<E>getBase()int[]getDimensions()intgetLowBound(int dim)Get the least dimension along the specified dimension.int[]getLowBounds()intgetSize(int dim)Get length along specified dimension.StringgetTag()protected voidinit(AVector<E> base, int[] dimensions, int[] lowBounds, int[] strides, int offset)static <E> GeneralArray<E>make(AVector<E> base, int[] dimensions, int[] lowBounds, int[] strides, int offset)static <E> GeneralArray<E>make0(AVector<E> base)static ArraymakeSimple(int[] lowBounds, int[] dimensions, SimpleVector base)protected intnextIndex(int ipos)Get the offset from the beginning corresponding to a position cookie.intrank()Get the rank (number of dimensions) of this array.intresolve(int[] indexes)Calculate corresponding index in base array.voidsetBase(E[] data)voidsetBase(AVector<E> base)voidsetStrides(int[] strides, int offset)intsize()See java.util.Collection.StringtoString()static voidtoString(Array array, StringBuffer sbuf)-
Methods inherited from class gnu.lists.TransformedArray
checkCanWrite, getBooleanRaw, getByteRaw, getCharRaw, getDoubleRaw, getElementKind, getFloatRaw, getInt, getInt, getIntRaw, getLongRaw, getRaw, getRowMajor, getShortRaw, setRaw
-
Methods inherited from class gnu.lists.AbstractSequence
add, add, addAll, addAll, addPos, asImmutable, badRank, boundedHash, checkRank, clear, compare, compare, compare, consume, consume, consumeNext, consumePosRange, contains, containsAll, copyPos, createPos, createRelativePos, effectiveIndex, elements, endPos, equals, equals, fill, fill, fillPosRange, firstAttributePos, firstChildPos, firstChildPos, fromEndIndex, get, get, get, get, getAttribute, getAttributeLength, getContainingSequenceSize, getIndexDifference, getInt, getInt, getInt, getIterator, getIterator, getIteratorAtPos, getNextKind, getNextTypeName, getNextTypeObject, getPosNext, getPosPrevious, getSize, gotoAttributesStart, gotoChildrenStart, gotoParent, hashCode, hasNext, hasPrevious, indexOf, isAfterPos, isEmpty, iterator, lastIndexOf, listIterator, listIterator, nextIndex, nextMatching, nextPos, parentPos, previousPos, releasePos, remove, remove, removeAll, removePos, removePosRange, retainAll, set, set, setAt, setBuffer, setPosNext, setPosPrevious, stableCompare, startPos, subList, subSequence, subSequencePos, toArray, toArray, toString, unsupported, unsupportedException
-
-
-
-
Method Detail
-
nextIndex
protected int nextIndex(int ipos)
Description copied from class:AbstractSequenceGet the offset from the beginning corresponding to a position cookie.- Overrides:
nextIndexin classAbstractSequence<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)
-
make0
public static <E> GeneralArray<E> make0(AVector<E> base)
-
make
public static <E> GeneralArray<E> make(AVector<E> base, int[] dimensions, int[] lowBounds, int[] strides, int offset)
-
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:ArrayGet 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.
-
effectiveIndex
public int effectiveIndex()
- Specified by:
effectiveIndexin interfaceArray<E>- Overrides:
effectiveIndexin classAbstractSequence<E>
-
effectiveIndex
public int effectiveIndex(int i)
- Specified by:
effectiveIndexin interfaceArray<E>- Overrides:
effectiveIndexin classAbstractSequence<E>
-
effectiveIndex
public int effectiveIndex(int i, int j)- Specified by:
effectiveIndexin interfaceArray<E>- Overrides:
effectiveIndexin classAbstractSequence<E>
-
effectiveIndex
public int effectiveIndex(int i, int j, int k, int... rest)- Specified by:
effectiveIndexin interfaceArray<E>- Overrides:
effectiveIndexin classAbstractSequence<E>
-
resolve
public int resolve(int[] indexes)
Calculate corresponding index in base array. effectiveIndex[indexes] == base.effectiveIndex(resolve[indexes])
-
get
public E get(int[] indexes)
-
size
public int size()
See java.util.Collection.- Overrides:
sizein classAbstractSequence<E>
-
getLowBound
public int getLowBound(int dim)
Description copied from interface:ArrayGet the least dimension along the specified dimension.- Specified by:
getLowBoundin interfaceArray<E>- Overrides:
getLowBoundin classAbstractSequence<E>
-
getSize
public int getSize(int dim)
Description copied from interface:ArrayGet length along specified dimension.
-
toString
public static void toString(Array array, StringBuffer sbuf)
-
getTag
public String getTag()
-
toString
public String toString()
- Overrides:
toStringin classAbstractSequence<E>
-
-