Newer
Older

Michal Kravcenko
committed
/**
* DESCRIPTION OF THE FILE
*
* @author Michal Kravčenko
* @date 4.9.18 -
*/
Martin Beseda
committed
#include <boost/serialization/export.hpp>
Martin Beseda
committed
Martin Beseda
committed
#include "exprtk.hpp"
#include "ExprtkWrapper.h"
#include "ExprtkWrapperSerialization.h"
Martin Beseda
committed
Martin Beseda
committed
BOOST_CLASS_EXPORT_IMPLEMENT(ExprtkWrapper);
Martin Beseda
committed
Martin Beseda
committed
ExprtkWrapper::ExprtkWrapper() {
// Because of serialization
// TODO implement?
THROW_NOT_IMPLEMENTED_ERROR("This constructors is being used only for serialization purposes.");
Martin Beseda
committed
}
Martin Beseda
committed
ExprtkWrapper::ExprtkWrapper(std::string expression_string) {

Michal Kravcenko
committed
this->p_impl->expression_str = expression_string;
this->p_impl->symbol_table = new symbol_table_t();
this->p_impl->symbol_table->add_variable("x",
this->p_impl->x);
this->p_impl->symbol_table->add_variable("y",
this->p_impl->y);
this->p_impl->symbol_table->add_variable("z",
this->p_impl->z);
this->p_impl->symbol_table->add_variable("t",
this->p_impl->t);
this->p_impl->symbol_table->add_variable("f",
this->p_impl->z);
this->p_impl->expression = new expression_t();
this->p_impl->expression->register_symbol_table(*this->p_impl->symbol_table);
this->p_impl->parser = new parser_t();
this->p_impl->parser->compile(this->p_impl->expression_str,
*this->p_impl->expression);

Michal Kravcenko
committed
}
ExprtkWrapper::~ExprtkWrapper() {

Michal Kravcenko
committed
delete this->p_impl->expression;
this->p_impl->expression = nullptr;
delete this->p_impl->symbol_table;
this->p_impl->symbol_table = nullptr;
delete this->p_impl->parser;
this->p_impl->parser = nullptr;

Michal Kravcenko
committed

Michal Kravcenko
committed
}
double ExprtkWrapper::eval(double x1,
double x2,
double x3,
double x4) {

Michal Kravcenko
committed
this->p_impl->x = x1;
this->p_impl->y = x2;
this->p_impl->z = x3;
this->p_impl->t = x4;

Michal Kravcenko
committed

Michal Kravcenko
committed
}
double ExprtkWrapper::eval(std::vector<double>& p) {

Michal Kravcenko
committed

Michal Kravcenko
committed
}

Michal Kravcenko
committed
}

Michal Kravcenko
committed
}

Michal Kravcenko
committed
}
double result = this->p_impl->expression->value();
return result;