1Ops(3)                User Contributed Perl Documentation               Ops(3)
2
3
4

NAME

6       PDL::Ops - Fundamental mathematical operators
7

DESCRIPTION

9       This module provides the functions used by PDL to overload the basic
10       mathematical operators ("+ - / *" etc.) and functions ("sin sqrt" etc.)
11
12       It also includes the function "log10", which should be a perl function
13       so that we can overload it!
14
15       Matrix multiplication (the operator "x") is handled by the module
16       PDL::Primitive.
17

SYNOPSIS

19       none
20

FUNCTIONS

22   plus
23         Signature: (a(); b(); [o]c(); int swap)
24
25       add two piddles
26
27          $c = plus $x, $y, 0;     # explicit call with trailing 0
28          $c = $x + $y;           # overloaded call
29          $x->inplace->plus($y,0);  # modify $x inplace
30
31       It can be made to work inplace with the "$x->inplace" syntax.  This
32       function is used to overload the binary "+" operator.  Note that when
33       calling this function explicitly you need to supply a third argument
34       that should generally be zero (see first example).  This restriction is
35       expected to go away in future releases.
36
37       plus processes bad values.  The state of the bad-value flag of the
38       output piddles is unknown.
39
40   mult
41         Signature: (a(); b(); [o]c(); int swap)
42
43       multiply two piddles
44
45          $c = mult $x, $y, 0;     # explicit call with trailing 0
46          $c = $x * $y;           # overloaded call
47          $x->inplace->mult($y,0);  # modify $x inplace
48
49       It can be made to work inplace with the "$x->inplace" syntax.  This
50       function is used to overload the binary "*" operator.  Note that when
51       calling this function explicitly you need to supply a third argument
52       that should generally be zero (see first example).  This restriction is
53       expected to go away in future releases.
54
55       mult processes bad values.  The state of the bad-value flag of the
56       output piddles is unknown.
57
58   minus
59         Signature: (a(); b(); [o]c(); int swap)
60
61       subtract two piddles
62
63          $c = minus $x, $y, 0;     # explicit call with trailing 0
64          $c = $x - $y;           # overloaded call
65          $x->inplace->minus($y,0);  # modify $x inplace
66
67       It can be made to work inplace with the "$x->inplace" syntax.  This
68       function is used to overload the binary "-" operator.  Note that when
69       calling this function explicitly you need to supply a third argument
70       that should generally be zero (see first example).  This restriction is
71       expected to go away in future releases.
72
73       minus processes bad values.  The state of the bad-value flag of the
74       output piddles is unknown.
75
76   divide
77         Signature: (a(); b(); [o]c(); int swap)
78
79       divide two piddles
80
81          $c = divide $x, $y, 0;     # explicit call with trailing 0
82          $c = $x / $y;           # overloaded call
83          $x->inplace->divide($y,0);  # modify $x inplace
84
85       It can be made to work inplace with the "$x->inplace" syntax.  This
86       function is used to overload the binary "/" operator.  Note that when
87       calling this function explicitly you need to supply a third argument
88       that should generally be zero (see first example).  This restriction is
89       expected to go away in future releases.
90
91       divide processes bad values.  The state of the bad-value flag of the
92       output piddles is unknown.
93
94   gt
95         Signature: (a(); b(); [o]c(); int swap)
96
97       the binary > (greater than) operation
98
99          $c = gt $x, $y, 0;     # explicit call with trailing 0
100          $c = $x > $y;           # overloaded call
101          $x->inplace->gt($y,0);  # modify $x inplace
102
103       It can be made to work inplace with the "$x->inplace" syntax.  This
104       function is used to overload the binary ">" operator.  Note that when
105       calling this function explicitly you need to supply a third argument
106       that should generally be zero (see first example).  This restriction is
107       expected to go away in future releases.
108
109       gt processes bad values.  The state of the bad-value flag of the output
110       piddles is unknown.
111
112   lt
113         Signature: (a(); b(); [o]c(); int swap)
114
115       the binary < (less than) operation
116
117          $c = lt $x, $y, 0;     # explicit call with trailing 0
118          $c = $x < $y;           # overloaded call
119          $x->inplace->lt($y,0);  # modify $x inplace
120
121       It can be made to work inplace with the "$x->inplace" syntax.  This
122       function is used to overload the binary "<" operator.  Note that when
123       calling this function explicitly you need to supply a third argument
124       that should generally be zero (see first example).  This restriction is
125       expected to go away in future releases.
126
127       lt processes bad values.  The state of the bad-value flag of the output
128       piddles is unknown.
129
130   le
131         Signature: (a(); b(); [o]c(); int swap)
132
133       the binary <= (less equal) operation
134
135          $c = le $x, $y, 0;     # explicit call with trailing 0
136          $c = $x <= $y;           # overloaded call
137          $x->inplace->le($y,0);  # modify $x inplace
138
139       It can be made to work inplace with the "$x->inplace" syntax.  This
140       function is used to overload the binary "<=" operator.  Note that when
141       calling this function explicitly you need to supply a third argument
142       that should generally be zero (see first example).  This restriction is
143       expected to go away in future releases.
144
145       le processes bad values.  The state of the bad-value flag of the output
146       piddles is unknown.
147
148   ge
149         Signature: (a(); b(); [o]c(); int swap)
150
151       the binary >= (greater equal) operation
152
153          $c = ge $x, $y, 0;     # explicit call with trailing 0
154          $c = $x >= $y;           # overloaded call
155          $x->inplace->ge($y,0);  # modify $x inplace
156
157       It can be made to work inplace with the "$x->inplace" syntax.  This
158       function is used to overload the binary ">=" operator.  Note that when
159       calling this function explicitly you need to supply a third argument
160       that should generally be zero (see first example).  This restriction is
161       expected to go away in future releases.
162
163       ge processes bad values.  The state of the bad-value flag of the output
164       piddles is unknown.
165
166   eq
167         Signature: (a(); b(); [o]c(); int swap)
168
169       binary equal to operation ("==")
170
171          $c = eq $x, $y, 0;     # explicit call with trailing 0
172          $c = $x == $y;           # overloaded call
173          $x->inplace->eq($y,0);  # modify $x inplace
174
175       It can be made to work inplace with the "$x->inplace" syntax.  This
176       function is used to overload the binary "==" operator.  Note that when
177       calling this function explicitly you need to supply a third argument
178       that should generally be zero (see first example).  This restriction is
179       expected to go away in future releases.
180
181       eq processes bad values.  The state of the bad-value flag of the output
182       piddles is unknown.
183
184   ne
185         Signature: (a(); b(); [o]c(); int swap)
186
187       binary not equal to operation ("!=")
188
189          $c = ne $x, $y, 0;     # explicit call with trailing 0
190          $c = $x != $y;           # overloaded call
191          $x->inplace->ne($y,0);  # modify $x inplace
192
193       It can be made to work inplace with the "$x->inplace" syntax.  This
194       function is used to overload the binary "!=" operator.  Note that when
195       calling this function explicitly you need to supply a third argument
196       that should generally be zero (see first example).  This restriction is
197       expected to go away in future releases.
198
199       ne processes bad values.  The state of the bad-value flag of the output
200       piddles is unknown.
201
202   shiftleft
203         Signature: (a(); b(); [o]c(); int swap)
204
205       leftshift $a by $b
206
207          $c = shiftleft $x, $y, 0;     # explicit call with trailing 0
208          $c = $x << $y;           # overloaded call
209          $x->inplace->shiftleft($y,0);  # modify $x inplace
210
211       It can be made to work inplace with the "$x->inplace" syntax.  This
212       function is used to overload the binary "<<" operator.  Note that when
213       calling this function explicitly you need to supply a third argument
214       that should generally be zero (see first example).  This restriction is
215       expected to go away in future releases.
216
217       shiftleft processes bad values.  The state of the bad-value flag of the
218       output piddles is unknown.
219
220   shiftright
221         Signature: (a(); b(); [o]c(); int swap)
222
223       rightshift $a by $b
224
225          $c = shiftright $x, $y, 0;     # explicit call with trailing 0
226          $c = $x >> $y;           # overloaded call
227          $x->inplace->shiftright($y,0);  # modify $x inplace
228
229       It can be made to work inplace with the "$x->inplace" syntax.  This
230       function is used to overload the binary ">>" operator.  Note that when
231       calling this function explicitly you need to supply a third argument
232       that should generally be zero (see first example).  This restriction is
233       expected to go away in future releases.
234
235       shiftright processes bad values.  The state of the bad-value flag of
236       the output piddles is unknown.
237
238   or2
239         Signature: (a(); b(); [o]c(); int swap)
240
241       binary or of two piddles
242
243          $c = or2 $x, $y, 0;     # explicit call with trailing 0
244          $c = $x | $y;           # overloaded call
245          $x->inplace->or2($y,0);  # modify $x inplace
246
247       It can be made to work inplace with the "$x->inplace" syntax.  This
248       function is used to overload the binary "|" operator.  Note that when
249       calling this function explicitly you need to supply a third argument
250       that should generally be zero (see first example).  This restriction is
251       expected to go away in future releases.
252
253       or2 processes bad values.  The state of the bad-value flag of the
254       output piddles is unknown.
255
256   and2
257         Signature: (a(); b(); [o]c(); int swap)
258
259       binary and of two piddles
260
261          $c = and2 $x, $y, 0;     # explicit call with trailing 0
262          $c = $x & $y;           # overloaded call
263          $x->inplace->and2($y,0);  # modify $x inplace
264
265       It can be made to work inplace with the "$x->inplace" syntax.  This
266       function is used to overload the binary "&" operator.  Note that when
267       calling this function explicitly you need to supply a third argument
268       that should generally be zero (see first example).  This restriction is
269       expected to go away in future releases.
270
271       and2 processes bad values.  The state of the bad-value flag of the
272       output piddles is unknown.
273
274   xor
275         Signature: (a(); b(); [o]c(); int swap)
276
277       binary exclusive or of two piddles
278
279          $c = xor $x, $y, 0;     # explicit call with trailing 0
280          $c = $x ^ $y;           # overloaded call
281          $x->inplace->xor($y,0);  # modify $x inplace
282
283       It can be made to work inplace with the "$x->inplace" syntax.  This
284       function is used to overload the binary "^" operator.  Note that when
285       calling this function explicitly you need to supply a third argument
286       that should generally be zero (see first example).  This restriction is
287       expected to go away in future releases.
288
289       xor processes bad values.  The state of the bad-value flag of the
290       output piddles is unknown.
291
292   bitnot
293         Signature: (a(); [o]b())
294
295       unary bit negation
296
297          $y = ~ $x;
298          $x->inplace->bitnot;  # modify $x inplace
299
300       It can be made to work inplace with the "$x->inplace" syntax.  This
301       function is used to overload the unary "~" operator/function.
302
303       bitnot processes bad values.  It will set the bad-value flag of all
304       output piddles if the flag is set for any of the input piddles.
305
306   power
307         Signature: (a(); b(); [o]c(); int swap)
308
309       raise piddle $a to the power $b
310
311          $c = $x->power($y,0); # explicit function call
312          $c = $a ** $b;    # overloaded use
313          $x->inplace->power($y,0);     # modify $x inplace
314
315       It can be made to work inplace with the "$x->inplace" syntax.  This
316       function is used to overload the binary "**" function.  Note that when
317       calling this function explicitly you need to supply a third argument
318       that should generally be zero (see first example).  This restriction is
319       expected to go away in future releases.
320
321       power processes bad values.  The state of the bad-value flag of the
322       output piddles is unknown.
323
324   atan2
325         Signature: (a(); b(); [o]c(); int swap)
326
327       elementwise "atan2" of two piddles
328
329          $c = $x->atan2($y,0); # explicit function call
330          $c = atan2 $a, $b;    # overloaded use
331          $x->inplace->atan2($y,0);     # modify $x inplace
332
333       It can be made to work inplace with the "$x->inplace" syntax.  This
334       function is used to overload the binary "atan2" function.  Note that
335       when calling this function explicitly you need to supply a third
336       argument that should generally be zero (see first example).  This
337       restriction is expected to go away in future releases.
338
339       atan2 processes bad values.  The state of the bad-value flag of the
340       output piddles is unknown.
341
342   modulo
343         Signature: (a(); b(); [o]c(); int swap)
344
345       elementwise "modulo" operation
346
347          $c = $x->modulo($y,0); # explicit function call
348          $c = $a % $b;    # overloaded use
349          $x->inplace->modulo($y,0);     # modify $x inplace
350
351       It can be made to work inplace with the "$x->inplace" syntax.  This
352       function is used to overload the binary "%" function.  Note that when
353       calling this function explicitly you need to supply a third argument
354       that should generally be zero (see first example).  This restriction is
355       expected to go away in future releases.
356
357       modulo processes bad values.  The state of the bad-value flag of the
358       output piddles is unknown.
359
360   spaceship
361         Signature: (a(); b(); [o]c(); int swap)
362
363       elementwise "<=>" operation
364
365          $c = $x->spaceship($y,0); # explicit function call
366          $c = $a <=> $b;    # overloaded use
367          $x->inplace->spaceship($y,0);     # modify $x inplace
368
369       It can be made to work inplace with the "$x->inplace" syntax.  This
370       function is used to overload the binary "<=>" function.  Note that when
371       calling this function explicitly you need to supply a third argument
372       that should generally be zero (see first example).  This restriction is
373       expected to go away in future releases.
374
375       spaceship processes bad values.  The state of the bad-value flag of the
376       output piddles is unknown.
377
378   sqrt
379         Signature: (a(); [o]b())
380
381       elementwise square root
382
383          $y = sqrt $x;
384          $x->inplace->sqrt;  # modify $x inplace
385
386       It can be made to work inplace with the "$x->inplace" syntax.  This
387       function is used to overload the unary "sqrt" operator/function.
388
389       sqrt processes bad values.  It will set the bad-value flag of all
390       output piddles if the flag is set for any of the input piddles.
391
392   abs
393         Signature: (a(); [o]b())
394
395       elementwise absolute value
396
397          $y = abs $x;
398          $x->inplace->abs;  # modify $x inplace
399
400       It can be made to work inplace with the "$x->inplace" syntax.  This
401       function is used to overload the unary "abs" operator/function.
402
403       abs processes bad values.  It will set the bad-value flag of all output
404       piddles if the flag is set for any of the input piddles.
405
406   sin
407         Signature: (a(); [o]b())
408
409       the sin function
410
411          $y = sin $x;
412          $x->inplace->sin;  # modify $x inplace
413
414       It can be made to work inplace with the "$x->inplace" syntax.  This
415       function is used to overload the unary "sin" operator/function.
416
417       sin processes bad values.  It will set the bad-value flag of all output
418       piddles if the flag is set for any of the input piddles.
419
420   cos
421         Signature: (a(); [o]b())
422
423       the cos function
424
425          $y = cos $x;
426          $x->inplace->cos;  # modify $x inplace
427
428       It can be made to work inplace with the "$x->inplace" syntax.  This
429       function is used to overload the unary "cos" operator/function.
430
431       cos processes bad values.  It will set the bad-value flag of all output
432       piddles if the flag is set for any of the input piddles.
433
434   not
435         Signature: (a(); [o]b())
436
437       the elementwise not operation
438
439          $y = ! $x;
440          $x->inplace->not;  # modify $x inplace
441
442       It can be made to work inplace with the "$x->inplace" syntax.  This
443       function is used to overload the unary "!" operator/function.
444
445       not processes bad values.  It will set the bad-value flag of all output
446       piddles if the flag is set for any of the input piddles.
447
448   exp
449         Signature: (a(); [o]b())
450
451       the exponential function
452
453          $y = exp $x;
454          $x->inplace->exp;  # modify $x inplace
455
456       It can be made to work inplace with the "$x->inplace" syntax.  This
457       function is used to overload the unary "exp" operator/function.
458
459       exp processes bad values.  It will set the bad-value flag of all output
460       piddles if the flag is set for any of the input piddles.
461
462   log
463         Signature: (a(); [o]b())
464
465       the natural logarithm
466
467          $y = log $x;
468          $x->inplace->log;  # modify $x inplace
469
470       It can be made to work inplace with the "$x->inplace" syntax.  This
471       function is used to overload the unary "log" operator/function.
472
473       log processes bad values.  It will set the bad-value flag of all output
474       piddles if the flag is set for any of the input piddles.
475
476   log10
477         Signature: (a(); [o]b())
478
479       the base 10 logarithm
480
481          $y = log10 $x;
482          $x->inplace->log10;  # modify $x inplace
483
484       It can be made to work inplace with the "$x->inplace" syntax.  This
485       function is used to overload the unary "log10" operator/function.
486
487       log10 processes bad values.  It will set the bad-value flag of all
488       output piddles if the flag is set for any of the input piddles.
489
490   assgn
491         Signature: (a(); [o]b())
492
493       Plain numerical assignment. This is used to implement the ".=" operator
494
495       If "a" is a child piddle (e.g., the result of a slice) and bad values
496       are generated in "b", the bad value flag is set in "b", but it is NOT
497       automatically propagated back to the parent of "a".  The following
498       idiom ensures that the badflag is propagated back to the parent of "a":
499
500        $pdl->slice(":,(1)") .= PDL::Bad_aware_func();
501        $pdl->badflag(1);
502        $pdl->check_badflag();
503
504       This is unnecessary if $pdl->badflag is known to be 1 before the slice
505       is performed.
506
507       See http://pdl.perl.org/PDLdocs/BadValues.html#dataflow_of_the_badflag
508       for details.
509
510   ipow
511         Signature: (a(); b(); [o] ans())
512
513       raise piddle $a to integer power $b
514
515          $c = $x->ipow($y,0);     # explicit function call
516          $c = ipow $x, $y;
517          $x->inplace->ipow($y,0);  # modify $x inplace
518
519       It can be made to work inplace with the "$x->inplace" syntax.  Note
520       that when calling this function explicitly you need to supply a third
521       argument that should generally be zero (see first example).  This
522       restriction is expected to go away in future releases.
523
524       Algorithm from Wikipedia
525       <http://en.wikipedia.org/wiki/Exponentiation_by_squaring>
526
527       ipow does not process bad values.  It will set the bad-value flag of
528       all output piddles if the flag is set for any of the input piddles.
529

AUTHOR

531       Tuomas J. Lukka (lukka@fas.harvard.edu), Karl Glazebrook
532       (kgb@aaoepp.aao.gov.au), Doug Hunt (dhunt@ucar.edu), Christian Soeller
533       (c.soeller@auckland.ac.nz), Doug Burke (burke@ifa.hawaii.edu), and
534       Craig DeForest (deforest@boulder.swri.edu).
535
536
537
538perl v5.32.1                      2021-02-15                            Ops(3)
Impressum