|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#pragma once
|
|
|
|
|
#include "../fractions/fractions.hpp"
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
@ -43,7 +44,8 @@ class cnumber {
|
|
|
|
|
return z;
|
|
|
|
|
}
|
|
|
|
|
cnumber operator*(const cnumber &that) const {
|
|
|
|
|
cnumber z( (that.r * this->r ) - (that.i * this->i) , (that.r * this->i) + (this->r * that.i) );
|
|
|
|
|
cnumber z((that.r * this->r) - (that.i * this->i),
|
|
|
|
|
(that.r * this->i) + (this->r * that.i));
|
|
|
|
|
return z;
|
|
|
|
|
}
|
|
|
|
|
cnumber operator*(const fraction &q) const {
|
|
|
|
@ -51,8 +53,10 @@ class cnumber {
|
|
|
|
|
return *this * that;
|
|
|
|
|
}
|
|
|
|
|
cnumber operator/(const cnumber &that) const {
|
|
|
|
|
cnumber numerator( (this->r * that.r ) - (this->i * ( that.i * -1)) , (this->r * (that.i * -1)) + (that.r * this->i) );
|
|
|
|
|
cnumber denominator( (that.r * that.r ) - (that.i * ( that.i * -1)) , (that.r * (that.i * -1)) + (that.r * that.i) );
|
|
|
|
|
cnumber numerator((this->r * that.r) - (this->i * (that.i * -1)),
|
|
|
|
|
(this->r * (that.i * -1)) + (that.r * this->i));
|
|
|
|
|
cnumber denominator((that.r * that.r) - (that.i * (that.i * -1)),
|
|
|
|
|
(that.r * (that.i * -1)) + (that.r * that.i));
|
|
|
|
|
cnumber ratio(numerator.r / denominator.r, numerator.i / denominator.r);
|
|
|
|
|
return ratio;
|
|
|
|
|
}
|
|
|
|
@ -79,4 +83,3 @@ class cnumber {
|
|
|
|
|
i = z.i;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|