Complex

1.2.1

Swift Complex Numbers
SomeRandomiOSDev/Complex

What's New

1.2.1

2021-10-20T23:56:46Z
  • Modernized the project
    • Regenerated the project using Project Template
    • Added support for watchOS unit tests
    • Added various Github Actions
  • Fixed up a few issues present in later versions of Xcode
  • Added Swift's Float16 type as part of the unit tests

Complex

Codacy Badge License MIT CocoaPods Compatible Carthage Compatible Platform Linux Code Coverage

Swift Package Xcode Project Cocoapods Carthage

Complex is a lightweight framework designed for representing and working with complex numbers for iOS, macOS, tvOS, and watchOS.

Installation

Complex is available through CocoaPods, Carthage and the Swift Package Manager.

To install via CocoaPods, simply add the following line to your Podfile:

pod 'Complex'

To install via Carthage, simply add the following line to your Cartfile:

github "SomeRandomiOSDev/Complex"

To install via the Swift Package Manager add the following line to your Package.swift file's dependencies:

.package(url: "https://github.com/SomeRandomiOSDev/Complex.git", from: "1.0.0")

Usage

First import Complex at the top of your Swift file:

import Complex

After importing, use of complex numbers is as simple as can be:

let input = Complex<Double>(real: 4.31, imaginary: 2.0)
let scale = Complex<Double>(real: 1.5, imaginary: 2.718)

let output = input * scale

...

The Complex type also has builtin functionality specific to complex numbers, such as conjugates and modulus/angle (for converting to polar coordinates):

let complex = Complex<Double>(real: 7.0, imaginary: -4.1)

// Equal to 7.0 + 4.1i
let conjugate = ~complex // or complex.conjugate()

let (modulus, angle) = (complex.modulus, complex.angle)

...

Note

The Swift library team has released their own Complex type as part of the Swift Numerics library. This library is likely to be archived in the future unless there is a continued need for this library to continue to be maintained. You can find more information about the new Complex type here

Contributing

If you have need for a specific feature or you encounter a bug, please open an issue. If you extend the functionality of Complex yourself or you feel like fixing a bug yourself, please submit a pull request.

Author

Joe Newton, somerandomiosdev@gmail.com

License

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

Description

  • Swift Tools 5.0.0
View More Packages from this Author

Dependencies

Last updated: Sun Oct 20 2024 09:58:14 GMT-0900 (Hawaii-Aleutian Daylight Time)