java.lang.Object | +--LinearArray
Class LinearArray provides several static operation on linear arrays of double. Methods add(), subtract() multiply(), merge() and clone() return a new array, while methods fillRandomData(), sortSelection() and sortBubble() modify the array that is passed as an argument to them.
| Constructor Summary | |
LinearArray()
|
|
| Method Summary | |
static double[] |
add(double[] a1,
double[] a2)
Implements linear array addition. |
static double[] |
clone(double[] original)
Creates an exact copy of an array. |
static void |
fillRandomData(double[] a)
Fills a linear array with radmon data in the range [0..1). |
static int |
maxLocationFrom(double[] a,
int start)
Starting from a specified position of an array, it identifies the location of the maximum element of the array. |
static double[] |
merge(double[] a1,
double[] a2)
Merges two sorted arrays. |
static int |
minLocationFrom(double[] a,
int start)
Starting from a specified position of an array, it identifies the location of the minimum element of the array. |
static double[] |
multiply(double factor,
double[] a)
Implements scalar linear array multiplication. |
static void |
printH(double[] a)
Prints the elements of an array, all at the same line. |
static void |
printV(double[] a)
Prints the elements of an array, each at a different line. |
static void |
sortBubble(double[] a)
Sorts an array in O(n^2) time by using the "Bubble-sort" method. |
static void |
sortSelection(double[] a)
Sorts an array in O(n^2) time by using the "selection-sort" method. |
static double[] |
subtract(double[] a1,
double[] a2)
Implements linear array subtraction. |
| Methods inherited from class java.lang.Object |
|
| Constructor Detail |
public LinearArray()
| Method Detail |
public static double[] add(double[] a1,
double[] a2)
a1 - The first array to be added. It cannot be NULL.a2 - The second array to be added. It cannot be NULL.public static double[] clone(double[] original)
a - The array to be copied. It cannot be NULL.public static void fillRandomData(double[] a)
a - The array to be filled. It cannot be NULL.
public static int maxLocationFrom(double[] a,
int start)
a - The array to be searched.start - The search for the maximum starts from this position.
public static double[] merge(double[] a1,
double[] a2)
a1 - The first of the two arrays to be merged. It must be sorted and cannot be NULL.a2 - The second of the two arrays to be merged. It must be sorted and cannot be NULL.
public static int minLocationFrom(double[] a,
int start)
a - The array to be searched.start - The search for the minimum starts from this position.
public static double[] multiply(double factor,
double[] a)
factor - The factor of the multiplication.a - The array to be multiplied. It cannot be NULL.public static void printH(double[] a)
a - The array of which the ellements are printed.public static void printV(double[] a)
a - The array of which the ellements are printed.public static void sortBubble(double[] a)
a - The array to be sorted. It cannot be NULL.public static void sortSelection(double[] a)
a - The array to be sorted. It cannot be NULL.
public static double[] subtract(double[] a1,
double[] a2)
a1 - The array from which we subtract. It cannot be NULL.a2 - The array to be subtracted. It cannot be NULL.