26 "Name of the lua function");
33 lua_function_name_(params.GetParamValue<std::string>(
"lua_function_name"))
40 const std::string fname = __PRETTY_FUNCTION__;
45 std::string(
"Attempted to access lua-function, ") +
47 ", but it seems the function could "
50 const size_t num_vals = vals.size();
54 std::string(
"Number of inputs do not match. ") +
55 "Attempted to evaluate with " + std::to_string(num_vals) +
60 for (
double val : vals)
62 lua_pushinteger(L, ++k);
63 lua_pushnumber(L, val);
67 std::vector<double> result;
69 if (lua_pcall(L, 1, 1, 0) == 0)
71 LuaCheckTableValue(fname, L, -1);
72 size_t table_length = lua_rawlen(L, -1);
73 result.reserve(table_length);
74 for (
size_t i = 0; i < table_length; ++i)
76 lua_pushinteger(L,
static_cast<lua_Integer
>(i) + 1);
78 result.push_back(lua_tonumber(L, -1));
83 throw std::logic_error(fname +
" attempted to call lua-function, " +
89 std::string(
"Number of outputs after the function was ") +
91 "match the function specifications. A table is expected with " +
#define ChiLogicalErrorIf(condition, message)
#define ChiInvalidArgumentIf(condition, message)
static chi::Console & console
lua_State *& GetConsoleState()
size_t OutputDimension() const
static chi::InputParameters GetInputParameters()
size_t InputDimension() const
std::vector< double > Evaluate(const std::vector< double > &vals) const override
static chi::InputParameters GetInputParameters()
const std::string lua_function_name_
LuaDimAToDimB(const chi::InputParameters ¶ms)
RegisterChiObject(chi_math::functions, LuaDimAToDimB)