-
Book Overview & Buying
-
Table Of Contents
Swift High Performance
By :
Both iOS and OS X SDK have a very powerful framework that provides high-performance functions for working with matrices, vectors, signals, image processing, and math operations. It is called the Accelerate framework. The Accelerate framework is quite big, so we will take a look at only one part that is related to working with collections; it is the vDSP part. You can find out more about it at https://developer.apple.com/library/prerelease/ios/documentation/Accelerate/Reference/vDSPRef/index.html.
First, let's implement the very basic mapping, calculating, and sum operations using the Swift standard library:
let array = [1.0, 2.0]
let result = array.map { $0 + 3.0 }
result // [4.0, 5.0]
let sum = array.reduce(0, combine: +)
sum // 3This code is very clear and readable and doesn't need any comments. Let's try to do the same using Accelerate:
let array = [1.0, 2.0] var result = [Double](count: array.count, repeatedValue: 0.0) var add = 3.0 vDSP_vsaddD(array, 1, &add...
Change the font size
Change margin width
Change background colour