public class FloatArrayNDim
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
Modified by: Joseph A. Huwaldt
Modifier and Type | Field and Description |
---|---|
protected float[] |
data
The 1D array that contains all the data strung out end-to-end.
|
protected int |
numDims
e
The number of dimensions that this array has.
|
protected int |
numElements
The total number of data values or elements.
|
protected int[] |
sizes
The number of elements per dimension.
|
Modifier | Constructor and Description |
---|---|
protected |
FloatArrayNDim()
Do not allow the default constructor to be used for instantiation.
|
|
FloatArrayNDim(float[] srcArray)
Creates a FloatArrayNDim object containing the values
stored in a given 1D Java array.
|
|
FloatArrayNDim(float[][] srcArray)
Creates a FloatArrayNDim object containing the values
stored in a given 2D Java array.
|
|
FloatArrayNDim(float[][][] srcArray)
Creates a FloatArrayNDim object containing the values
stored in a given 3D Java array.
|
|
FloatArrayNDim(int[] dimensionSizes)
Creates a FloatArrayNDim object with all the array elements
set to zero.
|
|
FloatArrayNDim(int[] dimensionSizes,
float[] flatArray)
Creates a FloatArrayNDim object with the specified dimensions with the data
set by the specified 1D array of flattened array data.
|
Modifier and Type | Method and Description |
---|---|
static void |
arraycopy(float[] srcArray,
int srcPos,
FloatArrayNDim dstArray,
int[] dstPos,
int length)
Copy a given Java array into a FloatArrayNDim array.
|
static void |
arraycopy(FloatArrayNDim srcArray,
int[] srcPos,
float[] dstArray,
int dstPos,
int length)
Copy a given FloatArrayNDim array into a Java array.
|
java.lang.Object |
clone()
Make a copy of this n-dimensional array.
|
int |
dimensions()
Returns the number of dimensions in this n-dimensional array.
|
float[] |
flatten()
Return a copy of all the data in this multi-dimensional array as a 1D Java array
with all the data strung out end-to-end.
|
float |
get(int position)
Get the value of a particular element in the 1-dimensional
array.
|
float |
get(int[] position)
Get the value of a particular element in the n dimensional
array.
|
protected int |
getOffset(int[] position)
Returns the offset into the 1D data array of the element
indicated by the index into the nD array.
|
int |
length(int dimension)
Returns the length of a given dimension of the array.
|
void |
set(int[] position,
float value)
Set the value of a particular element in the n dimensional
array.
|
void |
set(int position,
float value)
Set the value of a particular element in the 1-dimensional array.
|
void |
setAll(float value)
Set all the values stored in this array to the given
value.
|
int |
size()
Returns the overall number of elements in the array.
|
protected int numDims
protected int numElements
protected int[] sizes
protected float[] data
protected FloatArrayNDim()
public FloatArrayNDim(int[] dimensionSizes)
dimensionSizes
- Array indicating the number of elements in each dimension
of the array.public FloatArrayNDim(int[] dimensionSizes, float[] flatArray)
dimensionSizes
- Array indicating the number of elements in each dimension
of the array.flatArray
- The data for this n-dimensional array flattened into
a 1D array. The number of elements in this array must equal the number
indicated by the dimensionSizes.public FloatArrayNDim(float[] srcArray)
srcArray
- A 1D Java array to be converted into a floatArrayNDim
object.public FloatArrayNDim(float[][] srcArray)
srcArray
- A 2D Java array to be converted into a floatArrayNDim
object. The input array must be "square". This means
that each row of the array must have the same number
of columns in it.public FloatArrayNDim(float[][][] srcArray)
srcArray
- A 3D Java array to be converted into a FloatArrayNDim
object. The input array must be "square". This means
that every every row of every rank must have the same
number of columns.public void set(int[] position, float value)
position
- The index into the array of the value to be
set. For example, for a 3D array the position could be
{ 0, 3, 2 } which would translate to [0][3][2] in a
standard Java array.value
- The value to be stored in the array.public void set(int position, float value)
position
- The index into the 1-D array of the value to be
set.value
- The value to be stored in the array.public float get(int[] position)
position
- The index into the array of the value to be
returned. For example, for a 3D array the position could be
{ 0, 3, 2 } which would translate to [0][3][2] in a
standard Java array.public float get(int position)
position
- The index into the 1D array of the value to be
returned.public float[] flatten()
public void setAll(float value)
value
- Value to place in every element of the array.public int dimensions()
public int length(int dimension)
dimension
- The dimension to return the length of.public int size()
public static void arraycopy(float[] srcArray, int srcPos, FloatArrayNDim dstArray, int[] dstPos, int length)
srcArray
- The source array to copy from.srcPos
- Position in the source array to start copying
from.dstArray
- The destenation FloatArrayNDim to copy into.dstPos
- Position in the nDim array to copy to.length
- The number of array elements to copy.public static void arraycopy(FloatArrayNDim srcArray, int[] srcPos, float[] dstArray, int dstPos, int length)
srcArray
- The source FloatArrayNDim array to copy from.srcPos
- Position in the source array to start copying
from.dstArray
- The destenation Java array to copy into.dstPos
- Position in the destination array to copy to.length
- The number of array elements to copy.public java.lang.Object clone()
clone
in class java.lang.Object
protected final int getOffset(int[] position)
position
- The index into the nD array.