NAME
cplx.intro complex - introduction to C++ complex number math
library
SYNOPSIS
#include <complex.h>
class complex {
public:
complex(double real, double imag= 0.0);
complex();
... // remainder not shown here
};
#include <iostream.h>
ostream& operator<< (ostream&, const complex&);
istream& operator>> (istream&, complex&);
DESCRIPTION
This implementation of a complex number class and library is
based on the complex math library supplied by USL. Code
written for use with the USL library should work the same
way with this implementation.
Class complex, whose definition is found in header file
<complex.h>, uses a typical Cartesian coordinate implementa-
tion of mathematical complex numbers. The class includes:
o functions to convert between polar and Cartesian coordi-
nates. See cartpol(3C++).
o overloaded versions of the arithmetic operations, some of
which are optimized for combining real and complex opera-
tions. See cplxops(3C++).
o overloaded versions of the usual trigonometric functions.
See cplxtrig(3C++).
o overloaded versions of the usual exponential and logarithm
functions. See cplxexp(3C++).
o error handling which may be overridden by the user. See
cplxerr(3C++).
o functions to read and write complex numbers via iostreams.
See ios.intro(3C++).
Constructors
complex()
Creates a complex number initialized to (0.0, 0.0).
complex(x, y)
Creates a complex number initialized to (x, y), where x
and y have numerical types. Argument y may be omitted,
in which case its value is taken as 0.
Input/Output
The library provides default input and output routines for
complex. Either or both of these may be replaced by the
programmer by writing functions with the same signatures.
The default versions are described here.
input_stream >> x
Expects the representation of a complex number to have
the form
( real , imag )
where and are integral or floating-point numbers in
standard C++ format. Any amount of whitespace may
preceed or follow the parentheses and comma. If the
first non-whitespace character is not `(', that charac-
ter will be replaced in the stream and there will be
nothing further extracted. Otherwise, if the value is
not well-formed, extraction from the stream will stop
as soon as this is determined, and the stream will be
put into a "failed" state. (See the iostream documen-
tation.) In either case, or if there is any other
error condition, complex variable x will get the value
(0,0). If the input is in the proper form, x will get
the represented complex value.
output_stream << x
Writes the value of complex x to the output stream in
the form expected by the input function as noted above.
SEE ALSO
cartpol(3C++), cplxerr(3C++), cplxexp(3C++), cplxops(3C++),
cplxtrig(3C++), ios.intro(3C++). intro(2), ieee_values(3),
perror(3), Complex Tutorial
DIAGNOSTICS
In general, one of the values (0, 0), (0, _HUGE_VAL),
(_HUGE_VAL, 0), or (_HUGE_VAL, _HUGE_VAL) will be returned
when a result is too large or is mathematically undefined.
HUGE_VAL is defined in the header <math.h>, which is
included by <complex.h>, and in this implementation has the
value corresponding to infinity. See ieee_values(3). When
such an error condition occurs, external variable errno is
set to EDOM or ERANGE. See perror(3), intro(2).
|
Закладки на сайте Проследить за страницей |
Created 1996-2025 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |