for var stack:[Double]
for i in 1...N {
stack[sp+i] += stack[sp+b+i]
}
conveniently becomes
vDSP.add(stack[sp+1 ... sp+N], stack[sp+b+1 ... sp+b+N], &stack[sp+1 ... sp+N])
since ArraySlice<Double>
conforms to AccelerateBuffer
.
What would be the equivalent Accelerate magic for var stack: [Complex]
(where Complex is defined the usual way).
Bonus points if it is simple to use in a generic. i.e.
func evaluate(T:Computable) { // Double and Complex conform to Computable
var stack:[T]
etc...
vDSP_zvaddD looks promising, but [Complex] interleaves real and imaginary parts, and to use vDSP_zvaddD would seem to require getting an UnsafePointer<DSPDoubleSplitComplex>
from ArraySlice<Double>
.
(I will be needing all the usual arithmetic and transcendental operations on double precision Double and Complex, and mixed vector-scalar operations, as well....)