Skip to content

Commit 7446015

Browse files
committed
std::tie doesn't work as expected
1 parent 3f8d6f6 commit 7446015

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/mcomplex.hpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,23 @@ class FComplex : public CMSat::Field {
6262

6363
Field& operator*=(const Field& other) override {
6464
const auto& od = dynamic_cast<const FComplex&>(other);
65-
std::tie(real,imag) = std::tuple{
66-
real*od.real+imag*od.imag,
67-
real*od.imag+imag*od.real};
65+
mpq_class r = real;
66+
mpq_class i = imag;
67+
real = r*od.real+i*od.imag;
68+
imag = r*od.imag+i*od.real;
6869
return *this;
6970
}
7071

7172
Field& operator/=(const Field& other) override {
7273
const auto& od = dynamic_cast<const FComplex&>(other);
73-
if (od.real == 0) throw std::runtime_error("Division by zero");
74-
auto div = od.imag*od.imag+od.real*od.real;
75-
std::tie(real,imag) = std::tuple{
76-
(real*od.real+imag*od.imag)/div,
77-
(imag*od.real-real*od.imag)/div};
74+
if (od.is_zero()) throw std::runtime_error("Division by zero");
75+
mpq_class div = od.imag*od.imag+od.real*od.real;
76+
mpq_class r = real;
77+
mpq_class i = imag;
78+
real = r*od.real+i*od.imag;
79+
real /= div;
80+
imag = i*od.real-r*od.imag;
81+
imag /= div;
7882
return *this;
7983
}
8084

0 commit comments

Comments
 (0)