All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class JSci.maths.ArrayMath

java.lang.Object
   |
   +----JSci.maths.AbstractMath
           |
           +----JSci.maths.ArrayMath

public final class ArrayMath
extends AbstractMath
Arrays are faster than object so this class is there to take full advantage of arrays without encapsulation. All methods here are safe, that is, they create copies of arrays whenever necessary. This makes for slower methods, but the programmer can always define his own methods optimized for performance.


Method Index

 o abs(double[])
Takes the absolute value of each component of an array
 o abs(double[][])
Takes the absolute value of each component of an array.
 o abs(int[])
Takes the absolute value of each component of an array
 o abs(int[][])
Takes the absolute value of each component of an array
 o add(double[], double)
add a scalar to every element in the array
 o add(double[], double, double[], int)
add to an array w, a time v where a is a scalar...
 o add(double[], double[])
Add the two arrays together (componentwise)
 o add(int[], double, int[], int)
add to an array w, a time v where a is a scalar...
 o add(int[], int)
add a scalar to every element in the array
 o add(int[], int[])
Add the two arrays together (componentwise)
 o apply(Mapping, Complex[])
apply a map to every component of an array.
 o apply(Mapping, Complex[][])
apply a map to every component of an array.
 o apply(Mapping, double[])
apply a map to every component of an array.
 o apply(Mapping, double[][])
apply a map to every component of an array.
 o copy(double[])
Return a copy of the array
 o copy(double[][])
Return a copy of the array
 o copy(int[])
Return a copy of the array
 o copy(int[][])
Return a copy of the array
 o correlation(double[], double[])
Compute the (linear) correlation between two arrays.
 o correlation(int[], int[])
Compute the (linear) correlation between two arrays.
 o covariance(double[], double[])
Compute the covariance.
 o covariance(int[], int[])
Compute the covariance.
 o equals(double[], double[])
Check if two arrays are equal with a tolerance.
 o equals(int[], int[])
Check if two arrays are equal
 o extract(int, int, double[])
Extract a sub-array (will invert the resulting array if k0 > k1).
 o extract(int, int, int[])
Extract a sub-array (will invert the resulting array if k0 > k1).
 o invert(double[])
Invert an array from left to right
 o invert(int[])
Invert an array from left to right
 o mass(double[])
Return the sum of the elements of the array
 o mass(int[])
Return the sum of the elements of the array
 o max(double[])
Return the maximum of an array.
 o max(double[][])
Return the maximum of an array.
 o max(int[])
Return the maximum of an array
 o max(int[][])
Return the maximum of an array
 o mean(double[])
Compute the mean.
 o mean(int[])
Compute the mean
 o median(double[])
Compute the median of an array.
 o median(int[])
Compute the median of an array
 o min(double[])
Return the minimum of an array.
 o min(double[][])
Return the minimum of an array.
 o min(int[])
Return the minimum of an array
 o min(int[][])
Return the minimum of an array
 o mod(Complex[])
Return the componentwise modulus of an array of Complex numbers.
 o mod(Complex[][])
Return the componentwise modulus of an array of Complex numbers.
 o norm(double[])
Compute the L2 norm of an array (Euclidean norm or "length")
 o norm(int[])
Compute the L2 norm of an array (Euclidean norm or "length")
 o normalize(double[])
Renormalize the array so that its L2 norm is 1 (up to computational errors)
 o padding(int, int, double[])
fills in with zero to get to the desired length; original array with be at the specified position
 o padding(int, int, int[])
fills in with zeroes to get to the specified length; original array with be at the specified position
 o percentile(double[], double)
Gives the percentile of an array
 o percentile(int[], double)
Gives the percentile of an array
 o print(double[])
Print to screen an array.
 o print(double[][])
Print to screen an array.
 o print(int[])
Print to screen an array.
 o print(int[][])
Print to screen an array.
 o range(double)
Generate an array going for 0 to b with steps of size 1.
 o range(double, double)
Generate an array going for a to b inclusively with steps of size 1.
 o range(double, double, double)
Generate an array going for a to b with steps of size step.
 o range(int)
Generate an array going for 0 to b with steps of size 1.
 o range(int, int)
Generate an array going for a to b with steps of size 1.
 o range(int, int, int)
Generate an array going for a to b with steps of size step.
 o scalarMultiply(double, double[])
multiply every component of an array by a scalar
 o scalarMultiply(double, int[])
multiply every component of an array by a scalar
 o scalarMultiplyFast(double, double[])
Fast scalar multiplication for sparse arrays.
 o scalarMultiplyFast(double, int[])
Fast scalar multiplication for sparse arrays
 o scalarProduct(double[], double[])
Compute the scalar product of two array as if they were vectors
 o scalarProduct(double[][], double[][])
Compute the scalar product of two array as if they were matrices
 o scalarProduct(int[], int[])
Compute the scalar product of two array as if they were vectors
 o scalarProduct(int[][], int[][])
Compute the scalar product of two array as if they were matrices
 o setLengthFromBeginning(double[], int)
Set an array to the specified length scraping or padding the end if necessary
 o setLengthFromBeginning(int[], int)
Set an array to the specified length scraping or padding the end if necessary
 o setLengthFromEnd(double[], int)
Set an array to the specified length scraping or padding the beginning if necessary
 o setLengthFromEnd(int[], int)
Set an array to the specified length scraping or padding the beginning if necessary
 o sortMaxToMin(double[])
Return a sorted array from the maximum to the minimum value.
 o sortMaxToMin(int[])
return a sorted array from the maximum to the minimum value.
 o sortMinToMax(double[])
Return a sorted array from the minimum to the maximum value.
 o sortMinToMax(int[])
return a sorted array from the minimum to the maximum value.
 o standardDeviation(double[])
Compute the standard deviation of an array.
 o standardDeviation(int[])
Return the standard deviation of an array
 o subtract(double[], double[])
Subtract the two arrays together (componentwise)
 o subtract(int[], int[])
Subtract the two arrays together (componentwise)
 o sumSquares(double[])
Sum the squares of all components; also called the energy of the array.
 o sumSquares(double[][])
Sum the squares of all components; also called the energy of the array.
 o sumSquares(int[])
Sum the squares of all components; also called the energy of the array
 o sumSquares(int[][])
Sum the squares of all components; also called the energy of the array
 o toString(double[])
Returns a comma delimited string representing the value of the array.
 o toString(double[][])
Returns a comma delimited string representing the value of the array.
 o toString(int[])
Returns a comma delimited string representing the value of the array.
 o toString(int[][])
Returns a comma delimited string representing the value of the array.
 o transpose(double[][])
Takes the transpose of an array (like the matrix operation)
 o transpose(int[][])
Takes the transpose of an array (like the matrix operation)
 o variance(double[])
Compute the variance.
 o variance(int[])
Compute the variance.

Methods

 o apply
 public static double[] apply(Mapping m,
                              double v[])
apply a map to every component of an array.

 o apply
 public static double[][] apply(Mapping m,
                                double v[][])
apply a map to every component of an array.

 o apply
 public static Complex[] apply(Mapping m,
                               Complex v[])
apply a map to every component of an array.

 o apply
 public static Complex[][] apply(Mapping m,
                                 Complex v[][])
apply a map to every component of an array.

 o normalize
 public static double[] normalize(double v[])
Renormalize the array so that its L2 norm is 1 (up to computational errors)

 o setLengthFromEnd
 public static double[] setLengthFromEnd(double data[],
                                         int length)
Set an array to the specified length scraping or padding the beginning if necessary

 o setLengthFromBeginning
 public static double[] setLengthFromBeginning(double data[],
                                               int length)
Set an array to the specified length scraping or padding the end if necessary

 o copy
 public static double[] copy(double v[])
Return a copy of the array

 o copy
 public static double[][] copy(double v[][])
Return a copy of the array

 o variance
 public static double variance(double v[])
Compute the variance.

 o covariance
 public static double covariance(double v1[],
                                 double v2[])
Compute the covariance.

 o correlation
 public static double correlation(double v1[],
                                  double v2[])
Compute the (linear) correlation between two arrays. Squaring this result and multiply by 100 gives you the percentage of correlation.

 o mean
 public static double mean(double v[])
Compute the mean.

 o standardDeviation
 public static double standardDeviation(double v[])
Compute the standard deviation of an array.

 o sortMinToMax
 public static double[] sortMinToMax(double v[])
Return a sorted array from the minimum to the maximum value.

 o sortMaxToMin
 public static double[] sortMaxToMin(double v[])
Return a sorted array from the maximum to the minimum value.

 o percentile
 public static double percentile(double v[],
                                 double p)
Gives the percentile of an array

Parameters:
p - percentile, must be between 0 and 1.
Throws: IllegalArgumentException
if parameter p is not between 0 and 1
 o median
 public static double median(double v[])
Compute the median of an array.

 o equals
 public static boolean equals(double a[],
                              double b[])
Check if two arrays are equal with a tolerance.

 o abs
 public static double[] abs(double v[])
Takes the absolute value of each component of an array

 o abs
 public static double[][] abs(double v[][])
Takes the absolute value of each component of an array.

 o max
 public static double max(double v[])
Return the maximum of an array.

 o max
 public static double max(double v[][])
Return the maximum of an array.

 o min
 public static double min(double v[])
Return the minimum of an array.

 o min
 public static double min(double v[][])
Return the minimum of an array.

 o mod
 public static double[] mod(Complex v[])
Return the componentwise modulus of an array of Complex numbers.

 o mod
 public static double[][] mod(Complex v[][])
Return the componentwise modulus of an array of Complex numbers.

 o norm
 public static double norm(double data[])
Compute the L2 norm of an array (Euclidean norm or "length")

 o sumSquares
 public static double sumSquares(double data[])
Sum the squares of all components; also called the energy of the array.

 o sumSquares
 public static double sumSquares(double data[][])
Sum the squares of all components; also called the energy of the array.

 o scalarProduct
 public static double scalarProduct(double w0[],
                                    double w1[])
Compute the scalar product of two array as if they were vectors

Throws: IllegalArgumentException
if the don't have the same length
 o scalarProduct
 public static double scalarProduct(double w0[][],
                                    double w1[][])
Compute the scalar product of two array as if they were matrices

Throws: IllegalArgumentException
if the don't have the same length
 o extract
 public static double[] extract(int k0,
                                int k1,
                                double invect[])
Extract a sub-array (will invert the resulting array if k0 > k1).

Parameters:
k0 - location of the first component
k1 - location of the last component
 o invert
 public static double[] invert(double v[])
Invert an array from left to right

 o padding
 public static double[] padding(int n0,
                                int pos,
                                double v[])
fills in with zero to get to the desired length; original array with be at the specified position

Parameters:
n0 - length of the new array
pos - position of the old array
 o add
 public static double[] add(double w[],
                            double a,
                            double v[],
                            int p)
add to an array w, a time v where a is a scalar... since v can be smaller then w, we must specified the position at which v will be added.

Parameters:
a - scalar
p - position
 o add
 public static double[] add(double w[],
                            double a)
add a scalar to every element in the array

 o transpose
 public static double[][] transpose(double M[][])
Takes the transpose of an array (like the matrix operation)

Throws: IllegalArgumentException
if the array is not a matrix
 o range
 public static double[] range(double a,
                              double b,
                              double step)
Generate an array going for a to b with steps of size step. If it can't get to the value b in a finite number of steps, it gets as close as possible (a can be larger or smaller than b)

Parameters:
step - size of steps, must be positive
a - first value of array
b - last value of array
Throws: IllegalArgumentException
if step is negative or if a=b.
 o range
 public static double[] range(double a,
                              double b)
Generate an array going for a to b inclusively with steps of size 1. a can be smaller or larger than b.

 o range
 public static double[] range(double b)
Generate an array going for 0 to b with steps of size 1. 0 can be smaller or larger than b.

 o add
 public static double[] add(double a[],
                            double b[])
Add the two arrays together (componentwise)

Throws: IllegalArgumentException
if the two arrays don't have the same length
 o subtract
 public static double[] subtract(double a[],
                                 double b[])
Subtract the two arrays together (componentwise)

Throws: IllegalArgumentException
if the two arrays don't have the same length
 o scalarMultiply
 public static double[] scalarMultiply(double a,
                                       double v[])
multiply every component of an array by a scalar

 o toString
 public static String toString(double array[])
Returns a comma delimited string representing the value of the array.

 o toString
 public static String toString(double array[][])
Returns a comma delimited string representing the value of the array.

 o mass
 public static double mass(double v[])
Return the sum of the elements of the array

 o scalarMultiplyFast
 public static double[] scalarMultiplyFast(double a,
                                           double v[])
Fast scalar multiplication for sparse arrays.

 o print
 public static void print(double v[])
Print to screen an array.

 o print
 public static void print(double v[][])
Print to screen an array.

 o setLengthFromEnd
 public static int[] setLengthFromEnd(int data[],
                                      int length)
Set an array to the specified length scraping or padding the beginning if necessary

 o setLengthFromBeginning
 public static int[] setLengthFromBeginning(int data[],
                                            int length)
Set an array to the specified length scraping or padding the end if necessary

 o copy
 public static int[] copy(int v[])
Return a copy of the array

 o copy
 public static int[][] copy(int v[][])
Return a copy of the array

 o variance
 public static double variance(int v[])
Compute the variance.

 o covariance
 public static double covariance(int v1[],
                                 int v2[])
Compute the covariance.

 o correlation
 public static double correlation(int v1[],
                                  int v2[])
Compute the (linear) correlation between two arrays. Squaring this result and multiply by 100 gives you the percentage of correlation.

 o mean
 public static double mean(int v[])
Compute the mean

 o standardDeviation
 public static double standardDeviation(int v[])
Return the standard deviation of an array

 o sortMinToMax
 public static int[] sortMinToMax(int v[])
return a sorted array from the minimum to the maximum value.

 o sortMaxToMin
 public static int[] sortMaxToMin(int v[])
return a sorted array from the maximum to the minimum value.

 o toString
 public static String toString(int array[])
Returns a comma delimited string representing the value of the array.

 o toString
 public static String toString(int array[][])
Returns a comma delimited string representing the value of the array.

 o percentile
 public static double percentile(int v[],
                                 double p)
Gives the percentile of an array

Parameters:
p - percentile, must be between 0 and 1.
Throws: IllegalArgumentException
if parameter p is not between 0 and 1
 o median
 public static double median(int v[])
Compute the median of an array

 o equals
 public static boolean equals(int a[],
                              int b[])
Check if two arrays are equal

 o abs
 public static int[] abs(int v[])
Takes the absolute value of each component of an array

 o abs
 public static int[][] abs(int v[][])
Takes the absolute value of each component of an array

 o max
 public static int max(int v[])
Return the maximum of an array

 o max
 public static int max(int v[][])
Return the maximum of an array

 o min
 public static int min(int v[])
Return the minimum of an array

 o min
 public static int min(int v[][])
Return the minimum of an array

 o norm
 public static double norm(int data[])
Compute the L2 norm of an array (Euclidean norm or "length")

 o sumSquares
 public static int sumSquares(int data[])
Sum the squares of all components; also called the energy of the array

 o sumSquares
 public static int sumSquares(int data[][])
Sum the squares of all components; also called the energy of the array

 o scalarProduct
 public static int scalarProduct(int w0[],
                                 int w1[])
Compute the scalar product of two array as if they were vectors

Throws: IllegalArgumentException
if the don't have the same length
 o scalarProduct
 public static double scalarProduct(int w0[][],
                                    int w1[][])
Compute the scalar product of two array as if they were matrices

Throws: IllegalArgumentException
if the don't have the same length
 o extract
 public static int[] extract(int k0,
                             int k1,
                             int invect[])
Extract a sub-array (will invert the resulting array if k0 > k1).

Parameters:
k0 - location of the first component
k1 - location of the last component
 o invert
 public static int[] invert(int v[])
Invert an array from left to right

 o padding
 public static int[] padding(int n0,
                             int pos,
                             int v[])
fills in with zeroes to get to the specified length; original array with be at the specified position

Parameters:
n0 - length of the new array
pos - position of the old array
 o add
 public static int[] add(int w[],
                         double a,
                         int v[],
                         int p)
add to an array w, a time v where a is a scalar... since v can be smaller then w, we must specified the position at which v will be added.

Parameters:
a - scalar
p - position
w - longer array
v - shorter array
Throws: IllegalArgumentException
if the second array is not shorter than the first one
 o add
 public static int[] add(int w[],
                         int a)
add a scalar to every element in the array

 o range
 public static int[] range(int a,
                           int b)
Generate an array going for a to b with steps of size 1. a can be smaller or larger than b.

 o range
 public static int[] range(int b)
Generate an array going for 0 to b with steps of size 1. 0 can be smaller or larger than b.

 o range
 public static int[] range(int a,
                           int b,
                           int step)
Generate an array going for a to b with steps of size step. If it can't get to the value b in a finite number of steps, it gets as close as possible (a can be larger or smaller than b)

Parameters:
step - size of steps, must be positive
a - first value of array
b - last value of array
Throws: IllegalArgumentException
if step is negative or if a=b.
 o transpose
 public static int[][] transpose(int M[][])
Takes the transpose of an array (like the matrix operation)

Throws: IllegalArgumentException
if the array is not a matrix
 o add
 public static int[] add(int a[],
                         int b[])
Add the two arrays together (componentwise)

Throws: IllegalArgumentException
if the two arrays don't have the same length
 o subtract
 public static int[] subtract(int a[],
                              int b[])
Subtract the two arrays together (componentwise)

Throws: IllegalArgumentException
if the two arrays don't have the same length
 o mass
 public static int mass(int v[])
Return the sum of the elements of the array

 o scalarMultiply
 public static double[] scalarMultiply(double a,
                                       int v[])
multiply every component of an array by a scalar

 o scalarMultiplyFast
 public static double[] scalarMultiplyFast(double a,
                                           int v[])
Fast scalar multiplication for sparse arrays

 o print
 public static void print(int v[])
Print to screen an array.

 o print
 public static void print(int v[][])
Print to screen an array.


All Packages  Class Hierarchy  This Package  Previous  Next  Index