0

我正在尝试在 Swift 中实现 Accelerate DFT,希望这将处理任意样本大小,而不仅仅是 2^n 样本大小。

我正在努力将值传递给这个函数:vDSP_DFT_ExecuteD(...)。我的代码粘贴在下面,我收到一个错误:执行被中断,原因:EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=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
4

0 回答 0