|
|
@ -11,6 +11,7 @@ class cnumber {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
cnumber(int a, int b) {
|
|
|
|
cnumber(int a, int b) {
|
|
|
|
r = a;
|
|
|
|
r = a;
|
|
|
|
i = b;
|
|
|
|
i = b;
|
|
|
@ -18,6 +19,14 @@ class cnumber {
|
|
|
|
signi = get_sign(i);
|
|
|
|
signi = get_sign(i);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Member functions
|
|
|
|
|
|
|
|
cnumber conjugate() {
|
|
|
|
|
|
|
|
cnumber z(this->r, this->i * -1);
|
|
|
|
|
|
|
|
return z;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Operators
|
|
|
|
cnumber operator+(const cnumber &that) {
|
|
|
|
cnumber operator+(const cnumber &that) {
|
|
|
|
cnumber z(that.r + this->r, that.i + this->i);
|
|
|
|
cnumber z(that.r + this->r, that.i + this->i);
|
|
|
|
return z;
|
|
|
|
return z;
|
|
|
@ -31,7 +40,12 @@ class cnumber {
|
|
|
|
os << z.r << (z.signi ? '+' : '\0' ) << z.i << 'i';
|
|
|
|
os << z.r << (z.signi ? '+' : '\0' ) << z.i << 'i';
|
|
|
|
return os;
|
|
|
|
return os;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void operator=(const cnumber &z ) {
|
|
|
|
|
|
|
|
r = z.r;
|
|
|
|
|
|
|
|
i = z.i;
|
|
|
|
|
|
|
|
signr = z.signr;
|
|
|
|
|
|
|
|
signi = z.signi;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|