Package org.hipparchus.transform
Class TransformUtils
java.lang.Object
org.hipparchus.transform.TransformUtils
Useful functions for the implementation of various transforms.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Complex[]
createComplexArray
(double[][] dataRI) Builds a new array ofComplex
from the specified two dimensional array of real and imaginary parts.static double[][]
createRealImaginaryArray
(Complex[] dataC) Builds a new two dimensional array ofdouble
filled with the real and imaginary parts of the specifiedComplex
numbers.static int
exactLog2
(int n) Returns the base-2 logarithm of the specifiedint
.static double[]
scaleArray
(double[] f, double d) Multiply every component in the given real array by the given real number.static Complex[]
scaleArray
(Complex[] f, double d) Multiply every component in the given complex array by the given real number.
-
Method Details
-
scaleArray
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
- the real array to be scaledd
- the real scaling coefficient- Returns:
- a reference to the scaled array
-
scaleArray
Multiply every component in the given complex array by the given real number. The change is made in place.- Parameters:
f
- the complex array to be scaledd
- the real scaling coefficient- Returns:
- a reference to the scaled array
-
createRealImaginaryArray
Builds a new two dimensional array ofdouble
filled with the real and imaginary parts of the specifiedComplex
numbers. In the returned arraydataRI
, the data is laid out as followsdataRI[0][i] = dataC[i].getReal()
,dataRI[1][i] = dataC[i].getImaginary()
.
- Parameters:
dataC
- the array ofComplex
data to be transformed- Returns:
- a two dimensional array filled with the real and imaginary parts of the specified complex input
-
createComplexArray
Builds a new array ofComplex
from the specified two dimensional array of real and imaginary parts. In the returned arraydataC
, the data is laid out as followsdataC[i].getReal() = dataRI[0][i]
,dataC[i].getImaginary() = dataRI[1][i]
.
- Parameters:
dataRI
- the array of real and imaginary parts to be transformed- Returns:
- an array of
Complex
with specified real and imaginary parts. - Throws:
MathIllegalArgumentException
- if the number of rows of the specified array is not two, or the array is not rectangular
-
exactLog2
Returns the base-2 logarithm of the specifiedint
. Throws an exception ifn
is not a power of two.- Parameters:
n
- theint
whose base-2 logarithm is to be evaluated- Returns:
- the base-2 logarithm of
n
- Throws:
MathIllegalArgumentException
- ifn
is not a power of two
-