I'm attempting to use the vDSP_conv
function in Accelerate here. One of the arguments to vDSP_conv
is a const float *__F
that "needs to point to the last vector element". I'm not extremely familiar with using pointers in Swift, so I'm at a loss for how to create a pointer to the last array element of a Swift array.
Can anyone provide some insight?
/** EDIT **/
Function specification that I am trying to call:
func vDSP_conv(_ __A: UnsafePointer<Float>, _ __IA: vDSP_Stride, _ __F: UnsafePointer<Float>, _ __IF: vDSP_Stride, _ __C: UnsafeMutablePointer<Float>, _ __IC: vDSP_Stride, _ __N: vDSP_Length, _ __P: vDSP_Length)
So far, I have this code. I need y
to point be a pointer to the last element in the array as conv
starts at the end of the array and progresses to the front
public func conv(x: [Float], y: [Float]) -> [Float] {
var result = [Float](x)
let inputLength:Int = x.count
let outputLength:Int = inputLength + y.count - 1
vDSP_conv(x, 1, y, 1, &result, 1, vDSP_Length(inputLength), vDSP_Length(outputLength))
return result
}