类 Index
- java.lang.Object
-
- org.meteoinfo.ndarray.Index
-
- 所有已实现的接口:
java.lang.Cloneable
public class Index extends java.lang.Object implements java.lang.CloneableIndexes 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 an Array. The set() and seti() routines are convenience routines for 1-7 dim arrays.- 作者:
- caron
- 另请参阅:
Array
-
-
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 java.lang.Objectclone()static longcomputeSize(int[] shape)Compute total number of elements in the array.intcurrentElement()Get the current element's index into the 1D backing array.static Indexfactory(int[] shape)Generate a subclass of Index optimized for this array's rankint[]getCurrentCounter()Get the current counter.intgetRank()Get the number of dimensions in the array.int[]getShape()Get the shape: length of array in each dimension.intgetShape(int index)Get the length of the ith dimension.longgetSize()Get the total number of elements in the array.intincr()Increment the current element by 1.booleanisFastIterator()protected voidprecalc()subclass specialization/optimization calculationsIndexset(int v0)set current element at dimension 0 to v0Indexset(int[] index)Set the current element's index.Indexset(int v0, int v1)set current element at dimension 0,1 to v0,v1Indexset(int v0, int v1, int v2)set current element at dimension 0,1,2 to v0,v1,v2Indexset(int v0, int v1, int v2, int v3)set current element at dimension 0,1,2,3 to v0,v1,v2,v3Indexset(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,v4Indexset(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,v5Indexset(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,v6Indexset0(int v)set current element at dimension 0 to vIndexset1(int v)set current element at dimension 1 to vIndexset2(int v)set current element at dimension 2 to vIndexset3(int v)set current element at dimension 3 to vIndexset4(int v)set current element at dimension 4 to vIndexset5(int v)set current element at dimension 5 to vIndexset6(int v)set current element at dimension 6 to vvoidsetCurrentCounter(int currElement)Set the current counter from the 1D "current element" currElement = offset + stride[0]*current[0] + ...voidsetDim(int dim, int value)set current element at dimension dim to vjava.lang.StringtoString()java.lang.StringtoStringDebug()String representation
-
-
-
字段详细资料
-
scalarIndexImmutable
public static final Index0D scalarIndexImmutable
-
shape
protected int[] shape
-
stride
protected int[] stride
-
rank
protected int rank
-
size
protected long size
-
offset
protected int offset
-
current
protected int[] current
-
hasvlen
protected boolean hasvlen
-
-
构造器详细资料
-
Index
protected Index(int rank)
General case Index - use when you want to manipulate current elements yourself- 参数:
rank- rank of the Index
-
Index
protected Index(int[] _shape)
Constructor for subclasses only.- 参数:
_shape- describes an index section: slowest varying comes first (row major)
-
Index
public Index(int[] _shape, int[] _stride)Constructor that lets you set the strides yourself. This is used as a counter, not a description of an index section.- 参数:
_shape- Index shape_stride- Index stride
-
-
方法详细资料
-
factory
public static Index factory(int[] shape)
Generate a subclass of Index optimized for this array's rank- 参数:
shape- use this shape- 返回:
- a subclass of Index optimized for this array's rank
-
computeSize
public static long computeSize(int[] shape)
Compute total number of elements in the array. Stop at vlen- 参数:
shape- length of array in each dimension.- 返回:
- total number of elements in the array.
-
precalc
protected void precalc()
subclass specialization/optimization calculations
-
getRank
public int getRank()
Get the number of dimensions in the array.- 返回:
- the number of dimensions in the array.
-
getShape
public int[] getShape()
Get the shape: length of array in each dimension.- 返回:
- the shape
-
getShape
public int getShape(int index)
Get the length of the ith dimension.- 参数:
index- which dimension. must be in [0, getRank())- 返回:
- the ith dimension length
-
isFastIterator
public boolean isFastIterator()
-
getSize
public long getSize()
Get the total number of elements in the array.- 返回:
- the total number of elements in the array.
-
currentElement
public int currentElement()
Get the current element's index into the 1D backing array. VLEN stops processing.- 返回:
- the current element's index into the 1D backing array.
-
getCurrentCounter
public int[] getCurrentCounter()
Get the current counter.- 返回:
- copy of the current counter.
-
setCurrentCounter
public void setCurrentCounter(int currElement)
Set the current counter from the 1D "current element" currElement = offset + stride[0]*current[0] + ...- 参数:
currElement- set to this value
-
incr
public int incr()
Increment the current element by 1. Used by IndexIterator. General rank, with subclass specialization. Vlen skipped.- 返回:
- currentElement()
-
set
public Index set(int[] index)
Set the current element's index. General-rank case.- 参数:
index- set current value to these values- 返回:
- this, so you can use A.get(i.set(i))
- 抛出:
java.lang.ArrayIndexOutOfBoundsException- if index.length != rank.
-
setDim
public void setDim(int dim, int value)set current element at dimension dim to v- 参数:
dim- set this dimensionvalue- to this value
-
set0
public Index set0(int v)
set current element at dimension 0 to v- 参数:
v- set 0th dimension index to this value- 返回:
- this, so you can use A.get(i.set(i))
-
set1
public Index set1(int v)
set current element at dimension 1 to v- 参数:
v- set dimension 1 index to this value- 返回:
- this, so you can use A.get(i.set(i))
-
set2
public Index set2(int v)
set current element at dimension 2 to v- 参数:
v- set dimension 2 index to this value- 返回:
- this, so you can use A.get(i.set(i))
-
set3
public Index set3(int v)
set current element at dimension 3 to v- 参数:
v- set dimension 3 index to this value- 返回:
- this, so you can use A.get(i.set(i))
-
set4
public Index set4(int v)
set current element at dimension 4 to v- 参数:
v- set dimension 4 index to this value- 返回:
- this, so you can use A.get(i.set(i))
-
set5
public Index set5(int v)
set current element at dimension 5 to v- 参数:
v- set dimension 5 index to this value- 返回:
- this, so you can use A.get(i.set(i))
-
set6
public Index set6(int v)
set current element at dimension 6 to v- 参数:
v- set dimension 6 index to this value- 返回:
- this, so you can use A.get(i.set(i))
-
set
public Index set(int v0)
set current element at dimension 0 to v0- 参数:
v0- set dimension 0 index to this value- 返回:
- this, so you can use A.get(i.set(i))
-
set
public Index set(int v0, int v1)
set current element at dimension 0,1 to v0,v1- 参数:
v0- set dimension 0 index to this valuev1- set dimension 1 index to this value- 返回:
- this, so you can use A.get(i.set(i,j))
-
set
public Index set(int v0, int v1, int v2)
set current element at dimension 0,1,2 to v0,v1,v2- 参数:
v0- set dimension 0 index to this valuev1- set dimension 1 index to this valuev2- set dimension 2 index to this value- 返回:
- this, so you can use A.get(i.set(i,j,k))
-
set
public Index set(int v0, int v1, int v2, int v3)
set current element at dimension 0,1,2,3 to v0,v1,v2,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- 返回:
- this, so you can use A.get(i.set(i,j,k,l))
-
set
public 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- 参数:
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- 返回:
- this, so you can use A.get(i.set(i,j,k,l,m))
-
set
public 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- 参数:
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- 返回:
- this, so you can use A.get(i.set(i,j,k,l,m,n))
-
set
public 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- 参数:
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- 返回:
- this, so you can use A.get(i.set(i,j,k,l,m,n,p))
-
toStringDebug
public java.lang.String toStringDebug()
String representation- 返回:
- String representation
-
toString
public java.lang.String toString()
- 覆盖:
toString在类中java.lang.Object
-
clone
public java.lang.Object clone()
- 覆盖:
clone在类中java.lang.Object
-
-