diff options
author | Karl Berry <karl@freefriends.org> | 2023-08-24 20:18:43 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-08-24 20:18:43 +0000 |
commit | a5560f51ecbc195d32584aa363b0bbb89c1f483f (patch) | |
tree | 422f8e24cb94bd8bc76710e5146cba10a48d6afb /Master | |
parent | 08f53cf753a62f29e910709bffaed5ca2d45ef58 (diff) |
lualinalg (24aug23)
git-svn-id: svn://tug.org/texlive/trunk@68049 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/lualatex/lualinalg/README.txt | 2 | ||||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/lualinalg/lualinalg.pdf | bin | 268452 -> 269684 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/lualinalg/lualinalg.tex | 50 | ||||
-rw-r--r-- | Master/texmf-dist/tex/lualatex/lualinalg/lualinalg.sty | 71 |
4 files changed, 106 insertions, 17 deletions
diff --git a/Master/texmf-dist/doc/lualatex/lualinalg/README.txt b/Master/texmf-dist/doc/lualatex/lualinalg/README.txt index e63acad6718..a3b301cfe1e 100644 --- a/Master/texmf-dist/doc/lualatex/lualinalg/README.txt +++ b/Master/texmf-dist/doc/lualatex/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/Master/texmf-dist/doc/lualatex/lualinalg/lualinalg.pdf b/Master/texmf-dist/doc/lualatex/lualinalg/lualinalg.pdf Binary files differindex 30510d24908..7981b4258cc 100644 --- a/Master/texmf-dist/doc/lualatex/lualinalg/lualinalg.pdf +++ b/Master/texmf-dist/doc/lualatex/lualinalg/lualinalg.pdf diff --git a/Master/texmf-dist/doc/lualatex/lualinalg/lualinalg.tex b/Master/texmf-dist/doc/lualatex/lualinalg/lualinalg.tex index a5c792be1d5..784bac5199b 100644 --- a/Master/texmf-dist/doc/lualatex/lualinalg/lualinalg.tex +++ b/Master/texmf-dist/doc/lualatex/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/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}} |