Debian Codegraph @

source_2005/numerics.mss

raw
1 @comment{ $Source: e:\\cvsroot/ARM/Source/numerics.mss,v $ }
2 @comment{ $Revision: 1.54 $ $Date: 2006/10/19 06:40:29 $ $Author: Randy $ }
3 @Part(numerics, Root="ada.mss")
4
5 @Comment{$Date: 2006/10/19 06:40:29 $}
6
7 @LabeledNormativeAnnex{Numerics}
8 @begin{Intro}
9 @Defn{numerics}
10 The Numerics Annex specifies
11 @begin{itemize}
12 features for complex arithmetic, including complex I/O;
13
14 a mode (@lquotes@;strict mode@rquotes@;), in which the predefined arithmetic operations of
15 floating point and fixed point types and the functions and operations of
16 various predefined packages have to provide guaranteed accuracy or conform
17 to other numeric performance requirements, which the Numerics Annex also
18 specifies;
19
20 a mode (@lquotes@;relaxed mode@rquotes@;), in which no accuracy or other numeric performance
21 requirements need be satisfied, as for implementations not conforming to the
22 Numerics Annex;
23
24 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00296-01]}
25 models of floating point and fixed point arithmetic on which the accuracy
26 requirements of strict mode are based;@Chg{Version=[2],New=[],Old=[ and]}
27
28 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00296-01]}
29 the definitions of the model-oriented attributes of floating point types
30 that apply in the strict mode@Chg{Version=[2],New=[; and],Old=[.]}
31
32 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00296-01]}@ChgAdded{Version=[2],
33 Text=[features for the manipulation of real and complex vectors and
34 matrices.]}
35 @end{itemize}
36 @end{Intro}
37
38 @begin{ImplAdvice}
39 If Fortran (respectively, C) is widely supported in the target environment,
40 implementations supporting the Numerics Annex should provide the child package
41 Interfaces.Fortran (respectively, Interfaces.C) specified in
42 @RefSecNum{Interface to Other Languages}
43 and should support a @i{convention_}@nt{identifier} of
44 Fortran (respectively, C) in the interfacing pragmas
45 (see @RefSecNum{Interface to Other Languages}),
46 thus allowing Ada programs to interface with programs written in
47 that language.
48 @ChgImplAdvice{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
49 Text=[If Fortran (respectively, C) is supported in the target environment,
50 then interfacing to Fortran (respectively, C) should be supported as
51 specified in @RefSecNum{Interface to Other Languages}.]}]}
52
53 @end{ImplAdvice}
54
55 @begin{Extend83}
56 @Defn{extensions to Ada 83}
57 This Annex is new to Ada 95.
58 @end{Extend83}
59
60 @LabeledClause{Complex Arithmetic}
61
62 @begin{Intro}
63 Types and arithmetic operations for complex arithmetic are provided in
64 Generic_Complex_Types, which is defined in @RefSecNum{Complex Types}.
65 Implementation-defined approximations to the complex analogs of the mathematical
66 functions known as the @lquotes@;elementary functions@rquotes@; are provided by
67 the subprograms in Generic_@!Complex_@!Elementary_@!Functions, which is defined in
68 @RefSecNum{Complex Elementary Functions}. Both of these library units are generic
69 children of the predefined package Numerics (see @RefSecNum{The Numerics Packages}).
70 Nongeneric equivalents of these generic packages for each of the predefined
71 floating point types are also provided as children of Numerics.
72 @ImplDef{The accuracy actually achieved by the complex elementary
73 functions and by other complex arithmetic
74 operations.}
75 @begin{Discussion}
76 Complex arithmetic is defined in the Numerics Annex, rather than in the
77 core, because it is considered to be a specialized need of (some) numeric
78 applications.
79 @end{Discussion}
80 @end{Intro}
81
82 @LabeledSubClause{Complex Types}
83
84 @begin{StaticSem}
85 @Leading@;The generic library package
86 Numerics.Generic_Complex_Types has the following declaration:
87 @begin{Example}
88 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0020],ARef=[AI95-00126-01]}
89 @key{generic}@ChildUnit{Parent=[Ada.Numerics],Child=[Generic_@!Complex_@!Types]}
90 @key{type} Real @key{is} @key{digits} <>;
91 @key{package} Ada.Numerics.Generic_Complex_Types @key{is}
92 @Chg{New=[@key{pragma}],Old=[pragma]} Pure(Generic_Complex_Types);
93
94 @key{type} @AdaTypeDefn{Complex} @key{is}
95 @key{record}
96 Re, Im : Real'Base;
97 @key{end} @key{record};
98
99 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00161-01]}
100 @key{type} @AdaTypeDefn{Imaginary} @key{is} @key{private};@Chg{Version=[2],New=[
101 @key{pragma} Preelaborable_Initialization(Imaginary);],Old=[]}
102
103 @AdaObjDefn{i} : @key{constant} Imaginary;
104 @AdaObjDefn{j} : @key{constant} Imaginary;
105
106
107 @key{function} @AdaSubDefn{Re} (X : Complex) @key{return} Real'Base;
108 @key{function} @AdaSubDefn{Im} (X : Complex) @key{return} Real'Base;
109 @key{function} @AdaSubDefn{Im} (X : Imaginary) @key{return} Real'Base;
110
111 @key{procedure} @AdaSubDefn{Set_Re} (X : @key{in} @key{out} Complex;
112 Re : @key{in} Real'Base);
113 @key{procedure} @AdaSubDefn{Set_Im} (X : @key{in} @key{out} Complex;
114 Im : @key{in} Real'Base);
115 @key{procedure} @AdaSubDefn{Set_Im} (X : @key{out} Imaginary;
116 Im : @key{in} Real'Base);
117
118 @key{function} @AdaSubDefn{Compose_From_Cartesian} (Re, Im : Real'Base) @key{return} Complex;
119 @key{function} @AdaSubDefn{Compose_From_Cartesian} (Re : Real'Base) @key{return} Complex;
120 @key{function} @AdaSubDefn{Compose_From_Cartesian} (Im : Imaginary) @key{return} Complex;
121
122 @key{function} @AdaSubDefn{Modulus} (X : Complex) @key{return} Real'Base;
123 @key{function} "@key{abs}" (Right : Complex) @key{return} Real'Base @key{renames} Modulus;
124
125 @key{function} @AdaSubDefn{Argument} (X : Complex) @key{return} Real'Base;
126 @key{function} @AdaSubDefn{Argument} (X : Complex;
127 Cycle : Real'Base) @key{return} Real'Base;
128
129 @key{function} @AdaSubDefn{Compose_From_Polar} (Modulus, Argument : Real'Base)
130 @key{return} Complex;
131 @key{function} @AdaSubDefn{Compose_From_Polar} (Modulus, Argument, Cycle : Real'Base)
132 @key{return} Complex;
133
134
135 @key{function} "+" (Right : Complex) @key{return} Complex;
136 @key{function} "-" (Right : Complex) @key{return} Complex;
137 @key{function} @AdaSubDefn{Conjugate} (X : Complex) @key{return} Complex;
138
139
140 @key{function} "+" (Left, Right : Complex) @key{return} Complex;
141 @key{function} "-" (Left, Right : Complex) @key{return} Complex;
142 @key{function} "*" (Left, Right : Complex) @key{return} Complex;
143 @key{function} "/" (Left, Right : Complex) @key{return} Complex;
144
145
146 @key{function} "**" (Left : Complex; Right : Integer) @key{return} Complex;
147
148
149 @key{function} "+" (Right : Imaginary) @key{return} Imaginary;
150 @key{function} "-" (Right : Imaginary) @key{return} Imaginary;
151 @key{function} @AdaSubDefn{Conjugate} (X : Imaginary) @key{return} Imaginary @key{renames} "-";
152 @key{function} "@key{abs}" (Right : Imaginary) @key{return} Real'Base;
153
154
155 @key{function} "+" (Left, Right : Imaginary) @key{return} Imaginary;
156 @key{function} "-" (Left, Right : Imaginary) @key{return} Imaginary;
157 @key{function} "*" (Left, Right : Imaginary) @key{return} Real'Base;
158 @key{function} "/" (Left, Right : Imaginary) @key{return} Real'Base;
159
160
161 @key{function} "**" (Left : Imaginary; Right : Integer) @key{return} Complex;
162
163
164 @key{function} "<" (Left, Right : Imaginary) @key{return} Boolean;
165 @key{function} "<=" (Left, Right : Imaginary) @key{return} Boolean;
166 @key{function} ">" (Left, Right : Imaginary) @key{return} Boolean;
167 @key{function} ">=" (Left, Right : Imaginary) @key{return} Boolean;
168
169
170 @key{function} "+" (Left : Complex; Right : Real'Base) @key{return} Complex;
171 @key{function} "+" (Left : Real'Base; Right : Complex) @key{return} Complex;
172 @key{function} "-" (Left : Complex; Right : Real'Base) @key{return} Complex;
173 @key{function} "-" (Left : Real'Base; Right : Complex) @key{return} Complex;
174 @key{function} "*" (Left : Complex; Right : Real'Base) @key{return} Complex;
175 @key{function} "*" (Left : Real'Base; Right : Complex) @key{return} Complex;
176 @key{function} "/" (Left : Complex; Right : Real'Base) @key{return} Complex;
177 @key{function} "/" (Left : Real'Base; Right : Complex) @key{return} Complex;
178
179
180 @key{function} "+" (Left : Complex; Right : Imaginary) @key{return} Complex;
181 @key{function} "+" (Left : Imaginary; Right : Complex) @key{return} Complex;
182 @key{function} "-" (Left : Complex; Right : Imaginary) @key{return} Complex;
183 @key{function} "-" (Left : Imaginary; Right : Complex) @key{return} Complex;
184 @key{function} "*" (Left : Complex; Right : Imaginary) @key{return} Complex;
185 @key{function} "*" (Left : Imaginary; Right : Complex) @key{return} Complex;
186 @key{function} "/" (Left : Complex; Right : Imaginary) @key{return} Complex;
187 @key{function} "/" (Left : Imaginary; Right : Complex) @key{return} Complex;
188
189
190 @key{function} "+" (Left : Imaginary; Right : Real'Base) @key{return} Complex;
191 @key{function} "+" (Left : Real'Base; Right : Imaginary) @key{return} Complex;
192 @key{function} "-" (Left : Imaginary; Right : Real'Base) @key{return} Complex;
193 @key{function} "-" (Left : Real'Base; Right : Imaginary) @key{return} Complex;
194 @key{function} "*" (Left : Imaginary; Right : Real'Base) @key{return} Imaginary;
195 @key{function} "*" (Left : Real'Base; Right : Imaginary) @key{return} Imaginary;
196 @key{function} "/" (Left : Imaginary; Right : Real'Base) @key{return} Imaginary;
197 @key{function} "/" (Left : Real'Base; Right : Imaginary) @key{return} Imaginary;
198
199
200 @key[private]
201
202 @key{type} Imaginary @key{is} @key{new} Real'Base;
203 i : @key{constant} Imaginary := 1.0;
204 j : @key{constant} Imaginary := 1.0;
205
206 @key{end} Ada.Numerics.Generic_Complex_Types;
207 @end{Example}
208
209 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0020],ARef=[AI95-00126-01]}
210 @ChildUnit{Parent=[Ada.Numerics],Child=[Complex_@!Types]}
211 The library package Numerics.Complex_Types
212 @Chg{New=[is declared pure and ],Old=[]}defines the same types, constants,
213 and subprograms as Numerics.Generic_Complex_Types, except that the
214 predefined type Float is systematically substituted for Real'Base throughout.
215 Nongeneric equivalents of Numerics.Generic_Complex_Types for each of the other
216 predefined floating point types are defined similarly, with the names
217 Numerics.@!Short_@!Complex_@!Types, Numerics.@!Long_@!Complex_@!Types, etc.
218 @begin{Reason}
219 The nongeneric equivalents are provided to allow the programmer to
220 construct simple mathematical applications without being required to
221 understand and use generics.
222 @end{Reason}
223 @begin{Reason}
224 The nongeneric equivalents all export the types Complex and Imaginary and
225 the constants i and j (rather than uniquely named types and constants, such
226 as Short_Complex, Long_Complex, etc.) to preserve their equivalence to
227 actual instantiations of the generic package and to allow the programmer to
228 change the precision of an application globally by changing a single
229 context clause.
230 @end{Reason}
231
232 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00434-01]}
233 @Redundant{Complex is a visible type with
234 @Chg{Version=[2],New=[Cartesian],Old=[cartesian]} components.}
235 @begin{Reason}
236 The @Chg{Version=[2],New=[Cartesian],Old=[cartesian]} representation is
237 far more common than the polar
238 representation, in practice. The accuracy of the results of the complex
239 arithmetic operations and of the complex elementary functions
240 is dependent on the representation; thus, implementers need to know that
241 representation. The type is visible so that complex @lquotes@;literals@rquotes@; can be
242 written in aggregate notation, if desired.
243 @end{Reason}
244
245 @Redundant{Imaginary is a private type; its full type is derived from
246 Real'Base.}
247 @begin{Reason}
248 @Leading@;The Imaginary type and the constants i and j are provided for two reasons:
249 @begin{itemize}
250 They allow complex @lquotes@;literals@rquotes@; to be written in the alternate form of
251 @RI{a} + @RI{b}*i (or @RI{a} + @RI{b}*j), if desired. Of course,
252 in some contexts the sum will need to be parenthesized.
253
254 When an Ada binding to IEC 559:1989 that provides (signed) infinities
255 as the result of operations that overflow becomes available, it will be
256 important to allow arithmetic between pure-imaginary and complex operands
257 without requiring the former to be represented as (or promoted to)
258 complex values with a real component of zero. For example, the
259 multiplication of @RI{a} + @RI{b}*i by @RI{d}*i should yield
260 @en@RI{b}@Times @RI{d} + @RI{a}@Times @RI{d}*i, but if one cannot avoid representing the
261 pure-imaginary value @RI{d}*i as the complex value
262 0.0 + @RI{d}*i, then a NaN ("Not-a-Number") could be produced
263 as the result of multiplying @RI{a} by 0.0 (e.g., when @RI{a} is
264 infinite); the NaN could later trigger an exception.
265 Providing the Imaginary type and overloadings of the
266 arithmetic operators for mixtures of Imaginary and Complex operands
267 gives the programmer the same control over avoiding premature coercion of
268 pure-imaginary values to complex as is already provided for pure-real
269 values.
270 @end{itemize}
271 @end{Reason}
272 @begin{Reason}
273 @Leading@;The Imaginary type is private, rather than being visibly derived
274 from Real'Base, for two reasons:
275 @begin{itemize}
276 to preclude implicit conversions of real literals to the Imaginary type
277 (such implicit conversions would make many common arithmetic expressions
278 ambiguous); and
279
280 to suppress the implicit derivation of the multiplication, division, and
281 absolute value operators with Imaginary operands and an Imaginary result
282 (the result type would be incorrect).
283 @end{itemize}
284 @end{Reason}
285 @begin{Reason}
286 The base subtype Real'Base is used for the component type of Complex, the
287 parent type of Imaginary, and the parameter and result types of some of the
288 subprograms to maximize the chances of being able to pass meaningful values
289 into the subprograms and receive meaningful results back. The generic
290 formal parameter Real therefore plays only one role, that of providing the
291 precision to be maintained in complex arithmetic calculations. Thus, the
292 subprograms in Numerics.Generic_Complex_Types share with those in
293 Numerics.Generic_Elementary_Functions, and indeed even with the predefined
294 arithmetic operations (see @RefSecNum{Operators and Expression Evaluation}),
295 the property of being free of range checks on input
296 and output, i.e., of being able to exploit the base range of the relevant
297 floating point type fully. As a result, the user loses the ability to
298 impose application-oriented bounds on the range of values that the
299 components of a complex variable can acquire; however, it can be argued that
300 few, if any, applications have a naturally square domain (as opposed to a
301 circular domain) anyway.
302 @end{Reason}
303
304 @Leading@;The arithmetic operations and the Re, Im, Modulus, Argument, and Conjugate
305 functions have their usual mathematical meanings. When applied to a parameter
306 of pure-imaginary type, the @lquotes@;imaginary-part@rquotes@; function Im yields the value of
307 its parameter, as the corresponding real value.
308 The remaining subprograms have the following meanings:
309 @begin{Reason}
310 The middle case can be understood by considering the parameter of
311 pure-imaginary type to represent a complex value with a zero real part.
312 @end{Reason}
313 @begin{Itemize}
314 The Set_Re and Set_Im procedures replace the designated component of a
315 complex parameter with the given real value; applied to a parameter of
316 pure-imaginary type, the Set_Im procedure replaces the value of that
317 parameter with the imaginary value corresponding to the given real value.
318
319 The Compose_From_Cartesian function constructs a complex value from the
320 given real and imaginary components. If only one component is given, the
321 other component is implicitly zero.
322
323 The Compose_From_Polar function constructs a complex value from the given
324 modulus (radius) and argument (angle). When the value of the parameter
325 Modulus is positive (resp., negative), the result is the complex value
326 represented by the point in the complex plane lying at a distance from the
327 origin given by the absolute value of Modulus and forming an angle measured
328 counterclockwise from the positive (resp., negative) real axis given by the
329 value of the parameter Argument.
330 @end(Itemize)
331
332 When the Cycle parameter is specified, the result of the Argument function and
333 the parameter Argument of the Compose_From_Polar function are measured in units
334 such that a full cycle of revolution has the given value; otherwise, they are
335 measured in radians.
336
337 @Leading@;The computed results of the mathematically multivalued functions are rendered
338 single-valued by the following conventions, which are meant to imply the
339 principal branch:
340 @begin{Itemize}
341 The result of the Modulus function is nonnegative.
342
343 The result of the Argument function is in the quadrant containing the point
344 in the complex plane represented by the parameter X. This may be any
345 quadrant (I through IV); thus, the range of the Argument function is
346 approximately @en@Pi to @Pi
347 (@en@R[Cycle]/2.0 to @R[Cycle]/2.0, if the parameter Cycle is
348 specified). When the point represented by the parameter X lies on the
349 negative real axis, the result approximates
350 @begin{InnerItemize}
351 @Pi (resp., @en@Pi) when the sign of the imaginary
352 component of X is positive (resp., negative), if Real'Signed_Zeros is
353 True;
354
355 @Pi, if Real'Signed_Zeros is False.
356 @end{InnerItemize}
357
358 Because a result lying on or near one of the axes may not be exactly
359 representable, the approximation inherent in computing the result may place
360 it in an adjacent quadrant, close to but on the wrong side of the axis.
361 @end{Itemize}
362 @end{StaticSem}
363
364 @begin{RunTime}
365 The exception Numerics.Argument_Error is raised by the Argument and
366 Compose_From_Polar functions with specified cycle, signaling a parameter value
367 outside the domain of the corresponding mathematical function, when the value
368 of the parameter Cycle is zero or negative.
369
370 @IndexCheck{Division_Check}
371 @Defn2{Term=[Constraint_Error],Sec=(raised by failure of run-time check)}
372 The exception Constraint_Error is raised by the division operator when the
373 value of the right operand is zero, and by the exponentiation operator when
374 the value of the left operand is zero and the value of the exponent is
375 negative, provided that Real'Machine_Overflows is True; when
376 Real'Machine_Overflows is False, the result is
377 unspecified.
378 @PDefn{unspecified}
379 @Redundant[Constraint_Error
380 can also be raised when a finite result overflows
381 (see @RefSecNum{Accuracy Requirements for Complex Arithmetic}).]
382 @begin{Discussion}
383 It is anticipated that an Ada binding to IEC 559:1989 will be developed in
384 the future. As part of such a binding, the Machine_Overflows attribute of a
385 conformant floating point type will be specified to yield False, which will
386 permit implementations of the complex arithmetic operations to deliver
387 results with an infinite component (and set the overflow flag defined by the
388 binding) instead of raising Constraint_Error in overflow situations, when
389 traps are disabled. Similarly, it is appropriate for the complex arithmetic
390 operations to deliver results with infinite components (and set the
391 zero-divide flag defined by the binding) instead of raising Constraint_Error
392 in the situations defined above, when traps are disabled. Finally, such a
393 binding should also specify the behavior of the complex arithmetic
394 operations, when sensible, given operands with infinite components.
395 @end{Discussion}
396 @end{RunTime}
397
398 @begin{ImplReq}
399 In the implementation of Numerics.Generic_Complex_Types,
400 the range of intermediate values allowed during the calculation
401 of a final result shall not be affected by any
402 range constraint of the subtype Real.
403 @begin{ImplNote}
404 Implementations of Numerics.Generic_Complex_Types written in Ada should
405 therefore avoid declaring local variables of subtype Real; the subtype
406 Real'Base should be used instead.
407 @end{ImplNote}
408
409 @Leading
410 @Defn2{Term=[prescribed result],
411 Sec=[for the evaluation of a complex arithmetic operation]}
412 In the following cases, evaluation of a complex arithmetic operation shall
413 yield the @i{prescribed result},
414 provided that the preceding rules do not call for an exception to be
415 raised:
416 @begin{Itemize}
417 The results of the Re, Im, and Compose_From_Cartesian functions are exact.
418
419 The real (resp., imaginary) component of the result of a binary addition
420 operator that yields a result of complex type is exact when either of its
421 operands is of pure-imaginary (resp., real) type.
422 @begin{Ramification}
423 The result of the addition operator is exact when one of its operands is
424 of real type and the other is of pure-imaginary type. In this particular
425 case, the operator is analogous to the Compose_From_Cartesian function;
426 it performs no arithmetic.
427 @end{Ramification}
428
429 The real (resp., imaginary) component of the result of a binary subtraction
430 operator that yields a result of complex type is exact when its right
431 operand is of pure-imaginary (resp., real) type.
432
433 The real component of the result of the Conjugate function for the complex
434 type is exact.
435
436 When the point in the complex plane represented by the parameter X lies on
437 the nonnegative real axis, the Argument function yields a result of zero.
438 @begin{Discussion}
439 Argument(X + i*Y) is analogous to @i{EF}.Arctan(Y, X), where @i{EF} is an
440 appropriate instance of Numerics.Generic_Elementary_Functions, except
441 when X and Y are both zero, in which case the former yields the value
442 zero while the latter raises Numerics.Argument_Error.
443 @end{Discussion}
444
445 When the value of the parameter Modulus is zero, the Compose_From_Polar
446 function yields a result of zero.
447
448 When the value of the parameter Argument is equal to a multiple of the
449 quarter cycle, the result of the Compose_From_Polar function with specified
450 cycle lies on one of the axes. In this case, one of its components is zero,
451 and the other has the magnitude of the parameter Modulus.
452
453 Exponentiation by a zero exponent yields the value one. Exponentiation by
454 a unit exponent yields the value of the left operand. Exponentiation of
455 the value one yields the value one. Exponentiation of the value zero
456 yields the value zero, provided that the exponent is nonzero. When the
457 left operand is of pure-imaginary type, one component of the result of the
458 exponentiation operator is zero.
459 @end{Itemize}
460
461 When the result, or a result component, of any operator of
462 Numerics.Generic_Complex_Types has a mathematical definition in terms of a
463 single arithmetic or relational operation, that result or result component
464 exhibits the accuracy of the corresponding operation of the type Real.
465
466 Other accuracy requirements for the Modulus, Argument, and Compose_From_Polar
467 functions, and accuracy requirements for the multiplication of a pair of
468 complex operands or for division by a complex operand, all of which apply
469 only in the strict mode, are given in
470 @RefSecNum{Accuracy Requirements for Complex Arithmetic}.
471
472 The sign of a zero result or zero result component yielded by a complex
473 arithmetic operation or function is implementation defined when
474 Real'Signed_Zeros is True.
475 @ImplDef{The sign of a zero result (or a component thereof) from any operator
476 or function in Numerics.Generic_Complex_Types, when Real'Signed_Zeros is True.}
477 @end{ImplReq}
478
479 @begin{ImplPerm}
480 The nongeneric equivalent packages may, but need not, be actual
481 instantiations of the generic package for the appropriate predefined type.
482
483 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0091]}
484 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00434-01]}
485 Implementations may obtain the result of exponentiation of a complex
486 or pure-imaginary operand by repeated complex multiplication, with arbitrary
487 association of the factors and with a possible final complex reciprocation
488 (when the exponent is negative). Implementations are also permitted to obtain
489 the result of exponentiation of a complex operand, but not of a pure-imaginary
490 operand, by converting the left operand to a polar representation;
491 exponentiating the modulus by the given exponent; multiplying the argument by
492 the given exponent@Chg{New=[],Old=[, when the exponent is positive, or dividing
493 the argument by the absolute value of the given exponent, when the exponent is
494 negative]}; and reconverting to a @Chg{Version=[2],New=[Cartesian],Old=[cartesian]}
495 representation. Because of this
496 implementation freedom, no accuracy requirement is imposed on complex
497 exponentiation (except for the prescribed results given above, which apply
498 regardless of the implementation method chosen).
499 @end{ImplPerm}
500
501 @begin{ImplAdvice}
502 Because the usual mathematical meaning of multiplication of a complex operand
503 and a real operand is that of the scaling of both components of the former by
504 the latter, an implementation should not perform this operation by first
505 promoting the real operand to complex type and then performing a full complex
506 multiplication. In systems that, in the future, support an Ada binding to IEC
507 559:1989, the latter technique will not generate the required result when one
508 of the components of the complex operand is infinite. (Explicit multiplication
509 of the infinite component by the zero component obtained during promotion
510 yields a NaN that propagates into the final result.) Analogous advice applies
511 in the case of multiplication of a complex operand and a pure-imaginary
512 operand, and in the case of division of a complex operand by a real or
513 pure-imaginary operand.
514 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
515 Text=[Mixed real and complex operations (as well as pure-imaginary and complex
516 operations) should not be performed by converting
517 the real (resp. pure-imaginary) operand to complex.]}]}
518
519 Likewise, because the usual mathematical meaning of addition of a complex
520 operand and a real operand is that the imaginary operand remains unchanged, an
521 implementation should not perform this operation by first promoting the real
522 operand to complex type and then performing a full complex addition. In
523 implementations in which the Signed_Zeros attribute of the component type is
524 True (and which therefore conform to IEC 559:1989 in regard to the handling of
525 the sign of zero in predefined arithmetic operations), the latter technique
526 will not generate the required result when the imaginary component of the
527 complex operand is a negatively signed zero. (Explicit addition of the
528 negative zero to the zero obtained during promotion yields a positive zero.)
529 Analogous advice applies in the case of addition of a complex operand and a
530 pure-imaginary operand, and in the case of subtraction of a complex operand and
531 a real or pure-imaginary operand.
532
533 Implementations in which Real'Signed_Zeros is True should attempt to provide a
534 rational treatment of the signs of zero results and result components. As one
535 example, the result of the Argument function should have the sign of the
536 imaginary component of the parameter X when the point represented by that
537 parameter lies on the positive real axis; as another, the sign of the imaginary
538 component of the Compose_@!From_@!Polar function should be the same as (resp., the
539 opposite of) that of the Argument parameter when that parameter has a value of
540 zero and the Modulus parameter has a nonnegative (resp., negative) value.
541 @ChgImplAdvice{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
542 Text=[If Real'Signed_Zeros is true for Numerics.@!Generic_@!Complex_@!Types,
543 a rational treatment of the signs of
544 zero results and result components should be provided.]}]}
545 @end{ImplAdvice}
546
547 @begin{DiffWord83}
548 @Leading@;The semantics of Numerics.Generic_Complex_Types differs from
549 Generic_Complex_Types as defined in ISO/IEC CD 13813
550 (for Ada 83) in the following ways:
551 @begin{itemize}
552 The generic package is a child of the package defining the
553 Argument_Error exception.
554
555 The nongeneric equivalents export types and constants with the same names
556 as those exported by the generic package, rather than with names unique to
557 the package.
558
559 Implementations are not allowed to impose an optional restriction that the
560 generic actual parameter associated with Real be unconstrained. (In view of
561 the ability to declare variables of subtype Real'Base in implementations of
562 Numerics.Generic_Complex_Types, this flexibility is no longer needed.)
563
564 The dependence of the Argument function on the sign of a zero parameter
565 component is tied to the value of Real'Signed_Zeros.
566
567 Conformance to accuracy requirements is conditional.
568 @end{itemize}
569 @end{DiffWord83}
570
571 @begin{Extend95}
572 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00161-01]}
573 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
574 @b[Amendment Correction:] Added a @nt{pragma} Preelaborable_Initialization to
575 type Imaginary, so that it can be used in preelaborated units.]}
576 @end{Extend95}
577
578 @begin{DiffWord95}
579 @ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0020],ARef=[AI95-00126-01]}
580 @ChgAdded{Version=[2],Text=[@b<Corrigendum:> Explicitly stated that the
581 nongeneric equivalents of Generic_Complex_Types are pure.]}
582 @end{DiffWord95}
583
584
585 @LabeledSubClause{Complex Elementary Functions}
586
587 @begin{StaticSem}
588 @Leading@;The generic library package
589 Numerics.Generic_Complex_Elementary_Functions has the following declaration:
590 @begin{Example}
591 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00434-01]}
592 @key[with] Ada.Numerics.Generic_Complex_Types;
593 @key[generic]@ChildUnit{Parent=[Ada.Numerics],Child=[Generic_@!Complex_@!Elementary_@!Functions]}
594 @key[with] @key[package] Complex_Types @key[is]
595 @key[new] Ada.Numerics.Generic_Complex_Types (<>);
596 @key[use] Complex_Types;
597 @key[package] Ada.Numerics.Generic_Complex_Elementary_Functions @key[is]
598 @Chg{Version=[2],New=[@key{pragma}],Old=[pragma]} Pure(Generic_Complex_Elementary_Functions);
599
600 @key[function] @AdaSubDefn{Sqrt} (X : Complex) @key[return] Complex;
601 @key[function] @AdaSubDefn{Log} (X : Complex) @key[return] Complex;
602 @key[function] @AdaSubDefn{Exp} (X : Complex) @key[return] Complex;
603 @key[function] @AdaSubDefn{Exp} (X : Imaginary) @key[return] Complex;
604 @key[function] "**" (Left : Complex; Right : Complex) @key[return] Complex;
605 @key[function] "**" (Left : Complex; Right : Real'Base) @key[return] Complex;
606 @key[function] "**" (Left : Real'Base; Right : Complex) @key[return] Complex;
607
608
609 @key[function] @AdaSubDefn{Sin} (X : Complex) @key[return] Complex;
610 @key[function] @AdaSubDefn{Cos} (X : Complex) @key[return] Complex;
611 @key[function] @AdaSubDefn{Tan} (X : Complex) @key[return] Complex;
612 @key[function] @AdaSubDefn{Cot} (X : Complex) @key[return] Complex;
613
614
615 @key[function] @AdaSubDefn{Arcsin} (X : Complex) @key[return] Complex;
616 @key[function] @AdaSubDefn{Arccos} (X : Complex) @key[return] Complex;
617 @key[function] @AdaSubDefn{Arctan} (X : Complex) @key[return] Complex;
618 @key[function] @AdaSubDefn{Arccot} (X : Complex) @key[return] Complex;
619
620
621 @key[function] @AdaSubDefn{Sinh} (X : Complex) @key[return] Complex;
622 @key[function] @AdaSubDefn{Cosh} (X : Complex) @key[return] Complex;
623 @key[function] @AdaSubDefn{Tanh} (X : Complex) @key[return] Complex;
624 @key[function] @AdaSubDefn{Coth} (X : Complex) @key[return] Complex;
625
626
627 @key[function] @AdaSubDefn{Arcsinh} (X : Complex) @key[return] Complex;
628 @key[function] @AdaSubDefn{Arccosh} (X : Complex) @key[return] Complex;
629 @key[function] @AdaSubDefn{Arctanh} (X : Complex) @key[return] Complex;
630 @key[function] @AdaSubDefn{Arccoth} (X : Complex) @key[return] Complex;
631
632 @key[end] Ada.Numerics.Generic_Complex_Elementary_Functions;
633 @end{Example}
634
635 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0020],ARef=[AI95-00126-01]}
636 @ChildUnit{Parent=[Ada.Numerics],Child=[Complex_@!Elementary_@!Functions]}
637 The library package Numerics.Complex_Elementary_Functions
638 @Chg{New=[is declared pure and ],Old=[]}defines the same subprograms as
639 Numerics.@!Generic_@!Complex_@!Elementary_@!Functions,
640 except that the predefined type Float is systematically substituted for
641 Real'Base, and the Complex and Imaginary types exported by Numerics.@!Complex_@!Types
642 are systematically substituted for Complex and Imaginary, throughout.
643 Nongeneric equivalents of Numerics.@!Generic_@!Complex_@!Elementary_@!Functions
644 corresponding to each of the other predefined floating point types are
645 defined similarly, with the names Numerics.@!Short_@!Complex_@!Elementary_@!Functions,
646 Numerics.@!Long_@!Complex_@!Elementary_@!Functions, etc.
647 @begin{Reason}
648 The nongeneric equivalents are provided to allow the programmer to
649 construct simple mathematical applications without being required to
650 understand and use generics.
651 @end{Reason}
652
653 The overloading of the Exp function for the pure-imaginary type is provided
654 to give the user an alternate way to compose a complex value from a given
655 modulus and argument. In addition to Compose_@!From_@!Polar(Rho, Theta)
656 (see @RefSecNum{Complex Types}), the programmer may write Rho * Exp(i * Theta).
657
658 The imaginary (resp., real) component of the parameter X of the forward
659 hyperbolic (resp., trigonometric) functions and of the Exp function (and the
660 parameter X, itself, in the case of the overloading of the Exp function for the
661 pure-imaginary type) represents an angle measured in radians, as does the
662 imaginary (resp., real) component of the result of the Log and inverse
663 hyperbolic (resp., trigonometric) functions.
664
665 @Leading@;The functions have their usual mathematical meanings. However, the
666 arbitrariness inherent in the placement of branch cuts, across which some of
667 the complex elementary functions exhibit discontinuities, is eliminated by the
668 following conventions:
669 @begin{Itemize}
670 The imaginary component of the result of the Sqrt and Log functions is
671 discontinuous as the parameter X crosses the negative real axis.
672
673 The result of the exponentiation operator when the left operand is of
674 complex type is discontinuous as that operand crosses the negative real
675 axis.
676
677 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00185-01]}
678 The @Chg{Version=[2],New=[],Old=[real (resp., ]}imaginary@Chg{Version=[2],
679 New=[],Old=[)]} component of the result of the Arcsin@Chg{Version=[2],
680 New=[,],Old=[ and]} Arccos@Chg{Version=[2],New=[],Old=[(resp.]},
681 @Chg{Version=[2],New=[and ],Old=[]}Arctanh@Chg{Version=[2],
682 New=[],Old=[)]} functions is discontinuous as the parameter X crosses the
683 real axis to the left of @en@;1.0 or the right of 1.0.
684
685 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00185-01]}
686 The real @Chg{Version=[2],New=[],Old=[(resp., imaginary) ]}component of the
687 result of the Arctan @Chg{Version=[2],New=[and],Old=[(resp.,]}
688 Arcsinh@Chg{Version=[2], New=[ functions],Old=[) function]} is discontinuous
689 as the parameter X crosses the imaginary axis below @en@RI{i} or above @RI{i}.
690
691 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00185-01]}
692 The real component of the result of the Arccot function is discontinuous as
693 the parameter X crosses the imaginary axis @Chg{Version=[2],New=[below],
694 Old=[between]} @en@RI{i} @Chg{Version=[2],New=[or above],Old=[and]} @RI{i}.
695
696 The imaginary component of the Arccosh function is discontinuous as the
697 parameter X crosses the real axis to the left of 1.0.
698
699 The imaginary component of the result of the Arccoth function is
700 discontinuous as the parameter X crosses the real axis between @en@;1.0
701 and 1.0.
702 @end{Itemize}
703 @begin{Discussion}
704 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00185-01]}
705 @ChgAdded{Version=[2],Type=[Leading],Text=[The branch cuts come from the
706 fact that the functions in question are
707 really multi-valued in the complex domain, and that we have to pick one
708 @i{principal value} to be the result of the function. Evidently we have
709 much freedom in choosing where the branch cuts lie. However, we are
710 adhering to the following principles which seem to lead to the more
711 @i{natural} definitions:]}
712 @begin{Itemize}
713 @ChgRef{Version=[2],Kind=[AddedNormal]}
714 @ChgAdded{Version=[2],Text=[A branch cut should not intersect the real axis
715 at a place where the
716 corresponding real function is well-defined (in other words, the complex
717 function should be an extension of the corresponding real function).]}
718
719 @ChgRef{Version=[2],Kind=[AddedNormal]}
720 @ChgAdded{Version=[2],Text=[Because all the functions in question are
721 analytic, to ensure power
722 series validity for the principal value, the branch cuts should be
723 invariant by complex conjugation.]}
724
725 @ChgRef{Version=[2],Kind=[AddedNormal]}
726 @ChgAdded{Version=[2],Text=[For odd functions, to ensure that the principal
727 value remains an odd
728 function, the branch cuts should be invariant by reflection in the origin.]}
729 @end{Itemize}
730 @end{Discussion}
731
732 @Leading@;@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00185-01]}The
733 computed results of the mathematically multivalued functions
734 are rendered single-valued by the following conventions, which are meant to
735 imply @Chg{Version=[2],New=[that ],Old=[]}the
736 principal branch@Chg{Version=[2],New=[ is an analytic continuation of
737 the corresponding real-valued function in
738 Numerics.Generic_Elementary_Functions. (For Arctan and Arccot,
739 the single-argument function in question is that obtained from the two-argument
740 version by fixing the second argument to be its default value.)],Old=[:]}
741 @begin{Itemize}
742 The real component of the result of the Sqrt and Arccosh functions is
743 nonnegative.
744
745 The same convention applies to the imaginary component of the result of the
746 Log function as applies to the result of the natural-cycle version of the
747 Argument function of Numerics.Generic_Complex_Types
748 (see @RefSecNum{Complex Types}).
749
750 The range of the real (resp., imaginary) component of the result of the
751 Arcsin and Arctan (resp., Arcsinh and Arctanh) functions is
752 approximately @en@Pi/2.0 to @Pi/2.0.
753
754 The real (resp., imaginary) component of the result of the Arccos and Arccot
755 (resp., Arccoth) functions ranges from 0.0 to approximately @Pi.
756
757 The range of the imaginary component of the result of the Arccosh function
758 is approximately @en@Pi to @Pi.
759 @end{Itemize}
760
761 In addition, the exponentiation operator inherits the single-valuedness of the
762 Log function.
763 @end{StaticSem}
764
765 @begin{RunTime}
766 The exception Numerics.Argument_Error is raised by the exponentiation operator,
767 signaling a parameter value outside the domain of the corresponding
768 mathematical function, when the value of the left operand is zero and the real
769 component of the exponent (or the exponent itself, when it is of real type) is
770 zero.
771
772 @Leading@IndexCheck{Division_Check}
773 @Defn2{Term=[Constraint_Error],Sec=(raised by failure of run-time check)}
774 The exception Constraint_Error is raised, signaling a pole of the mathematical
775 function (analogous to dividing by zero), in the following cases, provided that
776 Complex_Types.Real'Machine_Overflows is True:
777 @begin{Itemize}
778 by the Log, Cot, and Coth functions, when the value of the parameter X is
779 zero;
780
781 by the exponentiation operator, when the value of the left operand is zero
782 and the real component of the exponent (or the exponent itself, when it is
783 of real type) is negative;
784
785 by the Arctan and Arccot functions, when the value of the parameter X is
786 @PorM @RI{i};
787
788 by the Arctanh and Arccoth functions, when the value of the parameter X is
789 @PorM 1.0.
790 @end{Itemize}
791
792 @redundant[Constraint_Error can also be raised
793 when a finite result overflows
794 (see @RefSecNum{Accuracy Requirements for Complex Arithmetic}); this may
795 occur for parameter values sufficiently @i{near} poles, and, in the case of
796 some of the functions, for parameter values having components of sufficiently
797 large magnitude.]
798 @PDefn{unspecified}
799 When Complex_Types.Real'Machine_Overflows is False, the result at poles is
800 unspecified.
801 @begin{Reason}
802 The purpose of raising Constraint_Error (rather than
803 Numerics.Argument_Error) at the poles of a function, when
804 Float_Type'Machine_Overflows is True, is to provide continuous behavior as
805 the actual parameters of the function approach the pole and finally reach
806 it.
807 @end{Reason}
808 @begin{Discussion}
809 It is anticipated that an Ada binding to IEC 559:1989 will be developed
810 in the future. As part of such a binding, the Machine_Overflows attribute
811 of a conformant floating point type will be specified to yield False, which
812 will permit implementations of the complex elementary functions to deliver
813 results with an infinite component (and set the overflow flag defined by the
814 binding) instead of raising Constraint_Error in overflow situations, when
815 traps are disabled. Similarly, it is appropriate for the complex elementary
816 functions to deliver results with an infinite component (and set the
817 zero-divide flag defined by the binding) instead of raising Constraint_Error
818 at poles, when traps are disabled. Finally, such a binding should also
819 specify the behavior of the complex elementary functions, when sensible,
820 given parameters with infinite components.
821 @end{Discussion}
822 @end{RunTime}
823
824 @begin{ImplReq}
825 In the implementation of Numerics.Generic_Complex_Elementary_Functions,
826 the range of intermediate values allowed during the calculation
827 of a final result shall not be affected by any
828 range constraint of the subtype Complex_Types.Real.
829 @begin{ImplNote}
830 Implementations of Numerics.Generic_Complex_Elementary_Functions written in Ada
831 should therefore avoid declaring local variables of subtype Complex_Types.Real; the
832 subtype Complex_Types.Real'Base should be used instead.
833 @end{ImplNote}
834
835 @Leading
836 @Defn2{Term=[prescribed result],
837 Sec=[for the evaluation of a complex elementary function]}
838 In the following cases, evaluation of a complex elementary function shall
839 yield the @i{prescribed result} (or a result having the prescribed component),
840 provided that the preceding rules do not call for an exception to be
841 raised:
842 @begin{Itemize}
843 When the parameter X has the value zero, the Sqrt, Sin, Arcsin, Tan, Arctan,
844 Sinh, Arcsinh, Tanh, and Arctanh functions yield a result of zero; the
845 Exp, Cos, and Cosh functions yield a result of one; the Arccos and Arccot
846 functions yield a real result; and the Arccoth function yields an imaginary
847 result.
848
849 When the parameter X has the value one, the Sqrt function yields a result
850 of one; the Log, Arccos, and Arccosh functions yield a result of zero; and
851 the Arcsin function yields a real result.
852
853 When the parameter X has the value @en@;1.0, the Sqrt function yields the
854 result
855 @begin{InnerItemize}
856 @RI{i} (resp., @en@RI{i}), when the sign of the imaginary component of
857 X is positive (resp., negative), if Complex_Types.Real'Signed_Zeros is
858 True;
859
860 @RI{i}, if Complex_Types.Real'Signed_Zeros is False;
861 @end{InnerItemize}
862
863 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00434-01]}
864 @Chg{Version=[2],New=[When the parameter X has the value @en@;1.0, ],
865 Old=[]}the Log function yields an imaginary result; and the Arcsin and Arccos
866 functions yield a real result.
867
868 When the parameter X has the value @PorM @RI{i}, the Log function yields
869 an imaginary result.
870
871 Exponentiation by a zero exponent yields the value one. Exponentiation by
872 a unit exponent yields the value of the left operand (as a complex value).
873 Exponentiation of the value one yields the value one. Exponentiation of
874 the value zero yields the value zero.
875 @end{Itemize}
876 @begin{Discussion}
877 It is possible to give many other prescribed results restricting the result
878 to the real or imaginary axis when the parameter X is appropriately
879 restricted to easily testable portions of the domain. We follow the
880 proposed ISO/IEC standard for Generic_Complex_Elementary_Functions (for Ada
881 83), CD 13813,
882 in not doing so, however.
883 @end{Discussion}
884
885 Other accuracy requirements for the complex elementary functions, which apply
886 only in the strict mode, are given in
887 @RefSecNum{Accuracy Requirements for Complex Arithmetic}.
888
889 The sign of a zero result or zero result component yielded by a complex
890 elementary function is implementation defined when
891 Complex_Types.Real'Signed_Zeros is True.
892 @ImplDef{The sign of a zero result (or a component thereof) from any operator
893 or function in Numerics.Generic_Complex_Elementary_Functions, when
894 Complex_Types.Real'Signed_Zeros is True.}
895 @end{ImplReq}
896
897 @begin{ImplPerm}
898 The nongeneric equivalent packages may, but need not, be actual
899 instantiations of the generic package with the appropriate predefined
900 nongeneric equivalent of Numerics.Generic_Complex_Types; if they are, then the
901 latter shall have been obtained by actual instantiation of
902 Numerics.Generic_Complex_Types.
903
904 The exponentiation operator may be implemented in terms of the Exp and Log
905 functions. Because this implementation yields poor accuracy in some parts of
906 the domain, no accuracy requirement is imposed on complex exponentiation.
907
908 @PDefn{unspecified}
909 The implementation of the Exp function of a complex parameter X is allowed to
910 raise the exception Constraint_Error, signaling overflow, when the real
911 component of X exceeds an unspecified threshold that
912 is approximately
913 @Log(@R[Complex_Types.Real'Safe_Last]).
914 This permission recognizes the impracticality of avoiding overflow in
915 the marginal
916 case that the exponential of the real component of X exceeds the safe range of
917 Complex_Types.Real but both components of the final result do not. Similarly,
918 the Sin and Cos (resp., Sinh and Cosh) functions are allowed to raise the
919 exception Constraint_Error, signaling overflow, when the absolute value of the
920 imaginary (resp., real) component of the parameter X exceeds an
921 unspecified threshold that is approximately
922 @Log(@R[Complex_Types.Real'Safe_Last]) +
923 @Log(2.0).
924 @PDefn{unspecified}
925 This permission
926 recognizes the impracticality of avoiding overflow in the marginal case that
927 the hyperbolic sine or cosine of the imaginary (resp., real) component of X
928 exceeds the safe range of Complex_Types.Real but both components of the final
929 result do not.
930 @end{ImplPerm}
931
932 @begin{ImplAdvice}
933 Implementations in which Complex_Types.Real'Signed_Zeros is True should attempt
934 to provide a rational treatment of the signs of zero results and result
935 components. For example, many of the complex elementary functions have
936 components that are odd functions of one of the parameter components; in these
937 cases, the result component should have the sign of the parameter component at
938 the origin. Other complex elementary functions have zero components whose sign
939 is opposite that of a parameter component at the origin, or is always positive
940 or always negative.
941 @ChgImplAdvice{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
942 Text=[If Complex_Types.Real'Signed_Zeros is true for
943 Numerics.@!Generic_@!Complex_@!Elementary_@!Functions,
944 a rational treatment of the signs of
945 zero results and result components should be provided.]}]}
946 @end{ImplAdvice}
947
948 @begin{DiffWord83}
949 @Leading@;The semantics of Numerics.@!Generic_@!Complex_@!Elementary_@!Functions
950 differs from Generic_@!Complex_@!Elementary_@!Functions as defined in
951 ISO/IEC CD 13814 (for Ada 83) in the following ways:
952 @begin{itemize}
953 The generic package is a child unit of the package defining the
954 Argument_Error exception.
955
956 The proposed Generic_Complex_Elementary_Functions standard (for Ada 83)
957 specified names for the nongeneric equivalents, if provided. Here, those
958 nongeneric equivalents are required.
959
960 The generic package imports an instance of Numerics.Generic_Complex_Types rather
961 than a long list of individual types and operations exported by such an
962 instance.
963
964 The dependence of the imaginary component of the Sqrt and Log functions on
965 the sign of a zero parameter component is tied to the value of
966 Complex_Types.Real'Signed_Zeros.
967
968 Conformance to accuracy requirements is conditional.
969 @end{itemize}
970 @end{DiffWord83}
971
972 @begin{DiffWord95}
973 @ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0020],ARef=[AI95-00126-01]}
974 @ChgAdded{Version=[2],Text=[@b<Corrigendum:> Explicitly stated that the
975 nongeneric equivalents of Generic_Complex_Elementary_Functions are pure.]}
976
977 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00185-01]}
978 @ChgAdded{Version=[2],Text=[Corrected various inconsistencies in the
979 definition of the branch cuts.]}
980 @end{DiffWord95}
981
982
983 @LabeledSubClause{Complex Input-Output}
984
985 @begin{Intro}
986 The generic package Text_IO.Complex_IO defines procedures for the
987 formatted input and output of complex values. The generic actual parameter in
988 an instantiation of Text_IO.Complex_IO is an instance of
989 Numerics.Generic_Complex_Types for some floating point subtype. Exceptional
990 conditions are reported by raising the appropriate exception defined in
991 Text_IO.
992 @begin{ImplNote}
993 An implementation of Text_IO.Complex_IO can
994 be built around an instance of
995 Text_IO.Float_IO for the base subtype of Complex_Types.Real, where
996 Complex_Types is the generic formal package parameter of Text_IO.Complex_IO.
997 There is no need for an implementation of Text_IO.Complex_IO to parse
998 real values.
999 @end{ImplNote}
1000 @end{Intro}
1001
1002 @begin{StaticSem}
1003 @Leading@;The generic library package
1004 Text_IO.Complex_IO has the following declaration:
1005 @begin{Ramification}
1006 Because this is a child of Text_IO, the declarations of the visible
1007 part of Text_IO are directly visible within it.
1008 @end{Ramification}
1009 @begin{Example}
1010 @key[with] Ada.Numerics.Generic_Complex_Types;
1011 @key[generic]@ChildUnit{Parent=[Ada.Text_IO],Child=[Complex_IO]}
1012 @key[with] @key[package] Complex_Types @key[is]
1013 @key[new] Ada.Numerics.Generic_Complex_Types (<>);
1014 @key[package] Ada.Text_IO.Complex_IO @key[is]
1015
1016
1017 @key[use] Complex_Types;
1018
1019 @AdaObjDefn{Default_Fore} : Field := 2;
1020 @AdaObjDefn{Default_Aft} : Field := Real'Digits - 1;
1021 @AdaObjDefn{Default_Exp} : Field := 3;
1022
1023
1024 @key[procedure] @AdaSubDefn{Get} (File : @key[in] File_Type;
1025 Item : @key[out] Complex;
1026 Width : @key[in] Field := 0);
1027 @key[procedure] @AdaSubDefn{Get} (Item : @key[out] Complex;
1028 Width : @key[in] Field := 0);
1029
1030
1031 @key[procedure] @AdaSubDefn{Put} (File : @key[in] File_Type;
1032 Item : @key[in] Complex;
1033 Fore : @key[in] Field := Default_Fore;
1034 Aft : @key[in] Field := Default_Aft;
1035 Exp : @key[in] Field := Default_Exp);
1036 @key[procedure] @AdaSubDefn{Put} (Item : @key[in] Complex;
1037 Fore : @key[in] Field := Default_Fore;
1038 Aft : @key[in] Field := Default_Aft;
1039 Exp : @key[in] Field := Default_Exp);
1040
1041
1042 @trailing@; @key[procedure] @AdaSubDefn{Get} (From : @key[in] String;
1043 Item : @key[out] Complex;
1044 Last : @key[out] Positive);
1045 @key[procedure] @AdaSubDefn{Put} (To : @key[out] String;
1046 Item : @key[in] Complex;
1047 Aft : @key[in] Field := Default_Aft;
1048 Exp : @key[in] Field := Default_Exp);
1049
1050 @key[end] Ada.Text_IO.Complex_IO;
1051 @end{Example}
1052
1053 @ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00328-01]}
1054 @ChgAdded{Version=[2],Text=[
1055 @ChildUnit{Parent=[Ada],Child=[Complex_@!Text_IO]}
1056 The library package Complex_Text_IO defines the
1057 same subprograms as Text_IO.Complex_IO, except that the predefined type Float
1058 is systematically substituted for Real, and the type
1059 Numerics.Complex_Types.Complex is systematically substituted for Complex
1060 throughout. Non-generic equivalents of Text_IO.Complex_IO corresponding to each
1061 of the other predefined floating point types are defined similarly, with the
1062 names Short_Complex_Text_IO, Long_Complex_Text_IO, etc.]}
1063 @begin{Reason}
1064 @ChgRef{Version=[2],Kind=[AddedNormal]}
1065 @ChgAdded{Version=[2],Text=[
1066 The nongeneric equivalents are provided to allow the programmer to
1067 construct simple mathematical applications without being required to
1068 understand and use generics.]}
1069 @end{Reason}
1070
1071 The semantics of the Get and Put procedures are as follows:
1072 @begin{DescribeCode}
1073 @begin{Example}
1074 @key[procedure] Get (File : @key[in] File_Type;
1075 Item : @key[out] Complex;
1076 Width : @key[in] Field := 0);
1077 @key[procedure] Get (Item : @key[out] Complex;
1078 Width : @key[in] Field := 0);
1079 @end{Example}
1080 @ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0092],ARef=[AI95-00029-01]}
1081 @Leading@;The input sequence is a pair of
1082 optionally signed real literals representing
1083 the real and imaginary components of a complex value@Chg{New=[ These components
1084 have the format defined for the corresponding Get procedure of an instance of
1085 Text_IO.Float_IO (see @RefSecNum{Input-Output for Real Types}) for the base
1086 subtype of Complex_Types.Real. T],Old=[; optionally, t]}he pair of components
1087 may be separated by a comma @Chg{New=[],Old=[and/]}or surrounded by a pair of
1088 parentheses@Chg{New=[ or both],Old=[]}. Blanks are freely allowed before each
1089 of the components and before the parentheses and comma, if either is used.
1090 If the value of the parameter Width is zero, then
1091 @begin{Itemize}
1092 line and page terminators are also allowed in these places;
1093
1094 the components shall be separated by at least one blank or line terminator
1095 if the comma is omitted; and
1096
1097 reading stops when the right parenthesis has been read, if the input
1098 sequence includes a left parenthesis, or when the imaginary component has
1099 been read, otherwise.
1100 @end{Itemize}
1101
1102 @ChgNote{The following paragraph is missing a number in the original version.
1103 To give it a number in the new version, it is marked as an insertion.}
1104 @ChgRef{Version=[0],Kind=[Added]}@Leading
1105 @Chg{New=[],Old=[@Noparanum@;]}If a nonzero value of Width is supplied, then
1106
1107 @begin{Itemize}
1108 the components shall be separated by at least one blank if the comma is
1109 omitted; and
1110
1111 exactly Width characters are read, or the characters (possibly none) up to
1112 a line terminator, whichever comes first (blanks are included in the count).
1113 @end{Itemize}
1114 @begin{Reason}
1115 The parenthesized and comma-separated form is the form produced by Put
1116 on output (see below), and also by list-directed output in Fortran. The
1117 other allowed forms match several common styles of edit-directed output in
1118 Fortran, allowing most preexisting Fortran data files containing complex
1119 data to be read easily. When such files contain complex values with no
1120 separation between the real and imaginary components, the user will have to
1121 read those components separately, using an instance of
1122 Text_IO.Float_IO.
1123 @end{Reason}
1124
1125 Returns, in the parameter Item, the value of type Complex that corresponds to
1126 the input sequence.
1127
1128 @Trailing@;The exception Text_IO.Data_Error
1129 is raised if the input sequence
1130 does not have the required syntax or if the components of the complex value
1131 obtained are not of the base subtype of Complex_Types.Real.
1132
1133 @begin{Example}
1134 @key[procedure] Put (File : @key[in] File_Type;
1135 Item : @key[in] Complex;
1136 Fore : @key[in] Field := Default_Fore;
1137 Aft : @key[in] Field := Default_Aft;
1138 Exp : @key[in] Field := Default_Exp);
1139 @key[procedure] Put (Item : @key[in] Complex;
1140 Fore : @key[in] Field := Default_Fore;
1141 Aft : @key[in] Field := Default_Aft;
1142 Exp : @key[in] Field := Default_Exp);
1143 @end{Example}
1144
1145 Outputs the value of the parameter Item as a pair of decimal literals
1146 representing the real and imaginary components of the complex value,
1147 using the syntax
1148 of an aggregate.
1149 More specifically,
1150 @begin{itemize}
1151 outputs a left parenthesis;
1152
1153 outputs the value of the real component of the parameter Item with the
1154 format defined by the corresponding Put procedure of an instance of
1155 Text_IO.Float_IO for the base subtype of Complex_Types.Real, using the given values of
1156 Fore, Aft, and Exp;
1157
1158 outputs a comma;
1159
1160 outputs the value of the imaginary component of the parameter Item with the
1161 format defined by the corresponding Put procedure of an instance of
1162 Text_IO.Float_IO for the base subtype of Complex_Types.Real, using the given values of
1163 Fore, Aft, and Exp;
1164
1165 @Trailing@;outputs a right parenthesis.
1166 @end{itemize}
1167 @begin{Discussion}
1168 If the file has a bounded line length, a line terminator may be output
1169 implicitly before any element of the sequence itemized above.
1170 @end{Discussion}
1171 @begin{Discussion}
1172 The option of outputting the complex value as a pair of reals without
1173 additional punctuation
1174 is not provided, since it can be
1175 accomplished by outputting the real and imaginary components of the complex
1176 value separately.
1177 @end{Discussion}
1178
1179 @begin{Example}
1180 @key[procedure] Get (From : @key[in] String;
1181 Item : @key[out] Complex;
1182 Last : @key[out] Positive);
1183 @end{Example}
1184
1185 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00434-01]}
1186 Reads a complex value from the beginning of the given string, following the
1187 same rule as the Get procedure that reads a complex value from a file, but
1188 treating the end of the string as a @Chg{Version=[2],New=[file],Old=[line]}
1189 terminator. Returns, in the parameter
1190 Item, the value of type Complex that corresponds to the input sequence.
1191 Returns in Last the index value such that From(Last) is the last character
1192 read.
1193
1194 @Trailing@;The exception Text_IO.Data_Error is raised if the input sequence
1195 does not have the required syntax or if the components of the complex value
1196 obtained are not of the base subtype of Complex_Types.Real.
1197
1198 @begin{Example}
1199 @key[procedure] Put (To : @key[out] String;
1200 Item : @key[in] Complex;
1201 Aft : @key[in] Field := Default_Aft;
1202 Exp : @key[in] Field := Default_Exp);
1203 @end{Example}
1204
1205 Outputs the value of the parameter Item to the given string as a pair of
1206 decimal literals representing the real and imaginary components of the complex
1207 value, using the syntax of an aggregate.
1208 More specifically,
1209 @begin{itemize}
1210 a left parenthesis, the real component, and a comma are left justified in
1211 the given string, with the real component having the format defined by the
1212 Put procedure (for output to a file) of an instance of Text_IO.Float_IO
1213 for the base subtype of Complex_Types.Real, using a value of zero for Fore and the given
1214 values of Aft and Exp;
1215
1216 the imaginary component and a right parenthesis are right justified in the
1217 given string, with the imaginary component having the format defined by the
1218 Put procedure (for output to a file) of an instance of Text_IO.Float_IO
1219 for the base subtype of Complex_Types.Real, using a value for Fore that completely fills
1220 the remainder of the string, together with the given values of Aft and Exp.
1221 @end{itemize}
1222 @begin{Reason}
1223 This rule is the one proposed in LSN-1051. Other rules were considered,
1224 including one that would have read @lquotes@;Outputs the value of the parameter Item
1225 to the given string, following the same rule as for output to a file, using
1226 a value for Fore such that the sequence of characters output exactly fills,
1227 or comes closest to filling, the string; in the latter case, the string is
1228 filled by inserting one extra blank immediately after the comma.@rquotes@; While
1229 this latter rule might be considered the closest analogue to the rule for
1230 output to a string in Text_IO.Float_IO, it requires a more difficult and
1231 inefficient implementation involving special cases when the integer part of
1232 one component is substantially longer than that of the other and the string
1233 is too short to allow both to be preceded by blanks. Unless such a special
1234 case applies, the latter rule might produce better columnar output if
1235 several such strings are ultimately output to a file, but very nearly the
1236 same output can be produced by outputting to the file directly, with the
1237 appropriate value of Fore; in any case, it might validly be assumed that
1238 output to a string is intended for further computation rather than for
1239 display, so that the precise formatting of the string to achieve a
1240 particular appearance is not the major concern.
1241 @end{Reason}
1242
1243 The exception Text_IO.Layout_Error is raised if the given string is
1244 too short to hold the formatted output.
1245 @end{DescribeCode}
1246 @end{StaticSem}
1247
1248 @begin{ImplPerm}
1249 Other exceptions declared (by renaming)
1250 in Text_IO may be raised by the preceding procedures
1251 in the appropriate circumstances, as for the corresponding
1252 procedures of Text_IO.Float_IO.
1253 @end{ImplPerm}
1254
1255 @begin{Extend95}
1256 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00328-01]}
1257 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
1258 Nongeneric equivalents for Text_IO.Complex_IO are added, to be consistent
1259 with all other language-defined Numerics generic packages.]}
1260 @end{Extend95}
1261
1262 @begin{DiffWord95}
1263 @ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0092],ARef=[AI95-00029-01]}
1264 @ChgAdded{Version=[2],Text=[@b<Corrigendum:> Clarified that the syntax
1265 of values read by Complex_IO is the same as that read by Text_IO.Float_IO.]}
1266 @end{DiffWord95}
1267
1268
1269 @LabeledSubClause{The Package Wide_Text_IO.Complex_IO}
1270
1271 @begin{StaticSem}
1272 @Defn{Ada.Wide_@!Text_IO.Complex_IO}
1273 @ChildUnit{Parent=[Ada.Wide_@!Text_IO],Child=[Complex_IO]}
1274 Implementations shall also provide the generic library package
1275 Wide_Text_IO.Complex_IO. Its declaration is obtained from that of
1276 Text_IO.Complex_IO by systematically replacing Text_IO by Wide_Text_IO and
1277 String by Wide_String; the description of its behavior is obtained by
1278 additionally replacing references to particular characters (commas,
1279 parentheses, etc.) by those for the corresponding wide characters.
1280 @end{StaticSem}
1281
1282
1283 @LabeledAddedSubClause{Version=[2],Name=[The Package Wide_Wide_Text_IO.Complex_IO]}
1284
1285 @begin{StaticSem}
1286 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01]}
1287 @ChgAdded{Version=[2],Text=[@Defn{Ada.Wide_Wide_@!Text_IO.Complex_IO}
1288 @ChildUnit{Parent=[Ada.Wide_Wide_@!Text_IO],Child=[Complex_IO]}
1289 Implementations shall also provide the generic library package
1290 Wide_Wide_Text_IO.Complex_IO. Its declaration is obtained from that of
1291 Text_IO.Complex_IO by systematically replacing Text_IO by Wide_Wide_Text_IO and
1292 String by Wide_Wide_String; the description of its behavior is obtained by
1293 additionally replacing references to particular characters (commas,
1294 parentheses, etc.) by those for the corresponding wide wide characters.]}
1295 @end{StaticSem}
1296
1297 @begin{Extend95}
1298 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01]}
1299 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
1300 Package Wide_Wide_Text_IO.Complex_IO is new. (At least it wasn't called
1301 Incredibly_Wide_Text_IO.Complex_IO; maybe next time.)]}
1302 @end{Extend95}
1303
1304
1305 @LabeledClause{Numeric Performance Requirements}
1306
1307 @begin{ImplReq}
1308 @Defn{accuracy}
1309 @Defn{strict mode}
1310 Implementations shall provide a user-selectable mode in which the accuracy
1311 and other numeric performance requirements detailed in the following subclauses
1312 are observed.
1313 This mode,
1314 referred to as the @i{strict mode}, may or may not be the default mode;
1315 it directly affects the results of the predefined arithmetic operations of real
1316 types and the results of the subprograms in
1317 children of the Numerics package, and indirectly affects the operations in
1318 other language defined packages.
1319 @Defn{relaxed mode}
1320 Implementations shall also provide the opposing mode, which is known as the
1321 @i{relaxed mode}.
1322 @begin{Reason}
1323 On the assumption that the users of an implementation that does not support
1324 the Numerics Annex have no particular need for numerical performance, such
1325 an implementation has no obligation to meet any particular requirements in
1326 this area. On the other hand, users of an implementation that does support
1327 the Numerics Annex are provided with a way of ensuring that their programs
1328 achieve a known level of numerical performance and that the performance is
1329 portable to other such implementations. The relaxed mode is provided to
1330 allow implementers to offer an efficient but not fully accurate alternative
1331 in the case that the strict mode entails a time overhead that some users may
1332 find excessive. In some of its areas of impact, the relaxed mode may be
1333 fully equivalent to the strict mode.
1334 @end{Reason}
1335 @begin{ImplNote}
1336 The relaxed mode may, for example, be used to exploit the implementation of
1337 (some of) the elementary functions in hardware, when available. Such
1338 implementations often do not meet the accuracy requirements of the strict
1339 mode, or do not meet them over the specified range of parameter values,
1340 but compensate in other ways that may be important to the user, such as
1341 their extreme speed.
1342 @end{ImplNote}
1343 @begin{Ramification}
1344 For implementations supporting the Numerics Annex,
1345 the choice of mode has no
1346 effect on the selection of a representation for a real type or on the values
1347 of attributes of a real type.
1348 @end{Ramification}
1349 @end{ImplReq}
1350
1351 @begin{ImplPerm}
1352 Either mode may be the default mode.
1353 @ImplDef{Whether the strict mode or the relaxed mode is the default.}
1354
1355 The two modes need not actually be different.
1356 @end{ImplPerm}
1357
1358 @begin{Extend83}
1359 @Defn{extensions to Ada 83}
1360 The choice between strict and relaxed numeric performance was not available in
1361 Ada 83.
1362 @end{Extend83}
1363
1364
1365 @RMNewPage@Comment{For printed version of Ada 2007 RM}
1366 @LabeledSubClause{Model of Floating Point Arithmetic}
1367
1368 @begin{Intro}
1369 In the strict mode, the predefined operations of a floating point type shall
1370 satisfy the accuracy requirements specified here and shall avoid or signal
1371 overflow in the situations described. This behavior is presented in terms of
1372 a model of floating point arithmetic that builds on the concept of the
1373 canonical form (see @RefSecNum{Attributes of Floating Point Types}).
1374 @end{Intro}
1375
1376 @begin{StaticSem}
1377 Associated with each floating point type is an infinite set of
1378 model numbers. The model numbers of a type are used to define the
1379 accuracy requirements that have to be satisfied by certain predefined
1380 operations of the type; through certain attributes of
1381 the model numbers, they are also used to explain
1382 the meaning of a user-declared floating point type declaration.
1383 The model numbers of a derived type are those of the
1384 parent type; the model numbers of a subtype are those of its type.
1385
1386 @Defn{model number}
1387 The @i{model numbers} of a floating point type T are zero and all the values
1388 expressible in the canonical form (for the type T),
1389 in which @i{mantissa} has T'Model_Mantissa digits
1390 and @i{exponent} has a value greater than or equal
1391 to T'Model_Emin.
1392 (These attributes are defined in
1393 @RefSecNum{Model-Oriented Attributes of Floating Point Types}.)
1394 @begin{Discussion}
1395 The model is capable of describing the behavior of most existing hardware
1396 that has a mantissa-exponent representation. As applied to a type T, it is
1397 parameterized by the values of T'Machine_Radix, T'Model_Mantissa,
1398 T'Model_Emin, T'Safe_First, and T'Safe_Last. The values of these
1399 attributes are determined by how, and how well, the hardware behaves.
1400 They in turn determine the set of model numbers and the safe range of the
1401 type, which figure in the accuracy and range (overflow avoidance)
1402 requirements.
1403
1404 In hardware that is free of arithmetic anomalies, T'Model_Mantissa,
1405 T'Model_Emin, T'Safe_First, and T'Safe_Last will yield the same values as
1406 T'Machine_Mantissa, T'Machine_Emin, T'Base'First, and T'Base'Last,
1407 respectively, and the
1408 model numbers in the safe range of the type T will coincide with the machine
1409 numbers of the type T. In less perfect hardware, it is not possible for the
1410 model-oriented attributes to have these optimal values, since the hardware,
1411 by definition, and therefore the implementation, cannot conform to the
1412 stringencies of the resulting model; in this case, the values yielded by the
1413 model-oriented parameters have to be made more conservative (i.e., have to
1414 be penalized), with the result that the model numbers are more widely
1415 separated than the machine numbers, and the safe range is a subrange of the
1416 base range. The implementation will then be able to conform to the
1417 requirements of the weaker model defined by the sparser set of model numbers
1418 and the smaller safe range.
1419 @end{Discussion}
1420
1421 @Defn{model interval}
1422 A @i(model interval) of a floating point type is any interval whose bounds
1423 are model numbers of the type.
1424 @Defn2{Term=[model interval],
1425 Sec=[associated with a value]}
1426 The @i{model interval} of a type T @i{associated with a value} @i{v} is the
1427 smallest model interval of T that includes @i{v}. (The model interval
1428 associated with a model number of a type consists of that number only.)
1429 @end{StaticSem}
1430
1431 @begin{ImplReq}
1432 The accuracy requirements for the evaluation of certain predefined
1433 operations of floating point types are as follows.
1434 @begin{Discussion}
1435 This subclause does not cover the accuracy of an operation of a static
1436 expression; such operations
1437 have to be evaluated exactly
1438 (see @RefSecNum(Static Expressions and Static Subtypes)).
1439 It also does not cover the accuracy of the predefined attributes of a
1440 floating point subtype that yield a value of the type;
1441 such operations also yield exact results
1442 (see @RefSecNum(Operations of Floating Point Types)
1443 and @RefSecNum(Attributes of Floating Point Types)).
1444 @end{Discussion}
1445
1446 @Defn{operand interval}
1447 An @i(operand interval) is the model interval, of the type specified for the
1448 operand of an operation, associated with the value of the operand.
1449
1450 @Leading@;For any predefined arithmetic operation
1451 that yields a result of a
1452 floating point type T, the required bounds on the result are given by
1453 a model interval of T (called the @i(result interval)) defined in terms of the
1454 operand values as follows:
1455 @begin(Itemize)
1456 @Defn2{Term=[result interval],
1457 Sec=[for the evaluation of a predefined arithmetic operation]}
1458 The result interval is the smallest model interval of T that includes
1459 the minimum and the maximum of all the values obtained by applying the
1460 (exact) mathematical operation to values arbitrarily selected from the
1461 respective operand intervals.
1462 @end(Itemize)
1463
1464 The result interval of an exponentiation is obtained by applying the above rule
1465 to the sequence of multiplications defined by the exponent, assuming arbitrary
1466 association of the factors, and to the final division in the case of a negative
1467 exponent.
1468
1469 The result interval of a conversion of a numeric value to a floating point type
1470 T is the model interval of T associated with the operand value, except when the
1471 source expression is of a fixed point type
1472 with a @i(small) that is not a power
1473 of T'Machine_Radix or is a fixed point multiplication or division either of
1474 whose operands has a @i(small) that is not a power of T'Machine_Radix;
1475 in these cases, the result interval is implementation defined.
1476 @ImplDef{The result interval in certain cases of fixed-to-float conversion.}
1477
1478 @IndexCheck{Overflow_Check}
1479 For any of the foregoing operations, the implementation shall deliver a value
1480 that belongs to the result interval when both bounds of the result interval are
1481 in the safe range of the result type T, as determined by the values of
1482 T'Safe_First and T'Safe_Last; otherwise,
1483 @begin(itemize)
1484 @Defn2{Term=[Constraint_Error],Sec=(raised by failure of run-time check)}
1485 if T'Machine_Overflows is True, the implementation shall either deliver a
1486 value that belongs to the result interval or raise Constraint_Error;
1487
1488 if T'Machine_Overflows is False, the result is implementation defined.
1489 @ImplDef{The result of a floating point arithmetic operation in
1490 overflow situations, when the Machine_Overflows attribute of the result
1491 type is False.}
1492 @end(itemize)
1493
1494 For any predefined relation on operands of a floating point type T, the
1495 implementation may deliver any value (i.e., either True or False) obtained by
1496 applying the (exact) mathematical comparison to values arbitrarily chosen from
1497 the respective operand intervals.
1498
1499 The result of a membership test is defined in terms of comparisons of the
1500 operand value with the lower and upper bounds of the given range or type
1501 mark (the usual rules apply to these comparisons).
1502 @end{ImplReq}
1503
1504 @begin{ImplPerm}
1505 If the underlying floating point hardware implements division
1506 as multiplication by a reciprocal, the result interval
1507 for division (and exponentiation by a negative exponent) is
1508 implementation
1509 defined.
1510 @ImplDef{The result interval for division (or exponentiation by a
1511 negative exponent), when the floating point hardware implements division as
1512 multiplication by a reciprocal.}
1513 @end{ImplPerm}
1514
1515 @begin{DiffWord83}
1516 The Ada 95 model numbers of a floating point type that are in the safe range of
1517 the type are comparable to the Ada 83 safe numbers of the type. There is no
1518 analog of the Ada 83 model numbers. The Ada 95 model numbers, when not
1519 restricted to the safe range, are an infinite set.
1520 @end{DiffWord83}
1521
1522 @begin{Inconsistent83}
1523 @Defn{inconsistencies with Ada 83}
1524 Giving the model numbers the hardware radix, instead of always a radix of two,
1525 allows (in conjunction with other changes) some borderline declared
1526 types to be represented with less precision than in Ada 83 (i.e., with single
1527 precision, whereas Ada 83 would have used double precision). Because the lower
1528 precision satisfies the requirements of the model (and did so in Ada 83 as
1529 well), this change is viewed as a desirable correction of an anomaly, rather
1530 than a worrisome inconsistency. (Of course, the wider representation chosen in
1531 Ada 83 also remains eligible for selection in Ada 95.)
1532
1533 As an example of this phenomenon, assume that Float is represented in single
1534 precision and that a double precision type is also available. Also assume
1535 hexadecimal hardware with clean properties, for example certain IBM hardware.
1536 Then,
1537 @begin{Example}
1538 @key[type] T @key[is] @key[digits] Float'Digits @key[range] -Float'Last .. Float'Last;
1539 @end{Example}
1540
1541 results in T being represented in double precision in Ada 83 and in single
1542 precision in Ada 95. The latter is intuitively correct; the former is
1543 counterintuitive. The reason why the double precision type is used in Ada 83
1544 is that Float has model and safe numbers (in Ada 83) with 21 binary digits in
1545 their mantissas, as is required to model the hypothesized
1546 hexadecimal hardware using a binary
1547 radix; thus Float'Last, which is not a model number, is slightly outside the
1548 range of safe numbers of the single precision type, making that type ineligible
1549 for selection as the representation of T even though it provides adequate
1550 precision. In Ada 95, Float'Last (the same value as before) is a model number
1551 and is in the safe range of Float on the hypothesized hardware, making Float
1552 eligible for the representation of T.
1553 @end{Inconsistent83}
1554
1555 @begin{Extend83}
1556 @Defn{extensions to Ada 83}
1557 Giving the model numbers the hardware radix allows for practical
1558 implementations on decimal hardware.
1559 @end{Extend83}
1560
1561 @begin{DiffWord83}
1562 The wording of the model of floating point arithmetic has been simplified to a
1563 large extent.
1564 @end{DiffWord83}
1565
1566
1567 @LabeledSubClause{Model-Oriented Attributes of Floating Point Types}
1568
1569 @begin{Intro}
1570 In implementations that support the Numerics Annex, the model-oriented
1571 attributes of floating point types shall yield the values defined here,
1572 in both the strict and the relaxed modes.
1573 These definitions add conditions to those in
1574 @RefSecNum{Attributes of Floating Point Types}.
1575 @end{Intro}
1576
1577 @begin{StaticSem}
1578 @Leading@keepnext@;For every subtype S of a floating point type @i{T}:
1579 @begin{Description}
1580 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00256-01]}
1581 S'@Attr{Model_Mantissa} @\Yields the number of digits in the mantissa of
1582 the canonical form of the model numbers of @i{T}
1583 (see @RefSecNum{Attributes of Floating Point Types}). The
1584 value of this attribute shall be greater than or equal to@Chg{Version=[2],New=[],
1585 Old=[ @Ceiling{@RI{d} @Times @Log(10) / @Log(@RI{T}'@R{Machine_Radix})} + 1, where @RI{d}
1586 is the requested decimal precision of @i{T}. In addition, it
1587 shall be less than or equal to the value of
1588 @i{T}'Machine_Mantissa. This attribute yields a value of the
1589 type @i{universal_integer}.]}
1590 @begin{Display}
1591 @ChgRef{Version=[2],Kind=[Added]}
1592 @ChgAdded{Version=[2],Text=[@Ceiling{@RI{d} @Times @Log(10) / @Log(@RI{T}'@R{Machine_Radix})} + @RI{g}]}
1593 @end{Display}
1594 @ChgRef{Version=[2],Kind=[Added]}
1595 @ChgAdded{Version=[2],NoPrefix=[T],Text=[where @RI{d}
1596 is the requested decimal precision of @i{T}, and @RI{g} is 0 if
1597 @i{T}'Machine_Radix
1598 is a positive power of 10 and 1 otherwise. In addition, @i{T}'Model_Mantissa
1599 shall be less than or equal to the value of
1600 @i{T}'Machine_Mantissa. This attribute yields a value of the
1601 type @i{universal_integer}.]}
1602 @begin{Ramification}
1603 S'Model_Epsilon, which is defined in terms of S'Model_Mantissa
1604 (see @RefSecNum{Attributes of Floating Point Types}), yields the
1605 absolute value of the difference between one and the next model number of
1606 the type @i{T} above one.
1607 It is equal to or larger than the absolute value of the difference
1608 between one and the next machine number of the type @i{T} above
1609 one.
1610 @end{Ramification}
1611
1612 S'@Attr{Model_Emin} @\Yields the minimum exponent of the canonical form
1613 of the model numbers of @i{T}
1614 (see @RefSecNum{Attributes of Floating Point Types}). The value of this
1615 attribute shall be greater than or equal to the value of
1616 @i{T}'Machine_Emin. This attribute yields a value of the type
1617 @i{universal_integer}.
1618 @begin{Ramification}
1619 S'Model_Small, which is defined in terms of S'Model_Emin
1620 (see @RefSecNum{Attributes of Floating Point Types}), yields the
1621 smallest positive (nonzero) model number of the type @i{T}.
1622 @end{Ramification}
1623
1624 S'@Attr{Safe_First} @\Yields the lower bound of the safe range of @i{T}.
1625 The value of this attribute shall be a model number of @i{T} and greater
1626 than or equal to the lower bound of the base range of @i{T}.
1627 In addition, if @i{T} is declared by a
1628 @nt{floating_point_definition} or is derived from such a type,
1629 and the @nt{floating_point_definition} includes a
1630 @nt{real_range_specification} specifying a lower bound of @RI{lb},
1631 then the value of this attribute shall be less than or
1632 equal to @RI{lb}; otherwise, it shall be less than or equal to
1633 @en@;10.0 @+[4 @Times @RI{d}], where @RI{d} is the requested decimal precision
1634 of @i{T}. This attribute yields a value of the type
1635 @i{universal_real}.
1636
1637 S'@Attr{Safe_Last} @\Yields the upper bound of the safe range of @i{T}.
1638 The value of this attribute shall be a model number of @i{T} and less
1639 than or equal to the upper bound of the base range of @i{T}.
1640 In addition, if @i{T} is declared by a
1641 @nt{floating_point_definition} or is derived from such a type,
1642 and the @nt{floating_point_definition} includes a
1643 @nt{real_range_specification} specifying an upper bound of @RI{ub},
1644 then the value of this attribute shall be greater than or
1645 equal to @RI{ub}; otherwise, it shall be greater than or equal
1646 to 10.0 @+[4 @Times @RI{d}], where d is the requested decimal
1647 precision of @i{T}. This attribute yields a value of the type
1648 @i{universal_real}.
1649
1650 @Defn2{Term=[Constraint_Error],Sec=(raised by failure of run-time check)}S'@Attr{Model} @\Denotes a function (of a parameter @i{X}) whose specification
1651 is given in
1652 @RefSecNum{Attributes of Floating Point Types}.
1653 If @i{X} is a model number of @i{T}, the
1654 function yields @i{X}; otherwise, it yields the value obtained
1655 by rounding or truncating @i{X} to either one of the adjacent
1656 model numbers of @i{T}.
1657 @IndexCheck{Overflow_Check}Constraint_Error is raised if the
1658 resulting model number is outside the safe range of S. A
1659 zero result has the sign of @i{X} when S'Signed_Zeros is True.
1660 @end{Description}
1661
1662 @Leading@;Subject to the constraints given above, the values of S'Model_Mantissa and
1663 S'Safe_Last are to be maximized, and the values of S'Model_Emin and
1664 S'Safe_First minimized, by the implementation as follows:
1665 @begin{Itemize}
1666 First, S'Model_Mantissa is set to the largest value for which values
1667 of S'Model_Emin, S'Safe_First, and S'Safe_Last can be chosen so that
1668 the implementation satisfies the strict-mode requirements of
1669 @RefSecNum{Model of Floating Point Arithmetic} in
1670 terms of the model numbers and safe range induced by these attributes.
1671
1672 Next, S'Model_Emin is set to the smallest value for which values of
1673 S'Safe_First and S'Safe_Last can be chosen so that the implementation
1674 satisfies the strict-mode requirements of
1675 @RefSecNum{Model of Floating Point Arithmetic} in terms of the model
1676 numbers and safe range induced by these attributes and the previously
1677 determined value of S'Model_Mantissa.
1678
1679 Finally, S'Safe_First and S'Safe_last are set (in either order) to the
1680 smallest and largest values, respectively, for which the
1681 implementation satisfies the strict-mode requirements of
1682 @RefSecNum{Model of Floating Point Arithmetic} in
1683 terms of the model numbers and safe range induced by these attributes
1684 and the previously determined values of S'Model_Mantissa and
1685 S'Model_Emin.
1686 @end{Itemize}
1687
1688 @begin{Ramification}
1689
1690 @Defn{IEEE floating point arithmetic}
1691 @Defn{IEC 559:1989}
1692 The following table shows appropriate attribute values for IEEE basic
1693 single and double precision types (ANSI/IEEE Std 754-1985, IEC 559:1989).
1694 Here, we use the names IEEE_Float_32 and IEEE_Float_64,
1695 the names that would typically be declared in package Interfaces,
1696 in an implementation that supports IEEE arithmetic.
1697 In such an implementation,
1698 the attributes would typically be the same for Standard.Float and
1699 Long_Float, respectively.
1700 @begin{Example}
1701 Attribute IEEE_Float_32 IEEE_Float_64
1702
1703 'Machine_Radix 2 2
1704 'Machine_Mantissa 24 53
1705 'Machine_Emin -125 -1021
1706 'Machine_Emax 128 1024
1707 'Denorm True True
1708 'Machine_Rounds True True
1709 'Machine_Overflows True/False True/False
1710 'Signed_Zeros should be True should be True
1711
1712 'Model_Mantissa (same as 'Machine_Mantissa) (same as 'Machine_Mantissa)
1713 'Model_Emin (same as 'Machine_Emin) (same as 'Machine_Emin)
1714 'Model_Epsilon 2.0**(-23) 2.0**(-52)
1715 'Model_Small 2.0**(-126) 2.0**(-1022)
1716 'Safe_First -2.0**128*(1.0-2.0**(-24)) -2.0**1024*(1.0-2.0**(-53))
1717 'Safe_Last 2.0**128*(1.0-2.0**(-24)) 2.0**1024*(1.0-2.0**(-53))
1718
1719 'Digits 6 15
1720 'Base'Digits (same as 'Digits) (same as 'Digits)
1721
1722 'First (same as 'Safe_First) (same as 'Safe_First)
1723 'Last (same as 'Safe_Last) (same as 'Safe_Last)
1724 'Size 32 64
1725 @end{Example}
1726
1727 Note: 'Machine_Overflows can be True or False, depending on whether the Ada
1728 implementation raises Constraint_Error or delivers a signed infinity in
1729 overflow and zerodivide situations (and at poles of the elementary functions).
1730
1731 @end{Ramification}
1732 @end{StaticSem}
1733
1734 @begin{DiffWord95}
1735 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00256-01]}
1736 @ChgAdded{Version=[2],Text=[Corrected the definition of Model_Mantissa to
1737 match that given in @RefSecNum{Operations of Floating Point Types}.]}
1738 @end{DiffWord95}
1739
1740
1741
1742 @LabeledSubClause{Model of Fixed Point Arithmetic}
1743
1744 @begin{Intro}
1745 In the strict mode, the predefined arithmetic operations of a fixed point type
1746 shall satisfy the accuracy requirements specified here and shall avoid or
1747 signal overflow in the situations described.
1748 @end{Intro}
1749
1750 @begin{ImplReq}
1751 The accuracy requirements for the predefined fixed point arithmetic operations
1752 and conversions, and the results of relations on fixed point operands, are
1753 given below.
1754 @begin{Discussion}
1755 This subclause does not cover the accuracy of an operation of a static
1756 expression; such operations
1757 have to be evaluated exactly
1758 (see @RefSecNum(Static Expressions and Static Subtypes)).
1759 @end{Discussion}
1760
1761 The operands of the fixed point adding operators, absolute value,
1762 and comparisons have the same type. These operations are required to
1763 yield exact results, unless they overflow.
1764
1765 Multiplications and divisions are allowed between operands of any two
1766 fixed point types; the result has to be (implicitly or explicitly)
1767 converted to some other numeric type.
1768 For purposes of defining the accuracy rules, the multiplication or
1769 division and the conversion are treated
1770 as a single operation whose accuracy depends on three types (those
1771 of the operands and the result).
1772 For decimal fixed point types, the
1773 attribute T'Round may be used to imply explicit conversion with
1774 rounding (see @RefSecNum(Operations of Fixed Point Types)).
1775
1776 When the result type is a floating point type, the accuracy is
1777 as given in @RefSecNum(Model of Floating Point Arithmetic).
1778 @Defn{perfect result set}
1779 For some combinations of the operand and result types in the remaining cases,
1780 the result is required to belong to a small set of values called the
1781 @i(perfect result set);
1782 @Defn{close result set}
1783 for other combinations, it is required merely to belong to a
1784 generally larger and implementation-defined set of values called the
1785 @i(close result set).
1786 When the result type is a decimal fixed point type, the perfect result set
1787 contains a single value; thus, operations on decimal types are always
1788 fully specified.
1789 @ImplDef{The definition of @i{close result set}, which determines the
1790 accuracy of certain fixed point multiplications and
1791 divisions.}
1792
1793 When one operand of a fixed-fixed multiplication or division is of type
1794 @i(universal_real), that operand is not implicitly converted in the usual sense,
1795 since the context does not determine a unique target type, but the accuracy of
1796 the result of the multiplication or division (i.e., whether the result has to
1797 belong to the perfect result set or merely the close result set) depends on the
1798 value of the operand of type @i(universal_real) and on the types of the other
1799 operand and of the result.
1800 @begin{Discussion}
1801 We need not consider here the multiplication or
1802 division of two such operands, since in that case either the operation is
1803 evaluated exactly (i.e., it is an operation of a static expression all of whose
1804 operators are of a root numeric type) or it is considered to be an operation of
1805 a floating point type.
1806 @end{Discussion}
1807
1808 @Leading@;For a fixed point multiplication or division whose (exact)
1809 mathematical result is @RI{v}, and for the conversion of a value
1810 @RI{v} to a fixed point type, the perfect result set and close result set
1811 are defined as follows:
1812 @begin(itemize)
1813 @Leading@Keepnext@;If the result type is an ordinary fixed point
1814 type with a @i(small) of @RI{s},
1815 @begin(InnerItemize)
1816 if @RI{v} is an integer multiple of
1817 @RI{s},
1818 then the perfect result set contains only the value
1819 @RI{v};
1820
1821 otherwise, it contains the integer multiple of
1822 @RI{s} just below
1823 @RI{v} and the
1824 integer multiple of @RI{s} just above
1825 @RI{v}.
1826 @end(InnerItemize)
1827
1828 @NoPrefix@;The close result set is an implementation-defined set of consecutive
1829 integer multiples of @RI{s} containing the perfect
1830 result set as a subset.
1831
1832 @Leading@Keepnext@;If the result type is a decimal type with a @i(small) of
1833 @RI{s},
1834 @begin(InnerItemize)
1835 if @RI{v} is an integer multiple of
1836 @RI{s},
1837 then the perfect result set contains
1838 only the value @RI{v};
1839
1840 otherwise, if truncation applies then it contains only the integer
1841 multiple of @RI{s} in the direction toward zero,
1842 whereas if rounding
1843 applies then it contains only the nearest integer multiple of
1844 @RI{s} (with
1845 ties broken by rounding away from zero).
1846 @end(InnerItemize)
1847
1848 @NoPrefix@;The close result set is an implementation-defined set of consecutive
1849 integer multiples of @RI{s} containing the perfect
1850 result set as a subset.
1851 @begin{Ramification}
1852 As a consequence of subsequent rules, this case does not arise
1853 when the operand types are also decimal types.
1854 @end{Ramification}
1855
1856 @Leading@Keepnext@;If the result type is an integer type,
1857 @begin(InnerItemize)
1858 if @RI{v} is an integer,
1859 then the perfect result set contains only the
1860 value @RI{v};
1861
1862 otherwise, it contains the integer nearest to the value
1863 @RI{v} (if @RI{v} lies
1864 equally distant from two consecutive integers, the perfect result set
1865 contains the one that is further from zero).
1866 @end(InnerItemize)
1867
1868 @NoPrefix@;The close result set is an implementation-defined set of consecutive
1869 integers containing the perfect result set as a subset.
1870 @end(itemize)
1871
1872 The result of a fixed point multiplication or division shall belong either to
1873 the perfect result set or to the close result set, as described below, if
1874 overflow does not occur. In the following
1875 cases, if the result type is a fixed point type,
1876 let @RI{s} be its @i(small);
1877 otherwise, i.e. when the result type is an integer type,
1878 let @RI{s} be 1.0.
1879 @begin(itemize)
1880 For a multiplication or division neither of whose operands is of type
1881 @i(universal_real), let @RI{l} and @RI{r}
1882 be the @i(smalls) of the left and right
1883 operands. For a multiplication, if (@RI{l} @Times @RI{r}) / @RI{s}
1884 is an integer or the
1885 reciprocal of an integer (the @i(smalls) are said to be @lquotes@;compatible@rquotes@; in
1886 this case), the result shall belong to the perfect result set; otherwise, it
1887 belongs to the close result set. For a division, if
1888 @RI{l} / (@RI{r} @Times @RI{s}) is an
1889 integer or the reciprocal of an integer (i.e., the @i(smalls) are
1890 compatible), the result shall belong to the perfect result set; otherwise,
1891 it belongs to the close result set.
1892 @begin{Ramification}
1893 When the operand and result types are all decimal types, their @i(smalls)
1894 are necessarily compatible; the same is true when they are all ordinary
1895 fixed point types with binary @i(smalls).
1896 @end{Ramification}
1897
1898 For a multiplication or division having one @i(universal_real) operand with
1899 a value of @RI{v},
1900 note that it is always possible to factor
1901 @RI{v} as an integer
1902 multiple of a @lquotes@;compatible@rquotes@; @i(small), but the integer multiple may be
1903 @lquotes@;too big.@rquotes@;
1904 If there exists a factorization in which that multiple is less than some
1905 implementation-defined limit, the result shall belong to the perfect result
1906 set; otherwise, it belongs to the close result set.
1907 @ImplDef{Conditions on a @i{universal_real} operand of a fixed point
1908 multiplication or division for which the result shall be in the @i{perfect
1909 result set}.}
1910 @end(itemize)
1911
1912 A multiplication P * Q of an operand of a fixed point type F by an operand of
1913 an integer type I, or vice-versa, and a division P / Q of an operand of a
1914 fixed point type F by an operand of an integer type I, are also allowed.
1915 In these cases, the result has a type of F; explicit conversion of the
1916 result is never required. The accuracy required in these cases is the same as
1917 that required for a multiplication F(P * Q) or a division F(P / Q) obtained by
1918 interpreting the operand of the integer type to have a fixed point type with a
1919 @i(small) of 1.0.
1920
1921 The accuracy of the result of a conversion from an integer or fixed point type
1922 to a fixed point type, or from a fixed point type to an integer
1923 type, is the same as that of a fixed point multiplication of the source value
1924 by a fixed point operand having a @i(small) of 1.0 and a value of 1.0, as given
1925 by the foregoing rules. The result of a conversion from a floating point type
1926 to a fixed point type shall belong to the close result set.
1927 The result of a conversion of a @i(universal_real) operand to a fixed point
1928 type shall belong to the perfect result set.
1929
1930 The possibility of overflow in the result of a predefined arithmetic operation
1931 or conversion yielding a result of a fixed point type T is analogous to that
1932 for floating point types, except for being related to the base range instead of
1933 the safe range.
1934 @IndexCheck{Overflow_Check}
1935 If all of the permitted results belong to the base range of T,
1936 then the implementation shall deliver one of the permitted results; otherwise,
1937 @begin(itemize)
1938 @Defn2{Term=[Constraint_Error],Sec=(raised by failure of run-time check)}
1939 if T'Machine_Overflows is True, the implementation shall either deliver one
1940 of the permitted results or raise Constraint_Error;
1941
1942 if T'Machine_Overflows is False, the result is implementation defined.
1943 @ImplDef{The result of a fixed point arithmetic operation in overflow
1944 situations, when the Machine_Overflows attribute of the result type is
1945 False.}
1946 @end(itemize)
1947 @end{ImplReq}
1948
1949 @begin{Inconsistent83}
1950 @Defn{inconsistencies with Ada 83}
1951 Since the values of a fixed point type are now just the integer multiples of
1952 its @i{small}, the possibility of using extra bits available in the chosen
1953 representation for extra accuracy rather than for increasing the base range
1954 would appear to be removed, raising the possibility that some fixed point
1955 expressions will yield less accurate results than in Ada 83. However, this is
1956 partially offset by the ability of an implementation to choose a smaller
1957 default @i{small} than before. Of course, if it does so for a type T then
1958 T'Small will have a different value than it previously had.
1959
1960 The accuracy requirements in the case of incompatible @i{smalls} are relaxed to
1961 foster wider support for non-binary @i{smalls}. If this relaxation is
1962 exploited for a type that was previously supported, lower accuracy could
1963 result; however, there is no particular incentive to exploit the relaxation in
1964 such a case.
1965 @end{Inconsistent83}
1966
1967 @begin{DiffWord83}
1968 @Leading@;The fixed point accuracy requirements are now expressed without reference to
1969 model or safe numbers, largely because the full generality of the former model
1970 was never exploited in the case of fixed point types (particularly in regard to
1971 operand perturbation). Although the new formulation in terms of perfect result
1972 sets and close result sets is still verbose, it can be seen to distill down to
1973 two cases:
1974 @begin{Itemize}
1975 a case where the result must be the exact result, if the exact result is
1976 representable, or, if not, then either one of the adjacent values of the
1977 type (in some subcases only one of those adjacent values is allowed);
1978
1979 a case where the accuracy is not specified by the language.
1980 @end{Itemize}
1981 @end{DiffWord83}
1982
1983
1984 @LabeledSubClause{Accuracy Requirements for the Elementary Functions}
1985
1986 @begin{Intro}
1987 In the strict mode, the performance of Numerics.Generic_Elementary_Functions
1988 shall be as specified here.
1989 @end{Intro}
1990
1991 @begin{ImplReq}
1992 @Defn2{Term=[result interval],
1993 Sec=[for the evaluation of an elementary function]}
1994 @Defn2{Term=[maximum relative error],
1995 Sec=[for the evaluation of an elementary function]}
1996 When an exception is not raised, the result of evaluating a function in an
1997 instance @i{EF} of Numerics.Generic_Elementary_Functions belongs to a @i{result
1998 interval}, defined as the smallest model interval of @i{EF}.Float_Type that
1999 contains all the values of the form @RI{f} @Times (1.0 + @RI{d}), where @RI{f} is the
2000 exact value of the corresponding mathematical function at the given parameter
2001 values, @RI{d} is a real number, and @Abs[@RI{d}] is less than or equal to
2002 the function's @i{maximum relative error}.
2003 @IndexCheck{Overflow_Check}
2004 The function delivers a value that belongs to the result interval when both of
2005 its bounds belong to the safe range of @i{EF}.Float_Type; otherwise,
2006 @begin{Itemize}
2007 @Defn2{Term=[Constraint_Error],Sec=(raised by failure of run-time check)}
2008 if @i{EF}.Float_Type'Machine_Overflows is True, the function either delivers
2009 a value that belongs to the result interval or raises Constraint_Error,
2010 signaling overflow;
2011
2012 @Trailing@;if @i{EF}.Float_Type'Machine_Overflows is False, the result is
2013 implementation defined.
2014 @ImplDef{The result of an elementary function reference in overflow
2015 situations, when the Machine_Overflows attribute of the result type is
2016 False.}
2017 @end{Itemize}
2018
2019 @Leading@;The maximum relative error exhibited by each function is as follows:
2020 @begin{Itemize}
2021 2.0 @Times @RI{EF}@R[.Float_Type'Model_Epsilon], in the case of the Sqrt, Sin,
2022 and Cos functions;
2023
2024 4.0 @Times @RI{EF}@R[.Float_Type'Model_Epsilon], in the case of the Log, Exp,
2025 Tan, Cot, and inverse trigonometric functions; and
2026
2027 8.0 @Times @RI{EF}@R[.Float_Type'Model_Epsilon], in the case of the forward and
2028 inverse hyperbolic functions.
2029 @end{Itemize}
2030
2031 The maximum relative error exhibited by the exponentiation operator, which
2032 depends on the values of the operands, is
2033 (4.0 + @Abs{@R[Right] @Times @Log(@R[Left])} / 32.0) @Times
2034 @RI{EF}@R[.Float_Type'Model_Epsilon].
2035
2036 The maximum relative error given above applies throughout the domain of
2037 the forward trigonometric functions when the Cycle parameter is specified.
2038 @Defn{angle threshold}
2039 When the Cycle parameter is omitted, the maximum relative error given above
2040 applies only when the absolute value of the angle parameter X is less than or
2041 equal to some implementation-defined @i{angle threshold}, which shall be at
2042 least
2043 @RI{EF}@R[.Float_@!Type'Machine_@!Radix] @+<@Floor(@RI{EF}@R[.Float_@!Type'Machine_@!Mantissa]/2)>.
2044 Beyond the angle threshold, the accuracy of the forward trigonometric functions
2045 is implementation defined.
2046 @ImplDef{The value of the @i{angle threshold}, within which certain elementary
2047 functions, complex arithmetic operations, and complex elementary functions
2048 yield results conforming to a maximum relative error bound.}
2049 @ImplDef{The accuracy of certain elementary functions for parameters beyond the
2050 angle threshold.}
2051 @begin{ImplNote}
2052 The angle threshold indirectly determines the amount of precision that the
2053 implementation has to maintain during argument reduction.
2054 @end{ImplNote}
2055
2056 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00434-01]}
2057 The prescribed results specified in @RefSecNum{Elementary Functions} for certain
2058 functions at particular parameter values take precedence over the maximum
2059 relative error bounds; effectively, they narrow to a single value the result
2060 interval allowed by the maximum relative error bounds. Additional rules with a
2061 similar effect are given by @Chg{Version=[2],New=[],Old=[the ]}table
2062 @Chg{Version=[2],New=[G-1],Old=[below]} for the inverse trigonometric
2063 functions, at particular parameter values for which the mathematical result is
2064 possibly not a model number of @i{EF}.Float_Type (or is, indeed, even
2065 transcendental). In each table entry, the values of the parameters are such
2066 that the result lies on the axis between two quadrants; the corresponding
2067 accuracy rule, which takes precedence over the maximum relative error bounds,
2068 is that the result interval is the model interval of @i{EF}.Float_Type
2069 associated with the exact mathematical result given in the table.
2070
2071 @ChgRef{Version=[1], Kind=[Deleted]}
2072 @Chg[New=<>,Old=<@ @;@comment{Empty paragraph to hang junk paragraph number (12) from original RM}>]
2073
2074 The last line of the table is meant to apply when
2075 @i{EF}.Float_Type'Signed_Zeros is False; the two lines just above it, when
2076 @i{EF}.Float_Type'Signed_Zeros is True and the parameter Y has a zero value
2077 with the indicated sign.
2078
2079 @Table[Columns=<5>,Alignment=<AllCenter>,FirstColWidth=[2],LastColWidth=[1],
2080 NoBreak=[T],Border=[T],SmallSize=[F],
2081 Caption=<@b{@Chg{Version=[2],New=[Table G-1: ],Old=[]}Tightly Approximated Elementary Function Results}>,
2082 Headers=<@b{Function}@\@b{Value of X}@\@b{Value of Y}@\@b{Exact Result @*when Cycle @*Specified}@\@b{Exact Result @*when Cycle @*Omitted}>,
2083 Body=<Arcsin@\1.0@\n.a.@\Cycle/4.0@\@Pi/2.0
2084 Arcsin@\@en@;1.0@\n.a.@\@en@R[Cycle]/4.0@\@en@Pi/2.0
2085 Arccos@\0.0@\n.a.@\Cycle/4.0@\@Pi/2.0
2086 Arccos@\@en@;1.0@\n.a.@\Cycle/2.0@\@Pi
2087 Arctan and Arccot@\0.0@\positive@\Cycle/4.0@\@Pi/2.0
2088 Arctan and Arccot@\0.0@\negative@\@en@R[Cycle]/4.0@\@en@Pi/2.0
2089 Arctan and Arccot@\negative@\+0.0@\Cycle/2.0@\@Pi
2090 Arctan and Arccot@\negative@\@en@;0.0@\@en@R[Cycle]/2.0@\@en@Pi@Last
2091 Arctan and Arccot@\negative@\0.0@\Cycle/2.0@\@Pi>]
2092 The amount by which the result of an inverse trigonometric function is allowed
2093 to spill over into a quadrant adjacent to the one corresponding to the
2094 principal branch, as given in @RefSecNum{Elementary Functions}, is limited.
2095 The rule is that the result belongs to the smallest model interval of
2096 @i{EF}.Float_Type that contains both boundaries of the quadrant corresponding
2097 to the principal branch. This rule also takes precedence over the maximum
2098 relative error bounds, effectively narrowing the result interval allowed by
2099 them.
2100
2101 @Comment{For Ada 95 with Corr, table G-1 appears here}
2102
2103 @Leading@;Finally, the following specifications also take precedence over the maximum
2104 relative error bounds:
2105 @begin{Itemize}
2106 The absolute value of the result of the Sin, Cos, and Tanh functions never
2107 exceeds one.
2108
2109 The absolute value of the result of the Coth function is never less than
2110 one.
2111
2112 The result of the Cosh function is never less than one.
2113 @end{Itemize}
2114 @end{ImplReq}
2115
2116 @begin{ImplAdvice}
2117 The versions of the forward trigonometric functions without a Cycle parameter
2118 should not be implemented by calling the corresponding version with a Cycle
2119 parameter of 2.0*Numerics.Pi, since this will not provide the required accuracy
2120 in some portions of the domain. For the same reason, the version of Log
2121 without a Base parameter should not be implemented by calling the corresponding
2122 version with a Base parameter of Numerics.e.
2123 @ChgImplAdvice{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
2124 Text=[For elementary functions, the forward trigonometric functions without a
2125 Cycle parameter should not be implemented by calling the corresponding version
2126 with a Cycle parameter. Log without a Base parameter should not be implemented
2127 by calling Log with a Base parameter.]}]}
2128 @end{ImplAdvice}
2129
2130 @begin{DiffWord83}
2131 @Leading@;The semantics of Numerics.Generic_Elementary_Functions differs from
2132 Generic_Elementary_Functions as defined in ISO/IEC DIS 11430 (for Ada 83) in
2133 the following ways related to the accuracy specified for strict mode:
2134 @begin{Itemize}
2135 The maximum relative error bounds use the Model_Epsilon attribute instead of
2136 the Base'Epsilon attribute.
2137
2138 The accuracy requirements are expressed in terms of result intervals that
2139 are model intervals. On the one hand, this facilitates the description of
2140 the required results in the presence of underflow; on the other hand, it
2141 slightly relaxes the requirements expressed in ISO/IEC DIS 11430.
2142 @end{Itemize}
2143 @end{DiffWord83}
2144
2145
2146 @LabeledSubClause{Performance Requirements for Random Number Generation}
2147
2148 @begin{Intro}
2149 In the strict mode, the performance of Numerics.Float_Random and
2150 Numerics.Discrete_Random shall be as specified here.
2151 @end{Intro}
2152
2153 @begin{ImplReq}
2154 Two different calls to the time-dependent Reset procedure shall reset the
2155 generator to different states, provided that the calls are separated in time by
2156 at least one second and not more than fifty
2157 years.
2158
2159 The implementation's representations of generator states and its algorithms for
2160 generating random numbers shall yield a period of at least 2@+{31}@en@;2;
2161 much longer periods are desirable but not required.
2162
2163 The implementations of Numerics.Float_Random.Random and
2164 Numerics.Discrete_Random.Random shall pass at least 85% of the individual
2165 trials in a suite of statistical tests. For Numerics.Float_Random, the tests
2166 are applied directly to the floating point values generated (i.e., they are not
2167 converted to integers first), while for Numerics.Discrete_Random they are
2168 applied to the generated values of various discrete types. Each test suite
2169 performs 6 different tests, with each test repeated 10 times, yielding a total
2170 of 60 individual trials. An individual trial is deemed to pass if the
2171 chi-square value (or other statistic) calculated for the observed counts or
2172 distribution falls within the range of values corresponding to the 2.5 and 97.5
2173 percentage points for the relevant degrees of freedom (i.e., it shall be
2174 neither too high nor too low). For the purpose of determining the degrees of
2175 freedom, measurement categories are combined whenever the expected counts are
2176 fewer than 5.
2177 @begin{ImplNote}
2178 In the floating point random number test suite, the generator is reset to a
2179 time-dependent state at the beginning of the run. The test suite
2180 incorporates the following tests, adapted from D. E. Knuth, @i{The Art of
2181 Computer Programming, vol. 2: Seminumerical Algorithms.} In the
2182 descriptions below, the given number of degrees of freedom is the number
2183 before reduction due to any necessary combination of measurement categories
2184 with small expected counts; it is one less than the number of measurement
2185 categories.
2186 @begin{itemize}
2187 Proportional Distribution Test (a variant of the Equidistribution Test).
2188 The interval 0.0 .. 1.0 is partitioned into @RI{K} subintervals.
2189 @RI{K} is chosen randomly between 4 and 25 for each repetition of the
2190 test, along with the boundaries of the subintervals (subject to the
2191 constraint that at least 2 of the subintervals have a width of 0.001 or
2192 more). 5000 random floating point numbers are generated. The counts of
2193 random numbers falling into each subinterval are tallied and compared
2194 with the expected counts, which are proportional to the widths of the
2195 subintervals. The number of degrees of freedom for the chi-square test
2196 is @RI{K}@en@;1.
2197
2198 Gap Test. The bounds of a range @RI{A} .. @RI{B}, with
2199 0.0 @leq @RI{A} @Lt @RI{B} @leq 1.0, are chosen randomly for each repetition
2200 of the test, subject to the constraint that 0.2 @leq @RI{B}@en@RI{A} @leq 0.6.
2201 Random floating point numbers are generated until 5000 falling into the
2202 range @RI{A} .. @RI{B} have been encountered. Each of these 5000 is
2203 preceded by a @lquotes@;gap@rquotes@; (of length greater than or equal to 0) of
2204 consecutive random numbers not falling into the range
2205 @RI{A} .. @RI{B}. The counts of gaps of each length from 0 to 15,
2206 and of all lengths greater than 15 lumped together, are tallied and
2207 compared with the expected counts. Let @RI{P} = @RI{B}@en@RI{A}. The
2208 probability that a gap has a length of @RI{L} is (1@en@RI{P}) @+[@RI{L}]
2209 @Times @RI{P} for @RI{L} @leq 15, while the probability that a gap has a
2210 length of 16 or more is (1@en@RI{P}) @+[16]. The number of degrees of
2211 freedom for the chi-square test is 16.
2212
2213 Permutation Test. 5000 tuples of 4 different random floating point
2214 numbers are generated. (An entire 4-tuple is discarded in the unlikely
2215 event that it contains any two exactly equal components.) The counts of
2216 each of the 4! = 24 possible relative orderings of the
2217 components of the 4-tuples are tallied and compared with the expected
2218 counts. Each of the possible relative orderings has an equal
2219 probability. The number of degrees of freedom for the chi-square test
2220 is 23.
2221
2222 Increasing-Runs Test. Random floating point numbers are generated until
2223 5000 increasing runs have been observed. An @lquotes@;increasing run@rquotes@; is a
2224 sequence of random numbers in strictly increasing order; it is followed
2225 by a random number that is strictly smaller than the preceding random
2226 number. (A run under construction is entirely discarded in the unlikely
2227 event that one random number is followed immediately by an exactly equal
2228 random number.) The decreasing random number that follows an increasing
2229 run is discarded and not included with the next increasing run. The
2230 counts of increasing runs of each length from 1 to 4, and of all lengths
2231 greater than 4 lumped together, are tallied and compared with the
2232 expected counts. The probability that an increasing run has a length of
2233 @RI{L} is 1/@RI{L}! @en 1/(@RI{L}+1)! for @RI{L} @leq 4, while
2234 the probability that an increasing run has a length of 5 or more is
2235 1/5!. The number of degrees of freedom for the chi-square test
2236 is 4.
2237
2238 Decreasing-Runs Test. The test is similar to the Increasing Runs Test,
2239 but with decreasing runs.
2240
2241 Maximum-of-@RI{t} Test (with @RI{t} = 5). 5000 tuples of
2242 5 random floating point numbers are generated. The maximum of the
2243 components of each 5-tuple is determined and raised to the 5th power.
2244 The uniformity of the resulting values over the range 0.0 .. 1.0 is
2245 tested as in the Proportional Distribution Test.
2246 @end{itemize}
2247 @end{ImplNote}
2248 @begin{ImplNote}
2249 In the discrete random number test suite, Numerics.Discrete_Random is
2250 instantiated as described below. The generator is reset to a time-dependent
2251 state after each instantiation. The test suite incorporates the following
2252 tests, adapted from D. E. Knuth (@i{op. cit.}) and other sources. The given
2253 number of degrees of freedom for the chi-square test is reduced by any
2254 necessary combination of measurement categories with small expected counts,
2255 as described above.
2256 @begin{Itemize}
2257 Equidistribution Test. In each repetition of the test, a number @RI{R}
2258 between 2 and 30 is chosen randomly, and Numerics.Discrete_Random is
2259 instantiated with an integer subtype whose range is 1 .. @RI{R}. 5000
2260 integers are generated randomly from this range. The counts of
2261 occurrences of each integer in the range are tallied and compared with
2262 the expected counts, which have equal probabilities. The number of
2263 degrees of freedom for the chi-square test is @RI{R}@en@;1.
2264
2265 Simplified Poker Test. Numerics.Discrete_Random is instantiated once
2266 with an enumeration subtype representing the 13 denominations (Two
2267 through Ten, Jack, Queen, King, and Ace) of an infinite deck of playing
2268 cards. 2000 @lquotes@;poker@rquotes@; hands (5-tuples of values of this subtype) are
2269 generated randomly. The counts of hands containing exactly @RI{K}
2270 different denominations (1 @leq @RI{K} @leq 5) are tallied and compared
2271 with the expected counts. The probability that a hand contains exactly
2272 @RI{K} different denominations is given by a formula in Knuth. The
2273 number of degrees of freedom for the chi-square test is 4.
2274
2275 Coupon Collector's Test. Numerics.Discrete_Random is instantiated in
2276 each repetition of the test with an integer subtype whose range is
2277 1 .. @RI{R}, where @RI{R} varies systematically from 2 to 11.
2278 Integers are generated randomly from this range until each value in the
2279 range has occurred, and the number @RI{K} of integers generated is
2280 recorded. This constitutes a @lquotes@;coupon collector's segment@rquotes@; of length
2281 @RI{K}. 2000 such segments are generated. The counts of segments of
2282 each length from @RI{R} to @RI{R}+29, and of all lengths greater than
2283 @RI{R}+29 lumped together, are tallied and compared with the expected
2284 counts. The probability that a segment has any given length is given by
2285 formulas in Knuth. The number of degrees of freedom for the chi-square
2286 test is 30.
2287
2288 Craps Test (Lengths of Games). Numerics.Discrete_Random is instantiated
2289 once with an integer subtype whose range is 1 .. 6 (representing the six
2290 numbers on a die). 5000 craps games are played, and their lengths are
2291 recorded. (The length of a craps game is the number of rolls of the pair
2292 of dice required to produce a win or a loss.
2293 A game is won on the first roll if
2294 the dice show 7 or 11; it is lost if they show 2, 3, or 12. If the dice
2295 show some other sum on the first roll, it is called the @i{point}, and
2296 the game is won if and only if the point is rolled again before a 7 is
2297 rolled.) The counts of games of each length from 1 to 18, and of all
2298 lengths greater than 18 lumped together, are tallied and compared with
2299 the expected counts. For 2 @leq @RI{S} @leq 12, let
2300 @RI{D} @-{@RI{S}} be the probability that a roll of a pair of dice shows
2301 the sum @RI{S}, and let
2302 @RI{Q} @-[@RI{S}](@RI{L}) = @RI{D} @-[@RI{S}] @Times
2303 (1 @en (@RI{D} @-[@RI{S}] + @RI{D} @-[7])) @+[@RI{L}@en@;2] @Times
2304 (@RI{D} @-[@RI{S}] + @RI{D} @-[7]). Then, the probability that a
2305 game has a length of 1 is @RI{D} @-[7] +
2306 @RI{D} @-[11] + @RI{D} @-[2] +
2307 @RI{D} @-[3] + @RI{D} @-[12]
2308 and, for @RI{L} @Gt 1, the probability that a game has a length of
2309 @RI{L} is @RI{Q} @-[4](@RI{L}) +
2310 @RI{Q} @-[5](@RI{L}) + @RI{Q} @-[6](@RI{L}) + @RI{Q} @-[8](@RI{L})
2311 + @RI{Q} @-[9](@RI{L}) + @RI{Q}
2312 @-[10](@RI{L}). The number of degrees of freedom for the chi-square test
2313 is 18.
2314
2315 Craps Test (Lengths of Passes). This test is similar to the last, but
2316 enough craps games are played for 3000 losses to occur. A string of wins
2317 followed by a loss is called a @i{pass}, and its length is the
2318 number of wins preceding the loss. The counts of passes of each length
2319 from 0 to 7, and of all lengths greater than 7 lumped together, are
2320 tallied and compared with the expected counts. For @RI{L} @geq 0, the
2321 probability that a pass has a length of @RI{L} is
2322 @RI{W} @+[@RI{L}] @Times (1@en@RI{W}), where @RI{W}, the probability that a game
2323 ends in a win, is 244.0/495.0. The number of degrees of freedom for the
2324 chi-square test is 8.
2325
2326 Collision Test. Numerics.Discrete_Random is instantiated once with an
2327 integer or enumeration type representing binary bits. 15 successive
2328 calls on the Random function are used to obtain the bits of a 15-bit
2329 binary integer between 0 and 32767. 3000 such integers are generated,
2330 and the number of collisions (integers previously generated) is counted
2331 and compared with the expected count. A chi-square test is not used to
2332 assess the number of collisions; rather, the limits on the number of
2333 collisions, corresponding to the 2.5 and 97.5 percentage points, are
2334 (from formulas in Knuth) 112 and 154. The test passes if and only if the
2335 number of collisions is in this range.
2336 @end{Itemize}
2337 @end{ImplNote}
2338 @end{ImplReq}
2339
2340 @LabeledSubClause{Accuracy Requirements for Complex Arithmetic}
2341
2342 @begin{Intro}
2343 In the strict mode, the performance of Numerics.Generic_@!Complex_Types and
2344 Numerics.Generic_@!Complex_@!Elementary_@!Functions shall be as specified here.
2345 @end{Intro}
2346
2347 @begin{ImplReq}
2348 When an exception is not raised, the result of evaluating a real function of
2349 an instance @i{CT} of Numerics.Generic_Complex_Types (i.e., a function that
2350 yields a value of subtype @i{CT}.Real'Base or @i{CT}.Imaginary) belongs to a
2351 result interval defined as for a real elementary function
2352 (see @RefSecNum{Accuracy Requirements for the Elementary Functions}).
2353
2354 @Defn2{Term=[result interval],
2355 Sec=[for a component of the result of evaluating a complex function]}
2356 When an exception is not raised, each component of the result of evaluating a
2357 complex function of such an instance, or of an instance of
2358 Numerics.Generic_Complex_Elementary_Functions obtained by instantiating the
2359 latter with @i{CT} (i.e., a function that yields a value of subtype
2360 @i{CT}.Complex), also belongs to a @i{result interval}. The result intervals
2361 for the components of the result are either defined by a
2362 @i{maximum relative error} bound or by a @i{maximum box error} bound.
2363 @Defn2{Term=[maximum relative error],
2364 Sec=[for a component of the result of evaluating a complex function]}
2365 When the result interval for the real (resp., imaginary) component is defined by
2366 maximum relative error, it is defined as for that of a real function, relative
2367 to the exact value of the real (resp., imaginary) part of the result of the
2368 corresponding mathematical function.
2369 @Defn2{Term=[maximum box error],
2370 Sec=[for a component of the result of evaluating a complex function]}
2371 When defined by maximum box error, the result interval for a component of the
2372 result is the smallest model interval of @i{CT}.Real that contains all the
2373 values of the corresponding part of @RI{f} @Times (1.0 + @RI{d}), where @RI{f} is the
2374 exact complex value of the corresponding mathematical function at the given
2375 parameter values, @RI{d} is complex, and @Abs{@RI{d}} is less than or equal
2376 to the given maximum box error.
2377 @IndexCheck{Overflow_Check}
2378 The function delivers a value that belongs to the result interval (or a value
2379 both of whose components belong to their respective result intervals) when both
2380 bounds of the result interval(s) belong to the safe range of @i{CT}.Real;
2381 otherwise,
2382 @begin{Discussion}
2383 The maximum relative error could be specified separately for each
2384 component, but we do not take advantage of that freedom here.
2385 @end{Discussion}
2386 @begin{Discussion}
2387 Note that
2388 @RI{f} @Times (1.0 + @RI{d}) defines a small circular region of the complex
2389 plane centered at @RI{f}, and the result intervals for
2390 the real and imaginary
2391 components of the result define a small rectangular box containing that
2392 circle.
2393 @end{Discussion}
2394 @begin{Reason}
2395 Box error is used when the computation of the result risks loss of
2396 significance in a component due to cancellation.
2397 @end{Reason}
2398 @begin{Ramification}
2399 The components of a complex function that exhibits bounded relative error in
2400 each component have to have the correct sign. In contrast, one of
2401 the components of a complex function that exhibits bounded box error may
2402 have the wrong sign, since the dimensions of the box containing the result
2403 are proportional to the modulus of the mathematical result and not to either
2404 component of the mathematical result individually. Thus, for example, the
2405 box containing the computed result of a complex function whose mathematical
2406 result has a large modulus but lies very close to the imaginary axis might
2407 well straddle that axis, allowing the real component of the computed result
2408 to have the wrong sign. In this case, the distance between the computed
2409 result and the mathematical result is, nevertheless, a small fraction of the
2410 modulus of the mathematical result.
2411 @end{Ramification}
2412 @begin{itemize}
2413 @Defn2{Term=[Constraint_Error],Sec=(raised by failure of run-time check)}
2414 if @i{CT}.Real'Machine_Overflows is True, the function either delivers a
2415 value that belongs to the result interval (or a value both of whose
2416 components belong to their respective result intervals) or raises
2417 Constraint_Error, signaling overflow;
2418
2419 if @i{CT}.Real'Machine_Overflows is False, the result is
2420 implementation defined.
2421 @ImplDef{The result of a complex arithmetic operation or complex
2422 elementary function reference in overflow situations, when the
2423 Machine_Overflows attribute of the corresponding real type is
2424 False.}
2425 @end{itemize}
2426
2427 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00434-01]}
2428 The error bounds for particular complex functions are tabulated @Chg{Version=[2],New=[in table G-2],Old=[below]}.
2429 In the table, the error bound is given as the coefficient of
2430 @i{CT}.Real'Model_Epsilon.
2431
2432 @ChgRef{Version=[1], Kind=[Deleted]}
2433 @Chg[New=<>,Old=<@ @;@comment{Empty paragraph to hang junk paragraph number (7) from original RM}>]
2434
2435 @Table[Columns=<4>,Alignment=<AllCenter>,FirstColWidth=[2],LastColWidth=[1],
2436 NoBreak=[T],Border=[T],SmallSize=[F],
2437 Caption=<@b{@Chg{Version=[2],New=[Table G-2: ],Old=[]}Error Bounds for Particular Complex Functions}>,
2438 Headers=<@b{Function or Operator}@\@b{Nature of @*Result}@\@b{Nature of @*Bound}@\@b{Error Bound}>,
2439 Body=<Modulus@\real@\max. rel. error@\3.0
2440 Argument@\real@\max. rel. error@\4.0
2441 Compose_From_Polar@\complex@\max. rel. error@\3.0
2442 "*" (both operands complex)@\complex@\max. box error@\5.0
2443 "/" (right operand complex)@\complex@\max. box error@\13.0
2444 Sqrt@\complex@\max. rel. error@\6.0
2445 Log@\complex@\max. box error@\13.0
2446 Exp (complex parameter)@\complex@\max. rel. error@\7.0
2447 Exp (imaginary parameter)@\complex@\max. rel. error@\2.0
2448 Sin, Cos, Sinh, and Cosh@\complex@\max. rel. error@\11.0
2449 Tan, Cot, Tanh, and Coth@\complex@\max. rel. error@\35.0
2450 inverse trigonometric@\complex@\max. rel. error@\14.0@Last
2451 inverse hyperbolic@\complex@\max. rel. error@\14.0>]
2452
2453 The maximum relative error given above applies throughout the domain of the
2454 Compose_From_Polar function when the Cycle parameter is specified. When the
2455 Cycle parameter is omitted, the maximum relative error applies only when the
2456 absolute value of the parameter Argument is less than or equal to the angle
2457 threshold (see @RefSecNum{Accuracy Requirements for the Elementary Functions}).
2458 For the Exp function, and for the forward hyperbolic (resp., trigonometric)
2459 functions, the maximum relative error given above likewise applies only when
2460 the absolute value of the imaginary (resp., real) component of the parameter X
2461 (or the absolute value of the parameter itself, in the case of the Exp function
2462 with a parameter of pure-imaginary type) is less than or equal to the angle
2463 threshold. For larger angles, the accuracy is
2464 implementation defined.
2465 @ImplDef{The accuracy of certain complex arithmetic operations and certain
2466 complex elementary functions for parameters (or components thereof) beyond
2467 the angle threshold.}
2468
2469 @Comment{For Ada 95 with Corr, table G-2 appears here}
2470
2471 @Leading@;The prescribed results specified in
2472 @RefSecNum{Complex Elementary Functions} for certain functions at particular
2473 parameter values take precedence over the error bounds;
2474 effectively, they narrow to a single value the result interval allowed by
2475 the error bounds for a component of the result. Additional rules with a similar
2476 effect are given below for certain inverse trigonometric and inverse hyperbolic
2477 functions, at particular parameter values for which a component of the
2478 mathematical result is transcendental. In each case, the accuracy rule,
2479 which takes precedence over the error bounds, is that the result interval
2480 for the stated result component is the model interval of @i{CT}.Real
2481 associated with the component's exact mathematical value. The cases in
2482 question are as follows:
2483 @begin{Itemize}
2484 When the parameter X has the value zero, the real (resp., imaginary)
2485 component of the result of the Arccot (resp., Arccoth) function is in the
2486 model interval of @i{CT}.Real associated with the value @Pi/2.0.
2487
2488 When the parameter X has the value one, the real component of the result of
2489 the Arcsin function is in the model interval of @i{CT}.Real associated with
2490 the value @Pi/2.0.
2491
2492 When the parameter X has the value @en@;1.0, the real component of the
2493 result of the Arcsin (resp., Arccos) function is in the model interval of
2494 @i{CT}.Real associated with the value @en@Pi/2.0 (resp.,
2495 @Pi).
2496 @end{Itemize}
2497 @begin{Discussion}
2498 It is possible to give many other prescribed results in which a component of
2499 the parameter is restricted to a similar model interval when the parameter X
2500 is appropriately restricted to an easily testable portion of the domain.
2501 We follow the proposed ISO/IEC standard for
2502 Generic_Complex_Elementary_Functions (for Ada 83) in not doing so, however.
2503 @end{Discussion}
2504
2505 @ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00434-01]}
2506 The amount by which a component of the result of an inverse trigonometric or
2507 inverse hyperbolic function is allowed to spill over into a quadrant adjacent
2508 to the one corresponding to the principal branch, as given in
2509 @RefSecNum{Complex Elementary Functions}, is limited. The rule is that the
2510 result belongs to the smallest model interval of @i{CT}.Real that contains both
2511 boundaries of the quadrant corresponding to the principal branch. This rule
2512 also takes precedence @Chg{Version=[2],New=[over],Old=[to]} the maximum error
2513 bounds, effectively narrowing the result interval allowed by them.
2514
2515 Finally, the results allowed by the error bounds are narrowed by one further
2516 rule: The absolute value of each component of the result of the Exp function,
2517 for a pure-imaginary parameter, never exceeds one.
2518 @end{ImplReq}
2519
2520 @begin{ImplAdvice}
2521 The version of the Compose_From_Polar function without a Cycle parameter should
2522 not be implemented by calling the corresponding version with a Cycle parameter
2523 of 2.0*Numerics.Pi, since this will not provide the required accuracy in some
2524 portions of the domain.
2525 @ChgImplAdvice{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2],
2526 Text=[For complex arithmetic, the Compose_From_Polar function without a Cycle
2527 parameter should not be implemented by calling Compose_From_Polar with a Cycle
2528 parameter.]}]}
2529 @end{ImplAdvice}
2530
2531 @begin{DiffWord83}
2532 The semantics of Numerics.Generic_Complex_Types and
2533 Numerics.Generic_Complex_Elementary_Functions differs from
2534 Generic_Complex_Types and Generic_Complex_Elementary_Functions as defined in
2535 ISO/IEC CDs
2536 13813 and 13814 (for Ada 83) in ways analogous to
2537 those identified for the elementary functions in
2538 @RefSecNum{Accuracy Requirements for the Elementary Functions}.
2539 In addition,
2540 we do not generally specify the signs of zero results (or result
2541 components), although those proposed standards do.
2542 @end{DiffWord83}
2543
2544
2545 @LabeledAddedClause{Version=[2],Name=[Vector and Matrix Manipulation]}
2546
2547 @begin{Intro}
2548 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
2549 @ChgAdded{Version=[2],Text=[Types and operations for the manipulation
2550 of real vectors and matrices are provided in Generic_Real_Arrays, which is
2551 defined in @RefSecNum[Real Vectors and Matrices]. Types and
2552 operations for the manipulation of complex vectors and matrices are provided
2553 in Generic_Complex_Arrays, which is defined in
2554 @RefSecNum[Complex Vectors and Matrices]. Both of these library units
2555 are generic children of the predefined package Numerics (see
2556 @RefSecNum[The Numerics Packages]). Nongeneric
2557 equivalents of these packages for each of the predefined floating point types
2558 are also provided as children of Numerics.]}
2559 @begin{Discussion}
2560 @ChgRef{Version=[2],Kind=[AddedNormal]}
2561 @ChgAdded{Version=[2],Text=[Vector and matrix manipulation is defined in
2562 the Numerics Annex, rather than in the core, because it is considered
2563 to be a specialized need of (some) numeric applications.]}
2564
2565 @ChgRef{Version=[2],Kind=[AddedNormal]}
2566 @ChgAdded{Version=[2],Text=[These packages provide facilities that are
2567 similar to and replace those found in ISO/IEC 13813:1998
2568 @i{Information technology @em Programming languages @em
2569 Generic packages of real and complex type declarations and basic
2570 operations for Ada (including vector and matrix types)}.
2571 (The other facilities provided by that Standard were already provided in Ada
2572 95.) In addition to the main facilities of that Standard, these packages also
2573 include subprograms for the solution of linear equations, matrix inversion,
2574 determinants, and the determination of the eigenvalues and eigenvectors of
2575 real symmetric matrices and Hermitian matrices.]}
2576 @end{Discussion}
2577 @end{Intro}
2578
2579 @begin{Extend95}
2580 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
2581 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
2582 This clause is new. It just provides an introduction to the following
2583 subclauses.]}
2584 @end{Extend95}
2585
2586
2587 @LabeledAddedSubClause{Version=[2],Name=[Real Vectors and Matrices]}
2588
2589 @begin{StaticSem}
2590 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01],ARef=[AI95-00418-01]}
2591 @ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The generic library
2592 package Numerics.Generic_Real_Arrays has the following declaration:]}
2593 @begin{Example}
2594 @ChgRef{Version=[2],Kind=[AddedNormal]}
2595 @ChgAdded{Version=[2],Text=[@key{generic}
2596 @key{type} Real @key{is digits} <>;
2597 @key{package} Ada.Numerics.Generic_Real_Arrays @key{is}@ChildUnit{Parent=[Ada.Numerics],Child=[Generic_Real_Arrays]}
2598 @key{pragma} Pure(Generic_Real_Arrays);]}
2599
2600 @ChgRef{Version=[2],Kind=[AddedNormal]}
2601 @ChgAdded{Version=[2],Text=[ -- @RI{Types}]}
2602
2603 @ChgRef{Version=[2],Kind=[AddedNormal]}
2604 @ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Real_Vector} @key{is array} (Integer @key{range} <>) @key{of} Real'Base;
2605 @key{type} @AdaTypeDefn{Real_Matrix} @key{is array} (Integer @key{range} <>, Integer @key{range} <>)
2606 @key{of} Real'Base;]}
2607
2608 @ChgRef{Version=[2],Kind=[AddedNormal]}
2609 @ChgAdded{Version=[2],Text=[ -- @RI{Subprograms for Real_Vector types}]}
2610
2611 @ChgRef{Version=[2],Kind=[AddedNormal]}
2612 @ChgAdded{Version=[2],Text=[ -- @RI{Real_Vector arithmetic operations}]}
2613
2614 @ChgRef{Version=[2],Kind=[AddedNormal]}
2615 @ChgAdded{Version=[2],Text=[ @key{function} "+" (Right : Real_Vector) @key{return} Real_Vector;
2616 @key{function} "-" (Right : Real_Vector) @key{return} Real_Vector;
2617 @key{function} "@key{abs}" (Right : Real_Vector) @key{return} Real_Vector;]}
2618
2619 @ChgRef{Version=[2],Kind=[AddedNormal]}
2620 @ChgAdded{Version=[2],Text=[ @key{function} "+" (Left, Right : Real_Vector) @key{return} Real_Vector;
2621 @key{function} "-" (Left, Right : Real_Vector) @key{return} Real_Vector;]}
2622
2623 @ChgRef{Version=[2],Kind=[AddedNormal]}
2624 @ChgAdded{Version=[2],Text=[ @key{function} "*" (Left, Right : Real_Vector) @key{return} Real'Base;]}
2625
2626 @ChgRef{Version=[2],Kind=[AddedNormal]}
2627 @ChgAdded{Version=[2],Text=[ @key{function} "@key{abs}" (Right : Real_Vector) @key{return} Real'Base;]}
2628
2629 @ChgRef{Version=[2],Kind=[AddedNormal]}
2630 @ChgAdded{Version=[2],Text=[ -- @RI[Real_Vector scaling operations]]}
2631
2632 @ChgRef{Version=[2],Kind=[AddedNormal]}
2633 @ChgAdded{Version=[2],Text=[ @key{function} "*" (Left : Real'Base; Right : Real_Vector)
2634 @key{return} Real_Vector;
2635 @key{function} "*" (Left : Real_Vector; Right : Real'Base)
2636 @key{return} Real_Vector;
2637 @key{function} "/" (Left : Real_Vector; Right : Real'Base)
2638 @key{return} Real_Vector;]}
2639
2640 @ChgRef{Version=[2],Kind=[AddedNormal]}
2641 @ChgAdded{Version=[2],Text=[ -- @RI[Other Real_Vector operations]]}
2642
2643 @ChgRef{Version=[2],Kind=[AddedNormal]}
2644 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Unit_Vector} (Index : Integer;
2645 Order : Positive;
2646 First : Integer := 1) @key{return} Real_Vector;]}
2647
2648 @ChgRef{Version=[2],Kind=[AddedNormal]}
2649 @ChgAdded{Version=[2],Text=[ -- @RI[Subprograms for Real_Matrix types]]}
2650
2651 @ChgRef{Version=[2],Kind=[AddedNormal]}
2652 @ChgAdded{Version=[2],Text=[ -- @RI[Real_Matrix arithmetic operations]]}
2653
2654 @ChgRef{Version=[2],Kind=[AddedNormal]}
2655 @ChgAdded{Version=[2],Text=[ @key{function} "+" (Right : Real_Matrix) @key{return} Real_Matrix;
2656 @key{function} "-" (Right : Real_Matrix) @key{return} Real_Matrix;
2657 @key{function} "@key{abs}" (Right : Real_Matrix) @key{return} Real_Matrix;
2658 @key{function} @AdaSubDefn{Transpose} (X : Real_Matrix) @key{return} Real_Matrix;]}
2659
2660 @ChgRef{Version=[2],Kind=[AddedNormal]}
2661 @ChgAdded{Version=[2],Text=[ @key{function} "+" (Left, Right : Real_Matrix) @key{return} Real_Matrix;
2662 @key{function} "-" (Left, Right : Real_Matrix) @key{return} Real_Matrix;
2663 @key{function} "*" (Left, Right : Real_Matrix) @key{return} Real_Matrix;]}
2664
2665 @ChgRef{Version=[2],Kind=[AddedNormal]}
2666 @ChgAdded{Version=[2],Text=[ @key{function} "*" (Left, Right : Real_Vector) @key{return} Real_Matrix;]}
2667
2668 @ChgRef{Version=[2],Kind=[AddedNormal]}
2669 @ChgAdded{Version=[2],Text=[ @key{function} "*" (Left : Real_Vector; Right : Real_Matrix)
2670 @key{return} Real_Vector;
2671 @key{function} "*" (Left : Real_Matrix; Right : Real_Vector)
2672 @key{return} Real_Vector;]}
2673
2674 @ChgRef{Version=[2],Kind=[AddedNormal]}
2675 @ChgAdded{Version=[2],Text=[ -- @RI[Real_Matrix scaling operations]]}
2676
2677 @ChgRef{Version=[2],Kind=[AddedNormal]}
2678 @ChgAdded{Version=[2],Text=[ @key{function} "*" (Left : Real'Base; Right : Real_Matrix)
2679 @key{return} Real_Matrix;
2680 @key{function} "*" (Left : Real_Matrix; Right : Real'Base)
2681 @key{return} Real_Matrix;
2682 @key{function} "/" (Left : Real_Matrix; Right : Real'Base)
2683 @key{return} Real_Matrix;]}
2684
2685 @ChgRef{Version=[2],Kind=[AddedNormal]}
2686 @ChgAdded{Version=[2],Text=[ -- @RI[Real_Matrix inversion and related operations]]}
2687
2688 @ChgRef{Version=[2],Kind=[AddedNormal]}
2689 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Solve} (A : Real_Matrix; X : Real_Vector) @key{return} Real_Vector;
2690 @key{function} @AdaSubDefn{Solve} (A, X : Real_Matrix) @key{return} Real_Matrix;
2691 @key{function} @AdaSubDefn{Inverse} (A : Real_Matrix) @key{return} Real_Matrix;
2692 @key{function} @AdaSubDefn{Determinant} (A : Real_Matrix) @key{return} Real'Base;]}
2693
2694 @ChgRef{Version=[2],Kind=[AddedNormal]}
2695 @ChgAdded{Version=[2],Text=[ -- @RI[Eigenvalues and vectors of a real symmetric matrix]]}
2696
2697 @ChgRef{Version=[2],Kind=[AddedNormal]}
2698 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Eigenvalues} (A : Real_Matrix) @key{return} Real_Vector;]}
2699
2700 @ChgRef{Version=[2],Kind=[AddedNormal]}
2701 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Eigensystem} (A : @key{in} Real_Matrix;
2702 Values : @key{out} Real_Vector;
2703 Vectors : @key{out} Real_Matrix);]}
2704
2705 @ChgRef{Version=[2],Kind=[AddedNormal]}
2706 @ChgAdded{Version=[2],Text=[ -- @RI[Other Real_Matrix operations]]}
2707
2708 @ChgRef{Version=[2],Kind=[AddedNormal]}
2709 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Unit_Matrix} (Order : Positive;
2710 First_1, First_2 : Integer := 1)
2711 @key{return} Real_Matrix;]}
2712
2713 @ChgRef{Version=[2],Kind=[AddedNormal]}
2714 @ChgAdded{Version=[2],Text=[@key{end} Ada.Numerics.Generic_Real_Arrays;]}
2715
2716 @end{Example}
2717
2718 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
2719 @ChgAdded{Version=[2],Text=[@ChildUnit{Parent=[Ada.Numerics],Child=[Real_@!Arrays]}
2720 The library package Numerics.Real_Arrays is declared pure and defines the
2721 same types and subprograms as Numerics.Generic_Real_Arrays, except that
2722 the predefined type Float is systematically substituted for Real'Base
2723 throughout. Nongeneric equivalents for each of the other predefined floating
2724 point types are defined similarly, with the names Numerics.Short_Real_Arrays,
2725 Numerics.Long_Real_Arrays, etc.]}
2726 @begin{Reason}
2727 @ChgRef{Version=[2],Kind=[AddedNormal]}
2728 @ChgAdded{Version=[2],Text=[
2729 The nongeneric equivalents are provided to allow the programmer to
2730 construct simple mathematical applications without being required to
2731 understand and use generics, and to be consistent with other
2732 Numerics packages.]}
2733 @end{Reason}
2734
2735 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
2736 @ChgAdded{Version=[2],Text=[Two types are defined and exported by
2737 Numerics.Generic_Real_Arrays. The composite type Real_Vector is provided to
2738 represent a vector with components of type Real; it is defined as an
2739 unconstrained, one-dimensional array with an index of type Integer. The
2740 composite type Real_Matrix is provided to represent a matrix with components of
2741 type Real; it is defined as an unconstrained, two-dimensional array with
2742 indices of type Integer.]}
2743
2744 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
2745 @ChgAdded{Version=[2],Text=[The effect of the various subprograms is as described
2746 below. In most cases the subprograms are described in terms of corresponding
2747 scalar operations of the type Real; any exception raised by those operations is
2748 propagated by the array operation. Moreover, the accuracy of the result for
2749 each individual component is as defined for the scalar operation unless stated
2750 otherwise.]}
2751
2752 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
2753 @ChgAdded{Version=[2],Text=[In the case of those operations which are defined
2754 to @i{involve an inner product}, Constraint_Error may be raised if an intermediate
2755 result is outside the range of Real'Base even though the mathematical final
2756 result would not be.@Defn2{Term=[involve an inner product],Sec=[real]}]}
2757
2758 @begin{DescribeCode}
2759
2760 @begin{Example}
2761 @ChgRef{Version=[2],Kind=[AddedNormal]}
2762 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "+" (Right : Real_Vector) @key{return} Real_Vector;
2763 @key{function} "-" (Right : Real_Vector) @key{return} Real_Vector;
2764 @key{function} "@key{abs}" (Right : Real_Vector) @key{return} Real_Vector;]}
2765 @end{Example}
2766
2767 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
2768 @ChgAdded{Version=[2],Type=[Trailing],Text=[Each operation returns the result
2769 of applying the corresponding operation of the type Real to each component of
2770 Right. The index range of the result is Right'Range.]}
2771
2772 @begin{Example}
2773 @ChgRef{Version=[2],Kind=[AddedNormal]}
2774 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "+" (Left, Right : Real_Vector) @key{return} Real_Vector;
2775 @key{function} "-" (Left, Right : Real_Vector) @key{return} Real_Vector;]}
2776 @end{Example}
2777
2778 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
2779 @ChgAdded{Version=[2],Text=[Each operation returns the result of applying the
2780 corresponding operation of the type Real to each component of Left and the
2781 matching component of Right. The index range of the result is Left'Range.
2782 Constraint_Error is raised if Left'Length is not equal to Right'Length.]}
2783
2784 @begin{Example}
2785 @ChgRef{Version=[2],Kind=[AddedNormal]}
2786 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left, Right : Real_Vector) @key{return} Real'Base;]}
2787 @end{Example}
2788
2789 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
2790 @ChgAdded{Version=[2],Text=[This operation returns the inner product of Left
2791 and Right. Constraint_Error is raised if Left'Length is not equal to
2792 Right'Length. This operation involves an inner product.]}
2793
2794 @begin{Example}
2795 @ChgRef{Version=[2],Kind=[AddedNormal]}
2796 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "@key{abs}" (Right : Real_Vector) @key{return} Real'Base;]}
2797 @end{Example}
2798
2799 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00418-01]}
2800 @ChgAdded{Version=[2],Text=[This operation returns the L2-norm of Right (the
2801 square root of the inner product of the vector with itself).]}
2802
2803 @begin{Discussion}
2804 @ChgRef{Version=[2],Kind=[AddedNormal]}
2805 @ChgAdded{Version=[2],Text=[Normalization of vectors is a frequent enough
2806 operation that it is useful to provide the norm as a basic operation.
2807 Furthermore, implementing the norm is not entirely straightforward, because
2808 the inner product might overflow while the final norm does not. An
2809 implementation cannot merely return Sqrt (X * X), it has to cope with a
2810 possible overflow of the inner product.]}
2811 @end{Discussion}
2812
2813 @begin{ImplNote}
2814 @ChgRef{Version=[2],Kind=[AddedNormal]}
2815 @ChgAdded{Version=[2],Text=[While the definition is given in terms of
2816 an inner product, the norm doesn't @lquotes@;involve an inner product@rquotes@;
2817 in the technical sense. The reason is that it has accuracy requirements
2818 substantially different from those applicable to inner products; and that
2819 cancellations cannot occur, because all the terms are positive, so there
2820 is no possibility of intermediate overflow.]}
2821 @end{ImplNote}
2822
2823 @begin{Example}
2824 @ChgRef{Version=[2],Kind=[AddedNormal]}
2825 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left : Real'Base; Right : Real_Vector) @key{return} Real_Vector;]}
2826 @end{Example}
2827
2828 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
2829 @ChgAdded{Version=[2],Text=[This operation returns the result of multiplying
2830 each component of Right by the scalar Left using the "*" operation of the type
2831 Real. The index range of the result is Right'Range.]}
2832
2833 @begin{Example}
2834 @ChgRef{Version=[2],Kind=[AddedNormal]}
2835 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left : Real_Vector; Right : Real'Base) @key{return} Real_Vector;
2836 @key{function} "/" (Left : Real_Vector; Right : Real'Base) @key{return} Real_Vector;]}
2837 @end{Example}
2838
2839 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
2840 @ChgAdded{Version=[2],Text=[Each operation returns the result of applying the
2841 corresponding operation of the type Real to each component of Left and to the
2842 scalar Right. The index range of the result is Left'Range.]}
2843
2844 @begin{Example}
2845 @ChgRef{Version=[2],Kind=[AddedNormal]}
2846 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Unit_Vector (Index : Integer;
2847 Order : Positive;
2848 First : Integer := 1) @key{return} Real_Vector;]}
2849 @end{Example}
2850
2851 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
2852 @ChgAdded{Version=[2],Text=[This function returns a @i<unit vector>@Defn2{Term=[unit vector],Sec=[real vector]}
2853 with Order components and a lower bound of First. All components are set to 0.0
2854 except for the Index component which is set to 1.0. Constraint_Error is raised
2855 if Index < First, Index > First + Order @en 1 or if First + Order @en 1 >
2856 Integer'Last.]}
2857
2858 @begin{Example}
2859 @ChgRef{Version=[2],Kind=[AddedNormal]}
2860 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "+" (Right : Real_Matrix) @key{return} Real_Matrix;
2861 @key{function} "-" (Right : Real_Matrix) @key{return} Real_Matrix;
2862 @key{function} "@key{abs}" (Right : Real_Matrix) @key{return} Real_Matrix;]}
2863 @end{Example}
2864
2865 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
2866 @ChgAdded{Version=[2],Text=[Each operation returns the result of applying the
2867 corresponding operation of the type Real to each component of Right. The index
2868 ranges of the result are those of Right.]}
2869
2870 @begin{Example}
2871 @ChgRef{Version=[2],Kind=[AddedNormal]}
2872 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Transpose (X : Real_Matrix) @key{return} Real_Matrix;]}
2873 @end{Example}
2874
2875 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
2876 @ChgAdded{Version=[2],Text=[This function returns the transpose of a matrix X.
2877 The first and second index ranges of the result are X'Range(2) and X'Range(1)
2878 respectively.]}
2879
2880 @begin{Example}
2881 @ChgRef{Version=[2],Kind=[AddedNormal]}
2882 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "+" (Left, Right : Real_Matrix) @key{return} Real_Matrix;
2883 @key{function} "-" (Left, Right : Real_Matrix) @key{return} Real_Matrix;]}
2884 @end{Example}
2885
2886 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
2887 @ChgAdded{Version=[2],Text=[Each operation returns the result of applying the
2888 corresponding operation of the type Real to each component of Left and the
2889 matching component of Right. The index ranges of the result are those of Left.
2890 Constraint_Error is raised if Left'Length(1) is not equal to Right'Length(1) or
2891 Left'Length(2) is not equal to Right'Length(2).]}
2892
2893 @begin{Example}
2894 @ChgRef{Version=[2],Kind=[AddedNormal]}
2895 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left, Right : Real_Matrix) @key{return} Real_Matrix;]}
2896 @end{Example}
2897
2898 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
2899 @ChgAdded{Version=[2],Text=[This operation provides the standard mathematical
2900 operation for matrix multiplication. The first and second index ranges of the
2901 result are Left'Range(1) and Right'Range(2) respectively. Constraint_Error is
2902 raised if Left'Length(2) is not equal to Right'Length(1). This operation
2903 involves inner products.]}
2904
2905 @begin{Example}
2906 @ChgRef{Version=[2],Kind=[AddedNormal]}
2907 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left, Right : Real_Vector) @key{return} Real_Matrix;]}
2908 @end{Example}
2909
2910 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
2911 @ChgAdded{Version=[2],Text=[This operation returns the outer product of a
2912 (column) vector Left by a (row) vector Right using the operation "*" of the
2913 type Real for computing the individual components. The first and second index
2914 ranges of the result are Left'Range and Right'Range respectively.]}
2915
2916 @begin{Example}
2917 @ChgRef{Version=[2],Kind=[AddedNormal]}
2918 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left : Real_Vector; Right : Real_Matrix) @key{return} Real_Vector;]}
2919 @end{Example}
2920
2921 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
2922 @ChgAdded{Version=[2],Text=[This operation provides the standard mathematical
2923 operation for multiplication of a (row) vector Left by a matrix Right. The
2924 index range of the (row) vector result is Right'Range(2). Constraint_Error is
2925 raised if Left'Length is not equal to Right'Length(1). This operation involves
2926 inner products.]}
2927
2928 @begin{Example}
2929 @ChgRef{Version=[2],Kind=[AddedNormal]}
2930 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left : Real_Matrix; Right : Real_Vector) @key{return} Real_Vector;]}
2931 @end{Example}
2932
2933 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
2934 @ChgAdded{Version=[2],Text=[This operation provides the standard mathematical
2935 operation for multiplication of a matrix Left by a (column) vector Right. The
2936 index range of the (column) vector result is Left'Range(1). Constraint_Error is
2937 raised if Left'Length(2) is not equal to Right'Length. This operation involves
2938 inner products.]}
2939
2940 @begin{Example}
2941 @ChgRef{Version=[2],Kind=[AddedNormal]}
2942 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left : Real'Base; Right : Real_Matrix) @key{return} Real_Matrix;]}
2943 @end{Example}
2944
2945 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
2946 @ChgAdded{Version=[2],Text=[This operation returns the result of multiplying
2947 each component of Right by the scalar Left using the "*" operation of the type
2948 Real. The index ranges of the result are those of Right.]}
2949
2950 @begin{Example}
2951 @ChgRef{Version=[2],Kind=[AddedNormal]}
2952 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left : Real_Matrix; Right : Real'Base) @key{return} Real_Matrix;
2953 @key{function} "/" (Left : Real_Matrix; Right : Real'Base) @key{return} Real_Matrix;]}
2954 @end{Example}
2955
2956 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
2957 @ChgAdded{Version=[2],Text=[Each operation returns the result of applying the
2958 corresponding operation of the type Real to each component of Left and to the
2959 scalar Right. The index ranges of the result are those of Left.]}
2960
2961 @begin{Example}
2962 @ChgRef{Version=[2],Kind=[AddedNormal]}
2963 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Solve (A : Real_Matrix; X : Real_Vector) @key{return} Real_Vector;]}
2964 @end{Example}
2965
2966 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
2967 @ChgAdded{Version=[2],Text=[This function returns a vector Y such that X is
2968 (nearly) equal to A * Y. This is the standard mathematical operation for
2969 solving a single set of linear equations. The index range of the result is
2970 A'Range(2). Constraint_Error is raised if A'Length(1), A'Length(2), and X'Length
2971 are not equal. Constraint_Error is raised if the matrix A is ill-conditioned.]}
2972
2973 @begin{Discussion}
2974 @ChgRef{Version=[2],Kind=[AddedNormal]}
2975 @ChgAdded{Version=[2],Text=[The text says that Y is such that @lquotes@;X is
2976 (nearly) equal to A * Y@rquotes rather than @lquotes@;X is equal to A *
2977 Y@rquotes because rounding errors may mean that there is no value of Y such
2978 that X is exactly equal to A * Y. On the other hand it does not mean that any
2979 old rough value will do. The algorithm given under @ImplAdviceTitle
2980 should be followed.]}
2981
2982 @ChgRef{Version=[2],Kind=[AddedNormal]}
2983 @ChgAdded{Version=[2],Text=[The requirement to raise Constraint_Error if the
2984 matrix is ill-conditioned is really a reflection of what will happen if the
2985 matrix is ill-conditioned. See @ImplAdviceTitle.
2986 We do not make any attempt to define ill-conditioned formally.]}
2987
2988 @ChgRef{Version=[2],Kind=[AddedNormal]}
2989 @ChgAdded{Version=[2],Text=[These remarks apply to all versions of Solve and
2990 Inverse.]}
2991 @end{Discussion}
2992
2993 @begin{Example}
2994 @ChgRef{Version=[2],Kind=[AddedNormal]}
2995 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Solve (A, X : Real_Matrix) @key{return} Real_Matrix;]}
2996 @end{Example}
2997
2998 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
2999 @ChgAdded{Version=[2],Text=[This function returns a matrix Y such that X is
3000 (nearly) equal to A * Y. This is the standard mathematical operation for
3001 solving several sets of linear equations. The index ranges of the result are
3002 A'Range(2) and X'Range(2). Constraint_Error is raised if A'Length(1), A'Length(2), and
3003 X'Length(1) are not equal. Constraint_Error is raised if the matrix A is
3004 ill-conditioned.]}
3005
3006 @begin{Example}
3007 @ChgRef{Version=[2],Kind=[AddedNormal]}
3008 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Inverse (A : Real_Matrix) @key{return} Real_Matrix;]}
3009 @end{Example}
3010
3011 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3012 @ChgAdded{Version=[2],Text=[This function returns a matrix B such that A * B is
3013 (nearly) equal to the unit matrix. The index ranges of the result are A'Range(2)
3014 and A'Range(1). Constraint_Error is raised if A'Length(1) is not equal to
3015 A'Length(2). Constraint_Error is raised if the matrix A is ill-conditioned.]}
3016
3017 @begin{Example}
3018 @ChgRef{Version=[2],Kind=[AddedNormal]}
3019 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Determinant (A : Real_Matrix) @key{return} Real'Base;]}
3020 @end{Example}
3021
3022 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3023 @ChgAdded{Version=[2],Text=[This function returns the determinant of the matrix
3024 A. Constraint_Error is raised if A'Length(1) is not equal to A'Length(2).]}
3025
3026 @begin{Example}
3027 @ChgRef{Version=[2],Kind=[AddedNormal]}
3028 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Eigenvalues(A : Real_Matrix) @key{return} Real_Vector;]}
3029 @end{Example}
3030
3031 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3032 @ChgAdded{Version=[2],Text=[This function returns the eigenvalues of the
3033 symmetric matrix A as a vector sorted into order with the largest first.
3034 Constraint_Error is raised if A'Length(1) is not equal to A'Length(2). The
3035 index range of the result is A'Range(1). Argument_Error is raised if the matrix
3036 A is not symmetric.]}
3037
3038 @begin{Example}
3039 @ChgRef{Version=[2],Kind=[AddedNormal]}
3040 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Eigensystem(A : @key{in} Real_Matrix;
3041 Values : @key{out} Real_Vector;
3042 Vectors : @key{out} Real_Matrix);]}
3043 @end{Example}
3044
3045 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3046 @ChgAdded{Version=[2],Text=[This procedure computes both the eigenvalues and
3047 eigenvectors of the symmetric matrix A. The out parameter Values is the same as
3048 that obtained by calling the function Eigenvalues. The out parameter Vectors is
3049 a matrix whose columns are the eigenvectors of the matrix A. The order of the
3050 columns corresponds to the order of the eigenvalues. The eigenvectors are
3051 normalized and mutually orthogonal (they are orthonormal), including when there
3052 are repeated eigenvalues. Constraint_Error is raised if A'Length(1) is not
3053 equal to A'Length(2). The index ranges of the parameter Vectors are those of A.
3054 Argument_Error is raised if the matrix A is not symmetric.]}
3055
3056 @begin{Example}
3057 @ChgRef{Version=[2],Kind=[AddedNormal]}
3058 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Unit_Matrix (Order : Positive;
3059 First_1, First_2 : Integer := 1) @key{return} Real_Matrix;]}
3060 @end{Example}
3061
3062 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3063 @ChgAdded{Version=[2],Text=[This function returns a square
3064 @i{unit matrix}@Defn2{Term=[unit matrix],Sec=[real matrix]}
3065 with Order**2 components and lower bounds of
3066 First_1 and First_2 (for the first and second index ranges respectively). All
3067 components are set to 0.0 except for the main diagonal, whose components are
3068 set to 1.0. Constraint_Error is raised if First_1 + Order @en 1 > Integer'Last or
3069 First_2 + Order @en 1 > Integer'Last.]}
3070
3071 @end{DescribeCode}
3072
3073 @end{StaticSem}
3074
3075 @begin{ImplReq}
3076
3077 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3078 @ChgAdded{Version=[2],Text=[Accuracy requirements for the subprograms Solve,
3079 Inverse, Determinant, Eigenvalues and Eigensystem are implementation defined.]}
3080 @ChgImplDef{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],Text=[The
3081 accuracy requirements for the subprograms Solve,
3082 Inverse, Determinant, Eigenvalues and Eigensystem for type Real_Matrix.]}]}
3083
3084 @ChgRef{Version=[2],Kind=[AddedNormal]}
3085 @ChgAdded{Version=[2],Text=[For operations not involving an inner product, the
3086 accuracy requirements are those of the corresponding operations of the type
3087 Real in both the strict mode and the relaxed mode
3088 (see @RefSecNum{Numeric Performance Requirements}).]}
3089
3090 @ChgRef{Version=[2],Kind=[AddedNormal]}
3091 @ChgAdded{Version=[2],Type=[Leading],Text=[For operations involving an inner
3092 product, no
3093 requirements are specified in the relaxed mode. In the strict mode the modulus
3094 of the absolute error of the inner product @i<X>*@i<Y> shall not exceed
3095 @i<g>*@b<abs>(@i<X>)*@b<abs>(@i<Y>) where @i<g> is defined as]}
3096 @begin{Display}
3097 @ChgRef{Version=[2],Kind=[AddedNormal]}
3098 @ChgAdded{Version=[2],Text=[@i<g> = @i<X>'Length * Real'Machine_Radix**(1 @en@; Real'Model_Mantissa)]}
3099 @end{Display}
3100
3101 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00418-01]}
3102 @ChgAdded{Version=[2],Text=[For the L2-norm, no accuracy
3103 requirements are specified in the relaxed mode. In the strict mode the relative
3104 error on the norm shall not exceed @i<g> / 2.0 + 3.0 * Real'Model_Epsilon where
3105 @i<g> is defined as above.]}
3106
3107 @begin{Reason}
3108 @ChgRef{Version=[2],Kind=[AddedNormal]}
3109 @ChgAdded{Version=[2],Text=[This is simply the combination of the error on
3110 the inner product with the error on Sqrt. A first order computation would
3111 lead to 2.0 * Real'Model_Epsilon above, but we are adding an extra
3112 Real'Model_Epsilon to account for higher order effects.]}
3113 @end{Reason}
3114 @end{ImplReq}
3115
3116 @begin{DocReq}
3117
3118 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3119 @ChgAdded{Version=[2],Text=[Implementations shall document any techniques used
3120 to reduce cancellation errors such as extended precision arithmetic.]}
3121 @ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],Text=[Any
3122 techniques used to reduce cancellation errors in
3123 Numerics.Generic_Real_Arrays shall be documented.]}]}
3124 @begin{ImplNote}
3125 @ChgRef{Version=[2],Kind=[AddedNormal]}
3126 @ChgAdded{Version=[2],Text=[The above accuracy requirement is met by the
3127 canonical implementation of the inner product by multiplication and addition
3128 using the corresponding operations of type Real'Base and performing the
3129 cumulative addition using ascending indices. Note however, that some hardware
3130 provides special operations for the computation of the inner product and
3131 although these may be fast they may not meet the accuracy requirement
3132 specified. See Accuracy and Stability of Numerical Algorithms By N J Higham
3133 (ISBN 0-89871-355-2), Section 3.1.]}
3134 @end{ImplNote}
3135 @end{DocReq}
3136
3137 @begin{ImplPerm}
3138
3139 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3140 @ChgAdded{Version=[2],Text=[The nongeneric equivalent packages may, but need
3141 not, be actual instantiations of the generic package for the appropriate
3142 predefined type.]}
3143
3144 @end{ImplPerm}
3145
3146 @begin{ImplAdvice}
3147
3148 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3149 @ChgAdded{Version=[2],Text=[Implementations should implement the Solve and
3150 Inverse functions using established techniques such as LU decomposition with
3151 row interchanges followed by back and forward substitution. Implementations are
3152 recommended to refine the result by performing an iteration on the residuals;
3153 if this is done then it should be documented.]}
3154 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
3155 Text=[Solve and Inverse for Numerics.Generic_Real_Arrays should be
3156 implemented using established techniques such as LU decomposition and
3157 the result should be refined by an iteration on the residuals.]}]}
3158
3159 @ChgRef{Version=[2],Kind=[AddedNormal]}
3160 @ChgAdded{Version=[2],Text=[It is not the intention that any special provision
3161 should be made to determine whether a matrix is ill-conditioned or not. The
3162 naturally occurring overflow (including division by zero) which will result
3163 from executing these functions with an ill-conditioned matrix and thus raise
3164 Constraint_Error is sufficient.]}
3165 @begin{Discussion}
3166 @ChgRef{Version=[2],Kind=[AddedNormal]}
3167 @ChgAdded{Version=[2],Text=[There isn't any advice for the implementation to
3168 document with this paragraph.]}
3169 @end{Discussion}
3170
3171 @ChgRef{Version=[2],Kind=[AddedNormal]}
3172 @ChgAdded{Version=[2],Text=[The test that a matrix is symmetric should be
3173 performed by using the equality operator to compare the relevant components.]}
3174 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
3175 Text=[The equality operator should be used to test that a matrix in
3176 Numerics.Generic_Real_Matrix is symmetric.]}]}
3177
3178 @end{ImplAdvice}
3179
3180 @begin{Extend95}
3181 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3182 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
3183 The package Numerics.Generic_Real_Arrays and its nongeneric equivalents
3184 are new.]}
3185 @end{Extend95}
3186
3187
3188 @LabeledAddedSubClause{Version=[2],Name=[Complex Vectors and Matrices]}
3189
3190
3191 @begin{StaticSem}
3192 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3193 @ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The generic library
3194 package Numerics.Generic_Complex_Arrays has the following declaration:]}
3195 @begin{Example}
3196 @ChgRef{Version=[2],Kind=[AddedNormal]}
3197 @ChgAdded{Version=[2],Text=[@key{with} Ada.Numerics.Generic_Real_Arrays, Ada.Numerics.Generic_Complex_Types;
3198 @key{generic}
3199 @key{with package} Real_Arrays @key{is new}
3200 Ada.Numerics.Generic_Real_Arrays (<>);
3201 @key{use} Real_Arrays;
3202 @key{with package} Complex_Types @key{is new}
3203 Ada.Numerics.Generic_Complex_Types (Real);
3204 @key{use} Complex_Types;
3205 @key{package} Ada.Numerics.Generic_Complex_Arrays @key{is}@ChildUnit{Parent=[Ada.Numerics],Child=[Generic_@!Complex_@!Arrays]}
3206 @key{pragma} Pure(Generic_Complex_Arrays);]}
3207
3208 @ChgRef{Version=[2],Kind=[AddedNormal]}
3209 @ChgAdded{Version=[2],Text=[ -- @RI{Types}]}
3210
3211 @ChgRef{Version=[2],Kind=[AddedNormal]}
3212 @ChgAdded{Version=[2],Text=[ @key{type} @AdaTypeDefn{Complex_Vector} @key{is array} (Integer @key{range} <>) @key{of} Complex;
3213 @key{type} @AdaTypeDefn{Complex_Matrix} @key{is array} (Integer @key{range} <>,
3214 Integer @key{range} <>) @key{of} Complex;]}
3215
3216 @ChgRef{Version=[2],Kind=[AddedNormal]}
3217 @ChgAdded{Version=[2],Text=[ -- @RI{Subprograms for Complex_Vector types}]}
3218
3219 @ChgRef{Version=[2],Kind=[AddedNormal]}
3220 @ChgAdded{Version=[2],Text=[ -- @RI{Complex_Vector selection, conversion and composition operations}]}
3221
3222 @ChgRef{Version=[2],Kind=[AddedNormal]}
3223 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Re} (X : Complex_Vector) @key{return} Real_Vector;
3224 @key{function} @AdaSubDefn{Im} (X : Complex_Vector) @key{return} Real_Vector;]}
3225
3226 @ChgRef{Version=[2],Kind=[AddedNormal]}
3227 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Set_Re} (X : @key{in out} Complex_Vector;
3228 Re : @key{in} Real_Vector);
3229 @key{procedure} @AdaSubDefn{Set_Im} (X : @key{in out} Complex_Vector;
3230 Im : @key{in} Real_Vector);]}
3231
3232 @ChgRef{Version=[2],Kind=[AddedNormal]}
3233 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Compose_From_Cartesian} (Re : Real_Vector)
3234 @key{return} Complex_Vector;
3235 @key{function} @AdaSubDefn{Compose_From_Cartesian} (Re, Im : Real_Vector)
3236 @key{return} Complex_Vector;]}
3237
3238 @ChgRef{Version=[2],Kind=[AddedNormal]}
3239 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Modulus} (X : Complex_Vector) @key{return} Real_Vector;
3240 @key{function} "@key{abs}" (Right : Complex_Vector) @key{return} Real_Vector
3241 @key{renames} Modulus;
3242 @key{function} @AdaSubDefn{Argument} (X : Complex_Vector) @key{return} Real_Vector;
3243 @key{function} @AdaSubDefn{Argument} (X : Complex_Vector;
3244 Cycle : Real'Base) @key{return} Real_Vector;]}
3245
3246 @ChgRef{Version=[2],Kind=[AddedNormal]}
3247 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Compose_From_Polar} (Modulus, Argument : Real_Vector)
3248 @key{return} Complex_Vector;
3249 @key{function} @AdaSubDefn{Compose_From_Polar} (Modulus, Argument : Real_Vector;
3250 Cycle : Real'Base)
3251 @key{return} Complex_Vector;]}
3252
3253 @ChgRef{Version=[2],Kind=[AddedNormal]}
3254 @ChgAdded{Version=[2],Text=[ -- @RI{Complex_Vector arithmetic operations}]}
3255
3256 @ChgRef{Version=[2],Kind=[AddedNormal]}
3257 @ChgAdded{Version=[2],Text=[ @key{function} "+" (Right : Complex_Vector) @key{return} Complex_Vector;
3258 @key{function} "-" (Right : Complex_Vector) @key{return} Complex_Vector;
3259 @key{function} @AdaSubDefn{Conjugate} (X : Complex_Vector) @key{return} Complex_Vector;]}
3260
3261 @ChgRef{Version=[2],Kind=[AddedNormal]}
3262 @ChgAdded{Version=[2],Text=[ @key{function} "+" (Left, Right : Complex_Vector) @key{return} Complex_Vector;
3263 @key{function} "-" (Left, Right : Complex_Vector) @key{return} Complex_Vector;]}
3264
3265 @ChgRef{Version=[2],Kind=[AddedNormal]}
3266 @ChgAdded{Version=[2],Text=[ @key{function} "*" (Left, Right : Complex_Vector) @key{return} Complex;]}
3267
3268 @ChgRef{Version=[2],Kind=[AddedNormal]}
3269 @ChgAdded{Version=[2],Text=[ @key{function} "@key{abs}" (Right : Complex_Vector) @key{return} Complex;]}
3270
3271 @ChgRef{Version=[2],Kind=[AddedNormal]}
3272 @ChgAdded{Version=[2],Text=[ -- @RI{Mixed Real_Vector and Complex_Vector arithmetic operations}]}
3273
3274 @ChgRef{Version=[2],Kind=[AddedNormal]}
3275 @ChgAdded{Version=[2],Text=[ @key{function} "+" (Left : Real_Vector;
3276 Right : Complex_Vector) @key{return} Complex_Vector;
3277 @key{function} "+" (Left : Complex_Vector;
3278 Right : Real_Vector) @key{return} Complex_Vector;
3279 @key{function} "-" (Left : Real_Vector;
3280 Right : Complex_Vector) @key{return} Complex_Vector;
3281 @key{function} "-" (Left : Complex_Vector;
3282 Right : Real_Vector) @key{return} Complex_Vector;]}
3283
3284 @ChgRef{Version=[2],Kind=[AddedNormal]}
3285 @ChgAdded{Version=[2],Text=[ @key{function} "*" (Left : Real_Vector; Right : Complex_Vector)
3286 @key{return} Complex;
3287 @key{function} "*" (Left : Complex_Vector; Right : Real_Vector)
3288 @key{return} Complex;]}
3289
3290 @ChgRef{Version=[2],Kind=[AddedNormal]}
3291 @ChgAdded{Version=[2],Text=[ -- @RI{Complex_Vector scaling operations}]}
3292
3293 @ChgRef{Version=[2],Kind=[AddedNormal]}
3294 @ChgAdded{Version=[2],Text=[ @key{function} "*" (Left : Complex;
3295 Right : Complex_Vector) @key{return} Complex_Vector;
3296 @key{function} "*" (Left : Complex_Vector;
3297 Right : Complex) @key{return} Complex_Vector;
3298 @key{function} "/" (Left : Complex_Vector;
3299 Right : Complex) @key{return} Complex_Vector;]}
3300
3301 @ChgRef{Version=[2],Kind=[AddedNormal]}
3302 @ChgAdded{Version=[2],Text=[ @key{function} "*" (Left : Real'Base;
3303 Right : Complex_Vector) @key{return} Complex_Vector;
3304 @key{function} "*" (Left : Complex_Vector;
3305 Right : Real'Base) @key{return} Complex_Vector;
3306 @key{function} "/" (Left : Complex_Vector;
3307 Right : Real'Base) @key{return} Complex_Vector;]}
3308
3309 @ChgRef{Version=[2],Kind=[AddedNormal]}
3310 @ChgAdded{Version=[2],Text=[ -- @RI{Other Complex_Vector operations}]}
3311
3312 @ChgRef{Version=[2],Kind=[AddedNormal]}
3313 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Unit_Vector} (Index : Integer;
3314 Order : Positive;
3315 First : Integer := 1) @key{return} Complex_Vector;]}
3316
3317 @ChgRef{Version=[2],Kind=[AddedNormal]}
3318 @ChgAdded{Version=[2],Text=[ -- @RI{Subprograms for Complex_Matrix types}]}
3319
3320 @ChgRef{Version=[2],Kind=[AddedNormal]}
3321 @ChgAdded{Version=[2],Text=[ -- @RI{Complex_Matrix selection, conversion and composition operations}]}
3322
3323 @ChgRef{Version=[2],Kind=[AddedNormal]}
3324 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Re} (X : Complex_Matrix) @key{return} Real_Matrix;
3325 @key{function} @AdaSubDefn{Im} (X : Complex_Matrix) @key{return} Real_Matrix;]}
3326
3327 @ChgRef{Version=[2],Kind=[AddedNormal]}
3328 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Set_Re} (X : @key{in out} Complex_Matrix;
3329 Re : @key{in} Real_Matrix);
3330 @key{procedure} @AdaSubDefn{Set_Im} (X : @key{in out} Complex_Matrix;
3331 Im : @key{in} Real_Matrix);]}
3332
3333 @ChgRef{Version=[2],Kind=[AddedNormal]}
3334 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Compose_From_Cartesian} (Re : Real_Matrix)
3335 @key{return} Complex_Matrix;
3336 @key{function} @AdaSubDefn{Compose_From_Cartesian} (Re, Im : Real_Matrix)
3337 @key{return} Complex_Matrix;]}
3338
3339 @ChgRef{Version=[2],Kind=[AddedNormal]}
3340 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Modulus} (X : Complex_Matrix) @key{return} Real_Matrix;
3341 @key{function} "@key{abs}" (Right : Complex_Matrix) @key{return} Real_Matrix
3342 @key{renames} Modulus;]}
3343
3344 @ChgRef{Version=[2],Kind=[AddedNormal]}
3345 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Argument} (X : Complex_Matrix) @key{return} Real_Matrix;
3346 @key{function} @AdaSubDefn{Argument} (X : Complex_Matrix;
3347 Cycle : Real'Base) @key{return} Real_Matrix;]}
3348
3349 @ChgRef{Version=[2],Kind=[AddedNormal]}
3350 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Compose_From_Polar} (Modulus, Argument : Real_Matrix)
3351 @key{return} Complex_Matrix;
3352 @key{function} @AdaSubDefn{Compose_From_Polar} (Modulus, Argument : Real_Matrix;
3353 Cycle : Real'Base)
3354 @key{return} Complex_Matrix;]}
3355
3356 @ChgRef{Version=[2],Kind=[AddedNormal]}
3357 @ChgAdded{Version=[2],Text=[ -- @RI{Complex_Matrix arithmetic operations}]}
3358
3359 @ChgRef{Version=[2],Kind=[AddedNormal]}
3360 @ChgAdded{Version=[2],Text=[ @key{function} "+" (Right : Complex_Matrix) @key{return} Complex_Matrix;
3361 @key{function} "-" (Right : Complex_Matrix) @key{return} Complex_Matrix;
3362 @key{function} @AdaSubDefn{Conjugate} (X : Complex_Matrix) @key{return} Complex_Matrix;
3363 @key{function} @AdaSubDefn{Transpose} (X : Complex_Matrix) @key{return} Complex_Matrix;]}
3364
3365 @ChgRef{Version=[2],Kind=[AddedNormal]}
3366 @ChgAdded{Version=[2],Text=[ @key{function} "+" (Left, Right : Complex_Matrix) @key{return} Complex_Matrix;
3367 @key{function} "-" (Left, Right : Complex_Matrix) @key{return} Complex_Matrix;
3368 @key{function} "*" (Left, Right : Complex_Matrix) @key{return} Complex_Matrix;]}
3369
3370 @ChgRef{Version=[2],Kind=[AddedNormal]}
3371 @ChgAdded{Version=[2],Text=[ @key{function} "*" (Left, Right : Complex_Vector) @key{return} Complex_Matrix;]}
3372
3373 @ChgRef{Version=[2],Kind=[AddedNormal]}
3374 @ChgAdded{Version=[2],Text=[ @key{function} "*" (Left : Complex_Vector;
3375 Right : Complex_Matrix) @key{return} Complex_Vector;
3376 @key{function} "*" (Left : Complex_Matrix;
3377 Right : Complex_Vector) @key{return} Complex_Vector;]}
3378
3379 @ChgRef{Version=[2],Kind=[AddedNormal]}
3380 @ChgAdded{Version=[2],Text=[ -- @RI{Mixed Real_Matrix and Complex_Matrix arithmetic operations}]}
3381
3382 @ChgRef{Version=[2],Kind=[AddedNormal]}
3383 @ChgAdded{Version=[2],Text=[ @key{function} "+" (Left : Real_Matrix;
3384 Right : Complex_Matrix) @key{return} Complex_Matrix;
3385 @key{function} "+" (Left : Complex_Matrix;
3386 Right : Real_Matrix) @key{return} Complex_Matrix;
3387 @key{function} "-" (Left : Real_Matrix;
3388 Right : Complex_Matrix) @key{return} Complex_Matrix;
3389 @key{function} "-" (Left : Complex_Matrix;
3390 Right : Real_Matrix) @key{return} Complex_Matrix;
3391 @key{function} "*" (Left : Real_Matrix;
3392 Right : Complex_Matrix) @key{return} Complex_Matrix;
3393 @key{function} "*" (Left : Complex_Matrix;
3394 Right : Real_Matrix) @key{return} Complex_Matrix;]}
3395
3396 @ChgRef{Version=[2],Kind=[AddedNormal]}
3397 @ChgAdded{Version=[2],Text=[ @key{function} "*" (Left : Real_Vector;
3398 Right : Complex_Vector) @key{return} Complex_Matrix;
3399 @key{function} "*" (Left : Complex_Vector;
3400 Right : Real_Vector) @key{return} Complex_Matrix;]}
3401
3402 @ChgRef{Version=[2],Kind=[AddedNormal]}
3403 @ChgAdded{Version=[2],Text=[ @key{function} "*" (Left : Real_Vector;
3404 Right : Complex_Matrix) @key{return} Complex_Vector;
3405 @key{function} "*" (Left : Complex_Vector;
3406 Right : Real_Matrix) @key{return} Complex_Vector;
3407 @key{function} "*" (Left : Real_Matrix;
3408 Right : Complex_Vector) @key{return} Complex_Vector;
3409 @key{function} "*" (Left : Complex_Matrix;
3410 Right : Real_Vector) @key{return} Complex_Vector;]}
3411
3412 @ChgRef{Version=[2],Kind=[AddedNormal]}
3413 @ChgAdded{Version=[2],Text=[ -- @RI{Complex_Matrix scaling operations}]}
3414
3415 @ChgRef{Version=[2],Kind=[AddedNormal]}
3416 @ChgAdded{Version=[2],Text=[ @key{function} "*" (Left : Complex;
3417 Right : Complex_Matrix) @key{return} Complex_Matrix;
3418 @key{function} "*" (Left : Complex_Matrix;
3419 Right : Complex) @key{return} Complex_Matrix;
3420 @key{function} "/" (Left : Complex_Matrix;
3421 Right : Complex) @key{return} Complex_Matrix;]}
3422
3423 @ChgRef{Version=[2],Kind=[AddedNormal]}
3424 @ChgAdded{Version=[2],Text=[ @key{function} "*" (Left : Real'Base;
3425 Right : Complex_Matrix) @key{return} Complex_Matrix;
3426 @key{function} "*" (Left : Complex_Matrix;
3427 Right : Real'Base) @key{return} Complex_Matrix;
3428 @key{function} "/" (Left : Complex_Matrix;
3429 Right : Real'Base) @key{return} Complex_Matrix;]}
3430
3431 @ChgRef{Version=[2],Kind=[AddedNormal]}
3432 @ChgAdded{Version=[2],Text=[ -- @RI{Complex_Matrix inversion and related operations}]}
3433
3434 @ChgRef{Version=[2],Kind=[AddedNormal]}
3435 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Solve} (A : Complex_Matrix; X : Complex_Vector)
3436 @key{return} Complex_Vector;
3437 @key{function} @AdaSubDefn{Solve} (A, X : Complex_Matrix) @key{return} Complex_Matrix;
3438 @key{function} @AdaSubDefn{Inverse} (A : Complex_Matrix) @key{return} Complex_Matrix;
3439 @key{function} @AdaSubDefn{Determinant} (A : Complex_Matrix) @key{return} Complex;]}
3440
3441 @ChgRef{Version=[2],Kind=[AddedNormal]}
3442 @ChgAdded{Version=[2],Text=[ -- @RI{Eigenvalues and vectors of a Hermitian matrix}]}
3443
3444 @ChgRef{Version=[2],Kind=[AddedNormal]}
3445 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Eigenvalues}(A : Complex_Matrix) @key{return} Real_Vector;]}
3446
3447 @ChgRef{Version=[2],Kind=[AddedNormal]}
3448 @ChgAdded{Version=[2],Text=[ @key{procedure} @AdaSubDefn{Eigensystem}(A : @key{in} Complex_Matrix;
3449 Values : @key{out} Real_Vector;
3450 Vectors : @key{out} Complex_Matrix);]}
3451
3452 @ChgRef{Version=[2],Kind=[AddedNormal]}
3453 @ChgAdded{Version=[2],Text=[ -- @RI{Other Complex_Matrix operations}]}
3454
3455 @ChgRef{Version=[2],Kind=[AddedNormal]}
3456 @ChgAdded{Version=[2],Text=[ @key{function} @AdaSubDefn{Unit_Matrix} (Order : Positive;
3457 First_1, First_2 : Integer := 1)
3458 @key{return} Complex_Matrix;]}
3459
3460 @ChgRef{Version=[2],Kind=[AddedNormal]}
3461 @ChgAdded{Version=[2],Text=[@key{end} Ada.Numerics.Generic_Complex_Arrays;]}
3462
3463 @end{Example}
3464
3465 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3466 @ChgAdded{Version=[2],Text=[@ChildUnit{Parent=[Ada.Numerics],Child=[Complex_@!Arrays]}
3467 The library package Numerics.Complex_Arrays is declared pure and defines
3468 the same types and subprograms as Numerics.Generic_Complex_Arrays, except
3469 that the predefined type Float is systematically substituted for Real'Base,
3470 and the Real_Vector and Real_Matrix types exported by Numerics.Real_Arrays
3471 are systematically substituted for Real_Vector and Real_Matrix, and the
3472 Complex type exported by Numerics.Complex_Types is systematically
3473 substituted for Complex, throughout. Nongeneric equivalents for each of
3474 the other predefined floating point types are defined similarly, with the
3475 names Numerics.Short_Complex_Arrays, Numerics.Long_Complex_Arrays, etc.]}
3476
3477 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3478 @ChgAdded{Version=[2],Text=[Two types are defined and exported by
3479 Numerics.Generic_Complex_Arrays. The composite type Complex_Vector is
3480 provided to represent a vector with components of type Complex; it is defined
3481 as an unconstrained one-dimensional array with an index of type Integer. The
3482 composite type Complex_Matrix is provided to represent a matrix with components
3483 of type Complex; it is defined as an unconstrained, two-dimensional array with
3484 indices of type Integer.]}
3485
3486 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3487 @ChgAdded{Version=[2],Text=[The effect of the various subprograms is as
3488 described below. In many cases they are described in terms of corresponding
3489 scalar operations in Numerics.Generic_Complex_Types. Any exception raised by
3490 those operations is propagated by the array subprogram. Moreover, any
3491 constraints on the parameters and the accuracy of the result for each
3492 individual component are as defined for the scalar operation.]}
3493
3494 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3495 @ChgAdded{Version=[2],Text=[In the case of those operations which are defined
3496 to @i{involve an inner product}, Constraint_Error may be raised if an intermediate
3497 result has a component outside the range of Real'Base even though the final
3498 mathematical result would not.@Defn2{Term=[involve an inner product],Sec=[complex]}]}
3499
3500 @begin{DescribeCode}
3501
3502 @begin{Example}
3503 @ChgRef{Version=[2],Kind=[AddedNormal]}
3504 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Re (X : Complex_Vector) @key{return} Real_Vector;
3505 @key{function} Im (X : Complex_Vector) @key{return} Real_Vector;]}
3506 @end{Example}
3507
3508 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3509 @ChgAdded{Version=[2],Text=[Each function returns a vector of the specified
3510 Cartesian components of X. The index range of the result is X'Range.]}
3511
3512 @begin{Example}
3513 @ChgRef{Version=[2],Kind=[AddedNormal]}
3514 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Set_Re (X : @key{in out} Complex_Vector; Re : @key{in} Real_Vector);
3515 @key{procedure} Set_Im (X : @key{in out} Complex_Vector; Im : @key{in} Real_Vector);]}
3516 @end{Example}
3517
3518 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3519 @ChgAdded{Version=[2],Text=[Each procedure replaces the specified (Cartesian)
3520 component of each of the components of X by the value of the matching component
3521 of Re or Im; the other (Cartesian) component of each of the components is
3522 unchanged. Constraint_Error is raised if X'Length is not equal to Re'Length or
3523 Im'Length.]}
3524
3525 @begin{Example}
3526 @ChgRef{Version=[2],Kind=[AddedNormal]}
3527 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Compose_From_Cartesian (Re : Real_Vector)
3528 @key{return} Complex_Vector;
3529 @key{function} Compose_From_Cartesian (Re, Im : Real_Vector)
3530 @key{return} Complex_Vector;]}
3531 @end{Example}
3532
3533 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3534 @ChgAdded{Version=[2],Text=[Each function constructs a vector of Complex
3535 results (in Cartesian representation) formed from given vectors of Cartesian
3536 components; when only the real components are given, imaginary components of
3537 zero are assumed. The index range of the result is Re'Range. Constraint_Error
3538 is raised if Re'Length is not equal to Im'Length.]}
3539
3540 @begin{Example}
3541 @ChgRef{Version=[2],Kind=[AddedNormal]}
3542 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Modulus (X : Complex_Vector) @key{return} Real_Vector;
3543 @key{function} "@key{abs}" (Right : Complex_Vector) @key{return} Real_Vector
3544 @key{renames} Modulus;
3545 @key{function} Argument (X : Complex_Vector) @key{return} Real_Vector;
3546 @key{function} Argument (X : Complex_Vector;
3547 Cycle : Real'Base) @key{return} Real_Vector;]}
3548 @end{Example}
3549
3550 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3551 @ChgAdded{Version=[2],Text=[Each function calculates and returns a vector of
3552 the specified polar components of X or Right using the corresponding function
3553 in numerics.@!generic_complex_types. The index range of the result is X'Range or
3554 Right'Range.]}
3555
3556 @begin{Example}
3557 @ChgRef{Version=[2],Kind=[AddedNormal]}
3558 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Compose_From_Polar (Modulus, Argument : Real_Vector)
3559 @key{return} Complex_Vector;
3560 @key{function} Compose_From_Polar (Modulus, Argument : Real_Vector;
3561 Cycle : Real'Base)
3562 @key{return} Complex_Vector;]}
3563 @end{Example}
3564
3565 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3566 @ChgAdded{Version=[2],Text=[Each function constructs a vector of Complex
3567 results (in Cartesian representation) formed from given vectors of polar
3568 components using the corresponding function in numerics.@!generic_complex_types
3569 on matching components of Modulus and Argument. The index range of the result
3570 is Modulus'Range. Constraint_Error is raised if Modulus'Length is not equal to
3571 Argument'Length.]}
3572
3573 @begin{Example}
3574 @ChgRef{Version=[2],Kind=[AddedNormal]}
3575 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "+" (Right : Complex_Vector) @key{return} Complex_Vector;
3576 @key{function} "-" (Right : Complex_Vector) @key{return} Complex_Vector;]}
3577 @end{Example}
3578
3579 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3580 @ChgAdded{Version=[2],Text=[Each operation returns the result of applying the
3581 corresponding operation in numerics.@!generic_complex_types to each component of
3582 Right. The index range of the result is Right'Range.]}
3583
3584 @begin{Example}
3585 @ChgRef{Version=[2],Kind=[AddedNormal]}
3586 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Conjugate (X : Complex_Vector) @key{return} Complex_Vector;]}
3587 @end{Example}
3588
3589 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3590 @ChgAdded{Version=[2],Text=[This function returns the result of applying the
3591 appropriate function Conjugate in numerics.@!generic_complex_types to each
3592 component of X. The index range of the result is X'Range.]}
3593
3594 @begin{Example}
3595 @ChgRef{Version=[2],Kind=[AddedNormal]}
3596 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "+" (Left, Right : Complex_Vector) @key{return} Complex_Vector;
3597 @key{function} "-" (Left, Right : Complex_Vector) @key{return} Complex_Vector;]}
3598 @end{Example}
3599
3600 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3601 @ChgAdded{Version=[2],Text=[Each operation returns the result of applying the
3602 corresponding operation in numerics.@!generic_complex_types to each component of
3603 Left and the matching component of Right. The index range of the result is
3604 Left'Range. Constraint_Error is raised if Left'Length is not equal to
3605 Right'Length.]}
3606
3607 @begin{Example}
3608 @ChgRef{Version=[2],Kind=[AddedNormal]}
3609 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left, Right : Complex_Vector) @key{return} Complex;]}
3610 @end{Example}
3611
3612 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3613 @ChgAdded{Version=[2],Text=[This operation returns the inner product of Left
3614 and Right. Constraint_Error is raised if Left'Length is not equal to
3615 Right'Length. This operation involves an inner product.]}
3616
3617 @begin{Example}
3618 @ChgRef{Version=[2],Kind=[AddedNormal]}
3619 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "@key{abs}" (Right : Complex_Vector) @key{return} Complex;]}
3620 @end{Example}
3621
3622 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00418-01]}
3623 @ChgAdded{Version=[2],Text=[This operation returns the Hermitian L2-norm of
3624 Right (the square root of the inner product of the vector with its
3625 conjugate).]}
3626
3627 @begin{ImplNote}
3628 @ChgRef{Version=[2],Kind=[AddedNormal]}
3629 @ChgAdded{Version=[2],Text=[While the definition is given in terms of
3630 an inner product, the norm doesn't @lquotes@;involve an inner product@rquotes
3631 in the technical sense. The reason is that it has accuracy requirements
3632 substantially different from those applicable to inner products; and that
3633 cancellations cannot occur, because all the terms are positive, so there
3634 is no possibility of intermediate overflow.]}
3635 @end{ImplNote}
3636
3637 @begin{Example}
3638 @ChgRef{Version=[2],Kind=[AddedNormal]}
3639 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "+" (Left : Real_Vector;
3640 Right : Complex_Vector) @key{return} Complex_Vector;
3641 @key{function} "+" (Left : Complex_Vector;
3642 Right : Real_Vector) @key{return} Complex_Vector;
3643 @key{function} "-" (Left : Real_Vector;
3644 Right : Complex_Vector) @key{return} Complex_Vector;
3645 @key{function} "-" (Left : Complex_Vector;
3646 Right : Real_Vector) @key{return} Complex_Vector;]}
3647 @end{Example}
3648
3649 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3650 @ChgAdded{Version=[2],Text=[Each operation returns the result of applying the
3651 corresponding operation in numerics.@!generic_complex_types to each component of
3652 Left and the matching component of Right. The index range of the result is
3653 Left'Range. Constraint_Error is raised if Left'Length is not equal to
3654 Right'Length.]}
3655
3656 @begin{Example}
3657 @ChgRef{Version=[2],Kind=[AddedNormal]}
3658 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left : Real_Vector; Right : Complex_Vector) @key{return} Complex;
3659 @key{function} "*" (Left : Complex_Vector; Right : Real_Vector) @key{return} Complex;]}
3660 @end{Example}
3661
3662 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3663 @ChgAdded{Version=[2],Text=[Each operation returns the inner product of Left
3664 and Right. Constraint_Error is raised if Left'Length is not equal to
3665 Right'Length. These operations involve an inner product.]}
3666
3667 @begin{Example}
3668 @ChgRef{Version=[2],Kind=[AddedNormal]}
3669 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left : Complex; Right : Complex_Vector) @key{return} Complex_Vector;]}
3670 @end{Example}
3671
3672 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3673 @ChgAdded{Version=[2],Text=[This operation returns the result of multiplying
3674 each component of Right by the complex number Left using the appropriate
3675 operation "*" in numerics.@!generic_complex_types. The index range of the result
3676 is Right'Range.]}
3677
3678 @begin{Example}
3679 @ChgRef{Version=[2],Kind=[AddedNormal]}
3680 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left : Complex_Vector; Right : Complex) @key{return} Complex_Vector;
3681 @key{function} "/" (Left : Complex_Vector; Right : Complex) @key{return} Complex_Vector;]}
3682 @end{Example}
3683
3684 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3685 @ChgAdded{Version=[2],Text=[Each operation returns the result of applying the
3686 corresponding operation in numerics.@!generic_complex_types to each component of
3687 the vector Left and the complex number Right. The index range of the result is
3688 Left'Range.]}
3689
3690 @begin{Example}
3691 @ChgRef{Version=[2],Kind=[AddedNormal]}
3692 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left : Real'Base;
3693 Right : Complex_Vector) @key{return} Complex_Vector;]}
3694 @end{Example}
3695
3696 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3697 @ChgAdded{Version=[2],Text=[This operation returns the result of multiplying
3698 each component of Right by the real number Left using the appropriate operation
3699 "*" in numerics.@!generic_complex_types. The index range of the result is
3700 Right'Range.]}
3701
3702 @begin{Example}
3703 @ChgRef{Version=[2],Kind=[AddedNormal]}
3704 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left : Complex_Vector;
3705 Right : Real'Base) @key{return} Complex_Vector;
3706 @key{function} "/" (Left : Complex_Vector;
3707 Right : Real'Base) @key{return} Complex_Vector;]}
3708 @end{Example}
3709
3710 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3711 @ChgAdded{Version=[2],Text=[Each operation returns the result of applying the
3712 corresponding operation in numerics.@!generic_complex_types to each component of
3713 the vector Left and the real number Right. The index range of the result is
3714 Left'Range.]}
3715
3716 @begin{Example}
3717 @ChgRef{Version=[2],Kind=[AddedNormal]}
3718 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Unit_Vector (Index : Integer;
3719 Order : Positive;
3720 First : Integer := 1) @key{return} Complex_Vector;]}
3721 @end{Example}
3722
3723 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3724 @ChgAdded{Version=[2],Text=[This function returns a @i{unit
3725 vector}@Defn2{Term=[unit vector],Sec=[complex vector]} with Order components
3726 and a lower bound of First. All components are set to (0.0, 0.0) except for the
3727 Index component which is set to (1.0, 0.0). Constraint_Error is raised if Index
3728 < First, Index > First + Order @en 1, or if First + Order @en 1 > Integer'Last.]}
3729
3730 @begin{Example}
3731 @ChgRef{Version=[2],Kind=[AddedNormal]}
3732 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Re (X : Complex_Matrix) @key{return} Real_Matrix;
3733 @key{function} Im (X : Complex_Matrix) @key{return} Real_Matrix;]}
3734 @end{Example}
3735
3736 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3737 @ChgAdded{Version=[2],Text=[Each function returns a matrix of the specified
3738 Cartesian components of X. The index ranges of the result are those of X.]}
3739
3740 @begin{Example}
3741 @ChgRef{Version=[2],Kind=[AddedNormal]}
3742 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Set_Re (X : @key{in out} Complex_Matrix; Re : @key{in} Real_Matrix);
3743 @key{procedure} Set_Im (X : @key{in out} Complex_Matrix; Im : @key{in} Real_Matrix);]}
3744 @end{Example}
3745
3746 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3747 @ChgAdded{Version=[2],Text=[Each procedure replaces the specified (Cartesian)
3748 component of each of the components of X by the value of the matching component
3749 of Re or Im; the other (Cartesian) component of each of the components is
3750 unchanged. Constraint_Error is raised if X'Length(1) is not equal to
3751 Re'Length(1) or Im'Length(1) or if X'Length(2) is not equal to Re'Length(2) or
3752 Im'Length(2).]}
3753
3754 @begin{Example}
3755 @ChgRef{Version=[2],Kind=[AddedNormal]}
3756 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Compose_From_Cartesian (Re : Real_Matrix)
3757 @key{return} Complex_Matrix;
3758 @key{function} Compose_From_Cartesian (Re, Im : Real_Matrix)
3759 @key{return} Complex_Matrix;]}
3760 @end{Example}
3761
3762 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3763 @ChgAdded{Version=[2],Text=[Each function constructs a matrix of Complex
3764 results (in Cartesian representation) formed from given matrices of Cartesian
3765 components; when only the real components are given, imaginary components of
3766 zero are assumed. The index ranges of the result are those of Re.
3767 Constraint_Error is raised if Re'Length(1) is not equal to Im'Length(1) or
3768 Re'Length(2) is not equal to Im'Length(2).]}
3769
3770 @begin{Example}
3771 @ChgRef{Version=[2],Kind=[AddedNormal]}
3772 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Modulus (X : Complex_Matrix) @key{return} Real_Matrix;
3773 @key{function} "@key{abs}" (Right : Complex_Matrix) @key{return} Real_Matrix
3774 @key{renames} Modulus;
3775 @key{function} Argument (X : Complex_Matrix) @key{return} Real_Matrix;
3776 @key{function} Argument (X : Complex_Matrix;
3777 Cycle : Real'Base) @key{return} Real_Matrix;]}
3778 @end{Example}
3779
3780 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3781 @ChgAdded{Version=[2],Text=[Each function calculates and returns a matrix of
3782 the specified polar components of X or Right using the corresponding function
3783 in numerics.@!generic_complex_types. The index ranges of the result are those of
3784 X or Right.]}
3785
3786 @begin{Example}
3787 @ChgRef{Version=[2],Kind=[AddedNormal]}
3788 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Compose_From_Polar (Modulus, Argument : Real_Matrix)
3789 @key{return} Complex_Matrix;
3790 @key{function} Compose_From_Polar (Modulus, Argument : Real_Matrix;
3791 Cycle : Real'Base)
3792 @key{return} Complex_Matrix;]}
3793 @end{Example}
3794
3795 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3796 @ChgAdded{Version=[2],Text=[Each function constructs a matrix of Complex
3797 results (in Cartesian representation) formed from given matrices of polar
3798 components using the corresponding function in numerics.@!generic_complex_types
3799 on matching components of Modulus and Argument. The index ranges of the result
3800 are those of Modulus. Constraint_Error is raised if Modulus'Length(1) is not
3801 equal to Argument'Length(1) or Modulus'Length(2) is not equal to
3802 Argument'Length(2).]}
3803
3804 @begin{Example}
3805 @ChgRef{Version=[2],Kind=[AddedNormal]}
3806 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "+" (Right : Complex_Matrix) @key{return} Complex_Matrix;
3807 @key{function} "-" (Right : Complex_Matrix) @key{return} Complex_Matrix;]}
3808 @end{Example}
3809
3810 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3811 @ChgAdded{Version=[2],Text=[Each operation returns the result of applying the
3812 corresponding operation in numerics.@!generic_complex_types to each component of
3813 Right. The index ranges of the result are those of Right.]}
3814
3815 @begin{Example}
3816 @ChgRef{Version=[2],Kind=[AddedNormal]}
3817 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Conjugate (X : Complex_Matrix) @key{return} Complex_Matrix;]}
3818 @end{Example}
3819
3820 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3821 @ChgAdded{Version=[2],Text=[This function returns the result of applying the
3822 appropriate function Conjugate in numerics.@!generic_complex_types to each
3823 component of X. The index ranges of the result are those of X.]}
3824
3825 @begin{Example}
3826 @ChgRef{Version=[2],Kind=[AddedNormal]}
3827 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Transpose (X : Complex_Matrix) @key{return} Complex_Matrix;]}
3828 @end{Example}
3829
3830 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3831 @ChgAdded{Version=[2],Text=[This function returns the transpose of a matrix X.
3832 The first and second index ranges of the result are X'Range(2) and X'Range(1)
3833 respectively.]}
3834
3835 @begin{Example}
3836 @ChgRef{Version=[2],Kind=[AddedNormal]}
3837 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "+" (Left, Right : Complex_Matrix) @key{return} Complex_Matrix;
3838 @key{function} "-" (Left, Right : Complex_Matrix) @key{return} Complex_Matrix;]}
3839 @end{Example}
3840
3841 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3842 @ChgAdded{Version=[2],Text=[Each operation returns the result of applying the
3843 corresponding operation in numerics.@!generic_complex_types to each component of
3844 Left and the matching component of Right. The index ranges of the result are
3845 those of Left. Constraint_Error is raised if Left'Length(1) is not equal to
3846 Right'Length(1) or Left'Length(2) is not equal to Right'Length(2).]}
3847
3848 @begin{Example}
3849 @ChgRef{Version=[2],Kind=[AddedNormal]}
3850 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left, Right : Complex_Matrix) @key{return} Complex_Matrix;]}
3851 @end{Example}
3852
3853 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3854 @ChgAdded{Version=[2],Text=[This operation provides the standard mathematical
3855 operation for matrix multiplication. The first and second index ranges of the
3856 result are Left'Range(1) and Right'Range(2) respectively. Constraint_Error is
3857 raised if Left'Length(2) is not equal to Right'Length(1). This operation
3858 involves inner products.]}
3859
3860 @begin{Example}
3861 @ChgRef{Version=[2],Kind=[AddedNormal]}
3862 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left, Right : Complex_Vector) @key{return} Complex_Matrix;]}
3863 @end{Example}
3864
3865 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3866 @ChgAdded{Version=[2],Text=[This operation returns the outer product of a
3867 (column) vector Left by a (row) vector Right using the appropriate operation
3868 "*" in numerics.@!generic_complex_types for computing the individual components.
3869 The first and second index ranges of the result are Left'Range and
3870 Right'Range respectively.]}
3871
3872 @begin{Example}
3873 @ChgRef{Version=[2],Kind=[AddedNormal]}
3874 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left : Complex_Vector;
3875 Right : Complex_Matrix) @key{return} Complex_Vector;]}
3876 @end{Example}
3877
3878 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3879 @ChgAdded{Version=[2],Text=[This operation provides the standard mathematical
3880 operation for multiplication of a (row) vector Left by a matrix Right. The
3881 index range of the (row) vector result is Right'Range(2). Constraint_Error is
3882 raised if Left'Length is not equal to Right'Length(1). This operation involves
3883 inner products.]}
3884
3885 @begin{Example}
3886 @ChgRef{Version=[2],Kind=[AddedNormal]}
3887 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left : Complex_Matrix;
3888 Right : Complex_Vector) @key{return} Complex_Vector;]}
3889 @end{Example}
3890
3891 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3892 @ChgAdded{Version=[2],Text=[This operation provides the standard mathematical
3893 operation for multiplication of a matrix Left by a (column) vector Right. The
3894 index range of the (column) vector result is Left'Range(1). Constraint_Error is
3895 raised if Left'Length(2) is not equal to Right'Length. This operation involves
3896 inner products.]}
3897
3898 @begin{Example}
3899 @ChgRef{Version=[2],Kind=[AddedNormal]}
3900 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "+" (Left : Real_Matrix;
3901 Right : Complex_Matrix) @key{return} Complex_Matrix;
3902 @key{function} "+" (Left : Complex_Matrix;
3903 Right : Real_Matrix) @key{return} Complex_Matrix;
3904 @key{function} "-" (Left : Real_Matrix;
3905 Right : Complex_Matrix) @key{return} Complex_Matrix;
3906 @key{function} "-" (Left : Complex_Matrix;
3907 Right : Real_Matrix) @key{return} Complex_Matrix;]}
3908 @end{Example}
3909
3910 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3911 @ChgAdded{Version=[2],Text=[Each operation returns the result of applying the
3912 corresponding operation in numerics.@!generic_complex_types to each component of
3913 Left and the matching component of Right. The index ranges of the result are
3914 those of Left. Constraint_Error is raised if Left'Length(1) is
3915 not equal to Right'Length(1) or Left'Length(2) is not equal to
3916 Right'Length(2).]}
3917
3918 @begin{Example}
3919 @ChgRef{Version=[2],Kind=[AddedNormal]}
3920 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left : Real_Matrix;
3921 Right : Complex_Matrix) @key{return} Complex_Matrix;
3922 @key{function} "*" (Left : Complex_Matrix;
3923 Right : Real_Matrix) @key{return} Complex_Matrix;]}
3924 @end{Example}
3925
3926 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3927 @ChgAdded{Version=[2],Text=[Each operation provides the standard mathematical
3928 operation for matrix multiplication. The first and second index ranges of the
3929 result are Left'Range(1) and Right'Range(2) respectively. Constraint_Error is
3930 raised if Left'Length(2) is not equal to Right'Length(1). These operations
3931 involve inner products.]}
3932
3933 @begin{Example}
3934 @ChgRef{Version=[2],Kind=[AddedNormal]}
3935 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left : Real_Vector;
3936 Right : Complex_Vector) @key{return} Complex_Matrix;
3937 @key{function} "*" (Left : Complex_Vector;
3938 Right : Real_Vector) @key{return} Complex_Matrix;]}
3939 @end{Example}
3940
3941 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3942 @ChgAdded{Version=[2],Text=[Each operation returns the outer product of a
3943 (column) vector Left by a (row) vector Right using the appropriate operation
3944 "*" in numerics.@!generic_complex_types for computing the individual components.
3945 The first and second index ranges of the result are Left'Range and
3946 Right'Range respectively.]}
3947
3948 @begin{Example}
3949 @ChgRef{Version=[2],Kind=[AddedNormal]}
3950 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left : Real_Vector;
3951 Right : Complex_Matrix) @key{return} Complex_Vector;
3952 @key{function} "*" (Left : Complex_Vector;
3953 Right : Real_Matrix) @key{return} Complex_Vector;]}
3954 @end{Example}
3955
3956 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3957 @ChgAdded{Version=[2],Text=[Each operation provides the standard mathematical
3958 operation for multiplication of a (row) vector Left by a matrix Right. The
3959 index range of the (row) vector result is Right'Range(2). Constraint_Error is
3960 raised if Left'Length is not equal to Right'Length(1). These operations involve
3961 inner products.]}
3962
3963 @begin{Example}
3964 @ChgRef{Version=[2],Kind=[AddedNormal]}
3965 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left : Real_Matrix;
3966 Right : Complex_Vector) @key{return} Complex_Vector;
3967 @key{function} "*" (Left : Complex_Matrix;
3968 Right : Real_Vector) @key{return} Complex_Vector;]}
3969 @end{Example}
3970
3971 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3972 @ChgAdded{Version=[2],Text=[Each operation provides the standard mathematical
3973 operation for multiplication of a matrix Left by a (column) vector Right. The
3974 index range of the (column) vector result is Left'Range(1). Constraint_Error is
3975 raised if Left'Length(2) is not equal to Right'Length. These operations involve
3976 inner products.]}
3977
3978 @begin{Example}
3979 @ChgRef{Version=[2],Kind=[AddedNormal]}
3980 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left : Complex; Right : Complex_Matrix) @key{return} Complex_Matrix;]}
3981 @end{Example}
3982
3983 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3984 @ChgAdded{Version=[2],Text=[This operation returns the result of multiplying
3985 each component of Right by the complex number Left using the appropriate
3986 operation "*" in numerics.@!generic_complex_types. The index ranges of the result
3987 are those of Right.]}
3988
3989 @begin{Example}
3990 @ChgRef{Version=[2],Kind=[AddedNormal]}
3991 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left : Complex_Matrix; Right : Complex) @key{return} Complex_Matrix;
3992 @key{function} "/" (Left : Complex_Matrix; Right : Complex) @key{return} Complex_Matrix;]}
3993 @end{Example}
3994
3995 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
3996 @ChgAdded{Version=[2],Text=[Each operation returns the result of applying the
3997 corresponding operation in numerics.@!generic_complex_types to each component of
3998 the matrix Left and the complex number Right. The index ranges of the result
3999 are those of Left.]}
4000
4001 @begin{Example}
4002 @ChgRef{Version=[2],Kind=[AddedNormal]}
4003 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left : Real'Base;
4004 Right : Complex_Matrix) @key{return} Complex_Matrix;]}
4005 @end{Example}
4006
4007 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
4008 @ChgAdded{Version=[2],Text=[This operation returns the result of multiplying
4009 each component of Right by the real number Left using the appropriate operation
4010 "*" in numerics.@!generic_complex_types. The index ranges of the result are those
4011 of Right.]}
4012
4013 @begin{Example}
4014 @ChgRef{Version=[2],Kind=[AddedNormal]}
4015 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} "*" (Left : Complex_Matrix;
4016 Right : Real'Base) @key{return} Complex_Matrix;
4017 @key{function} "/" (Left : Complex_Matrix;
4018 Right : Real'Base) @key{return} Complex_Matrix;]}
4019 @end{Example}
4020
4021 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
4022 @ChgAdded{Version=[2],Text=[Each operation returns the result of applying the
4023 corresponding operation in numerics.@!generic_complex_types to each component of
4024 the matrix Left and the real number Right. The index ranges of the result are
4025 those of Left.]}
4026
4027 @begin{Example}
4028 @ChgRef{Version=[2],Kind=[AddedNormal]}
4029 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Solve (A : Complex_Matrix; X : Complex_Vector) @key{return} Complex_Vector;]}
4030 @end{Example}
4031
4032 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
4033 @ChgAdded{Version=[2],Text=[This function returns a vector Y such that X is
4034 (nearly) equal to A * Y. This is the standard mathematical operation for
4035 solving a single set of linear equations. The index range of the result is
4036 A'Range(2). Constraint_Error is raised if A'Length(1), A'Length(2), and X'Length
4037 are not equal. Constraint_Error is raised if the matrix A is ill-conditioned.]}
4038
4039 @begin{Discussion}
4040 @ChgRef{Version=[2],Kind=[AddedNormal]}
4041 @ChgAdded{Version=[2],Text=[The text says that Y is such that @lquotes@;X is
4042 (nearly) equal to A * Y@rquotes rather than @lquotes@;X is equal to A *
4043 Y@rquotes because rounding errors may mean that there is no value of Y such
4044 that X is exactly equal to A * Y. On the other hand it does not mean that any
4045 old rough value will do. The algorithm given under @ImplAdviceTitle
4046 should be followed.]}
4047
4048 @ChgRef{Version=[2],Kind=[AddedNormal]}
4049 @ChgAdded{Version=[2],Text=[The requirement to raise Constraint_Error if the
4050 matrix is ill-conditioned is really a reflection of what will happen if the
4051 matrix is ill-conditioned. See @ImplAdviceTitle.
4052 We do not make any attempt to define ill-conditioned formally.]}
4053
4054 @ChgRef{Version=[2],Kind=[AddedNormal]}
4055 @ChgAdded{Version=[2],Text=[These remarks apply to all versions of Solve and
4056 Inverse.]}
4057 @end{Discussion}
4058
4059 @begin{Example}
4060 @ChgRef{Version=[2],Kind=[AddedNormal]}
4061 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Solve (A, X : Complex_Matrix) @key{return} Complex_Matrix;]}
4062 @end{Example}
4063
4064 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
4065 @ChgAdded{Version=[2],Text=[This function returns a matrix Y such that X is
4066 (nearly) equal to A * Y. This is the standard mathematical operation for
4067 solving several sets of linear equations. The index ranges of the result are
4068 A'Range(2) and X'Range(2). Constraint_Error is raised if A'Length(1), A'Length(2), and
4069 X'Length(1) are not equal. Constraint_Error is raised if the matrix A is
4070 ill-conditioned.]}
4071
4072 @begin{Example}
4073 @ChgRef{Version=[2],Kind=[AddedNormal]}
4074 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Inverse (A : Complex_Matrix) @key{return} Complex_Matrix;]}
4075 @end{Example}
4076
4077 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
4078 @ChgAdded{Version=[2],Text=[This function returns a matrix B such that A * B is
4079 (nearly) equal to the unit matrix. The index ranges of the result are A'Range(2)
4080 and A'Range(1). Constraint_Error is raised if A'Length(1) is not equal to
4081 A'Length(2). Constraint_Error is raised if the matrix A is ill-conditioned.]}
4082
4083 @begin{Example}
4084 @ChgRef{Version=[2],Kind=[AddedNormal]}
4085 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Determinant (A : Complex_Matrix) @key{return} Complex;]}
4086 @end{Example}
4087
4088 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
4089 @ChgAdded{Version=[2],Text=[This function returns the determinant of the matrix
4090 A. Constraint_Error is raised if A'Length(1) is not equal to A'Length(2).]}
4091
4092 @begin{Example}
4093 @ChgRef{Version=[2],Kind=[AddedNormal]}
4094 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Eigenvalues(A : Complex_Matrix) @key{return} Real_Vector;]}
4095 @end{Example}
4096
4097 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
4098 @ChgAdded{Version=[2],Text=[This function returns the eigenvalues of the
4099 Hermitian matrix A as a vector sorted into order with the largest first.
4100 Constraint_Error is raised if A'Length(1) is not equal to A'Length(2). The
4101 index range of the result is A'Range(1). Argument_Error is raised if the matrix
4102 A is not Hermitian.]}
4103
4104 @begin{Discussion}
4105 @ChgRef{Version=[2],Kind=[AddedNormal]}
4106 @ChgAdded{Version=[2],Text=[A Hermitian matrix is one whose transpose is
4107 equal to its complex conjugate. The eigenvalues of a Hermitian matrix are
4108 always real. We only support this case because algorithms for solving the
4109 general case are inherently unstable.]}
4110 @end{Discussion}
4111
4112
4113 @begin{Example}
4114 @ChgRef{Version=[2],Kind=[AddedNormal]}
4115 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{procedure} Eigensystem(A : @key{in} Complex_Matrix;
4116 Values : @key{out} Real_Vector;
4117 Vectors : @key{out} Complex_Matrix);]}
4118 @end{Example}
4119
4120 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
4121 @ChgAdded{Version=[2],Text=[This procedure computes both the eigenvalues and
4122 eigenvectors of the Hermitian matrix A. The out parameter Values is the same as
4123 that obtained by calling the function Eigenvalues. The out parameter Vectors is
4124 a matrix whose columns are the eigenvectors of the matrix A. The order of the
4125 columns corresponds to the order of the eigenvalues. The eigenvectors are
4126 mutually orthonormal, including when there are repeated eigenvalues.
4127 Constraint_Error is raised if A'Length(1) is not equal to A'Length(2). The
4128 index ranges of the parameter Vectors are those of A. Argument_Error is raised
4129 if the matrix A is not Hermitian.]}
4130
4131 @begin{Example}
4132 @ChgRef{Version=[2],Kind=[AddedNormal]}
4133 @ChgAdded{Version=[2],KeepNext=[T],Text=[@key{function} Unit_Matrix (Order : Positive;
4134 First_1, First_2 : Integer := 1)
4135 @key{return} Complex_Matrix;]}
4136 @end{Example}
4137
4138 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
4139 @ChgAdded{Version=[2],Text=[This function returns a square
4140 @i{unit matrix}@Defn2{Term=[unit matrix],Sec=[complex matrix]}
4141 with Order**2 components and
4142 lower bounds of First_1 and First_2 (for the first and second index ranges
4143 respectively). All components are set to (0.0, 0.0) except for the main diagonal,
4144 whose components are set to (1.0, 0.0). Constraint_Error is raised
4145 if First_1 + Order @en 1 > Integer'Last or First_2 + Order @en 1 > Integer'Last.]}
4146
4147 @end{DescribeCode}
4148
4149 @end{StaticSem}
4150
4151 @begin{ImplReq}
4152
4153 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
4154 @ChgAdded{Version=[2],Text=[Accuracy requirements for the subprograms Solve,
4155 Inverse, Determinant, Eigenvalues and Eigensystem are implementation defined.]}
4156 @ChgImplDef{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],Text=[The
4157 accuracy requirements for the subprograms Solve,
4158 Inverse, Determinant, Eigenvalues and Eigensystem for type Complex_Matrix.]}]}
4159
4160 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
4161 @ChgAdded{Version=[2],Text=[For operations not involving an inner product, the
4162 accuracy requirements are those of the corresponding operations of the type
4163 Real'Base and Complex in both the strict mode and the relaxed mode
4164 (see @RefSecNum{Numeric Performance Requirements}).]}
4165
4166 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
4167 @ChgAdded{Version=[2],Text=[For operations involving an inner product, no
4168 requirements are specified in the relaxed mode. In the strict mode the modulus
4169 of the absolute error of the inner product @i{X}*@i{Y} shall not exceed
4170 @i{g}*@key{abs}(@i{X})*@key{abs}(@i{Y}) where @i{g} is defined as]}
4171 @begin{Display}
4172 @ChgRef{Version=[2],Kind=[AddedNormal]}
4173 @ChgAdded{Version=[2],Text=[@i{g} = @i{X}'Length * Real'Machine_Radix**(1 @en@; Real'Model_Mantissa)
4174 for mixed complex and real operands]}
4175
4176 @ChgRef{Version=[2],Kind=[AddedNormal]}
4177 @ChgAdded{Version=[2],Text=[@i{g} = sqrt(2.0) * @i{X}'Length * Real'Machine_Radix**(1 @en@; Real'Model_Mantissa)
4178 for two complex operands]}
4179 @end{Display}
4180
4181 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00418-01]}
4182 @ChgAdded{Version=[2],Text=[For the L2-norm, no accuracy requirements are
4183 specified in the relaxed mode. In
4184 the strict mode the relative error on the norm shall not
4185 exceed @i<g> / 2.0 + 3.0 * Real'Model_Epsilon
4186 where @i<g> has the definition appropriate for two complex operands.]}
4187
4188
4189 @end{ImplReq}
4190
4191 @begin{DocReq}
4192
4193 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
4194 @ChgAdded{Version=[2],Text=[Implementations shall document any techniques used
4195 to reduce cancellation errors such as extended precision arithmetic.]}
4196 @ChgDocReq{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],Text=[Any
4197 techniques used to reduce cancellation errors in
4198 Numerics.Generic_Complex_Arrays shall be documented.]}]}
4199 @begin{ImplNote}
4200 @ChgRef{Version=[2],Kind=[AddedNormal]}
4201 @ChgAdded{Version=[2],Text=[The above accuracy requirement is met by the
4202 canonical implementation of the
4203 inner product by multiplication and addition using the corresponding
4204 operations of type Complex and performing the cumulative addition using
4205 ascending indices. Note however, that some hardware provides special
4206 operations for the computation of the inner product and although these may be
4207 fast they may not meet the accuracy requirement specified. See Accuracy and
4208 Stability of Numerical Algorithms by N J Higham (ISBN 0-89871-355-2),
4209 Sections 3.1 and 3.6.]}
4210 @end{ImplNote}
4211 @end{DocReq}
4212
4213 @begin{ImplPerm}
4214
4215 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
4216 @ChgAdded{Version=[2],Text=[The nongeneric equivalent packages may, but need
4217 not, be actual instantiations of the generic package for the appropriate
4218 predefined type.]}
4219
4220 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
4221 @ChgAdded{Version=[2],Text=[Although many operations are defined in terms of
4222 operations from numerics.@!generic_complex_types, they need not be implemented by
4223 calling those operations provided that the effect is the same.]}
4224 @end{ImplPerm}
4225
4226 @begin{ImplAdvice}
4227
4228 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
4229 @ChgAdded{Version=[2],Text=[Implementations should implement the Solve and
4230 Inverse functions using established techniques. Implementations are recommended
4231 to refine the result by performing an iteration on the residuals; if this is
4232 done then it should be documented.]}
4233 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
4234 Text=[Solve and Inverse for Numerics.Generic_Complex_Arrays should be
4235 implemented using established techniques and the result should be refined
4236 by an iteration on the residuals.]}]}
4237
4238 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
4239 @ChgAdded{Version=[2],Text=[It is not the intention that any special provision
4240 should be made to determine whether a matrix is ill-conditioned or not. The
4241 naturally occurring overflow (including division by zero) which will result
4242 from executing these functions with an ill-conditioned matrix and thus raise
4243 Constraint_Error is sufficient.]}
4244 @begin{Discussion}
4245 @ChgRef{Version=[2],Kind=[AddedNormal]}
4246 @ChgAdded{Version=[2],Text=[There isn't any advice for the implementation to
4247 document with this paragraph.]}
4248 @end{Discussion}
4249
4250 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
4251 @ChgAdded{Version=[2],Text=[The test that a matrix is Hermitian should use the
4252 equality operator to compare the real components and negation followed by
4253 equality to compare the imaginary components
4254 (see @RefSecNum{Model of Floating Point Arithmetic}).]}
4255 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
4256 Text=[The equality and negation operators should be used to test that a matrix is
4257 Hermitian.]}]}
4258
4259 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
4260 @ChgAdded{Version=[2],Text=[Implementations should not perform operations on
4261 mixed complex and real operands by first converting the real operand to
4262 complex. See @RefSecNum{Complex Types}.]}
4263 @ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2],
4264 Text=[Mixed real and complex operations should not be performed by converting
4265 the real operand to complex.]}]}
4266
4267 @end{ImplAdvice}
4268
4269
4270 @begin{Extend95}
4271 @ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00296-01]}
4272 @ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95}
4273 The package Numerics.Generic_Complex_Arrays and its nongeneric equivalents
4274 are new.@Comment{ It would be better if this was called
4275 "Ada.Numerics.Generic_Imitation_Arrays", 'cause that's the opposite of Real. :-)
4276 Just checking if anyone reads this stuff.}]}
4277 @end{Extend95}
4278
4279