1Math(3) User Contributed Perl Documentation Math(3)
2
3
4
6 PDL::Math - extended mathematical operations and special functions
7
9 use PDL::Math;
10
11 use PDL::Graphics::TriD;
12 imag3d [SURF2D,bessj0(rvals(zeroes(50,50))/2)];
13
15 This module extends PDL with more advanced mathematical functions than
16 provided by standard Perl.
17
18 All the functions have one input pdl, and one output, unless otherwise
19 stated.
20
21 Many of the functions are linked from the system maths library or the
22 Cephes maths library (determined when PDL is compiled); a few are
23 implemented entirely in PDL.
24
26 acos
27 Signature: (a(); [o]b())
28
29 The usual trigonometric function. Works inplace.
30
31 acos processes bad values. It will set the bad-value flag of all
32 output piddles if the flag is set for any of the input piddles.
33
34 asin
35 Signature: (a(); [o]b())
36
37 The usual trigonometric function. Works inplace.
38
39 asin processes bad values. It will set the bad-value flag of all
40 output piddles if the flag is set for any of the input piddles.
41
42 atan
43 Signature: (a(); [o]b())
44
45 The usual trigonometric function. Works inplace.
46
47 atan processes bad values. It will set the bad-value flag of all
48 output piddles if the flag is set for any of the input piddles.
49
50 cosh
51 Signature: (a(); [o]b())
52
53 The standard hyperbolic function. Works inplace.
54
55 cosh processes bad values. It will set the bad-value flag of all
56 output piddles if the flag is set for any of the input piddles.
57
58 sinh
59 Signature: (a(); [o]b())
60
61 The standard hyperbolic function. Works inplace.
62
63 sinh processes bad values. It will set the bad-value flag of all
64 output piddles if the flag is set for any of the input piddles.
65
66 tan
67 Signature: (a(); [o]b())
68
69 The usual trigonometric function. Works inplace.
70
71 tan processes bad values. It will set the bad-value flag of all output
72 piddles if the flag is set for any of the input piddles.
73
74 tanh
75 Signature: (a(); [o]b())
76
77 The standard hyperbolic function. Works inplace.
78
79 tanh processes bad values. It will set the bad-value flag of all
80 output piddles if the flag is set for any of the input piddles.
81
82 ceil
83 Signature: (a(); [o]b())
84
85 Round to integer values in floating-point format. Works inplace.
86
87 ceil processes bad values. It will set the bad-value flag of all
88 output piddles if the flag is set for any of the input piddles.
89
90 floor
91 Signature: (a(); [o]b())
92
93 Round to integer values in floating-point format. Works inplace.
94
95 floor processes bad values. It will set the bad-value flag of all
96 output piddles if the flag is set for any of the input piddles.
97
98 rint
99 Signature: (a(); [o]b())
100
101 Round to integer values in floating-point format.
102
103 rint uses the 'round half to even' rounding method (also known as
104 banker's rounding). Half-integers are rounded to the nearest even
105 number. This avoids a slight statistical bias inherent in always
106 rounding half-integers up or away from zero.
107
108 If you are looking to round half-integers up (regardless of sign), try
109 "floor($x+0.5)". If you want to round half-integers away from zero,
110 try "floor(abs($x)+0.5)*($x<=>0)". Works inplace.
111
112 rint processes bad values. It will set the bad-value flag of all
113 output piddles if the flag is set for any of the input piddles.
114
115 pow
116 Signature: (a(); b(); [o]c())
117
118 Synonym for `**'. Works inplace.
119
120 pow processes bad values. It will set the bad-value flag of all output
121 piddles if the flag is set for any of the input piddles.
122
123 acosh
124 Signature: (a(); [o]b())
125
126 The standard hyperbolic function. Works inplace.
127
128 acosh processes bad values. It will set the bad-value flag of all
129 output piddles if the flag is set for any of the input piddles.
130
131 asinh
132 Signature: (a(); [o]b())
133
134 The standard hyperbolic function. Works inplace.
135
136 asinh processes bad values. It will set the bad-value flag of all
137 output piddles if the flag is set for any of the input piddles.
138
139 atanh
140 Signature: (a(); [o]b())
141
142 The standard hyperbolic function. Works inplace.
143
144 atanh processes bad values. It will set the bad-value flag of all
145 output piddles if the flag is set for any of the input piddles.
146
147 erf
148 Signature: (a(); [o]b())
149
150 The error function. Works inplace.
151
152 erf processes bad values. It will set the bad-value flag of all output
153 piddles if the flag is set for any of the input piddles.
154
155 erfc
156 Signature: (a(); [o]b())
157
158 The complement of the error function. Works inplace.
159
160 erfc processes bad values. It will set the bad-value flag of all
161 output piddles if the flag is set for any of the input piddles.
162
163 bessj0
164 Signature: (a(); [o]b())
165
166 The regular Bessel function of the first kind, J_n Works inplace.
167
168 bessj0 processes bad values. It will set the bad-value flag of all
169 output piddles if the flag is set for any of the input piddles.
170
171 bessj1
172 Signature: (a(); [o]b())
173
174 The regular Bessel function of the first kind, J_n Works inplace.
175
176 bessj1 processes bad values. It will set the bad-value flag of all
177 output piddles if the flag is set for any of the input piddles.
178
179 bessy0
180 Signature: (a(); [o]b())
181
182 The regular Bessel function of the second kind, Y_n. Works inplace.
183
184 bessy0 processes bad values. It will set the bad-value flag of all
185 output piddles if the flag is set for any of the input piddles.
186
187 bessy1
188 Signature: (a(); [o]b())
189
190 The regular Bessel function of the second kind, Y_n. Works inplace.
191
192 bessy1 processes bad values. It will set the bad-value flag of all
193 output piddles if the flag is set for any of the input piddles.
194
195 bessjn
196 Signature: (a(); int n(); [o]b())
197
198 The regular Bessel function of the first kind, J_n . This takes a
199 second int argument which gives the order of the function required.
200 Works inplace.
201
202 bessjn processes bad values. It will set the bad-value flag of all
203 output piddles if the flag is set for any of the input piddles.
204
205 bessyn
206 Signature: (a(); int n(); [o]b())
207
208 The regular Bessel function of the first kind, Y_n . This takes a
209 second int argument which gives the order of the function required.
210 Works inplace.
211
212 bessyn processes bad values. It will set the bad-value flag of all
213 output piddles if the flag is set for any of the input piddles.
214
215 lgamma
216 Signature: (a(); [o]b(); int[o]s())
217
218 log gamma function
219
220 This returns 2 piddles -- the first set gives the log(gamma) values,
221 while the second set, of integer values, gives the sign of the gamma
222 function. This is useful for determining factorials, amongst other
223 things.
224
225 lgamma processes bad values. It will set the bad-value flag of all
226 output piddles if the flag is set for any of the input piddles.
227
228 badmask
229 Signature: (a(); b(); [o]c())
230
231 Clears all "infs" and "nans" in $a to the corresponding value in $b.
232
233 badmask can be run with $a inplace:
234
235 badmask($a->inplace,0);
236 $a->inplace->badmask(0);
237
238 If bad values are present, these are also cleared.
239
240 isfinite
241 Signature: (a(); int [o]mask())
242
243 Sets $mask true if $a is not a "NaN" or "inf" (either positive or
244 negative). Works inplace.
245
246 Bad values are treated as "NaN" or "inf".
247
248 erfi
249 Signature: (a(); [o]b())
250
251 The inverse of the error function. Works inplace.
252
253 erfi processes bad values. It will set the bad-value flag of all
254 output piddles if the flag is set for any of the input piddles.
255
256 ndtri
257 Signature: (a(); [o]b())
258
259 The value for which the area under the Gaussian probability density
260 function (integrated from minus infinity) is equal to the argument (cf
261 erfi). Works inplace.
262
263 ndtri processes bad values. It will set the bad-value flag of all
264 output piddles if the flag is set for any of the input piddles.
265
266 polyroots
267 Signature: (cr(n); ci(n); [o]rr(m); [o]ri(m))
268
269 Complex roots of a complex polynomial, given coefficients in order of
270 decreasing powers.
271
272 ($rr, $ri) = polyroots($cr, $ci);
273
274 polyroots does not process bad values. It will set the bad-value flag
275 of all output piddles if the flag is set for any of the input piddles.
276
278 Hasn't been tested on all platforms to ensure Cephes versions are
279 picked up automatically and used correctly.
280
282 Copyright (C) R.J.R. Williams 1997 (rjrw@ast.leeds.ac.uk), Karl
283 Glazebrook (kgb@aaoepp.aao.gov.au) and Tuomas J. Lukka
284 (Tuomas.Lukka@helsinki.fi). Portions (C) Craig DeForest 2002
285 (deforest@boulder.swri.edu).
286
287 All rights reserved. There is no warranty. You are allowed to
288 redistribute this software / documentation under certain conditions.
289 For details, see the file COPYING in the PDL distribution. If this file
290 is separated from the PDL distribution, the PDL copyright notice should
291 be included in the file.
292
293
294
295perl v5.30.0 2019-09-05 Math(3)