sqrt method
Implementation
MathComplex sqrt(){
if( _im == 0.0 ){
if( _re < 0.0 ){
if( ClipMath.complexIsReal() ){
ClipMath.setComplexError();
return floatToComplex( ClipMath.sqrt( _re ) );
}
} else {
return floatToComplex( ClipMath.sqrt( _re ) );
}
}
if( _re >= 0.0 ){
double r = ClipMath.sqrt( fabs() + _re );
return MathComplex(
_sqrt05 * r,
_sqrt05 * _im / r
);
}
if( _im >= 0.0 ){
double r = ClipMath.sqrt( fabs() - _re );
return MathComplex(
_sqrt05 * _im / r,
_sqrt05 * r
);
}
double r = ClipMath.sqrt( fabs() - _re );
return MathComplex(
-_sqrt05 * _im / r,
-_sqrt05 * r
);
}