love.math.randomNormal can be JIT-compiled

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-04-01 21:19:19 -03:00
parent b205b8a020
commit f8c58c54c8
2 changed files with 25 additions and 0 deletions
+14
View File
@@ -63,6 +63,7 @@ typedef struct Proxy Proxy;
typedef struct FFI_RandomGenerator
{
double (*random)(Proxy *p);
double (*randomNormal)(Proxy *p, double stddev, double mean);
} FFI_RandomGenerator;
]])
@@ -78,5 +79,18 @@ function RandomGenerator:random(l, u)
return getrandom(r, l, u)
end
function RandomGenerator:randomNormal(stddev, mean)
-- TODO: This should ideally be handled inside ffifuncs.randomNormal
if self == nil then error("bad argument #1 to 'randomNormal' (RandomGenerator expected, got no value)", 2) end
stddev = stddev == nil and 1 or stddev
mean = mean == nil and 0 or mean
if type(stddev) ~= "number" then error("bad argument #1 to 'randomNormal' (number expected)", 2) end
if type(mean) ~= "number" then error("bad argument #2 to 'randomNormal' (number expected)", 2) end
return tonumber(ffifuncs.randomNormal(self, stddev, mean))
end
-- DO NOT REMOVE THE NEXT LINE. It is used to load this file as a C++ string.
--)luastring"--"