DOKK / manpages / debian 12 / pdl / PDL::Math.3pm.en
Math(3pm) User Contributed Perl Documentation Math(3pm)

PDL::Math - extended mathematical operations and special functions

 use PDL::Math;
 use PDL::Graphics::TriD;
 imag3d [SURF2D,bessj0(rvals(zeroes(50,50))/2)];

This module extends PDL with more advanced mathematical functions than provided by standard Perl.

All the functions have one input pdl, and one output, unless otherwise stated.

Many of the functions are linked from the system maths library or the Cephes maths library (determined when PDL is compiled); a few are implemented entirely in PDL.

  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.

  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.

  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.

  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.

  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.

  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.

  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.

  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.

  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.

  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 are rounded to the nearest even number. This avoids a slight statistical bias inherent in always rounding half-integers up or away from zero.

If you are 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.

  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.

  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.

  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.

  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.

  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.

  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.

  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.

  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.

  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.

  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.

  Signature: (a(); int n(); [o]b())

The regular Bessel function of the first kind, J_n . This takes a second int argument which gives the order of the function required.
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.

  Signature: (a(); int n(); [o]b())

The regular Bessel function of the first kind, Y_n . This takes a second int argument which gives the order of the function required.
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.

  Signature: (a(); [o]b(); int[o]s())

log gamma function

This returns 2 ndarrays -- the first set gives the log(gamma) values, while the second set, of integer values, gives the sign of the gamma function. This is useful for determining factorials, amongst 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.

  Signature: (a(); int [o]mask())

Sets $mask true if $a is not a "NaN" or "inf" (either positive or negative). Works inplace.

Bad values are treated as "NaN" or "inf".

  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.

  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.

  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);

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.

Hasn't been tested on all platforms to ensure Cephes versions are picked up automatically and used correctly.

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.

2023-04-27 perl v5.36.0