mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[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:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user