summaryrefslogtreecommitdiff
path: root/Master/texmf-dist
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-07-09 20:10:48 +0000
committerKarl Berry <karl@freefriends.org>2022-07-09 20:10:48 +0000
commit0bc467b2fe6735f21a5f8d9d3ec5ceaf6c4d3be2 (patch)
tree27da88b712357c20d8e2980bb580fa554ce3c594 /Master/texmf-dist
parent302715d312e974c8fa6ed085e507b77d7dca6636 (diff)
derivative (9jul22)
git-svn-id: svn://tug.org/texlive/trunk@63850 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r--Master/texmf-dist/doc/latex/derivative/README.md4
-rw-r--r--Master/texmf-dist/doc/latex/derivative/derivative.pdfbin180462 -> 183631 bytes
-rw-r--r--Master/texmf-dist/doc/latex/derivative/derivative.tex114
-rw-r--r--Master/texmf-dist/tex/latex/derivative/derivative.sty770
4 files changed, 438 insertions, 450 deletions
diff --git a/Master/texmf-dist/doc/latex/derivative/README.md b/Master/texmf-dist/doc/latex/derivative/README.md
index 9b8aec07fe4..d9dc3127808 100644
--- a/Master/texmf-dist/doc/latex/derivative/README.md
+++ b/Master/texmf-dist/doc/latex/derivative/README.md
@@ -1,4 +1,4 @@
-## README for derivative package v1.1 dated 2021-06-03
+## README for derivative package v1.2 dated 2022-07-09
The package provides a set of commands `\NewDerivative`, `\NewDifferential` etc. that can be used to define a derivative or a differential operator, respectively. The package have already defined several derivatives and differentials:
@@ -16,7 +16,7 @@ The package provides a set of commands `\NewDerivative`, `\NewDifferential` etc.
### Copyright and license
-Copyright 2019-2021 Simon Jensen
+Copyright 2019-2022 Simon Jensen
This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either version 1.3
diff --git a/Master/texmf-dist/doc/latex/derivative/derivative.pdf b/Master/texmf-dist/doc/latex/derivative/derivative.pdf
index 606ae177835..9e4203f7b60 100644
--- a/Master/texmf-dist/doc/latex/derivative/derivative.pdf
+++ b/Master/texmf-dist/doc/latex/derivative/derivative.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/derivative/derivative.tex b/Master/texmf-dist/doc/latex/derivative/derivative.tex
index d7c50df7b8e..837a7695d01 100644
--- a/Master/texmf-dist/doc/latex/derivative/derivative.tex
+++ b/Master/texmf-dist/doc/latex/derivative/derivative.tex
@@ -1,5 +1,5 @@
% derivative.tex
-% Copyright 2019-2021 Simon Jensen
+% Copyright 2019-2022 Simon Jensen
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
@@ -83,8 +83,8 @@ indent_length "2"
\RequirePackage[unicode]{hyperref}
\RequirePackage[nameinlink]{cleveref}
-\makeatletter
\ExplSyntaxOn
+\makeatletter
\tl_new:N \pakkenavn
\tl_new:N \titel
@@ -147,7 +147,7 @@ indent_length "2"
columns = fullflexible,
basicstyle = \ttfamily\upshape\small,
alsoletter = {\\,-,*,/},
- keywords = [0]{style-inf, style-var, style-frac, style-frac-/, style-notation, style-notation-*, scale-eval, scale-eval-/, scale-fun, scale-var, scale-frac, scale-frac-/, scale-var, scale-var-*, delims-eval, delims-eval-/, delims-fun, delims-var, delims-frac, delims-var-*, delims-frac-/, sep-inf-ord, sep-inf-fun, sep-ord-fun, sep-frac-fun, sep-inf-var, sep-var-ord, sep-var-inf, sep-ord-inf, sep-var-var, sep-eval-sb, sep-eval-sp, sep-begin, sep-inf-ord, sep-inf-var, sep-ord-var, sep,var-inf, sep-var-var, sep-ord-ord, sep-end, switch-*, switch-/, add-delims, remove-delims, add-var-delims, order, morder, sort-method, sort-numerical, sort-abs-reverse, sort-number-reverse, sort-sign-reverse, sort-symbol-reverse, fun, frac, var, order, ord, mixed-order, mixord, scale-auto},
+ keywords = [0]{style-inf, style-var, style-frac, style-frac-/, style-notation, style-notation-*, scale-eval, scale-eval-/, scale-fun, scale-var, scale-var-*, scale-frac, scale-frac-/, delims-eval, delims-eval-/, delims-fun, delims-var, delims-var-*, delims-frac, delims-frac-/, sep-inf-ord, sep-inf-fun, sep-ord-fun, sep-frac-fun, sep-inf-var, sep-var-ord, sep-var-inf, sep-ord-inf, sep-var-var, sep-eval-sb, sep-eval-sp, sep-begin, sep-inf-ord, sep-inf-var, sep-ord-var, sep-var-inf, sep-ord-ord, sep-end, switch-*, switch-/, switch-sort, sort-method, sort-numerical, sort-abs-reverse, sort-lexical-reverse, sort-number-reverse, sort-sign-reverse, sort-symbol-reverse, fun, frac, var, order, ord, mixed-order, mixord, scale-auto},
keywordstyle = [0]\__mydoc_option_font:,
keywords = [1]{\\odv, \\pdv, \\mdv, \\fdv, \\adv, \\jdv, \\odif, \\pdif, \\mdif, \\fdif, \\adif, \\NewDerivative, \\RenewDerivative, \\ProvideDerivative, \\DeclareDerivative, \\NewDifferential, \\RenewDifferential, \\ProvideDifferential, \\DeclareDifferential, \\slashfrac, \\derivset},
keywordstyle = [1]\__mydoc_function_font:,
@@ -395,7 +395,6 @@ indent_length "2"
{
}
-
\tl_new:N \l__mydoc_number_tl
\tl_new:N \l_mydoc_index_item_tl
\tl_new:N \l_mydoc_index_subitem_tl
@@ -659,7 +658,10 @@ indent_length "2"
\group_begin:
\small \ttfamily
New: \tl_use:N \c_space_tl
- \tl_use:N #1
+
+ \tl_if_head_eq_charcode:fNTF {#1} v
+ { \tl_use:N #1 }
+ { v\tl_use:N #1 }
\group_end:
}
@@ -668,7 +670,10 @@ indent_length "2"
\group_begin:
\small \ttfamily
Updated: \tl_use:N \c_space_tl
- \tl_use:N #1
+
+ \tl_if_head_eq_charcode:fNTF {#1} v
+ { \tl_use:N #1 }
+ { v\tl_use:N #1 }
\group_end:
}
@@ -1318,15 +1323,16 @@ indent_length "2"
{ \mydoc_cs_to_str:N #1 }
\ExplSyntaxOff
+\makeatother
\Pakkenavn{derivative}
\Titel{The \pakkenavn{} package}
\Forfatter{Simon Jensen}
\Email{sjelatex@gmail.com}
-\Dato{2021/06/03}
-\Version{1.1}
+\Dato{2022/07/09}
+\Version{1.2}
-\RequirePackage[upright]{derivative}[\dato]
+\RequirePackage{derivative}[\dato]
% \derivset{all}[scale-auto = mleftmright]
\hypersetup
@@ -1360,17 +1366,21 @@ indent_length "2"
\begin{document}
- \forside{%
- The \mypackage{} package provides a set of commands which makes writing ordinary and partial derivatives of arbitrary order in a straight forward manner. Additionally, this package provides a set of commands to define variants of the aforementioned derivatives. A set of optional arguments along with lots of package options allow for easy and great flexibility over the derivative's format, such as where the function is positioned, point of evaluation, and switching between fraction styles. Moreover, the mixed order of the partial derivative and variants hereof is automatically computed. This package is written in the \pkg{expl3} language and requires therefore the \LaTeX3 package bundles \pkg{l3kernel} and \pkg{l3package}. Additionally, the \pkg{mleftright} package is optional and provides the improved automatically scaling \cs{mleft} and \cs{mright}.}
+ \forside{The \mypackage{} package provides a set of commands which makes writing ordinary and partial derivatives of arbitrary order in a straight forward manner. Additionally, this package provides a set of commands to define variants of the aforementioned derivatives. A set of optional arguments along with lots of package options allow for easy and great flexibility over the derivative's format, such as where the function is positioned, point of evaluation, and switching between fraction styles. Moreover, the mixed order of the partial derivative and variants hereof is automatically computed. This package is written in the \pkg{expl3} language and requires therefore the \LaTeX3 package bundles \pkg{l3kernel} and \pkg{l3package}. Additionally, the \pkg{mleftright} package is optional and provides the improved automatically scaling \cs{mleft} and \cs{mright}.}
\clearpage
\tableofcontents
\clearpage
+ \section{Introduction}
This package started as a personal package a few years ago that I used in various projects. Firstly, it was written in \tex{} and \latex, which gave rise to various errors as the complexity of the package grew larger and ended up as a spaghetti code. Therefore, the code was rewritten into the \latex3 language and may now be easily maintained. Originally this package was written because there did not exist any great package for derivatives. It was first much later that I discovered the \pkg{diffcoeff} package, which does a good job. However, at this time, I had already written much of the code with no documentation. So I decided to write one and make it into a package for the public.
As a note on terminology, I use the wording \emph{infinitesimal} abbreviated as \texttt{inf} for the operator symbols $d, \partial, \delta$ etc. that used in derivatives like $\odv{y}{x}, \pdv{y}{x}, \fdv{y}{x}$ and in differentials like $\odif{x}, \pdif{x}, \fdif{x}$. In the description of macros and options, I often write \emph{cs-\meta{placeholder}} to denote a comma-separated list of \meta{placeholder}. For example, \oarg{cs-numbers} is used in the option section for math space keys to denote comma-separated list of numbers. It should also be noted that whenever an argument reads \meta{keyvalue list}, it means that it is a comma-separated list of keyvalue pairs.
+ \bigskip
+
+ \noindent The github respository can be found at \href{https://github.com/sjelatex/derivative}{www.github.com/sjelatex/derivative}.
+
\clearpage
@@ -1477,7 +1487,7 @@ indent_length "2"
\begin{equation*}
\odv{f}{x} = \lim_{h\to 0} \mleft( \frac{ f(x+h) - f(x) }{ h } \mright)
\end{equation*}
- However it can always be changed with the \key{style-inf} key.
+ However it can always be changed with the \key{style-inf} key.
\end{function}
\begin{function}{\mdv}[updated=v1.1]
@@ -1990,16 +2000,34 @@ indent_length "2"
\noindent respectively. The key's default value is \default.
\end{option}
+ \begin{option}{switch-sort}[new = 1.2]
+ \begin{values}[default = true]
+ true, false
+ \end{values}
+ The sorting algorithm of the mixed order is turned on when given the value \val{true} i.e. the methods given in \keyval*{sort-method}{\dots} are applied. Likewise, the sorting algorithm is turned off when given the value \val{false} i.e. the terms in the mixed order are ordered by first appearance in \keyval*{order}{\dots}. As an example, compare below where the option is turned on (\val{true}) and off (\val{false})
+
+ \begin{example}
+ \pdv[switch-sort=false, order={a+b,2kn-d,2-2b}]{f}{x,y,z} \\
+ \pdv[switch-sort=true, order={a+b,2kn-d,2-2b}]{f}{x,y,z}
+ \end{example}
+
+ \noindent respectively. The key's default value is \default.
+ \end{option}
+
\subsubsection*{Sort}
The keys given in this subsection will be briefly described here and a in-depth description will be given in \cref{ssec:overall_order}.
- \begin{option}{sort-method}[updated = v1.0]
+ \begin{option}{sort-method}[updated = v1.2]
\begin{values}[default = {sign, symbol, abs}]
- abs, number, sign, symbol
+ abs, lexical, number, sign, symbol
\end{values}
- This key sets the sorting method behind the mixed order using build-in algorithms. The symbolic terms in the mixed order are sorted by their sign, symbolic length, numerical value and absolute value by the \val{sign}, \val{symbol}, \val{number} and \val{abs} algorithms, respectively. The key takes its input as a comma-separated list of values, accepting up to three values e.g.
+ This key sets the sorting method behind the mixed order using build-in algorithms. The symbolic terms in the mixed order are sorted by their sign, symbolic length, numerical value and absolute value by the \val{sign}, \val{symbol}, \val{number} and \val{abs} algorithms, respectively. The value \val{lexical} sorts the terms by lexicographical order i.e. alphabetically. The key takes its input as a comma-separated list of values, accepting up to three values e.g.
\begin{example}
+ \pdv[sort-method=abs, order={c+kn,-b+2a}]{f}{x,y} \\
+ \pdv[sort-method=lexical, order={c+kn,-b+2a}]{f}{x,y} \\
+ \pdv[sort-method=number, order={c+kn,-b+2a}]{f}{x,y} \\
+ \pdv[sort-method=symbol, order={c+kn,-b+2a}]{f}{x,y} \\
\pdv[sort-method=sign, order={c+kn,-b+2a}]{f}{x,y} \\
\pdv[sort-method={sign,symbol}, order={c+kn,-b+2a}]{f}{x,y} \\
\pdv[sort-method={sign,symbol,abs}, order={c+kn,-b+2a}]{f}{x,y}
@@ -2033,6 +2061,13 @@ indent_length "2"
The sorting algorithm \val{abs} sorts the terms by their absolute value in a descending manner. If the value \val{true} is used, then the terms will be sorted in an ascending manner instead. See \cref{ssec:sort-reverse} for more information.
\end{option}
+ \begin{option}{sort-lexical-reverse}[new = v1.2]
+ \begin{values}[default = false]
+ true, false
+ \end{values}
+ The sorting algorithm \val{lexical} sorts the terms in lexicographical order according to their character code i.e. alphabetically. If the value \val{true} is used, then the terms will be sorted in reverse lexicographical order instead. See \cref{ssec:sort-reverse} for more information.
+ \end{option}
+
\begin{option}{sort-number-reverse}[new = v1.0]
\begin{values}[default = false]
true, false
@@ -2104,7 +2139,7 @@ indent_length "2"
Sets the order of differentiation for each variable as a comma separated list of values.
\end{option}
- \bigskip\bigskip
+ \clearpage
\begin{option}{mixed-order, mixord}[cat=misc, new = v1.0]
\begin{values}[default = 1]
@@ -2137,7 +2172,6 @@ indent_length "2"
\odif[style-notation=single, order={n,1,2}]{x,y,z,t} \\
\odif[style-notation=mixed, order={n,1,2}]{x,y,z,t}
\end{example}
-
\end{option}
\begin{option}{style-notation-*}
@@ -2208,8 +2242,6 @@ indent_length "2"
This key sets the math space that is inserted in the infinitesimal's power left to the order. It is only inserted when the mixed order is different from \num{1}. The key's default value is \default{} \texttt{mu}.
\end{option}
- \clearpage
-
\begin{option}{sep-inf-var}
\begin{values}[default = 0]
\meta{cs-number}, \marg{mspace}, \marg{delimiter}
@@ -2370,10 +2402,11 @@ indent_length "2"
A unique feature of this package is that the sorting method behind the mixed order may be changed using built-in algorithms and there are currently four available: \val{abs}, \val{number}, \val{sign} and \val{symbol}. The algorithms have been chosen such that it the terms in the mixed order may be arranged in many ways with as few algorithms as possible to suit your liking. A sorting method may consist of up to three algorithms which are applied in layers.
\begin{itemize}
- \item The sorting algorithm \val{sign} separates the positive and negative terms, and puts the positive terms before the negative terms in the mixed order. The option \keyval{sort-sign-reverse}{true} reverses ordering is reversed such that the negative terms appear before the positive terms.
- \item The sorting algorithm \val{symbol} separates the terms by their symbolic length, where the terms are sorted in a descending manner according to their length. The option \keyval{sort-symbol-reverse}{true} sorts the terms in a ascending manner instead.
- \item The sorting by \val{abs} separates the terms by their absolute value, where the terms are ordered in a descending manner. The option \keyval{sort-abs-reverse}{true} sorts the terms in an ascending manner instead.
- \item The sorting by \val{number} separates the terms by their numerical value, where the terms are ordered in a descending manner. The option \keyval{sort-number-reverse}{true} sort the terms in an ascending manner instead.
+ \item The sorting algorithm \val{sign} separates the positive and negative terms, and puts the positive terms before the negative terms in the mixed order. The option \keyval{sort-sign-reverse}{true} reverses ordering such that the negative terms appear before the positive terms.
+ \item The sorting algorithm \val{symbol} sorts the terms in a descending manner according to their length. The option \keyval{sort-symbol-reverse}{true} sorts the terms in a ascending manner instead.
+ \item The sorting by \val{abs} sorts the terms in a descending manner. The option \keyval{sort-abs-reverse}{true} sorts the terms in an ascending manner instead.
+ \item The sorting by \val{number} sorts the terms in a descending manner. The option \keyval{sort-number-reverse}{true} sort the terms in an ascending manner instead.
+ \item The sorting by \val{lexical} sorts the terms in a lexicographical order that is alphabetically. The option \keyval{sort-number-reverse}{true} sort the terms in reverse lexicographical ordering.
\end{itemize}
When using the option \keyval{sort-method}{\{...\}}, the number of algorithms determines the number of layers e.g. \keyval*{sort-method}{sign,symbol} is a sorting method with two layers, where the algorithms \val{sign} and \val{symbol} are applied in layer \num{1} and layer \num{2}, respectively. E.i the \val{sign} algorithm splits the terms into two groups, one with positive terms and one with negative terms. Then the \val{symbol} algorithm will sorts the terms within each groups according to the terms symbolic length. The mixed order is then formed by combining these two groups.
@@ -2460,9 +2493,7 @@ indent_length "2"
as expected.
\subsection{The numerical term} \label{ssec:sort-numerical}
- With the symbolic part of the mixed order treated, it is time to look at the numerical term\footref{foot:numerical-term} which have a symbolic of zero. For this reason it is treated differently than the symbolic terms.
-
- The numerical term can be placed either at the beginning or at the end of the mixed order with the values \val{first} and \val{last}, respectively. The package can also determine where to place the numerical term with the value \val{auto}. Compare below
+ With the symbolic part of the mixed order treated, it is time to look at the numerical term\footref{foot:numerical-term} which have a symbolic of zero. For this reason it is treated differently than the symbolic terms. The numerical term can be placed either at the beginning or at the end of the mixed order with the values \val{first} and \val{last}, respectively. The package can also determine where to place the numerical term with the value \val{auto}. Compare below
\begin{align*}
\text{\inlinecode{sort-numerical=auto:}} &&
\pdv[order={\beta, 2}, sort-numerical=auto]{f}{x,y} &&
@@ -2476,19 +2507,21 @@ indent_length "2"
\text{\inlinecode{sort-numerical=symbolic:}} &&
\pdv[order={\beta, 2}, sort-numerical=symbolic]{f}{x,y} && \pdv[order={\beta, -2}, sort-numerical=symbolic]{f}{x,y} && \pdv[order={-\beta, 2}, sort-numerical=symbolic]{f}{x,y} && \pdv[order={-\beta, -2}, sort-numerical=symbolic]{f}{x,y}
\end{align*}
- These three options should satisfy every needs.
+ These four options should satisfy every needs.
\subsection{Reversing the sort algorithm} \label{ssec:sort-reverse}
- The reverse keys serves to reverse the ordering of the terms by the sorting algorithms. This allows for even greater flexibility over the sorting method. So if the default ordering of an algorithm is not wished it may be reversed with the corresponding reverse key. For example, the \val{sign} algorithm places the positive terms before the negative terms, but is opposite with \keyval{sort-sign-reverse}{true}. The reverse keys in action are shown below (\keyval[index=false]{sort-method}{\meta{1 algorithm only}} is also used to better show off the reverse functionality)
+ The reverse keys serves to reverse the ordering of the sorting algorithms. This allows for even greater flexibility over the sorting method. So if the default ordering of an algorithm is not wished it may be reversed with the corresponding reverse key. The reverse keys in action are shown below (\keyval[index=false]{sort-method}{\meta{1 algorithm only}} is also used to better show off the reverse functionality)
\begin{align*}
- \text{\inlinecode{sort-abs-reverse=false:}} && \pdv[sort-method={abs}, sort-abs-reverse=false, order={2a, -3b}]{f}{x,y} &&
- \text{\inlinecode{sort-abs-reverse=true:}} && \pdv[sort-method={abs}, sort-abs-reverse=true, order={2a, -3b}]{f}{x,y} \\
- \text{\inlinecode{sort-number-reverse=false:}} && \pdv[sort-method={number}, sort-number-reverse=false, order={2a, -3b}]{f}{x,y} &&
- \text{\inlinecode{sort-number-reverse=true:}} && \pdv[sort-method={number}, sort-number-reverse=true, order={2a, -3b}]{f}{x,y} \\
- \text{\inlinecode{sort-sign-reverse=false:}} && \pdv[sort-method={sign}, sort-sign-reverse=false, order={a, -b}]{f}{x,y} &&
- \text{\inlinecode{sort-sign-reverse=true:}} && \pdv[sort-method={sign}, sort-sign-reverse=true, order={a, -b}]{f}{x,y} \\
- \text{\inlinecode{sort-symbol-reverse=false:}} && \pdv[sort-method={symbol}, sort-symbol-reverse=false, order={ab, c}]{f}{x,y} &&
- \text{\inlinecode{sort-symbol-reverse=true:}} && \pdv[sort-method={symbol}, sort-symbol-reverse=true, order={ab, c}]{f}{x,y}
+ \text{\inlinecode{sort-abs-reverse=false:}} && \pdv[sort-method={abs}, sort-abs-reverse=false, order={2a, -3b}]{f}{x,y} &&
+ \text{\inlinecode{sort-abs-reverse=true:}} && \pdv[sort-method={abs}, sort-abs-reverse=true, order={2a, -3b}]{f}{x,y} \\
+ \text{\inlinecode{sort-number-reverse=false:}} && \pdv[sort-method={number}, sort-number-reverse=false, order={2a, -3b}]{f}{x,y} &&
+ \text{\inlinecode{sort-number-reverse=true:}} && \pdv[sort-method={number}, sort-number-reverse=true, order={2a, -3b}]{f}{x,y} \\
+ \text{\inlinecode{sort-sign-reverse=false:}} && \pdv[sort-method={sign}, sort-sign-reverse=false, order={a, -b}]{f}{x,y} &&
+ \text{\inlinecode{sort-sign-reverse=true:}} && \pdv[sort-method={sign}, sort-sign-reverse=true, order={a, -b}]{f}{x,y} \\
+ \text{\inlinecode{sort-symbol-reverse=false:}} && \pdv[sort-method={symbol}, sort-symbol-reverse=false, order={ab, c}]{f}{x,y} &&
+ \text{\inlinecode{sort-symbol-reverse=true:}} && \pdv[sort-method={symbol}, sort-symbol-reverse=true, order={ab, c}]{f}{x,y} \\
+ \text{\inlinecode{sort-lexical-reverse=false:}} && \pdv[sort-method={lexical}, sort-lexical-reverse=false, order={a, c, b}]{f}{x,y,z} &&
+ \text{\inlinecode{sort-lexical-reverse=true:}} && \pdv[sort-method={lexical}, sort-lexical-reverse=true, order={a, c, b}]{f}{x,y,z} \\
\end{align*}
\subsection{Mixed order override}
@@ -2632,6 +2665,13 @@ indent_length "2"
\item The package no longer uses \cs{symup} which have been replaced with \cs{mathrm} for simplicity
\item If \pkg{mleftright} is loaded then the default value of \key[index=false]{scale-auto} is \val{mleftmright}
\end{change}
+ \begin{change}[version = 1.2, date = 2022-07-09, beta = false]
+ \item Code clean-up and optimisation that significantly speeds up usage of the package
+ \item Added new sorting algorithm \keyval[index=false]{sort-method}{lexical} that sorts terms alphabetically
+ \item Added the option \key[index=false]{sort-lexical-reverse}
+ \item Added the option \key[index=false]{switch-sort} that turns on/off the sorting algorithm of the mixed order
+ \item Fixed bug concerning \keyval[index=false]{scale-\meta{\dots}}{none} when the corresponding delimiter option contained a period.
+ \item Fixed documentation errors
+ \end{change}
\end{changelog}
-
\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/derivative/derivative.sty b/Master/texmf-dist/tex/latex/derivative/derivative.sty
index a26080b4318..4e9a8308c2b 100644
--- a/Master/texmf-dist/tex/latex/derivative/derivative.sty
+++ b/Master/texmf-dist/tex/latex/derivative/derivative.sty
@@ -1,5 +1,5 @@
% derivative.sty
-% Copyright 2019-2021 Simon Jensen
+% Copyright 2019-2022 Simon Jensen
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
@@ -15,9 +15,9 @@
\NeedsTeXFormat{LaTeX2e}
-\RequirePackage{expl3,xparse}[2018/05/09]
+\RequirePackage{expl3,xparse}[2021/11/07]
\RequirePackage{l3keys2e}
-\ProvidesExplPackage{derivative}{2021/06/03}{1.1}{Nice and easy derivatives and differentials for LaTeX}
+\ProvidesExplPackage{derivative}{2022/07/09}{1.2}{Nice and easy derivatives and differentials for LaTeX}
\bool_new:N \l__deriv_pkg_italic_bool
\bool_new:N \l__deriv_pkg_upright_bool
@@ -25,34 +25,34 @@
\keys_define:nn { deriv/pkg }
{
italic .choice:,
+ italic .usage:n = { load },
italic .default:n = { true },
italic / true .code:n =
- {
- \bool_set_true:N \l__deriv_pkg_italic_bool
- \bool_set_false:N \l__deriv_pkg_upright_bool
- },
+ {
+ \bool_set_true:N \l__deriv_pkg_italic_bool
+ \bool_set_false:N \l__deriv_pkg_upright_bool
+ },
italic / false .code:n =
- {
- \bool_set_false:N \l__deriv_pkg_italic_bool
- \bool_set_true:N \l__deriv_pkg_upright_bool
- },
- italic / unknown .code:n =
- { \msg_error:nnx { deriv } { boolean-values-only } \l_keys_key_str },
-
+ {
+ \bool_set_false:N \l__deriv_pkg_italic_bool
+ \bool_set_true:N \l__deriv_pkg_upright_bool
+ },
+ italic / unknown .code:n = { \msg_error:nnx { deriv } { boolean-values-only } \l_keys_key_str },
+
upright .choice:,
+ upright .usage:n = { load },
upright .default:n = { true },
upright / true .code:n =
- {
- \bool_set_true:N \l__deriv_pkg_upright_bool
- \bool_set_false:N \l__deriv_pkg_italic_bool
- },
+ {
+ \bool_set_true:N \l__deriv_pkg_upright_bool
+ \bool_set_false:N \l__deriv_pkg_italic_bool
+ },
upright / false .code:n =
- {
- \bool_set_false:N \l__deriv_pkg_upright_bool
- \bool_set_true:N \l__deriv_pkg_italic_bool
- },
- upright / unknown .code:n =
- { \msg_error:nnx { deriv } { boolean-values-only } \l_keys_key_str },
+ {
+ \bool_set_false:N \l__deriv_pkg_upright_bool
+ \bool_set_true:N \l__deriv_pkg_italic_bool
+ },
+ upright / unknown .code:n = { \msg_error:nnx { deriv } { boolean-values-only } \l_keys_key_str },
upright .initial:n = true,
}
@@ -60,33 +60,15 @@
%%%%% Useful conditionals %%%%%
-\prg_new_conditional:Npnn \__deriv_if_pkg:n #1 { p, TF }
-{
- \@ifpackageloaded{unicode-math}
- { \prg_return_true: }
- { \prg_return_false: }
-}
-
-\prg_new_conditional:Npnn \__deriv_if_novalue:n #1 { T , F , TF }
+\prg_new_conditional:Npnn \__deriv_if_value:n #1 { T, TF }
{
\tl_if_novalue:nTF {#1}
- { \prg_return_true: }
+ { \prg_return_false: }
{
\tl_if_blank:nTF {#1}
- { \prg_return_true: }
- { \prg_return_false: }
- }
-}
-
-\prg_new_conditional:Npnn \__deriv_if_novalue_and:nn #1 #2 { F, TF }
-{
- \__deriv_if_novalue:nTF {#1}
- {
- \__deriv_if_novalue:nTF {#2}
- { \prg_return_true: }
- { \prg_return_false: }
+ { \prg_return_false: }
+ { \prg_return_true: }
}
- { \prg_return_false: }
}
\prg_new_conditional:Npnn \__deriv_show_order:N #1 { T, TF }
@@ -96,67 +78,35 @@
{ \prg_return_true: }
}
-\cs_new:Npn \__deriv_case:n #1
-{ \exp:w \__deriv_case_begin:nTF {#1} { } { } }
-
-\cs_new:Npn \__deriv_case:nT #1#2
-{ \exp:w \__deriv_case_begin:nTF {#1} {#2} { } }
-
-\cs_new:Npn \__deriv_case:nF #1#2
-{ \exp:w \__deriv_case_begin:nTF {#1} { } {#2} }
-
-\cs_new:Npn \__deriv_case:nTF #1
-{ \exp:w \__deriv_case_begin:nTF {#1} }
-
-\cs_new:Npn \__deriv_case_begin:nTF #1#2#3
-{ \__deriv_case:w #1 \c_true_bool { } \q_mark {#2} \q_mark {#3} \q_stop }
-
-\cs_new:Npn \__deriv_case:w #1#2
-{
- \bool_if:nTF {#1}
- { \__deriv_case_end:nw {#2} }
- { \__deriv_case:w }
-}
-
-\cs_new:Npn \__deriv_case_end:nw #1#2#3 \q_mark #4#5 \q_stop
-{ \exp_end: #1 #4 }
-
%%%%% Variables: derivatives %%%%%
-\tl_new:N \l__deriv_cs_name_tl
-\tl_new:N \l__deriv_derivset_tl
+\tl_new:N \l__deriv_dv_denom_tl
-\seq_new:N \l__deriv_new_var_seq
-\seq_new:N \l__deriv_rubber_seq
+\seq_new:N \l__deriv_dv_var_seq
+\seq_new:N \l__deriv_dv_order_seq
-\prop_new:N \l__deriv_tmp_keys_prop
-\seq_new:N \l__deriv_tmp_keys_seq
-\tl_new:N \l__deriv_tmp_keys_tl
+\seq_new:N \l__deriv_dv_variant_seq
%%%%% Variables: differential %%%%%
\seq_new:N \l__deriv_i_var_seq
-\seq_new:N \l__deriv_i_orders_seq
-\tl_new:N \l__deriv_i_tmpa_tl
+\seq_new:N \l__deriv_i_order_seq
\tl_new:N \l__deriv_i_denom_tl
\seq_new:N \l__deriv_i_variant_seq
%%%%% Variables: other %%%%%
-
-\seq_new:N \l__deriv_dv_variant_seq
-\seq_new:N \l__deriv_add_var_bool_seq
+\tl_new:N \l__deriv_cs_name_tl
+\tl_new:N \l__deriv_derivset_tl
\tl_new:N \l__deriv_tmpa_tl
\tl_new:N \l__deriv_tmpb_tl
\tl_new:N \l__deriv_tmpc_tl
\seq_new:N \l__deriv_tmpa_seq
-\tl_new:N \l__deriv_dv_denom_tl
-
-\seq_new:N \l__deriv_dv_var_seq
-\seq_new:N \l__deriv_dv_order_seq
-\seq_new:N \l__deriv_dv_mo_seq
+\seq_new:N \l__deriv_new_var_seq
+\seq_new:N \l__deriv_rubber_seq
+\seq_new:N \l__deriv_add_var_bool_seq
\int_new:N \l__deriv_vmo_int
@@ -168,27 +118,20 @@
\seq_new:N \l__deriv_input_seq
\seq_new:N \l__deriv_extract_seq
-\seq_new:N \l__deriv_unsorted_seq
+\seq_new:N \l__deriv_permutation_seq
\seq_new:N \l__deriv_sorted_seq
-
\seq_new:N \l__deriv_symbol_seq
\seq_new:N \l__deriv_number_seq
-\seq_new:N \l__deriv_rebuild_seq
+\int_new:N \l__deriv_var_count_int
\int_new:N \l__deriv_tmpa_int
\int_new:N \l__deriv_tmpb_int
\int_new:N \l__deriv_numerical_int
-\int_new:N \l__deriv_sort_counter_int
\int_new:N \l__deriv_sort_max_int
-\int_new:N \l__deriv_position_int
-\int_new:N \l__deriv_rebuild_int
-
-\bool_new:N \l__deriv_tmpa_bool
-
-\regex_const:Nn \c__deriv_pattern_regex { \A([\+\-]?\d*)(.*) }
\regex_const:Nn \c__deriv_cs_numbers_regex { \A\-?\d+(?:,\d+){0,2}\Z }
+\tl_const:Nn \c__deriv_digits_tl {-1234567890}
%%%%% default values %%%%%
@@ -223,12 +166,14 @@
sep-eval-sp = 0,
switch-* = false,
switch-/ = false,
+ switch-sort = true,
sort-method = {sign, symbol, abs},
sort-numerical = auto,
sort-abs-reverse = false,
sort-number-reverse = false,
sort-sign-reverse = false,
sort-symbol-reverse = false,
+ sort-lexical-reverse = false,
fun = false,
frac = false,
var = none,
@@ -286,16 +231,16 @@
\keys_define:nn { deriv/dv/#1 }
{
style-inf .tl_set:c = { l__deriv_dv_#1_style_inf_tl },
- style-var .tl_set:c = { l__deriv_dv_#1_style_var_tl },
+ style-var .code:n = { \__deriv_set_style_var:nn {#1} {##1} },
style-frac .cs_set:cp = { __deriv_dv_#1_style_frac:nn } {##1},
style-frac-/ .cs_set:cp = { __deriv_dv_#1_style_frac_slash:nn } {##1},
- scale-eval .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_dv_#1_scale_eval_tl } {##1} },
- scale-eval-/ .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_dv_#1_scale_eval_slash_tl } {##1} },
- scale-fun .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_dv_#1_scale_fun_tl } {##1} },
- scale-var .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_dv_#1_scale_var_tl } {##1} },
- scale-frac .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_dv_#1_scale_frac_tl } {##1} },
- scale-frac-/ .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_dv_#1_scale_frac_slash_tl } {##1} },
+ scale-eval .choices:nn = { auto, none, big, Big, bigg, Bigg } { \__deriv_set_scale:nnn {dv_#1} {##1} { eval } },
+ scale-eval-/ .choices:nn = { auto, none, big, Big, bigg, Bigg } { \__deriv_set_scale:nnn {dv_#1} {##1} { eval_slash } },
+ scale-fun .choices:nn = { auto, none, big, Big, bigg, Bigg } { \__deriv_set_scale:nnn {dv_#1} {##1} { fun } },
+ scale-var .choices:nn = { auto, none, big, Big, bigg, Bigg } { \__deriv_set_scale:nnn {dv_#1} {##1} { var } },
+ scale-frac .choices:nn = { auto, none, big, Big, bigg, Bigg } { \__deriv_set_scale:nnn {dv_#1} {##1} { frac } },
+ scale-frac-/ .choices:nn = { auto, none, big, Big, bigg, Bigg } { \__deriv_set_scale:nnn {dv_#1} {##1} { frac_slash } },
delims-eval .tl_set:c = { l__deriv_dv_#1_delims_eval_tl },
delims-eval-/ .tl_set:c = { l__deriv_dv_#1_delims_eval_slash_tl },
@@ -318,6 +263,7 @@
switch-* .bool_set:c = { l__deriv_dv_#1_switch_star_bool },
switch-/ .bool_set:c = { l__deriv_dv_#1_switch_slash_bool },
+ switch-sort .bool_set:c = { l__deriv_dv_#1_switch_sort_bool },
fun .bool_set:c = { l__deriv_dv_#1_misc_fun_bool },
frac .bool_set:c = { l__deriv_dv_#1_misc_frac_bool },
@@ -329,27 +275,94 @@
mixed-order .tl_set:c = { l__deriv_dv_#1_misc_mixed_order_tl },
mixord .tl_set:c = { l__deriv_dv_#1_misc_mixed_order_tl },
- sort-method .clist_set:c = { l__deriv_dv_#1_sort_method_clist },
+ sort-method .code:n = { \__deriv_set_sort_method:nn {#1} {##1} },
sort-numerical .choices:nn = { auto, first, last, symbolic } { \tl_set:cn { l__deriv_dv_#1_sort_numerical_tl } {##1} },
- sort-abs-reverse .bool_set:c = { l__deriv_dv_#1_sort_abs_reverse_bool },
- sort-number-reverse .bool_set:c = { l__deriv_dv_#1_sort_number_reverse_bool },
- sort-sign-reverse .bool_set:c = { l__deriv_dv_#1_sort_sign_reverse_bool },
- sort-symbol-reverse .bool_set:c = { l__deriv_dv_#1_sort_symbol_reverse_bool }
+ sort-abs-reverse .bool_set:c = { l__deriv_dv_#1_sort_abs_reverse_bool },
+ sort-number-reverse .bool_set:c = { l__deriv_dv_#1_sort_number_reverse_bool },
+ sort-sign-reverse .bool_set:c = { l__deriv_dv_#1_sort_sign_reverse_bool },
+ sort-symbol-reverse .bool_set:c = { l__deriv_dv_#1_sort_symbol_reverse_bool },
+ sort-lexical-reverse .bool_set:c = { l__deriv_dv_#1_sort_lexical_reverse_bool },
+ }
+}
+% variant, value
+\cs_new:Npn \__deriv_set_sort_method:nn #1 #2
+{
+ \seq_clear:c { l__deriv_dv_#1_sort_method_seq }
+ \seq_set_from_clist:Nn \l__deriv_tmpa_seq {#2}
+ \seq_map_indexed_inline:Nn \l__deriv_tmpa_seq
+ {
+ \str_case:nn {##2}
+ {
+ { sign } { \seq_put_right:cn { l__deriv_dv_#1_sort_method_seq } { \__deriv_sort_sign:n } }
+ { symbol } { \seq_put_right:cn { l__deriv_dv_#1_sort_method_seq } { \__deriv_sort_symbol:n } }
+ { abs } { \seq_put_right:cn { l__deriv_dv_#1_sort_method_seq } { \__deriv_sort_abs:n } }
+ { number } { \seq_put_right:cn { l__deriv_dv_#1_sort_method_seq } { \__deriv_sort_number:n } }
+ { lexical } { \seq_put_right:cn { l__deriv_dv_#1_sort_method_seq } { \__deriv_sort_lexical:n } }
+ }
+ \int_compare:nNnT {##1} = { 3 } { \seq_map_break: }
+ }
+}
+% variant, value
+\cs_new:Npn \__deriv_set_style_var:nn #1 #2
+{
+ \str_case:nn {#2}
+ {
+ { single } { \tl_set:cn { l__deriv_dv_#1_style_var_tl } { \__deriv_dv_build_single:NNNn } }
+ { multiple } { \tl_set:cn { l__deriv_dv_#1_style_var_tl } { \__deriv_dv_build_multiple:NNNn } }
+ }
+}
+% varaint, value, name
+\cs_new:Npn \__deriv_set_style_notation:nnn #1 #2 #3
+{
+ \str_case:nn {#2}
+ {
+ { single } { \tl_set:cn { l__deriv_i_#1_style_notation#3_tl } { \__deriv_i_build_single:NNNnn } }
+ { multiple } { \tl_set:cn { l__deriv_i_#1_style_notation#3_tl } { \__deriv_i_build_multiple:NNNnn } }
+ { mixed } { \tl_set:cn { l__deriv_i_#1_style_notation#3_tl } { \__deriv_i_build_mixed:NNNnn } }
+ }
+}
+% dv_variant, scale, name
+\cs_new:Npn \__deriv_set_scale:nnn #1 #2 #3
+{
+ \str_case:nnF {#2}
+ {
+ { auto } { \tl_set:cn { l__deriv_#1_scale_#3_tl } { \__deriv_scale_auto:nnn } }
+ { none } { \tl_set:cn { l__deriv_#1_scale_#3_tl } { \__deriv_scale_none:nnn } }
+ }
+ { \tl_set:cn { l__deriv_#1_scale_#3_tl } { \__deriv_scale_big:nnnn {#2} } }
+}
+% muskip, tl
+\cs_new:Npn \__deriv_set_rubber_length:Nn #1 #2
+{
+ \regex_match:NnTF \c__deriv_cs_numbers_regex {#2}
+ {
+ \str_case:nnF {#2}
+ {
+ { 0 } { \tl_clear:N #1 }
+ { 0,0 } { \tl_clear:N #1 }
+ { 0,0,0 } { \tl_clear:N #1 }
+ }
+ {
+ \seq_set_split:Nnn \l__deriv_rubber_seq { , } {#2}
+ \tl_set:Nf #1 { \seq_use:Nnnn \l__deriv_rubber_seq { mu plus } { mu plus } { mu minus } mu }
+ \tl_put_left:Nn #1 { \mskip }
+ }
}
+ { \tl_set:Nn #1 {#2} }
}
%%%%%% Key-val: derivatives %%%%%%
-
+% variant
\cs_new:Npn \__deriv_i_define_keys:n #1
{
\keys_define:nn { deriv/i/#1 }
{
style-inf .tl_set:c = { l__deriv_i_#1_style_inf_tl },
- style-notation .tl_set:c = { l__deriv_i_#1_style_notation_tl },
- style-notation-* .tl_set:c = { l__deriv_i_#1_style_notation_star_tl },
+ style-notation .code:n = { \__deriv_set_style_notation:nnn {#1} {##1} {} },
+ style-notation-* .code:n = { \__deriv_set_style_notation:nnn {#1} {##1} { _star } },
- scale-var .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_i_#1_scale_var_tl } {##1} },
- scale-var-* .choices:nn = { auto, none, big, Big, bigg, Bigg } { \tl_set:cn { l__deriv_i_#1_scale_var_star_tl } {##1} },
+ scale-var .choices:nn = { auto, none, big, Big, bigg, Bigg } { \__deriv_set_scale:nnn {i_#1} {##1} { var } },
+ scale-var-* .choices:nn = { auto, none, big, Big, bigg, Bigg } { \__deriv_set_scale:nnn {i_#1} {##1} { var_slash } },
delims-var .tl_set:c = { l__deriv_i_#1_delims_var_tl },
delims-var-* .tl_set:c = { l__deriv_i_#1_delims_var_star_tl },
@@ -430,9 +443,6 @@
{ \__deriv_preamble_aux:Vnn #1 { style-inf={#3} } {#5} }
{ \__deriv_preamble_aux:Vnn #1 { style-inf={#3}, #4} {#5} }
}
-% variant, inf, dv/i
-\cs_new_protected:Npn \deriv_set_style_inf:nnn #1 #2 #3
-{ \__deriv_set_default:nnn {#1} { style-inf = {#2} } {#3} }
% variant, key-value, dv/i
\cs_new_protected:Npn \__deriv_preamble_aux:nnn #1 #2 #3
{
@@ -459,10 +469,10 @@
\__deriv_new:nnnn { tl } {dv_#1} { scale } { eval, eval_slash, fun, var, frac, frac_slash }
\__deriv_new:nnnn { tl } {dv_#1} { delims } { eval, eval_slash, fun, var, frac, frac_slash }
\__deriv_new:nnnn { tl } {dv_#1} { sep } { inf_ord, inf_fun, ord_fun, frac_fun, inf_var, var_ord, var_inf, ord_inf, eval_sb, eval_sp }
- \__deriv_new:nnnn { bool } {dv_#1} { switch } { star, slash }
- \__deriv_new:nnnn { clist } {dv_#1} { sort } { method }
+ \__deriv_new:nnnn { bool } {dv_#1} { switch } { star, slash, sort }
+ \__deriv_new:nnnn { seq } {dv_#1} { sort } { method }
\__deriv_new:nnnn { tl } {dv_#1} { sort } { numerical }
- \__deriv_new:nnnn { bool } {dv_#1} { sort } { abs_reverse, sign_reverse, symbol_reverse, number_reverse }
+ \__deriv_new:nnnn { bool } {dv_#1} { sort } { abs_reverse, sign_reverse, symbol_reverse, number_reverse, lexical_reverse }
\__deriv_new:nnnn { bool } {dv_#1} { misc } { fun, frac }
\__deriv_new:nnnn { clist } {dv_#1} { misc } { var }
@@ -489,30 +499,17 @@
{
\tl_if_novalue:nTF {#2}
{ \prop_set_eq:cc { l__deriv_#3_#1_user_keys_prop } { c__deriv_#3_pkg_keys_prop } }
- { \__deriv_update_prop:cn { l__deriv_#3_#1_user_keys_prop } {#2} }
+ { \prop_put_from_keyval:cn { l__deriv_#3_#1_user_keys_prop } {#2} }
- \__deriv_set_default_from_prop:Nc \l__deriv_tmp_keys_tl { l__deriv_#3_#1_user_keys_prop }
- \__deriv_set_default_aux:Vnn \l__deriv_tmp_keys_tl {#1} {#3}
-}
-% user-prop, key-val
-\cs_new_protected:Npn \__deriv_update_prop:Nn #1 #2
-{
- \prop_set_from_keyval:Nn \l__deriv_tmp_keys_prop {#2}
- \prop_map_inline:Nn \l__deriv_tmp_keys_prop { \prop_put:Nnn #1 {##1} {##2} }
-}
-% user-prop
-\cs_new_protected:Npn \__deriv_set_default_from_prop:NN #1 #2
-{
- \seq_clear:N \l__deriv_tmp_keys_seq
- \prop_map_inline:Nn #2 { \seq_put_right:Nn \l__deriv_tmp_keys_seq { ##1 = {##2} } }
- \tl_set:Nx #1 { \seq_use:Nn \l__deriv_tmp_keys_seq { , } }
+ \__deriv_set_default_auxi:cnn { l__deriv_#3_#1_user_keys_prop } {#1} {#3}
+ \keys_set:nn { deriv/#3/#1 } { default }
}
+% prop-key-val, variant, dv/i
+\cs_new_protected:Npn \__deriv_set_default_auxi:Nnn #1 #2 #3
+{ \__deriv_set_default_auxii:fnn { \prop_to_keyval:N #1 } {#2} {#3} }
% key-val, variant, dv/i
-\cs_new_protected:Npn \__deriv_set_default_aux:nnn #1 #2 #3
-{
- \keys_define:nn { deriv/#3/#2 } { default .meta:n = {#1} }
- \keys_set:nn { deriv/#3/#2 } { default }
-}
+\cs_new_protected:Npn \__deriv_set_default_auxii:nnn #1 #2 #3
+{ \keys_define:nn { deriv/#3/#2 } { default .meta:n = {#1} } }
% new/delare/renew/provide, variant, macro
\cs_new_protected:Npn \deriv_dv_define:Nnn #1 #2 #3
{
@@ -608,7 +605,8 @@
{ \__deriv_dv_denominator:n {#1} }
}
}
-}% variant, function
+}
+% variant, function
\cs_new_protected:Npn \__deriv_dv_numerator_fun:nn #1 #2
{
\__deriv_insert_inf:n {#1}
@@ -636,28 +634,18 @@
\seq_set_from_clist:Nn \l__deriv_dv_var_seq {#3}
\seq_set_from_clist:Nc \l__deriv_dv_order_seq { l__deriv_#2_misc_order_clist }
- \__deriv_dv_choose_var:NNNn \l__deriv_dv_var_seq \l__deriv_dv_order_seq #1 {#2}
-}
-% var-seq, order-seq, denom-tl, variant
-\cs_new_protected:Npn \__deriv_dv_choose_var:NNNn #1 #2 #3 #4
-{
- \exp_args:Nv
- \str_case:nn { l__deriv_#4_style_var_tl }
- {
- { single } { \__deriv_dv_build_single:NNNn #1 #2 #3 {#4} }
- { multiple } { \__deriv_dv_build_multiple:NNNn #1 #2 #3 {#4} }
- }
+ \tl_use:c { l__deriv_#2_style_var_tl } \l__deriv_dv_var_seq \l__deriv_dv_order_seq #1 {#2}
}
% var_seq, order_seq, denom-tl, variant
\cs_new_protected:Npn \__deriv_dv_build_multiple:NNNn #1 #2 #3 #4
{
- \int_set:Nn \l__deriv_tmpa_int { \seq_count:N #1 }
- \__deriv_adjust_ord_seq:NN #1 #2
+ \int_set:Nn \l__deriv_var_count_int { \seq_count:N #1 }
+ \__deriv_adjust_ord_seq:NN \l__deriv_var_count_int #2
\str_if_eq:cNT { l__deriv_#4_misc_mixed_order_tl } 1
{ \__deriv_mixed_order:cNn { l__deriv_#4_misc_mixed_order_tl } #2 {#4} }
- \__deriv_var_bool_seq:cNN { l__deriv_#4_misc_var_clist } \l__deriv_tmpa_seq \l__deriv_tmpa_int
+ \__deriv_var_bool_seq:cNN { l__deriv_#4_misc_var_clist } \l__deriv_tmpa_seq \l__deriv_var_count_int
\seq_map_indexed_inline:Nn #1
{
@@ -671,11 +659,11 @@
\__deriv_show_order:NTF \l__deriv_tmpa_tl
{
\__deriv_insert_ord:Nnn \l__deriv_tmpa_tl {#4} { var_ord }
- \int_compare:nNnF {##1} = { \l__deriv_tmpa_int }
+ \int_compare:nNnF {##1} = { \l__deriv_var_count_int }
{ \__deriv_insert_mskip:nn {#4} { ord_inf } }
}
{
- \int_compare:nNnF {##1} = { \l__deriv_tmpa_int }
+ \int_compare:nNnF {##1} = { \l__deriv_var_count_int }
{ \__deriv_insert_mskip:nn {#4} { var_inf } }
}
}
@@ -684,10 +672,10 @@
% var_seq, order_seq, denom-tl, variant
\cs_new_protected:Npn \__deriv_dv_build_single:NNNn #1 #2 #3 #4
{
- \int_set:Nn \l__deriv_tmpa_int { \seq_count:N #1 }
- \tl_set:Nx \l__deriv_tmpa_tl { \seq_use:Nn #1 { \__deriv_insert_mskip:nn {#4} { var_var } } }
+ \int_set:Nn \l__deriv_var_count_int { \seq_count:N #1 }
+ \tl_set:Nf \l__deriv_tmpa_tl { \seq_use:Nn #1 { \__deriv_insert_mskip:nn {#4} { var_var } } }
- \__deriv_var_bool_seq:cNN { l__deriv_#4_misc_var_clist } \l__deriv_tmpa_seq \l__deriv_tmpa_int
+ \__deriv_var_bool_seq:cNN { l__deriv_#4_misc_var_clist } \l__deriv_tmpa_seq \l__deriv_var_count_int
\seq_pop_left:NN #2 \l__deriv_tmpb_tl
\seq_pop_left:NN \l__deriv_tmpa_seq \l__deriv_tmpc_tl
@@ -705,19 +693,12 @@
% var_seq, order_seq
\cs_new_protected:Npn \__deriv_adjust_ord_seq:NN #1 #2
{
- \int_set:Nn \l__deriv_vmo_int { \seq_count:N #1 - \seq_count:N #2 }
-
+ \int_set:Nn \l__deriv_vmo_int { #1 - \seq_count:N #2 }
\int_compare:nNnF { \l__deriv_vmo_int } = { 0 }
{
\int_compare:nNnTF { \l__deriv_vmo_int } < { 0 }
- {
- \int_step_inline:nn { -1 * \l__deriv_vmo_int }
- { \seq_pop_right:NN #2 \l__deriv_tmpa_tl }
- }
- {
- \int_step_inline:nn { \l__deriv_vmo_int }
- { \seq_put_right:Nn #2 { 1 } }
- }
+ { \int_step_inline:nn { -1*\l__deriv_vmo_int } { \seq_pop_right:NN #2 \l__deriv_tmpa_tl } }
+ { \int_step_inline:nn { \l__deriv_vmo_int } { \seq_put_right:Nn #2 { 1 } } }
}
}
% avd-clist, bool-seq, count
@@ -725,16 +706,10 @@
{
\seq_clear:N #2
\clist_if_in:NnTF #1 { all }
- {
- \exp_args:NNx
- \seq_set_from_clist:Nn #2 { \prg_replicate:nn {#3} { \c_true_bool , } }
- }
+ { \exp_args:NNf \seq_set_from_clist:Nn #2 { \prg_replicate:nn {#3} { \c_true_bool , } } }
{
\clist_if_in:NnTF #1 { none }
- {
- \exp_args:NNx
- \seq_set_from_clist:Nn #2 { \prg_replicate:nn {#3} { \c_false_bool , } }
- }
+ { \exp_args:NNf \seq_set_from_clist:Nn #2 { \prg_replicate:nn {#3} { \c_false_bool , } } }
{
\int_step_inline:nn {#3}
{
@@ -749,7 +724,6 @@
\cs_new_protected:Npn \__deriv_adjust_trailing_ord:NN #1 #2
{
\seq_clear:N \l__deriv_tmpa_seq
- \bool_set_false:N \l__deriv_tmpa_bool
\int_set:Nn \l__deriv_vmo_int { \seq_count:N #2 - \seq_count:N #1 }
\int_compare:nNnT { \l__deriv_vmo_int } < { 0 }
@@ -758,21 +732,15 @@
{ \seq_pop_right:NN #1 \l__deriv_tmpa_tl }
}
- \seq_reverse:N #1
- \seq_map_inline:Nn #1
+ \int_step_inline:nn { \seq_count:N #1 }
{
- \bool_if:NTF \l__deriv_tmpa_bool
- { \seq_put_right:Nn \l__deriv_tmpa_seq {##1} }
+ \seq_pop_right:NN #1 \l__deriv_tmpa_tl
+ \str_if_eq:VnF \l__deriv_tmpa_tl { 1 }
{
- \str_if_eq:nnF {##1} { 1 }
- {
- \seq_put_right:Nn \l__deriv_tmpa_seq {##1}
- \bool_set_true:N \l__deriv_tmpa_bool
- }
+ \seq_put_right:NV #1 \l__deriv_tmpa_tl
+ \prg_break:
}
}
- \seq_set_eq:NN #1 \l__deriv_tmpa_seq
- \seq_reverse:N #1
}
%%%%% infinisimal definition %%%%%
@@ -803,27 +771,16 @@
\seq_set_from_clist:Nn \l__deriv_i_var_seq {#3}
\seq_set_from_clist:Nc \l__deriv_i_order_seq { l__deriv_#2_misc_order_clist }
- \__deriv_i_choose_build:NNNnn \l__deriv_i_var_seq \l__deriv_i_order_seq #1 {#2} {#4}
-}
-% var-seq, order-seq, print-tl, variant, if star
-\cs_new_protected:Npn \__deriv_i_choose_build:NNNnn #1 #2 #3 #4 #5
-{
- \exp_args:Nv
- \str_case:nn { l__deriv_#4_style_notation#5_tl }
- {
- { single } { \__deriv_i_build_single:NNNnn #1 #2 #3 {#4} {#5} }
- { multiple } { \__deriv_i_build_multiple:NNNnn #1 #2 #3 {#4} {#5} }
- { mixed } { \__deriv_i_build_mixed:NNNnn #1 #2 #3 {#4} {#5} }
- }
+ \tl_use:c { l__deriv_#2_style_notation#4_tl } \l__deriv_i_var_seq \l__deriv_i_order_seq #1 {#2} {#4}
}
% var-seq, order-seq, print-tl, variant, if star
\cs_new_protected:Npn \__deriv_i_build_single:NNNnn #1 #2 #3 #4 #5
{
- \int_set:Nn \l__deriv_tmpa_int { \seq_count:N #1 }
- \__deriv_var_bool_seq:cNN { l__deriv_#4_misc_var_clist } \l__deriv_add_var_bool_seq \l__deriv_tmpa_int
+ \int_set:Nn \l__deriv_var_count_int { \seq_count:N #1 }
+ \__deriv_var_bool_seq:cNN { l__deriv_#4_misc_var_clist } \l__deriv_add_var_bool_seq \l__deriv_var_count_int
\__deriv_adjust_trailing_ord:NN #2 #1
- \int_set:Nn \l__deriv_tmpb_int { \seq_count:N #2 }
+ \int_set:Nn \l__deriv_tmpa_int { \seq_count:N #2 }
\seq_map_indexed_inline:Nn #1
{
@@ -831,7 +788,7 @@
\tl_put_right:Nx \l__deriv_tmpb_tl
{
\__deriv_insert_var:Nnnn \l__deriv_tmpa_tl {##2} {#4} {#5}
- \int_compare:nNnF {##1} = { \l__deriv_tmpa_int }
+ \int_compare:nNnF {##1} = { \l__deriv_var_count_int }
{ \__deriv_insert_mskip:nn {#4} { var_var } }
}
}
@@ -840,7 +797,7 @@
\tl_put_right:Nx \l__deriv_tmpc_tl
{
\exp_not:n {##2}
- \int_compare:nNnF {##1} = { \l__deriv_tmpb_int }
+ \int_compare:nNnF {##1} = { \l__deriv_tmpa_int }
{ \__deriv_insert_mskip:nn {#4} { ord_ord } }
}
}
@@ -865,9 +822,9 @@
% var-seq, order-seq, print-tl, variant
\cs_new_protected:Npn \__deriv_i_build_multiple:NNNnn #1 #2 #3 #4 #5
{
- \int_set:Nn \l__deriv_tmpa_int { \seq_count:N #1 }
- \__deriv_var_bool_seq:cNN { l__deriv_#4_misc_var_clist } \l__deriv_add_var_bool_seq \l__deriv_tmpa_int
- \__deriv_adjust_ord_seq:NN #1 #2
+ \int_set:Nn \l__deriv_var_count_int { \seq_count:N #1 }
+ \__deriv_var_bool_seq:cNN { l__deriv_#4_misc_var_clist } \l__deriv_add_var_bool_seq \l__deriv_var_count_int
+ \__deriv_adjust_ord_seq:NN \l__deriv_var_count_int #2
\seq_map_indexed_inline:Nn #1
{
@@ -884,7 +841,7 @@
{ \__deriv_insert_mskip:nn {#4} { inf_var } }
\__deriv_insert_var:Nnnn \l__deriv_tmpb_tl {##2} {#4} {#5}
- \int_compare:nNnF {##1} = { \l__deriv_tmpa_int }
+ \int_compare:nNnF {##1} = { \l__deriv_var_count_int }
{ \__deriv_insert_mskip:nn {#4} { var_inf } }
}
}
@@ -892,9 +849,9 @@
% var-seq, order-seq, print-tl, variant
\cs_new_protected:Npn \__deriv_i_build_mixed:NNNnn #1 #2 #3 #4 #5
{
- \int_set:Nn \l__deriv_tmpa_int { \seq_count:N #1 }
- \__deriv_var_bool_seq:cNN { l__deriv_#4_misc_var_clist } \l__deriv_add_var_bool_seq \l__deriv_tmpa_int
- \__deriv_adjust_ord_seq:NN #1 #2
+ \int_set:Nn \l__deriv_var_count_int { \seq_count:N #1 }
+ \__deriv_var_bool_seq:cNN { l__deriv_#4_misc_var_clist } \l__deriv_add_var_bool_seq \l__deriv_var_count_int
+ \__deriv_adjust_ord_seq:NN \l__deriv_var_count_int #2
\seq_map_indexed_inline:Nn #1
{
@@ -910,7 +867,7 @@
\__deriv_insert_mskip:nn {#4} { inf_var }
\__deriv_insert_var:Nnnn \l__deriv_tmpb_tl {##2} {#4} {#5}
}
- \int_compare:nNnF {##1} = { \l__deriv_tmpa_int }
+ \int_compare:nNnF {##1} = { \l__deriv_var_count_int }
{ \__deriv_insert_mskip:nn {#4} { var_inf } }
}
}
@@ -955,31 +912,7 @@
}
% dv, name
\cs_new:Npn \__deriv_insert_mskip:nn #1 #2
-{
- %[#2]
- \tl_if_empty:cF { l__deriv_#1_sep_#2_tl }
- { \exp_not:v { l__deriv_#1_sep_#2_tl } }
- %\exp_not:v { l__deriv_#1_sep_#2_tl }
-}
-% muskip, length
-\cs_new:Npn \__deriv_set_rubber_length:Nn #1 #2
-{
- \regex_match:NnTF \c__deriv_cs_numbers_regex {#2}
- {
- \str_case_e:nnF {#2}
- {
- { 0 } { \tl_clear:N #1 }
- { 0,0 } { \tl_clear:N #1 }
- { 0,0,0 } { \tl_clear:N #1 }
- }
- {
- \seq_set_split:Nnn \l__deriv_rubber_seq { , } {#2}
- \tl_set:Nf #1 { \seq_use:Nnnn \l__deriv_rubber_seq { mu plus } { mu plus } { mu minus } mu }
- \tl_put_left:Nn #1 { \mskip }
- }
- }
- { \tl_set:Nn #1 {#2} }
-}
+{ \exp_not:v { l__deriv_#1_sep_#2_tl } }
%%%%% Scale, delimiters, evaluation %%%%%
% variable
@@ -1009,63 +942,82 @@
% dv, sub, sup, code-for-fraction
\cs_new:Npn \__deriv_evaluation:nnnn #1 #2 #3 #4
{
- \__deriv_if_novalue_and:nnTF {#2} {#3}
- {#4}
+ \__deriv_if_value:nTF {#2}
{
\__deriv_add_delims:nnn {#1} { eval } {#4}
- \__deriv_if_novalue:nF {#2} { \sb{ \__deriv_insert_mskip:nn {#1} { eval_sb } #2 } }
- \__deriv_if_novalue:nF {#3} { \sp{ \__deriv_insert_mskip:nn {#1} { eval_sp } #3 } }
+ \sb{ \__deriv_insert_mskip:nn {#1} { eval_sb } #2 }
+ \__deriv_if_value:nT {#3}
+ { \sp{ \__deriv_insert_mskip:nn {#1} { eval_sp } #3 } }
+ }
+ {
+ \__deriv_if_value:nTF {#3}
+ {
+ \__deriv_add_delims:nnn {#1} { eval } {#4}
+ \sp{ \__deriv_insert_mskip:nn {#1} { eval_sp } #3 }
+ }
+ {#4}
}
}
% dv, sub, sup, code-for-fraction
\cs_new:Npn \__deriv_evaluation_slash:nnnn #1 #2 #3 #4
{
- \__deriv_if_novalue_and:nnTF {#2} {#3}
- {#4}
+ \__deriv_if_value:nTF {#2}
{
\__deriv_add_delims:nnn {#1} { eval_slash } {#4}
- \__deriv_if_novalue:nF {#2} { \sb{ \__deriv_insert_mskip:nn {#1} { eval_sb } #2 } }
- \__deriv_if_novalue:nF {#3} { \sp{ \__deriv_insert_mskip:nn {#1} { eval_sp } #3 } }
+ \sb{ \__deriv_insert_mskip:nn {#1} { eval_sb } #2 }
+ \__deriv_if_value:nT {#3}
+ { \sp{ \__deriv_insert_mskip:nn {#1} { eval_sp } #3 } }
+ }
+ {
+ \__deriv_if_value:nTF {#3}
+ {
+ \__deriv_add_delims:nnn {#1} { eval_slash } {#4}
+ \sp{ \__deriv_insert_mskip:nn {#1} { eval_sp } #3 }
+ }
+ {#4}
}
}
% dv, name, value
\cs_new:Npn \__deriv_add_delims:nnn #1 #2 #3
+{ \tl_use:c { l__deriv_#1_scale_#2_tl } {#1} {#2} {#3} }
+% dv, name, code
+\cs_new:Npn \__deriv_scale_auto:nnn #1 #2 #3
{
- \__deriv_scale:Nnnnn \__deriv_auto_left:n {#1} {#2} { 1 } { l }
+ \__deriv_auto_left:n \tl_item:cn { l__deriv_#1_delims_#2_tl } { 1 }
#3
- \__deriv_scale:Nnnnn \__deriv_auto_right:n {#1} {#2} { 2 } { r }
+ \__deriv_auto_right:n \tl_item:cn { l__deriv_#1_delims_#2_tl } { 2 }
}
-% dv, name
-\cs_new:Npn \__deriv_scale:Nnnnn #1 #2 #3 #4 #5
+% dv, name, code
+\cs_new:Npn \__deriv_scale_none:nnn #1 #2 #3
{
- \exp_args:Nv \str_case:nnF { l__deriv_#2_scale_#3_tl }
- {
- { auto } { \__deriv_scale_auto:Nnnn #1 {#2} {#3} {#4} }
- { none } { \__deriv_scale_none:nnn {#2} {#3} {#4} }
- }
- { \__deriv_scale_big:nnnn {#2} {#3} {#4} {#5} }
+ \__deriv_dont_use_dot:x { \tl_item:cn { l__deriv_#1_delims_#2_tl } { 1 } }
+ #3
+ \__deriv_dont_use_dot:x { \tl_item:cn { l__deriv_#1_delims_#2_tl } { 2 } }
}
-% left/right, variant, name, number
-\cs_new:Npn \__deriv_scale_auto:Nnnn #1 #2 #3 #4
-{ #1 \tl_item:cn { l__deriv_#2_delims_#3_tl } {#4} }
-% dv, name, number
-\cs_new:Npn \__deriv_scale_none:nnn #1 #2 #3
-{ \str_if_eq:cNF { l__deriv_#1_delims_#2_tl } . { \tl_item:cn { l__deriv_#1_delims_#2_tl } {#3} } }
-% dv, name, number, l/r
+% item
+\cs_new:Npn \__deriv_dont_use_dot:n #1
+{ \str_if_eq:nnF {#1} { . } {#1} }
+% dv, name, code
\cs_new:Npn \__deriv_scale_big:nnnn #1 #2 #3 #4
-{ \tl_use:c { \tl_use:c { l__deriv_#1_scale_#2_tl } #4 } { \tl_item:cn { l__deriv_#1_delims_#2_tl } {#3} } }
-
+{ \__deriv_scale_big_auxi:ncn {#1} { l__deriv_#2_delims_#3_tl } {#4} }
+% scaling, delims, code
+\cs_new:Npn \__deriv_scale_big_auxi:nNn #1 #2 #3
+{
+ \tl_use:c { #1 l } { \tl_item:Nn #2 { 1 } }
+ #3
+ \tl_use:c { #1 r } { \tl_item:Nn #2 { 2 } }
+}
%%%%% Calculation of mixed order %%%%%
-% mixed-order-tl, mixed-order-seq, variant
+% mixed-order-tl, order-seq, variant
\cs_new:Npn \__deriv_mixed_order:NNn #1 #2 #3
{
\__deriv_replace:NN \l__deriv_input_seq #2
- \__deriv_seq_counting:N \l__deriv_input_seq
- \__deriv_combine_seq:Nn \l__deriv_unsorted_seq {#3}
- \__deriv_sort:NNn \l__deriv_sorted_seq \l__deriv_unsorted_seq {#3}
+ \__deriv_seq_counting:NNN \l__deriv_symbol_seq \l__deriv_number_seq \l__deriv_input_seq
+ \__deriv_sort:NNNn \l__deriv_permutation_seq \l__deriv_symbol_seq \l__deriv_number_seq {#3}
+ \__deriv_combine_seq:NNNNn \l__deriv_sorted_seq \l__deriv_permutation_seq \l__deriv_symbol_seq \l__deriv_number_seq {#3}
\__deriv_output:NNNn #1 \l__deriv_sorted_seq \l__deriv_numerical_int {#3}
}
-% input-seq, mixed-order-seq
+% input-seq, order-seq
\cs_new_protected:Npn \__deriv_replace:NN #1 #2
{
\tl_set:Nf \l__deriv_input_tl { \seq_use:Nn #2 { , } }
@@ -1074,29 +1026,38 @@
\tl_replace_all:Nnn \l__deriv_input_tl { - } { ,- }
\tl_replace_all:Nnn \l__deriv_input_tl { + } { , }
- \exp_args:NNV \seq_set_from_clist:Nn #1 \l__deriv_input_tl
+ \seq_set_split:NnV #1 { , } \l__deriv_input_tl
+ \seq_remove_all:Nn #1 {}
}
-% input-seq
-\cs_new_protected:Npn \__deriv_seq_counting:N #1
+% symbol-seq, number-seq, input-seq
+\cs_new_protected:Npn \__deriv_seq_counting:NNN #1 #2 #3
{
- \seq_clear:N \l__deriv_symbol_seq
- \seq_clear:N \l__deriv_number_seq
+ \seq_clear:N #1
+ \seq_clear:N #2
- \seq_map_inline:Nn #1
+ \seq_map_inline:Nn #3
{
\__deriv_extract:NNn \l__deriv_sym_tmpa_tl \l__deriv_num_tmpa_tl {##1}
\seq_if_in:NVTF \l__deriv_symbol_seq \l__deriv_sym_tmpa_tl
- { \__deriv_update_seq:NN \l__deriv_sym_tmpa_tl \l__deriv_num_tmpa_tl }
- { \__deriv_add_to_seq:NN \l__deriv_sym_tmpa_tl \l__deriv_num_tmpa_tl }
+ { \__deriv_update_seq:NNNN #1 #2 \l__deriv_sym_tmpa_tl \l__deriv_num_tmpa_tl }
+ { \__deriv_add_to_seq:NNNN #1 #2 \l__deriv_sym_tmpa_tl \l__deriv_num_tmpa_tl }
}
}
% sym-tl, num-tl, seq-item
\cs_new_protected:Npn \__deriv_extract:NNn #1 #2 #3
{
- \regex_extract_once:NnN \c__deriv_pattern_regex {#3} \l__deriv_extract_seq
- \seq_pop_right:NN \l__deriv_extract_seq #1
- \seq_pop_right:NN \l__deriv_extract_seq #2
+ \int_zero:N \l__deriv_tmpa_int
+ \tl_map_inline:nn {#3}
+ {
+ \tl_if_in:NnTF \c__deriv_digits_tl {##1}
+ { \int_incr:N \l__deriv_tmpa_int }
+ { \tl_map_break: }
+ }
+
+ \tl_set:Nx #2 { \tl_range:nnn {#3} { 1 } \l__deriv_tmpa_int }
+ \int_incr:N \l__deriv_tmpa_int
+ \tl_set:Nx #1 { \tl_range:nnn {#3} \l__deriv_tmpa_int { -1 } }
\exp_args:NV \str_case:nn #2
{
@@ -1104,167 +1065,164 @@
{ - } { \tl_set:Nn #2 { -1 } }
}
}
-% unsorted-seq, variant
-\cs_new:Npn \__deriv_combine_seq:Nn #1 #2
+% sym-tl, num-tl
+\cs_new_protected:Npn \__deriv_add_to_seq:NNNN #1 #2 #3 #4
+{
+ \seq_put_right:NV #1 #3
+ \seq_put_right:NV #2 #4
+}
+% sym-tl, num-tl
+\cs_new_protected:Npn \__deriv_update_seq:NNNN #1 #2 #3 #4
+{
+ \seq_map_indexed_inline:Nn #1
+ {
+ \tl_if_eq:NnT #3 {##2}
+ {
+ \exp_args:NNnx
+ \seq_set_item:Nnn #2 {##1}
+ { \int_eval:n { \seq_item:Nn #2 {##1} + #4 } }
+ \seq_map_break:
+ }
+ }
+}
+% sorted-seq, permutation-seq, symbol-seq, number-seq, variant
+\cs_new:Npn \__deriv_combine_seq:NNNNn #1 #2 #3 #4 #5
{
\seq_clear:N #1
\int_zero:N \l__deriv_numerical_int
- \seq_map_inline:Nn \l__deriv_symbol_seq
+ \seq_map_inline:Nn #2
{
- \seq_pop_left:NN \l__deriv_number_seq \l__deriv_num_tmpa_tl
- \__deriv_eval_term:NVnn #1 \l__deriv_num_tmpa_tl {##1} {#2}
+ \tl_set:Nx \l__deriv_sym_tmpa_tl { \seq_item:Nn #3 {##1} }
+ \tl_set:Nx \l__deriv_num_tmpa_tl { \seq_item:Nn #4 {##1} }
+ \__deriv_eval_term:NVVn #1 \l__deriv_sym_tmpa_tl \l__deriv_num_tmpa_tl {#5}
}
}
-% unsorted-seq, num-tl, seq-item (sym), variant
+% sorted-seq, sym-tl, num-tl, variant
\cs_new_protected:Npn \__deriv_eval_term:Nnnn #1 #2 #3 #4
{
- \__deriv_case:nF
+ \tl_if_empty:nTF {#2}
+ { \__deriv_numerical_term:Nnn #1 {#3} {#4} }
{
- { \tl_if_empty_p:n {#3} } { \__deriv_numerical_term:Nnn #1 {#2} {#4} }
- { \int_compare_p:nNn {#2} = { 1 } } { \seq_put_left:Nn #1 {#3} }
- { \int_compare_p:nNn {#2} = { 0 } } { \prg_do_nothing: }
- { \int_compare_p:nNn {#2} = { -1 } } { \seq_put_left:Nn #1 { -#3 } }
+ \int_compare:nNnTF {#3} = { 1 }
+ { \seq_put_right:Nn #1 {#2} }
+ {
+ \int_compare:nNnTF {#3} = { 0 }
+ { \prg_do_nothing: }
+ {
+ \int_compare:nNnTF {#3} = { -1 }
+ { \seq_put_right:Nn #1 { -#2 } }
+ { \seq_put_right:Nn #1 {#3#2} }
+ }
+ }
}
- { \seq_put_left:Nn #1 {#2#3} }
}
-% unsorted-seq, num-tl, variant
+% sorted-seq, num-tl, variant
\cs_new_protected:Npn \__deriv_numerical_term:Nnn #1 #2 #3
{
\str_if_eq:vnTF { l__deriv_#3_sort_numerical_tl } { symbolic }
- { \seq_put_left:Nn #1 {#2} }
+ { \seq_put_right:Nn #1 {#2} }
{ \int_set:Nn \l__deriv_numerical_int {#2} }
}
-% sym-tl, num-tl
-\cs_new_protected:Npn \__deriv_add_to_seq:NN #1 #2
+% permutation-seq, symbol-seq, number-seq, variant
+\cs_new_protected:Npn \__deriv_sort:NNNn #1 #2 #3 #4
{
- \seq_put_left:NV \l__deriv_symbol_seq #1
- \seq_put_left:NV \l__deriv_number_seq #2
-}
-% sym-tl, num-tl
-\cs_new_protected:Npn \__deriv_update_seq:NN #1 #2
-{
- \__deriv_get_position:NN \l__deriv_position_int #1
- \__deriv_rebuild_seq:NNN \l__deriv_number_seq \l__deriv_position_int #2
-}
-% position-int, sym-tl
-\cs_new:Npn \__deriv_get_position:NN #1 #2
-{
- \int_zero:N #1
- \seq_map_inline:Nn \l__deriv_symbol_seq
- {
- \int_incr:N #1
- \exp_args:NV \tl_if_eq:nnT #2 {##1} { \seq_map_break: }
- }
-}
-% num-seq, position-int, num-tl
-\cs_new_protected:Npn \__deriv_rebuild_seq:NNN #1 #2 #3
-{
- \int_zero:N \l__deriv_rebuild_int
- \seq_clear:N \l__deriv_rebuild_seq
+ \seq_clear:N #1
+ \int_step_inline:nn { \seq_count:N #2 }
+ { \seq_put_right:Nn #1 {##1} }
- \seq_map_inline:Nn #1
+ \bool_if:cT { l__deriv_#4_switch_sort_bool }
{
- \int_incr:N \l__deriv_rebuild_int
- \int_compare:nNnTF \l__deriv_rebuild_int = #2
+ \int_set:Nn \l__deriv_sort_max_int { \seq_count:c { l__deriv_#4_sort_method_seq } }
+ \seq_sort:Nn #1
{
- \tl_set:Nf \l__deriv_num_tmpb_tl { \int_eval:n { ##1 + #3 } }
- \seq_put_right:NV \l__deriv_rebuild_seq \l__deriv_num_tmpb_tl
+ \tl_set:Nx \l__deriv_sym_tmpa_tl { \seq_item:Nn #2 {##1} }
+ \tl_set:Nx \l__deriv_sym_tmpb_tl { \seq_item:Nn #2 {##2} }
+ \tl_set:Nx \l__deriv_num_tmpa_tl { \seq_item:Nn #3 {##1} }
+ \tl_set:Nx \l__deriv_num_tmpb_tl { \seq_item:Nn #3 {##2} }
+
+ \__deriv_sort_method:cn { l__deriv_#4_sort_method_seq } {#4}
}
- { \seq_put_right:Nn \l__deriv_rebuild_seq {##1} }
- }
- \seq_set_eq:NN #1 \l__deriv_rebuild_seq
-}
-% sorted-seq, unsorted-seq, variant
-\cs_new_protected:Npn \__deriv_sort:NNn #1 #2 #3
-{
- \int_set:Nn \l__deriv_sort_max_int { \int_min:nn { 3 } { \clist_count:c { l__deriv_#3_sort_method_clist } } }
-
- \seq_sort:Nn #2
- {
- \__deriv_extract:NNn \l__deriv_sym_tmpa_tl \l__deriv_num_tmpa_tl {##1}
- \__deriv_extract:NNn \l__deriv_sym_tmpb_tl \l__deriv_num_tmpb_tl {##2}
- \int_zero:N \l__deriv_sort_counter_int
- \__deriv_sort_method:n {#3}
}
- \seq_set_eq:NN #1 #2
}
-% dv
-\cs_new_protected:Npn \__deriv_sort_method:n #1
+% method-seq, dv
+\cs_new_protected:Npn \__deriv_sort_method:Nn #1 #2
{
- \int_incr:N \l__deriv_sort_counter_int
-
- \exp_args:Nf
- \str_case:nn { \clist_item:cn { l__deriv_#1_sort_method_clist } { \l__deriv_sort_counter_int } }
+ \seq_map_indexed_inline:Nn #1
{
- { sign } { \__deriv_sort_sign:n {#1} }
- { symbol } { \__deriv_sort_symbol:n {#1} }
- { abs } { \__deriv_sort_abs:n {#1} }
- { number } { \__deriv_sort_number:n {#1} }
+ ##2 {#2}
+ \int_compare:nNnT {##1} = { \l__deriv_sort_max_int }
+ { \seq_map_break:n { \sort_return_same: } }
}
}
% dv
\cs_new_protected:Npn \__deriv_sort_sign:n #1
{
- \__deriv_case:nF
+ \tl_if_head_eq_charcode:VNTF \l__deriv_num_tmpb_tl -
{
- { \tl_if_head_eq_charcode_p:VN \l__deriv_num_tmpb_tl - && ! \tl_if_head_eq_charcode_p:VN \l__deriv_num_tmpa_tl - } { \__deriv_sort_reverse:nnn {#1} { sign } { same } }
- { \tl_if_head_eq_charcode_p:VN \l__deriv_num_tmpa_tl - && ! \tl_if_head_eq_charcode_p:VN \l__deriv_num_tmpb_tl - } { \__deriv_sort_reverse:nnn {#1} { sign } { swapped } }
+ \tl_if_head_eq_charcode:VNF \l__deriv_num_tmpa_tl -
+ { \__deriv_sort_reverse:Nnn \c_false_bool {#1} { sign } }
}
{
- \int_compare:nNnTF { \l__deriv_sort_counter_int } = { \l__deriv_sort_max_int }
- { \sort_return_same: }
- { \__deriv_sort_method:n {#1} }
+ \tl_if_head_eq_charcode:VNT \l__deriv_num_tmpa_tl -
+ { \__deriv_sort_reverse:Nnn \c_true_bool {#1} { sign } }
}
}
% dv
\cs_new_protected:Npn \__deriv_sort_symbol:n #1
{
- \__deriv_case:nF
+ \int_set:Nn \l__deriv_tmpa_int { \tl_count:N \l__deriv_sym_tmpa_tl }
+ \int_set:Nn \l__deriv_tmpb_int { \tl_count:N \l__deriv_sym_tmpb_tl }
+
+ \int_compare:nNnTF \l__deriv_tmpa_int > \l__deriv_tmpb_int
+ { \__deriv_sort_reverse:Nnn \c_false_bool {#1} { symbol } }
{
- { \int_compare_p:nNn { \tl_count:N \l__deriv_sym_tmpa_tl } > { \tl_count:N \l__deriv_sym_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { symbol } { same } }
- { \int_compare_p:nNn { \tl_count:N \l__deriv_sym_tmpa_tl } < { \tl_count:N \l__deriv_sym_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { symbol } { swapped } }
+ \int_compare:nNnT \l__deriv_tmpa_int < \l__deriv_tmpb_int
+ { \__deriv_sort_reverse:Nnn \c_true_bool {#1} { symbol } }
}
+}
+% dv
+\cs_new_protected:Npn \__deriv_sort_lexical:n #1
+{ \__deriv_sort_lexical_auxi:VVn \l__deriv_sym_tmpa_tl \l__deriv_sym_tmpb_tl {#1} }
+% dv
+\cs_new_protected:Npn \__deriv_sort_lexical_auxi:nnn #1 #2 #3
+{
+ \str_compare:nNnTF {#1} < {#2}
+ { \__deriv_sort_reverse:Nnn \c_false_bool {#3} { lexical } }
{
- \int_compare:nNnTF { \l__deriv_sort_counter_int } = { \l__deriv_sort_max_int }
- { \sort_return_same: }
- { \__deriv_sort_method:n {#1} }
+ \str_compare:nNnT {#1} > {#2}
+ { \__deriv_sort_reverse:Nnn \c_true_bool {#3} { lexical } }
}
}
% dv
\cs_new_protected:Npn \__deriv_sort_abs:n #1
{
- \__deriv_case:nF
- {
- { \int_compare_p:nNn { \int_abs:n \l__deriv_num_tmpa_tl } > { \int_abs:n \l__deriv_num_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { abs } { same } }
- { \int_compare_p:nNn { \int_abs:n \l__deriv_num_tmpa_tl } < { \int_abs:n \l__deriv_num_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { abs } { swapped } }
- }
+ \int_set:Nn \l__deriv_tmpa_int { \int_abs:n \l__deriv_num_tmpa_tl }
+ \int_set:Nn \l__deriv_tmpb_int { \int_abs:n \l__deriv_num_tmpb_tl }
+
+ \int_compare:nNnTF \l__deriv_tmpa_int > \l__deriv_tmpb_int
+ { \__deriv_sort_reverse:Nnn \c_false_bool {#1} { abs } }
{
- \int_compare:nNnTF { \l__deriv_sort_counter_int } = { \l__deriv_sort_max_int }
- { \sort_return_same: }
- { \__deriv_sort_method:n {#1} }
+ \int_compare:nNnT \l__deriv_tmpa_int < \l__deriv_tmpb_int
+ { \__deriv_sort_reverse:Nnn \c_true_bool {#1} { abs } }
}
}
% dv
\cs_new_protected:Npn \__deriv_sort_number:n #1
{
- \__deriv_case:nF
+ \int_compare:nNnTF \l__deriv_num_tmpa_tl > \l__deriv_num_tmpb_tl
+ { \__deriv_sort_reverse:Nnn \c_false_bool {#1} { number } }
{
- { \int_compare_p:nNn { \l__deriv_num_tmpa_tl } > { \l__deriv_num_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { number } { same } }
- { \int_compare_p:nNn { \l__deriv_num_tmpa_tl } < { \l__deriv_num_tmpb_tl } } { \__deriv_sort_reverse:nnn {#1} { number } { swapped } }
- }
- {
- \int_compare:nNnTF { \l__deriv_sort_counter_int } = { \l__deriv_sort_max_int }
- { \sort_return_same: }
- { \__deriv_sort_method:n {#1} }
+ \int_compare:nNnT \l__deriv_num_tmpa_tl < \l__deriv_num_tmpb_tl
+ { \__deriv_sort_reverse:Nnn \c_true_bool {#1} { number } }
}
}
-% dv, sort-method, same/swapped
-\cs_new_protected:Npn \__deriv_sort_reverse:nnn #1 #2 #3
+% true/false, dv, sort-method
+\cs_new_protected:Npn \__deriv_sort_reverse:Nnn #1 #2 #3
{
- \exp_args:Nc
- \bool_xor:nnTF { l__deriv_#1_sort_#2_reverse_bool } { \str_if_eq_p:nn {#3} { same } }
- { \sort_return_same: }
- { \sort_return_swapped: }
+ \exp_args:NNc
+ \bool_xor:nnTF #1 { l__deriv_#2_sort_#3_reverse_bool }
+ { \seq_map_break:n { \sort_return_swapped: } }
+ { \seq_map_break:n { \sort_return_same: } }
}
% mixed-order-tl, sorted-seq, numerical-term, variant
\cs_new_protected:Npn \__deriv_output:NNNn #1 #2 #3 #4
@@ -1282,7 +1240,7 @@
{ first } { \tl_put_left:Nx #1 { \int_use:N #3 + } }
}
{
- \bool_if:nTF { \tl_if_head_eq_charcode_p:VN #1 - }
+ \tl_if_head_eq_charcode:VNTF #1 -
{ \tl_put_left:NV #1 #3 }
{ \tl_put_right:Nx #1 { + \int_use:N #3 } }
}
@@ -1420,28 +1378,25 @@
%%%%% Generate variants %%%%%
\prg_generate_conditional_variant:Nnn \__deriv_show_order:N { c } { T, TF }
+\prg_generate_conditional_variant:Nnn \tl_if_head_eq_charcode:nN { V } { T, F, TF }
-\cs_generate_variant:Nn \tl_if_head_eq_charcode_p:nN { V }
\cs_generate_variant:Nn \__deriv_set_rubber_length:Nn { c }
-\cs_generate_variant:Nn \__deriv_dv_variables:n { V }
-\cs_generate_variant:Nn \__deriv_dv_define_keys:n { V }
\cs_generate_variant:Nn \deriv_dv_define:Nnn { NV }
-\cs_generate_variant:Nn \__deriv_i_variables:n { V }
-\cs_generate_variant:Nn \__deriv_i_define_keys:n { V }
\cs_generate_variant:Nn \deriv_i_define:Nnn { NV }
\cs_generate_variant:Nn \deriv_set_keys:nn { V }
+\cs_generate_variant:Nn \__deriv_dont_use_dot:n { x }
+\cs_generate_variant:Nn \__deriv_scale_big_auxi:nNn { nc }
\cs_generate_variant:Nn \__deriv_insert_ord:Nnn { c }
\cs_generate_variant:Nn \__deriv_insert_var:Nnn { NV }
-\prg_generate_conditional_variant:Nnn \__deriv_if_novalue:n { f } { T }
-\prg_generate_conditional_variant:Nnn \__deriv_if_novalue:n { V } { TF }
\cs_generate_variant:Nn \__deriv_mixed_order:NNn { c }
-\cs_generate_variant:Nn \__deriv_eval_term:Nnnn { NV }
+\cs_generate_variant:Nn \__deriv_sort_method:Nn { c }
+\cs_generate_variant:Nn \__deriv_eval_term:Nnnn { NVV }
+\cs_generate_variant:Nn \__deriv_sort_lexical_auxi:nnn { VV }
-\cs_generate_variant:Nn \__deriv_set_default_aux:nnn { V }
-\cs_generate_variant:Nn \__deriv_set_default_from_prop:NN { Nc }
-\cs_generate_variant:Nn \__deriv_update_prop:Nn { c }
+\cs_generate_variant:Nn \__deriv_set_default_auxi:Nnn { c }
+\cs_generate_variant:Nn \__deriv_set_default_auxii:nnn { f }
\cs_generate_variant:Nn \__deriv_preamble_aux:nnn { V }
\cs_generate_variant:Nn \__deriv_var_bool_seq:NNN { c }
@@ -1480,15 +1435,14 @@
{ \derivset{all}[scale-auto = mleftmright] }
{ \derivset{all}[scale-auto = leftright] }
-\cs_new_protected:Npn \deriv_define_legacy_italic_cs:
+
+\bool_if:NTF \l__deriv_pkg_italic_bool
{
\DeclareDerivative{\odv}{\mathnormal{d}}
\DeclareDerivative{\mdv}{\mathnormal{D}}
\DeclareDifferential{\odif}{\mathnormal{d}}
\DeclareDifferential{\mdif}{\mathnormal{D}}[style-notation=single, style-notation-*=mixed]
}
-
-\cs_new_protected:Npn \deriv_define_legacy_upright_cs:
{
\DeclareDerivative{\odv}{\mathrm{d}}
\DeclareDerivative{\mdv}{\mathrm{D}}
@@ -1496,12 +1450,6 @@
\DeclareDifferential{\mdif}{\mathrm{D}}[style-notation=single, style-notation-*=mixed]
}
-\__deriv_case:n
-{
- { \l__deriv_pkg_italic_bool } { \deriv_define_legacy_italic_cs: }
- { \l__deriv_pkg_upright_bool } { \deriv_define_legacy_upright_cs: }
-}
-
\DeclareDerivative{\fdv}{\delta}
\DeclareDerivative{\adv}{\Delta}
\DeclareDerivative{\jdv}{\partial}[fun=true, var=1]