From ba73c7edc85ac1310d82920c5f432993f8a9af23 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Fri, 25 Aug 2023 03:00:47 +0000 Subject: CTAN sync 202308250300 --- macros/luatex/latex/lualinalg/README.txt | 2 +- macros/luatex/latex/lualinalg/lualinalg.pdf | Bin 268452 -> 269684 bytes macros/luatex/latex/lualinalg/lualinalg.sty | 71 +++++++++++++++++++-- macros/luatex/latex/lualinalg/lualinalg.tex | 50 +++++++++++---- macros/luatex/latex/luamaths/README.txt | 2 +- .../luatex/latex/luamaths/luamaths-fractions.lua | 50 ++++++++++++++- macros/luatex/latex/luamaths/luamaths.pdf | Bin 146010 -> 146829 bytes macros/luatex/latex/luamaths/luamaths.sty | 10 ++- macros/luatex/latex/luamaths/luamaths.tex | 14 +++- 9 files changed, 175 insertions(+), 24 deletions(-) (limited to 'macros/luatex/latex') diff --git a/macros/luatex/latex/lualinalg/README.txt b/macros/luatex/latex/lualinalg/README.txt index e63acad671..a3b301cfe1 100644 --- a/macros/luatex/latex/lualinalg/README.txt +++ b/macros/luatex/latex/lualinalg/README.txt @@ -1,5 +1,5 @@ # The lualinalg package -# version 1.7 +# version 1.8 # Authors: Chetan Shirore and Ajit Kumar # Email: mathsbeauty@gmail.com diff --git a/macros/luatex/latex/lualinalg/lualinalg.pdf b/macros/luatex/latex/lualinalg/lualinalg.pdf index 30510d2490..7981b4258c 100644 Binary files a/macros/luatex/latex/lualinalg/lualinalg.pdf and b/macros/luatex/latex/lualinalg/lualinalg.pdf differ diff --git a/macros/luatex/latex/lualinalg/lualinalg.sty b/macros/luatex/latex/lualinalg/lualinalg.sty index 5c62f329fa..55d0542b93 100644 --- a/macros/luatex/latex/lualinalg/lualinalg.sty +++ b/macros/luatex/latex/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}} diff --git a/macros/luatex/latex/lualinalg/lualinalg.tex b/macros/luatex/latex/lualinalg/lualinalg.tex index a5c792be1d..784bac5199 100644 --- a/macros/luatex/latex/lualinalg/lualinalg.tex +++ b/macros/luatex/latex/lualinalg/lualinalg.tex @@ -1,7 +1,7 @@ \documentclass{article} \usepackage{listings,color,parskip,booktabs,longtable,array, hyperref,multirow,multicol,url,amsmath,amssymb,framed,lualinalg,tikz,tikz-3dplot} -\usepackage[top=1.1in, bottom=1.1in, left=1in, right=1in]{geometry} +\usepackage[top=1in, bottom=1in, left=1in, right=1in]{geometry} \usetikzlibrary{calc,3d,arrows} \hypersetup{colorlinks,urlcolor=blue} \lstset{frame=none, @@ -49,18 +49,17 @@ The \verb|lualinalg| package is released under the LaTeX Project Public License \vectorNew{v1}{{1,2,3,4,5,6}} \vectorNew{v2}{{3,6,lcomplex(6,6)}} \end{lstlisting} -The standard vector of dimension \(n \) with \(i^{th}\) coordinate \(1\) can be produced by using the following command. -\begin{lstlisting} -\vectorNew{e}{n,'e',i} -\end{lstlisting} -For example, the following commands +The standard vector of dimension \(n \) with \(i^{th}\) coordinate \(1\) and zero vectors can also be produced by using the command \verb|\vectorNew|. For example, the following commands \begin{lstlisting} \vectorNew{e_1}{3,'e',1} \(e_1=\left(\vectorPrint{e}\right)\) +\vectorNew{O}{3,'zero'} +\(O=\left(\vectorPrint{O}\right)\) \end{lstlisting} output to \vectorNew{e_1}{3,'e',1} -\(e_1=\left(\vectorPrint{e_1}\right)\). - +\(e_1=\left(\vectorPrint{e_1}\right)\) +\vectorNew{O}{3,'zero'} +\(O=\left(\vectorPrint{O}\right)\) \subsection{Commands for operations on vectors} Table \ref{tbl:luavector} lists commands for operations on vectors. \begin{longtable}{m{7cm}m{8.2cm}} @@ -89,6 +88,13 @@ Sets the \(i\)th coordinate of vector as \verb|val|. \\ \end{lstlisting}& Defines a new vector \(v\) obtained by copying coordinates of vector \(w\). \\ \midrule + +\begin{lstlisting} +\vectorEql{v}{w} +\end{lstlisting}& +Returns true if \(v = w\), otherwise returns false. \\ +\midrule + \begin{lstlisting} \vectorAdd{vector}{v1}{v2} \end{lstlisting}& @@ -218,6 +224,12 @@ third coordinate of vector \\ \midrule \begin{lstlisting} +\vectorEql{z}{w} +\end{lstlisting} & +\vectorEql{z}{w} +\\ +\midrule +\begin{lstlisting} new third coordinate of vector \(z = \vectorSetCoordinate{z}{3}{9.3}\) \(z=\left(\vectorPrint{z}\right)\) @@ -515,15 +527,18 @@ This command has two compulsory arguments: \verb|matrix name| and \verb|row entr \matrixNew{n}{{{1,2,3},{4,5,6},{7,8,10}}} \end{lstlisting} -The identity matrix can be defined as well by using the \verb|\matrixNew| command. For example, the following commands +The identity and zero matrices can be defined as well by using the \verb|\matrixNew| command. For example, the following commands \begin{lstlisting} \matrixNew{mtx}{3,'I'} I = \(\matrixPrint{mtx}\) +\matrixNew{O}{3,4,'zero'} +O = \(\matrixPrint{O}\) \end{lstlisting} output to \matrixNew{mtx}{3,'I'} -I = \(\matrixPrint{mtx}\) - +I = \(\matrixPrint{mtx}\) +\matrixNew{O}{3,4,'zero'} +O = \(\matrixPrint{O}\) \subsection{Commands for operations on matrices} Table \ref{tbl:luamtxcmd} lists all commands for operations on matrices in the \verb|lualinalg| package. \begin{longtable}{m{7cm}m{7.5cm}} @@ -673,6 +688,13 @@ Defines a new matrix obtained by evaluating an expression. The expression suppor \end{lstlisting}& Defines a new matrix obtained by copying values from matrix1. \\ \midrule + +\begin{lstlisting} +\matrixEql{m1}{m2} +\end{lstlisting}& +Returns true if m1 = m2, otherwise returns false. \\ +\midrule + \begin{lstlisting} \matrixCreateRandom {m}{i}{j}{k}{l} @@ -922,7 +944,11 @@ Determinant of matrix \(m =\matrixDet{m}\)\\ \end{lstlisting} & \matrixCopy{m12}{m} \(m12 = \matrixPrint{m12}\)\\ - +\midrule +\begin{lstlisting} +\matrixEql{m12}{m} +\end{lstlisting} & +\matrixEql{m12}{m}\\ \midrule \begin{lstlisting} trace of matrix \( m = \matrixTrace{m}\) diff --git a/macros/luatex/latex/luamaths/README.txt b/macros/luatex/latex/luamaths/README.txt index a4a7a334fd..30ceca2301 100644 --- a/macros/luatex/latex/luamaths/README.txt +++ b/macros/luatex/latex/luamaths/README.txt @@ -1,5 +1,5 @@ # The luamaths package -# version 1.4 +# version 1.5 # Authors: Chetan Shirore and Ajit Kumar # Email: mathsbeauty@gmail.com diff --git a/macros/luatex/latex/luamaths/luamaths-fractions.lua b/macros/luatex/latex/luamaths/luamaths-fractions.lua index f13d335245..6900b25ec4 100644 --- a/macros/luatex/latex/luamaths/luamaths-fractions.lua +++ b/macros/luatex/latex/luamaths/luamaths-fractions.lua @@ -1,9 +1,9 @@ -- The luafractions module -- Authors: Chetan Shirore and Ajit Kumar --- version 1.2, Date=21-Aug-2023 +-- version 1.3, 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. -M = {} -- the module +M = {} -- the module frac_mt = {} -- the metatable function M.new (n, d, mode) mode = mode or 'fracs' @@ -41,8 +41,11 @@ function M.simp (num) end function M.toFnumber(c) +if getmetatable( c ) == frac_mt then return c.n / c.d end +return c +end function M.toFrac(x) if type(x) == "number" then @@ -216,6 +219,48 @@ function M.tostring (c) return string.format("\\frac{%g}{%g}", c.n, c.d) end + +function lnumChqEql(x, y) + + if type(x) == "number" and type(y) == "number" then + return (x == y) + end + + if getmetatable( x ) == frac_mt and getmetatable( y ) == frac_mt then + return (M.toFnumber(x) == M.toFnumber(y)) + end + + if type(x) == "number" and getmetatable( y ) == frac_mt then + return (M.toFnumber(y) == x) + end + + if getmetatable( x ) == frac_mt and type(y) == "number" then + return (M.toFnumber(x) == y) + end + + if getmetatable( x ) == complex_meta and getmetatable( y ) == complex_meta then + return M.toFnumber(x[1]) == M.toFnumber(y[1]) and M.toFnumber(x[2]) == M.toFnumber(y[2]) + end + + if type(x) == "number" and getmetatable( y ) == complex_meta then + return (M.toFnumber(y[1]) == x and M.toFnumber(y[2]) == 0) + end + + if getmetatable(x) == complex_meta and type( y ) == "number" then + return (M.toFnumber(x[1]) == y and M.toFnumber(x[2]) == 0) + end + + if getmetatable( x ) == frac_mt and getmetatable( y ) == complex_meta then + return (M.toFnumber(x)==M.toFnumber(y[1]) and M.toFnumber(y[2]) == 0) + end + + if getmetatable( x ) == complex_meta and getmetatable( y ) == frac_mt then + return (M.toFnumber(y)==M.toFnumber(x[1]) and M.toFnumber(x[2]) == 0) + end + + return false +end + --Setting Metatable operations. frac_mt.__add = M.add frac_mt.__sub = M.sub @@ -224,5 +269,6 @@ frac_mt.__div = M.div frac_mt.__unm = minusFracs frac_mt.__pow = powerFracs frac_mt.__tostring = M.tostring +frac_mt.__eq = lnumChqEql return M \ No newline at end of file diff --git a/macros/luatex/latex/luamaths/luamaths.pdf b/macros/luatex/latex/luamaths/luamaths.pdf index 13ecb392af..5713dfa7de 100644 Binary files a/macros/luatex/latex/luamaths/luamaths.pdf and b/macros/luatex/latex/luamaths/luamaths.pdf differ diff --git a/macros/luatex/latex/luamaths/luamaths.sty b/macros/luatex/latex/luamaths/luamaths.sty index 1f6bf1ade0..48c285b61b 100644 --- a/macros/luatex/latex/luamaths/luamaths.sty +++ b/macros/luatex/latex/luamaths/luamaths.sty @@ -1,9 +1,9 @@ % The luamaths package -% version 1.4 +% version 1.5 % 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.4] +\ProvidesPackage{luamaths}[1.5] \RequirePackage{xkeyval} \RequirePackage{amsmath} \RequirePackage{luacode} @@ -50,6 +50,10 @@ tex.sprint(complex.tostring(complex.round(#1,#2))) }% }% \newcommand{\imUnit}{\mathrm{i}} - +\newcommand\luaChkeqnum[2]{% +\directlua{% +tex.sprint(tostring(lnumChqEql(#1,#2)))% +}% +} \endinput diff --git a/macros/luatex/latex/luamaths/luamaths.tex b/macros/luatex/latex/luamaths/luamaths.tex index 3cb499b88c..81b58f9511 100644 --- a/macros/luatex/latex/luamaths/luamaths.tex +++ b/macros/luatex/latex/luamaths/luamaths.tex @@ -1,7 +1,7 @@ \documentclass{article} \renewcommand{\baselinestretch}{1.2} \usepackage{float,listings,color,booktabs,longtable,array,hyperref,luamaths,amsmath,amssymb} -\usepackage[top=1.1in, bottom=1.1in, left=1.1in, right=1.1in]{geometry} +\usepackage[top=1in, bottom=1in, left=1.1in, right=1.1in]{geometry} \hypersetup{colorlinks,urlcolor=blue} \lstset{frame=none, language=[LaTeX]{TeX}, @@ -190,6 +190,13 @@ Table \ref{tbl:opluamaths} lists operations in the \verb|luamaths| package. \begin{lstlisting} \complexRound{cx_num}{digits} \end{lstlisting} & It rounds off a complex number to a specified number of decimal places.\\ +\midrule +\begin{lstlisting} +\luaChkeqnum +\end{lstlisting} & +\begin{lstlisting} +\luaChkeqnum{x}{y} +\end{lstlisting} & It returns true if x = y, otherwise returns false.\\ \bottomrule \\ @@ -333,6 +340,11 @@ Table \ref{tbl:illluamaths} illustrates operations in the \verb|luamaths| packag \begin{lstlisting} \complexRound{lcomplex(\mathPi,6)}{4} \end{lstlisting} & \(\complexRound{lcomplex(\mathPi,6)}{4}\)\\ +\midrule + +\begin{lstlisting} +\luaChkeqnum{\mathCos{0}}{1} +\end{lstlisting} & \luaChkeqnum{\mathCos{0}}{1}\\ \bottomrule \\ \caption{Illustrations of commands in the luamaths package} \label{tbl:illluamaths} -- cgit v1.2.3