Fonctions élémentaires

public protocol ElementaryFunctions

Un type qui a des fonctions élémentaires disponibles.

Une « fonction élémentaire » est une fonction construite à partir des puissances, des racines, des exponentielles, des logarithmes, des fonctions trigonométriques (sin, cos, tan) et leurs inverses, et des fonctions hyperboliques (sinh, cosh, tanh) et leurs inverses.

La conformité à ce protocole signifie que tous ces blocs de construction sont disponibles en tant que fonctions statiques sur le type.

let x: Float = 1
let y = Float.sin(x) // 0.84147096
  • La racine carrée de x .

    Pour les types réels, si l'argument est négatif, soit le résultat est NaN, soit un échec de condition préalable se produit. Pour les types complexes, cette fonction a une branche coupée le long de l’axe réel négatif.

    Déclaration

    static func sqrt(_ x: Self) -> Self
  • Le cosinus de x .

    Pour les types réels, x est interprété comme un angle mesuré en radians.

    Déclaration

    static func cos(_ x: Self) -> Self
  • Le sinus de x .

    Pour les types réels, x est interprété comme un angle mesuré en radians.

    Déclaration

    static func sin(_ x: Self) -> Self
  • La tangente de x .

    Déclaration

    static func tan(_ x: Self) -> Self
  • La fonction acos.

    Déclaration

    static func acos(_ x: Self) -> Self
  • La fonction asin.

    Déclaration

    static func asin(_ x: Self) -> Self
  • La fonction atan.

    Déclaration

    static func atan(_ x: Self) -> Self
  • La fonction cosh.

    Déclaration

    static func cosh(_ x: Self) -> Self
  • La fonction sinh.

    Déclaration

    static func sinh(_ x: Self) -> Self
  • La fonction tanh.

    Déclaration

    static func tanh(_ x: Self) -> Self
  • La fonction acosh.

    Déclaration

    static func acosh(_ x: Self) -> Self
  • La fonction asinh.

    Déclaration

    static func asinh(_ x: Self) -> Self
  • La fonction atanh.

    Déclaration

    static func atanh(_ x: Self) -> Self
  • La fonction exp.

    Déclaration

    static func exp(_ x: Self) -> Self
  • La fonction exp2.

    Déclaration

    static func exp2(_ x: Self) -> Self
  • La fonction exp10.

    Déclaration

    static func exp10(_ x: Self) -> Self
  • La fonction expm1.

    Déclaration

    static func expm1(_ x: Self) -> Self
  • La fonction de journalisation.

    Déclaration

    static func log(_ x: Self) -> Self
  • La fonction log2.

    Déclaration

    static func log2(_ x: Self) -> Self
  • La fonction log10.

    Déclaration

    static func log10(_ x: Self) -> Self
  • La fonction log1p.

    Déclaration

    static func log1p(_ x: Self) -> Self
  • exp(y log(x)) calculé sans perte de précision intermédiaire.

    Pour les types réels, si x est négatif le résultat est NaN, même si y a une valeur intégrale. Pour les types complexes, il existe une branche coupée sur l’axe réel négatif.

    Déclaration

    static func pow(_ x: Self, _ y: Self) -> Self
  • x élevé à la n puissance.

    Déclaration

    static func pow(_ x: Self, _ n: Int) -> Self
  • La n ème racine de x .

    Pour les types réels, si x est négatif et n est pair, le résultat est NaN. Pour les types complexes, il existe une branche coupée le long de l’axe réel négatif.

    Déclaration

    static func root(_ x: Self, _ n: Int) -> Self