std::imag(std::complex)
來自 cppreference.com
定義於標頭檔案 <complex> |
||
(1) | ||
template< class T > T imag( const std::complex<T>& z ); |
(C++14 前) | |
template< class T > constexpr T imag( const std::complex<T>& z ); |
(C++14 起) | |
額外過載 (自 C++11 起) |
||
定義於標頭檔案 <complex> |
||
(A) | ||
float imag( float f ); double imag( double f ); |
(C++14 前) | |
constexpr float imag( float f ); constexpr double imag( double f ); |
(C++14 起) (直至 C++23) |
|
template< class FloatingPoint > FloatingPoint imag( FloatingPoint f ); |
(C++23 起) | |
(B) | ||
template< class Integer > double imag( Integer i ); |
(C++14 前) | |
template< class Integer > constexpr double imag( Integer i ); |
(C++14 起) | |
1) 返回複數 z 的虛部,即 z.imag()。
A,B) 為所有整數和浮點型別提供了額外的過載,這些型別被視為虛部為零的複數。
|
(C++11 起) |
目錄 |
[編輯] 引數
z | - | 複數型別的值 |
f | - | 浮點值 |
i | - | 整數值 |
[編輯] 返回值
1) z 的虛部。
A) decltype(f){} (零)。
B) 0.0。
[編輯] 注意
不需要完全按照 (A,B) 提供額外的過載。它們只需要足以確保對於它們的引數 num
- 如果 num 具有 標準(C++23 前) 浮點型別
T
,則 std::imag(num) 與 std::imag(std::complex<T>(num)) 具有相同的效果。 - 否則,如果 num 具有整數型別,則 std::imag(num) 與 std::imag(std::complex<double>(num)) 具有相同的效果。
[編輯] 參閱
訪問複數的虛部 (public member function) | |
返回實部 (function template) | |
C documentation for cimag
|