jfftw
Class ArrayUtil

java.lang.Object
  extended by jfftw.ArrayUtil

public class ArrayUtil
extends Object

Class containing some useful static method to manipulate double arrays containing complex data used in jfftw. All array access is by array index with no setter/getter overhead. This is not very OOP, but vastly improves efficiency.


Constructor Summary
ArrayUtil()
           
 
Method Summary
static void conjugate(double[] data)
          Method to take form the conjugate of an interleaved array by taking the negative of imaginary parts.
static void conjugate(double[][] split)
          Method to take form the conjugate of a split array by taking the negative of the imaginary parts.
static void conjugate(double[] data, int i)
          Conjugate specified element of an interleaved array
static Complex getComplex(double[][] split, int i)
          Static method to get the ith Complex element from a split array consisting of real and imaginary parts in a [2][] array
static Complex getComplex(double[] real, double[] imag, int i)
          Static method to get the ith Complex element from a split array consisting of real and imaginary parts.
static Complex getComplex(double[] data, int i)
          Static method to get the ith Complex element from an interleaved array where real part is in 2*i and imaginary in 2*i + 1.
static double[] interleave(double[][] data)
          Static method to take split array normally holding real and imaginary parts and interleave them to a single array.
static double[] interleave(double[] real, double[] imag)
          Static method to take two double arrays normally holding real and imaginary parts and interleave them to a single array.
static double maxModSqr(double[] data)
          Method to get the modulus squared of the largest elements of an interleaved Complex array.
static double maxModSqr(double[][] split)
          Method to get the modulus squared of the largest elements of a split Complex array
static double maxModSqr(double[] real, double[] imag)
          Method to get the modulus squared of the largest elements of a split Complex array with real and imaginary parts held in separate arrays.
static double modulus(double[] data, int i)
          Get the modulus of specified element of interleaved array
static double modulusSqr(double[] data, int i)
          Get the modulus square of specified element of interleaved array
static void mult(double[][] split, Complex c)
          Method to multiply a split array by a complex.
static void mult(double[][] split, double a)
          Method to multiply a split array by a double.
static void mult(double[][] first, double[][] second)
          Method to multiply two split arrays putting the result in the first.
static void mult(double[][] split, double a, double b)
          Method to multiply a split array by a complex specified as two doubles.
static void mult(double[] data, Complex c)
          Method to multiply an interleaved array by a complex.
static void mult(double[] data, double a)
          Method to multiply an interleaved array by a double.
static void mult(double[] first, double[] second)
          Method to multiply two complex interleaved data arrays placing the result in the first.
static void mult(double[] data, double a, double b)
          Method to multiply a interleaved array by a complex specified as two doubles.
static void mult(double[] data, int i, Complex c)
          Multiply specified element of interleaved array by a complex.
static void mult(double[] data, int i, double a)
          Multiply specified element of interleaved array by a double
static void mult(double[] data, int i, double a, double b)
          Multiply specified element of interleaved array by a complex specified as two doubles.
static void multConjugate(double[][] first, double[][] second)
          Method to multiply first array by complex conjugate of the second.
static void multConjugate(double[] first, double[] second)
          Method to multiply a interleaves complex arrays with the complex conjugate of an interleaved array, placing the result in the first.
static double power(double[] data)
          Method to get power (sum of modulus squared) in an Complex interleaved array.
 double power(double[][] split)
          Method to get power (sum of modulus squared) in an Complex split array.
 double power(double[] real, double[] imag)
          Method to get power (sum of modulus squared) in an Complex split array held in real and imaginary arrays.
static void setComplex(double[][] split, int i, Complex z)
          Static to set the ith component of split array array with a Complex.
static void setComplex(double[][] split, int i, double a, double b)
          Static to set the ith component of split array array with a Complex.
static void setComplex(double[] real, double[] imag, int i, Complex z)
          Static to set the ith component of split array array with a Complex.
static void setComplex(double[] real, double[] imag, int i, double a, double b)
          Static to set the ith component of split array array with two doubles
static void setComplex(double[] data, int i, Complex z)
          Static to set the ith component of a interleaved complex array with a Complex.
static void setComplex(double[] data, int i, double a, double b)
          Static to set the ith component of a interleaved complex array with a two doubles
static double[][] split(double[] data)
          Static method to split an interleaved array into two split array, returned as a double[2][] array with [0][i] and [1][i] holding the real / imaginary parts.
static double[][] split(double[] real, double[] imag)
          Static method to form a split array from a real and imaginary array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayUtil

public ArrayUtil()
Method Detail

interleave

public static double[] interleave(double[] real,
                                  double[] imag)
Static method to take two double arrays normally holding real and imaginary parts and interleave them to a single array. If imaginary array is null or length zero it is taken as zero.

Parameters:
real - the real array
imag - the imaginary array (can be null, or length zero).
Returns:
double[] interleaved array.

interleave

public static double[] interleave(double[][] data)
Static method to take split array normally holding real and imaginary parts and interleave them to a single array.

Parameters:
data - the split array
Returns:
double[] interleaved array.

split

public static double[][] split(double[] data)
Static method to split an interleaved array into two split array, returned as a double[2][] array with [0][i] and [1][i] holding the real / imaginary parts.

Parameters:
data - the interleaved array.
Returns:
double[][] of size [2][data.length/2]

split

public static double[][] split(double[] real,
                               double[] imag)
Static method to form a split array from a real and imaginary array. If imaginary array is null or of length zero, it is assumed to be zero.

Note the data is not copied to new space.

Parameters:
real - the real array
imag - the imaginary array
Returns:
double[][] array in split format.

getComplex

public static Complex getComplex(double[] data,
                                 int i)
Static method to get the ith Complex element from an interleaved array where real part is in 2*i and imaginary in 2*i + 1.

Parameters:
data - the interleaved array
i - the element index

setComplex

public static void setComplex(double[] data,
                              int i,
                              Complex z)
Static to set the ith component of a interleaved complex array with a Complex.

Parameters:
data - the interleaved array
i - the element index
z - the value

setComplex

public static void setComplex(double[] data,
                              int i,
                              double a,
                              double b)
Static to set the ith component of a interleaved complex array with a two doubles

Parameters:
data - the interleaved array
i - the element index
a - the real part
b - the imaginary part.

getComplex

public static Complex getComplex(double[] real,
                                 double[] imag,
                                 int i)
Static method to get the ith Complex element from a split array consisting of real and imaginary parts.

Parameters:
real - the real array.
imag - the imaginary array.
i - the element index.

setComplex

public static void setComplex(double[] real,
                              double[] imag,
                              int i,
                              Complex z)
Static to set the ith component of split array array with a Complex.

Parameters:
real - the real array
imag - the imaginary array
i - the element index
z - the value

setComplex

public static void setComplex(double[] real,
                              double[] imag,
                              int i,
                              double a,
                              double b)
Static to set the ith component of split array array with two doubles

Parameters:
real - the real array
imag - the imaginary array
i - the element index
a - the real part
b - the imaginary part

getComplex

public static Complex getComplex(double[][] split,
                                 int i)
Static method to get the ith Complex element from a split array consisting of real and imaginary parts in a [2][] array

Parameters:
split - the [2][] array
i - the element index.

setComplex

public static void setComplex(double[][] split,
                              int i,
                              Complex z)
Static to set the ith component of split array array with a Complex.

Parameters:
split - the split array of real and imaginary parts
i - the element index
z - the value

setComplex

public static void setComplex(double[][] split,
                              int i,
                              double a,
                              double b)
Static to set the ith component of split array array with a Complex.

Parameters:
split - the split array of real and imaginary parts
i - the element index
a - the real part
b - the imaginary part.

conjugate

public static void conjugate(double[] data,
                             int i)
Conjugate specified element of an interleaved array

Parameters:
i - the index

modulusSqr

public static double modulusSqr(double[] data,
                                int i)
Get the modulus square of specified element of interleaved array

Parameters:
i - the index

modulus

public static double modulus(double[] data,
                             int i)
Get the modulus of specified element of interleaved array

Parameters:
i - the index

mult

public static void mult(double[] data,
                        int i,
                        double a)
Multiply specified element of interleaved array by a double

Parameters:
data - the interleaved array
i - the index
a - the double.

mult

public static void mult(double[] data,
                        int i,
                        double a,
                        double b)
Multiply specified element of interleaved array by a complex specified as two doubles.

Parameters:
data - the interleaved array
i - the index
a - real part
b - imaginary part

mult

public static void mult(double[] data,
                        int i,
                        Complex c)
Multiply specified element of interleaved array by a complex.

Parameters:
data - the interleaved array
i - the index
c - the Complex

mult

public static void mult(double[] data,
                        double a)
Method to multiply an interleaved array by a double.

Parameters:
data - the interleaved array
a - the multiplier.

mult

public static void mult(double[][] split,
                        double a)
Method to multiply a split array by a double.

Parameters:
split - the split array
a - the multiplier.

mult

public static void mult(double[] data,
                        double a,
                        double b)
Method to multiply a interleaved array by a complex specified as two doubles.

Parameters:
data - the interleaved array
a - real part of multiplier
b - imaginary part of multiplier

mult

public static void mult(double[] data,
                        Complex c)
Method to multiply an interleaved array by a complex.

Parameters:
data - the interleaved array
c - the Complex multiplier

mult

public static void mult(double[][] split,
                        double a,
                        double b)
Method to multiply a split array by a complex specified as two doubles.

Parameters:
split - the split array
a - real part of multiplier
b - imaginary part of multiplier
Throws:
ArrayIndexOutOfBoundsException - if real and imaginary arrays of different lengths.

mult

public static void mult(double[][] split,
                        Complex c)
Method to multiply a split array by a complex.

Parameters:
split - the split array
c - the Complex multiplier

mult

public static void mult(double[] first,
                        double[] second)
Method to multiply two complex interleaved data arrays placing the result in the first. Both must be the same size.

Parameters:
first - the first interleaved array
second - the second interleaved array (not changed)
Throws:
ArrayIndexOutOfBoundsException - if the two arrays are not the same length.

multConjugate

public static void multConjugate(double[] first,
                                 double[] second)
Method to multiply a interleaves complex arrays with the complex conjugate of an interleaved array, placing the result in the first. Both must be the same size.

Parameters:
first - the first interleaved array
second - the second interleaved array (not changed)
Throws:
ArrayIndexOutOfBoundsException - if the two arrays are not the same length.

mult

public static void mult(double[][] first,
                        double[][] second)
Method to multiply two split arrays putting the result in the first. Both must be of the same length.

Parameters:
first - the first split array
second - the second split array.
Throws:
ArrayIndexOutOfBoundsException - if the two arrays are not the same length.

multConjugate

public static void multConjugate(double[][] first,
                                 double[][] second)
Method to multiply first array by complex conjugate of the second. Both must be of the same length and the second array is not altered.

Parameters:
first - the first split array
second - the second split array.
Throws:
ArrayIndexOutOfBoundsException - if the two arrays are not the same length.

conjugate

public static void conjugate(double[] data)
Method to take form the conjugate of an interleaved array by taking the negative of imaginary parts.

Parameters:
data - the interleaved array.

conjugate

public static void conjugate(double[][] split)
Method to take form the conjugate of a split array by taking the negative of the imaginary parts.

Parameters:
split - the split array.

maxModSqr

public static double maxModSqr(double[] data)
Method to get the modulus squared of the largest elements of an interleaved Complex array.

Parameters:
data - the interleaved Complex array
Returns:
double maximum modulus squared

maxModSqr

public static double maxModSqr(double[] real,
                               double[] imag)
Method to get the modulus squared of the largest elements of a split Complex array with real and imaginary parts held in separate arrays.

Parameters:
real - the real array
imag - the imaginary array
Returns:
double maximum modulus squared

maxModSqr

public static double maxModSqr(double[][] split)
Method to get the modulus squared of the largest elements of a split Complex array

Parameters:
split - the split array
Returns:
double maximum modulus squared

power

public static double power(double[] data)
Method to get power (sum of modulus squared) in an Complex interleaved array.

Parameters:
data - the interleaved Complex array
Returns:
double the power.

power

public double power(double[] real,
                    double[] imag)
Method to get power (sum of modulus squared) in an Complex split array held in real and imaginary arrays.

Parameters:
real - the real array
imag - the imaginary array
Returns:
double the power

power

public double power(double[][] split)
Method to get power (sum of modulus squared) in an Complex split array.

Parameters:
split - the split array return double the power