Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set default parameters for vramp. #1

Merged
merged 2 commits into from
Apr 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store
/.build
/Packages
/DerivedData
/*.xcodeproj

*.log
Expand Down
2 changes: 1 addition & 1 deletion AccelerateArray.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "AccelerateArray"
s.version = "0.0.1"
s.version = "0.0.2"
s.summary = "Swift Array Extensions for the Apple Accelerate Framework"

# This description is used to generate tags and improve search results.
Expand Down
4 changes: 2 additions & 2 deletions Sources/AccelerateArray/vDSP.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public extension Array where Element == Float {

/// Build ramped vector
/// https://developer.apple.com/documentation/accelerate/1450369-vdsp_vramp
init(start: Element, step: Element, n: Int) {
init(start: Element = 0.0, step: Element = 1.0, n: Int) {
self.init(repeating: 0, count: n)
var a = start
var b = step
Expand Down Expand Up @@ -114,7 +114,7 @@ public extension Array where Element == Double {

/// Build ramped vector
/// https://developer.apple.com/documentation/accelerate/1449999-vdsp_vrampd
init(start: Element, step: Element, n: Int) {
init(start: Element = 0.0, step: Element = 1.0, n: Int) {
self.init(repeating: 0, count: n)
var a = start
var b = step
Expand Down
10 changes: 10 additions & 0 deletions Tests/AccelerateArrayTests/vDSP.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,27 @@ import XCTest
class VDSPTests: XCTestCase {

func testVrampFloat() {
XCTAssertEqual([Float].init(stop: 2.0), [0.0, 1.0])
XCTAssertEqual([Float].init(start: 0.0, stop: 1.0, step: 1.0), [0.0])
XCTAssertEqual([Float].init(start: 0.0, stop: 2.0, step: 1.1), [0.0, 1.1])
XCTAssertEqual([Float].init(start: -1.0, stop: 2.0, step: 1.0), [-1.0, 0.0, 1.0])
XCTAssertEqual([Float].init(start: -1.0, stop: -3.0, step: -1.0), [-1.0, -2.0])

XCTAssertEqual([Float].init(n: 2), [0.0, 1.0])
XCTAssertEqual([Float].init(start: 1.0, n: 2), [1.0, 2.0])
XCTAssertEqual([Float].init(start: 1.0, step: 2.0, n: 2), [1.0, 3.0])
}

func testVrampDouble() {
XCTAssertEqual([Double].init(stop: 2.0), [0.0, 1.0])
XCTAssertEqual([Double].init(start: 0.0, stop: 1.0, step: 1.0), [0.0])
XCTAssertEqual([Double].init(start: 0.0, stop: 2.0, step: 1.1), [0.0, 1.1])
XCTAssertEqual([Double].init(start: -1.0, stop: 2.0, step: 1.0), [-1.0, 0.0, 1.0])
XCTAssertEqual([Double].init(start: -1.0, stop: -3.0, step: -1.0), [-1.0, -2.0])

XCTAssertEqual([Double].init(n: 2), [0.0, 1.0])
XCTAssertEqual([Double].init(start: 1.0, n: 2), [1.0, 2.0])
XCTAssertEqual([Double].init(start: 1.0, step: 2.0, n: 2), [1.0, 3.0])
}

func testMtransFloatWhenEmpty() {
Expand Down