DEVELOPMENT EDITION · 769442725406
Library Reference
On this page

Ada.Numerics.Generic_Elementary_Functions

Five elementary functions over a chosen floating type.

Read the family guide for representation, selection and resource rules. The complete declaration page retains exact signatures/contracts; the source specification is the implementation baseline.

Availability and ownership

The functions call the C library's libm; their contracts, which give each function's domain and result range, are trusted. No error bound is stated.

A client proof uses these contracts without proving the body again (see library assurance). Global => null excludes package-global effects, not changes made through an in out argument.

Import and instantiate

Place the declaration in a declarative part, with the actuals your program needs.

with Ada.Numerics.Generic_Elementary_Functions;
package Instance_Name is new Ada.Numerics.Generic_Elementary_Functions (Long_Float);
import Ada.Numerics.Generic_Elementary_Functions;
package Instance_Name = new Ada.Numerics.Generic_Elementary_Functions<Long_Float>;

Vibe does not instantiate library generics; see library use across syntaxes. In Varc, keep each name's declared spelling and write & on arguments the call changes.

Contract and lifecycle reading

A Pre condition is the caller's obligation; a Post is what a normal return guarantees. What a postcondition does not state, a client cannot assume. Ghost functions are for contracts and ghost code. The family guide describes copying, lifetime, order and cost.

API 001

Generic formals (declaration) — Generic actuals establish this instance's nominal types and declared operations. Private formals require suitable definite nonlimited actuals; capacity/comparison/float restrictions are shown below. Defaulted comparison is resolved from the actual type, not an automatic proof of ordering laws.

Declared interface:

generic
   type Float_Type is digits <>;

API 002

Sqrt (declaration) — Compute the trusted elementary square root for X>=0, with only the declared result bounds promised.

Before this operation, establish:

X >= 0.0

On normal return the declared contract establishes:

Sqrt'Result >= 0.0 and then Sqrt'Result <= (if X <= 1.0 then 1.0 else X)

API 003

Exp (declaration) — Compute the trusted elementary exponential for X<=80, with nonnegative result promised.

Before this operation, establish:

X <= 80.0

On normal return the declared contract establishes:

Exp'Result >= 0.0

API 004

Log (declaration) — Compute the trusted elementary natural logarithm for X>0, with the declared finite result bounds.

Before this operation, establish:

X > 0.0

On normal return the declared contract establishes:

Log'Result in -800.0 .. 800.0

API 005

Sin (declaration) — Compute the trusted elementary sine with result constrained to [-1,1]; no exact transcendental error contract is declared.

On normal return the declared contract establishes:

Sin'Result in -1.0 .. 1.0

API 006

Cos (declaration) — Compute the trusted elementary cosine with result constrained to [-1,1].

On normal return the declared contract establishes:

Cos'Result in -1.0 .. 1.0

API 007

Log (declaration) — The logarithm of X to a base: positive X, and a base of at least 2 or at most 0.5 (APL's a ⍟ b).

API 008

Tan (declaration) — The tangent.

API 009

Arcsin (declaration) — The arcsine of X in -1 .. 1.

API 010

Arccos (declaration) — The arccosine of X in -1 .. 1.

API 011

Arctan (declaration) — The arctangent.

API 012

Sinh (declaration) — The hyperbolic sine of X in -80 .. 80.

API 013

Cosh (declaration) — The hyperbolic cosine of X in -80 .. 80.

API 014

Tanh (declaration) — The hyperbolic tangent.

API 015

Arcsinh (declaration) — The inverse hyperbolic sine.

API 016

Arccosh (declaration) — The inverse hyperbolic cosine of X of at least 1.

API 017

Arctanh (declaration) — The inverse hyperbolic tangent of X strictly between -1 and 1.