table of contents
Ops(3pm) | User Contributed Perl Documentation | Ops(3pm) |
NAME¶
PDL::Ops - Fundamental mathematical operators
DESCRIPTION¶
This module provides the functions used by PDL to overload the basic mathematical operators ("+ - / *" etc.) and functions ("sin sqrt" etc.)
It also includes the function "log10", which should be a perl function so that we can overload it!
Matrix multiplication (the operator "x") is handled by the module PDL::Primitive.
SYNOPSIS¶
none
FUNCTIONS¶
plus¶
Signature: (a(); b(); [o]c(); int $swap)
add two ndarrays
$c = $x + $y; # overloaded call $c = plus $x, $y; # explicit call with default swap of 0 $c = plus $x, $y, 1; # explicit call with trailing 1 to swap args $x->inplace->plus($y); # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the binary "+" operator. As of 2.065, when calling this function explicitly you can omit the third argument (see second example), or supply it (see third one).
plus 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.
mult¶
Signature: (a(); b(); [o]c(); int $swap)
multiply two ndarrays
$c = $x * $y; # overloaded call $c = mult $x, $y; # explicit call with default swap of 0 $c = mult $x, $y, 1; # explicit call with trailing 1 to swap args $x->inplace->mult($y); # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the binary "*" operator. As of 2.065, when calling this function explicitly you can omit the third argument (see second example), or supply it (see third one).
mult 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.
minus¶
Signature: (a(); b(); [o]c(); int $swap)
subtract two ndarrays
$c = $x - $y; # overloaded call $c = minus $x, $y; # explicit call with default swap of 0 $c = minus $x, $y, 1; # explicit call with trailing 1 to swap args $x->inplace->minus($y); # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the binary "-" operator. As of 2.065, when calling this function explicitly you can omit the third argument (see second example), or supply it (see third one).
minus 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.
divide¶
Signature: (a(); b(); [o]c(); int $swap)
divide two ndarrays
$c = $x / $y; # overloaded call $c = divide $x, $y; # explicit call with default swap of 0 $c = divide $x, $y, 1; # explicit call with trailing 1 to swap args $x->inplace->divide($y); # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the binary "/" operator. As of 2.065, when calling this function explicitly you can omit the third argument (see second example), or supply it (see third one).
divide 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.
gt¶
Signature: (a(); b(); [o]c(); int $swap)
the binary > (greater than) operation
$c = $x > $y; # overloaded call $c = gt $x, $y; # explicit call with default swap of 0 $c = gt $x, $y, 1; # explicit call with trailing 1 to swap args $x->inplace->gt($y); # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the binary ">" operator. As of 2.065, when calling this function explicitly you can omit the third argument (see second example), or supply it (see third one).
gt 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.
lt¶
Signature: (a(); b(); [o]c(); int $swap)
the binary < (less than) operation
$c = $x < $y; # overloaded call $c = lt $x, $y; # explicit call with default swap of 0 $c = lt $x, $y, 1; # explicit call with trailing 1 to swap args $x->inplace->lt($y); # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the binary "<" operator. As of 2.065, when calling this function explicitly you can omit the third argument (see second example), or supply it (see third one).
lt 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.
le¶
Signature: (a(); b(); [o]c(); int $swap)
the binary <= (less equal) operation
$c = $x <= $y; # overloaded call $c = le $x, $y; # explicit call with default swap of 0 $c = le $x, $y, 1; # explicit call with trailing 1 to swap args $x->inplace->le($y); # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the binary "<=" operator. As of 2.065, when calling this function explicitly you can omit the third argument (see second example), or supply it (see third one).
le 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.
ge¶
Signature: (a(); b(); [o]c(); int $swap)
the binary >= (greater equal) operation
$c = $x >= $y; # overloaded call $c = ge $x, $y; # explicit call with default swap of 0 $c = ge $x, $y, 1; # explicit call with trailing 1 to swap args $x->inplace->ge($y); # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the binary ">=" operator. As of 2.065, when calling this function explicitly you can omit the third argument (see second example), or supply it (see third one).
ge 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.
eq¶
Signature: (a(); b(); [o]c(); int $swap)
binary equal to operation ("==")
$c = $x == $y; # overloaded call $c = eq $x, $y; # explicit call with default swap of 0 $c = eq $x, $y, 1; # explicit call with trailing 1 to swap args $x->inplace->eq($y); # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the binary "==" operator. As of 2.065, when calling this function explicitly you can omit the third argument (see second example), or supply it (see third one).
eq 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.
ne¶
Signature: (a(); b(); [o]c(); int $swap)
binary not equal to operation ("!=")
$c = $x != $y; # overloaded call $c = ne $x, $y; # explicit call with default swap of 0 $c = ne $x, $y, 1; # explicit call with trailing 1 to swap args $x->inplace->ne($y); # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the binary "!=" operator. As of 2.065, when calling this function explicitly you can omit the third argument (see second example), or supply it (see third one).
ne 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.
shiftleft¶
Signature: (a(); b(); [o]c(); int $swap)
leftshift $a by $b
$c = $x << $y; # overloaded call $c = shiftleft $x, $y; # explicit call with default swap of 0 $c = shiftleft $x, $y, 1; # explicit call with trailing 1 to swap args $x->inplace->shiftleft($y); # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the binary "<<" operator. As of 2.065, when calling this function explicitly you can omit the third argument (see second example), or supply it (see third one).
shiftleft 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.
shiftright¶
Signature: (a(); b(); [o]c(); int $swap)
rightshift $a by $b
$c = $x >> $y; # overloaded call $c = shiftright $x, $y; # explicit call with default swap of 0 $c = shiftright $x, $y, 1; # explicit call with trailing 1 to swap args $x->inplace->shiftright($y); # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the binary ">>" operator. As of 2.065, when calling this function explicitly you can omit the third argument (see second example), or supply it (see third one).
shiftright 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.
or2¶
Signature: (a(); b(); [o]c(); int $swap; SV *$ign; int $ign2)
binary or of two ndarrays
$c = $x | $y; # overloaded call $c = or2 $x, $y; # explicit call with default swap of 0 $c = or2 $x, $y, 1; # explicit call with trailing 1 to swap args $x->inplace->or2($y); # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the binary "|" operator. As of 2.065, when calling this function explicitly you can omit the third argument (see second example), or supply it (see third one).
or2 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.
and2¶
Signature: (a(); b(); [o]c(); int $swap; SV *$ign; int $ign2)
binary and of two ndarrays
$c = $x & $y; # overloaded call $c = and2 $x, $y; # explicit call with default swap of 0 $c = and2 $x, $y, 1; # explicit call with trailing 1 to swap args $x->inplace->and2($y); # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the binary "&" operator. As of 2.065, when calling this function explicitly you can omit the third argument (see second example), or supply it (see third one).
and2 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.
xor¶
Signature: (a(); b(); [o]c(); int $swap; SV *$ign; int $ign2)
binary exclusive or of two ndarrays
$c = $x ^ $y; # overloaded call $c = xor $x, $y; # explicit call with default swap of 0 $c = xor $x, $y, 1; # explicit call with trailing 1 to swap args $x->inplace->xor($y); # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the binary "^" operator. As of 2.065, when calling this function explicitly you can omit the third argument (see second example), or supply it (see third one).
xor 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.
bitnot¶
Signature: (a(); [o]b())
unary bit negation
$y = ~ $x; $x->inplace->bitnot; # modify $x inplace
It can be made to work inplace with the "$x->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 ndarrays if the flag is set for any of the input ndarrays.
power¶
Signature: (a(); b(); [o]c(); int $swap)
raise ndarray $a to the power $b
$c = $x->power($y); # explicit call with default swap of 0 $c = $x->power($y, 1); # explicit call with trailing 1 to swap args $c = $a ** $b; # overloaded use $x->inplace->power($y,0); # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the binary "**" function. As of 2.065, when calling this function explicitly you can omit the third argument (see first example), or supply it (see second one).
power 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.
atan2¶
Signature: (a(); b(); [o]c(); int $swap)
elementwise "atan2" of two ndarrays
$c = $x->atan2($y); # explicit call with default swap of 0 $c = $x->atan2($y, 1); # explicit call with trailing 1 to swap args $c = atan2 $a, $b; # overloaded use $x->inplace->atan2($y,0); # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the binary "atan2" function. As of 2.065, when calling this function explicitly you can omit the third argument (see first example), or supply it (see second one).
atan2 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.
modulo¶
Signature: (a(); b(); [o]c(); int $swap)
elementwise "modulo" operation
$c = $x->modulo($y); # explicit call with default swap of 0 $c = $x->modulo($y, 1); # explicit call with trailing 1 to swap args $c = $a % $b; # overloaded use $x->inplace->modulo($y,0); # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the binary "%" function. As of 2.065, when calling this function explicitly you can omit the third argument (see first example), or supply it (see second one).
modulo 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.
spaceship¶
Signature: (a(); b(); [o]c(); int $swap)
elementwise "<=>" operation
$c = $x->spaceship($y); # explicit call with default swap of 0 $c = $x->spaceship($y, 1); # explicit call with trailing 1 to swap args $c = $a <=> $b; # overloaded use $x->inplace->spaceship($y,0); # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the binary "<=>" function. As of 2.065, when calling this function explicitly you can omit the third argument (see first example), or supply it (see second one).
spaceship 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.
sqrt¶
Signature: (a(); [o]b())
elementwise square root
$y = sqrt $x; $x->inplace->sqrt; # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the unary "sqrt" operator/function.
sqrt 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.
sin¶
Signature: (a(); [o]b())
the sin function
$y = sin $x; $x->inplace->sin; # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the unary "sin" operator/function.
sin 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.
cos¶
Signature: (a(); [o]b())
the cos function
$y = cos $x; $x->inplace->cos; # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the unary "cos" operator/function.
cos 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.
not¶
Signature: (a(); [o]b())
the elementwise not operation
$y = ! $x; $x->inplace->not; # modify $x inplace
It can be made to work inplace with the "$x->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 ndarrays if the flag is set for any of the input ndarrays.
exp¶
Signature: (a(); [o]b())
the exponential function
$y = exp $x; $x->inplace->exp; # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the unary "exp" operator/function.
exp 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.
log¶
Signature: (a(); [o]b())
the natural logarithm
$y = log $x; $x->inplace->log; # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax. This function is used to overload the unary "log" operator/function.
log 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.
re¶
Signature: (complexv(); real [o]b())
Returns the real part of a complex number. Flows data back & forth.
re 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.
im¶
Signature: (complexv(); real [o]b())
Returns the imaginary part of a complex number. Flows data back & forth.
im 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.
_cabs¶
Signature: (complexv(); real [o]b())
Returns the absolute (length) of a complex number.
_cabs 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.
log10¶
Signature: (a(); [o]b())
the base 10 logarithm
$y = log10 $x; $x->inplace->log10; # modify $x inplace
It can be made to work inplace with the "$x->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 ndarrays if the flag is set for any of the input ndarrays.
assgn¶
Signature: (a(); [o]b())
Plain numerical assignment. This is used to implement the ".=" operator
assgn 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.
carg¶
Signature: (complexv(); real [o]b())
Returns the polar angle of a complex number.
carg 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.
conj¶
Signature: (complexv(); [o]b())
complex conjugate.
conj 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.
czip¶
Signature: (r(); i(); complex [o]c())
convert real, imaginary to native complex, (sort of) like LISP zip function. Will add the "r" ndarray to "i" times the "i" ndarray. Only takes real ndarrays as input.
czip 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.
ipow¶
Signature: (a(); indx b(); [o] ans())
raise ndarray $a to integer power $b
$c = $x->ipow($y); # as method $c = ipow $x, $y; $x->inplace->ipow($y); # modify $x inplace
It can be made to work inplace with the "$x->inplace" syntax.
Algorithm from Wikipedia <http://en.wikipedia.org/wiki/Exponentiation_by_squaring>
ipow 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.
abs¶
Returns the absolute value of a number.
abs2¶
Returns the square of the absolute value of a number.
r2C¶
Signature: (r(); complex [o]c())
convert real to native complex, with an imaginary part of zero
r2C 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.
i2C¶
Signature: (i(); complex [o]c())
convert imaginary to native complex, with a real part of zero
i2C 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.
AUTHOR¶
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).
2023-06-17 | perl v5.36.0 |