blob: 5bd6c6229dcf698444df5fd96fd842e45cb85085 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
%%
%% This is file `phy-diagmat.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% physics2-code.dtx (with options: `diagmat')
%%
%% Copyright (C) 2023 by Zhang Tingxuan <alphaztx@163.com>
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. The latest version of this license is in:
%%
%% http://www.latex-project.org/lppl.txt
%%
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The Current Maintainer of this work is Zhang Tingxuan.
%%
%% This work consists of the files physics2-code.dtx,
%% and the derived files physics2.ins,
%% physics2.sty,
%% phy-<module>.sty,
%% physics2-code.pdf,
%% and README.md.
%%
\ProvidesExplFile{phy-diagmat.sty}{2023/10/24}{}
{`diagmat' module of physics2}
\RequirePackage { amsmath }
\phy@define@key { diagmat } { empty } [ 0 ] { \tl_gset:Nn \l__phy_mat_empty_tl { #1 } }
\clist_new:N \l__phy_mat_diag_clist
\clist_new:N \l__phy_mat_tmpa_clist
\clist_new:N \l__phy_mat_tmpb_clist
\clist_new:N \l__phy_mat_diagpos_clist
\int_new:N \l__phy_mat_dim_int
\tl_new:N \l__phy_mat_line_tl
\tl_new:N \l__phy_diagmat_tl
\tl_new:N \l__phy_mat_empty_tl
\tl_gset:Nn \l__phy_mat_empty_tl { 0 }
\phy@processkeyopt { diagmat }
\keys_define:nn { phy/diagmat }
{
empty .tl_set:N = \l__phy_mat_empty_tl ,
}
\DeclareDocumentCommand \diagmat { O{} m }
{ \__phy_diagmat_type:nnn { } { #1 } { #2 } }
\DeclareDocumentCommand \pdiagmat { O{} m }
{ \__phy_diagmat_type:nnn { p } { #1 } { #2 } }
\DeclareDocumentCommand \bdiagmat { O{} m }
{ \__phy_diagmat_type:nnn { b } { #1 } { #2 } }
\DeclareDocumentCommand \Bdiagmat { O{} m }
{ \__phy_diagmat_type:nnn { B } { #1 } { #2 } }
\DeclareDocumentCommand \vdiagmat { O{} m }
{ \__phy_diagmat_type:nnn { v } { #1 } { #2 } }
\DeclareDocumentCommand \Vdiagmat { O{} m }
{ \__phy_diagmat_type:nnn { V } { #1 } { #2 } }
\cs_new:Npn \__phy_diagmat_type:nnn #1#2#3
{
\group_begin:
\clist_set:Nn \l__phy_mat_diag_clist { #3 }
\int_set:Nn \l__phy_mat_dim_int { \clist_count:N \l__phy_mat_diag_clist }
\int_compare:nNnT { \l__phy_mat_dim_int } > { \value { MaxMatrixCols } }
{ \setcounter { MaxMatrixCols } { \l__phy_mat_dim_int } }
\keys_set:nn { phy/diagmat } { #2 }
\tl_gclear:N \l__phy_diagmat_tl
\int_step_inline:nnn { 0 } { \l__phy_mat_dim_int - 1 }
{
\int_step_inline:nnn { 0 } { \l__phy_mat_dim_int - 1 }
{
\int_compare:nNnTF { ##1 } = { ####1 }
{
\clist_gpop:NN \l__phy_mat_diag_clist \l__phy_tmpa_tl
\tl_if_empty:NTF \l__phy_tmpa_tl
{ \tl_gput_right:Nn \l__phy_mat_line_tl { \l__phy_mat_empty_tl } }
{ \tl_gput_right:Nx \l__phy_mat_line_tl { \l__phy_tmpa_tl } }
}
{ \tl_gput_right:Nn \l__phy_mat_line_tl { \l__phy_mat_empty_tl } }
\int_compare:nNnTF { ####1 } = { \l__phy_mat_dim_int - 1 }
{
\tl_gput_right:Nn \l__phy_mat_line_tl { \\ }
}
{
\tl_gput_right:Nn \l__phy_mat_line_tl { & }
}
}
\tl_gput_right:Nx \l__phy_diagmat_tl { \l__phy_mat_line_tl }
\tl_gclear:N \l__phy_mat_line_tl
}
\begin { #1 matrix }
\tl_use:N \l__phy_diagmat_tl
\end { #1 matrix }
\group_end:
}
\endinput
%%
%% End of file `phy-diagmat.sty'.
|