Class LinearArray

java.lang.Object
  extended byLinearArray

public class LinearArray
extends java.lang.Object

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.

Version:
(11 April 2002)
Author:
(Antonios Symvonis)

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 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 double[] subtract(double[] a1, double[] a2)
          Implements linear array subtraction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinearArray

public LinearArray()
Method Detail

add

public static double[] add(double[] a1,
                           double[] a2)
Implements linear array addition. The two arrays to be added must be of equal length.

Parameters:
a1 - The first array to be added. It cannot be NULL.
a2 - The second array to be added. It cannot be NULL.
Returns:
The sum of the argument arrays.

clone

public static double[] clone(double[] original)
Creates an exact copy of an array.

Returns:
An exact copy of the argument array.

fillRandomData

public static void fillRandomData(double[] a)
Fills a linear array with radmon data in the range [0..1). The random numbers have precision of 2 decimal digits.

Parameters:
a - The array to be filled. It cannot be NULL.
Returns:
The result of the multiplication.

maxLocationFrom

public 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. The specified position is included in the search.

Parameters:
a - The array to be searched.
start - The search for the maximum starts from this position.
Returns:
The index of the maximum element.

minLocationFrom

public 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. The specified position is included in the search.

Parameters:
a - The array to be searched.
start - The search for the minimum starts from this position.
Returns:
The index of the minimum element.

multiply

public static double[] multiply(double factor,
                                double[] a)
Implements scalar linear array multiplication.

Parameters:
factor - The factor of the multiplication.
a - The array to be multiplied. It cannot be NULL.
Returns:
The result of the multiplication.

printH

public static void printH(double[] a)
Prints the elements of an array, all at the same line.

Parameters:
a - The array of which the ellements are printed.

printV

public static void printV(double[] a)
Prints the elements of an array, each at a different line.

Parameters:
a - The array of which the ellements are printed.

subtract

public static double[] subtract(double[] a1,
                                double[] a2)
Implements linear array subtraction. The two arrays which participate must be of equal length.

Parameters:
a1 - The array from which we subtract. It cannot be NULL.
a2 - The array to be subtracted. It cannot be NULL.
Returns:
The result of the subtraction.