Ada Programming/Libraries/Ada.Numerics.Generic Complex Types
Appearance
This language feature is available from Ada 95 on.
Ada.Numerics.Generic_Complex_Types is a unit of the Predefined Language Environment since Ada 95.
The generic package Ada.Numerics.Generic_Complex_Types defines complex type for a defined floating point type. Being generic it can not only be used for predefined floating point types but also for any user defined floating type.
Usage
[edit | edit source]There is an extensive usage guide in Ada Programming/Mathematical calculations. Here the relevant extract:
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;
Specification
[edit | edit source]-- 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;
See also
[edit | edit source]Wikibook
[edit | edit source]- Ada Programming
- Ada Programming/Libraries
- Ada Programming/Mathematical calculations#Complex arithmethic
External examples
[edit source]- Search for examples of
Ada.Numerics.Generic_Complex_Typesin: Rosetta Code, GitHub (gists), any Alire crate or this Wikibook. - Search for posts related to
Ada.Numerics.Generic_Complex_Typesin: Stack Overflow, comp.lang.ada or any Ada related page.
Ada Reference Manual
[edit | edit source]Ada 95
[edit | edit source]Ada 2005
[edit | edit source]Ada 2012
[edit | edit source]Open-Source Implementations
[edit | edit source]FSF GNAT
- Specification: a-ngcoty.ads
- Body: a-ngcoty.adb
drake
- Specification: numerics/a-ngcoty.ads
- Body: numerics/a-ngcoty.adb
