本文整理汇总了Java中org.apache.commons.math3.exception.util.LocalizedFormats.NOT_POWER_OF_TWO_PLUS_ONE属性的典型用法代码示例。如果您正苦于以下问题:Java LocalizedFormats.NOT_POWER_OF_TWO_PLUS_ONE属性的具体用法?Java LocalizedFormats.NOT_POWER_OF_TWO_PLUS_ONE怎么用?Java LocalizedFormats.NOT_POWER_OF_TWO_PLUS_ONE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.math3.exception.util.LocalizedFormats
的用法示例。
在下文中一共展示了LocalizedFormats.NOT_POWER_OF_TWO_PLUS_ONE属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fct
/**
* Perform the FCT algorithm (including inverse).
*
* @param f the real data array to be transformed
* @return the real transformed array
* @throws MathIllegalArgumentException if the length of the data array is
* not a power of two plus one
*/
protected double[] fct(double[] f)
throws MathIllegalArgumentException {
final double[] transformed = new double[f.length];
final int n = f.length - 1;
if (!ArithmeticUtils.isPowerOfTwo(n)) {
throw new MathIllegalArgumentException(
LocalizedFormats.NOT_POWER_OF_TWO_PLUS_ONE,
Integer.valueOf(f.length));
}
if (n == 1) { // trivial case
transformed[0] = 0.5 * (f[0] + f[1]);
transformed[1] = 0.5 * (f[0] - f[1]);
return transformed;
}
// construct a new array and perform FFT on it
final double[] x = new double[n];
x[0] = 0.5 * (f[0] + f[n]);
x[n >> 1] = f[n >> 1];
// temporary variable for transformed[1]
double t1 = 0.5 * (f[0] - f[n]);
for (int i = 1; i < (n >> 1); i++) {
final double a = 0.5 * (f[i] + f[n - i]);
final double b = FastMath.sin(i * FastMath.PI / n) * (f[i] - f[n - i]);
final double c = FastMath.cos(i * FastMath.PI / n) * (f[i] - f[n - i]);
x[i] = a - b;
x[n - i] = a + b;
t1 += c;
}
FastFourierTransformer transformer;
transformer = new FastFourierTransformer(DftNormalization.STANDARD);
Complex[] y = transformer.transform(x, TransformType.FORWARD);
// reconstruct the FCT result for the original array
transformed[0] = y[0].getReal();
transformed[1] = t1;
for (int i = 1; i < (n >> 1); i++) {
transformed[2 * i] = y[i].getReal();
transformed[2 * i + 1] = transformed[2 * i - 1] - y[i].getImaginary();
}
transformed[n] = y[n >> 1].getReal();
return transformed;
}