CppDS.com

C++ 98 11 14 17 20 手册

std::conj(std::complex)

来自cppreference.com
< cpp‎ | numeric‎ | complex
定义于头文件 <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 起)
(2)
std::complex<float> conj( float z );

template< class DoubleOrInteger >
std::complex<double> conj( DoubleOrInteger z );

std::complex<long double> conj( long double z );
(C++11 起)
(C++20 前)
constexpr std::complex<float> conj( float z );

template< class DoubleOrInteger >
constexpr std::complex<double> conj( DoubleOrInteger z );

constexpr std::complex<long double> conj( long double z );
(C++20 起)
1) 通过反转虚部符号计算 z复共轭
2)floatdoublelong double 和所有整数类型添加额外重载,它们将参数当做虚部为零的复数。
(C++11 起)

参数

z - 复数值

返回值

z 的复共轭

示例

#include <iostream>
#include <complex>
 
int main()
{
    std::complex<double> z(1,2);
    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)

参阅

返回复数的模
(函数模板)
返回模(范数)的平方
(函数模板)
从模和辐角构造复数
(函数模板)
关闭