Debian Codegraph @

source_2020/numerics.mss

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