summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lua/lua_util.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c
index 8d5686f7c..ff061a927 100644
--- a/src/lua/lua_util.c
+++ b/src/lua/lua_util.c
@@ -69,6 +69,13 @@ LUA_FUNCTION_DEF (util, decode_base64);
*/
LUA_FUNCTION_DEF (util, tokenize_text);
LUA_FUNCTION_DEF (util, process_message);
+/***
+ * @function util.tanh(num)
+ * Calculates hyperbolic tanhent of the specified floating point value
+ * @param {number} num input number
+ * @return {number} hyperbolic tanhent of the variable
+ */
+LUA_FUNCTION_DEF (util, tanh);
static const struct luaL_reg utillib_f[] = {
LUA_INTERFACE_DEF (util, create_event_base),
@@ -78,6 +85,7 @@ static const struct luaL_reg utillib_f[] = {
LUA_INTERFACE_DEF (util, encode_base64),
LUA_INTERFACE_DEF (util, decode_base64),
LUA_INTERFACE_DEF (util, tokenize_text),
+ LUA_INTERFACE_DEF (util, tanh),
{NULL, NULL}
};
@@ -426,6 +434,16 @@ lua_util_tokenize_text (lua_State *L)
}
static gint
+lua_util_tanh (lua_State *L)
+{
+ gdouble in = luaL_checknumber (L, 1);
+
+ lua_pushnumber (L, tanh (in));
+
+ return 1;
+}
+
+static gint
lua_load_util (lua_State * L)
{
lua_newtable (L);