Пространства имён
Варианты
Действия

Заголовочный файл стандартной библиотеки <complex>

Материал из cppreference.com
< cpp‎ | header
 
 
Заголовочные файлы стандартной библиотеки
Языковая поддержка
Концепты
<concepts>(C++20)
Диагностика
Управление памятью
Метапрограммирование
<ratio>(C++11)
Общие утилиты
<charconv>(C++17)
<format>(C++20)
<bit>(C++20)

Строки
<cuchar>(C++11)

Контейнеры
<flat_set>(C++23)
<span>(C++20)
<mdspan>(C++23)

Итераторы
<iterator>
Диапазоны
<ranges>(C++20)
Алгоритмы
Числа
<cfenv>(C++11)
<complex>
<numbers>(C++20)

Время
<chrono>(C++11)
Локализация
<codecvt>(C++11/17*)
Ввод/вывод
Регулярные выражения
<regex>(C++11)
Поддержка конкуренции
<stop_token>(C++20)
<thread>(C++11)
<atomic>(C++11)
<barrier>(C++20)
<future>(C++11)

Совместимость с C
<cstdbool>(C++11/17/20*)  
<ccomplex>(C++11/17/20*)
<ctgmath>(C++11/17/20*)

<cstdalign>(C++11/17/20*)

<ciso646>(до C++20)

 

Этот заголовок является частью numeric библиотеки.

Содержание

[править]Классы

a complex number type
(шаблон класса)
a complex number type
(специализация шаблона класса)

[править]Функции

Операции
применяет унарные операторы к комплексным числам
(шаблон функции)[править]
выполняет арифметику комплексных чисел над двумя комплексными значениями или комплексным и скалярным значениями
(шаблон функции)[править]
(удалено в C++20)
сравнивает два комплексных числа или комплексное и скалярное числа
(шаблон функции)[править]
сериализует и десериализует комплексное число
(шаблон функции)[править]
возвращает действительную часть
(шаблон функции)[править]
возвращает мнимую часть
(шаблон функции)[править]
возвращает величину комплексного числа
(шаблон функции)[править]
возвращает угол фазы
(шаблон функции)[править]
возвращает квадрат величины
(шаблон функции)[править]
возвращает комплексное сопряжение
(шаблон функции)[править]
(C++11)
возвращает проекцию на сферу Римана
(шаблон функции)[править]
создаёт комплексное число из величины и угла фазы
(шаблон функции)[править]
Экспоненциальные функции
комплексная экспонента по основанию e
(шаблон функции)[править]
комплексный натуральный логарифм с ветвью, обрезанной по отрицательной действительной оси
(шаблон функции)[править]
комплексный десятичный логарифм с ветвью, обрезанной по отрицательной действительной оси
(шаблон функции)[править]
Степенные функции
комплексная степень, один или оба аргумента могут быть комплексным числом
(шаблон функции)[править]
комплексный квадратный корень из диапазона правой полуплоскости
(шаблон функции)[править]
Тригонометрические функции
вычисляет синус комплексного числа (sin(z))
(шаблон функции)[править]
вычисляет косинус комплексного числа (cos(z))
(шаблон функции)[править]
вычисляет тангенс комплексного числа (tan(z))
(шаблон функции)[править]
вычисляет арксинус комплексного числа (arcsin(z))
(шаблон функции)[править]
вычисляет арккосинус комплексного числа (arccos(z))
(шаблон функции)[править]
вычисляет арктангенс комплексного числа (arctan(z))
(шаблон функции)[править]
Гиперболические функции
вычисляет гиперболический синус комплексного числа (sinh(z))
(шаблон функции)[править]
вычисляет гиперболический косинус комплексного числа (cosh(z))
(шаблон функции)[править]
вычисляет гиперболический тангенс комплексного числа (tanh(z))
(шаблон функции)[править]
вычисляет гиперболический синус площади комплексного числа (arsinh(z))
(шаблон функции)[править]
вычисляет гиперболический косинус площади комплексного числа (arcosh(z))
(шаблон функции)[править]
вычисляет гиперболический тангенс площади комплексного числа (artanh(z))
(шаблон функции)[править]
Литералы
литерал std::complex, представляющий чисто мнимое число
(функция)[править]


[править]Краткое содержание

namespace std {template<class T>class complex;   template<>class complex<float>;template<>class complex<double>;template<>class complex<longdouble>;   // operators:template<class T>constexpr complex<T> operator+(const complex<T>&, const complex<T>&);template<class T>constexpr complex<T> operator+(const complex<T>&, const T&);template<class T>constexpr complex<T> operator+(const T&, const complex<T>&);   template<class T>constexpr complex<T> operator-(const complex<T>&, const complex<T>&);template<class T>constexpr complex<T> operator-(const complex<T>&, const T&);template<class T>constexpr complex<T> operator-(const T&, const complex<T>&);   template<class T>constexpr complex<T> operator*(const complex<T>&, const complex<T>&);template<class T>constexpr complex<T> operator*(const complex<T>&, const T&);template<class T>constexpr complex<T> operator*(const T&, const complex<T>&);   template<class T>constexpr complex<T> operator/(const complex<T>&, const complex<T>&);template<class T>constexpr complex<T> operator/(const complex<T>&, const T&);template<class T>constexpr complex<T> operator/(const T&, const complex<T>&);   template<class T>constexpr complex<T> operator+(const complex<T>&);template<class T>constexpr complex<T> operator-(const complex<T>&);   template<class T>constexprbool operator==const complex<T>&, const complex<T>&);template<class T>constexprbool operator==(const complex<T>&, const T&);template<class T>constexprbool operator==(const T&, const complex<T>&);   template<class T>constexprbool operator!=(const complex<T>&, const complex<T>&);template<class T>constexprbool operator!=(const complex<T>&, const T&);template<class T>constexprbool operator!=(const T&, const complex<T>&);   template<class T, class CharT, class Traits> basic_istream<CharT, Traits>& operator>>(basic_istream<CharT, Traits>&, complex<T>&);   template<class T, class CharT, class Traits> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>&, const complex<T>&);   // values:template<class T>constexpr T real(const complex<T>&);template<class T>constexpr T imag(const complex<T>&);   template<class T> T abs(const complex<T>&);template<class T> T arg(const complex<T>&);template<class T>constexpr T norm(const complex<T>&);   template<class T>constexpr complex<T> conj(const complex<T>&);template<class T> complex<T> proj(const complex<T>&);template<class T> complex<T> polar(const T&, const T&=0);   // transcendentals:template<class T> complex<T> acos(const complex<T>&);template<class T> complex<T> asin(const complex<T>&);template<class T> complex<T> atan(const complex<T>&);   template<class T> complex<T> acosh(const complex<T>&);template<class T> complex<T> asinh(const complex<T>&);template<class T> complex<T> atanh(const complex<T>&);   template<class T> complex<T> cos (const complex<T>&);template<class T> complex<T> cosh (const complex<T>&);template<class T> complex<T> exp (const complex<T>&);template<class T> complex<T> log (const complex<T>&);template<class T> complex<T> log10(const complex<T>&);   template<class T> complex<T> pow(const complex<T>&, const T&);template<class T> complex<T> pow(const complex<T>&, const complex<T>&);template<class T> complex<T> pow(const T&, const complex<T>&);   template<class T> complex<T> sin (const complex<T>&);template<class T> complex<T> sinh(const complex<T>&);template<class T> complex<T> sqrt(const complex<T>&);template<class T> complex<T> tan (const complex<T>&);template<class T> complex<T> tanh(const complex<T>&);   // complex literals:inlinenamespace literals {inlinenamespace complex_literals {constexpr complex<longdouble> operator""il(longdouble);constexpr complex<longdouble> operator""il(unsignedlonglong);constexpr complex<double> operator""i(longdouble);constexpr complex<double> operator""i(unsignedlonglong);constexpr complex<float> operator""if(longdouble);constexpr complex<float> operator""if(unsignedlonglong);}}}

[править]Класс std::complex

template<class T>class complex {public:typedef T value_type;constexpr complex(const T& re = T(), const T& im = T());constexpr complex(const complex&);template<class X>constexpr complex(const complex<X>&);   constexpr T real()const;constexprvoid real(T);constexpr T imag()const;constexprvoid imag(T);   constexpr complex<T>& operator=(const T&);constexpr complex<T>& operator+=(const T&);constexpr complex<T>& operator-=(const T&);constexpr complex<T>& operator*=(const T&);constexpr complex<T>& operator/=(const T&);   constexpr complex& operator=(const complex&);template<class X>constexpr complex<T>& operator=(const complex<X>&);template<class X>constexpr complex<T>& operator+=(const complex<X>&);template<class X>constexpr complex<T>& operator-=(const complex<X>&);template<class X>constexpr complex<T>& operator*=(const complex<X>&);template<class X>constexpr complex<T>& operator/=(const complex<X>&);};

[править]std::complex специализации

template<>class complex<float>{public:typedeffloat value_type;   constexpr complex(float re =0.0f, float im =0.0f);explicitconstexpr complex(const complex<double>&);explicitconstexpr complex(const complex<longdouble>&);   constexprfloat real()const;constexprvoid real(float);constexprfloat imag()const;constexprvoid imag(float);   constexpr complex<float>& operator=(float);constexpr complex<float>& operator+=(float);constexpr complex<float>& operator-=(float);constexpr complex<float>& operator*=(float);constexpr complex<float>& operator/=(float);   constexpr complex<float>& operator=(const complex<float>&);template<class X>constexpr complex<float>& operator=(const complex<X>&);template<class X>constexpr complex<float>& operator+=(const complex<X>&);template<class X>constexpr complex<float>& operator-=(const complex<X>&);template<class X>constexpr complex<float>& operator*=(const complex<X>&);template<class X>constexpr complex<float>& operator/=(const complex<X>&);};   template<>class complex<double>{public:typedefdouble value_type;   constexpr complex(double re =0.0, double im =0.0);constexpr complex(const complex<float>&);explicitconstexpr complex(const complex<longdouble>&);   constexprdouble real()const;constexprvoid real(double);constexprdouble imag()const;constexprvoid imag(double);   constexpr complex<double>& operator=(double);constexpr complex<double>& operator+=(double);constexpr complex<double>& operator-=(double);constexpr complex<double>& operator*=(double);constexpr complex<double>& operator/=(double);   constexpr complex<double>& operator=(const complex<double>&);template<class X>constexpr complex<double>& operator=(const complex<X>&);template<class X>constexpr complex<double>& operator+=(const complex<X>&);template<class X>constexpr complex<double>& operator-=(const complex<X>&);template<class X>constexpr complex<double>& operator*=(const complex<X>&);template<class X>constexpr complex<double>& operator/=(const complex<X>&);};   template<>class complex<longdouble>{public:typedeflongdouble value_type;   constexpr complex(longdouble re = 0.0L, longdouble im = 0.0L);constexpr complex(const complex<float>&);constexpr complex(const complex<double>&);   constexprlongdouble real()const;constexprvoid real(longdouble);constexprlongdouble imag()const;constexprvoid imag(longdouble);   constexpr complex<longdouble>& operator=(const complex<longdouble>&);constexpr complex<longdouble>& operator=(longdouble);constexpr complex<longdouble>& operator+=(longdouble);constexpr complex<longdouble>& operator-=(longdouble);constexpr complex<longdouble>& operator*=(longdouble);constexpr complex<longdouble>& operator/=(longdouble);   template<class X>constexpr complex<longdouble>& operator=(const complex<X>&);template<class X>constexpr complex<longdouble>& operator+=(const complex<X>&);template<class X>constexpr complex<longdouble>& operator-=(const complex<X>&);template<class X>constexpr complex<longdouble>& operator*=(const complex<X>&);template<class X>constexpr complex<longdouble>& operator/=(const complex<X>&);};

[править]Отчеты об ошибках

Следующие изменения поведения были применены с обратной силой к ранее опубликованным стандартам C++:

Номер Применён Поведение в стандарте Корректное поведение
LWG 79 C++98 the default argument of the second parameter
of polar was missing in the synopsis
added
close