Ada 编程/库/Ada.Numerics.Generic Complex Types
外观
此语言功能从 Ada 95 开始可用。
Ada.Numerics.Generic_Complex_Types 是 预定义语言环境 自 Ada 95 以来的一部分。
该 泛型 包 Ada.Numerics.Generic_Complex_Types 为定义的 浮点类型 定义了复数类型。由于是泛型,它不仅可以用于预定义的浮点类型,也可以用于任何用户定义的浮点类型。
在 Ada 编程/数学计算 中有一个广泛的用法指南。这里摘录了相关内容
with
Ada.Numerics.Generic_Complex_Types;procedure
Numeric_7is
type
Value_Typeis
digits
12range
-999_999_999_999.0e999 .. 999_999_999_999.0e999;package
Complex_Typesis
new
Ada.Numerics.Generic_Complex_Types ( Value_Type);use
type
Complex_Types.Complex;
-- Standard Ada library specification -- Copyright (c) 2003-2018 Maxim Reznik <[email protected]> -- 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
Realis
digits
<>;package
Ada.Numerics.Generic_Complex_Typesis
pragma
Pure (Generic_Complex_Types);type
Complexis
record
Re, Im : Real'Base;end
record
;type
Imaginaryis
private
;pragma
Preelaborable_Initialization (Imaginary); i :constant
Imaginary; j :constant
Imaginary;function
Re (X : Complex)return
Real'Base;function
Im (X : Complex)return
Real'Base;function
Im (X : Imaginary)return
Real'Base;procedure
Set_Re (X :in
out
Complex; Re :in
Real'Base);procedure
Set_Im (X :in
out
Complex; Im :in
Real'Base);procedure
Set_Im (X :out
Imaginary; Im :in
Real'Base);function
Compose_From_Cartesian (Re, Im : Real'Base)return
Complex;function
Compose_From_Cartesian (Re : Real'Base)return
Complex;function
Compose_From_Cartesian (Im : Imaginary)return
Complex;function
Modulus (X : Complex)return
Real'Base;function
"abs" (Right : Complex)return
Real'Baserenames
Modulus;function
Argument (X : Complex)return
Real'Base;function
Argument (X : Complex; Cycle : Real'Base)return
Real'Base;function
Compose_From_Polar (Modulus, Argument : Real'Base)return
Complex;function
Compose_From_Polar (Modulus, Argument, Cycle : Real'Base)return
Complex;function
"+" (Right : Complex)return
Complex;function
"-" (Right : Complex)return
Complex;function
Conjugate (X : Complex)return
Complex;function
"+" (Left, Right : Complex)return
Complex;function
"-" (Left, Right : Complex)return
Complex;function
"*" (Left, Right : Complex)return
Complex;function
"/" (Left, Right : Complex)return
Complex;function
"**" (Left : Complex; Right : Integer)return
Complex;function
"+" (Right : Imaginary)return
Imaginary;function
"-" (Right : Imaginary)return
Imaginary;function
Conjugate (X : Imaginary)return
Imaginaryrenames
"-";function
"abs" (Right : Imaginary)return
Real'Base;function
"+" (Left, Right : Imaginary)return
Imaginary;function
"-" (Left, Right : Imaginary)return
Imaginary;function
"*" (Left, Right : Imaginary)return
Real'Base;function
"/" (Left, Right : Imaginary)return
Real'Base;function
"**" (Left : Imaginary; Right : Integer)return
Complex;function
"<" (Left, Right : Imaginary)return
Boolean;function
"<=" (Left, Right : Imaginary)return
Boolean;function
">" (Left, Right : Imaginary)return
Boolean;function
">=" (Left, Right : Imaginary)return
Boolean;function
"+" (Left : Complex; Right : Real'Base)return
Complex;function
"+" (Left : Real'Base; Right : Complex)return
Complex;function
"-" (Left : Complex; Right : Real'Base)return
Complex;function
"-" (Left : Real'Base; Right : Complex)return
Complex;function
"*" (Left : Complex; Right : Real'Base)return
Complex;function
"*" (Left : Real'Base; Right : Complex)return
Complex;function
"/" (Left : Complex; Right : Real'Base)return
Complex;function
"/" (Left : Real'Base; Right : Complex)return
Complex;function
"+" (Left : Complex; Right : Imaginary)return
Complex;function
"+" (Left : Imaginary; Right : Complex)return
Complex;function
"-" (Left : Complex; Right : Imaginary)return
Complex;function
"-" (Left : Imaginary; Right : Complex)return
Complex;function
"*" (Left : Complex; Right : Imaginary)return
Complex;function
"*" (Left : Imaginary; Right : Complex)return
Complex;function
"/" (Left : Complex; Right : Imaginary)return
Complex;function
"/" (Left : Imaginary; Right : Complex)return
Complex;function
"+" (Left : Imaginary; Right : Real'Base)return
Complex;function
"+" (Left : Real'Base; Right : Imaginary)return
Complex;function
"-" (Left : Imaginary; Right : Real'Base)return
Complex;function
"-" (Left : Real'Base; Right : Imaginary)return
Complex;function
"*" (Left : Imaginary; Right : Real'Base)return
Imaginary;function
"*" (Left : Real'Base; Right : Imaginary)return
Imaginary;function
"/" (Left : Imaginary; Right : Real'Base)return
Imaginary;function
"/" (Left : Real'Base; Right : Imaginary)return
Imaginary;private
type
Imaginaryis
new
Real'Base; i :constant
Imaginary := 1.0; j :constant
Imaginary := 1.0;end
Ada.Numerics.Generic_Complex_Types;
外部示例
[编辑源代码]- 在以下位置搜索 示例
Ada.Numerics.Generic_Complex_Types
:Rosetta Code, GitHub (gists), 任何 Alire 包 或 本维基教科书。 - 在以下位置搜索与
Ada.Numerics.Generic_Complex_Types
相关的 帖子:Stack Overflow, comp.lang.ada 或 任何与 Ada 相关的页面。
FSF GNAT
- 规范:a-ngcoty.ads
- 主体:a-ngcoty.adb
drake