|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IMultiArray
Yet Another Container (YAC) for multidimensional arrays used in seismic analysis and processing. This interface attempts to re-use concepts in existing array packages, such as JBLAS (http://math.nist.gov/javanumerics/blas.html) and the NCAR/UCAR NetCDF packages (http://www.unidata.ucar.edu/software/netcdf-java). This interface is initially designed for simplicity of usage with both Java and native methods, especially Fortran. The Java Array utilities and CSM Array utilities can be used with the underlying arrays.
The main design targets are:
Simple usage: Call a Fortran native method on a 2D slice of a 3D array:
// Allocate a 3D array int n1=512; n2=256; n3=128; IMultiArray a = MultiArray.float3d( n1, n2, n3 ); // Get the 1D underlying storage for this array float [] xa = a.floats(); int[] position = new int[3]; // Loop over the 3rd dimension for (int k=0; k<n3; k++) { // Set the position to the start of this 2D plane position[0] = 0; position[1] = 0; position[2] = k; // Get the index of this 2D plane and call a native method int index = a.index(position) callNativeMethod2D( n1, n2, a[index] ); }
More complex usage in Java:
// Allocate 1D array that will be shaped to 3D int lengths[] = {512,256,128}; float x[512*256*128]; // Allocate an empty MultiArray IMultiArray a = new MultiArray(); // Use methods to set the type and shape a.setDataType( float.class ); a.setDimensions( 3 ); a.setShape( lengths ); // Assign our 1D array to this MultiArray and then zero a.setArray( x ); a.clear(); // Get the 1D vector for this MultiArray x = getFloats(); // Get the index of the first value and set to 1.0 int position[] = {0,0,0}; int ix = a.index( position ); x[ix] = 1.0; // // get a range triplet for the traversing the first "trace" int[] range = a.range( position, 1, 1, a.getLength(1), 1 ); // Loop and set values for the first trace for (int ix=range[0],i=1; ix<range[1]; ix+=range[2],i++) x[ix] = (float)i; // // Loop over all values in the 3D array for (int k=1; k<=a.getLength(3); k++ ) { position[2] = k; for (int j=1; j<=a.getLength(2); j++) { position[1] = j; position[0] = 1; // Get a range triplet for the current trace int[] range = a.range(position,1,1,a.getLength(1),1); int i = 0; // Loop and set values for this trace for (ix=range[0]; ix<range[1]; ix+=range[2]) { i++; x[ix] = (float)(i*j*k); } } }
Method Summary | ||
---|---|---|
byte[] |
bytes()
|
|
IMultiArray |
clone()
|
|
double[] |
doubles()
|
|
float[] |
floats()
|
|
int |
getDimensions()
Return the number of dimensions in this MultiArray |
|
void |
getFrame(byte[][] buf,
int[] position)
|
|
void |
getFrame(double[][] buf,
int[] position)
|
|
void |
getFrame(float[][] buf,
int[] position)
|
|
void |
getFrame(int[][] buf,
int[] position)
|
|
void |
getFrame(long[][] buf,
int[] position)
|
|
void |
getFrame(short[][] buf,
int[] position)
|
|
|
getFrame(T[][] buf,
int[] position)
Place a 2-dimensional array of values into the multiarray |
|
int |
getLength(int index)
Return the length of a particular dimension |
|
int |
getOffset()
Return the zero-based offset within the underlying storage for this array |
|
int[] |
getShape()
Return the length of each dimension in this MultiArray |
|
void |
getTrace(byte[] buf,
int[] position)
|
|
void |
getTrace(double[] buf,
int[] position)
|
|
void |
getTrace(float[] buf,
int[] position)
|
|
void |
getTrace(int[] buf,
int[] position)
|
|
void |
getTrace(long[] buf,
int[] position)
|
|
void |
getTrace(short[] buf,
int[] position)
|
|
|
getTrace(T[] buf,
int[] position)
Return a 1-dimensional array of values from the multiarray |
|
int |
index(int[] position)
Return the index in the underlying storage of the data at a particular position in the MultiArray |
|
int |
index(int[] position,
int element)
Return the index in the underlying storage of an element at a particular position in the MultiArray. |
|
int |
indexFortran(int[] position)
Return the index in the underlying storage of the data at a particular position in the MultiArray. |
|
int |
indexFortran(int[] position,
int element)
Return the index in the underlying storage of an element at a particular position in the MultiArray. |
|
int[] |
ints()
|
|
long[] |
longs()
|
|
|
objects()
Return the underlying storage for this MultiArray as a 1D array |
|
void |
putFrame(byte[][] buf,
int[] position)
|
|
void |
putFrame(double[][] buf,
int[] position)
|
|
void |
putFrame(float[][] buf,
int[] position)
|
|
void |
putFrame(int[][] buf,
int[] position)
|
|
void |
putFrame(long[][] buf,
int[] position)
|
|
void |
putFrame(short[][] buf,
int[] position)
|
|
|
putFrame(T[][] buf,
int[] position)
Place a 2-dimensional array of values into the multiarray |
|
void |
putTrace(byte[] buf,
int[] position)
|
|
void |
putTrace(double[] buf,
int[] position)
|
|
void |
putTrace(float[] buf,
int[] position)
|
|
void |
putTrace(int[] buf,
int[] position)
|
|
void |
putTrace(long[] buf,
int[] position)
|
|
void |
putTrace(short[] buf,
int[] position)
|
|
|
putTrace(T[] buf,
int[] position)
Place a 1-dimensional array of values into the multiarray |
|
int[] |
range(int[] position,
int dimension)
Return a zero-based index triplet defining start,end,increment that will traverse a specified dimension for this MultiArray. |
|
int[] |
range(int[] position,
int dimension,
int start,
int end,
int increment)
Return a zero-based index triplet defining start,end,increment that can be used to access the elements of the underlying 1D array storage for this MultiArray. |
|
int[] |
range(int[] position,
int dimension,
int start,
int end,
int increment,
int element)
Return a zero-based index triplet defining start,end,increment that can be used to access individual elements of the underlying 1D array storage for this MultiArray. |
|
int[] |
rangeFortran(int[] position,
int dimension)
Return a zero-based index triplet defining start,end,increment that will traverse a specified dimension for this MultiArray. |
|
int[] |
rangeFortran(int[] position,
int dimension,
int start,
int end,
int increment)
Return a Fortran index triplet defining start,end,increment that can be used to access the elements of the underlying 1D array storage for this MultiArray. |
|
int[] |
rangeFortran(int[] position,
int dimension,
int start,
int end,
int increment,
int element)
Return a Fortran style index triplet defining start,end,increment that can be used to access individual elements of the underlying 1D array storage for this MultiArray. |
|
void |
setArray(byte[] buf)
|
|
void |
setArray(double[] buf)
|
|
void |
setArray(float[] buf)
|
|
void |
setArray(int[] buf)
|
|
void |
setArray(long[] buf)
|
|
void |
setArray(short[] buf)
|
|
|
setArray(T[] buf)
Provide the array that is used for underlying storage The "object" version is a generic method that handles arbitrary objects The rest of the methods are for primitive types |
|
void |
setClassType(java.lang.Class classType)
Set the class type of this MultiArray |
|
void |
setDimensions(int ndim)
Set the number of dimensions for this MultiArray |
|
void |
setElementCount(int elementCount)
Set the element count for this MultiArray |
|
void |
setOffset(int offset)
Set the zero-based offset within the underlying storage for this array |
|
void |
setShape(int[] lengths)
Set the shape of this MultiArray, in Fortran style with the "fast" dimension first |
|
short[] |
shorts()
|
|
void |
transpose(TransposeType type)
Transpose the array |
Method Detail |
---|
byte[] bytes()
IMultiArray clone()
double[] doubles()
float[] floats()
int getDimensions()
void getFrame(byte[][] buf, int[] position)
void getFrame(double[][] buf, int[] position)
void getFrame(float[][] buf, int[] position)
void getFrame(int[][] buf, int[] position)
void getFrame(long[][] buf, int[] position)
void getFrame(short[][] buf, int[] position)
<T> void getFrame(T[][] buf, int[] position)
buf
- array to be placed into the multiarrayposition
- zero-based index location in fortran orderint getLength(int index)
index
- the index of the dimension whose length will be returned
int getOffset()
int[] getShape()
void getTrace(byte[] buf, int[] position)
void getTrace(double[] buf, int[] position)
void getTrace(float[] buf, int[] position)
void getTrace(int[] buf, int[] position)
void getTrace(long[] buf, int[] position)
void getTrace(short[] buf, int[] position)
<T> void getTrace(T[] buf, int[] position)
buf
- array to receive data from the multiarrayposition
- zero-based index location in fortran orderint index(int[] position)
position
- position of the sample to be accessed using zero-based indices
int index(int[] position, int element)
position
- position of the sample to be accessed using zero-based indiceselement
- index of the "sample" "element" that will be accessed
int indexFortran(int[] position)
position
- position of the sample to be accessed using Fortran indices
int indexFortran(int[] position, int element)
position
- position of the sample to be accessed using Fortran indiceselement
- index of the "sample" "element" that will be accessed
int[] ints()
long[] longs()
<T> T[] objects()
void putFrame(byte[][] buf, int[] position)
void putFrame(double[][] buf, int[] position)
void putFrame(float[][] buf, int[] position)
void putFrame(int[][] buf, int[] position)
void putFrame(long[][] buf, int[] position)
void putFrame(short[][] buf, int[] position)
<T> void putFrame(T[][] buf, int[] position)
buf
- array to be placed into the multiarrayposition
- zero-based index location in fortran ordervoid putTrace(byte[] buf, int[] position)
void putTrace(double[] buf, int[] position)
void putTrace(float[] buf, int[] position)
void putTrace(int[] buf, int[] position)
void putTrace(long[] buf, int[] position)
void putTrace(short[] buf, int[] position)
<T> void putTrace(T[] buf, int[] position)
buf
- array to be placed into the multiarrayposition
- zero-based index location in fortran orderint[] range(int[] position, int dimension)
position
- starting position in Fortran style indexingdimension
- the dimension that will be traversed
int[] range(int[] position, int dimension, int start, int end, int increment)
position
- starting position in Fortran style indexingdimension
- the dimension that will be traversedstart
- start index along the requested dimensionend
- ending indexincrement
- index increment
int[] range(int[] position, int dimension, int start, int end, int increment, int element)
position
- starting position in Fortran style indexingdimension
- the dimension that will be traversedstart
- start index along the requested dimensionend
- ending indexincrement
- index incrementelement
- the index of the element that will be accessed for the range selection
int[] rangeFortran(int[] position, int dimension)
position
- starting position in Fortran style indexingdimension
- the dimension that will be traversed
int[] rangeFortran(int[] position, int dimension, int start, int end, int increment)
position
- starting position in Fortran style indexingdimension
- the dimension that will be traversedstart
- start index along the requested dimensionend
- ending indexincrement
- index increment
int[] rangeFortran(int[] position, int dimension, int start, int end, int increment, int element)
position
- starting position in Fortran style indexingdimension
- the dimension that will be traversedstart
- start index along the requested dimensionend
- ending indexincrement
- index incrementelement
- the index of the element that will be accessed for the range selection
void setArray(byte[] buf)
void setArray(double[] buf)
void setArray(float[] buf)
void setArray(int[] buf)
void setArray(long[] buf)
void setArray(short[] buf)
<T> void setArray(T[] buf)
buf
- array that is used for underlying storagevoid setClassType(java.lang.Class classType)
classType
- - the class type for this arrayvoid setDimensions(int ndim)
ndim
- number of dimensionsvoid setElementCount(int elementCount)
elementCount
- - the number of "elements" per "sample"void setOffset(int offset)
offset
- zero based offset to the start of this arrayvoid setShape(int[] lengths)
lengths
- length of each dimensionshort[] shorts()
void transpose(TransposeType type)
type
- the type of transpose to apply
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |