public class ArrayFuncs extends java.lang.Object implements PrimitiveInfo
BOOLEAN_INDEX, BYTE_INDEX, CHAR_INDEX, classes, DOUBLE_INDEX, FIRST_NUMERIC, FLOAT_INDEX, INT_INDEX, isNumeric, LAST_NUMERIC, LONG_INDEX, SHORT_INDEX, sizes, suffixes, types
Constructor and Description |
---|
ArrayFuncs() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
arrayDescription(java.lang.Object o)
Generate a description of an array (presumed rectangular).
|
static boolean |
arrayEquals(java.lang.Object x,
java.lang.Object y)
Are two objects equal? Arrays have the standard object equals
method which only returns true if the two object are the same.
|
static boolean |
arrayEquals(java.lang.Object x,
java.lang.Object y,
double tolf,
double told)
Are two objects equal? Arrays have the standard object equals
method which only returns true if the two object are the same.
|
static long |
computeLSize(java.lang.Object o) |
static int |
computeSize(java.lang.Object o)
Deprecated.
May silently underestimate the size
if the size > 2 GB.
|
static java.lang.Object |
convertArray(java.lang.Object array,
java.lang.Class newType)
Convert an array to a specified type.
|
static java.lang.Object |
convertArray(java.lang.Object array,
java.lang.Class newType,
boolean reuse)
Convert an array to a specified type.
|
static void |
copyArray(java.lang.Object original,
java.lang.Object copy)
Copy one array into another.
|
static void |
copyInto(java.lang.Object array,
java.lang.Object mimic)
Copy an array into an array of a different type.
|
static java.lang.Object |
curl(java.lang.Object input,
int[] dimens)
Curl an input array up into a multi-dimensional array.
|
static java.lang.Object |
deepClone(java.lang.Object o)
Try to create a deep clone of an Array or a standard clone of a scalar.
|
protected static int |
doCurl(java.lang.Object input,
java.lang.Object output,
int[] dimens,
int offset)
Do the curling of the 1-d to multi-d array.
|
protected static int |
doFlatten(java.lang.Object input,
java.lang.Object output,
int offset)
This routine does the actually flattening of multi-dimensional
arrays.
|
static boolean |
doubleArrayEquals(double[] x,
double[] y,
double tol)
Compare two double arrays using a given tolerance
|
static void |
dumpArray(java.io.PrintStream p,
java.lang.Object arr)
Dump an array on the given print steam
|
static void |
examinePrimitiveArray(java.lang.Object o)
Examine the structure of an array in detail.
|
static java.lang.Object |
flatten(java.lang.Object input)
Given an array of arbitrary dimensionality return
the array flattened into a single dimension.
|
static boolean |
floatArrayEquals(float[] x,
float[] y,
float tol)
Compare two float arrays using a given tolerance
|
static java.lang.Object |
generateArray(java.lang.Class baseType,
int[] dims)
Create an array and populate it with a test pattern.
|
static java.lang.Object |
genericClone(java.lang.Object o)
Clone an Object if possible.
|
static java.lang.Object |
getBaseArray(java.lang.Object o)
This routine returns the base array of a multi-dimensional
array.
|
static java.lang.Class |
getBaseClass(java.lang.Object o)
This routine returns the base class of an object.
|
static int |
getBaseLength(java.lang.Object o)
This routine returns the size of the base element of an array.
|
static int[] |
getDimensions(java.lang.Object o)
Find the dimensions of an object.
|
static java.lang.Object |
mimicArray(java.lang.Object array,
java.lang.Class newType)
Create an array of a type given by new type with
the dimensionality given in array.
|
static int |
nElements(java.lang.Object o)
Deprecated.
May silently underestimate
size if number is > 2 G.
|
static java.lang.Object |
newInstance(java.lang.Class cl,
int dim)
Allocate an array dynamically.
|
static java.lang.Object |
newInstance(java.lang.Class cl,
int[] dims)
Allocate an array dynamically.
|
static long |
nLElements(java.lang.Object o)
Deprecated.
May silently underestimate
size if number is > 2 G.
|
static byte |
testPattern(java.lang.Object o,
byte start)
Just create a simple pattern cycling through valid byte values.
|
public static int computeSize(java.lang.Object o)
o
- The object whose size is desired.public static long computeLSize(java.lang.Object o)
public static int nElements(java.lang.Object o)
public static long nLElements(java.lang.Object o)
public static java.lang.Object deepClone(java.lang.Object o)
o
- The object to be copied.public static java.lang.Object genericClone(java.lang.Object o)
o
- The object to be cloned.public static void copyArray(java.lang.Object original, java.lang.Object copy)
original
- The array to be copied.copy
- The array to be copied into. This
array must already be fully allocated.public static int[] getDimensions(java.lang.Object o)
o
- The object to get the dimensions of.public static java.lang.Object getBaseArray(java.lang.Object o)
public static java.lang.Class getBaseClass(java.lang.Object o)
public static int getBaseLength(java.lang.Object o)
o
- The array object whose base length is desired.public static java.lang.Object generateArray(java.lang.Class baseType, int[] dims)
baseType
- The base type of the array. This is expected to
be a numeric type, but this is not checked.dims
- The desired dimensions.public static byte testPattern(java.lang.Object o, byte start)
o
- The array in which the test pattern is to be set.start
- The value for the first element.public static java.lang.String arrayDescription(java.lang.Object o)
o
- The array to be described.public static void examinePrimitiveArray(java.lang.Object o)
o
- The array to be examined.public static java.lang.Object flatten(java.lang.Object input)
input
- The input array.protected static int doFlatten(java.lang.Object input, java.lang.Object output, int offset)
input
- The input array to be flattened.output
- The flattened array.offset
- The current offset within the output array.public static java.lang.Object curl(java.lang.Object input, int[] dimens)
input
- The one dimensional array to be curled.dimens
- The desired dimensionsprotected static int doCurl(java.lang.Object input, java.lang.Object output, int[] dimens, int offset)
input
- The 1-d array to be curled.output
- The multi-dimensional array to be filled.dimens
- The desired output dimensions.offset
- The current offset in the input array.public static java.lang.Object mimicArray(java.lang.Object array, java.lang.Class newType)
array
- A possibly multidimensional array to be converted.newType
- The desired output type. This should be one of the
class descriptors for primitive numeric data, e.g., double.type.public static java.lang.Object convertArray(java.lang.Object array, java.lang.Class newType, boolean reuse)
array
- A possibly multidimensional array to be converted.newType
- The desired output type. This should be one of the
class descriptors for primitive numeric data, e.g., double.type.reuse
- If set, and the requested type is the same as the
original, then the original is returned.public static java.lang.Object convertArray(java.lang.Object array, java.lang.Class newType)
array
- A possibly multidimensional array to be converted.newType
- The desired output type. This should be one of the
class descriptors for primitive numeric data, e.g., double.type.public static void copyInto(java.lang.Object array, java.lang.Object mimic)
array
- The original array.mimic
- The array mimicking the original.public static java.lang.Object newInstance(java.lang.Class cl, int dim)
cl
- The class of the array.dim
- The dimension of the array.An
- OutOfMemoryError if insufficient space is available.public static java.lang.Object newInstance(java.lang.Class cl, int[] dims)
cl
- The class of the array.dims
- The dimensions of the array.An
- OutOfMemoryError if insufficient space is available.public static boolean arrayEquals(java.lang.Object x, java.lang.Object y)
public static boolean arrayEquals(java.lang.Object x, java.lang.Object y, double tolf, double told)
public static boolean doubleArrayEquals(double[] x, double[] y, double tol)
public static boolean floatArrayEquals(float[] x, float[] y, float tol)
public static void dumpArray(java.io.PrintStream p, java.lang.Object arr)