本文整理汇总了C++中Complex::im方法的典型用法代码示例。如果您正苦于以下问题:C++ Complex::im方法的具体用法?C++ Complex::im怎么用?C++ Complex::im使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Complex
的用法示例。
在下文中一共展示了Complex::im方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runtime_error
Complex Complex::operator / (const Complex &c)
{
double r = c.re() * c.re() + c.im() * c.im();
if (r==0)
throw std::runtime_error("Деление на нуль");
else
return Complex(((re_ * c.re() + im_ * c.im()) / r), ((im_ * c.re() - re_ * c.im()) / r));
}
示例2: Complex
Complex<T> Complex<T>::operator/ (Complex const& z) const {
T temp1, temp2;
if (z.re() >= z.im()) {
temp1 = z.im() / z.re();
temp2 = z.re() + z.im() * temp1;
return Complex( (re() + im() * temp1) / temp2, (im() - re() * temp1) / temp2 );
} else {
temp1 = z.re() / z.im();
temp2 = z.re() * temp1 + z.im();
return Complex( (re() * temp1 + im()) / temp2, (im() * temp1 - re()) / temp2 );
}
}
示例3: Complex
Complex Complex::operator+(const Complex &c) const{
return Complex(real + c.re(), imag + c.im());
}
示例4:
bool operator ==(const Complex& left, const Complex& right){
return left.re() == right.re() &&
left.im() == right.im();
}
示例5: Complex
Complex Complex::operator * (const Complex &c)
{
double real=re_ * c.re() - im_ * c.im();
double image=re_ * c.im() + im_ * c.re();
return Complex(real, image);
}
示例6: re
// Comparisons
bool operator== (Complex const& z) const { return re()==z.re() and im()==z.im(); }
示例7: im
Complex<T> Complex<T>::operator* (Complex const& z) const {
return Complex<T>(re()*z.re() - im()*z.im(), re()*z.im() + im()*z.re());
}