|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--ucar.multiarray.ArrayMultiArray
MultiArray implementation which is an adapter for java language arrays. If you have a java array and want to wrap it in a MultiArray interface, use this class. Rank of these is always > 0, use ScalarMultiArray for scalars.
The set, setXXX, get, getXXX methods use the corresponding methods from java.lang.reflect.Array, the conversion and exception characteristics of the methods here are like the ones found there.
Array,
MultiArray,
ScalarMultiArray| Field Summary | |
java.lang.Object |
jla
The java language array which this adapts. |
| Constructor Summary | |
ArrayMultiArray(java.lang.Class componentType,
int[] dimensions)
Create a new MultiArray of the given componentType and shape. |
|
ArrayMultiArray(MultiArray ma)
A copy constructor. |
|
ArrayMultiArray(java.lang.Object aro)
Given a java Object, typically an array of primitive (or an array of array of primitive ...), Provide a MultiArray interface to the provided object. |
|
| Method Summary | |
void |
copyin(int[] origin,
MultiArray data)
Aggregate write access. |
MultiArray |
copyout(int[] origin,
int[] shape)
Aggregate read access. |
java.lang.Object |
get(int index)
Peel the array by fixing the leftmost index value to the argument. |
java.lang.Object |
get(int[] index)
Get (read) the array element at index. |
boolean |
getBoolean(int[] index)
Get the array element at index, as a boolean. |
byte |
getByte(int[] index)
Get the array element at index, as a byte. |
char |
getChar(int[] index)
Get the array element at index, as a char. |
java.lang.Class |
getComponentType()
Returns the Class object representing the component type of the wrapped array. |
double |
getDouble(int[] index)
Get the array element at index, as a double. |
float |
getFloat(int[] index)
Get the array element at index, as a float. |
int |
getInt(int[] index)
Get the array element at index, as an int. |
java.lang.Object |
getLeaf(int[] index)
Get the leaf array at Index. |
int[] |
getLengths()
As if java.lang.reflect.Array.getLength() were called recursively on the wrapped object, return the dimension lengths. |
long |
getLong(int[] index)
Get the array element at index, as a long. |
int |
getRank()
Returns the number of dimensions of the array. |
short |
getShort(int[] index)
Get the array element at index, as a short. |
boolean |
isScalar()
Always returns false for this class. |
boolean |
isUnlimited()
Returns true if and only if the effective dimension
lengths can change. |
static void |
main(java.lang.String[] args)
|
void |
set(int[] index,
java.lang.Object value)
Set (modify, write) the array element at index to the specified value. |
void |
setBoolean(int[] index,
boolean value)
Set the array element at index to the specified boolean value. |
void |
setByte(int[] index,
byte value)
Set the array element at index to the specified byte value. |
void |
setChar(int[] index,
char value)
Set the array element at index to the specified char value. |
void |
setDouble(int[] index,
double value)
Set the array element at index to the specified double value. |
void |
setFloat(int[] index,
float value)
Set the array element at index to the specified float value. |
void |
setInt(int[] index,
int value)
Set the array element at index to the specified int value. |
void |
setLong(int[] index,
long value)
Set the array element at index to the specified long value. |
void |
setShort(int[] index,
short value)
Set the array element at index to the specified short value. |
java.lang.Object |
toArray()
Returns a new array containing all of the elements in this MultiArray. |
java.lang.Object |
toArray(java.lang.Object dst,
int[] origin,
int[] shape)
Returns an array containing elements of this MultiArray specified by origin and shape, possibly converting the component type. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public final java.lang.Object jla
| Constructor Detail |
public ArrayMultiArray(java.lang.Object aro)
aro - a (multi-dimensional) array of primitives.
public ArrayMultiArray(java.lang.Class componentType,
int[] dimensions)
componentType - Class of the primitives or objects to
be contained.dimensions - the shape of the MultiArray.
dimensions.length determines the rank of the new MultiArray.
public ArrayMultiArray(MultiArray ma)
throws java.io.IOException
Create a new MultiArray with the same componentType and shape as the argument
ma - the MultiArray to copy.| Method Detail |
public java.lang.Class getComponentType()
getComponentType in interface MultiArrayInfoMultiArrayInfo.getComponentType()public int getRank()
MultiArrayInfogetRank in interface MultiArrayInfoMultiArrayInfo.getRank()public int[] getLengths()
getLengths in interface MultiArrayInfoMultiArrayInfo.getLengths()public boolean isUnlimited()
true if and only if the effective dimension
lengths can change. Always returns false for this class.isUnlimited in interface MultiArrayInfofalseMultiArrayInfo.isUnlimited()public boolean isScalar()
isScalar in interface MultiArrayInfoMultiArrayInfo.isScalar()public java.lang.Object get(int[] index)
Accessorget in interface AccessorAccessor.get(int[])public boolean getBoolean(int[] index)
AccessorgetBoolean in interface AccessorAccessor.getBoolean(int[])public char getChar(int[] index)
AccessorgetChar in interface AccessorAccessor.getChar(int[])public byte getByte(int[] index)
AccessorgetByte in interface AccessorAccessor.getByte(int[])public short getShort(int[] index)
AccessorgetShort in interface AccessorAccessor.getShort(int[])public int getInt(int[] index)
AccessorgetInt in interface AccessorAccessor.getInt(int[])public long getLong(int[] index)
AccessorgetLong in interface AccessorAccessor.getLong(int[])public float getFloat(int[] index)
AccessorgetFloat in interface AccessorAccessor.getFloat(int[])public double getDouble(int[] index)
AccessorgetDouble in interface AccessorAccessor.getDouble(int[])
public void set(int[] index,
java.lang.Object value)
Accessorset in interface AccessorAccessor.set(int[], java.lang.Object)
public void setBoolean(int[] index,
boolean value)
AccessorsetBoolean in interface AccessorAccessor.setBoolean(int[], boolean)
public void setChar(int[] index,
char value)
AccessorsetChar in interface AccessorAccessor.setChar(int[], char)
public void setByte(int[] index,
byte value)
AccessorsetByte in interface AccessorAccessor.setByte(int[], byte)
public void setShort(int[] index,
short value)
AccessorsetShort in interface AccessorAccessor.setShort(int[], short)
public void setInt(int[] index,
int value)
AccessorsetInt in interface AccessorAccessor.setInt(int[], int)
public void setLong(int[] index,
long value)
AccessorsetLong in interface AccessorAccessor.setLong(int[], long)
public void setFloat(int[] index,
float value)
AccessorsetFloat in interface AccessorAccessor.setFloat(int[], float)
public void setDouble(int[] index,
double value)
AccessorsetDouble in interface AccessorAccessor.setDouble(int[], double)
public MultiArray copyout(int[] origin,
int[] shape)
AccessorIt is easier to implement than to specify :-).
The main reason to implement this instead of using the equivalent proxy is for remote or file access.
assert(origin[ii] + shape[ii] <= lengths[ii]);
copyout in interface AccessorAccessor.copyout(int[], int[])
public void copyin(int[] origin,
MultiArray data)
throws java.io.IOException
AccessorHopefully this member can be optimized in various situations.
assert(origin[ii] + (source.getLengths())[ii]
<= (getLengths())[ii]);
copyin in interface AccessorAccessor.copyin(int[], ucar.multiarray.MultiArray)public java.lang.Object toArray()
AccessorThis method acts as bridge between array-based and MultiArray-based APIs.
This method is functionally equivalent to
Object anArray = Array.newInstance(getComponentType(), 1); int [] origin = new int[getRank()] int [] shape = getDimensions(); return toArray(anArray, origin, shape);
toArray in interface AccessorAccessor.toArray()
public java.lang.Object toArray(java.lang.Object dst,
int[] origin,
int[] shape)
AccessorThe anArray argument should be an array. If it is large enough to contain the output, it is used and no new storage is allocated. Otherwise, new storage is allocated with the same component type as the argument, and the data is copied into it.
This method acts as bridge between array-based and MultiArray-based APIs.
This method is similar to copyout(origin, shape).toArray(), but avoids a copy operation and (potentially) an allocation.
NOTE: Implementation of type conversion is deferred until
JDK 1.2. Currently, the componentType of anArray
must be the same as this
toArray in interface AccessorAccessor.toArray()public java.lang.Object get(int index)
indexpublic java.lang.Object getLeaf(int[] index)
public static void main(java.lang.String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||