1

In Swift 4.0 Xcode 9.4.1 using the vDSP_zvmags function and passing an inout float array variable works however in Swift 4.2 Xcode 10.1 complains that one cannot pass an array parameter when a expecting a float type.

//Class variable
private var magnitudes: [Float]!    

self.magnitudes = [Float](repeating: 0.0, count: self.halfSize)
vDSP_zvmags(&(self.complexBuffer!), 1, &self.magnitudes!, 1, UInt(self.halfSize))

Error message:

Cannot convert value of type '[Float]' to expected argument type 'Float'

&self.magnitudes! is underlined in red.

Can someone shed some light as to why it is acceptable in Swift 4.0 and not acceptable in Swift 4.2? The function does not appear to have changed between the 2 functions, I have checked in Apple's documentation and looked at the vDSP library doc.

Alexander
  • 1,424
  • 18
  • 23
  • Cannot reproduce, but the problem my depend on your property declarations, which are not shown. Can you post a [mcve] ? – Martin R Nov 09 '18 at 06:46
  • @MartinR thanks for the response, I will edit my question – Alexander Nov 09 '18 at 09:26
  • @MartinR it seems if I initialize magnitudes to empty float array as a class variable then it works... still don't understand what the problem is.. – Alexander Nov 09 '18 at 10:14

1 Answers1

1

If the class variable is initialized on declaration to empty float array the error disappears.

Alexander
  • 1,424
  • 18
  • 23