Skip to content

Added unit tests for matrix arithmetic #108

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

Merged
merged 9 commits into from
Aug 29, 2019
Prev Previous commit
Fixed unit tests for Matrix.sum(_:axies:)
  • Loading branch information
regexident committed Aug 29, 2019
commit 0c8f39e04738031b1621f6c41a3a8696ef9e8522
35 changes: 34 additions & 1 deletion Tests/SurgeTests/MatrixTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,23 @@ class MatrixTests: XCTestCase {
XCTAssertEqual(actual, expected, accuracy: 1e-8)
}

func test_sum_matrix_rows_double() {
typealias Scalar = Double

let lhs: Matrix<Scalar> = [
[1, 2, 3],
[4, 5, 6],
]

let actual = sum(lhs, axies: .row)
let expected: Matrix<Scalar> = [
[6],
[15],
]

XCTAssertEqual(actual, expected, accuracy: 1e-5)
}

func test_sum_matrix_rows_float() {
typealias Scalar = Float

Expand All @@ -523,7 +540,7 @@ class MatrixTests: XCTestCase {
[4, 5, 6],
]

let actual = sum(lhs, axies: .column)
let actual = sum(lhs, axies: .row)
let expected: Matrix<Scalar> = [
[6],
[15],
Expand All @@ -532,6 +549,22 @@ class MatrixTests: XCTestCase {
XCTAssertEqual(actual, expected, accuracy: 1e-5)
}

func test_sum_matrix_columns_double() {
typealias Scalar = Double

let lhs: Matrix<Scalar> = [
[1, 2, 3],
[4, 5, 6],
]

let actual = sum(lhs, axies: .column)
let expected: Matrix<Scalar> = [
[5, 7, 9],
]

XCTAssertEqual(actual, expected, accuracy: 1e-5)
}

func test_sum_matrix_columns_float() {
typealias Scalar = Float

Expand Down