|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.math.transform.FastHadamardTransformer
public class FastHadamardTransformer
Implements the Fast Hadamard Transform (FHT). Transformation of an input vector x to the output vector y.
In addition to transformation of real vectors, the Hadamard transform can transform integer vectors into integer vectors. However, this integer transform cannot be inverted directly. Due to a scaling factor it may lead to rational results. As an example, the inverse transform of integer vector (0, 1, 0, 1) is rational vector (1/2, -1/2, 0, 0).
Constructor Summary | |
---|---|
FastHadamardTransformer()
|
Method Summary | |
---|---|
protected double[] |
fht(double[] x)
The FHT (Fast Hadamard Transformation) which uses only subtraction and addition. |
protected int[] |
fht(int[] x)
The FHT (Fast Hadamard Transformation) which uses only subtraction and addition. |
double[] |
inversetransform(double[] f)
Inversely transform the given real data set. |
double[] |
inversetransform(UnivariateRealFunction f,
double min,
double max,
int n)
Inversely transform the given real function, sampled on the given interval. |
double[] |
transform(double[] f)
Transform the given real data set. |
int[] |
transform(int[] f)
Transform the given real data set. |
double[] |
transform(UnivariateRealFunction f,
double min,
double max,
int n)
Transform the given real function, sampled on the given interval. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FastHadamardTransformer()
Method Detail |
---|
public double[] transform(double[] f) throws IllegalArgumentException
transform
in interface RealTransformer
f
- the real data array to be transformed (signal)
IllegalArgumentException
- if any parameters are invalidpublic double[] transform(UnivariateRealFunction f, double min, double max, int n) throws FunctionEvaluationException, IllegalArgumentException
transform
in interface RealTransformer
f
- the function to be sampled and transformedmin
- the lower bound for the intervalmax
- the upper bound for the intervaln
- the number of sample points
FunctionEvaluationException
- if function cannot be evaluated at some point
IllegalArgumentException
- if any parameters are invalidpublic double[] inversetransform(double[] f) throws IllegalArgumentException
inversetransform
in interface RealTransformer
f
- the real data array to be inversely transformed (spectrum)
IllegalArgumentException
- if any parameters are invalidpublic double[] inversetransform(UnivariateRealFunction f, double min, double max, int n) throws FunctionEvaluationException, IllegalArgumentException
inversetransform
in interface RealTransformer
f
- the function to be sampled and inversely transformedmin
- the lower bound for the intervalmax
- the upper bound for the intervaln
- the number of sample points
FunctionEvaluationException
- if function cannot be evaluated at some point
IllegalArgumentException
- if any parameters are invalidpublic int[] transform(int[] f) throws IllegalArgumentException
The integer transform cannot be inverted directly, due to a scaling factor it may lead to double results.
f
- the integer data array to be transformed (signal)
IllegalArgumentException
- if any parameters are invalidprotected double[] fht(double[] x) throws IllegalArgumentException
+----+----------+---------+----------+
| x | a | b | y |
+----+----------+---------+----------+
| x0 | a0=x0+x1 | b0=a0+a1 | y0=b0+b1 |
+----+----------+---------+----------+
| x1 | a1=x2+x3 | b0=a2+a3 | y0=b2+b3 |
+----+----------+---------+----------+
| x2 | a2=x4+x5 | b0=a4+a5 | y0=b4+b5 |
+----+----------+---------+----------+
| x3 | a3=x6+x7 | b0=a6+a7 | y0=b6+b7 |
+----+----------+---------+----------+
| x4 | a0=x0-x1 | b0=a0-a1 | y0=b0-b1 |
+----+----------+---------+----------+
| x5 | a1=x2-x3 | b0=a2-a3 | y0=b2-b3 |
+----+----------+---------+----------+
| x6 | a2=x4-x5 | b0=a4-a5 | y0=b4-b5 |
+----+----------+---------+----------+
| x7 | a3=x6-x7 | b0=a6-a7 | y0=b6-b7 |
+----+----------+---------+----------+
How it works
+--------+---+---+---+-----+---+ | 0 | 1 | 2 | 3 | ... |n+1| +------+--------+---+---+---+-----+---+ |0 | x0 | /\ | |1 | x1 | || | |2 | x2 | <= Dtop => | |... | ... | || | |N/2-1 | xN/2-1 | \/ | +------+--------+---+---+---+-----+---+ |N/2 | xN/2 | /\ | |N/2+1 | xN/2+1 | || | |N/2+2 | xN/2+2 | <= Dbottom => | which is in the last column of the matrix |... | ... | || | |N | xN/2 | \/ | +------+--------+---+---+---+-----+---+
x
- input vector
IllegalArgumentException
- if input array is not a power of 2protected int[] fht(int[] x) throws IllegalArgumentException
x
- input vector
IllegalArgumentException
- if input array is not a power of 2
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |