[poincare] Evaluation: force 0 imaginary/real parts to be 0 and not -0

to avoid using two differents conventions on branch cuts
This commit is contained in:
Émilie Feral
2018-05-03 16:47:57 +02:00
parent 66e87361e4
commit 0c61e74675
2 changed files with 15 additions and 2 deletions

View File

@@ -41,8 +41,15 @@ using ComplexFunction = std::complex<T> (*)(const std::complex<T>&);
template<typename T>
class Complex : public std::complex<T>, public Evaluation<T> {
public:
Complex(T a, T b = -0.0) : std::complex<T>(a, b) {}
Complex(std::complex<T> c) : std::complex<T>(c) {}
Complex(T a, T b = 0.0) : std::complex<T>(a, b) {}
Complex(std::complex<T> c) : std::complex<T>(c) {
if (this->real() == -0) {
this->real(0);
}
if (this->imag() == -0) {
this->imag(0);
}
}
static Complex Undefined() {
return Complex(NAN, NAN);
}

View File

@@ -72,6 +72,12 @@ MatrixComplex<T>::MatrixComplex(std::complex<T> * operands, int numberOfRows, in
m_operands = new std::complex<T> [numberOfRows*numberOfColumns];
for (int i=0; i<numberOfRows*numberOfColumns; i++) {
m_operands[i] = operands[i];
if (m_operands[i].real() == -0.0) {
m_operands[i].real(0.0);
}
if (m_operands[i].imag() == -0.0) {
m_operands[i].imag(0.0);
}
}
}