//====================================================//
// //
// Overloaded / //
// //
//====================================================//
MYCOMPLEX MYCOMPLEX::operator/(const MYCOMPLEX& w)
{
if(modulus(w)<1.0e-14){
cout << "Can't divide by 0!" << endl;
return w;
}
else{
MYCOMPLEX quotient;
double c = modulus(w);
c *=c;
quotient.real = (real*w.real + imaginary*w.imaginary)/c;
quotient.imaginary = (imaginary*w.real - real*w.imaginary)/c;
return quotient;
}
}
MYCOMPLEX operator/(const int& i,const MYCOMPLEX& w)
{
if(modulus(w)<1.0e-14){
cout << "Can't divide by 0!" << endl;
return w;
}
else{
MYCOMPLEX quotient;
double c = modulus(w);
c *=c;
quotient.real = (double)i*w.real/c;
quotient.imaginary = -(double)i*w.imaginary/c;
return quotient;
}
}
MYCOMPLEX operator/(const float& x,const MYCOMPLEX& w)
{
if(modulus(w)<1.0e-14){
cout << "Can't divide by 0!" << endl;
return w;
}
else{
MYCOMPLEX quotient;
double c = modulus(w);
c *=c;
quotient.real = x*w.real/c;
quotient.imaginary = -x*w.imaginary/c;
return quotient;
}
}
MYCOMPLEX operator/(const double& x,const MYCOMPLEX& w)
{
if(modulus(w)<1.0e-14){
cout << "Can't divide by 0!" << endl;
return w;
}
else{
MYCOMPLEX quotient;
double c = modulus(w);
c *=c;
quotient.real = x*w.real/c;
quotient.imaginary = -x*w.imaginary/c;
return quotient;
}
}
MYCOMPLEX operator/(const MYCOMPLEX& w,const int& i)
{
if(i==0){
cout << "Can't divide by 0!" << endl;
return w;
}
else{
MYCOMPLEX quotient;
double c = modulus(w);
c *=c;
quotient.real = w.real/(double)i;
quotient.imaginary = w.imaginary/(double)i;
return quotient;
}
}
MYCOMPLEX operator/(const MYCOMPLEX& w,const float& x)
{
if(fabs(x)<1.0e-7){
cout << "Can't divide by 0!" << endl;
return w;
}
else{
MYCOMPLEX quotient;
double c = modulus(w);
c *=c;
quotient.real = w.real/x;
quotient.imaginary = w.imaginary/x;
return quotient;
}
}
MYCOMPLEX operator/(const MYCOMPLEX& w,const double& x)
{
if(fabs(x)<1.0e-14){
cout << "Can't divide by 0!" << endl;
return w;
}
else{
MYCOMPLEX quotient;
double c = modulus(w);
c *=c;
quotient.real = w.real/x;
quotient.imaginary = w.imaginary/x;
return quotient;
}
}