Go to file
Vincent Esche 2659ad8f20 Made `Vector<Scalar>`’s `var scalars` public, adding explicit test for changes in dimension 2019-08-29 11:35:24 +02:00
Metadata Add macOS, tvOS and watchOS targets (#74) 2017-11-18 10:51:01 -08:00
Sources/Surge Made `Vector<Scalar>`’s `var scalars` public, adding explicit test for changes in dimension 2019-08-29 11:35:24 +02:00
Surge.playground Add UnsafeMemory abstraction (#77) 2018-04-01 12:23:36 -07:00
Surge.xcodeproj Added `Vector<Scalar>` type and corresponding unit tests 2019-08-29 11:35:24 +02:00
Surge.xcworkspace Add UnsafeMemory abstraction (#77) 2018-04-01 12:23:36 -07:00
Tests/SurgeTests Added matrix-vector multiplication 2019-08-29 11:35:24 +02:00
.gitignore Update .gitignore and remove user-specific files 2017-09-18 21:34:22 -07:00
.swift-version Migrated to Swift 5 (#97) 2019-04-24 09:04:38 -07:00
.swiftlint.yml Enable opt-in SwiftLint rules 2017-11-25 12:17:56 -08:00
.travis.yml Migrated to Swift 5 (#97) 2019-04-24 09:04:38 -07:00
LICENSE Add UnsafeMemory abstraction (#77) 2018-04-01 12:23:36 -07:00
Package.swift Add UnsafeMemory abstraction (#77) 2018-04-01 12:23:36 -07:00
README.md Added human-readable labels and links to corresponding Wikipedia articles for each of the listed functions in the README file 2019-07-31 23:55:32 +02:00
Surge.podspec Use Xcode 9.3 in TravisCI 2018-04-21 14:00:24 -07:00

README.md

Surge

Build Status GitHub license Carthage compatible SPM compatible CocoaPods

Surge is a Swift library that uses the Accelerate framework to provide high-performance functions for matrix math, digital signal processing, and image manipulation.

Accelerate exposes SIMD instructions available in modern CPUs to significantly improve performance of certain calculations. Because of its relative obscurity and inconvenient APIs, Accelerate is not commonly used by developers, which is a shame, since many applications could benefit from these performance optimizations.

Surge aims to bring Accelerate to the mainstream, making it as easy (and nearly as fast, in most cases) to perform computation over a set of numbers as for a single member.

Though, keep in mind: Accelerate is not a silver bullet. Under certain conditions, such as performing simple calculations over a small data set, Accelerate can be out-performed by conventional algorithms. Always benchmark to determine the performance characteristics of each potential approach.


Curious about the name Surge? Back in the mid 90's, Apple, IBM, and Motorola teamed up to create AltiVec (a.k.a the Velocity Engine), which provided a SIMD instruction set for the PowerPC architecture. When Apple made the switch to Intel CPUs, AltiVec was ported to the x86 architecture and rechristened Accelerate. The derivative of Accelerate (and second derivative of Velocity) is known as either jerk, jolt, surge, or lurch, hence the name of this library.


Installation

The infrastructure and best practices for distributing Swift libraries are currently in flux during this beta period of Swift & Xcode. In the meantime, you can add Surge as a git submodule, drag the Surge.xcodeproj file into your Xcode project, and add Surge.framework as a dependency for your target.

Surge uses Swift 5. This means that your code has to be written in Swift 5 due to current binary compatibility limitations.

Swift Package Manager

To use Swift Package Manager add Surge to your Package.swift file:

let package = Package(
    name: "myproject",
    dependencies: [
        .package(url: "https://github.com/mattt/Surge.git", .upToNextMajor(from: "2.0.0")),
    ],
    targets: [
        .target(
            name: "myproject",
            dependencies: ["Surge"]),
    ]
)

Then run swift build.

CocoaPods

To use CocoaPods add Surge to your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'Surge', '~> 2.0.0'
end

Then run pod install.

Carthage

To use Carthage add Surge to your Cartfile:

github "mattt/Surge" ~> 2.0.0

Then run carthage update and use the framework in Carthage/Build/<platform>.


Inventory

Surge functions are named according to their corresponding "Math.h" functions, where applicable (omitting f and d affixes, since type information is communicated and enforced by the language's type system).

Arithmetic

Auxiliary

Convolution

Exponential

FFT

Hyperbolic

Matrix

Power

Trigonometric

Usage

Computing Sum of [Double]

import Surge

let n = [1.0, 2.0, 3.0, 4.0, 5.0]
let sum = Surge.sum(n) // 15.0

Computing Product of Two [Double]s

import Surge

let a = [1.0, 3.0, 5.0, 7.0]
let b = [2.0, 4.0, 6.0, 8.0]

let product = Surge.mul(a, b) // [2.0, 12.0, 30.0, 56.0]

License

Surge is available under the MIT license. See the LICENSE file for more info.