Ops(3pm)

πŸ“¦
version 2.085 Β· 4 versions
, in ubuntu noble

πŸ’– 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