fix: Fixed issue with Windows CI test - M_PI doesn't work on Windows CI

This commit is contained in:
Tajmeet Singh 2020-06-23 16:33:54 +01:00
parent 1708de2296
commit 52f918a4ff

View File

@ -12,6 +12,11 @@
#include <iostream>
#include <stdexcept>
/**
* Global constant for pi to work with Windows environment
*/
const double pi = 3.14159265358979323846;
/**
* Class Complex to represent complex numbers as a field.
*/
@ -64,13 +69,13 @@ class Complex {
if (this->re > 0) {
return std::atan(this->im / this->re);
} else if (this->re < 0 && this->im >= 0) {
return std::atan(this->im / this->re) + M_PI;
return std::atan(this->im / this->re) + pi;
} else if (this->re < 0 && this->im < 0) {
return std::atan(this->im / this->re) - M_PI;
return std::atan(this->im / this->re) - pi;
} else if (this->re == 0 && this->im > 0) {
return M_PI / 2;
return pi / 2;
} else if (this->re == 0 && this->im < 0) {
return -M_PI / 2;
return -pi / 2;
} else {
throw std::invalid_argument("Undefined Value");
}