A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/complex/complex/ below:

class template

<complex>

std::complex
template <class T> class complex;

Complex number class

The complex class is designed to hold two elements of the same type representing a complex number in its Cartesian form.

A complex number can be represented by the sum of a real number (x) and an imaginary part (y*i):

x + y * i

The imaginary part (y*i) is a factor of i, known as the imaginary unit, and which satisfies that:

i2 = -1

In this class, complex numbers have two components: real (corresponding to x in the above example) and imag (corresponding to y).

The class replicates certain functionality aspects of regular numerical types, allowing them to be assigned, compared, inserted and extracted, as well as supporting some arithmetical operators. It is a literal type internally organized as an array of two elements of type T: the first is the real part and the second its imaginary part.



Template parameters
T
Type of both the real and imaginary components of the complex number.
The effect of instantiating a complex with a T other than float, double or long double is undefined (certain library implementations may support it, but the resulting code is non-portable).

Member types member type definition description value_type The first template parameter (T) The type of both Cartesian components
Member functions
(constructor)
Complex number constructor (public member function)
imag
Imaginary part (public member function)
real
Real part (public member function)
(operators)
Complex number operators (function)

Template specializationscomplex is specialized for the three fundamental floating-point types: float, double and long double.

These specializations have the same members as the template, but optimize its implementation for these fundamental types, as well as allowing operations with the other specializations of complex (complex objects with a different template argument).



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4