blob: 9db3b69b3139e5f549bc47bdda3fb91cab156e2c (
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
%%
%% This is file `pgfmath-xfp.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% pgfmath-xfp.dtx (with options: `pkg')
%%
%% --------------------------------------------------------------
%% pgfmath-xfp -- define pgfmath functions using xfp
%% E-mail: jspratte@yahoo.de
%% Released under the LaTeX Project Public License v1.3c or later
%% See http://www.latex-project.org/lppl.txt
%% --------------------------------------------------------------
%%
%% Copyright (C) 2020-2021 Jonathan P. Spratte
%%
%% This work may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License (LPPL), either version 1.3c of this license or
%% (at your option) any later version. The latest version of this license is in
%% the file:
%%
%% http://www.latex-project.org/lppl.txt
%%
%% This work is "maintained" (as per LPPL maintenance status) by
%% Jonathan P. Spratte.
%%
%% This work consists of the file pgfmath-xfp.dtx
%% and the derived files pgfmath-xfp.pdf
%% pgfmath-xfp.sty
%%
\providecommand\DeclareRelease[3]{}
\providecommand\DeclareCurrentRelease[2]{}
\DeclareCurrentRelease{}{2021-05-19}
\@ifundefined{ExplFileDate}
{\RequirePackage{expl3}}
{}
\RequirePackage{pgfmath}
\usepgflibrary{fpu}
\newcommand*\pgfmxfpDate{2021-05-19}
\newcommand*\pgfmxfpVersion{1.0}
\ProvidesExplPackage
{pgfmath-xfp} {\pgfmxfpDate}
{\pgfmxfpVersion} {define pgfmath functions using xfp}
\NewDocumentCommand \pgfmxfpdeclarefunction { m m o m }
{
\IfValueTF {#3}
{ \pgfmxfp_declare_processed_args:nnnn {#1} {#2} {#3} }
{ \pgfmxfp_declare:nnn {#1} {#2} }
{#4}
}
\cs_new_protected:Npn \pgfmxfp_declare:nnn #1#2#3
{
\__pgfmxfp_initialize_body:
\int_step_inline:nn {#2}
{
\tl_put_right:Nx \l__pgfmxfp_function_body_tl
{
\exp_not:n { \pgfmathsetmacro } \exp_not:c { __pgfmxfp_arg##1 }
{ \exp_not:n {####} ##1 }
}
}
\__pgfmxfp_define_function:nnnn {#2} {#1} {#2} {#3}
}
\cs_new_protected:Npn \pgfmxfp_declare_processed_args:nnnn #1#2#3#4
{
\__pgfmxfp_initialize_body:
\int_zero:N \l__pgfmxfp_args_int
\clist_map_inline:nn {#3}
{
\int_incr:N \l__pgfmxfp_args_int
\tl_put_right:Nx \l__pgfmxfp_function_body_tl
{
\exp_not:n { \pgfmathsetmacro }
\exp_not:c { __pgfmxfp_arg \int_use:N \l__pgfmxfp_args_int }
{ \exp_not:n {##1} }
}
}
\exp_args:NV \__pgfmxfp_define_function:nnnn \l__pgfmxfp_args_int {#1} {#2} {#4}
}
\tl_new:N \l__pgfmxfp_function_body_tl
\int_new:N \l__pgfmxfp_args_int
\cs_new_protected:Npn \__pgfmxfp_initialize_body:
{
\tl_set:Nn \l__pgfmxfp_function_body_tl
{
\group_begin:
\pgfkeys{/pgf/fpu=true, /pgf/fpu/output~format=sci}%
}
}
\cs_new_protected:Npn \__pgfmxfp_define_function:nnnn #1#2#3#4
{
\__pgfmxfp_define_internal_function:nnn {#1} {#2} {#4}
\tl_put_right:Nx \l__pgfmxfp_function_body_tl
{
\use:x
{
\exp_not:c { __pgfmxfp_function_ #2 _cmd }
\int_step_function:nN {#1} \__pgfmxfp_define_function_aux:n
}
}
\exp_args:Nnno
\pgfmathdeclarefunction {#2} {#3} \l__pgfmxfp_function_body_tl
}
\cs_new:Npn \__pgfmxfp_define_function_aux:n #1 { { \exp_not:c { __pgfmxfp_arg#1 } } }
\cs_new_protected:Npn \__pgfmxfp_define_internal_function:nnn #1#2#3
{
\exp_last_unbraced:Nx
\cs_set_protected:cpn
{
{ __pgfmxfp_function_ #2 _cmd }
\int_step_function:nN {#1} \__pgfmxfp_define_internal_function_aux:n
}
{ \group_end: \exp_args:Nf \pgfmathparse { \fp_eval:n {#3} } }
}
\cs_new:Npn \__pgfmxfp_define_internal_function_aux:n #1 { \exp_not:n {## #1} }
\ExplSyntaxOff
%%
%%
%% End of file `pgfmath-xfp.sty'.
|