LoginSignup
1
1

More than 3 years have passed since last update.

Swift swift-numericsを使用する

Posted at

概要

https://github.com/apple/swift-numerics
READE.MEより(Google翻訳)


Swift Numericsは、Swiftで数値計算をサポートするモジュールのセットを提供します。 これらのモジュールは、大きく2つのカテゴリに分類されます。
・標準ライブラリに入れるにはあまりにも特化されているが、単一の共通パッケージに集中化するのに十分一般的なAPI。
・標準ライブラリに将来含まれる可能性に向けて積極的に開発中のAPI。
これらの2つのカテゴリにはある程度の重複があり、最初のカテゴリで始まるAPIは、成熟して新しい用途が発見されると2番目のカテゴリに移行する場合があります。

Swift Packagesで取り込み


Xcode [File]-[Swift Packages]-[Add Package Dependency...]



https://github.com/apple/swift-numerics」指定



「Branch: master」使用



全Package Product指定



取り込み完了



Example

import Numerics

func sigmoid<T: Real>(_ x: T) -> T {
  1 / (1 + .exp(-x))
}

print(sigmoid(5.2))

Result

0.9945137011005495
Program ended with exit code: 0

memo

NumericはRealとComplexの@_exported import。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1