本文整理汇总了C++中Complex::getImaginaryPart方法的典型用法代码示例。如果您正苦于以下问题:C++ Complex::getImaginaryPart方法的具体用法?C++ Complex::getImaginaryPart怎么用?C++ Complex::getImaginaryPart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Complex
的用法示例。
在下文中一共展示了Complex::getImaginaryPart方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Complex
Complex Complex::operator/( const Complex c1 ) {
double a , b ;
if ( fabs( c1.getRealPart() ) >= fabs( c1.getImaginaryPart() ) ) {
a = c1.getImaginaryPart() / c1.getRealPart() ;
b = 1.0l / ( c1.getRealPart() + a * c1.getImaginaryPart() ) ;
return Complex( ( R + a * I ) * b , ( I - a * R ) * b ) ;
} else {
a = c1.getRealPart() / c1.getImaginaryPart() ;
b = 1.0l / ( c1.getRealPart() * a + c1.getImaginaryPart() ) ;
return Complex( ( R * a + I ) * b , ( I * a - R ) * b ) ;
}
}
示例2: pow
double Complex::pow( Complex base , double exp ) {
return ( pow( base.getRealPart() , exp ) - pow( base.getImaginaryPart() , exp ) );
}
示例3: Compare
bool Complex::Compare( const Complex & c1 ) {
if ( R == c1.getRealPart() || I == c1.getImaginaryPart() )
return true ;
else
return false ;
}
示例4:
bool Complex::operator!=( const Complex & c1 ) {
if ( R != c1.getRealPart() || I != c1.getImaginaryPart() )
return true ;
else
return false ;
}
示例5: subtract
//subtraction function
Complex Complex::subtract(Complex& c){
//follows imaginary number equation
return Complex(getRealPart()-c.getRealPart(),getImaginaryPart()-c.getImaginaryPart());
}
示例6:
//sets original to specified
void Complex::operator=(Complex c){
this->a=c.getRealPart();
this->b=c.getImaginaryPart();
}
示例7: add
//adding function
Complex Complex::add(Complex& c){
//follows imaginary number equation
return Complex(getRealPart()+c.getRealPart(),getImaginaryPart()+c.getImaginaryPart());
}
示例8: divide
//division function
Complex Complex::divide(Complex& c){
return Complex((getRealPart()*c.getRealPart()+getImaginaryPart()*c.getImaginaryPart())/(c.getRealPart()*c.getRealPart()+c.getImaginaryPart()*c.getImaginaryPart() ),( getImaginaryPart()*c.getRealPart()-getRealPart()*c.getImaginaryPart())/(c.getRealPart()*c.getRealPart()+c.getImaginaryPart()*c.getImaginaryPart() ));
}
示例9: multiply
//multiplication function
Complex Complex::multiply(Complex& c){
return Complex((getRealPart()*c.getRealPart()-getImaginaryPart()*c.getImaginaryPart()),( getImaginaryPart()*c.getRealPart()+getRealPart()*c.getImaginaryPart()));
}