eis/eqpalg/exp_macro/min_diff.cc

19 lines
471 B
C++
Raw Normal View History

#include <eqpalg/exp_macro/min_diff.h>
#include <string>
std::string replace_min_diff_macro(std::string&& exp_str) {
boost::regex base_regex("min_diff\\((\\d+),(\\d+)\\)");
std::string plv;
std::stringstream ss;
ss << "(";
for (auto i = 0; i < 2; i++) {
ss << "min(abs(pv$1_" << i << "-pv$2_0"
<< "),";
}
ss << "abs(pv$1_2 - pv$2_0)";
ss << ")))";
plv = ss.str();
auto ret = boost::regex_replace(exp_str, base_regex, plv);
return ret;
}