Tuesday, April 7, 2015 [Tweets] [Favorites]

Swift, Accelerate, and Generics

Chris Liscio:

After spending a while in a Playground, I managed to get a generic vDSP multiply routine written that could work on both Slice<Float> and [Float].

For no good reason at all, I decided that I should brain-dump this approach into my SMUGMath-Swift project before I lose the playground to the sands of time.

The “magic” is in the way that I was able to lean on the withUnsafeBufferPointer method that exists for both collection types, and then also specify some additional type clauses to ensure we’re working with Float vs Double floating point types.

Comments

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment