texlive[65388] Master: luacomplex (28dec22)
commits+karl at tug.org
commits+karl at tug.org
Wed Dec 28 23:31:17 CET 2022
Revision: 65388
http://tug.org/svn/texlive?view=revision&revision=65388
Author: karl
Date: 2022-12-28 23:31:17 +0100 (Wed, 28 Dec 2022)
Log Message:
-----------
luacomplex (28dec22)
Modified Paths:
--------------
trunk/Master/tlpkg/bin/tlpkg-ctan-check
trunk/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc
Added Paths:
-----------
trunk/Master/texmf-dist/doc/lualatex/luacomplex/
trunk/Master/texmf-dist/doc/lualatex/luacomplex/README.txt
trunk/Master/texmf-dist/doc/lualatex/luacomplex/luacomplex.pdf
trunk/Master/texmf-dist/doc/lualatex/luacomplex/luacomplex.tex
trunk/Master/texmf-dist/tex/lualatex/luacomplex/
trunk/Master/texmf-dist/tex/lualatex/luacomplex/luacomplex.sty
trunk/Master/tlpkg/tlpsrc/luacomplex.tlpsrc
Added: trunk/Master/texmf-dist/doc/lualatex/luacomplex/README.txt
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/luacomplex/README.txt (rev 0)
+++ trunk/Master/texmf-dist/doc/lualatex/luacomplex/README.txt 2022-12-28 22:31:17 UTC (rev 65388)
@@ -0,0 +1,19 @@
+# Introduction
+The luacomplex package is developed to define complex numbers and perform basic arithmetic on complex numbers in LaTeX.
+It also loads the luamaths package.
+It provides an easy way to define complex numbers and perform operations on complex numbers.
+The package has no particular environment for performing operations on complex numbers.
+The package commands can be used in any environment (including the mathematics environment).
+It is written in Lua, and the tex file is to be compiled with the LuaLatex engine.
+
+# License
+The luacomplex package is released under the LaTeX Project Public License v1.3c or later.
+The complete license text is available at http://www.latex-project.org/lppl.txt.
+It is developed in Lua.
+Lua is available as a certified open-source software.
+Its license is simple and liberal, which is compatible with GPL.
+
+#Installation and Inclusion
+The installation of luagcd package is similar to plain latex package, where the .sty file is in LaTeX directory of texmf tree.
+The package can be included with \usepackage{luacomplex } command in the preamble of the LaTeX document.
+The TeX file is to be compiled using the LuaLaTeX engine.
\ No newline at end of file
Property changes on: trunk/Master/texmf-dist/doc/lualatex/luacomplex/README.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/lualatex/luacomplex/luacomplex.pdf
===================================================================
(Binary files differ)
Index: trunk/Master/texmf-dist/doc/lualatex/luacomplex/luacomplex.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/luacomplex/luacomplex.pdf 2022-12-28 22:30:37 UTC (rev 65387)
+++ trunk/Master/texmf-dist/doc/lualatex/luacomplex/luacomplex.pdf 2022-12-28 22:31:17 UTC (rev 65388)
Property changes on: trunk/Master/texmf-dist/doc/lualatex/luacomplex/luacomplex.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/lualatex/luacomplex/luacomplex.tex
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/luacomplex/luacomplex.tex (rev 0)
+++ trunk/Master/texmf-dist/doc/lualatex/luacomplex/luacomplex.tex 2022-12-28 22:31:17 UTC (rev 65388)
@@ -0,0 +1,201 @@
+\documentclass{article}
+\usepackage{listings,color,booktabs,longtable,array,hyperref,multicol,framed}
+\usepackage[ top=1in, bottom = 1in, left=1in, right=1in]{geometry}
+\hypersetup{colorlinks,urlcolor=blue}
+\lstset{frame=none,
+ language=[LaTeX]{TeX},
+ aboveskip=3mm,
+ belowskip=3mm,
+ showstringspaces=false,
+ columns=flexible,
+ basicstyle={\ttfamily},
+ numbers=none,
+ numberstyle=\tiny\color{gray},
+ stringstyle=\color{mauve},
+ breaklines=true,
+ breakatwhitespace=true,
+ tabsize=1,
+ upquote=true
+}
+\usepackage[backend=bibtex]{biblatex}
+\begin{document}
+\title{The luacomplex Package in LaTeX}
+\author{Chetan Shirore and Dr. Ajit Kumar}
+\maketitle
+\section{Introduction}\label{section:introduction}
+The \verb|luacomplex| package is developed to define complex numbers and perform basic arithmetic on complex numbers in LaTeX. It also loads the \texttt{luamaths} package. It provides an easy way to define complex numbers and perform operations on complex numbers. The package has no particular environment for performing operations on complex numbers. The package commands can be used in any environment (including the mathematics environment). It is written in Lua, and the tex file is to be compiled with the LuaLatex engine. The time required for operations on complex numbers is not an issue while compiling with LuaLaTeX. There is no need to install Lua on the users' system as tex distributions (TeXLive or MikTeX) come bundled with LuaLaTeX. It may also save users' efforts to copy complex numbers from other software (which may not be in latex-compatible format) and to use them in a tex file.
+
+\section{Installation and License}
+
+The installation of \verb|luacomplex| package is similar to plain latex package, where the \texttt{.sty} file is in \LaTeX directory of texmf tree. The package can be included with \verb|\usepackage{luacomplex}| command in the preamble of the LaTeX document. The TeX file is to be compiled using the LuaLaTeX engine.
+
+The \verb|luacomplex| package is released under the LaTeX Project Public License v1.3c or later. The complete license text is available at \url{http://www.latex-project.org/lppl.txt}. It is developed in Lua. Lua is available as a certified open-source software. Its license is simple and liberal, which is compatible with GPL.
+
+\subsection{Defining and Printing Complex Numbers}
+A complex number can be defined by using the \verb|\cpxNew| command. It has the following syntax.
+\begin{lstlisting}
+\cpxNew{a}{x,y}
+\end{lstlisting}
+\(x\) and \(y\) are real and imaginary parts of complex number \(a\).
+The following commands define complex numbers \( a \) and \(b\).
+\begin{lstlisting}
+\cpxNew{a}{3,4}
+\cpxNew{b}{1,3}
+\end{lstlisting}
+A complex number can be printed by using the \verb|\cpxPrint| command. For example, the commands
+ \begin{lstlisting}
+\(a=\cpxPrint{a}\) \\
+\(b=\cpxPrint{b}\) }
+\end{lstlisting}
+output to \\
+\(a = 3 + 4i\)\\
+\(b = 1 + 3i\)
+
+\section{Commands in the luacomplex package}
+Table \ref{tbl:luacomplex} lists operations in the \verb|luacomplex| package.
+\begin{longtable}{llm{6cm}}
+\toprule
+\multicolumn{1}{c}{\textcolor{blue}{Function}} & \multicolumn{1}{c}{\textcolor{blue}{Command Format}} & \multicolumn{1}{c}{\textcolor{blue}{Description}}\\
+\toprule
+\begin{lstlisting}
+\cpxNew
+\end{lstlisting} &
+\begin{lstlisting}
+\cpxNew{c}{r}{i}
+\end{lstlisting} & Defines complex number \(c\) with real part \(r\) and imaginary part \(i\). \\
+\midrule
+\begin{lstlisting}
+\cpxPrint
+\end{lstlisting} &
+\begin{lstlisting}
+\cpxPrint{a}
+\end{lstlisting} & Prints complex number \(a\). \\
+\midrule
+\begin{lstlisting}
+\cpxAdd
+\end{lstlisting} &
+\begin{lstlisting}
+\cpxAdd{c}{a}{b}
+\end{lstlisting} & Defines complex number \(c\) obtained by adding complex numbers \(a\) and \(b\). \\
+\midrule
+\begin{lstlisting}
+\cpxSub
+\end{lstlisting} &
+\begin{lstlisting}
+\cpxSub{d}{a}{b}
+\end{lstlisting} & Defines complex number \(d\) obtained by subtracting complex number \(b\) from \(a\). \\
+\midrule
+\begin{lstlisting}
+\cpxMul
+\end{lstlisting} &
+\begin{lstlisting}
+\cpxMul{e}{a}{b}
+\end{lstlisting} & Defines complex number \(e\) obtained by multiplying complex number \(a\) by \(b\). \\
+\midrule
+\begin{lstlisting}
+\cpxDiv
+\end{lstlisting} &
+\begin{lstlisting}
+\cpxDiv{f}{a}{b}
+\end{lstlisting} & Defines complex number \(f\) obtained by dividing complex number \(a\) by \(b\). \\
+\midrule
+\begin{lstlisting}
+\cpxInv
+\end{lstlisting} &
+\begin{lstlisting}
+\cpxInv{g}{a}
+\end{lstlisting} & Defines complex number \(g\) obtained by taking inverse of complex number \(a\). \\
+\midrule
+\begin{lstlisting}
+\cpxRe
+\end{lstlisting} &
+\begin{lstlisting}
+\cpxRe{h}{a}
+\end{lstlisting} & Defines \(h\) as a real part of complex number \(a\). \\
+\midrule
+\begin{lstlisting}
+\cpxIm
+\end{lstlisting} &
+\begin{lstlisting}
+\cpxIm{j}{a}
+\end{lstlisting} & Defines \(j\) as an imaginary part of complex number \(a\). \\
+\midrule
+\begin{lstlisting}
+\cpxMod
+\end{lstlisting} &
+\begin{lstlisting}
+\cpxMod{m}{a}
+\end{lstlisting} & Defines \(m\) as modulus of complex number \(a\). \\
+\midrule
+\begin{lstlisting}
+\cpxPrinArg
+\end{lstlisting} &
+\begin{lstlisting}
+\cpxPrinArg{p}{a}
+\end{lstlisting} & Defines \(p\) as the principal argument of complex number \(a\). \\
+\midrule
+\begin{lstlisting}
+\cpxOp
+\end{lstlisting} &
+\begin{lstlisting}
+\cpxOp{n}{some operations}
+\end{lstlisting} & Defines \(n\) as a resulting complex number by performing some operations on complex numbers. It supports all standard operations such as \(+,-,*, /, \) \^{}.\\
+\bottomrule
+\caption{Commands in the luacomplex package}
+\label{tbl:luacomplex}
+\end{longtable}
+
+
+
+\section{Examples and Usage}
+The latex document (Listing: \ref{code:illluacomplex}) makes use of various commands in \verb|luacomplex| package.
+\begin{lstlisting}[label={code:illluacomplex}, caption={LaTeX document with luacomplex package}]
+\documentclass{article}
+\usepackage{luacomplex}
+\begin{document}
+\cpxNew{a}{3,4}
+\cpxNew{b}{1,3}
+\(a=\cpxPrint{a}\) \\
+\(b=\cpxPrint{b}\) \\
+\cpxAdd{c}{a}{b}
+\(c=a+b=\cpxPrint{c}\) \\
+\cpxSub{d}{a}{b}
+\(d=a-b=\cpxPrint{d}\) \\
+\cpxMul{e}{a}{b}
+\(e=a.b=\cpxPrint{e}\) \\
+\cpxDiv{f}{a}{b}
+\(f=\frac{a}{b}=\cpxPrint{f}\) \\
+\cpxInv{g}{a}
+\(g=\frac{1}{a}=\cpxPrint{g}\) \\
+\cpxRe{h}{a}
+\(h=Re(a)=\cpxPrint{h}\) \\
+\cpxIm{j}{a}
+\(j=Im(a)=\cpxPrint{j}\) \\
+\cpxMod{m}{a}
+\(m=|a|=\cpxPrint{m}\) \\
+\cpxOp{n}{a+b*c-d}
+\(n=a+bc-d=\cpxPrint{n}\) \\
+\cpxPrinArg{p}{a}
+\(p = prinArg(a) =\mathRound{\cpxPrint{p}}{4}\)
+\end{document}
+\end{lstlisting}
+This latex document (listing: \ref{code:illluacomplex}) outputs the following on compiling with the LuaLaTeX engine.
+\begin{framed}
+\noindent\(a = 3 + 4i\)\\
+\(b = 1 + 3i\)\\
+\(c = a + b = 4 + 7i\)\\
+\(d=a-b=2+i\)\\
+\(e = a.b = -9 + 13i\)\\
+\(f = ab = 1.5 - 0.5i\)\\
+\(g = a1 = 0.12 - 0.16i\)\\
+\(h = Re(a) = 3\)\\
+\(j = Im(a) = 4\)\\
+\(m = |a| = 25\)\\
+\(n =a+bc-d= -16 + 22i\)\\
+\(p = prinArg(a) = 0.9273\)
+\end{framed}
+
+The package can be modified or extended by adding custom Lua programs.
+
+\printbibliography
+\end{document}
Property changes on: trunk/Master/texmf-dist/doc/lualatex/luacomplex/luacomplex.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/lualatex/luacomplex/luacomplex.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/luacomplex/luacomplex.sty (rev 0)
+++ trunk/Master/texmf-dist/tex/lualatex/luacomplex/luacomplex.sty 2022-12-28 22:31:17 UTC (rev 65388)
@@ -0,0 +1,160 @@
+% luatruthtable package
+% version 1.0
+% 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{luacomplex}[1.0]
+\RequirePackage{xkeyval}
+\RequirePackage{amsmath}
+\RequirePackage{luacode}
+\RequirePackage{luamaths}
+\begin{luacode*}
+complex = {} -- global complex numbers registry
+M = {} -- the module
+local mt = {} --metatable for complex numbers
+setmetatable(_ENV, {__index = complex})
+ function new (r, i)
+ local cp = {}
+ cp = {r=r, i=i}
+ return setmetatable(cp,mt)
+ end
+ M.new = new -- add 'new' to the module
+ -- create constant 'i'
+ M.i = new(0, 1)
+
+ function M.add (c1, c2)
+ return new(c1.r + c2.r, c1.i + c2.i)
+ end
+
+ function M.sub (c1, c2)
+ return new(c1.r - c2.r, c1.i - c2.i)
+ end
+
+ function M.mul (c1, c2)
+ return new(c1.r*c2.r - c1.i*c2.i, c1.r*c2.i + c1.i*c2.r)
+ end
+
+ function M.inv (c)
+ local n = c.r^2 + c.i^2
+ return new(c.r/n, -c.i/n)
+ end
+
+ function M.div (c1, c2)
+ return M.mul(c1, M.inv(c2))
+ end
+
+ function M.re (c)
+ return new(c.r,0)
+ end
+
+ function M.im (c)
+ return new(c.i,0)
+ end
+
+ function M.mod (c)
+ local n = c.r^2 + c.i^2
+ return new(n,0)
+ end
+
+ function M.prinarg(c)
+ local arg
+ if c.r > 0 then
+ arg = math.atan(c.i/c.r)
+ elseif c.r < 0 and c.i >= 0 then
+ arg = math.atan(c.i/c.r) + math.pi
+ elseif c.r < 0 and c.i < 0 then
+ arg = math.atan(c.i/c.r) - math.pi
+ elseif c.r == 0 and c.i > 0 then
+ arg = math.pi / 2
+ elseif c.r == 0 and c.i < 0 then
+ arg = - math.pi / 2
+ else
+ error("Principal argument not defined.")
+ end
+ return arg
+ end
+
+ function M.op (...)
+ return ...
+ end
+
+ function M.tostring (c)
+ if c.i ==0 then
+ return string.format("%g", c.r)
+ elseif c.i> 0 and c.i==1 then
+ return string.format("%g+i", c.r)
+ elseif c.i> 0 and c.i~=1 then
+ return string.format("%g+%gi", c.r, c.i)
+ else
+ return string.format("%g%gi", c.r, c.i) --to avoid +-
+ end
+ end
+
+ --Setting Metatable operations.
+ mt.__add = M.add
+ mt.__mul = M.mul
+ mt.__sub = M.sub
+ mt.__tostring = M.tostring
+\end{luacode*}
+\newcommand\cpxNew[2]{%
+ \directlua{%
+ complex[\luastringN{#1}] = M.new(#2)
+ }%
+}
+\newcommand\cpxPrint[1]{%
+ \directlua{tex.sprint(tostring(complex[\luastringN{#1}]))}%
+}
+\newcommand\cpxAdd[3]{%
+ \directlua{%
+ complex[\luastringN{#1}] = M.add(complex[\luastringN{#2}],complex[\luastringN{#3}])
+ }%
+}
+\newcommand\cpxSub[3]{%
+ \directlua{%
+ complex[\luastringN{#1}] = M.sub(complex[\luastringN{#2}],complex[\luastringN{#3}])
+ }%
+}
+\newcommand\cpxMul[3]{%
+ \directlua{%
+ complex[\luastringN{#1}] = M.mul(complex[\luastringN{#2}],complex[\luastringN{#3}])
+ }%
+}
+\newcommand\cpxDiv[3]{%
+ \directlua{%
+ complex[\luastringN{#1}] = M.div(complex[\luastringN{#2}],complex[\luastringN{#3}])
+ }%
+}
+\newcommand\cpxInv[2]{%
+ \directlua{%
+ complex[\luastringN{#1}] = M.inv(complex[\luastringN{#2}])
+ }%
+}
+\newcommand\cpxRe[2]{%
+ \directlua{%
+ complex[\luastringN{#1}] = M.re(complex[\luastringN{#2}])
+ }%
+}
+\newcommand\cpxIm[2]{%
+ \directlua{%
+ complex[\luastringN{#1}] = M.im(complex[\luastringN{#2}])
+ }%
+}
+\newcommand\cpxMod[2]{%
+ \directlua{%
+ complex[\luastringN{#1}] = M.mod(complex[\luastringN{#2}])
+ }%
+}
+
+\newcommand\cpxPrinArg[2]{%
+ \directlua{%
+ complex[\luastringN{#1}] = M.prinarg(complex[\luastringN{#2}])
+ }%
+}
+
+\newcommand\cpxOp[2]{%
+ \directlua{%
+ complex[\luastringN{#1}] = M.op(#2)
+ }%
+}
+
+\endinput
\ No newline at end of file
Property changes on: trunk/Master/texmf-dist/tex/lualatex/luacomplex/luacomplex.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check 2022-12-28 22:30:37 UTC (rev 65387)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check 2022-12-28 22:31:17 UTC (rev 65388)
@@ -507,7 +507,7 @@
ltxkeys ltxmisc ltxnew ltxtools
lua-alt-getopt lua-check-hyphen lua-physical lua-typo lua-uca lua-ul
lua-uni-algos lua-visual-debug lua-widow-control luaaddplot
- luabibentry luabidi luacas luacensor luacode luacolor
+ luabibentry luabidi luacas luacensor luacode luacolor luacomplex
luafindfont luahyphenrules
luaimageembed luaindex luainputenc luaintro luakeys
lualatex-doc lualatex-doc-de
Modified: trunk/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc 2022-12-28 22:30:37 UTC (rev 65387)
+++ trunk/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc 2022-12-28 22:31:17 UTC (rev 65388)
@@ -39,6 +39,7 @@
depend luacensor
depend luacode
depend luacolor
+depend luacomplex
depend luahyphenrules
depend luaimageembed
depend luaindex
Added: trunk/Master/tlpkg/tlpsrc/luacomplex.tlpsrc
===================================================================
More information about the tex-live-commits
mailing list.