40 lines
917 B
C++
40 lines
917 B
C++
#include "mix_cc/matheval.h"
|
|
#include <Eigen/Core>
|
|
#include <functional>
|
|
#include <map>
|
|
#include <string>
|
|
namespace mix_cc {
|
|
namespace dataframe {
|
|
namespace detail {
|
|
class inner_exp {
|
|
public:
|
|
void init(std::string& exp_str, int tag_count) {
|
|
this->exp_str = exp_str;
|
|
this->exp_parser.parse(exp_str);
|
|
}
|
|
|
|
double calc(const Eigen::Block<Eigen::MatrixXd, 1, -1, false>& row) {
|
|
this->load_row_to_buffer(row);
|
|
return this->calc();
|
|
}
|
|
|
|
protected:
|
|
void load_row_to_buffer(
|
|
const Eigen::Block<Eigen::MatrixXd, 1, -1, false>& row) {
|
|
tmp_data["time"] = row(0);
|
|
for (auto i = 1; i < row.size(); i++) {
|
|
tmp_data["tag" + std::to_string(i)] = row(i);
|
|
}
|
|
}
|
|
|
|
double calc() { exp_parser.evaluate(tmp_data); }
|
|
|
|
std::map<std::string, double> tmp_data;
|
|
std::string exp_str;
|
|
matheval::Parser exp_parser;
|
|
};
|
|
} // namespace detail
|
|
} // namespace dataframe
|
|
|
|
} // namespace mix_cc
|