简体   繁体   English

需要解释FFT类的参数

[英]Need an explanation of the parameters for FFT class

The transform method produces a NullPointerException: transform方法产生NullPointerException:

FastFourierTransformer transformer = new FastFourierTransformer(null);
    try {
        Complex[] complx = transformer.transform(sineValue, null);

I suspect the issue is the 'null' parameters, but I don't understand what the documentation is requiring for "DftNormalization" and for " TransformType". 我怀疑问题是'null'参数,但我不明白文档对“DftNormalization”和“TransformType”的要求。

For instance, if I type in the word STANDARD for DftNormalization or the word FORWARD for TransformType, Eclipse shows an error. 例如,如果我输入单词STANDARD for DftNormalization或单词FORWARD for TransformType,Eclipse会显示错误。 Drilling down in the documentation didn't provide any help, just lists the words FORWARD and STANDARD. 在文档中向下钻取没有提供任何帮助,只需列出FORWARD和STANDARD字样。

I need a forward transform with standard normalization for a real array. 我需要一个正向变换,标准归一化为真实数组。

I generate the test array: 我生成测试数组:

sineValue = new double[4096];

    for (int i = 0; i < 4096; i++) {
        sineValue[i] = Math.sin(i * Math.PI * 2 / MIN_RATE) + 0.0
                * Math.sin(i * Math.PI * 4 / MIN_RATE) + 0.0
                * Math.sin(i * Math.PI * 15.3 / MIN_RATE);
        System.out.println("line " + i + "value: " + sineValue[i]);

MIN_RATE is 256. MIN_RATE是256。

When passing the second argument you need to prefix the value by the type name: 传递第二个参数时,您需要通过类型名称为值添加前缀:

FastFourierTransformer transformer = new FastFourierTransformer(null);
try {
    Complex[] complx = transformer.transform(sineValue, TransformType.FORWARD);

Alternatively use can do a static import: 或者使用可以进行静态导入:

import static org.apache.commons.math3.transform.TransformType.*;

Then you can omit the type name: 然后你可以省略类型名称:

FastFourierTransformer transformer = new FastFourierTransformer(null);
try {
    Complex[] complx = transformer.transform(sineValue, FORWARD);

The same is applicable to the constructor call: 这同样适用于构造函数调用:

FastFourierTransformer transformer = new FastFourierTransformer(DftNormalization.STANDARD);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM