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 ndarrays
26
27          $c = $x + $y;        # overloaded call
28          $c = plus $x, $y;     # explicit call with default swap of 0
29          $c = plus $x, $y, 1;  # explicit call with trailing 1 to swap args
30          $x->inplace->plus($y); # modify $x inplace
31
32       It can be made to work inplace with the "$x->inplace" syntax.  This
33       function is used to overload the binary "+" operator.  As of 2.065,
34       when calling this function explicitly you can omit the third argument
35       (see second example), or supply it (see third one).
36
37       plus processes bad values.  The state of the bad-value flag of the
38       output ndarrays is unknown.
39
40   mult
41         Signature: (a(); b(); [o]c(); int swap)
42
43       multiply two ndarrays
44
45          $c = $x * $y;        # overloaded call
46          $c = mult $x, $y;     # explicit call with default swap of 0
47          $c = mult $x, $y, 1;  # explicit call with trailing 1 to swap args
48          $x->inplace->mult($y); # modify $x inplace
49
50       It can be made to work inplace with the "$x->inplace" syntax.  This
51       function is used to overload the binary "*" operator.  As of 2.065,
52       when calling this function explicitly you can omit the third argument
53       (see second example), or supply it (see third one).
54
55       mult processes bad values.  The state of the bad-value flag of the
56       output ndarrays is unknown.
57
58   minus
59         Signature: (a(); b(); [o]c(); int swap)
60
61       subtract two ndarrays
62
63          $c = $x - $y;        # overloaded call
64          $c = minus $x, $y;     # explicit call with default swap of 0
65          $c = minus $x, $y, 1;  # explicit call with trailing 1 to swap args
66          $x->inplace->minus($y); # modify $x inplace
67
68       It can be made to work inplace with the "$x->inplace" syntax.  This
69       function is used to overload the binary "-" operator.  As of 2.065,
70       when calling this function explicitly you can omit the third argument
71       (see second example), or supply it (see third one).
72
73       minus processes bad values.  The state of the bad-value flag of the
74       output ndarrays is unknown.
75
76   divide
77         Signature: (a(); b(); [o]c(); int swap)
78
79       divide two ndarrays
80
81          $c = $x / $y;        # overloaded call
82          $c = divide $x, $y;     # explicit call with default swap of 0
83          $c = divide $x, $y, 1;  # explicit call with trailing 1 to swap args
84          $x->inplace->divide($y); # modify $x inplace
85
86       It can be made to work inplace with the "$x->inplace" syntax.  This
87       function is used to overload the binary "/" operator.  As of 2.065,
88       when calling this function explicitly you can omit the third argument
89       (see second example), or supply it (see third one).
90
91       divide processes bad values.  The state of the bad-value flag of the
92       output ndarrays is unknown.
93
94   gt
95         Signature: (a(); b(); [o]c(); int swap)
96
97       the binary > (greater than) operation
98
99          $c = $x > $y;        # overloaded call
100          $c = gt $x, $y;     # explicit call with default swap of 0
101          $c = gt $x, $y, 1;  # explicit call with trailing 1 to swap args
102          $x->inplace->gt($y); # modify $x inplace
103
104       It can be made to work inplace with the "$x->inplace" syntax.  This
105       function is used to overload the binary ">" operator.  As of 2.065,
106       when calling this function explicitly you can omit the third argument
107       (see second example), or supply it (see third one).
108
109       gt processes bad values.  The state of the bad-value flag of the output
110       ndarrays is unknown.
111
112   lt
113         Signature: (a(); b(); [o]c(); int swap)
114
115       the binary < (less than) operation
116
117          $c = $x < $y;        # overloaded call
118          $c = lt $x, $y;     # explicit call with default swap of 0
119          $c = lt $x, $y, 1;  # explicit call with trailing 1 to swap args
120          $x->inplace->lt($y); # modify $x inplace
121
122       It can be made to work inplace with the "$x->inplace" syntax.  This
123       function is used to overload the binary "<" operator.  As of 2.065,
124       when calling this function explicitly you can omit the third argument
125       (see second example), or supply it (see third one).
126
127       lt processes bad values.  The state of the bad-value flag of the output
128       ndarrays is unknown.
129
130   le
131         Signature: (a(); b(); [o]c(); int swap)
132
133       the binary <= (less equal) operation
134
135          $c = $x <= $y;        # overloaded call
136          $c = le $x, $y;     # explicit call with default swap of 0
137          $c = le $x, $y, 1;  # explicit call with trailing 1 to swap args
138          $x->inplace->le($y); # modify $x inplace
139
140       It can be made to work inplace with the "$x->inplace" syntax.  This
141       function is used to overload the binary "<=" operator.  As of 2.065,
142       when calling this function explicitly you can omit the third argument
143       (see second example), or supply it (see third one).
144
145       le processes bad values.  The state of the bad-value flag of the output
146       ndarrays is unknown.
147
148   ge
149         Signature: (a(); b(); [o]c(); int swap)
150
151       the binary >= (greater equal) operation
152
153          $c = $x >= $y;        # overloaded call
154          $c = ge $x, $y;     # explicit call with default swap of 0
155          $c = ge $x, $y, 1;  # explicit call with trailing 1 to swap args
156          $x->inplace->ge($y); # modify $x inplace
157
158       It can be made to work inplace with the "$x->inplace" syntax.  This
159       function is used to overload the binary ">=" operator.  As of 2.065,
160       when calling this function explicitly you can omit the third argument
161       (see second example), or supply it (see third one).
162
163       ge processes bad values.  The state of the bad-value flag of the output
164       ndarrays is unknown.
165
166   eq
167         Signature: (a(); b(); [o]c(); int swap)
168
169       binary equal to operation ("==")
170
171          $c = $x == $y;        # overloaded call
172          $c = eq $x, $y;     # explicit call with default swap of 0
173          $c = eq $x, $y, 1;  # explicit call with trailing 1 to swap args
174          $x->inplace->eq($y); # modify $x inplace
175
176       It can be made to work inplace with the "$x->inplace" syntax.  This
177       function is used to overload the binary "==" operator.  As of 2.065,
178       when calling this function explicitly you can omit the third argument
179       (see second example), or supply it (see third one).
180
181       eq processes bad values.  The state of the bad-value flag of the output
182       ndarrays is unknown.
183
184   ne
185         Signature: (a(); b(); [o]c(); int swap)
186
187       binary not equal to operation ("!=")
188
189          $c = $x != $y;        # overloaded call
190          $c = ne $x, $y;     # explicit call with default swap of 0
191          $c = ne $x, $y, 1;  # explicit call with trailing 1 to swap args
192          $x->inplace->ne($y); # modify $x inplace
193
194       It can be made to work inplace with the "$x->inplace" syntax.  This
195       function is used to overload the binary "!=" operator.  As of 2.065,
196       when calling this function explicitly you can omit the third argument
197       (see second example), or supply it (see third one).
198
199       ne processes bad values.  The state of the bad-value flag of the output
200       ndarrays is unknown.
201
202   shiftleft
203         Signature: (a(); b(); [o]c(); int swap)
204
205       leftshift $a by $b
206
207          $c = $x << $y;        # overloaded call
208          $c = shiftleft $x, $y;     # explicit call with default swap of 0
209          $c = shiftleft $x, $y, 1;  # explicit call with trailing 1 to swap args
210          $x->inplace->shiftleft($y); # modify $x inplace
211
212       It can be made to work inplace with the "$x->inplace" syntax.  This
213       function is used to overload the binary "<<" operator.  As of 2.065,
214       when calling this function explicitly you can omit the third argument
215       (see second example), or supply it (see third one).
216
217       shiftleft processes bad values.  The state of the bad-value flag of the
218       output ndarrays is unknown.
219
220   shiftright
221         Signature: (a(); b(); [o]c(); int swap)
222
223       rightshift $a by $b
224
225          $c = $x >> $y;        # overloaded call
226          $c = shiftright $x, $y;     # explicit call with default swap of 0
227          $c = shiftright $x, $y, 1;  # explicit call with trailing 1 to swap args
228          $x->inplace->shiftright($y); # modify $x inplace
229
230       It can be made to work inplace with the "$x->inplace" syntax.  This
231       function is used to overload the binary ">>" operator.  As of 2.065,
232       when calling this function explicitly you can omit the third argument
233       (see second example), or supply it (see third one).
234
235       shiftright processes bad values.  The state of the bad-value flag of
236       the output ndarrays is unknown.
237
238   or2
239         Signature: (a(); b(); [o]c(); int swap)
240
241       binary or of two ndarrays
242
243          $c = $x | $y;        # overloaded call
244          $c = or2 $x, $y;     # explicit call with default swap of 0
245          $c = or2 $x, $y, 1;  # explicit call with trailing 1 to swap args
246          $x->inplace->or2($y); # modify $x inplace
247
248       It can be made to work inplace with the "$x->inplace" syntax.  This
249       function is used to overload the binary "|" operator.  As of 2.065,
250       when calling this function explicitly you can omit the third argument
251       (see second example), or supply it (see third one).
252
253       or2 processes bad values.  The state of the bad-value flag of the
254       output ndarrays is unknown.
255
256   and2
257         Signature: (a(); b(); [o]c(); int swap)
258
259       binary and of two ndarrays
260
261          $c = $x & $y;        # overloaded call
262          $c = and2 $x, $y;     # explicit call with default swap of 0
263          $c = and2 $x, $y, 1;  # explicit call with trailing 1 to swap args
264          $x->inplace->and2($y); # modify $x inplace
265
266       It can be made to work inplace with the "$x->inplace" syntax.  This
267       function is used to overload the binary "&" operator.  As of 2.065,
268       when calling this function explicitly you can omit the third argument
269       (see second example), or supply it (see third one).
270
271       and2 processes bad values.  The state of the bad-value flag of the
272       output ndarrays is unknown.
273
274   xor
275         Signature: (a(); b(); [o]c(); int swap)
276
277       binary exclusive or of two ndarrays
278
279          $c = $x ^ $y;        # overloaded call
280          $c = xor $x, $y;     # explicit call with default swap of 0
281          $c = xor $x, $y, 1;  # explicit call with trailing 1 to swap args
282          $x->inplace->xor($y); # modify $x inplace
283
284       It can be made to work inplace with the "$x->inplace" syntax.  This
285       function is used to overload the binary "^" operator.  As of 2.065,
286       when calling this function explicitly you can omit the third argument
287       (see second example), or supply it (see third one).
288
289       xor processes bad values.  The state of the bad-value flag of the
290       output ndarrays 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 ndarrays if the flag is set for any of the input ndarrays.
305
306   power
307         Signature: (a(); b(); [o]c(); int swap)
308
309       raise ndarray $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 ndarrays is unknown.
323
324   atan2
325         Signature: (a(); b(); [o]c(); int swap)
326
327       elementwise "atan2" of two ndarrays
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 ndarrays 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 ndarrays 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 ndarrays 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 ndarrays if the flag is set for any of the input ndarrays.
391
392   sin
393         Signature: (a(); [o]b())
394
395       the sin function
396
397          $y = sin $x;
398          $x->inplace->sin;  # 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 "sin" operator/function.
402
403       sin processes bad values.  It will set the bad-value flag of all output
404       ndarrays if the flag is set for any of the input ndarrays.
405
406   cos
407         Signature: (a(); [o]b())
408
409       the cos function
410
411          $y = cos $x;
412          $x->inplace->cos;  # 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 "cos" operator/function.
416
417       cos processes bad values.  It will set the bad-value flag of all output
418       ndarrays if the flag is set for any of the input ndarrays.
419
420   not
421         Signature: (a(); [o]b())
422
423       the elementwise not operation
424
425          $y = ! $x;
426          $x->inplace->not;  # 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 "!" operator/function.
430
431       not processes bad values.  It will set the bad-value flag of all output
432       ndarrays if the flag is set for any of the input ndarrays.
433
434   exp
435         Signature: (a(); [o]b())
436
437       the exponential function
438
439          $y = exp $x;
440          $x->inplace->exp;  # 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 "exp" operator/function.
444
445       exp processes bad values.  It will set the bad-value flag of all output
446       ndarrays if the flag is set for any of the input ndarrays.
447
448   log
449         Signature: (a(); [o]b())
450
451       the natural logarithm
452
453          $y = log $x;
454          $x->inplace->log;  # 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 "log" operator/function.
458
459       log processes bad values.  It will set the bad-value flag of all output
460       ndarrays if the flag is set for any of the input ndarrays.
461
462   re
463         Signature: (complexv(); real [o]b())
464
465       Returns the real part of a complex number.
466
467       re processes bad values.  It will set the bad-value flag of all output
468       ndarrays if the flag is set for any of the input ndarrays.
469
470   im
471         Signature: (complexv(); real [o]b())
472
473       Returns the imaginary part of a complex number.
474
475       im processes bad values.  It will set the bad-value flag of all output
476       ndarrays if the flag is set for any of the input ndarrays.
477
478   _cabs
479         Signature: (complexv(); real [o]b())
480
481       Returns the absolute (length) of a complex number.
482
483       _cabs processes bad values.  It will set the bad-value flag of all
484       output ndarrays if the flag is set for any of the input ndarrays.
485
486   log10
487         Signature: (a(); [o]b())
488
489       the base 10 logarithm
490
491          $y = log10 $x;
492          $x->inplace->log10;  # modify $x inplace
493
494       It can be made to work inplace with the "$x->inplace" syntax.  This
495       function is used to overload the unary "log10" operator/function.
496
497       log10 processes bad values.  It will set the bad-value flag of all
498       output ndarrays if the flag is set for any of the input ndarrays.
499
500   assgn
501         Signature: (a(); [o]b())
502
503       Plain numerical assignment. This is used to implement the ".=" operator
504
505       If "a" is a child ndarray (e.g., the result of a slice) and bad values
506       are generated in "b", the bad value flag is set in "b", but it is NOT
507       automatically propagated back to the parent of "a".  The following
508       idiom ensures that the badflag is propagated back to the parent of "a":
509
510        $pdl->slice(":,(1)") .= PDL::Bad_aware_func();
511        $pdl->badflag(1);
512        $pdl->check_badflag();
513
514       This is unnecessary if $pdl->badflag is known to be 1 before the slice
515       is performed.
516
517       See http://pdl.perl.org/PDLdocs/BadValues.html#dataflow_of_the_badflag
518       for details.
519
520   carg
521         Signature: (complexv(); real [o]b())
522
523       Returns the polar angle of a complex number.
524
525       carg processes bad values.  It will set the bad-value flag of all
526       output ndarrays if the flag is set for any of the input ndarrays.
527
528   conj
529         Signature: (complexv();  [o]b())
530
531       complex conjugate.
532
533       conj processes bad values.  It will set the bad-value flag of all
534       output ndarrays if the flag is set for any of the input ndarrays.
535
536   czip
537         Signature: (r(); i(); complex [o]c())
538
539       convert real, imaginary to native complex, (sort of) like LISP zip
540       function. Will add the "r" ndarray to "i" times the "i" ndarray. Only
541       takes real ndarrays as input.
542
543       czip does not process bad values.  It will set the bad-value flag of
544       all output ndarrays if the flag is set for any of the input ndarrays.
545
546   ipow
547         Signature: (a(); indx b(); [o] ans())
548
549       raise ndarray $a to integer power $b
550
551          $c = $x->ipow($y,0);     # explicit function call
552          $c = ipow $x, $y;
553          $x->inplace->ipow($y,0);  # modify $x inplace
554
555       It can be made to work inplace with the "$x->inplace" syntax.  Note
556       that when calling this function explicitly you need to supply a third
557       argument that should generally be zero (see first example).  This
558       restriction is expected to go away in future releases.
559
560       Algorithm from Wikipedia
561       <http://en.wikipedia.org/wiki/Exponentiation_by_squaring>
562
563       ipow does not process bad values.  It will set the bad-value flag of
564       all output ndarrays if the flag is set for any of the input ndarrays.
565
566   abs
567       Returns the absolute value of a number.
568
569   abs2
570       Returns the square of the absolute value of a number.
571
572   r2C
573         Signature: (r(); complex [o]c())
574
575       convert real to native complex, with an imaginary part of zero
576
577       r2C does not process bad values.  It will set the bad-value flag of all
578       output ndarrays if the flag is set for any of the input ndarrays.
579
580   i2C
581         Signature: (i(); complex [o]c())
582
583       convert imaginary to native complex, with a real part of zero
584
585       i2C does not process bad values.  It will set the bad-value flag of all
586       output ndarrays if the flag is set for any of the input ndarrays.
587

AUTHOR

589       Tuomas J. Lukka (lukka@fas.harvard.edu), Karl Glazebrook
590       (kgb@aaoepp.aao.gov.au), Doug Hunt (dhunt@ucar.edu), Christian Soeller
591       (c.soeller@auckland.ac.nz), Doug Burke (burke@ifa.hawaii.edu), and
592       Craig DeForest (deforest@boulder.swri.edu).
593
594
595
596perl v5.34.0                      2022-02-28                            Ops(3)
Impressum