Ops(3pm)
π PDL::Ops π
okay so bestie, this is Ops(3pm) β the PDL module that's literally the math engine behind everything. π Come learn some operators with me, it's gonna be iconic.
πΈ NAME πΈ
PDL::Ops β Fundamental mathematical operators β¨
π« DESCRIPTION π«
This module is the one serving up all the functions PDL uses to overload the basic mathematical operators (+ - / * and the whole squad) plus the functions (sin sqrt etc.). It's giving β¨ backstage crew for your arithmetic β¨.
It also ships the function log10, which should be a perl function so that we can overload it! π (iykyk)
Matrix multiplication (the operator x) is handled by the module PDL::Primitive β different module, different vibe. π
π¦ SYNOPSIS π¦
none π like, nothing. it's that girl who shows up with no notes and still aces it.
π 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
You can make it work inplace with the $x->inplace syntax. This one is what overloads the binary + operator. As of 2.065, when you call this function explicitly you can just skip the third argument (see example two) or supply it (see example three). Both slay. π
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
You can make it work inplace with the $x->inplace syntax, bestie. This function is the one overloading the binary - operator. As of 2.065, when you call it explicitly you can drop the third argument (peep the second example) or hand it over (peep the 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 β yes bestie, it's giving negation but make it bitwise π
$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 β math but make it slay π₯
$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 β trig but make it two-ndarray energy β¨
$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 β the % vibe, but for ndarrays π
$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 β the spaceship operator, iconic, no notes π
$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 β math girlies rise π§
$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 β yes, that sin π
$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 β cos, the main character of trig π
$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 β not me forgetting the ! π
$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 β exp, she's exponential and she knows it π₯
$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 β log, but make it natural πΏ
$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. β real ones only, bestie π
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. β imaginary, but make it iconic π¦
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. β absolute length, no cap π
_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 β log but base 10, because she's extra π
$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 β assignment, but make it plain and numerical π
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. β polar angle, she's giving geometry π
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. β conjugate, periodt π
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. β zip energy, but make it complex π¦
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 β integer power, no decimals allowed π
$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 β iykyk π
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. β absolute value, absolute queen π
β¨ abs2 β¨
Returns the square of the absolute value of a number. β absolute value squared, she's squared and she knows it π
β¨ r2C β¨
Signature: (r(); complex [o]c())
convert real to native complex, with an imaginary part of zero β real to complex, imaginary part is zero, no cap β¨
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 β imaginary to complex, real part is zero, iconic π
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).
This page is serving perl v5.38.2 realness, dated 2024-04-10, and it's Ops(3pm) β periodt π β¨
π¦ 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