提取复数的虚分量。
语法
T imag( ) const;
T imag(const T& _Right);
参数
- _Right
要提取其虚数值的复数。
返回值
复数的虚部。
备注
对于复数 a + bi,虚部或虚分量为 Im(a + bi) = b。
// complex_imag.cpp
// compile with: /EHsc
#include <complex>
#include <iostream>
int main( )
{
using namespace std;
complex <double> c1 ( 4.0 , 3.0 );
cout << "The complex number c1 = " << c1 << endl;
double dr1 = c1.real ( );
cout << "The real part of c1 is c1.real ( ) = "
<< dr1 << "." << endl;
double di1 = c1.imag ( );
cout << "The imaginary part of c1 is c1.imag ( ) = "
<< di1 << "." << endl;
}
复数 c1 = (4,3) c1 的实部为 c1.real ( ) = 4。c1 的虚部为 c1.imag ( ) = 3。
要求
标头:<complex>
命名空间: std