2023-01-09 17:31:13 +00:00
|
|
|
#include "ComplexNumber.h"
|
|
|
|
|
2023-01-26 11:27:35 +00:00
|
|
|
#include <cmath>
|
|
|
|
|
2023-01-09 17:31:13 +00:00
|
|
|
ComplexNumber::ComplexNumber(double real, double imaginary)
|
|
|
|
: mReal(real),
|
|
|
|
mImaginary(imaginary)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
double ComplexNumber::getReal() const
|
|
|
|
{
|
|
|
|
return mReal;
|
|
|
|
}
|
|
|
|
|
|
|
|
double ComplexNumber::getImaginary() const
|
|
|
|
{
|
|
|
|
return mImaginary;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ComplexNumber::setReal(double value)
|
|
|
|
{
|
|
|
|
mReal = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ComplexNumber::setImaginary(double value)
|
|
|
|
{
|
|
|
|
mImaginary = value;
|
2023-01-26 11:27:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double ComplexNumber::getMagnitude() const
|
|
|
|
{
|
|
|
|
return std::sqrt(mReal * mReal + mImaginary * mImaginary);
|
2023-01-09 17:31:13 +00:00
|
|
|
}
|