edu.neu.ccs.util
Class FloatArray

java.lang.Object
  extended byedu.neu.ccs.util.FloatArray

public class FloatArray
extends Object

Class FloatArray encapsulates utilities for arrays of float.

Class FloatArray cannot be instantiated.

Since:
2.3
Version:
2.4.0

Constructor Summary
private FloatArray()
          Private constructor to prevent instantiation.
 
Method Summary
static boolean checkArray(float[][] array, int S)
          Returns true if and only if the data array is non-null and has S float numbers in each row.
static boolean checkArrayPair(float[][] array1, float[][] array2, int S)
          Returns true if and only if both data arrays are non-null, have the same length N, and have S float numbers in each row.
static float[] deepclone(float[] data)
          Returns a deep clone of an array float[].
static float[][] deepclone(float[][] data)
          Returns a deep clone of an array float[][].
static float[][] deepmerge(float[][] array1, float[][] array2)
          Returns a deep merge of the given arrays of float[][].
static float[] deepmerge(float[] array1, float[] array2)
          Returns a deep merge of the given arrays of float[].
static boolean equals(float[][] array1, float[][] array2)
          Returns true if the two arrays are both null or are both non-null and have the same structure and data.
static boolean equals(float[] array1, float[] array2)
          Returns true if the two arrays are both null or are both non-null and have the same size and data.
static float[] fromPoint2D(Point2D point)
          Returns a new size 2 float[] corresponding to the given Point2D.
static float[][] fromPoint2D(Point2D[] points)
          Returns a new float[][] of size N-by-2 corresponding to the given Point2D[] of size N.
static Point2D toPoint2D(float[] array)
          Returns a new Point2D corresponding to the given float[] provided the parameter is non-null and of size 2.
static Point2D[] toPoint2D(float[][] array)
          Returns a new Point2D[] of size N corresponding to the given float[][] of size N-by-2.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FloatArray

private FloatArray()
Private constructor to prevent instantiation.

Method Detail

deepclone

public static float[] deepclone(float[] data)

Returns a deep clone of an array float[].

Returns null if the given data is null.

Parameters:
data - the array to deep clone
Returns:
the deep clone

deepclone

public static float[][] deepclone(float[][] data)

Returns a deep clone of an array float[][].

Returns null if the given data is null.

Parameters:
data - the array to deep clone
Returns:
the deep clone

deepmerge

public static float[] deepmerge(float[] array1,
                                float[] array2)

Returns a deep merge of the given arrays of float[]. This means:

Parameters:
array1 - the first array to deep merge
array2 - the second array to deep merge
Returns:
the deep merge of array1 and array2

deepmerge

public static float[][] deepmerge(float[][] array1,
                                  float[][] array2)

Returns a deep merge of the given arrays of float[][]. This means:

Parameters:
array1 - the first array to deep merge
array2 - the second array to deep merge
Returns:
the deep merge of array1 and array2

checkArray

public static boolean checkArray(float[][] array,
                                 int S)
Returns true if and only if the data array is non-null and has S float numbers in each row.

Parameters:
array - the array to check
S - the desired size of each row
Returns:
true if and only if array has the form float[N][S] for some N

checkArrayPair

public static boolean checkArrayPair(float[][] array1,
                                     float[][] array2,
                                     int S)
Returns true if and only if both data arrays are non-null, have the same length N, and have S float numbers in each row.

Parameters:
array1 - the first array to check
array2 - the second array to check
S - the desired size of each row
Returns:
true if and only if both arrays have the form float[N][S] for some N

equals

public static boolean equals(float[] array1,
                             float[] array2)
Returns true if the two arrays are both null or are both non-null and have the same size and data.

Parameters:
array1 - the first array
array2 - the second array

equals

public static boolean equals(float[][] array1,
                             float[][] array2)
Returns true if the two arrays are both null or are both non-null and have the same structure and data.

Parameters:
array1 - the first array
array2 - the second array

fromPoint2D

public static float[] fromPoint2D(Point2D point)

Returns a new size 2 float[] corresponding to the given Point2D.

Returns null if the parameter is null.

Parameters:
point - the point to convert

fromPoint2D

public static float[][] fromPoint2D(Point2D[] points)

Returns a new float[][] of size N-by-2 corresponding to the given Point2D[] of size N.

Returns null if the parameter is null.

Parameters:
points - the points to convert

toPoint2D

public static Point2D toPoint2D(float[] array)

Returns a new Point2D corresponding to the given float[] provided the parameter is non-null and of size 2.

Returns null if the preconditions are not met.

Parameters:
array - to array to convert

toPoint2D

public static Point2D[] toPoint2D(float[][] array)

Returns a new Point2D[] of size N corresponding to the given float[][] of size N-by-2.

Returns null if the parameter is null.

Parameters:
array - to array to convert