我正在尝试在Swift中实现Accelerate DFT,希望这将处理任意样本大小而不是2 ^ n样本大小。
我正在努力将值传递给此函数:vDSP_DFT_ExecuteD(...)。我的代码粘贴在下面,我收到一个错误:执行被中断,原因:EXC_BAD_INSTRUCTION(代码= EXC_I386_INVOP,子代码= 0x0)。
import Accelerate
var x = [Double]() // Input Real Part
var y = [Double]() // Input Imag Part
var xo = [Double]() // Output Real Part
var yo = [Double]() // Output Imag Part
x = [1,2,3,4,5]
y = [0,0,0,0,0]
var splitComplex = DSPDoubleSplitComplex(realp: &x, imagp: &y)
let length = vDSP_Length(x.count)
let weights = vDSP_DFT_zop_CreateSetupD(nil, length, vDSP_DFT_Direction.FORWARD)
vDSP_DFT_ExecuteD(weights!, x, y, &xo, &yo)
print(xo) // Print Real Output
print(yo) // Print Imag Output