diff options
Diffstat (limited to 'Master/texmf-dist/tex/lualatex/lualinalg/lualinalg.sty')
-rw-r--r-- | Master/texmf-dist/tex/lualatex/lualinalg/lualinalg.sty | 71 |
1 files changed, 67 insertions, 4 deletions
diff --git a/Master/texmf-dist/tex/lualatex/lualinalg/lualinalg.sty b/Master/texmf-dist/tex/lualatex/lualinalg/lualinalg.sty index 5c62f329fad..55d0542b931 100644 --- a/Master/texmf-dist/tex/lualatex/lualinalg/lualinalg.sty +++ b/Master/texmf-dist/tex/lualatex/lualinalg/lualinalg.sty @@ -1,9 +1,9 @@ % The lualinalg package % Authors: Chetan Shirore and Ajit Kumar -% Version 1.7, Date=21-Aug-2023 +% Version 1.8, Date=23-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.7] +\ProvidesPackage{lualinalg}[1.8] \RequirePackage{xkeyval} \RequirePackage{amsmath} \RequirePackage{luamaths} @@ -17,7 +17,7 @@ matrix = {} --module local matrix_meta = {} -function matrix.new(matrix, rows, columns) +function matrix.new(matrix, rows, columns, str) if type(rows) == "table" then for i = 1, #rows do if #rows[1] ~= #rows[i] then @@ -40,6 +40,15 @@ function matrix.new(matrix, rows, columns) end return setmetatable(mtx, matrix_meta) end + if str == "zero" then + for i = 1, rows do + mtx[i] = {} + for j = 1, columns do + mtx[i][j] = 0 + end + end + return setmetatable(mtx, matrix_meta) + end end setmetatable( @@ -872,6 +881,21 @@ function matrix.show(mtx, format, dig) return str .. "\\end{" .. format .. "} " end +function matrix.chqeql(m1, m2) + if #m1 ~= #m2 or #m1[1] ~= #m2[1] then + return false + end + for i = 1, #m1 do + for j = 1, #m1[1] do + if not(lnumChqEql(m1[i][j],m2[i][j])) then + return false + end + end + end + return true +end + + matrix_meta.__tostring = function(...) return matrix.show(...) end @@ -906,6 +930,10 @@ matrix_meta.__unm = function(mtx) return matrix.mulnum(mtx, -1) end +matrix_meta.__eq = function(...) + return matrix.chqeql(...) +end + local option = { ["*"] = function(m1) return matrix.conjugate(m1) @@ -927,7 +955,7 @@ vector = {} --module local vector_meta = {} function vector.new(vector, rows, columns, n) - if columns ~= "e" then + if columns ~= "e" and columns ~= "zero" then local tbl = {} for i = 1, #rows do tbl[i] = rows[i] @@ -945,6 +973,13 @@ function vector.new(vector, rows, columns, n) end return setmetatable(vec, vector_meta) end + + if columns == "zero" then + for i = 1, rows do + vec[i] = 0 + end + return setmetatable(vec, vector_meta) + end end setmetatable( @@ -1221,6 +1256,18 @@ function vector.gsX(inptTbl, brckt, dignum) return str end +function vector.chqeql(v1, v2) + if #v1 ~= #v2 then + return false + end + for j = 1, #v1 do + if not(lnumChqEql(v1[j],v2[j])) then + return false + end + end + return true +end + vector_meta.__tostring = function(...) return vector.show(...) end @@ -1237,6 +1284,10 @@ vector_meta.__unm = function(vec) return vector.mulnum(vec, -1) end +vector_meta.__eq = function(...) + return vector.chqeql(...) +end + vector_meta.__mul = function(v1, v2) if getmetatable(v1) ~= vector_meta then return vector.mulnum(v2, v1) @@ -1475,6 +1526,12 @@ tex.sprint(tostring(matrix.rank(matrices['#1']))) }% } +\newcommand\matrixEql[2]{% +\directlua{% +tex.sprint(tostring(matrix.chqeql(matrices['#1'],matrices['#2']))) +}% +} + % ========= KEY DEFINITIONS ========= \define@key{matrixrr}{type}{\def\moprr@type{#1}} \define@key{matrixrr}{truncate}{\def\moprr@truncate{#1}} @@ -1624,6 +1681,12 @@ tex.sprint(tostring(vector.getangle(vectors['#1'],vectors['#2']))) }% } +\newcommand\vectorEql[2]{% +\directlua{% +tex.sprint(tostring(vector.chqeql(vectors['#1'],vectors['#2']))) +}% +} + % ========= KEY DEFINITIONS ========= \define@key{vecrr}{brckt}{\def\voprr@brckt{#1}} \define@key{vecrr}{truncate}{\def\voprr@truncate{#1}} |