complex::operator*=
Multipliziert eine Zahl Zielkomplexe mit einem Faktor, der möglicherweise oder ist der gleiche Typ komplex ist, wie die echten und die imaginären Teile der komplexe Zahlen sind.
template<class Other>
complex& operator*=(
const complex<Other>& _Right
);
complex<Type>& operator*=(
const Type& _Right
);
complex<Type>& operator*=(
const complex<Type>& _Right
);
Parameter
- _Right
Eine komplexe Zahl oder eine Zahl, die denselben Typ wie der Parameter der Zielkomplexen Zahl ist.
Rückgabewert
Eine komplexe Zahl, die von der Zahl multipliziert wurden, die als Parameter angegeben wird.
Hinweise
Der Vorgang wird überladen, sodass einfache arithmetische Operationen ohne die Konvertierung von Daten zu einem bestimmten Format ausgeführt werden können.
Beispiel
// complex_op_me.cpp
// compile with: /EHsc
#include <complex>
#include <iostream>
int main() {
using namespace std;
double pi = 3.14159265359;
// Example of the first member function
// type complex<double> multiplied by type complex<double>
complex <double> cl1 ( polar ( 3.0 , pi / 6 ) );
complex <double> cr1 ( polar ( 2.0 , pi / 3 ) );
cout << "The left-side complex number is cl1 = " << cl1 << endl;
cout << "The right-side complex number is cr1 = " << cr1 << endl;
complex <double> cs1 = cl1 * cr1;
cout << "Quotient of two complex numbers is: cs1 = cl1 * cr1 = "
<< cs1 << endl;
// This is equivalent to the following operation
cl1 *= cr1;
cout << "Quotient of two complex numbers is also: cl1 *= cr1 = "
<< cl1 << endl;
double abscl1 = abs ( cl1 );
double argcl1 = arg ( cl1 );
cout << "The modulus of cl1 is: " << abscl1 << endl;
cout << "The argument of cl1 is: "<< argcl1 << " radians, which is "
<< argcl1 * 180 / pi << " degrees." << endl << endl;
// Example of the second member function
// type complex<double> multiplied by type double
complex <double> cl2 ( polar ( 3.0 , pi / 6 ) );
double cr2 = 5.0;
cout << "The left-side complex number is cl2 = " << cl2 << endl;
cout << "The right-side complex number is cr2 = " << cr2 << endl;
complex <double> cs2 = cl2 * cr2;
cout << "Quotient of two complex numbers is: cs2 = cl2 * cr2 = "
<< cs2 << endl;
// This is equivalent to the following operation
cl2 *= cr2;
cout << "Quotient of two complex numbers is also: cl2 *= cr2 = "
<< cl2 << endl;
double abscl2 = abs ( cl2 );
double argcl2 = arg ( cl2 );
cout << "The modulus of cl2 is: " << abscl2 << endl;
cout << "The argument of cl2 is: "<< argcl2 << " radians, which is "
<< argcl2 * 180 / pi << " degrees." << endl;
}
Beispielausgabe
The left-side complex number is cl1 = (2.59808,1.5)
The right-side complex number is cr1 = (1,1.73205)
Quotient of two complex numbers is: cs1 = cl1 * cr1 = (-6.21281e-013,6)
Quotient of two complex numbers is also: cl1 *= cr1 = (-6.21281e-013,6)
The modulus of cl1 is: 6
The argument of cl1 is: 1.5708 radians, which is 90 degrees.
The left-side complex number is cl2 = (2.59808,1.5)
The right-side complex number is cr2 = 5
Quotient of two complex numbers is: cs2 = cl2 * cr2 = (12.9904,7.5)
Quotient of two complex numbers is also: cl2 *= cr2 = (12.9904,7.5)
The modulus of cl2 is: 15
The argument of cl2 is: 0.523599 radians, which is 30 degrees.
Anforderungen
Header: <complex>
Namespace: std