mlib-mat.lua /size: 11 Kb    last modification: 2020-07-01 14:35
1
if
not
modules
then
modules
=
{
}
end
modules
[
'
mlib-mat
'
]
=
{
2
version
=
1
.
001
,
3
comment
=
"
companion to mlib-ctx.mkiv
"
,
4
author
=
"
Hans Hagen, PRAGMA-ADE, Hasselt NL
"
,
5
copyright
=
"
PRAGMA ADE / ConTeXt Development Team
"
,
6
license
=
"
see context related readme files
"
,
7
}
8 9
local
scanners
=
mp
.
scan
10
local
injectors
=
mp
.
inject
11 12
local
scannumeric
=
scanners
.
numeric
13
local
scanpair
=
scanners
.
pair
14
local
scancolor
=
scanners
.
color
15 16
local
mppair
=
injectors
.
pair
or
mp
.
pair
17 18
local
registerscript
=
metapost
.
registerscript
19 20
local
m
=
xmath
21
local
c
=
xcomplex
22 23
local
m_acos
=
m
.
acos
registerscript
(
"
m_acos
"
,
function
(
)
return
m_acos
(
scannumeric
(
)
)
end
)
24
local
m_acosh
=
m
.
acosh
registerscript
(
"
m_acosh
"
,
function
(
)
return
m_acosh
(
scannumeric
(
)
)
end
)
25
local
m_asin
=
m
.
asin
registerscript
(
"
m_asin
"
,
function
(
)
return
m_asin
(
scannumeric
(
)
)
end
)
26
local
m_asinh
=
m
.
asinh
registerscript
(
"
m_asinh
"
,
function
(
)
return
m_asinh
(
scannumeric
(
)
)
end
)
27
local
m_atan
=
m
.
atan
registerscript
(
"
m_atan
"
,
function
(
)
return
m_atan
(
scannumeric
(
)
)
end
)
28
local
m_atan2
=
m
.
atan2
registerscript
(
"
m_atan2
"
,
function
(
)
return
m_atan2
(
scanpair
(
)
)
end
)
29
local
m_atanh
=
m
.
atanh
registerscript
(
"
m_atanh
"
,
function
(
)
return
m_atanh
(
scannumeric
(
)
)
end
)
30
local
m_cbrt
=
m
.
cbrt
registerscript
(
"
m_cbrt
"
,
function
(
)
return
m_cbrt
(
scannumeric
(
)
)
end
)
31
local
m_ceil
=
m
.
ceil
registerscript
(
"
m_ceil
"
,
function
(
)
return
m_ceil
(
scannumeric
(
)
)
end
)
32
local
m_copysign
=
m
.
copysign
registerscript
(
"
m_copysign
"
,
function
(
)
return
m_copysign
(
scanpair
(
)
)
end
)
33
local
m_cos
=
m
.
cos
registerscript
(
"
m_cos
"
,
function
(
)
return
m_cos
(
scannumeric
(
)
)
end
)
34
local
m_cosh
=
m
.
cosh
registerscript
(
"
m_cosh
"
,
function
(
)
return
m_cosh
(
scannumeric
(
)
)
end
)
35
local
m_deg
=
m
.
deg
registerscript
(
"
m_deg
"
,
function
(
)
return
m_deg
(
scannumeric
(
)
)
end
)
36
local
m_erf
=
m
.
erf
registerscript
(
"
m_erf
"
,
function
(
)
return
m_erf
(
scannumeric
(
)
)
end
)
37
local
m_erfc
=
m
.
erfc
registerscript
(
"
m_erfc
"
,
function
(
)
return
m_erfc
(
scannumeric
(
)
)
end
)
38
local
m_exp
=
m
.
exp
registerscript
(
"
m_exp
"
,
function
(
)
return
m_exp
(
scannumeric
(
)
)
end
)
39
local
m_exp2
=
m
.
exp2
registerscript
(
"
m_exp2
"
,
function
(
)
return
m_exp2
(
scannumeric
(
)
)
end
)
40
local
m_expm1
=
m
.
expm1
registerscript
(
"
m_expm1
"
,
function
(
)
return
m_expm1
(
scannumeric
(
)
)
end
)
41
local
m_fabs
=
m
.
fabs
registerscript
(
"
m_fabs
"
,
function
(
)
return
m_fabs
(
scannumeric
(
)
)
end
)
42
local
m_fdim
=
m
.
fdim
registerscript
(
"
m_fdim
"
,
function
(
)
return
m_fdim
(
scanpair
(
)
)
end
)
43
local
m_floor
=
m
.
floor
registerscript
(
"
m_floor
"
,
function
(
)
return
m_floor
(
scannumeric
(
)
)
end
)
44
local
m_fma
=
m
.
fma
registerscript
(
"
m_fma
"
,
function
(
)
return
m_fma
(
scancolor
(
)
)
end
)
45
local
m_fmax
=
m
.
fmax
registerscript
(
"
m_fmax
"
,
function
(
)
return
m_fmax
(
scannumeric
(
)
)
end
)
46
local
m_fmin
=
m
.
fmin
registerscript
(
"
m_fmin
"
,
function
(
)
return
m_fmin
(
scannumeric
(
)
)
end
)
47
local
m_fmod
=
m
.
fmod
registerscript
(
"
m_fmod
"
,
function
(
)
return
m_fmod
(
scanpair
(
)
)
end
)
48
local
m_frexp
=
m
.
frexp
registerscript
(
"
m_frexp
"
,
function
(
)
return
m_frexp
(
scannumeric
(
)
)
end
)
49
local
m_gamma
=
m
.
gamma
registerscript
(
"
m_gamma
"
,
function
(
)
return
m_gamma
(
scannumeric
(
)
)
end
)
50
local
m_hypot
=
m
.
hypot
registerscript
(
"
m_hypot
"
,
function
(
)
return
m_hypot
(
scanpair
(
)
)
end
)
51
local
m_isfinite
=
m
.
isfinite
registerscript
(
"
m_isfinite
"
,
function
(
)
return
m_isfinite
(
scannumeric
(
)
)
end
)
52
local
m_isinf
=
m
.
isinf
registerscript
(
"
m_isinf
"
,
function
(
)
return
m_isinf
(
scannumeric
(
)
)
end
)
53
local
m_isnan
=
m
.
isnan
registerscript
(
"
m_isnan
"
,
function
(
)
return
m_isnan
(
scannumeric
(
)
)
end
)
54
local
m_isnormal
=
m
.
isnormal
registerscript
(
"
m_isnormal
"
,
function
(
)
return
m_isnormal
(
scannumeric
(
)
)
end
)
55
local
m_j0
=
m
.
j0
registerscript
(
"
m_j0
"
,
function
(
)
return
m_j0
(
scannumeric
(
)
)
end
)
56
local
m_j1
=
m
.
j1
registerscript
(
"
m_j1
"
,
function
(
)
return
m_j1
(
scannumeric
(
)
)
end
)
57
local
m_jn
=
m
.
jn
registerscript
(
"
m_jn
"
,
function
(
)
return
m_jn
(
scanpair
(
)
)
end
)
58
local
m_ldexp
=
m
.
ldexp
registerscript
(
"
m_ldexp
"
,
function
(
)
return
m_ldexp
(
scanpair
(
)
)
end
)
59
local
m_lgamma
=
m
.
lgamma
registerscript
(
"
m_lgamma
"
,
function
(
)
return
m_lgamma
(
scannumeric
(
)
)
end
)
60
local
m_log
=
m
.
log
registerscript
(
"
m_log
"
,
function
(
)
return
m_log
(
scannumeric
(
)
)
end
)
61
local
m_log10
=
m
.
log10
registerscript
(
"
m_log10
"
,
function
(
)
return
m_log10
(
scannumeric
(
)
)
end
)
62
local
m_log1p
=
m
.
log1p
registerscript
(
"
m_log1p
"
,
function
(
)
return
m_log1p
(
scannumeric
(
)
)
end
)
63
local
m_log2
=
m
.
log2
registerscript
(
"
m_log2
"
,
function
(
)
return
m_log2
(
scannumeric
(
)
)
end
)
64
local
m_logb
=
m
.
logb
registerscript
(
"
m_logb
"
,
function
(
)
return
m_logb
(
scannumeric
(
)
)
end
)
65
local
m_modf
=
m
.
modf
registerscript
(
"
m_modf
"
,
function
(
)
return
m_modf
(
scannumeric
(
)
)
end
)
66
local
m_nearbyint
=
m
.
nearbyint
registerscript
(
"
m_nearbyint
"
,
function
(
)
return
m_nearbyint
(
scannumeric
(
)
)
end
)
67
local
m_nextafter
=
m
.
nextafter
registerscript
(
"
m_nextafter
"
,
function
(
)
return
m_nextafter
(
scanpair
(
)
)
end
)
68
local
m_pow
=
m
.
pow
registerscript
(
"
m_pow
"
,
function
(
)
return
m_pow
(
scanpair
(
)
)
end
)
69
local
m_rad
=
m
.
rad
registerscript
(
"
m_rad
"
,
function
(
)
return
m_rad
(
scannumeric
(
)
)
end
)
70
local
m_remainder
=
m
.
remainder
registerscript
(
"
m_remainder
"
,
function
(
)
return
m_remainder
(
scanpair
(
)
)
end
)
71
local
m_remquo
=
m
.
remquo
registerscript
(
"
m_remquo
"
,
function
(
)
return
m_remquo
(
scannumeric
(
)
)
end
)
72
local
m_round
=
m
.
round
registerscript
(
"
m_round
"
,
function
(
)
return
m_round
(
scannumeric
(
)
)
end
)
73
local
m_scalbn
=
m
.
scalbn
registerscript
(
"
m_scalbn
"
,
function
(
)
return
m_scalbn
(
scanpair
(
)
)
end
)
74
local
m_sin
=
m
.
sin
registerscript
(
"
m_sin
"
,
function
(
)
return
m_sin
(
scannumeric
(
)
)
end
)
75
local
m_sinh
=
m
.
sinh
registerscript
(
"
m_sinh
"
,
function
(
)
return
m_sinh
(
scannumeric
(
)
)
end
)
76
local
m_sqrt
=
m
.
sqrt
registerscript
(
"
m_sqrt
"
,
function
(
)
return
m_sqrt
(
scannumeric
(
)
)
end
)
77
local
m_tan
=
m
.
tan
registerscript
(
"
m_tan
"
,
function
(
)
return
m_tan
(
scannumeric
(
)
)
end
)
78
local
m_tanh
=
m
.
tanh
registerscript
(
"
m_tanh
"
,
function
(
)
return
m_tanh
(
scannumeric
(
)
)
end
)
79
local
m_tgamma
=
m
.
tgamma
registerscript
(
"
m_tgamma
"
,
function
(
)
return
m_tgamma
(
scannumeric
(
)
)
end
)
80
local
m_trunc
=
m
.
trunc
registerscript
(
"
m_trunc
"
,
function
(
)
return
m_trunc
(
scannumeric
(
)
)
end
)
81
local
m_y0
=
m
.
y0
registerscript
(
"
m_y0
"
,
function
(
)
return
m_y0
(
scannumeric
(
)
)
end
)
82
local
m_y1
=
m
.
y1
registerscript
(
"
m_y1
"
,
function
(
)
return
m_y1
(
scannumeric
(
)
)
end
)
83
local
m_yn
=
m
.
yn
registerscript
(
"
m_yn
"
,
function
(
)
return
m_yn
(
scanpair
(
)
)
end
)
84 85
if
not
(
c
and
c
.
sin
)
then
86
return
87
end
88 89
local
c_topair
=
c
.
topair
90
local
c_new
=
c
.
new
91 92
local
c_sin
=
c
.
sin
registerscript
(
"
c_sin
"
,
function
(
)
return
mppair
(
c_topair
(
c_sin
(
c_new
(
scanpair
(
)
)
)
)
)
end
)
93
local
c_cos
=
c
.
cos
registerscript
(
"
c_cos
"
,
function
(
)
return
mppair
(
c_topair
(
c_cos
(
c_new
(
scanpair
(
)
)
)
)
)
end
)
94
local
c_tan
=
c
.
tan
registerscript
(
"
c_tan
"
,
function
(
)
return
mppair
(
c_topair
(
c_tan
(
c_new
(
scanpair
(
)
)
)
)
)
end
)
95
local
c_sinh
=
c
.
sinh
registerscript
(
"
c_sinh
"
,
function
(
)
return
mppair
(
c_topair
(
c_sinh
(
c_new
(
scanpair
(
)
)
)
)
)
end
)
96
local
c_cosh
=
c
.
cosh
registerscript
(
"
c_cosh
"
,
function
(
)
return
mppair
(
c_topair
(
c_cosh
(
c_new
(
scanpair
(
)
)
)
)
)
end
)
97
local
c_tanh
=
c
.
tanh
registerscript
(
"
c_tanh
"
,
function
(
)
return
mppair
(
c_topair
(
c_tanh
(
c_new
(
scanpair
(
)
)
)
)
)
end
)
98 99
local
c_asin
=
c
.
asin
registerscript
(
"
c_asin
"
,
function
(
)
return
mppair
(
c_topair
(
c_sin
(
c_new
(
scanpair
(
)
)
)
)
)
end
)
100
local
c_acos
=
c
.
acos
registerscript
(
"
c_acos
"
,
function
(
)
return
mppair
(
c_topair
(
c_cos
(
c_new
(
scanpair
(
)
)
)
)
)
end
)
101
local
c_atan
=
c
.
atan
registerscript
(
"
c_atan
"
,
function
(
)
return
mppair
(
c_topair
(
c_tan
(
c_new
(
scanpair
(
)
)
)
)
)
end
)
102
local
c_asinh
=
c
.
asinh
registerscript
(
"
c_asinh
"
,
function
(
)
return
mppair
(
c_topair
(
c_sinh
(
c_new
(
scanpair
(
)
)
)
)
)
end
)
103
local
c_acosh
=
c
.
acosh
registerscript
(
"
c_acosh
"
,
function
(
)
return
mppair
(
c_topair
(
c_cosh
(
c_new
(
scanpair
(
)
)
)
)
)
end
)
104
local
c_atanh
=
c
.
atanh
registerscript
(
"
c_atanh
"
,
function
(
)
return
mppair
(
c_topair
(
c_tanh
(
c_new
(
scanpair
(
)
)
)
)
)
end
)
105 106
local
c_sqrt
=
c
.
sqrt
registerscript
(
"
c_sqrt
"
,
function
(
)
return
mppair
(
c_topair
(
c_sqrt
(
c_new
(
scanpair
(
)
)
)
)
)
end
)
107
local
c_abs
=
c
.
abs
registerscript
(
"
c_abs
"
,
function
(
)
return
c_topair
(
c_abs
(
c_new
(
scanpair
(
)
)
)
)
end
)
108
local
c_arg
=
c
.
arg
registerscript
(
"
c_arg
"
,
function
(
)
return
c_topair
(
c_arg
(
c_new
(
scanpair
(
)
)
)
)
end
)
109
local
c_conj
=
c
.
conj
registerscript
(
"
c_conj
"
,
function
(
)
return
mppair
(
c_topair
(
c_conj
(
c_new
(
scanpair
(
)
)
)
)
)
end
)
110
local
c_exp
=
c
.
exp
registerscript
(
"
c_exp
"
,
function
(
)
return
mppair
(
c_topair
(
c_exp
(
c_new
(
scanpair
(
)
)
)
)
)
end
)
111
local
c_log
=
c
.
log
registerscript
(
"
c_log
"
,
function
(
)
return
mppair
(
c_topair
(
c_log
(
c_new
(
scanpair
(
)
)
)
)
)
end
)
112
local
c_proj
=
c
.
proj
registerscript
(
"
c_proj
"
,
function
(
)
return
mppair
(
c_topair
(
c_proj
(
c_new
(
scanpair
(
)
)
)
)
)
end
)
113 114
local
c_erf
=
c
.
erf
registerscript
(
"
c_erf
"
,
function
(
)
return
mppair
(
c_topair
(
c_erf
(
c_new
(
scanpair
(
)
)
)
)
)
end
)
115
local
c_erfc
=
c
.
erfc
registerscript
(
"
c_erfc
"
,
function
(
)
return
mppair
(
c_topair
(
c_erfc
(
c_new
(
scanpair
(
)
)
)
)
)
end
)
116
local
c_erfcx
=
c
.
erfcx
registerscript
(
"
c_erfcx
"
,
function
(
)
return
mppair
(
c_topair
(
c_erfcx
(
c_new
(
scanpair
(
)
)
)
)
)
end
)
117
local
c_erfi
=
c
.
erfi
registerscript
(
"
c_erfi
"
,
function
(
)
return
mppair
(
c_topair
(
c_erfi
(
c_new
(
scanpair
(
)
)
)
)
)
end
)
118
local
c_dawson
=
c
.
dawson
registerscript
(
"
c_dawson
"
,
function
(
)
return
mppair
(
c_topair
(
c_dawson
(
c_new
(
scanpair
(
)
)
)
)
)
end
)
119 120
local
c_voigt
=
c
.
voigt
121
local
c_voigt_hwhm
=
c
.
voigt_hwhm
122 123
registerscript
(
"
c_voigt
"
,
function
(
)
124
return
mppair
(
c_topair
(
c_voigt
(
c_new
(
scanpair
(
)
)
,
c_new
(
scanpair
(
)
)
,
c_new
(
scanpair
(
)
)
)
)
)
125
end
)
126 127
registerscript
(
"
c_voigt_hwhm
"
,
function
(
)
128
return
mppair
(
c_topair
(
c_voigt_hwhm
(
c_new
(
scanpair
(
)
)
,
c_new
(
scanpair
(
)
)
)
)
)
129
end
)
130 131
local
c_pow
=
c
.
pow
registerscript
(
"
c_pow
"
,
function
(
)
return
mppair
(
c_topair
(
c_pow
(
c_new
(
scanpair
(
)
)
,
c_new
(
scanpair
(
)
)
)
)
)
end
)
132
local
c_add
=
c
.
add
registerscript
(
"
c_add
"
,
function
(
)
return
mppair
(
c_topair
(
c_add
(
c_new
(
scanpair
(
)
)
,
c_new
(
scanpair
(
)
)
)
)
)
end
)
133
local
c_sub
=
c
.
sub
registerscript
(
"
c_sub
"
,
function
(
)
return
mppair
(
c_topair
(
c_sub
(
c_new
(
scanpair
(
)
)
,
c_new
(
scanpair
(
)
)
)
)
)
end
)
134
local
c_mul
=
c
.
mul
registerscript
(
"
c_mul
"
,
function
(
)
return
mppair
(
c_topair
(
c_mul
(
c_new
(
scanpair
(
)
)
,
c_new
(
scanpair
(
)
)
)
)
)
end
)
135
local
c_div
=
c
.
div
registerscript
(
"
c_div
"
,
function
(
)
return
mppair
(
c_topair
(
c_div
(
c_new
(
scanpair
(
)
)
,
c_new
(
scanpair
(
)
)
)
)
)
end
)
136 137
local
c_imag
=
c
.
imag
registerscript
(
"
c_imag
"
,
function
(
)
return
c_topair
(
c_imag
(
c_new
(
scanpair
(
)
)
)
)
end
)
138
local
c_real
=
c
.
real
registerscript
(
"
c_real
"
,
function
(
)
return
c_topair
(
c_real
(
c_new
(
scanpair
(
)
)
)
)
end
)
139
local
c_neg
=
c
.
neg
registerscript
(
"
c_new
"
,
function
(
)
return
c_topair
(
c_neg
(
c_new
(
scanpair
(
)
)
)
)
end
)
140