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.  It will set the bad-value flag of all
38       output ndarrays if the flag is set for any of the input ndarrays.
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.  It will set the bad-value flag of all
56       output ndarrays if the flag is set for any of the input ndarrays.
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.  It will set the bad-value flag of all
74       output ndarrays if the flag is set for any of the input ndarrays.
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.  It will set the bad-value flag of all
92       output ndarrays if the flag is set for any of the input ndarrays.
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.  It will set the bad-value flag of all output
110       ndarrays if the flag is set for any of the input ndarrays.
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.  It will set the bad-value flag of all output
128       ndarrays if the flag is set for any of the input ndarrays.
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.  It will set the bad-value flag of all output
146       ndarrays if the flag is set for any of the input ndarrays.
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.  It will set the bad-value flag of all output
164       ndarrays if the flag is set for any of the input ndarrays.
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.  It will set the bad-value flag of all output
182       ndarrays if the flag is set for any of the input ndarrays.
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.  It will set the bad-value flag of all output
200       ndarrays if the flag is set for any of the input ndarrays.
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.  It will set the bad-value flag of all
218       output ndarrays if the flag is set for any of the input ndarrays.
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.  It will set the bad-value flag of all
236       output ndarrays if the flag is set for any of the input ndarrays.
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.  It will set the bad-value flag of all output
254       ndarrays if the flag is set for any of the input ndarrays.
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.  It will set the bad-value flag of all
272       output ndarrays if the flag is set for any of the input ndarrays.
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.  It will set the bad-value flag of all output
290       ndarrays if the flag is set for any of the input ndarrays.
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);    # explicit call with default swap of 0
312          $c = $x->power($y, 1); # explicit call with trailing 1 to swap args
313          $c = $a ** $b;    # overloaded use
314          $x->inplace->power($y,0);     # modify $x inplace
315
316       It can be made to work inplace with the "$x->inplace" syntax.  This
317       function is used to overload the binary "**" function.  As of 2.065,
318       when calling this function explicitly you can omit the third argument
319       (see first example), or supply it (see second one).
320
321       power processes bad values.  It will set the bad-value flag of all
322       output ndarrays if the flag is set for any of the input ndarrays.
323
324   atan2
325         Signature: (a(); b(); [o]c(); int swap)
326
327       elementwise "atan2" of two ndarrays
328
329          $c = $x->atan2($y);    # explicit call with default swap of 0
330          $c = $x->atan2($y, 1); # explicit call with trailing 1 to swap args
331          $c = atan2 $a, $b;    # overloaded use
332          $x->inplace->atan2($y,0);     # modify $x inplace
333
334       It can be made to work inplace with the "$x->inplace" syntax.  This
335       function is used to overload the binary "atan2" function.  As of 2.065,
336       when calling this function explicitly you can omit the third argument
337       (see first example), or supply it (see second one).
338
339       atan2 processes bad values.  It will set the bad-value flag of all
340       output ndarrays if the flag is set for any of the input ndarrays.
341
342   modulo
343         Signature: (a(); b(); [o]c(); int swap)
344
345       elementwise "modulo" operation
346
347          $c = $x->modulo($y);    # explicit call with default swap of 0
348          $c = $x->modulo($y, 1); # explicit call with trailing 1 to swap args
349          $c = $a % $b;    # overloaded use
350          $x->inplace->modulo($y,0);     # modify $x inplace
351
352       It can be made to work inplace with the "$x->inplace" syntax.  This
353       function is used to overload the binary "%" function.  As of 2.065,
354       when calling this function explicitly you can omit the third argument
355       (see first example), or supply it (see second one).
356
357       modulo processes bad values.  It will set the bad-value flag of all
358       output ndarrays if the flag is set for any of the input ndarrays.
359
360   spaceship
361         Signature: (a(); b(); [o]c(); int swap)
362
363       elementwise "<=>" operation
364
365          $c = $x->spaceship($y);    # explicit call with default swap of 0
366          $c = $x->spaceship($y, 1); # explicit call with trailing 1 to swap args
367          $c = $a <=> $b;    # overloaded use
368          $x->inplace->spaceship($y,0);     # modify $x inplace
369
370       It can be made to work inplace with the "$x->inplace" syntax.  This
371       function is used to overload the binary "<=>" function.  As of 2.065,
372       when calling this function explicitly you can omit the third argument
373       (see first example), or supply it (see second one).
374
375       spaceship processes bad values.  It will set the bad-value flag of all
376       output ndarrays if the flag is set for any of the input ndarrays.
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       assgn processes bad values.  It will set the bad-value flag of all
506       output ndarrays if the flag is set for any of the input ndarrays.
507
508   carg
509         Signature: (complexv(); real [o]b())
510
511       Returns the polar angle of a complex number.
512
513       carg processes bad values.  It will set the bad-value flag of all
514       output ndarrays if the flag is set for any of the input ndarrays.
515
516   conj
517         Signature: (complexv();  [o]b())
518
519       complex conjugate.
520
521       conj processes bad values.  It will set the bad-value flag of all
522       output ndarrays if the flag is set for any of the input ndarrays.
523
524   czip
525         Signature: (r(); i(); complex [o]c())
526
527       convert real, imaginary to native complex, (sort of) like LISP zip
528       function. Will add the "r" ndarray to "i" times the "i" ndarray. Only
529       takes real ndarrays as input.
530
531       czip does not process bad values.  It will set the bad-value flag of
532       all output ndarrays if the flag is set for any of the input ndarrays.
533
534   ipow
535         Signature: (a(); indx b(); [o] ans())
536
537       raise ndarray $a to integer power $b
538
539          $c = $x->ipow($y);     # as method
540          $c = ipow $x, $y;
541          $x->inplace->ipow($y);  # modify $x inplace
542
543       It can be made to work inplace with the "$x->inplace" syntax.
544
545       Algorithm from Wikipedia
546       <http://en.wikipedia.org/wiki/Exponentiation_by_squaring>
547
548       ipow does not process bad values.  It will set the bad-value flag of
549       all output ndarrays if the flag is set for any of the input ndarrays.
550
551   abs
552       Returns the absolute value of a number.
553
554   abs2
555       Returns the square of the absolute value of a number.
556
557   r2C
558         Signature: (r(); complex [o]c())
559
560       convert real to native complex, with an imaginary part of zero
561
562       r2C does not process bad values.  It will set the bad-value flag of all
563       output ndarrays if the flag is set for any of the input ndarrays.
564
565   i2C
566         Signature: (i(); complex [o]c())
567
568       convert imaginary to native complex, with a real part of zero
569
570       i2C does not process bad values.  It will set the bad-value flag of all
571       output ndarrays if the flag is set for any of the input ndarrays.
572

AUTHOR

574       Tuomas J. Lukka (lukka@fas.harvard.edu), Karl Glazebrook
575       (kgb@aaoepp.aao.gov.au), Doug Hunt (dhunt@ucar.edu), Christian Soeller
576       (c.soeller@auckland.ac.nz), Doug Burke (burke@ifa.hawaii.edu), and
577       Craig DeForest (deforest@boulder.swri.edu).
578
579
580
581perl v5.36.0                      2023-01-20                            Ops(3)
Impressum