diff options
author | Karl Berry <karl@freefriends.org> | 2018-09-26 20:50:34 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-09-26 20:50:34 +0000 |
commit | 78334b0d4607b242273f9d0cde94f6a6fba51832 (patch) | |
tree | 5b604ee30bb611eeeae95ed4218b4e7fd6eb00b8 /Master/texmf-dist/tex/luatex/luaotfload/fontloader-l-math.lua | |
parent | 3a0140d05a7e481750ec23a30ed5cf3cdef61eb7 (diff) |
luaotfload (26sep18)
git-svn-id: svn://tug.org/texlive/trunk@48771 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luaotfload/fontloader-l-math.lua')
-rw-r--r-- | Master/texmf-dist/tex/luatex/luaotfload/fontloader-l-math.lua | 119 |
1 files changed, 115 insertions, 4 deletions
diff --git a/Master/texmf-dist/tex/luatex/luaotfload/fontloader-l-math.lua b/Master/texmf-dist/tex/luatex/luaotfload/fontloader-l-math.lua index ec62919b46a..e5668a5db0a 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/fontloader-l-math.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/fontloader-l-math.lua @@ -6,33 +6,144 @@ if not modules then modules = { } end modules ['l-math'] = { license = "see context related readme files" } -local floor, sin, cos, tan = math.floor, math.sin, math.cos, math.tan - if not math.ceiling then + math.ceiling = math.ceil + end if not math.round then + + local floor = math.floor + function math.round(x) return floor(x + 0.5) end + end if not math.div then + + local floor = math.floor + function math.div(n,m) return floor(n/m) end + end if not math.mod then + function math.mod(n,m) return n % m end -end -local pipi = 2*math.pi/360 +end if not math.sind then + + local sin, cos, tan = math.sin, math.cos, math.tan + + local pipi = 2*math.pi/360 + function math.sind(d) return sin(d*pipi) end function math.cosd(d) return cos(d*pipi) end function math.tand(d) return tan(d*pipi) end + end if not math.odd then + function math.odd (n) return n % 2 ~= 0 end function math.even(n) return n % 2 == 0 end + +end + +if not math.cosh then + + local exp = math.exp + + function math.cosh(x) + local xx = exp(x) + return (xx+1/xx)/2 + end + function math.sinh(x) + local xx = exp(x) + return (xx-1/xx)/2 + end + function math.tanh(x) + local xx = exp(x) + return (xx-1/xx)/(xx+1/xx) + end + +end + +if not math.pow then + + function math.pow(x,y) + return x^y + end + +end + +if not math.atan2 then + + math.atan2 = math.atan + +end + +if not math.ldexp then + + function math.ldexp(x,e) + return x * 2.0^e + end + +end + +-- if not math.frexp then +-- +-- -- not a oneliner so use a math library instead +-- +-- function math.frexp(x,e) +-- -- returns m and e such that x = m2e, e is an integer and the absolute +-- -- value of m is in the range [0.5, 1) (or zero when x is zero) +-- end +-- +-- end + +if not math.log10 then + + local log = math.log + + function math.log10(x) + return log(x,10) + end + +end + +if not math.type then + + function math.type() + return "float" + end + +end + +if not math.tointeger then + + math.mininteger = -0x4FFFFFFFFFFF + math.maxinteger = 0x4FFFFFFFFFFF + + local floor = math.floor + + function math.tointeger(n) + local f = floor(n) + return f == n and f or nil + end + +end + +if not math.ult then + + local floor = math.floor + + function math.tointeger(m,n) + -- not ok but i'm not motivated to look into it now + return floor(m) < floor(n) -- unsigned comparison needed + end + end |