diff --git a/Sources/Algebra/Abelian.swift b/Sources/Algebra/Abelian.swift new file mode 100644 index 0000000..c99d01f --- /dev/null +++ b/Sources/Algebra/Abelian.swift @@ -0,0 +1,9 @@ +// +// Abelian.swift +// Algebra +// +// Created by James Bean on 9/6/19. +// + +/// Interface defining a `Group` which is also commutative. +public protocol Abelian: Group { } diff --git a/Sources/Algebra/AdditiveGroup.swift b/Sources/Algebra/AdditiveGroup.swift index 0b780d1..0aee363 100644 --- a/Sources/Algebra/AdditiveGroup.swift +++ b/Sources/Algebra/AdditiveGroup.swift @@ -5,19 +5,27 @@ // Created by Benjamin Wetherfield on 10/11/2018. // +/// The requirements for a type to display the behaviors of an `AdditiveGroup`. +/// +/// The `AdditiveGroup` builds upon the `AdditiveMonoid` with an `inverse` operation. public protocol AdditiveGroup: Additive, Invertible { - + + /// - Returns: The additive inverse of this `AdditiveGroup` element. static prefix func - (_ element: Self) -> Self + + /// - Returns: The difference between two `AdditiveGroup` elements. static func - (lhs: Self, rhs: Self) -> Self } extension AdditiveGroup { - - static prefix func - (_ element: Self) -> Self { + + /// - Returns: The additive inverse of this `AdditiveGroup` element. + public static prefix func - (_ element: Self) -> Self { return element.inverse } - - static func - (lhs: Self, rhs: Self) -> Self { + + /// - Returns: The difference between two `AdditiveGroup` elements. + public static func - (lhs: Self, rhs: Self) -> Self { return lhs + -rhs } } diff --git a/Tests/DataStructuresPerformanceTests/GraphPerformanceTests/GraphPerformanceTests.swift b/Tests/DataStructuresPerformanceTests/GraphPerformanceTests/GraphPerformanceTests.swift index 4ffa556..11bae29 100644 --- a/Tests/DataStructuresPerformanceTests/GraphPerformanceTests/GraphPerformanceTests.swift +++ b/Tests/DataStructuresPerformanceTests/GraphPerformanceTests/GraphPerformanceTests.swift @@ -50,7 +50,7 @@ class GraphPerformanceTests: XCTestCase { XCTAssert(benchmark.performance(is: .constant)) } - #warning("FIXME: Assess why the testEdgeFromSourceInCompleteGraph benchmark test files. It is currently disabled.") + // FIXME: Assess why the testEdgeFromSourceInCompleteGraph benchmark test files func DISABLED_testEdgeFromSourceInCompleteGraph_O_n() { let benchmark = Benchmark.mutating( testPoints: Scale.small, diff --git a/Tests/DataStructuresTests/MatrixTests.swift b/Tests/DataStructuresTests/MatrixTests.swift index b963184..e6f4ad6 100644 --- a/Tests/DataStructuresTests/MatrixTests.swift +++ b/Tests/DataStructuresTests/MatrixTests.swift @@ -12,11 +12,9 @@ import DataStructures class MatrixTests: XCTestCase { func testInit() { - let amountRows = 2 let amountColumns = 3 - var matrix = Matrix(height: amountRows, width: amountColumns, initial: 0) - + let matrix = Matrix(height: amountRows, width: amountColumns, initial: 0) for row in 0 ..< amountRows { for column in 0 ..< amountColumns { XCTAssertEqual(matrix[row, column], 0)