1

From what I understood, an UnsafePointer presents the pointee as immutable and an UnsafeMutablePointer presents the pointee as mutable. But the signature for the vDSP function vDSP_zrvmul is as follows:

func vDSP_zrvmul(_ __A: UnsafePointer<DSPSplitComplex>, 
               _ __IA: vDSP_Stride, 
               _ __B: UnsafePointer<Float>, 
               _ __IB: vDSP_Stride, 
               _ __C: UnsafePointer<DSPSplitComplex>, 
               _ __IC: vDSP_Stride, 
               _ __N: vDSP_Length)

__C is supposed to be the output vector, but it's not mutable… what am I missing? Thanks for reading.

Rogare
  • 3,234
  • 3
  • 27
  • 50

1 Answers1

1

__A and__C are pointers to DSPSplitComplex:

public struct DSPSplitComplex {
    public var realp: UnsafeMutablePointer<Float>
    public var imagp: UnsafeMutablePointer<Float>
}

which contain mutable pointers to arrays of floating point values.

vDSP_zrvmul writes the output to the arrays pointed to by __C.realp and __C.imagp, but __C itself is not mutated.

Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382
  • OK, so the contents of the `__A` and `__C` pointers are references themselves; these references aren't changed (just their values), hence the immutability. Got it. Though I think the two properties here should be `UnsafeMutablePointer`? – Rogare Jan 18 '18 at 19:59
  • @Rogare: Yes, I mixed that up with DSPDoubleSplitComplex. – Martin R Jan 18 '18 at 20:00