|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectucar.ma2.Index
public class Index
Indexes for Multidimensional arrays. An Index refers to a particular element of an array.
This is a generalization of index as int[]. Its main function is to do the index arithmetic to translate an n-dim index into a 1-dim index. The user obtains this by calling getIndex() on a Array. The set() and seti() routines are convenience routines for 1-7 dim arrays.
Array
Field Summary | |
---|---|
protected int[] |
current
|
protected int |
offset
|
protected int |
rank
|
static Index0D |
scalarIndexImmutable
|
protected int[] |
shape
|
protected long |
size
|
protected int[] |
stride
|
Constructor Summary | |
---|---|
protected |
Index(int rank)
General case Index - use when you want to manipulate current elements yourself |
protected |
Index(int[] _shape)
Constructor for subclasses only. |
|
Index(int[] _shape,
int[] _stride)
Constructor that lets you set the strides yourself. |
Method Summary | |
---|---|
Object |
clone()
|
static long |
computeSize(int[] shape)
Compute total number of elements in the array. |
int |
currentElement()
Get the current element's index into the 1D backing array. |
static Index |
factory(int[] shape)
Generate a subclass of Index optimized for this array's rank |
int[] |
getCurrentCounter()
Get the current counter. |
int |
getRank()
Get the number of dimensions in the array. |
int[] |
getShape()
Get the shape: length of array in each dimension. |
int |
getShape(int index)
Get the length of the ith dimension. |
long |
getSize()
Get the total number of elements in the array. |
int |
incr()
Increment the current element by 1. |
protected void |
precalc()
subclass specialization/optimization calculations |
Index |
set(int v0)
set current element at dimension 0 to v0 |
Index |
set(int[] index)
Set the current element's index. |
Index |
set(int v0,
int v1)
set current element at dimension 0,1 to v0,v1 |
Index |
set(int v0,
int v1,
int v2)
set current element at dimension 0,1,2 to v0,v1,v2 |
Index |
set(int v0,
int v1,
int v2,
int v3)
set current element at dimension 0,1,2,3 to v0,v1,v2,v3 |
Index |
set(int v0,
int v1,
int v2,
int v3,
int v4)
set current element at dimension 0,1,2,3,4 to v0,v1,v2,v3,v4 |
Index |
set(int v0,
int v1,
int v2,
int v3,
int v4,
int v5)
set current element at dimension 0,1,2,3,4,5 to v0,v1,v2,v3,v4,v5 |
Index |
set(int v0,
int v1,
int v2,
int v3,
int v4,
int v5,
int v6)
set current element at dimension 0,1,2,3,4,5,6 to v0,v1,v2,v3,v4,v5,v6 |
Index |
set0(int v)
set current element at dimension 0 to v |
Index |
set1(int v)
set current element at dimension 1 to v |
Index |
set2(int v)
set current element at dimension 2 to v |
Index |
set3(int v)
set current element at dimension 3 to v |
Index |
set4(int v)
set current element at dimension 4 to v |
Index |
set5(int v)
set current element at dimension 5 to v |
Index |
set6(int v)
set current element at dimension 6 to v |
void |
setCurrentCounter(int currElement)
Set the current counter from the 1D "current element" currElement = offset + stride[0]*current[0] + ... |
void |
setDim(int dim,
int value)
set current element at dimension dim to v |
String |
toString()
|
String |
toStringDebug()
String representation |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Index0D scalarIndexImmutable
protected int[] shape
protected int[] stride
protected int rank
protected long size
protected int offset
protected int[] current
Constructor Detail |
---|
protected Index(int rank)
rank
- rank of the Indexprotected Index(int[] _shape)
_shape
- describes an index section: slowest varying comes first (row major)public Index(int[] _shape, int[] _stride)
_shape
- Index shape_stride
- Index strideMethod Detail |
---|
public static Index factory(int[] shape)
shape
- use this shape
public static long computeSize(int[] shape)
shape
- length of array in each dimension.
protected void precalc()
public int getRank()
public int[] getShape()
public int getShape(int index)
index
- which dimension. must be in [0, getRank())
public long getSize()
public int currentElement()
public int[] getCurrentCounter()
public void setCurrentCounter(int currElement)
currElement
- set to this valuepublic int incr()
public Index set(int[] index)
index
- set current value to these values
ArrayIndexOutOfBoundsException
- if index.length != rank.public void setDim(int dim, int value)
dim
- set this dimensionvalue
- to this valuepublic Index set0(int v)
v
- set 0th dimension index to this value
public Index set1(int v)
v
- set dimension 1 index to this value
public Index set2(int v)
v
- set dimension 2 index to this value
public Index set3(int v)
v
- set dimension 3 index to this value
public Index set4(int v)
v
- set dimension 4 index to this value
public Index set5(int v)
v
- set dimension 5 index to this value
public Index set6(int v)
v
- set dimension 6 index to this value
public Index set(int v0)
v0
- set dimension 0 index to this value
public Index set(int v0, int v1)
v0
- set dimension 0 index to this valuev1
- set dimension 1 index to this value
public Index set(int v0, int v1, int v2)
v0
- set dimension 0 index to this valuev1
- set dimension 1 index to this valuev2
- set dimension 2 index to this value
public Index set(int v0, int v1, int v2, int v3)
v0
- set dimension 0 index to this valuev1
- set dimension 1 index to this valuev2
- set dimension 2 index to this valuev3
- set dimension 3 index to this value
public Index set(int v0, int v1, int v2, int v3, int v4)
v0
- set dimension 0 index to this valuev1
- set dimension 1 index to this valuev2
- set dimension 2 index to this valuev3
- set dimension 3 index to this valuev4
- set dimension 4 index to this value
public Index set(int v0, int v1, int v2, int v3, int v4, int v5)
v0
- set dimension 0 index to this valuev1
- set dimension 1 index to this valuev2
- set dimension 2 index to this valuev3
- set dimension 3 index to this valuev4
- set dimension 4 index to this valuev5
- set dimension 5 index to this value
public Index set(int v0, int v1, int v2, int v3, int v4, int v5, int v6)
v0
- set dimension 0 index to this valuev1
- set dimension 1 index to this valuev2
- set dimension 2 index to this valuev3
- set dimension 3 index to this valuev4
- set dimension 4 index to this valuev5
- set dimension 5 index to this valuev6
- set dimension 6 index to this value
public String toStringDebug()
public String toString()
toString
in class Object
public Object clone()
clone
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |