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.
The functions are usually available from the system maths library, however if they are not (determined when PDL is compiled) a version from the Cephes math library is used.
Signature: (a(); [o]b())
The usual trigonometric function. Works inplace.
acos does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(); [o]b())
The usual trigonometric function. Works inplace.
asin does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(); [o]b())
The usual trigonometric function. Works inplace.
atan does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(); [o]b())
The standard hyperbolic function. Works inplace.
cosh does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(); [o]b())
The standard hyperbolic function. Works inplace.
sinh does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(); [o]b())
The usual trigonometric function. Works inplace.
tan does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(); [o]b())
The standard hyperbolic function. Works inplace.
tanh does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(); [o]b())
Round to integral values in floating-point format. Works inplace.
ceil does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(); [o]b())
Round to integral values in floating-point format. Works inplace.
floor does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(); [o]b())
Round to integral values in floating-point format. Works inplace.
rint does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(); b(); [o]c())
Synonym for `**'. Works inplace.
pow does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(); [o]b())
The standard hyperbolic function. Works inplace.
acosh does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(); [o]b())
The standard hyperbolic function. Works inplace.
asinh does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(); [o]b())
The standard hyperbolic function. Works inplace.
atanh does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(); [o]b())
The error function. Works inplace.
erf does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(); [o]b())
The complement of the error function. Works inplace.
erfc does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(); [o]b())
The standard Bessel function. Works inplace.
bessj0 does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(); [o]b())
The standard Bessel function. Works inplace.
bessj1 does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(); [o]b())
The standard Bessel function. Works inplace.
bessy0 does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(); [o]b())
The standard Bessel function. Works inplace.
bessy1 does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(); int n(); [o]b())
The standard Bessel function. This has a second integer argument which gives the order of the function required. Works inplace.
bessjn does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(); int n(); [o]b())
The standard Bessel function. This has a second integer argument which gives the order of the function required. Works inplace.
bessyn does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(); b(); [o]c())
Clears all infs
and nans
in $a
to the corresponding value in $b
.
badmask can be run with $a
inplace:
badmask($a->inplace,0); $a->inplace->badmask(0);
If bad values are present, these are also cleared.
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 does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
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 does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(n,m); [o]u(n,m); [o,phys]z(n); [o]v(n,n))
Singular value decomposition of array.
($u, $s, $v) = svd($a);
svd ignores the bad-value flag of the input piddles. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
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 piddles if the flag is set for any of the input piddles.
Signature: ([phys]a(m); [o,phys]ev(n,n); [o,phys]e(n))
Eigenvalues and -vectors of a symmetric square matrix. If passed an asymmetric matrix, the routine will warn and symmetrize it.
($e, $ev) = eigens($a);
eigens ignores the bad-value flag of the input piddles. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: ([phys]a(n,n); [phys]b(n); [o,phys]x(n); int [o,phys]ips(n); int flag)
Solution of simultaneous linear equations, a x = b
.
$a
is an n x n
matrix (i.e., a vector of length n*n
), stored row-wise:
that is, a(i,j) = a[ij]
, where ij = i*n + j
.
While this is the
transpose of the normal column-wise storage, this corresponds to
normal PDL usage. The contents of matrix a may be altered (but may be
required for subsequent calls with flag = -1).
$b
, $x
, $ips
are vectors of length n
.
Set flag=0
to solve.
Set flag=-1
to do a new back substitution for
different $b
vector using the same a matrix previously reduced when
flag=0
(the $ips
vector generated in the previous solution is also
required).
simq ignores the bad-value flag of the input piddles. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(n,n); b(m))
Convert a symmetric square matrix to triangular vector storage
squaretotri does not process bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
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)
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 copyright notice should be included in the file.