Debian Codegraph @

texmf-dist/tex/lualatex/luamaths/luamaths.sty

raw
1 % The luamaths package
2 % version 1.6
3 % Licensed under LaTeX Project Public License v1.3c or later. The complete license text is available at http://www.latex-project.org/lppl.txt.
4 %Authors: Chetan Shirore and Ajit Kumar
5
6 \ProvidesPackage{luamaths}[1.6]
7 \RequirePackage{xkeyval}
8 \RequirePackage{amsmath}
9 \RequirePackage{luacode}
10 \begin{luacode*}
11 --load luamaths-complex and luamaths-fractions modules.
12 local complex = require "luamaths-complex"
13 local lfrac = require "luamaths-fractions"
14 --define lua function for evaluating expressions.
15 function mathop(...)
16 inf = math.huge
17 return ...
18 end
19 --define lua function for rounding numbers.
20 function mathround(num, numDecimalPlaces)
21 if num==math.floor(num) then
22 return math.floor(num)
23 end
24 local mult = 10^(numDecimalPlaces or 0)
25 return math.floor(num * mult + 0.5) / mult
26 end
27 \end{luacode*}
28 \newcommand\mathOp[1]{\directlua{tex.sprint(tostring(mathop(#1)))}}
29 \newcommand\mathAbs[1]{\directlua{tex.sprint(math.abs(#1))}}
30 \newcommand\mathAcos[1]{\directlua{tex.sprint(math.acos(#1))}}
31 \newcommand\mathAsin[1]{\directlua{tex.sprint(math.asin(#1))}}
32 \newcommand\mathAtan[1]{\directlua{tex.sprint(math.atan(#1))}}
33 \newcommand\mathCeil[1]{\directlua{tex.sprint(math.ceil(#1))}}
34 \newcommand\mathCos[1]{\directlua{tex.sprint(math.cos(#1))}}
35 \newcommand\mathExp[1]{\directlua{tex.sprint(math.exp(#1))}}
36 \newcommand\mathFloor[1]{\directlua{tex.sprint(math.floor(#1))}}
37 \newcommand\mathInf{\directlua{tex.sprint(math.huge)}}
38 \newcommand\mathLog[1]{\directlua{tex.sprint(math.log(#1))}}
39 \newcommand\mathMax[1]{\directlua{tex.sprint(math.max(#1))}}
40 \newcommand\mathMin[1]{\directlua{tex.sprint(math.min(#1))}}
41 \newcommand\mathPi{\directlua{tex.sprint(math.pi)}}
42 \newcommand\mathRandom[1]{\directlua{tex.sprint(math.random(#1))}}
43 \newcommand\mathSin[1]{\directlua{tex.sprint(tostring(math.sin(#1)))}}
44 \newcommand\mathSqrt[1]{\directlua{tex.sprint(math.sqrt(#1))}}
45 \newcommand\mathTan[1]{\directlua{tex.sprint(math.tan(#1))}}
46 \newcommand\mathRad[1]{\directlua{tex.sprint(math.rad(#1))}}
47 \newcommand\mathRound[2]{\directlua{tex.sprint(mathround(#1,#2))}}
48 \newcommand\complexRound[2]{%
49 \directlua{%
50 tex.sprint(complex.tostring(complex.round(#1,#2)))
51 }%
52 }%
53 \newcommand{\imUnit}{\mathrm{i}}
54 \newcommand\luaChkeqnum[2]{%
55 \directlua{%
56 tex.sprint(tostring(lnumChqEql(#1,#2)))%
57 }%
58 }
59
60 \endinput