|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.math3.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)
Returns the forward transform of the specified integer data set. |
double[] |
transform(double[] f,
TransformType type)
Returns the (forward, inverse) transform of the specified real data set. |
int[] |
transform(int[] f)
Returns the forward transform of the specified integer data set.The integer transform cannot be inverted directly, due to a scaling factor which may lead to double results. |
double[] |
transform(UnivariateFunction f,
double min,
double max,
int n,
TransformType type)
Returns the (forward, inverse) transform of the specified real function, sampled on the specified 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, TransformType type)
transform
in interface RealTransformer
f
- the real data array to be transformed (signal)type
- the type of transform (forward, inverse) to be performed
MathIllegalArgumentException
- if the length of the data array is
not a power of twopublic double[] transform(UnivariateFunction f, double min, double max, int n, TransformType type)
transform
in interface RealTransformer
f
- the function to be sampled and transformedmin
- the (inclusive) lower bound for the intervalmax
- the (exclusive) upper bound for the intervaln
- the number of sample pointstype
- the type of transform (forward, inverse) to be performed
NonMonotonicSequenceException
- if the lower bound is greater than, or equal to the upper bound
NotStrictlyPositiveException
- if the number of sample points is negative
MathIllegalArgumentException
- if the number of sample points is not a power of twopublic int[] transform(int[] f)
f
- the integer data array to be transformed (signal)
MathIllegalArgumentException
- if the length of the data array is not a power of twoprotected double[] fht(double[] x) throws MathIllegalArgumentException
N * log2(N) = n * 2^n
additions.
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 |
N
rows and n + 1
columns,
hadm[n+1][N]
.x[N]
in the first column of the
matrix hadm
.D_top
are calculated as follows
D_top
goes from entry [0][1]
to
[N / 2 - 1][n + 1]
,D_top
are the pairwise mutually
exclusive sums of the previous column.D_bottom
are calculated as
follows
D_bottom
goes from entry [N / 2][1]
to
[N][n + 1]
,D_bottom
are the pairwise differences
of the previous column.D_top
and D_bottom
are best
understood with the above example (for N = 8
).
y
is now in the last column of
hadm
.0 | 1 | 2 | 3 | … | n + 1 | |
---|---|---|---|---|---|---|
0 | x0 |
↑ ← Dtop → ↓ |
||||
1 | x1 | |||||
2 | x2 | |||||
… | … | |||||
N / 2 - 1 | xN/2-1 | |||||
N / 2 | xN/2 |
↑ ← Dbottom → ↓ |
||||
N / 2 + 1 | xN/2+1 | |||||
N / 2 + 2 | xN/2+2 | |||||
… | … | |||||
N | xN |
x
- the real data array to be transformed
y
MathIllegalArgumentException
- if the length of the data array is not a power of twoprotected int[] fht(int[] x) throws MathIllegalArgumentException
x
- the integer data array to be transformed
y
MathIllegalArgumentException
- if the length of the data array is not a power of two
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |