std::complex::operator+(binary), operator-(binary), operator*, operator/ - cppreference.com
Da cppreference.com.
|
|
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate. La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
<metanoindex/>
<tbody> </tbody>
|
|
(1) | |
|
|
(2) | |
|
|
(3) | |
|
|
(4) | |
|
|
(5) | |
|
|
(6) | |
|
|
(7) | |
|
|
(8) | |
|
|
(9) | |
|
|
(10) | |
|
|
(11) | |
|
|
(12) | |
Implementa gli operatori binari per l'aritmetica complessa e per complesso misto / scalare aritmetica. Gli scalari sono trattati come numeri complessi con parte reale uguale all'argomento e la parte immaginaria impostato a zero.
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.
1-3)
Restituisce la somma dei suoi argomenti
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.
4-6)
Restituisce il risultato della sottrazione rhs da 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.
7-9)
Moltiplica i suoi argomenti
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.
10-12)
Divide lhs da 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.
Parametri
| lhs, rhs | - | gli argomenti: o entrambi i numeri complessi o di un complesso e uno scalare di tipo di corrispondenza ( Original: the arguments: either both complex numbers or one complex and one scalar of matching type ( The text has been machine-translated via Google Translate. |
Valore di ritorno
1-3) complex<T>(lhs) += rhs
4-6) complex<T>(lhs) -= rhs
7-9) complex<T>(lhs) *= rhs
10-12) complex<T>(lhs) /= rhs
Esempio
#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 }
Output:
(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)
Vedi anche
assegnazione composta di due numeri complessi o un complesso e uno scalare Original: compound assignment of two complex numbers or a complex and a scalar The text has been machine-translated via Google Translate. (metodo pubblico) [modifica] | |
si applica operatori unari ai numeri complessi Original: applies unary operators to complex numbers The text has been machine-translated via Google Translate. (funzione di modello) [modifica] | |