Ada 编程/库/Ada.Numerics.Generic Complex Types
外观
此语言功能从 Ada 95 开始可用。
Ada.Numerics.Generic_Complex_Types 是 预定义语言环境 自 Ada 95 以来的一部分。
该 泛型 包 Ada.Numerics.Generic_Complex_Types 为定义的 浮点类型 定义了复数类型。由于是泛型,它不仅可以用于预定义的浮点类型,也可以用于任何用户定义的浮点类型。
在 Ada 编程/数学计算 中有一个广泛的用法指南。这里摘录了相关内容
withAda.Numerics.Generic_Complex_Types;procedureNumeric_7istypeValue_Typeisdigits12range-999_999_999_999.0e999 .. 999_999_999_999.0e999;packageComplex_TypesisnewAda.Numerics.Generic_Complex_Types ( Value_Type);usetypeComplex_Types.Complex;
-- 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 -- -------------------------------------------------------------------------generictypeRealisdigits<>;packageAda.Numerics.Generic_Complex_TypesispragmaPure (Generic_Complex_Types);typeComplexisrecordRe, Im : Real'Base;endrecord;typeImaginaryisprivate;pragmaPreelaborable_Initialization (Imaginary); i :constantImaginary; j :constantImaginary;functionRe (X : Complex)returnReal'Base;functionIm (X : Complex)returnReal'Base;functionIm (X : Imaginary)returnReal'Base;procedureSet_Re (X :inoutComplex; Re :inReal'Base);procedureSet_Im (X :inoutComplex; Im :inReal'Base);procedureSet_Im (X :outImaginary; Im :inReal'Base);functionCompose_From_Cartesian (Re, Im : Real'Base)returnComplex;functionCompose_From_Cartesian (Re : Real'Base)returnComplex;functionCompose_From_Cartesian (Im : Imaginary)returnComplex;functionModulus (X : Complex)returnReal'Base;function"abs" (Right : Complex)returnReal'BaserenamesModulus;functionArgument (X : Complex)returnReal'Base;functionArgument (X : Complex; Cycle : Real'Base)returnReal'Base;functionCompose_From_Polar (Modulus, Argument : Real'Base)returnComplex;functionCompose_From_Polar (Modulus, Argument, Cycle : Real'Base)returnComplex;function"+" (Right : Complex)returnComplex;function"-" (Right : Complex)returnComplex;functionConjugate (X : Complex)returnComplex;function"+" (Left, Right : Complex)returnComplex;function"-" (Left, Right : Complex)returnComplex;function"*" (Left, Right : Complex)returnComplex;function"/" (Left, Right : Complex)returnComplex;function"**" (Left : Complex; Right : Integer)returnComplex;function"+" (Right : Imaginary)returnImaginary;function"-" (Right : Imaginary)returnImaginary;functionConjugate (X : Imaginary)returnImaginaryrenames"-";function"abs" (Right : Imaginary)returnReal'Base;function"+" (Left, Right : Imaginary)returnImaginary;function"-" (Left, Right : Imaginary)returnImaginary;function"*" (Left, Right : Imaginary)returnReal'Base;function"/" (Left, Right : Imaginary)returnReal'Base;function"**" (Left : Imaginary; Right : Integer)returnComplex;function"<" (Left, Right : Imaginary)returnBoolean;function"<=" (Left, Right : Imaginary)returnBoolean;function">" (Left, Right : Imaginary)returnBoolean;function">=" (Left, Right : Imaginary)returnBoolean;function"+" (Left : Complex; Right : Real'Base)returnComplex;function"+" (Left : Real'Base; Right : Complex)returnComplex;function"-" (Left : Complex; Right : Real'Base)returnComplex;function"-" (Left : Real'Base; Right : Complex)returnComplex;function"*" (Left : Complex; Right : Real'Base)returnComplex;function"*" (Left : Real'Base; Right : Complex)returnComplex;function"/" (Left : Complex; Right : Real'Base)returnComplex;function"/" (Left : Real'Base; Right : Complex)returnComplex;function"+" (Left : Complex; Right : Imaginary)returnComplex;function"+" (Left : Imaginary; Right : Complex)returnComplex;function"-" (Left : Complex; Right : Imaginary)returnComplex;function"-" (Left : Imaginary; Right : Complex)returnComplex;function"*" (Left : Complex; Right : Imaginary)returnComplex;function"*" (Left : Imaginary; Right : Complex)returnComplex;function"/" (Left : Complex; Right : Imaginary)returnComplex;function"/" (Left : Imaginary; Right : Complex)returnComplex;function"+" (Left : Imaginary; Right : Real'Base)returnComplex;function"+" (Left : Real'Base; Right : Imaginary)returnComplex;function"-" (Left : Imaginary; Right : Real'Base)returnComplex;function"-" (Left : Real'Base; Right : Imaginary)returnComplex;function"*" (Left : Imaginary; Right : Real'Base)returnImaginary;function"*" (Left : Real'Base; Right : Imaginary)returnImaginary;function"/" (Left : Imaginary; Right : Real'Base)returnImaginary;function"/" (Left : Real'Base; Right : Imaginary)returnImaginary;privatetypeImaginaryisnewReal'Base; i :constantImaginary := 1.0; j :constantImaginary := 1.0;endAda.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
