Commit 119ed67a authored by Chuanren Wu's avatar Chuanren Wu

add debug info

parent 354d206f
......@@ -7,6 +7,7 @@
#include <algorithm>
#include <cassert>
#include <iterator>
#include <iostream>
template<class T> int clamp1(T x)
{
......@@ -108,7 +109,9 @@ static std::map<int, int> eliminateSide(
const int nTotal = c.minus.empty() ? c.knownLengthMinus
: std::ceil(realTotal);
if (nTotal < static_cast<int>(c.plus.size())) {
assert(!"failed to solve");
#ifndef NDEBUG
std::cerr << "failed to solve reason 0" << std::endl;
#endif
return m;
}
const double denominator = std::accumulate(
......@@ -145,7 +148,9 @@ static std::map<int, int> eliminateSide(
const int nTotal = c.plus.empty() ? c.knownLengthPlus
: std::ceil(realTotal);
if (nTotal < static_cast<int>(c.minus.size())) {
assert(!"failed to solve");
#ifndef NDEBUG
std::cerr << "failed to solve reason 1" << std::endl;
#endif
return m;
}
const double denominator = std::accumulate(
......@@ -175,6 +180,9 @@ static bool isValid(const std::vector<ConstraintExt> &vc)
for (const auto &c : vc) {
if (c.plus.empty() && c.minus.empty()
&& c.knownLengthPlus != c.knownLengthMinus) {
#ifndef NDEBUG
std::cerr << "failed to solve reason 2" << std::endl;
#endif
return false;
}
// maybe a duplicated test, but can be used as short-circuit
......@@ -182,12 +190,18 @@ static bool isValid(const std::vector<ConstraintExt> &vc)
&& static_cast<int>(c.minus.size())
> (c.knownLengthPlus-c.knownLengthMinus)
) {
#ifndef NDEBUG
std::cerr << "failed to solve reason 3" << std::endl;
#endif
return false;
}
if (c.minus.empty()
&& static_cast<int>(c.plus.size())
> (c.knownLengthMinus-c.knownLengthPlus)
) {
#ifndef NDEBUG
std::cerr << "failed to solve reason 4" << std::endl;
#endif
return false;
}
}
......
......@@ -1224,7 +1224,7 @@ TEST(BC, ComplexSystem)
cs.push_back(c);
}
std::vector<double> vl(466);
std::generate(vl.begin(), vl.end(), [](){ return 100.0;} );
std::generate(vl.begin(), vl.end(), [](){ return 1000.0;} );
auto v = discretizeImpl(vl, cs);
EXPECT_NE(0, v.size());
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment