diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-07-15 00:11:15 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-07-15 00:11:15 +0100 |
commit | 96f05a55a63ec28f423e204d8e66a94c9f605e61 (patch) | |
tree | 9749b0cd2c62132fdf3816944f275995fbb12c7f /src | |
parent | d32b1c887e86319691da76a6ee8d6ee51b17dcab (diff) | |
download | rspamd-96f05a55a63ec28f423e204d8e66a94c9f605e61.tar.gz rspamd-96f05a55a63ec28f423e204d8e66a94c9f605e61.zip |
Add util.tanh lua utility.
Diffstat (limited to 'src')
-rw-r--r-- | src/lua/lua_util.c | 18 |
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); |