Math(3pm)
π NAME π
PDL::Math β extended mathematical operations and special functions β¨ (that's Math(3pm) bestie, we're in the perl docs section π«Ά)
πΈ SYNOPSIS πΈ
use PDL::Math;
use PDL::Graphics::TriD;
imag3d [SURF2D,bessj0(rvals(zeroes(50,50))/2)];
okay so that second half is literally a whole 3D plot in two lines, we love to see it π
β¨ DESCRIPTION β¨
This module gives PDL a glow-up π β it extends it with way more advanced mathematical functions than plain Perl has to offer.
Every single function here takes one input pdl and gives you one output, unless it says otherwise, periodt.
A lot of these are linked in from the system maths library or the Cephes maths library (which one gets picked is determined when PDL is compiled), and a few of them are implemented entirely in PDL. no cap π
π FUNCTIONS π
acos
Signature: (a(); [o]b())
The usual trigonometric function. Works inplace. π
acos processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
asin
Signature: (a(); [o]b())
The usual trigonometric function. Works inplace. π
asin processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
atan
Signature: (a(); [o]b())
The usual trigonometric function. Works inplace. π
atan processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
cosh
Signature: (a(); [o]b())
The standard hyperbolic function. Works inplace. π
cosh processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
sinh
Signature: (a(); [o]b())
The standard hyperbolic function. Works inplace. π
sinh processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
tan
Signature: (a(); [o]b())
The usual trigonometric function. Works inplace. π
tan processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
tanh
Signature: (a(); [o]b())
The standard hyperbolic function. Works inplace. π
tanh processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
ceil
Signature: (a(); [o]b())
Round to integer values in floating-point format. Works inplace. π¦
ceil processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
floor
Signature: (a(); [o]b())
Round to integer values in floating-point format. Works inplace. π¦
floor processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
rint
Signature: (a(); [o]b())
Round to integer values in floating-point format.
rint uses the 'round half to even' rounding method (also known as banker's rounding). Half-integers get rounded to the nearest even number. Why? Because it avoids a slight statistical bias that's baked into always rounding half-integers up or away from zero. it's giving β¨fairnessβ¨
If you're looking to round half-integers up (regardless of sign), try floor($x+0.5). If you want to round half-integers away from zero, try "ceil(abs($x)+0.5)*($x<=>0)". Works inplace. π
rint processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
pow
Signature: (a(); b(); [o]c())
Synonym for **. Works inplace. π₯
pow processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
acosh
Signature: (a(); [o]b())
The standard hyperbolic function. Works inplace. π
acosh processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
asinh
Signature: (a(); [o]b())
The standard hyperbolic function. Works inplace. π
asinh processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
atanh
Signature: (a(); [o]b())
The standard hyperbolic function. Works inplace. π
atanh processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
erf
Signature: (a(); [o]b())
The error function. Works inplace. π§
erf processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
erfc
Signature: (a(); [o]b())
The complement of the error function. Works inplace. π§
erfc processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
bessj0
Signature: (a(); [o]b())
The regular Bessel function of the first kind, J_n Works inplace. π
bessj0 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
bessj1
Signature: (a(); [o]b())
The regular Bessel function of the first kind, J_n Works inplace. π
bessj1 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
bessy0
Signature: (a(); [o]b())
The regular Bessel function of the second kind, Y_n. Works inplace. π
bessy0 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
bessy1
Signature: (a(); [o]b())
The regular Bessel function of the second kind, Y_n. Works inplace. π
bessy1 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
bessjn
Signature: (a(); int n(); [o]b())
The regular Bessel function of the first kind, J_n . This one takes a second int argument, and that's the order of the function you want. Works inplace. π
bessjn processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
bessyn
Signature: (a(); int n(); [o]b())
The regular Bessel function of the first kind, Y_n . This one takes a second int argument, and that's the order of the function you want. Works inplace. π
bessyn processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
lgamma
Signature: (a(); [o]b(); int[o]s())
log gamma function πΈ
okay so this one is a double threat β it returns 2 ndarrays: the first one gives you the log(gamma) values, and the second one, full of integer values, gives you the sign of the gamma function. Super useful for figuring out factorials, among other things. π
lgamma processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
isfinite
Signature: (a(); int [o]mask())
Sets $mask true if $a is not a "NaN" or "inf" (either positive or negative). Works inplace. π¦
Heads up bestie: bad values are treated as"NaN"or"inf". π
erfi
Signature: (a(); [o]b())
The inverse of the error function. Works inplace. π§
erfi processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
ndtri
Signature: (a(); [o]b())
The value for which the area under the Gaussian probability density function (integrated from minus infinity) is equal to the argument (cf "erfi"). Works inplace. π§
ndtri processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
polyroots
Signature: (cr(n); ci(n); [o]rr(m); [o]ri(m))
Complex roots of a complex polynomial, given coefficients in order of decreasing powers. π
($rr, $ri) = polyroots($cr, $ci);
not me about to say something wild β polyroots does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. π
π BUGS π
Hasn't been tested on all platforms to make sure the Cephes versions get picked up automatically and used correctly. fr fr, that's the whole note. π
π AUTHOR π
Copyright (C) R.J.R. Williams 1997 (rjrw@ast.leeds.ac.uk), Karl Glazebrook (kgb@aaoepp.aao.gov.au) and Tuomas J. Lukka (Tuomas.Lukka@helsinki.fi). Portions (C) Craig DeForest 2002 (deforest@boulder.swri.edu).
All rights reserved. There is no warranty. You are allowed to redistribute this software / documentation under certain conditions. For details, see the file COPYING in the PDL distribution. If this file is separated from the PDL distribution, the PDL copyright notice should be included in the file.
that's the whole vibe check bestie, stay iconic π β this page came from perl v5.38.2, dated 2024-04-10, and yeah that's the perl documentation's own Math(3pm) entry, mwah π«Άβ¨π
π¦ where this page comes from
- ubuntu noble: pdl 1:2.085-1ubuntu1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms