summaryrefslogtreecommitdiff
path: root/macros/luatex/latex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-08-05 03:01:59 +0000
committerNorbert Preining <norbert@preining.info>2023-08-05 03:01:59 +0000
commitd40e7963c06e1302f226c67f32c143dcc5fa958a (patch)
treeb2a2f6f21f5f15e9e8b1c538a094131b87bbc29b /macros/luatex/latex
parent319c90e45fc96ba6f15edcf00b24e484d9d92f2b (diff)
CTAN sync 202308050301
Diffstat (limited to 'macros/luatex/latex')
-rw-r--r--macros/luatex/latex/lualinalg/README.txt2
-rw-r--r--macros/luatex/latex/lualinalg/lualinalg-complex.lua347
-rw-r--r--macros/luatex/latex/lualinalg/lualinalg-fractions.lua225
-rw-r--r--macros/luatex/latex/lualinalg/lualinalg.pdfbin269062 -> 271088 bytes
-rw-r--r--macros/luatex/latex/lualinalg/lualinalg.sty21
-rw-r--r--macros/luatex/latex/lualinalg/lualinalg.tex7
-rw-r--r--macros/luatex/latex/luamaths/README.txt2
-rw-r--r--macros/luatex/latex/luamaths/luamaths-complex.lua10
-rw-r--r--macros/luatex/latex/luamaths/luamaths-fractions.lua5
-rw-r--r--macros/luatex/latex/luamaths/luamaths.bib1
-rw-r--r--macros/luatex/latex/luamaths/luamaths.pdfbin145138 -> 146025 bytes
-rw-r--r--macros/luatex/latex/luamaths/luamaths.sty4
-rw-r--r--macros/luatex/latex/luamaths/luamaths.tex18
13 files changed, 47 insertions, 595 deletions
diff --git a/macros/luatex/latex/lualinalg/README.txt b/macros/luatex/latex/lualinalg/README.txt
index 03a71035cb..8f664663c1 100644
--- a/macros/luatex/latex/lualinalg/README.txt
+++ b/macros/luatex/latex/lualinalg/README.txt
@@ -1,5 +1,5 @@
# The lualinalg package
-# version 1.3
+# version 1.4
# Authors: Chetan Shirore and Ajit Kumar
# Email: mathsbeauty@gmail.com
diff --git a/macros/luatex/latex/lualinalg/lualinalg-complex.lua b/macros/luatex/latex/lualinalg/lualinalg-complex.lua
deleted file mode 100644
index 68fd055b5e..0000000000
--- a/macros/luatex/latex/lualinalg/lualinalg-complex.lua
+++ /dev/null
@@ -1,347 +0,0 @@
---Version=1.3, Date=30-July-2023
--- provides module for complex numbers
---Contains a modified version of the file complex.lua. It is availalbe on the link https://github.com/davidm/lua-matrix/blob/master/lua/complex.lua. This is licensed under the same terms as Lua itself. This license allows to freely copy, modify and distribute the file for any purpose and without any restrictions.
---Licensed under the same terms as Lua itself. This license allows to freely copy, modify and distribute the file for any purpose and without any restrictions.
-
-frac= require("luamaths-fractions")
-complex = {}
-complex_meta = {}
-
-local function parse_scalar(s, pos0)
- local x, n, pos = s:match('^([+-]?[%d%.]+)(.?)()', pos0)
- if not x then return end
- if n == 'e' or n == 'E' then
- local x2, n2, pos2 = s:match('^([+-]?%d+)(.?)()', pos)
- if not x2 then error 'number format error' end
- x = tonumber(x..n..x2)
- if not x then error 'number format error' end
- return x, n2, pos2
- else
- x = tonumber(x)
- if not x then error 'number format error' end
- return x, n, pos
- end
-end
-local function parse_component(s, pos0)
- local x, n, pos = parse_scalar(s, pos0)
- if not x then
- local x2, n2, pos2 = s:match('^([+-]?)(i)()$', pos0)
- if not x2 then error 'number format error' end
- return (x2=='-' and -1 or 1), n2, pos2
- end
- if n == '/' then
- local x2, n2, pos2 = parse_scalar(s, pos)
- x = x / x2
- return x, n2, pos2
- end
- return x, n, pos
-end
-local function parse_complex(s)
- local x, n, pos = parse_component(s, 1)
- if n == '+' or n == '-' then
- local x2, n2, pos2 = parse_component(s, pos)
- if n2 ~= 'i' or pos2 ~= #s+1 then error 'number format error' end
- if n == '-' then x2 = - x2 end
- return x, x2
- elseif n == '' then
- return x, 0
- elseif n == 'i' then
- if pos ~= #s+1 then error 'number format error' end
- return 0, x
- else
- error 'number format error'
- end
-end
-
-function complex.to( num )
- -- check for table type
- if type( num ) == "table" then
- -- check for a complex number
- if getmetatable( num ) == complex_meta then
- return num
- end
-
- if getmetatable( num) == frac_mt then
- return setmetatable( { num, 0 }, complex_meta )
- end
-
- local real,imag = tonumber( num[1] ),tonumber( num[2] )
- if real and imag then
- return setmetatable( { real,imag }, complex_meta )
- end
- return
- end
- local isnum = tonumber( num )
- if isnum then
- return setmetatable( { isnum,0 }, complex_meta )
- end
- if type( num ) == "string" then
- local real, imag = parse_complex(num)
- return setmetatable( { real, imag }, complex_meta )
- end
-end
-
-setmetatable( complex, { __call = function( _,num ) return complex.to( num ) end } )
-
-function complex.new( x,y)
- return setmetatable( {x,y}, complex_meta )
-end
-
-lcomplex = complex.new
-function complex.type( arg )
- if getmetatable( arg ) == complex_meta then
- return "complex"
- end
-end
-
-function complex.convpolar( radius, phi )
- return setmetatable( { radius * math.cos( phi ), radius * math.sin( phi ) }, complex_meta )
-end
-
-function complex.convpolardeg( radius, phi )
- phi = phi/180 * math.pi
- return setmetatable( { radius * math.cos( phi ), radius * math.sin( phi ) }, complex_meta )
-end
-
-function complex.tostring( cx,formatstr )
- imunit = "\\imUnit"
- local real,imag = cx[1],cx[2]
- if type(cx[1]) ~= "table" and type(cx[2]) ~= "table" then
- if imag == 0 then
- return real
- elseif real == 0 then
- return ((imag==1 and "") or (imag==-1 and "-") or imag)..imunit
- elseif imag > 0 then
- return real.."+"..(imag==1 and "" or imag)..imunit
- end
- return real..(imag==-1 and "-" or imag)..imunit
- end
-
- if type(cx[1]) == "table" and type(cx[2]) ~= "table" then
- if cx[2] == 0 then
- return frac.tostring(cx[1])
- end
- if cx[2] > 0 then
- return frac.tostring(cx[1]).. "+"..(imag==1 and "" or imag)..imunit
- end
- if cx[2] < 0 then
- return frac.tostring(cx[1])..(imag==-1 and "-" or imag)..imunit
- end
-
- end
-
- if type(cx[1]) ~= "table" and type(cx[2]) == "table" then
- if frac.toFnumber(cx[2])==0 then return cx[1] end
- return cx[1].."+"..frac.tostring(cx[2])..imunit
- end
-
- if type(cx[1]) == "table" and type(cx[2]) == "table" then
- if frac.toFnumber(cx[1]) == 0 and frac.toFnumber(cx[2]) ~= 0 then
- return frac.tostring(cx[2])..imunit
- end
-
- if frac.toFnumber(cx[2]) == 0 then
- return frac.tostring(cx[1] + 0)
- end
-
- if cx[2].d == 1 then
- if cx[2].n > 0 then
- return frac.tostring(cx[1]).. "+"..(cx[2].n==1 and "" or math.floor(cx[2].n))..imunit
- end
- if cx[2].n < 0 then
- return frac.tostring(cx[1])..(cx[2].n==-1 and "-" or math.floor(cx[2].n))..imunit
- end
- end
- end
- return frac.tostring(cx[1]).. "+"..frac.tostring(cx[2])..imunit
-end
-
-function complex.print( ... )
- print( complex.tostring( ... ) )
-end
-
-function complex.polar( cx )
- return math.sqrt( cx[1]^2 + cx[2]^2 ), math.atan2( cx[2], cx[1] )
-end
-
-function complex.polardeg( cx )
- return math.sqrt( cx[1]^2 + cx[2]^2 ), math.atan2( cx[2], cx[1] ) / math.pi * 180
-end
-
-function complex.norm2( cx )
- return cx[1]^2 + cx[2]^2
-end
-
-function complex.abs( cx )
- return math.sqrt( cx[1]^2 + cx[2]^2 )
-end
-
-function complex.get( cx )
- return cx[1],cx[2]
-end
-
-function complex.set( cx,real,imag )
- cx[1],cx[2] = real,imag
-end
-
-function complex.is( cx,real,imag )
- if cx[1] == real and cx[2] == imag then
- return true
- end
- return false
-end
-
-function complex.copy( cx )
- return setmetatable( { cx[1],cx[2] }, complex_meta )
-end
-
-function complex.add( cx1,cx2 )
- return setmetatable( { cx1[1]+cx2[1], cx1[2]+cx2[2] }, complex_meta )
-end
-
-function complex.sub( cx1,cx2 )
- return setmetatable( { cx1[1]-cx2[1], cx1[2]-cx2[2] }, complex_meta )
-end
-
-function complex.mul( cx1,cx2 )
- return setmetatable( { cx1[1]*cx2[1] - cx1[2]*cx2[2],cx1[1]*cx2[2] + cx1[2]*cx2[1] }, complex_meta )
-end
-
-function complex.mulnum( cx,num )
- return setmetatable( { cx[1]*num,cx[2]*num }, complex_meta )
-end
-
-function complex.div( cx1,cx2 )
- local val = cx2[1]*cx2[1] + cx2[2]*cx2[2]
- return setmetatable( { (cx1[1]*cx2[1]+cx1[2]*cx2[2])/val,(cx1[2]*cx2[1]-cx1[1]*cx2[2])/val }, complex_meta )
-end
-
-function complex.divnum( cx,num )
- return setmetatable( { cx[1]/num,cx[2]/num }, complex_meta )
-end
-
-function complex.pow( cx,num )
- if math.floor( num ) == num then
- if num < 0 then
- local val = cx[1]^2 + cx[2]^2
- cx = { cx[1]/val,-cx[2]/val }
- num = -num
- end
- local real,imag = cx[1],cx[2]
- for i = 2,num do
- real,imag = real*cx[1] - imag*cx[2],real*cx[2] + imag*cx[1]
- end
- return setmetatable( { real,imag }, complex_meta )
- end
- local length,phi = math.sqrt( cx[1]^2 + cx[2]^2 )^num, math.atan2( cx[2], cx[1] )*num
- return setmetatable( { length * math.cos( phi ), length * math.sin( phi ) }, complex_meta )
-end
-
-function complex.sqrt( cx )
- local h
- local k
-
- if type(cx[1]) ~= "table" then h = cx[1] end
- if type(cx[2]) ~= "table" then k = cx[2] end
-
- if type(cx[1]) == "table" then h = frac.toFnumber(cx[1]) end
- if type(cx[2]) == "table" then k = frac.toFnumber(cx[2]) end
- local len = math.sqrt( h^2 + k^2 )
- local sign = ( h<0 and -1) or 1
- return setmetatable( { math.sqrt((h +len)/2), sign*math.sqrt((len-h)/2) }, complex_meta )
-end
-
-function complex.ln( cx )
- return setmetatable( { math.log(math.sqrt( cx[1]^2 + cx[2]^2 )),
- math.atan2( cx[2], cx[1] ) }, complex_meta )
-end
-
-function complex.exp( cx )
- local expreal = math.exp(cx[1])
- return setmetatable( { expreal*math.cos(cx[2]), expreal*math.sin(cx[2]) }, complex_meta )
-end
-
-function complex.conjugate( cx )
- return setmetatable( { cx[1], -cx[2] }, complex_meta )
-end
-
-function Xround(num, numDecimalPlaces)
- if type(num)=="number" then
- if num==math.floor(num) then
- return math.floor(num)
- end
- end
- if type(num)=="number" then
- local mult = 10^(numDecimalPlaces or 0)
- return math.floor(num * mult + 0.5) / mult
- end
- return num
-end
-
-function complex.round( cx,idp )
- local mult =10^( idp or 0 )
- if type(cx[1]) ~= "table" and type(cx[2]) ~= "table" then
- return setmetatable( {Xround(cx[1],idp), Xround(cx[2],idp)}, complex_meta )
- end
- if type(cx[1]) ~= "table" and type(cx[2]) == "table" then
- return setmetatable( {Xround(cx[1],idp), cx[2]}, complex_meta )
- end
- if type(cx[1]) == "table" and type(cx[2]) ~= "table" then
- return setmetatable({cx[1],Xround(cx[2],idp)}, complex_meta )
- end
- if type(cx[1]) == "table" and type(cx[2]) == "table" then
- return setmetatable({cx[1],cx[2]}, complex_meta )
- end
-end
-
-complex.zero = complex.new(0, 0)
-complex.one = complex.new(1, 0)
-
-complex_meta.__add = function( cx1,cx2 )
-local cx1,cx2 = complex.to( cx1 ),complex.to( cx2 )
-return complex.add( cx1,cx2 )
-end
-complex_meta.__sub = function( cx1,cx2 )
-local cx1,cx2 = complex.to( cx1 ),complex.to( cx2 )
-return complex.sub( cx1,cx2 )
-end
-complex_meta.__mul = function( cx1,cx2 )
-local cx1,cx2 = complex.to( cx1 ),complex.to( cx2 )
-return complex.mul( cx1,cx2 )
-end
-complex_meta.__div = function( cx1,cx2 )
-local cx1,cx2 = complex.to( cx1 ),complex.to( cx2 )
-return complex.div( cx1,cx2 )
-end
-complex_meta.__pow = function( cx,num )
-if num == "*" then
-return complex.conjugate( cx )
-end
-return complex.pow( cx,num )
-end
-complex_meta.__unm = function( cx )
-return setmetatable( { -cx[1], -cx[2] }, complex_meta )
-end
-complex_meta.__eq = function( cx1,cx2 )
-if cx1[1] == cx2[1] and cx1[2] == cx2[2] then
-return true
-end
-return false
-end
-complex_meta.__tostring = function( cx )
-return tostring( complex.tostring( cx ) )
-end
-complex_meta.__concat = function( cx,cx2 )
-return tostring(cx)..tostring(cx2)
-end
--- cx( cx, formatstr )
-complex_meta.__call = function( ... )
-print( complex.tostring( ... ) )
-end
-complex_meta.__index = {}
-for k,v in pairs( complex ) do
-complex_meta.__index[k] = v
-end
-
-return complex
-
diff --git a/macros/luatex/latex/lualinalg/lualinalg-fractions.lua b/macros/luatex/latex/lualinalg/lualinalg-fractions.lua
deleted file mode 100644
index e4ab7a2329..0000000000
--- a/macros/luatex/latex/lualinalg/lualinalg-fractions.lua
+++ /dev/null
@@ -1,225 +0,0 @@
--- The luafractions module
--- Authors: Chetan Shirore and Ajit Kumar
--- version 1.0, Date=03-Aug-2023
--- Licensed under LaTeX Project Public License v1.3c or later. The complete license text is available at http://www.latex-project.org/lppl.txt.
-
-M = {} -- the module
-frac_mt = {} -- the metatable
-function M.new (n, d, mode)
- mode = mode or 'fracs'
- if mode == 'nofracs' then
- return (n/d)
- end
- if mode == 'fracs' then
- if n~=math.floor(n) or d~=math.floor(d) then
- error('Only integers are expected.')
- end
- if d == 0 then
- error('Invalid fraction')
- end
- local fr = {}
- local g = M.lgcd(n,d)
- fr = {n=n/g, d=d/g}
- return setmetatable(fr,frac_mt)
- end
-end
-lfrac = M.new
-
-function M.lgcd (a, b)
- local r
- while (b ~= 0) do
- r = a % b
- a = b
- b = r
- end
- return a
-end
-
-function M.simp (num)
- local cf = gcd(num[1], num[2])
- return M.new(num[1] / cf, num2[2] / cf)
-end
-
-function M.toFnumber(c)
- return c.n / c.d
-end
-
-function M.toFrac(x)
- if type(x) == "number" then
- if x==math.floor(x) then
- return M.new(math.floor(x),1)
- else
- return x
- end
- end
- return x
-end
-
-
-function addFracs (c1, c2)
- return M.new(c1.n * c2.d + c1.d * c2.n, c1.d*c2.d)
-end
-
-function subFracs (c1, c2)
- return M.new(c1.n * c2.d - c1.d * c2.n, c1.d*c2.d)
-end
-
-function mulFracs (c1, c2)
- return M.new(c1.n * c2.n, c1.d*c2.d)
-end
-
-function divFracs (c1, c2)
- return M.new(c1.n * c2.d, c1.d*c2.n)
-end
-
-function minusFracs (c1)
- return M.new(-c1.n,c1.d)
-end
-
-function powerFracs (c1,m)
- return M.new((c1.n)^m,(c1.d)^m)
-end
-
-
-function M.add(a, b)
- if type(a) == "number" then
- if a==math.floor(a) then
- return addFracs(M.new(a,1),b)
- else
- return a + M.toFnumber(b)
- end
- end
-
- if type(b) == "number" then
- if b==math.floor(b) then
- return addFracs(a,M.new(b,1))
- else
- return M.toFnumber(a) + b
- end
- end
-
- if type( a ) == "table" and type(b) =="table" then
- if getmetatable( a ) == frac_mt and getmetatable( b ) == complex_meta then
- return setmetatable( { a+b[1], b[2] }, complex_meta )
- end
- end
-
- if type( a ) == "table" and type(b) =="table" then
- if getmetatable( b ) == frac_mt and getmetatable( a ) == complex_meta then
- return setmetatable( { b+a[1], a[2] }, complex_meta )
- end
- end
- return addFracs(a, b)
-end
-
-
-function M.sub(a, b)
- if type(a) == "number" then
- if a==math.floor(a) then
- return subFracs(M.new(a,1),b)
- else
- return a - M.toFnumber(b)
- end
- end
-
- if type(b) == "number" then
- if b==math.floor(b) then
- return subFracs(a,M.new(b,1))
- else
- return M.toFnumber(a) - b
- end
- end
-
- if type( a ) == "table" and type(b) =="table" then
- if getmetatable( a ) == frac_mt and getmetatable( b ) == complex_meta then
- return setmetatable( { a-b[1], b[2] }, complex_meta )
- end
- end
-
- if type( a ) == "table" and type(b) =="table" then
- if getmetatable( b ) == frac_mt and getmetatable( a ) == complex_meta then
- return setmetatable( { a[1]-b, a[2] }, complex_meta )
- end
- end
- return subFracs(a, b)
-end
-
-
-function M.mul(a, b)
- if type(a) == "number" then
- if a==math.floor(a) then
- return mulFracs(M.new(a,1),b)
- else
- return a * M.toFnumber(b)
- end
- end
-
- if type(b) == "number" then
- if b==math.floor(b) then
- return mulFracs(a,M.new(b,1))
- else
- return M.toFnumber(a) * b
- end
- end
-
- if type( a ) == "table" and type(b) =="table" then
- if getmetatable( a ) == frac_mt and getmetatable( b ) == complex_meta then
- return setmetatable( { a*b[1], a*b[2] }, complex_meta )
- end
- end
-
- if type( a ) == "table" and type(b) =="table" then
- if getmetatable( b ) == frac_mt and getmetatable( a ) == complex_meta then
- return setmetatable( { b*a[1], b*a[2] }, complex_meta )
- end
- end
- return mulFracs(a, b)
-end
-
-
-function M.div(a, b)
- if type(a) == "number" then
- if a==math.floor(a) then
- return divFracs(M.new(a,1),b)
- else
- return a / M.toFnumber(b)
- end
- end
-
- if type(b) == "number" then
- if b==math.floor(b) then
- return divFracs(a,M.new(b,1))
- else
- return M.toFnumber(a) / b
- end
- end
-
- if type( a ) == "table" and type(b) =="table" then
- if getmetatable( a ) == frac_mt and getmetatable( b ) == complex_meta then
- b= setmetatable( { M.toFrac(b[1]), M.toFrac(b[2]) }, complex_meta )
- return a*(1/b)
- end
- end
- return divFracs(a, b)
-end
-
-function M.tostring (c)
- if c.d == 1 then
- return string.format("%g",c.n)
- end
- if c.d == -1 then
- return string.format("%g",-c.n)
- end
- return string.format("\\frac{%g}{%g}", c.n, c.d)
-end
-
---Setting Metatable operations.
-frac_mt.__add = M.add
-frac_mt.__sub = M.sub
-frac_mt.__mul = M.mul
-frac_mt.__div = M.div
-frac_mt.__unm = minusFracs
-frac_mt.__pow = powerFracs
-frac_mt.__tostring = M.tostring
-
-return M \ No newline at end of file
diff --git a/macros/luatex/latex/lualinalg/lualinalg.pdf b/macros/luatex/latex/lualinalg/lualinalg.pdf
index b164d33407..adc8fe3290 100644
--- a/macros/luatex/latex/lualinalg/lualinalg.pdf
+++ b/macros/luatex/latex/lualinalg/lualinalg.pdf
Binary files differ
diff --git a/macros/luatex/latex/lualinalg/lualinalg.sty b/macros/luatex/latex/lualinalg/lualinalg.sty
index de120d131a..c16cfa1e14 100644
--- a/macros/luatex/latex/lualinalg/lualinalg.sty
+++ b/macros/luatex/latex/lualinalg/lualinalg.sty
@@ -1,18 +1,17 @@
% The lualinalg package
% Authors: Chetan Shirore and Ajit Kumar
-% version 1.3, Date=03-Aug-2023
+% version 1.4, Date=04-Aug-2023
% Licensed under LaTeX Project Public License v1.3c or later. The complete license text is available at http://www.latex-project.org/lppl.txt.
-\ProvidesPackage{lualinalg}[1.3]
+\ProvidesPackage{lualinalg}[1.4]
\RequirePackage{xkeyval}
\RequirePackage{amsmath}
\RequirePackage{luamaths}
\RequirePackage{luacode}
\begin{luacode*}
-local complex = require "lualinalg-complex"
- local lfrac = require "lualinalg-fractions"
+
-- matrices part
matrices = {}
@@ -774,9 +773,9 @@ function matrix.gauss0E(mtx, augmt, fom, dignum)
tostring(stepCnt) ..
": Divide row " ..
tostring(r) ..
- " by " ..
+ " by $" ..
tostring(complex.round(complex(m), dignum)) ..
- ".$$" ..
+ "$. $$" ..
tostring(matrix.show(matrix.concath(mtx, augmt), fom, dignum)) ..
"$$"
end
@@ -798,9 +797,9 @@ function matrix.gauss0E(mtx, augmt, fom, dignum)
tostring(stepCnt) ..
": Multiply row " ..
tostring(r) ..
- " by " ..
+ " by $" ..
tostring(complex.round(complex(m), dignum)) ..
- " and subtract it from row " ..
+ "$ and subtract it from row " ..
tostring(i) ..
".$$" ..
tostring(
@@ -1183,9 +1182,9 @@ function vector.gsX(inptTbl, brckt, dignum)
str = str .. "\\ \\newline Take given vectors as $v_1,\\ldots, v_" .. k .. "$ in order."
if vector.euclidnorm(inptTbl[1]) ~= complex(0.0) then
- tbl[1] = vector.mulnum(inptTbl[1], 1 / vector.euclidnorm(inptTbl[1]))
+ tbl[1] = vector.mulnum(inptTbl[1], 1.0 / vector.euclidnorm(inptTbl[1]))
else
- tbl[1] = vector.mulnum(inptTbl[1], 1)
+ tbl[1] = vector.mulnum(inptTbl[1], 1.0)
end
setmetatable(tbl[1], vector_meta)
str = str .. "\\ \\newline Step " .. cnt .. ": $$ u_" .. cnt .. "=v_" .. cnt .. "="
@@ -1206,7 +1205,7 @@ function vector.gsX(inptTbl, brckt, dignum)
if vector.euclidnorm(tbl[i]) ~= complex(0.0) then
tbl[i] = vector.mulnum(tbl[i], 1 / vector.euclidnorm(tbl[i]))
else
- tbl[i] = vector.mulnum(tbl[i], 1)
+ tbl[i] = vector.mulnum(tbl[i], 1.0)
end
cnt = cnt + 1
diff --git a/macros/luatex/latex/lualinalg/lualinalg.tex b/macros/luatex/latex/lualinalg/lualinalg.tex
index 10b2d55c34..7c49480d27 100644
--- a/macros/luatex/latex/lualinalg/lualinalg.tex
+++ b/macros/luatex/latex/lualinalg/lualinalg.tex
@@ -1046,7 +1046,7 @@ The package has command \verb|\matrixRREFSteps| to produce step-by-step computat
\renewcommand*{\arraystretch}{1.0}
The command \verb|\matrixGaussJordan| is used to obtain Gauss-Jordan elimination of an augmented matrix.
\begin{lstlisting}
-\def\a{{{1,1,1},{2,-1,-1},{1,-1,1}}}
+\def\a{{{lfrac(1,2),1,1},{2,-1,-1},{1,-1,1}}}
\def\b{{{3},{3},{9}}}
\matrixNew{S}{\a}
\matrixNew{T}{\b}
@@ -1056,11 +1056,12 @@ $$W = \matrixPrint{W}$$
$$U = \matrixPrint{U}$$
\end{lstlisting}
The above code produces the following output.
-\def\a{{{1,1,1},{2,-1,-1},{1,-1,1}}}
+\def\a{{{lfrac(1,2),1,1},{2,-1,-1},{1,-1,1}}}
\def\b{{{3},{3},{9}}}
\matrixNew{S}{\a}
\matrixNew{T}{\b}
\matrixConcatH{W}{S}{T}
+\renewcommand{\arraystretch}{1.5}
\begin{framed}
$$W = \matrixPrint{W}$$
\matrixGaussJordan{U}{S}{T}
@@ -1070,6 +1071,7 @@ The package also has a command \verb|\matrixGaussJordanSteps| to produce step-by
\begin{framed}
\matrixGaussJordanSteps{S}{T}
\end{framed}
+\renewcommand{\arraystretch}{1.0}
\section{Customized usage}\label{customuse}
The commands available in the package can be used for performing further operations on vectors and matrices. The command \verb|\vectorAdd| can be extended to add more than two vectors. The latex document (listing \ref{code:custluavec}) provides some instances of such usage.
\begin{lstlisting}[label={code:custluavec}, caption={Customized usage of the lualinalg package}]
@@ -1179,4 +1181,5 @@ The sum of matrices \(m1,m2 \text{ and } m3 =\begin{bmatrix} 111 & 222 & 333 \
\item The error handling mechanism in the tool is not robust. There are some custom errors included in the package. However the package mostly depends on error handling mechanism of Lua. The error handling can be strengthened in future updates of the package.
\end{itemize}
+
\end{document} \ No newline at end of file
diff --git a/macros/luatex/latex/luamaths/README.txt b/macros/luatex/latex/luamaths/README.txt
index 926a94962c..43acb565dd 100644
--- a/macros/luatex/latex/luamaths/README.txt
+++ b/macros/luatex/latex/luamaths/README.txt
@@ -1,5 +1,5 @@
# The luamaths package
-# version 1.1
+# version 1.3
# Authors: Chetan Shirore and Ajit Kumar
# Email: mathsbeauty@gmail.com
diff --git a/macros/luatex/latex/luamaths/luamaths-complex.lua b/macros/luatex/latex/luamaths/luamaths-complex.lua
index 68fd055b5e..d8ad289d3f 100644
--- a/macros/luatex/latex/luamaths/luamaths-complex.lua
+++ b/macros/luatex/latex/luamaths/luamaths-complex.lua
@@ -1,7 +1,7 @@
---Version=1.3, Date=30-July-2023
+--Version=1.4, Date=04-Aug-2023
-- provides module for complex numbers
--Contains a modified version of the file complex.lua. It is availalbe on the link https://github.com/davidm/lua-matrix/blob/master/lua/complex.lua. This is licensed under the same terms as Lua itself. This license allows to freely copy, modify and distribute the file for any purpose and without any restrictions.
---Licensed under the same terms as Lua itself. This license allows to freely copy, modify and distribute the file for any purpose and without any restrictions.
+--This file is also licensed under the same terms as Lua itself. This license allows to freely copy, modify and distribute the file for any purpose and without any restrictions.
frac= require("luamaths-fractions")
complex = {}
@@ -107,6 +107,12 @@ function complex.tostring( cx,formatstr )
imunit = "\\imUnit"
local real,imag = cx[1],cx[2]
if type(cx[1]) ~= "table" and type(cx[2]) ~= "table" then
+ if imag == 0 and math.floor(real)==real then
+ return math.floor(real)
+ end
+ if real == 0 and math.floor(imag)==imag and math.abs(math.floor(imag))~=1 then
+ return math.floor(imag)..imunit
+ end
if imag == 0 then
return real
elseif real == 0 then
diff --git a/macros/luatex/latex/luamaths/luamaths-fractions.lua b/macros/luatex/latex/luamaths/luamaths-fractions.lua
index e4ab7a2329..540e5b21a2 100644
--- a/macros/luatex/latex/luamaths/luamaths-fractions.lua
+++ b/macros/luatex/latex/luamaths/luamaths-fractions.lua
@@ -1,6 +1,6 @@
-- The luafractions module
-- Authors: Chetan Shirore and Ajit Kumar
--- version 1.0, Date=03-Aug-2023
+-- version 1.1, Date=04-Aug-2023
-- Licensed under LaTeX Project Public License v1.3c or later. The complete license text is available at http://www.latex-project.org/lppl.txt.
M = {} -- the module
@@ -204,6 +204,9 @@ function M.div(a, b)
end
function M.tostring (c)
+ if c.n == 0 then
+ return string.format("%g",0)
+ end
if c.d == 1 then
return string.format("%g",c.n)
end
diff --git a/macros/luatex/latex/luamaths/luamaths.bib b/macros/luatex/latex/luamaths/luamaths.bib
index 4069c4adc2..8078492e11 100644
--- a/macros/luatex/latex/luamaths/luamaths.bib
+++ b/macros/luatex/latex/luamaths/luamaths.bib
@@ -1,4 +1,3 @@
-\begin{filecontents}{luamodtbl.bib}
@online{online.luaorg,
title = {Lua Programming Language},
diff --git a/macros/luatex/latex/luamaths/luamaths.pdf b/macros/luatex/latex/luamaths/luamaths.pdf
index 0b5d310b1d..d5389a3894 100644
--- a/macros/luatex/latex/luamaths/luamaths.pdf
+++ b/macros/luatex/latex/luamaths/luamaths.pdf
Binary files differ
diff --git a/macros/luatex/latex/luamaths/luamaths.sty b/macros/luatex/latex/luamaths/luamaths.sty
index 524b36a210..b73759c00b 100644
--- a/macros/luatex/latex/luamaths/luamaths.sty
+++ b/macros/luatex/latex/luamaths/luamaths.sty
@@ -1,9 +1,9 @@
% The luamaths package
-% version 1.1
+% version 1.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.
%Authors: Chetan Shirore and Ajit Kumar
-\ProvidesPackage{luamaths}[1.1]
+\ProvidesPackage{luamaths}[1.3]
\RequirePackage{xkeyval}
\RequirePackage{amsmath}
\RequirePackage{luacode}
diff --git a/macros/luatex/latex/luamaths/luamaths.tex b/macros/luatex/latex/luamaths/luamaths.tex
index 8e501abf14..3cb499b88c 100644
--- a/macros/luatex/latex/luamaths/luamaths.tex
+++ b/macros/luatex/latex/luamaths/luamaths.tex
@@ -42,7 +42,7 @@ The \verb|luamaths| package is released under the LaTeX Project Public License v
\section{Commands in the luamaths package}
Table \ref{tbl:opluamaths} lists operations in the \verb|luamaths| package.
\begin{center}
-\begin{longtable}{llm{6cm}}
+\begin{longtable}{llm{6.5cm}}
\toprule
\multicolumn{1}{c}{\textcolor{blue}{Function}} & \multicolumn{1}{l}{\textcolor{blue}{Command Format}} & \multicolumn{1}{c}{\textcolor{blue}{Description}} \\
\toprule
@@ -161,7 +161,7 @@ Table \ref{tbl:opluamaths} lists operations in the \verb|luamaths| package.
\end{lstlisting} &
\begin{lstlisting}
\mathRound{number}{digits}
-\end{lstlisting} & It rounds off a real number to a specified number of digits. \\
+\end{lstlisting} & It rounds off a real number to a specified number of decimal places. \\
\midrule
\begin{lstlisting}
\mathSin
@@ -183,6 +183,15 @@ Table \ref{tbl:opluamaths} lists operations in the \verb|luamaths| package.
\begin{lstlisting}
\mathTan{number}
\end{lstlisting} & Gives the tangent of a real number. Here the number is in radians.\\
+\midrule
+\begin{lstlisting}
+\complexRound
+\end{lstlisting} &
+\begin{lstlisting}
+\complexRound{cx_num}{digits}
+\end{lstlisting} & It rounds off a complex number to a specified number of decimal places.\\
+
+
\bottomrule \\
\caption{Operations in the luamaths package}
\label{tbl:opluamaths}
@@ -319,6 +328,11 @@ Table \ref{tbl:illluamaths} illustrates operations in the \verb|luamaths| packag
\begin{lstlisting}
\mathRound{\mathOp{9+\mathSin{4}}}{6}
\end{lstlisting} & \(\mathRound{\mathOp{9+\mathSin{4}}}{6}\)\\
+\midrule
+
+\begin{lstlisting}
+\complexRound{lcomplex(\mathPi,6)}{4}
+\end{lstlisting} & \(\complexRound{lcomplex(\mathPi,6)}{4}\)\\
\bottomrule \\
\caption{Illustrations of commands in the luamaths package}
\label{tbl:illluamaths}