Top Description Fields Constructors Methods
org.apache.commons.math3.transform

public Class TransformUtils

extends Object
Class Inheritance
Imports
java.util.Arrays, org.apache.commons.math3.complex.Complex, org.apache.commons.math3.exception.DimensionMismatchException, .MathIllegalArgumentException, org.apache.commons.math3.exception.util.LocalizedFormats

Useful functions for the implementation of various transforms.
Since
3.0

Field Summary

Modifier and TypeField and Description
private static final int[]
POWERS_OF_TWO

Table of the powers of 2 to facilitate binary search lookup.

Constructor Summary

AccessConstructor and Description
private
TransformUtils()

Private constructor.

Method Summary

Modifier and TypeMethod and Description
public static Complex[]

Returns:

an array of Complex with specified real and imaginary parts.
createComplexArray
(final double[][]
the array of real and imaginary parts to be transformed
dataRI
)

Builds a new array of Complex from the specified two dimensional array of real and imaginary parts.

public static double[][]

Returns:

a two dimensional array filled with the real and imaginary parts of the specified complex input
createRealImaginaryArray
(final Complex[]
the array of Complex data to be transformed
dataC
)

Builds a new two dimensional array of double filled with the real and imaginary parts of the specified Complex numbers.

public static int

Returns:

the base-2 logarithm of n
exactLog2
(final int
the int whose base-2 logarithm is to be evaluated
n
)

Returns the base-2 logarithm of the specified int.

public static double[]

Returns:

a reference to the scaled array
scaleArray
(double[]
the real array to be scaled
f
,
double
the real scaling coefficient
d
)

Multiply every component in the given real array by the given real number.

public static Complex[]

Returns:

a reference to the scaled array
scaleArray
(Complex[]
the complex array to be scaled
f
,
double
the real scaling coefficient
d
)

Multiply every component in the given complex array by the given real number.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

POWERS_OF_TWOback to summary
private static final int[] POWERS_OF_TWO

Table of the powers of 2 to facilitate binary search lookup.

See Also
exactLog2(int)

Constructor Detail

TransformUtilsback to summary
private TransformUtils()

Private constructor.

Method Detail

createComplexArrayback to summary
public static Complex[] createComplexArray(final double[][] dataRI) throws DimensionMismatchException

Builds a new array of Complex from the specified two dimensional array of real and imaginary parts. In the returned array dataC, the data is laid out as follows

  • dataC[i].getReal() = dataRI[0][i],
  • dataC[i].getImaginary() = dataRI[1][i].
Parameters
dataRI:double[][]

the array of real and imaginary parts to be transformed

Returns:Complex[]

an array of Complex with specified real and imaginary parts.

Exceptions
DimensionMismatchException:
if the number of rows of the specified array is not two, or the array is not rectangular
createRealImaginaryArrayback to summary
public static double[][] createRealImaginaryArray(final Complex[] dataC)

Builds a new two dimensional array of double filled with the real and imaginary parts of the specified Complex numbers. In the returned array dataRI, the data is laid out as follows

  • dataRI[0][i] = dataC[i].getReal(),
  • dataRI[1][i] = dataC[i].getImaginary().
Parameters
dataC:Complex[]

the array of Complex data to be transformed

Returns:double[][]

a two dimensional array filled with the real and imaginary parts of the specified complex input

exactLog2back to summary
public static int exactLog2(final int n) throws MathIllegalArgumentException

Returns the base-2 logarithm of the specified int. Throws an exception if n is not a power of two.

Parameters
n:int

the int whose base-2 logarithm is to be evaluated

Returns:int

the base-2 logarithm of n

Exceptions
MathIllegalArgumentException:
if n is not a power of two
scaleArrayback to summary
public static double[] scaleArray(double[] f, double d)

Multiply every component in the given real array by the given real number. The change is made in place.

Parameters
f:double[]

the real array to be scaled

d:double

the real scaling coefficient

Returns:double[]

a reference to the scaled array

scaleArrayback to summary
public static Complex[] scaleArray(Complex[] f, double d)

Multiply every component in the given complex array by the given real number. The change is made in place.

Parameters
f:Complex[]

the complex array to be scaled

d:double

the real scaling coefficient

Returns:Complex[]

a reference to the scaled array