std::complex::operator+(binary), operator-(binary), operator*, operator/
提供: cppreference.com
![]() | このページは、Google 翻訳を使って英語版から機械翻訳されました。 翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
template<class T > complex<T> operator+(const complex<T>& lhs, const complex<T>& rhs); | (1) | |
template<class T > complex<T> operator+(const complex<T>& lhs, const T& rhs); | (2) | |
template<class T > complex<T> operator+(const T& lhs, const complex<T>& rhs); | (3) | |
template<class T > complex<T> operator-(const complex<T>& lhs, const complex<T>& rhs); | (4) | |
template<class T > complex<T> operator-(const complex<T>& lhs, const T& rhs); | (5) | |
template<class T > complex<T> operator-(const T& lhs, const complex<T>& rhs); | (6) | |
template<class T > complex<T> operator*(const complex<T>& lhs, const complex<T>& rhs); | (7) | |
template<class T > complex<T> operator*(const complex<T>& lhs, const T& rhs); | (8) | |
template<class T > complex<T> operator*(const T& lhs, const complex<T>& rhs); | (9) | |
template<class T > complex<T> operator/(const complex<T>& lhs, const complex<T>& rhs); | (10) | |
template<class T > complex<T> operator/(const complex<T>& lhs, const T& rhs); | (11) | |
template<class T > complex<T> operator/(const T& lhs, const complex<T>& rhs); | (12) | |
複雑な演算や複雑な混合/スカラー演算用のバイナリ演算子を実装しています。スカラ引数は、引数に等しい実数部とゼロに設定虚数部を持つ複素数として扱われます.
Original:
Implements the binary operators for complex arithmetic and for mixed complex/scalar arithmetic. Scalar arguments are treated as complex numbers with the real part equal to the argument and the imaginary part set to zero.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
1-3)
その引数の合計を返します
Original:
Returns the sum of its arguments
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
4-6)
rhs
からlhs
を減算した結果を返しますOriginal:
Returns the result of subtracting
rhs
from lhs
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
7-9)
その引数を乗算します
Original:
Multiplies its arguments
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
10-12)
lhs
によってrhs
を分割しますOriginal:
Divides
lhs
by rhs
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
目次 |
[編集]パラメータ
lhs, rhs | - | 引数:両複素数や複雑なものと一致する型の1スカラーか(float、double、longdouble) Original: the arguments: either both complex numbers or one complex and one scalar of matching type (float, double, longdouble) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[編集]値を返します
1-3)complex<T>(lhs)+= rhs
4-6)complex<T>(lhs)-= rhs
7-9)complex<T>(lhs)*= rhs
10-12)complex<T>(lhs)/= rhs
[編集]例
このコードを実行します
#include <iostream>#include <complex>int main(){std::complex<double> c2(2, 0);std::complex<double> ci(0, 1); std::cout<< ci <<" + "<< c2 <<" = "<< ci+c2 <<'\n'<< ci <<" * "<< ci <<" = "<< ci*ci <<'\n'<< ci <<" + "<< c2 <<" / "<< ci <<" = "<< ci+c2/ci <<'\n'<<1<<" / "<< ci <<" = "<<1./ci <<'\n'; // std::cout << 1.f/ci; // compile error// std::cout << 1/ci; // compile error}
出力:
(0,1) + (2,0) = (2,1) (0,1) * (0,1) = (-1,0) (0,1) + (2,0) / (0,1) = (0,-1) 1 / (0,1) = (0,-1)
[編集]参照
2複素数や複雑とスカラーの複合代入 Original: compound assignment of two complex numbers or a complex and a scalar The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
複素数に単項演算子を適用します Original: applies unary operators to complex numbers The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |