Apple Releases Swift’s Math Computing Project: Swift Numerics

Swift’s Standard Library team member, Steve Canon, announced that Swift’s open source ecosystem is another addition to Swift’s. This is the Swift Barno API, hosted on GitHub, to quickly fill some important gaps in the existing API of the Standard Library and open up new areas for Swift programming.

Apple Releases Swift's Math Computing Project: Swift Numerics

Swift Numerics is said to provide Swift developers with the basis for building numerical operations, with relevant numerical computing modules bundled together and released as separate Swift components.

Steve Canon has built two high-sounding mathematical computing modules into Swift Numeric’s GitHub repository, the Real Number module and the Complex Number module that provides complex operations. The SE-0246 proposal proposes to include the Basic Mathematical Functions API in Swift, providing common operations such as trigonometry and xies. This proposal has been accepted, but due to compiler limitations, the API cannot yet be added to the standard library, so the real module will provide the API in a separate module, and developers can now use these features in the project.

The real module defines three protocols. The most common is ElementaryFunctions, which provides the following functions:

Index function: exp, expMinusOne

Log function: log,log (onePlus:)

Triangle function: cos, sin, tan

Anti-triangular function: acos, asin, atan

Hyperbolic function: cosh, sinh, tanh

Anti-hyperbolic function: acosh, asinh, atanh

Power and root functions: pow, sqrt, root

The complex module is created on top of the underlying real type (officially the complex module is built on the real module). We all know that complex numbers are often used in mathematical calculations, especially when converting Fourier, when working with audio or circuit simulation. Steve Canon notes that libraries often automatically hide these complex messages when used by developers on a daily basis, but complex modules are an important tool when developing relevant libraries.

Steve Canon also explains why Swift Numerics is not available in the standard library, but is being published in the form of components. He says there are many considerations, but the main reason is that he thinks not all content should be included in the standard library. Over time, some of the features in Swift Numerics may be put into the standard library of functions, but by default, some modules should not be added to each project by default, they should have a place of their own, and Swift Numerics is a collection of such mathematical computing modules, just like SwiftNIO components are designed to provide network-related functionality as well.

In addition, the benefits of component packaging include that updates to Swift Numerics will not be subject to the time limit for the release of the Swift version, and developers can release test modules to experiment before entering a stable version.

Steve Canon also mentions that they will then add important ShapedArray protocols and support types for Swift Numerics, making it easy for developers to express multi-dimensional homogenous data, and will add support for Float16.

Ref: https://www.ithome.com.tw/news/134151

Add a Comment

Your email address will not be published. Required fields are marked *