| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
%% File: simples-matrices.dtx |
| 4 |
%% Copyright (C) 2022 Yvon Henel aka Le TeXnicien de surface |
| 5 |
%% |
| 6 |
%% It may be distributed and/or modified under the conditions of the |
| 7 |
%% LaTeX Project Public License (LPPL), either version 1.3c of this |
| 8 |
%% license or (at your option) any later version. The latest version |
| 9 |
%% of this license is in the file |
| 10 |
%% |
| 11 |
%% http://www.latex-project.org/lppl.txt |
| 12 |
%% |
| 13 |
% |
| 14 |
%<*driver|package|doc> |
| 15 |
\RequirePackage{expl3}[2020/01/12] |
| 16 |
\GetIdInfo$Id: simples-matrices.dtx 1.0.1 2022-07-03 TdS $ |
| 17 |
{} |
| 18 |
%</driver|package|doc> |
| 19 |
%<*driver> |
| 20 |
\documentclass[full]{l3doc} |
| 21 |
% \usepackage[utf8]{inputenc} |
| 22 |
\usepackage[T1]{fontenc} |
| 23 |
\usepackage{amsmath} |
| 24 |
\usepackage[french,main=english]{babel} |
| 25 |
\usepackage{simples-matrices} |
| 26 |
\usepackage{xspace} |
| 27 |
\usepackage{csquotes} |
| 28 |
|
| 29 |
\providecommand\darg[3]{\texttt{#1}\meta{#2}\texttt{#3}} |
| 30 |
|
| 31 |
\begin{document} |
| 32 |
\DocInput{\jobname.dtx} |
| 33 |
\end{document} |
| 34 |
%</driver> |
| 35 |
% \fi |
| 36 |
% |
| 37 |
% \title{^^A |
| 38 |
% The \pkg{simples-matrices} package^^A |
| 39 |
% \thanks{This file describes v\ExplFileVersion, last revised \ExplFileDate.}^^A |
| 40 |
% } |
| 41 |
% |
| 42 |
% \author{^^A |
| 43 |
% Yvon Henel\thanks^^A |
| 44 |
% {^^A |
| 45 |
% E-mail: |
| 46 |
% \href{mailto:[email protected]} |
| 47 |
% {[email protected]}^^A |
| 48 |
% }^^A |
| 49 |
% } |
| 50 |
% |
| 51 |
% \date{Released \ExplFileDate} |
| 52 |
% |
| 53 |
% \maketitle |
| 54 |
% |
| 55 |
% \changes{v1.0}{2022/06/08}{First public version.\foreignlanguage{french}{\emph{Première version publique.}}} |
| 56 |
% \changes{v1.0.1}{2022/07/03}{Some improvements in the documentation.\foreignlanguage{french}{\emph{Quelques améliorations dans la documentation.}}} |
| 57 |
% |
| 58 |
% \thispagestyle{empty} |
| 59 |
% |
| 60 |
% \noindent\hrulefill |
| 61 |
% |
| 62 |
% \begin{otherlanguage}{french} |
| 63 |
% \begin{abstract} |
| 64 |
% Cette extension fournit des commandes pour définir et écrire des matrices en |
| 65 |
% donnant leurs coefficients, par ligne, dans une vliste (liste de valeurs |
| 66 |
% séparées par des virgules). |
| 67 |
% |
| 68 |
% La documentation française pour l'utilisateur de l'extension |
| 69 |
% \pkg{simples-matrices} est disponible sous le nom de |
| 70 |
% \texttt{simples-matrices-fra}. |
| 71 |
% \end{abstract} |
| 72 |
% \end{otherlanguage} |
| 73 |
% |
| 74 |
% \noindent\hrulefill |
| 75 |
% |
| 76 |
% \begin{abstract} |
| 77 |
% This package provides macros to define and write matrices the coefficients |
| 78 |
% of which are given, row by row, in a clist (list of values separated by |
| 79 |
% commas). |
| 80 |
% |
| 81 |
% The English documentation for the final user of the package |
| 82 |
% \pkg{simples-matrices} is available in the file |
| 83 |
% \texttt{simples-matrices-eng}. |
| 84 |
% \end{abstract} |
| 85 |
% |
| 86 |
% \noindent\hrulefill |
| 87 |
% |
| 88 |
% \begin{documentation} |
| 89 |
% |
| 90 |
% |
| 91 |
%\section{Summary of Syntax of Document Commands} |
| 92 |
%\label{sec:summary} |
| 93 |
% |
| 94 |
% |
| 95 |
% |
| 96 |
% \begin{function}{\matrice} |
| 97 |
% \begin{syntax} |
| 98 |
% \cs{matrice}\parg{prefix}\darg{\string<}{clist of key-value pairs}{\string>}\oarg{type}\marg{clist of coefficients} |
| 99 |
% \end{syntax} |
| 100 |
% \end{function} |
| 101 |
% |
| 102 |
% \begin{function}{\declarermatrice} |
| 103 |
% \begin{syntax} |
| 104 |
% \cs{declarermatrice*}\parg{prefix}\darg{\string<}{clist of key-value pairs}{\string>}\marg{matrix name}\oarg{type}\marg{clist of coefficients} |
| 105 |
% \end{syntax} |
| 106 |
% \end{function} |
| 107 |
% |
| 108 |
% \begin{function}{\lamatrice} |
| 109 |
% \begin{syntax} |
| 110 |
% \cs{lamatrice}\parg{prefix}\darg{\string<}{clist of key-value pairs}{\string>}\marg{matrix name} |
| 111 |
% \end{syntax} |
| 112 |
% \end{function} |
| 113 |
% |
| 114 |
% \begin{function}{\MatriceInterieur} |
| 115 |
% \begin{syntax} |
| 116 |
% \cs{MatriceInterieur} |
| 117 |
% \end{syntax} |
| 118 |
% \end{function} |
| 119 |
% |
| 120 |
% \begin{function}{\LaMatriceInterieur} |
| 121 |
% \begin{syntax} |
| 122 |
% \cs{LaMatriceInterieur}\marg{matrix name} |
| 123 |
% \end{syntax} |
| 124 |
% \end{function} |
| 125 |
% |
| 126 |
% \begin{function}{\simplesmatricessetup} |
| 127 |
% \begin{syntax} |
| 128 |
% \cs{simplesmatricessetup}\marg{clist of key-value pairs} |
| 129 |
% \end{syntax} |
| 130 |
% \end{function} |
| 131 |
% |
| 132 |
% \begin{function}{\matid} |
| 133 |
% \begin{syntax} |
| 134 |
% \cs{matid}\oarg{diagonal coefficient, default \(1\)}\marg{size of the square matrix} |
| 135 |
% \end{syntax} |
| 136 |
% \end{function} |
| 137 |
% |
| 138 |
% \begin{function}{\matnulle} |
| 139 |
% \begin{syntax} |
| 140 |
% \cs{matid}\oarg{diagonal coefficient, default \(0\)}\marg{size of the square matrix} |
| 141 |
% \end{syntax} |
| 142 |
% \end{function} |
| 143 |
% |
| 144 |
% \end{documentation} |
| 145 |
% |
| 146 |
% \iffalse |
| 147 |
%<*doc> |
| 148 |
\documentclass[full]{l3doc} |
| 149 |
\usepackage[utf8]{inputenc} |
| 150 |
\usepackage[T1]{fontenc} |
| 151 |
%<FRA>\usepackage[english,main=french]{babel} |
| 152 |
%<ENG>\usepackage[french,main=english]{babel} |
| 153 |
\usepackage{xparse} |
| 154 |
\usepackage{simples-matrices} |
| 155 |
\newcommand\BOP{\discretionary{}{}{}} |
| 156 |
\usepackage{xspace} |
| 157 |
\usepackage{csquotes} |
| 158 |
\usepackage{fancyvrb,fancyvrb-ex} |
| 159 |
\usepackage{listings} |
| 160 |
\usepackage{mathtools} |
| 161 |
\usepackage{delarray} |
| 162 |
\usepackage{nicematrix} |
| 163 |
|
| 164 |
\providecommand\darg[3]{ \texttt{#1} \meta{#2} \texttt{#3} } |
| 165 |
|
| 166 |
% \colorlet{option}{olive!75!black} |
| 167 |
% Couleur des mots-clés de niveau 1 |
| 168 |
\colorlet{keyword20}{cyan} %!75!black |
| 169 |
% Couleur des mots-clés de niveau 2 |
| 170 |
\colorlet{keyword30}{teal} |
| 171 |
\colorlet{keycolor}{green!50!black} |
| 172 |
\colorlet{dollarcolor}{violet} |
| 173 |
\colorlet{cmdmuette}{blue} |
| 174 |
\colorlet{cmdcausante}{red} |
| 175 |
|
| 176 |
\lstset{frame=single,% |
| 177 |
language=[LaTeX]{TeX},% |
| 178 |
showspaces=false,% |
| 179 |
breaklines=true,% |
| 180 |
breakatwhitespace=true,% |
| 181 |
basicstyle=\ttfamily\bfseries,% |
| 182 |
alsoletter={*-$},% |
| 183 |
texcsstyle=*[2]\color{cmdcausante},% |
| 184 |
texcs=[2]{matrice,declarermatrice*,lamatrice,matid,matnulle,MatriceInterieur,LaMatriceInterieur},% |
| 185 |
texcsstyle=*[3]\color{cmdmuette},% |
| 186 |
texcs=[3]{declarermatrice,simplesmatricessetup},% |
| 187 |
keywordstyle=[20]\color{keyword20},% |
| 188 |
keywordstyle=[30]\color{keyword30},% |
| 189 |
keywordstyle=[40]\color{keycolor},% |
| 190 |
keywordstyle=[50]\color{dollarcolor},% |
| 191 |
keywords=[20]{tabular,array,matrix,matrix*,NiceArray},% |
| 192 |
keywords=[30]{x,S,T,I,J,C,O,D},% |
| 193 |
keywords=[40]{out-of-box,prefix,envir,typeord,argopt},% |
| 194 |
keywords=[50]{$},% |
| 195 |
escapeinside={\%*@}{@*)}% |
| 196 |
} |
| 197 |
|
| 198 |
\newcommand{\MacroPres}[2]{\textcolor{#1}{\textbf{\cs{#2}}}} |
| 199 |
\newcommand{\csmute}{\MacroPres{cmdmuette}} |
| 200 |
\newcommand{\csprint}{\MacroPres{cmdcausante}} |
| 201 |
\newcommand{\ObjetPres}[2]{\textcolor{#1}{\textbf{\texttt{#2}}}} |
| 202 |
\newcommand{\keyname}{\ObjetPres{keycolor}} |
| 203 |
\newcommand{\envir}{\ObjetPres{keyword20}} |
| 204 |
\newcommand{\TypeMat}{\ObjetPres{keyword30}} |
| 205 |
|
| 206 |
\newcommand{\UnExemple}{% |
| 207 |
\par \medskip \par \noindent |
| 208 |
\begin{minipage}[c]{0.66\linewidth} |
| 209 |
\lstinputlisting[gobble=0, frame=single, numbers=left, numberstyle={\small}]{code00.tex} |
| 210 |
\end{minipage} |
| 211 |
\hspace{\stretch{1}} |
| 212 |
\begin{minipage}[c]{0.32\linewidth} |
| 213 |
\small |
| 214 |
\input{code00} |
| 215 |
\end{minipage} |
| 216 |
\par \medbreak} |
| 217 |
|
| 218 |
\newcommand*{\vliste}{liste\xspace} |
| 219 |
|
| 220 |
%<FRA> \newcommand{\VoirEx}[1]{(voir exemple en page~\pageref{#1})} |
| 221 |
%<ENG> \newcommand{\VoirEx}[1]{(see example on page~\pageref{#1})} |
| 222 |
|
| 223 |
\begin{document} |
| 224 |
%<*FRA> |
| 225 |
\title{Guide de l'utilisateur de \pkg{simples-matrices}\thanks{Ce fichier décrit |
| 226 |
la version~\ExplFileVersion, dernière révision~\ExplFileDate.\\ |
| 227 |
\emph{En souvenir de ma grand-mère maternelle}, Adrienne \textsc{Binaut} |
| 228 |
(1908-03-23 -- 1997-06-08).} } |
| 229 |
%</FRA> |
| 230 |
%<*ENG> |
| 231 |
\title{\pkg{simples-matrices} user guide\thanks{This file describes |
| 232 |
version~\ExplFileVersion, last revised~\ExplFileDate.\\ |
| 233 |
\emph{In memory of my maternal grandmother} Adrienne \textsc{Binaut} |
| 234 |
(1908-03-23 -- 1997-06-08).} } |
| 235 |
%</ENG> |
| 236 |
\author{Yvon Henel\thanks{E-mail: |
| 237 |
\href{mailto:[email protected]} |
| 238 |
{[email protected]}}} |
| 239 |
\maketitle |
| 240 |
\noindent\hrulefill |
| 241 |
|
| 242 |
\begin{abstract} |
| 243 |
%<*FRA> |
| 244 |
Une extension pour écrire des matrices en donnant les coefficients par ligne |
| 245 |
sous la forme d'une liste de valeurs séparées par des virgules. |
| 246 |
|
| 247 |
Une macro permet de définir des matrices nommées et une autre permet d'écrire |
| 248 |
les matrices nommées. L'extension fournit également quelques raccourcis pour les |
| 249 |
matrices identité et les matrices nulles. |
| 250 |
%</FRA> |
| 251 |
%<*ENG> |
| 252 |
A package to write matrices which are defined with a list of comma separated |
| 253 |
coefficients read by row. |
| 254 |
|
| 255 |
A macro enables the definition of a named matrix, another enables the writing of |
| 256 |
a named matrix. This package provides also some shortcuts for identity matrices |
| 257 |
and null matrices. |
| 258 |
|
| 259 |
The name of this package and of its macros are French based for there are |
| 260 |
already too many macros using the word ``matrix'' itself. The French |
| 261 |
``\foreignlanguage{french}{simples matrices}'' means ``simple |
| 262 |
matrices''. \emph{Just a letter apart!} |
| 263 |
%</ENG> |
| 264 |
\end{abstract} |
| 265 |
|
| 266 |
\noindent\hrulefill |
| 267 |
|
| 268 |
%<FRA> \begin{otherlanguage}{english} |
| 269 |
%<ENG> \begin{otherlanguage}{french} |
| 270 |
\begin{abstract} |
| 271 |
%<*FRA> |
| 272 |
A package to write matrices which are defined with a list of comma separated |
| 273 |
coefficients read by row. |
| 274 |
|
| 275 |
A macro enables the definition of a named matrix, another enables the writing of |
| 276 |
a named matrix. This package provides also some shortcuts for identity matrices |
| 277 |
and null matrices. |
| 278 |
|
| 279 |
The name of this package and of its macros are French based for there are |
| 280 |
already too many macros using the word ``matrix'' itself. The French |
| 281 |
``\foreignlanguage{french}{simples matrices}'' means ``simple |
| 282 |
matrices''. \emph{Just a letter apart!} |
| 283 |
|
| 284 |
The English documentation for the final user of the package |
| 285 |
\pkg{simples-matrices} is available in the file \texttt{simples-matrices-eng}. |
| 286 |
%</FRA> |
| 287 |
%<*ENG> |
| 288 |
Une extension pour écrire des matrices en donnant les coefficients par ligne |
| 289 |
sous la forme d'une liste de valeurs séparées par des virgules. |
| 290 |
|
| 291 |
Une macro permet de définir des matrices nommées et une autre permet d'écrire |
| 292 |
les matrices nommées. L'extension fournit également quelques raccourcis pour les |
| 293 |
matrices identité et les matrices nulles. |
| 294 |
|
| 295 |
|
| 296 |
La documentation française pour l'utilisateur de l'extension |
| 297 |
\pkg{simples-matrices} est disponible sous le nom de \texttt{simples-matrices-fra}. |
| 298 |
%</ENG> |
| 299 |
\end{abstract} |
| 300 |
\end{otherlanguage} |
| 301 |
|
| 302 |
\noindent\hrulefill |
| 303 |
|
| 304 |
\tableofcontents{} |
| 305 |
|
| 306 |
\vspace{3\baselineskip} |
| 307 |
|
| 308 |
|
| 309 |
%<*ENG> |
| 310 |
The package \pkg{simples-matrices} requires \pkg{xparse} and \pkg{l3keys2e} used |
| 311 |
to define macros and manage key-options. It loads \pkg{amsmath} as well for |
| 312 |
ensuring a correct presentation of matrices. |
| 313 |
|
| 314 |
\textbf{Beware}: you have to provide the suitable mathematical environment to |
| 315 |
use the macros which print a matrix. Only the unstarred version of |
| 316 |
\csmute{declarermatrice} may be used outside math-mode. |
| 317 |
|
| 318 |
%</ENG> |
| 319 |
%<*FRA> |
| 320 |
L'extension \pkg{simples-matrices} utilise \pkg{xparse} et \pkg{l3keys2e} pour |
| 321 |
définir ses macros et gérer les clés d'option. Elle charge également |
| 322 |
\pkg{amsmath} pour obtenir une présentation convenable des matrices. |
| 323 |
|
| 324 |
\textbf{Attention}: vous devez fournir l'environnement mathématique adéquat pour |
| 325 |
utiliser les macros qui écrivent les matrices. Seule la version non-étoilée de |
| 326 |
\csmute{declarermatrice} peut être utilisée en dehors du mode mathématique. |
| 327 |
%</FRA> |
| 328 |
|
| 329 |
%<*ENG> |
| 330 |
\section{The Macros} |
| 331 |
\label{sec:macros} |
| 332 |
|
| 333 |
\pkg{simples-matrices} offers nine document macros. |
| 334 |
|
| 335 |
%</ENG> |
| 336 |
%<*FRA> |
| 337 |
\section{Les macros} |
| 338 |
\label{sec:macros} |
| 339 |
|
| 340 |
L'extension \pkg{simples-matrices} offre neuf macros de document. |
| 341 |
|
| 342 |
%</FRA> |
| 343 |
|
| 344 |
%<*ENG> |
| 345 |
In the main text (syntaxes and examples), the name of a macro of this package is |
| 346 |
printed in red if the macro produces some text in the document, otherwise it is |
| 347 |
printed in blue. |
| 348 |
%</ENG> |
| 349 |
%<*FRA> |
| 350 |
Dans le texte principal (syntaxes et exemples), le nom d'une macro de cette |
| 351 |
extension est écrit en rouge si la macro produit du texte dans le document, |
| 352 |
autrement il est écrit en bleu. |
| 353 |
%</FRA> |
| 354 |
|
| 355 |
%<*ENG> |
| 356 |
\subsection{Main Macros} |
| 357 |
\label{sec:main} |
| 358 |
|
| 359 |
The six main document macros are the following: |
| 360 |
%</ENG> |
| 361 |
%<*FRA> |
| 362 |
\subsection{Macros principales} |
| 363 |
\label{sec:principales} |
| 364 |
|
| 365 |
Les six macros principales sont les suivantes: |
| 366 |
%</FRA> |
| 367 |
%<*ENG> |
| 368 |
|
| 369 |
\begin{function}{\matrice} |
| 370 |
\begin{syntax} |
| 371 |
\csprint{matrice}\parg{prefix}\darg{\string<}{clist of key-value pairs}{\string>}\oarg{type}\marg{clist of coefficients} |
| 372 |
\end{syntax} |
| 373 |
where \meta{prefix} has the same meaning as the key \keyname{prefix} (see page~\pageref{key-prefix}); |
| 374 |
\meta{clist of key-value pairs} ---optional and void by default--- can be used to |
| 375 |
redefined the \envir{matrix}-like environment; \meta{type} is a string of character |
| 376 |
the usage of which is explained later ---see \ref{sec:matrix-type}--- and |
| 377 |
\meta{clist of coefficients} is a clist of the coefficients of the matrix |
| 378 |
given by row order. |
| 379 |
|
| 380 |
The French \emph{matrice} means ``matrix''. |
| 381 |
\end{function} |
| 382 |
%</ENG> |
| 383 |
%<*FRA> |
| 384 |
\begin{function}{\matrice} |
| 385 |
\begin{syntax} |
| 386 |
\csprint{matrice}\parg{prefixe}\darg{\string<}{\vliste de paires de clé-valeur}{\string>}\oarg{type}\marg{\vliste des coefficients} |
| 387 |
\end{syntax} |
| 388 |
où \meta{prefixe} a la même fonction que la clé \keyname{prefix} (voir page~\pageref{key-prefix}); |
| 389 |
\meta{\vliste de paires de clé-valeur} --- optionnel et vide par défaut --- |
| 390 |
peut être utilisé pour redéfinir l'environnement de type \envir{matrix}; |
| 391 |
\meta{type} est une chaine de caractère dont l'utilisation sera expliquée |
| 392 |
ci-dessous --- voir~\ref{sec:matrix-type} --- et \meta{\vliste des |
| 393 |
coefficients} est la \vliste des coefficients de la matrice donnés ligne par |
| 394 |
ligne. |
| 395 |
\end{function} |
| 396 |
%</FRA> |
| 397 |
|
| 398 |
%<ENG> With |
| 399 |
%<FRA> Avec |
| 400 |
\lstinline+$\matrice{1, 2, 3, 4}$+ |
| 401 |
%<ENG> we obtain |
| 402 |
%<FRA> on obtient |
| 403 |
\(\matrice{1, 2, 3, 4}\). |
| 404 |
|
| 405 |
%<ENG> With |
| 406 |
%<FRA> Avec |
| 407 |
\lstinline+$\matrice(b)[3]{1, 2, 3, 4, 5, 6}$+ |
| 408 |
%<ENG> we obtain |
| 409 |
%<FRA> on obtient |
| 410 |
\(\matrice(b)[3]{1, 2, 3, 4, 5, 6}\). |
| 411 |
|
| 412 |
%<*ENG> |
| 413 |
\begin{function}{\declarermatrice} |
| 414 |
\begin{syntax} |
| 415 |
\csmute{declarermatrice}\parg{prefix}\darg{\string<}{clist of key-value pairs}{\string>}\marg{matrix name}\oarg{type}\marg{clist of coefficients} |
| 416 |
\end{syntax} |
| 417 |
\end{function} |
| 418 |
|
| 419 |
\begin{function}{\declarermatrice*} |
| 420 |
\begin{syntax} |
| 421 |
\csprint{declarermatrice*}\parg{prefix}\darg{\string<}{clist of key-value pairs}{\string>}\marg{matrix name}\oarg{type}\marg{clist of coefficients} |
| 422 |
\end{syntax} |
| 423 |
where \meta{matrix name} is the name of the matrix to be used afterwards. The |
| 424 |
other arguments, optional or mandatory, have the same meaning than above. The |
| 425 |
starred version defines and prints the matrix. The unstarred version only |
| 426 |
defines it. |
| 427 |
|
| 428 |
The definition is global but one can redefine an existing named matrix with |
| 429 |
the same function. \textbf{No check is done} to ensure that one is not |
| 430 |
redefining a previously defined matrix. |
| 431 |
|
| 432 |
With the macro \csmute{declarermatrice}, the first two optional arguments have |
| 433 |
no effect for they are not take into account to define the matrix \VoirEx{sec:declar}. |
| 434 |
|
| 435 |
The French \emph{déclarer une matrice} means ``declare a matrix''. |
| 436 |
\end{function} |
| 437 |
%</ENG> |
| 438 |
|
| 439 |
%<*FRA> |
| 440 |
\begin{function}{\declarermatrice} |
| 441 |
\begin{syntax} |
| 442 |
\csmute{declarermatrice}\parg{prefixe}\darg{\string<}{\vliste de paires de clé-valeur}{\string>}\marg{nom}\oarg{type}\marg{\vliste des coefficients} |
| 443 |
\end{syntax} |
| 444 |
\end{function} |
| 445 |
|
| 446 |
|
| 447 |
\begin{function}{\declarermatrice*} |
| 448 |
\begin{syntax} |
| 449 |
\csprint{declarermatrice*}\parg{prefixe}\darg{\string<}{\vliste de paires de clé-valeur}{\string>}\marg{nom}\oarg{type}\marg{\vliste des coefficients} |
| 450 |
\end{syntax} |
| 451 |
où \meta{nom} est le nom de la matrice pour utilisation future. Les autres |
| 452 |
arguments, optionnels ou obligatoires, ont la même signification que |
| 453 |
ci-dessus. La version étoilée définit et écrit la matrice. La version |
| 454 |
non-étoilée ne fait que la définir. |
| 455 |
|
| 456 |
La définition est globale mais on peut redéfinir une matrice nommée existante |
| 457 |
avec la même fonction. \textbf{Aucun contrôle} n'est exercé pour s'assurer que |
| 458 |
l'on n'est pas en train de redéfinir une matrice nommée précédemment définie. |
| 459 |
|
| 460 |
Avec la macro \csmute{declarermatrice}, les deux premiers arguments optionnels |
| 461 |
n'ont aucun effet car la définition de la matrice n'en tient pas compte \VoirEx{sec:declar}. |
| 462 |
\end{function} |
| 463 |
%</FRA> |
| 464 |
|
| 465 |
%<*ENG> |
| 466 |
\begin{function}{\lamatrice} |
| 467 |
\begin{syntax} |
| 468 |
\csprint{lamatrice}\parg{prefix}\darg{\string<}{clist of key-value pairs}{\string>}\marg{matrix name} |
| 469 |
\end{syntax} |
| 470 |
prints the previously defined matrix the name of which is given by |
| 471 |
\meta{matrix name}. The two optional arguments have the meaning as before \VoirEx{sec:declar}. |
| 472 |
|
| 473 |
The French \emph{la matrice} means ``the matrix''. |
| 474 |
\end{function} |
| 475 |
%</ENG> |
| 476 |
%<*FRA> |
| 477 |
\begin{function}{\lamatrice} |
| 478 |
\begin{syntax} |
| 479 |
\csprint{lamatrice}\parg{prefixe}\darg{\string<}{\vliste de paires de clé-valeur}{\string>}\marg{nom} |
| 480 |
\end{syntax} |
| 481 |
écrit la matrice nommée de nom \meta{nom}. |
| 482 |
Les deux arguments optionnels ont la même signification que ci-dessus \VoirEx{sec:declar}. |
| 483 |
\end{function} |
| 484 |
%</FRA> |
| 485 |
|
| 486 |
%<*ENG> |
| 487 |
\begin{function}{\MatriceInterieur} |
| 488 |
\begin{syntax} |
| 489 |
\csprint{MatriceInterieur} |
| 490 |
\end{syntax} |
| 491 |
gives the inner part of the last printed ---via \csprint{matrice} or |
| 492 |
\csprint{declarermatrice*}--- or defined ---via \csmute{declarermatrice}--- |
| 493 |
matrix. It can be used inside an \envir{array}-like environment |
| 494 |
\VoirEx{sec:matint}. |
| 495 |
|
| 496 |
The French should be \emph{\foreignlanguage{french}{intérieur de la matrice}} |
| 497 |
which means ``inside of the matrix''. What is implicit is the adjective |
| 498 |
``anonymous''. For named matrix see below. |
| 499 |
\end{function} |
| 500 |
%</ENG> |
| 501 |
%<*FRA> |
| 502 |
\begin{function}{\MatriceInterieur} |
| 503 |
\begin{syntax} |
| 504 |
\csprint{MatriceInterieur} |
| 505 |
\end{syntax} |
| 506 |
donne l'intérieur de la dernière matrice écrite --- via \csprint{matrice} ou |
| 507 |
\csprint{declarermatrice*} --- ou définie --- via \csmute{declarermatrice}. On |
| 508 |
peut l'utiliser dans un environnement du genre \envir{array} \VoirEx{sec:matint}. |
| 509 |
\end{function} |
| 510 |
%</FRA> |
| 511 |
|
| 512 |
%<*ENG> |
| 513 |
\begin{function}{\LaMatriceInterieur} |
| 514 |
\begin{syntax} |
| 515 |
\csprint{LaMatriceInterieur}\marg{matrix name} |
| 516 |
\end{syntax} |
| 517 |
gives the inner part of the matrix with name \meta{matrix name}. It can be |
| 518 |
used inside an \envir{array}-like environment \VoirEx{sec:matint}. |
| 519 |
|
| 520 |
Again false French but the parallel with \csprint{lamatrice} should suggest that, |
| 521 |
now, the matrix has a name and we have to use it. |
| 522 |
\end{function} |
| 523 |
|
| 524 |
%</ENG> |
| 525 |
%<*FRA> |
| 526 |
\begin{function}{\LaMatriceInterieur} |
| 527 |
\begin{syntax} |
| 528 |
\csprint{LaMatriceInterieur}\marg{nom} |
| 529 |
\end{syntax} |
| 530 |
donne l'intérieur de la matrice de nom \meta{nom}. On peut l'utiliser dans un |
| 531 |
environnement du genre \envir{array} \VoirEx{sec:matint}. |
| 532 |
\end{function} |
| 533 |
|
| 534 |
%</FRA> |
| 535 |
|
| 536 |
%<*ENG> |
| 537 |
\subsection{Setting the Keys} |
| 538 |
\label{sec:setting-keys} |
| 539 |
|
| 540 |
One can change the values of the keys of \pkg{simples-matrices} with |
| 541 |
\begin{function}{\simplesmatricessetup} |
| 542 |
\begin{syntax} |
| 543 |
\csmute{simplesmatricessetup}\marg{clist of key-value pairs} |
| 544 |
\end{syntax} |
| 545 |
where \meta{clist of key-value pairs} is the usual clist of key-value pairs |
| 546 |
setting one or many of the three keys of the package as presented on |
| 547 |
page~\pageref{sec:keys}. |
| 548 |
|
| 549 |
To stick to established convention the name of this macro is created from the |
| 550 |
name of the package (reduced to \TeX{} letters) followed by \emph{setup}. I |
| 551 |
apologize for that strange linguistic mixture. |
| 552 |
\end{function} |
| 553 |
%</ENG> |
| 554 |
%<*FRA> |
| 555 |
\subsection{Valuer les clés} |
| 556 |
\label{sec:setting-keys} |
| 557 |
|
| 558 |
On peut changer les valeurs des clés de \pkg{simples-matrices} avec |
| 559 |
\begin{function}{\simplesmatricessetup} |
| 560 |
\begin{syntax} |
| 561 |
\csmute{simplesmatricessetup}\marg{\vliste de paires de clé-valeur} |
| 562 |
\end{syntax} |
| 563 |
où \meta{\vliste de paires de clé-valeur} est l'habituelle \vliste de paires de |
| 564 |
clé-valeur valuant une ou plusieurs des trois clés de cette extension |
| 565 |
telles que présentées ci-dessous en page~\pageref{sec:clefs}. |
| 566 |
|
| 567 |
Pour suivre une convention désormais bien établie le nom de cette macro |
| 568 |
consiste en le nom de l'extension --- réduite à ces lettres \TeX{}iennes --- |
| 569 |
suivi de l'anglais \emph{setup}. Je demande pardon pour cette étrange mixture |
| 570 |
linguistique. |
| 571 |
\end{function} |
| 572 |
%</FRA> |
| 573 |
|
| 574 |
%<*ENG> |
| 575 |
\newpage{} |
| 576 |
\subsection{Shortcuts} |
| 577 |
\label{sec:shortcuts} |
| 578 |
|
| 579 |
There are also two \emph{shortcut} macros: |
| 580 |
%</ENG> |
| 581 |
%<*FRA> |
| 582 |
\subsection{Raccourcis} |
| 583 |
\label{sec:shortcuts} |
| 584 |
|
| 585 |
L'extension propose deux macros \emph{raccourcis}: |
| 586 |
%</FRA> |
| 587 |
|
| 588 |
%<*ENG> |
| 589 |
\begin{function}{\matid} |
| 590 |
\begin{syntax} |
| 591 |
\csprint{matid}\parg{prefix}\darg{\string<}{clist of key-value pairs}{\string>}\oarg{coefficient}\marg{number of columns} |
| 592 |
\end{syntax} |
| 593 |
which write the identity matrix --- by default --- with \meta{number of |
| 594 |
columns} columns. If \meta{coefficient} is given, we obtain a diagonal |
| 595 |
matrix with all its coefficients equal to \meta{coefficient}. |
| 596 |
|
| 597 |
The two first optional arguments have the same functionality as in the |
| 598 |
preceding macros. |
| 599 |
|
| 600 |
\emph{matid} stands for \emph{\foreignlanguage{French}{matrice identité}} which means |
| 601 |
``identity matrix''. |
| 602 |
\end{function} |
| 603 |
%</ENG> |
| 604 |
%<*FRA> |
| 605 |
\begin{function}{\matid} |
| 606 |
\begin{syntax} |
| 607 |
\csprint{matid}\parg{prefixe}\darg{\string<}{\vliste de paires de clé-valeur}{\string>}\oarg{coefficient}\marg{nombre de colonnes} |
| 608 |
\end{syntax} |
| 609 |
qui imprime la matrice identité --- par défaut --- avec |
| 610 |
\meta{nombre de colonnes} colonnes. |
| 611 |
Si \meta{coefficient} est fourni, on obtient une matrice diagonale |
| 612 |
dont tous les coefficients non-nuls sont égaux à \meta{coefficient}. |
| 613 |
|
| 614 |
Les deux premiers arguments optionnels ont la même fonction que dans les |
| 615 |
macros précédentes. |
| 616 |
\end{function} |
| 617 |
%</FRA> |
| 618 |
|
| 619 |
%<*ENG> |
| 620 |
\begin{function}{\matnulle} |
| 621 |
\begin{syntax} |
| 622 |
\csprint{matnulle}\parg{prefix}\darg{\string<}{clist of key-value pairs}{\string>}\oarg{coefficient}\marg{number of columns} |
| 623 |
\end{syntax} |
| 624 |
writes the null matrix with \meta{number of columns} columns ---by default--- |
| 625 |
or a matrix containing with \meta{number of columns} columns and all |
| 626 |
coefficients equal to \meta{coefficient}. |
| 627 |
|
| 628 |
The two first optional arguments have the same functionality as in the |
| 629 |
preceding macros. |
| 630 |
|
| 631 |
\emph{matnulle} stands for \emph{\foreignlanguage{French}{matrice nulle}} which means |
| 632 |
``null matrix''. |
| 633 |
\end{function} |
| 634 |
%</ENG> |
| 635 |
%<*FRA> |
| 636 |
\begin{function}{\matnulle} |
| 637 |
\begin{syntax} |
| 638 |
\csprint{matnulle}\parg{prefixe}\darg{\string<}{\vliste de paires de clé-valeur}{\string>}\oarg{coefficient}\marg{nombre de colonnes} |
| 639 |
\end{syntax} |
| 640 |
imprime la matrice nulle \meta{nombre de colonnes} colonnes --- par défaut --- |
| 641 |
ou une matrice de \meta{nombre de colonnes} colonnes dont tous les |
| 642 |
coefficients sont égaux à \meta{coefficient}. |
| 643 |
|
| 644 |
Les deux premiers arguments optionnels ont la même fonction que dans les |
| 645 |
macros précédentes. |
| 646 |
\end{function} |
| 647 |
%</FRA> |
| 648 |
|
| 649 |
\begin{VerbatimOut}[gobble=0]{code00.tex} |
| 650 |
$\matid{3}$\qquad $\matid[9]{3}$ |
| 651 |
\par \medskip |
| 652 |
$\matnulle{3}$\qquad $\matnulle[2]{3}$ |
| 653 |
\end{VerbatimOut} |
| 654 |
\UnExemple{} |
| 655 |
|
| 656 |
%<*ENG> |
| 657 |
\section{The Package Options} |
| 658 |
\label{sec:keys} |
| 659 |
|
| 660 |
The package uses key-value options. There are four keys: |
| 661 |
\keyname{envir}, |
| 662 |
\keyname{prefix}, |
| 663 |
\keyname{typeord} |
| 664 |
and |
| 665 |
\keyname{argopt}. |
| 666 |
|
| 667 |
\begin{description} |
| 668 |
\item[\keyname{envir} (\textit{\texttt{string}})] the main and last part of the |
| 669 |
name of the environment used to print the matrix. Its initial value is |
| 670 |
\texttt{matrix}.\label{key-envir} |
| 671 |
|
| 672 |
\item[\keyname{prefix} (\textit{\texttt{string}})] a string which is prefixed to |
| 673 |
\texttt{envir} to obtain the complete name of the environment. Its initial |
| 674 |
value is \texttt{p}. Therefore, by default, the environment used to print the |
| 675 |
matrix is \envir{pmatrix} as defined by \pkg{amsmath}.\label{key-prefix} |
| 676 |
|
| 677 |
\item[\keyname{typeord} (\textit{\texttt{string}})] a string which is the |
| 678 |
ordinary ---i.~e. default--- value of the \meta{type} optional argument. The |
| 679 |
initial value of the key is \TypeMat{C}.\label{key-typeord} |
| 680 |
|
| 681 |
\item[\keyname{argopt} (\textit{\texttt{token list}})] for French |
| 682 |
\foreignlanguage{french}{\emph{argument optionnel}} (optional argument). That |
| 683 |
key is initially void. See page~\pageref{sec:delarray} for usage.\label{key-argopt} |
| 684 |
\end{description} |
| 685 |
|
| 686 |
Moreover, an other key is available which is not an option of the package: |
| 687 |
\keyname{out-of-box} which is a metakey. |
| 688 |
%</ENG> |
| 689 |
|
| 690 |
%<*FRA> |
| 691 |
\section{Les options de l'extension} |
| 692 |
\label{sec:clefs} |
| 693 |
|
| 694 |
L'extension utilise le système de clefs-valeurs pour ses options. Elle possède |
| 695 |
quatre clés: \keyname{envir}, \keyname{prefix}, \keyname{typeord} et \keyname{argopt}. |
| 696 |
|
| 697 |
\begin{description} |
| 698 |
\item[\keyname{envir} (\textit{\texttt{chaine de caractères}})] est la partie |
| 699 |
finale du nom de l'environnement utilisé pour imprimer la matrice. Sa valeur |
| 700 |
initiale est \texttt{matrix}.\label{key-envir} |
| 701 |
|
| 702 |
\item[\keyname{prefix} (\textit{\texttt{chaine de caractères}})] contient les |
| 703 |
caractères placés devant \texttt{envir} pour fournir le nom complet de |
| 704 |
l'environnement utilisé pour imprimer la matrice. Sa valeur initiale est |
| 705 |
\texttt{p}. Cela fait que l'environnement par défaut est \envir{pmatrix} |
| 706 |
fourni par \pkg{amsmath}.\label{key-prefix} |
| 707 |
|
| 708 |
\item[\keyname{typeord} (\textit{\texttt{chaine de caractères}})] définit la |
| 709 |
valeur ordinaire --- c.-à -d. par défaut --- de l'argument optionnel |
| 710 |
\meta{type}. La valeur initiale de la clé est \TypeMat{C}.\label{key-typeord} |
| 711 |
|
| 712 |
\item[\keyname{argopt} (\textit{\texttt{liste de lexèmes}}, anglais: |
| 713 |
\foreignlanguage{english}{token list})] est vide par défaut. Voir |
| 714 |
page~\pageref{sec:delarray} pour son utilisation.\label{key-argopt} |
| 715 |
\end{description} |
| 716 |
|
| 717 |
De plus, une clé supplémentaire existe qui est une métaclé: |
| 718 |
\keyname{out-of-box}. |
| 719 |
%</FRA> |
| 720 |
|
| 721 |
|
| 722 |
%<ENG> With |
| 723 |
%<FRA> Avec |
| 724 |
\lstinline|\simplesmatricessetup{out-of-box}| |
| 725 |
%<ENG> we obtain the same effect as with |
| 726 |
%<FRA> on obtient le même effet qu'avec |
| 727 |
\lstinline|\simplesmatricessetup{prefix=p,|\BOP\lstinline| envir=matrix,|% |
| 728 |
\BOP\lstinline| argopt=,|\BOP\lstinline| typeord=C}|. |
| 729 |
|
| 730 |
%<*ENG> |
| 731 |
\newpage{} |
| 732 |
\section{Examples} |
| 733 |
\label{sec:examples} |
| 734 |
\subsection{Without any special package} |
| 735 |
\label{sec:amsmath} |
| 736 |
|
| 737 |
That is with only \pkg{amsmath} loaded as done by this package. |
| 738 |
|
| 739 |
\subsubsection{Declaration and Usage} |
| 740 |
\label{sec:declar} |
| 741 |
%</ENG> |
| 742 |
%<*FRA> |
| 743 |
\section{Exemples} |
| 744 |
\label{sec:exemples} |
| 745 |
\subsection{Sans extension particulière} |
| 746 |
\label{sec:amsmath} |
| 747 |
|
| 748 |
C'est-Ã -dire en chargeant uniquement \pkg{amsmath} comme le fait cette extension. |
| 749 |
|
| 750 |
\subsubsection{Déclaration et utilisation} |
| 751 |
\label{sec:declar} |
| 752 |
%</FRA> |
| 753 |
|
| 754 |
\begin{VerbatimOut}[gobble=0]{code00.tex} |
| 755 |
\declarermatrice{A}{1, 2, 300, 400} |
| 756 |
$\declarermatrice*{B}{a, b, c, d}$ |
| 757 |
\quad $\lamatrice{A}$ \par \bigskip |
| 758 |
$\lamatrice(V){A}$ |
| 759 |
\quad $\lamatrice(b){B}$ |
| 760 |
\end{VerbatimOut} |
| 761 |
\UnExemple{} |
| 762 |
|
| 763 |
%<*ENG> |
| 764 |
On the first line of this example, the matrix~\texttt{A} is defined but not |
| 765 |
printed. Then, on the second line, the matrix~\texttt{B} is defined and |
| 766 |
printed. We can afterwards call the~\texttt{A} or \texttt{B}-matrix with |
| 767 |
\csprint{lamatrice}. |
| 768 |
%</ENG> |
| 769 |
%<*FRA> |
| 770 |
Sur la première ligne de l'exemple, la matrice~\texttt{A} est définie mais pas |
| 771 |
écrite. Ensuite, sur la seconde ligne, la matrice~\texttt{B} est définie et |
| 772 |
écrite. Nous pouvons ensuite appeler les matrices~\texttt{A} ou~\texttt{B} à |
| 773 |
l'aide de \csprint{lamatrice}. |
| 774 |
%</FRA> |
| 775 |
|
| 776 |
%<*ENG> |
| 777 |
\subsubsection{The ``\texttt{type}'' argument} |
| 778 |
\label{sec:matrix-type} |
| 779 |
|
| 780 |
The last but one --- optional --- argument of macros \csprint{matrice}, |
| 781 |
\csmute{declarermatrice} and \csprint{declarermatrice*} |
| 782 |
defaults to \TypeMat{O}. In that case the value of the key |
| 783 |
\keyname{typeord} is used to determine the \emph{type} of the matrix input, |
| 784 |
see~\pageref{sec:matrix-type-key}. |
| 785 |
|
| 786 |
Its value can be a number, in which case it is the number of columns, or a |
| 787 |
string ---presently a one letter string--- among: \TypeMat{C}, \TypeMat{D}, |
| 788 |
\TypeMat{I}, \TypeMat{J}, \TypeMat{S}, \TypeMat{T} and \TypeMat{x}. |
| 789 |
%</ENG> |
| 790 |
|
| 791 |
%<*FRA> |
| 792 |
\subsubsection{L'argument \og \texttt{type}\fg} |
| 793 |
\label{sec:matrix-type} |
| 794 |
|
| 795 |
L'avant dernier argument --- optionnel --- des macros \csprint{matrice}, |
| 796 |
\csmute{declarermatrice} et \csprint{declarermatrice*} vaut par défaut |
| 797 |
\TypeMat{O}. Dans ce cas, c'est la valeur de la clé \keyname{typeord} qui est |
| 798 |
utilisée pour déterminer le \emph{type} des données de la matrice, |
| 799 |
voir~\pageref{sec:matrix-type-key}. |
| 800 |
|
| 801 |
Sinon, il peut prendre une valeur numérique qui est le nombre de colonnes de la |
| 802 |
matrice ou encore une chaine de caractères --- à ce jour, une seule lettre --- |
| 803 |
parmi: \TypeMat{C}, \TypeMat{D}, \TypeMat{I}, \TypeMat{J}, \TypeMat{S}, \TypeMat{T} et |
| 804 |
\TypeMat{x}. |
| 805 |
%</FRA> |
| 806 |
|
| 807 |
\medskip{} |
| 808 |
|
| 809 |
%<FRA> \TypeMat{C} signifie matrice \textbf{carrée}. |
| 810 |
%<ENG> \TypeMat{C} means square matrix for French ``\texttt{C}arré'' means ``square''. |
| 811 |
\begin{VerbatimOut}[gobble=0]{code00.tex} |
| 812 |
\[ |
| 813 |
\matrice{1, 2, 3, 4, 5, 6, 7, 8, 9} |
| 814 |
\quad |
| 815 |
\matrice[C]{1, 2, 3, 4, 5, 6, 7, 8, 9} |
| 816 |
\] |
| 817 |
\end{VerbatimOut} |
| 818 |
\UnExemple{} |
| 819 |
|
| 820 |
%<FRA> \TypeMat{D} signifie matrice \textbf{diagonale}. |
| 821 |
%<ENG> \TypeMat{D} means \textbf{diagonal} matrix. |
| 822 |
\begin{VerbatimOut}[gobble=0]{code00.tex} |
| 823 |
\[ |
| 824 |
\matrice{1, 2, 3, 4}\quad |
| 825 |
\matrice[D]{1, 2, 3, 4} |
| 826 |
\] |
| 827 |
\end{VerbatimOut} |
| 828 |
\UnExemple{} |
| 829 |
|
| 830 |
%<*FRA> |
| 831 |
\TypeMat{I} signifie matrice triangulaire \textbf{inférieure}; \TypeMat{J} |
| 832 |
signifie matrice triangulaire inférieure avec des zéros sur la diagonale. |
| 833 |
%</FRA> |
| 834 |
%<*ENG> |
| 835 |
\TypeMat{I} means lower triangular matrix. French ``\texttt{I}nférieur'' means |
| 836 |
``lower''; \TypeMat{J} means lower triangular matrix with zeros on the diagonal. |
| 837 |
%</ENG> |
| 838 |
\begin{VerbatimOut}[gobble=0]{code00.tex} |
| 839 |
\[ |
| 840 |
\matrice[I]{1, 2, 3}\quad |
| 841 |
\matrice[J]{1, 2, 3} |
| 842 |
\] |
| 843 |
\end{VerbatimOut} |
| 844 |
\UnExemple{} |
| 845 |
|
| 846 |
%<*FRA> |
| 847 |
\TypeMat{S} signifie matrice triangulaire \textbf{supérieure}; \TypeMat{T} |
| 848 |
signifie matrice triangulaire supérieure avec des zéros sur la diagonale. |
| 849 |
%</FRA> |
| 850 |
%<*ENG> |
| 851 |
\TypeMat{S} means upper triangular matrix. French ``\texttt{S}upérieur'' means |
| 852 |
``upper''; \TypeMat{T} means upper triangular matrix with zeros on the diagonal. |
| 853 |
%</ENG> |
| 854 |
\begin{VerbatimOut}[gobble=0]{code00.tex} |
| 855 |
\[ |
| 856 |
\matrice[S]{1, 2, 3}\quad |
| 857 |
\matrice[T]{1, 2, 3} |
| 858 |
\] |
| 859 |
\end{VerbatimOut} |
| 860 |
\UnExemple{} |
| 861 |
|
| 862 |
%<*FRA> |
| 863 |
\TypeMat{x} signifie \texttt{xcas}\footnote{Système de calcul formel libre |
| 864 |
disponible ici: |
| 865 |
\url{https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac_fr.html}}. Avec |
| 866 |
cette valeur, on peut copier-coller de \texttt{xcas} dans le document \LaTeX{}. |
| 867 |
%</FRA> |
| 868 |
%<*ENG> |
| 869 |
\TypeMat{x} means \texttt{xcas}\footnote{Free computer algebra system, see here: |
| 870 |
\url{https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac.html}.}. With that value, one can copy-paste from |
| 871 |
\texttt{xcas} into the \LaTeX{} document. |
| 872 |
%</ENG> |
| 873 |
\begin{VerbatimOut}[gobble=0]{code00.tex} |
| 874 |
\[ |
| 875 |
\matrice[x]{[[7,1,3],[1,0,3],[5,1,2]]} |
| 876 |
\] |
| 877 |
\end{VerbatimOut} |
| 878 |
\UnExemple{} |
| 879 |
|
| 880 |
\pagebreak[3] |
| 881 |
%<*FRA> |
| 882 |
Un nombre donne le nombre de colonnes de la matrice. |
| 883 |
%</FRA> |
| 884 |
%<*ENG> |
| 885 |
A number sets up the number of columns of the matrix. |
| 886 |
%</ENG> |
| 887 |
\begin{VerbatimOut}[gobble=0]{code00.tex} |
| 888 |
\[ |
| 889 |
\matrice[2]{1, 2, 3, 4, 5, 6} |
| 890 |
\quad |
| 891 |
\matrice[3]{1, 2, 3, 4, 5, 6} |
| 892 |
\] |
| 893 |
\end{VerbatimOut} |
| 894 |
\UnExemple{} |
| 895 |
|
| 896 |
|
| 897 |
%<*ENG> |
| 898 |
\subsubsection{Using the ``\keyname{typeord}'' Key} |
| 899 |
\label{sec:matrix-type-key} |
| 900 |
|
| 901 |
In this document, the key \keyname{typeord} has the initial value of~\TypeMat{C}. |
| 902 |
%</ENG> |
| 903 |
|
| 904 |
%<*FRA> |
| 905 |
\subsubsection{Utilisation de la clé \og \keyname{typeord}\fg} |
| 906 |
\label{sec:matrix-type-key} |
| 907 |
|
| 908 |
Dans ce document, la clé \keyname{typeord} a comme valeur initiale~\TypeMat{C}. |
| 909 |
%</FRA> |
| 910 |
|
| 911 |
\medskip{} |
| 912 |
|
| 913 |
\begin{VerbatimOut}[gobble=0]{code00.tex} |
| 914 |
\simplesmatricessetup{typeord=3} |
| 915 |
$\matrice{1, 2, 3, 4, 5, 6}$\quad |
| 916 |
\simplesmatricessetup{typeord=2} |
| 917 |
$\matrice{1, 2, 3, 4, 5, 6}$\quad |
| 918 |
\simplesmatricessetup{typeord=C} |
| 919 |
$\matrice{1, 2, 3, 4}$ |
| 920 |
\end{VerbatimOut} |
| 921 |
\UnExemple{} |
| 922 |
|
| 923 |
%<*FRA> |
| 924 |
Le code précédent n'est, bien entendu, donné qu'à titre d'illustration. Pour une |
| 925 |
déclaration de type ne concernant qu'une seule matrice, on aura intérêt à |
| 926 |
utiliser l'argument optionnel. Cependant si on veut rédiger un cours sur les |
| 927 |
matrices triangulaires supérieures\dots{} |
| 928 |
%</FRA> |
| 929 |
%<*ENG> |
| 930 |
The preceding code is but a mere illustration. In order to declare a type for |
| 931 |
one matrix it's more convenient to use the optional argument. However if one |
| 932 |
wants to write a lesson about upper triangular matrices\dots{} |
| 933 |
%</ENG> |
| 934 |
|
| 935 |
%<*ENG> |
| 936 |
\subsubsection{Using the \csprint{(La)MatriceInterieur} Macros} |
| 937 |
\label{sec:matint} |
| 938 |
%</ENG> |
| 939 |
%<*FRA> |
| 940 |
\subsubsection{Utilisation des macros \csprint{(La)MatriceInterieur}} |
| 941 |
\label{sec:matint} |
| 942 |
%</FRA> |
| 943 |
|
| 944 |
\begin{VerbatimOut}[gobble=0]{code00.tex} |
| 945 |
\declarermatrice{B}[4]{ |
| 946 |
\hline ein, zwei, drei, vier, |
| 947 |
\hline unos, dos, tres, cuatro, |
| 948 |
\hline unu, du, tri, kvar}% |
| 949 |
\declarermatrice{A}[3]{ |
| 950 |
one, two, three, |
| 951 |
un, deux, trois, |
| 952 |
uno, due, tre}% |
| 953 |
\begin{tabular}{*{3}{l}} |
| 954 |
\MatriceInterieur %*@\label{anonyme}@*) |
| 955 |
\end{tabular} |
| 956 |
\par \bigskip *** \par \bigskip |
| 957 |
\begin{tabular}{*{3}{l}} |
| 958 |
\LaMatriceInterieur{A} %*@\label{parnom}@*) |
| 959 |
\end{tabular} |
| 960 |
\par \bigskip |
| 961 |
\begin{tabular}{|*{4}{l|}} |
| 962 |
\LaMatriceInterieur{B}\hline |
| 963 |
\end{tabular} |
| 964 |
\end{VerbatimOut} |
| 965 |
\UnExemple{} |
| 966 |
|
| 967 |
%<*ENG> |
| 968 |
On lines~\ref{anonyme} and~\ref{parnom} we use the same \emph{internal} because |
| 969 |
the \texttt{A}-matrix is the last defined before line~\ref{anonyme}. |
| 970 |
%</ENG> |
| 971 |
%<*FRA> |
| 972 |
En lignes~\ref{anonyme} et~\ref{parnom}, nous accédons aux mêmes |
| 973 |
\emph{entrailles} car la matrice~\texttt{A} est la dernière définie avant la |
| 974 |
ligne~\ref{anonyme}. |
| 975 |
%</FRA> |
| 976 |
|
| 977 |
%<*ENG> |
| 978 |
\subsection{Changing the Look} |
| 979 |
\label{sec:changelook} |
| 980 |
|
| 981 |
We can load other packages which deal with matrices such as \pkg{mathtools}, |
| 982 |
\pkg{delarray} or \pkg{nicematrix}. In that case we can change the look of our |
| 983 |
matrices thanks to the option-key \keyname{envir}, \keyname{prefix} and |
| 984 |
\keyname{argopt}. |
| 985 |
|
| 986 |
This document loads the three packages \pkg{mathtools}, \pkg{delarray} and |
| 987 |
\pkg{nicematrix} in order to give the following examples. |
| 988 |
|
| 989 |
%</ENG> |
| 990 |
|
| 991 |
%<*FRA> |
| 992 |
\subsection{Changer l'aspect} |
| 993 |
\label{sec:aspect} |
| 994 |
|
| 995 |
On peut charger d'autres extensions qui permettent de présenter des matrices |
| 996 |
comme \pkg{mathtools}, \pkg{delarray} ou \pkg{nicematrix}. Dans ce cas on peut |
| 997 |
changer l'aspect de nos matrices grace aux clés d'option \keyname{envir}, |
| 998 |
\keyname{prefix} et \keyname{argopt}. |
| 999 |
|
| 1000 |
Ce document charge les trois extensions \pkg{mathtools}, \pkg{delarray} et |
| 1001 |
\pkg{nicematrix} pour présenter les exemples suivants. |
| 1002 |
|
| 1003 |
%</FRA> |
| 1004 |
|
| 1005 |
%<*ENG> |
| 1006 |
\subsubsection{With \pkg{mathtools}} |
| 1007 |
\label{sec:mathtools} |
| 1008 |
|
| 1009 |
As already stated above there are two ways to use the option-keys: through |
| 1010 |
\csmute{simples}\BOP\ObjetPres{cmdmuette}{matrices}\BOP\ObjetPres{cmdmuette}{setup} |
| 1011 |
or through the optional argument \darg{\string<}{clist of pairs of |
| 1012 |
key-value}{\string>}. I show both. |
| 1013 |
%</ENG> |
| 1014 |
%<*FRA> |
| 1015 |
\subsubsection{Avec \pkg{mathtools}} |
| 1016 |
\label{sec:mathtools} |
| 1017 |
|
| 1018 |
Comme déjà signalé, il y a deux façons d'utiliser les clés d'option: à l'aide de |
| 1019 |
\csmute{simplesmatricessetup} ou en utilisant l'argument optionnel |
| 1020 |
\darg{\string<}{\vliste de paires de clé-valeur}{\string>}. Je montre les deux. |
| 1021 |
%</FRA> |
| 1022 |
|
| 1023 |
\begin{VerbatimOut}[gobble=0]{code00.tex} |
| 1024 |
\simplesmatricessetup{ |
| 1025 |
envir=matrix*, prefix=p, argopt=[r]} |
| 1026 |
$\matrice{1, 2, 30, 40}$ \quad |
| 1027 |
\simplesmatricessetup{out-of-box} |
| 1028 |
$\matrice{1, 2, 30, 40}$ |
| 1029 |
\par \medskip |
| 1030 |
$\matrice(b)<envir=matrix*,argopt=[l]> {1, 2, 30, 40}$ |
| 1031 |
\end{VerbatimOut} |
| 1032 |
\UnExemple{} |
| 1033 |
|
| 1034 |
%<*ENG> |
| 1035 |
\subsubsection{With \pkg{delarray}} |
| 1036 |
\label{sec:delarray} |
| 1037 |
|
| 1038 |
%</ENG> |
| 1039 |
%<*FRA> |
| 1040 |
\subsubsection{Avec \pkg{delarray}} |
| 1041 |
\label{sec:delarray} |
| 1042 |
|
| 1043 |
%</FRA> |
| 1044 |
|
| 1045 |
\begin{VerbatimOut}[gobble=0]{code00.tex} |
| 1046 |
\simplesmatricessetup{ |
| 1047 |
envir=array, prefix=, |
| 1048 |
argopt=[c][{l r}\}} |
| 1049 |
$\matrice{1, 2, 30, 40}$ \quad |
| 1050 |
$\matid()<envir=array, |
| 1051 |
argopt={[c][{@{}c c c@{}}\}}>{3}$ |
| 1052 |
\end{VerbatimOut} |
| 1053 |
\UnExemple{} |
| 1054 |
\simplesmatricessetup{out-of-box} |
| 1055 |
|
| 1056 |
|
| 1057 |
%<*ENG> |
| 1058 |
\subsubsection{With \pkg{nicematrix}} |
| 1059 |
\label{sec:nicematrix} |
| 1060 |
%</ENG> |
| 1061 |
%<*FRA> |
| 1062 |
\subsubsection{Avec \pkg{nicematrix}} |
| 1063 |
\label{sec:nicematrix} |
| 1064 |
%</FRA> |
| 1065 |
|
| 1066 |
\begin{VerbatimOut}[gobble=0]{code00.tex} |
| 1067 |
$\matrice<prefix=b, envir=NiceArray, |
| 1068 |
argopt={ {cc||rl} }>{1, 2, 3, 4, 5, 6, |
| 1069 |
7, 8, 9, 10, 11, 12, 13, 14, 15, 16}$ |
| 1070 |
\end{VerbatimOut} |
| 1071 |
\UnExemple{} |
| 1072 |
|
| 1073 |
%<*ENG> |
| 1074 |
In that case we need to double the curly braces around the column descriptors of |
| 1075 |
the \envir{array} environment because the first level is stripped off by |
| 1076 |
\LaTeX{} when valuating the key. |
| 1077 |
|
| 1078 |
\medskip{} |
| 1079 |
|
| 1080 |
In the following example, for the second matrix, it is not necessary to surround |
| 1081 |
the value of \keyname{argopt} with an extra pair of curly braces (see |
| 1082 |
line~\ref{sansaccol}) ---even if it is not dangerous (see |
| 1083 |
line~\ref{avecaccol})--- for the presence of \texttt{[margin]} prevents \LaTeX{} |
| 1084 |
to strip off the curly braces. |
| 1085 |
%</ENG> |
| 1086 |
%<*FRA> |
| 1087 |
Dans ce cas il faut doubler les accolades entourant les descripteurs de colonnes |
| 1088 |
de l'environnement \envir{array} car \LaTeX{} retire un niveau d'accolades en |
| 1089 |
valuant la clé. |
| 1090 |
|
| 1091 |
\medskip{} |
| 1092 |
|
| 1093 |
Dans l'exemple suivant, pour la deuxième matrice, il n'est pas nécessaire |
| 1094 |
d'entourer la valeur de \keyname{argopt} d'une paire d'accolades (voir |
| 1095 |
ligne~\ref{sansaccol}) --- même si ça n'est pas dangereux (voir |
| 1096 |
ligne~\ref{avecaccol}) --- car la présence de \texttt{[margin]} empêche \LaTeX{} |
| 1097 |
de supprimer une paire d'accolades. |
| 1098 |
%</FRA> |
| 1099 |
|
| 1100 |
\begin{VerbatimOut}[gobble=0]{code00.tex} |
| 1101 |
$\matrice<prefix=b, envir=NiceArray, |
| 1102 |
argopt={{l c r}}>{1, 2, 3, 40, 50, 60, |
| 1103 |
700, 800, 900}$ |
| 1104 |
\par \medskip |
| 1105 |
$\matrice<prefix=b, envir=NiceArray, |
| 1106 |
argopt={l c r}[margin]>{1, 2, 3, %*@\label{sansaccol}@*) |
| 1107 |
40, 50, 60, 700, 800, 900}$ |
| 1108 |
\par \medskip |
| 1109 |
$\matrice<prefix=b, envir=NiceArray, |
| 1110 |
argopt={{l c r}[margin]}>{1, 2, 3, %*@\label{avecaccol}@*) |
| 1111 |
40, 50, 60, 700, 800, 900}$ |
| 1112 |
\end{VerbatimOut} |
| 1113 |
\UnExemple{} |
| 1114 |
|
| 1115 |
%<ENG> \section{Thanks} |
| 1116 |
%<FRA> \section{Remerciements} |
| 1117 |
%<*ENG> |
| 1118 |
Many thanks to Denis \textsc{Bitouzé} for his remarks about the initial state of |
| 1119 |
this documentation. Thanks to him, some colours have appeared on these pages. |
| 1120 |
%</ENG> |
| 1121 |
%<*FRA> |
| 1122 |
Mille mercis à Denis \textsc{Bitouzé} pour ses remarques à propos de l'état |
| 1123 |
initial de cette documentation. C'est grâce à lui que quelques couleurs sont |
| 1124 |
apparues sur ces pages. |
| 1125 |
%</FRA> |
| 1126 |
|
| 1127 |
|
| 1128 |
\vspace{\stretch{2}} |
| 1129 |
|
| 1130 |
\noindent\hspace*{0.2\textwidth}\hrulefill\hspace*{0.2\textwidth} |
| 1131 |
\begin{center} |
| 1132 |
\textsl{Le TeXnicien de Surface scripsit.} |
| 1133 |
\end{center} |
| 1134 |
\noindent\hspace*{0.2\textwidth}\hrulefill\hspace*{0.2\textwidth} |
| 1135 |
|
| 1136 |
\vspace*{\stretch{2}} |
| 1137 |
|
| 1138 |
\end{document} |
| 1139 |
%</doc> |
| 1140 |
% \fi |
| 1141 |
% \begin{implementation} |
| 1142 |
% |
| 1143 |
% \section{\pkg{simples-matrices} implementation} |
| 1144 |
% |
| 1145 |
% |
| 1146 |
% \iffalse |
| 1147 |
%<*package> |
| 1148 |
% \fi |
| 1149 |
% |
| 1150 |
%\subsection{Loading And Greeting} |
| 1151 |
%\label{sec:loading} |
| 1152 |
% |
| 1153 |
% \begin{macrocode} |
| 1154 |
%<@@=SMPLMTRC> |
| 1155 |
% \end{macrocode} |
| 1156 |
% |
| 1157 |
% \begin{macrocode} |
| 1158 |
\RequirePackage{l3keys2e,xparse} |
| 1159 |
\ProvidesExplPackage |
| 1160 |
{simples-matrices} {2022/06/08} {1.0} {defining and printing matrices} |
| 1161 |
\RequirePackage{amsmath} |
| 1162 |
% \end{macrocode} |
| 1163 |
% |
| 1164 |
% \pkg{amsmath} is the only auxiliary package loaded. We need it to write the |
| 1165 |
% matrices. |
| 1166 |
% |
| 1167 |
%\subsection{Keys And Options} |
| 1168 |
%\label{sec:keysandoptions} |
| 1169 |
% |
| 1170 |
% I'm using the key management mechanism of \LaTeX3. |
| 1171 |
% |
| 1172 |
% \begin{macrocode} |
| 1173 |
\keys_define:nn {simples-matrices} |
| 1174 |
{ |
| 1175 |
envir .tl_set:N = \g_@@_nom_environnement_tl, |
| 1176 |
envir .initial:n = {matrix}, |
| 1177 |
prefix .tl_set:N = \g_@@_prefix_environnement_tl, |
| 1178 |
prefix .initial:n = {p}, |
| 1179 |
argopt .tl_set:N = \g@@_argument_environnement_tl, |
| 1180 |
argopt .initial:n = { }, |
| 1181 |
typeord .str_set:N = \g_@@_type_ordinaire_str, |
| 1182 |
typeord .initial:n = { C }, |
| 1183 |
} |
| 1184 |
\ProcessKeysOptions {simples-matrices} |
| 1185 |
% \end{macrocode} |
| 1186 |
% |
| 1187 |
% The keys above defined the package options. The next one may be usefull to |
| 1188 |
% return to a kind of neutral state. |
| 1189 |
% |
| 1190 |
% \begin{macrocode} |
| 1191 |
\keys_define:nn {simples-matrices} |
| 1192 |
{ |
| 1193 |
out-of-box .meta:n = {prefix=p, envir=matrix, argopt=, typeord=C}, |
| 1194 |
} |
| 1195 |
% \end{macrocode} |
| 1196 |
% |
| 1197 |
% |
| 1198 |
%\subsection{Constants And Variables} |
| 1199 |
%\label{sec:const-var} |
| 1200 |
% |
| 1201 |
% To handle the syntax of \texttt{xcas} matrices, I resort to \emph{regex} so I |
| 1202 |
% have to create some constant \emph{regexes}. Some comments are just there to |
| 1203 |
% prevent \texttt{emacs} to go too far in formating the code. |
| 1204 |
% |
| 1205 |
% \begin{macrocode} |
| 1206 |
\regex_const:Nn \c_@@_xcas_debut_regexp {\[\[} %\]\] |
| 1207 |
\regex_const:Nn \c_@@_xcas_fin_regexp {\]\]} |
| 1208 |
\regex_const:Nn \c_@@_xcas_milieu_regexp{\],\ *\[} %\] |
| 1209 |
% \end{macrocode} |
| 1210 |
% |
| 1211 |
% Now come error messages: the first deals with bad numbers of coefficient for |
| 1212 |
% matrices of type I, J, S or T; the second appears when dealing with an x~type |
| 1213 |
% matrix. |
| 1214 |
% |
| 1215 |
% \begin{macrocode} |
| 1216 |
\msg_new:nnnn{simples-matrices}{errorIJST} |
| 1217 |
{The~number~of~coefficients~does~not~fit~the~matrix-type} |
| 1218 |
{I~was~expecting~#1~coefficients~and~obtain~only~#2.} |
| 1219 |
|
| 1220 |
\msg_new:nnnn{simples-matrices}{errorx} |
| 1221 |
{The~data~do~not~seem~to~match~the~x-type} |
| 1222 |
{I~was~expecting~the~data~to~begin~with~"[["} |
| 1223 |
% \end{macrocode} |
| 1224 |
% |
| 1225 |
% To contain the inner part of the matrix, we need a token list global |
| 1226 |
% variable. I chose to built it with a non-letter to try to prevent name clash. |
| 1227 |
% |
| 1228 |
% \begin{macrocode} |
| 1229 |
\tl_new:c {g_@@_contenu_anonyme*_tl} |
| 1230 |
% \end{macrocode} |
| 1231 |
% |
| 1232 |
% \begin{macro}{\@@_creer_matrice_aux:} |
| 1233 |
% |
| 1234 |
% When this macro is called, \cs{g_tmpa_int} contains the number of columns of |
| 1235 |
% the matrix and \cs{g_tmpa_seq} the \emph{sequence} of coefficients. |
| 1236 |
% |
| 1237 |
% \begin{macrocode} |
| 1238 |
\cs_new:Nn \@@_creer_matrice_aux: |
| 1239 |
{ |
| 1240 |
\tl_gclear:c {g_@@_contenu_anonyme*_tl} |
| 1241 |
|
| 1242 |
\seq_map_indexed_inline:Nn \g_tmpa_seq |
| 1243 |
{ |
| 1244 |
\tl_gput_right:cn {g_@@_contenu_anonyme*_tl} { ##2 } |
| 1245 |
\int_compare:nNnTF { \int_mod:nn {##1} { \g_tmpa_int } } = { 0 } |
| 1246 |
{ |
| 1247 |
\tl_gput_right:cn {g_@@_contenu_anonyme*_tl} { \\ } |
| 1248 |
} |
| 1249 |
{ |
| 1250 |
\tl_gput_right:cn {g_@@_contenu_anonyme*_tl} { & } |
| 1251 |
} |
| 1252 |
} |
| 1253 |
} |
| 1254 |
% \end{macrocode} |
| 1255 |
% |
| 1256 |
% At the end of this macro, \cs{g_@@_contenu_anonyme*_tl} contains the inner |
| 1257 |
% part of the matrix. |
| 1258 |
% |
| 1259 |
% \end{macro} |
| 1260 |
% |
| 1261 |
% For I need to match a text against a regex constant, I create a variant of one |
| 1262 |
% of the function of \LaTeX3: |
| 1263 |
% \begin{macrocode} |
| 1264 |
\cs_generate_variant:Nn \regex_match:nnF { nVF } |
| 1265 |
% \end{macrocode} |
| 1266 |
% |
| 1267 |
% The next macro does the bulk of the work in reading the coefficients in the |
| 1268 |
% second argument and managing them according to the data-type which is given in |
| 1269 |
% the first argument. |
| 1270 |
% |
| 1271 |
% \begin{macro}{\@@_creer_matrice:nn} |
| 1272 |
% |
| 1273 |
% To be on the safe side, I begin with clearing the variable. |
| 1274 |
% \begin{macrocode} |
| 1275 |
\cs_new:Nn \@@_creer_matrice:nn |
| 1276 |
{ |
| 1277 |
\tl_gclear:c {g_@@_contenu_anonyme*_tl} |
| 1278 |
% \end{macrocode} |
| 1279 |
% I then read the first argument inside \cs{l_tmpa_str} with \cs{str_set:Nx} in |
| 1280 |
% case the string is contained in a variable. |
| 1281 |
% \begin{macrocode} |
| 1282 |
\str_set:Nx \l_tmpa_str { #1 } |
| 1283 |
% \end{macrocode} |
| 1284 |
% If \verb|#1| is equal to \texttt{O}, I fetch the data-type in the string valued |
| 1285 |
% through the key \texttt{typeord}. |
| 1286 |
% \begin{macrocode} |
| 1287 |
\str_if_eq:VnT \l_tmpa_str { O } |
| 1288 |
{ |
| 1289 |
\str_set:NV \l_tmpa_str \g_@@_type_ordinaire_str |
| 1290 |
} |
| 1291 |
% \end{macrocode} |
| 1292 |
% We enter now the first \texttt{case} which depends on the data-type. The |
| 1293 |
% first case deals with the \texttt{x}-type. Here we obtain the inner part of |
| 1294 |
% the matrix by replacing, according to \emph{regex}. There is no need to |
| 1295 |
% calculate anything. |
| 1296 |
% |
| 1297 |
% If ever there are other types of the same kind ---e.~g. to deal with |
| 1298 |
% \texttt{maxima} syntax or the like--- those types would be dealt with here. |
| 1299 |
% |
| 1300 |
% \begin{macrocode} |
| 1301 |
\str_case:VnF \l_tmpa_str |
| 1302 |
{ |
| 1303 |
{ x } { |
| 1304 |
\tl_set:Nn \l_tmpa_tl { #2 } |
| 1305 |
|
| 1306 |
\regex_match:nVF {\A\s*\[\[} %\]\] |
| 1307 |
\l_tmpa_tl |
| 1308 |
{ |
| 1309 |
\msg_fatal:nn{simples-matrices} {errorx} |
| 1310 |
} |
| 1311 |
|
| 1312 |
\regex_replace_all:NnN \c_@@_xcas_debut_regexp { } \l_tmpa_tl |
| 1313 |
\regex_replace_all:NnN \c_@@_xcas_fin_regexp { \c{\\} } \l_tmpa_tl |
| 1314 |
\regex_replace_all:NnN \c_@@_xcas_milieu_regexp { \c{\\} } \l_tmpa_tl |
| 1315 |
\regex_replace_all:nnN { , }{ & } \l_tmpa_tl |
| 1316 |
|
| 1317 |
\tl_set_eq:cN {g_@@_contenu_anonyme*_tl} \l_tmpa_tl |
| 1318 |
} |
| 1319 |
} |
| 1320 |
% \end{macrocode} |
| 1321 |
% The \texttt{x} -type is done. Now for the \texttt{false} part of the |
| 1322 |
% \texttt{case} where I will take care of the other kind of data-types, those |
| 1323 |
% which require calculations. |
| 1324 |
% |
| 1325 |
% I prepare the work by reading the second argument inside the \emph{sequence} |
| 1326 |
% \cs{g_tmpa_seq} and cleaning \cs{g_tmpb_seq}. |
| 1327 |
% \begin{macrocode} |
| 1328 |
{ |
| 1329 |
\seq_set_from_clist:Nn \g_tmpa_seq { #2 } |
| 1330 |
\seq_clear:N \l_tmpb_seq |
| 1331 |
% \end{macrocode} |
| 1332 |
% Now come the second \texttt{case}: |
| 1333 |
% \begin{macrocode} |
| 1334 |
\str_case:VnF \l_tmpa_str |
| 1335 |
{ |
| 1336 |
% \end{macrocode} |
| 1337 |
% The first case is that of the square matrices. I calculate the number of |
| 1338 |
% columns as the square root of the number of coefficients. There is, as for |
| 1339 |
% now, no check for correctness because in case of bad number of coefficients |
| 1340 |
% there will just be a strange matrix, with void cells. |
| 1341 |
% \begin{macrocode} |
| 1342 |
{ C } { |
| 1343 |
\int_set:Nn \g_tmpb_int { \seq_count:N \g_tmpa_seq } |
| 1344 |
\int_set:Nn \g_tmpa_int { \fp_to_int:n { sqrt(\g_tmpb_int) } } |
| 1345 |
} |
| 1346 |
% \end{macrocode} |
| 1347 |
% In case of a diagonal matrix, the number of columns is simply the number of |
| 1348 |
% coefficients but we have to create the suitable \emph{sequence}. The trick is |
| 1349 |
% just to add as many zeros as there are columns between each given coefficient. |
| 1350 |
% \begin{macrocode} |
| 1351 |
{ D } { |
| 1352 |
\int_set:Nn \g_tmpa_int { \seq_count:N \g_tmpa_seq } |
| 1353 |
\seq_pop_left:NN \g_tmpa_seq \l_tmpa_tl |
| 1354 |
\seq_put_right:NV \l_tmpb_seq \l_tmpa_tl |
| 1355 |
|
| 1356 |
\bool_until_do:nn { \seq_if_empty_p:N \g_tmpa_seq } |
| 1357 |
{ |
| 1358 |
\int_step_inline:nn { \g_tmpa_int } |
| 1359 |
{ |
| 1360 |
\seq_put_right:Nn \l_tmpb_seq { 0 } |
| 1361 |
} |
| 1362 |
\seq_pop:NN \g_tmpa_seq \l_tmpa_tl |
| 1363 |
\seq_put_right:NV \l_tmpb_seq \l_tmpa_tl |
| 1364 |
} |
| 1365 |
\seq_set_eq:NN \g_tmpa_seq \l_tmpb_seq |
| 1366 |
} |
| 1367 |
% \end{macrocode} |
| 1368 |
% The code for the next four cases is very similar. We have to calculate the |
| 1369 |
% number of columns from the number of coefficient and then complete the |
| 1370 |
% \emph{sequence} of coefficients. |
| 1371 |
% |
| 1372 |
% Here I check the correctness because, otherwise, in case of error \LaTeX{} |
| 1373 |
% doesn't behave kindly. |
| 1374 |
% |
| 1375 |
% The number of coefficients \emph{non-necessarily} null in a triangular matrix |
| 1376 |
% with \(n\)~columns is \(n(n+1)/2\) or \(n(n-1)/2\) if the diagonal is |
| 1377 |
% \emph{null}. Therefore the computing of \cs{g_tmpa_int} from \cs{g_tmpb_int} |
| 1378 |
% which is equal to the number of coefficients, that is the number of items in |
| 1379 |
% the \emph{sequence} \cs{g_tmpa_seq}. |
| 1380 |
% |
| 1381 |
% In the first case (upper triangular) there are coefficients on the diagonal so |
| 1382 |
% we have to append \(L-1\) zeros before \(N+1-L\) coefficients where \(L\) is |
| 1383 |
% the line number and \(N\) the number of columns. |
| 1384 |
% |
| 1385 |
% \begin{macrocode} |
| 1386 |
{ S } { |
| 1387 |
\int_set:Nn \g_tmpb_int { \seq_count:N \g_tmpa_seq } |
| 1388 |
\int_set:Nn \g_tmpa_int |
| 1389 |
{ |
| 1390 |
\fp_to_int:n { ( sqrt(1 + 8*\g_tmpb_int) - 1 ) / 2 } |
| 1391 |
} |
| 1392 |
% \end{macrocode} |
| 1393 |
% We check for correctness and abort in case of discrepancy. |
| 1394 |
% \begin{macrocode} |
| 1395 |
\int_compare:nNnF |
| 1396 |
{2*\g_tmpb_int} = { \g_tmpa_int * (\g_tmpa_int + 1)} |
| 1397 |
{ |
| 1398 |
\msg_fatal:nnxx{simples-matrices} |
| 1399 |
{errorIJST} |
| 1400 |
{\int_to_arabic:n{(\g_tmpa_int * (\g_tmpa_int + 1))/2}} |
| 1401 |
{\int_to_arabic:n{\g_tmpb_int}} |
| 1402 |
} |
| 1403 |
% \end{macrocode} |
| 1404 |
% \verb|##1| is the line number of the matrix |
| 1405 |
% \begin{macrocode} |
| 1406 |
|
| 1407 |
\int_step_inline:nn { \g_tmpa_int } |
| 1408 |
{ |
| 1409 |
\int_step_inline:nn { ##1 - 1 } |
| 1410 |
{ |
| 1411 |
\seq_put_right:Nn \l_tmpb_seq {0} |
| 1412 |
} |
| 1413 |
\int_step_inline:nn { \g_tmpa_int - ##1 + 1 } |
| 1414 |
{ |
| 1415 |
\seq_pop:NN \g_tmpa_seq \l_tmpa_tl |
| 1416 |
\seq_put_right:NV \l_tmpb_seq \l_tmpa_tl |
| 1417 |
} |
| 1418 |
} |
| 1419 |
|
| 1420 |
\seq_set_eq:NN \g_tmpa_seq \l_tmpb_seq |
| 1421 |
|
| 1422 |
} |
| 1423 |
% \end{macrocode} |
| 1424 |
% When there are zeros on the diagonal, the formula changes a tiny bit: append |
| 1425 |
% \(L\) zeros before \(N-L\) coefficients. |
| 1426 |
% \begin{macrocode} |
| 1427 |
{ T } { |
| 1428 |
\int_set:Nn \g_tmpb_int { \seq_count:N \g_tmpa_seq } |
| 1429 |
\int_set:Nn \g_tmpa_int |
| 1430 |
{ |
| 1431 |
\fp_to_int:n { (1 + sqrt(1 + 8*\g_tmpb_int) ) / 2 } |
| 1432 |
} |
| 1433 |
\int_compare:nNnF |
| 1434 |
{2*\g_tmpb_int} = { \g_tmpa_int * (\g_tmpa_int - 1)} |
| 1435 |
{ |
| 1436 |
\msg_fatal:nnxx{simples-matrices} |
| 1437 |
{errorIJST} |
| 1438 |
{\int_to_arabic:n{(\g_tmpa_int * (\g_tmpa_int - 1))/2}} |
| 1439 |
{\int_to_arabic:n{\g_tmpb_int}} |
| 1440 |
} |
| 1441 |
\int_step_inline:nn { \g_tmpa_int } |
| 1442 |
{ |
| 1443 |
\int_step_inline:nn { ##1 } |
| 1444 |
{ |
| 1445 |
\seq_put_right:Nn \l_tmpb_seq {0} |
| 1446 |
} |
| 1447 |
\int_step_inline:nn { \g_tmpa_int - ##1 } |
| 1448 |
{ |
| 1449 |
\seq_pop:NN \g_tmpa_seq \l_tmpa_tl |
| 1450 |
\seq_put_right:NV \l_tmpb_seq \l_tmpa_tl |
| 1451 |
} |
| 1452 |
} |
| 1453 |
\seq_set_eq:NN \g_tmpa_seq \l_tmpb_seq |
| 1454 |
} |
| 1455 |
% \end{macrocode} |
| 1456 |
% Now come the cases for lower triangular matrices. First \emph{with diagonal}. |
| 1457 |
% \begin{macrocode} |
| 1458 |
{ I } { |
| 1459 |
\int_set:Nn \g_tmpb_int { \seq_count:N \g_tmpa_seq } |
| 1460 |
\int_set:Nn \g_tmpa_int |
| 1461 |
{ |
| 1462 |
\fp_to_int:n { ( sqrt(1 + 8*\g_tmpb_int) - 1 ) / 2 } |
| 1463 |
} |
| 1464 |
\int_compare:nNnF |
| 1465 |
{2*\g_tmpb_int} = { \g_tmpa_int * (\g_tmpa_int + 1)} |
| 1466 |
{ |
| 1467 |
\msg_fatal:nnxx{simples-matrices} |
| 1468 |
{errorIJST} |
| 1469 |
{\int_to_arabic:n{(\g_tmpa_int * (\g_tmpa_int + 1))/2}} |
| 1470 |
{\int_to_arabic:n{\g_tmpb_int}} |
| 1471 |
} |
| 1472 |
\int_step_inline:nn { \g_tmpa_int } |
| 1473 |
{ |
| 1474 |
\int_step_inline:nn { ##1 } |
| 1475 |
{ |
| 1476 |
\seq_pop:NN \g_tmpa_seq \l_tmpa_tl |
| 1477 |
\seq_put_right:NV \l_tmpb_seq \l_tmpa_tl |
| 1478 |
} |
| 1479 |
\int_step_inline:nn { \g_tmpa_int - ##1 } |
| 1480 |
{ |
| 1481 |
\seq_put_right:Nn \l_tmpb_seq {0} |
| 1482 |
} |
| 1483 |
} |
| 1484 |
\seq_set_eq:NN \g_tmpa_seq \l_tmpb_seq |
| 1485 |
} |
| 1486 |
% \end{macrocode} |
| 1487 |
% Secondly \emph{without diagonal}. |
| 1488 |
% \begin{macrocode} |
| 1489 |
{ J } { |
| 1490 |
\int_set:Nn \g_tmpb_int { \seq_count:N \g_tmpa_seq } |
| 1491 |
\int_set:Nn \g_tmpa_int |
| 1492 |
{ |
| 1493 |
\fp_to_int:n { (1 + sqrt(1 + 8*\g_tmpb_int) ) / 2 } |
| 1494 |
} |
| 1495 |
\int_compare:nNnF |
| 1496 |
{2*\g_tmpb_int} = { \g_tmpa_int * (\g_tmpa_int - 1)} |
| 1497 |
{ |
| 1498 |
\msg_fatal:nnxx{simples-matrices} |
| 1499 |
{errorIJST} |
| 1500 |
{\int_to_arabic:n{(\g_tmpa_int * (\g_tmpa_int - 1))/2}} |
| 1501 |
{\int_to_arabic:n{\g_tmpb_int}} |
| 1502 |
} |
| 1503 |
\int_step_inline:nn { \g_tmpa_int } |
| 1504 |
{ |
| 1505 |
\int_step_inline:nn { ##1 -1} |
| 1506 |
{ |
| 1507 |
\seq_pop:NN \g_tmpa_seq \l_tmpa_tl |
| 1508 |
\seq_put_right:NV \l_tmpb_seq \l_tmpa_tl |
| 1509 |
} |
| 1510 |
\int_step_inline:nn { \g_tmpa_int - ##1 + 1} |
| 1511 |
{ |
| 1512 |
\seq_put_right:Nn \l_tmpb_seq {0} |
| 1513 |
} |
| 1514 |
} |
| 1515 |
\seq_set_eq:NN \g_tmpa_seq \l_tmpb_seq |
| 1516 |
} |
| 1517 |
} |
| 1518 |
% \end{macrocode} |
| 1519 |
% Here we attain the \texttt{false} part of the second \texttt{case}. We assume |
| 1520 |
% that we have a number in \verb|#1|. |
| 1521 |
% \begin{macrocode} |
| 1522 |
{ |
| 1523 |
\int_set:Nn \g_tmpa_int { \l_tmpa_str } |
| 1524 |
} |
| 1525 |
% \end{macrocode} |
| 1526 |
% If all is well, here it ends well with the number of columns in |
| 1527 |
% \cs{g_tmpa_int} and all the coefficients of the matrix in \cs{g_tmpa_seq}. So |
| 1528 |
% it's time to call |
| 1529 |
% \begin{macrocode} |
| 1530 |
\@@_creer_matrice_aux: |
| 1531 |
} |
| 1532 |
} |
| 1533 |
% \end{macrocode} |
| 1534 |
% \end{macro} |
| 1535 |
% |
| 1536 |
% \begin{macro}{\MatriceInterieur} |
| 1537 |
% A document command to access the inner part of the \textbf{last} printed |
| 1538 |
% ---via \cs{matrice}--- or defined ---via \cs{declarermatrice}--- matrix. |
| 1539 |
% |
| 1540 |
% This macro can be placed inside an \env{array}-like environment. |
| 1541 |
% \begin{macrocode} |
| 1542 |
\cs_new:Npn \MatriceInterieur |
| 1543 |
{ |
| 1544 |
\tl_use:c { g_@@_contenu_anonyme*_tl } |
| 1545 |
} |
| 1546 |
% \end{macrocode} |
| 1547 |
% \end{macro} |
| 1548 |
% |
| 1549 |
% |
| 1550 |
% \begin{macro}{\LaMatriceInterieur} |
| 1551 |
% A version to access the inner part of a named matrix: |
| 1552 |
% |
| 1553 |
% \begin{macrocode} |
| 1554 |
\cs_new:Npn \LaMatriceInterieur #1 |
| 1555 |
{ |
| 1556 |
\tl_use:c { g_@@_contenu_nom_#1_tl } |
| 1557 |
} |
| 1558 |
% \end{macrocode} |
| 1559 |
% \end{macro} |
| 1560 |
% |
| 1561 |
% |
| 1562 |
% The next macro is used to print a matrix. Its name means \emph{prepare (the) |
| 1563 |
% presentation} of the matrix. It builds the name of the environment, taking |
| 1564 |
% care of possible arguments of the said environment. |
| 1565 |
% |
| 1566 |
% \begin{macro}{\@@_preparer_presentation:nn} |
| 1567 |
% At the end of the macro, \cs{g_tmpa_tl} contains the \emph{overture} of the |
| 1568 |
% environment and \cs{g_tmpb_tl} the \emph{grand final}. |
| 1569 |
% |
| 1570 |
% \begin{macrocode} |
| 1571 |
\cs_new:Nn \@@_preparer_presentation:nn |
| 1572 |
{ |
| 1573 |
\IfValueT{#1} |
| 1574 |
{ |
| 1575 |
\keys_set:nn {simples-matrices} {prefix = #1} |
| 1576 |
} |
| 1577 |
\IfValueT{#2} |
| 1578 |
{ |
| 1579 |
\keys_set:nn {simples-matrices} { #2 } |
| 1580 |
} |
| 1581 |
\tl_set:NV \l_tmpa_tl \g_@@_prefix_environnement_tl |
| 1582 |
\tl_put_right:NV \l_tmpa_tl \g_@@_nom_environnement_tl |
| 1583 |
\tl_set:Nn \g_tmpa_tl { \begin{\l_tmpa_tl} } |
| 1584 |
\tl_put_right:NV \g_tmpa_tl \g@@_argument_environnement_tl |
| 1585 |
\tl_set:Nn \g_tmpb_tl {\end{\l_tmpa_tl} } |
| 1586 |
} |
| 1587 |
% \end{macrocode} |
| 1588 |
% \end{macro} |
| 1589 |
% |
| 1590 |
% Now comes the first main document command which prints the matrix from the |
| 1591 |
% data-type and coefficients. It assigns the different arguments to the |
| 1592 |
% auxiliary macros and finishes with using the token lists created by the |
| 1593 |
% auxiliaries. |
| 1594 |
% |
| 1595 |
% \begin{macro}{\matrice} |
| 1596 |
% \begin{macrocode} |
| 1597 |
\NewDocumentCommand{\matrice}{ d() d<> O{O} m } |
| 1598 |
{ |
| 1599 |
\@@_creer_matrice:nn { #3 } { #4 } |
| 1600 |
\@@_preparer_presentation:nn { #1 } { #2 } |
| 1601 |
\tl_use:N \g_tmpa_tl |
| 1602 |
\tl_use:c { g_@@_contenu_anonyme*_tl } |
| 1603 |
\tl_use:N \g_tmpb_tl |
| 1604 |
} |
| 1605 |
% \end{macrocode} |
| 1606 |
% \end{macro} |
| 1607 |
% |
| 1608 |
% I provide a way of changing the keys inside the document with the usual |
| 1609 |
% \emph{setup} macro: |
| 1610 |
% \begin{macro}{\simplesmatricessetup} |
| 1611 |
% \begin{macrocode} |
| 1612 |
\NewDocumentCommand{\simplesmatricessetup}{m} |
| 1613 |
{ |
| 1614 |
\keys_set:nn {simples-matrices} { #1 } |
| 1615 |
} |
| 1616 |
% \end{macrocode} |
| 1617 |
% \end{macro} |
| 1618 |
% |
| 1619 |
% Another main document command to define a named matrix. The starred version |
| 1620 |
% defines and prints. |
| 1621 |
% |
| 1622 |
% The first mandatory argument ---the 4th of all--- should contain the ``name'' |
| 1623 |
% of the matrix with which one can recall the matrix using \cs{lamatrice}. |
| 1624 |
% \begin{macro}{\declarermatrice} |
| 1625 |
% \begin{macrocode} |
| 1626 |
\NewDocumentCommand{\declarermatrice}{ s d() d<> m O{O} m } |
| 1627 |
{ |
| 1628 |
\@@_creer_matrice:nn { #5 } { #6 } |
| 1629 |
\tl_gset_eq:cc {g_@@_contenu_nom_#4_tl} {g_@@_contenu_anonyme*_tl} |
| 1630 |
\IfBooleanT { #1 } |
| 1631 |
{ |
| 1632 |
\@@_preparer_presentation:nn { #2 } { #3 } |
| 1633 |
\tl_use:N \g_tmpa_tl |
| 1634 |
\tl_use:c { g_@@_contenu_anonyme*_tl } |
| 1635 |
\tl_use:N \g_tmpb_tl |
| 1636 |
} |
| 1637 |
} |
| 1638 |
% \end{macrocode} |
| 1639 |
% \end{macro} |
| 1640 |
% |
| 1641 |
% To print a named matrix: |
| 1642 |
% \begin{macro}{\lamatrice} |
| 1643 |
% \begin{macrocode} |
| 1644 |
\NewDocumentCommand{\lamatrice}{ d() d<> m } |
| 1645 |
{ |
| 1646 |
\@@_preparer_presentation:nn { #1 } { #2 } |
| 1647 |
\tl_use:N \g_tmpa_tl |
| 1648 |
\tl_use:c { g_@@_contenu_nom_#3_tl } |
| 1649 |
\tl_use:N \g_tmpb_tl |
| 1650 |
} |
| 1651 |
% \end{macrocode} |
| 1652 |
% \end{macro} |
| 1653 |
% |
| 1654 |
% For the next commands, I need a variant: |
| 1655 |
% \begin{macrocode} |
| 1656 |
\cs_generate_variant:Nn \@@_creer_matrice:nn { nV } |
| 1657 |
% \end{macrocode} |
| 1658 |
% |
| 1659 |
% The auxiliary macro to print an identity matrix. \verb|#1| will receive the value |
| 1660 |
% to print in the diagonal ---defaulting to \(1\)--- and \verb|#2| the number of |
| 1661 |
% columns. |
| 1662 |
% \begin{macro}{\@@_creer_matrice_identite:nn} |
| 1663 |
% \begin{macrocode} |
| 1664 |
\cs_new:Nn \@@_creer_matrice_identite:nn |
| 1665 |
{ |
| 1666 |
\clist_clear:N \l_tmpa_clist |
| 1667 |
\int_step_inline:nn { #2 } |
| 1668 |
{ |
| 1669 |
\clist_put_left:Nn \l_tmpa_clist { #1 } |
| 1670 |
} |
| 1671 |
\@@_creer_matrice:nV {D} \l_tmpa_clist |
| 1672 |
} |
| 1673 |
% \end{macrocode} |
| 1674 |
% \end{macro} |
| 1675 |
% |
| 1676 |
% I can then use it to define the document command: |
| 1677 |
% \begin{macro}{\matid} |
| 1678 |
% \begin{macrocode} |
| 1679 |
\NewDocumentCommand{\matid}{ d() d<> O{1} m} |
| 1680 |
{ |
| 1681 |
\@@_creer_matrice_identite:nn { #3 } { #4 } |
| 1682 |
\@@_preparer_presentation:nn { #1 } { #2 } |
| 1683 |
\tl_use:N \g_tmpa_tl |
| 1684 |
\tl_use:c { g_@@_contenu_anonyme*_tl } |
| 1685 |
\tl_use:N \g_tmpb_tl |
| 1686 |
} |
| 1687 |
% \end{macrocode} |
| 1688 |
% \end{macro} |
| 1689 |
% |
| 1690 |
% I follow the same pattern for null matrices. First the auxiliary macro, \verb|#2| |
| 1691 |
% is the number of columns, \verb|#1| the value of all the coefficients ---defaulting |
| 1692 |
% to \(0\)---. |
| 1693 |
% \begin{macro}{\@@_creer_matrice_nulle:nn} |
| 1694 |
% \begin{macrocode} |
| 1695 |
\cs_new:Nn \@@_creer_matrice_nulle:nn |
| 1696 |
{ |
| 1697 |
\clist_clear:N \l_tmpa_clist |
| 1698 |
\int_step_inline:nn { #2*#2 } |
| 1699 |
{ |
| 1700 |
\clist_put_left:Nn \l_tmpa_clist { #1 } |
| 1701 |
} |
| 1702 |
\@@_creer_matrice:nV {C} \l_tmpa_clist |
| 1703 |
} |
| 1704 |
% \end{macrocode} |
| 1705 |
% \end{macro} |
| 1706 |
% |
| 1707 |
% I can again use it to define the document command: |
| 1708 |
% \begin{macro}{\matnulle} |
| 1709 |
% \begin{macrocode} |
| 1710 |
\NewDocumentCommand{\matnulle}{ d() d<> O{0} m} |
| 1711 |
{ |
| 1712 |
\@@_creer_matrice_nulle:nn {#3} {#4} |
| 1713 |
\@@_preparer_presentation:nn { #1 } { #2 } |
| 1714 |
\tl_use:N \g_tmpa_tl |
| 1715 |
\tl_use:c { g_@@_contenu_anonyme*_tl } |
| 1716 |
\tl_use:N \g_tmpb_tl |
| 1717 |
} |
| 1718 |
% \end{macrocode} |
| 1719 |
% \end{macro} |
| 1720 |
% |
| 1721 |
% \iffalse |
| 1722 |
%</package> |
| 1723 |
% \fi |
| 1724 |
% |
| 1725 |
% \end{implementation} |
| 1726 |
% |
| 1727 |
% \Finale \PrintChanges\PrintIndex |
| 1728 |
% |
| 1729 |
\endinput |
| 1730 |
%%% Local Variables: |
| 1731 |
%%% mode: doctex |
| 1732 |
%%% coding: utf-8 |
| 1733 |
%%% fill-column: 80 |
| 1734 |
%%% TeX-master: t |
| 1735 |
%%% End: |