Namespaces
Variants

std:: conj (std::complex)

From cppreference.net
(注:指定されたHTMLフラグメントには翻訳対象のテキストが含まれていないため、元の構造を保持したまま出力します)
ヘッダーで定義 <complex>
(1)
template < class T >
std:: complex < T > conj ( const std:: complex < T > & z ) ;
(C++20まで)
template < class T >
constexpr std:: complex < T > conj ( const std:: complex < T > & z ) ;
(C++20から)
ヘッダーで定義 <complex>
(A)
std:: complex < float > conj ( float f ) ;

std:: complex < double > conj ( double f ) ;

std:: complex < long double > conj ( long double f ) ;
(C++20まで)
constexpr std:: complex < float > conj ( float f ) ;

constexpr std:: complex < double > conj ( double f ) ;

constexpr std:: complex < long double > conj ( long double f ) ;
(C++20から)
(C++23まで)
template < class FloatingPoint >
constexpr std:: complex < FloatingPoint > conj ( FloatingPoint f ) ;
(C++23から)
(B)
template < class Integer >
constexpr std:: complex < double > conj ( Integer i ) ;
(C++20まで)
template < class Integer >
constexpr std:: complex < double > conj ( Integer i ) ;
(C++20以降)
1) 虚数部の符号を反転させることで、 複素共役 を計算します。 z
A,B) すべての整数型および浮動小数点型に対して追加のオーバーロードが提供されており、これらは虚数部がゼロの複素数として扱われます。
(C++11以降)

目次

翻訳の説明: - 「Contents」を「目次」に翻訳しました - HTMLタグ、属性、 タグ内のテキスト(Parameters、Return value、Notes、Example、See also)はC++関連の専門用語として翻訳せず、原文のまま保持しました - 数字や構造はすべて元のフォーマットを保持しています - リンク先(href属性)も変更していません

パラメータ

z - 複素数値
f - 浮動小数点値
i - 整数値

戻り値

1) z の複素共役。
A) std:: complex ( f ) .
B) std:: complex < double > ( i ) の複素数値。

注記

追加のオーバーロードは (A,B) と厳密に同一である必要はありません。それらは引数 num に対して以下を保証するのに十分であればよいのです:

  • num 標準 (C++23まで) 浮動小数点型 T を持つ場合、 std :: conj ( num ) std :: conj ( std:: complex < T > ( num ) ) と同じ効果を持つ。
  • それ以外の場合、 num が整数型を持つならば、 std :: conj ( num ) std :: conj ( std:: complex < double > ( num ) ) と同じ効果を持つ。

#include <complex>
#include <iostream>
int main()
{
    std::complex<double> z(1.0, 2.0);
    std::cout << "The conjugate of " << z << " is " << std::conj(z) << '\n'
              << "Their product is " << z * std::conj(z) << '\n';
}

出力:

The conjugate of (1,2) is (1,-2)
Their product is (5,0)

関連項目

複素数の絶対値を返す
(関数テンプレート)
絶対値の2乗を返す
(関数テンプレート)
絶対値と偏角から複素数を構築する
(関数テンプレート)