问题描述
当我执行以下代码行时:
self.forwardDCTSetup = vDSP.DCT(count: 40,transformType: vDSP.DCTTransformType.II)!
我得到:
Fatal error: Unexpectedly found nil while unwrapping an Optional value
我几乎完全遵循本教程:https://developer.apple.com/documentation/accelerate/signal_extraction_from_noise。
解决方法
在长度/计数方面,vDSP.DCT
遵循与vDSP_DCT_CreateSetup
相同的规则:
The supported values are Length = f * 2**n,where f is 1,3,5,or 15 and n is at least 4.
请参阅:https://developer.apple.com/documentation/accelerate/1449930-vdsp_dct_createsetup