跳轉到內容

Ada 程式設計/庫/Ada.Numerics.Generic Elementary Functions

來自華夏公益教科書,開放的書籍,開放的世界

Ada. Time-tested, safe and secure.
Ada. 經時間考驗,安全可靠。

此語言功能從 Ada 95 開始提供。

Ada.Numerics.Generic_Elementary_Functions預定義語言環境 自 Ada 95 以來的一部分。

通用包 Ada.Numerics.Generic_Elementary_Functions 為浮點型別定義了各種數學函式。由於它是通用的,它不僅可以用於預定義的浮點型別,還可以用於任何使用者定義的浮點型別。

Ada 程式設計/數學計算 中有一個廣泛的用法指南。以下是相關的摘錄

檔案:numeric_4.adb (檢視, 純文字, 下載頁面, 瀏覽所有)
with Ada.Numerics.Generic_Elementary_Functions;

procedure Numeric_4 is

  type Value_Type is digits 12 range
     -999_999_999_999.0e999 .. 999_999_999_999.0e999;

  package Value_Functions is new Ada.Numerics.Generic_Elementary_Functions (
     Value_Type);
--                     Standard Ada library specification
--   Copyright (c) 2003-2018 Maxim Reznik <reznikmm@gmail.com>
--   Copyright (c) 2004-2016 AXE Consultants
--   Copyright (c) 2004, 2005, 2006 Ada-Europe
--   Copyright (c) 2000 The MITRE Corporation, Inc.
--   Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
--   SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
-- -------------------------------------------------------------------------

generic
   type Float_Type is digits <>;

package Ada.Numerics.Generic_Elementary_Functions is
   pragma Pure (Generic_Elementary_Functions);

   function Sqrt
     (X           : Float_Type'Base) return Float_Type'Base;
   function Log
     (X           : Float_Type'Base) return Float_Type'Base;
   function Log
     (X, Base     : Float_Type'Base) return Float_Type'Base;
   function Exp
     (X           : Float_Type'Base) return Float_Type'Base;
   function "**"    (Left, Right : Float_Type'Base) return Float_Type'Base;

   function Sin
     (X           : Float_Type'Base) return Float_Type'Base;
   function Sin
     (X, Cycle    : Float_Type'Base) return Float_Type'Base;
   function Cos
     (X           : Float_Type'Base) return Float_Type'Base;
   function Cos
     (X, Cycle    : Float_Type'Base) return Float_Type'Base;
   function Tan
     (X           : Float_Type'Base) return Float_Type'Base;
   function Tan
     (X, Cycle    : Float_Type'Base) return Float_Type'Base;
   function Cot
     (X           : Float_Type'Base) return Float_Type'Base;
   function Cot
     (X, Cycle    : Float_Type'Base) return Float_Type'Base;

   function Arcsin
     (X           : Float_Type'Base) return Float_Type'Base;
   function Arcsin
     (X, Cycle    : Float_Type'Base) return Float_Type'Base;
   function Arccos
     (X           : Float_Type'Base) return Float_Type'Base;
   function Arccos
     (X, Cycle    : Float_Type'Base) return Float_Type'Base;
   function Arctan  (Y           : Float_Type'Base;
                     X           : Float_Type'Base := 1.0)
                    return Float_Type'Base;
   function Arctan  (Y           : Float_Type'Base;
                     X           : Float_Type'Base := 1.0;
                     Cycle       : Float_Type'Base) return Float_Type'Base;
   function Arccot  (X           : Float_Type'Base;
                     Y           : Float_Type'Base := 1.0)
                    return Float_Type'Base;
   function Arccot  (X           : Float_Type'Base;
                     Y           : Float_Type'Base := 1.0;
                     Cycle       : Float_Type'Base) return Float_Type'Base;

   function Sinh
     (X           : Float_Type'Base) return Float_Type'Base;
   function Cosh
     (X           : Float_Type'Base) return Float_Type'Base;
   function Tanh
     (X           : Float_Type'Base) return Float_Type'Base;
   function Coth
     (X           : Float_Type'Base) return Float_Type'Base;
   function Arcsinh
     (X           : Float_Type'Base) return Float_Type'Base;
   function Arccosh
     (X           : Float_Type'Base) return Float_Type'Base;
   function Arctanh
     (X           : Float_Type'Base) return Float_Type'Base;
   function Arccoth
     (X           : Float_Type'Base) return Float_Type'Base;

end Ada.Numerics.Generic_Elementary_Functions;

華夏公益教科書

[編輯 | 編輯原始碼]

Ada 參考手冊

[編輯 | 編輯原始碼]

開源實現

[編輯 | 編輯原始碼]

FSF GNAT

drake

華夏公益教科書