Apple introduces Swift Numerics to support numerical computing in Swift

0
2152
2 min read

Yesterday, Steve Canon, a member of Apple’s Swift Standard Library team announced a new open-source project called Swift Numerics. The goal behind this project is to enable the use of Swift language in new domains of programming.

What is Swift Numerics

Swift Numerics is a Swift package containing a set of fine-grained modules. These modules fall broadly under two categories. One, modules that are too specialized to be included into the standard library, but are general enough to be in a single common package. The second category includes those modules that are “under active development toward possible future inclusion in the standard library.”

Currently, Swift Numerics has two most-requested modules: Real and Complex. The Real module provides basic math functions proposed in SE-0246. This proposal was accepted but due to some limitations in the compiler, it is not yet possible to add the new functions directly to the standard library. Real provides the basic math functionalities in a separate module so that developers can start using them right away in their projects.

The Complex module introduces a Complex number type over an underlying Real type. It includes usual arithmetic operators for complex numbers. It is conformant to usual protocols such as Equatable, Hashable, Codable, and Numeric. The support for complex numbers can be especially useful when working with Fourier transforms and signal processing algorithms.


The modules included in Swift Numerics have minimal dependencies. For instance, the current modules only require the availability of the Swift and C standard libraries and the runtime support provided by compiler-rt. Also, the Swift Numerics package is open-sourced under the same license and contribution guidelines as the Swift project (Apache License 2.0).

In a discussion on Hacker News, many developers shared their views on Swift Numerics. A user commented,  “Really looking forward to ShapedArray. Eventually, a lot of what one might do with Python may be available in Swift.”

Read the official announcement by Apple to know more about Swift Numerics. Also, check out its GitHub repository.

Read Next

Swift shares diagnostic architecture improvements that will be part of the Swift 5.2 release

Developers from the Swift for TensorFlow project propose adding first-class differentiable programming to Swift

Declarative UI programming faceoff: Apple’s SwiftUI vs Google’s Flutter

Introducing SwiftWasm, a tool for compiling Swift to WebAssembly

Swift is improving the UI of its generics model with the “reverse generics” system