PDL::Ops - Fundamental mathematical operators
This module provides the functions used by PDL to overload the basic mathematical operators (+ - / * etc.) and functions (sin sqrt etc.)
+ - / *
sin sqrt
It also includes the function log10, which should be a perl function so that we can overload it!
log10
Matrix multiplication (the operator x) is handled by the module PDL::Primitive.
x
none
Signature: (a(); b(); [o]c(); int swap)
add two piddles
$c = plus $a, $b, 0; # explicit call with trailing 0 $c = $a + $b; # overloaded call $a->inplace->plus($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the binary + operator. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases.
$a->inplace
+
plus processes bad values. The state of the bad-value flag of the output piddles is unknown.
multiply two piddles
$c = mult $a, $b, 0; # explicit call with trailing 0 $c = $a * $b; # overloaded call $a->inplace->mult($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the binary * operator. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases.
*
mult processes bad values. The state of the bad-value flag of the output piddles is unknown.
subtract two piddles
$c = minus $a, $b, 0; # explicit call with trailing 0 $c = $a - $b; # overloaded call $a->inplace->minus($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the binary - operator. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases.
-
minus processes bad values. The state of the bad-value flag of the output piddles is unknown.
divide two piddles
$c = divide $a, $b, 0; # explicit call with trailing 0 $c = $a / $b; # overloaded call $a->inplace->divide($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the binary / operator. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases.
/
divide processes bad values. The state of the bad-value flag of the output piddles is unknown.
the binary > (greater than) operation
$c = gt $a, $b, 0; # explicit call with trailing 0 $c = $a > $b; # overloaded call $a->inplace->gt($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the binary > operator. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases.
>
gt processes bad values. The state of the bad-value flag of the output piddles is unknown.
the binary < (less than) operation
$c = lt $a, $b, 0; # explicit call with trailing 0 $c = $a < $b; # overloaded call $a->inplace->lt($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the binary < operator. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases.
<
lt processes bad values. The state of the bad-value flag of the output piddles is unknown.
the binary <= (less equal) operation
$c = le $a, $b, 0; # explicit call with trailing 0 $c = $a <= $b; # overloaded call $a->inplace->le($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the binary <= operator. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases.
<=
le processes bad values. The state of the bad-value flag of the output piddles is unknown.
the binary >= (greater equal) operation
$c = ge $a, $b, 0; # explicit call with trailing 0 $c = $a >= $b; # overloaded call $a->inplace->ge($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the binary >= operator. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases.
>=
ge processes bad values. The state of the bad-value flag of the output piddles is unknown.
binary equal to operation (==)
==
$c = eq $a, $b, 0; # explicit call with trailing 0 $c = $a == $b; # overloaded call $a->inplace->eq($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the binary == operator. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases.
eq processes bad values. The state of the bad-value flag of the output piddles is unknown.
binary not equal to operation (!=)
!=
$c = ne $a, $b, 0; # explicit call with trailing 0 $c = $a != $b; # overloaded call $a->inplace->ne($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the binary != operator. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases.
ne processes bad values. The state of the bad-value flag of the output piddles is unknown.
leftshift $a by $b
$a
$b
$c = shiftleft $a, $b, 0; # explicit call with trailing 0 $c = $a << $b; # overloaded call $a->inplace->shiftleft($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the binary << operator. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases.
<<
shiftleft processes bad values. The state of the bad-value flag of the output piddles is unknown.
rightshift $a by $b
$c = shiftright $a, $b, 0; # explicit call with trailing 0 $c = $a >> $b; # overloaded call $a->inplace->shiftright($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the binary >> operator. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases.
>>
shiftright processes bad values. The state of the bad-value flag of the output piddles is unknown.
binary or of two piddles
$c = or2 $a, $b, 0; # explicit call with trailing 0 $c = $a | $b; # overloaded call $a->inplace->or2($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the binary | operator. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases.
|
or2 processes bad values. The state of the bad-value flag of the output piddles is unknown.
binary and of two piddles
$c = and2 $a, $b, 0; # explicit call with trailing 0 $c = $a & $b; # overloaded call $a->inplace->and2($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the binary & operator. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases.
&
and2 processes bad values. The state of the bad-value flag of the output piddles is unknown.
binary exclusive or of two piddles
$c = xor $a, $b, 0; # explicit call with trailing 0 $c = $a ^ $b; # overloaded call $a->inplace->xor($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the binary ^ operator. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases.
^
xor processes bad values. The state of the bad-value flag of the output piddles is unknown.
Signature: (a(); [o]b())
unary bit negation
$b = ~ $a; $a->inplace->bitnot; # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the unary ~ operator/function.
~
bitnot processes bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
raise piddle $a to the power $b
$c = $a->power($b,0); # explicit function call $c = $a ** $b; # overloaded use $a->inplace->power($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the binary ** function. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases.
**
power processes bad values. The state of the bad-value flag of the output piddles is unknown.
elementwise atan2 of two piddles
atan2
$c = $a->atan2($b,0); # explicit function call $c = atan2 $a, $b; # overloaded use $a->inplace->atan2($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the binary atan2 function. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases.
atan2 processes bad values. The state of the bad-value flag of the output piddles is unknown.
elementwise modulo operation
modulo
$c = $a->modulo($b,0); # explicit function call $c = $a % $b; # overloaded use $a->inplace->modulo($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the binary % function. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases.
%
modulo processes bad values. The state of the bad-value flag of the output piddles is unknown.
elementwise "<=>" operation
$c = $a->spaceship($b,0); # explicit function call $c = $a <=> $b; # overloaded use $a->inplace->spaceship($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the binary <=> function. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases.
<=>
spaceship processes bad values. The state of the bad-value flag of the output piddles is unknown.
elementwise square root
$b = sqrt $a; $a->inplace->sqrt; # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the unary sqrt operator/function.
sqrt
sqrt processes bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
elementwise absolute value
$b = abs $a; $a->inplace->abs; # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the unary abs operator/function.
abs
abs processes bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
the sin function
$b = sin $a; $a->inplace->sin; # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the unary sin operator/function.
sin
sin processes bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
the cos function
$b = cos $a; $a->inplace->cos; # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the unary cos operator/function.
cos
cos processes bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
the elementwise not operation
$b = ! $a; $a->inplace->not; # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the unary ! operator/function.
!
not processes bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
the exponential function
$b = exp $a; $a->inplace->exp; # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the unary exp operator/function.
exp
exp processes bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
the natural logarithm
$b = log $a; $a->inplace->log; # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the unary log operator/function.
log
log processes bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
the base 10 logarithm
$b = log10 $a; $a->inplace->log10; # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. This function is used to overload the unary log10 operator/function.
log10 processes bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Plain numerical assignment. This is used to implement the ".=" operator
assgn 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: (a(); b(); [o] ans())
raise piddle $a to integer power $b
$c = $a->ipow($b,0); # explicit function call $c = ipow $a, $b; $a->inplace->ipow($b,0); # modify $a inplace
It can be made to work inplace with the $a->inplace syntax. Note that when calling this function explicitly you need to supply a third argument that should generally be zero (see first example). This restriction is expected to go away in future releases.
Algorithm from Wikipedia
ipow 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.
Tuomas J. Lukka (lukka@fas.harvard.edu), Karl Glazebrook (kgb@aaoepp.aao.gov.au), Doug Hunt (dhunt@ucar.edu), Christian Soeller (c.soeller@auckland.ac.nz), Doug Burke (burke@ifa.hawaii.edu), and Craig DeForest (deforest@boulder.swri.edu).
To install PDL, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PDL
CPAN shell
perl -MCPAN -e shell install PDL
For more information on module installation, please visit the detailed CPAN module installation guide.