Go to the documentation of this file.
26 #define PI (l_mathop(3.141592653589793238462643383279502884))
173 res = l_mathop(log)(
x);
176 #if !defined(LUA_USE_C89)
177 if (base == l_mathop(2.0))
178 res = l_mathop(log2)(
x);
181 if (base == l_mathop(10.0))
182 res = l_mathop(log10)(
x);
184 res = l_mathop(log)(
x)/l_mathop(log)(base);
211 for (i = 2; i <=
n; i++) {
225 for (i = 2; i <=
n; i++) {
253 #define FIGS l_floatatt(MANT_DIG)
266 #if !defined(LUA_RAND32) && !defined(Rand64)
270 #if (ULONG_MAX >> 31 >> 31) >= 3
273 #define Rand64 unsigned long
275 #elif !defined(LUA_USE_C89) && defined(LLONG_MAX)
278 #define Rand64 unsigned long long
280 #elif (LUA_MAXUNSIGNED >> 31 >> 31) >= 3
283 #define Rand64 lua_Unsigned
300 #define trim64(x) ((x) & 0xffffffffffffffffu)
305 return (
x <<
n) | (trim64(
x) >> (64 -
n));
314 state[0] = state0 ^ state3;
315 state[1] = state1 ^ state2;
316 state[2] = state2 ^ (state1 << 17);
332 #define shift64_FIG (64 - FIGS)
335 #define scaleFIG (l_mathop(0.5) / ((Rand64)1 << (FIGS - 1)))
342 #define I2UInt(x) ((lua_Unsigned)trim64(x))
345 #define Int2I(x) ((Rand64)(x))
374 #define trim32(x) ((x) & 0xffffffffu)
423 (
trim32(i.
h) >> (32 - n)) | (i.
l << n));
431 (i.
h << (32 - n)) | (
trim32(i.
l) >> n));
455 #define UONE ((lu_int32)1)
461 #define scaleFIG (l_mathop(0.5) / (UONE << (FIGS - 1)))
478 ((lua_Number)1.0 / (UONE << 30) / 8.0 / (UONE << (FIGS - 33)))
484 #define shiftLOW (64 - FIGS)
489 #define shiftHI ((lua_Number)(UONE << (FIGS - 33)) * 2.0)
534 if ((n & (n + 1)) == 0)
544 #if (LUA_MAXUNSIGNED >> 31) >= 3
550 while ((ran &= lim) > n)
581 default:
return luaL_error(L,
"wrong number of arguments");
599 for (i = 0; i < 16; i++)
657 #if defined(LUA_COMPAT_MATHLIB)
727 #if defined(LUA_COMPAT_MATHLIB)
733 {
"frexp", math_frexp},
734 {
"ldexp", math_ldexp},
735 {
"log10", math_log10},
739 {
"randomseed", NULL},
742 {
"maxinteger", NULL},
743 {
"mininteger", NULL},
static const luaL_Reg randfuncs[]
static int math_max(lua_State *L)
LUA_UNSIGNED lua_Unsigned
static lua_Unsigned I2UInt(Rand64 x)
static int math_asin(lua_State *L)
static int math_ult(lua_State *L)
static int math_sqrt(lua_State *L)
static Rand64 Iadd(Rand64 i1, Rand64 i2)
static int math_log(lua_State *L)
static Rand64 times9(Rand64 i)
static lua_Unsigned project(lua_Unsigned ran, lua_Unsigned n, RanState *state)
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
static int math_sin(lua_State *L)
static Rand64 rotl(Rand64 i, int n)
#define lua_isnoneornil(L, n)
static int math_randomseed(lua_State *L)
static int math_deg(lua_State *L)
static int math_atan(lua_State *L)
LUA_API int lua_type(lua_State *L, int idx)
LUAMOD_API int luaopen_math(lua_State *L)
LUA_API void lua_pushnumber(lua_State *L, lua_Number n)
const LUA_API char * lua_pushstring(lua_State *L, const char *s)
LUA_API int lua_isinteger(lua_State *L, int idx)
static void setseed(lua_State *L, Rand64 *state, lua_Unsigned n1, lua_Unsigned n2)
static const luaL_Reg mathlib[]
static void randseed(lua_State *L, RanState *state)
static int math_toint(lua_State *L)
static void Ixor(Rand64 *i1, Rand64 i2)
#define lua_tointeger(L, i)
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
static int math_tan(lua_State *L)
#define lua_numbertointeger(n, p)
static Rand64 Ishl(Rand64 i, int n)
LUALIB_API void luaL_checkany(lua_State *L, int arg)
static int math_abs(lua_State *L)
static lua_Number I2d(Rand64 x)
LUA_API void * lua_touserdata(lua_State *L, int idx)
static int math_cos(lua_State *L)
static int math_exp(lua_State *L)
#define luaL_argcheck(L, cond, arg, extramsg)
LUA_API int lua_gettop(lua_State *L)
static int math_floor(lua_State *L)
LUA_API void lua_settop(lua_State *L, int idx)
static int math_rad(lua_State *L)
LUA_API void lua_pushboolean(lua_State *L, int b)
LUA_API void lua_pushvalue(lua_State *L, int idx)
static Rand64 rotl1(Rand64 i, int n)
static int math_ceil(lua_State *L)
LUALIB_API void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup)
LUALIB_API lua_Integer luaL_optinteger(lua_State *L, int arg, lua_Integer def)
static int math_random(lua_State *L)
static int math_type(lua_State *L)
static void setrandfunc(lua_State *L)
static Rand64 times5(Rand64 i)
static Rand64 packI(lu_int32 h, lu_int32 l)
static void pushnumint(lua_State *L, lua_Number d)
#define luaL_newlib(L, l)
LUALIB_API lua_Number luaL_checknumber(lua_State *L, int arg)
LUALIB_API int luaL_error(lua_State *L, const char *fmt,...)
static int math_min(lua_State *L)
LUALIB_API lua_Number luaL_optnumber(lua_State *L, int arg, lua_Number def)
LUA_API void * lua_newuserdatauv(lua_State *L, size_t size, int nuvalue)
LUALIB_API lua_Integer luaL_checkinteger(lua_State *L, int arg)
LUA_API lua_Integer lua_tointegerx(lua_State *L, int idx, int *pisnum)
static Rand64 Int2I(lua_Unsigned n)
static int math_fmod(lua_State *L)
#define lua_upvalueindex(i)
static int math_acos(lua_State *L)
LUA_API int lua_compare(lua_State *L, int index1, int index2, int op)
static Rand64 nextrand(Rand64 *state)
static int math_modf(lua_State *L)
plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:44