1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526
  
     | 
    
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
    <TITLE>AARM95 - Complex Types</TITLE>
    <META NAME="Author" CONTENT="JTC1/SC22/WG9/ARG, by Randall Brukardt, ARG Editor">
    <META NAME="GENERATOR" CONTENT="Arm_Form.Exe, Ada Reference Manual generator">
    <STYLE type="text/css">
    DIV.paranum {position: absolute; font-family: Arial, Helvetica, sans-serif; left: 0.5 em; top: auto}
    TT {font-family: "Courier New", monospace}
    DT {display: compact}
    DIV.Normal {font-family: "Times New Roman", Times, serif; margin-bottom: 0.6em}
    DIV.Wide {font-family: "Times New Roman", Times, serif; margin-top: 0.6em; margin-bottom: 0.6em}
    DIV.Annotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
    DIV.WideAnnotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0.6em; margin-bottom: 0.6em}
    DIV.Index {font-family: "Times New Roman", Times, serif}
    DIV.SyntaxSummary {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
    DIV.Notes {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.6em}
    DIV.NotesHeader {font-family: "Times New Roman", Times, serif; margin-left: 2.0em}
    DIV.SyntaxIndented {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
    DIV.Indented {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-bottom: 0.6em}
    DIV.CodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
    DIV.SmallIndented {font-family: "Times New Roman", Times, serif; margin-left:  10.0em; margin-bottom: 0.6em}
    DIV.SmallCodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-bottom: 0.6em}
    DIV.Examples {font-family: "Courier New", monospace; margin-left: 2.0em; margin-bottom: 0.6em}
    DIV.SmallExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 7.5em; margin-bottom: 0.6em}
    DIV.IndentedExamples {font-family: "Courier New", monospace; margin-left: 8.0em; margin-bottom: 0.6em}
    DIV.SmallIndentedExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left:  15.0em; margin-bottom: 0.6em}
    UL.Bulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.SmallBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.NestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.SmallNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.IndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.CodeIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.CodeIndentedNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.SyntaxIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.NotesBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.NotesNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
    DL.Hanging {font-family: "Times New Roman", Times, serif; margin-top: 0em; margin-bottom: 0.6em}
    DD.Hanging {margin-left: 6.0em}
    DL.IndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
    DD.IndentedHanging {margin-left: 2.0em}
    DL.HangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
    DD.HangingInBulleted {margin-left: 4.0em}
    DL.SmallHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
    DD.SmallHanging {margin-left: 7.5em}
    DL.SmallIndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-top: 0em; margin-bottom: 0.6em}
    DD.SmallIndentedHanging {margin-left: 2.0em}
    DL.SmallHangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
    DD.SmallHangingInBulleted {margin-left: 5.0em}
    DL.Enumerated {font-family: "Times New Roman", Times, serif; margin-right: 0.0em; margin-top: 0em; margin-bottom: 0.5em}
    DD.Enumerated {margin-left: 2.0em}
    DL.SmallEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
    DD.SmallEnumerated {margin-left: 2.5em}
    DL.NestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
    DL.SmallNestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
    </STYLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFF0" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<P><A HREF="AA-TOC.html">Contents</A>   <A HREF="AA-0-29.html">Index</A>   <A HREF="AA-G-1.html">Previous</A>   <A HREF="AA-G-1-2.html">Next</A></P>
<HR>
<H1> G.1.1 Complex Types</H1>
<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em">   The generic library
package Numerics.Generic_Complex_Types has the following declaration:
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>2/1</FONT></DIV>
<DIV Class="Examples"><TT>{<I><A HREF="defect1.html#8652/0020">8652/0020</A></I>}
<BR>
<B>generic</B><A NAME="I7123"></A><A NAME="I7124"></A><A NAME="I7125"></A><BR>
   <B>type</B> Real <B>is</B> <B>digits</B> <>;<BR>
<B>package</B> Ada.Numerics.Generic_Complex_Types <B>is</B><BR>
   <U><B>pragma</B></U><S>pragma</S> Pure(Generic_Complex_Types);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="Examples"><TT>   <B>type</B> <A NAME="I7126"></A><A NAME="I7127"></A>Complex <B>is</B><BR>
      <B>record</B><BR>
         Re, Im : Real'Base;<BR>
      <B>end</B> <B>record</B>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="Examples"><TT>   <B>type</B> <A NAME="I7128"></A><A NAME="I7129"></A>Imaginary <B>is</B> <B>private</B>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="Examples"><TT>   <A NAME="I7130"></A>i : <B>constant</B> Imaginary;<BR>
   <A NAME="I7131"></A>j : <B>constant</B> Imaginary;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="Examples"><TT>   <B>function</B> <A NAME="I7132"></A><A NAME="I7133"></A>Re (X : Complex)   <B>return</B> Real'Base;<BR>
   <B>function</B> <A NAME="I7134"></A><A NAME="I7135"></A>Im (X : Complex)   <B>return</B> Real'Base;<BR>
   <B>function</B> <A NAME="I7136"></A><A NAME="I7137"></A>Im (X : Imaginary) <B>return</B> Real'Base;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="Examples"><TT>   <B>procedure</B> <A NAME="I7138"></A><A NAME="I7139"></A>Set_Re (X  : <B>in</B> <B>out</B> Complex;<BR>
                     Re : <B>in</B>     Real'Base);<BR>
   <B>procedure</B> <A NAME="I7140"></A><A NAME="I7141"></A>Set_Im (X  : <B>in</B> <B>out</B> Complex;<BR>
                     Im : <B>in</B>     Real'Base);<BR>
   <B>procedure</B> <A NAME="I7142"></A><A NAME="I7143"></A>Set_Im (X  :    <B>out</B> Imaginary;<BR>
                     Im : <B>in</B>     Real'Base);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Examples"><TT>   <B>function</B> <A NAME="I7144"></A><A NAME="I7145"></A>Compose_From_Cartesian (Re, Im : Real'Base) <B>return</B> Complex;<BR>
   <B>function</B> <A NAME="I7146"></A><A NAME="I7147"></A>Compose_From_Cartesian (Re     : Real'Base) <B>return</B> Complex;<BR>
   <B>function</B> <A NAME="I7148"></A><A NAME="I7149"></A>Compose_From_Cartesian (Im     : Imaginary) <B>return</B> Complex;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Examples"><TT>   <B>function</B> <A NAME="I7150"></A><A NAME="I7151"></A>Modulus (X     : Complex) <B>return</B> Real'Base;<BR>
   <B>function</B> "<B>abs</B>"   (Right : Complex) <B>return</B> Real'Base <B>renames</B> Modulus;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Examples"><TT>   <B>function</B> <A NAME="I7152"></A><A NAME="I7153"></A>Argument (X     : Complex)   <B>return</B> Real'Base;<BR>
   <B>function</B> <A NAME="I7154"></A><A NAME="I7155"></A>Argument (X     : Complex;<BR>
                      Cycle : Real'Base) <B>return</B> Real'Base;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<DIV Class="Examples"><TT>   <B>function</B> <A NAME="I7156"></A><A NAME="I7157"></A>Compose_From_Polar (Modulus, Argument        : Real'Base)<BR>
      <B>return</B> Complex;<BR>
   <B>function</B> <A NAME="I7158"></A><A NAME="I7159"></A>Compose_From_Polar (Modulus, Argument, Cycle : Real'Base)<BR>
      <B>return</B> Complex;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="Examples"><TT>   <B>function</B> "+"       (Right : Complex) <B>return</B> Complex;<BR>
   <B>function</B> "-"       (Right : Complex) <B>return</B> Complex;<BR>
   <B>function</B> <A NAME="I7160"></A><A NAME="I7161"></A>Conjugate (X     : Complex) <B>return</B> Complex;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<DIV Class="Examples"><TT>   <B>function</B> "+" (Left, Right : Complex) <B>return</B> Complex;<BR>
   <B>function</B> "-" (Left, Right : Complex) <B>return</B> Complex;<BR>
   <B>function</B> "*" (Left, Right : Complex) <B>return</B> Complex;<BR>
   <B>function</B> "/" (Left, Right : Complex) <B>return</B> Complex;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<DIV Class="Examples"><TT>   <B>function</B> "**" (Left : Complex; Right : Integer) <B>return</B> Complex;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<DIV Class="Examples"><TT>   <B>function</B> "+"       (Right : Imaginary) <B>return</B> Imaginary;<BR>
   <B>function</B> "-"       (Right : Imaginary) <B>return</B> Imaginary;<BR>
   <B>function</B> <A NAME="I7162"></A><A NAME="I7163"></A>Conjugate (X     : Imaginary) <B>return</B> Imaginary <B>renames</B> "-";<BR>
   <B>function</B> "<B>abs</B>"     (Right : Imaginary) <B>return</B> Real'Base;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<DIV Class="Examples"><TT>   <B>function</B> "+" (Left, Right : Imaginary) <B>return</B> Imaginary;<BR>
   <B>function</B> "-" (Left, Right : Imaginary) <B>return</B> Imaginary;<BR>
   <B>function</B> "*" (Left, Right : Imaginary) <B>return</B> Real'Base;<BR>
   <B>function</B> "/" (Left, Right : Imaginary) <B>return</B> Real'Base;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<DIV Class="Examples"><TT>   <B>function</B> "**" (Left : Imaginary; Right : Integer) <B>return</B> Complex;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18</FONT></DIV>
<DIV Class="Examples"><TT>   <B>function</B> "<"  (Left, Right : Imaginary) <B>return</B> Boolean;<BR>
   <B>function</B> "<=" (Left, Right : Imaginary) <B>return</B> Boolean;<BR>
   <B>function</B> ">"  (Left, Right : Imaginary) <B>return</B> Boolean;<BR>
   <B>function</B> ">=" (Left, Right : Imaginary) <B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<DIV Class="Examples"><TT>   <B>function</B> "+" (Left : Complex;   Right : Real'Base) <B>return</B> Complex;<BR>
   <B>function</B> "+" (Left : Real'Base; Right : Complex)   <B>return</B> Complex;<BR>
   <B>function</B> "-" (Left : Complex;   Right : Real'Base) <B>return</B> Complex;<BR>
   <B>function</B> "-" (Left : Real'Base; Right : Complex)   <B>return</B> Complex;<BR>
   <B>function</B> "*" (Left : Complex;   Right : Real'Base) <B>return</B> Complex;<BR>
   <B>function</B> "*" (Left : Real'Base; Right : Complex)   <B>return</B> Complex;<BR>
   <B>function</B> "/" (Left : Complex;   Right : Real'Base) <B>return</B> Complex;<BR>
   <B>function</B> "/" (Left : Real'Base; Right : Complex)   <B>return</B> Complex;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20</FONT></DIV>
<DIV Class="Examples"><TT>   <B>function</B> "+" (Left : Complex;   Right : Imaginary) <B>return</B> Complex;<BR>
   <B>function</B> "+" (Left : Imaginary; Right : Complex)   <B>return</B> Complex;<BR>
   <B>function</B> "-" (Left : Complex;   Right : Imaginary) <B>return</B> Complex;<BR>
   <B>function</B> "-" (Left : Imaginary; Right : Complex)   <B>return</B> Complex;<BR>
   <B>function</B> "*" (Left : Complex;   Right : Imaginary) <B>return</B> Complex;<BR>
   <B>function</B> "*" (Left : Imaginary; Right : Complex)   <B>return</B> Complex;<BR>
   <B>function</B> "/" (Left : Complex;   Right : Imaginary) <B>return</B> Complex;<BR>
   <B>function</B> "/" (Left : Imaginary; Right : Complex)   <B>return</B> Complex;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>21</FONT></DIV>
<DIV Class="Examples"><TT>   <B>function</B> "+" (Left : Imaginary; Right : Real'Base) <B>return</B> Complex;<BR>
   <B>function</B> "+" (Left : Real'Base; Right : Imaginary) <B>return</B> Complex;<BR>
   <B>function</B> "-" (Left : Imaginary; Right : Real'Base) <B>return</B> Complex;<BR>
   <B>function</B> "-" (Left : Real'Base; Right : Imaginary) <B>return</B> Complex;<BR>
   <B>function</B> "*" (Left : Imaginary; Right : Real'Base) <B>return</B> Imaginary;<BR>
   <B>function</B> "*" (Left : Real'Base; Right : Imaginary) <B>return</B> Imaginary;<BR>
   <B>function</B> "/" (Left : Imaginary; Right : Real'Base) <B>return</B> Imaginary;<BR>
   <B>function</B> "/" (Left : Real'Base; Right : Imaginary) <B>return</B> Imaginary;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>22</FONT></DIV>
<DIV Class="Examples"><TT><B>private</B></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23</FONT></DIV>
<DIV Class="Examples"><TT>   <B>type</B> Imaginary <B>is</B> <B>new</B> Real'Base;<BR>
   i : <B>constant</B> Imaginary := 1.0;<BR>
   j : <B>constant</B> Imaginary := 1.0;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>24</FONT></DIV>
<DIV Class="Examples"><TT><B>end</B> Ada.Numerics.Generic_Complex_Types;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>25/1</FONT></DIV>
<DIV Class="Normal">      {<I><A HREF="defect1.html#8652/0020">8652/0020</A></I>}
<A NAME="I7164"></A><A NAME="I7165"></A><A NAME="I7166"></A><A NAME="I7167"></A>The
library package Numerics.Complex_Types <U>is declared pure and </U>defines
the same types, constants, and subprograms as Numerics.Generic_Complex_Types,
except that the predefined type Float is systematically substituted for
Real'Base throughout. Nongeneric equivalents of Numerics.Generic_Complex_Types
for each of the other predefined floating point types are defined similarly,
with the names Numerics.Short_Complex_Types, Numerics.Long_Complex_Types,
etc. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>25.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>The nongeneric
equivalents are provided to allow the programmer to construct simple
mathematical applications without being required to understand and use
generics. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>25.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>The nongeneric
equivalents all export the types Complex and Imaginary and the constants
i and j (rather than uniquely named types and constants, such as Short_Complex,
Long_Complex, etc.) to preserve their equivalence to actual instantiations
of the generic package and to allow the programmer to change the precision
of an application globally by changing a single context clause. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26</FONT></DIV>
<DIV Class="Normal">    [Complex is a visible type with cartesian components.]
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>The cartesian representation
is far more common than the polar representation, in practice. The accuracy
of the results of the complex arithmetic operations and of the complex
elementary functions is dependent on the representation; thus, implementers
need to know that representation. The type is visible so that complex
``literals'' can be written in aggregate notation, if desired. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>27</FONT></DIV>
<DIV Class="Normal">    [Imaginary is a private type; its full type is
derived from Real'Base.] </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>27.a</FONT></DIV>
<DIV Class="Annotations" Style="margin-bottom: 0.4em"><FONT SIZE=-1><B>Reason:
</B>The Imaginary type and the constants i and j are provided for two
reasons: </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>27.b</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1><LI TYPE=DISC>They allow complex ``literals'' to be written in the alternate
form of <I>a</I> + <I>b</I>*i (or <I>a</I> + <I>b</I>*j), if desired.
Of course, in some contexts the sum will need to be parenthesized.</LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>27.c</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1><LI TYPE=DISC>When an Ada binding to IEC 559:1989 that provides (signed)
infinities as the result of operations that overflow becomes available,
it will be important to allow arithmetic between pure-imaginary and complex
operands without requiring the former to be represented as (or promoted
to) complex values with a real component of zero. For example, the multiplication
of <I>a</I> + <I>b</I>*i by <I>d</I>*i should yield -<I>b</I>·
<I>d</I> + <I>a</I>· <I>d</I>*i, but if one cannot avoid representing
the pure-imaginary value <I>d</I>*i as the complex value 0.0 + <I>d</I>*i,
then a NaN ("Not-a-Number") could be produced as the result
of multiplying <I>a</I> by 0.0 (e.g., when <I>a</I> is infinite); the
NaN could later trigger an exception. Providing the Imaginary type and
overloadings of the arithmetic operators for mixtures of Imaginary and
Complex operands gives the programmer the same control over avoiding
premature coercion of pure-imaginary values to complex as is already
provided for pure-real values. </LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>27.d</FONT></DIV>
<DIV Class="Annotations" Style="margin-bottom: 0.4em"><FONT SIZE=-1><B>Reason:
</B>The Imaginary type is private, rather than being visibly derived
from Real'Base, for two reasons: </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>27.e</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1><LI TYPE=DISC>to preclude implicit conversions of real literals to the
Imaginary type (such implicit conversions would make many common arithmetic
expressions ambiguous); and</LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>27.f</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1><LI TYPE=DISC>to suppress the implicit derivation of the multiplication,
division, and absolute value operators with Imaginary operands and an
Imaginary result (the result type would be incorrect). </LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>27.g</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>The base subtype
Real'Base is used for the component type of Complex, the parent type
of Imaginary, and the parameter and result types of some of the subprograms
to maximize the chances of being able to pass meaningful values into
the subprograms and receive meaningful results back. The generic formal
parameter Real therefore plays only one role, that of providing the precision
to be maintained in complex arithmetic calculations. Thus, the subprograms
in Numerics.Generic_Complex_Types share with those in Numerics.Generic_Elementary_Functions,
and indeed even with the predefined arithmetic operations (see <A HREF="AA-4-5.html">4.5</A>),
the property of being free of range checks on input and output, i.e.,
of being able to exploit the base range of the relevant floating point
type fully. As a result, the user loses the ability to impose application-oriented
bounds on the range of values that the components of a complex variable
can acquire; however, it can be argued that few, if any, applications
have a naturally square domain (as opposed to a circular domain) anyway.
</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>28</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em">    The arithmetic
operations and the Re, Im, Modulus, Argument, and Conjugate functions
have their usual mathematical meanings. When applied to a parameter of
pure-imaginary type, the ``imaginary-part'' function Im yields the value
of its parameter, as the corresponding real value. The remaining subprograms
have the following meanings: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>28.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>The middle case
can be understood by considering the parameter of pure-imaginary type
to represent a complex value with a zero real part. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>29</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>The Set_Re and Set_Im procedures replace the designated
component of a complex parameter with the given real value; applied to
a parameter of pure-imaginary type, the Set_Im procedure replaces the
value of that parameter with the imaginary value corresponding to the
given real value.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>30</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>The Compose_From_Cartesian function constructs a complex
value from the given real and imaginary components. If only one component
is given, the other component is implicitly zero.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>31</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>The Compose_From_Polar function constructs a complex value
from the given modulus (radius) and argument (angle). When the value
of the parameter Modulus is positive (resp., negative), the result is
the complex value represented by the point in the complex plane lying
at a distance from the origin given by the absolute value of Modulus
and forming an angle measured counterclockwise from the positive (resp.,
negative) real axis given by the value of the parameter Argument. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>32</FONT></DIV>
<DIV Class="Normal">    When the Cycle parameter is specified, the result
of the Argument function and the parameter Argument of the Compose_From_Polar
function are measured in units such that a full cycle of revolution has
the given value; otherwise, they are measured in radians.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>33</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em">    The computed results
of the mathematically multivalued functions are rendered single-valued
by the following conventions, which are meant to imply the principal
branch: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>34</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>The result of the Modulus function is nonnegative.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>35</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>The result of the Argument function is in the quadrant
containing the point in the complex plane represented by the parameter
X. This may be any quadrant (I through IV); thus, the range of the Argument
function is approximately -PI to PI (-Cycle/2.0 to Cycle/2.0, if the
parameter Cycle is specified). When the point represented by the parameter
X lies on the negative real axis, the result approximates </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>36</FONT></DIV>
<UL Class="NestedBulleted"><LI TYPE=DISC>PI (resp., -PI) when the sign of the imaginary component
of X is positive (resp., negative), if Real'Signed_Zeros is True;</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>37</FONT></DIV>
<UL Class="NestedBulleted"><LI TYPE=DISC>PI, if Real'Signed_Zeros is False. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>38</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>Because a result lying on or near one of the axes may not
be exactly representable, the approximation inherent in computing the
result may place it in an adjacent quadrant, close to but on the wrong
side of the axis. </LI></UL>
<H4 ALIGN=CENTER>Dynamic Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>39</FONT></DIV>
<DIV Class="Normal">    The exception Numerics.Argument_Error is raised
by the Argument and Compose_From_Polar functions with specified cycle,
signaling a parameter value outside the domain of the corresponding mathematical
function, when the value of the parameter Cycle is zero or negative.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>40</FONT></DIV>
<DIV Class="Normal">    <A NAME="I7168"></A><A NAME="I7169"></A><A NAME="I7170"></A>The
exception Constraint_Error is raised by the division operator when the
value of the right operand is zero, and by the exponentiation operator
when the value of the left operand is zero and the value of the exponent
is negative, provided that Real'Machine_Overflows is True; when Real'Machine_Overflows
is False, the result is unspecified. <A NAME="I7171"></A>[Constraint_Error
can also be raised when a finite result overflows (see <A HREF="AA-G-2-6.html">G.2.6</A>).]
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>40.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>It is anticipated
that an Ada binding to IEC 559:1989 will be developed in the future.
As part of such a binding, the Machine_Overflows attribute of a conformant
floating point type will be specified to yield False, which will permit
implementations of the complex arithmetic operations to deliver results
with an infinite component (and set the overflow flag defined by the
binding) instead of raising Constraint_Error in overflow situations,
when traps are disabled. Similarly, it is appropriate for the complex
arithmetic operations to deliver results with infinite components (and
set the zero-divide flag defined by the binding) instead of raising Constraint_Error
in the situations defined above, when traps are disabled. Finally, such
a binding should also specify the behavior of the complex arithmetic
operations, when sensible, given operands with infinite components. </FONT></DIV>
<H4 ALIGN=CENTER>Implementation Requirements</H4>
<DIV Class="Paranum"><FONT SIZE=-2>41</FONT></DIV>
<DIV Class="Normal">    In the implementation of Numerics.Generic_Complex_Types,
the range of intermediate values allowed during the calculation of a
final result shall not be affected by any range constraint of the subtype
Real. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>41.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation Note: </B>Implementations
of Numerics.Generic_Complex_Types written in Ada should therefore avoid
declaring local variables of subtype Real; the subtype Real'Base should
be used instead. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>42</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em">    <A NAME="I7172"></A>In
the following cases, evaluation of a complex arithmetic operation shall
yield the <I>prescribed result</I>, provided that the preceding rules
do not call for an exception to be raised: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>43</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>The results of the Re, Im, and Compose_From_Cartesian functions
are exact.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>44</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>The real (resp., imaginary) component of the result of
a binary addition operator that yields a result of complex type is exact
when either of its operands is of pure-imaginary (resp., real) type.
</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>44.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>The result
of the addition operator is exact when one of its operands is of real
type and the other is of pure-imaginary type. In this particular case,
the operator is analogous to the Compose_From_Cartesian function; it
performs no arithmetic. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>45</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>The real (resp., imaginary) component of the result of
a binary subtraction operator that yields a result of complex type is
exact when its right operand is of pure-imaginary (resp., real) type.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>46</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>The real component of the result of the Conjugate function
for the complex type is exact.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>47</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>When the point in the complex plane represented by the
parameter X lies on the nonnegative real axis, the Argument function
yields a result of zero. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>47.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>Argument(X
+ i*Y) is analogous to <I>EF</I>.Arctan(Y, X), where <I>EF</I> is an
appropriate instance of Numerics.Generic_Elementary_Functions, except
when X and Y are both zero, in which case the former yields the value
zero while the latter raises Numerics.Argument_Error. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>48</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>When the value of the parameter Modulus is zero, the Compose_From_Polar
function yields a result of zero.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>49</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>When the value of the parameter Argument is equal to a
multiple of the quarter cycle, the result of the Compose_From_Polar function
with specified cycle lies on one of the axes. In this case, one of its
components is zero, and the other has the magnitude of the parameter
Modulus.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>50</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>Exponentiation by a zero exponent yields the value one.
Exponentiation by a unit exponent yields the value of the left operand.
Exponentiation of the value one yields the value one. Exponentiation
of the value zero yields the value zero, provided that the exponent is
nonzero. When the left operand is of pure-imaginary type, one component
of the result of the exponentiation operator is zero. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>51</FONT></DIV>
<DIV Class="Normal">    When the result, or a result component, of any
operator of Numerics.Generic_Complex_Types has a mathematical definition
in terms of a single arithmetic or relational operation, that result
or result component exhibits the accuracy of the corresponding operation
of the type Real.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>52</FONT></DIV>
<DIV Class="Normal">    Other accuracy requirements for the Modulus,
Argument, and Compose_From_Polar functions, and accuracy requirements
for the multiplication of a pair of complex operands or for division
by a complex operand, all of which apply only in the strict mode, are
given in <A HREF="AA-G-2-6.html">G.2.6</A>.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>53</FONT></DIV>
<DIV Class="Normal">    The sign of a zero result or zero result component
yielded by a complex arithmetic operation or function is implementation
defined when Real'Signed_Zeros is True. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>53.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation defined: </B>The
sign of a zero result (or a component thereof) from any operator or function
in Numerics.Generic_Complex_Types, when Real'Signed_Zeros is True.</FONT></DIV>
<H4 ALIGN=CENTER>Implementation Permissions</H4>
<DIV Class="Paranum"><FONT SIZE=-2>54</FONT></DIV>
<DIV Class="Normal">    The nongeneric equivalent packages may, but need
not, be actual instantiations of the generic package for the appropriate
predefined type.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>55/1</FONT></DIV>
<DIV Class="Normal">      {<I><A HREF="defect1.html#8652/0091">8652/0091</A></I>}
Implementations may obtain the result of exponentiation of a complex
or pure-imaginary operand by repeated complex multiplication, with arbitrary
association of the factors and with a possible final complex reciprocation
(when the exponent is negative). Implementations are also permitted to
obtain the result of exponentiation of a complex operand, but not of
a pure-imaginary operand, by converting the left operand to a polar representation;
exponentiating the modulus by the given exponent; multiplying the argument
by the given exponent<S>, when the exponent is positive, or dividing
the argument by the absolute value of the given exponent, when the exponent
is negative</S>; and reconverting to a cartesian representation. Because
of this implementation freedom, no accuracy requirement is imposed on
complex exponentiation (except for the prescribed results given above,
which apply regardless of the implementation method chosen). </DIV>
<H4 ALIGN=CENTER>Implementation Advice</H4>
<DIV Class="Paranum"><FONT SIZE=-2>56</FONT></DIV>
<DIV Class="Normal">    Because the usual mathematical meaning of multiplication
of a complex operand and a real operand is that of the scaling of both
components of the former by the latter, an implementation should not
perform this operation by first promoting the real operand to complex
type and then performing a full complex multiplication. In systems that,
in the future, support an Ada binding to IEC 559:1989, the latter technique
will not generate the required result when one of the components of the
complex operand is infinite. (Explicit multiplication of the infinite
component by the zero component obtained during promotion yields a NaN
that propagates into the final result.) Analogous advice applies in the
case of multiplication of a complex operand and a pure-imaginary operand,
and in the case of division of a complex operand by a real or pure-imaginary
operand.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>57</FONT></DIV>
<DIV Class="Normal">    Likewise, because the usual mathematical meaning
of addition of a complex operand and a real operand is that the imaginary
operand remains unchanged, an implementation should not perform this
operation by first promoting the real operand to complex type and then
performing a full complex addition. In implementations in which the Signed_Zeros
attribute of the component type is True (and which therefore conform
to IEC 559:1989 in regard to the handling of the sign of zero in predefined
arithmetic operations), the latter technique will not generate the required
result when the imaginary component of the complex operand is a negatively
signed zero. (Explicit addition of the negative zero to the zero obtained
during promotion yields a positive zero.) Analogous advice applies in
the case of addition of a complex operand and a pure-imaginary operand,
and in the case of subtraction of a complex operand and a real or pure-imaginary
operand.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>58</FONT></DIV>
<DIV Class="Normal">    Implementations in which Real'Signed_Zeros is
True should attempt to provide a rational treatment of the signs of zero
results and result components. As one example, the result of the Argument
function should have the sign of the imaginary component of the parameter
X when the point represented by that parameter lies on the positive real
axis; as another, the sign of the imaginary component of the Compose_From_Polar
function should be the same as (resp., the opposite of) that of the Argument
parameter when that parameter has a value of zero and the Modulus parameter
has a nonnegative (resp., negative) value. </DIV>
<H4 ALIGN=CENTER>Wording Changes from Ada 83</H4>
<DIV Class="Paranum"><FONT SIZE=-2>58.a</FONT></DIV>
<DIV Class="Annotations" Style="margin-bottom: 0.4em"><FONT SIZE=-1>The
semantics of Numerics.Generic_Complex_Types differs from Generic_Complex_Types
as defined in ISO/IEC CD 13813 (for Ada 83) in the following ways: </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>58.b</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1><LI TYPE=DISC>The generic package is a child of the package defining
the Argument_Error exception.</LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>58.c</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1><LI TYPE=DISC>The nongeneric equivalents export types and constants with
the same names as those exported by the generic package, rather than
with names unique to the package.</LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>58.d</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1><LI TYPE=DISC>Implementations are not allowed to impose an optional restriction
that the generic actual parameter associated with Real be unconstrained.
(In view of the ability to declare variables of subtype Real'Base in
implementations of Numerics.Generic_Complex_Types, this flexibility is
no longer needed.)</LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>58.e</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1><LI TYPE=DISC>The dependence of the Argument function on the sign of
a zero parameter component is tied to the value of Real'Signed_Zeros.</LI></FONT></UL>
<DIV Class="Paranum"><FONT SIZE=-2>58.f</FONT></DIV>
<UL Class="SmallBulleted"><FONT SIZE=-1><LI TYPE=DISC>Conformance to accuracy requirements is conditional. </LI></FONT></UL>
<HR>
<P><A HREF="AA-TOC.html">Contents</A>   <A HREF="AA-0-29.html">Index</A>   <A HREF="AA-G-1.html">Previous</A>   <A HREF="AA-G-1-2.html">Next</A>   <A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>
 
     |