Namespaces
Variants

Standard library header <complex>

From cppreference.net
Standard library headers

このヘッダは numeric ライブラリの一部です。

目次

翻訳の説明: - 「Contents」を「目次」に翻訳しました - C++関連の専門用語(Classes, Functions, Operations, Exponential functions, Power functions, Trigonometric functions, Hyperbolic functions, Literals, Synopsis, Defect reports, std::complex)は原文のまま保持しました - HTMLタグ、属性、コード部分は一切変更していません - 番号付けと構造は完全に保持されています

クラス

複素数型
(クラステンプレート)

関数

演算
複素数に単項演算子を適用する
(関数テンプレート)
2つの複素数値、または複素数とスカラーの間で複素数演算を実行する
(関数テンプレート)
(C++20で削除)
2つの複素数、または複素数とスカラーの比較
(関数テンプレート)
複素数のシリアライズとデシリアライズを行う
(関数テンプレート)
実部を返す
(関数テンプレート)
虚数部を返す
(関数テンプレート)
複素数の絶対値を返す
(関数テンプレート)
位相角を返す
(関数テンプレート)
二乗された絶対値を返す
(関数テンプレート)
複素共役を返す
(関数テンプレート)
(C++11)
リーマン球面上への射影を返す
(関数テンプレート)
大きさと位相角から複素数を構築する
(関数テンプレート)
指数関数
複素数の e を底とする指数関数
(関数テンプレート)
負の実軸に沿った分岐切断を持つ複素自然対数
(関数テンプレート)
負の実軸に沿って分岐切断を持つ複素数の常用対数
(関数テンプレート)
累乗関数
複素数の累乗、1つまたは両方の引数は複素数でも可
(関数テンプレート)
右半平面の範囲における複素数の平方根
(関数テンプレート)
三角関数
複素数の正弦を計算する ( 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<long double>;
    // 演算子:
    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> constexpr bool operator==(const complex<T>&, const complex<T>&);
    template<class T> constexpr bool operator==(const complex<T>&, const T&);
    template<class T> constexpr bool operator==(const T&, const complex<T>&);
    template<class T> constexpr bool operator!=(const complex<T>&, const complex<T>&);
    template<class T> constexpr bool operator!=(const complex<T>&, const T&);
    template<class T> constexpr bool 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>&);
    // 値:
    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);
    // 超越関数:
    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>&);
    // tuple インターフェース:
    template<class T> struct tuple_size;
    template<size_t I, class T> struct tuple_element;
    template<class T> struct tuple_size<complex<T>>;
    template<size_t I, class T> struct tuple_element<I, complex<T>>;
    template<size_t I, class T>
      constexpr T& get(complex<T>&) noexcept;
    template<size_t I, class T>
      constexpr T&& get(complex<T>&&) noexcept;
    template<size_t I, class T>
      constexpr const T& get(const complex<T>&) noexcept;
    template<size_t I, class T>
      constexpr const T&& get(const complex<T>&&) noexcept;
    // 複素リテラル:
    inline namespace literals {
        inline namespace complex_literals {
            constexpr complex<long double> operator""il(long double);
            constexpr complex<long double> operator""il(unsigned long long);
            constexpr complex<double> operator""i(long double);
            constexpr complex<double> operator""i(unsigned long long);
            constexpr complex<float> operator""if(long double);
            constexpr complex<float> operator""if(unsigned long long);
        }
    }
}

クラス 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&) = default;
    template<class X> constexpr explicit(/* コンストラクタページを参照 */)
        complex(const complex<X>&);
    constexpr T real() const;
    constexpr void real(T);
    constexpr T imag() const;
    constexpr void 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>&);
};

不具合報告

以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。

DR 適用対象 公開時の動作 正しい動作
LWG 79 C++98 polar の第2引数のデフォルト引数が
概要で欠落していた
追加された